From 826300d55b8f18593c4b56fb448d09fac52820bd Mon Sep 17 00:00:00 2001 From: Andrea Rosetti Date: Wed, 2 Aug 2023 11:40:25 +0200 Subject: tdf#86628 Add reset crop function to dialog Added a function that uncrops the image, keeping the modified size (which can be restored using the already existing Original Size button) Change-Id: I8e98de2b586c68d52f819955ce5a74f20cbe6698 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155219 Tested-by: Jenkins Reviewed-by: Heiko Tietze --- cui/source/inc/grfpage.hxx | 3 +++ cui/source/tabpages/grfpage.cxx | 28 ++++++++++++++++++++++++ cui/uiconfig/ui/croppage.ui | 48 +++++++++++++++++++++-------------------- 3 files changed, 56 insertions(+), 23 deletions(-) (limited to 'cui') diff --git a/cui/source/inc/grfpage.hxx b/cui/source/inc/grfpage.hxx index adfaebc33595..673062b7593a 100644 --- a/cui/source/inc/grfpage.hxx +++ b/cui/source/inc/grfpage.hxx @@ -80,6 +80,8 @@ class SvxGrfCropPage : public SfxTabPage std::unique_ptr m_xOrigSizeFT; std::unique_ptr m_xOrigSizePB; + std::unique_ptr m_xUncropPB; + // Example std::unique_ptr m_xExampleWN; @@ -87,6 +89,7 @@ class SvxGrfCropPage : public SfxTabPage DECL_LINK(SizeHdl, weld::MetricSpinButton&, void); DECL_LINK(CropModifyHdl, weld::MetricSpinButton&, void); DECL_LINK(OrigSizeHdl, weld::Button&, void); + DECL_LINK(UncropHdl, weld::Button&, void); void CalcZoom(); void CalcMinMaxBorder(); diff --git a/cui/source/tabpages/grfpage.cxx b/cui/source/tabpages/grfpage.cxx index aa49c2a7267c..fac0bfb6ab05 100644 --- a/cui/source/tabpages/grfpage.cxx +++ b/cui/source/tabpages/grfpage.cxx @@ -75,6 +75,7 @@ SvxGrfCropPage::SvxGrfCropPage(weld::Container* pPage, weld::DialogController* p , m_xOrigSizeGrid(m_xBuilder->weld_widget("origsizegrid")) , m_xOrigSizeFT(m_xBuilder->weld_label("origsizeft")) , m_xOrigSizePB(m_xBuilder->weld_button("origsize")) + , m_xUncropPB(m_xBuilder->weld_button("uncrop")) , m_xExampleWN(new weld::CustomWeld(*m_xBuilder, "preview", m_aExampleWN)) { SetExchangeSupport(); @@ -104,6 +105,7 @@ SvxGrfCropPage::SvxGrfCropPage(weld::Container* pPage, weld::DialogController* p m_xBottomMF->connect_value_changed( aLk ); m_xOrigSizePB->connect_clicked(LINK(this, SvxGrfCropPage, OrigSizeHdl)); + m_xUncropPB->connect_clicked(LINK(this, SvxGrfCropPage, UncropHdl)); } SvxGrfCropPage::~SvxGrfCropPage() @@ -524,6 +526,32 @@ IMPL_LINK_NOARG(SvxGrfCropPage, OrigSizeHdl, weld::Button&, void) m_xHeightZoomMF->set_value(100, FieldUnit::NONE); m_bSetOrigSize = true; } + +/*-------------------------------------------------------------------- + description: reset crop + --------------------------------------------------------------------*/ + +IMPL_LINK_NOARG(SvxGrfCropPage, UncropHdl, weld::Button&, void) +{ + SfxItemPool* pPool = GetItemSet().GetPool(); + DBG_ASSERT( pPool, "Where is the pool?" ); + + m_xLeftMF->set_value(0, FieldUnit::NONE); + m_xRightMF->set_value(0, FieldUnit::NONE); + m_xTopMF->set_value(0, FieldUnit::NONE); + m_xBottomMF->set_value(0, FieldUnit::NONE); + + m_aExampleWN.SetLeft(0); + m_aExampleWN.SetRight(0); + m_aExampleWN.SetTop(0); + m_aExampleWN.SetBottom(0); + + m_aExampleWN.Invalidate(); + CalcMinMaxBorder(); + +} + + /*-------------------------------------------------------------------- description: compute scale --------------------------------------------------------------------*/ diff --git a/cui/uiconfig/ui/croppage.ui b/cui/uiconfig/ui/croppage.ui index b7fe3d8224a6..93f3eafe504a 100644 --- a/cui/uiconfig/ui/croppage.ui +++ b/cui/uiconfig/ui/croppage.ui @@ -1,5 +1,5 @@ - + @@ -51,7 +51,6 @@ 1 10 - True False @@ -68,15 +67,14 @@ 0 none - True False + 12 + 6 True 6 18 - 12 - 6 Keep _scale @@ -108,7 +106,6 @@ - True False @@ -133,8 +130,8 @@ True True True + True adjustment1 - True 2 @@ -161,8 +158,8 @@ True True True + True adjustment7 - True 2 @@ -177,7 +174,6 @@ - True False @@ -216,8 +212,8 @@ True True True + True adjustment6 - True 2 @@ -230,8 +226,8 @@ True True True + True adjustment8 - True 2 @@ -278,7 +274,6 @@ - True False @@ -320,7 +315,16 @@ - + + Reset Crop + True + True + True + + + 0 + 4 + @@ -348,14 +352,13 @@ 0 none - True False + 12 + 6 6 12 - 12 - 6 True @@ -375,7 +378,7 @@ True True True - True + True adjustment2 @@ -402,7 +405,7 @@ True True True - True + True adjustment5 @@ -435,14 +438,13 @@ 0 none - True False + 12 + 6 6 12 - 12 - 6 True @@ -462,8 +464,8 @@ True True True + True adjustment3 - True 2 @@ -490,8 +492,8 @@ True True True + True adjustment4 - True 2 -- cgit