diff options
Diffstat (limited to 'idl')
34 files changed, 11159 insertions, 0 deletions
diff --git a/idl/Executable_svidl.mk b/idl/Executable_svidl.mk new file mode 100644 index 000000000000..f38edd1d181a --- /dev/null +++ b/idl/Executable_svidl.mk @@ -0,0 +1,68 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +#************************************************************************* +# +# 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. +# +#************************************************************************* + +$(eval $(call gb_Executable_Executable,svidl)) + +$(eval $(call gb_Executable_set_include,svidl,\ + $$(INCLUDE) \ + -I$(OUTDIR)/inc/ \ + -I$(realpath $(SRCDIR)/idl/inc/pch) \ + -I$(realpath $(SRCDIR)/idl/inc) \ +)) + +$(eval $(call gb_Executable_add_api,svidl,\ + offapi \ + udkapi \ +)) + +$(eval $(call gb_Executable_add_defs,svidl,\ + -DIDL_COMPILER \ +)) + +$(eval $(call gb_Executable_add_linked_libs,svidl,\ + tl \ + sal \ + $(gb_STDLIBS) \ +)) + +$(eval $(call gb_Executable_add_exception_objects,svidl,\ + idl/source/cmptools/hash \ + idl/source/cmptools/lex \ + idl/source/objects/basobj \ + idl/source/objects/bastype \ + idl/source/objects/module \ + idl/source/objects/object \ + idl/source/objects/slot \ + idl/source/objects/types \ + idl/source/prj/command \ + idl/source/prj/database \ + idl/source/prj/globals \ + idl/source/prj/svidl \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/idl/Makefile b/idl/Makefile new file mode 100644 index 000000000000..8d71119918b6 --- /dev/null +++ b/idl/Makefile @@ -0,0 +1,39 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +#************************************************************************* +# +# 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. +# +#************************************************************************* + +ifeq ($(strip $(SOLARENV)),) +$(error No environment set!) +endif + +gb_PARTIALBUILD := T +GBUILDDIR := $(SOLARENV)/gbuild +include $(GBUILDDIR)/gbuild.mk + +$(eval $(call gb_Module_make_global_targets,$(shell ls $(dir $(realpath $(firstword $(MAKEFILE_LIST))))/Module*.mk))) + +# vim: set noet sw=4 ts=4: diff --git a/idl/Module_idl.mk b/idl/Module_idl.mk new file mode 100644 index 000000000000..e96ac00ba9a4 --- /dev/null +++ b/idl/Module_idl.mk @@ -0,0 +1,36 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +#************************************************************************* +# +# 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. +# +#************************************************************************* + + +$(eval $(call gb_Module_Module,idl)) + +$(eval $(call gb_Module_add_targets,idl,\ + Executable_svidl \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/idl/inc/basobj.hxx b/idl/inc/basobj.hxx new file mode 100644 index 000000000000..ff1d7b48b569 --- /dev/null +++ b/idl/inc/basobj.hxx @@ -0,0 +1,267 @@ +/* -*- 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. + * + ************************************************************************/ + +#ifndef _BASOBJ_HXX +#define _BASOBJ_HXX + +#include <tools/ref.hxx> +#include <bastype.hxx> +#include <tools/pstm.hxx> + +class SvTokenStream; +class SvMetaObject; +class SvAttributeList; +class SvIdlDataBase; + +typedef SvMetaObject * (*CreateMetaObjectType)(); +#define IDL_WRITE_COMPILER 0x8000 +#define IDL_WRITE_BROWSER 0x4000 +#define IDL_WRITE_CALLING 0x2000 +#define IDL_WRITE_MASK 0xE000 + +#define C_PREF "C_" + +enum WriteType +{ + WRITE_IDL, WRITE_ODL, WRITE_SLOTMAP, WRITE_C_HEADER, WRITE_C_SOURCE, + WRITE_CXX_HEADER, WRITE_CXX_SOURCE, WRITE_DOCU +}; + +enum +{ + WA_METHOD = 0x1, WA_VARIABLE = 0x2, WA_ARGUMENT = 0x4, + WA_STRUCT = 0x8, WA_READONLY = 0x10 +}; +typedef int WriteAttribute; + +#define SV_DECL_META_FACTORY( Class, CLASS_ID ) \ + SV_DECL_PERSIST( Class, CLASS_ID ) + + +#define SV_DECL_META_FACTORY1( Class, Super1, CLASS_ID ) \ + SV_DECL_PERSIST1( Class, Super1, CLASS_ID ) + +#define SV_IMPL_META_FACTORY( Class ) \ + SV_IMPL_PERSIST( Class ) + + +#define SV_IMPL_META_FACTORY1( Class, Super1 ) \ + SV_IMPL_PERSIST1( Class, Super1 ) + +class SvMetaObject : public SvPersistBase +{ +public: + SV_DECL_META_FACTORY1( SvMetaObject, SvPersistBase, 14 ) + SvMetaObject(); + +#ifdef IDL_COMPILER + static void WriteTab( SvStream & rOutStm, sal_uInt16 nTab ); + static sal_Bool TestAndSeekSpaceOnly( SvStream &, sal_uLong nBegPos ); + static void Back2Delemitter( SvStream & ); + static void WriteStars( SvStream & ); + + virtual sal_Bool ReadSvIdl( SvIdlDataBase &, SvTokenStream & rInStm ); + virtual void WriteSvIdl( SvIdlDataBase & rBase, SvStream & rOutStm, sal_uInt16 nTab ); + + virtual void Write( SvIdlDataBase & rBase, SvStream & rOutStm, sal_uInt16 nTab, + WriteType, WriteAttribute = 0 ); + + virtual void WriteCxx( SvIdlDataBase & rBase, SvStream & rOutStm, sal_uInt16 nTab ); + virtual void WriteHxx( SvIdlDataBase & rBase, SvStream & rOutStm, sal_uInt16 nTab ); +#endif +}; +SV_DECL_IMPL_REF(SvMetaObject) +SV_DECL_PERSIST_LIST(SvMetaObject,SvMetaObject *) +SV_IMPL_PERSIST_LIST(SvMetaObject,SvMetaObject *) + + +class SvMetaObjectMemberStack +{ + SvMetaObjectMemberList aList; +public: + SvMetaObjectMemberStack() {;} + + void Push( SvMetaObject * pObj ) + { aList.Insert( pObj, LIST_APPEND ); } + SvMetaObject * Pop() { return aList.Remove( aList.Count() -1 ); } + SvMetaObject * Top() const { return aList.GetObject( aList.Count() -1 ); } + void Clear() { aList.Clear(); } + sal_uLong Count() const { return aList.Count(); } + + SvMetaObject * Get( TypeId nType ) + { + SvMetaObject * pObj = aList.Last(); + while( pObj ) + { + if( pObj->IsA( nType ) ) + return pObj; + pObj = aList.Prev(); + } + return NULL; + } +}; + +class SvMetaName : public SvMetaObject +{ + SvString aName; + SvHelpContext aHelpContext; + SvHelpText aHelpText; + SvString aConfigName; + SvString aDescription; + +protected: +#ifdef IDL_COMPILER + virtual sal_Bool ReadNameSvIdl( SvIdlDataBase &, SvTokenStream & rInStm ); + void DoReadContextSvIdl( SvIdlDataBase &, SvTokenStream & rInStm, + char c = '\0' ); + virtual void ReadContextSvIdl( SvIdlDataBase &, SvTokenStream & rInStm ); + virtual void WriteContextSvIdl( SvIdlDataBase & rBase, + SvStream & rOutStm, sal_uInt16 nTab ); + virtual void ReadAttributesSvIdl( SvIdlDataBase & rBase, + SvTokenStream & rInStm ); + virtual void WriteAttributesSvIdl( SvIdlDataBase & rBase, + SvStream & rOutStm, sal_uInt16 nTab ); + virtual void WriteAttributes( SvIdlDataBase & rBase, SvStream & rOutStm, sal_uInt16 nTab, + WriteType, WriteAttribute = 0); + virtual void WriteContext( SvIdlDataBase & rBase, SvStream & rOutStm, sal_uInt16 nTab, + WriteType, WriteAttribute = 0); +#endif +public: + SV_DECL_META_FACTORY1( SvMetaName, SvMetaObject, 15 ) + SvMetaName(); + + virtual sal_Bool SetName( const ByteString & rName, SvIdlDataBase * = NULL ); + void SetDescription( const ByteString& rText ) + { aDescription = rText; } + const SvHelpContext& GetHelpContext() const { return aHelpContext; } + virtual const SvString & GetName() const { return aName; } + virtual const SvString & GetHelpText() const { return aHelpText; } + virtual const SvString & GetConfigName() const{ return aConfigName; } + virtual const SvString& GetDescription() const{ return aDescription; } + +#ifdef IDL_COMPILER + virtual sal_Bool Test( SvIdlDataBase &, SvTokenStream & rInStm ); + virtual sal_Bool ReadSvIdl( SvIdlDataBase &, SvTokenStream & rInStm ); + virtual void WriteSvIdl( SvIdlDataBase & rBase, SvStream & rOutStm, sal_uInt16 nTab ); + virtual void Write( SvIdlDataBase & rBase, SvStream & rOutStm, sal_uInt16 nTab, + WriteType, WriteAttribute = 0); + void WriteDescription( SvStream& rOutStm ); +#endif +}; +SV_DECL_IMPL_REF(SvMetaName) +SV_DECL_IMPL_PERSIST_LIST(SvMetaName,SvMetaName *) + + +SV_DECL_REF(SvMetaReference) +class SvMetaReference : public SvMetaName +{ +protected: + SvMetaReferenceRef aRef; +public: + SV_DECL_META_FACTORY1( SvMetaReference, SvMetaName, 17 ) + SvMetaReference(); + + const SvString & GetName() const + { + return ( !aRef.Is() + || SvMetaName::GetName().Len() ) + ? SvMetaName::GetName() + : aRef->GetName(); + } + + const SvString & GetHelpText() const + { + return ( !aRef.Is() + || SvMetaName::GetHelpText().Len() ) + ? SvMetaName::GetHelpText() + : aRef->GetHelpText(); + } + + const SvString & GetConfigName() const + { + return ( !aRef.Is() + || SvMetaName::GetConfigName().Len() ) + ? SvMetaName::GetConfigName() + : aRef->GetConfigName(); + } + + const SvString & GetDescription() const + { + return ( !aRef.Is() + || SvMetaName::GetDescription().Len() ) + ? SvMetaName::GetDescription() + : aRef->GetDescription(); + } + SvMetaReference * GetRef() const { return aRef; } + void SetRef( SvMetaReference * pRef ) + { aRef = pRef; } +}; +SV_IMPL_REF(SvMetaReference) +SV_DECL_IMPL_PERSIST_LIST(SvMetaReference,SvMetaReference *) + + +class SvMetaModule; +class SvMetaExtern : public SvMetaReference +{ + SvMetaModule * pModule; // included in which module + + SvUUId aUUId; + SvVersion aVersion; + sal_Bool bReadUUId; + sal_Bool bReadVersion; +public: + SV_DECL_META_FACTORY1( SvMetaExtern, SvMetaName, 16 ) + SvMetaExtern(); + + SvMetaModule * GetModule() const; + + const SvGlobalName &GetUUId() const; + const SvVersion & GetVersion() const { return aVersion; } +#ifdef IDL_COMPILER + void SetModule( SvIdlDataBase & rBase ); + virtual sal_Bool ReadSvIdl( SvIdlDataBase &, SvTokenStream & rInStm ); + virtual void WriteSvIdl( SvIdlDataBase & rBase, SvStream & rOutStm, sal_uInt16 nTab ); + + virtual void Write( SvIdlDataBase & rBase, SvStream & rOutStm, sal_uInt16 nTab, + WriteType, WriteAttribute = 0); +protected: + virtual void ReadAttributesSvIdl( SvIdlDataBase &, SvTokenStream & rInStm ); + virtual void WriteAttributesSvIdl( SvIdlDataBase & rBase, + SvStream & rOutStm, sal_uInt16 nTab ); + virtual void WriteAttributes( SvIdlDataBase & rBase, SvStream & rOutStm, sal_uInt16 nTab, + WriteType, WriteAttribute = 0); +#endif +}; +SV_DECL_IMPL_REF(SvMetaExtern) +SV_DECL_IMPL_PERSIST_LIST(SvMetaExtern,SvMetaExtern *) + + +#endif // _BASOBJ_HXX + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/idl/inc/bastype.hxx b/idl/inc/bastype.hxx new file mode 100644 index 000000000000..a95114954eab --- /dev/null +++ b/idl/inc/bastype.hxx @@ -0,0 +1,279 @@ +/* -*- 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. + * + ************************************************************************/ + +#ifndef _BASTYPE_HXX +#define _BASTYPE_HXX + + +#include <tools/globname.hxx> +#include <tools/gen.hxx> +#include <tools/stream.hxx> +#include <tools/unqid.hxx> +#include <tools/string.hxx> + +class SvStringHashEntry; +class SvIdlDataBase; +class SvTokenStream; + +class SvUINT32 +{ + sal_uInt32 nVal; +public: + SvUINT32() { nVal = 0; } + SvUINT32( sal_uInt32 n ) : nVal( n ) {} + SvUINT32 & operator = ( sal_uInt32 n ) { nVal = n; return *this; } + + operator sal_uInt32 &() { return nVal; } + + static sal_uInt32 Read( SvStream & rStm ); + static void Write( SvStream & rStm, sal_uInt32 nVal ); + + friend SvStream& operator << (SvStream & rStm, const SvUINT32 & r ) + { SvUINT32::Write( rStm, r.nVal ); return rStm; } + friend SvStream& operator >> (SvStream & rStm, SvUINT32 & r ) + { r.nVal = SvUINT32::Read( rStm ); return rStm; } +}; + + +class SvINT16 +{ + short nVal; +public: + SvINT16() { nVal = 0; } + SvINT16( short n ) : nVal( n ) {} + SvINT16 & operator = ( short n ) { nVal = n; return *this; } + + operator short &() { return nVal; } + + friend SvStream& operator << (SvStream & rStm, const SvINT16 & r ) + { SvUINT32::Write( rStm, (sal_uInt32)r.nVal ); return rStm; } + friend SvStream& operator >> (SvStream & rStm, SvINT16 & r ) + { r.nVal = (short)SvUINT32::Read( rStm ); return rStm; } +}; + + +class SvUINT16 +{ + sal_uInt16 nVal; +public: + SvUINT16() { nVal = 0; } + SvUINT16( sal_uInt16 n ) : nVal( n ) {} + SvUINT16 & operator = ( sal_uInt16 n ) { nVal = n; return *this; } + + operator sal_uInt16 &() { return nVal; } + + friend SvStream& operator << (SvStream & rStm, const SvUINT16 & r ) + { SvUINT32::Write( rStm, (sal_uInt32)r.nVal ); return rStm; } + friend SvStream& operator >> (SvStream & rStm, SvUINT16 & r ) + { r.nVal = (sal_uInt16)SvUINT32::Read( rStm ); return rStm; } +}; + + +class SvINT32 +{ + sal_Int32 nVal; +public: + SvINT32() { nVal = 0; } + SvINT32( sal_Int32 n ) : nVal( n ) {} + SvINT32 & operator = ( sal_Int32 n ) { nVal = n; return *this; } + + operator sal_Int32 &() { return nVal; } + + friend SvStream& operator << (SvStream & rStm, const SvINT32 & r ) + { SvUINT32::Write( rStm, (sal_uInt32)r.nVal ); return rStm; } + friend SvStream& operator >> (SvStream & rStm, SvINT32 & r ) + { r.nVal = (sal_Int32)SvUINT32::Read( rStm ); return rStm; } +}; + + +class Svint +{ + int nVal; + sal_Bool bSet; +public: + Svint() { nVal = bSet = 0; } + Svint( int n ) : nVal( n ), bSet( sal_True ) {} + Svint( int n, sal_Bool bSetP ) : nVal( n ), bSet( bSetP ) {} + Svint & operator = ( int n ) { nVal = n; bSet = sal_True; return *this; } + + operator int ()const { return nVal; } + sal_Bool IsSet() const { return bSet; } + + friend SvStream& operator << (SvStream & rStm, const Svint & r ) + { SvUINT32::Write( rStm, (sal_uInt32)r.nVal ); rStm << r.bSet; return rStm; } + friend SvStream& operator >> (SvStream & rStm, Svint & r ) + { r.nVal = (int)SvUINT32::Read( rStm ); rStm >> r.bSet ; return rStm; } +}; + + +class SvBOOL +{ + sal_Bool nVal:1, + bSet:1; +public: + SvBOOL() { bSet = nVal = sal_False; } + SvBOOL( sal_Bool n ) : nVal( n ), bSet( sal_True ) {} + SvBOOL( sal_Bool n, sal_Bool bSetP ) : nVal( n ), bSet( bSetP ) {} + SvBOOL & operator = ( sal_Bool n ) { nVal = n; bSet = sal_True; return *this; } + + operator sal_Bool() const { return nVal; } +#ifdef STC + operator int() const { return nVal; } +#endif + sal_Bool Is() const { return nVal; } + sal_Bool IsSet() const { return bSet; } + + friend SvStream& operator << (SvStream &, const SvBOOL &); + friend SvStream& operator >> (SvStream &, SvBOOL &); + +#ifdef IDL_COMPILER + sal_Bool ReadSvIdl( SvStringHashEntry * pName, SvTokenStream & rInStm ); + sal_Bool WriteSvIdl( SvStringHashEntry * pName, SvStream & rOutStm ); + ByteString GetSvIdlString( SvStringHashEntry * pName ); +#endif +}; + + +class SvIdentifier : public ByteString +{ +public: + SvIdentifier(){}; + SvIdentifier & operator = ( const ByteString & rStr ) + { ByteString::operator =( rStr ); return *this; } + friend SvStream& operator << (SvStream &, const SvIdentifier &); + friend SvStream& operator >> (SvStream &, SvIdentifier &); + + sal_Bool IsSet() const { return Len() != 0; } +#ifdef IDL_COMPILER + sal_Bool ReadSvIdl( SvStringHashEntry * pName, SvTokenStream & rInStm ); + sal_Bool WriteSvIdl( SvStringHashEntry * pName, SvStream & rOutStm, + sal_uInt16 nTab ); +#endif +}; + + +class SvNumberIdentifier : public SvIdentifier +{ + sal_uInt32 nValue; + // must not be used + sal_Bool ReadSvIdl( SvStringHashEntry * pName, SvTokenStream & rInStm ); +public: + SvNumberIdentifier() : nValue( 0 ) {}; + sal_Bool IsSet() const + { + return SvIdentifier::IsSet() || nValue != 0; + } + sal_uInt32 GetValue() const { return nValue; } + void SetValue( sal_uInt32 nVal ) { nValue = nVal; } + + friend SvStream& operator << (SvStream &, const SvNumberIdentifier &); + friend SvStream& operator >> (SvStream &, SvNumberIdentifier &); +#ifdef IDL_COMPILER + sal_Bool ReadSvIdl( SvIdlDataBase &, SvTokenStream & rInStm ); + sal_Bool ReadSvIdl( SvIdlDataBase &, SvStringHashEntry * pName, + SvTokenStream & rInStm ); +#endif +}; + + +class SvString : public ByteString +{ +public: + SvString(){}; + SvString & operator = ( const ByteString & rStr ) + { ByteString::operator =( rStr ); return *this; } + sal_Bool IsSet() const { return Len() != 0; } + friend SvStream& operator << (SvStream &, const SvString &); + friend SvStream& operator >> (SvStream &, SvString &); + +#ifdef IDL_COMPILER + sal_Bool ReadSvIdl( SvStringHashEntry * pName, SvTokenStream & rInStm ); + sal_Bool WriteSvIdl( SvStringHashEntry * pName, SvStream & rOutStm, + sal_uInt16 nTab ); +#endif +}; + + +class SvHelpText : public SvString +{ +public: + SvHelpText() {} +#ifdef IDL_COMPILER + sal_Bool ReadSvIdl( SvIdlDataBase &, SvTokenStream & rInStm ); + sal_Bool WriteSvIdl( SvIdlDataBase & rBase, SvStream & rOutStm, + sal_uInt16 nTab ); +#endif +}; + + +class SvHelpContext : public SvNumberIdentifier +{ +}; + +class SvUUId : public SvGlobalName +{ +public: + SvUUId() {} +#ifdef IDL_COMPILER + sal_Bool ReadSvIdl( SvIdlDataBase &, SvTokenStream & rInStm ); + sal_Bool WriteSvIdl( SvStream & rOutStm ); +#endif +}; + + +class SvVersion +{ + sal_uInt16 nMajorVersion; + sal_uInt16 nMinorVersion; +public: + SvVersion() : nMajorVersion( 1 ), nMinorVersion( 0 ) {} + sal_Bool operator == ( const SvVersion & r ) + { + return (r.nMajorVersion == nMajorVersion) + && (r.nMinorVersion == nMinorVersion); + } + sal_Bool operator != ( const SvVersion & r ) + { + return !(*this == r); + } + + sal_uInt16 GetMajorVersion() const { return nMajorVersion; } + sal_uInt16 GetMinorVersion() const { return nMinorVersion; } + + friend SvStream& operator << (SvStream &, const SvVersion &); + friend SvStream& operator >> (SvStream &, SvVersion &); +#ifdef IDL_COMPILER + sal_Bool ReadSvIdl( SvTokenStream & rInStm ); + sal_Bool WriteSvIdl( SvStream & rOutStm ); +#endif +}; + + +#endif // _BASTYPE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/idl/inc/command.hxx b/idl/inc/command.hxx new file mode 100644 index 000000000000..f8ea98a5e63f --- /dev/null +++ b/idl/inc/command.hxx @@ -0,0 +1,78 @@ +/* -*- 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. + * + ************************************************************************/ + +#ifndef _COMMAND_HXX +#define _COMMAND_HXX + +#include <tools/string.hxx> +#include <vector> + +#ifndef STRING_LIST +#define STRING_LIST +typedef ::std::vector< String* > StringList; +#endif + +typedef ::std::vector< ByteString* > ByteStringList; + +class SvCommand +{ +public: + String aDataBaseFile; + StringList aInFileList; + String aListFile; + String aSlotMapFile; + String aSfxItemFile; + String aODLFile; + String aCallingFile; + String aCxxFile; + String aHxxFile; + String aSrcFile; + String aPath; + String aCHeaderFile; + String aCSourceFile; + String aTargetFile; + ByteString aSrsLine; + String aHelpIdFile; + String aCSVFile; + String aExportFile; + String aDocuFile; + sal_uInt32 nVerbosity; + sal_uInt32 nFlags; + + SvCommand( int argc, char ** argv ); + ~SvCommand(); +}; + +void Init(); +class SvIdlWorkingBase; +sal_Bool ReadIdl( SvIdlWorkingBase * pDataBase, const SvCommand & rCommand ); +void DeInit(); + +#endif // _COMMAND_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/idl/inc/database.hxx b/idl/inc/database.hxx new file mode 100644 index 000000000000..c8ad5cf2bff7 --- /dev/null +++ b/idl/inc/database.hxx @@ -0,0 +1,178 @@ +/* -*- 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. + * + ************************************************************************/ + +#ifndef _DATABASE_HXX +#define _DATABASE_HXX + +#include <module.hxx> +#include <hash.hxx> +#include <lex.hxx> +#include <tools/pstm.hxx> + +class SvCommand; + +#ifdef IDL_COMPILER + +class SvIdlError +{ + ByteString aText; +public: + sal_uInt32 nLine, nColumn; + + SvIdlError() : nLine(0), nColumn(0) {} + SvIdlError( sal_uInt32 nL, sal_uInt32 nC ) + : nLine(nL), nColumn(nC) {} + + const ByteString & GetText() const { return aText; } + void SetText( const ByteString & rT ) { aText = rT; } + sal_Bool IsError() const { return nLine != 0; } + void Clear() { nLine = nColumn = 0; } + SvIdlError & operator = ( const SvIdlError & rRef ) + { aText = rRef.aText; + nLine = rRef.nLine; + nColumn = rRef.nColumn; + return *this; + } +}; +#endif + +class SvIdlDataBase +{ + sal_Bool bExport; + String aExportFile; + sal_uInt32 nUniqueId; + sal_uInt32 nVerbosity; + String aDataBaseFile; + SvFileStream * pStm; + sal_Bool bIsModified; + SvPersistStream aPersStream; + StringList aIdFileList; + SvStringHashTable * pIdTable; + + SvMetaTypeMemberList aTypeList; + SvMetaClassMemberList aClassList; + SvMetaModuleMemberList aModuleList; + SvMetaAttributeMemberList aAttrList; + SvMetaTypeMemberList aTmpTypeList; // not persistent + +protected: +#ifdef IDL_COMPILER + SvMetaObjectMemberStack aContextStack; + String aPath; + SvIdlError aError; + void WriteReset() + { + aUsedTypes.Clear(); + aIFaceName.Erase(); + } +#endif +public: + explicit SvIdlDataBase( const SvCommand& rCmd ); + ~SvIdlDataBase(); + static sal_Bool IsBinaryFormat( SvStream & rInStm ); + + void Load( SvStream & rInStm ); + void Save( SvStream & rInStm, sal_uInt32 nContextFlags ); + + SvMetaAttributeMemberList& GetAttrList() { return aAttrList; } + SvStringHashTable * GetIdTable() { return pIdTable; } + SvMetaTypeMemberList & GetTypeList(); + SvMetaClassMemberList & GetClassList() { return aClassList; } + SvMetaModuleMemberList & GetModuleList() { return aModuleList; } + SvMetaModule * GetModule( const ByteString & rName ); + + // list of used types while writing + SvMetaTypeMemberList aUsedTypes; + ByteString aIFaceName; + SvNumberIdentifier aStructSlotId; + +#ifdef IDL_COMPILER + void StartNewFile( const String& rName ); + void SetExportFile( const String& rName ) + { aExportFile = rName; } + void AppendAttr( SvMetaAttribute *pSlot ); + const SvIdlError & GetError() const { return aError; } + void SetError( const SvIdlError & r ) + { aError = r; } + + const String & GetPath() const { return aPath; } + SvMetaObjectMemberStack & GetStack() { return aContextStack; } + + void Write( const ByteString & rText ); + void WriteError( const ByteString & rErrWrn, + const ByteString & rFileName, + const rtl::OString& rErrorText, + sal_uLong nRow = 0, sal_uLong nColumn = 0 ) const; + void WriteError( SvTokenStream & rInStm ); + void SetError( const ByteString & rError, SvToken * pTok ); + void Push( SvMetaObject * pObj ); + sal_Bool Pop( sal_Bool bOk, SvTokenStream & rInStm, sal_uInt32 nTokPos ) + { + GetStack().Pop(); + if( bOk ) + aError.Clear(); + else + rInStm.Seek( nTokPos ); + return bOk; + } + sal_uInt32 GetUniqueId() { return ++nUniqueId; } + sal_Bool FindId( const ByteString & rIdName, sal_uLong * pVal ); + sal_Bool InsertId( const ByteString & rIdName, sal_uLong nVal ); + sal_Bool ReadIdFile( const String & rFileName ); + + SvMetaType * FindType( const ByteString & rName ); + static SvMetaType * FindType( const SvMetaType *, SvMetaTypeMemberList & ); + + SvMetaType * ReadKnownType( SvTokenStream & rInStm ); + SvMetaAttribute * ReadKnownAttr( SvTokenStream & rInStm, + SvMetaType * pType = NULL ); + SvMetaAttribute * SearchKnownAttr( const SvNumberIdentifier& ); + SvMetaClass * ReadKnownClass( SvTokenStream & rInStm ); +#endif +}; + +#ifdef IDL_COMPILER +class SvIdlWorkingBase : public SvIdlDataBase +{ +public: + explicit SvIdlWorkingBase( const SvCommand& rCmd ); + + sal_Bool ReadSvIdl( SvTokenStream &, sal_Bool bImported, const String & rPath ); + sal_Bool WriteSvIdl( SvStream & ); + + sal_Bool WriteSfx( SvStream & ); + sal_Bool WriteHelpIds( SvStream & ); + sal_Bool WriteSfxItem( SvStream & ); + sal_Bool WriteCSV( SvStream& ); + sal_Bool WriteDocumentation( SvStream& ); +}; +#endif + +#endif // _DATABASE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/idl/inc/globals.hxx b/idl/inc/globals.hxx new file mode 100644 index 000000000000..525c2a9e27e2 --- /dev/null +++ b/idl/inc/globals.hxx @@ -0,0 +1,244 @@ +/* -*- 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. + * + ************************************************************************/ + +#ifndef _GLOBALS_HXX +#define _GLOBALS_HXX + +#ifdef IDL_COMPILER +#include <hash.hxx> + +#ifdef ICC +#undef _Export +#endif + +class SvIdlWorkingBase; +class SvClassManager; +struct SvGlobalHashNames +{ + SvStringHashEntryRef MM_Name; + SvStringHashEntryRef MM_module; + SvStringHashEntryRef MM_interface; + SvStringHashEntryRef MM_in; + SvStringHashEntryRef MM_out; + SvStringHashEntryRef MM_inout; + SvStringHashEntryRef MM_String; + SvStringHashEntryRef MM_UCHAR; + SvStringHashEntryRef MM_USHORT; + SvStringHashEntryRef MM_uuid; + SvStringHashEntryRef MM_HelpContext; + SvStringHashEntryRef MM_HelpText; + SvStringHashEntryRef MM_void; + SvStringHashEntryRef MM_shell; + SvStringHashEntryRef MM_Get; + SvStringHashEntryRef MM_Set; + SvStringHashEntryRef MM_SlotId; + SvStringHashEntryRef MM_HasCoreId; + SvStringHashEntryRef MM_Cachable; + SvStringHashEntryRef MM_Volatile; + SvStringHashEntryRef MM_Toggle; + SvStringHashEntryRef MM_AutoUpdate; + SvStringHashEntryRef MM_Synchron; + SvStringHashEntryRef MM_Asynchron; + SvStringHashEntryRef MM_RecordPerSet; + SvStringHashEntryRef MM_RecordPerItem; + SvStringHashEntryRef MM_RecordManual; + SvStringHashEntryRef MM_NoRecord; + SvStringHashEntryRef MM_RecordAbsolute; + SvStringHashEntryRef MM_enum; + SvStringHashEntryRef MM_UINT16; + SvStringHashEntryRef MM_INT16; + SvStringHashEntryRef MM_UINT32; + SvStringHashEntryRef MM_INT32; + SvStringHashEntryRef MM_int; + SvStringHashEntryRef MM_BOOL; + SvStringHashEntryRef MM_char; + SvStringHashEntryRef MM_BYTE; + SvStringHashEntryRef MM_float; + SvStringHashEntryRef MM_double; + SvStringHashEntryRef MM_item; + SvStringHashEntryRef MM_PseudoSlots; + SvStringHashEntryRef MM_map; + SvStringHashEntryRef MM_Default; + SvStringHashEntryRef MM_HelpFile; + SvStringHashEntryRef MM_Version; + SvStringHashEntryRef MM_import; + SvStringHashEntryRef MM_SlotIdFile; + SvStringHashEntryRef MM_SvName; + SvStringHashEntryRef MM_SbxName; + SvStringHashEntryRef MM_ItemName; + SvStringHashEntryRef MM_OdlName; + SvStringHashEntryRef MM_include; + SvStringHashEntryRef MM_ExecMethod; + SvStringHashEntryRef MM_StateMethod; + SvStringHashEntryRef MM_GroupId; + SvStringHashEntryRef MM_HasDialog; + SvStringHashEntryRef MM_TypeLibFile; + SvStringHashEntryRef MM_Export; + SvStringHashEntryRef MM_Automation; + SvStringHashEntryRef MM_PseudoPrefix; + SvStringHashEntryRef MM_define; + SvStringHashEntryRef MM_MenuConfig; + SvStringHashEntryRef MM_ToolBoxConfig; + SvStringHashEntryRef MM_StatusBarConfig; + SvStringHashEntryRef MM_AccelConfig; + SvStringHashEntryRef MM_AllConfig; + SvStringHashEntryRef MM_FastCall; + SvStringHashEntryRef MM_SbxObject; + SvStringHashEntryRef MM_Container; + SvStringHashEntryRef MM_ImageRotation; + SvStringHashEntryRef MM_ImageReflection; + SvStringHashEntryRef MM_IsCollection; + SvStringHashEntryRef MM_ReadOnlyDoc; + SvStringHashEntryRef MM_ConfigName; + SvStringHashEntryRef MM_union; + SvStringHashEntryRef MM_struct; + SvStringHashEntryRef MM_typedef; + SvStringHashEntryRef MM_Readonly; + SvStringHashEntryRef MM_SlotType; + SvStringHashEntryRef MM_ModulePrefix; + SvStringHashEntryRef MM_DisableFlags; + SvStringHashEntryRef MM_Hidden; + SvStringHashEntryRef MM_Description; + SvStringHashEntryRef MM_UnoName; + + SvGlobalHashNames(); +}; + +class IdlDll +{ +public: + SvStringHashTable * pHashTable; + SvClassManager * pClassMgr; + SvGlobalHashNames * pGlobalNames; + + IdlDll(); + ~IdlDll(); +}; + +IdlDll * GetIdlApp(); +#define IDLAPP GetIdlApp() + +#define SV_GLOBAL_HASH_ACCESS( Name ) \ + if( !IDLAPP->pGlobalNames ) \ + IDLAPP->pGlobalNames = new SvGlobalHashNames(); \ + return IDLAPP->pGlobalNames->MM_##Name; + +#define HASH_INLINE( Name ) \ +inline SvStringHashEntry * SvHash_##Name() { SV_GLOBAL_HASH_ACCESS( Name ) } + +HASH_INLINE(Name) +HASH_INLINE(module) +HASH_INLINE(interface) +HASH_INLINE(in) +HASH_INLINE(out) +HASH_INLINE(inout) +HASH_INLINE(String) +HASH_INLINE(UCHAR) +HASH_INLINE(USHORT) +HASH_INLINE(uuid) +HASH_INLINE(HelpContext) +HASH_INLINE(HelpText) +HASH_INLINE(void) +HASH_INLINE(shell) +HASH_INLINE(Get) +HASH_INLINE(Set) +HASH_INLINE(SlotId) +HASH_INLINE(HasCoreId) +HASH_INLINE(Cachable) +HASH_INLINE(Volatile) +HASH_INLINE(Toggle) +HASH_INLINE(AutoUpdate) +HASH_INLINE(Synchron) +HASH_INLINE(Asynchron) +HASH_INLINE(RecordPerItem) +HASH_INLINE(RecordPerSet) +HASH_INLINE(RecordManual) +HASH_INLINE(NoRecord) +HASH_INLINE(RecordAbsolute) +HASH_INLINE(enum) +HASH_INLINE(UINT16) +HASH_INLINE(INT16) +HASH_INLINE(UINT32) +HASH_INLINE(INT32) +HASH_INLINE(int) +HASH_INLINE(BOOL) +HASH_INLINE(char) +HASH_INLINE(BYTE) +HASH_INLINE(item) +HASH_INLINE(PseudoSlots) +HASH_INLINE(map) +HASH_INLINE(Default) +HASH_INLINE(HelpFile) +HASH_INLINE(Version) +HASH_INLINE(import) +HASH_INLINE(SlotIdFile) +HASH_INLINE(SvName) +HASH_INLINE(SbxName) +HASH_INLINE(ItemName) +HASH_INLINE(OdlName) +HASH_INLINE(include) +HASH_INLINE(ExecMethod) +HASH_INLINE(StateMethod) +HASH_INLINE(GroupId) +HASH_INLINE(float) +HASH_INLINE(double) +HASH_INLINE(HasDialog) +HASH_INLINE(TypeLibFile) +HASH_INLINE(Export) +HASH_INLINE(Automation) +HASH_INLINE(PseudoPrefix) +HASH_INLINE(define) +HASH_INLINE(MenuConfig) +HASH_INLINE(ToolBoxConfig) +HASH_INLINE(StatusBarConfig) +HASH_INLINE(AccelConfig) +HASH_INLINE(AllConfig) +HASH_INLINE(FastCall) +HASH_INLINE(SbxObject) +HASH_INLINE(Container) +HASH_INLINE(ImageRotation) +HASH_INLINE(ImageReflection) +HASH_INLINE(IsCollection) +HASH_INLINE(ReadOnlyDoc) +HASH_INLINE(ConfigName) +HASH_INLINE(union) +HASH_INLINE(struct) +HASH_INLINE(typedef) +HASH_INLINE(Readonly) +HASH_INLINE(SlotType) +HASH_INLINE(ModulePrefix) +HASH_INLINE(DisableFlags) +HASH_INLINE(Hidden) +HASH_INLINE(Description) +HASH_INLINE(UnoName) + + +#endif // IDL_COMPILER +#endif // _GLOBALS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/idl/inc/hash.hxx b/idl/inc/hash.hxx new file mode 100644 index 000000000000..6449dfd7b9e6 --- /dev/null +++ b/idl/inc/hash.hxx @@ -0,0 +1,124 @@ +/* -*- 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. + * + ************************************************************************/ + +#ifndef _HASH_HXX +#define _HASH_HXX + +#include <tools/ref.hxx> +#include <tools/string.hxx> +#include <vector> + +class SvHashTable +{ + sal_uInt32 nMax; // size of hash-tabel + sal_uInt32 nFill; // elements in hash-tabel + sal_uInt32 lAsk; // number of requests + sal_uInt32 lTry; // number of tries +protected: + sal_Bool Test_Insert( const void *, sal_Bool bInsert, sal_uInt32 * pInsertPos ); + + // compare element with entry + virtual StringCompare Compare( const void * , sal_uInt32 ) const = 0; + // get hash value from subclass + virtual sal_uInt32 HashFunc( const void * ) const = 0; +public: + SvHashTable( sal_uInt32 nMaxEntries ); + virtual ~SvHashTable(); + + sal_uInt32 GetMax() const { return nMax; } + + virtual sal_Bool IsEntry( sal_uInt32 ) const = 0; +}; + +class SvStringHashTable; +class SvStringHashEntry : public SvRefBase +{ +friend class SvStringHashTable; + ByteString aName; + sal_uInt32 nHashId; + sal_uLong nValue; + sal_Bool bHasId; +public: + SvStringHashEntry() : bHasId( sal_False ) {;} + SvStringHashEntry( const ByteString & rName, sal_uInt32 nIdx ) + : aName( rName ) + , nHashId( nIdx ) + , nValue( 0 ) + , bHasId( sal_True ) {} + ~SvStringHashEntry(); + + const ByteString & GetName() const { return aName; } + sal_Bool HasId() const { return bHasId; } + sal_uInt32 GetId() const { return nHashId; } + + void SetValue( sal_uLong n ) { nValue = n; } + sal_uLong GetValue() const { return nValue; } + + sal_Bool operator == ( const SvStringHashEntry & rRef ) + { return nHashId == rRef.nHashId; } + sal_Bool operator != ( const SvStringHashEntry & rRef ) + { return ! operator == ( rRef ); } + SvStringHashEntry & operator = ( const SvStringHashEntry & rRef ) + { SvRefBase::operator=( rRef ); + aName = rRef.aName; + nHashId = rRef.nHashId; + nValue = rRef.nValue; + bHasId = rRef.bHasId; + return *this; + } +}; + +SV_DECL_IMPL_REF(SvStringHashEntry) + +typedef ::std::vector< SvStringHashEntry* > SvStringHashList; + +class SvStringHashTable : public SvHashTable +{ + SvStringHashEntry* pEntries; +protected: + virtual sal_uInt32 HashFunc( const void * pElement ) const; + virtual StringCompare Compare( const void * pElement, sal_uInt32 nIndex ) const; +public: + SvStringHashTable( sal_uInt32 nMaxEntries ); // max size of hash-tabel + virtual ~SvStringHashTable(); + + ByteString GetNearString( const ByteString & rName ) const; + virtual sal_Bool IsEntry( sal_uInt32 nIndex ) const; + + sal_Bool Insert( const ByteString & rStr, sal_uInt32 * pHash ); // insert string + sal_Bool Test( const ByteString & rStr, sal_uInt32 * pHash ) const; // test of insert string + SvStringHashEntry * Get ( sal_uInt32 nIndex ) const; // return pointer to string + SvStringHashEntry & operator []( sal_uInt32 nPos ) const + { return pEntries[ nPos ]; } + + void FillHashList( SvStringHashList * rList ) const; +}; + +#endif // _RSCHASH_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/idl/inc/lex.hxx b/idl/inc/lex.hxx new file mode 100644 index 000000000000..607f0ec67a8d --- /dev/null +++ b/idl/inc/lex.hxx @@ -0,0 +1,271 @@ +/* -*- 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. + * + ************************************************************************/ + +#ifndef _LEX_HXX +#define _LEX_HXX + +#include <boost/ptr_container/ptr_vector.hpp> + +#include <hash.hxx> +#include <tools/gen.hxx> +#include <tools/stream.hxx> + +enum SVTOKEN_ENUM { SVTOKEN_EMPTY, SVTOKEN_COMMENT, + SVTOKEN_INTEGER, SVTOKEN_STRING, + SVTOKEN_BOOL, SVTOKEN_IDENTIFIER, + SVTOKEN_CHAR, SVTOKEN_RTTIBASE, + SVTOKEN_EOF, SVTOKEN_HASHID }; + +class BigInt; +class SvToken +{ +friend class SvTokenStream; + sal_uLong nLine, nColumn; + SVTOKEN_ENUM nType; + ByteString aString; + union + { + sal_uLong nLong; + sal_Bool bBool; + char cChar; + SvStringHashEntry * pHash; + }; +public: + SvToken(); + SvToken( const SvToken & rObj ); + SvToken( sal_uLong n ); + SvToken( SVTOKEN_ENUM nTypeP, sal_Bool b ); + SvToken( char c ); + SvToken( SVTOKEN_ENUM nTypeP, const ByteString & rStr ); + SvToken( SVTOKEN_ENUM nTypeP ); + + SvToken & operator = ( const SvToken & rObj ); + + ByteString GetTokenAsString() const; + SVTOKEN_ENUM GetType() const { return nType; } + + void SetLine( sal_uLong nLineP ) { nLine = nLineP; } + sal_uLong GetLine() const { return nLine; } + + void SetColumn( sal_uLong nColumnP ) { nColumn = nColumnP; } + sal_uLong GetColumn() const { return nColumn; } + + sal_Bool IsEmpty() const { return nType == SVTOKEN_EMPTY; } + sal_Bool IsComment() const { return nType == SVTOKEN_COMMENT; } + sal_Bool IsInteger() const { return nType == SVTOKEN_INTEGER; } + sal_Bool IsString() const { return nType == SVTOKEN_STRING; } + sal_Bool IsBool() const { return nType == SVTOKEN_BOOL; } + sal_Bool IsIdentifierHash() const + { return nType == SVTOKEN_HASHID; } + sal_Bool IsIdentifier() const + { + return nType == SVTOKEN_IDENTIFIER + || nType == SVTOKEN_HASHID; + } + sal_Bool IsChar() const { return nType == SVTOKEN_CHAR; } + sal_Bool IsRttiBase() const { return nType == SVTOKEN_RTTIBASE; } + sal_Bool IsEof() const { return nType == SVTOKEN_EOF; } + + const ByteString & GetString() const + { + return IsIdentifierHash() + ? pHash->GetName() + : aString; + } + sal_uLong GetNumber() const { return nLong; } + sal_Bool GetBool() const { return bBool; } + char GetChar() const { return cChar; } + + void SetHash( SvStringHashEntry * pHashP ) + { pHash = pHashP; nType = SVTOKEN_HASHID; } + sal_Bool HasHash() const + { return nType == SVTOKEN_HASHID; } + SvStringHashEntry * GetHash() const { return pHash; } + sal_Bool Is( SvStringHashEntry * pEntry ) const + { return IsIdentifierHash() && pHash == pEntry; } +}; + +inline SvToken::SvToken() + : nType( SVTOKEN_EMPTY ) {} + +inline SvToken::SvToken( sal_uLong n ) + : nType( SVTOKEN_INTEGER ), nLong( n ) {} + +inline SvToken::SvToken( SVTOKEN_ENUM nTypeP, sal_Bool b ) + : nType( nTypeP ), bBool( b ) {} + +inline SvToken::SvToken( char c ) + : nType( SVTOKEN_CHAR ), cChar( c ) {} + +inline SvToken::SvToken( SVTOKEN_ENUM nTypeP, const ByteString & rStr ) + : nType( nTypeP ), aString( rStr ) {} + +inline SvToken::SvToken( SVTOKEN_ENUM nTypeP ) +: nType( nTypeP ) {} + +class SvTokenStream +{ + sal_uLong nLine, nColumn; + int nBufPos; + int c; // next character + sal_uInt16 nTabSize; // length of tabulator + ByteString aStrTrue; + ByteString aStrFalse; + sal_uLong nMaxPos; + + SvFileStream * pInStream; + SvStream & rInStream; + String aFileName; + boost::ptr_vector<SvToken> aTokList; + boost::ptr_vector<SvToken>::iterator pCurToken; + + void InitCtor(); + + ByteString aBufStr; + int GetNextChar(); + int GetFastNextChar() + { + return aBufStr.GetChar((sal_uInt16)nBufPos++); + } + + void FillTokenList(); + sal_uLong GetNumber(); + sal_Bool MakeToken( SvToken & ); + sal_Bool IsEof() const { return rInStream.IsEof(); } + void SetMax() + { + sal_uLong n = Tell(); + if( n > nMaxPos ) + nMaxPos = n; + } + void CalcColumn() + { + // if end of line spare calculation + if( 0 != c ) + { + sal_uInt16 n = 0; + nColumn = 0; + while( n < nBufPos ) + nColumn += aBufStr.GetChar(n++) == '\t' ? nTabSize : 1; + } + } +public: + SvTokenStream( const String & rFileName ); + SvTokenStream( SvStream & rInStream, const String & rFileName ); + ~SvTokenStream(); + + const String & GetFileName() const { return aFileName; } + SvStream & GetStream() { return rInStream; } + + void SetTabSize( sal_uInt16 nTabSizeP ) + { nTabSize = nTabSizeP; } + sal_uInt16 GetTabSize() const { return nTabSize; } + + SvToken* GetToken_PrevAll() + { + boost::ptr_vector<SvToken>::iterator pRetToken = pCurToken; + + // current iterator always valid + if(pCurToken != aTokList.begin()) + --pCurToken; + + return &(*pRetToken); + } + + SvToken* GetToken_NextAll() + { + boost::ptr_vector<SvToken>::iterator pRetToken = pCurToken++; + + if (pCurToken == aTokList.end()) + pCurToken = pRetToken; + + SetMax(); + + return &(*pRetToken); + } + + SvToken* GetToken_Next() + { + // comments get removed initially + return GetToken_NextAll(); + } + + SvToken* GetToken() const { return &(*pCurToken); } + + sal_Bool Read( char cChar ) + { + if( pCurToken->IsChar() + && cChar == pCurToken->GetChar() ) + { + GetToken_Next(); + return sal_True; + } + else + return sal_False; + } + + void ReadDelemiter() + { + if( pCurToken->IsChar() + && (';' == pCurToken->GetChar() + || ',' == pCurToken->GetChar()) ) + { + GetToken_Next(); + } + } + + sal_uInt32 Tell() const { return pCurToken-aTokList.begin(); } + + void Seek( sal_uInt32 nPos ) + { + pCurToken = aTokList.begin() + nPos; + SetMax(); + } + + void SeekRel( sal_uInt32 nRelPos ) + { + sal_uInt32 relIdx = Tell() + nRelPos; + + if ( relIdx < aTokList.size()) + { + pCurToken = aTokList.begin()+ (Tell() + nRelPos ); + SetMax(); + } + } + + void SeekEnd() + { + pCurToken = aTokList.begin()+nMaxPos; + } +}; + + + +#endif // _LEX_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/idl/inc/module.hxx b/idl/inc/module.hxx new file mode 100644 index 000000000000..964cf148b87a --- /dev/null +++ b/idl/inc/module.hxx @@ -0,0 +1,116 @@ +/* -*- 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. + * + ************************************************************************/ + +#ifndef _MODULE_HXX +#define _MODULE_HXX + +#include <slot.hxx> +#include <object.hxx> + +struct SvNamePos +{ + SvGlobalName aUUId; + sal_uInt32 nStmPos; + SvNamePos( const SvGlobalName & rName, sal_uInt32 nPos ) + : aUUId( rName ) + , nStmPos( nPos ) {} +}; + +class SvMetaModule : public SvMetaExtern +{ + SvMetaClassMemberList aClassList; + SvMetaTypeMemberList aTypeList; + SvMetaAttributeMemberList aAttrList; +// browser + String aIdlFileName; + SvString aHelpFileName; + SvString aSlotIdFile; + SvString aTypeLibFile; + SvString aModulePrefix; + +#ifdef IDL_COMPILER + sal_Bool bImported : 1, + bIsModified : 1; + SvGlobalName aBeginName; + SvGlobalName aEndName; + SvGlobalName aNextName; +protected: + virtual void ReadAttributesSvIdl( SvIdlDataBase &, SvTokenStream & rInStm ); + virtual void WriteAttributesSvIdl( SvIdlDataBase & rBase, SvStream & rOutStm, sal_uInt16 nTab ); + virtual void ReadContextSvIdl( SvIdlDataBase &, SvTokenStream & rInStm ); + virtual void WriteContextSvIdl( SvIdlDataBase & rBase, SvStream & rOutStm, sal_uInt16 nTab ); +#endif +public: + SV_DECL_META_FACTORY1( SvMetaModule, SvMetaExtern, 13 ) + SvMetaModule(); + + const String & GetIdlFileName() const { return aIdlFileName; } + const ByteString & GetModulePrefix() const { return aModulePrefix; } + + virtual sal_Bool SetName( const ByteString & rName, SvIdlDataBase * = NULL ); + + const ByteString & GetHelpFileName() const { return aHelpFileName; } + const ByteString & GetTypeLibFileName() const { return aTypeLibFile; } + + const SvMetaAttributeMemberList & GetAttrList() const { return aAttrList; } + const SvMetaTypeMemberList & GetTypeList() const { return aTypeList; } + const SvMetaClassMemberList & GetClassList() const { return aClassList; } + +#ifdef IDL_COMPILER + SvMetaModule( const String & rIdlFileName, + sal_Bool bImported ); + + sal_Bool FillNextName( SvGlobalName * ); + sal_Bool IsImported() const { return bImported; } + sal_Bool IsModified() const { return bIsModified; } + + virtual sal_Bool ReadSvIdl( SvIdlDataBase &, SvTokenStream & rInStm ); + virtual void WriteSvIdl( SvIdlDataBase & rBase, SvStream & rOutStm, sal_uInt16 nTab ); + + virtual void WriteAttributes( SvIdlDataBase & rBase, + SvStream & rOutStm, sal_uInt16 nTab, + WriteType, WriteAttribute = 0 ); + virtual void Write( SvIdlDataBase & rBase, SvStream & rOutStm, sal_uInt16 nTab, + WriteType, WriteAttribute = 0 ); + virtual void WriteSfx( SvIdlDataBase & rBase, SvStream & rOutStm ); + virtual void WriteHelpIds( SvIdlDataBase & rBase, SvStream & rOutStm, + Table* pTable ); + virtual void WriteSrc( SvIdlDataBase & rBase, SvStream & rOutStm, + Table *pIdTable ); + + virtual void WriteCxx( SvIdlDataBase & rBase, SvStream & rOutStm, sal_uInt16 nTab ); + virtual void WriteHxx( SvIdlDataBase & rBase, SvStream & rOutStm, sal_uInt16 nTab ); +#endif +}; +SV_DECL_IMPL_REF(SvMetaModule) +SV_DECL_IMPL_PERSIST_LIST(SvMetaModule,SvMetaModule *) + + +#endif // _MODULE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/idl/inc/object.hxx b/idl/inc/object.hxx new file mode 100644 index 000000000000..a39c7e917d60 --- /dev/null +++ b/idl/inc/object.hxx @@ -0,0 +1,159 @@ +/* -*- 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. + * + ************************************************************************/ + +#ifndef _OBJECT_HXX +#define _OBJECT_HXX + +#define _SVSTDARR_ULONGS +#include <types.hxx> +#include <slot.hxx> +#include <vector> + +struct SvSlotElement +{ + SvMetaSlotRef xSlot; + ByteString aPrefix; + SvSlotElement( SvMetaSlot * pS, const ByteString & rPrefix ) + : xSlot( pS ) + , aPrefix( rPrefix ) + {} +}; +typedef std::vector< SvSlotElement* > SvSlotElementList; + +class SvMetaClass; +typedef ::std::vector< SvMetaClass* > SvMetaClassList; + +SV_DECL_REF(SvMetaClass) +class SvClassElement : public SvPersistBase +{ + SvBOOL aAutomation; + ByteString aPrefix; + SvMetaClassRef xClass; +public: + SV_DECL_PERSIST1( SvClassElement, SvPersistBase, 1 ) + SvClassElement(); + + void SetPrefix( const ByteString & rPrefix ) + { aPrefix = rPrefix; } + const ByteString & GetPrefix() const + { return aPrefix; } + + void SetAutomation( sal_Bool rAutomation ) + { aAutomation = rAutomation; } + sal_Bool GetAutomation() const + { return aAutomation; } + + void SetClass( SvMetaClass * pClass ) + { xClass = pClass; } + SvMetaClass * GetClass() const + { return xClass; } +}; + +SV_DECL_IMPL_REF(SvClassElement) +SV_DECL_IMPL_PERSIST_LIST(SvClassElement,SvClassElement *) + +class SvMetaModule; +SV_DECL_PERSIST_LIST(SvMetaClass,SvMetaClass *) +class SvMetaClass : public SvMetaType +{ + SvMetaAttributeMemberList aAttrList; + SvClassElementMemberList aClassList; + SvMetaClassRef aSuperClass; + SvBOOL aAutomation; + SvMetaClassRef xAutomationInterface; + + sal_Bool TestAttribute( SvIdlDataBase & rBase, SvTokenStream & rInStm, + SvMetaAttribute & rAttr ) const; +#ifdef IDL_COMPILER + void WriteSlotStubs( const ByteString & rShellName, + SvSlotElementList & rSlotList, + ByteStringList & rList, + SvStream & rOutStm ); + sal_uInt16 WriteSlotParamArray( SvIdlDataBase & rBase, + SvSlotElementList & rSlotList, + SvStream & rOutStm ); + sal_uInt16 WriteSlots( const ByteString & rShellName, sal_uInt16 nCount, + SvSlotElementList & rSlotList, + SvIdlDataBase & rBase, + SvStream & rOutStm ); + + void InsertSlots( SvSlotElementList& rList, std::vector<sal_uLong>& rSuperList, + SvMetaClassList & rClassList, + const ByteString & rPrefix, SvIdlDataBase& rBase ); + +protected: + virtual void ReadAttributesSvIdl( SvIdlDataBase & rBase, + SvTokenStream & rInStm ); + virtual void WriteAttributesSvIdl( SvIdlDataBase & rBase, + SvStream & rOutStm, sal_uInt16 nTab ); + virtual void ReadContextSvIdl( SvIdlDataBase &, + SvTokenStream & rInStm ); + virtual void WriteContextSvIdl( SvIdlDataBase & rBase, + SvStream & rOutStm, sal_uInt16 nTab ); + void WriteOdlMembers( ByteStringList & rSuperList, + sal_Bool bVariable, sal_Bool bWriteTab, + SvIdlDataBase & rBase, + SvStream & rOutStm, sal_uInt16 nTab ); +#endif +public: + SV_DECL_META_FACTORY1( SvMetaClass, SvMetaType, 6 ) + SvMetaClass(); + + sal_Bool GetAutomation() const + { return aAutomation; } + SvMetaClass * GetSuperClass() const + { return aSuperClass; } + + void FillClasses( SvMetaClassList & rList ); + + const SvClassElementMemberList& + GetClassList() const + { return aClassList; } + +#ifdef IDL_COMPILER + virtual sal_Bool ReadSvIdl( SvIdlDataBase &, SvTokenStream & rInStm ); + virtual void WriteSvIdl( SvIdlDataBase & rBase, SvStream & rOutStm, sal_uInt16 nTab ); + virtual void Write( SvIdlDataBase & rBase, SvStream & rOutStm, + sal_uInt16 nTab, + WriteType, WriteAttribute = 0 ); + virtual void WriteSfx( SvIdlDataBase & rBase, SvStream & rOutStm ); + virtual void WriteHelpIds( SvIdlDataBase & rBase, SvStream & rOutStm, + Table* pTable ); + virtual void WriteSrc( SvIdlDataBase & rBase, SvStream & rOutStm, + Table * pTable ); + virtual void WriteCxx( SvIdlDataBase & rBase, SvStream & rOutStm, sal_uInt16 nTab ); + virtual void WriteHxx( SvIdlDataBase & rBase, SvStream & rOutStm, sal_uInt16 nTab ); +#endif +}; +SV_IMPL_REF(SvMetaClass) +SV_IMPL_PERSIST_LIST(SvMetaClass,SvMetaClass *) + + +#endif // _OBJECT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/idl/inc/pch/precompiled_idl.cxx b/idl/inc/pch/precompiled_idl.cxx new file mode 100644 index 000000000000..7515c4ededbc --- /dev/null +++ b/idl/inc/pch/precompiled_idl.cxx @@ -0,0 +1,31 @@ +/* -*- 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 "precompiled_idl.hxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/idl/inc/pch/precompiled_idl.hxx b/idl/inc/pch/precompiled_idl.hxx new file mode 100644 index 000000000000..977fd5d3b09e --- /dev/null +++ b/idl/inc/pch/precompiled_idl.hxx @@ -0,0 +1,34 @@ +/* -*- 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): Generated on 2006-09-01 17:49:49.467600 + +#ifdef PRECOMPILED_HEADERS +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/idl/inc/slot.hxx b/idl/inc/slot.hxx new file mode 100644 index 000000000000..b4036ea2ff2d --- /dev/null +++ b/idl/inc/slot.hxx @@ -0,0 +1,277 @@ +/* -*- 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. + * + ************************************************************************/ + +#ifndef _SLOT_HXX +#define _SLOT_HXX + +#include <types.hxx> +#include <command.hxx> + +class SvMetaSlotMemberList; +class SvMetaSlot : public SvMetaAttribute +{ + SvMetaTypeRef aSlotType; + SvMetaAttributeRef aMethod; + SvIdentifier aGroupId; + SvBOOL aHasCoreId; + SvIdentifier aConfigId; + SvIdentifier aExecMethod; + SvIdentifier aStateMethod; + SvIdentifier aDefault; + SvBOOL aPseudoSlots; + SvBOOL aGet; + SvBOOL aSet; + + SvBOOL aCachable; // exclusive + SvBOOL aVolatile; + SvBOOL aToggle; + SvBOOL aAutoUpdate; + + SvBOOL aSynchron; // exclusive + SvBOOL aAsynchron; + + SvBOOL aRecordPerItem;// exclusive + SvBOOL aRecordPerSet; + SvBOOL aRecordManual; + SvBOOL aNoRecord; + SvBOOL aRecordAbsolute; + + SvBOOL aHasDialog; + SvBOOL aMenuConfig; + SvBOOL aToolBoxConfig; + SvBOOL aStatusBarConfig; + SvBOOL aAccelConfig; + SvBOOL aFastCall; + SvBOOL aContainer; + SvBOOL aImageRotation; + SvBOOL aImageReflection; + SvIdentifier aPseudoPrefix; + SvString aDisableFlags; + SvMetaSlot* pLinkedSlot; + SvMetaSlot* pNextSlot; + sal_uLong nListPos; + SvMetaEnumValue* pEnumValue; + SvString aUnoName; + +#ifdef IDL_COMPILER + void WriteSlot( const ByteString & rShellName, + sal_uInt16 nCount, const ByteString & rSlotId, + SvSlotElementList &rList, + size_t nStart, + const ByteString & rPrefix, + SvIdlDataBase & rBase, SvStream & rOutStm ); + virtual void Write( SvIdlDataBase & rBase, + SvStream & rOutStm, sal_uInt16 nTab, + WriteType, WriteAttribute = 0 ); + + void SetEnumValue(SvMetaEnumValue *p) + { pEnumValue = p; } +#endif +protected: + void SetCachable( sal_Bool bSet ) + { + aCachable = bSet; + if( bSet ) + aVolatile = sal_False; + } + void SetVolatile( sal_Bool bSet ) + { + aVolatile = bSet; + if( bSet ) + aCachable = sal_False; + } + void SetToggle( sal_Bool bSet ) + { + aToggle = bSet; + } + void SetAutoUpdate( sal_Bool bSet ) + { + aAutoUpdate = bSet; + } + + void SetSynchron( sal_Bool bSet ) + { + aSynchron = bSet; + if( bSet ) + aAsynchron = sal_False; + } + void SetAsynchron( sal_Bool bSet ) + { + aAsynchron = bSet; + if( bSet ) + aSynchron = sal_False; + } + + void SetRecordPerItem( sal_Bool bSet ) + { + aRecordPerItem = bSet; + if( bSet ) + aRecordPerSet = aRecordManual = aNoRecord = sal_False; + } + void SetRecordPerSet( sal_Bool bSet ) + { + aRecordPerSet = bSet; + if( bSet ) + aRecordPerItem = aRecordManual = aNoRecord = sal_False; + } + void SetRecordManual( sal_Bool bSet ) + { + aRecordManual = bSet; + if( bSet ) + aRecordPerItem = aRecordPerSet = aNoRecord = sal_False; + } + void SetNoRecord( sal_Bool bSet ) + { + aNoRecord = bSet; + if( bSet ) + aRecordPerItem = aRecordPerSet = aRecordManual = sal_False; + } + void SetRecordAbsolute( sal_Bool bSet ) + { aRecordAbsolute = bSet; } + void SetHasDialog( sal_Bool bSet ) + { aHasDialog = bSet; } + void SetMenuConfig( sal_Bool bSet ) + { aMenuConfig = bSet; } + void SetToolBoxConfig( sal_Bool bSet ) + { aToolBoxConfig = bSet; } + void SetStatusBarConfig( sal_Bool bSet ) + { aStatusBarConfig = bSet; } + void SetAccelConfig( sal_Bool bSet ) + { aAccelConfig = bSet; } + void SetAllConfig( sal_Bool bSet ) + { + aMenuConfig = bSet; + aToolBoxConfig = bSet; + aStatusBarConfig = bSet; + aAccelConfig = bSet; + } + void SetFastCall( sal_Bool bSet ) + { aFastCall = bSet; } + void SetContainer( sal_Bool bSet ) + { aContainer = bSet; } + void SetImageRotation( sal_Bool bSet ) + { aImageRotation = bSet; } + void SetImageReflection( sal_Bool bSet ) + { aImageReflection = bSet; } + +public: + SV_DECL_META_FACTORY1( SvMetaSlot, SvMetaReference, 11 ) + SvMetaObject * MakeClone() const; + SvMetaSlot *Clone() const { return (SvMetaSlot *)MakeClone(); } + + SvMetaSlot(); + SvMetaSlot( SvMetaType * pType ); + + virtual sal_Bool IsVariable() const; + virtual sal_Bool IsMethod() const; + virtual ByteString GetMangleName( sal_Bool bVariable ) const; + + SvMetaAttribute * GetMethod() const; + SvMetaType * GetSlotType() const; + sal_Bool GetHasCoreId() const; + const ByteString & GetGroupId() const; + const ByteString & GetConfigId() const; + const ByteString & GetExecMethod() const; + const ByteString & GetStateMethod() const; + const ByteString & GetDefault() const; + const ByteString & GetDisableFlags() const; + sal_Bool GetPseudoSlots() const; + sal_Bool GetCachable() const; + sal_Bool GetVolatile() const; + sal_Bool GetToggle() const; + sal_Bool GetAutoUpdate() const; + + sal_Bool GetSynchron() const; + sal_Bool GetAsynchron() const; + + sal_Bool GetRecordPerItem() const; + sal_Bool GetRecordPerSet() const; + sal_Bool GetRecordManual() const; + sal_Bool GetNoRecord() const; + sal_Bool GetRecordAbsolute() const; + + sal_Bool GetHasDialog() const; + const ByteString & GetPseudoPrefix() const; + const ByteString & GetUnoName() const; + sal_Bool GetMenuConfig() const; + sal_Bool GetToolBoxConfig() const; + sal_Bool GetStatusBarConfig() const; + sal_Bool GetAccelConfig() const; + sal_Bool GetFastCall() const; + sal_Bool GetContainer() const; + sal_Bool GetImageRotation() const; + sal_Bool GetImageReflection() const; + SvMetaSlot* GetLinkedSlot() const + { return pLinkedSlot; } + SvMetaSlot* GetNextSlot() const + { return pNextSlot; } + sal_uLong GetListPos() const + { return nListPos; } + void SetListPos(sal_uLong n) + { nListPos = n; } + void ResetSlotPointer() + { pNextSlot = pLinkedSlot = 0; } + +#ifdef IDL_COMPILER + SvMetaEnumValue* GetEnumValue() const + { return pEnumValue; } + virtual sal_Bool Test( SvIdlDataBase &, SvTokenStream & rInStm ); + virtual void ReadAttributesSvIdl( SvIdlDataBase & rBase, + SvTokenStream & rInStm ); + virtual void WriteAttributesSvIdl( SvIdlDataBase & rBase, + SvStream & rOutStm, sal_uInt16 nTab ); + virtual sal_Bool ReadSvIdl( SvIdlDataBase &, SvTokenStream & rInStm ); + virtual void WriteSvIdl( SvIdlDataBase & rBase, + SvStream & rOutStm, sal_uInt16 nTab ); + virtual void Insert( SvSlotElementList&, const ByteString & rPrefix, + SvIdlDataBase& ); + void WriteSlotStubs( const ByteString & rShellName, + ByteStringList & rList, + SvStream & rOutStm ); + sal_uInt16 WriteSlotMap( const ByteString & rShellName, + sal_uInt16 nCount, + SvSlotElementList&, + size_t nStart, + const ByteString &, + SvIdlDataBase & rBase, + SvStream & rOutStm ); + sal_uInt16 WriteSlotParamArray( SvIdlDataBase & rBase, + SvStream & rOutStm ); + virtual void WriteHelpId( SvIdlDataBase & rBase, SvStream & rOutStm, + Table * pIdTable ); + virtual void WriteSrc( SvIdlDataBase & rBase, SvStream & rOutStm, + Table * pIdTable ); + virtual void WriteCSV( SvIdlDataBase&, SvStream& ); +#endif +}; +SV_DECL_IMPL_REF(SvMetaSlot) +SV_DECL_IMPL_PERSIST_LIST(SvMetaSlot,SvMetaSlot *) + +#endif // _SLOT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/idl/inc/types.hxx b/idl/inc/types.hxx new file mode 100644 index 000000000000..e4f405d9e693 --- /dev/null +++ b/idl/inc/types.hxx @@ -0,0 +1,332 @@ +/* -*- 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. + * + ************************************************************************/ + +#ifndef _TYPES_HXX +#define _TYPES_HXX + +#include <tools/ref.hxx> +#include <basobj.hxx> + +struct SvSlotElement; +typedef std::vector< SvSlotElement* > SvSlotElementList; + +SV_DECL_REF(SvMetaType) +SV_DECL_REF(SvMetaAttribute) +SV_DECL_PERSIST_LIST(SvMetaAttribute,SvMetaAttribute *) +class SvMetaAttribute : public SvMetaReference +{ + SvMetaTypeRef aType; + SvNumberIdentifier aSlotId; + SvBOOL aAutomation; + SvBOOL aExport; + SvBOOL aReadonly; + SvBOOL aIsCollection; + SvBOOL aReadOnlyDoc; + SvBOOL aHidden; + sal_Bool bNewAttr; + +protected: +#ifdef IDL_COMPILER + virtual void WriteCSource( SvIdlDataBase & rBase, + SvStream & rOutStm, sal_Bool bSet ); + sal_uLong MakeSlotValue( SvIdlDataBase & rBase, sal_Bool bVariable ) const; + virtual void WriteAttributes( SvIdlDataBase & rBase, + SvStream & rOutStm, sal_uInt16 nTab, + WriteType, WriteAttribute = 0 ); + virtual void ReadAttributesSvIdl( SvIdlDataBase & rBase, + SvTokenStream & rInStm ); + virtual void WriteAttributesSvIdl( SvIdlDataBase & rBase, + SvStream & rOutStm, sal_uInt16 nTab ); +#endif +public: + SV_DECL_META_FACTORY1( SvMetaAttribute, SvMetaReference, 2 ) + SvMetaAttribute(); + SvMetaAttribute( SvMetaType * ); + + void SetNewAttribute( sal_Bool bNew ) + { bNewAttr = bNew; } + sal_Bool IsNewAttribute() const + { return bNewAttr; } + sal_Bool GetReadonly() const; + + void SetSlotId( const SvNumberIdentifier & rId ) + { aSlotId = rId; } + const SvNumberIdentifier & GetSlotId() const; + + void SetExport( sal_Bool bSet ) + { aExport = bSet; } + sal_Bool GetExport() const; + + void SetHidden( sal_Bool bSet ) + { aHidden = bSet; } + sal_Bool GetHidden() const; + + void SetAutomation( sal_Bool bSet ) + { aAutomation = bSet; } + sal_Bool GetAutomation() const; + + void SetIsCollection( sal_Bool bSet ) + { aIsCollection = bSet; } + sal_Bool GetIsCollection() const; + void SetReadOnlyDoc( sal_Bool bSet ) + { aReadOnlyDoc = bSet; } + sal_Bool GetReadOnlyDoc() const; + + void SetType( SvMetaType * pT ) { aType = pT; } + SvMetaType * GetType() const; + + virtual sal_Bool IsMethod() const; + virtual sal_Bool IsVariable() const; + virtual ByteString GetMangleName( sal_Bool bVariable ) const; + + +#ifdef IDL_COMPILER + virtual sal_Bool Test( SvIdlDataBase &, SvTokenStream & rInStm ); + virtual sal_Bool ReadSvIdl( SvIdlDataBase &, SvTokenStream & rInStm ); + virtual void WriteSvIdl( SvIdlDataBase & rBase, SvStream & rOutStm, sal_uInt16 nTab ); + virtual void WriteParam( SvIdlDataBase & rBase, SvStream & rOutStm, sal_uInt16 nTab, + WriteType ); + void WriteRecursiv_Impl( SvIdlDataBase & rBase, + SvStream & rOutStm, sal_uInt16 nTab, + WriteType, WriteAttribute ); + virtual void Write( SvIdlDataBase & rBase, SvStream & rOutStm, sal_uInt16 nTab, + WriteType, WriteAttribute = 0 ); + sal_uLong MakeSfx( ByteString * pAtrrArray ); + virtual void Insert( SvSlotElementList&, const ByteString & rPrefix, + SvIdlDataBase& ); + virtual void WriteHelpId( SvIdlDataBase & rBase, SvStream & rOutStm, + Table * pIdTable ); + virtual void WriteSrc( SvIdlDataBase & rBase, SvStream & rOutStm, + Table * pIdTable ); + virtual void WriteCSV( SvIdlDataBase&, SvStream& ); + void FillIDTable(Table *pIDTable); + ByteString Compare( SvMetaAttribute *pAttr ); +#endif +}; +SV_IMPL_REF(SvMetaAttribute) +SV_IMPL_PERSIST_LIST(SvMetaAttribute,SvMetaAttribute *) + + +enum { CALL_VALUE, CALL_POINTER, CALL_REFERENCE }; +enum { TYPE_METHOD, TYPE_STRUCT, TYPE_BASE, TYPE_ENUM, TYPE_UNION, + TYPE_CLASS, TYPE_POINTER }; +class SvMetaType : public SvMetaExtern +{ + SvBOOL aIn; // input parameter + SvBOOL aOut; // return parameter + Svint aCall0, aCall1; + Svint aSbxDataType; + SvIdentifier aSvName; + SvIdentifier aSbxName; + SvIdentifier aOdlName; + SvIdentifier aCName; + SvIdentifier aBasicPostfix; + SvIdentifier aBasicName; + SvMetaAttributeMemberList * pAttrList; + int nType; + sal_Bool bIsItem; + sal_Bool bIsShell; + char cParserChar; + +#ifdef IDL_COMPILER + void WriteSfxItem( const ByteString & rItemName, SvIdlDataBase & rBase, + SvStream & rOutStm ); +protected: + sal_Bool ReadNamesSvIdl( SvIdlDataBase & rBase, + SvTokenStream & rInStm ); + virtual void ReadAttributesSvIdl( SvIdlDataBase &, SvTokenStream & rInStm ); + virtual void WriteAttributesSvIdl( SvIdlDataBase & rBase, SvStream & rOutStm, sal_uInt16 nTab ); + virtual void ReadContextSvIdl( SvIdlDataBase &, SvTokenStream & rInStm ); + virtual void WriteContextSvIdl( SvIdlDataBase &, SvStream & rOutStm, + sal_uInt16 nTab ); + + virtual void WriteContext( SvIdlDataBase & rBase, SvStream & rOutStm, + sal_uInt16 nTab, + WriteType, WriteAttribute = 0 ); + virtual void WriteAttributes( SvIdlDataBase & rBase, SvStream & rOutStm, sal_uInt16 nTab, + WriteType, WriteAttribute = 0 ); + sal_Bool ReadHeaderSvIdl( SvIdlDataBase &, SvTokenStream & rInStm ); + void WriteHeaderSvIdl( SvIdlDataBase &, SvStream & rOutStm, + sal_uInt16 nTab ); +#endif +public: + SV_DECL_META_FACTORY1( SvMetaType, SvMetaExtern, 18 ) + SvMetaType(); + SvMetaType( const ByteString & rTypeName, char cParserChar, + const ByteString & rCName ); + SvMetaType( const ByteString & rTypeName, const ByteString & rSbxName, + const ByteString & rOdlName, char cParserChar, + const ByteString & rCName, const ByteString & rBasicName, + const ByteString & rBasicPostfix ); + + SvMetaAttributeMemberList & GetAttrList() const; + sal_uLong GetAttrCount() const + { + return pAttrList ? pAttrList->Count() : 0L; + } + void AppendAttr( SvMetaAttribute * pAttr ) + { + GetAttrList().Append( pAttr ); + } + + void SetType( int nT ); + int GetType() const { return nType; } + SvMetaType * GetBaseType() const; + SvMetaType * GetReturnType() const; + sal_Bool IsItem() const { return bIsItem; } + sal_Bool IsShell() const { return bIsShell; } + + void SetIn( sal_Bool b ) { aIn = b; } + sal_Bool GetIn() const; + + void SetOut( sal_Bool b ) { aOut = b; } + sal_Bool GetOut() const; + + void SetCall0( int e ); + int GetCall0() const; + + void SetCall1( int e); + int GetCall1() const; + + void SetBasicName(const ByteString& rName) + { aBasicName = rName; } + + const ByteString & GetBasicName() const; + ByteString GetBasicPostfix() const; + const ByteString & GetSvName() const; + const ByteString & GetSbxName() const; + const ByteString & GetOdlName() const; + const ByteString & GetCName() const; + char GetParserChar() const { return cParserChar; } + + virtual sal_Bool SetName( const ByteString & rName, SvIdlDataBase * = NULL ); + + +#ifdef IDL_COMPILER + virtual sal_Bool ReadSvIdl( SvIdlDataBase &, SvTokenStream & rInStm ); + virtual void WriteSvIdl( SvIdlDataBase & rBase, + SvStream & rOutStm, sal_uInt16 nTab ); + virtual void Write( SvIdlDataBase & rBase, SvStream & rOutStm, sal_uInt16 nTab, + WriteType, WriteAttribute = 0 ); + ByteString GetCString() const; + void WriteSvIdlType( SvIdlDataBase & rBase, SvStream & rOutStm, sal_uInt16 nTab ); + void WriteOdlType( SvIdlDataBase & rBase, SvStream & rOutStm, sal_uInt16 nTab ); + void AppendParserString (ByteString &rString); + + sal_uLong MakeSfx( ByteString * pAtrrArray ); + virtual void WriteSfx( SvIdlDataBase & rBase, SvStream & rOutStm ); + sal_Bool ReadMethodArgs( SvIdlDataBase & rBase, + SvTokenStream & rInStm ); + void WriteTypePrefix( SvIdlDataBase & rBase, SvStream & rOutStm, sal_uInt16 nTab, WriteType ); + void WriteMethodArgs( SvIdlDataBase & rBase, SvStream & rOutStm, sal_uInt16 nTab, WriteType ); + void WriteTheType( SvIdlDataBase & rBase, SvStream & rOutStm, sal_uInt16 nTab, WriteType ); + ByteString GetParserString() const; + void WriteParamNames( SvIdlDataBase & rBase, SvStream & rOutStm, + const ByteString & rChief ); +#endif +}; +SV_IMPL_REF(SvMetaType) +SV_DECL_IMPL_PERSIST_LIST(SvMetaType,SvMetaType *) + + +class SvMetaTypeString : public SvMetaType +{ +public: + SV_DECL_META_FACTORY1( SvMetaTypeString, SvMetaType, 19 ) + SvMetaTypeString(); +}; +SV_DECL_IMPL_REF(SvMetaTypeString) +SV_DECL_IMPL_PERSIST_LIST(SvMetaTypeString,SvMetaTypeString *) + + +class SvMetaEnumValue : public SvMetaName +{ + ByteString aEnumValue; +public: + SV_DECL_META_FACTORY1( SvMetaEnumValue, SvMetaName, 20 ) + SvMetaEnumValue(); + +#ifdef IDL_COMPILER + virtual sal_Bool ReadSvIdl( SvIdlDataBase &, SvTokenStream & rInStm ); + virtual void WriteSvIdl( SvIdlDataBase & rBase, SvStream & rOutStm, sal_uInt16 nTab ); + virtual void Write( SvIdlDataBase & rBase, SvStream & rOutStm, sal_uInt16 nTab, + WriteType, WriteAttribute = 0 ); +#endif +}; +SV_DECL_IMPL_REF(SvMetaEnumValue) +SV_DECL_IMPL_PERSIST_LIST(SvMetaEnumValue,SvMetaEnumValue *) + + +class SvMetaTypeEnum : public SvMetaType +{ + SvMetaEnumValueMemberList aEnumValueList; + ByteString aPrefix; +protected: +#ifdef IDL_COMPILER + virtual void ReadContextSvIdl( SvIdlDataBase &, SvTokenStream & rInStm ); + virtual void WriteContextSvIdl( SvIdlDataBase &, SvStream & rOutStm, + sal_uInt16 nTab ); + virtual void WriteContext( SvIdlDataBase & rBase, SvStream & rOutStm, sal_uInt16 nTab, + WriteType, WriteAttribute = 0 ); +#endif +public: + SV_DECL_META_FACTORY1( SvMetaTypeEnum, SvMetaType, 21 ) + SvMetaTypeEnum(); + + sal_uInt16 GetMaxValue() const; + sal_uLong Count() const { return aEnumValueList.Count(); } + const ByteString & GetPrefix() const { return aPrefix; } + SvMetaEnumValue * GetObject( sal_uLong n ) const + { return aEnumValueList.GetObject( n ); } + +#ifdef IDL_COMPILER + virtual sal_Bool ReadSvIdl( SvIdlDataBase &, SvTokenStream & rInStm ); + virtual void WriteSvIdl( SvIdlDataBase & rBase, SvStream & rOutStm, sal_uInt16 nTab ); + + virtual void Write( SvIdlDataBase & rBase, SvStream & rOutStm, + sal_uInt16 nTab, + WriteType, WriteAttribute = 0 ); +#endif +}; +SV_DECL_IMPL_REF(SvMetaTypeEnum) +SV_DECL_IMPL_PERSIST_LIST(SvMetaTypeEnum,SvMetaTypeEnum *) + + +class SvMetaTypevoid : public SvMetaType +{ +public: + SV_DECL_META_FACTORY1( SvMetaTypevoid, SvMetaName, 22 ) + SvMetaTypevoid(); +}; +SV_DECL_IMPL_REF(SvMetaTypevoid) +SV_DECL_IMPL_PERSIST_LIST(SvMetaTypevoid,SvMetaTypevoid *) + + +#endif // _TYPES_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/idl/prj/build.lst b/idl/prj/build.lst new file mode 100644 index 000000000000..92d343a24021 --- /dev/null +++ b/idl/prj/build.lst @@ -0,0 +1,2 @@ +id idl : tools NULL +id idl\prj nmake - all idl_gprj NULL diff --git a/idl/prj/d.lst b/idl/prj/d.lst new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/idl/prj/d.lst diff --git a/idl/prj/makefile.mk b/idl/prj/makefile.mk new file mode 100755 index 000000000000..d4cf94ec9f4e --- /dev/null +++ b/idl/prj/makefile.mk @@ -0,0 +1,40 @@ +#************************************************************************* +# +# 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. +# +#************************************************************************* + +PRJ=.. +TARGET=prj + +.INCLUDE : settings.mk + +.IF "$(VERBOSE)"!="" +VERBOSEFLAG := +.ELSE +VERBOSEFLAG := -s +.ENDIF + +all: + cd $(PRJ) && $(GNUMAKE) $(VERBOSEFLAG) -r -j$(GMAKE_MODULE_PARALLELISM) $(gb_MAKETARGET) && $(GNUMAKE) $(VERBOSEFLAG) -r deliverlog diff --git a/idl/source/cmptools/hash.cxx b/idl/source/cmptools/hash.cxx new file mode 100644 index 000000000000..6ddc5a618bce --- /dev/null +++ b/idl/source/cmptools/hash.cxx @@ -0,0 +1,213 @@ +/* -*- 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_idl.hxx" + +// C and C++ includes +#include <stdlib.h> +#include <stdio.h> +#include <ctype.h> + +// program-sensitive includes +#include <hash.hxx> +#include <tools/debug.hxx> + +SvStringHashEntry::~SvStringHashEntry() { }; + +SvHashTable::SvHashTable( sal_uInt32 nMaxEntries ) +{ + nMax = nMaxEntries; // set max entries + nFill = 0; // no entries + lTry = 0; + lAsk = 0; +} + +SvHashTable::~SvHashTable() +{ +} + +sal_Bool SvHashTable::Test_Insert( const void * pElement, sal_Bool bInsert, + sal_uInt32 * pInsertPos ) +{ + sal_uInt32 nHash; + sal_uInt32 nIndex; + sal_uInt32 nLoop; + + lAsk++; + lTry++; + + nHash = HashFunc( pElement ); + nIndex = nHash % nMax; + + nLoop = 0; // divide to range + while( (nMax != nLoop) && IsEntry( nIndex ) ) + { // is place occupied + if( COMPARE_EQUAL == Compare( pElement, nIndex ) ) + { + if( pInsertPos ) + *pInsertPos = nIndex; // place of Element + return sal_True; + } + nLoop++; + lTry++; + nIndex = (sal_uInt16)(nIndex + nHash + 7) % nMax; + } + + if( bInsert ) + { + DBG_ASSERT( nMax != nLoop, "Hash table full" ); + if( nMax != nLoop ) + { + nFill++; + *pInsertPos = nIndex; // return free place + return sal_True; + } + } + return( sal_False ); +} + +SvStringHashTable::SvStringHashTable( sal_uInt32 nMaxEntries ) + : SvHashTable( nMaxEntries ) +{ + pEntries = new SvStringHashEntry[ nMaxEntries ]; + + // set RefCount to one + SvStringHashEntry * pPos, *pEnd; + pPos = pEntries; + pEnd = pEntries + nMaxEntries; + while( pPos != pEnd ) + { + pPos->AddRef(); + pPos++; + } +} + +SvStringHashTable::~SvStringHashTable() +{ +#ifdef DBG_UTIL + // set RefCount to one + SvStringHashEntry * pPos, *pEnd; + pPos = pEntries; + pEnd = pEntries + GetMax(); + while( pPos != pEnd ) + { + DBG_ASSERT( pPos->GetRefCount() == 1, "Reference count != 1" ); + pPos++; + } +#endif + + delete [] pEntries; +} + +sal_uInt32 SvStringHashTable::HashFunc( const void * pElement ) const +{ + sal_uInt32 nHash = 0; // hash value + const char * pStr = ((const ByteString * )pElement)->GetBuffer(); + + int nShift = 0; + while( *pStr ) + { + if( isupper( *pStr ) ) + nHash ^= sal_uInt32(*pStr - 'A' + 26) << nShift; + else + nHash ^= sal_uInt32(*pStr - 'a') << nShift; + if( nShift == 28 ) + nShift = 0; + else + nShift += 4; + pStr++; + } + return( nHash ); +} + +ByteString SvStringHashTable::GetNearString( const ByteString & rName ) const +{ + for( sal_uInt32 i = 0; i < GetMax(); i++ ) + { + SvStringHashEntry * pE = Get( i ); + if( pE ) + { + if( pE->GetName().EqualsIgnoreCaseAscii( rName ) && !pE->GetName().Equals( rName ) ) + return pE->GetName(); + } + } + return ByteString(); +} + +sal_Bool SvStringHashTable::IsEntry( sal_uInt32 nIndex ) const +{ + if( nIndex >= GetMax() ) + return sal_False; + return pEntries[ nIndex ].HasId(); +} + +sal_Bool SvStringHashTable::Insert( const ByteString & rName, sal_uInt32 * pIndex ) +{ + sal_uInt32 nIndex; + + if( !pIndex ) pIndex = &nIndex; + + if( !SvHashTable::Test_Insert( &rName, sal_True, pIndex ) ) + return sal_False; + + if( !IsEntry( *pIndex ) ) + pEntries[ *pIndex ] = SvStringHashEntry( rName, *pIndex ); + return sal_True; +} + +sal_Bool SvStringHashTable::Test( const ByteString & rName, sal_uInt32 * pPos ) const +{ + return ((SvStringHashTable *)this)->SvHashTable:: + Test_Insert( &rName, sal_False, pPos ); +} + +SvStringHashEntry * SvStringHashTable::Get( sal_uInt32 nIndex ) const +{ + if( IsEntry( nIndex ) ) + return pEntries + nIndex; + return( NULL ); +} + +StringCompare SvStringHashTable::Compare( const void * pElement, + sal_uInt32 nIndex ) const +{ + return ((const ByteString *)pElement)->CompareTo( pEntries[ nIndex ].GetName() ); +} + +void SvStringHashTable::FillHashList( SvStringHashList * pList ) const +{ + for( sal_uInt32 n = 0; n < GetMax(); n++ ) + { + if( IsEntry( n ) ) + pList->push_back( Get( n ) ); + } + // hash order, sort now +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/idl/source/cmptools/lex.cxx b/idl/source/cmptools/lex.cxx new file mode 100644 index 000000000000..244aa23069f1 --- /dev/null +++ b/idl/source/cmptools/lex.cxx @@ -0,0 +1,382 @@ +/* -*- 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_idl.hxx" + + +#include <ctype.h> +#include <stdio.h> + +#include <hash.hxx> +#include <lex.hxx> +#include <globals.hxx> +#include <tools/bigint.hxx> + +ByteString SvToken::GetTokenAsString() const +{ + ByteString aStr; + switch( nType ) + { + case SVTOKEN_EMPTY: + break; + case SVTOKEN_COMMENT: + aStr = aString; + break; + case SVTOKEN_INTEGER: + aStr = rtl::OString::valueOf(static_cast<sal_Int64>(nLong)); + break; + case SVTOKEN_STRING: + aStr = aString; + break; + case SVTOKEN_BOOL: + aStr = bBool ? "TRUE" : "FALSE"; + break; + case SVTOKEN_IDENTIFIER: + aStr = aString; + break; + case SVTOKEN_CHAR: + aStr = cChar; + break; + case SVTOKEN_RTTIBASE: + aStr = "RTTIBASE"; + break; + case SVTOKEN_EOF: + case SVTOKEN_HASHID: + break; + } + + return aStr; +} + +SvToken::SvToken( const SvToken & rObj ) +{ + nLine = rObj.nLine; + nColumn = rObj.nColumn; + nType = rObj.nType; + aString = rObj.aString; + nLong = rObj.nLong; +} + +SvToken & SvToken::operator = ( const SvToken & rObj ) +{ + if( this != &rObj ) + { + nLine = rObj.nLine; + nColumn = rObj.nColumn; + nType = rObj.nType; + aString = rObj.aString; + nLong = rObj.nLong; + } + return *this; +} + +void SvTokenStream::InitCtor() +{ + aStrTrue = "TRUE"; + aStrFalse = "FALSE"; + nLine = nColumn = 0; + nBufPos = 0; + nTabSize = 4; + nMaxPos = 0; + c = GetNextChar(); + FillTokenList(); +} + +SvTokenStream::SvTokenStream( const String & rFileName ) + : pInStream( new SvFileStream( rFileName, STREAM_STD_READ | STREAM_NOCREATE ) ) + , rInStream( *pInStream ) + , aFileName( rFileName ) +{ + InitCtor(); +} + +SvTokenStream::SvTokenStream( SvStream & rStream, const String & rFileName ) + : pInStream( NULL ) + , rInStream( rStream ) + , aFileName( rFileName ) +{ + InitCtor(); +} + +SvTokenStream::~SvTokenStream() +{ + delete pInStream; +} + +void SvTokenStream::FillTokenList() +{ + SvToken * pToken = new SvToken(); + aTokList.push_back(pToken); + do + { + if( !MakeToken( *pToken ) ) + { + if (!aTokList.empty()) + { + *pToken = SvToken(); + boost::ptr_vector<SvToken>::const_iterator it = aTokList.begin(); + + pToken->SetLine(it->GetLine()); + pToken->SetColumn(it->GetColumn()); + } + break; + } + else if( pToken->IsComment() ) + *pToken = SvToken(); + else if( pToken->IsEof() ) + break; + else + { + pToken = new SvToken(); + aTokList.push_back(pToken); + } + } + while( !pToken->IsEof() ); + pCurToken = aTokList.begin(); +} + +int SvTokenStream::GetNextChar() +{ + int nChar; + if( (int)aBufStr.Len() < nBufPos ) + { + if( rInStream.ReadLine( aBufStr ) ) + { + nLine++; + nColumn = 0; + nBufPos = 0; + } + else + { + aBufStr.Erase(); + nColumn = 0; + nBufPos = 0; + return '\0'; + } + } + nChar = aBufStr.GetChar( (sal_uInt16)nBufPos++ ); + nColumn += nChar == '\t' ? nTabSize : 1; + return nChar; +} + +sal_uLong SvTokenStream::GetNumber() +{ + sal_uLong l = 0; + short nLog = 10; + + if( '0' == c ) + { + c = GetFastNextChar(); + if( 'x' == c ) + { + nLog = 16; + c = GetFastNextChar(); + } + }; + + if( nLog == 16 ) + { + while( isxdigit( c ) ) + { + if( isdigit( c ) ) + l = l * nLog + (c - '0'); + else + l = l * nLog + (toupper( c ) - 'A' + 10 ); + c = GetFastNextChar(); + } + } + else + { + while( isdigit( c ) || 'x' == c ) + { + l = l * nLog + (c - '0'); + c = GetFastNextChar(); + } + } + + return( l ); +} + +sal_Bool SvTokenStream::MakeToken( SvToken & rToken ) +{ + do + { + if( 0 == c ) + c = GetNextChar(); + // skip whitespace + while( isspace( c ) || 26 == c ) + { + c = GetFastNextChar(); + nColumn += c == '\t' ? nTabSize : 1; + } + } + while( 0 == c && !IsEof() && ( SVSTREAM_OK == rInStream.GetError() ) ); + + sal_uLong nLastLine = nLine; + sal_uLong nLastColumn = nColumn; + // comment + if( '/' == c ) + { + // time optimization, no comments + int c1 = c; + c = GetFastNextChar(); + if( '/' == c ) + { + while( '\0' != c ) + { + c = GetFastNextChar(); + } + c = GetNextChar(); + rToken.nType = SVTOKEN_COMMENT; + } + else if( '*' == c ) + { + c = GetFastNextChar(); + do + { + while( '*' != c ) + { + if( '\0' == c ) + { + c = GetNextChar(); + if( IsEof() ) + return sal_False; + } + else + c = GetFastNextChar(); + } + c = GetFastNextChar(); + } + while( '/' != c && !IsEof() && ( SVSTREAM_OK == rInStream.GetError() ) ); + if( IsEof() || ( SVSTREAM_OK != rInStream.GetError() ) ) + return sal_False; + c = GetNextChar(); + rToken.nType = SVTOKEN_COMMENT; + CalcColumn(); + } + else + { + rToken.nType = SVTOKEN_CHAR; + rToken.cChar = (char)c1; + } + } + else if( c == '"' ) + { + ByteString aStr; + sal_Bool bDone = sal_False; + while( !bDone && !IsEof() && c ) + { + c = GetFastNextChar(); + if( '\0' == c ) + { + // read strings beyond end of line + aStr += '\n'; + c = GetNextChar(); + if( IsEof() ) + return sal_False; + } + if( c == '"' ) + { + c = GetFastNextChar(); + if( c == '"' ) + { + aStr += '"'; + aStr += '"'; + } + else + bDone = sal_True; + } + else if( c == '\\' ) + { + aStr += '\\'; + c = GetFastNextChar(); + if( c ) + aStr += (char)c; + } + else + aStr += (char)c; + } + if( IsEof() || ( SVSTREAM_OK != rInStream.GetError() ) ) + return sal_False; + rToken.nType = SVTOKEN_STRING; + rToken.aString = aStr; + } + else if( isdigit( c ) ) + { + rToken.nType = SVTOKEN_INTEGER; + rToken.nLong = GetNumber(); + + } + else if( isalpha (c) || (c == '_') ) + { + ByteString aStr; + + while( isalnum( c ) || c == '_' ) + { + aStr += (char)c; + c = GetFastNextChar(); + } + if( aStr.EqualsIgnoreCaseAscii( aStrTrue ) ) + { + rToken.nType = SVTOKEN_BOOL; + rToken.bBool = sal_True; + } + else if( aStr.EqualsIgnoreCaseAscii( aStrFalse ) ) + { + rToken.nType = SVTOKEN_BOOL; + rToken.bBool = sal_False; + } + else + { + sal_uInt32 nHashId; + if( IDLAPP->pHashTable->Test( aStr, &nHashId ) ) + rToken.SetHash( IDLAPP->pHashTable->Get( nHashId ) ); + else + { + rToken.nType = SVTOKEN_IDENTIFIER; + rToken.aString = aStr; + } + } + } + else if( IsEof() ) + { + rToken.nType = SVTOKEN_EOF; + } + else + { + rToken.nType = SVTOKEN_CHAR; + rToken.cChar = (char)c; + c = GetFastNextChar(); + } + rToken.SetLine( nLastLine ); + rToken.SetColumn( nLastColumn ); + return rInStream.GetError() == SVSTREAM_OK; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/idl/source/objects/basobj.cxx b/idl/source/objects/basobj.cxx new file mode 100644 index 000000000000..97822791533e --- /dev/null +++ b/idl/source/objects/basobj.cxx @@ -0,0 +1,600 @@ +/* -*- 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_idl.hxx" + +#include <ctype.h> +#include <stdio.h> + +#include <tools/debug.hxx> + +#include <basobj.hxx> +#include <module.hxx> +#include <globals.hxx> +#include <database.hxx> + +SV_IMPL_META_FACTORY1( SvMetaObject, SvRttiBase ) +SvMetaObject::SvMetaObject() +{ +} + +void SvMetaObject::Load( SvPersistStream & ) +{ +} + +void SvMetaObject::Save( SvPersistStream & ) +{ +} + +#ifdef IDL_COMPILER +void SvMetaObject::WriteTab( SvStream & rOutStm, sal_uInt16 nTab ) +{ + while( nTab-- ) + rOutStm << " "; +} + +void SvMetaObject::WriteStars( SvStream & rOutStm ) +{ + rOutStm << '/'; + for( int i = 6; i > 0; i-- ) + rOutStm << "**********"; + rOutStm << '/' << endl; +} + +sal_Bool SvMetaObject::TestAndSeekSpaceOnly( SvStream & rOutStm, sal_uLong nBegPos ) +{ + // write no empty brackets + sal_uLong nPos = rOutStm.Tell(); + rOutStm.Seek( nBegPos ); + sal_Bool bOnlySpace = sal_True; + while( bOnlySpace && rOutStm.Tell() < nPos ) + { + char c; + rOutStm >> c; + if( !isspace( c ) ) + bOnlySpace = sal_False; + } + if( bOnlySpace ) + // nothing written + rOutStm.Seek( nBegPos ); + else + rOutStm.Seek( nPos ); + return bOnlySpace; +} + +void SvMetaObject::Back2Delemitter( SvStream & rOutStm ) +{ + // write no empty brackets + sal_uLong nPos = rOutStm.Tell(); + rOutStm.SeekRel( -1 ); + char c = 0; + rOutStm >> c; + + while( isspace( c ) && rOutStm.Tell() != 1 ) + { + rOutStm.SeekRel( -2 ); + rOutStm >> c; + } + + if( c == ';' || c == ',' ) + rOutStm.SeekRel( -1 ); + else + rOutStm.Seek( nPos ); +} + +sal_Bool SvMetaObject::ReadSvIdl( SvIdlDataBase &, SvTokenStream & ) +{ + return sal_False; +} + +void SvMetaObject::WriteSvIdl( SvIdlDataBase &, SvStream &, sal_uInt16 /*nTab */ ) +{ +} + +void SvMetaObject::Write( SvIdlDataBase &, SvStream &, sal_uInt16 /*nTab */, + WriteType, WriteAttribute ) +{ +} + +void SvMetaObject::WriteCxx( SvIdlDataBase &, SvStream &, sal_uInt16 /*nTab */ ) +{ +} + +void SvMetaObject::WriteHxx( SvIdlDataBase &, SvStream &, sal_uInt16 /*nTab */ ) +{ +} + +#endif + +SV_IMPL_META_FACTORY1( SvMetaName, SvMetaObject ); +SvMetaName::SvMetaName() +{ +} + +void SvMetaName::Load( SvPersistStream & rStm ) +{ + SvMetaObject::Load( rStm ); + sal_uInt8 nMask; + rStm >> nMask; + + if( nMask >= 0x20 ) + { + rStm.SetError( SVSTREAM_FILEFORMAT_ERROR ); + OSL_FAIL( "wrong format" ); + return; + } + if( nMask & 0x01 ) rStm >> aName; + if( nMask & 0x02 ) rStm >> aHelpContext; + if( nMask & 0x04 ) rStm >> aHelpText; + if( nMask & 0x08 ) rStm >> aConfigName; + if( nMask & 0x10 ) rStm >> aDescription; +} + +void SvMetaName::Save( SvPersistStream & rStm ) +{ + SvMetaObject::Save( rStm ); + sal_uInt8 nMask = 0; + if( aName.IsSet() ) nMask |= 0x01; + if( aHelpContext.IsSet() ) nMask |= 0x02; + if( aHelpText.IsSet() ) nMask |= 0x04; + if( aConfigName.IsSet() ) nMask |= 0x08; + if( aDescription.IsSet() ) nMask |= 0x10; + + rStm << nMask; + if( nMask & 0x01 ) rStm << aName; + if( nMask & 0x02 ) rStm << aHelpContext; + if( nMask & 0x04 ) rStm << aHelpText; + if( nMask & 0x08 ) rStm << aConfigName; + if( nMask & 0x10 ) rStm << aDescription; +} + +sal_Bool SvMetaName::SetName( const ByteString & rName, SvIdlDataBase * ) +{ + aName = rName; + return sal_True; +} + +#ifdef IDL_COMPILER +sal_Bool SvMetaName::ReadNameSvIdl( SvIdlDataBase & rBase, + SvTokenStream & rInStm ) +{ + sal_uInt32 nTokPos = rInStm.Tell(); + SvToken * pTok = rInStm.GetToken_Next(); + + // read module name + if( pTok->IsIdentifier() ) + if( SetName( pTok->GetString(), &rBase ) ) + return sal_True; + + rInStm.Seek( nTokPos ); + return sal_False; +} + +void SvMetaName::ReadAttributesSvIdl( SvIdlDataBase & rBase, + SvTokenStream & rInStm ) +{ + sal_uInt32 nTokPos = rInStm.Tell(); + if( aName.ReadSvIdl( SvHash_Name(), rInStm ) ) + { + if( !SetName( aName, &rBase ) ) + rInStm.Seek( nTokPos ); + } + aHelpContext.ReadSvIdl( rBase, SvHash_HelpContext(), rInStm ); + aHelpText.ReadSvIdl( rBase, rInStm ); + aConfigName.ReadSvIdl( SvHash_ConfigName(), rInStm ); + aDescription.ReadSvIdl( SvHash_Description(), rInStm ); +} + +void SvMetaName::DoReadContextSvIdl( SvIdlDataBase & rBase, + SvTokenStream & rInStm, char cDel ) +{ + sal_uInt32 nBeginPos = 0; // can not happen with Tell + while( nBeginPos != rInStm.Tell() ) + { + nBeginPos = rInStm.Tell(); + ReadContextSvIdl( rBase, rInStm ); + if( cDel == '\0' ) + rInStm.ReadDelemiter(); + else + rInStm.Read( cDel ); + } +} + +void SvMetaName::ReadContextSvIdl( SvIdlDataBase &, SvTokenStream & ) +{ +} + +sal_Bool SvMetaName::Test( SvIdlDataBase &, SvTokenStream & ) +{ + return sal_True; +} + +void SvMetaName::WriteContextSvIdl( SvIdlDataBase &, SvStream &, sal_uInt16 ) +{ +} + +void SvMetaName::WriteDescription( SvStream & rOutStm ) +{ + rOutStm << "<DESCRIPTION>" << endl; + + ByteString aDesc( GetDescription() ); + sal_uInt16 nPos = aDesc.Search( '\n' ); + while ( nPos != STRING_NOTFOUND ) + { + rOutStm << aDesc.Copy( 0, nPos ).GetBuffer() << endl; + aDesc.Erase(0,nPos+1); + nPos = aDesc.Search( '\n' ); + } + + rOutStm << aDesc.GetBuffer() << endl << "</DESCRIPTION>" << endl; +} + +void SvMetaName::WriteAttributesSvIdl( SvIdlDataBase & rBase, + SvStream & rOutStm, + sal_uInt16 nTab ) +{ + if( aHelpContext.IsSet() || aHelpText.IsSet() || aConfigName.IsSet() ) + { + WriteTab( rOutStm, nTab ); + rOutStm << "// class SvMetaName" << endl; + } + if( aHelpContext.IsSet() ) + { + WriteTab( rOutStm, nTab ); + aHelpContext.WriteSvIdl( SvHash_HelpContext(), rOutStm, nTab ); + rOutStm << ';' << endl; + } + if( aHelpText.IsSet() ) + { + WriteTab( rOutStm, nTab ); + aHelpText.WriteSvIdl( rBase, rOutStm, nTab ); + rOutStm << ';' << endl; + } + if( aConfigName.IsSet() ) + { + WriteTab( rOutStm, nTab ); + aConfigName.WriteSvIdl( SvHash_ConfigName(), rOutStm, nTab ); + rOutStm << ';' << endl; + } +} + +sal_Bool SvMetaName::ReadSvIdl( SvIdlDataBase & rBase, SvTokenStream & rInStm ) +{ + sal_uInt32 nTokPos = rInStm.Tell(); + sal_Bool bOk = sal_True; + if( rInStm.Read( '[' ) ) + { + sal_uInt32 nBeginPos = 0; // can not happen with Tell + while( nBeginPos != rInStm.Tell() ) + { + nBeginPos = rInStm.Tell(); + ReadAttributesSvIdl( rBase, rInStm ); + rInStm.ReadDelemiter(); + } + bOk = rInStm.Read( ']' ); + } + + if( bOk ) + { + if( rInStm.Read( '{' ) ) + { + DoReadContextSvIdl( rBase, rInStm ); + bOk = rInStm.Read( '}' ); + } + } + + if( !bOk ) + rInStm.Seek( nTokPos ); + return bOk; +} + +void SvMetaName::WriteSvIdl( SvIdlDataBase & rBase, SvStream & rOutStm, + sal_uInt16 nTab ) +{ + sal_uLong nBeginPos = rOutStm.Tell(); + WriteTab( rOutStm, nTab ); + rOutStm << '[' << endl; + sal_uLong nOldPos = rOutStm.Tell(); + WriteAttributesSvIdl( rBase, rOutStm, nTab +1 ); + + // write no empty brackets + if( TestAndSeekSpaceOnly( rOutStm, nOldPos ) ) + // nothing written + rOutStm.Seek( nBeginPos ); + else + { + WriteTab( rOutStm, nTab ); + rOutStm << ']'; + nBeginPos = rOutStm.Tell(); + rOutStm << endl; + } + + WriteTab( rOutStm, nTab ); + rOutStm << '{' << endl; + nOldPos = rOutStm.Tell(); + WriteContextSvIdl( rBase, rOutStm, nTab +1 ); + + // write no empty brackets + if( TestAndSeekSpaceOnly( rOutStm, nOldPos ) ) + // nothing written + rOutStm.Seek( nBeginPos ); + else + { + WriteTab( rOutStm, nTab ); + rOutStm << '}'; + } +} + +void SvMetaName::Write( SvIdlDataBase & rBase, SvStream & rOutStm, + sal_uInt16 nTab, + WriteType nT, WriteAttribute nA ) +{ + sal_uLong nBeginPos = rOutStm.Tell(); + WriteTab( rOutStm, nTab ); + rOutStm << '[' << endl; + sal_uLong nOldPos = rOutStm.Tell(); + WriteAttributes( rBase, rOutStm, nTab +1, nT, nA ); + + // write no empty brackets + sal_uLong nPos = rOutStm.Tell(); + rOutStm.Seek( nOldPos ); + sal_Bool bOnlySpace = sal_True; + while( bOnlySpace && rOutStm.Tell() < nPos ) + { + char c; + rOutStm >> c; + if( !isspace( c ) ) + bOnlySpace = sal_False; + } + if( bOnlySpace ) + // nothing written + rOutStm.Seek( nBeginPos ); + else + { + rOutStm.Seek( nPos ); + WriteTab( rOutStm, nTab ); + rOutStm << ']' << endl; + } +} + +void SvMetaName::WriteAttributes( SvIdlDataBase &, SvStream & rOutStm, + sal_uInt16 nTab, + WriteType, WriteAttribute ) +{ + if( GetHelpText().IsSet() || GetHelpContext().IsSet() ) + { + WriteTab( rOutStm, nTab ); + rOutStm << "// class SvMetaName" << endl; + } + if( GetHelpText().IsSet() ) + { + WriteTab( rOutStm, nTab ); + rOutStm << "helpstring(\"" << GetHelpText().GetBuffer() << "\")," << endl; + } + if( GetHelpContext().IsSet() ) + { + WriteTab( rOutStm, nTab ); + rOutStm << "helpcontext(" + << rtl::OString::valueOf(static_cast<sal_Int64>( + GetHelpContext().GetValue())).getStr() + << ")," << endl; + } +} + +void SvMetaName::WriteContext( SvIdlDataBase &, SvStream &, + sal_uInt16, + WriteType, WriteAttribute ) +{ +} +#endif // IDL_COMPILER + +SV_IMPL_META_FACTORY1( SvMetaReference, SvMetaName ); + +SvMetaReference::SvMetaReference() +{ +} + +void SvMetaReference::Load( SvPersistStream & rStm ) +{ + SvMetaName::Load( rStm ); + + sal_uInt8 nMask; + rStm >> nMask; + if( nMask >= 0x2 ) + { + rStm.SetError( SVSTREAM_FILEFORMAT_ERROR ); + OSL_FAIL( "wrong format" ); + return; + } + if( nMask & 0x01 ) + { + SvMetaReference * pRef; + rStm >> pRef; + aRef = pRef; + } +} + +void SvMetaReference::Save( SvPersistStream & rStm ) +{ + SvMetaName::Save( rStm ); + + // create mask + sal_uInt8 nMask = 0; + if( aRef.Is() ) + nMask |= 0x01; + + // write data + rStm << nMask; + if( nMask & 0x01 ) rStm << aRef; +} + +SV_IMPL_META_FACTORY1( SvMetaExtern, SvMetaReference ); + +SvMetaExtern::SvMetaExtern() + : pModule( NULL ) + , bReadUUId( sal_False ) + , bReadVersion( sal_False ) +{ +} + +void SvMetaExtern::Load( SvPersistStream & rStm ) +{ + SvMetaReference::Load( rStm ); + + sal_uInt8 nMask; + rStm >> nMask; + if( nMask >= 0x20 ) + { + rStm.SetError( SVSTREAM_FILEFORMAT_ERROR ); + OSL_FAIL( "wrong format" ); + return; + } + if( nMask & 0x01 ) rStm >> pModule; + if( nMask & 0x02 ) rStm >> aUUId; + if( nMask & 0x04 ) rStm >> aVersion; + if( nMask & 0x08 ) bReadUUId = sal_True; + if( nMask & 0x10 ) bReadVersion = sal_True; +} + +void SvMetaExtern::Save( SvPersistStream & rStm ) +{ + SvMetaReference::Save( rStm ); + + // create mask + sal_uInt8 nMask = 0; + if( pModule ) nMask |= 0x01; + if( aUUId != SvGlobalName() ) nMask |= 0x02; + if( aVersion != SvVersion() ) nMask |= 0x04; + if( bReadUUId ) nMask |= 0x08; + if( bReadVersion ) nMask |= 0x10; + + // write data + rStm << nMask; + if( nMask & 0x01 ) rStm << pModule; + if( nMask & 0x02 ) rStm << aUUId; + if( nMask & 0x04 ) rStm << aVersion; +} + +SvMetaModule * SvMetaExtern::GetModule() const +{ + DBG_ASSERT( pModule != NULL, "module not set" ); + return pModule; +} + +const SvGlobalName & SvMetaExtern::GetUUId() const +{ +#ifdef IDL_COMPILER + if( aUUId == SvGlobalName() ) + GetModule()->FillNextName( &((SvMetaExtern *)this)->aUUId ); +#endif + return aUUId; +} + +#ifdef IDL_COMPILER +void SvMetaExtern::SetModule( SvIdlDataBase & rBase ) +{ + pModule = (SvMetaModule *)rBase.GetStack().Get( TYPE( SvMetaModule ) ); +} + +void SvMetaExtern::ReadAttributesSvIdl( SvIdlDataBase & rBase, + SvTokenStream & rInStm ) +{ + SvMetaReference::ReadAttributesSvIdl( rBase, rInStm ); + if( aUUId.ReadSvIdl( rBase, rInStm ) ) + bReadUUId = sal_True; + if( aVersion.ReadSvIdl( rInStm ) ) + bReadVersion = sal_True; +} + +void SvMetaExtern::WriteAttributesSvIdl( SvIdlDataBase & rBase, + SvStream & rOutStm, sal_uInt16 nTab ) +{ + SvMetaReference::WriteAttributesSvIdl( rBase, rOutStm, nTab ); + if( bReadUUId || bReadVersion ) + { + WriteTab( rOutStm, nTab ); + rOutStm << "// class SvMetaExtern" << endl; + + if( bReadUUId ) + { + WriteTab( rOutStm, nTab ); + aUUId.WriteSvIdl( rOutStm ); + rOutStm << ';' << endl; + } + if( bReadVersion ) + { + WriteTab( rOutStm, nTab ); + aVersion.WriteSvIdl( rOutStm ); + rOutStm << ';' << endl; + } + } +} + +sal_Bool SvMetaExtern::ReadSvIdl( SvIdlDataBase & rBase, SvTokenStream & rInStm ) +{ + SetModule( rBase ); + GetUUId(); // id gets created + return SvMetaReference::ReadSvIdl( rBase, rInStm ); +} + +void SvMetaExtern::WriteSvIdl( SvIdlDataBase & rBase, SvStream & rOutStm, + sal_uInt16 nTab ) +{ + SvMetaReference::WriteSvIdl( rBase, rOutStm, nTab ); +} + +void SvMetaExtern::Write( SvIdlDataBase & rBase, SvStream & rOutStm, + sal_uInt16 nTab, + WriteType nT, WriteAttribute nA ) +{ + SvMetaReference::Write( rBase, rOutStm, nTab, nT, nA ); +} + +void SvMetaExtern::WriteAttributes( SvIdlDataBase & rBase, SvStream & rOutStm, + sal_uInt16 nTab, + WriteType nT, WriteAttribute nA ) +{ + SvMetaReference::WriteAttributes( rBase, rOutStm, nTab, nT, nA ); + + WriteTab( rOutStm, nTab ); + rOutStm << "// class SvMetaExtern" << endl; + WriteTab( rOutStm, nTab ); + rOutStm << "uuid(" << ByteString( GetUUId().GetHexName(), RTL_TEXTENCODING_UTF8 ).GetBuffer() << ")," << endl; + WriteTab( rOutStm, nTab ); + rOutStm << "version(" + << rtl::OString::valueOf(static_cast<sal_Int32>(aVersion.GetMajorVersion())).getStr() + << '.' + << rtl::OString::valueOf(static_cast<sal_Int32>(aVersion.GetMinorVersion())).getStr() + << ")," << endl; +} + +#endif // IDL_COMPILER + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/idl/source/objects/bastype.cxx b/idl/source/objects/bastype.cxx new file mode 100644 index 000000000000..01faea8c6d3f --- /dev/null +++ b/idl/source/objects/bastype.cxx @@ -0,0 +1,444 @@ +/* -*- 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_idl.hxx" + +#include <tools/debug.hxx> + +#include <limits.h> +#include <ctype.h> +#include <bastype.hxx> +#include <lex.hxx> +#include <globals.hxx> +#include <hash.hxx> +#include <database.hxx> + +#ifdef IDL_COMPILER +static sal_Bool ReadRangeSvIdl( SvStringHashEntry * pName, SvTokenStream & rInStm, + sal_uLong nMin, sal_uLong nMax, sal_uLong* pValue ) +{ + sal_uInt32 nTokPos = rInStm.Tell(); + SvToken * pTok = rInStm.GetToken_Next(); + if( pTok->Is( pName ) ) + { + sal_Bool bOk = sal_False; + if( rInStm.Read( '=' ) ) + { + pTok = rInStm.GetToken_Next(); + if( pTok->IsInteger() ) + { + sal_uLong n = pTok->GetNumber(); + if ( n >= nMin && n <= nMax ) + { + *pValue = n; + bOk = sal_True; + } + } + } + + if( bOk ) + return sal_True; + } + + rInStm.Seek( nTokPos ); + return sal_False; +} +#endif + +sal_uInt32 SvUINT32::Read( SvStream & rStm ) +{ + return SvPersistStream::ReadCompressed( rStm ); +} + +void SvUINT32::Write( SvStream & rStm, sal_uInt32 nVal ) +{ + SvPersistStream::WriteCompressed( rStm, nVal ); +} + +SvStream& operator << (SvStream & rStm, const SvBOOL & rb ) +{ + sal_uInt8 n = rb.nVal; + if( rb.bSet ) + n |= 0x02; + rStm << n; + return rStm; +} +SvStream& operator >> (SvStream & rStm, SvBOOL & rb ) +{ + sal_uInt8 n; + rStm >> n; + rb.nVal = (n & 0x01) ? sal_True : sal_False; + rb.bSet = (n & 0x02) ? sal_True : sal_False; + if( n & ~0x03 ) + { + rStm.SetError( SVSTREAM_FILEFORMAT_ERROR ); + OSL_FAIL( "format error" ); + } + return rStm; +} + +SvStream& operator << (SvStream & rStm, const SvVersion & r ) +{ + if( (r.GetMajorVersion() || r.GetMinorVersion()) + && r.GetMajorVersion() <= 0x0F && r.GetMinorVersion() <= 0x0F ) + { // compress version number in 1 byte + // format first 4 bit for major, then 4 bit for minor + // 0.0 gets not compressed + + int n = r.GetMajorVersion() << 4; + n |= r.GetMinorVersion(); + rStm << (sal_uInt8)n; + } + else + { + rStm << (sal_uInt8)0; + rStm << r.GetMajorVersion(); + rStm << r.GetMinorVersion(); + } + return rStm; +} + +SvStream& operator >> (SvStream & rStm, SvVersion & r ) +{ + sal_uInt8 n; + rStm >> n; + if( n == 0 ) + { // not compressed + rStm >> r.nMajorVersion; + rStm >> r.nMinorVersion; + } + else + { // compressed + r.nMajorVersion = (n >> 4) & 0x0F; + r.nMinorVersion = n & 0x0F; + } + return rStm; +} + + +#ifdef IDL_COMPILER +sal_Bool SvBOOL::ReadSvIdl( SvStringHashEntry * pName, SvTokenStream & rInStm ) +{ + sal_uInt32 nTokPos = rInStm.Tell(); + SvToken * pTok = rInStm.GetToken_Next(); + + if( pTok->Is( pName ) ) + { + sal_Bool bOk = sal_True; + sal_Bool bBraket = rInStm.Read( '(' ); + if( bBraket || rInStm.Read( '=' ) ) + { + pTok = rInStm.GetToken(); + if( pTok->IsBool() ) + { + *this = pTok->GetBool(); + + rInStm.GetToken_Next(); + } + if( bOk && bBraket ) + bOk = rInStm.Read( ')' ); + } + else + *this = sal_True; //default action set to TRUE + if( bOk ) + return sal_True; + } + rInStm.Seek( nTokPos ); + return sal_False; +} + +sal_Bool SvBOOL::WriteSvIdl( SvStringHashEntry * pName, SvStream & rOutStm ) +{ + if( nVal ) + rOutStm << pName->GetName().GetBuffer(); + else + rOutStm << pName->GetName().GetBuffer() << "(FALSE)"; + return sal_True; +} + +ByteString SvBOOL::GetSvIdlString( SvStringHashEntry * pName ) +{ + if( nVal ) + return pName->GetName(); + else + { + ByteString aTmp( pName->GetName() ); + aTmp += "(FALSE)"; + return aTmp; + } +} + + +sal_Bool SvIdentifier::ReadSvIdl( SvStringHashEntry * pName, SvTokenStream & rInStm ) +{ + sal_uInt32 nTokPos = rInStm.Tell(); + SvToken * pTok = rInStm.GetToken_Next(); + + if( pTok->Is( pName ) ) + { + sal_Bool bOk = sal_True; + sal_Bool bBraket = rInStm.Read( '(' ); + if( bBraket || rInStm.Read( '=' ) ) + { + pTok = rInStm.GetToken(); + if( pTok->IsIdentifier() ) + { + *(ByteString *)this = pTok->GetString(); + rInStm.GetToken_Next(); + } + if( bOk && bBraket ) + bOk = rInStm.Read( ')' ); + } + if( bOk ) + return sal_True; + } + rInStm.Seek( nTokPos ); + return sal_False; +} + +sal_Bool SvIdentifier::WriteSvIdl( SvStringHashEntry * pName, + SvStream & rOutStm, + sal_uInt16 /*nTab */ ) +{ + rOutStm << pName->GetName().GetBuffer() << '('; + rOutStm << GetBuffer() << ')'; + return sal_True; +} + +SvStream& operator << (SvStream & rStm, const SvIdentifier & r ) +{ + rStm.WriteByteString( r ); + return rStm; +} + +SvStream& operator >> (SvStream & rStm, SvIdentifier & r ) +{ + rStm.ReadByteString( r ); + return rStm; +} + + +sal_Bool SvNumberIdentifier::ReadSvIdl( SvIdlDataBase & rBase, + SvStringHashEntry * pName, + SvTokenStream & rInStm ) +{ + if( SvIdentifier::ReadSvIdl( pName, rInStm ) ) + { + sal_uLong n; + if( rBase.FindId( *this, &n ) ) + { + nValue = n; + return sal_True; + } + else + { + ByteString aStr ("no value for identifier <"); + aStr += *this; + aStr += "> "; + rBase.SetError( aStr, rInStm.GetToken() ); + rBase.WriteError( rInStm ); + } + } + return sal_False; +} + +sal_Bool SvNumberIdentifier::ReadSvIdl( SvIdlDataBase & rBase, + SvTokenStream & rInStm ) +{ + sal_uInt32 nTokPos = rInStm.Tell(); + SvToken * pTok = rInStm.GetToken_Next(); + + if( pTok->IsIdentifier() ) + { + sal_uLong n; + if( rBase.FindId( pTok->GetString(), &n ) ) + { + *(ByteString *)this = pTok->GetString(); + nValue = n; + return sal_True; + } + else + { + ByteString aStr ("no value for identifier <"); + aStr += *this; + aStr += "> "; + rBase.SetError( aStr, rInStm.GetToken() ); + rBase.WriteError( rInStm ); + } + } + rInStm.Seek( nTokPos ); + return sal_False; +} + +SvStream& operator << (SvStream & rStm, const SvNumberIdentifier & r ) +{ + rStm << (SvIdentifier &)r; + SvPersistStream::WriteCompressed( rStm, r.nValue ); + return rStm; +} + +SvStream& operator >> (SvStream & rStm, SvNumberIdentifier & r ) +{ + rStm >> (SvIdentifier &)r; + r.nValue = SvPersistStream::ReadCompressed( rStm ); + return rStm; +} + + +sal_Bool SvString::ReadSvIdl( SvStringHashEntry * pName, SvTokenStream & rInStm ) +{ + sal_uInt32 nTokPos = rInStm.Tell(); + SvToken * pTok = rInStm.GetToken_Next(); + + if( pTok->Is( pName ) ) + { + sal_Bool bOk = sal_True; + sal_Bool bBraket = rInStm.Read( '(' ); + if( bBraket || rInStm.Read( '=' ) ) + { + pTok = rInStm.GetToken(); + if( pTok->IsString() ) + { + *(ByteString *)this = pTok->GetString(); + rInStm.GetToken_Next(); + } + if( bOk && bBraket ) + bOk = rInStm.Read( ')' ); + } + if( bOk ) + return sal_True; + } + rInStm.Seek( nTokPos ); + return sal_False; +} + +sal_Bool SvString::WriteSvIdl( SvStringHashEntry * pName, SvStream & rOutStm, + sal_uInt16 /*nTab */ ) +{ + rOutStm << pName->GetName().GetBuffer() << "(\""; + rOutStm << GetBuffer() << "\")"; + return sal_True; +} + +SvStream& operator << (SvStream & rStm, const SvString & r ) +{ + rStm.WriteByteString( r ); + return rStm; +} + +SvStream& operator >> (SvStream & rStm, SvString & r ) +{ + rStm.ReadByteString( r ); + return rStm; +} + + +sal_Bool SvHelpText::ReadSvIdl( SvIdlDataBase &, SvTokenStream & rInStm ) +{ + return SvString::ReadSvIdl( SvHash_HelpText(), rInStm ); +} + +sal_Bool SvHelpText::WriteSvIdl( SvIdlDataBase &, SvStream & rOutStm, sal_uInt16 nTab ) +{ + return SvString::WriteSvIdl( SvHash_HelpText(), rOutStm, nTab ); +} + +sal_Bool SvUUId::ReadSvIdl( SvIdlDataBase &, SvTokenStream & rInStm ) +{ + sal_uInt32 nTokPos = rInStm.Tell(); + SvToken * pTok = rInStm.GetToken_Next(); + + if( pTok->Is( SvHash_uuid() ) ) + { + sal_Bool bOk = sal_True; + sal_Bool bBraket = rInStm.Read( '(' ); + if( bBraket || rInStm.Read( '=' ) ) + { + pTok = rInStm.GetToken(); + if( pTok->IsString() ) + { + pTok = rInStm.GetToken_Next(); + bOk = MakeId( String::CreateFromAscii( pTok->GetString().GetBuffer() ) ); + } + if( bOk && bBraket ) + bOk = rInStm.Read( ')' ); + } + if( bOk ) + return sal_True; + } + rInStm.Seek( nTokPos ); + return sal_False; +} + +sal_Bool SvUUId::WriteSvIdl( SvStream & rOutStm ) +{ + // write global id + rOutStm << SvHash_uuid()->GetName().GetBuffer() << "(\""; + rOutStm << ByteString( GetHexName(), RTL_TEXTENCODING_UTF8 ).GetBuffer() << "\")"; + return sal_True; +} + + +sal_Bool SvVersion::ReadSvIdl( SvTokenStream & rInStm ) +{ + sal_uLong n = 0; + + sal_uInt32 nTokPos = rInStm.Tell(); + if( ReadRangeSvIdl( SvHash_Version(), rInStm, 0 , 0xFFFF, &n ) ) + { + nMajorVersion = (sal_uInt16)n; + if( rInStm.Read( '.' ) ) + { + SvToken * pTok = rInStm.GetToken_Next(); + if( pTok->IsInteger() && pTok->GetNumber() <= 0xFFFF ) + { + nMinorVersion = (sal_uInt16)pTok->GetNumber(); + return sal_True; + } + } + else + return sal_True; + } + rInStm.Seek( nTokPos ); + return sal_False; +} + +sal_Bool SvVersion::WriteSvIdl( SvStream & rOutStm ) +{ + rOutStm << SvHash_Version()->GetName().GetBuffer() << '(' + << rtl::OString::valueOf(static_cast<sal_Int32>(nMajorVersion)).getStr() + << '.' + << rtl::OString::valueOf(static_cast<sal_Int32>(nMinorVersion)).getStr() + << ')'; + return sal_True; +} +#endif //IDL_COMPILER + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/idl/source/objects/module.cxx b/idl/source/objects/module.cxx new file mode 100644 index 000000000000..1ee58edc41ff --- /dev/null +++ b/idl/source/objects/module.cxx @@ -0,0 +1,551 @@ +/* -*- 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_idl.hxx" + +#include <ctype.h> +#include <stdio.h> + +#include <module.hxx> +#include <globals.hxx> +#include <database.hxx> +#include <tools/fsys.hxx> +#include <tools/debug.hxx> + +SV_IMPL_META_FACTORY1( SvMetaModule, SvMetaExtern ); + +SvMetaModule::SvMetaModule() +#ifdef IDL_COMPILER + : bImported( sal_False ) + , bIsModified( sal_False ) +#endif +{ +} + +#ifdef IDL_COMPILER +SvMetaModule::SvMetaModule( const String & rIdlFileName, sal_Bool bImp ) + : aIdlFileName( rIdlFileName ) + , bImported( bImp ), bIsModified( sal_False ) +{ +} +#endif + +#define MODULE_VER 0x0001 +void SvMetaModule::Load( SvPersistStream & rStm ) +{ + bImported = sal_True; // import always + SvMetaExtern::Load( rStm ); + + sal_uInt16 nVer; + + rStm >> nVer; // version + DBG_ASSERT( (nVer & ~IDL_WRITE_MASK) == MODULE_VER, "false version" ); + + rStm >> aClassList; + rStm >> aTypeList; + rStm >> aAttrList; + // browser + rStm.ReadByteString( aIdlFileName ); + rStm.ReadByteString( aHelpFileName ); + rStm.ReadByteString( aSlotIdFile ); + rStm.ReadByteString( aModulePrefix ); + + // read compiler data + sal_uInt16 nCmpLen; + rStm >> nCmpLen; +#ifdef IDL_COMPILER + DBG_ASSERT( (nVer & IDL_WRITE_MASK) == IDL_WRITE_COMPILER, + "no idl compiler format" ); + rStm >> aBeginName; + rStm >> aEndName; + rStm >> aNextName; +#else + rStm->SeekRel( nCmpLen ); +#endif +} + +void SvMetaModule::Save( SvPersistStream & rStm ) +{ + SvMetaExtern::Save( rStm ); + + rStm << (sal_uInt16)(MODULE_VER | IDL_WRITE_COMPILER); // Version + + rStm << aClassList; + rStm << aTypeList; + rStm << aAttrList; + // browser + rStm.WriteByteString( aIdlFileName ); + rStm.WriteByteString( aHelpFileName ); + rStm.WriteByteString( aSlotIdFile ); + rStm.WriteByteString( aModulePrefix ); + + // write compiler data + sal_uInt16 nCmpLen = 0; + sal_uLong nLenPos = rStm.Tell(); + rStm << nCmpLen; +#ifdef IDL_COMPILER + rStm << aBeginName; + rStm << aEndName; + rStm << aNextName; + // write length of compiler data + sal_uLong nPos = rStm.Tell(); + rStm.Seek( nLenPos ); + rStm << (sal_uInt16)( nPos - nLenPos - sizeof( sal_uInt16 ) ); + rStm.Seek( nPos ); +#endif +} + +sal_Bool SvMetaModule::SetName( const ByteString & rName, SvIdlDataBase * pBase ) +{ + if( pBase ) + { + if( pBase->GetModule( rName ) ) + return sal_False; + } + return SvMetaExtern::SetName( rName ); +} + +#ifdef IDL_COMPILER +sal_Bool SvMetaModule::FillNextName( SvGlobalName * pName ) +{ + *pName = aNextName; + + if( aNextName < aEndName ) + { + ++aNextName; + bIsModified = sal_True; + return sal_True; + } + return sal_False; +} + +void SvMetaModule::ReadAttributesSvIdl( SvIdlDataBase & rBase, + SvTokenStream & rInStm ) +{ + SvMetaExtern::ReadAttributesSvIdl( rBase, rInStm ); + + aHelpFileName.ReadSvIdl( SvHash_HelpFile(), rInStm ); + if( aSlotIdFile.ReadSvIdl( SvHash_SlotIdFile(), rInStm ) ) + { + sal_uInt32 nTokPos = rInStm.Tell(); + if( !rBase.ReadIdFile( String::CreateFromAscii( aSlotIdFile.GetBuffer() ) ) ) + { + ByteString aStr = "cannot read file: "; + aStr += aSlotIdFile; + rBase.SetError( aStr, rInStm.GetToken() ); + rBase.WriteError( rInStm ); + + rInStm.Seek( nTokPos ); + } + } + aTypeLibFile.ReadSvIdl( SvHash_TypeLibFile(), rInStm ); + aModulePrefix.ReadSvIdl( SvHash_ModulePrefix(), rInStm ); +} + +void SvMetaModule::WriteAttributesSvIdl( SvIdlDataBase & rBase, + SvStream & rOutStm, + sal_uInt16 nTab ) +{ + SvMetaExtern::WriteAttributesSvIdl( rBase, rOutStm, nTab ); + if( aTypeLibFile.Len() || aSlotIdFile.Len() || aTypeLibFile.Len() ) + { + if( aHelpFileName.Len() ) + { + WriteTab( rOutStm, nTab ); + aHelpFileName.WriteSvIdl( SvHash_HelpFile(), rOutStm, nTab +1 ); + rOutStm << ';' << endl; + } + if( aSlotIdFile.Len() ) + { + WriteTab( rOutStm, nTab ); + aSlotIdFile.WriteSvIdl( SvHash_SlotIdFile(), rOutStm, nTab +1 ); + rOutStm << ';' << endl; + } + if( aTypeLibFile.Len() ) + { + WriteTab( rOutStm, nTab ); + aTypeLibFile.WriteSvIdl( SvHash_TypeLibFile(), rOutStm, nTab +1 ); + rOutStm << ';' << endl; + } + } +} + +void SvMetaModule::ReadContextSvIdl( SvIdlDataBase & rBase, + SvTokenStream & rInStm ) +{ + sal_uInt32 nTokPos = rInStm.Tell(); + if( rInStm.GetToken()->Is( SvHash_interface() ) + || rInStm.GetToken()->Is( SvHash_shell() ) ) + { + SvMetaClassRef aClass = new SvMetaClass(); + if( aClass->ReadSvIdl( rBase, rInStm ) ) + { + aClassList.Append( aClass ); + // announce globally + rBase.GetClassList().Append( aClass ); + } + } + else if( rInStm.GetToken()->Is( SvHash_enum() ) ) + { + SvMetaTypeEnumRef aEnum = new SvMetaTypeEnum(); + + if( aEnum->ReadSvIdl( rBase, rInStm ) ) + { + // declared in module + aTypeList.Append( aEnum ); + // announce globally + rBase.GetTypeList().Append( aEnum ); + } + } + else if( rInStm.GetToken()->Is( SvHash_item() ) + || rInStm.GetToken()->Is( SvHash_struct() ) + || rInStm.GetToken()->Is( SvHash_typedef() ) ) + { + SvMetaTypeRef xItem = new SvMetaType(); + + if( xItem->ReadSvIdl( rBase, rInStm ) ) + { + // declared in module + aTypeList.Append( xItem ); + // announce globally + rBase.GetTypeList().Append( xItem ); + } + } + else if( rInStm.GetToken()->Is( SvHash_include() ) ) + { + sal_Bool bOk = sal_False; + rInStm.GetToken_Next(); + SvToken * pTok = rInStm.GetToken_Next(); + if( pTok->IsString() ) + { + DirEntry aFullName( String::CreateFromAscii( pTok->GetString().GetBuffer() ) ); + rBase.StartNewFile( aFullName.GetFull() ); + if( aFullName.Find( rBase.GetPath() ) ) + { + SvTokenStream aTokStm( aFullName.GetFull() ); + if( SVSTREAM_OK == aTokStm.GetStream().GetError() ) + { + // rescue error from old file + SvIdlError aOldErr = rBase.GetError(); + // reset error + rBase.SetError( SvIdlError() ); + + sal_uInt32 nBeginPos = 0xFFFFFFFF; // can not happen with Tell + while( nBeginPos != aTokStm.Tell() ) + { + nBeginPos = aTokStm.Tell(); + ReadContextSvIdl( rBase, aTokStm ); + aTokStm.ReadDelemiter(); + } + bOk = aTokStm.GetToken()->IsEof(); + if( !bOk ) + { + rBase.WriteError( aTokStm ); + } + // recover error from old file + rBase.SetError( aOldErr ); + } + else + { + ByteString aStr = "cannot open file: "; + aStr += ByteString( aFullName.GetFull(), RTL_TEXTENCODING_UTF8 ); + rBase.SetError( aStr, pTok ); + } + } + else + { + ByteString aStr = "cannot find file: "; + aStr += ByteString( aFullName.GetFull(), RTL_TEXTENCODING_UTF8 ); + rBase.SetError( aStr, pTok ); + } + } + if( !bOk ) + rInStm.Seek( nTokPos ); + } + else + { + SvMetaSlotRef xSlot = new SvMetaSlot(); + + if( xSlot->ReadSvIdl( rBase, rInStm ) ) + { + if( xSlot->Test( rBase, rInStm ) ) + { + // declared in module + aAttrList.Append( xSlot ); + // announce globally + rBase.AppendAttr( xSlot ); + } + } + } +} + +void SvMetaModule::WriteContextSvIdl( SvIdlDataBase & rBase, + SvStream & rOutStm, + sal_uInt16 nTab ) +{ + SvMetaExtern::WriteContextSvIdl( rBase, rOutStm, nTab ); + sal_uLong n; + for( n = 0; n < aTypeList.Count(); n++ ) + { + WriteTab( rOutStm, nTab ); + aTypeList.GetObject( n )->WriteSvIdl( rBase, rOutStm, nTab ); + } + rOutStm << endl; + 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++ ) + { + WriteTab( rOutStm, nTab ); + aClassList.GetObject( n )->WriteSvIdl( rBase, rOutStm, nTab ); + } +} + +sal_Bool SvMetaModule::ReadSvIdl( SvIdlDataBase & rBase, SvTokenStream & rInStm ) +{ + bIsModified = sal_True; // up to now always when compiler running + + sal_uInt32 nTokPos = rInStm.Tell(); + SvToken * pTok = rInStm.GetToken_Next(); + sal_Bool bOk = sal_False; + bOk = pTok->Is( SvHash_module() ); + if( bOk ) + { + pTok = rInStm.GetToken_Next(); + if( pTok->IsString() ) + bOk = aBeginName.MakeId( String::CreateFromAscii( pTok->GetString().GetBuffer() ) ); + } + rInStm.ReadDelemiter(); + if( bOk ) + { + pTok = rInStm.GetToken_Next(); + if( pTok->IsString() ) + bOk = aEndName.MakeId( String::CreateFromAscii( pTok->GetString().GetBuffer() ) ); + } + rInStm.ReadDelemiter(); + if( bOk ) + { + aNextName = aBeginName; + + rBase.Push( this ); // onto the context stack + + if( ReadNameSvIdl( rBase, rInStm ) ) + { + // set pointer to itself + SetModule( rBase ); + bOk = SvMetaName::ReadSvIdl( rBase, rInStm ); + } + rBase.GetStack().Pop(); // remove from stack + } + if( !bOk ) + rInStm.Seek( nTokPos ); + return bOk; +} + +void SvMetaModule::WriteSvIdl( SvIdlDataBase & rBase, SvStream & rOutStm, + sal_uInt16 nTab ) +{ + rOutStm << SvHash_module()->GetName().GetBuffer() << endl + << '\"'; + rOutStm.WriteByteString( aBeginName.GetHexName() ); + rOutStm << '\"' << endl << '\"'; + rOutStm.WriteByteString( aEndName.GetHexName() ); + rOutStm << '\"' << endl; + SvMetaExtern::WriteSvIdl( rBase, rOutStm, nTab ); +} + +void SvMetaModule::WriteSfx( SvIdlDataBase & rBase, SvStream & rOutStm ) +{ + for( sal_uLong n = 0; n < aClassList.Count(); n++ ) + { + SvMetaClass * pClass = aClassList.GetObject( n ); + pClass->WriteSfx( rBase, rOutStm ); + } +} + +void SvMetaModule::WriteHelpIds( SvIdlDataBase & rBase, SvStream & rOutStm, + Table* pTable ) +{ + for( sal_uLong n = 0; n < aClassList.Count(); n++ ) + { + SvMetaClass * pClass = aClassList.GetObject( n ); + pClass->WriteHelpIds( rBase, rOutStm, pTable ); + } +} + +void SvMetaModule::WriteAttributes( SvIdlDataBase & rBase, + SvStream & rOutStm, + sal_uInt16 nTab, + WriteType nT, WriteAttribute nA ) +{ + SvMetaExtern::WriteAttributes( rBase, rOutStm, nTab, nT, nA ); + if( aHelpFileName.Len() ) + { + WriteTab( rOutStm, nTab ); + rOutStm << "// class SvMetaModule" << endl; + WriteTab( rOutStm, nTab ); + rOutStm << "helpfile(\"" << aHelpFileName.GetBuffer() << "\");" << endl; + } +} + +void SvMetaModule::Write( SvIdlDataBase & rBase, SvStream & rOutStm, + sal_uInt16 nTab, + WriteType nT, WriteAttribute nA ) +{ + switch ( nT ) + { + case WRITE_ODL: + { + if( aSlotIdFile.Len() ) + { + WriteTab( rOutStm, nTab ); + rOutStm << "#include \"" << aSlotIdFile.GetBuffer() << '"' << endl << endl; + } + SvMetaExtern::Write( rBase, rOutStm, nTab, nT, nA ); + rOutStm << endl; + WriteTab( rOutStm, nTab ); + rOutStm << "library " << GetName().GetBuffer() << endl; + WriteTab( rOutStm, nTab ); + rOutStm << '{' << endl; + WriteTab( rOutStm, nTab ); + rOutStm << "importlib(\"STDOLE.TLB\");" << endl; + + for( sal_uLong n = 0; n < aClassList.Count(); n++ ) + { + SvMetaClass * pClass = aClassList.GetObject( n ); + if( !pClass->IsShell() && pClass->GetAutomation() ) + { + WriteTab( rOutStm, nTab ); + WriteStars( rOutStm ); + pClass->Write( rBase, rOutStm, nTab +1, nT, nA ); + if( n +1 < aClassList.Count() ) + rOutStm << endl; + } + } + + rOutStm << '}' << endl; + } + break; + case WRITE_DOCU: + { + rOutStm << "SvIDL interface documentation" << endl << endl; + rOutStm << "<MODULE>" << endl << GetName().GetBuffer() << endl; + WriteDescription( rOutStm ); + rOutStm << "</MODULE>" << endl << endl; + + rOutStm << "<CLASSES>" << endl; + for( sal_uLong n = 0; n < aClassList.Count(); n++ ) + { + SvMetaClass * pClass = aClassList.GetObject( n ); + if( !pClass->IsShell() ) + { + rOutStm << pClass->GetName().GetBuffer(); + SvMetaClass* pSC = pClass->GetSuperClass(); + if( pSC ) + rOutStm << " : " << pSC->GetName().GetBuffer(); + + // imported classes + const SvClassElementMemberList& rClassList = pClass->GetClassList(); + if ( rClassList.Count() ) + { + rOutStm << " ( "; + + for( sal_uLong m=0; m<rClassList.Count(); m++ ) + { + SvClassElement *pEle = rClassList.GetObject(m); + SvMetaClass *pCl = pEle->GetClass(); + rOutStm << pCl->GetName().GetBuffer(); + if ( m+1 == rClassList.Count() ) + rOutStm << " )"; + else + rOutStm << " , "; + } + } + + rOutStm << endl; + } + } + rOutStm << "</CLASSES>" << endl << endl; + // no break! + } + + case WRITE_C_SOURCE: + case WRITE_C_HEADER: + { + for( sal_uLong n = 0; n < aClassList.Count(); n++ ) + { + SvMetaClass * pClass = aClassList.GetObject( n ); + if( !pClass->IsShell() ) + pClass->Write( rBase, rOutStm, nTab, nT, nA ); + } + } + break; + + default: + break; + } +} + +void SvMetaModule::WriteSrc( SvIdlDataBase & rBase, SvStream & rOutStm, + Table * pTable ) +{ + if( aSlotIdFile.Len() ) + rOutStm << "//#include <" << aSlotIdFile.GetBuffer() << '>' << endl; + for( sal_uLong n = 0; n < aClassList.Count(); n++ ) + { + aClassList.GetObject( n )->WriteSrc( rBase, rOutStm, pTable ); + } +} + +void SvMetaModule::WriteHxx( SvIdlDataBase & rBase, SvStream & rOutStm, + sal_uInt16 nTab ) +{ + for( sal_uLong n = 0; n < aClassList.Count(); n++ ) + { + SvMetaClass * pClass = aClassList.GetObject( n ); + pClass->WriteHxx( rBase, rOutStm, nTab ); + } +} + +void SvMetaModule::WriteCxx( SvIdlDataBase & rBase, SvStream & rOutStm, + sal_uInt16 nTab ) +{ + for( sal_uLong n = 0; n < aClassList.Count(); n++ ) + { + SvMetaClass * pClass = aClassList.GetObject( n ); + pClass->WriteCxx( rBase, rOutStm, nTab ); + } +} + +#endif // IDL_COMPILER + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/idl/source/objects/object.cxx b/idl/source/objects/object.cxx new file mode 100644 index 000000000000..8308d50625ec --- /dev/null +++ b/idl/source/objects/object.cxx @@ -0,0 +1,755 @@ +/* -*- 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_idl.hxx" + +#include <ctype.h> +#include <stdio.h> + +#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( '.' ); + 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(); + ByteString rPre = rPrefix; + if( rPre.Len() && pEle->GetPrefix().Len() ) + rPre += '.'; + rPre += pEle->GetPrefix(); + + // first of all write direct imported interfaces + pCl->InsertSlots( rList, rSuperList, rClassList, rPre, 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( " << ByteString( GetUUId().GetctorName(), RTL_TEXTENCODING_UTF8 ).GetBuffer() << " ); }" << 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( " << ByteString( pMod->GetUUId().GetctorName(), RTL_TEXTENCODING_UTF8 ).GetBuffer() << " );" << 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: */ diff --git a/idl/source/objects/slot.cxx b/idl/source/objects/slot.cxx new file mode 100644 index 000000000000..e56d95776960 --- /dev/null +++ b/idl/source/objects/slot.cxx @@ -0,0 +1,1715 @@ +/* -*- 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_idl.hxx" + +#include <ctype.h> +#include <stdio.h> +#include <tools/debug.hxx> +#include <slot.hxx> +#include <globals.hxx> +#include <database.hxx> + +SV_IMPL_META_FACTORY1( SvMetaSlot, SvMetaAttribute ); + +SvMetaObject *SvMetaSlot::MakeClone() const +{ + return new SvMetaSlot( *this ); +} + +SvMetaSlot::SvMetaSlot() + : aCachable( sal_True, sal_False ) + , aSynchron( sal_True, sal_False ) + , aRecordPerSet( sal_True, sal_False ) + , aRecordAbsolute( sal_False, sal_False ) + , pLinkedSlot(0) + , pNextSlot(0) + , pEnumValue(0) +{ +} + +SvMetaSlot::SvMetaSlot( SvMetaType * pType ) + : SvMetaAttribute( pType ) + , aCachable( sal_True, sal_False ) + , aSynchron( sal_True, sal_False ) + , aRecordPerSet( sal_True, sal_False ) + , aRecordAbsolute( sal_False, sal_False ) + , pLinkedSlot(0) + , pNextSlot(0) + , pEnumValue(0) +{ +} + +#define TEST_READ +#define TEST_WRITE + +void SvMetaSlot::Load( SvPersistStream & rStm ) +{ + SvMetaAttribute::Load( rStm ); + + sal_uInt16 nMask; + rStm >> nMask; + + TEST_READ + if( nMask & 0x0001 ) + { + SvMetaAttribute * pMeth; + rStm >> pMeth; + aMethod = pMeth; + } + + TEST_READ + if( nMask & 0x0002 ) rStm >> aGroupId; + TEST_READ + if( nMask & 0x0004 ) rStm >> aHasCoreId; + TEST_READ + if( nMask & 0x0008 ) rStm >> aConfigId; + TEST_READ + if( nMask & 0x0010 ) rStm >> aExecMethod; + TEST_READ + if( nMask & 0x0020 ) rStm >> aStateMethod; + TEST_READ + if( nMask & 0x0040 ) rStm >> aDefault; + TEST_READ + if( nMask & 0x0080 ) rStm >> aPseudoSlots; + TEST_READ + if( nMask & 0x0100 ) rStm >> aGet; + TEST_READ + if( nMask & 0x0200 ) rStm >> aSet; + TEST_READ + if( nMask & 0x0400 ) rStm >> aCachable; + TEST_READ + if( nMask & 0x0800 ) rStm >> aVolatile; + TEST_READ + if( nMask & 0x1000 ) rStm >> aToggle; + TEST_READ + if( nMask & 0x2000 ) rStm >> aAutoUpdate; + TEST_READ + if( nMask & 0x4000 ) rStm >> aSynchron; + TEST_READ + if( nMask & 0x8000 ) rStm >> aAsynchron; + + nMask = 0; + rStm >> nMask; + + TEST_READ + if( nMask & 0x0001 ) rStm >> aRecordPerItem; + TEST_READ + if( nMask & 0x0002 ) rStm >> aRecordManual; + TEST_READ + if( nMask & 0x0004 ) rStm >> aNoRecord; + TEST_READ + if( nMask & 0x0008 ) rStm >> aHasDialog; + TEST_READ + if( nMask & 0x0010 ) rStm >> aDisableFlags; + TEST_READ + if( nMask & 0x0020 ) rStm >> aPseudoPrefix; + TEST_READ + if( nMask & 0x0040 ) rStm >> aRecordPerSet; + TEST_READ + if( nMask & 0x0080 ) rStm >> aMenuConfig; + TEST_READ + if( nMask & 0x0100 ) rStm >> aToolBoxConfig; + TEST_READ + if( nMask & 0x0200 ) rStm >> aStatusBarConfig; + TEST_READ + if( nMask & 0x0400 ) rStm >> aAccelConfig; + TEST_READ + if( nMask & 0x0800 ) rStm >> aFastCall; + TEST_READ + if( nMask & 0x1000 ) rStm >> aContainer; + TEST_READ + + if( nMask & 0x2000 ) + { + SvMetaType * pT; + rStm >> pT; + aSlotType = pT; + } + + TEST_READ + if( nMask & 0x4000 ) rStm >> aRecordAbsolute; + TEST_READ + if( nMask & 0x8000 ) rStm >> aImageRotation; + + nMask = 0; + rStm >> nMask; + + TEST_READ + if( nMask & 0x0001 ) rStm >> aUnoName; + if( nMask & 0x0002 ) rStm >> aImageReflection; +} + +void SvMetaSlot::Save( SvPersistStream & rStm ) +{ + SvMetaAttribute::Save( rStm ); + + // create mask + sal_uInt16 nMask = 0; + if( aMethod.Is() ) nMask |= 0x0001; + if( aGroupId.Len() ) nMask |= 0x0002; + if( aHasCoreId.IsSet() ) nMask |= 0x0004; + if( aConfigId.Len() ) nMask |= 0x0008; + if( aExecMethod.Len() ) nMask |= 0x0010; + if( aStateMethod.Len() ) nMask |= 0x0020; + if( aDefault.Len() ) nMask |= 0x0040; + if( aPseudoSlots.IsSet() ) nMask |= 0x0080; + if( aGet.IsSet() ) nMask |= 0x0100; + if( aSet.IsSet() ) nMask |= 0x0200; + if( aCachable.IsSet() ) nMask |= 0x0400; + if( aVolatile.IsSet() ) nMask |= 0x0800; + if( aToggle.IsSet() ) nMask |= 0x1000; + if( aAutoUpdate.IsSet() ) nMask |= 0x2000; + if( aSynchron.IsSet() ) nMask |= 0x4000; + if( aAsynchron.IsSet() ) nMask |= 0x8000; + + // write data + rStm << nMask; + TEST_WRITE + if( nMask & 0x0001 ) rStm << aMethod; + TEST_WRITE + if( nMask & 0x0002 ) rStm << aGroupId; + TEST_WRITE + if( nMask & 0x0004 ) rStm << aHasCoreId; + TEST_WRITE + if( nMask & 0x0008 ) rStm << aConfigId; + TEST_WRITE + if( nMask & 0x0010 ) rStm << aExecMethod; + TEST_WRITE + if( nMask & 0x0020 ) rStm << aStateMethod; + TEST_WRITE + if( nMask & 0x0040 ) rStm << aDefault; + TEST_WRITE + if( nMask & 0x0080 ) rStm << aPseudoSlots; + TEST_WRITE + if( nMask & 0x0100 ) rStm << aGet; + TEST_WRITE + if( nMask & 0x0200 ) rStm << aSet; + TEST_WRITE + if( nMask & 0x0400 ) rStm << aCachable; + TEST_WRITE + if( nMask & 0x0800 ) rStm << aVolatile; + TEST_WRITE + if( nMask & 0x1000 ) rStm << aToggle; + TEST_WRITE + if( nMask & 0x2000 ) rStm << aAutoUpdate; + TEST_WRITE + if( nMask & 0x4000 ) rStm << aSynchron; + TEST_WRITE + if( nMask & 0x8000 ) rStm << aAsynchron; + + // write next bunch + // create mask + nMask = 0; + if( aRecordPerItem.IsSet() ) nMask |= 0x0001; + if( aRecordManual.IsSet() ) nMask |= 0x0002; + if( aNoRecord.IsSet() ) nMask |= 0x0004; + if( aHasDialog.IsSet() ) nMask |= 0x0008; + if ( aDisableFlags.IsSet() ) nMask |= 0x0010; + if( aPseudoPrefix.Len() ) nMask |= 0x0020; + if( aRecordPerSet.IsSet() ) nMask |= 0x0040; + if( aMenuConfig.IsSet() ) nMask |= 0x0080; + if( aToolBoxConfig.IsSet() ) nMask |= 0x0100; + if( aStatusBarConfig.IsSet() )nMask |= 0x0200; + if( aAccelConfig.IsSet() ) nMask |= 0x0400; + if( aFastCall.IsSet() ) nMask |= 0x0800; + if( aContainer.IsSet() ) nMask |= 0x1000; + if( aSlotType.Is() ) nMask |= 0x2000; + if( aRecordAbsolute.IsSet() ) nMask |= 0x4000; + if( aImageRotation.IsSet() ) nMask |= 0x8000; + + // write data + rStm << nMask; + TEST_WRITE + if( nMask & 0x0001 ) rStm << aRecordPerItem; + TEST_WRITE + if( nMask & 0x0002 ) rStm << aRecordManual; + TEST_WRITE + if( nMask & 0x0004 ) rStm << aNoRecord; + TEST_WRITE + if( nMask & 0x0008 ) rStm << aHasDialog; + TEST_WRITE + if( nMask & 0x0010 ) rStm << aDisableFlags; + TEST_WRITE + if( nMask & 0x0020 ) rStm << aPseudoPrefix; + TEST_WRITE + if( nMask & 0x0040 ) rStm << aRecordPerSet; + TEST_WRITE + if( nMask & 0x0080 ) rStm << aMenuConfig; + TEST_WRITE + if( nMask & 0x0100 ) rStm << aToolBoxConfig; + TEST_WRITE + if( nMask & 0x0200 ) rStm << aStatusBarConfig; + TEST_WRITE + if( nMask & 0x0400 ) rStm << aAccelConfig; + TEST_WRITE + if( nMask & 0x0800 ) rStm << aFastCall; + TEST_WRITE + if( nMask & 0x1000 ) rStm << aContainer; + TEST_WRITE + if( nMask & 0x2000 ) rStm << aSlotType; + TEST_WRITE + if( nMask & 0x4000 ) rStm << aRecordAbsolute; + TEST_WRITE + if( nMask & 0x8000 ) rStm << aImageRotation; + + nMask = 0; + if( aUnoName.IsSet() ) nMask |= 0x0001; + if( aImageReflection.IsSet() ) nMask |= 0x0002; + rStm << nMask; + TEST_WRITE + if( nMask & 0x0001 ) rStm << aUnoName; + TEST_WRITE + if( nMask & 0x0002 ) rStm << aImageReflection; +} + +sal_Bool SvMetaSlot::IsVariable() const +{ + return SvMetaAttribute::IsVariable(); +} + +sal_Bool SvMetaSlot::IsMethod() const +{ + sal_Bool b = SvMetaAttribute::IsMethod(); + b |= NULL != GetMethod(); + return b; +} + +ByteString SvMetaSlot::GetMangleName( sal_Bool bVariable ) const +{ + if( !bVariable ) + { + SvMetaAttribute * pMeth = GetMethod(); + if( pMeth ) + return pMeth->GetName(); + } + return GetName(); +} + +/************************************************************************* +|* reference +|* +|* description Second FALSE in the SvBOOL-Objects means +|* IsSet() provides FALSE (default initialization). +*************************************************************************/ +/** reference disbandment **/ +SvMetaType * SvMetaSlot::GetSlotType() const +{ + if( aSlotType.Is() || !GetRef() ) return aSlotType; + return ((SvMetaSlot *)GetRef())->GetSlotType(); +} +SvMetaAttribute * SvMetaSlot::GetMethod() const +{ + if( aMethod.Is() || !GetRef() ) return aMethod; + return ((SvMetaSlot *)GetRef())->GetMethod(); +} +sal_Bool SvMetaSlot::GetHasCoreId() const +{ + if( aHasCoreId.IsSet() || !GetRef() ) return aHasCoreId; + return ((SvMetaSlot *)GetRef())->GetHasCoreId(); +} +const ByteString & SvMetaSlot::GetGroupId() const +{ + if( aGroupId.Len() || !GetRef() ) return aGroupId; + return ((SvMetaSlot *)GetRef())->GetGroupId(); +} +const ByteString & SvMetaSlot::GetDisableFlags() const +{ + if( aDisableFlags.Len() || !GetRef() ) return aDisableFlags; + return ((SvMetaSlot *)GetRef())->GetDisableFlags(); +} +const ByteString & SvMetaSlot::GetConfigId() const +{ + if( aConfigId.Len() || !GetRef() ) return aConfigId; + return ((SvMetaSlot *)GetRef())->GetConfigId(); +} +const ByteString & SvMetaSlot::GetExecMethod() const +{ + if( aExecMethod.Len() || !GetRef() ) return aExecMethod; + return ((SvMetaSlot *)GetRef())->GetExecMethod(); +} +const ByteString & SvMetaSlot::GetStateMethod() const +{ + if( aStateMethod.Len() || !GetRef() ) return aStateMethod; + return ((SvMetaSlot *)GetRef())->GetStateMethod(); +} +const ByteString & SvMetaSlot::GetDefault() const +{ + if( aDefault.Len() || !GetRef() ) return aDefault; + return ((SvMetaSlot *)GetRef())->GetDefault(); +} +sal_Bool SvMetaSlot::GetPseudoSlots() const +{ + if( aPseudoSlots.IsSet() || !GetRef() ) return aPseudoSlots; + return ((SvMetaSlot *)GetRef())->GetPseudoSlots(); +} +sal_Bool SvMetaSlot::GetCachable() const +{ + // Cachable and Volatile are exclusive + if( !GetRef() || aCachable.IsSet() || aVolatile.IsSet() ) + return aCachable; + return ((SvMetaSlot *)GetRef())->GetCachable(); +} +sal_Bool SvMetaSlot::GetVolatile() const +{ + // Cachable and Volatile are exclusive + if( !GetRef() || aVolatile.IsSet() || aCachable.IsSet() ) + return aVolatile; + return ((SvMetaSlot *)GetRef())->GetVolatile(); +} +sal_Bool SvMetaSlot::GetToggle() const +{ + if( aToggle.IsSet() || !GetRef() ) return aToggle; + return ((SvMetaSlot *)GetRef())->GetToggle(); +} +sal_Bool SvMetaSlot::GetAutoUpdate() const +{ + if( aAutoUpdate.IsSet() || !GetRef() ) return aAutoUpdate; + return ((SvMetaSlot *)GetRef())->GetAutoUpdate(); +} +sal_Bool SvMetaSlot::GetSynchron() const +{ + // Synchron and Asynchron are exclusive + if( !GetRef() || aSynchron.IsSet() || aAsynchron.IsSet() ) + return aSynchron; + return ((SvMetaSlot *)GetRef())->GetSynchron(); +} +sal_Bool SvMetaSlot::GetAsynchron() const +{ + // Synchron and Asynchron are exclusive + if( !GetRef() || aAsynchron.IsSet() || aSynchron.IsSet() ) + return aAsynchron; + return ((SvMetaSlot *)GetRef())->GetAsynchron(); +} +sal_Bool SvMetaSlot::GetRecordPerItem() const +{ + // Record- PerItem, No, PerSet and Manual are exclusive + if( !GetRef() || aRecordPerItem.IsSet() || aNoRecord.IsSet() + || aRecordPerSet.IsSet() || aRecordManual.IsSet() ) + return aRecordPerItem; + return ((SvMetaSlot *)GetRef())->GetRecordPerItem(); +} +sal_Bool SvMetaSlot::GetRecordPerSet() const +{ + // Record- PerItem, No, PerSet and Manual are exclusive + if( !GetRef() || aRecordPerItem.IsSet() || aNoRecord.IsSet() + || aRecordPerSet.IsSet() || aRecordManual.IsSet() ) + return aRecordPerSet; + return ((SvMetaSlot *)GetRef())->GetRecordPerSet(); +} +sal_Bool SvMetaSlot::GetRecordManual() const +{ + // Record- PerItem, No, PerSet and Manual are exclusive + if( !GetRef() || aRecordPerItem.IsSet() || aNoRecord.IsSet() + || aRecordPerSet.IsSet() || aRecordManual.IsSet() ) + return aRecordManual; + return ((SvMetaSlot *)GetRef())->GetRecordManual(); +} +sal_Bool SvMetaSlot::GetNoRecord() const +{ + // Record- PerItem, No, PerSet and Manual are exclusive + if( !GetRef() || aRecordPerItem.IsSet() || aNoRecord.IsSet() + || aRecordPerSet.IsSet() || aRecordManual.IsSet() ) + return aNoRecord; + return ((SvMetaSlot *)GetRef())->GetNoRecord(); +} +sal_Bool SvMetaSlot::GetRecordAbsolute() const +{ + if( !GetRef() || aRecordAbsolute.IsSet() ) + return aRecordAbsolute; + return ((SvMetaSlot *)GetRef())->GetRecordAbsolute(); +} +sal_Bool SvMetaSlot::GetHasDialog() const +{ + if( aHasDialog.IsSet() || !GetRef() ) return aHasDialog; + return ((SvMetaSlot *)GetRef())->GetHasDialog(); +} +const ByteString & SvMetaSlot::GetPseudoPrefix() const +{ + if( aPseudoPrefix.Len() || !GetRef() ) return aPseudoPrefix; + return ((SvMetaSlot *)GetRef())->GetPseudoPrefix(); +} +sal_Bool SvMetaSlot::GetMenuConfig() const +{ + if( aMenuConfig.IsSet() || !GetRef() ) return aMenuConfig; + return ((SvMetaSlot *)GetRef())->GetMenuConfig(); +} +sal_Bool SvMetaSlot::GetToolBoxConfig() const +{ + if( aToolBoxConfig.IsSet() || !GetRef() ) return aToolBoxConfig; + return ((SvMetaSlot *)GetRef())->GetToolBoxConfig(); +} +sal_Bool SvMetaSlot::GetStatusBarConfig() const +{ + if( aStatusBarConfig.IsSet() || !GetRef() ) return aStatusBarConfig; + return ((SvMetaSlot *)GetRef())->GetStatusBarConfig(); +} +sal_Bool SvMetaSlot::GetAccelConfig() const +{ + if( aAccelConfig.IsSet() || !GetRef() ) return aAccelConfig; + return ((SvMetaSlot *)GetRef())->GetAccelConfig(); +} +sal_Bool SvMetaSlot::GetFastCall() const +{ + if( aFastCall.IsSet() || !GetRef() ) return aFastCall; + return ((SvMetaSlot *)GetRef())->GetFastCall(); +} +sal_Bool SvMetaSlot::GetContainer() const +{ + if( aContainer.IsSet() || !GetRef() ) return aContainer; + return ((SvMetaSlot *)GetRef())->GetContainer(); +} + +sal_Bool SvMetaSlot::GetImageRotation() const +{ + if( aImageRotation.IsSet() || !GetRef() ) return aImageRotation; + return ((SvMetaSlot *)GetRef())->GetImageRotation(); +} + +sal_Bool SvMetaSlot::GetImageReflection() const +{ + if( aImageReflection.IsSet() || !GetRef() ) return aImageReflection; + return ((SvMetaSlot *)GetRef())->GetImageReflection(); +} + +const ByteString& SvMetaSlot::GetUnoName() const +{ + if( aUnoName.IsSet() || !GetRef() ) return aUnoName; + return ((SvMetaSlot *)GetRef())->GetUnoName(); +} + +#ifdef IDL_COMPILER +void SvMetaSlot::ReadAttributesSvIdl( SvIdlDataBase & rBase, + SvTokenStream & rInStm ) +{ + SvMetaAttribute::ReadAttributesSvIdl( rBase, rInStm ); + + sal_Bool bOk = sal_False; + bOk |= aDefault.ReadSvIdl( SvHash_Default(), rInStm ); + bOk |= aPseudoSlots.ReadSvIdl( SvHash_PseudoSlots(), rInStm ); + bOk |= aHasCoreId.ReadSvIdl( SvHash_HasCoreId(), rInStm ); + bOk |= aGroupId.ReadSvIdl( SvHash_GroupId(), rInStm ); + bOk |= aExecMethod.ReadSvIdl( SvHash_ExecMethod(), rInStm ); + bOk |= aStateMethod.ReadSvIdl( SvHash_StateMethod(), rInStm ); + bOk |= aDisableFlags.ReadSvIdl( SvHash_DisableFlags(), rInStm ); + if( aGet.ReadSvIdl( SvHash_Get(), rInStm ) ) + { + rBase.WriteError( "warning", ByteString( rInStm.GetFileName(), RTL_TEXTENCODING_UTF8 ), + "<Get> old style, use Readonly", + rInStm.GetToken()->GetLine(), + rInStm.GetToken()->GetColumn() ); + } + if( aSet.ReadSvIdl( SvHash_Set(), rInStm ) ) + { + rBase.WriteError( "warning", ByteString( rInStm.GetFileName(), RTL_TEXTENCODING_UTF8 ), + "<Set> old style, use method declaration", + rInStm.GetToken()->GetLine(), + rInStm.GetToken()->GetColumn() ); + } + + if( aCachable.ReadSvIdl( SvHash_Cachable(), rInStm ) ) + SetCachable( aCachable ), bOk = sal_True; + if( aVolatile.ReadSvIdl( SvHash_Volatile(), rInStm ) ) + SetVolatile( aVolatile ), bOk = sal_True; + if( aToggle.ReadSvIdl( SvHash_Toggle(), rInStm ) ) + SetToggle( aToggle ), bOk = sal_True; + if( aAutoUpdate.ReadSvIdl( SvHash_AutoUpdate(), rInStm ) ) + SetAutoUpdate( aAutoUpdate ), bOk = sal_True; + + if( aSynchron.ReadSvIdl( SvHash_Synchron(), rInStm ) ) + SetSynchron( aSynchron ), bOk = sal_True; + if( aAsynchron.ReadSvIdl( SvHash_Asynchron(), rInStm ) ) + SetAsynchron( aAsynchron ), bOk = sal_True; + + if( aRecordAbsolute.ReadSvIdl( SvHash_RecordAbsolute(), rInStm ) ) + SetRecordAbsolute( aRecordAbsolute), bOk = sal_True; + if( aRecordPerItem.ReadSvIdl( SvHash_RecordPerItem(), rInStm ) ) + SetRecordPerItem( aRecordPerItem ), bOk = sal_True; + if( aRecordPerSet.ReadSvIdl( SvHash_RecordPerSet(), rInStm ) ) + SetRecordPerSet( aRecordPerSet ), bOk = sal_True; + if( aRecordManual.ReadSvIdl( SvHash_RecordManual(), rInStm ) ) + SetRecordManual( aRecordManual ), bOk = sal_True; + if( aNoRecord.ReadSvIdl( SvHash_NoRecord(), rInStm ) ) + SetNoRecord( aNoRecord ), bOk = sal_True; + + bOk |= aHasDialog.ReadSvIdl( SvHash_HasDialog(), rInStm ); + bOk |= aPseudoPrefix.ReadSvIdl( SvHash_PseudoPrefix(), rInStm ); + bOk |= aMenuConfig.ReadSvIdl( SvHash_MenuConfig(), rInStm ); + bOk |= aToolBoxConfig.ReadSvIdl( SvHash_ToolBoxConfig(), rInStm ); + bOk |= aStatusBarConfig.ReadSvIdl( SvHash_StatusBarConfig(), rInStm ); + bOk |= aAccelConfig.ReadSvIdl( SvHash_AccelConfig(), rInStm ); + + SvBOOL aAllConfig; + if( aAllConfig.ReadSvIdl( SvHash_AllConfig(), rInStm ) ) + SetAllConfig( aAllConfig ), bOk = sal_True; + bOk |= aFastCall.ReadSvIdl( SvHash_FastCall(), rInStm ); + bOk |= aContainer.ReadSvIdl( SvHash_Container(), rInStm ); + bOk |= aImageRotation.ReadSvIdl( SvHash_ImageRotation(), rInStm ); + bOk |= aImageReflection.ReadSvIdl( SvHash_ImageReflection(), rInStm ); + bOk |= aUnoName.ReadSvIdl( SvHash_UnoName(), rInStm ); + + if( !bOk ) + { + if( !aSlotType.Is() ) + { + sal_uInt32 nTokPos = rInStm.Tell(); + SvToken * pTok = rInStm.GetToken_Next(); + if( pTok->Is( SvHash_SlotType() ) ) + { + sal_Bool bBraket = rInStm.Read( '(' ); + if( bBraket || rInStm.Read( '=' ) ) + { + aSlotType = rBase.ReadKnownType( rInStm ); + if( aSlotType.Is() ) + { + if( aSlotType->IsItem() ) + { + if( bBraket ) + { + if( rInStm.Read( ')' ) ) + return; + } + else + return; + } + rBase.SetError( "the SlotType is not a item", rInStm.GetToken() ); + rBase.WriteError( rInStm ); + } + rBase.SetError( "SlotType with unknown item type", rInStm.GetToken() ); + rBase.WriteError( rInStm ); + } + } + rInStm.Seek( nTokPos ); + + } + if( !aMethod.Is() ) + { + SvToken * pTok = rInStm.GetToken(); + if( pTok->IsIdentifier() ) + { + aMethod = new SvMetaSlot(); + sal_uInt32 nTokPos = rInStm.Tell(); + if( aMethod->ReadSvIdl( rBase, rInStm ) ) + { + if( aMethod->IsMethod() ) + { + aMethod->SetSlotId( GetSlotId() ); + if( aMethod->Test( rBase, rInStm ) ) + return; + } + rInStm.Seek( nTokPos ); + } + aMethod.Clear(); + } + } + } +} + +void SvMetaSlot::WriteAttributesSvIdl( SvIdlDataBase & rBase, + SvStream & rOutStm, + sal_uInt16 nTab ) +{ + SvMetaAttribute::WriteAttributesSvIdl( rBase, rOutStm, nTab ); + + if( aSlotType.Is() ) + { + WriteTab( rOutStm, nTab ); + rOutStm << SvHash_SlotType()->GetName().GetBuffer() << '('; + aSlotType->WriteTheType( rBase, rOutStm, nTab, WRITE_IDL ); + rOutStm << ");" << endl; + } + if( aMethod.Is() ) + { + WriteTab( rOutStm, nTab ); + aMethod->WriteSvIdl( rBase, rOutStm, nTab ); + rOutStm << ';' << endl; + } + if( aHasCoreId ) + { + aHasCoreId.WriteSvIdl( SvHash_HasCoreId(), rOutStm ); + rOutStm << ';' << endl; + } + if( aGroupId.Len() ) + { + WriteTab( rOutStm, nTab ); + aGroupId.WriteSvIdl( SvHash_GroupId(), rOutStm, nTab +1); + rOutStm << ';' << endl; + } + if( aExecMethod.Len() ) + { + WriteTab( rOutStm, nTab ); + aExecMethod.WriteSvIdl( SvHash_ExecMethod(), rOutStm, nTab +1); + rOutStm << ';' << endl; + } + if( aStateMethod.Len() ) + { + WriteTab( rOutStm, nTab ); + aStateMethod.WriteSvIdl( SvHash_StateMethod(), rOutStm, nTab +1); + rOutStm << ';' << endl; + } + + if( aDisableFlags.Len() ) + { + WriteTab( rOutStm, nTab ); + aDisableFlags.WriteSvIdl( SvHash_DisableFlags(), rOutStm, nTab +1); + rOutStm << ';' << endl; + } + + if( aSet || aGet || aPseudoSlots ) + { + WriteTab( rOutStm, nTab ); + char const * p = ""; + if( aPseudoSlots ) + { + aPseudoSlots.WriteSvIdl( SvHash_PseudoSlots(), rOutStm ); + p = ", "; + } + if( aGet ) + { + rOutStm << p; + aGet.WriteSvIdl( SvHash_Get(), rOutStm ); + p = ", "; + } + if( aSet ) + { + rOutStm << p; + aSet.WriteSvIdl( SvHash_Set(), rOutStm ); + } + rOutStm << ';' << endl; + } + + ByteString aDel( ", " ); + ByteString aOut; + if( aVolatile ) + aOut += aVolatile.GetSvIdlString( SvHash_Volatile() ); + else if( !aCachable ) + // because of Default == TRUE, only when no other is set + aOut += aCachable.GetSvIdlString( SvHash_Cachable() ); + else + aDel.Erase(); + + if( aToggle ) + { + ( aOut += aDel ) += aToggle.GetSvIdlString( SvHash_Toggle() ); + aDel = ", "; + } + if( aAutoUpdate ) + { + (aOut += aDel ) += aAutoUpdate.GetSvIdlString( SvHash_AutoUpdate() ); + aDel = ", "; + } + + ByteString aDel1( ", " ); + if( aAsynchron ) + ( aOut += aDel ) += aAsynchron.GetSvIdlString( SvHash_Asynchron() ); + else if( !aSynchron ) + // because of Default == TRUE, only when no other is set + ( aOut += aDel ) += aSynchron.GetSvIdlString( SvHash_Synchron() ); + else + aDel1 = aDel; + + aDel = ", "; + if( aRecordManual ) + ( aOut += aDel1 ) += aRecordManual.GetSvIdlString( SvHash_RecordManual() ); + else if( aNoRecord ) + ( aOut += aDel1 ) += aNoRecord.GetSvIdlString( SvHash_NoRecord() ); + else if( !aRecordPerSet ) + // because of Default == TRUE, only when no other is set + ( aOut += aDel1 ) += aRecordPerSet.GetSvIdlString( SvHash_RecordPerSet() ); + else if( aRecordPerItem ) + ( aOut += aDel1 ) += aRecordPerItem.GetSvIdlString( SvHash_RecordPerItem() ); + else + aDel = aDel1; + + if( aRecordAbsolute ) + { + ( aOut += aDel ) += aRecordAbsolute.GetSvIdlString( SvHash_RecordAbsolute() ); + aDel = ", "; + } + if( aHasDialog ) + { + ( aOut += aDel ) += aHasDialog.GetSvIdlString( SvHash_HasDialog() ); + aDel = ", "; + } + if( aMenuConfig ) + { + ( aOut += aDel ) += aMenuConfig.GetSvIdlString( SvHash_MenuConfig() ); + aDel = ", "; + } + if( aToolBoxConfig ) + { + ( aOut += aDel ) += aToolBoxConfig.GetSvIdlString( SvHash_ToolBoxConfig() ); + aDel = ", "; + } + if( aStatusBarConfig ) + { + ( aOut += aDel ) += aStatusBarConfig.GetSvIdlString( SvHash_StatusBarConfig() ); + aDel = ", "; + } + if( aAccelConfig ) + { + ( aOut += aDel ) += aAccelConfig.GetSvIdlString( SvHash_AccelConfig() ); + aDel = ", "; + } + if( aFastCall ) + { + ( aOut += aDel ) += aFastCall.GetSvIdlString( SvHash_FastCall() ); + aDel = ", "; + } + if( aContainer ) + { + ( aOut += aDel ) += aContainer.GetSvIdlString( SvHash_Container() ); + aDel = ", "; + } + if( aImageRotation ) + { + ( aOut += aDel ) += aImageRotation.GetSvIdlString( SvHash_ImageRotation() ); + aDel = ", "; + } + + if( aImageReflection ) + { + ( aOut += aDel ) += aImageReflection.GetSvIdlString( SvHash_ImageReflection() ); + aDel = ", "; + } + + if( aOut.Len() ) + { + WriteTab( rOutStm, nTab ); + rOutStm << aOut.GetBuffer() << endl; + } +} + + +sal_Bool SvMetaSlot::Test( SvIdlDataBase & rBase, SvTokenStream & rInStm ) +{ + sal_Bool bOk = SvMetaAttribute::Test( rBase, rInStm ); + if( bOk ) + { + SvMetaType * pType = GetType(); + if( pType->GetType() == TYPE_METHOD ) + pType = pType->GetReturnType(); + if( !pType->IsItem() ) + { + rBase.SetError( "this attribute is not a slot", rInStm.GetToken() ); + rBase.WriteError( rInStm ); + bOk = sal_False; + } + } + + return bOk; +} + +sal_Bool SvMetaSlot::ReadSvIdl( SvIdlDataBase & rBase, SvTokenStream & rInStm ) +{ + sal_uInt32 nTokPos = rInStm.Tell(); + sal_Bool bOk = sal_True; + + SvMetaAttribute * pAttr = rBase.ReadKnownAttr( rInStm, GetType() ); + if( pAttr ) + { + // c + SvMetaSlot * pKnownSlot = PTR_CAST( SvMetaSlot, pAttr ); + if( pKnownSlot ) + { + SetRef( pKnownSlot ); + SetName( pKnownSlot->GetName(), &rBase ); + bOk = SvMetaName::ReadSvIdl( rBase, rInStm ); + } + else + { + ByteString aStr( "attribute " ); + aStr += pAttr->GetName(); + aStr += " is method or variable but not a slot"; + rBase.SetError( aStr, rInStm.GetToken() ); + rBase.WriteError( rInStm ); + bOk = sal_False; + } + } + else + { + bOk = SvMetaAttribute::ReadSvIdl( rBase, rInStm ); + + SvMetaAttribute *pAttr2 = rBase.SearchKnownAttr( GetSlotId() ); + if( pAttr2 ) + { + // for testing purposes: reference in case of complete definition + SvMetaSlot * pKnownSlot = PTR_CAST( SvMetaSlot, pAttr2 ); + if( pKnownSlot ) + { + SetRef( pKnownSlot ); + + // names may differ, because explicitly given + if ( pKnownSlot->GetName() != GetName() ) + { + OSL_FAIL("Illegal definition!"); + rInStm.Seek( nTokPos ); + return sal_False; + } + + SetName( pKnownSlot->GetName(), &rBase ); + } + else + { + ByteString aStr( "attribute " ); + aStr += pAttr2->GetName(); + aStr += " is method or variable but not a slot"; + rBase.SetError( aStr, rInStm.GetToken() ); + rBase.WriteError( rInStm ); + bOk = sal_False; + } + } + } + + if( !bOk ) + rInStm.Seek( nTokPos ); + + return bOk; +} + +void SvMetaSlot::WriteSvIdl( SvIdlDataBase & rBase, SvStream & rOutStm, + sal_uInt16 nTab ) +{ + SvMetaAttribute::WriteSvIdl( rBase, rOutStm, nTab ); +} + +void SvMetaSlot::Write( SvIdlDataBase & rBase, + SvStream & rOutStm, sal_uInt16 nTab, + WriteType nT, WriteAttribute nA ) +{ + if ( nT == WRITE_DOCU ) + { + if ( GetHidden() ) + return; + } + else + { + // no attribute for Automation + if( !GetAutomation() || !GetExport() ) + return; + } + + if( !(nA & WA_VARIABLE) ) + { + SvMetaAttributeRef xM = GetMethod(); + if( xM.Is() ) + { + xM->SetSlotId( GetSlotId() ); + xM->SetDescription( GetDescription() ); + xM->Write( rBase, rOutStm, nTab, nT, nA ); + return; + } + } + + SvMetaAttribute::Write( rBase, rOutStm, nTab, nT, nA ); +} + + +void SvMetaSlot::Insert( SvSlotElementList& rList, const ByteString & rPrefix, + SvIdlDataBase& rBase) +{ + // get insert position through binary search in slotlist + sal_uInt16 nId = (sal_uInt16) GetSlotId().GetValue(); + sal_uInt16 nListCount = (sal_uInt16) rList.size(); + sal_uInt16 nPos; + sal_uLong m; // for inner "for" loop + + if ( !nListCount ) + nPos = 0; + else if ( nListCount == 1 ) + nPos = rList[ 0 ]->xSlot->GetSlotId().GetValue() >= nId ? 0 : 1; + else + { + sal_uInt16 nMid = 0, nLow = 0; + sal_uInt16 nHigh = nListCount - 1; + sal_Bool bFound = sal_False; + while ( !bFound && nLow <= nHigh ) + { + nMid = (nLow + nHigh) >> 1; + DBG_ASSERT( nMid < nListCount, "bsearch ist buggy" ); + int nDiff = (int) nId - (int) rList[ nMid ]->xSlot->GetSlotId().GetValue(); + if ( nDiff < 0) + { + if ( nMid == 0 ) + break; + nHigh = nMid - 1; + } + else if ( nDiff > 0 ) + { + nLow = nMid + 1; + if ( nLow == 0 ) + break; + } + else + bFound = sal_True; + } + + DBG_ASSERT(!bFound, "Duplicate SlotId!"); + nPos = bFound ? nMid : nLow; + } + + DBG_ASSERT( nPos <= nListCount, + "nPos too large" ); + DBG_ASSERT( nPos == nListCount || nId <= + (sal_uInt16) rList[ nPos ]->xSlot->GetSlotId().GetValue(), + "Successor has lower SlotId" ); + DBG_ASSERT( nPos == 0 || nId > + (sal_uInt16) rList[ nPos-1 ]->xSlot->GetSlotId().GetValue(), + "Predecessor has higher SlotId" ); + DBG_ASSERT( nPos+1 >= nListCount || nId < + (sal_uInt16) rList[ nPos+1 ]->xSlot->GetSlotId().GetValue(), + "Successor has lower SlotId" ); + + if ( nPos < rList.size() ) + { + SvSlotElementList::iterator it = rList.begin(); + std::advance( it, nPos ); + rList.insert( it, new SvSlotElement( this, rPrefix ) ); + } + else + { + rList.push_back( new SvSlotElement( this, rPrefix ) ); + } + + // iron out EnumSlots + SvMetaTypeEnum * pEnum = NULL; + SvMetaType * pBType = GetType()->GetBaseType(); + pEnum = PTR_CAST( SvMetaTypeEnum, pBType ); + if( GetPseudoSlots() && pEnum && pEnum->Count() ) + { + // clone the MasterSlot + SvMetaSlotRef xEnumSlot; + SvMetaSlot *pFirstEnumSlot = NULL; + for( sal_uLong n = 0; n < pEnum->Count(); n++ ) + { + // create SlotId + SvMetaEnumValue *enumValue = pEnum->GetObject(n); + ByteString aValName = enumValue->GetName(); + ByteString aSId( GetSlotId() ); + if( GetPseudoPrefix().Len() ) + aSId = GetPseudoPrefix(); + aSId += '_'; + aSId += aValName.Copy( pEnum->GetPrefix().Len() ); + + xEnumSlot = NULL; + for( m=0; m<rBase.GetAttrList().Count(); m++ ) + { + SvMetaAttribute * pAttr = rBase.GetAttrList().GetObject( m ); + if( pAttr->GetSlotId() == aSId ) + { + SvMetaSlot* pSlot = PTR_CAST( SvMetaSlot, pAttr ); + xEnumSlot = pSlot->Clone(); + break; + } + } + + if ( m == rBase.GetAttrList().Count() ) + { + OSL_FAIL("Invalid EnumSlot!"); + xEnumSlot = Clone(); + sal_uLong nValue; + if ( rBase.FindId(aSId , &nValue) ) + { + SvNumberIdentifier aId; + *((SvIdentifier*)&aId) = aSId; + aId.SetValue(nValue); + xEnumSlot->SetSlotId(aId); + } + } + + // The slaves are no master! + xEnumSlot->aPseudoSlots = sal_False; + xEnumSlot->SetEnumValue(enumValue); + + if ( !pFirstEnumSlot || xEnumSlot->GetSlotId().GetValue() < pFirstEnumSlot->GetSlotId().GetValue() ) + pFirstEnumSlot = xEnumSlot; + + // insert the created slave as well + xEnumSlot->Insert( rList, rPrefix, rBase); + + // concatenate the EnumSlots with the master + xEnumSlot->pLinkedSlot = this; + } + + // master points to the first slave + pLinkedSlot = pFirstEnumSlot; + + // concatenate slaves among themselves + xEnumSlot = pFirstEnumSlot; + size_t i = 0; + SvSlotElement *pEle; + do + { + pEle = ( ++i < rList.size() ) ? rList[ i ] : NULL; + if ( pEle && pEle->xSlot->pLinkedSlot == this ) + { + xEnumSlot->pNextSlot = pEle->xSlot; + xEnumSlot = pEle->xSlot; + } + } + while ( pEle ); + xEnumSlot->pNextSlot = pFirstEnumSlot; + } +} + + +static ByteString MakeSlotName( SvStringHashEntry * pEntry ) +{ + ByteString aName( "SFX_SLOT_" ); + aName += pEntry->GetName(); + return aName.ToUpperAscii(); +}; + +void SvMetaSlot::WriteSlotStubs( const ByteString & rShellName, + ByteStringList & rList, + SvStream & rOutStm ) +{ + if ( !GetExport() && !GetHidden() ) + return; + + ByteString aMethodName( GetExecMethod() ); + if ( aMethodName.Len() && aMethodName != "NoExec" ) + { + sal_Bool bIn = sal_False; + for( size_t n = 0; n < rList.size(); n++ ) + { + if( *(rList[ n ]) == aMethodName ) + { + bIn=sal_True; + break; + } + } + + if ( !bIn ) + { + rList.push_back( new ByteString(aMethodName) ); + rOutStm << "SFX_EXEC_STUB(" + << rShellName.GetBuffer() + << ',' + << aMethodName.GetBuffer() + << ')' << endl; + } + } + + aMethodName = GetStateMethod(); + if ( aMethodName.Len() && aMethodName != "NoState" ) + { + sal_Bool bIn = sal_False; + for ( size_t n=0; n < rList.size(); n++ ) + { + if ( *(rList[ n ]) == aMethodName ) + { + bIn=sal_True; + break; + } + } + + if ( !bIn ) + { + rList.push_back( new ByteString(aMethodName) ); + rOutStm << "SFX_STATE_STUB(" + << rShellName.GetBuffer() + << ',' + << aMethodName.GetBuffer() + << ')' << endl; + } + } +} + +void SvMetaSlot::WriteSlot( const ByteString & rShellName, sal_uInt16 nCount, + const ByteString & rSlotId, + SvSlotElementList& rSlotList, + size_t nStart, + const ByteString & rPrefix, + SvIdlDataBase & rBase, SvStream & rOutStm ) +{ + if ( !GetExport() && !GetHidden() ) + return; + + sal_Bool bIsEnumSlot = 0 != pEnumValue; + + rOutStm << "// Slot Nr. " + << rtl::OString::valueOf(static_cast<sal_Int32>(nListPos)).getStr() + << " : "; + ByteString aSlotIdValue(rtl::OString::valueOf(static_cast<sal_Int32>( + GetSlotId().GetValue()))); + rOutStm << aSlotIdValue.GetBuffer() << endl; + WriteTab( rOutStm, 1 ); + if( bIsEnumSlot ) + rOutStm << "SFX_NEW_SLOT_ENUM( "; + else + rOutStm << "SFX_NEW_SLOT_ARG( " << rShellName.GetBuffer() << ',' ; + + rOutStm << rSlotId.GetBuffer() << ','; + const SvHelpContext& rHlpCtx = GetHelpContext(); + if( rHlpCtx.IsSet() ) + rOutStm << rHlpCtx.GetBuffer() << ','; + else + rOutStm << rSlotId.GetBuffer() << ','; + + // GroupId + if( GetGroupId().Len() ) + rOutStm << GetGroupId().GetBuffer(); + else + rOutStm << '0'; + rOutStm << ',' << endl; + WriteTab( rOutStm, 4 ); + + if( bIsEnumSlot ) + { + rOutStm << "&a" << rShellName.GetBuffer() << "Slots_Impl[" + << rtl::OString::valueOf(static_cast<sal_Int32>(pLinkedSlot->GetListPos())).getStr() + << "] /*Offset Master*/, " << endl; + WriteTab( rOutStm, 4 ); + rOutStm << "&a" << rShellName.GetBuffer() << "Slots_Impl[" + << rtl::OString::valueOf(static_cast<sal_Int32>(pNextSlot->GetListPos())).getStr() + << "] /*Offset Next*/, " << endl; + + WriteTab( rOutStm, 4 ); + + // SlotId + if( GetSlotId().Len() ) + rOutStm << pLinkedSlot->GetSlotId().GetBuffer(); + else + rOutStm << '0'; + rOutStm << ','; + rOutStm << pEnumValue->GetName().GetBuffer(); + } + else + { + // look for the next slot with the same StateMethod like me + // the slotlist is set to the current slot + size_t i = nStart; + SvSlotElement* pEle = ( ++i < rSlotList.size() ) ? rSlotList[ i ] : NULL; + pNextSlot = pEle ? &pEle->xSlot : NULL; + while ( pNextSlot ) + { + if ( !pNextSlot->pNextSlot && + pNextSlot->GetStateMethod() == GetStateMethod() + ) { + break; + } + pEle = ( ++i < rSlotList.size() ) ? rSlotList[ i ] : NULL; + pNextSlot = pEle ? &pEle->xSlot : NULL; + } + + if ( !pNextSlot ) + { + // There is no slot behind me that has the same ExecMethod. + // So I search for the first slot with it (could be myself). + i = 0; + pEle = rSlotList.empty() ? NULL : rSlotList[ i ]; + pNextSlot = pEle ? &pEle->xSlot : NULL; + while ( pNextSlot != this ) + { + if ( !pNextSlot->pEnumValue && + pNextSlot->GetStateMethod() == GetStateMethod() ) + break; + pEle = ( ++i < rSlotList.size() ) ? rSlotList[ i ] : NULL; + pNextSlot = pEle ? &pEle->xSlot : NULL; + } + } + + if ( !pLinkedSlot ) + { + rOutStm << "0 ,"; + } + else + { + rOutStm << "&a" << rShellName.GetBuffer() << "Slots_Impl[" + << rtl::OString::valueOf(static_cast<sal_Int32>(pLinkedSlot->GetListPos())).getStr() + << "] /*Offset Linked*/, " << endl; + WriteTab( rOutStm, 4 ); + } + + rOutStm << "&a" << rShellName.GetBuffer() << "Slots_Impl[" + << rtl::OString::valueOf(static_cast<sal_Int32>(pNextSlot->GetListPos())).getStr() + << "] /*Offset Next*/, " << endl; + + WriteTab( rOutStm, 4 ); + + // write ExecMethod, with standard name if not specified + if( GetExecMethod().Len() && GetExecMethod() != "NoExec") + rOutStm << "SFX_STUB_PTR(" << rShellName.GetBuffer() << ',' + << GetExecMethod().GetBuffer() << ')'; + else + rOutStm << "SFX_STUB_PTR_EXEC_NONE"; + rOutStm << ','; + + // write StateMethod, with standard name if not specified + if( GetStateMethod().Len() && GetStateMethod() != "NoState") + rOutStm << "SFX_STUB_PTR(" << rShellName.GetBuffer() << ',' + << GetStateMethod().GetBuffer() << ')'; + else + rOutStm << "SFX_STUB_PTR_STATE_NONE"; + } + rOutStm << ',' << endl; + WriteTab( rOutStm, 4 ); + + // write flags + if( GetHasCoreId() ) + rOutStm << MakeSlotName( SvHash_HasCoreId() ).GetBuffer() << '|'; + if( GetCachable() ) + rOutStm << MakeSlotName( SvHash_Cachable() ).GetBuffer() << '|'; + if( GetVolatile() ) + rOutStm << MakeSlotName( SvHash_Volatile() ).GetBuffer() << '|'; + if( GetToggle() ) + rOutStm << MakeSlotName( SvHash_Toggle() ).GetBuffer() << '|'; + if( GetAutoUpdate() ) + rOutStm << MakeSlotName( SvHash_AutoUpdate() ).GetBuffer() << '|'; + if( GetSynchron() ) + rOutStm << MakeSlotName( SvHash_Synchron() ).GetBuffer() << '|'; + if( GetAsynchron() ) + rOutStm << MakeSlotName( SvHash_Asynchron() ).GetBuffer() << '|'; + if( GetRecordPerItem() ) + rOutStm << MakeSlotName( SvHash_RecordPerItem() ).GetBuffer() << '|'; + if( GetRecordPerSet() ) + rOutStm << MakeSlotName( SvHash_RecordPerSet() ).GetBuffer() << '|'; + if( GetRecordManual() ) + rOutStm << MakeSlotName( SvHash_RecordManual() ).GetBuffer() << '|'; + if( GetNoRecord() ) + rOutStm << MakeSlotName( SvHash_NoRecord() ).GetBuffer() << '|'; + if( GetRecordAbsolute() ) + rOutStm << MakeSlotName( SvHash_RecordAbsolute() ).GetBuffer() << '|'; + if( GetHasDialog() ) + rOutStm << MakeSlotName( SvHash_HasDialog() ).GetBuffer() << '|'; + if( GetMenuConfig() ) + rOutStm << MakeSlotName( SvHash_MenuConfig() ).GetBuffer() << '|'; + if( GetToolBoxConfig() ) + rOutStm << MakeSlotName( SvHash_ToolBoxConfig() ).GetBuffer() << '|'; + if( GetStatusBarConfig() ) + rOutStm << MakeSlotName( SvHash_StatusBarConfig() ).GetBuffer() << '|'; + if( GetAccelConfig() ) + rOutStm << MakeSlotName( SvHash_AccelConfig() ).GetBuffer() << '|'; + if( GetFastCall() ) + rOutStm << MakeSlotName( SvHash_FastCall() ).GetBuffer() << '|'; + if( GetContainer() ) + rOutStm << MakeSlotName( SvHash_Container() ).GetBuffer() << '|'; + if ( GetReadOnlyDoc() ) + rOutStm << MakeSlotName( SvHash_ReadOnlyDoc() ).GetBuffer() << '|'; + if( GetImageRotation() ) + rOutStm << MakeSlotName( SvHash_ImageRotation() ).GetBuffer() << '|'; + if( GetImageReflection() ) + rOutStm << MakeSlotName( SvHash_ImageReflection() ).GetBuffer() << '|'; + rOutStm << '0'; + + rOutStm << ',' << endl; + WriteTab( rOutStm, 4 ); + if ( !GetDisableFlags().Len() ) + rOutStm << "0"; + else + rOutStm << GetDisableFlags().GetBuffer(); + + // write attribute type + if( !bIsEnumSlot ) + { + rOutStm << ',' << endl; + WriteTab( rOutStm, 4 ); + + SvMetaType * pT = GetSlotType(); + if( !pT ) + { + if( !IsVariable() ) + pT = rBase.FindType( "SfxVoidItem" ); + else + pT = GetType(); + } + if( pT ) + { + rOutStm << pT->GetName().GetBuffer(); + if( !rBase.FindType( pT, rBase.aUsedTypes ) ) + rBase.aUsedTypes.Append( pT ); + } + else + rOutStm << "SfxVoidItem not defined"; + } + else + { + SvMetaType *pT = rBase.FindType( "SfxBoolItem" ); + if ( pT && !rBase.FindType( pT, rBase.aUsedTypes ) ) + rBase.aUsedTypes.Append( pT ); + } + + if( !bIsEnumSlot ) + { + rOutStm << ',' << endl; + WriteTab( rOutStm, 4 ); + rOutStm + << rtl::OString::valueOf(static_cast<sal_Int32>(nCount)).getStr() + << "/*Offset*/, "; + + if( IsMethod() ) + { + SvMetaAttribute * pMethod = GetMethod(); + SvMetaType * pType; + if( pMethod ) + pType = pMethod->GetType(); + else + pType = GetType(); + sal_uLong nSCount = pType->GetAttrCount(); + rOutStm + << rtl::OString::valueOf(static_cast<sal_Int32>( + nSCount)).getStr() + << "/*Count*/"; + } + else + rOutStm << '0'; + + // name for recording + if ( GetExport() ) + { + rOutStm << ",\""; + if( rPrefix.Len() ) + rOutStm << rPrefix.GetBuffer(); + rOutStm << '.'; + if ( !IsVariable() || !GetType() || + GetType()->GetBaseType()->GetType() != TYPE_STRUCT ) + rOutStm << GetMangleName( sal_False ).GetBuffer(); + rOutStm << "\","; + } + else + rOutStm << ", 0, "; + + // Method/Property flags + if( IsMethod() ) + rOutStm << "SFX_SLOT_METHOD|"; + if( IsVariable() ) + { + rOutStm << "SFX_SLOT_PROPGET|"; + if( !GetReadonly() ) + rOutStm << "SFX_SLOT_PROPSET|"; + } + + rOutStm << '0'; + } + + { + rOutStm << ",\""; + rOutStm << GetMangleName( sal_False ).GetBuffer(); + rOutStm << "\""; + } + + rOutStm << " )," << endl; +} + +sal_uInt16 SvMetaSlot::WriteSlotParamArray( SvIdlDataBase & rBase, SvStream & rOutStm ) +{ + if ( !GetExport() && !GetHidden() ) + return 0; + + SvMetaAttribute * pMethod = GetMethod(); + if( IsMethod() ) + { + SvMetaType * pType; + if( pMethod ) + pType = pMethod->GetType(); + else + pType = GetType(); + + if( !rBase.FindType( pType, rBase.aUsedTypes ) ) + rBase.aUsedTypes.Append( pType ); + + const SvMetaAttributeMemberList & rList = + pType->GetAttrList(); + for( sal_uLong n = 0; n < rList.Count(); n++ ) + { + SvMetaAttribute * pPar = rList.GetObject( n ); + SvMetaType * pPType = pPar->GetType(); + WriteTab( rOutStm, 1 ); + rOutStm << "SFX_ARGUMENT(" + << pPar->GetSlotId().GetBuffer() << ',' // SlodId + // parameter name + << "\"" << pPar->GetName().GetBuffer() << "\"," + // item name + << pPType->GetName().GetBuffer() << ")," << endl; + if( !rBase.FindType( pPType, rBase.aUsedTypes ) ) + rBase.aUsedTypes.Append( pPType ); + } + return (sal_uInt16)rList.Count(); + } + return 0; +} + +sal_uInt16 SvMetaSlot::WriteSlotMap( const ByteString & rShellName, sal_uInt16 nCount, + SvSlotElementList& rSlotList, + size_t nStart, + const ByteString & rPrefix, + SvIdlDataBase & rBase, + SvStream & rOutStm ) +{ + // SlotId, if not specified generate from name + ByteString slotId = GetSlotId(); + + sal_uInt16 nSCount = 0; + if( IsMethod() ) + { + SvMetaType * pType; + SvMetaAttribute * pMethod = GetMethod(); + if( pMethod ) + pType = pMethod->GetType(); + else + pType = GetType(); + + nSCount = (sal_uInt16)pType->GetAttrCount(); + } + + WriteSlot( rShellName, nCount, slotId, rSlotList, nStart, rPrefix, rBase, rOutStm ); + return nSCount; +} + +void SvMetaSlot::WriteSrc( SvIdlDataBase & rBase, SvStream & rOutStm, + Table * pTable ) +{ + if (!GetToolBoxConfig() && !GetAccelConfig() && !GetMenuConfig() && !GetStatusBarConfig() ) + return; + + sal_uLong nSId = GetSlotId().GetValue(); + if( !pTable->IsKeyValid( nSId ) ) + { + pTable->Insert( nSId, this ); + rOutStm << "SfxSlotInfo " + << rtl::OString::valueOf(static_cast<sal_Int32>(nSId)).getStr() + << endl << '{' << endl; + + WriteTab( rOutStm, 1 ); + ByteString aStr = GetConfigName(); + if( !aStr.Len() ) + aStr = GetName(); + + rOutStm << "SlotName = \"" << aStr.GetBuffer() << "\";" << endl; + + aStr = GetHelpText(); + if( aStr.Len() ) + { + WriteTab( rOutStm, 1 ); + rOutStm << "HelpText = \"" << aStr.GetBuffer() << "\";" << endl; + } + + rOutStm << "};" << endl; + } + + SvMetaTypeEnum * pEnum = PTR_CAST( SvMetaTypeEnum, GetType() ); + if( GetPseudoSlots() && pEnum ) + { + for( sal_uLong n = 0; n < pEnum->Count(); n++ ) + { + ByteString aValName = pEnum->GetObject( n )->GetName(); + ByteString aSId( GetSlotId() ); + if( GetPseudoPrefix().Len() ) + aSId = GetPseudoPrefix(); + aSId += '_'; + aSId += aValName.Copy( pEnum->GetPrefix().Len() ); + + sal_uLong nSId2; + sal_Bool bIdOk = sal_False; + if( rBase.FindId( aSId, &nSId2 ) ) + { + aSId = rtl::OString::valueOf(static_cast<sal_Int32>(nSId2)); + bIdOk = sal_True; + } + + // if id not found, write always + if( !bIdOk || !pTable->IsKeyValid( nSId2 ) ) + { + pTable->Insert( nSId2, this ); + rOutStm << "SfxSlotInfo " << aSId.GetBuffer() + << endl << '{' << endl; + + WriteTab( rOutStm, 1 ); + rOutStm << "SlotName = \"" << aValName.GetBuffer() << "\";" << endl; + + ByteString aStr = GetHelpText(); + if( aStr.Len() ) + { + WriteTab( rOutStm, 1 ); + rOutStm << "HelpText = \"" << aStr.GetBuffer() << "\";" << endl; + } + rOutStm << "};" << endl; + } + } + } +} + +void SvMetaSlot::WriteHelpId( SvIdlDataBase & rBase, SvStream & rOutStm, + Table * pTable ) +{ + sal_uLong nSId = GetSlotId().GetValue(); + if( !pTable->IsKeyValid( nSId ) ) + { + pTable->Insert( nSId, this ); + rOutStm << "#define " << GetSlotId().GetBuffer() << '\t' + << rtl::OString::valueOf(static_cast<sal_Int32>(nSId)).getStr() + << endl; + } + + SvMetaTypeEnum * pEnum = PTR_CAST( SvMetaTypeEnum, GetType() ); + if( GetPseudoSlots() && pEnum ) + { + for( sal_uLong n = 0; n < pEnum->Count(); n++ ) + { + ByteString aValName = pEnum->GetObject( n )->GetName(); + ByteString aSId( GetSlotId() ); + if( GetPseudoPrefix().Len() ) + aSId = GetPseudoPrefix(); + aSId += '_'; + aSId += aValName.Copy( pEnum->GetPrefix().Len() ); + + sal_uLong nSId2; + sal_Bool bIdOk = sal_False; + if( rBase.FindId( aSId, &nSId2 ) ) + { + aSId = rtl::OString::valueOf(static_cast<sal_Int32>(nSId2)); + bIdOk = sal_True; + } + + // if id not found, write always + if( !bIdOk || !pTable->IsKeyValid( nSId2 ) ) + { + pTable->Insert( nSId2, this ); + + rOutStm << "#define " << aSId.GetBuffer() << '\t' + << rtl::OString::valueOf( + static_cast<sal_Int32>(nSId2)).getStr() + << endl; + } + } + } +} + +void WriteBool( sal_Bool bSet, SvStream& rStream ) +{ + if ( bSet ) + rStream << "TRUE" << ','; + else + rStream << "FALSE" << ','; +} + +void SvMetaSlot::WriteCSV( SvIdlDataBase& rBase, SvStream& rStrm ) +{ + rStrm << "PROJECT,"; + rStrm << GetSlotId().GetBuffer() << ','; + rStrm + << rtl::OString::valueOf( + static_cast<sal_Int32>(GetSlotId().GetValue())).getStr() + << ','; + + if ( GetPseudoPrefix().Len() ) + rStrm << GetPseudoPrefix().GetBuffer() << ','; + else + rStrm << ','; + + rStrm << GetGroupId().GetBuffer() << ','; + + WriteBool( GetAccelConfig(), rStrm ); + WriteBool( GetMenuConfig(), rStrm ); + WriteBool( GetStatusBarConfig(), rStrm ); + WriteBool( GetToolBoxConfig(), rStrm ); + + if ( GetSlotType() ) + rStrm << GetSlotType()->GetName().GetBuffer() << ','; + else + rStrm << ','; + + WriteBool( GetAutoUpdate(), rStrm ); + if ( GetCachable() ) + rStrm << "Cachable" << ','; + else + rStrm << "Volatile" << ','; + + WriteBool( GetContainer(), rStrm ); + WriteBool( GetFastCall(), rStrm ); + WriteBool( GetHasCoreId(), rStrm ); + WriteBool( GetHasDialog(), rStrm ); + WriteBool( GetReadOnlyDoc(), rStrm ); + WriteBool( GetImageRotation(), rStrm ); + WriteBool( GetImageReflection(), rStrm ); + rStrm << GetDisableFlags().GetBuffer() << ','; + + if( GetSynchron() ) + rStrm << "Synchron" << ','; + else + rStrm << "Asynchron" << ','; + + WriteBool( GetToggle(), rStrm ); + WriteBool( GetReadonly(), rStrm ); + WriteBool( GetExport(), rStrm ); + if( GetRecordPerItem() ) + rStrm << "RecordPerItem" << ','; + else if ( GetNoRecord() ) + rStrm << "NoRecord" << ','; + else if ( GetRecordManual() ) + rStrm << "RecordManual" << ','; + else + rStrm << "RecordPerSet" << ','; + + WriteBool( GetRecordAbsolute(), rStrm ); + + if ( GetType()->GetType() != TYPE_METHOD && GetMethod() ) + { + rStrm << GetMethod()->GetType()->GetReturnType()->GetName().GetBuffer() << ','; + rStrm << GetMethod()->GetName().GetBuffer() << ','; + } + else + { + rStrm << ",,"; + } + + rStrm << GetType()->GetSvName().GetBuffer() << ','; + rStrm << GetName().GetBuffer() << ','; + + if ( GetType()->GetType() == TYPE_METHOD || GetMethod() ) + { + SvMetaAttributeMemberList *pList = &GetType()->GetAttrList(); + if ( GetMethod() ) + pList = &GetMethod()->GetType()->GetAttrList(); + + if( pList && pList->Count() ) + { + rStrm << "\"("; + SvMetaAttribute* pAttr = pList->First(); + while( pAttr ) + { + pAttr->WriteCSV( rBase, rStrm ); + pAttr = pList->Next(); + if( pAttr ) + rStrm << ','; + } + rStrm << ")\""; + } + else + rStrm << "()"; + } + + rStrm << endl; +} + +#endif // IDL_COMPILER + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/idl/source/objects/types.cxx b/idl/source/objects/types.cxx new file mode 100644 index 000000000000..d57d3cb0e33f --- /dev/null +++ b/idl/source/objects/types.cxx @@ -0,0 +1,2050 @@ +/* -*- 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_idl.hxx" + +#include <ctype.h> +#include <stdio.h> + +#include <tools/debug.hxx> + +#include <types.hxx> +#include <globals.hxx> +#include <database.hxx> + +SV_IMPL_META_FACTORY1( SvMetaAttribute, SvMetaReference ); +SvMetaAttribute::SvMetaAttribute() + : aAutomation( sal_True, sal_False ) + , aExport( sal_True, sal_False ) + , aIsCollection ( sal_False, sal_False ) + , aReadOnlyDoc ( sal_True, sal_False ) + , aHidden( sal_False, sal_False ) + , bNewAttr( sal_False ) +{ +} + +SvMetaAttribute::SvMetaAttribute( SvMetaType * pType ) + : aType( pType ) + , aAutomation( sal_True, sal_False ) + , aExport( sal_True, sal_False ) + , aIsCollection ( sal_False, sal_False) + , aReadOnlyDoc ( sal_True, sal_False) + , aHidden( sal_False, sal_False ) + , bNewAttr( sal_False ) +{ +} + +void SvMetaAttribute::Load( SvPersistStream & rStm ) +{ + SvMetaReference::Load( rStm ); + + sal_uInt8 nMask; + rStm >> nMask; + if( nMask & 0x01 ) + { + SvMetaType * pType; + rStm >> pType; + aType = pType; + } + if( nMask & 0x02 ) rStm >> aSlotId; + if( nMask & 0x04 ) rStm >> aExport; + if( nMask & 0x08 ) rStm >> aReadonly; + if( nMask & 0x10 ) rStm >> aAutomation; + if( nMask & 0x20 ) rStm >> aIsCollection; + if( nMask & 0x40 ) rStm >> aReadOnlyDoc; + if( nMask & 0x80 ) rStm >> aHidden; +} + +void SvMetaAttribute::Save( SvPersistStream & rStm ) +{ + SvMetaReference::Save( rStm ); + + // create mask + sal_uInt8 nMask = 0; + if( aType.Is() ) nMask |= 0x1; + if( aSlotId.IsSet() ) nMask |= 0x2; + if( aExport.IsSet() ) nMask |= 0x4; + if( aReadonly.IsSet() ) nMask |= 0x8; + if( aAutomation.IsSet() ) nMask |= 0x10; + if( aIsCollection.IsSet() ) nMask |= 0x20; + if( aReadOnlyDoc.IsSet() ) nMask |= 0x40; + if( aHidden.IsSet() ) nMask |= 0x80; + + // write data + rStm << nMask; + if( nMask & 0x1 ) rStm << aType; + if( nMask & 0x2 ) rStm << aSlotId; + if( nMask & 0x4 ) rStm << aExport; + if( nMask & 0x8 ) rStm << aReadonly; + if( nMask & 0x10 ) rStm << aAutomation; + if( nMask & 0x20 ) rStm << aIsCollection; + if( nMask & 0x40 ) rStm << aReadOnlyDoc; + if( nMask & 0x80 ) rStm << aHidden; +} + +SvMetaType * SvMetaAttribute::GetType() const +{ + if( aType.Is() || !GetRef() ) return aType; + return ((SvMetaAttribute *)GetRef())->GetType(); +} + +const SvNumberIdentifier & SvMetaAttribute::GetSlotId() const +{ + if( aSlotId.IsSet() || !GetRef() ) return aSlotId; + return ((SvMetaAttribute *)GetRef())->GetSlotId(); +} + +sal_Bool SvMetaAttribute::GetReadonly() const +{ + if( aReadonly.IsSet() || !GetRef() ) return aReadonly; + return ((SvMetaAttribute *)GetRef())->GetReadonly(); +} + +sal_Bool SvMetaAttribute::GetExport() const +{ + if( aExport.IsSet() || !GetRef() ) return aExport; + return ((SvMetaAttribute *)GetRef())->GetExport(); +} + +sal_Bool SvMetaAttribute::GetHidden() const +{ + // when export is set, but hidden is not the default is used + if ( aExport.IsSet() && !aHidden.IsSet() ) + return !aExport; + else if( aHidden.IsSet() || !GetRef() ) + return aHidden; + else + return ((SvMetaAttribute *)GetRef())->GetHidden(); +} + +sal_Bool SvMetaAttribute::GetAutomation() const +{ + if( aAutomation.IsSet() || !GetRef() ) return aAutomation; + return ((SvMetaAttribute *)GetRef())->GetAutomation(); +} + +sal_Bool SvMetaAttribute::GetIsCollection() const +{ + sal_Bool bRet; + if( aIsCollection.IsSet() || !GetRef() ) + { + if ( aIsCollection.IsSet() ) + { + bRet = aIsCollection; + return bRet; + } + + return aIsCollection; + } + + return ((SvMetaSlot *)GetRef())->GetIsCollection(); +} + +sal_Bool SvMetaAttribute::GetReadOnlyDoc() const +{ + if( aReadOnlyDoc.IsSet() || !GetRef() ) return aReadOnlyDoc; + return ((SvMetaSlot *)GetRef())->GetReadOnlyDoc(); +} + +sal_Bool SvMetaAttribute::IsMethod() const +{ + SvMetaType * pType = GetType(); + DBG_ASSERT( pType, "no type for attribute" ); + return pType->GetType() == TYPE_METHOD; +} + +sal_Bool SvMetaAttribute::IsVariable() const +{ + SvMetaType * pType = GetType(); + return pType->GetType() != TYPE_METHOD; +} + +ByteString SvMetaAttribute::GetMangleName( sal_Bool ) const +{ + return GetName(); +} + +#ifdef IDL_COMPILER +sal_Bool SvMetaAttribute::Test( SvIdlDataBase & rBase, + SvTokenStream & rInStm ) +{ + sal_Bool bOk = sal_True; + if( GetType()->IsItem() && !GetSlotId().IsSet() ) + { + rBase.SetError( "slot without id declared", rInStm.GetToken() ); + rBase.WriteError( rInStm ); + bOk = sal_False; + } + return bOk; +} + +sal_Bool SvMetaAttribute::ReadSvIdl( SvIdlDataBase & rBase, + SvTokenStream & rInStm ) +{ + sal_uInt32 nTokPos = rInStm.Tell(); + if( !GetType() ) + // no type in ctor passed on + aType = rBase.ReadKnownType( rInStm ); + sal_Bool bOk = sal_False; + if( GetType() ) + { + ReadNameSvIdl( rBase, rInStm ); + aSlotId.ReadSvIdl( rBase, rInStm ); + + bOk = sal_True; + SvToken * pTok = rInStm.GetToken(); + if( bOk && pTok->IsChar() && pTok->GetChar() == '(' ) + { + SvMetaTypeRef xT = new SvMetaType(); + xT->SetRef( GetType() ); + aType = xT; + bOk = aType->ReadMethodArgs( rBase, rInStm ); + } + if( bOk ) + bOk = SvMetaName::ReadSvIdl( rBase, rInStm ); + } + else + rBase.SetError( "unknown type", rInStm.GetToken() ); + + if( !bOk ) + rInStm.Seek( nTokPos ); + return bOk; +} + +void SvMetaAttribute::WriteSvIdl +( + SvIdlDataBase & rBase, + SvStream & rOutStm, + sal_uInt16 nTab +) +{ + SvMetaType * pType = GetType(); + pType->WriteTypePrefix( rBase, rOutStm, nTab, WRITE_IDL ); + rOutStm << ' ' << GetName().GetBuffer(); + if( aSlotId.IsSet() ) + rOutStm << ' ' << aSlotId.GetBuffer(); + if( pType->GetType() == TYPE_METHOD ) + pType->WriteMethodArgs( rBase, rOutStm, nTab, WRITE_IDL ); + sal_uLong nPos = rOutStm.Tell(); + rOutStm << endl; + SvMetaName::WriteSvIdl( rBase, rOutStm, nTab ); + TestAndSeekSpaceOnly( rOutStm, nPos ); +} + +void SvMetaAttribute::ReadAttributesSvIdl( SvIdlDataBase & rBase, + SvTokenStream & rInStm ) +{ + SvMetaReference::ReadAttributesSvIdl( rBase, rInStm ); + aSlotId.ReadSvIdl( rBase, SvHash_SlotId(), rInStm ); + aExport.ReadSvIdl( SvHash_Export(), rInStm ); + aHidden.ReadSvIdl( SvHash_Hidden(), rInStm ); + aAutomation.ReadSvIdl( SvHash_Automation(), rInStm ); + aIsCollection.ReadSvIdl( SvHash_IsCollection(), rInStm ); + aReadOnlyDoc.ReadSvIdl( SvHash_ReadOnlyDoc(), rInStm ); + if( aReadonly.ReadSvIdl( SvHash_Readonly(), rInStm ) ) + { + if( GetType()->GetType() == TYPE_METHOD ) + { + // set error + rBase.SetError( "Readonly in function attribute", rInStm.GetToken() ); + rBase.WriteError( rInStm ); + } + } +} + +void SvMetaAttribute::WriteAttributesSvIdl +( + SvIdlDataBase & rBase, + SvStream & rOutStm, + sal_uInt16 nTab +) +{ + SvMetaReference::WriteAttributesSvIdl( rBase, rOutStm, nTab ); + + if( !aExport || !aAutomation || aReadonly ) + { + WriteTab( rOutStm, nTab ); + rOutStm << "//class SvMetaAttribute" << endl; + if( !aExport ) + { + WriteTab( rOutStm, nTab ); + aExport.WriteSvIdl( SvHash_Export(), rOutStm ); + rOutStm << ';' << endl; + } + if ( aHidden != aExport ) + { + WriteTab( rOutStm, nTab ); + aExport.WriteSvIdl( SvHash_Hidden(), rOutStm ); + rOutStm << ';' << endl; + } + if( aReadonly ) + { + WriteTab( rOutStm, nTab ); + aReadonly.WriteSvIdl( SvHash_Readonly(), rOutStm ); + rOutStm << ';' << endl; + } + if( !aAutomation ) + { + WriteTab( rOutStm, nTab ); + aAutomation.WriteSvIdl( SvHash_Automation(), rOutStm ); + rOutStm << ';' << endl; + } + if( aIsCollection ) + { + WriteTab( rOutStm, nTab ); + aIsCollection.WriteSvIdl( SvHash_IsCollection(), rOutStm ); + rOutStm << ';' << endl; + } + if( !aReadOnlyDoc ) + { + WriteTab( rOutStm, nTab ); + aReadOnlyDoc.WriteSvIdl( SvHash_ReadOnlyDoc(), rOutStm ); + rOutStm << ';' << endl; + } + } +} + +void SvMetaAttribute::WriteParam( SvIdlDataBase & rBase, + SvStream & rOutStm, + sal_uInt16 nTab, + WriteType nT ) +{ + SvMetaType * pType = GetType(); + DBG_ASSERT( pType, "no type for attribute" ); + SvMetaType * pBaseType = pType->GetBaseType(); + DBG_ASSERT( pBaseType, "no base type for attribute" ); + + if( nT == WRITE_ODL || nT == WRITE_DOCU + || nT == WRITE_C_HEADER || nT == WRITE_C_SOURCE ) + { + if( pBaseType->GetType() == TYPE_STRUCT ) + { + const SvMetaAttributeMemberList & rList = pBaseType->GetAttrList(); + sal_uLong nCount = rList.Count(); + for( sal_uLong i = 0; i < nCount; i++ ) + { + rList.GetObject( i )->WriteParam( rBase, rOutStm, nTab, nT ); + if( i+1<nCount ) + { + rOutStm << ','; + } + } + } + else + { + if ( nT != WRITE_DOCU ) + { + WriteTab( rOutStm, nTab ); + pBaseType->WriteTypePrefix( rBase, rOutStm, nTab, nT ); + } + + if( GetName().Len() ) + { + rOutStm << ' '; + rOutStm << GetName().GetBuffer(); + } + + if ( nT == WRITE_DOCU ) + { + if( pBaseType->GetType() == TYPE_METHOD || + pBaseType->GetType() == TYPE_STRUCT || + pBaseType->GetType() == TYPE_ENUM ) + { + OSL_FAIL( "Falscher Parametertyp!" ); + } + else + rOutStm << pBaseType->GetBasicPostfix().GetBuffer(); + } + } + } +} + +sal_uLong SvMetaAttribute::MakeSlotValue( SvIdlDataBase & rBase, sal_Bool bVar ) const +{ + const SvNumberIdentifier & rId = GetSlotId(); + sal_uLong n = rId.GetValue(); + if( rBase.aStructSlotId.Len() ) + { + n = n << 20; + n += rBase.aStructSlotId.GetValue(); + } + if( PTR_CAST( SvMetaSlot, this ) ) + n |= 0x20000; + if( !bVar ) + n += 0x10000; + else if ( GetIsCollection() ) + n += 0x40000; + return n; +} + +void SvMetaAttribute::WriteAttributes( SvIdlDataBase & rBase, SvStream & rOutStm, + sal_uInt16 nTab, + WriteType nT, WriteAttribute nA ) +{ + if( nT == WRITE_ODL ) + { + const SvNumberIdentifier & rId = GetSlotId(); + sal_Bool bReadonly = GetReadonly() || ( nA & WA_READONLY ); + if( (rId.IsSet() && !(nA & WA_STRUCT)) || bReadonly ) + { + sal_Bool bVar = IsVariable(); + if( nA & WA_VARIABLE ) + bVar = sal_True; + else if( nA & WA_METHOD ) + bVar = sal_False; + + WriteTab( rOutStm, nTab ); + rOutStm << "//class SvMetaAttribute" << endl; + if( rId.IsSet() && !(nA & WA_STRUCT) ) + { + WriteTab( rOutStm, nTab ); + rOutStm << "id(" + << rtl::OString::valueOf(static_cast<sal_Int32>(MakeSlotValue(rBase,bVar))).getStr() + << ")," << endl; + } + if( bVar && (bReadonly || IsMethod()) ) + { + WriteTab( rOutStm, nTab ); + rOutStm << "readonly," << endl; + } + } + } +} + +void SvMetaAttribute::WriteCSource( SvIdlDataBase & rBase, SvStream & rOutStm, + sal_Bool bSet ) +{ + rOutStm << endl; + SvMetaType * pType = GetType(); + SvMetaType * pBaseType = pType->GetBaseType(); + + // for Set the return is always void + sal_Bool bVoid = bSet; + if( pBaseType->GetType() == TYPE_METHOD ) + bVoid = pBaseType->GetReturnType()->GetBaseType()->GetName() == "void"; + + // emit methods/functions body + rOutStm << '{' << endl; + WriteTab( rOutStm, 1 ); + + if( !bVoid ) + { + if ( pBaseType->GetCName() == "double" ) + { + rOutStm << "return *(double*)"; + } + else + { + rOutStm << "return ("; + pType->WriteTypePrefix( rBase, rOutStm, 2, WRITE_C_SOURCE ); + rOutStm << ") "; + } + } + rOutStm << "pODKCallFunction( " + << rtl::OString::valueOf(static_cast<sal_Int32>(MakeSlotValue(rBase, IsVariable()))).getStr(); + rOutStm << ',' << endl; + WriteTab( rOutStm, 3 ); + rOutStm << " h" << rBase.aIFaceName.GetBuffer() << " , "; + + ByteString aParserStr; + if( pBaseType->GetType() == TYPE_METHOD || bSet ) + aParserStr = pBaseType->GetParserString(); + if( aParserStr.Len() ) + { + rOutStm << '\"'; + rOutStm << aParserStr.GetBuffer(); + rOutStm << "\", "; + } + else + rOutStm << "NULL, "; + + if( pBaseType->GetType() == TYPE_METHOD && !bVoid ) + { + rOutStm << "'"; + rOutStm << pBaseType->GetReturnType()->GetBaseType()->GetParserChar(); + rOutStm << "'"; + } + else if ( !bSet ) + { + rOutStm << "'"; + rOutStm << pBaseType->GetParserChar(); + rOutStm << "'"; + } + else + rOutStm << '0'; + + if( aParserStr.Len() ) + { + rOutStm << ", "; + if( IsMethod() ) + pBaseType->WriteParamNames( rBase, rOutStm, ByteString() ); + else if( bSet ) + pBaseType->WriteParamNames( rBase, rOutStm, GetName() ); + } + + rOutStm << " );" << endl; + rOutStm << '}' << endl; +} + +void SvMetaAttribute::WriteRecursiv_Impl( SvIdlDataBase & rBase, + SvStream & rOutStm, sal_uInt16 nTab, + WriteType nT, WriteAttribute nA ) +{ + const SvMetaAttributeMemberList & rList = GetType()->GetBaseType()->GetAttrList(); + sal_uLong nCount = rList.Count(); + + SvNumberIdentifier slotId = rBase.aStructSlotId; + if ( GetSlotId().Len() ) + rBase.aStructSlotId = GetSlotId(); + + // offial hack interface by MM: special controls get passed with the WriteAttribute + if ( GetReadonly() ) + nA |= WA_READONLY; + + for( sal_uLong i = 0; i < nCount; i++ ) + { + SvMetaAttribute *pAttr = rList.GetObject( i ); + if ( nT == WRITE_DOCU ) + pAttr->SetDescription( GetDescription() ); + pAttr->Write( rBase, rOutStm, nTab, nT, nA ); + if( nT == WRITE_ODL && i +1 < nCount ) + rOutStm << ';' << endl; + } + + rBase.aStructSlotId = slotId; +} + +void SvMetaAttribute::Write( SvIdlDataBase & rBase, SvStream & rOutStm, + sal_uInt16 nTab, + WriteType nT, WriteAttribute nA ) +{ + // no attributes for automation + if( nT == WRITE_DOCU ) + { + if ( GetHidden() ) + return; + } + else if ( !GetAutomation() || !GetExport() ) + return; + + sal_Bool bVariable; + if( nA & WA_VARIABLE ) + bVariable = sal_True; + else if( nA & WA_METHOD ) + bVariable = sal_False; + else + bVariable = IsVariable(); + + SvMetaType * pType = GetType(); + DBG_ASSERT( pType, "no type for attribute" ); + SvMetaType * pBaseType = pType->GetBaseType(); + DBG_ASSERT( pBaseType, "no base type for attribute" ); + int nBType = pBaseType->GetType(); + + if( nT == WRITE_ODL ) + { + if( (bVariable && IsVariable()) || (!bVariable && IsMethod()) ) + { + if( nBType == TYPE_STRUCT ) + WriteRecursiv_Impl( rBase, rOutStm, nTab, nT, nA ); + else + { + SvMetaReference::Write( rBase, rOutStm, nTab, nT, nA ); + WriteTab( rOutStm, nTab ); + pBaseType->WriteTypePrefix( rBase, rOutStm, nTab, nT ); + + if( GetName().Len() ) + { + rOutStm << ' '; + rOutStm << GetName().GetBuffer(); + } + if( pType->GetType() == TYPE_METHOD ) + pType->WriteMethodArgs( rBase, rOutStm, nTab, nT ); + } + } + } + else if( nT == WRITE_C_HEADER || nT == WRITE_C_SOURCE ) + { + if( !bVariable && IsMethod() ) + { + ByteString name; + name += rBase.aIFaceName; + name += GetName(); + const char * pName = name.GetBuffer(); + WriteTab( rOutStm, nTab ); + pBaseType->WriteTypePrefix( rBase, rOutStm, nTab, nT ); + rOutStm << ' ' << pName; + pType->WriteMethodArgs( rBase, rOutStm, nTab, nT ); + if( nT == WRITE_C_HEADER ) + rOutStm << ';' << endl << endl; + else + WriteCSource( rBase, rOutStm, sal_False ); + } + else if ( bVariable && IsVariable() ) + { + if( nBType == TYPE_STRUCT ) + { + // for assistance emit the name of the property as acomment + rOutStm << "/* " << GetName().GetBuffer() << " */" << endl; + + WriteRecursiv_Impl( rBase, rOutStm, nTab, nT, nA ); + } + else + { + ByteString name = GetName(); + + sal_Bool bReadonly = GetReadonly() || ( nA & WA_READONLY ); + if ( !bReadonly && !IsMethod() ) + { + // allocation + WriteTab( rOutStm, nTab ); + rOutStm << "void "; + rOutStm << rBase.aIFaceName.GetBuffer() + << "Set" << name.GetBuffer() << "( " << C_PREF + << "Object h" << rBase.aIFaceName.GetBuffer() << ", " << endl; + WriteTab( rOutStm, nTab+1 ); + pBaseType->WriteTypePrefix( rBase, rOutStm, nTab, nT ); + rOutStm << ' ' << name.GetBuffer() << " )"; + if( nT == WRITE_C_HEADER ) + rOutStm << ';' << endl << endl; + else + WriteCSource( rBase, rOutStm, sal_True ); + } + + // access + WriteTab( rOutStm, nTab ); + pBaseType->WriteTypePrefix( rBase, rOutStm, nTab, nT ); + rOutStm << ' '; + rOutStm << rBase.aIFaceName.GetBuffer() + << "Get" << name.GetBuffer() << "( " << C_PREF + << "Object h" << rBase.aIFaceName.GetBuffer() << " )"; + if( nT == WRITE_C_HEADER ) + rOutStm << ';' << endl << endl; + else + WriteCSource( rBase, rOutStm, sal_False ); + } + } + } + else if ( nT == WRITE_DOCU ) + { + if( !bVariable && IsMethod() ) + { + rOutStm << "<METHOD>" << endl + << GetSlotId().GetBuffer() << endl + << GetName().GetBuffer() << endl + << endl; // readonly + + // return type + SvMetaType* pType2 = GetType(); + SvMetaType* pBaseType2 = pType2->GetBaseType(); + rOutStm << pBaseType2->GetReturnType()->GetBaseType()->GetBasicName().GetBuffer() << endl; + + DBG_ASSERT( pBaseType2->GetReturnType()->GetBaseType()->GetBasicName().Len(), + "Leerer BasicName" ); + + // syntax + rOutStm << GetName().GetBuffer(); + pType2->WriteMethodArgs( rBase, rOutStm, nTab, nT ); + + // C return type + pBaseType2->WriteTypePrefix( rBase, rOutStm, 0, WRITE_C_HEADER ); + rOutStm << endl; + + // for methods also C syntax + rOutStm << "<C-SYNTAX>" << endl; + Write( rBase, rOutStm, 0, WRITE_C_HEADER, nA ); + rOutStm << "</C-SYNTAX>" << endl; + + // description + WriteDescription( rOutStm ); + rOutStm << "</METHOD>" << endl << endl; + } + else if( bVariable && IsVariable() ) + { + if( nBType == TYPE_STRUCT ) + { + WriteRecursiv_Impl( rBase, rOutStm, nTab, nT, nA ); + } + else + { + rOutStm << "<PROPERTY>" << endl + << GetSlotId().GetBuffer() << endl + << GetName().GetBuffer() << endl; + if ( GetReadonly() ) + rOutStm << "(nur lesen)" << endl; + else + rOutStm << endl; + + // for properties type instead of the return value + rOutStm << pBaseType->GetBasicName().GetBuffer() << endl; + + DBG_ASSERT( pBaseType->GetBasicName().Len(), + "Leerer BasicName" ); + + // for properties no syntax + rOutStm << endl; + + // C return type + pBaseType->WriteTypePrefix( rBase, rOutStm, 0, WRITE_C_HEADER ); + rOutStm << endl; + + // description + WriteDescription( rOutStm ); + rOutStm << "</PROPERTY>" << endl << endl; + } + } + } +} + +sal_uLong SvMetaAttribute::MakeSfx( ByteString * pAttrArray ) +{ + SvMetaType * pType = GetType(); + DBG_ASSERT( pType, "no type for attribute" ); + SvMetaType * pBaseType = pType->GetBaseType(); + DBG_ASSERT( pBaseType, "no base type for attribute" ); + if( pBaseType->GetType() == TYPE_STRUCT ) + return pBaseType->MakeSfx( pAttrArray ); + else + { + *pAttrArray += '{'; + *pAttrArray += GetSlotId(); + *pAttrArray += ",\""; + *pAttrArray += GetName(); + *pAttrArray += "\"}"; + return 1; + } +} + +void SvMetaAttribute::Insert (SvSlotElementList&, const ByteString &, SvIdlDataBase&) +{ +} + +void SvMetaAttribute::WriteSrc( SvIdlDataBase &, SvStream &, Table * ) +{ +} + +void SvMetaAttribute::WriteHelpId( SvIdlDataBase &, SvStream &, Table * ) +{ +} + +#endif // IDL_COMPILER + +SV_IMPL_META_FACTORY1( SvMetaType, SvMetaExtern ); +#define CTOR \ + : aCall0( CALL_VALUE, sal_False ) \ + , aCall1( CALL_VALUE, sal_False ) \ + , aSbxDataType( 0, sal_False ) \ + , pAttrList( NULL ) \ + , nType( TYPE_BASE ) \ + , bIsItem( sal_False ) \ + , bIsShell( sal_False ) \ + , cParserChar( 'h' ) + +SvMetaType::SvMetaType() + CTOR +{ +} + +SvMetaType::SvMetaType( const ByteString & rName, char cPC, + const ByteString & rCName ) + CTOR +{ + SetName( rName ); + cParserChar = cPC; + aCName = rCName; +} + +SvMetaType::SvMetaType( const ByteString & rName, + const ByteString & rSbxName, + const ByteString & rOdlName, + char cPc, + const ByteString & rCName, + const ByteString & rBasicName, + const ByteString & rBasicPostfix ) + CTOR +{ + SetName( rName ); + aSbxName = rSbxName; + aOdlName = rOdlName; + cParserChar = cPc; + aCName = rCName; + aBasicName = rBasicName; + aBasicPostfix = rBasicPostfix; +} + +void SvMetaType::Load( SvPersistStream & rStm ) +{ + SvMetaExtern::Load( rStm ); + + sal_uInt16 nMask; + rStm >> nMask; + if( nMask & 0x0001 ) rStm >> aIn; + if( nMask & 0x0002 ) rStm >> aOut; + if( nMask & 0x0004 ) rStm >> aCall0; + if( nMask & 0x0008 ) rStm >> aCall1; + if( nMask & 0x0010 ) rStm >> aSbxDataType; + if( nMask & 0x0020 ) rStm >> aSvName; + if( nMask & 0x0040 ) rStm >> aSbxName; + if( nMask & 0x0080 ) rStm >> aOdlName; + if( nMask & 0x0100 ) rStm >> GetAttrList(); + if( nMask & 0x0200 ) bIsItem = sal_True; + if( nMask & 0x0400 ) bIsShell = sal_True; + if( nMask & 0x0800 ) + { + sal_uInt16 nT; + rStm >> nT; + nType = nT; + } + if( nMask & 0x1000 ) rStm >> cParserChar; + if( nMask & 0x2000 ) rStm >> aCName; + if( nMask & 0x4000 ) rStm >> aBasicName; + if( nMask & 0x8000 ) rStm >> aBasicPostfix; +} + +void SvMetaType::Save( SvPersistStream & rStm ) +{ + SvMetaExtern::Save( rStm ); + + // create mask + sal_uInt16 nMask = 0; + if( aIn.IsSet() ) nMask |= 0x0001; + if( aOut.IsSet() ) nMask |= 0x0002; + if( aCall0.IsSet() ) nMask |= 0x0004; + if( aCall1.IsSet() ) nMask |= 0x0008; + if( aSbxDataType.IsSet() ) nMask |= 0x0010; + if( aSvName.IsSet() ) nMask |= 0x0020; + if( aSbxName.IsSet() ) nMask |= 0x0040; + if( aOdlName.IsSet() ) nMask |= 0x0080; + if( GetAttrCount() ) nMask |= 0x0100; + if( bIsItem ) nMask |= 0x0200; + if( bIsShell ) nMask |= 0x0400; + if( nType != TYPE_BASE ) nMask |= 0x0800; + if( cParserChar != 'h' ) nMask |= 0x1000; + if( aCName.IsSet() ) nMask |= 0x2000; + if( aBasicName.IsSet() ) nMask |= 0x4000; + if( aBasicPostfix.IsSet() ) nMask |= 0x8000; + + // write data + rStm << nMask; + if( nMask & 0x0001 ) rStm << aIn; + if( nMask & 0x0002 ) rStm << aOut; + if( nMask & 0x0004 ) rStm << aCall0; + if( nMask & 0x0008 ) rStm << aCall1; + if( nMask & 0x0010 ) rStm << aSbxDataType; + if( nMask & 0x0020 ) rStm << aSvName; + if( nMask & 0x0040 ) rStm << aSbxName; + if( nMask & 0x0080 ) rStm << aOdlName; + if( nMask & 0x0100 ) rStm << *pAttrList; + if( nMask & 0x0800 ) rStm << (sal_uInt16)nType; + if( nMask & 0x1000 ) rStm << cParserChar; + if( nMask & 0x2000 ) rStm << aCName; + if( nMask & 0x4000 ) rStm << aBasicName; + if( nMask & 0x8000 ) rStm << aBasicPostfix; +} + +SvMetaAttributeMemberList & SvMetaType::GetAttrList() const +{ + if( !pAttrList ) + ((SvMetaType *)this)->pAttrList = new SvMetaAttributeMemberList(); + return *pAttrList; +} + +void SvMetaType::SetType( int nT ) +{ + nType = nT; + if( nType == TYPE_ENUM ) + { + aOdlName = "short"; + } + else if( nType == TYPE_CLASS ) + { + aCName = C_PREF; + aCName += "Object *"; + } +} + +SvMetaType * SvMetaType::GetBaseType() const +{ + if( GetRef() && GetType() == TYPE_BASE ) + return ((SvMetaType *)GetRef())->GetBaseType(); + return (SvMetaType *)this; +} + +SvMetaType * SvMetaType::GetReturnType() const +{ + DBG_ASSERT( GetType() == TYPE_METHOD, "no method" ); + DBG_ASSERT( GetRef(), "no return type" ); + return (SvMetaType *)GetRef(); +} + +const ByteString& SvMetaType::GetBasicName() const +{ + if( aBasicName.IsSet() || !GetRef() ) + return aBasicName; + else + return ((SvMetaType*)GetRef())->GetBasicName(); +} + +ByteString SvMetaType::GetBasicPostfix() const +{ + + ByteString aRet; + + // MBN and Co always want "As xxx" + { + + aRet = " As "; + aRet += GetBasicName(); + } + + return aRet; +} + +sal_Bool SvMetaType::GetIn() const +{ + if( aIn.IsSet() || !GetRef() ) + return aIn; + else + return ((SvMetaType *)GetRef())->GetIn(); +} + +sal_Bool SvMetaType::GetOut() const +{ + if( aOut.IsSet() || !GetRef() ) + return aOut; + else + return ((SvMetaType *)GetRef())->GetOut(); +} + +void SvMetaType::SetCall0( int e ) +{ + aCall0 = (int)e; + if( aCall0 == CALL_VALUE && aCall1 == CALL_VALUE ) + { + if( GetType() == TYPE_POINTER ) + SetType( TYPE_BASE ); + } + else + { + DBG_ASSERT( nType == TYPE_POINTER || nType == TYPE_BASE, + "set no base type to pointer" ); + SetType( TYPE_POINTER ); + } +} + +int SvMetaType::GetCall0() const +{ + if( aCall0.IsSet() || !GetRef() ) + return aCall0; + else + return ((SvMetaType *)GetRef())->GetCall0(); +} + +void SvMetaType::SetCall1( int e ) +{ + aCall1 = (int)e; + if( aCall0 == CALL_VALUE && aCall1 == CALL_VALUE ) + { + if( GetType() == TYPE_POINTER ) + SetType( TYPE_BASE ); + } + else + { + DBG_ASSERT( nType == TYPE_POINTER || nType == TYPE_BASE, + "set no base type to pointer" ); + SetType( TYPE_POINTER ); + } +} + +int SvMetaType::GetCall1() const +{ + if( aCall1.IsSet() || !GetRef() ) + return aCall1; + else + return ((SvMetaType *)GetRef())->GetCall1(); +} + +const ByteString & SvMetaType::GetSvName() const +{ + if( aSvName.IsSet() || !GetRef() ) + return aSvName; + else + return ((SvMetaType *)GetRef())->GetSvName(); +} + +const ByteString & SvMetaType::GetSbxName() const +{ + if( aSbxName.IsSet() || !GetRef() ) + return aSbxName; + else + return ((SvMetaType *)GetRef())->GetSbxName(); +} + +const ByteString & SvMetaType::GetOdlName() const +{ + if( aOdlName.IsSet() || !GetRef() ) + return aOdlName; + else + return ((SvMetaType *)GetRef())->GetOdlName(); +} + +const ByteString & SvMetaType::GetCName() const +{ + if( aCName.IsSet() || !GetRef() ) + return aCName; + else + return ((SvMetaType *)GetRef())->GetCName(); +} + +sal_Bool SvMetaType::SetName( const ByteString & rName, SvIdlDataBase * pBase ) +{ + aSvName = rName; + aSbxName = rName; + aCName = rName; + if( GetType() != TYPE_ENUM ) + aOdlName = rName; + return SvMetaReference::SetName( rName, pBase ); +} + +#ifdef IDL_COMPILER +ByteString SvMetaType::GetCString() const +{ + ByteString out( GetSvName() ); + if( aCall0 == (int)CALL_POINTER ) + out += " *"; + else if( aCall0 == (int)CALL_REFERENCE ) + out += " &"; + if( aCall1 == (int)CALL_POINTER ) + out += '*'; + else if( aCall1 == (int)CALL_REFERENCE ) + out += '&'; + return out; +} + +sal_Bool SvMetaType::ReadHeaderSvIdl( SvIdlDataBase & rBase, + SvTokenStream & rInStm ) +{ + sal_Bool bOk = sal_False; + sal_uInt32 nTokPos = rInStm.Tell(); + SvToken * pTok = rInStm.GetToken_Next(); + + if( pTok->Is( SvHash_interface() ) + || pTok->Is( SvHash_shell() ) ) + { + if( pTok->Is( SvHash_shell() ) ) + bIsShell = sal_True; + SetType( TYPE_CLASS ); + bOk = ReadNamesSvIdl( rBase, rInStm ); + + } + else if( pTok->Is( SvHash_struct() ) ) + { + SetType( TYPE_STRUCT ); + bOk = ReadNamesSvIdl( rBase, rInStm ); + } + else if( pTok->Is( SvHash_union() ) ) + { + SetType( TYPE_UNION ); + if( ReadNameSvIdl( rBase, rInStm ) ) + return sal_True; + } + else if( pTok->Is( SvHash_enum() ) ) + { + SetType( TYPE_ENUM ); + bOk = ReadNameSvIdl( rBase, rInStm ); + } + else if( pTok->Is( SvHash_typedef() ) + || pTok->Is( SvHash_item() ) ) + { + if( pTok->Is( SvHash_item() ) ) + bIsItem = sal_True; + + SvMetaType * pType = rBase.ReadKnownType( rInStm ); + if( pType ) + { + SetRef( pType ); + if( ReadNameSvIdl( rBase, rInStm ) ) + { + if( rInStm.Read( '(' ) ) + { + DoReadContextSvIdl( rBase, rInStm ); + if( rInStm.Read( ')' ) ) + { + SetType( TYPE_METHOD ); + bOk = sal_True; + } + } + else + { + bOk = sal_True; + } + } + } + else + { + ByteString aStr = "wrong typedef: "; + rBase.SetError( aStr, rInStm.GetToken() ); + rBase.WriteError( rInStm ); + } + } + if( bOk ) + SetModule( rBase ); + else + rInStm.Seek( nTokPos ); + return bOk; +} + +sal_Bool SvMetaType::ReadSvIdl( SvIdlDataBase & rBase, + SvTokenStream & rInStm ) +{ + if( ReadHeaderSvIdl( rBase, rInStm ) ) + { + rBase.Write( '.' ); + return SvMetaExtern::ReadSvIdl( rBase, rInStm ); + } + return sal_False; +} + +void SvMetaType::WriteSvIdl +( + SvIdlDataBase & rBase, + SvStream & rOutStm, + sal_uInt16 nTab +) +{ + WriteHeaderSvIdl( rBase, rOutStm, nTab ); + if( GetType() == TYPE_METHOD ) + WriteMethodArgs( rBase, rOutStm, nTab, WRITE_IDL ); + + sal_uLong nOldPos = rOutStm.Tell(); + rOutStm << endl; + SvMetaExtern::WriteSvIdl( rBase, rOutStm, nTab ); + if( TestAndSeekSpaceOnly( rOutStm, nOldPos ) ) + // nothin written + rOutStm.Seek( nOldPos ); + rOutStm << ';' << endl; +} + +void SvMetaType::WriteContext( SvIdlDataBase & rBase, SvStream & rOutStm, + sal_uInt16 nTab, + WriteType nT, WriteAttribute nA ) +{ + if( GetAttrCount() ) + { + SvMetaAttribute * pAttr = pAttrList->First(); + while( pAttr ) + { + pAttr->Write( rBase, rOutStm, nTab, nT, nA ); + if( GetType() == TYPE_METHOD ) + rOutStm << ',' << endl; + else + rOutStm << ';' << endl; + pAttr = pAttrList->Next(); + } + } +} + +void SvMetaType::Write( SvIdlDataBase & rBase, SvStream & rOutStm, + sal_uInt16 nTab, + WriteType nT, WriteAttribute nA ) +{ + if( nT == WRITE_C_HEADER && nType != TYPE_ENUM ) + // write only enum + return; + + ByteString name = GetName(); + if( nT == WRITE_ODL || nT == WRITE_C_HEADER || nT == WRITE_CXX_HEADER ) + { + switch( nType ) + { + case TYPE_CLASS: + { + } + break; + case TYPE_STRUCT: + case TYPE_UNION: + case TYPE_ENUM: + { + WriteStars( rOutStm ); + if( nType == TYPE_STRUCT || nType == TYPE_UNION ) + nA = WA_STRUCT; + + if( nT == WRITE_ODL || nT == WRITE_C_HEADER) + { + if ( nT == WRITE_C_HEADER ) + { + ByteString aStr = name; + aStr.ToUpperAscii(); + rOutStm << "#ifndef " << C_PREF << aStr.GetBuffer() << "_DEF " << endl; + rOutStm << "#define " << C_PREF << aStr.GetBuffer() << "_DEF " << endl; + } + + WriteTab( rOutStm, nTab ); + rOutStm << "typedef" << endl; + if ( nT == WRITE_ODL ) + SvMetaName::Write( rBase, rOutStm, nTab, nT, nA ); + } + WriteTab( rOutStm, nTab ); + if( nType == TYPE_STRUCT ) + rOutStm << "struct"; + else if( nType == TYPE_UNION ) + rOutStm << "union"; + else + rOutStm << "enum"; + if( nT != WRITE_ODL && nT != WRITE_C_HEADER) + rOutStm << ' ' << name.GetBuffer(); + + rOutStm << endl; + WriteTab( rOutStm, nTab ); + rOutStm << '{' << endl; + WriteContext( rBase, rOutStm, nTab +1, nT, nA ); + WriteTab( rOutStm, nTab ); + rOutStm << '}'; + if( nT == WRITE_ODL || nT == WRITE_C_HEADER ) + { + rOutStm << ' ' << C_PREF << name.GetBuffer(); + } + rOutStm << ';' << endl; + + if ( nT == WRITE_C_HEADER ) + rOutStm << "#endif"; + rOutStm << endl; + } + break; + case TYPE_POINTER: + case TYPE_BASE: + { + } + break; + case TYPE_METHOD: + { + } + break; + } + } +} + +sal_Bool SvMetaType::ReadNamesSvIdl( SvIdlDataBase & rBase, + SvTokenStream & rInStm ) +{ + sal_Bool bOk = ReadNameSvIdl( rBase, rInStm ); + + return bOk; +} + +void SvMetaType::WriteHeaderSvIdl( SvIdlDataBase & rBase, + SvStream & rOutStm, + sal_uInt16 nTab ) +{ + switch( nType ) + { + case TYPE_CLASS: + { + if( IsShell() ) + rOutStm << SvHash_shell()->GetName().GetBuffer(); + else + rOutStm << SvHash_interface()->GetName().GetBuffer(); + rOutStm << ' ' << GetName().GetBuffer(); + } + break; + case TYPE_STRUCT: + { + rOutStm << SvHash_struct()->GetName().GetBuffer() + << ' ' << GetName().GetBuffer(); + } + break; + case TYPE_UNION: + { + rOutStm << SvHash_union()->GetName().GetBuffer() + << ' ' << GetName().GetBuffer(); + } + break; + case TYPE_ENUM: + { + rOutStm << SvHash_enum()->GetName().GetBuffer() + << ' ' << GetName().GetBuffer(); + } + break; + case TYPE_POINTER: + case TYPE_BASE: + { + if( IsItem() ) + rOutStm << SvHash_item()->GetName().GetBuffer() << ' '; + else + rOutStm << SvHash_typedef()->GetName().GetBuffer() << ' '; + if( GetRef() ) + { + ((SvMetaType *)GetRef())->WriteTheType( rBase, rOutStm, nTab, WRITE_IDL ); + rOutStm << ' '; + } + rOutStm << GetName().GetBuffer(); + } + break; + case TYPE_METHOD: + { + rOutStm << SvHash_typedef()->GetName().GetBuffer() << ' '; + ((SvMetaType *)GetRef())->WriteTheType( rBase, rOutStm, nTab, WRITE_IDL ); + rOutStm << ' ' << GetName().GetBuffer() << "( "; + WriteContextSvIdl( rBase, rOutStm, nTab ); + rOutStm << " )"; + } + break; + } +} + +void SvMetaType::ReadAttributesSvIdl( SvIdlDataBase & rBase, + SvTokenStream & rInStm ) +{ + SvMetaExtern::ReadAttributesSvIdl( rBase, rInStm ); + aSvName.ReadSvIdl( SvHash_SvName(), rInStm ); + aSbxName.ReadSvIdl( SvHash_SbxName(), rInStm ); + aOdlName.ReadSvIdl( SvHash_OdlName(), rInStm ); +} + +void SvMetaType::WriteAttributesSvIdl( SvIdlDataBase & rBase, + SvStream & rOutStm, + sal_uInt16 nTab ) +{ + SvMetaExtern::WriteAttributesSvIdl( rBase, rOutStm, nTab ); + ByteString name = GetName(); + if( aSvName != name || aSbxName != name || aOdlName != name ) + { + WriteTab( rOutStm, nTab ); + rOutStm << "class SvMetaType" << endl; + if( aSvName != name ) + { + WriteTab( rOutStm, nTab ); + aSvName.WriteSvIdl( SvHash_SvName(), rOutStm, nTab ); + rOutStm << endl; + } + if( aSbxName != name ) + { + WriteTab( rOutStm, nTab ); + aSbxName.WriteSvIdl( SvHash_SbxName(), rOutStm, nTab ); + rOutStm << endl; + } + if( aOdlName != name ) + { + WriteTab( rOutStm, nTab ); + aOdlName.WriteSvIdl( SvHash_OdlName(), rOutStm, nTab ); + rOutStm << endl; + } + } +} + +void SvMetaType::ReadContextSvIdl( SvIdlDataBase & rBase, + SvTokenStream & rInStm ) +{ + SvMetaAttributeRef xAttr = new SvMetaAttribute(); + if( xAttr->ReadSvIdl( rBase, rInStm ) ) + { + if( xAttr->Test( rBase, rInStm ) ) + GetAttrList().Append( xAttr ); + } +} + +void SvMetaType::WriteContextSvIdl +( + SvIdlDataBase & rBase, + SvStream & rOutStm, + sal_uInt16 nTab +) +{ + if( GetAttrCount() ) + { + SvMetaAttribute * pAttr = pAttrList->First(); + while( pAttr ) + { + WriteTab( rOutStm, nTab ); + pAttr->WriteSvIdl( rBase, rOutStm, nTab ); + if( GetType() == TYPE_METHOD ) + rOutStm << ',' << endl; + else + rOutStm << ';' << endl; + pAttr = pAttrList->Next(); + } + } +} + +void SvMetaType::WriteAttributes( SvIdlDataBase & rBase, SvStream & rOutStm, + sal_uInt16 nTab, + WriteType nT, WriteAttribute nA ) +{ + SvMetaExtern::WriteAttributes( rBase, rOutStm, nTab, nT, nA ); +} + +sal_uLong SvMetaType::MakeSfx( ByteString * pAttrArray ) +{ + sal_uLong nC = 0; + + if( GetBaseType()->GetType() == TYPE_STRUCT ) + { + sal_uLong nAttrCount = GetAttrCount(); + // write the single attributes + for( sal_uLong n = 0; n < nAttrCount; n++ ) + { + nC += pAttrList->GetObject( n )->MakeSfx( pAttrArray ); + if( n +1 < nAttrCount ) + *pAttrArray += ", "; + } + } + return nC; +} + +void SvMetaType::WriteSfxItem( + const ByteString & rItemName, SvIdlDataBase &, SvStream & rOutStm ) +{ + WriteStars( rOutStm ); + ByteString aVarName = " a"; + aVarName += rItemName; + aVarName += "_Impl"; + + ByteString aTypeName = "SfxType"; + ByteString aAttrArray; + sal_uLong nAttrCount = MakeSfx( &aAttrArray ); + ByteString aAttrCount( + rtl::OString::valueOf(static_cast<sal_Int32>(nAttrCount))); + aTypeName += aAttrCount; + + rOutStm << "extern " << aTypeName.GetBuffer() + << aVarName.GetBuffer() << ';' << endl; + + // write the implementation part + rOutStm << "#ifdef SFX_TYPEMAP" << endl + << aTypeName.GetBuffer() << aVarName.GetBuffer() + << " = " << endl; + rOutStm << '{' << endl + << "\tTYPE(" << rItemName.GetBuffer() << "), " + << aAttrCount.GetBuffer(); + if( nAttrCount ) + { + rOutStm << ", { "; + // write the single attributes + rOutStm << aAttrArray.GetBuffer(); + rOutStm << " }"; + } + rOutStm << endl << "};" << endl + << "#endif" << endl << endl; +} + +void SvMetaType::WriteSfx( SvIdlDataBase & rBase, SvStream & rOutStm ) +{ + if( IsItem() ) + { + if( GetBaseType()->GetType() == TYPE_STRUCT ) + GetBaseType()->WriteSfxItem( GetName(), rBase, rOutStm ); + else + WriteSfxItem( GetName(), rBase, rOutStm ); + } +} + +sal_Bool SvMetaType::ReadMethodArgs( SvIdlDataBase & rBase, + SvTokenStream & rInStm ) +{ + sal_uInt32 nTokPos = rInStm.Tell(); + if( rInStm.Read( '(' ) ) + { + DoReadContextSvIdl( rBase, rInStm ); + if( rInStm.Read( ')' ) ) + { + SetType( TYPE_METHOD ); + return sal_True; + } + } + rInStm.Seek( nTokPos ); + return sal_False; +} + +void SvMetaType::WriteMethodArgs +( + SvIdlDataBase & rBase, + SvStream & rOutStm, + sal_uInt16 nTab, WriteType nT +) +{ + if( nT == WRITE_IDL ) + { + if( GetAttrCount() ) + { + rOutStm << endl; + WriteTab( rOutStm, nTab ); + rOutStm << '(' << endl; + + SvMetaAttribute * pAttr = pAttrList->First(); + while( pAttr ) + { + WriteTab( rOutStm, nTab +1 ); + pAttr->WriteSvIdl( rBase, rOutStm, nTab +1 ); + pAttr = pAttrList->Next(); + if( pAttr ) + rOutStm << ',' << endl; + } + rOutStm << endl; + WriteTab( rOutStm, nTab ); + rOutStm << ')'; + } + else + rOutStm << "()"; + } + else if ( nT == WRITE_DOCU ) + { + + rOutStm << '('; + if( GetAttrCount() ) + { + SvMetaAttribute * pAttr = pAttrList->First(); + while( pAttr ) + { + pAttr->WriteParam( rBase, rOutStm, nTab+1, nT ); + pAttr = pAttrList->Next(); + if( pAttr ) + rOutStm << ','; + else + rOutStm << ' '; + } + } + rOutStm << ')' << endl; + } + else + { + rOutStm << '('; + if( nT == WRITE_C_HEADER || nT == WRITE_C_SOURCE ) + { + rOutStm << ' ' << C_PREF << "Object h" << rBase.aIFaceName.GetBuffer(); + if( GetAttrCount() ) + rOutStm << ','; + else + rOutStm << ' '; + } + + if( GetAttrCount() ) + { + rOutStm << endl; + SvMetaAttribute * pAttr = pAttrList->First(); + while( pAttr ) + { + switch( nT ) + { + case WRITE_C_HEADER: + case WRITE_C_SOURCE: + case WRITE_ODL: + { + pAttr->WriteParam( rBase, rOutStm, nTab +1, nT ); + } + break; + + default: + { + DBG_ASSERT( sal_False, "WriteType not implemented" ); + } + } + pAttr = pAttrList->Next(); + if( pAttr ) + rOutStm << ',' << endl; + } + if( nT != WRITE_C_HEADER && nT != WRITE_C_SOURCE ) + { + rOutStm << endl; + WriteTab( rOutStm, nTab +1 ); + } + rOutStm << ' '; + } + rOutStm << ')'; + } +} + +void SvMetaType::WriteTypePrefix( SvIdlDataBase & rBase, SvStream & rOutStm, + sal_uInt16 nTab, WriteType nT ) +{ + switch( nT ) + { + case WRITE_IDL: + { + if( GetIn() && GetOut() ) + rOutStm << SvHash_inout()->GetName().GetBuffer() << ' '; + else if( GetIn() ) + rOutStm << SvHash_in()->GetName().GetBuffer() << ' '; + else if( GetOut() ) + rOutStm << SvHash_out()->GetName().GetBuffer() << ' '; + rOutStm << GetCString().GetBuffer(); + } + break; + + case WRITE_ODL: + { + sal_Bool bIn = GetIn(); + sal_Bool bOut = GetOut(); + if( bIn || bOut ) + { + if( bIn && bOut ) + rOutStm << "[in,out] "; + else if( bIn ) + rOutStm << "[in] "; + else if( bOut ) + rOutStm << "[out] "; + } + + ByteString out; + if( GetType() == TYPE_METHOD ) + out = GetReturnType()->GetBaseType()->GetOdlName(); + else + { + SvMetaType * pBType = GetBaseType(); + out = pBType->GetOdlName(); + } + if( aCall0 == (int)CALL_POINTER + || aCall0 == (int)CALL_REFERENCE ) + rOutStm << " *"; + if( aCall1 == (int)CALL_POINTER + || aCall1 == (int)CALL_REFERENCE ) + rOutStm << " *"; + rOutStm << out.GetBuffer(); + } + break; + + case WRITE_C_HEADER: + case WRITE_C_SOURCE: + case WRITE_CXX_HEADER: + case WRITE_CXX_SOURCE: + { + + SvMetaType * pBaseType = GetBaseType(); + DBG_ASSERT( pBaseType, "no base type for attribute" ); + + if( pBaseType->GetType() == TYPE_METHOD ) + pBaseType->GetReturnType()->WriteTypePrefix( + rBase, rOutStm, nTab, nT ); + else if( nT == WRITE_C_HEADER || nT == WRITE_C_SOURCE ) + { + if( TYPE_STRUCT == pBaseType->GetType() ) + rOutStm << C_PREF << pBaseType->GetName().GetBuffer() + << " *"; + else + { + if ( pBaseType->GetType() == TYPE_ENUM ) + rOutStm << C_PREF; + rOutStm << pBaseType->GetCName().GetBuffer(); + } + } + else + { + if( TYPE_STRUCT == pBaseType->GetType() ) + rOutStm << pBaseType->GetName().GetBuffer() << " *"; + else + rOutStm << pBaseType->GetName().GetBuffer(); + } + } + break; + + case WRITE_DOCU: + { + + SvMetaType * pBaseType = GetBaseType(); + DBG_ASSERT( pBaseType, "no base type for attribute" ); + + if( pBaseType->GetType() == TYPE_METHOD ) + { + pBaseType->GetReturnType()->WriteTypePrefix( + rBase, rOutStm, nTab, nT ); + } + else + { + if( TYPE_STRUCT == pBaseType->GetType() ) + rOutStm << "VARIANT" << pBaseType->GetName().GetBuffer(); + else if ( pBaseType->GetType() == TYPE_ENUM ) + rOutStm << "integer"; + else + rOutStm << pBaseType->GetOdlName().GetBuffer(); + } + } + + default: + { + DBG_ASSERT( sal_False, "WriteType not implemented" ); + } + } +} + +void SvMetaType::WriteTheType( SvIdlDataBase & rBase, SvStream & rOutStm, + sal_uInt16 nTab, WriteType nT ) +{ + WriteTypePrefix( rBase, rOutStm, nTab, nT ); + if( GetType() == TYPE_METHOD ) + WriteMethodArgs( rBase, rOutStm, nTab +2, nT ); +} + +ByteString SvMetaType::GetParserString() const +{ + SvMetaType * pBT = GetBaseType(); + if( pBT != this ) + return pBT->GetParserString(); + + int type = GetType(); + ByteString aPStr; + + if( TYPE_METHOD == type || TYPE_STRUCT == type ) + { + sal_uLong nAttrCount = GetAttrCount(); + // write the single attributes + for( sal_uLong n = 0; n < nAttrCount; n++ ) + { + SvMetaAttribute * pT = pAttrList->GetObject( n ); + aPStr += pT->GetType()->GetParserString(); + } + } + else + aPStr = GetParserChar(); + return aPStr; +} + +void SvMetaType::WriteParamNames( SvIdlDataBase & rBase, + SvStream & rOutStm, + const ByteString & rChief ) +{ + SvMetaType * pBT = GetBaseType(); + if( pBT != this ) + pBT->WriteParamNames( rBase, rOutStm, rChief ); + else + { + int type = GetType(); + ByteString aPStr; + + if( TYPE_METHOD == type || TYPE_STRUCT == type ) + { + sal_uLong nAttrCount = GetAttrCount(); + // write the single attributes + for( sal_uLong n = 0; n < nAttrCount; n++ ) + { + SvMetaAttribute * pA = pAttrList->GetObject( n ); + ByteString aStr = pA->GetName(); + pA->GetType()->WriteParamNames( rBase, rOutStm, aStr ); + if( n +1 < nAttrCount ) + rOutStm << ", "; + } + } + else + rOutStm << rChief.GetBuffer(); + } +} + +#endif // IDL_COMPILER + +SV_IMPL_META_FACTORY1( SvMetaTypeString, SvMetaType ); +SvMetaTypeString::SvMetaTypeString() + : SvMetaType( "String", "SbxSTRING", "BSTR", 's', "char *", "String", "$" ) +{ +} + +void SvMetaTypeString::Load( SvPersistStream & rStm ) +{ + SvMetaType::Load( rStm ); +} + +void SvMetaTypeString::Save( SvPersistStream & rStm ) +{ + SvMetaType::Save( rStm ); +} + +SV_IMPL_META_FACTORY1( SvMetaEnumValue, SvMetaName ); +SvMetaEnumValue::SvMetaEnumValue() +{ +} + +void SvMetaEnumValue::Load( SvPersistStream & rStm ) +{ + SvMetaName::Load( rStm ); + + sal_uInt8 nMask; + rStm >> nMask; + if( nMask >= 0x02 ) + { + rStm.SetError( SVSTREAM_FILEFORMAT_ERROR ); + OSL_FAIL( "wrong format" ); + return; + } + if( nMask & 0x01 ) rStm.ReadByteString( aEnumValue ); +} + +void SvMetaEnumValue::Save( SvPersistStream & rStm ) +{ + SvMetaName::Save( rStm ); + + // create mask + sal_uInt8 nMask = 0; + if( aEnumValue.Len() ) nMask |= 0x01; + + // write data + rStm << nMask; + if( nMask & 0x01 ) rStm.WriteByteString( aEnumValue ); +} + +#ifdef IDL_COMPILER +sal_Bool SvMetaEnumValue::ReadSvIdl( SvIdlDataBase & rBase, + SvTokenStream & rInStm ) +{ + if( !ReadNameSvIdl( rBase, rInStm ) ) + return sal_False; + return sal_True; +} + +void SvMetaEnumValue::WriteSvIdl( SvIdlDataBase &, SvStream & rOutStm, sal_uInt16 ) +{ + rOutStm << GetName().GetBuffer(); +} + +void SvMetaEnumValue::Write( SvIdlDataBase &, SvStream & rOutStm, sal_uInt16, + WriteType nT, WriteAttribute ) +{ + if ( nT == WRITE_C_HEADER || nT == WRITE_C_SOURCE ) + rOutStm << C_PREF << GetName().GetBuffer(); + else + rOutStm << GetName().GetBuffer(); +} +#endif // IDL_COMPILER + +SV_IMPL_META_FACTORY1( SvMetaTypeEnum, SvMetaType ); +SvMetaTypeEnum::SvMetaTypeEnum() +{ + SetBasicName( "Integer" ); +} + +void SvMetaTypeEnum::Load( SvPersistStream & rStm ) +{ + SvMetaType::Load( rStm ); + + sal_uInt8 nMask; + rStm >> nMask; + if( nMask >= 0x04 ) + { + rStm.SetError( SVSTREAM_FILEFORMAT_ERROR ); + OSL_FAIL( "wrong format" ); + return; + } + if( nMask & 0x01 ) rStm >> aEnumValueList; + if( nMask & 0x02 ) rStm.ReadByteString( aPrefix ); +} + +void SvMetaTypeEnum::Save( SvPersistStream & rStm ) +{ + SvMetaType::Save( rStm ); + + // create mask + sal_uInt8 nMask = 0; + if( aEnumValueList.Count() ) nMask |= 0x01; + if( aPrefix.Len() ) nMask |= 0x02; + + // write data + rStm << nMask; + if( nMask & 0x01 ) rStm << aEnumValueList; + if( nMask & 0x02 ) rStm.WriteByteString( aPrefix ); +} + +#ifdef IDL_COMPILER +void SvMetaTypeEnum::ReadContextSvIdl( SvIdlDataBase & rBase, + SvTokenStream & rInStm ) +{ + sal_uInt32 nTokPos = rInStm.Tell(); + + SvMetaEnumValueRef aEnumVal = new SvMetaEnumValue(); + sal_Bool bOk = aEnumVal->ReadSvIdl( rBase, rInStm ); + if( bOk ) + { + if( 0 == aEnumValueList.Count() ) + // the first + aPrefix = aEnumVal->GetName(); + else + { + sal_uInt16 nPos = aPrefix.Match( aEnumVal->GetName() ); + if( nPos != aPrefix.Len() && nPos != STRING_MATCH ) + aPrefix.Erase( nPos ); + } + aEnumValueList.Append( aEnumVal ); + } + if( !bOk ) + rInStm.Seek( nTokPos ); +} + +void SvMetaTypeEnum::WriteContextSvIdl( SvIdlDataBase & rBase, + SvStream & rOutStm, + sal_uInt16 nTab ) +{ + WriteTab( rOutStm, nTab +1 ); + for( sal_uLong n = 0; n < aEnumValueList.Count(); n++ ) + { + aEnumValueList.GetObject( n )->WriteSvIdl( rBase, rOutStm, nTab ); + if( n +1 != aEnumValueList.Count() ) + rOutStm << ", "; + else + rOutStm << endl; + } +} + +sal_Bool SvMetaTypeEnum::ReadSvIdl( SvIdlDataBase & rBase, + SvTokenStream & rInStm ) +{ + sal_uInt32 nTokPos = rInStm.Tell(); + if( SvMetaType::ReadHeaderSvIdl( rBase, rInStm ) + && GetType() == TYPE_ENUM ) + { + if( SvMetaName::ReadSvIdl( rBase, rInStm ) ) + return sal_True; + } + rInStm.Seek( nTokPos ); + return sal_False; +} + +void SvMetaTypeEnum::WriteSvIdl( SvIdlDataBase & rBase, SvStream & rOutStm, + sal_uInt16 nTab ) +{ + WriteHeaderSvIdl( rBase, rOutStm, nTab ); + rOutStm << endl; + SvMetaName::WriteSvIdl( rBase, rOutStm, nTab ); + rOutStm << endl; +} + +void SvMetaTypeEnum::Write( SvIdlDataBase & rBase, SvStream & rOutStm, + sal_uInt16 nTab, + WriteType nT, WriteAttribute nA ) +{ + SvMetaType::Write( rBase, rOutStm, nTab, nT, nA ); +} + +void SvMetaTypeEnum::WriteContext( SvIdlDataBase & rBase, SvStream & rOutStm, + sal_uInt16 nTab, + WriteType nT, WriteAttribute nA ) +{ + WriteTab( rOutStm, nTab +1 ); + for( sal_uLong n = 0; n < aEnumValueList.Count(); n++ ) + { + aEnumValueList.GetObject( n )->Write( rBase, rOutStm, nTab +1, nT, nA ); + + if( n +1 != aEnumValueList.Count() ) + { + if( 2 == n % 3 ) + { + rOutStm << ',' << endl; + WriteTab( rOutStm, nTab +1 ); + } + else + rOutStm << ",\t"; + } + else + rOutStm << endl; + } + rOutStm << endl; +} + +#endif // IDL_COMPILER + +SV_IMPL_META_FACTORY1( SvMetaTypevoid, SvMetaType ); +SvMetaTypevoid::SvMetaTypevoid() + : SvMetaType( "void", "SbxVOID", "void", 'v', "void", "", "" ) +{ +} + +void SvMetaTypevoid::Load( SvPersistStream & rStm ) +{ + SvMetaType::Load( rStm ); +} + +void SvMetaTypevoid::Save( SvPersistStream & rStm ) +{ + SvMetaType::Save( rStm ); +} + +ByteString SvMetaAttribute::Compare( SvMetaAttribute* pAttr ) +{ + ByteString aStr; + + if ( aType.Is() ) + { + if ( aType->GetType() == TYPE_METHOD ) + { + // Test only when the attribute is a method not if it has one! + if ( !pAttr->GetType()->GetType() == TYPE_METHOD ) + aStr += " IsMethod\n"; + else if ( aType->GetReturnType() && + aType->GetReturnType()->GetType() != pAttr->GetType()->GetReturnType()->GetType() ) + aStr += " ReturnType\n"; + + if ( aType->GetAttrCount() ) + { + sal_uLong nCount = aType->GetAttrCount(); + SvMetaAttributeMemberList& rList = aType->GetAttrList(); + SvMetaAttributeMemberList& rOtherList = pAttr->GetType()->GetAttrList(); + if ( pAttr->GetType()->GetAttrCount() != nCount ) + { + aStr += " AttributeCount\n"; + } + else + { + for ( sal_uInt16 n=0; n<nCount; n++ ) + { + SvMetaAttribute *pAttr1 = rList.GetObject(n); + SvMetaAttribute *pAttr2 = rOtherList.GetObject(n); + pAttr1->Compare( pAttr2 ); + } + } + } + } + + if ( GetType()->GetType() != pAttr->GetType()->GetType() ) + aStr += " Type\n"; + + if ( !GetType()->GetSvName().Equals( pAttr->GetType()->GetSvName() ) ) + aStr += " ItemType\n"; + } + + if ( GetExport() != pAttr->GetExport() ) + aStr += " Export\n"; + + if ( GetAutomation() != pAttr->GetAutomation() ) + aStr += " Automation\n"; + + if ( GetIsCollection() != pAttr->GetIsCollection() ) + aStr += " IsCollection\n"; + + if ( GetReadOnlyDoc() != pAttr->GetReadOnlyDoc() ) + aStr += " ReadOnlyDoc\n"; + + if ( GetExport() && GetReadonly() != pAttr->GetReadonly() ) + aStr += " Readonly\n"; + + return aStr; +} + +void SvMetaAttribute::WriteCSV( SvIdlDataBase&, SvStream& rStrm ) +{ + rStrm << GetType()->GetSvName().GetBuffer() << ' '; + rStrm << GetName().GetBuffer() << ' '; + rStrm << GetSlotId().GetBuffer(); +} + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/idl/source/prj/command.cxx b/idl/source/prj/command.cxx new file mode 100644 index 000000000000..a112e3b93f83 --- /dev/null +++ b/idl/source/prj/command.cxx @@ -0,0 +1,379 @@ +/* -*- 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_idl.hxx" + +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <ctype.h> + +#include <command.hxx> +#include <globals.hxx> +#include <database.hxx> +#include <tools/fsys.hxx> + +char const * SyntaxStrings[] = { +"basic-type:", +"\tvoid| char| int| float| double|", +"\tUINT16| INT16| UINT32| INT32| BOOL|", +"\tBYTE| String| SbxObject", +"", +"{ import \"filename\" }\n", +"module definition:", +"module", +"\tunique id range (ask MM)", +"modul-name", +"'['", +"\tSlotIdFile( \"filename\" )", +"']'", +"'{'", +"\t{ include \"filename\" }\n", + +"\titem definition:", +"\titem type item-name;\n", + +"\ttype definition:", +"\tstruct | union identifier", +"\t'{'", +"\t\t{ type idetifier }", +"\t'}'", +"\t|", +"\tenum identifier", +"\t'{'", +"\t\t{ identifier, }", +"\t'}'", +"\t|", +"\ttypedef type identifier\n", + +"\titem-method:", +"\titem identifier item-method-args\n", + +"\titem-method-args:", +"\t( { item parameter-name SLOT_ID } )\n", + +"\tslot definition:", +"\titem identifier SLOT_ID [ item-method-args ]", +"\t'['\n", + +"\t\titem-method-args", +"\t\tAccelConfig, MenuConfig, StatusBarConfig, ToolbarConfig", +"\t\tAutomation*", +"\t\tAutoUpdate", +"\t\tContainer", +"\t\tDefault = Identifier", +"\t\tExecMethod = Identifier", +"\t\tExport*", +"\t\tFastCall", +"\t\tGet, Set", +"\t\tGroupId = Identifier", +"\t\tHasCoreId", +"\t\tHasDialog", +"\t\tIsCollection", +"\t\tImageRotation", +"\t\tImageReflection", +"\t\tPseudoPrefix = Identifier", +"\t\tPseudoSlots", +"\t\tReadOnly", +"\t\tReadOnlyDoc*", +"\t\tRecordPerSet*, RecordPerItem, RecordManual, NoRecord", +"\t\tRecordAbsolute", +"\t\tStateMethod = Identifier", +"\t\tSynchron*, Asynchron", +"\t\tToggle", +"\t']'\n", + +"\tinterface definition:", +"\tshell | interface identifier ':' interface", +"\t'{'", +"\t\t{ slot }", +"\t'}'\n", +"---syntax example is sfx.idl---\n", +NULL }; + +char CommandLineSyntax[] = +"-fs<slotmap file> -fl<listing file>\n" +"-fo<odl file> -fd<data base file>\n" +"-fi<item implementation> -ft<type library file> (not OLE)\n" +"-fr<ressource file> -fm<makefile target file>\n" +"-fC<c++ source file> -fH<c++ header file>\n" +"-fc<c source file> -fh<c header file>\n" +"-rsc <*.srs header line>\n" +"-help, ? @<file> response file\n" +" <filenames>\n"; + +void Init() +{ + if( !IDLAPP->pHashTable ) + IDLAPP->pHashTable = new SvStringHashTable( 2801 ); + if( !IDLAPP->pGlobalNames ) + IDLAPP->pGlobalNames = new SvGlobalHashNames(); +} + +void DeInit() +{ + delete IDLAPP; +} + +sal_Bool ReadIdl( SvIdlWorkingBase * pDataBase, const SvCommand & rCommand ) +{ + for( size_t n = 0; n < rCommand.aInFileList.size(); ++n ) + { + String aFileName ( *rCommand.aInFileList[ n ] ); + SvFileStream aStm( aFileName, STREAM_STD_READ | STREAM_NOCREATE ); + if( aStm.GetError() == SVSTREAM_OK ) + { + if( pDataBase->IsBinaryFormat( aStm ) ) + { + pDataBase->Load( aStm ); + if( aStm.GetError() != SVSTREAM_OK ) + { + ByteString aStr; + if( aStm.GetError() == SVSTREAM_FILEFORMAT_ERROR ) + aStr = "error: incompatible format, file "; + else if( aStm.GetError() == SVSTREAM_WRONGVERSION ) + aStr = "error: wrong version, file "; + else + aStr = "error during load, file "; + aStr += ByteString( aFileName, RTL_TEXTENCODING_UTF8 ); + fprintf( stderr, "%s\n", aStr.GetBuffer() ); + return sal_False; + } + } + else + { + SvTokenStream aTokStm( aStm, aFileName ); + if( !pDataBase->ReadSvIdl( aTokStm, sal_False, rCommand.aPath ) ) + return sal_False; + } + } + else + { + const ByteString aStr( aFileName, RTL_TEXTENCODING_UTF8 ); + fprintf( stderr, "unable to read input file: %s\n", aStr.GetBuffer() ); + return sal_False; + } + } + return sal_True; +} + +static sal_Bool ResponseFile( StringList * pList, int argc, char ** argv ) +{ + // program name + pList->push_back( new String( String::CreateFromAscii(*argv) ) ); + for( int i = 1; i < argc; i++ ) + { + if( '@' == **(argv +i) ) + { // when @, then response file + SvFileStream aStm( String::CreateFromAscii((*(argv +i)) +1), STREAM_STD_READ | STREAM_NOCREATE ); + if( aStm.GetError() != SVSTREAM_OK ) + return sal_False; + + ByteString aStr; + while( aStm.ReadLine( aStr ) ) + { + sal_uInt16 n = 0; + sal_uInt16 nPos = 1; + while( n != nPos ) + { + while( aStr.GetChar(n) && isspace( aStr.GetChar(n) ) ) + n++; + nPos = n; + while( aStr.GetChar(n) && !isspace( aStr.GetChar(n) ) ) + n++; + if( n != nPos ) + pList->push_back( new String( String::CreateFromAscii( aStr.Copy( nPos, n - nPos ).GetBuffer() ) ) ); + } + } + } + else if( argv[ i ] ) + pList->push_back( new String( String::CreateFromAscii( argv[ i ] ) ) ); + } + return sal_True; +} + +SvCommand::SvCommand( int argc, char ** argv ) + : nVerbosity(1), nFlags( 0 ) +{ + StringList aList; + + if( ResponseFile( &aList, argc, argv ) ) + for( size_t i = 1; i < aList.size(); i++ ) + { + String aParam( *aList[ i ] ); + sal_Unicode aFirstChar( aParam.GetChar(0) ); + if( '-' == aFirstChar ) + { + aParam.Erase( 0, 1 ); + aFirstChar = aParam.GetChar(0); + if( aFirstChar == 'F' || aFirstChar == 'f' ) + { + aParam.Erase( 0, 1 ); + aFirstChar = aParam.GetChar(0); + String aName( aParam.Copy( 1 ) ); + if( 's' == aFirstChar ) + { // name of slot output + aSlotMapFile = aName; + } + else if( 'l' == aFirstChar ) + { // name of listing + aListFile = aName; + } + else if( 'i' == aFirstChar ) + { + } + else if( 'o' == aFirstChar ) + { + } + else if( 'd' == aFirstChar ) + { // name of data set file + aDataBaseFile = aName; + } + else if( 'D' == aFirstChar ) + { + } + else if( 'C' == aFirstChar ) + { + } + else if( 'H' == aFirstChar ) + { + } + else if( 'c' == aFirstChar ) + { + } + else if( 'h' == aFirstChar ) + { + } + else if( 't' == aFirstChar ) + { + } + else if( 'm' == aFirstChar ) + { // name of info file + aTargetFile = aName; + } + else if( 'r' == aFirstChar ) + { + } + else if( 'z' == aFirstChar ) + { // name of HelpId file + aHelpIdFile = aName; + } + else if( 'y' == aFirstChar ) + { // name of CSV file + aCSVFile = aName; + } + else if( 'x' == aFirstChar ) + { // name of IDL file for the CSV file + aExportFile = aName; + } + else + { + printf( + "unknown switch: %s\n", + rtl::OUStringToOString( + aParam, RTL_TEXTENCODING_UTF8).getStr()); + exit( -1 ); + } + } + else if( aParam.EqualsIgnoreCaseAscii( "help" ) || aParam.EqualsIgnoreCaseAscii( "?" ) ) + { // help + printf( "%s", CommandLineSyntax ); + } + else if( aParam.EqualsIgnoreCaseAscii( "quiet" ) ) + { + nVerbosity = 0; + } + else if( aParam.EqualsIgnoreCaseAscii( "verbose" ) ) + { + nVerbosity = 2; + } + else if( aParam.EqualsIgnoreCaseAscii( "syntax" ) ) + { // help + int j = 0; + while(SyntaxStrings[j]) + printf("%s\n",SyntaxStrings[j++]); + } + else if( aParam.EqualsIgnoreCaseAscii( "i", 0, 1 ) ) + { // define include paths + String aName( aParam.Copy( 1 ) ); + if( aPath.Len() ) + aPath += DirEntry::GetSearchDelimiter(); + aPath += aName; + } + else if( aParam.EqualsIgnoreCaseAscii( "rsc", 0, 3 ) ) + { // first line in *.srs file + if( aList[ i + 1 ] ) + { + aSrsLine = ByteString( *aList[ i +1 ], RTL_TEXTENCODING_UTF8 ); + i++; + } + } + else + { + // temporary compatibility hack + printf( + "unknown switch: %s\n", + rtl::OUStringToOString( + aParam, RTL_TEXTENCODING_UTF8).getStr()); + exit( -1 ); + } + } + else + { + aInFileList.push_back( new String( aParam ) ); + } + } + else + { + printf( "%s", CommandLineSyntax ); + } + + for ( size_t i = 0, n = aList.size(); i < n; ++i ) + delete aList[ i ]; + aList.clear(); + + ByteString aInc( getenv( "INCLUDE" ) ); + // append include environment variable + if( aInc.Len() ) + { + if( aPath.Len() ) + aPath += DirEntry::GetSearchDelimiter(); + aPath += String::CreateFromAscii( aInc.GetBuffer() ); + } +} + +SvCommand::~SvCommand() +{ + // release ByteString list + for ( size_t i = 0, n = aInFileList.size(); i < n; ++i ) + delete aInFileList[ i ]; + aInFileList.clear(); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/idl/source/prj/database.cxx b/idl/source/prj/database.cxx new file mode 100644 index 000000000000..fa37d2d003a3 --- /dev/null +++ b/idl/source/prj/database.cxx @@ -0,0 +1,834 @@ +/* -*- 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_idl.hxx" + +#include <ctype.h> +#include <stdio.h> +#include <stdlib.h> +#include <tools/fsys.hxx> +#include <tools/debug.hxx> +#include <database.hxx> +#include <globals.hxx> +#include <rtl/strbuf.hxx> + +SvIdlDataBase::SvIdlDataBase( const SvCommand& rCmd ) + : bExport( sal_False ) + , nUniqueId( 0 ) + , nVerbosity( rCmd.nVerbosity ) + , bIsModified( sal_False ) + , aPersStream( *IDLAPP->pClassMgr, NULL ) + , pIdTable( NULL ) +{ +} + +SvIdlDataBase::~SvIdlDataBase() +{ + for ( size_t i = 0, n = aIdFileList.size(); i < n; ++i ) + delete aIdFileList[ i ]; + aIdFileList.clear(); + + delete pIdTable; +} + +#define ADD_TYPE( Name, OdlName, ParserChar, CName, BasName, BasPost ) \ + aTypeList.Append( new SvMetaType( SvHash_##Name()->GetName(), \ + BasName, OdlName, ParserChar, CName, BasName, BasPost ) ); + +SvMetaTypeMemberList & SvIdlDataBase::GetTypeList() +{ + if( aTypeList.Count() == 0 ) + { // fill initially + aTypeList.Append( new SvMetaTypeString() ); + aTypeList.Append( new SvMetaTypevoid() ); + + // MI: IDispatch::Invoke can not unsigned + ADD_TYPE( UINT16, "long", 'h', "unsigned short", "Long", "&" ); + ADD_TYPE( INT16, "short", 'h', "short", "Integer", "%" ); + ADD_TYPE( UINT32, "long", 'l', "unsigned long", "Long", "&" ); + ADD_TYPE( INT32, "long", 'l', "long", "Long", "&" ); + ADD_TYPE( int, "int", 'i', "int", "Integer", "%" ); + ADD_TYPE( BOOL, "boolean", 'b', "unsigned char", "Boolean", "" ); + ADD_TYPE( char, "char", 'c', "char", "Integer", "%" ); + ADD_TYPE( BYTE, "char", 'c', "unsigned char", "Integer", "%" ); + ADD_TYPE( float, "float", 'f', "float", "Single", "!" ); + ADD_TYPE( double, "double", 'F', "double", "Double", "#" ); + ADD_TYPE( SbxObject, "VARIANT", 'o', "C_Object", "Object", "" ); + + // Attention! When adding types all binary data bases get incompatible + + } + return aTypeList; +} + +SvMetaModule * SvIdlDataBase::GetModule( const ByteString & rName ) +{ + for( sal_uLong n = 0; n < aModuleList.Count(); n++ ) + if( aModuleList.GetObject( n )->GetName() == rName ) + return aModuleList.GetObject( n ); + return NULL; +} + +#define DATABASE_SIGNATURE (sal_uInt32)0x13B799F2 +#define DATABASE_VER 0x0006 +sal_Bool SvIdlDataBase::IsBinaryFormat( SvStream & rStm ) +{ + sal_uInt32 nSig = 0; + sal_uLong nPos = rStm.Tell(); + rStm >> nSig; + rStm.Seek( nPos ); + + return nSig == DATABASE_SIGNATURE; +} + +void SvIdlDataBase::Load( SvStream & rStm ) +{ + DBG_ASSERT( aTypeList.Count() == 0, "type list already initialized" ); + SvPersistStream aPStm( *IDLAPP->pClassMgr, &rStm ); + + sal_uInt16 nVersion = 0; + sal_uInt32 nSig = 0; + + aPStm >> nSig; + aPStm >> nVersion; + if( nSig != DATABASE_SIGNATURE ) + { + aPStm.SetError( SVSTREAM_FILEFORMAT_ERROR ); + return; + } + if( nVersion != DATABASE_VER ) + { + aPStm.SetError( SVSTREAM_WRONGVERSION ); + return; + } + aPStm >> aClassList; + aPStm >> aTypeList; + aPStm >> aAttrList; + aPStm >> aModuleList; + aPStm >> nUniqueId; + + if( aPStm.IsEof() ) + aPStm.SetError( SVSTREAM_GENERALERROR ); +} + +void SvIdlDataBase::Save( SvStream & rStm, sal_uInt32 nFlags ) +{ + SvPersistStream aPStm( *IDLAPP->pClassMgr, &rStm ); + aPStm.SetContextFlags( nFlags ); + + aPStm << (sal_uInt32)DATABASE_SIGNATURE; + aPStm << (sal_uInt16)DATABASE_VER; + + sal_Bool bOnlyStreamedObjs = sal_False; + if( nFlags & IDL_WRITE_CALLING ) + bOnlyStreamedObjs = sal_True; + + if( bOnlyStreamedObjs ) + { + SvMetaClassMemberList aList; + for( sal_uLong n = 0; n < GetModuleList().Count(); n++ ) + { + SvMetaModule * pModule = GetModuleList().GetObject( n ); + if( !pModule->IsImported() ) + aList.Append( pModule->GetClassList() ); + } + aPStm << aList; + } + else + aPStm << aClassList; + + aTypeList.WriteObjects( aPStm, bOnlyStreamedObjs ); + aAttrList.WriteObjects( aPStm, bOnlyStreamedObjs ); + aModuleList.WriteObjects( aPStm, bOnlyStreamedObjs ); + aPStm << nUniqueId; +} + +void SvIdlDataBase::SetError( const ByteString & rError, SvToken * pTok ) +{ + if( pTok->GetLine() > 10000 ) + aError.SetText( "hgchcg" ); + + if( aError.nLine < pTok->GetLine() + || (aError.nLine == pTok->GetLine() && aError.nColumn < pTok->GetColumn()) ) + { + aError = SvIdlError( pTok->GetLine(), pTok->GetColumn() ); + aError.SetText( rError ); + } +} + +void SvIdlDataBase::Push( SvMetaObject * pObj ) +{ + GetStack().Push( pObj ); +} + +#ifdef IDL_COMPILER +sal_Bool SvIdlDataBase::FindId( const ByteString & rIdName, sal_uLong * pVal ) +{ + if( pIdTable ) + { + sal_uInt32 nHash; + if( pIdTable->Test( rIdName, &nHash ) ) + { + *pVal = pIdTable->Get( nHash )->GetValue(); + return sal_True; + } + } + return sal_False; +} + +sal_Bool SvIdlDataBase::InsertId( const ByteString & rIdName, sal_uLong nVal ) +{ + if( !pIdTable ) + pIdTable = new SvStringHashTable( 20003 ); + + sal_uInt32 nHash; + if( pIdTable->Insert( rIdName, &nHash ) ) + { + pIdTable->Get( nHash )->SetValue( nVal ); + return sal_True; + } + return sal_False; +} + +sal_Bool SvIdlDataBase::ReadIdFile( const String & rFileName ) +{ + DirEntry aFullName( rFileName ); + aFullName.Find( GetPath() ); + + for ( size_t i = 0, n = aIdFileList.size(); i < n; ++i ) + if ( *aIdFileList[ i ] == rFileName ) + return sal_True; + + aIdFileList.push_back( new String( rFileName ) ); + + SvTokenStream aTokStm( aFullName.GetFull() ); + if( aTokStm.GetStream().GetError() == SVSTREAM_OK ) + { + SvToken * pTok = aTokStm.GetToken_Next(); + + while( !pTok->IsEof() ) + { + if( pTok->IsChar() && pTok->GetChar() == '#' ) + { + pTok = aTokStm.GetToken_Next(); + if( pTok->Is( SvHash_define() ) ) + { + pTok = aTokStm.GetToken_Next(); + ByteString aDefName; + if( pTok->IsIdentifier() ) + aDefName = pTok->GetString(); + else + { + ByteString aStr( "unexpected token after define" ); + // set error + SetError( aStr, pTok ); + WriteError( aTokStm ); + return sal_False; + } + + sal_uLong nVal = 0; + sal_Bool bOk = sal_True; + while( bOk ) + { + pTok = aTokStm.GetToken_Next(); + if( pTok->IsIdentifier() ) + { + sal_uLong n; + if( FindId( pTok->GetString(), &n ) ) + nVal += n; + else + bOk = sal_False; + } + else if( pTok->IsChar() ) + { + if( pTok->GetChar() == '-' + || pTok->GetChar() == '/' + || pTok->GetChar() == '*' + || pTok->GetChar() == '&' + || pTok->GetChar() == '|' + || pTok->GetChar() == '^' + || pTok->GetChar() == '~' ) + { + ByteString aStr( "unknown operator '" ); + aStr += pTok->GetChar(); + aStr += "'in define"; + // set error + SetError( aStr, pTok ); + WriteError( aTokStm ); + return sal_False; + } + if( pTok->GetChar() != '+' + && pTok->GetChar() != '(' + && pTok->GetChar() != ')' ) + // only + is allowed, parentheses are immaterial + // because + is commutative + break; + } + else if( pTok->IsInteger() ) + { + nVal += pTok->GetNumber(); + } + else + break; + } + if( bOk ) + { + if( !InsertId( aDefName, nVal ) ) + { + ByteString aStr = "hash table overflow: "; + SetError( aStr, pTok ); + WriteError( aTokStm ); + return sal_False; + } + } + } + else if( pTok->Is( SvHash_include() ) ) + { + pTok = aTokStm.GetToken_Next(); + ByteString aName; + if( pTok->IsString() ) + aName = pTok->GetString(); + else if( pTok->IsChar() && pTok->GetChar() == '<' ) + { + pTok = aTokStm.GetToken_Next(); + while( !pTok->IsEof() + && !(pTok->IsChar() && pTok->GetChar() == '>') ) + { + aName += pTok->GetTokenAsString(); + pTok = aTokStm.GetToken_Next(); + } + if( pTok->IsEof() ) + { + ByteString aStr( "unexpected eof in #include" ); + // set error + SetError( aStr, pTok ); + WriteError( aTokStm ); + return sal_False; + } + } + if( !ReadIdFile( String::CreateFromAscii(aName.GetBuffer()) ) ) + { + ByteString aStr = "cannot read file: "; + aStr += aName; + SetError( aStr, pTok ); + WriteError( aTokStm ); + return sal_False; + } + } + } + else + pTok = aTokStm.GetToken_Next(); + } + } + else + return sal_False; + return sal_True; +} + +SvMetaType * SvIdlDataBase::FindType( const SvMetaType * pPType, + SvMetaTypeMemberList & rList ) +{ + SvMetaType * pType = rList.First(); + while( pType && pPType != pType ) + pType = rList.Next(); + return pType; +} + +SvMetaType * SvIdlDataBase::FindType( const ByteString & rName ) +{ + SvMetaType * pType = aTypeList.First(); + while( pType && rName != pType->GetName() ) + pType = aTypeList.Next(); + return pType; +} + +SvMetaType * SvIdlDataBase::ReadKnownType( SvTokenStream & rInStm ) +{ + sal_Bool bIn = sal_False; + sal_Bool bOut = sal_False; + int nCall0 = CALL_VALUE; + int nCall1 = CALL_VALUE; + sal_Bool bSet = sal_False; // any attribute set + + sal_uInt32 nTokPos = rInStm.Tell(); + SvToken * pTok = rInStm.GetToken_Next(); + + if( pTok->HasHash() ) + { + sal_uInt32 nBeginPos = 0; // can not happen with Tell + while( nBeginPos != rInStm.Tell() ) + { + nBeginPos = rInStm.Tell(); + if( pTok->Is( SvHash_in() ) ) + { + bIn = sal_True; + pTok = rInStm.GetToken_Next(); + bSet = sal_True; + } + if( pTok->Is( SvHash_out() ) ) + { + bOut = sal_True; + pTok = rInStm.GetToken_Next(); + bSet = sal_True; + } + if( pTok->Is( SvHash_inout() ) ) + { + bIn = sal_True; + bOut = sal_True; + pTok = rInStm.GetToken_Next(); + bSet = sal_True; + } + } + } + + if( pTok->IsIdentifier() ) + { + ByteString aName = pTok->GetString(); + SvMetaTypeMemberList & rList = GetTypeList(); + SvMetaType * pType = rList.First(); + while( pType ) + { + if( pType->GetName() == aName ) + break; + pType = rList.Next(); + } + if( pType ) + { + pTok = rInStm.GetToken(); + if( pTok->IsChar() ) + { + if( pTok->GetChar() == '&' || pTok->GetChar() == '*' ) + { + nCall0 = (pTok->GetChar() == '&') ? CALL_REFERENCE : + CALL_POINTER; + rInStm.GetToken_Next(); + pTok = rInStm.GetToken(); + if( pTok->GetChar() == '&' || pTok->GetChar() == '*' ) + { + nCall1 = (pTok->GetChar() == '&') ? CALL_REFERENCE : + CALL_POINTER; + rInStm.GetToken_Next(); + } + bSet = sal_True; + } + } + + if( !bSet ) + // is exactly this type + return pType; + + DBG_ASSERT( aTmpTypeList.First(), "mindestens ein Element" ); + SvMetaTypeRef xType = new SvMetaType( pType->GetName(), 'h', "dummy" ); + xType->SetRef( pType ); + xType->SetIn( bIn ); + xType->SetOut( bOut ); + xType->SetCall0( nCall0 ); + xType->SetCall1( nCall1 ); + + aTmpTypeList.Append( xType ); + return xType; + } + } + rInStm.Seek( nTokPos ); + return NULL; +} + +SvMetaAttribute * SvIdlDataBase::ReadKnownAttr +( + SvTokenStream & rInStm, + SvMetaType * pType /* If pType == NULL, then the type has + still to be read. */ +) +{ + sal_uInt32 nTokPos = rInStm.Tell(); + + if( !pType ) + pType = ReadKnownType( rInStm ); + + if( !pType ) + { + // otherwise SlotId? + SvToken * pTok = rInStm.GetToken_Next(); + if( pTok->IsIdentifier() ) + { + sal_uLong n; + if( FindId( pTok->GetString(), &n ) ) + { + for( sal_uLong i = 0; i < aAttrList.Count(); i++ ) + { + SvMetaAttribute * pAttr = aAttrList.GetObject( i ); + if( pAttr->GetSlotId() == pTok->GetString() ) + return pAttr; + } + } + + ByteString aStr( "Nicht gefunden : " ); + aStr += pTok->GetString(); + OSL_FAIL( aStr.GetBuffer() ); + } + } + + rInStm.Seek( nTokPos ); + return NULL; +} + +SvMetaAttribute* SvIdlDataBase::SearchKnownAttr +( + const SvNumberIdentifier& rId +) +{ + sal_uLong n; + if( FindId( rId, &n ) ) + { + for( sal_uLong i = 0; i < aAttrList.Count(); i++ ) + { + SvMetaAttribute * pAttr = aAttrList.GetObject( i ); + if( pAttr->GetSlotId() == rId ) + return pAttr; + } + } + + return NULL; +} + +SvMetaClass * SvIdlDataBase::ReadKnownClass( SvTokenStream & rInStm ) +{ + sal_uInt32 nTokPos = rInStm.Tell(); + SvToken * pTok = rInStm.GetToken_Next(); + + if( pTok->IsIdentifier() ) + for( sal_uLong n = 0; n < aClassList.Count(); n++ ) + { + SvMetaClass * pClass = aClassList.GetObject( n ); + if( pClass->GetName() == pTok->GetString() ) + return pClass; + } + + rInStm.Seek( nTokPos ); + return NULL; +} + +void SvIdlDataBase::Write( const ByteString & rText ) +{ + if( nVerbosity != 0 ) + fprintf( stdout, "%s", rText.GetBuffer() ); +} + +void SvIdlDataBase::WriteError( const ByteString & rErrWrn, + const ByteString & rFileName, + const rtl::OString& rErrorText, + sal_uLong nRow, sal_uLong nColumn ) const +{ + // error treatment + fprintf( stderr, "\n%s --- %s: ( %ld, %ld )\n", + rFileName.GetBuffer(), rErrWrn.GetBuffer(), nRow, nColumn ); + + if( !rErrorText.isEmpty() ) + { // error set + fprintf( stderr, "\t%s\n", rErrorText.getStr() ); + } +} + +void SvIdlDataBase::WriteError( SvTokenStream & rInStm ) +{ + // error treatment + String aFileName( rInStm.GetFileName() ); + rtl::OStringBuffer aErrorText; + sal_uLong nRow = 0, nColumn = 0; + + rInStm.SeekEnd(); + SvToken *pTok = rInStm.GetToken(); + + // error position + nRow = pTok->GetLine(); + nColumn = pTok->GetColumn(); + + if( aError.IsError() ) + { // error set + // search error token + // error text + if( aError.GetText().Len() ) + { + aErrorText.append(RTL_CONSTASCII_STRINGPARAM("may be <")); + aErrorText.append(aError.GetText()); + } + SvToken * pPrevTok = NULL; + while( pTok != pPrevTok ) + { + pPrevTok = pTok; + if( pTok->GetLine() == aError.nLine + && pTok->GetColumn() == aError.nColumn ) + break; + pTok = rInStm.GetToken_PrevAll(); + } + + // error position + aErrorText.append(RTL_CONSTASCII_STRINGPARAM("> at ( ")); + aErrorText.append(static_cast<sal_Int64>(aError.nLine)); + aErrorText.append(RTL_CONSTASCII_STRINGPARAM(", ")); + aErrorText.append(static_cast<sal_Int64>(aError.nColumn)); + aErrorText.append(RTL_CONSTASCII_STRINGPARAM(" )")); + + // reset error + aError = SvIdlError(); + } + + WriteError( "error", ByteString( aFileName, RTL_TEXTENCODING_UTF8 ), aErrorText.makeStringAndClear(), nRow, nColumn ); + + DBG_ASSERT( pTok, "token must be found" ); + if( !pTok ) + return; + + // look for identifier close by + if( !pTok->IsIdentifier() ) + { + rInStm.GetToken_PrevAll(); + pTok = rInStm.GetToken(); + } + if( pTok && pTok->IsIdentifier() ) + { + ByteString aN = IDLAPP->pHashTable->GetNearString( pTok->GetString() ); + if( aN.Len() ) + fprintf( stderr, "%s versus %s\n", pTok->GetString().GetBuffer(), aN.GetBuffer() ); + } +} + +SvIdlWorkingBase::SvIdlWorkingBase(const SvCommand& rCmd) : SvIdlDataBase(rCmd) +{ +} + +sal_Bool SvIdlWorkingBase::ReadSvIdl( SvTokenStream & rInStm, sal_Bool bImported, const String & rPath ) +{ + aPath = rPath; // only valid for this iteration + SvToken * pTok; + sal_Bool bOk = sal_True; + pTok = rInStm.GetToken(); + // only one import at the very beginning + if( pTok->Is( SvHash_import() ) ) + { + rInStm.GetToken_Next(); + rInStm.Read( '(' ); // optional + pTok = rInStm.GetToken_Next(); + if( pTok->IsString() ) + { + DirEntry aFullName( String::CreateFromAscii( pTok->GetString().GetBuffer() ) ); + if( aFullName.Find( rPath ) ) + { + SvFileStream aStm( aFullName.GetFull(), + STREAM_STD_READ | STREAM_NOCREATE ); + Load( aStm ); + if( aStm.GetError() != SVSTREAM_OK ) + { + if( aStm.GetError() == SVSTREAM_WRONGVERSION ) + { + ByteString aStr( "wrong version, file " ); + aStr += ByteString( aFullName.GetFull(), RTL_TEXTENCODING_UTF8 ); + SetError( aStr, pTok ); + WriteError( rInStm ); + bOk = sal_False; + } + else + { + aStm.Seek( 0 ); + aStm.ResetError(); + SvTokenStream aTokStm( aStm, aFullName.GetFull() ); + bOk = ReadSvIdl( aTokStm, sal_True, rPath ); + } + } + } + else + bOk = sal_False; + } + else + bOk = sal_False; + } + + sal_uInt32 nBeginPos = 0xFFFFFFFF; // can not happen with Tell + + while( bOk && nBeginPos != rInStm.Tell() ) + { + nBeginPos = rInStm.Tell(); + pTok = rInStm.GetToken(); + if( pTok->IsEof() ) + return sal_True; + if( pTok->IsEmpty() ) + bOk = sal_False; + + // only one import at the very beginning + if( pTok->Is( SvHash_module() ) ) + { + SvMetaModuleRef aModule = new SvMetaModule( rInStm.GetFileName(), bImported ); + if( aModule->ReadSvIdl( *this, rInStm ) ) + GetModuleList().Append( aModule ); + else + bOk = sal_False; + } + else + bOk = sal_False; + } + if( !bOk || !pTok->IsEof() ) + { + // error treatment + WriteError( rInStm ); + return sal_False; + } + return sal_True; +} + +sal_Bool SvIdlWorkingBase::WriteSvIdl( SvStream & rOutStm ) +{ + if( rOutStm.GetError() != SVSTREAM_OK ) + return sal_False; + + SvStringHashList aList; + if( GetIdTable() ) + { + GetIdTable()->FillHashList( &aList ); + for ( size_t i = 0, n = aList.size(); i < n; ++i ) + { + SvStringHashEntry* pEntry = aList[ i ]; + rOutStm << "#define " << pEntry->GetName().GetBuffer() + << '\t' + << rtl::OString::valueOf(static_cast<sal_Int64>( + pEntry->GetValue())).getStr() + << endl; + } + } + + for( sal_uLong n = 0; n < GetModuleList().Count(); n++ ) + { + SvMetaModule * pModule = GetModuleList().GetObject( n ); + pModule->WriteSvIdl( *this, rOutStm, 0 ); + } + return sal_True; +} + +sal_Bool SvIdlWorkingBase::WriteSfx( SvStream & rOutStm ) +{ + if( rOutStm.GetError() != SVSTREAM_OK ) + return sal_False; + + // reset all tmp variables for writing + WriteReset(); + SvMemoryStream aTmpStm( 256000, 256000 ); + sal_uLong n; + for( n = 0; n < GetModuleList().Count(); n++ ) + { + SvMetaModule * pModule = GetModuleList().GetObject( n ); + if( !pModule->IsImported() ) + pModule->WriteSfx( *this, aTmpStm ); + aTmpStm.Seek( 0 ); + } + for( n = 0; n < aUsedTypes.Count(); n++ ) + { + SvMetaType * pType = aUsedTypes.GetObject( n ); + pType->WriteSfx( *this, rOutStm ); + } + aUsedTypes.Clear(); + rOutStm << aTmpStm; + return sal_True; +} + +sal_Bool SvIdlWorkingBase::WriteHelpIds( SvStream& rOutStm ) +{ + if( rOutStm.GetError() != SVSTREAM_OK ) + return sal_False; + + Table aIdTable; + sal_uLong n; + for( n = 0; n < GetModuleList().Count(); n++ ) + { + SvMetaModule * pModule = GetModuleList().GetObject( n ); + pModule->WriteHelpIds( *this, rOutStm, &aIdTable ); + } + + const SvMetaAttributeMemberList & rAttrList = GetAttrList(); + for( n = 0; n < rAttrList.Count(); n++ ) + { + SvMetaAttribute * pAttr = rAttrList.GetObject( n ); + pAttr->WriteHelpId( *this, rOutStm, &aIdTable ); + } + + return sal_True; +} + +sal_Bool SvIdlWorkingBase::WriteSfxItem( SvStream & ) +{ + return sal_False; +} + +void SvIdlDataBase::StartNewFile( const String& rName ) +{ + bExport = ( aExportFile.EqualsIgnoreCaseAscii( rName ) ); +} + +void SvIdlDataBase::AppendAttr( SvMetaAttribute *pAttr ) +{ + aAttrList.Append( pAttr ); + if ( bExport ) + pAttr->SetNewAttribute( sal_True ); +} + +sal_Bool SvIdlWorkingBase::WriteCSV( SvStream& rStrm ) +{ + SvMetaAttributeMemberList &rList = GetAttrList(); + sal_uLong nCount = rList.Count(); + for ( sal_uLong n=0; n<nCount; n++ ) + { + if ( rList.GetObject(n)->IsNewAttribute() ) + { + rList.GetObject(n)->WriteCSV( *this, rStrm ); + } + } + + if ( rStrm.GetError() != SVSTREAM_OK ) + return sal_False; + else + return sal_True; +} + +sal_Bool SvIdlWorkingBase::WriteDocumentation( SvStream & rOutStm ) +{ + if( rOutStm.GetError() != SVSTREAM_OK ) + return sal_False; + + for( sal_uLong n = 0; n < GetModuleList().Count(); n++ ) + { + SvMetaModule * pModule = GetModuleList().GetObject( n ); + if( !pModule->IsImported() ) + pModule->Write( *this, rOutStm, 0, WRITE_DOCU ); + } + return sal_True; +} + + + +#endif // IDL_COMPILER + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/idl/source/prj/globals.cxx b/idl/source/prj/globals.cxx new file mode 100644 index 000000000000..cf79f7c02296 --- /dev/null +++ b/idl/source/prj/globals.cxx @@ -0,0 +1,176 @@ +/* -*- 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_idl.hxx" + +#include <tools/shl.hxx> + +#include <globals.hxx> +#include <database.hxx> + +IdlDll * GetIdlApp() +{ + if( !(*(IdlDll**)GetAppData(SHL_IDL)) ) + { + (*(IdlDll**)GetAppData(SHL_IDL)) = new IdlDll(); + } + return (*(IdlDll**)GetAppData(SHL_IDL)); +} + +IdlDll::IdlDll() + : pHashTable( NULL ) + , pClassMgr( NULL ) + , pGlobalNames( NULL ) + +{ + pClassMgr = new SvClassManager(); + // File OBJECT.HXX: + pClassMgr->SV_CLASS_REGISTER( SvMetaAttribute ); + pClassMgr->SV_CLASS_REGISTER( SvMetaClass ); + //File SLOT.HXX: + pClassMgr->SV_CLASS_REGISTER( SvMetaSlot ); + //File MODULE.HXX: + pClassMgr->SV_CLASS_REGISTER( SvMetaModule ); + //File BASOBJ.HXX: + pClassMgr->SV_CLASS_REGISTER( SvMetaObject ); + pClassMgr->SV_CLASS_REGISTER( SvMetaName ); + pClassMgr->SV_CLASS_REGISTER( SvMetaExtern ); + pClassMgr->SV_CLASS_REGISTER( SvMetaReference ); + //File TYPES.HXX: + pClassMgr->SV_CLASS_REGISTER( SvMetaType ); + pClassMgr->SV_CLASS_REGISTER( SvMetaTypeString ); + pClassMgr->SV_CLASS_REGISTER( SvMetaEnumValue ); + pClassMgr->SV_CLASS_REGISTER( SvMetaTypeEnum ); + pClassMgr->SV_CLASS_REGISTER( SvMetaTypevoid ); + pClassMgr->SV_CLASS_REGISTER( SvClassElement ); +} + +IdlDll::~IdlDll() +{ + delete pGlobalNames; + delete pClassMgr; + delete pHashTable; +} + +inline SvStringHashEntry * INS( const ByteString & rName ) +{ + sal_uInt32 nIdx; + IDLAPP->pHashTable->Insert( rName, &nIdx ); + return (SvStringHashEntry * )IDLAPP->pHashTable->Get( nIdx ); +} +#define A_ENTRY( Name ) , MM_##Name( INS( #Name ) ) + +SvGlobalHashNames::SvGlobalHashNames() + : MM_Name( INS( "Name" ) ) + , MM_module( INS( "module" ) ) + , MM_interface( INS( "interface" ) ) + , MM_in( INS( "in" ) ) + , MM_out( INS( "out" ) ) + , MM_inout( INS( "inout" ) ) + , MM_String( INS( "String" ) ) + , MM_UCHAR( INS( "UCHAR" ) ) + , MM_USHORT( INS( "USHORT" ) ) + , MM_uuid( INS( "uuid" ) ) + , MM_HelpContext( INS( "HelpContext" ) ) + , MM_HelpText( INS( "HelpText" ) ) + , MM_void( INS( "void" ) ) + , MM_shell( INS( "shell" ) ) + , MM_Get( INS( "Get" ) ) + , MM_Set( INS( "Set" ) ) + , MM_SlotId( INS( "SlotId" ) ) + , MM_HasCoreId( INS( "HasCoreId" ) ) + , MM_Cachable( INS( "Cachable" ) ) + , MM_Toggle( INS( "Toggle" ) ) + , MM_AutoUpdate( INS( "AutoUpdate" ) ) + , MM_Synchron( INS( "Synchron" ) ) + , MM_Asynchron( INS( "Asynchron" ) ) + A_ENTRY(RecordPerSet) + A_ENTRY(RecordPerItem) + A_ENTRY(RecordManual) + A_ENTRY(NoRecord) + A_ENTRY(RecordAbsolute) + A_ENTRY(enum) + A_ENTRY(UINT16) + A_ENTRY(INT16) + A_ENTRY(UINT32) + A_ENTRY(INT32) + A_ENTRY(int) + A_ENTRY(BOOL) + A_ENTRY(char) + A_ENTRY(BYTE) + A_ENTRY(float) + A_ENTRY(double) + A_ENTRY(item) + A_ENTRY(PseudoSlots) + A_ENTRY(map) + A_ENTRY(Default) + A_ENTRY(HelpFile) + A_ENTRY(Version) + A_ENTRY(import) + A_ENTRY(SlotIdFile) + A_ENTRY(SvName) + A_ENTRY(SbxName) + A_ENTRY(ItemName) + A_ENTRY(OdlName) + A_ENTRY(include) + A_ENTRY(ExecMethod) + A_ENTRY(StateMethod) + A_ENTRY(GroupId) + A_ENTRY(HasDialog) + A_ENTRY(TypeLibFile) + A_ENTRY(Export) + A_ENTRY(Automation) + A_ENTRY(PseudoPrefix) + A_ENTRY(define) + A_ENTRY(MenuConfig) + A_ENTRY(ToolBoxConfig) + A_ENTRY(StatusBarConfig) + A_ENTRY(AccelConfig) + A_ENTRY(AllConfig) + A_ENTRY(FastCall) + A_ENTRY(SbxObject) + A_ENTRY(Container) + A_ENTRY(ImageRotation) + A_ENTRY(ImageReflection) + A_ENTRY(IsCollection) + A_ENTRY(ReadOnlyDoc) + A_ENTRY(ConfigName) + A_ENTRY(union) + A_ENTRY(struct) + A_ENTRY(typedef) + A_ENTRY(Readonly) + A_ENTRY(SlotType) + A_ENTRY(ModulePrefix) + A_ENTRY(DisableFlags) + A_ENTRY(Hidden) + A_ENTRY(Description) + A_ENTRY(UnoName) +{} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/idl/source/prj/makefile.mk b/idl/source/prj/makefile.mk new file mode 100755 index 000000000000..c33d2e9f3d7a --- /dev/null +++ b/idl/source/prj/makefile.mk @@ -0,0 +1,49 @@ +#************************************************************************* +# +# 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. +# +#************************************************************************* + +PRJ=..$/.. + +PRJNAME=idl +TARGET=prj +ENABLE_EXCEPTIONS=TRUE + +# --- Settings ----------------------------------------------------------- + +.INCLUDE : settings.mk + +CDEFS+=-DIDL_COMPILER +# --- Files -------------------------------------------------------------- + +OBJFILES= $(OBJ)$/command.obj \ + $(OBJ)$/svidl.obj \ + $(OBJ)$/globals.obj \ + $(OBJ)$/database.obj + +# --- Targets ------------------------------------------------------------ + +.INCLUDE : target.mk + diff --git a/idl/source/prj/svidl.cxx b/idl/source/prj/svidl.cxx new file mode 100644 index 000000000000..0c7a66e7aa70 --- /dev/null +++ b/idl/source/prj/svidl.cxx @@ -0,0 +1,368 @@ +/* -*- 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_idl.hxx" + +#include <stdlib.h> +#include <stdio.h> +#include <database.hxx> +#include <globals.hxx> +#include <command.hxx> +#include <tools/fsys.hxx> +#include <tools/string.hxx> + +#define BR 0x8000 +sal_Bool FileMove_Impl( const String & rFile1, const String & rFile2, sal_Bool bImmerVerschieben ) +{ + //printf( "Move from %s to %s\n", rFile2.GetStr(), rFile1.GetStr() ); + sal_uLong nC1 = 0; + sal_uLong nC2 = 1; + if( !bImmerVerschieben ) + { + SvFileStream aOutStm1( rFile1, STREAM_STD_READ ); + SvFileStream aOutStm2( rFile2, STREAM_STD_READ ); + if( aOutStm1.GetError() == SVSTREAM_OK ) + { + sal_uInt8 * pBuf1 = new sal_uInt8[ BR ]; + sal_uInt8 * pBuf2 = new sal_uInt8[ BR ]; + nC1 = aOutStm1.Read( pBuf1, BR ); + nC2 = aOutStm2.Read( pBuf2, BR ); + while( nC1 == nC2 ) + { + if( memcmp( pBuf1, pBuf2, nC1 ) ) + { + nC1++; + break; + } + else + { + if( 0x8000 != nC1 ) + break; + nC1 = aOutStm1.Read( pBuf1, BR ); + nC2 = aOutStm2.Read( pBuf2, BR ); + } + } + delete[] pBuf1; + delete[] pBuf2; + } + } + DirEntry aF2( rFile2 ); + if( nC1 != nC2 ) + {// something has changed + DirEntry aF1( rFile1 ); + aF1.Kill(); + // move file + if( aF2.MoveTo( aF1 ) ) + { + // delete both files + aF1.Kill(); + aF2.Kill(); + return sal_False; + } + return sal_True; + } + return 0 == aF2.Kill(); +} + +#if defined( UNX ) || defined (__MINGW32__) +int main ( int argc, char ** argv) +{ +#else +int cdecl main ( int argc, char ** argv) +{ +#endif + + String aTmpListFile; + String aTmpSlotMapFile; + String aTmpSfxItemFile; + String aTmpDataBaseFile; + String aTmpCallingFile; + String aTmpSrcFile; + String aTmpCxxFile; + String aTmpHxxFile; + String aTmpHelpIdFile; + String aTmpCSVFile; + String aTmpDocuFile; + + SvCommand aCommand( argc, argv ); + + if( aCommand.nVerbosity != 0 ) + printf( "StarView Interface Definition Language (IDL) Compiler 3.0\n" ); + + Init(); + SvIdlWorkingBase * pDataBase = new SvIdlWorkingBase(aCommand); + + int nExit = 0; + if( aCommand.aExportFile.Len() ) + { + DirEntry aDE( aCommand.aExportFile ); + pDataBase->SetExportFile( aDE.GetName() ); + } + + if( ReadIdl( pDataBase, aCommand ) ) + { + if( nExit == 0 && aCommand.aDocuFile.Len() ) + { + DirEntry aDE( aCommand.aDocuFile ); + aDE.ToAbs(); + aTmpDocuFile = aDE.GetPath().TempName().GetFull(); + SvFileStream aOutStm( aTmpDocuFile, STREAM_READWRITE | STREAM_TRUNC ); + if( !pDataBase->WriteDocumentation( aOutStm ) ) + { + nExit = -1; + ByteString aStr = "cannot write documentation file: "; + aStr += ByteString( aCommand.aDocuFile, RTL_TEXTENCODING_UTF8 ); + fprintf( stderr, "%s\n", aStr.GetBuffer() ); + } + } + if( nExit == 0 && aCommand.aListFile.Len() ) + { + DirEntry aDE( aCommand.aListFile ); + aDE.ToAbs(); + aTmpListFile = aDE.GetPath().TempName().GetFull(); + SvFileStream aOutStm( aTmpListFile, STREAM_READWRITE | STREAM_TRUNC ); + if( !pDataBase->WriteSvIdl( aOutStm ) ) + { + nExit = -1; + ByteString aStr = "cannot write list file: "; + aStr += ByteString( aCommand.aListFile, RTL_TEXTENCODING_UTF8 ); + fprintf( stderr, "%s\n", aStr.GetBuffer() ); + } + } + if( nExit == 0 && aCommand.aSlotMapFile.Len() ) + { + DirEntry aDE( aCommand.aSlotMapFile ); + aDE.ToAbs(); + aTmpSlotMapFile = aDE.GetPath().TempName().GetFull(); + SvFileStream aOutStm( aTmpSlotMapFile, STREAM_READWRITE | STREAM_TRUNC ); + if( !pDataBase->WriteSfx( aOutStm ) ) + { + nExit = -1; + ByteString aStr = "cannot write slotmap file: "; + aStr += ByteString( aCommand.aSlotMapFile, RTL_TEXTENCODING_UTF8 ); + fprintf( stderr, "%s\n", aStr.GetBuffer() ); + } + } + if( nExit == 0 && aCommand.aHelpIdFile.Len() ) + { + DirEntry aDE( aCommand.aHelpIdFile ); + aDE.ToAbs(); + aTmpHelpIdFile = aDE.GetPath().TempName().GetFull(); + SvFileStream aStm( aTmpHelpIdFile, STREAM_READWRITE | STREAM_TRUNC ); + if (!pDataBase->WriteHelpIds( aStm ) ) + { + nExit = -1; + ByteString aStr = "cannot write help ID file: "; + aStr += ByteString( aCommand.aHelpIdFile, RTL_TEXTENCODING_UTF8 ); + fprintf( stderr, "%s\n", aStr.GetBuffer() ); + } + } + if( nExit == 0 && aCommand.aCSVFile.Len() ) + { + DirEntry aDE( aCommand.aCSVFile ); + aDE.ToAbs(); + aTmpCSVFile = aDE.GetPath().TempName().GetFull(); + SvFileStream aStm( aTmpCSVFile, STREAM_READWRITE | STREAM_TRUNC ); + if (!pDataBase->WriteCSV( aStm ) ) + { + nExit = -1; + ByteString aStr = "cannot write CSV file: "; + aStr += ByteString( aCommand.aCSVFile, RTL_TEXTENCODING_UTF8 ); + fprintf( stderr, "%s\n", aStr.GetBuffer() ); + } + } + if( nExit == 0 && aCommand.aSfxItemFile.Len() ) + { + DirEntry aDE( aCommand.aSfxItemFile ); + aDE.ToAbs(); + aTmpSfxItemFile = aDE.GetPath().TempName().GetFull(); + SvFileStream aOutStm( aTmpSfxItemFile, STREAM_READWRITE | STREAM_TRUNC ); + if( !pDataBase->WriteSfxItem( aOutStm ) ) + { + nExit = -1; + ByteString aStr = "cannot write item file: "; + aStr += ByteString( aCommand.aSfxItemFile, RTL_TEXTENCODING_UTF8 ); + fprintf( stderr, "%s\n", aStr.GetBuffer() ); + } + } + if( nExit == 0 && aCommand.aDataBaseFile.Len() ) + { + DirEntry aDE( aCommand.aDataBaseFile ); + aDE.ToAbs(); + aTmpDataBaseFile = aDE.GetPath().TempName().GetFull(); + SvFileStream aOutStm( aTmpDataBaseFile, STREAM_READWRITE | STREAM_TRUNC ); + pDataBase->Save( aOutStm, aCommand.nFlags ); + if( aOutStm.GetError() != SVSTREAM_OK ) + { + nExit = -1; + ByteString aStr = "cannot write database file: "; + aStr += ByteString( aCommand.aDataBaseFile, RTL_TEXTENCODING_UTF8 ); + fprintf( stderr, "%s\n", aStr.GetBuffer() ); + } + } + } + else + nExit = -1; + + if( nExit == 0 ) + { + sal_Bool bErr = sal_False; + sal_Bool bDoMove = aCommand.aTargetFile.Len() == 0; + String aErrFile, aErrFile2; + if( !bErr && aCommand.aListFile.Len() ) + { + bErr |= !FileMove_Impl( aCommand.aListFile, aTmpListFile, bDoMove ); + if( bErr ) { + aErrFile = aCommand.aListFile; + aErrFile2 = aTmpListFile; + } + } + if( !bErr && aCommand.aSlotMapFile.Len() ) + { + bErr |= !FileMove_Impl( aCommand.aSlotMapFile, aTmpSlotMapFile, bDoMove ); + if( bErr ) { + aErrFile = aCommand.aSlotMapFile; + aErrFile2 = aTmpSlotMapFile; + } + } + if( !bErr && aCommand.aSfxItemFile.Len() ) + { + bErr |= !FileMove_Impl( aCommand.aSfxItemFile, aTmpSfxItemFile, bDoMove ); + if( bErr ) { + aErrFile = aCommand.aSfxItemFile; + aErrFile2 = aTmpSfxItemFile; + } + } + if( !bErr && aCommand.aDataBaseFile.Len() ) + { + bErr |= !FileMove_Impl( aCommand.aDataBaseFile, aTmpDataBaseFile, bDoMove ); + if( bErr ) { + aErrFile = aCommand.aDataBaseFile; + aErrFile2 = aTmpDataBaseFile; + } + } + if( !bErr && aCommand.aCallingFile.Len() ) + { + bErr |= !FileMove_Impl( aCommand.aCallingFile, aTmpCallingFile, bDoMove ); + if( bErr ) { + aErrFile = aCommand.aCallingFile; + aErrFile2 = aTmpCallingFile; + } + } + if( !bErr && aCommand.aCxxFile.Len() ) + { + bErr |= !FileMove_Impl( aCommand.aCxxFile, aTmpCxxFile, bDoMove ); + if( bErr ) { + aErrFile = aCommand.aCxxFile; + aErrFile2 = aTmpCxxFile; + } + } + if( !bErr && aCommand.aHxxFile.Len() ) + { + bErr |= !FileMove_Impl( aCommand.aHxxFile, aTmpHxxFile, bDoMove ); + if( bErr ) { + aErrFile = aCommand.aHxxFile; + aErrFile2 = aTmpHxxFile; + } + } + if( !bErr && aCommand.aHelpIdFile.Len() ) + { + bErr |= !FileMove_Impl( aCommand.aHelpIdFile, aTmpHelpIdFile, bDoMove ); + if( bErr ) { + aErrFile = aCommand.aHelpIdFile; + aErrFile2 = aTmpHelpIdFile; + } + } + if( !bErr && aCommand.aCSVFile.Len() ) + { + bErr |= !FileMove_Impl( aCommand.aCSVFile, aTmpCSVFile, bDoMove ); + if( bErr ) { + aErrFile = aCommand.aCSVFile; + aErrFile2 = aTmpCSVFile; + } + } + if( !bErr && aCommand.aDocuFile.Len() ) + { + bErr |= !FileMove_Impl( aCommand.aDocuFile, aTmpDocuFile, bDoMove ); + if( bErr ) { + aErrFile = aCommand.aDocuFile; + aErrFile2 = aTmpDocuFile; + } + } + + if( bErr ) + { + nExit = -1; + ByteString aStr = "cannot move file from: "; + aStr += ByteString( aErrFile2, RTL_TEXTENCODING_UTF8 ); + aStr += "\n to file: "; + aStr += ByteString( aErrFile, RTL_TEXTENCODING_UTF8 ); + fprintf( stderr, "%s\n", aStr.GetBuffer() ); + } + else + { + if( aCommand.aTargetFile.Len() ) + { +#ifdef ICC + DirEntry aT(aCommand.aTargetFile); + aT.Kill(); +#endif + // stamp file, because idl passed through correctly + SvFileStream aOutStm( aCommand.aTargetFile, + STREAM_READWRITE | STREAM_TRUNC ); + } + } + } + + if( nExit != 0 ) + { + if( aCommand.aListFile.Len() ) + DirEntry( aTmpListFile ).Kill(); + if( aCommand.aSlotMapFile.Len() ) + DirEntry( aTmpSlotMapFile ).Kill(); + if( aCommand.aSfxItemFile.Len() ) + DirEntry( aTmpSfxItemFile ).Kill(); + if( aCommand.aDataBaseFile.Len() ) + DirEntry( aTmpDataBaseFile ).Kill(); + if( aCommand.aCallingFile.Len() ) + DirEntry( aTmpCallingFile ).Kill(); + if( aCommand.aCxxFile.Len() ) + DirEntry( aTmpCxxFile ).Kill(); + if( aCommand.aHxxFile.Len() ) + DirEntry( aTmpHxxFile ).Kill(); + } + + delete pDataBase; + DeInit(); + if( nExit != 0 ) + fprintf( stderr, "svidl terminated with errors\n" ); + return nExit; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/idl/source/svidl.dat b/idl/source/svidl.dat Binary files differnew file mode 100755 index 000000000000..4750475c7462 --- /dev/null +++ b/idl/source/svidl.dat diff --git a/idl/util/makefile.mk b/idl/util/makefile.mk new file mode 100755 index 000000000000..27cc52ef276e --- /dev/null +++ b/idl/util/makefile.mk @@ -0,0 +1,68 @@ +#************************************************************************* +# +# 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. +# +#************************************************************************* + +PRJ=.. + +PRJNAME=idl +TARGET=idl + +TARGETTYPE=CUI + +# --- Settings ----------------------------------------------------------- + +.INCLUDE : settings.mk + +# --- Files -------------------------------------------------------------- + +LIB1TARGET= $(LB)$/$(TARGET).lib +LIB1FILES = $(LB)$/prj.lib \ + $(LB)$/objects.lib \ + $(LB)$/cmptools.lib + +APP1TARGET= svidl +APP1RPATH=NONE + +APP1STDLIBS= \ + $(TOOLSLIB) \ + $(SALLIB) + +APP1LIBS= $(LB)$/$(TARGET).lib +.IF "$(GUI)" != "UNX" +.IF "$(COM)"!="GCC" +APP1OBJS= $(OBJ)$/svidl.obj \ + $(OBJ)$/command.obj +.ENDIF +.ENDIF + +.IF "$(OS)"=="LINUX" || "$(OS)"=="FREEBSD" +APP1STDLIBS+=-lcrypt +.ENDIF + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk + |