bump product version to 5.0.4.1
[LibreOffice.git] / rsc / source / res / rscclass.cxx
blob7d7861b607de34d97cbf4901226ebb9410545c7c
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <stdlib.h>
22 #include <stdio.h>
23 #include <string.h>
25 #include <rscdb.hxx>
26 #include <rscclass.hxx>
28 #include <tools/rcid.h>
29 #include <tools/rc.h>
31 RscClass::RscClass( Atom nId, sal_uInt32 nTypeId, RscTop * pSuperCl )
32 : RscTop( nId, nTypeId, pSuperCl )
34 nEntries = 0;
35 pVarTypeList = NULL;
36 nSuperSize = RscTop::Size();
37 nSize = nSuperSize + ALIGNED_SIZE( sizeof( RscClassInst ) );
40 void RscClass::Pre_dtor()
42 sal_uInt32 i;
44 RscTop::Pre_dtor();
46 for( i = 0; i < nEntries; i++ )
48 if( pVarTypeList[ i ].pDefault )
50 pVarTypeList[ i ].pClass->Destroy(
51 RSCINST( pVarTypeList[ i ].pClass,
52 pVarTypeList[ i ].pDefault ) );
53 rtl_freeMemory( pVarTypeList[ i ].pDefault );
54 pVarTypeList[ i ].pDefault = NULL;
59 RscClass::~RscClass()
61 if( pVarTypeList )
62 rtl_freeMemory( (void *)pVarTypeList );
65 RSCCLASS_TYPE RscClass::GetClassType() const
67 return RSCCLASS_COMPLEX;
70 RSCINST RscClass::GetInstData
72 CLASS_DATA pData,
73 sal_uInt32 nEle,
74 bool bGetCopy
77 RSCINST aInst;
79 aInst.pClass = pVarTypeList[ nEle ].pClass;
80 if( pData )
82 if( VAR_NODATAINST & pVarTypeList[ nEle ].nVarType )
84 RSCINST aTmpI;
86 aTmpI.pClass = this;
87 aTmpI.pData = pData;
88 if( bGetCopy )
89 aInst.pData = GetCopyVar(
90 aTmpI,
91 pVarTypeList[ nEle ].nDataBaseName
92 ).pData;
93 else
94 aInst.pData = GetVariable(
95 aTmpI,
96 pVarTypeList[ nEle ].nDataBaseName,
97 RSCINST()
98 ).pData;
100 else if( VAR_POINTER & pVarTypeList[ nEle ].nVarType )
102 if( VAR_EXTENDABLE & pVarTypeList[ nEle ].nVarType )
103 aInst = *reinterpret_cast<RSCINST *>(pData + pVarTypeList[ nEle ].nOffset);
104 else
105 aInst.pData = *reinterpret_cast<CLASS_DATA *>(pData + pVarTypeList[ nEle ].nOffset);
107 else
108 aInst.pData = pData + pVarTypeList[ nEle ].nOffset;
110 return aInst;
113 CLASS_DATA RscClass::GetDfltData( sal_uInt32 nEle )
115 if( pVarTypeList[ nEle ].pDefault )
116 return pVarTypeList[ nEle ].pDefault;
118 return pVarTypeList[ nEle ].pClass->GetDefault().pData;
121 void RscClass::SetVarDflt( CLASS_DATA pData, sal_uInt32 nEle, bool bSet )
123 RscClassInst * pClass;
125 pClass = reinterpret_cast<RscClassInst *>(pData + nSuperSize );
126 if( bSet )
127 pClass->nVarDflt |= ((sal_uLong)1 << nEle);
128 else
129 pClass->nVarDflt &= ~((sal_uLong)1 << nEle);
132 bool RscClass::IsDflt( CLASS_DATA pData, sal_uInt32 nEle )
134 RscClassInst * pClass;
136 pClass = reinterpret_cast<RscClassInst *>(pData + nSuperSize );
137 return pClass->nVarDflt & ((sal_uLong)1 << nEle);
140 RSCINST RscClass::Create( RSCINST * pInst,
141 const RSCINST & rDflt,
142 bool bOwnClass)
144 sal_uInt32 i;
145 RSCINST aInst;
146 RSCINST aMemInst, aDfltI;
148 if( !pInst )
150 aInst.pClass = this;
151 aInst.pData = static_cast<CLASS_DATA>(rtl_allocateMemory( Size() ));
153 else
154 aInst = *pInst;
156 if( !bOwnClass && rDflt.IsInst() )
157 bOwnClass = rDflt.pClass->InHierarchy( this );
159 RscTop::Create( &aInst, rDflt, bOwnClass );
161 if( bOwnClass )
162 reinterpret_cast<RscClassInst *>(aInst.pData + nSuperSize)->nVarDflt =
163 reinterpret_cast<RscClassInst *>(rDflt.pData + nSuperSize)->nVarDflt;
164 else
165 reinterpret_cast<RscClassInst *>(aInst.pData + nSuperSize)->nVarDflt = ~((sal_uLong)0);
167 for( i = 0; i < nEntries; i++ )
169 aDfltI = GetInstData( bOwnClass ? rDflt.pData : NULL, i, true );
171 if( (VAR_POINTER & pVarTypeList[ i ].nVarType) &&
172 !(VAR_NODATAINST & pVarTypeList[ i ].nVarType) )
174 CLASS_DATA * ppData;
175 if( VAR_EXTENDABLE & pVarTypeList[ i ].nVarType )
177 RSCINST * pInstance = reinterpret_cast<RSCINST *>(aInst.pData + pVarTypeList[ i ].nOffset );
178 pInstance->pClass = pVarTypeList[ i ].pClass;
179 ppData = &pInstance->pData;
181 else
182 ppData = reinterpret_cast<CLASS_DATA*>(aInst.pData + pVarTypeList[ i ].nOffset );
184 *ppData = NULL;
185 if( aDfltI.IsInst() )
187 aMemInst = pVarTypeList[ i ].pClass->Create( NULL, aDfltI );
188 *ppData = aMemInst.pData;
191 else
193 aMemInst = GetInstData( aInst.pData, i, true );
194 aMemInst = aMemInst.pClass->Create( &aMemInst, aDfltI );
198 return aInst;
201 void RscClass::Destroy( const RSCINST & rInst )
203 sal_uInt32 i;
205 RscTop::Destroy( rInst );
207 for( i = 0; i < nEntries; i++ )
209 if( !(pVarTypeList[ i ].nVarType & VAR_NODATAINST) )
211 RSCINST aTmpI;
213 aTmpI = GetInstData( rInst.pData, i, true );
214 if( aTmpI.IsInst() )
216 // Objekt loeschen
217 aTmpI.pClass->Destroy( aTmpI );
218 if( pVarTypeList[ i ].nVarType & VAR_POINTER )
220 // Speicher freigeben
221 rtl_freeMemory( aTmpI.pData );
228 ERRTYPE RscClass::SetVariable( Atom nVarName,
229 RscTop * pClass,
230 RSCINST * pDflt,
231 RSCVAR nVarType,
232 sal_uInt32 nMask,
233 Atom nDataBaseName)
235 if( pVarTypeList )
237 pVarTypeList = static_cast<VARTYPE_STRUCT *>(rtl_reallocateMemory( (void *)pVarTypeList,
238 ((nEntries +1) * sizeof( VARTYPE_STRUCT )) ));
240 else
242 pVarTypeList = static_cast<VARTYPE_STRUCT *>(rtl_allocateMemory( ((nEntries +1)
243 * sizeof( VARTYPE_STRUCT )) ));
245 pVarTypeList[ nEntries ].nVarName = nVarName;
246 pVarTypeList[ nEntries ].nMask = nMask;
247 pVarTypeList[ nEntries ].pClass = pClass;
248 pVarTypeList[ nEntries ].nOffset = nSize;
249 pVarTypeList[ nEntries ].nDataBaseName = nDataBaseName;
250 if( pDflt )
251 pVarTypeList[ nEntries ].pDefault = pDflt->pData;
252 else
253 pVarTypeList[ nEntries ].pDefault = NULL;
255 pVarTypeList[ nEntries ].nVarType = ~VAR_POINTER & nVarType;
256 if( pClass->Size() > 10 || (nVarType & VAR_EXTENDABLE) )
257 pVarTypeList[ nEntries ].nVarType |= VAR_POINTER;
259 if( !(pVarTypeList[ nEntries ].nVarType & VAR_NODATAINST) )
261 if( pVarTypeList[ nEntries ].nVarType & VAR_POINTER )
263 if( pVarTypeList[ nEntries ].nVarType & VAR_EXTENDABLE )
264 nSize += sizeof( RSCINST );
265 else
266 nSize += sizeof( CLASS_DATA );
268 else
269 nSize += pClass->Size();
272 nEntries++;
273 if( nEntries > (sizeof( sal_uLong ) * 8) )
275 // Bereich fuer Default zu klein
276 RscExit( 16 );
278 return ERR_OK;
281 void RscClass::EnumVariables( void * pData, VarEnumCallbackProc pProc )
283 sal_uInt32 i;
285 RscTop::EnumVariables( pData, pProc );
286 for( i = 0; i < nEntries; i ++ )
288 if( !(pVarTypeList[ i ].nVarType & VAR_NOENUM) )
289 (*pProc)( pData, pVarTypeList[ i ].pClass->GetClassType(), pVarTypeList[ i ].nVarName );
293 RSCINST RscClass::GetVariable( const RSCINST & rInst,
294 Atom nVarName,
295 const RSCINST & rInitInst,
296 bool bInitDflt,
297 RscTop * pCreateClass)
299 sal_uInt32 i = 0;
300 RSCINST aTmpI;
302 while( i < nEntries && pVarTypeList[ i ].nVarName != nVarName )
303 i++;
305 if( i < nEntries )
307 if( VAR_NODATAINST & pVarTypeList[ i ].nVarType )
309 aTmpI = GetVariable( rInst,
310 pVarTypeList[ i ].nDataBaseName,
311 RSCINST() );
312 aTmpI.pClass = pVarTypeList[ i ].pClass;
314 else
316 // Default Instanz generieren
317 RSCINST aDefInst = rInitInst;
318 if( !aDefInst.IsInst() && bInitDflt )
320 // mit dem Variablen-Default besetzen
321 aDefInst.pData = pVarTypeList[ i ].pDefault;
322 aDefInst.pClass = pVarTypeList[ i ].pClass;
325 aTmpI = GetInstData( rInst.pData, i );
326 if( aTmpI.IsInst() )
328 if( aDefInst.IsInst() )
330 aTmpI.pClass->Destroy( aTmpI );
331 aTmpI.pClass->Create( &aTmpI, aDefInst );
334 else
335 { // Wird ueber Zeiger angegeben
336 if( VAR_EXTENDABLE & pVarTypeList[ i ].nVarType )
338 RSCINST * pInst = reinterpret_cast<RSCINST *>
339 (rInst.pData + pVarTypeList[ i ].nOffset );
340 if( pCreateClass && pCreateClass->InHierarchy( aTmpI.pClass ) )
341 *pInst = pCreateClass->Create( NULL, aDefInst );
342 else
343 *pInst = aTmpI.pClass->Create( NULL, aDefInst );
344 aTmpI = *pInst;
346 else
348 CLASS_DATA * ppData
349 = reinterpret_cast<CLASS_DATA *>(rInst.pData + pVarTypeList[ i ].nOffset);
350 aTmpI = aTmpI.pClass->Create( NULL, aDefInst );
351 *ppData = aTmpI.pData;
355 // auf nicht Default setzen
356 SetVarDflt( rInst.pData, i, false );
357 return aTmpI;
360 return RscTop::GetVariable( rInst, nVarName, rInitInst,
361 bInitDflt, pCreateClass );
364 RSCINST RscClass::GetCopyVar( const RSCINST & rInst, Atom nVarName)
366 sal_uInt32 i = 0;
367 RSCINST aVarI;
369 while( i < nEntries && pVarTypeList[ i ].nVarName != nVarName )
370 i++;
372 if( i < nEntries )
374 if( VAR_NODATAINST & pVarTypeList[ i ].nVarType )
376 aVarI = GetCopyVar( rInst, pVarTypeList[ i ].nDataBaseName );
377 aVarI.pClass = pVarTypeList[ i ].pClass;
379 else
381 if( IsDflt( rInst.pData, i ) )
383 // mit Variablen Default initialiaieren
384 aVarI = GetVariable( rInst, nVarName, RSCINST(), true );
385 SetVarDflt( rInst.pData, i, true );
387 else
388 aVarI = GetInstData( rInst.pData, i, true );
391 return aVarI ;
394 return RscTop::GetCopyVar( rInst, nVarName );
397 bool RscClass::IsConsistent( const RSCINST & rInst )
399 sal_uInt32 i = 0;
400 RSCINST aTmpI;
401 bool bRet;
403 bRet = RscTop::IsConsistent( rInst );
405 for( i = 0; i < nEntries; i++ )
407 if( !(VAR_NODATAINST & pVarTypeList[ i ].nVarType) )
409 aTmpI = GetInstData( rInst.pData, i, true );
411 if( aTmpI.IsInst() )
412 if( ! aTmpI.pClass->IsConsistent( aTmpI ) )
413 bRet = false;
417 return bRet;
420 void RscClass::SetToDefault( const RSCINST & rInst )
422 sal_uInt32 i;
423 RSCINST aTmpI;
424 RscClassInst * pClass;
426 pClass = reinterpret_cast<RscClassInst *>(rInst.pData + nSuperSize );
428 for( i = 0; i < nEntries; i++ )
430 // Variablen ohne eigenen Speicher werden vom "Datenserver"
431 // auf Default gesetzt
432 if( !(VAR_NODATAINST & pVarTypeList[ i ].nVarType) )
434 aTmpI = GetInstData( rInst.pData, i, true );
435 if( aTmpI.IsInst() )
436 aTmpI.pClass->SetToDefault( aTmpI );
439 pClass->nVarDflt = ~((sal_uLong)0); // alles auf Default
441 RscTop::SetToDefault( rInst );
444 bool RscClass::IsDefault( const RSCINST & rInst )
446 sal_uInt32 i;
447 RSCINST aTmpI;
449 for( i = 0; i < nEntries; i++ )
451 // Variablen ohne eigenen Speicher werden vom "Datenserver"
452 // auf Default untersucht
453 if( !(VAR_NODATAINST & pVarTypeList[ i ].nVarType) )
454 if( !IsDflt( rInst.pData, i ) )
455 return false;
458 return RscTop::IsDefault( rInst );
461 RSCINST RscClass::GetDefault( Atom nVarId )
463 sal_uInt32 i;
465 i = 0;
466 while( i < nEntries && pVarTypeList[ i ].nVarName != nVarId )
467 i++;
469 if( i < nEntries )
471 RSCINST aTmpI;
473 aTmpI.pClass = pVarTypeList[ i ].pClass;
474 aTmpI.pData = GetDfltData( i );
475 return aTmpI;
478 return RscTop::GetDefault( nVarId );
481 bool RscClass::IsValueDflt( CLASS_DATA pData, sal_uInt32 nEle )
483 RSCINST aTmpI;
485 aTmpI = GetInstData( pData, nEle, true );
487 if( aTmpI.IsInst() )
489 if( VAR_SVDYNAMIC & pVarTypeList[ nEle ].nVarType )
490 return false;
492 if( aTmpI.pClass == pVarTypeList[ nEle ].pClass )
493 //sie haben auch die gleiche Klasse
494 return aTmpI.pClass->IsValueDefault( aTmpI, GetDfltData( nEle ) );
495 else
496 return false;
498 return true;
501 bool RscClass::IsValueDefault( const RSCINST & rInst, CLASS_DATA pDef )
503 RSCINST aTmpI;
504 RSCINST aDfltI;
506 if( !RscTop::IsValueDefault( rInst, pDef ) )
507 return false;
509 if( pDef )
511 for( sal_uInt32 i = 0; i < nEntries; i++ )
513 aTmpI = GetInstData( rInst.pData, i, true );
514 if( aTmpI.IsInst() )
516 if( aTmpI.pClass != pVarTypeList[ i ].pClass )
517 //sie haben nicht die gleiche Klasse
518 return false;
520 aDfltI = GetInstData( pDef, i, true );
521 if( !aDfltI.IsInst() )
522 aDfltI.pData = GetDfltData( i );
524 if( !aTmpI.pClass->IsValueDefault( aTmpI, aDfltI.pData ) )
525 return false;
529 else
530 return false;
532 return true;
535 void RscClass::SetDefault( const RSCINST & rInst, Atom nVarName )
537 sal_uInt32 i = 0;
538 RSCINST aTmpI;
540 while( i < nEntries && pVarTypeList[ i ].nVarName != nVarName )
541 i++;
543 if( i < nEntries )
545 aTmpI = GetInstData( rInst.pData, i, true );
546 if( aTmpI.IsInst() )
548 aTmpI.pClass->Destroy( aTmpI );
549 aTmpI.pClass->Create( &aTmpI, RSCINST() );
550 SetVarDflt( rInst.pData, i, true );
553 else //In Superklasse nach Variable suchen
554 RscTop::SetDefault( rInst, nVarName );
559 void RscClass::WriteSrc( const RSCINST & rInst,
560 FILE * fOutput,
561 RscTypCont * pTC,
562 sal_uInt32 nTab,
563 const char * pVarName)
565 sal_uInt32 i = 0, n = 0;
566 RSCINST aTmpI;
568 RscTop::WriteSrc( rInst, fOutput, pTC, nTab, pVarName );
570 for( i = 0; i < nEntries; i++ )
572 if( !(VAR_HIDDEN & pVarTypeList[ i ].nVarType) )
574 // Hack wegen Position und Dimensiuon
575 if( nRsc_XYMAPMODEId == pVarTypeList[ i ].nVarName ||
576 nRsc_WHMAPMODEId == pVarTypeList[ i ].nVarName )
578 if( !IsDflt( rInst.pData, i ) || // MapUnit
579 !IsDflt( rInst.pData, i+1 ) || //X, Width
580 !IsDflt( rInst.pData, i+2 ) ) //Y, Height
582 // ein Wert ist nicht Default
583 for( n = 0; n < nTab; n++ )
584 fputc( '\t', fOutput );
586 if( nRsc_XYMAPMODEId == pVarTypeList[ i ].nVarName )
587 fprintf( fOutput, "Pos = " );
588 else
589 fprintf( fOutput, "Size = " );
591 if( !IsDflt( rInst.pData, i ) )
593 aTmpI = GetInstData( rInst.pData, i, true );
594 aTmpI.pClass->WriteSrcHeader(
595 aTmpI, fOutput, pTC, nTab, RscId(), pVarName );
598 fprintf( fOutput, "( " );
599 aTmpI = GetInstData( rInst.pData, i+1, true );
600 if( !aTmpI.IsInst() )
601 aTmpI.pData = GetDfltData( i+1 );
603 aTmpI.pClass->WriteSrcHeader( aTmpI, fOutput, pTC, nTab, RscId(), pVarName );
605 fprintf( fOutput, ", " );
606 aTmpI = GetInstData( rInst.pData, i+2, true );
608 if( !aTmpI.IsInst() )
609 aTmpI.pData = GetDfltData( i+2 );
611 aTmpI.pClass->WriteSrcHeader(
612 aTmpI, fOutput, pTC, nTab, RscId(), pVarName );
613 fprintf( fOutput, " );\n" );
615 i += 2; //_X, _Y oder _Width, Height ueberlesen
617 else if( !IsDflt( rInst.pData, i )
618 && !IsValueDflt( rInst.pData, i ) )
620 aTmpI = GetInstData( rInst.pData, i, true );
622 if( aTmpI.IsInst() )
624 const char * pName = pHS->getString( pVarTypeList[ i ].nVarName ).getStr();
626 for( n = 0; n < nTab; n++ )
627 fputc( '\t', fOutput );
629 fprintf( fOutput, "%s", pName );
630 fprintf( fOutput, " = " );
631 aTmpI.pClass->WriteSrcHeader(
632 aTmpI, fOutput, pTC, nTab, RscId(), pName );
633 fprintf( fOutput, ";\n" );
639 return;
642 sal_Int32 RscClass::GetCorrectValues( const RSCINST & rInst,
643 sal_uInt32 nVarPos,
644 sal_uInt32 nTupelIdx,
645 RscTypCont * pTC)
647 sal_Int32 nLang = 0;
648 sal_Int32 nBaseValue;
650 // Basiswert holen
651 RSCINST aTmpI = GetInstData( rInst.pData, nVarPos, true );
652 aTmpI.pClass->GetNumber( aTmpI, &nBaseValue );
654 // Sprach Delta holen
655 aTmpI = rInst.pClass->GetVariable( rInst, nRsc_DELTALANG, RSCINST() );
656 if( aTmpI.IsInst() )
658 RscWriteRc aMem;
659 aTmpI.pClass->WriteRc( aTmpI, aMem, pTC, 0, false );
660 nLang = (sal_Int32)aMem.GetShort( nTupelIdx * sizeof(sal_uInt16) );
663 return nLang + nBaseValue;
666 ERRTYPE RscClass::WriteInstRc( const RSCINST & rInst,
667 RscWriteRc & rMem,
668 RscTypCont * pTC,
669 sal_uInt32 nDeep,
670 bool bExtra)
672 sal_uInt32 i = 0;
673 ERRTYPE aError;
674 RSCINST aTmpI;
675 sal_uInt32 nMaskOff = 0;// Offset um Maskenfeld zu addressieren
677 // Wenn eine Variable Maskierung hat, dann Maskenfeld
678 for( i = 0; i < nEntries; i++ )
680 if( pVarTypeList[ i ].nMask )
682 nMaskOff = rMem.Size();
683 rMem.Put( sal_uInt32(0) );
684 break;
688 for( i = 0; i < nEntries && aError.IsOk(); i++ )
690 if( !((VAR_NODATAINST | VAR_NORC) & pVarTypeList[ i ].nVarType ))
692 if( pVarTypeList[ i ].nMask )
694 if( !IsDflt( rInst.pData, i ) )
696 if( nRsc_X == pVarTypeList[ i ].nVarName )
698 sal_Int32 nVal = GetCorrectValues( rInst, i, 0, pTC );
699 rMem.Put( nVal );
701 else if( nRsc_Y == pVarTypeList[ i ].nVarName )
703 sal_Int32 nVal = GetCorrectValues( rInst, i, 1, pTC );
704 rMem.Put( nVal );
706 else if( nRsc_WIDTH == pVarTypeList[ i ].nVarName )
708 sal_Int32 nVal = GetCorrectValues( rInst, i, 2, pTC );
709 rMem.Put( nVal );
711 else if( nRsc_HEIGHT == pVarTypeList[ i ].nVarName )
713 sal_Int32 nVal = GetCorrectValues( rInst, i, 3, pTC );
714 rMem.Put( nVal );
716 else
718 aTmpI = GetInstData( rInst.pData, i, true );
719 // Nur an Variable Extradata bExtra nicht auf false
720 // setzen
721 aError = aTmpI.pClass->
722 WriteRcHeader( aTmpI, rMem, pTC,
723 RscId(), nDeep,
724 (nRsc_EXTRADATA == pVarTypeList[ i ].nVarName) && bExtra );
726 sal_uInt32 nMask = rMem.GetLong( nMaskOff );
727 nMask |= pVarTypeList[ i ].nMask;
728 rMem.PutAt( nMaskOff, nMask );
731 else
733 if( IsDflt( rInst.pData, i ) )
735 aTmpI.pClass = pVarTypeList[ i ].pClass;
736 aTmpI.pData = GetDfltData( i );
738 else
739 aTmpI = GetInstData( rInst.pData, i, true );
741 // Nur an Variable Extradata bExtra nicht auf false
742 // setzen
743 aError = aTmpI.pClass->
744 WriteRcHeader( aTmpI, rMem, pTC,
745 RscId(), nDeep,
746 (nRsc_EXTRADATA == pVarTypeList[ i ].nVarName) && bExtra );
751 return aError;
754 ERRTYPE RscClass::WriteRc( const RSCINST & rInst,
755 RscWriteRc & rMem,
756 RscTypCont * pTC,
757 sal_uInt32 nDeep,
758 bool bExtra)
760 ERRTYPE aError;
762 aError = RscTop::WriteRc( rInst, rMem, pTC, nDeep, bExtra );
763 if( aError.IsOk() )
764 aError = WriteInstRc( rInst, rMem, pTC, nDeep, bExtra );
766 return aError;
769 RscSysDepend::RscSysDepend( Atom nId, sal_uInt32 nTypeId, RscTop * pSuper )
770 : RscClass( nId, nTypeId, pSuper )
774 ERRTYPE RscSysDepend::WriteSysDependRc( const RSCINST & rInst, RscWriteRc & rMem,
775 RscTypCont * pTC, sal_uInt32 nDeep, bool bExtra, bool bFirst )
777 ERRTYPE aError;
778 RSCINST aFileName;
780 //Instanz mit dem Dateinamen "FILENAME" holen
781 aFileName = RscClass::GetCopyVar( rInst, pHS->getID( "FILE", true ) );
782 if( aFileName.IsInst() )
784 RscWriteRc aTmpMem;
785 aError = aFileName.pClass->WriteRcHeader( aFileName, aTmpMem, pTC,
786 RscId(), nDeep, bExtra );
787 // Obsolete - need changes in VCL
788 rMem.Put( sal_uInt32(0) );
790 // Identifier schreiben
791 sal_uInt32 nId = 0xFFFFFFFF;
792 if( aTmpMem.Size() && pTC && (*aTmpMem.GetUTF8( 0 ) != '\0') )
794 nId = pTC->PutSysName( rInst.pClass->GetTypId(),
795 aTmpMem.GetUTF8( 0 ),
796 0, 0, bFirst );
798 rMem.Put( nId );
799 aError = aFileName.pClass->WriteRcHeader( aFileName, rMem, pTC,
800 RscId(), nDeep, bExtra );
802 else
803 aError = ERR_ERROR;
805 return aError;
808 ERRTYPE RscSysDepend::WriteRc( const RSCINST & rInst, RscWriteRc & rMem,
809 RscTypCont * pTC, sal_uInt32 nDeep, bool bExtra )
811 ERRTYPE aError = RscClass::WriteRc( rInst, rMem, pTC, nDeep, bExtra );
813 if( this == rInst.pClass )
815 // nur wenn es eigen Klasse ist
816 aError = WriteSysDependRc( rInst, rMem, pTC, nDeep, bExtra );
818 return aError;
821 RscTupel::RscTupel( Atom nId, sal_uInt32 nTypeId, RscTop * pSuper )
822 : RscClass( nId, nTypeId, pSuper )
826 RSCINST RscTupel::GetTupelVar( const RSCINST & rInst, sal_uInt32 nPos,
827 const RSCINST & rInitInst )
829 if( nPos >= nEntries )
831 return RSCINST();
833 else
834 return GetVariable( rInst, pVarTypeList[ nPos ].nVarName, rInitInst );
837 void RscTupel::WriteSrc( const RSCINST & rInst, FILE * fOutput,
838 RscTypCont * pTC, sal_uInt32 nTab,
839 const char * pVarName )
841 sal_uInt32 i = 0;
842 RSCINST aTmpI;
844 RscTop::WriteSrc( rInst, fOutput, pTC, nTab, pVarName );
846 fprintf( fOutput, "< " );
847 for( i = 0; i < nEntries; i++ )
849 if( !(VAR_HIDDEN & pVarTypeList[ i ].nVarType) )
851 if( !IsDflt( rInst.pData, i )
852 && !IsValueDflt( rInst.pData, i ) )
854 aTmpI = GetInstData( rInst.pData, i, true );
856 if( aTmpI.IsInst() )
857 aTmpI.pClass->WriteSrcHeader(
858 aTmpI, fOutput, pTC, nTab, RscId(), pVarName );
859 else
860 fprintf( fOutput, "Default" );
862 else
863 fprintf( fOutput, "Default" );
864 fprintf( fOutput, "; " );
867 fprintf( fOutput, ">" );
869 return;
872 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */