Lines 5380-5386
Link Here
|
5380 |
aBtnOK ( this, ResId( BTN_OK ) ), |
5380 |
aBtnOK ( this, ResId( BTN_OK ) ), |
5381 |
aBtnCancel ( this, ResId( BTN_CANCEL ) ), |
5381 |
aBtnCancel ( this, ResId( BTN_CANCEL ) ), |
5382 |
aBtnHelp ( this, ResId( BTN_HELP ) ), |
5382 |
aBtnHelp ( this, ResId( BTN_HELP ) ), |
5383 |
aBtnImport ( this, ResId( BTN_IMPORT ) ), |
5383 |
aBtnImport ( this, ResId( BTN_IMPORT ) ), |
|
|
5384 |
aBtnDelete ( this, ResId( BTN_DELETE ) ), |
5385 |
aFlSeparator ( this, ResId( FL_SEPARATOR ) ), |
5384 |
m_xImageManager ( rXImageManager ), |
5386 |
m_xImageManager ( rXImageManager ), |
5385 |
m_xParentImageManager( rXParentImageManager ) |
5387 |
m_xParentImageManager( rXParentImageManager ) |
5386 |
{ |
5388 |
{ |
Lines 5558-5565
Link Here
|
5558 |
++pConstIter; |
5560 |
++pConstIter; |
5559 |
} |
5561 |
} |
5560 |
|
5562 |
|
|
|
5563 |
aBtnDelete.Enable( FALSE ); |
5561 |
aTbSymbol.SetSelectHdl( LINK(this, SvxIconSelectorDialog, SelectHdl) ); |
5564 |
aTbSymbol.SetSelectHdl( LINK(this, SvxIconSelectorDialog, SelectHdl) ); |
5562 |
aBtnImport.SetClickHdl( LINK(this, SvxIconSelectorDialog, ImportHdl) ); |
5565 |
aBtnImport.SetClickHdl( LINK(this, SvxIconSelectorDialog, ImportHdl) ); |
|
|
5566 |
aBtnDelete.SetClickHdl( LINK(this, SvxIconSelectorDialog, DeleteHdl) ); |
5563 |
} |
5567 |
} |
5564 |
|
5568 |
|
5565 |
SvxIconSelectorDialog::~SvxIconSelectorDialog() |
5569 |
SvxIconSelectorDialog::~SvxIconSelectorDialog() |
Lines 5617-5622
Link Here
|
5617 |
|
5621 |
|
5618 |
USHORT nId = aTbSymbol.GetCurItemId(); |
5622 |
USHORT nId = aTbSymbol.GetCurItemId(); |
5619 |
aTbSymbol.CheckItem( nId ); |
5623 |
aTbSymbol.CheckItem( nId ); |
|
|
5624 |
|
5625 |
::rtl::OUString aSelImageText = aTbSymbol.GetItemText( nId ); |
5626 |
if ( m_xImportedImageManager->hasImage( GetImageType(), aSelImageText ) ) |
5627 |
{ |
5628 |
aBtnDelete.Enable( TRUE ); |
5629 |
} |
5630 |
else |
5631 |
{ |
5632 |
aBtnDelete.Enable( FALSE ); |
5633 |
} |
5620 |
|
5634 |
|
5621 |
return 0; |
5635 |
return 0; |
5622 |
} |
5636 |
} |
Lines 5651-5679
Link Here
|
5651 |
return 0; |
5665 |
return 0; |
5652 |
} |
5666 |
} |
5653 |
|
5667 |
|
|
|
5668 |
IMPL_LINK( SvxIconSelectorDialog, DeleteHdl, PushButton *, pButton ) |
5669 |
{ |
5670 |
(void)pButton; |
5671 |
|
5672 |
OUString message = String( SVX_RES( RID_SVXSTR_DELETE_ICON_CONFIRM ) ); |
5673 |
bool ret = WarningBox( this, WinBits(WB_OK_CANCEL), message ).Execute(); |
5674 |
|
5675 |
if ( ret == RET_OK ) |
5676 |
{ |
5677 |
USHORT nCount = aTbSymbol.GetItemCount(); |
5678 |
|
5679 |
for (USHORT n = 0; n < nCount; n++ ) |
5680 |
{ |
5681 |
USHORT nId = aTbSymbol.GetItemId( n ); |
5682 |
|
5683 |
if ( aTbSymbol.IsItemChecked( nId ) ) |
5684 |
{ |
5685 |
::rtl::OUString aSelImageText = aTbSymbol.GetItemText( nId ); |
5686 |
uno::Sequence< OUString > URLs(1); |
5687 |
URLs[0] = aSelImageText; |
5688 |
aTbSymbol.RemoveItem( aTbSymbol.GetItemPos( nId ) ); |
5689 |
m_xImportedImageManager->removeImages( GetImageType(), URLs ); |
5690 |
uno::Reference< css::ui::XUIConfigurationPersistence > |
5691 |
xConfigPersistence( m_xImportedImageManager, uno::UNO_QUERY ); |
5692 |
if ( xConfigPersistence.is() && xConfigPersistence->isModified() ) |
5693 |
{ |
5694 |
xConfigPersistence->store(); |
5695 |
} |
5696 |
break; |
5697 |
} |
5698 |
} |
5699 |
} |
5700 |
return 0; |
5701 |
} |
5702 |
|
5654 |
void SvxIconSelectorDialog::ImportGraphics( |
5703 |
void SvxIconSelectorDialog::ImportGraphics( |
5655 |
const uno::Sequence< OUString >& rPaths ) |
5704 |
const uno::Sequence< OUString >& rPaths ) |
5656 |
{ |
5705 |
{ |
5657 |
uno::Sequence< OUString > rejected( rPaths.getLength() ); |
5706 |
uno::Sequence< OUString > rejected( rPaths.getLength() ); |
5658 |
sal_Int32 rejectedCount = 0; |
5707 |
sal_Int32 rejectedCount = 0; |
5659 |
|
5708 |
|
|
|
5709 |
USHORT ret = 0, nId, nCount; |
5710 |
sal_Int32 aIndex; |
5711 |
OUString aIconName; |
5712 |
uno::Sequence< OUString > URLs(1); |
5713 |
uno::Sequence< uno::Reference<graphic::XGraphic > > aImportGraph( 1 ); |
5714 |
uno::Sequence< beans::PropertyValue > aMediaProps( 1 ); |
5715 |
aMediaProps[0].Name = ::rtl::OUString::createFromAscii("URL"); |
5716 |
uno::Reference< css::ui::XUIConfigurationPersistence > |
5717 |
xConfigPer( m_xImportedImageManager, uno::UNO_QUERY ); |
5718 |
|
5660 |
if ( rPaths.getLength() == 1 ) |
5719 |
if ( rPaths.getLength() == 1 ) |
5661 |
{ |
5720 |
{ |
5662 |
if ( ImportGraphic( rPaths[0] ) == FALSE ) |
5721 |
if ( m_xImportedImageManager->hasImage( GetImageType(), rPaths[0] ) ) |
|
|
5722 |
{ |
5723 |
aIndex = rPaths[0].lastIndexOf( '/' ); |
5724 |
aIconName = rPaths[0].copy( aIndex+1 ); |
5725 |
ret = SvxIconReplacementDialog( this, aIconName ).ShowDialog(); |
5726 |
if ( ret == 2 ) |
5727 |
{ |
5728 |
nCount = aTbSymbol.GetItemCount(); |
5729 |
for (USHORT n = 0; n < nCount; n++ ) |
5730 |
{ |
5731 |
nId = aTbSymbol.GetItemId( n ); |
5732 |
|
5733 |
if ( OUString( aTbSymbol.GetItemText( nId ) ) == rPaths[0] ) |
5734 |
{ |
5735 |
URLs[0] = rPaths[0]; |
5736 |
aTbSymbol.RemoveItem( aTbSymbol.GetItemPos( nId ) ); |
5737 |
aMediaProps[0].Value <<= rPaths[0]; |
5738 |
aImportGraph[ 0 ] = m_xGraphProvider->queryGraphic( aMediaProps ); |
5739 |
aTbSymbol.InsertItem( nId, Image( aImportGraph[ 0 ] ), rPaths[0], 0, 0 ); |
5740 |
m_xImportedImageManager->replaceImages( GetImageType(), URLs, aImportGraph ); |
5741 |
if ( xConfigPer.is() && xConfigPer->isModified() ) |
5742 |
{ |
5743 |
xConfigPer->store(); |
5744 |
break; |
5745 |
} |
5746 |
} |
5747 |
} |
5748 |
} |
5749 |
} |
5750 |
else |
5663 |
{ |
5751 |
{ |
5664 |
rejected[0] = rPaths[0]; |
5752 |
if ( ImportGraphic( rPaths[0] ) == FALSE ) |
5665 |
rejectedCount = 1; |
5753 |
{ |
|
|
5754 |
rejected[0] = rPaths[0]; |
5755 |
rejectedCount = 1; |
5756 |
} |
5666 |
} |
5757 |
} |
5667 |
} |
5758 |
} |
5668 |
else |
5759 |
else |
5669 |
{ |
5760 |
{ |
5670 |
for ( sal_Int32 i = 1; i < rPaths.getLength(); i++ ) |
5761 |
for ( sal_Int32 i = 1; i < rPaths.getLength(); i++ ) |
5671 |
{ |
5762 |
{ |
5672 |
bool result = ImportGraphic( rPaths[0] + OUString::createFromAscii("/") + rPaths[i] ); |
5763 |
::rtl::OUString aPath = rPaths[0] + OUString::createFromAscii("/") + rPaths[i]; |
5673 |
if ( result == FALSE ) |
5764 |
if ( m_xImportedImageManager->hasImage( GetImageType(), aPath ) ) |
5674 |
{ |
5765 |
{ |
5675 |
rejected[ rejectedCount ] = rPaths[i]; |
5766 |
aIndex = rPaths[i].lastIndexOf( '/' ); |
5676 |
rejectedCount++; |
5767 |
aIconName = rPaths[i].copy( aIndex+1 ); |
|
|
5768 |
ret = SvxIconReplacementDialog( this, aIconName, TRUE ).ShowDialog(); |
5769 |
nCount = aTbSymbol.GetItemCount(); |
5770 |
if ( ret == 2 ) |
5771 |
{ |
5772 |
for (USHORT n = 0; n < nCount; n++ ) |
5773 |
{ |
5774 |
nId = aTbSymbol.GetItemId( n ); |
5775 |
if ( OUString( aTbSymbol.GetItemText( nId ) ) == aPath ) |
5776 |
{ |
5777 |
URLs[0] = aPath; |
5778 |
aTbSymbol.RemoveItem( aTbSymbol.GetItemPos( nId ) ); |
5779 |
aMediaProps[0].Value <<= aPath; |
5780 |
aImportGraph[ 0 ] = m_xGraphProvider->queryGraphic( aMediaProps ); |
5781 |
aTbSymbol.InsertItem( nId, Image( aImportGraph[ 0 ] ), aPath, 0, 0 ); |
5782 |
m_xImportedImageManager->replaceImages( GetImageType(), URLs, aImportGraph ); |
5783 |
if ( xConfigPer.is() && xConfigPer->isModified() ) |
5784 |
{ |
5785 |
xConfigPer->store(); |
5786 |
break; |
5787 |
} |
5788 |
} |
5789 |
} |
5790 |
} |
5791 |
else if ( ret == 5 ) |
5792 |
{ |
5793 |
for ( sal_Int32 k = i; k < rPaths.getLength(); k++ ) |
5794 |
{ |
5795 |
aPath = rPaths[0] + OUString::createFromAscii("/") + rPaths[k]; |
5796 |
bool bHasReplaced = FALSE; |
5797 |
for (USHORT n = 0; n < nCount; n++ ) |
5798 |
{ |
5799 |
nId = aTbSymbol.GetItemId( n ); |
5800 |
if ( OUString( aTbSymbol.GetItemText( nId ) ) == aPath ) |
5801 |
{ |
5802 |
URLs[0] = aPath; |
5803 |
aTbSymbol.RemoveItem( aTbSymbol.GetItemPos( nId ) ); |
5804 |
aMediaProps[0].Value <<= aPath; |
5805 |
aImportGraph[ 0 ] = m_xGraphProvider->queryGraphic( aMediaProps ); |
5806 |
aTbSymbol.InsertItem( nId, Image( aImportGraph[ 0 ] ), aPath, 0, 0 ); |
5807 |
m_xImportedImageManager->replaceImages( GetImageType(), URLs, aImportGraph ); |
5808 |
if ( xConfigPer.is() && xConfigPer->isModified() ) |
5809 |
{ |
5810 |
xConfigPer->store(); |
5811 |
bHasReplaced = TRUE; |
5812 |
break; |
5813 |
} |
5814 |
} |
5815 |
} |
5816 |
if ( !bHasReplaced ) |
5817 |
{ |
5818 |
bool result = ImportGraphic( aPath ); |
5819 |
if ( result == FALSE ) |
5820 |
{ |
5821 |
rejected[ rejectedCount ] = rPaths[i]; |
5822 |
rejectedCount++; |
5823 |
} |
5824 |
} |
5825 |
} |
5826 |
break; |
5827 |
} |
5828 |
} |
5829 |
else |
5830 |
{ |
5831 |
bool result = ImportGraphic( rPaths[0] + OUString::createFromAscii("/") + rPaths[i] ); |
5832 |
if ( result == FALSE ) |
5833 |
{ |
5834 |
rejected[ rejectedCount ] = rPaths[i]; |
5835 |
rejectedCount++; |
5836 |
} |
5677 |
} |
5837 |
} |
5678 |
} |
5838 |
} |
5679 |
} |
5839 |
} |
Lines 5774-5776
Link Here
|
5774 |
} |
5934 |
} |
5775 |
return result; |
5935 |
return result; |
5776 |
} |
5936 |
} |
|
|
5937 |
|
5938 |
/******************************************************************************* |
5939 |
* |
5940 |
* The SvxIconReplacementDialog class |
5941 |
* |
5942 |
*******************************************************************************/ |
5943 |
SvxIconReplacementDialog :: SvxIconReplacementDialog( |
5944 |
Window *pWindow, const rtl::OUString& aMessage, bool bYestoAll ) |
5945 |
: |
5946 |
MessBox( pWindow, WB_DEF_YES, String( SVX_RES( RID_SVXSTR_REPLACE_ICON_CONFIRM ) ), String( SVX_RES( RID_SVXSTR_REPLACE_ICON_WARNING ) ) ) |
5947 |
|
5948 |
{ |
5949 |
FreeResource(); |
5950 |
SetImage( WarningBox( this, NULL ).GetStandardImage() ); |
5951 |
SetMessText( ReplaceIconName( aMessage ) ); |
5952 |
RemoveButton( 1 ); |
5953 |
AddButton( BUTTON_YES, 2, 0 ); |
5954 |
AddButton( String( SVX_RES( RID_SVXSTR_YESTOALL ) ), 5, 0 ); |
5955 |
AddButton( BUTTON_NO, 3, 0 ); |
5956 |
AddButton( BUTTON_CANCEL, 4, 0 ); |
5957 |
} |
5958 |
|
5959 |
SvxIconReplacementDialog :: SvxIconReplacementDialog( |
5960 |
Window *pWindow, const rtl::OUString& aMessage ) |
5961 |
: |
5962 |
MessBox( pWindow, WB_YES_NO_CANCEL, String( SVX_RES( RID_SVXSTR_REPLACE_ICON_CONFIRM ) ), String( SVX_RES( RID_SVXSTR_REPLACE_ICON_WARNING ) ) ) |
5963 |
{ |
5964 |
FreeResource(); |
5965 |
SetImage( WarningBox( this, NULL ).GetStandardImage() ); |
5966 |
SetMessText( ReplaceIconName( aMessage )); |
5967 |
} |
5968 |
|
5969 |
rtl::OUString SvxIconReplacementDialog :: ReplaceIconName( const OUString& rMessage ) |
5970 |
{ |
5971 |
rtl::OUString name; |
5972 |
rtl::OUString message = String( SVX_RES( RID_SVXSTR_REPLACE_ICON_WARNING ) ); |
5973 |
rtl::OUString placeholder = OUString::createFromAscii( "%ICONNAME" ); |
5974 |
sal_Int32 pos = message.indexOf( placeholder ); |
5975 |
if ( pos != -1 ) |
5976 |
{ |
5977 |
name = message.replaceAt( |
5978 |
pos, placeholder.getLength(), rMessage ); |
5979 |
} |
5980 |
return name; |
5981 |
} |
5982 |
|
5983 |
USHORT SvxIconReplacementDialog :: ShowDialog() |
5984 |
{ |
5985 |
this->Execute(); |
5986 |
return ( this->GetCurButtonId() ); |
5987 |
} |