1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: namebuff.hxx,v $
10 * $Revision: 1.15.32.2 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SC_NAMEBUFF_HXX
32 #define SC_NAMEBUFF_HXX
34 #include <tools/debug.hxx>
35 #include <tools/string.hxx>
36 #include "compiler.hxx"
40 #include "rangenam.hxx"
54 friend class NameBuffer
;
58 static UINT32
MakeHashCode( const String
& );
60 inline StringHashEntry( const String
& );
61 inline StringHashEntry( void );
62 inline void operator =( const sal_Char
* );
63 inline void operator =( const String
& );
64 inline void operator =( const StringHashEntry
& );
65 inline BOOL
operator ==( const StringHashEntry
& ) const;
69 inline StringHashEntry::StringHashEntry( void )
74 inline StringHashEntry::StringHashEntry( const String
& r
) : aString( r
)
76 nHash
= MakeHashCode( r
);
80 inline void StringHashEntry::operator =( const sal_Char
* p
)
82 aString
.AssignAscii( p
);
83 nHash
= MakeHashCode( aString
);
87 inline void StringHashEntry::operator =( const String
& r
)
90 nHash
= MakeHashCode( r
);
94 inline void StringHashEntry::operator =( const StringHashEntry
& r
)
101 inline BOOL
StringHashEntry::operator ==( const StringHashEntry
& r
) const
103 return ( nHash
== r
.nHash
&& aString
== r
.aString
);
108 class NameBuffer
: private List
, public ExcRoot
111 UINT16 nBase
; // Index-Basis
113 // inline NameBuffer( void ); //#94039# prevent empty rootdata
114 inline NameBuffer( RootData
* );
115 inline NameBuffer( RootData
*, UINT16 nNewBase
);
117 virtual ~NameBuffer();
118 inline const String
* Get( UINT16 nIndex
);
119 inline UINT16
GetLastIndex( void );
120 inline void SetBase( UINT16 nNewBase
= 0 );
121 void operator <<( const String
& rNewString
);
124 //#94039# prevent empty rootdata
125 //inline NameBuffer::NameBuffer( void )
131 inline NameBuffer::NameBuffer( RootData
* p
) : ExcRoot( p
)
137 inline NameBuffer::NameBuffer( RootData
* p
, UINT16 nNewBase
) : ExcRoot( p
)
143 inline const String
* NameBuffer::Get( UINT16 n
)
149 StringHashEntry
* pObj
= ( StringHashEntry
* ) List::GetObject( n
);
152 return &pObj
->aString
;
159 inline UINT16
NameBuffer::GetLastIndex( void )
161 DBG_ASSERT( Count() + nBase
<= 0xFFFF, "*NameBuffer::GetLastIndex(): Ich hab' die Nase voll!" );
163 return ( UINT16
) ( Count() + nBase
);
167 inline void NameBuffer::SetBase( UINT16 nNewBase
)
175 class ShrfmlaBuffer
: public ExcRoot
177 struct ScAddressHashFunc
: public std::unary_function
< const ScAddress
&, size_t >
179 size_t operator() (const ScAddress
&addr
) const;
181 typedef std::hash_map
<ScAddress
, USHORT
, ScAddressHashFunc
> ShrfmlaHash
;
182 typedef std::list
<ScRange
> ShrfmlaList
;
184 ShrfmlaHash index_hash
;
185 ShrfmlaList index_list
;
189 ShrfmlaBuffer( RootData
* pRD
);
190 virtual ~ShrfmlaBuffer();
192 void Store( const ScRange
& rRange
, const ScTokenArray
& );
193 USHORT
Find (const ScAddress
& rAddress
) const;
195 static String
CreateName( const ScRange
& );
201 class RangeNameBufferWK3
: private List
206 StringHashEntry aStrHashEntry
;
207 ScComplexRefData aScComplexRefDataRel
;
209 UINT16 nAbsInd
; // == 0 -> noch keine Abs-Name!
212 ENTRY( const String
& rName
, const String
& rScName
, const ScComplexRefData
& rCRD
) :
213 aStrHashEntry( rName
),
214 aScComplexRefDataRel( rCRD
),
215 aScAbsName( rScName
)
218 aScAbsName
.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "_ABS" ) );
222 ScTokenArray
* pScTokenArray
;
225 RangeNameBufferWK3( void );
226 virtual ~RangeNameBufferWK3();
227 void Add( const String
& rName
, const ScComplexRefData
& rCRD
);
228 inline void Add( const String
& rName
, const ScRange
& aScRange
);
229 BOOL
FindRel( const String
& rRef
, UINT16
& rIndex
);
230 BOOL
FindAbs( const String
& rRef
, UINT16
& rIndex
);
234 inline void RangeNameBufferWK3::Add( const String
& rName
, const ScRange
& aScRange
)
236 ScComplexRefData aCRD
;
237 ScSingleRefData
* pSRD
;
238 const ScAddress
* pScAddr
;
241 pScAddr
= &aScRange
.aStart
;
242 pSRD
->SetFlag3D( TRUE
);
243 pSRD
->nCol
= pScAddr
->Col();
244 pSRD
->nRow
= pScAddr
->Row();
245 pSRD
->nTab
= pScAddr
->Tab();
247 // zunaechst ALLE Refs nur absolut
248 pSRD
->SetColRel( FALSE
);
249 pSRD
->SetRowRel( FALSE
);
250 pSRD
->SetTabRel( FALSE
);
253 pScAddr
= &aScRange
.aEnd
;
254 pSRD
->SetFlag3D( TRUE
);
255 pSRD
->nCol
= pScAddr
->Col();
256 pSRD
->nRow
= pScAddr
->Row();
257 pSRD
->nTab
= pScAddr
->Tab();
259 // zunaechst ALLE Refs nur absolut
260 pSRD
->SetColRel( FALSE
);
261 pSRD
->SetRowRel( FALSE
);
262 pSRD
->SetTabRel( FALSE
);
270 class ExtSheetBuffer
: private List
, public ExcRoot
277 UINT16 nTabNum
; // 0xFFFF -> noch nicht angelegt
278 // 0xFFFE -> versucht anzulegen, ging aber schief
279 // 0xFFFD -> soll im selben Workbook sein, findet's aber nicht
282 Cont( const String
& rFilePathAndName
, const String
& rTabName
) :
283 aFile( rFilePathAndName
),
286 nTabNum
= 0xFFFF; // -> Tabelle noch nicht erzeugt
287 bSWB
= bLink
= FALSE
;
289 Cont( const String
& rFilePathAndName
, const String
& rTabName
,
290 const BOOL bSameWB
) :
291 aFile( rFilePathAndName
),
294 nTabNum
= 0xFFFF; // -> Tabelle noch nicht erzeugt
300 inline ExtSheetBuffer( RootData
* );
301 virtual ~ExtSheetBuffer();
303 sal_Int16
Add( const String
& rFilePathAndName
,
304 const String
& rTabName
, const BOOL bSameWorkbook
= FALSE
);
306 BOOL
GetScTabIndex( UINT16 nExcSheetIndex
, UINT16
& rIn_LastTab_Out_ScIndex
);
307 BOOL
IsLink( const UINT16 nExcSheetIndex
) const;
308 BOOL
GetLink( const UINT16 nExcSheetIndex
, String
&rAppl
, String
&rDoc
) const;
314 inline ExtSheetBuffer::ExtSheetBuffer( RootData
* p
) : ExcRoot( p
)
327 inline ExtName( const String
& r
, sal_uInt16 n
) : aName( r
), nStorageId( 0 ), nFlags( n
) {}
329 BOOL
IsDDE( void ) const;
330 BOOL
IsOLE( void ) const;
336 class ExtNameBuff
: protected XclImpRoot
339 explicit ExtNameBuff( const XclImpRoot
& rRoot
);
341 void AddDDE( const String
& rName
, sal_Int16 nRefIdx
);
342 void AddOLE( const String
& rName
, sal_Int16 nRefIdx
, UINT32 nStorageId
);
343 void AddName( const String
& rName
, sal_Int16 nRefIdx
);
345 const ExtName
* GetNameByIndex( sal_Int16 nRefIdx
, sal_uInt16 nNameIdx
) const;
350 typedef ::std::vector
< ExtName
> ExtNameVec
;
351 typedef ::std::map
< sal_Int16
, ExtNameVec
> ExtNameMap
;
353 ExtNameMap maExtNames
;