diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2015-03-17 12:25:11 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2015-03-17 12:25:11 +0100 |
commit | 3099c70b11c7e5b80fe4dbe3dc99171fb38c6fc2 (patch) | |
tree | 63699b525800b2c6708e90b817853bb60be5f6d8 /include/comphelper | |
parent | 5229726b4d4e7d76f410d221f8f8cd8abcfd5a19 (diff) |
Fix various XServiceInfo implementations
...to match what is recorded in the .component files
Change-Id: Ie548cd37872d3b8540222201afaac73040e65c8f
Diffstat (limited to 'include/comphelper')
-rw-r--r-- | include/comphelper/sequence.hxx | 27 | ||||
-rw-r--r-- | include/comphelper/servicedecl.hxx | 34 |
2 files changed, 61 insertions, 0 deletions
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<typename T> css::uno::Sequence<T> combineSequences( + css::uno::Sequence<T> const & left, css::uno::Sequence<T> const & right) + { + sal_Int32 n1 = left.getLength(); + css::uno::Sequence<T> 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 <class T> 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 <typename ImplT> +class InheritingServiceImpl : public OwnServiceImpl< ImplT > +{ +typedef OwnServiceImpl< ImplT > ServiceImpl_BASE; +public: + InheritingServiceImpl( + ServiceDecl const& rServiceDecl, + css::uno::Sequence<css::uno::Any> const& args, + css::uno::Reference<css::uno::XComponentContext> const& xContext ) + : ServiceImpl_BASE(rServiceDecl, args, xContext) {} + InheritingServiceImpl( + ServiceDecl const& rServiceDecl, + css::uno::Reference<css::uno::XComponentContext> const& xContext ) + : ServiceImpl_BASE(rServiceDecl, xContext) {} +}; + template <typename ServiceImplT> struct PostProcessDefault { css::uno::Reference<css::uno::XInterface> @@ -298,6 +314,24 @@ struct class_ : public serviceimpl_base< detail::ServiceImpl<ImplT_>, WithArgsT explicit class_( PostProcessFuncT const& postProcessFunc ) : baseT( postProcessFunc ) {} }; +template <typename ImplT_, typename WithArgsT = with_args<false> > +struct inheritingClass_ : public serviceimpl_base< detail::InheritingServiceImpl<ImplT_>, WithArgsT > +{ + typedef serviceimpl_base< detail::InheritingServiceImpl<ImplT_>, WithArgsT > baseT; + /** Default ctor. Implementation class without args, expecting + component context as single argument. + */ + inheritingClass_() : baseT() {} + template <typename PostProcessFuncT> + /** 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<uno::XInterface> + */ + explicit inheritingClass_( PostProcessFuncT const& postProcessFunc ) : baseT( postProcessFunc ) {} +}; // component_... helpers with arbitrary service declarations: |