diff options
Diffstat (limited to 'codemaker/source/cppumaker')
-rw-r--r-- | codemaker/source/cppumaker/cpputype.cxx | 51 | ||||
-rw-r--r-- | codemaker/source/cppumaker/includes.cxx | 6 | ||||
-rw-r--r-- | codemaker/source/cppumaker/includes.hxx | 2 |
3 files changed, 23 insertions, 36 deletions
diff --git a/codemaker/source/cppumaker/cpputype.cxx b/codemaker/source/cppumaker/cpputype.cxx index b4637a9a30f6..23b0bc608596 100644 --- a/codemaker/source/cppumaker/cpputype.cxx +++ b/codemaker/source/cppumaker/cpputype.cxx @@ -3872,10 +3872,10 @@ sal_Bool ServiceType::dumpHxxFile( //TODO: Decide whether the types added to includes should rather be // added to m_dependencies (and thus be generated during // dumpDependedTypes): + includes.addCassert(); includes.addReference(); includes.addRtlUstringH(); includes.addRtlUstringHxx(); - includes.add("com/sun/star/lang/XMultiComponentFactory"); includes.add("com/sun/star/uno/DeploymentException"); includes.add("com/sun/star/uno/XComponentContext"); for (sal_uInt16 i = 0; i < ctors; ++i) { @@ -3949,27 +3949,16 @@ sal_Bool ServiceType::dumpHxxFile( " ::com::sun::star::uno::XComponentContext > const &" " the_context) {\n"); inc(); - o << indent() - << ("::com::sun::star::uno::Reference<" - " ::com::sun::star::lang::XMultiComponentFactory >" - " the_factory(the_context->getServiceManager());\n") - << indent() << "if (!the_factory.is()) {\n"; - inc(); - o << indent() - << ("throw ::com::sun::star::uno::DeploymentException(" - "::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(\"component" - " context fails to supply service manager\"))," - " the_context);\n"); - dec(); - o << indent() << "}\n" << indent() + o << indent() << "assert(the_context.is());\n" << indent() << "::com::sun::star::uno::Reference< " << scopedBaseName << " > the_instance;\n" << indent() << "try {\n"; inc(); o << indent() << "the_instance = ::com::sun::star::uno::Reference< " << scopedBaseName - << (" >(the_factory->createInstanceWithContext(" - "::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(\"") + << (" >(the_context->getServiceManager()->" + "createInstanceWithContext(::rtl::OUString(" + "RTL_CONSTASCII_USTRINGPARAM(\"") << fullName << "\")), the_context), ::com::sun::star::uno::UNO_QUERY);\n"; dec(); @@ -4038,19 +4027,7 @@ sal_Bool ServiceType::dumpHxxFile( } o << ") {\n"; inc(); - o << indent() - << ("::com::sun::star::uno::Reference<" - " ::com::sun::star::lang::XMultiComponentFactory >" - " the_factory(the_context->getServiceManager());\n") - << indent() << "if (!the_factory.is()) {\n"; - inc(); - o << indent() - << ("throw com::sun::star::uno::DeploymentException(" - "::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" - "\"component context fails to supply service manager\"))," - " the_context);\n"); - dec(); - o << indent() << "}\n"; + o << indent() << "assert(the_context.is());\n"; if (!rest && params > 0) { o << indent() << ("::com::sun::star::uno::Sequence<" @@ -4108,8 +4085,9 @@ sal_Bool ServiceType::dumpHxxFile( o << indent() << "the_instance = ::com::sun::star::uno::Reference< " << scopedBaseName - << (" >(the_factory->createInstanceWithArgumentsAndContext(" - "::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(\"") + << (" >(the_context->getServiceManager()->" + "createInstanceWithArgumentsAndContext(::rtl::OUString(" + "RTL_CONSTASCII_USTRINGPARAM(\"") << fullName << "\")), "; if (rest) { o << translateUnoToCppIdentifier( @@ -4243,6 +4221,7 @@ sal_Bool SingletonType::dumpHxxFile( // m_dependencies (and thus be generated during dumpDependedTypes): includes.add("com/sun/star/uno/DeploymentException"); includes.add("com/sun/star/uno/XComponentContext"); + includes.addCassert(); includes.addAny(); includes.addReference(); includes.addRtlUstringH(); @@ -4258,11 +4237,13 @@ sal_Bool SingletonType::dumpHxxFile( << scopedBaseName << " > " << translateUnoToCppIdentifier("get", "method", ITM_NONGLOBAL, &cppName) << ("(::com::sun::star::uno::Reference<" - " ::com::sun::star::uno::XComponentContext > const & context) {\n"); + " ::com::sun::star::uno::XComponentContext > const & the_context)" + " {\n"); inc(); - o << indent() << "::com::sun::star::uno::Reference< " << scopedBaseName + o << indent() << "assert(the_context.is());\n" << indent() + << "::com::sun::star::uno::Reference< " << scopedBaseName << " > instance;\n" << indent() - << ("if (!(context->getValueByName(" + << ("if (!(the_context->getValueByName(" "::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(\"/singletons/") << fullName << "\"))) >>= instance) || !instance.is()) {\n"; inc(); @@ -4270,7 +4251,7 @@ sal_Bool SingletonType::dumpHxxFile( << ("throw ::com::sun::star::uno::DeploymentException(" "::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(\"component context" " fails to supply singleton ") - << fullName << " of type " << fullBaseName << "\")), context);\n"; + << fullName << " of type " << fullBaseName << "\")), the_context);\n"; dec(); o << indent() << "}\n" << indent() << "return instance;\n"; dec(); diff --git a/codemaker/source/cppumaker/includes.cxx b/codemaker/source/cppumaker/includes.cxx index b6c9a63f4734..9411312eca93 100644 --- a/codemaker/source/cppumaker/includes.cxx +++ b/codemaker/source/cppumaker/includes.cxx @@ -40,7 +40,8 @@ Includes::Includes( TypeManager const & manager, codemaker::Dependencies const & dependencies, bool hpp): m_manager(manager), m_map(dependencies.getMap()), m_hpp(hpp), - m_includeAny(dependencies.hasAnyDependency()), m_includeReference(false), + m_includeCassert(false), m_includeAny(dependencies.hasAnyDependency()), + m_includeReference(false), m_includeSequence(dependencies.hasSequenceDependency()), m_includeType(dependencies.hasTypeDependency()), m_includeCppuMacrosHxx(false), m_includeCppuUnotypeHxx(false), @@ -155,6 +156,9 @@ void Includes::dump(FileStream & out, rtl::OString const * companionHdl) { } } out << "#include \"sal/config.h\"\n"; + if (m_includeCassert) { + out << "\n#include <cassert>\n"; + } if (companionHdl) { out << "\n"; dumpInclude(out, *companionHdl, false); diff --git a/codemaker/source/cppumaker/includes.hxx b/codemaker/source/cppumaker/includes.hxx index 7913d78e5ff0..dafc659211a4 100644 --- a/codemaker/source/cppumaker/includes.hxx +++ b/codemaker/source/cppumaker/includes.hxx @@ -37,6 +37,7 @@ public: ~Includes(); void add(rtl::OString const & registryType); + void addCassert() { m_includeCassert = true; } void addAny() { m_includeAny = true; } void addReference() { m_includeReference = true; } void addSequence() { m_includeSequence = true; } @@ -72,6 +73,7 @@ private: TypeManager const & m_manager; codemaker::Dependencies::Map m_map; bool m_hpp; + bool m_includeCassert; bool m_includeAny; bool m_includeReference; bool m_includeSequence; |