fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / filter / inc / xiescher.hxx
blobebf7792a248bf6fc4832ed2a696c11a4015db123
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_SC_SOURCE_FILTER_INC_XIESCHER_HXX
21 #define INCLUDED_SC_SOURCE_FILTER_INC_XIESCHER_HXX
23 #include <vector>
24 #include <map>
25 #include <filter/msfilter/msdffimp.hxx>
26 #include <vcl/graph.hxx>
27 #include "xlescher.hxx"
28 #include "xiroot.hxx"
29 #include "xistring.hxx"
30 #include <boost/shared_ptr.hpp>
31 #include <boost/scoped_ptr.hpp>
32 #include <oox/ole/olehelper.hxx>
33 #include <rtl/ustring.hxx>
35 namespace com { namespace sun { namespace star {
36 namespace drawing { class XShape; }
37 namespace form { class XForm; }
38 } } }
40 class SdrObjList;
41 class ScfProgressBar;
42 class ScfPropertySet;
43 class ScRangeList;
44 class XclImpChart;
45 class XclImpDffConverter;
46 class XclImpDrawing;
48 // Drawing objects ============================================================
50 class XclImpDrawObjBase;
51 typedef boost::shared_ptr< XclImpDrawObjBase > XclImpDrawObjRef;
53 /** Base class for drawing objects (OBJ records). */
54 class XclImpDrawObjBase : protected XclImpRoot
56 public:
57 explicit XclImpDrawObjBase( const XclImpRoot& rRoot );
58 virtual ~XclImpDrawObjBase();
60 /** Reads the BIFF3 OBJ record, returns a new drawing object. */
61 static XclImpDrawObjRef ReadObj3( const XclImpRoot& rRoot, XclImpStream& rStrm );
62 /** Reads the BIFF4 OBJ record, returns a new drawing object. */
63 static XclImpDrawObjRef ReadObj4( const XclImpRoot& rRoot, XclImpStream& rStrm );
64 /** Reads the BIFF5 OBJ record, returns a new drawing object. */
65 static XclImpDrawObjRef ReadObj5( const XclImpRoot& rRoot, XclImpStream& rStrm );
66 /** Reads the BIFF8 OBJ record, returns a new drawing object. */
67 static XclImpDrawObjRef ReadObj8( const XclImpRoot& rRoot, XclImpStream& rStrm );
69 /** Sets whether this is an area object (then its width and height must be greater than 0). */
70 inline void SetAreaObj( bool bAreaObj ) { mbAreaObj = bAreaObj; }
71 /** If set to true, a new SdrObject will be created while in DFF import. */
72 inline void SetSimpleMacro( bool bMacro ) { mbSimpleMacro = bMacro; }
74 /** Sets the object anchor explicitly. */
75 void SetAnchor( const XclObjAnchor& rAnchor );
76 /** Sets shape data from DFF stream. */
77 void SetDffData(
78 const DffObjData& rDffObjData, const OUString& rObjName, const OUString& rHyperlink,
79 bool bVisible, bool bAutoMargin );
81 /** If set to false, the SdrObject will not be created, processed, or inserted into the draw page. */
82 inline void SetProcessSdrObj( bool bProcess ) { mbProcessSdr = bProcess; }
83 /** If set to false, the SdrObject will be created or processed, but not be inserted into the draw page. */
84 inline void SetInsertSdrObj( bool bInsert ) { mbInsertSdr = bInsert; }
85 /** If set to true, a new SdrObject will be created while in DFF import. */
86 inline void SetCustomDffObj( bool bCustom ) { mbCustomDff = bCustom; }
88 /** Returns the sheet index and Excel object identifier from OBJ record. */
89 inline sal_uInt16 GetObjId() const { return mnObjId; }
90 /** Returns the Excel object type from OBJ record. */
91 inline sal_uInt16 GetObjType() const { return mnObjType; }
92 /** Returns the name of this object, may generate a default name. */
93 virtual OUString GetObjName() const;
94 /** Returns associated macro name, if set, otherwise zero length string. */
95 inline const OUString& GetMacroName() const { return maMacroName; }
97 /** Returns the shape identifier used in the DFF stream. */
98 inline sal_uInt32 GetDffShapeId() const { return mnDffShapeId; }
99 /** Returns the shape flags from the DFF stream. */
100 inline sal_uInt32 GetDffFlags() const { return mnDffFlags; }
102 /** Returns true, if the object is hidden. */
103 inline bool IsHidden() const { return mbHidden; }
104 /** Returns true, if the object is visible. */
105 inline bool IsVisible() const { return mbVisible; }
106 /** Returns true, if the object is printable. */
107 inline bool IsPrintable() const { return mbPrintable; }
109 /** Returns the object anchor if existing, null otherwise. */
110 const XclObjAnchor* GetAnchor() const;
111 /** Returns true, if the passed size is valid for this object. */
112 bool IsValidSize( const Rectangle& rAnchorRect ) const;
113 /** Returns the range in the sheet covered by this object. */
114 ScRange GetUsedArea( SCTAB nScTab ) const;
116 /** Returns true, if the object is valid and will be processed. */
117 inline bool IsProcessSdrObj() const { return mbProcessSdr && !mbHidden; }
118 /** Returns true, if the SdrObject will be created or processed, but not be inserted into the draw page. */
119 inline bool IsInsertSdrObj() const { return mbInsertSdr; }
121 /** Returns the needed size on the progress bar (calls virtual DoGetProgressSize() function). */
122 sal_Size GetProgressSize() const;
123 /** Creates and returns an SdrObject from the contained data. Caller takes ownership! */
124 SdrObject* CreateSdrObject( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect, bool bIsDff ) const;
125 /** Additional processing for the passed SdrObject before insertion into
126 the drawing page (calls virtual DoPreProcessSdrObj() function). */
127 void PreProcessSdrObject( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const;
128 /** Additional processing for the passed SdrObject after insertion into the
129 drawing page (calls virtual DoPostProcessSdrObj() function). */
130 void PostProcessSdrObject( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const;
131 SCTAB GetTab() const { return mnTab; }
133 protected:
134 /** Reads the object name in a BIFF5 OBJ record. */
135 void ReadName5( XclImpStream& rStrm, sal_uInt16 nNameLen );
136 /** Reads the macro link in a BIFF3 OBJ record. */
137 void ReadMacro3( XclImpStream& rStrm, sal_uInt16 nMacroSize );
138 /** Reads the macro link in a BIFF4 OBJ record. */
139 void ReadMacro4( XclImpStream& rStrm, sal_uInt16 nMacroSize );
140 /** Reads the macro link in a BIFF5 OBJ record. */
141 void ReadMacro5( XclImpStream& rStrm, sal_uInt16 nMacroSize );
142 /** Reads the contents of the ftMacro sub structure in an OBJ record. */
143 void ReadMacro8( XclImpStream& rStrm );
145 /** Converts the passed line formatting to the passed SdrObject. */
146 void ConvertLineStyle( SdrObject& rSdrObj, const XclObjLineData& rLineData ) const;
147 /** Converts the passed fill formatting to the passed SdrObject. */
148 void ConvertFillStyle( SdrObject& rSdrObj, const XclObjFillData& rFillData ) const;
149 /** Converts the passed frame flags to the passed SdrObject. */
150 void ConvertFrameStyle( SdrObject& rSdrObj, sal_uInt16 nFrameFlags ) const;
152 /** Returns a solid line color from the passed line data struct. */
153 Color GetSolidLineColor( const XclObjLineData& rLineData ) const;
154 /** Returns a solid fill color from the passed fill data struct. */
155 Color GetSolidFillColor( const XclObjFillData& rFillData ) const;
157 /** Derived classes read the contents of the a BIFF3 OBJ record from the passed stream. */
158 virtual void DoReadObj3( XclImpStream& rStrm, sal_uInt16 nMacroSize );
159 /** Derived classes read the contents of the a BIFF4 OBJ record from the passed stream. */
160 virtual void DoReadObj4( XclImpStream& rStrm, sal_uInt16 nMacroSize );
161 /** Derived classes read the contents of the a BIFF5 OBJ record from the passed stream. */
162 virtual void DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize );
163 /** Derived classes read the contents of the specified subrecord of a BIFF8 OBJ record from stream. */
164 virtual void DoReadObj8SubRec( XclImpStream& rStrm, sal_uInt16 nSubRecId, sal_uInt16 nSubRecSize );
166 /** Derived classes may return a progress bar size different from 1. */
167 virtual sal_Size DoGetProgressSize() const;
168 /** Derived classes create and return a new SdrObject from the contained data. Caller takes ownership! */
169 virtual SdrObject* DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const;
170 /** Derived classes may perform additional processing for the passed SdrObject before insertion. */
171 virtual void DoPreProcessSdrObj( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const;
172 /** Derived classes may perform additional processing for the passed SdrObject after insertion. */
173 virtual void DoPostProcessSdrObj( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const;
174 private:
175 /** Reads the contents of a BIFF3 OBJ record. */
176 void ImplReadObj3( XclImpStream& rStrm );
177 /** Reads the contents of a BIFF4 OBJ record. */
178 void ImplReadObj4( XclImpStream& rStrm );
179 /** Reads the contents of a BIFF5 OBJ record. */
180 void ImplReadObj5( XclImpStream& rStrm );
181 /** Reads the contents of a BIFF8 OBJ record. */
182 void ImplReadObj8( XclImpStream& rStrm );
184 private:
185 XclObjAnchor maAnchor; /// The position of the object in its parent.
186 sal_uInt16 mnObjId; /// The object identifier (unique per drawing).
187 SCTAB mnTab; /// Location of object
188 sal_uInt16 mnObjType; /// The Excel object type from OBJ record.
189 sal_uInt32 mnDffShapeId; /// Shape ID from DFF stream.
190 sal_uInt32 mnDffFlags; /// Shape flags from DFF stream.
191 OUString maObjName; /// Name of the object.
192 OUString maMacroName; /// Name of an attached macro.
193 OUString maHyperlink; /// On-click hyperlink URL.
194 bool mbHasAnchor; /// true = maAnchor is initialized.
195 bool mbHidden; /// true = Object is hidden.
196 bool mbVisible; /// true = Object is visible.
197 bool mbPrintable; /// true = Object is printable.
198 bool mbAreaObj; /// true = Width and height must be greater than 0.
199 bool mbAutoMargin; /// true = Set automatic text margin.
200 bool mbSimpleMacro; /// true = Create simple macro link and hyperlink.
201 bool mbProcessSdr; /// true = Object is valid, do processing and insertion.
202 bool mbInsertSdr; /// true = Insert the SdrObject into draw page.
203 bool mbCustomDff; /// true = Recreate SdrObject in DFF import.
206 class XclImpDrawObjVector
208 private:
209 ::std::vector< XclImpDrawObjRef > mObjs;
211 public:
212 inline explicit XclImpDrawObjVector() : mObjs() {}
214 ::std::vector< XclImpDrawObjRef >::const_iterator begin() const { return mObjs.begin(); }
215 ::std::vector< XclImpDrawObjRef >::const_iterator end() const { return mObjs.end(); }
216 void push_back(const XclImpDrawObjRef& rObj) { mObjs.push_back(rObj); }
218 /** Tries to insert the passed object into the last group or appends it. */
219 void InsertGrouped( XclImpDrawObjRef xDrawObj );
221 /** Returns the needed size on the progress bar for all contained objects. */
222 sal_Size GetProgressSize() const;
225 /** A placeholder object for unknown object types. */
226 class XclImpPhObj : public XclImpDrawObjBase
228 public:
229 explicit XclImpPhObj( const XclImpRoot& rRoot );
232 /** A group object. */
233 class XclImpGroupObj : public XclImpDrawObjBase
235 public:
236 explicit XclImpGroupObj( const XclImpRoot& rRoot );
238 /** Tries to insert the drawing object into this or a nested group. */
239 bool TryInsert( XclImpDrawObjRef xDrawObj );
241 protected:
242 /** Reads the contents of the a BIFF3 OBJ record from the passed stream. */
243 virtual void DoReadObj3( XclImpStream& rStrm, sal_uInt16 nMacroSize ) SAL_OVERRIDE;
244 /** Reads the contents of the a BIFF4 OBJ record from the passed stream. */
245 virtual void DoReadObj4( XclImpStream& rStrm, sal_uInt16 nMacroSize ) SAL_OVERRIDE;
246 /** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
247 virtual void DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize ) SAL_OVERRIDE;
248 /** Returns a progress bar size that takes all group children into account. */
249 virtual sal_Size DoGetProgressSize() const SAL_OVERRIDE;
250 /** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */
251 virtual SdrObject* DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const SAL_OVERRIDE;
253 protected:
254 XclImpDrawObjVector maChildren; /// Grouped objects.
255 sal_uInt16 mnFirstUngrouped; /// Object identfier of first object not grouped into this group.
258 /** A line object. */
259 class XclImpLineObj : public XclImpDrawObjBase
261 public:
262 explicit XclImpLineObj( const XclImpRoot& rRoot );
264 protected:
265 /** Reads the contents of the a BIFF3 OBJ record from the passed stream. */
266 virtual void DoReadObj3( XclImpStream& rStrm, sal_uInt16 nMacroSize ) SAL_OVERRIDE;
267 /** Reads the contents of the a BIFF4 OBJ record from the passed stream. */
268 virtual void DoReadObj4( XclImpStream& rStrm, sal_uInt16 nMacroSize ) SAL_OVERRIDE;
269 /** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
270 virtual void DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize ) SAL_OVERRIDE;
271 /** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */
272 virtual SdrObject* DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const SAL_OVERRIDE;
274 protected:
275 XclObjLineData maLineData; /// BIFF5 line formatting.
276 sal_uInt16 mnArrows; /// Line arrows.
277 sal_uInt8 mnStartPoint; /// Starting point.
280 /** A rectangle or oval object. */
281 class XclImpRectObj : public XclImpDrawObjBase
283 public:
284 explicit XclImpRectObj( const XclImpRoot& rRoot );
286 protected:
287 /** Reads fil data, line data, and frame flags. */
288 void ReadFrameData( XclImpStream& rStrm );
290 /** Converts fill formatting, line formattind, and frame style. */
291 void ConvertRectStyle( SdrObject& rSdrObj ) const;
293 /** Reads the contents of the a BIFF3 OBJ record from the passed stream. */
294 virtual void DoReadObj3( XclImpStream& rStrm, sal_uInt16 nMacroSize ) SAL_OVERRIDE;
295 /** Reads the contents of the a BIFF4 OBJ record from the passed stream. */
296 virtual void DoReadObj4( XclImpStream& rStrm, sal_uInt16 nMacroSize ) SAL_OVERRIDE;
297 /** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
298 virtual void DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize ) SAL_OVERRIDE;
299 /** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */
300 virtual SdrObject* DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const SAL_OVERRIDE;
302 protected:
303 XclObjFillData maFillData; /// BIFF5 fill formatting.
304 XclObjLineData maLineData; /// BIFF5 line formatting.
305 sal_uInt16 mnFrameFlags; /// Additional flags.
308 /** An oval object. */
309 class XclImpOvalObj : public XclImpRectObj
311 public:
312 explicit XclImpOvalObj( const XclImpRoot& rRoot );
314 protected:
315 /** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */
316 virtual SdrObject* DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const SAL_OVERRIDE;
319 /** An arc object. */
320 class XclImpArcObj : public XclImpDrawObjBase
322 public:
323 explicit XclImpArcObj( const XclImpRoot& rRoot );
325 protected:
326 /** Reads the contents of the a BIFF3 OBJ record from the passed stream. */
327 virtual void DoReadObj3( XclImpStream& rStrm, sal_uInt16 nMacroSize ) SAL_OVERRIDE;
328 /** Reads the contents of the a BIFF4 OBJ record from the passed stream. */
329 virtual void DoReadObj4( XclImpStream& rStrm, sal_uInt16 nMacroSize ) SAL_OVERRIDE;
330 /** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
331 virtual void DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize ) SAL_OVERRIDE;
332 /** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */
333 virtual SdrObject* DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const SAL_OVERRIDE;
335 protected:
336 XclObjFillData maFillData; /// BIFF5 fill formatting.
337 XclObjLineData maLineData; /// BIFF5 line formatting.
338 sal_uInt8 mnQuadrant; /// Visible quadrant of the circle.
341 /** A polygon object. */
342 class XclImpPolygonObj : public XclImpRectObj
344 public:
345 explicit XclImpPolygonObj( const XclImpRoot& rRoot );
347 protected:
348 /** Reads the COORDLIST record following the OBJ record. */
349 void ReadCoordList( XclImpStream& rStrm );
351 /** Reads the contents of the a BIFF4 OBJ record from the passed stream. */
352 virtual void DoReadObj4( XclImpStream& rStrm, sal_uInt16 nMacroSize ) SAL_OVERRIDE;
353 /** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
354 virtual void DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize ) SAL_OVERRIDE;
355 /** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */
356 virtual SdrObject* DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const SAL_OVERRIDE;
358 protected:
359 typedef ::std::vector< Point > PointVector;
360 PointVector maCoords; /// Coordinates relative to bounding rectangle.
361 sal_uInt16 mnPolyFlags; /// Additional flags.
362 sal_uInt16 mnPointCount; /// Polygon point count.
365 struct XclImpObjTextData
367 XclObjTextData maData; /// BIFF5 text data.
368 XclImpStringRef mxString; /// Plain or rich string.
370 /** Reads a byte string from the passed stream. */
371 void ReadByteString( XclImpStream& rStrm );
372 /** Reads text formatting from the passed stream. */
373 void ReadFormats( XclImpStream& rStrm );
376 /** A drawing object supporting text contents. Used for all simple objects in BIFF8. */
377 class XclImpTextObj : public XclImpRectObj
379 public:
380 explicit XclImpTextObj( const XclImpRoot& rRoot );
382 /** Stores the passed textbox data. */
383 inline void SetTextData( const XclImpObjTextData& rTextData ) { maTextData = rTextData; }
385 protected:
386 /** Reads the contents of the a BIFF3 OBJ record from the passed stream. */
387 virtual void DoReadObj3( XclImpStream& rStrm, sal_uInt16 nMacroSize ) SAL_OVERRIDE;
388 /** Reads the contents of the a BIFF4 OBJ record from the passed stream. */
389 virtual void DoReadObj4( XclImpStream& rStrm, sal_uInt16 nMacroSize ) SAL_OVERRIDE;
390 /** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
391 virtual void DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize ) SAL_OVERRIDE;
392 /** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */
393 virtual SdrObject* DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const SAL_OVERRIDE;
394 /** Inserts the contained text data at the passed object. */
395 virtual void DoPreProcessSdrObj( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const SAL_OVERRIDE;
397 protected:
398 XclImpObjTextData maTextData; /// Textbox data from BIFF5 OBJ or BIFF8 TXO record.
401 /** A chart object. This is the drawing object wrapper for the chart data. */
402 class XclImpChartObj : public XclImpRectObj
404 public:
405 /** @param bOwnTab True = chart is on an own sheet; false = chart is an embedded object. */
406 explicit XclImpChartObj( const XclImpRoot& rRoot, bool bOwnTab = false );
408 /** Reads the complete chart substream (BOF/EOF block). */
409 void ReadChartSubStream( XclImpStream& rStrm );
411 protected:
412 /** Reads the contents of the a BIFF3 OBJ record from the passed stream. */
413 virtual void DoReadObj3( XclImpStream& rStrm, sal_uInt16 nMacroSize ) SAL_OVERRIDE;
414 /** Reads the contents of the a BIFF4 OBJ record from the passed stream. */
415 virtual void DoReadObj4( XclImpStream& rStrm, sal_uInt16 nMacroSize ) SAL_OVERRIDE;
416 /** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
417 virtual void DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize ) SAL_OVERRIDE;
418 /** Reads the contents of the specified subrecord of a BIFF8 OBJ record from stream. */
419 virtual void DoReadObj8SubRec( XclImpStream& rStrm, sal_uInt16 nSubRecId, sal_uInt16 nSubRecSize ) SAL_OVERRIDE;
420 /** Returns the needed size on the progress bar. */
421 virtual sal_Size DoGetProgressSize() const SAL_OVERRIDE;
422 /** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */
423 virtual SdrObject* DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const SAL_OVERRIDE;
424 /** Converts the chart document. */
425 virtual void DoPostProcessSdrObj( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const SAL_OVERRIDE;
427 private:
428 /** Calculates the object anchor of a sheet chart (chart fills one page). */
429 void FinalizeTabChart();
431 private:
432 typedef boost::shared_ptr< XclImpChart > XclImpChartRef;
434 XclImpChartRef mxChart; /// The chart itself (BOF/EOF substream data).
435 bool mbOwnTab; /// true = own sheet; false = embedded object.
438 /** A note object, which is a specialized text box objext. */
439 class XclImpNoteObj : public XclImpTextObj
441 public:
442 explicit XclImpNoteObj( const XclImpRoot& rRoot );
444 /** Sets note flags and the note position in the Calc sheet. */
445 void SetNoteData( const ScAddress& rScPos, sal_uInt16 nNoteFlags );
447 protected:
448 /** Inserts the note into the document, sets visibility. */
449 virtual void DoPreProcessSdrObj( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const SAL_OVERRIDE;
451 private:
452 ScAddress maScPos; /// Cell position of the note object.
453 sal_uInt16 mnNoteFlags; /// Flags from NOTE record.
456 /** Helper base class for TBX and OCX form controls to manage spreadsheet links. */
457 class XclImpControlHelper
459 public:
460 explicit XclImpControlHelper( const XclImpRoot& rRoot, XclCtrlBindMode eBindMode );
461 virtual ~XclImpControlHelper();
463 /** Returns true, if a linked cell address is present. */
464 inline bool HasCellLink() const { return mxCellLink != 0; }
465 /** Returns true, if a linked source cell range is present. */
466 inline bool HasSourceRange() const { return mxSrcRange != 0; }
468 /** Returns the SdrObject from the passed control shape and sets the bounding rectangle. */
469 SdrObject* CreateSdrObjectFromShape(
470 const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& rxShape,
471 const Rectangle& rAnchorRect ) const;
473 /** Sets additional properties to the form control model, calls virtual DoProcessControl(). */
474 void ProcessControl( const XclImpDrawObjBase& rDrawObj ) const;
476 protected:
477 /** Reads the formula for the linked cell from the current position of the stream. */
478 void ReadCellLinkFormula( XclImpStream& rStrm, bool bWithBoundSize );
479 /** Reads the formula for the source range from the current position of the stream. */
480 void ReadSourceRangeFormula( XclImpStream& rStrm, bool bWithBoundSize );
482 /** Derived classes will set additional properties for the current form control. */
483 virtual void DoProcessControl( ScfPropertySet& rPropSet ) const;
485 void ApplySheetLinkProps() const;
486 mutable ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
487 mxShape; /// The UNO wrapper of the control shape.
488 boost::shared_ptr< ScAddress > mxCellLink; /// Linked cell in the Calc document.
489 private:
490 /** Reads a list of cell ranges from a formula at the current stream position. */
491 void ReadRangeList( ScRangeList& rScRanges, XclImpStream& rStrm );
492 /** Reads leading formula size and a list of cell ranges from a formula if the leading size is not zero. */
493 void ReadRangeList( ScRangeList& rScRanges, XclImpStream& rStrm, bool bWithBoundSize );
495 private:
496 const XclImpRoot& mrRoot; /// Not derived from XclImpRoot to allow multiple inheritance.
497 boost::shared_ptr< ScRange > mxSrcRange; /// Source data range in the Calc document.
498 XclCtrlBindMode meBindMode; /// Value binding mode.
501 /** Base class for textbox based form controls. */
502 class XclImpTbxObjBase : public XclImpTextObj, public XclImpControlHelper
504 public:
505 explicit XclImpTbxObjBase( const XclImpRoot& rRoot );
507 /** Sets line and fill formatting from the passed DFF property set. */
508 void SetDffProperties( const DffPropSet& rDffPropSet );
510 /** Returns the service name of the control component to be created. */
511 inline OUString GetServiceName() const { return DoGetServiceName(); }
512 /** Fills the passed macro event descriptor. */
513 bool FillMacroDescriptor(
514 ::com::sun::star::script::ScriptEventDescriptor& rDescriptor ) const;
516 protected:
517 /** Sets control text formatting. */
518 void ConvertFont( ScfPropertySet& rPropSet ) const;
519 /** Sets control label and text formatting. */
520 void ConvertLabel( ScfPropertySet& rPropSet ) const;
522 /** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */
523 virtual SdrObject* DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const SAL_OVERRIDE;
524 /** Additional processing on the SdrObject, calls new virtual function DoProcessControl(). */
525 virtual void DoPreProcessSdrObj( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const SAL_OVERRIDE;
527 /** Derived classes return the service name of the control component to be created. */
528 virtual OUString DoGetServiceName() const = 0;
529 /** Derived classes return the type of the macro event to be created. */
530 virtual XclTbxEventType DoGetEventType() const = 0;
533 /** A button control. */
534 class XclImpButtonObj : public XclImpTbxObjBase
536 public:
537 explicit XclImpButtonObj( const XclImpRoot& rRoot );
539 protected:
540 /** Sets additional properties for the current form control. */
541 virtual void DoProcessControl( ScfPropertySet& rPropSet ) const SAL_OVERRIDE;
542 /** Returns the service name of the control component to be created. */
543 virtual OUString DoGetServiceName() const SAL_OVERRIDE;
544 /** Returns the type of the macro event to be created. */
545 virtual XclTbxEventType DoGetEventType() const SAL_OVERRIDE;
548 /** A checkbox control. */
549 class XclImpCheckBoxObj : public XclImpTbxObjBase
551 public:
552 explicit XclImpCheckBoxObj( const XclImpRoot& rRoot );
554 protected:
555 /** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
556 virtual void DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize ) SAL_OVERRIDE;
557 /** Reads the contents of the specified subrecord of a BIFF8 OBJ record from stream. */
558 virtual void DoReadObj8SubRec( XclImpStream& rStrm, sal_uInt16 nSubRecId, sal_uInt16 nSubRecSize ) SAL_OVERRIDE;
559 /** Sets additional properties for the current form control. */
560 virtual void DoProcessControl( ScfPropertySet& rPropSet ) const SAL_OVERRIDE;
561 /** Returns the service name of the control component to be created. */
562 virtual OUString DoGetServiceName() const SAL_OVERRIDE;
563 /** Returns the type of the macro event to be created. */
564 virtual XclTbxEventType DoGetEventType() const SAL_OVERRIDE;
566 protected:
567 sal_uInt16 mnState;
568 sal_uInt16 mnCheckBoxFlags;
571 /** An option button control. */
572 class XclImpOptionButtonObj : public XclImpCheckBoxObj
574 public:
575 explicit XclImpOptionButtonObj( const XclImpRoot& rRoot );
577 protected:
578 /** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
579 virtual void DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize ) SAL_OVERRIDE;
580 /** Reads the contents of the specified subrecord of a BIFF8 OBJ record from stream. */
581 virtual void DoReadObj8SubRec( XclImpStream& rStrm, sal_uInt16 nSubRecId, sal_uInt16 nSubRecSize ) SAL_OVERRIDE;
582 /** Sets additional properties for the current form control. */
583 virtual void DoProcessControl( ScfPropertySet& rPropSet ) const SAL_OVERRIDE;
584 /** Returns the service name of the control component to be created. */
585 virtual OUString DoGetServiceName() const SAL_OVERRIDE;
586 /** Returns the type of the macro event to be created. */
587 virtual XclTbxEventType DoGetEventType() const SAL_OVERRIDE;
589 protected:
590 void ApplyGrouping( XclImpOptionButtonObj& rLeader, sal_Int32 nRefVal );
591 sal_uInt16 mnNextInGroup; /// Next option button in a group.
592 sal_uInt16 mnFirstInGroup; /// 1 = Button is the first in a group.
595 /** A label control. */
596 class XclImpLabelObj : public XclImpTbxObjBase
598 public:
599 explicit XclImpLabelObj( const XclImpRoot& rRoot );
601 protected:
602 /** Sets additional properties for the current form control. */
603 virtual void DoProcessControl( ScfPropertySet& rPropSet ) const SAL_OVERRIDE;
604 /** Returns the service name of the control component to be created. */
605 virtual OUString DoGetServiceName() const SAL_OVERRIDE;
606 /** Returns the type of the macro event to be created. */
607 virtual XclTbxEventType DoGetEventType() const SAL_OVERRIDE;
610 /** A groupbox control. */
611 class XclImpGroupBoxObj : public XclImpTbxObjBase
613 public:
614 explicit XclImpGroupBoxObj( const XclImpRoot& rRoot );
616 protected:
617 /** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
618 virtual void DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize ) SAL_OVERRIDE;
619 /** Reads the contents of the specified subrecord of a BIFF8 OBJ record from stream. */
620 virtual void DoReadObj8SubRec( XclImpStream& rStrm, sal_uInt16 nSubRecId, sal_uInt16 nSubRecSize ) SAL_OVERRIDE;
621 /** Sets additional properties for the current form control. */
622 virtual void DoProcessControl( ScfPropertySet& rPropSet ) const SAL_OVERRIDE;
623 /** Returns the service name of the control component to be created. */
624 virtual OUString DoGetServiceName() const SAL_OVERRIDE;
625 /** Returns the type of the macro event to be created. */
626 virtual XclTbxEventType DoGetEventType() const SAL_OVERRIDE;
628 protected:
629 sal_uInt16 mnGroupBoxFlags;
632 /** A dialog control. */
633 class XclImpDialogObj : public XclImpTbxObjBase
635 public:
636 explicit XclImpDialogObj( const XclImpRoot& rRoot );
638 protected:
639 /** Sets additional properties for the current form control. */
640 virtual void DoProcessControl( ScfPropertySet& rPropSet ) const SAL_OVERRIDE;
641 /** Returns the service name of the control component to be created. */
642 virtual OUString DoGetServiceName() const SAL_OVERRIDE;
643 /** Returns the type of the macro event to be created. */
644 virtual XclTbxEventType DoGetEventType() const SAL_OVERRIDE;
647 /** An edit control. */
648 class XclImpEditObj : public XclImpTbxObjBase
650 public:
651 explicit XclImpEditObj( const XclImpRoot& rRoot );
653 protected:
654 /** REturns true, if the field type is numeric. */
655 bool IsNumeric() const;
657 /** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
658 virtual void DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize ) SAL_OVERRIDE;
659 /** Reads the contents of the specified subrecord of a BIFF8 OBJ record from stream. */
660 virtual void DoReadObj8SubRec( XclImpStream& rStrm, sal_uInt16 nSubRecId, sal_uInt16 nSubRecSize ) SAL_OVERRIDE;
661 /** Sets additional properties for the current form control. */
662 virtual void DoProcessControl( ScfPropertySet& rPropSet ) const SAL_OVERRIDE;
663 /** Returns the service name of the control component to be created. */
664 virtual OUString DoGetServiceName() const SAL_OVERRIDE;
665 /** Returns the type of the macro event to be created. */
666 virtual XclTbxEventType DoGetEventType() const SAL_OVERRIDE;
668 protected:
669 sal_uInt16 mnContentType;
670 sal_uInt16 mnMultiLine;
671 sal_uInt16 mnScrollBar;
672 sal_uInt16 mnListBoxObjId;
675 /** Base class of scrollable form controls (spin button, scrollbar, listbox, dropdown). */
676 class XclImpTbxObjScrollableBase : public XclImpTbxObjBase
678 public:
679 explicit XclImpTbxObjScrollableBase( const XclImpRoot& rRoot );
681 protected:
682 /** Reads scrollbar data. */
683 void ReadSbs( XclImpStream& rStrm );
685 /** Reads the contents of the specified subrecord of a BIFF8 OBJ record from stream. */
686 virtual void DoReadObj8SubRec( XclImpStream& rStrm, sal_uInt16 nSubRecId, sal_uInt16 nSubRecSize ) SAL_OVERRIDE;
688 protected:
689 sal_uInt16 mnValue;
690 sal_uInt16 mnMin;
691 sal_uInt16 mnMax;
692 sal_uInt16 mnStep;
693 sal_uInt16 mnPageStep;
694 sal_uInt16 mnOrient;
695 sal_uInt16 mnThumbWidth;
696 sal_uInt16 mnScrollFlags;
699 /** A spinbutton control. */
700 class XclImpSpinButtonObj : public XclImpTbxObjScrollableBase
702 public:
703 explicit XclImpSpinButtonObj( const XclImpRoot& rRoot );
705 protected:
706 /** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
707 virtual void DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize ) SAL_OVERRIDE;
708 /** Sets additional properties for the current form control. */
709 virtual void DoProcessControl( ScfPropertySet& rPropSet ) const SAL_OVERRIDE;
710 /** Returns the service name of the control component to be created. */
711 virtual OUString DoGetServiceName() const SAL_OVERRIDE;
712 /** Returns the type of the macro event to be created. */
713 virtual XclTbxEventType DoGetEventType() const SAL_OVERRIDE;
716 /** A scrollbar control. */
717 class XclImpScrollBarObj : public XclImpTbxObjScrollableBase
719 public:
720 explicit XclImpScrollBarObj( const XclImpRoot& rRoot );
722 protected:
723 /** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
724 virtual void DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize ) SAL_OVERRIDE;
725 /** Sets additional properties for the current form control. */
726 virtual void DoProcessControl( ScfPropertySet& rPropSet ) const SAL_OVERRIDE;
727 /** Returns the service name of the control component to be created. */
728 virtual OUString DoGetServiceName() const SAL_OVERRIDE;
729 /** Returns the type of the macro event to be created. */
730 virtual XclTbxEventType DoGetEventType() const SAL_OVERRIDE;
733 /** Base class for list controls (listbox, dropdown). */
734 class XclImpTbxObjListBase : public XclImpTbxObjScrollableBase
736 public:
737 explicit XclImpTbxObjListBase( const XclImpRoot& rRoot );
739 protected:
740 /** Reads common listbox settings. */
741 void ReadLbsData( XclImpStream& rStrm );
742 /** Sets common listbox/dropdown formatting attributes. */
743 void SetBoxFormatting( ScfPropertySet& rPropSet ) const;
745 protected:
746 sal_uInt16 mnEntryCount;
747 sal_uInt16 mnSelEntry;
748 sal_uInt16 mnListFlags;
749 sal_uInt16 mnEditObjId;
750 bool mbHasDefFontIdx;
753 /** A listbox control. */
754 class XclImpListBoxObj : public XclImpTbxObjListBase
756 public:
757 explicit XclImpListBoxObj( const XclImpRoot& rRoot );
759 protected:
760 /** Reads listbox settings and selection. */
761 void ReadFullLbsData( XclImpStream& rStrm, sal_Size nRecLeft );
763 /** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
764 virtual void DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize ) SAL_OVERRIDE;
765 /** Reads the contents of the specified subrecord of a BIFF8 OBJ record from stream. */
766 virtual void DoReadObj8SubRec( XclImpStream& rStrm, sal_uInt16 nSubRecId, sal_uInt16 nSubRecSize ) SAL_OVERRIDE;
767 /** Sets additional properties for the current form control. */
768 virtual void DoProcessControl( ScfPropertySet& rPropSet ) const SAL_OVERRIDE;
769 /** Returns the service name of the control component to be created. */
770 virtual OUString DoGetServiceName() const SAL_OVERRIDE;
771 /** Returns the type of the macro event to be created. */
772 virtual XclTbxEventType DoGetEventType() const SAL_OVERRIDE;
774 protected:
775 ScfUInt8Vec maSelection;
778 /** A dropdown listbox control. */
779 class XclImpDropDownObj : public XclImpTbxObjListBase
781 public:
782 explicit XclImpDropDownObj( const XclImpRoot& rRoot );
784 protected:
785 /** Returns the type of the dropdown control. */
786 sal_uInt16 GetDropDownType() const;
788 /** Reads dropdown box settings. */
789 void ReadFullLbsData( XclImpStream& rStrm );
791 /** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
792 virtual void DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize ) SAL_OVERRIDE;
793 /** Reads the contents of the specified subrecord of a BIFF8 OBJ record from stream. */
794 virtual void DoReadObj8SubRec( XclImpStream& rStrm, sal_uInt16 nSubRecId, sal_uInt16 nSubRecSize ) SAL_OVERRIDE;
795 /** Sets additional properties for the current form control. */
796 virtual void DoProcessControl( ScfPropertySet& rPropSet ) const SAL_OVERRIDE;
797 /** Returns the service name of the control component to be created. */
798 virtual OUString DoGetServiceName() const SAL_OVERRIDE;
799 /** Returns the type of the macro event to be created. */
800 virtual XclTbxEventType DoGetEventType() const SAL_OVERRIDE;
802 protected:
803 sal_uInt16 mnLeft;
804 sal_uInt16 mnTop;
805 sal_uInt16 mnRight;
806 sal_uInt16 mnBottom;
807 sal_uInt16 mnDropDownFlags;
808 sal_uInt16 mnLineCount;
809 sal_uInt16 mnMinWidth;
812 /** A picture, an embedded or linked OLE object, or an OCX form control. */
813 class XclImpPictureObj : public XclImpRectObj, public XclImpControlHelper
815 public:
816 explicit XclImpPictureObj( const XclImpRoot& rRoot );
817 /** Returns the ObjectName - can use non-obvious lookup for override in the associated vba document module stream**/
818 virtual OUString GetObjName() const SAL_OVERRIDE;
819 /** Returns the graphic imported from the IMGDATA record. */
820 inline const Graphic& GetGraphic() const { return maGraphic; }
822 /** Returns the visible area of the imported graphic. */
823 inline const Rectangle& GetVisArea() const { return maVisArea; }
825 /** Returns true, if the OLE object will be shown as symbol. */
826 inline bool IsSymbol() const { return mbSymbol; }
827 /** Returns the storage name for the OLE object. */
828 OUString GetOleStorageName() const;
830 /** Returns true, if this object is an OCX form control. */
831 inline bool IsOcxControl() const { return mbEmbedded && mbControl && mbUseCtlsStrm; }
832 /** Returns the position in the 'Ctls' stream for additional form control data. */
833 inline sal_Size GetCtlsStreamPos() const { return mnCtlsStrmPos; }
834 /** Returns the size in the 'Ctls' stream for additional form control data. */
835 inline sal_Size GetCtlsStreamSize() const { return mnCtlsStrmSize; }
837 protected:
838 /** Reads the contents of the a BIFF3 OBJ record from the passed stream. */
839 virtual void DoReadObj3( XclImpStream& rStrm, sal_uInt16 nMacroSize ) SAL_OVERRIDE;
840 /** Reads the contents of the a BIFF4 OBJ record from the passed stream. */
841 virtual void DoReadObj4( XclImpStream& rStrm, sal_uInt16 nMacroSize ) SAL_OVERRIDE;
842 /** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
843 virtual void DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize ) SAL_OVERRIDE;
844 /** Reads the contents of the specified subrecord of a BIFF8 OBJ record from stream. */
845 virtual void DoReadObj8SubRec( XclImpStream& rStrm, sal_uInt16 nSubRecId, sal_uInt16 nSubRecSize ) SAL_OVERRIDE;
846 /** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */
847 virtual SdrObject* DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const SAL_OVERRIDE;
848 /** Override to do additional processing on the SdrObject. */
849 virtual void DoPreProcessSdrObj( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const SAL_OVERRIDE;
851 private:
852 /** Reads and sets the picture flags from a BIFF3-BIFF5 OBJ picture record. */
853 void ReadFlags3( XclImpStream& rStrm );
854 /** Reads the contents of the OBJFLAGS subrecord. */
855 void ReadFlags8( XclImpStream& rStrm );
856 /** Reads the contents of the OBJPICTFMLA subrecord. */
857 void ReadPictFmla( XclImpStream& rStrm, sal_uInt16 nLinkSize );
859 private:
860 Graphic maGraphic; /// Picture or OLE placeholder graphic.
861 Rectangle maVisArea; /// Size of graphic.
862 OUString maClassName; /// Class name of embedded OLE object.
863 sal_uInt32 mnStorageId; /// Identifier of the storage for this object.
864 sal_Size mnCtlsStrmPos; /// Position in 'Ctls' stream for this control.
865 sal_Size mnCtlsStrmSize; /// Size in 'Ctls' stream for this control.
866 bool mbEmbedded; /// true = Embedded OLE object.
867 bool mbLinked; /// true = Linked OLE object.
868 bool mbSymbol; /// true = Show as symbol.
869 bool mbControl; /// true = Form control, false = OLE object.
870 bool mbUseCtlsStrm; /// true = Form control data in 'Ctls' stream, false = Own storage.
873 // DFF stream conversion ======================================================
875 /** The solver container collects all connector rules for connected objects. */
876 class XclImpSolverContainer : public SvxMSDffSolverContainer
878 public:
880 /** Inserts information about a new SdrObject. */
881 void InsertSdrObjectInfo( SdrObject& rSdrObj, sal_uInt32 nDffShapeId, sal_uInt32 nDffFlags );
882 /** Removes information of an SdrObject (and all child objects if it is a group). */
883 void RemoveSdrObjectInfo( SdrObject& rSdrObj );
885 /** Inserts the SdrObject pointers into all connector rules. */
886 void UpdateConnectorRules();
887 /** Removes all contained connector rules. */
888 void RemoveConnectorRules();
890 private:
891 /** Updates the data of a connected shape in a connector rule. */
892 void UpdateConnection( sal_uInt32 nDffShapeId, SdrObject*& rpSdrObj, sal_uInt32* pnDffFlags = 0 );
894 private:
895 /** Stores data about an SdrObject processed during import. */
896 struct XclImpSdrInfo
898 SdrObject* mpSdrObj; /// Pointer to an SdrObject.
899 sal_uInt32 mnDffFlags; /// Shape flags from DFF stream.
900 inline explicit XclImpSdrInfo() : mpSdrObj( 0 ), mnDffFlags( 0 ) {}
901 inline void Set( SdrObject* pSdrObj, sal_uInt32 nDffFlags )
902 { mpSdrObj = pSdrObj; mnDffFlags = nDffFlags; }
904 typedef ::std::map< sal_uInt32, XclImpSdrInfo > XclImpSdrInfoMap;
905 typedef ::std::map< SdrObject*, sal_uInt32 > XclImpSdrObjMap;
907 XclImpSdrInfoMap maSdrInfoMap; /// Maps shape IDs to SdrObjects and flags.
908 XclImpSdrObjMap maSdrObjMap; /// Maps SdrObjects to shape IDs.
911 /** Simple implementation of the SVX DFF manager. Implements resolving palette
912 colors. Used by XclImpDffPropSet (as is), extended by XclImpDffConverter.
914 class XclImpSimpleDffConverter : public SvxMSDffManager, protected XclImpRoot
916 public:
917 explicit XclImpSimpleDffConverter( const XclImpRoot& rRoot, SvStream& rDffStrm );
918 virtual ~XclImpSimpleDffConverter();
920 protected:
921 /** Returns a color from the Excel color palette. */
922 virtual bool GetColorFromPalette( sal_uInt16 nIndex, Color& rColor ) const SAL_OVERRIDE;
925 /** This is the central instance for converting binary DFF data into shape
926 objects. Used for all sheet shapes and shapes embedded in chart objects.
928 The class derives from SvxMSDffManager and SvxMSConvertOCXControls and
929 contains core implementation of DFF stream import and OCX form control
930 import.
932 class XclImpDffConverter : public XclImpSimpleDffConverter, private oox::ole::MSConvertOCXControls
934 public:
935 explicit XclImpDffConverter( const XclImpRoot& rRoot, SvStream& rDffStrm );
936 virtual ~XclImpDffConverter();
938 /** Initializes the internal progress bar with the passed size and starts it. */
939 void StartProgressBar( sal_Size nProgressSize );
940 /** Increase the progress bar by the passed value. */
941 void Progress( sal_Size nDelta = 1 );
943 /** Initially called before the objects of the passed drawing manager are converted. */
944 void InitializeDrawing( XclImpDrawing& rDrawing, SdrModel& rSdrModel, SdrPage& rSdrPage );
945 /** Processes BIFF5 drawing objects without DFF data, inserts into the passed object list. */
946 void ProcessObject( SdrObjList& rObjList, const XclImpDrawObjBase& rDrawObj );
947 /** Processes all objects in the passed list. */
948 void ProcessDrawing( const XclImpDrawObjVector& rDrawObjs );
949 /** Processes a drawing container in the passed DFF stream, converts all objects. */
950 void ProcessDrawing( SvStream& rDffStrm );
951 /** Finally called after the objects of the passed drawing manager have been converted. */
952 void FinalizeDrawing();
954 /** Creates the SdrObject for the passed Excel TBX form control object. */
955 SdrObject* CreateSdrObject( const XclImpTbxObjBase& rTbxObj, const Rectangle& rAnchorRect );
956 /** Creates the SdrObject for the passed Excel OLE object or OCX form control object. */
957 SdrObject* CreateSdrObject( const XclImpPictureObj& rPicObj, const Rectangle& rAnchorRect );
959 /** Returns true, if the conversion of OLE objects is supported. */
960 bool SupportsOleObjects() const;
961 /** Returns the default text margin in drawing layer units. */
962 inline sal_Int32 GetDefaultTextMargin() const { return mnDefTextMargin; }
964 private:
965 // virtual functions of SvxMSDffManager
967 /** Reads the client anchor from the DFF stream and sets it at the correct object. */
968 virtual void ProcessClientAnchor2(
969 SvStream& rDffStrm,
970 DffRecordHeader& rHeader,
971 void* pClientData,
972 DffObjData& rObjData ) SAL_OVERRIDE;
973 /** Processes an DFF object, reads properties from DFF stream. */
974 virtual SdrObject* ProcessObj(
975 SvStream& rDffStrm,
976 DffObjData& rDffObjData,
977 void* pClientData,
978 Rectangle& rTextRect,
979 SdrObject* pOldSdrObj = 0 ) SAL_OVERRIDE;
981 // virtual functions of SvxMSConvertOCXControls
983 /** Inserts the passed control rxFComp into the form. Needs call to SetCurrentForm() before. */
984 virtual bool InsertControl(
985 const ::com::sun::star::uno::Reference<
986 ::com::sun::star::form::XFormComponent >& rxFormComp,
987 const ::com::sun::star::awt::Size& rSize,
988 ::com::sun::star::uno::Reference<
989 ::com::sun::star::drawing::XShape >* pxShape,
990 bool bFloatingCtrl ) SAL_OVERRIDE;
992 private:
993 /** Data per registered drawing manager, will be stacked for recursive calls. */
994 struct XclImpDffConvData
996 XclImpDrawing& mrDrawing; /// Current drawing container with all drawing objects.
997 SdrModel& mrSdrModel; /// The SdrModel of the drawing manager.
998 SdrPage& mrSdrPage; /// The SdrPage of the drawing manager.
999 XclImpSolverContainer maSolverCont; /// The solver container for connector rules.
1000 ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >
1001 mxCtrlForm; /// Controls form of current drawing page.
1002 sal_Int32 mnLastCtrlIndex; /// Last insertion index of a form control (for macro events).
1003 bool mbHasCtrlForm; /// True = mxCtrlForm is initialized (but maybe still null).
1005 explicit XclImpDffConvData( XclImpDrawing& rDrawing,
1006 SdrModel& rSdrModel, SdrPage& rSdrPage );
1009 /** Returns the current drawing manager data struct from top of the stack. */
1010 XclImpDffConvData& GetConvData();
1011 /** Returns the current drawing manager data struct from top of the stack. */
1012 const XclImpDffConvData& GetConvData() const;
1014 /** Reads contents of a hyperlink property and returns the extracted URL. */
1015 OUString ReadHlinkProperty( SvStream& rDffStrm ) const;
1017 /** Processes a drawing container (all drawing data of a sheet). */
1018 void ProcessDgContainer( SvStream& rDffStrm, const DffRecordHeader& rDgHeader );
1019 /** Processes the global shape group container (all shapes of a sheet). */
1020 void ProcessShGrContainer( SvStream& rDffStrm, const DffRecordHeader& rShGrHeader );
1021 /** Processes the solver container (connectors of a sheet). */
1022 void ProcessSolverContainer( SvStream& rDffStrm, const DffRecordHeader& rSolverHeader );
1023 /** Processes a shape or shape group container (one top-level shape). */
1024 void ProcessShContainer( SvStream& rDffStrm, const DffRecordHeader& rShHeader );
1026 /** Inserts the passed SdrObject into the document. This function takes ownership of pSdrObj! */
1027 void InsertSdrObject( SdrObjList& rObjList, const XclImpDrawObjBase& rDrawObj, SdrObject* pSdrObj );
1028 /** Initializes the mxCtrlForm referring to the standard controls form. */
1029 void InitControlForm();
1031 private:
1032 typedef boost::shared_ptr< ScfProgressBar > ScfProgressBarRef;
1033 typedef boost::shared_ptr< XclImpDffConvData > XclImpDffConvDataRef;
1034 typedef ::std::vector< XclImpDffConvDataRef > XclImpDffConvDataStack;
1036 const OUString maStdFormName; /// Standard name of control forms.
1037 tools::SvRef<SotStorageStream> mxCtlsStrm; /// The 'Ctls' stream for OCX form controls.
1038 ScfProgressBarRef mxProgress; /// The progress bar used in ProcessObj().
1039 XclImpDffConvDataStack maDataStack; /// Stack for registered drawing managers.
1040 sal_uInt32 mnOleImpFlags; /// Application OLE import settings.
1041 sal_Int32 mnDefTextMargin; /// Default margin in text boxes.
1044 // Drawing manager ============================================================
1046 /** Base class for a container for all objects on a drawing (spreadsheet or
1047 embedded chart object). */
1048 class XclImpDrawing : protected XclImpRoot
1050 public:
1051 explicit XclImpDrawing( const XclImpRoot& rRoot, bool bOleObjects );
1052 virtual ~XclImpDrawing();
1054 /** Reads and returns a bitmap from the IMGDATA record. */
1055 static Graphic ReadImgData( const XclImpRoot& rRoot, XclImpStream& rStrm );
1057 /** Reads a plain OBJ record (without leading DFF data). */
1058 void ReadObj( XclImpStream& rStrm );
1059 /** Reads the MSODRAWING or MSODRAWINGSELECTION record. */
1060 void ReadMsoDrawing( XclImpStream& rStrm );
1062 /** Returns true, if the conversion of OLE objects is supported. */
1063 inline bool SupportsOleObjects() const { return mbOleObjs; }
1064 /** Finds the OBJ record data related to the DFF shape at the passed position. */
1065 XclImpDrawObjRef FindDrawObj( const DffRecordHeader& rHeader ) const;
1066 /** Finds the OBJ record data specified by the passed object identifier. */
1067 XclImpDrawObjRef FindDrawObj( sal_uInt16 nObjId ) const;
1068 /** Finds the textbox data related to the DFF shape at the passed position. */
1069 const XclImpObjTextData* FindTextData( const DffRecordHeader& rHeader ) const;
1071 /** Sets the object with the passed identification to be skipped on import. */
1072 void SetSkipObj( sal_uInt16 nObjId );
1073 /** Returns the size of the progress bar shown while processing all objects. */
1074 sal_Size GetProgressSize() const;
1076 /** Derived classes calculate the resulting rectangle of the passed anchor. */
1077 virtual Rectangle CalcAnchorRect( const XclObjAnchor& rAnchor, bool bDffAnchor ) const = 0;
1078 /** Called whenever an object has been inserted into the draw page. */
1079 virtual void OnObjectInserted( const XclImpDrawObjBase& rDrawObj ) = 0;
1081 protected:
1082 /** Appends a new drawing object to the list of raw objects (without DFF data). */
1083 void AppendRawObject( const XclImpDrawObjRef& rxDrawObj );
1084 /** Converts all objects and inserts them into the current drawing page. */
1085 void ImplConvertObjects( XclImpDffConverter& rDffConv, SdrModel& rSdrModel, SdrPage& rSdrPage );
1087 private:
1088 /** Reads and returns a bitmap from WMF/PICT format. */
1089 static void ReadWmf( Graphic& rGraphic, const XclImpRoot& rRoot, XclImpStream& rStrm );
1090 /** Reads and returns a bitmap from BMP format. */
1091 static void ReadBmp( Graphic& rGraphic, const XclImpRoot& rRoot, XclImpStream& rStrm );
1093 /** Reads contents of an DFF record and append data to internal DFF stream. */
1094 void ReadDffRecord( XclImpStream& rStrm );
1095 /** Reads a BIFF8 OBJ record following an MSODRAWING record. */
1096 void ReadObj8( XclImpStream& rStrm );
1097 /** Reads the TXO record and following CONTINUE records containing string and formatting. */
1098 void ReadTxo( XclImpStream& rStrm );
1100 private:
1101 typedef ::std::map< sal_Size, XclImpDrawObjRef > XclImpObjMap;
1102 typedef ::std::map< sal_uInt16, XclImpDrawObjRef > XclImpObjMapById;
1103 typedef boost::shared_ptr< XclImpObjTextData > XclImpObjTextRef;
1104 typedef ::std::map< sal_Size, XclImpObjTextRef > XclImpObjTextMap;
1106 XclImpDrawObjVector maRawObjs; /// BIFF5 objects without DFF data.
1107 SvMemoryStream maDffStrm; /// Copy of the DFF page stream in memory.
1108 XclImpObjMap maObjMap; /// Maps BIFF8 drawing objects to DFF stream position.
1109 XclImpObjMapById maObjMapId; /// Maps BIFF8 drawing objects to object ID.
1110 XclImpObjTextMap maTextMap; /// Maps BIFF8 TXO textbox data to DFF stream position.
1111 ScfUInt16Vec maSkipObjs; /// IDs of all objects to be skipped.
1112 bool mbOleObjs; /// True = draw model supports OLE objects.
1115 /** Drawing manager of a single sheet. */
1116 class XclImpSheetDrawing : public XclImpDrawing
1118 public:
1119 explicit XclImpSheetDrawing( const XclImpRoot& rRoot, SCTAB nScTab );
1121 /** Reads the NOTE record. */
1122 void ReadNote( XclImpStream& rStrm );
1123 /** Inserts a new chart object and reads the chart substream (BOF/EOF block).
1124 @descr Used to import chart sheets, which do not have a corresponding OBJ record. */
1125 void ReadTabChart( XclImpStream& rStrm );
1127 /** Returns the total cell range covered by any shapes in the sheet. */
1128 inline const ScRange& GetUsedArea() const { return maScUsedArea; }
1129 /** Converts all objects and inserts them into the sheet drawing page. */
1130 void ConvertObjects( XclImpDffConverter& rDffConv );
1132 /** Calculate the resulting rectangle of the passed anchor. */
1133 virtual Rectangle CalcAnchorRect( const XclObjAnchor& rAnchor, bool bDffAnchor ) const SAL_OVERRIDE;
1134 /** On call, updates the used area of the sheet. */
1135 virtual void OnObjectInserted( const XclImpDrawObjBase& rDrawObj ) SAL_OVERRIDE;
1137 private:
1138 /** Reads a BIFF3-BIFF5 NOTE record. */
1139 void ReadNote3( XclImpStream& rStrm );
1140 /** Reads a BIFF8 NOTE record. */
1141 void ReadNote8( XclImpStream& rStrm );
1143 private:
1144 ScRange maScUsedArea; /// Sheet index and used area in this sheet.
1147 // The object manager =========================================================
1149 /** Stores all drawing and OLE objects and additional data related to these objects. */
1150 class XclImpObjectManager : protected XclImpRoot
1152 public:
1153 explicit XclImpObjectManager( const XclImpRoot& rRoot );
1154 virtual ~XclImpObjectManager();
1156 /** Reads the MSODRAWINGGROUP record. */
1157 void ReadMsoDrawingGroup( XclImpStream& rStrm );
1159 /** Returns (initially creates) the drawing manager of the specified sheet. */
1160 XclImpSheetDrawing& GetSheetDrawing( SCTAB nScTab );
1161 /** Inserts all objects into the Calc document. */
1162 void ConvertObjects();
1164 /** Returns the default name for the passed object. */
1165 OUString GetDefaultObjName( const XclImpDrawObjBase& rDrawObj ) const;
1166 /** Returns the used area in the sheet with the passed index. */
1167 ScRange GetUsedArea( SCTAB nScTab ) const;
1168 /** Sets the container to receive overridden shape/ctrl names from
1169 the filter. */
1170 void SetOleNameOverrideInfo( const com::sun::star::uno::Reference< com::sun::star::container::XNameContainer >& rxOverrideInfo ) { mxOleCtrlNameOverride = rxOverrideInfo; }
1171 /** Returns the name of overridden name ( or zero length string ) for
1172 associated object id. */
1173 OUString GetOleNameOverride( SCTAB nTab, sal_uInt16 nObjId );
1175 private:
1177 /** Reads and returns a bitmap from WMF/PICT format. */
1178 static void ReadWmf( Graphic& rGraphic, XclImpStream& rStrm );
1179 /** Reads and returns a bitmap from BMP format. */
1180 static void ReadBmp( Graphic& rGraphic, XclImpStream& rStrm );
1182 /** Reads contents of an DFF record and append data to internal DFF stream. */
1183 void ReadDffRecord( XclImpStream& rStrm );
1184 /** Reads a BIFF8 OBJ record following an MSODRAWING record. */
1185 void ReadObj8( XclImpStream& rStrm );
1186 /** Reads the TXO record and following CONTINUE records containing string and formatting. */
1187 void ReadTxo( XclImpStream& rStrm );
1189 /** Reads a BIFF3-BIFF5 NOTE record. */
1190 void ReadNote3( XclImpStream& rStrm );
1191 /** Reads a BIFF8 NOTE record. */
1192 void ReadNote8( XclImpStream& rStrm );
1194 /** Returns the size of the progress bar shown while processing all objects. */
1195 sal_Size GetProgressSize() const;
1197 private:
1198 typedef ::std::map< sal_uInt16, OUString > DefObjNameMap;
1199 typedef boost::shared_ptr< XclImpSheetDrawing > XclImpSheetDrawingRef;
1200 typedef ::std::map< SCTAB, XclImpSheetDrawingRef > XclImpSheetDrawingMap;
1202 com::sun::star::uno::Reference< com::sun::star::container::XNameContainer > mxOleCtrlNameOverride;
1203 DefObjNameMap maDefObjNames; /// Default base names for all object types.
1204 SvMemoryStream maDggStrm; /// Copy of global DFF data (DGG container) in memory.
1205 XclImpSheetDrawingMap maSheetDrawings; /// Drawing managers of all sheets.
1208 // DFF property set helper ====================================================
1210 /** This class reads an DFF property set (msofbtOPT record).
1212 It can return separate property values or an item set which contains items
1213 translated from these properties.
1215 class XclImpDffPropSet : protected XclImpRoot
1217 public:
1218 explicit XclImpDffPropSet( const XclImpRoot& rRoot );
1220 /** Reads an DFF property set from the stream.
1221 @descr The stream must point to the start of an DFF record containing properties. */
1222 void Read( XclImpStream& rStrm );
1224 /** Returns the specified property or the default value, if not extant. */
1225 sal_uInt32 GetPropertyValue( sal_uInt16 nPropId, sal_uInt32 nDefault = 0 ) const;
1227 /** Translates the properties and fills the item set. */
1228 void FillToItemSet( SfxItemSet& rItemSet ) const;
1230 private:
1231 typedef ::boost::scoped_ptr<SvMemoryStream> SvMemoryStreamPtr;
1233 SvMemoryStream maDummyStrm; /// Dummy DGG stream for DFF manager.
1234 XclImpSimpleDffConverter maDffConv; /// DFF converter used to resolve palette colors.
1235 SvMemoryStreamPtr mxMemStrm; /// Helper stream.
1238 XclImpStream& operator>>( XclImpStream& rStrm, XclImpDffPropSet& rPropSet );
1240 #endif
1242 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */