Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include "scitems.hxx"
30 : : #include <svx/algitem.hxx>
31 : : #include <editeng/justifyitem.hxx>
32 : : #include <svl/zforlist.hxx>
33 : : #include <tools/solar.h>
34 : :
35 : : #include "cell.hxx"
36 : : #include "rangenam.hxx"
37 : : #include "compiler.hxx"
38 : :
39 : : #include "tool.h"
40 : : #include "decl.h"
41 : : #include "root.hxx"
42 : : #include "lotrange.hxx"
43 : : #include "namebuff.hxx"
44 : : #include "ftools.hxx"
45 : :
46 : : #include <math.h>
47 : :
48 : : #ifdef _MSC_VER
49 : : #pragma optimize("",off)
50 : : #endif
51 : :
52 : : //--------------------------------------------------------- EXTERNE VARIABLEN -
53 : : extern WKTYP eTyp; // -> filter.cxx, aktueller Dateityp
54 : : extern ScDocument* pDoc; // -> filter.cxx, Aufhaenger zum Dokumentzugriff
55 : :
56 : : //--------------------------------------------------------- GLOBALE VARIABLEN -
57 : : sal_uInt8 nDefaultFormat; // -> op.cpp, Standard-Zellenformat
58 : :
59 : : extern SvxHorJustifyItem *pAttrRight, *pAttrLeft, *pAttrCenter, *pAttrRepeat, *pAttrStandard;
60 : : extern ScProtectionAttr* pAttrUnprot;
61 : : extern SfxUInt32Item** pAttrValForms;
62 : :
63 : : SvxHorJustifyItem *pAttrRight, *pAttrLeft, *pAttrCenter, *pAttrRepeat, *pAttrStandard;
64 : : // -> in memory.cxx initialisiert
65 : : ScProtectionAttr* pAttrUnprot; // -> " memory.cxx "
66 : :
67 : : extern FormCache* pValueFormCache; // -> in memory.cxx initialisiert
68 : : FormCache* pValueFormCache;
69 : :
70 : : SCCOL LotusRangeList::nEingCol;
71 : : SCROW LotusRangeList::nEingRow;
72 : :
73 : :
74 : :
75 : :
76 : 0 : void PutFormString( SCCOL nCol, SCROW nRow, SCTAB nTab, sal_Char* pString )
77 : : {
78 : : // Label-Format-Auswertung
79 : : OSL_ENSURE( pString != NULL, "PutFormString(): pString == NULL" );
80 [ # # ]: 0 : if (!pString)
81 : 0 : return;
82 : :
83 : : sal_Char cForm;
84 : 0 : SvxHorJustifyItem* pJustify = NULL;
85 : :
86 : 0 : cForm = *pString;
87 : :
88 [ # # # # : 0 : switch( cForm )
# # ]
89 : : {
90 : : case '"': // rechtsbuendig
91 : 0 : pJustify = pAttrRight;
92 : 0 : pString++;
93 : 0 : break;
94 : : case '\'': // linksbuendig
95 : 0 : pJustify = pAttrLeft;
96 : 0 : pString++;
97 : 0 : break;
98 : : case '^': // zentriert
99 : 0 : pJustify = pAttrCenter;
100 : 0 : pString++;
101 : 0 : break;
102 : : case '|': // printer command
103 : 0 : pString = NULL;
104 : 0 : break;
105 : : case '\\': // Wiederholung
106 : 0 : pJustify = pAttrRepeat;
107 : 0 : pString++;
108 : 0 : break;
109 : : default: // kenn' ich nicht!
110 : 0 : pJustify = pAttrStandard;
111 : : }
112 : :
113 : 0 : pDoc->ApplyAttr( nCol, nRow, nTab, *pJustify );
114 [ # # ][ # # ]: 0 : ScStringCell* pZelle = new ScStringCell( String( pString, pLotusRoot->eCharsetQ ) );
[ # # ]
115 : 0 : pDoc->PutCell( nCol, nRow, nTab, pZelle, true );
116 : : }
117 : :
118 : :
119 : :
120 : :
121 : 0 : void SetFormat( SCCOL nCol, SCROW nRow, SCTAB nTab, sal_uInt8 nFormat, sal_uInt8 nSt )
122 : : {
123 : : // PREC: nSt = Standard-Dezimalstellenanzahl
124 [ # # ][ # # ]: 0 : pDoc->ApplyAttr( nCol, nRow, nTab, *( pValueFormCache->GetAttr( nFormat, nSt ) ) );
125 : :
126 [ # # ]: 0 : ScProtectionAttr aAttr;
127 : :
128 [ # # ]: 0 : aAttr.SetProtection( nFormat & 0x80 );
129 : :
130 [ # # ][ # # ]: 0 : pDoc->ApplyAttr( nCol, nRow, nTab, aAttr );
131 : 0 : }
132 : :
133 : 0 : void InitPage( void )
134 : : { // Seitenformat initialisieren, d.h. Default-Werte von SC holen
135 : : //scGetPageFormat( 0, &aPage );
136 : 0 : }
137 : :
138 : :
139 : 0 : double SnumToDouble( sal_Int16 nVal )
140 : : {
141 : : const double pFacts[ 8 ] = {
142 : : 5000.0,
143 : : 500.0,
144 : : 0.05,
145 : : 0.005,
146 : : 0.0005,
147 : : 0.00005,
148 : : 0.0625,
149 : 0 : 0.015625 };
150 : :
151 : : double fVal;
152 : :
153 [ # # ]: 0 : if( nVal & 0x0001 )
154 : : {
155 : 0 : fVal = pFacts[ ( nVal >> 1 ) & 0x0007 ];
156 : 0 : fVal *= ( sal_Int16 ) ( nVal >> 4 );
157 : : }
158 : : else
159 : 0 : fVal = ( sal_Int16 ) ( nVal >> 1 );
160 : :
161 : 0 : return fVal;
162 : : }
163 : :
164 : 0 : double Snum32ToDouble( sal_uInt32 nValue )
165 : : {
166 : : double fValue, temp;
167 : :
168 : 0 : fValue = nValue >> 6;
169 : 0 : temp = nValue & 0x0f;
170 [ # # ]: 0 : if (temp)
171 : : {
172 [ # # ]: 0 : if (nValue & 0x00000010)
173 : 0 : fValue /= pow((double)10, temp);
174 : : else
175 : 0 : fValue *= pow((double)10, temp);
176 : : }
177 : :
178 [ # # ]: 0 : if ((nValue & 0x00000020))
179 : 0 : fValue = -fValue;
180 : 0 : return fValue;
181 : : }
182 : :
183 : :
184 [ # # ]: 0 : FormCache::FormCache( ScDocument* pDoc1, sal_uInt8 nNewDefaultFormat )
185 : : { // Default-Format ist 'Default'
186 : 0 : nDefaultFormat = nNewDefaultFormat;
187 : 0 : pFormTable = pDoc1->GetFormatTable();
188 [ # # ]: 0 : for( sal_uInt16 nC = 0 ; nC < __nSize ; nC++ )
189 : 0 : bValid[ nC ] = false;
190 : 0 : eLanguage = ScGlobal::eLnge;
191 : 0 : }
192 : :
193 : :
194 : 0 : FormCache::~FormCache()
195 : : {
196 [ # # ]: 0 : for( sal_uInt16 nC = 0 ; nC < __nSize ; nC++ )
197 [ # # ]: 0 : delete aIdents[ nC ].GetAttr();
198 : 0 : }
199 : :
200 : :
201 : 0 : SfxUInt32Item* FormCache::NewAttr( sal_uInt8 nFormat, sal_uInt8 nSt )
202 : : {
203 : : // neues Format erzeugen
204 : : sal_uInt8 nL, nH; // Low-/High-Nibble
205 : 0 : sal_uInt8 nForm = nFormat;
206 [ # # ]: 0 : String aFormString;
207 : 0 : sal_Int16 eType = NUMBERFORMAT_ALL;
208 : : sal_uInt32 nIndex1;
209 : : sal_uInt32 nHandle;
210 : 0 : NfIndexTableOffset eIndexTableOffset = NF_NUMERIC_START;
211 : 0 : sal_Bool bDefault = false;
212 : : //void GenerateFormat( aFormString, eType, COUNTRY_SYSTEM, LANGUAGE_SYSTEM,
213 : : // sal_Bool bThousand, sal_Bool IsRed, sal_uInt16 nPrecision, sal_uInt16 nAnzLeading );
214 : :
215 [ # # ]: 0 : if( nForm == 0xFF ) // Default-Format?
216 : 0 : nForm = nDefaultFormat;
217 : :
218 : : // Aufdroeseln in Low- und High-Nibble
219 : 0 : nL = nFormat & 0x0F;
220 : 0 : nH = ( nFormat & 0xF0 ) / 16;
221 : :
222 : 0 : nH &= 0x07; // Bits 4-6 'rausziehen
223 [ # # # # : 0 : switch( nH )
# # # #
# ]
224 : : {
225 : : case 0x00: // Festkommaformat (fixed)
226 : : //fStandard;nL;
227 : : nIndex1 = pFormTable->GetStandardFormat(
228 [ # # ]: 0 : NUMBERFORMAT_NUMBER, eLanguage );
229 : : pFormTable->GenerateFormat( aFormString, nIndex1,
230 [ # # ]: 0 : eLanguage, false, false, nL, 1 );
231 : 0 : break;
232 : : case 0x01: // Exponentdarstellung (scientific notation)
233 : : //fExponent;nL;
234 : : nIndex1 = pFormTable->GetStandardFormat(
235 [ # # ]: 0 : NUMBERFORMAT_SCIENTIFIC, eLanguage );
236 : : pFormTable->GenerateFormat( aFormString, nIndex1,
237 [ # # ]: 0 : eLanguage, false, false, nL, 1 );
238 : 0 : break;
239 : : case 0x02: // Waehrungsdarstellung (currency)
240 : : //fMoney;nL;
241 : : nIndex1 = pFormTable->GetStandardFormat(
242 [ # # ]: 0 : NUMBERFORMAT_CURRENCY, eLanguage );
243 : : pFormTable->GenerateFormat( aFormString, nIndex1,
244 [ # # ]: 0 : eLanguage, false, false, nL, 1 );
245 : 0 : break;
246 : : case 0x03: // Prozent
247 : : //fPercent;nL;
248 : : nIndex1 = pFormTable->GetStandardFormat(
249 [ # # ]: 0 : NUMBERFORMAT_PERCENT, eLanguage );
250 : : pFormTable->GenerateFormat( aFormString, nIndex1,
251 [ # # ]: 0 : eLanguage, false, false, nL, 1 );
252 : 0 : break;
253 : : case 0x04: // Komma
254 : : //fStandard;nL;
255 : : nIndex1 = pFormTable->GetStandardFormat(
256 [ # # ]: 0 : NUMBERFORMAT_NUMBER, eLanguage );
257 : : pFormTable->GenerateFormat( aFormString, nIndex1,
258 [ # # ]: 0 : eLanguage, sal_True, false, nL, 1 );
259 : 0 : break;
260 : : case 0x05: // frei
261 : : //fStandard;nL;
262 : : nIndex1 = pFormTable->GetStandardFormat(
263 [ # # ]: 0 : NUMBERFORMAT_NUMBER, eLanguage );
264 : : pFormTable->GenerateFormat( aFormString, nIndex1,
265 [ # # ]: 0 : eLanguage, false, false, nL, 1 );
266 : 0 : break;
267 : : case 0x06: // frei
268 : : //fStandard;nL;
269 : : nIndex1 = pFormTable->GetStandardFormat(
270 [ # # ]: 0 : NUMBERFORMAT_NUMBER, eLanguage );
271 : : pFormTable->GenerateFormat( aFormString, nIndex1,
272 [ # # ]: 0 : eLanguage, false, false, nL, 1 );
273 : 0 : nIndex1 = 0;
274 : 0 : break;
275 : : case 0x07: // Spezialformat
276 [ # # # # : 0 : switch( nL )
# # # # #
# # # # #
# ]
277 : : {
278 : : case 0x00: // +/-
279 : : //fStandard;nSt;
280 : : nIndex1 = pFormTable->GetStandardFormat(
281 [ # # ]: 0 : NUMBERFORMAT_NUMBER, eLanguage );
282 : : pFormTable->GenerateFormat( aFormString, nIndex1,
283 [ # # ]: 0 : eLanguage, false, sal_True, nSt, 1 );
284 : 0 : break;
285 : : case 0x01: // generelles Format
286 : : //fStandard;nSt;
287 : : nIndex1 = pFormTable->GetStandardFormat(
288 [ # # ]: 0 : NUMBERFORMAT_NUMBER, eLanguage );
289 : : pFormTable->GenerateFormat( aFormString, nIndex1,
290 [ # # ]: 0 : eLanguage, false, false, nSt, 1 );
291 : 0 : break;
292 : : case 0x02: // Datum: Tag, Monat, Jahr
293 : : //fDate;dfDayMonthYearLong;
294 : 0 : eType = NUMBERFORMAT_DATE;
295 : 0 : eIndexTableOffset = NF_DATE_SYS_DDMMYYYY;
296 : 0 : break;
297 : : case 0x03: // Datum: Tag, Monat
298 : : //fDate;dfDayMonthLong;
299 : 0 : eType = NUMBERFORMAT_DATE;
300 [ # # ][ # # ]: 0 : aFormString = pFormTable->GetKeyword( eLanguage, NF_KEY_DD);
[ # # ]
301 [ # # ]: 0 : aFormString += pFormTable->GetDateSep(); // matches last eLanguage
302 [ # # ][ # # ]: 0 : aFormString += pFormTable->GetKeyword( eLanguage, NF_KEY_MMMM);
[ # # ]
303 : 0 : break;
304 : : case 0x04: // Datum: Monat, Jahr
305 : : //fDate;dfMonthYearLong;
306 : 0 : eType = NUMBERFORMAT_DATE;
307 [ # # ][ # # ]: 0 : aFormString = pFormTable->GetKeyword( eLanguage, NF_KEY_MM);
[ # # ]
308 [ # # ]: 0 : aFormString += pFormTable->GetDateSep(); // matches last eLanguage
309 [ # # ][ # # ]: 0 : aFormString += pFormTable->GetKeyword( eLanguage, NF_KEY_YYYY);
[ # # ]
310 : 0 : break;
311 : : case 0x05: // Textformate
312 : : //fString;nSt;
313 : 0 : eType = NUMBERFORMAT_TEXT;
314 : 0 : eIndexTableOffset = NF_TEXT;
315 : 0 : break;
316 : : case 0x06: // versteckt
317 : : //wFlag |= paHideAll;bSetFormat = sal_False;
318 : 0 : eType = NUMBERFORMAT_NUMBER;
319 [ # # ]: 0 : aFormString = "\"\"";
320 : 0 : break;
321 : : case 0x07: // Time: hour, min, sec
322 : : //fTime;tfHourMinSec24;
323 : 0 : eType = NUMBERFORMAT_TIME;
324 : 0 : eIndexTableOffset = NF_TIME_HHMMSS;
325 : 0 : break;
326 : : case 0x08: // Time: hour, min
327 : : //fTime;tfHourMin24;
328 : 0 : eType = NUMBERFORMAT_TIME;
329 : 0 : eIndexTableOffset = NF_TIME_HHMM;
330 : 0 : break;
331 : : case 0x09: // Date, intern sal_Int32 1
332 : : //fDate;dfDayMonthYearLong;
333 : 0 : eType = NUMBERFORMAT_DATE;
334 : 0 : eIndexTableOffset = NF_DATE_SYS_DDMMYYYY;
335 : 0 : break;
336 : : case 0x0A: // Date, intern sal_Int32 2
337 : : //fDate;dfDayMonthYearLong;
338 : 0 : eType = NUMBERFORMAT_DATE;
339 : 0 : eIndexTableOffset = NF_DATE_SYS_DDMMYYYY;
340 : 0 : break;
341 : : case 0x0B: // Time, intern sal_Int32 1
342 : : //fTime;tfHourMinSec24;
343 : 0 : eType = NUMBERFORMAT_TIME;
344 : 0 : eIndexTableOffset = NF_TIME_HHMMSS;
345 : 0 : break;
346 : : case 0x0C: // Time, intern sal_Int32 2
347 : : //fTime;tfHourMinSec24;
348 : 0 : eType = NUMBERFORMAT_TIME;
349 : 0 : eIndexTableOffset = NF_TIME_HHMMSS;
350 : 0 : break;
351 : : case 0x0F: // Standardeinstellung
352 : : //fStandard;nSt;
353 : 0 : bDefault = sal_True;
354 : 0 : break;
355 : : default:
356 : : //fStandard;nSt;
357 : 0 : bDefault = sal_True;
358 : 0 : break;
359 : : }
360 : 0 : break;
361 : : default:
362 : : //fStandard;nL;
363 : : nIndex1 = pFormTable->GetStandardFormat(
364 [ # # ]: 0 : NUMBERFORMAT_NUMBER, eLanguage );
365 : : pFormTable->GenerateFormat( aFormString, nIndex1,
366 [ # # ]: 0 : eLanguage, false, false, nL, 1 );
367 : 0 : nIndex1 = 0;
368 : 0 : break;
369 : : }
370 : :
371 : : // Format in Table schieben
372 [ # # ]: 0 : if( bDefault )
373 : 0 : nHandle = 0;
374 [ # # ]: 0 : else if (eIndexTableOffset != NF_NUMERIC_START)
375 [ # # ]: 0 : nHandle = pFormTable->GetFormatIndex( eIndexTableOffset, eLanguage);
376 : : else
377 : : {
378 : : xub_StrLen nDummy;
379 [ # # ]: 0 : pFormTable->PutEntry( aFormString, nDummy, eType, nHandle, eLanguage );
380 : : }
381 : :
382 [ # # ][ # # ]: 0 : return new SfxUInt32Item( ATTR_VALUE_FORMAT, ( sal_uInt32 ) nHandle );
[ # # ]
383 : : }
384 : :
385 : :
386 : :
387 : :
388 : 0 : void LotusRange::MakeHash( void )
389 : : {
390 : : // 33222222222211111111110000000000
391 : : // 10987654321098765432109876543210
392 : : // ******** nColS
393 : : // ******** nColE
394 : : // **************** nRowS
395 : : // **************** nRowE
396 : 0 : nHash = static_cast<sal_uInt32>(nColStart);
397 : 0 : nHash += static_cast<sal_uInt32>(nColEnd) << 6;
398 : 0 : nHash += static_cast<sal_uInt32>(nRowStart) << 12;
399 : 0 : nHash += static_cast<sal_uInt32>(nRowEnd ) << 16;
400 : 0 : }
401 : :
402 : :
403 : 0 : LotusRange::LotusRange( SCCOL nCol, SCROW nRow )
404 : : {
405 : 0 : nColStart = nColEnd = nCol;
406 : 0 : nRowStart = nRowEnd = nRow;
407 : 0 : nId = ID_FAIL;
408 : 0 : MakeHash();
409 : 0 : }
410 : :
411 : :
412 : 0 : LotusRange::LotusRange( SCCOL nCS, SCROW nRS, SCCOL nCE, SCROW nRE )
413 : : {
414 : 0 : nColStart = nCS;
415 : 0 : nColEnd = nCE;
416 : 0 : nRowStart = nRS;
417 : 0 : nRowEnd = nRE;
418 : 0 : nId = ID_FAIL;
419 : 0 : MakeHash();
420 : 0 : }
421 : :
422 : :
423 : 0 : LotusRange::LotusRange( const LotusRange& rCpy )
424 : : {
425 : 0 : Copy( rCpy );
426 : 0 : }
427 : :
428 : :
429 : :
430 : :
431 : :
432 : 0 : LotusRangeList::LotusRangeList( void )
433 : : {
434 : 0 : aComplRef.InitFlags();
435 : :
436 : : ScSingleRefData* pSingRef;
437 : 0 : nIdCnt = 1;
438 : :
439 : 0 : pSingRef = &aComplRef.Ref1;
440 : 0 : pSingRef->nTab = pSingRef->nRelTab = 0;
441 : 0 : pSingRef->SetColRel( false );
442 : 0 : pSingRef->SetRowRel( false );
443 : 0 : pSingRef->SetTabRel( sal_True );
444 : 0 : pSingRef->SetFlag3D( false );
445 : :
446 : 0 : pSingRef = &aComplRef.Ref2;
447 : 0 : pSingRef->nTab = pSingRef->nRelTab = 0;
448 : 0 : pSingRef->SetColRel( false );
449 : 0 : pSingRef->SetRowRel( false );
450 : 0 : pSingRef->SetTabRel( sal_True );
451 : 0 : pSingRef->SetFlag3D( false );
452 : 0 : }
453 : :
454 : 0 : LotusRangeList::~LotusRangeList ()
455 : : {
456 : 0 : std::vector<LotusRange*>::iterator pIter;
457 [ # # ][ # # ]: 0 : for (pIter = maRanges.begin(); pIter != maRanges.end(); ++pIter)
458 : 0 : delete (*pIter);
459 : 0 : }
460 : :
461 : 0 : LR_ID LotusRangeList::GetIndex( const LotusRange &rRef )
462 : : {
463 : 0 : std::vector<LotusRange*>::iterator pIter;
464 [ # # ][ # # ]: 0 : for (pIter = maRanges.begin(); pIter != maRanges.end(); ++pIter)
465 : : {
466 [ # # ]: 0 : if (rRef == *(*pIter))
467 : 0 : return (*pIter)->nId;
468 : : }
469 : :
470 : 0 : return ID_FAIL;
471 : : }
472 : :
473 : :
474 : 0 : void LotusRangeList::Append( LotusRange* pLR, const String& rName )
475 : : {
476 : : OSL_ENSURE( pLR, "*LotusRangeList::Append(): das wird nichts!" );
477 [ # # ]: 0 : maRanges.push_back(pLR);
478 : :
479 [ # # ]: 0 : ScTokenArray aTokArray;
480 : :
481 : 0 : ScSingleRefData* pSingRef = &aComplRef.Ref1;
482 : :
483 : 0 : pSingRef->nCol = pLR->nColStart;
484 : 0 : pSingRef->nRow = pLR->nRowStart;
485 : :
486 [ # # ]: 0 : if( pLR->IsSingle() )
487 [ # # ]: 0 : aTokArray.AddSingleReference( *pSingRef );
488 : : else
489 : : {
490 : 0 : pSingRef = &aComplRef.Ref2;
491 : 0 : pSingRef->nCol = pLR->nColEnd;
492 : 0 : pSingRef->nRow = pLR->nRowEnd;
493 [ # # ]: 0 : aTokArray.AddDoubleReference( aComplRef );
494 : : }
495 : :
496 : : ScRangeData* pData = new ScRangeData(
497 [ # # ][ # # ]: 0 : pLotusRoot->pDoc, rName, aTokArray );
[ # # ]
498 : :
499 [ # # ]: 0 : pLotusRoot->pScRangeName->insert( pData );
500 : :
501 : 0 : pLR->SetId( nIdCnt );
502 : :
503 [ # # ]: 0 : nIdCnt++;
504 : 0 : }
505 : :
506 : :
507 : :
508 : :
509 : 0 : RangeNameBufferWK3::RangeNameBufferWK3( void )
510 : : {
511 [ # # ][ # # ]: 0 : pScTokenArray = new ScTokenArray;
512 : 0 : nIntCount = 1;
513 : 0 : }
514 : :
515 : :
516 : 0 : RangeNameBufferWK3::~RangeNameBufferWK3()
517 : : {
518 [ # # ][ # # ]: 0 : delete pScTokenArray;
519 [ # # ]: 0 : }
520 : :
521 : :
522 : 0 : void RangeNameBufferWK3::Add( const String& rOrgName, const ScComplexRefData& rCRD )
523 : : {
524 [ # # ]: 0 : String aScName( rOrgName );
525 [ # # ]: 0 : ScfTools::ConvertToScDefinedName( aScName );
526 : :
527 [ # # ]: 0 : Entry aInsert( rOrgName, aScName, rCRD );
528 : :
529 [ # # ]: 0 : pScTokenArray->Clear();
530 : :
531 : 0 : register const ScSingleRefData& rRef1 = rCRD.Ref1;
532 : 0 : register const ScSingleRefData& rRef2 = rCRD.Ref2;
533 : :
534 [ # # ][ # # ]: 0 : if( rRef1.nCol == rRef2.nCol && rRef1.nRow == rRef2.nRow && rRef1.nTab == rRef2.nTab )
[ # # ]
535 : : {
536 [ # # ]: 0 : pScTokenArray->AddSingleReference( rCRD.Ref1 );
537 : 0 : aInsert.bSingleRef = sal_True;
538 : : }
539 : : else
540 : : {
541 [ # # ]: 0 : pScTokenArray->AddDoubleReference( rCRD );
542 : 0 : aInsert.bSingleRef = false;
543 : : }
544 : :
545 [ # # ][ # # ]: 0 : ScRangeData* pData = new ScRangeData( pLotusRoot->pDoc, aScName, *pScTokenArray );
[ # # ]
546 : :
547 : 0 : aInsert.nRelInd = nIntCount;
548 : 0 : pData->SetIndex( nIntCount );
549 : 0 : nIntCount++;
550 : :
551 [ # # ]: 0 : maEntries.push_back( aInsert );
552 [ # # ][ # # ]: 0 : pLotusRoot->pScRangeName->insert( pData );
[ # # ]
553 : 0 : }
554 : :
555 : :
556 : 0 : sal_Bool RangeNameBufferWK3::FindRel( const String& rRef, sal_uInt16& rIndex )
557 : : {
558 [ # # ]: 0 : StringHashEntry aRef( rRef );
559 : :
560 : 0 : std::vector<Entry>::const_iterator itr;
561 [ # # ][ # # ]: 0 : for ( itr = maEntries.begin(); itr != maEntries.end(); ++itr )
[ # # ]
562 : : {
563 [ # # ][ # # ]: 0 : if ( aRef == itr->aStrHashEntry )
564 : : {
565 : 0 : rIndex = itr->nRelInd;
566 : 0 : return true;
567 : : }
568 : : }
569 : :
570 [ # # ]: 0 : return false;
571 : : }
572 : :
573 : :
574 : 0 : sal_Bool RangeNameBufferWK3::FindAbs( const String& rRef, sal_uInt16& rIndex )
575 : : {
576 [ # # ]: 0 : String aTmp( rRef );
577 [ # # ][ # # ]: 0 : StringHashEntry aRef( aTmp.Erase( 0, 1 ) ); // ohne '$' suchen!
578 : :
579 : 0 : std::vector<Entry>::iterator itr;
580 [ # # ][ # # ]: 0 : for ( itr = maEntries.begin(); itr != maEntries.end(); ++itr )
581 : : {
582 [ # # ][ # # ]: 0 : if ( aRef == itr->aStrHashEntry )
583 : : {
584 : : // eventuell neuen Range Name aufbauen
585 [ # # ]: 0 : if( itr->nAbsInd )
586 : 0 : rIndex = itr->nAbsInd;
587 : : else
588 : : {
589 : 0 : ScSingleRefData* pRef = &itr->aScComplexRefDataRel.Ref1;
590 [ # # ]: 0 : pScTokenArray->Clear();
591 : :
592 : 0 : pRef->SetColRel( false );
593 : 0 : pRef->SetRowRel( false );
594 : 0 : pRef->SetTabRel( sal_True );
595 : :
596 [ # # ]: 0 : if( itr->bSingleRef )
597 [ # # ]: 0 : pScTokenArray->AddSingleReference( *pRef );
598 : : else
599 : : {
600 : 0 : pRef = &itr->aScComplexRefDataRel.Ref2;
601 : 0 : pRef->SetColRel( false );
602 : 0 : pRef->SetRowRel( false );
603 : 0 : pRef->SetTabRel( sal_True );
604 [ # # ]: 0 : pScTokenArray->AddDoubleReference( itr->aScComplexRefDataRel );
605 : : }
606 : :
607 [ # # ][ # # ]: 0 : ScRangeData* pData = new ScRangeData( pLotusRoot->pDoc, itr->aScAbsName, *pScTokenArray );
[ # # ]
608 : :
609 : 0 : rIndex = itr->nAbsInd = nIntCount;
610 : 0 : pData->SetIndex( rIndex );
611 : 0 : nIntCount++;
612 : :
613 [ # # ]: 0 : pLotusRoot->pScRangeName->insert( pData );
614 : : }
615 : :
616 : 0 : return true;
617 : : }
618 : : }
619 : :
620 [ # # ][ # # ]: 0 : return false;
621 : : }
622 : :
623 : :
624 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|