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