1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_rsc.hxx" 26 /****************** I N C L U D E S **************************************/ 27 28 // C and C++ Includes. 29 #include <stdlib.h> 30 #include <stdio.h> 31 #include <string.h> 32 33 // Programmabh�ngige Includes. 34 #include <rsccont.hxx> 35 36 #include <tools/rcid.h> 37 38 /****************** C O D E **********************************************/ 39 /****************** E N T R Y S T R U C T ********************************/ 40 /************************************************************************* 41 |* 42 |* ENTRYSTRUCT::Destroy() 43 |* 44 |* Beschreibung 45 |* Ersterstellung MM 06.08.91 46 |* Letzte Aenderung MM 06.08.91 47 |* 48 *************************************************************************/ 49 void ENTRY_STRUCT::Destroy() 50 { 51 aName.Destroy(); 52 if( aInst.IsInst() ){ 53 aInst.pClass->Destroy( aInst ); 54 rtl_freeMemory( aInst.pData ); 55 }; 56 } 57 58 /****************** R s c B a s e C o n t ********************************/ 59 /************************************************************************* 60 |* 61 |* RscBaseCont::RscBaseCont() 62 |* 63 |* Beschreibung 64 |* Ersterstellung MM 25.05.91 65 |* Letzte Aenderung MM 25.05.91 66 |* 67 *************************************************************************/ 68 RscBaseCont::RscBaseCont( Atom nId, sal_uInt32 nTypeId, RscTop * pSuper, 69 sal_Bool bNoIdent ) 70 : RscTop( nId, nTypeId, pSuper ), 71 nSize( 0 ) 72 { 73 pTypeClass = NULL; 74 pTypeClass1 = NULL; 75 bNoId = bNoIdent; 76 nOffInstData = RscTop::Size(); 77 nSize = nOffInstData + ALIGNED_SIZE( sizeof( RscBaseContInst ) ); 78 } 79 80 /************************************************************************* 81 |* 82 |* RscBaseCont::~RscBaseCont() 83 |* 84 |* Beschreibung 85 |* Ersterstellung MM 25.05.91 86 |* Letzte Aenderung MM 25.05.91 87 |* 88 *************************************************************************/ 89 RscBaseCont::~RscBaseCont() 90 { 91 } 92 93 /************************************************************************* 94 |* 95 |* RscBaseCont::GetClassType() 96 |* 97 |* Beschreibung 98 |* Ersterstellung MM 25.05.91 99 |* Letzte Aenderung MM 25.05.91 100 |* 101 *************************************************************************/ 102 RSCCLASS_TYPE RscBaseCont::GetClassType() const 103 { 104 return RSCCLASS_COMPLEX; 105 } 106 107 /************************************************************************* 108 |* 109 |* DestroyElements() 110 |* 111 |* Beschreibung 112 |* Ersterstellung MM 26.04.91 113 |* Letzte Aenderung MM 26.04.91 114 |* 115 *************************************************************************/ 116 void RscBaseCont::DestroyElements( RscBaseContInst * pClassData ) 117 { 118 sal_uInt32 i = 0; 119 120 if( pClassData->nEntries ){ 121 for( i = 0; i < pClassData->nEntries; i++ ){ 122 pClassData->pEntries[ i ].Destroy(); 123 }; 124 rtl_freeMemory( pClassData->pEntries ); 125 pClassData->pEntries = NULL; 126 pClassData->nEntries = 0; 127 }; 128 } 129 130 /************************************************************************* 131 |* 132 |* RscBaseCont::Create() 133 |* 134 |* Beschreibung 135 |* Ersterstellung MM 26.04.91 136 |* Letzte Aenderung MM 26.04.91 137 |* 138 *************************************************************************/ 139 RSCINST RscBaseCont::Create( RSCINST * pInst, const RSCINST & rDflt, 140 sal_Bool bOwnClass ) 141 { 142 sal_uInt32 i = 0; 143 RSCINST aInst; 144 RscBaseContInst * pClassData; 145 146 if( !pInst ){ 147 aInst.pClass = this; 148 aInst.pData = (CLASS_DATA) rtl_allocateMemory( Size() ); 149 } 150 else 151 aInst = *pInst; 152 if( !bOwnClass && rDflt.IsInst() ) 153 bOwnClass = rDflt.pClass->InHierarchy( this ); 154 155 RscTop::Create( &aInst, rDflt, bOwnClass ); 156 157 pClassData = (RscBaseContInst *)(aInst.pData + nOffInstData); 158 pClassData->nEntries = 0; 159 pClassData->pEntries = NULL; 160 pClassData->bDflt = sal_True; 161 162 if( bOwnClass ){ 163 RscBaseContInst * pDfltClassData; 164 RSCINST aDfltI; 165 166 pDfltClassData = (RscBaseContInst *)(rDflt.pData + nOffInstData); 167 168 if( 0 != pDfltClassData->nEntries ){ 169 *pClassData = *pDfltClassData; 170 pClassData->pEntries = 171 (ENTRY_STRUCT *)rtl_allocateMemory( sizeof( ENTRY_STRUCT ) 172 * pClassData->nEntries ); 173 for( i = 0; i < pClassData->nEntries; i++ ){ 174 pClassData->pEntries[ i ].Create(); 175 pClassData->pEntries[ i ].aName = 176 pDfltClassData->pEntries[ i ].aName; 177 aDfltI = pDfltClassData->pEntries[ i ].aInst; 178 pClassData->pEntries[ i ].aInst = 179 aDfltI.pClass->Create( NULL, aDfltI ); 180 }; 181 }; 182 } 183 184 return( aInst ); 185 } 186 187 /************************************************************************* 188 |* 189 |* RscBaseCont::Destroy() 190 |* 191 |* Beschreibung 192 |* Ersterstellung MM 25.05.91 193 |* Letzte Aenderung MM 25.05.91 194 |* 195 *************************************************************************/ 196 void RscBaseCont::Destroy( const RSCINST & rInst ){ 197 RscBaseContInst * pClassData; 198 199 RscTop::Destroy( rInst); 200 201 pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData); 202 DestroyElements( pClassData ); 203 } 204 205 /************************************************************************* 206 |* 207 |* RscBaseCont::SearchEle() 208 |* 209 |* Beschreibung 210 |* Ersterstellung MM 17.05.91 211 |* Letzte Aenderung MM 17.05.91 212 |* 213 *************************************************************************/ 214 RSCINST RscBaseCont::SearchElePos( const RSCINST & rInst, const RscId & rEleName, 215 RscTop * pClass, sal_uInt32 nPos ) 216 { 217 sal_uInt32 i = 0; 218 RscBaseContInst * pClassData; 219 220 pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData); 221 if( !pClass ) 222 pClass = pTypeClass; 223 224 if( rEleName.IsId() ){ 225 for( i = nPos; i < pClassData->nEntries; i++ ){ 226 if( pClassData->pEntries[ i ].aName == rEleName 227 && pClassData->pEntries[ i ].aInst.pClass == pClass ) 228 { 229 return( pClassData->pEntries[ i ].aInst ); 230 }; 231 }; 232 }; 233 return RSCINST(); 234 } 235 236 /************************************************************************* 237 |* 238 |* RscBaseCont::SearchEle() 239 |* 240 |* Beschreibung 241 |* Ersterstellung MM 17.05.91 242 |* Letzte Aenderung MM 17.05.91 243 |* 244 *************************************************************************/ 245 RSCINST RscBaseCont::SearchEle( const RSCINST & rInst, const RscId & rEleName, 246 RscTop * pClass ) 247 { 248 return SearchElePos( rInst, rEleName, pClass, 0 ); 249 } 250 251 /************************************************************************* 252 |* 253 |* RscBaseCont::GetElement() 254 |* 255 |* Beschreibung 256 |* Ersterstellung MM 26.04.91 257 |* Letzte Aenderung MM 26.04.91 258 |* 259 *************************************************************************/ 260 ERRTYPE RscBaseCont::GetElement( const RSCINST & rInst, const RscId & rEleName, 261 RscTop * pCreateClass, 262 const RSCINST & rCreateInst, RSCINST * pGetInst ) 263 { 264 RscBaseContInst * pClassData; 265 RSCINST aTmpI; 266 ERRTYPE aError; 267 268 if( !bNoId && !rEleName.IsId() ) 269 aError = WRN_CONT_NOID; 270 pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData); 271 272 if( pCreateClass ){ 273 if( !pCreateClass->InHierarchy( pTypeClass ) ){ 274 if( pTypeClass1 ){ 275 if( !pCreateClass->InHierarchy( pTypeClass1 ) ){ 276 // Falscher Typ 277 return ERR_CONT_INVALIDTYPE; 278 } 279 } 280 else{ 281 // Falscher Typ 282 return ERR_CONT_INVALIDTYPE; 283 }; 284 }; 285 } 286 else 287 pCreateClass = pTypeClass; 288 289 pClassData->bDflt = sal_False; 290 if( !bNoId ) 291 aTmpI = SearchEle( rInst, rEleName, pCreateClass ); 292 // Eintrag gefunden 293 if( aTmpI.IsInst() ){ 294 aError = WRN_CONT_DOUBLEID; 295 if( rCreateInst.IsInst() ){ 296 aTmpI.pClass->Destroy( aTmpI ); 297 aTmpI.pClass->Create( &aTmpI, rCreateInst ); 298 }; 299 } 300 else { 301 if( pClassData->pEntries ){ 302 pClassData->pEntries = 303 (ENTRY_STRUCT *)rtl_reallocateMemory( pClassData->pEntries, 304 sizeof( ENTRY_STRUCT ) * (pClassData->nEntries +1) ); 305 } 306 else { 307 pClassData->pEntries = 308 (ENTRY_STRUCT *)rtl_allocateMemory( sizeof( ENTRY_STRUCT ) 309 * (pClassData->nEntries +1) ); 310 }; 311 312 pClassData->pEntries[ pClassData->nEntries ].Create(); 313 pClassData->pEntries[ pClassData->nEntries ].aName = rEleName; 314 315 if( rCreateInst.IsInst() ){ 316 // Instanz mit CreateInst-Daten initialisieren 317 pClassData->pEntries[ pClassData->nEntries ].aInst = 318 pCreateClass->Create( NULL, rCreateInst ); 319 } 320 else { 321 pClassData->pEntries[ pClassData->nEntries ].aInst = 322 pCreateClass->Create( NULL, RSCINST() ); 323 }; 324 325 pClassData->nEntries++; 326 aTmpI = pClassData->pEntries[ pClassData->nEntries -1 ].aInst; 327 } 328 329 *pGetInst = aTmpI; 330 return aError; 331 } 332 333 /************************************************************************* 334 |* 335 |* RscBaseCont::GetCount() 336 |* 337 |* Beschreibung 338 |* Ersterstellung MM 08.05.91 339 |* Letzte Aenderung MM 08.05.91 340 |* 341 *************************************************************************/ 342 sal_uInt32 RscBaseCont::GetCount( const RSCINST & rInst ){ 343 RscBaseContInst * pClassData; 344 345 pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData); 346 return( pClassData->nEntries ); 347 } 348 349 /************************************************************************* 350 |* 351 |* RscBaseCont::GetPosEle() 352 |* 353 |* Beschreibung 354 |* Ersterstellung MM 08.05.91 355 |* Letzte Aenderung MM 08.05.91 356 |* 357 *************************************************************************/ 358 RSCINST RscBaseCont::GetPosEle( const RSCINST & rInst, sal_uInt32 nPos ){ 359 RscBaseContInst * pClassData; 360 361 pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData); 362 363 if( nPos < pClassData->nEntries ) 364 return( pClassData->pEntries[ nPos ].aInst ); 365 return RSCINST(); 366 } 367 368 /************************************************************************* 369 |* 370 |* RscBaseCont::MovePosEle() 371 |* 372 |* Beschreibung 373 |* Ersterstellung MM 23.10.91 374 |* Letzte Aenderung MM 23.10.91 375 |* 376 *************************************************************************/ 377 ERRTYPE RscBaseCont::MovePosEle( const RSCINST & rInst, sal_uInt32 nDestPos, 378 sal_uInt32 nSourcePos ) 379 { 380 ERRTYPE aError; 381 RscBaseContInst * pClassData; 382 383 pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData); 384 385 if( (nDestPos < pClassData->nEntries) && (nSourcePos < pClassData->nEntries) ){ 386 ENTRY_STRUCT aEntry; 387 int nInc = 1; 388 sal_uInt32 i = 0; 389 390 // Quelle Merken 391 aEntry = pClassData->pEntries[ nSourcePos ]; 392 // Richtung der for-Schleife bestimmen 393 if( nDestPos < nSourcePos ) 394 nInc = -1; 395 396 for( i = nSourcePos; i != nDestPos; i += nInc ) 397 pClassData->pEntries[ i ] = pClassData->pEntries[ i + nInc ]; 398 399 // Zuweisung Quelle auf Ziel 400 pClassData->pEntries[ nDestPos ] = aEntry; 401 } 402 else 403 aError = ERR_RSCCONT; 404 return aError; 405 } 406 407 /************************************************************************* 408 |* 409 |* RscBaseCont::SetPosRscId() 410 |* 411 |* Beschreibung 412 |* Ersterstellung MM 30.09.91 413 |* Letzte Aenderung MM 30.09.91 414 |* 415 *************************************************************************/ 416 ERRTYPE RscBaseCont::SetPosRscId( const RSCINST & rInst, sal_uInt32 nPos, 417 const RscId & rId ){ 418 RscBaseContInst * pClassData; 419 RSCINST aTmpI; 420 ERRTYPE aError; 421 422 pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData); 423 424 if( nPos < pClassData->nEntries ){ 425 if( ! (rId == pClassData->pEntries[ nPos ].aName) ) 426 aTmpI = SearchEle( rInst, rId, 427 pClassData->pEntries[ nPos ].aInst.pClass ); 428 if( !aTmpI.IsInst() ) 429 pClassData->pEntries[ nPos ].aName = rId; 430 else 431 aError = ERR_RSCCONT; 432 } 433 else 434 aError = ERR_RSCCONT; 435 return( aError ); 436 } 437 438 /************************************************************************* 439 |* 440 |* RscBaseCont::GetInfoEle() 441 |* 442 |* Beschreibung 443 |* Ersterstellung MM 08.05.91 444 |* Letzte Aenderung MM 08.05.91 445 |* 446 *************************************************************************/ 447 SUBINFO_STRUCT RscBaseCont::GetInfoEle( const RSCINST & rInst, sal_uInt32 nPos ){ 448 RscBaseContInst * pClassData; 449 SUBINFO_STRUCT aInfo; 450 451 pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData); 452 453 if( nPos < pClassData->nEntries ){ 454 aInfo.aId = pClassData->pEntries[ nPos ].aName; 455 aInfo.nPos = nPos; 456 aInfo.pClass = pClassData->pEntries[ nPos ].aInst.pClass; 457 } 458 return( aInfo ); 459 } 460 461 /************************************************************************* 462 |* 463 |* RscBaseCont::SetString() 464 |* 465 |* Beschreibung 466 |* Ersterstellung MM 29.04.91 467 |* Letzte Aenderung MM 29.04.91 468 |* 469 *************************************************************************/ 470 ERRTYPE RscBaseCont::SetString( const RSCINST & rInst, const char * pStr ) 471 { 472 RscBaseContInst * pClassData; 473 RSCINST aTmpI; 474 ERRTYPE aError; 475 char *pTmpStr; 476 477 pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData); 478 479 //?B 040991 480 //?W 040991 sonst Endlosrekursion moeglich 481 if( RSC_NOTYPE == pTypeClass->GetTypId() ){ 482 aError = GetElement( rInst, RscId(), pTypeClass, RSCINST(), &aTmpI ); 483 aError = aTmpI.pClass->GetString( aTmpI, &pTmpStr ); 484 if( aError.IsOk() ) 485 aError = aTmpI.pClass->SetString( aTmpI, pStr ); 486 else { 487 aError.Clear(); 488 DeletePos( rInst, pClassData->nEntries -1 ); 489 aError = GetElement( rInst, RscId(), pTypeClass1, RSCINST(), &aTmpI ); 490 aError = aTmpI.pClass->GetString( aTmpI, &pTmpStr ); 491 if( aError.IsOk() ) 492 aError = aTmpI.pClass->SetString( aTmpI, pStr ); 493 } 494 if( aError.IsError() ) 495 DeletePos( rInst, pClassData->nEntries -1 ); 496 } 497 else 498 aError = ERR_UNKNOWN_METHOD; 499 500 return( aError ); 501 } 502 503 /************************************************************************* 504 |* 505 |* RscBaseCont::SetNumber() 506 |* 507 |* Beschreibung 508 |* Ersterstellung MM 12.06.91 509 |* Letzte Aenderung MM 12.06.91 510 |* 511 *************************************************************************/ 512 ERRTYPE RscBaseCont::SetNumber( const RSCINST & rInst, sal_Int32 lValue ){ 513 RscBaseContInst * pClassData; 514 RSCINST aTmpI; 515 ERRTYPE aError; 516 sal_Int32 lNumber; 517 518 pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData); 519 520 //?B 040991 521 //?W 040991 sonst Endlosrekursion moeglich 522 if( RSC_NOTYPE == pTypeClass->GetTypId() ){ 523 aError = GetElement( rInst, RscId(), pTypeClass, RSCINST(), &aTmpI ); 524 aError = aTmpI.pClass->GetNumber( aTmpI, &lNumber ); 525 if( aError.IsOk() ) 526 aError = aTmpI.pClass->SetNumber( aTmpI, lValue ); 527 else { 528 aError.Clear(); 529 DeletePos( rInst, pClassData->nEntries -1 ); 530 aError = GetElement( rInst, RscId(), pTypeClass1, RSCINST(), &aTmpI ); 531 aError = aTmpI.pClass->GetNumber( aTmpI, &lNumber ); 532 if( aError.IsOk() ) 533 aError = aTmpI.pClass->SetNumber( aTmpI, lValue ); 534 } 535 if( aError.IsError() ) 536 DeletePos( rInst, pClassData->nEntries -1 ); 537 } 538 else 539 aError = ERR_UNKNOWN_METHOD; 540 541 return( aError ); 542 } 543 544 //================================================================== 545 ERRTYPE RscBaseCont::SetBool 546 ( 547 const RSCINST & rInst, 548 sal_Bool bValue 549 ) 550 { 551 RscBaseContInst * pClassData; 552 RSCINST aTmpI; 553 ERRTYPE aError; 554 sal_Bool bBool; 555 556 pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData); 557 558 //?B 040991 559 //?W 040991 sonst Endlosrekursion moeglich 560 if( RSC_NOTYPE == pTypeClass->GetTypId() ) 561 { 562 aError = GetElement( rInst, RscId(), pTypeClass, RSCINST(), &aTmpI ); 563 aError = aTmpI.pClass->GetBool( aTmpI, &bBool ); 564 if( aError.IsOk() ) 565 aError = aTmpI.pClass->SetBool( aTmpI, bValue ); 566 else { 567 aError.Clear(); 568 DeletePos( rInst, pClassData->nEntries -1 ); 569 aError = GetElement( rInst, RscId(), pTypeClass1, RSCINST(), &aTmpI ); 570 aError = aTmpI.pClass->GetBool( aTmpI, &bBool ); 571 if( aError.IsOk() ) 572 aError = aTmpI.pClass->SetBool( aTmpI, bValue ); 573 } 574 if( aError.IsError() ) 575 DeletePos( rInst, pClassData->nEntries -1 ); 576 } 577 else 578 aError = ERR_UNKNOWN_METHOD; 579 580 return( aError ); 581 } 582 583 //================================================================== 584 ERRTYPE RscBaseCont::SetConst 585 ( 586 const RSCINST & rInst, 587 Atom nValueId, 588 sal_Int32 lValue 589 ) 590 { 591 RscBaseContInst * pClassData; 592 RSCINST aTmpI; 593 ERRTYPE aError; 594 Atom nConst; 595 596 pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData); 597 598 //?B 040991 599 //?W 040991 sonst Endlosrekursion moeglich 600 if( RSC_NOTYPE == pTypeClass->GetTypId() ){ 601 aError = GetElement( rInst, RscId(), pTypeClass, RSCINST(), &aTmpI ); 602 aError = aTmpI.pClass->GetConst( aTmpI, &nConst ); 603 if( aError.IsOk() ) 604 aError = aTmpI.pClass->SetConst( aTmpI, nValueId, lValue ); 605 else { 606 aError.Clear(); 607 DeletePos( rInst, pClassData->nEntries -1 ); 608 aError = GetElement( rInst, RscId(), pTypeClass1, RSCINST(), &aTmpI ); 609 aError = aTmpI.pClass->GetConst( aTmpI, &nConst ); 610 if( aError.IsOk() ) 611 aError = aTmpI.pClass->SetConst( aTmpI, nValueId, lValue ); 612 } 613 if( aError.IsError() ) 614 DeletePos( rInst, pClassData->nEntries -1 ); 615 } 616 else 617 aError = ERR_UNKNOWN_METHOD; 618 619 return( aError ); 620 } 621 622 /************************************************************************* 623 |* 624 |* RscBaseCont::SetRef() 625 |* 626 |* Beschreibung 627 |* Ersterstellung MM 02.12.91 628 |* Letzte Aenderung MM 02.12.91 629 |* 630 *************************************************************************/ 631 ERRTYPE RscBaseCont::SetRef( const RSCINST & rInst, const RscId & rRefId ){ 632 RscBaseContInst * pClassData; 633 RSCINST aTmpI; 634 ERRTYPE aError; 635 RscId aId; 636 637 pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData); 638 639 //?B 040991 640 //?W 040991 sonst Endlosrekursion moeglich 641 if( RSC_NOTYPE == pTypeClass->GetTypId() ){ 642 aError = GetElement( rInst, RscId(), pTypeClass, RSCINST(), &aTmpI ); 643 aError = aTmpI.pClass->GetRef( aTmpI, &aId ); 644 if( aError.IsOk() ) 645 aError = aTmpI.pClass->SetRef( aTmpI, rRefId ); 646 else { 647 aError.Clear(); 648 DeletePos( rInst, pClassData->nEntries -1 ); 649 aError = GetElement( rInst, RscId(), pTypeClass1, RSCINST(), &aTmpI ); 650 aError = aTmpI.pClass->GetRef( aTmpI, &aId ); 651 if( aError.IsOk() ) 652 aError = aTmpI.pClass->SetNumber( aTmpI, rRefId ); 653 } 654 if( aError.IsError() ) 655 DeletePos( rInst, pClassData->nEntries -1 ); 656 } 657 else 658 aError = ERR_UNKNOWN_METHOD; 659 660 return( aError ); 661 } 662 663 /************************************************************************* 664 |* 665 |* RscBaseCont::IsConsistent() 666 |* 667 |* Beschreibung 668 |* Ersterstellung MM 23.09.91 669 |* Letzte Aenderung MM 23.09.91 670 |* 671 *************************************************************************/ 672 sal_Bool RscBaseCont::IsConsistent( const RSCINST & rInst, RscInconsList * pList ){ 673 sal_uInt32 i = 0; 674 RscBaseContInst * pClassData; 675 sal_Bool bRet; 676 677 bRet = RscTop::IsConsistent( rInst, pList ); 678 679 pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData); 680 681 // auf doppelten Id Testen und Reihenfolge beibehalten 682 // Komplexitaet = n^2 / 2 683 for( i = 0; i < pClassData->nEntries; i++ ){ 684 if( !bNoId ){ 685 if( (sal_Int32)pClassData->pEntries[ i ].aName > 0x7FFF 686 || (sal_Int32)pClassData->pEntries[ i ].aName < 1 ){ 687 bRet = sal_False; 688 if( pList ) 689 pList->Insert( new RscInconsistent( 690 pClassData->pEntries[ i ].aName, 691 pClassData->pEntries[ i ].aName ) ); 692 } 693 else if( SearchElePos( rInst, pClassData->pEntries[ i ].aName, 694 pClassData->pEntries[ i ].aInst.pClass, i +1 ).IsInst() ) 695 { 696 bRet = sal_False; 697 if( pList ) 698 pList->Insert( new RscInconsistent( 699 pClassData->pEntries[ i ].aName, 700 pClassData->pEntries[ i +1 ].aName ) ); 701 }; 702 } 703 if( ! pClassData->pEntries[ i ].aInst.pClass-> 704 IsConsistent( pClassData->pEntries[ i ].aInst, pList ) ) 705 bRet = sal_False; 706 }; 707 708 return( bRet ); 709 } 710 711 /************************************************************************* 712 |* 713 |* RscBaseCont::SetToDefault() 714 |* 715 |* Beschreibung 716 |* Ersterstellung MM 25.04.91 717 |* Letzte Aenderung MM 25.04.91 718 |* 719 *************************************************************************/ 720 void RscBaseCont::SetToDefault( const RSCINST & rInst ) 721 { 722 sal_uInt32 i = 0; 723 RscBaseContInst * pClassData; 724 725 pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData); 726 727 for( i = 0; i < pClassData->nEntries; i++ ) 728 { 729 pClassData->pEntries[ i ].aInst.pClass-> 730 SetToDefault( pClassData->pEntries[ i ].aInst ); 731 }; 732 733 RscTop::SetToDefault( rInst ); 734 } 735 736 /************************************************************************* 737 |* 738 |* RscBaseCont::IsDefault() 739 |* 740 |* Beschreibung 741 |* Ersterstellung MM 25.04.91 742 |* Letzte Aenderung MM 25.04.91 743 |* 744 *************************************************************************/ 745 sal_Bool RscBaseCont::IsDefault( const RSCINST & rInst ){ 746 sal_uInt32 i = 0; 747 RscBaseContInst * pClassData; 748 749 pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData); 750 751 if( !pClassData->bDflt ) 752 return sal_False; 753 754 for( i = 0; i < pClassData->nEntries; i++ ){ 755 if( ! pClassData->pEntries[ i ].aInst.pClass-> 756 IsDefault( pClassData->pEntries[ i ].aInst ) ) 757 { 758 return( sal_False ); 759 }; 760 }; 761 762 return( RscTop::IsDefault( rInst ) ); 763 } 764 765 /************************************************************************* 766 |* 767 |* RscBaseCont::IsValueDefault() 768 |* 769 |* Beschreibung 770 |* Ersterstellung MM 25.04.91 771 |* Letzte Aenderung MM 15.01.92 772 |* 773 *************************************************************************/ 774 sal_Bool RscBaseCont::IsValueDefault( const RSCINST & rInst, CLASS_DATA pDef ) 775 { 776 RscBaseContInst * pClassData; 777 778 if( !RscTop::IsValueDefault( rInst, pDef ) ) 779 return sal_False; 780 781 pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData); 782 783 if( pClassData->nEntries ) 784 return sal_False; 785 else 786 return sal_True; 787 } 788 789 /************************************************************************* 790 |* 791 |* RscBaseCont::Delete() 792 |* 793 |* Beschreibung 794 |* Ersterstellung MM 12.06.91 795 |* Letzte Aenderung MM 12.06.91 796 |* 797 *************************************************************************/ 798 void RscBaseCont::Delete( const RSCINST & rInst, RscTop * pClass, 799 const RscId & rId ) 800 { 801 sal_uInt32 i = 0; 802 RscBaseContInst * pClassData; 803 804 pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData); 805 if( !pClass ) 806 pClass = pTypeClass; 807 808 for( i = 0; i < pClassData->nEntries; i++ ){ 809 if( pClassData->pEntries[ i ].aName == rId ) 810 if( pClassData->pEntries[ i ].aInst.pClass == pClass || !pClass ){ 811 DeletePos( rInst, i ); 812 return; 813 }; 814 }; 815 816 } 817 818 /************************************************************************* 819 |* 820 |* RscBaseCont::DeletePos() 821 |* 822 |* Beschreibung 823 |* Ersterstellung MM 12.06.91 824 |* Letzte Aenderung MM 12.06.91 825 |* 826 *************************************************************************/ 827 void RscBaseCont::DeletePos( const RSCINST & rInst, sal_uInt32 nPos ){ 828 RscBaseContInst * pClassData; 829 sal_uInt32 i = 0; 830 831 pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData); 832 833 if( nPos < pClassData->nEntries ){ 834 if( 1 == pClassData->nEntries ) 835 DestroyElements( pClassData ); 836 else{ 837 pClassData->pEntries[ nPos ].Destroy(); 838 pClassData->nEntries--; 839 for( i = nPos; i < pClassData->nEntries; i++ ) 840 pClassData->pEntries[ i ] = pClassData->pEntries[ i + 1 ]; 841 }; 842 }; 843 } 844 845 /************************************************************************* 846 |* 847 |* RscBaseCont::ContWriteSrc() 848 |* 849 |* Beschreibung 850 |* Ersterstellung MM 26.04.91 851 |* Letzte Aenderung MM 26.04.91 852 |* 853 *************************************************************************/ 854 void RscBaseCont::ContWriteSrc( const RSCINST & rInst, FILE * fOutput, 855 RscTypCont * pTC, sal_uInt32 nTab, 856 const char * pVarName ) 857 { 858 sal_uInt32 i = 0, t = 0; 859 RscBaseContInst * pClassData; 860 861 pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData); 862 863 for( i = 0; i < pClassData->nEntries; i++ ) 864 { 865 for( t = 0; t < nTab; t++ ) 866 fputc( '\t', fOutput ); 867 pClassData->pEntries[ i ].aInst.pClass-> 868 WriteSrcHeader( pClassData->pEntries[ i ].aInst, 869 fOutput, pTC, nTab, 870 pClassData->pEntries[ i ].aName, pVarName ); 871 fprintf( fOutput, ";\n" ); 872 }; 873 } 874 875 /************************************************************************* 876 |* 877 |* RscBaseCont::ContWriteRc() 878 |* 879 |* Beschreibung 880 |* Ersterstellung MM 26.04.91 881 |* Letzte Aenderung MM 26.04.91 882 |* 883 *************************************************************************/ 884 ERRTYPE RscBaseCont::ContWriteRc( const RSCINST & rInst, RscWriteRc & rMem, 885 RscTypCont * pTC, sal_uInt32 nDeep, sal_Bool bExtra ) 886 { 887 sal_uInt32 i = 0; 888 RscBaseContInst * pClassData; 889 ERRTYPE aError; 890 891 if( bExtra || bNoId ) 892 { // Nur Subresourcen schreiben, wenn bExtra == sal_True 893 pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData); 894 895 for( i = 0; i < pClassData->nEntries && aError.IsOk(); i++ ){ 896 aError = pClassData->pEntries[ i ].aInst.pClass-> 897 WriteRcHeader( pClassData->pEntries[ i ].aInst, 898 rMem, pTC, 899 pClassData->pEntries[ i ].aName, 900 nDeep, bExtra ); 901 } 902 } 903 904 return( aError ); 905 } 906 907 //================================================================== 908 void RscBaseCont::ContWriteRcAccess 909 ( 910 FILE * fOutput, 911 RscTypCont * pTC, 912 const char * pName, 913 sal_Bool bWriteSize 914 ) 915 { 916 if( (bNoId || bWriteSize) && !pTypeClass1 ) 917 { 918 fprintf( fOutput, "\t\tsal_uInt32 nItems = *(sal_uInt32 *)(pResData+nOffset) );\n" ); 919 fprintf( fOutput, "\t\tnOffset += sizeof( sal_uInt32 );\n" ); 920 921 fprintf( fOutput, "\t\t// Items hinzufuegen\n" ); 922 fprintf( fOutput, "\t\tfor( sal_uInt32 i = 0; i < nItems; i++ )\n" ); 923 fprintf( fOutput, "\t\t{\n" ); 924 pTypeClass->WriteRcAccess( fOutput, pTC, "Item" ); 925 fprintf( fOutput, "\t\t}\n" ); 926 } 927 else 928 { 929 fprintf( fOutput, "\t\tSet%s( %s ", pName, pHS->getString( GetId() ).getStr() ); 930 fprintf( fOutput, "%s ", aCallPar2.GetBuffer() ); 931 fprintf( fOutput, "ResId( (RSHEADER_TYPE*)(pResData+nOffset) ) ) );\n" ); 932 fprintf( fOutput, "\t\tnOffset += GetObjSizeRes( (RSHEADER_TYPE*)(pResData+nOffset) );\n" ); 933 } 934 } 935 936 937 /************************************************************************* 938 |* 939 |* RscBaseCont::WriteSrc() 940 |* 941 |* Beschreibung 942 |* Ersterstellung MM 26.04.91 943 |* Letzte Aenderung MM 26.04.91 944 |* 945 *************************************************************************/ 946 void RscBaseCont::WriteSrc( const RSCINST & rInst, FILE * fOutput, 947 RscTypCont * pTC, sal_uInt32 nTab, 948 const char * pVarName ) 949 { 950 RscTop::WriteSrc( rInst, fOutput, pTC, nTab, pVarName ); 951 ContWriteSrc( rInst, fOutput, pTC, nTab, pVarName ); 952 } 953 954 /************************************************************************* 955 |* 956 |* RscBaseCont::WriteRc() 957 |* 958 |* Beschreibung 959 |* Ersterstellung MM 26.04.91 960 |* Letzte Aenderung MM 26.04.91 961 |* 962 *************************************************************************/ 963 ERRTYPE RscBaseCont::WriteRc( const RSCINST & rInst, RscWriteRc & rMem, 964 RscTypCont * pTC, sal_uInt32 nDeep, sal_Bool bExtra ) 965 { 966 ERRTYPE aError; 967 968 aError = RscTop::WriteRc( rInst, rMem, pTC, nDeep, bExtra ); 969 if( aError.IsOk() ) 970 aError = ContWriteRc( rInst, rMem, pTC, nDeep, bExtra ); 971 972 return( aError ); 973 } 974 975 /************************************************************************* 976 |* 977 |* RscBaseCont::WriteHxx() 978 |* 979 |* Beschreibung 980 |* Ersterstellung MM 26.04.91 981 |* Letzte Aenderung MM 26.04.91 982 |* 983 *************************************************************************/ 984 ERRTYPE RscBaseCont::WriteHxx( const RSCINST & rInst, FILE * fOutput, 985 RscTypCont * pTC, const RscId & rRscId ) 986 { 987 sal_uInt32 i = 0; 988 RscBaseContInst * pClassData; 989 ERRTYPE aError; 990 991 aError = RscTop::WriteHxx( rInst, fOutput, pTC, rRscId ); 992 993 pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData); 994 995 for( i = 0; i < pClassData->nEntries && aError.IsOk(); i++ ) 996 { 997 if( pClassData->pEntries[ i ].aName.IsId() 998 && pClassData->pEntries[ i ].aInst.pClass->IsCodeWriteable() ) 999 { 1000 aError = pClassData->pEntries[ i ].aInst.pClass-> 1001 WriteHxx( pClassData->pEntries[ i ].aInst, 1002 fOutput, pTC, 1003 pClassData->pEntries[ i ].aName ); 1004 } 1005 }; 1006 1007 return( aError ); 1008 } 1009 1010 /************************************************************************* 1011 |* 1012 |* RscBaseCont::WriteCxx() 1013 |* 1014 |* Beschreibung 1015 |* Ersterstellung MM 26.04.91 1016 |* Letzte Aenderung MM 26.04.91 1017 |* 1018 *************************************************************************/ 1019 ERRTYPE RscBaseCont::WriteCxx( const RSCINST & rInst, FILE * fOutput, 1020 RscTypCont * pTC, const RscId & rRscId ) 1021 { 1022 sal_uInt32 i = 0; 1023 RscBaseContInst * pClassData; 1024 ERRTYPE aError; 1025 1026 aError = RscTop::WriteCxx( rInst, fOutput, pTC, rRscId ); 1027 1028 pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData); 1029 1030 for( i = 0; i < pClassData->nEntries && aError.IsOk(); i++ ) 1031 { 1032 if( pClassData->pEntries[ i ].aName.IsId() 1033 && pClassData->pEntries[ i ].aInst.pClass->IsCodeWriteable() ) 1034 { 1035 aError = pClassData->pEntries[ i ].aInst.pClass-> 1036 WriteCxx( pClassData->pEntries[ i ].aInst, 1037 fOutput, pTC, 1038 pClassData->pEntries[ i ].aName ); 1039 } 1040 }; 1041 1042 return( aError ); 1043 } 1044 1045 /*************** R s c C o n t W r i t e S r c ***************************/ 1046 /************************************************************************* 1047 |* 1048 |* RscContWriteSrc::RscContWriteSrc() 1049 |* 1050 |* Beschreibung 1051 |* Ersterstellung MM 08.05.91 1052 |* Letzte Aenderung MM 08.05.91 1053 |* 1054 *************************************************************************/ 1055 RscContWriteSrc::RscContWriteSrc( Atom nId, sal_uInt32 nTypeId, 1056 RscTop * pSuper, sal_Bool bNoIdent ) 1057 : RscBaseCont( nId, nTypeId, pSuper, bNoIdent ) 1058 {} 1059 1060 /************************************************************************* 1061 |* 1062 |* RscContWriteSrc::WriteSrc() 1063 |* 1064 |* Beschreibung 1065 |* Ersterstellung MM 08.05.91 1066 |* Letzte Aenderung MM 08.05.91 1067 |* 1068 *************************************************************************/ 1069 void RscContWriteSrc::WriteSrc( const RSCINST & rInst, FILE * fOutput, 1070 RscTypCont * pTC, sal_uInt32 nTab, 1071 const char * pVarName ) 1072 { 1073 sal_uInt32 i; 1074 1075 RscTop::WriteSrc( rInst, fOutput, pTC, nTab, pVarName ); 1076 1077 fprintf( fOutput, "\n" ); 1078 for( i = 0; i < nTab; i++ ) 1079 fputc( '\t', fOutput ); 1080 fprintf( fOutput, "{\n" ); 1081 1082 ContWriteSrc( rInst, fOutput, pTC, nTab +1, pVarName ); 1083 1084 for( i = 0; i < nTab; i++ ) 1085 fputc( '\t', fOutput ); 1086 fprintf( fOutput, "}" ); 1087 } 1088 1089 /*************** R s c C o n t *******************************************/ 1090 /************************************************************************* 1091 |* 1092 |* RscCont::RscCont() 1093 |* 1094 |* Beschreibung 1095 |* Ersterstellung MM 08.05.91 1096 |* Letzte Aenderung MM 08.05.91 1097 |* 1098 *************************************************************************/ 1099 RscCont::RscCont( Atom nId, sal_uInt32 nTypeId, RscTop * pSuper, sal_Bool bNoIdent ) 1100 : RscContWriteSrc( nId, nTypeId, pSuper, bNoIdent ) 1101 {} 1102 1103 /************************************************************************* 1104 |* 1105 |* RscCont::WriteRc() 1106 |* 1107 |* Beschreibung 1108 |* Ersterstellung MM 08.05.91 1109 |* Letzte Aenderung MM 08.05.91 1110 |* 1111 *************************************************************************/ 1112 ERRTYPE RscCont::WriteRc( const RSCINST & rInst, RscWriteRc & rMem, 1113 RscTypCont * pTC, sal_uInt32 nDeep, sal_Bool bExtra ) 1114 { 1115 RscBaseContInst * pClassData; 1116 ERRTYPE aError; 1117 1118 aError = RscTop::WriteRc( rInst, rMem, pTC, nDeep, bExtra ); 1119 1120 pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData); 1121 1122 rMem.Put( pClassData->nEntries ); 1123 1124 if( aError.IsOk() ) 1125 aError = ContWriteRc( rInst, rMem, pTC, nDeep, bExtra ); 1126 1127 return aError; 1128 } 1129 1130 //================================================================== 1131 void RscCont::WriteRcAccess 1132 ( 1133 FILE * fOutput, 1134 RscTypCont * pTC, 1135 const char * pName 1136 ) 1137 { 1138 ContWriteRcAccess( fOutput, pTC, pName, sal_True ); 1139 } 1140 1141 /************************************************************************* 1142 |* 1143 |* RscContExtraData::RscContExtraData() 1144 |* 1145 |* Beschreibung 1146 |* Ersterstellung MM 08.05.91 1147 |* Letzte Aenderung MM 08.05.91 1148 |* 1149 *************************************************************************/ 1150 RscContExtraData::RscContExtraData( Atom nId, sal_uInt32 nTypeId, 1151 RscTop * pSuper, sal_Bool bNoIdent ) 1152 : RscContWriteSrc( nId, nTypeId, pSuper, bNoIdent ) 1153 {} 1154 1155 /************************************************************************* 1156 |* 1157 |* RscContExtraData::WriteRc() 1158 |* 1159 |* Beschreibung 1160 |* Ersterstellung MM 08.05.91 1161 |* Letzte Aenderung MM 08.05.91 1162 |* 1163 *************************************************************************/ 1164 ERRTYPE RscContExtraData::WriteRc( const RSCINST & rInst, RscWriteRc & rMem, 1165 RscTypCont * pTC, sal_uInt32 nDeep, sal_Bool bExtra ) 1166 { 1167 ERRTYPE aError; 1168 1169 if( bExtra ) 1170 aError = RscContWriteSrc::WriteRc( rInst, rMem, pTC, nDeep, bExtra ); 1171 else 1172 aError = RscTop::WriteRc( rInst, rMem, pTC, nDeep, bExtra ); 1173 1174 return aError; 1175 } 1176