LibreOffice Module sc (master)  1
xiname.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #pragma once
21 
22 #include "xiroot.hxx"
23 #include "xistream.hxx"
24 
25 #include <rangenam.hxx>
26 
27 #include <memory>
28 #include <vector>
29 
30 class ScTokenArray;
31 
33 class XclImpName : protected XclImpRoot
34 {
36  {
39  std::size_t mnStrmPos;
40  std::size_t mnStrmSize;
41 
42  TokenStrmData( XclImpStream& rStrm );
43  };
44 
45 public:
46  XclImpName(const XclImpName&) = delete;
47  const XclImpName& operator=(const XclImpName&) = delete;
48 
49  explicit XclImpName( XclImpStream& rStrm, sal_uInt16 nXclNameIdx );
50 
51  const OUString& GetXclName() const { return maXclName; }
52  const OUString& GetScName() const { return maScName; }
53  SCTAB GetScTab() const { return mnScTab; }
54  const ScRangeData* GetScRangeData() const { return mpScData; }
55  bool IsGlobal() const { return mnScTab == SCTAB_MAX; }
56  bool IsVBName() const { return mbVBName; }
57  bool IsMacro() const { return mbMacro; }
58  void ConvertTokens();
59 
60 private:
61  void InsertName(const ScTokenArray* pArray);
62 
63  OUString maXclName;
64  OUString maScName;
68  sal_uInt16 mnXclTab;
69  sal_uInt16 mnNameIndex;
70  bool mbVBName:1;
71  bool mbMacro:1;
72 
73  std::unique_ptr<TokenStrmData> mpTokensData;
74 };
75 
81 class XclImpNameManager : protected XclImpRoot
82 {
83 public:
84  explicit XclImpNameManager( const XclImpRoot& rRoot );
85 
87  void ReadName( XclImpStream& rStrm );
88 
93  const XclImpName* FindName( std::u16string_view rXclName, SCTAB nScTab ) const;
94 
98  const XclImpName* GetName( sal_uInt16 nXclNameIdx ) const;
99 
100  void ConvertAllTokens();
101 
102 private:
103  typedef std::vector< std::unique_ptr<XclImpName> > XclImpNameList;
104  XclImpNameList maNameList;
105 };
106 
107 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_uInt16 mnNameIndex
Definition: xiname.hxx:69
XclImpNameManager(const XclImpRoot &rRoot)
Definition: xiname.cxx:278
void InsertName(const ScTokenArray *pArray)
Definition: xiname.cxx:236
void ConvertAllTokens()
Definition: xiname.cxx:316
void ReadName(XclImpStream &rStrm)
Reads a NAME record and creates an entry in this buffer.
Definition: xiname.cxx:283
const ScRangeData * mpScData
Name inserted into the Calc document.
Definition: xiname.hxx:65
This buffer contains all internal defined names of the document.
Definition: xiname.hxx:81
const OUString & GetScName() const
Definition: xiname.hxx:52
bool IsVBName() const
Definition: xiname.hxx:56
TokenStrmData(XclImpStream &rStrm)
Definition: xiname.cxx:31
bool IsMacro() const
Definition: xiname.hxx:57
const XclImpName * GetName(sal_uInt16 nXclNameIdx) const
Returns the defined name specified by its Excel index.
Definition: xiname.cxx:310
bool mbVBName
Definition: xiname.hxx:70
SCTAB GetScTab() const
Definition: xiname.hxx:53
std::size_t mnStrmPos
Definition: xiname.hxx:39
OUString maScName
Original name read from the file.
Definition: xiname.hxx:64
XclImpStream & mrStrm
Definition: xiname.hxx:37
const XclImpName & operator=(const XclImpName &)=delete
ScRangeData::Type meNameType
Calc sheet index of local names.
Definition: xiname.hxx:67
std::vector< std::unique_ptr< XclImpName > > XclImpNameList
Definition: xiname.hxx:103
const OUString & GetXclName() const
Definition: xiname.hxx:51
const XclImpName * FindName(std::u16string_view rXclName, SCTAB nScTab) const
Tries to find the name used in Calc, based on the original Excel defined name.
Definition: xiname.cxx:290
OUString maXclName
Definition: xiname.hxx:63
std::unique_ptr< TokenStrmData > mpTokensData
Whether it's a user-defined macro.
Definition: xiname.hxx:73
XclImpStreamPos maStrmPos
Definition: xiname.hxx:38
SCTAB mnScTab
Pointer to Calc defined name (no ownership).
Definition: xiname.hxx:66
This class represents an Excel stream position.
Definition: xistream.hxx:201
bool IsGlobal() const
Definition: xiname.hxx:55
bool mbMacro
true = Visual Basic procedure or function.
Definition: xiname.hxx:71
void ConvertTokens()
Definition: xiname.cxx:214
std::size_t mnStrmSize
Definition: xiname.hxx:40
This class is used to import record oriented streams.
Definition: xistream.hxx:277
XclImpName(const XclImpName &)=delete
const ScRangeData * GetScRangeData() const
Definition: xiname.hxx:54
void SvStream & rStrm
const SCTAB SCTAB_MAX
Definition: address.hxx:57
Access to global data from other classes.
Definition: xiroot.hxx:125
sal_uInt16 mnXclTab
Definition: xiname.hxx:68
Represents a defined name.
Definition: xiname.hxx:33
XclImpNameList maNameList
Definition: xiname.hxx:104
sal_Int16 SCTAB
Definition: types.hxx:22