From 3099c70b11c7e5b80fe4dbe3dc99171fb38c6fc2 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Tue, 17 Mar 2015 12:25:11 +0100 Subject: Fix various XServiceInfo implementations ...to match what is recorded in the .component files Change-Id: Ie548cd37872d3b8540222201afaac73040e65c8f --- include/comphelper/sequence.hxx | 27 +++++++++++++++++++++++++++ include/comphelper/servicedecl.hxx | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) (limited to 'include/comphelper') diff --git a/include/comphelper/sequence.hxx b/include/comphelper/sequence.hxx index 471358285fd2..fdba924ae790 100644 --- a/include/comphelper/sequence.hxx +++ b/include/comphelper/sequence.hxx @@ -62,6 +62,33 @@ namespace comphelper return aReturn; } + /// concat additional elements from right sequence to left sequence + /// + /// be aware that this takes time O(|left| * |right|) + template css::uno::Sequence combineSequences( + css::uno::Sequence const & left, css::uno::Sequence const & right) + { + sal_Int32 n1 = left.getLength(); + css::uno::Sequence ret(n1 + right.getLength()); + //TODO: check for overflow + T * p = ret.getArray(); + internal::implCopySequence(left.getConstArray(), p, n1); + sal_Int32 n2 = n1; + for (sal_Int32 i = 0; i != right.getLength(); ++i) { + bool found = false; + for (sal_Int32 j = 0; j != n1; ++j) { + if (right[i] == left[j]) { + found = true; + break; + } + } + if (!found) { + ret[n2++] = right[i]; + } + } + ret.realloc(n2); + return ret; + } /// concat three sequences template diff --git a/include/comphelper/servicedecl.hxx b/include/comphelper/servicedecl.hxx index 69c640305907..0e3fef2e2380 100644 --- a/include/comphelper/servicedecl.hxx +++ b/include/comphelper/servicedecl.hxx @@ -197,6 +197,22 @@ public: : ServiceImpl_BASE(rServiceDecl, xContext) {} }; +template +class InheritingServiceImpl : public OwnServiceImpl< ImplT > +{ +typedef OwnServiceImpl< ImplT > ServiceImpl_BASE; +public: + InheritingServiceImpl( + ServiceDecl const& rServiceDecl, + css::uno::Sequence const& args, + css::uno::Reference const& xContext ) + : ServiceImpl_BASE(rServiceDecl, args, xContext) {} + InheritingServiceImpl( + ServiceDecl const& rServiceDecl, + css::uno::Reference const& xContext ) + : ServiceImpl_BASE(rServiceDecl, xContext) {} +}; + template struct PostProcessDefault { css::uno::Reference @@ -298,6 +314,24 @@ struct class_ : public serviceimpl_base< detail::ServiceImpl, WithArgsT explicit class_( PostProcessFuncT const& postProcessFunc ) : baseT( postProcessFunc ) {} }; +template > +struct inheritingClass_ : public serviceimpl_base< detail::InheritingServiceImpl, WithArgsT > +{ + typedef serviceimpl_base< detail::InheritingServiceImpl, WithArgsT > baseT; + /** Default ctor. Implementation class without args, expecting + component context as single argument. + */ + inheritingClass_() : baseT() {} + template + /** Ctor to pass a post processing function/functor. + + @tpl PostProcessDefaultT let your compiler deduce this + @param postProcessFunc function/functor that gets the yet unacquired + ImplT_ pointer returning a + uno::Reference + */ + explicit inheritingClass_( PostProcessFuncT const& postProcessFunc ) : baseT( postProcessFunc ) {} +}; // component_... helpers with arbitrary service declarations: -- cgit