diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2013-03-26 14:59:34 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2013-03-27 09:36:54 +0100 |
commit | bb1f0c667f8b38bf27818fe1608beb4295d9c429 (patch) | |
tree | 36e98fecb1fb3fed8e28155763d858620c70fce1 /unodevtools | |
parent | aaaeec55c6ca86a4871a59e058f80498e898b29b (diff) |
Clean up codemaker/typemanager.hxx
Change-Id: I650efd6780070410eaf34993dd41ed1b8ada7c9a
Diffstat (limited to 'unodevtools')
-rw-r--r-- | unodevtools/Executable_skeletonmaker.mk | 1 | ||||
-rw-r--r-- | unodevtools/inc/unodevtools/options.hxx | 7 | ||||
-rw-r--r-- | unodevtools/inc/unodevtools/typemanager.hxx | 83 | ||||
-rw-r--r-- | unodevtools/source/skeletonmaker/cppcompskeleton.cxx | 20 | ||||
-rw-r--r-- | unodevtools/source/skeletonmaker/cpptypemaker.cxx | 36 | ||||
-rw-r--r-- | unodevtools/source/skeletonmaker/javacompskeleton.cxx | 10 | ||||
-rw-r--r-- | unodevtools/source/skeletonmaker/javatypemaker.cxx | 38 | ||||
-rw-r--r-- | unodevtools/source/skeletonmaker/skeletoncommon.cxx | 42 | ||||
-rw-r--r-- | unodevtools/source/skeletonmaker/skeletoncommon.hxx | 15 | ||||
-rw-r--r-- | unodevtools/source/skeletonmaker/skeletoncpp.hxx | 26 | ||||
-rw-r--r-- | unodevtools/source/skeletonmaker/skeletonjava.hxx | 24 | ||||
-rw-r--r-- | unodevtools/source/skeletonmaker/skeletonmaker.cxx | 12 | ||||
-rw-r--r-- | unodevtools/source/unodevtools/typemanager.cxx | 270 |
13 files changed, 116 insertions, 468 deletions
diff --git a/unodevtools/Executable_skeletonmaker.mk b/unodevtools/Executable_skeletonmaker.mk index 433ba38b85ff..1d00f3bcf978 100644 --- a/unodevtools/Executable_skeletonmaker.mk +++ b/unodevtools/Executable_skeletonmaker.mk @@ -54,7 +54,6 @@ $(eval $(call gb_Executable_use_static_libraries,uno-skeletonmaker,\ $(eval $(call gb_Executable_add_exception_objects,uno-skeletonmaker,\ unodevtools/source/unodevtools/options \ unodevtools/source/unodevtools/typeblob \ - unodevtools/source/unodevtools/typemanager \ unodevtools/source/skeletonmaker/skeletonmaker \ unodevtools/source/skeletonmaker/skeletoncommon \ unodevtools/source/skeletonmaker/javatypemaker \ diff --git a/unodevtools/inc/unodevtools/options.hxx b/unodevtools/inc/unodevtools/options.hxx index a321bc9db026..7c1a9c1d5236 100644 --- a/unodevtools/inc/unodevtools/options.hxx +++ b/unodevtools/inc/unodevtools/options.hxx @@ -20,11 +20,10 @@ #ifndef INCLUDED_UNODEVTOOLS_OPTIONS_HXX #define INCLUDED_UNODEVTOOLS_OPTIONS_HXX -#include <rtl/ustrbuf.hxx> +#include "sal/config.h" -namespace com { namespace sun { namespace star { namespace uno { -class RuntimeException; -} } } } +#include <com/sun/star/uno/RuntimeException.hpp> +#include <rtl/ustrbuf.hxx> namespace unodevtools { diff --git a/unodevtools/inc/unodevtools/typemanager.hxx b/unodevtools/inc/unodevtools/typemanager.hxx deleted file mode 100644 index c2807762cec2..000000000000 --- a/unodevtools/inc/unodevtools/typemanager.hxx +++ /dev/null @@ -1,83 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_UNODEVTOOLS_TYPEMANAGER_HXX -#define INCLUDED_UNODEVTOOLS_TYPEMANAGER_HXX - -#include <codemaker/typemanager.hxx> -#include <com/sun/star/container/XHierarchicalNameAccess.hpp> - -#include <boost/unordered_map.hpp> -#include <vector> - -class RegistryKey; - -namespace typereg { class Reader; } - -typedef boost::unordered_map -< - ::rtl::OString, // Typename - RTTypeClass, // TypeClass - HashString, - EqualString -> T2TypeClassMap; - -namespace unodevtools { - -struct UnoTypeManagerImpl -{ - UnoTypeManagerImpl() {} - - T2TypeClassMap m_t2TypeClass; - ::com::sun::star::uno::Reference< - ::com::sun::star::container::XHierarchicalNameAccess> m_tdmgr; -}; - -class UnoTypeManager : public TypeManager -{ -public: - UnoTypeManager(); - ~UnoTypeManager(); - - UnoTypeManager( const UnoTypeManager& value ) - : TypeManager(value) - , m_pImpl( value.m_pImpl ) - {} - - sal_Bool init(const ::std::vector< ::rtl::OUString > registries); - - sal_Bool isValidType(const ::rtl::OString& name) const; - ::rtl::OString getTypeName(RegistryKey& rTypeKey) const; - typereg::Reader getTypeReader( - const ::rtl::OString& name, sal_Bool * pIsExtraType = 0 ) const; - typereg::Reader getTypeReader(RegistryKey& rTypeKey) const; - RTTypeClass getTypeClass(const ::rtl::OString& name) const; - RTTypeClass getTypeClass(RegistryKey& rTypeKey) const; - -protected: - void release(); - - UnoTypeManagerImpl* m_pImpl; -}; - -} - -#endif // _UNODEVTOOLS_TYPEMANAGER_HXX_ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/unodevtools/source/skeletonmaker/cppcompskeleton.cxx b/unodevtools/source/skeletonmaker/cppcompskeleton.cxx index 8f42cd4d575a..5604962bce0a 100644 --- a/unodevtools/source/skeletonmaker/cppcompskeleton.cxx +++ b/unodevtools/source/skeletonmaker/cppcompskeleton.cxx @@ -499,7 +499,7 @@ void generateXDispatchProvider(std::ostream& o, void generateAddinConstructorAndHelper(std::ostream& o, ProgramOptions const & options, - TypeManager const & manager, const OString & classname, + rtl::Reference< TypeManager > const & manager, const OString & classname, const boost::unordered_set< OString, OStringHash >& interfaces) { o << classname << "::" << classname @@ -575,7 +575,7 @@ void generateAddinConstructorAndHelper(std::ostream& o, void generateMemberInitialization(std::ostream& o, ProgramOptions const & options, - TypeManager const & manager, + rtl::Reference< TypeManager > const & manager, AttributeInfo const & members) { if (!members.empty()) { @@ -602,7 +602,7 @@ void generateMemberInitialization(std::ostream& o, void generateMemberDeclaration(std::ostream& o, ProgramOptions const & options, - TypeManager const & manager, + rtl::Reference< TypeManager > const & manager, AttributeInfo const & members) { for (AttributeInfo::const_iterator i(members.begin()); @@ -617,7 +617,7 @@ void generateMemberDeclaration(std::ostream& o, OString generateClassDefinition(std::ostream& o, ProgramOptions const & options, - TypeManager const & manager, + rtl::Reference< TypeManager > const & manager, OString const & classname, boost::unordered_set< OString, OStringHash > const & interfaces, AttributeInfo const & properties, @@ -705,7 +705,7 @@ OString generateClassDefinition(std::ostream& o, codemaker::GeneratedTypeSet generated; while (it != interfaces.end()) { - typereg::Reader reader(manager.getTypeReader((*it).replace('.','/'))); + typereg::Reader reader(manager->getTypeReader((*it).replace('.','/'))); printMethods(o, options, manager, reader, generated, "", "", " ", true, propertyhelper); ++it; @@ -880,7 +880,7 @@ void generateXServiceInfoBodies(std::ostream& o, void generateMethodBodies(std::ostream& o, ProgramOptions const & options, - TypeManager const & manager, + rtl::Reference< TypeManager > const & manager, boost::unordered_set< OString, OStringHash > const & interfaces, OString const & classname, OString const & comphelpernamespace, @@ -895,7 +895,7 @@ void generateMethodBodies(std::ostream& o, generateXServiceInfoBodies(o, name, comphelpernamespace); generated.add(*iter); } else { - typereg::Reader reader(manager.getTypeReader((*iter).replace('.','/'))); + typereg::Reader reader(manager->getTypeReader((*iter).replace('.','/'))); printMethods(o, options, manager, reader, generated, "_", name, "", true, propertyhelper); } @@ -905,7 +905,7 @@ void generateMethodBodies(std::ostream& o, void generateQueryInterface(std::ostream& o, ProgramOptions const & options, - TypeManager const & manager, + rtl::Reference< TypeManager > const & manager, const boost::unordered_set< OString, OStringHash >& interfaces, OString const & parentname, OString const & classname, @@ -954,7 +954,7 @@ void generateQueryInterface(std::ostream& o, } void generateSkeleton(ProgramOptions const & options, - TypeManager const & manager, + rtl::Reference< TypeManager > const & manager, std::vector< OString > const & types) { // special handling of calc add-ins @@ -1093,7 +1093,7 @@ void generateSkeleton(ProgramOptions const & options, } void generateCalcAddin(ProgramOptions const & options, - TypeManager const & manager, + rtl::Reference< TypeManager > const & manager, std::vector< OString > const & types) { boost::unordered_set< OString, OStringHash > interfaces; diff --git a/unodevtools/source/skeletonmaker/cpptypemaker.cxx b/unodevtools/source/skeletonmaker/cpptypemaker.cxx index e95b5039934f..640d0545464d 100644 --- a/unodevtools/source/skeletonmaker/cpptypemaker.cxx +++ b/unodevtools/source/skeletonmaker/cpptypemaker.cxx @@ -28,7 +28,7 @@ using namespace ::codemaker::cpp; namespace skeletonmaker { namespace cpp { void printType(std::ostream & o, - ProgramOptions const & options, TypeManager const & manager, + ProgramOptions const & options, rtl::Reference< TypeManager > const & manager, codemaker::UnoType::Sort sort, RTTypeClass typeClass, OString const & name, sal_Int32 rank, std::vector< OString > const & arguments, short referenceType, @@ -63,7 +63,7 @@ void printType(std::ostream & o, if (defaultvalue && referenceType == 16) { if (typeClass == RT_TYPE_ENUM) { - typereg::Reader reader(manager.getTypeReader(name)); + typereg::Reader reader(manager->getTypeReader(name)); o << name.copy(name.lastIndexOf('/')) << "_" << codemaker::convertString(reader.getFieldName(0)); @@ -122,7 +122,7 @@ void printType(std::ostream & o, } void printType(std::ostream & o, - ProgramOptions const & options, TypeManager const & manager, + ProgramOptions const & options, rtl::Reference< TypeManager > const & manager, OString const & type, short referenceType, bool defaultvalue) { RTTypeClass typeClass; @@ -137,7 +137,7 @@ void printType(std::ostream & o, } bool printConstructorParameters(std::ostream & o, - ProgramOptions const & options, TypeManager const & manager, + ProgramOptions const & options, rtl::Reference< TypeManager > const & manager, typereg::Reader const & reader, typereg::Reader const & outerReader, std::vector< OString > const & arguments) { @@ -145,7 +145,7 @@ bool printConstructorParameters(std::ostream & o, if (reader.getSuperTypeCount() != 0) { OString super( codemaker::convertString(reader.getSuperTypeName(0))); - typereg::Reader superReader(manager.getTypeReader(super)); + typereg::Reader superReader(manager->getTypeReader(super)); if (!superReader.isValid()) throw CannotDumpException("Bad type library entity " + super); @@ -186,7 +186,7 @@ bool printConstructorParameters(std::ostream & o, } void printConstructor(std::ostream & o, - ProgramOptions const & options, TypeManager const & manager, + ProgramOptions const & options, rtl::Reference< TypeManager > const & manager, typereg::Reader const & reader, std::vector< OString > const & arguments) { @@ -199,7 +199,7 @@ void printConstructor(std::ostream & o, } void printMethodParameters(std::ostream & o, - ProgramOptions const & options, TypeManager const & manager, + ProgramOptions const & options, rtl::Reference< TypeManager > const & manager, typereg::Reader const & reader, sal_uInt16 method, bool previous, bool withtype) { @@ -235,7 +235,7 @@ void printMethodParameters(std::ostream & o, } void printExceptionSpecification(std::ostream & o, - ProgramOptions const & options, TypeManager const & manager, + ProgramOptions const & options, rtl::Reference< TypeManager > const & manager, typereg::Reader const & reader, sal_uInt16 method) { o << ((options.shortnames) ? " throw (css::uno::RuntimeException" : @@ -367,7 +367,7 @@ void generateXDispatchProvider(std::ostream& o, void printMethods(std::ostream & o, - ProgramOptions const & options, TypeManager const & manager, + ProgramOptions const & options, rtl::Reference< TypeManager > const & manager, typereg::Reader const & reader, codemaker::GeneratedTypeSet & generated, OString const & delegate, OString const & classname, OString const & indentation, bool defaultvalue, @@ -456,7 +456,7 @@ void printMethods(std::ostream & o, if (options.all || defaultvalue) { for (sal_uInt16 i = 0; i < reader.getSuperTypeCount(); ++i) { typereg::Reader super( - manager.getTypeReader( + manager->getTypeReader( codemaker::convertString( reader.getSuperTypeName(i)))); if (!super.isValid()) { @@ -642,7 +642,7 @@ void printMethods(std::ostream & o, } void printConstructionMethods(std::ostream & o, - ProgramOptions const & options, TypeManager const & manager, + ProgramOptions const & options, rtl::Reference< TypeManager > const & manager, typereg::Reader const & reader) { for (sal_uInt16 i = 0; i < reader.getMethodCount(); ++i) { @@ -671,7 +671,7 @@ void printConstructionMethods(std::ostream & o, } void printServiceMembers(std::ostream & o, - ProgramOptions const & options, TypeManager const & manager, + ProgramOptions const & options, rtl::Reference< TypeManager > const & manager, typereg::Reader const & reader, OString const & type, OString const & delegate) { @@ -709,7 +709,7 @@ void printServiceMembers(std::ostream & o, } void printMapsToCppType(std::ostream & o, - ProgramOptions const & options, TypeManager const & manager, + ProgramOptions const & options, rtl::Reference< TypeManager > const & manager, codemaker::UnoType::Sort sort, RTTypeClass typeClass, OString const & name, sal_Int32 rank, std::vector< OString > const & arguments, const char * cppTypeSort) @@ -728,7 +728,7 @@ void printMapsToCppType(std::ostream & o, } void generateDocumentation(std::ostream & o, - ProgramOptions const & options, TypeManager const & manager, + ProgramOptions const & options, rtl::Reference< TypeManager > const & manager, OString const & type, OString const & delegate) { if (type.indexOf('/') >= 0) @@ -760,7 +760,7 @@ void generateDocumentation(std::ostream & o, } else if (sort != codemaker::UnoType::SORT_COMPLEX) { o << " simple type"; } else { - typereg::Reader reader(manager.getTypeReader(name)); + typereg::Reader reader(manager->getTypeReader(name)); if (!reader.isValid()) throw CannotDumpException("Bad type library entity " + name); @@ -803,7 +803,7 @@ void generateDocumentation(std::ostream & o, break; case RT_TYPE_SINGLETON: - if ((manager.getTypeReader( + if ((manager->getTypeReader( codemaker::convertString( reader.getSuperTypeName(0))).getTypeClass()) == RT_TYPE_INTERFACE) @@ -839,7 +839,7 @@ void generateDocumentation(std::ostream & o, o << '\n'; } } else { - typereg::Reader reader(manager.getTypeReader(name)); + typereg::Reader reader(manager->getTypeReader(name)); if (!reader.isValid()) throw CannotDumpException("Bad type library entity " + name); @@ -933,7 +933,7 @@ void generateDocumentation(std::ostream & o, case RT_TYPE_SINGLETON: if (reader.getSuperTypeCount() > 0 && - ((manager.getTypeReader( + ((manager->getTypeReader( codemaker::convertString( reader.getSuperTypeName(0))). getTypeClass()) == RT_TYPE_INTERFACE) ) diff --git a/unodevtools/source/skeletonmaker/javacompskeleton.cxx b/unodevtools/source/skeletonmaker/javacompskeleton.cxx index 4ddaf595622d..6110e9c57704 100644 --- a/unodevtools/source/skeletonmaker/javacompskeleton.cxx +++ b/unodevtools/source/skeletonmaker/javacompskeleton.cxx @@ -503,7 +503,7 @@ void generateXDispatchProviderBodies(std::ostream& o, ProgramOptions const & opt void generateMethodBodies(std::ostream& o, ProgramOptions const & options, - TypeManager const & manager, + rtl::Reference< TypeManager > const & manager, const boost::unordered_set< OString, OStringHash >& interfaces, const OString& indentation, bool usepropertymixin) { @@ -559,7 +559,7 @@ void generateMethodBodies(std::ostream& o, continue; } } - typereg::Reader reader(manager.getTypeReader(type.replace('.','/'))); + typereg::Reader reader(manager->getTypeReader(type.replace('.','/'))); printMethods(o, options, manager, reader, generated, "_", indentation, true, usepropertymixin); } @@ -575,7 +575,7 @@ static const char* propcomment= void generateAddinConstructorAndHelper(std::ostream& o, ProgramOptions const & options, - TypeManager const & manager, const OString & classname, + rtl::Reference< TypeManager > const & manager, const OString & classname, const boost::unordered_set< OString, OStringHash >& services, const boost::unordered_set< OString, OStringHash >& interfaces) { @@ -720,7 +720,7 @@ void generateAddinConstructorAndHelper(std::ostream& o, void generateClassDefinition(std::ostream& o, ProgramOptions const & options, - TypeManager const & manager, + rtl::Reference< TypeManager > const & manager, const OString & classname, const boost::unordered_set< OString, OStringHash >& services, const boost::unordered_set< OString, OStringHash >& interfaces, @@ -840,7 +840,7 @@ void generateClassDefinition(std::ostream& o, } void generateSkeleton(ProgramOptions const & options, - TypeManager const & manager, + rtl::Reference< TypeManager > const & manager, std::vector< OString > const & types) { boost::unordered_set< OString, OStringHash > interfaces; diff --git a/unodevtools/source/skeletonmaker/javatypemaker.cxx b/unodevtools/source/skeletonmaker/javatypemaker.cxx index 7e7f86c3825c..155bd0517dc2 100644 --- a/unodevtools/source/skeletonmaker/javatypemaker.cxx +++ b/unodevtools/source/skeletonmaker/javatypemaker.cxx @@ -27,12 +27,12 @@ using namespace ::rtl; namespace skeletonmaker { namespace java { void printType(std::ostream & o, - ProgramOptions const & options, TypeManager const & manager, + ProgramOptions const & options, rtl::Reference< TypeManager > const & manager, OString const & type, bool referenceType, bool defaultvalue); void printType(std::ostream & o, - ProgramOptions const & options, TypeManager const & manager, + ProgramOptions const & options, rtl::Reference< TypeManager > const & manager, codemaker::UnoType::Sort sort, RTTypeClass typeClass, OString const & name, sal_Int32 rank, std::vector< OString > const & arguments, bool referenceType, @@ -115,7 +115,7 @@ void printType(std::ostream & o, } void printType(std::ostream & o, - ProgramOptions const & options, TypeManager const & manager, + ProgramOptions const & options, rtl::Reference< TypeManager > const & manager, OString const & type, bool referenceType, bool defaultvalue) { RTTypeClass typeClass; @@ -130,7 +130,7 @@ void printType(std::ostream & o, } bool printConstructorParameters(std::ostream & o, - ProgramOptions const & options, TypeManager const & manager, + ProgramOptions const & options, rtl::Reference< TypeManager > const & manager, typereg::Reader const & reader, typereg::Reader const & outerReader, std::vector< OString > const & arguments) { @@ -138,7 +138,7 @@ bool printConstructorParameters(std::ostream & o, if ( reader.getSuperTypeCount() != 0 ) { OString super( codemaker::convertString(reader.getSuperTypeName(0))); - typereg::Reader superReader(manager.getTypeReader(super)); + typereg::Reader superReader(manager->getTypeReader(super)); if ( !superReader.isValid() ) { throw CannotDumpException("Bad type library entity " + super); } @@ -180,7 +180,7 @@ bool printConstructorParameters(std::ostream & o, } void printConstructor(std::ostream & o, - ProgramOptions const & options, TypeManager const & manager, + ProgramOptions const & options, rtl::Reference< TypeManager > const & manager, typereg::Reader const & reader, std::vector< OString > const & arguments) { @@ -191,7 +191,7 @@ void printConstructor(std::ostream & o, } void printMethodParameters(std::ostream & o, - ProgramOptions const & options, TypeManager const & manager, + ProgramOptions const & options, rtl::Reference< TypeManager > const & manager, typereg::Reader const & reader, sal_uInt16 method, bool previous, bool withtype) { @@ -226,7 +226,7 @@ void printMethodParameters(std::ostream & o, } void printExceptionSpecification(std::ostream & o, - ProgramOptions const & options, TypeManager const & manager, + ProgramOptions const & options, rtl::Reference< TypeManager > const & manager, typereg::Reader const & reader, sal_uInt16 method) { if ( reader.getMethodExceptionCount(method) > 0 ) { @@ -345,7 +345,7 @@ void generateXFastPropertySetBodies(std::ostream& o); void generateXPropertyAccessBodies(std::ostream& o); void printMethods(std::ostream & o, - ProgramOptions const & options, TypeManager const & manager, + ProgramOptions const & options, rtl::Reference< TypeManager > const & manager, typereg::Reader const & reader, codemaker::GeneratedTypeSet & generated, OString const & delegate, OString const & indentation, @@ -384,7 +384,7 @@ void printMethods(std::ostream & o, if ( options.all || defaultvalue ) { for (sal_uInt16 i = 0; i < reader.getSuperTypeCount(); ++i) { typereg::Reader super( - manager.getTypeReader( + manager->getTypeReader( codemaker::convertString( reader.getSuperTypeName(i)))); if ( !super.isValid() ) { @@ -544,7 +544,7 @@ void printMethods(std::ostream & o, } void printConstructionMethods(std::ostream & o, - ProgramOptions const & options, TypeManager const & manager, + ProgramOptions const & options, rtl::Reference< TypeManager > const & manager, typereg::Reader const & reader) { for ( sal_uInt16 i = 0; i < reader.getMethodCount(); ++i ) { @@ -569,11 +569,11 @@ void printConstructionMethods(std::ostream & o, } void generateDocumentation(std::ostream & o, - ProgramOptions const & options, TypeManager const & manager, + ProgramOptions const & options, rtl::Reference< TypeManager > const & manager, OString const & type); void printServiceMembers(std::ostream & o, - ProgramOptions const & options, TypeManager const & manager, + ProgramOptions const & options, rtl::Reference< TypeManager > const & manager, typereg::Reader const & reader, OString const & type, OString const & delegate) { @@ -608,7 +608,7 @@ void printServiceMembers(std::ostream & o, } void printMapsToJavaType(std::ostream & o, - ProgramOptions const & options, TypeManager const & manager, + ProgramOptions const & options, rtl::Reference< TypeManager > const & manager, codemaker::UnoType::Sort sort, RTTypeClass typeClass, OString const & name, sal_Int32 rank, std::vector< OString > const & arguments, const char * javaTypeSort) @@ -628,7 +628,7 @@ void printMapsToJavaType(std::ostream & o, } void generateDocumentation(std::ostream & o, - ProgramOptions const & options, TypeManager const & manager, + ProgramOptions const & options, rtl::Reference< TypeManager > const & manager, OString const & type, OString const & delegate) { if ( type.indexOf('/') >= 0 ) { @@ -658,7 +658,7 @@ void generateDocumentation(std::ostream & o, } else if ( sort != codemaker::UnoType::SORT_COMPLEX ) { o << " simple type"; } else { - typereg::Reader reader(manager.getTypeReader(name)); + typereg::Reader reader(manager->getTypeReader(name)); if ( !reader.isValid() ) { throw CannotDumpException("Bad type library entity " + name); } @@ -702,7 +702,7 @@ void generateDocumentation(std::ostream & o, break; case RT_TYPE_SINGLETON: - if ( (manager.getTypeReader( + if ( (manager->getTypeReader( codemaker::convertString( reader.getSuperTypeName(0))).getTypeClass()) == RT_TYPE_INTERFACE ) @@ -736,7 +736,7 @@ void generateDocumentation(std::ostream & o, options, manager, sort, typeClass, name, rank, arguments, 0); o << '\n'; } else { - typereg::Reader reader(manager.getTypeReader(name)); + typereg::Reader reader(manager->getTypeReader(name)); if ( !reader.isValid() ) { throw CannotDumpException("Bad type library entity " + name); } @@ -820,7 +820,7 @@ void generateDocumentation(std::ostream & o, case RT_TYPE_SINGLETON: if ( reader.getSuperTypeCount() > 0 && - ((manager.getTypeReader( + ((manager->getTypeReader( codemaker::convertString( reader.getSuperTypeName(0))).getTypeClass()) == RT_TYPE_INTERFACE) ) { diff --git a/unodevtools/source/skeletonmaker/skeletoncommon.cxx b/unodevtools/source/skeletonmaker/skeletoncommon.cxx index e32fda26e030..1b63edaccdab 100644 --- a/unodevtools/source/skeletonmaker/skeletoncommon.cxx +++ b/unodevtools/source/skeletonmaker/skeletoncommon.cxx @@ -91,7 +91,7 @@ bool getOutputStream(ProgramOptions const & options, } codemaker::UnoType::Sort decomposeResolveAndCheck( - TypeManager const & manager, OString const & type, + rtl::Reference< TypeManager > const & manager, OString const & type, bool resolveTypedefs, bool allowVoid, bool allowExtraEntities, RTTypeClass * typeClass, OString * name, sal_Int32 * rank, std::vector< OString > * arguments) @@ -125,7 +125,7 @@ bool containsAttribute(AttributeInfo& attributes, OString const & attrname) } // collect attributes including inherited attributes -void checkAttributes(TypeManager const & manager, +void checkAttributes(rtl::Reference< TypeManager > const & manager, const typereg::Reader& reader, AttributeInfo& attributes, boost::unordered_set< OString, OStringHash >& propinterfaces) @@ -140,7 +140,7 @@ void checkAttributes(TypeManager const & manager, } for ( sal_uInt16 i = 0; i < reader.getSuperTypeCount(); ++i ) { - typereg::Reader supertype(manager.getTypeReader( + typereg::Reader supertype(manager->getTypeReader( codemaker::convertString( reader.getSuperTypeName(i)))); if ( !supertype.isValid() ) { @@ -167,7 +167,7 @@ void checkAttributes(TypeManager const & manager, } } -void checkType(TypeManager const & manager, +void checkType(rtl::Reference< TypeManager > const & manager, OString const & type, boost::unordered_set< OString, OStringHash >& interfaceTypes, boost::unordered_set< OString, OStringHash >& serviceTypes, @@ -175,7 +175,7 @@ void checkType(TypeManager const & manager, { OString binType(type.replace('.', '/')); - typereg::Reader reader(manager.getTypeReader(binType)); + typereg::Reader reader(manager->getTypeReader(binType)); if ( !reader.isValid() ) { throw CannotDumpException("Bad type library entity " + binType); } @@ -205,7 +205,7 @@ void checkType(TypeManager const & manager, if ( interfaceTypes.find(supername) == interfaceTypes.end() ) { interfaceTypes.insert(supername); - typereg::Reader supertype(manager.getTypeReader( + typereg::Reader supertype(manager->getTypeReader( codemaker::convertString( reader.getSuperTypeName(0)))); if ( !supertype.isValid() ) { @@ -288,7 +288,7 @@ void checkDefaultInterfaces( } } -bool checkServiceProperties(TypeManager const & manager, +bool checkServiceProperties(rtl::Reference< TypeManager > const & manager, const typereg::Reader & reader) { if ( reader.getFieldCount() > 0 ) @@ -298,7 +298,7 @@ bool checkServiceProperties(TypeManager const & manager, for ( sal_uInt16 i = 0; i < reader.getReferenceCount(); ++i ) { if ( reader.getReferenceSort(i) == RT_REF_EXPORTS ) { typereg::Reader refreader( - manager.getTypeReader( + manager->getTypeReader( codemaker::convertString(reader.getReferenceTypeName(i)))); if ( checkServiceProperties(manager, refreader) ) @@ -312,7 +312,7 @@ bool checkServiceProperties(TypeManager const & manager, OString checkPropertyHelper( ProgramOptions const & options, - TypeManager const & manager, + rtl::Reference< TypeManager > const & manager, const boost::unordered_set< OString, OStringHash >& services, const boost::unordered_set< OString, OStringHash >& interfaces, AttributeInfo& attributes, @@ -331,13 +331,13 @@ OString checkPropertyHelper( bool oldStyleWithProperties = false; while ( iter != end ) { - typereg::Reader reader(manager.getTypeReader((*iter).replace('.', '/'))); + typereg::Reader reader(manager->getTypeReader((*iter).replace('.', '/'))); if ( !services.empty() ) { if ( options.supportpropertysetmixin && reader.getSuperTypeCount() > 0 ) { typereg::Reader supertype( - manager.getTypeReader( + manager->getTypeReader( codemaker::convertString( reader.getSuperTypeName(0)))); if ( !supertype.isValid() ) { @@ -371,7 +371,7 @@ OString checkPropertyHelper( return (oldStyleWithProperties ? "_" : ""); } -bool checkXComponentSupport(TypeManager const & manager, +bool checkXComponentSupport(rtl::Reference< TypeManager > const & manager, typereg::Reader const & reader) { static OUString s( "com/sun/star/lang/XComponent"); @@ -380,7 +380,7 @@ bool checkXComponentSupport(TypeManager const & manager, for ( sal_uInt16 i = 0; i < reader.getSuperTypeCount(); ++i ) { typereg::Reader super( - manager.getTypeReader( + manager->getTypeReader( codemaker::convertString( reader.getSuperTypeName(i)))); if ( !super.isValid() ) { @@ -399,7 +399,7 @@ bool checkXComponentSupport(TypeManager const & manager, // if XComponent is directly specified, return true and remove it from the // supported interfaces list -bool checkXComponentSupport(TypeManager const & manager, +bool checkXComponentSupport(rtl::Reference< TypeManager > const & manager, boost::unordered_set< OString, OStringHash >& interfaces) { if ( interfaces.empty() ) @@ -412,7 +412,7 @@ bool checkXComponentSupport(TypeManager const & manager, interfaces.erase("com.sun.star.lang.XComponent"); return true; } - typereg::Reader reader(manager.getTypeReader((*iter).replace('.', '/'))); + typereg::Reader reader(manager->getTypeReader((*iter).replace('.', '/'))); if ( checkXComponentSupport(manager, reader) ) return true; ++iter; @@ -465,7 +465,7 @@ sal_uInt16 checkAdditionalPropertyFlags(typereg::Reader const & reader, // This function checks if the specified types for parameters and return // types are allowed add-in types, for more info see the com.sun.star.sheet.AddIn // service description -bool checkAddinType(TypeManager const & manager, +bool checkAddinType(rtl::Reference< TypeManager > const & manager, OString const & type, bool & bLastAny, bool & bHasXPropertySet, bool bIsReturn) { @@ -515,7 +515,7 @@ bool checkAddinType(TypeManager const & manager, return false; } -void checkAddInTypes(TypeManager const & manager, +void checkAddInTypes(rtl::Reference< TypeManager > const & manager, typereg::Reader const & reader) { OString sType(codemaker::convertString(reader.getTypeName()).replace('/', '.')); @@ -568,7 +568,7 @@ void checkAddInTypes(TypeManager const & manager, void generateFunctionParamterMap(std::ostream& o, ProgramOptions const & options, - TypeManager const & manager, + rtl::Reference< TypeManager > const & manager, typereg::Reader const & reader, ::codemaker::GeneratedTypeSet & generated, bool bFirst) @@ -590,7 +590,7 @@ void generateFunctionParamterMap(std::ostream& o, for ( sal_uInt16 i = 0; i < reader.getSuperTypeCount(); ++i ) { typereg::Reader super( - manager.getTypeReader( + manager->getTypeReader( codemaker::convertString( reader.getSuperTypeName(i)))); if ( !super.isValid() ) { @@ -669,14 +669,14 @@ void generateFunctionParamterMap(std::ostream& o, void generateFunctionParameterMap(std::ostream& o, ProgramOptions const & options, - TypeManager const & manager, + rtl::Reference< TypeManager > const & manager, const boost::unordered_set< OString, OStringHash >& interfaces) { ::codemaker::GeneratedTypeSet generated; bool bFirst = true; boost::unordered_set< OString, OStringHash >::const_iterator iter = interfaces.begin(); while ( iter != interfaces.end() ) { - typereg::Reader reader(manager.getTypeReader((*iter).replace('.','/'))); + typereg::Reader reader(manager->getTypeReader((*iter).replace('.','/'))); if (!reader.isValid()) { throw CannotDumpException( "Bad type library entity " diff --git a/unodevtools/source/skeletonmaker/skeletoncommon.hxx b/unodevtools/source/skeletonmaker/skeletoncommon.hxx index 93a27c65f8e9..8fc3951c39d6 100644 --- a/unodevtools/source/skeletonmaker/skeletoncommon.hxx +++ b/unodevtools/source/skeletonmaker/skeletoncommon.hxx @@ -19,6 +19,9 @@ #ifndef INCLUDED_UNODEVTOOLS_SOURCE_SKELETONMAKER_SKELETONCOMMON_HXX #define INCLUDED_UNODEVTOOLS_SOURCE_SKELETONMAKER_SKELETONCOMMON_HXX +#include "sal/config.h" + +#include "rtl/ref.hxx" #include "rtl/string.hxx" #include "registry/reader.hxx" #include "codemaker/typemanager.hxx" @@ -95,12 +98,12 @@ bool getOutputStream(ProgramOptions const & options, rtl::OString & tmpSourceFileName); codemaker::UnoType::Sort decomposeResolveAndCheck( - TypeManager const & manager, rtl::OString const & type, + rtl::Reference< TypeManager > const & manager, rtl::OString const & type, bool resolveTypedefs, bool allowVoid, bool allowExtraEntities, RTTypeClass * typeClass, rtl::OString * name, sal_Int32 * rank, std::vector< rtl::OString > * arguments); -void checkType(TypeManager const & manager, +void checkType(rtl::Reference< TypeManager > const & manager, rtl::OString const & type, boost::unordered_set< rtl::OString, rtl::OStringHash >& interfaceTypes, boost::unordered_set< rtl::OString, rtl::OStringHash >& serviceTypes, @@ -112,7 +115,7 @@ void checkDefaultInterfaces( const rtl::OString & propertyhelper); rtl::OString checkPropertyHelper( - ProgramOptions const & options, TypeManager const & manager, + ProgramOptions const & options, rtl::Reference< TypeManager > const & manager, const boost::unordered_set< rtl::OString, rtl::OStringHash >& services, const boost::unordered_set< rtl::OString, rtl::OStringHash >& interfaces, AttributeInfo& attributes, @@ -127,7 +130,7 @@ rtl::OString checkPropertyHelper( @param reader a registry type reader of an interface defining calc add-in functions */ -void checkAddInTypes(TypeManager const & manager, +void checkAddInTypes(rtl::Reference< TypeManager > const & manager, typereg::Reader const & reader); @@ -141,7 +144,7 @@ void checkAddInTypes(TypeManager const & manager, @return true if XComponent have to be supported */ -bool checkXComponentSupport(TypeManager const & manager, +bool checkXComponentSupport(rtl::Reference< TypeManager > const & manager, boost::unordered_set< rtl::OString, rtl::OStringHash >& interfaces); @@ -151,7 +154,7 @@ sal_uInt16 checkAdditionalPropertyFlags(typereg::Reader const & reader, void generateFunctionParameterMap(std::ostream& o, ProgramOptions const & options, - TypeManager const & manager, + rtl::Reference< TypeManager > const & manager, const boost::unordered_set< ::rtl::OString, ::rtl::OStringHash >& interfaces); } diff --git a/unodevtools/source/skeletonmaker/skeletoncpp.hxx b/unodevtools/source/skeletonmaker/skeletoncpp.hxx index 3d05e4339029..3ce20d13ab64 100644 --- a/unodevtools/source/skeletonmaker/skeletoncpp.hxx +++ b/unodevtools/source/skeletonmaker/skeletoncpp.hxx @@ -34,21 +34,21 @@ namespace skeletonmaker { namespace cpp { // 8 = default construction for example for return types, means "return <type>();" // 16 = default member initialization in a constructor void printType(std::ostream & o, - ProgramOptions const & options, TypeManager const & manager, + ProgramOptions const & options, rtl::Reference< TypeManager > const & manager, codemaker::UnoType::Sort sort, RTTypeClass typeClass, rtl::OString const & name, sal_Int32 rank, std::vector< rtl::OString > const & arguments, short referenceType, bool defaultvalue=false); void printType(std::ostream & o, - ProgramOptions const & options, TypeManager const & manager, + ProgramOptions const & options, rtl::Reference< TypeManager > const & manager, rtl::OString const & type, short referenceType, bool defaultvalue=false); bool printConstructorParameters(std::ostream & o, ProgramOptions const & options, - TypeManager const & manager, + rtl::Reference< TypeManager > const & manager, typereg::Reader const & reader, typereg::Reader const & outerReader, std::vector< rtl::OString > const & arguments); @@ -56,14 +56,14 @@ bool printConstructorParameters(std::ostream & o, void printConstructor(std::ostream & o, ProgramOptions const & options, - TypeManager const & manager, + rtl::Reference< TypeManager > const & manager, typereg::Reader const & reader, std::vector< rtl::OString > const & arguments); void printMethodParameters(std::ostream & o, ProgramOptions const & options, - TypeManager const & manager, + rtl::Reference< TypeManager > const & manager, typereg::Reader const & reader, sal_uInt16 method, bool previous, bool withtype); @@ -71,13 +71,13 @@ void printMethodParameters(std::ostream & o, void printExceptionSpecification(std::ostream & o, ProgramOptions const & options, - TypeManager const & manager, + rtl::Reference< TypeManager > const & manager, typereg::Reader const & reader, sal_uInt16 method); void printMethods(std::ostream & o, - ProgramOptions const & options, TypeManager const & manager, + ProgramOptions const & options, rtl::Reference< TypeManager > const & manager, typereg::Reader const & reader, codemaker::GeneratedTypeSet & generated, rtl::OString const & delegate, @@ -89,13 +89,13 @@ void printMethods(std::ostream & o, void printConstructionMethods(std::ostream & o, ProgramOptions const & options, - TypeManager const & manager, + rtl::Reference< TypeManager > const & manager, typereg::Reader const & reader); void printServiceMembers(std::ostream & o, ProgramOptions const & options, - TypeManager const & manager, + rtl::Reference< TypeManager > const & manager, typereg::Reader const & reader, rtl::OString const & type, rtl::OString const & delegate); @@ -103,7 +103,7 @@ void printServiceMembers(std::ostream & o, void printMapsToCppType(std::ostream & o, ProgramOptions const & options, - TypeManager const & manager, + rtl::Reference< TypeManager > const & manager, codemaker::UnoType::Sort sort, RTTypeClass typeClass, rtl::OString const & name, @@ -114,17 +114,17 @@ void printMapsToCppType(std::ostream & o, void generateDocumentation(std::ostream & o, ProgramOptions const & options, - TypeManager const & manager, + rtl::Reference< TypeManager > const & manager, rtl::OString const & type, rtl::OString const & delegate); void generateSkeleton(ProgramOptions const & options, - TypeManager const & manager, + rtl::Reference< TypeManager > const & manager, std::vector< rtl::OString > const & types); void generateCalcAddin(ProgramOptions const & options, - TypeManager const & manager, + rtl::Reference< TypeManager > const & manager, std::vector< rtl::OString > const & types); } } diff --git a/unodevtools/source/skeletonmaker/skeletonjava.hxx b/unodevtools/source/skeletonmaker/skeletonjava.hxx index 5bfae4b01138..41da0e06223c 100644 --- a/unodevtools/source/skeletonmaker/skeletonjava.hxx +++ b/unodevtools/source/skeletonmaker/skeletonjava.hxx @@ -27,44 +27,44 @@ namespace skeletonmaker { namespace java { void printType(std::ostream & o, - ProgramOptions const & options, TypeManager const & manager, + ProgramOptions const & options, rtl::Reference< TypeManager > const & manager, codemaker::UnoType::Sort sort, RTTypeClass typeClass, rtl::OString const & name, sal_Int32 rank, std::vector< rtl::OString > const & arguments, bool referenceType, bool defaultvalue=false); void printType(std::ostream & o, - ProgramOptions const & options, TypeManager const & manager, + ProgramOptions const & options, rtl::Reference< TypeManager > const & manager, rtl::OString const & type, bool referenceType, bool defaultvalue=false); bool printConstructorParameters(std::ostream & o, ProgramOptions const & options, - TypeManager const & manager, + rtl::Reference< TypeManager > const & manager, typereg::Reader const & reader, typereg::Reader const & outerReader, std::vector< rtl::OString > const & arguments); void printConstructor(std::ostream & o, - ProgramOptions const & options, TypeManager const & manager, + ProgramOptions const & options, rtl::Reference< TypeManager > const & manager, typereg::Reader const & reader, std::vector< rtl::OString > const & arguments); void printMethodParameters(std::ostream & o, ProgramOptions const & options, - TypeManager const & manager, + rtl::Reference< TypeManager > const & manager, typereg::Reader const & reader, sal_uInt16 method, bool previous, bool withtype); void printExceptionSpecification(std::ostream & o, ProgramOptions const & options, - TypeManager const & manager, + rtl::Reference< TypeManager > const & manager, typereg::Reader const & reader, sal_uInt16 method); void printMethods(std::ostream & o, - ProgramOptions const & options, TypeManager const & manager, + ProgramOptions const & options, rtl::Reference< TypeManager > const & manager, typereg::Reader const & reader, codemaker::GeneratedTypeSet & generated, rtl::OString const & delegate, @@ -74,19 +74,19 @@ void printMethods(std::ostream & o, void printConstructionMethods(std::ostream & o, ProgramOptions const & options, - TypeManager const & manager, + rtl::Reference< TypeManager > const & manager, typereg::Reader const & reader); void printServiceMembers(std::ostream & o, ProgramOptions const & options, - TypeManager const & manager, + rtl::Reference< TypeManager > const & manager, typereg::Reader const & reader, rtl::OString const & type, rtl::OString const & delegate); void printMapsToJavaType(std::ostream & o, ProgramOptions const & options, - TypeManager const & manager, + rtl::Reference< TypeManager > const & manager, codemaker::UnoType::Sort sort, RTTypeClass typeClass, rtl::OString const & name, sal_Int32 rank, @@ -95,11 +95,11 @@ void printMapsToJavaType(std::ostream & o, void generateDocumentation(std::ostream & o, ProgramOptions const & options, - TypeManager const & manager, + rtl::Reference< TypeManager > const & manager, rtl::OString const & type, rtl::OString const & delegate); -void generateSkeleton(ProgramOptions const & options, TypeManager const & manager, std::vector< rtl::OString > const & types); +void generateSkeleton(ProgramOptions const & options, rtl::Reference< TypeManager > const & manager, std::vector< rtl::OString > const & types); } } diff --git a/unodevtools/source/skeletonmaker/skeletonmaker.cxx b/unodevtools/source/skeletonmaker/skeletonmaker.cxx index 4884bd4f69ad..42eb62c81329 100644 --- a/unodevtools/source/skeletonmaker/skeletonmaker.cxx +++ b/unodevtools/source/skeletonmaker/skeletonmaker.cxx @@ -18,10 +18,10 @@ */ #include <iostream> +#include "codemaker/typemanager.hxx" #include "sal/main.h" #include "rtl/process.h" #include "rtl/ustrbuf.hxx" -#include "unodevtools/typemanager.hxx" #include "unodevtools/options.hxx" #include "skeletonjava.hxx" #include "skeletoncpp.hxx" @@ -143,7 +143,7 @@ SAL_IMPLEMENT_MAIN() } ProgramOptions options; - std::vector< OUString > registries; + std::vector< OString > registries; std::vector< OString > types; OString delegate; @@ -243,7 +243,7 @@ SAL_IMPLEMENT_MAIN() continue; } if ( readOption( &sOption, "l", &nPos, arg) ) { - registries.push_back(sOption); + registries.push_back(OUStringToOString(sOption, RTL_TEXTENCODING_UTF8)); continue; } if ( readOption( &sOption, "t", &nPos, arg) ) { @@ -274,7 +274,7 @@ SAL_IMPLEMENT_MAIN() buf.append(arg); buf.append("\"!"); throw RuntimeException(buf.makeStringAndClear(), - Reference< XInterface >()); + css::uno::Reference< XInterface >()); } if ( types.empty() && options.componenttype != 3) { @@ -284,8 +284,8 @@ SAL_IMPLEMENT_MAIN() exit(EXIT_FAILURE); } - UnoTypeManager manager; - if ( !manager.init(registries) ) { + rtl::Reference< TypeManager > manager(new TypeManager); + if ( !manager->init(registries) ) { std::cerr << ("\nError: Using the binary type libraries failed, check the -L" " options\n"); diff --git a/unodevtools/source/unodevtools/typemanager.cxx b/unodevtools/source/unodevtools/typemanager.cxx deleted file mode 100644 index c25bcac9964c..000000000000 --- a/unodevtools/source/unodevtools/typemanager.cxx +++ /dev/null @@ -1,270 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include "unodevtools/typemanager.hxx" - -#include "rtl/alloc.h" -#include "registry/reader.hxx" -#include "cppuhelper/bootstrap.hxx" - -#include "com/sun/star/container/XSet.hpp" -#include "com/sun/star/reflection/XTypeDescription.hpp" -#include "com/sun/star/registry/XSimpleRegistry.hpp" -#include "com/sun/star/uno/XComponentContext.hpp" - -using namespace ::rtl; -using namespace ::cppu; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::container; -using namespace ::com::sun::star::registry; -using namespace ::com::sun::star::reflection; - -namespace unodevtools { - -static RTTypeClass mapTypeClass(TypeClass typeclass) { - switch(typeclass) { - case TypeClass_ENUM: - return RT_TYPE_ENUM; - case TypeClass_TYPEDEF: - return RT_TYPE_TYPEDEF; - case TypeClass_STRUCT: - return RT_TYPE_STRUCT; - case TypeClass_UNION: - return RT_TYPE_UNION; - case TypeClass_EXCEPTION: - return RT_TYPE_EXCEPTION; - case TypeClass_INTERFACE: - return RT_TYPE_INTERFACE; - case TypeClass_SERVICE: - return RT_TYPE_SERVICE; - case TypeClass_MODULE: - return RT_TYPE_MODULE; - case TypeClass_CONSTANTS: - return RT_TYPE_CONSTANTS; - case TypeClass_SINGLETON: - return RT_TYPE_SINGLETON; - default: - break; - } - return RT_TYPE_INVALID; -} - - -UnoTypeManager::UnoTypeManager() -{ - m_pImpl = new UnoTypeManagerImpl(); - acquire(); -} - -UnoTypeManager::~UnoTypeManager() -{ - release(); -} - -void UnoTypeManager::release() -{ - if (0 == TypeManager::release()) - delete m_pImpl; -} - -sal_Bool UnoTypeManager::init( - const ::std::vector< ::rtl::OUString > registries) -{ - Reference< XComponentContext > xContext= - defaultBootstrap_InitialComponentContext(); - - if ( !xContext.is() ) { - OUString msg( - "internal UNO problem, can't create initial UNO component context"); - throw RuntimeException( msg, Reference< XInterface >()); - } - Any a = xContext->getValueByName( - OUString( - "/singletons/com.sun.star.reflection.theTypeDescriptionManager")); - - a >>= m_pImpl->m_tdmgr; - - if ( !m_pImpl->m_tdmgr.is() ) { - OUString msg("internal UNO problem, can't get TypeDescriptionManager"); - throw RuntimeException( msg, Reference< XInterface >()); - } - - if ( !registries.empty() ) { - - Reference< XMultiComponentFactory > xServiceManager( - xContext->getServiceManager() ); - if ( !xServiceManager.is() ) { - OUString msg("internal UNO problem, can't get ServiceManager"); - throw RuntimeException( msg, Reference< XInterface >()); - } - - Sequence<Any> seqArgs(registries.size()); - - std::vector< OUString >::const_iterator iter = registries.begin(); - int i = 0; - while ( iter != registries.end() ) - { - Reference< XSimpleRegistry > xReg( - xServiceManager->createInstanceWithContext( - OUString("com.sun.star.registry.SimpleRegistry"), - xContext), UNO_QUERY); - xReg->open(convertToFileUrl( - OUStringToOString(*iter, RTL_TEXTENCODING_UTF8)), - sal_True, sal_False); - - seqArgs[i++] = makeAny(xReg); - ++iter; - } - - Reference< XHierarchicalNameAccess > xTDProvider( - xServiceManager->createInstanceWithArgumentsAndContext( - OUString("com.sun.star.reflection.TypeDescriptionProvider"), - seqArgs, xContext), - UNO_QUERY); - if ( !xTDProvider.is() ) { - OUString msg("internal UNO problem, can't create local" - " type description provider"); - throw RuntimeException( msg, Reference< XInterface >()); - } - - a = makeAny(xTDProvider); - Reference< XSet > xSet(m_pImpl->m_tdmgr, UNO_QUERY); - xSet->insert(a); - } - - return sal_True; -} - -sal_Bool UnoTypeManager::isValidType(const ::rtl::OString& name) const -{ - return m_pImpl->m_tdmgr->hasByHierarchicalName( - OStringToOUString(name, RTL_TEXTENCODING_UTF8)); -} - -OString UnoTypeManager::getTypeName(RegistryKey& rTypeKey) const -{ - OString typeName = OUStringToOString(rTypeKey.getName(), RTL_TEXTENCODING_UTF8); - static OString sBase("/UCR"); - if (typeName.indexOf(sBase) == 0) { - typeName = typeName.copy(typeName.indexOf('/', 1) + 1); - } else { - typeName = typeName.copy(1); - } - return typeName; -} - -// extern -void* getTypeBlob(Reference< XHierarchicalNameAccess > xTDmgr, - const OString& typeName, sal_uInt32* pBlob); - -typereg::Reader UnoTypeManager::getTypeReader( - const OString& name, sal_Bool * /*pIsExtraType*/ ) const -{ - typereg::Reader reader; - - void* pBlob = NULL; - sal_uInt32 blobsize = 0; - - if ( (pBlob = getTypeBlob(m_pImpl->m_tdmgr, name, &blobsize)) != NULL ) - reader = typereg::Reader(pBlob, blobsize, sal_True, TYPEREG_VERSION_1); - - if ( pBlob ) - rtl_freeMemory(pBlob); - - return reader; -} - -typereg::Reader UnoTypeManager::getTypeReader(RegistryKey& rTypeKey) const -{ - typereg::Reader reader; - - if (rTypeKey.isValid()) { - RegValueType valueType; - sal_uInt32 valueSize; - - if (!rTypeKey.getValueInfo(OUString(), &valueType, &valueSize)) { - sal_uInt8* pBuffer = (sal_uInt8*)rtl_allocateMemory(valueSize); - if ( !rTypeKey.getValue(OUString(), pBuffer) ) { - reader = typereg::Reader( - pBuffer, valueSize, true, TYPEREG_VERSION_1); - } - rtl_freeMemory(pBuffer); - } - } - return reader; -} - - -RTTypeClass UnoTypeManager::getTypeClass(const OString& name) const -{ - if ( m_pImpl->m_t2TypeClass.count(name) > 0 ) { - return m_pImpl->m_t2TypeClass[name]; - } else { - Reference< XTypeDescription > xTD; - Any a = m_pImpl->m_tdmgr->getByHierarchicalName( - OStringToOUString(name, RTL_TEXTENCODING_UTF8)); - a >>= xTD; - - if ( xTD.is() ) { - RTTypeClass tc = mapTypeClass(xTD->getTypeClass()); - if (tc != RT_TYPE_INVALID) - m_pImpl->m_t2TypeClass[name] = tc; - return tc; - } - } - - return RT_TYPE_INVALID; -} - -RTTypeClass UnoTypeManager::getTypeClass(RegistryKey& rTypeKey) const -{ - OString name = getTypeName(rTypeKey); - - if ( m_pImpl->m_t2TypeClass.count(name) > 0 ) { - return m_pImpl->m_t2TypeClass[name]; - } else { - if ( rTypeKey.isValid() ) { - RegValueType valueType; - sal_uInt32 valueSize; - - if ( !rTypeKey.getValueInfo(OUString(), &valueType, &valueSize) ) { - sal_uInt8* pBuffer = (sal_uInt8*)rtl_allocateMemory(valueSize); - if ( !rTypeKey.getValue(OUString(), pBuffer) ) { - typereg::Reader reader( - pBuffer, valueSize, false, TYPEREG_VERSION_1); - - RTTypeClass ret = reader.getTypeClass(); - - rtl_freeMemory(pBuffer); - - m_pImpl->m_t2TypeClass[name] = ret; - return ret; - } - rtl_freeMemory(pBuffer); - } - } - } - - return RT_TYPE_INVALID; -} - -} // end of namespace unodevtools - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |