1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 <boost/ptr_container/ptr_vector.hpp>
26 #include "xistream.hxx"
28 #include "rangenam.hxx"
30 #include <boost/noncopyable.hpp>
31 #include <boost/scoped_ptr.hpp>
36 /** Represents a defined name. It may be related to a single sheet or global. */
37 class XclImpName
: protected XclImpRoot
, public boost::noncopyable
42 XclImpStreamPos maStrmPos
;
46 TokenStrmData( XclImpStream
& rStrm
);
50 explicit XclImpName( XclImpStream
& rStrm
, sal_uInt16 nXclNameIdx
);
52 inline const OUString
& GetXclName() const { return maXclName
; }
53 inline const OUString
& GetScName() const { return maScName
; }
54 inline SCTAB
GetScTab() const { return mnScTab
; }
55 inline const ScRangeData
* GetScRangeData() const { return mpScData
; }
56 inline bool IsGlobal() const { return mnScTab
== SCTAB_MAX
; }
57 inline bool IsVBName() const { return mbVBName
; }
58 bool IsMacro() const { return mbMacro
; }
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 sal_Unicode mcBuiltIn
; /// Excel built-in name index.
68 SCTAB mnScTab
; /// Calc sheet index of local names.
71 sal_uInt16 mnNameIndex
;
72 bool mbVBName
:1; /// true = Visual Basic procedure or function.
73 bool mbMacro
:1; /// Whether it's a user-defined macro.
75 boost::scoped_ptr
<TokenStrmData
> mpTokensData
; /// For later conversion of token array.
78 /** This buffer contains all internal defined names of the document.
79 @descr It manages the position of the names in the document, means if they are
80 global or attached to a specific sheet. While inserting the names into the Calc
81 document this buffer resolves conflicts caused by equal names from different
83 class XclImpNameManager
: protected XclImpRoot
86 explicit XclImpNameManager( const XclImpRoot
& rRoot
);
88 /** Reads a NAME record and creates an entry in this buffer. */
89 void ReadName( XclImpStream
& rStrm
);
91 /** Tries to find the name used in Calc, based on the original Excel defined name.
92 @param nScTab The sheet index for local names or SCTAB_MAX for global names.
93 If no local name is found, tries to find a matching global name.
94 @return Pointer to the defined name or 0 on error. */
95 const XclImpName
* FindName( const OUString
& rXclName
, SCTAB nScTab
= SCTAB_MAX
) const;
97 /** Returns the defined name specified by its Excel index.
98 @param nXclNameIdx The index of the internal defined name.
99 @return Pointer to the defined name or 0 on error. */
100 const XclImpName
* GetName( sal_uInt16 nXclNameIdx
) const;
102 void ConvertAllTokens();
105 typedef boost::ptr_vector
< XclImpName
> XclImpNameList
;
106 XclImpNameList maNameList
;
111 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */