Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / sc / source / filter / inc / xechart.hxx
blob37cdf1125d489bfc2a10e220a04bbc30be54f865
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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_XECHART_HXX
21 #define INCLUDED_SC_SOURCE_FILTER_INC_XECHART_HXX
23 #include "xerecord.hxx"
24 #include "xlchart.hxx"
25 #include "xlformula.hxx"
26 #include "xlstyle.hxx"
27 #include "xeroot.hxx"
28 #include "xestring.hxx"
30 #include <memory>
31 #include <map>
33 class Size;
34 class Rectangle;
36 namespace com { namespace sun { namespace star {
37 namespace awt
39 struct Rectangle;
41 namespace frame
43 class XModel;
45 namespace chart
47 class XAxis;
49 namespace chart2
51 struct ScaleData;
52 class XChartDocument;
53 class XDiagram;
54 class XCoordinateSystem;
55 class XChartType;
56 class XDataSeries;
57 class XAxis;
58 class XTitle;
59 class XFormattedString;
60 class XRegressionCurve;
61 namespace data
63 class XDataSequence;
64 class XLabeledDataSequence;
67 } } }
69 // Common =====================================================================
71 struct XclExpChRootData;
72 class XclExpChChart;
74 /** Base class for complex chart classes, provides access to other components
75 of the chart.
77 Keeps also track of future record levels and writes the needed future
78 records on demand.
80 class XclExpChRoot : public XclExpRoot
82 public:
83 explicit XclExpChRoot( const XclExpRoot& rRoot, XclExpChChart& rChartData );
84 virtual ~XclExpChRoot();
86 /** Returns this root instance - for code readability in derived classes. */
87 inline const XclExpChRoot& GetChRoot() const { return *this; }
88 /** Returns the API Chart document model. */
89 css::uno::Reference< css::chart2::XChartDocument >
90 GetChartDocument() const;
91 /** Returns a reference to the parent chart data object. */
92 XclExpChChart& GetChartData() const;
93 /** Returns chart type info for a unique chart type identifier. */
94 const XclChTypeInfo& GetChartTypeInfo( XclChTypeId eType ) const;
95 /** Returns the first fitting chart type info for the passed service name. */
96 const XclChTypeInfo& GetChartTypeInfo( const OUString& rServiceName ) const;
98 /** Returns an info struct about auto formatting for the passed object type. */
99 const XclChFormatInfo& GetFormatInfo( XclChObjectType eObjType ) const;
101 /** Starts the API chart document conversion. Must be called once before all API conversion. */
102 void InitConversion( css::uno::Reference< css::chart2::XChartDocument > xChartDoc,
103 const Rectangle& rChartRect ) const;
104 /** Finishes the API chart document conversion. Must be called once after all API conversion. */
105 void FinishConversion() const;
107 /** Returns true, if the passed color equals to the specified system color. */
108 bool IsSystemColor( const Color& rColor, sal_uInt16 nSysColorIdx ) const;
109 /** Sets a system color and the respective color identifier. */
110 void SetSystemColor( Color& rColor, sal_uInt32& rnColorId, sal_uInt16 nSysColorIdx ) const;
112 /** Converts the passed horizontal coordinate from 1/100 mm to Excel chart units. */
113 sal_Int32 CalcChartXFromHmm( sal_Int32 nPosX ) const;
114 /** Converts the passed vertical coordinate from 1/100 mm to Excel chart units. */
115 sal_Int32 CalcChartYFromHmm( sal_Int32 nPosY ) const;
116 /** Converts the passed rectangle from 1/100 mm to Excel chart units. */
117 XclChRectangle CalcChartRectFromHmm( const css::awt::Rectangle& rRect ) const;
119 /** Reads all line properties from the passed property set. */
120 void ConvertLineFormat(
121 XclChLineFormat& rLineFmt,
122 const ScfPropertySet& rPropSet,
123 XclChPropertyMode ePropMode ) const;
124 /** Reads solid area properties from the passed property set.
125 @return true = object contains complex fill properties. */
126 bool ConvertAreaFormat(
127 XclChAreaFormat& rAreaFmt,
128 const ScfPropertySet& rPropSet,
129 XclChPropertyMode ePropMode ) const;
130 /** Reads gradient or bitmap area properties from the passed property set. */
131 void ConvertEscherFormat(
132 XclChEscherFormat& rEscherFmt,
133 XclChPicFormat& rPicFmt,
134 const ScfPropertySet& rPropSet,
135 XclChPropertyMode ePropMode ) const;
136 /** Reads font properties from the passed property set. */
137 sal_uInt16 ConvertFont(
138 const ScfPropertySet& rPropSet,
139 sal_Int16 nScript ) const;
141 /** Reads the pie rotation property and returns the converted angle. */
142 static sal_uInt16 ConvertPieRotation( const ScfPropertySet& rPropSet );
144 protected:
145 /** Called from XclExpChGroupBase::Save, registers a new future record level. */
146 void RegisterFutureRecBlock( const XclChFrBlock& rFrBlock );
147 /** Called from XclExpChFutureRecordBase::Save, Initializes the current future record level. */
148 void InitializeFutureRecBlock( XclExpStream& rStrm );
149 /** Called from XclExpChGroupBase::Save, finalizes the current future record level. */
150 void FinalizeFutureRecBlock( XclExpStream& rStrm );
152 private:
153 typedef std::shared_ptr< XclExpChRootData > XclExpChRootDataRef;
154 XclExpChRootDataRef mxChData; /// Reference to the root data object.
157 /** Base class for chart record groups. Provides helper functions to write sub records.
159 A chart record group consists of a header record, followed by a CHBEGIN
160 record, followed by group sub records, and finished with a CHEND record.
162 class XclExpChGroupBase : public XclExpRecord, protected XclExpChRoot
164 public:
165 explicit XclExpChGroupBase(
166 const XclExpChRoot& rRoot, sal_uInt16 nFrType,
167 sal_uInt16 nRecId, sal_Size nRecSize = 0 );
168 virtual ~XclExpChGroupBase();
170 /** Saves the header record. Calls WriteSubRecords() to let derived classes write sub records. */
171 virtual void Save( XclExpStream& rStrm ) override;
172 /** Derived classes return whether there are any records embedded in this group. */
173 virtual bool HasSubRecords() const;
174 /** Derived classes implement writing any records embedded in this group. */
175 virtual void WriteSubRecords( XclExpStream& rStrm ) = 0;
177 protected:
178 /** Sets context information for future record blocks. */
179 void SetFutureRecordContext( sal_uInt16 nFrContext,
180 sal_uInt16 nFrValue1 = 0, sal_uInt16 nFrValue2 = 0 );
182 private:
183 XclChFrBlock maFrBlock; /// Future records block settings.
186 /** Base class for chart future records. On saving, the record writes missing
187 CHFRBLOCKBEGIN records automatically.
189 class XclExpChFutureRecordBase : public XclExpFutureRecord, protected XclExpChRoot
191 public:
192 explicit XclExpChFutureRecordBase( const XclExpChRoot& rRoot,
193 XclFutureRecType eRecType, sal_uInt16 nRecId, sal_Size nRecSize = 0 );
195 /** Writes missing CHFRBLOCKBEGIN records and this record. */
196 virtual void Save( XclExpStream& rStrm ) override;
199 // Frame formatting ===========================================================
201 class XclExpChFramePos : public XclExpRecord
203 public:
204 explicit XclExpChFramePos( sal_uInt16 nTLMode, sal_uInt16 nBRMode );
206 /** Returns read/write access to the frame position data. */
207 inline XclChFramePos& GetFramePosData() { return maData; }
209 private:
210 virtual void WriteBody( XclExpStream& rStrm ) override;
212 private:
213 XclChFramePos maData; /// Position of the frame.
216 typedef std::shared_ptr< XclExpChFramePos > XclExpChFramePosRef;
218 class XclExpChLineFormat : public XclExpRecord
220 public:
221 explicit XclExpChLineFormat( const XclExpChRoot& rRoot );
223 /** Converts line formatting properties from the passed property set. */
224 void Convert( const XclExpChRoot& rRoot,
225 const ScfPropertySet& rPropSet, XclChObjectType eObjType );
226 /** Sets or clears the automatic flag. */
227 inline void SetAuto( bool bAuto ) { ::set_flag( maData.mnFlags, EXC_CHLINEFORMAT_AUTO, bAuto ); }
228 /** Sets flag to show or hide an axis. */
229 inline void SetShowAxis( bool bShowAxis )
230 { ::set_flag( maData.mnFlags, EXC_CHLINEFORMAT_SHOWAXIS, bShowAxis ); }
231 /** Sets the line format to the specified default type. */
232 void SetDefault( XclChFrameType eDefFrameType );
234 /** Returns true, if the line format is set to automatic. */
235 inline bool IsAuto() const { return ::get_flag( maData.mnFlags, EXC_CHLINEFORMAT_AUTO ); }
236 /** Returns true, if the line style is set to something visible. */
237 inline bool HasLine() const { return maData.mnPattern != EXC_CHLINEFORMAT_NONE; }
238 /** Returns true, if the line contains default formatting according to the passed frame type. */
239 bool IsDefault( XclChFrameType eDefFrameType ) const;
241 private:
242 virtual void WriteBody( XclExpStream& rStrm ) override;
244 private:
245 XclChLineFormat maData; /// Contents of the CHLINEFORMAT record.
246 sal_uInt32 mnColorId; /// Line color identifier.
249 typedef std::shared_ptr< XclExpChLineFormat > XclExpChLineFormatRef;
251 class XclExpChAreaFormat : public XclExpRecord
253 public:
254 explicit XclExpChAreaFormat( const XclExpChRoot& rRoot );
256 /** Converts area formatting properties from the passed property set.
257 @return true = object contains complex fill properties. */
258 bool Convert( const XclExpChRoot& rRoot,
259 const ScfPropertySet& rPropSet, XclChObjectType eObjType );
260 /** Sets or clears the automatic flag. */
261 inline void SetAuto( bool bAuto ) { ::set_flag( maData.mnFlags, EXC_CHAREAFORMAT_AUTO, bAuto ); }
262 /** Sets the area format to the specified default type. */
263 void SetDefault( XclChFrameType eDefFrameType );
265 /** Returns true, if the area format is set to automatic. */
266 inline bool IsAuto() const { return ::get_flag( maData.mnFlags, EXC_CHAREAFORMAT_AUTO ); }
267 /** Returns true, if the area style is set to something visible. */
268 inline bool HasArea() const { return maData.mnPattern != EXC_PATT_NONE; }
269 /** Returns true, if the area contains default formatting according to the passed frame type. */
270 bool IsDefault( XclChFrameType eDefFrameType ) const;
272 private:
273 virtual void WriteBody( XclExpStream& rStrm ) override;
275 private:
276 XclChAreaFormat maData; /// Contents of the CHAREAFORMAT record.
277 sal_uInt32 mnPattColorId; /// Pattern color identifier.
278 sal_uInt32 mnBackColorId; /// Pattern background color identifier.
281 typedef std::shared_ptr< XclExpChAreaFormat > XclExpChAreaFormatRef;
283 class XclExpChEscherFormat : public XclExpChGroupBase
285 public:
286 explicit XclExpChEscherFormat( const XclExpChRoot& rRoot );
288 /** Converts complex area formatting from the passed property set. */
289 void Convert( const ScfPropertySet& rPropSet, XclChObjectType eObjType );
291 /** Returns true, if the object contains valid formatting data. */
292 bool IsValid() const;
294 /** Writes the CHESCHERFORMAT record group to the stream, if complex formatting is extant. */
295 virtual void Save( XclExpStream& rStrm ) override;
296 /** Returns true, if this record group contains a CHPICFORMAT record. */
297 virtual bool HasSubRecords() const override;
298 /** Writes all embedded records. */
299 virtual void WriteSubRecords( XclExpStream& rStrm ) override;
301 private:
302 /** Inserts a color from the contained Escher property set into the color palette. */
303 sal_uInt32 RegisterColor( sal_uInt16 nPropId );
305 virtual void WriteBody( XclExpStream& rStrm ) override;
307 private:
308 XclChEscherFormat maData; /// Fill properties for complex areas (CHESCHERFORMAT record).
309 XclChPicFormat maPicFmt; /// Image options, e.g. stretched, stacked (CHPICFORMAT record).
310 sal_uInt32 mnColor1Id; /// First fill color identifier.
311 sal_uInt32 mnColor2Id; /// Second fill color identifier.
314 typedef std::shared_ptr< XclExpChEscherFormat > XclExpChEscherFormatRef;
316 /** Base class for record groups containing frame formatting.
318 Frame formatting can be part of several record groups, e.g. CHFRAME,
319 CHDATAFORMAT, CHDROPBAR. It consists of CHLINEFORMAT, CHAREAFORMAT, and
320 CHESCHERFORMAT group.
322 class XclExpChFrameBase
324 public:
325 explicit XclExpChFrameBase();
326 virtual ~XclExpChFrameBase();
328 protected:
329 /** Converts frame formatting properties from the passed property set. */
330 void ConvertFrameBase( const XclExpChRoot& rRoot,
331 const ScfPropertySet& rPropSet, XclChObjectType eObjType );
332 /** Sets the frame formatting to the specified default type. */
333 void SetDefaultFrameBase( const XclExpChRoot& rRoot,
334 XclChFrameType eDefFrameType, bool bIsFrame );
336 /** Returns true, if the frame contains default formatting (as if the frame is missing). */
337 bool IsDefaultFrameBase( XclChFrameType eDefFrameType ) const;
339 /** Writes all contained frame records to the passed stream. */
340 void WriteFrameRecords( XclExpStream& rStrm );
342 private:
343 XclExpChLineFormatRef mxLineFmt; /// Line format (CHLINEFORMAT record).
344 XclExpChAreaFormatRef mxAreaFmt; /// Area format (CHAREAFORMAT record).
345 XclExpChEscherFormatRef mxEscherFmt; /// Complex area format (CHESCHERFORMAT record).
348 /** Represents the CHFRAME record group containing object frame properties.
350 The CHFRAME group consists of: CHFRAME, CHBEGIN, CHLINEFORMAT,
351 CHAREAFORMAT, CHESCHERFORMAT group, CHEND.
353 class XclExpChFrame : public XclExpChGroupBase, public XclExpChFrameBase
355 public:
356 explicit XclExpChFrame( const XclExpChRoot& rRoot, XclChObjectType eObjType );
358 /** Converts frame formatting properties from the passed property set. */
359 void Convert( const ScfPropertySet& rPropSet );
360 /** Sets the specified automatic flags. */
361 void SetAutoFlags( bool bAutoPos, bool bAutoSize );
363 /** Returns true, if the frame object contains default formats. */
364 bool IsDefault() const;
365 /** Returns true, if the frame object can be deleted because it contains default formats. */
366 bool IsDeleteable() const;
368 /** Writes the entire record group. */
369 virtual void Save( XclExpStream& rStrm ) override;
370 /** Writes all embedded records. */
371 virtual void WriteSubRecords( XclExpStream& rStrm ) override;
373 private:
374 virtual void WriteBody( XclExpStream& rStrm ) override;
376 private:
377 XclChFrame maData; /// Contents of the CHFRAME record.
378 XclChObjectType meObjType; /// Type of the represented object.
381 typedef std::shared_ptr< XclExpChFrame > XclExpChFrameRef;
383 // Source links ===============================================================
385 class XclExpChSourceLink : public XclExpRecord, protected XclExpChRoot
387 public:
388 explicit XclExpChSourceLink( const XclExpChRoot& rRoot, sal_uInt8 nDestType );
390 void ConvertString( const OUString& aString );
391 /** Converts the passed source link, returns the number of linked values. */
392 sal_uInt16 ConvertDataSequence( css::uno::Reference< css::chart2::data::XDataSequence > xDataSeq,
393 bool bSplitToColumns, sal_uInt16 nDefCount = 0 );
394 /** Converts the passed sequence of formatted string objects, returns leading font index. */
395 sal_uInt16 ConvertStringSequence( const css::uno::Sequence< css::uno::Reference< css::chart2::XFormattedString > >& rStringSeq );
396 /** Converts the number format from the passed property set. */
397 void ConvertNumFmt( const ScfPropertySet& rPropSet, bool bPercent );
399 void AppendString( const OUString& rStr );
401 /** Returns true, if this source link contains explicit string data. */
402 inline bool HasString() const { return mxString && !mxString->IsEmpty(); }
404 /** Writes the CHSOURCELINK record and optionally a CHSTRING record with explicit string data. */
405 virtual void Save( XclExpStream& rStrm ) override;
407 private:
408 virtual void WriteBody( XclExpStream& rStrm ) override;
410 private:
411 XclChSourceLink maData; /// Contents of the CHSOURCELINK record.
412 XclTokenArrayRef mxLinkFmla; /// Formula with link to source data.
413 XclExpStringRef mxString; /// Text data (CHSTRING record).
416 typedef std::shared_ptr< XclExpChSourceLink > XclExpChSourceLinkRef;
418 // Text =======================================================================
420 /** The CHFONT record containing a font index for text objects. */
421 class XclExpChFont : public XclExpUInt16Record
423 public:
424 explicit XclExpChFont( sal_uInt16 nFontIdx );
427 typedef std::shared_ptr< XclExpChFont > XclExpChFontRef;
429 /** The CHOBJECTLINK record linking a text object to a specific chart object. */
430 class XclExpChObjectLink : public XclExpRecord
432 public:
433 explicit XclExpChObjectLink( sal_uInt16 nLinkTarget, const XclChDataPointPos& rPointPos );
435 private:
436 virtual void WriteBody( XclExpStream& rStrm ) override;
438 private:
439 XclChObjectLink maData; /// Contents of the CHOBJECTLINK record.
442 typedef std::shared_ptr< XclExpChObjectLink > XclExpChObjectLinkRef;
444 /** Additional data label settings in the future record CHFRLABELPROPS. */
445 class XclExpChFrLabelProps : public XclExpChFutureRecordBase
447 public:
448 explicit XclExpChFrLabelProps( const XclExpChRoot& rRoot );
450 /** Converts separator and the passed data label flags. */
451 void Convert(
452 const ScfPropertySet& rPropSet,
453 bool bShowCateg, bool bShowValue,
454 bool bShowPercent, bool bShowBubble );
456 private:
457 virtual void WriteBody( XclExpStream& rStrm ) override;
459 private:
460 XclChFrLabelProps maData; /// Contents of the CHFRLABELPROPS record.
463 typedef std::shared_ptr< XclExpChFrLabelProps > XclExpChFrLabelPropsRef;
465 /** Base class for objects with font settings. Provides font conversion helper functions. */
466 class XclExpChFontBase
468 public:
469 virtual ~XclExpChFontBase();
471 /** Derived classes set font color and color identifier to internal data structures. */
472 virtual void SetFont( XclExpChFontRef xFont, const Color& rColor, sal_uInt32 nColorId ) = 0;
473 /** Derived classes set text rotation to internal data structures. */
474 virtual void SetRotation( sal_uInt16 nRotation ) = 0;
476 /** Creates a CHFONT record from the passed font index, calls virtual function SetFont(). */
477 void ConvertFontBase( const XclExpChRoot& rRoot, sal_uInt16 nFontIdx );
478 /** Creates a CHFONT record from the passed font index, calls virtual function SetFont(). */
479 void ConvertFontBase( const XclExpChRoot& rRoot, const ScfPropertySet& rPropSet );
480 /** Converts rotation settings, calls virtual function SetRotation(). */
481 void ConvertRotationBase( const ScfPropertySet& rPropSet, bool bSupportsStacked );
484 /** Represents the CHTEXT record group containing text object properties.
486 The CHTEXT group consists of: CHTEXT, CHBEGIN, CHFRAMEPOS, CHFONT,
487 CHFORMATRUNS, CHSOURCELINK, CHSTRING, CHFRAME group, CHOBJECTLINK, and CHEND.
489 class XclExpChText : public XclExpChGroupBase, public XclExpChFontBase
491 public:
492 explicit XclExpChText( const XclExpChRoot& rRoot );
494 /** Sets font color and color identifier to internal data structures. */
495 virtual void SetFont( XclExpChFontRef xFont, const Color& rColor, sal_uInt32 nColorId ) override;
496 /** Sets text rotation to internal data structures. */
497 virtual void SetRotation( sal_uInt16 nRotation ) override;
499 /** Converts all text settings of the passed title text object. */
500 void ConvertTitle( css::uno::Reference< css::chart2::XTitle > xTitle, sal_uInt16 nTarget, const OUString* pSubTitle = nullptr );
501 /** Converts all text settings of the passed legend. */
502 void ConvertLegend( const ScfPropertySet& rPropSet );
503 /** Converts all settings of the passed data point caption text object. */
504 bool ConvertDataLabel( const ScfPropertySet& rPropSet,
505 const XclChTypeInfo& rTypeInfo, const XclChDataPointPos& rPointPos );
506 /** Converts all settings of the passed trend line equation box. */
507 void ConvertTrendLineEquation( const ScfPropertySet& rPropSet, const XclChDataPointPos& rPointPos );
509 /** Returns true, if the string object does not contain any text data. */
510 inline bool HasString() const { return mxSrcLink && mxSrcLink->HasString(); }
511 /** Returns the flags needed for the CHATTACHEDLABEL record. */
512 sal_uInt16 GetAttLabelFlags() const;
514 /** Writes all embedded records. */
515 virtual void WriteSubRecords( XclExpStream& rStrm ) override;
517 private:
518 virtual void WriteBody( XclExpStream& rStrm ) override;
520 private:
521 XclChText maData; /// Contents of the CHTEXT record.
522 XclExpChFramePosRef mxFramePos; /// Relative text frame position (CHFRAMEPOS record).
523 XclExpChSourceLinkRef mxSrcLink; /// Linked data (CHSOURCELINK with CHSTRING record).
524 XclExpChFrameRef mxFrame; /// Text object frame properties (CHFRAME group).
525 XclExpChFontRef mxFont; /// Index into font buffer (CHFONT record).
526 XclExpChObjectLinkRef mxObjLink; /// Link target for this text object.
527 XclExpChFrLabelPropsRef mxLabelProps; /// Extended data label properties (CHFRLABELPROPS record).
528 sal_uInt32 mnTextColorId; /// Text color identifier.
531 typedef std::shared_ptr< XclExpChText > XclExpChTextRef;
533 // Data series ================================================================
535 /** The CHMARKERFORMAT record containing data point marker formatting data. */
536 class XclExpChMarkerFormat : public XclExpRecord
538 public:
539 explicit XclExpChMarkerFormat( const XclExpChRoot& rRoot );
541 /** Converts symbol properties from the passed property set. */
542 void Convert( const XclExpChRoot& rRoot,
543 const ScfPropertySet& rPropSet, sal_uInt16 nFormatIdx );
544 /** Converts symbol properties for stock charts from the passed property set. */
545 void ConvertStockSymbol( const XclExpChRoot& rRoot,
546 const ScfPropertySet& rPropSet, bool bCloseSymbol );
548 /** Returns true, if markers are enabled. */
549 inline bool HasMarker() const { return maData.mnMarkerType != EXC_CHMARKERFORMAT_NOSYMBOL; }
550 /** Returns true, if border line of markers is visible. */
551 inline bool HasLineColor() const { return !::get_flag( maData.mnFlags, EXC_CHMARKERFORMAT_NOLINE ); }
552 /** Returns true, if fill area of markers is visible. */
553 inline bool HasFillColor() const { return !::get_flag( maData.mnFlags, EXC_CHMARKERFORMAT_NOFILL ); }
555 private:
556 /** Registers marker colors in palette and stores color identifiers. */
557 void RegisterColors( const XclExpChRoot& rRoot );
559 virtual void WriteBody( XclExpStream& rStrm ) override;
561 private:
562 XclChMarkerFormat maData; /// Contents of the CHMARKERFORMAT record.
563 sal_uInt32 mnLineColorId; /// Border line color identifier.
564 sal_uInt32 mnFillColorId; /// Fill color identifier.
567 typedef std::shared_ptr< XclExpChMarkerFormat > XclExpChMarkerFormatRef;
569 /** The CHPIEFORMAT record containing data point formatting data for pie segments. */
570 class XclExpChPieFormat : public XclExpUInt16Record
572 public:
573 explicit XclExpChPieFormat();
575 /** Sets pie segment properties from the passed property set. */
576 void Convert( const ScfPropertySet& rPropSet );
579 typedef std::shared_ptr< XclExpChPieFormat > XclExpChPieFormatRef;
581 /** The CH3DDATAFORMAT record containing the bar type in 3D bar charts. */
582 class XclExpCh3dDataFormat : public XclExpRecord
584 public:
585 explicit XclExpCh3dDataFormat();
587 /** Sets 3d bar properties from the passed property set. */
588 void Convert( const ScfPropertySet& rPropSet );
590 private:
591 virtual void WriteBody( XclExpStream& rStrm ) override;
593 private:
594 XclCh3dDataFormat maData; /// Contents of the CH3DDATAFORMAT record.
597 typedef std::shared_ptr< XclExpCh3dDataFormat > XclExpCh3dDataFormatRef;
599 /** The CHATTACHEDLABEL record that contains the type of a data point label. */
600 class XclExpChAttachedLabel : public XclExpUInt16Record
602 public:
603 explicit XclExpChAttachedLabel( sal_uInt16 nFlags );
606 typedef std::shared_ptr< XclExpChAttachedLabel > XclExpChAttLabelRef;
608 /** Represents the CHDATAFORMAT record group containing data point properties.
610 The CHDATAFORMAT group consists of: CHDATAFORMAT, CHBEGIN, CHFRAME group,
611 CHMARKERFORMAT, CHPIEFORMAT, CH3DDATAFORMAT, CHSERIESFORMAT,
612 CHATTACHEDLABEL, CHEND.
614 class XclExpChDataFormat : public XclExpChGroupBase, public XclExpChFrameBase
616 public:
617 explicit XclExpChDataFormat( const XclExpChRoot& rRoot,
618 const XclChDataPointPos& rPointPos, sal_uInt16 nFormatIdx );
620 /** Converts the passed data series or data point formatting. */
621 void ConvertDataSeries( const ScfPropertySet& rPropSet, const XclChExtTypeInfo& rTypeInfo );
622 /** Sets default formatting for a series in a stock chart. */
623 void ConvertStockSeries( const ScfPropertySet& rPropSet, bool bCloseSymbol );
624 /** Converts line formatting for the specified object (e.g. trend lines, error bars). */
625 void ConvertLine( const ScfPropertySet& rPropSet, XclChObjectType eObjType );
627 /** Returns true, if this objects describes the formatting of an entire series. */
628 inline bool IsSeriesFormat() const { return maData.maPointPos.mnPointIdx == EXC_CHDATAFORMAT_ALLPOINTS; }
630 /** Writes all embedded records. */
631 virtual void WriteSubRecords( XclExpStream& rStrm ) override;
633 private:
634 virtual void WriteBody( XclExpStream& rStrm ) override;
636 private:
637 XclChDataFormat maData; /// Contents of the CHDATAFORMAT record.
638 XclExpChMarkerFormatRef mxMarkerFmt; /// Data point marker (CHMARKERFORMAT record).
639 XclExpChPieFormatRef mxPieFmt; /// Pie segment format (CHPIEFORMAT record).
640 XclExpRecordRef mxSeriesFmt; /// Series properties (CHSERIESFORMAT record).
641 XclExpCh3dDataFormatRef mx3dDataFmt; /// 3D bar format (CH3DDATAFORMAT record).
642 XclExpChAttLabelRef mxAttLabel; /// Data point label type (CHATTACHEDLABEL record).
645 typedef std::shared_ptr< XclExpChDataFormat > XclExpChDataFormatRef;
647 /** Represents the CHSERTRENDLINE record containing settings for a trend line. */
648 class XclExpChSerTrendLine : public XclExpRecord, protected XclExpChRoot
650 public:
651 explicit XclExpChSerTrendLine( const XclExpChRoot& rRoot );
653 /** Converts the passed trend line, returns true if trend line type is supported. */
654 bool Convert( css::uno::Reference< css::chart2::XRegressionCurve > xRegCurve,
655 sal_uInt16 nSeriesIdx );
657 /** Returns formatting information of the trend line, created in Convert(). */
658 const XclExpChDataFormatRef& GetDataFormat() const { return mxDataFmt; }
659 /** Returns formatting of the equation text box, created in Convert(). */
660 const XclExpChTextRef& GetDataLabel() const { return mxLabel; }
662 private:
663 virtual void WriteBody( XclExpStream& rStrm ) override;
665 private:
666 XclChSerTrendLine maData; /// Contents of the CHSERTRENDLINE record.
667 XclExpChDataFormatRef mxDataFmt; /// Formatting settings of the trend line.
668 XclExpChTextRef mxLabel; /// Formatting of the equation text box.
671 typedef std::shared_ptr< XclExpChSerTrendLine > XclExpChSerTrendLineRef;
673 /** Represents the CHSERERRORBAR record containing settings for error bars. */
674 class XclExpChSerErrorBar : public XclExpRecord, protected XclExpChRoot
676 public:
677 explicit XclExpChSerErrorBar( const XclExpChRoot& rRoot, sal_uInt8 nBarType );
679 /** Converts the passed error bar settings, returns true if error bar type is supported. */
680 bool Convert( XclExpChSourceLink& rValueLink, sal_uInt16& rnValueCount, const ScfPropertySet& rPropSet );
682 private:
683 virtual void WriteBody( XclExpStream& rStrm ) override;
685 private:
686 XclChSerErrorBar maData; /// Contents of the CHSERERRORBAR record.
689 typedef std::shared_ptr< XclExpChSerErrorBar > XclExpChSerErrorBarRef;
691 /** Represents the CHSERIES record group describing a data series in a chart.
693 The CHSERIES group consists of: CHSERIES, CHBEGIN, CHSOURCELINK groups,
694 CHDATAFORMAT groups, CHSERGROUP, CHSERPARENT, CHSERERRORBAR,
695 CHSERTRENDLINE, CHEND.
697 class XclExpChSeries : public XclExpChGroupBase
699 public:
700 explicit XclExpChSeries( const XclExpChRoot& rRoot, sal_uInt16 nSeriesIdx );
702 /** Converts the passed data series (source links and formatting). */
703 bool ConvertDataSeries(
704 css::uno::Reference< css::chart2::XDiagram > xDiagram,
705 css::uno::Reference< css::chart2::XDataSeries > xDataSeries,
706 const XclChExtTypeInfo& rTypeInfo,
707 sal_uInt16 nGroupIdx, sal_uInt16 nFormatIdx );
708 /** Converts the passed data series for stock charts. */
709 bool ConvertStockSeries(
710 css::uno::Reference< css::chart2::XDataSeries > xDataSeries,
711 const OUString& rValueRole,
712 sal_uInt16 nGroupIdx, sal_uInt16 nFormatIdx, bool bCloseSymbol );
713 /** Converts the passed error bar settings (called at trend line child series). */
714 bool ConvertTrendLine( const XclExpChSeries& rParent,
715 css::uno::Reference< css::chart2::XRegressionCurve > xRegCurve );
716 /** Converts the passed error bar settings (called at error bar child series). */
717 bool ConvertErrorBar( const XclExpChSeries& rParent, const ScfPropertySet& rPropSet, sal_uInt8 nBarId );
718 /** Converts and inserts category ranges for all inserted series. */
719 void ConvertCategSequence( css::uno::Reference< css::chart2::data::XLabeledDataSequence > xCategSeq );
721 /** Writes all embedded records. */
722 virtual void WriteSubRecords( XclExpStream& rStrm ) override;
724 private:
725 /** Initializes members of this series to represent a child of the passed series. */
726 void InitFromParent( const XclExpChSeries& rParent );
727 /** Tries to create trend line series objects (called at parent series). */
728 void CreateTrendLines( css::uno::Reference< css::chart2::XDataSeries > xDataSeries );
729 /** Tries to create positive and negative error bar series objects (called at parent series). */
730 void CreateErrorBars( const ScfPropertySet& rPropSet,
731 const OUString& rBarPropName,
732 sal_uInt8 nPosBarId, sal_uInt8 nNegBarId );
733 /** Tries to create an error bar series object (called at parent series). */
734 void CreateErrorBar( const ScfPropertySet& rPropSet,
735 const OUString& rShowPropName, sal_uInt8 nBarId );
737 virtual void WriteBody( XclExpStream& rStrm ) override;
739 private:
740 typedef XclExpRecordList< XclExpChDataFormat > XclExpChDataFormatList;
742 private:
743 XclChSeries maData; /// Contents of the CHSERIES record.
744 XclExpChSourceLinkRef mxTitleLink; /// Link data for series title.
745 XclExpChSourceLinkRef mxValueLink; /// Link data for series values.
746 XclExpChSourceLinkRef mxCategLink; /// Link data for series category names.
747 XclExpChSourceLinkRef mxBubbleLink; /// Link data for series bubble sizes.
748 XclExpChDataFormatRef mxSeriesFmt; /// CHDATAFORMAT group for series format.
749 XclExpChDataFormatList maPointFmts; /// CHDATAFORMAT groups for data point formats.
750 XclExpChSerTrendLineRef mxTrendLine; /// Trend line settings (CHSERTRENDLINE record).
751 XclExpChSerErrorBarRef mxErrorBar; /// Error bar settings (CHSERERRORBAR record).
752 sal_uInt16 mnGroupIdx; /// Chart type group (CHTYPEGROUP group) this series is assigned to.
753 sal_uInt16 mnSeriesIdx; /// 0-based series index.
754 sal_uInt16 mnParentIdx; /// 0-based index of parent series (trend lines and error bars).
757 typedef std::shared_ptr< XclExpChSeries > XclExpChSeriesRef;
759 // Chart type groups ==========================================================
761 /** Represents the chart type record for all supported chart types. */
762 class XclExpChType : public XclExpRecord, protected XclExpChRoot
764 public:
765 explicit XclExpChType( const XclExpChRoot& rRoot );
767 /** Converts the passed chart type and the contained data series. */
768 void Convert( css::uno::Reference< css::chart2::XDiagram > xDiagram,
769 css::uno::Reference< css::chart2::XChartType > xChartType,
770 sal_Int32 nApiAxesSetIdx, bool bSwappedAxesSet, bool bHasXLabels );
771 /** Sets stacking mode (standard or percent) for the series in this chart type group. */
772 void SetStacked( bool bPercent );
774 /** Returns true, if this is object represents a valid chart type. */
775 inline bool IsValidType() const { return maTypeInfo.meTypeId != EXC_CHTYPEID_UNKNOWN; }
776 /** Returns the chart type info struct for the contained chart type. */
777 inline const XclChTypeInfo& GetTypeInfo() const { return maTypeInfo; }
779 private:
780 virtual void WriteBody( XclExpStream& rStrm ) override;
782 private:
783 XclChType maData; /// Contents of the chart type record.
784 XclChTypeInfo maTypeInfo; /// Chart type info for the contained type.
787 /** Represents the CHCHART3D record that contains 3D view settings. */
788 class XclExpChChart3d : public XclExpRecord
790 public:
791 explicit XclExpChChart3d();
793 /** Converts 3d settings for the passed chart type. */
794 void Convert( const ScfPropertySet& rPropSet, bool b3dWallChart );
795 /** Sets flag that the data points are clustered on the X axis. */
796 inline void SetClustered() { ::set_flag( maData.mnFlags, EXC_CHCHART3D_CLUSTER ); }
798 /** Returns true, if the data points are clustered on the X axis. */
799 inline bool IsClustered() const { return ::get_flag( maData.mnFlags, EXC_CHCHART3D_CLUSTER ); }
801 private:
802 virtual void WriteBody( XclExpStream& rStrm ) override;
804 private:
805 XclChChart3d maData; /// Contents of the CHCHART3D record.
808 typedef std::shared_ptr< XclExpChChart3d > XclExpChChart3dRef;
810 /** Represents the CHLEGEND record group describing the chart legend.
812 The CHLEGEND group consists of: CHLEGEND, CHBEGIN, CHFRAMEPOS, CHFRAME
813 group, CHTEXT group, CHEND.
815 class XclExpChLegend : public XclExpChGroupBase
817 public:
818 explicit XclExpChLegend( const XclExpChRoot& rRoot );
820 /** Converts all legend settings from the passed property set. */
821 void Convert( const ScfPropertySet& rPropSet );
823 /** Writes all embedded records. */
824 virtual void WriteSubRecords( XclExpStream& rStrm ) override;
826 private:
827 virtual void WriteBody( XclExpStream& rStrm ) override;
829 private:
830 XclChLegend maData; /// Contents of the CHLEGEND record.
831 XclExpChFramePosRef mxFramePos; /// Legend frame position (CHFRAMEPOS record).
832 XclExpChTextRef mxText; /// Legend text format (CHTEXT group).
833 XclExpChFrameRef mxFrame; /// Legend frame format (CHFRAME group).
836 typedef std::shared_ptr< XclExpChLegend > XclExpChLegendRef;
838 /** Represents the CHDROPBAR record group describing pos/neg bars in line charts.
840 The CHDROPBAR group consists of: CHDROPBAR, CHBEGIN, CHLINEFORMAT,
841 CHAREAFORMAT, CHESCHERFORMAT group, CHEND.
843 class XclExpChDropBar : public XclExpChGroupBase, public XclExpChFrameBase
845 public:
846 explicit XclExpChDropBar( const XclExpChRoot& rRoot, XclChObjectType eObjType );
848 /** Converts and writes the contained frame data to the passed property set. */
849 void Convert( const ScfPropertySet& rPropSet );
851 /** Writes all embedded records. */
852 virtual void WriteSubRecords( XclExpStream& rStrm ) override;
854 private:
855 virtual void WriteBody( XclExpStream& rStrm ) override;
857 private:
858 XclChObjectType meObjType; /// Type of the dropbar.
859 sal_uInt16 mnBarDist; /// Distance between bars (CHDROPBAR record).
862 typedef std::shared_ptr< XclExpChDropBar > XclExpChDropBarRef;
864 /** Represents the CHTYPEGROUP record group describing a group of series.
866 The CHTYPEGROUP group consists of: CHTYPEGROUP, CHBEGIN, a chart type
867 record (e.g. CHBAR, CHLINE, CHAREA, CHPIE, ...), CHCHART3D, CHLEGEND group,
868 CHDROPBAR groups, CHCHARTLINE groups (CHCHARTLINE with CHLINEFORMAT),
869 CHDATAFORMAT group, CHEND.
871 class XclExpChTypeGroup : public XclExpChGroupBase
873 public:
874 explicit XclExpChTypeGroup( const XclExpChRoot& rRoot, sal_uInt16 nGroupIdx );
876 /** Converts the passed chart type to Excel type settings. */
877 void ConvertType( css::uno::Reference< css::chart2::XDiagram > xDiagram,
878 css::uno::Reference< css::chart2::XChartType > xChartType,
879 sal_Int32 nApiAxesSetIdx, bool b3dChart, bool bSwappedAxesSet, bool bHasXLabels );
880 /** Converts and inserts all series from the passed chart type. */
881 void ConvertSeries( css::uno::Reference< css::chart2::XDiagram > xDiagram,
882 css::uno::Reference< css::chart2::XChartType > xChartType,
883 sal_Int32 nGroupAxesSetIdx, bool bPercent, bool bConnectorLines );
884 /** Converts and inserts category ranges for all inserted series. */
885 void ConvertCategSequence( css::uno::Reference< css::chart2::data::XLabeledDataSequence > xCategSeq );
886 /** Creates a legend object and converts all legend settings. */
887 void ConvertLegend( const ScfPropertySet& rPropSet );
889 /** Returns true, if this chart type group contains at least one valid series. */
890 inline bool IsValidGroup() const { return !maSeries.IsEmpty() && maType.IsValidType(); }
891 /** Returns the index of this chart type group format. */
892 inline sal_uInt16 GetGroupIdx() const { return maData.mnGroupIdx; }
893 /** Returns the chart type info struct for the contained chart type. */
894 inline const XclChExtTypeInfo& GetTypeInfo() const { return maTypeInfo; }
895 /** Returns true, if the chart is three-dimensional. */
896 inline bool Is3dChart() const { return maTypeInfo.mb3dChart; }
897 /** Returns true, if chart type supports wall and floor format. */
898 inline bool Is3dWallChart() const { return Is3dChart() && (maTypeInfo.meTypeCateg != EXC_CHTYPECATEG_PIE); }
899 /** Returns true, if the series in this chart type group are ordered on the Z axis. */
900 inline bool Is3dDeepChart() const { return Is3dWallChart() && mxChart3d && !mxChart3d->IsClustered(); }
901 /** Returns true, if this chart type can be combined with other types. */
902 inline bool IsCombinable2d() const { return !Is3dChart() && maTypeInfo.mbCombinable2d; }
904 /** Writes all embedded records. */
905 virtual void WriteSubRecords( XclExpStream& rStrm ) override;
907 private:
908 /** Returns an unused format index to be used for the next created series. */
909 sal_uInt16 GetFreeFormatIdx() const;
910 /** Creates all data series of any chart type except stock charts. */
911 void CreateDataSeries( css::uno::Reference< css::chart2::XDiagram > xDiagram,
912 css::uno::Reference< css::chart2::XDataSeries > xDataSeries );
913 /** Creates all data series of a stock chart. */
914 void CreateAllStockSeries( css::uno::Reference< css::chart2::XChartType > xChartType,
915 css::uno::Reference< css::chart2::XDataSeries > xDataSeries );
916 /** Creates a single data series of a stock chart. */
917 bool CreateStockSeries( css::uno::Reference< css::chart2::XDataSeries > xDataSeries,
918 const OUString& rValueRole, bool bCloseSymbol );
920 virtual void WriteBody( XclExpStream& rStrm ) override;
922 private:
923 typedef XclExpRecordList< XclExpChSeries > XclExpChSeriesList;
924 typedef ::std::map<sal_uInt16, std::unique_ptr<XclExpChLineFormat>> XclExpChLineFormatMap;
926 XclChTypeGroup maData; /// Contents of the CHTYPEGROUP record.
927 XclExpChType maType; /// Chart type (e.g. CHBAR, CHLINE, ...).
928 XclChExtTypeInfo maTypeInfo; /// Extended chart type info.
929 XclExpChSeriesList maSeries; /// List of series data (CHSERIES groups).
930 XclExpChChart3dRef mxChart3d; /// 3D settings (CHCHART3D record).
931 XclExpChLegendRef mxLegend; /// Chart legend (CHLEGEND group).
932 XclExpChDropBarRef mxUpBar; /// White dropbars (CHDROPBAR group).
933 XclExpChDropBarRef mxDownBar; /// Black dropbars (CHDROPBAR group).
934 XclExpChLineFormatMap m_ChartLines; /// Global line formats (CHCHARTLINE group).
937 typedef std::shared_ptr< XclExpChTypeGroup > XclExpChTypeGroupRef;
939 // Axes =======================================================================
941 class XclExpChLabelRange : public XclExpRecord, protected XclExpChRoot
943 public:
944 explicit XclExpChLabelRange( const XclExpChRoot& rRoot );
946 /** Converts category axis scaling settings. */
947 void Convert( const css::chart2::ScaleData& rScaleData,
948 const ScfPropertySet& rChart1Axis, bool bMirrorOrient );
949 /** Converts position settings of a crossing axis at this axis. */
950 void ConvertAxisPosition( const ScfPropertySet& rPropSet );
951 /** Sets flag for tickmark position between categories or on categories. */
952 inline void SetTicksBetweenCateg( bool bTicksBetween )
953 { ::set_flag( maLabelData.mnFlags, EXC_CHLABELRANGE_BETWEEN, bTicksBetween ); }
955 private:
956 virtual void Save( XclExpStream& rStrm ) override;
957 virtual void WriteBody( XclExpStream& rStrm ) override;
959 private:
960 XclChLabelRange maLabelData; /// Contents of the CHLABELRANGE record.
961 XclChDateRange maDateData; /// Contents of the CHDATERANGE record.
964 typedef std::shared_ptr< XclExpChLabelRange > XclExpChLabelRangeRef;
966 class XclExpChValueRange : public XclExpRecord, protected XclExpChRoot
968 public:
969 explicit XclExpChValueRange( const XclExpChRoot& rRoot );
971 /** Converts value axis scaling settings. */
972 void Convert( const css::chart2::ScaleData& rScaleData );
973 /** Converts position settings of a crossing axis at this axis. */
974 void ConvertAxisPosition( const ScfPropertySet& rPropSet );
976 private:
977 virtual void WriteBody( XclExpStream& rStrm ) override;
979 private:
980 XclChValueRange maData; /// Contents of the CHVALUERANGE record.
983 typedef std::shared_ptr< XclExpChValueRange > XclExpChValueRangeRef;
985 class XclExpChTick : public XclExpRecord, protected XclExpChRoot
987 public:
988 explicit XclExpChTick( const XclExpChRoot& rRoot );
990 /** Converts axis tick mark settings. */
991 void Convert( const ScfPropertySet& rPropSet, const XclChExtTypeInfo& rTypeInfo, sal_uInt16 nAxisType );
992 /** Sets font color and color identifier to internal data structures. */
993 void SetFontColor( const Color& rColor, sal_uInt32 nColorId );
994 /** Sets text rotation to internal data structures. */
995 void SetRotation( sal_uInt16 nRotation );
997 private:
998 virtual void WriteBody( XclExpStream& rStrm ) override;
1000 private:
1001 XclChTick maData; /// Contents of the CHTICK record.
1002 sal_uInt32 mnTextColorId; /// Axis labels text color identifier.
1005 typedef std::shared_ptr< XclExpChTick > XclExpChTickRef;
1007 /** Represents the CHAXIS record group describing an entire chart axis.
1009 The CHAXIS group consists of: CHAXIS, CHBEGIN, CHLABELRANGE, CHEXTRANGE,
1010 CHVALUERANGE, CHFORMAT, CHTICK, CHFONT, CHAXISLINE groups (CHAXISLINE with
1011 CHLINEFORMAT, CHAREAFORMAT, and CHESCHERFORMAT group), CHEND.
1013 class XclExpChAxis : public XclExpChGroupBase, public XclExpChFontBase
1015 public:
1016 explicit XclExpChAxis( const XclExpChRoot& rRoot, sal_uInt16 nAxisType );
1018 /** Sets font color and color identifier to internal data structures. */
1019 virtual void SetFont( XclExpChFontRef xFont, const Color& rColor, sal_uInt32 nColorId ) override;
1020 /** Sets text rotation to internal data structures. */
1021 virtual void SetRotation( sal_uInt16 nRotation ) override;
1023 /** Converts formatting and scaling settings from the passed axis. */
1024 void Convert( css::uno::Reference< css::chart2::XAxis > xAxis,
1025 css::uno::Reference< css::chart2::XAxis > xCrossingAxis,
1026 css::uno::Reference< css::chart::XAxis > xChart1Axis,
1027 const XclChExtTypeInfo& rTypeInfo );
1028 /** Converts and writes 3D wall/floor properties from the passed diagram. */
1029 void ConvertWall( css::uno::Reference< css::chart2::XDiagram > xDiagram );
1031 /** Returns the type of this axis. */
1032 inline sal_uInt16 GetAxisType() const { return maData.mnType; }
1033 /** Returns the axis dimension index used by the chart API. */
1034 inline sal_Int32 GetApiAxisDimension() const { return maData.GetApiAxisDimension(); }
1036 /** Writes all embedded records. */
1037 virtual void WriteSubRecords( XclExpStream& rStrm ) override;
1039 private:
1040 virtual void WriteBody( XclExpStream& rStrm ) override;
1042 private:
1043 XclChAxis maData; /// Contents of the CHAXIS record.
1044 XclExpChLabelRangeRef mxLabelRange; /// Category scaling (CHLABELRANGE record).
1045 XclExpChValueRangeRef mxValueRange; /// Value scaling (CHVALUERANGE record).
1046 XclExpChTickRef mxTick; /// Axis ticks (CHTICK record).
1047 XclExpChFontRef mxFont; /// Index into font buffer (CHFONT record).
1048 XclExpChLineFormatRef mxAxisLine; /// Axis line format (CHLINEFORMAT record).
1049 XclExpChLineFormatRef mxMajorGrid; /// Major grid line format (CHLINEFORMAT record).
1050 XclExpChLineFormatRef mxMinorGrid; /// Minor grid line format (CHLINEFORMAT record).
1051 XclExpChFrameRef mxWallFrame; /// Wall/floor format (sub records of CHFRAME group).
1052 sal_uInt16 mnNumFmtIdx; /// Index into number format buffer (CHFORMAT record).
1055 typedef std::shared_ptr< XclExpChAxis > XclExpChAxisRef;
1057 /** Represents the CHAXESSET record group describing an axes set (X/Y/Z axes).
1059 The CHAXESSET group consists of: CHAXESSET, CHBEGIN, CHFRAMEPOS, CHAXIS
1060 groups, CHTEXT groups, CHPLOTFRAME group (CHPLOTFRAME with CHFRAME group),
1061 CHTYPEGROUP group, CHEND.
1063 class XclExpChAxesSet : public XclExpChGroupBase
1065 public:
1066 explicit XclExpChAxesSet( const XclExpChRoot& rRoot, sal_uInt16 nAxesSetId );
1068 /** Converts the passed diagram to chart record data.
1069 @return First unused chart type group index. */
1070 sal_uInt16 Convert( css::uno::Reference< css::chart2::XDiagram > xDiagram,
1071 sal_uInt16 nFirstGroupIdx );
1073 /** Returns true, if this axes set exists (returns false if this is a dummy object). */
1074 inline bool IsValidAxesSet() const { return !maTypeGroups.IsEmpty(); }
1075 /** Returns the index of the axes set (primary/secondary). */
1076 inline sal_uInt16 GetAxesSetId() const { return maData.mnAxesSetId; }
1077 /** Returns the axes set index used by the chart API. */
1078 inline sal_Int32 GetApiAxesSetIndex() const { return maData.GetApiAxesSetIndex(); }
1079 /** Returns true, if the chart is three-dimensional. */
1080 bool Is3dChart() const;
1082 /** Writes all embedded records. */
1083 virtual void WriteSubRecords( XclExpStream& rStrm ) override;
1085 private:
1086 /** Returns first inserted chart type group. */
1087 XclExpChTypeGroupRef GetFirstTypeGroup() const;
1088 /** Returns last inserted chart type group. */
1089 XclExpChTypeGroupRef GetLastTypeGroup() const;
1091 /** Converts a complete axis object including axis title. */
1092 void ConvertAxis( XclExpChAxisRef& rxChAxis, sal_uInt16 nAxisType,
1093 XclExpChTextRef& rxChAxisTitle, sal_uInt16 nTitleTarget,
1094 css::uno::Reference< css::chart2::XCoordinateSystem > xCoordSystem,
1095 const XclChExtTypeInfo& rTypeInfo,
1096 sal_Int32 nCrossingAxisDim );
1098 virtual void WriteBody( XclExpStream& rStrm ) override;
1100 private:
1101 typedef XclExpRecordList< XclExpChTypeGroup > XclExpChTypeGroupList;
1103 XclChAxesSet maData; /// Contents of the CHAXESSET record.
1104 XclExpChFramePosRef mxFramePos; /// Outer plot area position (CHFRAMEPOS record).
1105 XclExpChAxisRef mxXAxis; /// The X axis (CHAXIS group).
1106 XclExpChAxisRef mxYAxis; /// The Y axis (CHAXIS group).
1107 XclExpChAxisRef mxZAxis; /// The Z axis (CHAXIS group).
1108 XclExpChTextRef mxXAxisTitle; /// The X axis title (CHTEXT group).
1109 XclExpChTextRef mxYAxisTitle; /// The Y axis title (CHTEXT group).
1110 XclExpChTextRef mxZAxisTitle; /// The Z axis title (CHTEXT group).
1111 XclExpChFrameRef mxPlotFrame; /// Plot area (CHPLOTFRAME group).
1112 XclExpChTypeGroupList maTypeGroups; /// Chart type groups (CHTYPEGROUP group).
1115 typedef std::shared_ptr< XclExpChAxesSet > XclExpChAxesSetRef;
1117 // The chart object ===========================================================
1119 /** Represents the CHCHART record group describing the chart contents.
1121 The CHCHART group consists of: CHCHART, CHBEGIN, SCL, CHPLOTGROWTH, CHFRAME
1122 group, CHSERIES groups, CHPROPERTIES, CHDEFAULTTEXT groups (CHDEFAULTTEXT
1123 with CHTEXT groups), CHUSEDAXESSETS, CHAXESSET groups, CHTEXT groups, CHEND.
1125 class XclExpChChart : public XclExpChGroupBase
1127 public:
1128 explicit XclExpChChart( const XclExpRoot& rRoot,
1129 css::uno::Reference< css::chart2::XChartDocument > xChartDoc,
1130 const Rectangle& rChartRect );
1132 /** Creates, registers and returns a new data series object. */
1133 XclExpChSeriesRef CreateSeries();
1134 /** Removes the last created data series object from the series list. */
1135 void RemoveLastSeries();
1136 /** Stores a CHTEXT group that describes a data point label. */
1137 void SetDataLabel( XclExpChTextRef xText );
1138 /** Sets the plot area position and size to manual mode. */
1139 void SetManualPlotArea();
1141 /** Writes all embedded records. */
1142 virtual void WriteSubRecords( XclExpStream& rStrm ) override;
1144 private:
1145 virtual void WriteBody( XclExpStream& rStrm ) override;
1147 private:
1148 typedef XclExpRecordList< XclExpChSeries > XclExpChSeriesList;
1149 typedef XclExpRecordList< XclExpChText > XclExpChTextList;
1151 XclChRectangle maRect; /// Position of the chart on the sheet (CHCHART record).
1152 XclExpChSeriesList maSeries; /// List of series data (CHSERIES groups).
1153 XclExpChFrameRef mxFrame; /// Chart frame format (CHFRAME group).
1154 XclChProperties maProps; /// Chart properties (CHPROPERTIES record).
1155 XclExpChAxesSetRef mxPrimAxesSet; /// Primary axes set (CHAXESSET group).
1156 XclExpChAxesSetRef mxSecnAxesSet; /// Secondary axes set (CHAXESSET group).
1157 XclExpChTextRef mxTitle; /// Chart title (CHTEXT group).
1158 XclExpChTextList maLabels; /// Data point labels (CHTEXT groups).
1161 /** Represents the group of DFF and OBJ records containing all drawing shapes
1162 embedded in the chart object.
1164 class XclExpChartDrawing : public XclExpRecordBase, protected XclExpRoot
1166 public:
1167 explicit XclExpChartDrawing(
1168 const XclExpRoot& rRoot,
1169 const css::uno::Reference< css::frame::XModel >& rxModel,
1170 const Size& rChartSize );
1171 virtual ~XclExpChartDrawing();
1173 virtual void Save( XclExpStream& rStrm ) override;
1175 private:
1176 std::shared_ptr< XclExpObjectManager > mxObjMgr;
1177 std::shared_ptr< XclExpRecordBase > mxObjRecs;
1180 /** Represents the entire chart substream (all records in BOF/EOF block). */
1181 class XclExpChart : public XclExpSubStream, protected XclExpRoot
1183 public:
1184 explicit XclExpChart( const XclExpRoot& rRoot,
1185 css::uno::Reference< css::frame::XModel > xModel,
1186 const Rectangle& rChartRect );
1189 #endif
1191 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */