CWS-TOOLING: integrate CWS os146
[LibreOffice.git] / rsc / source / res / rscclass.cxx
blob465e55a1e2cd672df63b7cf77e6cb79edb5f0375
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_rsc.hxx"
30 /****************** I N C L U D E S **************************************/
32 // C and C++ Includes.
33 #include <stdlib.h>
34 #include <stdio.h>
35 #include <string.h>
37 // Programmabhaengige Includes.
38 #include <rscdb.hxx>
39 #include <rscclass.hxx>
41 #include <tools/fsys.hxx>
42 #include <tools/rcid.h>
43 #include <tools/rc.h>
45 /****************** C O D E **********************************************/
46 /****************** R s c C l a s s **************************************/
47 /*************************************************************************
49 |* RscClass::RscClass()
51 |* Beschreibung
52 |* Ersterstellung MM 25.05.91
53 |* Letzte Aenderung MM 25.05.91
55 *************************************************************************/
56 RscClass::RscClass( Atom nId, sal_uInt32 nTypeId, RscTop * pSuperCl )
57 : RscTop( nId, nTypeId, pSuperCl )
59 nEntries = 0;
60 pVarTypeList = NULL;
61 nSuperSize = RscTop::Size();
62 nSize = nSuperSize + ALIGNED_SIZE( sizeof( RscClassInst ) );
65 /*************************************************************************
67 |* RscClass::Pre_dtor()
69 |* Beschreibung
70 |* Ersterstellung MM 25.05.91
71 |* Letzte Aenderung MM 25.05.91
73 *************************************************************************/
74 void RscClass::Pre_dtor()
76 sal_uInt32 i;
78 RscTop::Pre_dtor();
80 for( i = 0; i < nEntries; i++ )
82 if( pVarTypeList[ i ].pDefault )
84 pVarTypeList[ i ].pClass->Destroy(
85 RSCINST( pVarTypeList[ i ].pClass,
86 pVarTypeList[ i ].pDefault ) );
87 rtl_freeMemory( pVarTypeList[ i ].pDefault );
88 pVarTypeList[ i ].pDefault = NULL;
93 /*************************************************************************
95 |* RscClass::~RscClass()
97 |* Beschreibung
98 |* Ersterstellung MM 25.05.91
99 |* Letzte Aenderung MM 25.05.91
101 *************************************************************************/
102 RscClass::~RscClass()
104 if( pVarTypeList )
105 rtl_freeMemory( (void *)pVarTypeList );
108 /*************************************************************************
110 |* RscClass::GetClassType()
112 |* Beschreibung
113 |* Ersterstellung MM 25.05.91
114 |* Letzte Aenderung MM 25.05.91
116 *************************************************************************/
117 RSCCLASS_TYPE RscClass::GetClassType() const
119 return RSCCLASS_COMPLEX;
122 /*************************************************************************
124 |* RscClass::GetInstData()
126 |* Beschreibung
127 |* Ersterstellung MM 15.04.91
128 |* Letzte Aenderung MM 15.04.91
130 *************************************************************************/
131 RSCINST RscClass::GetInstData
133 CLASS_DATA pData,
134 sal_uInt32 nEle,
135 sal_Bool bGetCopy
138 RSCINST aInst;
140 aInst.pClass = pVarTypeList[ nEle ].pClass;
141 if( pData )
143 if( VAR_NODATAINST & pVarTypeList[ nEle ].nVarType )
145 RSCINST aTmpI;
147 aTmpI.pClass = this;
148 aTmpI.pData = pData;
149 if( bGetCopy )
150 aInst.pData = GetCopyVar(
151 aTmpI,
152 pVarTypeList[ nEle ].nDataBaseName
153 ).pData;
154 else
155 aInst.pData = GetVariable(
156 aTmpI,
157 pVarTypeList[ nEle ].nDataBaseName,
158 RSCINST()
159 ).pData;
161 else if( VAR_POINTER & pVarTypeList[ nEle ].nVarType )
163 if( VAR_EXTENDABLE & pVarTypeList[ nEle ].nVarType )
164 aInst = *(RSCINST *)
165 (pData + pVarTypeList[ nEle ].nOffset);
166 else
167 aInst.pData = *(CLASS_DATA *)
168 (pData + pVarTypeList[ nEle ].nOffset);
170 else
171 aInst.pData = pData + pVarTypeList[ nEle ].nOffset;
173 return( aInst );
176 /*************************************************************************
178 |* RscClass::GetInstDflt()
180 |* Beschreibung
182 *************************************************************************/
183 CLASS_DATA RscClass::GetDfltData( sal_uInt32 nEle )
185 if( pVarTypeList[ nEle ].pDefault )
186 return pVarTypeList[ nEle ].pDefault;
188 return pVarTypeList[ nEle ].pClass->GetDefault().pData;
191 /*************************************************************************
193 |* RscClass::SetVarDflt()
195 |* Beschreibung
196 |* Ersterstellung MM 22.07.91
197 |* Letzte Aenderung MM 22.07.91
199 *************************************************************************/
200 void RscClass::SetVarDflt( CLASS_DATA pData, sal_uInt32 nEle, sal_Bool bSet )
202 RscClassInst * pClass;
204 pClass = (RscClassInst *)(pData + nSuperSize );
205 if( bSet )
206 pClass->nVarDflt |= ((sal_uLong)1 << nEle);
207 else
208 pClass->nVarDflt &= ~((sal_uLong)1 << nEle);
211 /*************************************************************************
213 |* RscClass::IsDflt()
215 |* Beschreibung
216 |* Ersterstellung MM 22.07.91
217 |* Letzte Aenderung MM 08.01.92
219 *************************************************************************/
220 sal_Bool RscClass::IsDflt( CLASS_DATA pData, sal_uInt32 nEle )
222 RscClassInst * pClass;
223 sal_Bool bRet;
225 pClass = (RscClassInst *)(pData + nSuperSize );
226 if( pClass->nVarDflt & ((sal_uLong)1 << nEle) )
227 bRet = sal_True;
228 else
229 bRet = sal_False;
230 /* {
231 //Variablenname ist Default
232 RSCINST aTmpI;
234 aTmpI = GetInstData( pData, nEle, sal_True );
235 if( aTmpI.IsInst() && !aTmpI.pClass->IsDefault( aTmpI ) )
236 bRet = sal_False;
239 return bRet;
242 /*************************************************************************
244 |* RscClass::Create()
246 |* Beschreibung
247 |* Ersterstellung MM 03.04.91
248 |* Letzte Aenderung MM 03.04.91
250 *************************************************************************/
251 RSCINST RscClass::Create
253 RSCINST * pInst,
254 const RSCINST & rDflt,
255 sal_Bool bOwnClass
258 sal_uInt32 i;
259 CLASS_DATA * ppData;
260 RSCINST aInst;
261 RSCINST aMemInst, aDfltI;
263 if( !pInst )
265 aInst.pClass = this;
266 aInst.pData = (CLASS_DATA) rtl_allocateMemory( Size() );
268 else
269 aInst = *pInst;
270 if( !bOwnClass && rDflt.IsInst() )
271 bOwnClass = rDflt.pClass->InHierarchy( this );
273 RscTop::Create( &aInst, rDflt, bOwnClass );
275 if( bOwnClass )
276 ((RscClassInst *)(aInst.pData + nSuperSize))->nVarDflt =
277 ((RscClassInst *)(rDflt.pData + nSuperSize))->nVarDflt;
278 else
279 ((RscClassInst *)(aInst.pData + nSuperSize))->nVarDflt = ~((sal_uLong)0);
281 for( i = 0; i < nEntries; i++ )
283 aDfltI = GetInstData( bOwnClass ? rDflt.pData : NULL, i, sal_True );
285 if( (VAR_POINTER & pVarTypeList[ i ].nVarType)
286 && !(VAR_NODATAINST & pVarTypeList[ i ].nVarType) )
288 if( VAR_EXTENDABLE & pVarTypeList[ i ].nVarType )
290 RSCINST * pInstance = (RSCINST *)
291 (aInst.pData + pVarTypeList[ i ].nOffset );
292 pInstance->pClass = pVarTypeList[ i ].pClass;
293 ppData = &pInstance->pData;
295 else
296 ppData = (CLASS_DATA* )
297 (aInst.pData + pVarTypeList[ i ].nOffset );
298 *ppData = NULL;
299 if( aDfltI.IsInst() )
301 aMemInst = pVarTypeList[ i ].pClass->Create( NULL, aDfltI );
302 *ppData = aMemInst.pData;
305 else
307 aMemInst = GetInstData( aInst.pData, i, sal_True );
308 aMemInst = aMemInst.pClass->Create( &aMemInst, aDfltI );
312 return( aInst );
315 /*************************************************************************
317 |* RscClass::Destroy()
319 |* Beschreibung
321 *************************************************************************/
322 void RscClass::Destroy( const RSCINST & rInst )
324 sal_uInt32 i;
326 RscTop::Destroy( rInst );
328 for( i = 0; i < nEntries; i++ )
330 if( !(pVarTypeList[ i ].nVarType & VAR_NODATAINST) )
332 RSCINST aTmpI;
334 aTmpI = GetInstData( rInst.pData, i, sal_True );
335 if( aTmpI.IsInst() )
337 // Objekt loeschen
338 aTmpI.pClass->Destroy( aTmpI );
339 if( pVarTypeList[ i ].nVarType & VAR_POINTER )
341 // Speicher freigeben
342 rtl_freeMemory( aTmpI.pData );
349 /*************************************************************************
351 |* RscClass::SetVariable()
353 |* Beschreibung
355 *************************************************************************/
356 ERRTYPE RscClass::SetVariable
358 Atom nVarName,
359 RscTop * pClass,
360 RSCINST * pDflt,
361 RSCVAR nVarType,
362 sal_uInt32 nMask,
363 Atom nDataBaseName
366 if( pVarTypeList )
367 pVarTypeList = (VARTYPE_STRUCT *)
368 rtl_reallocateMemory( (void *)pVarTypeList,
369 ((nEntries +1) * sizeof( VARTYPE_STRUCT )) );
370 else
371 pVarTypeList = (VARTYPE_STRUCT *)
372 rtl_allocateMemory( ((nEntries +1)
373 * sizeof( VARTYPE_STRUCT )) );
375 pVarTypeList[ nEntries ].nVarName = nVarName;
376 pVarTypeList[ nEntries ].nMask = nMask;
377 pVarTypeList[ nEntries ].pClass = pClass;
378 pVarTypeList[ nEntries ].nOffset = nSize;
379 pVarTypeList[ nEntries ].nDataBaseName = nDataBaseName;
380 if( pDflt )
381 pVarTypeList[ nEntries ].pDefault = pDflt->pData;
382 else
383 pVarTypeList[ nEntries ].pDefault = NULL;
385 pVarTypeList[ nEntries ].nVarType = ~VAR_POINTER & nVarType;
386 if( pClass->Size() > 10 || (nVarType & VAR_EXTENDABLE) )
387 pVarTypeList[ nEntries ].nVarType |= VAR_POINTER;
389 if( !(pVarTypeList[ nEntries ].nVarType & VAR_NODATAINST) )
391 if( pVarTypeList[ nEntries ].nVarType & VAR_POINTER )
393 if( pVarTypeList[ nEntries ].nVarType & VAR_EXTENDABLE )
394 nSize += sizeof( RSCINST );
395 else
396 nSize += sizeof( CLASS_DATA );
398 else
399 nSize += pClass->Size();
402 nEntries++;
403 if( nEntries > (sizeof( sal_uLong ) * 8) )
405 // Bereich fuer Default zu klein
406 RscExit( 16 );
408 return( ERR_OK );
411 /*************************************************************************
413 |* RscClass::EnumVariable()
415 |* Beschreibung
417 *************************************************************************/
418 void RscClass::EnumVariables( void * pData, VarEnumCallbackProc pProc )
420 sal_uInt32 i;
422 RscTop::EnumVariables( pData, pProc );
423 for( i = 0; i < nEntries; i ++ )
425 if( !(pVarTypeList[ i ].nVarType & VAR_NOENUM) )
426 (*pProc)( pData, pVarTypeList[ i ].pClass->GetClassType(),
427 pVarTypeList[ i ].nVarName );
431 /*************************************************************************
433 |* RscClass::GetVariable()
435 |* Beschreibung
437 *************************************************************************/
438 RSCINST RscClass::GetVariable
440 const RSCINST & rInst,
441 Atom nVarName,
442 const RSCINST & rInitInst,
443 sal_Bool bInitDflt,
444 RscTop * pCreateClass
447 sal_uInt32 i = 0;
448 RSCINST aTmpI;
450 while( i < nEntries && pVarTypeList[ i ].nVarName != nVarName )
451 i++;
452 if( i < nEntries )
454 if( VAR_NODATAINST & pVarTypeList[ i ].nVarType )
456 aTmpI = GetVariable( rInst,
457 pVarTypeList[ i ].nDataBaseName,
458 RSCINST() );
459 aTmpI.pClass = pVarTypeList[ i ].pClass;
461 else
463 // Default Instanz generieren
464 RSCINST aDefInst = rInitInst;
465 if( !aDefInst.IsInst() && bInitDflt )
467 // mit dem Variablen-Default besetzen
468 aDefInst.pData = pVarTypeList[ i ].pDefault;
469 aDefInst.pClass = pVarTypeList[ i ].pClass;
472 aTmpI = GetInstData( rInst.pData, i );
473 if( aTmpI.IsInst() )
475 if( aDefInst.IsInst() )
477 aTmpI.pClass->Destroy( aTmpI );
478 aTmpI.pClass->Create( &aTmpI, aDefInst );
481 else
482 { // Wird ueber Zeiger angegeben
483 if( VAR_EXTENDABLE & pVarTypeList[ i ].nVarType )
485 RSCINST * pInst = (RSCINST *)
486 (rInst.pData + pVarTypeList[ i ].nOffset );
487 if( pCreateClass && pCreateClass->InHierarchy( aTmpI.pClass ) )
488 *pInst = pCreateClass->Create( NULL, aDefInst );
489 else
490 *pInst = aTmpI.pClass->Create( NULL, aDefInst );
491 aTmpI = *pInst;
493 else
495 CLASS_DATA * ppData
496 = (CLASS_DATA *)(rInst.pData + pVarTypeList[ i ].nOffset);
497 aTmpI = aTmpI.pClass->Create( NULL, aDefInst );
498 *ppData = aTmpI.pData;
502 // auf nicht Default setzen
503 SetVarDflt( rInst.pData, i, sal_False );
504 return( aTmpI );
507 return( RscTop::GetVariable( rInst, nVarName, rInitInst,
508 bInitDflt, pCreateClass ) );
511 /*************************************************************************
513 |* RscClass::GetCopyVar()
515 |* Beschreibung
517 *************************************************************************/
518 RSCINST RscClass::GetCopyVar
520 const RSCINST & rInst,
521 Atom nVarName
524 sal_uInt32 i = 0;
525 RSCINST aVarI;
527 while( i < nEntries && pVarTypeList[ i ].nVarName != nVarName )
528 i++;
530 if( i < nEntries )
532 if( VAR_NODATAINST & pVarTypeList[ i ].nVarType )
534 aVarI = GetCopyVar( rInst, pVarTypeList[ i ].nDataBaseName );
535 aVarI.pClass = pVarTypeList[ i ].pClass;
537 else
539 if( IsDflt( rInst.pData, i ) )
541 // mit Variablen Default initialiaieren
542 aVarI = GetVariable( rInst, nVarName, RSCINST(), sal_True );
543 SetVarDflt( rInst.pData, i, sal_True );
545 else
546 aVarI = GetInstData( rInst.pData, i, sal_True );
549 return aVarI ;
552 return RscTop::GetCopyVar( rInst, nVarName );
555 /*************************************************************************
557 |* RscClass::IsConsistent()
559 |* Beschreibung
561 *************************************************************************/
562 sal_Bool RscClass::IsConsistent( const RSCINST & rInst, RscInconsList * pList )
564 sal_uInt32 i = 0;
565 RSCINST aTmpI;
566 sal_Bool bRet;
568 bRet = RscTop::IsConsistent( rInst, pList );
570 for( i = 0; i < nEntries; i++ )
572 if( !(VAR_NODATAINST & pVarTypeList[ i ].nVarType) )
574 aTmpI = GetInstData( rInst.pData, i, sal_True );
576 if( aTmpI.IsInst() )
577 if( ! aTmpI.pClass->IsConsistent( aTmpI, pList ) )
578 bRet = sal_False;
582 return( bRet );
585 /*************************************************************************
587 |* RscClass::SetToDefault()
589 |* Beschreibung
591 *************************************************************************/
592 void RscClass::SetToDefault( const RSCINST & rInst )
594 sal_uInt32 i;
595 RSCINST aTmpI;
596 RscClassInst * pClass;
598 pClass = (RscClassInst *)(rInst.pData + nSuperSize );
600 for( i = 0; i < nEntries; i++ )
602 // Variablen ohne eigenen Speicher werden vom "Datenserver"
603 // auf Default gesetzt
604 if( !(VAR_NODATAINST & pVarTypeList[ i ].nVarType) )
606 aTmpI = GetInstData( rInst.pData, i, sal_True );
607 if( aTmpI.IsInst() )
608 aTmpI.pClass->SetToDefault( aTmpI );
611 pClass->nVarDflt = ~((sal_uLong)0); // alles auf Default
613 RscTop::SetToDefault( rInst );
616 /*************************************************************************
618 |* RscClass::IsDefault()
620 |* Beschreibung
622 *************************************************************************/
623 sal_Bool RscClass::IsDefault( const RSCINST & rInst )
625 sal_uInt32 i;
626 RSCINST aTmpI;
628 for( i = 0; i < nEntries; i++ )
630 // Variablen ohne eigenen Speicher werden vom "Datenserver"
631 // auf Default untersucht
632 if( !(VAR_NODATAINST & pVarTypeList[ i ].nVarType) )
633 if( !IsDflt( rInst.pData, i ) )
634 return( sal_False );
637 return( RscTop::IsDefault( rInst ) );
640 /*************************************************************************
642 |* RscClass::GetDefault()
644 |* Beschreibung
646 *************************************************************************/
647 RSCINST RscClass::GetDefault( Atom nVarId )
649 sal_uInt32 i;
651 i = 0;
652 while( i < nEntries && pVarTypeList[ i ].nVarName != nVarId )
653 i++;
654 if( i < nEntries )
656 RSCINST aTmpI;
658 aTmpI.pClass = pVarTypeList[ i ].pClass;
659 aTmpI.pData = GetDfltData( i );
660 return( aTmpI );
663 return( RscTop::GetDefault( nVarId ) );
666 /*************************************************************************
668 |* RscClass::IsValueDflt()
670 |* Beschreibung
672 *************************************************************************/
673 sal_Bool RscClass::IsValueDflt( CLASS_DATA pData, sal_uInt32 nEle )
675 RSCINST aTmpI;
677 aTmpI = GetInstData( pData, nEle, sal_True );
679 if( aTmpI.IsInst() )
681 if( VAR_SVDYNAMIC & pVarTypeList[ nEle ].nVarType )
682 return sal_False;
684 if( aTmpI.pClass == pVarTypeList[ nEle ].pClass )
685 //sie haben auch die gleiche Klasse
686 return aTmpI.pClass->IsValueDefault( aTmpI, GetDfltData( nEle ) );
687 else
688 return sal_False;
690 return sal_True;
693 /*************************************************************************
695 |* RscClass::IsValueDefault()
697 |* Beschreibung
699 *************************************************************************/
700 sal_Bool RscClass::IsValueDefault( const RSCINST & rInst, CLASS_DATA pDef )
702 sal_uInt32 i = 0;
703 RSCINST aTmpI;
704 RSCINST aDfltI;
706 if( !RscTop::IsValueDefault( rInst, pDef ) )
707 return sal_False;
709 if( pDef )
711 for( i = 0; i < nEntries; i++ )
713 aTmpI = GetInstData( rInst.pData, i, sal_True );
714 if( aTmpI.IsInst() )
716 if( aTmpI.pClass != pVarTypeList[ i ].pClass )
717 //sie haben nicht die gleiche Klasse
718 return sal_False;
720 aDfltI = GetInstData( pDef, i, sal_True );
721 if( !aDfltI.IsInst() )
722 aDfltI.pData = GetDfltData( i );
724 if( !aTmpI.pClass->IsValueDefault( aTmpI, aDfltI.pData ) )
725 return sal_False;
729 else
730 return sal_False;
732 return sal_True;
735 /*************************************************************************
737 |* RscClass::SetDefault()
739 |* Beschreibung
741 *************************************************************************/
742 void RscClass::SetDefault( const RSCINST & rInst, Atom nVarName )
744 sal_uInt32 i = 0;
745 RSCINST aTmpI;
747 while( i < nEntries && pVarTypeList[ i ].nVarName != nVarName )
748 i++;
750 if( i < nEntries )
752 aTmpI = GetInstData( rInst.pData, i, sal_True );
753 if( aTmpI.IsInst() )
755 aTmpI.pClass->Destroy( aTmpI );
756 aTmpI.pClass->Create( &aTmpI, RSCINST() );
757 SetVarDflt( rInst.pData, i, sal_True );
760 else //In Superklasse nach Variable suchen
761 RscTop::SetDefault( rInst, nVarName );
766 /*************************************************************************
768 |* RscClass::WriteSrc()
770 |* Beschreibung
772 *************************************************************************/
773 void RscClass::WriteSrc
775 const RSCINST & rInst,
776 FILE * fOutput,
777 RscTypCont * pTC,
778 sal_uInt32 nTab,
779 const char * pVarName
782 sal_uInt32 i = 0, n = 0;
783 RSCINST aTmpI;
785 RscTop::WriteSrc( rInst, fOutput, pTC, nTab, pVarName );
787 for( i = 0; i < nEntries; i++ )
789 if( !(VAR_HIDDEN & pVarTypeList[ i ].nVarType) )
791 // Hack wegen Position und Dimensiuon
792 if( nRsc_XYMAPMODEId == pVarTypeList[ i ].nVarName
793 || nRsc_WHMAPMODEId == pVarTypeList[ i ].nVarName )
795 if( !IsDflt( rInst.pData, i ) //MapUnit
796 || !IsDflt( rInst.pData, i+1 ) //X, Width
797 || !IsDflt( rInst.pData, i+2 ) )//Y, Height
798 {// ein Wert ist nicht Default
799 for( n = 0; n < nTab; n++ )
800 fputc( '\t', fOutput );
801 if( nRsc_XYMAPMODEId == pVarTypeList[ i ].nVarName )
802 fprintf( fOutput, "Pos = " );
803 else
804 fprintf( fOutput, "Size = " );
806 if( !IsDflt( rInst.pData, i ) )
808 aTmpI = GetInstData( rInst.pData, i, sal_True );
809 aTmpI.pClass->WriteSrcHeader(
810 aTmpI, fOutput, pTC, nTab, RscId(), pVarName );
813 fprintf( fOutput, "( " );
814 aTmpI = GetInstData( rInst.pData, i+1, sal_True );
815 if( !aTmpI.IsInst() )
816 aTmpI.pData = GetDfltData( i+1 );
817 aTmpI.pClass->WriteSrcHeader(
818 aTmpI, fOutput, pTC, nTab, RscId(), pVarName );
820 fprintf( fOutput, ", " );
821 aTmpI = GetInstData( rInst.pData, i+2, sal_True );
822 if( !aTmpI.IsInst() )
823 aTmpI.pData = GetDfltData( i+2 );
824 aTmpI.pClass->WriteSrcHeader(
825 aTmpI, fOutput, pTC, nTab, RscId(), pVarName );
826 fprintf( fOutput, " );\n" );
828 i += 2; //_X, _Y oder _Widht, Height ueberlesen
830 else if( !IsDflt( rInst.pData, i )
831 && !IsValueDflt( rInst.pData, i ) )
833 aTmpI = GetInstData( rInst.pData, i, sal_True );
835 if( aTmpI.IsInst() )
837 const char * pName = pHS->getString( pVarTypeList[ i ].nVarName ).getStr();
839 for( n = 0; n < nTab; n++ )
840 fputc( '\t', fOutput );
841 fprintf( fOutput, "%s", pName );
842 fprintf( fOutput, " = " );
843 aTmpI.pClass->WriteSrcHeader(
844 aTmpI, fOutput, pTC, nTab, RscId(), pName );
845 fprintf( fOutput, ";\n" );
851 return;
854 /*************************************************************************
856 |* RscClass::WriteInstRc()
858 |* Beschreibung
860 *************************************************************************/
861 sal_Int32 RscClass::GetCorrectValues
863 const RSCINST & rInst,
864 sal_uInt32 nVarPos,
865 sal_uInt32 nTupelIdx,
866 RscTypCont * pTC
869 sal_Int32 nLang = 0;
870 sal_Int32 nBaseValue;
872 // Basiswert holen
873 RSCINST aTmpI = GetInstData( rInst.pData, nVarPos, sal_True );
874 aTmpI.pClass->GetNumber( aTmpI, &nBaseValue );
876 // Sprach Delta holen
877 aTmpI = rInst.pClass->GetVariable( rInst, nRsc_DELTALANG, RSCINST() );
878 if( aTmpI.IsInst() )
880 RscWriteRc aMem;
881 aTmpI.pClass->WriteRc( aTmpI, aMem, pTC, 0, sal_False );
882 nLang = (sal_Int32)aMem.GetShort( nTupelIdx * sizeof(sal_uInt16) );
885 return nLang + nBaseValue;
888 ERRTYPE RscClass::WriteInstRc
890 const RSCINST & rInst,
891 RscWriteRc & rMem,
892 RscTypCont * pTC,
893 sal_uInt32 nDeep,
894 sal_Bool bExtra
897 sal_uInt32 i = 0;
898 ERRTYPE aError;
899 RSCINST aTmpI;
900 sal_uInt32 nMaskOff = 0;// Offset um Maskenfeld zu addressieren
902 // Wenn eine Variable Maskierung hat, dann Maskenfeld
903 for( i = 0; i < nEntries; i++ )
905 if( pVarTypeList[ i ].nMask )
907 nMaskOff = rMem.Size();
908 rMem.Put( sal_uInt32(0) );
909 break;
913 for( i = 0; i < nEntries && aError.IsOk(); i++ )
915 if( !((VAR_NODATAINST | VAR_NORC) & pVarTypeList[ i ].nVarType ))
917 if( pVarTypeList[ i ].nMask )
919 if( !IsDflt( rInst.pData, i ) )
921 if( nRsc_X == pVarTypeList[ i ].nVarName )
923 sal_Int32 nVal = GetCorrectValues( rInst, i, 0, pTC );
924 rMem.Put( nVal );
926 else if( nRsc_Y == pVarTypeList[ i ].nVarName )
928 sal_Int32 nVal = GetCorrectValues( rInst, i, 1, pTC );
929 rMem.Put( nVal );
931 else if( nRsc_WIDTH == pVarTypeList[ i ].nVarName )
933 sal_Int32 nVal = GetCorrectValues( rInst, i, 2, pTC );
934 rMem.Put( nVal );
936 else if( nRsc_HEIGHT == pVarTypeList[ i ].nVarName )
938 sal_Int32 nVal = GetCorrectValues( rInst, i, 3, pTC );
939 rMem.Put( nVal );
941 else
943 aTmpI = GetInstData( rInst.pData, i, sal_True );
944 // Nur an Variable Extradata bExtra nicht auf sal_False
945 // setzen
946 aError = aTmpI.pClass->
947 WriteRcHeader( aTmpI, rMem, pTC,
948 RscId(), nDeep,
949 (nRsc_EXTRADATA
950 == pVarTypeList[ i ].nVarName)
951 ? bExtra : sal_False );
953 sal_uInt32 nMask = rMem.GetLong( nMaskOff );
954 nMask |= pVarTypeList[ i ].nMask;
955 rMem.PutAt( nMaskOff, nMask );
958 else{
959 if( IsDflt( rInst.pData, i ) )
961 aTmpI.pClass = pVarTypeList[ i ].pClass;
962 aTmpI.pData = GetDfltData( i );
964 else
965 aTmpI = GetInstData( rInst.pData, i, sal_True );
966 // Nur an Variable Extradata bExtra nicht auf sal_False
967 // setzen
968 aError = aTmpI.pClass->
969 WriteRcHeader( aTmpI, rMem, pTC,
970 RscId(), nDeep,
971 (nRsc_EXTRADATA
972 == pVarTypeList[ i ].nVarName)
973 ? bExtra : sal_False );
978 return( aError );
981 /*************************************************************************
983 |* RscClass::WriteRc()
985 |* Beschreibung
987 *************************************************************************/
988 ERRTYPE RscClass::WriteRc
990 const RSCINST & rInst,
991 RscWriteRc & rMem,
992 RscTypCont * pTC,
993 sal_uInt32 nDeep,
994 sal_Bool bExtra
997 ERRTYPE aError;
999 aError = RscTop::WriteRc( rInst, rMem, pTC, nDeep, bExtra );
1000 if( aError.IsOk() )
1001 aError = WriteInstRc( rInst, rMem, pTC, nDeep, bExtra );
1003 return( aError );
1006 /*************************************************************************
1008 |* RscClass::WriteSyntax()
1010 |* Beschreibung
1012 *************************************************************************/
1013 void RscClass::WriteSyntax( FILE * fOutput, RscTypCont * pTC )
1015 RscTop::WriteSyntax( fOutput, pTC );
1017 sal_uInt32 i;
1018 // Wenn eine Variable Maskierung hat, dann Maskenfeld
1019 fprintf( fOutput, "\t//%s\n", pHS->getString( GetId() ).getStr() );
1020 for( i = 0; i < nEntries; i++ )
1022 fprintf( fOutput, "\t%s", pHS->getString( pVarTypeList[ i ].nVarName ).getStr() );
1023 sal_uInt32 n = strlen( pHS->getString( pVarTypeList[ i ].nVarName ).getStr() );
1024 while( n < 20 )
1026 putc( ' ', fOutput );
1027 n++;
1029 fprintf( fOutput, " = %s;\n",
1030 pHS->getString( pVarTypeList[ i ].pClass->GetId() ).getStr() );
1034 //==================================================================
1035 void RscClass::WriteRcAccess
1037 FILE * fOutput,
1038 RscTypCont * /*pTC*/,
1039 const char * pName
1042 fprintf( fOutput, "\t\tSet%s( %s ", pName, pHS->getString( GetId() ).getStr() );
1043 fprintf( fOutput, "%s ", aCallPar2.GetBuffer() );
1044 fprintf( fOutput, "ResId( (RSHEADER_TYPE*)(pResData+nOffset) ) ) );\n" );
1045 fprintf( fOutput, "\t\tnOffset += GetObjSizeRes( (RSHEADER_TYPE*)(pResData+nOffset) );\n" );
1048 //==================================================================
1049 void RscClass::WriteRcCtor( FILE * fOutput, RscTypCont * pTC )
1051 if( GetId() != InvalidAtom )
1053 // Konstruktor
1054 fprintf( fOutput, "%s::%s%s bFreeResource )",
1055 pHS->getString( GetId() ).getStr(),
1056 pHS->getString( GetId() ).getStr(),
1057 aCallParType.GetBuffer() );
1058 if( GetSuperClass() )
1060 // Superaufruf
1061 fprintf( fOutput, "\n\t: %s", pHS->getString( GetSuperClass()->GetId() ).getStr() );
1062 fprintf( fOutput, "%s", GetSuperClass()->aCallPar1.GetBuffer() );
1063 fprintf( fOutput, " rResId.SetRT2( 0x%lx ) )",
1064 sal::static_int_cast< unsigned long >(GetTypId()) );
1066 fprintf( fOutput, "\n{\n" );
1067 fprintf( fOutput, "\tsal_uInt32\tnObjMask;\n" );
1068 fprintf( fOutput, "\tsal_uInt32\tnOffset = 0;\n" );
1069 fprintf( fOutput, "\tBYTE *\tpResData;\n\n" );
1070 fprintf( fOutput, "\tpResData = (tBYTE *)GetClassRes();\n\n" );
1071 fprintf( fOutput, "\tnObjMask = *(sal_uInt32*)pResData;\n" );
1072 fprintf( fOutput, "\tnOffset += 4;\n\n" );
1074 for( sal_uInt32 i = 0; i < nEntries; i++ )
1076 if( !((VAR_NODATAINST | VAR_NORC) & pVarTypeList[ i ].nVarType ))
1078 fprintf( fOutput, "\tif( nObjMask & 0x%lx )\n\t{\n",
1079 sal::static_int_cast< unsigned long >(
1080 pVarTypeList[ i ].nMask) );
1082 pVarTypeList[ i ].pClass->WriteRcAccess( fOutput, pTC,
1083 pHS->getString( pVarTypeList[ i ].nVarName ).getStr() );
1085 fprintf( fOutput, "\t}\n" );
1088 fprintf( fOutput, "\tIncrementRes( nOffset );\n" );
1089 fprintf( fOutput, "\tif( bFreeResource )\n" );
1090 fprintf( fOutput, "\t\tFreeResource();\n" );
1091 fprintf( fOutput, "}\n\n" );
1095 /*************************************************************************
1097 |* RscSysDepend::RscSysDepend()
1099 |* Beschreibung
1101 *************************************************************************/
1102 RscSysDepend::RscSysDepend( Atom nId, sal_uInt32 nTypeId, RscTop * pSuper )
1103 : RscClass( nId, nTypeId, pSuper )
1106 /*************************************************************************
1108 |* RscSysDepend::WriteRc()
1110 |* Beschreibung
1112 *************************************************************************/
1113 ERRTYPE RscSysDepend::WriteSysDependRc( const RSCINST & rInst, RscWriteRc & rMem,
1114 RscTypCont * pTC, sal_uInt32 nDeep, sal_Bool bExtra, sal_Bool bFirst )
1116 sal_uInt32 nId = 0xFFFFFFFF;
1117 ERRTYPE aError;
1118 RSCINST aFileName;
1120 //Instanz mit dem Dateinamen "FILENAME" holen
1121 aFileName = RscClass::GetCopyVar( rInst, pHS->getID( "FILE", true ) );
1122 if( aFileName.IsInst() )
1124 RscWriteRc aTmpMem;
1125 aError = aFileName.pClass->WriteRcHeader( aFileName, aTmpMem, pTC,
1126 RscId(), nDeep, bExtra );
1127 // Obsolete - need changes in VCL
1128 rMem.Put( sal_uInt32(0) );
1130 // Identifier schreiben
1131 if( aTmpMem.Size() && pTC && (*aTmpMem.GetUTF8( 0 ) != '\0') )
1133 nId = pTC->PutSysName( rInst.pClass->GetTypId(),
1134 aTmpMem.GetUTF8( 0 ),
1135 0, 0, bFirst );
1137 rMem.Put( nId );
1138 aError = aFileName.pClass->WriteRcHeader( aFileName, rMem, pTC,
1139 RscId(), nDeep, bExtra );
1141 else
1142 aError = ERR_ERROR;
1144 return( aError );
1147 /*************************************************************************
1149 |* RscSysDepend::WriteRc()
1151 |* Beschreibung
1153 *************************************************************************/
1154 ERRTYPE RscSysDepend::WriteRc( const RSCINST & rInst, RscWriteRc & rMem,
1155 RscTypCont * pTC, sal_uInt32 nDeep, sal_Bool bExtra )
1157 ERRTYPE aError = RscClass::WriteRc( rInst, rMem, pTC, nDeep, bExtra );
1159 if( this == rInst.pClass )
1160 // nur wenn es eigen Klasse ist
1161 aError = WriteSysDependRc( rInst, rMem, pTC, nDeep, bExtra );
1162 return aError;
1165 /*************************************************************************
1167 |* RscFirstSysDepend::RscFirstSysDepend()
1169 |* Beschreibung
1171 *************************************************************************/
1172 RscFirstSysDepend::RscFirstSysDepend( Atom nId, sal_uInt32 nTypeId,
1173 RscTop * pSuper )
1174 : RscSysDepend( nId, nTypeId, pSuper )
1177 /*************************************************************************
1179 |* RscFirstSysDepend::WriteRc()
1181 |* Beschreibung
1183 *************************************************************************/
1184 ERRTYPE RscFirstSysDepend::WriteRc( const RSCINST & rInst, RscWriteRc & rMem,
1185 RscTypCont * pTC, sal_uInt32 nDeep, sal_Bool bExtra )
1187 ERRTYPE aError = RscClass::WriteRc( rInst, rMem, pTC, nDeep, bExtra );
1188 aError = WriteSysDependRc( rInst, rMem, pTC, nDeep, bExtra, sal_True );
1189 return aError;
1192 /*************************************************************************
1194 |* RscTupel::RscTupel()
1196 |* Beschreibung
1198 *************************************************************************/
1199 RscTupel::RscTupel( Atom nId, sal_uInt32 nTypeId, RscTop * pSuper )
1200 : RscClass( nId, nTypeId, pSuper )
1203 /*************************************************************************
1205 |* RscTupel::GetTupelVar()
1207 |* Beschreibung
1209 *************************************************************************/
1210 RSCINST RscTupel::GetTupelVar( const RSCINST & rInst, sal_uInt32 nPos,
1211 const RSCINST & rInitInst )
1213 if( nPos >= nEntries )
1215 return RSCINST();
1217 else
1218 return GetVariable( rInst, pVarTypeList[ nPos ].nVarName, rInitInst );
1221 /*************************************************************************
1223 |* RscTupel::WriteSrc()
1225 |* Beschreibung
1227 *************************************************************************/
1228 void RscTupel::WriteSrc( const RSCINST & rInst, FILE * fOutput,
1229 RscTypCont * pTC, sal_uInt32 nTab,
1230 const char * pVarName )
1232 sal_uInt32 i = 0;
1233 RSCINST aTmpI;
1235 RscTop::WriteSrc( rInst, fOutput, pTC, nTab, pVarName );
1237 fprintf( fOutput, "< " );
1238 for( i = 0; i < nEntries; i++ )
1240 if( !(VAR_HIDDEN & pVarTypeList[ i ].nVarType) )
1242 if( !IsDflt( rInst.pData, i )
1243 && !IsValueDflt( rInst.pData, i ) )
1245 aTmpI = GetInstData( rInst.pData, i, sal_True );
1247 if( aTmpI.IsInst() )
1248 aTmpI.pClass->WriteSrcHeader(
1249 aTmpI, fOutput, pTC, nTab, RscId(), pVarName );
1250 else
1251 fprintf( fOutput, "Default" );
1253 else
1254 fprintf( fOutput, "Default" );
1255 fprintf( fOutput, "; " );
1258 fprintf( fOutput, ">" );
1260 return;