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_XECHART_HXX
21 : #define SC_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/shared_ptr.hpp>
30 : #include <boost/ptr_container/ptr_map.hpp>
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 0 : 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 0 : 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 boost::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 0 : 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 0 : 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 0 : 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 boost::shared_ptr< XclExpChFramePos > XclExpChFramePosRef;
217 :
218 0 : 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 0 : inline void SetShowAxis( bool bShowAxis )
230 0 : { ::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 0 : 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 0 : 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 boost::shared_ptr< XclExpChLineFormat > XclExpChLineFormatRef;
250 :
251 0 : 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 0 : 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 0 : 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 boost::shared_ptr< XclExpChAreaFormat > XclExpChAreaFormatRef;
282 :
283 0 : 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 boost::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 0 : 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 boost::shared_ptr< XclExpChFrame > XclExpChFrameRef;
382 :
383 : // Source links ===============================================================
384 :
385 0 : 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 :
396 : void ConvertString( const OUString& aString );
397 : /** Converts the passed source link, returns the number of linked values. */
398 : sal_uInt16 ConvertDataSequence( XDataSequenceRef xDataSeq, bool bSplitToColumns, sal_uInt16 nDefCount = 0 );
399 : /** Converts the passed sequence of formatted string objects, returns leading font index. */
400 : sal_uInt16 ConvertStringSequence( const XFormattedStringSeq& rStringSeq );
401 : /** Converts the number format from the passed property set. */
402 : void ConvertNumFmt( const ScfPropertySet& rPropSet, bool bPercent );
403 :
404 : void AppendString( const OUString& rStr );
405 :
406 : /** Returns true, if this source link contains explicit string data. */
407 0 : inline bool HasString() const { return mxString && !mxString->IsEmpty(); }
408 :
409 : /** Writes the CHSOURCELINK record and optionally a CHSTRING record with explicit string data. */
410 : virtual void Save( XclExpStream& rStrm ) SAL_OVERRIDE;
411 :
412 : private:
413 : virtual void WriteBody( XclExpStream& rStrm ) SAL_OVERRIDE;
414 :
415 : private:
416 : XclChSourceLink maData; /// Contents of the CHSOURCELINK record.
417 : XclTokenArrayRef mxLinkFmla; /// Formula with link to source data.
418 : XclExpStringRef mxString; /// Text data (CHSTRING record).
419 : };
420 :
421 : typedef boost::shared_ptr< XclExpChSourceLink > XclExpChSourceLinkRef;
422 :
423 : // Text =======================================================================
424 :
425 : /** The CHFONT record containing a font index for text objects. */
426 0 : class XclExpChFont : public XclExpUInt16Record
427 : {
428 : public:
429 : explicit XclExpChFont( sal_uInt16 nFontIdx );
430 : };
431 :
432 : typedef boost::shared_ptr< XclExpChFont > XclExpChFontRef;
433 :
434 : /** The CHOBJECTLINK record linking a text object to a specific chart object. */
435 0 : class XclExpChObjectLink : public XclExpRecord
436 : {
437 : public:
438 : explicit XclExpChObjectLink( sal_uInt16 nLinkTarget, const XclChDataPointPos& rPointPos );
439 :
440 : private:
441 : virtual void WriteBody( XclExpStream& rStrm ) SAL_OVERRIDE;
442 :
443 : private:
444 : XclChObjectLink maData; /// Contents of the CHOBJECTLINK record.
445 : };
446 :
447 : typedef boost::shared_ptr< XclExpChObjectLink > XclExpChObjectLinkRef;
448 :
449 : /** Additional data label settings in the future record CHFRLABELPROPS. */
450 0 : class XclExpChFrLabelProps : public XclExpChFutureRecordBase
451 : {
452 : public:
453 : explicit XclExpChFrLabelProps( const XclExpChRoot& rRoot );
454 :
455 : /** Converts separator and the passed data label flags. */
456 : void Convert(
457 : const ScfPropertySet& rPropSet, bool bShowSeries,
458 : bool bShowCateg, bool bShowValue,
459 : bool bShowPercent, bool bShowBubble );
460 :
461 : private:
462 : virtual void WriteBody( XclExpStream& rStrm ) SAL_OVERRIDE;
463 :
464 : private:
465 : XclChFrLabelProps maData; /// Contents of the CHFRLABELPROPS record.
466 : };
467 :
468 : typedef boost::shared_ptr< XclExpChFrLabelProps > XclExpChFrLabelPropsRef;
469 :
470 : /** Base class for objects with font settings. Provides font conversion helper functions. */
471 0 : class XclExpChFontBase
472 : {
473 : public:
474 : virtual ~XclExpChFontBase();
475 :
476 : /** Derived classes set font color and color identifier to internal data structures. */
477 : virtual void SetFont( XclExpChFontRef xFont, const Color& rColor, sal_uInt32 nColorId ) = 0;
478 : /** Derived classes set text rotation to internal data structures. */
479 : virtual void SetRotation( sal_uInt16 nRotation ) = 0;
480 :
481 : /** Creates a CHFONT record from the passed font index, calls virtual function SetFont(). */
482 : void ConvertFontBase( const XclExpChRoot& rRoot, sal_uInt16 nFontIdx );
483 : /** Creates a CHFONT record from the passed font index, calls virtual function SetFont(). */
484 : void ConvertFontBase( const XclExpChRoot& rRoot, const ScfPropertySet& rPropSet );
485 : /** Converts rotation settings, calls virtual function SetRotation(). */
486 : void ConvertRotationBase( const XclExpChRoot& rRoot, const ScfPropertySet& rPropSet, bool bSupportsStacked );
487 : };
488 :
489 : /** Represents the CHTEXT record group containing text object properties.
490 :
491 : The CHTEXT group consists of: CHTEXT, CHBEGIN, CHFRAMEPOS, CHFONT,
492 : CHFORMATRUNS, CHSOURCELINK, CHSTRING, CHFRAME group, CHOBJECTLINK, and CHEND.
493 : */
494 0 : class XclExpChText : public XclExpChGroupBase, public XclExpChFontBase
495 : {
496 : public:
497 : typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XTitle > XTitleRef;
498 : typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XRegressionCurve > XRegressionCurveRef;
499 :
500 : public:
501 : explicit XclExpChText( const XclExpChRoot& rRoot );
502 :
503 : /** Sets font color and color identifier to internal data structures. */
504 : virtual void SetFont( XclExpChFontRef xFont, const Color& rColor, sal_uInt32 nColorId ) SAL_OVERRIDE;
505 : /** Sets text rotation to internal data structures. */
506 : virtual void SetRotation( sal_uInt16 nRotation ) SAL_OVERRIDE;
507 :
508 : /** Converts all text settings of the passed title text object. */
509 : void ConvertTitle( XTitleRef xTitle, sal_uInt16 nTarget, const OUString* pSubTitle = NULL );
510 : /** Converts all text settings of the passed legend. */
511 : void ConvertLegend( const ScfPropertySet& rPropSet );
512 : /** Converts all settings of the passed data point caption text object. */
513 : bool ConvertDataLabel( const ScfPropertySet& rPropSet,
514 : const XclChTypeInfo& rTypeInfo, const XclChDataPointPos& rPointPos );
515 : /** Converts all settings of the passed trend line equation box. */
516 : void ConvertTrendLineEquation( const ScfPropertySet& rPropSet, const XclChDataPointPos& rPointPos );
517 :
518 : /** Returns true, if the string object does not contain any text data. */
519 0 : inline bool HasString() const { return mxSrcLink && mxSrcLink->HasString(); }
520 : /** Returns the flags needed for the CHATTACHEDLABEL record. */
521 : sal_uInt16 GetAttLabelFlags() const;
522 :
523 : /** Writes all embedded records. */
524 : virtual void WriteSubRecords( XclExpStream& rStrm ) SAL_OVERRIDE;
525 :
526 : private:
527 : virtual void WriteBody( XclExpStream& rStrm ) SAL_OVERRIDE;
528 :
529 : private:
530 : XclChText maData; /// Contents of the CHTEXT record.
531 : XclExpChFramePosRef mxFramePos; /// Relative text frame position (CHFRAMEPOS record).
532 : XclExpChSourceLinkRef mxSrcLink; /// Linked data (CHSOURCELINK with CHSTRING record).
533 : XclExpChFrameRef mxFrame; /// Text object frame properties (CHFRAME group).
534 : XclExpChFontRef mxFont; /// Index into font buffer (CHFONT record).
535 : XclExpChObjectLinkRef mxObjLink; /// Link target for this text object.
536 : XclExpChFrLabelPropsRef mxLabelProps; /// Extended data label properties (CHFRLABELPROPS record).
537 : sal_uInt32 mnTextColorId; /// Text color identifier.
538 : };
539 :
540 : typedef boost::shared_ptr< XclExpChText > XclExpChTextRef;
541 :
542 : // Data series ================================================================
543 :
544 : /** The CHMARKERFORMAT record containing data point marker formatting data. */
545 0 : class XclExpChMarkerFormat : public XclExpRecord
546 : {
547 : public:
548 : explicit XclExpChMarkerFormat( const XclExpChRoot& rRoot );
549 :
550 : /** Converts symbol properties from the passed property set. */
551 : void Convert( const XclExpChRoot& rRoot,
552 : const ScfPropertySet& rPropSet, sal_uInt16 nFormatIdx );
553 : /** Converts symbol properties for stock charts from the passed property set. */
554 : void ConvertStockSymbol( const XclExpChRoot& rRoot,
555 : const ScfPropertySet& rPropSet, bool bCloseSymbol );
556 :
557 : /** Returns true, if markers are enabled. */
558 0 : inline bool HasMarker() const { return maData.mnMarkerType != EXC_CHMARKERFORMAT_NOSYMBOL; }
559 : /** Returns true, if border line of markers is visible. */
560 0 : inline bool HasLineColor() const { return !::get_flag( maData.mnFlags, EXC_CHMARKERFORMAT_NOLINE ); }
561 : /** Returns true, if fill area of markers is visible. */
562 0 : inline bool HasFillColor() const { return !::get_flag( maData.mnFlags, EXC_CHMARKERFORMAT_NOFILL ); }
563 :
564 : private:
565 : /** Registers marker colors in palette and stores color identifiers. */
566 : void RegisterColors( const XclExpChRoot& rRoot );
567 :
568 : virtual void WriteBody( XclExpStream& rStrm ) SAL_OVERRIDE;
569 :
570 : private:
571 : XclChMarkerFormat maData; /// Contents of the CHMARKERFORMAT record.
572 : sal_uInt32 mnLineColorId; /// Border line color identifier.
573 : sal_uInt32 mnFillColorId; /// Fill color identifier.
574 : };
575 :
576 : typedef boost::shared_ptr< XclExpChMarkerFormat > XclExpChMarkerFormatRef;
577 :
578 : /** The CHPIEFORMAT record containing data point formatting data for pie segments. */
579 0 : class XclExpChPieFormat : public XclExpUInt16Record
580 : {
581 : public:
582 : explicit XclExpChPieFormat();
583 :
584 : /** Sets pie segment properties from the passed property set. */
585 : void Convert( const ScfPropertySet& rPropSet );
586 : };
587 :
588 : typedef boost::shared_ptr< XclExpChPieFormat > XclExpChPieFormatRef;
589 :
590 : /** The CH3DDATAFORMAT record containing the bar type in 3D bar charts. */
591 0 : class XclExpCh3dDataFormat : public XclExpRecord
592 : {
593 : public:
594 : explicit XclExpCh3dDataFormat();
595 :
596 : /** Sets 3d bar properties from the passed property set. */
597 : void Convert( const ScfPropertySet& rPropSet );
598 :
599 : private:
600 : virtual void WriteBody( XclExpStream& rStrm ) SAL_OVERRIDE;
601 :
602 : private:
603 : XclCh3dDataFormat maData; /// Contents of the CH3DDATAFORMAT record.
604 : };
605 :
606 : typedef boost::shared_ptr< XclExpCh3dDataFormat > XclExpCh3dDataFormatRef;
607 :
608 : /** The CHATTACHEDLABEL record that contains the type of a data point label. */
609 0 : class XclExpChAttachedLabel : public XclExpUInt16Record
610 : {
611 : public:
612 : explicit XclExpChAttachedLabel( sal_uInt16 nFlags );
613 : };
614 :
615 : typedef boost::shared_ptr< XclExpChAttachedLabel > XclExpChAttLabelRef;
616 :
617 : /** Represents the CHDATAFORMAT record group containing data point properties.
618 :
619 : The CHDATAFORMAT group consists of: CHDATAFORMAT, CHBEGIN, CHFRAME group,
620 : CHMARKERFORMAT, CHPIEFORMAT, CH3DDATAFORMAT, CHSERIESFORMAT,
621 : CHATTACHEDLABEL, CHEND.
622 : */
623 0 : class XclExpChDataFormat : public XclExpChGroupBase, public XclExpChFrameBase
624 : {
625 : public:
626 : explicit XclExpChDataFormat( const XclExpChRoot& rRoot,
627 : const XclChDataPointPos& rPointPos, sal_uInt16 nFormatIdx );
628 :
629 : /** Converts the passed data series or data point formatting. */
630 : void ConvertDataSeries( const ScfPropertySet& rPropSet, const XclChExtTypeInfo& rTypeInfo );
631 : /** Sets default formatting for a series in a stock chart. */
632 : void ConvertStockSeries( const ScfPropertySet& rPropSet, bool bCloseSymbol );
633 : /** Converts line formatting for the specified object (e.g. trend lines, error bars). */
634 : void ConvertLine( const ScfPropertySet& rPropSet, XclChObjectType eObjType );
635 :
636 : /** Returns true, if this objects describes the formatting of an entire series. */
637 0 : inline bool IsSeriesFormat() const { return maData.maPointPos.mnPointIdx == EXC_CHDATAFORMAT_ALLPOINTS; }
638 :
639 : /** Writes all embedded records. */
640 : virtual void WriteSubRecords( XclExpStream& rStrm ) SAL_OVERRIDE;
641 :
642 : private:
643 : virtual void WriteBody( XclExpStream& rStrm ) SAL_OVERRIDE;
644 :
645 : private:
646 : XclChDataFormat maData; /// Contents of the CHDATAFORMAT record.
647 : XclExpChMarkerFormatRef mxMarkerFmt; /// Data point marker (CHMARKERFORMAT record).
648 : XclExpChPieFormatRef mxPieFmt; /// Pie segment format (CHPIEFORMAT record).
649 : XclExpRecordRef mxSeriesFmt; /// Series properties (CHSERIESFORMAT record).
650 : XclExpCh3dDataFormatRef mx3dDataFmt; /// 3D bar format (CH3DDATAFORMAT record).
651 : XclExpChAttLabelRef mxAttLabel; /// Data point label type (CHATTACHEDLABEL record).
652 : };
653 :
654 : typedef boost::shared_ptr< XclExpChDataFormat > XclExpChDataFormatRef;
655 :
656 : /** Represents the CHSERTRENDLINE record containing settings for a trend line. */
657 0 : class XclExpChSerTrendLine : public XclExpRecord, protected XclExpChRoot
658 : {
659 : public:
660 : typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XRegressionCurve > XRegressionCurveRef;
661 :
662 : public:
663 : explicit XclExpChSerTrendLine( const XclExpChRoot& rRoot );
664 :
665 : /** Converts the passed trend line, returns true if trend line type is supported. */
666 : bool Convert( XRegressionCurveRef xRegCurve, sal_uInt16 nSeriesIdx );
667 :
668 : /** Returns formatting information of the trend line, created in Convert(). */
669 0 : inline XclExpChDataFormatRef GetDataFormat() const { return mxDataFmt; }
670 : /** Returns formatting of the equation text box, created in Convert(). */
671 0 : inline XclExpChTextRef GetDataLabel() const { return mxLabel; }
672 :
673 : private:
674 : virtual void WriteBody( XclExpStream& rStrm ) SAL_OVERRIDE;
675 :
676 : private:
677 : XclChSerTrendLine maData; /// Contents of the CHSERTRENDLINE record.
678 : XclExpChDataFormatRef mxDataFmt; /// Formatting settings of the trend line.
679 : XclExpChTextRef mxLabel; /// Formatting of the equation text box.
680 : };
681 :
682 : typedef boost::shared_ptr< XclExpChSerTrendLine > XclExpChSerTrendLineRef;
683 :
684 : /** Represents the CHSERERRORBAR record containing settings for error bars. */
685 0 : class XclExpChSerErrorBar : public XclExpRecord, protected XclExpChRoot
686 : {
687 : public:
688 : explicit XclExpChSerErrorBar( const XclExpChRoot& rRoot, sal_uInt8 nBarType );
689 :
690 : /** Converts the passed error bar settings, returns true if error bar type is supported. */
691 : bool Convert( XclExpChSourceLink& rValueLink, sal_uInt16& rnValueCount, const ScfPropertySet& rPropSet );
692 :
693 : private:
694 : virtual void WriteBody( XclExpStream& rStrm ) SAL_OVERRIDE;
695 :
696 : private:
697 : XclChSerErrorBar maData; /// Contents of the CHSERERRORBAR record.
698 : };
699 :
700 : typedef boost::shared_ptr< XclExpChSerErrorBar > XclExpChSerErrorBarRef;
701 :
702 : /** Represents the CHSERIES record group describing a data series in a chart.
703 :
704 : The CHSERIES group consists of: CHSERIES, CHBEGIN, CHSOURCELINK groups,
705 : CHDATAFORMAT groups, CHSERGROUP, CHSERPARENT, CHSERERRORBAR,
706 : CHSERTRENDLINE, CHEND.
707 : */
708 0 : class XclExpChSeries : public XclExpChGroupBase
709 : {
710 : public:
711 : typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDiagram > XDiagramRef;
712 : typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDataSeries > XDataSeriesRef;
713 : typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XLabeledDataSequence > XLabeledDataSeqRef;
714 : typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XRegressionCurve > XRegressionCurveRef;
715 :
716 : public:
717 : explicit XclExpChSeries( const XclExpChRoot& rRoot, sal_uInt16 nSeriesIdx );
718 :
719 : /** Converts the passed data series (source links and formatting). */
720 : bool ConvertDataSeries(
721 : XDiagramRef xDiagram, XDataSeriesRef xDataSeries,
722 : const XclChExtTypeInfo& rTypeInfo,
723 : sal_uInt16 nGroupIdx, sal_uInt16 nFormatIdx );
724 : /** Converts the passed data series for stock charts. */
725 : bool ConvertStockSeries(
726 : XDataSeriesRef xDataSeries,
727 : const OUString& rValueRole,
728 : sal_uInt16 nGroupIdx, sal_uInt16 nFormatIdx, bool bCloseSymbol );
729 : /** Converts the passed error bar settings (called at trend line child series). */
730 : bool ConvertTrendLine( const XclExpChSeries& rParent, XRegressionCurveRef xRegCurve );
731 : /** Converts the passed error bar settings (called at error bar child series). */
732 : bool ConvertErrorBar( const XclExpChSeries& rParent, const ScfPropertySet& rPropSet, sal_uInt8 nBarId );
733 : /** Converts and inserts category ranges for all inserted series. */
734 : void ConvertCategSequence( XLabeledDataSeqRef xCategSeq );
735 :
736 : /** Writes all embedded records. */
737 : virtual void WriteSubRecords( XclExpStream& rStrm ) SAL_OVERRIDE;
738 :
739 : private:
740 : /** Initializes members of this series to represent a child of the passed series. */
741 : void InitFromParent( const XclExpChSeries& rParent );
742 : /** Tries to create trend line series objects (called at parent series). */
743 : void CreateTrendLines( XDataSeriesRef xDataSeries );
744 : /** Tries to create positive and negative error bar series objects (called at parent series). */
745 : void CreateErrorBars( const ScfPropertySet& rPropSet,
746 : const OUString& rBarPropName,
747 : sal_uInt8 nPosBarId, sal_uInt8 nNegBarId );
748 : /** Tries to create an error bar series object (called at parent series). */
749 : void CreateErrorBar( const ScfPropertySet& rPropSet,
750 : const OUString& rShowPropName, sal_uInt8 nBarId );
751 :
752 : virtual void WriteBody( XclExpStream& rStrm ) SAL_OVERRIDE;
753 :
754 : private:
755 : typedef XclExpRecordList< XclExpChDataFormat > XclExpChDataFormatList;
756 :
757 : private:
758 : XclChSeries maData; /// Contents of the CHSERIES record.
759 : XclExpChSourceLinkRef mxTitleLink; /// Link data for series title.
760 : XclExpChSourceLinkRef mxValueLink; /// Link data for series values.
761 : XclExpChSourceLinkRef mxCategLink; /// Link data for series category names.
762 : XclExpChSourceLinkRef mxBubbleLink; /// Link data for series bubble sizes.
763 : XclExpChDataFormatRef mxSeriesFmt; /// CHDATAFORMAT group for series format.
764 : XclExpChDataFormatList maPointFmts; /// CHDATAFORMAT groups for data point formats.
765 : XclExpChSerTrendLineRef mxTrendLine; /// Trend line settings (CHSERTRENDLINE record).
766 : XclExpChSerErrorBarRef mxErrorBar; /// Error bar settings (CHSERERRORBAR record).
767 : sal_uInt16 mnGroupIdx; /// Chart type group (CHTYPEGROUP group) this series is assigned to.
768 : sal_uInt16 mnSeriesIdx; /// 0-based series index.
769 : sal_uInt16 mnParentIdx; /// 0-based index of parent series (trend lines and error bars).
770 : };
771 :
772 : typedef boost::shared_ptr< XclExpChSeries > XclExpChSeriesRef;
773 :
774 : // Chart type groups ==========================================================
775 :
776 : /** Represents the chart type record for all supported chart types. */
777 0 : class XclExpChType : public XclExpRecord, protected XclExpChRoot
778 : {
779 : public:
780 : typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDiagram > XDiagramRef;
781 : typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartType > XChartTypeRef;
782 :
783 : public:
784 : explicit XclExpChType( const XclExpChRoot& rRoot );
785 :
786 : /** Converts the passed chart type and the contained data series. */
787 : void Convert( XDiagramRef xDiagram, XChartTypeRef xChartType,
788 : sal_Int32 nApiAxesSetIdx, bool bSwappedAxesSet, bool bHasXLabels );
789 : /** Sets stacking mode (standard or percent) for the series in this chart type group. */
790 : void SetStacked( bool bPercent );
791 :
792 : /** Returns true, if this is object represents a valid chart type. */
793 0 : inline bool IsValidType() const { return maTypeInfo.meTypeId != EXC_CHTYPEID_UNKNOWN; }
794 : /** Returns the chart type info struct for the contained chart type. */
795 0 : inline const XclChTypeInfo& GetTypeInfo() const { return maTypeInfo; }
796 :
797 : private:
798 : virtual void WriteBody( XclExpStream& rStrm ) SAL_OVERRIDE;
799 :
800 : private:
801 : XclChType maData; /// Contents of the chart type record.
802 : XclChTypeInfo maTypeInfo; /// Chart type info for the contained type.
803 : };
804 :
805 : /** Represents the CHCHART3D record that contains 3D view settings. */
806 0 : class XclExpChChart3d : public XclExpRecord
807 : {
808 : public:
809 : explicit XclExpChChart3d();
810 :
811 : /** Converts 3d settings for the passed chart type. */
812 : void Convert( const ScfPropertySet& rPropSet, bool b3dWallChart );
813 : /** Sets flag that the data points are clustered on the X axis. */
814 0 : inline void SetClustered() { ::set_flag( maData.mnFlags, EXC_CHCHART3D_CLUSTER ); }
815 :
816 : /** Returns true, if the data points are clustered on the X axis. */
817 0 : inline bool IsClustered() const { return ::get_flag( maData.mnFlags, EXC_CHCHART3D_CLUSTER ); }
818 :
819 : private:
820 : virtual void WriteBody( XclExpStream& rStrm ) SAL_OVERRIDE;
821 :
822 : private:
823 : XclChChart3d maData; /// Contents of the CHCHART3D record.
824 : };
825 :
826 : typedef boost::shared_ptr< XclExpChChart3d > XclExpChChart3dRef;
827 :
828 : /** Represents the CHLEGEND record group describing the chart legend.
829 :
830 : The CHLEGEND group consists of: CHLEGEND, CHBEGIN, CHFRAMEPOS, CHFRAME
831 : group, CHTEXT group, CHEND.
832 : */
833 0 : class XclExpChLegend : public XclExpChGroupBase
834 : {
835 : public:
836 : explicit XclExpChLegend( const XclExpChRoot& rRoot );
837 :
838 : /** Converts all legend settings from the passed property set. */
839 : void Convert( const ScfPropertySet& rPropSet );
840 :
841 : /** Writes all embedded records. */
842 : virtual void WriteSubRecords( XclExpStream& rStrm ) SAL_OVERRIDE;
843 :
844 : private:
845 : virtual void WriteBody( XclExpStream& rStrm ) SAL_OVERRIDE;
846 :
847 : private:
848 : XclChLegend maData; /// Contents of the CHLEGEND record.
849 : XclExpChFramePosRef mxFramePos; /// Legend frame position (CHFRAMEPOS record).
850 : XclExpChTextRef mxText; /// Legend text format (CHTEXT group).
851 : XclExpChFrameRef mxFrame; /// Legend frame format (CHFRAME group).
852 : };
853 :
854 : typedef boost::shared_ptr< XclExpChLegend > XclExpChLegendRef;
855 :
856 : /** Represents the CHDROPBAR record group describing pos/neg bars in line charts.
857 :
858 : The CHDROPBAR group consists of: CHDROPBAR, CHBEGIN, CHLINEFORMAT,
859 : CHAREAFORMAT, CHESCHERFORMAT group, CHEND.
860 : */
861 0 : class XclExpChDropBar : public XclExpChGroupBase, public XclExpChFrameBase
862 : {
863 : public:
864 : explicit XclExpChDropBar( const XclExpChRoot& rRoot, XclChObjectType eObjType );
865 :
866 : /** Converts and writes the contained frame data to the passed property set. */
867 : void Convert( const ScfPropertySet& rPropSet );
868 :
869 : /** Writes all embedded records. */
870 : virtual void WriteSubRecords( XclExpStream& rStrm ) SAL_OVERRIDE;
871 :
872 : private:
873 : virtual void WriteBody( XclExpStream& rStrm ) SAL_OVERRIDE;
874 :
875 : private:
876 : XclChObjectType meObjType; /// Type of the dropbar.
877 : sal_uInt16 mnBarDist; /// Distance between bars (CHDROPBAR record).
878 : };
879 :
880 : typedef boost::shared_ptr< XclExpChDropBar > XclExpChDropBarRef;
881 :
882 : /** Represents the CHTYPEGROUP record group describing a group of series.
883 :
884 : The CHTYPEGROUP group consists of: CHTYPEGROUP, CHBEGIN, a chart type
885 : record (e.g. CHBAR, CHLINE, CHAREA, CHPIE, ...), CHCHART3D, CHLEGEND group,
886 : CHDROPBAR groups, CHCHARTLINE groups (CHCHARTLINE with CHLINEFORMAT),
887 : CHDATAFORMAT group, CHEND.
888 : */
889 0 : class XclExpChTypeGroup : public XclExpChGroupBase
890 : {
891 : public:
892 : typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDiagram > XDiagramRef;
893 : typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartType > XChartTypeRef;
894 : typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDataSeries > XDataSeriesRef;
895 : typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XLabeledDataSequence > XLabeledDataSeqRef;
896 :
897 : public:
898 : explicit XclExpChTypeGroup( const XclExpChRoot& rRoot, sal_uInt16 nGroupIdx );
899 :
900 : /** Converts the passed chart type to Excel type settings. */
901 : void ConvertType( XDiagramRef xDiagram, XChartTypeRef xChartType,
902 : sal_Int32 nApiAxesSetIdx, bool b3dChart, bool bSwappedAxesSet, bool bHasXLabels );
903 : /** Converts and inserts all series from the passed chart type. */
904 : void ConvertSeries( XDiagramRef xDiagram, XChartTypeRef xChartType,
905 : sal_Int32 nGroupAxesSetIdx, bool bPercent, bool bConnectorLines );
906 : /** Converts and inserts category ranges for all inserted series. */
907 : void ConvertCategSequence( XLabeledDataSeqRef xCategSeq );
908 : /** Creates a legend object and converts all legend settings. */
909 : void ConvertLegend( const ScfPropertySet& rPropSet );
910 :
911 : /** Returns true, if this chart type group contains at least one valid series. */
912 0 : inline bool IsValidGroup() const { return !maSeries.IsEmpty() && maType.IsValidType(); }
913 : /** Returns the index of this chart type group format. */
914 0 : inline sal_uInt16 GetGroupIdx() const { return maData.mnGroupIdx; }
915 : /** Returns the chart type info struct for the contained chart type. */
916 0 : inline const XclChExtTypeInfo& GetTypeInfo() const { return maTypeInfo; }
917 : /** Returns true, if the chart is three-dimensional. */
918 0 : inline bool Is3dChart() const { return maTypeInfo.mb3dChart; }
919 : /** Returns true, if chart type supports wall and floor format. */
920 0 : inline bool Is3dWallChart() const { return Is3dChart() && (maTypeInfo.meTypeCateg != EXC_CHTYPECATEG_PIE); }
921 : /** Returns true, if the series in this chart type group are ordered on the Z axis. */
922 0 : inline bool Is3dDeepChart() const { return Is3dWallChart() && mxChart3d && !mxChart3d->IsClustered(); }
923 : /** Returns true, if this chart type can be combined with other types. */
924 0 : inline bool IsCombinable2d() const { return !Is3dChart() && maTypeInfo.mbCombinable2d; }
925 :
926 : /** Writes all embedded records. */
927 : virtual void WriteSubRecords( XclExpStream& rStrm ) SAL_OVERRIDE;
928 :
929 : private:
930 : /** Returns an unused format index to be used for the next created series. */
931 : sal_uInt16 GetFreeFormatIdx() const;
932 : /** Creates all data series of any chart type except stock charts. */
933 : void CreateDataSeries( XDiagramRef xDiagram,
934 : XDataSeriesRef xDataSeries );
935 : /** Creates all data series of a stock chart. */
936 : void CreateAllStockSeries( XChartTypeRef xChartType,
937 : XDataSeriesRef xDataSeries );
938 : /** Creates a single data series of a stock chart. */
939 : bool CreateStockSeries( XDataSeriesRef xDataSeries,
940 : const OUString& rValueRole, bool bCloseSymbol );
941 :
942 : virtual void WriteBody( XclExpStream& rStrm ) SAL_OVERRIDE;
943 :
944 : private:
945 : typedef XclExpRecordList< XclExpChSeries > XclExpChSeriesList;
946 : typedef ::boost::ptr_map<sal_uInt16, XclExpChLineFormat> XclExpChLineFormatMap;
947 :
948 : XclChTypeGroup maData; /// Contents of the CHTYPEGROUP record.
949 : XclExpChType maType; /// Chart type (e.g. CHBAR, CHLINE, ...).
950 : XclChExtTypeInfo maTypeInfo; /// Extended chart type info.
951 : XclExpChSeriesList maSeries; /// List of series data (CHSERIES groups).
952 : XclExpChChart3dRef mxChart3d; /// 3D settings (CHCHART3D record).
953 : XclExpChLegendRef mxLegend; /// Chart legend (CHLEGEND group).
954 : XclExpChDropBarRef mxUpBar; /// White dropbars (CHDROPBAR group).
955 : XclExpChDropBarRef mxDownBar; /// Black dropbars (CHDROPBAR group).
956 : XclExpChLineFormatMap maChartLines; /// Global line formats (CHCHARTLINE group).
957 : };
958 :
959 : typedef boost::shared_ptr< XclExpChTypeGroup > XclExpChTypeGroupRef;
960 :
961 : // Axes =======================================================================
962 :
963 0 : class XclExpChLabelRange : public XclExpRecord, protected XclExpChRoot
964 : {
965 : public:
966 : explicit XclExpChLabelRange( const XclExpChRoot& rRoot );
967 :
968 : /** Converts category axis scaling settings. */
969 : void Convert( const ::com::sun::star::chart2::ScaleData& rScaleData,
970 : const ScfPropertySet& rChart1Axis, bool bMirrorOrient );
971 : /** Converts position settings of a crossing axis at this axis. */
972 : void ConvertAxisPosition( const ScfPropertySet& rPropSet );
973 : /** Sets flag for tickmark position between categories or on categories. */
974 0 : inline void SetTicksBetweenCateg( bool bTicksBetween )
975 0 : { ::set_flag( maLabelData.mnFlags, EXC_CHLABELRANGE_BETWEEN, bTicksBetween ); }
976 :
977 : private:
978 : virtual void Save( XclExpStream& rStrm ) SAL_OVERRIDE;
979 : virtual void WriteBody( XclExpStream& rStrm ) SAL_OVERRIDE;
980 :
981 : private:
982 : XclChLabelRange maLabelData; /// Contents of the CHLABELRANGE record.
983 : XclChDateRange maDateData; /// Contents of the CHDATERANGE record.
984 : };
985 :
986 : typedef boost::shared_ptr< XclExpChLabelRange > XclExpChLabelRangeRef;
987 :
988 0 : class XclExpChValueRange : public XclExpRecord, protected XclExpChRoot
989 : {
990 : public:
991 : explicit XclExpChValueRange( const XclExpChRoot& rRoot );
992 :
993 : /** Converts value axis scaling settings. */
994 : void Convert( const ::com::sun::star::chart2::ScaleData& rScaleData );
995 : /** Converts position settings of a crossing axis at this axis. */
996 : void ConvertAxisPosition( const ScfPropertySet& rPropSet );
997 :
998 : private:
999 : virtual void WriteBody( XclExpStream& rStrm ) SAL_OVERRIDE;
1000 :
1001 : private:
1002 : XclChValueRange maData; /// Contents of the CHVALUERANGE record.
1003 : };
1004 :
1005 : typedef boost::shared_ptr< XclExpChValueRange > XclExpChValueRangeRef;
1006 :
1007 0 : class XclExpChTick : public XclExpRecord, protected XclExpChRoot
1008 : {
1009 : public:
1010 : explicit XclExpChTick( const XclExpChRoot& rRoot );
1011 :
1012 : /** Converts axis tick mark settings. */
1013 : void Convert( const ScfPropertySet& rPropSet, const XclChExtTypeInfo& rTypeInfo, sal_uInt16 nAxisType );
1014 : /** Sets font color and color identifier to internal data structures. */
1015 : void SetFontColor( const Color& rColor, sal_uInt32 nColorId );
1016 : /** Sets text rotation to internal data structures. */
1017 : void SetRotation( sal_uInt16 nRotation );
1018 :
1019 : private:
1020 : virtual void WriteBody( XclExpStream& rStrm ) SAL_OVERRIDE;
1021 :
1022 : private:
1023 : XclChTick maData; /// Contents of the CHTICK record.
1024 : sal_uInt32 mnTextColorId; /// Axis labels text color identifier.
1025 : };
1026 :
1027 : typedef boost::shared_ptr< XclExpChTick > XclExpChTickRef;
1028 :
1029 : /** Represents the CHAXIS record group describing an entire chart axis.
1030 :
1031 : The CHAXIS group consists of: CHAXIS, CHBEGIN, CHLABELRANGE, CHEXTRANGE,
1032 : CHVALUERANGE, CHFORMAT, CHTICK, CHFONT, CHAXISLINE groups (CHAXISLINE with
1033 : CHLINEFORMAT, CHAREAFORMAT, and CHESCHERFORMAT group), CHEND.
1034 : */
1035 0 : class XclExpChAxis : public XclExpChGroupBase, public XclExpChFontBase
1036 : {
1037 : public:
1038 : typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDiagram > XDiagramRef;
1039 : typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis > XAxisRef;
1040 : typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart::XAxis > XChart1AxisRef;
1041 :
1042 : public:
1043 : explicit XclExpChAxis( const XclExpChRoot& rRoot, sal_uInt16 nAxisType );
1044 :
1045 : /** Sets font color and color identifier to internal data structures. */
1046 : virtual void SetFont( XclExpChFontRef xFont, const Color& rColor, sal_uInt32 nColorId ) SAL_OVERRIDE;
1047 : /** Sets text rotation to internal data structures. */
1048 : virtual void SetRotation( sal_uInt16 nRotation ) SAL_OVERRIDE;
1049 :
1050 : /** Converts formatting and scaling settings from the passed axis. */
1051 : void Convert( XAxisRef xAxis, XAxisRef xCrossingAxis,
1052 : XChart1AxisRef xChart1Axis, const XclChExtTypeInfo& rTypeInfo );
1053 : /** Converts and writes 3D wall/floor properties from the passed diagram. */
1054 : void ConvertWall( XDiagramRef xDiagram );
1055 :
1056 : /** Returns the type of this axis. */
1057 0 : inline sal_uInt16 GetAxisType() const { return maData.mnType; }
1058 : /** Returns the axis dimension index used by the chart API. */
1059 0 : inline sal_Int32 GetApiAxisDimension() const { return maData.GetApiAxisDimension(); }
1060 :
1061 : /** Writes all embedded records. */
1062 : virtual void WriteSubRecords( XclExpStream& rStrm ) SAL_OVERRIDE;
1063 :
1064 : private:
1065 : virtual void WriteBody( XclExpStream& rStrm ) SAL_OVERRIDE;
1066 :
1067 : private:
1068 : XclChAxis maData; /// Contents of the CHAXIS record.
1069 : XclExpChLabelRangeRef mxLabelRange; /// Category scaling (CHLABELRANGE record).
1070 : XclExpChValueRangeRef mxValueRange; /// Value scaling (CHVALUERANGE record).
1071 : XclExpChTickRef mxTick; /// Axis ticks (CHTICK record).
1072 : XclExpChFontRef mxFont; /// Index into font buffer (CHFONT record).
1073 : XclExpChLineFormatRef mxAxisLine; /// Axis line format (CHLINEFORMAT record).
1074 : XclExpChLineFormatRef mxMajorGrid; /// Major grid line format (CHLINEFORMAT record).
1075 : XclExpChLineFormatRef mxMinorGrid; /// Minor grid line format (CHLINEFORMAT record).
1076 : XclExpChFrameRef mxWallFrame; /// Wall/floor format (sub records of CHFRAME group).
1077 : sal_uInt16 mnNumFmtIdx; /// Index into number format buffer (CHFORMAT record).
1078 : };
1079 :
1080 : typedef boost::shared_ptr< XclExpChAxis > XclExpChAxisRef;
1081 :
1082 : /** Represents the CHAXESSET record group describing an axes set (X/Y/Z axes).
1083 :
1084 : The CHAXESSET group consists of: CHAXESSET, CHBEGIN, CHFRAMEPOS, CHAXIS
1085 : groups, CHTEXT groups, CHPLOTFRAME group (CHPLOTFRAME with CHFRAME group),
1086 : CHTYPEGROUP group, CHEND.
1087 : */
1088 0 : class XclExpChAxesSet : public XclExpChGroupBase
1089 : {
1090 : public:
1091 : typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDiagram > XDiagramRef;
1092 : typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XCoordinateSystem > XCoordSystemRef;
1093 :
1094 : public:
1095 : explicit XclExpChAxesSet( const XclExpChRoot& rRoot, sal_uInt16 nAxesSetId );
1096 :
1097 : /** Converts the passed diagram to chart record data.
1098 : @return First unused chart type group index. */
1099 : sal_uInt16 Convert( XDiagramRef xDiagram, sal_uInt16 nFirstGroupIdx );
1100 :
1101 : /** Returns true, if this axes set exists (returns false if this is a dummy object). */
1102 0 : inline bool IsValidAxesSet() const { return !maTypeGroups.IsEmpty(); }
1103 : /** Returns the index of the axes set (primary/secondary). */
1104 0 : inline sal_uInt16 GetAxesSetId() const { return maData.mnAxesSetId; }
1105 : /** Returns the axes set index used by the chart API. */
1106 0 : inline sal_Int32 GetApiAxesSetIndex() const { return maData.GetApiAxesSetIndex(); }
1107 : /** Returns true, if the chart is three-dimensional. */
1108 : bool Is3dChart() const;
1109 :
1110 : /** Writes all embedded records. */
1111 : virtual void WriteSubRecords( XclExpStream& rStrm ) SAL_OVERRIDE;
1112 :
1113 : private:
1114 : /** Returns first inserted chart type group. */
1115 : XclExpChTypeGroupRef GetFirstTypeGroup() const;
1116 : /** Returns last inserted chart type group. */
1117 : XclExpChTypeGroupRef GetLastTypeGroup() const;
1118 :
1119 : /** Converts a complete axis object including axis title. */
1120 : void ConvertAxis( XclExpChAxisRef& rxChAxis, sal_uInt16 nAxisType,
1121 : XclExpChTextRef& rxChAxisTitle, sal_uInt16 nTitleTarget,
1122 : XCoordSystemRef xCoordSystem, const XclChExtTypeInfo& rTypeInfo,
1123 : sal_Int32 nCrossingAxisDim );
1124 :
1125 : virtual void WriteBody( XclExpStream& rStrm ) SAL_OVERRIDE;
1126 :
1127 : private:
1128 : typedef XclExpRecordList< XclExpChTypeGroup > XclExpChTypeGroupList;
1129 :
1130 : XclChAxesSet maData; /// Contents of the CHAXESSET record.
1131 : XclExpChFramePosRef mxFramePos; /// Outer plot area position (CHFRAMEPOS record).
1132 : XclExpChAxisRef mxXAxis; /// The X axis (CHAXIS group).
1133 : XclExpChAxisRef mxYAxis; /// The Y axis (CHAXIS group).
1134 : XclExpChAxisRef mxZAxis; /// The Z axis (CHAXIS group).
1135 : XclExpChTextRef mxXAxisTitle; /// The X axis title (CHTEXT group).
1136 : XclExpChTextRef mxYAxisTitle; /// The Y axis title (CHTEXT group).
1137 : XclExpChTextRef mxZAxisTitle; /// The Z axis title (CHTEXT group).
1138 : XclExpChFrameRef mxPlotFrame; /// Plot area (CHPLOTFRAME group).
1139 : XclExpChTypeGroupList maTypeGroups; /// Chart type groups (CHTYPEGROUP group).
1140 : };
1141 :
1142 : typedef boost::shared_ptr< XclExpChAxesSet > XclExpChAxesSetRef;
1143 :
1144 : // The chart object ===========================================================
1145 :
1146 : /** Represents the CHCHART record group describing the chart contents.
1147 :
1148 : The CHCHART group consists of: CHCHART, CHBEGIN, SCL, CHPLOTGROWTH, CHFRAME
1149 : group, CHSERIES groups, CHPROPERTIES, CHDEFAULTTEXT groups (CHDEFAULTTEXT
1150 : with CHTEXT groups), CHUSEDAXESSETS, CHAXESSET groups, CHTEXT groups, CHEND.
1151 : */
1152 0 : class XclExpChChart : public XclExpChGroupBase
1153 : {
1154 : public:
1155 : typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument > XChartDocRef;
1156 :
1157 : public:
1158 : explicit XclExpChChart( const XclExpRoot& rRoot,
1159 : XChartDocRef xChartDoc, const Rectangle& rChartRect );
1160 :
1161 : /** Creates, registers and returns a new data series object. */
1162 : XclExpChSeriesRef CreateSeries();
1163 : /** Removes the last created data series object from the series list. */
1164 : void RemoveLastSeries();
1165 : /** Stores a CHTEXT group that describes a data point label. */
1166 : void SetDataLabel( XclExpChTextRef xText );
1167 : /** Sets the plot area position and size to manual mode. */
1168 : void SetManualPlotArea();
1169 :
1170 : /** Writes all embedded records. */
1171 : virtual void WriteSubRecords( XclExpStream& rStrm ) SAL_OVERRIDE;
1172 :
1173 : private:
1174 : virtual void WriteBody( XclExpStream& rStrm ) SAL_OVERRIDE;
1175 :
1176 : private:
1177 : typedef XclExpRecordList< XclExpChSeries > XclExpChSeriesList;
1178 : typedef XclExpRecordList< XclExpChText > XclExpChTextList;
1179 :
1180 : XclChRectangle maRect; /// Position of the chart on the sheet (CHCHART record).
1181 : XclExpChSeriesList maSeries; /// List of series data (CHSERIES groups).
1182 : XclExpChFrameRef mxFrame; /// Chart frame format (CHFRAME group).
1183 : XclChProperties maProps; /// Chart properties (CHPROPERTIES record).
1184 : XclExpChAxesSetRef mxPrimAxesSet; /// Primary axes set (CHAXESSET group).
1185 : XclExpChAxesSetRef mxSecnAxesSet; /// Secondary axes set (CHAXESSET group).
1186 : XclExpChTextRef mxTitle; /// Chart title (CHTEXT group).
1187 : XclExpChTextList maLabels; /// Data point labels (CHTEXT groups).
1188 : };
1189 :
1190 : /** Represents the group of DFF and OBJ records containing all drawing shapes
1191 : embedded in the chart object.
1192 : */
1193 : class XclExpChartDrawing : public XclExpRecordBase, protected XclExpRoot
1194 : {
1195 : public:
1196 : explicit XclExpChartDrawing(
1197 : const XclExpRoot& rRoot,
1198 : const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& rxModel,
1199 : const Size& rChartSize );
1200 : virtual ~XclExpChartDrawing();
1201 :
1202 : virtual void Save( XclExpStream& rStrm ) SAL_OVERRIDE;
1203 :
1204 : private:
1205 : boost::shared_ptr< XclExpObjectManager > mxObjMgr;
1206 : boost::shared_ptr< XclExpRecordBase > mxObjRecs;
1207 : };
1208 :
1209 : /** Represents the entire chart substream (all records in BOF/EOF block). */
1210 0 : class XclExpChart : public XclExpSubStream, protected XclExpRoot
1211 : {
1212 : public:
1213 : typedef ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > XModelRef;
1214 :
1215 : public:
1216 : explicit XclExpChart( const XclExpRoot& rRoot,
1217 : XModelRef xModel, const Rectangle& rChartRect );
1218 : };
1219 :
1220 : #endif
1221 :
1222 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|