summaryrefslogtreecommitdiffstats
path: root/codemaker/source/cppumaker/cpputype.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'codemaker/source/cppumaker/cpputype.cxx')
-rw-r--r--codemaker/source/cppumaker/cpputype.cxx51
1 files changed, 16 insertions, 35 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();