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