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/string.hxx>
40 #include <rtl/ustring.hxx>
41 #include <sal/types.h>
42 #include <svx/msdffdef.hxx>
43 #include <vcl/errcode.hxx>
44 #include <tools/gen.hxx>
45 #include <tools/ref.hxx>
46 #include <tools/solar.h>
47 #include <vcl/graph.hxx>
59 class SwFlyFrameFormat
;
61 struct SvxMSDffBLIPInfos
;
62 struct SvxMSDffShapeInfo
;
63 struct SvxMSDffShapeOrder
;
65 class SvxMSDffManager
;
70 namespace com
{ namespace sun
{ namespace star
{
71 namespace beans
{ class XPropertySet
; }
72 namespace embed
{ class XEmbeddedObject
; }
73 namespace embed
{ class XStorage
; }
76 class MSFILTER_DLLPUBLIC SvxMSDffClientData
79 virtual void NotifyFreeObj(SdrObject
* pObj
) = 0;
80 virtual ~SvxMSDffClientData() {}
83 class MSFILTER_DLLPUBLIC DffPropertyReader
: public DffPropSet
85 const SvxMSDffManager
& rManager
;
86 std::unique_ptr
<DffPropSet
> pDefaultPropSet
;
88 void ApplyCustomShapeTextAttributes( SfxItemSet
& rSet
) const;
89 void CheckAndCorrectExcelTextRotation( SvStream
& rIn
, SfxItemSet
& rSet
, DffObjData
const & rObjData
) const;
90 void ApplyCustomShapeGeometryAttributes( SvStream
& rIn
,
92 const DffObjData
& rObjData
) const;
93 void ApplyLineAttributes( SfxItemSet
& rSet
, const MSO_SPT eShapeType
) const; // #i28269#
94 void ApplyFillAttributes( SvStream
& rIn
, SfxItemSet
& rSet
, const DffObjData
& rObjData
) const;
97 sal_Int32 mnFix16Angle
;
98 bool mbRotateGranientFillWithAngle
;
100 explicit DffPropertyReader( const SvxMSDffManager
& rManager
);
101 ~DffPropertyReader();
103 DffPropertyReader
& operator=( DffPropertyReader
const & ) = delete; // MSVC2015 workaround
104 DffPropertyReader( DffPropertyReader
const & ) = delete; // MSVC2015 workaround
106 static sal_Int32
Fix16ToAngle( sal_Int32 nAngle
);
108 #ifdef DBG_CUSTOMSHAPE
109 void ReadPropSet( SvStream
& rIn
, SvxMSDffClientData
* pClientData
, sal_uInt32 nShapeType
= 0 ) const;
111 void ReadPropSet( SvStream
& rIn
, SvxMSDffClientData
* pClientData
) const;
114 void SetDefaultPropSet( SvStream
& rIn
, sal_uInt32 nOffDgg
) const;
115 void ApplyAttributes( SvStream
& rIn
, SfxItemSet
& rSet
) const;
116 void ApplyAttributes( SvStream
& rIn
, SfxItemSet
& rSet
, DffObjData
const & rObjData
) const;
117 void ImportGradientColor( SfxItemSet
& aSet
, MSO_FillType eMSO_FillType
, double dTrans
, double dBackTrans
) const;
120 #define COL_DEFAULT ::Color( 0xFA, 0xFB, 0xFC )
122 typedef ::std::map
< sal_Int32
, SdrObject
* > SvxMSDffShapeIdContainer
;
124 #define SVEXT_PERSIST_STREAM "\002OlePres000"
126 /// the following will be sorted by the order of their appearance:
127 typedef std::vector
<std::unique_ptr
<SvxMSDffShapeOrder
>> SvxMSDffShapeOrders
;
129 struct MSFILTER_DLLPUBLIC CompareSvxMSDffShapeInfoById
131 bool operator()(std::shared_ptr
<SvxMSDffShapeInfo
> const& lhs
,
132 std::shared_ptr
<SvxMSDffShapeInfo
> const& rhs
) const;
134 struct MSFILTER_DLLPUBLIC CompareSvxMSDffShapeInfoByTxBxComp
136 bool operator()(std::shared_ptr
<SvxMSDffShapeInfo
> const& lhs
,
137 std::shared_ptr
<SvxMSDffShapeInfo
> const& rhs
) const;
140 // the following will be sorted explicitly:
141 typedef ::std::set
< std::shared_ptr
<SvxMSDffShapeInfo
>,
142 CompareSvxMSDffShapeInfoById
> SvxMSDffShapeInfos_ById
;
143 typedef ::std::multiset
< std::shared_ptr
<SvxMSDffShapeInfo
>,
144 CompareSvxMSDffShapeInfoByTxBxComp
> SvxMSDffShapeInfos_ByTxBxComp
;
146 #define SVXMSDFF_SETTINGS_CROP_BITMAPS 1
147 #define SVXMSDFF_SETTINGS_IMPORT_PPT 2
148 #define SVXMSDFF_SETTINGS_IMPORT_EXCEL 4
150 // for the CreateSdrOLEFromStorage we need the information, how we handle
151 // convert able OLE-Objects - this is stored in
152 #define OLE_MATHTYPE_2_STARMATH 0x0001
153 #define OLE_WINWORD_2_STARWRITER 0x0002
154 #define OLE_EXCEL_2_STARCALC 0x0004
155 #define OLE_POWERPOINT_2_STARIMPRESS 0x0008
157 struct SvxMSDffConnectorRule
159 sal_uInt32 nShapeA
; ///< SPID of shape A
160 sal_uInt32 nShapeB
; ///< SPID of shape B
161 sal_uInt32 nShapeC
; ///< SPID of connector shape
162 sal_uInt32 ncptiA
; ///< Connection site Index of shape A
163 sal_uInt32 ncptiB
; ///< Connection site Index of shape B
164 ShapeFlag nSpFlagsA
; ///< SpFlags of shape A (the original mirror flags
165 ///< must be known when solving the Solver Container)
166 ShapeFlag nSpFlagsB
; ///< SpFlags of shape B
168 SdrObject
* pAObj
; ///< pPtr of object (corresponding to shape A)
169 SdrObject
* pBObj
; ///< pPtr of object (corresponding to shape B)
170 SdrObject
* pCObj
; ///< pPtr of connector object
172 SvxMSDffConnectorRule()
178 , nSpFlagsA( ShapeFlag::NONE
)
179 , nSpFlagsB( ShapeFlag::NONE
)
187 struct MSFILTER_DLLPUBLIC SvxMSDffSolverContainer
189 ::std::vector
< std::unique_ptr
<SvxMSDffConnectorRule
> > aCList
;
191 SvxMSDffSolverContainer();
192 ~SvxMSDffSolverContainer();
194 SvxMSDffSolverContainer
& operator=( SvxMSDffSolverContainer
const & ) = delete; // MSVC2015 workaround
195 SvxMSDffSolverContainer( SvxMSDffSolverContainer
const & ) = delete; // MSVC2015 workaround
197 MSFILTER_DLLPUBLIC
friend SvStream
& ReadSvxMSDffSolverContainer( SvStream
& rIn
, SvxMSDffSolverContainer
& rAtom
);
202 sal_uInt32 dgid
; ///< DG owning the SPIDs in this cluster
205 /// provided by SvxMSDffManager for each shape in a group
209 sal_uInt16 nSequence
;
211 : nTxBxS( 0 ), nSequence( 0 ) {}
212 MSDffTxId( const MSDffTxId
& rCopy
)
213 : nTxBxS( rCopy
.nTxBxS
), nSequence( rCopy
.nSequence
) {}
216 struct MSFILTER_DLLPUBLIC SvxMSDffImportRec
218 static const int RELTO_DEFAULT
= 2;
221 std::unique_ptr
<tools::Polygon
>
223 std::unique_ptr
<char[]>
225 sal_uInt32 nClientAnchorLen
;
226 std::unique_ptr
<char[]>
228 sal_uInt32 nClientDataLen
;
230 boost::optional
<sal_uInt32
> nXRelTo
;
232 boost::optional
<sal_uInt32
> nYRelTo
;
233 sal_uInt32 nLayoutInTableCell
;
235 sal_Int32 nDxTextLeft
; ///< distance of text box from surrounding shape
236 sal_Int32 nDyTextTop
;
237 sal_Int32 nDxTextRight
;
238 sal_Int32 nDyTextBottom
;
239 sal_Int32 nDxWrapDistLeft
;
240 sal_Int32 nDyWrapDistTop
;
241 sal_Int32 nDxWrapDistRight
;
242 sal_Int32 nDyWrapDistBottom
;
243 sal_Int32 nCropFromTop
;
244 sal_Int32 nCropFromBottom
;
245 sal_Int32 nCropFromLeft
;
246 sal_Int32 nCropFromRight
;
247 MSDffTxId aTextId
; ///< identifier for text boxes
248 sal_uLong nNextShapeId
; ///< for linked text boxes
251 MSO_LineStyle eLineStyle
; ///< border types
252 MSO_LineDashing eLineDashing
;
255 bool bReplaceByFly
:1;
259 int relativeHorizontalWidth
; ///< in 0.1% or -1 for none
260 bool isHorizontalRule
;
263 SvxMSDffImportRec(const SvxMSDffImportRec
& rCopy
);
264 ~SvxMSDffImportRec();
266 bool operator<( const SvxMSDffImportRec
& rEntry
) const
267 { return nShapeId
< rEntry
.nShapeId
; }
270 SvxMSDffImportRec
&operator=(const SvxMSDffImportRec
&) = delete;
273 /** block of parameters for import/export for a single call of
274 ImportObjAtCurrentStreamPos() */
275 class MSFILTER_DLLPUBLIC SvxMSDffImportData
: public SvxMSDffClientData
278 /** list of all SvxMSDffImportRec instances of/for a group */
279 typedef std::set
<std::unique_ptr
<SvxMSDffImportRec
>,
280 comphelper::UniquePtrValueLess
<SvxMSDffImportRec
>> MSDffImportRecords
;
281 MSDffImportRecords m_Records
; ///< Shape pointer, Shape ids and private data
282 std::map
<const SdrObject
*, SvxMSDffImportRec
*> m_ObjToRecMap
;
284 tools::Rectangle aParentRect
;///< Rectangle of the surrounding groups,
285 ///< which might have been provided externally
287 explicit SvxMSDffImportData(const tools::Rectangle
& rParentRect
);
288 SvxMSDffImportData
& operator=( SvxMSDffImportData
const & ) = delete; // MSVC2015 workaround
289 SvxMSDffImportData( SvxMSDffImportData
const & ) = delete; // MSVC2015 workaround
290 virtual ~SvxMSDffImportData() override
;
291 bool empty() const { return m_Records
.empty(); }
292 void insert(std::unique_ptr
<SvxMSDffImportRec
> pImpRec
);
293 void unmap(const SdrObject
* pObj
) { m_ObjToRecMap
.erase(pObj
); }
294 size_t size() const { return m_Records
.size(); }
295 SvxMSDffImportRec
* find(const SdrObject
* pObj
);
296 MSDffImportRecords::const_iterator
begin() const { return m_Records
.begin(); }
297 MSDffImportRecords::const_iterator
end() const { return m_Records
.end(); }
298 virtual void NotifyFreeObj(SdrObject
* pObj
) override
;
303 const DffRecordHeader
& rSpHd
;
305 tools::Rectangle aBoundRect
;
306 tools::Rectangle aChildAnchor
;
313 bool bClientAnchor
: 1;
314 bool bClientData
: 1;
315 bool bChildAnchor
: 1;
318 bool bRotateTextWithShape
: 1;
322 DffObjData( const DffRecordHeader
& rObjHd
,
323 const tools::Rectangle
& rBoundRect
,
326 aBoundRect( rBoundRect
),
328 nSpFlags( ShapeFlag::NONE
),
329 eShapeType( mso_sptNil
),
331 bClientAnchor( false ),
332 bClientData( false ),
333 bChildAnchor( false ),
336 bRotateTextWithShape( true ),
338 nCalledByGroup( nClByGroup
){}
340 // Clone a DffObjData _o_ by replacing its rSpHd with a shared_ptr to another one
341 DffObjData( const std::shared_ptr
<DffRecordHeader
>& rObjHd
, const DffObjData
& o
) :
343 aBoundRect( o
.aBoundRect
),
344 nShapeId( o
.nShapeId
),
345 nSpFlags( o
.nSpFlags
),
346 eShapeType( o
.eShapeType
),
347 bShapeType( o
.bShapeType
),
348 bClientAnchor( o
.bClientAnchor
),
349 bClientData( o
.bClientData
),
350 bChildAnchor( o
.bChildAnchor
),
353 bRotateTextWithShape( o
.bRotateTextWithShape
),
354 bPageAnchor( o
.bPageAnchor
),
355 nCalledByGroup( o
.nCalledByGroup
){}
358 #define DFF_RECORD_MANAGER_BUF_SIZE 64
364 DffRecordList
* pPrev
;
365 std::unique_ptr
<DffRecordList
>
368 DffRecordHeader mHd
[ DFF_RECORD_MANAGER_BUF_SIZE
];
370 explicit DffRecordList( DffRecordList
* pList
);
374 enum DffSeekToContentMode
378 SEEK_FROM_CURRENT_AND_RESTART
381 class MSFILTER_DLLPUBLIC DffRecordManager
: public DffRecordList
384 DffRecordList
* pCList
;
387 void Consume( SvStream
& rIn
,
388 sal_uInt32 nStOfs
= 0 );
390 bool SeekToContent( SvStream
& rIn
,
392 DffSeekToContentMode eMode
= SEEK_FROM_BEGINNING
);
393 DffRecordHeader
* GetRecordHeader( sal_uInt16 nRecType
,
394 DffSeekToContentMode eMode
= SEEK_FROM_BEGINNING
);
397 explicit DffRecordManager( SvStream
& rIn
);
399 DffRecordHeader
* Current();
400 DffRecordHeader
* First();
401 DffRecordHeader
* Next();
402 DffRecordHeader
* Prev();
403 DffRecordHeader
* Last();
406 /** abstract base class for Escher imports
408 Purpose: access to objects in Drawing File Format
410 Note: The method ProcessUserDefinedRecord() _has_ to be implemented in the
411 inheriting class(es) that is/are eventually used for PowerPoint, Word,
414 Status: Currently only access to BLIPs (will be extended later)
416 class MSFILTER_DLLPUBLIC SvxMSDffManager
: public DffPropertyReader
418 std::unique_ptr
<SvxMSDffBLIPInfos
> m_pBLIPInfos
;
419 std::unique_ptr
<SvxMSDffShapeInfos_ByTxBxComp
> m_xShapeInfosByTxBxComp
;
420 std::unique_ptr
<SvxMSDffShapeInfos_ById
> m_xShapeInfosById
;
421 SvxMSDffShapeOrders m_aShapeOrders
;
423 sal_uInt16 nBLIPCount
;
424 ShapeFlag nGroupShapeFlags
;
426 void CheckTxBxStoryChain();
427 void GetFidclData(sal_uInt32 nOffsDgg
);
430 typedef std::map
<sal_uInt32
, sal_uInt32
> OffsetMap
;
433 sal_uInt32 mnIdClusters
; // while only knowing the shapeid
434 std::vector
<FIDCL
> maFidcls
;
435 OffsetMap maDgOffsetTable
; ///< array of fileoffsets
437 /** When importing Excel files, cell anchor computations for non-page-anchored
438 groups must be done after all nested groups have been processed; for each open
439 group, the pending data is stored here. The storage also holds a shared_ptr to
440 the DffObjData ow DffRecordHeader to avoid it going out of scope except when needed
442 std::vector
< std::pair
<DffObjData
, std::shared_ptr
<DffRecordHeader
> > > maPendingGroupData
;
444 friend class DffPropertyReader
;
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
,
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
,
476 sal_uInt16 nDrawingContainerId
);
477 bool GetShapeGroupContainerData( SvStream
& rSt
,
478 sal_uLong nLenShapeGroupCont
,
480 sal_uInt16 nDrawingContainerId
);
481 bool GetShapeContainerData( SvStream
& rSt
,
482 sal_uLong nLenShapeCont
,
484 sal_uInt16 nDrawingContainerId
);
486 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 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
,
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
,
505 std::unique_ptr
<char[]>& rpBuff
,
506 sal_uInt32
& rBuffLen
);
507 virtual void ProcessClientAnchor2( SvStream
& rStData
,
508 DffRecordHeader
& rHd
,
509 SvxMSDffClientData
& rData
, DffObjData
& );
510 static void ProcessClientData( SvStream
& rStData
,
512 std::unique_ptr
<char[]>& rpBuff
,
513 sal_uInt32
& rBuffLen
);
514 virtual SdrObject
* ProcessObj( SvStream
& rSt
,
516 SvxMSDffClientData
& rClientData
,
517 tools::Rectangle
& rTextRect
,
519 virtual 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
,
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 tools::SvRef
<SotStorage
>& rSrcStorage
,
539 css::uno::Reference
< css::embed::XStorage
>& xDestStg
542 /** Prevent that (rounded) rectangles with wrapped text will always be
543 converted into SdrRectObj( OBJ_TEXT ).
545 @return true means "conversion".
547 virtual bool ShapeHasText(sal_uLong nShapeId
, sal_uLong nFilePos
) const;
550 std::unique_ptr
<DffPropertyReader
> pSecPropSet
;
551 std::unordered_map
<sal_uInt32
, Graphic
> aEscherBlipCache
;
553 DffRecordManager maShapeRecords
;
554 Color mnDefaultColor
;
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
,
566 sal_uLong nMaxFilePos
,
567 DffRecordHeader
* pRecHd
= nullptr,
568 sal_uLong nSkipCount
= 0 );
569 bool SeekToRec2( sal_uInt16 nRecId1
,
571 sal_uLong nMaxFilePos
) const;
573 static OUString
MSDFFReadZString( SvStream
& rIn
,
577 [[nodiscard
]] static bool ReadCommonRecordHeader( SvStream
& rSt
,
581 sal_uInt32
& rLength
);
583 // TODO: provide proper documentation here
588 @param rStCtrl Management stream with containers, FBSE
589 objects and shapes (mandatory; stream needs
592 @param nOffsDgg offset in rStrCtrl; beginning of the drawing
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_ ???
603 @param bSkipImages skipping images for text extraction/indexing
605 SvxMSDffManager( SvStream
& rStCtrl
,
606 const OUString
& rBaseURL
,
609 SdrModel
* pSdrModel_
,
610 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
617 SvxMSDffManager( SvStream
& rStCtrl
, const OUString
& rBaseURL
);
618 void InitSvxMSDffManager( sal_uInt32 nOffsDgg_
,
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
,
633 const tools::SvRef
<SotStorage
> & rDest
);
635 void SetModel(SdrModel
* pModel
, 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
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 a 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)
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
, SdrObject
*& rpData
, SvxMSDffImportData
& rData
);
670 SdrObject
* ImportObj( SvStream
& rSt
,
671 SvxMSDffClientData
& rData
,
672 tools::Rectangle
& rClientRect
,
673 const tools::Rectangle
& rGlobalChildRect
,
675 sal_Int32
* pShapeId
);
676 SdrObject
* ImportGroup( const DffRecordHeader
& rHd
,
678 SvxMSDffClientData
& rData
,
679 tools::Rectangle
& rClientRect
,
680 const tools::Rectangle
& rGlobalChildRect
,
682 sal_Int32
* pShapeId
);
683 SdrObject
* ImportShape( const DffRecordHeader
& rHd
,
685 SvxMSDffClientData
& rData
,
686 tools::Rectangle
& rClientRect
,
687 const tools::Rectangle
& rGlobalChildRect
,
689 sal_Int32
* pShapeId
);
691 tools::Rectangle
GetGlobalChildAnchor( const DffRecordHeader
& rHd
,
693 tools::Rectangle
& aClientRect
);
694 void GetGroupAnchors( const DffRecordHeader
& rHd
,
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
,
710 SwFlyFrameFormat
* pFly
= nullptr) const;
712 void ExchangeInShapeOrder(SdrObject
const * pOldObject
,
714 SdrObject
* pObject
) const;
716 void RemoveFromShapeOrder( SdrObject
const * pObject
) const;
718 static SdrOle2Obj
* CreateSdrOLEFromStorage(
720 const OUString
& rStorageName
,
721 tools::SvRef
<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
,
728 sal_uInt32 nConvertFlags
,
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
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_uLong 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_uLong nFPos
, sal_uInt32 nId
=0, // sal_uLong nBIdx=0,
766 sal_uInt16 nSeqId
=0, sal_uInt16 nBoxId
=0):
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
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
> {};
812 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */