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

Generated by: LCOV version 1.10