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_SC_SOURCE_FILTER_INC_XIESCHER_HXX
21 #define INCLUDED_SC_SOURCE_FILTER_INC_XIESCHER_HXX
23 #include <filter/msfilter/msdffimp.hxx>
24 #include <vcl/graph.hxx>
25 #include "xlescher.hxx"
27 #include <oox/ole/olehelper.hxx>
28 #include <rtl/ustring.hxx>
29 #include <svx/svdobj.hxx>
34 namespace com
{ namespace sun
{ namespace star
{
35 namespace drawing
{ class XShape
; }
36 namespace form
{ class XForm
; }
39 namespace com
{ namespace sun
{ namespace star
{ namespace container
{ class XNameContainer
; } } } }
46 class XclImpDffConverter
;
49 // Drawing objects ============================================================
51 class XclImpDrawObjBase
;
52 typedef std::shared_ptr
< XclImpDrawObjBase
> XclImpDrawObjRef
;
54 /** Base class for drawing objects (OBJ records). */
55 class XclImpDrawObjBase
: protected XclImpRoot
58 explicit XclImpDrawObjBase( const XclImpRoot
& rRoot
);
59 virtual ~XclImpDrawObjBase() override
;
61 /** Reads the BIFF3 OBJ record, returns a new drawing object. */
62 static XclImpDrawObjRef
ReadObj3( const XclImpRoot
& rRoot
, XclImpStream
& rStrm
);
63 /** Reads the BIFF4 OBJ record, returns a new drawing object. */
64 static XclImpDrawObjRef
ReadObj4( const XclImpRoot
& rRoot
, XclImpStream
& rStrm
);
65 /** Reads the BIFF5 OBJ record, returns a new drawing object. */
66 static XclImpDrawObjRef
ReadObj5( const XclImpRoot
& rRoot
, XclImpStream
& rStrm
);
67 /** Reads the BIFF8 OBJ record, returns a new drawing object. */
68 static XclImpDrawObjRef
ReadObj8( const XclImpRoot
& rRoot
, XclImpStream
& rStrm
);
70 /** Sets whether this is an area object (then its width and height must be greater than 0). */
71 void SetAreaObj( bool bAreaObj
) { mbAreaObj
= bAreaObj
; }
72 /** If set to true, a new SdrObject will be created while in DFF import. */
73 void SetSimpleMacro( bool bMacro
) { mbSimpleMacro
= bMacro
; }
75 /** Sets the object anchor explicitly. */
76 void SetAnchor( const XclObjAnchor
& rAnchor
);
77 /** Sets shape data from DFF stream. */
79 const DffObjData
& rDffObjData
, const OUString
& rObjName
, const OUString
& rHyperlink
,
80 bool bVisible
, bool bAutoMargin
);
82 /** If set to false, the SdrObject will not be created, processed, or inserted into the draw page. */
83 void SetProcessSdrObj( bool bProcess
) { mbProcessSdr
= bProcess
; }
84 /** If set to false, the SdrObject will be created or processed, but not be inserted into the draw page. */
85 void SetInsertSdrObj( bool bInsert
) { mbInsertSdr
= bInsert
; }
86 /** If set to true, a new SdrObject will be created while in DFF import. */
87 void SetCustomDffObj( bool bCustom
) { mbCustomDff
= bCustom
; }
89 /** Returns the sheet index and Excel object identifier from OBJ record. */
90 sal_uInt16
GetObjId() const { return mnObjId
; }
91 /** Returns the Excel object type from OBJ record. */
92 sal_uInt16
GetObjType() const { return mnObjType
; }
93 /** Returns the name of this object, may generate a default name. */
94 virtual OUString
GetObjName() const;
95 /** Returns associated macro name, if set, otherwise zero length string. */
96 const OUString
& GetMacroName() const { return maMacroName
; }
98 /** Returns the shape identifier used in the DFF stream. */
99 sal_uInt32
GetDffShapeId() const { return mnDffShapeId
; }
100 /** Returns the shape flags from the DFF stream. */
101 ShapeFlag
GetDffFlags() const { return mnDffFlags
; }
103 /** Returns true, if the object is hidden. */
104 bool IsHidden() const { return mbHidden
; }
105 /** Returns true, if the object is visible. */
106 bool IsVisible() const { return mbVisible
; }
107 /** Returns true, if the object is printable. */
108 bool IsPrintable() const { return mbPrintable
; }
110 /** Returns the object anchor if existing, null otherwise. */
111 const XclObjAnchor
* GetAnchor() const;
112 /** Returns true, if the passed size is valid for this object. */
113 bool IsValidSize( const tools::Rectangle
& rAnchorRect
) const;
114 /** Returns the range in the sheet covered by this object. */
115 ScRange
GetUsedArea( SCTAB nScTab
) const;
117 /** Returns true, if the object is valid and will be processed. */
118 bool IsProcessSdrObj() const { return mbProcessSdr
&& !mbHidden
; }
119 /** Returns true, if the SdrObject will be created or processed, but not be inserted into the draw page. */
120 bool IsInsertSdrObj() const { return mbInsertSdr
; }
122 /** Returns the needed size on the progress bar (calls virtual DoGetProgressSize() function). */
123 std::size_t GetProgressSize() const;
124 /** Creates and returns an SdrObject from the contained data. Caller takes ownership! */
125 SdrObjectUniquePtr
CreateSdrObject( XclImpDffConverter
& rDffConv
, const tools::Rectangle
& rAnchorRect
, bool bIsDff
) const;
126 /** Additional processing for the passed SdrObject before insertion into
127 the drawing page (calls virtual DoPreProcessSdrObj() function). */
128 void PreProcessSdrObject( XclImpDffConverter
& rDffConv
, SdrObject
& rSdrObj
);
129 /** Additional processing for the passed SdrObject after insertion into the
130 drawing page (calls virtual DoPostProcessSdrObj() function). */
131 void PostProcessSdrObject( XclImpDffConverter
& rDffConv
, SdrObject
& rSdrObj
) const;
132 SCTAB
GetTab() const { return mnTab
; }
135 /** Reads the object name in a BIFF5 OBJ record. */
136 void ReadName5( XclImpStream
& rStrm
, sal_uInt16 nNameLen
);
137 /** Reads the macro link in a BIFF3 OBJ record. */
138 void ReadMacro3( XclImpStream
& rStrm
, sal_uInt16 nMacroSize
);
139 /** Reads the macro link in a BIFF4 OBJ record. */
140 void ReadMacro4( XclImpStream
& rStrm
, sal_uInt16 nMacroSize
);
141 /** Reads the macro link in a BIFF5 OBJ record. */
142 void ReadMacro5( XclImpStream
& rStrm
, sal_uInt16 nMacroSize
);
143 /** Reads the contents of the ftMacro sub structure in an OBJ record. */
144 void ReadMacro8( XclImpStream
& rStrm
);
146 /** Converts the passed line formatting to the passed SdrObject. */
147 void ConvertLineStyle( SdrObject
& rSdrObj
, const XclObjLineData
& rLineData
) const;
148 /** Converts the passed fill formatting to the passed SdrObject. */
149 void ConvertFillStyle( SdrObject
& rSdrObj
, const XclObjFillData
& rFillData
) const;
150 /** Converts the passed frame flags to the passed SdrObject. */
151 void ConvertFrameStyle( SdrObject
& rSdrObj
, sal_uInt16 nFrameFlags
) const;
153 /** Returns a solid line color from the passed line data struct. */
154 Color
GetSolidLineColor( const XclObjLineData
& rLineData
) const;
155 /** Returns a solid fill color from the passed fill data struct. */
156 Color
GetSolidFillColor( const XclObjFillData
& rFillData
) const;
158 /** Derived classes read the contents of the a BIFF3 OBJ record from the passed stream. */
159 virtual void DoReadObj3( XclImpStream
& rStrm
, sal_uInt16 nMacroSize
);
160 /** Derived classes read the contents of the a BIFF4 OBJ record from the passed stream. */
161 virtual void DoReadObj4( XclImpStream
& rStrm
, sal_uInt16 nMacroSize
);
162 /** Derived classes read the contents of the a BIFF5 OBJ record from the passed stream. */
163 virtual void DoReadObj5( XclImpStream
& rStrm
, sal_uInt16 nNameLen
, sal_uInt16 nMacroSize
);
164 /** Derived classes read the contents of the specified subrecord of a BIFF8 OBJ record from stream. */
165 virtual void DoReadObj8SubRec( XclImpStream
& rStrm
, sal_uInt16 nSubRecId
, sal_uInt16 nSubRecSize
);
167 /** Derived classes may return a progress bar size different from 1. */
168 virtual std::size_t DoGetProgressSize() const;
169 /** Derived classes create and return a new SdrObject from the contained data. Caller takes ownership! */
170 virtual SdrObjectUniquePtr
DoCreateSdrObj( XclImpDffConverter
& rDffConv
, const tools::Rectangle
& rAnchorRect
) const;
171 /** Derived classes may perform additional processing for the passed SdrObject before insertion. */
172 virtual void DoPreProcessSdrObj( XclImpDffConverter
& rDffConv
, SdrObject
& rSdrObj
) const;
173 /** Derived classes may perform additional processing for the passed SdrObject after insertion. */
174 virtual void DoPostProcessSdrObj( XclImpDffConverter
& rDffConv
, SdrObject
& rSdrObj
) const;
176 /** Notify that the document contains a macro event handler */
177 void NotifyMacroEventRead();
179 /** Reads the contents of a BIFF3 OBJ record. */
180 void ImplReadObj3( XclImpStream
& rStrm
);
181 /** Reads the contents of a BIFF4 OBJ record. */
182 void ImplReadObj4( XclImpStream
& rStrm
);
183 /** Reads the contents of a BIFF5 OBJ record. */
184 void ImplReadObj5( XclImpStream
& rStrm
);
185 /** Reads the contents of a BIFF8 OBJ record. */
186 void ImplReadObj8( XclImpStream
& rStrm
);
189 XclObjAnchor maAnchor
; /// The position of the object in its parent.
190 sal_uInt16 mnObjId
; /// The object identifier (unique per drawing).
191 SCTAB mnTab
; /// Location of object
192 sal_uInt16 mnObjType
; /// The Excel object type from OBJ record.
193 sal_uInt32 mnDffShapeId
; /// Shape ID from DFF stream.
194 ShapeFlag mnDffFlags
; /// Shape flags from DFF stream.
195 OUString maObjName
; /// Name of the object.
196 OUString maMacroName
; /// Name of an attached macro.
197 OUString maHyperlink
; /// On-click hyperlink URL.
198 bool mbHasAnchor
; /// true = maAnchor is initialized.
199 bool mbHidden
; /// true = Object is hidden.
200 bool mbVisible
; /// true = Object is visible.
201 bool mbPrintable
; /// true = Object is printable.
202 bool mbAreaObj
; /// true = Width and height must be greater than 0.
203 bool mbAutoMargin
; /// true = Set automatic text margin.
204 bool mbSimpleMacro
; /// true = Create simple macro link and hyperlink.
205 bool mbProcessSdr
; /// true = Object is valid, do processing and insertion.
206 bool mbInsertSdr
; /// true = Insert the SdrObject into draw page.
207 bool mbCustomDff
; /// true = Recreate SdrObject in DFF import.
208 bool mbNotifyMacroEventRead
; /// true == If we have already seen a macro event
211 class XclImpDrawObjVector
214 std::vector
< XclImpDrawObjRef
> mObjs
;
217 explicit XclImpDrawObjVector() : mObjs() {}
219 std::vector
< XclImpDrawObjRef
>::const_iterator
begin() const { return mObjs
.begin(); }
220 std::vector
< XclImpDrawObjRef
>::const_iterator
end() const { return mObjs
.end(); }
221 void push_back(const XclImpDrawObjRef
& rObj
) { mObjs
.push_back(rObj
); }
223 /** Tries to insert the passed object into the last group or appends it. */
224 void InsertGrouped( XclImpDrawObjRef
const & xDrawObj
);
226 /** Returns the needed size on the progress bar for all contained objects. */
227 std::size_t GetProgressSize() const;
230 /** A placeholder object for unknown object types. */
231 class XclImpPhObj
: public XclImpDrawObjBase
234 explicit XclImpPhObj( const XclImpRoot
& rRoot
);
237 /** A group object. */
238 class XclImpGroupObj final
: public XclImpDrawObjBase
241 explicit XclImpGroupObj( const XclImpRoot
& rRoot
);
243 /** Tries to insert the drawing object into this or a nested group. */
244 bool TryInsert( XclImpDrawObjRef
const & xDrawObj
);
247 /** Reads the contents of the a BIFF3 OBJ record from the passed stream. */
248 virtual void DoReadObj3( XclImpStream
& rStrm
, sal_uInt16 nMacroSize
) override
;
249 /** Reads the contents of the a BIFF4 OBJ record from the passed stream. */
250 virtual void DoReadObj4( XclImpStream
& rStrm
, sal_uInt16 nMacroSize
) override
;
251 /** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
252 virtual void DoReadObj5( XclImpStream
& rStrm
, sal_uInt16 nNameLen
, sal_uInt16 nMacroSize
) override
;
253 /** Returns a progress bar size that takes all group children into account. */
254 virtual std::size_t DoGetProgressSize() const override
;
255 /** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */
256 virtual SdrObjectUniquePtr
DoCreateSdrObj( XclImpDffConverter
& rDffConv
, const tools::Rectangle
& rAnchorRect
) const override
;
258 XclImpDrawObjVector maChildren
; /// Grouped objects.
259 sal_uInt16 mnFirstUngrouped
; /// Object identifier of first object not grouped into this group.
262 /** A line object. */
263 class XclImpLineObj final
: public XclImpDrawObjBase
266 explicit XclImpLineObj( const XclImpRoot
& rRoot
);
269 /** Reads the contents of the a BIFF3 OBJ record from the passed stream. */
270 virtual void DoReadObj3( XclImpStream
& rStrm
, sal_uInt16 nMacroSize
) override
;
271 /** Reads the contents of the a BIFF4 OBJ record from the passed stream. */
272 virtual void DoReadObj4( XclImpStream
& rStrm
, sal_uInt16 nMacroSize
) override
;
273 /** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
274 virtual void DoReadObj5( XclImpStream
& rStrm
, sal_uInt16 nNameLen
, sal_uInt16 nMacroSize
) override
;
275 /** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */
276 virtual SdrObjectUniquePtr
DoCreateSdrObj( XclImpDffConverter
& rDffConv
, const tools::Rectangle
& rAnchorRect
) const override
;
278 XclObjLineData maLineData
; /// BIFF5 line formatting.
279 sal_uInt16 mnArrows
; /// Line arrows.
280 sal_uInt8 mnStartPoint
; /// Starting point.
283 /** A rectangle or oval object. */
284 class XclImpRectObj
: public XclImpDrawObjBase
287 explicit XclImpRectObj( const XclImpRoot
& rRoot
);
290 /** Reads fil data, line data, and frame flags. */
291 void ReadFrameData( XclImpStream
& rStrm
);
293 /** Converts fill formatting, line formatting, and frame style. */
294 void ConvertRectStyle( SdrObject
& rSdrObj
) const;
296 /** Reads the contents of the a BIFF3 OBJ record from the passed stream. */
297 virtual void DoReadObj3( XclImpStream
& rStrm
, sal_uInt16 nMacroSize
) override
;
298 /** Reads the contents of the a BIFF4 OBJ record from the passed stream. */
299 virtual void DoReadObj4( XclImpStream
& rStrm
, sal_uInt16 nMacroSize
) override
;
300 /** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
301 virtual void DoReadObj5( XclImpStream
& rStrm
, sal_uInt16 nNameLen
, sal_uInt16 nMacroSize
) override
;
302 /** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */
303 virtual SdrObjectUniquePtr
DoCreateSdrObj( XclImpDffConverter
& rDffConv
, const tools::Rectangle
& rAnchorRect
) const override
;
306 XclObjFillData maFillData
; /// BIFF5 fill formatting.
307 XclObjLineData maLineData
; /// BIFF5 line formatting.
308 sal_uInt16 mnFrameFlags
; /// Additional flags.
311 /** An oval object. */
312 class XclImpOvalObj
: public XclImpRectObj
315 explicit XclImpOvalObj( const XclImpRoot
& rRoot
);
318 /** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */
319 virtual SdrObjectUniquePtr
DoCreateSdrObj( XclImpDffConverter
& rDffConv
, const tools::Rectangle
& rAnchorRect
) const override
;
322 /** An arc object. */
323 class XclImpArcObj final
: public XclImpDrawObjBase
326 explicit XclImpArcObj( const XclImpRoot
& rRoot
);
329 /** Reads the contents of the a BIFF3 OBJ record from the passed stream. */
330 virtual void DoReadObj3( XclImpStream
& rStrm
, sal_uInt16 nMacroSize
) override
;
331 /** Reads the contents of the a BIFF4 OBJ record from the passed stream. */
332 virtual void DoReadObj4( XclImpStream
& rStrm
, sal_uInt16 nMacroSize
) override
;
333 /** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
334 virtual void DoReadObj5( XclImpStream
& rStrm
, sal_uInt16 nNameLen
, sal_uInt16 nMacroSize
) override
;
335 /** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */
336 virtual SdrObjectUniquePtr
DoCreateSdrObj( XclImpDffConverter
& rDffConv
, const tools::Rectangle
& rAnchorRect
) const override
;
338 XclObjFillData maFillData
; /// BIFF5 fill formatting.
339 XclObjLineData maLineData
; /// BIFF5 line formatting.
340 sal_uInt8 mnQuadrant
; /// Visible quadrant of the circle.
343 /** A polygon object. */
344 class XclImpPolygonObj final
: public XclImpRectObj
347 explicit XclImpPolygonObj( const XclImpRoot
& rRoot
);
350 /** Reads the COORDLIST record following the OBJ record. */
351 void ReadCoordList( XclImpStream
& rStrm
);
353 /** Reads the contents of the a BIFF4 OBJ record from the passed stream. */
354 virtual void DoReadObj4( XclImpStream
& rStrm
, sal_uInt16 nMacroSize
) override
;
355 /** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
356 virtual void DoReadObj5( XclImpStream
& rStrm
, sal_uInt16 nNameLen
, sal_uInt16 nMacroSize
) override
;
357 /** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */
358 virtual SdrObjectUniquePtr
DoCreateSdrObj( XclImpDffConverter
& rDffConv
, const tools::Rectangle
& rAnchorRect
) const override
;
360 typedef std::vector
< Point
> PointVector
;
361 PointVector maCoords
; /// Coordinates relative to bounding rectangle.
362 sal_uInt16 mnPolyFlags
; /// Additional flags.
363 sal_uInt16 mnPointCount
; /// Polygon point count.
366 struct XclImpObjTextData
368 XclObjTextData maData
; /// BIFF5 text data.
369 XclImpStringRef mxString
; /// Plain or rich string.
371 /** Reads a byte string from the passed stream. */
372 void ReadByteString( XclImpStream
& rStrm
);
373 /** Reads text formatting from the passed stream. */
374 void ReadFormats( XclImpStream
& rStrm
);
377 /** A drawing object supporting text contents. Used for all simple objects in BIFF8. */
378 class XclImpTextObj
: public XclImpRectObj
381 explicit XclImpTextObj( const XclImpRoot
& rRoot
);
383 /** Stores the passed textbox data. */
384 void SetTextData( const XclImpObjTextData
& rTextData
) { maTextData
= rTextData
; }
387 /** Reads the contents of the a BIFF3 OBJ record from the passed stream. */
388 virtual void DoReadObj3( XclImpStream
& rStrm
, sal_uInt16 nMacroSize
) override
;
389 /** Reads the contents of the a BIFF4 OBJ record from the passed stream. */
390 virtual void DoReadObj4( XclImpStream
& rStrm
, sal_uInt16 nMacroSize
) override
;
391 /** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
392 virtual void DoReadObj5( XclImpStream
& rStrm
, sal_uInt16 nNameLen
, sal_uInt16 nMacroSize
) override
;
393 /** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */
394 virtual SdrObjectUniquePtr
DoCreateSdrObj( XclImpDffConverter
& rDffConv
, const tools::Rectangle
& rAnchorRect
) const override
;
395 /** Inserts the contained text data at the passed object. */
396 virtual void DoPreProcessSdrObj( XclImpDffConverter
& rDffConv
, SdrObject
& rSdrObj
) const override
;
399 XclImpObjTextData maTextData
; /// Textbox data from BIFF5 OBJ or BIFF8 TXO record.
402 /** A chart object. This is the drawing object wrapper for the chart data. */
403 class XclImpChartObj
: public XclImpRectObj
406 /** @param bOwnTab True = chart is on an own sheet; false = chart is an embedded object. */
407 explicit XclImpChartObj( const XclImpRoot
& rRoot
, bool bOwnTab
= false );
409 /** Reads the complete chart substream (BOF/EOF block). */
410 void ReadChartSubStream( XclImpStream
& rStrm
);
413 /** Reads the contents of the a BIFF3 OBJ record from the passed stream. */
414 virtual void DoReadObj3( XclImpStream
& rStrm
, sal_uInt16 nMacroSize
) override
;
415 /** Reads the contents of the a BIFF4 OBJ record from the passed stream. */
416 virtual void DoReadObj4( XclImpStream
& rStrm
, sal_uInt16 nMacroSize
) override
;
417 /** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
418 virtual void DoReadObj5( XclImpStream
& rStrm
, sal_uInt16 nNameLen
, sal_uInt16 nMacroSize
) override
;
419 /** Reads the contents of the specified subrecord of a BIFF8 OBJ record from stream. */
420 virtual void DoReadObj8SubRec( XclImpStream
& rStrm
, sal_uInt16 nSubRecId
, sal_uInt16 nSubRecSize
) override
;
421 /** Returns the needed size on the progress bar. */
422 virtual std::size_t DoGetProgressSize() const override
;
423 /** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */
424 virtual SdrObjectUniquePtr
DoCreateSdrObj( XclImpDffConverter
& rDffConv
, const tools::Rectangle
& rAnchorRect
) const override
;
425 /** Converts the chart document. */
426 virtual void DoPostProcessSdrObj( XclImpDffConverter
& rDffConv
, SdrObject
& rSdrObj
) const override
;
429 /** Calculates the object anchor of a sheet chart (chart fills one page). */
430 void FinalizeTabChart();
433 typedef std::shared_ptr
< XclImpChart
> XclImpChartRef
;
435 XclImpChartRef mxChart
; /// The chart itself (BOF/EOF substream data).
436 bool const mbOwnTab
; /// true = own sheet; false = embedded object.
439 /** A note object, which is a specialized text box object. */
440 class XclImpNoteObj
: public XclImpTextObj
443 explicit XclImpNoteObj( const XclImpRoot
& rRoot
);
445 /** Sets note flags and the note position in the Calc sheet. */
446 void SetNoteData( const ScAddress
& rScPos
, sal_uInt16 nNoteFlags
);
449 /** Inserts the note into the document, sets visibility. */
450 virtual void DoPreProcessSdrObj( XclImpDffConverter
& rDffConv
, SdrObject
& rSdrObj
) const override
;
453 ScAddress maScPos
; /// Cell position of the note object.
454 sal_uInt16 mnNoteFlags
; /// Flags from NOTE record.
457 /** Helper base class for TBX and OCX form controls to manage spreadsheet links. */
458 class XclImpControlHelper
461 explicit XclImpControlHelper( const XclImpRoot
& rRoot
, XclCtrlBindMode eBindMode
);
462 virtual ~XclImpControlHelper();
464 /** Returns true, if a linked cell address is present. */
465 bool HasCellLink() const { return mxCellLink
!= nullptr; }
467 /** Returns the SdrObject from the passed control shape and sets the bounding rectangle. */
468 SdrObjectUniquePtr
CreateSdrObjectFromShape(
469 const css::uno::Reference
< css::drawing::XShape
>& rxShape
,
470 const tools::Rectangle
& rAnchorRect
) const;
472 /** Sets additional properties to the form control model, calls virtual DoProcessControl(). */
473 void ProcessControl( const XclImpDrawObjBase
& rDrawObj
) const;
476 /** Reads the formula for the linked cell from the current position of the stream. */
477 void ReadCellLinkFormula( XclImpStream
& rStrm
, bool bWithBoundSize
);
478 /** Reads the formula for the source range from the current position of the stream. */
479 void ReadSourceRangeFormula( XclImpStream
& rStrm
, bool bWithBoundSize
);
481 /** Derived classes will set additional properties for the current form control. */
482 virtual void DoProcessControl( ScfPropertySet
& rPropSet
) const;
484 void ApplySheetLinkProps() const;
485 mutable css::uno::Reference
< css::drawing::XShape
>
486 mxShape
; /// The UNO wrapper of the control shape.
487 std::shared_ptr
< ScAddress
> mxCellLink
; /// Linked cell in the Calc document.
489 /** Reads a list of cell ranges from a formula at the current stream position. */
490 void ReadRangeList( ScRangeList
& rScRanges
, XclImpStream
& rStrm
);
491 /** Reads leading formula size and a list of cell ranges from a formula if the leading size is not zero. */
492 void ReadRangeList( ScRangeList
& rScRanges
, XclImpStream
& rStrm
, bool bWithBoundSize
);
495 const XclImpRoot
& mrRoot
; /// Not derived from XclImpRoot to allow multiple inheritance.
496 std::shared_ptr
< ScRange
> mxSrcRange
; /// Source data range in the Calc document.
497 XclCtrlBindMode
const meBindMode
; /// Value binding mode.
500 /** Base class for textbox based form controls. */
501 class XclImpTbxObjBase
: public XclImpTextObj
, public XclImpControlHelper
504 explicit XclImpTbxObjBase( const XclImpRoot
& rRoot
);
506 /** Sets line and fill formatting from the passed DFF property set. */
507 void SetDffProperties( const DffPropSet
& rDffPropSet
);
509 /** Returns the service name of the control component to be created. */
510 OUString
GetServiceName() const { return DoGetServiceName(); }
511 /** Fills the passed macro event descriptor. */
512 bool FillMacroDescriptor(
513 css::script::ScriptEventDescriptor
& rDescriptor
) const;
516 /** Sets control text formatting. */
517 void ConvertFont( ScfPropertySet
& rPropSet
) const;
518 /** Sets control label and text formatting. */
519 void ConvertLabel( ScfPropertySet
& rPropSet
) const;
521 /** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */
522 virtual SdrObjectUniquePtr
DoCreateSdrObj( XclImpDffConverter
& rDffConv
, const tools::Rectangle
& rAnchorRect
) const override
;
523 /** Additional processing on the SdrObject, calls new virtual function DoProcessControl(). */
524 virtual void DoPreProcessSdrObj( XclImpDffConverter
& rDffConv
, SdrObject
& rSdrObj
) const override
;
526 /** Derived classes return the service name of the control component to be created. */
527 virtual OUString
DoGetServiceName() const = 0;
528 /** Derived classes return the type of the macro event to be created. */
529 virtual XclTbxEventType
DoGetEventType() const = 0;
532 /** A button control. */
533 class XclImpButtonObj
: public XclImpTbxObjBase
536 explicit XclImpButtonObj( const XclImpRoot
& rRoot
);
539 /** Sets additional properties for the current form control. */
540 virtual void DoProcessControl( ScfPropertySet
& rPropSet
) const override
;
541 /** Returns the service name of the control component to be created. */
542 virtual OUString
DoGetServiceName() const override
;
543 /** Returns the type of the macro event to be created. */
544 virtual XclTbxEventType
DoGetEventType() const override
;
547 /** A checkbox control. */
548 class XclImpCheckBoxObj
: public XclImpTbxObjBase
551 explicit XclImpCheckBoxObj( const XclImpRoot
& rRoot
);
554 /** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
555 virtual void DoReadObj5( XclImpStream
& rStrm
, sal_uInt16 nNameLen
, sal_uInt16 nMacroSize
) override
;
556 /** Reads the contents of the specified subrecord of a BIFF8 OBJ record from stream. */
557 virtual void DoReadObj8SubRec( XclImpStream
& rStrm
, sal_uInt16 nSubRecId
, sal_uInt16 nSubRecSize
) override
;
558 /** Sets additional properties for the current form control. */
559 virtual void DoProcessControl( ScfPropertySet
& rPropSet
) const override
;
560 /** Returns the service name of the control component to be created. */
561 virtual OUString
DoGetServiceName() const override
;
562 /** Returns the type of the macro event to be created. */
563 virtual XclTbxEventType
DoGetEventType() const override
;
567 sal_uInt16 mnCheckBoxFlags
;
570 /** An option button control. */
571 class XclImpOptionButtonObj final
: public XclImpCheckBoxObj
574 explicit XclImpOptionButtonObj( const XclImpRoot
& rRoot
);
577 /** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
578 virtual void DoReadObj5( XclImpStream
& rStrm
, sal_uInt16 nNameLen
, sal_uInt16 nMacroSize
) override
;
579 /** Reads the contents of the specified subrecord of a BIFF8 OBJ record from stream. */
580 virtual void DoReadObj8SubRec( XclImpStream
& rStrm
, sal_uInt16 nSubRecId
, sal_uInt16 nSubRecSize
) override
;
581 /** Sets additional properties for the current form control. */
582 virtual void DoProcessControl( ScfPropertySet
& rPropSet
) const override
;
583 /** Returns the service name of the control component to be created. */
584 virtual OUString
DoGetServiceName() const override
;
585 /** Returns the type of the macro event to be created. */
586 virtual XclTbxEventType
DoGetEventType() const override
;
588 sal_uInt16 mnNextInGroup
; /// Next option button in a group.
589 sal_uInt16 mnFirstInGroup
; /// 1 = Button is the first in a group.
592 /** A label control. */
593 class XclImpLabelObj
: public XclImpTbxObjBase
596 explicit XclImpLabelObj( const XclImpRoot
& rRoot
);
599 /** Sets additional properties for the current form control. */
600 virtual void DoProcessControl( ScfPropertySet
& rPropSet
) const override
;
601 /** Returns the service name of the control component to be created. */
602 virtual OUString
DoGetServiceName() const override
;
603 /** Returns the type of the macro event to be created. */
604 virtual XclTbxEventType
DoGetEventType() const override
;
607 /** A groupbox control. */
608 class XclImpGroupBoxObj final
: public XclImpTbxObjBase
611 explicit XclImpGroupBoxObj( const XclImpRoot
& rRoot
);
614 /** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
615 virtual void DoReadObj5( XclImpStream
& rStrm
, sal_uInt16 nNameLen
, sal_uInt16 nMacroSize
) override
;
616 /** Reads the contents of the specified subrecord of a BIFF8 OBJ record from stream. */
617 virtual void DoReadObj8SubRec( XclImpStream
& rStrm
, sal_uInt16 nSubRecId
, sal_uInt16 nSubRecSize
) override
;
618 /** Sets additional properties for the current form control. */
619 virtual void DoProcessControl( ScfPropertySet
& rPropSet
) const override
;
620 /** Returns the service name of the control component to be created. */
621 virtual OUString
DoGetServiceName() const override
;
622 /** Returns the type of the macro event to be created. */
623 virtual XclTbxEventType
DoGetEventType() const override
;
625 sal_uInt16 mnGroupBoxFlags
;
628 /** A dialog control. */
629 class XclImpDialogObj
: public XclImpTbxObjBase
632 explicit XclImpDialogObj( const XclImpRoot
& rRoot
);
635 /** Sets additional properties for the current form control. */
636 virtual void DoProcessControl( ScfPropertySet
& rPropSet
) const override
;
637 /** Returns the service name of the control component to be created. */
638 virtual OUString
DoGetServiceName() const override
;
639 /** Returns the type of the macro event to be created. */
640 virtual XclTbxEventType
DoGetEventType() const override
;
643 /** An edit control. */
644 class XclImpEditObj final
: public XclImpTbxObjBase
647 explicit XclImpEditObj( const XclImpRoot
& rRoot
);
650 /** REturns true, if the field type is numeric. */
651 bool IsNumeric() const;
653 /** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
654 virtual void DoReadObj5( XclImpStream
& rStrm
, sal_uInt16 nNameLen
, sal_uInt16 nMacroSize
) override
;
655 /** Reads the contents of the specified subrecord of a BIFF8 OBJ record from stream. */
656 virtual void DoReadObj8SubRec( XclImpStream
& rStrm
, sal_uInt16 nSubRecId
, sal_uInt16 nSubRecSize
) override
;
657 /** Sets additional properties for the current form control. */
658 virtual void DoProcessControl( ScfPropertySet
& rPropSet
) const override
;
659 /** Returns the service name of the control component to be created. */
660 virtual OUString
DoGetServiceName() const override
;
661 /** Returns the type of the macro event to be created. */
662 virtual XclTbxEventType
DoGetEventType() const override
;
664 sal_uInt16 mnContentType
;
665 sal_uInt16 mnMultiLine
;
666 sal_uInt16 mnScrollBar
;
667 sal_uInt16 mnListBoxObjId
;
670 /** Base class of scrollable form controls (spin button, scrollbar, listbox, dropdown). */
671 class XclImpTbxObjScrollableBase
: public XclImpTbxObjBase
674 explicit XclImpTbxObjScrollableBase( const XclImpRoot
& rRoot
);
677 /** Reads scrollbar data. */
678 void ReadSbs( XclImpStream
& rStrm
);
680 /** Reads the contents of the specified subrecord of a BIFF8 OBJ record from stream. */
681 virtual void DoReadObj8SubRec( XclImpStream
& rStrm
, sal_uInt16 nSubRecId
, sal_uInt16 nSubRecSize
) override
;
688 sal_uInt16 mnPageStep
;
690 sal_uInt16 mnThumbWidth
;
691 sal_uInt16 mnScrollFlags
;
694 /** A spinbutton control. */
695 class XclImpSpinButtonObj
: public XclImpTbxObjScrollableBase
698 explicit XclImpSpinButtonObj( const XclImpRoot
& rRoot
);
701 /** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
702 virtual void DoReadObj5( XclImpStream
& rStrm
, sal_uInt16 nNameLen
, sal_uInt16 nMacroSize
) override
;
703 /** Sets additional properties for the current form control. */
704 virtual void DoProcessControl( ScfPropertySet
& rPropSet
) const override
;
705 /** Returns the service name of the control component to be created. */
706 virtual OUString
DoGetServiceName() const override
;
707 /** Returns the type of the macro event to be created. */
708 virtual XclTbxEventType
DoGetEventType() const override
;
711 /** A scrollbar control. */
712 class XclImpScrollBarObj
: public XclImpTbxObjScrollableBase
715 explicit XclImpScrollBarObj( const XclImpRoot
& rRoot
);
718 /** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
719 virtual void DoReadObj5( XclImpStream
& rStrm
, sal_uInt16 nNameLen
, sal_uInt16 nMacroSize
) override
;
720 /** Sets additional properties for the current form control. */
721 virtual void DoProcessControl( ScfPropertySet
& rPropSet
) const override
;
722 /** Returns the service name of the control component to be created. */
723 virtual OUString
DoGetServiceName() const override
;
724 /** Returns the type of the macro event to be created. */
725 virtual XclTbxEventType
DoGetEventType() const override
;
728 /** Base class for list controls (listbox, dropdown). */
729 class XclImpTbxObjListBase
: public XclImpTbxObjScrollableBase
732 explicit XclImpTbxObjListBase( const XclImpRoot
& rRoot
);
735 /** Reads common listbox settings. */
736 void ReadLbsData( XclImpStream
& rStrm
);
737 /** Sets common listbox/dropdown formatting attributes. */
738 void SetBoxFormatting( ScfPropertySet
& rPropSet
) const;
741 sal_uInt16 mnEntryCount
;
742 sal_uInt16 mnSelEntry
;
743 sal_uInt16 mnListFlags
;
744 sal_uInt16 mnEditObjId
;
745 bool mbHasDefFontIdx
;
748 /** A listbox control. */
749 class XclImpListBoxObj final
: public XclImpTbxObjListBase
752 explicit XclImpListBoxObj( const XclImpRoot
& rRoot
);
755 /** Reads listbox settings and selection. */
756 void ReadFullLbsData( XclImpStream
& rStrm
, std::size_t nRecLeft
);
758 /** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
759 virtual void DoReadObj5( XclImpStream
& rStrm
, sal_uInt16 nNameLen
, sal_uInt16 nMacroSize
) override
;
760 /** Reads the contents of the specified subrecord of a BIFF8 OBJ record from stream. */
761 virtual void DoReadObj8SubRec( XclImpStream
& rStrm
, sal_uInt16 nSubRecId
, sal_uInt16 nSubRecSize
) override
;
762 /** Sets additional properties for the current form control. */
763 virtual void DoProcessControl( ScfPropertySet
& rPropSet
) const override
;
764 /** Returns the service name of the control component to be created. */
765 virtual OUString
DoGetServiceName() const override
;
766 /** Returns the type of the macro event to be created. */
767 virtual XclTbxEventType
DoGetEventType() const override
;
769 ScfUInt8Vec maSelection
;
772 /** A dropdown listbox control. */
773 class XclImpDropDownObj final
: public XclImpTbxObjListBase
776 explicit XclImpDropDownObj( const XclImpRoot
& rRoot
);
779 /** Returns the type of the dropdown control. */
780 sal_uInt16
GetDropDownType() const;
782 /** Reads dropdown box settings. */
783 void ReadFullLbsData( XclImpStream
& rStrm
);
785 /** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
786 virtual void DoReadObj5( XclImpStream
& rStrm
, sal_uInt16 nNameLen
, sal_uInt16 nMacroSize
) override
;
787 /** Reads the contents of the specified subrecord of a BIFF8 OBJ record from stream. */
788 virtual void DoReadObj8SubRec( XclImpStream
& rStrm
, sal_uInt16 nSubRecId
, sal_uInt16 nSubRecSize
) override
;
789 /** Sets additional properties for the current form control. */
790 virtual void DoProcessControl( ScfPropertySet
& rPropSet
) const override
;
791 /** Returns the service name of the control component to be created. */
792 virtual OUString
DoGetServiceName() const override
;
793 /** Returns the type of the macro event to be created. */
794 virtual XclTbxEventType
DoGetEventType() const override
;
800 sal_uInt16 mnDropDownFlags
;
801 sal_uInt16 mnLineCount
;
802 sal_uInt16 mnMinWidth
;
805 /** A picture, an embedded or linked OLE object, or an OCX form control. */
806 class XclImpPictureObj
: public XclImpRectObj
, public XclImpControlHelper
809 explicit XclImpPictureObj( const XclImpRoot
& rRoot
);
810 /** Returns the ObjectName - can use non-obvious lookup for override in the associated vba document module stream**/
811 virtual OUString
GetObjName() const override
;
812 /** Returns the graphic imported from the IMGDATA record. */
813 const Graphic
& GetGraphic() const { return maGraphic
; }
815 /** Returns true, if the OLE object will be shown as symbol. */
816 bool IsSymbol() const { return mbSymbol
; }
817 /** Returns the storage name for the OLE object. */
818 OUString
GetOleStorageName() const;
820 /** Returns true, if this object is an OCX form control. */
821 bool IsOcxControl() const { return mbEmbedded
&& mbControl
&& mbUseCtlsStrm
; }
822 /** Returns the position in the 'Ctls' stream for additional form control data. */
823 std::size_t GetCtlsStreamPos() const { return mnCtlsStrmPos
; }
824 /** Returns the size in the 'Ctls' stream for additional form control data. */
825 std::size_t GetCtlsStreamSize() const { return mnCtlsStrmSize
; }
828 /** Reads the contents of the a BIFF3 OBJ record from the passed stream. */
829 virtual void DoReadObj3( XclImpStream
& rStrm
, sal_uInt16 nMacroSize
) override
;
830 /** Reads the contents of the a BIFF4 OBJ record from the passed stream. */
831 virtual void DoReadObj4( XclImpStream
& rStrm
, sal_uInt16 nMacroSize
) override
;
832 /** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
833 virtual void DoReadObj5( XclImpStream
& rStrm
, sal_uInt16 nNameLen
, sal_uInt16 nMacroSize
) override
;
834 /** Reads the contents of the specified subrecord of a BIFF8 OBJ record from stream. */
835 virtual void DoReadObj8SubRec( XclImpStream
& rStrm
, sal_uInt16 nSubRecId
, sal_uInt16 nSubRecSize
) override
;
836 /** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */
837 virtual SdrObjectUniquePtr
DoCreateSdrObj( XclImpDffConverter
& rDffConv
, const tools::Rectangle
& rAnchorRect
) const override
;
838 /** Override to do additional processing on the SdrObject. */
839 virtual void DoPreProcessSdrObj( XclImpDffConverter
& rDffConv
, SdrObject
& rSdrObj
) const override
;
842 /** Reads and sets the picture flags from a BIFF3-BIFF5 OBJ picture record. */
843 void ReadFlags3( XclImpStream
& rStrm
);
844 /** Reads the contents of the OBJFLAGS subrecord. */
845 void ReadFlags8( XclImpStream
& rStrm
);
846 /** Reads the contents of the OBJPICTFMLA subrecord. */
847 void ReadPictFmla( XclImpStream
& rStrm
, sal_uInt16 nLinkSize
);
850 Graphic maGraphic
; /// Picture or OLE placeholder graphic.
851 OUString maClassName
; /// Class name of embedded OLE object.
852 sal_uInt32 mnStorageId
; /// Identifier of the storage for this object.
853 std::size_t mnCtlsStrmPos
; /// Position in 'Ctls' stream for this control.
854 std::size_t mnCtlsStrmSize
; /// Size in 'Ctls' stream for this control.
855 bool mbEmbedded
; /// true = Embedded OLE object.
856 bool mbLinked
; /// true = Linked OLE object.
857 bool mbSymbol
; /// true = Show as symbol.
858 bool mbControl
; /// true = Form control, false = OLE object.
859 bool mbUseCtlsStrm
; /// true = Form control data in 'Ctls' stream, false = Own storage.
862 // DFF stream conversion ======================================================
864 /** The solver container collects all connector rules for connected objects. */
865 class XclImpSolverContainer
: public SvxMSDffSolverContainer
869 /** Inserts information about a new SdrObject. */
870 void InsertSdrObjectInfo( SdrObject
& rSdrObj
, sal_uInt32 nDffShapeId
, ShapeFlag nDffFlags
);
871 /** Removes information of an SdrObject (and all child objects if it is a group). */
872 void RemoveSdrObjectInfo( SdrObject
& rSdrObj
);
874 /** Inserts the SdrObject pointers into all connector rules. */
875 void UpdateConnectorRules();
876 /** Removes all contained connector rules. */
877 void RemoveConnectorRules();
880 /** Updates the data of a connected shape in a connector rule. */
881 void UpdateConnection( sal_uInt32 nDffShapeId
, SdrObject
*& rpSdrObj
, ShapeFlag
* pnDffFlags
= nullptr );
884 /** Stores data about an SdrObject processed during import. */
887 SdrObject
* mpSdrObj
; /// Pointer to an SdrObject.
888 ShapeFlag mnDffFlags
; /// Shape flags from DFF stream.
889 explicit XclImpSdrInfo() : mpSdrObj( nullptr ), mnDffFlags( ShapeFlag::NONE
) {}
890 void Set( SdrObject
* pSdrObj
, ShapeFlag nDffFlags
)
891 { mpSdrObj
= pSdrObj
; mnDffFlags
= nDffFlags
; }
893 typedef std::map
< sal_uInt32
, XclImpSdrInfo
> XclImpSdrInfoMap
;
894 typedef std::map
< SdrObject
*, sal_uInt32
> XclImpSdrObjMap
;
896 XclImpSdrInfoMap maSdrInfoMap
; /// Maps shape IDs to SdrObjects and flags.
897 XclImpSdrObjMap maSdrObjMap
; /// Maps SdrObjects to shape IDs.
900 /** Simple implementation of the SVX DFF manager. Implements resolving palette
901 colors. Used by XclImpDffPropSet (as is), extended by XclImpDffConverter.
903 class XclImpSimpleDffConverter
: public SvxMSDffManager
, protected XclImpRoot
906 explicit XclImpSimpleDffConverter( const XclImpRoot
& rRoot
, SvStream
& rDffStrm
);
907 virtual ~XclImpSimpleDffConverter() override
;
910 /** Returns a color from the Excel color palette. */
911 virtual bool GetColorFromPalette( sal_uInt16 nIndex
, Color
& rColor
) const override
;
914 /** This is the central instance for converting binary DFF data into shape
915 objects. Used for all sheet shapes and shapes embedded in chart objects.
917 The class derives from SvxMSDffManager and SvxMSConvertOCXControls and
918 contains core implementation of DFF stream import and OCX form control
921 class XclImpDffConverter
: public XclImpSimpleDffConverter
, private oox::ole::MSConvertOCXControls
924 explicit XclImpDffConverter( const XclImpRoot
& rRoot
, SvStream
& rDffStrm
);
925 virtual ~XclImpDffConverter() override
;
927 /** Initializes the internal progress bar with the passed size and starts it. */
928 void StartProgressBar( std::size_t nProgressSize
);
929 /** Increase the progress bar by the passed value. */
930 void Progress( std::size_t nDelta
= 1 );
932 /** Initially called before the objects of the passed drawing manager are converted. */
933 void InitializeDrawing( XclImpDrawing
& rDrawing
, SdrModel
& rSdrModel
, SdrPage
& rSdrPage
);
934 /** Processes BIFF5 drawing objects without DFF data, inserts into the passed object list. */
935 void ProcessObject( SdrObjList
& rObjList
, XclImpDrawObjBase
& rDrawObj
);
936 /** Processes all objects in the passed list. */
937 void ProcessDrawing( const XclImpDrawObjVector
& rDrawObjs
);
938 /** Processes a drawing container in the passed DFF stream, converts all objects. */
939 void ProcessDrawing( SvStream
& rDffStrm
);
940 /** Finally called after the objects of the passed drawing manager have been converted. */
941 void FinalizeDrawing();
943 /** Creates the SdrObject for the passed Excel TBX form control object. */
944 SdrObjectUniquePtr
CreateSdrObject( const XclImpTbxObjBase
& rTbxObj
, const tools::Rectangle
& rAnchorRect
);
945 /** Creates the SdrObject for the passed Excel OLE object or OCX form control object. */
946 SdrObjectUniquePtr
CreateSdrObject( const XclImpPictureObj
& rPicObj
, const tools::Rectangle
& rAnchorRect
);
948 /** Returns true, if the conversion of OLE objects is supported. */
949 bool SupportsOleObjects() const;
950 /** Returns the default text margin in drawing layer units. */
951 sal_Int32
GetDefaultTextMargin() const { return mnDefTextMargin
; }
954 // virtual functions of SvxMSDffManager
956 /** Reads the client anchor from the DFF stream and sets it at the correct object. */
957 virtual void ProcessClientAnchor2(
959 DffRecordHeader
& rHeader
,
960 DffObjData
& rObjData
) override
;
961 /** Processes a DFF object, reads properties from DFF stream. */
962 virtual SdrObject
* ProcessObj(
964 DffObjData
& rDffObjData
,
965 SvxMSDffClientData
& rClientData
,
966 tools::Rectangle
& rTextRect
,
967 SdrObject
* pOldSdrObj
) override
;
969 /** Finalize a DFF object, sets anchor after nested objs have been loaded. */
970 virtual SdrObject
* FinalizeObj(
971 DffObjData
& rDffObjData
,
972 SdrObject
* pOldSdrObj
) override
;
974 // virtual functions of SvxMSConvertOCXControls
976 /** Inserts the passed control rxFComp into the form. Needs call to SetCurrentForm() before. */
977 virtual bool InsertControl(
978 const css::uno::Reference
<
979 css::form::XFormComponent
>& rxFormComp
,
980 const css::awt::Size
& rSize
,
982 css::drawing::XShape
>* pxShape
,
983 bool bFloatingCtrl
) override
;
986 /** Data per registered drawing manager, will be stacked for recursive calls. */
987 struct XclImpDffConvData
989 XclImpDrawing
& mrDrawing
; /// Current drawing container with all drawing objects.
990 SdrModel
& mrSdrModel
; /// The SdrModel of the drawing manager.
991 SdrPage
& mrSdrPage
; /// The SdrPage of the drawing manager.
992 XclImpSolverContainer maSolverCont
; /// The solver container for connector rules.
993 css::uno::Reference
< css::form::XForm
>
994 mxCtrlForm
; /// Controls form of current drawing page.
995 sal_Int32 mnLastCtrlIndex
; /// Last insertion index of a form control (for macro events).
996 bool mbHasCtrlForm
; /// True = mxCtrlForm is initialized (but maybe still null).
998 explicit XclImpDffConvData( XclImpDrawing
& rDrawing
,
999 SdrModel
& rSdrModel
, SdrPage
& rSdrPage
);
1002 /** Returns the current drawing manager data struct from top of the stack. */
1003 XclImpDffConvData
& GetConvData();
1004 /** Returns the current drawing manager data struct from top of the stack. */
1005 const XclImpDffConvData
& GetConvData() const;
1007 /** Reads contents of a hyperlink property and returns the extracted URL. */
1008 OUString
ReadHlinkProperty( SvStream
& rDffStrm
) const;
1010 /** Processes a drawing container (all drawing data of a sheet). */
1011 bool ProcessDgContainer( SvStream
& rDffStrm
, const DffRecordHeader
& rDgHeader
);
1012 /** Processes the global shape group container (all shapes of a sheet). */
1013 bool ProcessShGrContainer( SvStream
& rDffStrm
, const DffRecordHeader
& rShGrHeader
);
1014 /** Processes the solver container (connectors of a sheet). */
1015 bool ProcessSolverContainer( SvStream
& rDffStrm
, const DffRecordHeader
& rSolverHeader
);
1016 /** Processes a shape or shape group container (one top-level shape). */
1017 bool ProcessShContainer( SvStream
& rDffStrm
, const DffRecordHeader
& rShHeader
);
1019 /** Inserts the passed SdrObject into the document. This function takes ownership of pSdrObj! */
1020 void InsertSdrObject( SdrObjList
& rObjList
, const XclImpDrawObjBase
& rDrawObj
, SdrObject
* pSdrObj
);
1021 /** Initializes the mxCtrlForm referring to the standard controls form. */
1022 void InitControlForm();
1023 /** Notify that this document contains a macro event handler */
1024 void NotifyMacroEventRead();
1027 typedef std::shared_ptr
< ScfProgressBar
> ScfProgressBarRef
;
1028 typedef std::shared_ptr
< XclImpDffConvData
> XclImpDffConvDataRef
;
1029 typedef std::vector
< XclImpDffConvDataRef
> XclImpDffConvDataStack
;
1031 tools::SvRef
<SotStorageStream
> mxCtlsStrm
; /// The 'Ctls' stream for OCX form controls.
1032 ScfProgressBarRef mxProgress
; /// The progress bar used in ProcessObj().
1033 XclImpDffConvDataStack maDataStack
; /// Stack for registered drawing managers.
1034 sal_uInt32 mnOleImpFlags
; /// Application OLE import settings.
1035 sal_Int32 mnDefTextMargin
; /// Default margin in text boxes.
1036 bool mbNotifyMacroEventRead
; /// If we have already seen a macro event
1039 // Drawing manager ============================================================
1041 /** Base class for a container for all objects on a drawing (spreadsheet or
1042 embedded chart object). */
1043 class XclImpDrawing
: protected XclImpRoot
1046 explicit XclImpDrawing( const XclImpRoot
& rRoot
, bool bOleObjects
);
1047 virtual ~XclImpDrawing() override
;
1049 /** Reads and returns a bitmap from the IMGDATA record. */
1050 static Graphic
ReadImgData( const XclImpRoot
& rRoot
, XclImpStream
& rStrm
);
1052 /** Reads a plain OBJ record (without leading DFF data). */
1053 void ReadObj( XclImpStream
& rStrm
);
1054 /** Reads the MSODRAWING or MSODRAWINGSELECTION record. */
1055 void ReadMsoDrawing( XclImpStream
& rStrm
);
1057 /** Returns true, if the conversion of OLE objects is supported. */
1058 bool SupportsOleObjects() const { return mbOleObjs
; }
1059 /** Finds the OBJ record data related to the DFF shape at the passed position. */
1060 XclImpDrawObjRef
FindDrawObj( const DffRecordHeader
& rHeader
) const;
1061 /** Finds the OBJ record data specified by the passed object identifier. */
1062 XclImpDrawObjRef
FindDrawObj( sal_uInt16 nObjId
) const;
1063 /** Finds the textbox data related to the DFF shape at the passed position. */
1064 const XclImpObjTextData
* FindTextData( const DffRecordHeader
& rHeader
) const;
1066 /** Sets the object with the passed identification to be skipped on import. */
1067 void SetSkipObj( sal_uInt16 nObjId
);
1068 /** Returns the size of the progress bar shown while processing all objects. */
1069 std::size_t GetProgressSize() const;
1071 /** Derived classes calculate the resulting rectangle of the passed anchor. */
1072 virtual tools::Rectangle
CalcAnchorRect( const XclObjAnchor
& rAnchor
, bool bDffAnchor
) const = 0;
1073 /** Called whenever an object has been inserted into the draw page. */
1074 virtual void OnObjectInserted( const XclImpDrawObjBase
& rDrawObj
) = 0;
1077 /** Appends a new drawing object to the list of raw objects (without DFF data). */
1078 void AppendRawObject( const XclImpDrawObjRef
& rxDrawObj
);
1079 /** Converts all objects and inserts them into the current drawing page. */
1080 void ImplConvertObjects( XclImpDffConverter
& rDffConv
, SdrModel
& rSdrModel
, SdrPage
& rSdrPage
);
1083 /** Reads and returns a bitmap from WMF/PICT format. */
1084 static void ReadWmf( Graphic
& rGraphic
, XclImpStream
& rStrm
);
1085 /** Reads and returns a bitmap from BMP format. */
1086 static void ReadBmp( Graphic
& rGraphic
, const XclImpRoot
& rRoot
, XclImpStream
& rStrm
);
1088 /** Reads contents of a DFF record and append data to internal DFF stream. */
1089 void ReadDffRecord( XclImpStream
& rStrm
);
1090 /** Reads a BIFF8 OBJ record following an MSODRAWING record. */
1091 void ReadObj8( XclImpStream
& rStrm
);
1092 /** Reads the TXO record and following CONTINUE records containing string and formatting. */
1093 void ReadTxo( XclImpStream
& rStrm
);
1096 typedef std::map
< std::size_t, XclImpDrawObjRef
> XclImpObjMap
;
1097 typedef std::map
< sal_uInt16
, XclImpDrawObjRef
> XclImpObjMapById
;
1098 typedef std::shared_ptr
< XclImpObjTextData
> XclImpObjTextRef
;
1099 typedef std::map
< std::size_t, XclImpObjTextRef
> XclImpObjTextMap
;
1101 XclImpDrawObjVector maRawObjs
; /// BIFF5 objects without DFF data.
1102 SvMemoryStream maDffStrm
; /// Copy of the DFF page stream in memory.
1103 XclImpObjMap maObjMap
; /// Maps BIFF8 drawing objects to DFF stream position.
1104 XclImpObjMapById maObjMapId
; /// Maps BIFF8 drawing objects to object ID.
1105 XclImpObjTextMap maTextMap
; /// Maps BIFF8 TXO textbox data to DFF stream position.
1106 ScfUInt16Vec maSkipObjs
; /// IDs of all objects to be skipped.
1107 bool const mbOleObjs
; /// True = draw model supports OLE objects.
1110 /** Drawing manager of a single sheet. */
1111 class XclImpSheetDrawing
: public XclImpDrawing
1114 explicit XclImpSheetDrawing( const XclImpRoot
& rRoot
, SCTAB nScTab
);
1116 /** Reads the NOTE record. */
1117 void ReadNote( XclImpStream
& rStrm
);
1118 /** Inserts a new chart object and reads the chart substream (BOF/EOF block).
1119 @descr Used to import chart sheets, which do not have a corresponding OBJ record. */
1120 void ReadTabChart( XclImpStream
& rStrm
);
1122 /** Returns the total cell range covered by any shapes in the sheet. */
1123 const ScRange
& GetUsedArea() const { return maScUsedArea
; }
1124 /** Converts all objects and inserts them into the sheet drawing page. */
1125 void ConvertObjects( XclImpDffConverter
& rDffConv
);
1127 /** Calculate the resulting rectangle of the passed anchor. */
1128 virtual tools::Rectangle
CalcAnchorRect( const XclObjAnchor
& rAnchor
, bool bDffAnchor
) const override
;
1129 /** On call, updates the used area of the sheet. */
1130 virtual void OnObjectInserted( const XclImpDrawObjBase
& rDrawObj
) override
;
1133 /** Reads a BIFF3-BIFF5 NOTE record. */
1134 void ReadNote3( XclImpStream
& rStrm
);
1135 /** Reads a BIFF8 NOTE record. */
1136 void ReadNote8( XclImpStream
& rStrm
);
1139 ScRange maScUsedArea
; /// Sheet index and used area in this sheet.
1142 // The object manager =========================================================
1144 /** Stores all drawing and OLE objects and additional data related to these objects. */
1145 class XclImpObjectManager
: protected XclImpRoot
1148 explicit XclImpObjectManager( const XclImpRoot
& rRoot
);
1149 virtual ~XclImpObjectManager() override
;
1151 /** Reads the MSODRAWINGGROUP record. */
1152 void ReadMsoDrawingGroup( XclImpStream
& rStrm
);
1154 /** Returns (initially creates) the drawing manager of the specified sheet. */
1155 XclImpSheetDrawing
& GetSheetDrawing( SCTAB nScTab
);
1156 /** Inserts all objects into the Calc document. */
1157 void ConvertObjects();
1159 /** Returns the default name for the passed object. */
1160 OUString
GetDefaultObjName( const XclImpDrawObjBase
& rDrawObj
) const;
1161 /** Returns the used area in the sheet with the passed index. */
1162 ScRange
GetUsedArea( SCTAB nScTab
) const;
1163 /** Sets the container to receive overridden shape/ctrl names from
1165 void SetOleNameOverrideInfo( const css::uno::Reference
< css::container::XNameContainer
>& rxOverrideInfo
) { mxOleCtrlNameOverride
= rxOverrideInfo
; }
1166 /** Returns the name of overridden name ( or zero length string ) for
1167 associated object id. */
1168 OUString
GetOleNameOverride( SCTAB nTab
, sal_uInt16 nObjId
);
1171 typedef std::map
< sal_uInt16
, OUString
> DefObjNameMap
;
1172 typedef std::shared_ptr
< XclImpSheetDrawing
> XclImpSheetDrawingRef
;
1173 typedef std::map
< SCTAB
, XclImpSheetDrawingRef
> XclImpSheetDrawingMap
;
1175 css::uno::Reference
< css::container::XNameContainer
> mxOleCtrlNameOverride
;
1176 DefObjNameMap maDefObjNames
; /// Default base names for all object types.
1177 SvMemoryStream maDggStrm
; /// Copy of global DFF data (DGG container) in memory.
1178 XclImpSheetDrawingMap maSheetDrawings
; /// Drawing managers of all sheets.
1181 // DFF property set helper ====================================================
1183 /** This class reads a DFF property set (msofbtOPT record).
1185 It can return separate property values or an item set which contains items
1186 translated from these properties.
1188 class XclImpDffPropSet
: protected XclImpRoot
1191 explicit XclImpDffPropSet( const XclImpRoot
& rRoot
);
1193 /** Reads a DFF property set from the stream.
1194 @descr The stream must point to the start of a DFF record containing properties. */
1195 void Read( XclImpStream
& rStrm
);
1197 /** Returns the specified property or zero, if not extant. */
1198 sal_uInt32
GetPropertyValue( sal_uInt16 nPropId
) const;
1200 /** Translates the properties and fills the item set. */
1201 void FillToItemSet( SfxItemSet
& rItemSet
) const;
1204 typedef std::unique_ptr
<SvMemoryStream
> SvMemoryStreamPtr
;
1206 SvMemoryStream maDummyStrm
; /// Dummy DGG stream for DFF manager.
1207 XclImpSimpleDffConverter
const maDffConv
; /// DFF converter used to resolve palette colors.
1208 SvMemoryStreamPtr mxMemStrm
; /// Helper stream.
1211 XclImpStream
& operator>>( XclImpStream
& rStrm
, XclImpDffPropSet
& rPropSet
);
1215 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */