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