Update ooo320-m1
[ooovba.git] / binfilter / inc / bf_sc / rangenam.hxx
blobe87b0a10c4d15b8d3cf8c223f6884faa97cb3cf0
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: rangenam.hxx,v $
10 * $Revision: 1.7 $
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
34 #ifndef SC_SCGLOB_HXX
35 #include "global.hxx" // -> enum UpdateRefMode
36 #endif
37 #ifndef SC_COLLECT_HXX
38 #include "collect.hxx"
39 #endif
40 namespace rtl {
41 class OUStringBuffer;
43 namespace binfilter {
45 //------------------------------------------------------------------------
47 class ScDocument;
48 class ScMultipleReadHeader;
49 class ScMultipleWriteHeader;
51 //STRIP008 namespace rtl {
52 //STRIP008 class OUStringBuffer;
53 //STRIP008 }
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 //------------------------------------------------------------------------
74 class ScTokenArray;
75 class ScIndexMap;
77 class ScRangeData : public DataObject
79 #if defined( ICC ) && defined( OS2 )
80 friend static int _Optlink ICCQsortNameCompare( const void* a, const void* b);
81 #endif
82 private:
83 String aName;
84 ScTokenArray* pCode;
85 ScAddress aPos;
86 RangeType eType;
87 ScDocument* pDoc;
88 USHORT nIndex;
89 USHORT nExportIndex;
90 BOOL bModified; // wird bei UpdateReference gesetzt/geloescht
92 friend class ScRangeName;
93 ScRangeData( USHORT nIndex );
94 public:
95 ScRangeData( ScDocument* pDoc,
96 const String& rName,
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,
105 USHORT nVer );
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; }
124 USHORT GetErrCode();
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 );
156 #ifdef WNT
157 static int __cdecl QsortNameCompare( const void*, const void* );
158 #else
159 static int QsortNameCompare( const void*, const void* );
160 #endif
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); }
171 #endif
173 //------------------------------------------------------------------------
175 class ScRangeName : public SortedCollection
177 private:
178 ScDocument* pDoc;
179 USHORT nSharedMaxIndex;
180 public:
181 ScRangeName(USHORT nLim = 4, USHORT nDel = 4, BOOL bDup = FALSE,
182 ScDocument* pDocument = NULL) :
183 SortedCollection ( nLim, nDel, bDup ),
184 pDoc ( pDocument ),
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
212 #endif