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