LCOV - code coverage report
Current view: top level - sc/source/filter/inc - tablebuffer.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 13 7.7 %
Date: 2012-08-25 Functions: 2 15 13.3 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 1 6 16.7 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #ifndef OOX_XLS_TABLEBUFFER_HXX
      30                 :            : #define OOX_XLS_TABLEBUFFER_HXX
      31                 :            : 
      32                 :            : #include <com/sun/star/table/CellRangeAddress.hpp>
      33                 :            : #include "autofilterbuffer.hxx"
      34                 :            : #include "workbookhelper.hxx"
      35                 :            : 
      36                 :            : namespace oox {
      37                 :            : namespace xls {
      38                 :            : 
      39                 :            : // ============================================================================
      40                 :            : 
      41                 :          0 : struct TableModel
      42                 :            : {
      43                 :            :     ::com::sun::star::table::CellRangeAddress
      44                 :            :                         maRange;            /// Original (unchecked) range of the table.
      45                 :            :     ::rtl::OUString     maProgName;         /// Programmatical name.
      46                 :            :     ::rtl::OUString     maDisplayName;      /// Display name.
      47                 :            :     sal_Int32           mnId;               /// Unique table identifier.
      48                 :            :     sal_Int32           mnType;             /// Table type (worksheet, query, etc.).
      49                 :            :     sal_Int32           mnHeaderRows;       /// Number of header rows.
      50                 :            :     sal_Int32           mnTotalsRows;       /// Number of totals rows.
      51                 :            : 
      52                 :            :     explicit            TableModel();
      53                 :            : };
      54                 :            : 
      55                 :            : // ----------------------------------------------------------------------------
      56                 :            : 
      57 [ #  # ][ #  # ]:          0 : class Table : public WorkbookHelper
      58                 :            : {
      59                 :            : public:
      60                 :            :     explicit            Table( const WorkbookHelper& rHelper );
      61                 :            : 
      62                 :            :     /** Imports a table definition from the passed attributes. */
      63                 :            :     void                importTable( const AttributeList& rAttribs, sal_Int16 nSheet );
      64                 :            :     /** Imports a table definition from a TABLE record. */
      65                 :            :     void                importTable( SequenceInputStream& rStrm, sal_Int16 nSheet );
      66                 :            :     /** Creates a new auto filter and stores it internally. */
      67                 :          0 :     inline AutoFilter&  createAutoFilter() { return maAutoFilters.createAutoFilter(); }
      68                 :            : 
      69                 :            :     /** Creates a database range from this tables. */
      70                 :            :     void                finalizeImport();
      71                 :            : 
      72                 :            :     /** Returns the unique table identifier. */
      73                 :          0 :     inline sal_Int32    getTableId() const { return maModel.mnId; }
      74                 :            :     /** Returns the token index used in API token arrays (com.sun.star.sheet.FormulaToken). */
      75                 :          0 :     inline sal_Int32    getTokenIndex() const { return mnTokenIndex; }
      76                 :            :     /** Returns the original display name of the table. */
      77                 :          0 :     inline const ::rtl::OUString& getDisplayName() const { return maModel.maDisplayName; }
      78                 :            : 
      79                 :            :     /** Returns the original (unchecked) total range of the table. */
      80                 :          0 :     inline const ::com::sun::star::table::CellRangeAddress& getOriginalRange() const { return maModel.maRange; }
      81                 :            :     /** Returns the cell range of this table. */
      82                 :          0 :     inline const ::com::sun::star::table::CellRangeAddress& getRange() const { return maDestRange; }
      83                 :            :     /** Returns the number of columns of this table. */
      84                 :          0 :     inline sal_Int32    getWidth() const { return maDestRange.EndColumn - maDestRange.StartColumn + 1; }
      85                 :            :     /** Returns the number of rows of this table. */
      86                 :          0 :     inline sal_Int32    getHeight() const { return maDestRange.EndRow - maDestRange.StartRow + 1; }
      87                 :            :     /** Returns the number of header rows in the table range. */
      88                 :          0 :     inline sal_Int32    getHeaderRows() const { return maModel.mnHeaderRows; }
      89                 :            :     /** Returns the number of totals rows in the table range. */
      90                 :          0 :     inline sal_Int32    getTotalsRows() const { return maModel.mnTotalsRows; }
      91                 :            : 
      92                 :            : private:
      93                 :            :     TableModel          maModel;
      94                 :            :     AutoFilterBuffer    maAutoFilters;      /// Filter settings for this table.
      95                 :            :     ::rtl::OUString     maDBRangeName;      /// Name of the databae range in the Calc document.
      96                 :            :     ::com::sun::star::table::CellRangeAddress
      97                 :            :                         maDestRange;        /// Validated range of the table in the worksheet.
      98                 :            :     sal_Int32           mnTokenIndex;       /// Token index used in API token array.
      99                 :            : };
     100                 :            : 
     101                 :            : typedef ::boost::shared_ptr< Table > TableRef;
     102                 :            : 
     103                 :            : // ============================================================================
     104                 :            : 
     105         [ -  + ]:         48 : class TableBuffer : public WorkbookHelper
     106                 :            : {
     107                 :            : public:
     108                 :            :     explicit            TableBuffer( const WorkbookHelper& rHelper );
     109                 :            : 
     110                 :            :     /** Creates a new empty table. */
     111                 :            :     Table&              createTable();
     112                 :            : 
     113                 :            :     /** Creates database ranges from all imported tables. */
     114                 :            :     void                finalizeImport();
     115                 :            : 
     116                 :            :     /** Returns a table by its identifier. */
     117                 :            :     TableRef            getTable( sal_Int32 nTableId ) const;
     118                 :            :     /** Returns a table by its display name. */
     119                 :            :     TableRef            getTable( const ::rtl::OUString& rDispName ) const;
     120                 :            : 
     121                 :            : private:
     122                 :            :     /** Inserts the passed table into the maps according to its identifier and name. */
     123                 :            :     void                insertTableToMaps( const TableRef& rxTable );
     124                 :            : 
     125                 :            : private:
     126                 :            :     typedef RefVector< Table >                  TableVector;
     127                 :            :     typedef RefMap< sal_Int32, Table >          TableIdMap;
     128                 :            :     typedef RefMap< ::rtl::OUString, Table >    TableNameMap;
     129                 :            : 
     130                 :            :     TableVector         maTables;
     131                 :            :     TableIdMap          maIdTables;
     132                 :            :     TableNameMap        maNameTables;
     133                 :            : };
     134                 :            : 
     135                 :            : // ============================================================================
     136                 :            : 
     137                 :            : } // namespace xls
     138                 :            : } // namespace oox
     139                 :            : 
     140                 :            : #endif
     141                 :            : 
     142                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10