1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: xichart.hxx,v $
10 * $Revision: 1.13.62.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SC_XICHART_HXX
32 #define SC_XICHART_HXX
39 #include <svtools/itemset.hxx>
41 #include "rangelst.hxx"
43 #include "xlchart.hxx"
44 #include "xlstyle.hxx"
45 #include "xistring.hxx"
48 namespace com
{ namespace sun
{ namespace star
{
58 class XCoordinateSystem
;
61 class XRegressionCurve
;
65 class XFormattedString
;
70 class XLabeledDataSequence
;
75 struct XclObjLineData
;
76 struct XclObjFillData
;
78 // Common =====================================================================
81 class XclImpChRootData
;
85 /** Base class for complex chart classes, provides access to other components of the chart. */
86 class XclImpChRoot
: public XclImpRoot
89 typedef ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::XChartDocument
> XChartDocRef
;
90 typedef ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::data::XDataProvider
> XDataProviderRef
;
93 explicit XclImpChRoot( const XclImpRoot
& rRoot
, XclImpChChart
* pChartData
);
94 virtual ~XclImpChRoot();
96 /** Returns this root instance - for code readability in derived classes. */
97 inline const XclImpChRoot
& GetChRoot() const { return *this; }
98 /** Returns a reference to the parent chart data object. */
99 XclImpChChart
& GetChartData() const;
100 /** Returns chart type info for a unique chart type identifier. */
101 const XclChTypeInfo
& GetChartTypeInfo( XclChTypeId eType
) const;
102 /** Returns the first fitting chart type info for an Excel chart type record identifier. */
103 const XclChTypeInfo
& GetChartTypeInfo( sal_uInt16 nRecId
) const;
104 /** Returns an info struct about auto formatting for the passed object type. */
105 const XclChFormatInfo
& GetFormatInfo( XclChObjectType eObjType
) const;
107 /** Returns the default text color for charts. */
108 Color
GetFontAutoColor() const;
109 /** Returns the automatic line color of linear series. */
110 Color
GetSeriesLineAutoColor( sal_uInt16 nFormatIdx
) const;
111 /** Returns the automatic fill color of filled series. */
112 Color
GetSeriesFillAutoColor( sal_uInt16 nFormatIdx
) const;
114 /** Starts the API chart document conversion. Must be called once before all API conversion. */
115 void InitConversion( XChartDocRef xChartDoc
) const;
116 /** Finishes the API chart document conversion. Must be called once after all API conversion. */
117 void FinishConversion( ScfProgressBar
& rProgress
) const;
119 /** Returns the data provider for the chart document. */
120 XDataProviderRef
GetDataProvider() const;
122 /** Writes all line properties to the passed property set. */
123 void ConvertLineFormat(
124 ScfPropertySet
& rPropSet
,
125 const XclChLineFormat
& rLineFmt
,
126 XclChPropertyMode ePropMode
) const;
127 /** Writes solid area properties to the passed property set. */
128 void ConvertAreaFormat(
129 ScfPropertySet
& rPropSet
,
130 const XclChAreaFormat
& rAreaFmt
,
131 XclChPropertyMode ePropMode
) const;
132 /** Writes gradient or bitmap area properties to the passed property set. */
133 void ConvertEscherFormat(
134 ScfPropertySet
& rPropSet
,
135 const XclChEscherFormat
& rEscherFmt
,
136 const XclChPicFormat
& rPicFmt
,
137 XclChPropertyMode ePropMode
) const;
138 /** Writes font properties to the passed property set. */
140 ScfPropertySet
& rPropSet
,
142 const Color
* pFontColor
= 0 ) const;
144 /** Writes the pie rotation property for the passed angle. */
145 static void ConvertPieRotation(
146 ScfPropertySet
& rPropSet
,
150 typedef ScfRef
< XclImpChRootData
> XclImpChRootDataRef
;
151 XclImpChRootDataRef mxChData
; /// Reference to the root data object.
154 // ----------------------------------------------------------------------------
156 /** Base class for chart record groups. Provides helper functions to read sub records.
158 A chart record group consists of a header record, followed by a CHBEGIN
159 record, followed by group sub records, and finished with a CHEND record.
161 class XclImpChGroupBase
164 virtual ~XclImpChGroupBase();
166 /** Reads the entire record group.
167 @descr First calls ReadHeaderRecord() to read the contents of the
168 header record. Then tries to read the sub records. If next record
169 is a CHBEGIN record, ReadSubRecord() is called for each following
170 record until a CHEND record is found. */
171 void ReadRecordGroup( XclImpStream
& rStrm
);
173 /** Helper to skip a CHBEGIN/CHEND block, includes nested blocks. */
174 static void SkipBlock( XclImpStream
& rStrm
);
176 /** Derived classes implement to read the group header record. */
177 virtual void ReadHeaderRecord( XclImpStream
& rStrm
) = 0;
178 /** Derived classes implement to read a record from the group. */
179 virtual void ReadSubRecord( XclImpStream
& rStrm
) = 0;
182 // Frame formatting ===========================================================
184 class XclImpChFramePos
187 /** Reads the CHFRAMEPOS record (frame position and size). */
188 void ReadChFramePos( XclImpStream
& rStrm
);
191 XclChFramePos maData
; /// Position of the frame.
194 typedef ScfRef
< XclImpChFramePos
> XclImpChFramePosRef
;
196 // ----------------------------------------------------------------------------
198 /** The CHLINEFORMAT record containing line formatting data. */
199 class XclImpChLineFormat
202 /** Creates a new line format object with automatic formatting. */
203 inline explicit XclImpChLineFormat() {}
204 /** Creates a new line format object with the passed formatting. */
205 inline explicit XclImpChLineFormat( const XclChLineFormat
& rLineFmt
) : maData( rLineFmt
) {}
207 /** Reads the CHLINEFORMAT record (basic line properties). */
208 void ReadChLineFormat( XclImpStream
& rStrm
);
210 /** Returns true, if the line format is set to automatic. */
211 inline bool IsAuto() const { return ::get_flag( maData
.mnFlags
, EXC_CHLINEFORMAT_AUTO
); }
212 /** Returns true, if the line style is set to something visible. */
213 inline bool HasLine() const { return IsAuto() || (maData
.mnPattern
!= EXC_CHLINEFORMAT_NONE
); }
214 /** Returns the line width of this line format (returns 'single', if the line is invisible). */
215 inline sal_Int16
GetWeight() const { return (IsAuto() || !HasLine()) ? EXC_CHLINEFORMAT_SINGLE
: maData
.mnWeight
; }
216 /** Returns true, if the "show axis" flag is set. */
217 inline bool IsShowAxis() const { return ::get_flag( maData
.mnFlags
, EXC_CHLINEFORMAT_SHOWAXIS
); }
219 /** Converts and writes the contained data to the passed property set. */
220 void Convert( const XclImpChRoot
& rRoot
,
221 ScfPropertySet
& rPropSet
, XclChObjectType eObjType
,
222 sal_uInt16 nFormatIdx
= EXC_CHDATAFORMAT_UNKNOWN
) const;
225 XclChLineFormat maData
; /// Contents of the CHLINEFORMAT record.
228 typedef ScfRef
< XclImpChLineFormat
> XclImpChLineFormatRef
;
230 // ----------------------------------------------------------------------------
232 /** The CHAREAFORMAT record containing simple area formatting data (solid or patterns). */
233 class XclImpChAreaFormat
236 /** Creates a new area format object with automatic formatting. */
237 inline explicit XclImpChAreaFormat() {}
238 /** Creates a new area format object with the passed formatting. */
239 inline explicit XclImpChAreaFormat( const XclChAreaFormat
& rAreaFmt
) : maData( rAreaFmt
) {}
241 /** Reads the CHAREAFORMAT record (basic fill properties, e.g. transparent or colored). */
242 void ReadChAreaFormat( XclImpStream
& rStrm
);
244 /** Returns true, if the area format is set to automatic. */
245 inline bool IsAuto() const { return ::get_flag( maData
.mnFlags
, EXC_CHAREAFORMAT_AUTO
); }
246 /** Returns true, if the area style is set to something visible. */
247 inline bool HasArea() const { return IsAuto() || (maData
.mnPattern
!= EXC_PATT_NONE
); }
249 /** Converts and writes the contained data to the passed property set. */
250 void Convert( const XclImpChRoot
& rRoot
,
251 ScfPropertySet
& rPropSet
, XclChObjectType eObjType
,
252 sal_uInt16 nFormatIdx
= EXC_CHDATAFORMAT_UNKNOWN
) const;
255 XclChAreaFormat maData
; /// Contents of the CHAREAFORMAT record.
258 typedef ScfRef
< XclImpChAreaFormat
> XclImpChAreaFormatRef
;
260 // ----------------------------------------------------------------------------
262 /** The CHESCHERFORMAT record containing complex area formatting data (bitmaps, hatches). */
263 class XclImpChEscherFormat
: public XclImpChGroupBase
266 explicit XclImpChEscherFormat( const XclImpRoot
& rRoot
);
268 /** Reads the CHESCHERFORMAT record (complex fill data) (called by base class). */
269 virtual void ReadHeaderRecord( XclImpStream
& rStrm
);
270 /** Reads a record from the CHESCHERFORMAT group (called by base class). */
271 virtual void ReadSubRecord( XclImpStream
& rStrm
);
273 /** Converts and writes the contained data to the passed property set. */
274 void Convert( const XclImpChRoot
& rRoot
,
275 ScfPropertySet
& rPropSet
, XclChObjectType eObjType
) const;
278 XclChEscherFormat maData
; /// Fill properties for complex areas (CHESCHERFORMAT record).
279 XclChPicFormat maPicFmt
; /// Image options, e.g. stretched, stacked (CHPICFORMAT record).
282 typedef ScfRef
< XclImpChEscherFormat
> XclImpChEscherFormatRef
;
284 // ----------------------------------------------------------------------------
286 /** Base class for record groups containing frame formatting.
288 Frame formatting can be part of several record groups, e.g. CHFRAME,
289 CHDATAFORMAT, CHDROPBAR. It consists of CHLINEFORMAT, CHAREAFORMAT, and
290 CHESCHERFORMAT group.
292 class XclImpChFrameBase
: public XclImpChGroupBase
295 /** Creates a new frame object without internal formatting objects. */
296 inline explicit XclImpChFrameBase() {}
297 /** Creates a new frame object with specific default formatting. */
298 explicit XclImpChFrameBase( const XclChFormatInfo
& rFmtInfo
);
300 /** Reads a frame formatting record (called by base class). */
301 virtual void ReadSubRecord( XclImpStream
& rStrm
);
303 /** Returns true, if the line format is set to automatic. */
304 inline bool IsAutoLine() const { return !mxLineFmt
|| mxLineFmt
->IsAuto(); }
305 /** Returns true, if the line style is set to something visible. */
306 inline bool HasLine() const { return IsAutoLine() || mxLineFmt
->HasLine(); }
307 /** Returns the line weight used for this frame. */
308 inline sal_Int16
GetLineWeight() const { return mxLineFmt
.is() ? mxLineFmt
->GetWeight() : EXC_CHLINEFORMAT_SINGLE
; }
310 /** Returns true, if the area format is set to automatic. */
311 inline bool IsAutoArea() const { return !mxEscherFmt
&& (!mxAreaFmt
|| mxAreaFmt
->IsAuto()); }
312 /** Returns true, if the area style is set to something visible. */
313 inline bool HasArea() const { return mxEscherFmt
.is() || IsAutoArea() || mxAreaFmt
->HasArea(); }
316 /** Converts and writes the contained line formatting to the passed property set. */
317 void ConvertLineBase( const XclImpChRoot
& rRoot
,
318 ScfPropertySet
& rPropSet
, XclChObjectType eObjType
,
319 sal_uInt16 nFormatIdx
= EXC_CHDATAFORMAT_UNKNOWN
) const;
320 /** Converts and writes the contained area formatting to the passed property set. */
321 void ConvertAreaBase( const XclImpChRoot
& rRoot
,
322 ScfPropertySet
& rPropSet
, XclChObjectType eObjType
,
323 sal_uInt16 nFormatIdx
= EXC_CHDATAFORMAT_UNKNOWN
) const;
324 /** Converts and writes the contained data to the passed property set. */
325 void ConvertFrameBase( const XclImpChRoot
& rRoot
,
326 ScfPropertySet
& rPropSet
, XclChObjectType eObjType
,
327 sal_uInt16 nFormatIdx
= EXC_CHDATAFORMAT_UNKNOWN
) const;
330 XclImpChLineFormatRef mxLineFmt
; /// Line format (CHLINEFORMAT record).
331 XclImpChAreaFormatRef mxAreaFmt
; /// Area format (CHAREAFORMAT record).
332 XclImpChEscherFormatRef mxEscherFmt
; /// Complex area format (CHESCHERFORMAT record).
335 // ----------------------------------------------------------------------------
337 /** Represents the CHFRAME record group containing object frame properties.
339 The CHFRAME group consists of: CHFRAME, CHBEGIN, CHLINEFORMAT,
340 CHAREAFORMAT, CHESCHERFORMAT group, CHEND.
342 class XclImpChFrame
: public XclImpChFrameBase
, protected XclImpChRoot
345 /** Creates a new frame object with specific default formatting. */
346 explicit XclImpChFrame(
347 const XclImpChRoot
& rRoot
,
348 XclChObjectType eObjType
);
350 /** Reads the CHFRAME record (called by base class). */
351 virtual void ReadHeaderRecord( XclImpStream
& rStrm
);
353 /** Sets formatting from BIFF3-BIFF5 OBJ record, if own formatting is invisible. */
354 void UpdateObjFrame( const XclObjLineData
& rLineData
, const XclObjFillData
& rFillData
);
356 /** Converts and writes the contained data to the passed property set. */
357 void Convert( ScfPropertySet
& rPropSet
) const;
360 XclChFrame maData
; /// Contents of the CHFRAME record.
361 XclChObjectType meObjType
; /// Type of the represented object.
364 typedef ScfRef
< XclImpChFrame
> XclImpChFrameRef
;
366 // Source links ===============================================================
368 class XclImpChSourceLink
: protected XclImpChRoot
371 typedef ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::data::XDataSequence
> XDataSequenceRef
;
372 typedef ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::XFormattedString
> XFormattedStringRef
;
373 typedef ::com::sun::star::uno::Sequence
< XFormattedStringRef
> XFormattedStringSeq
;
376 explicit XclImpChSourceLink( const XclImpChRoot
& rRoot
);
377 virtual ~XclImpChSourceLink();
379 /** Reads the CHSOURCELINK record (link to source data). */
380 void ReadChSourceLink( XclImpStream
& rStrm
);
381 /** Sets explicit string data for this text object. */
382 void SetString( const String
& rString
);
383 /** Sets formatting runs read from a CHFORMATRUNS record. */
384 void SetTextFormats( const XclFormatRunVec
& rFormats
);
386 /** Returns the destination object (title, values, category, ...). */
387 inline sal_uInt8
GetDestType() const { return maData
.mnDestType
; }
388 /** Returns the link type (to worksheet, directly, default, ...). */
389 inline sal_uInt8
GetLinkType() const { return maData
.mnLinkType
; }
391 /** Returns true, if the source link contains explicit string data. */
392 inline bool HasString() const { return mxString
.is() && !mxString
->IsEmpty(); }
393 /** Returns explicit string data or an empty string. */
394 inline const String
& GetString() const { return mxString
.is() ? mxString
->GetText() : String::EmptyString(); }
395 /** Returns the number of data points of this source link. */
396 sal_uInt16
GetCellCount() const;
398 /** Converts and writes the contained number format to the passed property set. */
399 void ConvertNumFmt( ScfPropertySet
& rPropSet
, bool bPercent
) const;
401 /** Creates a data sequence containing the link into the Calc document. */
402 XDataSequenceRef
CreateDataSequence( const ::rtl::OUString
& rRole
) const;
403 /** Creates a sequence of formatted string objects. */
404 XFormattedStringSeq
CreateStringSequence( const XclImpChRoot
& rRoot
,
405 sal_uInt16 nLeadFontIdx
, const Color
& rLeadFontColor
) const;
407 void FillSourceLink(::std::vector
<ScSharedTokenRef
>& rTokens
) const;
410 XclChSourceLink maData
; /// Contents of the CHSOURCELINK record.
411 XclImpStringRef mxString
; /// Text data (CHSTRING record).
412 ScfRef
< ScTokenArray
> mxTokenArray
; /// Token array representing the data ranges.
415 typedef ScfRef
< XclImpChSourceLink
> XclImpChSourceLinkRef
;
417 // Text =======================================================================
419 /** Base class for objects with font settings. Provides font conversion helper functions. */
420 class XclImpChFontBase
423 virtual ~XclImpChFontBase();
425 /** Derived classes return the leading font index for the text object. */
426 virtual sal_uInt16
GetFontIndex() const = 0;
427 /** Derived classes return the leading font color for the text object. */
428 virtual Color
GetFontColor() const = 0;
429 /** Derived classes return the rotation value for the text object. */
430 virtual sal_uInt16
GetRotation() const = 0;
432 /** Converts and writes the contained font settings to the passed property set. */
433 void ConvertFontBase( const XclImpChRoot
& rRoot
, ScfPropertySet
& rPropSet
) const;
434 /** Converts and writes the contained rotation settings to the passed property set. */
435 void ConvertRotationBase( const XclImpChRoot
& rRoot
, ScfPropertySet
& rPropSet
, bool bSupportsStacked
) const;
438 // ----------------------------------------------------------------------------
440 /** The CHFONT record containing a font index for text objects. */
444 explicit XclImpChFont();
445 /** Reads the CHFONT record (font index). */
446 void ReadChFont( XclImpStream
& rStrm
);
448 /** Returns the contained font index. */
449 inline sal_uInt16
GetFontIndex() const { return mnFontIdx
; }
452 sal_uInt16 mnFontIdx
; /// Index into font buffer.
455 typedef ScfRef
< XclImpChFont
> XclImpChFontRef
;
457 // ----------------------------------------------------------------------------
459 /** Represents the CHTEXT record group containing text object properties.
461 The CHTEXT group consists of: CHTEXT, CHBEGIN, CHFRAMEPOS, CHFONT,
462 CHFORMATRUNS, CHSOURCELINK, CHSTRING, CHFRAME group, CHOBJECTLINK, and CHEND.
464 class XclImpChText
: public XclImpChGroupBase
, public XclImpChFontBase
, protected XclImpChRoot
467 typedef ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::XTitle
> XTitleRef
;
470 explicit XclImpChText( const XclImpChRoot
& rRoot
);
472 /** Reads the CHTEXT record (called by base class). */
473 virtual void ReadHeaderRecord( XclImpStream
& rStrm
);
474 /** Reads a record from the CHTEXT group (called by base class). */
475 virtual void ReadSubRecord( XclImpStream
& rStrm
);
477 /** Returns the leading font index for the text object. */
478 virtual sal_uInt16
GetFontIndex() const;
479 /** Returns the leading font color for the text object. */
480 virtual Color
GetFontColor() const;
481 /** Returns the rotation value for the text object. */
482 virtual sal_uInt16
GetRotation() const;
484 /** Sets explicit string data for this text object. */
485 void SetString( const String
& rString
);
486 /** Updates missing parts of this text object from the passed object. */
487 void UpdateText( const XclImpChText
* pParentText
);
488 /** Updates display type of this data point label text object. */
489 void UpdateDataLabel( bool bCateg
, bool bValue
, bool bPercent
);
491 /** Returns the target object this text is linked to. */
492 inline sal_uInt16
GetLinkTarget() const { return maObjLink
.mnTarget
; }
493 /** Returns the position of the data point label this text is linked to. */
494 inline const XclChDataPointPos
& GetPointPos() const { return maObjLink
.maPointPos
; }
495 /** Returns true, if this text group contains string data. */
496 inline bool HasString() const { return mxSrcLink
.is() && mxSrcLink
->HasString(); }
497 /** Returns true, if the text object is marked as deleted. */
498 inline bool IsDeleted() const { return ::get_flag( maData
.mnFlags
, EXC_CHTEXT_DELETED
); }
500 /** Converts and writes the contained font settings to the passed property set. */
501 void ConvertFont( ScfPropertySet
& rPropSet
) const;
502 /** Converts and writes the contained rotation settings to the passed property set. */
503 void ConvertRotation( ScfPropertySet
& rPropSet
, bool bSupportsStacked
) const;
504 /** Converts and writes the contained frame data to the passed property set. */
505 void ConvertFrame( ScfPropertySet
& rPropSet
) const;
506 /** Converts and writes the contained number format to the passed property set. */
507 void ConvertNumFmt( ScfPropertySet
& rPropSet
, bool bPercent
) const;
508 /** Converts and writes all contained data to the passed data point label property set. */
509 void ConvertDataLabel( ScfPropertySet
& rPropSet
, const XclChTypeInfo
& rTypeInfo
) const;
510 /** Creates a title text object. */
511 XTitleRef
CreateTitle() const;
514 using XclImpChRoot::ConvertFont
;
516 /** Reads a CHFRLABELPROPS record. */
517 void ReadChFrLabelProps( XclImpStream
& rStrm
);
520 typedef ScfRef
< XclChFrLabelProps
> XclChFrLabelPropsRef
;
522 XclChText maData
; /// Contents of the CHTEXT record.
523 XclChObjectLink maObjLink
; /// Link target for this text object.
524 XclFormatRunVec maFormats
; /// Formatting runs (CHFORMATRUNS record).
525 XclImpChSourceLinkRef mxSrcLink
; /// Linked data (CHSOURCELINK with CHSTRING record).
526 XclImpChFrameRef mxFrame
; /// Text object frame properties (CHFRAME group).
527 XclImpChFontRef mxFont
; /// Index into font buffer (CHFONT record).
528 XclChFrLabelPropsRef mxLabelProps
; /// Extended data label properties (CHFRLABELPROPS record).
531 typedef ScfRef
< XclImpChText
> XclImpChTextRef
;
533 // Data series ================================================================
535 /** The CHMARKERFORMAT record containing data point marker formatting data. */
536 class XclImpChMarkerFormat
539 /** Reads the CHMARKERFORMAT record (data point marker properties). */
540 void ReadChMarkerFormat( XclImpStream
& rStrm
);
542 /** Returns true, if the marker format is set to automatic. */
543 inline bool IsAuto() const { return ::get_flag( maData
.mnFlags
, EXC_CHMARKERFORMAT_AUTO
); }
545 /** Converts and writes the contained data to the passed property set. */
546 void Convert( const XclImpChRoot
& rRoot
, ScfPropertySet
& rPropSet
,
547 sal_uInt16 nFormatIdx
, sal_Int16 nLineWeight
) const;
548 /** Sets the marker fill color as main color to the passed property set. */
549 void ConvertColor( const XclImpChRoot
& rRoot
,
550 ScfPropertySet
& rPropSet
, sal_uInt16 nFormatIdx
) const;
553 XclChMarkerFormat maData
; /// Contents of the CHMARKERFORMAT record.
556 typedef ScfRef
< XclImpChMarkerFormat
> XclImpChMarkerFormatRef
;
558 // ----------------------------------------------------------------------------
560 /** The CHPIEFORMAT record containing data point formatting data for pie segments. */
561 class XclImpChPieFormat
564 explicit XclImpChPieFormat();
565 /** Reads the CHPIEFORMAT record (pie segment properties). */
566 void ReadChPieFormat( XclImpStream
& rStrm
);
567 /** Converts and writes the contained data to the passed property set. */
568 void Convert( ScfPropertySet
& rPropSet
) const;
571 sal_uInt16 mnPieDist
; /// Pie distance to diagram center.
574 typedef ScfRef
< XclImpChPieFormat
> XclImpChPieFormatRef
;
576 // ----------------------------------------------------------------------------
578 /** The CHSERIESFORMAT record containing additional settings for a data series. */
579 class XclImpChSeriesFormat
582 explicit XclImpChSeriesFormat();
583 /** Reads the CHSERIESFORMAT record (additional settings for a series). */
584 void ReadChSeriesFormat( XclImpStream
& rStrm
);
585 /** Returns true, if the series line is smoothed. */
586 inline bool HasSpline() const { return ::get_flag( mnFlags
, EXC_CHSERIESFORMAT_SMOOTHED
); }
589 sal_uInt16 mnFlags
; /// Additional flags.
592 typedef ScfRef
< XclImpChSeriesFormat
> XclImpChSeriesFormatRef
;
594 // ----------------------------------------------------------------------------
596 /** The CH3DDATAFORMAT record containing the bar type in 3D bar charts. */
597 class XclImpCh3dDataFormat
600 /** Reads the CH3DDATAFORMAT record (3D bar properties). */
601 void ReadCh3dDataFormat( XclImpStream
& rStrm
);
602 /** Converts and writes the contained data to the passed property set. */
603 void Convert( ScfPropertySet
& rPropSet
) const;
606 XclCh3dDataFormat maData
; /// Contents of the CH3DDATAFORMAT record.
609 typedef ScfRef
< XclImpCh3dDataFormat
> XclImpCh3dDataFormatRef
;
611 // ----------------------------------------------------------------------------
613 /** The CHATTACHEDLABEL record that contains the type of a data point label. */
614 class XclImpChAttachedLabel
: protected XclImpChRoot
617 explicit XclImpChAttachedLabel( const XclImpChRoot
& rRoot
);
618 /** Reads the CHATTACHEDLABEL record (data series/point labels). */
619 void ReadChAttachedLabel( XclImpStream
& rStrm
);
620 /** Creates a CHTEXT group for the label. Clones xParentText and sets additional label settings */
621 XclImpChTextRef
CreateDataLabel( XclImpChTextRef xParent
) const;
624 sal_uInt16 mnFlags
; /// Additional flags.
627 typedef ScfRef
< XclImpChAttachedLabel
> XclImpChAttLabelRef
;
629 // ----------------------------------------------------------------------------
631 /** Represents the CHDATAFORMAT record group containing data point properties.
633 The CHDATAFORMAT group consists of: CHDATAFORMAT, CHBEGIN, CHFRAME group,
634 CHMARKERFORMAT, CHPIEFORMAT, CH3DDATAFORMAT, CHSERIESFORMAT,
635 CHATTACHEDLABEL, CHEND.
637 class XclImpChDataFormat
: public XclImpChFrameBase
, protected XclImpChRoot
640 explicit XclImpChDataFormat( const XclImpChRoot
& rRoot
);
642 /** Reads the CHDATAFORMAT record (called by base class). */
643 virtual void ReadHeaderRecord( XclImpStream
& rStrm
);
644 /** Reads a record from the CHDATAFORMAT group (called by base class). */
645 virtual void ReadSubRecord( XclImpStream
& rStrm
);
647 /** Sets this object to the specified data point position. */
648 void SetPointPos( const XclChDataPointPos
& rPointPos
, sal_uInt16 nFormatIdx
);
649 /** Sets type and text formatting for a data point label (CHTEXT group). */
650 inline void SetDataLabel( XclImpChTextRef xLabel
) { mxLabel
= xLabel
; }
652 /** Updates default data format for series group. */
653 void UpdateGroupFormat( const XclChExtTypeInfo
& rTypeInfo
);
654 /** Updates missing series settings from the passed chart type group data format. */
655 void UpdateSeriesFormat( const XclChExtTypeInfo
& rTypeInfo
, const XclImpChDataFormat
* pGroupFmt
);
656 /** Updates missing data point settings from the passed series format. */
657 void UpdatePointFormat( const XclChExtTypeInfo
& rTypeInfo
, const XclImpChDataFormat
* pSeriesFmt
);
658 /** Updates default data format for trend lines. */
659 void UpdateTrendLineFormat();
661 /** Returns the position of the data point described by this group. */
662 inline const XclChDataPointPos
& GetPointPos() const { return maData
.maPointPos
; }
663 /** Returns the format index of the data point described by this group. */
664 inline sal_uInt16
GetFormatIdx() const { return maData
.mnFormatIdx
; }
665 /** Returns true, if markers are set to automatic format. */
666 inline bool IsAutoMarker() const { return !mxMarkerFmt
|| mxMarkerFmt
->IsAuto(); }
667 /** Returns true, if the series line is smoothed. */
668 inline bool HasSpline() const { return mxSeriesFmt
.is() && mxSeriesFmt
->HasSpline(); }
669 /** Returns the data label text object. */
670 inline XclImpChTextRef
GetDataLabel() const { return mxLabel
; }
672 /** Converts and writes the contained data to the passed property set. */
673 void Convert( ScfPropertySet
& rPropSet
, const XclChExtTypeInfo
& rTypeInfo
) const;
674 /** Writes the line format only, e.g. for trend lines or error bars. */
675 void ConvertLine( ScfPropertySet
& rPropSet
, XclChObjectType eObjType
) const;
676 /** Writes the area format only for the series or a data point. */
677 void ConvertArea( ScfPropertySet
& rPropSet
, sal_uInt16 nFormatIdx
) const;
680 /** Removes unused formatting (e.g. pie distance in a bar chart). */
681 void RemoveUnusedFormats( const XclChExtTypeInfo
& rTypeInfo
);
682 /** Updates or creates the data point label. */
683 void UpdateDataLabel( const XclImpChDataFormat
* pParentFmt
);
686 XclChDataFormat maData
; /// Contents of the CHDATAFORMAT record.
687 XclImpChMarkerFormatRef mxMarkerFmt
; /// Data point marker (CHMARKERFORMAT record).
688 XclImpChPieFormatRef mxPieFmt
; /// Pie segment format (CHPIEFORMAT record).
689 XclImpChSeriesFormatRef mxSeriesFmt
; /// Series properties (CHSERIESFORMAT record).
690 XclImpCh3dDataFormatRef mx3dDataFmt
; /// 3D bar format (CH3DDATAFORMAT record).
691 XclImpChAttLabelRef mxAttLabel
; /// Data point label type (CHATTACHEDLABEL record).
692 XclImpChTextRef mxLabel
; /// Data point label formatting (CHTEXT group).
695 typedef ScfRef
< XclImpChDataFormat
> XclImpChDataFormatRef
;
697 // ----------------------------------------------------------------------------
699 /** Represents the CHSERTRENDLINE record containing settings for a trend line. */
700 class XclImpChSerTrendLine
: protected XclImpChRoot
703 typedef ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::XRegressionCurve
> XRegressionCurveRef
;
706 explicit XclImpChSerTrendLine( const XclImpChRoot
& rRoot
);
708 /** Reads the CHSERTRENDLINE record. */
709 void ReadChSerTrendLine( XclImpStream
& rStrm
);
710 /** Sets formatting information for the trend line. */
711 inline void SetDataFormat( XclImpChDataFormatRef xDataFmt
) { mxDataFmt
= xDataFmt
; }
713 /** Creates an API object representing this trend line. */
714 XRegressionCurveRef
CreateRegressionCurve() const;
717 XclChSerTrendLine maData
; /// Contents of the CHSERTRENDLINE record.
718 XclImpChDataFormatRef mxDataFmt
; /// Formatting settings of the trend line.
721 typedef ScfRef
< XclImpChSerTrendLine
> XclImpChSerTrendLineRef
;
723 // ----------------------------------------------------------------------------
725 /** Represents the CHSERERRORBAR record containing settings for error bars. */
726 class XclImpChSerErrorBar
: protected XclImpChRoot
729 typedef ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::data::XLabeledDataSequence
> XLabeledDataSeqRef
;
730 typedef ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
> XPropertySetRef
;
733 explicit XclImpChSerErrorBar( const XclImpChRoot
& rRoot
);
735 /** Reads the CHSERERRORBAR record. */
736 void ReadChSerErrorBar( XclImpStream
& rStrm
);
737 /** Sets link and formatting information for the error bars. */
739 XclImpChSourceLinkRef xValueLink
,
740 XclImpChDataFormatRef xDataFmt
);
742 /** Returns the type of this error bar (X/Y, plus/minus). */
743 inline sal_uInt8
GetBarType() const { return maData
.mnBarType
; }
744 /** Creates a labeled data sequence object from value data link. */
745 XLabeledDataSeqRef
CreateValueSequence() const;
747 /** Tries to create an error bar API object from the specified Excel error bars. */
748 static XPropertySetRef
CreateErrorBar(
749 const XclImpChSerErrorBar
* pPosBar
,
750 const XclImpChSerErrorBar
* pNegBar
);
753 XclChSerErrorBar maData
; /// Contents of the CHSERERRORBAR record.
754 XclImpChSourceLinkRef mxValueLink
; /// Link data for manual error bar values.
755 XclImpChDataFormatRef mxDataFmt
; /// Formatting settings of the error bars.
758 typedef ScfRef
< XclImpChSerErrorBar
> XclImpChSerErrorBarRef
;
760 // ----------------------------------------------------------------------------
762 /** Represents the CHSERIES record group describing a data series in a chart.
764 The CHSERIES group consists of: CHSERIES, CHBEGIN, CHSOURCELINK groups,
765 CHDATAFORMAT groups, CHSERGROUP, CHSERPARENT, CHSERERRORBAR,
766 CHSERTRENDLINE, CHEND.
768 class XclImpChSeries
: public XclImpChGroupBase
, protected XclImpChRoot
771 typedef ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::XDataSeries
> XDataSeriesRef
;
772 typedef ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::data::XLabeledDataSequence
> XLabeledDataSeqRef
;
773 typedef ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
> XPropertySetRef
;
776 explicit XclImpChSeries( const XclImpChRoot
& rRoot
, sal_uInt16 nSeriesIdx
);
778 /** Reads the CHSERIES record (called by base class). */
779 virtual void ReadHeaderRecord( XclImpStream
& rStrm
);
780 /** Reads a record from the CHSERIES group (called by base class). */
781 virtual void ReadSubRecord( XclImpStream
& rStrm
);
783 /** Sets a data point or series format (CHDATAFORMAT group) for this series. */
784 void SetDataFormat( XclImpChDataFormatRef xDataFmt
);
785 /** Sets a label text (CHTEXT group) attached to a series or data point. */
786 void SetDataLabel( XclImpChTextRef xLabel
);
787 /** Adds error bar settings from the passed series to the own series. */
788 void AddChildSeries( const XclImpChSeries
& rSeries
);
789 /** Updates missing series formatting by using default formatting from axes sets. */
790 void FinalizeDataFormats();
792 /** Returns the axes set identifier this series is assigned to (primary/secondary). */
793 inline sal_uInt16
GetGroupIdx() const { return mnGroupIdx
; }
794 /** Returns the 0-based series index described by this series. */
795 inline sal_uInt16
GetSeriesIdx() const { return mnSeriesIdx
; }
796 /** Returns the 0-based index of the parent series (e.g. of a trend line). */
797 inline sal_uInt16
GetParentIdx() const { return mnParentIdx
; }
798 /** Returns the format index of the series used for automatic line and area colors. */
799 inline sal_uInt16
GetFormatIdx() const { return mxSeriesFmt
.is() ? mxSeriesFmt
->GetFormatIdx() : EXC_CHDATAFORMAT_DEFAULT
; }
800 /** Returns true, if the series is child of another series (e.g. trend line). */
801 inline bool HasParentSeries() const { return mnParentIdx
!= EXC_CHSERIES_INVALID
; }
802 /** Returns true, if the series contains child series (e.g. trend lines). */
803 inline bool HasChildSeries() const { return !maTrendLines
.empty() || !maErrorBars
.empty(); }
804 /** Returns series title or an empty string, if the series does not contain a title. */
805 inline const String
& GetTitle() const { return mxTitleLink
.is() ? mxTitleLink
->GetString() : String::EmptyString(); }
807 /** Returns true, if the series line is smoothed. */
808 inline bool HasSpline() const { return mxSeriesFmt
.is() && mxSeriesFmt
->HasSpline(); }
810 /** Creates a labeled data sequence object from value data link. */
811 XLabeledDataSeqRef
CreateValueSequence( const ::rtl::OUString
& rValueRole
) const;
812 /** Creates a labeled data sequence object from category data link. */
813 XLabeledDataSeqRef
CreateCategSequence( const ::rtl::OUString
& rCategRole
) const;
814 /** Creates a data series object with initialized source links. */
815 XDataSeriesRef
CreateDataSeries() const;
817 void FillAllSourceLinks(::std::vector
<ScSharedTokenRef
>& rTokens
) const;
820 /** Reads a CHSOURCELINK record. */
821 void ReadChSourceLink( XclImpStream
& rStrm
);
822 /** Reads a CHDATAFORMAT group containing series and point formatting. */
823 void ReadChDataFormat( XclImpStream
& rStrm
);
824 /** Reads a CHSERPARENT record specifying the parent series of this series. */
825 void ReadChSerParent( XclImpStream
& rStrm
);
826 /** Reads a CHSERTRENDLINE record containing trend line settings. */
827 void ReadChSerTrendLine( XclImpStream
& rStrm
);
828 /** Reads a CHSERERRORBAR record containing error bar settings. */
829 void ReadChSerErrorBar( XclImpStream
& rStrm
);
831 /** Creates a new CHDATAFORMAT group with the specified point index. */
832 XclImpChDataFormatRef
CreateDataFormat( sal_uInt16 nPointIdx
, sal_uInt16 nFormatIdx
);
833 /** Returns the pointer to a CHDATAFORMAT group reference or 0 for invalid pointer index. */
834 XclImpChDataFormatRef
* GetDataFormatRef( sal_uInt16 nPointIdx
);
835 /** Returns the pointer to a CHTEXT group reference or 0 for invalid pointer index. */
836 XclImpChTextRef
* GetDataLabelRef( sal_uInt16 nPointIdx
);
838 /** Converts all trend lines and inserts them into the passed API data series object. */
839 void ConvertTrendLines( XDataSeriesRef xDataSeries
) const;
840 /** Tries to create an error bar API object from the specified Excel error bars. */
841 XPropertySetRef
CreateErrorBar( sal_uInt8 nPosBarId
, sal_uInt8 nNegBarId
) const;
844 typedef ScfRefMap
< sal_uInt16
, XclImpChDataFormat
> XclImpChDataFormatMap
;
845 typedef ScfRefMap
< sal_uInt16
, XclImpChText
> XclImpChTextMap
;
846 typedef ::std::list
< XclImpChSerTrendLineRef
> XclImpChSerTrendLineList
;
847 typedef ScfRefMap
< sal_uInt8
, XclImpChSerErrorBar
> XclImpChSerErrorBarMap
;
849 XclChSeries maData
; /// Contents of the CHSERIES record.
850 XclImpChSourceLinkRef mxValueLink
; /// Link data for series values.
851 XclImpChSourceLinkRef mxCategLink
; /// Link data for series category names.
852 XclImpChSourceLinkRef mxTitleLink
; /// Link data for series title.
853 XclImpChSourceLinkRef mxBubbleLink
; /// Link data for series bubble sizes.
854 XclImpChDataFormatRef mxSeriesFmt
; /// CHDATAFORMAT group for series format.
855 XclImpChDataFormatMap maPointFmts
; /// CHDATAFORMAT groups for data point formats.
856 XclImpChTextMap maLabels
; /// Data point labels (CHTEXT groups).
857 XclImpChSerTrendLineList maTrendLines
; /// Trend line settings (CHSERTRENDLINE records).
858 XclImpChSerErrorBarMap maErrorBars
; /// Error bar settings (CHSERERRORBAR records).
859 sal_uInt16 mnGroupIdx
; /// Chart type group (CHTYPEGROUP group) this series is assigned to.
860 sal_uInt16 mnSeriesIdx
; /// 0-based series index.
861 sal_uInt16 mnParentIdx
; /// 0-based index of parent series (trend lines and error bars).
864 typedef ScfRef
< XclImpChSeries
> XclImpChSeriesRef
;
866 // Chart type groups ==========================================================
868 class XclImpChType
: protected XclImpChRoot
871 typedef ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::XDiagram
> XDiagramRef
;
872 typedef ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::XCoordinateSystem
> XCoordSystemRef
;
873 typedef ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::XChartType
> XChartTypeRef
;
876 explicit XclImpChType( const XclImpChRoot
& rRoot
);
878 /** Reads a chart type record (e.g. CHBAR, CHLINE, CHPIE, ...). */
879 void ReadChType( XclImpStream
& rStrm
);
880 /** Final processing after reading the entire chart. */
881 void Finalize( bool bStockChart
);
883 /** Returns the record identifier of the chart type record. */
884 inline sal_uInt16
GetRecId() const { return mnRecId
; }
885 /** Returns the chart type info struct for the contained chart type. */
886 inline const XclChTypeInfo
& GetTypeInfo() const { return maTypeInfo
; }
887 /** Returns true, if the series in this chart type group are stacked on each other (no percentage). */
888 bool IsStacked() const;
889 /** Returns true, if the series in this chart type group are stacked on each other as percentage. */
890 bool IsPercent() const;
891 /** Returns true, if chart type has category labels enabled (may be disabled in radar charts). */
892 bool HasCategoryLabels() const;
894 /** Creates a coordinate system according to the contained chart type. */
895 XCoordSystemRef
CreateCoordSystem( bool b3dChart
) const;
896 /** Creates and returns an object that represents the contained chart type. */
897 XChartTypeRef
CreateChartType( XDiagramRef xDiagram
, bool b3dChart
) const;
900 XclChType maData
; /// Contents of the chart type record.
901 sal_uInt16 mnRecId
; /// Record identifier for chart type.
902 XclChTypeInfo maTypeInfo
; /// Chart type info for the contained type.
905 // ----------------------------------------------------------------------------
907 /** Represents the CHCHART3D record that contains 3D view settings. */
908 class XclImpChChart3d
911 /** Reads the CHCHART3D record (properties for 3D charts). */
912 void ReadChChart3d( XclImpStream
& rStrm
);
913 /** Returns true, if the data points are clustered on the X axis. */
914 inline bool IsClustered() const { return ::get_flag( maData
.mnFlags
, EXC_CHCHART3D_CLUSTER
); }
915 /** Converts and writes the contained data to the passed property set. */
916 void Convert( ScfPropertySet
& rPropSet
, bool b3dWallChart
) const;
919 XclChChart3d maData
; /// Contents of the CHCHART3D record.
922 typedef ScfRef
< XclImpChChart3d
> XclImpChChart3dRef
;
924 // ----------------------------------------------------------------------------
926 /** Represents the CHLEGEND record group describing the chart legend.
928 The CHLEGEND group consists of: CHLEGEND, CHBEGIN, CHFRAME group,
931 class XclImpChLegend
: public XclImpChGroupBase
, protected XclImpChRoot
934 typedef ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::XLegend
> XLegendRef
;
937 explicit XclImpChLegend( const XclImpChRoot
& rRoot
);
939 /** Reads the CHLEGEND record (called by base class). */
940 virtual void ReadHeaderRecord( XclImpStream
& rStrm
);
941 /** Reads a record from the CHLEGEND group (called by base class). */
942 virtual void ReadSubRecord( XclImpStream
& rStrm
);
943 /** Final processing after reading the entire chart. */
946 /** Creates a new legend object. */
947 XLegendRef
CreateLegend() const;
950 XclChLegend maData
; /// Contents of the CHLEGEND record.
951 XclImpChTextRef mxText
; /// Legend text format (CHTEXT group).
952 XclImpChFrameRef mxFrame
; /// Legend frame format (CHFRAME group).
955 typedef ScfRef
< XclImpChLegend
> XclImpChLegendRef
;
957 // ----------------------------------------------------------------------------
959 /** Represents the CHDROPBAR record group describing pos/neg bars in line charts.
961 The CHDROPBAR group consists of: CHDROPBAR, CHBEGIN, CHLINEFORMAT,
962 CHAREAFORMAT, CHESCHERFORMAT group, CHEND.
964 class XclImpChDropBar
: public XclImpChFrameBase
967 explicit XclImpChDropBar( sal_uInt16 nDropBar
);
969 /** Reads the CHDROPBAR record (called by base class). */
970 virtual void ReadHeaderRecord( XclImpStream
& rStrm
);
972 /** Converts and writes the contained frame data to the passed property set. */
973 void Convert( const XclImpChRoot
& rRoot
, ScfPropertySet
& rPropSet
) const;
976 sal_uInt16 mnDropBar
; /// Drop bar identifier, needed for auto format.
977 sal_uInt16 mnBarDist
; /// Distance between bars (CHDROPBAR record).
980 typedef ScfRef
< XclImpChDropBar
> XclImpChDropBarRef
;
982 // ----------------------------------------------------------------------------
984 /** Represents the CHTYPEGROUP record group describing a group of series.
986 The CHTYPEGROUP group consists of: CHTYPEGROUP, CHBEGIN, a chart type
987 record (e.g. CHBAR, CHLINE, CHAREA, CHPIE, ...), CHCHART3D, CHLEGEND group,
988 CHDEFAULTTEXT groups (CHDEFAULTTEXT with CHTEXT groups), CHDROPBAR groups,
989 CHCHARTLINE groups (CHCHARTLINE with CHLINEFORMAT), CHDATAFORMAT group,
992 class XclImpChTypeGroup
: public XclImpChGroupBase
, protected XclImpChRoot
995 typedef ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::XDiagram
> XDiagramRef
;
996 typedef ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::XCoordinateSystem
> XCoordSystemRef
;
997 typedef ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::XChartType
> XChartTypeRef
;
998 typedef ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::XDataSeries
> XDataSeriesRef
;
999 typedef ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::data::XLabeledDataSequence
> XLabeledDataSeqRef
;
1002 explicit XclImpChTypeGroup( const XclImpChRoot
& rRoot
);
1004 /** Reads the CHTYPEGROUP record (called by base class). */
1005 virtual void ReadHeaderRecord( XclImpStream
& rStrm
);
1006 /** Reads a record from the CHTYPEGROUP group (called by base class). */
1007 virtual void ReadSubRecord( XclImpStream
& rStrm
);
1008 /** Final processing after reading the entire chart. */
1011 /** Inserts a series attached to this chart type group.*/
1012 void AddSeries( XclImpChSeriesRef xSeries
);
1013 /** Marks the passed format index as used. PopUnusedFormatIndex() will not return this index. */
1014 void SetUsedFormatIndex( sal_uInt16 nFormatIdx
);
1015 /** Returns the next unused format index and marks it as used. */
1016 sal_uInt16
PopUnusedFormatIndex();
1018 /** Returns the index of this chart type group. */
1019 inline sal_uInt16
GetGroupIdx() const { return maData
.mnGroupIdx
; }
1020 /** Returns the chart type info struct for the contained chart type. */
1021 inline const XclChExtTypeInfo
& GetTypeInfo() const { return maTypeInfo
; }
1022 /** Returns true, if this chart type group contains at least one valid series. */
1023 inline bool IsValidGroup() const { return !maSeries
.empty(); }
1024 /** Returns true, if the series in this chart type group are stacked on each other (no percentage). */
1025 inline bool IsStacked() const { return maType
.IsStacked(); }
1026 /** Returns true, if the series in this chart type group are stacked on each other as percentage. */
1027 inline bool IsPercent() const { return maType
.IsPercent(); }
1028 /** Returns true, if the chart is three-dimensional. */
1029 inline bool Is3dChart() const { return mxChart3d
.is() && maTypeInfo
.mbSupports3d
; }
1030 /** Returns true, if chart type supports wall and floor format in 3d mode. */
1031 inline bool Is3dWallChart() const { return Is3dChart() && (maTypeInfo
.meTypeCateg
!= EXC_CHTYPECATEG_PIE
); }
1032 /** Returns true, if the series in this chart type group are ordered on the Z axis. */
1033 inline bool Is3dDeepChart() const { return Is3dWallChart() && mxChart3d
.is() && !mxChart3d
->IsClustered(); }
1034 /** Returns true, if category (X axis) labels are enabled (may be disabled in radar charts). */
1035 inline bool HasCategoryLabels() const { return maType
.HasCategoryLabels(); }
1036 /** Returns true, if points of a series show varying automatic area format. */
1037 bool HasVarPointFormat() const;
1038 /** Returns true, if bars are connected with lines (stacked bar charts only). */
1039 bool HasConnectorLines() const;
1041 /** Returns the legend object. */
1042 inline XclImpChLegendRef
GetLegend() const { return mxLegend
; }
1043 /** Returns the default series data format. */
1044 inline XclImpChDataFormatRef
GetGroupFormat() const { return mxGroupFmt
; }
1045 /** Returns series title, if the chart type group contains only one single series. */
1046 const String
& GetSingleSeriesTitle() const;
1048 /** Converts and writes all 3D settings to the passed diagram. */
1049 void ConvertChart3d( ScfPropertySet
& rPropSet
) const;
1050 /** Creates a coordinate system according to the contained chart type. */
1051 XCoordSystemRef
CreateCoordSystem() const;
1052 /** Creates and returns an object that represents the contained chart type. */
1053 XChartTypeRef
CreateChartType( XDiagramRef xDiagram
, sal_Int32 nApiAxesSetIdx
) const;
1054 /** Creates a labeled data sequence object for axis categories. */
1055 XLabeledDataSeqRef
CreateCategSequence() const;
1058 /** Reads a CHDROPBAR record group. */
1059 void ReadChDropBar( XclImpStream
& rStrm
);
1060 /** Reads a CHCHARTLINE record group. */
1061 void ReadChChartLine( XclImpStream
& rStrm
);
1062 /** Reads a CHDATAFORMAT record group (default series format). */
1063 void ReadChDataFormat( XclImpStream
& rStrm
);
1065 /** Returns true, if the chart type group contains a hi-lo line format. */
1066 inline bool HasHiLoLine() const { return maChartLines
.has( EXC_CHCHARTLINE_HILO
); }
1067 /** Returns true, if the chart type group contains drop bar formats. */
1068 inline bool HasDropBars() const { return !maDropBars
.empty(); }
1070 /** Inserts the passed series into the chart type. Adds additional properties to the series. */
1071 void InsertDataSeries( XChartTypeRef xChartType
,
1072 XDataSeriesRef xSeries
, sal_Int32 nApiAxesSetIdx
) const;
1073 /** Creates all data series of any chart type except stock charts. */
1074 void CreateDataSeries( XChartTypeRef xChartType
, sal_Int32 nApiAxesSetIdx
) const;
1075 /** Creates all data series of of a stock chart. */
1076 void CreateStockSeries( XChartTypeRef xChartType
, sal_Int32 nApiAxesSetIdx
) const;
1079 typedef ::std::vector
< XclImpChSeriesRef
> XclImpChSeriesVec
;
1080 typedef ScfRefMap
< sal_uInt16
, XclImpChDropBar
> XclImpChDropBarMap
;
1081 typedef ScfRefMap
< sal_uInt16
, XclImpChLineFormat
> XclImpChLineFormatMap
;
1082 typedef ::std::set
< sal_uInt16
> UInt16Set
;
1084 XclChTypeGroup maData
; /// Contents of the CHTYPEGROUP record.
1085 XclImpChType maType
; /// Chart type (e.g. CHBAR, CHLINE, ...).
1086 XclChExtTypeInfo maTypeInfo
; /// Extended chart type info.
1087 XclImpChSeriesVec maSeries
; /// Series attached to this chart type group (CHSERIES groups).
1088 XclImpChSeriesRef mxFirstSeries
; /// First series in this chart type group (CHSERIES groups).
1089 XclImpChChart3dRef mxChart3d
; /// 3D settings (CHCHART3D record).
1090 XclImpChLegendRef mxLegend
; /// Chart legend (CHLEGEND group).
1091 XclImpChDropBarMap maDropBars
; /// Dropbars (CHDROPBAR group).
1092 XclImpChLineFormatMap maChartLines
; /// Global line formats (CHCHARTLINE group).
1093 XclImpChDataFormatRef mxGroupFmt
; /// Default format for all series (CHDATAFORMAT group).
1094 UInt16Set maUnusedFormats
; /// Contains unused format indexes for automatic colors.
1097 typedef ScfRef
< XclImpChTypeGroup
> XclImpChTypeGroupRef
;
1099 // Axes =======================================================================
1101 class XclImpChLabelRange
: protected XclImpChRoot
1104 typedef ::com::sun::star::chart2::ScaleData ScaleData
;
1107 explicit XclImpChLabelRange( const XclImpChRoot
& rRoot
);
1108 /** Reads the CHLABELRANGE record (category axis scaling properties). */
1109 void ReadChLabelRange( XclImpStream
& rStrm
);
1110 /** Converts category axis scaling settings. */
1111 void Convert( ScfPropertySet
& rPropSet
, ScaleData
& rScaleData
, bool bMirrorOrient
) const;
1112 /** Converts position settings of this axis at a crossing axis. */
1113 void ConvertAxisPosition( ScfPropertySet
& rPropSet
, bool b3dChart
) const;
1116 XclChLabelRange maData
; /// Contents of the CHLABELRANGE record.
1119 typedef ScfRef
< XclImpChLabelRange
> XclImpChLabelRangeRef
;
1121 // ----------------------------------------------------------------------------
1123 class XclImpChValueRange
: protected XclImpChRoot
1126 typedef ::com::sun::star::chart2::ScaleData ScaleData
;
1129 explicit XclImpChValueRange( const XclImpChRoot
& rRoot
);
1130 /** Reads the CHVALUERANGE record (numeric axis scaling properties). */
1131 void ReadChValueRange( XclImpStream
& rStrm
);
1132 /** Converts value axis scaling settings. */
1133 void Convert( ScaleData
& rScaleData
, bool bMirrorOrient
) const;
1134 /** Converts position settings of this axis at a crossing axis. */
1135 void ConvertAxisPosition( ScfPropertySet
& rPropSet
) const;
1138 XclChValueRange maData
; /// Contents of the CHVALUERANGE record.
1141 typedef ScfRef
< XclImpChValueRange
> XclImpChValueRangeRef
;
1143 // ----------------------------------------------------------------------------
1145 class XclImpChTick
: protected XclImpChRoot
1148 explicit XclImpChTick( const XclImpChRoot
& rRoot
);
1149 /** Reads the CHTICK record (axis ticks properties). */
1150 void ReadChTick( XclImpStream
& rStrm
);
1152 /** Returns true, if the axis shows attached labels. */
1153 inline bool HasLabels() const { return maData
.mnLabelPos
!= EXC_CHTICK_NOLABEL
; }
1154 /** Returns the leading font color for the axis labels. */
1155 Color
GetFontColor() const;
1156 /** Returns the rotation value for the axis labels. */
1157 sal_uInt16
GetRotation() const;
1159 /** Converts and writes the contained data to the passed property set. */
1160 void Convert( ScfPropertySet
& rPropSet
) const;
1163 XclChTick maData
; /// Contents of the CHTICK record.
1166 typedef ScfRef
< XclImpChTick
> XclImpChTickRef
;
1168 // ----------------------------------------------------------------------------
1170 /** Represents the CHAXIS record group describing an entire chart axis.
1172 The CHAXIS group consists of: CHAXIS, CHBEGIN, CHLABELRANGE, CHEXTRANGE,
1173 CHVALUERANGE, CHFORMAT, CHTICK, CHFONT, CHAXISLINE groups (CHAXISLINE with
1174 CHLINEFORMAT, CHAREAFORMAT, and CHESCHERFORMAT group), CHEND.
1176 class XclImpChAxis
: public XclImpChGroupBase
, public XclImpChFontBase
, protected XclImpChRoot
1179 typedef ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::XAxis
> XAxisRef
;
1182 explicit XclImpChAxis( const XclImpChRoot
& rRoot
, sal_uInt16 nAxisType
= EXC_CHAXIS_NONE
);
1184 /** Reads the CHAXIS record (called by base class). */
1185 virtual void ReadHeaderRecord( XclImpStream
& rStrm
);
1186 /** Reads a record from the CHAXIS group (called by base class). */
1187 virtual void ReadSubRecord( XclImpStream
& rStrm
);
1188 /** Final processing after reading the entire chart. */
1191 /** Returns the font index for the axis labels. */
1192 virtual sal_uInt16
GetFontIndex() const;
1193 /** Returns the font color for the axis labels. */
1194 virtual Color
GetFontColor() const;
1195 /** Returns the rotation value for axis labels. */
1196 virtual sal_uInt16
GetRotation() const;
1198 /** Returns the type of this axis. */
1199 inline sal_uInt16
GetAxisType() const { return maData
.mnType
; }
1200 /** Returns the axis dimension index used by the chart API. */
1201 inline sal_Int32
GetApiAxisDimension() const { return maData
.GetApiAxisDimension(); }
1202 /** Returns true, if the axis is active. */
1203 inline bool IsActivated() const { return !mxAxisLine
|| mxAxisLine
->IsShowAxis(); }
1204 /** Returns true, if the axis contains caption labels. */
1205 inline bool HasLabels() const { return !mxTick
|| mxTick
->HasLabels(); }
1206 /** Returns true, if the axis shows its major grid lines. */
1207 inline bool HasMajorGrid() const { return mxMajorGrid
.is(); }
1208 /** Returns true, if the axis shows its minor grid lines. */
1209 inline bool HasMinorGrid() const { return mxMinorGrid
.is(); }
1211 /** Creates an API axis object. */
1212 XAxisRef
CreateAxis( const XclImpChTypeGroup
& rTypeGroup
, const XclImpChAxis
* pCrossingAxis
) const;
1213 /** Converts and writes 3D wall/floor properties to the passed property set. */
1214 void ConvertWall( ScfPropertySet
& rPropSet
) const;
1215 /** Converts position settings of this axis at a crossing axis. */
1216 void ConvertAxisPosition( ScfPropertySet
& rPropSet
, const XclImpChTypeGroup
& rTypeGroup
) const;
1219 /** Reads a CHAXISLINE record specifying the target for following line properties. */
1220 void ReadChAxisLine( XclImpStream
& rStrm
);
1221 /** Creates a CHFRAME object and stores it into the mxWallFrame member. */
1222 void CreateWallFrame();
1225 XclChAxis maData
; /// Contents of the CHAXIS record.
1226 XclImpChLabelRangeRef mxLabelRange
; /// Category scaling (CHLABELRANGE record).
1227 XclImpChValueRangeRef mxValueRange
; /// Value scaling (CHVALUERANGE record).
1228 XclImpChTickRef mxTick
; /// Axis ticks (CHTICK record).
1229 XclImpChFontRef mxFont
; /// Index into font buffer (CHFONT record).
1230 XclImpChLineFormatRef mxAxisLine
; /// Axis line format (CHLINEFORMAT record).
1231 XclImpChLineFormatRef mxMajorGrid
; /// Major grid line format (CHLINEFORMAT record).
1232 XclImpChLineFormatRef mxMinorGrid
; /// Minor grid line format (CHLINEFORMAT record).
1233 XclImpChFrameRef mxWallFrame
; /// Wall/floor format (sub records of CHFRAME group).
1234 sal_uInt16 mnNumFmtIdx
; /// Index into number format buffer (CHFORMAT record).
1237 typedef ScfRef
< XclImpChAxis
> XclImpChAxisRef
;
1239 // ----------------------------------------------------------------------------
1241 /** Represents the CHAXESSET record group describing an axes set (X/Y/Z axes).
1243 The CHAXESSET group consists of: CHAXESSET, CHBEGIN, CHFRAMEPOS, CHAXIS
1244 groups, CHTEXT groups, CHPLOTFRAME group (CHPLOTFRAME with CHFRAME group),
1245 CHTYPEGROUP group, CHEND.
1247 class XclImpChAxesSet
: public XclImpChGroupBase
, protected XclImpChRoot
1250 typedef ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::XDiagram
> XDiagramRef
;
1251 typedef ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::XCoordinateSystem
> XCoordSystemRef
;
1252 typedef ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::XAxis
> XAxisRef
;
1255 explicit XclImpChAxesSet( const XclImpChRoot
& rRoot
, sal_uInt16 nAxesSetId
);
1257 /** Reads the CHAXESSET record (called by base class). */
1258 virtual void ReadHeaderRecord( XclImpStream
& rStrm
);
1259 /** Reads a record from the CHAXESSET group (called by base class). */
1260 virtual void ReadSubRecord( XclImpStream
& rStrm
);
1261 /** Final processing after reading the entire chart. */
1264 /** Returns true, if this axes set exists (returns false if this is a dummy object). */
1265 inline bool IsValidAxesSet() const { return !maTypeGroups
.empty(); }
1266 /** Returns the index of the axes set (primary/secondary). */
1267 inline sal_uInt16
GetAxesSetId() const { return maData
.mnAxesSetId
; }
1268 /** Returns the axes set index used by the chart API. */
1269 inline sal_Int32
GetApiAxesSetIndex() const { return maData
.GetApiAxesSetIndex(); }
1271 /** Returns the specified chart type group. */
1272 inline XclImpChTypeGroupRef
GetTypeGroup( sal_uInt16 nGroupIdx
) const { return maTypeGroups
.get( nGroupIdx
); }
1273 /** Returns the first chart type group. */
1274 XclImpChTypeGroupRef
GetFirstTypeGroup() const;
1275 /** Looks for a legend in all chart type groups and returns it. */
1276 XclImpChLegendRef
GetLegend() const;
1277 /** Returns series title, if the axes set contains only one single series. */
1278 const String
& GetSingleSeriesTitle() const;
1280 /** Creates a coordinate system and converts all series and axis settings. */
1281 void Convert( XDiagramRef xDiagram
) const;
1284 /** Reads a CHAXIS record group containing a single axis. */
1285 void ReadChAxis( XclImpStream
& rStrm
);
1286 /** Reads a CHTEXT record group containing an axis title. */
1287 void ReadChText( XclImpStream
& rStrm
);
1288 /** Reads the CHPLOTFRAME record group containing diagram area formatting. */
1289 void ReadChPlotFrame( XclImpStream
& rStrm
);
1290 /** Reads a CHTYPEGROUP record group containing chart type and chart settings. */
1291 void ReadChTypeGroup( XclImpStream
& rStrm
);
1293 /** Updates text formatting of the passed axis title with global text formatting. */
1294 void UpdateAxisTitle( XclImpChTextRef xTitle
);
1296 /** Creates a coordinate system that contains all chart types for this axes set. */
1297 XCoordSystemRef
CreateCoordSystem( XDiagramRef xDiagram
) const;
1298 /** Creates and inserts an axis into the container and registers the coordinate system. */
1299 void ConvertAxis( XclImpChAxisRef xChAxis
, XclImpChTextRef xChAxisTitle
,
1300 XCoordSystemRef xCoordSystem
, const XclImpChAxis
* pCrossingAxis
) const;
1301 /** Creates and returns an API axis object. */
1302 XAxisRef
CreateAxis( const XclImpChAxis
& rChAxis
, const XclImpChAxis
* pCrossingAxis
) const;
1303 /** Writes all properties of the background area to the passed diagram. */
1304 void ConvertBackground( XDiagramRef xDiagram
) const;
1307 typedef ScfRefMap
< sal_uInt16
, XclImpChTypeGroup
> XclImpChTypeGroupMap
;
1309 XclChAxesSet maData
; /// Contents of the CHAXESSET record.
1310 XclImpChFramePosRef mxPos
; /// Position of the axes set (CHFRAMEPOS record).
1311 XclImpChAxisRef mxXAxis
; /// The X axis (CHAXIS group).
1312 XclImpChAxisRef mxYAxis
; /// The Y axis (CHAXIS group).
1313 XclImpChAxisRef mxZAxis
; /// The Z axis (CHAXIS group).
1314 XclImpChTextRef mxXAxisTitle
; /// The X axis title (CHTEXT group).
1315 XclImpChTextRef mxYAxisTitle
; /// The Y axis title (CHTEXT group).
1316 XclImpChTextRef mxZAxisTitle
; /// The Z axis title (CHTEXT group).
1317 XclImpChFrameRef mxPlotFrame
; /// Plot area (CHPLOTFRAME group).
1318 XclImpChTypeGroupMap maTypeGroups
; /// Chart type groups (CHTYPEGROUP group).
1321 typedef ScfRef
< XclImpChAxesSet
> XclImpChAxesSetRef
;
1323 // The chart object ===========================================================
1325 /** Represents the CHCHART record group describing the chart contents.
1327 The CHCHART group consists of: CHCHART, CHBEGIN, SCL, CHPLOTGROWTH, CHFRAME
1328 group, CHSERIES groups, CHPROPERTIES, CHDEFAULTTEXT groups (CHDEFAULTTEXT
1329 with CHTEXT groups), CHUSEDAXESSETS, CHAXESSET groups, CHTEXT groups, CHEND.
1331 class XclImpChChart
: public XclImpChGroupBase
, protected XclImpChRoot
1334 typedef ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::XChartDocument
> XChartDocRef
;
1335 typedef ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::XDiagram
> XDiagramRef
;
1338 explicit XclImpChChart( const XclImpRoot
& rRoot
);
1339 virtual ~XclImpChChart();
1341 /** Reads the CHCHART record (called by base class). */
1342 virtual void ReadHeaderRecord( XclImpStream
& rStrm
);
1343 /** Reads a record from the CHCHART group (called by base class). */
1344 virtual void ReadSubRecord( XclImpStream
& rStrm
);
1345 /** Reads a CHDEFAULTTEXT group (default text formats). */
1346 void ReadChDefaultText( XclImpStream
& rStrm
);
1347 /** Reads a CHDATAFORMAT group describing a series format or a data point format. */
1348 void ReadChDataFormat( XclImpStream
& rStrm
);
1350 /** Sets formatting from BIFF3-BIFF5 OBJ record, if own formatting is invisible. */
1351 void UpdateObjFrame( const XclObjLineData
& rLineData
, const XclObjFillData
& rFillData
);
1353 /** Returns the specified chart type group. */
1354 XclImpChTypeGroupRef
GetTypeGroup( sal_uInt16 nGroupIdx
) const;
1355 /** Returns the specified default text. */
1356 XclImpChTextRef
GetDefaultText( XclChTextType eTextType
) const;
1357 /** Returns the number of units on the progress bar needed for the chart. */
1358 inline sal_Size
GetProgressSize() const { return 2 * EXC_CHART_PROGRESS_SIZE
; }
1360 /** Converts and writes all properties to the passed chart. */
1361 void Convert( XChartDocRef xChartDoc
, ScfProgressBar
& rProgress
, const ::rtl::OUString
& rObjName
) const;
1364 /** Reads a CHSERIES group (data series source and formatting). */
1365 void ReadChSeries( XclImpStream
& rStrm
);
1366 /** Reads a CHPROPERTIES record (global chart properties). */
1367 void ReadChProperties( XclImpStream
& rStrm
);
1368 /** Reads a CHAXESSET group (primary/secondary axes set). */
1369 void ReadChAxesSet( XclImpStream
& rStrm
);
1370 /** Reads a CHTEXT group (chart title and series/point captions). */
1371 void ReadChText( XclImpStream
& rStrm
);
1373 /** Final processing after reading the entire chart data. */
1375 /** Finalizes series list, assigns child series to parent series. */
1376 void FinalizeSeries();
1377 /** Assigns all imported CHDATAFORMAT groups to the respective series. */
1378 void FinalizeDataFormats();
1379 /** Finalizes chart title, tries to detect title auto-generated from series name. */
1380 void FinalizeTitle();
1382 /** Creates and returns a new diagram object and converts global chart settings. */
1383 XDiagramRef
CreateDiagram() const;
1386 typedef ::std::vector
< XclImpChSeriesRef
> XclImpChSeriesVec
;
1387 typedef ScfRefMap
< XclChDataPointPos
, XclImpChDataFormat
> XclImpChDataFormatMap
;
1388 typedef ScfRefMap
< sal_uInt16
, XclImpChText
> XclImpChTextMap
;
1390 XclChRectangle maRect
; /// Position of the chart on the sheet (CHCHART record).
1391 XclImpChSeriesVec maSeries
; /// List of series data (CHSERIES groups).
1392 XclImpChDataFormatMap maDataFmts
; /// All series and point formats (CHDATAFORMAT groups).
1393 XclImpChFrameRef mxFrame
; /// Chart frame format (CHFRAME group).
1394 XclChProperties maProps
; /// Chart properties (CHPROPERTIES record).
1395 XclImpChTextMap maDefTexts
; /// Default text objects (CHDEFAULTTEXT groups).
1396 XclImpChAxesSetRef mxPrimAxesSet
; /// Primary axes set (CHAXESSET group).
1397 XclImpChAxesSetRef mxSecnAxesSet
; /// Secondary axes set (CHAXESSET group).
1398 XclImpChTextRef mxTitle
; /// Chart title (CHTEXT group).
1399 XclImpChLegendRef mxLegend
; /// Chart legend (CHLEGEND group).
1402 typedef ScfRef
< XclImpChChart
> XclImpChChartRef
;
1404 // ----------------------------------------------------------------------------
1406 /** Represents the entire chart substream (all records in BOF/EOF block). */
1407 class XclImpChart
: protected XclImpRoot
1410 typedef ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XModel
> XModelRef
;
1413 /** Constructs a new chart object.
1414 @param bOwnTab True = chart is on an own sheet; false = chart is an embedded object. */
1415 explicit XclImpChart( const XclImpRoot
& rRoot
, bool bOwnTab
);
1417 /** Reads the complete chart substream (BOF/EOF block).
1418 @descr The passed stream must be located in the BOF record of the chart substream. */
1419 void ReadChartSubStream( XclImpStream
& rStrm
);
1420 /** Sets formatting from BIFF3-BIFF5 OBJ record, if own formatting is invisible. */
1421 void UpdateObjFrame( const XclObjLineData
& rLineData
, const XclObjFillData
& rFillData
);
1423 /** Returns the number of units on the progress bar needed for the chart. */
1424 sal_Size
GetProgressSize() const;
1425 /** Returns true, if the chart is based on a pivot table. */
1426 inline bool IsPivotChart() const { return mbIsPivotChart
; }
1428 /** Creates the chart object in the passed component. */
1429 void Convert( XModelRef xModel
, ScfProgressBar
& rProgress
, const ::rtl::OUString
& rObjName
) const;
1432 /** Reads the CHCHART group (entire chart data). */
1433 void ReadChChart( XclImpStream
& rStrm
);
1436 XclImpChChartRef mxChartData
; /// The chart data (CHCHART group).
1437 bool mbOwnTab
; /// true = own sheet; false = embedded object.
1438 bool mbIsPivotChart
; /// true = chart is based on a pivot table.
1441 // ============================================================================