xref: /aoo41x/main/sc/source/filter/inc/xichart.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_XICHART_HXX
25 #define SC_XICHART_HXX
26 
27 #include <vector>
28 #include <map>
29 #include <set>
30 #include <list>
31 
32 #include <svl/itemset.hxx>
33 
34 #include "rangelst.hxx"
35 #include "token.hxx"
36 #include "xlchart.hxx"
37 #include "xlstyle.hxx"
38 #include "xiescher.hxx"
39 #include "xistring.hxx"
40 
41 namespace com { namespace sun { namespace star {
42     namespace awt
43     {
44         struct Rectangle;
45     }
46     namespace frame
47     {
48         class XModel;
49     }
50     namespace drawing
51     {
52         class XShape;
53     }
54     namespace chart2
55     {
56         struct ScaleData;
57         class XChartDocument;
58         class XDiagram;
59         class XCoordinateSystem;
60         class XChartType;
61         class XDataSeries;
62         class XRegressionCurve;
63         class XAxis;
64         class XLegend;
65         class XTitle;
66         class XFormattedString;
67         namespace data
68         {
69             class XDataProvider;
70             class XDataSequence;
71             class XLabeledDataSequence;
72         }
73     }
74 } } }
75 
76 struct XclObjLineData;
77 struct XclObjFillData;
78 
79 // Common =====================================================================
80 
81 class ScfProgressBar;
82 struct XclImpChRootData;
83 class XclImpChChart;
84 class ScTokenArray;
85 
86 /** Base class for complex chart classes, provides access to other components of the chart. */
87 class XclImpChRoot : public XclImpRoot
88 {
89 public:
90     typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument > XChartDocRef;
91 
92 public:
93     explicit            XclImpChRoot( const XclImpRoot& rRoot, XclImpChChart& rChartData );
94     virtual             ~XclImpChRoot();
95 
96     /** Returns this root instance - for code readability in derived classes. */
GetChRoot() const97     inline const XclImpChRoot& GetChRoot() const { return *this; }
98     /** Returns a reference to the parent chart data object. */
99     XclImpChChart&      GetChartData() const;
100     /** Returns chart type info for a unique chart type identifier. */
101     const XclChTypeInfo& GetChartTypeInfo( XclChTypeId eType ) const;
102     /** Returns the first fitting chart type info for an Excel chart type record identifier. */
103     const XclChTypeInfo& GetChartTypeInfo( sal_uInt16 nRecId ) const;
104     /** Returns an info struct about auto formatting for the passed object type. */
105     const XclChFormatInfo& GetFormatInfo( XclChObjectType eObjType ) const;
106 
107     /** Returns the default text color for charts. */
108     Color               GetFontAutoColor() const;
109     /** Returns the automatic line color of linear series. */
110     Color               GetSeriesLineAutoColor( sal_uInt16 nFormatIdx ) const;
111     /** Returns the automatic fill color of filled series. */
112     Color               GetSeriesFillAutoColor( sal_uInt16 nFormatIdx ) const;
113 
114     /** Starts the API chart document conversion. Must be called once before all API conversion. */
115     void                InitConversion( XChartDocRef xChartDoc, const Rectangle& rChartRect ) const;
116     /** Finishes the API chart document conversion. Must be called once after all API conversion. */
117     void                FinishConversion( XclImpDffConverter& rDffConv ) const;
118 
119     /** Returns the data provider for the chart document. */
120     ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataProvider >
121                         GetDataProvider() const;
122     /** Returns the drawing shape interface of the specified title object. */
123     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
124                         GetTitleShape( const XclChTextKey& rTitleKey ) const;
125 
126     /** Converts the passed horizontal coordinate from Excel chart units into 1/100 mm. */
127     sal_Int32           CalcHmmFromChartX( sal_Int32 nPosX ) const;
128     /** Converts the passed vertical coordinate from Excel chart units into 1/100 mm. */
129     sal_Int32           CalcHmmFromChartY( sal_Int32 nPosY ) const;
130     /** Converts the passed rectangle from Excel chart units into 1/100 mm. */
131     ::com::sun::star::awt::Rectangle CalcHmmFromChartRect( const XclChRectangle& rRect ) const;
132 
133     /** Converts the passed horizontal coordinate from 1/100 mm into a relative position. */
134     double              CalcRelativeFromHmmX( sal_Int32 nPosX ) const;
135     /** Converts the passed vertical coordinate from 1/100 mm into a relative position. */
136     double              CalcRelativeFromHmmY( sal_Int32 nPosY ) const;
137 
138     /** Converts the passed horizontal coordinate from Excel chart units into a relative position. */
139     double              CalcRelativeFromChartX( sal_Int32 nPosX ) const;
140     /** Converts the passed vertical coordinate from Excel chart units into a relative position. */
141     double              CalcRelativeFromChartY( sal_Int32 nPosY ) const;
142 
143     /** Writes all line properties to the passed property set. */
144     void                ConvertLineFormat(
145                             ScfPropertySet& rPropSet,
146                             const XclChLineFormat& rLineFmt,
147                             XclChPropertyMode ePropMode ) const;
148     /** Writes solid area properties to the passed property set. */
149     void                ConvertAreaFormat(
150                             ScfPropertySet& rPropSet,
151                             const XclChAreaFormat& rAreaFmt,
152                             XclChPropertyMode ePropMode ) const;
153     /** Writes gradient or bitmap area properties to the passed property set. */
154     void                ConvertEscherFormat(
155                             ScfPropertySet& rPropSet,
156                             const XclChEscherFormat& rEscherFmt,
157                             const XclChPicFormat* pPicFmt,
158                             sal_uInt32 nDffFillType,
159                             XclChPropertyMode ePropMode ) const;
160     /** Writes font properties to the passed property set. */
161     void                ConvertFont(
162                             ScfPropertySet& rPropSet,
163                             sal_uInt16 nFontIdx,
164                             const Color* pFontColor = 0 ) const;
165 
166     /** Writes the pie rotation property for the passed angle. */
167     static void         ConvertPieRotation(
168                             ScfPropertySet& rPropSet,
169                             sal_uInt16 nAngle );
170 
171 private:
172     typedef ScfRef< XclImpChRootData > XclImpChRootDataRef;
173     XclImpChRootDataRef mxChData;           /// Reference to the root data object.
174 };
175 
176 // ----------------------------------------------------------------------------
177 
178 /** Base class for chart record groups. Provides helper functions to read sub records.
179 
180     A chart record group consists of a header record, followed by a CHBEGIN
181     record, followed by group sub records, and finished with a CHEND record.
182  */
183 class XclImpChGroupBase
184 {
185 public:
186     virtual             ~XclImpChGroupBase();
187 
188     /** Reads the entire record group.
189         @descr  First calls ReadHeaderRecord() to read the contents of the
190             header record. Then tries to read the sub records. If next record
191             is a CHBEGIN record, ReadSubRecord() is called for each following
192             record until a CHEND record is found. */
193     void                ReadRecordGroup( XclImpStream& rStrm );
194 
195     /** Helper to skip a CHBEGIN/CHEND block, includes nested blocks. */
196     static void         SkipBlock( XclImpStream& rStrm );
197 
198     /** Derived classes implement to read the group header record. */
199     virtual void        ReadHeaderRecord( XclImpStream& rStrm ) = 0;
200     /** Derived classes implement to read a record from the group. */
201     virtual void        ReadSubRecord( XclImpStream& rStrm ) = 0;
202 };
203 
204 // Frame formatting ===========================================================
205 
206 class XclImpChFramePos
207 {
208 public:
209     /** Reads the CHFRAMEPOS record (frame position and size). */
210     void                ReadChFramePos( XclImpStream& rStrm );
211 
212     /** Returns read-only access to the imported frame position data. */
GetFramePosData() const213     inline const XclChFramePos& GetFramePosData() const { return maData; }
214 
215 private:
216     XclChFramePos       maData;             /// Position of the frame.
217 };
218 
219 typedef ScfRef< XclImpChFramePos > XclImpChFramePosRef;
220 
221 // ----------------------------------------------------------------------------
222 
223 /** The CHLINEFORMAT record containing line formatting data. */
224 class XclImpChLineFormat
225 {
226 public:
227     /** Creates a new line format object with automatic formatting. */
XclImpChLineFormat()228     inline explicit     XclImpChLineFormat() {}
229     /** Creates a new line format object with the passed formatting. */
XclImpChLineFormat(const XclChLineFormat & rLineFmt)230     inline explicit     XclImpChLineFormat( const XclChLineFormat& rLineFmt ) : maData( rLineFmt ) {}
231 
232     /** Reads the CHLINEFORMAT record (basic line properties). */
233     void                ReadChLineFormat( XclImpStream& rStrm );
234 
235     /** Returns true, if the line format is set to automatic. */
IsAuto() const236     inline bool         IsAuto() const { return ::get_flag( maData.mnFlags, EXC_CHLINEFORMAT_AUTO ); }
237     /** Returns true, if the line style is set to something visible. */
HasLine() const238     inline bool         HasLine() const { return IsAuto() || (maData.mnPattern != EXC_CHLINEFORMAT_NONE); }
239     /** Returns the line width of this line format (returns 'single', if the line is invisible). */
GetWeight() const240     inline sal_Int16    GetWeight() const { return (IsAuto() || !HasLine()) ? EXC_CHLINEFORMAT_SINGLE : maData.mnWeight; }
241     /** Returns true, if the "show axis" flag is set. */
IsShowAxis() const242     inline bool         IsShowAxis() const { return ::get_flag( maData.mnFlags, EXC_CHLINEFORMAT_SHOWAXIS ); }
243 
244     /** Converts and writes the contained data to the passed property set. */
245     void                Convert( const XclImpChRoot& rRoot,
246                             ScfPropertySet& rPropSet, XclChObjectType eObjType,
247                             sal_uInt16 nFormatIdx = EXC_CHDATAFORMAT_UNKNOWN ) const;
248 
249 private:
250     XclChLineFormat     maData;             /// Contents of the CHLINEFORMAT record.
251 };
252 
253 typedef ScfRef< XclImpChLineFormat > XclImpChLineFormatRef;
254 
255 // ----------------------------------------------------------------------------
256 
257 /** The CHAREAFORMAT record containing simple area formatting data (solid or patterns). */
258 class XclImpChAreaFormat
259 {
260 public:
261     /** Creates a new area format object with automatic formatting. */
XclImpChAreaFormat()262     inline explicit     XclImpChAreaFormat() {}
263     /** Creates a new area format object with the passed formatting. */
XclImpChAreaFormat(const XclChAreaFormat & rAreaFmt)264     inline explicit     XclImpChAreaFormat( const XclChAreaFormat& rAreaFmt ) : maData( rAreaFmt ) {}
265 
266     /** Reads the CHAREAFORMAT record (basic fill properties, e.g. transparent or colored). */
267     void                ReadChAreaFormat( XclImpStream& rStrm );
268 
269     /** Returns true, if the area format is set to automatic. */
IsAuto() const270     inline bool         IsAuto() const { return ::get_flag( maData.mnFlags, EXC_CHAREAFORMAT_AUTO ); }
271     /** Returns true, if the area style is set to something visible. */
HasArea() const272     inline bool         HasArea() const { return IsAuto() || (maData.mnPattern != EXC_PATT_NONE); }
273 
274     /** Converts and writes the contained data to the passed property set. */
275     void                Convert( const XclImpChRoot& rRoot,
276                             ScfPropertySet& rPropSet, XclChObjectType eObjType,
277                             sal_uInt16 nFormatIdx = EXC_CHDATAFORMAT_UNKNOWN ) const;
278 
279 private:
280     XclChAreaFormat     maData;             /// Contents of the CHAREAFORMAT record.
281 };
282 
283 typedef ScfRef< XclImpChAreaFormat > XclImpChAreaFormatRef;
284 
285 // ----------------------------------------------------------------------------
286 
287 /** The CHESCHERFORMAT record containing complex area formatting data (bitmaps, hatches). */
288 class XclImpChEscherFormat : public XclImpChGroupBase
289 {
290 public:
291     explicit            XclImpChEscherFormat( const XclImpRoot& rRoot );
292 
293     /** Reads the CHESCHERFORMAT record (complex fill data) (called by base class). */
294     virtual void        ReadHeaderRecord( XclImpStream& rStrm );
295     /** Reads a record from the CHESCHERFORMAT group (called by base class). */
296     virtual void        ReadSubRecord( XclImpStream& rStrm );
297 
298     /** Converts and writes the contained data to the passed property set. */
299     void                Convert( const XclImpChRoot& rRoot, ScfPropertySet& rPropSet,
300                             XclChObjectType eObjType, bool bUsePicFmt ) const;
301 
302 private:
303     XclChEscherFormat   maData;             /// Fill properties for complex areas (CHESCHERFORMAT record).
304     XclChPicFormat      maPicFmt;           /// Image options, e.g. stretched, stacked (CHPICFORMAT record).
305     sal_uInt32          mnDffFillType;      /// Fill type imported from the DFF property set.
306 };
307 
308 typedef ScfRef< XclImpChEscherFormat > XclImpChEscherFormatRef;
309 
310 // ----------------------------------------------------------------------------
311 
312 /** Base class for record groups containing frame formatting.
313 
314     Frame formatting can be part of several record groups, e.g. CHFRAME,
315     CHDATAFORMAT, CHDROPBAR. It consists of CHLINEFORMAT, CHAREAFORMAT, and
316     CHESCHERFORMAT group.
317  */
318 class XclImpChFrameBase : public XclImpChGroupBase
319 {
320 public:
321     /** Creates a new frame object without internal formatting objects. */
XclImpChFrameBase()322     inline explicit     XclImpChFrameBase() {}
323     /** Creates a new frame object with specific default formatting. */
324     explicit            XclImpChFrameBase( const XclChFormatInfo& rFmtInfo );
325 
326     /** Reads a frame formatting record (called by base class). */
327     virtual void        ReadSubRecord( XclImpStream& rStrm );
328 
329     /** Returns true, if the line format is set to automatic. */
IsAutoLine() const330     inline bool         IsAutoLine() const { return !mxLineFmt || mxLineFmt->IsAuto(); }
331     /** Returns true, if the line style is set to something visible. */
HasLine() const332     inline bool         HasLine() const { return IsAutoLine() || mxLineFmt->HasLine(); }
333     /** Returns the line weight used for this frame. */
GetLineWeight() const334     inline sal_Int16    GetLineWeight() const { return mxLineFmt.is() ? mxLineFmt->GetWeight() : EXC_CHLINEFORMAT_SINGLE; }
335 
336     /** Returns true, if the area format is set to automatic. */
IsAutoArea() const337     inline bool         IsAutoArea() const { return !mxEscherFmt && (!mxAreaFmt || mxAreaFmt->IsAuto()); }
338     /** Returns true, if the area style is set to something visible. */
HasArea() const339     inline bool         HasArea() const { return mxEscherFmt.is() || IsAutoArea() || mxAreaFmt->HasArea(); }
340 
341 protected:
342     /** Converts and writes the contained line formatting to the passed property set. */
343     void                ConvertLineBase( const XclImpChRoot& rRoot,
344                             ScfPropertySet& rPropSet, XclChObjectType eObjType,
345                             sal_uInt16 nFormatIdx = EXC_CHDATAFORMAT_UNKNOWN ) const;
346     /** Converts and writes the contained area formatting to the passed property set. */
347     void                ConvertAreaBase( const XclImpChRoot& rRoot,
348                             ScfPropertySet& rPropSet, XclChObjectType eObjType,
349                             sal_uInt16 nFormatIdx = EXC_CHDATAFORMAT_UNKNOWN, bool bUsePicFmt = false ) const;
350     /** Converts and writes the contained data to the passed property set. */
351     void                ConvertFrameBase( const XclImpChRoot& rRoot,
352                             ScfPropertySet& rPropSet, XclChObjectType eObjType,
353                             sal_uInt16 nFormatIdx = EXC_CHDATAFORMAT_UNKNOWN, bool bUsePicFmt = false ) const;
354 
355 protected:
356     XclImpChLineFormatRef mxLineFmt;        /// Line format (CHLINEFORMAT record).
357     XclImpChAreaFormatRef mxAreaFmt;        /// Area format (CHAREAFORMAT record).
358     XclImpChEscherFormatRef mxEscherFmt;    /// Complex area format (CHESCHERFORMAT record).
359 };
360 
361 // ----------------------------------------------------------------------------
362 
363 /** Represents the CHFRAME record group containing object frame properties.
364 
365     The CHFRAME group consists of: CHFRAME, CHBEGIN, CHLINEFORMAT,
366     CHAREAFORMAT, CHESCHERFORMAT group, CHEND.
367  */
368 class XclImpChFrame : public XclImpChFrameBase, protected XclImpChRoot
369 {
370 public:
371     /** Creates a new frame object with specific default formatting. */
372     explicit            XclImpChFrame(
373                             const XclImpChRoot& rRoot,
374                             XclChObjectType eObjType );
375 
376     /** Reads the CHFRAME record (called by base class). */
377     virtual void        ReadHeaderRecord( XclImpStream& rStrm );
378 
379     /** Sets formatting from BIFF3-BIFF5 OBJ record, if own formatting is invisible. */
380     void                UpdateObjFrame( const XclObjLineData& rLineData, const XclObjFillData& rFillData );
381 
382     /** Converts and writes the contained data to the passed property set. */
383     void                Convert( ScfPropertySet& rPropSet, bool bUsePicFmt = false ) const;
384 
385 private:
386     XclChFrame          maData;             /// Contents of the CHFRAME record.
387     XclChObjectType     meObjType;          /// Type of the represented object.
388 };
389 
390 typedef ScfRef< XclImpChFrame > XclImpChFrameRef;
391 
392 // Source links ===============================================================
393 
394 class XclImpChSourceLink : protected XclImpChRoot
395 {
396 public:
397     typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSequence >   XDataSequenceRef;
398     typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XFormattedString >      XFormattedStringRef;
399     typedef ::com::sun::star::uno::Sequence< XFormattedStringRef >                              XFormattedStringSeq;
400 
401 public:
402     explicit            XclImpChSourceLink( const XclImpChRoot& rRoot );
403     virtual             ~XclImpChSourceLink();
404 
405     /** Reads the CHSOURCELINK record (link to source data). */
406     void                ReadChSourceLink( XclImpStream& rStrm );
407     /** Sets explicit string data for this text object. */
408     void                SetString( const String& rString );
409     /** Sets formatting runs read from a CHFORMATRUNS record. */
410     void                SetTextFormats( const XclFormatRunVec& rFormats );
411 
412     /** Returns the destination object (title, values, category, ...). */
GetDestType() const413     inline sal_uInt8    GetDestType() const { return maData.mnDestType; }
414     /** Returns the link type (to worksheet, directly, default, ...). */
GetLinkType() const415     inline sal_uInt8    GetLinkType() const { return maData.mnLinkType; }
416 
417     /** Returns true, if the source link contains explicit string data. */
HasString() const418     inline bool         HasString() const { return mxString.is() && !mxString->IsEmpty(); }
419     /** Returns explicit string data or an empty string. */
GetString() const420     inline const String& GetString() const { return mxString.is() ? mxString->GetText() : String::EmptyString(); }
421     /** Returns the number of data points of this source link. */
422     sal_uInt16          GetCellCount() const;
423 
424     /** Converts and writes the contained number format to the passed property set. */
425     void                ConvertNumFmt( ScfPropertySet& rPropSet, bool bPercent ) const;
426 
427     /** Creates a data sequence containing the link into the Calc document. */
428     XDataSequenceRef    CreateDataSequence( const ::rtl::OUString& rRole ) const;
429     /** Creates a sequence of formatted string objects. */
430     XFormattedStringSeq CreateStringSequence( const XclImpChRoot& rRoot,
431                             sal_uInt16 nLeadFontIdx, const Color& rLeadFontColor ) const;
432 
433     void                FillSourceLink(::std::vector<ScSharedTokenRef>& rTokens) const;
434 
435 private:
436     XclChSourceLink     maData;             /// Contents of the CHSOURCELINK record.
437     XclImpStringRef     mxString;           /// Text data (CHSTRING record).
438     ScfRef< ScTokenArray> mxTokenArray;     /// Token array representing the data ranges.
439 };
440 
441 typedef ScfRef< XclImpChSourceLink > XclImpChSourceLinkRef;
442 
443 // Text =======================================================================
444 
445 /** Base class for objects with font settings. Provides font conversion helper functions. */
446 class XclImpChFontBase
447 {
448 public:
449     virtual             ~XclImpChFontBase();
450 
451     /** Derived classes return the leading font index for the text object. */
452     virtual sal_uInt16  GetFontIndex() const = 0;
453     /** Derived classes return the leading font color for the text object. */
454     virtual Color       GetFontColor() const = 0;
455     /** Derived classes return the rotation value for the text object. */
456     virtual sal_uInt16  GetRotation() const = 0;
457 
458     /** Converts and writes the contained font settings to the passed property set. */
459     void                ConvertFontBase( const XclImpChRoot& rRoot, ScfPropertySet& rPropSet ) const;
460     /** Converts and writes the contained rotation settings to the passed property set. */
461     void                ConvertRotationBase( const XclImpChRoot& rRoot, ScfPropertySet& rPropSet, bool bSupportsStacked ) const;
462 };
463 
464 // ----------------------------------------------------------------------------
465 
466 /** The CHFONT record containing a font index for text objects. */
467 class XclImpChFont
468 {
469 public:
470     explicit            XclImpChFont();
471     /** Reads the CHFONT record (font index). */
472     void                ReadChFont( XclImpStream& rStrm );
473 
474     /** Returns the contained font index. */
GetFontIndex() const475     inline sal_uInt16   GetFontIndex() const { return mnFontIdx; }
476 
477 private:
478     sal_uInt16          mnFontIdx;          /// Index into font buffer.
479 };
480 
481 typedef ScfRef< XclImpChFont > XclImpChFontRef;
482 
483 // ----------------------------------------------------------------------------
484 
485 /** Represents the CHTEXT record group containing text object properties.
486 
487     The CHTEXT group consists of: CHTEXT, CHBEGIN, CHFRAMEPOS, CHFONT,
488     CHFORMATRUNS, CHSOURCELINK, CHSTRING, CHFRAME group, CHOBJECTLINK, and CHEND.
489  */
490 class XclImpChText : public XclImpChGroupBase, public XclImpChFontBase, protected XclImpChRoot
491 {
492 public:
493     typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XTitle > XTitleRef;
494 
495 public:
496     explicit            XclImpChText( const XclImpChRoot& rRoot );
497 
498     /** Reads the CHTEXT record (called by base class). */
499     virtual void        ReadHeaderRecord( XclImpStream& rStrm );
500     /** Reads a record from the CHTEXT group (called by base class). */
501     virtual void        ReadSubRecord( XclImpStream& rStrm );
502 
503     /** Returns the leading font index for the text object. */
504     virtual sal_uInt16  GetFontIndex() const;
505     /** Returns the leading font color for the text object. */
506     virtual Color       GetFontColor() const;
507     /** Returns the rotation value for the text object. */
508     virtual sal_uInt16  GetRotation() const;
509 
510     /** Sets explicit string data for this text object. */
511     void                SetString( const String& rString );
512     /** Updates missing parts of this text object from the passed object. */
513     void                UpdateText( const XclImpChText* pParentText );
514     /** Updates display type of this data point label text object. */
515     void                UpdateDataLabel( bool bCateg, bool bValue, bool bPercent );
516 
517     /** Returns the target object this text is linked to. */
GetLinkTarget() const518     inline sal_uInt16   GetLinkTarget() const { return maObjLink.mnTarget; }
519     /** Returns the position of the data point label this text is linked to. */
GetPointPos() const520     inline const XclChDataPointPos& GetPointPos() const { return maObjLink.maPointPos; }
521     /** Returns true, if this text group contains string data. */
HasString() const522     inline bool         HasString() const { return mxSrcLink.is() && mxSrcLink->HasString(); }
523     /** Returns true, if the text object is marked as deleted. */
IsDeleted() const524     inline bool         IsDeleted() const { return ::get_flag( maData.mnFlags, EXC_CHTEXT_DELETED ); }
525 
526     /** Converts and writes the contained font settings to the passed property set. */
527     void                ConvertFont( ScfPropertySet& rPropSet ) const;
528     /** Converts and writes the contained rotation settings to the passed property set. */
529     void                ConvertRotation( ScfPropertySet& rPropSet, bool bSupportsStacked ) const;
530     /** Converts and writes the contained frame data to the passed property set. */
531     void                ConvertFrame( ScfPropertySet& rPropSet ) const;
532     /** Converts and writes the contained number format to the passed property set. */
533     void                ConvertNumFmt( ScfPropertySet& rPropSet, bool bPercent ) const;
534     /** Converts and writes all contained data to the passed data point label property set. */
535     void                ConvertDataLabel( ScfPropertySet& rPropSet, const XclChTypeInfo& rTypeInfo ) const;
536     /** Creates a title text object. */
537     XTitleRef           CreateTitle() const;
538     /** Converts the manual position of the specified title */
539     void                ConvertTitlePosition( const XclChTextKey& rTitleKey ) const;
540 
541 private:
542     using               XclImpChRoot::ConvertFont;
543 
544     /** Reads a CHFRLABELPROPS record. */
545     void                ReadChFrLabelProps( XclImpStream& rStrm );
546 
547 private:
548     typedef ScfRef< XclChFrLabelProps > XclChFrLabelPropsRef;
549 
550     XclChText           maData;             /// Contents of the CHTEXT record.
551     XclChObjectLink     maObjLink;          /// Link target for this text object.
552     XclFormatRunVec     maFormats;          /// Formatting runs (CHFORMATRUNS record).
553     XclImpChFramePosRef mxFramePos;         /// Relative text frame position (CHFRAMEPOS record).
554     XclImpChSourceLinkRef mxSrcLink;        /// Linked data (CHSOURCELINK with CHSTRING record).
555     XclImpChFrameRef    mxFrame;            /// Text object frame properties (CHFRAME group).
556     XclImpChFontRef     mxFont;             /// Index into font buffer (CHFONT record).
557     XclChFrLabelPropsRef mxLabelProps;      /// Extended data label properties (CHFRLABELPROPS record).
558 };
559 
560 typedef ScfRef< XclImpChText > XclImpChTextRef;
561 
562 // Data series ================================================================
563 
564 /** The CHMARKERFORMAT record containing data point marker formatting data. */
565 class XclImpChMarkerFormat
566 {
567 public:
568     /** Reads the CHMARKERFORMAT record (data point marker properties). */
569     void                ReadChMarkerFormat( XclImpStream& rStrm );
570 
571     /** Returns true, if the marker format is set to automatic. */
IsAuto() const572     inline bool         IsAuto() const { return ::get_flag( maData.mnFlags, EXC_CHMARKERFORMAT_AUTO ); }
573 
574     /** Converts and writes the contained data to the passed property set. */
575     void                Convert( const XclImpChRoot& rRoot, ScfPropertySet& rPropSet,
576                             sal_uInt16 nFormatIdx, sal_Int16 nLineWeight ) const;
577     /** Sets the marker fill color as main color to the passed property set. */
578     void                ConvertColor( const XclImpChRoot& rRoot,
579                             ScfPropertySet& rPropSet, sal_uInt16 nFormatIdx ) const;
580 
581 private:
582     XclChMarkerFormat   maData;             /// Contents of the CHMARKERFORMAT record.
583 };
584 
585 typedef ScfRef< XclImpChMarkerFormat > XclImpChMarkerFormatRef;
586 
587 // ----------------------------------------------------------------------------
588 
589 /** The CHPIEFORMAT record containing data point formatting data for pie segments. */
590 class XclImpChPieFormat
591 {
592 public:
593     explicit            XclImpChPieFormat();
594     /** Reads the CHPIEFORMAT record (pie segment properties). */
595     void                ReadChPieFormat( XclImpStream& rStrm );
596     /** Converts and writes the contained data to the passed property set. */
597     void                Convert( ScfPropertySet& rPropSet ) const;
598 
599 private:
600     sal_uInt16          mnPieDist;          /// Pie distance to diagram center.
601 };
602 
603 typedef ScfRef< XclImpChPieFormat > XclImpChPieFormatRef;
604 
605 // ----------------------------------------------------------------------------
606 
607 /** The CHSERIESFORMAT record containing additional settings for a data series. */
608 class XclImpChSeriesFormat
609 {
610 public:
611     explicit            XclImpChSeriesFormat();
612     /** Reads the CHSERIESFORMAT record (additional settings for a series). */
613     void                ReadChSeriesFormat( XclImpStream& rStrm );
614     /** Returns true, if the series line is smoothed. */
HasSpline() const615     inline bool         HasSpline() const { return ::get_flag( mnFlags, EXC_CHSERIESFORMAT_SMOOTHED ); }
616 
617 private:
618     sal_uInt16          mnFlags;            /// Additional flags.
619 };
620 
621 typedef ScfRef< XclImpChSeriesFormat > XclImpChSeriesFormatRef;
622 
623 // ----------------------------------------------------------------------------
624 
625 /** The CH3DDATAFORMAT record containing the bar type in 3D bar charts. */
626 class XclImpCh3dDataFormat
627 {
628 public:
629     /** Reads the CH3DDATAFORMAT record (3D bar properties). */
630     void                ReadCh3dDataFormat( XclImpStream& rStrm );
631     /** Converts and writes the contained data to the passed property set. */
632     void                Convert( ScfPropertySet& rPropSet ) const;
633 
634 private:
635     XclCh3dDataFormat   maData;             /// Contents of the CH3DDATAFORMAT record.
636 };
637 
638 typedef ScfRef< XclImpCh3dDataFormat > XclImpCh3dDataFormatRef;
639 
640 // ----------------------------------------------------------------------------
641 
642 /** The CHATTACHEDLABEL record that contains the type of a data point label. */
643 class XclImpChAttachedLabel : protected XclImpChRoot
644 {
645 public:
646     explicit            XclImpChAttachedLabel( const XclImpChRoot& rRoot );
647     /** Reads the CHATTACHEDLABEL record (data series/point labels). */
648     void                ReadChAttachedLabel( XclImpStream& rStrm );
649     /** Creates a CHTEXT group for the label. Clones xParentText and sets additional label settings */
650     XclImpChTextRef     CreateDataLabel( XclImpChTextRef xParent ) const;
651 
652 private:
653     sal_uInt16          mnFlags;            /// Additional flags.
654 };
655 
656 typedef ScfRef< XclImpChAttachedLabel > XclImpChAttLabelRef;
657 
658 // ----------------------------------------------------------------------------
659 
660 /** Represents the CHDATAFORMAT record group containing data point properties.
661 
662     The CHDATAFORMAT group consists of: CHDATAFORMAT, CHBEGIN, CHFRAME group,
663     CHMARKERFORMAT, CHPIEFORMAT, CH3DDATAFORMAT, CHSERIESFORMAT,
664     CHATTACHEDLABEL, CHEND.
665  */
666 class XclImpChDataFormat : public XclImpChFrameBase, protected XclImpChRoot
667 {
668 public:
669     explicit            XclImpChDataFormat( const XclImpChRoot& rRoot );
670 
671     /** Reads the CHDATAFORMAT record (called by base class). */
672     virtual void        ReadHeaderRecord( XclImpStream& rStrm );
673     /** Reads a record from the CHDATAFORMAT group (called by base class). */
674     virtual void        ReadSubRecord( XclImpStream& rStrm );
675 
676     /** Sets this object to the specified data point position. */
677     void                SetPointPos( const XclChDataPointPos& rPointPos, sal_uInt16 nFormatIdx );
678     /** Sets type and text formatting for a data point label (CHTEXT group). */
SetDataLabel(XclImpChTextRef xLabel)679     inline void         SetDataLabel( XclImpChTextRef xLabel ) { mxLabel = xLabel; }
680 
681     /** Updates default data format for series group. */
682     void                UpdateGroupFormat( const XclChExtTypeInfo& rTypeInfo );
683     /** Updates missing series settings from the passed chart type group data format. */
684     void                UpdateSeriesFormat( const XclChExtTypeInfo& rTypeInfo, const XclImpChDataFormat* pGroupFmt );
685     /** Updates missing data point settings from the passed series format. */
686     void                UpdatePointFormat( const XclChExtTypeInfo& rTypeInfo, const XclImpChDataFormat* pSeriesFmt );
687     /** Updates default data format for trend lines. */
688     void                UpdateTrendLineFormat();
689 
690     /** Returns the position of the data point described by this group. */
GetPointPos() const691     inline const XclChDataPointPos& GetPointPos() const { return maData.maPointPos; }
692     /** Returns the format index of the data point described by this group. */
GetFormatIdx() const693     inline sal_uInt16   GetFormatIdx() const { return maData.mnFormatIdx; }
694     /** Returns true, if markers are set to automatic format. */
IsAutoMarker() const695     inline bool         IsAutoMarker() const { return !mxMarkerFmt || mxMarkerFmt->IsAuto(); }
696     /** Returns true, if the series line is smoothed. */
HasSpline() const697     inline bool         HasSpline() const { return mxSeriesFmt.is() && mxSeriesFmt->HasSpline(); }
698     /** Returns the data label text object. */
GetDataLabel() const699     inline XclImpChTextRef GetDataLabel() const { return mxLabel; }
700 
701     /** Converts and writes the contained data to the passed property set. */
702     void                Convert( ScfPropertySet& rPropSet, const XclChExtTypeInfo& rTypeInfo ) const;
703     /** Writes the line format only, e.g. for trend lines or error bars. */
704     void                ConvertLine( ScfPropertySet& rPropSet, XclChObjectType eObjType ) const;
705     /** Writes the area format only for the series or a data point. */
706     void                ConvertArea( ScfPropertySet& rPropSet, sal_uInt16 nFormatIdx, bool bUsePicFmt ) const;
707 
708 private:
709     /** Removes unused formatting (e.g. pie distance in a bar chart). */
710     void                RemoveUnusedFormats( const XclChExtTypeInfo& rTypeInfo );
711     /** Updates or creates the data point label. */
712     void                UpdateDataLabel( const XclImpChDataFormat* pParentFmt );
713 
714 private:
715     XclChDataFormat     maData;             /// Contents of the CHDATAFORMAT record.
716     XclImpChMarkerFormatRef mxMarkerFmt;    /// Data point marker (CHMARKERFORMAT record).
717     XclImpChPieFormatRef mxPieFmt;          /// Pie segment format (CHPIEFORMAT record).
718     XclImpChSeriesFormatRef mxSeriesFmt;    /// Series properties (CHSERIESFORMAT record).
719     XclImpCh3dDataFormatRef mx3dDataFmt;    /// 3D bar format (CH3DDATAFORMAT record).
720     XclImpChAttLabelRef mxAttLabel;         /// Data point label type (CHATTACHEDLABEL record).
721     XclImpChTextRef     mxLabel;            /// Data point label formatting (CHTEXT group).
722 };
723 
724 typedef ScfRef< XclImpChDataFormat > XclImpChDataFormatRef;
725 
726 // ----------------------------------------------------------------------------
727 
728 /** Represents the CHSERTRENDLINE record containing settings for a trend line. */
729 class XclImpChSerTrendLine : protected XclImpChRoot
730 {
731 public:
732     typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XRegressionCurve > XRegressionCurveRef;
733 
734 public:
735     explicit            XclImpChSerTrendLine( const XclImpChRoot& rRoot );
736 
737     /** Reads the CHSERTRENDLINE record. */
738     void                ReadChSerTrendLine( XclImpStream& rStrm );
739     /** Sets formatting information for the trend line. */
SetDataFormat(XclImpChDataFormatRef xDataFmt)740     inline void         SetDataFormat( XclImpChDataFormatRef xDataFmt ) { mxDataFmt = xDataFmt; }
741 
742     /** Creates an API object representing this trend line. */
743     XRegressionCurveRef CreateRegressionCurve() const;
744 
745 private:
746     XclChSerTrendLine   maData;             /// Contents of the CHSERTRENDLINE record.
747     XclImpChDataFormatRef mxDataFmt;        /// Formatting settings of the trend line.
748 };
749 
750 typedef ScfRef< XclImpChSerTrendLine > XclImpChSerTrendLineRef;
751 
752 // ----------------------------------------------------------------------------
753 
754 /** Represents the CHSERERRORBAR record containing settings for error bars. */
755 class XclImpChSerErrorBar : protected XclImpChRoot
756 {
757 public:
758     typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XLabeledDataSequence >    XLabeledDataSeqRef;
759     typedef ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >                   XPropertySetRef;
760 
761 public:
762     explicit            XclImpChSerErrorBar( const XclImpChRoot& rRoot );
763 
764     /** Reads the CHSERERRORBAR record. */
765     void                ReadChSerErrorBar( XclImpStream& rStrm );
766     /** Sets link and formatting information for the error bars. */
767     void                SetSeriesData(
768                             XclImpChSourceLinkRef xValueLink,
769                             XclImpChDataFormatRef xDataFmt );
770 
771     /** Returns the type of this error bar (X/Y, plus/minus). */
GetBarType() const772     inline sal_uInt8    GetBarType() const { return maData.mnBarType; }
773     /** Creates a labeled data sequence object from value data link. */
774     XLabeledDataSeqRef  CreateValueSequence() const;
775 
776     /** Tries to create an error bar API object from the specified Excel error bars. */
777     static XPropertySetRef CreateErrorBar(
778                             const XclImpChSerErrorBar* pPosBar,
779                             const XclImpChSerErrorBar* pNegBar );
780 
781 private:
782     XclChSerErrorBar    maData;             /// Contents of the CHSERERRORBAR record.
783     XclImpChSourceLinkRef mxValueLink;      /// Link data for manual error bar values.
784     XclImpChDataFormatRef mxDataFmt;        /// Formatting settings of the error bars.
785 };
786 
787 typedef ScfRef< XclImpChSerErrorBar > XclImpChSerErrorBarRef;
788 
789 // ----------------------------------------------------------------------------
790 
791 /** Represents the CHSERIES record group describing a data series in a chart.
792 
793     The CHSERIES group consists of: CHSERIES, CHBEGIN, CHSOURCELINK groups,
794     CHDATAFORMAT groups, CHSERGROUP, CHSERPARENT, CHSERERRORBAR,
795     CHSERTRENDLINE, CHEND.
796  */
797 class XclImpChSeries : public XclImpChGroupBase, protected XclImpChRoot
798 {
799 public:
800     typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDataSeries >                   XDataSeriesRef;
801     typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XLabeledDataSequence >    XLabeledDataSeqRef;
802     typedef ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >                   XPropertySetRef;
803 
804 public:
805     explicit            XclImpChSeries( const XclImpChRoot& rRoot, sal_uInt16 nSeriesIdx );
806 
807     /** Reads the CHSERIES record (called by base class). */
808     virtual void        ReadHeaderRecord( XclImpStream& rStrm );
809     /** Reads a record from the CHSERIES group (called by base class). */
810     virtual void        ReadSubRecord( XclImpStream& rStrm );
811 
812     /** Sets a data point or series format (CHDATAFORMAT group) for this series. */
813     void                SetDataFormat( XclImpChDataFormatRef xDataFmt );
814     /** Sets a label text (CHTEXT group) attached  to a series or data point. */
815     void                SetDataLabel( XclImpChTextRef xLabel );
816     /** Adds error bar settings from the passed series to the own series. */
817     void                AddChildSeries( const XclImpChSeries& rSeries );
818     /** Updates missing series formatting by using default formatting from axes sets. */
819     void                FinalizeDataFormats();
820 
821     /** Returns the axes set identifier this series is assigned to (primary/secondary). */
GetGroupIdx() const822     inline sal_uInt16   GetGroupIdx() const { return mnGroupIdx; }
823     /** Returns the 0-based series index described by this series. */
GetSeriesIdx() const824     inline sal_uInt16   GetSeriesIdx() const { return mnSeriesIdx; }
825     /** Returns the 0-based index of the parent series (e.g. of a trend line). */
GetParentIdx() const826     inline sal_uInt16   GetParentIdx() const { return mnParentIdx; }
827     /** Returns the format index of the series used for automatic line and area colors. */
GetFormatIdx() const828     inline sal_uInt16   GetFormatIdx() const { return mxSeriesFmt.is() ? mxSeriesFmt->GetFormatIdx() : EXC_CHDATAFORMAT_DEFAULT; }
829     /** Returns true, if the series is child of another series (e.g. trend line). */
HasParentSeries() const830     inline bool         HasParentSeries() const { return mnParentIdx != EXC_CHSERIES_INVALID; }
831     /** Returns true, if the series contains child series (e.g. trend lines). */
HasChildSeries() const832     inline bool         HasChildSeries() const { return !maTrendLines.empty() || !maErrorBars.empty(); }
833     /** Returns series title or an empty string, if the series does not contain a title. */
GetTitle() const834     inline const String& GetTitle() const { return mxTitleLink.is() ? mxTitleLink->GetString() : String::EmptyString(); }
835 
836     /** Returns true, if the series line is smoothed. */
HasSpline() const837     inline bool         HasSpline() const { return mxSeriesFmt.is() && mxSeriesFmt->HasSpline(); }
838 
839     /** Creates a labeled data sequence object from value data link. */
840     XLabeledDataSeqRef  CreateValueSequence( const ::rtl::OUString& rValueRole ) const;
841     /** Creates a labeled data sequence object from category data link. */
842     XLabeledDataSeqRef  CreateCategSequence( const ::rtl::OUString& rCategRole ) const;
843     /** Creates a data series object with initialized source links. */
844     XDataSeriesRef      CreateDataSeries() const;
845 
846     void                FillAllSourceLinks(::std::vector<ScSharedTokenRef>& rTokens) const;
847 
848 private:
849     /** Reads a CHSOURCELINK record. */
850     void                ReadChSourceLink( XclImpStream& rStrm );
851     /** Reads a CHDATAFORMAT group containing series and point formatting. */
852     void                ReadChDataFormat( XclImpStream& rStrm );
853     /** Reads a CHSERPARENT record specifying the parent series of this series. */
854     void                ReadChSerParent( XclImpStream& rStrm );
855     /** Reads a CHSERTRENDLINE record containing trend line settings. */
856     void                ReadChSerTrendLine( XclImpStream& rStrm );
857     /** Reads a CHSERERRORBAR record containing error bar settings. */
858     void                ReadChSerErrorBar( XclImpStream& rStrm );
859 
860     /** Creates a new CHDATAFORMAT group with the specified point index. */
861     XclImpChDataFormatRef CreateDataFormat( sal_uInt16 nPointIdx, sal_uInt16 nFormatIdx );
862     /** Returns the pointer to a CHDATAFORMAT group reference or 0 for invalid pointer index. */
863     XclImpChDataFormatRef* GetDataFormatRef( sal_uInt16 nPointIdx );
864     /** Returns the pointer to a CHTEXT group reference or 0 for invalid pointer index. */
865     XclImpChTextRef*    GetDataLabelRef( sal_uInt16 nPointIdx );
866 
867     /** Converts all trend lines and inserts them into the passed API data series object. */
868     void                ConvertTrendLines( XDataSeriesRef xDataSeries ) const;
869     /** Tries to create an error bar API object from the specified Excel error bars. */
870     XPropertySetRef     CreateErrorBar( sal_uInt8 nPosBarId, sal_uInt8 nNegBarId ) const;
871 
872 private:
873     typedef ScfRefMap< sal_uInt16, XclImpChDataFormat > XclImpChDataFormatMap;
874     typedef ScfRefMap< sal_uInt16, XclImpChText >       XclImpChTextMap;
875     typedef ::std::list< XclImpChSerTrendLineRef >      XclImpChSerTrendLineList;
876     typedef ScfRefMap< sal_uInt8, XclImpChSerErrorBar > XclImpChSerErrorBarMap;
877 
878     XclChSeries         maData;             /// Contents of the CHSERIES record.
879     XclImpChSourceLinkRef mxValueLink;      /// Link data for series values.
880     XclImpChSourceLinkRef mxCategLink;      /// Link data for series category names.
881     XclImpChSourceLinkRef mxTitleLink;      /// Link data for series title.
882     XclImpChSourceLinkRef mxBubbleLink;     /// Link data for series bubble sizes.
883     XclImpChDataFormatRef mxSeriesFmt;      /// CHDATAFORMAT group for series format.
884     XclImpChDataFormatMap maPointFmts;      /// CHDATAFORMAT groups for data point formats.
885     XclImpChTextMap     maLabels;           /// Data point labels (CHTEXT groups).
886     XclImpChSerTrendLineList maTrendLines;  /// Trend line settings (CHSERTRENDLINE records).
887     XclImpChSerErrorBarMap maErrorBars;     /// Error bar settings (CHSERERRORBAR records).
888     sal_uInt16          mnGroupIdx;         /// Chart type group (CHTYPEGROUP group) this series is assigned to.
889     sal_uInt16          mnSeriesIdx;        /// 0-based series index.
890     sal_uInt16          mnParentIdx;        /// 0-based index of parent series (trend lines and error bars).
891 };
892 
893 typedef ScfRef< XclImpChSeries > XclImpChSeriesRef;
894 
895 // Chart type groups ==========================================================
896 
897 class XclImpChType : protected XclImpChRoot
898 {
899 public:
900     typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDiagram >          XDiagramRef;
901     typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XCoordinateSystem > XCoordSystemRef;
902     typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartType >        XChartTypeRef;
903 
904 public:
905     explicit            XclImpChType( const XclImpChRoot& rRoot );
906 
907     /** Reads a chart type record (e.g. CHBAR, CHLINE, CHPIE, ...). */
908     void                ReadChType( XclImpStream& rStrm );
909     /** Final processing after reading the entire chart. */
910     void                Finalize( bool bStockChart );
911 
912     /** Returns the record identifier of the chart type record. */
GetRecId() const913     inline sal_uInt16   GetRecId() const { return mnRecId; }
914     /** Returns the chart type info struct for the contained chart type. */
GetTypeInfo() const915     inline const XclChTypeInfo& GetTypeInfo() const { return maTypeInfo; }
916     /** Returns true, if the series in this chart type group are stacked on each other (no percentage). */
917     bool                IsStacked() const;
918     /** Returns true, if the series in this chart type group are stacked on each other as percentage. */
919     bool                IsPercent() const;
920     /** Returns true, if chart type has category labels enabled (may be disabled in radar charts). */
921     bool                HasCategoryLabels() const;
922 
923     /** Creates a coordinate system according to the contained chart type. */
924     XCoordSystemRef     CreateCoordSystem( bool b3dChart ) const;
925     /** Creates and returns an object that represents the contained chart type. */
926     XChartTypeRef       CreateChartType( XDiagramRef xDiagram, bool b3dChart ) const;
927 
928 private:
929     XclChType           maData;             /// Contents of the chart type record.
930     sal_uInt16          mnRecId;            /// Record identifier for chart type.
931     XclChTypeInfo       maTypeInfo;         /// Chart type info for the contained type.
932 };
933 
934 // ----------------------------------------------------------------------------
935 
936 /** Represents the CHCHART3D record that contains 3D view settings. */
937 class XclImpChChart3d
938 {
939 public:
940     /** Reads the CHCHART3D record (properties for 3D charts). */
941     void                ReadChChart3d( XclImpStream& rStrm );
942     /** Returns true, if the data points are clustered on the X axis. */
IsClustered() const943     inline bool         IsClustered() const { return ::get_flag( maData.mnFlags, EXC_CHCHART3D_CLUSTER ); }
944     /** Converts and writes the contained data to the passed property set. */
945     void                Convert( ScfPropertySet& rPropSet, bool b3dWallChart ) const;
946 
947 private:
948     XclChChart3d        maData;             /// Contents of the CHCHART3D record.
949 };
950 
951 typedef ScfRef< XclImpChChart3d > XclImpChChart3dRef;
952 
953 // ----------------------------------------------------------------------------
954 
955 /** Represents the CHLEGEND record group describing the chart legend.
956 
957     The CHLEGEND group consists of: CHLEGEND, CHBEGIN, CHFRAMEPOS, CHFRAME
958     group, CHTEXT group, CHEND.
959  */
960 class XclImpChLegend : public XclImpChGroupBase, protected XclImpChRoot
961 {
962 public:
963     typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XLegend > XLegendRef;
964 
965 public:
966     explicit            XclImpChLegend( const XclImpChRoot& rRoot );
967 
968     /** Reads the CHLEGEND record (called by base class). */
969     virtual void        ReadHeaderRecord( XclImpStream& rStrm );
970     /** Reads a record from the CHLEGEND group (called by base class). */
971     virtual void        ReadSubRecord( XclImpStream& rStrm );
972     /** Final processing after reading the entire chart. */
973     void                Finalize();
974 
975     /** Creates a new legend object. */
976     XLegendRef          CreateLegend() const;
977 
978 private:
979     XclChLegend         maData;             /// Contents of the CHLEGEND record.
980     XclImpChFramePosRef mxFramePos;         /// Legend frame position (CHFRAMEPOS record).
981     XclImpChTextRef     mxText;             /// Legend text format (CHTEXT group).
982     XclImpChFrameRef    mxFrame;            /// Legend frame format (CHFRAME group).
983 };
984 
985 typedef ScfRef< XclImpChLegend > XclImpChLegendRef;
986 
987 // ----------------------------------------------------------------------------
988 
989 /** Represents the CHDROPBAR record group describing pos/neg bars in line charts.
990 
991     The CHDROPBAR group consists of: CHDROPBAR, CHBEGIN, CHLINEFORMAT,
992     CHAREAFORMAT, CHESCHERFORMAT group, CHEND.
993  */
994 class XclImpChDropBar : public XclImpChFrameBase
995 {
996 public:
997     explicit            XclImpChDropBar( sal_uInt16 nDropBar );
998 
999     /** Reads the CHDROPBAR record (called by base class). */
1000     virtual void        ReadHeaderRecord( XclImpStream& rStrm );
1001 
1002     /** Converts and writes the contained frame data to the passed property set. */
1003     void                Convert( const XclImpChRoot& rRoot, ScfPropertySet& rPropSet ) const;
1004 
1005 private:
1006     sal_uInt16          mnDropBar;          /// Drop bar identifier, needed for auto format.
1007     sal_uInt16          mnBarDist;          /// Distance between bars (CHDROPBAR record).
1008 };
1009 
1010 typedef ScfRef< XclImpChDropBar > XclImpChDropBarRef;
1011 
1012 // ----------------------------------------------------------------------------
1013 
1014 /** Represents the CHTYPEGROUP record group describing a group of series.
1015 
1016     The CHTYPEGROUP group consists of: CHTYPEGROUP, CHBEGIN, a chart type
1017     record (e.g. CHBAR, CHLINE, CHAREA, CHPIE, ...), CHCHART3D, CHLEGEND group,
1018     CHDEFAULTTEXT groups (CHDEFAULTTEXT with CHTEXT groups), CHDROPBAR groups,
1019     CHCHARTLINE groups (CHCHARTLINE with CHLINEFORMAT), CHDATAFORMAT group,
1020     CHEND.
1021  */
1022 class XclImpChTypeGroup : public XclImpChGroupBase, protected XclImpChRoot
1023 {
1024 public:
1025     typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDiagram >                      XDiagramRef;
1026     typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XCoordinateSystem >             XCoordSystemRef;
1027     typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartType >                    XChartTypeRef;
1028     typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDataSeries >                   XDataSeriesRef;
1029     typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XLabeledDataSequence >    XLabeledDataSeqRef;
1030 
1031 public:
1032     explicit            XclImpChTypeGroup( const XclImpChRoot& rRoot );
1033 
1034     /** Reads the CHTYPEGROUP record (called by base class). */
1035     virtual void        ReadHeaderRecord( XclImpStream& rStrm );
1036     /** Reads a record from the CHTYPEGROUP group (called by base class). */
1037     virtual void        ReadSubRecord( XclImpStream& rStrm );
1038     /** Final processing after reading the entire chart. */
1039     void                Finalize();
1040 
1041     /** Inserts a series attached to this chart type group.*/
1042     void                AddSeries( XclImpChSeriesRef xSeries );
1043     /** Marks the passed format index as used. PopUnusedFormatIndex() will not return this index. */
1044     void                SetUsedFormatIndex( sal_uInt16 nFormatIdx );
1045     /** Returns the next unused format index and marks it as used. */
1046     sal_uInt16          PopUnusedFormatIndex();
1047 
1048     /** Returns the index of this chart type group. */
GetGroupIdx() const1049     inline sal_uInt16   GetGroupIdx() const { return maData.mnGroupIdx; }
1050     /** Returns the chart type info struct for the contained chart type. */
GetTypeInfo() const1051     inline const XclChExtTypeInfo& GetTypeInfo() const { return maTypeInfo; }
1052     /** Returns true, if this chart type group contains at least one valid series. */
IsValidGroup() const1053     inline bool         IsValidGroup() const { return !maSeries.empty(); }
1054     /** Returns true, if the series in this chart type group are stacked on each other (no percentage). */
IsStacked() const1055     inline bool         IsStacked() const { return maType.IsStacked(); }
1056     /** Returns true, if the series in this chart type group are stacked on each other as percentage. */
IsPercent() const1057     inline bool         IsPercent() const { return maType.IsPercent(); }
1058     /** Returns true, if the chart is three-dimensional. */
Is3dChart() const1059     inline bool         Is3dChart() const { return mxChart3d.is() && maTypeInfo.mbSupports3d; }
1060     /** Returns true, if chart type supports wall and floor format in 3d mode. */
Is3dWallChart() const1061     inline bool         Is3dWallChart() const { return Is3dChart() && (maTypeInfo.meTypeCateg != EXC_CHTYPECATEG_PIE); }
1062     /** Returns true, if the series in this chart type group are ordered on the Z axis. */
Is3dDeepChart() const1063     inline bool         Is3dDeepChart() const { return Is3dWallChart() && mxChart3d.is() && !mxChart3d->IsClustered(); }
1064     /** Returns true, if category (X axis) labels are enabled (may be disabled in radar charts). */
HasCategoryLabels() const1065     inline bool         HasCategoryLabels() const { return maType.HasCategoryLabels(); }
1066     /** Returns true, if points of a series show varying automatic area format. */
1067     bool                HasVarPointFormat() const;
1068     /** Returns true, if bars are connected with lines (stacked bar charts only). */
1069     bool                HasConnectorLines() const;
1070 
1071     /** Returns the legend object. */
GetLegend() const1072     inline XclImpChLegendRef GetLegend() const { return mxLegend; }
1073     /** Returns the default series data format. */
GetGroupFormat() const1074     inline XclImpChDataFormatRef GetGroupFormat() const { return mxGroupFmt; }
1075     /** Returns series title, if the chart type group contains only one single series. */
1076     const String&       GetSingleSeriesTitle() const;
1077 
1078     /** Converts and writes all 3D settings to the passed diagram. */
1079     void                ConvertChart3d( ScfPropertySet& rPropSet ) const;
1080     /** Creates a coordinate system according to the contained chart type. */
1081     XCoordSystemRef     CreateCoordSystem() const;
1082     /** Creates and returns an object that represents the contained chart type. */
1083     XChartTypeRef       CreateChartType( XDiagramRef xDiagram, sal_Int32 nApiAxesSetIdx ) const;
1084     /** Creates a labeled data sequence object for axis categories. */
1085     XLabeledDataSeqRef  CreateCategSequence() const;
1086 
1087 private:
1088     /** Reads a CHDROPBAR record group. */
1089     void                ReadChDropBar( XclImpStream& rStrm );
1090     /** Reads a CHCHARTLINE record group. */
1091     void                ReadChChartLine( XclImpStream& rStrm );
1092     /** Reads a CHDATAFORMAT record group (default series format). */
1093     void                ReadChDataFormat( XclImpStream& rStrm );
1094 
1095     /** Returns true, if the chart type group contains a hi-lo line format. */
HasHiLoLine() const1096     inline bool         HasHiLoLine() const { return maChartLines.has( EXC_CHCHARTLINE_HILO ); }
1097     /** Returns true, if the chart type group contains drop bar formats. */
HasDropBars() const1098     inline bool         HasDropBars() const { return !maDropBars.empty(); }
1099 
1100     /** Inserts the passed series into the chart type. Adds additional properties to the series. */
1101     void                InsertDataSeries( XChartTypeRef xChartType,
1102                             XDataSeriesRef xSeries, sal_Int32 nApiAxesSetIdx ) const;
1103     /** Creates all data series of any chart type except stock charts. */
1104     void                CreateDataSeries( XChartTypeRef xChartType, sal_Int32 nApiAxesSetIdx ) const;
1105     /** Creates all data series of of a stock chart. */
1106     void                CreateStockSeries( XChartTypeRef xChartType, sal_Int32 nApiAxesSetIdx ) const;
1107 
1108 private:
1109     typedef ::std::vector< XclImpChSeriesRef >          XclImpChSeriesVec;
1110     typedef ScfRefMap< sal_uInt16, XclImpChDropBar >    XclImpChDropBarMap;
1111     typedef ScfRefMap< sal_uInt16, XclImpChLineFormat > XclImpChLineFormatMap;
1112     typedef ::std::set< sal_uInt16 >                    UInt16Set;
1113 
1114     XclChTypeGroup      maData;             /// Contents of the CHTYPEGROUP record.
1115     XclImpChType        maType;             /// Chart type (e.g. CHBAR, CHLINE, ...).
1116     XclChExtTypeInfo    maTypeInfo;         /// Extended chart type info.
1117     XclImpChSeriesVec   maSeries;           /// Series attached to this chart type group (CHSERIES groups).
1118     XclImpChSeriesRef   mxFirstSeries;      /// First series in this chart type group (CHSERIES groups).
1119     XclImpChChart3dRef  mxChart3d;          /// 3D settings (CHCHART3D record).
1120     XclImpChLegendRef   mxLegend;           /// Chart legend (CHLEGEND group).
1121     XclImpChDropBarMap  maDropBars;         /// Dropbars (CHDROPBAR group).
1122     XclImpChLineFormatMap maChartLines;     /// Global line formats (CHCHARTLINE group).
1123     XclImpChDataFormatRef mxGroupFmt;       /// Default format for all series (CHDATAFORMAT group).
1124     UInt16Set           maUnusedFormats;    /// Contains unused format indexes for automatic colors.
1125 };
1126 
1127 typedef ScfRef< XclImpChTypeGroup > XclImpChTypeGroupRef;
1128 
1129 // Axes =======================================================================
1130 
1131 class XclImpChLabelRange : protected XclImpChRoot
1132 {
1133 public:
1134     typedef ::com::sun::star::chart2::ScaleData ScaleData;
1135 
1136 public:
1137     explicit            XclImpChLabelRange( const XclImpChRoot& rRoot );
1138     /** Reads the CHLABELRANGE record (category axis scaling properties). */
1139     void                ReadChLabelRange( XclImpStream& rStrm );
1140     /** Reads the CHDATERANGE record (date axis scaling properties). */
1141     void                ReadChDateRange( XclImpStream& rStrm );
1142     /** Converts category axis scaling settings. */
1143     void                Convert( ScfPropertySet& rPropSet, ScaleData& rScaleData, bool bMirrorOrient ) const;
1144     /** Converts position settings of this axis at a crossing axis. */
1145     void                ConvertAxisPosition( ScfPropertySet& rPropSet, bool b3dChart ) const;
1146 
1147 private:
1148     XclChLabelRange     maLabelData;        /// Contents of the CHLABELRANGE record.
1149     XclChDateRange      maDateData;         /// Contents of the CHDATERANGE record.
1150 };
1151 
1152 typedef ScfRef< XclImpChLabelRange > XclImpChLabelRangeRef;
1153 
1154 // ----------------------------------------------------------------------------
1155 
1156 class XclImpChValueRange : protected XclImpChRoot
1157 {
1158 public:
1159     typedef ::com::sun::star::chart2::ScaleData ScaleData;
1160 
1161 public:
1162     explicit            XclImpChValueRange( const XclImpChRoot& rRoot );
1163     /** Reads the CHVALUERANGE record (numeric axis scaling properties). */
1164     void                ReadChValueRange( XclImpStream& rStrm );
1165     /** Converts value axis scaling settings. */
1166     void                Convert( ScaleData& rScaleData, bool bMirrorOrient ) const;
1167     /** Converts position settings of this axis at a crossing axis. */
1168     void                ConvertAxisPosition( ScfPropertySet& rPropSet ) const;
1169 
1170 private:
1171     XclChValueRange     maData;             /// Contents of the CHVALUERANGE record.
1172 };
1173 
1174 typedef ScfRef< XclImpChValueRange > XclImpChValueRangeRef;
1175 
1176 // ----------------------------------------------------------------------------
1177 
1178 class XclImpChTick : protected XclImpChRoot
1179 {
1180 public:
1181     explicit            XclImpChTick( const XclImpChRoot& rRoot );
1182     /** Reads the CHTICK record (axis ticks properties). */
1183     void                ReadChTick( XclImpStream& rStrm );
1184 
1185     /** Returns true, if the axis shows attached labels. */
HasLabels() const1186     inline bool         HasLabels() const { return maData.mnLabelPos != EXC_CHTICK_NOLABEL; }
1187     /** Returns the leading font color for the axis labels. */
1188     Color               GetFontColor() const;
1189     /** Returns the rotation value for the axis labels. */
1190     sal_uInt16          GetRotation() const;
1191 
1192     /** Converts and writes the contained data to the passed property set. */
1193     void                Convert( ScfPropertySet& rPropSet ) const;
1194 
1195 private:
1196     XclChTick           maData;             /// Contents of the CHTICK record.
1197 };
1198 
1199 typedef ScfRef< XclImpChTick > XclImpChTickRef;
1200 
1201 // ----------------------------------------------------------------------------
1202 
1203 /** Represents the CHAXIS record group describing an entire chart axis.
1204 
1205     The CHAXIS group consists of: CHAXIS, CHBEGIN, CHLABELRANGE, CHEXTRANGE,
1206     CHVALUERANGE, CHFORMAT, CHTICK, CHFONT, CHAXISLINE groups (CHAXISLINE with
1207     CHLINEFORMAT, CHAREAFORMAT, and CHESCHERFORMAT group), CHEND.
1208  */
1209 class XclImpChAxis : public XclImpChGroupBase, public XclImpChFontBase, protected XclImpChRoot
1210 {
1211 public:
1212     typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis > XAxisRef;
1213 
1214 public:
1215     explicit            XclImpChAxis( const XclImpChRoot& rRoot, sal_uInt16 nAxisType = EXC_CHAXIS_NONE );
1216 
1217     /** Reads the CHAXIS record (called by base class). */
1218     virtual void        ReadHeaderRecord( XclImpStream& rStrm );
1219     /** Reads a record from the CHAXIS group (called by base class). */
1220     virtual void        ReadSubRecord( XclImpStream& rStrm );
1221     /** Final processing after reading the entire chart. */
1222     void                Finalize();
1223 
1224     /** Returns the font index for the axis labels. */
1225     virtual sal_uInt16  GetFontIndex() const;
1226     /** Returns the font color for the axis labels. */
1227     virtual Color       GetFontColor() const;
1228     /** Returns the rotation value for axis labels. */
1229     virtual sal_uInt16  GetRotation() const;
1230 
1231     /** Returns the type of this axis. */
GetAxisType() const1232     inline sal_uInt16   GetAxisType() const { return maData.mnType; }
1233     /** Returns the axis dimension index used by the chart API. */
GetApiAxisDimension() const1234     inline sal_Int32    GetApiAxisDimension() const { return maData.GetApiAxisDimension(); }
1235     /** Returns true, if the axis is active. */
IsActivated() const1236     inline bool         IsActivated() const { return !mxAxisLine || mxAxisLine->IsShowAxis(); }
1237     /** Returns true, if the axis contains caption labels. */
HasLabels() const1238     inline bool         HasLabels() const { return !mxTick || mxTick->HasLabels(); }
1239     /** Returns true, if the axis shows its major grid lines. */
HasMajorGrid() const1240     inline bool         HasMajorGrid() const { return mxMajorGrid.is(); }
1241     /** Returns true, if the axis shows its minor grid lines. */
HasMinorGrid() const1242     inline bool         HasMinorGrid() const { return mxMinorGrid.is(); }
1243 
1244     /** Creates an API axis object. */
1245     XAxisRef            CreateAxis( const XclImpChTypeGroup& rTypeGroup, const XclImpChAxis* pCrossingAxis ) const;
1246     /** Converts and writes 3D wall/floor properties to the passed property set. */
1247     void                ConvertWall( ScfPropertySet& rPropSet ) const;
1248     /** Converts position settings of this axis at a crossing axis. */
1249     void                ConvertAxisPosition( ScfPropertySet& rPropSet, const XclImpChTypeGroup& rTypeGroup ) const;
1250 
1251 private:
1252     /** Reads a CHAXISLINE record specifying the target for following line properties. */
1253     void                ReadChAxisLine( XclImpStream& rStrm );
1254     /** Creates a CHFRAME object and stores it into the mxWallFrame member. */
1255     void                CreateWallFrame();
1256 
1257 private:
1258     XclChAxis           maData;             /// Contents of the CHAXIS record.
1259     XclImpChLabelRangeRef mxLabelRange;     /// Category scaling (CHLABELRANGE record).
1260     XclImpChValueRangeRef mxValueRange;     /// Value scaling (CHVALUERANGE record).
1261     XclImpChTickRef     mxTick;             /// Axis ticks (CHTICK record).
1262     XclImpChFontRef     mxFont;             /// Index into font buffer (CHFONT record).
1263     XclImpChLineFormatRef mxAxisLine;       /// Axis line format (CHLINEFORMAT record).
1264     XclImpChLineFormatRef mxMajorGrid;      /// Major grid line format (CHLINEFORMAT record).
1265     XclImpChLineFormatRef mxMinorGrid;      /// Minor grid line format (CHLINEFORMAT record).
1266     XclImpChFrameRef    mxWallFrame;        /// Wall/floor format (sub records of CHFRAME group).
1267     sal_uInt16          mnNumFmtIdx;        /// Index into number format buffer (CHFORMAT record).
1268 };
1269 
1270 typedef ScfRef< XclImpChAxis > XclImpChAxisRef;
1271 
1272 // ----------------------------------------------------------------------------
1273 
1274 /** Represents the CHAXESSET record group describing an axes set (X/Y/Z axes).
1275 
1276     The CHAXESSET group consists of: CHAXESSET, CHBEGIN, CHFRAMEPOS, CHAXIS
1277     groups, CHTEXT groups, CHPLOTFRAME group (CHPLOTFRAME with CHFRAME group),
1278     CHTYPEGROUP group, CHEND.
1279  */
1280 class XclImpChAxesSet : public XclImpChGroupBase, protected XclImpChRoot
1281 {
1282 public:
1283     typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDiagram >          XDiagramRef;
1284     typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XCoordinateSystem > XCoordSystemRef;
1285     typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis >             XAxisRef;
1286 
1287 public:
1288     explicit            XclImpChAxesSet( const XclImpChRoot& rRoot, sal_uInt16 nAxesSetId );
1289 
1290     /** Reads the CHAXESSET record (called by base class). */
1291     virtual void        ReadHeaderRecord( XclImpStream& rStrm );
1292     /** Reads a record from the CHAXESSET group (called by base class). */
1293     virtual void        ReadSubRecord( XclImpStream& rStrm );
1294     /** Final processing after reading the entire chart. */
1295     void                Finalize();
1296 
1297     /** Returns true, if this axes set exists (returns false if this is a dummy object). */
IsValidAxesSet() const1298     inline bool         IsValidAxesSet() const { return !maTypeGroups.empty(); }
1299     /** Returns the index of the axes set (primary/secondary). */
GetAxesSetId() const1300     inline sal_uInt16   GetAxesSetId() const { return maData.mnAxesSetId; }
1301     /** Returns the axes set index used by the chart API. */
GetApiAxesSetIndex() const1302     inline sal_Int32    GetApiAxesSetIndex() const { return maData.GetApiAxesSetIndex(); }
1303 
1304     /** Returns the outer plot area position, if existing. */
GetPlotAreaFramePos() const1305     inline XclImpChFramePosRef GetPlotAreaFramePos() const { return mxFramePos; }
1306     /** Returns the specified chart type group. */
GetTypeGroup(sal_uInt16 nGroupIdx) const1307     inline XclImpChTypeGroupRef GetTypeGroup( sal_uInt16 nGroupIdx ) const { return maTypeGroups.get( nGroupIdx ); }
1308     /** Returns the first chart type group. */
1309     XclImpChTypeGroupRef GetFirstTypeGroup() const;
1310     /** Looks for a legend in all chart type groups and returns it. */
1311     XclImpChLegendRef   GetLegend() const;
1312     /** Returns series title, if the axes set contains only one single series. */
1313     const String&       GetSingleSeriesTitle() const;
1314 
1315     /** Creates a coordinate system and converts all series and axis settings. */
1316     void                Convert( XDiagramRef xDiagram ) const;
1317     /** Converts the manual positions of all axis titles. */
1318     void                ConvertTitlePositions() const;
1319 
1320 private:
1321     /** Reads a CHAXIS record group containing a single axis. */
1322     void                ReadChAxis( XclImpStream& rStrm );
1323     /** Reads a CHTEXT record group containing an axis title. */
1324     void                ReadChText( XclImpStream& rStrm );
1325     /** Reads the CHPLOTFRAME record group containing diagram area formatting. */
1326     void                ReadChPlotFrame( XclImpStream& rStrm );
1327     /** Reads a CHTYPEGROUP record group containing chart type and chart settings. */
1328     void                ReadChTypeGroup( XclImpStream& rStrm );
1329 
1330     /** Updates text formatting of the passed axis title with global text formatting. */
1331     void                UpdateAxisTitle( XclImpChTextRef xTitle );
1332 
1333     /** Creates a coordinate system that contains all chart types for this axes set. */
1334     XCoordSystemRef     CreateCoordSystem( XDiagramRef xDiagram ) const;
1335     /** Creates and inserts an axis into the container and registers the coordinate system. */
1336     void                ConvertAxis( XclImpChAxisRef xChAxis, XclImpChTextRef xChAxisTitle,
1337                             XCoordSystemRef xCoordSystem, const XclImpChAxis* pCrossingAxis ) const;
1338     /** Creates and returns an API axis object. */
1339     XAxisRef            CreateAxis( const XclImpChAxis& rChAxis, const XclImpChAxis* pCrossingAxis ) const;
1340     /** Writes all properties of the background area to the passed diagram. */
1341     void                ConvertBackground( XDiagramRef xDiagram ) const;
1342 
1343 private:
1344     typedef ScfRefMap< sal_uInt16, XclImpChTypeGroup > XclImpChTypeGroupMap;
1345 
1346     XclChAxesSet        maData;             /// Contents of the CHAXESSET record.
1347     XclImpChFramePosRef mxFramePos;         /// Outer plot area position (CHFRAMEPOS record).
1348     XclImpChAxisRef     mxXAxis;            /// The X axis (CHAXIS group).
1349     XclImpChAxisRef     mxYAxis;            /// The Y axis (CHAXIS group).
1350     XclImpChAxisRef     mxZAxis;            /// The Z axis (CHAXIS group).
1351     XclImpChTextRef     mxXAxisTitle;       /// The X axis title (CHTEXT group).
1352     XclImpChTextRef     mxYAxisTitle;       /// The Y axis title (CHTEXT group).
1353     XclImpChTextRef     mxZAxisTitle;       /// The Z axis title (CHTEXT group).
1354     XclImpChFrameRef    mxPlotFrame;        /// Plot area (CHPLOTFRAME group).
1355     XclImpChTypeGroupMap maTypeGroups;      /// Chart type groups (CHTYPEGROUP group).
1356 };
1357 
1358 typedef ScfRef< XclImpChAxesSet > XclImpChAxesSetRef;
1359 
1360 // The chart object ===========================================================
1361 
1362 /** Represents the CHCHART record group describing the chart contents.
1363 
1364     The CHCHART group consists of: CHCHART, CHBEGIN, SCL, CHPLOTGROWTH, CHFRAME
1365     group, CHSERIES groups, CHPROPERTIES, CHDEFAULTTEXT groups (CHDEFAULTTEXT
1366     with CHTEXT groups), CHUSEDAXESSETS, CHAXESSET groups, CHTEXT groups, CHEND.
1367  */
1368 class XclImpChChart : public XclImpChGroupBase, protected XclImpChRoot
1369 {
1370 public:
1371     typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument >    XChartDocRef;
1372     typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDiagram >          XDiagramRef;
1373 
1374 public:
1375     explicit            XclImpChChart( const XclImpRoot& rRoot );
1376     virtual             ~XclImpChChart();
1377 
1378     /** Reads the CHCHART record (called by base class). */
1379     virtual void        ReadHeaderRecord( XclImpStream& rStrm );
1380     /** Reads a record from the CHCHART group (called by base class). */
1381     virtual void        ReadSubRecord( XclImpStream& rStrm );
1382     /** Reads a CHDEFAULTTEXT group (default text formats). */
1383     void                ReadChDefaultText( XclImpStream& rStrm );
1384     /** Reads a CHDATAFORMAT group describing a series format or a data point format. */
1385     void                ReadChDataFormat( XclImpStream& rStrm );
1386 
1387     /** Sets formatting from BIFF3-BIFF5 OBJ record, if own formatting is invisible. */
1388     void                UpdateObjFrame( const XclObjLineData& rLineData, const XclObjFillData& rFillData );
1389 
1390     /** Returns the specified chart type group. */
1391     XclImpChTypeGroupRef GetTypeGroup( sal_uInt16 nGroupIdx ) const;
1392     /** Returns the specified default text. */
1393     XclImpChTextRef     GetDefaultText( XclChTextType eTextType ) const;
1394     /** Returns true, if the plot area has benn moved and/or resized manually. */
1395     bool                IsManualPlotArea() const;
1396     /** Returns the number of units on the progress bar needed for the chart. */
GetProgressSize() const1397     inline sal_Size     GetProgressSize() const { return 2 * EXC_CHART_PROGRESS_SIZE; }
1398 
1399     /** Converts and writes all properties to the passed chart. */
1400     void                Convert( XChartDocRef xChartDoc,
1401                             XclImpDffConverter& rDffConv,
1402                             const ::rtl::OUString& rObjName,
1403                             const Rectangle& rChartRect ) const;
1404 
1405 private:
1406     /** Reads a CHSERIES group (data series source and formatting). */
1407     void                ReadChSeries( XclImpStream& rStrm );
1408     /** Reads a CHPROPERTIES record (global chart properties). */
1409     void                ReadChProperties( XclImpStream& rStrm );
1410     /** Reads a CHAXESSET group (primary/secondary axes set). */
1411     void                ReadChAxesSet( XclImpStream& rStrm );
1412     /** Reads a CHTEXT group (chart title and series/point captions). */
1413     void                ReadChText( XclImpStream& rStrm );
1414 
1415     /** Final processing after reading the entire chart data. */
1416     void                Finalize();
1417     /** Finalizes series list, assigns child series to parent series. */
1418     void                FinalizeSeries();
1419     /** Assigns all imported CHDATAFORMAT groups to the respective series. */
1420     void                FinalizeDataFormats();
1421     /** Finalizes chart title, tries to detect title auto-generated from series name. */
1422     void                FinalizeTitle();
1423 
1424     /** Creates and returns a new diagram object and converts global chart settings. */
1425     XDiagramRef         CreateDiagram() const;
1426 
1427 private:
1428     typedef ::std::vector< XclImpChSeriesRef >                  XclImpChSeriesVec;
1429     typedef ScfRefMap< XclChDataPointPos, XclImpChDataFormat >  XclImpChDataFormatMap;
1430     typedef ScfRefMap< sal_uInt16, XclImpChText >               XclImpChTextMap;
1431 
1432     XclChRectangle      maRect;             /// Position of the chart on the sheet (CHCHART record).
1433     XclImpChSeriesVec   maSeries;           /// List of series data (CHSERIES groups).
1434     XclImpChDataFormatMap maDataFmts;       /// All series and point formats (CHDATAFORMAT groups).
1435     XclImpChFrameRef    mxFrame;            /// Chart frame format (CHFRAME group).
1436     XclChProperties     maProps;            /// Chart properties (CHPROPERTIES record).
1437     XclImpChTextMap     maDefTexts;         /// Default text objects (CHDEFAULTTEXT groups).
1438     XclImpChAxesSetRef  mxPrimAxesSet;      /// Primary axes set (CHAXESSET group).
1439     XclImpChAxesSetRef  mxSecnAxesSet;      /// Secondary axes set (CHAXESSET group).
1440     XclImpChTextRef     mxTitle;            /// Chart title (CHTEXT group).
1441     XclImpChLegendRef   mxLegend;           /// Chart legend (CHLEGEND group).
1442 };
1443 
1444 typedef ScfRef< XclImpChChart > XclImpChChartRef;
1445 
1446 // ----------------------------------------------------------------------------
1447 
1448 /** Drawing container of a chart. */
1449 class XclImpChartDrawing : public XclImpDrawing
1450 {
1451 public:
1452     explicit            XclImpChartDrawing( const XclImpRoot& rRoot, bool bOwnTab );
1453 
1454     /** Converts all objects and inserts them into the chart drawing page. */
1455     void                ConvertObjects(
1456                             XclImpDffConverter& rDffConv,
1457                             const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& rxModel,
1458                             const Rectangle& rChartRect );
1459 
1460     /** Calculate the resulting rectangle of the passed anchor. */
1461     virtual Rectangle   CalcAnchorRect( const XclObjAnchor& rAnchor, bool bDffAnchor ) const;
1462     /** Called whenever an object has been inserted into the draw page. */
1463     virtual void        OnObjectInserted( const XclImpDrawObjBase& rDrawObj );
1464 
1465 private:
1466     Rectangle           maChartRect;        /// Position and size of the chart shape in 1/100 mm.
1467     SCTAB               mnScTab;            /// Index of the sheet that contains the chart.
1468     bool                mbOwnTab;           /// True = own sheet, false = embedded object.
1469 };
1470 
1471 // ----------------------------------------------------------------------------
1472 
1473 /** Represents the entire chart substream (all records in BOF/EOF block). */
1474 class XclImpChart : protected XclImpRoot
1475 {
1476 public:
1477     typedef ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > XModelRef;
1478 
1479 public:
1480     /** Constructs a new chart object.
1481         @param bOwnTab  True = chart is on an own sheet; false = chart is an embedded object. */
1482     explicit            XclImpChart( const XclImpRoot& rRoot, bool bOwnTab );
1483     virtual             ~XclImpChart();
1484 
1485     /** Reads the complete chart substream (BOF/EOF block).
1486         @descr  The passed stream must be located in the BOF record of the chart substream. */
1487     void                ReadChartSubStream( XclImpStream& rStrm );
1488     /** Sets formatting from BIFF3-BIFF5 OBJ record, if own formatting is invisible. */
1489     void                UpdateObjFrame( const XclObjLineData& rLineData, const XclObjFillData& rFillData );
1490 
1491     /** Returns the number of units on the progress bar needed for the chart. */
1492     sal_Size            GetProgressSize() const;
1493     /** Returns true, if the chart is based on a pivot table. */
IsPivotChart() const1494     inline bool         IsPivotChart() const { return mbIsPivotChart; }
1495 
1496     /** Creates the chart object in the passed component. */
1497     void                Convert( XModelRef xModel,
1498                             XclImpDffConverter& rDffConv,
1499                             const ::rtl::OUString& rObjName,
1500                             const Rectangle& rChartRect ) const;
1501 
1502 private:
1503     /** Returns (initially creates) the drawing container for embedded shapes. **/
1504     XclImpChartDrawing& GetChartDrawing();
1505     /** Reads the CHCHART group (entire chart data). */
1506     void                ReadChChart( XclImpStream& rStrm );
1507 
1508 private:
1509     typedef ScfRef< XclImpChartDrawing > XclImpChartDrawingRef;
1510 
1511     XclImpChChartRef    mxChartData;        /// The chart data (CHCHART group).
1512     XclImpChartDrawingRef mxChartDrawing;   /// Drawing container for embedded shapes.
1513     bool                mbOwnTab;           /// true = own sheet; false = embedded object.
1514     bool                mbIsPivotChart;     /// true = chart is based on a pivot table.
1515 };
1516 
1517 // ============================================================================
1518 
1519 #endif
1520 
1521