LCOV - code coverage report
Current view: top level - libreoffice/sc/source/filter/inc - xechart.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 69 0.0 %
Date: 2012-12-27 Functions: 0 98 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10