Update ooo320-m1
[ooovba.git] / rsc / source / res / rscclass.cxx
blobb590a92bdee6d546ae03189722b308661e9b67af
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: rscclass.cxx,v $
10 * $Revision: 1.10 $
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_rsc.hxx"
33 /****************** I N C L U D E S **************************************/
35 // C and C++ Includes.
36 #include <stdlib.h>
37 #include <stdio.h>
38 #include <string.h>
40 // Programmabhaengige Includes.
41 #include <rscdb.hxx>
42 #include <rscclass.hxx>
44 #include <tools/fsys.hxx>
45 #include <tools/rcid.h>
46 #include <tools/rc.h>
48 /****************** C O D E **********************************************/
49 /****************** R s c C l a s s **************************************/
50 /*************************************************************************
52 |* RscClass::RscClass()
54 |* Beschreibung
55 |* Ersterstellung MM 25.05.91
56 |* Letzte Aenderung MM 25.05.91
58 *************************************************************************/
59 RscClass::RscClass( Atom nId, sal_uInt32 nTypeId, RscTop * pSuperCl )
60 : RscTop( nId, nTypeId, pSuperCl )
62 nEntries = 0;
63 pVarTypeList = NULL;
64 nSuperSize = RscTop::Size();
65 nSize = nSuperSize + ALIGNED_SIZE( sizeof( RscClassInst ) );
68 /*************************************************************************
70 |* RscClass::Pre_dtor()
72 |* Beschreibung
73 |* Ersterstellung MM 25.05.91
74 |* Letzte Aenderung MM 25.05.91
76 *************************************************************************/
77 void RscClass::Pre_dtor()
79 sal_uInt32 i;
81 RscTop::Pre_dtor();
83 for( i = 0; i < nEntries; i++ )
85 if( pVarTypeList[ i ].pDefault )
87 pVarTypeList[ i ].pClass->Destroy(
88 RSCINST( pVarTypeList[ i ].pClass,
89 pVarTypeList[ i ].pDefault ) );
90 rtl_freeMemory( pVarTypeList[ i ].pDefault );
91 pVarTypeList[ i ].pDefault = NULL;
96 /*************************************************************************
98 |* RscClass::~RscClass()
100 |* Beschreibung
101 |* Ersterstellung MM 25.05.91
102 |* Letzte Aenderung MM 25.05.91
104 *************************************************************************/
105 RscClass::~RscClass()
107 if( pVarTypeList )
108 rtl_freeMemory( (void *)pVarTypeList );
111 /*************************************************************************
113 |* RscClass::GetClassType()
115 |* Beschreibung
116 |* Ersterstellung MM 25.05.91
117 |* Letzte Aenderung MM 25.05.91
119 *************************************************************************/
120 RSCCLASS_TYPE RscClass::GetClassType() const
122 return RSCCLASS_COMPLEX;
125 /*************************************************************************
127 |* RscClass::GetInstData()
129 |* Beschreibung
130 |* Ersterstellung MM 15.04.91
131 |* Letzte Aenderung MM 15.04.91
133 *************************************************************************/
134 RSCINST RscClass::GetInstData
136 CLASS_DATA pData,
137 sal_uInt32 nEle,
138 BOOL bGetCopy
141 RSCINST aInst;
143 aInst.pClass = pVarTypeList[ nEle ].pClass;
144 if( pData )
146 if( VAR_NODATAINST & pVarTypeList[ nEle ].nVarType )
148 RSCINST aTmpI;
150 aTmpI.pClass = this;
151 aTmpI.pData = pData;
152 if( bGetCopy )
153 aInst.pData = GetCopyVar(
154 aTmpI,
155 pVarTypeList[ nEle ].nDataBaseName
156 ).pData;
157 else
158 aInst.pData = GetVariable(
159 aTmpI,
160 pVarTypeList[ nEle ].nDataBaseName,
161 RSCINST()
162 ).pData;
164 else if( VAR_POINTER & pVarTypeList[ nEle ].nVarType )
166 if( VAR_EXTENDABLE & pVarTypeList[ nEle ].nVarType )
167 aInst = *(RSCINST *)
168 (pData + pVarTypeList[ nEle ].nOffset);
169 else
170 aInst.pData = *(CLASS_DATA *)
171 (pData + pVarTypeList[ nEle ].nOffset);
173 else
174 aInst.pData = pData + pVarTypeList[ nEle ].nOffset;
176 return( aInst );
179 /*************************************************************************
181 |* RscClass::GetInstDflt()
183 |* Beschreibung
185 *************************************************************************/
186 CLASS_DATA RscClass::GetDfltData( sal_uInt32 nEle )
188 if( pVarTypeList[ nEle ].pDefault )
189 return pVarTypeList[ nEle ].pDefault;
191 return pVarTypeList[ nEle ].pClass->GetDefault().pData;
194 /*************************************************************************
196 |* RscClass::SetVarDflt()
198 |* Beschreibung
199 |* Ersterstellung MM 22.07.91
200 |* Letzte Aenderung MM 22.07.91
202 *************************************************************************/
203 void RscClass::SetVarDflt( CLASS_DATA pData, sal_uInt32 nEle, BOOL bSet )
205 RscClassInst * pClass;
207 pClass = (RscClassInst *)(pData + nSuperSize );
208 if( bSet )
209 pClass->nVarDflt |= ((ULONG)1 << nEle);
210 else
211 pClass->nVarDflt &= ~((ULONG)1 << nEle);
214 /*************************************************************************
216 |* RscClass::IsDflt()
218 |* Beschreibung
219 |* Ersterstellung MM 22.07.91
220 |* Letzte Aenderung MM 08.01.92
222 *************************************************************************/
223 BOOL RscClass::IsDflt( CLASS_DATA pData, sal_uInt32 nEle )
225 RscClassInst * pClass;
226 BOOL bRet;
228 pClass = (RscClassInst *)(pData + nSuperSize );
229 if( pClass->nVarDflt & ((ULONG)1 << nEle) )
230 bRet = TRUE;
231 else
232 bRet = FALSE;
233 /* {
234 //Variablenname ist Default
235 RSCINST aTmpI;
237 aTmpI = GetInstData( pData, nEle, TRUE );
238 if( aTmpI.IsInst() && !aTmpI.pClass->IsDefault( aTmpI ) )
239 bRet = FALSE;
242 return bRet;
245 /*************************************************************************
247 |* RscClass::Create()
249 |* Beschreibung
250 |* Ersterstellung MM 03.04.91
251 |* Letzte Aenderung MM 03.04.91
253 *************************************************************************/
254 RSCINST RscClass::Create
256 RSCINST * pInst,
257 const RSCINST & rDflt,
258 BOOL bOwnClass
261 sal_uInt32 i;
262 CLASS_DATA * ppData;
263 RSCINST aInst;
264 RSCINST aMemInst, aDfltI;
266 if( !pInst )
268 aInst.pClass = this;
269 aInst.pData = (CLASS_DATA) rtl_allocateMemory( Size() );
271 else
272 aInst = *pInst;
273 if( !bOwnClass && rDflt.IsInst() )
274 bOwnClass = rDflt.pClass->InHierarchy( this );
276 RscTop::Create( &aInst, rDflt, bOwnClass );
278 if( bOwnClass )
279 ((RscClassInst *)(aInst.pData + nSuperSize))->nVarDflt =
280 ((RscClassInst *)(rDflt.pData + nSuperSize))->nVarDflt;
281 else
282 ((RscClassInst *)(aInst.pData + nSuperSize))->nVarDflt = ~((ULONG)0);
284 for( i = 0; i < nEntries; i++ )
286 aDfltI = GetInstData( bOwnClass ? rDflt.pData : NULL, i, TRUE );
288 if( (VAR_POINTER & pVarTypeList[ i ].nVarType)
289 && !(VAR_NODATAINST & pVarTypeList[ i ].nVarType) )
291 if( VAR_EXTENDABLE & pVarTypeList[ i ].nVarType )
293 RSCINST * pInstance = (RSCINST *)
294 (aInst.pData + pVarTypeList[ i ].nOffset );
295 pInstance->pClass = pVarTypeList[ i ].pClass;
296 ppData = &pInstance->pData;
298 else
299 ppData = (CLASS_DATA* )
300 (aInst.pData + pVarTypeList[ i ].nOffset );
301 *ppData = NULL;
302 if( aDfltI.IsInst() )
304 aMemInst = pVarTypeList[ i ].pClass->Create( NULL, aDfltI );
305 *ppData = aMemInst.pData;
308 else
310 aMemInst = GetInstData( aInst.pData, i, TRUE );
311 aMemInst = aMemInst.pClass->Create( &aMemInst, aDfltI );
315 return( aInst );
318 /*************************************************************************
320 |* RscClass::Destroy()
322 |* Beschreibung
324 *************************************************************************/
325 void RscClass::Destroy( const RSCINST & rInst )
327 sal_uInt32 i;
329 RscTop::Destroy( rInst );
331 for( i = 0; i < nEntries; i++ )
333 if( !(pVarTypeList[ i ].nVarType & VAR_NODATAINST) )
335 RSCINST aTmpI;
337 aTmpI = GetInstData( rInst.pData, i, TRUE );
338 if( aTmpI.IsInst() )
340 // Objekt loeschen
341 aTmpI.pClass->Destroy( aTmpI );
342 if( pVarTypeList[ i ].nVarType & VAR_POINTER )
344 // Speicher freigeben
345 rtl_freeMemory( aTmpI.pData );
352 /*************************************************************************
354 |* RscClass::SetVariable()
356 |* Beschreibung
358 *************************************************************************/
359 ERRTYPE RscClass::SetVariable
361 Atom nVarName,
362 RscTop * pClass,
363 RSCINST * pDflt,
364 RSCVAR nVarType,
365 sal_uInt32 nMask,
366 Atom nDataBaseName
369 if( pVarTypeList )
370 pVarTypeList = (VARTYPE_STRUCT *)
371 rtl_reallocateMemory( (void *)pVarTypeList,
372 ((nEntries +1) * sizeof( VARTYPE_STRUCT )) );
373 else
374 pVarTypeList = (VARTYPE_STRUCT *)
375 rtl_allocateMemory( ((nEntries +1)
376 * sizeof( VARTYPE_STRUCT )) );
378 pVarTypeList[ nEntries ].nVarName = nVarName;
379 pVarTypeList[ nEntries ].nMask = nMask;
380 pVarTypeList[ nEntries ].pClass = pClass;
381 pVarTypeList[ nEntries ].nOffset = nSize;
382 pVarTypeList[ nEntries ].nDataBaseName = nDataBaseName;
383 if( pDflt )
384 pVarTypeList[ nEntries ].pDefault = pDflt->pData;
385 else
386 pVarTypeList[ nEntries ].pDefault = NULL;
388 pVarTypeList[ nEntries ].nVarType = ~VAR_POINTER & nVarType;
389 if( pClass->Size() > 10 || (nVarType & VAR_EXTENDABLE) )
390 pVarTypeList[ nEntries ].nVarType |= VAR_POINTER;
392 if( !(pVarTypeList[ nEntries ].nVarType & VAR_NODATAINST) )
394 if( pVarTypeList[ nEntries ].nVarType & VAR_POINTER )
396 if( pVarTypeList[ nEntries ].nVarType & VAR_EXTENDABLE )
397 nSize += sizeof( RSCINST );
398 else
399 nSize += sizeof( CLASS_DATA );
401 else
402 nSize += pClass->Size();
405 nEntries++;
406 if( nEntries > (sizeof( ULONG ) * 8) )
408 // Bereich fuer Default zu klein
409 RscExit( 16 );
411 return( ERR_OK );
414 /*************************************************************************
416 |* RscClass::EnumVariable()
418 |* Beschreibung
420 *************************************************************************/
421 void RscClass::EnumVariables( void * pData, VarEnumCallbackProc pProc )
423 sal_uInt32 i;
425 RscTop::EnumVariables( pData, pProc );
426 for( i = 0; i < nEntries; i ++ )
428 if( !(pVarTypeList[ i ].nVarType & VAR_NOENUM) )
429 (*pProc)( pData, pVarTypeList[ i ].pClass->GetClassType(),
430 pVarTypeList[ i ].nVarName );
434 /*************************************************************************
436 |* RscClass::GetVariable()
438 |* Beschreibung
440 *************************************************************************/
441 RSCINST RscClass::GetVariable
443 const RSCINST & rInst,
444 Atom nVarName,
445 const RSCINST & rInitInst,
446 BOOL bInitDflt,
447 RscTop * pCreateClass
450 sal_uInt32 i = 0;
451 RSCINST aTmpI;
453 while( i < nEntries && pVarTypeList[ i ].nVarName != nVarName )
454 i++;
455 if( i < nEntries )
457 if( VAR_NODATAINST & pVarTypeList[ i ].nVarType )
459 aTmpI = GetVariable( rInst,
460 pVarTypeList[ i ].nDataBaseName,
461 RSCINST() );
462 aTmpI.pClass = pVarTypeList[ i ].pClass;
464 else
466 // Default Instanz generieren
467 RSCINST aDefInst = rInitInst;
468 if( !aDefInst.IsInst() && bInitDflt )
470 // mit dem Variablen-Default besetzen
471 aDefInst.pData = pVarTypeList[ i ].pDefault;
472 aDefInst.pClass = pVarTypeList[ i ].pClass;
475 aTmpI = GetInstData( rInst.pData, i );
476 if( aTmpI.IsInst() )
478 if( aDefInst.IsInst() )
480 aTmpI.pClass->Destroy( aTmpI );
481 aTmpI.pClass->Create( &aTmpI, aDefInst );
484 else
485 { // Wird ueber Zeiger angegeben
486 if( VAR_EXTENDABLE & pVarTypeList[ i ].nVarType )
488 RSCINST * pInst = (RSCINST *)
489 (rInst.pData + pVarTypeList[ i ].nOffset );
490 if( pCreateClass && pCreateClass->InHierarchy( aTmpI.pClass ) )
491 *pInst = pCreateClass->Create( NULL, aDefInst );
492 else
493 *pInst = aTmpI.pClass->Create( NULL, aDefInst );
494 aTmpI = *pInst;
496 else
498 CLASS_DATA * ppData
499 = (CLASS_DATA *)(rInst.pData + pVarTypeList[ i ].nOffset);
500 aTmpI = aTmpI.pClass->Create( NULL, aDefInst );
501 *ppData = aTmpI.pData;
505 // auf nicht Default setzen
506 SetVarDflt( rInst.pData, i, FALSE );
507 return( aTmpI );
510 return( RscTop::GetVariable( rInst, nVarName, rInitInst,
511 bInitDflt, pCreateClass ) );
514 /*************************************************************************
516 |* RscClass::GetCopyVar()
518 |* Beschreibung
520 *************************************************************************/
521 RSCINST RscClass::GetCopyVar
523 const RSCINST & rInst,
524 Atom nVarName
527 sal_uInt32 i = 0;
528 RSCINST aVarI;
530 while( i < nEntries && pVarTypeList[ i ].nVarName != nVarName )
531 i++;
533 if( i < nEntries )
535 if( VAR_NODATAINST & pVarTypeList[ i ].nVarType )
537 aVarI = GetCopyVar( rInst, pVarTypeList[ i ].nDataBaseName );
538 aVarI.pClass = pVarTypeList[ i ].pClass;
540 else
542 if( IsDflt( rInst.pData, i ) )
544 // mit Variablen Default initialiaieren
545 aVarI = GetVariable( rInst, nVarName, RSCINST(), TRUE );
546 SetVarDflt( rInst.pData, i, TRUE );
548 else
549 aVarI = GetInstData( rInst.pData, i, TRUE );
552 return aVarI ;
555 return RscTop::GetCopyVar( rInst, nVarName );
558 /*************************************************************************
560 |* RscClass::IsConsistent()
562 |* Beschreibung
564 *************************************************************************/
565 BOOL RscClass::IsConsistent( const RSCINST & rInst, RscInconsList * pList )
567 sal_uInt32 i = 0;
568 RSCINST aTmpI;
569 BOOL bRet;
571 bRet = RscTop::IsConsistent( rInst, pList );
573 for( i = 0; i < nEntries; i++ )
575 if( !(VAR_NODATAINST & pVarTypeList[ i ].nVarType) )
577 aTmpI = GetInstData( rInst.pData, i, TRUE );
579 if( aTmpI.IsInst() )
580 if( ! aTmpI.pClass->IsConsistent( aTmpI, pList ) )
581 bRet = FALSE;
585 return( bRet );
588 /*************************************************************************
590 |* RscClass::SetToDefault()
592 |* Beschreibung
594 *************************************************************************/
595 void RscClass::SetToDefault( const RSCINST & rInst )
597 sal_uInt32 i;
598 RSCINST aTmpI;
599 RscClassInst * pClass;
601 pClass = (RscClassInst *)(rInst.pData + nSuperSize );
603 for( i = 0; i < nEntries; i++ )
605 // Variablen ohne eigenen Speicher werden vom "Datenserver"
606 // auf Default gesetzt
607 if( !(VAR_NODATAINST & pVarTypeList[ i ].nVarType) )
609 aTmpI = GetInstData( rInst.pData, i, TRUE );
610 if( aTmpI.IsInst() )
611 aTmpI.pClass->SetToDefault( aTmpI );
614 pClass->nVarDflt = ~((ULONG)0); // alles auf Default
616 RscTop::SetToDefault( rInst );
619 /*************************************************************************
621 |* RscClass::IsDefault()
623 |* Beschreibung
625 *************************************************************************/
626 BOOL RscClass::IsDefault( const RSCINST & rInst )
628 sal_uInt32 i;
629 RSCINST aTmpI;
631 for( i = 0; i < nEntries; i++ )
633 // Variablen ohne eigenen Speicher werden vom "Datenserver"
634 // auf Default untersucht
635 if( !(VAR_NODATAINST & pVarTypeList[ i ].nVarType) )
636 if( !IsDflt( rInst.pData, i ) )
637 return( FALSE );
640 return( RscTop::IsDefault( rInst ) );
643 /*************************************************************************
645 |* RscClass::GetDefault()
647 |* Beschreibung
649 *************************************************************************/
650 RSCINST RscClass::GetDefault( Atom nVarId )
652 sal_uInt32 i;
654 i = 0;
655 while( i < nEntries && pVarTypeList[ i ].nVarName != nVarId )
656 i++;
657 if( i < nEntries )
659 RSCINST aTmpI;
661 aTmpI.pClass = pVarTypeList[ i ].pClass;
662 aTmpI.pData = GetDfltData( i );
663 return( aTmpI );
666 return( RscTop::GetDefault( nVarId ) );
669 /*************************************************************************
671 |* RscClass::IsValueDflt()
673 |* Beschreibung
675 *************************************************************************/
676 BOOL RscClass::IsValueDflt( CLASS_DATA pData, sal_uInt32 nEle )
678 RSCINST aTmpI;
680 aTmpI = GetInstData( pData, nEle, TRUE );
682 if( aTmpI.IsInst() )
684 if( VAR_SVDYNAMIC & pVarTypeList[ nEle ].nVarType )
685 return FALSE;
687 if( aTmpI.pClass == pVarTypeList[ nEle ].pClass )
688 //sie haben auch die gleiche Klasse
689 return aTmpI.pClass->IsValueDefault( aTmpI, GetDfltData( nEle ) );
690 else
691 return FALSE;
693 return TRUE;
696 /*************************************************************************
698 |* RscClass::IsValueDefault()
700 |* Beschreibung
702 *************************************************************************/
703 BOOL RscClass::IsValueDefault( const RSCINST & rInst, CLASS_DATA pDef )
705 sal_uInt32 i = 0;
706 RSCINST aTmpI;
707 RSCINST aDfltI;
709 if( !RscTop::IsValueDefault( rInst, pDef ) )
710 return FALSE;
712 if( pDef )
714 for( i = 0; i < nEntries; i++ )
716 aTmpI = GetInstData( rInst.pData, i, TRUE );
717 if( aTmpI.IsInst() )
719 if( aTmpI.pClass != pVarTypeList[ i ].pClass )
720 //sie haben nicht die gleiche Klasse
721 return FALSE;
723 aDfltI = GetInstData( pDef, i, TRUE );
724 if( !aDfltI.IsInst() )
725 aDfltI.pData = GetDfltData( i );
727 if( !aTmpI.pClass->IsValueDefault( aTmpI, aDfltI.pData ) )
728 return FALSE;
732 else
733 return FALSE;
735 return TRUE;
738 /*************************************************************************
740 |* RscClass::SetDefault()
742 |* Beschreibung
744 *************************************************************************/
745 void RscClass::SetDefault( const RSCINST & rInst, Atom nVarName )
747 sal_uInt32 i = 0;
748 RSCINST aTmpI;
750 while( i < nEntries && pVarTypeList[ i ].nVarName != nVarName )
751 i++;
753 if( i < nEntries )
755 aTmpI = GetInstData( rInst.pData, i, TRUE );
756 if( aTmpI.IsInst() )
758 aTmpI.pClass->Destroy( aTmpI );
759 aTmpI.pClass->Create( &aTmpI, RSCINST() );
760 SetVarDflt( rInst.pData, i, TRUE );
763 else //In Superklasse nach Variable suchen
764 RscTop::SetDefault( rInst, nVarName );
769 /*************************************************************************
771 |* RscClass::WriteSrc()
773 |* Beschreibung
775 *************************************************************************/
776 void RscClass::WriteSrc
778 const RSCINST & rInst,
779 FILE * fOutput,
780 RscTypCont * pTC,
781 sal_uInt32 nTab,
782 const char * pVarName
785 sal_uInt32 i = 0, n = 0;
786 RSCINST aTmpI;
788 RscTop::WriteSrc( rInst, fOutput, pTC, nTab, pVarName );
790 for( i = 0; i < nEntries; i++ )
792 if( !(VAR_HIDDEN & pVarTypeList[ i ].nVarType) )
794 // Hack wegen Position und Dimensiuon
795 if( nRsc_XYMAPMODEId == pVarTypeList[ i ].nVarName
796 || nRsc_WHMAPMODEId == pVarTypeList[ i ].nVarName )
798 if( !IsDflt( rInst.pData, i ) //MapUnit
799 || !IsDflt( rInst.pData, i+1 ) //X, Width
800 || !IsDflt( rInst.pData, i+2 ) )//Y, Height
801 {// ein Wert ist nicht Default
802 for( n = 0; n < nTab; n++ )
803 fputc( '\t', fOutput );
804 if( nRsc_XYMAPMODEId == pVarTypeList[ i ].nVarName )
805 fprintf( fOutput, "Pos = " );
806 else
807 fprintf( fOutput, "Size = " );
809 if( !IsDflt( rInst.pData, i ) )
811 aTmpI = GetInstData( rInst.pData, i, TRUE );
812 aTmpI.pClass->WriteSrcHeader(
813 aTmpI, fOutput, pTC, nTab, RscId(), pVarName );
816 fprintf( fOutput, "( " );
817 aTmpI = GetInstData( rInst.pData, i+1, TRUE );
818 if( !aTmpI.IsInst() )
819 aTmpI.pData = GetDfltData( i+1 );
820 aTmpI.pClass->WriteSrcHeader(
821 aTmpI, fOutput, pTC, nTab, RscId(), pVarName );
823 fprintf( fOutput, ", " );
824 aTmpI = GetInstData( rInst.pData, i+2, TRUE );
825 if( !aTmpI.IsInst() )
826 aTmpI.pData = GetDfltData( i+2 );
827 aTmpI.pClass->WriteSrcHeader(
828 aTmpI, fOutput, pTC, nTab, RscId(), pVarName );
829 fprintf( fOutput, " );\n" );
831 i += 2; //_X, _Y oder _Widht, Height ueberlesen
833 else if( !IsDflt( rInst.pData, i )
834 && !IsValueDflt( rInst.pData, i ) )
836 aTmpI = GetInstData( rInst.pData, i, TRUE );
838 if( aTmpI.IsInst() )
840 const char * pName = pHS->getString( pVarTypeList[ i ].nVarName ).getStr();
842 for( n = 0; n < nTab; n++ )
843 fputc( '\t', fOutput );
844 fprintf( fOutput, "%s", pName );
845 fprintf( fOutput, " = " );
846 aTmpI.pClass->WriteSrcHeader(
847 aTmpI, fOutput, pTC, nTab, RscId(), pName );
848 fprintf( fOutput, ";\n" );
854 return;
857 /*************************************************************************
859 |* RscClass::WriteInstRc()
861 |* Beschreibung
863 *************************************************************************/
864 INT32 RscClass::GetCorrectValues
866 const RSCINST & rInst,
867 sal_uInt32 nVarPos,
868 sal_uInt32 nTupelIdx,
869 RscTypCont * pTC
872 INT32 nLang = 0;
873 INT32 nBaseValue;
875 // Basiswert holen
876 RSCINST aTmpI = GetInstData( rInst.pData, nVarPos, TRUE );
877 aTmpI.pClass->GetNumber( aTmpI, &nBaseValue );
879 // Sprach Delta holen
880 aTmpI = rInst.pClass->GetVariable( rInst, nRsc_DELTALANG, RSCINST() );
881 if( aTmpI.IsInst() )
883 RscWriteRc aMem;
884 aTmpI.pClass->WriteRc( aTmpI, aMem, pTC, 0, FALSE );
885 nLang = (INT32)aMem.GetShort( nTupelIdx * sizeof(sal_uInt16) );
888 return nLang + nBaseValue;
891 ERRTYPE RscClass::WriteInstRc
893 const RSCINST & rInst,
894 RscWriteRc & rMem,
895 RscTypCont * pTC,
896 sal_uInt32 nDeep,
897 BOOL bExtra
900 sal_uInt32 i = 0;
901 ERRTYPE aError;
902 RSCINST aTmpI;
903 sal_uInt32 nMaskOff = 0;// Offset um Maskenfeld zu addressieren
905 // Wenn eine Variable Maskierung hat, dann Maskenfeld
906 for( i = 0; i < nEntries; i++ )
908 if( pVarTypeList[ i ].nMask )
910 nMaskOff = rMem.Size();
911 rMem.Put( sal_uInt32(0) );
912 break;
916 for( i = 0; i < nEntries && aError.IsOk(); i++ )
918 if( !((VAR_NODATAINST | VAR_NORC) & pVarTypeList[ i ].nVarType ))
920 if( pVarTypeList[ i ].nMask )
922 if( !IsDflt( rInst.pData, i ) )
924 if( nRsc_X == pVarTypeList[ i ].nVarName )
926 INT32 nVal = GetCorrectValues( rInst, i, 0, pTC );
927 rMem.Put( nVal );
929 else if( nRsc_Y == pVarTypeList[ i ].nVarName )
931 INT32 nVal = GetCorrectValues( rInst, i, 1, pTC );
932 rMem.Put( nVal );
934 else if( nRsc_WIDTH == pVarTypeList[ i ].nVarName )
936 INT32 nVal = GetCorrectValues( rInst, i, 2, pTC );
937 rMem.Put( nVal );
939 else if( nRsc_HEIGHT == pVarTypeList[ i ].nVarName )
941 INT32 nVal = GetCorrectValues( rInst, i, 3, pTC );
942 rMem.Put( nVal );
944 else
946 aTmpI = GetInstData( rInst.pData, i, TRUE );
947 // Nur an Variable Extradata bExtra nicht auf FALSE
948 // setzen
949 aError = aTmpI.pClass->
950 WriteRcHeader( aTmpI, rMem, pTC,
951 RscId(), nDeep,
952 (nRsc_EXTRADATA
953 == pVarTypeList[ i ].nVarName)
954 ? bExtra : FALSE );
956 sal_uInt32 nMask = rMem.GetLong( nMaskOff );
957 nMask |= pVarTypeList[ i ].nMask;
958 rMem.PutAt( nMaskOff, nMask );
961 else{
962 if( IsDflt( rInst.pData, i ) )
964 aTmpI.pClass = pVarTypeList[ i ].pClass;
965 aTmpI.pData = GetDfltData( i );
967 else
968 aTmpI = GetInstData( rInst.pData, i, TRUE );
969 // Nur an Variable Extradata bExtra nicht auf FALSE
970 // setzen
971 aError = aTmpI.pClass->
972 WriteRcHeader( aTmpI, rMem, pTC,
973 RscId(), nDeep,
974 (nRsc_EXTRADATA
975 == pVarTypeList[ i ].nVarName)
976 ? bExtra : FALSE );
981 return( aError );
984 /*************************************************************************
986 |* RscClass::WriteRc()
988 |* Beschreibung
990 *************************************************************************/
991 ERRTYPE RscClass::WriteRc
993 const RSCINST & rInst,
994 RscWriteRc & rMem,
995 RscTypCont * pTC,
996 sal_uInt32 nDeep,
997 BOOL bExtra
1000 ERRTYPE aError;
1002 aError = RscTop::WriteRc( rInst, rMem, pTC, nDeep, bExtra );
1003 if( aError.IsOk() )
1004 aError = WriteInstRc( rInst, rMem, pTC, nDeep, bExtra );
1006 return( aError );
1009 /*************************************************************************
1011 |* RscClass::WriteSyntax()
1013 |* Beschreibung
1015 *************************************************************************/
1016 void RscClass::WriteSyntax( FILE * fOutput, RscTypCont * pTC )
1018 RscTop::WriteSyntax( fOutput, pTC );
1020 sal_uInt32 i;
1021 // Wenn eine Variable Maskierung hat, dann Maskenfeld
1022 fprintf( fOutput, "\t//%s\n", pHS->getString( GetId() ).getStr() );
1023 for( i = 0; i < nEntries; i++ )
1025 fprintf( fOutput, "\t%s", pHS->getString( pVarTypeList[ i ].nVarName ).getStr() );
1026 sal_uInt32 n = strlen( pHS->getString( pVarTypeList[ i ].nVarName ).getStr() );
1027 while( n < 20 )
1029 putc( ' ', fOutput );
1030 n++;
1032 fprintf( fOutput, " = %s;\n",
1033 pHS->getString( pVarTypeList[ i ].pClass->GetId() ).getStr() );
1037 //==================================================================
1038 void RscClass::WriteRcAccess
1040 FILE * fOutput,
1041 RscTypCont * /*pTC*/,
1042 const char * pName
1045 fprintf( fOutput, "\t\tSet%s( %s ", pName, pHS->getString( GetId() ).getStr() );
1046 fprintf( fOutput, "%s ", aCallPar2.GetBuffer() );
1047 fprintf( fOutput, "ResId( (RSHEADER_TYPE*)(pResData+nOffset) ) ) );\n" );
1048 fprintf( fOutput, "\t\tnOffset += GetObjSizeRes( (RSHEADER_TYPE*)(pResData+nOffset) );\n" );
1051 //==================================================================
1052 void RscClass::WriteRcCtor( FILE * fOutput, RscTypCont * pTC )
1054 if( GetId() != InvalidAtom )
1056 // Konstruktor
1057 fprintf( fOutput, "%s::%s%s bFreeResource )",
1058 pHS->getString( GetId() ).getStr(),
1059 pHS->getString( GetId() ).getStr(),
1060 aCallParType.GetBuffer() );
1061 if( GetSuperClass() )
1063 // Superaufruf
1064 fprintf( fOutput, "\n\t: %s", pHS->getString( GetSuperClass()->GetId() ).getStr() );
1065 fprintf( fOutput, "%s", GetSuperClass()->aCallPar1.GetBuffer() );
1066 fprintf( fOutput, " rResId.SetRT2( 0x%lx ) )",
1067 sal::static_int_cast< unsigned long >(GetTypId()) );
1069 fprintf( fOutput, "\n{\n" );
1070 fprintf( fOutput, "\tsal_uInt32\tnObjMask;\n" );
1071 fprintf( fOutput, "\tsal_uInt32\tnOffset = 0;\n" );
1072 fprintf( fOutput, "\tBYTE *\tpResData;\n\n" );
1073 fprintf( fOutput, "\tpResData = (BYTE *)GetClassRes();\n\n" );
1074 fprintf( fOutput, "\tnObjMask = *(sal_uInt32*)pResData;\n" );
1075 fprintf( fOutput, "\tnOffset += 4;\n\n" );
1077 for( sal_uInt32 i = 0; i < nEntries; i++ )
1079 if( !((VAR_NODATAINST | VAR_NORC) & pVarTypeList[ i ].nVarType ))
1081 fprintf( fOutput, "\tif( nObjMask & 0x%lx )\n\t{\n",
1082 sal::static_int_cast< unsigned long >(
1083 pVarTypeList[ i ].nMask) );
1085 pVarTypeList[ i ].pClass->WriteRcAccess( fOutput, pTC,
1086 pHS->getString( pVarTypeList[ i ].nVarName ).getStr() );
1088 fprintf( fOutput, "\t}\n" );
1091 fprintf( fOutput, "\tIncrementRes( nOffset );\n" );
1092 fprintf( fOutput, "\tif( bFreeResource )\n" );
1093 fprintf( fOutput, "\t\tFreeResource();\n" );
1094 fprintf( fOutput, "}\n\n" );
1098 /*************************************************************************
1100 |* RscSysDepend::RscSysDepend()
1102 |* Beschreibung
1104 *************************************************************************/
1105 RscSysDepend::RscSysDepend( Atom nId, sal_uInt32 nTypeId, RscTop * pSuper )
1106 : RscClass( nId, nTypeId, pSuper )
1109 /*************************************************************************
1111 |* RscSysDepend::WriteRc()
1113 |* Beschreibung
1115 *************************************************************************/
1116 ERRTYPE RscSysDepend::WriteSysDependRc( const RSCINST & rInst, RscWriteRc & rMem,
1117 RscTypCont * pTC, sal_uInt32 nDeep, BOOL bExtra, BOOL bFirst )
1119 sal_uInt32 nId = 0xFFFFFFFF;
1120 ERRTYPE aError;
1121 RSCINST aFileName;
1123 //Instanz mit dem Dateinamen "FILENAME" holen
1124 aFileName = RscClass::GetCopyVar( rInst, pHS->getID( "FILE", true ) );
1125 if( aFileName.IsInst() )
1127 RscWriteRc aTmpMem;
1128 aError = aFileName.pClass->WriteRcHeader( aFileName, aTmpMem, pTC,
1129 RscId(), nDeep, bExtra );
1130 // Obsolete - need changes in VCL
1131 rMem.Put( sal_uInt32(0) );
1133 // Identifier schreiben
1134 if( aTmpMem.Size() && pTC && (*aTmpMem.GetUTF8( 0 ) != '\0') )
1136 nId = pTC->PutSysName( rInst.pClass->GetTypId(),
1137 aTmpMem.GetUTF8( 0 ),
1138 0, 0, bFirst );
1140 rMem.Put( nId );
1141 aError = aFileName.pClass->WriteRcHeader( aFileName, rMem, pTC,
1142 RscId(), nDeep, bExtra );
1144 else
1145 aError = ERR_ERROR;
1147 return( aError );
1150 /*************************************************************************
1152 |* RscSysDepend::WriteRc()
1154 |* Beschreibung
1156 *************************************************************************/
1157 ERRTYPE RscSysDepend::WriteRc( const RSCINST & rInst, RscWriteRc & rMem,
1158 RscTypCont * pTC, sal_uInt32 nDeep, BOOL bExtra )
1160 ERRTYPE aError = RscClass::WriteRc( rInst, rMem, pTC, nDeep, bExtra );
1162 if( this == rInst.pClass )
1163 // nur wenn es eigen Klasse ist
1164 aError = WriteSysDependRc( rInst, rMem, pTC, nDeep, bExtra );
1165 return aError;
1168 /*************************************************************************
1170 |* RscFirstSysDepend::RscFirstSysDepend()
1172 |* Beschreibung
1174 *************************************************************************/
1175 RscFirstSysDepend::RscFirstSysDepend( Atom nId, sal_uInt32 nTypeId,
1176 RscTop * pSuper )
1177 : RscSysDepend( nId, nTypeId, pSuper )
1180 /*************************************************************************
1182 |* RscFirstSysDepend::WriteRc()
1184 |* Beschreibung
1186 *************************************************************************/
1187 ERRTYPE RscFirstSysDepend::WriteRc( const RSCINST & rInst, RscWriteRc & rMem,
1188 RscTypCont * pTC, sal_uInt32 nDeep, BOOL bExtra )
1190 ERRTYPE aError = RscClass::WriteRc( rInst, rMem, pTC, nDeep, bExtra );
1191 aError = WriteSysDependRc( rInst, rMem, pTC, nDeep, bExtra, TRUE );
1192 return aError;
1195 /*************************************************************************
1197 |* RscTupel::RscTupel()
1199 |* Beschreibung
1201 *************************************************************************/
1202 RscTupel::RscTupel( Atom nId, sal_uInt32 nTypeId, RscTop * pSuper )
1203 : RscClass( nId, nTypeId, pSuper )
1206 /*************************************************************************
1208 |* RscTupel::GetTupelVar()
1210 |* Beschreibung
1212 *************************************************************************/
1213 RSCINST RscTupel::GetTupelVar( const RSCINST & rInst, sal_uInt32 nPos,
1214 const RSCINST & rInitInst )
1216 if( nPos >= nEntries )
1218 return RSCINST();
1220 else
1221 return GetVariable( rInst, pVarTypeList[ nPos ].nVarName, rInitInst );
1224 /*************************************************************************
1226 |* RscTupel::WriteSrc()
1228 |* Beschreibung
1230 *************************************************************************/
1231 void RscTupel::WriteSrc( const RSCINST & rInst, FILE * fOutput,
1232 RscTypCont * pTC, sal_uInt32 nTab,
1233 const char * pVarName )
1235 sal_uInt32 i = 0;
1236 RSCINST aTmpI;
1238 RscTop::WriteSrc( rInst, fOutput, pTC, nTab, pVarName );
1240 fprintf( fOutput, "< " );
1241 for( i = 0; i < nEntries; i++ )
1243 if( !(VAR_HIDDEN & pVarTypeList[ i ].nVarType) )
1245 if( !IsDflt( rInst.pData, i )
1246 && !IsValueDflt( rInst.pData, i ) )
1248 aTmpI = GetInstData( rInst.pData, i, TRUE );
1250 if( aTmpI.IsInst() )
1251 aTmpI.pClass->WriteSrcHeader(
1252 aTmpI, fOutput, pTC, nTab, RscId(), pVarName );
1253 else
1254 fprintf( fOutput, "Default" );
1256 else
1257 fprintf( fOutput, "Default" );
1258 fprintf( fOutput, "; " );
1261 fprintf( fOutput, ">" );
1263 return;