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

Generated by: LCOV version 1.11