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