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.
37 // Programmabhaengige Includes.
39 #include <rscclass.hxx>
41 #include <tools/fsys.hxx>
42 #include <tools/rcid.h>
45 /****************** C O D E **********************************************/
46 /****************** R s c C l a s s **************************************/
47 /*************************************************************************
49 |* RscClass::RscClass()
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
)
61 nSuperSize
= RscTop::Size();
62 nSize
= nSuperSize
+ ALIGNED_SIZE( sizeof( RscClassInst
) );
65 /*************************************************************************
67 |* RscClass::Pre_dtor()
70 |* Ersterstellung MM 25.05.91
71 |* Letzte Aenderung MM 25.05.91
73 *************************************************************************/
74 void RscClass::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()
98 |* Ersterstellung MM 25.05.91
99 |* Letzte Aenderung MM 25.05.91
101 *************************************************************************/
102 RscClass::~RscClass()
105 rtl_freeMemory( (void *)pVarTypeList
);
108 /*************************************************************************
110 |* RscClass::GetClassType()
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()
127 |* Ersterstellung MM 15.04.91
128 |* Letzte Aenderung MM 15.04.91
130 *************************************************************************/
131 RSCINST
RscClass::GetInstData
140 aInst
.pClass
= pVarTypeList
[ nEle
].pClass
;
143 if( VAR_NODATAINST
& pVarTypeList
[ nEle
].nVarType
)
150 aInst
.pData
= GetCopyVar(
152 pVarTypeList
[ nEle
].nDataBaseName
155 aInst
.pData
= GetVariable(
157 pVarTypeList
[ nEle
].nDataBaseName
,
161 else if( VAR_POINTER
& pVarTypeList
[ nEle
].nVarType
)
163 if( VAR_EXTENDABLE
& pVarTypeList
[ nEle
].nVarType
)
165 (pData
+ pVarTypeList
[ nEle
].nOffset
);
167 aInst
.pData
= *(CLASS_DATA
*)
168 (pData
+ pVarTypeList
[ nEle
].nOffset
);
171 aInst
.pData
= pData
+ pVarTypeList
[ nEle
].nOffset
;
176 /*************************************************************************
178 |* RscClass::GetInstDflt()
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()
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
);
206 pClass
->nVarDflt
|= ((sal_uLong
)1 << nEle
);
208 pClass
->nVarDflt
&= ~((sal_uLong
)1 << nEle
);
211 /*************************************************************************
213 |* RscClass::IsDflt()
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
;
225 pClass
= (RscClassInst
*)(pData
+ nSuperSize
);
226 if( pClass
->nVarDflt
& ((sal_uLong
)1 << nEle
) )
231 //Variablenname ist Default
234 aTmpI = GetInstData( pData, nEle, sal_True );
235 if( aTmpI.IsInst() && !aTmpI.pClass->IsDefault( aTmpI ) )
242 /*************************************************************************
244 |* RscClass::Create()
247 |* Ersterstellung MM 03.04.91
248 |* Letzte Aenderung MM 03.04.91
250 *************************************************************************/
251 RSCINST
RscClass::Create
254 const RSCINST
& rDflt
,
261 RSCINST aMemInst
, aDfltI
;
266 aInst
.pData
= (CLASS_DATA
) rtl_allocateMemory( Size() );
270 if( !bOwnClass
&& rDflt
.IsInst() )
271 bOwnClass
= rDflt
.pClass
->InHierarchy( this );
273 RscTop::Create( &aInst
, rDflt
, bOwnClass
);
276 ((RscClassInst
*)(aInst
.pData
+ nSuperSize
))->nVarDflt
=
277 ((RscClassInst
*)(rDflt
.pData
+ nSuperSize
))->nVarDflt
;
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
;
296 ppData
= (CLASS_DATA
* )
297 (aInst
.pData
+ pVarTypeList
[ i
].nOffset
);
299 if( aDfltI
.IsInst() )
301 aMemInst
= pVarTypeList
[ i
].pClass
->Create( NULL
, aDfltI
);
302 *ppData
= aMemInst
.pData
;
307 aMemInst
= GetInstData( aInst
.pData
, i
, sal_True
);
308 aMemInst
= aMemInst
.pClass
->Create( &aMemInst
, aDfltI
);
315 /*************************************************************************
317 |* RscClass::Destroy()
321 *************************************************************************/
322 void RscClass::Destroy( const RSCINST
& rInst
)
326 RscTop::Destroy( rInst
);
328 for( i
= 0; i
< nEntries
; i
++ )
330 if( !(pVarTypeList
[ i
].nVarType
& VAR_NODATAINST
) )
334 aTmpI
= GetInstData( rInst
.pData
, i
, sal_True
);
338 aTmpI
.pClass
->Destroy( aTmpI
);
339 if( pVarTypeList
[ i
].nVarType
& VAR_POINTER
)
341 // Speicher freigeben
342 rtl_freeMemory( aTmpI
.pData
);
349 /*************************************************************************
351 |* RscClass::SetVariable()
355 *************************************************************************/
356 ERRTYPE
RscClass::SetVariable
367 pVarTypeList
= (VARTYPE_STRUCT
*)
368 rtl_reallocateMemory( (void *)pVarTypeList
,
369 ((nEntries
+1) * sizeof( VARTYPE_STRUCT
)) );
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
;
381 pVarTypeList
[ nEntries
].pDefault
= pDflt
->pData
;
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
);
396 nSize
+= sizeof( CLASS_DATA
);
399 nSize
+= pClass
->Size();
403 if( nEntries
> (sizeof( sal_uLong
) * 8) )
405 // Bereich fuer Default zu klein
411 /*************************************************************************
413 |* RscClass::EnumVariable()
417 *************************************************************************/
418 void RscClass::EnumVariables( void * pData
, VarEnumCallbackProc pProc
)
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()
437 *************************************************************************/
438 RSCINST
RscClass::GetVariable
440 const RSCINST
& rInst
,
442 const RSCINST
& rInitInst
,
444 RscTop
* pCreateClass
450 while( i
< nEntries
&& pVarTypeList
[ i
].nVarName
!= nVarName
)
454 if( VAR_NODATAINST
& pVarTypeList
[ i
].nVarType
)
456 aTmpI
= GetVariable( rInst
,
457 pVarTypeList
[ i
].nDataBaseName
,
459 aTmpI
.pClass
= pVarTypeList
[ i
].pClass
;
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
);
475 if( aDefInst
.IsInst() )
477 aTmpI
.pClass
->Destroy( aTmpI
);
478 aTmpI
.pClass
->Create( &aTmpI
, aDefInst
);
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
);
490 *pInst
= aTmpI
.pClass
->Create( NULL
, aDefInst
);
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
);
507 return( RscTop::GetVariable( rInst
, nVarName
, rInitInst
,
508 bInitDflt
, pCreateClass
) );
511 /*************************************************************************
513 |* RscClass::GetCopyVar()
517 *************************************************************************/
518 RSCINST
RscClass::GetCopyVar
520 const RSCINST
& rInst
,
527 while( i
< nEntries
&& pVarTypeList
[ i
].nVarName
!= nVarName
)
532 if( VAR_NODATAINST
& pVarTypeList
[ i
].nVarType
)
534 aVarI
= GetCopyVar( rInst
, pVarTypeList
[ i
].nDataBaseName
);
535 aVarI
.pClass
= pVarTypeList
[ i
].pClass
;
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
);
546 aVarI
= GetInstData( rInst
.pData
, i
, sal_True
);
552 return RscTop::GetCopyVar( rInst
, nVarName
);
555 /*************************************************************************
557 |* RscClass::IsConsistent()
561 *************************************************************************/
562 sal_Bool
RscClass::IsConsistent( const RSCINST
& rInst
, RscInconsList
* pList
)
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
);
577 if( ! aTmpI
.pClass
->IsConsistent( aTmpI
, pList
) )
585 /*************************************************************************
587 |* RscClass::SetToDefault()
591 *************************************************************************/
592 void RscClass::SetToDefault( const RSCINST
& rInst
)
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
);
608 aTmpI
.pClass
->SetToDefault( aTmpI
);
611 pClass
->nVarDflt
= ~((sal_uLong
)0); // alles auf Default
613 RscTop::SetToDefault( rInst
);
616 /*************************************************************************
618 |* RscClass::IsDefault()
622 *************************************************************************/
623 sal_Bool
RscClass::IsDefault( const RSCINST
& rInst
)
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
) )
637 return( RscTop::IsDefault( rInst
) );
640 /*************************************************************************
642 |* RscClass::GetDefault()
646 *************************************************************************/
647 RSCINST
RscClass::GetDefault( Atom nVarId
)
652 while( i
< nEntries
&& pVarTypeList
[ i
].nVarName
!= nVarId
)
658 aTmpI
.pClass
= pVarTypeList
[ i
].pClass
;
659 aTmpI
.pData
= GetDfltData( i
);
663 return( RscTop::GetDefault( nVarId
) );
666 /*************************************************************************
668 |* RscClass::IsValueDflt()
672 *************************************************************************/
673 sal_Bool
RscClass::IsValueDflt( CLASS_DATA pData
, sal_uInt32 nEle
)
677 aTmpI
= GetInstData( pData
, nEle
, sal_True
);
681 if( VAR_SVDYNAMIC
& pVarTypeList
[ nEle
].nVarType
)
684 if( aTmpI
.pClass
== pVarTypeList
[ nEle
].pClass
)
685 //sie haben auch die gleiche Klasse
686 return aTmpI
.pClass
->IsValueDefault( aTmpI
, GetDfltData( nEle
) );
693 /*************************************************************************
695 |* RscClass::IsValueDefault()
699 *************************************************************************/
700 sal_Bool
RscClass::IsValueDefault( const RSCINST
& rInst
, CLASS_DATA pDef
)
706 if( !RscTop::IsValueDefault( rInst
, pDef
) )
711 for( i
= 0; i
< nEntries
; i
++ )
713 aTmpI
= GetInstData( rInst
.pData
, i
, sal_True
);
716 if( aTmpI
.pClass
!= pVarTypeList
[ i
].pClass
)
717 //sie haben nicht die gleiche Klasse
720 aDfltI
= GetInstData( pDef
, i
, sal_True
);
721 if( !aDfltI
.IsInst() )
722 aDfltI
.pData
= GetDfltData( i
);
724 if( !aTmpI
.pClass
->IsValueDefault( aTmpI
, aDfltI
.pData
) )
735 /*************************************************************************
737 |* RscClass::SetDefault()
741 *************************************************************************/
742 void RscClass::SetDefault( const RSCINST
& rInst
, Atom nVarName
)
747 while( i
< nEntries
&& pVarTypeList
[ i
].nVarName
!= nVarName
)
752 aTmpI
= GetInstData( rInst
.pData
, i
, sal_True
);
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()
772 *************************************************************************/
773 void RscClass::WriteSrc
775 const RSCINST
& rInst
,
779 const char * pVarName
782 sal_uInt32 i
= 0, n
= 0;
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 = " );
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
);
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" );
854 /*************************************************************************
856 |* RscClass::WriteInstRc()
860 *************************************************************************/
861 sal_Int32
RscClass::GetCorrectValues
863 const RSCINST
& rInst
,
865 sal_uInt32 nTupelIdx
,
870 sal_Int32 nBaseValue
;
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() );
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
,
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) );
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
);
926 else if( nRsc_Y
== pVarTypeList
[ i
].nVarName
)
928 sal_Int32 nVal
= GetCorrectValues( rInst
, i
, 1, pTC
);
931 else if( nRsc_WIDTH
== pVarTypeList
[ i
].nVarName
)
933 sal_Int32 nVal
= GetCorrectValues( rInst
, i
, 2, pTC
);
936 else if( nRsc_HEIGHT
== pVarTypeList
[ i
].nVarName
)
938 sal_Int32 nVal
= GetCorrectValues( rInst
, i
, 3, pTC
);
943 aTmpI
= GetInstData( rInst
.pData
, i
, sal_True
);
944 // Nur an Variable Extradata bExtra nicht auf sal_False
946 aError
= aTmpI
.pClass
->
947 WriteRcHeader( aTmpI
, rMem
, pTC
,
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
);
959 if( IsDflt( rInst
.pData
, i
) )
961 aTmpI
.pClass
= pVarTypeList
[ i
].pClass
;
962 aTmpI
.pData
= GetDfltData( i
);
965 aTmpI
= GetInstData( rInst
.pData
, i
, sal_True
);
966 // Nur an Variable Extradata bExtra nicht auf sal_False
968 aError
= aTmpI
.pClass
->
969 WriteRcHeader( aTmpI
, rMem
, pTC
,
972 == pVarTypeList
[ i
].nVarName
)
973 ? bExtra
: sal_False
);
981 /*************************************************************************
983 |* RscClass::WriteRc()
987 *************************************************************************/
988 ERRTYPE
RscClass::WriteRc
990 const RSCINST
& rInst
,
999 aError
= RscTop::WriteRc( rInst
, rMem
, pTC
, nDeep
, bExtra
);
1001 aError
= WriteInstRc( rInst
, rMem
, pTC
, nDeep
, bExtra
);
1006 /*************************************************************************
1008 |* RscClass::WriteSyntax()
1012 *************************************************************************/
1013 void RscClass::WriteSyntax( FILE * fOutput
, RscTypCont
* pTC
)
1015 RscTop::WriteSyntax( fOutput
, pTC
);
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() );
1026 putc( ' ', fOutput
);
1029 fprintf( fOutput
, " = %s;\n",
1030 pHS
->getString( pVarTypeList
[ i
].pClass
->GetId() ).getStr() );
1034 //==================================================================
1035 void RscClass::WriteRcAccess
1038 RscTypCont
* /*pTC*/,
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
)
1054 fprintf( fOutput
, "%s::%s%s bFreeResource )",
1055 pHS
->getString( GetId() ).getStr(),
1056 pHS
->getString( GetId() ).getStr(),
1057 aCallParType
.GetBuffer() );
1058 if( GetSuperClass() )
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()
1101 *************************************************************************/
1102 RscSysDepend::RscSysDepend( Atom nId
, sal_uInt32 nTypeId
, RscTop
* pSuper
)
1103 : RscClass( nId
, nTypeId
, pSuper
)
1106 /*************************************************************************
1108 |* RscSysDepend::WriteRc()
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;
1120 //Instanz mit dem Dateinamen "FILENAME" holen
1121 aFileName
= RscClass::GetCopyVar( rInst
, pHS
->getID( "FILE", true ) );
1122 if( aFileName
.IsInst() )
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 ),
1138 aError
= aFileName
.pClass
->WriteRcHeader( aFileName
, rMem
, pTC
,
1139 RscId(), nDeep
, bExtra
);
1147 /*************************************************************************
1149 |* RscSysDepend::WriteRc()
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
);
1165 /*************************************************************************
1167 |* RscFirstSysDepend::RscFirstSysDepend()
1171 *************************************************************************/
1172 RscFirstSysDepend::RscFirstSysDepend( Atom nId
, sal_uInt32 nTypeId
,
1174 : RscSysDepend( nId
, nTypeId
, pSuper
)
1177 /*************************************************************************
1179 |* RscFirstSysDepend::WriteRc()
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
);
1192 /*************************************************************************
1194 |* RscTupel::RscTupel()
1198 *************************************************************************/
1199 RscTupel::RscTupel( Atom nId
, sal_uInt32 nTypeId
, RscTop
* pSuper
)
1200 : RscClass( nId
, nTypeId
, pSuper
)
1203 /*************************************************************************
1205 |* RscTupel::GetTupelVar()
1209 *************************************************************************/
1210 RSCINST
RscTupel::GetTupelVar( const RSCINST
& rInst
, sal_uInt32 nPos
,
1211 const RSCINST
& rInitInst
)
1213 if( nPos
>= nEntries
)
1218 return GetVariable( rInst
, pVarTypeList
[ nPos
].nVarName
, rInitInst
);
1221 /*************************************************************************
1223 |* RscTupel::WriteSrc()
1227 *************************************************************************/
1228 void RscTupel::WriteSrc( const RSCINST
& rInst
, FILE * fOutput
,
1229 RscTypCont
* pTC
, sal_uInt32 nTab
,
1230 const char * pVarName
)
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
);
1251 fprintf( fOutput
, "Default" );
1254 fprintf( fOutput
, "Default" );
1255 fprintf( fOutput
, "; " );
1258 fprintf( fOutput
, ">" );