[Libreoffice-commits] core.git: desktop/source filter/Configuration_filter.mk filter/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Dec 14 18:53:17 UTC 2018


 desktop/source/lib/init.cxx                                  |    9 
 filter/Configuration_filter.mk                               |    2 
 filter/source/config/fragments/filters/writer_svg_Export.xcu |   30 +
 filter/source/svg/svgexport.cxx                              |  245 +++++++----
 filter/source/svg/svgfilter.cxx                              |   82 +++
 filter/source/svg/svgfilter.hxx                              |   42 +
 6 files changed, 312 insertions(+), 98 deletions(-)

New commits:
commit b052974a6574e4074794ffa590fe60f7c1726768
Author:     Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Fri Dec 14 17:50:18 2018 +0100
Commit:     Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Fri Dec 14 19:52:48 2018 +0100

    lok: Implement SVG export for Writer (SelectionOnly mode)
    
    Separate generic code from Impress / Draw specific code
    and implement shape selection handling in case of Writer.
    This is an internal filter, so it can be called only from
    the code.
    
    Change-Id: I807e04a0949530d6029037bb964c10c80197ff33
    Reviewed-on: https://gerrit.libreoffice.org/65174
    Tested-by: Jenkins
    Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 90994a92c257..65ccfdf4a411 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -2618,7 +2618,14 @@ static size_t doc_renderShapeSelection(LibreOfficeKitDocument* pThis, char** pOu
         uno::Reference<io::XOutputStream> xOut = new utl::OOutputStreamWrapper(aOutStream);
 
         utl::MediaDescriptor aMediaDescriptor;
-        aMediaDescriptor["FilterName"] <<= OUString("impress_svg_Export");
+        if (doc_getDocumentType(pThis) == LOK_DOCTYPE_PRESENTATION)
+        {
+            aMediaDescriptor["FilterName"] <<= OUString("impress_svg_Export");
+        }
+        else if(doc_getDocumentType(pThis) == LOK_DOCTYPE_TEXT)
+        {
+            aMediaDescriptor["FilterName"] <<= OUString("writer_svg_Export");
+        }
         aMediaDescriptor["SelectionOnly"] <<= true;
         aMediaDescriptor["OutputStream"] <<= xOut;
 
diff --git a/filter/Configuration_filter.mk b/filter/Configuration_filter.mk
index d7a6322e5564..b56e0ae39bc8 100644
--- a/filter/Configuration_filter.mk
+++ b/filter/Configuration_filter.mk
@@ -790,11 +790,13 @@ $(eval $(call filter_Configuration_add_filters,fcfg_langpack,fcfg_impressgraphic
 $(eval $(call filter_Configuration_add_types,fcfg_langpack,fcfg_writergraphics_types.xcu,filter/source/config/fragments/types,\
 	jpg_JPEG \
 	png_Portable_Network_Graphic \
+	svg_Scalable_Vector_Graphics \
 ))
 
 $(eval $(call filter_Configuration_add_filters,fcfg_langpack,fcfg_writergraphics_filters.xcu,filter/source/config/fragments/filters,\
 	writer_jpg_Export \
 	writer_png_Export \
+	writer_svg_Export \
 ))
 
 # fcfg_calcgraphics
diff --git a/filter/source/config/fragments/filters/writer_svg_Export.xcu b/filter/source/config/fragments/filters/writer_svg_Export.xcu
new file mode 100644
index 000000000000..c08576cdd69b
--- /dev/null
+++ b/filter/source/config/fragments/filters/writer_svg_Export.xcu
@@ -0,0 +1,30 @@
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+-->
+    <node oor:name="writer_svg_Export" oor:op="replace">
+        <prop oor:name="Flags"><value>EXPORT ALIEN 3RDPARTYFILTER INTERNAL NOTINFILEDIALOG</value></prop>
+        <prop oor:name="UIComponent"/>
+        <prop oor:name="FilterService"><value>com.sun.star.comp.Draw.SVGFilter</value></prop>
+        <prop oor:name="UserData"><value></value></prop>
+        <prop oor:name="UIName">
+            <value xml:lang="en-US">SVG - Scalable Vector Graphics</value>
+        </prop>
+        <prop oor:name="FileFormatVersion"><value>0</value></prop>
+        <prop oor:name="Type"><value>svg_Scalable_Vector_Graphics</value></prop>
+        <prop oor:name="TemplateName"/>
+        <prop oor:name="DocumentService"><value>com.sun.star.text.TextDocument</value></prop>
+    </node>
diff --git a/filter/source/svg/svgexport.cxx b/filter/source/svg/svgexport.cxx
index babf682a024f..729fd2e29c2c 100644
--- a/filter/source/svg/svgexport.cxx
+++ b/filter/source/svg/svgexport.cxx
@@ -504,12 +504,10 @@ bool EqualityBitmap::operator()( const ObjectRepresentation& rObjRep1,
 
 bool SVGFilter::implExport( const Sequence< PropertyValue >& rDescriptor )
 {
-    Reference< XComponentContext >        xContext( ::comphelper::getProcessComponentContext() ) ;
     Reference< XOutputStream >            xOStm;
     std::unique_ptr<SvStream>             pOStm;
     sal_Int32                             nLength = rDescriptor.getLength();
     const PropertyValue*                  pValue = rDescriptor.getConstArray();
-    bool                                  bRet = false;
 
     maFilterData.realloc( 0 );
 
@@ -533,11 +531,22 @@ bool SVGFilter::implExport( const Sequence< PropertyValue >& rDescriptor )
         }
     }
 
-    if( xOStm.is() )
+    if(mbWriterFilter)
+       return implExportWriter(xOStm);
+
+    return implExportImpressDraw(xOStm);
+}
+
+bool SVGFilter::implExportImpressDraw( const Reference< XOutputStream >& rxOStm)
+{
+    Reference< XComponentContext >        xContext( ::comphelper::getProcessComponentContext() ) ;
+    bool                                  bRet = false;
+
+    if( rxOStm.is() )
     {
         if( !mSelectedPages.empty() && !mMasterPageTargets.empty() )
         {
-            Reference< XDocumentHandler > xDocHandler( implCreateExportDocumentHandler( xOStm ), UNO_QUERY );
+            Reference< XDocumentHandler > xDocHandler( implCreateExportDocumentHandler( rxOStm ), UNO_QUERY );
 
             if( xDocHandler.is() )
             {
@@ -616,7 +625,51 @@ bool SVGFilter::implExport( const Sequence< PropertyValue >& rDescriptor )
             }
         }
     }
+    return bRet;
+}
+
+
+bool SVGFilter::implExportWriter( const Reference< XOutputStream >& rxOStm )
+{
+    Reference< XComponentContext >        xContext( ::comphelper::getProcessComponentContext() ) ;
+    bool                                  bRet = false;
+
+    if( rxOStm.is() )
+    {
+        Reference< XDocumentHandler > xDocHandler( implCreateExportDocumentHandler( rxOStm ), UNO_QUERY );
+
+        if( xDocHandler.is() )
+        {
+            mpObjects = new ObjectMap;
+
+            // mpSVGExport = new SVGExport( xDocHandler );
+            mpSVGExport = new SVGExport( xContext, xDocHandler, maFilterData );
+
+            // xSVGExport is set up only to manage the life-time of the object pointed by mpSVGExport,
+            // and in order to prevent that it is destroyed when passed to AnimationExporter.
+            Reference< XInterface > xSVGExport = static_cast< css::document::XFilter* >( mpSVGExport );
 
+            try
+            {
+                mxDefaultPage = mSelectedPages[0];
+                bRet = implExportDocument();
+            }
+            catch( ... )
+            {
+                delete mpSVGDoc;
+                mpSVGDoc = nullptr;
+                OSL_FAIL( "Exception caught" );
+            }
+
+            delete mpSVGWriter;
+            mpSVGWriter = nullptr;
+            mpSVGExport = nullptr; // pointed object is released by xSVGExport dtor at the end of this scope
+            delete mpSVGFontExport;
+            mpSVGFontExport = nullptr;
+            delete mpObjects;
+            mpObjects = nullptr;
+        }
+    }
     return bRet;
 }
 
@@ -639,6 +692,11 @@ bool SVGFilter::implLookForFirstVisiblePage()
 {
     sal_Int32 nCurPage = 0, nLastPage = mSelectedPages.size() - 1;
 
+    if(!mbPresentation || mbSinglePage)
+    {
+        mnVisiblePage = nCurPage;
+    }
+
     while( ( nCurPage <= nLastPage ) && ( -1 == mnVisiblePage ) )
     {
         const Reference< css::drawing::XDrawPage > & xDrawPage = mSelectedPages[nCurPage];
@@ -651,8 +709,7 @@ bool SVGFilter::implLookForFirstVisiblePage()
             {
                 bool bVisible = false;
 
-                if( !mbPresentation || mbSinglePage ||
-                    ( ( xPropSet->getPropertyValue( "Visible" ) >>= bVisible ) && bVisible ) )
+                if( ( xPropSet->getPropertyValue( "Visible" ) >>= bVisible ) && bVisible )
                 {
                     mnVisiblePage = nCurPage;
                 }
@@ -667,17 +724,15 @@ bool SVGFilter::implLookForFirstVisiblePage()
 
 bool SVGFilter::implExportDocument()
 {
-    OUString         aAttr;
     sal_Int32        nDocX = 0, nDocY = 0; // #i124608#
     sal_Int32        nDocWidth = 0, nDocHeight = 0;
-    bool         bRet = false;
+    bool             bRet = false;
     sal_Int32        nLastPage = mSelectedPages.size() - 1;
 
     mbSinglePage = (nLastPage == 0);
     mnVisiblePage = -1;
 
     const Reference< XPropertySet >             xDefaultPagePropertySet( mxDefaultPage, UNO_QUERY );
-    const Reference< XExtendedDocumentHandler > xExtDocHandler( mpSVGExport->GetDocHandler(), UNO_QUERY );
 
     // #i124608#
     mbExportShapeSelection = mbSinglePage && maShapeSelection.is() && maShapeSelection->getCount();
@@ -693,33 +748,18 @@ bool SVGFilter::implExportDocument()
         // #i124608# create BoundRange and set nDocX, nDocY, nDocWidth and nDocHeight
         basegfx::B2DRange aShapeRange;
 
-        uno::Reference< XPrimitiveFactory2D > xPrimitiveFactory = PrimitiveFactory2D::create( mxContext );
-
-        // use XPrimitiveFactory2D and go the way over getting the primitives; this
-        // will give better precision (doubles) and be based on the true object
-        // geometry. If needed aViewInformation may be expanded to carry a view
-        // resolution for which to prepare the geometry.
-        if(xPrimitiveFactory.is())
+        for(sal_Int32 a(0); a < maShapeSelection->getCount(); a++)
         {
             Reference< css::drawing::XShape > xShapeCandidate;
-            const Sequence< PropertyValue > aViewInformation;
-            const Sequence< PropertyValue > aParams;
-
-            for(sal_Int32 a(0); a < maShapeSelection->getCount(); a++)
+            if((maShapeSelection->getByIndex(a) >>= xShapeCandidate) && xShapeCandidate.is())
             {
-                if((maShapeSelection->getByIndex(a) >>= xShapeCandidate) && xShapeCandidate.is())
+                Reference< XPropertySet > xShapePropSet( xShapeCandidate, UNO_QUERY );
+                css::awt::Rectangle aBoundRect;
+                if( xShapePropSet.is() && ( xShapePropSet->getPropertyValue( "BoundRect" ) >>= aBoundRect ))
                 {
-                    const Sequence< Reference< XPrimitive2D > > aPrimitiveSequence(
-                        xPrimitiveFactory->createPrimitivesFromXShape( xShapeCandidate, aParams ));
-                    const sal_Int32 nCount(aPrimitiveSequence.getLength());
-
-                    for(sal_Int32 nIndex = 0; nIndex < nCount; nIndex++)
-                    {
-                        const RealRectangle2D aRect(aPrimitiveSequence[nIndex]->getRange(aViewInformation));
-
-                        aShapeRange.expand(basegfx::B2DTuple(aRect.X1, aRect.Y1));
-                        aShapeRange.expand(basegfx::B2DTuple(aRect.X2, aRect.Y2));
-                    }
+                    aShapeRange.expand(basegfx::B2DTuple(aBoundRect.X, aBoundRect.Y));
+                    aShapeRange.expand(basegfx::B2DTuple(aBoundRect.X + aBoundRect.Width,
+                                                         aBoundRect.Y + aBoundRect.Height));
                 }
             }
         }
@@ -733,6 +773,72 @@ bool SVGFilter::implExportDocument()
         }
     }
 
+    if(mbWriterFilter)
+        implExportDocumentHeaderWriter(nDocX, nDocY, nDocWidth, nDocHeight);
+    else
+        implExportDocumentHeaderImpressDraw(nDocX, nDocY, nDocWidth, nDocHeight);
+
+
+    if( implLookForFirstVisiblePage() )  // OK! We found at least one visible page.
+    {
+        if( mbPresentation && !mbExportShapeSelection )
+        {
+            implGenerateMetaData();
+            implExportAnimations();
+        }
+        else
+        {
+            implGetPagePropSet( mSelectedPages[0] );
+        }
+
+        // Create the (Shape, GDIMetaFile) map
+        if( implCreateObjects() )
+        {
+            ::std::vector< ObjectRepresentation >    aObjects( mpObjects->size() );
+            sal_uInt32                               nPos = 0;
+
+            for (auto const& elem : *mpObjects)
+            {
+                aObjects[ nPos++ ] = elem.second;
+            }
+
+            mpSVGFontExport = new SVGFontExport( *mpSVGExport, aObjects );
+            mpSVGWriter = new SVGActionWriter( *mpSVGExport, *mpSVGFontExport );
+
+            if( mpSVGExport->IsEmbedFonts() )
+            {
+                mpSVGFontExport->EmbedFonts();
+            }
+            if( !mpSVGExport->IsUsePositionedCharacters() )
+            {
+                implExportTextShapeIndex();
+                implEmbedBulletGlyphs();
+                implExportTextEmbeddedBitmaps();
+            }
+
+            // #i124608# export a given object selection, so no MasterPage export at all
+            if (!mbExportShapeSelection)
+                implExportMasterPages( mMasterPageTargets, 0, mMasterPageTargets.size() - 1 );
+            implExportDrawPages( mSelectedPages, 0, nLastPage );
+
+            if( mbPresentation && !mbExportShapeSelection )
+            {
+                implGenerateScript();
+            }
+
+            delete mpSVGDoc;
+            mpSVGDoc = nullptr;
+            bRet = true;
+        }
+    }
+
+    return bRet;
+}
+
+void SVGFilter::implExportDocumentHeaderImpressDraw(sal_Int32 nDocX, sal_Int32 nDocY,
+                                                    sal_Int32 nDocWidth, sal_Int32 nDocHeight)
+{
+    const Reference< XExtendedDocumentHandler > xExtDocHandler( mpSVGExport->GetDocHandler(), UNO_QUERY );
     if( xExtDocHandler.is() && !mpSVGExport->IsUseTinyProfile() )
     {
         xExtDocHandler->unknown( SVG_DTD_STRING );
@@ -746,6 +852,7 @@ bool SVGFilter::implExportDocument()
     // The following if block means that the slide size is not adapted
     // to the size of the browser window, moreover the slide is top left aligned
     // instead of centered:
+    OUString aAttr;
     if( !mbPresentation )
     {
         aAttr = OUString::number( nDocWidth * 0.01 ) + "mm";
@@ -819,64 +926,40 @@ bool SVGFilter::implExportDocument()
             }
         }
     }
+}
 
-    if( implLookForFirstVisiblePage() )  // OK! We found at least one visible page.
-    {
-        if( mbPresentation && !mbExportShapeSelection )
-        {
-            implGenerateMetaData();
-            implExportAnimations();
-        }
-        else
-        {
-            implGetPagePropSet( mSelectedPages[0] );
-        }
-
-        // Create the (Shape, GDIMetaFile) map
-        if( implCreateObjects() )
-        {
-            ::std::vector< ObjectRepresentation >    aObjects( mpObjects->size() );
-            sal_uInt32                               nPos = 0;
-
-            for (auto const& elem : *mpObjects)
-            {
-                aObjects[ nPos++ ] = elem.second;
-            }
+void SVGFilter::implExportDocumentHeaderWriter(sal_Int32 nDocX, sal_Int32 nDocY,
+                                               sal_Int32 nDocWidth, sal_Int32 nDocHeight)
+{
+    OUString aAttr;
+    mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "version", "1.2" );
 
-            mpSVGFontExport = new SVGFontExport( *mpSVGExport, aObjects );
-            mpSVGWriter = new SVGActionWriter( *mpSVGExport, *mpSVGFontExport );
+    aAttr = OUString::number( nDocWidth * 0.01 ) + "mm";
+    mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "width", aAttr );
 
-            if( mpSVGExport->IsEmbedFonts() )
-            {
-                mpSVGFontExport->EmbedFonts();
-            }
-            if( !mpSVGExport->IsUsePositionedCharacters() )
-            {
-                implExportTextShapeIndex();
-                implEmbedBulletGlyphs();
-                implExportTextEmbeddedBitmaps();
-            }
+    aAttr = OUString::number( nDocHeight * 0.01 ) + "mm";
+    mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "height", aAttr );
 
-            // #i124608# export a given object selection, so no MasterPage export at all
-            if (!mbExportShapeSelection)
-                implExportMasterPages( mMasterPageTargets, 0, mMasterPageTargets.size() - 1 );
-            implExportDrawPages( mSelectedPages, 0, nLastPage );
+    aAttr = OUString::number(nDocX) + " " + OUString::number(nDocY) + " ";
+    aAttr += OUString::number(nDocWidth) + " " + OUString::number(nDocHeight);
 
-            if( mbPresentation && !mbExportShapeSelection )
-            {
-                implGenerateScript();
-            }
+    mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "viewBox", aAttr );
+    mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "preserveAspectRatio", "xMidYMid" );
+    mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "fill-rule", "evenodd" );
 
-            delete mpSVGDoc;
-            mpSVGDoc = nullptr;
-            bRet = true;
-        }
-    }
+    // standard line width is based on 1 pixel on a 90 DPI device (0.28222mmm)
+    mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "stroke-width", OUString::number( 28.222 ) );
+    mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "stroke-linejoin", "round" );
+    mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "xmlns", constSvgNamespace );
+    mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "xmlns:ooo", "http://xml.openoffice.org/svg/export" );
+    mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "xmlns:xlink", "http://www.w3.org/1999/xlink" );
+    mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "xmlns:office", "urn:oasis:names:tc:opendocument:xmlns:office:1.0" );
+    mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "xmlns:smil", "urn:oasis:names:tc:opendocument:xmlns:smil-compatible:1.0" );
+    mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "xml:space", "preserve" );
 
-    return bRet;
+    mpSVGDoc = new SvXMLElementExport( *mpSVGExport, XML_NAMESPACE_NONE, "svg", true, true );
 }
 
-
 /// Append aField to aFieldSet if it is not already present in the set and create the field id sFieldId
 template< typename TextFieldType >
 static OUString implGenerateFieldId( std::vector< TextField* > & aFieldSet,
diff --git a/filter/source/svg/svgfilter.cxx b/filter/source/svg/svgfilter.cxx
index ebcc522fbbca..539891c8b5ae 100644
--- a/filter/source/svg/svgfilter.cxx
+++ b/filter/source/svg/svgfilter.cxx
@@ -24,6 +24,7 @@
 #include <comphelper/lok.hxx>
 #include <comphelper/servicedecl.hxx>
 #include <uno/environment.h>
+#include <com/sun/star/text/XTextDocument.hpp>
 #include <com/sun/star/drawing/XDrawPage.hpp>
 #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
 #include <com/sun/star/drawing/XDrawView.hpp>
@@ -78,17 +79,19 @@ SVGFilter::SVGFilter( const Reference< XComponentContext >& rxCtx ) :
     mpSVGExport( nullptr ),
     mpSVGFontExport( nullptr ),
     mpSVGWriter( nullptr ),
-    mpDefaultSdrPage( nullptr ),
-    mbPresentation( false ),
     mbSinglePage( false ),
     mnVisiblePage( -1 ),
     mpObjects( nullptr ),
     mxSrcDoc(),
     mxDstDoc(),
-    mxDefaultPage(),
-    maFilterData(),
     maShapeSelection(),
     mbExportShapeSelection(false),
+    maFilterData(),
+    mxDefaultPage(),
+    mbWriterFilter(false),
+    mpDefaultSdrPage( nullptr ),
+    mpSdrModel( nullptr ),
+    mbPresentation( false ),
     maOldFieldHdl()
 {
 }
@@ -104,6 +107,34 @@ SVGFilter::~SVGFilter()
 
 sal_Bool SAL_CALL SVGFilter::filter( const Sequence< PropertyValue >& rDescriptor )
 {
+    mbWriterFilter = false;
+
+    if(mxDstDoc.is()) // Import works for Impress / draw only
+        return filterImpressDraw(rDescriptor);
+
+    if(mxSrcDoc.is())
+    {
+        for (sal_Int32 nInd = 0; nInd < rDescriptor.getLength(); nInd++)
+        {
+            if (rDescriptor[nInd].Name == "FilterName")
+            {
+                OUString sFilterName;
+                rDescriptor[nInd].Value >>= sFilterName;
+                if(sFilterName == "writer_svg_Export")
+                {
+                    mbWriterFilter = true;
+                    return filterWriter(rDescriptor);
+                }
+                break;
+            }
+        }
+        return filterImpressDraw(rDescriptor);
+    }
+    return false;
+}
+
+bool SVGFilter::filterImpressDraw( const Sequence< PropertyValue >& rDescriptor )
+{
     SolarMutexGuard aGuard;
     vcl::Window* pFocusWindow(Application::GetFocusWindow());
     bool bRet(false);
@@ -505,6 +536,49 @@ sal_Bool SAL_CALL SVGFilter::filter( const Sequence< PropertyValue >& rDescripto
     return bRet;
 }
 
+bool SVGFilter::filterWriter( const Sequence< PropertyValue >& rDescriptor )
+{
+    bool bSelectionOnly = false;
+
+    for (sal_Int32 nInd = 0; nInd < rDescriptor.getLength(); nInd++)
+    {
+        if (rDescriptor[nInd].Name == "SelectionOnly")
+        {
+            rDescriptor[nInd].Value >>= bSelectionOnly;
+            break;
+        }
+    }
+
+    if(!bSelectionOnly) // For Writer onéy the selection-only mode is supported
+        return false;
+
+    uno::Reference<frame::XDesktop2> xDesktop(frame::Desktop::create(mxContext));
+    uno::Reference<frame::XController > xController;
+    if (xDesktop->getCurrentFrame().is())
+    {
+        uno::Reference<frame::XFrame> xFrame(xDesktop->getCurrentFrame(), uno::UNO_QUERY_THROW);
+        xController.set(xFrame->getController(), uno::UNO_QUERY_THROW);
+    }
+
+    Reference< view::XSelectionSupplier > xSelection (xController, UNO_QUERY);
+    if (!xSelection.is())
+        return false;
+
+    xSelection->getSelection() >>= maShapeSelection;
+
+    if (!maShapeSelection)
+        return false;
+
+    // Select only one draw page
+    uno::Reference< drawing::XDrawPagesSupplier > xDrawPagesSupplier( mxSrcDoc, uno::UNO_QUERY );
+    uno::Reference<drawing::XDrawPages> xDrawPages = xDrawPagesSupplier->getDrawPages();
+    uno::Reference< drawing::XDrawPage > xDrawPage( xDrawPages->getByIndex(0), uno::UNO_QUERY );
+    mSelectedPages.resize( 1 );
+    mSelectedPages[0] = xDrawPage;
+
+    return implExport( rDescriptor );
+}
+
 void SAL_CALL SVGFilter::cancel( )
 {
 }
diff --git a/filter/source/svg/svgfilter.hxx b/filter/source/svg/svgfilter.hxx
index 1b5254e25469..5a70c3c63679 100644
--- a/filter/source/svg/svgfilter.hxx
+++ b/filter/source/svg/svgfilter.hxx
@@ -192,31 +192,40 @@ public:
 
 private:
 
+    /// Generally use members
+
     Reference< XComponentContext >      mxContext;
     SvXMLElementExport*                 mpSVGDoc;
     SVGExport*                          mpSVGExport;
     SVGFontExport*                      mpSVGFontExport;
     SVGActionWriter*                    mpSVGWriter;
-    SdrPage*                            mpDefaultSdrPage;
-    bool                            mbPresentation;
-    bool                            mbSinglePage;
+    bool                                mbSinglePage;
     sal_Int32                           mnVisiblePage;
-    PagePropertySet                     mVisiblePagePropSet;
-    OUString                     msClipPathId;
-    UCharSetMapMap                      mTextFieldCharSets;
-    Reference< XInterface >             mCreateOjectsCurrentMasterPage;
-    UOStringMap                         mTextShapeIdListMap;
-    MetaBitmapActionSet                 mEmbeddedBitmapActionSet;
-    ObjectMap                           mEmbeddedBitmapActionMap;
     ObjectMap*                          mpObjects;
     Reference< XComponent >             mxSrcDoc;
     Reference< XComponent >             mxDstDoc;
-    Reference< css::drawing::XDrawPage > mxDefaultPage;
-    Sequence< PropertyValue >           maFilterData;
     // #i124608# explicit ShapeSelection for export when export of the selection is wanted
     Reference< css::drawing::XShapes >  maShapeSelection;
     bool                                mbExportShapeSelection;
+    Sequence< PropertyValue >           maFilterData;
+    Reference< css::drawing::XDrawPage > mxDefaultPage;
     std::vector< Reference< css::drawing::XDrawPage > > mSelectedPages;
+
+    bool                                mbWriterFilter;
+
+
+    /// Impress / draw only members
+
+    SdrPage*                            mpDefaultSdrPage;
+    SdrModel*                           mpSdrModel;
+    bool                                mbPresentation;
+    PagePropertySet                     mVisiblePagePropSet;
+    OUString                            msClipPathId;
+    UCharSetMapMap                      mTextFieldCharSets;
+    Reference< XInterface >             mCreateOjectsCurrentMasterPage;
+    UOStringMap                         mTextShapeIdListMap;
+    MetaBitmapActionSet                 mEmbeddedBitmapActionSet;
+    ObjectMap                           mEmbeddedBitmapActionMap;
     std::vector< Reference< css::drawing::XDrawPage > > mMasterPageTargets;
 
     Link<EditFieldInfo*,void>           maOldFieldHdl;
@@ -224,6 +233,8 @@ private:
 
     /// @throws css::uno::RuntimeException
     bool                            implExport( const Sequence< PropertyValue >& rDescriptor );
+    bool                            implExportImpressDraw( const Reference< XOutputStream >& rxOStm );
+    bool                            implExportWriter( const Reference< XOutputStream >& rxOStm );
     static Reference< XWriter >     implCreateExportDocumentHandler( const Reference< XOutputStream >& rxOStm );
 
     void                            implGetPagePropSet( const Reference< css::drawing::XDrawPage > & rxPage );
@@ -235,6 +246,10 @@ private:
     void                            implGenerateScript();
 
     bool                            implExportDocument();
+    void                            implExportDocumentHeaderImpressDraw(sal_Int32 nDocX, sal_Int32 nDocY,
+                                                                        sal_Int32 nDocWidth, sal_Int32 nDocHeight);
+    void                            implExportDocumentHeaderWriter(sal_Int32 nDocX, sal_Int32 nDocY,
+                                                                   sal_Int32 nDocWidth, sal_Int32 nDocHeight);
     void                            implExportAnimations();
 
     bool                            implExportMasterPages( const std::vector< Reference< css::drawing::XDrawPage > >& rxPages,
@@ -266,6 +281,9 @@ private:
                                                                 const Reference< XPropertySetInfo > & rxPropSetInfo );
     DECL_LINK( CalcFieldHdl, EditFieldInfo*, void );
 
+    bool filterImpressDraw( const Sequence< PropertyValue >& rDescriptor );
+    bool filterWriter( const Sequence< PropertyValue >& rDescriptor );
+
 protected:
 
     // XFilter


More information about the Libreoffice-commits mailing list