Update ooo320-m1
[ooovba.git] / rsc / source / res / rsccont.cxx
blobbf6925aaa2355da796874f9f0236ef919dd233da
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: rsccont.cxx,v $
10 * $Revision: 1.7 $
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 // 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()
51 |* Beschreibung
52 |* Ersterstellung MM 06.08.91
53 |* Letzte Aenderung MM 06.08.91
55 *************************************************************************/
56 void ENTRY_STRUCT::Destroy()
58 aName.Destroy();
59 if( aInst.IsInst() ){
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()
70 |* Beschreibung
71 |* Ersterstellung MM 25.05.91
72 |* Letzte Aenderung MM 25.05.91
74 *************************************************************************/
75 RscBaseCont::RscBaseCont( Atom nId, sal_uInt32 nTypeId, RscTop * pSuper,
76 BOOL bNoIdent )
77 : RscTop( nId, nTypeId, pSuper ),
78 nSize( 0 )
80 pTypeClass = NULL;
81 pTypeClass1 = NULL;
82 bNoId = bNoIdent;
83 nOffInstData = RscTop::Size();
84 nSize = nOffInstData + ALIGNED_SIZE( sizeof( RscBaseContInst ) );
87 /*************************************************************************
89 |* RscBaseCont::~RscBaseCont()
91 |* Beschreibung
92 |* Ersterstellung MM 25.05.91
93 |* Letzte Aenderung MM 25.05.91
95 *************************************************************************/
96 RscBaseCont::~RscBaseCont()
100 /*************************************************************************
102 |* RscBaseCont::GetClassType()
104 |* Beschreibung
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 /*************************************************************************
116 |* DestroyElements()
118 |* Beschreibung
119 |* Ersterstellung MM 26.04.91
120 |* Letzte Aenderung MM 26.04.91
122 *************************************************************************/
123 void RscBaseCont::DestroyElements( RscBaseContInst * pClassData )
125 sal_uInt32 i = 0;
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()
141 |* Beschreibung
142 |* Ersterstellung MM 26.04.91
143 |* Letzte Aenderung MM 26.04.91
145 *************************************************************************/
146 RSCINST RscBaseCont::Create( RSCINST * pInst, const RSCINST & rDflt,
147 BOOL bOwnClass )
149 sal_uInt32 i = 0;
150 RSCINST aInst;
151 RscBaseContInst * pClassData;
153 if( !pInst ){
154 aInst.pClass = this;
155 aInst.pData = (CLASS_DATA) rtl_allocateMemory( Size() );
157 else
158 aInst = *pInst;
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;
169 if( bOwnClass ){
170 RscBaseContInst * pDfltClassData;
171 RSCINST aDfltI;
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 );
191 return( aInst );
194 /*************************************************************************
196 |* RscBaseCont::Destroy()
198 |* Beschreibung
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()
216 |* Beschreibung
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 )
224 sal_uInt32 i = 0;
225 RscBaseContInst * pClassData;
227 pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData);
228 if( !pClass )
229 pClass = pTypeClass;
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 );
240 return RSCINST();
243 /*************************************************************************
245 |* RscBaseCont::SearchEle()
247 |* Beschreibung
248 |* Ersterstellung MM 17.05.91
249 |* Letzte Aenderung MM 17.05.91
251 *************************************************************************/
252 RSCINST RscBaseCont::SearchEle( const RSCINST & rInst, const RscId & rEleName,
253 RscTop * pClass )
255 return SearchElePos( rInst, rEleName, pClass, 0 );
258 /*************************************************************************
260 |* RscBaseCont::GetElement()
262 |* Beschreibung
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;
272 RSCINST aTmpI;
273 ERRTYPE aError;
275 if( !bNoId && !rEleName.IsId() )
276 aError = WRN_CONT_NOID;
277 pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData);
279 if( pCreateClass ){
280 if( !pCreateClass->InHierarchy( pTypeClass ) ){
281 if( pTypeClass1 ){
282 if( !pCreateClass->InHierarchy( pTypeClass1 ) ){
283 // Falscher Typ
284 return ERR_CONT_INVALIDTYPE;
287 else{
288 // Falscher Typ
289 return ERR_CONT_INVALIDTYPE;
293 else
294 pCreateClass = pTypeClass;
296 pClassData->bDflt = FALSE;
297 if( !bNoId )
298 aTmpI = SearchEle( rInst, rEleName, pCreateClass );
299 // Eintrag gefunden
300 if( aTmpI.IsInst() ){
301 aError = WRN_CONT_DOUBLEID;
302 if( rCreateInst.IsInst() ){
303 aTmpI.pClass->Destroy( aTmpI );
304 aTmpI.pClass->Create( &aTmpI, rCreateInst );
307 else {
308 if( pClassData->pEntries ){
309 pClassData->pEntries =
310 (ENTRY_STRUCT *)rtl_reallocateMemory( pClassData->pEntries,
311 sizeof( ENTRY_STRUCT ) * (pClassData->nEntries +1) );
313 else {
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 );
327 else {
328 pClassData->pEntries[ pClassData->nEntries ].aInst =
329 pCreateClass->Create( NULL, RSCINST() );
332 pClassData->nEntries++;
333 aTmpI = pClassData->pEntries[ pClassData->nEntries -1 ].aInst;
336 *pGetInst = aTmpI;
337 return aError;
340 /*************************************************************************
342 |* RscBaseCont::GetCount()
344 |* Beschreibung
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()
360 |* Beschreibung
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 );
372 return RSCINST();
375 /*************************************************************************
377 |* RscBaseCont::MovePosEle()
379 |* Beschreibung
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 )
387 ERRTYPE aError;
388 RscBaseContInst * pClassData;
390 pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData);
392 if( (nDestPos < pClassData->nEntries) && (nSourcePos < pClassData->nEntries) ){
393 ENTRY_STRUCT aEntry;
394 int nInc = 1;
395 sal_uInt32 i = 0;
397 // Quelle Merken
398 aEntry = pClassData->pEntries[ nSourcePos ];
399 // Richtung der for-Schleife bestimmen
400 if( nDestPos < nSourcePos )
401 nInc = -1;
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;
409 else
410 aError = ERR_RSCCONT;
411 return aError;
414 /*************************************************************************
416 |* RscBaseCont::SetPosRscId()
418 |* Beschreibung
419 |* Ersterstellung MM 30.09.91
420 |* Letzte Aenderung MM 30.09.91
422 *************************************************************************/
423 ERRTYPE RscBaseCont::SetPosRscId( const RSCINST & rInst, sal_uInt32 nPos,
424 const RscId & rId ){
425 RscBaseContInst * pClassData;
426 RSCINST aTmpI;
427 ERRTYPE aError;
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;
437 else
438 aError = ERR_RSCCONT;
440 else
441 aError = ERR_RSCCONT;
442 return( aError );
445 /*************************************************************************
447 |* RscBaseCont::GetInfoEle()
449 |* Beschreibung
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;
462 aInfo.nPos = nPos;
463 aInfo.pClass = pClassData->pEntries[ nPos ].aInst.pClass;
465 return( aInfo );
468 /*************************************************************************
470 |* RscBaseCont::SetString()
472 |* Beschreibung
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;
480 RSCINST aTmpI;
481 ERRTYPE aError;
482 char *pTmpStr;
484 pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData);
486 //?B 040991
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 );
491 if( aError.IsOk() )
492 aError = aTmpI.pClass->SetString( aTmpI, pStr );
493 else {
494 aError.Clear();
495 DeletePos( rInst, pClassData->nEntries -1 );
496 aError = GetElement( rInst, RscId(), pTypeClass1, RSCINST(), &aTmpI );
497 aError = aTmpI.pClass->GetString( aTmpI, &pTmpStr );
498 if( aError.IsOk() )
499 aError = aTmpI.pClass->SetString( aTmpI, pStr );
501 if( aError.IsError() )
502 DeletePos( rInst, pClassData->nEntries -1 );
504 else
505 aError = ERR_UNKNOWN_METHOD;
507 return( aError );
510 /*************************************************************************
512 |* RscBaseCont::SetNumber()
514 |* Beschreibung
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;
521 RSCINST aTmpI;
522 ERRTYPE aError;
523 INT32 lNumber;
525 pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData);
527 //?B 040991
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 );
532 if( aError.IsOk() )
533 aError = aTmpI.pClass->SetNumber( aTmpI, lValue );
534 else {
535 aError.Clear();
536 DeletePos( rInst, pClassData->nEntries -1 );
537 aError = GetElement( rInst, RscId(), pTypeClass1, RSCINST(), &aTmpI );
538 aError = aTmpI.pClass->GetNumber( aTmpI, &lNumber );
539 if( aError.IsOk() )
540 aError = aTmpI.pClass->SetNumber( aTmpI, lValue );
542 if( aError.IsError() )
543 DeletePos( rInst, pClassData->nEntries -1 );
545 else
546 aError = ERR_UNKNOWN_METHOD;
548 return( aError );
551 //==================================================================
552 ERRTYPE RscBaseCont::SetBool
554 const RSCINST & rInst,
555 BOOL bValue
558 RscBaseContInst * pClassData;
559 RSCINST aTmpI;
560 ERRTYPE aError;
561 BOOL bBool;
563 pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData);
565 //?B 040991
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 );
571 if( aError.IsOk() )
572 aError = aTmpI.pClass->SetBool( aTmpI, bValue );
573 else {
574 aError.Clear();
575 DeletePos( rInst, pClassData->nEntries -1 );
576 aError = GetElement( rInst, RscId(), pTypeClass1, RSCINST(), &aTmpI );
577 aError = aTmpI.pClass->GetBool( aTmpI, &bBool );
578 if( aError.IsOk() )
579 aError = aTmpI.pClass->SetBool( aTmpI, bValue );
581 if( aError.IsError() )
582 DeletePos( rInst, pClassData->nEntries -1 );
584 else
585 aError = ERR_UNKNOWN_METHOD;
587 return( aError );
590 //==================================================================
591 ERRTYPE RscBaseCont::SetConst
593 const RSCINST & rInst,
594 Atom nValueId,
595 INT32 lValue
598 RscBaseContInst * pClassData;
599 RSCINST aTmpI;
600 ERRTYPE aError;
601 Atom nConst;
603 pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData);
605 //?B 040991
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 );
610 if( aError.IsOk() )
611 aError = aTmpI.pClass->SetConst( aTmpI, nValueId, lValue );
612 else {
613 aError.Clear();
614 DeletePos( rInst, pClassData->nEntries -1 );
615 aError = GetElement( rInst, RscId(), pTypeClass1, RSCINST(), &aTmpI );
616 aError = aTmpI.pClass->GetConst( aTmpI, &nConst );
617 if( aError.IsOk() )
618 aError = aTmpI.pClass->SetConst( aTmpI, nValueId, lValue );
620 if( aError.IsError() )
621 DeletePos( rInst, pClassData->nEntries -1 );
623 else
624 aError = ERR_UNKNOWN_METHOD;
626 return( aError );
629 /*************************************************************************
631 |* RscBaseCont::SetRef()
633 |* Beschreibung
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;
640 RSCINST aTmpI;
641 ERRTYPE aError;
642 RscId aId;
644 pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData);
646 //?B 040991
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 );
651 if( aError.IsOk() )
652 aError = aTmpI.pClass->SetRef( aTmpI, rRefId );
653 else {
654 aError.Clear();
655 DeletePos( rInst, pClassData->nEntries -1 );
656 aError = GetElement( rInst, RscId(), pTypeClass1, RSCINST(), &aTmpI );
657 aError = aTmpI.pClass->GetRef( aTmpI, &aId );
658 if( aError.IsOk() )
659 aError = aTmpI.pClass->SetNumber( aTmpI, rRefId );
661 if( aError.IsError() )
662 DeletePos( rInst, pClassData->nEntries -1 );
664 else
665 aError = ERR_UNKNOWN_METHOD;
667 return( aError );
670 /*************************************************************************
672 |* RscBaseCont::IsConsistent()
674 |* Beschreibung
675 |* Ersterstellung MM 23.09.91
676 |* Letzte Aenderung MM 23.09.91
678 *************************************************************************/
679 BOOL RscBaseCont::IsConsistent( const RSCINST & rInst, RscInconsList * pList ){
680 sal_uInt32 i = 0;
681 RscBaseContInst * pClassData;
682 BOOL bRet;
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++ ){
691 if( !bNoId ){
692 if( (INT32)pClassData->pEntries[ i ].aName > 0x7FFF
693 || (INT32)pClassData->pEntries[ i ].aName < 1 ){
694 bRet = FALSE;
695 if( pList )
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() )
703 bRet = FALSE;
704 if( pList )
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 ) )
712 bRet = FALSE;
715 return( bRet );
718 /*************************************************************************
720 |* RscBaseCont::SetToDefault()
722 |* Beschreibung
723 |* Ersterstellung MM 25.04.91
724 |* Letzte Aenderung MM 25.04.91
726 *************************************************************************/
727 void RscBaseCont::SetToDefault( const RSCINST & rInst )
729 sal_uInt32 i = 0;
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()
747 |* Beschreibung
748 |* Ersterstellung MM 25.04.91
749 |* Letzte Aenderung MM 25.04.91
751 *************************************************************************/
752 BOOL RscBaseCont::IsDefault( const RSCINST & rInst ){
753 sal_uInt32 i = 0;
754 RscBaseContInst * pClassData;
756 pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData);
758 if( !pClassData->bDflt )
759 return FALSE;
761 for( i = 0; i < pClassData->nEntries; i++ ){
762 if( ! pClassData->pEntries[ i ].aInst.pClass->
763 IsDefault( pClassData->pEntries[ i ].aInst ) )
765 return( FALSE );
769 return( RscTop::IsDefault( rInst ) );
772 /*************************************************************************
774 |* RscBaseCont::IsValueDefault()
776 |* Beschreibung
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 ) )
786 return FALSE;
788 pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData);
790 if( pClassData->nEntries )
791 return FALSE;
792 else
793 return TRUE;
796 /*************************************************************************
798 |* RscBaseCont::Delete()
800 |* Beschreibung
801 |* Ersterstellung MM 12.06.91
802 |* Letzte Aenderung MM 12.06.91
804 *************************************************************************/
805 void RscBaseCont::Delete( const RSCINST & rInst, RscTop * pClass,
806 const RscId & rId )
808 sal_uInt32 i = 0;
809 RscBaseContInst * pClassData;
811 pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData);
812 if( !pClass )
813 pClass = pTypeClass;
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 );
819 return;
825 /*************************************************************************
827 |* RscBaseCont::DeletePos()
829 |* Beschreibung
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;
836 sal_uInt32 i = 0;
838 pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData);
840 if( nPos < pClassData->nEntries ){
841 if( 1 == pClassData->nEntries )
842 DestroyElements( pClassData );
843 else{
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()
856 |* Beschreibung
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,
876 fOutput, pTC, nTab,
877 pClassData->pEntries[ i ].aName, pVarName );
878 fprintf( fOutput, ";\n" );
882 /*************************************************************************
884 |* RscBaseCont::ContWriteRc()
886 |* Beschreibung
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 )
894 sal_uInt32 i = 0;
895 RscBaseContInst * pClassData;
896 ERRTYPE aError;
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,
905 rMem, pTC,
906 pClassData->pEntries[ i ].aName,
907 nDeep, bExtra );
911 return( aError );
914 //==================================================================
915 void RscBaseCont::ContWriteRcAccess
917 FILE * fOutput,
918 RscTypCont * pTC,
919 const char * pName,
920 BOOL bWriteSize
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" );
934 else
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()
948 |* Beschreibung
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()
965 |* Beschreibung
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 )
973 ERRTYPE aError;
975 aError = RscTop::WriteRc( rInst, rMem, pTC, nDeep, bExtra );
976 if( aError.IsOk() )
977 aError = ContWriteRc( rInst, rMem, pTC, nDeep, bExtra );
979 return( aError );
982 /*************************************************************************
984 |* RscBaseCont::WriteHxx()
986 |* Beschreibung
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 )
994 sal_uInt32 i = 0;
995 RscBaseContInst * pClassData;
996 ERRTYPE aError;
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,
1009 fOutput, pTC,
1010 pClassData->pEntries[ i ].aName );
1014 return( aError );
1017 /*************************************************************************
1019 |* RscBaseCont::WriteCxx()
1021 |* Beschreibung
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 )
1029 sal_uInt32 i = 0;
1030 RscBaseContInst * pClassData;
1031 ERRTYPE aError;
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,
1044 fOutput, pTC,
1045 pClassData->pEntries[ i ].aName );
1049 return( aError );
1052 /*************** R s c C o n t W r i t e S r c ***************************/
1053 /*************************************************************************
1055 |* RscContWriteSrc::RscContWriteSrc()
1057 |* Beschreibung
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()
1071 |* Beschreibung
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 )
1080 sal_uInt32 i;
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()
1101 |* Beschreibung
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()
1114 |* Beschreibung
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;
1123 ERRTYPE aError;
1125 aError = RscTop::WriteRc( rInst, rMem, pTC, nDeep, bExtra );
1127 pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData);
1129 rMem.Put( pClassData->nEntries );
1131 if( aError.IsOk() )
1132 aError = ContWriteRc( rInst, rMem, pTC, nDeep, bExtra );
1134 return aError;
1137 //==================================================================
1138 void RscCont::WriteRcAccess
1140 FILE * fOutput,
1141 RscTypCont * pTC,
1142 const char * pName
1145 ContWriteRcAccess( fOutput, pTC, pName, TRUE );
1148 /*************************************************************************
1150 |* RscContExtraData::RscContExtraData()
1152 |* Beschreibung
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()
1166 |* Beschreibung
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 )
1174 ERRTYPE aError;
1176 if( bExtra )
1177 aError = RscContWriteSrc::WriteRc( rInst, rMem, pTC, nDeep, bExtra );
1178 else
1179 aError = RscTop::WriteRc( rInst, rMem, pTC, nDeep, bExtra );
1181 return aError;