tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / include / filter / msfilter / msdffimp.hxx
blob3b51d5b714245aca3bc970c9324756533a983bf6
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 <optional>
27 #include <set>
28 #include <utility>
29 #include <vector>
30 #include <unordered_map>
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 <rtl/ref.hxx>
41 #include <sal/types.h>
42 #include <svx/msdffdef.hxx>
43 #include <comphelper/errcode.hxx>
44 #include <tools/degree.hxx>
45 #include <tools/gen.hxx>
46 #include <tools/ref.hxx>
47 #include <tools/solar.h>
48 #include <tools/poly.hxx>
49 #include <vcl/graph.hxx>
51 class Color;
52 class GDIMetaFile;
53 class SotStorage;
54 class SvStream;
55 class SdrObject;
56 class SdrOle2Obj;
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::sun::star {
70 namespace beans { class XPropertySet; }
71 namespace embed { class XEmbeddedObject; }
72 namespace embed { class XStorage; }
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 Degree100 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 Degree100 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, sal_uInt32 eMSO_FillType, double dTrans, double dBackTrans ) const;
119 #define COL_DEFAULT ::Color( 0xFA, 0xFB, 0xFC )
121 typedef ::std::map< sal_Int32, SdrObject* > SvxMSDffShapeIdContainer;
123 inline constexpr OUString SVEXT_PERSIST_STREAM = u"\002OlePres000"_ustr;
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 rtl::Reference<SdrObject> pObj;
220 std::optional<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 std::optional<sal_uInt32> nXRelTo;
230 sal_uInt32 nYAlign;
231 std::optional<sal_uInt32> nYRelTo;
232 sal_uInt32 nGroupShapeBooleanProperties;
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 size_t size() const { return m_Records.size(); }
293 SvxMSDffImportRec* find(const SdrObject* pObj);
294 MSDffImportRecords::const_iterator begin() const { return m_Records.begin(); }
295 MSDffImportRecords::const_iterator end() const { return m_Records.end(); }
296 virtual void NotifyFreeObj(SdrObject* pObj) override;
299 struct DffObjData
301 const DffRecordHeader& rSpHd;
303 tools::Rectangle aBoundRect;
304 tools::Rectangle aChildAnchor;
306 sal_uInt32 nShapeId;
307 ShapeFlag nSpFlags;
308 MSO_SPT eShapeType;
310 bool bShapeType : 1;
311 bool bClientAnchor : 1;
312 bool bClientData : 1;
313 bool bChildAnchor : 1;
314 bool bOpt : 1;
315 bool bOpt2 : 1;
316 bool bRotateTextWithShape : 1;
317 bool bPageAnchor;
318 int nCalledByGroup;
320 DffObjData( const DffRecordHeader& rObjHd,
321 const tools::Rectangle& rBoundRect,
322 int nClByGroup ) :
323 rSpHd( rObjHd ),
324 aBoundRect( rBoundRect ),
325 nShapeId( 0 ),
326 nSpFlags( ShapeFlag::NONE ),
327 eShapeType( mso_sptNil ),
328 bShapeType( false ),
329 bClientAnchor( false ),
330 bClientData( false ),
331 bChildAnchor( false ),
332 bOpt( false ),
333 bOpt2( false ),
334 bRotateTextWithShape( true ),
335 bPageAnchor( true ),
336 nCalledByGroup( nClByGroup ){}
338 // Clone a DffObjData _o_ by replacing its rSpHd with a shared_ptr to another one
339 DffObjData( const std::shared_ptr<DffRecordHeader>& rObjHd, const DffObjData& o) :
340 rSpHd( *rObjHd ),
341 aBoundRect( o.aBoundRect ),
342 nShapeId( o.nShapeId ),
343 nSpFlags( o.nSpFlags ),
344 eShapeType( o.eShapeType ),
345 bShapeType( o.bShapeType ),
346 bClientAnchor( o.bClientAnchor ),
347 bClientData( o.bClientData ),
348 bChildAnchor( o.bChildAnchor ),
349 bOpt( o.bOpt ),
350 bOpt2( o.bOpt2 ),
351 bRotateTextWithShape( o.bRotateTextWithShape ),
352 bPageAnchor( o.bPageAnchor ),
353 nCalledByGroup( o.nCalledByGroup ){}
356 #define DFF_RECORD_MANAGER_BUF_SIZE 64
358 struct DffRecordList
360 sal_uInt32 nCount;
361 sal_uInt32 nCurrent;
362 DffRecordList* pPrev;
363 std::unique_ptr<DffRecordList>
364 pNext;
366 DffRecordHeader mHd[ DFF_RECORD_MANAGER_BUF_SIZE ];
368 explicit DffRecordList( DffRecordList* pList );
369 ~DffRecordList();
372 enum DffSeekToContentMode
374 SEEK_FROM_BEGINNING,
375 SEEK_FROM_CURRENT,
376 SEEK_FROM_CURRENT_AND_RESTART
379 class MSFILTER_DLLPUBLIC DffRecordManager : public DffRecordList
381 public:
382 DffRecordList* pCList;
384 void Clear();
385 void Consume( SvStream& rIn,
386 sal_uInt32 nStOfs = 0 );
388 bool SeekToContent( SvStream& rIn,
389 sal_uInt16 nRecType,
390 DffSeekToContentMode eMode = SEEK_FROM_BEGINNING );
391 DffRecordHeader* GetRecordHeader( sal_uInt16 nRecType,
392 DffSeekToContentMode eMode = SEEK_FROM_BEGINNING );
394 DffRecordManager();
395 explicit DffRecordManager( SvStream& rIn );
397 DffRecordHeader* Current();
398 DffRecordHeader* First();
399 DffRecordHeader* Next();
400 DffRecordHeader* Prev();
401 DffRecordHeader* Last();
404 /** abstract base class for Escher imports
406 Purpose: access to objects in Drawing File Format
408 Note: The method ProcessUserDefinedRecord() _has_ to be implemented in the
409 inheriting class(es) that is/are eventually used for PowerPoint, Word,
410 or Excel importing.
412 Status: Currently only access to BLIPs (will be extended later)
414 class MSFILTER_DLLPUBLIC SvxMSDffManager : public DffPropertyReader
416 std::unique_ptr<SvxMSDffBLIPInfos> m_pBLIPInfos;
417 std::unique_ptr<SvxMSDffShapeInfos_ByTxBxComp> m_xShapeInfosByTxBxComp;
418 std::unique_ptr<SvxMSDffShapeInfos_ById> m_xShapeInfosById;
419 SvxMSDffShapeOrders m_aShapeOrders;
420 sal_uInt32 nOffsDgg;
421 sal_uInt16 nBLIPCount;
422 ShapeFlag nGroupShapeFlags;
424 void CheckTxBxStoryChain();
425 void GetFidclData(sal_uInt32 nOffsDgg);
427 protected:
428 typedef std::map<sal_uInt32, sal_uInt64> OffsetMap;
430 OUString maBaseURL;
431 sal_uInt32 mnIdClusters; // while only knowing the shapeid
432 std::vector<FIDCL> maFidcls;
433 OffsetMap maDgOffsetTable; ///< array of fileoffsets
435 /** When importing Excel files, cell anchor computations for non-page-anchored
436 groups must be done after all nested groups have been processed; for each open
437 group, the pending data is stored here. The storage also holds a shared_ptr to
438 the DffObjData ow DffRecordHeader to avoid it going out of scope except when needed
440 std::vector< std::pair<DffObjData, std::shared_ptr<DffRecordHeader> > > maPendingGroupData;
442 friend class DffPropertyReader;
444 SvStream& rStCtrl;
445 SvStream* pStData;
446 SvStream* pStData2;
447 SdrModel* pSdrModel;
449 tools::Long nMapMul;
450 tools::Long nMapDiv;
451 tools::Long nMapXOfs;
452 tools::Long nMapYOfs;
453 tools::Long nEmuMul;
454 tools::Long nEmuDiv;
455 tools::Long nPntMul;
456 tools::Long nPntDiv;
457 bool bNeedMap;
458 sal_Int32 nMinAllowedVal;
459 sal_Int32 nMaxAllowedVal;
460 sal_uInt32 nSvxMSDffSettings;
461 sal_uInt32 nSvxMSDffOLEConvFlags;
463 /** stores a reference to an imported SdrObject
464 with its shape id if it has one */
465 SvxMSDffShapeIdContainer maShapeIdContainer;
467 void GetCtrlData(sal_uInt32 nOffsDgg);
468 void GetDrawingGroupContainerData( SvStream& rSt,
469 sal_uInt32 nLenDgg );
470 // Add internal drawing container id as parameter to the sub methods of
471 // reading the control information about the drawing objects.
472 // The drawing container id is used to distinguish the text ids of drawing
473 // objects in different drawing containers.
474 void GetDrawingContainerData( SvStream& rSt,
475 sal_uInt32 nLenDg,
476 sal_uInt16 nDrawingContainerId );
477 bool GetShapeGroupContainerData( SvStream& rSt,
478 sal_uInt32 nLenShapeGroupCont,
479 bool bPatriarch,
480 sal_uInt16 nDrawingContainerId );
481 bool GetShapeContainerData( SvStream& rSt,
482 sal_uInt32 nLenShapeCont,
483 sal_uInt64 nPosGroup,
484 sal_uInt16 nDrawingContainerId );
486 rtl::Reference<SdrObject> ImportGraphic( SvStream&, SfxItemSet&, const DffObjData& );
487 // #i32596# - pass <nCalledByGroup> to method
488 // Needed in Writer's Microsoft Word import to avoid import of OLE objects
489 // inside groups. Instead a graphic object is created.
490 virtual rtl::Reference<SdrObject> ImportOLE( sal_uInt32 nOLEId,
491 const Graphic& rGraf,
492 const tools::Rectangle& rBoundRect,
493 const tools::Rectangle& rVisArea,
494 const int _nCalledByGroup ) const;
495 static css::uno::Reference < css::embed::XEmbeddedObject > CheckForConvertToSOObj(
496 sal_uInt32 nConvertFlags, SotStorage& rSrcStg,
497 const css::uno::Reference < css::embed::XStorage >& xDestStg,
498 const Graphic& rGrf,
499 const tools::Rectangle& rVisArea,
500 OUString const& rBaseURL);
502 // the following methods need to be overridden for Excel imports
503 static void ProcessClientAnchor( SvStream& rStData,
504 sal_uInt32 nDatLen,
505 std::unique_ptr<char[]>& rpBuff,
506 sal_uInt32& rBuffLen );
507 virtual void ProcessClientAnchor2( SvStream& rStData,
508 DffRecordHeader& rHd,
509 DffObjData& );
510 static void ProcessClientData( SvStream& rStData,
511 sal_uInt32 nDatLen,
512 std::unique_ptr<char[]>& rpBuff,
513 sal_uInt32& rBuffLen );
514 virtual rtl::Reference<SdrObject> ProcessObj( SvStream& rSt,
515 DffObjData& rData,
516 SvxMSDffClientData& rClientData,
517 tools::Rectangle& rTextRect,
518 SdrObject* pObj);
519 void NotifyFreeObj(SvxMSDffClientData& rData, SdrObject* pObj);
520 void FreeObj(SvxMSDffClientData& rData, SdrObject* pObj);
523 /** Object finalization, used by the Excel filter to correctly
524 compute the object anchoring after nested objects have been imported.
526 virtual SdrObject* FinalizeObj(DffObjData& rData,
527 SdrObject* pObj);
529 virtual bool GetColorFromPalette(sal_uInt16 nNum, Color& rColor) const;
531 // Fontwork objects use a new implementation of ReadObjText because the old
532 // one does not properly import multiple paragraphs.
533 static void ReadObjText( const OUString& rText, SdrObject* pObj );
535 // the following method needs to be overridden for the import of OLE objects
536 virtual bool GetOLEStorageName( sal_uInt32 nOLEId,
537 OUString& rStorageName,
538 rtl::Reference<SotStorage>& rSrcStorage,
539 css::uno::Reference < css::embed::XStorage >& xDestStg
540 ) const;
542 /** Prevent that (rounded) rectangles with wrapped text will always be
543 converted into SdrRectObj( SdrObjKind::Text ).
545 @return true means "conversion".
547 virtual bool ShapeHasText(sal_uLong nShapeId, sal_uLong nFilePos) const;
549 public:
550 std::unique_ptr<DffPropertyReader> pSecPropSet;
551 std::unordered_map<sal_uInt32, Graphic> aEscherBlipCache;
553 DffRecordManager maShapeRecords;
554 Color mnDefaultColor;
556 bool mbSkipImages;
558 Color MSO_TEXT_CLR_ToColor( sal_uInt32 nColorCode ) const;
559 Color MSO_CLR_ToColor( sal_uInt32 nColorCode,
560 sal_uInt16 nContextProperty = DFF_Prop_lineColor ) const;
561 virtual bool SeekToShape( SvStream& rSt,
562 SvxMSDffClientData* pClientData,
563 sal_uInt32 nId ) const;
564 static bool SeekToRec( SvStream& rSt,
565 sal_uInt16 nRecId,
566 sal_uLong nMaxFilePos,
567 DffRecordHeader* pRecHd = nullptr,
568 sal_uLong nSkipCount = 0 );
569 bool SeekToRec2( sal_uInt16 nRecId1,
570 sal_uInt16 nRecId2,
571 sal_uLong nMaxFilePos ) const;
573 static OUString MSDFFReadZString( SvStream& rIn,
574 sal_uInt32 nMaxLen,
575 bool bUniCode);
577 [[nodiscard]] static bool ReadCommonRecordHeader( SvStream& rSt,
578 sal_uInt8& rVer,
579 sal_uInt16& rInst,
580 sal_uInt16& rFbt,
581 sal_uInt32& rLength);
583 // TODO: provide proper documentation here
584 /** constructor
586 sets nBLIPCount
588 @param rStCtrl Management stream with containers, FBSE
589 objects and shapes (mandatory; stream needs
590 to be open already)
591 @param rBaseURL ???
592 @param nOffsDgg offset in rStrCtrl; beginning of the drawing
593 group container
594 @param pStData data stream in that the BLIPs are stored (if
595 NULL it is assumed that all BLIPs are also in
596 the rStCtrl; stream needs to be open already)
597 @param pSdrModel_ ??? (can be empty during Ctor call but needs
598 to be set via SetModel() later in that case!)
599 @param nApplicationScale ???
600 @param mnDefaultColor_ ???
601 @param nDefaultFontHeight_ ???
602 @param pStData2_ ???
603 @param bSkipImages skipping images for text extraction/indexing
605 SvxMSDffManager( SvStream& rStCtrl,
606 OUString aBaseURL,
607 sal_uInt32 nOffsDgg,
608 SvStream* pStData,
609 SdrModel* pSdrModel_,
610 tools::Long nApplicationScale,
611 Color mnDefaultColor_,
612 SvStream* pStData2_ = nullptr,
613 bool bSkipImages = false );
615 // in PPT the parameters DGGContainerOffset and PicStream are provided by an
616 // init method
617 SvxMSDffManager( SvStream& rStCtrl, OUString aBaseURL );
618 void InitSvxMSDffManager( sal_uInt32 nOffsDgg_,
619 SvStream* pStData_,
620 sal_uInt32 nSvxMSDffOLEConvFlags);
621 void SetDgContainer( SvStream& rSt );
623 virtual ~SvxMSDffManager();
625 sal_uInt32 GetSvxMSDffSettings() const { return nSvxMSDffSettings; };
626 void SetSvxMSDffSettings( sal_uInt32 nSettings ) { nSvxMSDffSettings = nSettings; };
628 static bool MakeContentStream( SotStorage * pStor, const GDIMetaFile & );
629 static void ReadObjText( SvStream& rStream, SdrObject* pObj );
630 static bool ConvertToOle2( SvStream& rStm,
631 sal_uInt32 nLen,
632 const GDIMetaFile*,
633 const rtl::Reference<SotStorage> & rDest );
635 void SetModel(SdrModel* pModel, tools::Long nApplicationScale);
636 SdrModel* GetModel() const { return pSdrModel; }
637 void Scale(sal_Int32& rVal) const;
638 void Scale(Point& rPos) const;
639 void Scale(Size& rSiz) const;
640 void ScaleEmu(sal_Int32& rVal) const;
641 sal_uInt32 ScalePt( sal_uInt32 nPt ) const;
642 sal_Int32 ScalePoint( sal_Int32 nVal ) const;
644 // TODO: provide proper documentation here
645 /** Request for a specific BLIP.
647 @param[in] nIdx number of the requested BLIP (mandatory)
648 @param[out] rData already converted data (insert directly as graphics
649 into our documents)
650 @param pVisArea ???
652 @return true if successful, false otherwise
654 bool GetBLIP( sal_uLong nIdx, Graphic& rData, tools::Rectangle* pVisArea = nullptr );
656 // TODO: provide proper documentation here
657 /** read a BLIP out of an already positioned stream
659 @param[in] rBLIPStream already positioned stream (mandatory)
660 @param[out] rData already converted data (insert directly as
661 graphics into our documents)
662 @param pVisArea ???
664 @return true if successful, false otherwise
666 static bool GetBLIPDirect(SvStream& rBLIPStream, Graphic& rData, tools::Rectangle* pVisArea = nullptr );
668 bool GetShape(sal_uLong nId, rtl::Reference<SdrObject>& rpData, SvxMSDffImportData& rData);
670 rtl::Reference<SdrObject> ImportObj( SvStream& rSt,
671 SvxMSDffClientData& rData,
672 tools::Rectangle& rClientRect,
673 const tools::Rectangle& rGlobalChildRect,
674 int nCalledByGroup,
675 sal_Int32* pShapeId);
676 rtl::Reference<SdrObject> ImportGroup( const DffRecordHeader& rHd,
677 SvStream& rSt,
678 SvxMSDffClientData& rData,
679 tools::Rectangle& rClientRect,
680 const tools::Rectangle& rGlobalChildRect,
681 int nCalledByGroup,
682 sal_Int32* pShapeId );
683 rtl::Reference<SdrObject> ImportShape( const DffRecordHeader& rHd,
684 SvStream& rSt,
685 SvxMSDffClientData& rData,
686 tools::Rectangle& rClientRect,
687 const tools::Rectangle& rGlobalChildRect,
688 int nCalledByGroup,
689 sal_Int32* pShapeId);
691 tools::Rectangle GetGlobalChildAnchor( const DffRecordHeader& rHd,
692 SvStream& rSt,
693 tools::Rectangle& aClientRect );
694 void GetGroupAnchors( const DffRecordHeader& rHd,
695 SvStream& rSt,
696 tools::Rectangle& rGroupClientAnchor,
697 tools::Rectangle& rGroupChildAnchor,
698 const tools::Rectangle& rClientRect,
699 const tools::Rectangle& rGlobalChildRect );
701 const SvxMSDffShapeInfos_ById* GetShapeInfos() const
702 { return m_xShapeInfosById.get(); }
704 const SvxMSDffShapeOrders* GetShapeOrders() const
705 { return &m_aShapeOrders; }
707 void StoreShapeOrder(sal_uLong nId,
708 sal_uLong nTxBx,
709 SdrObject* pObject,
710 SwFlyFrameFormat* pFly = nullptr) const;
712 void ExchangeInShapeOrder(SdrObject const * pOldObject,
713 sal_uLong nTxBx,
714 SdrObject* pObject) const;
716 void RemoveFromShapeOrder( SdrObject const * pObject ) const;
718 static rtl::Reference<SdrOle2Obj> CreateSdrOLEFromStorage(
719 SdrModel& rSdrModel,
720 const OUString& rStorageName,
721 rtl::Reference<SotStorage> const & rSrcStorage,
722 const css::uno::Reference < css::embed::XStorage >& xDestStg,
723 const Graphic& rGraf,
724 const tools::Rectangle& rBoundRect,
725 const tools::Rectangle& rVisArea,
726 SvStream* pDataStrrm,
727 ErrCode& rError,
728 sal_uInt32 nConvertFlags,
729 sal_Int64 nAspect,
730 OUString const& rBaseURL);
732 /** Create connections between shapes.
733 This method should be called after a page is imported.
735 @param rSolver contains necessary data that is collected during the
736 import of each shape
738 static void SolveSolver( const SvxMSDffSolverContainer& rSolver );
740 static bool SetPropValue(
741 const css::uno::Any& rAny,
742 const css::uno::Reference< css::beans::XPropertySet > & rXPropSet,
743 const OUString& rPropertyName
746 /// Determines an ODF filter name (if there is one) for aGlobName.
747 static OUString GetFilterNameFromClassID(const SvGlobalName& aGlobName);
748 /// Extracts ODF data from rSrcStg.
749 static void ExtractOwnStream(SotStorage& rSrcStg, SvMemoryStream& rMemStream);
751 void insertShapeId( sal_Int32 nShapeId, SdrObject* pShape );
752 void removeShapeId( SdrObject const * pShape );
753 SdrObject* getShapeForId( sal_Int32 nShapeId );
756 struct SvxMSDffShapeInfo
758 sal_uInt32 nShapeId; ///< shape id, used in PLCF SPA and in mso_fbtSp (FSP)
759 sal_uInt64 nFilePos; ///< offset of the shape in control stream for
760 ///< potential later access to it
761 sal_uInt32 nTxBxComp;
763 bool bReplaceByFly :1; ///< shape can be replaced by a frame in Writer
765 explicit SvxMSDffShapeInfo(sal_uInt64 nFPos, sal_uInt32 nId=0, // sal_uLong nBIdx=0,
766 sal_uInt16 nSeqId=0, sal_uInt16 nBoxId=0):
767 nShapeId( nId ),
768 nFilePos( nFPos ),
769 nTxBxComp( (nSeqId << 16) + nBoxId )
771 bReplaceByFly = false;
773 SvxMSDffShapeInfo(const SvxMSDffShapeInfo& rInfo):
774 nShapeId( rInfo.nShapeId ),
775 nFilePos( rInfo.nFilePos ),
776 nTxBxComp( rInfo.nTxBxComp ),
777 bReplaceByFly( rInfo.bReplaceByFly )
783 struct SvxMSDffShapeOrder
785 sal_uLong nShapeId; ///< shape id used in PLCF SPA and in mso_fbtSp (FSP)
786 sal_uLong nTxBxComp; ///< chain or box number in the Text-Box-Story (or NULL)
787 SwFlyFrameFormat* pFly; ///< format of frame that was inserted as a replacement
788 ///< for a Sdr-Text object in Writer - needed for
789 ///< chaining!
790 SdrObject* pObj; ///< pointer to the draw object (or NULL if not used)
792 // Approach: In the Ctor of SvxMSDffManager only the shape ids are stored in
793 // the shape order array. The Text-Box number and the object
794 // pointer are only stored if the shape is really imported.
795 explicit SvxMSDffShapeOrder( sal_uLong nId ):
796 nShapeId( nId ), nTxBxComp( 0 ), pFly( nullptr ), pObj( nullptr ){}
798 bool operator<( const SvxMSDffShapeOrder& rEntry ) const
799 { return (nTxBxComp < rEntry.nTxBxComp); }
802 // the following will be sorted explicitly:
803 struct CompareSvxMSDffShapeTxBxSort
805 bool operator()( SvxMSDffShapeOrder* const& lhs, SvxMSDffShapeOrder* const& rhs ) const { return (*lhs)<(*rhs); }
807 class MSFILTER_DLLPUBLIC SvxMSDffShapeTxBxSort : public std::set<SvxMSDffShapeOrder*,CompareSvxMSDffShapeTxBxSort> {};
810 #endif
812 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */