LCOV - code coverage report
Current view: top level - sc/source/filter/inc - worksheetbuffer.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 3 3 100.0 %
Date: 2015-06-13 12:38:46 Functions: 5 5 100.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 INCLUDED_SC_SOURCE_FILTER_INC_WORKSHEETBUFFER_HXX
      21             : #define INCLUDED_SC_SOURCE_FILTER_INC_WORKSHEETBUFFER_HXX
      22             : 
      23             : #include <utility>
      24             : #include <oox/helper/refmap.hxx>
      25             : #include <oox/helper/refvector.hxx>
      26             : #include "workbookhelper.hxx"
      27             : #include "documentimport.hxx"
      28             : 
      29             : namespace com { namespace sun { namespace star {
      30             :     namespace i18n { class XCharacterClassification; }
      31             : } } }
      32             : 
      33             : namespace oox {
      34             : namespace xls {
      35             : 
      36             : /** Contains data from the 'sheet' element describing a sheet in the workbook. */
      37         807 : struct SheetInfoModel
      38             : {
      39             :     OUString     maRelId;        /// Relation identifier for the sheet substream.
      40             :     OUString     maName;         /// Original name of the sheet.
      41             :     sal_Int64           mnBiffHandle;   /// BIFF record handle of the sheet substream.
      42             :     sal_Int32           mnSheetId;      /// Sheet identifier.
      43             :     sal_Int32           mnState;        /// Visibility state.
      44             : 
      45             :     explicit            SheetInfoModel();
      46             : };
      47             : 
      48             : /** Stores information about all sheets in a spreadsheet document.
      49             : 
      50             :     Information about sheets includes the sheet name, the visibility state, and
      51             :     for the OOXML filter, the relation identifier of the sheet used to obtain
      52             :     the related worksheet fragment.
      53             :  */
      54         290 : class WorksheetBuffer : public WorkbookHelper
      55             : {
      56             : public:
      57             :     explicit            WorksheetBuffer( const WorkbookHelper& rHelper );
      58             : 
      59             :     /** Imports the attributes of a sheet element. */
      60             :     void                importSheet( const AttributeList& rAttribs );
      61             :     /** Imports the SHEET record from the passed BIFF12 stream. */
      62             :     void                importSheet( SequenceInputStream& rStrm );
      63             :     /** Inserts a new empty sheet into the document. Looks for an unused name.
      64             :          @return  Index of the new sheet in the Calc document. */
      65             :     sal_Int16           insertEmptySheet( const OUString& rPreferredName, bool bVisible );
      66             : 
      67             :     /** Returns the number of original sheets contained in the workbook. */
      68             :     sal_Int32           getWorksheetCount() const;
      69             :     /** Returns the number of all sheets, workbook + dummy ones (pivot table cache records ) */
      70             :     sal_Int32           getAllSheetCount() const;
      71             :     /** Returns the OOXML relation identifier of the specified worksheet. */
      72             :     OUString     getWorksheetRelId( sal_Int32 nWorksheet ) const;
      73             : 
      74             :     /** Returns the Calc index of the specified worksheet. */
      75             :     sal_Int16           getCalcSheetIndex( sal_Int32 nWorksheet ) const;
      76             :     /** Returns the finalized name of the specified worksheet. */
      77             :     OUString     getCalcSheetName( sal_Int32 nWorksheet ) const;
      78             : 
      79             :     /** Returns the Calc index of the sheet with the passed original worksheet name. */
      80             :     sal_Int16           getCalcSheetIndex( const OUString& rWorksheetName ) const;
      81             :     /** Returns the finalized name of the sheet with the passed worksheet name. */
      82             :     OUString     getCalcSheetName( const OUString& rWorksheetName ) const;
      83             :     /** Converts sSheetNameRef (e.g. '#SheetName!A1' to '#SheetName.A1' )
      84             :         if sSheetNameRef doesn't start with '#' it is ignored and not modified
      85             :     */
      86             :     void                convertSheetNameRef( OUString& sSheetNameRef ) const;
      87             : 
      88             : private:
      89         269 :     struct SheetInfo : public SheetInfoModel
      90             :     {
      91             :         OUString     maCalcName;
      92             :         OUString     maCalcQuotedName;
      93             :         sal_Int16           mnCalcSheet;
      94             : 
      95             :         explicit            SheetInfo( const SheetInfoModel& rModel, sal_Int16 nCalcSheet, const OUString& rCalcName );
      96             :     };
      97             : 
      98             :     typedef ::std::pair< sal_Int16, OUString > IndexNamePair;
      99             : 
     100             :     /** Creates a new sheet in the Calc document. Does not insert anything in the own lists. */
     101             :     IndexNamePair       createSheet( const OUString& rPreferredName, sal_Int32 nSheetPos, bool bVisible );
     102             :     /** Creates a new sheet in the Calc document and inserts the related SheetInfo. */
     103             :     void                insertSheet( const SheetInfoModel& rModel );
     104             : 
     105             : private:
     106             :     typedef RefVector< SheetInfo > SheetInfoVector;
     107             :     SheetInfoVector     maSheetInfos;
     108             : 
     109             :     typedef RefMap< OUString, SheetInfo, IgnoreCaseCompare > SheetInfoMap;
     110             :     SheetInfoMap        maSheetInfosByName;
     111             : };
     112             : 
     113             : } // namespace xls
     114             : } // namespace oox
     115             : 
     116             : #endif
     117             : 
     118             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11