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(-)

New commits:
commit 826300d55b8f18593c4b56fb448d09fac52820bd
Author:     Andrea Rosetti <andreamassim...@gmail.com>
AuthorDate: Wed Aug 2 11:40:25 2023 +0200
Commit:     Heiko Tietze <heiko.tie...@documentfoundation.org>
CommitDate: Fri Aug 25 07:37:33 2023 +0200

    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 <heiko.tie...@documentfoundation.org>

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<weld::Label> m_xOrigSizeFT;
     std::unique_ptr<weld::Button> m_xOrigSizePB;
 
+    std::unique_ptr<weld::Button> m_xUncropPB;
+
     // Example
     std::unique_ptr<weld::CustomWeld> 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 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.22.1 -->
+<!-- Generated with glade 3.20.3 -->
 <interface domain="cui">
   <requires lib="gtk+" version="3.20"/>
   <object class="GtkAdjustment" id="adjustment1">
@@ -51,7 +51,6 @@
     <property name="step_increment">1</property>
     <property name="page_increment">10</property>
   </object>
-  <!-- n-columns=1 n-rows=1 -->
   <object class="GtkGrid" id="CropPage">
     <property name="visible">True</property>
     <property name="can_focus">False</property>
@@ -68,15 +67,14 @@
         <property name="label_xalign">0</property>
         <property name="shadow_type">none</property>
         <child>
-          <!-- n-columns=1 n-rows=1 -->
           <object class="GtkGrid" id="grid10">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
+            <property name="margin_start">12</property>
+            <property name="margin_top">6</property>
             <property name="hexpand">True</property>
             <property name="row_spacing">6</property>
             <property name="column_spacing">18</property>
-            <property name="margin-start">12</property>
-            <property name="margin-top">6</property>
             <child>
               <object class="GtkRadioButton" id="keepscale">
                 <property name="label" translatable="yes" 
context="croppage|keepscale">Keep _scale</property>
@@ -108,7 +106,6 @@
               </packing>
             </child>
             <child>
-              <!-- n-columns=1 n-rows=1 -->
               <object class="GtkGrid" id="grid1">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
@@ -133,8 +130,8 @@
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
                     <property name="activates_default">True</property>
+                    <property name="truncate_multiline">True</property>
                     <property name="adjustment">adjustment1</property>
-                    <property name="truncate-multiline">True</property>
                     <property name="digits">2</property>
                   </object>
                   <packing>
@@ -161,8 +158,8 @@
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
                     <property name="activates_default">True</property>
+                    <property name="truncate_multiline">True</property>
                     <property name="adjustment">adjustment7</property>
-                    <property name="truncate-multiline">True</property>
                     <property name="digits">2</property>
                   </object>
                   <packing>
@@ -177,7 +174,6 @@
               </packing>
             </child>
             <child>
-              <!-- n-columns=1 n-rows=1 -->
               <object class="GtkGrid" id="grid2">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
@@ -216,8 +212,8 @@
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
                     <property name="activates_default">True</property>
+                    <property name="truncate_multiline">True</property>
                     <property name="adjustment">adjustment6</property>
-                    <property name="truncate-multiline">True</property>
                     <property name="digits">2</property>
                   </object>
                   <packing>
@@ -230,8 +226,8 @@
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
                     <property name="activates_default">True</property>
+                    <property name="truncate_multiline">True</property>
                     <property name="adjustment">adjustment8</property>
-                    <property name="truncate-multiline">True</property>
                     <property name="digits">2</property>
                   </object>
                   <packing>
@@ -278,7 +274,6 @@
               </packing>
             </child>
             <child>
-              <!-- n-columns=1 n-rows=1 -->
               <object class="GtkGrid" id="origsizegrid">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
@@ -320,7 +315,16 @@
               </packing>
             </child>
             <child>
-              <placeholder/>
+              <object class="GtkButton" id="uncrop">
+                <property name="label" translatable="yes" 
context="croppage|uncrop">Reset Crop</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+              </object>
+              <packing>
+                <property name="left_attach">0</property>
+                <property name="top_attach">4</property>
+              </packing>
             </child>
           </object>
         </child>
@@ -348,14 +352,13 @@
         <property name="label_xalign">0</property>
         <property name="shadow_type">none</property>
         <child>
-          <!-- n-columns=1 n-rows=1 -->
           <object class="GtkGrid" id="grid4">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
+            <property name="margin_start">12</property>
+            <property name="margin_top">6</property>
             <property name="row_spacing">6</property>
             <property name="column_spacing">12</property>
-            <property name="margin-start">12</property>
-            <property name="margin-top">6</property>
             <child>
               <object class="GtkLabel" id="label6">
                 <property name="visible">True</property>
@@ -375,7 +378,7 @@
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="activates_default">True</property>
-                <property name="truncate-multiline">True</property>
+                <property name="truncate_multiline">True</property>
                 <property name="adjustment">adjustment2</property>
               </object>
               <packing>
@@ -402,7 +405,7 @@
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="activates_default">True</property>
-                <property name="truncate-multiline">True</property>
+                <property name="truncate_multiline">True</property>
                 <property name="adjustment">adjustment5</property>
               </object>
               <packing>
@@ -435,14 +438,13 @@
         <property name="label_xalign">0</property>
         <property name="shadow_type">none</property>
         <child>
-          <!-- n-columns=1 n-rows=1 -->
           <object class="GtkGrid" id="grid3">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
+            <property name="margin_start">12</property>
+            <property name="margin_top">6</property>
             <property name="row_spacing">6</property>
             <property name="column_spacing">12</property>
-            <property name="margin-start">12</property>
-            <property name="margin-top">6</property>
             <child>
               <object class="GtkLabel" id="label8">
                 <property name="visible">True</property>
@@ -462,8 +464,8 @@
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="activates_default">True</property>
+                <property name="truncate_multiline">True</property>
                 <property name="adjustment">adjustment3</property>
-                <property name="truncate-multiline">True</property>
                 <property name="digits">2</property>
               </object>
               <packing>
@@ -490,8 +492,8 @@
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="activates_default">True</property>
+                <property name="truncate_multiline">True</property>
                 <property name="adjustment">adjustment4</property>
-                <property name="truncate-multiline">True</property>
                 <property name="digits">2</property>
               </object>
               <packing>

Reply via email to