1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: rscclass.cxx,v $
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.
40 // Programmabhaengige Includes.
42 #include <rscclass.hxx>
44 #include <tools/fsys.hxx>
45 #include <tools/rcid.h>
48 /****************** C O D E **********************************************/
49 /****************** R s c C l a s s **************************************/
50 /*************************************************************************
52 |* RscClass::RscClass()
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
)
64 nSuperSize
= RscTop::Size();
65 nSize
= nSuperSize
+ ALIGNED_SIZE( sizeof( RscClassInst
) );
68 /*************************************************************************
70 |* RscClass::Pre_dtor()
73 |* Ersterstellung MM 25.05.91
74 |* Letzte Aenderung MM 25.05.91
76 *************************************************************************/
77 void RscClass::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()
101 |* Ersterstellung MM 25.05.91
102 |* Letzte Aenderung MM 25.05.91
104 *************************************************************************/
105 RscClass::~RscClass()
108 rtl_freeMemory( (void *)pVarTypeList
);
111 /*************************************************************************
113 |* RscClass::GetClassType()
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()
130 |* Ersterstellung MM 15.04.91
131 |* Letzte Aenderung MM 15.04.91
133 *************************************************************************/
134 RSCINST
RscClass::GetInstData
143 aInst
.pClass
= pVarTypeList
[ nEle
].pClass
;
146 if( VAR_NODATAINST
& pVarTypeList
[ nEle
].nVarType
)
153 aInst
.pData
= GetCopyVar(
155 pVarTypeList
[ nEle
].nDataBaseName
158 aInst
.pData
= GetVariable(
160 pVarTypeList
[ nEle
].nDataBaseName
,
164 else if( VAR_POINTER
& pVarTypeList
[ nEle
].nVarType
)
166 if( VAR_EXTENDABLE
& pVarTypeList
[ nEle
].nVarType
)
168 (pData
+ pVarTypeList
[ nEle
].nOffset
);
170 aInst
.pData
= *(CLASS_DATA
*)
171 (pData
+ pVarTypeList
[ nEle
].nOffset
);
174 aInst
.pData
= pData
+ pVarTypeList
[ nEle
].nOffset
;
179 /*************************************************************************
181 |* RscClass::GetInstDflt()
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()
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
);
209 pClass
->nVarDflt
|= ((ULONG
)1 << nEle
);
211 pClass
->nVarDflt
&= ~((ULONG
)1 << nEle
);
214 /*************************************************************************
216 |* RscClass::IsDflt()
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
;
228 pClass
= (RscClassInst
*)(pData
+ nSuperSize
);
229 if( pClass
->nVarDflt
& ((ULONG
)1 << nEle
) )
234 //Variablenname ist Default
237 aTmpI = GetInstData( pData, nEle, TRUE );
238 if( aTmpI.IsInst() && !aTmpI.pClass->IsDefault( aTmpI ) )
245 /*************************************************************************
247 |* RscClass::Create()
250 |* Ersterstellung MM 03.04.91
251 |* Letzte Aenderung MM 03.04.91
253 *************************************************************************/
254 RSCINST
RscClass::Create
257 const RSCINST
& rDflt
,
264 RSCINST aMemInst
, aDfltI
;
269 aInst
.pData
= (CLASS_DATA
) rtl_allocateMemory( Size() );
273 if( !bOwnClass
&& rDflt
.IsInst() )
274 bOwnClass
= rDflt
.pClass
->InHierarchy( this );
276 RscTop::Create( &aInst
, rDflt
, bOwnClass
);
279 ((RscClassInst
*)(aInst
.pData
+ nSuperSize
))->nVarDflt
=
280 ((RscClassInst
*)(rDflt
.pData
+ nSuperSize
))->nVarDflt
;
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
;
299 ppData
= (CLASS_DATA
* )
300 (aInst
.pData
+ pVarTypeList
[ i
].nOffset
);
302 if( aDfltI
.IsInst() )
304 aMemInst
= pVarTypeList
[ i
].pClass
->Create( NULL
, aDfltI
);
305 *ppData
= aMemInst
.pData
;
310 aMemInst
= GetInstData( aInst
.pData
, i
, TRUE
);
311 aMemInst
= aMemInst
.pClass
->Create( &aMemInst
, aDfltI
);
318 /*************************************************************************
320 |* RscClass::Destroy()
324 *************************************************************************/
325 void RscClass::Destroy( const RSCINST
& rInst
)
329 RscTop::Destroy( rInst
);
331 for( i
= 0; i
< nEntries
; i
++ )
333 if( !(pVarTypeList
[ i
].nVarType
& VAR_NODATAINST
) )
337 aTmpI
= GetInstData( rInst
.pData
, i
, TRUE
);
341 aTmpI
.pClass
->Destroy( aTmpI
);
342 if( pVarTypeList
[ i
].nVarType
& VAR_POINTER
)
344 // Speicher freigeben
345 rtl_freeMemory( aTmpI
.pData
);
352 /*************************************************************************
354 |* RscClass::SetVariable()
358 *************************************************************************/
359 ERRTYPE
RscClass::SetVariable
370 pVarTypeList
= (VARTYPE_STRUCT
*)
371 rtl_reallocateMemory( (void *)pVarTypeList
,
372 ((nEntries
+1) * sizeof( VARTYPE_STRUCT
)) );
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
;
384 pVarTypeList
[ nEntries
].pDefault
= pDflt
->pData
;
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
);
399 nSize
+= sizeof( CLASS_DATA
);
402 nSize
+= pClass
->Size();
406 if( nEntries
> (sizeof( ULONG
) * 8) )
408 // Bereich fuer Default zu klein
414 /*************************************************************************
416 |* RscClass::EnumVariable()
420 *************************************************************************/
421 void RscClass::EnumVariables( void * pData
, VarEnumCallbackProc pProc
)
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()
440 *************************************************************************/
441 RSCINST
RscClass::GetVariable
443 const RSCINST
& rInst
,
445 const RSCINST
& rInitInst
,
447 RscTop
* pCreateClass
453 while( i
< nEntries
&& pVarTypeList
[ i
].nVarName
!= nVarName
)
457 if( VAR_NODATAINST
& pVarTypeList
[ i
].nVarType
)
459 aTmpI
= GetVariable( rInst
,
460 pVarTypeList
[ i
].nDataBaseName
,
462 aTmpI
.pClass
= pVarTypeList
[ i
].pClass
;
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
);
478 if( aDefInst
.IsInst() )
480 aTmpI
.pClass
->Destroy( aTmpI
);
481 aTmpI
.pClass
->Create( &aTmpI
, aDefInst
);
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
);
493 *pInst
= aTmpI
.pClass
->Create( NULL
, aDefInst
);
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
);
510 return( RscTop::GetVariable( rInst
, nVarName
, rInitInst
,
511 bInitDflt
, pCreateClass
) );
514 /*************************************************************************
516 |* RscClass::GetCopyVar()
520 *************************************************************************/
521 RSCINST
RscClass::GetCopyVar
523 const RSCINST
& rInst
,
530 while( i
< nEntries
&& pVarTypeList
[ i
].nVarName
!= nVarName
)
535 if( VAR_NODATAINST
& pVarTypeList
[ i
].nVarType
)
537 aVarI
= GetCopyVar( rInst
, pVarTypeList
[ i
].nDataBaseName
);
538 aVarI
.pClass
= pVarTypeList
[ i
].pClass
;
542 if( IsDflt( rInst
.pData
, i
) )
544 // mit Variablen Default initialiaieren
545 aVarI
= GetVariable( rInst
, nVarName
, RSCINST(), TRUE
);
546 SetVarDflt( rInst
.pData
, i
, TRUE
);
549 aVarI
= GetInstData( rInst
.pData
, i
, TRUE
);
555 return RscTop::GetCopyVar( rInst
, nVarName
);
558 /*************************************************************************
560 |* RscClass::IsConsistent()
564 *************************************************************************/
565 BOOL
RscClass::IsConsistent( const RSCINST
& rInst
, RscInconsList
* pList
)
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
);
580 if( ! aTmpI
.pClass
->IsConsistent( aTmpI
, pList
) )
588 /*************************************************************************
590 |* RscClass::SetToDefault()
594 *************************************************************************/
595 void RscClass::SetToDefault( const RSCINST
& rInst
)
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
);
611 aTmpI
.pClass
->SetToDefault( aTmpI
);
614 pClass
->nVarDflt
= ~((ULONG
)0); // alles auf Default
616 RscTop::SetToDefault( rInst
);
619 /*************************************************************************
621 |* RscClass::IsDefault()
625 *************************************************************************/
626 BOOL
RscClass::IsDefault( const RSCINST
& rInst
)
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
) )
640 return( RscTop::IsDefault( rInst
) );
643 /*************************************************************************
645 |* RscClass::GetDefault()
649 *************************************************************************/
650 RSCINST
RscClass::GetDefault( Atom nVarId
)
655 while( i
< nEntries
&& pVarTypeList
[ i
].nVarName
!= nVarId
)
661 aTmpI
.pClass
= pVarTypeList
[ i
].pClass
;
662 aTmpI
.pData
= GetDfltData( i
);
666 return( RscTop::GetDefault( nVarId
) );
669 /*************************************************************************
671 |* RscClass::IsValueDflt()
675 *************************************************************************/
676 BOOL
RscClass::IsValueDflt( CLASS_DATA pData
, sal_uInt32 nEle
)
680 aTmpI
= GetInstData( pData
, nEle
, TRUE
);
684 if( VAR_SVDYNAMIC
& pVarTypeList
[ nEle
].nVarType
)
687 if( aTmpI
.pClass
== pVarTypeList
[ nEle
].pClass
)
688 //sie haben auch die gleiche Klasse
689 return aTmpI
.pClass
->IsValueDefault( aTmpI
, GetDfltData( nEle
) );
696 /*************************************************************************
698 |* RscClass::IsValueDefault()
702 *************************************************************************/
703 BOOL
RscClass::IsValueDefault( const RSCINST
& rInst
, CLASS_DATA pDef
)
709 if( !RscTop::IsValueDefault( rInst
, pDef
) )
714 for( i
= 0; i
< nEntries
; i
++ )
716 aTmpI
= GetInstData( rInst
.pData
, i
, TRUE
);
719 if( aTmpI
.pClass
!= pVarTypeList
[ i
].pClass
)
720 //sie haben nicht die gleiche Klasse
723 aDfltI
= GetInstData( pDef
, i
, TRUE
);
724 if( !aDfltI
.IsInst() )
725 aDfltI
.pData
= GetDfltData( i
);
727 if( !aTmpI
.pClass
->IsValueDefault( aTmpI
, aDfltI
.pData
) )
738 /*************************************************************************
740 |* RscClass::SetDefault()
744 *************************************************************************/
745 void RscClass::SetDefault( const RSCINST
& rInst
, Atom nVarName
)
750 while( i
< nEntries
&& pVarTypeList
[ i
].nVarName
!= nVarName
)
755 aTmpI
= GetInstData( rInst
.pData
, i
, TRUE
);
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()
775 *************************************************************************/
776 void RscClass::WriteSrc
778 const RSCINST
& rInst
,
782 const char * pVarName
785 sal_uInt32 i
= 0, n
= 0;
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 = " );
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
);
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" );
857 /*************************************************************************
859 |* RscClass::WriteInstRc()
863 *************************************************************************/
864 INT32
RscClass::GetCorrectValues
866 const RSCINST
& rInst
,
868 sal_uInt32 nTupelIdx
,
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() );
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
,
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) );
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
);
929 else if( nRsc_Y
== pVarTypeList
[ i
].nVarName
)
931 INT32 nVal
= GetCorrectValues( rInst
, i
, 1, pTC
);
934 else if( nRsc_WIDTH
== pVarTypeList
[ i
].nVarName
)
936 INT32 nVal
= GetCorrectValues( rInst
, i
, 2, pTC
);
939 else if( nRsc_HEIGHT
== pVarTypeList
[ i
].nVarName
)
941 INT32 nVal
= GetCorrectValues( rInst
, i
, 3, pTC
);
946 aTmpI
= GetInstData( rInst
.pData
, i
, TRUE
);
947 // Nur an Variable Extradata bExtra nicht auf FALSE
949 aError
= aTmpI
.pClass
->
950 WriteRcHeader( aTmpI
, rMem
, pTC
,
953 == pVarTypeList
[ i
].nVarName
)
956 sal_uInt32 nMask
= rMem
.GetLong( nMaskOff
);
957 nMask
|= pVarTypeList
[ i
].nMask
;
958 rMem
.PutAt( nMaskOff
, nMask
);
962 if( IsDflt( rInst
.pData
, i
) )
964 aTmpI
.pClass
= pVarTypeList
[ i
].pClass
;
965 aTmpI
.pData
= GetDfltData( i
);
968 aTmpI
= GetInstData( rInst
.pData
, i
, TRUE
);
969 // Nur an Variable Extradata bExtra nicht auf FALSE
971 aError
= aTmpI
.pClass
->
972 WriteRcHeader( aTmpI
, rMem
, pTC
,
975 == pVarTypeList
[ i
].nVarName
)
984 /*************************************************************************
986 |* RscClass::WriteRc()
990 *************************************************************************/
991 ERRTYPE
RscClass::WriteRc
993 const RSCINST
& rInst
,
1002 aError
= RscTop::WriteRc( rInst
, rMem
, pTC
, nDeep
, bExtra
);
1004 aError
= WriteInstRc( rInst
, rMem
, pTC
, nDeep
, bExtra
);
1009 /*************************************************************************
1011 |* RscClass::WriteSyntax()
1015 *************************************************************************/
1016 void RscClass::WriteSyntax( FILE * fOutput
, RscTypCont
* pTC
)
1018 RscTop::WriteSyntax( fOutput
, pTC
);
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() );
1029 putc( ' ', fOutput
);
1032 fprintf( fOutput
, " = %s;\n",
1033 pHS
->getString( pVarTypeList
[ i
].pClass
->GetId() ).getStr() );
1037 //==================================================================
1038 void RscClass::WriteRcAccess
1041 RscTypCont
* /*pTC*/,
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
)
1057 fprintf( fOutput
, "%s::%s%s bFreeResource )",
1058 pHS
->getString( GetId() ).getStr(),
1059 pHS
->getString( GetId() ).getStr(),
1060 aCallParType
.GetBuffer() );
1061 if( GetSuperClass() )
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()
1104 *************************************************************************/
1105 RscSysDepend::RscSysDepend( Atom nId
, sal_uInt32 nTypeId
, RscTop
* pSuper
)
1106 : RscClass( nId
, nTypeId
, pSuper
)
1109 /*************************************************************************
1111 |* RscSysDepend::WriteRc()
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;
1123 //Instanz mit dem Dateinamen "FILENAME" holen
1124 aFileName
= RscClass::GetCopyVar( rInst
, pHS
->getID( "FILE", true ) );
1125 if( aFileName
.IsInst() )
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 ),
1141 aError
= aFileName
.pClass
->WriteRcHeader( aFileName
, rMem
, pTC
,
1142 RscId(), nDeep
, bExtra
);
1150 /*************************************************************************
1152 |* RscSysDepend::WriteRc()
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
);
1168 /*************************************************************************
1170 |* RscFirstSysDepend::RscFirstSysDepend()
1174 *************************************************************************/
1175 RscFirstSysDepend::RscFirstSysDepend( Atom nId
, sal_uInt32 nTypeId
,
1177 : RscSysDepend( nId
, nTypeId
, pSuper
)
1180 /*************************************************************************
1182 |* RscFirstSysDepend::WriteRc()
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
);
1195 /*************************************************************************
1197 |* RscTupel::RscTupel()
1201 *************************************************************************/
1202 RscTupel::RscTupel( Atom nId
, sal_uInt32 nTypeId
, RscTop
* pSuper
)
1203 : RscClass( nId
, nTypeId
, pSuper
)
1206 /*************************************************************************
1208 |* RscTupel::GetTupelVar()
1212 *************************************************************************/
1213 RSCINST
RscTupel::GetTupelVar( const RSCINST
& rInst
, sal_uInt32 nPos
,
1214 const RSCINST
& rInitInst
)
1216 if( nPos
>= nEntries
)
1221 return GetVariable( rInst
, pVarTypeList
[ nPos
].nVarName
, rInitInst
);
1224 /*************************************************************************
1226 |* RscTupel::WriteSrc()
1230 *************************************************************************/
1231 void RscTupel::WriteSrc( const RSCINST
& rInst
, FILE * fOutput
,
1232 RscTypCont
* pTC
, sal_uInt32 nTab
,
1233 const char * pVarName
)
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
);
1254 fprintf( fOutput
, "Default" );
1257 fprintf( fOutput
, "Default" );
1258 fprintf( fOutput
, "; " );
1261 fprintf( fOutput
, ">" );