[Libreoffice-commits] core.git: Branch 'distro/vector/vtext-6.5' - 3 commits - filter/source sc/source svx/inc svx/source vcl/source

Jan Holesovsky kendy at collabora.com
Mon Oct 19 05:07:19 PDT 2015


 filter/source/graphicfilter/eos2met/eos2met.cxx |   16 -
 filter/source/graphicfilter/epict/epict.cxx     |   21 --
 filter/source/svg/svgexport.cxx                 |   42 ++++
 filter/source/svg/svgfilter.component           |    3 
 filter/source/svg/svgfilter.cxx                 |   27 ++
 filter/source/svg/svgfilter.hxx                 |    2 
 filter/source/svg/svgwriter.cxx                 |   39 +++
 filter/source/svg/svgwriter.hxx                 |   22 ++
 sc/source/ui/drawfunc/chartsh.cxx               |   12 -
 svx/inc/svx/extedit.hxx                         |    5 
 svx/inc/svx/graphichelper.hxx                   |   10 
 svx/source/core/extedit.cxx                     |   56 ++---
 svx/source/core/graphichelper.cxx               |  247 ++++++++++++++++++------
 svx/source/svdraw/svdxcgv.cxx                   |   12 -
 svx/source/unodraw/unoshap4.cxx                 |   14 -
 svx/source/unodraw/unoshape.cxx                 |   14 -
 vcl/source/filter/graphicfilter.cxx             |   58 -----
 vcl/source/gdi/impgraph.cxx                     |   34 +++
 18 files changed, 418 insertions(+), 216 deletions(-)

New commits:
commit c2e729954926e30b4d4c61a64a8f804c2c365d7b
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Mon Oct 19 12:22:42 2015 +0200

    Fix build.

diff --git a/filter/source/svg/svgwriter.cxx b/filter/source/svg/svgwriter.cxx
index 849298f..9de7a66 100644
--- a/filter/source/svg/svgwriter.cxx
+++ b/filter/source/svg/svgwriter.cxx
@@ -3937,7 +3937,8 @@ void SAL_CALL SVGWriter::write( const Reference<XDocumentHandler>& rxDocHandler,
     const Reference< XDocumentHandler > xDocumentHandler( rxDocHandler );
     const Sequence< PropertyValue > aFilterData;
 
-    SVGExport* pWriter = new SVGExport( mxContext, xDocumentHandler, aFilterData );
+    Reference<XMultiServiceFactory> xFactory(mxContext->getServiceManager(), UNO_QUERY);
+    SVGExport* pWriter = new SVGExport(xFactory, xDocumentHandler, aFilterData);
     pWriter->writeMtf( aMtf );
     delete pWriter;
 }
diff --git a/svx/source/core/graphichelper.cxx b/svx/source/core/graphichelper.cxx
index 4671c91..d0c4558 100644
--- a/svx/source/core/graphichelper.cxx
+++ b/svx/source/core/graphichelper.cxx
@@ -133,7 +133,7 @@ OUString GraphicHelper::ExportGraphic( const Graphic& rGraphic, const OUString&
         // "wrong" extension?
         GetPreferedExtension( aExtension, rGraphic );
         for ( sal_uInt16 i = 0; i < nCount; ++i )
-            if ( aExtension == rGraphicFilter.GetExportFormatShortName( i ).ToLowerAscii() )
+            if (aExtension == OUString(rGraphicFilter.GetExportFormatShortName(i).ToLowerAscii()))
             {
                 nDefaultFilter =  i;
                 break;
commit 9f221c152add6a05810c76f7c8c223aa4c9ebd56
Author: Tomaž Vajngerl <quikee at gmail.com>
Date:   Tue Mar 26 23:07:42 2013 +0100

    Export Chart as Graphic - allow vector graphic export
    
    Readd removed SaveShapeAsGraphic to GraphicHelper with which it
    is possible to export any shape to vector/raster graphic.
    Additionally cleanup GraphicHelper and ExternalEdit (convertsion
    to OUString, remove unused imports, comments).
    
    (cherry picked from commit a5e22906c0b27019b61b41161ccc8cbc2cf40ade)
    
    Conflicts:
    	sc/source/ui/drawfunc/chartsh.cxx
    
    Change-Id: I1af45e2ed5d3b66dbd80a5f3a71c44530e46baef

diff --git a/sc/source/ui/drawfunc/chartsh.cxx b/sc/source/ui/drawfunc/chartsh.cxx
index 251fa5d..170ede8 100644
--- a/sc/source/ui/drawfunc/chartsh.cxx
+++ b/sc/source/ui/drawfunc/chartsh.cxx
@@ -40,6 +40,8 @@
 #define ScChartShell
 #include "scslots.hxx"
 
+using namespace ::css::uno;
+
 SFX_IMPL_INTERFACE(ScChartShell, ScDrawShell, ScResId(SCSTR_CHARTSHELL) )
 {
     SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT | SFX_VISIBILITY_STANDARD | SFX_VISIBILITY_SERVER,
@@ -88,14 +90,8 @@ void ScChartShell::ExecuteExportAsGraphic( SfxRequest& )
 
         if( pObject && pObject->ISA( SdrOle2Obj ) )
         {
-            SdrOle2Obj* aOle2Object = ((SdrOle2Obj*) pObject)->Clone();
-            aOle2Object->NbcResize(Point(), Fraction(1,1), Fraction(1,1));
-            Graphic* pGraphic = aOle2Object->GetGraphic();
-            if( pGraphic != NULL )
-            {
-                String sGrfNm, sFilterNm;
-                GraphicHelper::ExportGraphic( *pGraphic,  String("") );
-            }
+            Reference< XShape > xSourceDoc = Reference< XShape >( pObject->getUnoShape(), UNO_QUERY_THROW );
+            GraphicHelper::SaveShapeAsGraphic( xSourceDoc );
         }
     }
 
diff --git a/svx/inc/svx/extedit.hxx b/svx/inc/svx/extedit.hxx
index 3760c54..6f3c44a 100644
--- a/svx/inc/svx/extedit.hxx
+++ b/svx/inc/svx/extedit.hxx
@@ -24,10 +24,10 @@
 #ifndef _EXTEDIT_HXX
 #define _EXTEDIT_HXX
 
+#include <svtools/grfmgr.hxx>
 #include <osl/file.hxx>
 #include <osl/process.h>
 #include <vcl/graph.hxx>
-#include <svtools/grfmgr.hxx>
 #include <vcl/timer.hxx>
 #include <svx/svxdllapi.h>
 
@@ -35,7 +35,7 @@ class SVX_DLLPUBLIC ExternalToolEdit
 {
 public:
     GraphicObject* m_pGraphicObject;
-    rtl::OUString m_aFileName;
+    OUString m_aFileName;
 
     ExternalToolEdit();
     virtual ~ExternalToolEdit();
@@ -43,7 +43,6 @@ public:
     virtual void Update( Graphic& aGraphic ) = 0;
     void Edit( GraphicObject *pGraphic );
 
-
     DECL_LINK( StartListeningEvent, void *pEvent );
 
     static void threadWorker( void *pThreadData );
diff --git a/svx/inc/svx/graphichelper.hxx b/svx/inc/svx/graphichelper.hxx
index 317e0ff..1d9e9e3 100644
--- a/svx/inc/svx/graphichelper.hxx
+++ b/svx/inc/svx/graphichelper.hxx
@@ -23,12 +23,18 @@
 #include <vcl/graph.hxx>
 #include <svx/svxdllapi.h>
 
+#include <com/sun/star/drawing/XShape.hpp>
+
+using namespace css::uno;
+using namespace css::drawing;
+
 class SVX_DLLPUBLIC GraphicHelper
 {
 
 public:
-    static void GetPreferedExtension( String &rExt, const Graphic &rGrf );
-    static String ExportGraphic( const Graphic &rGraphic, const String &rGrfName );
+    static void GetPreferedExtension( OUString& rExtension, const Graphic& rGraphic );
+    static OUString ExportGraphic( const Graphic& rGraphic, const OUString& rGraphicName );
+    static void SaveShapeAsGraphic( const Reference< XShape >& xShape );
 };
 
 
diff --git a/svx/source/core/extedit.cxx b/svx/source/core/extedit.cxx
index 7754075..9835fb2 100644
--- a/svx/source/core/extedit.cxx
+++ b/svx/source/core/extedit.cxx
@@ -22,6 +22,11 @@
  * instead of those above.
  */
 
+#include <vcl/svapp.hxx>
+#include <vcl/graph.hxx>
+#include <vcl/cvtgrf.hxx>
+#include <vcl/graphicfilter.hxx>
+#include <svx/xoutbmp.hxx>
 #include <svx/extedit.hxx>
 #include <svx/graphichelper.hxx>
 #include <sfx2/viewfrm.hxx>
@@ -30,21 +35,17 @@
 #include <osl/thread.hxx>
 #include <osl/process.h>
 #include <osl/time.h>
-#include <vcl/graphicfilter.hxx>
 #include <svtools/filechangedchecker.hxx>
-#include <svx/xoutbmp.hxx>
 #include <unotools/ucbstreamhelper.hxx>
-#include <vcl/svapp.hxx>
-#include <vcl/graph.hxx>
-#include <vcl/cvtgrf.hxx>
-
-#include "com/sun/star/system/SystemShellExecute.hpp"
-#include "com/sun/star/system/SystemShellExecuteFlags.hpp"
 #include <comphelper/processfactory.hxx>
-
 #include <boost/bind.hpp>
 
-using namespace ::com::sun::star;
+#include <com/sun/star/system/SystemShellExecute.hpp>
+#include <com/sun/star/system/SystemShellExecuteFlags.hpp>
+
+using namespace css::uno;
+using namespace css::system;
+
 ExternalToolEdit::ExternalToolEdit()
 {}
 
@@ -74,9 +75,7 @@ IMPL_LINK (ExternalToolEdit, StartListeningEvent, void*, pEvent)
     ExternalToolEdit* pData = ( ExternalToolEdit* )pEvent;
     String aURL( pData->m_aFileName );
 
-    new FileChangedChecker(
-        pData->m_aFileName,
-        ::boost::bind(&HandleCloseEvent, pData));
+    new FileChangedChecker(pData->m_aFileName, ::boost::bind(&HandleCloseEvent, pData));
 
     return 0;
 }
@@ -89,9 +88,9 @@ void ExternalToolEdit::threadWorker(void* pThreadData)
     // getting changed
     Application::PostUserEvent( LINK( NULL, ExternalToolEdit, StartListeningEvent ), pThreadData);
 
-    uno::Reference< com::sun::star::system::XSystemShellExecute > xSystemShellExecute(
-        com::sun::star::system::SystemShellExecute::create(::comphelper::getProcessComponentContext() ) );
-    xSystemShellExecute->execute( pData->m_aFileName, rtl::OUString(),  com::sun::star::system::SystemShellExecuteFlags::URIS_ONLY );
+    Reference<XSystemShellExecute> xSystemShellExecute(
+        SystemShellExecute::create( ::comphelper::getProcessComponentContext() ) );
+    xSystemShellExecute->execute( pData->m_aFileName, OUString(), SystemShellExecuteFlags::URIS_ONLY );
 }
 
 void ExternalToolEdit::Edit( GraphicObject* pGraphicObject )
@@ -101,37 +100,36 @@ void ExternalToolEdit::Edit( GraphicObject* pGraphicObject )
     const Graphic aGraphic = pGraphicObject->GetGraphic();
 
     //get the Preferred File Extension for this graphic
-    String fExtension;
+    OUString fExtension;
     GraphicHelper::GetPreferedExtension(fExtension, aGraphic);
 
     //Create the temp File
-    rtl::OUString tempFileBase, tempFileName;
+    OUString aTempFileBase;
+    OUString aTempFileName;
+
     oslFileHandle pHandle;
-    osl::FileBase::createTempFile(0, &pHandle, &tempFileBase);
+    osl::FileBase::createTempFile(0, &pHandle, &aTempFileBase);
 
     // Move it to a file name with image extension properly set
-    tempFileName = tempFileBase + rtl::OUString('.') + rtl::OUString(fExtension);
-    osl::File::move(tempFileBase, tempFileName);
+    aTempFileName = aTempFileBase + OUString('.') + OUString(fExtension);
+    osl::File::move(aTempFileBase, aTempFileName);
 
     //Write Graphic to the Temp File
     GraphicFilter& rGraphicFilter = GraphicFilter::GetGraphicFilter();
     sal_uInt16 nFilter(rGraphicFilter.GetExportFormatNumber(fExtension));
+
     String aFilter(rGraphicFilter.GetExportFormatShortName(nFilter));
-    String sPath(tempFileName);
+    String sPath(aTempFileName);
 
     // Write the Graphic to the file now
-    XOutBitmap::WriteGraphic(aGraphic, sPath, aFilter, XOUTBMP_USE_NATIVE_IF_POSSIBLE|XOUTBMP_DONT_EXPAND_FILENAME);
+    XOutBitmap::WriteGraphic(aGraphic, sPath, aFilter, XOUTBMP_USE_NATIVE_IF_POSSIBLE | XOUTBMP_DONT_EXPAND_FILENAME);
 
     // There is a possiblity that sPath extnesion might have been changed if the
     // provided extension is not writable
-    tempFileName = rtl::OUString(sPath);
+    m_aFileName = OUString(sPath);
 
     //Create a thread
-    rtl_uString* aFileName = new rtl_uString();
-    rtl_uString_newFromAscii(
-        &aFileName,
-        rtl::OUStringToOString(tempFileName, RTL_TEXTENCODING_UTF8).getStr());
-    m_aFileName = aFileName;
+
     // Create the data that is needed by the thread later
     osl_createThread(ExternalToolEdit::threadWorker, this);
 }
diff --git a/svx/source/core/graphichelper.cxx b/svx/source/core/graphichelper.cxx
index 2cc0c7c..4671c91 100644
--- a/svx/source/core/graphichelper.cxx
+++ b/svx/source/core/graphichelper.cxx
@@ -18,119 +18,144 @@
  */
 
 #include <tools/string.hxx>
-#include <svx/graphichelper.hxx>
 #include <unotools/pathoptions.hxx>
 #include <vcl/graphicfilter.hxx>
 #include <sfx2/docfile.hxx>
-#include <svx/xoutbmp.hxx>
 #include <sfx2/filedlghelper.hxx>
+#include <svx/xoutbmp.hxx>
 #include <svx/dialmgr.hxx>
+#include <svx/graphichelper.hxx>
 #include <svx/dialogs.hrc>
 
+#include <cppuhelper/exc_hlp.hxx>
+#include <comphelper/anytostring.hxx>
+#include <comphelper/processfactory.hxx>
+
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/graphic/XGraphicProvider.hpp>
+#include <com/sun/star/graphic/GraphicType.hpp>
+#include <com/sun/star/ucb/XSimpleFileAccess2.hpp>
+#include <com/sun/star/beans/PropertyValues.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/io/XInputStream.hpp>
 #include <com/sun/star/ui/dialogs/XFilePicker.hpp>
 #include <com/sun/star/ui/dialogs/XFilterManager.hpp>
 #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
+#include <com/sun/star/document/XExporter.hpp>
+#include <com/sun/star/document/XFilter.hpp>
+
+using namespace css::uno;
+using namespace css::lang;
+using namespace css::graphic;
+using namespace css::ucb;
+using namespace css::beans;
+using namespace css::io;
+using namespace css::document;
+using namespace css::ui::dialogs;
 
-using namespace ::com::sun::star::uno;
-using namespace ::com::sun::star::ui::dialogs;
-using namespace ::sfx2;
+using namespace sfx2;
 
-void GraphicHelper::GetPreferedExtension( String &rExtension, const Graphic &rGraphic )
+void GraphicHelper::GetPreferedExtension( OUString& rExtension, const Graphic& rGraphic )
 {
-    // propose the "best" filter using the native-info, if applicable
-    const sal_Char* pExtension = "png";
+    OUString aExtension = "png";
     switch( const_cast<Graphic&>( rGraphic ).GetLink().GetType() )
     {
         case GFX_LINK_TYPE_NATIVE_GIF:
-            pExtension = "gif";
+            aExtension = "gif";
             break;
         case GFX_LINK_TYPE_NATIVE_TIF:
-            pExtension = "tif";
+            aExtension = "tif";
             break;
         case GFX_LINK_TYPE_NATIVE_WMF:
-            pExtension = "wmf";
+            aExtension = "wmf";
             break;
         case GFX_LINK_TYPE_NATIVE_MET:
-            pExtension = "met";
+            aExtension = "met";
             break;
         case GFX_LINK_TYPE_NATIVE_PCT:
-            pExtension = "pct";
+            aExtension = "pct";
             break;
         case GFX_LINK_TYPE_NATIVE_JPG:
-            pExtension = "jpg";
+            aExtension = "jpg";
             break;
         default:
             break;
     }
-    rExtension.AssignAscii( pExtension );
+    rExtension = aExtension;
 }
 
-String GraphicHelper::ExportGraphic( const Graphic &rGraphic, const String &rGrfName )
+OUString GraphicHelper::ExportGraphic( const Graphic& rGraphic, const OUString& rGraphicName )
 {
     SvtPathOptions aPathOpt;
-    String sGrfPath( aPathOpt.GetGraphicPath() );
+    OUString sGraphicsPath( aPathOpt.GetGraphicPath() );
 
-    FileDialogHelper aDlgHelper( TemplateDescription::FILESAVE_AUTOEXTENSION, 0 );
-    Reference < XFilePicker > xFP = aDlgHelper.GetFilePicker();
+    FileDialogHelper aDialogHelper( TemplateDescription::FILESAVE_AUTOEXTENSION, 0 );
+    Reference < XFilePicker > xFilePicker = aDialogHelper.GetFilePicker();
 
     INetURLObject aPath;
-    aPath.SetSmartURL( sGrfPath );
+    aPath.SetSmartURL( sGraphicsPath );
 
     // fish out the graphic's name
-    String aName = rGrfName;
+    OUString aName = rGraphicName;
 
-    aDlgHelper.SetTitle( SVX_RESSTR(RID_SVXSTR_EXPORT_GRAPHIC_TITLE));
-    aDlgHelper.SetDisplayDirectory( aPath.GetMainURL(INetURLObject::DECODE_TO_IURI) );
+    aDialogHelper.SetTitle( SVX_RESSTR(RID_SVXSTR_EXPORT_GRAPHIC_TITLE));
+    aDialogHelper.SetDisplayDirectory( aPath.GetMainURL(INetURLObject::DECODE_TO_IURI) );
     INetURLObject aURL;
     aURL.SetSmartURL( aName );
-    aDlgHelper.SetFileName( aURL.GetName() );
+    aDialogHelper.SetFileName( aURL.GetName() );
 
-    GraphicFilter& rGF = GraphicFilter::GetGraphicFilter();
-    const sal_uInt16 nCount = rGF.GetExportFormatCount();
+    GraphicFilter& rGraphicFilter = GraphicFilter::GetGraphicFilter();
+    const sal_uInt16 nCount = rGraphicFilter.GetExportFormatCount();
 
-    String aExt( aURL.GetExtension() );
-    if( !aExt.Len() )
-        GetPreferedExtension( aExt, rGraphic );
+    OUString aExtension( aURL.GetExtension() );
+    if( aExtension.isEmpty() )
+    {
+        GetPreferedExtension( aExtension, rGraphic );
+    }
 
-    aExt.ToLowerAscii();
-    sal_uInt16 nDfltFilter = USHRT_MAX;
+    aExtension = aExtension.toAsciiLowerCase();
+    sal_uInt16 nDefaultFilter = USHRT_MAX;
 
-    Reference<XFilterManager> xFltMgr(xFP, UNO_QUERY);
+    Reference<XFilterManager> xFilterManager(xFilePicker, UNO_QUERY);
 
     for ( sal_uInt16 i = 0; i < nCount; i++ )
     {
-        xFltMgr->appendFilter( rGF.GetExportFormatName( i ), rGF.GetExportWildcard( i ) );
-        if ( COMPARE_EQUAL == aExt.CompareIgnoreCaseToAscii(rGF.GetExportFormatShortName( i ).ToLowerAscii() ))
-            nDfltFilter = i;
+        xFilterManager->appendFilter( rGraphicFilter.GetExportFormatName( i ), rGraphicFilter.GetExportWildcard( i ) );
+        OUString aFormatShortName = rGraphicFilter.GetExportFormatShortName( i );
+        if ( aFormatShortName.equalsIgnoreAsciiCase( aExtension ) )
+        {
+            nDefaultFilter = i;
+        }
     }
-    if ( USHRT_MAX == nDfltFilter )
+    if ( USHRT_MAX == nDefaultFilter )
     {
         // "wrong" extension?
-        GetPreferedExtension( aExt, rGraphic );
+        GetPreferedExtension( aExtension, rGraphic );
         for ( sal_uInt16 i = 0; i < nCount; ++i )
-            if ( aExt == rGF.GetExportFormatShortName( i ).ToLowerAscii() )
+            if ( aExtension == rGraphicFilter.GetExportFormatShortName( i ).ToLowerAscii() )
             {
-                nDfltFilter =  i;
+                nDefaultFilter =  i;
                 break;
             }
     }
 
-    if( USHRT_MAX != nDfltFilter )
+    if( USHRT_MAX != nDefaultFilter )
     {
-        xFltMgr->setCurrentFilter( rGF.GetExportFormatName( nDfltFilter ) ) ;
+        xFilterManager->setCurrentFilter( rGraphicFilter.GetExportFormatName( nDefaultFilter ) ) ;
 
-        if( aDlgHelper.Execute() == ERRCODE_NONE )
+        if( aDialogHelper.Execute() == ERRCODE_NONE )
         {
-            String sPath( xFP->getFiles().getConstArray()[0] );
+            OUString sPath( xFilePicker->getFiles().getConstArray()[0] );
             // remember used path - please don't optimize away!
             aPath.SetSmartURL( sPath);
-            sGrfPath = aPath.GetPath();
+            sGraphicsPath = aPath.GetPath();
 
-            if( rGrfName.Len() &&
-                 nDfltFilter == rGF.GetExportFormatNumber( xFltMgr->getCurrentFilter()))
+            if( !rGraphicName.isEmpty() &&
+                nDefaultFilter == rGraphicFilter.GetExportFormatNumber( xFilterManager->getCurrentFilter()))
             {
                 // try to save the original graphic
-                SfxMedium aIn( rGrfName, STREAM_READ | STREAM_NOCREATE );
+                SfxMedium aIn( rGraphicName, STREAM_READ | STREAM_NOCREATE );
                 if( aIn.GetInStream() && !aIn.GetInStream()->GetError() )
                 {
                     SfxMedium aOut( sPath, STREAM_WRITE | STREAM_SHARE_DENYNONE);
@@ -149,19 +174,133 @@ String GraphicHelper::ExportGraphic( const Graphic &rGraphic, const String &rGrf
             }
 
             sal_uInt16 nFilter;
-            if ( !xFltMgr->getCurrentFilter().isEmpty() && rGF.GetExportFormatCount() )
-                nFilter = rGF.GetExportFormatNumber( xFltMgr->getCurrentFilter() );
+            if ( !xFilterManager->getCurrentFilter().isEmpty() && rGraphicFilter.GetExportFormatCount() )
+            {
+                nFilter = rGraphicFilter.GetExportFormatNumber( xFilterManager->getCurrentFilter() );
+            }
             else
+            {
                 nFilter = GRFILTER_FORMAT_DONTKNOW;
-            String aFilter( rGF.GetExportFormatShortName( nFilter ) );
-            XOutBitmap::WriteGraphic( rGraphic, sPath, aFilter,
-                                        XOUTBMP_DONT_EXPAND_FILENAME|
-                                        XOUTBMP_DONT_ADD_EXTENSION|
+            }
+            OUString aFilter( rGraphicFilter.GetExportFormatShortName( nFilter ) );
+
+            String aFilterString( aFilter );
+            String aPathString( sPath );
+            XOutBitmap::WriteGraphic( rGraphic, aPathString, aFilterString,
+                                        XOUTBMP_DONT_EXPAND_FILENAME |
+                                        XOUTBMP_DONT_ADD_EXTENSION |
                                         XOUTBMP_USE_NATIVE_IF_POSSIBLE );
             return sPath;
         }
     }
-    return String();
+    return OUString();
+}
+
+void GraphicHelper::SaveShapeAsGraphic( const Reference< XShape >& xShape )
+{
+    try
+    {
+        Reference< XMultiServiceFactory > xServiceFactory( ::comphelper::getProcessServiceFactory(), UNO_QUERY_THROW );
+        Reference< XPropertySet > xShapeSet( xShape, UNO_QUERY_THROW );
+
+        OUString aMimeType;
+        OUString sGraphicURL;
+
+        SvtPathOptions aPathOpt;
+        String sGraphicPath( aPathOpt.GetGraphicPath() );
+
+        FileDialogHelper aDialogHelper( TemplateDescription::FILESAVE_AUTOEXTENSION, 0 );
+        Reference < XFilePicker > xFilePicker = aDialogHelper.GetFilePicker();
+
+        aDialogHelper.SetTitle( OUString( "Save as Picture" ) );
+
+        INetURLObject aPath;
+        aPath.SetSmartURL( sGraphicPath );
+        xFilePicker->setDisplayDirectory( aPath.GetMainURL(INetURLObject::DECODE_TO_IURI) );
+
+        // populate filter dialog filter list and select default filter to match graphic mime type
+
+        GraphicFilter& rGraphicFilter = GraphicFilter::GetGraphicFilter();
+        Reference<XFilterManager> xFilterManager( xFilePicker, UNO_QUERY );
+        OUString aDefaultFormatName;
+        sal_uInt16 nCount = rGraphicFilter.GetExportFormatCount();
+
+        std::map< OUString, OUString > aMimeTypeMap;
+
+        for ( sal_uInt16 i = 0; i < nCount; i++ )
+        {
+            const OUString aExportFormatName( rGraphicFilter.GetExportFormatName( i ) );
+            const OUString aFilterMimeType( rGraphicFilter.GetExportFormatMediaType( i ) );
+            xFilterManager->appendFilter( aExportFormatName, rGraphicFilter.GetExportWildcard( i ) );
+            aMimeTypeMap[ aExportFormatName ] = aFilterMimeType;
+            if( aMimeType == aFilterMimeType )
+                aDefaultFormatName = aExportFormatName;
+        }
+
+        if( aDefaultFormatName.getLength() == 0 )
+        {
+            nCount = rGraphicFilter.GetImportFormatCount();
+            for( sal_uInt16 i = 0; i < nCount; i++ )
+            {
+                const OUString aFilterMimeType( rGraphicFilter.GetImportFormatMediaType( i ) );
+                if( aMimeType == aFilterMimeType )
+                {
+                    aDefaultFormatName = rGraphicFilter.GetImportFormatName( i );
+                    xFilterManager->appendFilter( aDefaultFormatName,  rGraphicFilter.GetImportWildcard( i ) );
+                    aMimeTypeMap[ aDefaultFormatName ] = aFilterMimeType;
+                    break;
+                }
+            }
+        }
+
+        if( aDefaultFormatName.getLength() == 0 )
+            aDefaultFormatName = OUString( "PNG - Portable Network Graphic" );
+
+        xFilterManager->setCurrentFilter( aDefaultFormatName );
+
+        // execute dialog
+
+        if( aDialogHelper.Execute() == ERRCODE_NONE )
+        {
+            OUString sPath( xFilePicker->getFiles().getConstArray()[0] );
+            OUString aExportMimeType( aMimeTypeMap[xFilterManager->getCurrentFilter()] );
+
+            Reference< XInputStream > xGraphStream;
+            if( aMimeType == aExportMimeType )
+            {
+                xShapeSet->getPropertyValue( OUString( "GraphicStream" ) ) >>= xGraphStream;
+            }
+
+            if( xGraphStream.is() )
+            {
+                OUString aSimpleFileAccessFilter( "com.sun.star.ucb.SimpleFileAccess" );
+                Reference<XSimpleFileAccess2> xFileAccess( xServiceFactory->createInstance( aSimpleFileAccessFilter ), UNO_QUERY_THROW );
+                xFileAccess->writeFile( sPath, xGraphStream );
+            }
+            else
+            {
+                OUString aGraphicExportFilter("com.sun.star.drawing.GraphicExportFilter");
+                Reference<XExporter> xGraphicExporter( xServiceFactory->createInstance( aGraphicExportFilter ), UNO_QUERY_THROW );
+                Reference<XFilter> xFilter( xGraphicExporter, UNO_QUERY_THROW );
+
+                Sequence<PropertyValue> aDescriptor( 2 );
+                aDescriptor[0].Name = OUString("MediaType");
+                aDescriptor[0].Value <<= aExportMimeType;
+                aDescriptor[1].Name = OUString("URL");
+                aDescriptor[1].Value <<= sPath;
+
+                Reference< XComponent > xSourceDocument = Reference< XComponent >( xShape, UNO_QUERY_THROW );
+                if ( xSourceDocument.is() )
+                {
+                    xGraphicExporter->setSourceDocument( xSourceDocument );
+                    xFilter->filter( aDescriptor );
+                }
+            }
+        }
+    }
+    catch( Exception& )
+    {
+    }
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit f4bfbc56bdf2b942740628ce28e08994227142cf
Author: Armin Le Grand <alg at apache.org>
Date:   Mon Jun 11 08:38:23 2012 +0000

    Resolves: #i119735# missing css.svg.SVGWriter when using GraphicProvider
    
    missing implementation for com.sun.star.svg.SVGWriter when using
    GraphicProvider
    
    Adapted patch provided by Sven Jacobi (thanks), added some fixes/cleanups to
    make it work with all kind of graphics (SVG, Bitmap, Metafile)
    
    (cherry picked from commit 891011181285d7ad54984ffd05ed44d825a70647)
    
    Conflicts:
    	filter/inc/filter/msfilter/msdffimp.hxx
    	filter/source/graphicfilter/epict/epict.cxx
    	filter/source/svg/svgexport.cxx
    	filter/source/svg/svguno.cxx
    	filter/source/svg/svgwriter.cxx
    	filter/source/svg/svgwriter.hxx
    	svtools/source/filter/filter.cxx
    
    Change-Id: Ie53f995614060a00c709f620f89d132913a25c5c

diff --git a/filter/source/graphicfilter/eos2met/eos2met.cxx b/filter/source/graphicfilter/eos2met/eos2met.cxx
index 834a0f4..09110c7 100644
--- a/filter/source/graphicfilter/eos2met/eos2met.cxx
+++ b/filter/source/graphicfilter/eos2met/eos2met.cxx
@@ -2561,20 +2561,8 @@ extern "C" SAL_DLLPUBLIC_EXPORT sal_Bool __LOADONCALLAPI
 GraphicExport( SvStream & rStream, Graphic & rGraphic, FilterConfigItem* pFilterConfigItem, sal_Bool )
 {   METWriter aMETWriter;
 
-    if ( rGraphic.GetType() == GRAPHIC_GDIMETAFILE )
-        return aMETWriter.WriteMET( rGraphic.GetGDIMetaFile(), rStream, pFilterConfigItem );
-    else
-    {
-        Bitmap aBmp=rGraphic.GetBitmap();
-        GDIMetaFile aMTF;
-        VirtualDevice aVirDev;
-
-        aMTF.Record(&aVirDev);
-        aVirDev.DrawBitmap(Point(),aBmp);
-        aMTF.Stop();
-        aMTF.SetPrefSize(aBmp.GetSizePixel());
-        return aMETWriter.WriteMET( aMTF, rStream, pFilterConfigItem );
-    }
+    // #119735# just use GetGDIMetaFile, it will create a bufferd version of contained bitmap now automatically
+    return aMETWriter.WriteMET( rGraphic.GetGDIMetaFile(), rStream, pFilterConfigItem );
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/filter/source/graphicfilter/epict/epict.cxx b/filter/source/graphicfilter/epict/epict.cxx
index 7af0456..f94ce97 100644
--- a/filter/source/graphicfilter/epict/epict.cxx
+++ b/filter/source/graphicfilter/epict/epict.cxx
@@ -2282,23 +2282,10 @@ GraphicExport(SvStream & rStream, Graphic & rGraphic, FilterConfigItem* pFilterC
 {
     PictWriter      aPictWriter;
 
-    if (rGraphic.GetType()==GRAPHIC_GDIMETAFILE)
-    {
-        GDIMetaFile aScaledMtf( rGraphic.GetGDIMetaFile() );
-        return aPictWriter.WritePict( aScaledMtf, rStream, pFilterConfigItem );
-    }
-    else
-    {
-        Bitmap aBmp=rGraphic.GetBitmap();
-        GDIMetaFile aMTF;
-        VirtualDevice aVirDev;
-
-        aMTF.Record(&aVirDev);
-        aVirDev.DrawBitmap(Point(),aBmp);
-        aMTF.Stop();
-        aMTF.SetPrefSize(aBmp.GetSizePixel());
-        return aPictWriter.WritePict( aMTF, rStream, pFilterConfigItem );
-    }
+    // #i119735# just use GetGDIMetaFile, it will create a bufferd version of contained bitmap now automatically
+    GDIMetaFile aScaledMtf( rGraphic.GetGDIMetaFile() );
+
+    return aPictWriter.WritePict( aScaledMtf, rStream, pFilterConfigItem );
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/filter/source/svg/svgexport.cxx b/filter/source/svg/svgexport.cxx
index 4289a30..5e61ce3 100644
--- a/filter/source/svg/svgexport.cxx
+++ b/filter/source/svg/svgexport.cxx
@@ -2345,4 +2345,46 @@ IMPL_LINK( SVGFilter, CalcFieldHdl, EditFieldInfo*, pInfo )
     return ( bFieldProcessed ? 0 : maOldFieldHdl.Call( pInfo ) );
 }
 
+// -----------------------------------------------------------------------------
+
+void SVGExport::writeMtf( const GDIMetaFile& rMtf )
+{
+    const Size aSize( OutputDevice::LogicToLogic( rMtf.GetPrefSize(), rMtf.GetPrefMapMode(), MAP_MM ) );
+    rtl::OUString aAttr;
+    Reference< XExtendedDocumentHandler> xExtDocHandler( GetDocHandler(), UNO_QUERY );
+
+    if( xExtDocHandler.is() )
+        xExtDocHandler->unknown( SVG_DTD_STRING );
+
+    aAttr = rtl::OUString::valueOf( aSize.Width() );
+    aAttr += "mm";
+    AddAttribute( XML_NAMESPACE_NONE, "width", aAttr );
+
+    aAttr = rtl::OUString::valueOf( aSize.Height() );
+    aAttr += "mm";
+    AddAttribute( XML_NAMESPACE_NONE, "height", aAttr );
+
+    aAttr = "0 0 ";
+    aAttr += rtl::OUString::valueOf( aSize.Width() * 100L );
+    aAttr += " ";
+    aAttr += rtl::OUString::valueOf( aSize.Height() * 100L );
+    AddAttribute( XML_NAMESPACE_NONE, "viewBox", aAttr );
+
+    {
+        SvXMLElementExport  aSVG( *this, XML_NAMESPACE_NONE, "svg", sal_True, sal_True );
+
+        std::vector< ObjectRepresentation > aObjects;
+
+        aObjects.push_back( ObjectRepresentation( Reference< XInterface >(), rMtf ) );
+        SVGFontExport aSVGFontExport( *this, aObjects );
+
+        Point aPoint100thmm( OutputDevice::LogicToLogic( rMtf.GetPrefMapMode().GetOrigin(), rMtf.GetPrefMapMode(), MAP_100TH_MM ) );
+        Size  aSize100thmm( OutputDevice::LogicToLogic( rMtf.GetPrefSize(), rMtf.GetPrefMapMode(), MAP_100TH_MM ) );
+
+        SVGActionWriter aWriter( *this, aSVGFontExport );
+        aWriter.WriteMetaFile( aPoint100thmm, aSize100thmm, rMtf,
+            SVGWRITER_WRITE_FILL | SVGWRITER_WRITE_TEXT, NULL );
+    }
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/filter/source/svg/svgfilter.component b/filter/source/svg/svgfilter.component
index 51fd50d6..1bf7b47 100644
--- a/filter/source/svg/svgfilter.component
+++ b/filter/source/svg/svgfilter.component
@@ -24,4 +24,7 @@
     <service name="com.sun.star.document.ExportFilter"/>
     <service name="com.sun.star.document.ExtendedTypeDetection"/>
   </implementation>
+  <implementation name="com.sun.star.comp.Draw.SVGWriter">
+    <service name="com.sun.star.svg.SVGWriter"/>
+  </implementation>
 </component>
diff --git a/filter/source/svg/svgfilter.cxx b/filter/source/svg/svgfilter.cxx
index bbe2a3c..365caea 100644
--- a/filter/source/svg/svgfilter.cxx
+++ b/filter/source/svg/svgfilter.cxx
@@ -43,6 +43,7 @@
 #include <osl/mutex.hxx>
 
 #include "svgfilter.hxx"
+#include "svgwriter.hxx"
 
 using ::rtl::OUString;
 using namespace ::com::sun::star;
@@ -309,23 +310,39 @@ rtl::OUString SAL_CALL SVGFilter::detect( Sequence< PropertyValue >& io_rDescrip
 
 // -----------------------------------------------------------------------------
 
+#define SVG_FILTER_IMPL_NAME "com.sun.star.comp.Draw.SVGFilter"
+#define SVG_WRITER_IMPL_NAME "com.sun.star.comp.Draw.SVGWriter"
+
 namespace sdecl = comphelper::service_decl;
- sdecl::class_<SVGFilter> serviceImpl;
+ sdecl::class_<SVGFilter> serviceFilterImpl;
  const sdecl::ServiceDecl svgFilter(
-     serviceImpl,
-     "com.sun.star.comp.Draw.SVGFilter",
+     serviceFilterImpl,
+     SVG_FILTER_IMPL_NAME,
      "com.sun.star.document.ImportFilter;"
      "com.sun.star.document.ExportFilter;"
      "com.sun.star.document.ExtendedTypeDetection" );
 
+ sdecl::class_<SVGWriter> serviceWriterImpl;
+ const sdecl::ServiceDecl svgWriter(
+     serviceWriterImpl,
+     SVG_WRITER_IMPL_NAME,
+     "com.sun.star.svg.SVGWriter" );
+
 // The C shared lib entry points
 extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL svgfilter_component_getFactory(
     sal_Char const* pImplName,
     ::com::sun::star::lang::XMultiServiceFactory* pServiceManager,
     ::com::sun::star::registry::XRegistryKey* pRegistryKey )
 {
-    return component_getFactoryHelper( pImplName, pServiceManager,
-        pRegistryKey, svgFilter );
+    if ( rtl_str_compare (pImplName, SVG_FILTER_IMPL_NAME) == 0 )
+    {
+        return component_getFactoryHelper( pImplName, pServiceManager, pRegistryKey, svgFilter );
+    }
+    else if ( rtl_str_compare (pImplName, SVG_WRITER_IMPL_NAME) == 0 )
+    {
+        return component_getFactoryHelper( pImplName, pServiceManager, pRegistryKey, svgWriter );
+    }
+    return NULL;
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/filter/source/svg/svgfilter.hxx b/filter/source/svg/svgfilter.hxx
index 975b7c6..2469198 100644
--- a/filter/source/svg/svgfilter.hxx
+++ b/filter/source/svg/svgfilter.hxx
@@ -133,6 +133,8 @@ public:
     sal_Bool IsUseNativeTextDecoration() const;
     sal_Bool IsUseOpacity() const;
 
+    void writeMtf( const GDIMetaFile& rMtf );
+
 protected:
 
     virtual void            _ExportStyles( sal_Bool /* bUsed */ ) {}
diff --git a/filter/source/svg/svgwriter.cxx b/filter/source/svg/svgwriter.cxx
index 2f269ba..849298f 100644
--- a/filter/source/svg/svgwriter.cxx
+++ b/filter/source/svg/svgwriter.cxx
@@ -2848,7 +2848,10 @@ void SVGActionWriter::ImplWriteText( const Point& rPos, const String& rText,
                         if( bCont )
                         {
                             // #118796# do NOT access pDXArray, it may be zero (!)
-                            nX = aPos.X() + pDX[ nCurPos - 1 ];
+                            sal_Int32 nDXWidth = pDX[ nCurPos - 1 ];
+                            if ( bApplyMapping )
+                                nDXWidth = ImplMap( nDXWidth );
+                            nX = aPos.X() + nDXWidth;
                         }
                     }
                 }
@@ -3906,4 +3909,37 @@ void SVGActionWriter::WriteMetaFile( const Point& rPos100thmm,
     mpVDev->Pop();
 }
 
+// -------------
+// - SVGWriter -
+// -------------
+
+SVGWriter::SVGWriter( const Reference< XComponentContext >& rxCtx )
+    : mxContext(rxCtx)
+{
+}
+
+// -----------------------------------------------------------------------------
+
+SVGWriter::~SVGWriter()
+{
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL SVGWriter::write( const Reference<XDocumentHandler>& rxDocHandler,
+                                const Sequence<sal_Int8>& rMtfSeq ) throw( RuntimeException )
+{
+    SvMemoryStream  aMemStm( (char*) rMtfSeq.getConstArray(), rMtfSeq.getLength(), STREAM_READ );
+    GDIMetaFile     aMtf;
+
+    aMemStm >> aMtf;
+
+    const Reference< XDocumentHandler > xDocumentHandler( rxDocHandler );
+    const Sequence< PropertyValue > aFilterData;
+
+    SVGExport* pWriter = new SVGExport( mxContext, xDocumentHandler, aFilterData );
+    pWriter->writeMtf( aMtf );
+    delete pWriter;
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/filter/source/svg/svgwriter.hxx b/filter/source/svg/svgwriter.hxx
index ebffda9..8813646 100644
--- a/filter/source/svg/svgwriter.hxx
+++ b/filter/source/svg/svgwriter.hxx
@@ -21,7 +21,7 @@
 #define SVGWRITER_HXX
 
 #include <stack>
-#include <cppuhelper/weak.hxx>
+#include <cppuhelper/implbase1.hxx>
 #include <rtl/ustring.hxx>
 #include <tools/stream.hxx>
 #include <tools/string.hxx>
@@ -58,6 +58,7 @@
 #include <com/sun/star/text/XTextRange.hpp>
 #include <com/sun/star/text/XTextField.hpp>
 #include <com/sun/star/style/NumberingType.hpp>
+#include <com/sun/star/svg/XSVGWriter.hpp>
 
 
 // -----------------------------------------------------------------------------
@@ -68,6 +69,8 @@ using namespace ::com::sun::star::lang;
 using namespace ::com::sun::star::text;
 using namespace ::com::sun::star::drawing;
 using namespace ::com::sun::star::style;
+using namespace ::com::sun::star::svg;
+using namespace ::com::sun::star::xml::sax;
 
 // -----------------------------------------------------------------------------
 
@@ -162,6 +165,7 @@ struct SVGShapeDescriptor
 
 
 class SVGAttributeWriter;
+class SVGExport;
 class GDIMetaFile;
 
 
@@ -409,6 +413,22 @@ public:
                                            const GDIMetaFile* pTextEmbeddedBitmapMtf = NULL );
 };
 
+class SVGWriter : public cppu::WeakImplHelper1< XSVGWriter >
+{
+private:
+    Reference< XComponentContext >      mxContext;
+
+    SVGWriter();
+
+public:
+    explicit SVGWriter( const Reference< XComponentContext >& rxCtx );
+    virtual ~SVGWriter();
+
+    // XSVGWriter
+    virtual void SAL_CALL write( const Reference<XDocumentHandler>& rxDocHandler,
+        const Sequence<sal_Int8>& rMtfSeq ) throw( RuntimeException );
+};
+
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdxcgv.cxx b/svx/source/svdraw/svdxcgv.cxx
index df282db6..4c9cfed 100644
--- a/svx/source/svdraw/svdxcgv.cxx
+++ b/svx/source/svdraw/svdxcgv.cxx
@@ -514,16 +514,8 @@ GDIMetaFile SdrExchangeView::GetMarkedObjMetaFile(bool bNoVDevIfOneMtfMarked) co
             {
                 Graphic aGraphic( pGrafObj->GetTransformedGraphic() );
 
-                if( aGraphic.GetType() == GRAPHIC_BITMAP )
-                {
-                    const Point aPos;
-
-                    aMtf.AddAction( new MetaBmpExScaleAction( aPos, aBoundSize, aGraphic.GetBitmapEx() ) );
-                    aMtf.SetPrefMapMode( aMap );
-                    aMtf.SetPrefSize( aBoundSize );
-                }
-                else
-                    aMtf = aGraphic.GetGDIMetaFile();
+                // #119735# just use GetGDIMetaFile, it will create a bufferd version of contained bitmap now automatically
+                aMtf = aGraphic.GetGDIMetaFile();
             }
         }
 
diff --git a/svx/source/unodraw/unoshap4.cxx b/svx/source/unodraw/unoshap4.cxx
index c516b6ff..8d806e9 100644
--- a/svx/source/unodraw/unoshap4.cxx
+++ b/svx/source/unodraw/unoshap4.cxx
@@ -235,18 +235,8 @@ bool SvxOle2Shape::getPropertyValueImpl( const ::rtl::OUString& rName, const Sfx
                 }
                 if ( !bIsWMF )
                 {
-                    GDIMetaFile aMtf;
-                    if ( pGraphic->GetType() != GRAPHIC_BITMAP )
-                        aMtf = pObj->GetGraphic()->GetGDIMetaFile();
-                    else
-                    {
-                        VirtualDevice aVirDev;
-                        aMtf.Record( &aVirDev );
-                        pGraphic->Draw( &aVirDev, Point(),  pGraphic->GetPrefSize() );
-                        aMtf.Stop();
-                        aMtf.SetPrefSize( pGraphic->GetPrefSize() );
-                        aMtf.SetPrefMapMode( pGraphic->GetPrefMapMode() );
-                    }
+                    // #i119735# just use GetGDIMetaFile, it will create a bufferd version of contained bitmap now automatically
+                    GDIMetaFile aMtf(pObj->GetGraphic()->GetGDIMetaFile());
                     SvMemoryStream aDestStrm( 65535, 65535 );
                     ConvertGDIMetaFileToWMF( aMtf, aDestStrm, NULL, sal_False );
                     const uno::Sequence<sal_Int8> aSeq(
diff --git a/svx/source/unodraw/unoshape.cxx b/svx/source/unodraw/unoshape.cxx
index dc41794..28f174c 100644
--- a/svx/source/unodraw/unoshape.cxx
+++ b/svx/source/unodraw/unoshape.cxx
@@ -2945,18 +2945,8 @@ bool SvxShape::getPropertyValueImpl( const ::rtl::OUString&, const SfxItemProper
                 }
                 if ( !bIsWMF )
                 {
-                    GDIMetaFile aMtf;
-                    if ( pGraphic->GetType() != GRAPHIC_BITMAP )
-                        aMtf = pObj->GetGraphic()->GetGDIMetaFile();
-                    else
-                    {
-                        VirtualDevice aVirDev;
-                        aMtf.Record( &aVirDev );
-                        pGraphic->Draw( &aVirDev, Point(),  pGraphic->GetPrefSize() );
-                        aMtf.Stop();
-                        aMtf.SetPrefSize( pGraphic->GetPrefSize() );
-                        aMtf.SetPrefMapMode( pGraphic->GetPrefMapMode() );
-                    }
+                    // #119735# just use GetGDIMetaFile, it will create a bufferd version of contained bitmap now automatically
+                    GDIMetaFile aMtf(pObj->GetGraphic()->GetGDIMetaFile());
                     SvMemoryStream aDestStrm( 65535, 65535 );
                     ConvertGDIMetaFileToWMF( aMtf, aDestStrm, NULL, sal_False );
                     const uno::Sequence<sal_Int8> aSeq(
diff --git a/vcl/source/filter/graphicfilter.cxx b/vcl/source/filter/graphicfilter.cxx
index 3a68acd..4af61de 100644
--- a/vcl/source/filter/graphicfilter.cxx
+++ b/vcl/source/filter/graphicfilter.cxx
@@ -2017,69 +2017,30 @@ sal_uInt16 GraphicFilter::ExportGraphic( const Graphic& rGraphic, const String&
                 sal_Int32 nVersion = aConfigItem.ReadInt32( String( RTL_CONSTASCII_USTRINGPARAM( "Version" ) ), 0 ) ;
                 if ( nVersion )
                     rOStm.SetVersion( nVersion );
-                GDIMetaFile aMTF;
 
-                if ( eType != GRAPHIC_BITMAP )
-                    aMTF = aGraphic.GetGDIMetaFile();
-                else
-                {
-                    VirtualDevice aVirDev;
+                // #i119735# just use GetGDIMetaFile, it will create a bufferd version of contained bitmap now automatically
+                GDIMetaFile aMTF(aGraphic.GetGDIMetaFile());
 
-                    aMTF.Record( &aVirDev );
-                    aGraphic.Draw( &aVirDev, Point(), aGraphic.GetPrefSize() );
-                    aMTF.Stop();
-                    aMTF.SetPrefSize( aGraphic.GetPrefSize() );
-                    aMTF.SetPrefMapMode( aGraphic.GetPrefMapMode() );
-                }
                 aMTF.Write( rOStm );
+
                 if( rOStm.GetError() )
                     nStatus = GRFILTER_IOERROR;
             }
             else if ( aFilterName.EqualsIgnoreCaseAscii( EXP_WMF ) )
             {
-                if( eType == GRAPHIC_GDIMETAFILE )
-                {
-                    if ( !ConvertGDIMetaFileToWMF( aGraphic.GetGDIMetaFile(), rOStm, &aConfigItem ) )
-                        nStatus = GRFILTER_FORMATERROR;
-                }
-                else
-                {
-                    Bitmap          aBmp( aGraphic.GetBitmap() );
-                    GDIMetaFile     aMTF;
-                    VirtualDevice   aVirDev;
-
-                    aMTF.Record( &aVirDev );
-                    aVirDev.DrawBitmap( Point(), aBmp );
-                    aMTF.Stop();
-                    aMTF.SetPrefSize( aBmp.GetSizePixel() );
+                // #i119735# just use GetGDIMetaFile, it will create a bufferd version of contained bitmap now automatically
+                if ( !ConvertGDIMetaFileToWMF( aGraphic.GetGDIMetaFile(), rOStm, &aConfigItem ) )
+                    nStatus = GRFILTER_FORMATERROR;
 
-                    if( !ConvertGDIMetaFileToWMF( aMTF, rOStm, &aConfigItem ) )
-                        nStatus = GRFILTER_FORMATERROR;
-                }
                 if( rOStm.GetError() )
                     nStatus = GRFILTER_IOERROR;
             }
             else if ( aFilterName.EqualsIgnoreCaseAscii( EXP_EMF ) )
             {
-                if( eType == GRAPHIC_GDIMETAFILE )
-                {
-                    if ( !ConvertGDIMetaFileToEMF( aGraphic.GetGDIMetaFile(), rOStm, &aConfigItem ) )
-                        nStatus = GRFILTER_FORMATERROR;
-                }
-                else
-                {
-                    Bitmap          aBmp( aGraphic.GetBitmap() );
-                    GDIMetaFile     aMTF;
-                    VirtualDevice   aVirDev;
-
-                    aMTF.Record( &aVirDev );
-                    aVirDev.DrawBitmap( Point(), aBmp );
-                    aMTF.Stop();
-                    aMTF.SetPrefSize( aBmp.GetSizePixel() );
+                // #i119735# just use GetGDIMetaFile, it will create a bufferd version of contained bitmap now automatically
+                if ( !ConvertGDIMetaFileToEMF( aGraphic.GetGDIMetaFile(), rOStm, &aConfigItem ) )
+                    nStatus = GRFILTER_FORMATERROR;
 
-                    if( !ConvertGDIMetaFileToEMF( aMTF, rOStm, &aConfigItem ) )
-                        nStatus = GRFILTER_FORMATERROR;
-                }
                 if( rOStm.GetError() )
                     nStatus = GRFILTER_IOERROR;
             }
@@ -2195,6 +2156,7 @@ sal_uInt16 GraphicFilter::ExportGraphic( const Graphic& rGraphic, const String&
 
                                     SvMemoryStream aMemStm( 65535, 65535 );
 
+                                    // #i119735# just use GetGDIMetaFile, it will create a bufferd version of contained bitmap now automatically
                                     ( (GDIMetaFile&) aGraphic.GetGDIMetaFile() ).Write( aMemStm );
 
                                     xActiveDataSource->setOutputStream( ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >(
diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx
index 2421bcb..9a036b4 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -666,6 +666,40 @@ Animation ImpGraphic::ImplGetAnimation() const
 
 const GDIMetaFile& ImpGraphic::ImplGetGDIMetaFile() const
 {
+    if (GRAPHIC_BITMAP == meType && !maMetaFile.GetActionSize())
+    {
+        // #i119735#
+        // Use the local maMetaFile as container for a metafile-representation
+        // of the bitmap graphic. This will be done only once, thus be buffered.
+        // I checked all usages of maMetaFile, it is only used when type is not
+        // GRAPHIC_BITMAP. In operator= it will get copied, thus buffering will
+        // survive copying (change this if not wanted)
+        ImpGraphic* pThat = const_cast< ImpGraphic* >(this);
+
+        if(maSvgData.get() && !maEx)
+        {
+            // use maEx as local buffer for rendered svg
+            pThat->maEx = maSvgData->getReplacement();
+        }
+
+        VirtualDevice aVirDev;
+        const Size aSizePixel(maEx.GetSizePixel());
+
+        pThat->maMetaFile.Record(&aVirDev);
+
+        if(maEx.IsTransparent())
+        {
+            aVirDev.DrawBitmapEx(Point(), maEx);
+        }
+        else
+        {
+            aVirDev.DrawBitmap(Point(), maEx.GetBitmap());
+        }
+
+        pThat->maMetaFile.Stop();
+        pThat->maMetaFile.SetPrefSize(aSizePixel);
+    }
+
     return maMetaFile;
 }
 


More information about the Libreoffice-commits mailing list