Bump version to 6.4-15
[LibreOffice.git] / include / filter / msfilter / msdffimp.hxx
blob341dc2b5329e7036107a804b07836a5f80124ca7
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 <cstring>
24 #include <map>
25 #include <memory>
26 #include <set>
27 #include <utility>
28 #include <vector>
29 #include <unordered_map>
31 #include <boost/optional.hpp>
32 #include <com/sun/star/uno/Any.hxx>
33 #include <com/sun/star/uno/Reference.hxx>
34 #include <comphelper/stl_types.hxx>
35 #include <filter/msfilter/dffpropset.hxx>
36 #include <filter/msfilter/dffrecordheader.hxx>
37 #include <filter/msfilter/escherex.hxx>
38 #include <filter/msfilter/msfilterdllapi.h>
39 #include <rtl/ustring.hxx>
40 #include <sal/types.h>
41 #include <svx/msdffdef.hxx>
42 #include <vcl/errcode.hxx>
43 #include <tools/gen.hxx>
44 #include <tools/ref.hxx>
45 #include <tools/solar.h>
46 #include <vcl/graph.hxx>
48 class Color;
49 class GDIMetaFile;
50 class SotStorage;
51 class SvStream;
52 class SdrObject;
53 class SdrOle2Obj;
54 namespace tools {
55 class Polygon;
57 class SdrModel;
58 class SwFlyFrameFormat;
60 struct SvxMSDffBLIPInfos;
61 struct SvxMSDffShapeInfo;
62 struct SvxMSDffShapeOrder;
64 class SvxMSDffManager;
65 class SfxItemSet;
66 struct DffObjData;
67 class SvGlobalName;
69 namespace com { namespace sun { namespace star {
70 namespace beans { class XPropertySet; }
71 namespace embed { class XEmbeddedObject; }
72 namespace embed { class XStorage; }
73 } } }
75 class MSFILTER_DLLPUBLIC SvxMSDffClientData
77 public:
78 virtual void NotifyFreeObj(SdrObject* pObj) = 0;
79 virtual ~SvxMSDffClientData() {}
82 class MSFILTER_DLLPUBLIC DffPropertyReader : public DffPropSet
84 const SvxMSDffManager& rManager;
85 std::unique_ptr<DffPropSet> pDefaultPropSet;
87 void ApplyCustomShapeTextAttributes( SfxItemSet& rSet ) const;
88 void CheckAndCorrectExcelTextRotation( SvStream& rIn, SfxItemSet& rSet, DffObjData const & rObjData ) const;
89 void ApplyCustomShapeGeometryAttributes( SvStream& rIn,
90 SfxItemSet& rSet,
91 const DffObjData& rObjData ) const;
92 void ApplyLineAttributes( SfxItemSet& rSet, const MSO_SPT eShapeType ) const; // #i28269#
93 void ApplyFillAttributes( SvStream& rIn, SfxItemSet& rSet, const DffObjData& rObjData ) const;
95 public:
96 sal_Int32 mnFix16Angle;
97 bool mbRotateGranientFillWithAngle;
99 explicit DffPropertyReader( const SvxMSDffManager& rManager );
100 ~DffPropertyReader();
102 DffPropertyReader& operator=( DffPropertyReader const & ) = delete; // MSVC2015 workaround
103 DffPropertyReader( DffPropertyReader const & ) = delete; // MSVC2015 workaround
105 static sal_Int32 Fix16ToAngle( sal_Int32 nAngle );
107 #ifdef DBG_CUSTOMSHAPE
108 void ReadPropSet( SvStream& rIn, SvxMSDffClientData* pClientData, sal_uInt32 nShapeType = 0 ) const;
109 #else
110 void ReadPropSet( SvStream& rIn, SvxMSDffClientData* pClientData ) const;
111 #endif
113 void SetDefaultPropSet( SvStream& rIn, sal_uInt32 nOffDgg ) const;
114 void ApplyAttributes( SvStream& rIn, SfxItemSet& rSet ) const;
115 void ApplyAttributes( SvStream& rIn, SfxItemSet& rSet, DffObjData const & rObjData ) const;
116 void ImportGradientColor( SfxItemSet& aSet, MSO_FillType eMSO_FillType, double dTrans, double dBackTrans ) const;
119 #define COL_DEFAULT ::Color( 0xFA, 0xFB, 0xFC )
121 typedef ::std::map< sal_Int32, SdrObject* > SvxMSDffShapeIdContainer;
123 #define SVEXT_PERSIST_STREAM "\002OlePres000"
125 /// the following will be sorted by the order of their appearance:
126 typedef std::vector<std::unique_ptr<SvxMSDffShapeOrder>> SvxMSDffShapeOrders;
128 struct MSFILTER_DLLPUBLIC CompareSvxMSDffShapeInfoById
130 bool operator()(std::shared_ptr<SvxMSDffShapeInfo> const& lhs,
131 std::shared_ptr<SvxMSDffShapeInfo> const& rhs) const;
133 struct CompareSvxMSDffShapeInfoByTxBxComp
135 bool operator()(std::shared_ptr<SvxMSDffShapeInfo> const& lhs,
136 std::shared_ptr<SvxMSDffShapeInfo> const& rhs) const;
139 // the following will be sorted explicitly:
140 typedef ::std::set< std::shared_ptr<SvxMSDffShapeInfo>,
141 CompareSvxMSDffShapeInfoById > SvxMSDffShapeInfos_ById;
142 typedef ::std::multiset< std::shared_ptr<SvxMSDffShapeInfo>,
143 CompareSvxMSDffShapeInfoByTxBxComp> SvxMSDffShapeInfos_ByTxBxComp;
145 #define SVXMSDFF_SETTINGS_CROP_BITMAPS 1
146 #define SVXMSDFF_SETTINGS_IMPORT_PPT 2
147 #define SVXMSDFF_SETTINGS_IMPORT_EXCEL 4
149 // for the CreateSdrOLEFromStorage we need the information, how we handle
150 // convert able OLE-Objects - this is stored in
151 #define OLE_MATHTYPE_2_STARMATH 0x0001
152 #define OLE_WINWORD_2_STARWRITER 0x0002
153 #define OLE_EXCEL_2_STARCALC 0x0004
154 #define OLE_POWERPOINT_2_STARIMPRESS 0x0008
156 struct SvxMSDffConnectorRule
158 sal_uInt32 nShapeA; ///< SPID of shape A
159 sal_uInt32 nShapeB; ///< SPID of shape B
160 sal_uInt32 nShapeC; ///< SPID of connector shape
161 sal_uInt32 ncptiA; ///< Connection site Index of shape A
162 sal_uInt32 ncptiB; ///< Connection site Index of shape B
163 ShapeFlag nSpFlagsA; ///< SpFlags of shape A (the original mirror flags
164 ///< must be known when solving the Solver Container)
165 ShapeFlag nSpFlagsB; ///< SpFlags of shape B
167 SdrObject* pAObj; ///< pPtr of object (corresponding to shape A)
168 SdrObject* pBObj; ///< pPtr of object (corresponding to shape B)
169 SdrObject* pCObj; ///< pPtr of connector object
171 SvxMSDffConnectorRule()
172 : nShapeA(0)
173 , nShapeB(0)
174 , nShapeC(0)
175 , ncptiA(0)
176 , ncptiB(0)
177 , nSpFlagsA( ShapeFlag::NONE )
178 , nSpFlagsB( ShapeFlag::NONE )
179 , pAObj( nullptr )
180 , pBObj( nullptr )
181 , pCObj( nullptr )
186 struct MSFILTER_DLLPUBLIC SvxMSDffSolverContainer
188 ::std::vector< std::unique_ptr<SvxMSDffConnectorRule> > aCList;
190 SvxMSDffSolverContainer();
191 ~SvxMSDffSolverContainer();
193 SvxMSDffSolverContainer& operator=( SvxMSDffSolverContainer const & ) = delete; // MSVC2015 workaround
194 SvxMSDffSolverContainer( SvxMSDffSolverContainer const & ) = delete; // MSVC2015 workaround
196 MSFILTER_DLLPUBLIC friend SvStream& ReadSvxMSDffSolverContainer( SvStream& rIn, SvxMSDffSolverContainer& rAtom );
199 struct FIDCL
201 sal_uInt32 dgid; ///< DG owning the SPIDs in this cluster
204 /// provided by SvxMSDffManager for each shape in a group
205 struct MSDffTxId
207 sal_uInt16 nTxBxS;
208 sal_uInt16 nSequence;
209 MSDffTxId()
210 : nTxBxS( 0 ), nSequence( 0 ) {}
211 MSDffTxId( const MSDffTxId& rCopy )
212 : nTxBxS( rCopy.nTxBxS ), nSequence( rCopy.nSequence ) {}
215 struct MSFILTER_DLLPUBLIC SvxMSDffImportRec
217 static const int RELTO_DEFAULT = 2;
219 SdrObject* pObj;
220 std::unique_ptr<tools::Polygon>
221 pWrapPolygon;
222 std::unique_ptr<char[]>
223 pClientAnchorBuffer;
224 sal_uInt32 nClientAnchorLen;
225 std::unique_ptr<char[]>
226 pClientDataBuffer;
227 sal_uInt32 nClientDataLen;
228 sal_uInt32 nXAlign;
229 boost::optional<sal_uInt32> nXRelTo;
230 sal_uInt32 nYAlign;
231 boost::optional<sal_uInt32> nYRelTo;
232 sal_uInt32 nLayoutInTableCell;
233 ShapeFlag nFlags;
234 sal_Int32 nDxTextLeft; ///< distance of text box from surrounding shape
235 sal_Int32 nDyTextTop;
236 sal_Int32 nDxTextRight;
237 sal_Int32 nDyTextBottom;
238 sal_Int32 nDxWrapDistLeft;
239 sal_Int32 nDyWrapDistTop;
240 sal_Int32 nDxWrapDistRight;
241 sal_Int32 nDyWrapDistBottom;
242 sal_Int32 nCropFromTop;
243 sal_Int32 nCropFromBottom;
244 sal_Int32 nCropFromLeft;
245 sal_Int32 nCropFromRight;
246 MSDffTxId aTextId; ///< identifier for text boxes
247 sal_uLong nNextShapeId; ///< for linked text boxes
248 sal_uLong nShapeId;
249 MSO_SPT eShapeType;
250 MSO_LineStyle eLineStyle; ///< border types
251 MSO_LineDashing eLineDashing;
252 bool bDrawHell :1;
253 bool bHidden :1;
254 bool bReplaceByFly :1;
255 bool bVFlip :1;
256 bool bHFlip :1;
257 bool bAutoWidth :1;
258 int relativeHorizontalWidth; ///< in 0.1% or -1 for none
259 bool isHorizontalRule;
261 SvxMSDffImportRec();
262 SvxMSDffImportRec(const SvxMSDffImportRec& rCopy);
263 ~SvxMSDffImportRec();
265 bool operator<( const SvxMSDffImportRec& rEntry ) const
266 { return nShapeId < rEntry.nShapeId; }
268 private:
269 SvxMSDffImportRec &operator=(const SvxMSDffImportRec&) = delete;
272 /** block of parameters for import/export for a single call of
273 ImportObjAtCurrentStreamPos() */
274 class MSFILTER_DLLPUBLIC SvxMSDffImportData final : public SvxMSDffClientData
276 private:
277 /** list of all SvxMSDffImportRec instances of/for a group */
278 typedef std::set<std::unique_ptr<SvxMSDffImportRec>,
279 comphelper::UniquePtrValueLess<SvxMSDffImportRec>> MSDffImportRecords;
280 MSDffImportRecords m_Records; ///< Shape pointer, Shape ids and private data
281 std::map<const SdrObject*, SvxMSDffImportRec*> m_ObjToRecMap;
282 public:
283 tools::Rectangle aParentRect;///< Rectangle of the surrounding groups,
284 ///< which might have been provided externally
286 explicit SvxMSDffImportData(const tools::Rectangle& rParentRect);
287 SvxMSDffImportData& operator=( SvxMSDffImportData const & ) = delete; // MSVC2015 workaround
288 SvxMSDffImportData( SvxMSDffImportData const & ) = delete; // MSVC2015 workaround
289 virtual ~SvxMSDffImportData() override;
290 bool empty() const { return m_Records.empty(); }
291 void insert(std::unique_ptr<SvxMSDffImportRec> pImpRec);
292 void unmap(const SdrObject* pObj) { m_ObjToRecMap.erase(pObj); }
293 size_t size() const { return m_Records.size(); }
294 SvxMSDffImportRec* find(const SdrObject* pObj);
295 MSDffImportRecords::const_iterator begin() const { return m_Records.begin(); }
296 MSDffImportRecords::const_iterator end() const { return m_Records.end(); }
297 virtual void NotifyFreeObj(SdrObject* pObj) override;
300 struct DffObjData
302 const DffRecordHeader& rSpHd;
304 tools::Rectangle aBoundRect;
305 tools::Rectangle aChildAnchor;
307 sal_uInt32 nShapeId;
308 ShapeFlag nSpFlags;
309 MSO_SPT eShapeType;
311 bool bShapeType : 1;
312 bool bClientAnchor : 1;
313 bool bClientData : 1;
314 bool bChildAnchor : 1;
315 bool bOpt : 1;
316 bool bOpt2 : 1;
317 bool bRotateTextWithShape : 1;
318 bool bPageAnchor;
319 int nCalledByGroup;
321 DffObjData( const DffRecordHeader& rObjHd,
322 const tools::Rectangle& rBoundRect,
323 int nClByGroup ) :
324 rSpHd( rObjHd ),
325 aBoundRect( rBoundRect ),
326 nShapeId( 0 ),
327 nSpFlags( ShapeFlag::NONE ),
328 eShapeType( mso_sptNil ),
329 bShapeType( false ),
330 bClientAnchor( false ),
331 bClientData( false ),
332 bChildAnchor( false ),
333 bOpt( false ),
334 bOpt2( false ),
335 bRotateTextWithShape( true ),
336 bPageAnchor( true ),
337 nCalledByGroup( nClByGroup ){}
339 // Clone a DffObjData _o_ by replacing its rSpHd with a shared_ptr to another one
340 DffObjData( const std::shared_ptr<DffRecordHeader>& rObjHd, const DffObjData& o) :
341 rSpHd( *rObjHd ),
342 aBoundRect( o.aBoundRect ),
343 nShapeId( o.nShapeId ),
344 nSpFlags( o.nSpFlags ),
345 eShapeType( o.eShapeType ),
346 bShapeType( o.bShapeType ),
347 bClientAnchor( o.bClientAnchor ),
348 bClientData( o.bClientData ),
349 bChildAnchor( o.bChildAnchor ),
350 bOpt( o.bOpt ),
351 bOpt2( o.bOpt2 ),
352 bRotateTextWithShape( o.bRotateTextWithShape ),
353 bPageAnchor( o.bPageAnchor ),
354 nCalledByGroup( o.nCalledByGroup ){}
357 #define DFF_RECORD_MANAGER_BUF_SIZE 64
359 struct DffRecordList
361 sal_uInt32 nCount;
362 sal_uInt32 nCurrent;
363 DffRecordList* pPrev;
364 std::unique_ptr<DffRecordList>
365 pNext;
367 DffRecordHeader mHd[ DFF_RECORD_MANAGER_BUF_SIZE ];
369 explicit DffRecordList( DffRecordList* pList );
370 ~DffRecordList();
373 enum DffSeekToContentMode
375 SEEK_FROM_BEGINNING,
376 SEEK_FROM_CURRENT,
377 SEEK_FROM_CURRENT_AND_RESTART
380 class MSFILTER_DLLPUBLIC DffRecordManager : public DffRecordList
382 public:
383 DffRecordList* pCList;
385 void Clear();
386 void Consume( SvStream& rIn,
387 sal_uInt32 nStOfs = 0 );
389 bool SeekToContent( SvStream& rIn,
390 sal_uInt16 nRecType,
391 DffSeekToContentMode eMode = SEEK_FROM_BEGINNING );
392 DffRecordHeader* GetRecordHeader( sal_uInt16 nRecType,
393 DffSeekToContentMode eMode = SEEK_FROM_BEGINNING );
395 DffRecordManager();
396 explicit DffRecordManager( SvStream& rIn );
398 DffRecordHeader* Current();
399 DffRecordHeader* First();
400 DffRecordHeader* Next();
401 DffRecordHeader* Prev();
402 DffRecordHeader* Last();
405 /** abstract base class for Escher imports
407 Purpose: access to objects in Drawing File Format
409 Note: The method ProcessUserDefinedRecord() _has_ to be implemented in the
410 inheriting class(es) that is/are eventually used for PowerPoint, Word,
411 or Excel importing.
413 Status: Currently only access to BLIPs (will be extended later)
415 class MSFILTER_DLLPUBLIC SvxMSDffManager : public DffPropertyReader
417 std::unique_ptr<SvxMSDffBLIPInfos> m_pBLIPInfos;
418 std::unique_ptr<SvxMSDffShapeInfos_ByTxBxComp> m_xShapeInfosByTxBxComp;
419 std::unique_ptr<SvxMSDffShapeInfos_ById> m_xShapeInfosById;
420 SvxMSDffShapeOrders m_aShapeOrders;
421 sal_uInt32 nOffsDgg;
422 sal_uInt16 nBLIPCount;
423 ShapeFlag nGroupShapeFlags;
425 void CheckTxBxStoryChain();
426 void GetFidclData(sal_uInt32 nOffsDgg);
428 protected:
429 typedef std::map<sal_uInt32, sal_uInt32> OffsetMap;
431 OUString maBaseURL;
432 sal_uInt32 mnIdClusters; // while only knowing the shapeid
433 std::vector<FIDCL> maFidcls;
434 OffsetMap maDgOffsetTable; ///< array of fileoffsets
436 /** When importing Excel files, cell anchor computations for non-page-anchored
437 groups must be done after all nested groups have been processed; for each open
438 group, the pending data is stored here. The storage also holds a shared_ptr to
439 the DffObjData ow DffRecordHeader to avoid it going out of scope except when needed
441 std::vector< std::pair<DffObjData, std::shared_ptr<DffRecordHeader> > > maPendingGroupData;
443 friend class DffPropertyReader;
445 SvStream& rStCtrl;
446 SvStream* pStData;
447 SvStream* pStData2;
448 SdrModel* pSdrModel;
450 long nMapMul;
451 long nMapDiv;
452 long nMapXOfs;
453 long nMapYOfs;
454 long nEmuMul;
455 long nEmuDiv;
456 long nPntMul;
457 long nPntDiv;
458 bool bNeedMap;
459 sal_uInt32 nSvxMSDffSettings;
460 sal_uInt32 nSvxMSDffOLEConvFlags;
462 /** stores a reference to an imported SdrObject
463 with its shape id if it has one */
464 SvxMSDffShapeIdContainer maShapeIdContainer;
466 void GetCtrlData(sal_uInt32 nOffsDgg);
467 void GetDrawingGroupContainerData( SvStream& rSt,
468 sal_uLong nLenDgg );
469 // Add internal drawing container id as parameter to the sub methods of
470 // reading the control information about the drawing objects.
471 // The drawing container id is used to distinguish the text ids of drawing
472 // objects in different drawing containers.
473 void GetDrawingContainerData( SvStream& rSt,
474 sal_uLong nLenDg,
475 sal_uInt16 nDrawingContainerId );
476 bool GetShapeGroupContainerData( SvStream& rSt,
477 sal_uLong nLenShapeGroupCont,
478 bool bPatriarch,
479 sal_uInt16 nDrawingContainerId );
480 bool GetShapeContainerData( SvStream& rSt,
481 sal_uLong nLenShapeCont,
482 sal_uLong nPosGroup,
483 sal_uInt16 nDrawingContainerId );
485 SdrObject* ImportGraphic( SvStream&, SfxItemSet&, const DffObjData& );
486 // #i32596# - pass <nCalledByGroup> to method
487 // Needed in Writer's Microsoft Word import to avoid import of OLE objects
488 // inside groups. Instead a graphic object is created.
489 virtual SdrObject* ImportOLE( sal_uInt32 nOLEId,
490 const Graphic& rGraf,
491 const tools::Rectangle& rBoundRect,
492 const tools::Rectangle& rVisArea,
493 const int _nCalledByGroup ) const;
494 static css::uno::Reference < css::embed::XEmbeddedObject > CheckForConvertToSOObj(
495 sal_uInt32 nConvertFlags, SotStorage& rSrcStg,
496 const css::uno::Reference < css::embed::XStorage >& xDestStg,
497 const Graphic& rGrf,
498 const tools::Rectangle& rVisArea,
499 OUString const& rBaseURL);
501 // the following methods need to be overridden for Excel imports
502 static void ProcessClientAnchor( SvStream& rStData,
503 sal_uInt32 nDatLen,
504 std::unique_ptr<char[]>& rpBuff,
505 sal_uInt32& rBuffLen );
506 virtual void ProcessClientAnchor2( SvStream& rStData,
507 DffRecordHeader& rHd,
508 DffObjData& );
509 static void ProcessClientData( SvStream& rStData,
510 sal_uInt32 nDatLen,
511 std::unique_ptr<char[]>& rpBuff,
512 sal_uInt32& rBuffLen );
513 virtual SdrObject* ProcessObj( SvStream& rSt,
514 DffObjData& rData,
515 SvxMSDffClientData& rClientData,
516 tools::Rectangle& rTextRect,
517 SdrObject* pObj);
518 void NotifyFreeObj(SvxMSDffClientData& rData, SdrObject* pObj);
519 void FreeObj(SvxMSDffClientData& rData, SdrObject* pObj);
522 /** Object finalization, used by the Excel filter to correctly
523 compute the object anchoring after nested objects have been imported.
525 virtual SdrObject* FinalizeObj(DffObjData& rData,
526 SdrObject* pObj);
528 virtual bool GetColorFromPalette(sal_uInt16 nNum, Color& rColor) const;
530 // Fontwork objects use a new implementation of ReadObjText because the old
531 // one does not properly import multiple paragraphs.
532 static void ReadObjText( const OUString& rText, SdrObject* pObj );
534 // the following method needs to be overridden for the import of OLE objects
535 virtual bool GetOLEStorageName( sal_uInt32 nOLEId,
536 OUString& rStorageName,
537 tools::SvRef<SotStorage>& rSrcStorage,
538 css::uno::Reference < css::embed::XStorage >& xDestStg
539 ) const;
541 /** Prevent that (rounded) rectangles with wrapped text will always be
542 converted into SdrRectObj( OBJ_TEXT ).
544 @return true means "conversion".
546 virtual bool ShapeHasText(sal_uLong nShapeId, sal_uLong nFilePos) const;
548 public:
549 std::unique_ptr<DffPropertyReader> pSecPropSet;
550 std::unordered_map<sal_uInt32, Graphic> aEscherBlipCache;
552 DffRecordManager maShapeRecords;
553 Color mnDefaultColor;
555 bool mbSkipImages;
557 Color MSO_TEXT_CLR_ToColor( sal_uInt32 nColorCode ) const;
558 Color MSO_CLR_ToColor( sal_uInt32 nColorCode,
559 sal_uInt16 nContextProperty = DFF_Prop_lineColor ) const;
560 virtual bool SeekToShape( SvStream& rSt,
561 SvxMSDffClientData* pClientData,
562 sal_uInt32 nId ) const;
563 static bool SeekToRec( SvStream& rSt,
564 sal_uInt16 nRecId,
565 sal_uLong nMaxFilePos,
566 DffRecordHeader* pRecHd = nullptr,
567 sal_uLong nSkipCount = 0 );
568 bool SeekToRec2( sal_uInt16 nRecId1,
569 sal_uInt16 nRecId2,
570 sal_uLong nMaxFilePos ) const;
572 static OUString MSDFFReadZString( SvStream& rIn,
573 sal_uInt32 nMaxLen,
574 bool bUniCode);
576 [[nodiscard]] static bool ReadCommonRecordHeader( SvStream& rSt,
577 sal_uInt8& rVer,
578 sal_uInt16& rInst,
579 sal_uInt16& rFbt,
580 sal_uInt32& rLength);
582 // TODO: provide proper documentation here
583 /** constructor
585 sets nBLIPCount
587 @param rStCtrl Management stream with containers, FBSE
588 objects and shapes (mandatory; stream needs
589 to be open already)
590 @param rBaseURL ???
591 @param nOffsDgg offset in rStrCtrl; beginning of the drawing
592 group container
593 @param pStData data stream in that the BLIPs are stored (if
594 NULL it is assumed that all BLIPs are also in
595 the rStCtrl; stream needs to be open already)
596 @param pSdrModel_ ??? (can be empty during Ctor call but needs
597 to be set via SetModel() later in that case!)
598 @param nApplicationScale ???
599 @param mnDefaultColor_ ???
600 @param nDefaultFontHeight_ ???
601 @param pStData2_ ???
602 @param bSkipImages skipping images for text extraction/indexing
604 SvxMSDffManager( SvStream& rStCtrl,
605 const OUString& rBaseURL,
606 sal_uInt32 nOffsDgg,
607 SvStream* pStData,
608 SdrModel* pSdrModel_,
609 long nApplicationScale,
610 Color mnDefaultColor_,
611 SvStream* pStData2_ = nullptr,
612 bool bSkipImages = false );
614 // in PPT the parameters DGGContainerOffset and PicStream are provided by an
615 // init method
616 SvxMSDffManager( SvStream& rStCtrl, const OUString& rBaseURL );
617 void InitSvxMSDffManager( sal_uInt32 nOffsDgg_,
618 SvStream* pStData_,
619 sal_uInt32 nSvxMSDffOLEConvFlags);
620 void SetDgContainer( SvStream& rSt );
622 virtual ~SvxMSDffManager();
624 sal_uInt32 GetSvxMSDffSettings() const { return nSvxMSDffSettings; };
625 void SetSvxMSDffSettings( sal_uInt32 nSettings ) { nSvxMSDffSettings = nSettings; };
627 static bool MakeContentStream( SotStorage * pStor, const GDIMetaFile & );
628 static void ReadObjText( SvStream& rStream, SdrObject* pObj );
629 static bool ConvertToOle2( SvStream& rStm,
630 sal_uInt32 nLen,
631 const GDIMetaFile*,
632 const tools::SvRef<SotStorage> & rDest );
634 void SetModel(SdrModel* pModel, long nApplicationScale);
635 SdrModel* GetModel() const { return pSdrModel; }
636 void Scale(sal_Int32& rVal) const;
637 void Scale(Point& rPos) const;
638 void Scale(Size& rSiz) const;
639 void ScaleEmu(sal_Int32& rVal) const;
640 sal_uInt32 ScalePt( sal_uInt32 nPt ) const;
641 sal_Int32 ScalePoint( sal_Int32 nVal ) const;
643 // TODO: provide proper documentation here
644 /** Request for a specific BLIP.
646 @param[in] nIdx number of the requested BLIP (mandatory)
647 @param[out] rData already converted data (insert directly as graphics
648 into our documents)
649 @param pVisArea ???
651 @return true if successful, false otherwise
653 bool GetBLIP( sal_uLong nIdx, Graphic& rData, tools::Rectangle* pVisArea = nullptr );
655 // TODO: provide proper documentation here
656 /** read a BLIP out of an already positioned stream
658 @param[in] rBLIPStream already positioned stream (mandatory)
659 @param[out] rData already converted data (insert directly as
660 graphics into our documents)
661 @param pVisArea ???
663 @return true if successful, false otherwise
665 static bool GetBLIPDirect(SvStream& rBLIPStream, Graphic& rData, tools::Rectangle* pVisArea = nullptr );
667 bool GetShape(sal_uLong nId, SdrObject*& rpData, SvxMSDffImportData& rData);
669 SdrObject* ImportObj( SvStream& rSt,
670 SvxMSDffClientData& rData,
671 tools::Rectangle& rClientRect,
672 const tools::Rectangle& rGlobalChildRect,
673 int nCalledByGroup,
674 sal_Int32* pShapeId);
675 SdrObject* ImportGroup( const DffRecordHeader& rHd,
676 SvStream& rSt,
677 SvxMSDffClientData& rData,
678 tools::Rectangle& rClientRect,
679 const tools::Rectangle& rGlobalChildRect,
680 int nCalledByGroup,
681 sal_Int32* pShapeId );
682 SdrObject* ImportShape( const DffRecordHeader& rHd,
683 SvStream& rSt,
684 SvxMSDffClientData& rData,
685 tools::Rectangle& rClientRect,
686 const tools::Rectangle& rGlobalChildRect,
687 int nCalledByGroup,
688 sal_Int32* pShapeId);
690 tools::Rectangle GetGlobalChildAnchor( const DffRecordHeader& rHd,
691 SvStream& rSt,
692 tools::Rectangle& aClientRect );
693 void GetGroupAnchors( const DffRecordHeader& rHd,
694 SvStream& rSt,
695 tools::Rectangle& rGroupClientAnchor,
696 tools::Rectangle& rGroupChildAnchor,
697 const tools::Rectangle& rClientRect,
698 const tools::Rectangle& rGlobalChildRect );
700 const SvxMSDffShapeInfos_ById* GetShapeInfos() const
701 { return m_xShapeInfosById.get(); }
703 const SvxMSDffShapeOrders* GetShapeOrders() const
704 { return &m_aShapeOrders; }
706 void StoreShapeOrder(sal_uLong nId,
707 sal_uLong nTxBx,
708 SdrObject* pObject,
709 SwFlyFrameFormat* pFly = nullptr) const;
711 void ExchangeInShapeOrder(SdrObject const * pOldObject,
712 sal_uLong nTxBx,
713 SdrObject* pObject) const;
715 void RemoveFromShapeOrder( SdrObject const * pObject ) const;
717 static SdrOle2Obj* CreateSdrOLEFromStorage(
718 SdrModel& rSdrModel,
719 const OUString& rStorageName,
720 tools::SvRef<SotStorage> const & rSrcStorage,
721 const css::uno::Reference < css::embed::XStorage >& xDestStg,
722 const Graphic& rGraf,
723 const tools::Rectangle& rBoundRect,
724 const tools::Rectangle& rVisArea,
725 SvStream* pDataStrrm,
726 ErrCode& rError,
727 sal_uInt32 nConvertFlags,
728 sal_Int64 nAspect,
729 OUString const& rBaseURL);
731 /** Create connections between shapes.
732 This method should be called after a page is imported.
734 @param rSolver contains necessary data that is collected during the
735 import of each shape
737 static void SolveSolver( const SvxMSDffSolverContainer& rSolver );
739 static bool SetPropValue(
740 const css::uno::Any& rAny,
741 const css::uno::Reference< css::beans::XPropertySet > & rXPropSet,
742 const OUString& rPropertyName
745 /// Determines an ODF filter name (if there is one) for aGlobName.
746 static OUString GetFilterNameFromClassID(const SvGlobalName& aGlobName);
747 /// Extracts ODF data from rSrcStg.
748 static void ExtractOwnStream(SotStorage& rSrcStg, SvMemoryStream& rMemStream);
750 void insertShapeId( sal_Int32 nShapeId, SdrObject* pShape );
751 void removeShapeId( SdrObject const * pShape );
752 SdrObject* getShapeForId( sal_Int32 nShapeId );
755 struct SvxMSDffShapeInfo
757 sal_uInt32 nShapeId; ///< shape id, used in PLCF SPA and in mso_fbtSp (FSP)
758 sal_uLong nFilePos; ///< offset of the shape in control stream for
759 ///< potential later access to it
760 sal_uInt32 nTxBxComp;
762 bool bReplaceByFly :1; ///< shape can be replaced by a frame in Writer
764 explicit SvxMSDffShapeInfo(sal_uLong nFPos, sal_uInt32 nId=0, // sal_uLong nBIdx=0,
765 sal_uInt16 nSeqId=0, sal_uInt16 nBoxId=0):
766 nShapeId( nId ),
767 nFilePos( nFPos ),
768 nTxBxComp( (nSeqId << 16) + nBoxId )
770 bReplaceByFly = false;
772 SvxMSDffShapeInfo(const SvxMSDffShapeInfo& rInfo):
773 nShapeId( rInfo.nShapeId ),
774 nFilePos( rInfo.nFilePos ),
775 nTxBxComp( rInfo.nTxBxComp ),
776 bReplaceByFly( rInfo.bReplaceByFly )
782 struct SvxMSDffShapeOrder
784 sal_uLong nShapeId; ///< shape id used in PLCF SPA and in mso_fbtSp (FSP)
785 sal_uLong nTxBxComp; ///< chain or box number in the Text-Box-Story (or NULL)
786 SwFlyFrameFormat* pFly; ///< format of frame that was inserted as a replacement
787 ///< for a Sdr-Text object in Writer - needed for
788 ///< chaining!
789 SdrObject* pObj; ///< pointer to the draw object (or NULL if not used)
791 // Approach: In the Ctor of SvxMSDffManager only the shape ids are stored in
792 // the shape order array. The Text-Box number and the object
793 // pointer are only stored if the shape is really imported.
794 explicit SvxMSDffShapeOrder( sal_uLong nId ):
795 nShapeId( nId ), nTxBxComp( 0 ), pFly( nullptr ), pObj( nullptr ){}
797 bool operator<( const SvxMSDffShapeOrder& rEntry ) const
798 { return (nTxBxComp < rEntry.nTxBxComp); }
801 // the following will be sorted explicitly:
802 struct CompareSvxMSDffShapeTxBxSort
804 bool operator()( SvxMSDffShapeOrder* const& lhs, SvxMSDffShapeOrder* const& rhs ) const { return (*lhs)<(*rhs); }
806 class MSFILTER_DLLPUBLIC SvxMSDffShapeTxBxSort : public std::set<SvxMSDffShapeOrder*,CompareSvxMSDffShapeTxBxSort> {};
809 #endif
811 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */