1*38d50f7bSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*38d50f7bSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*38d50f7bSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*38d50f7bSAndrew Rist * distributed with this work for additional information 6*38d50f7bSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*38d50f7bSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*38d50f7bSAndrew Rist * "License"); you may not use this file except in compliance 9*38d50f7bSAndrew Rist * with the License. You may obtain a copy of the License at 10*38d50f7bSAndrew Rist * 11*38d50f7bSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*38d50f7bSAndrew Rist * 13*38d50f7bSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*38d50f7bSAndrew Rist * software distributed under the License is distributed on an 15*38d50f7bSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*38d50f7bSAndrew Rist * KIND, either express or implied. See the License for the 17*38d50f7bSAndrew Rist * specific language governing permissions and limitations 18*38d50f7bSAndrew Rist * under the License. 19*38d50f7bSAndrew Rist * 20*38d50f7bSAndrew Rist *************************************************************/ 21*38d50f7bSAndrew Rist 22*38d50f7bSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef SC_XINAME_HXX 25cdf0e10cSrcweir #define SC_XINAME_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <map> 28cdf0e10cSrcweir #include "xlname.hxx" 29cdf0e10cSrcweir #include "xiroot.hxx" 30cdf0e10cSrcweir 31cdf0e10cSrcweir //class ScDocument; 32cdf0e10cSrcweir //class ScTokenArray; 33cdf0e10cSrcweir 34cdf0e10cSrcweir // ============================================================================ 35cdf0e10cSrcweir 36cdf0e10cSrcweir class ScRangeData; 37cdf0e10cSrcweir 38cdf0e10cSrcweir /** Represents a defined name. It may be related to a single sheet or global. */ 39cdf0e10cSrcweir class XclImpName : protected XclImpRoot 40cdf0e10cSrcweir { 41cdf0e10cSrcweir public: 42cdf0e10cSrcweir explicit XclImpName( XclImpStream& rStrm, sal_uInt16 nXclNameIdx ); 43cdf0e10cSrcweir GetXclName() const44cdf0e10cSrcweir inline const String& GetXclName() const { return maXclName; } GetScName() const45cdf0e10cSrcweir inline const String& GetScName() const { return maScName; } GetScTab() const46cdf0e10cSrcweir inline SCTAB GetScTab() const { return mnScTab; } GetScRangeData() const47cdf0e10cSrcweir inline const ScRangeData* GetScRangeData() const { return mpScData; } IsGlobal() const48cdf0e10cSrcweir inline bool IsGlobal() const { return mnScTab == SCTAB_MAX; } IsFunction() const49cdf0e10cSrcweir inline bool IsFunction() const { return mbFunction; } IsVBName() const50cdf0e10cSrcweir inline bool IsVBName() const { return mbVBName; } 51cdf0e10cSrcweir 52cdf0e10cSrcweir private: 53cdf0e10cSrcweir String maXclName; /// Original name read from the file. 54cdf0e10cSrcweir String maScName; /// Name inserted into the Calc document. 55cdf0e10cSrcweir const ScRangeData* mpScData; /// Pointer to Calc defined name (no ownership). 56cdf0e10cSrcweir sal_Unicode mcBuiltIn; /// Excel built-in name index. 57cdf0e10cSrcweir SCTAB mnScTab; /// Calc sheet index of local names. 58cdf0e10cSrcweir bool mbFunction; /// true = Name refers to a function (add-in or VBA). 59cdf0e10cSrcweir bool mbVBName; /// true = Visual Basic procedure or function. 60cdf0e10cSrcweir }; 61cdf0e10cSrcweir 62cdf0e10cSrcweir // ---------------------------------------------------------------------------- 63cdf0e10cSrcweir 64cdf0e10cSrcweir /** This buffer contains all internal defined names of the document. 65cdf0e10cSrcweir @descr It manages the position of the names in the document, means if they are 66cdf0e10cSrcweir global or attached to a specific sheet. While inserting the names into the Calc 67cdf0e10cSrcweir document this buffer resolves conflicts caused by equal names from different 68cdf0e10cSrcweir sheets. */ 69cdf0e10cSrcweir class XclImpNameManager : protected XclImpRoot 70cdf0e10cSrcweir { 71cdf0e10cSrcweir public: 72cdf0e10cSrcweir explicit XclImpNameManager( const XclImpRoot& rRoot ); 73cdf0e10cSrcweir 74cdf0e10cSrcweir /** Reads a NAME record and creates an entry in this buffer. */ 75cdf0e10cSrcweir void ReadName( XclImpStream& rStrm ); 76cdf0e10cSrcweir 77cdf0e10cSrcweir /** Tries to find the name used in Calc, based on the original Excel defined name. 78cdf0e10cSrcweir @param nScTab The sheet index for local names or SCTAB_MAX for global names. 79cdf0e10cSrcweir If no local name is found, tries to find a matching global name. 80cdf0e10cSrcweir @return Pointer to the defined name or 0 on error. */ 81cdf0e10cSrcweir const XclImpName* FindName( const String& rXclName, SCTAB nScTab = SCTAB_MAX ) const; 82cdf0e10cSrcweir 83cdf0e10cSrcweir /** Returns the defined name specified by its Excel index. 84cdf0e10cSrcweir @param nXclNameIdx The index of the internal defined name. 85cdf0e10cSrcweir @return Pointer to the defined name or 0 on error. */ 86cdf0e10cSrcweir const XclImpName* GetName( sal_uInt16 nXclNameIdx ) const; 87cdf0e10cSrcweir 88cdf0e10cSrcweir private: 89cdf0e10cSrcweir typedef ScfDelList< XclImpName > XclImpNameList; 90cdf0e10cSrcweir XclImpNameList maNameList; 91cdf0e10cSrcweir }; 92cdf0e10cSrcweir 93cdf0e10cSrcweir // ============================================================================ 94cdf0e10cSrcweir 95cdf0e10cSrcweir #endif 96cdf0e10cSrcweir 97