diff options
author | Caolán McNamara <caolanm@redhat.com> | 2019-11-04 13:06:04 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2019-12-09 13:28:35 +0100 |
commit | 1efeb17837c22499f00299c033ae59ba3910f7d7 (patch) | |
tree | a8db0b758e942b3b14fba26129dc51a95ff5c10c /svx/source | |
parent | 4da3e0a0e5b2260c26186890724978bfd00f796c (diff) |
weld Property Browser
Replaced the odd HyperlinkField Edit whose text can be clicked on to activate
listeners, with an ordinary Edit and a Button beside it which can be clicked
instead to do that. I couldn't find a real world use of this HyperlinkField in
the forms or control properties, nor in casual experimentation in the sidebar
in the basicide dialog editor.
Also replaced the other strange Edit-alike TextView with a real Edit entry and
a dropdown which can be used to support entry of multi-line labels
Change-Id: Iad5265e404f6de14c8e760d617dbad49cd6ddead
Reviewed-on: https://gerrit.libreoffice.org/82213
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'svx/source')
-rw-r--r-- | svx/source/form/fmPropBrw.cxx | 162 | ||||
-rw-r--r-- | svx/source/inc/fmPropBrw.hxx | 23 |
2 files changed, 43 insertions, 142 deletions
diff --git a/svx/source/form/fmPropBrw.cxx b/svx/source/form/fmPropBrw.cxx index 61f9c7468f54..e7fdd4f99330 100644 --- a/svx/source/form/fmPropBrw.cxx +++ b/svx/source/form/fmPropBrw.cxx @@ -35,7 +35,6 @@ #include <svx/svdpagv.hxx> #include <svx/svxids.hrc> -#include <com/sun/star/awt/XLayoutConstrains.hpp> #include <com/sun/star/awt/XControlContainer.hpp> #include <com/sun/star/awt/PosSize.hpp> #include <com/sun/star/beans/PropertyValue.hpp> @@ -65,7 +64,9 @@ #include <tools/diagnose_ex.h> #include <unotools/confignode.hxx> #include <vcl/stdtext.hxx> +#include <vcl/svapp.hxx> #include <vcl/weld.hxx> +#include <vcl/weldutils.hxx> #include <algorithm> @@ -83,27 +84,16 @@ using namespace ::svxform; using ::com::sun::star::awt::XWindow; //= FmPropBrwMgr - - -SFX_IMPL_FLOATINGWINDOW(FmPropBrwMgr, SID_FM_SHOW_PROPERTIES) - +SFX_IMPL_MODELESSDIALOGCONTOLLER(FmPropBrwMgr, SID_FM_SHOW_PROPERTIES) FmPropBrwMgr::FmPropBrwMgr( vcl::Window* _pParent, sal_uInt16 _nId, SfxBindings* _pBindings, SfxChildWinInfo* _pInfo) :SfxChildWindow(_pParent, _nId) { - SetWindow( VclPtr<FmPropBrw>::Create( ::comphelper::getProcessComponentContext(), _pBindings, this, _pParent, _pInfo ) ); - static_cast<SfxFloatingWindow*>(GetWindow())->Initialize( _pInfo ); + SetController(std::make_shared<FmPropBrw>(::comphelper::getProcessComponentContext(), _pBindings, this, _pParent->GetFrameWeld(), _pInfo)); + static_cast<FmPropBrw*>(GetController().get())->Initialize( _pInfo ); } - -const long STD_WIN_SIZE_X = 300; -const long STD_WIN_SIZE_Y = 350; - -const long STD_MIN_SIZE_X = 250; -const long STD_MIN_SIZE_Y = 250; - - static OUString GetUIHeadlineName(sal_Int16 nClassId, const Any& aUnoObj) { const char* pClassNameResourceId = nullptr; @@ -183,79 +173,46 @@ static OUString GetUIHeadlineName(sal_Int16 nClassId, const Any& aUnoObj) return SvxResId(pClassNameResourceId); } -FmPropBrw::FmPropBrw( const Reference< XComponentContext >& _xORB, SfxBindings* _pBindings, - SfxChildWindow* _pMgr, vcl::Window* _pParent, const SfxChildWinInfo* _pInfo ) - :SfxFloatingWindow(_pBindings, _pMgr, _pParent, WinBits(WB_STDMODELESS|WB_SIZEABLE|WB_3DLOOK|WB_ROLLABLE) ) - ,SfxControllerItem(SID_FM_PROPERTY_CONTROL, *_pBindings) - ,m_bInitialStateChange(true) - ,m_xORB(_xORB) +FmPropBrw::FmPropBrw(const Reference< XComponentContext >& _xORB, SfxBindings* _pBindings, + SfxChildWindow* _pMgr, weld::Window* _pParent, const SfxChildWinInfo* _pInfo) + : SfxModelessDialogController(_pBindings, _pMgr, _pParent, "svx/ui/formpropertydialog.ui", "FormPropertyDialog") + , SfxControllerItem(SID_FM_PROPERTY_CONTROL, *_pBindings) + , m_bInitialStateChange(true) + , m_pParent(_pParent) + , m_nAsyncGetFocusId(nullptr) + , m_xContainer(m_xBuilder->weld_container("container")) + , m_xORB(_xORB) { - - ::Size aPropWinSize(STD_WIN_SIZE_X,STD_WIN_SIZE_Y); - SetMinOutputSizePixel(::Size(STD_MIN_SIZE_X,STD_MIN_SIZE_Y)); - SetOutputSizePixel(aPropWinSize); + m_xContainer->set_size_request(m_xContainer->get_approximate_digit_width() * 72, m_xContainer->get_text_height() * 20); try { // create a frame wrapper for myself m_xMeAsFrame = Frame::create(m_xORB); - // create an intermediate window, which is to be the container window of the frame - // Do *not* use |this| as container window for the frame, this would result in undefined - // responsibility for this window (as soon as we initialize a frame with a window, the frame - // is responsible for its life time, but |this| is controlled by the belonging SfxChildWindow) - // #i34249# - VclPtr<vcl::Window> pContainerWindow = VclPtr<vcl::Window>::Create( this ); - pContainerWindow->Show(); - m_xFrameContainerWindow = VCLUnoHelper::GetInterface ( pContainerWindow ); - - m_xMeAsFrame->initialize( m_xFrameContainerWindow ); + // transport the container area of this dialog to be the container window of the frame + css::uno::Reference<css::awt::XWindow> xFrameContainerWindow(new weld::TransportAsXWindow(m_xContainer.get())); + m_xMeAsFrame->initialize(xFrameContainerWindow); m_xMeAsFrame->setName("form property browser"); } - catch (Exception&) + catch (const Exception&) { OSL_FAIL("FmPropBrw::FmPropBrw: could not create/initialize my frame!"); m_xMeAsFrame.clear(); } - if (m_xMeAsFrame.is()) - _pMgr->SetFrame( Reference<XFrame>(m_xMeAsFrame,UNO_QUERY_THROW) ); - - - if ( m_xBrowserComponentWindow.is() ) - m_xBrowserComponentWindow->setVisible( true ); - if ( _pInfo ) m_sLastActivePage = _pInfo->aExtraString; } - -void FmPropBrw::Resize() +FmPropBrw::~FmPropBrw() { - SfxFloatingWindow::Resize(); - - if ( m_xFrameContainerWindow.is() ) + if (m_nAsyncGetFocusId) { - try - { - ::Size aOutputSize( GetOutputSizePixel() ); - m_xFrameContainerWindow->setPosSize( 0, 0, aOutputSize.Width(), aOutputSize.Height(), awt::PosSize::POSSIZE ); - } - catch( const Exception& ) - { - OSL_FAIL( "FmPropBrw::Resize: caught an exception!" ); - } + Application::RemoveUserEvent(m_nAsyncGetFocusId); + m_nAsyncGetFocusId = nullptr; } -} - -FmPropBrw::~FmPropBrw() -{ - disposeOnce(); -} - -void FmPropBrw::dispose() -{ if (m_xBrowserController.is()) implDetachController(); try @@ -279,10 +236,8 @@ void FmPropBrw::dispose() DBG_UNHANDLED_EXCEPTION("svx"); } ::SfxControllerItem::dispose(); - SfxFloatingWindow::dispose(); } - OUString FmPropBrw::getCurrentPage() const { OUString sCurrentPage; @@ -303,7 +258,6 @@ OUString FmPropBrw::getCurrentPage() const return sCurrentPage; } - void FmPropBrw::implDetachController() { m_sLastActivePage = getCurrentPage(); @@ -324,15 +278,16 @@ void FmPropBrw::implDetachController() // we attached a frame to the controller manually, so we need to manually tell it that it's detached, too if ( m_xBrowserController.is() ) + { m_xBrowserController->attachFrame( nullptr ); + } m_xBrowserController.clear(); m_xInspectorModel.clear(); m_xMeAsFrame.clear(); } - -bool FmPropBrw::Close() +void FmPropBrw::Close() { // suspend the controller (it is allowed to veto) if ( m_xMeAsFrame.is() ) @@ -341,7 +296,7 @@ bool FmPropBrw::Close() { Reference< XController > xController( m_xMeAsFrame->getController() ); if ( xController.is() && !xController->suspend( true ) ) - return false; + return; } catch( const Exception& ) { @@ -351,26 +306,17 @@ bool FmPropBrw::Close() implDetachController(); - if( IsRollUp() ) - RollDown(); - // remember our bindings: while we're closed, we're deleted, too, so accessing the bindings after this // would be deadly // 10/19/00 - 79321 - FS SfxBindings& rBindings = SfxControllerItem::GetBindings(); - bool bClose = SfxFloatingWindow::Close(); - - if (bClose) - { - rBindings.Invalidate(SID_FM_CTL_PROPERTIES); - rBindings.Invalidate(SID_FM_PROPERTIES); - } + SfxModelessDialogController::Close(); - return bClose; + rBindings.Invalidate(SID_FM_CTL_PROPERTIES); + rBindings.Invalidate(SID_FM_PROPERTIES); } - bool FmPropBrw::implIsReadOnlyModel() const { try @@ -439,55 +385,21 @@ void FmPropBrw::implSetNewSelection( const InterfaceBag& _rSelection ) if ( implIsReadOnlyModel() ) sTitle += SvxResId(RID_STR_READONLY_VIEW); - SetText( sTitle ); - - Reference< css::awt::XLayoutConstrains > xLayoutConstrains( m_xBrowserController, UNO_QUERY ); - if( xLayoutConstrains.is() ) - { - ::Size aConstrainedSize; - css::awt::Size aMinSize = xLayoutConstrains->getMinimumSize(); - - sal_Int32 nLeft(0), nTop(0), nRight(0), nBottom(0); - GetBorder( nLeft, nTop, nRight, nBottom ); - aMinSize.Width += nLeft + nRight + 8; - aMinSize.Height += nTop + nBottom + 8; - - aConstrainedSize.setHeight( aMinSize.Height ); - aConstrainedSize.setWidth( aMinSize.Width ); - SetMinOutputSizePixel( aConstrainedSize ); - aConstrainedSize = GetOutputSizePixel(); - bool bResize = false; - if( aConstrainedSize.Width() < aMinSize.Width ) - { - aConstrainedSize.setWidth( aMinSize.Width ); - bResize = true; - } - if( aConstrainedSize.Height() < aMinSize.Height ) - { - aConstrainedSize.setHeight( aMinSize.Height ); - bResize = true; - } - if( bResize ) - SetOutputSizePixel( aConstrainedSize ); - } + m_xDialog->set_title(sTitle); } } - void FmPropBrw::FillInfo( SfxChildWinInfo& rInfo ) const { rInfo.bVisible = false; rInfo.aExtraString = getCurrentPage(); } - IMPL_LINK_NOARG( FmPropBrw, OnAsyncGetFocus, void*, void ) { - if (m_xBrowserComponentWindow.is()) - m_xBrowserComponentWindow->setFocus(); + m_nAsyncGetFocusId = nullptr; } - namespace { bool lcl_shouldEnableHelpSection( const Reference< XComponentContext >& _rxContext ) @@ -528,7 +440,7 @@ void FmPropBrw::impl_createPropertyBrowser_throw( FmFormShell* _pFormShell ) } // the default parent window for message boxes - Reference< XWindow > xParentWindow( VCLUnoHelper::GetInterface ( this ) ); + Reference< XWindow > xParentWindow(m_xDialog->GetXWindow()); // the mapping from control models to control shapes Reference< XMap > xControlMap; @@ -566,14 +478,11 @@ void FmPropBrw::impl_createPropertyBrowser_throw( FmFormShell* _pFormShell ) if ( !m_xBrowserController.is() ) { - vcl::Window *pWin = GetParent(); - ShowServiceNotAvailableError(pWin ? pWin->GetFrameWeld() : nullptr, "com.sun.star.inspection.ObjectInspector", true); + ShowServiceNotAvailableError(m_pParent, "com.sun.star.inspection.ObjectInspector", true); } else { m_xBrowserController->attachFrame( Reference<XFrame>(m_xMeAsFrame,UNO_QUERY_THROW) ); - m_xBrowserComponentWindow = m_xMeAsFrame->getComponentWindow(); - DBG_ASSERT( m_xBrowserComponentWindow.is(), "FmPropBrw::impl_createPropertyBrowser_throw: attached the controller, but have no component window!" ); } if ( bEnableHelpSection ) @@ -605,7 +514,6 @@ void FmPropBrw::impl_ensurePropertyBrowser_nothrow( FmFormShell* _pFormShell ) ::comphelper::disposeComponent( m_xBrowserController ); m_xBrowserController.clear(); m_xInspectorModel.clear(); - m_xBrowserComponentWindow.clear(); // and create a new one impl_createPropertyBrowser_throw( _pFormShell ); @@ -641,7 +549,7 @@ void FmPropBrw::StateChanged(sal_uInt16 nSID, SfxItemState eState, const SfxPool if ( m_bInitialStateChange ) { // if we're just newly created, we want to have the focus - PostUserEvent( LINK( this, FmPropBrw, OnAsyncGetFocus ), nullptr, true ); + m_nAsyncGetFocusId = Application::PostUserEvent(LINK(this, FmPropBrw, OnAsyncGetFocus)); // and additionally, we want to show the page which was active during // our previous incarnation diff --git a/svx/source/inc/fmPropBrw.hxx b/svx/source/inc/fmPropBrw.hxx index 34315d9c7a49..1d856b96a2fd 100644 --- a/svx/source/inc/fmPropBrw.hxx +++ b/svx/source/inc/fmPropBrw.hxx @@ -40,10 +40,13 @@ public: class SfxBindings; class FmFormShell; -class FmPropBrw final : public SfxFloatingWindow, public SfxControllerItem +class FmPropBrw final : public SfxModelessDialogController, public SfxControllerItem { bool m_bInitialStateChange; + weld::Window* m_pParent; + ImplSVEvent* m_nAsyncGetFocusId; OUString m_sLastActivePage; + std::unique_ptr<weld::Container> m_xContainer; css::uno::Reference< css::uno::XComponentContext > m_xInspectorContext; css::uno::Reference< css::uno::XComponentContext > @@ -56,14 +59,10 @@ class FmPropBrw final : public SfxFloatingWindow, public SfxControllerItem m_xInspectorModel; css::uno::Reference< css::frame::XController > m_xBrowserController; - css::uno::Reference< css::awt::XWindow > - m_xBrowserComponentWindow; - css::uno::Reference< css::awt::XWindow > - m_xFrameContainerWindow; virtual void StateChanged(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState) override; virtual void FillInfo( SfxChildWinInfo& rInfo ) const override; - virtual bool Close() override; + virtual void Close() override; DECL_LINK( OnAsyncGetFocus, void*, void ); @@ -77,16 +76,12 @@ public: const css::uno::Reference< css::uno::XComponentContext >& _xORB, SfxBindings* pBindings, SfxChildWindow* pMgr, - vcl::Window* pParent, + weld::Window* pParent, const SfxChildWinInfo* _pInfo ); virtual ~FmPropBrw() override; - virtual void dispose() override; - - using SfxFloatingWindow::StateChanged; private: - virtual void Resize() override; /** creates the PropertyBrowser (aka ObjectInspector) and plugs it into our frame @@ -98,12 +93,10 @@ private: /** creates a property browser - After this method returns, m_xBrowserController and m_xBrowserComponentWindow are - not <NULL/>. + After this method returns, m_xBrowserController is not <NULL/>. @precond - we don't have an ObjectInspector, yet, i.e. m_xBrowserController and m_xBrowserComponentWindow - are <NULL/>. + we don't have an ObjectInspector, yet, i.e. m_xBrowserController is <NULL/>. */ void impl_createPropertyBrowser_throw( FmFormShell* _pFormShell ); }; |