LCOV - code coverage report
Current view: top level - include/filter/msfilter - msdffimp.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 37 42 88.1 %
Date: 2014-11-03 Functions: 24 27 88.9 %
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_MSFILTER_MSDFFIMP_HXX
      21             : #define INCLUDED_FILTER_MSFILTER_MSDFFIMP_HXX
      22             : 
      23             : #include <string.h>
      24             : 
      25             : #include <map>
      26             : #include <vector>
      27             : #include <set>
      28             : 
      29             : #include <boost/shared_ptr.hpp>
      30             : #include <boost/scoped_ptr.hpp>
      31             : #include <boost/ptr_container/ptr_vector.hpp>
      32             : #include <boost/ptr_container/ptr_set.hpp>
      33             : 
      34             : #include <com/sun/star/uno/Reference.h>
      35             : #include <com/sun/star/embed/XEmbeddedObject.hpp>
      36             : #include <com/sun/star/beans/XPropertySet.hpp>
      37             : 
      38             : #include <tools/solar.h>
      39             : #include <tools/color.hxx>
      40             : #include <tools/gen.hxx>
      41             : 
      42             : #include <sot/storage.hxx>
      43             : 
      44             : #include <vcl/graph.hxx>
      45             : 
      46             : #include <svx/msdffdef.hxx>
      47             : #include <filter/msfilter/dffpropset.hxx>
      48             : #include <filter/msfilter/dffrecordheader.hxx>
      49             : 
      50             : #include <filter/msfilter/msfilterdllapi.h>
      51             : 
      52             : class Graphic;
      53             : class SvStream;
      54             : class SdrObject;
      55             : class SdrOle2Obj;
      56             : class Polygon;
      57             : namespace tools { class PolyPolygon; }
      58             : class FmFormModel;
      59             : class SdrModel;
      60             : class SwFlyFrmFmt;
      61             : 
      62             : struct SvxMSDffBLIPInfo;
      63             : struct SvxMSDffShapeInfo;
      64             : struct SvxMSDffShapeOrder;
      65             : 
      66             : class SvxMSDffManager;
      67             : class SfxItemSet;
      68             : class SdrObject;
      69             : class SdrTextObj;
      70             : struct DffObjData;
      71             : 
      72             : class MSFILTER_DLLPUBLIC DffPropertyReader : public DffPropSet
      73             : {
      74             :     const SvxMSDffManager&  rManager;
      75             :     DffPropSet*             pDefaultPropSet;
      76             : 
      77             :     void ApplyCustomShapeTextAttributes( SfxItemSet& rSet ) const;
      78             :     void CheckAndCorrectExcelTextRotation( SvStream& rIn, SfxItemSet& rSet, DffObjData& rObjData ) const;
      79             :     void ApplyCustomShapeAdjustmentAttributes( SfxItemSet& rSet ) const;
      80             :     void ApplyCustomShapeGeometryAttributes( SvStream& rIn,
      81             :                                              SfxItemSet& rSet,
      82             :                                              const DffObjData& rObjData ) const;
      83             :     void ApplyLineAttributes( SfxItemSet& rSet, const MSO_SPT eShapeType ) const; // #i28269#
      84             :     void ApplyFillAttributes( SvStream& rIn, SfxItemSet& rSet, const DffObjData& rObjData ) const;
      85             : 
      86             : public:
      87             :     sal_Int32 mnFix16Angle;
      88             :     bool      mbRotateGranientFillWithAngle;
      89             : 
      90             :     explicit DffPropertyReader( const SvxMSDffManager& rManager );
      91             :     ~DffPropertyReader();
      92             :     sal_Int32 Fix16ToAngle( sal_Int32 nAngle ) const;
      93             : 
      94             : #ifdef DBG_CUSTOMSHAPE
      95             :     void ReadPropSet( SvStream& rIn, void* pClientData, sal_uInt32 nShapeType = 0 ) const;
      96             : #else
      97             :     void ReadPropSet( SvStream& rIn, void* pClientData ) const;
      98             : #endif
      99             : 
     100             :     void SetDefaultPropSet( SvStream& rIn, sal_uInt32 nOffDgg ) const;
     101             :     void ApplyAttributes( SvStream& rIn, SfxItemSet& rSet ) const;
     102             :     void ApplyAttributes( SvStream& rIn, SfxItemSet& rSet, DffObjData& rObjData ) const;
     103             :     void ImportGradientColor( SfxItemSet& aSet, MSO_FillType eMSO_FillType, double dTrans = 1.0 , double dBackTrans = 1.0 ) const;
     104             : };
     105             : 
     106             : #define COL_DEFAULT RGB_COLORDATA( 0xFA, 0xFB, 0xFC )
     107             : 
     108             : typedef ::std::map< sal_Int32, SdrObject* > SvxMSDffShapeIdContainer;
     109             : 
     110             : #define SVEXT_PERSIST_STREAM "\002OlePres000"
     111             : 
     112             : // the following two will be sorted by the order of their appearance:
     113             : typedef boost::ptr_vector<SvxMSDffBLIPInfo> SvxMSDffBLIPInfos;
     114             : typedef boost::ptr_vector<SvxMSDffShapeOrder> SvxMSDffShapeOrders;
     115             : 
     116             : struct MSFILTER_DLLPUBLIC CompareSvxMSDffShapeInfoById
     117             : {
     118             :     bool operator()(::boost::shared_ptr<SvxMSDffShapeInfo> const& lhs,
     119             :                     ::boost::shared_ptr<SvxMSDffShapeInfo> const& rhs) const;
     120             : };
     121             : struct MSFILTER_DLLPUBLIC CompareSvxMSDffShapeInfoByTxBxComp
     122             : {
     123             :     bool operator()(::boost::shared_ptr<SvxMSDffShapeInfo> const& lhs,
     124             :                     ::boost::shared_ptr<SvxMSDffShapeInfo> const& rhs) const;
     125             : };
     126             : 
     127             : // the following will be sorted explicitly:
     128             : typedef ::std::set< ::boost::shared_ptr<SvxMSDffShapeInfo>,
     129             :             CompareSvxMSDffShapeInfoById > SvxMSDffShapeInfos_ById;
     130             : typedef ::std::multiset< ::boost::shared_ptr<SvxMSDffShapeInfo>,
     131             :             CompareSvxMSDffShapeInfoByTxBxComp> SvxMSDffShapeInfos_ByTxBxComp;
     132             : 
     133             : #define SVXMSDFF_SETTINGS_CROP_BITMAPS      1
     134             : #define SVXMSDFF_SETTINGS_IMPORT_PPT        2
     135             : #define SVXMSDFF_SETTINGS_IMPORT_EXCEL      4
     136             : 
     137             : #define SP_FGROUP       0x001   ///< This shape is a group shape
     138             : #define SP_FCHILD       0x002   ///< Not a top-level shape
     139             : #define SP_FPATRIARCH   0x004   ///< This is the topmost group shape.
     140             :                                 ///< Exactly one of these per drawing.
     141             : #define SP_FDELETED     0x008   ///< The shape has been deleted
     142             : #define SP_FOLESHAPE    0x010   ///< The shape is an OLE object
     143             : #define SP_FHAVEMASTER  0x020   ///< Shape has a hspMaster property
     144             : #define SP_FFLIPH       0x040   ///< Shape is flipped horizontally
     145             : #define SP_FFLIPV       0x080   ///< Shape is flipped vertically
     146             : #define SP_FCONNECTOR   0x100   ///< Connector type of shape
     147             : #define SP_FHAVEANCHOR  0x200   ///< Shape has an anchor of some kind
     148             : #define SP_FBACKGROUND  0x400   ///< Background shape
     149             : #define SP_FHAVESPT     0x800   ///< Shape has a shape type property
     150             : 
     151             : // for the CreateSdrOLEFromStorage we need the information, how we handle
     152             : // convert able OLE-Objects - this ist stored in
     153             : #define OLE_MATHTYPE_2_STARMATH             0x0001
     154             : #define OLE_WINWORD_2_STARWRITER            0x0002
     155             : #define OLE_EXCEL_2_STARCALC                0x0004
     156             : #define OLE_POWERPOINT_2_STARIMPRESS        0x0008
     157             : 
     158             : struct SvxMSDffConnectorRule
     159             : {
     160             :     sal_uInt32  nRuleId;
     161             :     sal_uInt32  nShapeA;   ///< SPID of shape A
     162             :     sal_uInt32  nShapeB;   ///< SPID of shape B
     163             :     sal_uInt32  nShapeC;   ///< SPID of connector shape
     164             :     sal_uInt32  ncptiA;    ///< Connection site Index of shape A
     165             :     sal_uInt32  ncptiB;    ///< Connection site Index of shape B
     166             :     sal_uInt32  nSpFlagsA; ///< SpFlags of shape A (the original mirror flags
     167             :                            ///< must be known when solving the Solver Container)
     168             :     sal_uInt32  nSpFlagsB; ///< SpFlags of shape B
     169             : 
     170             :     SdrObject*  pAObj;     ///< pPtr of object (corresponding to shape A)
     171             :     SdrObject*  pBObj;     ///< pPtr of object (corresponding to shape B)
     172             :     SdrObject*  pCObj;     ///< pPtr of connector object
     173             : 
     174           4 :     SvxMSDffConnectorRule()
     175             :         : nRuleId(0)
     176             :         , nShapeA(0)
     177             :         , nShapeB(0)
     178             :         , nShapeC(0)
     179             :         , ncptiA(0)
     180             :         , ncptiB(0)
     181             :         , nSpFlagsA( 0 )
     182             :         , nSpFlagsB( 0 )
     183             :         , pAObj( NULL )
     184             :         , pBObj( NULL )
     185           4 :         , pCObj( NULL )
     186           4 :         {};
     187             : 
     188             :     friend SvStream& ReadSvxMSDffConnectorRule( SvStream& rIn, SvxMSDffConnectorRule& rAtom );
     189             : };
     190             : 
     191             : typedef ::std::vector< SvxMSDffConnectorRule* > SvxMSDffConnectorRuleList;
     192             : 
     193             : struct MSFILTER_DLLPUBLIC SvxMSDffSolverContainer
     194             : {
     195             :     SvxMSDffConnectorRuleList   aCList;
     196             : 
     197             :     SvxMSDffSolverContainer();
     198             :     ~SvxMSDffSolverContainer();
     199             : 
     200             :     MSFILTER_DLLPUBLIC friend SvStream& ReadSvxMSDffSolverContainer( SvStream& rIn, SvxMSDffSolverContainer& rAtom );
     201             : };
     202             : 
     203             : struct FIDCL
     204             : {
     205             :     sal_uInt32  dgid;       ///< DG owning the SPIDs in this cluster
     206             :     sal_uInt32  cspidCur;   ///< number of SPIDs used so far
     207             : };
     208             : 
     209             : /// provided by SvxMSDffManager for each shape in a group
     210             : struct MSDffTxId
     211             : {
     212             :     sal_uInt16 nTxBxS;
     213             :     sal_uInt16 nSequence;
     214         810 :     MSDffTxId( sal_uInt16 nTxBxS_, sal_uInt16 nSequence_ )
     215         810 :         : nTxBxS( nTxBxS_ ), nSequence( nSequence_ ){}
     216           0 :     MSDffTxId( const MSDffTxId& rCopy )
     217           0 :         : nTxBxS( rCopy.nTxBxS ), nSequence( rCopy.nSequence ){}
     218             : };
     219             : 
     220             : struct MSFILTER_DLLPUBLIC SvxMSDffImportRec
     221             : {
     222             :     static const int RELTO_DEFAULT = 2;
     223             : 
     224             :     SdrObject*      pObj;
     225             :     Polygon*        pWrapPolygon;
     226             :     char*           pClientAnchorBuffer;
     227             :     sal_uInt32      nClientAnchorLen;
     228             :     char*           pClientDataBuffer;
     229             :     sal_uInt32      nClientDataLen;
     230             :     sal_uInt32      nXAlign;
     231             :     sal_uInt32      *pXRelTo;
     232             :     sal_uInt32      nYAlign;
     233             :     sal_uInt32      *pYRelTo;
     234             :     sal_uInt32      nLayoutInTableCell;
     235             :     sal_uInt32      nFlags;
     236             :     sal_Int32       nTextRotationAngle;
     237             :     sal_Int32       nDxTextLeft;    ///< distance of text box from surrounding shape
     238             :     sal_Int32       nDyTextTop;
     239             :     sal_Int32       nDxTextRight;
     240             :     sal_Int32       nDyTextBottom;
     241             :     sal_Int32       nDxWrapDistLeft;
     242             :     sal_Int32       nDyWrapDistTop;
     243             :     sal_Int32       nDxWrapDistRight;
     244             :     sal_Int32       nDyWrapDistBottom;
     245             :     sal_Int32       nCropFromTop;
     246             :     sal_Int32       nCropFromBottom;
     247             :     sal_Int32       nCropFromLeft;
     248             :     sal_Int32       nCropFromRight;
     249             :     MSDffTxId       aTextId;        ///< identifier for text boxes
     250             :     sal_uLong       nNextShapeId;   ///< for linked text boxes
     251             :     sal_uLong       nShapeId;
     252             :     MSO_SPT         eShapeType;
     253             :     MSO_LineStyle   eLineStyle;     ///< border types
     254             :     MSO_LineDashing eLineDashing;
     255             :     bool            bDrawHell       :1;
     256             :     bool            bHidden         :1;
     257             :     bool            bReplaceByFly   :1;
     258             :     bool            bVFlip          :1;
     259             :     bool            bHFlip          :1;
     260             :     bool            bAutoWidth      :1;
     261             :     int             relativeHorizontalWidth; ///< in 0.1% or -1 for none
     262             :     bool            isHorizontalRule;
     263             : 
     264             :     SvxMSDffImportRec();
     265             :     SvxMSDffImportRec(const SvxMSDffImportRec& rCopy);
     266             :     ~SvxMSDffImportRec();
     267             : 
     268             :     bool operator==( const SvxMSDffImportRec& rEntry ) const
     269             :     {   return nShapeId == rEntry.nShapeId; }
     270        2200 :     bool operator<( const SvxMSDffImportRec& rEntry ) const
     271        2200 :     {   return nShapeId < rEntry.nShapeId;  }
     272             : 
     273             : private:
     274             :     SvxMSDffImportRec &operator=(const SvxMSDffImportRec&);
     275             : };
     276             : 
     277             : /** list of all SvxMSDffImportRec instances of/for a group */
     278         604 : class MSDffImportRecords
     279             :     : public ::boost::ptr_set<SvxMSDffImportRec>
     280             : {};
     281             : 
     282             : /** block of parameters for import/export for a single call of
     283             :     ImportObjAtCurrentStreamPos() */
     284         302 : struct SvxMSDffImportData
     285             : {
     286             :     MSDffImportRecords  aRecords;   ///< Shape pointer, Shape ids and private data
     287             :     Rectangle           aParentRect;///< Rectangle of the surrounding groups,
     288             :                                     ///< which might have been provided externally
     289             :     Rectangle           aNewRect;   ///< Rectangle that is defined by this shape
     290             : 
     291             :     SvxMSDffImportData()
     292             :         {}
     293         302 :     explicit SvxMSDffImportData( const Rectangle& rParentRect ) : aParentRect( rParentRect ) {}
     294             :     void SetNewRect(sal_Int32 left, sal_Int32 top, sal_Int32 right, sal_Int32 bottom )
     295             :         { aNewRect = Rectangle(left, top, right, bottom); }
     296             :     bool HasParRect() const { return aParentRect.IsEmpty(); }
     297             :     bool HasNewRect() const { return aNewRect.IsEmpty()   ; }
     298         128 :     bool empty() const { return aRecords.empty(); }
     299         234 :     size_t size() const { return aRecords.size(); }
     300         384 :     MSDffImportRecords::const_iterator begin() const { return aRecords.begin();  }
     301         812 :     MSDffImportRecords::const_iterator end() const { return aRecords.end();  }
     302             : };
     303             : 
     304             : struct DffObjData
     305             : {
     306             :     const DffRecordHeader&  rSpHd;
     307             : 
     308             :     Rectangle   aBoundRect;
     309             :     Rectangle   aChildAnchor;
     310             : 
     311             :     sal_uInt32  nShapeId;
     312             :     sal_uInt32  nSpFlags;
     313             :     MSO_SPT     eShapeType;
     314             : 
     315             :     bool        bShapeType     : 1;
     316             :     bool        bClientAnchor  : 1;
     317             :     bool        bClientData    : 1;
     318             :     bool        bChildAnchor   : 1;
     319             :     bool        bOpt           : 1;
     320             :     bool        bOpt2          : 1;
     321             :     bool        bIsAutoText    : 1;
     322             :     bool        bRotateTextWithShape : 1;
     323             :     bool        bPageAnchor;
     324             :     int         nCalledByGroup;
     325             : 
     326        3968 :     DffObjData( const DffRecordHeader& rObjHd,
     327             :                 const Rectangle& rBoundRect,
     328             :                 int   nClByGroup ) :
     329             :         rSpHd( rObjHd ),
     330             :         aBoundRect( rBoundRect ),
     331             :         nShapeId( 0 ),
     332             :         nSpFlags( 0 ),
     333             :         eShapeType( mso_sptNil ),
     334             :         bShapeType( false ),
     335             :         bClientAnchor( false ),
     336             :         bClientData( false ),
     337             :         bChildAnchor( false ),
     338             :         bOpt( false ),
     339             :         bOpt2( false ),
     340             :         bIsAutoText( false ),
     341             :         bRotateTextWithShape( true ),
     342             :         bPageAnchor( true ),
     343        3968 :         nCalledByGroup( nClByGroup ){}
     344             : };
     345             : 
     346             : #define DFF_RECORD_MANAGER_BUF_SIZE         64
     347             : 
     348             : struct DffRecordList
     349             : {
     350             :     sal_uInt32          nCount;
     351             :     sal_uInt32          nCurrent;
     352             :     DffRecordList*      pPrev;
     353             :     DffRecordList*      pNext;
     354             : 
     355             :     DffRecordHeader     mHd[ DFF_RECORD_MANAGER_BUF_SIZE ];
     356             : 
     357             :     explicit DffRecordList( DffRecordList* pList );
     358             :     ~DffRecordList();
     359             : };
     360             : 
     361             : enum DffSeekToContentMode
     362             : {
     363             :     SEEK_FROM_BEGINNING,
     364             :     SEEK_FROM_CURRENT,
     365             :     SEEK_FROM_CURRENT_AND_RESTART
     366             : };
     367             : 
     368         442 : class MSFILTER_DLLPUBLIC DffRecordManager : public DffRecordList
     369             : {
     370             : public :
     371             :         DffRecordList*   pCList;
     372             : 
     373             :         void             Clear();
     374             :         void             Consume( SvStream& rIn,
     375             :                                   bool bAppend = false,
     376             :                                   sal_uInt32 nStOfs = 0 );
     377             : 
     378             :         bool             SeekToContent( SvStream& rIn,
     379             :                                         sal_uInt16 nRecType,
     380             :                                         DffSeekToContentMode eMode = SEEK_FROM_BEGINNING );
     381             :         DffRecordHeader* GetRecordHeader( sal_uInt16 nRecType,
     382             :                                           DffSeekToContentMode eMode = SEEK_FROM_BEGINNING );
     383             : 
     384             :         DffRecordManager();
     385             :         explicit DffRecordManager( SvStream& rIn );
     386             : 
     387             :         DffRecordHeader* Current();
     388             :         DffRecordHeader* First();
     389             :         DffRecordHeader* Next();
     390             :         DffRecordHeader* Prev();
     391             :         DffRecordHeader* Last();
     392             : };
     393             : 
     394             : /** abstract base class for Escher imports
     395             : 
     396             :     Purpose: access to objects in Drawing File Format
     397             : 
     398             :     Note: The method ProcessUserDefinedRecord() _has_ to be implemented in the
     399             :           inheriting class(es) that is/are eventually used for PowerPoint, Word,
     400             :           or Excel importing.
     401             : 
     402             :     Status: Currently only access to BLIPs (will be extended later)
     403             : */
     404             : class MSFILTER_DLLPUBLIC SvxMSDffManager : public DffPropertyReader
     405             : {
     406             :     FmFormModel*            pFormModel;
     407             :     SvxMSDffBLIPInfos*      pBLIPInfos;
     408             :     ::boost::scoped_ptr<SvxMSDffShapeInfos_ByTxBxComp> m_pShapeInfosByTxBxComp;
     409             :     ::boost::scoped_ptr<SvxMSDffShapeInfos_ById> m_pShapeInfosById;
     410             :     SvxMSDffShapeOrders*    pShapeOrders;
     411             :     sal_uLong               nDefaultFontHeight;
     412             :     sal_uInt32              nOffsDgg;
     413             :     sal_uInt16              nBLIPCount;
     414             :     sal_uInt16              nShapeCount;
     415             :     sal_uInt32              nGroupShapeFlags;
     416             : 
     417             :     void CheckTxBxStoryChain();
     418             :     void GetFidclData(sal_uInt32 nOffsDgg);
     419             : 
     420             : protected :
     421             :     typedef std::map<sal_uInt32, sal_uInt32> OffsetMap;
     422             : 
     423             :     OUString        maBaseURL;
     424             :     sal_uInt32      mnCurMaxShapeId;    // we need this information to
     425             :     sal_uInt32      mnDrawingsSaved;    // access the right drawing
     426             :     sal_uInt32      mnIdClusters;       // while only knowing the shapeid
     427             :     std::vector<FIDCL> maFidcls;
     428             :     OffsetMap       maDgOffsetTable;    ///< array of fileoffsets
     429             : 
     430             :     friend class DffPropertyReader;
     431             : 
     432             :     SvStream&       rStCtrl;
     433             :     SvStream*       pStData;
     434             :     SvStream*       pStData2;
     435             :     SdrModel*       pSdrModel;
     436             : 
     437             :     long            nMapMul;
     438             :     long            nMapDiv;
     439             :     long            nMapXOfs;
     440             :     long            nMapYOfs;
     441             :     long            nEmuMul;
     442             :     long            nEmuDiv;
     443             :     long            nPntMul;
     444             :     long            nPntDiv;
     445             :     bool            bNeedMap;
     446             :     sal_uInt32      nSvxMSDffSettings;
     447             :     sal_uInt32      nSvxMSDffOLEConvFlags;
     448             : 
     449             :     /** stores a reference to an imported SdrObject
     450             :         with its shape id if it has one */
     451             :     SvxMSDffShapeIdContainer    maShapeIdContainer;
     452             : 
     453             :     void GetCtrlData(sal_uInt32 nOffsDgg);
     454             :     void GetDrawingGroupContainerData( SvStream& rSt,
     455             :                                        sal_uLong nLenDgg );
     456             :     // #156763#
     457             :     // Add internal drawing container id as parameter to the sub methods of
     458             :     // reading the control information about the drawing objects.
     459             :     // The drawing container id is used to distinguish the text ids of drawing
     460             :     // objects in different drawing containers.
     461             :     void GetDrawingContainerData( SvStream& rSt,
     462             :                                   sal_uLong nLenDg,
     463             :                                   const unsigned long nDrawingContainerId );
     464             :     bool GetShapeGroupContainerData( SvStream& rSt,
     465             :                                      sal_uLong nLenShapeGroupCont,
     466             :                                      bool bPatriarch,
     467             :                                      const unsigned long nDrawingContainerId );
     468             :     bool GetShapeContainerData( SvStream& rSt,
     469             :                                 sal_uLong nLenShapeCont,
     470             :                                 sal_uLong nPosGroup,
     471             :                                 const unsigned long nDrawingContainerId );
     472             : 
     473             :     bool ReadGraphic( SvStream& rSt, sal_uLong nIndex, Graphic& rGraphic ) const;
     474             :     SdrObject* ImportGraphic( SvStream&, SfxItemSet&, const DffObjData& );
     475             :     // #i32596# - pass <nCalledByGroup> to method
     476             :     // Needed in Writer's Microsoft Word import to avoid import of OLE objects
     477             :     // inside groups. Instead a graphic object is created.
     478             :     virtual SdrObject* ImportOLE( long nOLEId,
     479             :                                   const Graphic& rGraf,
     480             :                                   const Rectangle& rBoundRect,
     481             :                                   const Rectangle& rVisArea,
     482             :                                   const int _nCalledByGroup,
     483             :                                   sal_Int64 nAspect ) const;
     484             :     static com::sun::star::uno::Reference < com::sun::star::embed::XEmbeddedObject > CheckForConvertToSOObj(
     485             :                 sal_uInt32 nConvertFlags, SotStorage& rSrcStg,
     486             :                 const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >& xDestStg,
     487             :                 const Graphic& rGrf,
     488             :                 const Rectangle& rVisArea );
     489             : 
     490             : // the following methods need to be overridden for Excel imports
     491             :     virtual bool ProcessClientAnchor( SvStream& rStData,
     492             :                                           sal_uInt32 nDatLen,
     493             :                                           char*& rpBuff,
     494             :                                           sal_uInt32& rBuffLen ) const;
     495             :     virtual void ProcessClientAnchor2( SvStream& rStData,
     496             :                                        DffRecordHeader& rHd,
     497             :                                        void* pData, DffObjData& );
     498             :     virtual bool ProcessClientData( SvStream& rStData,
     499             :                                         sal_uInt32 nDatLen,
     500             :                                         char*& rpBuff,
     501             :                                         sal_uInt32& rBuffLen ) const;
     502             :     virtual SdrObject* ProcessObj( SvStream& rSt,
     503             :                                    DffObjData& rData,
     504             :                                    void* pData,
     505             :                                    Rectangle& rTextRect,
     506             :                                    SdrObject* pObj = NULL);
     507             :     virtual sal_uLong Calc_nBLIPPos( sal_uLong nOrgVal,
     508             :                                      sal_uLong nStreamPos ) const;
     509             :     virtual bool GetColorFromPalette(sal_uInt16 nNum, Color& rColor) const;
     510             : 
     511             :     // Fontwork objects use a new implementation of ReadObjText because the old
     512             :     // one does not properly import multiple paragraphs.
     513             :     static void ReadObjText( const OUString& rText, SdrObject* pObj );
     514             : 
     515             : // the following method needs to be overridden for the import of OLE objects
     516             :     virtual bool GetOLEStorageName( long nOLEId,
     517             :                                         OUString& rStorageName,
     518             :                                         SotStorageRef& rSrcStorage,
     519             :                       com::sun::star::uno::Reference < com::sun::star::embed::XStorage >& xDestStg
     520             :                                     ) const;
     521             : 
     522             :     /** Prevent that (rounded) rectangles with wrapped text will always be
     523             :         converted into SdrRectObj( OBJ_TEXT ).
     524             : 
     525             :         @return true means "conversion".
     526             :     */
     527             :     virtual bool ShapeHasText(sal_uLong nShapeId, sal_uLong nFilePos) const;
     528             : 
     529             : public:
     530             :     DffPropertyReader* pSecPropSet;
     531             :     std::map<sal_uInt32,OString> aEscherBlipCache;
     532             : 
     533             :     DffRecordManager    maShapeRecords;
     534             :     ColorData           mnDefaultColor;
     535             : 
     536             :     bool                mbTracing;
     537             : 
     538             :     Color MSO_TEXT_CLR_ToColor( sal_uInt32 nColorCode ) const;
     539             :     Color MSO_CLR_ToColor( sal_uInt32 nColorCode,
     540             :                            sal_uInt16 nContextProperty = DFF_Prop_lineColor ) const;
     541             :     virtual bool SeekToShape( SvStream& rSt,
     542             :                                   void* pClientData,
     543             :                                   sal_uInt32 nId ) const;
     544             :     bool SeekToRec( SvStream& rSt,
     545             :                     sal_uInt16 nRecId,
     546             :                     sal_uLong nMaxFilePos,
     547             :                     DffRecordHeader* pRecHd = NULL,
     548             :                     sal_uLong nSkipCount = 0 ) const;
     549             :     bool SeekToRec2( sal_uInt16 nRecId1,
     550             :                      sal_uInt16 nRecId2,
     551             :                      sal_uLong nMaxFilePos,
     552             :                      DffRecordHeader* pRecHd = NULL,
     553             :                      sal_uLong nSkipCount = 0 ) const;
     554             : 
     555             :     static OUString MSDFFReadZString( SvStream& rIn,
     556             :                                            sal_uInt32 nMaxLen,
     557             :                                            bool bUniCode = false);
     558             : 
     559             :     static bool ReadCommonRecordHeader( SvStream& rSt,
     560             :                                         sal_uInt8& rVer,
     561             :                                         sal_uInt16& rInst,
     562             :                                         sal_uInt16& rFbt,
     563             :                                         sal_uInt32& rLength) SAL_WARN_UNUSED_RESULT;
     564             : 
     565             : // TODO: provide proper documentation here
     566             :     /** constructor
     567             : 
     568             :         sets nBLIPCount
     569             : 
     570             :         @param rStCtrl             Management stream with containers, FBSE
     571             :                                    objects and shapes (mandatory; stream needs
     572             :                                    to be open already)
     573             :         @param rBaseURL            ???
     574             :         @param nOffsDgg            offset in rStrCtrl; beginning of the drawing
     575             :                                    group container
     576             :         @param pStData             data stream in that the BLIPs are stored (if
     577             :                                    NULL it is assumed that all BLIPs are also in
     578             :                                    the rStCtrl; stream needs to be open already)
     579             :         @param pSdrModel_          ??? (can be empty during Ctor call but needs
     580             :                                    to be set via SetModel() later in that case!)
     581             :         @param nApplicationScale   ???
     582             :         @param mnDefaultColor_     ???
     583             :         @param nDefaultFontHeight_ ???
     584             :         @param pStData2_           ???
     585             :     */
     586             :     SvxMSDffManager( SvStream& rStCtrl,
     587             :                      const OUString& rBaseURL,
     588             :                      sal_uInt32 nOffsDgg,
     589             :                      SvStream* pStData,
     590             :                      SdrModel* pSdrModel_           =  0,
     591             :                      long      nApplicationScale    =  0,
     592             :                      ColorData mnDefaultColor_      =  COL_DEFAULT,
     593             :                      sal_uLong nDefaultFontHeight_  = 24,
     594             :                      SvStream* pStData2_            =  0 );
     595             : 
     596             :     // in PPT the parameters DGGContainerOffset and PicStream are provided by an
     597             :     // init method
     598             :     SvxMSDffManager( SvStream& rStCtrl, const OUString& rBaseURL );
     599             :     void InitSvxMSDffManager( sal_uInt32 nOffsDgg_,
     600             :                               SvStream* pStData_,
     601             :                               sal_uInt32 nSvxMSDffOLEConvFlags);
     602             :     void SetDgContainer( SvStream& rSt );
     603             : 
     604             :     virtual ~SvxMSDffManager();
     605             : 
     606        7872 :     sal_uInt32  GetSvxMSDffSettings() const { return nSvxMSDffSettings; };
     607         388 :     void    SetSvxMSDffSettings( sal_uInt32 nSettings ) { nSvxMSDffSettings = nSettings; };
     608             : 
     609             :     static bool         MakeContentStream( SotStorage * pStor, const GDIMetaFile & );
     610             :     static void         ReadObjText( SvStream& rStream, SdrObject* pObj );
     611             :     static bool         ConvertToOle2( SvStream& rStm,
     612             :                                        sal_uInt32 nLen,
     613             :                                        const GDIMetaFile*,
     614             :                                        const SotStorageRef & rDest );
     615             : 
     616             :     void SetModel(SdrModel* pModel, long nApplicationScale);
     617         394 :     SdrModel*  GetModel() const { return pSdrModel; }
     618             :     void Scale(sal_Int32& rVal) const;
     619             :     void Scale(Point& rPos) const;
     620             :     void Scale(Size& rSiz) const;
     621             :     void ScaleEmu(sal_Int32& rVal) const;
     622             :     sal_uInt32 ScalePt( sal_uInt32 nPt ) const;
     623             :     sal_Int32 ScalePoint( sal_Int32 nVal ) const;
     624             : 
     625             : // TODO: provide proper documentation here
     626             :     /** Request for a specific BLIP.
     627             : 
     628             :         @param[in] nIdx   number of the requested BLIP (mandatory)
     629             :         @param[out] rData already converted data (insert directly as graphics
     630             :                           into our documents)
     631             :         @param pVisArea   ???
     632             : 
     633             :         @return true if successful, false otherwise
     634             :     */
     635             :     bool GetBLIP( sal_uLong nIdx, Graphic& rData, Rectangle* pVisArea = NULL );
     636             : 
     637             : // TODO: provide proper documentation here
     638             :     /** read a BLIP out of a already positioned stream
     639             : 
     640             :         @param[in] rBLIPStream alread positioned stream (mandatory)
     641             :         @param[out] rData      already converted data (insert directly as
     642             :                                graphics into our documents)
     643             :         @param pVisArea        ???
     644             : 
     645             :         @return true if successful, false otherwise
     646             :     */
     647             :     bool GetBLIPDirect(SvStream& rBLIPStream, Graphic& rData, Rectangle* pVisArea = NULL ) const;
     648             : 
     649             :     bool GetShape(sal_uLong nId, SdrObject*& rpData, SvxMSDffImportData& rData);
     650             : 
     651             :     /** Get count of managed BLIPs
     652             : 
     653             :         @return Number of BLIPs in pStData (or rStCtrl), thus number of FBSEs in
     654             :                 the drawing group container. If 0 is returned this means that
     655             :                 the structure is ok but there are no BLIPs; if USHRT_MAX is
     656             :                 returned than there was an error: no correct Drawing File Format
     657             :     */
     658             :     sal_uInt16 GetBLIPCount() const{ return nBLIPCount; }
     659             : 
     660             :     SdrObject* ImportObj( SvStream& rSt,
     661             :                           void* pData,
     662             :                           Rectangle& rClientRect,
     663             :                           const Rectangle& rGlobalChildRect,
     664             :                           int nCalledByGroup = 0,
     665             :                           sal_Int32* pShapeId = NULL);
     666             :     SdrObject* ImportGroup( const DffRecordHeader& rHd,
     667             :                             SvStream& rSt,
     668             :                             void* pData,
     669             :                             Rectangle& rClientRect,
     670             :                             const Rectangle& rGlobalChildRect,
     671             :                             int nCalledByGroup = 0,
     672             :                             sal_Int32* pShapeId = NULL );
     673             :     SdrObject* ImportShape( const DffRecordHeader& rHd,
     674             :                             SvStream& rSt,
     675             :                             void* pData,
     676             :                             Rectangle& rClientRect,
     677             :                             const Rectangle& rGlobalChildRect,
     678             :                             int nCalledByGroup = 0,
     679             :                             sal_Int32* pShapeId = NULL);
     680             : 
     681             :     Rectangle GetGlobalChildAnchor( const DffRecordHeader& rHd,
     682             :                                     SvStream& rSt,
     683             :                                     Rectangle& aClientRect );
     684             :     void GetGroupAnchors( const DffRecordHeader& rHd,
     685             :                           SvStream& rSt,
     686             :                           Rectangle& rGroupClientAnchor,
     687             :                           Rectangle& rGroupChildAnchor,
     688             :                           const Rectangle& rClientRect,
     689             :                           const Rectangle& rGlobalChildRect );
     690             : 
     691         264 :     inline const SvxMSDffShapeInfos_ById* GetShapeInfos( void ) const
     692         264 :         { return m_pShapeInfosById.get(); }
     693             : 
     694         878 :     inline SvxMSDffShapeOrders* GetShapeOrders( void ) const
     695         878 :         { return pShapeOrders; }
     696             : 
     697             :     void StoreShapeOrder(sal_uLong      nId,
     698             :                          sal_uLong      nTxBx,
     699             :                          SdrObject*     pObject,
     700             :                          SwFlyFrmFmt*   pFly = 0,
     701             :                          short          nHdFtSection = 0) const;
     702             : 
     703             :     void ExchangeInShapeOrder(SdrObject*    pOldObject,
     704             :                               sal_uLong     nTxBx,
     705             :                               SwFlyFrmFmt*  pFly,
     706             :                               SdrObject*    pObject) const;
     707             : 
     708             :     void RemoveFromShapeOrder( SdrObject* pObject ) const;
     709             : 
     710             :     sal_uInt32  GetConvertFlags() const { return nSvxMSDffOLEConvFlags; }
     711             : 
     712             :     static SdrOle2Obj* CreateSdrOLEFromStorage( const OUString& rStorageName,
     713             :                                                 SotStorageRef& rSrcStorage,
     714             :                                                 const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >& xDestStg,
     715             :                                                 const Graphic& rGraf,
     716             :                                                 const Rectangle& rBoundRect,
     717             :                                                 const Rectangle& rVisArea,
     718             :                                                 SvStream* pDataStrrm,
     719             :                                                 ErrCode& rError,
     720             :                                                 sal_uInt32 nConvertFlags,
     721             :                                                 sal_Int64 nAspect );
     722             : 
     723             :     /** Create connections between shapes.
     724             :         This method should be called after a page is imported.
     725             : 
     726             :         @param rSolver contains necessary data that is collected during the
     727             :                        import of each shape
     728             :     */
     729             :     void SolveSolver( const SvxMSDffSolverContainer& rSolver );
     730             : 
     731             :     static bool SetPropValue(
     732             :         const ::com::sun::star::uno::Any& rAny,
     733             :         const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & rXPropSet,
     734             :         const OUString& rPropertyName,
     735             :         bool bTestPropertyAvailability = false
     736             :     );
     737             : 
     738             :     void insertShapeId( sal_Int32 nShapeId, SdrObject* pShape );
     739             :     void removeShapeId( SdrObject* pShape );
     740             :     SdrObject* getShapeForId( sal_Int32 nShapeId );
     741             : };
     742             : 
     743             : struct SvxMSDffBLIPInfo
     744             : {
     745             :     sal_uInt16 nBLIPType;   ///< type of BLIP: e.g. 6 for PNG
     746             :     sal_uLong  nFilePos;    ///< offset of the BLIP in data strem
     747             :     sal_uLong  nBLIPSize;   ///< number of bytes that the BLIP needs in stream
     748         188 :     SvxMSDffBLIPInfo(sal_uInt16 nBType, sal_uLong nFPos, sal_uLong nBSize):
     749         188 :         nBLIPType( nBType ), nFilePos( nFPos ), nBLIPSize( nBSize ){}
     750             : };
     751             : 
     752             : struct SvxMSDffShapeInfo
     753             : {
     754             :     sal_uInt32 nShapeId; ///< shape id, used in PLCF SPA and in mso_fbtSp (FSP)
     755             :     sal_uLong nFilePos;  ///< offset of the shape in control stream for
     756             :                          ///< potential later access to it
     757             :     sal_uInt32 nTxBxComp;
     758             : 
     759             :     bool bReplaceByFly  :1; ///< shape can be replaced by a frame in Writer
     760             : 
     761        1068 :     explicit SvxMSDffShapeInfo(sal_uLong nFPos, sal_uInt32 nId=0, // sal_uLong nBIdx=0,
     762             :                       sal_uInt16 nSeqId=0, sal_uInt16 nBoxId=0):
     763             :         nShapeId( nId ),
     764             :         nFilePos( nFPos ),
     765        1068 :         nTxBxComp( (nSeqId << 16) + nBoxId )
     766             :         {
     767        1068 :             bReplaceByFly   = false;
     768        1068 :         }
     769         684 :     SvxMSDffShapeInfo(SvxMSDffShapeInfo& rInfo):
     770             :         nShapeId( rInfo.nShapeId ),
     771             :         nFilePos( rInfo.nFilePos ),
     772         684 :         nTxBxComp( rInfo.nTxBxComp )
     773             :         {
     774         684 :             bReplaceByFly   = rInfo.bReplaceByFly;
     775         684 :         }
     776             : };
     777             : 
     778             : 
     779             : struct SvxMSDffShapeOrder
     780             : {
     781             :     sal_uLong nShapeId;  ///< shape id used in PLCF SPA and in mso_fbtSp (FSP)
     782             :     sal_uLong nTxBxComp; ///< chain or box number in the Text-Box-Story (or NULL)
     783             :     SwFlyFrmFmt* pFly;   ///< format of frame that was inserted as a replacement
     784             :                          ///< for a Sdr-Text object in Writer - needed for
     785             :                          ///< chaining!
     786             :     short nHdFtSection;  ///< used by Writer to find out if linked frames are in
     787             :                          ///< the same header or footer of the same section
     788             :     SdrObject*  pObj;    ///< pointer to the draw object (or NULL if not used)
     789             : 
     790             :     // Approach: In the Ctor of SvxMSDffManager only the shape ids are stored in
     791             :     //           the shape order array. The Text-Box number and the object
     792             :     //           pointer are only stored if the shape is really imported.
     793         684 :     explicit SvxMSDffShapeOrder( sal_uLong nId ):
     794         684 :         nShapeId( nId ), nTxBxComp( 0 ), pFly( 0 ), nHdFtSection( 0 ), pObj( 0 ){}
     795             : 
     796             :     bool operator==( const SvxMSDffShapeOrder& rEntry ) const
     797             :     { return (nTxBxComp == rEntry.nTxBxComp); }
     798           0 :     bool operator<( const SvxMSDffShapeOrder& rEntry ) const
     799           0 :     { return (nTxBxComp < rEntry.nTxBxComp); }
     800             : };
     801             : 
     802             : // the following will be sorted explicitly:
     803             : struct CompareSvxMSDffShapeTxBxSort
     804             : {
     805           0 :   bool operator()( SvxMSDffShapeOrder* const& lhs, SvxMSDffShapeOrder* const& rhs ) const { return (*lhs)<(*rhs); }
     806             : };
     807         112 : class MSFILTER_DLLPUBLIC SvxMSDffShapeTxBxSort : public std::set<SvxMSDffShapeOrder*,CompareSvxMSDffShapeTxBxSort> {};
     808             : 
     809             : 
     810             : #endif
     811             : 
     812             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10