LCOV - code coverage report
Current view: top level - sc/source/filter/inc - formulabuffer.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 5 7 71.4 %
Date: 2012-08-25 Functions: 8 11 72.7 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 1 2 50.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*
       3                 :            :  * Copyright 2012 LibreOffice contributors.
       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 OOX_XLS_FORMULABUFFER_HXX
      11                 :            : #define OOX_XLS_FORMULABUFFER_HXX
      12                 :            : 
      13                 :            : #include <utility>
      14                 :            : #include "oox/helper/refmap.hxx"
      15                 :            : #include "oox/helper/refvector.hxx"
      16                 :            : #include "workbookhelper.hxx"
      17                 :            : #include <com/sun/star/table/CellAddress.hpp>
      18                 :            : #include <com/sun/star/table/CellRangeAddress.hpp>
      19                 :            : #include <com/sun/star/table/XCellRange.hpp>
      20                 :            : #include <com/sun/star/table/XCell.hpp>
      21                 :            : #include <com/sun/star/sheet/XSpreadsheet.hpp>
      22                 :            : #include <map>
      23                 :            : #include <vector>
      24                 :            : #include "worksheethelper.hxx"
      25                 :            : #include "sheetdatabuffer.hxx"
      26                 :            : #include <com/sun/star/sheet/XFormulaTokens.hpp>
      27                 :            : 
      28                 :            : namespace oox {
      29                 :            : namespace xls {
      30                 :            : 
      31         [ -  + ]:         48 : class FormulaBuffer : public WorkbookHelper
      32                 :            : {
      33                 :            : private:
      34                 :          9 : struct SharedFormulaEntry
      35                 :            : {
      36                 :            :     ::com::sun::star::table::CellAddress maAddress;
      37                 :            :     rtl::OUString maTokenStr;
      38                 :            :     sal_Int32 mnSharedId;
      39                 :            :     ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XFormulaTokens > mxFormulaTokens;
      40                 :          3 :     SharedFormulaEntry( const ::com::sun::star::table::CellAddress& rAddress, const rtl::OUString& rTokenStr, sal_Int32 nSharedId ) : maAddress( rAddress ), maTokenStr( rTokenStr ), mnSharedId( nSharedId ) {}
      41                 :            : };
      42                 :            : 
      43                 :            : 
      44                 :        441 : struct TokenAddressItem
      45                 :            : {
      46                 :            :     ::rtl::OUString maTokenStr;
      47                 :            :     ::com::sun::star::table::CellAddress maCellAddress;
      48                 :         81 :     TokenAddressItem( const rtl::OUString& rTokenStr, const ::com::sun::star::table::CellAddress& rCellAddress ) : maTokenStr( rTokenStr ), maCellAddress( rCellAddress ) {}
      49                 :            : };
      50                 :            : 
      51                 :          0 : struct TokenRangeAddressItem
      52                 :            : {
      53                 :            :     TokenAddressItem maTokenAndAddress;
      54                 :            :     ::com::sun::star::table::CellRangeAddress maCellRangeAddress;
      55                 :          0 :     TokenRangeAddressItem( const TokenAddressItem& rTokenAndAddress, const ::com::sun::star::table::CellRangeAddress& rCellRangeAddress ) : maTokenAndAddress( rTokenAndAddress ), maCellRangeAddress( rCellRangeAddress ) {}
      56                 :            : };
      57                 :            : 
      58                 :            : typedef ::std::map< sal_Int32, std::vector< TokenAddressItem > > FormulaDataMap;
      59                 :            : typedef ::std::map< sal_Int32, std::vector< TokenRangeAddressItem > > ArrayFormulaDataMap;
      60                 :            : // shared formuala descriptions, the id and address the formula is at
      61                 :            : typedef std::pair< ::com::sun::star::table::CellAddress, sal_Int32 > SharedFormulaDesc;
      62                 :            : // sheet -> list of shared formula descriptions
      63                 :            : typedef ::std::map< sal_Int32, std::vector< SharedFormulaDesc > > SheetToSharedFormulaid;
      64                 :            : // sheet -> stuff needed to create shared formulae
      65                 :            : typedef ::std::map< sal_Int32, std::vector< SharedFormulaEntry > >  SheetToFormulaEntryMap;
      66                 :            : // sharedId -> tokedId
      67                 :            : typedef ::std::map< sal_Int32, sal_Int32 > SharedIdToTokenIndex;
      68                 :            : typedef ::std::map< sal_Int32, SharedIdToTokenIndex > SheetToSharedIdToTokenIndex;
      69                 :            : typedef ::std::pair< ::com::sun::star::table::CellAddress, double > ValueAddressPair;
      70                 :            : typedef ::std::map< sal_Int32, std::vector< ValueAddressPair > > FormulaValueMap;
      71                 :            : 
      72                 :            :     void createSharedFormula(  const ::com::sun::star::table::CellAddress& rAddress,  sal_Int32 nSharedId, const rtl::OUString& rTokens );
      73                 :            :     ::com::sun::star::uno::Reference< com::sun::star::table::XCellRange > getRange( const ::com::sun::star::table::CellRangeAddress& rRange);
      74                 :            :     com::sun::star::uno::Reference< com::sun::star::sheet::XSpreadsheet > mxCurrSheet;
      75                 :            :     FormulaDataMap      cellFormulas;
      76                 :            :     ArrayFormulaDataMap cellArrayFormulas;
      77                 :            :     SheetToFormulaEntryMap sharedFormulas;
      78                 :            :     SheetToSharedFormulaid sharedFormulaIds;
      79                 :            :     SheetToSharedIdToTokenIndex tokenIndexes;
      80                 :            :     FormulaValueMap        cellFormulaValues;
      81                 :            : 
      82                 :            :     void                applyArrayFormulas(  const std::vector< TokenRangeAddressItem >& rVector );
      83                 :            :     void                applyCellFormula( ScDocument& rDoc, const ApiTokenSequence& rTokens, const ::com::sun::star::table::CellAddress& rAddress );
      84                 :            :     void                applyCellFormulas(  const std::vector< TokenAddressItem >& rVector );
      85                 :            :     void                applyCellFormulaValues( const std::vector< ValueAddressPair >& rVector );
      86                 :            : 
      87                 :            : public:
      88                 :            :     explicit            FormulaBuffer( const WorkbookHelper& rHelper );
      89                 :            :     void                finalizeImport();
      90                 :            :     void                setCellFormula( const ::com::sun::star::table::CellAddress& rAddress, const rtl::OUString&  );
      91                 :            :     void                setCellFormula( const ::com::sun::star::table::CellAddress& rAddress, sal_Int32 nSharedId );
      92                 :            :     void                setCellFormulaValue( const ::com::sun::star::table::CellAddress& rAddress, double fValue  );
      93                 :            :     void                setCellArrayFormula( const ::com::sun::star::table::CellRangeAddress& rRangeAddress, const ::com::sun::star::table::CellAddress& rTokenAddress, const rtl::OUString&  );
      94                 :            :     void                createSharedFormulaMapEntry( const ::com::sun::star::table::CellAddress& rAddress, sal_Int32 nSharedId, const rtl::OUString& rTokens );
      95                 :            : };
      96                 :            : }
      97                 :            : }
      98                 :            : #endif
      99                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10