diff options
Diffstat (limited to 'comphelper')
26 files changed, 296 insertions, 453 deletions
diff --git a/comphelper/Library_comphelp.mk b/comphelper/Library_comphelp.mk index 7c365bc97cd2..8336b8cb2124 100644 --- a/comphelper/Library_comphelp.mk +++ b/comphelper/Library_comphelp.mk @@ -90,7 +90,6 @@ $(eval $(call gb_Library_add_exception_objects,comphelper,\ comphelper/source/misc/ihwrapnofilter \ comphelper/source/misc/instancelocker \ comphelper/source/misc/interaction \ - comphelper/source/misc/legacysingletonfactory \ comphelper/source/misc/listenernotification \ comphelper/source/misc/locale \ comphelper/source/misc/logging \ diff --git a/comphelper/Package_inc.mk b/comphelper/Package_inc.mk index 5794c56ab74d..a02bde6b7475 100644 --- a/comphelper/Package_inc.mk +++ b/comphelper/Package_inc.mk @@ -38,6 +38,7 @@ $(eval $(call gb_Package_add_file,comphelper_inc,inc/comphelper/stillreadwritein $(eval $(call gb_Package_add_file,comphelper_inc,inc/comphelper/anycompare.hxx,comphelper/anycompare.hxx)) $(eval $(call gb_Package_add_file,comphelper_inc,inc/comphelper/propagg.hxx,comphelper/propagg.hxx)) $(eval $(call gb_Package_add_file,comphelper_inc,inc/comphelper/scopeguard.hxx,comphelper/scopeguard.hxx)) +$(eval $(call gb_Package_add_file,comphelper_inc,inc/comphelper/scoped_disposing_ptr.hxx,comphelper/scoped_disposing_ptr.hxx)) $(eval $(call gb_Package_add_file,comphelper_inc,inc/comphelper/asyncnotification.hxx,comphelper/asyncnotification.hxx)) $(eval $(call gb_Package_add_file,comphelper_inc,inc/comphelper/namedvaluecollection.hxx,comphelper/namedvaluecollection.hxx)) $(eval $(call gb_Package_add_file,comphelper_inc,inc/comphelper/composedprops.hxx,comphelper/composedprops.hxx)) @@ -89,7 +90,6 @@ $(eval $(call gb_Package_add_file,comphelper_inc,inc/comphelper/ChainablePropert $(eval $(call gb_Package_add_file,comphelper_inc,inc/comphelper/stl_types.hxx,comphelper/stl_types.hxx)) $(eval $(call gb_Package_add_file,comphelper_inc,inc/comphelper/eventattachermgr.hxx,comphelper/eventattachermgr.hxx)) $(eval $(call gb_Package_add_file,comphelper_inc,inc/comphelper/componentcontext.hxx,comphelper/componentcontext.hxx)) -$(eval $(call gb_Package_add_file,comphelper_inc,inc/comphelper/legacysingletonfactory.hxx,comphelper/legacysingletonfactory.hxx)) $(eval $(call gb_Package_add_file,comphelper_inc,inc/comphelper/accessibleeventnotifier.hxx,comphelper/accessibleeventnotifier.hxx)) $(eval $(call gb_Package_add_file,comphelper_inc,inc/comphelper/ihwrapnofilter.hxx,comphelper/ihwrapnofilter.hxx)) $(eval $(call gb_Package_add_file,comphelper_inc,inc/comphelper/sequenceasvector.hxx,comphelper/sequenceasvector.hxx)) diff --git a/comphelper/inc/comphelper/accimplaccess.hxx b/comphelper/inc/comphelper/accimplaccess.hxx index 8ba9fe43867e..fbbee6fbfde6 100644 --- a/comphelper/inc/comphelper/accimplaccess.hxx +++ b/comphelper/inc/comphelper/accimplaccess.hxx @@ -154,7 +154,7 @@ namespace comphelper private: - COMPHELPER_DLLPRIVATE static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelImplementationId(); + COMPHELPER_DLLPRIVATE static const ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId(); }; //......................................................................... diff --git a/comphelper/inc/comphelper/componentmodule.hxx b/comphelper/inc/comphelper/componentmodule.hxx index cd65ea50577d..4bc917ef13d3 100644 --- a/comphelper/inc/comphelper/componentmodule.hxx +++ b/comphelper/inc/comphelper/componentmodule.hxx @@ -29,7 +29,6 @@ #define COMPHELPER_INC_COMPHELPER_COMPONENTMODULE_HXX #include <comphelper/comphelperdllapi.h> -#include <comphelper/legacysingletonfactory.hxx> /** === begin UNO includes === **/ #include <com/sun/star/lang/XMultiServiceFactory.hpp> @@ -272,29 +271,6 @@ namespace comphelper } //========================================================================== - //= OLegacySingletonRegistration - //========================================================================== - template <class TYPE> - class OLegacySingletonRegistration - { - public: - OLegacySingletonRegistration( OModule& _rModule ); - }; - - //-------------------------------------------------------------------------- - template <class TYPE> - OLegacySingletonRegistration<TYPE>::OLegacySingletonRegistration( OModule& _rModule ) - { - _rModule.registerImplementation( ComponentDescription( - TYPE::getImplementationName_static(), - TYPE::getSupportedServiceNames_static(), - ::rtl::OUString(), - &TYPE::Create, - &::comphelper::createLegacySingletonFactory - ) ); - } - - //========================================================================== //= helpers //========================================================================== @@ -305,7 +281,7 @@ namespace comphelper /* -------------------------------------------------------------------- */ \ class ModuleClass : public ::comphelper::OModule \ { \ - friend struct CreateModuleClass; \ + friend struct ModuleClass##Creator; \ typedef ::comphelper::OModule BaseClass; \ \ public: \ @@ -350,32 +326,20 @@ namespace comphelper OSingletonRegistration() : BaseClass( ModuleClass::getInstance() ) \ { \ } \ - }; \ - /* -------------------------------------------------------------------- */ \ - template < class TYPE > \ - class OLegacySingletonRegistration : public ::comphelper::OLegacySingletonRegistration< TYPE > \ - { \ - private: \ - typedef ::comphelper::OLegacySingletonRegistration< TYPE > BaseClass; \ - \ - public: \ - OLegacySingletonRegistration() : BaseClass( ModuleClass::getInstance() ) \ - { \ - } \ - }; \ + }; //========================================================================== //= implementing a OModule for a component library #define IMPLEMENT_COMPONENT_MODULE( ModuleClass ) \ - struct CreateModuleClass \ + struct ModuleClass##Creator \ { \ - ModuleClass* operator()() \ - { \ - static ModuleClass* pModule = new ModuleClass; \ - return pModule; \ - } \ + ModuleClass m_aModuleClass; \ }; \ + namespace \ + { \ + class the##ModuleClass##Instance : public rtl::Static<ModuleClass##Creator, the##ModuleClass##Instance> {}; \ + } \ \ ModuleClass::ModuleClass() \ :BaseClass() \ @@ -384,16 +348,14 @@ namespace comphelper \ ModuleClass& ModuleClass::getInstance() \ { \ - return *rtl_Instance< ModuleClass, CreateModuleClass, ::osl::MutexGuard, ::osl::GetGlobalMutex >:: \ - create( CreateModuleClass(), ::osl::GetGlobalMutex() ); \ + return the##ModuleClass##Instance::get().m_aModuleClass; \ } \ //========================================================================== //= implementing the API of a component library (component_*) #define IMPLEMENT_COMPONENT_LIBRARY_API( module_class, initializer_function ) \ - extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL \ - component_getImplementationEnvironment( \ + extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment( \ const sal_Char **ppEnvTypeName, uno_Environment ** /*ppEnv*/ ) \ { \ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; \ diff --git a/comphelper/inc/comphelper/documentconstants.hxx b/comphelper/inc/comphelper/documentconstants.hxx index cb280b2525f7..06653b023002 100644 --- a/comphelper/inc/comphelper/documentconstants.hxx +++ b/comphelper/inc/comphelper/documentconstants.hxx @@ -148,4 +148,4 @@ #define SFX_FILTER_VERSION_NONE 0 #define SFX_FILTER_NOTINSTALLED SFX_FILTER_MUSTINSTALL | SFX_FILTER_CONSULTSERVICE -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/comphelper/inc/comphelper/legacysingletonfactory.hxx b/comphelper/inc/comphelper/legacysingletonfactory.hxx deleted file mode 100644 index d40f828d1384..000000000000 --- a/comphelper/inc/comphelper/legacysingletonfactory.hxx +++ /dev/null @@ -1,75 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef COMPHELPER_LEGACYSINGLETONFACTORY_HXX -#define COMPHELPER_LEGACYSINGLETONFACTORY_HXX - -#include "comphelper/comphelperdllapi.h" - -/** === begin UNO includes === **/ -/** === end UNO includes === **/ - -#include <cppuhelper/factory.hxx> - -//........................................................................ -namespace comphelper -{ -//........................................................................ - -/** creates a factory which can be used when implementing old-style singletons - - Before UNO having the component context concept, singletons were implemented by providing - a factory which return the very same component instance for every creation request. - - Nowadays, singletons are implemented by making them available at the component context, - as dedicated property. - - To bridge between both worlds - sometimes necessary to support legacy code, which instantiates - singletons at the global service manager, instead of obtaining the property at the - component context -, you can use the function below. I creates a single-component - factory, which behaves like the old factories did: Upon multiple creation requests, - it will always return the same instance. Additionally, the signature of the function - is the same as the signature of <code>::cppu::createSingleComponentFactory</code> - (which creates a "normal" component factory), so you can use both factory functions - in the same context. -*/ -::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleComponentFactory > - COMPHELPER_DLLPUBLIC createLegacySingletonFactory( - ::cppu::ComponentFactoryFunc _componentFactoryFunc, - const ::rtl::OUString& _rImplementationName, - const ::com::sun::star::uno::Sequence< ::rtl::OUString >& _rServiceNames, - rtl_ModuleCount* _pModCount = NULL - ); - -//........................................................................ -} // namespace comphelper -//........................................................................ - -#endif // COMPHELPER_LEGACYSINGLETONFACTORY_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/comphelper/inc/comphelper/scoped_disposing_ptr.hxx b/comphelper/inc/comphelper/scoped_disposing_ptr.hxx new file mode 100644 index 000000000000..7278126c2633 --- /dev/null +++ b/comphelper/inc/comphelper/scoped_disposing_ptr.hxx @@ -0,0 +1,178 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Version: MPL 1.1 / GPLv3+ / LGPLv3+ + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (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.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Initial Developer of the Original Code is + * Caolán McNamara <caolanm@redhat.com> (Red Hat, Inc.) + * Portions created by the Initial Developer are Copyright (C) 2011 the + * Initial Developer. All Rights Reserved. + * + * Contributor(s): Caolán McNamara <caolanm@redhat.com> + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 3 or later (the "GPLv3+"), or + * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), + * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable + * instead of those above. + */ +#ifndef _SCOPED_DISPOSING_PTR +#define _SCOPED_DISPOSING_PTR + +#include <cppuhelper/implbase1.hxx> +#include <boost/utility.hpp> +#include <boost/scoped_ptr.hpp> + +#include <com/sun/star/lang/XComponent.hpp> +#include <com/sun/star/frame/XDesktop.hpp> + +// for locking SolarMutex: svapp + mutex +#include <vcl/svapp.hxx> +#include <osl/mutex.hxx> + +namespace comphelper +{ +//Similar to boost::scoped_ptr, except additionally releases the ptr on XComponent::disposing and/or XTerminateListener::notifyTermination if supported +template<class T> class scoped_disposing_ptr : private boost::noncopyable +{ +private: + boost::scoped_ptr<T> m_aItem; + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XTerminateListener> m_xTerminateListener; +public: + scoped_disposing_ptr( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > &rComponent, T * p = 0 ) + : m_aItem(p) + { + m_xTerminateListener = new TerminateListener(rComponent, *this); + } + + virtual void reset(T * p = 0) + { + m_aItem.reset(p); + } + + T & operator*() const + { + return *m_aItem; + } + + T * get() const + { + return m_aItem.get(); + } + + T * operator->() const + { + return m_aItem.get(); + } + + operator bool () const + { + return m_aItem; + } + + virtual ~scoped_disposing_ptr() + { + reset(); + } +private: + class TerminateListener : public ::cppu::WeakImplHelper1< ::com::sun::star::frame::XTerminateListener > + { + private: + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > m_xComponent; + scoped_disposing_ptr<T>& m_rItem; + public: + TerminateListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > &rComponent, + scoped_disposing_ptr<T>& rItem) : m_xComponent(rComponent), m_rItem(rItem) + { + if (m_xComponent.is()) + { + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDesktop> xDesktop(m_xComponent, ::com::sun::star::uno::UNO_QUERY); + if (xDesktop.is()) + xDesktop->addTerminateListener(this); + else + m_xComponent->addEventListener(this); + } + } + + ~TerminateListener() + { + if ( m_xComponent.is() ) + { + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDesktop> xDesktop(m_xComponent, ::com::sun::star::uno::UNO_QUERY); + if (xDesktop.is()) + xDesktop->removeTerminateListener(this); + else + m_xComponent->removeEventListener(this); + } + } + + private: + // XEventListener + virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& rEvt ) + throw (::com::sun::star::uno::RuntimeException) + { + bool shutDown = (rEvt.Source == m_xComponent); + + if (shutDown && m_xComponent.is()) + { + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDesktop> xDesktop(m_xComponent, ::com::sun::star::uno::UNO_QUERY); + if (xDesktop.is()) + xDesktop->removeTerminateListener(this); + else + m_xComponent->removeEventListener(this); + m_xComponent.clear(); + } + + if (shutDown) + m_rItem.reset(); + } + + // XTerminateListener + virtual void SAL_CALL queryTermination( const ::com::sun::star::lang::EventObject& ) + throw(::com::sun::star::frame::TerminationVetoException, + ::com::sun::star::uno::RuntimeException) + { + } + + virtual void SAL_CALL notifyTermination( const ::com::sun::star::lang::EventObject& rEvt ) + throw (::com::sun::star::uno::RuntimeException) + { + disposing(rEvt); + } + }; +}; + +//Something like an OutputDevice requires the SolarMutex to be taken before use +//for threadsafety. The user can ensure this, except in the case of its dtor +//being called from reset due to a terminate on the XComponent being called +//from an aribitrary thread +template<class T> class scoped_disposing_solar_mutex_reset_ptr + : public scoped_disposing_ptr<T> +{ +public: + scoped_disposing_solar_mutex_reset_ptr( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > &rComponent, T * p = 0 ) + : scoped_disposing_ptr<T>(rComponent, p) + { + } + + virtual void reset(T * p = 0) + { + SolarMutexGuard aGuard; + scoped_disposing_ptr<T>::reset(p); + } +}; + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/comphelper/inc/comphelper/sequence.hxx b/comphelper/inc/comphelper/sequence.hxx index 9ccb89770ca4..125668172fb1 100644 --- a/comphelper/inc/comphelper/sequence.hxx +++ b/comphelper/inc/comphelper/sequence.hxx @@ -179,13 +179,9 @@ namespace comphelper ,m_pCurrent(NULL) { ::com::sun::star::uno::Sequence< TYPE > aContainer; - #ifdef DBG_UTIL - sal_Bool bSuccess = - #endif - _rSequenceAny >>= aContainer; - #ifdef DBG_UTIL + sal_Bool bSuccess = _rSequenceAny >>= aContainer; OSL_ENSURE(bSuccess, "OSequenceIterator::OSequenceIterator: invalid Any!"); - #endif + (void)bSuccess; construct(aContainer); } diff --git a/comphelper/inc/comphelper/servicehelper.hxx b/comphelper/inc/comphelper/servicehelper.hxx index e691ea2bd76c..15b0ae6a9f7c 100644 --- a/comphelper/inc/comphelper/servicehelper.hxx +++ b/comphelper/inc/comphelper/servicehelper.hxx @@ -29,6 +29,21 @@ #ifndef _COMPHELPER_SERVICEHELPER_HXX_ #define _COMPHELPER_SERVICEHELPER_HXX_ +#include <rtl/uuid.h> +#include <rtl/instance.hxx> + +class UnoTunnelIdInit +{ +private: + ::com::sun::star::uno::Sequence< sal_Int8 > m_aSeq; +public: + UnoTunnelIdInit() : m_aSeq(16) + { + rtl_createUuid( (sal_uInt8*)m_aSeq.getArray(), 0, sal_True ); + } + const ::com::sun::star::uno::Sequence< sal_Int8 >& getSeq() const { return m_aSeq; } +}; + /** the UNO3_GETIMPLEMENTATION_* macros implement a static helper function that gives access to your implementation for a given interface reference, if possible. @@ -49,20 +64,13 @@ virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); #define UNO3_GETIMPLEMENTATION_BASE_IMPL( classname ) \ +namespace \ +{ \ + class the##classname##UnoTunnelId : public rtl::Static< UnoTunnelIdInit, the##classname##UnoTunnelId> {}; \ +} \ const ::com::sun::star::uno::Sequence< sal_Int8 > & classname::getUnoTunnelId() throw() \ { \ - static ::com::sun::star::uno::Sequence< sal_Int8 > * pSeq = 0; \ - if( !pSeq ) \ - { \ - ::osl::Guard< ::osl::Mutex > aGuard( ::osl::Mutex::getGlobalMutex() ); \ - if( !pSeq ) \ - { \ - static ::com::sun::star::uno::Sequence< sal_Int8 > aSeq( 16 ); \ - rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True ); \ - pSeq = &aSeq; \ - } \ - } \ - return *pSeq; \ + return the##classname##UnoTunnelId::get().getSeq(); \ } \ \ classname* classname::getImplementation( const uno::Reference< uno::XInterface >& xInt ) \ diff --git a/comphelper/inc/comphelper/string.hxx b/comphelper/inc/comphelper/string.hxx index b1f769388ee0..e71a008c5e3e 100644 --- a/comphelper/inc/comphelper/string.hxx +++ b/comphelper/inc/comphelper/string.hxx @@ -190,6 +190,7 @@ public: { return compareNatural(rLHS, rRHS, m_xCollator, m_xBI, m_aLocale); } + const ::com::sun::star::lang::Locale& getLocale() const { return m_aLocale; } }; } } diff --git a/comphelper/inc/comphelper/types.hxx b/comphelper/inc/comphelper/types.hxx index 46020e64dd29..dfa1565c4493 100644 --- a/comphelper/inc/comphelper/types.hxx +++ b/comphelper/inc/comphelper/types.hxx @@ -104,7 +104,7 @@ namespace comphelper /** check if a type you have at hand at runtime is equal to another type you have at compile time */ template <class TYPE> - sal_Bool isAReference(const staruno::Any& _rVal, TYPE* pDummy) + sal_Bool isAReference(const staruno::Any& _rVal, TYPE*) { return _rVal.getValueType().equals( cppu::getTypeFavourUnsigned( diff --git a/comphelper/inc/comphelper/uno3.hxx b/comphelper/inc/comphelper/uno3.hxx index 617c200d3fd5..dff10cc994d3 100644 --- a/comphelper/inc/comphelper/uno3.hxx +++ b/comphelper/inc/comphelper/uno3.hxx @@ -30,6 +30,7 @@ #define _COMPHELPER_UNO3_HXX_ #include <osl/interlck.h> +#include <rtl/instance.hxx> #include <comphelper/types.hxx> #include <com/sun/star/uno/XAggregation.hpp> #include <comphelper/sequence.hxx> @@ -197,19 +198,13 @@ namespace comphelper virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw (::com::sun::star::uno::RuntimeException); #define IMPLEMENT_GET_IMPLEMENTATION_ID( classname ) \ + namespace \ + { \ + class the##classname##ImplementationId : public rtl::Static< ::cppu::OImplementationId, the##classname##ImplementationId> {}; \ + } \ ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL classname::getImplementationId( ) throw (::com::sun::star::uno::RuntimeException) \ { \ - static ::cppu::OImplementationId* pId = NULL; \ - if (!pId) \ - { \ - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); \ - if (!pId) \ - { \ - static ::cppu::OImplementationId aId; \ - pId = &aId; \ - } \ - } \ - return pId->getImplementationId(); \ + return the##classname##ImplementationId::get().getImplementationId(); \ } #define IMPLEMENT_FORWARD_XTYPEPROVIDER2( classname, baseclass1, baseclass2 ) \ diff --git a/comphelper/source/container/containermultiplexer.cxx b/comphelper/source/container/containermultiplexer.cxx index fa68a34c2940..21c72fbbead1 100644 --- a/comphelper/source/container/containermultiplexer.cxx +++ b/comphelper/source/container/containermultiplexer.cxx @@ -118,7 +118,7 @@ namespace comphelper } catch(const Exception&) { - OSL_FAIL("Exceptiopn catched!"); + OSL_FAIL("Exceptiopn caught!"); } ::comphelper::decrement(m_refCount); } @@ -153,7 +153,7 @@ namespace comphelper } catch(const Exception&) { - OSL_FAIL("Exception catched!"); + OSL_FAIL("Exception caught!"); } m_xContainer = NULL; m_pListener = NULL; diff --git a/comphelper/source/eventattachermgr/eventattachermgr.cxx b/comphelper/source/eventattachermgr/eventattachermgr.cxx index acbb962ea4d7..dd4fa54f3354 100644 --- a/comphelper/source/eventattachermgr/eventattachermgr.cxx +++ b/comphelper/source/eventattachermgr/eventattachermgr.cxx @@ -31,7 +31,7 @@ #include <deque> -#if defined( OS2 ) || defined( UNX ) +#if defined( UNX ) #include <wchar.h> #endif #include <osl/mutex.hxx> @@ -470,7 +470,7 @@ void detachAll_Impl while( aObjIt != aObjEnd ) { pMgr->detach( nIdx, (*aObjIt).xTarget ); - aObjIt++; + ++aObjIt; } } @@ -487,7 +487,7 @@ void attachAll_Impl while( aObjIt != aObjEnd ) { pMgr->attach( nIdx, (*aObjIt).xTarget, (*aObjIt).aHelper ); - aObjIt++; + ++aObjIt; } } @@ -541,7 +541,7 @@ void SAL_CALL ImplEventAttacherManager::registerScriptEvent { } - aObjIt++; + ++aObjIt; } } @@ -605,7 +605,7 @@ void SAL_CALL ImplEventAttacherManager::revokeScriptEvent break; } - aEvtIt++; + ++aEvtIt; } #else Sequence< ScriptEventDescriptor >& rEventList = (*aIt).aEventList; @@ -698,7 +698,7 @@ Sequence< ScriptEventDescriptor > SAL_CALL ImplEventAttacherManager::getScriptEv while( aEvtIt != aEvtEnd ) { pArray[i++] = *aEvtIt; - aEvtIt++; + ++aEvtIt; } return aSeq; #else @@ -763,7 +763,7 @@ void SAL_CALL ImplEventAttacherManager::attach(sal_Int32 nIndex, const Reference } pArray[i++] = xAdapter; - aEvtIt++; + ++aEvtIt; } #else sal_Int32 nLen = aCurrentPosition->aEventList.getLength(); @@ -824,7 +824,7 @@ void SAL_CALL ImplEventAttacherManager::detach(sal_Int32 nIndex, const Reference } } i++; - aEvtIt++; + ++aEvtIt; } #else sal_Int32 nLen = aCurrentPosition->aEventList.getLength(); @@ -847,7 +847,7 @@ void SAL_CALL ImplEventAttacherManager::detach(sal_Int32 nIndex, const Reference aCurrentPosition->aObjList.erase( aObjIt ); break; } - aObjIt++; + ++aObjIt; } } @@ -910,7 +910,7 @@ void SAL_CALL ImplEventAttacherManager::write(const Reference< XObjectOutputStre OutStream->writeUTF( rDesc.ScriptType ); OutStream->writeUTF( rDesc.ScriptCode ); - aEvtIt++; + ++aEvtIt; } #else sal_Int32 nLen = (*aIt).aEventList.getLength(); @@ -927,7 +927,7 @@ void SAL_CALL ImplEventAttacherManager::write(const Reference< XObjectOutputStre OutStream->writeUTF( rDesc.ScriptCode ); } #endif - aIt++; + ++aIt; } // Die jetzt bekannte Laenge eintragen diff --git a/comphelper/source/misc/accessiblewrapper.cxx b/comphelper/source/misc/accessiblewrapper.cxx index 650130939cda..b9d26591f19f 100644 --- a/comphelper/source/misc/accessiblewrapper.cxx +++ b/comphelper/source/misc/accessiblewrapper.cxx @@ -241,10 +241,9 @@ namespace comphelper case AccessibleEventId::TABLE_ROW_DESCRIPTION_CHANGED: case AccessibleEventId::TABLE_ROW_HEADER_CHANGED: case AccessibleEventId::TABLE_SUMMARY_CHANGED: - // --> PB 2006-03-21 #130798# EventId TEXT_SELECTION_CHANGED was missed + // #130798# // these Ids are also missed: SUB_WINDOW_OF_RELATION_CHANGED & TEXT_ATTRIBUTE_CHANGED case AccessibleEventId::TEXT_SELECTION_CHANGED: - // <-- // nothing to translate break; diff --git a/comphelper/source/misc/accimplaccess.cxx b/comphelper/source/misc/accimplaccess.cxx index 7128d4e13991..e06df35cde0c 100644 --- a/comphelper/source/misc/accimplaccess.cxx +++ b/comphelper/source/misc/accimplaccess.cxx @@ -121,21 +121,13 @@ namespace comphelper return ( NULL != pImplementation ); } + namespace { struct lcl_ImplId : public rtl::Static< ::cppu::OImplementationId, lcl_ImplId > {}; } + //--------------------------------------------------------------------- - const Sequence< sal_Int8 >& OAccessibleImplementationAccess::getUnoTunnelImplementationId() + const Sequence< sal_Int8 > OAccessibleImplementationAccess::getUnoTunnelImplementationId() { - static Sequence< sal_Int8 > aId; - if ( !aId.getLength() ) - { - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if ( !aId.getLength() ) - { - static ::cppu::OImplementationId aImplId; - // unfortunately, the OImplementationId::getImplementationId returns a copy, not a static reference ... - aId = aImplId.getImplementationId(); - } - } - return aId; + ::cppu::OImplementationId &rID = lcl_ImplId::get(); + return rID.getImplementationId(); } //--------------------------------------------------------------------- diff --git a/comphelper/source/misc/comphelper_services.cxx b/comphelper/source/misc/comphelper_services.cxx index b9cc41fe5b09..32d1c53aff93 100644 --- a/comphelper/source/misc/comphelper_services.cxx +++ b/comphelper/source/misc/comphelper_services.cxx @@ -30,6 +30,8 @@ #include "comphelper_module.hxx" +#include <rtl/instance.hxx> + //-------------------------------------------------------------------- extern void createRegistryInfo_OPropertyBag(); extern void createRegistryInfo_SequenceOutputStream(); @@ -49,13 +51,12 @@ namespace comphelper { namespace module { //........................................................................ - static void initializeModule() + namespace { - static bool bInitialized( false ); - if ( !bInitialized ) + class doInitialize { - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if ( !bInitialized ) + public: + doInitialize() { createRegistryInfo_OPropertyBag(); createRegistryInfo_SequenceOutputStream(); @@ -70,7 +71,14 @@ namespace comphelper { namespace module createRegistryInfo_OSimpleLogRing(); createRegistryInfo_OOfficeRestartManager(); } - } + }; + + struct theInitializer : public rtl::Static< doInitialize, theInitializer > {}; + } + + static void initializeModule() + { + theInitializer::get(); } //........................................................................ diff --git a/comphelper/source/misc/legacysingletonfactory.cxx b/comphelper/source/misc/legacysingletonfactory.cxx deleted file mode 100644 index d469d2512c4f..000000000000 --- a/comphelper/source/misc/legacysingletonfactory.cxx +++ /dev/null @@ -1,200 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_comphelper.hxx" - -#include "comphelper/legacysingletonfactory.hxx" - -/** === begin UNO includes === **/ -#include <com/sun/star/lang/XServiceInfo.hpp> -#include <com/sun/star/lang/XInitialization.hpp> -/** === end UNO includes === **/ - -#include <cppuhelper/implbase2.hxx> - -#include <algorithm> - -//........................................................................ -namespace comphelper -{ -//........................................................................ - - /** === begin UNO using === **/ - using ::com::sun::star::uno::Reference; - using ::com::sun::star::uno::XInterface; - using ::com::sun::star::uno::UNO_QUERY; - using ::com::sun::star::uno::UNO_QUERY_THROW; - using ::com::sun::star::uno::UNO_SET_THROW; - using ::com::sun::star::uno::Exception; - using ::com::sun::star::uno::RuntimeException; - using ::com::sun::star::uno::Any; - using ::com::sun::star::uno::makeAny; - using ::com::sun::star::lang::XSingleComponentFactory; - using ::com::sun::star::uno::Sequence; - using ::com::sun::star::uno::XComponentContext; - using ::com::sun::star::lang::XServiceInfo; - using ::com::sun::star::lang::XInitialization; - /** === end UNO using === **/ - - //==================================================================== - //= LegacySingletonFactory - //==================================================================== - typedef ::cppu::WeakImplHelper2 < XServiceInfo - , XSingleComponentFactory - > LegacySingletonFactory_Base; - - class COMPHELPER_DLLPRIVATE LegacySingletonFactory : public LegacySingletonFactory_Base - { - public: - LegacySingletonFactory( - ::cppu::ComponentFactoryFunc _componentFactoryFunc, const ::rtl::OUString& _rImplementationName, - const Sequence< ::rtl::OUString >& _rServiceNames, rtl_ModuleCount* _pModCount - ); - - // XServiceInfo - virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (RuntimeException); - virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (RuntimeException); - virtual Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (RuntimeException); - - // XSingleComponentFactory - virtual Reference< XInterface > SAL_CALL createInstanceWithContext( const Reference< XComponentContext >& Context ) throw (Exception, RuntimeException); - virtual Reference< XInterface > SAL_CALL createInstanceWithArgumentsAndContext( const Sequence< Any >& Arguments, const Reference< XComponentContext >& Context ) throw (Exception, RuntimeException); - - protected: - ~LegacySingletonFactory(); - - private: - /** creates m_xInstance, returns whether it actually was created (<TRUE/>) or existed before (<FALSE/> - */ - bool impl_nts_ensureInstance( const Reference< XComponentContext >& _rxContext ); - - private: - ::osl::Mutex m_aMutex; - ::cppu::ComponentFactoryFunc m_componentFactoryFunc; - ::rtl::OUString m_sImplementationName; - Sequence< ::rtl::OUString > m_aServiceNames; - rtl_ModuleCount* m_pModuleCount; - Reference< XInterface > m_xTheInstance; - }; - - //-------------------------------------------------------------------- - LegacySingletonFactory::LegacySingletonFactory( ::cppu::ComponentFactoryFunc _componentFactoryFunc, const ::rtl::OUString& _rImplementationName, - const Sequence< ::rtl::OUString >& _rServiceNames, rtl_ModuleCount* _pModCount ) - :m_componentFactoryFunc ( _componentFactoryFunc ) - ,m_sImplementationName ( _rImplementationName ) - ,m_aServiceNames ( _rServiceNames ) - ,m_pModuleCount ( _pModCount ) - ,m_xTheInstance ( ) - { - if ( m_pModuleCount ) - m_pModuleCount->acquire( m_pModuleCount ); - } - - //-------------------------------------------------------------------- - LegacySingletonFactory::~LegacySingletonFactory() - { - if ( m_pModuleCount ) - m_pModuleCount->release( m_pModuleCount ); - } - - //-------------------------------------------------------------------- - ::rtl::OUString SAL_CALL LegacySingletonFactory::getImplementationName( ) throw (RuntimeException) - { - return m_sImplementationName; - } - - //-------------------------------------------------------------------- - ::sal_Bool SAL_CALL LegacySingletonFactory::supportsService( const ::rtl::OUString& _rServiceName ) throw (RuntimeException) - { - Sequence< ::rtl::OUString > aServices( getSupportedServiceNames() ); - const ::rtl::OUString* pStart = aServices.getConstArray(); - const ::rtl::OUString* pEnd = aServices.getConstArray() + aServices.getLength(); - return ::std::find( pStart, pEnd, _rServiceName ) != pEnd; - } - - //-------------------------------------------------------------------- - Sequence< ::rtl::OUString > SAL_CALL LegacySingletonFactory::getSupportedServiceNames( ) throw (RuntimeException) - { - return m_aServiceNames; - } - - //-------------------------------------------------------------------- - bool LegacySingletonFactory::impl_nts_ensureInstance( const Reference< XComponentContext >& _rxContext ) - { - if ( m_xTheInstance.is() ) - return false; - - m_xTheInstance = (*m_componentFactoryFunc)( _rxContext ); - if ( !m_xTheInstance.is() ) - throw RuntimeException(); - - return true; // true -> "was newly created" - } - - //-------------------------------------------------------------------- - Reference< XInterface > SAL_CALL LegacySingletonFactory::createInstanceWithContext( const Reference< XComponentContext >& _rxContext ) throw (Exception, RuntimeException) - { - ::osl::MutexGuard aGuard( m_aMutex ); - impl_nts_ensureInstance( _rxContext ); - - return m_xTheInstance; - } - - //-------------------------------------------------------------------- - Reference< XInterface > SAL_CALL LegacySingletonFactory::createInstanceWithArgumentsAndContext( const Sequence< Any >& _rArguments, const Reference< XComponentContext >& _rxContext ) throw (Exception, RuntimeException) - { - ::osl::MutexGuard aGuard( m_aMutex ); - if ( !impl_nts_ensureInstance( _rxContext ) ) - throw RuntimeException( - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Instance already created before, unable to initialize it." ) ), - *this - ); - - Reference< XInitialization > xInit( m_xTheInstance, UNO_QUERY_THROW ); - xInit->initialize( _rArguments ); - - return m_xTheInstance; - } - - //==================================================================== - //= createLegacySingletonFactory - //==================================================================== - Reference< XSingleComponentFactory > createLegacySingletonFactory( - ::cppu::ComponentFactoryFunc _componentFactoryFunc, const ::rtl::OUString& _rImplementationName, - const Sequence< ::rtl::OUString >& _rServiceNames, rtl_ModuleCount* _pModCount ) - { - return new LegacySingletonFactory( _componentFactoryFunc, _rImplementationName, _rServiceNames, _pModCount ); - } - - -//........................................................................ -} // namespace comphelper -//........................................................................ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/comphelper/source/misc/mimeconfighelper.cxx b/comphelper/source/misc/mimeconfighelper.cxx index d8d81aadea3f..c81e761392b9 100644 --- a/comphelper/source/misc/mimeconfighelper.cxx +++ b/comphelper/source/misc/mimeconfighelper.cxx @@ -197,7 +197,7 @@ uno::Reference< container::XNameAccess > MimeConfigurationHelper::GetFilterFacto if ( !m_xFilterFactory.is() ) m_xFilterFactory.set( - m_xFactory->createInstance( ::rtl::OUString::createFromAscii( "com.sun.star.document.FilterFactory" ) ), + m_xFactory->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.FilterFactory")) ), uno::UNO_QUERY ); return m_xFilterFactory; @@ -220,7 +220,7 @@ sal_Int32 MimeConfigurationHelper::GetFilterFlags( const ::rtl::OUString& aFilte if ( aFilterAny >>= aData ) { SequenceAsHashMap aFilterHM( aData ); - nFlags = aFilterHM.getUnpackedValueOrDefault( ::rtl::OUString::createFromAscii( "Flags" ), (sal_Int32)0 ); + nFlags = aFilterHM.getUnpackedValueOrDefault( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Flags")), (sal_Int32)0 ); } } } catch( uno::Exception& ) @@ -795,7 +795,7 @@ sal_Bool MimeConfigurationHelper::AddFilterNameCheckOwnFile( if ( aImpFilterAny >>= aImpData ) { SequenceAsHashMap aImpFilterHM( aImpData ); - sal_Int32 nFlags = aImpFilterHM.getUnpackedValueOrDefault( ::rtl::OUString::createFromAscii( "Flags" ), + sal_Int32 nFlags = aImpFilterHM.getUnpackedValueOrDefault( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Flags")), (sal_Int32)0 ); if ( !( nFlags & SFX_FILTER_IMPORT ) ) @@ -810,16 +810,16 @@ sal_Bool MimeConfigurationHelper::AddFilterNameCheckOwnFile( } else { - ::rtl::OUString aDocumentServiceName = aImpFilterHM.getUnpackedValueOrDefault( ::rtl::OUString::createFromAscii( "DocumentService" ), ::rtl::OUString() ); - ::rtl::OUString aTypeName = aImpFilterHM.getUnpackedValueOrDefault( ::rtl::OUString::createFromAscii( "Type" ), ::rtl::OUString() ); + ::rtl::OUString aDocumentServiceName = aImpFilterHM.getUnpackedValueOrDefault( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DocumentService")), ::rtl::OUString() ); + ::rtl::OUString aTypeName = aImpFilterHM.getUnpackedValueOrDefault( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Type")), ::rtl::OUString() ); OSL_ENSURE( aDocumentServiceName.getLength() && aTypeName.getLength(), "Incomplete filter data!" ); if ( aDocumentServiceName.getLength() && aTypeName.getLength() ) { uno::Sequence< beans::NamedValue > aSearchRequest( 2 ); - aSearchRequest[0].Name = ::rtl::OUString::createFromAscii( "Type" ); + aSearchRequest[0].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Type")); aSearchRequest[0].Value <<= aTypeName; - aSearchRequest[1].Name = ::rtl::OUString::createFromAscii( "DocumentService" ); + aSearchRequest[1].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DocumentService")); aSearchRequest[1].Value <<= aDocumentServiceName; uno::Sequence< beans::PropertyValue > aExportFilterProps = SearchForFilter( @@ -831,7 +831,7 @@ sal_Bool MimeConfigurationHelper::AddFilterNameCheckOwnFile( if ( aExportFilterProps.getLength() ) { SequenceAsHashMap aExpPropsHM( aExportFilterProps ); - aExportFilterName = aExpPropsHM.getUnpackedValueOrDefault( ::rtl::OUString::createFromAscii( "Name" ), ::rtl::OUString() ); + aExportFilterName = aExpPropsHM.getUnpackedValueOrDefault( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Name")), ::rtl::OUString() ); } } } @@ -866,7 +866,7 @@ uno::Sequence< beans::PropertyValue > MimeConfigurationHelper::SearchForFilter( if ( xFilterEnum->nextElement() >>= aProps ) { SequenceAsHashMap aPropsHM( aProps ); - sal_Int32 nFlags = aPropsHM.getUnpackedValueOrDefault( ::rtl::OUString::createFromAscii( "Flags" ), + sal_Int32 nFlags = aPropsHM.getUnpackedValueOrDefault( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Flags")), (sal_Int32)0 ); if ( ( ( nFlags & nMustFlags ) == nMustFlags ) && !( nFlags & nDontFlags ) ) { diff --git a/comphelper/source/misc/uieventslogger.cxx b/comphelper/source/misc/uieventslogger.cxx index ab25d70c6e24..0491d9991271 100644 --- a/comphelper/source/misc/uieventslogger.cxx +++ b/comphelper/source/misc/uieventslogger.cxx @@ -49,6 +49,7 @@ #include <osl/mutex.hxx> #include <osl/time.h> #include <rtl/ustrbuf.hxx> +#include <rtl/instance.hxx> using namespace com::sun::star::beans; @@ -143,7 +144,6 @@ namespace comphelper // static methods and data static ptr getInstance(); - static void prepareMutex(); static bool shouldActivate(); static bool getEnabledFromCoreController(); static bool getEnabledFromCfg(); @@ -152,7 +152,6 @@ namespace comphelper static sal_Int32 findIdx(const Sequence<PropertyValue>& args, const OUString& key); static ptr instance; - static Mutex * singleton_mutex; static const sal_Int32 COLUMNS; static const OUString CFG_ENABLED; static const OUString CFG_IDLETIMEOUT; @@ -214,6 +213,10 @@ namespace comphelper const OUString UiEventsLogger_Impl::URL_SPECIAL(RTL_CONSTASCII_USTRINGPARAM(".special:")); const OUString UiEventsLogger_Impl::URL_FILE(RTL_CONSTASCII_USTRINGPARAM("file:")); + namespace + { + struct theSingletonMutex : public rtl::Static< Mutex, theSingletonMutex > {}; + } // public UiEventsLogger interface sal_Bool UiEventsLogger::isEnabled() @@ -221,8 +224,7 @@ namespace comphelper if ( UiEventsLogger_Impl::getEnabledFromCfg() ) { try { - UiEventsLogger_Impl::prepareMutex(); - Guard<Mutex> singleton_guard(UiEventsLogger_Impl::singleton_mutex); + Guard<Mutex> singleton_guard(theSingletonMutex::get()); return UiEventsLogger_Impl::getInstance()->m_Active; } catch(...) { return false; } // never throws } // if ( ) @@ -232,8 +234,7 @@ namespace comphelper sal_Int32 UiEventsLogger::getSessionLogEventCount() { try { - UiEventsLogger_Impl::prepareMutex(); - Guard<Mutex> singleton_guard(UiEventsLogger_Impl::singleton_mutex); + Guard<Mutex> singleton_guard(theSingletonMutex::get()); return UiEventsLogger_Impl::getInstance()->m_SessionLogEventCount; } catch(...) { return 0; } // never throws } @@ -269,8 +270,7 @@ namespace comphelper const Sequence<PropertyValue>& args) { try { - UiEventsLogger_Impl::prepareMutex(); - Guard<Mutex> singleton_guard(UiEventsLogger_Impl::singleton_mutex); + Guard<Mutex> singleton_guard(theSingletonMutex::get()); UiEventsLogger_Impl::getInstance()->logDispatch(url, args); } catch(...) { } // never throws } @@ -283,8 +283,7 @@ namespace comphelper const OUString& param) { try { - UiEventsLogger_Impl::prepareMutex(); - Guard<Mutex> singleton_guard(UiEventsLogger_Impl::singleton_mutex); + Guard<Mutex> singleton_guard(theSingletonMutex::get()); UiEventsLogger_Impl::getInstance()->logVcl(parent_id, window_type, id, method, param); } catch(...) { } // never throws } @@ -313,16 +312,14 @@ namespace comphelper void UiEventsLogger::disposing() { // we dont want to create an instance just to dispose it - UiEventsLogger_Impl::prepareMutex(); - Guard<Mutex> singleton_guard(UiEventsLogger_Impl::singleton_mutex); + Guard<Mutex> singleton_guard(theSingletonMutex::get()); if(UiEventsLogger_Impl::instance!=UiEventsLogger_Impl::ptr()) UiEventsLogger_Impl::getInstance()->disposing(); } void UiEventsLogger::reinit() { - UiEventsLogger_Impl::prepareMutex(); - Guard<Mutex> singleton_guard(UiEventsLogger_Impl::singleton_mutex); + Guard<Mutex> singleton_guard(theSingletonMutex::get()); if(UiEventsLogger_Impl::instance) { UiEventsLogger_Impl::instance->disposing(); @@ -665,17 +662,6 @@ namespace comphelper return instance; } - Mutex * UiEventsLogger_Impl::singleton_mutex = NULL; - void UiEventsLogger_Impl::prepareMutex() - { - if(singleton_mutex == NULL) - { - Guard<Mutex> global_guard(Mutex::getGlobalMutex()); - if(singleton_mutex == NULL) - singleton_mutex = new Mutex(); - } - } - sal_Int32 UiEventsLogger_Impl::findIdx(const Sequence<PropertyValue>& args, const OUString& key) { for(sal_Int32 i=0; i<args.getLength(); i++) diff --git a/comphelper/source/officeinstdir/officeinstallationdirectories.cxx b/comphelper/source/officeinstdir/officeinstallationdirectories.cxx index de636191b1aa..35bcfecc7f9d 100644 --- a/comphelper/source/officeinstdir/officeinstallationdirectories.cxx +++ b/comphelper/source/officeinstdir/officeinstallationdirectories.cxx @@ -67,7 +67,7 @@ static bool makeCanonicalFileURL( rtl::OUString & rURL ) if ( osl::DirectoryItem::get( aNormalizedURL, aDirItem ) == osl::DirectoryItem::E_None ) { - osl::FileStatus aFileStatus( FileStatusMask_FileURL ); + osl::FileStatus aFileStatus( osl_FileStatus_Mask_FileURL ); if ( aDirItem.getFileStatus( aFileStatus ) == osl::DirectoryItem::E_None ) @@ -162,9 +162,9 @@ OfficeInstallationDirectories::makeRelocatableURL( const rtl::OUString& URL ) if ( nIndex != -1 ) { return rtl::OUString( - URL.replaceAt( nIndex, - m_pOfficeBrandDir->getLength(), - m_aOfficeBrandDirMacro ) ); + aCanonicalURL.replaceAt( nIndex, + m_pOfficeBrandDir->getLength(), + m_aOfficeBrandDirMacro ) ); } else { @@ -172,9 +172,9 @@ OfficeInstallationDirectories::makeRelocatableURL( const rtl::OUString& URL ) if ( nIndex != -1 ) { return rtl::OUString( - URL.replaceAt( nIndex, - m_pOfficeBaseDir->getLength(), - m_aOfficeBaseDirMacro ) ); + aCanonicalURL.replaceAt( nIndex, + m_pOfficeBaseDir->getLength(), + m_aOfficeBaseDirMacro ) ); } else { @@ -182,9 +182,9 @@ OfficeInstallationDirectories::makeRelocatableURL( const rtl::OUString& URL ) if ( nIndex != -1 ) { return rtl::OUString( - URL.replaceAt( nIndex, - m_pUserDir->getLength(), - m_aUserDirMacro ) ); + aCanonicalURL.replaceAt( nIndex, + m_pUserDir->getLength(), + m_aUserDirMacro ) ); } } } diff --git a/comphelper/source/property/MasterPropertySet.cxx b/comphelper/source/property/MasterPropertySet.cxx index 2844031d370c..78f33af7aed0 100644 --- a/comphelper/source/property/MasterPropertySet.cxx +++ b/comphelper/source/property/MasterPropertySet.cxx @@ -108,7 +108,7 @@ MasterPropertySet::~MasterPropertySet() while (aIter != aEnd ) { delete (*aIter).second; - aIter++; + ++aIter; } } diff --git a/comphelper/source/property/MasterPropertySetInfo.cxx b/comphelper/source/property/MasterPropertySetInfo.cxx index 0cfaf6ec1a6f..46dffe062c03 100644 --- a/comphelper/source/property/MasterPropertySetInfo.cxx +++ b/comphelper/source/property/MasterPropertySetInfo.cxx @@ -63,7 +63,7 @@ MasterPropertySetInfo::~MasterPropertySetInfo() while (aIter != aEnd ) { delete (*aIter).second; - aIter++; + ++aIter; } } diff --git a/comphelper/source/property/propstate.cxx b/comphelper/source/property/propstate.cxx index 5be6c842a5f8..b58bdb6d0283 100644 --- a/comphelper/source/property/propstate.cxx +++ b/comphelper/source/property/propstate.cxx @@ -32,6 +32,7 @@ #include <com/sun/star/uno/genfunc.h> #include <cppuhelper/queryinterface.hxx> #include <comphelper/sequence.hxx> +#include <rtl/instance.hxx> //......................................................................... namespace comphelper @@ -217,20 +218,13 @@ namespace comphelper ); } + namespace { struct lcl_ImplId : public rtl::Static< ::cppu::OImplementationId, lcl_ImplId > {}; } + //--------------------------------------------------------------------- Sequence< sal_Int8 > SAL_CALL OStatefulPropertySet::getImplementationId() throw(RuntimeException) { - static ::cppu::OImplementationId * pId = NULL; - if ( !pId ) - { - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if ( !pId ) - { - static ::cppu::OImplementationId aId; - pId = &aId; - } - } - return pId->getImplementationId(); + ::cppu::OImplementationId &rID = lcl_ImplId::get(); + return rID.getImplementationId(); } //--------------------------------------------------------------------- diff --git a/comphelper/source/streaming/oslfile2streamwrap.cxx b/comphelper/source/streaming/oslfile2streamwrap.cxx index 40858acd338b..68af33298336 100644 --- a/comphelper/source/streaming/oslfile2streamwrap.cxx +++ b/comphelper/source/streaming/oslfile2streamwrap.cxx @@ -139,7 +139,7 @@ sal_Int32 SAL_CALL OSLInputStreamWrapper::available() throw( stario::NotConnecte throw stario::NotConnectedException(::rtl::OUString(), static_cast<staruno::XWeak*>(this)); sal_uInt64 nDummy = 0; - eError = m_pFile->setPos(Pos_End, nDummy); + eError = m_pFile->setPos(osl_Pos_End, nDummy); if (eError != FileBase::E_None) throw stario::NotConnectedException(::rtl::OUString(),static_cast<staruno::XWeak*>(this)); @@ -149,7 +149,7 @@ sal_Int32 SAL_CALL OSLInputStreamWrapper::available() throw( stario::NotConnecte throw stario::NotConnectedException(::rtl::OUString(),static_cast<staruno::XWeak*>(this)); nAvailable = nAvailable - nPos; - eError = m_pFile->setPos(Pos_Absolut, nPos); + eError = m_pFile->setPos(osl_Pos_Absolut, nPos); if (eError != FileBase::E_None) throw stario::NotConnectedException(::rtl::OUString(),static_cast<staruno::XWeak*>(this)); return sal::static_int_cast< sal_Int32 >( diff --git a/comphelper/source/xml/attributelist.cxx b/comphelper/source/xml/attributelist.cxx index 2c956623fcb7..2442fd69f106 100644 --- a/comphelper/source/xml/attributelist.cxx +++ b/comphelper/source/xml/attributelist.cxx @@ -93,7 +93,7 @@ OUString SAL_CALL AttributeList::getTypeByName( const OUString& sName ) throw( : { ::std::vector<struct TagAttribute_Impl>::iterator ii = m_pImpl->vecAttribute.begin(); - for( ; ii != m_pImpl->vecAttribute.end() ; ii ++ ) { + for( ; ii != m_pImpl->vecAttribute.end() ; ++ii ) { if( (*ii).sName == sName ) { return (*ii).sType; } @@ -105,7 +105,7 @@ OUString SAL_CALL AttributeList::getValueByName(const OUString& sName) throw( :: { ::std::vector<struct TagAttribute_Impl>::iterator ii = m_pImpl->vecAttribute.begin(); - for( ; ii != m_pImpl->vecAttribute.end() ; ii ++ ) { + for( ; ii != m_pImpl->vecAttribute.end() ; ++ii ) { if( (*ii).sName == sName ) { return (*ii).sValue; } @@ -144,7 +144,7 @@ void AttributeList::RemoveAttribute( const OUString sName ) { ::std::vector<struct TagAttribute_Impl>::iterator ii = m_pImpl->vecAttribute.begin(); - for( ; ii != m_pImpl->vecAttribute.end() ; ii ++ ) { + for( ; ii != m_pImpl->vecAttribute.end() ; ++ii ) { if( (*ii).sName == sName ) { m_pImpl->vecAttribute.erase( ii ); break; |