fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / filter / inc / namebuff.hxx
blobae296aeff1365093c2f31607def1306b4f83a28b
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_NAMEBUFF_HXX
21 #define INCLUDED_SC_SOURCE_FILTER_INC_NAMEBUFF_HXX
23 #include <rtl/ustring.hxx>
24 #include <osl/diagnose.h>
25 #include "compiler.hxx"
26 #include "root.hxx"
27 #include "xiroot.hxx"
29 #include "rangenam.hxx"
30 #include "formulacell.hxx"
32 #include <list>
33 #include <unordered_map>
35 class ScTokenArray;
36 class NameBuffer;
38 class StringHashEntry
40 private:
41 friend class NameBuffer;
42 OUString aString;
43 sal_uInt32 nHash;
45 static sal_uInt32 MakeHashCode( const OUString& );
46 public:
47 inline StringHashEntry( const OUString& );
48 inline StringHashEntry();
49 inline void operator =( const sal_Char* );
50 inline void operator =( const OUString& );
51 inline void operator =( const StringHashEntry& );
52 inline bool operator ==( const StringHashEntry& ) const;
55 inline StringHashEntry::StringHashEntry()
59 inline StringHashEntry::StringHashEntry( const OUString& r ) : aString( r )
61 nHash = MakeHashCode( r );
64 inline void StringHashEntry::operator =( const sal_Char* p )
66 aString = OUString(p, strlen(p), RTL_TEXTENCODING_ASCII_US);
67 nHash = MakeHashCode( aString );
70 inline void StringHashEntry::operator =( const OUString& r )
72 aString = r;
73 nHash = MakeHashCode( r );
76 inline void StringHashEntry::operator =( const StringHashEntry& r )
78 nHash = r.nHash;
79 aString = r.aString;
82 inline bool StringHashEntry::operator ==( const StringHashEntry& r ) const
84 return ( nHash == r.nHash && aString == r.aString );
87 class NameBuffer : public ExcRoot
89 private:
90 sal_uInt16 nBase; // Index-Base
91 std::vector<StringHashEntry*> maHashes;
93 public:
95 inline NameBuffer( RootData* );
96 inline NameBuffer( RootData*, sal_uInt16 nNewBase );
98 virtual ~NameBuffer();
99 inline const OUString* Get( sal_uInt16 nIndex ) const;
100 inline sal_uInt16 GetLastIndex() const;
101 inline void SetBase( sal_uInt16 nNewBase = 0 );
102 void operator <<( const OUString& rNewString );
105 inline NameBuffer::NameBuffer( RootData* p ) : ExcRoot( p )
107 nBase = 0;
110 inline NameBuffer::NameBuffer( RootData* p, sal_uInt16 nNewBase ) : ExcRoot( p )
112 nBase = nNewBase;
115 inline const OUString* NameBuffer::Get ( sal_uInt16 n ) const
117 if( n < nBase || n >= maHashes.size() )
118 return NULL;
120 return &(maHashes[n]->aString);
123 inline sal_uInt16 NameBuffer::GetLastIndex () const
125 int size = maHashes.size() + nBase;
127 OSL_ENSURE( size <= 0xFFFF, "*NameBuffer::GetLastIndex(): I'm sick and tired!" );
129 return static_cast<sal_uInt16>( size );
132 inline void NameBuffer::SetBase( sal_uInt16 nNewBase )
134 nBase = nNewBase;
138 * Store and manage shared formula tokens.
140 class SharedFormulaBuffer : public ExcRoot
142 typedef std::unordered_map<ScAddress, ScTokenArray*, ScAddressHashFunctor> TokenArraysType;
143 TokenArraysType maTokenArrays;
145 public:
146 SharedFormulaBuffer( RootData* pRD );
147 virtual ~SharedFormulaBuffer();
148 void Clear();
149 void Store( const ScAddress& rPos, const ScTokenArray& rArray );
150 const ScTokenArray* Find( const ScAddress& rRefPos ) const;
153 class RangeNameBufferWK3
155 private:
156 struct Entry
158 StringHashEntry aStrHashEntry;
159 ScComplexRefData aScComplexRefDataRel;
160 OUString aScAbsName;
161 sal_uInt16 nAbsInd; // == 0 -> no Abs-Name yet!
162 sal_uInt16 nRelInd;
163 bool bSingleRef;
164 Entry( const OUString& rName, const OUString& rScName, const ScComplexRefData& rCRD )
165 : aStrHashEntry( rName )
166 , aScComplexRefDataRel( rCRD )
167 , aScAbsName( rScName )
168 , nAbsInd(0)
169 , nRelInd(0)
170 , bSingleRef(false)
172 aScAbsName = "_ABS";
176 LOTUS_ROOT* m_pLotRoot;
177 ScTokenArray* pScTokenArray;
178 sal_uInt16 nIntCount;
179 std::vector<Entry> maEntries;
181 public:
182 RangeNameBufferWK3(LOTUS_ROOT* pLotRoot);
183 virtual ~RangeNameBufferWK3();
184 void Add( const OUString& rName, const ScComplexRefData& rCRD );
185 inline void Add( const OUString& rName, const ScRange& aScRange );
186 bool FindRel( const OUString& rRef, sal_uInt16& rIndex );
187 bool FindAbs( const OUString& rRef, sal_uInt16& rIndex );
190 inline void RangeNameBufferWK3::Add( const OUString& rName, const ScRange& aScRange )
192 ScComplexRefData aCRD;
193 ScSingleRefData* pSRD;
195 pSRD = &aCRD.Ref1;
196 pSRD->InitAddress(aScRange.aStart);
197 pSRD->SetFlag3D(true);
199 pSRD = &aCRD.Ref2;
200 pSRD->InitAddress(aScRange.aEnd);
201 pSRD->SetFlag3D(true);
203 Add( rName, aCRD );
206 class ExtSheetBuffer : public ExcRoot
208 private:
209 struct Cont
211 OUString aFile;
212 OUString aTab;
213 sal_uInt16 nTabNum; // 0xFFFF -> not set yet
214 // 0xFFFE -> tried to set, but failed
215 // 0xFFFD -> should be in the same workbook, but not found
216 bool bSWB;
217 bool bLink;
218 Cont( const OUString& rFilePathAndName, const OUString& rTabName ) :
219 aFile( rFilePathAndName ),
220 aTab( rTabName )
222 nTabNum = 0xFFFF; // -> table not created yet
223 bSWB = bLink = false;
225 Cont( const OUString& rFilePathAndName, const OUString& rTabName,
226 const bool bSameWB ) :
227 aFile( rFilePathAndName ),
228 aTab( rTabName )
230 nTabNum = 0xFFFF; // -> table not created yet
231 bSWB = bSameWB;
232 bLink = false;
236 std::vector<Cont> maEntries;
238 public:
239 inline ExtSheetBuffer( RootData* );
241 sal_Int16 Add( const OUString& rFilePathAndName,
242 const OUString& rTabName, const bool bSameWorkbook = false );
244 bool GetScTabIndex( sal_uInt16 nExcSheetIndex, sal_uInt16& rIn_LastTab_Out_ScIndex );
245 bool IsLink( const sal_uInt16 nExcSheetIndex ) const;
246 bool GetLink( const sal_uInt16 nExcSheetIndex, OUString &rAppl, OUString &rDoc ) const;
248 void Reset();
251 inline ExtSheetBuffer::ExtSheetBuffer( RootData* p ) : ExcRoot( p )
255 struct ExtName
257 OUString aName;
258 sal_uInt32 nStorageId;
259 sal_uInt16 nFlags;
261 inline ExtName( const OUString& r, sal_uInt16 n ) : aName( r ), nStorageId( 0 ), nFlags( n ) {}
263 bool IsDDE() const;
264 bool IsOLE() const;
267 class ExtNameBuff : protected XclImpRoot
269 public:
270 explicit ExtNameBuff( const XclImpRoot& rRoot );
272 void AddDDE( const OUString& rName, sal_Int16 nRefIdx );
273 void AddOLE( const OUString& rName, sal_Int16 nRefIdx, sal_uInt32 nStorageId );
274 void AddName( const OUString& rName, sal_Int16 nRefIdx );
276 const ExtName* GetNameByIndex( sal_Int16 nRefIdx, sal_uInt16 nNameIdx ) const;
278 void Reset();
280 private:
281 typedef ::std::vector< ExtName > ExtNameVec;
282 typedef ::std::map< sal_Int16, ExtNameVec > ExtNameMap;
284 ExtNameMap maExtNames;
287 #endif
289 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */