diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2015-12-16 11:11:51 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2015-12-16 14:21:27 +0100 |
commit | df997d92e080c8ed95e393ae9710483529a82115 (patch) | |
tree | 16e4f5a068e3b1a40a0fe0d32a5ab5a84d6dc868 /framework | |
parent | a2016848005b3ed9430575f6401bfec25f354dfa (diff) |
Simplify Desktop::getInfoHelper
Change-Id: I13058816e8b2b1c821f0123f110671706bf90449
Diffstat (limited to 'framework')
-rw-r--r-- | framework/inc/services/desktop.hxx | 1 | ||||
-rw-r--r-- | framework/source/services/desktop.cxx | 98 |
2 files changed, 25 insertions, 74 deletions
diff --git a/framework/inc/services/desktop.hxx b/framework/inc/services/desktop.hxx index 6379e41f933f..1731dd846782 100644 --- a/framework/inc/services/desktop.hxx +++ b/framework/inc/services/desktop.hxx @@ -322,7 +322,6 @@ class Desktop : private cppu::BaseMutex, private: css::uno::Reference< css::lang::XComponent > impl_getFrameComponent ( const css::uno::Reference< css::frame::XFrame >& xFrame ) const; - static const css::uno::Sequence< css::beans::Property > impl_getStaticPropertyDescriptor( ); /** calls queryTermination() on every registered termination listener. * diff --git a/framework/source/services/desktop.cxx b/framework/source/services/desktop.cxx index 68c5ca8954e5..8e92656d9d9e 100644 --- a/framework/source/services/desktop.cxx +++ b/framework/source/services/desktop.cxx @@ -60,6 +60,7 @@ #include <comphelper/sequence.hxx> #include <cppuhelper/supportsservice.hxx> +#include <rtl/instance.hxx> #include <vcl/svapp.hxx> #include <tools/errinf.hxx> @@ -1411,46 +1412,34 @@ void SAL_CALL Desktop::getFastPropertyValue( css::uno::Any& aValue , } } -/*-************************************************************************************************************ - @short return structure and information about transient properties - @descr This method is calling from helperclass "OPropertySetHelper". - Don't use this directly! - - @attention You must use global lock (method use static variable) ... and it must be the shareable osl mutex of it. - Because; our baseclass use this mutex to make his code threadsafe. We use our lock! - So we could have two different mutex/lock mechanism at the same object. - - @seealso class OPropertySetHelper - @return structure with property-information - @threadsafe yes -*//*-*************************************************************************************************************/ ::cppu::IPropertyArrayHelper& SAL_CALL Desktop::getInfoHelper() { - /* UNSAFE AREA --------------------------------------------------------------------------------------------- */ - // Register transaction and reject wrong calls. - TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS ); - - // Optimize this method ! - // We initialize a static variable only one time. And we don't must use a mutex at every call! - // For the first call; pInfoHelper is NULL - for the second call pInfoHelper is different from NULL! - static ::cppu::OPropertyArrayHelper* pInfoHelper = nullptr; - - if( pInfoHelper == nullptr ) + struct Static: + public rtl::StaticWithInit<cppu::OPropertyArrayHelper, Static> { - SolarMutexGuard aGuard; - - // Control this pointer again, another instance can be faster then these! - if( pInfoHelper == nullptr ) - { - // Define static member to give structure of properties to baseclass "OPropertySetHelper". - // "impl_getStaticPropertyDescriptor" is a non exported and static function, who will define a static propertytable. - // "sal_True" say: Table is sorted by name. - static ::cppu::OPropertyArrayHelper aInfoHelper( impl_getStaticPropertyDescriptor(), sal_True ); - pInfoHelper = &aInfoHelper; + cppu::OPropertyArrayHelper operator ()() { + return { + {{"ActiveFrame", PropHandle::ActiveFrame, + cppu::UnoType<css::lang::XComponent>::get(), + (css::beans::PropertyAttribute::TRANSIENT + | css::beans::PropertyAttribute::READONLY)}, + {"DispatchRecorderSupplier", + PropHandle::DispatchRecorderSupplier, + cppu::UnoType<css::frame::XDispatchRecorderSupplier>::get(), + css::beans::PropertyAttribute::TRANSIENT}, + {"IsPlugged", + PropHandle::IsPlugged, cppu::UnoType<bool>::get(), + (css::beans::PropertyAttribute::TRANSIENT + | css::beans::PropertyAttribute::READONLY)}, + {"SuspendQuickstartVeto", PropHandle::SuspendQuickstartVeto, + cppu::UnoType<bool>::get(), + css::beans::PropertyAttribute::TRANSIENT}, + {"Title", PropHandle::Title, cppu::UnoType<OUString>::get(), + css::beans::PropertyAttribute::TRANSIENT}}, + true}; } - } - - return(*pInfoHelper); + }; + return Static::get(); } /*-************************************************************************************************************ @@ -1549,43 +1538,6 @@ css::uno::Reference< css::lang::XComponent > Desktop::impl_getFrameComponent( co return xComponent; } -/*-************************************************************************************************************ - @short create table with information about properties - @descr We use a helper class to support properties. These class need some information about this. - These method create a new static description table with name, type, r/w-flags and so on ... - - @seealso class OPropertySetHelper - @seealso method getInfoHelper() - @return Static table with information about properties. - @threadsafe yes -*//*-*************************************************************************************************************/ -const css::uno::Sequence< css::beans::Property > Desktop::impl_getStaticPropertyDescriptor() -{ - // Create a property array to initialize sequence! - // Table of all predefined properties of this class. Its used from OPropertySetHelper-class! - // Don't forget to change the defines (see begin of this file), if you add, change or delete a property in this list!!! - // It's necessary for methods of OPropertySetHelper. - // ATTENTION: - // YOU MUST SORT FOLLOW TABLE BY NAME ALPHABETICAL !!! - return { - {"ActiveFrame", PropHandle::ActiveFrame, - cppu::UnoType<css::lang::XComponent>::get(), - (css::beans::PropertyAttribute::TRANSIENT - | css::beans::PropertyAttribute::READONLY)}, - {"DispatchRecorderSupplier", - PropHandle::DispatchRecorderSupplier, - cppu::UnoType<css::frame::XDispatchRecorderSupplier>::get(), - css::beans::PropertyAttribute::TRANSIENT}, - {"IsPlugged", PropHandle::IsPlugged, cppu::UnoType<bool>::get(), - (css::beans::PropertyAttribute::TRANSIENT - | css::beans::PropertyAttribute::READONLY)}, - {"SuspendQuickstartVeto", - PropHandle::SuspendQuickstartVeto, cppu::UnoType<bool>::get(), - css::beans::PropertyAttribute::TRANSIENT}, - {"Title", PropHandle::Title, cppu::UnoType<OUString>::get(), - css::beans::PropertyAttribute::TRANSIENT}}; -} - void Desktop::impl_sendQueryTerminationEvent(Desktop::TTerminateListenerList& lCalledListener, bool& bVeto ) { |