Version 6.4.0.3, tag libreoffice-6.4.0.3
[LibreOffice.git] / sc / source / filter / inc / xiname.hxx
blob9260e0b0d41cf2271e9ac8b9c739d56b1a768cfd
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SC_SOURCE_FILTER_INC_XINAME_HXX
21 #define INCLUDED_SC_SOURCE_FILTER_INC_XINAME_HXX
23 #include "xiroot.hxx"
24 #include "xistream.hxx"
26 #include <rangenam.hxx>
28 #include <memory>
29 #include <vector>
31 class ScTokenArray;
33 /** Represents a defined name. It may be related to a single sheet or global. */
34 class XclImpName : protected XclImpRoot
36 struct TokenStrmData
38 XclImpStream& mrStrm;
39 XclImpStreamPos maStrmPos;
40 std::size_t mnStrmPos;
41 std::size_t mnStrmSize;
43 TokenStrmData( XclImpStream& rStrm );
46 public:
47 XclImpName(const XclImpName&) = delete;
48 const XclImpName& operator=(const XclImpName&) = delete;
50 explicit XclImpName( XclImpStream& rStrm, sal_uInt16 nXclNameIdx );
52 const OUString& GetXclName() const { return maXclName; }
53 const OUString& GetScName() const { return maScName; }
54 SCTAB GetScTab() const { return mnScTab; }
55 const ScRangeData* GetScRangeData() const { return mpScData; }
56 bool IsGlobal() const { return mnScTab == SCTAB_MAX; }
57 bool IsVBName() const { return mbVBName; }
58 bool IsMacro() const { return mbMacro; }
59 void ConvertTokens();
61 private:
62 void InsertName(const ScTokenArray* pArray);
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 SCTAB mnScTab; /// Calc sheet index of local names.
68 ScRangeData::Type meNameType;
69 sal_uInt16 mnXclTab;
70 sal_uInt16 const mnNameIndex;
71 bool mbVBName:1; /// true = Visual Basic procedure or function.
72 bool mbMacro:1; /// Whether it's a user-defined macro.
74 std::unique_ptr<TokenStrmData> mpTokensData; /// For later conversion of token array.
77 /** This buffer contains all internal defined names of the document.
78 @descr It manages the position of the names in the document, means if they are
79 global or attached to a specific sheet. While inserting the names into the Calc
80 document this buffer resolves conflicts caused by equal names from different
81 sheets. */
82 class XclImpNameManager : protected XclImpRoot
84 public:
85 explicit XclImpNameManager( const XclImpRoot& rRoot );
87 /** Reads a NAME record and creates an entry in this buffer. */
88 void ReadName( XclImpStream& rStrm );
90 /** Tries to find the name used in Calc, based on the original Excel defined name.
91 @param nScTab The sheet index for local names or SCTAB_MAX for global names.
92 If no local name is found, tries to find a matching global name.
93 @return Pointer to the defined name or 0 on error. */
94 const XclImpName* FindName( const OUString& rXclName, SCTAB nScTab ) const;
96 /** Returns the defined name specified by its Excel index.
97 @param nXclNameIdx The index of the internal defined name.
98 @return Pointer to the defined name or 0 on error. */
99 const XclImpName* GetName( sal_uInt16 nXclNameIdx ) const;
101 void ConvertAllTokens();
103 private:
104 typedef std::vector< std::unique_ptr<XclImpName> > XclImpNameList;
105 XclImpNameList maNameList;
108 #endif
110 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */