[Libreoffice-commits] core.git: filter/source vcl/source

SJacobi Sven-Jacobi at gmx.de
Sat Jun 29 13:03:07 PDT 2013


 filter/source/svg/impsvgdialog.hxx  |    3 
 filter/source/svg/svgexport.cxx     |  124 ++++++++----------------------------
 filter/source/svg/svgfilter.cxx     |    2 
 filter/source/svg/svgfilter.hxx     |   18 +++--
 filter/source/svg/svgwriter.cxx     |    8 +-
 filter/source/svg/svgwriter.hxx     |    8 +-
 vcl/source/filter/graphicfilter.cxx |    8 +-
 7 files changed, 53 insertions(+), 118 deletions(-)

New commits:
commit 9911631895f2e42b5c90a108e4940b0091d05ee1
Author: SJacobi <Sven-Jacobi at gmx.de>
Date:   Sat Jun 29 15:52:20 2013 +0200

    SVGWriter can now be initialized properly. Removing some strange code peaces.
    
    Change-Id: Ia3011d002c4028008b207505352384f6bb72ce10
    Reviewed-on: https://gerrit.libreoffice.org/4619
    Reviewed-by: Michael Stahl <mstahl at redhat.com>
    Tested-by: Michael Stahl <mstahl at redhat.com>

diff --git a/filter/source/svg/impsvgdialog.hxx b/filter/source/svg/impsvgdialog.hxx
index 563a874..bc005f2 100644
--- a/filter/source/svg/impsvgdialog.hxx
+++ b/filter/source/svg/impsvgdialog.hxx
@@ -34,9 +34,8 @@
 #define SVG_PROP_TINYPROFILE                "TinyMode"
 #define SVG_PROP_EMBEDFONTS                 "EmbedFonts"
 #define SVG_PROP_NATIVEDECORATION           "UseNativeTextDecoration"
-#define SVG_PROP_GLYPHPLACEMENT             "GlyphPlacement"
 #define SVG_PROP_OPACITY                    "Opacity"
-#define SVG_PROP_GRADIENT                   "Gradient"
+#define SVG_PROP_POSITIONED_CHARACTERS      "UsePositionedCharacters"
 
 // ----------------
 // - ImpSVGDialog -
diff --git a/filter/source/svg/svgexport.cxx b/filter/source/svg/svgexport.cxx
index d923b49..200d8fd 100644
--- a/filter/source/svg/svgexport.cxx
+++ b/filter/source/svg/svgexport.cxx
@@ -38,6 +38,7 @@
 #include <editeng/flditem.hxx>
 #include <editeng/numitem.hxx>
 #include <comphelper/processfactory.hxx>
+#include <comphelper/sequenceashashmap.hxx>
 #include <i18nlangtag/lang.h>
 #include <svl/zforlist.hxx>
 #include <xmloff/unointerfacetouniqueidentifiermapper.hxx>
@@ -317,76 +318,48 @@ SVGExport::SVGExport(
                    xContext,
                    xmloff::token::XML_TOKEN_INVALID,
                    EXPORT_META|EXPORT_PRETTY )
-        , mrFilterData( rFilterData )
 {
     SetDocHandler( rxHandler );
     GetDocHandler()->startDocument();
-}
-
-// -----------------------------------------------------------------------------
-
-SVGExport::~SVGExport()
-{
-    GetDocHandler()->endDocument();
-}
-
-// -----------------------------------------------------------------------------
-
-sal_Bool SVGExport::IsUseTinyProfile() const
-{
-    sal_Bool bRet = sal_False;
-
-    if( IsUsePositionedCharacters() && mrFilterData.getLength() > 0 )
-        mrFilterData[ 0 ].Value >>= bRet;
-
-    return bRet;
-}
-
-// -----------------------------------------------------------------------------
-
-sal_Bool SVGExport::IsEmbedFonts() const
-{
-    sal_Bool bRet = sal_False;
-
-    if( IsUsePositionedCharacters() && mrFilterData.getLength() > 1 )
-        mrFilterData[ 1 ].Value >>= bRet;
-
-    return bRet;
-}
-
-// -----------------------------------------------------------------------------
 
-sal_Bool SVGExport::IsUseNativeTextDecoration() const
-{
-    sal_Bool bRet = !IsUseTinyProfile();
+    // initializing filter settings from filter data
+    comphelper::SequenceAsHashMap aFilterDataHashMap = rFilterData;
 
-    if( bRet && ( mrFilterData.getLength() > 2 ) )
-        mrFilterData[ 2 ].Value >>= bRet;
+    // TinyProfile
+    mbIsUseTinyProfile = aFilterDataHashMap.getUnpackedValueOrDefault(SVG_PROP_TINYPROFILE, sal_True);
 
-    return bRet;
-}
+    // Font Embedding
+    comphelper::SequenceAsHashMap::const_iterator iter = aFilterDataHashMap.find(SVG_PROP_EMBEDFONTS);
+    if(iter==aFilterDataHashMap.end())
+    {
+        const char* pSVGDisableFontEmbedding = getenv( "SVG_DISABLE_FONT_EMBEDDING" );
+        OUString aEmbedFontEnv("${SVG_DISABLE_FONT_EMBEDDING}");
+        rtl::Bootstrap::expandMacros(aEmbedFontEnv);
+        mbIsEmbedFonts=pSVGDisableFontEmbedding ? sal_False : (
+            aEmbedFontEnv.getLength() ? sal_False : sal_True);
+    }
+    else
+    {
+        if(!(iter->second >>= mbIsEmbedFonts))
+            mbIsEmbedFonts = sal_False;
+    }
 
-// -----------------------------------------------------------------------------
+    // Native Decoration
+    mbIsUseNativeTextDecoration = mbIsUseTinyProfile ? sal_False : aFilterDataHashMap.getUnpackedValueOrDefault(SVG_PROP_NATIVEDECORATION, sal_False);
 
-sal_Bool SVGExport::IsUseOpacity() const
-{
-    sal_Bool bRet = !IsUseTinyProfile();
+    // Tiny Opacity
+    mbIsUseOpacity = mbIsUseTinyProfile ? sal_False : aFilterDataHashMap.getUnpackedValueOrDefault(SVG_PROP_OPACITY, sal_True);
 
-    if( !bRet && ( mrFilterData.getLength() > 4 ) )
-        mrFilterData[ 4 ].Value >>= bRet;
+    // Positioned Characters    (Seems to be experimental, as it was always initialized with false)
+    mbIsUsePositionedCharacters = aFilterDataHashMap.getUnpackedValueOrDefault(SVG_PROP_POSITIONED_CHARACTERS, sal_False);
 
-    return bRet;
 }
 
 // -----------------------------------------------------------------------------
 
-sal_Bool SVGExport::IsUsePositionedCharacters() const
+SVGExport::~SVGExport()
 {
-    sal_Bool bRet = sal_False;
-    if( mrFilterData.getLength() > 6 )
-        mrFilterData[ 6 ].Value >>= bRet;
-
-    return bRet;
+    GetDocHandler()->endDocument();
 }
 
 
@@ -576,47 +549,6 @@ sal_Bool SVGFilter::implExport( const Sequence< PropertyValue >& rDescriptor )
         }
     }
 
-    // if no filter data is given use stored/prepared ones
-    if( !maFilterData.getLength() )
-    {
-        maFilterData.realloc( 6 );
-
-        maFilterData[ 0 ].Name = SVG_PROP_TINYPROFILE;
-        maFilterData[ 0 ].Value <<= (sal_Bool) sal_True;
-
-        // font embedding
-        const char* pSVGDisableFontEmbedding = getenv( "SVG_DISABLE_FONT_EMBEDDING" );
-        OUString aEmbedFontEnv("${SVG_DISABLE_FONT_EMBEDDING}");
-        rtl::Bootstrap::expandMacros(aEmbedFontEnv);
-        const bool bEmbedFonts=pSVGDisableFontEmbedding ? false : (
-            aEmbedFontEnv.getLength() ? false : true);
-
-        maFilterData[ 1 ].Name = SVG_PROP_EMBEDFONTS;
-        maFilterData[ 1 ].Value <<= (sal_Bool) (bEmbedFonts);
-
-        // Native decoration
-        maFilterData[ 2 ].Name = SVG_PROP_NATIVEDECORATION;
-        maFilterData[ 2 ].Value <<= (sal_Bool) sal_False;
-
-        // glyph placement
-        const char* pSVGGlyphPlacement = getenv( "SVG_GLYPH_PLACEMENT" );
-
-        maFilterData[ 3 ].Name = SVG_PROP_GLYPHPLACEMENT;
-
-        if( pSVGGlyphPlacement )
-            maFilterData[ 3 ].Value <<= OUString::createFromAscii( pSVGGlyphPlacement );
-        else
-            maFilterData[ 3 ].Value <<= OUString("xlist");
-
-        // Tiny Opacity
-        maFilterData[ 4 ].Name = SVG_PROP_OPACITY;
-        maFilterData[ 4 ].Value <<= (sal_Bool) sal_True;
-
-        // Tiny Gradient
-        maFilterData[ 5 ].Name = SVG_PROP_GRADIENT;
-        maFilterData[ 5 ].Value <<= (sal_Bool) sal_False;
-    }
-
     if( xOStm.is() )
     {
         if( mSelectedPages.hasElements() && mMasterPageTargets.hasElements() )
diff --git a/filter/source/svg/svgfilter.cxx b/filter/source/svg/svgfilter.cxx
index 7556840..54a257d 100644
--- a/filter/source/svg/svgfilter.cxx
+++ b/filter/source/svg/svgfilter.cxx
@@ -319,7 +319,7 @@ namespace sdecl = comphelper::service_decl;
      "com.sun.star.document.ExportFilter;"
      "com.sun.star.document.ExtendedTypeDetection" );
 
- sdecl::class_<SVGWriter> serviceWriterImpl;
+ sdecl::class_<SVGWriter, sdecl::with_args<true>> serviceWriterImpl;
  const sdecl::ServiceDecl svgWriter(
      serviceWriterImpl,
      SVG_WRITER_IMPL_NAME,
diff --git a/filter/source/svg/svgfilter.hxx b/filter/source/svg/svgfilter.hxx
index 2873bc5..814a1d3 100644
--- a/filter/source/svg/svgfilter.hxx
+++ b/filter/source/svg/svgfilter.hxx
@@ -105,6 +105,12 @@ class SVGExport : public SvXMLExport
 {
     typedef ::std::list< ::basegfx::B2DPolyPolygon > B2DPolyPolygonList;
 
+    sal_Bool    mbIsUseTinyProfile;
+    sal_Bool    mbIsEmbedFonts;
+    sal_Bool    mbIsUseOpacity;
+    sal_Bool    mbIsUseNativeTextDecoration;
+    sal_Bool    mbIsUsePositionedCharacters;
+
 public:
 
     SVGExport( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > xContext,
@@ -113,11 +119,11 @@ public:
 
     virtual ~SVGExport();
 
-    sal_Bool IsUseTinyProfile() const;
-    sal_Bool IsEmbedFonts() const;
-    sal_Bool IsUsePositionedCharacters() const;
-    sal_Bool IsUseNativeTextDecoration() const;
-    sal_Bool IsUseOpacity() const;
+    sal_Bool IsUseTinyProfile() const { return mbIsUseTinyProfile; };
+    sal_Bool IsEmbedFonts() const { return mbIsEmbedFonts; };
+    sal_Bool IsUseOpacity() const { return mbIsUseOpacity; };
+    sal_Bool IsUseNativeTextDecoration() const { return mbIsUseNativeTextDecoration; };
+    sal_Bool IsUsePositionedCharacters() const { return mbIsUsePositionedCharacters; };
 
     void writeMtf( const GDIMetaFile& rMtf );
 
@@ -131,8 +137,6 @@ protected:
 
 private:
 
-    const Sequence< PropertyValue >&    mrFilterData;
-
     SVGExport();
 };
 
diff --git a/filter/source/svg/svgwriter.cxx b/filter/source/svg/svgwriter.cxx
index 99c9e25..4a31742 100644
--- a/filter/source/svg/svgwriter.cxx
+++ b/filter/source/svg/svgwriter.cxx
@@ -3578,9 +3578,11 @@ void SVGActionWriter::WriteMetaFile( const Point& rPos100thmm,
 // - SVGWriter -
 // -------------
 
-SVGWriter::SVGWriter( const Reference< XComponentContext >& rxCtx )
+SVGWriter::SVGWriter( const Sequence<Any>& args, const Reference< XComponentContext >& rxCtx )
     : mxContext(rxCtx)
 {
+    if(args.getLength()==1)
+        args[0]>>=maFilterData;
 }
 
 // -----------------------------------------------------------------------------
@@ -3600,9 +3602,7 @@ void SAL_CALL SVGWriter::write( const Reference<XDocumentHandler>& rxDocHandler,
     aMemStm >> aMtf;
 
     const Reference< XDocumentHandler > xDocumentHandler( rxDocHandler );
-    const Sequence< PropertyValue > aFilterData;
-
-    SVGExport* pWriter = new SVGExport( mxContext, xDocumentHandler, aFilterData );
+    SVGExport* pWriter = new SVGExport( mxContext, xDocumentHandler, maFilterData );
     pWriter->writeMtf( aMtf );
     delete pWriter;
 }
diff --git a/filter/source/svg/svgwriter.hxx b/filter/source/svg/svgwriter.hxx
index 31ef423..1a9e6ae 100644
--- a/filter/source/svg/svgwriter.hxx
+++ b/filter/source/svg/svgwriter.hxx
@@ -60,7 +60,6 @@
 #include <com/sun/star/style/NumberingType.hpp>
 #include <com/sun/star/svg/XSVGWriter.hpp>
 
-
 // -----------------------------------------------------------------------------
 
 using namespace ::com::sun::star::uno;
@@ -407,12 +406,13 @@ public:
 class SVGWriter : public cppu::WeakImplHelper1< XSVGWriter >
 {
 private:
-    Reference< XComponentContext >      mxContext;
-
+    Reference< XComponentContext >                      mxContext;
+    Sequence< com::sun::star::beans::PropertyValue >    maFilterData;
     SVGWriter();
 
 public:
-    explicit SVGWriter( const Reference< XComponentContext >& rxCtx );
+    explicit SVGWriter( const Sequence<Any>& args,
+                        const Reference< XComponentContext >& rxCtx );
     virtual ~SVGWriter();
 
     // XSVGWriter
diff --git a/vcl/source/filter/graphicfilter.cxx b/vcl/source/filter/graphicfilter.cxx
index d2198d3..eb38d56 100644
--- a/vcl/source/filter/graphicfilter.cxx
+++ b/vcl/source/filter/graphicfilter.cxx
@@ -2012,11 +2012,11 @@ sal_uInt16 GraphicFilter::ExportGraphic( const Graphic& rGraphic, const String&
 
                         css::uno::Reference< css::xml::sax::XDocumentHandler > xSaxWriter(
                             xml::sax::Writer::create( xContext ), uno::UNO_QUERY_THROW);
-
+                        css::uno::Sequence< css::uno::Any > aArguments( 1 );
+                        aArguments[ 0 ] <<= aConfigItem.GetFilterData();
                         css::uno::Reference< css::svg::XSVGWriter > xSVGWriter(
-                            xContext->getServiceManager()->createInstanceWithContext( "com.sun.star.svg.SVGWriter", xContext ),
-                            css::uno::UNO_QUERY );
-
+                            xContext->getServiceManager()->createInstanceWithArgumentsAndContext( "com.sun.star.svg.SVGWriter", aArguments, xContext),
+                                css::uno::UNO_QUERY );
                         if( xSaxWriter.is() && xSVGWriter.is() )
                         {
                             css::uno::Reference< css::io::XActiveDataSource > xActiveDataSource(


More information about the Libreoffice-commits mailing list