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

Generated by: LCOV version 1.10