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: rangenam.hxx,v $
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_RANGENAM_HXX
32 #define SC_RANGENAM_HXX
35 #include "global.hxx" // -> enum UpdateRefMode
37 #ifndef SC_COLLECT_HXX
38 #include "collect.hxx"
45 //------------------------------------------------------------------------
48 class ScMultipleReadHeader
;
49 class ScMultipleWriteHeader
;
51 //STRIP008 namespace rtl {
52 //STRIP008 class OUStringBuffer;
56 //------------------------------------------------------------------------
58 typedef USHORT RangeType
;
60 #define RT_NAME ((RangeType)0x0000)
61 #define RT_DATABASE ((RangeType)0x0001)
62 #define RT_CRITERIA ((RangeType)0x0002)
63 #define RT_PRINTAREA ((RangeType)0x0004)
64 #define RT_COLHEADER ((RangeType)0x0008)
65 #define RT_ROWHEADER ((RangeType)0x0010)
66 #define RT_ABSAREA ((RangeType)0x0020)
67 #define RT_REFAREA ((RangeType)0x0040)
68 #define RT_ABSPOS ((RangeType)0x0080)
69 #define RT_SHARED ((RangeType)0x0100)
70 #define RT_SHAREDMOD ((RangeType)0x0200)
72 //------------------------------------------------------------------------
77 class ScRangeData
: public DataObject
79 #if defined( ICC ) && defined( OS2 )
80 friend static int _Optlink
ICCQsortNameCompare( const void* a
, const void* b
);
90 BOOL bModified
; // wird bei UpdateReference gesetzt/geloescht
92 friend class ScRangeName
;
93 ScRangeData( USHORT nIndex
);
95 ScRangeData( ScDocument
* pDoc
,
97 const String
& rSymbol
,
98 const ScAddress
& rAdr
= ScAddress(),
99 RangeType nType
= RT_NAME
,
100 BOOL bEnglish
= FALSE
);
101 // rTarget ist ABSPOS Sprungmarke
102 ScRangeData(const ScRangeData
& rScRangeData
);
103 ScRangeData( SvStream
& rStream
,
104 ScMultipleReadHeader
& rHdr
,
107 virtual ~ScRangeData();
110 virtual DataObject
* Clone() const;
112 BOOL
Store( SvStream
& rStream
, ScMultipleWriteHeader
& rHdr
) const;
115 void GetName( String
& rName
) const { rName
= aName
; }
116 const String
& GetName( void ) const { return aName
; }
117 ScAddress
GetPos() const { return aPos
; }
118 // Der Index muss eindeutig sein. Ist er 0, wird ein neuer Index vergeben
119 void SetIndex( USHORT nInd
) { nIndex
= nExportIndex
= nInd
; }
120 const USHORT
GetIndex() { return nIndex
; }
121 void SetExportIndex( USHORT nInd
) { nExportIndex
= nInd
; }
122 const USHORT
GetExportIndex() { return nExportIndex
; }
123 ScTokenArray
* GetCode() { return pCode
; }
125 BOOL
HasReferences() const;
126 void SetDocument( ScDocument
* pDocument
){ pDoc
= pDocument
; }
127 ScDocument
* GetDocument() const { return pDoc
; }
128 void SetType( RangeType nType
) { eType
= nType
; }
129 void AddType( RangeType nType
) { eType
= eType
|nType
; }
130 RangeType
GetType() const { return eType
; }
131 BOOL
HasType( RangeType nType
) const;
132 void GetSymbol(String
& rSymbol
) const;
133 void GetEnglishSymbol(String
& rSymbol
, BOOL bCompileXML
= FALSE
) const;
134 void UpdateSymbol( String
& rSymbol
, const ScAddress
&,
135 BOOL bEnglish
= FALSE
, BOOL bCompileXML
= FALSE
);
136 void UpdateSymbol( ::rtl::OUStringBuffer
& rBuffer
, const ScAddress
&,
137 BOOL bEnglish
= FALSE
, BOOL bCompileXML
= FALSE
);
138 /*N*/ void UpdateReference( UpdateRefMode eUpdateRefMode
,
139 /*N*/ const ScRange
& r
,
140 /*N*/ short nDx
, short nDy
, short nDz
);
141 BOOL
IsModified() const { return bModified
; }
145 BOOL
IsReference( ScRange
& rRef
) const;
149 void ValidateTabRefs();
151 void ReplaceRangeNamesInUse( const ScIndexMap
& rMap
);
153 BOOL
IsBeyond( USHORT nMaxRow
) const;
155 static void MakeValidName( String
& rName
);
157 static int __cdecl
QsortNameCompare( const void*, const void* );
159 static int QsortNameCompare( const void*, const void* );
163 inline BOOL
ScRangeData::HasType( RangeType nType
) const
165 return ( ( eType
& nType
) == nType
);
168 #if defined( ICC ) && defined( OS2 )
169 static int _Optlink
ICCQsortNameCompare( const void* a
, const void* b
)
170 { ScRangeData::QsortNameCompare(a
,b
); }
173 //------------------------------------------------------------------------
175 class ScRangeName
: public SortedCollection
179 USHORT nSharedMaxIndex
;
181 ScRangeName(USHORT nLim
= 4, USHORT nDel
= 4, BOOL bDup
= FALSE
,
182 ScDocument
* pDocument
= NULL
) :
183 SortedCollection ( nLim
, nDel
, bDup
),
185 nSharedMaxIndex ( 1 ) {} // darf nicht 0 sein!!
187 ScRangeName(const ScRangeName
& rScRangeName
, ScDocument
* pDocument
);
189 virtual DataObject
* Clone(ScDocument
* pDoc
) const
190 { return new ScRangeName(*this, pDoc
); }
191 ScRangeData
* operator[]( const USHORT nIndex
) const
192 { return (ScRangeData
*)At(nIndex
); }
193 virtual short Compare(DataObject
* pKey1
, DataObject
* pKey2
) const;
195 BOOL
Load( SvStream
& rStream
, USHORT nVer
);
196 BOOL
Store( SvStream
& rStream
) const;
197 BOOL
SearchName( const String
& rName
, USHORT
& rPos
) const;
198 /*N*/ void UpdateReference(UpdateRefMode eUpdateRefMode
,
199 /*N*/ const ScRange
& rRange
,
200 /*N*/ short nDx
, short nDy
, short nDz
);
201 void UpdateTabRef(USHORT nTable
, USHORT nFlag
, USHORT nNewTable
= 0);
202 /*N*/ void UpdateTranspose( const ScRange
& rSource
, const ScAddress
& rDest
);
203 /*N*/ void UpdateGrow( const ScRange
& rArea
, USHORT nGrowX
, USHORT nGrowY
);
204 virtual BOOL
Insert(DataObject
* pDataObject
);
205 ScRangeData
* FindIndex(USHORT nIndex
);
206 USHORT
GetSharedMaxIndex() { return nSharedMaxIndex
; }
207 void SetSharedMaxIndex(USHORT nInd
) { nSharedMaxIndex
= nInd
; }
208 USHORT
GetEntryIndex();
211 } //namespace binfilter