Update to m13
[ooovba.git] / applied_patches / 0397-vba-servicemacros-rework.diff
blob7059edbb12ac4ab0667e09c6617a935518ec41c6
1 diff --git comphelper/inc/comphelper/servicedecl.hxx comphelper/inc/comphelper/servicedecl.hxx
2 index bbfb1c8..bd114be 100644
3 --- comphelper/inc/comphelper/servicedecl.hxx
4 +++ comphelper/inc/comphelper/servicedecl.hxx
5 @@ -169,21 +169,20 @@ template <bool> struct with_args;
7 /// @internal
8 namespace detail {
10 template <typename ImplT>
11 -class ServiceImpl
12 - : public ::cppu::ImplInheritanceHelper1<ImplT, css::lang::XServiceInfo>,
13 +class OwnServiceImpl
14 + : public ImplT,
15 private ::boost::noncopyable
17 - typedef ::cppu::ImplInheritanceHelper1<ImplT,css::lang::XServiceInfo> BaseT;
18 + typedef ImplT BaseT;
20 public:
21 - ServiceImpl(
22 + OwnServiceImpl(
23 ServiceDecl const& rServiceDecl,
24 css::uno::Sequence<css::uno::Any> const& args,
25 css::uno::Reference<css::uno::XComponentContext> const& xContext )
26 - : BaseT(args, xContext), m_rServiceDecl(rServiceDecl) {}
27 - ServiceImpl(
28 + :BaseT(args, xContext), m_rServiceDecl(rServiceDecl) {}
29 + OwnServiceImpl(
30 ServiceDecl const& rServiceDecl,
31 css::uno::Reference<css::uno::XComponentContext> const& xContext )
32 : BaseT(xContext), m_rServiceDecl(rServiceDecl) {}
33 @@ -206,6 +205,22 @@ private:
34 ServiceDecl const& m_rServiceDecl;
37 +template <typename ImplT>
38 +class ServiceImpl : public OwnServiceImpl< ::cppu::ImplInheritanceHelper1<ImplT,css::lang::XServiceInfo> >
40 +typedef OwnServiceImpl< ::cppu::ImplInheritanceHelper1<ImplT,css::lang::XServiceInfo> > ServiceImpl_BASE;
41 +public:
42 + ServiceImpl(
43 + ServiceDecl const& rServiceDecl,
44 + css::uno::Sequence<css::uno::Any> const& args,
45 + css::uno::Reference<css::uno::XComponentContext> const& xContext )
46 + : ServiceImpl_BASE(rServiceDecl, args, xContext) {}
47 + ServiceImpl(
48 + ServiceDecl const& rServiceDecl,
49 + css::uno::Reference<css::uno::XComponentContext> const& xContext )
50 + : ServiceImpl_BASE(rServiceDecl, xContext) {}
51 +};
53 template <typename ServiceImplT>
54 struct PostProcessDefault {
55 css::uno::Reference<css::uno::XInterface>
56 @@ -230,7 +245,7 @@ struct CreateFunc<ImplT, PostProcessFuncT, with_args<false> > {
57 const& xContext ) const
59 return m_postProcessFunc(
60 - new ServiceImpl<ImplT>( rServiceDecl, xContext ) );
61 + new ImplT( rServiceDecl, xContext ) );
65 @@ -247,7 +262,7 @@ struct CreateFunc<ImplT, PostProcessFuncT, with_args<true> > {
66 const& xContext ) const
68 return m_postProcessFunc(
69 - new ServiceImpl<ImplT>( rServiceDecl, args, xContext ) );
70 + new ImplT( rServiceDecl, args, xContext ) );
74 @@ -261,18 +276,17 @@ struct CreateFunc<ImplT, PostProcessFuncT, with_args<true> > {
75 or just (uno::Reference<uno::XComponentContext>)
77 template <typename ImplT_, typename WithArgsT = with_args<false> >
78 -struct class_ {
79 +struct serviceimpl_base {
80 typedef ImplT_ ImplT;
81 - typedef detail::ServiceImpl<ImplT_> ServiceImplT;
83 detail::CreateFuncF const m_createFunc;
85 - typedef detail::PostProcessDefault<ServiceImplT> PostProcessDefaultT;
86 + typedef detail::PostProcessDefault<ImplT> PostProcessDefaultT;
88 /** Default ctor. Implementation class without args, expecting
89 component context as single argument.
91 - class_() : m_createFunc(
92 + serviceimpl_base() : m_createFunc(
93 detail::CreateFunc<ImplT, PostProcessDefaultT, WithArgsT>(
94 PostProcessDefaultT() ) ) {}
96 @@ -284,11 +298,29 @@ struct class_ {
97 uno::Reference<uno::XInterface>
99 template <typename PostProcessFuncT>
100 - explicit class_( PostProcessFuncT const& postProcessFunc )
101 + explicit serviceimpl_base( PostProcessFuncT const& postProcessFunc )
102 : m_createFunc( detail::CreateFunc<ImplT, PostProcessFuncT, WithArgsT>(
103 postProcessFunc ) ) {}
106 +template <typename ImplT_, typename WithArgsT = with_args<false> >
107 +struct class_ : public serviceimpl_base< detail::ServiceImpl<ImplT_>, WithArgsT >
109 + typedef serviceimpl_base< detail::ServiceImpl<ImplT_>, WithArgsT > baseT;
110 + /** Default ctor. Implementation class without args, expecting
111 + component context as single argument.
112 + */
113 + class_() : baseT() {}
114 + template <typename PostProcessFuncT>
115 + /** Ctor to pass a post processing function/functor.
117 + @tpl PostProcessDefaultT let your compiler deduce this
118 + @param postProcessFunc function/functor that gets the yet unacquired
119 + ImplT_ pointer returning a
120 + uno::Reference<uno::XInterface>
121 + */
122 + explicit class_( PostProcessFuncT const& postProcessFunc ) : baseT( postProcessFunc ) {}
126 // component_... helpers with arbitrary service declarations:
127 diff --git sc/source/ui/vba/helperdecl.hxx sc/source/ui/vba/helperdecl.hxx
128 index 1581e66..c3c1007 100644
129 --- sc/source/ui/vba/helperdecl.hxx
130 +++ sc/source/ui/vba/helperdecl.hxx
131 @@ -32,107 +32,25 @@
133 namespace comphelper {
134 namespace service_decl {
136 -namespace detail {
137 -namespace css = ::com::sun::star;
138 -template <typename ImplT>
139 -class OwnServiceImpl
140 - : public ImplT,
141 - private ::boost::noncopyable
143 - typedef ImplT BaseT;
145 -public:
146 - OwnServiceImpl(
147 - ServiceDecl const& rServiceDecl,
148 - css::uno::Sequence<css::uno::Any> const& args,
149 - css::uno::Reference<css::uno::XComponentContext> const& xContext )
150 - :BaseT(args, xContext), m_rServiceDecl(rServiceDecl) {}
151 - OwnServiceImpl(
152 - ServiceDecl const& rServiceDecl,
153 - css::uno::Reference<css::uno::XComponentContext> const& xContext )
154 - : BaseT(xContext), m_rServiceDecl(rServiceDecl) {}
156 - // XServiceInfo
157 - virtual ::rtl::OUString SAL_CALL getImplementationName()
158 - throw (css::uno::RuntimeException) {
159 - return m_rServiceDecl.getImplementationName();
161 - virtual sal_Bool SAL_CALL supportsService( ::rtl::OUString const& name )
162 - throw (css::uno::RuntimeException) {
163 - return m_rServiceDecl.supportsService(name);
165 - virtual css::uno::Sequence< ::rtl::OUString>
166 - SAL_CALL getSupportedServiceNames() throw (css::uno::RuntimeException) {
167 - return m_rServiceDecl.getSupportedServiceNames();
170 -private:
171 - ServiceDecl const& m_rServiceDecl;
175 -template <typename ImplT, typename WithArgsT>
176 -struct OwnCreateFunc;
178 -template <typename ImplT>
179 -struct OwnCreateFunc<ImplT, with_args<false> > {
180 - explicit OwnCreateFunc( )
181 - {}
183 - css::uno::Reference<css::uno::XInterface>
184 - operator()( ServiceDecl const& rServiceDecl,
185 - css::uno::Sequence<css::uno::Any> const&,
186 - css::uno::Reference<css::uno::XComponentContext>
187 - const& xContext ) const
189 - return css::uno::Reference< ooo::vba::XHelperInterface >(new OwnServiceImpl<ImplT>( rServiceDecl, xContext ));
193 -template <typename ImplT>
194 -struct OwnCreateFunc<ImplT, with_args<true> > {
195 - explicit OwnCreateFunc( )
196 - {}
198 - css::uno::Reference<css::uno::XInterface>
199 - operator()( ServiceDecl const& rServiceDecl,
200 - css::uno::Sequence<css::uno::Any> const& args,
201 - css::uno::Reference<css::uno::XComponentContext>
202 - const& xContext ) const
204 - css::uno::Reference< ooo::vba::XHelperInterface > xHelp(
205 - new OwnServiceImpl<ImplT>( rServiceDecl, args, xContext ) );
206 - css::uno::Reference< css::uno::XInterface > xIf( xHelp, css::uno::UNO_QUERY ) ;
207 - return xIf;
211 -} // namespace detail
213 -/** Defines a service implementation class.
215 - @tpl ImplT_ service implementation class
216 - @WithArgsT whether the implementation class ctor expects arguments
217 - (uno::Sequence<uno::Any>, uno::Reference<uno::XComponentContext>)
218 - or just (uno::Reference<uno::XComponentContext>)
220 template <typename ImplT_, typename WithArgsT = with_args<false> >
221 -struct vba_service_class_ {
222 - typedef ImplT_ ImplT;
223 - typedef detail::OwnServiceImpl<ImplT_ > ServiceImplT;
225 - detail::CreateFuncF const m_createFunc;
227 +struct vba_service_class_ : public serviceimpl_base< detail::OwnServiceImpl<ImplT_>, WithArgsT >
229 + typedef serviceimpl_base< detail::OwnServiceImpl<ImplT_>, WithArgsT > baseT;
230 /** Default ctor. Implementation class without args, expecting
231 component context as single argument.
233 - vba_service_class_() : m_createFunc(
234 - detail::OwnCreateFunc<ImplT, WithArgsT>() ) {}
236 + vba_service_class_() : baseT() {}
237 + template <typename PostProcessFuncT>
238 + /** Ctor to pass a post processing function/functor.
240 + @tpl PostProcessDefaultT let your compiler deduce this
241 + @param postProcessFunc function/functor that gets the yet unacquired
242 + ImplT_ pointer returning a
243 + uno::Reference<uno::XInterface>
244 + */
245 + explicit vba_service_class_( PostProcessFuncT const& postProcessFunc ) : baseT( postProcessFunc ) {}
249 } // namespace service_decl
250 } // namespace comphelper