diff options
Diffstat (limited to 'framework/source/services/frame.cxx')
-rw-r--r-- | framework/source/services/frame.cxx | 103 |
1 files changed, 52 insertions, 51 deletions
diff --git a/framework/source/services/frame.cxx b/framework/source/services/frame.cxx index db26f59aec0b..0cbc1ca68f9d 100644 --- a/framework/source/services/frame.cxx +++ b/framework/source/services/frame.cxx @@ -37,7 +37,6 @@ #include <pattern/window.hxx> #include <properties.h> -#include <stdtypes.h> #include <targets.h> #include <com/sun/star/awt/Toolkit.hpp> @@ -68,9 +67,11 @@ #include <cppuhelper/basemutex.hxx> #include <cppuhelper/compbase.hxx> +#include <comphelper/multiinterfacecontainer3.hxx> #include <comphelper/multicontainer2.hxx> #include <cppuhelper/supportsservice.hxx> #include <cppuhelper/weak.hxx> +#include <rtl/ref.hxx> #include <sal/log.hxx> #include <vcl/window.hxx> #include <vcl/wrkwin.hxx> @@ -78,9 +79,10 @@ #include <toolkit/helper/vclunohelper.hxx> #include <unotools/moduleoptions.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <unotools/cmdoptions.hxx> #include <vcl/threadex.hxx> +#include <mutex> using namespace framework; @@ -112,7 +114,7 @@ class XFrameImpl: { public: - explicit XFrameImpl(const css::uno::Reference< css::uno::XComponentContext >& xContext); + explicit XFrameImpl(css::uno::Reference< css::uno::XComponentContext > xContext); /// Initialization function after having acquire()'d. void initListeners(); @@ -352,7 +354,7 @@ private: // non threadsafe void impl_checkMenuCloser ( ); - void impl_setCloser ( const css::uno::Reference< css::frame::XFrame2 >& xFrame , bool bState ); + static void impl_setCloser ( const css::uno::Reference< css::frame::XFrame2 >& xFrame , bool bState ); void disableLayoutManager(const css::uno::Reference< css::frame::XLayoutManager2 >& xLayoutManager); @@ -373,7 +375,7 @@ private: /// points to an external set progress, which should be used instead of the internal one. css::uno::WeakReference< css::task::XStatusIndicator > m_xIndicatorInterception; /// helper for XDispatch/Provider and interception interfaces - css::uno::Reference< css::frame::XDispatchProvider > m_xDispatchHelper; + rtl::Reference< InterceptionHelper > m_xDispatchHelper; /// helper for XFrames, XIndexAccess and XElementAccess interfaces css::uno::Reference< css::frame::XFrames > m_xFramesHelper; /// container for ALL Listener @@ -417,8 +419,8 @@ private: typedef std::unordered_map<OUString, css::beans::Property> TPropInfoHash; TPropInfoHash m_lProps; - ListenerHash m_lSimpleChangeListener; - ListenerHash m_lVetoChangeListener; + comphelper::OMultiTypeInterfaceContainerHelperVar3<css::beans::XPropertyChangeListener, OUString> m_lSimpleChangeListener; + comphelper::OMultiTypeInterfaceContainerHelperVar3<css::beans::XVetoableChangeListener, OUString> m_lVetoChangeListener; // hold it weak ... otherwise this helper has to be "killed" explicitly .-) css::uno::WeakReference< css::uno::XInterface > m_xBroadcaster; @@ -451,10 +453,10 @@ private: The value must be different from NULL! @onerror ASSERT in debug version or nothing in release version. *//*-*****************************************************************************************************/ -XFrameImpl::XFrameImpl( const css::uno::Reference< css::uno::XComponentContext >& xContext ) +XFrameImpl::XFrameImpl( css::uno::Reference< css::uno::XComponentContext > xContext ) : PartialWeakComponentImplHelper(m_aMutex) // init member - , m_xContext ( xContext ) + , m_xContext (std::move( xContext )) , m_aListenerContainer ( m_aMutex ) , m_eActiveState ( E_INACTIVE ) , m_bIsFrameTop ( true ) // I think we are top without a parent ... and there is no parent yet! @@ -764,15 +766,14 @@ void SAL_CALL XFrameImpl::initialize( const css::uno::Reference< css::awt::XWind /* SAFE AREA ----------------------------------------------------------------------------------------------- */ SolarMutexResettableGuard aWriteLock; + // This must be the first call of this method! + // We should initialize our object and open it for working. if ( m_xContainerWindow.is() ) throw css::uno::RuntimeException( "XFrameImpl::initialized() is called more than once, which is not useful nor allowed.", static_cast< css::frame::XFrame* >(this)); - // This must be the first call of this method! - // We should initialize our object and open it for working. // Set the new window. - SAL_WARN_IF( m_xContainerWindow.is(), "fwk.frame", "XFrameImpl::initialize(): Leak detected! This state should never occur ..." ); m_xContainerWindow = xWindow; // if window is initially visible, we will never get a windowShowing event @@ -798,17 +799,18 @@ void SAL_CALL XFrameImpl::initialize( const css::uno::Reference< css::awt::XWind lcl_enableLayoutManager(xLayoutManager, this); // create progress helper - css::uno::Reference< css::frame::XFrame > xThis (static_cast< css::frame::XFrame* >(this), - css::uno::UNO_QUERY_THROW); - css::uno::Reference< css::task::XStatusIndicatorFactory > xIndicatorFactory = - css::task::StatusIndicatorFactory::createWithFrame(m_xContext, xThis, - false/*DisableReschedule*/, true/*AllowParentShow*/ ); + css::uno::Reference< css::frame::XFrame > xThis (this); + { + css::uno::Reference< css::task::XStatusIndicatorFactory > xIndicatorFactory = + css::task::StatusIndicatorFactory::createWithFrame(m_xContext, xThis, + false/*DisableReschedule*/, true/*AllowParentShow*/ ); - // SAFE -> ---------------------------------- - aWriteLock.reset(); - m_xIndicatorFactoryHelper = xIndicatorFactory; - aWriteLock.clear(); - // <- SAFE ---------------------------------- + // SAFE -> ---------------------------------- + aWriteLock.reset(); + m_xIndicatorFactoryHelper = std::move(xIndicatorFactory); + aWriteLock.clear(); + // <- SAFE ---------------------------------- + } // Start listening for events after setting it on helper class ... // So superfluous messages are filtered to NULL :-) @@ -817,9 +819,7 @@ void SAL_CALL XFrameImpl::initialize( const css::uno::Reference< css::awt::XWind m_pWindowCommandDispatch.reset(new WindowCommandDispatch(m_xContext, this)); // Initialize title functionality - rtl::Reference<TitleHelper> pTitleHelper = new TitleHelper( m_xContext ); - m_xTitleHelper = pTitleHelper; - pTitleHelper->setOwner(xThis); + m_xTitleHelper = new TitleHelper( m_xContext, xThis, nullptr ); } /*-**************************************************************************************************** @@ -1476,6 +1476,15 @@ sal_Bool SAL_CALL XFrameImpl::setComponent(const css::uno::Reference< css::awt:: { SolarMutexGuard aWriteLock; m_xController = nullptr; + + if (m_xDispatchHelper) + { + rtl::Reference<DispatchProvider> pDispatchProvider = m_xDispatchHelper->GetSlave(); + if (pDispatchProvider) + { + pDispatchProvider->ClearProtocolHandlers(); + } + } } /* } SAFE */ @@ -1850,9 +1859,7 @@ void SAL_CALL XFrameImpl::setLayoutManager(const css::uno::Reference<css::uno::X css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL XFrameImpl::getPropertySetInfo() { checkDisposed(); - css::uno::Reference< css::beans::XPropertySetInfo > xInfo( - static_cast< css::beans::XPropertySetInfo* >(this), css::uno::UNO_QUERY_THROW); - return xInfo; + return css::uno::Reference< css::beans::XPropertySetInfo >(this); } void SAL_CALL XFrameImpl::setPropertyValue(const OUString& sProperty, @@ -1989,10 +1996,10 @@ css::uno::Sequence< css::beans::Property > SAL_CALL XFrameImpl::getProperties() sal_Int32 c = static_cast<sal_Int32>(m_lProps.size()); css::uno::Sequence< css::beans::Property > lProps(c); - + auto lPropsRange = asNonConstRange(lProps); for (auto const& elem : m_lProps) { - lProps[--c] = elem.second; + lPropsRange[--c] = elem.second; } return lProps; @@ -2112,7 +2119,7 @@ void SAL_CALL XFrameImpl::disposing() css::uno::Reference< css::lang::XEventListener > xDispatchHelper; { SolarMutexGuard g; - xDispatchHelper.set(m_xDispatchHelper, css::uno::UNO_QUERY_THROW); + xDispatchHelper = m_xDispatchHelper; } xDispatchHelper->disposing(aEvent); xDispatchHelper.clear(); @@ -2308,7 +2315,7 @@ css::uno::Reference< css::frame::XDispatch > SAL_CALL XFrameImpl::queryDispatch( aCommand = aURL.Path; // Make std::unordered_map lookup if the current URL is in the disabled list - if ( m_aCommandOptions.Lookup( SvtCommandOptions::CMDOPTION_DISABLED, aCommand ) ) + if ( m_aCommandOptions.LookupDisabled( aCommand ) ) return css::uno::Reference< css::frame::XDispatch >(); else { @@ -2378,7 +2385,7 @@ void SAL_CALL XFrameImpl::registerDispatchProviderInterceptor( css::uno::Reference< css::frame::XDispatchProviderInterception > xInterceptionHelper; { SolarMutexGuard g; - xInterceptionHelper.set( m_xDispatchHelper, css::uno::UNO_QUERY ); + xInterceptionHelper = m_xDispatchHelper; } if (xInterceptionHelper.is()) { xInterceptionHelper->registerDispatchProviderInterceptor( xInterceptor ); @@ -2397,7 +2404,7 @@ void SAL_CALL XFrameImpl::releaseDispatchProviderInterceptor( css::uno::Reference< css::frame::XDispatchProviderInterception > xInterceptionHelper; { SolarMutexGuard g; - xInterceptionHelper.set( m_xDispatchHelper, css::uno::UNO_QUERY ); + xInterceptionHelper = m_xDispatchHelper; } if (xInterceptionHelper.is()) { xInterceptionHelper->releaseDispatchProviderInterceptor( xInterceptor ); @@ -2584,7 +2591,7 @@ void SAL_CALL XFrameImpl::windowClosing( const css::lang::EventObject& ) *//*-*****************************************************************************************************/ void SAL_CALL XFrameImpl::windowShown( const css::lang::EventObject& ) { - static osl::Mutex aFirstVisibleLock; + static std::mutex aFirstVisibleLock; /* SAFE { */ SolarMutexClearableGuard aReadLock; @@ -2599,10 +2606,10 @@ void SAL_CALL XFrameImpl::windowShown( const css::lang::EventObject& ) return; static bool bFirstVisibleTask = true; - osl::ClearableMutexGuard aGuard(aFirstVisibleLock); + std::unique_lock aGuard(aFirstVisibleLock); bool bMustBeTriggered = bFirstVisibleTask; bFirstVisibleTask = false; - aGuard.clear(); + aGuard.unlock(); if (bMustBeTriggered) { @@ -2863,19 +2870,16 @@ bool XFrameImpl::impl_existsVeto(const css::beans::PropertyChangeEvent& aEvent) The used helper is threadsafe and it lives for the whole lifetime of our own object. */ - ::comphelper::OInterfaceContainerHelper2* pVetoListener = m_lVetoChangeListener.getContainer(aEvent.PropertyName); + ::comphelper::OInterfaceContainerHelper3<css::beans::XVetoableChangeListener>* pVetoListener = m_lVetoChangeListener.getContainer(aEvent.PropertyName); if (! pVetoListener) return false; - ::comphelper::OInterfaceIteratorHelper2 pListener(*pVetoListener); + ::comphelper::OInterfaceIteratorHelper3 pListener(*pVetoListener); while (pListener.hasMoreElements()) { try { - css::uno::Reference< css::beans::XVetoableChangeListener > xListener( - static_cast<css::beans::XVetoableChangeListener*>(pListener.next()), - css::uno::UNO_QUERY_THROW); - xListener->vetoableChange(aEvent); + pListener.next()->vetoableChange(aEvent); } catch(const css::uno::RuntimeException&) { pListener.remove(); } @@ -2892,19 +2896,16 @@ void XFrameImpl::impl_notifyChangeListener(const css::beans::PropertyChangeEvent The used helper is threadsafe and it lives for the whole lifetime of our own object. */ - ::comphelper::OInterfaceContainerHelper2* pSimpleListener = m_lSimpleChangeListener.getContainer(aEvent.PropertyName); + ::comphelper::OInterfaceContainerHelper3<css::beans::XPropertyChangeListener>* pSimpleListener = m_lSimpleChangeListener.getContainer(aEvent.PropertyName); if (! pSimpleListener) return; - ::comphelper::OInterfaceIteratorHelper2 pListener(*pSimpleListener); + ::comphelper::OInterfaceIteratorHelper3 pListener(*pSimpleListener); while (pListener.hasMoreElements()) { try { - css::uno::Reference< css::beans::XPropertyChangeListener > xListener( - static_cast<css::beans::XVetoableChangeListener*>(pListener.next()), - css::uno::UNO_QUERY_THROW); - xListener->propertyChange(aEvent); + pListener.next()->propertyChange(aEvent); } catch(const css::uno::RuntimeException&) { pListener.remove(); } @@ -3212,7 +3213,7 @@ void XFrameImpl::implts_checkSuicide() @param bState <TRUE/> enable; <FALSE/> disable this state */ - +// static void XFrameImpl::impl_setCloser( /*IN*/ const css::uno::Reference< css::frame::XFrame2 >& xFrame , /*IN*/ bool bState ) { @@ -3226,7 +3227,7 @@ void XFrameImpl::impl_setCloser( /*IN*/ const css::uno::Reference< css::frame::X css::uno::Reference< css::frame::XLayoutManager > xLayoutManager; xFrameProps->getPropertyValue(FRAME_PROPNAME_ASCII_LAYOUTMANAGER) >>= xLayoutManager; css::uno::Reference< css::beans::XPropertySet > xLayoutProps(xLayoutManager, css::uno::UNO_QUERY_THROW); - xLayoutProps->setPropertyValue(LAYOUTMANAGER_PROPNAME_MENUBARCLOSER, css::uno::makeAny(bState)); + xLayoutProps->setPropertyValue(LAYOUTMANAGER_PROPNAME_MENUBARCLOSER, css::uno::Any(bState)); } catch(const css::uno::RuntimeException&) { throw; } |