Version 7.5.1.1, tag libreoffice-7.5.1.1
[LibreOffice.git] / sc / source / filter / inc / xechart.hxx
blobff7dcc90920f80e57ff8f147c0d0711bf4845a3d
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 #pragma once
22 #include "xerecord.hxx"
23 #include "xlchart.hxx"
24 #include "xlformula.hxx"
25 #include "xlstyle.hxx"
26 #include "xeroot.hxx"
27 #include "xestring.hxx"
29 #include <memory>
30 #include <map>
32 class Size;
33 namespace tools { class Rectangle; }
35 namespace com::sun::star {
36 namespace awt
38 struct Rectangle;
40 namespace frame
42 class XModel;
44 namespace chart
46 class XAxis;
48 namespace chart2
50 struct ScaleData;
51 class XChartDocument;
52 class XDiagram;
53 class XCoordinateSystem;
54 class XChartType;
55 class XDataSeries;
56 class XAxis;
57 class XTitle;
58 class XFormattedString;
59 class XRegressionCurve;
60 namespace data
62 class XDataSequence;
63 class XLabeledDataSequence;
68 // Common =====================================================================
70 struct XclExpChRootData;
71 class XclExpChChart;
73 /** Base class for complex chart classes, provides access to other components
74 of the chart.
76 Keeps also track of future record levels and writes the needed future
77 records on demand.
79 class XclExpChRoot : public XclExpRoot
81 public:
82 explicit XclExpChRoot( const XclExpRoot& rRoot, XclExpChChart& rChartData );
83 virtual ~XclExpChRoot() override;
85 XclExpChRoot(XclExpChRoot const &) = default;
86 XclExpChRoot(XclExpChRoot &&) = default;
87 XclExpChRoot & operator =(XclExpChRoot const &) = delete; // due to XclExpRoot
88 XclExpChRoot & operator =(XclExpChRoot &&) = delete; // due to XclExpRoot
90 /** Returns this root instance - for code readability in derived classes. */
91 const XclExpChRoot& GetChRoot() const { return *this; }
92 /** Returns the API Chart document model. */
93 css::uno::Reference< css::chart2::XChartDocument > const &
94 GetChartDocument() const;
95 /** Returns a reference to the parent chart data object. */
96 XclExpChChart& GetChartData() const;
97 /** Returns chart type info for a unique chart type identifier. */
98 const XclChTypeInfo& GetChartTypeInfo( XclChTypeId eType ) const;
99 /** Returns the first fitting chart type info for the passed service name. */
100 const XclChTypeInfo& GetChartTypeInfo( std::u16string_view rServiceName ) const;
102 /** Returns an info struct about auto formatting for the passed object type. */
103 const XclChFormatInfo& GetFormatInfo( XclChObjectType eObjType ) const;
105 /** Starts the API chart document conversion. Must be called once before all API conversion. */
106 void InitConversion( css::uno::Reference< css::chart2::XChartDocument > const & xChartDoc,
107 const tools::Rectangle& rChartRect ) const;
108 /** Finishes the API chart document conversion. Must be called once after all API conversion. */
109 void FinishConversion() const;
111 /** Returns true, if the passed color equals to the specified system color. */
112 bool IsSystemColor( const Color& rColor, sal_uInt16 nSysColorIdx ) const;
113 /** Sets a system color and the respective color identifier. */
114 void SetSystemColor( Color& rColor, sal_uInt32& rnColorId, sal_uInt16 nSysColorIdx ) const;
116 /** Converts the passed horizontal coordinate from 1/100 mm to Excel chart units. */
117 sal_Int32 CalcChartXFromHmm( sal_Int32 nPosX ) const;
118 /** Converts the passed vertical coordinate from 1/100 mm to Excel chart units. */
119 sal_Int32 CalcChartYFromHmm( sal_Int32 nPosY ) const;
120 /** Converts the passed rectangle from 1/100 mm to Excel chart units. */
121 XclChRectangle CalcChartRectFromHmm( const css::awt::Rectangle& rRect ) const;
123 /** Reads all line properties from the passed property set. */
124 void ConvertLineFormat(
125 XclChLineFormat& rLineFmt,
126 const ScfPropertySet& rPropSet,
127 XclChPropertyMode ePropMode ) const;
128 /** Reads solid area properties from the passed property set.
129 @return true = object contains complex fill properties. */
130 bool ConvertAreaFormat(
131 XclChAreaFormat& rAreaFmt,
132 const ScfPropertySet& rPropSet,
133 XclChPropertyMode ePropMode ) const;
134 /** Reads gradient or bitmap area properties from the passed property set. */
135 void ConvertEscherFormat(
136 XclChEscherFormat& rEscherFmt,
137 XclChPicFormat& rPicFmt,
138 const ScfPropertySet& rPropSet,
139 XclChPropertyMode ePropMode ) const;
140 /** Reads font properties from the passed property set. */
141 sal_uInt16 ConvertFont(
142 const ScfPropertySet& rPropSet,
143 sal_Int16 nScript ) const;
145 /** Reads the pie rotation property and returns the converted angle. */
146 static sal_uInt16 ConvertPieRotation( const ScfPropertySet& rPropSet );
148 protected:
149 /** Called from XclExpChGroupBase::Save, registers a new future record level. */
150 void RegisterFutureRecBlock( const XclChFrBlock& rFrBlock );
151 /** Called from XclExpChFutureRecordBase::Save, Initializes the current future record level. */
152 void InitializeFutureRecBlock( XclExpStream& rStrm );
153 /** Called from XclExpChGroupBase::Save, finalizes the current future record level. */
154 void FinalizeFutureRecBlock( XclExpStream& rStrm );
156 private:
157 typedef std::shared_ptr< XclExpChRootData > XclExpChRootDataRef;
158 XclExpChRootDataRef mxChData; /// Reference to the root data object.
161 /** Base class for chart record groups. Provides helper functions to write sub records.
163 A chart record group consists of a header record, followed by a CHBEGIN
164 record, followed by group sub records, and finished with a CHEND record.
166 class XclExpChGroupBase : public XclExpRecord, protected XclExpChRoot
168 public:
169 explicit XclExpChGroupBase(
170 const XclExpChRoot& rRoot, sal_uInt16 nFrType,
171 sal_uInt16 nRecId, std::size_t nRecSize = 0 );
172 virtual ~XclExpChGroupBase() override;
174 /** Saves the header record. Calls WriteSubRecords() to let derived classes write sub records. */
175 virtual void Save( XclExpStream& rStrm ) override;
176 /** Derived classes return whether there are any records embedded in this group. */
177 virtual bool HasSubRecords() const;
178 /** Derived classes implement writing any records embedded in this group. */
179 virtual void WriteSubRecords( XclExpStream& rStrm ) = 0;
181 protected:
182 /** Sets context information for future record blocks. */
183 void SetFutureRecordContext( sal_uInt16 nFrContext,
184 sal_uInt16 nFrValue1 = 0, sal_uInt16 nFrValue2 = 0 );
186 private:
187 XclChFrBlock maFrBlock; /// Future records block settings.
190 /** Base class for chart future records. On saving, the record writes missing
191 CHFRBLOCKBEGIN records automatically.
193 class XclExpChFutureRecordBase : public XclExpFutureRecord, protected XclExpChRoot
195 public:
196 explicit XclExpChFutureRecordBase( const XclExpChRoot& rRoot,
197 XclFutureRecType eRecType, sal_uInt16 nRecId, std::size_t nRecSize );
199 /** Writes missing CHFRBLOCKBEGIN records and this record. */
200 virtual void Save( XclExpStream& rStrm ) override;
203 // Frame formatting ===========================================================
205 class XclExpChFramePos : public XclExpRecord
207 public:
208 explicit XclExpChFramePos( sal_uInt16 nTLMode );
210 /** Returns read/write access to the frame position data. */
211 XclChFramePos& GetFramePosData() { return maData; }
213 private:
214 virtual void WriteBody( XclExpStream& rStrm ) override;
216 private:
217 XclChFramePos maData; /// Position of the frame.
220 typedef rtl::Reference< XclExpChFramePos > XclExpChFramePosRef;
222 class XclExpChLineFormat : public XclExpRecord
224 public:
225 explicit XclExpChLineFormat( const XclExpChRoot& rRoot );
227 /** Converts line formatting properties from the passed property set. */
228 void Convert( const XclExpChRoot& rRoot,
229 const ScfPropertySet& rPropSet, XclChObjectType eObjType );
230 /** Sets or clears the automatic flag. */
231 void SetAuto( bool bAuto ) { ::set_flag( maData.mnFlags, EXC_CHLINEFORMAT_AUTO, bAuto ); }
232 /** Sets flag to show or hide an axis. */
233 void SetShowAxis( bool bShowAxis )
234 { ::set_flag( maData.mnFlags, EXC_CHLINEFORMAT_SHOWAXIS, bShowAxis ); }
235 /** Sets the line format to the specified default type. */
236 void SetDefault( XclChFrameType eDefFrameType );
238 /** Returns true, if the line format is set to automatic. */
239 bool IsAuto() const { return ::get_flag( maData.mnFlags, EXC_CHLINEFORMAT_AUTO ); }
240 /** Returns true, if the line style is set to something visible. */
241 bool HasLine() const { return maData.mnPattern != EXC_CHLINEFORMAT_NONE; }
242 /** Returns true, if the line contains default formatting according to the passed frame type. */
243 bool IsDefault( XclChFrameType eDefFrameType ) const;
245 private:
246 virtual void WriteBody( XclExpStream& rStrm ) override;
248 private:
249 XclChLineFormat maData; /// Contents of the CHLINEFORMAT record.
250 sal_uInt32 mnColorId; /// Line color identifier.
253 typedef rtl::Reference< XclExpChLineFormat > XclExpChLineFormatRef;
255 class XclExpChAreaFormat : public XclExpRecord
257 public:
258 explicit XclExpChAreaFormat( const XclExpChRoot& rRoot );
260 /** Converts area formatting properties from the passed property set.
261 @return true = object contains complex fill properties. */
262 bool Convert( const XclExpChRoot& rRoot,
263 const ScfPropertySet& rPropSet, XclChObjectType eObjType );
264 /** Sets or clears the automatic flag. */
265 void SetAuto( bool bAuto ) { ::set_flag( maData.mnFlags, EXC_CHAREAFORMAT_AUTO, bAuto ); }
266 /** Sets the area format to the specified default type. */
267 void SetDefault( XclChFrameType eDefFrameType );
269 /** Returns true, if the area format is set to automatic. */
270 bool IsAuto() const { return ::get_flag( maData.mnFlags, EXC_CHAREAFORMAT_AUTO ); }
271 /** Returns true, if the area style is set to something visible. */
272 bool HasArea() const { return maData.mnPattern != EXC_PATT_NONE; }
273 /** Returns true, if the area contains default formatting according to the passed frame type. */
274 bool IsDefault( XclChFrameType eDefFrameType ) const;
276 private:
277 virtual void WriteBody( XclExpStream& rStrm ) override;
279 private:
280 XclChAreaFormat maData; /// Contents of the CHAREAFORMAT record.
281 sal_uInt32 mnPattColorId; /// Pattern color identifier.
282 sal_uInt32 mnBackColorId; /// Pattern background color identifier.
285 typedef rtl::Reference< XclExpChAreaFormat > XclExpChAreaFormatRef;
287 class XclExpChEscherFormat : public XclExpChGroupBase
289 public:
290 explicit XclExpChEscherFormat( const XclExpChRoot& rRoot );
292 /** Converts complex area formatting from the passed property set. */
293 void Convert( const ScfPropertySet& rPropSet, XclChObjectType eObjType );
295 /** Returns true, if the object contains valid formatting data. */
296 bool IsValid() const;
298 /** Writes the CHESCHERFORMAT record group to the stream, if complex formatting is extant. */
299 virtual void Save( XclExpStream& rStrm ) override;
300 /** Returns true, if this record group contains a CHPICFORMAT record. */
301 virtual bool HasSubRecords() const override;
302 /** Writes all embedded records. */
303 virtual void WriteSubRecords( XclExpStream& rStrm ) override;
305 private:
306 /** Inserts a color from the contained Escher property set into the color palette. */
307 sal_uInt32 RegisterColor( sal_uInt16 nPropId );
309 virtual void WriteBody( XclExpStream& rStrm ) override;
311 private:
312 XclChEscherFormat maData; /// Fill properties for complex areas (CHESCHERFORMAT record).
313 XclChPicFormat maPicFmt; /// Image options, e.g. stretched, stacked (CHPICFORMAT record).
314 sal_uInt32 mnColor1Id; /// First fill color identifier.
315 sal_uInt32 mnColor2Id; /// Second fill color identifier.
318 typedef rtl::Reference< XclExpChEscherFormat > XclExpChEscherFormatRef;
320 /** Base class for record groups containing frame formatting.
322 Frame formatting can be part of several record groups, e.g. CHFRAME,
323 CHDATAFORMAT, CHDROPBAR. It consists of CHLINEFORMAT, CHAREAFORMAT, and
324 CHESCHERFORMAT group.
326 class XclExpChFrameBase
328 public:
329 explicit XclExpChFrameBase();
330 virtual ~XclExpChFrameBase();
332 protected:
333 /** Converts frame formatting properties from the passed property set. */
334 void ConvertFrameBase( const XclExpChRoot& rRoot,
335 const ScfPropertySet& rPropSet, XclChObjectType eObjType );
336 /** Sets the frame formatting to the specified default type. */
337 void SetDefaultFrameBase( const XclExpChRoot& rRoot,
338 XclChFrameType eDefFrameType, bool bIsFrame );
340 /** Returns true, if the frame contains default formatting (as if the frame is missing). */
341 bool IsDefaultFrameBase( XclChFrameType eDefFrameType ) const;
343 /** Writes all contained frame records to the passed stream. */
344 void WriteFrameRecords( XclExpStream& rStrm );
346 private:
347 XclExpChLineFormatRef mxLineFmt; /// Line format (CHLINEFORMAT record).
348 XclExpChAreaFormatRef mxAreaFmt; /// Area format (CHAREAFORMAT record).
349 XclExpChEscherFormatRef 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 XclExpChFrame : public XclExpChGroupBase, public XclExpChFrameBase
359 public:
360 explicit XclExpChFrame( const XclExpChRoot& rRoot, XclChObjectType eObjType );
362 /** Converts frame formatting properties from the passed property set. */
363 void Convert( const ScfPropertySet& rPropSet );
364 /** Sets the specified automatic flags. */
365 void SetAutoFlags( bool bAutoPos, bool bAutoSize );
367 /** Returns true, if the frame object contains default formats. */
368 bool IsDefault() const;
369 /** Returns true, if the frame object can be deleted because it contains default formats. */
370 bool IsDeleteable() const;
372 /** Writes the entire record group. */
373 virtual void Save( XclExpStream& rStrm ) override;
374 /** Writes all embedded records. */
375 virtual void WriteSubRecords( XclExpStream& rStrm ) override;
377 private:
378 virtual void WriteBody( XclExpStream& rStrm ) override;
380 private:
381 XclChFrame maData; /// Contents of the CHFRAME record.
382 XclChObjectType meObjType; /// Type of the represented object.
385 typedef rtl::Reference< XclExpChFrame > XclExpChFrameRef;
387 // Source links ===============================================================
389 class XclExpChSourceLink : public XclExpRecord, protected XclExpChRoot
391 public:
392 explicit XclExpChSourceLink( const XclExpChRoot& rRoot, sal_uInt8 nDestType );
394 void ConvertString( const OUString& aString );
395 /** Converts the passed source link, returns the number of linked values. */
396 sal_uInt16 ConvertDataSequence( css::uno::Reference< css::chart2::data::XDataSequence > const & xDataSeq,
397 bool bSplitToColumns, sal_uInt16 nDefCount = 0 );
398 /** Converts the passed sequence of formatted string objects, returns leading font index. */
399 sal_uInt16 ConvertStringSequence( const css::uno::Sequence< css::uno::Reference< css::chart2::XFormattedString > >& rStringSeq );
400 /** Converts the number format from the passed property set. */
401 void ConvertNumFmt( const ScfPropertySet& rPropSet, bool bPercent );
403 void AppendString( std::u16string_view rStr );
405 /** Returns true, if this source link contains explicit string data. */
406 bool HasString() const { return mxString && !mxString->IsEmpty(); }
408 /** Writes the CHSOURCELINK record and optionally a CHSTRING record with explicit string data. */
409 virtual void Save( XclExpStream& rStrm ) override;
411 private:
412 virtual void WriteBody( XclExpStream& rStrm ) override;
414 private:
415 XclChSourceLink maData; /// Contents of the CHSOURCELINK record.
416 XclTokenArrayRef mxLinkFmla; /// Formula with link to source data.
417 XclExpStringRef mxString; /// Text data (CHSTRING record).
420 typedef rtl::Reference< XclExpChSourceLink > XclExpChSourceLinkRef;
422 // Text =======================================================================
424 /** The CHFONT record containing a font index for text objects. */
425 class XclExpChFont : public XclExpUInt16Record
427 public:
428 explicit XclExpChFont( sal_uInt16 nFontIdx );
431 typedef rtl::Reference< XclExpChFont > XclExpChFontRef;
433 /** The CHOBJECTLINK record linking a text object to a specific chart object. */
434 class XclExpChObjectLink : public XclExpRecord
436 public:
437 explicit XclExpChObjectLink( sal_uInt16 nLinkTarget, const XclChDataPointPos& rPointPos );
439 private:
440 virtual void WriteBody( XclExpStream& rStrm ) override;
442 private:
443 XclChObjectLink maData; /// Contents of the CHOBJECTLINK record.
446 typedef rtl::Reference< XclExpChObjectLink > XclExpChObjectLinkRef;
448 /** Additional data label settings in the future record CHFRLABELPROPS. */
449 class XclExpChFrLabelProps : public XclExpChFutureRecordBase
451 public:
452 explicit XclExpChFrLabelProps( const XclExpChRoot& rRoot );
454 /** Converts separator and the passed data label flags. */
455 void Convert(
456 const ScfPropertySet& rPropSet,
457 bool bShowCateg, bool bShowValue,
458 bool bShowPercent, bool bShowBubble );
460 private:
461 virtual void WriteBody( XclExpStream& rStrm ) override;
463 private:
464 XclChFrLabelProps maData; /// Contents of the CHFRLABELPROPS record.
467 typedef rtl::Reference< XclExpChFrLabelProps > XclExpChFrLabelPropsRef;
469 /** Base class for objects with font settings. Provides font conversion helper functions. */
470 class XclExpChFontBase
472 public:
473 virtual ~XclExpChFontBase();
475 /** Derived classes set font color and color identifier to internal data structures. */
476 virtual void SetFont( XclExpChFontRef xFont, const Color& rColor, sal_uInt32 nColorId ) = 0;
477 /** Derived classes set text rotation to internal data structures. */
478 virtual void SetRotation( sal_uInt16 nRotation ) = 0;
480 /** Creates a CHFONT record from the passed font index, calls virtual function SetFont(). */
481 void ConvertFontBase( const XclExpChRoot& rRoot, sal_uInt16 nFontIdx );
482 /** Creates a CHFONT record from the passed font index, calls virtual function SetFont(). */
483 void ConvertFontBase( const XclExpChRoot& rRoot, const ScfPropertySet& rPropSet );
484 /** Converts rotation settings, calls virtual function SetRotation(). */
485 void ConvertRotationBase( const ScfPropertySet& rPropSet, bool bSupportsStacked );
488 /** Represents the CHTEXT record group containing text object properties.
490 The CHTEXT group consists of: CHTEXT, CHBEGIN, CHFRAMEPOS, CHFONT,
491 CHFORMATRUNS, CHSOURCELINK, CHSTRING, CHFRAME group, CHOBJECTLINK, and CHEND.
493 class XclExpChText : public XclExpChGroupBase, public XclExpChFontBase
495 public:
496 explicit XclExpChText( const XclExpChRoot& rRoot );
498 /** Sets font color and color identifier to internal data structures. */
499 virtual void SetFont( XclExpChFontRef xFont, const Color& rColor, sal_uInt32 nColorId ) override;
500 /** Sets text rotation to internal data structures. */
501 virtual void SetRotation( sal_uInt16 nRotation ) override;
503 /** Converts all text settings of the passed title text object. */
504 void ConvertTitle( css::uno::Reference< css::chart2::XTitle > const & xTitle, sal_uInt16 nTarget, const OUString* pSubTitle );
505 /** Converts all text settings of the passed legend. */
506 void ConvertLegend( const ScfPropertySet& rPropSet );
507 /** Converts all settings of the passed data point caption text object. */
508 bool ConvertDataLabel( const ScfPropertySet& rPropSet,
509 const XclChTypeInfo& rTypeInfo, const XclChDataPointPos& rPointPos );
510 /** Converts all settings of the passed trend line equation box. */
511 void ConvertTrendLineEquation( const ScfPropertySet& rPropSet, const XclChDataPointPos& rPointPos );
513 /** Returns true, if the string object does not contain any text data. */
514 bool HasString() const { return mxSrcLink && mxSrcLink->HasString(); }
515 /** Returns the flags needed for the CHATTACHEDLABEL record. */
516 sal_uInt16 GetAttLabelFlags() const;
518 /** Writes all embedded records. */
519 virtual void WriteSubRecords( XclExpStream& rStrm ) override;
521 private:
522 virtual void WriteBody( XclExpStream& rStrm ) override;
524 private:
525 XclChText maData; /// Contents of the CHTEXT record.
526 XclExpChFramePosRef mxFramePos; /// Relative text frame position (CHFRAMEPOS record).
527 XclExpChSourceLinkRef mxSrcLink; /// Linked data (CHSOURCELINK with CHSTRING record).
528 XclExpChFrameRef mxFrame; /// Text object frame properties (CHFRAME group).
529 XclExpChFontRef mxFont; /// Index into font buffer (CHFONT record).
530 XclExpChObjectLinkRef mxObjLink; /// Link target for this text object.
531 XclExpChFrLabelPropsRef mxLabelProps; /// Extended data label properties (CHFRLABELPROPS record).
532 sal_uInt32 mnTextColorId; /// Text color identifier.
535 typedef rtl::Reference< XclExpChText > XclExpChTextRef;
537 // Data series ================================================================
539 /** The CHMARKERFORMAT record containing data point marker formatting data. */
540 class XclExpChMarkerFormat : public XclExpRecord
542 public:
543 explicit XclExpChMarkerFormat( const XclExpChRoot& rRoot );
545 /** Converts symbol properties from the passed property set. */
546 void Convert( const XclExpChRoot& rRoot,
547 const ScfPropertySet& rPropSet, sal_uInt16 nFormatIdx );
548 /** Converts symbol properties for stock charts from the passed property set. */
549 void ConvertStockSymbol( const XclExpChRoot& rRoot,
550 const ScfPropertySet& rPropSet, bool bCloseSymbol );
552 /** Returns true, if markers are enabled. */
553 bool HasMarker() const { return maData.mnMarkerType != EXC_CHMARKERFORMAT_NOSYMBOL; }
554 /** Returns true, if border line of markers is visible. */
555 bool HasLineColor() const { return !::get_flag( maData.mnFlags, EXC_CHMARKERFORMAT_NOLINE ); }
556 /** Returns true, if fill area of markers is visible. */
557 bool HasFillColor() const { return !::get_flag( maData.mnFlags, EXC_CHMARKERFORMAT_NOFILL ); }
559 private:
560 /** Registers marker colors in palette and stores color identifiers. */
561 void RegisterColors( const XclExpChRoot& rRoot );
563 virtual void WriteBody( XclExpStream& rStrm ) override;
565 private:
566 XclChMarkerFormat maData; /// Contents of the CHMARKERFORMAT record.
567 sal_uInt32 mnLineColorId; /// Border line color identifier.
568 sal_uInt32 mnFillColorId; /// Fill color identifier.
571 typedef rtl::Reference< XclExpChMarkerFormat > XclExpChMarkerFormatRef;
573 /** The CHPIEFORMAT record containing data point formatting data for pie segments. */
574 class XclExpChPieFormat : public XclExpUInt16Record
576 public:
577 explicit XclExpChPieFormat();
579 /** Sets pie segment properties from the passed property set. */
580 void Convert( const ScfPropertySet& rPropSet );
583 typedef rtl::Reference< XclExpChPieFormat > XclExpChPieFormatRef;
585 /** The CH3DDATAFORMAT record containing the bar type in 3D bar charts. */
586 class XclExpCh3dDataFormat : public XclExpRecord
588 public:
589 explicit XclExpCh3dDataFormat();
591 /** Sets 3d bar properties from the passed property set. */
592 void Convert( const ScfPropertySet& rPropSet );
594 private:
595 virtual void WriteBody( XclExpStream& rStrm ) override;
597 private:
598 XclCh3dDataFormat maData; /// Contents of the CH3DDATAFORMAT record.
601 typedef rtl::Reference< XclExpCh3dDataFormat > XclExpCh3dDataFormatRef;
603 /** The CHATTACHEDLABEL record that contains the type of a data point label. */
604 class XclExpChAttachedLabel : public XclExpUInt16Record
606 public:
607 explicit XclExpChAttachedLabel( sal_uInt16 nFlags );
610 typedef rtl::Reference< XclExpChAttachedLabel > XclExpChAttLabelRef;
612 /** Represents the CHDATAFORMAT record group containing data point properties.
614 The CHDATAFORMAT group consists of: CHDATAFORMAT, CHBEGIN, CHFRAME group,
615 CHMARKERFORMAT, CHPIEFORMAT, CH3DDATAFORMAT, CHSERIESFORMAT,
616 CHATTACHEDLABEL, CHEND.
618 class XclExpChDataFormat : public XclExpChGroupBase, public XclExpChFrameBase
620 public:
621 explicit XclExpChDataFormat( const XclExpChRoot& rRoot,
622 const XclChDataPointPos& rPointPos, sal_uInt16 nFormatIdx );
624 /** Converts the passed data series or data point formatting. */
625 void ConvertDataSeries( const ScfPropertySet& rPropSet, const XclChExtTypeInfo& rTypeInfo );
626 /** Sets default formatting for a series in a stock chart. */
627 void ConvertStockSeries( const ScfPropertySet& rPropSet, bool bCloseSymbol );
628 /** Converts line formatting for the specified object (e.g. trend lines, error bars). */
629 void ConvertLine( const ScfPropertySet& rPropSet, XclChObjectType eObjType );
631 /** Returns true, if this objects describes the formatting of an entire series. */
632 bool IsSeriesFormat() const { return maData.maPointPos.mnPointIdx == EXC_CHDATAFORMAT_ALLPOINTS; }
634 /** Writes all embedded records. */
635 virtual void WriteSubRecords( XclExpStream& rStrm ) override;
637 private:
638 virtual void WriteBody( XclExpStream& rStrm ) override;
640 private:
641 XclChDataFormat maData; /// Contents of the CHDATAFORMAT record.
642 XclExpChMarkerFormatRef mxMarkerFmt; /// Data point marker (CHMARKERFORMAT record).
643 XclExpChPieFormatRef mxPieFmt; /// Pie segment format (CHPIEFORMAT record).
644 XclExpRecordRef mxSeriesFmt; /// Series properties (CHSERIESFORMAT record).
645 XclExpCh3dDataFormatRef mx3dDataFmt; /// 3D bar format (CH3DDATAFORMAT record).
646 XclExpChAttLabelRef mxAttLabel; /// Data point label type (CHATTACHEDLABEL record).
649 typedef rtl::Reference< XclExpChDataFormat > XclExpChDataFormatRef;
651 /** Represents the CHSERTRENDLINE record containing settings for a trend line. */
652 class XclExpChSerTrendLine : public XclExpRecord, protected XclExpChRoot
654 public:
655 explicit XclExpChSerTrendLine( const XclExpChRoot& rRoot );
657 /** Converts the passed trend line, returns true if trend line type is supported. */
658 bool Convert( css::uno::Reference< css::chart2::XRegressionCurve > const & xRegCurve,
659 sal_uInt16 nSeriesIdx );
661 /** Returns formatting information of the trend line, created in Convert(). */
662 const XclExpChDataFormatRef& GetDataFormat() const { return mxDataFmt; }
663 /** Returns formatting of the equation text box, created in Convert(). */
664 const XclExpChTextRef& GetDataLabel() const { return mxLabel; }
666 private:
667 virtual void WriteBody( XclExpStream& rStrm ) override;
669 private:
670 XclChSerTrendLine maData; /// Contents of the CHSERTRENDLINE record.
671 XclExpChDataFormatRef mxDataFmt; /// Formatting settings of the trend line.
672 XclExpChTextRef mxLabel; /// Formatting of the equation text box.
675 typedef rtl::Reference< XclExpChSerTrendLine > XclExpChSerTrendLineRef;
677 /** Represents the CHSERERRORBAR record containing settings for error bars. */
678 class XclExpChSerErrorBar : public XclExpRecord, protected XclExpChRoot
680 public:
681 explicit XclExpChSerErrorBar( const XclExpChRoot& rRoot, sal_uInt8 nBarType );
683 /** Converts the passed error bar settings, returns true if error bar type is supported. */
684 bool Convert( XclExpChSourceLink& rValueLink, sal_uInt16& rnValueCount, const ScfPropertySet& rPropSet );
686 private:
687 virtual void WriteBody( XclExpStream& rStrm ) override;
689 private:
690 XclChSerErrorBar maData; /// Contents of the CHSERERRORBAR record.
693 typedef rtl::Reference< XclExpChSerErrorBar > XclExpChSerErrorBarRef;
695 /** Represents the CHSERIES record group describing a data series in a chart.
697 The CHSERIES group consists of: CHSERIES, CHBEGIN, CHSOURCELINK groups,
698 CHDATAFORMAT groups, CHSERGROUP, CHSERPARENT, CHSERERRORBAR,
699 CHSERTRENDLINE, CHEND.
701 class XclExpChSeries : public XclExpChGroupBase
703 public:
704 explicit XclExpChSeries( const XclExpChRoot& rRoot, sal_uInt16 nSeriesIdx );
706 /** Converts the passed data series (source links and formatting). */
707 bool ConvertDataSeries(
708 css::uno::Reference< css::chart2::XDiagram > const & xDiagram,
709 css::uno::Reference< css::chart2::XDataSeries > const & xDataSeries,
710 const XclChExtTypeInfo& rTypeInfo,
711 sal_uInt16 nGroupIdx, sal_uInt16 nFormatIdx );
712 /** Converts the passed data series for stock charts. */
713 bool ConvertStockSeries(
714 css::uno::Reference< css::chart2::XDataSeries > const & xDataSeries,
715 std::u16string_view rValueRole,
716 sal_uInt16 nGroupIdx, sal_uInt16 nFormatIdx, bool bCloseSymbol );
717 /** Converts the passed error bar settings (called at trend line child series). */
718 bool ConvertTrendLine( const XclExpChSeries& rParent,
719 css::uno::Reference< css::chart2::XRegressionCurve > const & xRegCurve );
720 /** Converts the passed error bar settings (called at error bar child series). */
721 bool ConvertErrorBar( const XclExpChSeries& rParent, const ScfPropertySet& rPropSet, sal_uInt8 nBarId );
722 /** Converts and inserts category ranges for all inserted series. */
723 void ConvertCategSequence( css::uno::Reference< css::chart2::data::XLabeledDataSequence > const & xCategSeq );
725 /** Writes all embedded records. */
726 virtual void WriteSubRecords( XclExpStream& rStrm ) override;
728 private:
729 /** Initializes members of this series to represent a child of the passed series. */
730 void InitFromParent( const XclExpChSeries& rParent );
731 /** Tries to create trend line series objects (called at parent series). */
732 void CreateTrendLines( css::uno::Reference< css::chart2::XDataSeries > const & xDataSeries );
733 /** Tries to create positive and negative error bar series objects (called at parent series). */
734 void CreateErrorBars( const ScfPropertySet& rPropSet,
735 const OUString& rBarPropName,
736 sal_uInt8 nPosBarId, sal_uInt8 nNegBarId );
737 /** Tries to create an error bar series object (called at parent series). */
738 void CreateErrorBar( const ScfPropertySet& rPropSet,
739 const OUString& rShowPropName, sal_uInt8 nBarId );
741 virtual void WriteBody( XclExpStream& rStrm ) override;
743 private:
745 private:
746 XclChSeries maData; /// Contents of the CHSERIES record.
747 XclExpChSourceLinkRef mxTitleLink; /// Link data for series title.
748 XclExpChSourceLinkRef mxValueLink; /// Link data for series values.
749 XclExpChSourceLinkRef mxCategLink; /// Link data for series category names.
750 XclExpChSourceLinkRef mxBubbleLink; /// Link data for series bubble sizes.
751 XclExpChDataFormatRef mxSeriesFmt; /// CHDATAFORMAT group for series format.
752 XclExpRecordList< XclExpChDataFormat >
753 maPointFmts; /// CHDATAFORMAT groups for data point formats.
754 XclExpChSerTrendLineRef mxTrendLine; /// Trend line settings (CHSERTRENDLINE record).
755 XclExpChSerErrorBarRef mxErrorBar; /// Error bar settings (CHSERERRORBAR record).
756 sal_uInt16 mnGroupIdx; /// Chart type group (CHTYPEGROUP group) this series is assigned to.
757 sal_uInt16 mnSeriesIdx; /// 0-based series index.
758 sal_uInt16 mnParentIdx; /// 0-based index of parent series (trend lines and error bars).
761 typedef rtl::Reference< XclExpChSeries > XclExpChSeriesRef;
763 // Chart type groups ==========================================================
765 /** Represents the chart type record for all supported chart types. */
766 class XclExpChType : public XclExpRecord, protected XclExpChRoot
768 public:
769 explicit XclExpChType( const XclExpChRoot& rRoot );
771 /** Converts the passed chart type and the contained data series. */
772 void Convert( css::uno::Reference< css::chart2::XDiagram > const & xDiagram,
773 css::uno::Reference< css::chart2::XChartType > const & xChartType,
774 sal_Int32 nApiAxesSetIdx, bool bSwappedAxesSet, bool bHasXLabels );
775 /** Sets stacking mode (standard or percent) for the series in this chart type group. */
776 void SetStacked( bool bPercent );
778 /** Returns true, if this is object represents a valid chart type. */
779 bool IsValidType() const { return maTypeInfo.meTypeId != EXC_CHTYPEID_UNKNOWN; }
780 /** Returns the chart type info struct for the contained chart type. */
781 const XclChTypeInfo& GetTypeInfo() const { return maTypeInfo; }
783 private:
784 virtual void WriteBody( XclExpStream& rStrm ) override;
786 private:
787 XclChType maData; /// Contents of the chart type record.
788 XclChTypeInfo maTypeInfo; /// Chart type info for the contained type.
791 /** Represents the CHCHART3D record that contains 3D view settings. */
792 class XclExpChChart3d : public XclExpRecord
794 public:
795 explicit XclExpChChart3d();
797 /** Converts 3d settings for the passed chart type. */
798 void Convert( const ScfPropertySet& rPropSet, bool b3dWallChart );
799 /** Sets flag that the data points are clustered on the X axis. */
800 void SetClustered() { ::set_flag( maData.mnFlags, EXC_CHCHART3D_CLUSTER ); }
802 /** Returns true, if the data points are clustered on the X axis. */
803 bool IsClustered() const { return ::get_flag( maData.mnFlags, EXC_CHCHART3D_CLUSTER ); }
805 private:
806 virtual void WriteBody( XclExpStream& rStrm ) override;
808 private:
809 XclChChart3d maData; /// Contents of the CHCHART3D record.
812 typedef rtl::Reference< XclExpChChart3d > XclExpChChart3dRef;
814 /** Represents the CHLEGEND record group describing the chart legend.
816 The CHLEGEND group consists of: CHLEGEND, CHBEGIN, CHFRAMEPOS, CHFRAME
817 group, CHTEXT group, CHEND.
819 class XclExpChLegend : public XclExpChGroupBase
821 public:
822 explicit XclExpChLegend( const XclExpChRoot& rRoot );
824 /** Converts all legend settings from the passed property set. */
825 void Convert( const ScfPropertySet& rPropSet );
827 /** Writes all embedded records. */
828 virtual void WriteSubRecords( XclExpStream& rStrm ) override;
830 private:
831 virtual void WriteBody( XclExpStream& rStrm ) override;
833 private:
834 XclChLegend maData; /// Contents of the CHLEGEND record.
835 XclExpChFramePosRef mxFramePos; /// Legend frame position (CHFRAMEPOS record).
836 XclExpChTextRef mxText; /// Legend text format (CHTEXT group).
837 XclExpChFrameRef mxFrame; /// Legend frame format (CHFRAME group).
840 typedef rtl::Reference< XclExpChLegend > XclExpChLegendRef;
842 /** Represents the CHDROPBAR record group describing pos/neg bars in line charts.
844 The CHDROPBAR group consists of: CHDROPBAR, CHBEGIN, CHLINEFORMAT,
845 CHAREAFORMAT, CHESCHERFORMAT group, CHEND.
847 class XclExpChDropBar : public XclExpChGroupBase, public XclExpChFrameBase
849 public:
850 explicit XclExpChDropBar( const XclExpChRoot& rRoot, XclChObjectType eObjType );
852 /** Converts and writes the contained frame data to the passed property set. */
853 void Convert( const ScfPropertySet& rPropSet );
855 /** Writes all embedded records. */
856 virtual void WriteSubRecords( XclExpStream& rStrm ) override;
858 private:
859 virtual void WriteBody( XclExpStream& rStrm ) override;
861 private:
862 XclChObjectType meObjType; /// Type of the dropbar.
865 typedef rtl::Reference< XclExpChDropBar > XclExpChDropBarRef;
867 /** Represents the CHTYPEGROUP record group describing a group of series.
869 The CHTYPEGROUP group consists of: CHTYPEGROUP, CHBEGIN, a chart type
870 record (e.g. CHBAR, CHLINE, CHAREA, CHPIE, ...), CHCHART3D, CHLEGEND group,
871 CHDROPBAR groups, CHCHARTLINE groups (CHCHARTLINE with CHLINEFORMAT),
872 CHDATAFORMAT group, CHEND.
874 class XclExpChTypeGroup : public XclExpChGroupBase
876 public:
877 explicit XclExpChTypeGroup( const XclExpChRoot& rRoot, sal_uInt16 nGroupIdx );
879 /** Converts the passed chart type to Excel type settings. */
880 void ConvertType( css::uno::Reference< css::chart2::XDiagram > const & xDiagram,
881 css::uno::Reference< css::chart2::XChartType > const & xChartType,
882 sal_Int32 nApiAxesSetIdx, bool b3dChart, bool bSwappedAxesSet, bool bHasXLabels );
883 /** Converts and inserts all series from the passed chart type. */
884 void ConvertSeries( css::uno::Reference< css::chart2::XDiagram > const & xDiagram,
885 css::uno::Reference< css::chart2::XChartType > const & xChartType,
886 sal_Int32 nGroupAxesSetIdx, bool bPercent, bool bConnectorLines );
887 /** Converts and inserts category ranges for all inserted series. */
888 void ConvertCategSequence( css::uno::Reference< css::chart2::data::XLabeledDataSequence > const & xCategSeq );
889 /** Creates a legend object and converts all legend settings. */
890 void ConvertLegend( const ScfPropertySet& rPropSet );
892 /** Returns true, if this chart type group contains at least one valid series. */
893 bool IsValidGroup() const { return !maSeries.IsEmpty() && maType.IsValidType(); }
894 /** Returns the index of this chart type group format. */
895 sal_uInt16 GetGroupIdx() const { return maData.mnGroupIdx; }
896 /** Returns the chart type info struct for the contained chart type. */
897 const XclChExtTypeInfo& GetTypeInfo() const { return maTypeInfo; }
898 /** Returns true, if the chart is three-dimensional. */
899 bool Is3dChart() const { return maTypeInfo.mb3dChart; }
900 /** Returns true, if chart type supports wall and floor format. */
901 bool Is3dWallChart() const { return Is3dChart() && (maTypeInfo.meTypeCateg != EXC_CHTYPECATEG_PIE); }
902 /** Returns true, if the series in this chart type group are ordered on the Z axis. */
903 bool Is3dDeepChart() const { return Is3dWallChart() && mxChart3d && !mxChart3d->IsClustered(); }
904 /** Returns true, if this chart type can be combined with other types. */
905 bool IsCombinable2d() const { return !Is3dChart() && maTypeInfo.mbCombinable2d; }
907 /** Writes all embedded records. */
908 virtual void WriteSubRecords( XclExpStream& rStrm ) override;
910 private:
911 /** Returns an unused format index to be used for the next created series. */
912 sal_uInt16 GetFreeFormatIdx() const;
913 /** Creates all data series of any chart type except stock charts. */
914 void CreateDataSeries( css::uno::Reference< css::chart2::XDiagram > const & xDiagram,
915 css::uno::Reference< css::chart2::XDataSeries > const & xDataSeries );
916 /** Creates all data series of a stock chart. */
917 void CreateAllStockSeries( css::uno::Reference< css::chart2::XChartType > const & xChartType,
918 css::uno::Reference< css::chart2::XDataSeries > const & xDataSeries );
919 /** Creates a single data series of a stock chart. */
920 bool CreateStockSeries( css::uno::Reference< css::chart2::XDataSeries > const & xDataSeries,
921 std::u16string_view rValueRole, bool bCloseSymbol );
923 virtual void WriteBody( XclExpStream& rStrm ) override;
925 private:
926 typedef XclExpRecordList< XclExpChSeries > XclExpChSeriesList;
928 XclChTypeGroup maData; /// Contents of the CHTYPEGROUP record.
929 XclExpChType maType; /// Chart type (e.g. CHBAR, CHLINE, ...).
930 XclChExtTypeInfo maTypeInfo; /// Extended chart type info.
931 XclExpChSeriesList maSeries; /// List of series data (CHSERIES groups).
932 XclExpChChart3dRef mxChart3d; /// 3D settings (CHCHART3D record).
933 XclExpChLegendRef mxLegend; /// Chart legend (CHLEGEND group).
934 XclExpChDropBarRef mxUpBar; /// White dropbars (CHDROPBAR group).
935 XclExpChDropBarRef mxDownBar; /// Black dropbars (CHDROPBAR group).
936 std::map<sal_uInt16, std::unique_ptr<XclExpChLineFormat>>
937 m_ChartLines; /// Global line formats (CHCHARTLINE group).
940 typedef rtl::Reference< XclExpChTypeGroup > XclExpChTypeGroupRef;
942 // Axes =======================================================================
944 class XclExpChLabelRange : public XclExpRecord, protected XclExpChRoot
946 public:
947 explicit XclExpChLabelRange( const XclExpChRoot& rRoot );
949 /** Converts category axis scaling settings. */
950 void Convert( const css::chart2::ScaleData& rScaleData,
951 const ScfPropertySet& rChart1Axis, bool bMirrorOrient );
952 /** Converts position settings of a crossing axis at this axis. */
953 void ConvertAxisPosition( const ScfPropertySet& rPropSet );
954 /** Sets flag for tickmark position between categories or on categories. */
955 void SetTicksBetweenCateg( bool bTicksBetween )
956 { ::set_flag( maLabelData.mnFlags, EXC_CHLABELRANGE_BETWEEN, bTicksBetween ); }
958 private:
959 virtual void Save( XclExpStream& rStrm ) override;
960 virtual void WriteBody( XclExpStream& rStrm ) override;
962 private:
963 XclChLabelRange maLabelData; /// Contents of the CHLABELRANGE record.
964 XclChDateRange maDateData; /// Contents of the CHDATERANGE record.
967 typedef rtl::Reference< XclExpChLabelRange > XclExpChLabelRangeRef;
969 class XclExpChValueRange : public XclExpRecord, protected XclExpChRoot
971 public:
972 explicit XclExpChValueRange( const XclExpChRoot& rRoot );
974 /** Converts value axis scaling settings. */
975 void Convert( const css::chart2::ScaleData& rScaleData );
976 /** Converts position settings of a crossing axis at this axis. */
977 void ConvertAxisPosition( const ScfPropertySet& rPropSet );
979 private:
980 virtual void WriteBody( XclExpStream& rStrm ) override;
982 private:
983 XclChValueRange maData; /// Contents of the CHVALUERANGE record.
986 typedef rtl::Reference< XclExpChValueRange > XclExpChValueRangeRef;
988 class XclExpChTick : public XclExpRecord, protected XclExpChRoot
990 public:
991 explicit XclExpChTick( const XclExpChRoot& rRoot );
993 /** Converts axis tick mark settings. */
994 void Convert( const ScfPropertySet& rPropSet, const XclChExtTypeInfo& rTypeInfo, sal_uInt16 nAxisType );
995 /** Sets font color and color identifier to internal data structures. */
996 void SetFontColor( const Color& rColor, sal_uInt32 nColorId );
997 /** Sets text rotation to internal data structures. */
998 void SetRotation( sal_uInt16 nRotation );
1000 private:
1001 virtual void WriteBody( XclExpStream& rStrm ) override;
1003 private:
1004 XclChTick maData; /// Contents of the CHTICK record.
1005 sal_uInt32 mnTextColorId; /// Axis labels text color identifier.
1008 typedef rtl::Reference< XclExpChTick > XclExpChTickRef;
1010 /** Represents the CHAXIS record group describing an entire chart axis.
1012 The CHAXIS group consists of: CHAXIS, CHBEGIN, CHLABELRANGE, CHEXTRANGE,
1013 CHVALUERANGE, CHFORMAT, CHTICK, CHFONT, CHAXISLINE groups (CHAXISLINE with
1014 CHLINEFORMAT, CHAREAFORMAT, and CHESCHERFORMAT group), CHEND.
1016 class XclExpChAxis : public XclExpChGroupBase, public XclExpChFontBase
1018 public:
1019 explicit XclExpChAxis( const XclExpChRoot& rRoot, sal_uInt16 nAxisType );
1021 /** Sets font color and color identifier to internal data structures. */
1022 virtual void SetFont( XclExpChFontRef xFont, const Color& rColor, sal_uInt32 nColorId ) override;
1023 /** Sets text rotation to internal data structures. */
1024 virtual void SetRotation( sal_uInt16 nRotation ) override;
1026 /** Converts formatting and scaling settings from the passed axis. */
1027 void Convert( css::uno::Reference< css::chart2::XAxis > const & xAxis,
1028 css::uno::Reference< css::chart2::XAxis > const & xCrossingAxis,
1029 css::uno::Reference< css::chart::XAxis > const & xChart1Axis,
1030 const XclChExtTypeInfo& rTypeInfo );
1031 /** Converts and writes 3D wall/floor properties from the passed diagram. */
1032 void ConvertWall( css::uno::Reference< css::chart2::XDiagram > const & xDiagram );
1034 /** Returns the type of this axis. */
1035 sal_uInt16 GetAxisType() const { return maData.mnType; }
1036 /** Returns the axis dimension index used by the chart API. */
1037 sal_Int32 GetApiAxisDimension() const { return maData.GetApiAxisDimension(); }
1039 /** Writes all embedded records. */
1040 virtual void WriteSubRecords( XclExpStream& rStrm ) override;
1042 private:
1043 virtual void WriteBody( XclExpStream& rStrm ) override;
1045 private:
1046 XclChAxis maData; /// Contents of the CHAXIS record.
1047 XclExpChLabelRangeRef mxLabelRange; /// Category scaling (CHLABELRANGE record).
1048 XclExpChValueRangeRef mxValueRange; /// Value scaling (CHVALUERANGE record).
1049 XclExpChTickRef mxTick; /// Axis ticks (CHTICK record).
1050 XclExpChFontRef mxFont; /// Index into font buffer (CHFONT record).
1051 XclExpChLineFormatRef mxAxisLine; /// Axis line format (CHLINEFORMAT record).
1052 XclExpChLineFormatRef mxMajorGrid; /// Major grid line format (CHLINEFORMAT record).
1053 XclExpChLineFormatRef mxMinorGrid; /// Minor grid line format (CHLINEFORMAT record).
1054 XclExpChFrameRef mxWallFrame; /// Wall/floor format (sub records of CHFRAME group).
1055 sal_uInt16 mnNumFmtIdx; /// Index into number format buffer (CHFORMAT record).
1058 typedef rtl::Reference< XclExpChAxis > XclExpChAxisRef;
1060 /** Represents the CHAXESSET record group describing an axes set (X/Y/Z axes).
1062 The CHAXESSET group consists of: CHAXESSET, CHBEGIN, CHFRAMEPOS, CHAXIS
1063 groups, CHTEXT groups, CHPLOTFRAME group (CHPLOTFRAME with CHFRAME group),
1064 CHTYPEGROUP group, CHEND.
1066 class XclExpChAxesSet : public XclExpChGroupBase
1068 public:
1069 explicit XclExpChAxesSet( const XclExpChRoot& rRoot, sal_uInt16 nAxesSetId );
1071 /** Converts the passed diagram to chart record data.
1072 @return First unused chart type group index. */
1073 sal_uInt16 Convert( css::uno::Reference< css::chart2::XDiagram > const & xDiagram,
1074 sal_uInt16 nFirstGroupIdx );
1076 /** Returns true, if this axes set exists (returns false if this is a dummy object). */
1077 bool IsValidAxesSet() const { return !maTypeGroups.IsEmpty(); }
1078 /** Returns the index of the axes set (primary/secondary). */
1079 sal_uInt16 GetAxesSetId() const { return maData.mnAxesSetId; }
1080 /** Returns the axes set index used by the chart API. */
1081 sal_Int32 GetApiAxesSetIndex() const { return maData.GetApiAxesSetIndex(); }
1082 /** Returns true, if the chart is three-dimensional. */
1083 bool Is3dChart() const;
1085 /** Writes all embedded records. */
1086 virtual void WriteSubRecords( XclExpStream& rStrm ) override;
1088 private:
1089 /** Returns first inserted chart type group. */
1090 XclExpChTypeGroupRef GetFirstTypeGroup() const;
1091 /** Returns last inserted chart type group. */
1092 XclExpChTypeGroupRef GetLastTypeGroup() const;
1094 /** Converts a complete axis object including axis title. */
1095 void ConvertAxis( XclExpChAxisRef& rxChAxis, sal_uInt16 nAxisType,
1096 XclExpChTextRef& rxChAxisTitle, sal_uInt16 nTitleTarget,
1097 css::uno::Reference< css::chart2::XCoordinateSystem > const & xCoordSystem,
1098 const XclChExtTypeInfo& rTypeInfo,
1099 sal_Int32 nCrossingAxisDim );
1101 virtual void WriteBody( XclExpStream& rStrm ) override;
1103 private:
1104 XclChAxesSet maData; /// Contents of the CHAXESSET record.
1105 XclExpChFramePosRef mxFramePos; /// Outer plot area position (CHFRAMEPOS record).
1106 XclExpChAxisRef mxXAxis; /// The X axis (CHAXIS group).
1107 XclExpChAxisRef mxYAxis; /// The Y axis (CHAXIS group).
1108 XclExpChAxisRef mxZAxis; /// The Z axis (CHAXIS group).
1109 XclExpChTextRef mxXAxisTitle; /// The X axis title (CHTEXT group).
1110 XclExpChTextRef mxYAxisTitle; /// The Y axis title (CHTEXT group).
1111 XclExpChTextRef mxZAxisTitle; /// The Z axis title (CHTEXT group).
1112 XclExpChFrameRef mxPlotFrame; /// Plot area (CHPLOTFRAME group).
1113 XclExpRecordList< XclExpChTypeGroup >
1114 maTypeGroups; /// Chart type groups (CHTYPEGROUP group).
1117 typedef std::shared_ptr< XclExpChAxesSet > XclExpChAxesSetRef;
1119 // The chart object ===========================================================
1121 /** Represents the CHCHART record group describing the chart contents.
1123 The CHCHART group consists of: CHCHART, CHBEGIN, SCL, CHPLOTGROWTH, CHFRAME
1124 group, CHSERIES groups, CHPROPERTIES, CHDEFAULTTEXT groups (CHDEFAULTTEXT
1125 with CHTEXT groups), CHUSEDAXESSETS, CHAXESSET groups, CHTEXT groups, CHEND.
1127 class XclExpChChart : public XclExpChGroupBase
1129 public:
1130 explicit XclExpChChart( const XclExpRoot& rRoot,
1131 css::uno::Reference< css::chart2::XChartDocument > const & xChartDoc,
1132 const tools::Rectangle& rChartRect );
1134 /** Creates, registers and returns a new data series object. */
1135 XclExpChSeriesRef CreateSeries();
1136 /** Removes the last created data series object from the series list. */
1137 void RemoveLastSeries();
1138 /** Stores a CHTEXT group that describes a data point label. */
1139 void SetDataLabel( XclExpChTextRef const & xText );
1140 /** Sets the plot area position and size to manual mode. */
1141 void SetManualPlotArea();
1143 /** Writes all embedded records. */
1144 virtual void WriteSubRecords( XclExpStream& rStrm ) override;
1146 private:
1147 virtual void WriteBody( XclExpStream& rStrm ) override;
1149 private:
1150 typedef XclExpRecordList< XclExpChSeries > XclExpChSeriesList;
1152 XclChRectangle maRect; /// Position of the chart on the sheet (CHCHART record).
1153 XclExpChSeriesList maSeries; /// List of series data (CHSERIES groups).
1154 XclExpChFrameRef mxFrame; /// Chart frame format (CHFRAME group).
1155 XclChProperties maProps; /// Chart properties (CHPROPERTIES record).
1156 XclExpChAxesSetRef mxPrimAxesSet; /// Primary axes set (CHAXESSET group).
1157 XclExpChAxesSetRef mxSecnAxesSet; /// Secondary axes set (CHAXESSET group).
1158 XclExpChTextRef mxTitle; /// Chart title (CHTEXT group).
1159 XclExpRecordList< XclExpChText >
1160 maLabels; /// Data point labels (CHTEXT groups).
1163 /** Represents the group of DFF and OBJ records containing all drawing shapes
1164 embedded in the chart object.
1166 class XclExpChartDrawing : public XclExpRecordBase, protected XclExpRoot
1168 public:
1169 explicit XclExpChartDrawing(
1170 const XclExpRoot& rRoot,
1171 const css::uno::Reference< css::frame::XModel >& rxModel,
1172 const Size& rChartSize );
1173 virtual ~XclExpChartDrawing() override;
1175 virtual void Save( XclExpStream& rStrm ) override;
1177 private:
1178 std::shared_ptr< XclExpObjectManager > mxObjMgr;
1179 rtl::Reference< XclExpRecordBase > mxObjRecs;
1182 /** Represents the entire chart substream (all records in BOF/EOF block). */
1183 class XclExpChart : public XclExpSubStream, protected XclExpRoot
1185 public:
1186 explicit XclExpChart( const XclExpRoot& rRoot,
1187 css::uno::Reference< css::frame::XModel > const & xModel,
1188 const tools::Rectangle& rChartRect );
1191 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */