1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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
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>
58 class SwFlyFrameFormat
;
60 struct SvxMSDffBLIPInfos
;
61 struct SvxMSDffShapeInfo
;
62 struct SvxMSDffShapeOrder
;
64 class SvxMSDffManager
;
69 namespace com
{ namespace sun
{ namespace star
{
70 namespace beans
{ class XPropertySet
; }
71 namespace embed
{ class XEmbeddedObject
; }
72 namespace embed
{ class XStorage
; }
75 class MSFILTER_DLLPUBLIC SvxMSDffClientData
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
,
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;
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;
110 void ReadPropSet( SvStream
& rIn
, SvxMSDffClientData
* pClientData
) const;
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()
177 , nSpFlagsA( ShapeFlag::NONE
)
178 , nSpFlagsB( ShapeFlag::NONE
)
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
);
201 sal_uInt32 dgid
; ///< DG owning the SPIDs in this cluster
204 /// provided by SvxMSDffManager for each shape in a group
208 sal_uInt16 nSequence
;
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;
220 std::unique_ptr
<tools::Polygon
>
222 std::unique_ptr
<char[]>
224 sal_uInt32 nClientAnchorLen
;
225 std::unique_ptr
<char[]>
227 sal_uInt32 nClientDataLen
;
229 boost::optional
<sal_uInt32
> nXRelTo
;
231 boost::optional
<sal_uInt32
> nYRelTo
;
232 sal_uInt32 nLayoutInTableCell
;
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
250 MSO_LineStyle eLineStyle
; ///< border types
251 MSO_LineDashing eLineDashing
;
254 bool bReplaceByFly
:1;
258 int relativeHorizontalWidth
; ///< in 0.1% or -1 for none
259 bool isHorizontalRule
;
262 SvxMSDffImportRec(const SvxMSDffImportRec
& rCopy
);
263 ~SvxMSDffImportRec();
265 bool operator<( const SvxMSDffImportRec
& rEntry
) const
266 { return nShapeId
< rEntry
.nShapeId
; }
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
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
;
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
;
302 const DffRecordHeader
& rSpHd
;
304 tools::Rectangle aBoundRect
;
305 tools::Rectangle aChildAnchor
;
312 bool bClientAnchor
: 1;
313 bool bClientData
: 1;
314 bool bChildAnchor
: 1;
317 bool bRotateTextWithShape
: 1;
321 DffObjData( const DffRecordHeader
& rObjHd
,
322 const tools::Rectangle
& rBoundRect
,
325 aBoundRect( rBoundRect
),
327 nSpFlags( ShapeFlag::NONE
),
328 eShapeType( mso_sptNil
),
330 bClientAnchor( false ),
331 bClientData( false ),
332 bChildAnchor( false ),
335 bRotateTextWithShape( 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
) :
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
),
352 bRotateTextWithShape( o
.bRotateTextWithShape
),
353 bPageAnchor( o
.bPageAnchor
),
354 nCalledByGroup( o
.nCalledByGroup
){}
357 #define DFF_RECORD_MANAGER_BUF_SIZE 64
363 DffRecordList
* pPrev
;
364 std::unique_ptr
<DffRecordList
>
367 DffRecordHeader mHd
[ DFF_RECORD_MANAGER_BUF_SIZE
];
369 explicit DffRecordList( DffRecordList
* pList
);
373 enum DffSeekToContentMode
377 SEEK_FROM_CURRENT_AND_RESTART
380 class MSFILTER_DLLPUBLIC DffRecordManager
: public DffRecordList
383 DffRecordList
* pCList
;
386 void Consume( SvStream
& rIn
,
387 sal_uInt32 nStOfs
= 0 );
389 bool SeekToContent( SvStream
& rIn
,
391 DffSeekToContentMode eMode
= SEEK_FROM_BEGINNING
);
392 DffRecordHeader
* GetRecordHeader( sal_uInt16 nRecType
,
393 DffSeekToContentMode eMode
= SEEK_FROM_BEGINNING
);
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,
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
;
422 sal_uInt16 nBLIPCount
;
423 ShapeFlag nGroupShapeFlags
;
425 void CheckTxBxStoryChain();
426 void GetFidclData(sal_uInt32 nOffsDgg
);
429 typedef std::map
<sal_uInt32
, sal_uInt32
> OffsetMap
;
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
;
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
,
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
,
475 sal_uInt16 nDrawingContainerId
);
476 bool GetShapeGroupContainerData( SvStream
& rSt
,
477 sal_uLong nLenShapeGroupCont
,
479 sal_uInt16 nDrawingContainerId
);
480 bool GetShapeContainerData( SvStream
& rSt
,
481 sal_uLong nLenShapeCont
,
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
,
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
,
504 std::unique_ptr
<char[]>& rpBuff
,
505 sal_uInt32
& rBuffLen
);
506 virtual void ProcessClientAnchor2( SvStream
& rStData
,
507 DffRecordHeader
& rHd
,
509 static void ProcessClientData( SvStream
& rStData
,
511 std::unique_ptr
<char[]>& rpBuff
,
512 sal_uInt32
& rBuffLen
);
513 virtual SdrObject
* ProcessObj( SvStream
& rSt
,
515 SvxMSDffClientData
& rClientData
,
516 tools::Rectangle
& rTextRect
,
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
,
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
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;
549 std::unique_ptr
<DffPropertyReader
> pSecPropSet
;
550 std::unordered_map
<sal_uInt32
, Graphic
> aEscherBlipCache
;
552 DffRecordManager maShapeRecords
;
553 Color mnDefaultColor
;
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
,
565 sal_uLong nMaxFilePos
,
566 DffRecordHeader
* pRecHd
= nullptr,
567 sal_uLong nSkipCount
= 0 );
568 bool SeekToRec2( sal_uInt16 nRecId1
,
570 sal_uLong nMaxFilePos
) const;
572 static OUString
MSDFFReadZString( SvStream
& rIn
,
576 [[nodiscard
]] static bool ReadCommonRecordHeader( SvStream
& rSt
,
580 sal_uInt32
& rLength
);
582 // TODO: provide proper documentation here
587 @param rStCtrl Management stream with containers, FBSE
588 objects and shapes (mandatory; stream needs
591 @param nOffsDgg offset in rStrCtrl; beginning of the drawing
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_ ???
602 @param bSkipImages skipping images for text extraction/indexing
604 SvxMSDffManager( SvStream
& rStCtrl
,
605 const OUString
& rBaseURL
,
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
616 SvxMSDffManager( SvStream
& rStCtrl
, const OUString
& rBaseURL
);
617 void InitSvxMSDffManager( sal_uInt32 nOffsDgg_
,
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
,
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
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)
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
,
674 sal_Int32
* pShapeId
);
675 SdrObject
* ImportGroup( const DffRecordHeader
& rHd
,
677 SvxMSDffClientData
& rData
,
678 tools::Rectangle
& rClientRect
,
679 const tools::Rectangle
& rGlobalChildRect
,
681 sal_Int32
* pShapeId
);
682 SdrObject
* ImportShape( const DffRecordHeader
& rHd
,
684 SvxMSDffClientData
& rData
,
685 tools::Rectangle
& rClientRect
,
686 const tools::Rectangle
& rGlobalChildRect
,
688 sal_Int32
* pShapeId
);
690 tools::Rectangle
GetGlobalChildAnchor( const DffRecordHeader
& rHd
,
692 tools::Rectangle
& aClientRect
);
693 void GetGroupAnchors( const DffRecordHeader
& rHd
,
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
,
709 SwFlyFrameFormat
* pFly
= nullptr) const;
711 void ExchangeInShapeOrder(SdrObject
const * pOldObject
,
713 SdrObject
* pObject
) const;
715 void RemoveFromShapeOrder( SdrObject
const * pObject
) const;
717 static SdrOle2Obj
* CreateSdrOLEFromStorage(
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
,
727 sal_uInt32 nConvertFlags
,
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
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):
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
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
> {};
811 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */