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_XENAME_HXX 25 #define SC_XENAME_HXX 26 27 #include "xerecord.hxx" 28 #include "xlname.hxx" 29 #include "xlformula.hxx" 30 #include "xeroot.hxx" 31 32 // ============================================================================ 33 34 class ScRangeList; 35 class XclExpNameManagerImpl; 36 37 /** Manager that stores all internal defined names (NAME records) of the document. */ 38 class XclExpNameManager : public XclExpRecordBase, protected XclExpRoot 39 { 40 public: 41 explicit XclExpNameManager( const XclExpRoot& rRoot ); 42 virtual ~XclExpNameManager(); 43 44 /** Creates NAME records for built-in and user defined names. */ 45 void Initialize(); 46 47 /** Inserts the Calc name with the passed index and returns the Excel NAME index. */ 48 sal_uInt16 InsertName( sal_uInt16 nScNameIdx ); 49 /** Inserts the Calc database range with the passed index and returns the Excel NAME index. */ 50 sal_uInt16 InsertDBRange( sal_uInt16 nScDBRangeIdx ); 51 52 //UNUSED2009-05 /** Inserts a new built-in defined name. */ 53 //UNUSED2009-05 sal_uInt16 InsertBuiltInName( sal_Unicode cBuiltIn, XclTokenArrayRef xTokArr, SCTAB nScTab ); 54 /** Inserts a new built-in defined name, referring to the passed sheet range. */ 55 sal_uInt16 InsertBuiltInName( sal_Unicode cBuiltIn, const ScRange& rRange ); 56 /** Inserts a new built-in defined name, referring to the passed sheet range list. */ 57 sal_uInt16 InsertBuiltInName( sal_Unicode cBuiltIn, const ScRangeList& rRangeList ); 58 59 /** Inserts a new defined name. Sets another unused name, if rName already exists. */ 60 sal_uInt16 InsertUniqueName( const String& rName, XclTokenArrayRef xTokArr, SCTAB nScTab ); 61 /** Returns index of an existing name, or creates a name without definition. */ 62 sal_uInt16 InsertRawName( const String& rName ); 63 /** Searches or inserts a defined name describing a macro name. 64 @param bVBasic true = Visual Basic macro, false = Sheet macro. 65 @param bFunc true = Macro function; false = Macro procedure. */ 66 sal_uInt16 InsertMacroCall( const String& rMacroName, bool bVBasic, bool bFunc, bool bHidden = false ); 67 68 /** Returns the Calc sheet of a local defined name, or SCTAB_GLOBAL for global defined names. */ 69 const String& GetOrigName( sal_uInt16 nNameIdx ) const; 70 /** Returns the Calc sheet of a local defined name, or SCTAB_GLOBAL for global defined names. */ 71 SCTAB GetScTab( sal_uInt16 nNameIdx ) const; 72 /** Returns true, if the specified defined name is volatile. */ 73 bool IsVolatile( sal_uInt16 nNameIdx ) const; 74 75 /** Writes the entire list of NAME records. */ 76 virtual void Save( XclExpStream& rStrm ); 77 virtual void SaveXml( XclExpXmlStream& rStrm ); 78 79 private: 80 typedef ScfRef< XclExpNameManagerImpl > XclExpNameMgrImplRef; 81 XclExpNameMgrImplRef mxImpl; 82 }; 83 84 // ============================================================================ 85 86 #endif 87 88