LCOV - code coverage report
Current view: top level - sc/source/filter/inc - formulabuffer.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 6 8 75.0 %
Date: 2015-06-13 12:38:46 Functions: 14 18 77.8 %
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             : 
      10             : #ifndef INCLUDED_SC_SOURCE_FILTER_INC_FORMULABUFFER_HXX
      11             : #define INCLUDED_SC_SOURCE_FILTER_INC_FORMULABUFFER_HXX
      12             : 
      13             : #include <utility>
      14             : #include <oox/helper/refmap.hxx>
      15             : #include <oox/helper/refvector.hxx>
      16             : #include <salhelper/thread.hxx>
      17             : #include <osl/mutex.hxx>
      18             : #include "workbookhelper.hxx"
      19             : #include <com/sun/star/table/CellAddress.hpp>
      20             : #include <com/sun/star/table/CellRangeAddress.hpp>
      21             : #include <com/sun/star/table/XCellRange.hpp>
      22             : #include <com/sun/star/table/XCell.hpp>
      23             : #include <com/sun/star/sheet/XSpreadsheet.hpp>
      24             : #include <map>
      25             : #include <vector>
      26             : #include "worksheethelper.hxx"
      27             : #include "sheetdatabuffer.hxx"
      28             : #include <com/sun/star/sheet/XFormulaTokens.hpp>
      29             : 
      30             : namespace oox { namespace xls {
      31             : 
      32         290 : class FormulaBuffer : public WorkbookHelper
      33             : {
      34             : public:
      35             :     /**
      36             :      * Represents a shared formula definition.
      37             :      */
      38         393 :     struct SharedFormulaEntry
      39             :     {
      40             :         com::sun::star::table::CellAddress maAddress;
      41             :         com::sun::star::table::CellRangeAddress maRange;
      42             :         OUString maTokenStr;
      43             :         sal_Int32 mnSharedId;
      44             : 
      45             :         SharedFormulaEntry(
      46             :             const com::sun::star::table::CellAddress& rAddress,
      47             :             const com::sun::star::table::CellRangeAddress& rRange,
      48             :             const OUString& rTokenStr, sal_Int32 nSharedId );
      49             :     };
      50             : 
      51             :     /**
      52             :      * Represents a formula cell that uses shared formula.
      53             :      */
      54        7284 :     struct SharedFormulaDesc
      55             :     {
      56             :         com::sun::star::table::CellAddress maAddress;
      57             :         sal_Int32 mnSharedId;
      58             :         OUString maCellValue;
      59             :         sal_Int32 mnValueType;
      60             : 
      61             :         SharedFormulaDesc(
      62             :             const com::sun::star::table::CellAddress& rAddr, sal_Int32 nSharedId,
      63             :             const OUString& rCellValue, sal_Int32 nValueType );
      64             :     };
      65             : 
      66        6479 :     struct TokenAddressItem
      67             :     {
      68             :         OUString maTokenStr;
      69             :         ::com::sun::star::table::CellAddress maCellAddress;
      70        1067 :         TokenAddressItem( const OUString& rTokenStr, const ::com::sun::star::table::CellAddress& rCellAddress ) : maTokenStr( rTokenStr ), maCellAddress( rCellAddress ) {}
      71             :     };
      72             : 
      73           0 :     struct TokenRangeAddressItem
      74             :     {
      75             :         TokenAddressItem maTokenAndAddress;
      76             :         ::com::sun::star::table::CellRangeAddress maCellRangeAddress;
      77           0 :         TokenRangeAddressItem( const TokenAddressItem& rTokenAndAddress, const ::com::sun::star::table::CellRangeAddress& rCellRangeAddress ) : maTokenAndAddress( rTokenAndAddress ), maCellRangeAddress( rCellRangeAddress ) {}
      78             :     };
      79             : 
      80        7535 :     struct FormulaValue
      81             :     {
      82             :         com::sun::star::table::CellAddress maCellAddress;
      83             :         OUString maValueStr;
      84             :         sal_Int32 mnCellType;
      85             :     };
      86             :     typedef std::pair<com::sun::star::table::CellAddress, double> ValueAddressPair;
      87             : 
      88             :     struct SheetItem
      89             :     {
      90             :         std::vector<TokenAddressItem>* mpCellFormulas;
      91             :         std::vector<TokenRangeAddressItem>* mpArrayFormulas;
      92             :         std::vector<FormulaValue>* mpCellFormulaValues;
      93             :         std::vector<SharedFormulaEntry>* mpSharedFormulaEntries;
      94             :         std::vector<SharedFormulaDesc>* mpSharedFormulaIDs;
      95             : 
      96             :         SheetItem();
      97             :     };
      98             : 
      99             : private:
     100             :     // Vectors indexed by SCTAB - cf. SetSheetCount
     101             :     typedef ::std::vector< std::vector<TokenAddressItem> > FormulaDataArray;
     102             :     typedef ::std::vector< std::vector<TokenRangeAddressItem> > ArrayFormulaDataArray;
     103             :     // sheet -> list of shared formula descriptions
     104             :     typedef ::std::vector< std::vector<SharedFormulaDesc> > SheetToSharedFormulaid;
     105             :     // sheet -> stuff needed to create shared formulae
     106             :     typedef ::std::vector< std::vector<SharedFormulaEntry> >  SheetToFormulaEntryArray;
     107             :     typedef ::std::vector< std::vector<FormulaValue> > FormulaValueArray;
     108             : 
     109             :     osl::Mutex maMtxData;
     110             :     FormulaDataArray         maCellFormulas;
     111             :     ArrayFormulaDataArray    maCellArrayFormulas;
     112             :     SheetToFormulaEntryArray maSharedFormulas;
     113             :     SheetToSharedFormulaid   maSharedFormulaIds;
     114             :     FormulaValueArray        maCellFormulaValues;
     115             : 
     116             :     SheetItem getSheetItem( SCTAB nTab );
     117             : 
     118             : public:
     119             :     explicit            FormulaBuffer( const WorkbookHelper& rHelper );
     120             :     void                finalizeImport();
     121             :     void                setCellFormula( const ::com::sun::star::table::CellAddress& rAddress, const OUString&  );
     122             : 
     123             :     void setCellFormula(
     124             :         const ::com::sun::star::table::CellAddress& rAddress, sal_Int32 nSharedId,
     125             :         const OUString& rCellValue, sal_Int32 nValueType );
     126             : 
     127             :     void setCellFormulaValue(
     128             :         const css::table::CellAddress& rAddress, const OUString& rValueStr, sal_Int32 nCellType );
     129             : 
     130             :     void                setCellArrayFormula( const css::table::CellRangeAddress& rRangeAddress,
     131             :                                              const css::table::CellAddress& rTokenAddress,
     132             :                                              const OUString& );
     133             :     void                createSharedFormulaMapEntry( const css::table::CellAddress& rAddress,
     134             :                                                      const css::table::CellRangeAddress& rRange,
     135             :                                                      sal_Int32 nSharedId, const OUString& rTokens );
     136             : 
     137             :     /// ensure sizes of vectors matches the number of sheets
     138             :     void SetSheetCount( SCTAB nSheets );
     139             : };
     140             : 
     141             : }}
     142             : 
     143             : #endif
     144             : 
     145             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11