summaryrefslogtreecommitdiff
path: root/dbaccess/source/ui/browser/genericcontroller.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'dbaccess/source/ui/browser/genericcontroller.cxx')
-rw-r--r--dbaccess/source/ui/browser/genericcontroller.cxx142
1 files changed, 48 insertions, 94 deletions
diff --git a/dbaccess/source/ui/browser/genericcontroller.cxx b/dbaccess/source/ui/browser/genericcontroller.cxx
index 7d0d326605b0..8bde54b54549 100644
--- a/dbaccess/source/ui/browser/genericcontroller.cxx
+++ b/dbaccess/source/ui/browser/genericcontroller.cxx
@@ -23,7 +23,7 @@
#include <vcl/weld.hxx>
#include <toolkit/helper/vclunohelper.hxx>
#include <dbaccess/dataview.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <osl/diagnose.h>
#include <vcl/stdtext.hxx>
#include <framework/titlehelper.hxx>
@@ -37,7 +37,6 @@
#include <com/sun/star/util/XCloseable.hpp>
#include <com/sun/star/ui/XSidebarProvider.hpp>
-#include <sfx2/userinputinterception.hxx>
#include <datasourceconnector.hxx>
#include <com/sun/star/frame/FrameSearchFlag.hpp>
@@ -57,7 +56,6 @@ using namespace ::com::sun::star::frame;
using namespace ::com::sun::star::frame::status;
using namespace ::com::sun::star::util;
using namespace ::com::sun::star::lang;
-using namespace ::com::sun::star::container;
using namespace ::com::sun::star::sdbc;
using namespace ::com::sun::star::sdb;
using namespace ::com::sun::star::task;
@@ -67,40 +65,17 @@ using namespace ::dbtools;
using namespace ::comphelper;
#define ALL_FEATURES -1
-#define FIRST_USER_DEFINED_FEATURE ( std::numeric_limits< sal_uInt16 >::max() - 1000 )
-#define LAST_USER_DEFINED_FEATURE ( std::numeric_limits< sal_uInt16 >::max() )
typedef std::unordered_map< sal_Int16, sal_Int16 > CommandHashMap;
namespace dbaui
{
-namespace {
-
-// UserDefinedFeatures
-class UserDefinedFeatures
-{
-public:
- explicit UserDefinedFeatures( const Reference< XController >& _rxController );
-
- void execute( const URL& _rFeatureURL, const Sequence< PropertyValue>& _rArgs );
-
-private:
- css::uno::WeakReference< XController > m_aController;
-};
-
-}
-
-UserDefinedFeatures::UserDefinedFeatures( const Reference< XController >& _rxController )
- :m_aController( _rxController )
-{
-}
-
-void UserDefinedFeatures::execute( const URL& _rFeatureURL, const Sequence< PropertyValue>& _rArgs )
+void OGenericUnoController::executeUserDefinedFeatures( const URL& _rFeatureURL, const Sequence< PropertyValue>& _rArgs )
{
try
{
- Reference< XController > xController( Reference< XController >(m_aController), UNO_SET_THROW );
+ Reference< XController > xController( getXController(), UNO_SET_THROW );
Reference< XDispatchProvider > xDispatchProvider( xController->getFrame(), UNO_QUERY_THROW );
Reference< XDispatch > xDispatch( xDispatchProvider->queryDispatch(
_rFeatureURL,
@@ -123,22 +98,10 @@ void UserDefinedFeatures::execute( const URL& _rFeatureURL, const Sequence< Prop
}
}
-// OGenericUnoController_Data
-struct OGenericUnoController_Data
-{
- ::sfx2::UserInputInterception m_aUserInputInterception;
- UserDefinedFeatures m_aUserDefinedFeatures;
-
- OGenericUnoController_Data( OGenericUnoController& _rController, ::osl::Mutex& _rMutex )
- :m_aUserInputInterception( _rController, _rMutex )
- ,m_aUserDefinedFeatures( _rController.getXController() )
- {
- }
-};
-
// OGenericUnoController
OGenericUnoController::OGenericUnoController(const Reference< XComponentContext >& _rM)
:OGenericUnoController_Base( getMutex() )
+ ,m_aUserInputInterception(*this, getMutex())
,m_pView(nullptr)
#ifdef DBG_UTIL
,m_bDescribingSupportedFeatures( false )
@@ -152,12 +115,6 @@ OGenericUnoController::OGenericUnoController(const Reference< XComponentContext
,m_bCurrentlyModified(false)
,m_bExternalTitle(false)
{
- osl_atomic_increment( &m_refCount );
- {
- m_pData.reset( new OGenericUnoController_Data( *this, getMutex() ) );
- }
- osl_atomic_decrement( &m_refCount );
-
try
{
@@ -209,7 +166,7 @@ IMPL_LINK_NOARG(OGenericUnoController, OnAsyncInvalidateAll, void*, void)
InvalidateFeature_Impl();
}
-void OGenericUnoController::impl_initialize()
+void OGenericUnoController::impl_initialize(const ::comphelper::NamedValueCollection& /*rArguments*/)
{
}
@@ -248,7 +205,6 @@ void SAL_CALL OGenericUnoController::initialize( const Sequence< Any >& aArgumen
throw IllegalArgumentException("Parent window is null", *this, 1 );
}
- m_aInitParameters.assign( aArguments );
Construct( pParentWin );
ODataView* pView = getView();
@@ -258,7 +214,7 @@ void SAL_CALL OGenericUnoController::initialize( const Sequence< Any >& aArgumen
if ( m_bReadOnly || m_bPreview )
pView->EnableInput( false );
- impl_initialize();
+ impl_initialize(::comphelper::NamedValueCollection(aArguments));
}
catch(Exception&)
{
@@ -372,11 +328,11 @@ namespace
// #i68216# is the bug which requests to fix the code in Draw which relies on
// framework's implementation details
if ( !!_rFeatureState.sTitle )
- _out_rStates.push_back( makeAny( *_rFeatureState.sTitle ) );
- if ( !!_rFeatureState.bChecked )
- _out_rStates.push_back( makeAny( *_rFeatureState.bChecked ) );
- if ( !!_rFeatureState.bInvisible )
- _out_rStates.push_back( makeAny( Visibility( !*_rFeatureState.bInvisible ) ) );
+ _out_rStates.push_back( Any( *_rFeatureState.sTitle ) );
+ if ( _rFeatureState.bChecked.has_value() )
+ _out_rStates.push_back( Any( *_rFeatureState.bChecked ) );
+ if ( _rFeatureState.bInvisible.has_value() )
+ _out_rStates.push_back( Any( Visibility( !*_rFeatureState.bInvisible ) ) );
if ( _rFeatureState.aValue.hasValue() )
_out_rStates.push_back( _rFeatureState.aValue );
if ( _out_rStates.empty() )
@@ -431,7 +387,7 @@ void OGenericUnoController::ImplBroadcastFeatureState(const OUString& _rFeature,
// it is possible that listeners are registered or revoked while
// we are notifying them, so we must use a copy of m_arrStatusListener, not
// m_arrStatusListener itself
- Dispatch aNotifyLoop( m_arrStatusListener );
+ std::vector<DispatchTarget> aNotifyLoop( m_arrStatusListener );
for (auto const& elem : aNotifyLoop)
{
@@ -461,7 +417,7 @@ void OGenericUnoController::InvalidateFeature_Impl()
bool bEmpty = true;
FeatureListener aNextFeature;
{
- ::osl::MutexGuard aGuard( m_aFeatureMutex);
+ std::unique_lock aGuard( m_aFeatureMutex);
bEmpty = m_aFeaturesToInvalidate.empty();
if (!bEmpty)
aNextFeature = m_aFeaturesToInvalidate.front();
@@ -494,7 +450,7 @@ void OGenericUnoController::InvalidateFeature_Impl()
ImplBroadcastFeatureState( aFeaturePos->first, aNextFeature.xListener, aNextFeature.bForceBroadcast );
}
- ::osl::MutexGuard aGuard( m_aFeatureMutex);
+ std::unique_lock aGuard( m_aFeatureMutex);
m_aFeaturesToInvalidate.pop_front();
bEmpty = m_aFeaturesToInvalidate.empty();
if (!bEmpty)
@@ -523,7 +479,7 @@ void OGenericUnoController::ImplInvalidateFeature( sal_Int32 _nId, const Referen
bool bWasEmpty;
{
- ::osl::MutexGuard aGuard( m_aFeatureMutex );
+ std::unique_lock aGuard( m_aFeatureMutex );
bWasEmpty = m_aFeaturesToInvalidate.empty();
m_aFeaturesToInvalidate.push_back( aListener );
}
@@ -549,7 +505,7 @@ void OGenericUnoController::InvalidateAll_Impl()
ImplBroadcastFeatureState( supportedFeature.first, nullptr, true );
{
- ::osl::MutexGuard aGuard( m_aFeatureMutex);
+ std::unique_lock aGuard( m_aFeatureMutex);
OSL_ENSURE(m_aFeaturesToInvalidate.size(), "OGenericUnoController::InvalidateAll_Impl: to be called from within InvalidateFeature_Impl only!");
m_aFeaturesToInvalidate.pop_front();
if(!m_aFeaturesToInvalidate.empty())
@@ -655,14 +611,12 @@ void OGenericUnoController::removeStatusListener(const Reference< XStatusListene
{
if (_rURL.Complete.isEmpty())
{
- m_arrStatusListener.erase(std::remove_if(m_arrStatusListener.begin(), m_arrStatusListener.end(),
- [&aListener](const DispatchTarget& rCurrent) { return rCurrent.xListener == aListener; }),
- m_arrStatusListener.end());
+ std::erase_if(m_arrStatusListener, [&aListener](const DispatchTarget& rCurrent) { return rCurrent.xListener == aListener; });
}
else
{
// remove the listener only for the given URL
- Dispatch::iterator iterSearch = std::find_if(m_arrStatusListener.begin(), m_arrStatusListener.end(),
+ auto iterSearch = std::find_if(m_arrStatusListener.begin(), m_arrStatusListener.end(),
[&aListener, &_rURL](const DispatchTarget& rCurrent) {
return (rCurrent.xListener == aListener) && (rCurrent.aURL.Complete == _rURL.Complete); });
if (iterSearch != m_arrStatusListener.end())
@@ -676,18 +630,14 @@ void OGenericUnoController::removeStatusListener(const Reference< XStatusListene
SupportedFeatures::const_iterator aIter = m_aSupportedFeatures.find(_rURL.Complete);
if (aIter != m_aSupportedFeatures.end())
{ // clear the cache for that feature
- StateCache::const_iterator aCachePos = m_aStateCache.find( aIter->second.nFeatureId );
+ auto aCachePos = m_aStateCache.find( aIter->second.nFeatureId );
if ( aCachePos != m_aStateCache.end() )
m_aStateCache.erase( aCachePos );
}
// now remove the listener from the deque
- ::osl::MutexGuard aGuard( m_aFeatureMutex );
- m_aFeaturesToInvalidate.erase(
- std::remove_if( m_aFeaturesToInvalidate.begin(),
- m_aFeaturesToInvalidate.end(),
- FindFeatureListener(aListener))
- ,m_aFeaturesToInvalidate.end());
+ std::unique_lock aGuard( m_aFeatureMutex );
+ std::erase_if( m_aFeaturesToInvalidate, FindFeatureListener(aListener));
}
void OGenericUnoController::releaseNumberForComponent()
@@ -709,7 +659,7 @@ void OGenericUnoController::disposing()
{
EventObject aDisposeEvent;
aDisposeEvent.Source = static_cast<XWeak*>(this);
- Dispatch aStatusListener = m_arrStatusListener;
+ std::vector<DispatchTarget> aStatusListener = m_arrStatusListener;
for (auto const& statusListener : aStatusListener)
{
statusListener.xListener->disposing(aDisposeEvent);
@@ -719,7 +669,7 @@ void OGenericUnoController::disposing()
m_xDatabaseContext = nullptr;
{
- ::osl::MutexGuard aGuard( m_aFeatureMutex);
+ std::unique_lock aGuard( m_aFeatureMutex);
m_aAsyncInvalidateAll.CancelCall();
m_aFeaturesToInvalidate.clear();
}
@@ -735,7 +685,6 @@ void OGenericUnoController::disposing()
m_xSlaveDispatcher = nullptr;
m_xTitleHelper.clear();
m_xUrlTransformer.clear();
- m_aInitParameters.clear();
}
void SAL_CALL OGenericUnoController::addEventListener( const Reference< XEventListener >& xListener )
@@ -757,16 +706,17 @@ void OGenericUnoController::frameAction(const FrameActionEvent& aEvent)
m_aCurrentFrame.frameAction( aEvent.Action );
}
-void OGenericUnoController::implDescribeSupportedFeature( const char* _pAsciiCommandURL,
+void OGenericUnoController::implDescribeSupportedFeature( const OUString& _rCommandURL,
sal_uInt16 _nFeatureId, sal_Int16 _nCommandGroup )
{
#ifdef DBG_UTIL
OSL_ENSURE( m_bDescribingSupportedFeatures, "OGenericUnoController::implDescribeSupportedFeature: bad timing for this call!" );
#endif
- OSL_PRECOND( _nFeatureId < FIRST_USER_DEFINED_FEATURE, "OGenericUnoController::implDescribeSupportedFeature: invalid feature id!" );
+ OSL_PRECOND( _nFeatureId < ( std::numeric_limits< sal_uInt16 >::max() - 1000 ), // FIRST_USER_DEFINED_FEATURE
+ "OGenericUnoController::implDescribeSupportedFeature: invalid feature id!" );
ControllerFeature aFeature;
- aFeature.Command = OUString::createFromAscii( _pAsciiCommandURL );
+ aFeature.Command = _rCommandURL;
aFeature.nFeatureId = _nFeatureId;
aFeature.GroupId = _nCommandGroup;
@@ -816,7 +766,7 @@ void OGenericUnoController::Execute( sal_uInt16 _nId, const Sequence< PropertyVa
// user defined features can be handled by dispatch interceptors resp. protocol handlers only.
// So, we need to do a queryDispatch, and dispatch the URL
- m_pData->m_aUserDefinedFeatures.execute( getURLForId( _nId ), _rArgs );
+ executeUserDefinedFeatures( getURLForId( _nId ), _rArgs );
}
URL OGenericUnoController::getURLForId(sal_Int32 _nId) const
@@ -841,7 +791,11 @@ URL OGenericUnoController::getURLForId(sal_Int32 _nId) const
bool OGenericUnoController::isUserDefinedFeature( const sal_uInt16 _nFeatureId )
{
- return ( _nFeatureId >= FIRST_USER_DEFINED_FEATURE ) && ( _nFeatureId < LAST_USER_DEFINED_FEATURE );
+ return
+ (_nFeatureId >= ( std::numeric_limits< sal_uInt16 >::max() - 1000 )) // test if >= FIRST_USER_DEFINED_FEATURE
+ &&
+ ( _nFeatureId < (std::numeric_limits< sal_uInt16 >::max())) // test if < LAST_USER_DEFINED_FEATURE
+ ;
}
bool OGenericUnoController::isUserDefinedFeature( const OUString& _rFeatureURL ) const
@@ -1047,21 +1001,16 @@ Reference< awt::XWindow> OGenericUnoController::getTopMostContainerWindow() cons
return xWindow;
}
-Reference< XTitle > OGenericUnoController::impl_getTitleHelper_throw()
+Reference< XTitle > OGenericUnoController::impl_getTitleHelper_throw(bool bCreateIfNecessary)
{
SolarMutexGuard aSolarGuard;
::osl::MutexGuard aGuard( getMutex() );
- if ( ! m_xTitleHelper.is ())
+ if (!m_xTitleHelper.is() && bCreateIfNecessary)
{
Reference< XUntitledNumbers > xUntitledProvider(getPrivateModel(), UNO_QUERY );
- Reference< XController > xThis(static_cast< XController* >(this), UNO_QUERY_THROW);
-
- rtl::Reference<::framework::TitleHelper> pHelper = new ::framework::TitleHelper( m_xContext );
- m_xTitleHelper = pHelper;
- pHelper->setOwner (xThis );
- pHelper->connectWithUntitledNumbers (xUntitledProvider);
+ m_xTitleHelper = new ::framework::TitleHelper( m_xContext, Reference< XController >(this), xUntitledProvider );
}
return m_xTitleHelper;
@@ -1095,7 +1044,7 @@ void SAL_CALL OGenericUnoController::addTitleChangeListener(const Reference< XTi
void SAL_CALL OGenericUnoController::removeTitleChangeListener(const Reference< XTitleChangeListener >& xListener)
{
- Reference< XTitleChangeBroadcaster > xBroadcaster(impl_getTitleHelper_throw(), UNO_QUERY);
+ Reference< XTitleChangeBroadcaster > xBroadcaster(impl_getTitleHelper_throw(false), UNO_QUERY);
if (xBroadcaster.is ())
xBroadcaster->removeTitleChangeListener (xListener);
}
@@ -1104,23 +1053,23 @@ void SAL_CALL OGenericUnoController::removeTitleChangeListener(const Reference<
void SAL_CALL OGenericUnoController::addKeyHandler( const Reference< XKeyHandler >& _rxHandler )
{
if ( _rxHandler.is() )
- m_pData->m_aUserInputInterception.addKeyHandler( _rxHandler );
+ m_aUserInputInterception.addKeyHandler( _rxHandler );
}
void SAL_CALL OGenericUnoController::removeKeyHandler( const Reference< XKeyHandler >& _rxHandler )
{
- m_pData->m_aUserInputInterception.removeKeyHandler( _rxHandler );
+ m_aUserInputInterception.removeKeyHandler( _rxHandler );
}
void SAL_CALL OGenericUnoController::addMouseClickHandler( const Reference< XMouseClickHandler >& _rxHandler )
{
if ( _rxHandler.is() )
- m_pData->m_aUserInputInterception.addMouseClickHandler( _rxHandler );
+ m_aUserInputInterception.addMouseClickHandler( _rxHandler );
}
void SAL_CALL OGenericUnoController::removeMouseClickHandler( const Reference< XMouseClickHandler >& _rxHandler )
{
- m_pData->m_aUserInputInterception.removeMouseClickHandler( _rxHandler );
+ m_aUserInputInterception.removeMouseClickHandler( _rxHandler );
}
void OGenericUnoController::executeChecked(sal_uInt16 _nCommandId, const Sequence< PropertyValue >& aArgs)
@@ -1146,14 +1095,14 @@ Reference< XController > OGenericUnoController::getXController()
bool OGenericUnoController::interceptUserInput( const NotifyEvent& _rEvent )
{
- return m_pData->m_aUserInputInterception.handleNotifyEvent( _rEvent );
+ return m_aUserInputInterception.handleNotifyEvent( _rEvent );
}
bool OGenericUnoController::isCommandChecked(sal_uInt16 _nCommandId) const
{
FeatureState aState = GetState( _nCommandId );
- return aState.bChecked && *aState.bChecked;
+ return aState.bChecked.has_value() && *aState.bChecked;
}
bool OGenericUnoController::isCommandEnabled( const OUString& _rCompleteCommandURL ) const
@@ -1207,6 +1156,11 @@ void SAL_CALL OGenericUnoController::dispose()
{
SolarMutexGuard aSolarGuard;
OGenericUnoController_Base::dispose();
+ m_xUrlTransformer.clear();
+ m_xSlaveDispatcher.clear();
+ m_xMasterDispatcher.clear();
+ m_xDatabaseContext.clear();
+ m_xTitleHelper.clear();
}
weld::Window* OGenericUnoController::getFrameWeld() const