xref: /aoo41x/main/sc/source/filter/inc/xechart.hxx (revision 38d50f7b)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef SC_XECHART_HXX
25 #define SC_XECHART_HXX
26 
27 #include <tools/gen.hxx>
28 #include "xerecord.hxx"
29 #include "xlchart.hxx"
30 #include "xlformula.hxx"
31 #include "xlstyle.hxx"
32 #include "xeroot.hxx"
33 #include "xestring.hxx"
34 
35 class Size;
36 
37 namespace com { namespace sun { namespace star {
38     namespace awt
39     {
40         struct Rectangle;
41     }
42     namespace frame
43     {
44         class XModel;
45     }
46     namespace chart
47     {
48         class XAxis;
49     }
50     namespace chart2
51     {
52         struct ScaleData;
53         class XChartDocument;
54         class XDiagram;
55         class XCoordinateSystem;
56         class XChartType;
57         class XDataSeries;
58         class XAxis;
59         class XTitle;
60         class XFormattedString;
61         class XRegressionCurve;
62         namespace data
63         {
64             class XDataSequence;
65             class XLabeledDataSequence;
66         }
67     }
68 } } }
69 
70 // Common =====================================================================
71 
72 struct XclExpChRootData;
73 class XclExpChChart;
74 
75 /** Base class for complex chart classes, provides access to other components
76     of the chart.
77 
78     Keeps also track of future record levels and writes the needed future
79     records on demand.
80  */
81 class XclExpChRoot : public XclExpRoot
82 {
83 public:
84     typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument > XChartDocRef;
85 
86 public:
87     explicit            XclExpChRoot( const XclExpRoot& rRoot, XclExpChChart& rChartData );
88     virtual             ~XclExpChRoot();
89 
90     /** Returns this root instance - for code readability in derived classes. */
GetChRoot() const91     inline const XclExpChRoot& GetChRoot() const { return *this; }
92     /** Returns the API Chart document model. */
93     XChartDocRef        GetChartDocument() const;
94     /** Returns a reference to the parent chart data object. */
95     XclExpChChart&      GetChartData() const;
96     /** Returns chart type info for a unique chart type identifier. */
97     const XclChTypeInfo& GetChartTypeInfo( XclChTypeId eType ) const;
98     /** Returns the first fitting chart type info for the passed service name. */
99     const XclChTypeInfo& GetChartTypeInfo( const ::rtl::OUString& rServiceName ) const;
100 
101     /** Returns an info struct about auto formatting for the passed object type. */
102     const XclChFormatInfo& GetFormatInfo( XclChObjectType eObjType ) const;
103 
104     /** Starts the API chart document conversion. Must be called once before all API conversion. */
105     void                InitConversion( XChartDocRef xChartDoc, const Rectangle& rChartRect ) const;
106     /** Finishes the API chart document conversion. Must be called once after all API conversion. */
107     void                FinishConversion() const;
108 
109     /** Returns true, if the passed color equals to the specified system color. */
110     bool                IsSystemColor( const Color& rColor, sal_uInt16 nSysColorIdx ) const;
111     /** Sets a system color and the respective color identifier. */
112     void                SetSystemColor( Color& rColor, sal_uInt32& rnColorId, sal_uInt16 nSysColorIdx ) const;
113 
114     /** Converts the passed horizontal coordinate from 1/100 mm to Excel chart units. */
115     sal_Int32           CalcChartXFromHmm( sal_Int32 nPosX ) const;
116     /** Converts the passed vertical coordinate from 1/100 mm to Excel chart units. */
117     sal_Int32           CalcChartYFromHmm( sal_Int32 nPosY ) const;
118     /** Converts the passed rectangle from 1/100 mm to Excel chart units. */
119     XclChRectangle      CalcChartRectFromHmm( const ::com::sun::star::awt::Rectangle& rRect ) const;
120 
121     /** Converts the passed horizontal coordinate from a relative position to Excel chart units. */
122     sal_Int32           CalcChartXFromRelative( double fPosX ) const;
123     /** Converts the passed vertical coordinate from a relative position to Excel chart units. */
124     sal_Int32           CalcChartYFromRelative( double fPosY ) const;
125 
126     /** Reads all line properties from the passed property set. */
127     void                ConvertLineFormat(
128                             XclChLineFormat& rLineFmt,
129                             const ScfPropertySet& rPropSet,
130                             XclChPropertyMode ePropMode ) const;
131     /** Reads solid area properties from the passed property set.
132         @return  true = object contains complex fill properties. */
133     bool                ConvertAreaFormat(
134                             XclChAreaFormat& rAreaFmt,
135                             const ScfPropertySet& rPropSet,
136                             XclChPropertyMode ePropMode ) const;
137     /** Reads gradient or bitmap area properties from the passed property set. */
138     void                ConvertEscherFormat(
139                             XclChEscherFormat& rEscherFmt,
140                             XclChPicFormat& rPicFmt,
141                             const ScfPropertySet& rPropSet,
142                             XclChPropertyMode ePropMode ) const;
143     /** Reads font properties from the passed property set. */
144     sal_uInt16          ConvertFont(
145                             const ScfPropertySet& rPropSet,
146                             sal_Int16 nScript ) const;
147 
148     /** Reads the pie rotation property and returns the converted angle. */
149     static sal_uInt16   ConvertPieRotation( const ScfPropertySet& rPropSet );
150 
151 protected:
152     /** Called from XclExpChGroupBase::Save, registers a new future record level. */
153     void                RegisterFutureRecBlock( const XclChFrBlock& rFrBlock );
154     /** Called from XclExpChFutureRecordBase::Save, Initializes the current future record level. */
155     void                InitializeFutureRecBlock( XclExpStream& rStrm );
156     /** Called from XclExpChGroupBase::Save, finalizes the current future record level. */
157     void                FinalizeFutureRecBlock( XclExpStream& rStrm );
158 
159 private:
160     typedef ScfRef< XclExpChRootData > XclExpChRootDataRef;
161     XclExpChRootDataRef mxChData;           /// Reference to the root data object.
162 };
163 
164 // ----------------------------------------------------------------------------
165 
166 /** Base class for chart record groups. Provides helper functions to write sub records.
167 
168     A chart record group consists of a header record, followed by a CHBEGIN
169     record, followed by group sub records, and finished with a CHEND record.
170  */
171 class XclExpChGroupBase : public XclExpRecord, protected XclExpChRoot
172 {
173 public:
174     explicit            XclExpChGroupBase(
175                             const XclExpChRoot& rRoot, sal_uInt16 nFrType,
176                             sal_uInt16 nRecId, sal_Size nRecSize = 0 );
177     virtual             ~XclExpChGroupBase();
178 
179     /** Saves the header record. Calls WriteSubRecords() to let derived classes write sub records. */
180     virtual void        Save( XclExpStream& rStrm );
181     /** Derived classes return whether there are any records embedded in this group. */
182     virtual bool        HasSubRecords() const;
183     /** Derived classes implement writing any records embedded in this group. */
184     virtual void        WriteSubRecords( XclExpStream& rStrm ) = 0;
185 
186 protected:
187     /** Sets context information for future record blocks. */
188     void                SetFutureRecordContext( sal_uInt16 nFrContext,
189                             sal_uInt16 nFrValue1 = 0, sal_uInt16 nFrValue2 = 0 );
190 
191 private:
192     XclChFrBlock        maFrBlock;          /// Future records block settings.
193 };
194 
195 // ----------------------------------------------------------------------------
196 
197 /** Base class for chart future records. On saving, the record writes missing
198     CHFRBLOCKBEGIN records automatically.
199  */
200 class XclExpChFutureRecordBase : public XclExpFutureRecord, protected XclExpChRoot
201 {
202 public:
203     explicit            XclExpChFutureRecordBase( const XclExpChRoot& rRoot,
204                             XclFutureRecType eRecType, sal_uInt16 nRecId, sal_Size nRecSize = 0 );
205 
206     /** Writes missing CHFRBLOCKBEGIN records and this record. */
207     virtual void        Save( XclExpStream& rStrm );
208 };
209 
210 // Frame formatting ===========================================================
211 
212 class XclExpChFramePos : public XclExpRecord
213 {
214 public:
215     explicit            XclExpChFramePos( sal_uInt16 nTLMode, sal_uInt16 nBRMode );
216 
217     /** Returns read/write access to the frame position data. */
GetFramePosData()218     inline XclChFramePos& GetFramePosData() { return maData; }
219 
220 private:
221     virtual void        WriteBody( XclExpStream& rStrm );
222 
223 private:
224     XclChFramePos       maData;             /// Position of the frame.
225 };
226 
227 typedef ScfRef< XclExpChFramePos > XclExpChFramePosRef;
228 
229 // ----------------------------------------------------------------------------
230 
231 class XclExpChLineFormat : public XclExpRecord
232 {
233 public:
234     explicit            XclExpChLineFormat( const XclExpChRoot& rRoot );
235 
236     /** Converts line formatting properties from the passed property set. */
237     void                Convert( const XclExpChRoot& rRoot,
238                             const ScfPropertySet& rPropSet, XclChObjectType eObjType );
239     /** Sets or clears the automatic flag. */
SetAuto(bool bAuto)240     inline void         SetAuto( bool bAuto ) { ::set_flag( maData.mnFlags, EXC_CHLINEFORMAT_AUTO, bAuto ); }
241     /** Sets flag to show or hide an axis. */
SetShowAxis(bool bShowAxis)242     inline void         SetShowAxis( bool bShowAxis )
243                             { ::set_flag( maData.mnFlags, EXC_CHLINEFORMAT_SHOWAXIS, bShowAxis ); }
244     /** Sets the line format to the specified default type. */
245     void                SetDefault( XclChFrameType eDefFrameType );
246 
247     /** Returns true, if the line format is set to automatic. */
IsAuto() const248     inline bool         IsAuto() const { return ::get_flag( maData.mnFlags, EXC_CHLINEFORMAT_AUTO ); }
249     /** Returns true, if the line style is set to something visible. */
HasLine() const250     inline bool         HasLine() const { return maData.mnPattern != EXC_CHLINEFORMAT_NONE; }
251     /** Returns true, if the line contains default formatting according to the passed frame type. */
252     bool                IsDefault( XclChFrameType eDefFrameType ) const;
253 
254 private:
255     virtual void        WriteBody( XclExpStream& rStrm );
256 
257 private:
258     XclChLineFormat     maData;             /// Contents of the CHLINEFORMAT record.
259     sal_uInt32          mnColorId;          /// Line color identifier.
260 };
261 
262 typedef ScfRef< XclExpChLineFormat > XclExpChLineFormatRef;
263 
264 // ----------------------------------------------------------------------------
265 
266 class XclExpChAreaFormat : public XclExpRecord
267 {
268 public:
269     explicit            XclExpChAreaFormat( const XclExpChRoot& rRoot );
270 
271     /** Converts area formatting properties from the passed property set.
272         @return  true = object contains complex fill properties. */
273     bool                Convert( const XclExpChRoot& rRoot,
274                             const ScfPropertySet& rPropSet, XclChObjectType eObjType );
275     /** Sets or clears the automatic flag. */
SetAuto(bool bAuto)276     inline void         SetAuto( bool bAuto ) { ::set_flag( maData.mnFlags, EXC_CHAREAFORMAT_AUTO, bAuto ); }
277     /** Sets the area format to the specified default type. */
278     void                SetDefault( XclChFrameType eDefFrameType );
279 
280     /** Returns true, if the area format is set to automatic. */
IsAuto() const281     inline bool         IsAuto() const { return ::get_flag( maData.mnFlags, EXC_CHAREAFORMAT_AUTO ); }
282     /** Returns true, if the area style is set to something visible. */
HasArea() const283     inline bool         HasArea() const { return maData.mnPattern != EXC_PATT_NONE; }
284     /** Returns true, if the area contains default formatting according to the passed frame type. */
285     bool                IsDefault( XclChFrameType eDefFrameType ) const;
286 
287 private:
288     virtual void        WriteBody( XclExpStream& rStrm );
289 
290 private:
291     XclChAreaFormat     maData;             /// Contents of the CHAREAFORMAT record.
292     sal_uInt32          mnPattColorId;      /// Pattern color identifier.
293     sal_uInt32          mnBackColorId;      /// Pattern background color identifier.
294 };
295 
296 typedef ScfRef< XclExpChAreaFormat > XclExpChAreaFormatRef;
297 
298 // ----------------------------------------------------------------------------
299 
300 class XclExpChEscherFormat : public XclExpChGroupBase
301 {
302 public:
303     explicit            XclExpChEscherFormat( const XclExpChRoot& rRoot );
304 
305     /** Converts complex area formatting from the passed property set. */
306     void                Convert( const ScfPropertySet& rPropSet, XclChObjectType eObjType );
307 
308     /** Returns true, if the object contains valid formatting data. */
309     bool                IsValid() const;
310 
311     /** Writes the CHESCHERFORMAT record group to the stream, if complex formatting is extant. */
312     virtual void        Save( XclExpStream& rStrm );
313     /** Returns true, if this record group contains a CHPICFORMAT record. */
314     virtual bool        HasSubRecords() const;
315     /** Writes all embedded records. */
316     virtual void        WriteSubRecords( XclExpStream& rStrm );
317 
318 private:
319     /** Inserts a color from the contained Escher property set into the color palette. */
320     sal_uInt32          RegisterColor( sal_uInt16 nPropId );
321 
322     virtual void        WriteBody( XclExpStream& rStrm );
323 
324 private:
325     XclChEscherFormat   maData;             /// Fill properties for complex areas (CHESCHERFORMAT record).
326     XclChPicFormat      maPicFmt;           /// Image options, e.g. stretched, stacked (CHPICFORMAT record).
327     sal_uInt32          mnColor1Id;         /// First fill color identifier.
328     sal_uInt32          mnColor2Id;         /// Second fill color identifier.
329 };
330 
331 typedef ScfRef< XclExpChEscherFormat > XclExpChEscherFormatRef;
332 
333 // ----------------------------------------------------------------------------
334 
335 /** Base class for record groups containing frame formatting.
336 
337     Frame formatting can be part of several record groups, e.g. CHFRAME,
338     CHDATAFORMAT, CHDROPBAR. It consists of CHLINEFORMAT, CHAREAFORMAT, and
339     CHESCHERFORMAT group.
340  */
341 class XclExpChFrameBase
342 {
343 public:
344     explicit            XclExpChFrameBase();
345     virtual             ~XclExpChFrameBase();
346 
347 protected:
348     /** Converts frame formatting properties from the passed property set. */
349     void                ConvertFrameBase( const XclExpChRoot& rRoot,
350                             const ScfPropertySet& rPropSet, XclChObjectType eObjType );
351     /** Sets the frame formatting to the specified default type. */
352     void                SetDefaultFrameBase( const XclExpChRoot& rRoot,
353                             XclChFrameType eDefFrameType, bool bIsFrame );
354 
355     /** Returns true, if the frame contains default formatting (as if the frame is missing). */
356     bool                IsDefaultFrameBase( XclChFrameType eDefFrameType ) const;
357 
358     /** Writes all contained frame records to the passed stream. */
359     void                WriteFrameRecords( XclExpStream& rStrm );
360 
361 private:
362     XclExpChLineFormatRef mxLineFmt;        /// Line format (CHLINEFORMAT record).
363     XclExpChAreaFormatRef mxAreaFmt;        /// Area format (CHAREAFORMAT record).
364     XclExpChEscherFormatRef mxEscherFmt;    /// Complex area format (CHESCHERFORMAT record).
365 };
366 
367 // ----------------------------------------------------------------------------
368 
369 /** Represents the CHFRAME record group containing object frame properties.
370 
371     The CHFRAME group consists of: CHFRAME, CHBEGIN, CHLINEFORMAT,
372     CHAREAFORMAT, CHESCHERFORMAT group, CHEND.
373  */
374 class XclExpChFrame : public XclExpChGroupBase, public XclExpChFrameBase
375 {
376 public:
377     explicit            XclExpChFrame( const XclExpChRoot& rRoot, XclChObjectType eObjType );
378 
379     /** Converts frame formatting properties from the passed property set. */
380     void                Convert( const ScfPropertySet& rPropSet );
381     /** Sets the specified automatic flags. */
382     void                SetAutoFlags( bool bAutoPos, bool bAutoSize );
383 
384     /** Returns true, if the frame object contains default formats. */
385     bool                IsDefault() const;
386     /** Returns true, if the frame object can be deleted because it contains default formats. */
387     bool                IsDeleteable() const;
388 
389     /** Writes the entire record group. */
390     virtual void        Save( XclExpStream& rStrm );
391     /** Writes all embedded records. */
392     virtual void        WriteSubRecords( XclExpStream& rStrm );
393 
394 private:
395     virtual void        WriteBody( XclExpStream& rStrm );
396 
397 private:
398     XclChFrame          maData;             /// Contents of the CHFRAME record.
399     XclChObjectType     meObjType;          /// Type of the represented object.
400 };
401 
402 typedef ScfRef< XclExpChFrame > XclExpChFrameRef;
403 
404 // Source links ===============================================================
405 
406 class XclExpChSourceLink : public XclExpRecord, protected XclExpChRoot
407 {
408 public:
409     typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSequence >   XDataSequenceRef;
410     typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XFormattedString >      XFormattedStringRef;
411     typedef ::com::sun::star::uno::Sequence< XFormattedStringRef >                              XFormattedStringSeq;
412 
413 public:
414     explicit            XclExpChSourceLink( const XclExpChRoot& rRoot, sal_uInt8 nDestType );
415 
416     /** Converts the passed source link, returns the number of linked values. */
417     sal_uInt16          ConvertDataSequence( XDataSequenceRef xDataSeq, bool bSplitToColumns, sal_uInt16 nDefCount = 0 );
418     /** Converts the passed sequence of formatted string objects, returns leading font index. */
419     sal_uInt16          ConvertStringSequence( const XFormattedStringSeq& rStringSeq );
420     /** Converts the number format from the passed property set. */
421     void                ConvertNumFmt( const ScfPropertySet& rPropSet, bool bPercent );
422 
423     /** Returns true, if this source link contains explicit string data. */
HasString() const424     inline bool         HasString() const { return mxString.is() && !mxString->IsEmpty(); }
425 
426     /** Writes the CHSOURCELINK record and optionally a CHSTRING record with explicit string data. */
427     virtual void        Save( XclExpStream& rStrm );
428 
429 private:
430     virtual void        WriteBody( XclExpStream& rStrm );
431 
432 private:
433     XclChSourceLink     maData;             /// Contents of the CHSOURCELINK record.
434     XclTokenArrayRef    mxLinkFmla;         /// Formula with link to source data.
435     XclExpStringRef     mxString;           /// Text data (CHSTRING record).
436 };
437 
438 typedef ScfRef< XclExpChSourceLink > XclExpChSourceLinkRef;
439 
440 // Text =======================================================================
441 
442 /** The CHFONT record containing a font index for text objects. */
443 class XclExpChFont : public XclExpUInt16Record
444 {
445 public:
446     explicit            XclExpChFont( sal_uInt16 nFontIdx );
447 };
448 
449 typedef ScfRef< XclExpChFont > XclExpChFontRef;
450 
451 // ----------------------------------------------------------------------------
452 
453 /** The CHOBJECTLINK record linking a text object to a specific chart object. */
454 class XclExpChObjectLink : public XclExpRecord
455 {
456 public:
457     explicit            XclExpChObjectLink( sal_uInt16 nLinkTarget, const XclChDataPointPos& rPointPos );
458 
459 private:
460     virtual void        WriteBody( XclExpStream& rStrm );
461 
462 private:
463     XclChObjectLink     maData;             /// Contents of the CHOBJECTLINK record.
464 };
465 
466 typedef ScfRef< XclExpChObjectLink > XclExpChObjectLinkRef;
467 
468 // ----------------------------------------------------------------------------
469 
470 /** Additional data label settings in the future record CHFRLABELPROPS. */
471 class XclExpChFrLabelProps : public XclExpChFutureRecordBase
472 {
473 public:
474     explicit            XclExpChFrLabelProps( const XclExpChRoot& rRoot );
475 
476     /** Converts separator and the passed data label flags. */
477     void                Convert(
478                             const ScfPropertySet& rPropSet, bool bShowSeries,
479                             bool bShowCateg, bool bShowValue,
480                             bool bShowPercent, bool bShowBubble );
481 
482 private:
483     virtual void        WriteBody( XclExpStream& rStrm );
484 
485 private:
486     XclChFrLabelProps   maData;             /// Contents of the CHFRLABELPROPS record.
487 };
488 
489 typedef ScfRef< XclExpChFrLabelProps > XclExpChFrLabelPropsRef;
490 
491 // ----------------------------------------------------------------------------
492 
493 /** Base class for objects with font settings. Provides font conversion helper functions. */
494 class XclExpChFontBase
495 {
496 public:
497     virtual             ~XclExpChFontBase();
498 
499     /** Derived classes set font color and color identifier to internal data structures. */
500     virtual void        SetFont( XclExpChFontRef xFont, const Color& rColor, sal_uInt32 nColorId ) = 0;
501     /** Derived classes set text rotation to internal data structures. */
502     virtual void        SetRotation( sal_uInt16 nRotation ) = 0;
503 
504     /** Creates a CHFONT record from the passed font index, calls virtual function SetFont(). */
505     void                ConvertFontBase( const XclExpChRoot& rRoot, sal_uInt16 nFontIdx );
506     /** Creates a CHFONT record from the passed font index, calls virtual function SetFont(). */
507     void                ConvertFontBase( const XclExpChRoot& rRoot, const ScfPropertySet& rPropSet );
508     /** Converts rotation settings, calls virtual function SetRotation(). */
509     void                ConvertRotationBase( const XclExpChRoot& rRoot, const ScfPropertySet& rPropSet, bool bSupportsStacked );
510 };
511 
512 // ----------------------------------------------------------------------------
513 
514 /** Represents the CHTEXT record group containing text object properties.
515 
516     The CHTEXT group consists of: CHTEXT, CHBEGIN, CHFRAMEPOS, CHFONT,
517     CHFORMATRUNS, CHSOURCELINK, CHSTRING, CHFRAME group, CHOBJECTLINK, and CHEND.
518  */
519 class XclExpChText : public XclExpChGroupBase, public XclExpChFontBase
520 {
521 public:
522     typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XTitle >            XTitleRef;
523     typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XRegressionCurve >  XRegressionCurveRef;
524 
525 public:
526     explicit            XclExpChText( const XclExpChRoot& rRoot );
527 
528     /** Sets font color and color identifier to internal data structures. */
529     virtual void        SetFont( XclExpChFontRef xFont, const Color& rColor, sal_uInt32 nColorId );
530     /** Sets text rotation to internal data structures. */
531     virtual void        SetRotation( sal_uInt16 nRotation );
532 
533     /** Converts all text settings of the passed title text object. */
534     void                ConvertTitle( XTitleRef xTitle, sal_uInt16 nTarget );
535     /** Converts all text settings of the passed legend. */
536     void                ConvertLegend( const ScfPropertySet& rPropSet );
537     /** Converts all settings of the passed data point caption text object. */
538     bool                ConvertDataLabel( const ScfPropertySet& rPropSet,
539                             const XclChTypeInfo& rTypeInfo, const XclChDataPointPos& rPointPos );
540     /** Converts all settings of the passed trend line equation box. */
541     void                ConvertTrendLineEquation( const ScfPropertySet& rPropSet, const XclChDataPointPos& rPointPos );
542 
543     /** Returns true, if the string object does not contain any text data. */
HasString() const544     inline bool         HasString() const { return mxSrcLink.is() && mxSrcLink->HasString(); }
545     /** Returns the flags needed for the CHATTACHEDLABEL record. */
546     sal_uInt16          GetAttLabelFlags() const;
547 
548     /** Writes all embedded records. */
549     virtual void        WriteSubRecords( XclExpStream& rStrm );
550 
551 private:
552     virtual void        WriteBody( XclExpStream& rStrm );
553 
554 private:
555     XclChText           maData;             /// Contents of the CHTEXT record.
556     XclExpChFramePosRef mxFramePos;         /// Relative text frame position (CHFRAMEPOS record).
557     XclExpChSourceLinkRef mxSrcLink;        /// Linked data (CHSOURCELINK with CHSTRING record).
558     XclExpChFrameRef    mxFrame;            /// Text object frame properties (CHFRAME group).
559     XclExpChFontRef     mxFont;             /// Index into font buffer (CHFONT record).
560     XclExpChObjectLinkRef mxObjLink;        /// Link target for this text object.
561     XclExpChFrLabelPropsRef mxLabelProps;   /// Extended data label properties (CHFRLABELPROPS record).
562     sal_uInt32          mnTextColorId;      /// Text color identifier.
563 };
564 
565 typedef ScfRef< XclExpChText > XclExpChTextRef;
566 
567 // Data series ================================================================
568 
569 /** The CHMARKERFORMAT record containing data point marker formatting data. */
570 class XclExpChMarkerFormat : public XclExpRecord
571 {
572 public:
573     explicit            XclExpChMarkerFormat( const XclExpChRoot& rRoot );
574 
575     /** Converts symbol properties from the passed property set. */
576     void                Convert( const XclExpChRoot& rRoot,
577                             const ScfPropertySet& rPropSet, sal_uInt16 nFormatIdx );
578     /** Converts symbol properties for stock charts from the passed property set. */
579     void                ConvertStockSymbol( const XclExpChRoot& rRoot,
580                             const ScfPropertySet& rPropSet, bool bCloseSymbol );
581 
582     /** Returns true, if markers are enabled. */
HasMarker() const583     inline bool         HasMarker() const { return maData.mnMarkerType != EXC_CHMARKERFORMAT_NOSYMBOL; }
584     /** Returns true, if border line of markers is visible. */
HasLineColor() const585     inline bool         HasLineColor() const { return !::get_flag( maData.mnFlags, EXC_CHMARKERFORMAT_NOLINE ); }
586     /** Returns true, if fill area of markers is visible. */
HasFillColor() const587     inline bool         HasFillColor() const { return !::get_flag( maData.mnFlags, EXC_CHMARKERFORMAT_NOFILL ); }
588 
589 private:
590     /** Registers marker colors in palette and stores color identifiers. */
591     void                RegisterColors( const XclExpChRoot& rRoot );
592 
593     virtual void        WriteBody( XclExpStream& rStrm );
594 
595 private:
596     XclChMarkerFormat   maData;             /// Contents of the CHMARKERFORMAT record.
597     sal_uInt32          mnLineColorId;      /// Border line color identifier.
598     sal_uInt32          mnFillColorId;      /// Fill color identifier.
599 };
600 
601 typedef ScfRef< XclExpChMarkerFormat > XclExpChMarkerFormatRef;
602 
603 // ----------------------------------------------------------------------------
604 
605 /** The CHPIEFORMAT record containing data point formatting data for pie segments. */
606 class XclExpChPieFormat : public XclExpUInt16Record
607 {
608 public:
609     explicit            XclExpChPieFormat();
610 
611     /** Sets pie segment properties from the passed property set. */
612     void                Convert( const ScfPropertySet& rPropSet );
613 };
614 
615 typedef ScfRef< XclExpChPieFormat > XclExpChPieFormatRef;
616 
617 // ----------------------------------------------------------------------------
618 
619 /** The CH3DDATAFORMAT record containing the bar type in 3D bar charts. */
620 class XclExpCh3dDataFormat : public XclExpRecord
621 {
622 public:
623     explicit            XclExpCh3dDataFormat();
624 
625     /** Sets 3d bar properties from the passed property set. */
626     void                Convert( const ScfPropertySet& rPropSet );
627 
628 private:
629     virtual void        WriteBody( XclExpStream& rStrm );
630 
631 private:
632     XclCh3dDataFormat   maData;             /// Contents of the CH3DDATAFORMAT record.
633 };
634 
635 typedef ScfRef< XclExpCh3dDataFormat > XclExpCh3dDataFormatRef;
636 
637 // ----------------------------------------------------------------------------
638 
639 /** The CHATTACHEDLABEL record that contains the type of a data point label. */
640 class XclExpChAttachedLabel : public XclExpUInt16Record
641 {
642 public:
643     explicit            XclExpChAttachedLabel( sal_uInt16 nFlags );
644 };
645 
646 typedef ScfRef< XclExpChAttachedLabel > XclExpChAttLabelRef;
647 
648 // ----------------------------------------------------------------------------
649 
650 /** Represents the CHDATAFORMAT record group containing data point properties.
651 
652     The CHDATAFORMAT group consists of: CHDATAFORMAT, CHBEGIN, CHFRAME group,
653     CHMARKERFORMAT, CHPIEFORMAT, CH3DDATAFORMAT, CHSERIESFORMAT,
654     CHATTACHEDLABEL, CHEND.
655  */
656 class XclExpChDataFormat : public XclExpChGroupBase, public XclExpChFrameBase
657 {
658 public:
659     explicit            XclExpChDataFormat( const XclExpChRoot& rRoot,
660                             const XclChDataPointPos& rPointPos, sal_uInt16 nFormatIdx );
661 
662     /** Converts the passed data series or data point formatting. */
663     void                ConvertDataSeries( const ScfPropertySet& rPropSet, const XclChExtTypeInfo& rTypeInfo );
664     /** Sets default formatting for a series in a stock chart. */
665     void                ConvertStockSeries( const ScfPropertySet& rPropSet, bool bCloseSymbol );
666     /** Converts line formatting for the specified object (e.g. trend lines, error bars). */
667     void                ConvertLine( const ScfPropertySet& rPropSet, XclChObjectType eObjType );
668 
669     /** Returns true, if this objects describes the formatting of an entire series. */
IsSeriesFormat() const670     inline bool         IsSeriesFormat() const { return maData.maPointPos.mnPointIdx == EXC_CHDATAFORMAT_ALLPOINTS; }
671 
672     /** Writes all embedded records. */
673     virtual void        WriteSubRecords( XclExpStream& rStrm );
674 
675 private:
676     virtual void        WriteBody( XclExpStream& rStrm );
677 
678 private:
679     XclChDataFormat     maData;             /// Contents of the CHDATAFORMAT record.
680     XclExpChMarkerFormatRef mxMarkerFmt;    /// Data point marker (CHMARKERFORMAT record).
681     XclExpChPieFormatRef mxPieFmt;          /// Pie segment format (CHPIEFORMAT record).
682     XclExpRecordRef     mxSeriesFmt;        /// Series properties (CHSERIESFORMAT record).
683     XclExpCh3dDataFormatRef mx3dDataFmt;    /// 3D bar format (CH3DDATAFORMAT record).
684     XclExpChAttLabelRef mxAttLabel;         /// Data point label type (CHATTACHEDLABEL record).
685 };
686 
687 typedef ScfRef< XclExpChDataFormat > XclExpChDataFormatRef;
688 
689 // ----------------------------------------------------------------------------
690 
691 /** Represents the CHSERTRENDLINE record containing settings for a trend line. */
692 class XclExpChSerTrendLine : public XclExpRecord, protected XclExpChRoot
693 {
694 public:
695     typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XRegressionCurve > XRegressionCurveRef;
696 
697 public:
698     explicit            XclExpChSerTrendLine( const XclExpChRoot& rRoot );
699 
700     /** Converts the passed trend line, returns true if trend line type is supported. */
701     bool                Convert( XRegressionCurveRef xRegCurve, sal_uInt16 nSeriesIdx );
702 
703     /** Returns formatting information of the trend line, created in Convert(). */
GetDataFormat() const704     inline XclExpChDataFormatRef GetDataFormat() const { return mxDataFmt; }
705     /** Returns formatting of the equation text box, created in Convert(). */
GetDataLabel() const706     inline XclExpChTextRef GetDataLabel() const { return mxLabel; }
707 
708 private:
709     virtual void        WriteBody( XclExpStream& rStrm );
710 
711 private:
712     XclChSerTrendLine   maData;             /// Contents of the CHSERTRENDLINE record.
713     XclExpChDataFormatRef mxDataFmt;        /// Formatting settings of the trend line.
714     XclExpChTextRef     mxLabel;            /// Formatting of the equation text box.
715 };
716 
717 typedef ScfRef< XclExpChSerTrendLine > XclExpChSerTrendLineRef;
718 
719 // ----------------------------------------------------------------------------
720 
721 /** Represents the CHSERERRORBAR record containing settings for error bars. */
722 class XclExpChSerErrorBar : public XclExpRecord, protected XclExpChRoot
723 {
724 public:
725     explicit            XclExpChSerErrorBar( const XclExpChRoot& rRoot, sal_uInt8 nBarType );
726 
727     /** Converts the passed error bar settings, returns true if error bar type is supported. */
728     bool                Convert( XclExpChSourceLink& rValueLink, sal_uInt16& rnValueCount, const ScfPropertySet& rPropSet );
729 
730 private:
731     virtual void        WriteBody( XclExpStream& rStrm );
732 
733 private:
734     XclChSerErrorBar    maData;             /// Contents of the CHSERERRORBAR record.
735 };
736 
737 typedef ScfRef< XclExpChSerErrorBar > XclExpChSerErrorBarRef;
738 
739 // ----------------------------------------------------------------------------
740 
741 /** Represents the CHSERIES record group describing a data series in a chart.
742 
743     The CHSERIES group consists of: CHSERIES, CHBEGIN, CHSOURCELINK groups,
744     CHDATAFORMAT groups, CHSERGROUP, CHSERPARENT, CHSERERRORBAR,
745     CHSERTRENDLINE, CHEND.
746  */
747 class XclExpChSeries : public XclExpChGroupBase
748 {
749 public:
750     typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDiagram >                      XDiagramRef;
751     typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDataSeries >                   XDataSeriesRef;
752     typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XLabeledDataSequence >    XLabeledDataSeqRef;
753     typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XRegressionCurve >              XRegressionCurveRef;
754 
755 public:
756     explicit            XclExpChSeries( const XclExpChRoot& rRoot, sal_uInt16 nSeriesIdx );
757 
758     /** Converts the passed data series (source links and formatting). */
759     bool                ConvertDataSeries(
760                             XDiagramRef xDiagram, XDataSeriesRef xDataSeries,
761                             const XclChExtTypeInfo& rTypeInfo,
762                             sal_uInt16 nGroupIdx, sal_uInt16 nFormatIdx );
763     /** Converts the passed data series for stock charts. */
764     bool                ConvertStockSeries(
765                             XDataSeriesRef xDataSeries,
766                             const ::rtl::OUString& rValueRole,
767                             sal_uInt16 nGroupIdx, sal_uInt16 nFormatIdx, bool bCloseSymbol );
768     /** Converts the passed error bar settings (called at trend line child series). */
769     bool                ConvertTrendLine( const XclExpChSeries& rParent, XRegressionCurveRef xRegCurve );
770     /** Converts the passed error bar settings (called at error bar child series). */
771     bool                ConvertErrorBar( const XclExpChSeries& rParent, const ScfPropertySet& rPropSet, sal_uInt8 nBarId );
772     /** Converts and inserts category ranges for all inserted series. */
773     void                ConvertCategSequence( XLabeledDataSeqRef xCategSeq );
774 
775     /** Writes all embedded records. */
776     virtual void        WriteSubRecords( XclExpStream& rStrm );
777 
778 private:
779     /** Initializes members of this series to represent a child of the passed series. */
780     void                InitFromParent( const XclExpChSeries& rParent );
781     /** Tries to create trend line series objects (called at parent series). */
782     void                CreateTrendLines( XDataSeriesRef xDataSeries );
783     /** Tries to create positive and negative error bar series objects (called at parent series). */
784     void                CreateErrorBars( const ScfPropertySet& rPropSet,
785                             const ::rtl::OUString& rBarPropName,
786                             sal_uInt8 nPosBarId, sal_uInt8 nNegBarId );
787     /** Tries to create an error bar series object (called at parent series). */
788     void                CreateErrorBar( const ScfPropertySet& rPropSet,
789                             const ::rtl::OUString& rShowPropName, sal_uInt8 nBarId );
790 
791     virtual void        WriteBody( XclExpStream& rStrm );
792 
793 private:
794     typedef XclExpRecordList< XclExpChDataFormat > XclExpChDataFormatList;
795 
796 private:
797     XclChSeries         maData;             /// Contents of the CHSERIES record.
798     XclExpChSourceLinkRef mxTitleLink;      /// Link data for series title.
799     XclExpChSourceLinkRef mxValueLink;      /// Link data for series values.
800     XclExpChSourceLinkRef mxCategLink;      /// Link data for series category names.
801     XclExpChSourceLinkRef mxBubbleLink;     /// Link data for series bubble sizes.
802     XclExpChDataFormatRef mxSeriesFmt;      /// CHDATAFORMAT group for series format.
803     XclExpChDataFormatList maPointFmts;     /// CHDATAFORMAT groups for data point formats.
804     XclExpChSerTrendLineRef mxTrendLine;    /// Trend line settings (CHSERTRENDLINE record).
805     XclExpChSerErrorBarRef mxErrorBar;      /// Error bar settings (CHSERERRORBAR record).
806     sal_uInt16          mnGroupIdx;         /// Chart type group (CHTYPEGROUP group) this series is assigned to.
807     sal_uInt16          mnSeriesIdx;        /// 0-based series index.
808     sal_uInt16          mnParentIdx;        /// 0-based index of parent series (trend lines and error bars).
809 };
810 
811 typedef ScfRef< XclExpChSeries > XclExpChSeriesRef;
812 
813 // Chart type groups ==========================================================
814 
815 /** Represents the chart type record for all supported chart types. */
816 class XclExpChType : public XclExpRecord, protected XclExpChRoot
817 {
818 public:
819     typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDiagram >      XDiagramRef;
820     typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartType >    XChartTypeRef;
821 
822 public:
823     explicit            XclExpChType( const XclExpChRoot& rRoot );
824 
825     /** Converts the passed chart type and the contained data series. */
826     void                Convert( XDiagramRef xDiagram, XChartTypeRef xChartType,
827                             sal_Int32 nApiAxesSetIdx, bool bSwappedAxesSet, bool bHasXLabels );
828     /** Sets stacking mode (standard or percent) for the series in this chart type group. */
829     void                SetStacked( bool bPercent );
830 
831     /** Returns true, if this is object represents a valid chart type. */
IsValidType() const832     inline bool         IsValidType() const { return maTypeInfo.meTypeId != EXC_CHTYPEID_UNKNOWN; }
833     /** Returns the chart type info struct for the contained chart type. */
GetTypeInfo() const834     inline const XclChTypeInfo& GetTypeInfo() const { return maTypeInfo; }
835 
836 private:
837     virtual void        WriteBody( XclExpStream& rStrm );
838 
839 private:
840     XclChType           maData;             /// Contents of the chart type record.
841     XclChTypeInfo       maTypeInfo;         /// Chart type info for the contained type.
842 };
843 
844 // ----------------------------------------------------------------------------
845 
846 /** Represents the CHCHART3D record that contains 3D view settings. */
847 class XclExpChChart3d : public XclExpRecord
848 {
849 public:
850     explicit            XclExpChChart3d();
851 
852     /** Converts 3d settings for the passed chart type. */
853     void                Convert( const ScfPropertySet& rPropSet, bool b3dWallChart );
854     /** Sets flag that the data points are clustered on the X axis. */
SetClustered()855     inline void         SetClustered() { ::set_flag( maData.mnFlags, EXC_CHCHART3D_CLUSTER ); }
856 
857     /** Returns true, if the data points are clustered on the X axis. */
IsClustered() const858     inline bool         IsClustered() const { return ::get_flag( maData.mnFlags, EXC_CHCHART3D_CLUSTER ); }
859 
860 private:
861     virtual void        WriteBody( XclExpStream& rStrm );
862 
863 private:
864     XclChChart3d        maData;             /// Contents of the CHCHART3D record.
865 };
866 
867 typedef ScfRef< XclExpChChart3d > XclExpChChart3dRef;
868 
869 // ----------------------------------------------------------------------------
870 
871 /** Represents the CHLEGEND record group describing the chart legend.
872 
873     The CHLEGEND group consists of: CHLEGEND, CHBEGIN, CHFRAMEPOS, CHFRAME
874     group, CHTEXT group, CHEND.
875  */
876 class XclExpChLegend : public XclExpChGroupBase
877 {
878 public:
879     explicit            XclExpChLegend( const XclExpChRoot& rRoot );
880 
881     /** Converts all legend settings from the passed property set. */
882     void                Convert( const ScfPropertySet& rPropSet );
883 
884     /** Writes all embedded records. */
885     virtual void        WriteSubRecords( XclExpStream& rStrm );
886 
887 private:
888     virtual void        WriteBody( XclExpStream& rStrm );
889 
890 private:
891     XclChLegend         maData;             /// Contents of the CHLEGEND record.
892     XclExpChFramePosRef mxFramePos;         /// Legend frame position (CHFRAMEPOS record).
893     XclExpChTextRef     mxText;             /// Legend text format (CHTEXT group).
894     XclExpChFrameRef    mxFrame;            /// Legend frame format (CHFRAME group).
895 };
896 
897 typedef ScfRef< XclExpChLegend > XclExpChLegendRef;
898 
899 // ----------------------------------------------------------------------------
900 
901 /** Represents the CHDROPBAR record group describing pos/neg bars in line charts.
902 
903     The CHDROPBAR group consists of: CHDROPBAR, CHBEGIN, CHLINEFORMAT,
904     CHAREAFORMAT, CHESCHERFORMAT group, CHEND.
905  */
906 class XclExpChDropBar : public XclExpChGroupBase, public XclExpChFrameBase
907 {
908 public:
909     explicit            XclExpChDropBar( const XclExpChRoot& rRoot, XclChObjectType eObjType );
910 
911     /** Converts and writes the contained frame data to the passed property set. */
912     void                Convert( const ScfPropertySet& rPropSet );
913 
914     /** Writes all embedded records. */
915     virtual void        WriteSubRecords( XclExpStream& rStrm );
916 
917 private:
918     virtual void        WriteBody( XclExpStream& rStrm );
919 
920 private:
921     XclChObjectType     meObjType;          /// Type of the dropbar.
922     sal_uInt16          mnBarDist;          /// Distance between bars (CHDROPBAR record).
923 };
924 
925 typedef ScfRef< XclExpChDropBar > XclExpChDropBarRef;
926 
927 // ----------------------------------------------------------------------------
928 
929 /** Represents the CHTYPEGROUP record group describing a group of series.
930 
931     The CHTYPEGROUP group consists of: CHTYPEGROUP, CHBEGIN, a chart type
932     record (e.g. CHBAR, CHLINE, CHAREA, CHPIE, ...), CHCHART3D, CHLEGEND group,
933     CHDROPBAR groups, CHCHARTLINE groups (CHCHARTLINE with CHLINEFORMAT),
934     CHDATAFORMAT group, CHEND.
935  */
936 class XclExpChTypeGroup : public XclExpChGroupBase
937 {
938 public:
939     typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDiagram >                      XDiagramRef;
940     typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartType >                    XChartTypeRef;
941     typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDataSeries >                   XDataSeriesRef;
942     typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XLabeledDataSequence >    XLabeledDataSeqRef;
943 
944 public:
945     explicit            XclExpChTypeGroup( const XclExpChRoot& rRoot, sal_uInt16 nGroupIdx );
946 
947     /** Converts the passed chart type to Excel type settings. */
948     void                ConvertType( XDiagramRef xDiagram, XChartTypeRef xChartType,
949                             sal_Int32 nApiAxesSetIdx, bool b3dChart, bool bSwappedAxesSet, bool bHasXLabels );
950     /** Converts and inserts all series from the passed chart type. */
951     void                ConvertSeries( XDiagramRef xDiagram, XChartTypeRef xChartType,
952                             sal_Int32 nGroupAxesSetIdx, bool bPercent, bool bConnectorLines );
953     /** Converts and inserts category ranges for all inserted series. */
954     void                ConvertCategSequence( XLabeledDataSeqRef xCategSeq );
955     /** Creates a legend object and converts all legend settings. */
956     void                ConvertLegend( const ScfPropertySet& rPropSet );
957 
958     /** Returns true, if this chart type group contains at least one valid series. */
IsValidGroup() const959     inline bool         IsValidGroup() const { return !maSeries.IsEmpty() && maType.IsValidType(); }
960     /** Returns the index of this chart type group format. */
GetGroupIdx() const961     inline sal_uInt16   GetGroupIdx() const { return maData.mnGroupIdx; }
962     /** Returns the chart type info struct for the contained chart type. */
GetTypeInfo() const963     inline const XclChExtTypeInfo& GetTypeInfo() const { return maTypeInfo; }
964     /** Returns true, if the chart is three-dimensional. */
Is3dChart() const965     inline bool         Is3dChart() const { return maTypeInfo.mb3dChart; }
966     /** Returns true, if chart type supports wall and floor format. */
Is3dWallChart() const967     inline bool         Is3dWallChart() const { return Is3dChart() && (maTypeInfo.meTypeCateg != EXC_CHTYPECATEG_PIE); }
968     /** Returns true, if the series in this chart type group are ordered on the Z axis. */
Is3dDeepChart() const969     inline bool         Is3dDeepChart() const { return Is3dWallChart() && mxChart3d.is() && !mxChart3d->IsClustered(); }
970     /** Returns true, if this chart type can be combined with other types. */
IsCombinable2d() const971     inline bool         IsCombinable2d() const { return !Is3dChart() && maTypeInfo.mbCombinable2d; }
972 
973     /** Writes all embedded records. */
974     virtual void        WriteSubRecords( XclExpStream& rStrm );
975 
976 private:
977     /** Returns an unused format index to be used for the next created series. */
978     sal_uInt16          GetFreeFormatIdx() const;
979     /** Creates all data series of any chart type except stock charts. */
980     void                CreateDataSeries( XDiagramRef xDiagram,
981                             XDataSeriesRef xDataSeries );
982     /** Creates all data series of a stock chart. */
983     void                CreateAllStockSeries( XChartTypeRef xChartType,
984                             XDataSeriesRef xDataSeries );
985     /** Creates a single data series of a stock chart. */
986     bool                CreateStockSeries( XDataSeriesRef xDataSeries,
987                             const ::rtl::OUString& rValueRole, bool bCloseSymbol );
988 
989     virtual void        WriteBody( XclExpStream& rStrm );
990 
991 private:
992     typedef XclExpRecordList< XclExpChSeries >          XclExpChSeriesList;
993     typedef ScfRefMap< sal_uInt16, XclExpChLineFormat > XclExpChLineFormatMap;
994 
995     XclChTypeGroup      maData;             /// Contents of the CHTYPEGROUP record.
996     XclExpChType        maType;             /// Chart type (e.g. CHBAR, CHLINE, ...).
997     XclChExtTypeInfo    maTypeInfo;         /// Extended chart type info.
998     XclExpChSeriesList  maSeries;           /// List of series data (CHSERIES groups).
999     XclExpChChart3dRef  mxChart3d;          /// 3D settings (CHCHART3D record).
1000     XclExpChLegendRef   mxLegend;           /// Chart legend (CHLEGEND group).
1001     XclExpChDropBarRef  mxUpBar;            /// White dropbars (CHDROPBAR group).
1002     XclExpChDropBarRef  mxDownBar;          /// Black dropbars (CHDROPBAR group).
1003     XclExpChLineFormatMap maChartLines;     /// Global line formats (CHCHARTLINE group).
1004 };
1005 
1006 typedef ScfRef< XclExpChTypeGroup > XclExpChTypeGroupRef;
1007 
1008 // Axes =======================================================================
1009 
1010 class XclExpChLabelRange : public XclExpRecord, protected XclExpChRoot
1011 {
1012 public:
1013     explicit            XclExpChLabelRange( const XclExpChRoot& rRoot );
1014 
1015     /** Converts category axis scaling settings. */
1016     void                Convert( const ::com::sun::star::chart2::ScaleData& rScaleData,
1017                             const ScfPropertySet& rChart1Axis, bool bMirrorOrient );
1018     /** Converts position settings of a crossing axis at this axis. */
1019     void                ConvertAxisPosition( const ScfPropertySet& rPropSet );
1020     /** Sets flag for tickmark position between categories or on categories. */
SetTicksBetweenCateg(bool bTicksBetween)1021     inline void         SetTicksBetweenCateg( bool bTicksBetween )
1022                             { ::set_flag( maLabelData.mnFlags, EXC_CHLABELRANGE_BETWEEN, bTicksBetween ); }
1023 
1024 private:
1025     virtual void        Save( XclExpStream& rStrm );
1026     virtual void        WriteBody( XclExpStream& rStrm );
1027 
1028 private:
1029     XclChLabelRange     maLabelData;        /// Contents of the CHLABELRANGE record.
1030     XclChDateRange      maDateData;         /// Contents of the CHDATERANGE record.
1031 };
1032 
1033 typedef ScfRef< XclExpChLabelRange > XclExpChLabelRangeRef;
1034 
1035 // ----------------------------------------------------------------------------
1036 
1037 class XclExpChValueRange : public XclExpRecord, protected XclExpChRoot
1038 {
1039 public:
1040     explicit            XclExpChValueRange( const XclExpChRoot& rRoot );
1041 
1042     /** Converts value axis scaling settings. */
1043     void                Convert( const ::com::sun::star::chart2::ScaleData& rScaleData );
1044     /** Converts position settings of a crossing axis at this axis. */
1045     void                ConvertAxisPosition( const ScfPropertySet& rPropSet );
1046 
1047 private:
1048     virtual void        WriteBody( XclExpStream& rStrm );
1049 
1050 private:
1051     XclChValueRange     maData;             /// Contents of the CHVALUERANGE record.
1052 };
1053 
1054 typedef ScfRef< XclExpChValueRange > XclExpChValueRangeRef;
1055 
1056 // ----------------------------------------------------------------------------
1057 
1058 class XclExpChTick : public XclExpRecord, protected XclExpChRoot
1059 {
1060 public:
1061     explicit            XclExpChTick( const XclExpChRoot& rRoot );
1062 
1063     /** Converts axis tick mark settings. */
1064     void                Convert( const ScfPropertySet& rPropSet, const XclChExtTypeInfo& rTypeInfo, sal_uInt16 nAxisType );
1065     /** Sets font color and color identifier to internal data structures. */
1066     void                SetFontColor( const Color& rColor, sal_uInt32 nColorId );
1067     /** Sets text rotation to internal data structures. */
1068     void                SetRotation( sal_uInt16 nRotation );
1069 
1070 private:
1071     virtual void        WriteBody( XclExpStream& rStrm );
1072 
1073 private:
1074     XclChTick           maData;             /// Contents of the CHTICK record.
1075     sal_uInt32          mnTextColorId;      /// Axis labels text color identifier.
1076 };
1077 
1078 typedef ScfRef< XclExpChTick > XclExpChTickRef;
1079 
1080 // ----------------------------------------------------------------------------
1081 
1082 /** Represents the CHAXIS record group describing an entire chart axis.
1083 
1084     The CHAXIS group consists of: CHAXIS, CHBEGIN, CHLABELRANGE, CHEXTRANGE,
1085     CHVALUERANGE, CHFORMAT, CHTICK, CHFONT, CHAXISLINE groups (CHAXISLINE with
1086     CHLINEFORMAT, CHAREAFORMAT, and CHESCHERFORMAT group), CHEND.
1087  */
1088 class XclExpChAxis : public XclExpChGroupBase, public XclExpChFontBase
1089 {
1090 public:
1091     typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDiagram >  XDiagramRef;
1092     typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis >     XAxisRef;
1093     typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart::XAxis >      XChart1AxisRef;
1094 
1095 public:
1096     explicit            XclExpChAxis( const XclExpChRoot& rRoot, sal_uInt16 nAxisType );
1097 
1098     /** Sets font color and color identifier to internal data structures. */
1099     virtual void        SetFont( XclExpChFontRef xFont, const Color& rColor, sal_uInt32 nColorId );
1100     /** Sets text rotation to internal data structures. */
1101     virtual void        SetRotation( sal_uInt16 nRotation );
1102 
1103     /** Converts formatting and scaling settings from the passed axis. */
1104     void                Convert( XAxisRef xAxis, XAxisRef xCrossingAxis,
1105                             XChart1AxisRef xChart1Axis, const XclChExtTypeInfo& rTypeInfo );
1106     /** Converts and writes 3D wall/floor properties from the passed diagram. */
1107     void                ConvertWall( XDiagramRef xDiagram );
1108 
1109     /** Returns the type of this axis. */
GetAxisType() const1110     inline sal_uInt16   GetAxisType() const { return maData.mnType; }
1111     /** Returns the axis dimension index used by the chart API. */
GetApiAxisDimension() const1112     inline sal_Int32    GetApiAxisDimension() const { return maData.GetApiAxisDimension(); }
1113 
1114     /** Writes all embedded records. */
1115     virtual void        WriteSubRecords( XclExpStream& rStrm );
1116 
1117 private:
1118     virtual void        WriteBody( XclExpStream& rStrm );
1119 
1120 private:
1121     XclChAxis           maData;             /// Contents of the CHAXIS record.
1122     XclExpChLabelRangeRef mxLabelRange;     /// Category scaling (CHLABELRANGE record).
1123     XclExpChValueRangeRef mxValueRange;     /// Value scaling (CHVALUERANGE record).
1124     XclExpChTickRef     mxTick;             /// Axis ticks (CHTICK record).
1125     XclExpChFontRef     mxFont;             /// Index into font buffer (CHFONT record).
1126     XclExpChLineFormatRef mxAxisLine;       /// Axis line format (CHLINEFORMAT record).
1127     XclExpChLineFormatRef mxMajorGrid;      /// Major grid line format (CHLINEFORMAT record).
1128     XclExpChLineFormatRef mxMinorGrid;      /// Minor grid line format (CHLINEFORMAT record).
1129     XclExpChFrameRef    mxWallFrame;        /// Wall/floor format (sub records of CHFRAME group).
1130     sal_uInt16          mnNumFmtIdx;        /// Index into number format buffer (CHFORMAT record).
1131 };
1132 
1133 typedef ScfRef< XclExpChAxis > XclExpChAxisRef;
1134 
1135 // ----------------------------------------------------------------------------
1136 
1137 /** Represents the CHAXESSET record group describing an axes set (X/Y/Z axes).
1138 
1139     The CHAXESSET group consists of: CHAXESSET, CHBEGIN, CHFRAMEPOS, CHAXIS
1140     groups, CHTEXT groups, CHPLOTFRAME group (CHPLOTFRAME with CHFRAME group),
1141     CHTYPEGROUP group, CHEND.
1142  */
1143 class XclExpChAxesSet : public XclExpChGroupBase
1144 {
1145 public:
1146     typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDiagram >          XDiagramRef;
1147     typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XCoordinateSystem > XCoordSystemRef;
1148 
1149 public:
1150     explicit            XclExpChAxesSet( const XclExpChRoot& rRoot, sal_uInt16 nAxesSetId );
1151 
1152     /** Converts the passed diagram to chart record data.
1153         @return  First unused chart type group index. */
1154     sal_uInt16          Convert( XDiagramRef xDiagram, sal_uInt16 nFirstGroupIdx );
1155 
1156     /** Returns true, if this axes set exists (returns false if this is a dummy object). */
IsValidAxesSet() const1157     inline bool         IsValidAxesSet() const { return !maTypeGroups.IsEmpty(); }
1158     /** Returns the index of the axes set (primary/secondary). */
GetAxesSetId() const1159     inline sal_uInt16   GetAxesSetId() const { return maData.mnAxesSetId; }
1160     /** Returns the axes set index used by the chart API. */
GetApiAxesSetIndex() const1161     inline sal_Int32    GetApiAxesSetIndex() const { return maData.GetApiAxesSetIndex(); }
1162     /** Returns true, if the chart is three-dimensional. */
1163     bool                Is3dChart() const;
1164 
1165     /** Writes all embedded records. */
1166     virtual void        WriteSubRecords( XclExpStream& rStrm );
1167 
1168 private:
1169     /** Returns first inserted chart type group. */
1170     XclExpChTypeGroupRef GetFirstTypeGroup() const;
1171     /** Returns last inserted chart type group. */
1172     XclExpChTypeGroupRef GetLastTypeGroup() const;
1173 
1174     /** Converts a complete axis object including axis title. */
1175     void                ConvertAxis( XclExpChAxisRef& rxChAxis, sal_uInt16 nAxisType,
1176                             XclExpChTextRef& rxChAxisTitle, sal_uInt16 nTitleTarget,
1177                             XCoordSystemRef xCoordSystem, const XclChExtTypeInfo& rTypeInfo,
1178                             sal_Int32 nCrossingAxisDim );
1179 
1180     virtual void        WriteBody( XclExpStream& rStrm );
1181 
1182 private:
1183     typedef XclExpRecordList< XclExpChTypeGroup > XclExpChTypeGroupList;
1184 
1185     XclChAxesSet        maData;             /// Contents of the CHAXESSET record.
1186     XclExpChFramePosRef mxFramePos;         /// Outer plot area position (CHFRAMEPOS record).
1187     XclExpChAxisRef     mxXAxis;            /// The X axis (CHAXIS group).
1188     XclExpChAxisRef     mxYAxis;            /// The Y axis (CHAXIS group).
1189     XclExpChAxisRef     mxZAxis;            /// The Z axis (CHAXIS group).
1190     XclExpChTextRef     mxXAxisTitle;       /// The X axis title (CHTEXT group).
1191     XclExpChTextRef     mxYAxisTitle;       /// The Y axis title (CHTEXT group).
1192     XclExpChTextRef     mxZAxisTitle;       /// The Z axis title (CHTEXT group).
1193     XclExpChFrameRef    mxPlotFrame;        /// Plot area (CHPLOTFRAME group).
1194     XclExpChTypeGroupList maTypeGroups;     /// Chart type groups (CHTYPEGROUP group).
1195 };
1196 
1197 typedef ScfRef< XclExpChAxesSet > XclExpChAxesSetRef;
1198 
1199 // The chart object ===========================================================
1200 
1201 /** Represents the CHCHART record group describing the chart contents.
1202 
1203     The CHCHART group consists of: CHCHART, CHBEGIN, SCL, CHPLOTGROWTH, CHFRAME
1204     group, CHSERIES groups, CHPROPERTIES, CHDEFAULTTEXT groups (CHDEFAULTTEXT
1205     with CHTEXT groups), CHUSEDAXESSETS, CHAXESSET groups, CHTEXT groups, CHEND.
1206  */
1207 class XclExpChChart : public XclExpChGroupBase
1208 {
1209 public:
1210     typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument > XChartDocRef;
1211 
1212 public:
1213     explicit            XclExpChChart( const XclExpRoot& rRoot,
1214                             XChartDocRef xChartDoc, const Rectangle& rChartRect );
1215 
1216     /** Creates, registers and returns a new data series object. */
1217     XclExpChSeriesRef   CreateSeries();
1218     /** Removes the last created data series object from the series list. */
1219     void                RemoveLastSeries();
1220     /** Stores a CHTEXT group that describes a data point label. */
1221     void                SetDataLabel( XclExpChTextRef xText );
1222     /** Sets the plot area position and size to manual mode. */
1223     void                SetManualPlotArea();
1224 
1225     /** Writes all embedded records. */
1226     virtual void        WriteSubRecords( XclExpStream& rStrm );
1227 
1228 private:
1229     virtual void        WriteBody( XclExpStream& rStrm );
1230 
1231 private:
1232     typedef XclExpRecordList< XclExpChSeries >  XclExpChSeriesList;
1233     typedef XclExpRecordList< XclExpChText >    XclExpChTextList;
1234 
1235     XclChRectangle      maRect;             /// Position of the chart on the sheet (CHCHART record).
1236     XclExpChSeriesList  maSeries;           /// List of series data (CHSERIES groups).
1237     XclExpChFrameRef    mxFrame;            /// Chart frame format (CHFRAME group).
1238     XclChProperties     maProps;            /// Chart properties (CHPROPERTIES record).
1239     XclExpChAxesSetRef  mxPrimAxesSet;      /// Primary axes set (CHAXESSET group).
1240     XclExpChAxesSetRef  mxSecnAxesSet;      /// Secondary axes set (CHAXESSET group).
1241     XclExpChTextRef     mxTitle;            /// Chart title (CHTEXT group).
1242     XclExpChTextList    maLabels;           /// Data point labels (CHTEXT groups).
1243 };
1244 
1245 // ----------------------------------------------------------------------------
1246 
1247 /** Represents the group of DFF and OBJ records containing all drawing shapes
1248     embedded in the chart object.
1249  */
1250 class XclExpChartDrawing : public XclExpRecordBase, protected XclExpRoot
1251 {
1252 public:
1253     explicit            XclExpChartDrawing(
1254                             const XclExpRoot& rRoot,
1255                             const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& rxModel,
1256                             const Size& rChartSize );
1257     virtual             ~XclExpChartDrawing();
1258 
1259     virtual void        Save( XclExpStream& rStrm );
1260 
1261 private:
1262     ScfRef< XclExpObjectManager > mxObjMgr;
1263     ScfRef< XclExpRecordBase > mxObjRecs;
1264 };
1265 
1266 // ----------------------------------------------------------------------------
1267 
1268 /** Represents the entire chart substream (all records in BOF/EOF block). */
1269 class XclExpChart : public XclExpSubStream, protected XclExpRoot
1270 {
1271 public:
1272     typedef ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > XModelRef;
1273 
1274 public:
1275     explicit            XclExpChart( const XclExpRoot& rRoot,
1276                             XModelRef xModel, const Rectangle& rChartRect );
1277 };
1278 
1279 // ============================================================================
1280 
1281 #endif
1282 
1283