diff -uNr old/cfg.cxx new/cfg.cxx --- old/cfg.cxx 2007-09-24 17:35:58.000000000 +0800 +++ new/cfg.cxx 2007-09-21 15:25:44.000000000 +0800 @@ -5380,7 +5380,9 @@ aBtnOK ( this, ResId( BTN_OK ) ), aBtnCancel ( this, ResId( BTN_CANCEL ) ), aBtnHelp ( this, ResId( BTN_HELP ) ), - aBtnImport ( this, ResId( BTN_IMPORT ) ), + aBtnImport ( this, ResId( BTN_IMPORT ) ), + aBtnDelete ( this, ResId( BTN_DELETE ) ), + aFlSeparator ( this, ResId( FL_SEPARATOR ) ), m_xImageManager ( rXImageManager ), m_xParentImageManager( rXParentImageManager ) { @@ -5558,8 +5560,10 @@ ++pConstIter; } + aBtnDelete.Enable( FALSE ); aTbSymbol.SetSelectHdl( LINK(this, SvxIconSelectorDialog, SelectHdl) ); aBtnImport.SetClickHdl( LINK(this, SvxIconSelectorDialog, ImportHdl) ); + aBtnDelete.SetClickHdl( LINK(this, SvxIconSelectorDialog, DeleteHdl) ); } SvxIconSelectorDialog::~SvxIconSelectorDialog() @@ -5617,6 +5621,16 @@ USHORT nId = aTbSymbol.GetCurItemId(); aTbSymbol.CheckItem( nId ); + + ::rtl::OUString aSelImageText = aTbSymbol.GetItemText( nId ); + if ( m_xImportedImageManager->hasImage( GetImageType(), aSelImageText ) ) + { + aBtnDelete.Enable( TRUE ); + } + else + { + aBtnDelete.Enable( FALSE ); + } return 0; } @@ -5651,29 +5665,175 @@ return 0; } +IMPL_LINK( SvxIconSelectorDialog, DeleteHdl, PushButton *, pButton ) +{ + (void)pButton; + + OUString message = String( SVX_RES( RID_SVXSTR_DELETE_ICON_CONFIRM ) ); + bool ret = WarningBox( this, WinBits(WB_OK_CANCEL), message ).Execute(); + + if ( ret == RET_OK ) + { + USHORT nCount = aTbSymbol.GetItemCount(); + + for (USHORT n = 0; n < nCount; n++ ) + { + USHORT nId = aTbSymbol.GetItemId( n ); + + if ( aTbSymbol.IsItemChecked( nId ) ) + { + ::rtl::OUString aSelImageText = aTbSymbol.GetItemText( nId ); + uno::Sequence< OUString > URLs(1); + URLs[0] = aSelImageText; + aTbSymbol.RemoveItem( aTbSymbol.GetItemPos( nId ) ); + m_xImportedImageManager->removeImages( GetImageType(), URLs ); + uno::Reference< css::ui::XUIConfigurationPersistence > + xConfigPersistence( m_xImportedImageManager, uno::UNO_QUERY ); + if ( xConfigPersistence.is() && xConfigPersistence->isModified() ) + { + xConfigPersistence->store(); + } + break; + } + } + } + return 0; +} + void SvxIconSelectorDialog::ImportGraphics( const uno::Sequence< OUString >& rPaths ) { uno::Sequence< OUString > rejected( rPaths.getLength() ); sal_Int32 rejectedCount = 0; + USHORT ret = 0, nId, nCount; + sal_Int32 aIndex; + OUString aIconName; + uno::Sequence< OUString > URLs(1); + uno::Sequence< uno::Reference > aImportGraph( 1 ); + uno::Sequence< beans::PropertyValue > aMediaProps( 1 ); + aMediaProps[0].Name = ::rtl::OUString::createFromAscii("URL"); + uno::Reference< css::ui::XUIConfigurationPersistence > + xConfigPer( m_xImportedImageManager, uno::UNO_QUERY ); + if ( rPaths.getLength() == 1 ) { - if ( ImportGraphic( rPaths[0] ) == FALSE ) + if ( m_xImportedImageManager->hasImage( GetImageType(), rPaths[0] ) ) + { + aIndex = rPaths[0].lastIndexOf( '/' ); + aIconName = rPaths[0].copy( aIndex+1 ); + ret = SvxIconReplacementDialog( this, aIconName ).ShowDialog(); + if ( ret == 2 ) + { + nCount = aTbSymbol.GetItemCount(); + for (USHORT n = 0; n < nCount; n++ ) + { + nId = aTbSymbol.GetItemId( n ); + + if ( OUString( aTbSymbol.GetItemText( nId ) ) == rPaths[0] ) + { + URLs[0] = rPaths[0]; + aTbSymbol.RemoveItem( aTbSymbol.GetItemPos( nId ) ); + aMediaProps[0].Value <<= rPaths[0]; + aImportGraph[ 0 ] = m_xGraphProvider->queryGraphic( aMediaProps ); + aTbSymbol.InsertItem( nId, Image( aImportGraph[ 0 ] ), rPaths[0], 0, 0 ); + m_xImportedImageManager->replaceImages( GetImageType(), URLs, aImportGraph ); + if ( xConfigPer.is() && xConfigPer->isModified() ) + { + xConfigPer->store(); + break; + } + } + } + } + } + else { - rejected[0] = rPaths[0]; - rejectedCount = 1; + if ( ImportGraphic( rPaths[0] ) == FALSE ) + { + rejected[0] = rPaths[0]; + rejectedCount = 1; + } } } else { - for ( sal_Int32 i = 1; i < rPaths.getLength(); i++ ) + for ( sal_Int32 i = 1; i < rPaths.getLength(); i++ ) { - bool result = ImportGraphic( rPaths[0] + OUString::createFromAscii("/") + rPaths[i] ); - if ( result == FALSE ) + ::rtl::OUString aPath = rPaths[0] + OUString::createFromAscii("/") + rPaths[i]; + if ( m_xImportedImageManager->hasImage( GetImageType(), aPath ) ) { - rejected[ rejectedCount ] = rPaths[i]; - rejectedCount++; + aIndex = rPaths[i].lastIndexOf( '/' ); + aIconName = rPaths[i].copy( aIndex+1 ); + ret = SvxIconReplacementDialog( this, aIconName, TRUE ).ShowDialog(); + nCount = aTbSymbol.GetItemCount(); + if ( ret == 2 ) + { + for (USHORT n = 0; n < nCount; n++ ) + { + nId = aTbSymbol.GetItemId( n ); + if ( OUString( aTbSymbol.GetItemText( nId ) ) == aPath ) + { + URLs[0] = aPath; + aTbSymbol.RemoveItem( aTbSymbol.GetItemPos( nId ) ); + aMediaProps[0].Value <<= aPath; + aImportGraph[ 0 ] = m_xGraphProvider->queryGraphic( aMediaProps ); + aTbSymbol.InsertItem( nId, Image( aImportGraph[ 0 ] ), aPath, 0, 0 ); + m_xImportedImageManager->replaceImages( GetImageType(), URLs, aImportGraph ); + if ( xConfigPer.is() && xConfigPer->isModified() ) + { + xConfigPer->store(); + break; + } + } + } + } + else if ( ret == 5 ) + { + for ( sal_Int32 k = i; k < rPaths.getLength(); k++ ) + { + aPath = rPaths[0] + OUString::createFromAscii("/") + rPaths[k]; + bool bHasReplaced = FALSE; + for (USHORT n = 0; n < nCount; n++ ) + { + nId = aTbSymbol.GetItemId( n ); + if ( OUString( aTbSymbol.GetItemText( nId ) ) == aPath ) + { + URLs[0] = aPath; + aTbSymbol.RemoveItem( aTbSymbol.GetItemPos( nId ) ); + aMediaProps[0].Value <<= aPath; + aImportGraph[ 0 ] = m_xGraphProvider->queryGraphic( aMediaProps ); + aTbSymbol.InsertItem( nId, Image( aImportGraph[ 0 ] ), aPath, 0, 0 ); + m_xImportedImageManager->replaceImages( GetImageType(), URLs, aImportGraph ); + if ( xConfigPer.is() && xConfigPer->isModified() ) + { + xConfigPer->store(); + bHasReplaced = TRUE; + break; + } + } + } + if ( !bHasReplaced ) + { + bool result = ImportGraphic( aPath ); + if ( result == FALSE ) + { + rejected[ rejectedCount ] = rPaths[i]; + rejectedCount++; + } + } + } + break; + } + } + else + { + bool result = ImportGraphic( rPaths[0] + OUString::createFromAscii("/") + rPaths[i] ); + if ( result == FALSE ) + { + rejected[ rejectedCount ] = rPaths[i]; + rejectedCount++; + } } } } @@ -5774,3 +5934,54 @@ } return result; } + +/******************************************************************************* +* +* The SvxIconReplacementDialog class +* +*******************************************************************************/ +SvxIconReplacementDialog :: SvxIconReplacementDialog( + Window *pWindow, const rtl::OUString& aMessage, bool bYestoAll ) + : +MessBox( pWindow, WB_DEF_YES, String( SVX_RES( RID_SVXSTR_REPLACE_ICON_CONFIRM ) ), String( SVX_RES( RID_SVXSTR_REPLACE_ICON_WARNING ) ) ) + +{ + FreeResource(); + SetImage( WarningBox( this, NULL ).GetStandardImage() ); + SetMessText( ReplaceIconName( aMessage ) ); + RemoveButton( 1 ); + AddButton( BUTTON_YES, 2, 0 ); + AddButton( String( SVX_RES( RID_SVXSTR_YESTOALL ) ), 5, 0 ); + AddButton( BUTTON_NO, 3, 0 ); + AddButton( BUTTON_CANCEL, 4, 0 ); +} + +SvxIconReplacementDialog :: SvxIconReplacementDialog( + Window *pWindow, const rtl::OUString& aMessage ) + : +MessBox( pWindow, WB_YES_NO_CANCEL, String( SVX_RES( RID_SVXSTR_REPLACE_ICON_CONFIRM ) ), String( SVX_RES( RID_SVXSTR_REPLACE_ICON_WARNING ) ) ) +{ + FreeResource(); + SetImage( WarningBox( this, NULL ).GetStandardImage() ); + SetMessText( ReplaceIconName( aMessage )); +} + +rtl::OUString SvxIconReplacementDialog :: ReplaceIconName( const OUString& rMessage ) +{ + rtl::OUString name; + rtl::OUString message = String( SVX_RES( RID_SVXSTR_REPLACE_ICON_WARNING ) ); + rtl::OUString placeholder = OUString::createFromAscii( "%ICONNAME" ); + sal_Int32 pos = message.indexOf( placeholder ); + if ( pos != -1 ) + { + name = message.replaceAt( + pos, placeholder.getLength(), rMessage ); + } + return name; +} + +USHORT SvxIconReplacementDialog :: ShowDialog() +{ + this->Execute(); + return ( this->GetCurButtonId() ); +} \ No newline at end of file diff -uNr old/cfg.hrc new/cfg.hrc --- old/cfg.hrc 2007-09-05 13:34:50.000000000 +0800 +++ new/cfg.hrc 2007-09-05 13:21:24.000000000 +0800 @@ -101,4 +101,7 @@ #define BTN_OK (103 + CFG_OFFSET) #define BTN_CANCEL (104 + CFG_OFFSET) #define BTN_HELP (105 + CFG_OFFSET) -#define FT_NAME (106 + CFG_OFFSET) \ No newline at end of file +#define FT_NAME (106 + CFG_OFFSET) + +#define FL_SEPARATOR (108 + CFG_OFFSET) +#define BTN_DELETE (109 + CFG_OFFSET) \ No newline at end of file diff -uNr old/cfg.hxx new/cfg.hxx --- old/cfg.hxx 2007-09-05 13:35:18.000000000 +0800 +++ new/cfg.hxx 2007-09-24 17:26:24.000000000 +0800 @@ -796,6 +796,8 @@ CancelButton aBtnCancel; HelpButton aBtnHelp; PushButton aBtnImport; + PushButton aBtnDelete; + FixedLine aFlSeparator; sal_Int32 m_nExpectedSize; @@ -833,6 +835,23 @@ DECL_LINK( SelectHdl, ToolBox * ); DECL_LINK( ImportHdl, PushButton * ); + DECL_LINK( DeleteHdl, PushButton * ); +}; + +class SvxIconReplacementDialog : public MessBox +{ +public: + SvxIconReplacementDialog( + Window *pWindow, + const rtl::OUString& aMessage, + bool aYestoAll); + + SvxIconReplacementDialog( + Window *pWindow, + const rtl::OUString& aMessage ); + + rtl::OUString ReplaceIconName( const rtl::OUString& ); + USHORT ShowDialog(); }; #endif // _SVXCFG_HXX diff -uNr old/cfg.src new/cfg.src --- old/cfg.src 2007-09-05 13:25:10.000000000 +0800 +++ new/cfg.src 2007-09-24 17:20:38.000000000 +0800 @@ -636,47 +636,59 @@ ToolBox TB_SYMBOLS { Pos = MAP_APPFONT ( 12 , 14 ) ; - Size = MAP_APPFONT ( 160 , 96 ) ; + Size = MAP_APPFONT ( 160 , 80 ) ; Scroll = TRUE ; LineSpacing = TRUE ; Customize = FALSE ; - }; + }; OKButton BTN_OK { - Pos = MAP_APPFONT ( 184 , 7 ) ; + Pos = MAP_APPFONT ( 60 , 130 ) ; Size = MAP_APPFONT ( 50 , 14 ) ; TabStop = TRUE ; DefButton = TRUE ; }; CancelButton BTN_CANCEL { - Pos = MAP_APPFONT ( 184 , 24 ) ; + Pos = MAP_APPFONT ( 120 , 130 ) ; Size = MAP_APPFONT ( 50 , 14 ) ; TabStop = TRUE ; }; HelpButton BTN_HELP { - Pos = MAP_APPFONT ( 184 , 44 ) ; + Pos = MAP_APPFONT ( 180 , 130 ) ; Size = MAP_APPFONT ( 50 , 14 ) ; TabStop = TRUE ; }; PushButton BTN_IMPORT { - Pos = MAP_APPFONT ( 184 , 95 ) ; + Pos = MAP_APPFONT ( 184 , 7 ) ; Size = MAP_APPFONT ( 50 , 14 ) ; TabStop = TRUE ; Text [ de ] = "Importieren..." ; Text[ en-US ] = "Import..."; }; + PushButton BTN_DELETE + { + Pos = MAP_APPFONT ( 184 , 24 ) ; + Size = MAP_APPFONT ( 50 , 14 ) ; + TabStop = TRUE ; + Text[ en-US ] = "Delete..."; + }; FixedText FT_NOTE { - Pos = MAP_APPFONT ( 12 , 117 ) ; + Pos = MAP_APPFONT ( 12 , 95 ) ; Size = MAP_APPFONT ( 172 , 24 ) ; Text [ de ] = "Hinweis:\nBitte beachten Sie das für einen erfolgreichen Import die Symbole eine Größe von 16x16 Pixel haben müssen." ; Text [ en-US ] = "Note:\nThe size of the icons must be 16x16 pixels for them to be successfully imported." ; Left = TRUE ; WordBreak = TRUE; }; + FixedLine FL_SEPARATOR + { + Pos = MAP_APPFONT ( 0, 120 ); + Size = MAP_APPFONT ( 240, 8 ); + }; Color IMAGE_BTN_COLOR { Red = 0xC000 ; @@ -692,6 +704,26 @@ Text [ en-US ] = "The files listed here could not be imported. The icons are not the required 16x16 pixels in size." ; }; +String RID_SVXSTR_DELETE_ICON_CONFIRM +{ + Text [ en-US ] = "Are you sure to delete the image?" ; +}; + +String RID_SVXSTR_REPLACE_ICON_WARNING +{ + Text [ en-US ] = "The icon %ICONNAME is already contained in the image list.\nWould you like to replace the existing icon?"; +}; + +String RID_SVXSTR_REPLACE_ICON_CONFIRM +{ + Text [ en-US ] = "Confirm Icon Replacement"; +}; + +String RID_SVXSTR_YESTOALL +{ + Text [ en-US ] = "Yes to All"; +}; + String RID_SVXSTR_PRODUCTNAME_TOOLBARS { Text [ de ] = "%PRODUCTNAME %MODULENAME Symbolleisten" ;