LCOV - code coverage report
Current view: top level - sc/source/filter/inc - condformatbuffer.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 20 0.0 %
Date: 2014-04-14 Functions: 0 27 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 OOX_XLS_CONDFORMATBUFFER_HXX
      21             : #define OOX_XLS_CONDFORMATBUFFER_HXX
      22             : 
      23             : #include <com/sun/star/sheet/ConditionOperator2.hpp>
      24             : #include "formulaparser.hxx"
      25             : #include "worksheethelper.hxx"
      26             : #include <boost/scoped_ptr.hpp>
      27             : #include <tools/color.hxx>
      28             : 
      29             : namespace com { namespace sun { namespace star {
      30             :     namespace sheet { class XSheetConditionalEntries; }
      31             : } } }
      32             : class ScColorScaleFormat;
      33             : class ScDataBarFormat;
      34             : struct ScDataBarFormatData;
      35             : class ScConditionalFormat;
      36             : class ScIconSetFormat;
      37             : struct ScIconSetFormatData;
      38             : 
      39             : namespace oox {
      40             : namespace xls {
      41             : 
      42             : class CondFormat;
      43             : 
      44             : /** Model for a single rule in a conditional formatting. */
      45           0 : struct CondFormatRuleModel
      46             : {
      47             :     typedef ::std::vector< ApiTokenSequence > ApiTokenSequenceVector;
      48             : 
      49             :     ApiTokenSequenceVector maFormulas;      /// Formulas for rule conditions.
      50             :     OUString     maText;             /// Text for 'contains' rules.
      51             :     sal_Int32           mnPriority;         /// Priority of this rule.
      52             :     sal_Int32           mnType;             /// Type of the rule.
      53             :     sal_Int32           mnOperator;         /// In cell-is rules: Comparison operator.
      54             :     sal_Int32           mnTimePeriod;       /// In time-period rules: Type of time period.
      55             :     sal_Int32           mnRank;             /// In top-10 rules: True = bottom, false = top.
      56             :     sal_Int32           mnStdDev;           /// In average rules: Number of std deviations.
      57             :     sal_Int32           mnDxfId;            /// Differential formatting identifier.
      58             :     bool                mbStopIfTrue;       /// True = stop evaluating rules, if this rule is true.
      59             :     bool                mbBottom;           /// In top-10 rules: True = bottom, false = top.
      60             :     bool                mbPercent;          /// In top-10 rules: True = percent, false = rank.
      61             :     bool                mbAboveAverage;     /// In average rules: True = above average, false = below.
      62             :     bool                mbEqualAverage;     /// In average rules: True = include average, false = exclude.
      63             : 
      64             :     explicit            CondFormatRuleModel();
      65             : 
      66             :     /** Sets the passed BIFF operator for condition type cellIs. */
      67             :     void                setBiffOperator( sal_Int32 nOperator );
      68             : 
      69             :     /** Sets the passed BIFF12 text comparison type and operator. */
      70             :     void                setBiff12TextType( sal_Int32 nOperator );
      71             : };
      72             : 
      73           0 : struct ColorScaleRuleModelEntry
      74             : {
      75             :     ::Color maColor;
      76             :     double mnVal;
      77             : 
      78             :     bool mbMin;
      79             :     bool mbMax;
      80             :     bool mbPercent;
      81             :     bool mbPercentile;
      82             :     OUString maFormula;
      83             : 
      84           0 :     ColorScaleRuleModelEntry():
      85             :         maColor(),
      86             :         mnVal(0),
      87             :         mbMin(false),
      88             :         mbMax(false),
      89             :         mbPercent(false),
      90           0 :         mbPercentile(false) {}
      91             : };
      92             : 
      93           0 : class ColorScaleRule : public WorksheetHelper
      94             : {
      95             : public:
      96             :     ColorScaleRule( const CondFormat& rFormat );
      97             : 
      98             :     void importCfvo( const AttributeList& rAttribs );
      99             :     void importColor( const AttributeList& rAttribs );
     100             : 
     101             :     void AddEntries( ScColorScaleFormat* pFormat, ScDocument* pDoc, const ScAddress& rAddr );
     102             : 
     103             : private:
     104             :     std::vector< ColorScaleRuleModelEntry > maColorScaleRuleEntries;
     105             : 
     106             :     sal_uInt32 mnCfvo;
     107             :     sal_uInt32 mnCol;
     108             : };
     109             : 
     110           0 : class DataBarRule : public WorksheetHelper
     111             : {
     112             : public:
     113             :     DataBarRule( const CondFormat& rFormat );
     114             :     void importCfvo( const AttributeList& rAttribs );
     115             :     void importColor( const AttributeList& rAttribs );
     116             :     void importAttribs( const AttributeList& rAttribs );
     117             : 
     118             :     void SetData( ScDataBarFormat* pFormat, ScDocument* pDoc, const ScAddress& rAddr );
     119             : 
     120           0 :     ScDataBarFormatData* getDataBarFormatData() { return mpFormat; }
     121             : 
     122             : private:
     123             :     ScDataBarFormatData* mpFormat;
     124             : 
     125             :     boost::scoped_ptr<ColorScaleRuleModelEntry> mpUpperLimit;
     126             :     boost::scoped_ptr<ColorScaleRuleModelEntry> mpLowerLimit;
     127             : };
     128             : 
     129           0 : class IconSetRule : public WorksheetHelper
     130             : {
     131             : public:
     132             :     IconSetRule( const CondFormat& rFormat );
     133             :     void importCfvo( const AttributeList& rAttribs );
     134             :     void importAttribs( const AttributeList& rAttribs );
     135             : 
     136             :     void SetData( ScIconSetFormat* pFormat, ScDocument* pDoc, const ScAddress& rAddr );
     137             : 
     138             : private:
     139             :     std::vector< ColorScaleRuleModelEntry > maEntries;
     140             :     ScIconSetFormatData* mpFormatData;
     141             :     OUString maIconSetType;
     142             : };
     143             : 
     144             : 
     145             : 
     146             : /** Represents a single rule in a conditional formatting. */
     147           0 : class CondFormatRule : public WorksheetHelper
     148             : {
     149             : public:
     150             :     explicit            CondFormatRule( const CondFormat& rCondFormat, ScConditionalFormat* pFormat );
     151             : 
     152             :     /** Imports rule settings from the cfRule element. */
     153             :     void                importCfRule( const AttributeList& rAttribs );
     154             :     /** Appends a new condition formula string. */
     155             :     void                appendFormula( const OUString& rFormula );
     156             : 
     157             :     /** Imports rule settings from a CFRULE record. */
     158             :     void                importCfRule( SequenceInputStream& rStrm );
     159             : 
     160             :     /** Creates a conditional formatting rule in the Calc document. */
     161             :     void                finalizeImport();
     162             : 
     163             :     /** Returns the priority of this rule. */
     164           0 :     inline sal_Int32    getPriority() const { return maModel.mnPriority; }
     165             : 
     166             :     ColorScaleRule*     getColorScale();
     167             :     DataBarRule*        getDataBar();
     168             :     IconSetRule*            getIconSet();
     169             : 
     170             : private:
     171             :     const CondFormat&   mrCondFormat;
     172             :     CondFormatRuleModel maModel;
     173             :     ScConditionalFormat* mpFormat;
     174             :     boost::scoped_ptr<ColorScaleRule> mpColor;
     175             :     boost::scoped_ptr<DataBarRule> mpDataBar;
     176             :     boost::scoped_ptr<IconSetRule> mpIconSet;
     177             : };
     178             : 
     179             : typedef ::boost::shared_ptr< CondFormatRule > CondFormatRuleRef;
     180             : 
     181             : /** Model for a conditional formatting object. */
     182           0 : struct CondFormatModel
     183             : {
     184             :     ApiCellRangeList    maRanges;           /// Cell ranges for this conditional format.
     185             :     bool                mbPivot;            /// Conditional formatting belongs to pivot table.
     186             : 
     187             :     explicit            CondFormatModel();
     188             : };
     189             : 
     190             : /** Represents a conditional formatting object with a list of affected cell ranges. */
     191           0 : class CondFormat : public WorksheetHelper
     192             : {
     193             : public:
     194             :     explicit            CondFormat( const WorksheetHelper& rHelper );
     195             : 
     196             :     /** Imports settings from the conditionalFormatting element. */
     197             :     void                importConditionalFormatting( const AttributeList& rAttribs );
     198             :     /** Imports a conditional formatting rule from the cfRule element. */
     199             :     CondFormatRuleRef   importCfRule( const AttributeList& rAttribs );
     200             : 
     201             :     /** Imports settings from the CONDFORMATTING record. */
     202             :     void                importCondFormatting( SequenceInputStream& rStrm );
     203             :     /** Imports a conditional formatting rule from the CFRULE record. */
     204             :     void                importCfRule( SequenceInputStream& rStrm );
     205             : 
     206             :     /** Creates the conditional formatting in the Calc document. */
     207             :     void                finalizeImport();
     208             : 
     209             :     /** Returns the cell ranges this conditional formatting belongs to. */
     210           0 :     inline const ApiCellRangeList& getRanges() const { return maModel.maRanges; }
     211             : 
     212           0 :     void                setReadyForFinalize() { mbReadyForFinalize = true; }
     213             : private:
     214             :     CondFormatRuleRef   createRule();
     215             :     void                insertRule( CondFormatRuleRef xRule );
     216             : 
     217             : private:
     218             :     typedef RefMap< sal_Int32, CondFormatRule > CondFormatRuleMap;
     219             : 
     220             :     CondFormatModel     maModel;            /// Model of this conditional formatting.
     221             :     CondFormatRuleMap   maRules;            /// Maps formatting rules by priority.
     222             :     ScConditionalFormat* mpFormat;
     223             :     bool                mbReadyForFinalize;
     224             : };
     225             : 
     226           0 : struct ExCfRuleModel
     227             : {
     228           0 :     ExCfRuleModel() : mbGradient( false ), mbNegativeBarColorSameAsPositive( false ), mnAxisColor( API_RGB_TRANSPARENT ), mnNegativeColor( API_RGB_TRANSPARENT ), mbIsLower( true ) {}
     229             :     // DataBar
     230             :     bool mbGradient;
     231             :     OUString maAxisPosition;
     232             :     bool mbNegativeBarColorSameAsPositive;
     233             :     // AxisColor
     234             :     sal_Int32 mnAxisColor;
     235             :     // NegativeFillColor
     236             :     sal_Int32 mnNegativeColor;
     237             :     // Cfvo
     238             :     bool mbIsLower;
     239             :     OUString maColorScaleType;
     240             : };
     241             : 
     242           0 : class ExtCfRule
     243             : {
     244             :     enum RuleType
     245             :     {
     246             :         DATABAR,
     247             :         NEGATIVEFILLCOLOR,
     248             :         AXISCOLOR,
     249             :         CFVO,
     250             :         UNKNOWN,
     251             :     };
     252             :     ExCfRuleModel maModel;
     253             :     RuleType mnRuleType;
     254             :     void*    mpTarget;
     255             : public:
     256           0 :     ExtCfRule(void* pTarget = NULL ) : mnRuleType( ExtCfRule::UNKNOWN ), mpTarget(pTarget) {}
     257             :     void finalizeImport();
     258             :     void importDataBar(  const AttributeList& rAttribs );
     259             :     void importNegativeFillColor(  const AttributeList& rAttribs );
     260             :     void importAxisColor(  const AttributeList& rAttribs );
     261             :     void importCfvo(  const AttributeList& rAttribs );
     262           0 :     ExCfRuleModel& getModel() { return maModel; }
     263             : };
     264             : 
     265             : typedef ::boost::shared_ptr< CondFormat > CondFormatRef;
     266             : typedef ::boost::shared_ptr< ExtCfRule > ExtCfRuleRef;
     267             : 
     268           0 : class CondFormatBuffer : public WorksheetHelper
     269             : {
     270             : public:
     271             :     explicit            CondFormatBuffer( const WorksheetHelper& rHelper );
     272             : 
     273             :     /** Imports settings from the conditionalFormatting element. */
     274             :     CondFormatRef       importConditionalFormatting( const AttributeList& rAttribs );
     275             :     /** Imports settings from the CONDFORMATTING record. */
     276             :     CondFormatRef       importCondFormatting( SequenceInputStream& rStrm );
     277             :     ExtCfRuleRef        createExtCfRule( void* pTarget );
     278             : 
     279             :     /** Converts an OOXML condition operator token to the API constant. */
     280             :     static sal_Int32    convertToApiOperator( sal_Int32 nToken );
     281             :     static sal_Int32    convertToInternalOperator( sal_Int32 nToken );
     282             :     void                finalizeImport();
     283             : private:
     284             :     CondFormatRef       createCondFormat();
     285             : 
     286             : private:
     287             :     typedef RefVector< CondFormat > CondFormatVec;
     288             :     typedef RefVector< ExtCfRule > ExtCfRuleVec;
     289             :     CondFormatVec       maCondFormats;      /// All conditional formatting in a sheet.
     290             :     ExtCfRuleVec        maCfRules;          /// All external conditional formatting rules in a sheet.
     291             : };
     292             : 
     293             : } // namespace xls
     294             : } // namespace oox
     295             : 
     296             : #endif
     297             : 
     298             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10