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