[Libreoffice-commits] .: 2 commits - comphelper/source eventattacher/source extensions/source extensions/test pyuno/source udkapi/com udkapi/UnoApi_udkapi.mk
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Wed Sep 5 06:47:37 PDT 2012
comphelper/source/eventattachermgr/eventattachermgr.cxx | 22 +++++-----
eventattacher/source/eventattacher.cxx | 4 -
extensions/source/ole/unoobjw.cxx | 34 +++++++--------
extensions/test/ole/cpnt/cpnt.cxx | 35 +++++++---------
pyuno/source/module/pyuno_runtime.cxx | 12 +----
udkapi/UnoApi_udkapi.mk | 3 +
udkapi/com/sun/star/reflection/CoreReflection.idl | 10 ----
udkapi/com/sun/star/reflection/theCoreReflection.idl | 35 ++++++++++++++++
8 files changed, 90 insertions(+), 65 deletions(-)
New commits:
commit 0411360989b7a1371d4fa13dcd695ebe9157bbd1
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Wed Sep 5 15:46:18 2012 +0200
Some clean up of previous commit
Change-Id: I05287fd79455f968c770d61bf5f320b07bba7d9e
diff --git a/pyuno/source/module/pyuno_runtime.cxx b/pyuno/source/module/pyuno_runtime.cxx
index a89b182..c61ae00 100644
--- a/pyuno/source/module/pyuno_runtime.cxx
+++ b/pyuno/source/module/pyuno_runtime.cxx
@@ -46,7 +46,6 @@ using com::sun::star::uno::TypeDescription;
using com::sun::star::uno::Sequence;
using com::sun::star::uno::Type;
using com::sun::star::uno::UNO_QUERY;
-using com::sun::star::uno::UNO_QUERY_THROW;
using com::sun::star::uno::Exception;
using com::sun::star::uno::RuntimeException;
using com::sun::star::uno::XComponentContext;
commit b679a2a02180c017bd8b596fb2e4f283bad93b75
Author: Noel Grandin <noel at peralex.com>
Date: Tue Sep 4 16:12:17 2012 +0200
fdo#46808, Adapt reflection::CoreReflection UNO service to new style
The XComponent part of the interface made no sense for a singleton,
so it was removed.
Explicitly document the 'theCoreReflection' singleton and move it
into it's own file.
Deprecated the now old CoreReflection service.
Change-Id: Ib8befa87c7da7eb53a2f587948fd54a64c082472
diff --git a/comphelper/source/eventattachermgr/eventattachermgr.cxx b/comphelper/source/eventattachermgr/eventattachermgr.cxx
index 644d2d9..9b24026 100644
--- a/comphelper/source/eventattachermgr/eventattachermgr.cxx
+++ b/comphelper/source/eventattachermgr/eventattachermgr.cxx
@@ -23,6 +23,7 @@
#endif
#include <osl/mutex.hxx>
#include <osl/diagnose.h>
+#include <comphelper/componentcontext.hxx>
#include <comphelper/eventattachermgr.hxx>
#include <com/sun/star/beans/XIntrospection.hpp>
#include <com/sun/star/io/XObjectInputStream.hpp>
@@ -31,6 +32,7 @@
#include <com/sun/star/io/XMarkableStream.hpp>
#include <com/sun/star/lang/XInitialization.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/reflection/theCoreReflection.hpp>
#include <com/sun/star/reflection/XIdlClass.hpp>
#include <com/sun/star/reflection/XIdlReflection.hpp>
#include <com/sun/star/reflection/XIdlMethod.hpp>
@@ -94,14 +96,14 @@ class ImplEventAttacherManager
OInterfaceContainerHelper aScriptListeners;
// Instance of EventAttacher
Reference< XEventAttacher2 > xAttacher;
- Reference< XMultiServiceFactory > mxSMgr;
+ Reference< XComponentContext > mxContext;
Reference< XIdlReflection > mxCoreReflection;
Reference< XIntrospection > mxIntrospection;
Reference< XTypeConverter > xConverter;
sal_Int16 nVersion;
public:
ImplEventAttacherManager( const Reference< XIntrospection > & rIntrospection,
- const Reference< XMultiServiceFactory > rSMgr );
+ const Reference< XComponentContext > xContext );
~ImplEventAttacherManager();
// Methods of XEventAttacherManager
@@ -361,7 +363,7 @@ Reference< XEventAttacherManager > createEventAttacherManager( const Reference<
if ( xIFace.is() )
{
Reference< XIntrospection > xIntrospection( xIFace, UNO_QUERY);
- return new ImplEventAttacherManager( xIntrospection, rSMgr );
+ return new ImplEventAttacherManager( xIntrospection, comphelper::ComponentContext(rSMgr).getUNOContext() );
}
}
@@ -370,19 +372,20 @@ Reference< XEventAttacherManager > createEventAttacherManager( const Reference<
//-----------------------------------------------------------------------------
ImplEventAttacherManager::ImplEventAttacherManager( const Reference< XIntrospection > & rIntrospection,
- const Reference< XMultiServiceFactory > rSMgr )
+ const Reference< XComponentContext > xContext )
: aScriptListeners( aLock )
- , mxSMgr( rSMgr )
+ , mxContext( xContext )
, mxIntrospection( rIntrospection )
{
- if ( rSMgr.is() )
+ if ( xContext.is() )
{
- Reference< XInterface > xIFace( rSMgr->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.script.EventAttacher" )) ) );
+ Reference< XInterface > xIFace( xContext->getServiceManager()->createInstanceWithContext(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.script.EventAttacher" )), xContext) );
if ( xIFace.is() )
{
xAttacher = Reference< XEventAttacher2 >::query( xIFace );
}
- xConverter = Converter::create(comphelper::ComponentContext(rSMgr).getUNOContext());
+ xConverter = Converter::create(xContext);
}
Reference< XInitialization > xInit( xAttacher, UNO_QUERY );
@@ -405,8 +408,7 @@ Reference< XIdlReflection > ImplEventAttacherManager::getReflection() throw( Exc
// Do we already have a service? If not, create one.
if( !mxCoreReflection.is() )
{
- Reference< XInterface > xIFace( mxSMgr->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.reflection.CoreReflection" )) ) );
- mxCoreReflection = Reference< XIdlReflection >( xIFace, UNO_QUERY);
+ mxCoreReflection = theCoreReflection::get(mxContext);
}
return mxCoreReflection;
}
diff --git a/eventattacher/source/eventattacher.cxx b/eventattacher/source/eventattacher.cxx
index 06764fe..0d04048 100644
--- a/eventattacher/source/eventattacher.cxx
+++ b/eventattacher/source/eventattacher.cxx
@@ -28,6 +28,7 @@
#include <com/sun/star/script/Converter.hpp>
#include <com/sun/star/script/XAllListener.hpp>
#include <com/sun/star/script/XInvocationAdapterFactory.hpp>
+#include <com/sun/star/reflection/theCoreReflection.hpp>
#include <com/sun/star/reflection/XIdlReflection.hpp>
// InvocationToAllListenerMapper
@@ -407,8 +408,7 @@ Reference< XIdlReflection > EventAttacherImpl::getReflection() throw( Exception
Guard< Mutex > aGuard( m_aMutex );
if( !m_xReflection.is() )
{
- Reference< XInterface > xIFace( m_xSMgr->createInstance( rtl::OUString("com.sun.star.reflection.CoreReflection") ) );
- m_xReflection = Reference< XIdlReflection >( xIFace, UNO_QUERY);
+ m_xReflection = theCoreReflection::get(comphelper::ComponentContext(m_xSMgr).getUNOContext());
}
return m_xReflection;
}
diff --git a/extensions/source/ole/unoobjw.cxx b/extensions/source/ole/unoobjw.cxx
index 641e643..cb0c408 100644
--- a/extensions/source/ole/unoobjw.cxx
+++ b/extensions/source/ole/unoobjw.cxx
@@ -43,6 +43,7 @@
#include <com/sun/star/beans/MethodConcept.hpp>
#include <com/sun/star/beans/PropertyConcept.hpp>
#include <com/sun/star/script/FailReason.hpp>
+#include <com/sun/star/reflection/theCoreReflection.hpp>
#include <com/sun/star/reflection/ParamInfo.hpp>
#include <com/sun/star/beans/XExactName.hpp>
#include <com/sun/star/container/NoSuchElementException.hpp>
@@ -53,6 +54,7 @@
#include <com/sun/star/reflection/XIdlReflection.hpp>
#include <osl/interlck.h>
#include <com/sun/star/uno/genfunc.h>
+#include <comphelper/componentcontext.hxx>
#include <cppuhelper/implbase1.hxx>
#include "comifaces.hxx"
@@ -1120,27 +1122,23 @@ HRESULT InterfaceOleWrapper_Impl::InvokeGeneral( DISPID dispidMember, unsigned s
sal_Bool bStruct= sal_False;
- Reference<XInterface> xIntCore= m_smgr->createInstance( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.reflection.CoreReflection")));
- Reference<XIdlReflection> xRefl( xIntCore, UNO_QUERY);
- if( xRefl.is() )
+ Reference<XIdlReflection> xRefl = theCoreReflection::get(comphelper::ComponentContext(m_smgr).getUNOContext());
+ // the first parameter is in DISPPARAMS rgvargs contains the name of the struct.
+ CComVariant arg;
+ if( pdispparams->cArgs == 1 && SUCCEEDED( arg.ChangeType( VT_BSTR, &pdispparams->rgvarg[0])) )
{
- // the first parameter is in DISPPARAMS rgvargs contains the name of the struct.
- CComVariant arg;
- if( pdispparams->cArgs == 1 && SUCCEEDED( arg.ChangeType( VT_BSTR, &pdispparams->rgvarg[0])) )
+ Reference<XIdlClass> classStruct= xRefl->forName( reinterpret_cast<const sal_Unicode*>(arg.bstrVal));
+ if( classStruct.is())
{
- Reference<XIdlClass> classStruct= xRefl->forName( reinterpret_cast<const sal_Unicode*>(arg.bstrVal));
- if( classStruct.is())
- {
- Any anyStruct;
- classStruct->createObject( anyStruct);
- CComVariant var;
- anyToVariant( &var, anyStruct );
+ Any anyStruct;
+ classStruct->createObject( anyStruct);
+ CComVariant var;
+ anyToVariant( &var, anyStruct );
- if( var.vt == VT_DISPATCH)
- {
- VariantCopy( pvarResult, & var);
- bStruct= sal_True;
- }
+ if( var.vt == VT_DISPATCH)
+ {
+ VariantCopy( pvarResult, & var);
+ bStruct= sal_True;
}
}
}
diff --git a/extensions/test/ole/cpnt/cpnt.cxx b/extensions/test/ole/cpnt/cpnt.cxx
index b20795e..0f94488 100644
--- a/extensions/test/ole/cpnt/cpnt.cxx
+++ b/extensions/test/ole/cpnt/cpnt.cxx
@@ -33,12 +33,14 @@
#include <com/sun/star/registry/XRegistryKey.hpp>
#include <osl/diagnose.h>
#include <uno/environment.h>
+#include <comphelper/componentcontext.hxx>
#include <cppuhelper/factory.hxx>
// OPTIONAL is a constant in com.sun.star.beans.PropertyAttributes but it must be
// undef'd in some header files
#define OPTIONAL OPTIONAL
#include <com/sun/star/beans/PropertyAttribute.hpp>
#include <com/sun/star/script/XInvocation.hpp>
+#include <com/sun/star/reflection/theCoreReflection.hpp>
#include <com/sun/star/reflection/XIdlReflection.hpp>
#include <com/sun/star/lang/XEventListener.hpp>
@@ -1491,27 +1493,24 @@ void SAL_CALL OComponent::testInterface( const Reference< XCallback >& xCallbac
}
case 101:
{
- Reference<XIdlReflection> xRefl( m_rFactory->createInstance(L"com.sun.star.reflection.CoreReflection"), UNO_QUERY);
- if( xRefl.is())
- {
- Reference<XIdlClass> xClass= xRefl->forName(L"oletest.SimpleStruct");
- Any any;
- if( xClass.is())
- xClass->createObject( any);
-
- if( any.getValueTypeClass() == TypeClass_STRUCT)
- {
- SimpleStruct* pStruct= ( SimpleStruct*) any.getValue();
- pStruct->message= OUString(RTL_CONSTASCII_USTRINGPARAM("This struct was created in OleTest"));
+ Reference<XIdlReflection> xRefl( theCoreReflection::get(comphelper::ComponentContext(m_rFactory).getUNOContext()) );
+ Reference<XIdlClass> xClass= xRefl->forName(L"oletest.SimpleStruct");
+ Any any;
+ if( xClass.is())
+ xClass->createObject( any);
- SimpleStruct aStruct;
- any >>= aStruct;
- xCallback->inoutStruct( aStruct);
- // a Struct should now contain a different message
- MessageBox( NULL, W2T(aStruct.message), _T("OleTest in out parameter"), MB_OK);
- }
+ if( any.getValueTypeClass() == TypeClass_STRUCT)
+ {
+ SimpleStruct* pStruct= ( SimpleStruct*) any.getValue();
+ pStruct->message= OUString(RTL_CONSTASCII_USTRINGPARAM("This struct was created in OleTest"));
+ SimpleStruct aStruct;
+ any >>= aStruct;
+ xCallback->inoutStruct( aStruct);
+ // a Struct should now contain a different message
+ MessageBox( NULL, W2T(aStruct.message), _T("OleTest in out parameter"), MB_OK);
}
+
break;
}
case 102:
diff --git a/pyuno/source/module/pyuno_runtime.cxx b/pyuno/source/module/pyuno_runtime.cxx
index 3196be6..a89b182 100644
--- a/pyuno/source/module/pyuno_runtime.cxx
+++ b/pyuno/source/module/pyuno_runtime.cxx
@@ -31,6 +31,7 @@
#include <com/sun/star/beans/XMaterialHolder.hpp>
#include <com/sun/star/script/Converter.hpp>
+#include <com/sun/star/reflection/theCoreReflection.hpp>
using rtl::OUString;
using rtl::OUStringToOString;
@@ -45,11 +46,13 @@ using com::sun::star::uno::TypeDescription;
using com::sun::star::uno::Sequence;
using com::sun::star::uno::Type;
using com::sun::star::uno::UNO_QUERY;
+using com::sun::star::uno::UNO_QUERY_THROW;
using com::sun::star::uno::Exception;
using com::sun::star::uno::RuntimeException;
using com::sun::star::uno::XComponentContext;
using com::sun::star::lang::XSingleServiceFactory;
using com::sun::star::lang::XUnoTunnel;
+using com::sun::star::reflection::theCoreReflection;
using com::sun::star::reflection::XIdlReflection;
using com::sun::star::script::Converter;
using com::sun::star::script::XTypeConverter;
@@ -264,15 +267,7 @@ PyRef stRuntimeImpl::create( const Reference< XComponentContext > &ctx )
OUString( "pyuno: couldn't instantiate typeconverter service" ),
Reference< XInterface > () );
- c->xCoreReflection = Reference< XIdlReflection > (
- ctx->getServiceManager()->createInstanceWithContext(
- OUString( "com.sun.star.reflection.CoreReflection" ),
- ctx ),
- UNO_QUERY );
- if( ! c->xCoreReflection.is() )
- throw RuntimeException(
- OUString( "pyuno: couldn't instantiate corereflection service" ),
- Reference< XInterface > () );
+ c->xCoreReflection = theCoreReflection::get(ctx);
c->xAdapterFactory = Reference< XInvocationAdapterFactory2 > (
ctx->getServiceManager()->createInstanceWithContext(
diff --git a/udkapi/UnoApi_udkapi.mk b/udkapi/UnoApi_udkapi.mk
index d909fb6..cdffbda 100644
--- a/udkapi/UnoApi_udkapi.mk
+++ b/udkapi/UnoApi_udkapi.mk
@@ -143,6 +143,9 @@ $(eval $(call gb_UnoApi_add_idlfiles_nohdl,udkapi,udkapi/com/sun/star/io,\
SequenceOutputStream \
TempFile \
))
+$(eval $(call gb_UnoApi_add_idlfiles_nohdl,udkapi,udkapi/com/sun/star/reflection,\
+ theCoreReflection \
+))
$(eval $(call gb_UnoApi_add_idlfiles_nohdl,udkapi,udkapi/com/sun/star/registry,\
ImplementationRegistration \
SimpleRegistry \
diff --git a/udkapi/com/sun/star/reflection/CoreReflection.idl b/udkapi/com/sun/star/reflection/CoreReflection.idl
index 8dc78a3..7d2cdde 100644
--- a/udkapi/com/sun/star/reflection/CoreReflection.idl
+++ b/udkapi/com/sun/star/reflection/CoreReflection.idl
@@ -30,6 +30,8 @@
/** This service is the implementation of the reflection API.
You can obtain information about types, modify values of reflected types
and call on objects.
+
+ @deprecated Rather use the 'theCoreReflection' singleton.
*/
published service CoreReflection
{
@@ -42,14 +44,6 @@ published service CoreReflection
[optional] interface com::sun::star::lang::XComponent;
};
-/** Accessable singleton to CoreReflection instance.
-singleton theCoreReflection
-{
- service CoreReflection;
-};
-*/
-
-
}; }; }; };
#endif
diff --git a/udkapi/com/sun/star/reflection/theCoreReflection.idl b/udkapi/com/sun/star/reflection/theCoreReflection.idl
new file mode 100644
index 0000000..f60914e
--- /dev/null
+++ b/udkapi/com/sun/star/reflection/theCoreReflection.idl
@@ -0,0 +1,35 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef __com_sun_star_reflection_theCoreReflection_idl__
+#define __com_sun_star_reflection_theCoreReflection_idl__
+
+#include <com/sun/star/reflection/XIdlReflection.idl>
+
+
+module com { module sun { module star { module reflection {
+
+
+singleton theCoreReflection : com::sun::star::reflection::XIdlReflection;
+
+
+}; }; }; };
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list