1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_SC_SOURCE_FILTER_INC_XICHART_HXX
21 #define INCLUDED_SC_SOURCE_FILTER_INC_XICHART_HXX
29 #include "xlchart.hxx"
30 #include "xlstyle.hxx"
31 #include "xiescher.hxx"
32 #include "xistring.hxx"
34 namespace com
{ namespace sun
{ namespace star
{
52 class XCoordinateSystem
;
55 class XRegressionCurve
;
59 class XFormattedString
;
64 class XLabeledDataSequence
;
69 struct XclObjLineData
;
70 struct XclObjFillData
;
72 // Common =====================================================================
74 struct XclImpChRootData
;
78 /** Base class for complex chart classes, provides access to other components of the chart. */
79 class XclImpChRoot
: public XclImpRoot
82 explicit XclImpChRoot( const XclImpRoot
& rRoot
, XclImpChChart
& rChartData
);
83 virtual ~XclImpChRoot() override
;
85 XclImpChRoot(XclImpChRoot
const &) = default;
86 XclImpChRoot(XclImpChRoot
&&) = default;
87 XclImpChRoot
& operator =(XclImpChRoot
const &) = delete; // due to XclImpRoot
88 XclImpChRoot
& operator =(XclImpChRoot
&&) = delete; // due to XclImpRoot
90 /** Returns this root instance - for code readability in derived classes. */
91 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;
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;
108 /** Starts the API chart document conversion. Must be called once before all API conversion. */
110 const css::uno::Reference
< css::chart2::XChartDocument
>& xChartDoc
,
111 const tools::Rectangle
& rChartRect
) const;
113 /** Finishes the API chart document conversion. Must be called once after all API conversion. */
114 void FinishConversion( XclImpDffConverter
& rDffConv
) const;
116 /** Returns the data provider for the chart document. */
117 css::uno::Reference
< css::chart2::data::XDataProvider
>
118 GetDataProvider() const;
119 /** Returns the drawing shape interface of the specified title object. */
120 css::uno::Reference
< css::drawing::XShape
>
121 GetTitleShape( const XclChTextKey
& rTitleKey
) const;
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 css::awt::Rectangle
CalcHmmFromChartRect( const XclChRectangle
& rRect
) const;
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;
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;
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. */
159 ScfPropertySet
& rPropSet
,
161 const Color
* pFontColor
= nullptr ) const;
163 /** Writes the pie rotation property for the passed angle. */
164 static void ConvertPieRotation(
165 ScfPropertySet
& rPropSet
,
169 typedef std::shared_ptr
< XclImpChRootData
> XclImpChRootDataRef
;
170 XclImpChRootDataRef mxChData
; /// Reference to the root data object.
173 /** Base class for chart record groups. Provides helper functions to read sub records.
175 A chart record group consists of a header record, followed by a CHBEGIN
176 record, followed by group sub records, and finished with a CHEND record.
178 class XclImpChGroupBase
181 XclImpChGroupBase() = default;
182 XclImpChGroupBase(XclImpChGroupBase
const &) = default;
183 XclImpChGroupBase(XclImpChGroupBase
&&) = default;
184 XclImpChGroupBase
& operator =(XclImpChGroupBase
const &) = default;
185 XclImpChGroupBase
& operator =(XclImpChGroupBase
&&) = default;
187 virtual ~XclImpChGroupBase();
189 /** Reads the entire record group.
190 @descr First calls ReadHeaderRecord() to read the contents of the
191 header record. Then tries to read the sub records. If next record
192 is a CHBEGIN record, ReadSubRecord() is called for each following
193 record until a CHEND record is found. */
194 void ReadRecordGroup( XclImpStream
& rStrm
);
196 /** Helper to skip a CHBEGIN/CHEND block, includes nested blocks. */
197 static void SkipBlock( XclImpStream
& rStrm
);
199 /** Derived classes implement to read the group header record. */
200 virtual void ReadHeaderRecord( XclImpStream
& rStrm
) = 0;
201 /** Derived classes implement to read a record from the group. */
202 virtual void ReadSubRecord( XclImpStream
& rStrm
) = 0;
205 // Frame formatting ===========================================================
207 class XclImpChFramePos
210 /** Reads the CHFRAMEPOS record (frame position and size). */
211 void ReadChFramePos( XclImpStream
& rStrm
);
213 /** Returns read-only access to the imported frame position data. */
214 const XclChFramePos
& GetFramePosData() const { return maData
; }
217 XclChFramePos maData
; /// Position of the frame.
220 typedef std::shared_ptr
< XclImpChFramePos
> XclImpChFramePosRef
;
222 /** The CHLINEFORMAT record containing line formatting data. */
223 class XclImpChLineFormat
226 /** Creates a new line format object with automatic formatting. */
227 explicit XclImpChLineFormat() {}
228 /** Creates a new line format object with the passed formatting. */
229 explicit XclImpChLineFormat( const XclChLineFormat
& rLineFmt
) : maData( rLineFmt
) {}
231 /** Reads the CHLINEFORMAT record (basic line properties). */
232 void ReadChLineFormat( XclImpStream
& rStrm
);
234 /** Returns true, if the line format is set to automatic. */
235 bool IsAuto() const { return ::get_flag( maData
.mnFlags
, EXC_CHLINEFORMAT_AUTO
); }
236 /** Returns true, if the line style is set to something visible. */
237 bool HasLine() const { return IsAuto() || (maData
.mnPattern
!= EXC_CHLINEFORMAT_NONE
); }
238 /** Returns the line width of this line format (returns 'single', if the line is invisible). */
239 sal_Int16
GetWeight() const { return (IsAuto() || !HasLine()) ? EXC_CHLINEFORMAT_SINGLE
: maData
.mnWeight
; }
240 /** Returns true, if the "show axis" flag is set. */
241 bool IsShowAxis() const { return ::get_flag( maData
.mnFlags
, EXC_CHLINEFORMAT_SHOWAXIS
); }
243 /** Converts and writes the contained data to the passed property set. */
244 void Convert( const XclImpChRoot
& rRoot
,
245 ScfPropertySet
& rPropSet
, XclChObjectType eObjType
,
246 sal_uInt16 nFormatIdx
= EXC_CHDATAFORMAT_UNKNOWN
) const;
249 XclChLineFormat maData
; /// Contents of the CHLINEFORMAT record.
252 typedef std::shared_ptr
< XclImpChLineFormat
> XclImpChLineFormatRef
;
254 /** The CHAREAFORMAT record containing simple area formatting data (solid or patterns). */
255 class XclImpChAreaFormat
258 /** Creates a new area format object with automatic formatting. */
259 explicit XclImpChAreaFormat() {}
260 /** Creates a new area format object with the passed formatting. */
261 explicit XclImpChAreaFormat( const XclChAreaFormat
& rAreaFmt
) : maData( rAreaFmt
) {}
263 /** Reads the CHAREAFORMAT record (basic fill properties, e.g. transparent or colored). */
264 void ReadChAreaFormat( XclImpStream
& rStrm
);
266 /** Returns true, if the area format is set to automatic. */
267 bool IsAuto() const { return ::get_flag( maData
.mnFlags
, EXC_CHAREAFORMAT_AUTO
); }
268 /** Returns true, if the area style is set to something visible. */
269 bool HasArea() const { return IsAuto() || (maData
.mnPattern
!= EXC_PATT_NONE
); }
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
) const;
277 XclChAreaFormat maData
; /// Contents of the CHAREAFORMAT record.
280 typedef std::shared_ptr
< XclImpChAreaFormat
> XclImpChAreaFormatRef
;
282 /** The CHESCHERFORMAT record containing complex area formatting data (bitmaps, hatches). */
283 class XclImpChEscherFormat
: public XclImpChGroupBase
286 explicit XclImpChEscherFormat( const XclImpRoot
& rRoot
);
288 /** Reads the CHESCHERFORMAT record (complex fill data) (called by base class). */
289 virtual void ReadHeaderRecord( XclImpStream
& rStrm
) override
;
290 /** Reads a record from the CHESCHERFORMAT group (called by base class). */
291 virtual void ReadSubRecord( XclImpStream
& rStrm
) override
;
293 /** Converts and writes the contained data to the passed property set. */
294 void Convert( const XclImpChRoot
& rRoot
, ScfPropertySet
& rPropSet
,
295 XclChObjectType eObjType
, bool bUsePicFmt
) const;
298 XclChEscherFormat maData
; /// Fill properties for complex areas (CHESCHERFORMAT record).
299 XclChPicFormat maPicFmt
; /// Image options, e.g. stretched, stacked (CHPICFORMAT record).
300 sal_uInt32 mnDffFillType
; /// Fill type imported from the DFF property set.
303 typedef std::shared_ptr
< XclImpChEscherFormat
> XclImpChEscherFormatRef
;
305 /** Base class for record groups containing frame formatting.
307 Frame formatting can be part of several record groups, e.g. CHFRAME,
308 CHDATAFORMAT, CHDROPBAR. It consists of CHLINEFORMAT, CHAREAFORMAT, and
309 CHESCHERFORMAT group.
311 class XclImpChFrameBase
: public XclImpChGroupBase
314 /** Creates a new frame object without internal formatting objects. */
315 explicit XclImpChFrameBase() {}
316 /** Creates a new frame object with specific default formatting. */
317 explicit XclImpChFrameBase( const XclChFormatInfo
& rFmtInfo
);
319 /** Reads a frame formatting record (called by base class). */
320 virtual void ReadSubRecord( XclImpStream
& rStrm
) override
;
322 /** Returns true, if the line format is set to automatic. */
323 bool IsAutoLine() const { return !mxLineFmt
|| mxLineFmt
->IsAuto(); }
324 /** Returns true, if the line style is set to something visible. */
325 bool HasLine() const { return IsAutoLine() || mxLineFmt
->HasLine(); }
326 /** Returns the line weight used for this frame. */
327 sal_Int16
GetLineWeight() const { return mxLineFmt
? mxLineFmt
->GetWeight() : EXC_CHLINEFORMAT_SINGLE
; }
329 /** Returns true, if the area format is set to automatic. */
330 bool IsAutoArea() const { return !mxEscherFmt
&& (!mxAreaFmt
|| mxAreaFmt
->IsAuto()); }
333 /** Converts and writes the contained line formatting to the passed property set. */
334 void ConvertLineBase( const XclImpChRoot
& rRoot
,
335 ScfPropertySet
& rPropSet
, XclChObjectType eObjType
,
336 sal_uInt16 nFormatIdx
= EXC_CHDATAFORMAT_UNKNOWN
) const;
337 /** Converts and writes the contained area formatting to the passed property set. */
338 void ConvertAreaBase( const XclImpChRoot
& rRoot
,
339 ScfPropertySet
& rPropSet
, XclChObjectType eObjType
,
340 sal_uInt16 nFormatIdx
= EXC_CHDATAFORMAT_UNKNOWN
, bool bUsePicFmt
= false ) const;
341 /** Converts and writes the contained data to the passed property set. */
342 void ConvertFrameBase( const XclImpChRoot
& rRoot
,
343 ScfPropertySet
& rPropSet
, XclChObjectType eObjType
,
344 sal_uInt16 nFormatIdx
= EXC_CHDATAFORMAT_UNKNOWN
, bool bUsePicFmt
= false ) const;
347 XclImpChLineFormatRef mxLineFmt
; /// Line format (CHLINEFORMAT record).
348 XclImpChAreaFormatRef mxAreaFmt
; /// Area format (CHAREAFORMAT record).
349 XclImpChEscherFormatRef mxEscherFmt
; /// Complex area format (CHESCHERFORMAT record).
352 /** Represents the CHFRAME record group containing object frame properties.
354 The CHFRAME group consists of: CHFRAME, CHBEGIN, CHLINEFORMAT,
355 CHAREAFORMAT, CHESCHERFORMAT group, CHEND.
357 class XclImpChFrame
: public XclImpChFrameBase
, protected XclImpChRoot
360 /** Creates a new frame object with specific default formatting. */
361 explicit XclImpChFrame(
362 const XclImpChRoot
& rRoot
,
363 XclChObjectType eObjType
);
365 /** Reads the CHFRAME record (called by base class). */
366 virtual void ReadHeaderRecord( XclImpStream
& rStrm
) override
;
368 /** Sets formatting from BIFF3-BIFF5 OBJ record, if own formatting is invisible. */
369 void UpdateObjFrame( const XclObjLineData
& rLineData
, const XclObjFillData
& rFillData
);
371 /** Converts and writes the contained data to the passed property set. */
372 void Convert( ScfPropertySet
& rPropSet
, bool bUsePicFmt
= false ) const;
375 XclChFrame maData
; /// Contents of the CHFRAME record.
376 XclChObjectType meObjType
; /// Type of the represented object.
379 typedef std::shared_ptr
< XclImpChFrame
> XclImpChFrameRef
;
381 // Source links ===============================================================
383 class XclImpChSourceLink
: protected XclImpChRoot
386 explicit XclImpChSourceLink( const XclImpChRoot
& rRoot
);
387 virtual ~XclImpChSourceLink() override
;
389 /** Reads the CHSOURCELINK record (link to source data). */
390 void ReadChSourceLink( XclImpStream
& rStrm
);
391 /** Sets explicit string data for this text object. */
392 void SetString( const OUString
& rString
);
393 /** Sets formatting runs read from a CHFORMATRUNS record. */
394 void SetTextFormats( const XclFormatRunVec
& rFormats
);
396 /** Returns the destination object (title, values, category, ...). */
397 sal_uInt8
GetDestType() const { return maData
.mnDestType
; }
398 /** Returns the link type (to worksheet, directly, default, ...). */
399 sal_uInt8
GetLinkType() const { return maData
.mnLinkType
; }
401 /** Returns true, if the source link contains explicit string data. */
402 bool HasString() const { return mxString
&& !mxString
->IsEmpty(); }
403 /** Returns explicit string data or an empty string. */
404 OUString
GetString() const {
405 if (mxString
) return mxString
->GetText();
408 /** Returns the number of data points of this source link. */
409 sal_uInt16
GetCellCount() const;
411 /** Converts and writes the contained number format to the passed property set. */
412 void ConvertNumFmt( ScfPropertySet
& rPropSet
, bool bPercent
) const;
414 /** Creates a data sequence containing the link into the Calc document. */
415 css::uno::Reference
< css::chart2::data::XDataSequence
>
416 CreateDataSequence( const OUString
& rRole
) const;
417 /** Creates a sequence of formatted string objects. */
418 css::uno::Sequence
< css::uno::Reference
< css::chart2::XFormattedString
> >
419 CreateStringSequence( const XclImpChRoot
& rRoot
,
420 sal_uInt16 nLeadFontIdx
, const Color
& rLeadFontColor
) const;
422 void FillSourceLink(::std::vector
<ScTokenRef
>& rTokens
) const;
425 XclChSourceLink maData
; /// Contents of the CHSOURCELINK record.
426 XclImpStringRef mxString
; /// Text data (CHSTRING record).
427 std::shared_ptr
< ScTokenArray
> mxTokenArray
; /// Token array representing the data ranges.
430 typedef std::shared_ptr
< XclImpChSourceLink
> XclImpChSourceLinkRef
;
432 // Text =======================================================================
434 /** Base class for objects with font settings. Provides font conversion helper functions. */
435 class XclImpChFontBase
438 XclImpChFontBase() = default;
439 XclImpChFontBase(XclImpChFontBase
const &) = default;
440 XclImpChFontBase(XclImpChFontBase
&&) = default;
441 XclImpChFontBase
& operator =(XclImpChFontBase
const &) = default;
442 XclImpChFontBase
& operator =(XclImpChFontBase
&&) = default;
444 virtual ~XclImpChFontBase();
446 /** Derived classes return the leading font index for the text object. */
447 virtual sal_uInt16
GetFontIndex() const = 0;
448 /** Derived classes return the leading font color for the text object. */
449 virtual Color
GetFontColor() const = 0;
450 /** Derived classes return the rotation value for the text object. */
451 virtual sal_uInt16
GetRotation() const = 0;
453 /** Converts and writes the contained font settings to the passed property set. */
454 void ConvertFontBase( const XclImpChRoot
& rRoot
, ScfPropertySet
& rPropSet
) const;
455 /** Converts and writes the contained rotation settings to the passed property set. */
456 void ConvertRotationBase( ScfPropertySet
& rPropSet
, bool bSupportsStacked
) const;
459 /** The CHFONT record containing a font index for text objects. */
463 explicit XclImpChFont();
464 /** Reads the CHFONT record (font index). */
465 void ReadChFont( XclImpStream
& rStrm
);
467 /** Returns the contained font index. */
468 sal_uInt16
GetFontIndex() const { return mnFontIdx
; }
471 sal_uInt16 mnFontIdx
; /// Index into font buffer.
474 typedef std::shared_ptr
< XclImpChFont
> XclImpChFontRef
;
476 /** Represents the CHTEXT record group containing text object properties.
478 The CHTEXT group consists of: CHTEXT, CHBEGIN, CHFRAMEPOS, CHFONT,
479 CHFORMATRUNS, CHSOURCELINK, CHSTRING, CHFRAME group, CHOBJECTLINK, and CHEND.
481 class XclImpChText
: public XclImpChGroupBase
, public XclImpChFontBase
, protected XclImpChRoot
484 explicit XclImpChText( const XclImpChRoot
& rRoot
);
486 /** Reads the CHTEXT record (called by base class). */
487 virtual void ReadHeaderRecord( XclImpStream
& rStrm
) override
;
488 /** Reads a record from the CHTEXT group (called by base class). */
489 virtual void ReadSubRecord( XclImpStream
& rStrm
) override
;
491 /** Returns the leading font index for the text object. */
492 virtual sal_uInt16
GetFontIndex() const override
;
493 /** Returns the leading font color for the text object. */
494 virtual Color
GetFontColor() const override
;
495 /** Returns the rotation value for the text object. */
496 virtual sal_uInt16
GetRotation() const override
;
498 /** Sets explicit string data for this text object. */
499 void SetString( const OUString
& rString
);
500 /** Updates missing parts of this text object from the passed object. */
501 void UpdateText( const XclImpChText
* pParentText
);
502 /** Updates display type of this data point label text object. */
503 void UpdateDataLabel( bool bCateg
, bool bValue
, bool bPercent
);
505 /** Returns the target object this text is linked to. */
506 sal_uInt16
GetLinkTarget() const { return maObjLink
.mnTarget
; }
507 /** Returns the position of the data point label this text is linked to. */
508 const XclChDataPointPos
& GetPointPos() const { return maObjLink
.maPointPos
; }
509 /** Returns true, if this text group contains string data. */
510 bool HasString() const { return mxSrcLink
&& mxSrcLink
->HasString(); }
511 /** Returns true, if the text object is marked as deleted. */
512 bool IsDeleted() const { return ::get_flag( maData
.mnFlags
, EXC_CHTEXT_DELETED
); }
514 /** Converts and writes the contained font settings to the passed property set. */
515 void ConvertFont( ScfPropertySet
& rPropSet
) const;
516 /** Converts and writes the contained rotation settings to the passed property set. */
517 void ConvertRotation( ScfPropertySet
& rPropSet
, bool bSupportsStacked
) const;
518 /** Converts and writes the contained frame data to the passed property set. */
519 void ConvertFrame( ScfPropertySet
& rPropSet
) const;
520 /** Converts and writes the contained number format to the passed property set. */
521 void ConvertNumFmt( ScfPropertySet
& rPropSet
, bool bPercent
) const;
522 /** Converts and writes all contained data to the passed data point label property set. */
523 void ConvertDataLabel( ScfPropertySet
& rPropSet
, const XclChTypeInfo
& rTypeInfo
, const ScfPropertySet
* pGlobalPropSet
) const;
524 /** Creates a title text object. */
525 css::uno::Reference
< css::chart2::XTitle
>
527 /** Converts the manual position of the specified title */
528 void ConvertTitlePosition( const XclChTextKey
& rTitleKey
) const;
531 using XclImpChRoot::ConvertFont
;
533 /** Reads a CHFRLABELPROPS record. */
534 void ReadChFrLabelProps( XclImpStream
& rStrm
);
537 typedef std::shared_ptr
< XclChFrLabelProps
> XclChFrLabelPropsRef
;
539 XclChText maData
; /// Contents of the CHTEXT record.
540 XclChObjectLink maObjLink
; /// Link target for this text object.
541 XclFormatRunVec maFormats
; /// Formatting runs (CHFORMATRUNS record).
542 XclImpChFramePosRef mxFramePos
; /// Relative text frame position (CHFRAMEPOS record).
543 XclImpChSourceLinkRef mxSrcLink
; /// Linked data (CHSOURCELINK with CHSTRING record).
544 XclImpChFrameRef mxFrame
; /// Text object frame properties (CHFRAME group).
545 XclImpChFontRef mxFont
; /// Index into font buffer (CHFONT record).
546 XclChFrLabelPropsRef mxLabelProps
; /// Extended data label properties (CHFRLABELPROPS record).
549 typedef std::shared_ptr
< XclImpChText
> XclImpChTextRef
;
551 // Data series ================================================================
553 /** The CHMARKERFORMAT record containing data point marker formatting data. */
554 class XclImpChMarkerFormat
557 /** Reads the CHMARKERFORMAT record (data point marker properties). */
558 void ReadChMarkerFormat( XclImpStream
& rStrm
);
560 /** Returns true, if the marker format is set to automatic. */
561 bool IsAuto() const { return ::get_flag( maData
.mnFlags
, EXC_CHMARKERFORMAT_AUTO
); }
563 /** Converts and writes the contained data to the passed property set. */
564 void Convert( const XclImpChRoot
& rRoot
, ScfPropertySet
& rPropSet
,
565 sal_uInt16 nFormatIdx
, sal_Int16 nLineWeight
) const;
566 /** Sets the marker fill color as main color to the passed property set. */
567 void ConvertColor( const XclImpChRoot
& rRoot
,
568 ScfPropertySet
& rPropSet
, sal_uInt16 nFormatIdx
) const;
571 XclChMarkerFormat maData
; /// Contents of the CHMARKERFORMAT record.
574 typedef std::shared_ptr
< XclImpChMarkerFormat
> XclImpChMarkerFormatRef
;
576 /** The CHPIEFORMAT record containing data point formatting data for pie segments. */
577 class XclImpChPieFormat
580 explicit XclImpChPieFormat();
581 /** Reads the CHPIEFORMAT record (pie segment properties). */
582 void ReadChPieFormat( XclImpStream
& rStrm
);
583 /** Converts and writes the contained data to the passed property set. */
584 void Convert( ScfPropertySet
& rPropSet
) const;
587 sal_uInt16 mnPieDist
; /// Pie distance to diagram center.
590 typedef std::shared_ptr
< XclImpChPieFormat
> XclImpChPieFormatRef
;
592 /** The CHSERIESFORMAT record containing additional settings for a data series. */
593 class XclImpChSeriesFormat
596 explicit XclImpChSeriesFormat();
597 /** Reads the CHSERIESFORMAT record (additional settings for a series). */
598 void ReadChSeriesFormat( XclImpStream
& rStrm
);
599 /** Returns true, if the series line is smoothed. */
600 bool HasSpline() const { return ::get_flag( mnFlags
, EXC_CHSERIESFORMAT_SMOOTHED
); }
603 sal_uInt16 mnFlags
; /// Additional flags.
606 typedef std::shared_ptr
< XclImpChSeriesFormat
> XclImpChSeriesFormatRef
;
608 /** The CH3DDATAFORMAT record containing the bar type in 3D bar charts. */
609 class XclImpCh3dDataFormat
612 /** Reads the CH3DDATAFORMAT record (3D bar properties). */
613 void ReadCh3dDataFormat( XclImpStream
& rStrm
);
614 /** Converts and writes the contained data to the passed property set. */
615 void Convert( ScfPropertySet
& rPropSet
) const;
618 XclCh3dDataFormat maData
; /// Contents of the CH3DDATAFORMAT record.
621 typedef std::shared_ptr
< XclImpCh3dDataFormat
> XclImpCh3dDataFormatRef
;
623 /** The CHATTACHEDLABEL record that contains the type of a data point label. */
624 class XclImpChAttachedLabel
: protected XclImpChRoot
627 explicit XclImpChAttachedLabel( const XclImpChRoot
& rRoot
);
628 /** Reads the CHATTACHEDLABEL record (data series/point labels). */
629 void ReadChAttachedLabel( XclImpStream
& rStrm
);
630 /** Creates a CHTEXT group for the label. Clones xParentText and sets additional label settings */
631 XclImpChTextRef
CreateDataLabel( const XclImpChText
* pParent
) const;
634 sal_uInt16 mnFlags
; /// Additional flags.
637 typedef std::shared_ptr
< XclImpChAttachedLabel
> XclImpChAttLabelRef
;
639 /** Represents the CHDATAFORMAT record group containing data point properties.
641 The CHDATAFORMAT group consists of: CHDATAFORMAT, CHBEGIN, CHFRAME group,
642 CHMARKERFORMAT, CHPIEFORMAT, CH3DDATAFORMAT, CHSERIESFORMAT,
643 CHATTACHEDLABEL, CHEND.
645 class XclImpChDataFormat
: public XclImpChFrameBase
, protected XclImpChRoot
648 explicit XclImpChDataFormat( const XclImpChRoot
& rRoot
);
650 /** Reads the CHDATAFORMAT record (called by base class). */
651 virtual void ReadHeaderRecord( XclImpStream
& rStrm
) override
;
652 /** Reads a record from the CHDATAFORMAT group (called by base class). */
653 virtual void ReadSubRecord( XclImpStream
& rStrm
) override
;
655 /** Sets this object to the specified data point position. */
656 void SetPointPos( const XclChDataPointPos
& rPointPos
, sal_uInt16 nFormatIdx
);
657 /** Sets type and text formatting for a data point label (CHTEXT group). */
658 void SetDataLabel( XclImpChTextRef xLabel
) { mxLabel
= xLabel
; }
660 /** Updates default data format for series group. */
661 void UpdateGroupFormat( const XclChExtTypeInfo
& rTypeInfo
);
662 /** Updates missing series settings from the passed chart type group data format. */
663 void UpdateSeriesFormat( const XclChExtTypeInfo
& rTypeInfo
, const XclImpChDataFormat
* pGroupFmt
);
664 /** Updates missing data point settings from the passed series format. */
665 void UpdatePointFormat( const XclChExtTypeInfo
& rTypeInfo
, const XclImpChDataFormat
* pSeriesFmt
);
666 /** Updates default data format for trend lines. */
667 void UpdateTrendLineFormat();
669 /** Returns the position of the data point described by this group. */
670 const XclChDataPointPos
& GetPointPos() const { return maData
.maPointPos
; }
671 /** Returns the format index of the data point described by this group. */
672 sal_uInt16
GetFormatIdx() const { return maData
.mnFormatIdx
; }
673 /** Returns true, if markers are set to automatic format. */
674 bool IsAutoMarker() const { return !mxMarkerFmt
|| mxMarkerFmt
->IsAuto(); }
675 /** Returns true, if the series line is smoothed. */
676 bool HasSpline() const { return mxSeriesFmt
&& mxSeriesFmt
->HasSpline(); }
677 /** Returns the data label text object. */
678 const XclImpChText
* GetDataLabel() const { return mxLabel
.get(); }
680 /** Converts and writes the contained data to the passed property set. */
681 void Convert( ScfPropertySet
& rPropSet
, const XclChExtTypeInfo
& rTypeInfo
, const ScfPropertySet
* pGlobalPropSet
= nullptr ) const;
682 /** Writes the line format only, e.g. for trend lines or error bars. */
683 void ConvertLine( ScfPropertySet
& rPropSet
, XclChObjectType eObjType
) const;
684 /** Writes the area format only for the series or a data point. */
685 void ConvertArea( ScfPropertySet
& rPropSet
, sal_uInt16 nFormatIdx
) const;
688 /** Removes unused formatting (e.g. pie distance in a bar chart). */
689 void RemoveUnusedFormats( const XclChExtTypeInfo
& rTypeInfo
);
690 /** Updates or creates the data point label. */
691 void UpdateDataLabel( const XclImpChDataFormat
* pParentFmt
);
694 XclChDataFormat maData
; /// Contents of the CHDATAFORMAT record.
695 XclImpChMarkerFormatRef mxMarkerFmt
; /// Data point marker (CHMARKERFORMAT record).
696 XclImpChPieFormatRef mxPieFmt
; /// Pie segment format (CHPIEFORMAT record).
697 XclImpChSeriesFormatRef mxSeriesFmt
; /// Series properties (CHSERIESFORMAT record).
698 XclImpCh3dDataFormatRef mx3dDataFmt
; /// 3D bar format (CH3DDATAFORMAT record).
699 XclImpChAttLabelRef mxAttLabel
; /// Data point label type (CHATTACHEDLABEL record).
700 XclImpChTextRef mxLabel
; /// Data point label formatting (CHTEXT group).
703 typedef std::shared_ptr
< XclImpChDataFormat
> XclImpChDataFormatRef
;
705 /** Represents the CHSERTRENDLINE record containing settings for a trend line. */
706 class XclImpChSerTrendLine
: protected XclImpChRoot
709 explicit XclImpChSerTrendLine( const XclImpChRoot
& rRoot
);
711 /** Reads the CHSERTRENDLINE record. */
712 void ReadChSerTrendLine( XclImpStream
& rStrm
);
713 /** Sets formatting information for the trend line. */
714 void SetDataFormat( XclImpChDataFormatRef xDataFmt
) { mxDataFmt
= xDataFmt
; }
716 void SetTrendlineName( const OUString
& aTrendlineName
) { maTrendLineName
= aTrendlineName
; }
718 /** Creates an API object representing this trend line. */
719 css::uno::Reference
< css::chart2::XRegressionCurve
>
720 CreateRegressionCurve() const;
723 OUString maTrendLineName
;
724 XclChSerTrendLine maData
; /// Contents of the CHSERTRENDLINE record.
725 XclImpChDataFormatRef mxDataFmt
; /// Formatting settings of the trend line.
728 typedef std::shared_ptr
< XclImpChSerTrendLine
> XclImpChSerTrendLineRef
;
730 /** Represents the CHSERERRORBAR record containing settings for error bars. */
731 class XclImpChSerErrorBar
: protected XclImpChRoot
734 explicit XclImpChSerErrorBar( const XclImpChRoot
& rRoot
);
736 /** Reads the CHSERERRORBAR record. */
737 void ReadChSerErrorBar( XclImpStream
& rStrm
);
738 /** Sets link and formatting information for the error bars. */
740 XclImpChSourceLinkRef
const & xValueLink
,
741 XclImpChDataFormatRef
const & xDataFmt
);
743 /** Returns the type of this error bar (X/Y, plus/minus). */
744 sal_uInt8
GetBarType() const { return maData
.mnBarType
; }
745 /** Creates a labeled data sequence object from value data link. */
746 css::uno::Reference
< css::chart2::data::XLabeledDataSequence
>
747 CreateValueSequence() const;
749 /** Tries to create an error bar API object from the specified Excel error bars. */
750 static css::uno::Reference
< css::beans::XPropertySet
>
752 const XclImpChSerErrorBar
* pPosBar
,
753 const XclImpChSerErrorBar
* pNegBar
);
756 XclChSerErrorBar maData
; /// Contents of the CHSERERRORBAR record.
757 XclImpChSourceLinkRef mxValueLink
; /// Link data for manual error bar values.
758 XclImpChDataFormatRef mxDataFmt
; /// Formatting settings of the error bars.
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 explicit XclImpChSeries( const XclImpChRoot
& rRoot
, sal_uInt16 nSeriesIdx
);
773 /** Reads the CHSERIES record (called by base class). */
774 virtual void ReadHeaderRecord( XclImpStream
& rStrm
) override
;
775 /** Reads a record from the CHSERIES group (called by base class). */
776 virtual void ReadSubRecord( XclImpStream
& rStrm
) override
;
778 /** Sets a data point or series format (CHDATAFORMAT group) for this series. */
779 void SetDataFormat( const XclImpChDataFormatRef
& xDataFmt
);
780 /** Sets a label text (CHTEXT group) attached to a series or data point. */
781 void SetDataLabel( const XclImpChTextRef
& xLabel
);
782 /** Adds error bar settings from the passed series to the own series. */
783 void AddChildSeries( const XclImpChSeries
& rSeries
);
784 /** Updates missing series formatting by using default formatting from axes sets. */
785 void FinalizeDataFormats();
787 /** Returns the axes set identifier this series is assigned to (primary/secondary). */
788 sal_uInt16
GetGroupIdx() const { return mnGroupIdx
; }
789 /** Returns the 0-based index of the parent series (e.g. of a trend line). */
790 sal_uInt16
GetParentIdx() const { return mnParentIdx
; }
791 /** Returns true, if the series is child of another series (e.g. trend line). */
792 bool HasParentSeries() const { return mnParentIdx
!= EXC_CHSERIES_INVALID
; }
793 /** Returns true, if the series contains child series (e.g. trend lines). */
794 bool HasChildSeries() const { return !maTrendLines
.empty() || !m_ErrorBars
.empty(); }
795 /** Returns series title or an empty string, if the series does not contain a title. */
796 OUString
GetTitle() const { return mxTitleLink
? mxTitleLink
->GetString() : OUString(); }
798 /** Returns true, if the series line is smoothed. */
799 bool HasSpline() const { return mxSeriesFmt
&& mxSeriesFmt
->HasSpline(); }
801 /** Creates a labeled data sequence object from value data link. */
802 css::uno::Reference
< css::chart2::data::XLabeledDataSequence
>
803 CreateValueSequence( const OUString
& rValueRole
) const;
804 /** Creates a labeled data sequence object from category data link. */
805 css::uno::Reference
< css::chart2::data::XLabeledDataSequence
>
806 CreateCategSequence( const OUString
& rCategRole
) const;
807 /** Creates a data series object with initialized source links. */
808 css::uno::Reference
< css::chart2::XDataSeries
>
809 CreateDataSeries() const;
811 void FillAllSourceLinks(::std::vector
<ScTokenRef
>& rTokens
) const;
814 /** Reads a CHSOURCELINK record. */
815 void ReadChSourceLink( XclImpStream
& rStrm
);
816 /** Reads a CHDATAFORMAT group containing series and point formatting. */
817 void ReadChDataFormat( XclImpStream
& rStrm
);
818 /** Reads a CHSERPARENT record specifying the parent series of this series. */
819 void ReadChSerParent( XclImpStream
& rStrm
);
820 /** Reads a CHSERTRENDLINE record containing trend line settings. */
821 void ReadChSerTrendLine( XclImpStream
& rStrm
);
822 /** Reads a CHSERERRORBAR record containing error bar settings. */
823 void ReadChSerErrorBar( XclImpStream
& rStrm
);
825 void ReadChLegendException( XclImpStream
& rStrm
);
826 /** Creates a new CHDATAFORMAT group with the specified point index. */
827 XclImpChDataFormatRef
CreateDataFormat( sal_uInt16 nPointIdx
, sal_uInt16 nFormatIdx
);
829 /** Converts all trend lines and inserts them into the passed API data series object. */
830 void ConvertTrendLines( css::uno::Reference
< css::chart2::XDataSeries
> const & xDataSeries
) const;
831 /** Tries to create an error bar API object from the specified Excel error bars. */
832 css::uno::Reference
< css::beans::XPropertySet
>
833 CreateErrorBar( sal_uInt8 nPosBarId
, sal_uInt8 nNegBarId
) const;
836 typedef ::std::map
<sal_uInt16
, XclImpChDataFormatRef
> XclImpChDataFormatMap
;
837 typedef ::std::map
<sal_uInt16
, XclImpChTextRef
> XclImpChTextMap
;
838 typedef ::std::map
<sal_uInt8
, std::unique_ptr
<XclImpChSerErrorBar
>> XclImpChSerErrorBarMap
;
840 XclChSeries maData
; /// Contents of the CHSERIES record.
841 XclImpChSourceLinkRef mxValueLink
; /// Link data for series values.
842 XclImpChSourceLinkRef mxCategLink
; /// Link data for series category names.
843 XclImpChSourceLinkRef mxTitleLink
; /// Link data for series title.
844 XclImpChSourceLinkRef mxBubbleLink
; /// Link data for series bubble sizes.
845 XclImpChDataFormatRef mxSeriesFmt
; /// CHDATAFORMAT group for series format.
846 XclImpChDataFormatMap maPointFmts
; /// CHDATAFORMAT groups for data point formats.
847 XclImpChTextMap maLabels
; /// Data point labels (CHTEXT groups).
848 std::vector
< XclImpChSerTrendLineRef
> maTrendLines
; /// Trend line settings (CHSERTRENDLINE records).
849 XclImpChSerErrorBarMap m_ErrorBars
; /// Error bar settings (CHSERERRORBAR records).
850 sal_uInt16 mnGroupIdx
; /// Chart type group (CHTYPEGROUP group) this series is assigned to.
851 sal_uInt16 mnSeriesIdx
; /// 0-based series index.
852 sal_uInt16 mnParentIdx
; /// 0-based index of parent series (trend lines and error bars).
853 bool mbLabelDeleted
; /// Legend label deleted
856 typedef std::shared_ptr
< XclImpChSeries
> XclImpChSeriesRef
;
858 // Chart type groups ==========================================================
860 class XclImpChType
: protected XclImpChRoot
863 explicit XclImpChType( const XclImpChRoot
& rRoot
);
865 /** Reads a chart type record (e.g. CHBAR, CHLINE, CHPIE, ...). */
866 void ReadChType( XclImpStream
& rStrm
);
867 /** Final processing after reading the entire chart. */
868 void Finalize( bool bStockChart
);
870 /** Returns the record identifier of the chart type record. */
871 sal_uInt16
GetRecId() const { return mnRecId
; }
872 /** Returns the chart type info struct for the contained chart type. */
873 const XclChTypeInfo
& GetTypeInfo() const { return maTypeInfo
; }
874 /** Returns true, if the series in this chart type group are stacked on each other (no percentage). */
875 bool IsStacked() const;
876 /** Returns true, if the series in this chart type group are stacked on each other as percentage. */
877 bool IsPercent() const;
878 /** Returns true, if chart type has category labels enabled (may be disabled in radar charts). */
879 bool HasCategoryLabels() const;
881 /** Creates a coordinate system according to the contained chart type. */
882 css::uno::Reference
< css::chart2::XCoordinateSystem
>
883 CreateCoordSystem( bool b3dChart
) const;
884 /** Creates and returns an object that represents the contained chart type. */
885 css::uno::Reference
< css::chart2::XChartType
>
886 CreateChartType( css::uno::Reference
< css::chart2::XDiagram
> const & xDiagram
, bool b3dChart
) const;
889 XclChType maData
; /// Contents of the chart type record.
890 sal_uInt16 mnRecId
; /// Record identifier for chart type.
891 XclChTypeInfo maTypeInfo
; /// Chart type info for the contained type.
894 /** Represents the CHCHART3D record that contains 3D view settings. */
895 class XclImpChChart3d
898 /** Reads the CHCHART3D record (properties for 3D charts). */
899 void ReadChChart3d( XclImpStream
& rStrm
);
900 /** Returns true, if the data points are clustered on the X axis. */
901 bool IsClustered() const { return ::get_flag( maData
.mnFlags
, EXC_CHCHART3D_CLUSTER
); }
902 /** Converts and writes the contained data to the passed property set. */
903 void Convert( ScfPropertySet
& rPropSet
, bool b3dWallChart
) const;
906 XclChChart3d maData
; /// Contents of the CHCHART3D record.
909 typedef std::shared_ptr
< XclImpChChart3d
> XclImpChChart3dRef
;
911 /** Represents the CHLEGEND record group describing the chart legend.
913 The CHLEGEND group consists of: CHLEGEND, CHBEGIN, CHFRAMEPOS, CHFRAME
914 group, CHTEXT group, CHEND.
916 class XclImpChLegend
: public XclImpChGroupBase
, protected XclImpChRoot
919 explicit XclImpChLegend( const XclImpChRoot
& rRoot
);
921 /** Reads the CHLEGEND record (called by base class). */
922 virtual void ReadHeaderRecord( XclImpStream
& rStrm
) override
;
923 /** Reads a record from the CHLEGEND group (called by base class). */
924 virtual void ReadSubRecord( XclImpStream
& rStrm
) override
;
925 /** Final processing after reading the entire chart. */
928 /** Creates a new legend object. */
929 css::uno::Reference
< css::chart2::XLegend
>
930 CreateLegend() const;
933 XclChLegend maData
; /// Contents of the CHLEGEND record.
934 XclImpChFramePosRef mxFramePos
; /// Legend frame position (CHFRAMEPOS record).
935 XclImpChTextRef mxText
; /// Legend text format (CHTEXT group).
936 XclImpChFrameRef mxFrame
; /// Legend frame format (CHFRAME group).
939 typedef std::shared_ptr
< XclImpChLegend
> XclImpChLegendRef
;
941 /** Represents the CHDROPBAR record group describing pos/neg bars in line charts.
943 The CHDROPBAR group consists of: CHDROPBAR, CHBEGIN, CHLINEFORMAT,
944 CHAREAFORMAT, CHESCHERFORMAT group, CHEND.
946 class XclImpChDropBar
: public XclImpChFrameBase
949 explicit XclImpChDropBar( sal_uInt16 nDropBar
);
951 /** Reads the CHDROPBAR record (called by base class). */
952 virtual void ReadHeaderRecord( XclImpStream
& rStrm
) override
;
954 /** Converts and writes the contained frame data to the passed property set. */
955 void Convert( const XclImpChRoot
& rRoot
, ScfPropertySet
& rPropSet
) const;
958 sal_uInt16 mnDropBar
; /// Drop bar identifier, needed for auto format.
959 sal_uInt16 mnBarDist
; /// Distance between bars (CHDROPBAR record).
963 /** Represents the CHTYPEGROUP record group describing a group of series.
965 The CHTYPEGROUP group consists of: CHTYPEGROUP, CHBEGIN, a chart type
966 record (e.g. CHBAR, CHLINE, CHAREA, CHPIE, ...), CHCHART3D, CHLEGEND group,
967 CHDEFAULTTEXT groups (CHDEFAULTTEXT with CHTEXT groups), CHDROPBAR groups,
968 CHCHARTLINE groups (CHCHARTLINE with CHLINEFORMAT), CHDATAFORMAT group,
971 class XclImpChTypeGroup
: public XclImpChGroupBase
, protected XclImpChRoot
974 explicit XclImpChTypeGroup( const XclImpChRoot
& rRoot
);
976 /** Reads the CHTYPEGROUP record (called by base class). */
977 virtual void ReadHeaderRecord( XclImpStream
& rStrm
) override
;
978 /** Reads a record from the CHTYPEGROUP group (called by base class). */
979 virtual void ReadSubRecord( XclImpStream
& rStrm
) override
;
980 /** Final processing after reading the entire chart. */
983 /** Inserts a series attached to this chart type group.*/
984 void AddSeries( XclImpChSeriesRef
const & xSeries
);
985 /** Marks the passed format index as used. PopUnusedFormatIndex() will not return this index. */
986 void SetUsedFormatIndex( sal_uInt16 nFormatIdx
);
987 /** Returns the next unused format index and marks it as used. */
988 sal_uInt16
PopUnusedFormatIndex();
990 /** Returns the index of this chart type group. */
991 sal_uInt16
GetGroupIdx() const { return maData
.mnGroupIdx
; }
992 /** Returns the chart type info struct for the contained chart type. */
993 const XclChExtTypeInfo
& GetTypeInfo() const { return maTypeInfo
; }
994 /** Returns true, if this chart type group contains at least one valid series. */
995 bool IsValidGroup() const { return !maSeries
.empty(); }
996 /** Returns true, if the series in this chart type group are stacked on each other as percentage. */
997 bool IsPercent() const { return maType
.IsPercent(); }
998 /** Returns true, if the chart is three-dimensional. */
999 bool Is3dChart() const { return mxChart3d
&& maTypeInfo
.mbSupports3d
; }
1000 /** Returns true, if chart type supports wall and floor format in 3d mode. */
1001 bool Is3dWallChart() const { return Is3dChart() && (maTypeInfo
.meTypeCateg
!= EXC_CHTYPECATEG_PIE
); }
1002 /** Returns true, if the series in this chart type group are ordered on the Z axis. */
1003 bool Is3dDeepChart() const { return Is3dWallChart() && mxChart3d
&& !mxChart3d
->IsClustered(); }
1004 /** Returns true, if category (X axis) labels are enabled (may be disabled in radar charts). */
1005 bool HasCategoryLabels() const { return maType
.HasCategoryLabels(); }
1006 /** Returns true, if points of a series show varying automatic area format. */
1007 bool HasVarPointFormat() const;
1008 /** Returns true, if bars are connected with lines (stacked bar charts only). */
1009 bool HasConnectorLines() const;
1011 /** Returns the legend object. */
1012 const XclImpChLegendRef
& GetLegend() const { return mxLegend
; }
1013 /** Returns the default series data format. */
1014 const XclImpChDataFormatRef
& GetGroupFormat() const { return mxGroupFmt
; }
1015 /** Returns series title, if the chart type group contains only one single series. */
1016 OUString
GetSingleSeriesTitle() const;
1018 /** Converts and writes all 3D settings to the passed diagram. */
1019 void ConvertChart3d( ScfPropertySet
& rPropSet
) const;
1020 /** Creates a coordinate system according to the contained chart type. */
1021 css::uno::Reference
< css::chart2::XCoordinateSystem
>
1022 CreateCoordSystem() const;
1023 /** Creates and returns an object that represents the contained chart type. */
1024 css::uno::Reference
< css::chart2::XChartType
>
1025 CreateChartType( css::uno::Reference
< css::chart2::XDiagram
> const & xDiagram
, sal_Int32 nApiAxesSetIdx
) const;
1026 /** Creates a labeled data sequence object for axis categories. */
1027 css::uno::Reference
< css::chart2::data::XLabeledDataSequence
>
1028 CreateCategSequence() const;
1031 /** Reads a CHDROPBAR record group. */
1032 void ReadChDropBar( XclImpStream
& rStrm
);
1033 /** Reads a CHCHARTLINE record group. */
1034 void ReadChChartLine( XclImpStream
& rStrm
);
1035 /** Reads a CHDATAFORMAT record group (default series format). */
1036 void ReadChDataFormat( XclImpStream
& rStrm
);
1038 /** Returns true, if the chart type group contains drop bar formats. */
1039 bool HasDropBars() const { return !m_DropBars
.empty(); }
1041 /** Inserts the passed series into the chart type. Adds additional properties to the series. */
1042 void InsertDataSeries( css::uno::Reference
< css::chart2::XChartType
> const & xChartType
,
1043 css::uno::Reference
< css::chart2::XDataSeries
> const & xSeries
,
1044 sal_Int32 nApiAxesSetIdx
) const;
1045 /** Creates all data series of any chart type except stock charts. */
1046 void CreateDataSeries( css::uno::Reference
< css::chart2::XChartType
> const & xChartType
,
1047 sal_Int32 nApiAxesSetIdx
) const;
1048 /** Creates all data series of a stock chart. */
1049 void CreateStockSeries( css::uno::Reference
< css::chart2::XChartType
> const & xChartType
,
1050 sal_Int32 nApiAxesSetIdx
) const;
1053 typedef ::std::vector
< XclImpChSeriesRef
> XclImpChSeriesVec
;
1054 typedef ::std::map
<sal_uInt16
, std::unique_ptr
<XclImpChDropBar
>> XclImpChDropBarMap
;
1055 typedef ::std::map
<sal_uInt16
, XclImpChLineFormat
> XclImpChLineFormatMap
;
1056 typedef ::std::set
< sal_uInt16
> UInt16Set
;
1058 XclChTypeGroup maData
; /// Contents of the CHTYPEGROUP record.
1059 XclImpChType maType
; /// Chart type (e.g. CHBAR, CHLINE, ...).
1060 XclChExtTypeInfo maTypeInfo
; /// Extended chart type info.
1061 XclImpChSeriesVec maSeries
; /// Series attached to this chart type group (CHSERIES groups).
1062 XclImpChSeriesRef mxFirstSeries
; /// First series in this chart type group (CHSERIES groups).
1063 XclImpChChart3dRef mxChart3d
; /// 3D settings (CHCHART3D record).
1064 XclImpChLegendRef mxLegend
; /// Chart legend (CHLEGEND group).
1065 XclImpChDropBarMap m_DropBars
; /// Dropbars (CHDROPBAR group).
1066 XclImpChLineFormatMap m_ChartLines
; /// Global line formats (CHCHARTLINE group).
1067 XclImpChDataFormatRef mxGroupFmt
; /// Default format for all series (CHDATAFORMAT group).
1068 UInt16Set maUnusedFormats
; /// Contains unused format indexes for automatic colors.
1071 typedef std::shared_ptr
< XclImpChTypeGroup
> XclImpChTypeGroupRef
;
1073 // Axes =======================================================================
1075 class XclImpChLabelRange
: protected XclImpChRoot
1078 explicit XclImpChLabelRange( const XclImpChRoot
& rRoot
);
1079 /** Reads the CHLABELRANGE record (category axis scaling properties). */
1080 void ReadChLabelRange( XclImpStream
& rStrm
);
1081 /** Reads the CHDATERANGE record (date axis scaling properties). */
1082 void ReadChDateRange( XclImpStream
& rStrm
);
1083 /** Converts category axis scaling settings. */
1084 void Convert( ScfPropertySet
& rPropSet
, css::chart2::ScaleData
& rScaleData
, bool bMirrorOrient
) const;
1085 /** Converts position settings of this axis at a crossing axis. */
1086 void ConvertAxisPosition( ScfPropertySet
& rPropSet
, bool b3dChart
) const;
1089 XclChLabelRange maLabelData
; /// Contents of the CHLABELRANGE record.
1090 XclChDateRange maDateData
; /// Contents of the CHDATERANGE record.
1093 typedef std::shared_ptr
< XclImpChLabelRange
> XclImpChLabelRangeRef
;
1095 class XclImpChValueRange
: protected XclImpChRoot
1098 explicit XclImpChValueRange( const XclImpChRoot
& rRoot
);
1099 /** Reads the CHVALUERANGE record (numeric axis scaling properties). */
1100 void ReadChValueRange( XclImpStream
& rStrm
);
1101 /** Converts value axis scaling settings. */
1102 void Convert( css::chart2::ScaleData
& rScaleData
, bool bMirrorOrient
) const;
1103 /** Converts position settings of this axis at a crossing axis. */
1104 void ConvertAxisPosition( ScfPropertySet
& rPropSet
) const;
1107 XclChValueRange maData
; /// Contents of the CHVALUERANGE record.
1110 typedef std::shared_ptr
< XclImpChValueRange
> XclImpChValueRangeRef
;
1112 class XclImpChTick
: protected XclImpChRoot
1115 explicit XclImpChTick( const XclImpChRoot
& rRoot
);
1116 /** Reads the CHTICK record (axis ticks properties). */
1117 void ReadChTick( XclImpStream
& rStrm
);
1119 /** Returns true, if the axis shows attached labels. */
1120 bool HasLabels() const { return maData
.mnLabelPos
!= EXC_CHTICK_NOLABEL
; }
1121 /** Returns the leading font color for the axis labels. */
1122 Color
GetFontColor() const;
1123 /** Returns the rotation value for the axis labels. */
1124 sal_uInt16
GetRotation() const;
1126 /** Converts and writes the contained data to the passed property set. */
1127 void Convert( ScfPropertySet
& rPropSet
) const;
1130 XclChTick maData
; /// Contents of the CHTICK record.
1133 typedef std::shared_ptr
< XclImpChTick
> XclImpChTickRef
;
1135 /** Represents the CHAXIS record group describing an entire chart axis.
1137 The CHAXIS group consists of: CHAXIS, CHBEGIN, CHLABELRANGE, CHEXTRANGE,
1138 CHVALUERANGE, CHFORMAT, CHTICK, CHFONT, CHAXISLINE groups (CHAXISLINE with
1139 CHLINEFORMAT, CHAREAFORMAT, and CHESCHERFORMAT group), CHEND.
1141 class XclImpChAxis
: public XclImpChGroupBase
, public XclImpChFontBase
, protected XclImpChRoot
1144 explicit XclImpChAxis( const XclImpChRoot
& rRoot
, sal_uInt16 nAxisType
= EXC_CHAXIS_NONE
);
1146 /** Reads the CHAXIS record (called by base class). */
1147 virtual void ReadHeaderRecord( XclImpStream
& rStrm
) override
;
1148 /** Reads a record from the CHAXIS group (called by base class). */
1149 virtual void ReadSubRecord( XclImpStream
& rStrm
) override
;
1150 /** Final processing after reading the entire chart. */
1153 /** Returns the font index for the axis labels. */
1154 virtual sal_uInt16
GetFontIndex() const override
;
1155 /** Returns the font color for the axis labels. */
1156 virtual Color
GetFontColor() const override
;
1157 /** Returns the rotation value for axis labels. */
1158 virtual sal_uInt16
GetRotation() const override
;
1160 /** Returns the type of this axis. */
1161 sal_uInt16
GetAxisType() const { return maData
.mnType
; }
1162 /** Returns the axis dimension index used by the chart API. */
1163 sal_Int32
GetApiAxisDimension() const { return maData
.GetApiAxisDimension(); }
1165 /** Creates an API axis object. */
1166 css::uno::Reference
< css::chart2::XAxis
>
1167 CreateAxis( const XclImpChTypeGroup
& rTypeGroup
, const XclImpChAxis
* pCrossingAxis
) const;
1168 /** Converts and writes 3D wall/floor properties to the passed property set. */
1169 void ConvertWall( ScfPropertySet
& rPropSet
) const;
1170 /** Converts position settings of this axis at a crossing axis. */
1171 void ConvertAxisPosition( ScfPropertySet
& rPropSet
, const XclImpChTypeGroup
& rTypeGroup
) const;
1174 /** Reads a CHAXISLINE record specifying the target for following line properties. */
1175 void ReadChAxisLine( XclImpStream
& rStrm
);
1176 /** Creates a CHFRAME object and stores it into the mxWallFrame member. */
1177 void CreateWallFrame();
1180 XclChAxis maData
; /// Contents of the CHAXIS record.
1181 XclImpChLabelRangeRef mxLabelRange
; /// Category scaling (CHLABELRANGE record).
1182 XclImpChValueRangeRef mxValueRange
; /// Value scaling (CHVALUERANGE record).
1183 XclImpChTickRef mxTick
; /// Axis ticks (CHTICK record).
1184 XclImpChFontRef mxFont
; /// Index into font buffer (CHFONT record).
1185 XclImpChLineFormatRef mxAxisLine
; /// Axis line format (CHLINEFORMAT record).
1186 XclImpChLineFormatRef mxMajorGrid
; /// Major grid line format (CHLINEFORMAT record).
1187 XclImpChLineFormatRef mxMinorGrid
; /// Minor grid line format (CHLINEFORMAT record).
1188 XclImpChFrameRef mxWallFrame
; /// Wall/floor format (sub records of CHFRAME group).
1189 sal_uInt16 mnNumFmtIdx
; /// Index into number format buffer (CHFORMAT record).
1192 typedef std::shared_ptr
< XclImpChAxis
> XclImpChAxisRef
;
1194 /** Represents the CHAXESSET record group describing an axes set (X/Y/Z axes).
1196 The CHAXESSET group consists of: CHAXESSET, CHBEGIN, CHFRAMEPOS, CHAXIS
1197 groups, CHTEXT groups, CHPLOTFRAME group (CHPLOTFRAME with CHFRAME group),
1198 CHTYPEGROUP group, CHEND.
1200 class XclImpChAxesSet
: public XclImpChGroupBase
, protected XclImpChRoot
1203 explicit XclImpChAxesSet( const XclImpChRoot
& rRoot
, sal_uInt16 nAxesSetId
);
1205 /** Reads the CHAXESSET record (called by base class). */
1206 virtual void ReadHeaderRecord( XclImpStream
& rStrm
) override
;
1207 /** Reads a record from the CHAXESSET group (called by base class). */
1208 virtual void ReadSubRecord( XclImpStream
& rStrm
) override
;
1209 /** Final processing after reading the entire chart. */
1212 /** Returns true, if this axes set exists (returns false if this is a dummy object). */
1213 bool IsValidAxesSet() const { return !maTypeGroups
.empty(); }
1214 /** Returns the index of the axes set (primary/secondary). */
1215 sal_uInt16
GetAxesSetId() const { return maData
.mnAxesSetId
; }
1216 /** Returns the axes set index used by the chart API. */
1217 sal_Int32
GetApiAxesSetIndex() const { return maData
.GetApiAxesSetIndex(); }
1219 /** Returns the outer plot area position, if existing. */
1220 const XclImpChFramePosRef
& GetPlotAreaFramePos() const { return mxFramePos
; }
1221 /** Returns the specified chart type group. */
1222 XclImpChTypeGroupRef
GetTypeGroup( sal_uInt16 nGroupIdx
) const;
1223 /** Returns the first chart type group. */
1224 XclImpChTypeGroupRef
GetFirstTypeGroup() const;
1225 /** Looks for a legend in all chart type groups and returns it. */
1226 XclImpChLegendRef
GetLegend() const;
1227 /** Returns series title, if the axes set contains only one single series. */
1228 OUString
GetSingleSeriesTitle() const;
1230 /** Creates a coordinate system and converts all series and axis settings. */
1231 void Convert( css::uno::Reference
< css::chart2::XDiagram
> const & xDiagram
) const;
1232 /** Converts the manual positions of all axis titles. */
1233 void ConvertTitlePositions() const;
1236 /** Reads a CHAXIS record group containing a single axis. */
1237 void ReadChAxis( XclImpStream
& rStrm
);
1238 /** Reads a CHTEXT record group containing an axis title. */
1239 void ReadChText( XclImpStream
& rStrm
);
1240 /** Reads the CHPLOTFRAME record group containing diagram area formatting. */
1241 void ReadChPlotFrame( XclImpStream
& rStrm
);
1242 /** Reads a CHTYPEGROUP record group containing chart type and chart settings. */
1243 void ReadChTypeGroup( XclImpStream
& rStrm
);
1245 /** Creates a coordinate system that contains all chart types for this axes set. */
1246 css::uno::Reference
< css::chart2::XCoordinateSystem
>
1247 CreateCoordSystem( css::uno::Reference
< css::chart2::XDiagram
> const & xDiagram
) const;
1248 /** Creates and inserts an axis into the container and registers the coordinate system. */
1249 void ConvertAxis( XclImpChAxisRef
const & xChAxis
, XclImpChTextRef
const & xChAxisTitle
,
1250 css::uno::Reference
< css::chart2::XCoordinateSystem
> const & xCoordSystem
,
1251 const XclImpChAxis
* pCrossingAxis
) const;
1252 /** Creates and returns an API axis object. */
1253 css::uno::Reference
< css::chart2::XAxis
>
1254 CreateAxis( const XclImpChAxis
& rChAxis
, const XclImpChAxis
* pCrossingAxis
) const;
1255 /** Writes all properties of the background area to the passed diagram. */
1256 void ConvertBackground( css::uno::Reference
< css::chart2::XDiagram
> const & xDiagram
) const;
1259 typedef ::std::map
<sal_uInt16
, XclImpChTypeGroupRef
> XclImpChTypeGroupMap
;
1261 XclChAxesSet maData
; /// Contents of the CHAXESSET record.
1262 XclImpChFramePosRef mxFramePos
; /// Outer plot area position (CHFRAMEPOS record).
1263 XclImpChAxisRef mxXAxis
; /// The X axis (CHAXIS group).
1264 XclImpChAxisRef mxYAxis
; /// The Y axis (CHAXIS group).
1265 XclImpChAxisRef mxZAxis
; /// The Z axis (CHAXIS group).
1266 XclImpChTextRef mxXAxisTitle
; /// The X axis title (CHTEXT group).
1267 XclImpChTextRef mxYAxisTitle
; /// The Y axis title (CHTEXT group).
1268 XclImpChTextRef mxZAxisTitle
; /// The Z axis title (CHTEXT group).
1269 XclImpChFrameRef mxPlotFrame
; /// Plot area (CHPLOTFRAME group).
1270 XclImpChTypeGroupMap maTypeGroups
; /// Chart type groups (CHTYPEGROUP group).
1273 typedef std::shared_ptr
< XclImpChAxesSet
> XclImpChAxesSetRef
;
1275 // The chart object ===========================================================
1277 /** Represents the CHCHART record group describing the chart contents.
1279 The CHCHART group consists of: CHCHART, CHBEGIN, SCL, CHPLOTGROWTH, CHFRAME
1280 group, CHSERIES groups, CHPROPERTIES, CHDEFAULTTEXT groups (CHDEFAULTTEXT
1281 with CHTEXT groups), CHUSEDAXESSETS, CHAXESSET groups, CHTEXT groups, CHEND.
1283 class XclImpChChart
: public XclImpChGroupBase
, protected XclImpChRoot
1286 explicit XclImpChChart( const XclImpRoot
& rRoot
);
1287 virtual ~XclImpChChart() override
;
1289 /** Reads the CHCHART record (called by base class). */
1290 virtual void ReadHeaderRecord( XclImpStream
& rStrm
) override
;
1291 /** Reads a record from the CHCHART group (called by base class). */
1292 virtual void ReadSubRecord( XclImpStream
& rStrm
) override
;
1293 /** Reads a CHDEFAULTTEXT group (default text formats). */
1294 void ReadChDefaultText( XclImpStream
& rStrm
);
1295 /** Reads a CHDATAFORMAT group describing a series format or a data point format. */
1296 void ReadChDataFormat( XclImpStream
& rStrm
);
1298 /** Sets formatting from BIFF3-BIFF5 OBJ record, if own formatting is invisible. */
1299 void UpdateObjFrame( const XclObjLineData
& rLineData
, const XclObjFillData
& rFillData
);
1301 /** Returns the specified chart type group. */
1302 XclImpChTypeGroupRef
GetTypeGroup( sal_uInt16 nGroupIdx
) const;
1303 /** Returns the specified default text. */
1304 const XclImpChText
* GetDefaultText( XclChTextType eTextType
) const;
1305 /** Returns true, if the plot area has benn moved and/or resized manually. */
1306 bool IsManualPlotArea() const;
1307 /** Returns the number of units on the progress bar needed for the chart. */
1308 static std::size_t GetProgressSize() { return 2 * EXC_CHART_PROGRESS_SIZE
; }
1310 /** Converts and writes all properties to the passed chart. */
1312 const css::uno::Reference
< css::chart2::XChartDocument
>& xChartDoc
,
1313 XclImpDffConverter
& rDffConv
,
1314 const OUString
& rObjName
,
1315 const tools::Rectangle
& rChartRect
) const;
1318 /** Reads a CHSERIES group (data series source and formatting). */
1319 void ReadChSeries( XclImpStream
& rStrm
);
1320 /** Reads a CHPROPERTIES record (global chart properties). */
1321 void ReadChProperties( XclImpStream
& rStrm
);
1322 /** Reads a CHAXESSET group (primary/secondary axes set). */
1323 void ReadChAxesSet( XclImpStream
& rStrm
);
1324 /** Reads a CHTEXT group (chart title and series/point captions). */
1325 void ReadChText( XclImpStream
& rStrm
);
1327 /** Final processing after reading the entire chart data. */
1329 /** Finalizes series list, assigns child series to parent series. */
1330 void FinalizeSeries();
1331 /** Assigns all imported CHDATAFORMAT groups to the respective series. */
1332 void FinalizeDataFormats();
1333 /** Finalizes chart title, tries to detect title auto-generated from series name. */
1334 void FinalizeTitle();
1336 /** Creates and returns a new diagram object and converts global chart settings. */
1337 css::uno::Reference
<css::chart2::XDiagram
>
1338 CreateDiagram() const;
1341 typedef ::std::vector
< XclImpChSeriesRef
> XclImpChSeriesVec
;
1342 typedef ::std::map
<XclChDataPointPos
, XclImpChDataFormatRef
> XclImpChDataFormatMap
;
1343 typedef ::std::map
<sal_uInt16
, std::unique_ptr
<XclImpChText
>> XclImpChTextMap
;
1345 XclChRectangle maRect
; /// Position of the chart on the sheet (CHCHART record).
1346 XclImpChSeriesVec maSeries
; /// List of series data (CHSERIES groups).
1347 XclImpChDataFormatMap maDataFmts
; /// All series and point formats (CHDATAFORMAT groups).
1348 XclImpChFrameRef mxFrame
; /// Chart frame format (CHFRAME group).
1349 XclChProperties maProps
; /// Chart properties (CHPROPERTIES record).
1350 XclImpChTextMap m_DefTexts
; /// Default text objects (CHDEFAULTTEXT groups).
1351 XclImpChAxesSetRef mxPrimAxesSet
; /// Primary axes set (CHAXESSET group).
1352 XclImpChAxesSetRef mxSecnAxesSet
; /// Secondary axes set (CHAXESSET group).
1353 XclImpChTextRef mxTitle
; /// Chart title (CHTEXT group).
1354 XclImpChLegendRef mxLegend
; /// Chart legend (CHLEGEND group).
1357 typedef std::shared_ptr
< XclImpChChart
> XclImpChChartRef
;
1359 /** Drawing container of a chart. */
1360 class XclImpChartDrawing
: public XclImpDrawing
1363 explicit XclImpChartDrawing( const XclImpRoot
& rRoot
, bool bOwnTab
);
1365 /** Converts all objects and inserts them into the chart drawing page. */
1366 void ConvertObjects(
1367 XclImpDffConverter
& rDffConv
,
1368 const css::uno::Reference
< css::frame::XModel
>& rxModel
,
1369 const tools::Rectangle
& rChartRect
);
1371 /** Calculate the resulting rectangle of the passed anchor. */
1372 virtual tools::Rectangle
CalcAnchorRect( const XclObjAnchor
& rAnchor
, bool bDffAnchor
) const override
;
1373 /** Called whenever an object has been inserted into the draw page. */
1374 virtual void OnObjectInserted( const XclImpDrawObjBase
& rDrawObj
) override
;
1377 tools::Rectangle maChartRect
; /// Position and size of the chart shape in 1/100 mm.
1378 SCTAB mnScTab
; /// Index of the sheet that contains the chart.
1379 bool mbOwnTab
; /// True = own sheet, false = embedded object.
1382 /** Represents the entire chart substream (all records in BOF/EOF block). */
1383 class XclImpChart
: protected XclImpRoot
1386 /** Constructs a new chart object.
1387 @param bOwnTab True = chart is on an own sheet; false = chart is an embedded object. */
1388 explicit XclImpChart( const XclImpRoot
& rRoot
, bool bOwnTab
);
1389 virtual ~XclImpChart() override
;
1391 /** Reads the complete chart substream (BOF/EOF block).
1392 @descr The passed stream must be located in the BOF record of the chart substream. */
1393 void ReadChartSubStream( XclImpStream
& rStrm
);
1394 /** Sets formatting from BIFF3-BIFF5 OBJ record, if own formatting is invisible. */
1395 void UpdateObjFrame( const XclObjLineData
& rLineData
, const XclObjFillData
& rFillData
);
1397 /** Returns the number of units on the progress bar needed for the chart. */
1398 std::size_t GetProgressSize() const;
1399 /** Returns true, if the chart is based on a pivot table. */
1400 bool IsPivotChart() const { return mbIsPivotChart
; }
1402 /** Creates the chart object in the passed component. */
1403 void Convert( css::uno::Reference
< css::frame::XModel
> const & xModel
,
1404 XclImpDffConverter
& rDffConv
,
1405 const OUString
& rObjName
,
1406 const tools::Rectangle
& rChartRect
) const;
1409 /** Returns (initially creates) the drawing container for embedded shapes. **/
1410 XclImpChartDrawing
& GetChartDrawing();
1411 /** Reads the CHCHART group (entire chart data). */
1412 void ReadChChart( XclImpStream
& rStrm
);
1415 typedef std::shared_ptr
< XclImpChartDrawing
> XclImpChartDrawingRef
;
1417 XclImpChChartRef mxChartData
; /// The chart data (CHCHART group).
1418 XclImpChartDrawingRef mxChartDrawing
; /// Drawing container for embedded shapes.
1419 bool mbOwnTab
; /// true = own sheet; false = embedded object.
1420 bool mbIsPivotChart
; /// true = chart is based on a pivot table.
1425 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */