1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
#include <ctype.h>
#include <stdio.h>
#include <rtl/strbuf.hxx>
#include <tools/debug.hxx>
#include <object.hxx>
#include <globals.hxx>
#include <database.hxx>
SV_IMPL_PERSIST1( SvClassElement, SvPersistBase );
SvClassElement::SvClassElement()
{
};
void SvClassElement::Load( SvPersistStream & rStm )
{
sal_uInt8 nMask;
rStm >> nMask;
if( nMask >= 0x08 )
{
rStm.SetError( SVSTREAM_FILEFORMAT_ERROR );
OSL_FAIL( "wrong format" );
return;
}
if( nMask & 0x01 ) rStm >> aAutomation;
if( nMask & 0x02 ) rStm.ReadByteString( aPrefix );
if( nMask & 0x04 )
{
SvMetaClass * p;
rStm >> p;
xClass = p;
}
}
void SvClassElement::Save( SvPersistStream & rStm )
{
// create mask
sal_uInt8 nMask = 0;
if( aAutomation.IsSet() ) nMask |= 0x1;
if( aPrefix.Len() ) nMask |= 0x2;
if( xClass.Is() ) nMask |= 0x4;
// write data
rStm << nMask;
if( nMask & 0x01 ) rStm << aAutomation;
if( nMask & 0x02 ) rStm.WriteByteString( aPrefix );
if( nMask & 0x04 ) rStm << xClass;
}
SV_IMPL_META_FACTORY1( SvMetaClass, SvMetaType );
SvMetaClass::SvMetaClass()
: aAutomation( sal_True, sal_False )
{
}
void SvMetaClass::Load( SvPersistStream & rStm )
{
SvMetaType::Load( rStm );
sal_uInt8 nMask;
rStm >> nMask;
if( nMask >= 0x20 )
{
rStm.SetError( SVSTREAM_FILEFORMAT_ERROR );
OSL_FAIL( "wrong format" );
return;
}
if( nMask & 0x01 ) rStm >> aAttrList;
if( nMask & 0x02 )
{
SvMetaClass * pSuper;
rStm >> pSuper;
aSuperClass = pSuper;
}
if( nMask & 0x04 ) rStm >> aClassList;
if( nMask & 0x8 )
{
SvMetaClass * p;
rStm >> p;
xAutomationInterface = p;
}
if( nMask & 0x10 ) rStm >> aAutomation;
}
void SvMetaClass::Save( SvPersistStream & rStm )
{
SvMetaType::Save( rStm );
// create mask
sal_uInt8 nMask = 0;
if( aAttrList.Count() ) nMask |= 0x1;
if( aSuperClass.Is() ) nMask |= 0x2;
if( aClassList.Count() ) nMask |= 0x4;
if( xAutomationInterface.Is() ) nMask |= 0x8;
if( aAutomation.IsSet() ) nMask |= 0x10;
// write data
rStm << nMask;
if( nMask & 0x01 ) rStm << aAttrList;
if( nMask & 0x02 ) rStm << aSuperClass;
if( nMask & 0x04 ) rStm << aClassList;
if( nMask & 0x08 ) rStm << xAutomationInterface;
if( nMask & 0x10 ) rStm << aAutomation;
}
#ifdef IDL_COMPILER
void SvMetaClass::ReadAttributesSvIdl( SvIdlDataBase & rBase,
SvTokenStream & rInStm )
{
SvMetaType::ReadAttributesSvIdl( rBase, rInStm );
aAutomation.ReadSvIdl( SvHash_Automation(), rInStm );
}
void SvMetaClass::WriteAttributesSvIdl( SvIdlDataBase & rBase,
SvStream & rOutStm, sal_uInt16 nTab )
{
SvMetaType::WriteAttributesSvIdl( rBase, rOutStm, nTab );
if( !aAutomation )
{
WriteTab( rOutStm, nTab );
rOutStm << "//class SvMetaClass" << endl;
if( !aAutomation )
{
WriteTab( rOutStm, nTab );
aAutomation.WriteSvIdl( SvHash_Automation(), rOutStm );
rOutStm << ';' << endl;
}
}
}
void SvMetaClass::ReadContextSvIdl( SvIdlDataBase & rBase,
SvTokenStream & rInStm )
{
sal_uInt32 nTokPos = rInStm.Tell();
SvToken * pTok = rInStm.GetToken_Next();
if( pTok->Is( SvHash_import() ) )
{
SvMetaClass * pClass = rBase.ReadKnownClass( rInStm );
if( pClass )
{
SvClassElementRef xEle = new SvClassElement();
xEle->SetClass( pClass );
aClassList.Append( xEle );
if( rInStm.Read( '[' ) )
{
pTok = rInStm.GetToken_Next();
if( pTok->Is( SvHash_Automation() ) )
{
if( rInStm.Read( ']' ) )
{
if( xAutomationInterface.Is() )
{
// set error
rBase.SetError( "Automation allready set",
rInStm.GetToken() );
rBase.WriteError( rInStm );
}
xAutomationInterface = pClass;
xEle->SetAutomation( sal_True );
}
else
{
// set error
rBase.SetError( "missing ]", rInStm.GetToken() );
rBase.WriteError( rInStm );
}
}
else
{
// set error
rBase.SetError( "only attribute Automation allowed",
rInStm.GetToken() );
rBase.WriteError( rInStm );
}
}
pTok = rInStm.GetToken();
if( pTok->IsString() )
{
xEle->SetPrefix( pTok->GetString() );
rInStm.GetToken_Next();
}
return;
}
else
{
// set error
rBase.SetError( "unknown imported interface", rInStm.GetToken() );
rBase.WriteError( rInStm );
}
}
else
{
rInStm.Seek( nTokPos );
SvMetaType * pType = rBase.ReadKnownType( rInStm );
sal_Bool bOk = sal_False;
SvMetaAttributeRef xAttr;
if( !pType || pType->IsItem() )
{
xAttr = new SvMetaSlot( pType );
if( xAttr->ReadSvIdl( rBase, rInStm ) )
bOk = xAttr->Test( rBase, rInStm );
}
else
{
xAttr = new SvMetaAttribute( pType );
if( xAttr->ReadSvIdl( rBase, rInStm ) )
bOk = xAttr->Test( rBase, rInStm );
}
if( bOk )
bOk = TestAttribute( rBase, rInStm, *xAttr );
if( bOk )
{
if( !xAttr->GetSlotId().IsSet() )
{
SvNumberIdentifier aI;
aI.SetValue( rBase.GetUniqueId() );
xAttr->SetSlotId( aI );
}
aAttrList.Append( xAttr );
return;
}
}
rInStm.Seek( nTokPos );
}
void SvMetaClass::WriteContextSvIdl
(
SvIdlDataBase & rBase,
SvStream & rOutStm,
sal_uInt16 nTab
)
{
sal_uLong n;
for( n = 0; n < aAttrList.Count(); n++ )
{
WriteTab( rOutStm, nTab );
aAttrList.GetObject( n )->WriteSvIdl( rBase, rOutStm, nTab );
rOutStm << ';' << endl;
}
for( n = 0; n < aClassList.Count(); n++ )
{
SvClassElement * pEle = aClassList.GetObject( n );
WriteTab( rOutStm, nTab );
rOutStm << SvHash_import()->GetName().GetBuffer() << ' '
<< pEle->GetPrefix().GetBuffer();
if( pEle->GetAutomation() )
rOutStm << " [ " << SvHash_Automation()->GetName().GetBuffer()
<< " ]";
if( pEle->GetPrefix().Len() )
rOutStm << ' ' << pEle->GetPrefix().GetBuffer();
rOutStm << ';' << endl;
}
}
sal_Bool SvMetaClass::ReadSvIdl( SvIdlDataBase & rBase, SvTokenStream & rInStm )
{
sal_uLong nTokPos = rInStm.Tell();
if( SvMetaType::ReadHeaderSvIdl( rBase, rInStm ) && GetType() == TYPE_CLASS )
{
sal_Bool bOk = sal_True;
if( rInStm.Read( ':' ) )
{
aSuperClass = rBase.ReadKnownClass( rInStm );
bOk = aSuperClass.Is();
if( !bOk )
{
// set error
rBase.SetError( "unknown super class",
rInStm.GetToken() );
rBase.WriteError( rInStm );
}
}
if( bOk )
{
rBase.Write(rtl::OString('.'));
bOk = SvMetaName::ReadSvIdl( rBase, rInStm );
}
if( bOk )
return bOk;
}
rInStm.Seek( nTokPos );
return sal_False;
}
sal_Bool SvMetaClass::TestAttribute( SvIdlDataBase & rBase, SvTokenStream & rInStm,
SvMetaAttribute & rAttr ) const
{
if ( !rAttr.GetRef() && rAttr.IsA( TYPE( SvMetaSlot ) ) )
{
OSL_FAIL( "Neuer Slot : " );
OSL_FAIL( rAttr.GetSlotId().GetBuffer() );
}
for( sal_uLong n = 0; n < aAttrList.Count(); n++ )
{
SvMetaAttribute * pS = aAttrList.GetObject( n );
if( pS->GetName() == rAttr.GetName() )
{
// values have to match
if( pS->GetSlotId().GetValue() != rAttr.GetSlotId().GetValue() )
{
OSL_FAIL( "Gleicher Name in MetaClass : " );
OSL_FAIL( pS->GetName().GetBuffer() );
OSL_FAIL( pS->GetSlotId().GetBuffer() );
OSL_FAIL( rAttr.GetSlotId().GetBuffer() );
ByteString aStr( "Attribute's " );
aStr += pS->GetName();
aStr += " with different id's";
rBase.SetError( aStr, rInStm.GetToken() );
rBase.WriteError( rInStm );
return sal_False;
}
}
else
{
sal_uInt32 nId1 = pS->GetSlotId().GetValue();
sal_uInt32 nId2 = rAttr.GetSlotId().GetValue();
if( nId1 == nId2 && nId1 != 0 )
{
OSL_FAIL( "Gleiche Id in MetaClass : " );
OSL_FAIL(rtl::OString::valueOf(static_cast<sal_Int32>(
pS->GetSlotId().GetValue())).getStr());
OSL_FAIL( pS->GetSlotId().GetBuffer() );
OSL_FAIL( rAttr.GetSlotId().GetBuffer() );
ByteString aStr( "Attribute " );
aStr += pS->GetName();
aStr += " and Attribute ";
aStr += rAttr.GetName();
aStr += " with equal id's";
rBase.SetError( aStr, rInStm.GetToken() );
rBase.WriteError( rInStm );
return sal_False;
}
}
}
SvMetaClass * pSC = aSuperClass;
if( pSC )
return pSC->TestAttribute( rBase, rInStm, rAttr );
return sal_True;
}
void SvMetaClass::WriteSvIdl( SvIdlDataBase & rBase, SvStream & rOutStm,
sal_uInt16 nTab )
{
WriteHeaderSvIdl( rBase, rOutStm, nTab );
if( aSuperClass.Is() )
rOutStm << " : " << aSuperClass->GetName().GetBuffer();
rOutStm << endl;
SvMetaName::WriteSvIdl( rBase, rOutStm, nTab );
rOutStm << endl;
}
void SvMetaClass::Write( SvIdlDataBase & rBase, SvStream & rOutStm,
sal_uInt16 nTab,
WriteType nT, WriteAttribute )
{
rBase.aIFaceName = GetName();
switch( nT )
{
case WRITE_ODL:
{
OSL_FAIL( "Not supported anymore!" );
break;
}
case WRITE_C_SOURCE:
case WRITE_C_HEADER:
{
OSL_FAIL( "Not supported anymore!" );
break;
}
case WRITE_DOCU:
{
rOutStm << "<INTERFACE>" << endl
<< GetName().GetBuffer();
if ( GetAutomation() )
rOutStm << " ( Automation ) ";
rOutStm << endl;
WriteDescription( rOutStm );
rOutStm << "</INTERFACE>" << endl << endl;
// write all attributes
sal_uLong n;
for( n = 0; n < aAttrList.Count(); n++ )
{
SvMetaAttribute * pAttr = aAttrList.GetObject( n );
if( !pAttr->GetHidden() )
{
if( pAttr->IsMethod() )
pAttr->Write( rBase, rOutStm, nTab, nT, WA_METHOD );
if( pAttr->IsVariable() )
pAttr->Write( rBase, rOutStm, nTab, nT, WA_VARIABLE );
}
}
break;
}
default:
break;
}
}
sal_uInt16 SvMetaClass::WriteSlotParamArray( SvIdlDataBase & rBase,
SvSlotElementList & rSlotList,
SvStream & rOutStm )
{
sal_uInt16 nCount = 0;
for ( size_t i = 0, n = rSlotList.size(); i < n; ++i )
{
SvSlotElement *pEle = rSlotList[ i ];
SvMetaSlot *pAttr = pEle->xSlot;
nCount = nCount + pAttr->WriteSlotParamArray( rBase, rOutStm );
}
return nCount;
}
sal_uInt16 SvMetaClass::WriteSlots( const ByteString & rShellName,
sal_uInt16 nCount, SvSlotElementList & rSlotList,
SvIdlDataBase & rBase,
SvStream & rOutStm )
{
sal_uInt16 nSCount = 0;
for ( size_t i = 0, n = rSlotList.size(); i < n; ++i )
{
SvSlotElement * pEle = rSlotList[ i ];
SvMetaSlot * pAttr = pEle->xSlot;
nSCount = nSCount + pAttr->WriteSlotMap( rShellName, nCount + nSCount,
rSlotList, i, pEle->aPrefix, rBase,
rOutStm );
}
return nSCount;
}
void SvMetaClass::InsertSlots( SvSlotElementList& rList, std::vector<sal_uLong>& rSuperList,
SvMetaClassList &rClassList,
const ByteString & rPrefix, SvIdlDataBase& rBase)
{
// was this class already written?
for ( size_t i = 0, n = rClassList.size(); i < n ; ++i )
if ( rClassList[ i ] == this )
return;
rClassList.push_back( this );
// write all direct attributes
sal_uLong n;
for( n = 0; n < aAttrList.Count(); n++ )
{
SvMetaAttribute * pAttr = aAttrList.GetObject( n );
sal_uLong nId = pAttr->GetSlotId().GetValue();
std::vector<sal_uLong>::iterator iter = std::find(rSuperList.begin(),
rSuperList.end(),nId);
if( iter == rSuperList.end() )
{
// Write only if not already written by subclass or
// imported interface.
rSuperList.push_back(nId);
pAttr->Insert(rList, rPrefix, rBase);
}
}
// All Interfaces already imported by SuperShells should not be
// written any more.
// It is prohibited that Shell and SuperShell directly import the same
//class.
if( IsShell() && aSuperClass.Is() )
aSuperClass->FillClasses( rClassList );
// Write all attributes of the imported classes, as long as they have
// not already been imported by the superclass.
for( n = 0; n < aClassList.Count(); n++ )
{
SvClassElement * pEle = aClassList.GetObject( n );
SvMetaClass * pCl = pEle->GetClass();
rtl::OStringBuffer rPre(rPrefix);
if( rPre.getLength() && pEle->GetPrefix().Len() )
rPre.append('.');
rPre.append(pEle->GetPrefix());
// first of all write direct imported interfaces
pCl->InsertSlots( rList, rSuperList, rClassList,
rPre.makeStringAndClear(), rBase );
}
// only write superclass if no shell and not in the list
if( !IsShell() && aSuperClass.Is() )
{
aSuperClass->InsertSlots( rList, rSuperList, rClassList, rPrefix, rBase );
}
}
void SvMetaClass::FillClasses( SvMetaClassList & rList )
{
// Am I not yet in?
for ( size_t i = 0, n = rList.size(); i < n; ++i )
if ( rList[ i ] == this )
return;
rList.push_back( this );
// my imports
for( sal_uInt32 n = 0; n < aClassList.Count(); n++ )
{
SvClassElement * pEle = aClassList.GetObject( n );
SvMetaClass * pCl = pEle->GetClass();
pCl->FillClasses( rList );
}
// my superclass
if( aSuperClass.Is() )
aSuperClass->FillClasses( rList );
}
void SvMetaClass::WriteSlotStubs( const ByteString & rShellName,
SvSlotElementList & rSlotList,
ByteStringList & rList,
SvStream & rOutStm )
{
// write all attributes
for ( size_t i = 0, n = rSlotList.size(); i < n; ++i )
{
SvSlotElement *pEle = rSlotList[ i ];
SvMetaSlot *pAttr = pEle->xSlot;
pAttr->WriteSlotStubs( rShellName, rList, rOutStm );
}
}
void SvMetaClass::WriteSfx( SvIdlDataBase & rBase, SvStream & rOutStm )
{
WriteStars( rOutStm );
// define class
rOutStm << "#ifdef " << GetName().GetBuffer() << endl;
rOutStm << "#undef ShellClass" << endl;
rOutStm << "#undef " << GetName().GetBuffer() << endl;
rOutStm << "#define ShellClass " << GetName().GetBuffer() << endl;
// no slotmaps get written for interfaces
if( !IsShell() )
{
rOutStm << "#endif" << endl << endl;
return;
}
// write parameter array
rOutStm << "SFX_ARGUMENTMAP(" << GetName().GetBuffer() << ')' << endl
<< '{' << endl;
std::vector<sal_uLong> aSuperList;
SvMetaClassList classList;
SvSlotElementList aSlotList;
InsertSlots(aSlotList, aSuperList, classList, ByteString(), rBase);
for ( size_t i = 0, n = aSlotList.size(); i < n; ++i )
{
SvSlotElement *pEle = aSlotList[ i ];
SvMetaSlot *pSlot = pEle->xSlot;
pSlot->SetListPos( i );
}
size_t nSlotCount = aSlotList.size();
// write all attributes
sal_uInt16 nArgCount = WriteSlotParamArray( rBase, aSlotList, rOutStm );
if( nArgCount )
Back2Delemitter( rOutStm );
else
{
// at leaast one dummy
WriteTab( rOutStm, 1 );
rOutStm << "SFX_ARGUMENT( 0, 0, SfxVoidItem )" << endl;
}
rOutStm << endl << "};" << endl << endl;
ByteStringList aStringList;
WriteSlotStubs( GetName(), aSlotList, aStringList, rOutStm );
for ( size_t i = 0, n = aStringList.size(); i < n; ++i )
delete aStringList[ i ];
aStringList.clear();
rOutStm << endl;
// write slotmap
rOutStm << "SFX_SLOTMAP_ARG(" << GetName().GetBuffer() << ')' << endl
<< '{' << endl;
// write all attributes
WriteSlots( GetName(), 0, aSlotList, rBase, rOutStm );
if( nSlotCount )
Back2Delemitter( rOutStm );
else
{
// at least one dummy
WriteTab( rOutStm, 1 );
rOutStm << "SFX_SLOT_ARG(" << GetName().GetBuffer()
<< ", 0, 0, "
<< "SFX_STUB_PTR_EXEC_NONE,"
<< "SFX_STUB_PTR_STATE_NONE,"
<< "0, SfxVoidItem, 0, 0, \"\", 0 )" << endl;
}
rOutStm << endl << "};" << endl << "#endif" << endl << endl;
for( size_t i = 0, n = aSlotList.size(); i < n; ++i )
{
SvSlotElement* pEle = aSlotList[ i ];
SvMetaSlot* pAttr = pEle->xSlot;
pAttr->ResetSlotPointer();
}
for( size_t i = 0, n = aSlotList.size(); i < n; ++i )
delete aSlotList[ i ];
aSlotList.clear();
}
void SvMetaClass::WriteHelpIds( SvIdlDataBase & rBase, SvStream & rOutStm,
Table* pTable )
{
for( sal_uLong n=0; n<aAttrList.Count(); n++ )
{
SvMetaAttribute * pAttr = aAttrList.GetObject( n );
pAttr->WriteHelpId( rBase, rOutStm, pTable );
}
}
void SvMetaClass::WriteSrc( SvIdlDataBase & rBase, SvStream & rOutStm,
Table * pTable )
{
for( sal_uLong n=0; n<aAttrList.Count(); n++ )
{
SvMetaAttribute * pAttr = aAttrList.GetObject( n );
pAttr->WriteSrc( rBase, rOutStm, pTable );
}
}
void SvMetaClass::WriteHxx( SvIdlDataBase &, SvStream & rOutStm, sal_uInt16 )
{
ByteString aSuperName( "SvDispatch" );
if( GetSuperClass() )
aSuperName = GetSuperClass()->GetName();
const char * pSup = aSuperName.GetBuffer();
rOutStm
<< "class " << GetSvName().GetBuffer()
<< ": public " << pSup << endl
<< '{' << endl
<< "protected:" << endl
<< "\tvirtual SvGlobalName GetTypeName() const;" << endl
<< "\tvirtual sal_Bool FillTypeLibInfo( SvGlobalName *, sal_uInt16 * pMajor," << endl
<< "\t sal_uInt16 * pMinor ) const;" << endl
<< "\tvirtual sal_Bool FillTypeLibInfo( ByteString * pName, sal_uInt16 * pMajor," << endl;
rOutStm
<< "\t sal_uInt16 * pMinor ) const;" << endl
<< "\tvirtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) = 0;" << endl
<< "public:" << endl
<< "\t static SvGlobalName ClassName()" << endl
<< "\t { return SvGlobalName( " << rtl::OUStringToOString(GetUUId().GetctorName(), RTL_TEXTENCODING_UTF8).getStr() << " ); }" << endl
<< "};" << endl;
}
void SvMetaClass::WriteCxx( SvIdlDataBase &, SvStream & rOutStm, sal_uInt16 )
{
ByteString aSuperName( "SvDispatch" );
if( GetSuperClass() )
aSuperName = GetSuperClass()->GetName();
const char * pSup = aSuperName.GetBuffer();
ByteString name = GetSvName();
// GetTypeName
rOutStm << "SvGlobalName " << name.GetBuffer() << "::GetTypeName() const" << endl
<< '{' << endl
<< "\treturn ClassName();" << endl
<< '}' << endl;
SvMetaModule * pMod = GetModule();
// FillTypeLibInfo
rOutStm << "sal_Bool " << name.GetBuffer() << "::FillTypeLibInfo( SvGlobalName * pGN," << endl
<< "\t sal_uInt16 * pMajor," << endl
<< "\t sal_uInt16 * pMinor ) const" << endl
<< '{' << endl
<< "\tSvGlobalName aN( " << rtl::OUStringToOString(pMod->GetUUId().GetctorName(), RTL_TEXTENCODING_UTF8).getStr() << " );" << endl;
rOutStm << "\t*pGN = aN;" << endl
<< "\t*pMajor = "
<< rtl::OString::valueOf(static_cast<sal_Int32>(pMod->GetVersion().GetMajorVersion())).getStr()
<< ';' << endl
<< "\t*pMinor = "
<< rtl::OString::valueOf(static_cast<sal_Int32>(pMod->GetVersion().GetMinorVersion())).getStr()
<< ';' << endl
<< "\treturn sal_True;" << endl
<< '}' << endl;
// FillTypeLibInfo
rOutStm << "sal_Bool " << name.GetBuffer() << "::FillTypeLibInfo( ByteString * pName,"
<< "\t sal_uInt16 * pMajor," << endl
<< "\t sal_uInt16 * pMinor ) const" << endl;
rOutStm << '{' << endl
<< "\t*pName = \"" << pMod->GetTypeLibFileName().GetBuffer() << "\";" << endl
<< "\t*pMajor = "
<< rtl::OString::valueOf(static_cast<sal_Int32>(pMod->GetVersion().GetMajorVersion())).getStr()
<< ';' << endl
<< "\t*pMinor = "
<< rtl::OString::valueOf(static_cast<sal_Int32>(pMod->GetVersion().GetMinorVersion())).getStr()
<< ';' << endl
<< "\treturn sal_True;" << endl
<< '}' << endl;
rOutStm << "void " << name.GetBuffer() << "::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )" << endl
<< '{' << endl
<< "\t" << pSup << "::Notify( rBC, rHint );" << endl
<< '}' << endl;
}
#endif // IDL_COMPILER
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|