include/svx/ruler.hxx               |    3 ++-
 svx/source/dialog/rlrcitem.cxx      |    2 +-
 svx/source/dialog/svxruler.cxx      |   13 ++++++++++++-
 sw/source/uibase/uiview/viewtab.cxx |   22 +++++++++++-----------
 4 files changed, 26 insertions(+), 14 deletions(-)

New commits:
commit e87f9b4fa158b917bb38fc00513bae7f94024e58
Author:     Justin Luth <justin_l...@sil.org>
AuthorDate: Tue Feb 15 14:26:35 2022 +0200
Commit:     Justin Luth <jl...@mail.com>
CommitDate: Thu Feb 24 07:36:57 2022 +0100

    tdf#95882 svxruler: restore adjustment for borders
    
    This restores the clause removed from
    LO 3.6's commit 47a77d7dbc427e51421e2df8d59695834cb74980
        Ruler: disable snapping, tooltips
    
    [Because that removal left behind dead code,
     which was later cleared out, of course this patch
     restores that as well.
        commit 8303e7ed668fbcbd0ba75bd9dd259f03073ffd46
        Author: Noel Grandin on Fri Jun 14 10:41:11 2019 +0200
    ]
    
    Basic borders on the paragraph itself
    do not affect where LO ends the tabstop,
    and thus the removal of that clause was partially justified.
    But the table/frame/page/headers definitely need to be adjusted
    in order for the tabstops to show in the correct position.
    
    RightFrameMargin needed this as well,
    especially now that RTL is supported by the ruler since LO 3.6,
    although the Left/Right functions are very different.
    
    [Frames never worked because the aCoreSet wasn't accepting
     RES_BOX items. Interesting error considering all of the
     other sections of code created a new CoreSet.]
    
    Change-Id: Ic24839dbbd730e66d8b0d588bfbd73bc7cb260bf
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130125
    Tested-by: Justin Luth <jl...@mail.com>
    Reviewed-by: Justin Luth <jl...@mail.com>

diff --git a/include/svx/ruler.hxx b/include/svx/ruler.hxx
index 374209a73f69..010af4b17936 100644
--- a/include/svx/ruler.hxx
+++ b/include/svx/ruler.hxx
@@ -91,6 +91,7 @@ class SVX_DLLPUBLIC SvxRuler: public Ruler, public SfxListener
     std::unique_ptr<SvxLongULSpaceItem> mxULSpaceItem;    // upper and lower 
edge
     std::unique_ptr<SvxTabStopItem>     mxTabStopItem;    // tab stops
     std::unique_ptr<SvxLRSpaceItem>     mxParaItem;       // paragraphs
+    std::unique_ptr<SvxLRSpaceItem>     mxBorderItem;     // border distance
     std::unique_ptr<SvxPagePosSizeItem> mxPagePosItem;    // page distance to 
the rule
     std::unique_ptr<SvxColumnItem>      mxColumnItem;     // columns
     std::unique_ptr<SvxObjectItem>      mxObjectItem;     // object
@@ -140,7 +141,7 @@ class SVX_DLLPUBLIC SvxRuler: public Ruler, public 
SfxListener
     // paragraph indentations
     void UpdatePara(const SvxLRSpaceItem* pItem);
     // Border distance
-    void UpdateParaBorder();
+    void UpdateBorder(const SvxLRSpaceItem* pItem);
     // Tabs
     void Update(const SvxTabStopItem* pItem);
     // page position and width
diff --git a/svx/source/dialog/rlrcitem.cxx b/svx/source/dialog/rlrcitem.cxx
index 873663b27e30..a73cd00bdac5 100644
--- a/svx/source/dialog/rlrcitem.cxx
+++ b/svx/source/dialog/rlrcitem.cxx
@@ -131,7 +131,7 @@ void SvxRulerItem::StateChangedAtToolBoxControl( sal_uInt16 
nSID, SfxItemState e
         {
             const SvxLRSpaceItem *pItem = dynamic_cast<const SvxLRSpaceItem*>( 
pState );
             SAL_WARN_IF(pState != nullptr && pItem == nullptr, "svx.dialog", 
"SvxLRSpaceItem expected");
-            rRuler.UpdateParaBorder();
+            rRuler.UpdateBorder(pItem);
         }
         break;
         case SID_RULER_TEXT_RIGHT_TO_LEFT :
diff --git a/svx/source/dialog/svxruler.cxx b/svx/source/dialog/svxruler.cxx
index 6e960a18433d..d676c3c1208f 100644
--- a/svx/source/dialog/svxruler.cxx
+++ b/svx/source/dialog/svxruler.cxx
@@ -881,11 +881,16 @@ void SvxRuler::UpdatePara(const SvxLRSpaceItem *pItem) // 
new value of paragraph
     }
 }
 
-void SvxRuler::UpdateParaBorder()
+void SvxRuler::UpdateBorder(const SvxLRSpaceItem * pItem)
 {
     /* Border distance */
     if(bActive)
     {
+        if (pItem)
+            mxBorderItem.reset(new SvxLRSpaceItem(*pItem));
+        else
+            mxBorderItem.reset();
+
         StartListening_Impl();
     }
 }
@@ -1206,6 +1211,9 @@ tools::Long SvxRuler::GetLeftFrameMargin() const
         nLeft = mxColumnItem->GetActiveColumnDescription().nStart;
     }
 
+    if (mxBorderItem && (!mxColumnItem || mxColumnItem->IsTable()))
+        nLeft += mxBorderItem->GetLeft();
+
     return nLeft;
 }
 
@@ -1257,6 +1265,9 @@ tools::Long SvxRuler::GetRightFrameMargin() const
     else if(!bHorz && mxULSpaceItem)
         lResult += mxULSpaceItem->GetLower();
 
+    if (bHorz && mxBorderItem && (!mxColumnItem || mxColumnItem->IsTable()))
+        lResult += mxBorderItem->GetRight();
+
     if(bHorz)
         lResult = mxPagePosItem->GetWidth() - lResult;
     else
diff --git a/sw/source/uibase/uiview/viewtab.cxx 
b/sw/source/uibase/uiview/viewtab.cxx
index 6bf269219d9a..c911971fd314 100644
--- a/sw/source/uibase/uiview/viewtab.cxx
+++ b/sw/source/uibase/uiview/viewtab.cxx
@@ -1699,6 +1699,8 @@ void SwView::StateTabWin(SfxItemSet& rSet)
         {
             m_nLeftBorderDistance = 0;
             m_nRightBorderDistance = 0;
+            SfxItemSetFixed<RES_BOX, RES_BOX,
+                            SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER> 
aCoreSet2(GetPool());
             if ( nSelType & SelectionType::Graphic ||
                     nSelType & SelectionType::Frame ||
                     nSelType & SelectionType::Ole ||
@@ -1714,15 +1716,17 @@ void SwView::StateTabWin(SfxItemSet& rSet)
                         const SwRect& rFlyPrtRect = rSh.GetAnyCurRect( 
CurRectType::FlyEmbeddedPrt, pPt );
                         aDistLR.SetLeft(rFlyPrtRect.Left());
                         aDistLR.SetRight(rFlyPrtRect.Left());
+                        rSet.Put(aDistLR);
                     }
                     else
                     {
                         SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
-                        aCoreSet.Put( aBoxInfo );
-                        rSh.GetFlyFrameAttr( aCoreSet );
-                        const SvxBoxItem& rBox = aCoreSet.Get(RES_BOX);
+                        aCoreSet2.Put(aBoxInfo);
+                        rSh.GetFlyFrameAttr(aCoreSet2);
+                        const SvxBoxItem& rBox = aCoreSet2.Get(RES_BOX);
                         
aDistLR.SetLeft(rBox.GetDistance(SvxBoxItemLine::LEFT));
                         
aDistLR.SetRight(rBox.GetDistance(SvxBoxItemLine::RIGHT));
+                        rSet.Put(aDistLR);
 
                         //add the paragraph border distance
                         SfxItemSetFixed<RES_BOX, RES_BOX> aCoreSet1( GetPool() 
);
@@ -1731,7 +1735,6 @@ void SwView::StateTabWin(SfxItemSet& rSet)
                         aDistLR.SetLeft(aDistLR.GetLeft() + 
rParaBox.GetDistance(SvxBoxItemLine::LEFT));
                         aDistLR.SetRight(aDistLR.GetRight() + 
rParaBox.GetDistance(SvxBoxItemLine::RIGHT));
                     }
-                    rSet.Put(aDistLR);
                     m_nLeftBorderDistance  = static_cast< sal_uInt16 
>(aDistLR.GetLeft());
                     m_nRightBorderDistance = static_cast< sal_uInt16 
>(aDistLR.GetRight());
                 }
@@ -1739,8 +1742,6 @@ void SwView::StateTabWin(SfxItemSet& rSet)
                     ( rSh.GetTableFormat() && !bFrameSelection &&
                     !(nFrameType & FrameTypeFlags::COLSECT ) ) )
                 {
-                    SfxItemSetFixed<RES_BOX, RES_BOX,
-                                    SID_ATTR_BORDER_INNER, 
SID_ATTR_BORDER_INNER>  aCoreSet2( GetPool() );
                     SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
                     aBoxInfo.SetTable(false);
                     aBoxInfo.SetDist(true);
@@ -1749,6 +1750,7 @@ void SwView::StateTabWin(SfxItemSet& rSet)
                     const SvxBoxItem& rBox = aCoreSet2.Get(RES_BOX);
                     aDistLR.SetLeft(rBox.GetDistance(SvxBoxItemLine::LEFT));
                     aDistLR.SetRight(rBox.GetDistance(SvxBoxItemLine::RIGHT));
+                    rSet.Put(aDistLR);
 
                     //add the border distance of the paragraph
                     SfxItemSetFixed<RES_BOX, RES_BOX> aCoreSet1( GetPool() );
@@ -1756,7 +1758,6 @@ void SwView::StateTabWin(SfxItemSet& rSet)
                     const SvxBoxItem& rParaBox = aCoreSet1.Get(RES_BOX);
                     aDistLR.SetLeft(aDistLR.GetLeft() + 
rParaBox.GetDistance(SvxBoxItemLine::LEFT));
                     aDistLR.SetRight(aDistLR.GetRight() + 
rParaBox.GetDistance(SvxBoxItemLine::RIGHT));
-                    rSet.Put(aDistLR);
                     m_nLeftBorderDistance  = static_cast< sal_uInt16 
>(aDistLR.GetLeft());
                     m_nRightBorderDistance = static_cast< sal_uInt16 
>(aDistLR.GetRight());
                 }
@@ -1789,14 +1790,13 @@ void SwView::StateTabWin(SfxItemSet& rSet)
                         
aDistLR.SetLeft(pBox->GetDistance(SvxBoxItemLine::LEFT));
                         
aDistLR.SetRight(pBox->GetDistance(SvxBoxItemLine::RIGHT));
                     }
+                    rSet.Put(aDistLR);
 
                     //add the border distance of the paragraph
-                    SfxItemSetFixed<RES_BOX, RES_BOX> aCoreSetTmp( GetPool() );
-                    rSh.GetCurAttr( aCoreSetTmp );
-                    const SvxBoxItem& rParaBox = aCoreSetTmp.Get(RES_BOX);
+                    rSh.GetCurAttr(aCoreSet2);
+                    const SvxBoxItem& rParaBox = aCoreSet2.Get(RES_BOX);
                     aDistLR.SetLeft(aDistLR.GetLeft() + 
rParaBox.GetDistance(SvxBoxItemLine::LEFT));
                     aDistLR.SetRight(aDistLR.GetRight() + 
rParaBox.GetDistance(SvxBoxItemLine::RIGHT));
-                    rSet.Put(aDistLR);
                     m_nLeftBorderDistance  = static_cast< sal_uInt16 
>(aDistLR.GetLeft());
                     m_nRightBorderDistance = static_cast< sal_uInt16 
>(aDistLR.GetRight());
                 }

Reply via email to