[Libreoffice-commits] core.git: cui/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Thu Oct 11 14:40:20 UTC 2018


 cui/source/inc/border.hxx      |    4 ++
 cui/source/tabpages/border.cxx |   56 ++++++++++++++++++++++++-----------------
 2 files changed, 38 insertions(+), 22 deletions(-)

New commits:
commit 3643a93698d9d2f86e58c80dcaf15427199acffc
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Thu Oct 11 13:54:10 2018 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Thu Oct 11 16:39:56 2018 +0200

    Resolves: tdf#120503 fix border padding
    
    a) SetFirst doesn't imply SetMin
    b) ModifyFlag and SaveValue are orthogonal
    
    Change-Id: Ibe637ec5d33af030af068fcf8690191a775a6460
    Reviewed-on: https://gerrit.libreoffice.org/61670
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/cui/source/inc/border.hxx b/cui/source/inc/border.hxx
index 80dea4edc8b0..02d3e6b24107 100644
--- a/cui/source/inc/border.hxx
+++ b/cui/source/inc/border.hxx
@@ -115,6 +115,10 @@ private:
     bool                mbBLTREnabled;      ///< true = Bottom-left to top-right border enabled.
     bool                mbUseMarginItem;
     bool                mbAllowPaddingWithoutBorders;
+    bool                mbLeftModified;
+    bool                mbRightModified;
+    bool                mbTopModified;
+    bool                mbBottomModified;
     bool                mbSync;
     bool                mbRemoveAdjacentCellBorders;
     bool                bIsCalcDoc;
diff --git a/cui/source/tabpages/border.cxx b/cui/source/tabpages/border.cxx
index c64aa54e6669..414c8a2a05a6 100644
--- a/cui/source/tabpages/border.cxx
+++ b/cui/source/tabpages/border.cxx
@@ -216,6 +216,10 @@ SvxBorderTabPage::SvxBorderTabPage(TabPageParent pParent, const SfxItemSet& rCor
     , mbBLTREnabled(false)
     , mbUseMarginItem(false)
     , mbAllowPaddingWithoutBorders(true)
+    , mbLeftModified(false)
+    , mbRightModified(false)
+    , mbTopModified(false)
+    , mbBottomModified(false)
     , mbSync(true)
     , mbRemoveAdjacentCellBorders(false)
     , bIsCalcDoc(false)
@@ -602,14 +606,6 @@ void SvxBorderTabPage::Reset( const SfxItemSet* rSet )
 
                 nMinValue = m_xLeftMF->get_value(FUNIT_NONE);
 
-                if ( pBoxInfoItem->IsMinDist() )
-                {
-                    m_xLeftMF->set_min(nMinValue, FUNIT_NONE);
-                    m_xRightMF->set_min(nMinValue, FUNIT_NONE);
-                    m_xTopMF->set_min(nMinValue, FUNIT_NONE);
-                    m_xBottomMF->set_min(nMinValue, FUNIT_NONE);
-                }
-
                 if ( pBoxInfoItem->IsDist() )
                 {
                     if( rSet->GetItemState( nWhichBox ) >= SfxItemState::DEFAULT )
@@ -630,6 +626,22 @@ void SvxBorderTabPage::Reset( const SfxItemSet* rSet )
                         SetMetricValue( *m_xTopMF, nTopDist, eCoreUnit );
                         long nBottomDist = pBoxItem->GetDistance( SvxBoxItemLine::BOTTOM);
                         SetMetricValue( *m_xBottomMF, nBottomDist, eCoreUnit );
+
+                        // if the distance is set with no active border line
+                        // or it is null with an active border line
+                        // no automatic changes should be made
+                        const long nDefDist = bIsAnyBorderVisible ? pBoxInfoItem->GetDefDist() : 0;
+                        bool bDiffDist = (nDefDist != nLeftDist ||
+                                    nDefDist != nRightDist ||
+                                    nDefDist != nTopDist   ||
+                                    nDefDist != nBottomDist);
+                        if ((pBoxItem->GetSmallestDistance() || bIsAnyBorderVisible) && bDiffDist )
+                        {
+                            mbLeftModified = true;
+                            mbRightModified = true;
+                            mbTopModified = true;
+                            mbBottomModified = true;
+                        }
                     }
                     else
                     {
@@ -896,8 +908,7 @@ bool SvxBorderTabPage::FillItemSet( SfxItemSet* rCoreAttrs )
             {
                 if ( mbAllowPaddingWithoutBorders
                      || ((mbHorEnabled || mbVerEnabled || (nSWMode & SwBorderModes::TABLE)) &&
-                         (m_xLeftMF->get_value_changed_from_saved()||m_xRightMF->get_value_changed_from_saved()||
-                             m_xTopMF->get_value_changed_from_saved()||m_xBottomMF->get_value_changed_from_saved()) )
+                         (mbLeftModified || mbRightModified || mbTopModified || mbBottomModified) )
                      || m_aFrameSel.GetFrameBorderState( svx::FrameBorderType::Top ) != svx::FrameBorderState::Hide
                      || m_aFrameSel.GetFrameBorderState( svx::FrameBorderType::Bottom ) != svx::FrameBorderState::Hide
                      || m_aFrameSel.GetFrameBorderState( svx::FrameBorderType::Left ) != svx::FrameBorderState::Hide
@@ -1310,21 +1321,13 @@ IMPL_LINK_NOARG(SvxBorderTabPage, LinesChanged_Impl, LinkParamNone*, void)
     if (!mbUseMarginItem && m_xLeftMF->get_visible())
     {
         bool bLineSet = m_aFrameSel.IsAnyBorderVisible();
-        bool bMinAllowed = bool(nSWMode & (SwBorderModes::FRAME|SwBorderModes::TABLE));
-        bool bSpaceModified =   m_xLeftMF->get_value_changed_from_saved() ||
-                                m_xRightMF->get_value_changed_from_saved() ||
-                                m_xTopMF->get_value_changed_from_saved() ||
-                                m_xBottomMF->get_value_changed_from_saved();
+        bool bSpaceModified =   mbLeftModified ||
+                                mbRightModified ||
+                                mbTopModified ||
+                                mbBottomModified;
 
         if(bLineSet)
         {
-            if(!bMinAllowed)
-            {
-                m_xLeftMF->set_min(nMinValue, FUNIT_NONE);
-                m_xRightMF->set_min(nMinValue, FUNIT_NONE);
-                m_xTopMF->set_min(nMinValue, FUNIT_NONE);
-                m_xBottomMF->set_min(nMinValue, FUNIT_NONE);
-            }
             if(!bSpaceModified)
             {
                 m_xLeftMF->set_value(nMinValue, FUNIT_NONE);
@@ -1380,6 +1383,15 @@ IMPL_LINK_NOARG(SvxBorderTabPage, LinesChanged_Impl, LinkParamNone*, void)
 
 IMPL_LINK( SvxBorderTabPage, ModifyDistanceHdl_Impl, weld::MetricSpinButton&, rField, void)
 {
+    if (&rField == m_xLeftMF.get())
+        mbLeftModified = true;
+    else if (&rField == m_xRightMF.get())
+        mbRightModified = true;
+    else if (&rField == m_xTopMF.get())
+        mbTopModified = true;
+    else if (&rField == m_xBottomMF.get())
+        mbBottomModified = true;
+
     if (mbSync)
     {
         const auto nVal = rField.get_value(FUNIT_NONE);


More information about the Libreoffice-commits mailing list