Hi Carsten,
I have fixed finally the issue83555, the attachment is the source changes.
And I have submitted the it to the issue83555. Please, review it.
During I did the work, Carsten helped me enormously with advice on how
to fix it.
Thank you for your helps.
Kind Regards
Shi zhoubo
diff -urNpw svx_old/source/dialog/cfg.cxx svx/source/dialog/cfg.cxx
--- svx_old/source/dialog/cfg.cxx 2007-11-20 01:20:20.000000000 +0800
+++ svx/source/dialog/cfg.cxx 2008-01-22 17:14:36.000000000 +0800
@@ -51,11 +51,6 @@
#ifndef _SV_SCRBAR_HXX
#include <vcl/scrbar.hxx>
#endif
-//added for issue73355
-//#ifndef _SV_SVDATA_HXX
-//#include <vcl/svdata.hxx>
-//#endif
-//issue73355 ends
#include <sfx2/app.hxx>
#include <sfx2/sfxdlg.hxx>
@@ -5759,10 +5754,21 @@ bool SvxIconSelectorDialog::ReplaceGraph
uno::Sequence< beans::PropertyValue > aMediaProps( 1 );
aMediaProps[0].Name = ::rtl::OUString::createFromAscii("URL");
aMediaProps[0].Value <<= aURL;
-
+ com::sun::star::awt::Size aSize;
+ bool bOK = FALSE;
try
{
xGraphic = m_xGraphProvider->queryGraphic( aMediaProps );
+
+ uno::Reference< beans::XPropertySet > props =
+ m_xGraphProvider->queryGraphicDescriptor( aMediaProps );
+ uno::Any a = props->getPropertyValue(
+ OUString::createFromAscii("SizePixel") );
+ a >>= aSize;
+ if (0 == aSize.Width || 0 == aSize.Height)
+ return FALSE;
+ else
+ bOK = TRUE;
}
catch ( uno::Exception& )
{
@@ -5787,8 +5793,16 @@ bool SvxIconSelectorDialog::ReplaceGraph
aTbSymbol.RemoveItem( aTbSymbol.GetItemPos( nId ) );
aMediaProps[0].Value <<= aURL;
- aTbSymbol.InsertItem( nId, Image( xGraphic ), aURL, 0,
0 );
-
+ Image aImage( xGraphic );
+ if ( bOK && ((aSize.Width != m_nExpectedSize)
|| (aSize.Height != m_nExpectedSize)) )
+ {
+ BitmapEx aBitmap = aImage.GetBitmapEx();
+ BitmapEx aBitmapex =
AutoScaleBitmap(aBitmap, m_nExpectedSize);
+ aBitmap.Clear();
+ aImage = Image( aBitmapex);
+ aBitmapex.Clear();
+ }
+ aTbSymbol.InsertItem( nId,aImage, aURL, 0, 0 );
bResult = true;
break;
}
@@ -5891,23 +5905,18 @@ void SvxIconSelectorDialog::ImportGraphi
if ( rejectedCount != 0 )
{
- OUString message = String( SVX_RES(
RID_SVXSTR_IMPORT_ICON_ERROR ) );
- if ( m_nExpectedSize != 16 )
- {
- message = replaceSixteen( message, m_nExpectedSize );
- }
-
+ OUString message =OUString::createFromAscii("");
OUString newLine = OUString::createFromAscii("\n");
- message += newLine;
- message += newLine;
-
+ rtl::OUString fPath = OUString::createFromAscii("");
+ if (rejectedCount > 1)
+ fPath = rPaths[0].copy(8) +
::rtl::OUString::createFromAscii( "/" );
for ( sal_Int32 i = 0; i < rejectedCount; i++ )
{
- message += rejected[i];
+ message += fPath + rejected[i];
message += newLine;
}
-
- InfoBox( this, message ).Execute();
+ SvxIconChangeDialog * pDialog = new SvxIconChangeDialog(this,
message);
+ pDialog->Execute();
}
}
@@ -5923,9 +5932,8 @@ bool SvxIconSelectorDialog::ImportGraphi
uno::Reference< graphic::XGraphic > xGraphic;
com::sun::star::awt::Size aSize;
-
+ bool bOK = TRUE;
aMediaProps[0].Value <<= aURL;
-
try
{
uno::Reference< beans::XPropertySet > props =
@@ -5934,30 +5942,34 @@ bool SvxIconSelectorDialog::ImportGraphi
uno::Any a = props->getPropertyValue(
OUString::createFromAscii("SizePixel") );
- if ( ( a >>= aSize ) && aSize.Width == m_nExpectedSize &&
- aSize.Height == m_nExpectedSize )
- {
xGraphic = m_xGraphProvider->queryGraphic( aMediaProps
);
-
if ( xGraphic.is() )
{
+ a >>= aSize;
+ if ( 0 == aSize.Width || 0 == aSize.Height )
+ bOK = FALSE;
Image aImage( xGraphic );
-
- if ( !!aImage )
+ if ( bOK && ((aSize.Width != m_nExpectedSize)
|| (aSize.Height != m_nExpectedSize)) )
+ {
+ BitmapEx aBitmap = aImage.GetBitmapEx();
+ BitmapEx aBitmapex =
AutoScaleBitmap(aBitmap, m_nExpectedSize);
+ aBitmap.Clear();
+ aImage = Image( aBitmapex);
+ aBitmapex.Clear();
+ }
+ if ( bOK && !!aImage )
{
aTbSymbol.InsertItem( nId, aImage,
aURL, 0, 0 );
-
+ xGraphic = aImage.GetXGraphic();
xGraphic->acquire();
aTbSymbol.SetItemData(
nId, static_cast< void * > (
xGraphic.get() ) );
-
uno::Sequence< OUString > aImportURL( 1
);
aImportURL[ 0 ] = aURL;
uno::Sequence<
uno::Reference<graphic::XGraphic > > aImportGraph( 1 );
aImportGraph[ 0 ] = xGraphic;
m_xImportedImageManager->insertImages(
GetImageType(), aImportURL, aImportGraph );
-
uno::Reference<
css::ui::XUIConfigurationPersistence >
xConfigPersistence(
m_xImportedImageManager, uno::UNO_QUERY );
@@ -5978,7 +5990,6 @@ bool SvxIconSelectorDialog::ImportGraphi
OSL_TRACE("could not get query XGraphic");
}
}
- }
catch( uno::Exception& e )
{
OSL_TRACE("Caught exception importing XGraphic: %s",
PRTSTR(e.Message));
@@ -6034,3 +6045,74 @@ USHORT SvxIconReplacementDialog :: ShowD
this->Execute();
return ( this->GetCurButtonId() );
}
+
+SvxIconChangeDialog::SvxIconChangeDialog(
+ Window *pWindow, const rtl::OUString& aMessage)
+ :
+ ModalDialog ( pWindow, SVX_RES( MD_ICONCHANGE ) ),
+ aFImageInfo (this, SVX_RES( FI_INFO ) ),
+ aDescriptionLabel (this, SVX_RES(FTCHGE_DESCRIPTION)),
+ aBtnOK (this, SVX_RES(MD_BTN_OK)),
+ aLineEditDescription (this, SVX_RES(EDT_ADDR))
+{
+ FreeResource();
+ aFImageInfo.SetImage(InfoBox::GetStandardImage());
+ aLineEditDescription.SetControlBackground(
GetSettings().GetStyleSettings().GetDialogColor() );
+ aLineEditDescription.SetAutoScroll( TRUE );
+ aLineEditDescription.EnableCursor( FALSE );
+ aLineEditDescription.SetText(aMessage);
+}
+
+BitmapEx SvxIconSelectorDialog::AutoScaleBitmap(BitmapEx & aBitmap, const long
aStandardSize)
+{
+
+ Point aEmptyPoint(0,0);
+ sal_Int32 imgNewWidth = 0;
+ sal_Int32 imgNewHeight = 0;
+ double imgposX = 0;
+ double imgposY = 0;
+ BitmapEx aRet = aBitmap;
+ double imgOldWidth = aRet.GetSizePixel().Width();
+ double imgOldHeight =aRet.GetSizePixel().Height();
+
+ if (imgOldWidth >= aStandardSize || imgOldHeight >= aStandardSize)
+ {
+ if (imgOldWidth >= imgOldHeight)
+ {
+ imgNewWidth = aStandardSize;
+ imgNewHeight = sal_Int32(imgOldHeight / (imgOldWidth /
aStandardSize) + 0.5);
+ imgposX = 0;
+ imgposY = (aStandardSize - (imgOldHeight / (imgOldWidth
/ aStandardSize) + 0.5)) / 2 + 0.5;
+ }
+ else
+ {
+ imgNewHeight = aStandardSize;
+ imgNewWidth = sal_Int32(imgOldWidth / (imgOldHeight /
aStandardSize) + 0.5);
+ imgposY = 0;
+ imgposX = (aStandardSize - (imgOldWidth / (imgOldHeight
/ aStandardSize) + 0.5)) / 2 + 0.5;
+ }
+
+ aRet.Scale(Size( imgNewWidth, imgNewHeight ),
BMP_SCALE_INTERPOLATE);
+
+ }
+ else
+ {
+ imgposX = (aStandardSize - imgOldWidth) / 2 + 0.5;
+ imgposY = (aStandardSize - imgOldHeight) / 2 + 0.5;
+ }
+
+ Size aStdSize( aStandardSize, aStandardSize );
+ Rectangle aRect(aEmptyPoint, aStdSize );
+
+ VirtualDevice aVirDevice( *Application::GetDefaultDevice(),0,1);
+ aVirDevice.SetOutputSizePixel( aStdSize );
+ aVirDevice.SetFillColor( COL_TRANSPARENT );
+ aVirDevice.SetLineColor( COL_TRANSPARENT );
+
+ aVirDevice.DrawRect( aRect );
+ Point aPointPixel( (long)imgposX, (long)imgposY );
+ aVirDevice.DrawBitmapEx( aPointPixel, aRet );
+ aRet = aVirDevice.GetBitmapEx( aEmptyPoint, aStdSize );
+
+ return aRet;
+}
\ No newline at end of file
diff -urNpw svx_old/source/dialog/cfg.hrc svx/source/dialog/cfg.hrc
--- svx_old/source/dialog/cfg.hrc 2007-11-20 01:20:34.000000000 +0800
+++ svx/source/dialog/cfg.hrc 2008-01-22 17:10:08.000000000 +0800
@@ -105,3 +105,9 @@
#define FL_SEPARATOR (108 + CFG_OFFSET)
#define BTN_DELETE (109 + CFG_OFFSET)
+
+#define MD_ICONCHANGE (119 + CFG_OFFSET)
+#define FTCHGE_DESCRIPTION (120 + CFG_OFFSET)
+#define EDT_ADDR (121 + CFG_OFFSET)
+#define MD_BTN_OK (122 + CFG_OFFSET)
+#define FI_INFO (123 + CFG_OFFSET)
\ No newline at end of file
diff -urNpw svx_old/source/dialog/cfg.hxx svx/source/dialog/cfg.hxx
--- svx_old/source/dialog/cfg.hxx 2007-11-20 01:20:48.000000000 +0800
+++ svx/source/dialog/cfg.hxx 2008-01-22 17:12:40.000000000 +0800
@@ -60,7 +60,6 @@
#ifndef _SVTOOLS_SVMEDIT2_HXX
#include <svtools/svmedit2.hxx>
#endif
-
#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
#include <com/sun/star/beans/XPropertySet.hpp>
#endif
@@ -834,6 +833,8 @@ private:
void ImportGraphics(
const com::sun::star::uno::Sequence< rtl::OUString >& aURLs );
+ BitmapEx AutoScaleBitmap(BitmapEx & aBitmap, const long aStandardSize);
+
public:
SvxIconSelectorDialog(
@@ -869,4 +870,14 @@ public:
rtl::OUString ReplaceIconName( const rtl::OUString& );
USHORT ShowDialog();
};
+class SvxIconChangeDialog : public ModalDialog
+{
+private:
+ FixedImage aFImageInfo;
+ OKButton aBtnOK;
+ FixedText aDescriptionLabel;
+ SvxDescriptionEdit aLineEditDescription;
+public:
+ SvxIconChangeDialog(Window *pWindow, const rtl::OUString& aMessage);
+};
#endif // _SVXCFG_HXX
diff -urNpw svx_old/source/dialog/cfg.src svx/source/dialog/cfg.src
--- svx_old/source/dialog/cfg.src 2007-11-20 01:21:02.000000000 +0800
+++ svx/source/dialog/cfg.src 2008-01-22 17:10:44.000000000 +0800
@@ -678,9 +678,9 @@ ModalDialog MD_ICONSELECTOR
FixedText FT_NOTE
{
Pos = MAP_APPFONT ( 12 , 95 ) ;
- Size = MAP_APPFONT ( 172 , 24 ) ;
+ Size = MAP_APPFONT ( 200 , 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." ;
+ Text [ en-US ] = "Note:\nThe size of an icon should be 16x16
pixel to achieve best quality. Different sized icons will be scaled
automatically." ;
Left = TRUE ;
WordBreak = TRUE;
};
@@ -697,11 +697,53 @@ ModalDialog MD_ICONSELECTOR
};
};
+ModalDialog MD_ICONCHANGE
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 200 , 150 ) ;
+ Text [ en-US ] = "%PRODUCTNAME %PRODUCTVERSION" ;
+ Moveable = TRUE ;
+ FixedImage FI_INFO
+ {
+ Pos = MAP_APPFONT ( 6 , 6 ) ;
+ Size = MAP_APPFONT ( 24 , 24 ) ;
+ Fixed = Image
+ {
+
+ };
+ };
+ FixedText FTCHGE_DESCRIPTION
+ {
+ Pos = MAP_APPFONT ( 30 ,15 ) ;
+ Size = MAP_APPFONT ( 200 , 50 ) ;
+ Text [ en-US ] = "The files listed below could not be imported.\nThe
file format could not be interpreted." ;
+ };
+
+ MultiLineEdit EDT_ADDR
+ {
+ Pos = MAP_APPFONT ( 30 , 38) ;
+ Size = MAP_APPFONT ( 140 , 83 ) ;
+ Border = TRUE;
+ VScroll = TRUE;
+ IgnoreTab = TRUE;
+ ReadOnly = TRUE;
+ };
+ OKButton MD_BTN_OK
+ {
+ Pos = MAP_APPFONT ( 68 , 131 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+
+};
+
// Strings ---------------------------------------------------------------
String RID_SVXSTR_IMPORT_ICON_ERROR
{
Text [ de ] = "Die aufgelisteten Dateien konnten nicht importiert
werden. Die Symbole entsprechen nicht der GröÃe von 16x16 Pixel." ;
- Text [ en-US ] = "The files listed here could not be imported. The
icons are not the required 16x16 pixels in size." ;
+ Text [ en-US ] = "The files listed below could not be imported. The
file format could not be interpreted." ;
};
String RID_SVXSTR_DELETE_ICON_CONFIRM //added for issue73355
@@ -836,4 +878,3 @@ String RID_SVXSTR_RENAME_TOOLBAR
};
-
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]