Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / sc / source / filter / inc / xiname.hxx
blobca3b8dc3a36cdcf94b1c16d131a9915d4d57c02b
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 "xlname.hxx"
24 #include "xiroot.hxx"
25 #include "xistream.hxx"
27 #include "rangenam.hxx"
29 #include <memory>
30 #include <vector>
32 class ScRangeData;
33 class ScTokenArray;
35 /** Represents a defined name. It may be related to a single sheet or global. */
36 class XclImpName : protected XclImpRoot
38 struct TokenStrmData
40 XclImpStream& mrStrm;
41 XclImpStreamPos maStrmPos;
42 sal_Size mnStrmPos;
43 sal_Size mnStrmSize;
45 TokenStrmData( XclImpStream& rStrm );
48 public:
49 XclImpName(const XclImpName&) = delete;
50 const XclImpName& operator=(const XclImpName&) = delete;
52 explicit XclImpName( XclImpStream& rStrm, sal_uInt16 nXclNameIdx );
54 inline const OUString& GetXclName() const { return maXclName; }
55 inline const OUString& GetScName() const { return maScName; }
56 inline SCTAB GetScTab() const { return mnScTab; }
57 inline const ScRangeData* GetScRangeData() const { return mpScData; }
58 inline bool IsGlobal() const { return mnScTab == SCTAB_MAX; }
59 inline bool IsVBName() const { return mbVBName; }
60 bool IsMacro() const { return mbMacro; }
61 void ConvertTokens();
63 private:
64 void InsertName(const ScTokenArray* pArray);
66 OUString maXclName; /// Original name read from the file.
67 OUString maScName; /// Name inserted into the Calc document.
68 const ScRangeData* mpScData; /// Pointer to Calc defined name (no ownership).
69 sal_Unicode mcBuiltIn; /// Excel built-in name index.
70 SCTAB mnScTab; /// Calc sheet index of local names.
71 ScRangeData::Type meNameType;
72 sal_uInt16 mnXclTab;
73 sal_uInt16 mnNameIndex;
74 bool mbVBName:1; /// true = Visual Basic procedure or function.
75 bool mbMacro:1; /// Whether it's a user-defined macro.
77 std::unique_ptr<TokenStrmData> mpTokensData; /// For later conversion of token array.
80 /** This buffer contains all internal defined names of the document.
81 @descr It manages the position of the names in the document, means if they are
82 global or attached to a specific sheet. While inserting the names into the Calc
83 document this buffer resolves conflicts caused by equal names from different
84 sheets. */
85 class XclImpNameManager : protected XclImpRoot
87 public:
88 explicit XclImpNameManager( const XclImpRoot& rRoot );
90 /** Reads a NAME record and creates an entry in this buffer. */
91 void ReadName( XclImpStream& rStrm );
93 /** Tries to find the name used in Calc, based on the original Excel defined name.
94 @param nScTab The sheet index for local names or SCTAB_MAX for global names.
95 If no local name is found, tries to find a matching global name.
96 @return Pointer to the defined name or 0 on error. */
97 const XclImpName* FindName( const OUString& rXclName, SCTAB nScTab = SCTAB_MAX ) const;
99 /** Returns the defined name specified by its Excel index.
100 @param nXclNameIdx The index of the internal defined name.
101 @return Pointer to the defined name or 0 on error. */
102 const XclImpName* GetName( sal_uInt16 nXclNameIdx ) const;
104 void ConvertAllTokens();
106 private:
107 typedef std::vector< std::unique_ptr<XclImpName> > XclImpNameList;
108 XclImpNameList maNameList;
111 #endif
113 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */