LCOV - code coverage report
Current view: top level - libreoffice/sc/source/filter/inc - tablebuffer.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 13 7.7 %
Date: 2012-12-27 Functions: 2 15 13.3 %
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_TABLEBUFFER_HXX
      21             : #define OOX_XLS_TABLEBUFFER_HXX
      22             : 
      23             : #include <com/sun/star/table/CellRangeAddress.hpp>
      24             : #include "autofilterbuffer.hxx"
      25             : #include "workbookhelper.hxx"
      26             : 
      27             : namespace oox {
      28             : namespace xls {
      29             : 
      30             : // ============================================================================
      31             : 
      32           0 : struct TableModel
      33             : {
      34             :     ::com::sun::star::table::CellRangeAddress
      35             :                         maRange;            /// Original (unchecked) range of the table.
      36             :     ::rtl::OUString     maProgName;         /// Programmatical name.
      37             :     ::rtl::OUString     maDisplayName;      /// Display name.
      38             :     sal_Int32           mnId;               /// Unique table identifier.
      39             :     sal_Int32           mnType;             /// Table type (worksheet, query, etc.).
      40             :     sal_Int32           mnHeaderRows;       /// Number of header rows.
      41             :     sal_Int32           mnTotalsRows;       /// Number of totals rows.
      42             : 
      43             :     explicit            TableModel();
      44             : };
      45             : 
      46             : // ----------------------------------------------------------------------------
      47             : 
      48           0 : class Table : public WorkbookHelper
      49             : {
      50             : public:
      51             :     explicit            Table( const WorkbookHelper& rHelper );
      52             : 
      53             :     /** Imports a table definition from the passed attributes. */
      54             :     void                importTable( const AttributeList& rAttribs, sal_Int16 nSheet );
      55             :     /** Imports a table definition from a TABLE record. */
      56             :     void                importTable( SequenceInputStream& rStrm, sal_Int16 nSheet );
      57             :     /** Creates a new auto filter and stores it internally. */
      58           0 :     inline AutoFilter&  createAutoFilter() { return maAutoFilters.createAutoFilter(); }
      59             : 
      60             :     /** Creates a database range from this tables. */
      61             :     void                finalizeImport();
      62             : 
      63             :     /** Returns the unique table identifier. */
      64           0 :     inline sal_Int32    getTableId() const { return maModel.mnId; }
      65             :     /** Returns the token index used in API token arrays (com.sun.star.sheet.FormulaToken). */
      66           0 :     inline sal_Int32    getTokenIndex() const { return mnTokenIndex; }
      67             :     /** Returns the original display name of the table. */
      68           0 :     inline const ::rtl::OUString& getDisplayName() const { return maModel.maDisplayName; }
      69             : 
      70             :     /** Returns the original (unchecked) total range of the table. */
      71           0 :     inline const ::com::sun::star::table::CellRangeAddress& getOriginalRange() const { return maModel.maRange; }
      72             :     /** Returns the cell range of this table. */
      73           0 :     inline const ::com::sun::star::table::CellRangeAddress& getRange() const { return maDestRange; }
      74             :     /** Returns the number of columns of this table. */
      75           0 :     inline sal_Int32    getWidth() const { return maDestRange.EndColumn - maDestRange.StartColumn + 1; }
      76             :     /** Returns the number of rows of this table. */
      77           0 :     inline sal_Int32    getHeight() const { return maDestRange.EndRow - maDestRange.StartRow + 1; }
      78             :     /** Returns the number of header rows in the table range. */
      79           0 :     inline sal_Int32    getHeaderRows() const { return maModel.mnHeaderRows; }
      80             :     /** Returns the number of totals rows in the table range. */
      81           0 :     inline sal_Int32    getTotalsRows() const { return maModel.mnTotalsRows; }
      82             : 
      83             : private:
      84             :     TableModel          maModel;
      85             :     AutoFilterBuffer    maAutoFilters;      /// Filter settings for this table.
      86             :     ::rtl::OUString     maDBRangeName;      /// Name of the databae range in the Calc document.
      87             :     ::com::sun::star::table::CellRangeAddress
      88             :                         maDestRange;        /// Validated range of the table in the worksheet.
      89             :     sal_Int32           mnTokenIndex;       /// Token index used in API token array.
      90             : };
      91             : 
      92             : typedef ::boost::shared_ptr< Table > TableRef;
      93             : 
      94             : // ============================================================================
      95             : 
      96          22 : class TableBuffer : public WorkbookHelper
      97             : {
      98             : public:
      99             :     explicit            TableBuffer( const WorkbookHelper& rHelper );
     100             : 
     101             :     /** Creates a new empty table. */
     102             :     Table&              createTable();
     103             : 
     104             :     /** Creates database ranges from all imported tables. */
     105             :     void                finalizeImport();
     106             : 
     107             :     /** Returns a table by its identifier. */
     108             :     TableRef            getTable( sal_Int32 nTableId ) const;
     109             :     /** Returns a table by its display name. */
     110             :     TableRef            getTable( const ::rtl::OUString& rDispName ) const;
     111             : 
     112             : private:
     113             :     /** Inserts the passed table into the maps according to its identifier and name. */
     114             :     void                insertTableToMaps( const TableRef& rxTable );
     115             : 
     116             : private:
     117             :     typedef RefVector< Table >                  TableVector;
     118             :     typedef RefMap< sal_Int32, Table >          TableIdMap;
     119             :     typedef RefMap< ::rtl::OUString, Table >    TableNameMap;
     120             : 
     121             :     TableVector         maTables;
     122             :     TableIdMap          maIdTables;
     123             :     TableNameMap        maNameTables;
     124             : };
     125             : 
     126             : // ============================================================================
     127             : 
     128             : } // namespace xls
     129             : } // namespace oox
     130             : 
     131             : #endif
     132             : 
     133             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10