merge the formfield patch from ooo-build
[ooovba.git] / sc / source / filter / inc / xiescher.hxx
blob42c2ec10464206361a19c9054e53623e32ac8747
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: xiescher.hxx,v $
10 * $Revision: 1.28.90.14 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SC_XIESCHER_HXX
32 #define SC_XIESCHER_HXX
34 #include <vector>
35 #include <map>
36 #include <hash_map>
37 #include <svx/msdffimp.hxx>
38 #include <svx/msocximex.hxx>
39 #include <vcl/graph.hxx>
40 #include "xlescher.hxx"
41 #include "xiroot.hxx"
42 #include "xistring.hxx"
44 namespace com { namespace sun { namespace star {
45 namespace drawing { class XShape; }
46 namespace form { class XForm; }
47 } } }
49 class ScfProgressBar;
50 class ScfPropertySet;
51 class XclImpChart;
53 // Drawing objects ============================================================
55 class XclImpDrawObjBase;
56 typedef ScfRef< XclImpDrawObjBase > XclImpDrawObjRef;
58 /** Base class for drawing objects (OBJ records). */
59 class XclImpDrawObjBase : protected XclImpRoot
61 public:
62 explicit XclImpDrawObjBase( const XclImpRoot& rRoot );
63 virtual ~XclImpDrawObjBase();
65 /** Reads the BIFF3 OBJ record, returns a new drawing object. */
66 static XclImpDrawObjRef ReadObj3( XclImpStream& rStrm );
67 /** Reads the BIFF4 OBJ record, returns a new drawing object. */
68 static XclImpDrawObjRef ReadObj4( XclImpStream& rStrm );
69 /** Reads the BIFF5 OBJ record, returns a new drawing object. */
70 static XclImpDrawObjRef ReadObj5( XclImpStream& rStrm );
71 /** Reads the BIFF8 OBJ record, returns a new drawing object. */
72 static XclImpDrawObjRef ReadObj8( XclImpStream& rStrm );
74 /** Sets whether this is an area object (then its width and height must be greater than 0). */
75 inline void SetAreaObj( bool bAreaObj ) { mbAreaObj = bAreaObj; }
76 /** If set to true, a new SdrObject will be created while in DFF import. */
77 inline void SetSimpleMacro( bool bMacro ) { mbSimpleMacro = bMacro; }
79 /** Sets shape data from DFF stream. */
80 void SetDffData( const DffObjData& rDffObjData, const String& rObjName, const String& rHyperlink, bool bVisible, bool bAutoMargin );
81 /** Sets the object anchor explicitly. */
82 void SetAnchor( const XclObjAnchor& rAnchor );
84 /** If set to false, the SdrObject will not be created, processed, or inserted into the draw page. */
85 inline void SetProcessSdrObj( bool bProcess ) { mbProcessSdr = bProcess; }
86 /** If set to false, the SdrObject will be created or processed, but not be inserted into the draw page. */
87 inline void SetInsertSdrObj( bool bInsert ) { mbInsertSdr = bInsert; }
88 /** If set to true, a new SdrObject will be created while in DFF import. */
89 inline void SetCustomDffObj( bool bCustom ) { mbCustomDff = bCustom; }
91 /** Returns the Calc sheet index of this object. */
92 inline SCTAB GetScTab() const { return maObjId.mnScTab; }
93 /** Returns the sheet index and Excel object identifier from OBJ record. */
94 inline const XclObjId& GetObjId() const { return maObjId; }
95 /** Returns the Excel object type from OBJ record. */
96 inline sal_uInt16 GetObjType() const { return mnObjType; }
97 /** Returns the name of this object, may generate a default name. */
98 String GetObjName() const;
99 /** Returns associated macro name, if set, otherwise zero length string. */
100 inline const String& GetMacroName() const { return maMacroName; }
102 /** Returns the shape identifier used in the DFF stream. */
103 inline sal_uInt32 GetDffShapeId() const { return mnDffShapeId; }
104 /** Returns the shape flags from the DFF stream. */
105 inline sal_uInt32 GetDffFlags() const { return mnDffFlags; }
107 /** Returns true, if the object is hidden. */
108 inline bool IsHidden() const { return mbHidden; }
109 /** Returns true, if the object is visible. */
110 inline bool IsVisible() const { return mbVisible; }
111 /** Returns true, if the object is printable. */
112 inline bool IsPrintable() const { return mbPrintable; }
114 /** Returns true, if the passed size is valid for this object. */
115 bool IsValidSize( const Rectangle& rAnchorRect ) const;
116 /** Returns the area in the sheet used by this object. */
117 ScRange GetUsedArea() const;
118 /** Returns the area on the drawing layer for this object. */
119 Rectangle GetAnchorRect() const;
121 /** Returns true, if the object is valid and will be processed.. */
122 inline bool IsProcessSdrObj() const { return mbProcessSdr && !mbHidden; }
123 /** Returns true, if the SdrObject will be created or processed, but not be inserted into the draw page. */
124 inline bool IsInsertSdrObj() const { return mbInsertSdr; }
126 /** Returns the needed size on the progress bar (calls virtual DoGetProgressSize() function). */
127 sal_Size GetProgressSize() const;
128 /** Creates and returns an SdrObject from the contained data. Caller takes ownership! */
129 SdrObject* CreateSdrObject( const Rectangle& rAnchorRect, ScfProgressBar& rProgress, bool bDffImport ) const;
130 /** Additional processing for the passed SdrObject (calls virtual DoProcessSdrObj() function). */
131 void ProcessSdrObject( SdrObject& rSdrObj ) const;
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( const Rectangle& rAnchorRect, ScfProgressBar& rProgress ) const;
170 /** Derived classes may perform additional processing for the passed SdrObject. */
171 virtual void DoProcessSdrObj( SdrObject& rSdrObj ) const;
173 private:
174 /** Reads the contents of a BIFF3 OBJ record. */
175 void ImplReadObj3( XclImpStream& rStrm );
176 /** Reads the contents of a BIFF4 OBJ record. */
177 void ImplReadObj4( XclImpStream& rStrm );
178 /** Reads the contents of a BIFF5 OBJ record. */
179 void ImplReadObj5( XclImpStream& rStrm );
180 /** Reads the contents of a BIFF8 OBJ record. */
181 void ImplReadObj8( XclImpStream& rStrm );
183 private:
184 typedef ScfRef< XclObjAnchor > XclObjAnchorRef;
186 XclObjAnchorRef mxAnchor; /// The position of the object in the containing sheet.
187 XclObjId maObjId; /// Sheet index and object identifier.
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 String maObjName; /// Name of the object.
192 String maMacroName; /// Name of an attached macro.
193 String maHyperlink; /// On-click hyperlink URL.
194 bool mbHidden; /// true = Object is hidden.
195 bool mbVisible; /// true = Object is visible.
196 bool mbPrintable; /// true = Object is printable.
197 bool mbAreaObj; /// true = Width and height must be greater than 0.
198 bool mbAutoMargin; /// true = Set automatic text margin.
199 bool mbSimpleMacro; /// true = Create simple macro link and hyperlink.
200 bool mbProcessSdr; /// true = Object is valid, do processing and insertion.
201 bool mbInsertSdr; /// true = Insert the SdrObject into draw page.
202 bool mbCustomDff; /// true = Recreate SdrObject in DFF import.
205 // ----------------------------------------------------------------------------
207 class XclImpDrawObjVector : public ::std::vector< XclImpDrawObjRef >
209 public:
210 inline explicit XclImpDrawObjVector() {}
212 /** Tries to insert the passed object into the last group or appends it. */
213 void InsertGrouped( XclImpDrawObjRef xDrawObj );
215 /** Returns the needed size on the progress bar for all contained objects. */
216 sal_Size GetProgressSize() const;
219 // ----------------------------------------------------------------------------
221 /** A placeholder object for unknown object types. */
222 class XclImpPhObj : public XclImpDrawObjBase
224 public:
225 explicit XclImpPhObj( const XclImpRoot& rRoot );
228 // ----------------------------------------------------------------------------
230 /** A group object. */
231 class XclImpGroupObj : public XclImpDrawObjBase
233 public:
234 explicit XclImpGroupObj( const XclImpRoot& rRoot );
236 /** Tries to insert the drawing object into this or a nested group. */
237 bool TryInsert( XclImpDrawObjRef xDrawObj );
239 protected:
240 /** Reads the contents of the a BIFF3 OBJ record from the passed stream. */
241 virtual void DoReadObj3( XclImpStream& rStrm, sal_uInt16 nMacroSize );
242 /** Reads the contents of the a BIFF4 OBJ record from the passed stream. */
243 virtual void DoReadObj4( XclImpStream& rStrm, sal_uInt16 nMacroSize );
244 /** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
245 virtual void DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize );
246 /** Returns a progress bar size that takes all group children into account. */
247 virtual sal_Size DoGetProgressSize() const;
248 /** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */
249 virtual SdrObject* DoCreateSdrObj( const Rectangle& rAnchorRect, ScfProgressBar& rProgress ) const;
251 protected:
252 XclImpDrawObjVector maChildren; /// Grouped objects.
253 sal_uInt16 mnFirstUngrouped; /// Object identfier of first object not grouped into this group.
256 // ----------------------------------------------------------------------------
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 );
267 /** Reads the contents of the a BIFF4 OBJ record from the passed stream. */
268 virtual void DoReadObj4( XclImpStream& rStrm, sal_uInt16 nMacroSize );
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 );
271 /** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */
272 virtual SdrObject* DoCreateSdrObj( const Rectangle& rAnchorRect, ScfProgressBar& rProgress ) const;
274 protected:
275 XclObjLineData maLineData; /// BIFF5 line formatting.
276 sal_uInt16 mnArrows; /// Line arrows.
277 sal_uInt8 mnStartPoint; /// Starting point.
280 // ----------------------------------------------------------------------------
282 /** A rectangle or oval object. */
283 class XclImpRectObj : public XclImpDrawObjBase
285 public:
286 explicit XclImpRectObj( const XclImpRoot& rRoot );
288 protected:
289 /** Reads fil data, line data, and frame flags. */
290 void ReadFrameData( XclImpStream& rStrm );
292 /** Converts fill formatting, line formattind, and frame style. */
293 void ConvertRectStyle( SdrObject& rSdrObj ) const;
295 /** Reads the contents of the a BIFF3 OBJ record from the passed stream. */
296 virtual void DoReadObj3( XclImpStream& rStrm, sal_uInt16 nMacroSize );
297 /** Reads the contents of the a BIFF4 OBJ record from the passed stream. */
298 virtual void DoReadObj4( XclImpStream& rStrm, sal_uInt16 nMacroSize );
299 /** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
300 virtual void DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize );
301 /** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */
302 virtual SdrObject* DoCreateSdrObj( const Rectangle& rAnchorRect, ScfProgressBar& rProgress ) const;
304 protected:
305 XclObjFillData maFillData; /// BIFF5 fill formatting.
306 XclObjLineData maLineData; /// BIFF5 line formatting.
307 sal_uInt16 mnFrameFlags; /// Additional flags.
310 // ----------------------------------------------------------------------------
312 /** An oval object. */
313 class XclImpOvalObj : public XclImpRectObj
315 public:
316 explicit XclImpOvalObj( const XclImpRoot& rRoot );
318 protected:
319 /** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */
320 virtual SdrObject* DoCreateSdrObj( const Rectangle& rAnchorRect, ScfProgressBar& rProgress ) const;
323 // ----------------------------------------------------------------------------
325 /** An arc object. */
326 class XclImpArcObj : public XclImpDrawObjBase
328 public:
329 explicit XclImpArcObj( const XclImpRoot& rRoot );
331 protected:
332 /** Reads the contents of the a BIFF3 OBJ record from the passed stream. */
333 virtual void DoReadObj3( XclImpStream& rStrm, sal_uInt16 nMacroSize );
334 /** Reads the contents of the a BIFF4 OBJ record from the passed stream. */
335 virtual void DoReadObj4( XclImpStream& rStrm, sal_uInt16 nMacroSize );
336 /** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
337 virtual void DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize );
338 /** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */
339 virtual SdrObject* DoCreateSdrObj( const Rectangle& rAnchorRect, ScfProgressBar& rProgress ) const;
341 protected:
342 XclObjFillData maFillData; /// BIFF5 fill formatting.
343 XclObjLineData maLineData; /// BIFF5 line formatting.
344 sal_uInt8 mnQuadrant; /// Visible quadrant of the circle.
347 // ----------------------------------------------------------------------------
349 /** A polygon object. */
350 class XclImpPolygonObj : public XclImpRectObj
352 public:
353 explicit XclImpPolygonObj( const XclImpRoot& rRoot );
355 protected:
356 /** Reads the COORDLIST record following the OBJ record. */
357 void ReadCoordList( XclImpStream& rStrm );
359 /** Reads the contents of the a BIFF4 OBJ record from the passed stream. */
360 virtual void DoReadObj4( XclImpStream& rStrm, sal_uInt16 nMacroSize );
361 /** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
362 virtual void DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize );
363 /** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */
364 virtual SdrObject* DoCreateSdrObj( const Rectangle& rAnchorRect, ScfProgressBar& rProgress ) const;
366 protected:
367 typedef ::std::vector< Point > PointVector;
368 PointVector maCoords; /// Coordinates relative to bounding rectangle.
369 sal_uInt16 mnPolyFlags; /// Additional flags.
370 sal_uInt16 mnPointCount; /// Polygon point count.
373 // ----------------------------------------------------------------------------
375 struct XclImpObjTextData
377 XclObjTextData maData; /// BIFF5 text data.
378 XclImpStringRef mxString; /// Plain or rich string.
380 /** Reads a byte string from the passed stream. */
381 void ReadByteString( XclImpStream& rStrm );
382 /** Reads text formatting from the passed stream. */
383 void ReadFormats( XclImpStream& rStrm );
386 // ----------------------------------------------------------------------------
388 /** A drawing object supporting text contents. Used for all simple objects in BIFF8. */
389 class XclImpTextObj : public XclImpRectObj
391 public:
392 explicit XclImpTextObj( const XclImpRoot& rRoot );
394 /** Stores the passed textbox data. */
395 inline void SetTextData( const XclImpObjTextData& rTextData ) { maTextData = rTextData; }
397 protected:
398 /** Reads the contents of the a BIFF3 OBJ record from the passed stream. */
399 virtual void DoReadObj3( XclImpStream& rStrm, sal_uInt16 nMacroSize );
400 /** Reads the contents of the a BIFF4 OBJ record from the passed stream. */
401 virtual void DoReadObj4( XclImpStream& rStrm, sal_uInt16 nMacroSize );
402 /** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
403 virtual void DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize );
404 /** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */
405 virtual SdrObject* DoCreateSdrObj( const Rectangle& rAnchorRect, ScfProgressBar& rProgress ) const;
406 /** Inserts the contained text data at the passed object. */
407 virtual void DoProcessSdrObj( SdrObject& rSdrObj ) const;
409 protected:
410 XclImpObjTextData maTextData; /// Textbox data from BIFF5 OBJ or BIFF8 TXO record.
413 // ----------------------------------------------------------------------------
415 /** A chart object. This is the drawing object wrapper for the chart data. */
416 class XclImpChartObj : public XclImpRectObj
418 public:
419 /** @param bOwnTab True = chart is on an own sheet; false = chart is an embedded object. */
420 explicit XclImpChartObj( const XclImpRoot& rRoot, bool bOwnTab = false );
422 /** Reads the complete chart substream (BOF/EOF block). */
423 void ReadChartSubStream( XclImpStream& rStrm );
425 protected:
426 /** Reads the contents of the a BIFF3 OBJ record from the passed stream. */
427 virtual void DoReadObj3( XclImpStream& rStrm, sal_uInt16 nMacroSize );
428 /** Reads the contents of the a BIFF4 OBJ record from the passed stream. */
429 virtual void DoReadObj4( XclImpStream& rStrm, sal_uInt16 nMacroSize );
430 /** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
431 virtual void DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize );
432 /** Reads the contents of the specified subrecord of a BIFF8 OBJ record from stream. */
433 virtual void DoReadObj8SubRec( XclImpStream& rStrm, sal_uInt16 nSubRecId, sal_uInt16 nSubRecSize );
434 /** Returns the needed size on the progress bar. */
435 virtual sal_Size DoGetProgressSize() const;
436 /** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */
437 virtual SdrObject* DoCreateSdrObj( const Rectangle& rAnchorRect, ScfProgressBar& rProgress ) const;
439 private:
440 /** Calculates the object anchor of a sheet chart (chart fills one page). */
441 void FinalizeTabChart();
443 private:
444 typedef ScfRef< XclImpChart > XclImpChartRef;
446 XclImpChartRef mxChart; /// The chart itself (BOF/EOF substream data).
447 bool mbOwnTab; /// true = own sheet; false = embedded object.
450 // ----------------------------------------------------------------------------
452 /** A note object, which is a specialized text box objext. */
453 class XclImpNoteObj : public XclImpTextObj
455 public:
456 explicit XclImpNoteObj( const XclImpRoot& rRoot );
458 /** Sets note flags and the note position in the Calc sheet. */
459 void SetNoteData( const ScAddress& rScPos, sal_uInt16 nNoteFlags );
461 protected:
462 /** Inserts the note into the document, sets visibility. */
463 virtual void DoProcessSdrObj( SdrObject& rSdrObj ) const;
465 private:
466 ScAddress maScPos; /// Cell position of the note object.
467 sal_uInt16 mnNoteFlags; /// Flags from NOTE record.
470 // ----------------------------------------------------------------------------
472 /** Helper base class for TBX and OCX form controls to manage spreadsheet links. */
473 class XclImpControlHelper
475 public:
476 explicit XclImpControlHelper( const XclImpRoot& rRoot, XclCtrlBindMode eBindMode );
477 virtual ~XclImpControlHelper();
479 /** Returns true, if a linked cell address is present. */
480 inline bool HasCellLink() const { return mxCellLink.is(); }
481 /** Returns true, if a linked source cell range is present. */
482 inline bool HasSourceRange() const { return mxSrcRange.is(); }
484 /** Returns the SdrObject from the passed control shape and sets the bounding rectangle. */
485 SdrObject* CreateSdrObjectFromShape(
486 const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& rxShape,
487 const Rectangle& rAnchorRect ) const;
489 /** Sets additional properties to the form control model, calls virtual DoProcessControl(). */
490 void ProcessControl( const XclImpDrawObjBase& rDrawObj ) const;
492 protected:
493 /** Reads the formula for the linked cell from the current position of the stream. */
494 void ReadCellLinkFormula( XclImpStream& rStrm, bool bWithBoundSize );
495 /** Reads the formula for the source range from the current position of the stream. */
496 void ReadSourceRangeFormula( XclImpStream& rStrm, bool bWithBoundSize );
498 /** Derived classes will set additional properties for the current form control. */
499 virtual void DoProcessControl( ScfPropertySet& rPropSet ) const;
501 void ApplySheetLinkProps() const;
502 mutable ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
503 mxShape; /// The UNO wrapper of the control shape.
504 ScfRef< ScAddress > mxCellLink; /// Linked cell in the Calc document.
505 private:
506 /** Reads a list of cell ranges from a formula at the current stream position. */
507 void ReadRangeList( ScRangeList& rScRanges, XclImpStream& rStrm );
508 /** Reads leading formula size and a list of cell ranges from a formula if the leading size is not zero. */
509 void ReadRangeList( ScRangeList& rScRanges, XclImpStream& rStrm, bool bWithBoundSize );
511 private:
512 const XclImpRoot& mrRoot; /// Not derived from XclImpRoot to allow multiple inheritance.
513 ScfRef< ScRange > mxSrcRange; /// Source data range in the Calc document.
514 XclCtrlBindMode meBindMode; /// Value binding mode.
517 // ----------------------------------------------------------------------------
519 /** Base class for textbox based form controls. */
520 class XclImpTbxObjBase : public XclImpTextObj, public XclImpControlHelper
522 public:
523 explicit XclImpTbxObjBase( const XclImpRoot& rRoot );
525 /** Sets line and fill formatting from the passed DFF property set. */
526 void SetDffProperties( const DffPropSet& rDffPropSet );
528 /** Returns the service name of the control component to be created. */
529 inline ::rtl::OUString GetServiceName() const { return DoGetServiceName(); }
530 /** Fills the passed macro event descriptor. */
531 bool FillMacroDescriptor(
532 ::com::sun::star::script::ScriptEventDescriptor& rDescriptor ) const;
534 protected:
535 /** Sets control text formatting. */
536 void ConvertFont( ScfPropertySet& rPropSet ) const;
537 /** Sets control label and text formatting. */
538 void ConvertLabel( ScfPropertySet& rPropSet ) const;
540 /** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */
541 virtual SdrObject* DoCreateSdrObj( const Rectangle& rAnchorRect, ScfProgressBar& rProgress ) const;
542 /** Additional processing on the SdrObject, calls new virtual function DoProcessControl(). */
543 virtual void DoProcessSdrObj( SdrObject& rSdrObj ) const;
545 /** Derived classes return the service name of the control component to be created. */
546 virtual ::rtl::OUString DoGetServiceName() const = 0;
547 /** Derived classes return the type of the macro event to be created. */
548 virtual XclTbxEventType DoGetEventType() const = 0;
551 // ----------------------------------------------------------------------------
553 /** A button control. */
554 class XclImpButtonObj : public XclImpTbxObjBase
556 public:
557 explicit XclImpButtonObj( const XclImpRoot& rRoot );
559 protected:
560 /** Sets additional properties for the current form control. */
561 virtual void DoProcessControl( ScfPropertySet& rPropSet ) const;
562 /** Returns the service name of the control component to be created. */
563 virtual ::rtl::OUString DoGetServiceName() const;
564 /** Returns the type of the macro event to be created. */
565 virtual XclTbxEventType DoGetEventType() const;
568 // ----------------------------------------------------------------------------
570 /** A checkbox control. */
571 class XclImpCheckBoxObj : public XclImpTbxObjBase
573 public:
574 explicit XclImpCheckBoxObj( const XclImpRoot& rRoot );
576 protected:
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 );
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 );
581 /** Sets additional properties for the current form control. */
582 virtual void DoProcessControl( ScfPropertySet& rPropSet ) const;
583 /** Returns the service name of the control component to be created. */
584 virtual ::rtl::OUString DoGetServiceName() const;
585 /** Returns the type of the macro event to be created. */
586 virtual XclTbxEventType DoGetEventType() const;
588 protected:
589 sal_uInt16 mnState;
590 sal_uInt16 mnCheckBoxFlags;
593 // ----------------------------------------------------------------------------
595 /** An option button control. */
596 class XclImpOptionButtonObj : public XclImpCheckBoxObj
598 public:
599 explicit XclImpOptionButtonObj( const XclImpRoot& rRoot );
601 protected:
602 /** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
603 virtual void DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize );
604 /** Reads the contents of the specified subrecord of a BIFF8 OBJ record from stream. */
605 virtual void DoReadObj8SubRec( XclImpStream& rStrm, sal_uInt16 nSubRecId, sal_uInt16 nSubRecSize );
606 /** Sets additional properties for the current form control. */
607 virtual void DoProcessControl( ScfPropertySet& rPropSet ) const;
608 /** Returns the service name of the control component to be created. */
609 virtual ::rtl::OUString DoGetServiceName() const;
610 /** Returns the type of the macro event to be created. */
611 virtual XclTbxEventType DoGetEventType() const;
613 protected:
614 void ApplyGrouping( XclImpOptionButtonObj& rLeader, sal_Int32 nRefVal );
615 sal_uInt16 mnNextInGroup; /// Next option button in a group.
616 sal_uInt16 mnFirstInGroup; /// 1 = Button is the first in a group.
619 // ----------------------------------------------------------------------------
621 /** A label control. */
622 class XclImpLabelObj : public XclImpTbxObjBase
624 public:
625 explicit XclImpLabelObj( const XclImpRoot& rRoot );
627 protected:
628 /** Sets additional properties for the current form control. */
629 virtual void DoProcessControl( ScfPropertySet& rPropSet ) const;
630 /** Returns the service name of the control component to be created. */
631 virtual ::rtl::OUString DoGetServiceName() const;
632 /** Returns the type of the macro event to be created. */
633 virtual XclTbxEventType DoGetEventType() const;
636 // ----------------------------------------------------------------------------
638 /** A groupbox control. */
639 class XclImpGroupBoxObj : public XclImpTbxObjBase
641 public:
642 explicit XclImpGroupBoxObj( const XclImpRoot& rRoot );
644 protected:
645 /** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
646 virtual void DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize );
647 /** Reads the contents of the specified subrecord of a BIFF8 OBJ record from stream. */
648 virtual void DoReadObj8SubRec( XclImpStream& rStrm, sal_uInt16 nSubRecId, sal_uInt16 nSubRecSize );
649 /** Sets additional properties for the current form control. */
650 virtual void DoProcessControl( ScfPropertySet& rPropSet ) const;
651 /** Returns the service name of the control component to be created. */
652 virtual ::rtl::OUString DoGetServiceName() const;
653 /** Returns the type of the macro event to be created. */
654 virtual XclTbxEventType DoGetEventType() const;
656 protected:
657 sal_uInt16 mnGroupBoxFlags;
660 // ----------------------------------------------------------------------------
662 /** A dialog control. */
663 class XclImpDialogObj : public XclImpTbxObjBase
665 public:
666 explicit XclImpDialogObj( const XclImpRoot& rRoot );
668 protected:
669 /** Sets additional properties for the current form control. */
670 virtual void DoProcessControl( ScfPropertySet& rPropSet ) const;
671 /** Returns the service name of the control component to be created. */
672 virtual ::rtl::OUString DoGetServiceName() const;
673 /** Returns the type of the macro event to be created. */
674 virtual XclTbxEventType DoGetEventType() const;
677 // ----------------------------------------------------------------------------
679 /** An edit control. */
680 class XclImpEditObj : public XclImpTbxObjBase
682 public:
683 explicit XclImpEditObj( const XclImpRoot& rRoot );
685 protected:
686 /** REturns true, if the field type is numeric. */
687 bool IsNumeric() const;
689 /** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
690 virtual void DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize );
691 /** Reads the contents of the specified subrecord of a BIFF8 OBJ record from stream. */
692 virtual void DoReadObj8SubRec( XclImpStream& rStrm, sal_uInt16 nSubRecId, sal_uInt16 nSubRecSize );
693 /** Sets additional properties for the current form control. */
694 virtual void DoProcessControl( ScfPropertySet& rPropSet ) const;
695 /** Returns the service name of the control component to be created. */
696 virtual ::rtl::OUString DoGetServiceName() const;
697 /** Returns the type of the macro event to be created. */
698 virtual XclTbxEventType DoGetEventType() const;
700 protected:
701 sal_uInt16 mnContentType;
702 sal_uInt16 mnMultiLine;
703 sal_uInt16 mnScrollBar;
704 sal_uInt16 mnListBoxObjId;
707 // ----------------------------------------------------------------------------
709 /** Base class of scrollable form controls (spin button, scrollbar, listbox, dropdown). */
710 class XclImpTbxObjScrollableBase : public XclImpTbxObjBase
712 public:
713 explicit XclImpTbxObjScrollableBase( const XclImpRoot& rRoot );
715 protected:
716 /** Reads scrollbar data. */
717 void ReadSbs( XclImpStream& rStrm );
719 /** Reads the contents of the specified subrecord of a BIFF8 OBJ record from stream. */
720 virtual void DoReadObj8SubRec( XclImpStream& rStrm, sal_uInt16 nSubRecId, sal_uInt16 nSubRecSize );
722 protected:
723 sal_uInt16 mnValue;
724 sal_uInt16 mnMin;
725 sal_uInt16 mnMax;
726 sal_uInt16 mnStep;
727 sal_uInt16 mnPageStep;
728 sal_uInt16 mnOrient;
729 sal_uInt16 mnThumbWidth;
730 sal_uInt16 mnScrollFlags;
733 // ----------------------------------------------------------------------------
735 /** A spinbutton control. */
736 class XclImpSpinButtonObj : public XclImpTbxObjScrollableBase
738 public:
739 explicit XclImpSpinButtonObj( const XclImpRoot& rRoot );
741 protected:
742 /** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
743 virtual void DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize );
744 /** Sets additional properties for the current form control. */
745 virtual void DoProcessControl( ScfPropertySet& rPropSet ) const;
746 /** Returns the service name of the control component to be created. */
747 virtual ::rtl::OUString DoGetServiceName() const;
748 /** Returns the type of the macro event to be created. */
749 virtual XclTbxEventType DoGetEventType() const;
752 // ----------------------------------------------------------------------------
754 /** A scrollbar control. */
755 class XclImpScrollBarObj : public XclImpTbxObjScrollableBase
757 public:
758 explicit XclImpScrollBarObj( const XclImpRoot& rRoot );
760 protected:
761 /** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
762 virtual void DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize );
763 /** Sets additional properties for the current form control. */
764 virtual void DoProcessControl( ScfPropertySet& rPropSet ) const;
765 /** Returns the service name of the control component to be created. */
766 virtual ::rtl::OUString DoGetServiceName() const;
767 /** Returns the type of the macro event to be created. */
768 virtual XclTbxEventType DoGetEventType() const;
771 // ----------------------------------------------------------------------------
773 /** Base class for list controls (listbox, dropdown). */
774 class XclImpTbxObjListBase : public XclImpTbxObjScrollableBase
776 public:
777 explicit XclImpTbxObjListBase( const XclImpRoot& rRoot );
779 protected:
780 /** Reads common listbox settings. */
781 void ReadLbsData( XclImpStream& rStrm );
782 /** Sets common listbox/dropdown formatting attributes. */
783 void SetBoxFormatting( ScfPropertySet& rPropSet ) const;
785 protected:
786 sal_uInt16 mnEntryCount;
787 sal_uInt16 mnSelEntry;
788 sal_uInt16 mnListFlags;
789 sal_uInt16 mnEditObjId;
790 bool mbHasDefFontIdx;
793 // ----------------------------------------------------------------------------
795 /** A listbox control. */
796 class XclImpListBoxObj : public XclImpTbxObjListBase
798 public:
799 explicit XclImpListBoxObj( const XclImpRoot& rRoot );
801 protected:
802 /** Reads listbox settings and selection. */
803 void ReadFullLbsData( XclImpStream& rStrm, sal_Size nRecLeft );
805 /** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
806 virtual void DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize );
807 /** Reads the contents of the specified subrecord of a BIFF8 OBJ record from stream. */
808 virtual void DoReadObj8SubRec( XclImpStream& rStrm, sal_uInt16 nSubRecId, sal_uInt16 nSubRecSize );
809 /** Sets additional properties for the current form control. */
810 virtual void DoProcessControl( ScfPropertySet& rPropSet ) const;
811 /** Returns the service name of the control component to be created. */
812 virtual ::rtl::OUString DoGetServiceName() const;
813 /** Returns the type of the macro event to be created. */
814 virtual XclTbxEventType DoGetEventType() const;
816 protected:
817 ScfUInt8Vec maSelection;
820 // ----------------------------------------------------------------------------
822 /** A dropdown listbox control. */
823 class XclImpDropDownObj : public XclImpTbxObjListBase
825 public:
826 explicit XclImpDropDownObj( const XclImpRoot& rRoot );
828 protected:
829 /** Returns the type of the dropdown control. */
830 sal_uInt16 GetDropDownType() const;
832 /** Reads dropdown box settings. */
833 void ReadFullLbsData( XclImpStream& rStrm );
835 /** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
836 virtual void DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize );
837 /** Reads the contents of the specified subrecord of a BIFF8 OBJ record from stream. */
838 virtual void DoReadObj8SubRec( XclImpStream& rStrm, sal_uInt16 nSubRecId, sal_uInt16 nSubRecSize );
839 /** Sets additional properties for the current form control. */
840 virtual void DoProcessControl( ScfPropertySet& rPropSet ) const;
841 /** Returns the service name of the control component to be created. */
842 virtual ::rtl::OUString DoGetServiceName() const;
843 /** Returns the type of the macro event to be created. */
844 virtual XclTbxEventType DoGetEventType() const;
846 protected:
847 sal_uInt16 mnLeft;
848 sal_uInt16 mnTop;
849 sal_uInt16 mnRight;
850 sal_uInt16 mnBottom;
851 sal_uInt16 mnDropDownFlags;
852 sal_uInt16 mnLineCount;
853 sal_uInt16 mnMinWidth;
856 // ----------------------------------------------------------------------------
858 /** A picture, an embedded or linked OLE object, or an OCX form control. */
859 class XclImpPictureObj : public XclImpRectObj, public XclImpControlHelper
861 public:
862 explicit XclImpPictureObj( const XclImpRoot& rRoot );
864 /** Returns the graphic imported from the IMGDATA record. */
865 inline const Graphic& GetGraphic() const { return maGraphic; }
866 /** Returns the visible area of the imported graphic. */
867 inline const Rectangle& GetVisArea() const { return maVisArea; }
869 /** Returns true, if the OLE object will be shown as symbol. */
870 inline bool IsSymbol() const { return mbSymbol; }
871 /** Returns the storage name for the OLE object. */
872 String GetOleStorageName() const;
874 /** Returns true, if this object is an OCX form control. */
875 inline bool IsOcxControl() const { return mbEmbedded && mbControl && mbUseCtlsStrm; }
876 /** Returns the position in the 'Ctls' stream for additional form control data. */
877 inline sal_Size GetCtlsStreamPos() const { return mnCtlsStrmPos; }
878 /** Returns the size in the 'Ctls' stream for additional form control data. */
879 inline sal_Size GetCtlsStreamSize() const { return mnCtlsStrmSize; }
881 protected:
882 /** Reads the contents of the a BIFF3 OBJ record from the passed stream. */
883 virtual void DoReadObj3( XclImpStream& rStrm, sal_uInt16 nMacroSize );
884 /** Reads the contents of the a BIFF4 OBJ record from the passed stream. */
885 virtual void DoReadObj4( XclImpStream& rStrm, sal_uInt16 nMacroSize );
886 /** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
887 virtual void DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize );
888 /** Reads the contents of the specified subrecord of a BIFF8 OBJ record from stream. */
889 virtual void DoReadObj8SubRec( XclImpStream& rStrm, sal_uInt16 nSubRecId, sal_uInt16 nSubRecSize );
890 /** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */
891 virtual SdrObject* DoCreateSdrObj( const Rectangle& rAnchorRect, ScfProgressBar& rProgress ) const;
892 /** Overloaded to do additional processing on the SdrObject. */
893 virtual void DoProcessSdrObj( SdrObject& rSdrObj ) const;
895 private:
896 /** Reads and sets the picture flags from a BIFF3-BIFF5 OBJ picture record. */
897 void ReadFlags3( XclImpStream& rStrm );
898 /** Reads the contents of the OBJFLAGS subrecord. */
899 void ReadFlags8( XclImpStream& rStrm );
900 /** Reads the contents of the OBJPICTFMLA subrecord. */
901 void ReadPictFmla( XclImpStream& rStrm, sal_uInt16 nLinkSize );
903 private:
904 Graphic maGraphic; /// Picture or OLE placeholder graphic.
905 Rectangle maVisArea; /// Size of graphic.
906 String maClassName; /// Class name of embedded OLE object.
907 sal_uInt32 mnStorageId; /// Identifier of the storage for this object.
908 sal_Size mnCtlsStrmPos; /// Position in 'Ctls' stream for this control.
909 sal_Size mnCtlsStrmSize; /// Size in 'Ctls' stream for this control.
910 bool mbEmbedded; /// true = Embedded OLE object.
911 bool mbLinked; /// true = Linked OLE object.
912 bool mbSymbol; /// true = Show as symbol.
913 bool mbControl; /// true = Form control, false = OLE object.
914 bool mbUseCtlsStrm; /// true = Form control data in 'Ctls' stream, false = Own storage.
917 // DFF stream conversion ======================================================
919 /** The solver container collects all connector rules for connected objects. */
920 class XclImpSolverContainer : public SvxMSDffSolverContainer
922 public:
923 //UNUSED2009-05 /** Reads the entire solver container. Stream must point to begin of container header. */
924 //UNUSED2009-05 void ReadSolverContainer( SvStream& rDffStrm );
926 /** Inserts information about a new SdrObject. */
927 void InsertSdrObjectInfo( SdrObject& rSdrObj, sal_uInt32 nDffShapeId, sal_uInt32 nDffFlags );
928 /** Removes inforamtion of an SdrObject (and all child objects if it is a group). */
929 void RemoveSdrObjectInfo( SdrObject& rSdrObj );
931 /** Inserts the SdrObject pointers into all connector rules. */
932 void UpdateConnectorRules();
933 /** Removes all contained connector rules. */
934 void RemoveConnectorRules();
936 private:
937 /** Returns the first connector rule from the internal list. */
938 SvxMSDffConnectorRule* GetFirstRule();
939 /** Returns the next connector rule from the internal list. */
940 SvxMSDffConnectorRule* GetNextRule();
941 /** Updates the data of a connected shape in a connector rule. */
942 void UpdateConnection( sal_uInt32 nDffShapeId, SdrObject*& rpSdrObj, sal_uInt32* pnDffFlags = 0 );
944 private:
945 /** Stores data about an SdrObject processed during import. */
946 struct XclImpSdrInfo
948 SdrObject* mpSdrObj; /// Pointer to an SdrObject.
949 sal_uInt32 mnDffFlags; /// Shape flags from DFF stream.
950 inline explicit XclImpSdrInfo() : mpSdrObj( 0 ), mnDffFlags( 0 ) {}
951 inline void Set( SdrObject* pSdrObj, sal_uInt32 nDffFlags )
952 { mpSdrObj = pSdrObj; mnDffFlags = nDffFlags; }
954 typedef ::std::map< sal_uInt32, XclImpSdrInfo > XclImpSdrInfoMap;
955 typedef ::std::map< SdrObject*, sal_uInt32 > XclImpSdrObjMap;
957 XclImpSdrInfoMap maSdrInfoMap; /// Maps shape IDs to SdrObjects and flags.
958 XclImpSdrObjMap maSdrObjMap; /// Maps SdrObjects to shape IDs.
961 // ----------------------------------------------------------------------------
963 /** Simple implementation of the SVX DFF manager. Implements resolving palette
964 colors. Used by XclImpDffPropSet (as is), extended by XclImpDffManager.
966 class XclImpSimpleDffManager : public SvxMSDffManager, protected XclImpRoot
968 public:
969 explicit XclImpSimpleDffManager( const XclImpRoot& rRoot, SvStream& rDffStrm );
970 virtual ~XclImpSimpleDffManager();
972 protected:
973 /** Returns a color from the Excel color palette. */
974 virtual FASTBOOL GetColorFromPalette( USHORT nIndex, Color& rColor ) const;
977 // ----------------------------------------------------------------------------
979 class XclImpObjectManager;
980 class SdrObjList;
982 /** Derived from SvxMSDffManager and SvxMSConvertOCXControls, contains core
983 implementation of DFF stream import and OCX form control import.
985 class XclImpDffManager : protected XclImpSimpleDffManager, protected SvxMSConvertOCXControls
987 public:
988 explicit XclImpDffManager(
989 const XclImpRoot& rRoot,
990 XclImpObjectManager& rObjManager,
991 SvStream& rDffStrm );
992 virtual ~XclImpDffManager();
994 /** Initializes the internal progress bar with the passed size and starts it. */
995 void StartProgressBar( sal_Size nProgressSize );
997 /** Processes BIFF5 drawing objects without DFF data, inserts into the passed object list. */
998 void ProcessObject( SdrObjList* pObjList, const XclImpDrawObjBase& rDrawObj );
999 /** Processes the leading drawing group container in the DFF stream. */
1000 void ProcessDrawingGroup( SvStream& rDffStrm );
1001 /** Processes a drawing container for a sheet in the DFF stream, converts all objects. */
1002 void ProcessDrawing( SvStream& rDffStrm, sal_Size nStrmPos );
1004 /** Creates the SdrObject for the passed Excel TBX form control object. */
1005 SdrObject* CreateSdrObject( const XclImpTbxObjBase& rTbxObj, const Rectangle& rAnchorRect );
1006 /** Creates the SdrObject for the passed Excel OLE object or OCX form control object. */
1007 SdrObject* CreateSdrObject( const XclImpPictureObj& rPicObj, const Rectangle& rAnchorRect );
1009 /** Returns the default text margin in drawing layer units. */
1010 inline sal_Int32 GetDefaultTextMargin() const { return mnDefTextMargin; }
1011 /** Returns the used area in the sheet with the passed index. */
1012 ScRange GetUsedArea( SCTAB nScTab ) const;
1014 protected:
1015 // virtual functions of SvxMSDffManager
1017 /** Reads the client anchor from the DFF stream and sets it at the correct object. */
1018 virtual void ProcessClientAnchor2(
1019 SvStream& rDffStrm,
1020 DffRecordHeader& rHeader,
1021 void* pClientData,
1022 DffObjData& rObjData );
1023 /** Processes an DFF object, reads properties from DFF stream. */
1024 virtual SdrObject* ProcessObj(
1025 SvStream& rDffStrm,
1026 DffObjData& rDffObjData,
1027 void* pClientData,
1028 Rectangle& rTextRect,
1029 SdrObject* pOldSdrObj = 0 );
1030 /** Returns the BLIP stream position, based on the passed DFF stream position. */
1031 virtual ULONG Calc_nBLIPPos( ULONG nOrgVal, ULONG nStreamPos ) const;
1033 // virtual functions of SvxMSConvertOCXControls
1035 /** Inserts the passed control rxFComp into the form. Needs call to SetCurrentForm() before. */
1036 virtual sal_Bool InsertControl(
1037 const ::com::sun::star::uno::Reference<
1038 ::com::sun::star::form::XFormComponent >& rxFormComp,
1039 const ::com::sun::star::awt::Size& rSize,
1040 ::com::sun::star::uno::Reference<
1041 ::com::sun::star::drawing::XShape >* pxShape,
1042 BOOL bFloatingCtrl );
1044 private:
1045 /** Reads contents of a hyperlink property and returns the extracted URL. */
1046 String ReadHlinkProperty( SvStream& rDffStrm ) const;
1048 /** Processes a drawing group container (global drawing data). */
1049 void ProcessDggContainer( SvStream& rDffStrm, const DffRecordHeader& rDggHeader );
1050 /** Processes a drawing container (all drawing data of a sheet). */
1051 void ProcessDgContainer( SvStream& rDffStrm, const DffRecordHeader& rDgHeader );
1052 /** Processes the global shape group container (all shapes of a sheet). */
1053 void ProcessShGrContainer( SvStream& rDffStrm, const DffRecordHeader& rShGrHeader );
1054 /** Processes the solver container (connectors of a sheet). */
1055 void ProcessSolverContainer( SvStream& rDffStrm, const DffRecordHeader& rSolverHeader );
1056 /** Processes a shape or shape group container (one top-level shape). */
1057 void ProcessShContainer( SvStream& rDffStrm, const DffRecordHeader& rShHeader );
1059 /** Inserts the passed SdrObject into the document. This function takes ownership of pSdrObj! */
1060 void InsertSdrObject( SdrObjList* pObjList, const XclImpDrawObjBase& rDrawObj, SdrObject* pSdrObj );
1061 /** Stores the standard controls form for the passed sheet in mxCurrForm member. */
1062 void SetCurrentForm( SCTAB nScTab );
1064 /** Updates the used area of a sheet with the position and size of the passed object. */
1065 void UpdateUsedArea( const XclImpDrawObjBase& rDrawObj );
1067 private:
1068 typedef ::std::map< SCTAB, ScRange > ScRangeMap;
1069 typedef ScfRef< ScfProgressBar > ScfProgressBarRef;
1071 XclImpObjectManager& mrObjManager; /// The Excel object manager.
1072 XclImpSolverContainer maSolverCont; /// The solver container for connector rules.
1073 SotStorageStreamRef mxCtlsStrm; /// The 'Ctls' stream for OCX form controls.
1074 ScRangeMap maUsedAreaMap; /// Used ranges for all sheets.
1075 ScfProgressBarRef mxProgress; /// The progress bar used in ProcessObj().
1076 ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >
1077 mxCurrForm; /// Controls form of current sheet (needed in virtual functions).
1078 sal_uInt32 mnOleImpFlags; /// Application OLE import settings.
1079 sal_Int32 mnDefTextMargin; /// Default margin in text boxes.
1080 sal_Int32 mnLastCtrlIndex; /// Last insertion index of a form control (for macro events).
1081 SCTAB mnCurrFormScTab; /// Sheet index of form stored in mxCurrForm.
1084 // The object manager =========================================================
1086 /** Stores all drawing and OLE objects and additional data related to these objects. */
1087 class XclImpObjectManager : protected XclImpRoot
1089 typedef std::hash_map< sal_Int32, String > CntrlObjIdToName;
1090 typedef std::map< String, CntrlObjIdToName > CodeNameToCntrlObjIdInfo;
1091 public:
1092 explicit XclImpObjectManager( const XclImpRoot& rRoot );
1093 virtual ~XclImpObjectManager();
1095 // *** Read Excel records *** ---------------------------------------------
1097 /** Reads and returns a bitmap from the IMGDATA record. */
1098 static Graphic ReadImgData( XclImpStream& rStrm );
1100 /** Reads a plain OBJ record (without leading DFF data). */
1101 void ReadObj( XclImpStream& rStrm );
1102 /** Reads the MSODRAWINGGROUP record. */
1103 void ReadMsoDrawingGroup( XclImpStream& rStrm );
1104 /** Reads the MSODRAWING or MSODRAWINGSELECTION record. */
1105 void ReadMsoDrawing( XclImpStream& rStrm );
1106 /** Reads the NOTE record. */
1107 void ReadNote( XclImpStream& rStrm );
1109 /** Inserts a new chart object and reads the chart substream (BOF/EOF block).
1110 @descr Used to import chart sheets, which do not have a corresponding OBJ record. */
1111 void ReadTabChart( XclImpStream& rStrm );
1113 // *** Drawing objects *** ------------------------------------------------
1115 /** Finds the OBJ record data related to the DFF shape at the passed position. */
1116 XclImpDrawObjRef FindDrawObj( const DffRecordHeader& rHeader ) const;
1117 /** Finds the OBJ record data specified by the passed object identifier. */
1118 XclImpDrawObjRef FindDrawObj( const XclObjId& rObjId ) const;
1119 /** Finds the textbox data related to the DFF shape at the passed position. */
1120 const XclImpObjTextData* FindTextData( const DffRecordHeader& rHeader ) const;
1122 /** Sets the object with the passed identification to be skipped on import. */
1123 void SetSkipObj( SCTAB nScTab, sal_uInt16 nObjId );
1125 // *** Drawing object conversion *** --------------------------------------
1127 /** Returns the DFF manager (DFF stream converter). Don't call before the DFF stream is read. */
1128 XclImpDffManager& GetDffManager();
1129 /** Inserts all objects into the Calc document. */
1130 void ConvertObjects();
1132 /** Returns the default name for the passed object. */
1133 String GetDefaultObjName( const XclImpDrawObjBase& rDrawObj ) const;
1134 /** Returns the used area in the sheet with the passed index. */
1135 ScRange GetUsedArea( SCTAB nScTab ) const;
1136 void SetOleNameOverrideInfo( const CodeNameToCntrlObjIdInfo& rOverrideInfo ) { maOleCtrlNameOverride = rOverrideInfo; }
1137 String GetOleNameOverride( const XclObjId& nObjId );
1138 // ------------------------------------------------------------------------
1139 private:
1141 CodeNameToCntrlObjIdInfo maOleCtrlNameOverride;
1143 /** Reads and returns a bitmap from WMF/PICT format. */
1144 static void ReadWmf( Graphic& rGraphic, XclImpStream& rStrm );
1145 /** Reads and returns a bitmap from BMP format. */
1146 static void ReadBmp( Graphic& rGraphic, XclImpStream& rStrm );
1148 /** Reads contents of an DFF record and append data to internal DFF stream. */
1149 void ReadDffRecord( XclImpStream& rStrm );
1150 /** Reads a BIFF8 OBJ record following an MSODRAWING record. */
1151 void ReadObj8( XclImpStream& rStrm );
1152 /** Reads the TXO record and following CONTINUE records containing string and formatting. */
1153 void ReadTxo( XclImpStream& rStrm );
1155 /** Reads a BIFF3-BIFF5 NOTE record. */
1156 void ReadNote3( XclImpStream& rStrm );
1157 /** Reads a BIFF8 NOTE record. */
1158 void ReadNote8( XclImpStream& rStrm );
1160 /** Returns the size of the progress bar shown while processing all objects. */
1161 sal_Size GetProgressSize() const;
1163 // ------------------------------------------------------------------------
1164 private:
1165 typedef ::std::map< sal_Size, XclImpDrawObjRef > XclImpObjMap;
1166 typedef ::std::map< XclObjId, XclImpDrawObjRef > XclImpObjMapById;
1167 typedef ScfRef< XclImpObjTextData > XclImpObjTextRef;
1168 typedef ::std::map< sal_Size, XclImpObjTextRef > XclImpObjTextMap;
1169 typedef ::std::vector< XclObjId > XclObjIdVec;
1171 typedef ::std::map< sal_uInt16, String > DefObjNameMap;
1172 typedef ::std::vector< sal_Size > StreamPosVec;
1173 typedef ScfRef< XclImpDffManager > XclImpDffMgrRef;
1175 XclImpDrawObjVector maRawObjs; /// BIFF5 objects without DFF data.
1176 XclImpObjMap maObjMap; /// Maps BIFF8 drawing objects to DFF stream position.
1177 XclImpObjMapById maObjMapId; /// Maps BIFF8 drawing objects to sheet index and object ID.
1178 XclImpObjTextMap maTextMap; /// Maps BIFF8 TXO textbox data to DFF stream position.
1179 XclObjIdVec maSkipObjs; /// All objects to be skipped.
1181 DefObjNameMap maDefObjNames; /// Default base names for all object types.
1182 SvMemoryStream maDffStrm; /// Copy of DFF stream in memory.
1183 StreamPosVec maTabStrmPos; /// Start positions of DFF stream fragments for all sheets.
1184 XclImpDffMgrRef mxDffManager; /// The DFF stream converter.
1187 // DFF property set helper ====================================================
1189 /** This class reads an DFF property set (msofbtOPT record).
1191 It can return separate property values or an item set which contains items
1192 translated from these properties.
1194 class XclImpDffPropSet : protected XclImpRoot
1196 public:
1197 explicit XclImpDffPropSet( const XclImpRoot& rRoot );
1199 /** Reads an DFF property set from the stream.
1200 @descr The stream must point to the start of an DFF record containing properties. */
1201 void Read( XclImpStream& rStrm );
1203 /** Returns the specified property or the default value, if not extant. */
1204 sal_uInt32 GetPropertyValue( sal_uInt16 nPropId, sal_uInt32 nDefault = 0 ) const;
1206 /** Translates the properties and fills the item set. */
1207 void FillToItemSet( SfxItemSet& rItemSet ) const;
1209 private:
1210 typedef ::std::auto_ptr< SvMemoryStream > SvMemoryStreamPtr;
1212 SvMemoryStream maDummyStrm; /// Dummy stream for DFF manager.
1213 XclImpSimpleDffManager maDffManager;/// DFF manager used to resolve palette colors.
1214 SvMemoryStreamPtr mxMemStrm; /// Helper stream.
1217 XclImpStream& operator>>( XclImpStream& rStrm, XclImpDffPropSet& rPropSet );
1219 // ============================================================================
1221 #endif