merge the formfield patch from ooo-build
[ooovba.git] / sc / source / filter / excel / tokstack.cxx
blobd24dac42ca967fce82d301dadafcdc8c7b62d514
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: tokstack.cxx,v $
10 * $Revision: 1.14.32.3 $
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 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
35 #ifndef PCH
36 #include <string.h>
37 #endif
39 #include "compiler.hxx"
40 #include "tokstack.hxx"
41 #include "global.hxx"
42 #include "scmatrix.hxx"
44 #include <stdio.h> // printf
46 const UINT16 TokenPool::nScTokenOff = 8192;
49 TokenStack::TokenStack( UINT16 nNewSize )
51 pStack = new TokenId[ nNewSize ];
53 Reset();
54 nSize = nNewSize;
58 TokenStack::~TokenStack()
60 delete[] pStack;
66 //------------------------------------------------------------------------
68 // !ACHTUNG!: nach Aussen hin beginnt die Nummerierung mit 1!
69 // !ACHTUNG!: SC-Token werden mit einem Offset nScTokenOff abgelegt
70 // -> Unterscheidung von anderen Token
73 TokenPool::TokenPool( void )
75 UINT16 nLauf = nScTokenOff;
77 // Sammelstelle fuer Id-Folgen
78 nP_Id = 256;
79 pP_Id = new UINT16[ nP_Id ];
81 // Sammelstelle fuer Ids
82 nElement = 32;
83 pElement = new UINT16[ nElement ];
84 pType = new E_TYPE[ nElement ];
85 pSize = new UINT16[ nElement ];
86 nP_IdLast = 0;
88 // Sammelstelle fuer Strings
89 nP_Str = 4;
90 ppP_Str = new String *[ nP_Str ];
91 for( nLauf = 0 ; nLauf < nP_Str ; nLauf++ )
92 ppP_Str[ nLauf ] = NULL;
94 // Sammelstelle fuer double
95 nP_Dbl = 8;
96 pP_Dbl = new double[ nP_Dbl ];
98 // Sammelstelle fuer error codes
99 nP_Err = 8;
100 pP_Err = new USHORT[ nP_Err ];
102 // Sammelstellen fuer Referenzen
103 nP_RefTr = 32;
104 ppP_RefTr = new ScSingleRefData *[ nP_RefTr ];
105 for( nLauf = 0 ; nLauf < nP_RefTr ; nLauf++ )
106 ppP_RefTr[ nLauf ] = NULL;
108 nP_Ext = 32;
109 ppP_Ext = new EXTCONT*[ nP_Ext ];
110 memset( ppP_Ext, 0, sizeof( EXTCONT* ) * nP_Ext );
112 nP_Nlf = 16;
113 ppP_Nlf = new NLFCONT*[ nP_Nlf ];
114 memset( ppP_Nlf, 0, sizeof( NLFCONT* ) * nP_Nlf );
116 nP_Matrix = 16;
117 ppP_Matrix = new ScMatrix*[ nP_Matrix ];
118 memset( ppP_Matrix, 0, sizeof( ScMatrix* ) * nP_Matrix );
120 pScToken = new ScTokenArray;
122 Reset();
126 TokenPool::~TokenPool()
128 UINT16 n;
130 delete[] pP_Id;
131 delete[] pElement;
132 delete[] pType;
133 delete[] pSize;
134 delete[] pP_Dbl;
135 delete[] pP_Err;
137 for( n = 0 ; n < nP_RefTr ; n++/*, pAktTr++*/ )
139 if( ppP_RefTr[ n ] )
140 delete ppP_RefTr[ n ];
142 delete[] ppP_RefTr;
144 for( n = 0 ; n < nP_Str ; n++/*, pAktStr++*/ )
146 if( ppP_Str[ n ] )
147 delete ppP_Str[ n ];
149 delete[] ppP_Str;
151 for( n = 0 ; n < nP_Ext ; n++ )
153 if( ppP_Ext[ n ] )
154 delete ppP_Ext[ n ];
156 delete[] ppP_Ext;
158 for( n = 0 ; n < nP_Nlf ; n++ )
160 if( ppP_Nlf[ n ] )
161 delete ppP_Nlf[ n ];
163 delete[] ppP_Nlf;
165 for( n = 0 ; n < nP_Matrix ; n++ )
167 if( ppP_Matrix[ n ] )
168 ppP_Matrix[ n ]->DecRef( );
170 delete[] ppP_Matrix;
172 delete pScToken;
176 void TokenPool::GrowString( void )
178 UINT16 nP_StrNew = nP_Str * 2;
179 UINT16 nL;
181 String** ppP_StrNew = new String *[ nP_StrNew ];
183 for( nL = 0 ; nL < nP_Str ; nL++ )
184 ppP_StrNew[ nL ] = ppP_Str[ nL ];
185 for( nL = nP_Str ; nL < nP_StrNew ; nL++ )
186 ppP_StrNew[ nL ] = NULL;
188 nP_Str = nP_StrNew;
190 delete[] ppP_Str;
191 ppP_Str = ppP_StrNew;
195 void TokenPool::GrowDouble( void )
197 UINT16 nP_DblNew = nP_Dbl * 2;
199 double* pP_DblNew = new double[ nP_DblNew ];
201 for( UINT16 nL = 0 ; nL < nP_Dbl ; nL++ )
202 pP_DblNew[ nL ] = pP_Dbl[ nL ];
204 nP_Dbl = nP_DblNew;
206 delete[] pP_Dbl;
207 pP_Dbl = pP_DblNew;
211 //UNUSED2009-05 void TokenPool::GrowError( void )
212 //UNUSED2009-05 {
213 //UNUSED2009-05 UINT16 nP_ErrNew = nP_Err * 2;
214 //UNUSED2009-05
215 //UNUSED2009-05 USHORT* pP_ErrNew = new USHORT[ nP_ErrNew ];
216 //UNUSED2009-05
217 //UNUSED2009-05 for( UINT16 nL = 0 ; nL < nP_Err ; nL++ )
218 //UNUSED2009-05 pP_ErrNew[ nL ] = pP_Err[ nL ];
219 //UNUSED2009-05
220 //UNUSED2009-05 nP_Err = nP_ErrNew;
221 //UNUSED2009-05
222 //UNUSED2009-05 delete[] pP_Err;
223 //UNUSED2009-05 pP_Err = pP_ErrNew;
224 //UNUSED2009-05 }
227 void TokenPool::GrowTripel( void )
229 UINT16 nP_RefTrNew = nP_RefTr * 2;
230 UINT16 nL;
232 ScSingleRefData** ppP_RefTrNew = new ScSingleRefData *[ nP_RefTrNew ];
234 for( nL = 0 ; nL < nP_RefTr ; nL++ )
235 ppP_RefTrNew[ nL ] = ppP_RefTr[ nL ];
236 for( nL = nP_RefTr ; nL < nP_RefTrNew ; nL++ )
237 ppP_RefTrNew[ nL ] = NULL;
239 nP_RefTr = nP_RefTrNew;
241 delete[] ppP_RefTr;
242 ppP_RefTr = ppP_RefTrNew;
246 void TokenPool::GrowId( void )
248 UINT16 nP_IdNew = nP_Id * 2;
250 UINT16* pP_IdNew = new UINT16[ nP_IdNew ];
252 for( UINT16 nL = 0 ; nL < nP_Id ; nL++ )
253 pP_IdNew[ nL ] = pP_Id[ nL ];
255 nP_Id = nP_IdNew;
257 delete[] pP_Id;
258 pP_Id = pP_IdNew;
262 void TokenPool::GrowElement( void )
264 UINT16 nElementNew = nElement * 2;
266 UINT16* pElementNew = new UINT16[ nElementNew ];
267 E_TYPE* pTypeNew = new E_TYPE[ nElementNew ];
268 UINT16* pSizeNew = new UINT16[ nElementNew ];
270 for( UINT16 nL = 0 ; nL < nElement ; nL++ )
272 pElementNew[ nL ] = pElement[ nL ];
273 pTypeNew[ nL ] = pType[ nL ];
274 pSizeNew[ nL ] = pSize[ nL ];
277 nElement = nElementNew;
279 delete[] pElement;
280 delete[] pType;
281 delete[] pSize;
282 pElement = pElementNew;
283 pType = pTypeNew;
284 pSize = pSizeNew;
288 void TokenPool::GrowExt( void )
290 UINT16 nNewSize = nP_Ext * 2;
292 EXTCONT** ppNew = new EXTCONT*[ nNewSize ];
294 memset( ppNew, 0, sizeof( EXTCONT* ) * nNewSize );
295 memcpy( ppNew, ppP_Ext, sizeof( EXTCONT* ) * nP_Ext );
297 delete[] ppP_Ext;
298 ppP_Ext = ppNew;
299 nP_Ext = nNewSize;
303 void TokenPool::GrowNlf( void )
305 UINT16 nNewSize = nP_Nlf * 2;
307 NLFCONT** ppNew = new NLFCONT*[ nNewSize ];
309 memset( ppNew, 0, sizeof( NLFCONT* ) * nNewSize );
310 memcpy( ppNew, ppP_Nlf, sizeof( NLFCONT* ) * nP_Nlf );
312 delete[] ppP_Nlf;
313 ppP_Nlf = ppNew;
314 nP_Nlf = nNewSize;
318 void TokenPool::GrowMatrix( void )
320 UINT16 nNewSize = nP_Matrix * 2;
322 ScMatrix** ppNew = new ScMatrix*[ nNewSize ];
324 memset( ppNew, 0, sizeof( ScMatrix* ) * nNewSize );
325 memcpy( ppNew, ppP_Matrix, sizeof( ScMatrix* ) * nP_Matrix );
327 delete[] ppP_Matrix;
328 ppP_Matrix = ppNew;
329 nP_Matrix = nNewSize;
332 void TokenPool::GetElement( const UINT16 nId )
334 DBG_ASSERT( nId < nElementAkt, "*TokenPool::GetElement(): Id zu gross!?" );
336 if( pType[ nId ] == T_Id )
337 GetElementRek( nId );
338 else
340 switch( pType[ nId ] )
342 #ifdef DBG_UTIL
343 case T_Id:
344 DBG_ERROR( "-TokenPool::GetElement(): hier hast Du nichts zu suchen!" );
345 break;
346 #endif
347 case T_Str:
348 pScToken->AddString( ppP_Str[ pElement[ nId ] ]->GetBuffer() );
349 break;
350 case T_D:
351 pScToken->AddDouble( pP_Dbl[ pElement[ nId ] ] );
352 break;
353 case T_Err:
354 #if 0 // erAck
355 pScToken->AddError( pP_Err[ pElement[ nId ] ] );
356 #endif
357 break;
358 case T_RefC:
359 pScToken->AddSingleReference( *ppP_RefTr[ pElement[ (UINT16) nId ] ] );
360 break;
361 case T_RefA:
363 ScComplexRefData aScComplexRefData;
364 aScComplexRefData.Ref1 = *ppP_RefTr[ pElement[ nId ] ];
365 aScComplexRefData.Ref2 = *ppP_RefTr[ pElement[ nId ] + 1 ];
366 pScToken->AddDoubleReference( aScComplexRefData );
368 break;
369 case T_RN:
370 pScToken->AddName( pElement[ nId ] );
371 break;
372 case T_Ext:
374 UINT16 n = pElement[ nId ];
375 EXTCONT* p = ( n < nP_Ext )? ppP_Ext[ n ] : NULL;
377 if( p )
379 if( p->eId == ocEuroConvert )
380 pScToken->AddOpCode( p->eId );
381 else
382 pScToken->AddExternal( p->aText, p->eId );
385 break;
386 case T_Nlf:
388 UINT16 n = pElement[ nId ];
389 NLFCONT* p = ( n < nP_Nlf )? ppP_Nlf[ n ] : NULL;
391 if( p )
392 pScToken->AddColRowName( p->aRef );
394 break;
395 case T_Matrix:
397 UINT16 n = pElement[ nId ];
398 ScMatrix* p = ( n < nP_Matrix )? ppP_Matrix[ n ] : NULL;
400 if( p )
401 pScToken->AddMatrix( p );
403 break;
404 case T_ExtName:
406 UINT16 n = pElement[nId];
407 if (n < maExtNames.size())
409 const ExtName& r = maExtNames[n];
410 pScToken->AddExternalName(r.mnFileId, r.maName);
413 case T_ExtRefC:
415 UINT16 n = pElement[nId];
416 if (n < maExtCellRefs.size())
418 const ExtCellRef& r = maExtCellRefs[n];
419 pScToken->AddExternalSingleReference(r.mnFileId, r.maTabName, r.maRef);
422 case T_ExtRefA:
424 UINT16 n = pElement[nId];
425 if (n < maExtAreaRefs.size())
427 const ExtAreaRef& r = maExtAreaRefs[n];
428 pScToken->AddExternalDoubleReference(r.mnFileId, r.maTabName, r.maRef);
431 break;
432 default:
433 DBG_ERROR("-TokenPool::GetElement(): Zustand undefiniert!?");
439 void TokenPool::GetElementRek( const UINT16 nId )
441 #ifdef DBG_UTIL
442 nRek++;
443 DBG_ASSERT( nRek <= nP_Id, "*TokenPool::GetElement(): Rekursion loopt!?" );
444 #endif
446 DBG_ASSERT( nId < nElementAkt, "*TokenPool::GetElementRek(): Id zu gross!?" );
448 DBG_ASSERT( pType[ nId ] == T_Id, "-TokenPool::GetElementRek(): nId nicht Id-Folge!" );
451 UINT16 nAnz = pSize[ nId ];
452 UINT16* pAkt = &pP_Id[ pElement[ nId ] ];
453 for( ; nAnz > 0 ; nAnz--, pAkt++ )
455 if( *pAkt < nScTokenOff )
456 {// Rekursion oder nicht?
457 switch( pType[ *pAkt ] )
459 case T_Id:
460 GetElementRek( *pAkt );
461 break;
462 case T_Str:
463 pScToken->AddString( ppP_Str[ pElement[ *pAkt ] ]->GetBuffer() );
464 break;
465 case T_D:
466 pScToken->AddDouble( pP_Dbl[ pElement[ *pAkt ] ] );
467 break;
468 case T_Err:
469 #if 0 // erAck
470 pScToken->AddError( pP_Err[ pElement[ *pAkt ] ] );
471 #endif
472 break;
473 case T_RefC:
474 pScToken->AddSingleReference( *ppP_RefTr[ pElement[ *pAkt ] ] );
475 break;
476 case T_RefA:
478 ScComplexRefData aScComplexRefData;
479 aScComplexRefData.Ref1 = *ppP_RefTr[ pElement[ *pAkt ] ];
480 aScComplexRefData.Ref2 = *ppP_RefTr[ pElement[ *pAkt ] + 1 ];
481 pScToken->AddDoubleReference( aScComplexRefData );
483 break;
484 case T_RN:
485 pScToken->AddName( pElement[ *pAkt ] );
486 break;
487 case T_Ext:
489 UINT16 n = pElement[ *pAkt ];
490 EXTCONT* p = ( n < nP_Ext )? ppP_Ext[ n ] : NULL;
492 if( p )
493 pScToken->AddExternal( p->aText, p->eId );
495 break;
496 case T_Nlf:
498 UINT16 n = pElement[ *pAkt ];
499 NLFCONT* p = ( n < nP_Nlf )? ppP_Nlf[ n ] : NULL;
501 if( p )
502 pScToken->AddColRowName( p->aRef );
504 break;
505 case T_Matrix:
507 UINT16 n = pElement[ *pAkt ];
508 ScMatrix* p = ( n < nP_Matrix )? ppP_Matrix[ n ] : NULL;
510 if( p )
511 pScToken->AddMatrix( p );
513 break;
514 case T_ExtName:
516 UINT16 n = pElement[*pAkt];
517 if (n < maExtNames.size())
519 const ExtName& r = maExtNames[n];
520 pScToken->AddExternalName(r.mnFileId, r.maName);
523 case T_ExtRefC:
525 UINT16 n = pElement[*pAkt];
526 if (n < maExtCellRefs.size())
528 const ExtCellRef& r = maExtCellRefs[n];
529 pScToken->AddExternalSingleReference(r.mnFileId, r.maTabName, r.maRef);
532 case T_ExtRefA:
534 UINT16 n = pElement[*pAkt];
535 if (n < maExtAreaRefs.size())
537 const ExtAreaRef& r = maExtAreaRefs[n];
538 pScToken->AddExternalDoubleReference(r.mnFileId, r.maTabName, r.maRef);
541 break;
542 default:
543 DBG_ERROR("-TokenPool::GetElementRek(): Zustand undefiniert!?");
546 else // elementarer SC_Token
547 pScToken->AddOpCode( ( DefTokenId ) ( *pAkt - nScTokenOff ) );
551 #ifdef DBG_UTIL
552 nRek--;
553 #endif
557 void TokenPool::operator >>( TokenId& rId )
559 rId = ( TokenId ) ( nElementAkt + 1 );
561 if( nElementAkt >= nElement )
562 GrowElement();
564 pElement[ nElementAkt ] = nP_IdLast; // Start der Token-Folge
565 pType[ nElementAkt ] = T_Id; // Typinfo eintragen
566 pSize[ nElementAkt ] = nP_IdAkt - nP_IdLast;
567 // von nP_IdLast bis nP_IdAkt-1 geschrieben -> Laenge der Folge
569 nElementAkt++; // Startwerte fuer naechste Folge
570 nP_IdLast = nP_IdAkt;
574 const TokenId TokenPool::Store( const double& rDouble )
576 if( nElementAkt >= nElement )
577 GrowElement();
579 if( nP_DblAkt >= nP_Dbl )
580 GrowDouble();
582 pElement[ nElementAkt ] = nP_DblAkt; // Index in Double-Array
583 pType[ nElementAkt ] = T_D; // Typinfo Double eintragen
585 pP_Dbl[ nP_DblAkt ] = rDouble;
587 pSize[ nElementAkt ] = 1; // eigentlich Banane
589 nElementAkt++;
590 nP_DblAkt++;
592 return ( const TokenId ) nElementAkt; // Ausgabe von altem Wert + 1!
596 const TokenId TokenPool::Store( const UINT16 nIndex )
598 if( nElementAkt >= nElement )
599 GrowElement();
601 pElement[ nElementAkt ] = nIndex; // Daten direkt im Index!
602 pType[ nElementAkt ] = T_RN; // Typinfo Range Name eintragen
604 nElementAkt++;
605 return ( const TokenId ) nElementAkt; // Ausgabe von altem Wert + 1!
609 const TokenId TokenPool::Store( const String& rString )
611 // weitgehend nach Store( const sal_Char* ) kopiert, zur Vermeidung
612 // eines temporaeren Strings in "
613 if( nElementAkt >= nElement )
614 GrowElement();
616 if( nP_StrAkt >= nP_Str )
617 GrowString();
619 pElement[ nElementAkt ] = nP_StrAkt; // Index in String-Array
620 pType[ nElementAkt ] = T_Str; // Typinfo String eintragen
622 // String anlegen
623 if( !ppP_Str[ nP_StrAkt ] )
624 //...aber nur, wenn noch nicht vorhanden
625 ppP_Str[ nP_StrAkt ] = new String( rString );
626 else
627 //...ansonsten nur kopieren
628 *ppP_Str[ nP_StrAkt ] = rString;
630 DBG_ASSERT( sizeof( xub_StrLen ) <= 2, "*TokenPool::Store(): StrLen doesn't match!" );
632 pSize[ nElementAkt ] = ( UINT16 ) ppP_Str[ nP_StrAkt ]->Len();
634 nElementAkt++;
635 nP_StrAkt++;
637 return ( const TokenId ) nElementAkt; // Ausgabe von altem Wert + 1!
641 const TokenId TokenPool::Store( const ScSingleRefData& rTr )
643 if( nElementAkt >= nElement )
644 GrowElement();
646 if( nP_RefTrAkt >= nP_RefTr )
647 GrowTripel();
649 pElement[ nElementAkt ] = nP_RefTrAkt;
650 pType[ nElementAkt ] = T_RefC; // Typinfo Cell-Reff eintragen
652 if( !ppP_RefTr[ nP_RefTrAkt ] )
653 ppP_RefTr[ nP_RefTrAkt ] = new ScSingleRefData( rTr );
654 else
655 *ppP_RefTr[ nP_RefTrAkt ] = rTr;
657 nElementAkt++;
658 nP_RefTrAkt++;
660 return ( const TokenId ) nElementAkt; // Ausgabe von altem Wert + 1!
664 const TokenId TokenPool::Store( const ScComplexRefData& rTr )
666 if( nElementAkt >= nElement )
667 GrowElement();
669 if( nP_RefTrAkt + 1 >= nP_RefTr )
670 GrowTripel();
672 pElement[ nElementAkt ] = nP_RefTrAkt;
673 pType[ nElementAkt ] = T_RefA; // Typinfo Area-Reff eintragen
675 if( !ppP_RefTr[ nP_RefTrAkt ] )
676 ppP_RefTr[ nP_RefTrAkt ] = new ScSingleRefData( rTr.Ref1 );
677 else
678 *ppP_RefTr[ nP_RefTrAkt ] = rTr.Ref1;
679 nP_RefTrAkt++;
681 if( !ppP_RefTr[ nP_RefTrAkt ] )
682 ppP_RefTr[ nP_RefTrAkt ] = new ScSingleRefData( rTr.Ref2 );
683 else
684 *ppP_RefTr[ nP_RefTrAkt ] = rTr.Ref2;
685 nP_RefTrAkt++;
687 nElementAkt++;
689 return ( const TokenId ) nElementAkt; // Ausgabe von altem Wert + 1!
693 const TokenId TokenPool::Store( const DefTokenId e, const String& r )
695 if( nElementAkt >= nElement )
696 GrowElement();
698 if( nP_ExtAkt >= nP_Ext )
699 GrowExt();
701 pElement[ nElementAkt ] = nP_ExtAkt;
702 pType[ nElementAkt ] = T_Ext; // Typinfo String eintragen
704 if( ppP_Ext[ nP_ExtAkt ] )
706 ppP_Ext[ nP_ExtAkt ]->eId = e;
707 ppP_Ext[ nP_ExtAkt ]->aText = r;
709 else
710 ppP_Ext[ nP_ExtAkt ] = new EXTCONT( e, r );
712 nElementAkt++;
713 nP_ExtAkt++;
715 return ( const TokenId ) nElementAkt; // Ausgabe von altem Wert + 1!
719 const TokenId TokenPool::StoreNlf( const ScSingleRefData& rTr )
721 if( nElementAkt >= nElement )
722 GrowElement();
724 if( nP_NlfAkt >= nP_Nlf )
725 GrowNlf();
727 pElement[ nElementAkt ] = nP_NlfAkt;
728 pType[ nElementAkt ] = T_Nlf;
730 if( ppP_Nlf[ nP_NlfAkt ] )
732 ppP_Nlf[ nP_NlfAkt ]->aRef = rTr;
734 else
735 ppP_Nlf[ nP_NlfAkt ] = new NLFCONT( rTr );
737 nElementAkt++;
738 nP_NlfAkt++;
740 return ( const TokenId ) nElementAkt;
743 const TokenId TokenPool::StoreMatrix( SCSIZE nC, SCSIZE nR )
745 ScMatrix* pM;
747 if( nElementAkt >= nElement )
748 GrowElement();
750 if( nP_MatrixAkt >= nP_Matrix )
751 GrowMatrix();
753 pElement[ nElementAkt ] = nP_MatrixAkt;
754 pType[ nElementAkt ] = T_Matrix;
756 pM = new ScMatrix( nC, nR );
757 pM->FillDouble( 0., 0,0, nC-1, nR-1 );
758 pM->IncRef( );
759 ppP_Matrix[ nP_MatrixAkt ] = pM;
761 nElementAkt++;
762 nP_MatrixAkt++;
764 return ( const TokenId ) nElementAkt;
767 const TokenId TokenPool::StoreExtName( sal_uInt16 nFileId, const String& rName )
769 if ( nElementAkt >= nElement )
770 GrowElement();
772 pElement[nElementAkt] = static_cast<UINT16>(maExtNames.size());
773 pType[nElementAkt] = T_ExtName;
775 maExtNames.push_back(ExtName());
776 ExtName& r = maExtNames.back();
777 r.mnFileId = nFileId;
778 r.maName = rName;
780 ++nElementAkt;
782 return static_cast<const TokenId>(nElementAkt);
785 const TokenId TokenPool::StoreExtRef( sal_uInt16 nFileId, const String& rTabName, const ScSingleRefData& rRef )
787 if ( nElementAkt >= nElement )
788 GrowElement();
790 pElement[nElementAkt] = static_cast<UINT16>(maExtCellRefs.size());
791 pType[nElementAkt] = T_ExtRefC;
793 maExtCellRefs.push_back(ExtCellRef());
794 ExtCellRef& r = maExtCellRefs.back();
795 r.mnFileId = nFileId;
796 r.maTabName = rTabName;
797 r.maRef = rRef;
799 ++nElementAkt;
801 return static_cast<const TokenId>(nElementAkt);
804 const TokenId TokenPool::StoreExtRef( sal_uInt16 nFileId, const String& rTabName, const ScComplexRefData& rRef )
806 if ( nElementAkt >= nElement )
807 GrowElement();
809 pElement[nElementAkt] = static_cast<UINT16>(maExtAreaRefs.size());
810 pType[nElementAkt] = T_ExtRefA;
812 maExtAreaRefs.push_back(ExtAreaRef());
813 ExtAreaRef& r = maExtAreaRefs.back();
814 r.mnFileId = nFileId;
815 r.maTabName = rTabName;
816 r.maRef = rRef;
818 ++nElementAkt;
820 return static_cast<const TokenId>(nElementAkt);
823 void TokenPool::Reset( void )
825 nP_IdAkt = nP_IdLast = nElementAkt = nP_StrAkt = nP_DblAkt = nP_ErrAkt = nP_RefTrAkt = nP_ExtAkt = nP_NlfAkt = nP_MatrixAkt = 0;
826 maExtNames.clear();
827 maExtCellRefs.clear();
828 maExtAreaRefs.clear();
832 BOOL TokenPool::IsSingleOp( const TokenId& rId, const DefTokenId eId ) const
834 UINT16 nId = (UINT16) rId;
835 if( nId && nId <= nElementAkt )
836 {// existent?
837 nId--;
838 if( T_Id == pType[ nId ] )
839 {// Tokenfolge?
840 if( pSize[ nId ] == 1 )
841 {// GENAU 1 Token
842 UINT16 nSecId = pP_Id[ pElement[ nId ] ];
843 if( nSecId >= nScTokenOff )
844 {// Default-Token?
845 return ( DefTokenId ) ( nSecId - nScTokenOff ) == eId; // Gesuchter?
851 return FALSE;
855 const String* TokenPool::GetExternal( const TokenId& rId ) const
857 const String* p = NULL;
858 UINT16 n = (UINT16) rId;
859 if( n && n <= nElementAkt )
861 n--;
862 if( (pType[ n ] == T_Ext) && ppP_Ext[ pElement[ n ] ] )
863 p = &ppP_Ext[ pElement[ n ] ]->aText;
866 return p;
870 //UNUSED2008-05 const String* TokenPool::GetString( const TokenId& r ) const
871 //UNUSED2008-05 {
872 //UNUSED2008-05 const String* p = NULL;
873 //UNUSED2008-05 UINT16 n = (UINT16) r;
874 //UNUSED2008-05 if( n && n <= nElementAkt )
875 //UNUSED2008-05 {
876 //UNUSED2008-05 n--;
877 //UNUSED2008-05 if( pType[ n ] == T_Str )
878 //UNUSED2008-05 p = ppP_Str[ pElement[ n ] ];
879 //UNUSED2008-05 }
880 //UNUSED2008-05
881 //UNUSED2008-05 return p;
882 //UNUSED2008-05 }
884 ScMatrix* TokenPool::GetMatrix( unsigned int n ) const
886 if( n < nP_MatrixAkt )
887 return ppP_Matrix[ n ];
888 else
889 printf ("GETMATRIX %d >= %d\n", n, nP_MatrixAkt);
890 return NULL;