2010-10-12 15:53:47 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-07-11 19:49:09 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2000-09-18 15:33:13 +00:00
|
|
|
|
2006-09-16 11:47:56 +00:00
|
|
|
|
2000-09-18 15:33:13 +00:00
|
|
|
#include <ctype.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2011-09-20 23:30:51 +01:00
|
|
|
#include <rtl/strbuf.hxx>
|
|
|
|
|
2000-09-18 15:33:13 +00:00
|
|
|
#include <object.hxx>
|
|
|
|
#include <globals.hxx>
|
|
|
|
#include <database.hxx>
|
|
|
|
|
|
|
|
SV_IMPL_PERSIST1( SvClassElement, SvPersistBase );
|
|
|
|
|
|
|
|
SvClassElement::SvClassElement()
|
|
|
|
{
|
|
|
|
};
|
|
|
|
|
|
|
|
void SvClassElement::Load( SvPersistStream & rStm )
|
|
|
|
{
|
2010-11-03 15:49:08 +01:00
|
|
|
sal_uInt8 nMask;
|
2014-02-05 10:41:04 +02:00
|
|
|
rStm.ReadUChar( nMask );
|
2000-09-18 15:33:13 +00:00
|
|
|
if( nMask >= 0x08 )
|
|
|
|
{
|
|
|
|
rStm.SetError( SVSTREAM_FILEFORMAT_ERROR );
|
2011-03-01 19:07:44 +01:00
|
|
|
OSL_FAIL( "wrong format" );
|
2000-09-18 15:33:13 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if( nMask & 0x01 ) rStm >> aAutomation;
|
2014-02-06 12:44:59 +02:00
|
|
|
if( nMask & 0x02 ) aPrefix = read_uInt16_lenPrefixed_uInt8s_ToOString(rStm);
|
2000-09-18 15:33:13 +00:00
|
|
|
if( nMask & 0x04 )
|
|
|
|
{
|
|
|
|
SvMetaClass * p;
|
|
|
|
rStm >> p;
|
|
|
|
xClass = p;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SvClassElement::Save( SvPersistStream & rStm )
|
|
|
|
{
|
2011-02-13 18:06:10 +01:00
|
|
|
// create mask
|
2010-11-03 15:49:08 +01:00
|
|
|
sal_uInt8 nMask = 0;
|
2000-09-18 15:33:13 +00:00
|
|
|
if( aAutomation.IsSet() ) nMask |= 0x1;
|
2012-01-26 09:46:41 +00:00
|
|
|
if( !aPrefix.isEmpty() ) nMask |= 0x2;
|
2000-09-18 15:33:13 +00:00
|
|
|
if( xClass.Is() ) nMask |= 0x4;
|
|
|
|
|
2011-02-13 18:06:10 +01:00
|
|
|
// write data
|
2014-01-16 12:40:11 +02:00
|
|
|
rStm.WriteUChar( nMask );
|
|
|
|
if( nMask & 0x01 ) rStm.WriteUChar( aAutomation );
|
2014-01-17 08:48:50 +02:00
|
|
|
if( nMask & 0x02 ) write_uInt16_lenPrefixed_uInt8s_FromOString(rStm, aPrefix);
|
2014-01-14 13:52:54 +02:00
|
|
|
if( nMask & 0x04 ) WriteSvPersistBase( rStm, xClass );
|
2000-09-18 15:33:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SV_IMPL_META_FACTORY1( SvMetaClass, SvMetaType );
|
|
|
|
SvMetaClass::SvMetaClass()
|
2014-05-08 11:42:16 +02:00
|
|
|
: aAutomation( true, false )
|
2000-09-18 15:33:13 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void SvMetaClass::Load( SvPersistStream & rStm )
|
|
|
|
{
|
|
|
|
SvMetaType::Load( rStm );
|
|
|
|
|
2010-11-03 15:49:08 +01:00
|
|
|
sal_uInt8 nMask;
|
2014-02-05 10:41:04 +02:00
|
|
|
rStm.ReadUChar( nMask );
|
2000-09-18 15:33:13 +00:00
|
|
|
if( nMask >= 0x20 )
|
|
|
|
{
|
|
|
|
rStm.SetError( SVSTREAM_FILEFORMAT_ERROR );
|
2011-03-01 19:07:44 +01:00
|
|
|
OSL_FAIL( "wrong format" );
|
2000-09-18 15:33:13 +00:00
|
|
|
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 );
|
|
|
|
|
2011-02-13 18:06:10 +01:00
|
|
|
// create mask
|
2010-11-03 15:49:08 +01:00
|
|
|
sal_uInt8 nMask = 0;
|
2012-08-07 16:56:51 +02:00
|
|
|
if( !aAttrList.empty() ) nMask |= 0x1;
|
2000-09-18 15:33:13 +00:00
|
|
|
if( aSuperClass.Is() ) nMask |= 0x2;
|
2012-08-07 16:56:51 +02:00
|
|
|
if( !aClassList.empty() ) nMask |= 0x4;
|
2000-09-18 15:33:13 +00:00
|
|
|
if( xAutomationInterface.Is() ) nMask |= 0x8;
|
|
|
|
if( aAutomation.IsSet() ) nMask |= 0x10;
|
|
|
|
|
2011-02-13 18:06:10 +01:00
|
|
|
// write data
|
2014-01-16 12:40:11 +02:00
|
|
|
rStm.WriteUChar( nMask );
|
2014-01-14 13:52:54 +02:00
|
|
|
if( nMask & 0x01 ) WriteSvDeclPersistList( rStm, aAttrList );
|
|
|
|
if( nMask & 0x02 ) WriteSvPersistBase( rStm, aSuperClass );
|
|
|
|
if( nMask & 0x04 ) WriteSvDeclPersistList( rStm, aClassList );
|
|
|
|
if( nMask & 0x08 ) WriteSvPersistBase( rStm, xAutomationInterface );
|
2014-01-16 12:40:11 +02:00
|
|
|
if( nMask & 0x10 ) rStm.WriteUChar( aAutomation );
|
2000-09-18 15:33:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SvMetaClass::ReadAttributesSvIdl( SvIdlDataBase & rBase,
|
|
|
|
SvTokenStream & rInStm )
|
|
|
|
{
|
|
|
|
SvMetaType::ReadAttributesSvIdl( rBase, rInStm );
|
|
|
|
aAutomation.ReadSvIdl( SvHash_Automation(), rInStm );
|
|
|
|
}
|
|
|
|
|
|
|
|
void SvMetaClass::WriteAttributesSvIdl( SvIdlDataBase & rBase,
|
2010-11-03 15:49:08 +01:00
|
|
|
SvStream & rOutStm, sal_uInt16 nTab )
|
2000-09-18 15:33:13 +00:00
|
|
|
{
|
|
|
|
SvMetaType::WriteAttributesSvIdl( rBase, rOutStm, nTab );
|
|
|
|
|
|
|
|
if( !aAutomation )
|
|
|
|
{
|
|
|
|
WriteTab( rOutStm, nTab );
|
2014-01-16 12:40:11 +02:00
|
|
|
rOutStm.WriteCharPtr( "//class SvMetaClass" ) << endl;
|
2000-09-18 15:33:13 +00:00
|
|
|
if( !aAutomation )
|
|
|
|
{
|
|
|
|
WriteTab( rOutStm, nTab );
|
|
|
|
aAutomation.WriteSvIdl( SvHash_Automation(), rOutStm );
|
2014-01-16 12:40:11 +02:00
|
|
|
rOutStm.WriteChar( ';' ) << endl;
|
2000-09-18 15:33:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SvMetaClass::ReadContextSvIdl( SvIdlDataBase & rBase,
|
|
|
|
SvTokenStream & rInStm )
|
|
|
|
{
|
2010-11-03 15:49:08 +01:00
|
|
|
sal_uInt32 nTokPos = rInStm.Tell();
|
2000-09-18 15:33:13 +00:00
|
|
|
SvToken * pTok = rInStm.GetToken_Next();
|
|
|
|
|
|
|
|
if( pTok->Is( SvHash_import() ) )
|
|
|
|
{
|
|
|
|
SvMetaClass * pClass = rBase.ReadKnownClass( rInStm );
|
|
|
|
if( pClass )
|
|
|
|
{
|
|
|
|
SvClassElementRef xEle = new SvClassElement();
|
|
|
|
xEle->SetClass( pClass );
|
2012-08-07 16:56:51 +02:00
|
|
|
aClassList.push_back( xEle );
|
2000-09-18 15:33:13 +00:00
|
|
|
|
|
|
|
if( rInStm.Read( '[' ) )
|
|
|
|
{
|
|
|
|
pTok = rInStm.GetToken_Next();
|
|
|
|
if( pTok->Is( SvHash_Automation() ) )
|
|
|
|
{
|
|
|
|
if( rInStm.Read( ']' ) )
|
|
|
|
{
|
|
|
|
if( xAutomationInterface.Is() )
|
|
|
|
{
|
2011-02-13 18:06:10 +01:00
|
|
|
// set error
|
2013-04-15 05:10:29 +02:00
|
|
|
rBase.SetError( "Automation already set",
|
2000-09-18 15:33:13 +00:00
|
|
|
rInStm.GetToken() );
|
|
|
|
rBase.WriteError( rInStm );
|
|
|
|
}
|
|
|
|
xAutomationInterface = pClass;
|
2014-05-08 11:42:16 +02:00
|
|
|
xEle->SetAutomation( true );
|
2000-09-18 15:33:13 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-02-13 18:06:10 +01:00
|
|
|
// set error
|
2000-09-18 15:33:13 +00:00
|
|
|
rBase.SetError( "missing ]", rInStm.GetToken() );
|
|
|
|
rBase.WriteError( rInStm );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-02-13 18:06:10 +01:00
|
|
|
// set error
|
2000-09-18 15:33:13 +00:00
|
|
|
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
|
|
|
|
{
|
2011-02-13 18:06:10 +01:00
|
|
|
// set error
|
2000-09-18 15:33:13 +00:00
|
|
|
rBase.SetError( "unknown imported interface", rInStm.GetToken() );
|
|
|
|
rBase.WriteError( rInStm );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rInStm.Seek( nTokPos );
|
|
|
|
SvMetaType * pType = rBase.ReadKnownType( rInStm );
|
|
|
|
|
2014-05-08 11:42:16 +02:00
|
|
|
bool bOk = false;
|
2000-09-18 15:33:13 +00:00
|
|
|
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 );
|
|
|
|
}
|
2012-08-07 16:56:51 +02:00
|
|
|
aAttrList.push_back( xAttr );
|
2000-09-18 15:33:13 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
rInStm.Seek( nTokPos );
|
|
|
|
}
|
|
|
|
|
|
|
|
void SvMetaClass::WriteContextSvIdl
|
|
|
|
(
|
|
|
|
SvIdlDataBase & rBase,
|
|
|
|
SvStream & rOutStm,
|
2010-11-03 15:49:08 +01:00
|
|
|
sal_uInt16 nTab
|
2000-09-18 15:33:13 +00:00
|
|
|
)
|
|
|
|
{
|
2011-01-13 09:32:03 +01:00
|
|
|
sal_uLong n;
|
2012-08-07 16:56:51 +02:00
|
|
|
for( n = 0; n < aAttrList.size(); n++ )
|
2000-09-18 15:33:13 +00:00
|
|
|
{
|
|
|
|
WriteTab( rOutStm, nTab );
|
2012-08-07 16:56:51 +02:00
|
|
|
aAttrList[n]->WriteSvIdl( rBase, rOutStm, nTab );
|
2014-01-16 12:40:11 +02:00
|
|
|
rOutStm.WriteChar( ';' ) << endl;
|
2000-09-18 15:33:13 +00:00
|
|
|
}
|
2012-08-07 16:56:51 +02:00
|
|
|
for( n = 0; n < aClassList.size(); n++ )
|
2000-09-18 15:33:13 +00:00
|
|
|
{
|
2012-08-07 16:56:51 +02:00
|
|
|
SvClassElement * pEle = aClassList[n];
|
2000-09-18 15:33:13 +00:00
|
|
|
WriteTab( rOutStm, nTab );
|
2014-01-16 12:40:11 +02:00
|
|
|
rOutStm.WriteCharPtr( SvHash_import()->GetName().getStr() ).WriteChar( ' ' )
|
|
|
|
.WriteCharPtr( pEle->GetPrefix().getStr() );
|
2000-09-18 15:33:13 +00:00
|
|
|
if( pEle->GetAutomation() )
|
2014-01-16 12:40:11 +02:00
|
|
|
rOutStm.WriteCharPtr( " [ " ).WriteCharPtr( SvHash_Automation()->GetName().getStr() )
|
|
|
|
.WriteCharPtr( " ]" );
|
2012-01-26 09:46:41 +00:00
|
|
|
if( !pEle->GetPrefix().isEmpty() )
|
2014-01-16 12:40:11 +02:00
|
|
|
rOutStm.WriteChar( ' ' ).WriteCharPtr( pEle->GetPrefix().getStr() );
|
|
|
|
rOutStm.WriteChar( ';' ) << endl;
|
2000-09-18 15:33:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-08 11:42:16 +02:00
|
|
|
bool SvMetaClass::ReadSvIdl( SvIdlDataBase & rBase, SvTokenStream & rInStm )
|
2000-09-18 15:33:13 +00:00
|
|
|
{
|
2011-01-13 09:32:03 +01:00
|
|
|
sal_uLong nTokPos = rInStm.Tell();
|
2000-09-18 15:33:13 +00:00
|
|
|
if( SvMetaType::ReadHeaderSvIdl( rBase, rInStm ) && GetType() == TYPE_CLASS )
|
|
|
|
{
|
2014-05-08 11:42:16 +02:00
|
|
|
bool bOk = true;
|
2000-09-18 15:33:13 +00:00
|
|
|
if( rInStm.Read( ':' ) )
|
|
|
|
{
|
|
|
|
aSuperClass = rBase.ReadKnownClass( rInStm );
|
|
|
|
bOk = aSuperClass.Is();
|
|
|
|
if( !bOk )
|
|
|
|
{
|
2011-02-13 18:06:10 +01:00
|
|
|
// set error
|
2000-09-18 15:33:13 +00:00
|
|
|
rBase.SetError( "unknown super class",
|
|
|
|
rInStm.GetToken() );
|
|
|
|
rBase.WriteError( rInStm );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if( bOk )
|
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
rBase.Write(OString('.'));
|
2000-09-18 15:33:13 +00:00
|
|
|
bOk = SvMetaName::ReadSvIdl( rBase, rInStm );
|
|
|
|
}
|
|
|
|
if( bOk )
|
|
|
|
return bOk;
|
|
|
|
}
|
|
|
|
rInStm.Seek( nTokPos );
|
2014-05-08 11:42:16 +02:00
|
|
|
return false;
|
2000-09-18 15:33:13 +00:00
|
|
|
}
|
|
|
|
|
2014-05-08 11:42:16 +02:00
|
|
|
bool SvMetaClass::TestAttribute( SvIdlDataBase & rBase, SvTokenStream & rInStm,
|
2000-09-18 15:33:13 +00:00
|
|
|
SvMetaAttribute & rAttr ) const
|
|
|
|
{
|
|
|
|
if ( !rAttr.GetRef() && rAttr.IsA( TYPE( SvMetaSlot ) ) )
|
|
|
|
{
|
2011-03-01 19:07:44 +01:00
|
|
|
OSL_FAIL( "Neuer Slot : " );
|
2012-01-26 09:46:41 +00:00
|
|
|
OSL_FAIL( rAttr.GetSlotId().getString().getStr() );
|
2000-09-18 15:33:13 +00:00
|
|
|
}
|
|
|
|
|
2012-08-07 16:56:51 +02:00
|
|
|
for( sal_uLong n = 0; n < aAttrList.size(); n++ )
|
2000-09-18 15:33:13 +00:00
|
|
|
{
|
2012-08-07 16:56:51 +02:00
|
|
|
SvMetaAttribute * pS = aAttrList[n];
|
2011-12-29 10:37:09 +00:00
|
|
|
if( pS->GetName().getString() == rAttr.GetName().getString() )
|
2000-09-18 15:33:13 +00:00
|
|
|
{
|
2011-02-13 18:06:10 +01:00
|
|
|
// values have to match
|
2000-09-18 15:33:13 +00:00
|
|
|
if( pS->GetSlotId().GetValue() != rAttr.GetSlotId().GetValue() )
|
|
|
|
{
|
2014-05-08 12:14:50 +01:00
|
|
|
OSL_FAIL( "Same Name in MetaClass : " );
|
2012-01-26 09:46:41 +00:00
|
|
|
OSL_FAIL( pS->GetName().getString().getStr() );
|
|
|
|
OSL_FAIL( pS->GetSlotId().getString().getStr() );
|
|
|
|
OSL_FAIL( rAttr.GetSlotId().getString().getStr() );
|
2000-09-18 15:33:13 +00:00
|
|
|
|
2013-11-20 10:05:20 +02:00
|
|
|
OStringBuffer aStr("Attribute's ");
|
2011-12-29 10:37:09 +00:00
|
|
|
aStr.append(pS->GetName().getString());
|
2013-11-20 10:05:20 +02:00
|
|
|
aStr.append(" with different id's");
|
2011-12-13 23:13:22 +00:00
|
|
|
rBase.SetError(aStr.makeStringAndClear(), rInStm.GetToken());
|
2000-09-18 15:33:13 +00:00
|
|
|
rBase.WriteError( rInStm );
|
2014-05-08 11:42:16 +02:00
|
|
|
return false;
|
2000-09-18 15:33:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-11-03 15:49:08 +01:00
|
|
|
sal_uInt32 nId1 = pS->GetSlotId().GetValue();
|
|
|
|
sal_uInt32 nId2 = rAttr.GetSlotId().GetValue();
|
2011-02-13 18:06:10 +01:00
|
|
|
if( nId1 == nId2 && nId1 != 0 )
|
2000-09-18 15:33:13 +00:00
|
|
|
{
|
2011-03-01 19:07:44 +01:00
|
|
|
OSL_FAIL( "Gleiche Id in MetaClass : " );
|
2013-08-21 15:07:31 +02:00
|
|
|
OSL_FAIL(OString::number(pS->GetSlotId().GetValue()).getStr());
|
2012-01-26 09:46:41 +00:00
|
|
|
OSL_FAIL( pS->GetSlotId().getString().getStr() );
|
|
|
|
OSL_FAIL( rAttr.GetSlotId().getString().getStr() );
|
2000-09-18 15:33:13 +00:00
|
|
|
|
2013-11-20 10:05:20 +02:00
|
|
|
OStringBuffer aStr("Attribute ");
|
2011-12-29 10:37:09 +00:00
|
|
|
aStr.append(pS->GetName().getString());
|
2013-11-20 10:05:20 +02:00
|
|
|
aStr.append(" and Attribute ");
|
2011-12-29 10:37:09 +00:00
|
|
|
aStr.append(rAttr.GetName().getString());
|
2013-11-20 10:05:20 +02:00
|
|
|
aStr.append(" with equal id's");
|
2011-12-13 23:13:22 +00:00
|
|
|
rBase.SetError(aStr.makeStringAndClear(), rInStm.GetToken());
|
2000-09-18 15:33:13 +00:00
|
|
|
rBase.WriteError( rInStm );
|
2014-05-08 11:42:16 +02:00
|
|
|
return false;
|
2000-09-18 15:33:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SvMetaClass * pSC = aSuperClass;
|
|
|
|
if( pSC )
|
|
|
|
return pSC->TestAttribute( rBase, rInStm, rAttr );
|
2014-05-08 11:42:16 +02:00
|
|
|
return true;
|
2000-09-18 15:33:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SvMetaClass::WriteSvIdl( SvIdlDataBase & rBase, SvStream & rOutStm,
|
2010-11-03 15:49:08 +01:00
|
|
|
sal_uInt16 nTab )
|
2000-09-18 15:33:13 +00:00
|
|
|
{
|
|
|
|
WriteHeaderSvIdl( rBase, rOutStm, nTab );
|
|
|
|
if( aSuperClass.Is() )
|
2014-01-16 12:40:11 +02:00
|
|
|
rOutStm.WriteCharPtr( " : " ).WriteCharPtr( aSuperClass->GetName().getString().getStr() );
|
2000-09-18 15:33:13 +00:00
|
|
|
rOutStm << endl;
|
|
|
|
SvMetaName::WriteSvIdl( rBase, rOutStm, nTab );
|
|
|
|
rOutStm << endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SvMetaClass::Write( SvIdlDataBase & rBase, SvStream & rOutStm,
|
2010-11-03 15:49:08 +01:00
|
|
|
sal_uInt16 nTab,
|
2006-06-19 09:42:24 +00:00
|
|
|
WriteType nT, WriteAttribute )
|
2000-09-18 15:33:13 +00:00
|
|
|
{
|
2011-12-29 10:37:09 +00:00
|
|
|
rBase.aIFaceName = GetName().getString();
|
2000-09-18 15:33:13 +00:00
|
|
|
switch( nT )
|
|
|
|
{
|
|
|
|
case WRITE_ODL:
|
|
|
|
{
|
2011-03-01 19:07:44 +01:00
|
|
|
OSL_FAIL( "Not supported anymore!" );
|
2000-09-18 15:33:13 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case WRITE_C_SOURCE:
|
|
|
|
case WRITE_C_HEADER:
|
|
|
|
{
|
2011-03-01 19:07:44 +01:00
|
|
|
OSL_FAIL( "Not supported anymore!" );
|
2000-09-18 15:33:13 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case WRITE_DOCU:
|
|
|
|
{
|
2014-01-16 12:40:11 +02:00
|
|
|
rOutStm.WriteCharPtr( "<INTERFACE>" ) << endl;
|
|
|
|
rOutStm.WriteCharPtr( GetName().getString().getStr() );
|
2000-09-18 15:33:13 +00:00
|
|
|
if ( GetAutomation() )
|
2014-01-16 12:40:11 +02:00
|
|
|
rOutStm.WriteCharPtr( " ( Automation ) " );
|
2000-09-18 15:33:13 +00:00
|
|
|
rOutStm << endl;
|
2006-06-19 09:42:24 +00:00
|
|
|
WriteDescription( rOutStm );
|
2014-01-16 12:40:11 +02:00
|
|
|
rOutStm.WriteCharPtr( "</INTERFACE>" ) << endl << endl;
|
2000-09-18 15:33:13 +00:00
|
|
|
|
2011-02-13 18:06:10 +01:00
|
|
|
// write all attributes
|
2011-01-13 09:32:03 +01:00
|
|
|
sal_uLong n;
|
2012-08-07 16:56:51 +02:00
|
|
|
for( n = 0; n < aAttrList.size(); n++ )
|
2000-09-18 15:33:13 +00:00
|
|
|
{
|
2012-08-07 16:56:51 +02:00
|
|
|
SvMetaAttribute * pAttr = aAttrList[n];
|
2000-09-18 15:33:13 +00:00
|
|
|
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;
|
|
|
|
}
|
2006-06-19 09:42:24 +00:00
|
|
|
default:
|
|
|
|
break;
|
2000-09-18 15:33:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-11-03 15:49:08 +01:00
|
|
|
sal_uInt16 SvMetaClass::WriteSlotParamArray( SvIdlDataBase & rBase,
|
2000-09-18 15:33:13 +00:00
|
|
|
SvSlotElementList & rSlotList,
|
|
|
|
SvStream & rOutStm )
|
|
|
|
{
|
2010-11-03 15:49:08 +01:00
|
|
|
sal_uInt16 nCount = 0;
|
2011-04-20 20:59:37 -07:00
|
|
|
for ( size_t i = 0, n = rSlotList.size(); i < n; ++i )
|
2000-09-18 15:33:13 +00:00
|
|
|
{
|
2011-04-20 20:59:37 -07:00
|
|
|
SvSlotElement *pEle = rSlotList[ i ];
|
2011-03-29 18:12:25 +02:00
|
|
|
SvMetaSlot *pAttr = pEle->xSlot;
|
2006-06-19 09:42:24 +00:00
|
|
|
nCount = nCount + pAttr->WriteSlotParamArray( rBase, rOutStm );
|
2000-09-18 15:33:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return nCount;
|
|
|
|
}
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
sal_uInt16 SvMetaClass::WriteSlots( const OString& rShellName,
|
2010-11-03 15:49:08 +01:00
|
|
|
sal_uInt16 nCount, SvSlotElementList & rSlotList,
|
2000-09-18 15:33:13 +00:00
|
|
|
SvIdlDataBase & rBase,
|
|
|
|
SvStream & rOutStm )
|
|
|
|
{
|
2010-11-03 15:49:08 +01:00
|
|
|
sal_uInt16 nSCount = 0;
|
2011-04-20 20:59:37 -07:00
|
|
|
for ( size_t i = 0, n = rSlotList.size(); i < n; ++i )
|
2000-09-18 15:33:13 +00:00
|
|
|
{
|
2011-04-20 20:59:37 -07:00
|
|
|
SvSlotElement * pEle = rSlotList[ i ];
|
2011-03-29 18:12:25 +02:00
|
|
|
SvMetaSlot * pAttr = pEle->xSlot;
|
2006-06-19 09:42:24 +00:00
|
|
|
nSCount = nSCount + pAttr->WriteSlotMap( rShellName, nCount + nSCount,
|
2011-04-20 20:59:37 -07:00
|
|
|
rSlotList, i, pEle->aPrefix, rBase,
|
2000-09-18 15:33:13 +00:00
|
|
|
rOutStm );
|
|
|
|
}
|
|
|
|
|
|
|
|
return nSCount;
|
|
|
|
}
|
|
|
|
|
2011-03-12 02:42:58 +01:00
|
|
|
void SvMetaClass::InsertSlots( SvSlotElementList& rList, std::vector<sal_uLong>& rSuperList,
|
2000-09-18 15:33:13 +00:00
|
|
|
SvMetaClassList &rClassList,
|
2013-04-07 12:06:47 +02:00
|
|
|
const OString& rPrefix, SvIdlDataBase& rBase)
|
2000-09-18 15:33:13 +00:00
|
|
|
{
|
2011-02-13 18:06:10 +01:00
|
|
|
// was this class already written?
|
2010-12-30 07:02:52 -08:00
|
|
|
for ( size_t i = 0, n = rClassList.size(); i < n ; ++i )
|
|
|
|
if ( rClassList[ i ] == this )
|
|
|
|
return;
|
2000-09-18 15:33:13 +00:00
|
|
|
|
2010-12-30 07:02:52 -08:00
|
|
|
rClassList.push_back( this );
|
2000-09-18 15:33:13 +00:00
|
|
|
|
2011-02-13 18:06:10 +01:00
|
|
|
// write all direct attributes
|
2011-01-13 09:32:03 +01:00
|
|
|
sal_uLong n;
|
2012-08-07 16:56:51 +02:00
|
|
|
for( n = 0; n < aAttrList.size(); n++ )
|
2000-09-18 15:33:13 +00:00
|
|
|
{
|
2012-08-07 16:56:51 +02:00
|
|
|
SvMetaAttribute * pAttr = aAttrList[n];
|
2000-09-18 15:33:13 +00:00
|
|
|
|
2011-01-13 09:32:03 +01:00
|
|
|
sal_uLong nId = pAttr->GetSlotId().GetValue();
|
2000-09-18 15:33:13 +00:00
|
|
|
|
2011-03-12 02:42:58 +01:00
|
|
|
std::vector<sal_uLong>::iterator iter = std::find(rSuperList.begin(),
|
2011-02-27 21:35:16 -08:00
|
|
|
rSuperList.end(),nId);
|
|
|
|
|
|
|
|
if( iter == rSuperList.end() )
|
2000-09-18 15:33:13 +00:00
|
|
|
{
|
2011-02-13 18:06:10 +01:00
|
|
|
// Write only if not already written by subclass or
|
|
|
|
// imported interface.
|
2011-02-27 21:35:16 -08:00
|
|
|
rSuperList.push_back(nId);
|
2000-09-18 15:33:13 +00:00
|
|
|
pAttr->Insert(rList, rPrefix, rBase);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-13 18:06:10 +01:00
|
|
|
// All Interfaces already imported by SuperShells should not be
|
|
|
|
// written any more.
|
|
|
|
// It is prohibited that Shell and SuperShell directly import the same
|
|
|
|
//class.
|
2000-09-18 15:33:13 +00:00
|
|
|
if( IsShell() && aSuperClass.Is() )
|
|
|
|
aSuperClass->FillClasses( rClassList );
|
|
|
|
|
2011-02-13 18:06:10 +01:00
|
|
|
// Write all attributes of the imported classes, as long as they have
|
|
|
|
// not already been imported by the superclass.
|
2012-08-07 16:56:51 +02:00
|
|
|
for( n = 0; n < aClassList.size(); n++ )
|
2000-09-18 15:33:13 +00:00
|
|
|
{
|
2012-08-07 16:56:51 +02:00
|
|
|
SvClassElement * pEle = aClassList[n];
|
2000-09-18 15:33:13 +00:00
|
|
|
SvMetaClass * pCl = pEle->GetClass();
|
2013-04-07 12:06:47 +02:00
|
|
|
OStringBuffer rPre(rPrefix);
|
2013-06-17 20:32:03 +02:00
|
|
|
if( !rPre.isEmpty() && !pEle->GetPrefix().isEmpty() )
|
2011-09-20 23:30:51 +01:00
|
|
|
rPre.append('.');
|
|
|
|
rPre.append(pEle->GetPrefix());
|
2000-09-18 15:33:13 +00:00
|
|
|
|
2011-02-13 18:06:10 +01:00
|
|
|
// first of all write direct imported interfaces
|
2011-09-20 23:30:51 +01:00
|
|
|
pCl->InsertSlots( rList, rSuperList, rClassList,
|
|
|
|
rPre.makeStringAndClear(), rBase );
|
2000-09-18 15:33:13 +00:00
|
|
|
}
|
|
|
|
|
2011-02-13 18:06:10 +01:00
|
|
|
// only write superclass if no shell and not in the list
|
2000-09-18 15:33:13 +00:00
|
|
|
if( !IsShell() && aSuperClass.Is() )
|
|
|
|
{
|
|
|
|
aSuperClass->InsertSlots( rList, rSuperList, rClassList, rPrefix, rBase );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SvMetaClass::FillClasses( SvMetaClassList & rList )
|
|
|
|
{
|
2011-02-13 18:06:10 +01:00
|
|
|
// Am I not yet in?
|
2010-12-30 07:02:52 -08:00
|
|
|
for ( size_t i = 0, n = rList.size(); i < n; ++i )
|
|
|
|
if ( rList[ i ] == this )
|
|
|
|
return;
|
2000-09-18 15:33:13 +00:00
|
|
|
|
2010-12-30 07:02:52 -08:00
|
|
|
rList.push_back( this );
|
2000-09-18 15:33:13 +00:00
|
|
|
|
2011-02-13 18:06:10 +01:00
|
|
|
// my imports
|
2012-08-07 16:56:51 +02:00
|
|
|
for( sal_uInt32 n = 0; n < aClassList.size(); n++ )
|
2010-12-30 07:02:52 -08:00
|
|
|
{
|
2012-08-07 16:56:51 +02:00
|
|
|
SvClassElement * pEle = aClassList[n];
|
2010-12-30 07:02:52 -08:00
|
|
|
SvMetaClass * pCl = pEle->GetClass();
|
|
|
|
pCl->FillClasses( rList );
|
2000-09-18 15:33:13 +00:00
|
|
|
}
|
2010-12-30 07:02:52 -08:00
|
|
|
|
2011-02-13 18:06:10 +01:00
|
|
|
// my superclass
|
2010-12-30 07:02:52 -08:00
|
|
|
if( aSuperClass.Is() )
|
|
|
|
aSuperClass->FillClasses( rList );
|
2000-09-18 15:33:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
void SvMetaClass::WriteSlotStubs( const OString& rShellName,
|
2000-09-18 15:33:13 +00:00
|
|
|
SvSlotElementList & rSlotList,
|
|
|
|
ByteStringList & rList,
|
|
|
|
SvStream & rOutStm )
|
|
|
|
{
|
2011-03-29 18:12:25 +02:00
|
|
|
// write all attributes
|
2011-04-20 20:59:37 -07:00
|
|
|
for ( size_t i = 0, n = rSlotList.size(); i < n; ++i )
|
2011-03-29 18:12:25 +02:00
|
|
|
{
|
2011-04-20 20:59:37 -07:00
|
|
|
SvSlotElement *pEle = rSlotList[ i ];
|
2011-03-29 18:12:25 +02:00
|
|
|
SvMetaSlot *pAttr = pEle->xSlot;
|
|
|
|
pAttr->WriteSlotStubs( rShellName, rList, rOutStm );
|
|
|
|
}
|
2000-09-18 15:33:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SvMetaClass::WriteSfx( SvIdlDataBase & rBase, SvStream & rOutStm )
|
|
|
|
{
|
|
|
|
WriteStars( rOutStm );
|
2011-02-13 18:06:10 +01:00
|
|
|
// define class
|
2014-01-16 12:40:11 +02:00
|
|
|
rOutStm.WriteCharPtr( "#ifdef " ).WriteCharPtr( GetName().getString().getStr() ) << endl;
|
|
|
|
rOutStm.WriteCharPtr( "#undef ShellClass" ) << endl;
|
|
|
|
rOutStm.WriteCharPtr( "#undef " ).WriteCharPtr( GetName().getString().getStr() ) << endl;
|
|
|
|
rOutStm.WriteCharPtr( "#define ShellClass " ).WriteCharPtr( GetName().getString().getStr() ) << endl;
|
2000-09-18 15:33:13 +00:00
|
|
|
|
2011-02-13 18:06:10 +01:00
|
|
|
// no slotmaps get written for interfaces
|
2000-09-18 15:33:13 +00:00
|
|
|
if( !IsShell() )
|
|
|
|
{
|
2014-01-16 12:40:11 +02:00
|
|
|
rOutStm.WriteCharPtr( "#endif" ) << endl << endl;
|
2000-09-18 15:33:13 +00:00
|
|
|
return;
|
|
|
|
}
|
2011-02-13 18:06:10 +01:00
|
|
|
// write parameter array
|
2014-04-18 07:57:15 +02:00
|
|
|
rOutStm.WriteCharPtr("static SfxFormalArgument a").WriteCharPtr(GetName().getString().getStr()).WriteCharPtr("Args_Impl[] =") << endl;
|
|
|
|
rOutStm.WriteChar('{') << endl;
|
2000-09-18 15:33:13 +00:00
|
|
|
|
2011-03-12 02:42:58 +01:00
|
|
|
std::vector<sal_uLong> aSuperList;
|
2006-06-19 09:42:24 +00:00
|
|
|
SvMetaClassList classList;
|
2000-09-18 15:33:13 +00:00
|
|
|
SvSlotElementList aSlotList;
|
2013-04-07 12:06:47 +02:00
|
|
|
InsertSlots(aSlotList, aSuperList, classList, OString(), rBase);
|
2011-04-20 20:59:37 -07:00
|
|
|
for ( size_t i = 0, n = aSlotList.size(); i < n; ++i )
|
2011-03-29 18:12:25 +02:00
|
|
|
{
|
2011-04-20 20:59:37 -07:00
|
|
|
SvSlotElement *pEle = aSlotList[ i ];
|
2011-03-29 18:12:25 +02:00
|
|
|
SvMetaSlot *pSlot = pEle->xSlot;
|
2011-04-20 20:59:37 -07:00
|
|
|
pSlot->SetListPos( i );
|
2011-03-29 18:12:25 +02:00
|
|
|
}
|
2000-09-18 15:33:13 +00:00
|
|
|
|
2011-04-20 20:59:37 -07:00
|
|
|
size_t nSlotCount = aSlotList.size();
|
2000-09-18 15:33:13 +00:00
|
|
|
|
2011-02-13 18:06:10 +01:00
|
|
|
// write all attributes
|
2010-11-03 15:49:08 +01:00
|
|
|
sal_uInt16 nArgCount = WriteSlotParamArray( rBase, aSlotList, rOutStm );
|
2000-09-18 15:33:13 +00:00
|
|
|
if( nArgCount )
|
|
|
|
Back2Delemitter( rOutStm );
|
|
|
|
else
|
|
|
|
{
|
2011-02-13 18:06:10 +01:00
|
|
|
// at leaast one dummy
|
2000-09-18 15:33:13 +00:00
|
|
|
WriteTab( rOutStm, 1 );
|
2014-04-18 11:00:19 +02:00
|
|
|
rOutStm.WriteCharPtr("{ (const SfxType*) &aSfxVoidItem_Impl, 0, 0 }" ) << endl;
|
2000-09-18 15:33:13 +00:00
|
|
|
}
|
2014-01-16 12:40:11 +02:00
|
|
|
rOutStm << endl;
|
|
|
|
rOutStm.WriteCharPtr( "};" ) << endl << endl;
|
2000-09-18 15:33:13 +00:00
|
|
|
|
|
|
|
ByteStringList aStringList;
|
2011-12-29 10:37:09 +00:00
|
|
|
WriteSlotStubs( GetName().getString(), aSlotList, aStringList, rOutStm );
|
2010-12-28 18:25:01 -08:00
|
|
|
for ( size_t i = 0, n = aStringList.size(); i < n; ++i )
|
|
|
|
delete aStringList[ i ];
|
|
|
|
aStringList.clear();
|
2000-09-18 15:33:13 +00:00
|
|
|
|
|
|
|
rOutStm << endl;
|
|
|
|
|
2011-02-13 18:06:10 +01:00
|
|
|
// write slotmap
|
2014-04-18 11:38:19 +02:00
|
|
|
rOutStm.WriteCharPtr("static SfxSlot a").WriteCharPtr(GetName().getString().getStr()).WriteCharPtr("Slots_Impl[] =") << endl;
|
2014-01-16 12:40:11 +02:00
|
|
|
rOutStm.WriteChar( '{' ) << endl;
|
2000-09-18 15:33:13 +00:00
|
|
|
|
2011-02-13 18:06:10 +01:00
|
|
|
// write all attributes
|
2011-12-29 10:37:09 +00:00
|
|
|
WriteSlots( GetName().getString(), 0, aSlotList, rBase, rOutStm );
|
2000-09-18 15:33:13 +00:00
|
|
|
if( nSlotCount )
|
|
|
|
Back2Delemitter( rOutStm );
|
|
|
|
else
|
|
|
|
{
|
2011-02-13 18:06:10 +01:00
|
|
|
// at least one dummy
|
2000-09-18 15:33:13 +00:00
|
|
|
WriteTab( rOutStm, 1 );
|
2014-01-16 12:40:11 +02:00
|
|
|
rOutStm.WriteCharPtr( "SFX_SLOT_ARG(" ).WriteCharPtr( GetName().getString().getStr() )
|
|
|
|
.WriteCharPtr( ", 0, 0, " )
|
|
|
|
.WriteCharPtr( "SFX_STUB_PTR_EXEC_NONE," )
|
|
|
|
.WriteCharPtr( "SFX_STUB_PTR_STATE_NONE," )
|
|
|
|
.WriteCharPtr( "0, SfxVoidItem, 0, 0, \"\", 0 )" ) << endl;
|
2000-09-18 15:33:13 +00:00
|
|
|
}
|
2014-01-16 12:40:11 +02:00
|
|
|
rOutStm << endl;
|
|
|
|
rOutStm.WriteCharPtr( "};" ) << endl;
|
|
|
|
rOutStm.WriteCharPtr( "#endif" ) << endl << endl;
|
2000-09-18 15:33:13 +00:00
|
|
|
|
2011-04-20 20:59:37 -07:00
|
|
|
for( size_t i = 0, n = aSlotList.size(); i < n; ++i )
|
2000-09-18 15:33:13 +00:00
|
|
|
{
|
2011-04-20 20:59:37 -07:00
|
|
|
SvSlotElement* pEle = aSlotList[ i ];
|
2011-03-29 18:12:25 +02:00
|
|
|
SvMetaSlot* pAttr = pEle->xSlot;
|
|
|
|
pAttr->ResetSlotPointer();
|
2000-09-18 15:33:13 +00:00
|
|
|
}
|
2011-03-29 18:12:25 +02:00
|
|
|
|
2011-04-20 20:59:37 -07:00
|
|
|
for( size_t i = 0, n = aSlotList.size(); i < n; ++i )
|
|
|
|
delete aSlotList[ i ];
|
|
|
|
aSlotList.clear();
|
2000-09-18 15:33:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SvMetaClass::WriteHelpIds( SvIdlDataBase & rBase, SvStream & rOutStm,
|
2012-03-11 12:03:11 +02:00
|
|
|
HelpIdTable& rTable )
|
2000-09-18 15:33:13 +00:00
|
|
|
{
|
2012-08-07 16:56:51 +02:00
|
|
|
for( sal_uLong n=0; n<aAttrList.size(); n++ )
|
2000-09-18 15:33:13 +00:00
|
|
|
{
|
2012-08-07 16:56:51 +02:00
|
|
|
SvMetaAttribute * pAttr = aAttrList[n];
|
2012-03-11 12:03:11 +02:00
|
|
|
pAttr->WriteHelpId( rBase, rOutStm, rTable );
|
2000-09-18 15:33:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-12 15:53:47 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|