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: rsccont.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 // Programmabh�ngige Includes.
41 #include <rsccont.hxx>
43 #include <tools/rcid.h>
45 /****************** C O D E **********************************************/
46 /****************** E N T R Y S T R U C T ********************************/
47 /*************************************************************************
49 |* ENTRYSTRUCT::Destroy()
52 |* Ersterstellung MM 06.08.91
53 |* Letzte Aenderung MM 06.08.91
55 *************************************************************************/
56 void ENTRY_STRUCT::Destroy()
60 aInst
.pClass
->Destroy( aInst
);
61 rtl_freeMemory( aInst
.pData
);
65 /****************** R s c B a s e C o n t ********************************/
66 /*************************************************************************
68 |* RscBaseCont::RscBaseCont()
71 |* Ersterstellung MM 25.05.91
72 |* Letzte Aenderung MM 25.05.91
74 *************************************************************************/
75 RscBaseCont::RscBaseCont( Atom nId
, sal_uInt32 nTypeId
, RscTop
* pSuper
,
77 : RscTop( nId
, nTypeId
, pSuper
),
83 nOffInstData
= RscTop::Size();
84 nSize
= nOffInstData
+ ALIGNED_SIZE( sizeof( RscBaseContInst
) );
87 /*************************************************************************
89 |* RscBaseCont::~RscBaseCont()
92 |* Ersterstellung MM 25.05.91
93 |* Letzte Aenderung MM 25.05.91
95 *************************************************************************/
96 RscBaseCont::~RscBaseCont()
100 /*************************************************************************
102 |* RscBaseCont::GetClassType()
105 |* Ersterstellung MM 25.05.91
106 |* Letzte Aenderung MM 25.05.91
108 *************************************************************************/
109 RSCCLASS_TYPE
RscBaseCont::GetClassType() const
111 return RSCCLASS_COMPLEX
;
114 /*************************************************************************
119 |* Ersterstellung MM 26.04.91
120 |* Letzte Aenderung MM 26.04.91
122 *************************************************************************/
123 void RscBaseCont::DestroyElements( RscBaseContInst
* pClassData
)
127 if( pClassData
->nEntries
){
128 for( i
= 0; i
< pClassData
->nEntries
; i
++ ){
129 pClassData
->pEntries
[ i
].Destroy();
131 rtl_freeMemory( pClassData
->pEntries
);
132 pClassData
->pEntries
= NULL
;
133 pClassData
->nEntries
= 0;
137 /*************************************************************************
139 |* RscBaseCont::Create()
142 |* Ersterstellung MM 26.04.91
143 |* Letzte Aenderung MM 26.04.91
145 *************************************************************************/
146 RSCINST
RscBaseCont::Create( RSCINST
* pInst
, const RSCINST
& rDflt
,
151 RscBaseContInst
* pClassData
;
155 aInst
.pData
= (CLASS_DATA
) rtl_allocateMemory( Size() );
159 if( !bOwnClass
&& rDflt
.IsInst() )
160 bOwnClass
= rDflt
.pClass
->InHierarchy( this );
162 RscTop::Create( &aInst
, rDflt
, bOwnClass
);
164 pClassData
= (RscBaseContInst
*)(aInst
.pData
+ nOffInstData
);
165 pClassData
->nEntries
= 0;
166 pClassData
->pEntries
= NULL
;
167 pClassData
->bDflt
= TRUE
;
170 RscBaseContInst
* pDfltClassData
;
173 pDfltClassData
= (RscBaseContInst
*)(rDflt
.pData
+ nOffInstData
);
175 if( 0 != pDfltClassData
->nEntries
){
176 *pClassData
= *pDfltClassData
;
177 pClassData
->pEntries
=
178 (ENTRY_STRUCT
*)rtl_allocateMemory( sizeof( ENTRY_STRUCT
)
179 * pClassData
->nEntries
);
180 for( i
= 0; i
< pClassData
->nEntries
; i
++ ){
181 pClassData
->pEntries
[ i
].Create();
182 pClassData
->pEntries
[ i
].aName
=
183 pDfltClassData
->pEntries
[ i
].aName
;
184 aDfltI
= pDfltClassData
->pEntries
[ i
].aInst
;
185 pClassData
->pEntries
[ i
].aInst
=
186 aDfltI
.pClass
->Create( NULL
, aDfltI
);
194 /*************************************************************************
196 |* RscBaseCont::Destroy()
199 |* Ersterstellung MM 25.05.91
200 |* Letzte Aenderung MM 25.05.91
202 *************************************************************************/
203 void RscBaseCont::Destroy( const RSCINST
& rInst
){
204 RscBaseContInst
* pClassData
;
206 RscTop::Destroy( rInst
);
208 pClassData
= (RscBaseContInst
*)(rInst
.pData
+ nOffInstData
);
209 DestroyElements( pClassData
);
212 /*************************************************************************
214 |* RscBaseCont::SearchEle()
217 |* Ersterstellung MM 17.05.91
218 |* Letzte Aenderung MM 17.05.91
220 *************************************************************************/
221 RSCINST
RscBaseCont::SearchElePos( const RSCINST
& rInst
, const RscId
& rEleName
,
222 RscTop
* pClass
, sal_uInt32 nPos
)
225 RscBaseContInst
* pClassData
;
227 pClassData
= (RscBaseContInst
*)(rInst
.pData
+ nOffInstData
);
231 if( rEleName
.IsId() ){
232 for( i
= nPos
; i
< pClassData
->nEntries
; i
++ ){
233 if( pClassData
->pEntries
[ i
].aName
== rEleName
234 && pClassData
->pEntries
[ i
].aInst
.pClass
== pClass
)
236 return( pClassData
->pEntries
[ i
].aInst
);
243 /*************************************************************************
245 |* RscBaseCont::SearchEle()
248 |* Ersterstellung MM 17.05.91
249 |* Letzte Aenderung MM 17.05.91
251 *************************************************************************/
252 RSCINST
RscBaseCont::SearchEle( const RSCINST
& rInst
, const RscId
& rEleName
,
255 return SearchElePos( rInst
, rEleName
, pClass
, 0 );
258 /*************************************************************************
260 |* RscBaseCont::GetElement()
263 |* Ersterstellung MM 26.04.91
264 |* Letzte Aenderung MM 26.04.91
266 *************************************************************************/
267 ERRTYPE
RscBaseCont::GetElement( const RSCINST
& rInst
, const RscId
& rEleName
,
268 RscTop
* pCreateClass
,
269 const RSCINST
& rCreateInst
, RSCINST
* pGetInst
)
271 RscBaseContInst
* pClassData
;
275 if( !bNoId
&& !rEleName
.IsId() )
276 aError
= WRN_CONT_NOID
;
277 pClassData
= (RscBaseContInst
*)(rInst
.pData
+ nOffInstData
);
280 if( !pCreateClass
->InHierarchy( pTypeClass
) ){
282 if( !pCreateClass
->InHierarchy( pTypeClass1
) ){
284 return ERR_CONT_INVALIDTYPE
;
289 return ERR_CONT_INVALIDTYPE
;
294 pCreateClass
= pTypeClass
;
296 pClassData
->bDflt
= FALSE
;
298 aTmpI
= SearchEle( rInst
, rEleName
, pCreateClass
);
300 if( aTmpI
.IsInst() ){
301 aError
= WRN_CONT_DOUBLEID
;
302 if( rCreateInst
.IsInst() ){
303 aTmpI
.pClass
->Destroy( aTmpI
);
304 aTmpI
.pClass
->Create( &aTmpI
, rCreateInst
);
308 if( pClassData
->pEntries
){
309 pClassData
->pEntries
=
310 (ENTRY_STRUCT
*)rtl_reallocateMemory( pClassData
->pEntries
,
311 sizeof( ENTRY_STRUCT
) * (pClassData
->nEntries
+1) );
314 pClassData
->pEntries
=
315 (ENTRY_STRUCT
*)rtl_allocateMemory( sizeof( ENTRY_STRUCT
)
316 * (pClassData
->nEntries
+1) );
319 pClassData
->pEntries
[ pClassData
->nEntries
].Create();
320 pClassData
->pEntries
[ pClassData
->nEntries
].aName
= rEleName
;
322 if( rCreateInst
.IsInst() ){
323 // Instanz mit CreateInst-Daten initialisieren
324 pClassData
->pEntries
[ pClassData
->nEntries
].aInst
=
325 pCreateClass
->Create( NULL
, rCreateInst
);
328 pClassData
->pEntries
[ pClassData
->nEntries
].aInst
=
329 pCreateClass
->Create( NULL
, RSCINST() );
332 pClassData
->nEntries
++;
333 aTmpI
= pClassData
->pEntries
[ pClassData
->nEntries
-1 ].aInst
;
340 /*************************************************************************
342 |* RscBaseCont::GetCount()
345 |* Ersterstellung MM 08.05.91
346 |* Letzte Aenderung MM 08.05.91
348 *************************************************************************/
349 sal_uInt32
RscBaseCont::GetCount( const RSCINST
& rInst
){
350 RscBaseContInst
* pClassData
;
352 pClassData
= (RscBaseContInst
*)(rInst
.pData
+ nOffInstData
);
353 return( pClassData
->nEntries
);
356 /*************************************************************************
358 |* RscBaseCont::GetPosEle()
361 |* Ersterstellung MM 08.05.91
362 |* Letzte Aenderung MM 08.05.91
364 *************************************************************************/
365 RSCINST
RscBaseCont::GetPosEle( const RSCINST
& rInst
, sal_uInt32 nPos
){
366 RscBaseContInst
* pClassData
;
368 pClassData
= (RscBaseContInst
*)(rInst
.pData
+ nOffInstData
);
370 if( nPos
< pClassData
->nEntries
)
371 return( pClassData
->pEntries
[ nPos
].aInst
);
375 /*************************************************************************
377 |* RscBaseCont::MovePosEle()
380 |* Ersterstellung MM 23.10.91
381 |* Letzte Aenderung MM 23.10.91
383 *************************************************************************/
384 ERRTYPE
RscBaseCont::MovePosEle( const RSCINST
& rInst
, sal_uInt32 nDestPos
,
385 sal_uInt32 nSourcePos
)
388 RscBaseContInst
* pClassData
;
390 pClassData
= (RscBaseContInst
*)(rInst
.pData
+ nOffInstData
);
392 if( (nDestPos
< pClassData
->nEntries
) && (nSourcePos
< pClassData
->nEntries
) ){
398 aEntry
= pClassData
->pEntries
[ nSourcePos
];
399 // Richtung der for-Schleife bestimmen
400 if( nDestPos
< nSourcePos
)
403 for( i
= nSourcePos
; i
!= nDestPos
; i
+= nInc
)
404 pClassData
->pEntries
[ i
] = pClassData
->pEntries
[ i
+ nInc
];
406 // Zuweisung Quelle auf Ziel
407 pClassData
->pEntries
[ nDestPos
] = aEntry
;
410 aError
= ERR_RSCCONT
;
414 /*************************************************************************
416 |* RscBaseCont::SetPosRscId()
419 |* Ersterstellung MM 30.09.91
420 |* Letzte Aenderung MM 30.09.91
422 *************************************************************************/
423 ERRTYPE
RscBaseCont::SetPosRscId( const RSCINST
& rInst
, sal_uInt32 nPos
,
425 RscBaseContInst
* pClassData
;
429 pClassData
= (RscBaseContInst
*)(rInst
.pData
+ nOffInstData
);
431 if( nPos
< pClassData
->nEntries
){
432 if( ! (rId
== pClassData
->pEntries
[ nPos
].aName
) )
433 aTmpI
= SearchEle( rInst
, rId
,
434 pClassData
->pEntries
[ nPos
].aInst
.pClass
);
435 if( !aTmpI
.IsInst() )
436 pClassData
->pEntries
[ nPos
].aName
= rId
;
438 aError
= ERR_RSCCONT
;
441 aError
= ERR_RSCCONT
;
445 /*************************************************************************
447 |* RscBaseCont::GetInfoEle()
450 |* Ersterstellung MM 08.05.91
451 |* Letzte Aenderung MM 08.05.91
453 *************************************************************************/
454 SUBINFO_STRUCT
RscBaseCont::GetInfoEle( const RSCINST
& rInst
, sal_uInt32 nPos
){
455 RscBaseContInst
* pClassData
;
456 SUBINFO_STRUCT aInfo
;
458 pClassData
= (RscBaseContInst
*)(rInst
.pData
+ nOffInstData
);
460 if( nPos
< pClassData
->nEntries
){
461 aInfo
.aId
= pClassData
->pEntries
[ nPos
].aName
;
463 aInfo
.pClass
= pClassData
->pEntries
[ nPos
].aInst
.pClass
;
468 /*************************************************************************
470 |* RscBaseCont::SetString()
473 |* Ersterstellung MM 29.04.91
474 |* Letzte Aenderung MM 29.04.91
476 *************************************************************************/
477 ERRTYPE
RscBaseCont::SetString( const RSCINST
& rInst
, const char * pStr
)
479 RscBaseContInst
* pClassData
;
484 pClassData
= (RscBaseContInst
*)(rInst
.pData
+ nOffInstData
);
487 //?W 040991 sonst Endlosrekursion moeglich
488 if( RSC_NOTYPE
== pTypeClass
->GetTypId() ){
489 aError
= GetElement( rInst
, RscId(), pTypeClass
, RSCINST(), &aTmpI
);
490 aError
= aTmpI
.pClass
->GetString( aTmpI
, &pTmpStr
);
492 aError
= aTmpI
.pClass
->SetString( aTmpI
, pStr
);
495 DeletePos( rInst
, pClassData
->nEntries
-1 );
496 aError
= GetElement( rInst
, RscId(), pTypeClass1
, RSCINST(), &aTmpI
);
497 aError
= aTmpI
.pClass
->GetString( aTmpI
, &pTmpStr
);
499 aError
= aTmpI
.pClass
->SetString( aTmpI
, pStr
);
501 if( aError
.IsError() )
502 DeletePos( rInst
, pClassData
->nEntries
-1 );
505 aError
= ERR_UNKNOWN_METHOD
;
510 /*************************************************************************
512 |* RscBaseCont::SetNumber()
515 |* Ersterstellung MM 12.06.91
516 |* Letzte Aenderung MM 12.06.91
518 *************************************************************************/
519 ERRTYPE
RscBaseCont::SetNumber( const RSCINST
& rInst
, INT32 lValue
){
520 RscBaseContInst
* pClassData
;
525 pClassData
= (RscBaseContInst
*)(rInst
.pData
+ nOffInstData
);
528 //?W 040991 sonst Endlosrekursion moeglich
529 if( RSC_NOTYPE
== pTypeClass
->GetTypId() ){
530 aError
= GetElement( rInst
, RscId(), pTypeClass
, RSCINST(), &aTmpI
);
531 aError
= aTmpI
.pClass
->GetNumber( aTmpI
, &lNumber
);
533 aError
= aTmpI
.pClass
->SetNumber( aTmpI
, lValue
);
536 DeletePos( rInst
, pClassData
->nEntries
-1 );
537 aError
= GetElement( rInst
, RscId(), pTypeClass1
, RSCINST(), &aTmpI
);
538 aError
= aTmpI
.pClass
->GetNumber( aTmpI
, &lNumber
);
540 aError
= aTmpI
.pClass
->SetNumber( aTmpI
, lValue
);
542 if( aError
.IsError() )
543 DeletePos( rInst
, pClassData
->nEntries
-1 );
546 aError
= ERR_UNKNOWN_METHOD
;
551 //==================================================================
552 ERRTYPE
RscBaseCont::SetBool
554 const RSCINST
& rInst
,
558 RscBaseContInst
* pClassData
;
563 pClassData
= (RscBaseContInst
*)(rInst
.pData
+ nOffInstData
);
566 //?W 040991 sonst Endlosrekursion moeglich
567 if( RSC_NOTYPE
== pTypeClass
->GetTypId() )
569 aError
= GetElement( rInst
, RscId(), pTypeClass
, RSCINST(), &aTmpI
);
570 aError
= aTmpI
.pClass
->GetBool( aTmpI
, &bBool
);
572 aError
= aTmpI
.pClass
->SetBool( aTmpI
, bValue
);
575 DeletePos( rInst
, pClassData
->nEntries
-1 );
576 aError
= GetElement( rInst
, RscId(), pTypeClass1
, RSCINST(), &aTmpI
);
577 aError
= aTmpI
.pClass
->GetBool( aTmpI
, &bBool
);
579 aError
= aTmpI
.pClass
->SetBool( aTmpI
, bValue
);
581 if( aError
.IsError() )
582 DeletePos( rInst
, pClassData
->nEntries
-1 );
585 aError
= ERR_UNKNOWN_METHOD
;
590 //==================================================================
591 ERRTYPE
RscBaseCont::SetConst
593 const RSCINST
& rInst
,
598 RscBaseContInst
* pClassData
;
603 pClassData
= (RscBaseContInst
*)(rInst
.pData
+ nOffInstData
);
606 //?W 040991 sonst Endlosrekursion moeglich
607 if( RSC_NOTYPE
== pTypeClass
->GetTypId() ){
608 aError
= GetElement( rInst
, RscId(), pTypeClass
, RSCINST(), &aTmpI
);
609 aError
= aTmpI
.pClass
->GetConst( aTmpI
, &nConst
);
611 aError
= aTmpI
.pClass
->SetConst( aTmpI
, nValueId
, lValue
);
614 DeletePos( rInst
, pClassData
->nEntries
-1 );
615 aError
= GetElement( rInst
, RscId(), pTypeClass1
, RSCINST(), &aTmpI
);
616 aError
= aTmpI
.pClass
->GetConst( aTmpI
, &nConst
);
618 aError
= aTmpI
.pClass
->SetConst( aTmpI
, nValueId
, lValue
);
620 if( aError
.IsError() )
621 DeletePos( rInst
, pClassData
->nEntries
-1 );
624 aError
= ERR_UNKNOWN_METHOD
;
629 /*************************************************************************
631 |* RscBaseCont::SetRef()
634 |* Ersterstellung MM 02.12.91
635 |* Letzte Aenderung MM 02.12.91
637 *************************************************************************/
638 ERRTYPE
RscBaseCont::SetRef( const RSCINST
& rInst
, const RscId
& rRefId
){
639 RscBaseContInst
* pClassData
;
644 pClassData
= (RscBaseContInst
*)(rInst
.pData
+ nOffInstData
);
647 //?W 040991 sonst Endlosrekursion moeglich
648 if( RSC_NOTYPE
== pTypeClass
->GetTypId() ){
649 aError
= GetElement( rInst
, RscId(), pTypeClass
, RSCINST(), &aTmpI
);
650 aError
= aTmpI
.pClass
->GetRef( aTmpI
, &aId
);
652 aError
= aTmpI
.pClass
->SetRef( aTmpI
, rRefId
);
655 DeletePos( rInst
, pClassData
->nEntries
-1 );
656 aError
= GetElement( rInst
, RscId(), pTypeClass1
, RSCINST(), &aTmpI
);
657 aError
= aTmpI
.pClass
->GetRef( aTmpI
, &aId
);
659 aError
= aTmpI
.pClass
->SetNumber( aTmpI
, rRefId
);
661 if( aError
.IsError() )
662 DeletePos( rInst
, pClassData
->nEntries
-1 );
665 aError
= ERR_UNKNOWN_METHOD
;
670 /*************************************************************************
672 |* RscBaseCont::IsConsistent()
675 |* Ersterstellung MM 23.09.91
676 |* Letzte Aenderung MM 23.09.91
678 *************************************************************************/
679 BOOL
RscBaseCont::IsConsistent( const RSCINST
& rInst
, RscInconsList
* pList
){
681 RscBaseContInst
* pClassData
;
684 bRet
= RscTop::IsConsistent( rInst
, pList
);
686 pClassData
= (RscBaseContInst
*)(rInst
.pData
+ nOffInstData
);
688 // auf doppelten Id Testen und Reihenfolge beibehalten
689 // Komplexitaet = n^2 / 2
690 for( i
= 0; i
< pClassData
->nEntries
; i
++ ){
692 if( (INT32
)pClassData
->pEntries
[ i
].aName
> 0x7FFF
693 || (INT32
)pClassData
->pEntries
[ i
].aName
< 1 ){
696 pList
->Insert( new RscInconsistent(
697 pClassData
->pEntries
[ i
].aName
,
698 pClassData
->pEntries
[ i
].aName
) );
700 else if( SearchElePos( rInst
, pClassData
->pEntries
[ i
].aName
,
701 pClassData
->pEntries
[ i
].aInst
.pClass
, i
+1 ).IsInst() )
705 pList
->Insert( new RscInconsistent(
706 pClassData
->pEntries
[ i
].aName
,
707 pClassData
->pEntries
[ i
+1 ].aName
) );
710 if( ! pClassData
->pEntries
[ i
].aInst
.pClass
->
711 IsConsistent( pClassData
->pEntries
[ i
].aInst
, pList
) )
718 /*************************************************************************
720 |* RscBaseCont::SetToDefault()
723 |* Ersterstellung MM 25.04.91
724 |* Letzte Aenderung MM 25.04.91
726 *************************************************************************/
727 void RscBaseCont::SetToDefault( const RSCINST
& rInst
)
730 RscBaseContInst
* pClassData
;
732 pClassData
= (RscBaseContInst
*)(rInst
.pData
+ nOffInstData
);
734 for( i
= 0; i
< pClassData
->nEntries
; i
++ )
736 pClassData
->pEntries
[ i
].aInst
.pClass
->
737 SetToDefault( pClassData
->pEntries
[ i
].aInst
);
740 RscTop::SetToDefault( rInst
);
743 /*************************************************************************
745 |* RscBaseCont::IsDefault()
748 |* Ersterstellung MM 25.04.91
749 |* Letzte Aenderung MM 25.04.91
751 *************************************************************************/
752 BOOL
RscBaseCont::IsDefault( const RSCINST
& rInst
){
754 RscBaseContInst
* pClassData
;
756 pClassData
= (RscBaseContInst
*)(rInst
.pData
+ nOffInstData
);
758 if( !pClassData
->bDflt
)
761 for( i
= 0; i
< pClassData
->nEntries
; i
++ ){
762 if( ! pClassData
->pEntries
[ i
].aInst
.pClass
->
763 IsDefault( pClassData
->pEntries
[ i
].aInst
) )
769 return( RscTop::IsDefault( rInst
) );
772 /*************************************************************************
774 |* RscBaseCont::IsValueDefault()
777 |* Ersterstellung MM 25.04.91
778 |* Letzte Aenderung MM 15.01.92
780 *************************************************************************/
781 BOOL
RscBaseCont::IsValueDefault( const RSCINST
& rInst
, CLASS_DATA pDef
)
783 RscBaseContInst
* pClassData
;
785 if( !RscTop::IsValueDefault( rInst
, pDef
) )
788 pClassData
= (RscBaseContInst
*)(rInst
.pData
+ nOffInstData
);
790 if( pClassData
->nEntries
)
796 /*************************************************************************
798 |* RscBaseCont::Delete()
801 |* Ersterstellung MM 12.06.91
802 |* Letzte Aenderung MM 12.06.91
804 *************************************************************************/
805 void RscBaseCont::Delete( const RSCINST
& rInst
, RscTop
* pClass
,
809 RscBaseContInst
* pClassData
;
811 pClassData
= (RscBaseContInst
*)(rInst
.pData
+ nOffInstData
);
815 for( i
= 0; i
< pClassData
->nEntries
; i
++ ){
816 if( pClassData
->pEntries
[ i
].aName
== rId
)
817 if( pClassData
->pEntries
[ i
].aInst
.pClass
== pClass
|| !pClass
){
818 DeletePos( rInst
, i
);
825 /*************************************************************************
827 |* RscBaseCont::DeletePos()
830 |* Ersterstellung MM 12.06.91
831 |* Letzte Aenderung MM 12.06.91
833 *************************************************************************/
834 void RscBaseCont::DeletePos( const RSCINST
& rInst
, sal_uInt32 nPos
){
835 RscBaseContInst
* pClassData
;
838 pClassData
= (RscBaseContInst
*)(rInst
.pData
+ nOffInstData
);
840 if( nPos
< pClassData
->nEntries
){
841 if( 1 == pClassData
->nEntries
)
842 DestroyElements( pClassData
);
844 pClassData
->pEntries
[ nPos
].Destroy();
845 pClassData
->nEntries
--;
846 for( i
= nPos
; i
< pClassData
->nEntries
; i
++ )
847 pClassData
->pEntries
[ i
] = pClassData
->pEntries
[ i
+ 1 ];
852 /*************************************************************************
854 |* RscBaseCont::ContWriteSrc()
857 |* Ersterstellung MM 26.04.91
858 |* Letzte Aenderung MM 26.04.91
860 *************************************************************************/
861 void RscBaseCont::ContWriteSrc( const RSCINST
& rInst
, FILE * fOutput
,
862 RscTypCont
* pTC
, sal_uInt32 nTab
,
863 const char * pVarName
)
865 sal_uInt32 i
= 0, t
= 0;
866 RscBaseContInst
* pClassData
;
868 pClassData
= (RscBaseContInst
*)(rInst
.pData
+ nOffInstData
);
870 for( i
= 0; i
< pClassData
->nEntries
; i
++ )
872 for( t
= 0; t
< nTab
; t
++ )
873 fputc( '\t', fOutput
);
874 pClassData
->pEntries
[ i
].aInst
.pClass
->
875 WriteSrcHeader( pClassData
->pEntries
[ i
].aInst
,
877 pClassData
->pEntries
[ i
].aName
, pVarName
);
878 fprintf( fOutput
, ";\n" );
882 /*************************************************************************
884 |* RscBaseCont::ContWriteRc()
887 |* Ersterstellung MM 26.04.91
888 |* Letzte Aenderung MM 26.04.91
890 *************************************************************************/
891 ERRTYPE
RscBaseCont::ContWriteRc( const RSCINST
& rInst
, RscWriteRc
& rMem
,
892 RscTypCont
* pTC
, sal_uInt32 nDeep
, BOOL bExtra
)
895 RscBaseContInst
* pClassData
;
898 if( bExtra
|| bNoId
)
899 { // Nur Subresourcen schreiben, wenn bExtra == TRUE
900 pClassData
= (RscBaseContInst
*)(rInst
.pData
+ nOffInstData
);
902 for( i
= 0; i
< pClassData
->nEntries
&& aError
.IsOk(); i
++ ){
903 aError
= pClassData
->pEntries
[ i
].aInst
.pClass
->
904 WriteRcHeader( pClassData
->pEntries
[ i
].aInst
,
906 pClassData
->pEntries
[ i
].aName
,
914 //==================================================================
915 void RscBaseCont::ContWriteRcAccess
923 if( (bNoId
|| bWriteSize
) && !pTypeClass1
)
925 fprintf( fOutput
, "\t\tsal_uInt32 nItems = *(sal_uInt32 *)(pResData+nOffset) );\n" );
926 fprintf( fOutput
, "\t\tnOffset += sizeof( sal_uInt32 );\n" );
928 fprintf( fOutput
, "\t\t// Items hinzufuegen\n" );
929 fprintf( fOutput
, "\t\tfor( sal_uInt32 i = 0; i < nItems; i++ )\n" );
930 fprintf( fOutput
, "\t\t{\n" );
931 pTypeClass
->WriteRcAccess( fOutput
, pTC
, "Item" );
932 fprintf( fOutput
, "\t\t}\n" );
936 fprintf( fOutput
, "\t\tSet%s( %s ", pName
, pHS
->getString( GetId() ).getStr() );
937 fprintf( fOutput
, "%s ", aCallPar2
.GetBuffer() );
938 fprintf( fOutput
, "ResId( (RSHEADER_TYPE*)(pResData+nOffset) ) ) );\n" );
939 fprintf( fOutput
, "\t\tnOffset += GetObjSizeRes( (RSHEADER_TYPE*)(pResData+nOffset) );\n" );
944 /*************************************************************************
946 |* RscBaseCont::WriteSrc()
949 |* Ersterstellung MM 26.04.91
950 |* Letzte Aenderung MM 26.04.91
952 *************************************************************************/
953 void RscBaseCont::WriteSrc( const RSCINST
& rInst
, FILE * fOutput
,
954 RscTypCont
* pTC
, sal_uInt32 nTab
,
955 const char * pVarName
)
957 RscTop::WriteSrc( rInst
, fOutput
, pTC
, nTab
, pVarName
);
958 ContWriteSrc( rInst
, fOutput
, pTC
, nTab
, pVarName
);
961 /*************************************************************************
963 |* RscBaseCont::WriteRc()
966 |* Ersterstellung MM 26.04.91
967 |* Letzte Aenderung MM 26.04.91
969 *************************************************************************/
970 ERRTYPE
RscBaseCont::WriteRc( const RSCINST
& rInst
, RscWriteRc
& rMem
,
971 RscTypCont
* pTC
, sal_uInt32 nDeep
, BOOL bExtra
)
975 aError
= RscTop::WriteRc( rInst
, rMem
, pTC
, nDeep
, bExtra
);
977 aError
= ContWriteRc( rInst
, rMem
, pTC
, nDeep
, bExtra
);
982 /*************************************************************************
984 |* RscBaseCont::WriteHxx()
987 |* Ersterstellung MM 26.04.91
988 |* Letzte Aenderung MM 26.04.91
990 *************************************************************************/
991 ERRTYPE
RscBaseCont::WriteHxx( const RSCINST
& rInst
, FILE * fOutput
,
992 RscTypCont
* pTC
, const RscId
& rRscId
)
995 RscBaseContInst
* pClassData
;
998 aError
= RscTop::WriteHxx( rInst
, fOutput
, pTC
, rRscId
);
1000 pClassData
= (RscBaseContInst
*)(rInst
.pData
+ nOffInstData
);
1002 for( i
= 0; i
< pClassData
->nEntries
&& aError
.IsOk(); i
++ )
1004 if( pClassData
->pEntries
[ i
].aName
.IsId()
1005 && pClassData
->pEntries
[ i
].aInst
.pClass
->IsCodeWriteable() )
1007 aError
= pClassData
->pEntries
[ i
].aInst
.pClass
->
1008 WriteHxx( pClassData
->pEntries
[ i
].aInst
,
1010 pClassData
->pEntries
[ i
].aName
);
1017 /*************************************************************************
1019 |* RscBaseCont::WriteCxx()
1022 |* Ersterstellung MM 26.04.91
1023 |* Letzte Aenderung MM 26.04.91
1025 *************************************************************************/
1026 ERRTYPE
RscBaseCont::WriteCxx( const RSCINST
& rInst
, FILE * fOutput
,
1027 RscTypCont
* pTC
, const RscId
& rRscId
)
1030 RscBaseContInst
* pClassData
;
1033 aError
= RscTop::WriteCxx( rInst
, fOutput
, pTC
, rRscId
);
1035 pClassData
= (RscBaseContInst
*)(rInst
.pData
+ nOffInstData
);
1037 for( i
= 0; i
< pClassData
->nEntries
&& aError
.IsOk(); i
++ )
1039 if( pClassData
->pEntries
[ i
].aName
.IsId()
1040 && pClassData
->pEntries
[ i
].aInst
.pClass
->IsCodeWriteable() )
1042 aError
= pClassData
->pEntries
[ i
].aInst
.pClass
->
1043 WriteCxx( pClassData
->pEntries
[ i
].aInst
,
1045 pClassData
->pEntries
[ i
].aName
);
1052 /*************** R s c C o n t W r i t e S r c ***************************/
1053 /*************************************************************************
1055 |* RscContWriteSrc::RscContWriteSrc()
1058 |* Ersterstellung MM 08.05.91
1059 |* Letzte Aenderung MM 08.05.91
1061 *************************************************************************/
1062 RscContWriteSrc::RscContWriteSrc( Atom nId
, sal_uInt32 nTypeId
,
1063 RscTop
* pSuper
, BOOL bNoIdent
)
1064 : RscBaseCont( nId
, nTypeId
, pSuper
, bNoIdent
)
1067 /*************************************************************************
1069 |* RscContWriteSrc::WriteSrc()
1072 |* Ersterstellung MM 08.05.91
1073 |* Letzte Aenderung MM 08.05.91
1075 *************************************************************************/
1076 void RscContWriteSrc::WriteSrc( const RSCINST
& rInst
, FILE * fOutput
,
1077 RscTypCont
* pTC
, sal_uInt32 nTab
,
1078 const char * pVarName
)
1082 RscTop::WriteSrc( rInst
, fOutput
, pTC
, nTab
, pVarName
);
1084 fprintf( fOutput
, "\n" );
1085 for( i
= 0; i
< nTab
; i
++ )
1086 fputc( '\t', fOutput
);
1087 fprintf( fOutput
, "{\n" );
1089 ContWriteSrc( rInst
, fOutput
, pTC
, nTab
+1, pVarName
);
1091 for( i
= 0; i
< nTab
; i
++ )
1092 fputc( '\t', fOutput
);
1093 fprintf( fOutput
, "}" );
1096 /*************** R s c C o n t *******************************************/
1097 /*************************************************************************
1099 |* RscCont::RscCont()
1102 |* Ersterstellung MM 08.05.91
1103 |* Letzte Aenderung MM 08.05.91
1105 *************************************************************************/
1106 RscCont::RscCont( Atom nId
, sal_uInt32 nTypeId
, RscTop
* pSuper
, BOOL bNoIdent
)
1107 : RscContWriteSrc( nId
, nTypeId
, pSuper
, bNoIdent
)
1110 /*************************************************************************
1112 |* RscCont::WriteRc()
1115 |* Ersterstellung MM 08.05.91
1116 |* Letzte Aenderung MM 08.05.91
1118 *************************************************************************/
1119 ERRTYPE
RscCont::WriteRc( const RSCINST
& rInst
, RscWriteRc
& rMem
,
1120 RscTypCont
* pTC
, sal_uInt32 nDeep
, BOOL bExtra
)
1122 RscBaseContInst
* pClassData
;
1125 aError
= RscTop::WriteRc( rInst
, rMem
, pTC
, nDeep
, bExtra
);
1127 pClassData
= (RscBaseContInst
*)(rInst
.pData
+ nOffInstData
);
1129 rMem
.Put( pClassData
->nEntries
);
1132 aError
= ContWriteRc( rInst
, rMem
, pTC
, nDeep
, bExtra
);
1137 //==================================================================
1138 void RscCont::WriteRcAccess
1145 ContWriteRcAccess( fOutput
, pTC
, pName
, TRUE
);
1148 /*************************************************************************
1150 |* RscContExtraData::RscContExtraData()
1153 |* Ersterstellung MM 08.05.91
1154 |* Letzte Aenderung MM 08.05.91
1156 *************************************************************************/
1157 RscContExtraData::RscContExtraData( Atom nId
, sal_uInt32 nTypeId
,
1158 RscTop
* pSuper
, BOOL bNoIdent
)
1159 : RscContWriteSrc( nId
, nTypeId
, pSuper
, bNoIdent
)
1162 /*************************************************************************
1164 |* RscContExtraData::WriteRc()
1167 |* Ersterstellung MM 08.05.91
1168 |* Letzte Aenderung MM 08.05.91
1170 *************************************************************************/
1171 ERRTYPE
RscContExtraData::WriteRc( const RSCINST
& rInst
, RscWriteRc
& rMem
,
1172 RscTypCont
* pTC
, sal_uInt32 nDeep
, BOOL bExtra
)
1177 aError
= RscContWriteSrc::WriteRc( rInst
, rMem
, pTC
, nDeep
, bExtra
);
1179 aError
= RscTop::WriteRc( rInst
, rMem
, pTC
, nDeep
, bExtra
);