[Libreoffice-commits] core.git: 9 commits - framework/inc framework/source vcl/source
Stephan Bergmann
sbergman at redhat.com
Wed Dec 16 05:21:55 PST 2015
framework/inc/properties.h | 19 --
framework/inc/services/desktop.hxx | 1
framework/inc/threadhelp/transactionguard.hxx | 90 -----------
framework/inc/threadhelp/transactionmanager.hxx | 23 --
framework/source/fwi/threadhelp/transactionmanager.cxx | 116 +++-----------
framework/source/services/desktop.cxx | 138 +++++------------
framework/source/services/frame.cxx | 115 +++++++-------
vcl/source/window/brdwin.cxx | 2
8 files changed, 137 insertions(+), 367 deletions(-)
New commits:
commit 81a1d5ceb7a2fefa0d41a6e5ca1650120e46cbe9
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Wed Dec 16 14:20:46 2015 +0100
loplugin:vclwidgets
Change-Id: I9a9748879fcc55b524138d865e71a713efad180d
diff --git a/vcl/source/window/brdwin.cxx b/vcl/source/window/brdwin.cxx
index cc7cb3f..0e844e2 100644
--- a/vcl/source/window/brdwin.cxx
+++ b/vcl/source/window/brdwin.cxx
@@ -2179,7 +2179,7 @@ void ImplBorderWindow::SetMenuBarMode( bool bHide )
void ImplBorderWindow::SetNotebookBarWindow(const OUString& rUIXMLDescription, const css::uno::Reference<css::frame::XFrame>& rFrame)
{
- mpNotebookBarWindow.reset(new NotebookBarWindow(this, "NotebookBar", rUIXMLDescription, rFrame));
+ mpNotebookBarWindow = VclPtr<NotebookBarWindow>::Create(this, "NotebookBar", rUIXMLDescription, rFrame);
Resize();
mpNotebookBarWindow->Show();
}
commit df997d92e080c8ed95e393ae9710483529a82115
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Wed Dec 16 11:11:51 2015 +0100
Simplify Desktop::getInfoHelper
Change-Id: I13058816e8b2b1c821f0123f110671706bf90449
diff --git a/framework/inc/services/desktop.hxx b/framework/inc/services/desktop.hxx
index 6379e41..1731dd8 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 68c5ca8..8e92656 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 )
{
commit a2016848005b3ed9430575f6401bfec25f354dfa
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Wed Dec 16 10:53:36 2015 +0100
Remove comment noise
Change-Id: I7794e40e07520c1e504b1167aa64cf24819271f2
diff --git a/framework/inc/threadhelp/transactionguard.hxx b/framework/inc/threadhelp/transactionguard.hxx
index 52ee098..0b87721 100644
--- a/framework/inc/threadhelp/transactionguard.hxx
+++ b/framework/inc/threadhelp/transactionguard.hxx
@@ -25,59 +25,26 @@
namespace framework{
-/*-************************************************************************************************************
- @short implement a guard to support non breakable transactions
- @descr If you wish to support non breakable method calls without locking any mutex, rw-lock or
- something like that - you should use this guard implementation.
- Initialize it at first in your method and don't release it till end of your function!
- Your "transaction" is registered in ctor and automatically released in dtor.
- Use set/get of working mode to enable/disable further transactions.
- It's possible too, to enable automatically throwing of some exceptions for illegal
- transaction requests ... e.g. interface call for already disposed objects.
-
- @attention To prevent us against wrong using, the default ctor, copy ctor and the =operator are marked private!
- @devstatus draft
-*//*-*************************************************************************************************************/
class TransactionGuard : private boost::noncopyable
{
-
- // public methods
-
public:
-
- /*-****************************************************************************************************
- @short ctors
- @descr Use these ctor methods to initialize the guard right.
- Given reference must be valid - otherwise crashes could occur!
-
- @attention It's not necessary to lock any mutex here! Because a ctor should not be called
- from different threads at the same time ... this class use no refcount mechanism!
- @param "rManager" reference to transaction manager for using to register a request
- @param "eMode" enable/disable throwing of exceptions for rejected calls
- *//*-*****************************************************************************************************/
inline TransactionGuard( TransactionManager& rManager, EExceptionMode eMode )
: m_pManager( &rManager )
{
m_pManager->registerTransaction( eMode );
}
- /*-************************************************************************************************************
- @short dtor
- @descr We must release the transaction manager and can forget his pointer.
- *//*-*************************************************************************************************************/
inline ~TransactionGuard()
{
m_pManager->unregisterTransaction();
}
private:
+ TransactionManager* m_pManager;
+};
- TransactionManager* m_pManager; /// pointer to safed transaction manager
-
-}; // class TransactionGuard
-
-} // namespace framework
+}
-#endif // INCLUDED_FRAMEWORK_INC_THREADHELP_TRANSACTIONGUARD_HXX
+#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 4ac13fb72a12ac6dba7b002a4ac0cdd40eaaada5
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Wed Dec 16 10:52:40 2015 +0100
No need for TransactionGuard::stop
Change-Id: If1c0b7285817bb10338077460b77de4a27d35753
diff --git a/framework/inc/threadhelp/transactionguard.hxx b/framework/inc/threadhelp/transactionguard.hxx
index ac3aeca..52ee098 100644
--- a/framework/inc/threadhelp/transactionguard.hxx
+++ b/framework/inc/threadhelp/transactionguard.hxx
@@ -67,24 +67,7 @@ class TransactionGuard : private boost::noncopyable
*//*-*************************************************************************************************************/
inline ~TransactionGuard()
{
- stop();
- }
-
- /*-************************************************************************************************************
- @short stop current transaction
- @descr We must release the transaction manager and can forget his pointer.
-
- @attention We don't support any start() method here - because it is not easy to
- detect if a transaction already started or not!
- (combination of EExceptionMode and ERejectReason)
- *//*-*************************************************************************************************************/
- inline void stop()
- {
- if( m_pManager != nullptr )
- {
- m_pManager->unregisterTransaction();
- m_pManager = nullptr;
- }
+ m_pManager->unregisterTransaction();
}
private:
diff --git a/framework/source/services/desktop.cxx b/framework/source/services/desktop.cxx
index 35ce361..68c5ca8 100644
--- a/framework/source/services/desktop.cxx
+++ b/framework/source/services/desktop.cxx
@@ -1029,19 +1029,9 @@ void SAL_CALL Desktop::disposing()
SolarMutexClearableGuard aWriteLock;
- // Look for multiple calls of this method!
- // If somewhere call dispose() twice - he will be stopped here really!!!
- TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
-
- // Now - we are alone and its the first call of this method ...
- // otherwise call before had thrown a DisposedException / hopefully .-)
- // But we don't use the transaction object created before ... we reset it immediately ...
- // two lines of code ... for what ?
- // The answer: We wished to synchronize concurrent dispose() calls -> OK
- // But next line will wait for all currently running transaction (even if they
- // are running within the same thread!) So we would block ourself there if aTransaction
- // will stay registered .-)
- aTransaction.stop();
+ {
+ TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
+ }
// Disable this instance for further work.
// This will wait for all current running transactions ...
diff --git a/framework/source/services/frame.cxx b/framework/source/services/frame.cxx
index bcd12d4..69692ec 100644
--- a/framework/source/services/frame.cxx
+++ b/framework/source/services/frame.cxx
@@ -1729,79 +1729,80 @@ void SAL_CALL Frame::removeFrameActionListener( const css::uno::Reference< css::
void SAL_CALL Frame::close( sal_Bool bDeliverOwnership ) throw( css::util::CloseVetoException,
css::uno::RuntimeException, std::exception )
{
- TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
-
- // At the end of this method may we must dispose ourself...
- // and may nobody from outside hold a reference to us...
- // then it's a good idea to do that by ourself.
- css::uno::Reference< css::uno::XInterface > xSelfHold( static_cast< ::cppu::OWeakObject* >(this) );
-
- // Check any close listener before we look for currently running internal processes.
- // Because if a listener disagree with this close() request - we have time to finish this
- // internal operations too...
- // Note: container is threadsafe himself.
- css::lang::EventObject aSource (static_cast< ::cppu::OWeakObject*>(this));
- ::cppu::OInterfaceContainerHelper* pContainer = m_aListenerContainer.getContainer( cppu::UnoType<css::util::XCloseListener>::get());
- if (pContainer!=nullptr)
{
- ::cppu::OInterfaceIteratorHelper pIterator(*pContainer);
- while (pIterator.hasMoreElements())
+ TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
+
+ // At the end of this method may we must dispose ourself...
+ // and may nobody from outside hold a reference to us...
+ // then it's a good idea to do that by ourself.
+ css::uno::Reference< css::uno::XInterface > xSelfHold( static_cast< ::cppu::OWeakObject* >(this) );
+
+ // Check any close listener before we look for currently running internal processes.
+ // Because if a listener disagree with this close() request - we have time to finish this
+ // internal operations too...
+ // Note: container is threadsafe himself.
+ css::lang::EventObject aSource (static_cast< ::cppu::OWeakObject*>(this));
+ ::cppu::OInterfaceContainerHelper* pContainer = m_aListenerContainer.getContainer( cppu::UnoType<css::util::XCloseListener>::get());
+ if (pContainer!=nullptr)
{
- try
+ ::cppu::OInterfaceIteratorHelper pIterator(*pContainer);
+ while (pIterator.hasMoreElements())
{
- static_cast<css::util::XCloseListener*>(pIterator.next())->queryClosing( aSource, bDeliverOwnership );
- }
- catch( const css::uno::RuntimeException& )
- {
- pIterator.remove();
+ try
+ {
+ static_cast<css::util::XCloseListener*>(pIterator.next())->queryClosing( aSource, bDeliverOwnership );
+ }
+ catch( const css::uno::RuntimeException& )
+ {
+ pIterator.remove();
+ }
}
}
- }
- // Ok - no listener disagreed with this close() request
- // check if this frame is used for any load process currently
- if (isActionLocked())
- {
- if (bDeliverOwnership)
+ // Ok - no listener disagreed with this close() request
+ // check if this frame is used for any load process currently
+ if (isActionLocked())
{
- SolarMutexGuard g;
- m_bSelfClose = true;
- }
+ if (bDeliverOwnership)
+ {
+ SolarMutexGuard g;
+ m_bSelfClose = true;
+ }
- throw css::util::CloseVetoException("Frame in use for loading document ...",static_cast< ::cppu::OWeakObject*>(this));
- }
+ throw css::util::CloseVetoException("Frame in use for loading document ...",static_cast< ::cppu::OWeakObject*>(this));
+ }
- if ( ! setComponent(nullptr,nullptr) )
- throw css::util::CloseVetoException("Component couldn't be deattached ...",static_cast< ::cppu::OWeakObject*>(this));
+ if ( ! setComponent(nullptr,nullptr) )
+ throw css::util::CloseVetoException("Component couldn't be deattached ...",static_cast< ::cppu::OWeakObject*>(this));
- // If closing is allowed... inform all listeners and dispose this frame!
- pContainer = m_aListenerContainer.getContainer( cppu::UnoType<css::util::XCloseListener>::get());
- if (pContainer!=nullptr)
- {
- ::cppu::OInterfaceIteratorHelper pIterator(*pContainer);
- while (pIterator.hasMoreElements())
+ // If closing is allowed... inform all listeners and dispose this frame!
+ pContainer = m_aListenerContainer.getContainer( cppu::UnoType<css::util::XCloseListener>::get());
+ if (pContainer!=nullptr)
{
- try
+ ::cppu::OInterfaceIteratorHelper pIterator(*pContainer);
+ while (pIterator.hasMoreElements())
{
- static_cast<css::util::XCloseListener*>(pIterator.next())->notifyClosing( aSource );
- }
- catch( const css::uno::RuntimeException& )
- {
- pIterator.remove();
+ try
+ {
+ static_cast<css::util::XCloseListener*>(pIterator.next())->notifyClosing( aSource );
+ }
+ catch( const css::uno::RuntimeException& )
+ {
+ pIterator.remove();
+ }
}
}
- }
- /* SAFE { */
- SolarMutexClearableGuard aWriteLock;
- m_bIsHidden = true;
- aWriteLock.clear();
- /* } SAFE */
- impl_checkMenuCloser();
+ /* SAFE { */
+ SolarMutexClearableGuard aWriteLock;
+ m_bIsHidden = true;
+ aWriteLock.clear();
+ /* } SAFE */
+ impl_checkMenuCloser();
- // Attention: We must release our own registered transaction here. Otherwhise following dispose() call
- // wait for us too ....
- aTransaction.stop();
+ // Attention: We must release our own registered transaction here. Otherwhise following dispose() call
+ // wait for us too ....
+ }
dispose();
}
commit e9e61809ea31b30f50d39dda45e54bed6f0e4742
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Wed Dec 16 10:45:33 2015 +0100
Simplify TransactionManager
Change-Id: I51d1969f9f88d9e29fc081fd54df365578900126
diff --git a/framework/inc/threadhelp/transactionmanager.hxx b/framework/inc/threadhelp/transactionmanager.hxx
index cc9e0b1..e4beb04 100644
--- a/framework/inc/threadhelp/transactionmanager.hxx
+++ b/framework/inc/threadhelp/transactionmanager.hxx
@@ -52,18 +52,6 @@ enum EWorkingMode
};
/*-************************************************************************************************************
- @descr If a request was refused by a transaction manager (internal state different E_WORK ...)
- user can check the reason by using this enum values.
-*//*-*************************************************************************************************************/
-enum ERejectReason
-{
- E_UNINITIALIZED ,
- E_NOREASON ,
- E_INCLOSE ,
- E_CLOSED
-};
-
-/*-************************************************************************************************************
@descr A transaction object should support throwing exceptions if user used it at wrong working mode.
e.g. We can throw a DisposedException if user try to work and our mode is E_CLOSE!
But sometimes he doesn't need this feature - will handle it by himself.
@@ -120,18 +108,9 @@ class FWI_DLLPUBLIC TransactionManager: private boost::noncopyable
~TransactionManager ( );
void setWorkingMode ( EWorkingMode eMode );
EWorkingMode getWorkingMode ( ) const;
- bool isCallRejected ( ERejectReason& eReason ) const;
void registerTransaction ( EExceptionMode eMode ) throw( css::uno::RuntimeException, css::lang::DisposedException );
void unregisterTransaction ( ) throw( css::uno::RuntimeException, css::lang::DisposedException );
- // private methods
-
- private:
-
- void impl_throwExceptions( EExceptionMode eMode, ERejectReason eReason ) const throw( css::uno::RuntimeException, css::lang::DisposedException );
-
- // private member
-
private:
mutable ::osl::Mutex m_aAccessLock; /// regulate access on internal member of this instance
diff --git a/framework/source/fwi/threadhelp/transactionmanager.cxx b/framework/source/fwi/threadhelp/transactionmanager.cxx
index 6639d78..a6d8efc 100644
--- a/framework/source/fwi/threadhelp/transactionmanager.cxx
+++ b/framework/source/fwi/threadhelp/transactionmanager.cxx
@@ -155,22 +155,34 @@ EWorkingMode TransactionManager::getWorkingMode() const
*//*-*****************************************************************************************************/
void TransactionManager::registerTransaction( EExceptionMode eMode ) throw( css::uno::RuntimeException, css::lang::DisposedException )
{
- // Look for rejected calls first.
- // If call was refused we throw some exceptions or do nothing!
- // It depends from given parameter eMode.
- ERejectReason eReason;
- if( isCallRejected( eReason ) )
+ ::osl::MutexGuard aAccessGuard( m_aAccessLock );
+ switch( m_eWorkingMode )
{
- impl_throwExceptions( eMode, eReason );
+ case E_INIT:
+ if( eMode == E_HARDEXCEPTIONS )
+ {
+ // Help programmer to find out, why this exception is thrown!
+ SAL_WARN( "fwk", "TransactionManager...: Owner instance not correctly initialized yet. Call was rejected! Normally it's an algorithm error ... wrong use of class!" );
+ //ATTENTION: temp. disabled - till all bad code positions are detected and changed! */
+ // throw css::uno::RuntimeException( "TransactionManager...\nOwner instance not right initialized yet. Call was rejected! Normally it's an algorithm error... wrong using of class!\n", css::uno::Reference< css::uno::XInterface >() );
+ }
+ break;
+ case E_WORK:
+ break;
+ case E_BEFORECLOSE:
+ if( eMode == E_HARDEXCEPTIONS )
+ {
+ // Help programmer to find out, why this exception is thrown!
+ SAL_WARN( "fwk", "TransactionManager...: Owner instance stand in close method. Call was rejected!" );
+ throw css::lang::DisposedException( "TransactionManager...\nOwner instance stand in close method. Call was rejected!" );
+ }
+ break;
+ case E_CLOSE:
+ // Help programmer to find out, why this exception is thrown!
+ SAL_WARN( "fwk", "TransactionManager...: Owner instance already closed. Call was rejected!" );
+ throw css::lang::DisposedException( "TransactionManager...\nOwner instance already closed. Call was rejected!" );
}
- // BUT if no exception was thrown ... (may be eMode = E_SOFTEXCEPTIONS!)
- // we must register this transaction too!
- // Don't use "else" or a new scope here!!!
-
- // Safe access to internal member.
- ::osl::MutexGuard aAccessGuard( m_aAccessLock );
-
// Register this new transaction.
// If it is the first one .. close gate to disable changing of working mode.
++m_nTransactionCount;
@@ -203,82 +215,6 @@ void TransactionManager::unregisterTransaction() throw( css::uno::RuntimeExcept
}
}
-/*-****************************************************************************************************
- @short look for rejected calls
- @descr Sometimes user need a possibility to get information about rejected calls
- without starting a transaction!
- @param "eReason" returns reason of a rejected call
- @return true if call was rejected, false otherwise
-
- @onerror We return false.
-*//*-*****************************************************************************************************/
-bool TransactionManager::isCallRejected( ERejectReason& eReason ) const
-{
- // This call must safe access to internal member only.
- // Set "possible reason" for return and check reject-state then!
- // User should look for return value first - reason then ...
- ::osl::MutexGuard aAccessGuard( m_aAccessLock );
- switch( m_eWorkingMode )
- {
- case E_INIT : eReason = E_UNINITIALIZED;
- break;
- case E_WORK : eReason = E_NOREASON;
- break;
- case E_BEFORECLOSE : eReason = E_INCLOSE;
- break;
- case E_CLOSE : eReason = E_CLOSED;
- break;
- }
- return( eReason!=E_NOREASON );
-}
-
-/*-****************************************************************************************************
- @short throw any exceptions for rejected calls
- @descr If a user wishes to use our automatic exception mode we use this impl-method.
- We check all combinations of eReason and eExceptionMode and throw correct exception with some
- descriptions for the recipient.
-
- @seealso method registerTransaction()
- @seealso enum ERejectReason
- @seealso enum EExceptionMode
-
- @param "eReason" , reason for rejected call
- @param "eMode" , exception mode - set by user
-*//*-*****************************************************************************************************/
-void TransactionManager::impl_throwExceptions( EExceptionMode eMode, ERejectReason eReason ) const throw( css::uno::RuntimeException, css::lang::DisposedException )
-{
- switch( eReason )
- {
- case E_UNINITIALIZED : if( eMode == E_HARDEXCEPTIONS )
- {
- // Help programmer to find out, why this exception is thrown!
- SAL_WARN( "fwk", "TransactionManager...: Owner instance not correctly initialized yet. Call was rejected! Normally it's an algorithm error ... wrong use of class!" );
- //ATTENTION: temp. disabled - till all bad code positions are detected and changed! */
- // throw css::uno::RuntimeException( "TransactionManager...\nOwner instance not right initialized yet. Call was rejected! Normally it's an algorithm error... wrong using of class!\n", css::uno::Reference< css::uno::XInterface >() );
- }
- break;
- case E_INCLOSE : if( eMode == E_HARDEXCEPTIONS )
- {
- // Help programmer to find out, why this exception is thrown!
- SAL_WARN( "fwk", "TransactionManager...: Owner instance stand in close method. Call was rejected!" );
- throw css::lang::DisposedException( "TransactionManager...\nOwner instance stand in close method. Call was rejected!" );
- }
- break;
- case E_CLOSED : {
- // Help programmer to find out, why this exception is thrown!
- SAL_WARN( "fwk", "TransactionManager...: Owner instance already closed. Call was rejected!" );
- throw css::lang::DisposedException( "TransactionManager...\nOwner instance already closed. Call was rejected!" );
- }
- case E_NOREASON : {
- // Help programmer to find out
- SAL_WARN( "fwk", "TransactionManager...: Impossible case E_NOREASON!" );
- }
- break;
- default:
- assert(false);
- }
-}
-
} // namespace framework
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit fc44b7104cacc5ec76d2a0b560a9f6bbc5c252b5
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Wed Dec 16 10:35:35 2015 +0100
No need to pass eReason out of TransactionManager::registerTransaction
Change-Id: I0c8468219a4a9df904f34ec1363043bc46265c14
diff --git a/framework/inc/threadhelp/transactionguard.hxx b/framework/inc/threadhelp/transactionguard.hxx
index 7a85e6a..ac3aeca 100644
--- a/framework/inc/threadhelp/transactionguard.hxx
+++ b/framework/inc/threadhelp/transactionguard.hxx
@@ -58,11 +58,7 @@ class TransactionGuard : private boost::noncopyable
inline TransactionGuard( TransactionManager& rManager, EExceptionMode eMode )
: m_pManager( &rManager )
{
- // If exception mode is set to E_HARDEXCEPTIONS we don't need a buffer to return reason!
- // We handle it private. If a call is rejected, our manager throw some exceptions ... and the reason
- // could be ignorable ...
- ERejectReason eMyReason;
- m_pManager->registerTransaction( eMode, eMyReason );
+ m_pManager->registerTransaction( eMode );
}
/*-************************************************************************************************************
diff --git a/framework/inc/threadhelp/transactionmanager.hxx b/framework/inc/threadhelp/transactionmanager.hxx
index 393e130..cc9e0b1 100644
--- a/framework/inc/threadhelp/transactionmanager.hxx
+++ b/framework/inc/threadhelp/transactionmanager.hxx
@@ -121,7 +121,7 @@ class FWI_DLLPUBLIC TransactionManager: private boost::noncopyable
void setWorkingMode ( EWorkingMode eMode );
EWorkingMode getWorkingMode ( ) const;
bool isCallRejected ( ERejectReason& eReason ) const;
- void registerTransaction ( EExceptionMode eMode, ERejectReason& eReason ) throw( css::uno::RuntimeException, css::lang::DisposedException );
+ void registerTransaction ( EExceptionMode eMode ) throw( css::uno::RuntimeException, css::lang::DisposedException );
void unregisterTransaction ( ) throw( css::uno::RuntimeException, css::lang::DisposedException );
// private methods
diff --git a/framework/source/fwi/threadhelp/transactionmanager.cxx b/framework/source/fwi/threadhelp/transactionmanager.cxx
index a6ade42..6639d78 100644
--- a/framework/source/fwi/threadhelp/transactionmanager.cxx
+++ b/framework/source/fwi/threadhelp/transactionmanager.cxx
@@ -152,13 +152,13 @@ EWorkingMode TransactionManager::getWorkingMode() const
@seealso method unregisterTransaction()
@param "eMode" ,used to enable/disable throwing exceptions automatically for rejected calls
- @param "eReason" ,reason for rejected calls
*//*-*****************************************************************************************************/
-void TransactionManager::registerTransaction( EExceptionMode eMode, ERejectReason& eReason ) throw( css::uno::RuntimeException, css::lang::DisposedException )
+void TransactionManager::registerTransaction( EExceptionMode eMode ) throw( css::uno::RuntimeException, css::lang::DisposedException )
{
// Look for rejected calls first.
// If call was refused we throw some exceptions or do nothing!
// It depends from given parameter eMode.
+ ERejectReason eReason;
if( isCallRejected( eReason ) )
{
impl_throwExceptions( eMode, eReason );
commit 51351a28ec45f7b3cb4bcca6bead9a5c2165211b
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Wed Dec 16 10:28:38 2015 +0100
TransactionGuard is always called with null eReason
Change-Id: If416f9539136563dba43f38f7622d70e7fb1f005
diff --git a/framework/inc/threadhelp/transactionguard.hxx b/framework/inc/threadhelp/transactionguard.hxx
index 80ffb77..7a85e6a 100644
--- a/framework/inc/threadhelp/transactionguard.hxx
+++ b/framework/inc/threadhelp/transactionguard.hxx
@@ -54,23 +54,15 @@ class TransactionGuard : private boost::noncopyable
from different threads at the same time ... this class use no refcount mechanism!
@param "rManager" reference to transaction manager for using to register a request
@param "eMode" enable/disable throwing of exceptions for rejected calls
- @param "eReason" returns reason for rejected calls
*//*-*****************************************************************************************************/
- inline TransactionGuard( TransactionManager& rManager, EExceptionMode eMode, ERejectReason* eReason = nullptr )
+ inline TransactionGuard( TransactionManager& rManager, EExceptionMode eMode )
: m_pManager( &rManager )
{
// If exception mode is set to E_HARDEXCEPTIONS we don't need a buffer to return reason!
// We handle it private. If a call is rejected, our manager throw some exceptions ... and the reason
// could be ignorable ...
- if( eReason == nullptr )
- {
- ERejectReason eMyReason;
- m_pManager->registerTransaction( eMode, eMyReason );
- }
- else
- {
- m_pManager->registerTransaction( eMode, *eReason );
- }
+ ERejectReason eMyReason;
+ m_pManager->registerTransaction( eMode, eMyReason );
}
/*-************************************************************************************************************
commit 1681323093de8555edf49c136621db80c05cd892
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Wed Dec 16 10:26:40 2015 +0100
Remove dead ctor
Change-Id: If1576f9eabcad4e0287181838e0a019fe9372065
diff --git a/framework/inc/threadhelp/transactionguard.hxx b/framework/inc/threadhelp/transactionguard.hxx
index 30f9dfb..80ffb77 100644
--- a/framework/inc/threadhelp/transactionguard.hxx
+++ b/framework/inc/threadhelp/transactionguard.hxx
@@ -99,20 +99,6 @@ class TransactionGuard : private boost::noncopyable
}
}
-
- private:
-
- /*-****************************************************************************************************
- @short disable using of these functions!
- @descr It's not allowed to use this methods. Different problem can occur otherwise.
- Thats why we disable it by make it private.
-
- @seealso other ctor
- *//*-*****************************************************************************************************/
- TransactionGuard();
-
- // private member
-
private:
TransactionManager* m_pManager; /// pointer to safed transaction manager
commit 52379d720b0f61bd14520c69a4fbff928e37a0d0
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Tue Dec 15 17:30:21 2015 +0100
Clean up
Change-Id: I170b12d1024d51beb5c48333c0759bc33049f577
diff --git a/framework/inc/properties.h b/framework/inc/properties.h
index 5f0947d..383225f 100644
--- a/framework/inc/properties.h
+++ b/framework/inc/properties.h
@@ -43,25 +43,6 @@ namespace framework{
#define FRAME_PROPCOUNT 5
-/** properties for "Desktop" class */
-
-#define DESKTOP_PROPNAME_ASCII_ACTIVEFRAME "ActiveFrame"
-#define DESKTOP_PROPNAME_ASCII_DISPATCHRECORDERSUPPLIER "DispatchRecorderSupplier"
-#define DESKTOP_PROPNAME_ASCII_ISPLUGGED "IsPlugged"
-#define DESKTOP_PROPNAME_ASCII_SUSPENDQUICKSTARTVETO "SuspendQuickstartVeto"
-#define DESKTOP_PROPNAME_ASCII_TITLE "Title"
-
-// Please add new entries alphabetical sorted and correct all other handles!
-// Start counting with 0, so it can be used as direct index into an array too.
-// Don't forget updating of define DESKTOP_PROPCOUNT below!!!
-#define DESKTOP_PROPHANDLE_ACTIVEFRAME 0
-#define DESKTOP_PROPHANDLE_DISPATCHRECORDERSUPPLIER 1
-#define DESKTOP_PROPHANDLE_ISPLUGGED 2
-#define DESKTOP_PROPHANDLE_SUSPENDQUICKSTARTVETO 3
-#define DESKTOP_PROPHANDLE_TITLE 4
-
-#define DESKTOP_PROPCOUNT 5
-
/** properties for "PathSettings" class */
#define PATHSETTINGS_PROPNAME_ASCII_ADDIN "Addin"
diff --git a/framework/source/services/desktop.cxx b/framework/source/services/desktop.cxx
index edbadd8..35ce361 100644
--- a/framework/source/services/desktop.cxx
+++ b/framework/source/services/desktop.cxx
@@ -68,6 +68,10 @@
namespace framework{
+enum PropHandle {
+ ActiveFrame, DispatchRecorderSupplier, IsPlugged, SuspendQuickstartVeto,
+ Title };
+
OUString SAL_CALL Desktop::getImplementationName()
throw (css::uno::RuntimeException, std::exception)
{
@@ -1288,7 +1292,7 @@ OUString SAL_CALL Desktop::getUntitledPrefix()
@short try to convert a property value
@descr This method is called from helperclass "OPropertySetHelper".
Don't use this directly!
- You must try to convert the value of given DESKTOP_PROPHANDLE and
+ You must try to convert the value of given PropHandle and
return results of this operation. This will be used to ask vetoable
listener. If no listener has a veto, we will change value really!
( in method setFastPropertyValue_NoBroadcast(...) )
@@ -1323,21 +1327,21 @@ sal_Bool SAL_CALL Desktop::convertFastPropertyValue( css::uno::Any& aCon
switch( nHandle )
{
- case DESKTOP_PROPHANDLE_SUSPENDQUICKSTARTVETO:
+ case PropHandle::SuspendQuickstartVeto:
bReturn = PropHelper::willPropertyBeChanged(
css::uno::makeAny(m_bSuspendQuickstartVeto),
aValue,
aOldValue,
aConvertedValue);
break;
- case DESKTOP_PROPHANDLE_DISPATCHRECORDERSUPPLIER :
+ case PropHandle::DispatchRecorderSupplier :
bReturn = PropHelper::willPropertyBeChanged(
css::uno::makeAny(m_xDispatchRecorderSupplier),
aValue,
aOldValue,
aConvertedValue);
break;
- case DESKTOP_PROPHANDLE_TITLE :
+ case PropHandle::Title :
bReturn = PropHelper::willPropertyBeChanged(
css::uno::makeAny(m_sTitle),
aValue,
@@ -1373,11 +1377,11 @@ void SAL_CALL Desktop::setFastPropertyValue_NoBroadcast( sal_Int32
switch( nHandle )
{
- case DESKTOP_PROPHANDLE_SUSPENDQUICKSTARTVETO: aValue >>= m_bSuspendQuickstartVeto;
+ case PropHandle::SuspendQuickstartVeto: aValue >>= m_bSuspendQuickstartVeto;
break;
- case DESKTOP_PROPHANDLE_DISPATCHRECORDERSUPPLIER: aValue >>= m_xDispatchRecorderSupplier;
+ case PropHandle::DispatchRecorderSupplier: aValue >>= m_xDispatchRecorderSupplier;
break;
- case DESKTOP_PROPHANDLE_TITLE: aValue >>= m_sTitle;
+ case PropHandle::Title: aValue >>= m_sTitle;
break;
}
}
@@ -1404,15 +1408,15 @@ void SAL_CALL Desktop::getFastPropertyValue( css::uno::Any& aValue ,
switch( nHandle )
{
- case DESKTOP_PROPHANDLE_ACTIVEFRAME : aValue <<= m_aChildTaskContainer.getActive();
+ case PropHandle::ActiveFrame : aValue <<= m_aChildTaskContainer.getActive();
break;
- case DESKTOP_PROPHANDLE_ISPLUGGED : aValue <<= sal_False;
+ case PropHandle::IsPlugged : aValue <<= sal_False;
break;
- case DESKTOP_PROPHANDLE_SUSPENDQUICKSTARTVETO: aValue <<= m_bSuspendQuickstartVeto;
+ case PropHandle::SuspendQuickstartVeto: aValue <<= m_bSuspendQuickstartVeto;
break;
- case DESKTOP_PROPHANDLE_DISPATCHRECORDERSUPPLIER: aValue <<= m_xDispatchRecorderSupplier;
+ case PropHandle::DispatchRecorderSupplier: aValue <<= m_xDispatchRecorderSupplier;
break;
- case DESKTOP_PROPHANDLE_TITLE: aValue <<= m_sTitle;
+ case PropHandle::Title: aValue <<= m_sTitle;
break;
}
}
@@ -1573,19 +1577,23 @@ const css::uno::Sequence< css::beans::Property > Desktop::impl_getStaticProperty
// It's necessary for methods of OPropertySetHelper.
// ATTENTION:
// YOU MUST SORT FOLLOW TABLE BY NAME ALPHABETICAL !!!
-
- const css::beans::Property pProperties[] =
- {
- css::beans::Property( DESKTOP_PROPNAME_ASCII_ACTIVEFRAME , DESKTOP_PROPHANDLE_ACTIVEFRAME , cppu::UnoType<css::lang::XComponent>::get(), css::beans::PropertyAttribute::TRANSIENT | css::beans::PropertyAttribute::READONLY ),
- css::beans::Property( DESKTOP_PROPNAME_ASCII_DISPATCHRECORDERSUPPLIER , DESKTOP_PROPHANDLE_DISPATCHRECORDERSUPPLIER, cppu::UnoType<css::frame::XDispatchRecorderSupplier>::get(), css::beans::PropertyAttribute::TRANSIENT ),
- css::beans::Property( DESKTOP_PROPNAME_ASCII_ISPLUGGED , DESKTOP_PROPHANDLE_ISPLUGGED , cppu::UnoType<bool>::get() , css::beans::PropertyAttribute::TRANSIENT | css::beans::PropertyAttribute::READONLY ),
- css::beans::Property( DESKTOP_PROPNAME_ASCII_SUSPENDQUICKSTARTVETO , DESKTOP_PROPHANDLE_SUSPENDQUICKSTARTVETO , cppu::UnoType<bool>::get() , css::beans::PropertyAttribute::TRANSIENT ),
- css::beans::Property( DESKTOP_PROPNAME_ASCII_TITLE , DESKTOP_PROPHANDLE_TITLE , cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::TRANSIENT ),
- };
- // Use it to initialize sequence!
- const css::uno::Sequence< css::beans::Property > lPropertyDescriptor( pProperties, DESKTOP_PROPCOUNT );
- // Return "PropertyDescriptor"
- return lPropertyDescriptor;
+ 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,
More information about the Libreoffice-commits
mailing list