/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * 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 . */ #ifndef SVGFILTER_HXX #define SVGFILTER_HXX #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace ::com::sun::star::animations; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::container; using namespace ::com::sun::star::document; using namespace ::com::sun::star::drawing; using namespace ::com::sun::star::io; using namespace ::com::sun::star::java; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::presentation; using namespace ::com::sun::star::style; using namespace ::com::sun::star::text; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::xml::sax; using namespace ::std; #define SVG_EXPORT_ALLPAGES ((sal_Int32)-1) // Placeholder tag used into the ImplWriteActions method to filter text placeholder fields static const OUString sPlaceholderTag( "<[:isPlaceholder:]>" ); 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, const Reference< XDocumentHandler >& rxHandler, const Sequence< PropertyValue >& rFilterData ); virtual ~SVGExport(); 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 ); protected: virtual void _ExportStyles( sal_Bool /* bUsed */ ) {} virtual void _ExportAutoStyles() {} virtual void _ExportContent() {} virtual void _ExportMasterStyles() {} virtual sal_uInt32 exportDoc( enum ::xmloff::token::XMLTokenEnum /* eClass */ ) { return 0; } private: SVGExport(); }; class ObjectRepresentation { private: Reference< XInterface > mxObject; GDIMetaFile* mpMtf; public: ObjectRepresentation(); ObjectRepresentation( const Reference< XInterface >& rxIf, const GDIMetaFile& rMtf ); ObjectRepresentation( const ObjectRepresentation& rPresentation ); ~ObjectRepresentation(); ObjectRepresentation& operator=( const ObjectRepresentation& rPresentation ); sal_Bool operator==( const ObjectRepresentation& rPresentation ) const; const Reference< XInterface >& GetObject() const { return mxObject; } sal_Bool HasRepresentation() const { return mpMtf != NULL; } const GDIMetaFile& GetRepresentation() const { return *mpMtf; } }; struct PagePropertySet { sal_Bool bIsBackgroundVisible; sal_Bool bAreBackgroundObjectsVisible; sal_Bool bIsPageNumberFieldVisible; sal_Bool bIsDateTimeFieldVisible; sal_Bool bIsFooterFieldVisible; sal_Bool bIsHeaderFieldVisible; sal_Int32 nPageNumberingType; sal_Bool bIsDateTimeFieldFixed; sal_Int16 nPageNumber; sal_Int32 nDateTimeFormat; OUString sDateTimeText; OUString sFooterText; OUString sHeaderText; }; struct HashReferenceXInterface { size_t operator()( const Reference< XInterface >& rxIf ) const { return reinterpret_cast< size_t >( rxIf.get() ); } }; struct HashOUString { size_t operator()( const OUString& oustr ) const { return static_cast< size_t >( oustr.hashCode() ); } }; struct HashUChar { size_t operator()( const sal_Unicode uchar ) const { return static_cast< size_t >( uchar ); } }; struct HashBitmap { size_t operator()( const ObjectRepresentation& rObjRep ) const; }; struct EqualityBitmap { bool operator()( const ObjectRepresentation& rObjRep1, const ObjectRepresentation& rObjRep2 ) const; }; class SVGFontExport; class SVGActionWriter; class EditFieldInfo; class SVGFilter : public cppu::WeakImplHelper4 < XFilter, XImporter, XExporter, XExtendedFilterDetection > { public: typedef ::boost::unordered_map< Reference< XInterface >, ObjectRepresentation, HashReferenceXInterface > ObjectMap; typedef ::boost::unordered_set< Reference< XInterface >, HashReferenceXInterface > ObjectSet; typedef Sequence< Reference< XInterface > > ObjectSequence; typedef Sequence< Reference< XDrawPage > > XDrawPageSequence; typedef ::boost::unordered_set< sal_Unicode, HashUChar > UCharSet; typedef ::boost::unordered_map< OUString, UCharSet, HashOUString > UCharSetMap; typedef ::boost::unordered_map< Reference< XInterface >, UCharSetMap, HashReferenceXInterface > UCharSetMapMap; typedef ::boost::unordered_map< Reference< XInterface >, OUString, HashReferenceXInterface > UOStringMap; typedef ::boost::unordered_set< ObjectRepresentation, HashBitmap, EqualityBitmap > MetaBitmapActionSet; private: Reference< XComponentContext > mxContext; SvXMLElementExport* mpSVGDoc; SVGExport* mpSVGExport; SVGFontExport* mpSVGFontExport; SVGActionWriter* mpSVGWriter; SdrPage* mpDefaultSdrPage; SdrModel* mpSdrModel; sal_Bool mbPresentation; sal_Bool mbExportAll; sal_Bool mbSinglePage; sal_Int32 mnVisiblePage; PagePropertySet mVisiblePagePropSet; OUString msClipPathId; UCharSetMapMap mTextFieldCharSets; Reference< XInterface > mCreateOjectsCurrentMasterPage; UOStringMap mTextShapeIdListMap; #ifndef DISABLE_EXPORT MetaBitmapActionSet mEmbeddedBitmapActionSet; ObjectMap mEmbeddedBitmapActionMap; #endif ObjectMap* mpObjects; Reference< XComponent > mxSrcDoc; Reference< XComponent > mxDstDoc; Reference< XDrawPage > mxDefaultPage; Sequence< PropertyValue > maFilterData; XDrawPageSequence mSelectedPages; XDrawPageSequence mMasterPageTargets; Link maOldFieldHdl; sal_Bool implImport( const Sequence< PropertyValue >& rDescriptor ) throw (RuntimeException); sal_Bool implExport( const Sequence< PropertyValue >& rDescriptor ) throw (RuntimeException); Reference< XWriter > implCreateExportDocumentHandler( const Reference< XOutputStream >& rxOStm ); sal_Bool implGetPagePropSet( const Reference< XDrawPage > & rxPage ); sal_Bool implGenerateMetaData(); void implExportTextShapeIndex(); void implEmbedBulletGlyphs(); void implEmbedBulletGlyph( sal_Unicode cBullet, const OUString & sPathData ); sal_Bool implExportTextEmbeddedBitmaps(); sal_Bool implGenerateScript(); sal_Bool implExportDocument(); sal_Bool implExportAnimations(); sal_Bool implExportMasterPages( const XDrawPageSequence& rxPages, sal_Int32 nFirstPage, sal_Int32 nLastPage ); sal_Bool implExportDrawPages( const XDrawPageSequence& rxPages, sal_Int32 nFirstPage, sal_Int32 nLastPage ); sal_Bool implExportPage( const OUString & sPageId, const Reference< XDrawPage > & rxPage, const Reference< XShapes > & xShapes, sal_Bool bMaster ); sal_Bool implExportShapes( const Reference< XShapes >& rxShapes ); sal_Bool implExportShape( const Reference< XShape >& rxShape ); sal_Bool implCreateObjects(); sal_Bool implCreateObjectsFromShapes( const Reference< XDrawPage > & rxPage, const Reference< XShapes >& rxShapes ); sal_Bool implCreateObjectsFromShape( const Reference< XDrawPage > & rxPage, const Reference< XShape >& rxShape ); sal_Bool implCreateObjectsFromBackground( const Reference< XDrawPage >& rxMasterPage ); OUString implGetClassFromShape( const Reference< XShape >& rxShape ); void implRegisterInterface( const Reference< XInterface >& rxIf ); const OUString & implGetValidIDFromInterface( const Reference< XInterface >& rxIf ); OUString implGetInterfaceName( const Reference< XInterface >& rxIf ); sal_Bool implLookForFirstVisiblePage(); Any implSafeGetPagePropSet( const OUString & sPropertyName, const Reference< XPropertySet > & rxPropSet, const Reference< XPropertySetInfo > & rxPropSetInfo ); DECL_LINK( CalcFieldHdl, EditFieldInfo* ); protected: // XFilter virtual sal_Bool SAL_CALL filter( const Sequence< PropertyValue >& rDescriptor ) throw(RuntimeException); virtual void SAL_CALL cancel( ) throw (RuntimeException); // XImporter virtual void SAL_CALL setTargetDocument( const Reference< XComponent >& xDoc ) throw(IllegalArgumentException, RuntimeException); // XExporter virtual void SAL_CALL setSourceDocument( const Reference< XComponent >& xDoc ) throw(IllegalArgumentException, RuntimeException); // XExtendedFilterDetection virtual OUString SAL_CALL detect( Sequence< PropertyValue >& io_rDescriptor ) throw (RuntimeException); public: explicit SVGFilter( const Reference< XComponentContext >& rxCtx ); virtual ~SVGFilter(); }; #endif // SVGFILTER_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */