diff options
author | Kohei Yoshida <kyoshida@novell.com> | 2010-01-29 22:03:10 +0100 |
---|---|---|
committer | Kohei Yoshida <kyoshida@novell.com> | 2010-01-29 22:03:10 +0100 |
commit | 324721c3ef3715b002328683f8045c5bcfca0013 (patch) | |
tree | ad304244c9b1d3abdb5eb4e414fa6b4c26100125 /comphelper | |
parent | 0ce0dd5863208500d8d4658f1f68f34e254ab015 (diff) | |
parent | 7f5f6c30e89c27422a1576ccceb9b0d79c8e3f0d (diff) |
rebased to m70
Diffstat (limited to 'comphelper')
-rw-r--r-- | comphelper/inc/comphelper/servicedecl.hxx | 60 | ||||
-rw-r--r-- | comphelper/qa/makefile.mk | 6 | ||||
-rw-r--r-- | comphelper/qa/test_string.cxx | 2 | ||||
-rw-r--r-- | comphelper/qa/test_weakbag.cxx | 2 | ||||
-rw-r--r-- | comphelper/source/misc/comphelper_services.cxx | 2 | ||||
-rw-r--r-- | comphelper/source/misc/documentiologring.cxx | 25 | ||||
-rw-r--r-- | comphelper/source/misc/documentiologring.hxx | 11 | ||||
-rw-r--r-- | comphelper/source/property/ChainablePropertySetInfo.cxx | 2 | ||||
-rw-r--r-- | comphelper/source/property/MasterPropertySetInfo.cxx | 4 | ||||
-rw-r--r-- | comphelper/source/property/opropertybag.cxx | 9 | ||||
-rw-r--r-- | comphelper/source/property/property.cxx | 25 | ||||
-rw-r--r-- | comphelper/source/property/propertysetinfo.cxx | 2 |
12 files changed, 102 insertions, 48 deletions
diff --git a/comphelper/inc/comphelper/servicedecl.hxx b/comphelper/inc/comphelper/servicedecl.hxx index a11598bdca85..7b77d3ba29e7 100644 --- a/comphelper/inc/comphelper/servicedecl.hxx +++ b/comphelper/inc/comphelper/servicedecl.hxx @@ -169,21 +169,20 @@ template <bool> struct with_args; /// @internal namespace detail { - template <typename ImplT> -class ServiceImpl - : public ::cppu::ImplInheritanceHelper1<ImplT, css::lang::XServiceInfo>, +class OwnServiceImpl + : public ImplT, private ::boost::noncopyable { - typedef ::cppu::ImplInheritanceHelper1<ImplT,css::lang::XServiceInfo> BaseT; + typedef ImplT BaseT; public: - ServiceImpl( + OwnServiceImpl( ServiceDecl const& rServiceDecl, css::uno::Sequence<css::uno::Any> const& args, css::uno::Reference<css::uno::XComponentContext> const& xContext ) - : BaseT(args, xContext), m_rServiceDecl(rServiceDecl) {} - ServiceImpl( + :BaseT(args, xContext), m_rServiceDecl(rServiceDecl) {} + OwnServiceImpl( ServiceDecl const& rServiceDecl, css::uno::Reference<css::uno::XComponentContext> const& xContext ) : BaseT(xContext), m_rServiceDecl(rServiceDecl) {} @@ -206,6 +205,22 @@ private: ServiceDecl const& m_rServiceDecl; }; +template <typename ImplT> +class ServiceImpl : public OwnServiceImpl< ::cppu::ImplInheritanceHelper1<ImplT,css::lang::XServiceInfo> > +{ +typedef OwnServiceImpl< ::cppu::ImplInheritanceHelper1<ImplT,css::lang::XServiceInfo> > ServiceImpl_BASE; +public: + ServiceImpl( + ServiceDecl const& rServiceDecl, + css::uno::Sequence<css::uno::Any> const& args, + css::uno::Reference<css::uno::XComponentContext> const& xContext ) + : ServiceImpl_BASE(rServiceDecl, args, xContext) {} + ServiceImpl( + 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> @@ -230,7 +245,7 @@ struct CreateFunc<ImplT, PostProcessFuncT, with_args<false> > { const& xContext ) const { return m_postProcessFunc( - new ServiceImpl<ImplT>( rServiceDecl, xContext ) ); + new ImplT( rServiceDecl, xContext ) ); } }; @@ -247,7 +262,7 @@ struct CreateFunc<ImplT, PostProcessFuncT, with_args<true> > { const& xContext ) const { return m_postProcessFunc( - new ServiceImpl<ImplT>( rServiceDecl, args, xContext ) ); + new ImplT( rServiceDecl, args, xContext ) ); } }; @@ -261,18 +276,17 @@ struct CreateFunc<ImplT, PostProcessFuncT, with_args<true> > { or just (uno::Reference<uno::XComponentContext>) */ template <typename ImplT_, typename WithArgsT = with_args<false> > -struct class_ { +struct serviceimpl_base { typedef ImplT_ ImplT; - typedef detail::ServiceImpl<ImplT_> ServiceImplT; detail::CreateFuncF const m_createFunc; - typedef detail::PostProcessDefault<ServiceImplT> PostProcessDefaultT; + typedef detail::PostProcessDefault<ImplT> PostProcessDefaultT; /** Default ctor. Implementation class without args, expecting component context as single argument. */ - class_() : m_createFunc( + serviceimpl_base() : m_createFunc( detail::CreateFunc<ImplT, PostProcessDefaultT, WithArgsT>( PostProcessDefaultT() ) ) {} @@ -284,11 +298,29 @@ struct class_ { uno::Reference<uno::XInterface> */ template <typename PostProcessFuncT> - explicit class_( PostProcessFuncT const& postProcessFunc ) + explicit serviceimpl_base( PostProcessFuncT const& postProcessFunc ) : m_createFunc( detail::CreateFunc<ImplT, PostProcessFuncT, WithArgsT>( postProcessFunc ) ) {} }; +template <typename ImplT_, typename WithArgsT = with_args<false> > +struct class_ : public serviceimpl_base< detail::ServiceImpl<ImplT_>, WithArgsT > +{ + typedef serviceimpl_base< detail::ServiceImpl<ImplT_>, WithArgsT > baseT; + /** Default ctor. Implementation class without args, expecting + component context as single argument. + */ + class_() : 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 class_( PostProcessFuncT const& postProcessFunc ) : baseT( postProcessFunc ) {} +}; // // component_... helpers with arbitrary service declarations: diff --git a/comphelper/qa/makefile.mk b/comphelper/qa/makefile.mk index cfc597570bc4..52c57a9d77de 100644 --- a/comphelper/qa/makefile.mk +++ b/comphelper/qa/makefile.mk @@ -1,7 +1,7 @@ #************************************************************************* # # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# +# # Copyright 2008 by Sun Microsystems, Inc. # # OpenOffice.org - a multi-platform office productivity suite @@ -43,7 +43,7 @@ INCPRE += $(MISC)$/$(TARGET)$/inc SHL1TARGET = $(TARGET)_weakbag SHL1OBJS = $(SLO)$/test_weakbag.obj -SHL1STDLIBS = $(CPPUHELPERLIB) $(CPPULIB) $(CPPUNITLIB) $(SALLIB) +SHL1STDLIBS = $(CPPUHELPERLIB) $(CPPULIB) $(CPPUNITLIB) $(TESTSHL2LIB) $(SALLIB) SHL1VERSIONMAP = version.map SHL1IMPLIB = i$(SHL1TARGET) DEF1NAME = $(SHL1TARGET) @@ -55,4 +55,4 @@ SLOFILES = $(SHL1OBJS) ALLTAR: test test .PHONY: $(SHL1TARGETN) - testshl2 $(SHL1TARGETN) + $(TESTSHL2) $(SHL1TARGETN) diff --git a/comphelper/qa/test_string.cxx b/comphelper/qa/test_string.cxx index 035e56fdb8c4..c237158beccc 100644 --- a/comphelper/qa/test_string.cxx +++ b/comphelper/qa/test_string.cxx @@ -32,7 +32,7 @@ #include "sal/config.h" #include "comphelper/string.hxx" -#include "cppunit/simpleheader.hxx" +#include "testshl/simpleheader.hxx" #include "rtl/string.h" #include "rtl/ustring.h" #include "rtl/ustring.hxx" diff --git a/comphelper/qa/test_weakbag.cxx b/comphelper/qa/test_weakbag.cxx index dd4a8356eb5a..470ac2eef6c0 100644 --- a/comphelper/qa/test_weakbag.cxx +++ b/comphelper/qa/test_weakbag.cxx @@ -35,7 +35,7 @@ #include "com/sun/star/uno/XInterface.hpp" #include "comphelper/weakbag.hxx" #include "cppuhelper/weak.hxx" -#include "cppunit/simpleheader.hxx" +#include "testshl/simpleheader.hxx" namespace { diff --git a/comphelper/source/misc/comphelper_services.cxx b/comphelper/source/misc/comphelper_services.cxx index 77ab145e2581..8fa318a92eb1 100644 --- a/comphelper/source/misc/comphelper_services.cxx +++ b/comphelper/source/misc/comphelper_services.cxx @@ -39,6 +39,7 @@ extern void createRegistryInfo_AnyCompareFactory(); extern void createRegistryInfo_OfficeInstallationDirectories(); extern void createRegistryInfo_OInstanceLocker(); extern void createRegistryInfo_Map(); +extern void createRegistryInfo_OSimpleLogRing(); //........................................................................ namespace comphelper { namespace module @@ -63,6 +64,7 @@ namespace comphelper { namespace module createRegistryInfo_OfficeInstallationDirectories(); createRegistryInfo_OInstanceLocker(); createRegistryInfo_Map(); + createRegistryInfo_OSimpleLogRing(); } } } diff --git a/comphelper/source/misc/documentiologring.cxx b/comphelper/source/misc/documentiologring.cxx index 7969b938e108..8b999aaf4449 100644 --- a/comphelper/source/misc/documentiologring.cxx +++ b/comphelper/source/misc/documentiologring.cxx @@ -34,6 +34,8 @@ #include <com/sun/star/frame/DoubleInitializationException.hpp>
#include <com/sun/star/lang/IllegalArgumentException.hpp>
+#include <comphelper_module.hxx>
+
#include "documentiologring.hxx"
using namespace ::com::sun::star;
@@ -56,33 +58,33 @@ OSimpleLogRing::~OSimpleLogRing() }
// ----------------------------------------------------------
-uno::Sequence< ::rtl::OUString > SAL_CALL OSimpleLogRing::impl_staticGetSupportedServiceNames()
+uno::Sequence< ::rtl::OUString > SAL_CALL OSimpleLogRing::getSupportedServiceNames_static()
{
uno::Sequence< rtl::OUString > aResult( 1 );
- aResult[0] = impl_staticGetServiceName();
+ aResult[0] = getServiceName_static();
return aResult;
}
// ----------------------------------------------------------
-::rtl::OUString SAL_CALL OSimpleLogRing::impl_staticGetImplementationName()
+::rtl::OUString SAL_CALL OSimpleLogRing::getImplementationName_static()
{
return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.logging.SimpleLogRing" ) );
}
// ----------------------------------------------------------
-::rtl::OUString SAL_CALL OSimpleLogRing::impl_staticGetSingletonName()
+::rtl::OUString SAL_CALL OSimpleLogRing::getSingletonName_static()
{
return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.logging.DocumentIOLogRing" ) );
}
// ----------------------------------------------------------
-::rtl::OUString SAL_CALL OSimpleLogRing::impl_staticGetServiceName()
+::rtl::OUString SAL_CALL OSimpleLogRing::getServiceName_static()
{
return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.logging.SimpleLogRing" ) );
}
// ----------------------------------------------------------
-uno::Reference< uno::XInterface > SAL_CALL OSimpleLogRing::impl_staticCreateSelfInstance( const uno::Reference< uno::XComponentContext >& rxContext )
+uno::Reference< uno::XInterface > SAL_CALL OSimpleLogRing::Create( const uno::Reference< uno::XComponentContext >& rxContext )
{
return static_cast< cppu::OWeakObject* >( new OSimpleLogRing( rxContext ) );
}
@@ -149,13 +151,13 @@ void SAL_CALL OSimpleLogRing::initialize( const uno::Sequence< uno::Any >& aArgu // ----------------------------------------------------------
::rtl::OUString SAL_CALL OSimpleLogRing::getImplementationName() throw (uno::RuntimeException)
{
- return impl_staticGetImplementationName();
+ return getImplementationName_static();
}
// ----------------------------------------------------------
::sal_Bool SAL_CALL OSimpleLogRing::supportsService( const ::rtl::OUString& aServiceName ) throw (uno::RuntimeException)
{
- const uno::Sequence< rtl::OUString > & aSupportedNames = impl_staticGetSupportedServiceNames();
+ const uno::Sequence< rtl::OUString > & aSupportedNames = getSupportedServiceNames_static();
for ( sal_Int32 nInd = 0; nInd < aSupportedNames.getLength(); nInd++ )
{
if ( aSupportedNames[ nInd ].equals( aServiceName ) )
@@ -168,8 +170,13 @@ void SAL_CALL OSimpleLogRing::initialize( const uno::Sequence< uno::Any >& aArgu // ----------------------------------------------------------
uno::Sequence< ::rtl::OUString > SAL_CALL OSimpleLogRing::getSupportedServiceNames() throw (uno::RuntimeException)
{
- return impl_staticGetSupportedServiceNames();
+ return getSupportedServiceNames_static();
}
} // namespace comphelper
+void createRegistryInfo_OSimpleLogRing()
+{
+ static ::comphelper::module::OAutoRegistration< ::comphelper::OSimpleLogRing > aAutoRegistration;
+ static ::comphelper::module::OSingletonRegistration< ::comphelper::OSimpleLogRing > aSingletonRegistration;
+}
diff --git a/comphelper/source/misc/documentiologring.hxx b/comphelper/source/misc/documentiologring.hxx index ae7d2a6eaf19..b2b935c478af 100644 --- a/comphelper/source/misc/documentiologring.hxx +++ b/comphelper/source/misc/documentiologring.hxx @@ -60,17 +60,16 @@ public: virtual ~OSimpleLogRing(); static ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL - impl_staticGetSupportedServiceNames(); + getSupportedServiceNames_static(); - static ::rtl::OUString SAL_CALL impl_staticGetImplementationName(); + static ::rtl::OUString SAL_CALL getImplementationName_static(); - static ::rtl::OUString SAL_CALL impl_staticGetSingletonName(); + static ::rtl::OUString SAL_CALL getSingletonName_static(); - static ::rtl::OUString SAL_CALL impl_staticGetServiceName(); + static ::rtl::OUString SAL_CALL getServiceName_static(); static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL - impl_staticCreateSelfInstance( - const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext ); + Create( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext ); // XSimpleLogRing virtual void SAL_CALL logString( const ::rtl::OUString& aMessage ) throw (::com::sun::star::uno::RuntimeException); diff --git a/comphelper/source/property/ChainablePropertySetInfo.cxx b/comphelper/source/property/ChainablePropertySetInfo.cxx index b27cef88319c..c5d134eb9982 100644 --- a/comphelper/source/property/ChainablePropertySetInfo.cxx +++ b/comphelper/source/property/ChainablePropertySetInfo.cxx @@ -76,7 +76,7 @@ void ChainablePropertySetInfo::add( PropertyInfo* pMap, sal_Int32 nCount ) { OUString aName( pMap->mpName, pMap->mnNameLen, RTL_TEXTENCODING_ASCII_US ); -#ifndef PRODUCT +#ifdef DBG_UTIL PropertyInfoHash::iterator aIter = maMap.find( aName ); if( aIter != maMap.end() ) OSL_ENSURE( sal_False, "Warning: PropertyInfo added twice, possible error!"); diff --git a/comphelper/source/property/MasterPropertySetInfo.cxx b/comphelper/source/property/MasterPropertySetInfo.cxx index e74d21b2d755..91a9a17856d4 100644 --- a/comphelper/source/property/MasterPropertySetInfo.cxx +++ b/comphelper/source/property/MasterPropertySetInfo.cxx @@ -84,7 +84,7 @@ void MasterPropertySetInfo::add( PropertyInfo* pMap, sal_Int32 nCount, sal_uInt8 { OUString aName( pMap->mpName, pMap->mnNameLen, RTL_TEXTENCODING_ASCII_US ); -#ifndef PRODUCT +#ifdef DBG_UTIL PropertyDataHash::iterator aIter = maMap.find( aName ); if( aIter != maMap.end() ) OSL_ENSURE( sal_False, "Warning: PropertyInfo added twice, possible error!"); @@ -102,7 +102,7 @@ void MasterPropertySetInfo::add( PropertyInfoHash &rHash, sal_uInt8 nMapId ) while ( aIter != aEnd ) { -#ifndef PRODUCT +#ifdef DBG_UTIL PropertyDataHash::iterator aDebugIter = maMap.find( (*aIter).first ); if( aDebugIter != maMap.end() ) OSL_ENSURE( sal_False, "Warning: PropertyInfo added twice, possible error!"); diff --git a/comphelper/source/property/opropertybag.cxx b/comphelper/source/property/opropertybag.cxx index 8b816e8c1ce9..caa895021103 100644 --- a/comphelper/source/property/opropertybag.cxx +++ b/comphelper/source/property/opropertybag.cxx @@ -240,7 +240,7 @@ namespace comphelper if ( !( _element >>= aProperty ) ) throw IllegalArgumentException( ::rtl::OUString(), *this, 1 ); - ::osl::MutexGuard aGuard( m_aMutex ); + ::osl::ClearableMutexGuard g( m_aMutex ); // check whether the type is allowed, everything else will be checked // by m_aDynamicProperties @@ -254,6 +254,7 @@ namespace comphelper // our property info is dirty m_pArrayHelper.reset(); + g.clear(); setModified(sal_True); } @@ -346,7 +347,7 @@ namespace comphelper //-------------------------------------------------------------------- void SAL_CALL OPropertyBag::addProperty( const ::rtl::OUString& _rName, ::sal_Int16 _nAttributes, const Any& _rInitialValue ) throw (PropertyExistException, IllegalTypeException, IllegalArgumentException, RuntimeException) { - ::osl::MutexGuard aGuard( m_aMutex ); + ::osl::ClearableMutexGuard g( m_aMutex ); // check whether the type is allowed, everything else will be checked // by m_aDynamicProperties @@ -362,19 +363,21 @@ namespace comphelper // our property info is dirty m_pArrayHelper.reset(); + g.clear(); setModified(sal_True); } //-------------------------------------------------------------------- void SAL_CALL OPropertyBag::removeProperty( const ::rtl::OUString& _rName ) throw (UnknownPropertyException, NotRemoveableException, RuntimeException) { - ::osl::MutexGuard aGuard( m_aMutex ); + ::osl::ClearableMutexGuard g( m_aMutex ); m_aDynamicProperties.removeProperty( _rName ); // our property info is dirty m_pArrayHelper.reset(); + g.clear(); setModified(sal_True); } diff --git a/comphelper/source/property/property.cxx b/comphelper/source/property/property.cxx index fe6cbaa9d767..0ccc28d4238b 100644 --- a/comphelper/source/property/property.cxx +++ b/comphelper/source/property/property.cxx @@ -38,15 +38,11 @@ #include <osl/diagnose.h> #if OSL_DEBUG_LEVEL > 0 - #ifndef _RTL_STRBUF_HXX_ #include <rtl/strbuf.hxx> - #endif - #ifndef _CPPUHELPER_EXC_HLP_HXX_ #include <cppuhelper/exc_hlp.hxx> - #endif - #ifndef _OSL_THREAD_H_ #include <osl/thread.h> - #endif + #include <com/sun/star/lang/XServiceInfo.hpp> + #include <typeinfo> #endif #include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/lang/IllegalArgumentException.hpp> @@ -71,6 +67,10 @@ namespace comphelper using ::com::sun::star::uno::cpp_queryInterface; using ::com::sun::star::uno::cpp_acquire; using ::com::sun::star::uno::cpp_release; +#if OSL_DEBUG_LEVEL > 0 + using ::com::sun::star::lang::XServiceInfo; +#endif + using ::com::sun::star::uno::UNO_QUERY; /** === end UNO using === **/ namespace PropertyAttribute = ::com::sun::star::beans::PropertyAttribute; @@ -110,7 +110,18 @@ void copyProperties(const Reference<XPropertySet>& _rxSource, ::rtl::OStringBuffer aBuffer; aBuffer.append( "::comphelper::copyProperties: could not copy property '" ); aBuffer.append( ::rtl::OString( pSourceProps->Name.getStr(), pSourceProps->Name.getLength(), RTL_TEXTENCODING_ASCII_US ) ); - aBuffer.append( "' to the destination set.\n" ); + aBuffer.append( "' to the destination set (a '" ); + + Reference< XServiceInfo > xSI( _rxDest, UNO_QUERY ); + if ( xSI.is() ) + { + aBuffer.append( ::rtl::OUStringToOString( xSI->getImplementationName(), osl_getThreadTextEncoding() ) ); + } + else + { + aBuffer.append( typeid( *_rxDest.get() ).name() ); + } + aBuffer.append( "' implementation).\n" ); Any aException( ::cppu::getCaughtException() ); aBuffer.append( "Caught an exception of type '" ); diff --git a/comphelper/source/property/propertysetinfo.cxx b/comphelper/source/property/propertysetinfo.cxx index e155d695e2c9..83b769553331 100644 --- a/comphelper/source/property/propertysetinfo.cxx +++ b/comphelper/source/property/propertysetinfo.cxx @@ -82,7 +82,7 @@ void PropertyMapImpl::add( PropertyMapEntry* pMap, sal_Int32 nCount ) throw() { OUString aName( pMap->mpName, pMap->mnNameLen, RTL_TEXTENCODING_ASCII_US ); -#ifndef PRODUCT +#ifdef DBG_UTIL PropertyMap::iterator aIter = maPropertyMap.find( aName ); if( aIter != maPropertyMap.end() ) { |