diff options
Diffstat (limited to 'filter/inc/filter/msfilter/escherex.hxx')
-rw-r--r-- | filter/inc/filter/msfilter/escherex.hxx | 180 |
1 files changed, 141 insertions, 39 deletions
diff --git a/filter/inc/filter/msfilter/escherex.hxx b/filter/inc/filter/msfilter/escherex.hxx index 4f1381749a55..b98f5dc85147 100644 --- a/filter/inc/filter/msfilter/escherex.hxx +++ b/filter/inc/filter/msfilter/escherex.hxx @@ -28,7 +28,9 @@ #ifndef _SVX_ESCHEREX_HXX #define _SVX_ESCHEREX_HXX +#include <memory> #include <vector> +#include <boost/shared_ptr.hpp> #include <tools/solar.h> #include <tools/gen.hxx> #include <tools/list.hxx> @@ -945,13 +947,13 @@ enum ESCHER_LineCap #define ESCHER_Persist_PrivateEntry 0x80000000 #define ESCHER_Persist_Dgg 0x00010000 -#define ESCHER_Persist_Dgg_FIDCL 0x00010001 #define ESCHER_Persist_Dg 0x00020000 -#define ESCHER_Persist_BlibStoreContainer 0x00030000 #define ESCHER_Persist_CurrentPosition 0x00040000 #define ESCHER_Persist_Grouping_Snap 0x00050000 #define ESCHER_Persist_Grouping_Logic 0x00060000 +const sal_uInt32 DFF_DGG_CLUSTER_SIZE = 0x00000400; /// Shape IDs per cluster in DGG atom. + // --------------------------------------------------------------------------------------------- namespace com { namespace sun { namespace star { @@ -961,6 +963,7 @@ namespace com { namespace sun { namespace star { namespace drawing { struct EnhancedCustomShapeAdjustmentValue; class XShape; + class XShapes; } }}} @@ -1030,13 +1033,11 @@ struct EscherPersistEntry // --------------------------------------------------------------------------------------------- -class SvMemoryStream; class EscherBlibEntry { friend class EscherGraphicProvider; friend class EscherEx; - friend class _EscherEx; protected: @@ -1344,52 +1345,137 @@ public: }; +// ============================================================================ + +/** Instance for global DFF data, shared through various instances of EscherEx. */ +class MSFILTER_DLLPUBLIC EscherExGlobal : public EscherGraphicProvider +{ +public: + explicit EscherExGlobal( sal_uInt32 nGraphicProvFlags = _E_GRAPH_PROV_DO_NOT_ROTATE_METAFILES ); + virtual ~EscherExGlobal(); + + /** Returns a new drawing ID for a new drawing container (DGCONTAINER). */ + sal_uInt32 GenerateDrawingId(); + /** Creates and returns a new shape identifier, updates the internal shape + counters and registers the identifier in the DGG cluster table. + @param nDrawingId Drawing identifier has to be passed to be able to + generate shape identifiers for multiple drawings simultaniously. */ + sal_uInt32 GenerateShapeId( sal_uInt32 nDrawingId, bool bIsInSpgr ); + /** Returns the number of shapes in the current drawing, based on number of + calls to the GenerateShapeId() function. */ + sal_uInt32 GetDrawingShapeCount( sal_uInt32 nDrawingId ) const; + /** Returns the last shape identifier generated by the GenerateShapeId() + function. */ + sal_uInt32 GetLastShapeId( sal_uInt32 nDrawingId ) const; + + /** Sets the flag indicating that the DGGCONTAINER exists. */ + inline void SetDggContainer() { mbHasDggCont = true; } + /** Sets the flag indicating that the DGGCONTAINER exists. */ + inline bool HasDggContainer() const { return mbHasDggCont; } + /** Returns the total size of the DGG atom (including header). */ + sal_uInt32 GetDggAtomSize() const; + /** Writes the complete DGG atom to the passed stream (overwrites existing data!). */ + void WriteDggAtom( SvStream& rStrm ) const; + + /** Called if a picture shall be written and no picture stream is set at + class ImplEscherExSdr. + + On first invokation, this function calls the virtual member function + ImplQueryPictureStream(). The return value will be cached internally + for subsequent calls and for the GetPictureStream() function. + */ + SvStream* QueryPictureStream(); + + /** Returns the picture stream if existing (queried), otherwise null. */ + inline SvStream* GetPictureStream() { return mpPicStrm; } + +private: + /** Derived classes may implement to create a new stream used to store the + picture data. + + The implementation has to take care about lifetime of the returned + stream (it will not be destructed automatically). This function is + called exactly once. The return value will be cached internally for + repeated calls of the public QueryPictureStream() function. + */ + virtual SvStream* ImplQueryPictureStream(); + +private: + struct ClusterEntry + { + sal_uInt32 mnDrawingId; /// Identifier of drawing this cluster belongs to (one-based index into maDrawingInfos). + sal_uInt32 mnNextShapeId; /// Next free shape identifier in this cluster. + inline explicit ClusterEntry( sal_uInt32 nDrawingId ) : mnDrawingId( nDrawingId ), mnNextShapeId( 0 ) {} + }; + typedef ::std::vector< ClusterEntry > ClusterTable; + + struct DrawingInfo + { + sal_uInt32 mnClusterId; /// Currently used cluster (one-based index into maClusterTable). + sal_uInt32 mnShapeCount; /// Current number of shapes in this drawing. + sal_uInt32 mnLastShapeId; /// Last shape identifier generated for this drawing. + inline explicit DrawingInfo( sal_uInt32 nClusterId ) : mnClusterId( nClusterId ), mnShapeCount( 0 ), mnLastShapeId( 0 ) {} + }; + typedef ::std::vector< DrawingInfo > DrawingInfoVector; + + ClusterTable maClusterTable; /// List with cluster IDs (used object IDs in drawings). + DrawingInfoVector maDrawingInfos; /// Data about all used drawings. + SvStream* mpPicStrm; /// Cached result of ImplQueryPictureStream(). + bool mbHasDggCont; /// True = the DGGCONTAINER has been initialized. + bool mbPicStrmQueried; /// True = ImplQueryPictureStream() has been called. +}; + +typedef ::boost::shared_ptr< EscherExGlobal > EscherExGlobalRef; + // --------------------------------------------------------------------------------------------- class SdrObject; class SdrPage; class ImplEscherExSdr; -class Color; - -class Graphic; -class SvMemoryStream; -class SvStream; -class MSFILTER_DLLPUBLIC EscherEx : public EscherPersistTable, public EscherGraphicProvider +class MSFILTER_DLLPUBLIC EscherEx : public EscherPersistTable { - protected : + protected: + typedef ::std::auto_ptr< ImplEscherExSdr > ImplEscherExSdrPtr; + EscherExGlobalRef mxGlobal; + ImplEscherExSdrPtr mpImplEscherExSdr; SvStream* mpOutStrm; - ImplEscherExSdr* mpImplEscherExSdr; UINT32 mnStrmStartOfs; std::vector< sal_uInt32 > mOffsets; std::vector< sal_uInt16 > mRecTypes; - UINT32 mnDrawings; - UINT32 mnFIDCLs; // anzahl der cluster ID's - UINT32 mnCurrentDg; - UINT32 mnCurrentShapeID; // die naechste freie ID - UINT32 mnCurrentShapeMaximumID; // die hoechste und auch benutzte ID - UINT32 mnTotalShapesDg; // anzahl der shapes im Dg - UINT32 mnTotalShapeIdUsedDg; // anzahl der benutzten shape Id's im Dg - UINT32 mnTotalShapesDgg; // anzahl der shapes im Dgg UINT32 mnCountOfs; UINT32 mnGroupLevel; UINT16 mnHellLayerId; BOOL mbEscherSpgr; - BOOL mbEscherDgg; BOOL mbEscherDg; BOOL mbOleEmf; // OLE is EMF instead of WMF virtual BOOL DoSeek( UINT32 nKey ); - public: +public: + explicit EscherEx( const EscherExGlobalRef& rxGlobal, SvStream& rOutStrm ); + virtual ~EscherEx(); - EscherEx( SvStream& rOut, UINT32 nDrawings ); + /** Creates and returns a new shape identifier, updates the internal shape + counters and registers the identifier in the DGG cluster table. */ + inline sal_uInt32 GenerateShapeId() { return mxGlobal->GenerateShapeId( mnCurrentDg, mbEscherSpgr ); } + + /** Returns the graphic provider from the global object that has been + passed to the constructor. + */ + inline EscherGraphicProvider& + GetGraphicProvider() { return *mxGlobal; } + + /** Called if a picture shall be written and no picture stream is set at + class ImplEscherExSdr. + */ + inline SvStream* QueryPictureStream() { return mxGlobal->QueryPictureStream(); } /// Fuegt in den EscherStream interne Daten ein, dieser Vorgang /// darf und muss nur einmal ausgefuehrt werden. @@ -1398,14 +1484,29 @@ class MSFILTER_DLLPUBLIC EscherEx : public EscherPersistTable, public EscherGrap /// gemerged, wie es fuer Excel (und Word?) benoetigt wird. virtual void Flush( SvStream* pPicStreamMergeBSE = NULL ); - virtual ~EscherEx(); + /** Inserts the passed number of bytes at the current position of the + output stream. + + Inserts dummy bytes and moves all following stream data, and updates + all internal stream offsets stored in the PersistTable and the affected + container sizes, which makes this operation very expensive. (!) - // Application may overload this function to maintain an offset - // table for specific regions but MUST call this function too. - virtual void InsertAtCurrentPos( UINT32 nBytes, BOOL bCont = FALSE );// es werden nBytes an der aktuellen Stream Position eingefuegt, - // die PersistantTable und interne Zeiger angepasst + @param nBytes The number of bytes to be inserted into the stream. + + @param bExpandEndOfAtom If set to true, an atom that currently ends + exactly at the current stream position will be expanded to include + the inserted data. If set to false, an atom that currently ends + exactly at the current stream position will not be expanded to + include the inserted data (used to insert e.g. a new atom after an + existing atom). Note that containers that end exactly at the + current stream position are always expanded to include the inserted + data. + */ + void InsertAtCurrentPos( sal_uInt32 nBytes, bool bExpandEndOfAtom ); void InsertPersistOffset( UINT32 nKey, UINT32 nOffset ); // Es wird nicht geprueft, ob sich jener schluessel schon in der PersistantTable befindet + void ReplacePersistOffset( UINT32 nKey, UINT32 nOffset ); + UINT32 GetPersistOffset( UINT32 nKey ); BOOL SeekToPersistOffset( UINT32 nKey ); virtual BOOL InsertAtPersistOffset( UINT32 nKey, UINT32 nValue );// nValue wird im Stream an entrsprechender Stelle eingefuegt(overwrite modus), ohne dass sich die // aktuelle StreamPosition aendert @@ -1440,21 +1541,16 @@ class MSFILTER_DLLPUBLIC EscherEx : public EscherPersistTable, public EscherGrap // ein ESCHER_Sp wird geschrieben ( Ein ESCHER_DgContainer muss dazu geoeffnet sein !!) virtual void AddShape( UINT32 nShpInstance, UINT32 nFlagIds, UINT32 nShapeID = 0 ); - // reserviert eine ShapeId - UINT32 GetShapeID(); virtual void Commit( EscherPropertyContainer& rProps, const Rectangle& rRect ); UINT32 GetColor( const UINT32 nColor, BOOL bSwap = TRUE ); UINT32 GetColor( const Color& rColor, BOOL bSwap = TRUE ); - // OLE is written as EMF instead of WMF (default WMF) - void SetOleEmf( BOOL bVal ) { mbOleEmf = bVal; } - BOOL IsOleEmf() const { return mbOleEmf; } - // ...Sdr... implemented in eschesdo.cxx void AddSdrPage( const SdrPage& rPage ); + void AddUnoShapes( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes ); /// returns the ShapeID UINT32 AddSdrObject( const SdrObject& rObj ); @@ -1467,7 +1563,9 @@ class MSFILTER_DLLPUBLIC EscherEx : public EscherPersistTable, public EscherGrap /// Called before a shape is written, application supplies /// ClientRecords. May set AppData::bDontWriteShape so the /// shape is ignored. - virtual EscherExHostAppData* StartShape( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& rShape ); + virtual EscherExHostAppData* StartShape( + const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& rShape, + const Rectangle* pChildAnchor ); /// Called after a shape is written to inform the application /// of the resulted shape type and ID. @@ -1491,10 +1589,6 @@ class MSFILTER_DLLPUBLIC EscherEx : public EscherPersistTable, public EscherGrap /// the same functionality as an ordinary recursive group. virtual EscherExHostAppData* EnterAdditionalTextGroup(); - /// Called if a picture shall be written and no PicStream is - /// set at ImplEscherExSdr - virtual SvStream* QueryPicStream(); - /// Called if an ESCHER_Prop_lTxid shall be written virtual UINT32 QueryTextID( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >&, UINT32 nShapeId ); // add an dummy rectangle shape into the escher stream @@ -1504,6 +1598,14 @@ class MSFILTER_DLLPUBLIC EscherEx : public EscherPersistTable, public EscherGrap void SetHellLayerId( UINT16 nId ) { mnHellLayerId = nId; } UINT16 GetHellLayerId() const { return mnHellLayerId; } + +private: + EscherEx( const EscherEx& ); + EscherEx& operator=( const EscherEx& ); + + // prevent C-style cast to former base class EscherGraphicProvider + operator EscherGraphicProvider&(); + operator EscherGraphicProvider const&(); }; |