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_XICHART_HXX
21 : #define SC_XICHART_HXX
22 :
23 : #include <vector>
24 : #include <map>
25 : #include <set>
26 : #include <list>
27 :
28 : #include <svl/itemset.hxx>
29 :
30 : #include "rangelst.hxx"
31 : #include "token.hxx"
32 : #include "xlchart.hxx"
33 : #include "xlstyle.hxx"
34 : #include "xiescher.hxx"
35 : #include "xistring.hxx"
36 : #include <boost/shared_ptr.hpp>
37 : #include <boost/ptr_container/ptr_map.hpp>
38 :
39 : namespace com { namespace sun { namespace star {
40 : namespace awt
41 : {
42 : struct Rectangle;
43 : }
44 : namespace frame
45 : {
46 : class XModel;
47 : }
48 : namespace drawing
49 : {
50 : class XShape;
51 : }
52 : namespace chart2
53 : {
54 : struct ScaleData;
55 : class XChartDocument;
56 : class XDiagram;
57 : class XCoordinateSystem;
58 : class XChartType;
59 : class XDataSeries;
60 : class XRegressionCurve;
61 : class XAxis;
62 : class XLegend;
63 : class XTitle;
64 : class XFormattedString;
65 : namespace data
66 : {
67 : class XDataProvider;
68 : class XDataSequence;
69 : class XLabeledDataSequence;
70 : }
71 : }
72 : } } }
73 :
74 : struct XclObjLineData;
75 : struct XclObjFillData;
76 :
77 : // Common =====================================================================
78 :
79 : struct XclImpChRootData;
80 : class XclImpChChart;
81 : class ScTokenArray;
82 :
83 : /** Base class for complex chart classes, provides access to other components of the chart. */
84 1522 : class XclImpChRoot : public XclImpRoot
85 : {
86 : public:
87 : explicit XclImpChRoot( const XclImpRoot& rRoot, XclImpChChart& rChartData );
88 : virtual ~XclImpChRoot();
89 :
90 : /** Returns this root instance - for code readability in derived classes. */
91 2178 : inline const XclImpChRoot& GetChRoot() const { return *this; }
92 : /** Returns a reference to the parent chart data object. */
93 : XclImpChChart& GetChartData() const;
94 : /** Returns chart type info for a unique chart type identifier. */
95 : const XclChTypeInfo& GetChartTypeInfo( XclChTypeId eType ) const;
96 : /** Returns the first fitting chart type info for an Excel chart type record identifier. */
97 : const XclChTypeInfo& GetChartTypeInfo( sal_uInt16 nRecId ) const;
98 : /** Returns an info struct about auto formatting for the passed object type. */
99 : const XclChFormatInfo& GetFormatInfo( XclChObjectType eObjType ) const;
100 :
101 : /** Returns the default text color for charts. */
102 : Color GetFontAutoColor() const;
103 : /** Returns the automatic line color of linear series. */
104 : Color GetSeriesLineAutoColor( sal_uInt16 nFormatIdx ) const;
105 : /** Returns the automatic fill color of filled series. */
106 : Color GetSeriesFillAutoColor( sal_uInt16 nFormatIdx ) const;
107 :
108 : /** Starts the API chart document conversion. Must be called once before all API conversion. */
109 : void InitConversion(
110 : const ::com::sun::star::uno::Reference<
111 : com::sun::star::chart2::XChartDocument>& xChartDoc, const Rectangle& rChartRect ) const;
112 :
113 : /** Finishes the API chart document conversion. Must be called once after all API conversion. */
114 : void FinishConversion( XclImpDffConverter& rDffConv ) const;
115 :
116 : /** Returns the data provider for the chart document. */
117 : ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataProvider >
118 : GetDataProvider() const;
119 : /** Returns the drawing shape interface of the specified title object. */
120 : ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
121 : GetTitleShape( const XclChTextKey& rTitleKey ) const;
122 :
123 : /** Converts the passed horizontal coordinate from Excel chart units into 1/100 mm. */
124 : sal_Int32 CalcHmmFromChartX( sal_Int32 nPosX ) const;
125 : /** Converts the passed vertical coordinate from Excel chart units into 1/100 mm. */
126 : sal_Int32 CalcHmmFromChartY( sal_Int32 nPosY ) const;
127 : /** Converts the passed rectangle from Excel chart units into 1/100 mm. */
128 : ::com::sun::star::awt::Rectangle CalcHmmFromChartRect( const XclChRectangle& rRect ) const;
129 :
130 : /** Converts the passed horizontal coordinate from 1/100 mm into a relative position. */
131 : double CalcRelativeFromHmmX( sal_Int32 nPosX ) const;
132 : /** Converts the passed vertical coordinate from 1/100 mm into a relative position. */
133 : double CalcRelativeFromHmmY( sal_Int32 nPosY ) const;
134 :
135 : /** Converts the passed horizontal coordinate from Excel chart units into a relative position. */
136 : double CalcRelativeFromChartX( sal_Int32 nPosX ) const;
137 : /** Converts the passed vertical coordinate from Excel chart units into a relative position. */
138 : double CalcRelativeFromChartY( sal_Int32 nPosY ) const;
139 :
140 : /** Writes all line properties to the passed property set. */
141 : void ConvertLineFormat(
142 : ScfPropertySet& rPropSet,
143 : const XclChLineFormat& rLineFmt,
144 : XclChPropertyMode ePropMode ) const;
145 : /** Writes solid area properties to the passed property set. */
146 : void ConvertAreaFormat(
147 : ScfPropertySet& rPropSet,
148 : const XclChAreaFormat& rAreaFmt,
149 : XclChPropertyMode ePropMode ) const;
150 : /** Writes gradient or bitmap area properties to the passed property set. */
151 : void ConvertEscherFormat(
152 : ScfPropertySet& rPropSet,
153 : const XclChEscherFormat& rEscherFmt,
154 : const XclChPicFormat* pPicFmt,
155 : sal_uInt32 nDffFillType,
156 : XclChPropertyMode ePropMode ) const;
157 : /** Writes font properties to the passed property set. */
158 : void ConvertFont(
159 : ScfPropertySet& rPropSet,
160 : sal_uInt16 nFontIdx,
161 : const Color* pFontColor = 0 ) const;
162 :
163 : /** Writes the pie rotation property for the passed angle. */
164 : static void ConvertPieRotation(
165 : ScfPropertySet& rPropSet,
166 : sal_uInt16 nAngle );
167 :
168 : private:
169 : typedef boost::shared_ptr< XclImpChRootData > XclImpChRootDataRef;
170 : XclImpChRootDataRef mxChData; /// Reference to the root data object.
171 : };
172 :
173 : // ----------------------------------------------------------------------------
174 :
175 : /** Base class for chart record groups. Provides helper functions to read sub records.
176 :
177 : A chart record group consists of a header record, followed by a CHBEGIN
178 : record, followed by group sub records, and finished with a CHEND record.
179 : */
180 998 : class XclImpChGroupBase
181 : {
182 : public:
183 : virtual ~XclImpChGroupBase();
184 :
185 : /** Reads the entire record group.
186 : @descr First calls ReadHeaderRecord() to read the contents of the
187 : header record. Then tries to read the sub records. If next record
188 : is a CHBEGIN record, ReadSubRecord() is called for each following
189 : record until a CHEND record is found. */
190 : void ReadRecordGroup( XclImpStream& rStrm );
191 :
192 : /** Helper to skip a CHBEGIN/CHEND block, includes nested blocks. */
193 : static void SkipBlock( XclImpStream& rStrm );
194 :
195 : /** Derived classes implement to read the group header record. */
196 : virtual void ReadHeaderRecord( XclImpStream& rStrm ) = 0;
197 : /** Derived classes implement to read a record from the group. */
198 : virtual void ReadSubRecord( XclImpStream& rStrm ) = 0;
199 : };
200 :
201 : // Frame formatting ===========================================================
202 :
203 248 : class XclImpChFramePos
204 : {
205 : public:
206 : /** Reads the CHFRAMEPOS record (frame position and size). */
207 : void ReadChFramePos( XclImpStream& rStrm );
208 :
209 : /** Returns read-only access to the imported frame position data. */
210 80 : inline const XclChFramePos& GetFramePosData() const { return maData; }
211 :
212 : private:
213 : XclChFramePos maData; /// Position of the frame.
214 : };
215 :
216 : typedef boost::shared_ptr< XclImpChFramePos > XclImpChFramePosRef;
217 :
218 : // ----------------------------------------------------------------------------
219 :
220 : /** The CHLINEFORMAT record containing line formatting data. */
221 : class XclImpChLineFormat
222 : {
223 : public:
224 : /** Creates a new line format object with automatic formatting. */
225 358 : inline explicit XclImpChLineFormat() {}
226 : /** Creates a new line format object with the passed formatting. */
227 160 : inline explicit XclImpChLineFormat( const XclChLineFormat& rLineFmt ) : maData( rLineFmt ) {}
228 :
229 : /** Reads the CHLINEFORMAT record (basic line properties). */
230 : void ReadChLineFormat( XclImpStream& rStrm );
231 :
232 : /** Returns true, if the line format is set to automatic. */
233 360 : inline bool IsAuto() const { return ::get_flag( maData.mnFlags, EXC_CHLINEFORMAT_AUTO ); }
234 : /** Returns true, if the line style is set to something visible. */
235 2 : inline bool HasLine() const { return IsAuto() || (maData.mnPattern != EXC_CHLINEFORMAT_NONE); }
236 : /** Returns the line width of this line format (returns 'single', if the line is invisible). */
237 1 : inline sal_Int16 GetWeight() const { return (IsAuto() || !HasLine()) ? EXC_CHLINEFORMAT_SINGLE : maData.mnWeight; }
238 : /** Returns true, if the "show axis" flag is set. */
239 80 : inline bool IsShowAxis() const { return ::get_flag( maData.mnFlags, EXC_CHLINEFORMAT_SHOWAXIS ); }
240 :
241 : /** Converts and writes the contained data to the passed property set. */
242 : void Convert( const XclImpChRoot& rRoot,
243 : ScfPropertySet& rPropSet, XclChObjectType eObjType,
244 : sal_uInt16 nFormatIdx = EXC_CHDATAFORMAT_UNKNOWN ) const;
245 :
246 : private:
247 : XclChLineFormat maData; /// Contents of the CHLINEFORMAT record.
248 : };
249 :
250 : typedef boost::shared_ptr< XclImpChLineFormat > XclImpChLineFormatRef;
251 :
252 : // ----------------------------------------------------------------------------
253 :
254 : /** The CHAREAFORMAT record containing simple area formatting data (solid or patterns). */
255 : class XclImpChAreaFormat
256 : {
257 : public:
258 : /** Creates a new area format object with automatic formatting. */
259 356 : inline explicit XclImpChAreaFormat() {}
260 : /** Creates a new area format object with the passed formatting. */
261 80 : inline explicit XclImpChAreaFormat( const XclChAreaFormat& rAreaFmt ) : maData( rAreaFmt ) {}
262 :
263 : /** Reads the CHAREAFORMAT record (basic fill properties, e.g. transparent or colored). */
264 : void ReadChAreaFormat( XclImpStream& rStrm );
265 :
266 : /** Returns true, if the area format is set to automatic. */
267 121 : inline bool IsAuto() const { return ::get_flag( maData.mnFlags, EXC_CHAREAFORMAT_AUTO ); }
268 : /** Returns true, if the area style is set to something visible. */
269 0 : inline bool HasArea() const { return IsAuto() || (maData.mnPattern != EXC_PATT_NONE); }
270 :
271 : /** Converts and writes the contained data to the passed property set. */
272 : void Convert( const XclImpChRoot& rRoot,
273 : ScfPropertySet& rPropSet, XclChObjectType eObjType,
274 : sal_uInt16 nFormatIdx = EXC_CHDATAFORMAT_UNKNOWN ) const;
275 :
276 : private:
277 : XclChAreaFormat maData; /// Contents of the CHAREAFORMAT record.
278 : };
279 :
280 : typedef boost::shared_ptr< XclImpChAreaFormat > XclImpChAreaFormatRef;
281 :
282 : // ----------------------------------------------------------------------------
283 :
284 : /** The CHESCHERFORMAT record containing complex area formatting data (bitmaps, hatches). */
285 190 : class XclImpChEscherFormat : public XclImpChGroupBase
286 : {
287 : public:
288 : explicit XclImpChEscherFormat( const XclImpRoot& rRoot );
289 :
290 : /** Reads the CHESCHERFORMAT record (complex fill data) (called by base class). */
291 : virtual void ReadHeaderRecord( XclImpStream& rStrm );
292 : /** Reads a record from the CHESCHERFORMAT group (called by base class). */
293 : virtual void ReadSubRecord( XclImpStream& rStrm );
294 :
295 : /** Converts and writes the contained data to the passed property set. */
296 : void Convert( const XclImpChRoot& rRoot, ScfPropertySet& rPropSet,
297 : XclChObjectType eObjType, bool bUsePicFmt ) const;
298 :
299 : private:
300 : XclChEscherFormat maData; /// Fill properties for complex areas (CHESCHERFORMAT record).
301 : XclChPicFormat maPicFmt; /// Image options, e.g. stretched, stacked (CHPICFORMAT record).
302 : sal_uInt32 mnDffFillType; /// Fill type imported from the DFF property set.
303 : };
304 :
305 : typedef boost::shared_ptr< XclImpChEscherFormat > XclImpChEscherFormatRef;
306 :
307 : // ----------------------------------------------------------------------------
308 :
309 : /** Base class for record groups containing frame formatting.
310 :
311 : Frame formatting can be part of several record groups, e.g. CHFRAME,
312 : CHDATAFORMAT, CHDROPBAR. It consists of CHLINEFORMAT, CHAREAFORMAT, and
313 : CHESCHERFORMAT group.
314 : */
315 375 : class XclImpChFrameBase : public XclImpChGroupBase
316 : {
317 : public:
318 : /** Creates a new frame object without internal formatting objects. */
319 116 : inline explicit XclImpChFrameBase() {}
320 : /** Creates a new frame object with specific default formatting. */
321 : explicit XclImpChFrameBase( const XclChFormatInfo& rFmtInfo );
322 :
323 : /** Reads a frame formatting record (called by base class). */
324 : virtual void ReadSubRecord( XclImpStream& rStrm );
325 :
326 : /** Returns true, if the line format is set to automatic. */
327 58 : inline bool IsAutoLine() const { return !mxLineFmt || mxLineFmt->IsAuto(); }
328 : /** Returns true, if the line style is set to something visible. */
329 1 : inline bool HasLine() const { return IsAutoLine() || mxLineFmt->HasLine(); }
330 : /** Returns the line weight used for this frame. */
331 1 : inline sal_Int16 GetLineWeight() const { return mxLineFmt ? mxLineFmt->GetWeight() : EXC_CHLINEFORMAT_SINGLE; }
332 :
333 : /** Returns true, if the area format is set to automatic. */
334 95 : inline bool IsAutoArea() const { return !mxEscherFmt && (!mxAreaFmt || mxAreaFmt->IsAuto()); }
335 : /** Returns true, if the area style is set to something visible. */
336 : inline bool HasArea() const { return mxEscherFmt || IsAutoArea() || mxAreaFmt->HasArea(); }
337 :
338 : protected:
339 : /** Converts and writes the contained line formatting to the passed property set. */
340 : void ConvertLineBase( const XclImpChRoot& rRoot,
341 : ScfPropertySet& rPropSet, XclChObjectType eObjType,
342 : sal_uInt16 nFormatIdx = EXC_CHDATAFORMAT_UNKNOWN ) const;
343 : /** Converts and writes the contained area formatting to the passed property set. */
344 : void ConvertAreaBase( const XclImpChRoot& rRoot,
345 : ScfPropertySet& rPropSet, XclChObjectType eObjType,
346 : sal_uInt16 nFormatIdx = EXC_CHDATAFORMAT_UNKNOWN, bool bUsePicFmt = false ) const;
347 : /** Converts and writes the contained data to the passed property set. */
348 : void ConvertFrameBase( const XclImpChRoot& rRoot,
349 : ScfPropertySet& rPropSet, XclChObjectType eObjType,
350 : sal_uInt16 nFormatIdx = EXC_CHDATAFORMAT_UNKNOWN, bool bUsePicFmt = false ) const;
351 :
352 : protected:
353 : XclImpChLineFormatRef mxLineFmt; /// Line format (CHLINEFORMAT record).
354 : XclImpChAreaFormatRef mxAreaFmt; /// Area format (CHAREAFORMAT record).
355 : XclImpChEscherFormatRef mxEscherFmt; /// Complex area format (CHESCHERFORMAT record).
356 : };
357 :
358 : // ----------------------------------------------------------------------------
359 :
360 : /** Represents the CHFRAME record group containing object frame properties.
361 :
362 : The CHFRAME group consists of: CHFRAME, CHBEGIN, CHLINEFORMAT,
363 : CHAREAFORMAT, CHESCHERFORMAT group, CHEND.
364 : */
365 518 : class XclImpChFrame : public XclImpChFrameBase, protected XclImpChRoot
366 : {
367 : public:
368 : /** Creates a new frame object with specific default formatting. */
369 : explicit XclImpChFrame(
370 : const XclImpChRoot& rRoot,
371 : XclChObjectType eObjType );
372 :
373 : /** Reads the CHFRAME record (called by base class). */
374 : virtual void ReadHeaderRecord( XclImpStream& rStrm );
375 :
376 : /** Sets formatting from BIFF3-BIFF5 OBJ record, if own formatting is invisible. */
377 : void UpdateObjFrame( const XclObjLineData& rLineData, const XclObjFillData& rFillData );
378 :
379 : /** Converts and writes the contained data to the passed property set. */
380 : void Convert( ScfPropertySet& rPropSet, bool bUsePicFmt = false ) const;
381 :
382 : private:
383 : XclChFrame maData; /// Contents of the CHFRAME record.
384 : XclChObjectType meObjType; /// Type of the represented object.
385 : };
386 :
387 : typedef boost::shared_ptr< XclImpChFrame > XclImpChFrameRef;
388 :
389 : // Source links ===============================================================
390 :
391 : class XclImpChSourceLink : protected XclImpChRoot
392 : {
393 : public:
394 : typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSequence > XDataSequenceRef;
395 : typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XFormattedString > XFormattedStringRef;
396 : typedef ::com::sun::star::uno::Sequence< XFormattedStringRef > XFormattedStringSeq;
397 :
398 : public:
399 : explicit XclImpChSourceLink( const XclImpChRoot& rRoot );
400 : virtual ~XclImpChSourceLink();
401 :
402 : /** Reads the CHSOURCELINK record (link to source data). */
403 : void ReadChSourceLink( XclImpStream& rStrm );
404 : /** Sets explicit string data for this text object. */
405 : void SetString( const String& rString );
406 : /** Sets formatting runs read from a CHFORMATRUNS record. */
407 : void SetTextFormats( const XclFormatRunVec& rFormats );
408 :
409 : /** Returns the destination object (title, values, category, ...). */
410 160 : inline sal_uInt8 GetDestType() const { return maData.mnDestType; }
411 : /** Returns the link type (to worksheet, directly, default, ...). */
412 347 : inline sal_uInt8 GetLinkType() const { return maData.mnLinkType; }
413 :
414 : /** Returns true, if the source link contains explicit string data. */
415 84 : inline bool HasString() const { return mxString && !mxString->IsEmpty(); }
416 : /** Returns explicit string data or an empty string. */
417 38 : inline const String& GetString() const { return mxString ? mxString->GetText() : String::EmptyString(); }
418 : /** Returns the number of data points of this source link. */
419 : sal_uInt16 GetCellCount() const;
420 :
421 : /** Converts and writes the contained number format to the passed property set. */
422 : void ConvertNumFmt( ScfPropertySet& rPropSet, bool bPercent ) const;
423 :
424 : /** Creates a data sequence containing the link into the Calc document. */
425 : XDataSequenceRef CreateDataSequence( const ::rtl::OUString& rRole ) const;
426 : /** Creates a sequence of formatted string objects. */
427 : XFormattedStringSeq CreateStringSequence( const XclImpChRoot& rRoot,
428 : sal_uInt16 nLeadFontIdx, const Color& rLeadFontColor ) const;
429 :
430 : void FillSourceLink(::std::vector<ScTokenRef>& rTokens) const;
431 :
432 : private:
433 : XclChSourceLink maData; /// Contents of the CHSOURCELINK record.
434 : XclImpStringRef mxString; /// Text data (CHSTRING record).
435 : boost::shared_ptr< ScTokenArray> mxTokenArray; /// Token array representing the data ranges.
436 : };
437 :
438 : typedef boost::shared_ptr< XclImpChSourceLink > XclImpChSourceLinkRef;
439 :
440 : // Text =======================================================================
441 :
442 : /** Base class for objects with font settings. Provides font conversion helper functions. */
443 267 : class XclImpChFontBase
444 : {
445 : public:
446 : virtual ~XclImpChFontBase();
447 :
448 : /** Derived classes return the leading font index for the text object. */
449 : virtual sal_uInt16 GetFontIndex() const = 0;
450 : /** Derived classes return the leading font color for the text object. */
451 : virtual Color GetFontColor() const = 0;
452 : /** Derived classes return the rotation value for the text object. */
453 : virtual sal_uInt16 GetRotation() const = 0;
454 :
455 : /** Converts and writes the contained font settings to the passed property set. */
456 : void ConvertFontBase( const XclImpChRoot& rRoot, ScfPropertySet& rPropSet ) const;
457 : /** Converts and writes the contained rotation settings to the passed property set. */
458 : void ConvertRotationBase( const XclImpChRoot& rRoot, ScfPropertySet& rPropSet, bool bSupportsStacked ) const;
459 : };
460 :
461 : // ----------------------------------------------------------------------------
462 :
463 : /** The CHFONT record containing a font index for text objects. */
464 : class XclImpChFont
465 : {
466 : public:
467 : explicit XclImpChFont();
468 : /** Reads the CHFONT record (font index). */
469 : void ReadChFont( XclImpStream& rStrm );
470 :
471 : /** Returns the contained font index. */
472 181 : inline sal_uInt16 GetFontIndex() const { return mnFontIdx; }
473 :
474 : private:
475 : sal_uInt16 mnFontIdx; /// Index into font buffer.
476 : };
477 :
478 : typedef boost::shared_ptr< XclImpChFont > XclImpChFontRef;
479 :
480 : // ----------------------------------------------------------------------------
481 :
482 : /** Represents the CHTEXT record group containing text object properties.
483 :
484 : The CHTEXT group consists of: CHTEXT, CHBEGIN, CHFRAMEPOS, CHFONT,
485 : CHFORMATRUNS, CHSOURCELINK, CHSTRING, CHFRAME group, CHOBJECTLINK, and CHEND.
486 : */
487 374 : class XclImpChText : public XclImpChGroupBase, public XclImpChFontBase, protected XclImpChRoot
488 : {
489 : public:
490 : typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XTitle > XTitleRef;
491 :
492 : public:
493 : explicit XclImpChText( const XclImpChRoot& rRoot );
494 :
495 : /** Reads the CHTEXT record (called by base class). */
496 : virtual void ReadHeaderRecord( XclImpStream& rStrm );
497 : /** Reads a record from the CHTEXT group (called by base class). */
498 : virtual void ReadSubRecord( XclImpStream& rStrm );
499 :
500 : /** Returns the leading font index for the text object. */
501 : virtual sal_uInt16 GetFontIndex() const;
502 : /** Returns the leading font color for the text object. */
503 : virtual Color GetFontColor() const;
504 : /** Returns the rotation value for the text object. */
505 : virtual sal_uInt16 GetRotation() const;
506 :
507 : /** Sets explicit string data for this text object. */
508 : void SetString( const String& rString );
509 : /** Updates missing parts of this text object from the passed object. */
510 : void UpdateText( const XclImpChText* pParentText );
511 : /** Updates display type of this data point label text object. */
512 : void UpdateDataLabel( bool bCateg, bool bValue, bool bPercent );
513 :
514 : /** Returns the target object this text is linked to. */
515 86 : inline sal_uInt16 GetLinkTarget() const { return maObjLink.mnTarget; }
516 : /** Returns the position of the data point label this text is linked to. */
517 130 : inline const XclChDataPointPos& GetPointPos() const { return maObjLink.maPointPos; }
518 : /** Returns true, if this text group contains string data. */
519 63 : inline bool HasString() const { return mxSrcLink && mxSrcLink->HasString(); }
520 : /** Returns true, if the text object is marked as deleted. */
521 86 : inline bool IsDeleted() const { return ::get_flag( maData.mnFlags, EXC_CHTEXT_DELETED ); }
522 :
523 : /** Converts and writes the contained font settings to the passed property set. */
524 : void ConvertFont( ScfPropertySet& rPropSet ) const;
525 : /** Converts and writes the contained rotation settings to the passed property set. */
526 : void ConvertRotation( ScfPropertySet& rPropSet, bool bSupportsStacked ) const;
527 : /** Converts and writes the contained frame data to the passed property set. */
528 : void ConvertFrame( ScfPropertySet& rPropSet ) const;
529 : /** Converts and writes the contained number format to the passed property set. */
530 : void ConvertNumFmt( ScfPropertySet& rPropSet, bool bPercent ) const;
531 : /** Converts and writes all contained data to the passed data point label property set. */
532 : void ConvertDataLabel( ScfPropertySet& rPropSet, const XclChTypeInfo& rTypeInfo ) const;
533 : /** Creates a title text object. */
534 : XTitleRef CreateTitle() const;
535 : /** Converts the manual position of the specified title */
536 : void ConvertTitlePosition( const XclChTextKey& rTitleKey ) const;
537 :
538 : private:
539 : using XclImpChRoot::ConvertFont;
540 :
541 : /** Reads a CHFRLABELPROPS record. */
542 : void ReadChFrLabelProps( XclImpStream& rStrm );
543 :
544 : private:
545 : typedef boost::shared_ptr< XclChFrLabelProps > XclChFrLabelPropsRef;
546 :
547 : XclChText maData; /// Contents of the CHTEXT record.
548 : XclChObjectLink maObjLink; /// Link target for this text object.
549 : XclFormatRunVec maFormats; /// Formatting runs (CHFORMATRUNS record).
550 : XclImpChFramePosRef mxFramePos; /// Relative text frame position (CHFRAMEPOS record).
551 : XclImpChSourceLinkRef mxSrcLink; /// Linked data (CHSOURCELINK with CHSTRING record).
552 : XclImpChFrameRef mxFrame; /// Text object frame properties (CHFRAME group).
553 : XclImpChFontRef mxFont; /// Index into font buffer (CHFONT record).
554 : XclChFrLabelPropsRef mxLabelProps; /// Extended data label properties (CHFRLABELPROPS record).
555 : };
556 :
557 : typedef boost::shared_ptr< XclImpChText > XclImpChTextRef;
558 :
559 : // Data series ================================================================
560 :
561 : /** The CHMARKERFORMAT record containing data point marker formatting data. */
562 116 : class XclImpChMarkerFormat
563 : {
564 : public:
565 : /** Reads the CHMARKERFORMAT record (data point marker properties). */
566 : void ReadChMarkerFormat( XclImpStream& rStrm );
567 :
568 : /** Returns true, if the marker format is set to automatic. */
569 58 : inline bool IsAuto() const { return ::get_flag( maData.mnFlags, EXC_CHMARKERFORMAT_AUTO ); }
570 :
571 : /** Converts and writes the contained data to the passed property set. */
572 : void Convert( const XclImpChRoot& rRoot, ScfPropertySet& rPropSet,
573 : sal_uInt16 nFormatIdx, sal_Int16 nLineWeight ) const;
574 : /** Sets the marker fill color as main color to the passed property set. */
575 : void ConvertColor( const XclImpChRoot& rRoot,
576 : ScfPropertySet& rPropSet, sal_uInt16 nFormatIdx ) const;
577 :
578 : private:
579 : XclChMarkerFormat maData; /// Contents of the CHMARKERFORMAT record.
580 : };
581 :
582 : typedef boost::shared_ptr< XclImpChMarkerFormat > XclImpChMarkerFormatRef;
583 :
584 : // ----------------------------------------------------------------------------
585 :
586 : /** The CHPIEFORMAT record containing data point formatting data for pie segments. */
587 : class XclImpChPieFormat
588 : {
589 : public:
590 : explicit XclImpChPieFormat();
591 : /** Reads the CHPIEFORMAT record (pie segment properties). */
592 : void ReadChPieFormat( XclImpStream& rStrm );
593 : /** Converts and writes the contained data to the passed property set. */
594 : void Convert( ScfPropertySet& rPropSet ) const;
595 :
596 : private:
597 : sal_uInt16 mnPieDist; /// Pie distance to diagram center.
598 : };
599 :
600 : typedef boost::shared_ptr< XclImpChPieFormat > XclImpChPieFormatRef;
601 :
602 : // ----------------------------------------------------------------------------
603 :
604 : /** The CHSERIESFORMAT record containing additional settings for a data series. */
605 : class XclImpChSeriesFormat
606 : {
607 : public:
608 : explicit XclImpChSeriesFormat();
609 : /** Reads the CHSERIESFORMAT record (additional settings for a series). */
610 : void ReadChSeriesFormat( XclImpStream& rStrm );
611 : /** Returns true, if the series line is smoothed. */
612 0 : inline bool HasSpline() const { return ::get_flag( mnFlags, EXC_CHSERIESFORMAT_SMOOTHED ); }
613 :
614 : private:
615 : sal_uInt16 mnFlags; /// Additional flags.
616 : };
617 :
618 : typedef boost::shared_ptr< XclImpChSeriesFormat > XclImpChSeriesFormatRef;
619 :
620 : // ----------------------------------------------------------------------------
621 :
622 : /** The CH3DDATAFORMAT record containing the bar type in 3D bar charts. */
623 116 : class XclImpCh3dDataFormat
624 : {
625 : public:
626 : /** Reads the CH3DDATAFORMAT record (3D bar properties). */
627 : void ReadCh3dDataFormat( XclImpStream& rStrm );
628 : /** Converts and writes the contained data to the passed property set. */
629 : void Convert( ScfPropertySet& rPropSet ) const;
630 :
631 : private:
632 : XclCh3dDataFormat maData; /// Contents of the CH3DDATAFORMAT record.
633 : };
634 :
635 : typedef boost::shared_ptr< XclImpCh3dDataFormat > XclImpCh3dDataFormatRef;
636 :
637 : // ----------------------------------------------------------------------------
638 :
639 : /** The CHATTACHEDLABEL record that contains the type of a data point label. */
640 64 : class XclImpChAttachedLabel : protected XclImpChRoot
641 : {
642 : public:
643 : explicit XclImpChAttachedLabel( const XclImpChRoot& rRoot );
644 : /** Reads the CHATTACHEDLABEL record (data series/point labels). */
645 : void ReadChAttachedLabel( XclImpStream& rStrm );
646 : /** Creates a CHTEXT group for the label. Clones xParentText and sets additional label settings */
647 : XclImpChTextRef CreateDataLabel( const XclImpChText* pParent ) const;
648 :
649 : private:
650 : sal_uInt16 mnFlags; /// Additional flags.
651 : };
652 :
653 : typedef boost::shared_ptr< XclImpChAttachedLabel > XclImpChAttLabelRef;
654 :
655 : // ----------------------------------------------------------------------------
656 :
657 : /** Represents the CHDATAFORMAT record group containing data point properties.
658 :
659 : The CHDATAFORMAT group consists of: CHDATAFORMAT, CHBEGIN, CHFRAME group,
660 : CHMARKERFORMAT, CHPIEFORMAT, CH3DDATAFORMAT, CHSERIESFORMAT,
661 : CHATTACHEDLABEL, CHEND.
662 : */
663 232 : class XclImpChDataFormat : public XclImpChFrameBase, protected XclImpChRoot
664 : {
665 : public:
666 : explicit XclImpChDataFormat( const XclImpChRoot& rRoot );
667 :
668 : /** Reads the CHDATAFORMAT record (called by base class). */
669 : virtual void ReadHeaderRecord( XclImpStream& rStrm );
670 : /** Reads a record from the CHDATAFORMAT group (called by base class). */
671 : virtual void ReadSubRecord( XclImpStream& rStrm );
672 :
673 : /** Sets this object to the specified data point position. */
674 : void SetPointPos( const XclChDataPointPos& rPointPos, sal_uInt16 nFormatIdx );
675 : /** Sets type and text formatting for a data point label (CHTEXT group). */
676 65 : inline void SetDataLabel( XclImpChTextRef xLabel ) { mxLabel = xLabel; }
677 :
678 : /** Updates default data format for series group. */
679 : void UpdateGroupFormat( const XclChExtTypeInfo& rTypeInfo );
680 : /** Updates missing series settings from the passed chart type group data format. */
681 : void UpdateSeriesFormat( const XclChExtTypeInfo& rTypeInfo, const XclImpChDataFormat* pGroupFmt );
682 : /** Updates missing data point settings from the passed series format. */
683 : void UpdatePointFormat( const XclChExtTypeInfo& rTypeInfo, const XclImpChDataFormat* pSeriesFmt );
684 : /** Updates default data format for trend lines. */
685 : void UpdateTrendLineFormat();
686 :
687 : /** Returns the position of the data point described by this group. */
688 310 : inline const XclChDataPointPos& GetPointPos() const { return maData.maPointPos; }
689 : /** Returns the format index of the data point described by this group. */
690 59 : inline sal_uInt16 GetFormatIdx() const { return maData.mnFormatIdx; }
691 : /** Returns true, if markers are set to automatic format. */
692 114 : inline bool IsAutoMarker() const { return !mxMarkerFmt || mxMarkerFmt->IsAuto(); }
693 : /** Returns true, if the series line is smoothed. */
694 40 : inline bool HasSpline() const { return mxSeriesFmt && mxSeriesFmt->HasSpline(); }
695 : /** Returns the data label text object. */
696 76 : inline const XclImpChText* GetDataLabel() const { return mxLabel.get(); }
697 :
698 : /** Converts and writes the contained data to the passed property set. */
699 : void Convert( ScfPropertySet& rPropSet, const XclChExtTypeInfo& rTypeInfo ) const;
700 : /** Writes the line format only, e.g. for trend lines or error bars. */
701 : void ConvertLine( ScfPropertySet& rPropSet, XclChObjectType eObjType ) const;
702 : /** Writes the area format only for the series or a data point. */
703 : void ConvertArea( ScfPropertySet& rPropSet, sal_uInt16 nFormatIdx, bool bUsePicFmt ) const;
704 :
705 : private:
706 : /** Removes unused formatting (e.g. pie distance in a bar chart). */
707 : void RemoveUnusedFormats( const XclChExtTypeInfo& rTypeInfo );
708 : /** Updates or creates the data point label. */
709 : void UpdateDataLabel( const XclImpChDataFormat* pParentFmt );
710 :
711 : private:
712 : XclChDataFormat maData; /// Contents of the CHDATAFORMAT record.
713 : XclImpChMarkerFormatRef mxMarkerFmt; /// Data point marker (CHMARKERFORMAT record).
714 : XclImpChPieFormatRef mxPieFmt; /// Pie segment format (CHPIEFORMAT record).
715 : XclImpChSeriesFormatRef mxSeriesFmt; /// Series properties (CHSERIESFORMAT record).
716 : XclImpCh3dDataFormatRef mx3dDataFmt; /// 3D bar format (CH3DDATAFORMAT record).
717 : XclImpChAttLabelRef mxAttLabel; /// Data point label type (CHATTACHEDLABEL record).
718 : XclImpChTextRef mxLabel; /// Data point label formatting (CHTEXT group).
719 : };
720 :
721 : typedef boost::shared_ptr< XclImpChDataFormat > XclImpChDataFormatRef;
722 :
723 : // ----------------------------------------------------------------------------
724 :
725 : /** Represents the CHSERTRENDLINE record containing settings for a trend line. */
726 0 : class XclImpChSerTrendLine : protected XclImpChRoot
727 : {
728 : public:
729 : typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XRegressionCurve > XRegressionCurveRef;
730 :
731 : public:
732 : explicit XclImpChSerTrendLine( const XclImpChRoot& rRoot );
733 :
734 : /** Reads the CHSERTRENDLINE record. */
735 : void ReadChSerTrendLine( XclImpStream& rStrm );
736 : /** Sets formatting information for the trend line. */
737 0 : inline void SetDataFormat( XclImpChDataFormatRef xDataFmt ) { mxDataFmt = xDataFmt; }
738 :
739 : /** Creates an API object representing this trend line. */
740 : XRegressionCurveRef CreateRegressionCurve() const;
741 :
742 : private:
743 : XclChSerTrendLine maData; /// Contents of the CHSERTRENDLINE record.
744 : XclImpChDataFormatRef mxDataFmt; /// Formatting settings of the trend line.
745 : };
746 :
747 : typedef boost::shared_ptr< XclImpChSerTrendLine > XclImpChSerTrendLineRef;
748 :
749 : // ----------------------------------------------------------------------------
750 :
751 : /** Represents the CHSERERRORBAR record containing settings for error bars. */
752 0 : class XclImpChSerErrorBar : protected XclImpChRoot
753 : {
754 : public:
755 : typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XLabeledDataSequence > XLabeledDataSeqRef;
756 : typedef ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > XPropertySetRef;
757 :
758 : public:
759 : explicit XclImpChSerErrorBar( const XclImpChRoot& rRoot );
760 :
761 : /** Reads the CHSERERRORBAR record. */
762 : void ReadChSerErrorBar( XclImpStream& rStrm );
763 : /** Sets link and formatting information for the error bars. */
764 : void SetSeriesData(
765 : XclImpChSourceLinkRef xValueLink,
766 : XclImpChDataFormatRef xDataFmt );
767 :
768 : /** Returns the type of this error bar (X/Y, plus/minus). */
769 0 : inline sal_uInt8 GetBarType() const { return maData.mnBarType; }
770 : /** Creates a labeled data sequence object from value data link. */
771 : XLabeledDataSeqRef CreateValueSequence() const;
772 :
773 : /** Tries to create an error bar API object from the specified Excel error bars. */
774 : static XPropertySetRef CreateErrorBar(
775 : const XclImpChSerErrorBar* pPosBar,
776 : const XclImpChSerErrorBar* pNegBar );
777 :
778 : private:
779 : XclChSerErrorBar maData; /// Contents of the CHSERERRORBAR record.
780 : XclImpChSourceLinkRef mxValueLink; /// Link data for manual error bar values.
781 : XclImpChDataFormatRef mxDataFmt; /// Formatting settings of the error bars.
782 : };
783 :
784 : typedef boost::shared_ptr< XclImpChSerErrorBar > XclImpChSerErrorBarRef;
785 :
786 : // ----------------------------------------------------------------------------
787 :
788 : /** Represents the CHSERIES record group describing a data series in a chart.
789 :
790 : The CHSERIES group consists of: CHSERIES, CHBEGIN, CHSOURCELINK groups,
791 : CHDATAFORMAT groups, CHSERGROUP, CHSERPARENT, CHSERERRORBAR,
792 : CHSERTRENDLINE, CHEND.
793 : */
794 80 : class XclImpChSeries : public XclImpChGroupBase, protected XclImpChRoot
795 : {
796 : public:
797 : typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDataSeries > XDataSeriesRef;
798 : typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XLabeledDataSequence > XLabeledDataSeqRef;
799 : typedef ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > XPropertySetRef;
800 :
801 : public:
802 : explicit XclImpChSeries( const XclImpChRoot& rRoot, sal_uInt16 nSeriesIdx );
803 :
804 : /** Reads the CHSERIES record (called by base class). */
805 : virtual void ReadHeaderRecord( XclImpStream& rStrm );
806 : /** Reads a record from the CHSERIES group (called by base class). */
807 : virtual void ReadSubRecord( XclImpStream& rStrm );
808 :
809 : /** Sets a data point or series format (CHDATAFORMAT group) for this series. */
810 : void SetDataFormat( const XclImpChDataFormatRef& xDataFmt );
811 : /** Sets a label text (CHTEXT group) attached to a series or data point. */
812 : void SetDataLabel( const XclImpChTextRef& xLabel );
813 : /** Adds error bar settings from the passed series to the own series. */
814 : void AddChildSeries( const XclImpChSeries& rSeries );
815 : /** Updates missing series formatting by using default formatting from axes sets. */
816 : void FinalizeDataFormats();
817 :
818 : /** Returns the axes set identifier this series is assigned to (primary/secondary). */
819 40 : inline sal_uInt16 GetGroupIdx() const { return mnGroupIdx; }
820 : /** Returns the 0-based series index described by this series. */
821 : inline sal_uInt16 GetSeriesIdx() const { return mnSeriesIdx; }
822 : /** Returns the 0-based index of the parent series (e.g. of a trend line). */
823 0 : inline sal_uInt16 GetParentIdx() const { return mnParentIdx; }
824 : /** Returns the format index of the series used for automatic line and area colors. */
825 : inline sal_uInt16 GetFormatIdx() const { return mxSeriesFmt ? mxSeriesFmt->GetFormatIdx() : EXC_CHDATAFORMAT_DEFAULT; }
826 : /** Returns true, if the series is child of another series (e.g. trend line). */
827 120 : inline bool HasParentSeries() const { return mnParentIdx != EXC_CHSERIES_INVALID; }
828 : /** Returns true, if the series contains child series (e.g. trend lines). */
829 38 : inline bool HasChildSeries() const { return !maTrendLines.empty() || !maErrorBars.empty(); }
830 : /** Returns series title or an empty string, if the series does not contain a title. */
831 38 : inline const String& GetTitle() const { return mxTitleLink ? mxTitleLink->GetString() : String::EmptyString(); }
832 :
833 : /** Returns true, if the series line is smoothed. */
834 40 : inline bool HasSpline() const { return mxSeriesFmt && mxSeriesFmt->HasSpline(); }
835 :
836 : /** Creates a labeled data sequence object from value data link. */
837 : XLabeledDataSeqRef CreateValueSequence( const ::rtl::OUString& rValueRole ) const;
838 : /** Creates a labeled data sequence object from category data link. */
839 : XLabeledDataSeqRef CreateCategSequence( const ::rtl::OUString& rCategRole ) const;
840 : /** Creates a data series object with initialized source links. */
841 : XDataSeriesRef CreateDataSeries() const;
842 :
843 : void FillAllSourceLinks(::std::vector<ScTokenRef>& rTokens) const;
844 :
845 : private:
846 : /** Reads a CHSOURCELINK record. */
847 : void ReadChSourceLink( XclImpStream& rStrm );
848 : /** Reads a CHDATAFORMAT group containing series and point formatting. */
849 : void ReadChDataFormat( XclImpStream& rStrm );
850 : /** Reads a CHSERPARENT record specifying the parent series of this series. */
851 : void ReadChSerParent( XclImpStream& rStrm );
852 : /** Reads a CHSERTRENDLINE record containing trend line settings. */
853 : void ReadChSerTrendLine( XclImpStream& rStrm );
854 : /** Reads a CHSERERRORBAR record containing error bar settings. */
855 : void ReadChSerErrorBar( XclImpStream& rStrm );
856 :
857 : /** Creates a new CHDATAFORMAT group with the specified point index. */
858 : XclImpChDataFormatRef CreateDataFormat( sal_uInt16 nPointIdx, sal_uInt16 nFormatIdx );
859 :
860 : /** Converts all trend lines and inserts them into the passed API data series object. */
861 : void ConvertTrendLines( XDataSeriesRef xDataSeries ) const;
862 : /** Tries to create an error bar API object from the specified Excel error bars. */
863 : XPropertySetRef CreateErrorBar( sal_uInt8 nPosBarId, sal_uInt8 nNegBarId ) const;
864 :
865 : private:
866 : typedef ::std::map<sal_uInt16, XclImpChDataFormatRef> XclImpChDataFormatMap;
867 : typedef ::std::map<sal_uInt16, XclImpChTextRef> XclImpChTextMap;
868 : typedef ::std::list< XclImpChSerTrendLineRef > XclImpChSerTrendLineList;
869 : typedef ::boost::ptr_map<sal_uInt8, XclImpChSerErrorBar> XclImpChSerErrorBarMap;
870 :
871 : XclChSeries maData; /// Contents of the CHSERIES record.
872 : XclImpChSourceLinkRef mxValueLink; /// Link data for series values.
873 : XclImpChSourceLinkRef mxCategLink; /// Link data for series category names.
874 : XclImpChSourceLinkRef mxTitleLink; /// Link data for series title.
875 : XclImpChSourceLinkRef mxBubbleLink; /// Link data for series bubble sizes.
876 : XclImpChDataFormatRef mxSeriesFmt; /// CHDATAFORMAT group for series format.
877 : XclImpChDataFormatMap maPointFmts; /// CHDATAFORMAT groups for data point formats.
878 : XclImpChTextMap maLabels; /// Data point labels (CHTEXT groups).
879 : XclImpChSerTrendLineList maTrendLines; /// Trend line settings (CHSERTRENDLINE records).
880 : XclImpChSerErrorBarMap maErrorBars; /// Error bar settings (CHSERERRORBAR records).
881 : sal_uInt16 mnGroupIdx; /// Chart type group (CHTYPEGROUP group) this series is assigned to.
882 : sal_uInt16 mnSeriesIdx; /// 0-based series index.
883 : sal_uInt16 mnParentIdx; /// 0-based index of parent series (trend lines and error bars).
884 : };
885 :
886 : typedef boost::shared_ptr< XclImpChSeries > XclImpChSeriesRef;
887 :
888 : // Chart type groups ==========================================================
889 :
890 40 : class XclImpChType : protected XclImpChRoot
891 : {
892 : public:
893 : typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDiagram > XDiagramRef;
894 : typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XCoordinateSystem > XCoordSystemRef;
895 : typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartType > XChartTypeRef;
896 :
897 : public:
898 : explicit XclImpChType( const XclImpChRoot& rRoot );
899 :
900 : /** Reads a chart type record (e.g. CHBAR, CHLINE, CHPIE, ...). */
901 : void ReadChType( XclImpStream& rStrm );
902 : /** Final processing after reading the entire chart. */
903 : void Finalize( bool bStockChart );
904 :
905 : /** Returns the record identifier of the chart type record. */
906 40 : inline sal_uInt16 GetRecId() const { return mnRecId; }
907 : /** Returns the chart type info struct for the contained chart type. */
908 80 : inline const XclChTypeInfo& GetTypeInfo() const { return maTypeInfo; }
909 : /** Returns true, if the series in this chart type group are stacked on each other (no percentage). */
910 : bool IsStacked() const;
911 : /** Returns true, if the series in this chart type group are stacked on each other as percentage. */
912 : bool IsPercent() const;
913 : /** Returns true, if chart type has category labels enabled (may be disabled in radar charts). */
914 : bool HasCategoryLabels() const;
915 :
916 : /** Creates a coordinate system according to the contained chart type. */
917 : XCoordSystemRef CreateCoordSystem( bool b3dChart ) const;
918 : /** Creates and returns an object that represents the contained chart type. */
919 : XChartTypeRef CreateChartType( XDiagramRef xDiagram, bool b3dChart ) const;
920 :
921 : private:
922 : XclChType maData; /// Contents of the chart type record.
923 : sal_uInt16 mnRecId; /// Record identifier for chart type.
924 : XclChTypeInfo maTypeInfo; /// Chart type info for the contained type.
925 : };
926 :
927 : // ----------------------------------------------------------------------------
928 :
929 : /** Represents the CHCHART3D record that contains 3D view settings. */
930 0 : class XclImpChChart3d
931 : {
932 : public:
933 : /** Reads the CHCHART3D record (properties for 3D charts). */
934 : void ReadChChart3d( XclImpStream& rStrm );
935 : /** Returns true, if the data points are clustered on the X axis. */
936 0 : inline bool IsClustered() const { return ::get_flag( maData.mnFlags, EXC_CHCHART3D_CLUSTER ); }
937 : /** Converts and writes the contained data to the passed property set. */
938 : void Convert( ScfPropertySet& rPropSet, bool b3dWallChart ) const;
939 :
940 : private:
941 : XclChChart3d maData; /// Contents of the CHCHART3D record.
942 : };
943 :
944 : typedef boost::shared_ptr< XclImpChChart3d > XclImpChChart3dRef;
945 :
946 : // ----------------------------------------------------------------------------
947 :
948 : /** Represents the CHLEGEND record group describing the chart legend.
949 :
950 : The CHLEGEND group consists of: CHLEGEND, CHBEGIN, CHFRAMEPOS, CHFRAME
951 : group, CHTEXT group, CHEND.
952 : */
953 42 : class XclImpChLegend : public XclImpChGroupBase, protected XclImpChRoot
954 : {
955 : public:
956 : typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XLegend > XLegendRef;
957 :
958 : public:
959 : explicit XclImpChLegend( const XclImpChRoot& rRoot );
960 :
961 : /** Reads the CHLEGEND record (called by base class). */
962 : virtual void ReadHeaderRecord( XclImpStream& rStrm );
963 : /** Reads a record from the CHLEGEND group (called by base class). */
964 : virtual void ReadSubRecord( XclImpStream& rStrm );
965 : /** Final processing after reading the entire chart. */
966 : void Finalize();
967 :
968 : /** Creates a new legend object. */
969 : XLegendRef CreateLegend() const;
970 :
971 : private:
972 : XclChLegend maData; /// Contents of the CHLEGEND record.
973 : XclImpChFramePosRef mxFramePos; /// Legend frame position (CHFRAMEPOS record).
974 : XclImpChTextRef mxText; /// Legend text format (CHTEXT group).
975 : XclImpChFrameRef mxFrame; /// Legend frame format (CHFRAME group).
976 : };
977 :
978 : typedef boost::shared_ptr< XclImpChLegend > XclImpChLegendRef;
979 :
980 : // ----------------------------------------------------------------------------
981 :
982 : /** Represents the CHDROPBAR record group describing pos/neg bars in line charts.
983 :
984 : The CHDROPBAR group consists of: CHDROPBAR, CHBEGIN, CHLINEFORMAT,
985 : CHAREAFORMAT, CHESCHERFORMAT group, CHEND.
986 : */
987 0 : class XclImpChDropBar : public XclImpChFrameBase
988 : {
989 : public:
990 : explicit XclImpChDropBar( sal_uInt16 nDropBar );
991 :
992 : /** Reads the CHDROPBAR record (called by base class). */
993 : virtual void ReadHeaderRecord( XclImpStream& rStrm );
994 :
995 : /** Converts and writes the contained frame data to the passed property set. */
996 : void Convert( const XclImpChRoot& rRoot, ScfPropertySet& rPropSet ) const;
997 :
998 : private:
999 : sal_uInt16 mnDropBar; /// Drop bar identifier, needed for auto format.
1000 : sal_uInt16 mnBarDist; /// Distance between bars (CHDROPBAR record).
1001 : };
1002 :
1003 : typedef boost::shared_ptr< XclImpChDropBar > XclImpChDropBarRef;
1004 :
1005 : // ----------------------------------------------------------------------------
1006 :
1007 : /** Represents the CHTYPEGROUP record group describing a group of series.
1008 :
1009 : The CHTYPEGROUP group consists of: CHTYPEGROUP, CHBEGIN, a chart type
1010 : record (e.g. CHBAR, CHLINE, CHAREA, CHPIE, ...), CHCHART3D, CHLEGEND group,
1011 : CHDEFAULTTEXT groups (CHDEFAULTTEXT with CHTEXT groups), CHDROPBAR groups,
1012 : CHCHARTLINE groups (CHCHARTLINE with CHLINEFORMAT), CHDATAFORMAT group,
1013 : CHEND.
1014 : */
1015 80 : class XclImpChTypeGroup : public XclImpChGroupBase, protected XclImpChRoot
1016 : {
1017 : public:
1018 : typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDiagram > XDiagramRef;
1019 : typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XCoordinateSystem > XCoordSystemRef;
1020 : typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartType > XChartTypeRef;
1021 : typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDataSeries > XDataSeriesRef;
1022 : typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XLabeledDataSequence > XLabeledDataSeqRef;
1023 :
1024 : public:
1025 : explicit XclImpChTypeGroup( const XclImpChRoot& rRoot );
1026 :
1027 : /** Reads the CHTYPEGROUP record (called by base class). */
1028 : virtual void ReadHeaderRecord( XclImpStream& rStrm );
1029 : /** Reads a record from the CHTYPEGROUP group (called by base class). */
1030 : virtual void ReadSubRecord( XclImpStream& rStrm );
1031 : /** Final processing after reading the entire chart. */
1032 : void Finalize();
1033 :
1034 : /** Inserts a series attached to this chart type group.*/
1035 : void AddSeries( XclImpChSeriesRef xSeries );
1036 : /** Marks the passed format index as used. PopUnusedFormatIndex() will not return this index. */
1037 : void SetUsedFormatIndex( sal_uInt16 nFormatIdx );
1038 : /** Returns the next unused format index and marks it as used. */
1039 : sal_uInt16 PopUnusedFormatIndex();
1040 :
1041 : /** Returns the index of this chart type group. */
1042 40 : inline sal_uInt16 GetGroupIdx() const { return maData.mnGroupIdx; }
1043 : /** Returns the chart type info struct for the contained chart type. */
1044 296 : inline const XclChExtTypeInfo& GetTypeInfo() const { return maTypeInfo; }
1045 : /** Returns true, if this chart type group contains at least one valid series. */
1046 40 : inline bool IsValidGroup() const { return !maSeries.empty(); }
1047 : /** Returns true, if the series in this chart type group are stacked on each other (no percentage). */
1048 : inline bool IsStacked() const { return maType.IsStacked(); }
1049 : /** Returns true, if the series in this chart type group are stacked on each other as percentage. */
1050 40 : inline bool IsPercent() const { return maType.IsPercent(); }
1051 : /** Returns true, if the chart is three-dimensional. */
1052 241 : inline bool Is3dChart() const { return mxChart3d && maTypeInfo.mbSupports3d; }
1053 : /** Returns true, if chart type supports wall and floor format in 3d mode. */
1054 119 : inline bool Is3dWallChart() const { return Is3dChart() && (maTypeInfo.meTypeCateg != EXC_CHTYPECATEG_PIE); }
1055 : /** Returns true, if the series in this chart type group are ordered on the Z axis. */
1056 79 : inline bool Is3dDeepChart() const { return Is3dWallChart() && mxChart3d && !mxChart3d->IsClustered(); }
1057 : /** Returns true, if category (X axis) labels are enabled (may be disabled in radar charts). */
1058 40 : inline bool HasCategoryLabels() const { return maType.HasCategoryLabels(); }
1059 : /** Returns true, if points of a series show varying automatic area format. */
1060 : bool HasVarPointFormat() const;
1061 : /** Returns true, if bars are connected with lines (stacked bar charts only). */
1062 : bool HasConnectorLines() const;
1063 :
1064 : /** Returns the legend object. */
1065 40 : inline XclImpChLegendRef GetLegend() const { return mxLegend; }
1066 : /** Returns the default series data format. */
1067 40 : inline XclImpChDataFormatRef GetGroupFormat() const { return mxGroupFmt; }
1068 : /** Returns series title, if the chart type group contains only one single series. */
1069 : const String& GetSingleSeriesTitle() const;
1070 :
1071 : /** Converts and writes all 3D settings to the passed diagram. */
1072 : void ConvertChart3d( ScfPropertySet& rPropSet ) const;
1073 : /** Creates a coordinate system according to the contained chart type. */
1074 : XCoordSystemRef CreateCoordSystem() const;
1075 : /** Creates and returns an object that represents the contained chart type. */
1076 : XChartTypeRef CreateChartType( XDiagramRef xDiagram, sal_Int32 nApiAxesSetIdx ) const;
1077 : /** Creates a labeled data sequence object for axis categories. */
1078 : XLabeledDataSeqRef CreateCategSequence() const;
1079 :
1080 : private:
1081 : /** Reads a CHDROPBAR record group. */
1082 : void ReadChDropBar( XclImpStream& rStrm );
1083 : /** Reads a CHCHARTLINE record group. */
1084 : void ReadChChartLine( XclImpStream& rStrm );
1085 : /** Reads a CHDATAFORMAT record group (default series format). */
1086 : void ReadChDataFormat( XclImpStream& rStrm );
1087 :
1088 : /** Returns true, if the chart type group contains a hi-lo line format. */
1089 1 : inline bool HasHiLoLine() const { return maChartLines.find( EXC_CHCHARTLINE_HILO ) != maChartLines.end(); }
1090 : /** Returns true, if the chart type group contains drop bar formats. */
1091 0 : inline bool HasDropBars() const { return !maDropBars.empty(); }
1092 :
1093 : /** Inserts the passed series into the chart type. Adds additional properties to the series. */
1094 : void InsertDataSeries( XChartTypeRef xChartType,
1095 : XDataSeriesRef xSeries, sal_Int32 nApiAxesSetIdx ) const;
1096 : /** Creates all data series of any chart type except stock charts. */
1097 : void CreateDataSeries( XChartTypeRef xChartType, sal_Int32 nApiAxesSetIdx ) const;
1098 : /** Creates all data series of of a stock chart. */
1099 : void CreateStockSeries( XChartTypeRef xChartType, sal_Int32 nApiAxesSetIdx ) const;
1100 :
1101 : private:
1102 : typedef ::std::vector< XclImpChSeriesRef > XclImpChSeriesVec;
1103 : typedef boost::ptr_map<sal_uInt16, XclImpChDropBar> XclImpChDropBarMap;
1104 : typedef boost::ptr_map<sal_uInt16, XclImpChLineFormat> XclImpChLineFormatMap;
1105 : typedef ::std::set< sal_uInt16 > UInt16Set;
1106 :
1107 : XclChTypeGroup maData; /// Contents of the CHTYPEGROUP record.
1108 : XclImpChType maType; /// Chart type (e.g. CHBAR, CHLINE, ...).
1109 : XclChExtTypeInfo maTypeInfo; /// Extended chart type info.
1110 : XclImpChSeriesVec maSeries; /// Series attached to this chart type group (CHSERIES groups).
1111 : XclImpChSeriesRef mxFirstSeries; /// First series in this chart type group (CHSERIES groups).
1112 : XclImpChChart3dRef mxChart3d; /// 3D settings (CHCHART3D record).
1113 : XclImpChLegendRef mxLegend; /// Chart legend (CHLEGEND group).
1114 : XclImpChDropBarMap maDropBars; /// Dropbars (CHDROPBAR group).
1115 : XclImpChLineFormatMap maChartLines; /// Global line formats (CHCHARTLINE group).
1116 : XclImpChDataFormatRef mxGroupFmt; /// Default format for all series (CHDATAFORMAT group).
1117 : UInt16Set maUnusedFormats; /// Contains unused format indexes for automatic colors.
1118 : };
1119 :
1120 : typedef boost::shared_ptr< XclImpChTypeGroup > XclImpChTypeGroupRef;
1121 :
1122 : // Axes =======================================================================
1123 :
1124 160 : class XclImpChLabelRange : protected XclImpChRoot
1125 : {
1126 : public:
1127 : typedef ::com::sun::star::chart2::ScaleData ScaleData;
1128 :
1129 : public:
1130 : explicit XclImpChLabelRange( const XclImpChRoot& rRoot );
1131 : /** Reads the CHLABELRANGE record (category axis scaling properties). */
1132 : void ReadChLabelRange( XclImpStream& rStrm );
1133 : /** Reads the CHDATERANGE record (date axis scaling properties). */
1134 : void ReadChDateRange( XclImpStream& rStrm );
1135 : /** Converts category axis scaling settings. */
1136 : void Convert( ScfPropertySet& rPropSet, ScaleData& rScaleData, bool bMirrorOrient ) const;
1137 : /** Converts position settings of this axis at a crossing axis. */
1138 : void ConvertAxisPosition( ScfPropertySet& rPropSet, bool b3dChart ) const;
1139 :
1140 : private:
1141 : XclChLabelRange maLabelData; /// Contents of the CHLABELRANGE record.
1142 : XclChDateRange maDateData; /// Contents of the CHDATERANGE record.
1143 : };
1144 :
1145 : typedef boost::shared_ptr< XclImpChLabelRange > XclImpChLabelRangeRef;
1146 :
1147 : // ----------------------------------------------------------------------------
1148 :
1149 160 : class XclImpChValueRange : protected XclImpChRoot
1150 : {
1151 : public:
1152 : typedef ::com::sun::star::chart2::ScaleData ScaleData;
1153 :
1154 : public:
1155 : explicit XclImpChValueRange( const XclImpChRoot& rRoot );
1156 : /** Reads the CHVALUERANGE record (numeric axis scaling properties). */
1157 : void ReadChValueRange( XclImpStream& rStrm );
1158 : /** Converts value axis scaling settings. */
1159 : void Convert( ScaleData& rScaleData, bool bMirrorOrient ) const;
1160 : /** Converts position settings of this axis at a crossing axis. */
1161 : void ConvertAxisPosition( ScfPropertySet& rPropSet ) const;
1162 :
1163 : private:
1164 : XclChValueRange maData; /// Contents of the CHVALUERANGE record.
1165 : };
1166 :
1167 : typedef boost::shared_ptr< XclImpChValueRange > XclImpChValueRangeRef;
1168 :
1169 : // ----------------------------------------------------------------------------
1170 :
1171 160 : class XclImpChTick : protected XclImpChRoot
1172 : {
1173 : public:
1174 : explicit XclImpChTick( const XclImpChRoot& rRoot );
1175 : /** Reads the CHTICK record (axis ticks properties). */
1176 : void ReadChTick( XclImpStream& rStrm );
1177 :
1178 : /** Returns true, if the axis shows attached labels. */
1179 80 : inline bool HasLabels() const { return maData.mnLabelPos != EXC_CHTICK_NOLABEL; }
1180 : /** Returns the leading font color for the axis labels. */
1181 : Color GetFontColor() const;
1182 : /** Returns the rotation value for the axis labels. */
1183 : sal_uInt16 GetRotation() const;
1184 :
1185 : /** Converts and writes the contained data to the passed property set. */
1186 : void Convert( ScfPropertySet& rPropSet ) const;
1187 :
1188 : private:
1189 : XclChTick maData; /// Contents of the CHTICK record.
1190 : };
1191 :
1192 : typedef boost::shared_ptr< XclImpChTick > XclImpChTickRef;
1193 :
1194 : // ----------------------------------------------------------------------------
1195 :
1196 : /** Represents the CHAXIS record group describing an entire chart axis.
1197 :
1198 : The CHAXIS group consists of: CHAXIS, CHBEGIN, CHLABELRANGE, CHEXTRANGE,
1199 : CHVALUERANGE, CHFORMAT, CHTICK, CHFONT, CHAXISLINE groups (CHAXISLINE with
1200 : CHLINEFORMAT, CHAREAFORMAT, and CHESCHERFORMAT group), CHEND.
1201 : */
1202 160 : class XclImpChAxis : public XclImpChGroupBase, public XclImpChFontBase, protected XclImpChRoot
1203 : {
1204 : public:
1205 : typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis > XAxisRef;
1206 :
1207 : public:
1208 : explicit XclImpChAxis( const XclImpChRoot& rRoot, sal_uInt16 nAxisType = EXC_CHAXIS_NONE );
1209 :
1210 : /** Reads the CHAXIS record (called by base class). */
1211 : virtual void ReadHeaderRecord( XclImpStream& rStrm );
1212 : /** Reads a record from the CHAXIS group (called by base class). */
1213 : virtual void ReadSubRecord( XclImpStream& rStrm );
1214 : /** Final processing after reading the entire chart. */
1215 : void Finalize();
1216 :
1217 : /** Returns the font index for the axis labels. */
1218 : virtual sal_uInt16 GetFontIndex() const;
1219 : /** Returns the font color for the axis labels. */
1220 : virtual Color GetFontColor() const;
1221 : /** Returns the rotation value for axis labels. */
1222 : virtual sal_uInt16 GetRotation() const;
1223 :
1224 : /** Returns the type of this axis. */
1225 364 : inline sal_uInt16 GetAxisType() const { return maData.mnType; }
1226 : /** Returns the axis dimension index used by the chart API. */
1227 80 : inline sal_Int32 GetApiAxisDimension() const { return maData.GetApiAxisDimension(); }
1228 : /** Returns true, if the axis is active. */
1229 80 : inline bool IsActivated() const { return !mxAxisLine || mxAxisLine->IsShowAxis(); }
1230 : /** Returns true, if the axis contains caption labels. */
1231 80 : inline bool HasLabels() const { return !mxTick || mxTick->HasLabels(); }
1232 : /** Returns true, if the axis shows its major grid lines. */
1233 80 : inline bool HasMajorGrid() const { return mxMajorGrid; }
1234 : /** Returns true, if the axis shows its minor grid lines. */
1235 80 : inline bool HasMinorGrid() const { return mxMinorGrid; }
1236 :
1237 : /** Creates an API axis object. */
1238 : XAxisRef CreateAxis( const XclImpChTypeGroup& rTypeGroup, const XclImpChAxis* pCrossingAxis ) const;
1239 : /** Converts and writes 3D wall/floor properties to the passed property set. */
1240 : void ConvertWall( ScfPropertySet& rPropSet ) const;
1241 : /** Converts position settings of this axis at a crossing axis. */
1242 : void ConvertAxisPosition( ScfPropertySet& rPropSet, const XclImpChTypeGroup& rTypeGroup ) const;
1243 :
1244 : private:
1245 : /** Reads a CHAXISLINE record specifying the target for following line properties. */
1246 : void ReadChAxisLine( XclImpStream& rStrm );
1247 : /** Creates a CHFRAME object and stores it into the mxWallFrame member. */
1248 : void CreateWallFrame();
1249 :
1250 : private:
1251 : XclChAxis maData; /// Contents of the CHAXIS record.
1252 : XclImpChLabelRangeRef mxLabelRange; /// Category scaling (CHLABELRANGE record).
1253 : XclImpChValueRangeRef mxValueRange; /// Value scaling (CHVALUERANGE record).
1254 : XclImpChTickRef mxTick; /// Axis ticks (CHTICK record).
1255 : XclImpChFontRef mxFont; /// Index into font buffer (CHFONT record).
1256 : XclImpChLineFormatRef mxAxisLine; /// Axis line format (CHLINEFORMAT record).
1257 : XclImpChLineFormatRef mxMajorGrid; /// Major grid line format (CHLINEFORMAT record).
1258 : XclImpChLineFormatRef mxMinorGrid; /// Minor grid line format (CHLINEFORMAT record).
1259 : XclImpChFrameRef mxWallFrame; /// Wall/floor format (sub records of CHFRAME group).
1260 : sal_uInt16 mnNumFmtIdx; /// Index into number format buffer (CHFORMAT record).
1261 : };
1262 :
1263 : typedef boost::shared_ptr< XclImpChAxis > XclImpChAxisRef;
1264 :
1265 : // ----------------------------------------------------------------------------
1266 :
1267 : /** Represents the CHAXESSET record group describing an axes set (X/Y/Z axes).
1268 :
1269 : The CHAXESSET group consists of: CHAXESSET, CHBEGIN, CHFRAMEPOS, CHAXIS
1270 : groups, CHTEXT groups, CHPLOTFRAME group (CHPLOTFRAME with CHFRAME group),
1271 : CHTYPEGROUP group, CHEND.
1272 : */
1273 240 : class XclImpChAxesSet : public XclImpChGroupBase, protected XclImpChRoot
1274 : {
1275 : public:
1276 : typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDiagram > XDiagramRef;
1277 : typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XCoordinateSystem > XCoordSystemRef;
1278 : typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis > XAxisRef;
1279 :
1280 : public:
1281 : explicit XclImpChAxesSet( const XclImpChRoot& rRoot, sal_uInt16 nAxesSetId );
1282 :
1283 : /** Reads the CHAXESSET record (called by base class). */
1284 : virtual void ReadHeaderRecord( XclImpStream& rStrm );
1285 : /** Reads a record from the CHAXESSET group (called by base class). */
1286 : virtual void ReadSubRecord( XclImpStream& rStrm );
1287 : /** Final processing after reading the entire chart. */
1288 : void Finalize();
1289 :
1290 : /** Returns true, if this axes set exists (returns false if this is a dummy object). */
1291 278 : inline bool IsValidAxesSet() const { return !maTypeGroups.empty(); }
1292 : /** Returns the index of the axes set (primary/secondary). */
1293 80 : inline sal_uInt16 GetAxesSetId() const { return maData.mnAxesSetId; }
1294 : /** Returns the axes set index used by the chart API. */
1295 120 : inline sal_Int32 GetApiAxesSetIndex() const { return maData.GetApiAxesSetIndex(); }
1296 :
1297 : /** Returns the outer plot area position, if existing. */
1298 40 : inline XclImpChFramePosRef GetPlotAreaFramePos() const { return mxFramePos; }
1299 : /** Returns the specified chart type group. */
1300 : XclImpChTypeGroupRef GetTypeGroup( sal_uInt16 nGroupIdx ) const;
1301 : /** Returns the first chart type group. */
1302 : XclImpChTypeGroupRef GetFirstTypeGroup() const;
1303 : /** Looks for a legend in all chart type groups and returns it. */
1304 : XclImpChLegendRef GetLegend() const;
1305 : /** Returns series title, if the axes set contains only one single series. */
1306 : const String& GetSingleSeriesTitle() const;
1307 :
1308 : /** Creates a coordinate system and converts all series and axis settings. */
1309 : void Convert( XDiagramRef xDiagram ) const;
1310 : /** Converts the manual positions of all axis titles. */
1311 : void ConvertTitlePositions() const;
1312 :
1313 : private:
1314 : /** Reads a CHAXIS record group containing a single axis. */
1315 : void ReadChAxis( XclImpStream& rStrm );
1316 : /** Reads a CHTEXT record group containing an axis title. */
1317 : void ReadChText( XclImpStream& rStrm );
1318 : /** Reads the CHPLOTFRAME record group containing diagram area formatting. */
1319 : void ReadChPlotFrame( XclImpStream& rStrm );
1320 : /** Reads a CHTYPEGROUP record group containing chart type and chart settings. */
1321 : void ReadChTypeGroup( XclImpStream& rStrm );
1322 :
1323 : /** Updates text formatting of the passed axis title with global text formatting. */
1324 : void UpdateAxisTitle( XclImpChTextRef xTitle );
1325 :
1326 : /** Creates a coordinate system that contains all chart types for this axes set. */
1327 : XCoordSystemRef CreateCoordSystem( XDiagramRef xDiagram ) const;
1328 : /** Creates and inserts an axis into the container and registers the coordinate system. */
1329 : void ConvertAxis( XclImpChAxisRef xChAxis, XclImpChTextRef xChAxisTitle,
1330 : XCoordSystemRef xCoordSystem, const XclImpChAxis* pCrossingAxis ) const;
1331 : /** Creates and returns an API axis object. */
1332 : XAxisRef CreateAxis( const XclImpChAxis& rChAxis, const XclImpChAxis* pCrossingAxis ) const;
1333 : /** Writes all properties of the background area to the passed diagram. */
1334 : void ConvertBackground( XDiagramRef xDiagram ) const;
1335 :
1336 : private:
1337 : typedef ::std::map<sal_uInt16, XclImpChTypeGroupRef> XclImpChTypeGroupMap;
1338 :
1339 : XclChAxesSet maData; /// Contents of the CHAXESSET record.
1340 : XclImpChFramePosRef mxFramePos; /// Outer plot area position (CHFRAMEPOS record).
1341 : XclImpChAxisRef mxXAxis; /// The X axis (CHAXIS group).
1342 : XclImpChAxisRef mxYAxis; /// The Y axis (CHAXIS group).
1343 : XclImpChAxisRef mxZAxis; /// The Z axis (CHAXIS group).
1344 : XclImpChTextRef mxXAxisTitle; /// The X axis title (CHTEXT group).
1345 : XclImpChTextRef mxYAxisTitle; /// The Y axis title (CHTEXT group).
1346 : XclImpChTextRef mxZAxisTitle; /// The Z axis title (CHTEXT group).
1347 : XclImpChFrameRef mxPlotFrame; /// Plot area (CHPLOTFRAME group).
1348 : XclImpChTypeGroupMap maTypeGroups; /// Chart type groups (CHTYPEGROUP group).
1349 : };
1350 :
1351 : typedef boost::shared_ptr< XclImpChAxesSet > XclImpChAxesSetRef;
1352 :
1353 : // The chart object ===========================================================
1354 :
1355 : /** Represents the CHCHART record group describing the chart contents.
1356 :
1357 : The CHCHART group consists of: CHCHART, CHBEGIN, SCL, CHPLOTGROWTH, CHFRAME
1358 : group, CHSERIES groups, CHPROPERTIES, CHDEFAULTTEXT groups (CHDEFAULTTEXT
1359 : with CHTEXT groups), CHUSEDAXESSETS, CHAXESSET groups, CHTEXT groups, CHEND.
1360 : */
1361 : class XclImpChChart : public XclImpChGroupBase, protected XclImpChRoot
1362 : {
1363 : public:
1364 : explicit XclImpChChart( const XclImpRoot& rRoot );
1365 : virtual ~XclImpChChart();
1366 :
1367 : /** Reads the CHCHART record (called by base class). */
1368 : virtual void ReadHeaderRecord( XclImpStream& rStrm );
1369 : /** Reads a record from the CHCHART group (called by base class). */
1370 : virtual void ReadSubRecord( XclImpStream& rStrm );
1371 : /** Reads a CHDEFAULTTEXT group (default text formats). */
1372 : void ReadChDefaultText( XclImpStream& rStrm );
1373 : /** Reads a CHDATAFORMAT group describing a series format or a data point format. */
1374 : void ReadChDataFormat( XclImpStream& rStrm );
1375 :
1376 : /** Sets formatting from BIFF3-BIFF5 OBJ record, if own formatting is invisible. */
1377 : void UpdateObjFrame( const XclObjLineData& rLineData, const XclObjFillData& rFillData );
1378 :
1379 : /** Returns the specified chart type group. */
1380 : XclImpChTypeGroupRef GetTypeGroup( sal_uInt16 nGroupIdx ) const;
1381 : /** Returns the specified default text. */
1382 : const XclImpChText* GetDefaultText( XclChTextType eTextType ) const;
1383 : /** Returns true, if the plot area has benn moved and/or resized manually. */
1384 : bool IsManualPlotArea() const;
1385 : /** Returns the number of units on the progress bar needed for the chart. */
1386 40 : inline sal_Size GetProgressSize() const { return 2 * EXC_CHART_PROGRESS_SIZE; }
1387 :
1388 : /** Converts and writes all properties to the passed chart. */
1389 : void Convert(
1390 : const ::com::sun::star::uno::Reference<
1391 : com::sun::star::chart2::XChartDocument>& xChartDoc,
1392 : XclImpDffConverter& rDffConv,
1393 : const ::rtl::OUString& rObjName,
1394 : const Rectangle& rChartRect ) const;
1395 :
1396 : private:
1397 : /** Reads a CHSERIES group (data series source and formatting). */
1398 : void ReadChSeries( XclImpStream& rStrm );
1399 : /** Reads a CHPROPERTIES record (global chart properties). */
1400 : void ReadChProperties( XclImpStream& rStrm );
1401 : /** Reads a CHAXESSET group (primary/secondary axes set). */
1402 : void ReadChAxesSet( XclImpStream& rStrm );
1403 : /** Reads a CHTEXT group (chart title and series/point captions). */
1404 : void ReadChText( XclImpStream& rStrm );
1405 :
1406 : /** Final processing after reading the entire chart data. */
1407 : void Finalize();
1408 : /** Finalizes series list, assigns child series to parent series. */
1409 : void FinalizeSeries();
1410 : /** Assigns all imported CHDATAFORMAT groups to the respective series. */
1411 : void FinalizeDataFormats();
1412 : /** Finalizes chart title, tries to detect title auto-generated from series name. */
1413 : void FinalizeTitle();
1414 :
1415 : /** Creates and returns a new diagram object and converts global chart settings. */
1416 : com::sun::star::uno::Reference<com::sun::star::chart2::XDiagram>
1417 : CreateDiagram() const;
1418 :
1419 : private:
1420 : typedef ::std::vector< XclImpChSeriesRef > XclImpChSeriesVec;
1421 : typedef ::std::map<XclChDataPointPos, XclImpChDataFormatRef> XclImpChDataFormatMap;
1422 : typedef ::boost::ptr_map<sal_uInt16, XclImpChText> XclImpChTextMap;
1423 :
1424 : XclChRectangle maRect; /// Position of the chart on the sheet (CHCHART record).
1425 : XclImpChSeriesVec maSeries; /// List of series data (CHSERIES groups).
1426 : XclImpChDataFormatMap maDataFmts; /// All series and point formats (CHDATAFORMAT groups).
1427 : XclImpChFrameRef mxFrame; /// Chart frame format (CHFRAME group).
1428 : XclChProperties maProps; /// Chart properties (CHPROPERTIES record).
1429 : XclImpChTextMap maDefTexts; /// Default text objects (CHDEFAULTTEXT groups).
1430 : XclImpChAxesSetRef mxPrimAxesSet; /// Primary axes set (CHAXESSET group).
1431 : XclImpChAxesSetRef mxSecnAxesSet; /// Secondary axes set (CHAXESSET group).
1432 : XclImpChTextRef mxTitle; /// Chart title (CHTEXT group).
1433 : XclImpChLegendRef mxLegend; /// Chart legend (CHLEGEND group).
1434 : };
1435 :
1436 : typedef boost::shared_ptr< XclImpChChart > XclImpChChartRef;
1437 :
1438 : // ----------------------------------------------------------------------------
1439 :
1440 : /** Drawing container of a chart. */
1441 76 : class XclImpChartDrawing : public XclImpDrawing
1442 : {
1443 : public:
1444 : explicit XclImpChartDrawing( const XclImpRoot& rRoot, bool bOwnTab );
1445 :
1446 : /** Converts all objects and inserts them into the chart drawing page. */
1447 : void ConvertObjects(
1448 : XclImpDffConverter& rDffConv,
1449 : const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& rxModel,
1450 : const Rectangle& rChartRect );
1451 :
1452 : /** Calculate the resulting rectangle of the passed anchor. */
1453 : virtual Rectangle CalcAnchorRect( const XclObjAnchor& rAnchor, bool bDffAnchor ) const;
1454 : /** Called whenever an object has been inserted into the draw page. */
1455 : virtual void OnObjectInserted( const XclImpDrawObjBase& rDrawObj );
1456 :
1457 : private:
1458 : Rectangle maChartRect; /// Position and size of the chart shape in 1/100 mm.
1459 : SCTAB mnScTab; /// Index of the sheet that contains the chart.
1460 : bool mbOwnTab; /// True = own sheet, false = embedded object.
1461 : };
1462 :
1463 : // ----------------------------------------------------------------------------
1464 :
1465 : /** Represents the entire chart substream (all records in BOF/EOF block). */
1466 : class XclImpChart : protected XclImpRoot
1467 : {
1468 : public:
1469 : typedef ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > XModelRef;
1470 :
1471 : public:
1472 : /** Constructs a new chart object.
1473 : @param bOwnTab True = chart is on an own sheet; false = chart is an embedded object. */
1474 : explicit XclImpChart( const XclImpRoot& rRoot, bool bOwnTab );
1475 : virtual ~XclImpChart();
1476 :
1477 : /** Reads the complete chart substream (BOF/EOF block).
1478 : @descr The passed stream must be located in the BOF record of the chart substream. */
1479 : void ReadChartSubStream( XclImpStream& rStrm );
1480 : /** Sets formatting from BIFF3-BIFF5 OBJ record, if own formatting is invisible. */
1481 : void UpdateObjFrame( const XclObjLineData& rLineData, const XclObjFillData& rFillData );
1482 :
1483 : /** Returns the number of units on the progress bar needed for the chart. */
1484 : sal_Size GetProgressSize() const;
1485 : /** Returns true, if the chart is based on a pivot table. */
1486 41 : inline bool IsPivotChart() const { return mbIsPivotChart; }
1487 :
1488 : /** Creates the chart object in the passed component. */
1489 : void Convert( XModelRef xModel,
1490 : XclImpDffConverter& rDffConv,
1491 : const ::rtl::OUString& rObjName,
1492 : const Rectangle& rChartRect ) const;
1493 :
1494 : private:
1495 : /** Returns (initially creates) the drawing container for embedded shapes. **/
1496 : XclImpChartDrawing& GetChartDrawing();
1497 : /** Reads the CHCHART group (entire chart data). */
1498 : void ReadChChart( XclImpStream& rStrm );
1499 :
1500 : private:
1501 : typedef boost::shared_ptr< XclImpChartDrawing > XclImpChartDrawingRef;
1502 :
1503 : XclImpChChartRef mxChartData; /// The chart data (CHCHART group).
1504 : XclImpChartDrawingRef mxChartDrawing; /// Drawing container for embedded shapes.
1505 : bool mbOwnTab; /// true = own sheet; false = embedded object.
1506 : bool mbIsPivotChart; /// true = chart is based on a pivot table.
1507 : };
1508 :
1509 : // ============================================================================
1510 :
1511 : #endif
1512 :
1513 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|