LCOV - code coverage report
Current view: top level - sc/source/filter/inc - xiname.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 4 8 50.0 %
Date: 2012-08-25 Functions: 6 10 60.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 6 12 50.0 %

           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 SC_XINAME_HXX
      30                 :            : #define SC_XINAME_HXX
      31                 :            : 
      32                 :            : #include <boost/ptr_container/ptr_vector.hpp>
      33                 :            : #include "xlname.hxx"
      34                 :            : #include "xiroot.hxx"
      35                 :            : #include "xistream.hxx"
      36                 :            : 
      37                 :            : #include "rangenam.hxx"
      38                 :            : 
      39                 :            : #include <boost/noncopyable.hpp>
      40                 :            : #include <boost/scoped_ptr.hpp>
      41                 :            : 
      42                 :            : // ============================================================================
      43                 :            : 
      44                 :            : class ScRangeData;
      45                 :            : class ScTokenArray;
      46                 :            : 
      47                 :            : /** Represents a defined name. It may be related to a single sheet or global. */
      48 [ +  - ][ +  - ]:        132 : class XclImpName : protected XclImpRoot, public boost::noncopyable
         [ +  - ][ -  + ]
      49                 :            : {
      50                 :            :     struct TokenStrmData
      51                 :            :     {
      52                 :            :         XclImpStream& mrStrm;
      53                 :            :         XclImpStreamPos maStrmPos;
      54                 :            :         sal_Size mnStrmPos;
      55                 :            :         sal_Size mnStrmSize;
      56                 :            : 
      57                 :            :         TokenStrmData( XclImpStream& rStrm );
      58                 :            :     };
      59                 :            : 
      60                 :            : public:
      61                 :            :     explicit            XclImpName( XclImpStream& rStrm, sal_uInt16 nXclNameIdx );
      62                 :            : 
      63                 :          3 :     inline const String& GetXclName() const { return maXclName; }
      64                 :          0 :     inline const String& GetScName() const { return maScName; }
      65                 :          0 :     inline SCTAB        GetScTab() const { return mnScTab; }
      66                 :          0 :     inline const ScRangeData* GetScRangeData() const { return mpScData; }
      67                 :         42 :     inline bool         IsGlobal() const { return mnScTab == SCTAB_MAX; }
      68                 :          0 :     inline bool         IsVBName() const { return mbVBName; }
      69                 :            :     bool IsMacro() const;
      70                 :            :     void ConvertTokens();
      71                 :            : 
      72                 :            : private:
      73                 :            :     void InsertName(const ScTokenArray* pArray);
      74                 :            : 
      75                 :            :     String              maXclName;      /// Original name read from the file.
      76                 :            :     String              maScName;       /// Name inserted into the Calc document.
      77                 :            :     const ScRangeData*  mpScData;       /// Pointer to Calc defined name (no ownership).
      78                 :            :     sal_Unicode         mcBuiltIn;      /// Excel built-in name index.
      79                 :            :     SCTAB               mnScTab;        /// Calc sheet index of local names.
      80                 :            :     RangeType           meNameType;
      81                 :            :     sal_uInt16          mnXclTab;
      82                 :            :     sal_uInt16          mnNameIndex;
      83                 :            :     bool                mbVBName:1;     /// true = Visual Basic procedure or function.
      84                 :            :     bool                mbMacro:1;      /// Whether it's a user-defined macro.
      85                 :            : 
      86                 :            :     boost::scoped_ptr<TokenStrmData> mpTokensData;   /// For later conversion of token array.
      87                 :            : };
      88                 :            : 
      89                 :            : // ----------------------------------------------------------------------------
      90                 :            : 
      91                 :            : /** This buffer contains all internal defined names of the document.
      92                 :            :     @descr  It manages the position of the names in the document, means if they are
      93                 :            :     global or attached to a specific sheet. While inserting the names into the Calc
      94                 :            :     document this buffer resolves conflicts caused by equal names from different
      95                 :            :     sheets. */
      96 [ +  - ][ -  + ]:        110 : class XclImpNameManager : protected XclImpRoot
      97                 :            : {
      98                 :            : public:
      99                 :            :     explicit            XclImpNameManager( const XclImpRoot& rRoot );
     100                 :            : 
     101                 :            :     /** Reads a NAME record and creates an entry in this buffer. */
     102                 :            :     void                ReadName( XclImpStream& rStrm );
     103                 :            : 
     104                 :            :     /** Tries to find the name used in Calc, based on the original Excel defined name.
     105                 :            :         @param nScTab  The sheet index for local names or SCTAB_MAX for global names.
     106                 :            :         If no local name is found, tries to find a matching global name.
     107                 :            :         @return  Pointer to the defined name or 0 on error. */
     108                 :            :     const XclImpName*   FindName( const String& rXclName, SCTAB nScTab = SCTAB_MAX ) const;
     109                 :            : 
     110                 :            :     /** Returns the defined name specified by its Excel index.
     111                 :            :         @param nXclNameIdx  The index of the internal defined name.
     112                 :            :         @return  Pointer to the defined name or 0 on error. */
     113                 :            :     const XclImpName*   GetName( sal_uInt16 nXclNameIdx ) const;
     114                 :            : 
     115                 :            :     void ConvertAllTokens();
     116                 :            : 
     117                 :            : private:
     118                 :            :     typedef boost::ptr_vector< XclImpName > XclImpNameList;
     119                 :            :     XclImpNameList      maNameList;
     120                 :            : };
     121                 :            : 
     122                 :            : // ============================================================================
     123                 :            : 
     124                 :            : #endif
     125                 :            : 
     126                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10