Kaydet (Commit) 67bb39e3 authored tarafından Matúš Kukan's avatar Matúš Kukan

svt: Use constructor feature for GObjectImpl.

Change-Id: I324dd00205319fe4e8f7b0b352ed2ab6422fcbbd
üst d5524ff9
...@@ -17,18 +17,20 @@ ...@@ -17,18 +17,20 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 . * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/ */
#include <cppuhelper/implbase2.hxx>
#include <comphelper/servicedecl.hxx> #include <cppuhelper/supportsservice.hxx>
#include <cppuhelper/implbase1.hxx>
#include <com/sun/star/graphic/XGraphicObject.hpp> #include <com/sun/star/graphic/XGraphicObject.hpp>
#include <com/sun/star/lang/IllegalArgumentException.hpp> #include <com/sun/star/lang/IllegalArgumentException.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <svtools/grfmgr.hxx> #include <svtools/grfmgr.hxx>
#include <rtl/ref.hxx>
using namespace com::sun::star; using namespace com::sun::star;
namespace unographic { namespace {
typedef ::cppu::WeakImplHelper1< graphic::XGraphicObject > GObjectAccess_BASE; typedef ::cppu::WeakImplHelper2< graphic::XGraphicObject, css::lang::XServiceInfo > GObjectAccess_BASE;
// Simple uno wrapper around the GraphicObject class to allow basic // Simple uno wrapper around the GraphicObject class to allow basic
// access. ( and solves a horrible cyclic link problem between // access. ( and solves a horrible cyclic link problem between
// goodies/toolkit/extensions ) // goodies/toolkit/extensions )
...@@ -37,15 +39,36 @@ class GObjectImpl : public GObjectAccess_BASE ...@@ -37,15 +39,36 @@ class GObjectImpl : public GObjectAccess_BASE
::osl::Mutex m_aMutex; ::osl::Mutex m_aMutex;
std::auto_ptr< GraphicObject > mpGObject; std::auto_ptr< GraphicObject > mpGObject;
public: public:
GObjectImpl( uno::Sequence< uno::Any > const & args, uno::Reference< uno::XComponentContext > const & xComponentContext ) throw (uno::RuntimeException); GObjectImpl( uno::Sequence< uno::Any > const & args ) throw (uno::RuntimeException);
// XGraphicObject // XGraphicObject
virtual uno::Reference< graphic::XGraphic > SAL_CALL getGraphic() throw (uno::RuntimeException); virtual uno::Reference< graphic::XGraphic > SAL_CALL getGraphic() throw (uno::RuntimeException);
virtual void SAL_CALL setGraphic( const uno::Reference< graphic::XGraphic >& _graphic ) throw (uno::RuntimeException); virtual void SAL_CALL setGraphic( const uno::Reference< graphic::XGraphic >& _graphic ) throw (uno::RuntimeException);
OUString SAL_CALL getUniqueID() throw (uno::RuntimeException); OUString SAL_CALL getUniqueID() throw (uno::RuntimeException);
virtual OUString SAL_CALL getImplementationName()
throw (css::uno::RuntimeException)
{
return OUString("com.sun.star.graphic.GraphicObject");
}
virtual sal_Bool SAL_CALL supportsService(OUString const & ServiceName)
throw (css::uno::RuntimeException)
{
return cppu::supportsService(this, ServiceName);
}
virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames()
throw (css::uno::RuntimeException)
{
uno::Sequence< OUString > aRet(1);
OUString* pArray = aRet.getArray();
pArray[0] = OUString("com.sun.star.graphic.GraphicObject");
return aRet;
}
}; };
GObjectImpl::GObjectImpl( uno::Sequence< uno::Any > const & args, uno::Reference< uno::XComponentContext > const & /*xComponentContext*/ ) throw (uno::RuntimeException) GObjectImpl::GObjectImpl( uno::Sequence< uno::Any > const & args) throw (uno::RuntimeException)
{ {
if ( args.getLength() == 1 ) if ( args.getLength() == 1 )
{ {
...@@ -85,11 +108,16 @@ OUString SAL_CALL GObjectImpl::getUniqueID() throw (uno::RuntimeException) ...@@ -85,11 +108,16 @@ OUString SAL_CALL GObjectImpl::getUniqueID() throw (uno::RuntimeException)
return sId; return sId;
} }
}
namespace sdecl = comphelper::service_decl; extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
sdecl::class_<GObjectImpl, sdecl::with_args<true> > serviceBI; com_sun_star_graphic_GraphicObject_get_implementation(
extern sdecl::ServiceDecl const serviceDecl( serviceBI, "com.sun.star.graphic.GraphicObject", "com.sun.star.graphic.GraphicObject" ); SAL_UNUSED_PARAMETER css::uno::XComponentContext *,
css::uno::Sequence<css::uno::Any> const &arguments)
{
rtl::Reference<GObjectImpl> x(new GObjectImpl(arguments));
x->acquire();
return static_cast<cppu::OWeakObject *>(x.get());
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -37,13 +37,6 @@ using namespace ::com::sun::star::uno; ...@@ -37,13 +37,6 @@ using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::registry; using namespace ::com::sun::star::registry;
using namespace ::com::sun::star::lang; using namespace ::com::sun::star::lang;
namespace sdecl = comphelper::service_decl;
namespace unographic {
extern sdecl::ServiceDecl const serviceDecl;
}
// for CreateInstance functions implemented elsewhere, while the function is within a namespace // for CreateInstance functions implemented elsewhere, while the function is within a namespace
#define DECLARE_CREATEINSTANCE_NAMESPACE( nmspe, ImplName ) \ #define DECLARE_CREATEINSTANCE_NAMESPACE( nmspe, ImplName ) \
namespace nmspe { \ namespace nmspe { \
...@@ -56,7 +49,7 @@ extern "C" ...@@ -56,7 +49,7 @@ extern "C"
{ {
SAL_DLLPUBLIC_EXPORT void * SAL_CALL svt_component_getFactory ( SAL_DLLPUBLIC_EXPORT void * SAL_CALL svt_component_getFactory (
const sal_Char * pImplementationName, void * _pServiceManager, void * pRegistryKey) const sal_Char * pImplementationName, void * _pServiceManager, void * )
{ {
void * pResult = 0; void * pResult = 0;
if ( _pServiceManager ) if ( _pServiceManager )
...@@ -76,14 +69,6 @@ SAL_DLLPUBLIC_EXPORT void * SAL_CALL svt_component_getFactory ( ...@@ -76,14 +69,6 @@ SAL_DLLPUBLIC_EXPORT void * SAL_CALL svt_component_getFactory (
svt::OAddressBookSourceDialogUno_CreateInstance, svt::OAddressBookSourceDialogUno_CreateInstance,
aServiceNames); aServiceNames);
} }
else
{
pResult = comphelper::service_decl::component_getFactoryHelper(
pImplementationName,
static_cast<css::lang::XMultiServiceFactory *>(_pServiceManager),
static_cast<css::registry::XRegistryKey *>(pRegistryKey),
unographic::serviceDecl );
}
if ( xFactory.is() ) if ( xFactory.is() )
{ {
......
...@@ -34,7 +34,8 @@ ...@@ -34,7 +34,8 @@
constructor="com_sun_star_comp_svtools_uno_Wizard_get_implementation"> constructor="com_sun_star_comp_svtools_uno_Wizard_get_implementation">
<service name="com.sun.star.ui.dialogs.Wizard"/> <service name="com.sun.star.ui.dialogs.Wizard"/>
</implementation> </implementation>
<implementation name="com.sun.star.graphic.GraphicObject"> <implementation name="com.sun.star.graphic.GraphicObject"
constructor="com_sun_star_graphic_GraphicObject_get_implementation">
<service name="com.sun.star.graphic.GraphicObject"/> <service name="com.sun.star.graphic.GraphicObject"/>
</implementation> </implementation>
<implementation name="com.sun.star.svtools.SvFilterOptionsDialog" <implementation name="com.sun.star.svtools.SvFilterOptionsDialog"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment