LCOV - code coverage report
Current view: top level - filter/source/svg - svgfilter.hxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 0 19 0.0 %
Date: 2014-04-11 Functions: 0 18 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #ifndef INCLUDED_FILTER_SOURCE_SVG_SVGFILTER_HXX
      21             : #define INCLUDED_FILTER_SOURCE_SVG_SVGFILTER_HXX
      22             : 
      23             : #include <com/sun/star/uno/Type.hxx>
      24             : #include <com/sun/star/animations/XAnimationNodeSupplier.hpp>
      25             : #include <com/sun/star/drawing/XMasterPageTarget.hpp>
      26             : #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
      27             : #include <com/sun/star/container/XNamed.hpp>
      28             : 
      29             : #include <com/sun/star/drawing/XMasterPagesSupplier.hpp>
      30             : #include <com/sun/star/presentation/XPresentationSupplier.hpp>
      31             : #include <com/sun/star/document/XFilter.hpp>
      32             : #include <com/sun/star/document/XImporter.hpp>
      33             : #include <com/sun/star/document/XExporter.hpp>
      34             : #include <com/sun/star/document/XExtendedFilterDetection.hpp>
      35             : #include <com/sun/star/lang/XInitialization.hpp>
      36             : #include <com/sun/star/lang/XServiceInfo.hpp>
      37             : #include <com/sun/star/beans/XPropertySet.hpp>
      38             : #include <com/sun/star/lang/XComponent.hpp>
      39             : #include <cppuhelper/implbase4.hxx>
      40             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      41             : #include <com/sun/star/io/XActiveDataSource.hpp>
      42             : #include <com/sun/star/presentation/AnimationEffect.hpp>
      43             : #include <com/sun/star/presentation/AnimationSpeed.hpp>
      44             : #include <com/sun/star/presentation/ClickAction.hpp>
      45             : #include <com/sun/star/presentation/FadeEffect.hpp>
      46             : #include <com/sun/star/text/XText.hpp>
      47             : #include <com/sun/star/frame/XDesktop.hpp>
      48             : #include <com/sun/star/java/XJavaVM.hpp>
      49             : #include <com/sun/star/java/XJavaThreadRegister_11.hpp>
      50             : #include <com/sun/star/style/ParagraphAdjust.hpp>
      51             : #include <com/sun/star/drawing/FillStyle.hpp>
      52             : #include <com/sun/star/graphic/XGraphicProvider.hpp>
      53             : #include <com/sun/star/xml/sax/XWriter.hpp>
      54             : 
      55             : #include <boost/unordered_set.hpp>
      56             : #include <boost/unordered_map.hpp>
      57             : #include <osl/diagnose.h>
      58             : #include <sal/log.hxx>
      59             : #include <rtl/process.h>
      60             : #include <basegfx/polygon/b2dpolypolygon.hxx>
      61             : #include <basegfx/polygon/b2dpolygonclipper.hxx>
      62             : #include <basegfx/polygon/b2dpolypolygontools.hxx>
      63             : #include <comphelper/processfactory.hxx>
      64             : #include <unotools/tempfile.hxx>
      65             : #include <unotools/localfilehelper.hxx>
      66             : #include <unotools/ucbstreamhelper.hxx>
      67             : #include <unotools/streamwrap.hxx>
      68             : #include <vcl/cvtgrf.hxx>
      69             : #include <vcl/svapp.hxx>
      70             : #include <vcl/outdev.hxx>
      71             : #include <vcl/metaact.hxx>
      72             : #include <svtools/grfmgr.hxx>
      73             : #include <svx/unomodel.hxx>
      74             : #include <svx/unoapi.hxx>
      75             : #include <svx/svdxcgv.hxx>
      76             : #include <svx/svdobj.hxx>
      77             : #include <xmloff/xmlexp.hxx>
      78             : 
      79             : #include <cstdio>
      80             : 
      81             : 
      82             : using namespace ::com::sun::star::animations;
      83             : using namespace ::com::sun::star::beans;
      84             : using namespace ::com::sun::star::container;
      85             : using namespace ::com::sun::star::document;
      86             : using namespace ::com::sun::star::drawing;
      87             : using namespace ::com::sun::star::io;
      88             : using namespace ::com::sun::star::java;
      89             : using namespace ::com::sun::star::lang;
      90             : using namespace ::com::sun::star::presentation;
      91             : using namespace ::com::sun::star::style;
      92             : using namespace ::com::sun::star::text;
      93             : using namespace ::com::sun::star::uno;
      94             : using namespace ::com::sun::star::xml::sax;
      95             : 
      96             : using namespace ::std;
      97             : 
      98             : #define SVG_EXPORT_ALLPAGES ((sal_Int32)-1)
      99             : 
     100             : 
     101             : // Placeholder tag used into the ImplWriteActions method to filter text placeholder fields
     102           0 : static const OUString sPlaceholderTag( "<[:isPlaceholder:]>" );
     103             : 
     104             : class SVGExport : public SvXMLExport
     105             : {
     106             :     typedef ::std::list< ::basegfx::B2DPolyPolygon > B2DPolyPolygonList;
     107             : 
     108             :     sal_Bool    mbIsUseTinyProfile;
     109             :     sal_Bool    mbIsEmbedFonts;
     110             :     sal_Bool    mbIsUseOpacity;
     111             :     sal_Bool    mbIsUseNativeTextDecoration;
     112             :     sal_Bool    mbIsUsePositionedCharacters;
     113             : 
     114             : public:
     115             : 
     116             :     SVGExport( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > xContext,
     117             :                 const Reference< XDocumentHandler >& rxHandler,
     118             :                 const Sequence< PropertyValue >& rFilterData );
     119             : 
     120             :     virtual ~SVGExport();
     121             : 
     122           0 :     sal_Bool IsUseTinyProfile() const { return mbIsUseTinyProfile; };
     123           0 :     sal_Bool IsEmbedFonts() const { return mbIsEmbedFonts; };
     124           0 :     sal_Bool IsUseOpacity() const { return mbIsUseOpacity; };
     125           0 :     sal_Bool IsUseNativeTextDecoration() const { return mbIsUseNativeTextDecoration; };
     126           0 :     sal_Bool IsUsePositionedCharacters() const { return mbIsUsePositionedCharacters; };
     127             : 
     128             :     void writeMtf( const GDIMetaFile& rMtf );
     129             : 
     130             : protected:
     131             : 
     132           0 :     virtual void            _ExportStyles( bool /* bUsed */ ) SAL_OVERRIDE {}
     133           0 :     virtual void            _ExportAutoStyles() SAL_OVERRIDE {}
     134           0 :     virtual void            _ExportContent() SAL_OVERRIDE {}
     135           0 :     virtual void            _ExportMasterStyles() SAL_OVERRIDE {}
     136           0 :     virtual sal_uInt32        exportDoc( enum ::xmloff::token::XMLTokenEnum /* eClass */ ) SAL_OVERRIDE { return 0; }
     137             : 
     138             : private:
     139             : 
     140             :     SVGExport();
     141             : };
     142             : 
     143             : class ObjectRepresentation
     144             : {
     145             : private:
     146             : 
     147             :     Reference< XInterface >         mxObject;
     148             :     GDIMetaFile*                    mpMtf;
     149             : 
     150             : public:
     151             : 
     152             :                                       ObjectRepresentation();
     153             :                                       ObjectRepresentation( const Reference< XInterface >& rxIf,
     154             :                                                             const GDIMetaFile& rMtf );
     155             :                                       ObjectRepresentation( const ObjectRepresentation& rPresentation );
     156             :                                       ~ObjectRepresentation();
     157             : 
     158             :     ObjectRepresentation&             operator=( const ObjectRepresentation& rPresentation );
     159             :     sal_Bool                          operator==( const ObjectRepresentation& rPresentation ) const;
     160             : 
     161           0 :     const Reference< XInterface >&    GetObject() const { return mxObject; }
     162           0 :     sal_Bool                          HasRepresentation() const { return mpMtf != NULL; }
     163           0 :     const GDIMetaFile&                GetRepresentation() const { return *mpMtf; }
     164             : };
     165             : 
     166           0 : struct PagePropertySet
     167             : {
     168             :     sal_Bool               bIsBackgroundVisible;
     169             :     sal_Bool               bAreBackgroundObjectsVisible;
     170             :     sal_Bool               bIsPageNumberFieldVisible;
     171             :     sal_Bool               bIsDateTimeFieldVisible;
     172             :     sal_Bool               bIsFooterFieldVisible;
     173             :     sal_Bool               bIsHeaderFieldVisible;
     174             :     sal_Int32              nPageNumberingType;
     175             :     sal_Bool               bIsDateTimeFieldFixed;
     176             :     sal_Int16              nPageNumber;
     177             :     sal_Int32              nDateTimeFormat;
     178             :     OUString        sDateTimeText;
     179             :     OUString        sFooterText;
     180             :     OUString        sHeaderText;
     181             : };
     182             : 
     183             : struct HashReferenceXInterface
     184             : {
     185           0 :     size_t operator()( const Reference< XInterface >& rxIf ) const
     186             :     {
     187           0 :         return reinterpret_cast< size_t >( rxIf.get() );
     188             :     }
     189             : };
     190             : 
     191             : struct HashOUString
     192             : {
     193           0 :     size_t operator()( const OUString& oustr ) const { return static_cast< size_t >( oustr.hashCode() ); }
     194             : };
     195             : 
     196             : struct HashUChar
     197             : {
     198           0 :     size_t operator()( const sal_Unicode uchar ) const { return static_cast< size_t >( uchar ); }
     199             : };
     200             : 
     201             : struct HashBitmap
     202             : {
     203             :     size_t operator()( const ObjectRepresentation& rObjRep ) const;
     204             : };
     205             : 
     206             : struct EqualityBitmap
     207             : {
     208             :     bool operator()( const ObjectRepresentation& rObjRep1,
     209             :                      const ObjectRepresentation& rObjRep2 ) const;
     210             : };
     211             : 
     212             : class SVGFontExport;
     213             : class SVGActionWriter;
     214             : class EditFieldInfo;
     215             : 
     216             : class SVGFilter : public cppu::WeakImplHelper4 < XFilter,
     217             :                                                  XImporter,
     218             :                                                  XExporter,
     219             :                                                  XExtendedFilterDetection >
     220             : {
     221             : public:
     222             :     typedef ::boost::unordered_map< Reference< XInterface >, ObjectRepresentation, HashReferenceXInterface >    ObjectMap;
     223             :     typedef ::boost::unordered_set< Reference< XInterface >, HashReferenceXInterface >                          ObjectSet;
     224             :     typedef Sequence< Reference< XInterface > >                                                                 ObjectSequence;
     225             :     typedef Sequence< Reference< XDrawPage > >                                                                  XDrawPageSequence;
     226             : 
     227             :     typedef ::boost::unordered_set< sal_Unicode, HashUChar >                                                    UCharSet;
     228             :     typedef ::boost::unordered_map< OUString, UCharSet, HashOUString >                                   UCharSetMap;
     229             :     typedef ::boost::unordered_map< Reference< XInterface >, UCharSetMap, HashReferenceXInterface >             UCharSetMapMap;
     230             : 
     231             :     typedef ::boost::unordered_map< Reference< XInterface >, OUString, HashReferenceXInterface >         UOStringMap;
     232             : 
     233             :     typedef ::boost::unordered_set< ObjectRepresentation, HashBitmap, EqualityBitmap >                  MetaBitmapActionSet;
     234             : 
     235             : private:
     236             : 
     237             :     Reference< XComponentContext >      mxContext;
     238             :     SvXMLElementExport*                 mpSVGDoc;
     239             :     SVGExport*                          mpSVGExport;
     240             :     SVGFontExport*                      mpSVGFontExport;
     241             :     SVGActionWriter*                    mpSVGWriter;
     242             :     SdrPage*                            mpDefaultSdrPage;
     243             :     SdrModel*                           mpSdrModel;
     244             :     sal_Bool                            mbPresentation;
     245             :     sal_Bool                            mbSinglePage;
     246             :     sal_Int32                           mnVisiblePage;
     247             :     PagePropertySet                     mVisiblePagePropSet;
     248             :     OUString                     msClipPathId;
     249             :     UCharSetMapMap                      mTextFieldCharSets;
     250             :     Reference< XInterface >             mCreateOjectsCurrentMasterPage;
     251             :     UOStringMap                         mTextShapeIdListMap;
     252             : #ifndef DISABLE_EXPORT
     253             :     MetaBitmapActionSet                 mEmbeddedBitmapActionSet;
     254             :     ObjectMap                           mEmbeddedBitmapActionMap;
     255             : #endif
     256             :     ObjectMap*                          mpObjects;
     257             :     Reference< XComponent >             mxSrcDoc;
     258             :     Reference< XComponent >             mxDstDoc;
     259             :     Reference< XDrawPage >              mxDefaultPage;
     260             :     Sequence< PropertyValue >           maFilterData;
     261             :     // #i124608# explicit ShapeSelection for export when export of the selection is wanted
     262             :     Reference< XShapes >                maShapeSelection;
     263             :     XDrawPageSequence                   mSelectedPages;
     264             :     XDrawPageSequence                   mMasterPageTargets;
     265             : 
     266             :     Link                                maOldFieldHdl;
     267             : 
     268             :     sal_Bool                            implImport( const Sequence< PropertyValue >& rDescriptor ) throw (RuntimeException);
     269             : 
     270             :     sal_Bool                            implExport( const Sequence< PropertyValue >& rDescriptor ) throw (RuntimeException);
     271             :     Reference< XWriter >                implCreateExportDocumentHandler( const Reference< XOutputStream >& rxOStm );
     272             : 
     273             :     sal_Bool                            implGetPagePropSet( const Reference< XDrawPage > & rxPage );
     274             :     sal_Bool                            implGenerateMetaData();
     275             :     void                                implExportTextShapeIndex();
     276             :     void                                implEmbedBulletGlyphs();
     277             :     void                                implEmbedBulletGlyph( sal_Unicode cBullet, const OUString & sPathData );
     278             :     sal_Bool                            implExportTextEmbeddedBitmaps();
     279             :     sal_Bool                            implGenerateScript();
     280             : 
     281             :     sal_Bool                            implExportDocument();
     282             :     sal_Bool                            implExportAnimations();
     283             : 
     284             :     sal_Bool                            implExportMasterPages( const XDrawPageSequence& rxPages,
     285             :                                                                sal_Int32 nFirstPage, sal_Int32 nLastPage );
     286             :     sal_Bool                            implExportDrawPages( const XDrawPageSequence& rxPages,
     287             :                                                              sal_Int32 nFirstPage, sal_Int32 nLastPage );
     288             :     sal_Bool                            implExportPage( const OUString & sPageId,
     289             :                                                         const Reference< XDrawPage > & rxPage,
     290             :                                                         const Reference< XShapes > & xShapes,
     291             :                                                         sal_Bool bMaster );
     292             : 
     293             :     sal_Bool                            implExportShapes( const Reference< XShapes >& rxShapes,
     294             :                                                           sal_Bool bMaster );
     295             :     sal_Bool                            implExportShape( const Reference< XShape >& rxShape,
     296             :                                                          sal_Bool bMaster );
     297             : 
     298             :     sal_Bool                            implCreateObjects();
     299             :     sal_Bool                            implCreateObjectsFromShapes( const Reference< XDrawPage > & rxPage, const Reference< XShapes >& rxShapes );
     300             :     sal_Bool                            implCreateObjectsFromShape( const Reference< XDrawPage > & rxPage, const Reference< XShape >& rxShape );
     301             :     sal_Bool                            implCreateObjectsFromBackground( const Reference< XDrawPage >& rxMasterPage );
     302             : 
     303             :     OUString                     implGetClassFromShape( const Reference< XShape >& rxShape );
     304             :     void                                implRegisterInterface( const Reference< XInterface >& rxIf );
     305             :     const OUString &             implGetValidIDFromInterface( const Reference< XInterface >& rxIf );
     306             :     OUString                     implGetInterfaceName( const Reference< XInterface >& rxIf );
     307             :     sal_Bool                            implLookForFirstVisiblePage();
     308             :     Any                                 implSafeGetPagePropSet( const OUString & sPropertyName,
     309             :                                                                 const Reference< XPropertySet > & rxPropSet,
     310             :                                                                 const Reference< XPropertySetInfo > & rxPropSetInfo );
     311             :                                         DECL_LINK( CalcFieldHdl, EditFieldInfo* );
     312             : 
     313             :     bool isStreamGZip(css::uno::Reference<css::io::XInputStream> xInput);
     314             :     bool isStreamSvg(css::uno::Reference<css::io::XInputStream> xInput);
     315             : 
     316             : protected:
     317             : 
     318             :     // XFilter
     319             :     virtual sal_Bool SAL_CALL filter( const Sequence< PropertyValue >& rDescriptor ) throw(RuntimeException, std::exception) SAL_OVERRIDE;
     320             :     virtual void SAL_CALL cancel( ) throw (RuntimeException, std::exception) SAL_OVERRIDE;
     321             : 
     322             :     // XImporter
     323             :     virtual void SAL_CALL setTargetDocument( const Reference< XComponent >& xDoc ) throw(IllegalArgumentException, RuntimeException, std::exception) SAL_OVERRIDE;
     324             : 
     325             :     // XExporter
     326             :     virtual void SAL_CALL setSourceDocument( const Reference< XComponent >& xDoc ) throw(IllegalArgumentException, RuntimeException, std::exception) SAL_OVERRIDE;
     327             : 
     328             :     // XExtendedFilterDetection
     329             :     virtual OUString SAL_CALL detect( Sequence< PropertyValue >& io_rDescriptor ) throw (RuntimeException, std::exception) SAL_OVERRIDE;
     330             : 
     331             : public:
     332             : 
     333             :     explicit SVGFilter( const Reference< XComponentContext >& rxCtx );
     334             :     virtual    ~SVGFilter();
     335             : };
     336             : 
     337             : #endif // INCLUDED_FILTER_SOURCE_SVG_SVGFILTER_HXX
     338             : 
     339             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10