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 .
26 #include <rtl/ustring.hxx>
29 #include <refdata.hxx>
30 #include <tokenarray.hxx>
32 #include <unordered_map>
40 static sal_uInt32
MakeHashCode( const OUString
& );
42 inline StringHashEntry( const OUString
& );
43 inline bool operator ==( const StringHashEntry
& ) const;
46 inline StringHashEntry::StringHashEntry( const OUString
& r
)
48 , nHash( MakeHashCode(r
) )
52 inline bool StringHashEntry::operator ==( const StringHashEntry
& r
) const
54 return ( nHash
== r
.nHash
&& aString
== r
.aString
);
58 * Store and manage shared formula tokens.
60 class SharedFormulaBuffer
: public ExcRoot
62 typedef std::unordered_map
<ScAddress
, ScTokenArray
, ScAddressHashFunctor
> TokenArraysType
;
63 TokenArraysType maTokenArrays
;
66 SharedFormulaBuffer( RootData
* pRD
);
67 virtual ~SharedFormulaBuffer();
69 void Store( const ScAddress
& rPos
, const ScTokenArray
& rArray
);
70 const ScTokenArray
* Find( const ScAddress
& rRefPos
) const;
73 class RangeNameBufferWK3 final
78 StringHashEntry aStrHashEntry
;
79 ScComplexRefData aScComplexRefDataRel
;
80 sal_uInt16 nAbsInd
; // == 0 -> no Abs-Name yet!
83 Entry( const OUString
& rName
, const ScComplexRefData
& rCRD
)
84 : aStrHashEntry( rName
)
85 , aScComplexRefDataRel( rCRD
)
93 std::unique_ptr
<ScTokenArray
>
96 std::vector
<Entry
> maEntries
;
99 RangeNameBufferWK3(const ScDocument
& rDoc
);
100 ~RangeNameBufferWK3();
101 void Add( const ScDocument
& rDoc
, const OUString
& rName
, const ScComplexRefData
& rCRD
);
102 inline void Add( const ScDocument
& rDoc
, const OUString
& rName
, const ScRange
& aScRange
);
103 bool FindRel( const OUString
& rRef
, sal_uInt16
& rIndex
);
104 bool FindAbs( std::u16string_view rRef
, sal_uInt16
& rIndex
);
107 inline void RangeNameBufferWK3::Add( const ScDocument
& rDoc
, const OUString
& rName
, const ScRange
& aScRange
)
109 ScComplexRefData aCRD
;
110 ScSingleRefData
* pSRD
;
113 pSRD
->InitAddress(aScRange
.aStart
);
114 pSRD
->SetFlag3D(true);
117 pSRD
->InitAddress(aScRange
.aEnd
);
118 pSRD
->SetFlag3D(true);
120 Add( rDoc
, rName
, aCRD
);
123 class ExtSheetBuffer
: public ExcRoot
130 sal_uInt16 nTabNum
; // 0xFFFF -> not set yet
131 // 0xFFFE -> tried to set, but failed
132 // 0xFFFD -> should be in the same workbook, but not found
134 Cont( OUString aFilePathAndName
, OUString aTabName
,
135 const bool bSameWB
) :
136 aFile(std::move( aFilePathAndName
)),
137 aTab(std::move( aTabName
))
139 nTabNum
= 0xFFFF; // -> table not created yet
144 std::vector
<Cont
> maEntries
;
147 inline ExtSheetBuffer( RootData
* );
149 sal_Int16
Add( const OUString
& rFilePathAndName
,
150 const OUString
& rTabName
, const bool bSameWorkbook
);
152 bool GetScTabIndex( sal_uInt16 nExcSheetIndex
, sal_uInt16
& rIn_LastTab_Out_ScIndex
);
157 inline ExtSheetBuffer::ExtSheetBuffer( RootData
* p
) : ExcRoot( p
)
163 sal_uInt32 nStorageId
;
166 ExtName( sal_uInt16 n
) : nStorageId( 0 ), nFlags( n
) {}
171 class ExtNameBuff
: protected XclImpRoot
174 explicit ExtNameBuff( const XclImpRoot
& rRoot
);
176 void AddDDE( sal_Int16 nRefIdx
);
177 void AddOLE( sal_Int16 nRefIdx
, sal_uInt32 nStorageId
);
178 void AddName( sal_Int16 nRefIdx
);
180 const ExtName
* GetNameByIndex( sal_Int16 nRefIdx
, sal_uInt16 nNameIdx
) const;
185 typedef ::std::vector
< ExtName
> ExtNameVec
;
186 typedef ::std::map
< sal_Int16
, ExtNameVec
> ExtNameMap
;
188 ExtNameMap maExtNames
;
191 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */