editeng/source/items/frmitems.cxx                  |   88 ++++++++++++++-------
 include/editeng/lrspitem.hxx                       |   67 +++------------
 reportdesign/source/ui/report/ReportController.cxx |    2 
 sc/source/core/data/stlsheet.cxx                   |    3 
 sc/source/ui/drawfunc/drtxtob.cxx                  |    3 
 sd/source/core/stlpool.cxx                         |    2 
 sd/source/ui/func/fupage.cxx                       |    2 
 sd/source/ui/view/drviews3.cxx                     |    4 
 sd/source/ui/view/outlview.cxx                     |    2 
 sw/source/core/attr/format.cxx                     |    2 
 sw/source/core/doc/DocumentStylePoolManager.cxx    |    6 -
 sw/source/core/docnode/ndtbl.cxx                   |    2 
 sw/source/filter/html/htmltab.cxx                  |    2 
 sw/source/filter/ww8/wrtw8nds.cxx                  |    2 
 sw/source/filter/ww8/wrtw8sty.cxx                  |    2 
 sw/source/filter/ww8/ww8graf.cxx                   |    2 
 sw/source/filter/ww8/ww8par6.cxx                   |    8 -
 sw/source/ui/dialog/uiregionsw.cxx                 |    2 
 sw/source/uibase/app/applab.cxx                    |    2 
 sw/source/uibase/sidebar/WrapPropertyPanel.cxx     |    2 
 20 files changed, 102 insertions(+), 103 deletions(-)

New commits:
commit a0875d09d9eeb368e9e319f3f2f29ec3be71b56c
Author:     Michael Stahl <[email protected]>
AuthorDate: Tue Feb 7 20:22:25 2023 +0100
Commit:     Michael Stahl <[email protected]>
CommitDate: Wed Feb 8 11:03:36 2023 +0000

    editeng: remove SvxLRSpaceItem::nTxtLeft
    
    Several parts of SvxLRSpaceItem appear to maintain an invariant of the
    3 members nTxtLeft/nLeftMargin/nFirstLineOffset: nLeftMargin is either
    equal to nTxtLeft if nFirstLineOffset is positive, otherwise equal to
    nTxtLeft + nFirstLineOffset.
    
    But not every part maintains it: there are functions SetLeftValue() and
    SetLeft() which simply write into nLeftMargin regardless, and a
    constructor that takes 3 separate numbers without any checks.
    
    The constructor calls violate the invariant in 2 ways: nTxtLeft is
    simply set to 0 (many cases), and one case in OutlineView::OutlineView()
    that sets nTxtLeft to 2000 but the other 2 at 0.
    
    Another odd thing is that the UNO services that expose SvxLRSpaceItem
    either expose a property for MID_L_MARGIN or for MID_TXT_LMARGIN but
    never both.
    
    It looks like there are 2 distinct usages of SvxLRSpaceItem:
    for anything that's applied to paragraphs, all 3 members are used;
    for anything else, nTxtLeft is unused.
    
    Try to simplify this by removing the nTxtLeft member, instead
    GetTextLeft() simply calculates it.
    
    Also assert in SetLeftValue()/SetLeft() that nFirstLineOffset is 0.
    
    Change-Id: Ida900c6ff04ef78e92e8914beda1cc731a695b06
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146643
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <[email protected]>

diff --git a/editeng/source/items/frmitems.cxx 
b/editeng/source/items/frmitems.cxx
index 4d6cd80088b5..01a2f7d70879 100644
--- a/editeng/source/items/frmitems.cxx
+++ b/editeng/source/items/frmitems.cxx
@@ -284,19 +284,16 @@ bool SvxSizeItem::HasMetrics() const
 }
 
 
-SvxLRSpaceItem::SvxLRSpaceItem( const sal_uInt16 nId ) :
-
-    SfxPoolItem( nId ),
-
-    nTxtLeft        ( 0 ),
-    nLeftMargin     ( 0 ),
-    nRightMargin    ( 0 ),
-    m_nGutterMargin(0),
-    m_nRightGutterMargin(0),
+SvxLRSpaceItem::SvxLRSpaceItem(const sal_uInt16 nId)
+    : SfxPoolItem(nId)
+    , nFirstLineOffset(0)
+    , nLeftMargin(0)
+    , nRightMargin(0)
+    , m_nGutterMargin(0)
+    , m_nRightGutterMargin(0),
     nPropFirstLineOffset( 100 ),
     nPropLeftMargin( 100 ),
     nPropRightMargin( 100 ),
-    nFirstLineOffset  ( 0 ),
     bAutoFirst      ( false ),
     bExplicitZeroMarginValRight(false),
     bExplicitZeroMarginValLeft(false)
@@ -305,19 +302,17 @@ SvxLRSpaceItem::SvxLRSpaceItem( const sal_uInt16 nId ) :
 
 
 SvxLRSpaceItem::SvxLRSpaceItem( const tools::Long nLeft, const tools::Long 
nRight,
-                                const tools::Long nTLeft, const short nOfset,
+                                const short nOfset,
                                 const sal_uInt16 nId )
-:   SfxPoolItem( nId ),
-
-    nTxtLeft        ( nTLeft ),
-    nLeftMargin     ( nLeft ),
-    nRightMargin    ( nRight ),
-    m_nGutterMargin(0),
-    m_nRightGutterMargin(0),
+    : SfxPoolItem(nId)
+    , nFirstLineOffset(nOfset)
+    , nLeftMargin(nLeft)
+    , nRightMargin(nRight)
+    , m_nGutterMargin(0)
+    , m_nRightGutterMargin(0),
     nPropFirstLineOffset( 100 ),
     nPropLeftMargin( 100 ),
     nPropRightMargin( 100 ),
-    nFirstLineOffset  ( nOfset ),
     bAutoFirst      ( false ),
     bExplicitZeroMarginValRight(false),
     bExplicitZeroMarginValLeft(false)
@@ -337,7 +332,7 @@ bool SvxLRSpaceItem::QueryValue( uno::Any& rVal, sal_uInt8 
nMemberId ) const
         {
             css::frame::status::LeftRightMarginScale aLRSpace;
             aLRSpace.Left = static_cast<sal_Int32>(bConvert ? 
convertTwipToMm100(nLeftMargin) : nLeftMargin);
-            aLRSpace.TextLeft = static_cast<sal_Int32>(bConvert ? 
convertTwipToMm100(nTxtLeft) : nTxtLeft);
+            aLRSpace.TextLeft = static_cast<sal_Int32>(bConvert ? 
convertTwipToMm100(GetTextLeft()) : GetTextLeft());
             aLRSpace.Right = static_cast<sal_Int32>(bConvert ? 
convertTwipToMm100(nRightMargin) : nRightMargin);
             aLRSpace.ScaleLeft = static_cast<sal_Int16>(nPropLeftMargin);
             aLRSpace.ScaleRight = static_cast<sal_Int16>(nPropRightMargin);
@@ -352,7 +347,7 @@ bool SvxLRSpaceItem::QueryValue( uno::Any& rVal, sal_uInt8 
nMemberId ) const
             break;
 
         case MID_TXT_LMARGIN :
-            rVal <<= static_cast<sal_Int32>(bConvert ? 
convertTwipToMm100(nTxtLeft) : nTxtLeft);
+            rVal <<= static_cast<sal_Int32>(bConvert ? 
convertTwipToMm100(GetTextLeft()) : GetTextLeft());
         break;
         case MID_R_MARGIN:
             rVal <<= static_cast<sal_Int32>(bConvert ? 
convertTwipToMm100(nRightMargin) : nRightMargin);
@@ -470,7 +465,7 @@ bool SvxLRSpaceItem::PutValue( const uno::Any& rVal, 
sal_uInt8 nMemberId )
 void SvxLRSpaceItem::SetLeft(const tools::Long nL, const sal_uInt16 nProp)
 {
     nLeftMargin = (nL * nProp) / 100;
-    nTxtLeft = nLeftMargin;
+    assert(nFirstLineOffset == 0); // probably call SetTextLeft instead? looks 
inconsistent otherwise
     nPropLeftMargin = nProp;
 }
 
@@ -486,9 +481,17 @@ void SvxLRSpaceItem::SetRight(const tools::Long nR, const 
sal_uInt16 nProp)
 
 void SvxLRSpaceItem::SetTextFirstLineOffset(const short nF, const sal_uInt16 
nProp)
 {
+    // note: left margin contains any negative first line offset - preserve it!
+    if (nFirstLineOffset < 0)
+    {
+        nLeftMargin -= nFirstLineOffset;
+    }
     nFirstLineOffset = short((tools::Long(nF) * nProp ) / 100);
     nPropFirstLineOffset = nProp;
-    AdjustLeft();
+    if (nFirstLineOffset < 0)
+    {
+        nLeftMargin += nFirstLineOffset;
+    }
 }
 
 void SvxLRSpaceItem::SetTextLeft(const tools::Long nL, const sal_uInt16 nProp)
@@ -497,20 +500,22 @@ void SvxLRSpaceItem::SetTextLeft(const tools::Long nL, 
const sal_uInt16 nProp)
     {
         SetExplicitZeroMarginValLeft(true);
     }
-    nTxtLeft = (nL * nProp) / 100;
+    auto const nTxtLeft = (nL * nProp) / 100;
     nPropLeftMargin = nProp;
-    AdjustLeft();
-}
-
-/// Adapt nLeftMargin and nTxtLeft.
-void SvxLRSpaceItem::AdjustLeft()
-{
+    // note: left margin contains any negative first line offset
     if ( 0 > nFirstLineOffset )
         nLeftMargin = nTxtLeft + nFirstLineOffset;
     else
         nLeftMargin = nTxtLeft;
 }
 
+tools::Long SvxLRSpaceItem::GetTextLeft() const
+{
+    // remove any negative first line offset from left margin to get text-left
+    return (nFirstLineOffset < 0)
+        ? nLeftMargin - nFirstLineOffset
+        : nLeftMargin;
+}
 
 bool SvxLRSpaceItem::operator==( const SfxPoolItem& rAttr ) const
 {
@@ -520,7 +525,6 @@ bool SvxLRSpaceItem::operator==( const SfxPoolItem& rAttr ) 
const
 
     return (
         nFirstLineOffset == rOther.GetTextFirstLineOffset() &&
-        nTxtLeft == rOther.GetTextLeft() &&
         m_nGutterMargin == rOther.GetGutterMargin() &&
         m_nRightGutterMargin == rOther.GetRightGutterMargin() &&
         nLeftMargin == rOther.GetLeft()  &&
@@ -625,7 +629,6 @@ bool SvxLRSpaceItem::GetPresentation
 void SvxLRSpaceItem::ScaleMetrics( tools::Long nMult, tools::Long nDiv )
 {
     nFirstLineOffset = static_cast<short>(BigInt::Scale( nFirstLineOffset, 
nMult, nDiv ));
-    nTxtLeft = BigInt::Scale( nTxtLeft, nMult, nDiv );
     nLeftMargin = BigInt::Scale( nLeftMargin, nMult, nDiv );
     nRightMargin = BigInt::Scale( nRightMargin, nMult, nDiv );
 }
@@ -642,7 +645,6 @@ void SvxLRSpaceItem::dumpAsXml(xmlTextWriterPtr pWriter) 
const
     (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SvxLRSpaceItem"));
     (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), 
BAD_CAST(OString::number(Which()).getStr()));
     (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("nFirstLineOffset"), 
BAD_CAST(OString::number(nFirstLineOffset).getStr()));
-    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("nTxtLeft"), 
BAD_CAST(OString::number(nTxtLeft).getStr()));
     (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("nLeftMargin"), 
BAD_CAST(OString::number(nLeftMargin).getStr()));
     (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("nRightMargin"), 
BAD_CAST(OString::number(nRightMargin).getStr()));
     (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("m_nGutterMargin"),
diff --git a/include/editeng/lrspitem.hxx b/include/editeng/lrspitem.hxx
index 8ddaa157416c..3072e385f939 100644
--- a/include/editeng/lrspitem.hxx
+++ b/include/editeng/lrspitem.hxx
@@ -49,7 +49,8 @@ SetTextLeft SetTextFirst GetLeft GetTextLeft  GetTextFirst  
(What?)
 
 class EDITENG_DLLPUBLIC SvxLRSpaceItem final : public SfxPoolItem
 {
-    tools::Long    nTxtLeft;           // We spend a sal_uInt16
+    /// First-line indent always relative to GetTextLeft()
+    short   nFirstLineOffset;
     tools::Long    nLeftMargin;        // nLeft or the negative first-line 
indent
     tools::Long    nRightMargin;       // The unproblematic right edge
     /// The amount of extra space added to the left margin.
@@ -58,20 +59,17 @@ class EDITENG_DLLPUBLIC SvxLRSpaceItem final : public 
SfxPoolItem
     tools::Long    m_nRightGutterMargin;
 
     sal_uInt16  nPropFirstLineOffset, nPropLeftMargin, nPropRightMargin;
-    short   nFirstLineOffset;     // First-line indent _always_ relative to 
nTxtLeft
     bool        bAutoFirst;    // Automatic calculation of the first line 
indent
     bool        bExplicitZeroMarginValRight;
     bool        bExplicitZeroMarginValLeft;
 
-    void   AdjustLeft();        // nLeftMargin and nTxtLeft are being adjusted.
-
 public:
 
     static SfxPoolItem* CreateDefault();
 
     explicit SvxLRSpaceItem( const sal_uInt16 nId  );
     SvxLRSpaceItem( const tools::Long nLeft, const tools::Long nRight,
-                    const tools::Long nTLeft /*= 0*/, const short nOfset /*= 
0*/,
+                    const short nOfset /*= 0*/,
                     const sal_uInt16 nId  );
     SvxLRSpaceItem(SvxLRSpaceItem const &) = default; // SfxPoolItem copy 
function dichotomy
 
@@ -97,7 +95,7 @@ public:
     // Query/direct setting of the absolute values
     tools::Long GetLeft()  const { return nLeftMargin; }
     tools::Long GetRight() const { return nRightMargin;}
-    void SetLeftValue( const tools::Long nL ) { nTxtLeft = nLeftMargin = nL; }
+    void SetLeftValue( const tools::Long nL ) { assert(nFirstLineOffset == 0); 
nLeftMargin = nL; }
     void SetRightValue( const tools::Long nR ) { nRightMargin = nR; }
     bool IsAutoFirst()  const { return bAutoFirst; }
     void SetAutoFirst( const bool bNew ) { bAutoFirst = bNew; }
@@ -111,7 +109,7 @@ public:
 
     // The UI/text interface:
     void SetTextLeft(const tools::Long nL, const sal_uInt16 nProp = 100);
-    tools::Long GetTextLeft() const { return nTxtLeft; }
+    tools::Long GetTextLeft() const;
 
     void SetTextFirstLineOffset(const short nF, const sal_uInt16 nProp = 100);
     short  GetTextFirstLineOffset() const { return nFirstLineOffset; }
diff --git a/reportdesign/source/ui/report/ReportController.cxx 
b/reportdesign/source/ui/report/ReportController.cxx
index fb389172985e..0266e14b6698 100644
--- a/reportdesign/source/ui/report/ReportController.cxx
+++ b/reportdesign/source/ui/report/ReportController.cxx
@@ -2425,7 +2425,7 @@ void OReportController::openPageDialog(const 
uno::Reference<report::XSection>& _
         {
             
aDescriptor.Put(SvxSizeItem(RPTUI_ID_SIZE,VCLSize(getStyleProperty<awt::Size>(m_xReportDefinition,PROPERTY_PAPERSIZE))));
             
aDescriptor.Put(SvxLRSpaceItem(getStyleProperty<sal_Int32>(m_xReportDefinition,PROPERTY_LEFTMARGIN)
-                                            
,getStyleProperty<sal_Int32>(m_xReportDefinition,PROPERTY_RIGHTMARGIN),0,0,RPTUI_ID_LRSPACE));
+                                            
,getStyleProperty<sal_Int32>(m_xReportDefinition,PROPERTY_RIGHTMARGIN),0,RPTUI_ID_LRSPACE));
             
aDescriptor.Put(SvxULSpaceItem(static_cast<sal_uInt16>(getStyleProperty<sal_Int32>(m_xReportDefinition,PROPERTY_TOPMARGIN))
                                             
,static_cast<sal_uInt16>(getStyleProperty<sal_Int32>(m_xReportDefinition,PROPERTY_BOTTOMMARGIN)),RPTUI_ID_ULSPACE));
             
aDescriptor.Put(SfxUInt16Item(SID_ATTR_METRIC,static_cast<sal_uInt16>(eUserMetric)));
diff --git a/sc/source/core/data/stlsheet.cxx b/sc/source/core/data/stlsheet.cxx
index fdf09e7cde3e..4ee18ef0f0fb 100644
--- a/sc/source/core/data/stlsheet.cxx
+++ b/sc/source/core/data/stlsheet.cxx
@@ -171,7 +171,6 @@ SfxItemSet& ScStyleSheet::GetItemSet()
 
                         SvxLRSpaceItem  aLRSpaceItem( TWO_CM,   // nLeft
                                                       TWO_CM,   // nRight
-                                                      TWO_CM,   // nTLeft
                                                       0,        // 
nFirstLineOffset
                                                       ATTR_LRSPACE );
                         SvxULSpaceItem  aULSpaceItem( TWO_CM,   // nUp
@@ -188,7 +187,7 @@ SfxItemSet& ScStyleSheet::GetItemSet()
                         rHFSet.Put( aBoxInfoItem );
                         rHFSet.Put( aHFSizeItem );
                         rHFSet.Put( aHFDistItem );
-                        rHFSet.Put( SvxLRSpaceItem( 0,0,0,0, ATTR_LRSPACE ) ); 
// Set border to Null
+                        rHFSet.Put( SvxLRSpaceItem(0, 0, 0, ATTR_LRSPACE) ); 
// Set border to Null
 
                         aHFSetItem.SetWhich(ATTR_PAGE_HEADERSET);
                         pSet->Put( aHFSetItem );
diff --git a/sc/source/ui/drawfunc/drtxtob.cxx 
b/sc/source/ui/drawfunc/drtxtob.cxx
index c17ea9c19baf..f6e8982bd74d 100644
--- a/sc/source/ui/drawfunc/drtxtob.cxx
+++ b/sc/source/ui/drawfunc/drtxtob.cxx
@@ -928,8 +928,7 @@ void ScDrawTextObjectBar::ExecuteAttr( SfxRequest &rReq )
         SfxItemSetFixed<EE_PARA_LRSPACE, EE_PARA_LRSPACE> aAttr( GetPool() );
         nId = EE_PARA_LRSPACE;
         SvxLRSpaceItem aLRSpaceItem( rItem.GetLeft(),
-            rItem.GetRight(), rItem.GetTextLeft(),
-            rItem.GetTextFirstLineOffset(), nId );
+            rItem.GetRight(), rItem.GetTextFirstLineOffset(), nId );
         aAttr.Put( aLRSpaceItem );
         pView->SetAttributes( aAttr );
     }
diff --git a/sd/source/core/stlpool.cxx b/sd/source/core/stlpool.cxx
index 4bca10fb71bc..2134cec147f5 100644
--- a/sd/source/core/stlpool.cxx
+++ b/sd/source/core/stlpool.cxx
@@ -450,7 +450,7 @@ void 
SdStyleSheetPool::CreateLayoutStyleSheets(std::u16string_view rLayoutName,
         rNotesSet.Put( SvxCharReliefItem(FontRelief::NONE, EE_CHAR_RELIEF) );
         rNotesSet.Put( SvxColorItem( COL_AUTO, EE_CHAR_COLOR ) );
         rNotesSet.Put( SvxColorItem( COL_AUTO, EE_CHAR_BKGCOLOR ) );
-        rNotesSet.Put( SvxLRSpaceItem( 0, 0, 600, -600, EE_PARA_LRSPACE  ) );
+        rNotesSet.Put( SvxLRSpaceItem( 0, 0, -600, EE_PARA_LRSPACE  ) );
         // #i16874# enable kerning by default but only for new documents
         rNotesSet.Put( SvxAutoKernItem( true, EE_CHAR_PAIRKERNING ) );
 
diff --git a/sd/source/ui/func/fupage.cxx b/sd/source/ui/func/fupage.cxx
index edb242ab1a6e..7e353bba1c91 100644
--- a/sd/source/ui/func/fupage.cxx
+++ b/sd/source/ui/func/fupage.cxx
@@ -246,7 +246,7 @@ const SfxItemSet* FuPage::ExecuteDialog(weld::Window* 
pParent, const SfxRequest&
     SvxPaperBinItem aPaperBinItem( SID_ATTR_PAGE_PAPERBIN, 
static_cast<sal_uInt8>(mpPage->GetPaperBin()) );
     aNewAttr.Put( aPaperBinItem );
 
-    SvxLRSpaceItem aLRSpaceItem( 
static_cast<sal_uInt16>(mpPage->GetLeftBorder()), 
static_cast<sal_uInt16>(mpPage->GetRightBorder()), 0, 0, 
mpDoc->GetPool().GetWhich(SID_ATTR_LRSPACE));
+    SvxLRSpaceItem aLRSpaceItem( 
static_cast<sal_uInt16>(mpPage->GetLeftBorder()), 
static_cast<sal_uInt16>(mpPage->GetRightBorder()), 0, 
mpDoc->GetPool().GetWhich(SID_ATTR_LRSPACE));
     aNewAttr.Put( aLRSpaceItem );
 
     SvxULSpaceItem aULSpaceItem( 
static_cast<sal_uInt16>(mpPage->GetUpperBorder()), 
static_cast<sal_uInt16>(mpPage->GetLowerBorder()), 
mpDoc->GetPool().GetWhich(SID_ATTR_ULSPACE));
diff --git a/sd/source/ui/view/drviews3.cxx b/sd/source/ui/view/drviews3.cxx
index e0c0db7b7e48..5c3a80bdf96e 100644
--- a/sd/source/ui/view/drviews3.cxx
+++ b/sd/source/ui/view/drviews3.cxx
@@ -809,7 +809,7 @@ void  DrawViewShell::ExecRuler(SfxRequest& rReq)
 
                 nId = EE_PARA_LRSPACE;
                 SvxLRSpaceItem aLRSpaceItem( rItem.GetLeft(),
-                        rItem.GetRight(), rItem.GetTextLeft(),
+                        rItem.GetRight(),
                         rItem.GetTextFirstLineOffset(), nId );
 
                 const sal_Int16 nOutlineLevel = aEditAttr.Get( 
EE_PARA_OUTLLEVEL ).GetValue();
@@ -938,7 +938,7 @@ void  DrawViewShell::GetRulerState(SfxItemSet& rSet)
 
                     const SvxLRSpaceItem& rLRSpaceItem = aEditAttr.Get( 
EE_PARA_LRSPACE );
                     SvxLRSpaceItem aLRSpaceItem( rLRSpaceItem.GetLeft(),
-                            rLRSpaceItem.GetRight(), 
rLRSpaceItem.GetTextLeft(),
+                            rLRSpaceItem.GetRight(),
                             rLRSpaceItem.GetTextFirstLineOffset(), 
SID_ATTR_PARA_LRSPACE );
 
                     const sal_Int16 nOutlineLevel = aEditAttr.Get( 
EE_PARA_OUTLLEVEL ).GetValue();
diff --git a/sd/source/ui/view/outlview.cxx b/sd/source/ui/view/outlview.cxx
index 3c51ee76747b..4ddc3be230bd 100644
--- a/sd/source/ui/view/outlview.cxx
+++ b/sd/source/ui/view/outlview.cxx
@@ -77,7 +77,7 @@ OutlineView::OutlineView( DrawDocShell& rDocSh, vcl::Window* 
pWindow, OutlineVie
 , mnPagesProcessed(0)
 , mbFirstPaint(true)
 , maDocColor( COL_WHITE )
-, maLRSpaceItem( 0, 0, 2000, 0, EE_PARA_OUTLLRSPACE )
+, maLRSpaceItem(2000, 0, 0, EE_PARA_OUTLLRSPACE)
 {
     bool bInitOutliner = false;
 
diff --git a/sw/source/core/attr/format.cxx b/sw/source/core/attr/format.cxx
index 1ced91e62972..fe341f21b8da 100644
--- a/sw/source/core/attr/format.cxx
+++ b/sw/source/core/attr/format.cxx
@@ -688,7 +688,7 @@ void SwFormat::DelDiffs( const SfxItemSet& rSet )
 void SwFormat::SetPageFormatToDefault()
 {
     const sal_Int32 nSize = o3tl::convert(2, o3tl::Length::cm, 
o3tl::Length::twip);
-    SetFormatAttr(SvxLRSpaceItem(nSize, nSize, nSize, 0, RES_LR_SPACE));
+    SetFormatAttr(SvxLRSpaceItem(nSize, nSize, 0, RES_LR_SPACE));
     SetFormatAttr(SvxULSpaceItem(nSize, nSize, RES_UL_SPACE));
 }
 
diff --git a/sw/source/core/doc/DocumentStylePoolManager.cxx 
b/sw/source/core/doc/DocumentStylePoolManager.cxx
index 06a614318d44..9877dc785ccb 100644
--- a/sw/source/core/doc/DocumentStylePoolManager.cxx
+++ b/sw/source/core/doc/DocumentStylePoolManager.cxx
@@ -1624,7 +1624,7 @@ SwFormat* DocumentStylePoolManager::GetFormatFromPool( 
sal_uInt16 nId )
                 aBox.SetLine( &aLine, SvxBoxItemLine::RIGHT );
                 aBox.SetAllDistances( 85 );
                 aSet.Put( aBox );
-                aSet.Put( SvxLRSpaceItem( 114, 114, 0, 0, RES_LR_SPACE ) );
+                aSet.Put( SvxLRSpaceItem( 114, 114, 0, RES_LR_SPACE ) );
                 aSet.Put( SvxULSpaceItem( 114, 114, RES_UL_SPACE ) );
             }
 
@@ -1645,7 +1645,7 @@ SwFormat* DocumentStylePoolManager::GetFormatFromPool( 
sal_uInt16 nId )
         {
             aSet.Put( SwFormatAnchor( RndStdIds::FLY_AS_CHAR ) );
             aSet.Put( SwFormatVertOrient( 0, 
text::VertOrientation::CHAR_CENTER, text::RelOrientation::FRAME ) );
-            aSet.Put( SvxLRSpaceItem( 0, 0, 0, 0, RES_LR_SPACE ) );
+            aSet.Put( SvxLRSpaceItem( 0, 0, 0, RES_LR_SPACE ) );
         }
         break;
     case RES_POOLFRM_MARGINAL:
@@ -1673,7 +1673,7 @@ SwFormat* DocumentStylePoolManager::GetFormatFromPool( 
sal_uInt16 nId )
         {
             aSet.Put( SwFormatAnchor( RndStdIds::FLY_AS_CHAR ) );
             aSet.Put( SwFormatVertOrient( 0, text::VertOrientation::TOP, 
text::RelOrientation::FRAME ) );
-            aSet.Put( SvxLRSpaceItem( 114, 114, 0, 0, RES_LR_SPACE ) );
+            aSet.Put( SvxLRSpaceItem( 114, 114, 0, RES_LR_SPACE ) );
 
             SvxProtectItem aProtect( RES_PROTECT );
             aProtect.SetSizeProtect( true );
diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx
index 5e2cd8605bdd..14c6ce7f702b 100644
--- a/sw/source/core/docnode/ndtbl.cxx
+++ b/sw/source/core/docnode/ndtbl.cxx
@@ -427,7 +427,7 @@ const SwTable* SwDoc::InsertTable( const 
SwInsertTableOptions& rInsTableOpts,
         {
             sal_uInt16 nFrameWidth = nLastPos;
             nLastPos = (*pColArr)[ pColArr->size()-2 ];
-            pTableFormat->SetFormatAttr( SvxLRSpaceItem( nSttPos, nFrameWidth 
- nLastPos, 0, 0, RES_LR_SPACE ) );
+            pTableFormat->SetFormatAttr( SvxLRSpaceItem( nSttPos, nFrameWidth 
- nLastPos, 0, RES_LR_SPACE ) );
         }
         nWidth = nLastPos - nSttPos;
     }
diff --git a/sw/source/filter/html/htmltab.cxx 
b/sw/source/filter/html/htmltab.cxx
index 7913cd9e85fa..a028a8fe86c4 100644
--- a/sw/source/filter/html/htmltab.cxx
+++ b/sw/source/filter/html/htmltab.cxx
@@ -3440,7 +3440,7 @@ void SwHTMLParser::BuildTableCell( HTMLTable *pCurTable, 
bool bReadOptions,
 
                     sal_uInt16 nSpace = pCurTable->GetHSpace();
                     if( nSpace )
-                        aFrameSet.Put( SvxLRSpaceItem(nSpace,nSpace, 0, 0, 
RES_LR_SPACE) );
+                        aFrameSet.Put( SvxLRSpaceItem(nSpace, nSpace, 0, 
RES_LR_SPACE) );
                     nSpace = pCurTable->GetVSpace();
                     if( nSpace )
                         aFrameSet.Put( SvxULSpaceItem(nSpace,nSpace, 
RES_UL_SPACE) );
diff --git a/sw/source/filter/ww8/wrtw8nds.cxx 
b/sw/source/filter/ww8/wrtw8nds.cxx
index 3b6f4c2b47ed..5b68a1dc94b2 100644
--- a/sw/source/filter/ww8/wrtw8nds.cxx
+++ b/sw/source/filter/ww8/wrtw8nds.cxx
@@ -3042,7 +3042,7 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
                 const SfxPoolItem* pLrSpaceItem = 
oTmpSet->GetItemIfSet(RES_LR_SPACE);
                 SvxLRSpaceItem aLRSpace(
                     ( pLrSpaceItem == nullptr )
-                        ? SvxLRSpaceItem(0, 0, 0, 0, RES_LR_SPACE)
+                        ? SvxLRSpaceItem(0, 0, 0, RES_LR_SPACE)
                         : *static_cast<const SvxLRSpaceItem*>( pLrSpaceItem ) 
);
 
                 // new left margin = old left + label space
diff --git a/sw/source/filter/ww8/wrtw8sty.cxx 
b/sw/source/filter/ww8/wrtw8sty.cxx
index 27fcae621b17..1d556fc312b8 100644
--- a/sw/source/filter/ww8/wrtw8sty.cxx
+++ b/sw/source/filter/ww8/wrtw8sty.cxx
@@ -1721,7 +1721,7 @@ void MSWordExportBase::SectionProperties( const 
WW8_SepInfo& rSepInfo, WW8_PdAtt
 
             SvxLRSpaceItem aResultLR( rPageLR.GetLeft() +
                     rSectionLR.GetLeft(), rPageLR.GetRight() +
-                    rSectionLR.GetRight(), 0, 0, RES_LR_SPACE );
+                    rSectionLR.GetRight(), 0, RES_LR_SPACE );
             //i120133: The Section width should consider section indent value.
             if (rSectionLR.GetLeft()+rSectionLR.GetRight()!=0)
             {
diff --git a/sw/source/filter/ww8/ww8graf.cxx b/sw/source/filter/ww8/ww8graf.cxx
index 7fcbde440d68..d8ae5938d6dd 100644
--- a/sw/source/filter/ww8/ww8graf.cxx
+++ b/sw/source/filter/ww8/ww8graf.cxx
@@ -2011,7 +2011,7 @@ void SwWW8ImplReader::MapWrapIntoFlyFormat(const 
SvxMSDffImportRec& rRecord,
     if (rRecord.nDxWrapDistLeft || rRecord.nDxWrapDistRight)
     {
         SvxLRSpaceItem aLR(writer_cast<sal_uInt16>(rRecord.nDxWrapDistLeft),
-                           writer_cast<sal_uInt16>(rRecord.nDxWrapDistRight), 
0, 0, RES_LR_SPACE);
+                           writer_cast<sal_uInt16>(rRecord.nDxWrapDistRight), 
0, RES_LR_SPACE);
         AdjustLRWrapForWordMargins(rRecord, aLR);
         rFlyFormat.SetFormatAttr(aLR);
     }
diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx
index 00c9b1cda0df..7569ec903f06 100644
--- a/sw/source/filter/ww8/ww8par6.cxx
+++ b/sw/source/filter/ww8/ww8par6.cxx
@@ -526,7 +526,7 @@ void wwSectionManager::SetPage(SwPageDesc &rInPageDesc, 
SwFrameFormat &rFormat,
     
aSz.SetHeight(SvxPaperInfo::GetSloppyPaperDimension(rSection.GetPageHeight()));
     rFormat.SetFormatAttr(aSz);
 
-    SvxLRSpaceItem aLR(rSection.GetPageLeft(), rSection.GetPageRight(), 0, 0, 
RES_LR_SPACE);
+    SvxLRSpaceItem aLR(rSection.GetPageLeft(), rSection.GetPageRight(), 0, 
RES_LR_SPACE);
     aLR.SetGutterMargin(rSection.m_nPgGutter);
     rFormat.SetFormatAttr(aLR);
 
@@ -764,7 +764,7 @@ SwSectionFormat *wwSectionManager::InsertSection(
     tools::Long nSectionRight = rSection.GetPageRight() - nPageRight;
     if ((nSectionLeft != 0) || (nSectionRight != 0))
     {
-        SvxLRSpaceItem aLR(nSectionLeft, nSectionRight, 0, 0, RES_LR_SPACE);
+        SvxLRSpaceItem aLR(nSectionLeft, nSectionRight, 0, RES_LR_SPACE);
         pFormat->SetFormatAttr(aLR);
     }
 
@@ -2183,7 +2183,7 @@ WW8FlySet::WW8FlySet(SwWW8ImplReader& rReader, const 
WW8FlyPara* pFW,
     Put( SwFormatVertOrient( pFS->nYPos, pFS->eVAlign, pFS->eVRel ) );
 
     if (pFS->nLeMgn || pFS->nRiMgn)     // set borders
-        Put(SvxLRSpaceItem(pFS->nLeMgn, pFS->nRiMgn, 0, 0, RES_LR_SPACE));
+        Put(SvxLRSpaceItem(pFS->nLeMgn, pFS->nRiMgn, 0, RES_LR_SPACE));
 
     if (pFS->nUpMgn || pFS->nLoMgn)
         Put(SvxULSpaceItem(pFS->nUpMgn, pFS->nLoMgn, RES_UL_SPACE));
@@ -2244,7 +2244,7 @@ WW8FlySet::WW8FlySet( SwWW8ImplReader& rReader, const 
SwPaM* pPaM,
         brcVer9[i] = WW8_BRCVer9(rPic.rgbrc[i]);
     if (SwWW8ImplReader::SetFlyBordersShadow( *this, brcVer9, &aSizeArray[0]))
     {
-        Put(SvxLRSpaceItem( aSizeArray[WW8_LEFT], 0, 0, 0, RES_LR_SPACE ) );
+        Put(SvxLRSpaceItem( aSizeArray[WW8_LEFT], 0, 0, RES_LR_SPACE ) );
         Put(SvxULSpaceItem( aSizeArray[WW8_TOP], 0, RES_UL_SPACE ));
         aSizeArray[WW8_RIGHT]*=2;
         aSizeArray[WW8_BOT]*=2;
diff --git a/sw/source/ui/dialog/uiregionsw.cxx 
b/sw/source/ui/dialog/uiregionsw.cxx
index afe90adc6c21..b2259f3cb8b5 100644
--- a/sw/source/ui/dialog/uiregionsw.cxx
+++ b/sw/source/ui/dialog/uiregionsw.cxx
@@ -2075,7 +2075,7 @@ bool SwSectionIndentTabPage::FillItemSet(SfxItemSet* rSet)
     {
         SvxLRSpaceItem aLRSpace(
                 
m_xBeforeMF->denormalize(m_xBeforeMF->get_value(FieldUnit::TWIP)) ,
-                
m_xAfterMF->denormalize(m_xAfterMF->get_value(FieldUnit::TWIP)), 0, 0, 
RES_LR_SPACE);
+                
m_xAfterMF->denormalize(m_xAfterMF->get_value(FieldUnit::TWIP)), 0, 
RES_LR_SPACE);
         rSet->Put(aLRSpace);
     }
     return true;
diff --git a/sw/source/uibase/app/applab.cxx b/sw/source/uibase/app/applab.cxx
index 1ea666ccdf61..786e9bf63d4c 100644
--- a/sw/source/uibase/app/applab.cxx
+++ b/sw/source/uibase/app/applab.cxx
@@ -277,7 +277,7 @@ void SwModule::InsertLab(SfxRequest& rReq, bool bLabel)
 
         //frame represents label itself, no border space
         SvxULSpaceItem aFrameNoULSpace( 0, 0, RES_UL_SPACE );
-        SvxLRSpaceItem aFrameNoLRSpace( 0, 0, 0, 0, RES_LR_SPACE );
+        SvxLRSpaceItem aFrameNoLRSpace( 0, 0, 0, RES_LR_SPACE );
         pFormat->SetFormatAttr( aFrameNoULSpace );
         pFormat->SetFormatAttr( aFrameNoLRSpace );
 
diff --git a/sw/source/uibase/sidebar/WrapPropertyPanel.cxx 
b/sw/source/uibase/sidebar/WrapPropertyPanel.cxx
index 45cf0e61f646..ef7990729f87 100644
--- a/sw/source/uibase/sidebar/WrapPropertyPanel.cxx
+++ b/sw/source/uibase/sidebar/WrapPropertyPanel.cxx
@@ -119,7 +119,7 @@ IMPL_LINK(WrapPropertyPanel, SpacingLBHdl, weld::ComboBox&, 
rBox, void)
 {
     sal_uInt16 nVal = rBox.get_active_id().toUInt32();
 
-    SvxLRSpaceItem aLRItem(nVal, nVal, 0, 0, RES_LR_SPACE);
+    SvxLRSpaceItem aLRItem(nVal, nVal, 0, RES_LR_SPACE);
     SvxULSpaceItem aULItem(nVal, nVal, RES_UL_SPACE);
 
     m_nTop = m_nBottom = m_nLeft = m_nRight = nVal;
commit 9bf7092aa05b47e6290d894edaf00f21038a636a
Author:     Michael Stahl <[email protected]>
AuthorDate: Mon Feb 6 20:44:11 2023 +0100
Commit:     Michael Stahl <[email protected]>
CommitDate: Wed Feb 8 11:03:23 2023 +0000

    editeng: SvxLRSpaceItem uninline some functions
    
    Change-Id: I719ec54ef0e4540c8dbacb783b335ccb69b08e9a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146642
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <[email protected]>

diff --git a/editeng/source/items/frmitems.cxx 
b/editeng/source/items/frmitems.cxx
index 890d74a75510..4d6cd80088b5 100644
--- a/editeng/source/items/frmitems.cxx
+++ b/editeng/source/items/frmitems.cxx
@@ -467,6 +467,40 @@ bool SvxLRSpaceItem::PutValue( const uno::Any& rVal, 
sal_uInt8 nMemberId )
     return true;
 }
 
+void SvxLRSpaceItem::SetLeft(const tools::Long nL, const sal_uInt16 nProp)
+{
+    nLeftMargin = (nL * nProp) / 100;
+    nTxtLeft = nLeftMargin;
+    nPropLeftMargin = nProp;
+}
+
+void SvxLRSpaceItem::SetRight(const tools::Long nR, const sal_uInt16 nProp)
+{
+    if (0 == nR)
+    {
+        SetExplicitZeroMarginValRight(true);
+    }
+    nRightMargin = (nR * nProp) / 100;
+    nPropRightMargin = nProp;
+}
+
+void SvxLRSpaceItem::SetTextFirstLineOffset(const short nF, const sal_uInt16 
nProp)
+{
+    nFirstLineOffset = short((tools::Long(nF) * nProp ) / 100);
+    nPropFirstLineOffset = nProp;
+    AdjustLeft();
+}
+
+void SvxLRSpaceItem::SetTextLeft(const tools::Long nL, const sal_uInt16 nProp)
+{
+    if (0 == nL)
+    {
+        SetExplicitZeroMarginValLeft(true);
+    }
+    nTxtLeft = (nL * nProp) / 100;
+    nPropLeftMargin = nProp;
+    AdjustLeft();
+}
 
 /// Adapt nLeftMargin and nTxtLeft.
 void SvxLRSpaceItem::AdjustLeft()
diff --git a/include/editeng/lrspitem.hxx b/include/editeng/lrspitem.hxx
index 0510ee47d521..8ddaa157416c 100644
--- a/include/editeng/lrspitem.hxx
+++ b/include/editeng/lrspitem.hxx
@@ -29,14 +29,15 @@
 
     Left/Right margin and first line indent
 
-    SvxLRSpaceItem offers two interfaces for views from the left margin and
-    first line indent. The get methods return the member, with the layout also
-    as expected: the left edge shifts to the negative first line indent to the
-    left. The SetTxt/Gettxt methods assume that the left side represents the
-    0 coordinate for the first line indent:
+    SvxLRSpaceItem offers two interfaces to get the left margin and first line
+    indent.
+    - The Get* methods return the member in the way the layout used to expect:
+      with a negative first line indent, the left margin shifts to the left.
+    - The SetText*,GetText* methods assume that the left margin represents
+      the 0 coordinate for the first line indent:
 
     UI         UI       LAYOUT   UI/TEXT      UI/TEXT    (Where?)
-    SetTextLeft SetTxtFirst GetLeft  GetTextLeft  GetTxtFirst  (What?)
+SetTextLeft SetTextFirst GetLeft GetTextLeft  GetTextFirst  (What?)
     500       -500        0        500         -500      (How much?)
     500         0        500       500           0
     500       +500       500       500         +500
@@ -90,8 +91,8 @@ public:
     virtual bool                 HasMetrics() const override;
 
     // The "layout interface":
-    inline void   SetLeft ( const tools::Long nL, const sal_uInt16 nProp = 100 
);
-    inline void   SetRight( const tools::Long nR, const sal_uInt16 nProp = 100 
);
+    void   SetLeft (const tools::Long nL, const sal_uInt16 nProp = 100);
+    void   SetRight(const tools::Long nR, const sal_uInt16 nProp = 100);
 
     // Query/direct setting of the absolute values
     tools::Long GetLeft()  const { return nLeftMargin; }
@@ -109,10 +110,10 @@ public:
     sal_uInt16 GetPropRight() const { return nPropRightMargin;}
 
     // The UI/text interface:
-    inline void SetTextLeft( const tools::Long nL, const sal_uInt16 nProp = 
100 );
+    void SetTextLeft(const tools::Long nL, const sal_uInt16 nProp = 100);
     tools::Long GetTextLeft() const { return nTxtLeft; }
 
-    inline void   SetTextFirstLineOffset( const short nF, const sal_uInt16 
nProp = 100 );
+    void SetTextFirstLineOffset(const short nF, const sal_uInt16 nProp = 100);
     short  GetTextFirstLineOffset() const { return nFirstLineOffset; }
     void SetPropTextFirstLineOffset( const sal_uInt16 nProp )
                     { nPropFirstLineOffset = nProp; }
@@ -129,40 +130,6 @@ public:
     virtual boost::property_tree::ptree dumpAsJSON() const override;
 };
 
-inline void SvxLRSpaceItem::SetLeft( const tools::Long nL, const sal_uInt16 
nProp )
-{
-    nLeftMargin = (nL * nProp) / 100;
-    nTxtLeft = nLeftMargin;
-    nPropLeftMargin = nProp;
-}
-inline void SvxLRSpaceItem::SetRight( const tools::Long nR, const sal_uInt16 
nProp )
-{
-    if (0 == nR)
-    {
-        SetExplicitZeroMarginValRight(true);
-    }
-    nRightMargin = (nR * nProp) / 100;
-    nPropRightMargin = nProp;
-}
-inline void SvxLRSpaceItem::SetTextFirstLineOffset( const short nF,
-                                                 const sal_uInt16 nProp )
-{
-    nFirstLineOffset = short((tools::Long(nF) * nProp ) / 100);
-    nPropFirstLineOffset = nProp;
-    AdjustLeft();
-}
-
-inline void SvxLRSpaceItem::SetTextLeft( const tools::Long nL, const 
sal_uInt16 nProp )
-{
-    if (0 == nL)
-    {
-        SetExplicitZeroMarginValLeft(true);
-    }
-    nTxtLeft = (nL * nProp) / 100;
-    nPropLeftMargin = nProp;
-    AdjustLeft();
-}
-
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Reply via email to