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