From 23cf9370edf41c591ebb5acad372b5ce2395f68e Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 30 Apr 2018 11:55:31 +0100 Subject: weld SdSnapLineDlg MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I3a8117719525fa204f29cc10a944376116050d61 Reviewed-on: https://gerrit.libreoffice.org/53658 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- sd/source/ui/dlg/dlgsnap.cxx | 165 ++++++++++++++++++----------------------- sd/source/ui/dlg/sddlgfact.cxx | 20 +++-- sd/source/ui/dlg/sddlgfact.hxx | 11 ++- sd/source/ui/func/fusnapln.cxx | 3 +- sd/source/ui/inc/dlgsnap.hxx | 40 +++++----- 5 files changed, 112 insertions(+), 127 deletions(-) (limited to 'sd/source') diff --git a/sd/source/ui/dlg/dlgsnap.cxx b/sd/source/ui/dlg/dlgsnap.cxx index 58a893078aa1..40de52f786e0 100644 --- a/sd/source/ui/dlg/dlgsnap.cxx +++ b/sd/source/ui/dlg/dlgsnap.cxx @@ -30,32 +30,28 @@ /** * dialog to adjust grid (scarcely ESO!) */ -SdSnapLineDlg::SdSnapLineDlg( - vcl::Window* pWindow, - const SfxItemSet& rInAttrs, - ::sd::View const * pView) - : ModalDialog(pWindow, "SnapObjectDialog", "modules/sdraw/ui/dlgsnap.ui") +SdSnapLineDlg::SdSnapLineDlg(weld::Window* pWindow, const SfxItemSet& rInAttrs, ::sd::View const * pView) + : GenericDialogController(pWindow, "modules/sdraw/ui/dlgsnap.ui", "SnapObjectDialog") , eUIUnit(pView->GetDoc().GetUIUnit()) , aUIScale(pView->GetDoc().GetUIScale()) + , m_xFtX(m_xBuilder->weld_label("xlabel")) + , m_xMtrFldX(m_xBuilder->weld_metric_spin_button("x", FUNIT_CM)) + , m_xFtY(m_xBuilder->weld_label("ylabel")) + , m_xMtrFldY(m_xBuilder->weld_metric_spin_button("y", FUNIT_CM)) + , m_xRadioGroup(m_xBuilder->weld_widget("radiogroup")) + , m_xRbPoint(m_xBuilder->weld_radio_button("point")) + , m_xRbVert(m_xBuilder->weld_radio_button("vert")) + , m_xRbHorz(m_xBuilder->weld_radio_button("horz")) + , m_xBtnDelete(m_xBuilder->weld_button("delete")) { - get(m_pFtX, "xlabel"); - get(m_pMtrFldX, "x"); - get(m_pFtY, "ylabel"); - get(m_pMtrFldY, "y"); - get(m_pRadioGroup, "radiogroup"); - get(m_pRbPoint, "point"); - get(m_pRbVert, "vert"); - get(m_pRbHorz, "horz"); - get(m_pBtnDelete, "delete"); + m_xRbHorz->connect_clicked(LINK(this, SdSnapLineDlg, ClickHdl)); + m_xRbVert->connect_clicked(LINK(this, SdSnapLineDlg, ClickHdl)); + m_xRbPoint->connect_clicked(LINK(this, SdSnapLineDlg, ClickHdl)); - m_pRbHorz->SetClickHdl(LINK(this, SdSnapLineDlg, ClickHdl)); - m_pRbVert->SetClickHdl(LINK(this, SdSnapLineDlg, ClickHdl)); - m_pRbPoint->SetClickHdl(LINK(this, SdSnapLineDlg, ClickHdl)); + m_xBtnDelete->connect_clicked(LINK(this, SdSnapLineDlg, ClickHdl)); - m_pBtnDelete->SetClickHdl(LINK(this, SdSnapLineDlg, ClickHdl)); - - SetFieldUnit( *m_pMtrFldX, eUIUnit, true ); - SetFieldUnit( *m_pMtrFldY, eUIUnit, true ); + SetFieldUnit(*m_xMtrFldX, eUIUnit, true); + SetFieldUnit(*m_xMtrFldY, eUIUnit, true); // get WorkArea ::tools::Rectangle aWorkArea = pView->GetWorkArea(); @@ -74,70 +70,51 @@ SdSnapLineDlg::SdSnapLineDlg( // determine max and min values depending on // WorkArea, PoolUnit and FieldUnit: - SetMetricValue( *m_pMtrFldX, aLeftTop.X(), ePoolUnit ); - - long nValue = static_cast(m_pMtrFldX->GetValue()); - nValue = long( nValue / aUIScale); - m_pMtrFldX->SetMin( nValue ); - m_pMtrFldX->SetFirst( nValue ); - - SetMetricValue( *m_pMtrFldX, aRightBottom.X(), ePoolUnit ); - nValue = static_cast(m_pMtrFldX->GetValue()); - nValue = long( nValue / aUIScale); - m_pMtrFldX->SetMax( nValue ); - m_pMtrFldX->SetLast( nValue ); - - SetMetricValue( *m_pMtrFldY, aLeftTop.Y(), ePoolUnit ); - nValue = static_cast(m_pMtrFldY->GetValue()); - nValue = long( nValue / aUIScale); - m_pMtrFldY->SetMin( nValue ); - m_pMtrFldY->SetFirst( nValue ); - - SetMetricValue( *m_pMtrFldY, aRightBottom.Y(), ePoolUnit ); - nValue = static_cast(m_pMtrFldY->GetValue()); - nValue = long( nValue / aUIScale); - m_pMtrFldY->SetMax( nValue ); - m_pMtrFldY->SetLast( nValue ); + SetMetricValue(*m_xMtrFldX, aLeftTop.X(), ePoolUnit ); + + int nValue = m_xMtrFldX->get_value(FUNIT_NONE); + nValue = sal_Int32(nValue / aUIScale); + m_xMtrFldX->set_min(nValue, FUNIT_NONE); + + SetMetricValue(*m_xMtrFldX, aRightBottom.X(), ePoolUnit); + nValue = m_xMtrFldX->get_value(FUNIT_NONE); + nValue = sal_Int32(nValue / aUIScale); + m_xMtrFldX->set_max(nValue, FUNIT_NONE); + + SetMetricValue(*m_xMtrFldY, aLeftTop.Y(), ePoolUnit); + nValue = m_xMtrFldY->get_value(FUNIT_NONE); + nValue = sal_Int32(nValue / aUIScale); + m_xMtrFldY->set_min(nValue, FUNIT_NONE); + + SetMetricValue(*m_xMtrFldY, aRightBottom.Y(), ePoolUnit); + nValue = m_xMtrFldY->get_value(FUNIT_NONE); + nValue = sal_Int32(nValue / aUIScale); + m_xMtrFldY->set_max(nValue, FUNIT_NONE); // set values nXValue = static_cast( rInAttrs.Get(ATTR_SNAPLINE_X)).GetValue(); nYValue = static_cast( rInAttrs.Get(ATTR_SNAPLINE_Y)).GetValue(); - nXValue = long(nXValue / aUIScale); - nYValue = long(nYValue / aUIScale); - SetMetricValue( *m_pMtrFldX, nXValue, MapUnit::Map100thMM); - SetMetricValue( *m_pMtrFldY, nYValue, MapUnit::Map100thMM); + nXValue = sal_Int32(nXValue / aUIScale); + nYValue = sal_Int32(nYValue / aUIScale); + SetMetricValue(*m_xMtrFldX, nXValue, MapUnit::Map100thMM); + SetMetricValue(*m_xMtrFldY, nYValue, MapUnit::Map100thMM); - m_pRbPoint->Check(); + m_xRbPoint->set_active(true); } SdSnapLineDlg::~SdSnapLineDlg() { - disposeOnce(); -} - -void SdSnapLineDlg::dispose() -{ - m_pFtX.clear(); - m_pMtrFldX.clear(); - m_pFtY.clear(); - m_pMtrFldY.clear(); - m_pRadioGroup.clear(); - m_pRbPoint.clear(); - m_pRbVert.clear(); - m_pRbHorz.clear(); - m_pBtnDelete.clear(); - ModalDialog::dispose(); } /** * fills provided item sets with dialog box attributes */ -IMPL_LINK( SdSnapLineDlg, ClickHdl, Button *, pBtn, void ) +IMPL_LINK( SdSnapLineDlg, ClickHdl, weld::Button&, rBtn, void ) { - if ( pBtn == m_pRbPoint ) SetInputFields(true, true); - else if ( pBtn == m_pRbHorz ) SetInputFields(false, true); - else if ( pBtn == m_pRbVert ) SetInputFields(true, false); - else if ( pBtn == m_pBtnDelete ) EndDialog(RET_SNAP_DELETE); + if (&rBtn == m_xRbPoint.get()) SetInputFields(true, true); + else if (&rBtn == m_xRbHorz.get()) SetInputFields(false, true); + else if (&rBtn == m_xRbVert.get()) SetInputFields(true, false); + else if (&rBtn == m_xBtnDelete.get()) m_xDialog->response(RET_SNAP_DELETE); } /** @@ -147,12 +124,12 @@ void SdSnapLineDlg::GetAttr(SfxItemSet& rOutAttrs) { SnapKind eKind; - if ( m_pRbHorz->IsChecked() ) eKind = SK_HORIZONTAL; - else if ( m_pRbVert->IsChecked() ) eKind = SK_VERTICAL; - else eKind = SK_POINT; + if (m_xRbHorz->get_active()) eKind = SK_HORIZONTAL; + else if (m_xRbVert->get_active()) eKind = SK_VERTICAL; + else eKind = SK_POINT; - nXValue = long( GetCoreValue( *m_pMtrFldX, MapUnit::Map100thMM) * aUIScale); - nYValue = long( GetCoreValue( *m_pMtrFldY, MapUnit::Map100thMM) * aUIScale); + nXValue = sal_Int32(GetCoreValue(*m_xMtrFldX, MapUnit::Map100thMM) * aUIScale); + nYValue = sal_Int32(GetCoreValue(*m_xMtrFldY, MapUnit::Map100thMM) * aUIScale); rOutAttrs.Put(SfxAllEnumItem(ATTR_SNAPLINE_KIND, static_cast(eKind))); rOutAttrs.Put(SfxInt32Item(ATTR_SNAPLINE_X, nXValue)); @@ -161,7 +138,7 @@ void SdSnapLineDlg::GetAttr(SfxItemSet& rOutAttrs) void SdSnapLineDlg::HideRadioGroup() { - m_pRadioGroup->Hide(); + m_xRadioGroup->hide(); } /** @@ -171,31 +148,31 @@ void SdSnapLineDlg::SetInputFields(bool bEnableX, bool bEnableY) { if ( bEnableX ) { - if ( !m_pMtrFldX->IsEnabled() ) - m_pMtrFldX->SetValue(nXValue); - m_pMtrFldX->Enable(); - m_pFtX->Enable(); + if (!m_xMtrFldX->get_sensitive()) + m_xMtrFldX->set_value(nXValue, FUNIT_NONE); + m_xMtrFldX->set_sensitive(true); + m_xFtX->set_sensitive(true); } - else if ( m_pMtrFldX->IsEnabled() ) + else if (m_xMtrFldX->get_sensitive()) { - nXValue = static_cast(m_pMtrFldX->GetValue()); - m_pMtrFldX->SetText(OUString()); - m_pMtrFldX->Disable(); - m_pFtX->Disable(); + nXValue = m_xMtrFldX->get_value(FUNIT_NONE); + m_xMtrFldX->set_text(OUString()); + m_xMtrFldX->set_sensitive(false); + m_xFtX->set_sensitive(false); } if ( bEnableY ) { - if ( !m_pMtrFldY->IsEnabled() ) - m_pMtrFldY->SetValue(nYValue); - m_pMtrFldY->Enable(); - m_pFtY->Enable(); + if (!m_xMtrFldY->get_sensitive()) + m_xMtrFldY->set_value(nYValue, FUNIT_NONE); + m_xMtrFldY->set_sensitive(true); + m_xFtY->set_sensitive(true); } - else if ( m_pMtrFldY->IsEnabled() ) + else if (m_xMtrFldY->get_sensitive()) { - nYValue = static_cast(m_pMtrFldY->GetValue()); - m_pMtrFldY->SetText(OUString()); - m_pMtrFldY->Disable(); - m_pFtY->Disable(); + nYValue = m_xMtrFldY->get_value(FUNIT_NONE); + m_xMtrFldY->set_text(OUString()); + m_xMtrFldY->set_sensitive(false); + m_xFtY->set_sensitive(false); } } diff --git a/sd/source/ui/dlg/sddlgfact.cxx b/sd/source/ui/dlg/sddlgfact.cxx index dca60841af70..2c6131f7fd4b 100644 --- a/sd/source/ui/dlg/sddlgfact.cxx +++ b/sd/source/ui/dlg/sddlgfact.cxx @@ -52,7 +52,11 @@ IMPL_ABSTDLG_BASE(AbstractSdCustomShowDlg_Impl); IMPL_ABSTDLG_BASE(SdAbstractTabDialog_Impl); IMPL_ABSTDLG_BASE(SdPresLayoutTemplateDlg_Impl); IMPL_ABSTDLG_BASE(AbstractSdModifyFieldDlg_Impl); -IMPL_ABSTDLG_BASE(AbstractSdSnapLineDlg_Impl); + +short AbstractSdSnapLineDlg_Impl::Execute() +{ + return m_xDlg->run(); +} short AbstractSdInsertLayerDlg_Impl::Execute() { @@ -197,27 +201,27 @@ SfxItemSet AbstractSdModifyFieldDlg_Impl::GetItemSet() void AbstractSdSnapLineDlg_Impl::GetAttr(SfxItemSet& rOutAttrs) { - pDlg->GetAttr(rOutAttrs); + m_xDlg->GetAttr(rOutAttrs); } void AbstractSdSnapLineDlg_Impl::HideRadioGroup() { - pDlg->HideRadioGroup(); + m_xDlg->HideRadioGroup(); } void AbstractSdSnapLineDlg_Impl::HideDeleteBtn() { - pDlg->HideDeleteBtn(); + m_xDlg->HideDeleteBtn(); } void AbstractSdSnapLineDlg_Impl::SetInputFields(bool bEnableX, bool bEnableY) { - pDlg->SetInputFields(bEnableX, bEnableY); + m_xDlg->SetInputFields(bEnableX, bEnableY); } void AbstractSdSnapLineDlg_Impl::SetText( const OUString& rStr ) { - pDlg->SetText( rStr ); + m_xDlg->set_title(rStr); } void AbstractSdInsertLayerDlg_Impl::GetAttr( SfxItemSet& rOutAttrs ) @@ -334,9 +338,9 @@ VclPtr SdAbstractDialogFactory_Impl::CreateSdModifyFie return VclPtr::Create( VclPtr::Create( pParent, pInField, rSet ) ); } -VclPtr SdAbstractDialogFactory_Impl::CreateSdSnapLineDlg( vcl::Window* pParent, const SfxItemSet& rInAttrs, ::sd::View* pView) +VclPtr SdAbstractDialogFactory_Impl::CreateSdSnapLineDlg(weld::Window* pParent, const SfxItemSet& rInAttrs, ::sd::View* pView) { - return VclPtr::Create( VclPtr::Create( pParent, rInAttrs, pView ) ); + return VclPtr::Create(new SdSnapLineDlg(pParent, rInAttrs, pView)); } VclPtr SdAbstractDialogFactory_Impl::CreateSdInsertLayerDlg(weld::Window* pParent, const SfxItemSet& rInAttrs, bool bDeletable, const OUString& aStr) diff --git a/sd/source/ui/dlg/sddlgfact.hxx b/sd/source/ui/dlg/sddlgfact.hxx index 0367e9a8e192..d8bb3438f65f 100644 --- a/sd/source/ui/dlg/sddlgfact.hxx +++ b/sd/source/ui/dlg/sddlgfact.hxx @@ -142,7 +142,14 @@ class AbstractSdModifyFieldDlg_Impl : public AbstractSdModifyFieldDlg class SdSnapLineDlg; class AbstractSdSnapLineDlg_Impl : public AbstractSdSnapLineDlg { - DECL_ABSTDLG_BASE(AbstractSdSnapLineDlg_Impl,SdSnapLineDlg) +private: + std::unique_ptr m_xDlg; +public: + AbstractSdSnapLineDlg_Impl(SdSnapLineDlg* pDlg) + : m_xDlg(pDlg) + { + } + virtual short Execute() override; virtual void GetAttr(SfxItemSet& rOutAttrs) override; virtual void HideRadioGroup() override; virtual void HideDeleteBtn() override; @@ -245,7 +252,7 @@ public: virtual VclPtr CreateSdTabCharDialog(vcl::Window* pWindow, const SfxItemSet* pAttr, SfxObjectShell* pDocShell) override; virtual VclPtr CreateSdTabPageDialog(vcl::Window* pWindow, const SfxItemSet* pAttr, SfxObjectShell* pDocShell, bool bAreaPage) override; virtual VclPtr CreateSdModifyFieldDlg( vcl::Window* pWindow, const SvxFieldData* pInField, const SfxItemSet& rSet ) override; - virtual VclPtr CreateSdSnapLineDlg(vcl::Window* pParent, const SfxItemSet& rInAttrs, ::sd::View* pView) override; + virtual VclPtr CreateSdSnapLineDlg(weld::Window* pParent, const SfxItemSet& rInAttrs, ::sd::View* pView) override; virtual VclPtr CreateSdInsertLayerDlg(weld::Window* pParent, const SfxItemSet& rInAttrs, bool bDeletable, const OUString& aStr) override; virtual VclPtr CreateSdInsertPagesObjsDlg(vcl::Window* pParent, const SdDrawDocument* pDoc, SfxMedium* pSfxMedium, const OUString& rFileName ) override; virtual VclPtr CreateMorphDlg(weld::Window* pParent, const SdrObject* pObj1, const SdrObject* pObj2) override; diff --git a/sd/source/ui/func/fusnapln.cxx b/sd/source/ui/func/fusnapln.cxx index f86710d28f62..a4719be2bcf9 100644 --- a/sd/source/ui/func/fusnapln.cxx +++ b/sd/source/ui/func/fusnapln.cxx @@ -109,7 +109,8 @@ void FuSnapLine::DoExecute( SfxRequest& rReq ) aNewAttr.Put(SfxInt32Item(ATTR_SNAPLINE_Y, aLinePos.Y())); SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create(); - ScopedVclPtr pDlg(pFact ? pFact->CreateSdSnapLineDlg(mpViewShell->GetActiveWindow(), aNewAttr, mpView) : nullptr); + vcl::Window* pWin = mpViewShell->GetActiveWindow(); + ScopedVclPtr pDlg(pFact ? pFact->CreateSdSnapLineDlg(pWin ? pWin->GetFrameWeld() : nullptr, aNewAttr, mpView) : nullptr); OSL_ASSERT(pDlg); if (!pDlg) return; diff --git a/sd/source/ui/inc/dlgsnap.hxx b/sd/source/ui/inc/dlgsnap.hxx index 7444b561b649..25b1f248844d 100644 --- a/sd/source/ui/inc/dlgsnap.hxx +++ b/sd/source/ui/inc/dlgsnap.hxx @@ -20,14 +20,10 @@ #ifndef INCLUDED_SD_SOURCE_UI_INC_DLGSNAP_HXX #define INCLUDED_SD_SOURCE_UI_INC_DLGSNAP_HXX -#include -#include -#include -#include -#include #include -#include #include +#include + /************************************************************************/ class SfxItemSet; @@ -38,34 +34,34 @@ namespace sd { /** * dialog to adjust snap- lines and points */ -class SdSnapLineDlg : public ModalDialog +class SdSnapLineDlg : public weld::GenericDialogController { private: - VclPtr m_pFtX; - VclPtr m_pMtrFldX; - VclPtr m_pFtY; - VclPtr m_pMtrFldY; - VclPtr m_pRadioGroup; - VclPtr m_pRbPoint; - VclPtr m_pRbVert; - VclPtr m_pRbHorz; - VclPtr m_pBtnDelete; - long nXValue; - long nYValue; + int nXValue; + int nYValue; FieldUnit eUIUnit; Fraction aUIScale; - DECL_LINK( ClickHdl, Button *, void ); + std::unique_ptr m_xFtX; + std::unique_ptr m_xMtrFldX; + std::unique_ptr m_xFtY; + std::unique_ptr m_xMtrFldY; + std::unique_ptr m_xRadioGroup; + std::unique_ptr m_xRbPoint; + std::unique_ptr m_xRbVert; + std::unique_ptr m_xRbHorz; + std::unique_ptr m_xBtnDelete; + + DECL_LINK(ClickHdl, weld::Button&, void); public: - SdSnapLineDlg(vcl::Window* pWindow, const SfxItemSet& rInAttrs, ::sd::View const * pView); + SdSnapLineDlg(weld::Window* pWindow, const SfxItemSet& rInAttrs, ::sd::View const * pView); virtual ~SdSnapLineDlg() override; - virtual void dispose() override; void GetAttr(SfxItemSet& rOutAttrs); void HideRadioGroup(); - void HideDeleteBtn() { m_pBtnDelete->Hide(); } + void HideDeleteBtn() { m_xBtnDelete->hide(); } void SetInputFields(bool bEnableX, bool bEnableY); }; -- cgit