From db115bec9254417ef7a3faf687478fe5424ab378 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Tue, 14 Feb 2023 18:03:55 +0100 Subject: tdf#78510 sw,cui: split SvxLRSpaceItem for SwTextNode, SwTextFormatColl Leave editengine and non-paragraph usages of SvxLRSpaceItem as-is for now. Add new items RES_MARGIN_LEFT etc., order them so that paragraphs can have 3 consecutive items RES_MARGIN_FIRSTLINE..RES_MARGIN_RIGHT and non-paragraphs also have 2-4 consecutive items RES_MARGIN_RIGHT..RES_MARGIN_LEFT (only the 3 paragraph ones are actually used now). The HTML import filter is particularly annoying because it parses CSS stuff into SfxItemSets without knowing where the items will be applied, so it can't know whether to create SvxLeftMarginItem or SvxTextLeftMarginItem... the split items are created in ParseCSS1_* functions and then converted later if necessary. WW8 import has some weird code as well, SwWW8ImplReader::Read_LR() creates 3 items and then something wants to set every item on its own so SwWW8FltControlStack::SetAttrInDoc() turned out rather weird. Convert the paragraph dialog to handle the split items (by mapping them to SID_ATTR_PARA_FIRSTLINESPACE/SID_ATTR_PARA_LEFTSPACE/ SID_ATTR_PARA_RIGHTSPACE), but the SvxRuler looks a bit more confusing so convert in sw shells for now and leave that for later (also unclear if changing these slot items like SID_ATTR_PARA_LRSPACE breaks any ABIs?). Change-Id: I40431821868fd3e1cceba121b5539ff9ae6befbc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147024 Tested-by: Michael Stahl Reviewed-by: Michael Stahl --- cui/source/inc/paragrph.hxx | 3 +- cui/source/tabpages/paragrph.cxx | 230 +++++++++++++++++++++++- sw/inc/format.hxx | 6 + sw/inc/frmatr.hxx | 24 +++ sw/inc/hintids.hxx | 185 ++++++++++--------- sw/inc/ndtxt.hxx | 7 +- sw/inc/swatrset.hxx | 12 ++ sw/qa/extras/uiwriter/uiwriter2.cxx | 12 +- sw/source/core/access/accpara.cxx | 7 +- sw/source/core/attr/BorderCacheOwner.cxx | 3 + sw/source/core/bastyp/init.cxx | 12 ++ sw/source/core/crsr/crstrvl.cxx | 13 +- sw/source/core/doc/DocumentStylePoolManager.cxx | 112 +++++++----- sw/source/core/doc/dbgoutsw.cxx | 6 + sw/source/core/doc/docfmt.cxx | 14 +- sw/source/core/doc/docnum.cxx | 10 +- sw/source/core/doc/fmtcol.cxx | 90 +++++++--- sw/source/core/edit/autofmt.cxx | 38 ++-- sw/source/core/inc/frmtool.hxx | 4 +- sw/source/core/layout/fly.cxx | 11 +- sw/source/core/layout/frmtool.cxx | 45 +++-- sw/source/core/layout/wsfrm.cxx | 6 + sw/source/core/text/EnhancedPDFExportHelper.cxx | 6 +- sw/source/core/text/frmcrsr.cxx | 10 +- sw/source/core/text/frmpaint.cxx | 10 +- sw/source/core/text/itratr.cxx | 11 +- sw/source/core/text/itrcrsr.cxx | 13 +- sw/source/core/text/porfld.cxx | 2 +- sw/source/core/text/porrst.cxx | 4 +- sw/source/core/text/txtfrm.cxx | 2 +- sw/source/core/tox/ToxTabStopTokenHandler.cxx | 18 +- sw/source/core/txtnode/ndtxt.cxx | 37 ++-- sw/source/core/txtnode/thints.cxx | 8 +- sw/source/core/unocore/unomapproperties.hxx | 28 +-- sw/source/core/unocore/unosrch.cxx | 12 ++ sw/source/filter/html/css1atr.cxx | 70 ++++++++ sw/source/filter/html/htmlatr.cxx | 50 ++++-- sw/source/filter/html/htmlcss1.cxx | 97 +++++----- sw/source/filter/html/htmlctxt.cxx | 62 +++++-- sw/source/filter/html/htmldrawreader.cxx | 17 +- sw/source/filter/html/htmlflywriter.cxx | 8 +- sw/source/filter/html/htmlform.cxx | 17 +- sw/source/filter/html/htmlnumreader.cxx | 4 +- sw/source/filter/html/htmlplug.cxx | 17 +- sw/source/filter/html/svxcss1.cxx | 105 ++++------- sw/source/filter/html/swhtml.cxx | 125 ++++++++----- sw/source/filter/html/swhtml.hxx | 4 +- sw/source/filter/html/wrthtml.cxx | 2 +- sw/source/filter/ww8/attributeoutputbase.hxx | 7 + sw/source/filter/ww8/docxattributeoutput.cxx | 94 +++++++--- sw/source/filter/ww8/docxattributeoutput.hxx | 8 + sw/source/filter/ww8/rtfattributeoutput.cxx | 42 ++++- sw/source/filter/ww8/rtfattributeoutput.hxx | 7 + sw/source/filter/ww8/wrtw8nds.cxx | 47 +++-- sw/source/filter/ww8/ww8atr.cxx | 81 +++++++-- sw/source/filter/ww8/ww8attributeoutput.hxx | 7 + sw/source/filter/ww8/ww8par.cxx | 90 +++++++--- sw/source/filter/ww8/ww8par.hxx | 11 +- sw/source/filter/ww8/ww8par2.cxx | 10 +- sw/source/filter/ww8/ww8par3.cxx | 73 +++++--- sw/source/filter/ww8/ww8par6.cxx | 55 +++--- sw/source/filter/xml/xmlexpit.cxx | 5 + sw/source/filter/xml/xmlimpit.cxx | 8 + sw/source/filter/xml/xmlitemm.cxx | 1 - sw/source/ui/envelp/envfmt.cxx | 5 +- sw/source/uibase/app/docstyle.cxx | 21 ++- sw/source/uibase/shells/textsh1.cxx | 16 +- sw/source/uibase/shells/txtattr.cxx | 13 +- sw/source/uibase/uiview/viewsrch.cxx | 3 +- sw/source/uibase/uiview/viewtab.cxx | 77 +++++--- sw/source/uibase/wrtsh/delete.cxx | 22 +-- 71 files changed, 1607 insertions(+), 685 deletions(-) diff --git a/cui/source/inc/paragrph.hxx b/cui/source/inc/paragrph.hxx index c44374776d79..c61e988d04f5 100644 --- a/cui/source/inc/paragrph.hxx +++ b/cui/source/inc/paragrph.hxx @@ -50,7 +50,8 @@ private: SvxParaPrevWindow m_aExampleWin; - // indention + // indentation + bool m_bSplitLRSpace = false; ///< which items to use? std::unique_ptr m_xLeftIndent; std::unique_ptr m_xRightIndent; diff --git a/cui/source/tabpages/paragrph.cxx b/cui/source/tabpages/paragrph.cxx index ff6426b499aa..04a4ad8c82ea 100644 --- a/cui/source/tabpages/paragrph.cxx +++ b/cui/source/tabpages/paragrph.cxx @@ -54,6 +54,7 @@ const WhichRangesContainer SvxStdParagraphTabPage::pStdRanges( svl::Items< SID_ATTR_PARA_LINESPACE, SID_ATTR_PARA_LINESPACE, // 10033 + SID_ATTR_PARA_LEFTSPACE, SID_ATTR_PARA_FIRSTLINESPACE, SID_ATTR_LRSPACE, SID_ATTR_ULSPACE, // 10048 - 10049 SID_ATTR_PARA_REGISTER, SID_ATTR_PARA_REGISTER // 10413 >); @@ -310,10 +311,126 @@ bool SvxStdParagraphTabPage::FillItemSet( SfxItemSet* rOutSet ) } bool bNullTab = false; - if ( m_xLeftIndent->get_value_changed_from_saved() || + if (m_bSplitLRSpace && m_xLeftIndent->get_value_changed_from_saved()) + { + nWhich = GetWhich(SID_ATTR_PARA_LEFTSPACE); + MapUnit const eUnit = pPool->GetMetric(nWhich); + SvxTextLeftMarginItem item(nWhich); + pOld = GetOldItem(*rOutSet, SID_ATTR_PARA_LEFTSPACE); + + if (bRelativeMode) + { + assert(GetItemSet().GetParent()); + + const SvxTextLeftMarginItem & rOldItem( + static_cast(GetItemSet().GetParent()->Get(nWhich))); + + if (m_xLeftIndent->IsRelative()) + { + item.SetTextLeft(rOldItem.GetTextLeft(), + static_cast(m_xLeftIndent->get_value(FieldUnit::NONE))); + } + else + { + item.SetTextLeft(m_xLeftIndent->GetCoreValue(eUnit)); + } + } + else + { + item.SetTextLeft(m_xLeftIndent->GetCoreValue(eUnit)); + } + if (!pOld || *static_cast(pOld) != item + || SfxItemState::DONTCARE == GetItemSet().GetItemState(nWhich)) + { + rOutSet->Put(item); + bModified = true; + } + } + + if (m_bSplitLRSpace && m_xRightIndent->get_value_changed_from_saved()) + { + nWhich = GetWhich(SID_ATTR_PARA_RIGHTSPACE); + MapUnit const eUnit = pPool->GetMetric(nWhich); + SvxRightMarginItem item(nWhich); + pOld = GetOldItem(*rOutSet, SID_ATTR_PARA_RIGHTSPACE); + + if (bRelativeMode) + { + assert(GetItemSet().GetParent()); + + const SvxRightMarginItem & rOldItem( + static_cast(GetItemSet().GetParent()->Get(nWhich))); + + if (m_xRightIndent->IsRelative()) + { + item.SetRight(rOldItem.GetRight(), + static_cast(m_xRightIndent->get_value(FieldUnit::NONE))); + } + else + { + item.SetRight(m_xRightIndent->GetCoreValue(eUnit)); + } + } + else + { + item.SetRight(m_xRightIndent->GetCoreValue(eUnit)); + } + if (!pOld || *static_cast(pOld) != item + || SfxItemState::DONTCARE == GetItemSet().GetItemState(nWhich)) + { + rOutSet->Put(item); + bModified = true; + } + } + + if (m_bSplitLRSpace && (m_xFLineIndent->get_value_changed_from_saved() + || m_xAutoCB->get_state_changed_from_saved())) + { + nWhich = GetWhich(SID_ATTR_PARA_FIRSTLINESPACE); + MapUnit const eUnit = pPool->GetMetric(nWhich); + SvxFirstLineIndentItem item(nWhich); + pOld = GetOldItem(*rOutSet, SID_ATTR_PARA_FIRSTLINESPACE); + + if (bRelativeMode) + { + assert(GetItemSet().GetParent()); + + const SvxFirstLineIndentItem & rOldItem( + static_cast(GetItemSet().GetParent()->Get(nWhich))); + + if (m_xFLineIndent->IsRelative()) + { + item.SetTextFirstLineOffset(rOldItem.GetTextFirstLineOffset(), + static_cast(m_xFLineIndent->get_value(FieldUnit::NONE))); + } + else + { + item.SetTextFirstLineOffset(static_cast(m_xFLineIndent->GetCoreValue(eUnit))); + } + } + else + { + item.SetTextFirstLineOffset(static_cast(m_xFLineIndent->GetCoreValue(eUnit))); + } + item.SetAutoFirst(m_xAutoCB->get_active()); + if (item.GetTextFirstLineOffset() < 0) + { + bNullTab = true; + } + + if (!pOld || *static_cast(pOld) != item + || SfxItemState::DONTCARE == GetItemSet().GetItemState(nWhich)) + { + rOutSet->Put(item); + bModified = true; + } + } + + if (!m_bSplitLRSpace && + (m_xLeftIndent->get_value_changed_from_saved() || m_xFLineIndent->get_value_changed_from_saved() || m_xRightIndent->get_value_changed_from_saved() || - m_xAutoCB->get_state_changed_from_saved() ) + m_xAutoCB->get_state_changed_from_saved())) { nWhich = GetWhich( SID_ATTR_LRSPACE ); MapUnit eUnit = pPool->GetMetric( nWhich ); @@ -436,10 +553,115 @@ void SvxStdParagraphTabPage::Reset( const SfxItemSet* rSet ) SetFieldUnit(*m_xLineDistAtMetricBox, eFUnit); } + sal_uInt16 const nWhichFL(GetWhich(SID_ATTR_PARA_FIRSTLINESPACE)); + m_bSplitLRSpace = (nWhichFL != SID_ATTR_PARA_FIRSTLINESPACE); + SfxItemState const eItemStateFL(rSet->GetItemState(nWhichFL)); + sal_uInt16 const nWhichLM(GetWhich(SID_ATTR_PARA_LEFTSPACE)); + SfxItemState const eItemStateLM(rSet->GetItemState(nWhichLM)); + sal_uInt16 const nWhichRM(GetWhich(SID_ATTR_PARA_RIGHTSPACE)); + SfxItemState const eItemStateRM(rSet->GetItemState(nWhichRM)); + + if (m_bSplitLRSpace && SfxItemState::DEFAULT <= eItemStateLM) + { + const SvxTextLeftMarginItem & rOldLeftMargin( + static_cast(rSet->Get(nWhichLM))); + + MapUnit const eUnit = pPool->GetMetric(nWhichLM); + + if (bRelativeMode) + { + if (rOldLeftMargin.GetPropLeft() != 100) + { + m_xLeftIndent->SetRelative( true ); + m_xLeftIndent->set_value(rOldLeftMargin.GetPropLeft(), FieldUnit::NONE); + } + else + { + m_xLeftIndent->SetRelative(false); + m_xLeftIndent->SetFieldUnit(eFUnit); + m_xLeftIndent->SetMetricValue(rOldLeftMargin.GetTextLeft(), eUnit); + } + } + else + { + m_xLeftIndent->SetMetricValue(rOldLeftMargin.GetTextLeft(), eUnit); + } + } + else if (m_bSplitLRSpace) + { + m_xLeftIndent->set_text(OUString()); + } + + if (m_bSplitLRSpace && SfxItemState::DEFAULT <= eItemStateRM) + { + const SvxRightMarginItem & rOldRightMargin( + static_cast(rSet->Get(nWhichRM))); + + MapUnit const eUnit = pPool->GetMetric(nWhichRM); + + if (bRelativeMode) + { + if (rOldRightMargin.GetPropRight() != 100) + { + m_xRightIndent->SetRelative( true ); + m_xRightIndent->set_value(rOldRightMargin.GetPropRight(), FieldUnit::NONE); + } + else + { + m_xRightIndent->SetRelative(false); + m_xRightIndent->SetFieldUnit(eFUnit); + m_xRightIndent->SetMetricValue(rOldRightMargin.GetRight(), eUnit); + } + } + else + { + m_xRightIndent->SetMetricValue(rOldRightMargin.GetRight(), eUnit); + } + } + else if (m_bSplitLRSpace) + { + m_xRightIndent->set_text(OUString()); + } + + if (m_bSplitLRSpace && SfxItemState::DEFAULT <= eItemStateFL) + { + const SvxFirstLineIndentItem & rOldFirstLine( + static_cast(rSet->Get(nWhichFL))); + + MapUnit const eUnit = pPool->GetMetric(nWhichFL); + + if (bRelativeMode) + { + if (rOldFirstLine.GetPropTextFirstLineOffset() != 100) + { + m_xFLineIndent->SetRelative(true); + m_xFLineIndent->set_value(rOldFirstLine.GetPropTextFirstLineOffset(), FieldUnit::NONE); + } + else + { + m_xFLineIndent->SetRelative(false); + m_xFLineIndent->set_min(-9999, FieldUnit::NONE); + m_xFLineIndent->SetFieldUnit(eFUnit); + m_xFLineIndent->SetMetricValue(rOldFirstLine.GetTextFirstLineOffset(), eUnit); + } + m_xAutoCB->set_active(rOldFirstLine.IsAutoFirst()); + } + else + { + m_xFLineIndent->SetMetricValue(rOldFirstLine.GetTextFirstLineOffset(), eUnit); + m_xAutoCB->set_active(rOldFirstLine.IsAutoFirst()); + } + AutoHdl_Impl(*m_xAutoCB); + } + else if (m_bSplitLRSpace) + { + m_xFLineIndent->set_text(OUString()); + } + sal_uInt16 _nWhich = GetWhich( SID_ATTR_LRSPACE ); SfxItemState eItemState = rSet->GetItemState( _nWhich ); - if ( eItemState >= SfxItemState::DEFAULT ) + if (!m_bSplitLRSpace && SfxItemState::DEFAULT <= eItemState) { MapUnit eUnit = pPool->GetMetric( _nWhich ); @@ -498,7 +720,7 @@ void SvxStdParagraphTabPage::Reset( const SfxItemSet* rSet ) } AutoHdl_Impl(*m_xAutoCB); } - else + else if (!m_bSplitLRSpace) { m_xLeftIndent->set_text(OUString()); m_xRightIndent->set_text(OUString()); diff --git a/sw/inc/format.hxx b/sw/inc/format.hxx index c5b599d36d31..9313b863dfbb 100644 --- a/sw/inc/format.hxx +++ b/sw/inc/format.hxx @@ -212,6 +212,12 @@ public: inline const SwFormatAnchor &GetAnchor( bool = true ) const; inline const SwFormatCol &GetCol( bool = true ) const; inline const SvxPaperBinItem &GetPaperBin( bool = true ) const; + inline const SvxLeftMarginItem & GetLeftMargin(bool = true) const; + inline const SvxTextLeftMarginItem &GetTextLeftMargin(bool = true) const; + inline const SvxFirstLineIndentItem &GetFirstLineIndent(bool = true) const; + inline const SvxRightMarginItem & GetRightMargin(bool = true) const; + inline const SvxGutterLeftMarginItem &GetGutterLeftMargin(bool = true) const; + inline const SvxGutterRightMarginItem &GetGutterRightMargin(bool = true) const; inline const SvxLRSpaceItem &GetLRSpace( bool = true ) const; inline const SvxULSpaceItem &GetULSpace( bool = true ) const; inline const SwFormatContent &GetContent( bool = true ) const; diff --git a/sw/inc/frmatr.hxx b/sw/inc/frmatr.hxx index 51dda4f4a5d0..10dd955ceeb7 100644 --- a/sw/inc/frmatr.hxx +++ b/sw/inc/frmatr.hxx @@ -41,6 +41,18 @@ // Implementation of FrameAttribute methods of SwAttrSet. inline const SvxPaperBinItem &SwAttrSet::GetPaperBin(bool bInP) const { return Get( RES_PAPER_BIN,bInP); } +inline const SvxLeftMarginItem& SwAttrSet::GetLeftMargin(bool const bInP) const + { return Get(RES_MARGIN_LEFT, bInP); } +inline const SvxTextLeftMarginItem& SwAttrSet::GetTextLeftMargin(bool const bInP) const + { return Get(RES_MARGIN_TEXTLEFT, bInP); } +inline const SvxFirstLineIndentItem& SwAttrSet::GetFirstLineIndent(bool const bInP) const + { return Get(RES_MARGIN_FIRSTLINE, bInP); } +inline const SvxRightMarginItem& SwAttrSet::GetRightMargin(bool const bInP) const + { return Get(RES_MARGIN_RIGHT, bInP); } +inline const SvxGutterLeftMarginItem& SwAttrSet::GetGutterLeftMargin(bool const bInP) const + { return Get(RES_MARGIN_GUTTER, bInP); } +inline const SvxGutterRightMarginItem& SwAttrSet::GetGutterRightMargin(bool const bInP) const + { return Get(RES_MARGIN_GUTTER_RIGHT, bInP); } inline const SvxLRSpaceItem &SwAttrSet::GetLRSpace(bool bInP) const { return Get( RES_LR_SPACE,bInP); } inline const SvxULSpaceItem &SwAttrSet::GetULSpace(bool bInP) const @@ -71,6 +83,18 @@ inline const SdrTextVertAdjustItem &SwAttrSet::GetTextVertAdjust(bool bInP) cons // Implementation of FrameAttribute methods of SwFormat. inline const SvxPaperBinItem &SwFormat::GetPaperBin(bool bInP) const { return m_aSet.GetPaperBin(bInP); } +inline const SvxLeftMarginItem& SwFormat::GetLeftMargin(bool bInP) const + { return m_aSet.GetLeftMargin(bInP); } +inline const SvxTextLeftMarginItem& SwFormat::GetTextLeftMargin(bool const bInP) const + { return m_aSet.GetTextLeftMargin(bInP); } +inline const SvxFirstLineIndentItem& SwFormat::GetFirstLineIndent(bool const bInP) const + { return m_aSet.GetFirstLineIndent(bInP); } +inline const SvxRightMarginItem& SwFormat::GetRightMargin(bool const bInP) const + { return m_aSet.GetRightMargin(bInP); } +inline const SvxGutterLeftMarginItem& SwFormat::GetGutterLeftMargin(bool const bInP) const + { return m_aSet.GetGutterLeftMargin(bInP); } +inline const SvxGutterRightMarginItem& SwFormat::GetGutterRightMargin(bool const bInP) const + { return m_aSet.GetGutterRightMargin(bInP); } inline const SvxLRSpaceItem &SwFormat::GetLRSpace(bool bInP) const { return m_aSet.GetLRSpace(bInP); } inline const SvxULSpaceItem &SwFormat::GetULSpace(bool bInP) const diff --git a/sw/inc/hintids.hxx b/sw/inc/hintids.hxx index 05ee37676181..4be4a5182585 100644 --- a/sw/inc/hintids.hxx +++ b/sw/inc/hintids.hxx @@ -39,6 +39,12 @@ class SwMsgPoolItem; class SwPtrMsgPoolItem; class SfxBoolItem; class SvxColorItem; +class SvxLeftMarginItem; +class SvxTextLeftMarginItem; +class SvxFirstLineIndentItem; +class SvxRightMarginItem; +class SvxGutterLeftMarginItem; +class SvxGutterRightMarginItem; class SvxLRSpaceItem; class SdrTextVertAdjustItem; class SfxGrabBagItem; @@ -326,108 +332,113 @@ constexpr sal_uInt16 RES_FRMATR_BEGIN(RES_PARATR_LIST_END); constexpr TypedWhichId RES_FILL_ORDER(RES_FRMATR_BEGIN); constexpr TypedWhichId RES_FRM_SIZE(89); constexpr TypedWhichId RES_PAPER_BIN(90); -constexpr TypedWhichId RES_LR_SPACE(91); -constexpr TypedWhichId RES_UL_SPACE(92); -constexpr TypedWhichId RES_PAGEDESC(93); -constexpr TypedWhichId RES_BREAK(94); -constexpr TypedWhichId RES_CNTNT(95); -constexpr TypedWhichId RES_HEADER(96); -constexpr TypedWhichId RES_FOOTER(97); -constexpr TypedWhichId RES_PRINT(98); -constexpr TypedWhichId RES_OPAQUE(99); -constexpr TypedWhichId RES_PROTECT(100); -constexpr TypedWhichId RES_SURROUND(101); -constexpr TypedWhichId RES_VERT_ORIENT(102); -constexpr TypedWhichId RES_HORI_ORIENT(103); -constexpr TypedWhichId RES_ANCHOR(104); -constexpr TypedWhichId RES_BACKGROUND(105); -constexpr TypedWhichId RES_BOX(106); -constexpr TypedWhichId RES_SHADOW(107); -constexpr TypedWhichId RES_FRMMACRO(108); -constexpr TypedWhichId RES_COL(109); -constexpr TypedWhichId RES_KEEP(110); -constexpr TypedWhichId RES_URL(111); -constexpr TypedWhichId RES_EDIT_IN_READONLY(112); -constexpr TypedWhichId RES_LAYOUT_SPLIT(113); -constexpr TypedWhichId RES_CHAIN(114); -constexpr TypedWhichId RES_TEXTGRID(115); -constexpr TypedWhichId RES_LINENUMBER(116); -constexpr TypedWhichId RES_FTN_AT_TXTEND(117); -constexpr TypedWhichId RES_END_AT_TXTEND(118); -constexpr TypedWhichId RES_COLUMNBALANCE(119); -constexpr TypedWhichId RES_FRAMEDIR(120); -constexpr TypedWhichId RES_HEADER_FOOTER_EAT_SPACING(121); -constexpr TypedWhichId RES_ROW_SPLIT(122); -constexpr TypedWhichId RES_FLY_SPLIT(123); -constexpr TypedWhichId RES_FOLLOW_TEXT_FLOW(124); -constexpr TypedWhichId RES_COLLAPSING_BORDERS(125); -constexpr TypedWhichId RES_WRAP_INFLUENCE_ON_OBJPOS(126); -constexpr TypedWhichId RES_AUTO_STYLE(127); -constexpr TypedWhichId RES_FRMATR_STYLE_NAME(128); -constexpr TypedWhichId RES_FRMATR_CONDITIONAL_STYLE_NAME(129); -constexpr TypedWhichId RES_FRMATR_GRABBAG(130); -constexpr TypedWhichId RES_TEXT_VERT_ADJUST(131); -constexpr TypedWhichId RES_BACKGROUND_FULL_SIZE(132); -constexpr TypedWhichId RES_RTL_GUTTER(133); -constexpr TypedWhichId RES_DECORATIVE(134); -constexpr sal_uInt16 RES_FRMATR_END(135); +constexpr TypedWhichId RES_MARGIN_FIRSTLINE(91); +constexpr TypedWhichId RES_MARGIN_TEXTLEFT(92); +constexpr TypedWhichId RES_MARGIN_RIGHT(93); +constexpr TypedWhichId RES_MARGIN_LEFT(94); +constexpr TypedWhichId RES_MARGIN_GUTTER(95); +constexpr TypedWhichId RES_MARGIN_GUTTER_RIGHT(96); +constexpr TypedWhichId RES_LR_SPACE(97); +constexpr TypedWhichId RES_UL_SPACE(98); +constexpr TypedWhichId RES_PAGEDESC(99); +constexpr TypedWhichId RES_BREAK(100); +constexpr TypedWhichId RES_CNTNT(101); +constexpr TypedWhichId RES_HEADER(102); +constexpr TypedWhichId RES_FOOTER(103); +constexpr TypedWhichId RES_PRINT(104); +constexpr TypedWhichId RES_OPAQUE(105); +constexpr TypedWhichId RES_PROTECT(106); +constexpr TypedWhichId RES_SURROUND(107); +constexpr TypedWhichId RES_VERT_ORIENT(108); +constexpr TypedWhichId RES_HORI_ORIENT(109); +constexpr TypedWhichId RES_ANCHOR(110); +constexpr TypedWhichId RES_BACKGROUND(111); +constexpr TypedWhichId RES_BOX(112); +constexpr TypedWhichId RES_SHADOW(113); +constexpr TypedWhichId RES_FRMMACRO(114); +constexpr TypedWhichId RES_COL(115); +constexpr TypedWhichId RES_KEEP(116); +constexpr TypedWhichId RES_URL(117); +constexpr TypedWhichId RES_EDIT_IN_READONLY(118); +constexpr TypedWhichId RES_LAYOUT_SPLIT(119); +constexpr TypedWhichId RES_CHAIN(120); +constexpr TypedWhichId RES_TEXTGRID(121); +constexpr TypedWhichId RES_LINENUMBER(122); +constexpr TypedWhichId RES_FTN_AT_TXTEND(123); +constexpr TypedWhichId RES_END_AT_TXTEND(124); +constexpr TypedWhichId RES_COLUMNBALANCE(125); +constexpr TypedWhichId RES_FRAMEDIR(126); +constexpr TypedWhichId RES_HEADER_FOOTER_EAT_SPACING(127); +constexpr TypedWhichId RES_ROW_SPLIT(128); +constexpr TypedWhichId RES_FLY_SPLIT(129); +constexpr TypedWhichId RES_FOLLOW_TEXT_FLOW(130); +constexpr TypedWhichId RES_COLLAPSING_BORDERS(131); +constexpr TypedWhichId RES_WRAP_INFLUENCE_ON_OBJPOS(132); +constexpr TypedWhichId RES_AUTO_STYLE(133); +constexpr TypedWhichId RES_FRMATR_STYLE_NAME(134); +constexpr TypedWhichId RES_FRMATR_CONDITIONAL_STYLE_NAME(135); +constexpr TypedWhichId RES_FRMATR_GRABBAG(136); +constexpr TypedWhichId RES_TEXT_VERT_ADJUST(137); +constexpr TypedWhichId RES_BACKGROUND_FULL_SIZE(138); +constexpr TypedWhichId RES_RTL_GUTTER(139); +constexpr TypedWhichId RES_DECORATIVE(140); +constexpr sal_uInt16 RES_FRMATR_END(141); constexpr sal_uInt16 RES_GRFATR_BEGIN(RES_FRMATR_END); constexpr TypedWhichId RES_GRFATR_MIRRORGRF(RES_GRFATR_BEGIN); -constexpr TypedWhichId RES_GRFATR_CROPGRF(136); - -constexpr TypedWhichId RES_GRFATR_ROTATION(137); -constexpr TypedWhichId RES_GRFATR_LUMINANCE(138); -constexpr TypedWhichId RES_GRFATR_CONTRAST(139); -constexpr TypedWhichId RES_GRFATR_CHANNELR(140); -constexpr TypedWhichId RES_GRFATR_CHANNELG(141); -constexpr TypedWhichId RES_GRFATR_CHANNELB(142); -constexpr TypedWhichId RES_GRFATR_GAMMA(143); -constexpr TypedWhichId RES_GRFATR_INVERT(144); -constexpr TypedWhichId RES_GRFATR_TRANSPARENCY(145); -constexpr TypedWhichId RES_GRFATR_DRAWMODE(146); - -constexpr TypedWhichId RES_GRFATR_DUMMY3(147); -constexpr TypedWhichId RES_GRFATR_DUMMY4(148); -constexpr TypedWhichId RES_GRFATR_DUMMY5(149); -constexpr sal_uInt16 RES_GRFATR_END(150); +constexpr TypedWhichId RES_GRFATR_CROPGRF(142); + +constexpr TypedWhichId RES_GRFATR_ROTATION(143); +constexpr TypedWhichId RES_GRFATR_LUMINANCE(144); +constexpr TypedWhichId RES_GRFATR_CONTRAST(145); +constexpr TypedWhichId RES_GRFATR_CHANNELR(146); +constexpr TypedWhichId RES_GRFATR_CHANNELG(147); +constexpr TypedWhichId RES_GRFATR_CHANNELB(148); +constexpr TypedWhichId RES_GRFATR_GAMMA(149); +constexpr TypedWhichId RES_GRFATR_INVERT(150); +constexpr TypedWhichId RES_GRFATR_TRANSPARENCY(151); +constexpr TypedWhichId RES_GRFATR_DRAWMODE(152); + +constexpr TypedWhichId RES_GRFATR_DUMMY3(153); +constexpr TypedWhichId RES_GRFATR_DUMMY4(154); +constexpr TypedWhichId RES_GRFATR_DUMMY5(155); +constexpr sal_uInt16 RES_GRFATR_END(156); constexpr sal_uInt16 RES_BOXATR_BEGIN(RES_GRFATR_END); -constexpr TypedWhichId RES_BOXATR_FORMAT(RES_BOXATR_BEGIN); // 150 -constexpr TypedWhichId RES_BOXATR_FORMULA(151); -constexpr TypedWhichId RES_BOXATR_VALUE(152); -constexpr sal_uInt16 RES_BOXATR_END(153); +constexpr TypedWhichId RES_BOXATR_FORMAT(RES_BOXATR_BEGIN); +constexpr TypedWhichId RES_BOXATR_FORMULA(157); +constexpr TypedWhichId RES_BOXATR_VALUE(158); +constexpr sal_uInt16 RES_BOXATR_END(159); constexpr sal_uInt16 RES_UNKNOWNATR_BEGIN(RES_BOXATR_END); -constexpr TypedWhichId - RES_UNKNOWNATR_CONTAINER(RES_UNKNOWNATR_BEGIN); // 153 -constexpr sal_uInt16 RES_UNKNOWNATR_END(154); +constexpr TypedWhichId RES_UNKNOWNATR_CONTAINER(RES_UNKNOWNATR_BEGIN); +constexpr sal_uInt16 RES_UNKNOWNATR_END(160); constexpr sal_uInt16 POOLATTR_END(RES_UNKNOWNATR_END); // Format IDs constexpr sal_uInt16 RES_FMT_BEGIN(RES_UNKNOWNATR_END); -constexpr TypedWhichId RES_CHRFMT(RES_FMT_BEGIN); // 154 -constexpr TypedWhichId RES_FRMFMT(155); -constexpr TypedWhichId RES_FLYFRMFMT(156); -constexpr TypedWhichId RES_TXTFMTCOLL(157); -constexpr TypedWhichId RES_GRFFMTCOLL(158); -constexpr TypedWhichId RES_DRAWFRMFMT(159); -constexpr TypedWhichId RES_CONDTXTFMTCOLL(160); -constexpr sal_uInt16 RES_FMT_END(161); +constexpr TypedWhichId RES_CHRFMT(RES_FMT_BEGIN); +constexpr TypedWhichId RES_FRMFMT(161); +constexpr TypedWhichId RES_FLYFRMFMT(162); +constexpr TypedWhichId RES_TXTFMTCOLL(163); +constexpr TypedWhichId RES_GRFFMTCOLL(164); +constexpr TypedWhichId RES_DRAWFRMFMT(165); +constexpr TypedWhichId RES_CONDTXTFMTCOLL(166); +constexpr sal_uInt16 RES_FMT_END(167); // ID's for Messages in the Formats constexpr sal_uInt16 RES_FORMAT_MSG_BEGIN(RES_FMT_END); -constexpr TypedWhichId RES_OBJECTDYING(RES_FORMAT_MSG_BEGIN); // 161 -constexpr TypedWhichId RES_FMT_CHG(162); -constexpr TypedWhichId RES_ATTRSET_CHG(163); -constexpr TypedWhichId RES_UPDATE_ATTR(167); -constexpr TypedWhichId RES_REFMARKFLD_UPDATE(168); -constexpr TypedWhichId RES_DOCPOS_UPDATE(169); -constexpr TypedWhichId RES_TABLEFML_UPDATE(170); -constexpr TypedWhichId RES_UPDATEDDETBL(171); -constexpr TypedWhichId RES_TBLHEADLINECHG(172); -constexpr TypedWhichId RES_AUTOFMT_DOCNODE(173); +constexpr TypedWhichId RES_OBJECTDYING(RES_FORMAT_MSG_BEGIN); // 167 +constexpr TypedWhichId RES_FMT_CHG(168); +constexpr TypedWhichId RES_ATTRSET_CHG(169); +constexpr TypedWhichId RES_UPDATE_ATTR(170); +constexpr TypedWhichId RES_REFMARKFLD_UPDATE(171); +constexpr TypedWhichId RES_DOCPOS_UPDATE(172); +constexpr TypedWhichId RES_TABLEFML_UPDATE(173); +constexpr TypedWhichId RES_UPDATEDDETBL(174); +constexpr TypedWhichId RES_TBLHEADLINECHG(175); +constexpr TypedWhichId RES_AUTOFMT_DOCNODE(176); constexpr TypedWhichId RES_HIDDENPARA_PRINT(178); constexpr TypedWhichId RES_VIRTPAGENUM_INFO(180); constexpr TypedWhichId RES_REMOVE_UNO_OBJECT(181); diff --git a/sw/inc/ndtxt.hxx b/sw/inc/ndtxt.hxx index f28f2faf1e02..0ea123233d69 100644 --- a/sw/inc/ndtxt.hxx +++ b/sw/inc/ndtxt.hxx @@ -41,7 +41,8 @@ class SfxHint; class SwNumRule; class SwNodeNum; -class SvxLRSpaceItem; +class SvxFirstLineIndentItem; +class SvxTextLeftMarginItem; class SwXParagraph; namespace utl { @@ -535,7 +536,9 @@ public: SwTwips GetAdditionalIndentForStartingNewList() const; - void ClearLRSpaceItemDueToListLevelIndents( std::shared_ptr& o_rLRSpaceItem ) const; + void ClearLRSpaceItemDueToListLevelIndents( + std::unique_ptr& o_rFirstLineItem, + std::unique_ptr& o_rTextLeftMarginItem) const; /** return left margin for tab stop position calculation diff --git a/sw/inc/swatrset.hxx b/sw/inc/swatrset.hxx index 6fd2662186d8..96a7cc833e55 100644 --- a/sw/inc/swatrset.hxx +++ b/sw/inc/swatrset.hxx @@ -56,6 +56,12 @@ class SvxCharHiddenItem; class SwFormatFillOrder; class SwFormatFrameSize; class SvxPaperBinItem; +class SvxLeftMarginItem; +class SvxTextLeftMarginItem; +class SvxFirstLineIndentItem; +class SvxRightMarginItem; +class SvxGutterLeftMarginItem; +class SvxGutterRightMarginItem; class SvxLRSpaceItem; class SvxULSpaceItem; class SwFormatContent; @@ -239,6 +245,12 @@ public: inline const SwFormatFillOrder &GetFillOrder( bool = true ) const; inline const SwFormatFrameSize &GetFrameSize( bool = true ) const; inline const SvxPaperBinItem &GetPaperBin( bool = true ) const; + inline const SvxLeftMarginItem & GetLeftMargin(bool = true) const; + inline const SvxTextLeftMarginItem &GetTextLeftMargin(bool = true) const; + inline const SvxFirstLineIndentItem &GetFirstLineIndent(bool = true) const; + inline const SvxRightMarginItem & GetRightMargin(bool = true) const; + inline const SvxGutterLeftMarginItem &GetGutterLeftMargin(bool = true) const; + inline const SvxGutterRightMarginItem &GetGutterRightMargin(bool = true) const; inline const SvxLRSpaceItem &GetLRSpace( bool = true ) const; inline const SvxULSpaceItem &GetULSpace( bool = true ) const; inline const SwFormatContent &GetContent( bool = true ) const; diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx index 84a7502191d0..c3f20d2f1390 100644 --- a/sw/qa/extras/uiwriter/uiwriter2.cxx +++ b/sw/qa/extras/uiwriter/uiwriter2.cxx @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -151,9 +152,12 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf101534) // Go to the second paragraph, assert that we have margins as direct // formatting. pWrtShell->Down(/*bSelect=*/false); - SfxItemSet aSet(pWrtShell->GetAttrPool(), svl::Items); + SfxItemSet aSet(pWrtShell->GetAttrPool(), + svl::Items); pWrtShell->GetCurAttr(aSet); - CPPUNIT_ASSERT(aSet.HasItem(RES_LR_SPACE)); + CPPUNIT_ASSERT(!aSet.HasItem(RES_MARGIN_FIRSTLINE)); + CPPUNIT_ASSERT(aSet.HasItem(RES_MARGIN_TEXTLEFT)); + CPPUNIT_ASSERT_EQUAL(::tools::Long(0), aSet.GetItem(RES_MARGIN_TEXTLEFT)->GetTextLeft()); // Make sure that direct formatting is preserved during paste. pWrtShell->EndPara(/*bSelect=*/false); @@ -162,7 +166,9 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf101534) aSet.ClearItem(); pWrtShell->GetCurAttr(aSet); // This failed, direct formatting was lost. - CPPUNIT_ASSERT(aSet.HasItem(RES_LR_SPACE)); + CPPUNIT_ASSERT(!aSet.HasItem(RES_MARGIN_FIRSTLINE)); + CPPUNIT_ASSERT(aSet.HasItem(RES_MARGIN_TEXTLEFT)); + CPPUNIT_ASSERT_EQUAL(::tools::Long(0), aSet.GetItem(RES_MARGIN_TEXTLEFT)->GetTextLeft()); } CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testRedlineMoveInsertInDelete) diff --git a/sw/source/core/access/accpara.cxx b/sw/source/core/access/accpara.cxx index 67b12571f412..70eec47e51a2 100644 --- a/sw/source/core/access/accpara.cxx +++ b/sw/source/core/access/accpara.cxx @@ -1751,7 +1751,8 @@ void SwAccessibleParagraph::_getSupplementalAttributesImpl( RES_PARATR_TABSTOP, RES_PARATR_TABSTOP, RES_PARATR_NUMRULE, RES_PARATR_NUMRULE, RES_PARATR_LIST_BEGIN, RES_PARATR_LIST_END - 1, - RES_LR_SPACE, RES_UL_SPACE> + RES_MARGIN_FIRSTLINE, RES_MARGIN_RIGHT, + RES_UL_SPACE, RES_UL_SPACE> aSet( const_cast(pTextNode->GetDoc().GetAttrPool()) ); if ( pTextNode->HasBullet() || pTextNode->HasNumber() ) @@ -1759,7 +1760,9 @@ void SwAccessibleParagraph::_getSupplementalAttributesImpl( aSet.Put( pTextNode->GetAttr(RES_PARATR_LIST_LEVEL) ); } aSet.Put( pTextNode->SwContentNode::GetAttr(RES_UL_SPACE) ); - aSet.Put( pTextNode->SwContentNode::GetAttr(RES_LR_SPACE) ); + aSet.Put( pTextNode->SwContentNode::GetAttr(RES_MARGIN_FIRSTLINE) ); + aSet.Put( pTextNode->SwContentNode::GetAttr(RES_MARGIN_TEXTLEFT) ); + aSet.Put( pTextNode->SwContentNode::GetAttr(RES_MARGIN_RIGHT) ); aSet.Put( pTextNode->SwContentNode::GetAttr(RES_PARATR_ADJUST) ); tAccParaPropValMap aSupplementalAttrSeq; diff --git a/sw/source/core/attr/BorderCacheOwner.cxx b/sw/source/core/attr/BorderCacheOwner.cxx index af13686c5afd..dd71b694931f 100644 --- a/sw/source/core/attr/BorderCacheOwner.cxx +++ b/sw/source/core/attr/BorderCacheOwner.cxx @@ -29,6 +29,9 @@ void BorderCacheOwner::InvalidateInSwCache(const sal_uInt16 nWhich) case RES_FMT_CHG: case RES_ATTRSET_CHG: case RES_UL_SPACE: + case RES_MARGIN_FIRSTLINE: + case RES_MARGIN_TEXTLEFT: + case RES_MARGIN_RIGHT: case RES_LR_SPACE: case RES_BOX: case RES_SHADOW: diff --git a/sw/source/core/bastyp/init.cxx b/sw/source/core/bastyp/init.cxx index feadd5c9298d..52e452bb4aa0 100644 --- a/sw/source/core/bastyp/init.cxx +++ b/sw/source/core/bastyp/init.cxx @@ -357,6 +357,12 @@ SfxItemInfo aSlotTab[] = { 0, true }, // RES_FILL_ORDER { 0, true }, // RES_FRM_SIZE { SID_ATTR_PAGE_PAPERBIN, true }, // RES_PAPER_BIN + { SID_ATTR_PARA_FIRSTLINESPACE, true }, // RES_MARGIN_FIRSTLINE + { SID_ATTR_PARA_LEFTSPACE, true }, // RES_MARGIN_TEXTLEFT + { SID_ATTR_PARA_RIGHTSPACE, true }, // RES_MARGIN_RIGHT + { 0, true }, // RES_MARGIN_LEFT + { 0, true }, // RES_MARGIN_GUTTER + { 0, true }, // RES_MARGIN_GUTTER_RIGHT { SID_ATTR_LRSPACE, true }, // RES_LR_SPACE { SID_ATTR_ULSPACE, true }, // RES_UL_SPACE { 0, false }, // RES_PAGEDESC @@ -562,6 +568,12 @@ void InitCore() aAttrTab[ RES_FILL_ORDER- POOLATTR_BEGIN ] = new SwFormatFillOrder; aAttrTab[ RES_FRM_SIZE- POOLATTR_BEGIN ] = new SwFormatFrameSize; aAttrTab[ RES_PAPER_BIN- POOLATTR_BEGIN ] = new SvxPaperBinItem( RES_PAPER_BIN ); + aAttrTab[ RES_MARGIN_FIRSTLINE - POOLATTR_BEGIN ] = new SvxFirstLineIndentItem(RES_MARGIN_FIRSTLINE); + aAttrTab[ RES_MARGIN_TEXTLEFT - POOLATTR_BEGIN ] = new SvxTextLeftMarginItem(RES_MARGIN_TEXTLEFT); + aAttrTab[ RES_MARGIN_RIGHT - POOLATTR_BEGIN ] = new SvxRightMarginItem(RES_MARGIN_RIGHT); + aAttrTab[ RES_MARGIN_LEFT - POOLATTR_BEGIN ] = new SvxLeftMarginItem(RES_MARGIN_LEFT); + aAttrTab[ RES_MARGIN_GUTTER - POOLATTR_BEGIN ] = new SvxGutterLeftMarginItem(RES_MARGIN_GUTTER); + aAttrTab[ RES_MARGIN_GUTTER_RIGHT - POOLATTR_BEGIN ] = new SvxGutterRightMarginItem(RES_MARGIN_GUTTER_RIGHT); aAttrTab[ RES_LR_SPACE- POOLATTR_BEGIN ] = new SvxLRSpaceItem( RES_LR_SPACE ); aAttrTab[ RES_UL_SPACE- POOLATTR_BEGIN ] = new SvxULSpaceItem( RES_UL_SPACE ); aAttrTab[ RES_PAGEDESC- POOLATTR_BEGIN ] = new SwFormatPageDesc; diff --git a/sw/source/core/crsr/crstrvl.cxx b/sw/source/core/crsr/crstrvl.cxx index 966127cece62..c5c0c741f5dd 100644 --- a/sw/source/core/crsr/crstrvl.cxx +++ b/sw/source/core/crsr/crstrvl.cxx @@ -2374,13 +2374,16 @@ bool SwCursorShell::SetShadowCursorPos( const Point& rPt, SwFillMode eFillMode ) case SwFillMode::Indent: if( nullptr != (pCNd = aPos.GetNode().GetContentNode() )) { + assert(pCNd->IsTextNode()); // ??? SfxItemSetFixed< RES_PARATR_ADJUST, RES_PARATR_ADJUST, - RES_LR_SPACE, RES_LR_SPACE> aSet( GetDoc()->GetAttrPool() ); - SvxLRSpaceItem aLR(pCNd->GetAttr(RES_LR_SPACE)); - aLR.SetTextLeft( aFPos.nTabCnt ); - aLR.SetTextFirstLineOffset( 0 ); - aSet.Put( aLR ); + RES_MARGIN_FIRSTLINE, RES_MARGIN_TEXTLEFT> aSet(GetDoc()->GetAttrPool()); + SvxFirstLineIndentItem firstLine(pCNd->GetAttr(RES_MARGIN_FIRSTLINE)); + SvxTextLeftMarginItem leftMargin(pCNd->GetAttr(RES_MARGIN_TEXTLEFT)); + firstLine.SetTextFirstLineOffset(0); + leftMargin.SetTextLeft(aFPos.nTabCnt); + aSet.Put(firstLine); + aSet.Put(leftMargin); const SvxAdjustItem& rAdj = pCNd->GetAttr(RES_PARATR_ADJUST); if( SvxAdjust::Left != rAdj.GetAdjust() ) diff --git a/sw/source/core/doc/DocumentStylePoolManager.cxx b/sw/source/core/doc/DocumentStylePoolManager.cxx index 9877dc785ccb..ad0c00ff42c0 100644 --- a/sw/source/core/doc/DocumentStylePoolManager.cxx +++ b/sw/source/core/doc/DocumentStylePoolManager.cxx @@ -210,11 +210,13 @@ namespace SvxNumberFormat::LABEL_WIDTH_AND_POSITION && ( rNFormat.GetAbsLSpace() || rNFormat.GetFirstLineOffset() ) ) { - SvxLRSpaceItem aLR( pColl->GetFormatAttr( RES_LR_SPACE ) ); - aLR.SetTextFirstLineOffsetValue( rNFormat.GetFirstLineOffset() ); + SvxFirstLineIndentItem firstLine(pColl->GetFormatAttr(RES_MARGIN_FIRSTLINE)); + SvxTextLeftMarginItem leftMargin(pColl->GetFormatAttr(RES_MARGIN_TEXTLEFT)); + firstLine.SetTextFirstLineOffsetValue(rNFormat.GetFirstLineOffset()); //TODO: overflow - aLR.SetTextLeft( rNFormat.GetAbsLSpace() ); - pColl->SetFormatAttr( aLR ); + leftMargin.SetTextLeft(rNFormat.GetAbsLSpace()); + pColl->SetFormatAttr(firstLine); + pColl->SetFormatAttr(leftMargin); } // All paragraph styles, which are assigned to a level of the @@ -229,11 +231,11 @@ namespace void lcl_SetRegister( SwDoc& rDoc, SfxItemSet& rSet, sal_uInt16 nFact, bool bHeader, bool bTab ) { - SvxLRSpaceItem aLR( RES_LR_SPACE ); sal_uInt16 nLeft = o3tl::convert(5 * nFact, o3tl::Length::mm, o3tl::Length::twip); - aLR.SetTextLeft( nLeft ); - - rSet.Put( aLR ); + SvxFirstLineIndentItem const firstLine(0, RES_MARGIN_FIRSTLINE); + SvxTextLeftMarginItem const leftMargin(nLeft, RES_MARGIN_TEXTLEFT); + rSet.Put(firstLine); + rSet.Put(leftMargin); if( bHeader ) { SetAllScriptItem( rSet, SvxWeightItem( WEIGHT_BOLD, RES_CHRATR_WEIGHT ) ); @@ -255,14 +257,13 @@ namespace sal_uInt16 nNxt, SwTwips nEZ, SwTwips nLeft, SwTwips nUpper, SwTwips nLower ) { - - SvxLRSpaceItem aLR( RES_LR_SPACE ); + SvxFirstLineIndentItem const firstLine(sal_uInt16(nEZ), RES_MARGIN_FIRSTLINE); + SvxTextLeftMarginItem const leftMargin(sal_uInt16(nLeft), RES_MARGIN_TEXTLEFT); + rSet.Put(firstLine); + rSet.Put(leftMargin); SvxULSpaceItem aUL( RES_UL_SPACE ); - aLR.SetTextFirstLineOffset( sal_uInt16(nEZ) ); - aLR.SetTextLeft( sal_uInt16(nLeft) ); aUL.SetUpper( sal_uInt16(nUpper) ); aUL.SetLower( sal_uInt16(nLower) ); - rSet.Put( aLR ); rSet.Put( aUL ); if( pColl ) @@ -706,49 +707,58 @@ SwTextFormatColl* DocumentStylePoolManager::GetTextCollFromPool( sal_uInt16 nId, break; case RES_POOLCOLL_TEXT_IDENT: // Text body indentation { - SvxLRSpaceItem aLR( RES_LR_SPACE ); - aLR.SetTextFirstLineOffset(o3tl::convert(5, o3tl::Length::mm, o3tl::Length::twip)); - aSet.Put( aLR ); + auto const first(o3tl::convert(5, o3tl::Length::mm, o3tl::Length::twip)); + SvxFirstLineIndentItem const firstLine(first, RES_MARGIN_FIRSTLINE); + SvxTextLeftMarginItem const leftMargin(0, RES_MARGIN_TEXTLEFT); + aSet.Put(firstLine); + aSet.Put(leftMargin); } break; case RES_POOLCOLL_TEXT_NEGIDENT: // Text body neg. indentation { - SvxLRSpaceItem aLR( RES_LR_SPACE ); - aLR.SetTextFirstLineOffset(-o3tl::convert(5, o3tl::Length::mm, o3tl::Length::twip)); - aLR.SetTextLeft(o3tl::convert(1, o3tl::Length::cm, o3tl::Length::twip)); + auto const first(-o3tl::convert(5, o3tl::Length::mm, o3tl::Length::twip)); + auto const left(o3tl::convert(1, o3tl::Length::cm, o3tl::Length::twip)); + SvxFirstLineIndentItem const firstLine(first, RES_MARGIN_FIRSTLINE); + SvxTextLeftMarginItem const leftMargin(left, RES_MARGIN_TEXTLEFT); + aSet.Put(firstLine); + aSet.Put(leftMargin); + SvxTabStopItem aTStops(RES_PARATR_TABSTOP); aTStops.Insert( SvxTabStop( 0 )); - - aSet.Put( aLR ); aSet.Put( aTStops ); } break; case RES_POOLCOLL_TEXT_MOVE: // Text body move { - SvxLRSpaceItem aLR( RES_LR_SPACE ); - aLR.SetTextLeft(o3tl::convert(5, o3tl::Length::mm, o3tl::Length::twip)); - aSet.Put( aLR ); + auto const left(o3tl::convert(5, o3tl::Length::mm, o3tl::Length::twip)); + SvxFirstLineIndentItem const firstLine(0, RES_MARGIN_FIRSTLINE); + SvxTextLeftMarginItem const leftMargin(left, RES_MARGIN_TEXTLEFT); + aSet.Put(firstLine); + aSet.Put(leftMargin); } break; case RES_POOLCOLL_CONFRONTATION: // Text body confrontation { - SvxLRSpaceItem aLR( RES_LR_SPACE ); - aLR.SetTextFirstLineOffset( - -o3tl::convert(45, o3tl::Length::mm, o3tl::Length::twip)); - aLR.SetTextLeft(o3tl::convert(5, o3tl::Length::cm, o3tl::Length::twip)); + auto const first(-o3tl::convert(45, o3tl::Length::mm, o3tl::Length::twip)); + auto const left(o3tl::convert(5, o3tl::Length::cm, o3tl::Length::twip)); + SvxFirstLineIndentItem const firstLine(first, RES_MARGIN_FIRSTLINE); + SvxTextLeftMarginItem const leftMargin(left, RES_MARGIN_TEXTLEFT); + aSet.Put(firstLine); + aSet.Put(leftMargin); + SvxTabStopItem aTStops( RES_PARATR_TABSTOP ); aTStops.Insert( SvxTabStop( 0 )); - - aSet.Put( aLR ); aSet.Put( aTStops ); } break; case RES_POOLCOLL_MARGINAL: // Text body marginal { - SvxLRSpaceItem aLR( RES_LR_SPACE ); - aLR.SetTextLeft(o3tl::convert(4, o3tl::Length::cm, o3tl::Length::twip)); - aSet.Put( aLR ); + auto const left(o3tl::convert(4, o3tl::Length::cm, o3tl::Length::twip)); + SvxFirstLineIndentItem const firstLine(0, RES_MARGIN_FIRSTLINE); + SvxTextLeftMarginItem const leftMargin(left, RES_MARGIN_TEXTLEFT); + aSet.Put(firstLine); + aSet.Put(leftMargin); } break; @@ -938,11 +948,14 @@ SwTextFormatColl* DocumentStylePoolManager::GetTextCollFromPool( sal_uInt16 nId, case RES_POOLCOLL_FOOTNOTE: // paragraph style Footnote case RES_POOLCOLL_ENDNOTE: // paragraph style Endnote { - SvxLRSpaceItem aLR( RES_LR_SPACE ); - aLR.SetTextFirstLineOffset(-o3tl::convert(6, o3tl::Length::mm, o3tl::Length::twip)); - aLR.SetTextLeft(o3tl::convert(6, o3tl::Length::mm, o3tl::Length::twip)); + auto const first(-o3tl::convert(6, o3tl::Length::mm, o3tl::Length::twip)); + auto const left(o3tl::convert(6, o3tl::Length::mm, o3tl::Length::twip)); + SvxFirstLineIndentItem const firstLine(first, RES_MARGIN_FIRSTLINE); + SvxTextLeftMarginItem const leftMargin(left, RES_MARGIN_TEXTLEFT); + aSet.Put(firstLine); + aSet.Put(leftMargin); + SetAllScriptItem( aSet, SvxFontHeightItem( PT_10, 100, RES_CHRATR_FONTSIZE ) ); - aSet.Put( aLR ); SwFormatLineNumber aLN; aLN.SetCountLines( false ); aSet.Put( aLN ); @@ -1344,10 +1357,15 @@ SwTextFormatColl* DocumentStylePoolManager::GetTextCollFromPool( sal_uInt16 nId, case RES_POOLCOLL_HTML_BLOCKQUOTE: { - SvxLRSpaceItem aLR( RES_LR_SPACE ); - aLR.SetLeft(o3tl::convert(1, o3tl::Length::cm, o3tl::Length::twip)); - aLR.SetRight(o3tl::convert(1, o3tl::Length::cm, o3tl::Length::twip)); - aSet.Put( aLR ); + auto const left(o3tl::convert(1, o3tl::Length::cm, o3tl::Length::twip)); + auto const right(o3tl::convert(1, o3tl::Length::cm, o3tl::Length::twip)); + SvxFirstLineIndentItem const firstLine(0, RES_MARGIN_FIRSTLINE); + SvxTextLeftMarginItem const leftMargin(left, RES_MARGIN_TEXTLEFT); + SvxRightMarginItem const rightMargin(right, RES_MARGIN_RIGHT); + aSet.Put(firstLine); + aSet.Put(leftMargin); + aSet.Put(rightMargin); + std::unique_ptr aUL(pNewColl->GetULSpace().Clone()); aUL->SetLower( HTML_PARSPACE ); aSet.Put(std::move(aUL)); @@ -1395,22 +1413,20 @@ SwTextFormatColl* DocumentStylePoolManager::GetTextCollFromPool( sal_uInt16 nId, case RES_POOLCOLL_HTML_DD: { - std::unique_ptr aLR(pNewColl->GetLRSpace().Clone()); // We indent by 1 cm. The IDs are always 2 away from each other! - aLR->SetLeft(o3tl::convert(1, o3tl::Length::cm, o3tl::Length::twip)); - aSet.Put(std::move(aLR)); + auto const left(o3tl::convert(1, o3tl::Length::cm, o3tl::Length::twip)); + SvxTextLeftMarginItem const leftMargin(left, RES_MARGIN_TEXTLEFT); + aSet.Put(leftMargin); } break; case RES_POOLCOLL_HTML_DT: { - std::unique_ptr aLR; { pNewColl->SetNextTextFormatColl( *GetTextCollFromPool( RES_POOLCOLL_HTML_DD )); - aLR.reset(pNewColl->GetLRSpace().Clone()); } // We indent by 0 cm. The IDs are always 2 away from each other! - aLR->SetLeft( 0 ); - aSet.Put( std::move(aLR) ); + SvxTextLeftMarginItem const leftMargin(0, RES_MARGIN_TEXTLEFT); + aSet.Put(leftMargin); } break; } diff --git a/sw/source/core/doc/dbgoutsw.cxx b/sw/source/core/doc/dbgoutsw.cxx index 184390720407..20f8e6ecae9f 100644 --- a/sw/source/core/doc/dbgoutsw.cxx +++ b/sw/source/core/doc/dbgoutsw.cxx @@ -162,6 +162,12 @@ static std::map & GetItemWhichMap() { RES_FILL_ORDER , "FILL_ORDER" }, { RES_FRM_SIZE , "FRM_SIZE" }, { RES_PAPER_BIN , "PAPER_BIN" }, + { RES_MARGIN_FIRSTLINE, "FIRSTLINE" }, + { RES_MARGIN_TEXTLEFT, "TEXTLEFT" }, + { RES_MARGIN_RIGHT, "RIGHT" }, + { RES_MARGIN_LEFT, "LEFT" }, + { RES_MARGIN_GUTTER, "GUTTER" }, + { RES_MARGIN_GUTTER_RIGHT, "GUTTER_RIGHT" }, { RES_LR_SPACE , "LR_SPACE" }, { RES_UL_SPACE , "UL_SPACE" }, { RES_PAGEDESC , "PAGEDESC" }, diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx index 03e8d8d2ee0c..e990919ed719 100644 --- a/sw/source/core/doc/docfmt.cxx +++ b/sw/source/core/doc/docfmt.cxx @@ -1649,7 +1649,8 @@ void SwDoc::MoveLeftMargin(const SwPaM& rPam, bool bRight, bool bModulus, if( pTNd ) { pTNd = sw::GetParaPropsNode(*pLayout, aIdx.GetNode()); - SvxLRSpaceItem aLS(pTNd->SwContentNode::GetAttr(RES_LR_SPACE)); + SvxFirstLineIndentItem firstLine(pTNd->SwContentNode::GetAttr(RES_MARGIN_FIRSTLINE)); + SvxTextLeftMarginItem leftMargin(pTNd->SwContentNode::GetAttr(RES_MARGIN_TEXTLEFT)); // #i93873# See also lcl_MergeListLevelIndentAsLRSpaceItem in thints.cxx if ( pTNd->AreListLevelIndentsApplicable() ) @@ -1663,14 +1664,14 @@ void SwDoc::MoveLeftMargin(const SwPaM& rPam, bool bRight, bool bModulus, const SwNumFormat& rFormat = pRule->Get(o3tl::narrowing(nListLevel)); if ( rFormat.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT ) { - aLS.SetTextLeft( rFormat.GetIndentAt() ); - aLS.SetTextFirstLineOffset( static_cast(rFormat.GetFirstLineIndent()) ); + leftMargin.SetTextLeft(rFormat.GetIndentAt()); + firstLine.SetTextFirstLineOffset(static_cast(rFormat.GetFirstLineIndent())); } } } } - tools::Long nNext = aLS.GetTextLeft(); + tools::Long nNext = leftMargin.GetTextLeft(); if( bModulus ) nNext = ( nNext / nDefDist ) * nDefDist; @@ -1680,10 +1681,11 @@ void SwDoc::MoveLeftMargin(const SwPaM& rPam, bool bRight, bool bModulus, if(nNext >0) // fdo#75936 set limit for decreasing indent nNext -= nDefDist; - aLS.SetTextLeft( nNext ); + leftMargin.SetTextLeft( nNext ); SwRegHistory aRegH( pTNd, *pTNd, pHistory ); - pTNd->SetAttr( aLS ); + pTNd->SetAttr(firstLine); + pTNd->SetAttr(leftMargin); aIdx = *sw::GetFirstAndLastNode(*pLayout, aIdx.GetNode()).second; } ++aIdx; diff --git a/sw/source/core/doc/docnum.cxx b/sw/source/core/doc/docnum.cxx index b4d32ea25b61..fc51f148e3c3 100644 --- a/sw/source/core/doc/docnum.cxx +++ b/sw/source/core/doc/docnum.cxx @@ -59,10 +59,10 @@ #include namespace { - void lcl_ResetIndentAttrs(SwDoc *pDoc, const SwPaM &rPam, sal_uInt16 marker, + void lcl_ResetIndentAttrs(SwDoc *pDoc, const SwPaM &rPam, + const o3tl::sorted_vector aResetAttrsArray, SwRootFrame const*const pLayout) { - const o3tl::sorted_vector aResetAttrsArray{ marker }; // #i114929# // On a selection setup a corresponding Point-and-Mark in order to get // the indentation attribute reset on all paragraphs touched by the selection @@ -978,7 +978,8 @@ OUString SwDoc::SetNumRule( const SwPaM& rPam, if ( bResetIndentAttrs && pNewOrChangedNumRule->Get( 0 ).GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT ) { - ::lcl_ResetIndentAttrs(this, aPam, RES_LR_SPACE, pLayout); + const o3tl::sorted_vector attrs{ RES_MARGIN_FIRSTLINE, RES_MARGIN_TEXTLEFT, RES_MARGIN_RIGHT }; + ::lcl_ResetIndentAttrs(this, aPam, attrs, pLayout); } if (GetIDocumentUndoRedo().DoesUndo()) @@ -996,7 +997,8 @@ void SwDoc::SetCounted(const SwPaM & rPam, bool bCounted, { if ( bCounted ) { - ::lcl_ResetIndentAttrs(this, rPam, RES_PARATR_LIST_ISCOUNTED, pLayout); + const o3tl::sorted_vector attrs{ RES_PARATR_LIST_ISCOUNTED }; + ::lcl_ResetIndentAttrs(this, rPam, attrs, pLayout); } else { diff --git a/sw/source/core/doc/fmtcol.cxx b/sw/source/core/doc/fmtcol.cxx index 0a53339b0460..95cd8754fb44 100644 --- a/sw/source/core/doc/fmtcol.cxx +++ b/sw/source/core/doc/fmtcol.cxx @@ -137,7 +137,9 @@ void SwTextFormatColl::SwClientNotify(const SwModify& rModify, const SfxHint& rH } bool bNewParent( false ); // #i66431# - adjust type of const SvxULSpaceItem *pNewULSpace = nullptr, *pOldULSpace = nullptr; - const SvxLRSpaceItem *pNewLRSpace = nullptr, *pOldLRSpace = nullptr; + const SvxFirstLineIndentItem *pNewFirstLineIndent = nullptr; + const SvxTextLeftMarginItem *pNewTextLeftMargin = nullptr; + const SvxRightMarginItem *pNewRightMargin = nullptr; const SvxFontHeightItem* aFontSizeArr[3] = {nullptr,nullptr,nullptr}; // #i70223# const bool bAssignedToListLevelOfOutlineStyle(IsAssignedToListLevelOfOutlineStyle()); @@ -152,7 +154,9 @@ void SwTextFormatColl::SwClientNotify(const SwModify& rModify, const SfxHint& rH // Only recalculate if we're not the sender! pNewChgSet = &pNew->StaticWhichCast(RES_ATTRSET_CHG); pOldChgSet = &pOld->StaticWhichCast(RES_ATTRSET_CHG); - pNewLRSpace = pNewChgSet->GetChgSet()->GetItemIfSet( RES_LR_SPACE, false ); + pNewFirstLineIndent = pNewChgSet->GetChgSet()->GetItemIfSet(RES_MARGIN_FIRSTLINE, false); + pNewTextLeftMargin = pNewChgSet->GetChgSet()->GetItemIfSet(RES_MARGIN_TEXTLEFT, false); + pNewRightMargin = pNewChgSet->GetChgSet()->GetItemIfSet(RES_MARGIN_RIGHT, false); pNewULSpace = pNewChgSet->GetChgSet()->GetItemIfSet( RES_UL_SPACE, false ); aFontSizeArr[0] = pNewChgSet->GetChgSet()->GetItemIfSet( RES_CHRATR_FONTSIZE, false ); aFontSizeArr[1] = pNewChgSet->GetChgSet()->GetItemIfSet( RES_CHRATR_CJK_FONTSIZE, false ); @@ -171,7 +175,9 @@ void SwTextFormatColl::SwClientNotify(const SwModify& rModify, const SfxHint& rH if( GetAttrSet().GetParent() ) { const SfxItemSet* pParent = GetAttrSet().GetParent(); - pNewLRSpace = &pParent->Get( RES_LR_SPACE ); + pNewFirstLineIndent = &pParent->Get(RES_MARGIN_FIRSTLINE); + pNewTextLeftMargin = &pParent->Get(RES_MARGIN_TEXTLEFT); + pNewRightMargin = &pParent->Get(RES_MARGIN_RIGHT); pNewULSpace = &pParent->Get( RES_UL_SPACE ); aFontSizeArr[0] = &pParent->Get( RES_CHRATR_FONTSIZE ); aFontSizeArr[1] = &pParent->Get( RES_CHRATR_CJK_FONTSIZE ); @@ -181,8 +187,14 @@ void SwTextFormatColl::SwClientNotify(const SwModify& rModify, const SfxHint& rH } break; - case RES_LR_SPACE: - pNewLRSpace = &pNew->StaticWhichCast(RES_LR_SPACE); + case RES_MARGIN_FIRSTLINE: + pNewFirstLineIndent = &pNew->StaticWhichCast(RES_MARGIN_FIRSTLINE); + break; + case RES_MARGIN_TEXTLEFT: + pNewTextLeftMargin = &pNew->StaticWhichCast(RES_MARGIN_TEXTLEFT); + break; + case RES_MARGIN_RIGHT: + pNewRightMargin = &pNew->StaticWhichCast(RES_MARGIN_RIGHT); break; case RES_UL_SPACE: pNewULSpace = &pNew->StaticWhichCast(RES_UL_SPACE); @@ -217,34 +229,72 @@ void SwTextFormatColl::SwClientNotify(const SwModify& rModify, const SfxHint& rH bool bContinue = true; // Check against the own attributes - if( pNewLRSpace && (pOldLRSpace = GetItemIfSet( RES_LR_SPACE, false)) ) + const SvxFirstLineIndentItem *pOldFirstLineIndent(GetItemIfSet(RES_MARGIN_FIRSTLINE, false)); + if (pNewFirstLineIndent && pOldFirstLineIndent) + { + if (pOldFirstLineIndent != pNewFirstLineIndent) // Avoid recursion (SetAttr!) + { + bool bChg = false; + SvxFirstLineIndentItem aNew(*pOldFirstLineIndent); + // We had a relative value -> recalculate + if( 100 != aNew.GetPropTextFirstLineOffset() ) + { + short nTmp = aNew.GetTextFirstLineOffset(); // keep so that we can compare + aNew.SetTextFirstLineOffset(pNewFirstLineIndent->GetTextFirstLineOffset(), + aNew.GetPropTextFirstLineOffset() ); + bChg |= nTmp != aNew.GetTextFirstLineOffset(); + } + if( bChg ) + { + SetFormatAttr( aNew ); + bContinue = nullptr != pOldChgSet || bNewParent; + } + // We set it to absolute -> do not propagate it further, unless + // we set it! + else if( pNewChgSet ) + bContinue = pNewChgSet->GetTheChgdSet() == &GetAttrSet(); + } + } + const SvxTextLeftMarginItem *pOldTextLeftMargin(GetItemIfSet(RES_MARGIN_TEXTLEFT, false)); + if (pNewTextLeftMargin && pOldTextLeftMargin) { - if( pOldLRSpace != pNewLRSpace ) // Avoid recursion (SetAttr!) + if (pOldTextLeftMargin != pNewTextLeftMargin) // Avoid recursion (SetAttr!) { bool bChg = false; - SvxLRSpaceItem aNew( *pOldLRSpace ); + SvxTextLeftMarginItem aNew(*pOldTextLeftMargin); // We had a relative value -> recalculate if( 100 != aNew.GetPropLeft() ) { - tools::Long nTmp = aNew.GetLeft(); // keep so that we can compare - aNew.SetLeft( pNewLRSpace->GetLeft(), aNew.GetPropLeft() ); - bChg |= nTmp != aNew.GetLeft(); + // note: changing from Left to TextLeft - looked wrong with Left + tools::Long nTmp = aNew.GetTextLeft(); // keep so that we can compare + aNew.SetTextLeft(pNewTextLeftMargin->GetTextLeft(), aNew.GetPropLeft()); + bChg |= nTmp != aNew.GetTextLeft(); + } + if( bChg ) + { + SetFormatAttr( aNew ); + bContinue = nullptr != pOldChgSet || bNewParent; } + // We set it to absolute -> do not propagate it further, unless + // we set it! + else if( pNewChgSet ) + bContinue = pNewChgSet->GetTheChgdSet() == &GetAttrSet(); + } + } + const SvxRightMarginItem *pOldRightMargin(GetItemIfSet(RES_MARGIN_RIGHT, false)); + if (pNewRightMargin && pOldRightMargin) + { + if (pOldRightMargin != pNewRightMargin) // Avoid recursion (SetAttr!) + { + bool bChg = false; + SvxRightMarginItem aNew(*pOldRightMargin); // We had a relative value -> recalculate if( 100 != aNew.GetPropRight() ) { tools::Long nTmp = aNew.GetRight(); // keep so that we can compare - aNew.SetRight( pNewLRSpace->GetRight(), aNew.GetPropRight() ); + aNew.SetRight(pNewRightMargin->GetRight(), aNew.GetPropRight()); bChg |= nTmp != aNew.GetRight(); } - // We had a relative value -> recalculate - if( 100 != aNew.GetPropTextFirstLineOffset() ) - { - short nTmp = aNew.GetTextFirstLineOffset(); // keep so that we can compare - aNew.SetTextFirstLineOffset( pNewLRSpace->GetTextFirstLineOffset(), - aNew.GetPropTextFirstLineOffset() ); - bChg |= nTmp != aNew.GetTextFirstLineOffset(); - } if( bChg ) { SetFormatAttr( aNew ); diff --git a/sw/source/core/edit/autofmt.cxx b/sw/source/core/edit/autofmt.cxx index a4c6e02dbc30..0f5d4cd307e9 100644 --- a/sw/source/core/edit/autofmt.cxx +++ b/sw/source/core/edit/autofmt.cxx @@ -1479,7 +1479,7 @@ void SwAutoFormat::BuildEnum( sal_uInt16 nLvl, sal_uInt16 nDigitLevel ) SwTextFrameInfo aInfo( m_pCurTextFrame ); nLeftTextPos = aInfo.GetCharPos(nPos); - nLeftTextPos -= m_pCurTextFrame->GetTextNodeForParaProps()->GetSwAttrSet().GetLRSpace().GetLeft(); + nLeftTextPos -= m_pCurTextFrame->GetTextNodeForParaProps()->GetSwAttrSet().GetTextLeftMargin().GetLeft(m_pCurTextFrame->GetTextNodeForParaProps()->GetSwAttrSet().GetFirstLineIndent()); } if( m_bMoreLines ) @@ -2414,16 +2414,19 @@ SwAutoFormat::SwAutoFormat( SwEditShell* pEdShell, SvxSwAutoFormatFlags aFlags, break; } - // check for hard spaces or LRSpaces set by the template + // check for left margin set by the style if( IsPoolUserFormat( nPoolId ) || RES_POOLCOLL_STANDARD == nPoolId ) { - short nSz; - SvxLRSpaceItem const * pLRSpace = m_pCurTextFrame->GetTextNodeForParaProps()->GetSwAttrSet(). - GetItemIfSet( RES_LR_SPACE ); - if (pLRSpace && - ( 0 != (nSz = pLRSpace->GetTextFirstLineOffset()) || - 0 != pLRSpace->GetTextLeft() ) ) + SvxFirstLineIndentItem const*const pFirstLineIndent( + m_pCurTextFrame->GetTextNodeForParaProps() + ->GetSwAttrSet().GetItemIfSet(RES_MARGIN_FIRSTLINE)); + SvxTextLeftMarginItem const*const pTextLeftMargin( + m_pCurTextFrame->GetTextNodeForParaProps() + ->GetSwAttrSet().GetItemIfSet(RES_MARGIN_TEXTLEFT)); + short nSz(pFirstLineIndent ? pFirstLineIndent->GetTextFirstLineOffset() : 0); + if (0 != nSz || + (pTextLeftMargin && 0 != pTextLeftMargin->GetTextLeft())) { // exception: numbering/enumeration can have an indentation if (IsEnumericChar(*m_pCurTextFrame)) @@ -2446,7 +2449,7 @@ SwAutoFormat::SwAutoFormat( SwEditShell* pEdShell, SvxSwAutoFormatFlags aFlags, BuildIndent(); else if( 0 > nSz ) // negative 1st line indentation BuildNegIndent( aFInfo.GetLineStart() ); - else if( pLRSpace->GetTextLeft() ) // is indentation + else if (pTextLeftMargin && pTextLeftMargin->GetTextLeft() != 0) // is indentation BuildTextIndent(); } eStat = READ_NEXT_PARA; @@ -2651,13 +2654,16 @@ SwAutoFormat::SwAutoFormat( SwEditShell* pEdShell, SvxSwAutoFormatFlags aFlags, // handle hard attributes if (m_pCurTextFrame->GetTextNodeForParaProps()->HasSwAttrSet()) { - short nSz; - SvxLRSpaceItem const * pLRSpace; + SvxFirstLineIndentItem const*const pFirstLineIndent( + m_pCurTextFrame->GetTextNodeForParaProps() + ->GetSwAttrSet().GetItemIfSet(RES_MARGIN_FIRSTLINE, false)); + SvxTextLeftMarginItem const*const pTextLeftMargin( + m_pCurTextFrame->GetTextNodeForParaProps() + ->GetSwAttrSet().GetItemIfSet(RES_MARGIN_TEXTLEFT, false)); + short nSz(pFirstLineIndent ? pFirstLineIndent->GetTextFirstLineOffset() : 0); if( bReplaceStyles && - (pLRSpace = m_pCurTextFrame->GetTextNodeForParaProps()->GetSwAttrSet(). - GetItemIfSet( RES_LR_SPACE, false )) && - ( 0 != (nSz = pLRSpace->GetTextFirstLineOffset()) || - 0 != pLRSpace->GetTextLeft() ) ) + (0 != nSz || + (pTextLeftMargin && 0 != pTextLeftMargin->GetTextLeft()))) { // then use one of our templates if( 0 < nSz ) // positive 1st line indentation @@ -2666,7 +2672,7 @@ SwAutoFormat::SwAutoFormat( SwEditShell* pEdShell, SvxSwAutoFormatFlags aFlags, { BuildNegIndent( aFInfo.GetLineStart() ); } - else if( pLRSpace->GetTextLeft() ) // is indentation + else if (pTextLeftMargin && pTextLeftMargin->GetTextLeft()) // is indentation BuildTextIndent(); else BuildText(); diff --git a/sw/source/core/inc/frmtool.hxx b/sw/source/core/inc/frmtool.hxx index 0aaa4d2c05c3..ca3c787e3954 100644 --- a/sw/source/core/inc/frmtool.hxx +++ b/sw/source/core/inc/frmtool.hxx @@ -309,7 +309,9 @@ class SwBorderAttrs final : public SwCacheObj { const SwAttrSet &m_rAttrSet; const SvxULSpaceItem &m_rUL; - // #i96772# + std::unique_ptr m_pFirstLineIndent; + std::unique_ptr m_pTextLeftMargin; + std::unique_ptr m_pRightMargin; std::shared_ptr m_xLR; const SvxBoxItem &m_rBox; const SvxShadowItem &m_rShadow; diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx index 91c0f0549680..398452d603be 100644 --- a/sw/source/core/layout/fly.cxx +++ b/sw/source/core/layout/fly.cxx @@ -2650,10 +2650,15 @@ static SwTwips lcl_CalcAutoWidth( const SwLayoutFrame& rFrame ) if ( pFrame->IsTextFrame() ) { nMin = const_cast(static_cast(pFrame))->CalcFitToContent(); - const SvxLRSpaceItem &rSpace = - static_cast(pFrame)->GetTextNodeForParaProps()->GetSwAttrSet().GetLRSpace(); + auto const& rParaSet(static_cast(pFrame)->GetTextNodeForParaProps()->GetSwAttrSet()); + SvxFirstLineIndentItem const& rFirstLine(rParaSet.GetFirstLineIndent()); + SvxTextLeftMarginItem const& rLeftMargin(rParaSet.GetTextLeftMargin()); + SvxRightMarginItem const& rRightMargin(rParaSet.GetRightMargin()); if (!static_cast(pFrame)->IsLocked()) - nMin += rSpace.GetRight() + rSpace.GetTextLeft() + rSpace.GetTextFirstLineOffset(); + { + nMin += rRightMargin.GetRight() + rLeftMargin.GetTextLeft() + + rFirstLine.GetTextFirstLineOffset(); + } } else if ( pFrame->IsTabFrame() ) { diff --git a/sw/source/core/layout/frmtool.cxx b/sw/source/core/layout/frmtool.cxx index e47c68283e33..bcdb49c292eb 100644 --- a/sw/source/core/layout/frmtool.cxx +++ b/sw/source/core/layout/frmtool.cxx @@ -2234,9 +2234,6 @@ SwBorderAttrs::SwBorderAttrs(const sw::BorderCacheOwner* pOwner, const SwFrame* : static_cast(pConstructor)->GetNode()->GetSwAttrSet() : static_cast(pConstructor)->GetFormat()->GetAttrSet()) , m_rUL(m_rAttrSet.GetULSpace()) - // #i96772# - // LRSpaceItem is copied due to the possibility that it is adjusted - see below - , m_xLR(m_rAttrSet.GetLRSpace().Clone()) , m_rBox(m_rAttrSet.GetBox()) , m_rShadow(m_rAttrSet.GetShadow()) , m_aFrameSize(m_rAttrSet.GetFrameSize().GetSize()) @@ -2257,15 +2254,24 @@ SwBorderAttrs::SwBorderAttrs(const sw::BorderCacheOwner* pOwner, const SwFrame* const SwTextFrame* pTextFrame = pConstructor->DynCastTextFrame(); if ( pTextFrame ) { - pTextFrame->GetTextNodeForParaProps()->ClearLRSpaceItemDueToListLevelIndents( m_xLR ); + m_pFirstLineIndent.reset(m_rAttrSet.GetFirstLineIndent().Clone()); + m_pTextLeftMargin.reset(m_rAttrSet.GetTextLeftMargin().Clone()); + m_pRightMargin.reset(m_rAttrSet.GetRightMargin().Clone()); + pTextFrame->GetTextNodeForParaProps()->ClearLRSpaceItemDueToListLevelIndents(m_pFirstLineIndent, m_pTextLeftMargin); + assert(m_pFirstLineIndent); + assert(m_pTextLeftMargin); } - else if ( pConstructor->IsNoTextFrame() ) + else { - m_xLR = std::make_shared(RES_LR_SPACE); + // LRSpaceItem is copied due to the possibility that it is adjusted + m_xLR.reset(m_rAttrSet.GetLRSpace().Clone()); + if (pConstructor->IsNoTextFrame()) + { + m_xLR = std::make_shared(RES_LR_SPACE); + } + assert(m_xLR); } - assert(m_xLR && "always exists"); - // Caution: The USHORTs for the cached values are not initialized by intention! // everything needs to be calculated at least once: @@ -2298,7 +2304,7 @@ void SwBorderAttrs::CalcTop_() bool bGutterAtTop = m_rAttrSet.GetDoc()->getIDocumentSettingAccess().get( DocumentSettingId::GUTTER_AT_TOP); - if (bGutterAtTop) + if (bGutterAtTop && m_xLR) { // Decrease the print area: the top space is the sum of top and gutter margins. m_nTop += m_xLR->GetGutterMargin(); @@ -2327,8 +2333,17 @@ tools::Long SwBorderAttrs::CalcRight( const SwFrame* pCaller ) const } // for paragraphs, "left" is "before text" and "right" is "after text" - if ( pCaller->IsTextFrame() && pCaller->IsRightToLeft() ) - nRight += m_xLR->GetLeft(); + if (pCaller->IsTextFrame()) + { + if (pCaller->IsRightToLeft()) + { + nRight += m_pTextLeftMargin->GetLeft(*m_pFirstLineIndent); + } + else + { + nRight += m_pRightMargin->GetRight(); + } + } else nRight += m_xLR->GetRight(); @@ -2391,7 +2406,7 @@ tools::Long SwBorderAttrs::CalcLeft( const SwFrame *pCaller ) const // for paragraphs, "left" is "before text" and "right" is "after text" if ( pCaller->IsTextFrame() && pCaller->IsRightToLeft() ) - nLeft += m_xLR->GetRight(); + nLeft += m_pRightMargin->GetRight(); else { bool bIgnoreMargin = false; @@ -2407,8 +2422,12 @@ tools::Long SwBorderAttrs::CalcLeft( const SwFrame *pCaller ) const else if (pTextFrame->FindPrev() && pTextFrame->FindPrev()->IsTextFrame() && lcl_hasTabFrame(static_cast(pTextFrame->FindPrev()))) bIgnoreMargin = true; } + if (!bIgnoreMargin) + { + nLeft += m_pTextLeftMargin->GetLeft(*m_pFirstLineIndent); + } } - if (!bIgnoreMargin) + else nLeft += m_xLR->GetLeft(); } diff --git a/sw/source/core/layout/wsfrm.cxx b/sw/source/core/layout/wsfrm.cxx index 5a31c3c0a2d5..7484db742c7c 100644 --- a/sw/source/core/layout/wsfrm.cxx +++ b/sw/source/core/layout/wsfrm.cxx @@ -541,6 +541,9 @@ void SwFrame::UpdateAttrFrame( const SfxPoolItem *pOld, const SfxPoolItem *pNew, case RES_SHADOW: Prepare( PrepareHint::FixSizeChanged ); [[fallthrough]]; + case RES_MARGIN_FIRSTLINE: + case RES_MARGIN_TEXTLEFT: + case RES_MARGIN_RIGHT: case RES_LR_SPACE: case RES_UL_SPACE: case RES_RTL_GUTTER: @@ -2490,6 +2493,9 @@ void SwContentFrame::UpdateAttr_( const SfxPoolItem* pOld, const SfxPoolItem* pN rInvFlags |= SwContentFrameInvFlags::SetNextCompletePaint; [[fallthrough]]; } + case RES_MARGIN_FIRSTLINE: + case RES_MARGIN_TEXTLEFT: + case RES_MARGIN_RIGHT: case RES_LR_SPACE: case RES_BOX: case RES_SHADOW: diff --git a/sw/source/core/text/EnhancedPDFExportHelper.cxx b/sw/source/core/text/EnhancedPDFExportHelper.cxx index 9e7a01c60a7f..053b67990eda 100644 --- a/sw/source/core/text/EnhancedPDFExportHelper.cxx +++ b/sw/source/core/text/EnhancedPDFExportHelper.cxx @@ -661,9 +661,9 @@ void SwTaggedPDFHelper::SetAttributes( vcl::PDFWriter::StructElement eType ) if ( bTextIndent ) { OSL_ENSURE( pFrame->IsTextFrame(), "Frame type <-> tag attribute mismatch" ); - const SvxLRSpaceItem &rSpace = - static_cast(pFrame)->GetTextNodeForParaProps()->GetSwAttrSet().GetLRSpace(); - nVal = rSpace.GetTextFirstLineOffset(); + const SvxFirstLineIndentItem& rFirstLine( + static_cast(pFrame)->GetTextNodeForParaProps()->GetSwAttrSet().GetFirstLineIndent()); + nVal = rFirstLine.GetTextFirstLineOffset(); if ( 0 != nVal ) mpPDFExtOutDevData->SetStructureAttributeNumerical( vcl::PDFWriter::TextIndent, nVal ); } diff --git a/sw/source/core/text/frmcrsr.cxx b/sw/source/core/text/frmcrsr.cxx index 0891a38321e7..d7f7a2cab99e 100644 --- a/sw/source/core/text/frmcrsr.cxx +++ b/sw/source/core/text/frmcrsr.cxx @@ -1431,16 +1431,18 @@ void SwTextFrame::FillCursorPos( SwFillData& rFill ) const else { const SvxTabStopItem &rRuler = pSet->GetTabStops(); - const SvxLRSpaceItem &rLRSpace = pSet->GetLRSpace(); + const SvxFirstLineIndentItem& rFirstLine(pSet->GetFirstLineIndent()); + const SvxTextLeftMarginItem& rTextLeftMargin(pSet->GetTextLeftMargin()); + const SvxRightMarginItem& rRightMargin(pSet->GetRightMargin()); SwRect &rRect = rFill.Fill().aCursor; rRect.Top( rFill.Bottom() + (nDiff+1) * nDist - nLineHeight ); if( nFirst && nDiff > -1 ) rRect.Top( rRect.Top() + nFirst ); rRect.Height( nLineHeight ); - SwTwips nLeft = rFill.Left() + rLRSpace.GetLeft() + + SwTwips nLeft = rFill.Left() + rTextLeftMargin.GetLeft(rFirstLine) + GetTextNodeForParaProps()->GetLeftMarginWithNum(); - SwTwips nRight = rFill.Right() - rLRSpace.GetRight(); + SwTwips nRight = rFill.Right() - rRightMargin.GetRight(); SwTwips nCenter = ( nLeft + nRight ) / 2; rRect.Left( nLeft ); if( SwFillMode::Margin == rFill.Mode() ) @@ -1510,7 +1512,7 @@ void SwTextFrame::FillCursorPos( SwFillData& rFill ) const } else if( rFill.X() > nLeft ) { - SwTwips nTextLeft = rFill.Left() + rLRSpace.GetTextLeft() + + SwTwips nTextLeft = rFill.Left() + rTextLeftMargin.GetTextLeft() + GetTextNodeForParaProps()->GetLeftMarginWithNum(true); rFill.nLineWidth += rFill.bFirstLine ? nLeft : nTextLeft; SwTwips nLeftTab; diff --git a/sw/source/core/text/frmpaint.cxx b/sw/source/core/text/frmpaint.cxx index 461c8094c0ac..2af086d9fd69 100644 --- a/sw/source/core/text/frmpaint.cxx +++ b/sw/source/core/text/frmpaint.cxx @@ -570,11 +570,13 @@ bool SwTextFrame::PaintEmpty( const SwRect &rRect, bool bCheck ) const pFnt->ChgPhysFnt( pSh, *pSh->GetOut() ); Point aPos = getFrameArea().Pos() + getFramePrintArea().Pos(); - const SvxLRSpaceItem &rSpace = - GetTextNodeForParaProps()->GetSwAttrSet().GetLRSpace(); + const SvxFirstLineIndentItem& rFirstLine( + GetTextNodeForParaProps()->GetSwAttrSet().GetFirstLineIndent()); - if ( rSpace.GetTextFirstLineOffset() > 0 ) - aPos.AdjustX(rSpace.GetTextFirstLineOffset() ); + if (0 < rFirstLine.GetTextFirstLineOffset()) + { + aPos.AdjustX(rFirstLine.GetTextFirstLineOffset()); + } std::unique_ptr> xClip; if( IsUndersized() ) diff --git a/sw/source/core/text/itratr.cxx b/sw/source/core/text/itratr.cxx index 613a2aa44265..bc46758eb590 100644 --- a/sw/source/core/text/itratr.cxx +++ b/sw/source/core/text/itratr.cxx @@ -1026,8 +1026,9 @@ void SwTextNode::GetMinMaxSize( SwNodeOffset nIndex, sal_uLong& rMin, sal_uLong rMax = 0; rAbsMin = 0; - const SvxLRSpaceItem &rSpace = GetSwAttrSet().GetLRSpace(); - tools::Long nLROffset = rSpace.GetTextLeft() + GetLeftMarginWithNum( true ); + SvxTextLeftMarginItem const& rTextLeftMargin(GetSwAttrSet().GetTextLeftMargin()); + SvxRightMarginItem const& rRightMargin(GetSwAttrSet().GetRightMargin()); + tools::Long nLROffset = rTextLeftMargin.GetTextLeft() + GetLeftMarginWithNum( true ); short nFLOffs; // For enumerations a negative first line indentation is probably filled already if( !GetFirstLineOfsWithNum( nFLOffs ) || nFLOffs > nLROffset ) @@ -1037,7 +1038,7 @@ void SwTextNode::GetMinMaxSize( SwNodeOffset nIndex, sal_uLong& rMin, sal_uLong aNodeArgs.m_nMinWidth = 0; aNodeArgs.m_nMaxWidth = 0; aNodeArgs.m_nLeftRest = nLROffset; - aNodeArgs.m_nRightRest = rSpace.GetRight(); + aNodeArgs.m_nRightRest = rRightMargin.GetRight(); aNodeArgs.m_nLeftDiff = 0; aNodeArgs.m_nRightDiff = 0; if( nIndex ) @@ -1057,7 +1058,7 @@ void SwTextNode::GetMinMaxSize( SwNodeOffset nIndex, sal_uLong& rMin, sal_uLong aNodeArgs.m_nMaxWidth -= aNodeArgs.m_nLeftRest; if (aNodeArgs.m_nRightRest < 0) - aNodeArgs.Minimum(rSpace.GetRight() - aNodeArgs.m_nRightRest); + aNodeArgs.Minimum(rRightMargin.GetRight() - aNodeArgs.m_nRightRest); aNodeArgs.m_nRightRest -= aNodeArgs.m_nRightDiff; if (aNodeArgs.m_nRightRest < 0) aNodeArgs.m_nMaxWidth -= aNodeArgs.m_nRightRest; @@ -1230,7 +1231,7 @@ void SwTextNode::GetMinMaxSize( SwNodeOffset nIndex, sal_uLong& rMin, sal_uLong if (static_cast(rMax) < aArg.m_nRowWidth) rMax = aArg.m_nRowWidth; - nLROffset += rSpace.GetRight(); + nLROffset += rRightMargin.GetRight(); rAbsMin += nLROffset; rAbsMin += nAdd; diff --git a/sw/source/core/text/itrcrsr.cxx b/sw/source/core/text/itrcrsr.cxx index 47befa14d008..7158aa9f0d8f 100644 --- a/sw/source/core/text/itrcrsr.cxx +++ b/sw/source/core/text/itrcrsr.cxx @@ -161,7 +161,8 @@ void SwTextMargin::CtorInitTextMargin( SwTextFrame *pNewFrame, SwTextSizeInfo *p GetInfo().SetFont( GetFnt() ); const SwTextNode *const pNode = m_pFrame->GetTextNodeForParaProps(); - const SvxLRSpaceItem &rSpace = pNode->GetSwAttrSet().GetLRSpace(); + SvxFirstLineIndentItem const& rFirstLine(pNode->GetSwAttrSet().GetFirstLineIndent()); + SvxTextLeftMarginItem const& rTextLeftMargin(pNode->GetSwAttrSet().GetTextLeftMargin()); // #i95907# // #i111284# const SwTextNode *pTextNode = m_pFrame->GetTextNodeForParaProps(); @@ -193,7 +194,7 @@ void SwTextMargin::CtorInitTextMargin( SwTextFrame *pNewFrame, SwTextSizeInfo *p // rSpace.GetLeft() + rSpace.GetTextLeft(); ( bListLevelIndentsApplicableAndLabelAlignmentActive ? 0 - : ( rSpace.GetLeft() - rSpace.GetTextLeft() ) ); + : (rTextLeftMargin.GetLeft(rFirstLine) - rTextLeftMargin.GetTextLeft())); } else { @@ -211,12 +212,12 @@ void SwTextMargin::CtorInitTextMargin( SwTextFrame *pNewFrame, SwTextSizeInfo *p // #i111284# ( bListLevelIndentsApplicableAndLabelAlignmentActive ? 0 - : ( rSpace.GetLeft() - rSpace.GetTextLeft() ) ); + : (rTextLeftMargin.GetLeft(rFirstLine) - rTextLeftMargin.GetTextLeft())); } else { mnLeft = m_pFrame->getFrameArea().Left() + - std::max( tools::Long( rSpace.GetTextLeft() + nLMWithNum ), + std::max(tools::Long(rTextLeftMargin.GetTextLeft() + nLMWithNum), m_pFrame->getFramePrintArea().Left() ); } } @@ -242,7 +243,7 @@ void SwTextMargin::CtorInitTextMargin( SwTextFrame *pNewFrame, SwTextSizeInfo *p short nFLOfst = 0; tools::Long nFirstLineOfs = 0; if( !pNode->GetFirstLineOfsWithNum( nFLOfst ) && - rSpace.IsAutoFirst() ) + rFirstLine.IsAutoFirst()) { nFirstLineOfs = GetFnt()->GetSize( GetFnt()->GetActual() ).Height(); LanguageType const aLang = m_pFrame->GetLangOfChar( @@ -325,7 +326,7 @@ void SwTextMargin::CtorInitTextMargin( SwTextFrame *pNewFrame, SwTextSizeInfo *p else { mnFirst = m_pFrame->getFrameArea().Left() + - std::max( rSpace.GetTextLeft() + nLMWithNum+ nFirstLineOfs, + std::max(rTextLeftMargin.GetTextLeft() + nLMWithNum + nFirstLineOfs, m_pFrame->getFramePrintArea().Left() ); } diff --git a/sw/source/core/text/porfld.cxx b/sw/source/core/text/porfld.cxx index 795caed47d92..dbe62d49e6bb 100644 --- a/sw/source/core/text/porfld.cxx +++ b/sw/source/core/text/porfld.cxx @@ -575,7 +575,7 @@ bool SwNumberPortion::Format( SwTextFormatInfo &rInf ) { nDiff = rInf.Left() + rInf.GetTextFrame()->GetTextNodeForParaProps()-> - GetSwAttrSet().GetLRSpace().GetTextFirstLineOffset() + GetSwAttrSet().GetFirstLineIndent().GetTextFirstLineOffset() - rInf.First() + rInf.ForcedLeftMargin(); } diff --git a/sw/source/core/text/porrst.cxx b/sw/source/core/text/porrst.cxx index 90f4d763578d..73bd05aa96da 100644 --- a/sw/source/core/text/porrst.cxx +++ b/sw/source/core/text/porrst.cxx @@ -427,8 +427,10 @@ bool SwTextFrame::FormatEmpty() const SvxLineSpacingItem &rSpacing = aSet.GetLineSpacing(); if( !bCollapse && ( SvxLineSpaceRule::Min == rSpacing.GetLineSpaceRule() || SvxLineSpaceRule::Fix == rSpacing.GetLineSpaceRule() || - aSet.GetLRSpace().IsAutoFirst() ) ) + aSet.GetFirstLineIndent().IsAutoFirst())) + { return false; + } SwTextFly aTextFly( this ); SwRect aRect; diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx index 7ac2a5183114..bd772efc74f9 100644 --- a/sw/source/core/text/txtfrm.cxx +++ b/sw/source/core/text/txtfrm.cxx @@ -1756,7 +1756,7 @@ void SwTextFrame::CalcLineSpace() return; if( GetDrawObjs() || - GetTextNodeForParaProps()->GetSwAttrSet().GetLRSpace().IsAutoFirst()) + GetTextNodeForParaProps()->GetSwAttrSet().GetFirstLineIndent().IsAutoFirst()) { Init(); return; diff --git a/sw/source/core/tox/ToxTabStopTokenHandler.cxx b/sw/source/core/tox/ToxTabStopTokenHandler.cxx index a89e9ad276eb..b3943d6e5393 100644 --- a/sw/source/core/tox/ToxTabStopTokenHandler.cxx +++ b/sw/source/core/tox/ToxTabStopTokenHandler.cxx @@ -50,11 +50,12 @@ DefaultToxTabStopTokenHandler::HandleTabStopToken( // check whether a tab adjustment has been specified. if (SvxTabAdjust::End > aToken.eTabAlign) { - const SvxLRSpaceItem& rLR = targetNode.SwContentNode::GetAttr(RES_LR_SPACE); - + SvxTextLeftMarginItem const& rTextLeftMargin( + targetNode.SwContentNode::GetAttr(RES_MARGIN_TEXTLEFT)); tools::Long nTabPosition = aToken.nTabStopPosition; - if (!mTabPositionIsRelativeToParagraphIndent && rLR.GetTextLeft()) { - nTabPosition -= rLR.GetTextLeft(); + if (!mTabPositionIsRelativeToParagraphIndent && rTextLeftMargin.GetTextLeft() != 0) + { + nTabPosition -= rTextLeftMargin.GetTextLeft(); } result.tabStop = SvxTabStop(nTabPosition, aToken.eTabAlign, cDfltDecimalChar, aToken.cTabFillChar); return result; @@ -73,9 +74,12 @@ DefaultToxTabStopTokenHandler::HandleTabStopToken( //#i24363# tab stops relative to indent if (mTabStopReferencePolicy == TABSTOPS_RELATIVE_TO_INDENT) { // left margin of paragraph style - const SvxLRSpaceItem& rLRSpace = targetNode.GetTextColl()->GetLRSpace(); - nRightMargin -= rLRSpace.GetLeft(); - nRightMargin -= rLRSpace.GetTextFirstLineOffset(); + SvxFirstLineIndentItem const& rFirstLine( + targetNode.GetTextColl()->GetFirstLineIndent()); + SvxTextLeftMarginItem const& rTextLeftMargin( + targetNode.GetTextColl()->GetTextLeftMargin()); + nRightMargin -= rTextLeftMargin.GetLeft(rFirstLine); + nRightMargin -= rFirstLine.GetTextFirstLineOffset(); } result.tabStop = SvxTabStop(nRightMargin, SvxTabAdjust::Right, cDfltDecimalChar, aToken.cTabFillChar); diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx index ba7ab2b1f54f..ed2065f02c70 100644 --- a/sw/source/core/txtnode/ndtxt.cxx +++ b/sw/source/core/txtnode/ndtxt.cxx @@ -2976,7 +2976,7 @@ void SwTextNode::NumRuleChgd() // in the list tree reflected in the layout. // Important note: { - SvxLRSpaceItem& rLR = const_cast(GetSwAttrSet().GetLRSpace()); + SvxTextLeftMarginItem & rLR = const_cast(GetSwAttrSet().GetTextLeftMargin()); CallSwClientNotify(sw::LegacyModifyHint(&rLR, &rLR)); } @@ -3294,7 +3294,10 @@ tools::Long SwTextNode::GetLeftMarginWithNum( bool bTextLeft ) const } if( pRule->IsAbsSpaces() ) - nRet = nRet - GetSwAttrSet().GetLRSpace().GetLeft(); + { + SvxFirstLineIndentItem const& rFirst(GetSwAttrSet().GetFirstLineIndent()); + nRet = nRet - GetSwAttrSet().GetTextLeftMargin().GetLeft(rFirst); + } } else if ( rFormat.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT ) { @@ -3333,7 +3336,7 @@ bool SwTextNode::GetFirstLineOfsWithNum( short& rFLOffset ) const if (!getIDocumentSettingAccess()->get(DocumentSettingId::IGNORE_FIRST_LINE_INDENT_IN_NUMBERING)) { - SvxLRSpaceItem aItem = GetSwAttrSet().GetLRSpace(); + SvxFirstLineIndentItem const aItem(GetSwAttrSet().GetFirstLineIndent()); rFLOffset = rFLOffset + aItem.GetTextFirstLineOffset(); } } @@ -3345,7 +3348,7 @@ bool SwTextNode::GetFirstLineOfsWithNum( short& rFLOffset ) const } else if (!getIDocumentSettingAccess()->get(DocumentSettingId::IGNORE_FIRST_LINE_INDENT_IN_NUMBERING)) { - SvxLRSpaceItem aItem = GetSwAttrSet().GetLRSpace(); + SvxFirstLineIndentItem const aItem(GetSwAttrSet().GetFirstLineIndent()); rFLOffset = aItem.GetTextFirstLineOffset(); } } @@ -3354,7 +3357,7 @@ bool SwTextNode::GetFirstLineOfsWithNum( short& rFLOffset ) const return true; } - rFLOffset = GetSwAttrSet().GetLRSpace().GetTextFirstLineOffset(); + rFLOffset = GetSwAttrSet().GetFirstLineIndent().GetTextFirstLineOffset(); return false; } @@ -3368,12 +3371,13 @@ SwTwips SwTextNode::GetAdditionalIndentForStartingNewList() const const SwNumFormat& rFormat = pRule->Get(lcl_BoundListLevel(GetActualListLevel())); if ( rFormat.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION ) { - nAdditionalIndent = GetSwAttrSet().GetLRSpace().GetLeft(); + SvxFirstLineIndentItem const& rFirst(GetSwAttrSet().GetFirstLineIndent()); + nAdditionalIndent = GetSwAttrSet().GetTextLeftMargin().GetLeft(rFirst); if (getIDocumentSettingAccess()->get(DocumentSettingId::IGNORE_FIRST_LINE_INDENT_IN_NUMBERING)) { nAdditionalIndent = nAdditionalIndent - - GetSwAttrSet().GetLRSpace().GetTextFirstLineOffset(); + GetSwAttrSet().GetFirstLineIndent().GetTextFirstLineOffset(); } } else if ( rFormat.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT ) @@ -3384,25 +3388,29 @@ SwTwips SwTextNode::GetAdditionalIndentForStartingNewList() const } else { - nAdditionalIndent = GetSwAttrSet().GetLRSpace().GetLeft(); + SvxFirstLineIndentItem const& rFirst(GetSwAttrSet().GetFirstLineIndent()); + nAdditionalIndent = GetSwAttrSet().GetTextLeftMargin().GetLeft(rFirst); if (getIDocumentSettingAccess()->get(DocumentSettingId::IGNORE_FIRST_LINE_INDENT_IN_NUMBERING)) { nAdditionalIndent = nAdditionalIndent - - GetSwAttrSet().GetLRSpace().GetTextFirstLineOffset(); + GetSwAttrSet().GetFirstLineIndent().GetTextFirstLineOffset(); } } } } else { - nAdditionalIndent = GetSwAttrSet().GetLRSpace().GetLeft(); + SvxFirstLineIndentItem const& rFirst(GetSwAttrSet().GetFirstLineIndent()); + nAdditionalIndent = GetSwAttrSet().GetTextLeftMargin().GetLeft(rFirst); } return nAdditionalIndent; } // #i96772# -void SwTextNode::ClearLRSpaceItemDueToListLevelIndents( std::shared_ptr& o_rLRSpaceItem ) const +void SwTextNode::ClearLRSpaceItemDueToListLevelIndents( + std::unique_ptr& o_rFirstLineItem, + std::unique_ptr& o_rTextLeftMarginItem) const { if ( AreListLevelIndentsApplicable() ) { @@ -3412,7 +3420,8 @@ void SwTextNode::ClearLRSpaceItemDueToListLevelIndents( std::shared_ptrGet(lcl_BoundListLevel(GetActualListLevel())); if ( rFormat.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT ) { - o_rLRSpaceItem = std::make_shared(RES_LR_SPACE); + o_rFirstLineItem = std::make_unique(RES_MARGIN_FIRSTLINE); + o_rTextLeftMarginItem = std::make_unique(RES_MARGIN_TEXTLEFT); } } } @@ -3439,7 +3448,7 @@ tools::Long SwTextNode::GetLeftMarginForTabCalculation() const } if ( !bLeftMarginForTabCalcSetToListLevelIndent ) { - nLeftMarginForTabCalc = GetSwAttrSet().GetLRSpace().GetTextLeft(); + nLeftMarginForTabCalc = GetSwAttrSet().GetTextLeftMargin().GetTextLeft(); } return nLeftMarginForTabCalc; @@ -4690,7 +4699,7 @@ bool SwTextNode::GetListTabStopPosition( tools::Long& nListTabStopPosition ) con } else if (!getIDocumentSettingAccess()->get(DocumentSettingId::IGNORE_FIRST_LINE_INDENT_IN_NUMBERING)) { - SvxLRSpaceItem aItem = GetSwAttrSet().GetLRSpace(); + SvxTextLeftMarginItem const aItem(GetSwAttrSet().GetTextLeftMargin()); nListTabStopPosition -= aItem.GetTextLeft(); } } diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx index 59a931a406de..c31afa4abead 100644 --- a/sw/source/core/txtnode/thints.cxx +++ b/sw/source/core/txtnode/thints.cxx @@ -2121,10 +2121,10 @@ static void lcl_MergeListLevelIndentAsLRSpaceItem( const SwTextNode& rTextNode, const SwNumFormat& rFormat = pRule->Get(o3tl::narrowing(rTextNode.GetActualListLevel())); if ( rFormat.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT ) { - SvxLRSpaceItem aLR( RES_LR_SPACE ); - aLR.SetTextLeft( rFormat.GetIndentAt() ); - aLR.SetTextFirstLineOffset( static_cast(rFormat.GetFirstLineIndent()) ); - rSet.Put( aLR ); + SvxTextLeftMarginItem const leftMargin(rFormat.GetIndentAt(), RES_MARGIN_TEXTLEFT); + SvxFirstLineIndentItem const firstLine(static_cast(rFormat.GetFirstLineIndent()), RES_MARGIN_FIRSTLINE); + rSet.Put(firstLine); + rSet.Put(leftMargin); } } } diff --git a/sw/source/core/unocore/unomapproperties.hxx b/sw/source/core/unocore/unomapproperties.hxx index d849c4fcb36c..77cd36a1bb51 100644 --- a/sw/source/core/unocore/unomapproperties.hxx +++ b/sw/source/core/unocore/unomapproperties.hxx @@ -147,10 +147,10 @@ { UNO_NAME_PARA_GRAPHIC, RES_BACKGROUND, cppu::UnoType::get(), PropertyAttribute::MAYBEVOID, MID_GRAPHIC }, \ { UNO_NAME_PARA_GRAPHIC_FILTER, RES_BACKGROUND, cppu::UnoType::get(), PropertyAttribute::MAYBEVOID, MID_GRAPHIC_FILTER }, \ { UNO_NAME_PARA_GRAPHIC_LOCATION, RES_BACKGROUND, cppu::UnoType::get(), PropertyAttribute::MAYBEVOID, MID_GRAPHIC_POSITION }, \ - { UNO_NAME_PARA_LEFT_MARGIN, RES_LR_SPACE, cppu::UnoType::get(), PropertyAttribute::MAYBEVOID, MID_TXT_LMARGIN | CONVERT_TWIPS }, \ - { UNO_NAME_PARA_RIGHT_MARGIN, RES_LR_SPACE, cppu::UnoType::get(), PropertyAttribute::MAYBEVOID, MID_R_MARGIN | CONVERT_TWIPS }, \ - { UNO_NAME_PARA_IS_AUTO_FIRST_LINE_INDENT, RES_LR_SPACE, cppu::UnoType::get(), PropertyAttribute::MAYBEVOID, MID_FIRST_AUTO }, \ - { UNO_NAME_PARA_FIRST_LINE_INDENT, RES_LR_SPACE, cppu::UnoType::get(), PropertyAttribute::MAYBEVOID, MID_FIRST_LINE_INDENT | CONVERT_TWIPS }, \ + { UNO_NAME_PARA_LEFT_MARGIN, RES_MARGIN_TEXTLEFT, cppu::UnoType::get(), PropertyAttribute::MAYBEVOID, MID_TXT_LMARGIN | CONVERT_TWIPS }, \ + { UNO_NAME_PARA_RIGHT_MARGIN, RES_MARGIN_RIGHT, cppu::UnoType::get(), PropertyAttribute::MAYBEVOID, MID_R_MARGIN | CONVERT_TWIPS }, \ + { UNO_NAME_PARA_IS_AUTO_FIRST_LINE_INDENT, RES_MARGIN_FIRSTLINE, cppu::UnoType::get(), PropertyAttribute::MAYBEVOID, MID_FIRST_AUTO }, \ + { UNO_NAME_PARA_FIRST_LINE_INDENT, RES_MARGIN_FIRSTLINE, cppu::UnoType::get(), PropertyAttribute::MAYBEVOID, MID_FIRST_LINE_INDENT | CONVERT_TWIPS }, \ STANDARD_FONT_PROPERTIES \ CJK_FONT_PROPERTIES \ CTL_FONT_PROPERTIES \ @@ -392,13 +392,13 @@ { UNO_NAME_CHAR_OVERLINE, RES_CHRATR_OVERLINE , cppu::UnoType::get(), PROPERTY_NONE, MID_TL_STYLE},\ { UNO_NAME_CHAR_OVERLINE_COLOR, RES_CHRATR_OVERLINE , cppu::UnoType::get(), PROPERTY_NONE, MID_TL_COLOR},\ { UNO_NAME_CHAR_OVERLINE_HAS_COLOR, RES_CHRATR_OVERLINE , cppu::UnoType::get(), PROPERTY_NONE, MID_TL_HASCOLOR},\ - { UNO_NAME_PARA_LEFT_MARGIN, RES_LR_SPACE, cppu::UnoType::get(), PROPERTY_NONE, MID_TXT_LMARGIN|CONVERT_TWIPS},\ - { UNO_NAME_PARA_RIGHT_MARGIN, RES_LR_SPACE, cppu::UnoType::get(), PROPERTY_NONE, MID_R_MARGIN|CONVERT_TWIPS},\ - { UNO_NAME_PARA_LEFT_MARGIN_RELATIVE, RES_LR_SPACE, cppu::UnoType::get(), PROPERTY_NONE, MID_L_REL_MARGIN},\ - { UNO_NAME_PARA_RIGHT_MARGIN_RELATIVE, RES_LR_SPACE, cppu::UnoType::get(), PROPERTY_NONE, MID_R_REL_MARGIN},\ - { UNO_NAME_PARA_IS_AUTO_FIRST_LINE_INDENT, RES_LR_SPACE, cppu::UnoType::get(), PROPERTY_NONE, MID_FIRST_AUTO},\ - { UNO_NAME_PARA_FIRST_LINE_INDENT, RES_LR_SPACE, cppu::UnoType::get(), PROPERTY_NONE, MID_FIRST_LINE_INDENT|CONVERT_TWIPS},\ - { UNO_NAME_PARA_FIRST_LINE_INDENT_RELATIVE, RES_LR_SPACE, cppu::UnoType::get(), PROPERTY_NONE, MID_FIRST_LINE_REL_INDENT|CONVERT_TWIPS},\ + { UNO_NAME_PARA_LEFT_MARGIN, RES_MARGIN_TEXTLEFT, cppu::UnoType::get(), PROPERTY_NONE, MID_TXT_LMARGIN|CONVERT_TWIPS},\ + { UNO_NAME_PARA_RIGHT_MARGIN, RES_MARGIN_RIGHT, cppu::UnoType::get(), PROPERTY_NONE, MID_R_MARGIN|CONVERT_TWIPS},\ + { UNO_NAME_PARA_LEFT_MARGIN_RELATIVE, RES_MARGIN_TEXTLEFT, cppu::UnoType::get(), PROPERTY_NONE, MID_L_REL_MARGIN},\ + { UNO_NAME_PARA_RIGHT_MARGIN_RELATIVE, RES_MARGIN_RIGHT, cppu::UnoType::get(), PROPERTY_NONE, MID_R_REL_MARGIN},\ + { UNO_NAME_PARA_IS_AUTO_FIRST_LINE_INDENT, RES_MARGIN_FIRSTLINE, cppu::UnoType::get(), PROPERTY_NONE, MID_FIRST_AUTO},\ + { UNO_NAME_PARA_FIRST_LINE_INDENT, RES_MARGIN_FIRSTLINE, cppu::UnoType::get(), PROPERTY_NONE, MID_FIRST_LINE_INDENT|CONVERT_TWIPS},\ + { UNO_NAME_PARA_FIRST_LINE_INDENT_RELATIVE, RES_MARGIN_FIRSTLINE, cppu::UnoType::get(), PROPERTY_NONE, MID_FIRST_LINE_REL_INDENT|CONVERT_TWIPS},\ { UNO_NAME_CHAR_KERNING, RES_CHRATR_KERNING , cppu::UnoType::get() , PROPERTY_NONE, CONVERT_TWIPS},\ { UNO_NAME_CHAR_NO_HYPHENATION, RES_CHRATR_NOHYPHEN , cppu::UnoType::get() , PROPERTY_NONE, 0},\ { UNO_NAME_CHAR_SHADOWED, RES_CHRATR_SHADOWED , cppu::UnoType::get() , PROPERTY_NONE, 0},\ @@ -505,10 +505,10 @@ { UNO_NAME_NUMBERING_RULES, RES_PARATR_NUMRULE,cppu::UnoType::get(), PropertyAttribute::MAYBEVOID, CONVERT_TWIPS}, \ { UNO_NAME_PARA_ADJUST, RES_PARATR_ADJUST, cppu::UnoType::get(), PropertyAttribute::MAYBEVOID, MID_PARA_ADJUST}, \ { UNO_NAME_PARA_BOTTOM_MARGIN, RES_UL_SPACE, cppu::UnoType::get(), PropertyAttribute::MAYBEVOID, MID_LO_MARGIN|CONVERT_TWIPS}, \ - { UNO_NAME_PARA_FIRST_LINE_INDENT, RES_LR_SPACE, cppu::UnoType::get(), PropertyAttribute::MAYBEVOID, MID_FIRST_LINE_INDENT|CONVERT_TWIPS}, \ - { UNO_NAME_PARA_LEFT_MARGIN, RES_LR_SPACE, cppu::UnoType::get(), PropertyAttribute::MAYBEVOID, MID_TXT_LMARGIN|CONVERT_TWIPS}, \ + { UNO_NAME_PARA_FIRST_LINE_INDENT, RES_MARGIN_FIRSTLINE, cppu::UnoType::get(), PropertyAttribute::MAYBEVOID, MID_FIRST_LINE_INDENT|CONVERT_TWIPS}, \ + { UNO_NAME_PARA_LEFT_MARGIN, RES_MARGIN_TEXTLEFT, cppu::UnoType::get(), PropertyAttribute::MAYBEVOID, MID_TXT_LMARGIN|CONVERT_TWIPS}, \ { UNO_NAME_PARA_LINE_SPACING, RES_PARATR_LINESPACING, cppu::UnoType::get(), PropertyAttribute::MAYBEVOID, CONVERT_TWIPS}, \ - { UNO_NAME_PARA_RIGHT_MARGIN, RES_LR_SPACE, cppu::UnoType::get(), PropertyAttribute::MAYBEVOID, MID_R_MARGIN|CONVERT_TWIPS}, \ + { UNO_NAME_PARA_RIGHT_MARGIN, RES_MARGIN_RIGHT, cppu::UnoType::get(), PropertyAttribute::MAYBEVOID, MID_R_MARGIN|CONVERT_TWIPS}, \ { UNO_NAME_TABSTOPS, RES_PARATR_TABSTOP, cppu::UnoType< cppu::UnoSequenceType >::get(), PropertyAttribute::MAYBEVOID, CONVERT_TWIPS}, \ #define FILL_PROPERTIES_SW_BMP \ diff --git a/sw/source/core/unocore/unosrch.cxx b/sw/source/core/unocore/unosrch.cxx index b9ee20b02c33..096e4f8fca57 100644 --- a/sw/source/core/unocore/unosrch.cxx +++ b/sw/source/core/unocore/unosrch.cxx @@ -105,6 +105,9 @@ void SwSearchProperties_Impl::FillItemSet(SfxItemSet& rSet, bool bIsValueSearch) pLineSpaceItem , pLineNumItem , pKeepItem , + pFirstLineIndent, + pTextLeftMargin, + pRightMargin, pLRItem , pULItem , pBackItem , @@ -247,6 +250,15 @@ void SwSearchProperties_Impl::FillItemSet(SfxItemSet& rSet, bool bIsValueSearch) case RES_UL_SPACE: pTempItem = funcClone(nWID, pULItem); break; + case RES_MARGIN_FIRSTLINE: + pTempItem = funcClone(nWID, pFirstLineIndent); + break; + case RES_MARGIN_TEXTLEFT: + pTempItem = funcClone(nWID, pTextLeftMargin); + break; + case RES_MARGIN_RIGHT: + pTempItem = funcClone(nWID, pRightMargin); + break; case RES_LR_SPACE: pTempItem = funcClone(nWID, pLRItem); break; diff --git a/sw/source/filter/html/css1atr.cxx b/sw/source/filter/html/css1atr.cxx index 4180e94702d8..fe922c884ce5 100644 --- a/sw/source/filter/html/css1atr.cxx +++ b/sw/source/filter/html/css1atr.cxx @@ -138,6 +138,9 @@ static Writer& OutCSS1_SvxTextLn_SvxCrOut_SvxBlink( Writer& rWrt, static Writer& OutCSS1_SvxFontWeight( Writer& rWrt, const SfxPoolItem& rHt ); static Writer& OutCSS1_SvxPosture( Writer& rWrt, const SfxPoolItem& rHt ); static Writer& OutCSS1_SvxULSpace( Writer& rWrt, const SfxPoolItem& rHt ); +static Writer& OutCSS1_SvxFirstLineIndent(Writer& rWrt, const SfxPoolItem& rHt); +static Writer& OutCSS1_SvxTextLeftMargin(Writer& rWrt, const SfxPoolItem& rHt); +static Writer& OutCSS1_SvxRightMargin(Writer& rWrt, const SfxPoolItem& rHt); static Writer& OutCSS1_SvxLRSpace( Writer& rWrt, const SfxPoolItem& rHt ); static Writer& OutCSS1_SvxULSpace_SvxLRSpace( Writer& rWrt, const SvxULSpaceItem *pULSpace, @@ -2862,6 +2865,67 @@ static Writer& OutCSS1_SwFormatFrameSize( Writer& rWrt, const SfxPoolItem& rHt, return rWrt; } +static Writer& OutCSS1_SvxFirstLineIndent(Writer & rWrt, SfxPoolItem const& rHt) +{ + SwHTMLWriter & rHTMLWrt = static_cast(rWrt); + + const SvxFirstLineIndentItem & rFirstLine(static_cast(rHt)); + + // No Export of a firm attribute is needed if the new values + // match that of the current template + + // The LineIndent of the first line might contain the room for numbering + tools::Long nFirstLineIndent = static_cast(rFirstLine.GetTextFirstLineOffset()) + - rHTMLWrt.m_nFirstLineIndent; + if (rHTMLWrt.m_nDfltFirstLineIndent != nFirstLineIndent) + { + rHTMLWrt.OutCSS1_UnitProperty(sCSS1_P_text_indent, nFirstLineIndent); + } + + return rWrt; +} + +static Writer& OutCSS1_SvxTextLeftMargin(Writer & rWrt, SfxPoolItem const& rHt) +{ + SwHTMLWriter & rHTMLWrt = static_cast(rWrt); + + const SvxTextLeftMarginItem& rLeftMargin(static_cast(rHt)); + + // No Export of a firm attribute is needed if the new values + // match that of the current template + + // A left margin can exist because of a list nearby + tools::Long nLeftMargin = rLeftMargin.GetTextLeft() - rHTMLWrt.m_nLeftMargin; + if (rHTMLWrt.m_nDfltLeftMargin != nLeftMargin) + { + rHTMLWrt.OutCSS1_UnitProperty(sCSS1_P_margin_left, nLeftMargin); + + // max-width = max-width - margin-left for TOC paragraphs with dot leaders + if (rHTMLWrt.m_bParaDotLeaders) + rHTMLWrt.OutCSS1_UnitProperty(sCSS1_P_max_width, tools::Long(DOT_LEADERS_MAX_WIDTH/2.54*72*20) - nLeftMargin); + + } + + return rWrt; +} + +static Writer& OutCSS1_SvxRightMargin(Writer & rWrt, SfxPoolItem const& rHt) +{ + SwHTMLWriter & rHTMLWrt = static_cast(rWrt); + + const SvxRightMarginItem& rRightMargin(static_cast(rHt)); + + // No Export of a firm attribute is needed if the new values + // match that of the current template + + if (rHTMLWrt.m_nDfltRightMargin != rRightMargin.GetRight()) + { + rHTMLWrt.OutCSS1_UnitProperty(sCSS1_P_margin_right, rRightMargin.GetRight()); + } + + return rWrt; +} + static Writer& OutCSS1_SvxLRSpace( Writer& rWrt, const SfxPoolItem& rHt ) { SwHTMLWriter & rHTMLWrt = static_cast(rWrt); @@ -3531,6 +3595,12 @@ SwAttrFnTab const aCSS1AttrFnTab = { /* RES_FILL_ORDER */ nullptr, /* RES_FRM_SIZE */ nullptr, /* RES_PAPER_BIN */ nullptr, +/* RES_MARGIN_FIRSTLINE */ OutCSS1_SvxFirstLineIndent, +/* RES_MARGIN_TEXTLEFT */ OutCSS1_SvxTextLeftMargin, +/* RES_MARGIN_RIGHT */ OutCSS1_SvxRightMargin, +/* RES_MARGIN_LEFT */ nullptr, +/* RES_MARGIN_GUTTER */ nullptr, +/* RES_MARGIN_GUTTER_RIGHT */ nullptr, /* RES_LR_SPACE */ OutCSS1_SvxLRSpace, /* RES_UL_SPACE */ OutCSS1_SvxULSpace, /* RES_PAGEDESC */ nullptr, diff --git a/sw/source/filter/html/htmlatr.cxx b/sw/source/filter/html/htmlatr.cxx index 3b05399e2bea..5988270e615c 100644 --- a/sw/source/filter/html/htmlatr.cxx +++ b/sw/source/filter/html/htmlatr.cxx @@ -367,11 +367,15 @@ SwHTMLFormatInfo::SwHTMLFormatInfo( const SwFormat *pF, SwDoc *pDoc, SwDoc *pTem // remember all the different default spacings from the style or // the comparison style. - const SvxLRSpaceItem &rLRSpace = - (pReferenceFormat ? pReferenceFormat : pFormat)->GetLRSpace(); - nLeftMargin = rLRSpace.GetTextLeft(); - nRightMargin = rLRSpace.GetRight(); - nFirstLineIndent = rLRSpace.GetTextFirstLineOffset(); + SvxFirstLineIndentItem const& rFirstLine( + (pReferenceFormat ? pReferenceFormat : pFormat)->GetFirstLineIndent()); + SvxTextLeftMarginItem const& rTextLeftMargin( + (pReferenceFormat ? pReferenceFormat : pFormat)->GetTextLeftMargin()); + SvxRightMarginItem const& rRightMargin( + (pReferenceFormat ? pReferenceFormat : pFormat)->GetRightMargin()); + nLeftMargin = rTextLeftMargin.GetTextLeft(); + nRightMargin = rRightMargin.GetRight(); + nFirstLineIndent = rFirstLine.GetTextFirstLineOffset(); const SvxULSpaceItem &rULSpace = (pReferenceFormat ? pReferenceFormat : pFormat)->GetULSpace(); @@ -628,17 +632,20 @@ static void OutHTML_SwFormat( Writer& rWrt, const SwFormat& rFormat, (rWrt.m_pCurrentPam->GetPoint()->GetNodeIndex() != rWrt.m_pCurrentPam->GetMark()->GetNodeIndex()); // If styles are exported, indented paragraphs become definition lists - const SvxLRSpaceItem& rLRSpace = - pNodeItemSet ? pNodeItemSet->Get(RES_LR_SPACE) - : rFormat.GetLRSpace(); + SvxFirstLineIndentItem const& rFirstLine( + pNodeItemSet ? pNodeItemSet->Get(RES_MARGIN_FIRSTLINE) + : rFormat.GetFirstLineIndent()); + SvxTextLeftMarginItem const& rTextLeftMargin( + pNodeItemSet ? pNodeItemSet->Get(RES_MARGIN_TEXTLEFT) + : rFormat.GetTextLeftMargin()); if( (!rHWrt.m_bCfgOutStyles || bForceDL) && !rInfo.bInNumberBulletList ) { sal_Int32 nLeftMargin; if( bForceDL ) - nLeftMargin = rLRSpace.GetTextLeft(); + nLeftMargin = rTextLeftMargin.GetTextLeft(); else - nLeftMargin = rLRSpace.GetTextLeft() > pFormatInfo->nLeftMargin - ? rLRSpace.GetTextLeft() - pFormatInfo->nLeftMargin + nLeftMargin = rTextLeftMargin.GetTextLeft() > pFormatInfo->nLeftMargin + ? rTextLeftMargin.GetTextLeft() - pFormatInfo->nLeftMargin : 0; if( nLeftMargin > 0 && rHWrt.m_nDefListMargin > 0 ) @@ -706,10 +713,10 @@ static void OutHTML_SwFormat( Writer& rWrt, const SwFormat& rFormat, if( rInfo.bInNumberBulletList ) { if( !rHWrt.IsHTMLMode( HTMLMODE_LSPACE_IN_NUMBER_BULLET ) ) - rHWrt.m_nDfltLeftMargin = rLRSpace.GetTextLeft(); + rHWrt.m_nDfltLeftMargin = rTextLeftMargin.GetTextLeft(); // In numbered lists, don't output a first line indent. - rHWrt.m_nFirstLineIndent = rLRSpace.GetTextFirstLineOffset(); + rHWrt.m_nFirstLineIndent = rFirstLine.GetTextFirstLineOffset(); } if( rInfo.bInNumberBulletList && bNumbered && bPara && !rHWrt.m_bCfgOutStyles ) @@ -2029,10 +2036,15 @@ Writer& OutHTML_SwTextNode( Writer& rWrt, const SwContentNode& rNode ) aHtml.endAttribute(); return rHTMLWrt; } - if( const SvxLRSpaceItem* pItem = pItemSet->GetItemIfSet( RES_LR_SPACE, false )) + if (pItemSet->GetItemIfSet(RES_MARGIN_FIRSTLINE, false) + || pItemSet->GetItemIfSet(RES_MARGIN_TEXTLEFT, false) + || pItemSet->GetItemIfSet(RES_MARGIN_RIGHT, false)) { - sal_Int32 nLeft = pItem->GetLeft(); - sal_Int32 nRight = pItem->GetRight(); + SvxFirstLineIndentItem const& rFirstLine(pItemSet->Get(RES_MARGIN_FIRSTLINE)); + SvxTextLeftMarginItem const& rTextLeftMargin(pItemSet->Get(RES_MARGIN_TEXTLEFT)); + SvxRightMarginItem const& rRightMargin(pItemSet->Get(RES_MARGIN_RIGHT)); + sal_Int32 const nLeft(rTextLeftMargin.GetLeft(rFirstLine)); + sal_Int32 const nRight(rRightMargin.GetRight()); if( nLeft || nRight ) { const SwFrameFormat& rPgFormat = @@ -3311,6 +3323,12 @@ SwAttrFnTab aHTMLAttrFnTab = { /* RES_FILL_ORDER */ nullptr, /* RES_FRM_SIZE */ nullptr, /* RES_PAPER_BIN */ nullptr, +/* RES_MARGIN_FIRSTLINE */ nullptr, +/* RES_MARGIN_TEXTLEFT */ nullptr, +/* RES_MARGIN_RIGHT */ nullptr, +/* RES_MARGIN_LEFT */ nullptr, +/* RES_MARGIN_GUTTER */ nullptr, +/* RES_MARGIN_GUTTER_RIGHT */ nullptr, /* RES_LR_SPACE */ nullptr, /* RES_UL_SPACE */ nullptr, /* RES_PAGEDESC */ nullptr, diff --git a/sw/source/filter/html/htmlcss1.cxx b/sw/source/filter/html/htmlcss1.cxx index c4e601825931..92e5d0d94d3a 100644 --- a/sw/source/filter/html/htmlcss1.cxx +++ b/sw/source/filter/html/htmlcss1.cxx @@ -268,27 +268,12 @@ static void SetTextCollAttrs( SwTextFormatColl *pColl, SfxItemSet& rItemSet, SwCSS1Parser *pCSS1Parser ) { const SfxItemSet& rCollItemSet = pColl->GetAttrSet(); - const SvxLRSpaceItem* pCollLRItem; - const SvxLRSpaceItem* pLRItem; - // left, right border and first line indentation - if( (rPropInfo.m_bLeftMargin || rPropInfo.m_bRightMargin || - rPropInfo.m_bTextIndent) && - (!rPropInfo.m_bLeftMargin || !rPropInfo.m_bRightMargin || - !rPropInfo.m_bTextIndent) && - (pCollLRItem = rCollItemSet.GetItemIfSet(RES_LR_SPACE)) && - (pLRItem = rItemSet.GetItemIfSet(RES_LR_SPACE,false)) ) - { - SvxLRSpaceItem aLRItem( *pCollLRItem ); - if( rPropInfo.m_bLeftMargin ) - aLRItem.SetTextLeft( pLRItem->GetTextLeft() ); - if( rPropInfo.m_bRightMargin ) - aLRItem.SetRight( pLRItem->GetRight() ); - if( rPropInfo.m_bTextIndent ) - aLRItem.SetTextFirstLineOffset( pLRItem->GetTextFirstLineOffset() ); - - rItemSet.Put( aLRItem ); - } + // note: there was some SvxLRSpaceItem code here that was nonobvious + // but it looks like the only cases in which it would be required + // with split items are if some nProp != 100 or if SetAutoFirst() had + // been called (on the pColl items) but it looks like none of these are + // possible in HTML import. // top and bottom border const SvxULSpaceItem* pCollULItem; @@ -444,26 +429,49 @@ void SwCSS1Parser::SetPageDescAttrs( const SwPageDesc *pPageDesc, bool bChanged = false; // left, right border and first line indentation - const SvxLRSpaceItem *pLRItem; - if( (rPropInfo.m_bLeftMargin || rPropInfo.m_bRightMargin) && - (pLRItem = rItemSet.GetItemIfSet(RES_LR_SPACE,false)) ) + ::std::optional oLRSpace; + assert(!rItemSet.GetItemIfSet(RES_LR_SPACE,false)); + if (rPropInfo.m_bLeftMargin) { - const SvxLRSpaceItem* pPageItem; - if( (!rPropInfo.m_bLeftMargin || !rPropInfo.m_bRightMargin) && - (pPageItem = rPageItemSet.GetItemIfSet(RES_LR_SPACE)) ) + // note: parser never creates SvxLeftMarginItem! must be converted + if (SvxTextLeftMarginItem const*const pLeft = rItemSet.GetItemIfSet(RES_MARGIN_TEXTLEFT, false)) { - SvxLRSpaceItem aLRItem( *pPageItem ); - if( rPropInfo.m_bLeftMargin ) - aLRItem.SetLeft( pLRItem->GetLeft() ); - if( rPropInfo.m_bRightMargin ) - aLRItem.SetRight( pLRItem->GetRight() ); - - rMaster.SetFormatAttr( aLRItem ); + if (!oLRSpace) + { + if (const SvxLRSpaceItem* pPageItem = rPageItemSet.GetItemIfSet(RES_LR_SPACE)) + { + oLRSpace.emplace(*pPageItem); + } + else + { + oLRSpace.emplace(RES_LR_SPACE); + } + } + oLRSpace->SetLeft(pLeft->GetTextLeft()); } - else + } + if (rPropInfo.m_bRightMargin) + { + // note: parser never creates SvxLeftMarginItem! must be converted + if (SvxRightMarginItem const*const pRight = rItemSet.GetItemIfSet(RES_MARGIN_RIGHT, false)) { - rMaster.SetFormatAttr( *pLRItem ); + if (!oLRSpace) + { + if (const SvxLRSpaceItem* pPageItem = rPageItemSet.GetItemIfSet(RES_LR_SPACE)) + { + oLRSpace.emplace(*pPageItem); + } + else + { + oLRSpace.emplace(RES_LR_SPACE); + } + } + oLRSpace->SetRight(pRight->GetRight()); } + } + if (oLRSpace) + { + rMaster.SetFormatAttr(*oLRSpace); bChanged = true; } @@ -1479,12 +1487,13 @@ void SwCSS1Parser::FillDropCap( SwFormatDrop& rDrop, rDrop.GetLines() = nLines; // a right border becomes the spacing to text! - if( const SvxLRSpaceItem* pLRSpaceItem = rItemSet.GetItemIfSet( RES_LR_SPACE, false ) ) + if (const SvxRightMarginItem *const pRightMargin = rItemSet.GetItemIfSet(RES_MARGIN_RIGHT, false)) { - rDrop.GetDistance() = static_cast< sal_uInt16 >( - pLRSpaceItem->GetRight() ); - rItemSet.ClearItem( RES_LR_SPACE ); + rDrop.GetDistance() = static_cast(pRightMargin->GetRight()); + rItemSet.ClearItem(RES_MARGIN_RIGHT); } + rItemSet.ClearItem(RES_MARGIN_FIRSTLINE); + rItemSet.ClearItem(RES_MARGIN_TEXTLEFT); // for every other attribute create a character style if( !rItemSet.Count() ) @@ -1598,8 +1607,14 @@ HTMLAttr **SwHTMLParser::GetAttrTabEntry( sal_uInt16 nWhich ) ppAttr = &m_xAttrTab->pAdjust; break; - case RES_LR_SPACE: - ppAttr = &m_xAttrTab->pLRSpace; + case RES_MARGIN_FIRSTLINE: + ppAttr = &m_xAttrTab->pFirstLineIndent; + break; + case RES_MARGIN_TEXTLEFT: + ppAttr = &m_xAttrTab->pTextLeftMargin; + break; + case RES_MARGIN_RIGHT: + ppAttr = &m_xAttrTab->pRightMargin; break; case RES_UL_SPACE: ppAttr = &m_xAttrTab->pULSpace; diff --git a/sw/source/filter/html/htmlctxt.cxx b/sw/source/filter/html/htmlctxt.cxx index 70b26ad07e1e..80245ba2ea6a 100644 --- a/sw/source/filter/html/htmlctxt.cxx +++ b/sw/source/filter/html/htmlctxt.cxx @@ -565,18 +565,36 @@ void SwHTMLParser::InsertAttrs( SfxItemSet &rItemSet, SfxItemIter aIter( rItemSet ); + const SvxFirstLineIndentItem * pFirstLineItem(nullptr); + const SvxTextLeftMarginItem * pTextLeftMargin(nullptr); + const SvxRightMarginItem * pRightMargin(nullptr); + for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = aIter.NextItem()) { - HTMLAttr **ppAttr = nullptr; - switch( pItem->Which() ) { - case RES_LR_SPACE: + case RES_MARGIN_FIRSTLINE: + { + pFirstLineItem = static_cast(pItem); + } + break; + case RES_MARGIN_TEXTLEFT: + { + pTextLeftMargin = static_cast(pItem); + } + break; + case RES_MARGIN_RIGHT: + { + pRightMargin = static_cast(pItem); + } + break; + } + } + +#if 1 { // Paragraph indents need to be added and are generated for each paragraphs // (here for the first paragraph only, all the following in SetTextCollAttrs) - const SvxLRSpaceItem *pLRItem = - static_cast(pItem); // Get old paragraph indents without the top context (that's the one we're editing) sal_uInt16 nOldLeft = 0, nOldRight = 0; @@ -598,7 +616,8 @@ void SwHTMLParser::InsertAttrs( SfxItemSet &rItemSet, if( rPropInfo.m_bLeftMargin ) { OSL_ENSURE( rPropInfo.m_nLeftMargin < 0 || - rPropInfo.m_nLeftMargin == pLRItem->GetTextLeft(), + !pTextLeftMargin || + rPropInfo.m_nLeftMargin == pTextLeftMargin->GetTextLeft(), "left margin does not match with item" ); if( rPropInfo.m_nLeftMargin < 0 && -rPropInfo.m_nLeftMargin > nOldLeft ) @@ -609,7 +628,8 @@ void SwHTMLParser::InsertAttrs( SfxItemSet &rItemSet, if( rPropInfo.m_bRightMargin ) { OSL_ENSURE( rPropInfo.m_nRightMargin < 0 || - rPropInfo.m_nRightMargin == pLRItem->GetRight(), + !pRightMargin || + rPropInfo.m_nRightMargin == pRightMargin->GetRight(), "right margin does not match with item" ); if( rPropInfo.m_nRightMargin < 0 && -rPropInfo.m_nRightMargin > nOldRight ) @@ -617,21 +637,31 @@ void SwHTMLParser::InsertAttrs( SfxItemSet &rItemSet, else nRight = nOldRight + static_cast< sal_uInt16 >(rPropInfo.m_nRightMargin); } - if( rPropInfo.m_bTextIndent ) - nIndent = pLRItem->GetTextFirstLineOffset(); + if (rPropInfo.m_bTextIndent && pFirstLineItem) + nIndent = pFirstLineItem->GetTextFirstLineOffset(); // Remember the value for the following paragraphs pContext->SetMargins( nLeft, nRight, nIndent ); // Set the attribute on the current paragraph - SvxLRSpaceItem aLRItem( *pLRItem ); - aLRItem.SetTextFirstLineOffset( nIndent ); - aLRItem.SetTextLeft( nLeft ); - aLRItem.SetRight( nRight ); - NewAttr(m_xAttrTab, &m_xAttrTab->pLRSpace, aLRItem); - EndAttr( m_xAttrTab->pLRSpace, false ); + SvxFirstLineIndentItem const firstLine(nIndent, RES_MARGIN_FIRSTLINE); + NewAttr(m_xAttrTab, &m_xAttrTab->pFirstLineIndent, firstLine); + EndAttr(m_xAttrTab->pFirstLineIndent, false); + SvxTextLeftMarginItem const leftMargin(nLeft, RES_MARGIN_TEXTLEFT); + NewAttr(m_xAttrTab, &m_xAttrTab->pTextLeftMargin, leftMargin); + EndAttr(m_xAttrTab->pTextLeftMargin, false); + SvxRightMarginItem const rightMargin(nRight, RES_MARGIN_RIGHT); + NewAttr(m_xAttrTab, &m_xAttrTab->pRightMargin, rightMargin); + EndAttr(m_xAttrTab->pRightMargin, false); } - break; +#endif + + for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = aIter.NextItem()) + { + HTMLAttr **ppAttr = nullptr; + + switch( pItem->Which() ) + { case RES_UL_SPACE: if( !rPropInfo.m_bTopMargin || !rPropInfo.m_bBottomMargin ) diff --git a/sw/source/filter/html/htmldrawreader.cxx b/sw/source/filter/html/htmldrawreader.cxx index 4c5ea2dbcb9f..809aa5bec0c3 100644 --- a/sw/source/filter/html/htmldrawreader.cxx +++ b/sw/source/filter/html/htmldrawreader.cxx @@ -98,22 +98,25 @@ void SwHTMLParser::InsertDrawObject( SdrObject* pNewDrawObj, } // set left/right border - if( const SvxLRSpaceItem* pLRItem = rCSS1ItemSet.GetItemIfSet( RES_LR_SPACE ) ) + // note: parser never creates SvxLeftMarginItem! must be converted + if (const SvxTextLeftMarginItem *const pLeft = rCSS1ItemSet.GetItemIfSet(RES_MARGIN_TEXTLEFT)) { - // maybe flatten the first line indentation - SvxLRSpaceItem aLRItem( *pLRItem ); - aLRItem.SetTextFirstLineOffset( 0 ); if( rCSS1PropInfo.m_bLeftMargin ) { - nLeftSpace = static_cast< sal_uInt16 >(aLRItem.GetLeft()); + // should be SvxLeftMarginItem... "cast" it + nLeftSpace = static_cast(pLeft->GetTextLeft()); rCSS1PropInfo.m_bLeftMargin = false; } + rCSS1ItemSet.ClearItem(RES_MARGIN_TEXTLEFT); + } + if (const SvxRightMarginItem *const pRight = rCSS1ItemSet.GetItemIfSet(RES_MARGIN_RIGHT)) + { if( rCSS1PropInfo.m_bRightMargin ) { - nRightSpace = static_cast< sal_uInt16 >(aLRItem.GetRight()); + nRightSpace = static_cast< sal_uInt16 >(pRight->GetRight()); rCSS1PropInfo.m_bRightMargin = false; } - rCSS1ItemSet.ClearItem( RES_LR_SPACE ); + rCSS1ItemSet.ClearItem(RES_MARGIN_RIGHT); } if( nLeftSpace || nRightSpace ) { diff --git a/sw/source/filter/html/htmlflywriter.cxx b/sw/source/filter/html/htmlflywriter.cxx index 2cf3c6894ec1..927d4fad4bba 100644 --- a/sw/source/filter/html/htmlflywriter.cxx +++ b/sw/source/filter/html/htmlflywriter.cxx @@ -319,9 +319,11 @@ void SwHTMLWriter::CollectFlyFrames() (pAnchorNode = rAnchor.GetAnchorNode()) != nullptr && (pACNd = pAnchorNode->GetContentNode()) != nullptr ) { - const SvxLRSpaceItem& rLRItem = - pACNd->GetAttr(RES_LR_SPACE); - if( rLRItem.GetTextLeft() || rLRItem.GetRight() ) + const SvxTextLeftMarginItem& rTextLeftMargin = + pACNd->GetAttr(RES_MARGIN_TEXTLEFT); + const SvxRightMarginItem& rRightMargin = + pACNd->GetAttr(RES_MARGIN_RIGHT); + if (rTextLeftMargin.GetTextLeft() || rRightMargin.GetRight()) { nMode = aHTMLOutFrameParaFrameTable[eType][m_nExportMode]; break; diff --git a/sw/source/filter/html/htmlform.cxx b/sw/source/filter/html/htmlform.cxx index e264ec609b24..ddb37c6f9341 100644 --- a/sw/source/filter/html/htmlform.cxx +++ b/sw/source/filter/html/htmlform.cxx @@ -886,22 +886,25 @@ uno::Reference< drawing::XShape > SwHTMLParser::InsertControl( uno::Reference< beans::XPropertySet > xShapePropSet( xCreate, UNO_QUERY ); // set left/right border - if( const SvxLRSpaceItem* pLRItem = rCSS1ItemSet.GetItemIfSet( RES_LR_SPACE ) ) + // note: parser never creates SvxLeftMarginItem! must be converted + if (const SvxTextLeftMarginItem *const pLeft = rCSS1ItemSet.GetItemIfSet(RES_MARGIN_TEXTLEFT)) { - // Flatten first line indent - SvxLRSpaceItem aLRItem( *pLRItem ); - aLRItem.SetTextFirstLineOffset( 0 ); if( rCSS1PropInfo.m_bLeftMargin ) { - nLeftSpace = convertTwipToMm100( aLRItem.GetLeft() ); + // should be SvxLeftMarginItem... "cast" it + nLeftSpace = convertTwipToMm100(pLeft->GetTextLeft()); rCSS1PropInfo.m_bLeftMargin = false; } + rCSS1ItemSet.ClearItem(RES_MARGIN_TEXTLEFT); + } + if (const SvxRightMarginItem *const pRight = rCSS1ItemSet.GetItemIfSet(RES_MARGIN_RIGHT)) + { if( rCSS1PropInfo.m_bRightMargin ) { - nRightSpace = convertTwipToMm100( aLRItem.GetRight() ); + nRightSpace = convertTwipToMm100(pRight->GetRight()); rCSS1PropInfo.m_bRightMargin = false; } - rCSS1ItemSet.ClearItem( RES_LR_SPACE ); + rCSS1ItemSet.ClearItem(RES_MARGIN_RIGHT); } if( nLeftSpace || nRightSpace ) { diff --git a/sw/source/filter/html/htmlnumreader.cxx b/sw/source/filter/html/htmlnumreader.cxx index 3564fd5ebac1..191ba1e21add 100644 --- a/sw/source/filter/html/htmlnumreader.cxx +++ b/sw/source/filter/html/htmlnumreader.cxx @@ -280,7 +280,7 @@ void SwHTMLParser::NewNumberBulletList( HtmlTokenId nToken ) if( aPropInfo.m_bTextIndent ) { short nTextIndent = - aItemSet.Get( RES_LR_SPACE ).GetTextFirstLineOffset(); + aItemSet.Get(RES_MARGIN_FIRSTLINE).GetTextFirstLineOffset(); aNumFormat.SetFirstLineOffset( nTextIndent ); bChangeNumFormat = true; } @@ -297,7 +297,7 @@ void SwHTMLParser::NewNumberBulletList( HtmlTokenId nToken ) } aPropInfo.m_bLeftMargin = aPropInfo.m_bTextIndent = false; if( !aPropInfo.m_bRightMargin ) - aItemSet.ClearItem( RES_LR_SPACE ); + aItemSet.ClearItem(RES_MARGIN_RIGHT); // superfluous? // #i89812# - Perform change to list style before calling , // because may open a new context and thus may diff --git a/sw/source/filter/html/htmlplug.cxx b/sw/source/filter/html/htmlplug.cxx index 1aec184d8a6c..a8cb6d34cfa0 100644 --- a/sw/source/filter/html/htmlplug.cxx +++ b/sw/source/filter/html/htmlplug.cxx @@ -258,22 +258,25 @@ void SwHTMLParser::SetSpace( const Size& rPixSpace, } // set left/right margin - if( const SvxLRSpaceItem* pLRItem = rCSS1ItemSet.GetItemIfSet( RES_LR_SPACE ) ) + // note: parser never creates SvxLeftMarginItem! must be converted + if (const SvxTextLeftMarginItem *const pLeft = rCSS1ItemSet.GetItemIfSet(RES_MARGIN_TEXTLEFT)) { - // if applicable remove the first line indent - SvxLRSpaceItem aLRItem( *pLRItem ); - aLRItem.SetTextFirstLineOffset( 0 ); if( rCSS1PropInfo.m_bLeftMargin ) { - nLeftSpace = aLRItem.GetLeft(); + // should be SvxLeftMarginItem... "cast" it + nLeftSpace = pLeft->GetTextLeft(); rCSS1PropInfo.m_bLeftMargin = false; } + rCSS1ItemSet.ClearItem(RES_MARGIN_TEXTLEFT); + } + if (const SvxRightMarginItem *const pRight = rCSS1ItemSet.GetItemIfSet(RES_MARGIN_RIGHT)) + { if( rCSS1PropInfo.m_bRightMargin ) { - nRightSpace = aLRItem.GetRight(); + nRightSpace = pRight->GetRight(); rCSS1PropInfo.m_bRightMargin = false; } - rCSS1ItemSet.ClearItem( RES_LR_SPACE ); + rCSS1ItemSet.ClearItem(RES_MARGIN_RIGHT); } if( nLeftSpace > 0 || nRightSpace > 0 ) { diff --git a/sw/source/filter/html/svxcss1.cxx b/sw/source/filter/html/svxcss1.cxx index 9b312e0b3239..076871c0ac71 100644 --- a/sw/source/filter/html/svxcss1.cxx +++ b/sw/source/filter/html/svxcss1.cxx @@ -57,6 +57,8 @@ #include #include +#include + #include "css1kywd.hxx" #include "svxcss1.hxx" #include "htmlnum.hxx" @@ -284,7 +286,7 @@ struct SvxCSS1ItemIds sal_uInt16 nOrphans; sal_uInt16 nFormatSplit; - TypedWhichId nLRSpace{0}; + // this looks a bit superflous? TypedWhichId nLRSpace{0}; TypedWhichId nULSpace{0}; sal_uInt16 nBox; sal_uInt16 nBrush; @@ -739,7 +741,10 @@ SvxCSS1Parser::SvxCSS1Parser( SfxItemPool& rPool, OUString aBaseURL, aItemIds.nOrphans = initTrueWhich( SID_ATTR_PARA_ORPHANS ); aItemIds.nFormatSplit = initTrueWhich( SID_ATTR_PARA_SPLIT ); - aItemIds.nLRSpace = TypedWhichId(initTrueWhich( SID_ATTR_LRSPACE )); + // every id that is used must be added + m_aWhichMap = m_aWhichMap.MergeRange(RES_MARGIN_FIRSTLINE, RES_MARGIN_FIRSTLINE); + m_aWhichMap = m_aWhichMap.MergeRange(RES_MARGIN_TEXTLEFT, RES_MARGIN_TEXTLEFT); + m_aWhichMap = m_aWhichMap.MergeRange(RES_MARGIN_RIGHT, RES_MARGIN_RIGHT); aItemIds.nULSpace = TypedWhichId(initTrueWhich( SID_ATTR_ULSPACE )); aItemIds.nBox = initTrueWhich( SID_ATTR_BORDER_OUTER ); aItemIds.nBrush = initTrueWhich( SID_ATTR_BRUSH ); @@ -944,25 +949,24 @@ void SvxCSS1Parser::MergeStyles( const SfxItemSet& rSrcSet, } else { - SvxLRSpaceItem aLRSpace( rTargetSet.Get(aItemIds.nLRSpace) ); - SvxULSpaceItem aULSpace( rTargetSet.Get(aItemIds.nULSpace) ); - - rTargetSet.Put( rSrcSet ); - - if( rSrcInfo.m_bLeftMargin || rSrcInfo.m_bRightMargin || - rSrcInfo.m_bTextIndent ) + // not sure if this is really necessary? + SfxItemSet copy(rSrcSet); + if (!rSrcInfo.m_bTextIndent) + { + copy.ClearItem(RES_MARGIN_FIRSTLINE); + } + if (!rSrcInfo.m_bLeftMargin) { - const SvxLRSpaceItem& rNewLRSpace = rSrcSet.Get( aItemIds.nLRSpace ); + copy.ClearItem(RES_MARGIN_TEXTLEFT); + } + if (!rSrcInfo.m_bRightMargin) + { + copy.ClearItem(RES_MARGIN_RIGHT); + } - if( rSrcInfo.m_bLeftMargin ) - aLRSpace.SetLeft( rNewLRSpace.GetLeft() ); - if( rSrcInfo.m_bRightMargin ) - aLRSpace.SetRight( rNewLRSpace.GetRight() ); - if( rSrcInfo.m_bTextIndent ) - aLRSpace.SetTextFirstLineOffset( rNewLRSpace.GetTextFirstLineOffset() ); + SvxULSpaceItem aULSpace( rTargetSet.Get(aItemIds.nULSpace) ); - rTargetSet.Put( aLRSpace ); - } + rTargetSet.Put(copy); if( rSrcInfo.m_bTopMargin || rSrcInfo.m_bBottomMargin ) { @@ -1991,18 +1995,8 @@ static void ParseCSS1_text_indent( const CSS1Expression *pExpr, if( !bSet ) return; - if( const SvxLRSpaceItem* pItem = rItemSet.GetItemIfSet( aItemIds.nLRSpace, false ) ) - { - SvxLRSpaceItem aLRItem( *pItem ); - aLRItem.SetTextFirstLineOffset( nIndent ); - rItemSet.Put( aLRItem ); - } - else - { - SvxLRSpaceItem aLRItem( aItemIds.nLRSpace ); - aLRItem.SetTextFirstLineOffset( nIndent ); - rItemSet.Put( aLRItem ); - } + SvxFirstLineIndentItem const firstLine(nIndent, RES_MARGIN_FIRSTLINE); + rItemSet.Put(firstLine); rPropInfo.m_bTextIndent = true; } @@ -2058,18 +2052,10 @@ static void ParseCSS1_margin_left( const CSS1Expression *pExpr, rPropInfo.m_nLeftMargin = nLeft; if( nLeft < 0 ) nLeft = 0; - if( const SvxLRSpaceItem* pItem = rItemSet.GetItemIfSet( aItemIds.nLRSpace, false ) ) - { - SvxLRSpaceItem aLRItem( *pItem ); - aLRItem.SetTextLeft( o3tl::narrowing(nLeft) ); - rItemSet.Put( aLRItem ); - } - else - { - SvxLRSpaceItem aLRItem( aItemIds.nLRSpace ); - aLRItem.SetTextLeft( o3tl::narrowing(nLeft) ); - rItemSet.Put( aLRItem ); - } + + // TODO: other things may need a SvxLeftMarginItem ? but they currently convert it anyway so they can convert that too. + SvxTextLeftMarginItem const leftMargin(o3tl::narrowing(nLeft), RES_MARGIN_TEXTLEFT); + rItemSet.Put(leftMargin); rPropInfo.m_bLeftMargin = true; } @@ -2121,18 +2107,9 @@ static void ParseCSS1_margin_right( const CSS1Expression *pExpr, rPropInfo.m_nRightMargin = nRight; if( nRight < 0 ) nRight = 0; - if( const SvxLRSpaceItem* pItem = rItemSet.GetItemIfSet( aItemIds.nLRSpace, false ) ) - { - SvxLRSpaceItem aLRItem( *pItem ); - aLRItem.SetRight( o3tl::narrowing(nRight) ); - rItemSet.Put( aLRItem ); - } - else - { - SvxLRSpaceItem aLRItem( aItemIds.nLRSpace ); - aLRItem.SetRight( o3tl::narrowing(nRight) ); - rItemSet.Put( aLRItem ); - } + + SvxRightMarginItem rightMargin(o3tl::narrowing(nRight), RES_MARGIN_RIGHT); + rItemSet.Put(rightMargin); rPropInfo.m_bRightMargin = true; } @@ -2349,23 +2326,15 @@ static void ParseCSS1_margin( const CSS1Expression *pExpr, nMargins[1] = 0; } - if( const SvxLRSpaceItem* pItem = rItemSet.GetItemIfSet( aItemIds.nLRSpace, false ) ) + if (bSetMargins[3]) { - SvxLRSpaceItem aLRItem( *pItem ); - if( bSetMargins[3] ) - aLRItem.SetLeft( o3tl::narrowing(nMargins[3]) ); - if( bSetMargins[1] ) - aLRItem.SetRight( o3tl::narrowing(nMargins[1]) ); - rItemSet.Put( aLRItem ); + SvxTextLeftMarginItem const leftMargin(o3tl::narrowing(nMargins[3]), RES_MARGIN_TEXTLEFT); + rItemSet.Put(leftMargin); } - else + if (bSetMargins[1]) { - SvxLRSpaceItem aLRItem( aItemIds.nLRSpace ); - if( bSetMargins[3] ) - aLRItem.SetLeft( o3tl::narrowing(nMargins[3]) ); - if( bSetMargins[1] ) - aLRItem.SetRight( o3tl::narrowing(nMargins[1]) ); - rItemSet.Put( aLRItem ); + SvxRightMarginItem const rightMargin(o3tl::narrowing(nMargins[1]), RES_MARGIN_RIGHT); + rItemSet.Put(rightMargin); } } diff --git a/sw/source/filter/html/swhtml.cxx b/sw/source/filter/html/swhtml.cxx index fbd5eadd1028..f6f52c8a45a3 100644 --- a/sw/source/filter/html/swhtml.cxx +++ b/sw/source/filter/html/swhtml.cxx @@ -2769,7 +2769,7 @@ void SwHTMLParser::SetAttr_( bool bChkEnd, bool bBeforeTable, // which can't be set. Because the attributes are inserted with // SETATTR_DONTREPLACE, they should be able to be set later. bSetAttr = ( nEndParaIdx < rEndPos.GetNodeIndex() && - (RES_LR_SPACE != nWhich || !GetNumInfo().GetNumRule()) ) || + ((RES_MARGIN_FIRSTLINE != nWhich && RES_MARGIN_TEXTLEFT != nWhich) || !GetNumInfo().GetNumRule()) ) || ( !pAttr->IsLikePara() && nEndParaIdx == rEndPos.GetNodeIndex() && pAttr->GetEndContent() < nEndCnt && @@ -2951,6 +2951,12 @@ void SwHTMLParser::SetAttr_( bool bChkEnd, bool bBeforeTable, continue; case RES_LR_SPACE: + assert(false); + break; + + case RES_MARGIN_FIRSTLINE: + case RES_MARGIN_TEXTLEFT: + case RES_MARGIN_RIGHT: if( aAttrPam.GetPoint()->GetNodeIndex() == aAttrPam.GetMark()->GetNodeIndex()) { @@ -4396,10 +4402,10 @@ void SwHTMLParser::NewDefList() { // and the one of the DT-style of the current level - SvxLRSpaceItem rLRSpace = + SvxTextLeftMarginItem const& rTextLeftMargin = m_pCSS1Parser->GetTextFormatColl(RES_POOLCOLL_HTML_DD, OUString()) - ->GetLRSpace(); - nLeft = nLeft + static_cast< sal_uInt16 >(rLRSpace.GetTextLeft()); + ->GetTextLeftMargin(); + nLeft = nLeft + static_cast(rTextLeftMargin.GetTextLeft()); } xCntxt->SetMargins( nLeft, nRight, nIndent ); @@ -4738,20 +4744,20 @@ void SwHTMLParser::SetTextCollAttrs( HTMLAttrContext *pContext ) const SwTextFormatColl *pTopColl = m_pCSS1Parser->GetTextFormatColl( nTopColl, rTopClass ); const SfxItemSet& rItemSet = pTopColl->GetAttrSet(); - if( const SvxLRSpaceItem *pLRItem = rItemSet.GetItemIfSet(RES_LR_SPACE) ) + if (rItemSet.GetItemIfSet(RES_MARGIN_FIRSTLINE) + || rItemSet.GetItemIfSet(RES_MARGIN_TEXTLEFT) + || rItemSet.GetItemIfSet(RES_MARGIN_RIGHT)) { - sal_Int32 nLeft = pLRItem->GetTextLeft(); - sal_Int32 nRight = pLRItem->GetRight(); - nFirstLineIndent = pLRItem->GetTextFirstLineOffset(); + sal_Int32 nLeft = rItemSet.Get(RES_MARGIN_TEXTLEFT).GetTextLeft(); + sal_Int32 nRight = rItemSet.Get(RES_MARGIN_RIGHT).GetRight(); + nFirstLineIndent = rItemSet.Get(RES_MARGIN_FIRSTLINE).GetTextFirstLineOffset(); // In Definition lists the margins also contain the margins from the previous levels if( RES_POOLCOLL_HTML_DD == nTopColl ) { - const SvxLRSpaceItem& rDTLRSpace = m_pCSS1Parser - ->GetTextFormatColl(RES_POOLCOLL_HTML_DT, OUString()) - ->GetLRSpace(); - nLeft -= rDTLRSpace.GetTextLeft(); - nRight -= rDTLRSpace.GetRight(); + auto const*const pColl(m_pCSS1Parser->GetTextFormatColl(RES_POOLCOLL_HTML_DT, OUString())); + nLeft -= pColl->GetTextLeftMargin().GetTextLeft(); + nRight -= pColl->GetRightMargin().GetRight(); } else if( RES_POOLCOLL_HTML_DT == nTopColl ) { @@ -4776,13 +4782,18 @@ void SwHTMLParser::SetTextCollAttrs( HTMLAttrContext *pContext ) if( !pCollToSet ) { pCollToSet = m_pCSS1Parser->GetTextCollFromPool( nDfltColl ); - const SvxLRSpaceItem& rLRItem = pCollToSet->GetLRSpace(); if( !nLeftMargin ) - nLeftMargin = static_cast< sal_uInt16 >(rLRItem.GetTextLeft()); + { + nLeftMargin = static_cast(pCollToSet->GetTextLeftMargin().GetTextLeft()); + } if( !nRightMargin ) - nRightMargin = static_cast< sal_uInt16 >(rLRItem.GetRight()); + { + nRightMargin = static_cast(pCollToSet->GetRightMargin().GetRight()); + } if( !nFirstLineIndent ) - nFirstLineIndent = rLRItem.GetTextFirstLineOffset(); + { + nFirstLineIndent = pCollToSet->GetFirstLineIndent().GetTextFirstLineOffset(); + } } // remove previous hard attribution of paragraph @@ -4794,25 +4805,41 @@ void SwHTMLParser::SetTextCollAttrs( HTMLAttrContext *pContext ) m_xDoc->SetTextFormatColl( *m_pPam, pCollToSet ); // if applicable correct the paragraph indent - const SvxLRSpaceItem& rLRItem = pCollToSet->GetLRSpace(); - bool bSetLRSpace = nLeftMargin != rLRItem.GetTextLeft() || - nFirstLineIndent != rLRItem.GetTextFirstLineOffset() || - nRightMargin != rLRItem.GetRight(); + const SvxFirstLineIndentItem & rFirstLine = pCollToSet->GetFirstLineIndent(); + const SvxTextLeftMarginItem & rTextLeftMargin = pCollToSet->GetTextLeftMargin(); + const SvxRightMarginItem & rRightMargin = pCollToSet->GetRightMargin(); + bool bSetLRSpace = nLeftMargin != rTextLeftMargin.GetTextLeft() || + nFirstLineIndent != rFirstLine.GetTextFirstLineOffset() || + nRightMargin != rRightMargin.GetRight(); if( bSetLRSpace ) { - SvxLRSpaceItem aLRItem( rLRItem ); - aLRItem.SetTextLeft( nLeftMargin ); - aLRItem.SetRight( nRightMargin ); - aLRItem.SetTextFirstLineOffset( nFirstLineIndent ); + SvxFirstLineIndentItem firstLine(rFirstLine); + SvxTextLeftMarginItem leftMargin(rTextLeftMargin); + SvxRightMarginItem rightMargin(rRightMargin); + firstLine.SetTextFirstLineOffset(nFirstLineIndent); + leftMargin.SetTextLeft(nLeftMargin); + rightMargin.SetRight(nRightMargin); if( pItemSet ) - pItemSet->Put( aLRItem ); + { + pItemSet->Put(firstLine); + pItemSet->Put(leftMargin); + pItemSet->Put(rightMargin); + } else { - NewAttr(m_xAttrTab, &m_xAttrTab->pLRSpace, aLRItem); - m_xAttrTab->pLRSpace->SetLikePara(); - m_aParaAttrs.push_back( m_xAttrTab->pLRSpace ); - EndAttr( m_xAttrTab->pLRSpace, false ); + NewAttr(m_xAttrTab, &m_xAttrTab->pFirstLineIndent, firstLine); + m_xAttrTab->pFirstLineIndent->SetLikePara(); + m_aParaAttrs.push_back(m_xAttrTab->pFirstLineIndent); + EndAttr(m_xAttrTab->pFirstLineIndent, false); + NewAttr(m_xAttrTab, &m_xAttrTab->pTextLeftMargin, leftMargin); + m_xAttrTab->pTextLeftMargin->SetLikePara(); + m_aParaAttrs.push_back(m_xAttrTab->pTextLeftMargin); + EndAttr(m_xAttrTab->pTextLeftMargin, false); + NewAttr(m_xAttrTab, &m_xAttrTab->pRightMargin, rightMargin); + m_xAttrTab->pRightMargin->SetLikePara(); + m_aParaAttrs.push_back(m_xAttrTab->pRightMargin); + EndAttr(m_xAttrTab->pRightMargin, false); } } @@ -5035,13 +5062,16 @@ void SwHTMLParser::InsertSpacer() GetMarginsFromContextWithNumberBullet( nLeft, nRight, nIndent ); nIndent = nIndent + static_cast(nSize); - SvxLRSpaceItem aLRItem( RES_LR_SPACE ); - aLRItem.SetTextLeft( nLeft ); - aLRItem.SetRight( nRight ); - aLRItem.SetTextFirstLineOffset( nIndent ); + SvxFirstLineIndentItem const firstLine(nIndent, RES_MARGIN_FIRSTLINE); + SvxTextLeftMarginItem const leftMargin(nLeft, RES_MARGIN_TEXTLEFT); + SvxRightMarginItem const rightMargin(nRight, RES_MARGIN_RIGHT); - NewAttr(m_xAttrTab, &m_xAttrTab->pLRSpace, aLRItem); - EndAttr( m_xAttrTab->pLRSpace, false ); + NewAttr(m_xAttrTab, &m_xAttrTab->pFirstLineIndent, firstLine); + EndAttr(m_xAttrTab->pFirstLineIndent, false); + NewAttr(m_xAttrTab, &m_xAttrTab->pTextLeftMargin, leftMargin); + EndAttr(m_xAttrTab->pTextLeftMargin, false); + NewAttr(m_xAttrTab, &m_xAttrTab->pRightMargin, rightMargin); + EndAttr(m_xAttrTab->pRightMargin, false); } else { @@ -5332,27 +5362,36 @@ void SwHTMLParser::InsertHorzRule() const SwFormatColl *pColl = (static_cast(nWidth) < nBrowseWidth) ? GetCurrFormatColl() : nullptr; if (pColl) { - SvxLRSpaceItem aLRItem( pColl->GetLRSpace() ); tools::Long nDist = nBrowseWidth - nWidth; + ::std::optional oLeft; + ::std::optional oRight; switch( eAdjust ) { case SvxAdjust::Right: - aLRItem.SetTextLeft( o3tl::narrowing(nDist) ); + oLeft.emplace(o3tl::narrowing(nDist), RES_MARGIN_RIGHT); break; case SvxAdjust::Left: - aLRItem.SetRight( o3tl::narrowing(nDist) ); + oRight.emplace(o3tl::narrowing(nDist)); break; case SvxAdjust::Center: default: nDist /= 2; - aLRItem.SetTextLeft( o3tl::narrowing(nDist) ); - aLRItem.SetRight( o3tl::narrowing(nDist) ); + oLeft.emplace(o3tl::narrowing(nDist)); + oRight.emplace(o3tl::narrowing(nDist)); break; } - HTMLAttr* pTmp = new HTMLAttr(*m_pPam->GetPoint(), aLRItem, nullptr, std::shared_ptr()); - m_aSetAttrTab.push_back( pTmp ); + if (oLeft) + { + HTMLAttr* pTmp = new HTMLAttr(*m_pPam->GetPoint(), *oLeft, nullptr, std::shared_ptr()); + m_aSetAttrTab.push_back( pTmp ); + } + if (oRight) + { + HTMLAttr* pTmp = new HTMLAttr(*m_pPam->GetPoint(), *oRight, nullptr, std::shared_ptr()); + m_aSetAttrTab.push_back( pTmp ); + } } } } diff --git a/sw/source/filter/html/swhtml.hxx b/sw/source/filter/html/swhtml.hxx index 629364bcc15e..a605ba13f908 100644 --- a/sw/source/filter/html/swhtml.hxx +++ b/sw/source/filter/html/swhtml.hxx @@ -88,7 +88,9 @@ struct HTMLAttrTable HTMLAttr* pBreak; HTMLAttr* pPageDesc; - HTMLAttr* pLRSpace; // paragraph attributes + HTMLAttr* pFirstLineIndent; // paragraph attributes + HTMLAttr* pTextLeftMargin; + HTMLAttr* pRightMargin; HTMLAttr* pULSpace; HTMLAttr* pLineSpacing; HTMLAttr* pAdjust; diff --git a/sw/source/filter/html/wrthtml.cxx b/sw/source/filter/html/wrthtml.cxx index 21d25d434eb6..9d3e683db7f1 100644 --- a/sw/source/filter/html/wrthtml.cxx +++ b/sw/source/filter/html/wrthtml.cxx @@ -470,7 +470,7 @@ ErrCode SwHTMLWriter::WriteStream() m_nDefListLvl = 0; m_nDefListMargin = ((m_xTemplate.is() && !m_bCfgOutStyles) ? m_xTemplate.get() : m_pDoc) ->getIDocumentStylePoolAccess().GetTextCollFromPool( RES_POOLCOLL_HTML_DD, false ) - ->GetLRSpace().GetTextLeft(); + ->GetTextLeftMargin().GetTextLeft(); m_nHeaderFooterSpace = 0; m_nTextAttrsToIgnore = 0; m_nCSS1OutMode = 0; diff --git a/sw/source/filter/ww8/attributeoutputbase.hxx b/sw/source/filter/ww8/attributeoutputbase.hxx index 99cae10812cc..faa8b700e31e 100644 --- a/sw/source/filter/ww8/attributeoutputbase.hxx +++ b/sw/source/filter/ww8/attributeoutputbase.hxx @@ -559,6 +559,13 @@ protected: /// Sfx item RES_PAPER_BIN virtual void FormatPaperBin( const SvxPaperBinItem& ) = 0; + /// Sfx item RES_MARGIN_FIRSTLINE + virtual void FormatFirstLineIndent(const SvxFirstLineIndentItem & rFirstLine) = 0; + /// Sfx item RES_MARGIN_TEXTLEFT + virtual void FormatTextLeftMargin(const SvxTextLeftMarginItem & rTextLeftMargin) = 0; + /// Sfx item RES_MARGIN_RIGHT + virtual void FormatRightMargin(const SvxRightMarginItem & rRightMargin) = 0; + /// Sfx item RES_LR_SPACE virtual void FormatLRSpace( const SvxLRSpaceItem& ) = 0; diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index c36b57a0df18..ff8ed2763cb9 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -1317,6 +1317,7 @@ void DocxAttributeOutput::StartParagraphProperties() void DocxAttributeOutput::InitCollectedParagraphProperties() { + m_pLRSpaceAttrList.clear(); m_pParagraphSpacingAttrList.clear(); // Write the elements in the spec order @@ -1376,6 +1377,12 @@ void DocxAttributeOutput::WriteCollectedParagraphProperties() m_pSerializer->singleElementNS( XML_w, XML_framePr, xAttrList ); } + if (m_pLRSpaceAttrList.is()) + { + rtl::Reference xAttrList = std::move(m_pLRSpaceAttrList); + m_pSerializer->singleElementNS(XML_w, XML_ind, xAttrList); + } + if ( m_pParagraphSpacingAttrList.is() ) { rtl::Reference xAttrList = std::move( m_pParagraphSpacingAttrList ); @@ -3885,6 +3892,8 @@ void DocxAttributeOutput::Redline( const SwRedlineData* pRedlineData) // we are done exporting the redline attributes. rtl::Reference pFlyAttrList_Original(m_rExport.SdrExporter().getFlyAttrList()); m_rExport.SdrExporter().getFlyAttrList().clear(); + rtl::Reference pLRSpaceAttrList_Original(m_pLRSpaceAttrList); + m_pLRSpaceAttrList.clear(); rtl::Reference pParagraphSpacingAttrList_Original(m_pParagraphSpacingAttrList); m_pParagraphSpacingAttrList.clear(); @@ -3897,6 +3906,7 @@ void DocxAttributeOutput::Redline( const SwRedlineData* pRedlineData) // Revert back the original values that were stored in 'm_rExport.SdrExporter().getFlyAttrList()', 'm_pParagraphSpacingAttrList' m_rExport.SdrExporter().getFlyAttrList() = pFlyAttrList_Original; + m_pLRSpaceAttrList = pLRSpaceAttrList_Original; m_pParagraphSpacingAttrList = pParagraphSpacingAttrList_Original; m_pSerializer->endElementNS( XML_w, XML_pPr ); @@ -8688,7 +8698,7 @@ void DocxAttributeOutput::ParaTabStop( const SvxTabStopItem& rTabStop ) // But in ODT, zero position could be page margins or paragraph indent according to used settings. tools::Long tabsOffset = 0; if (m_rExport.m_rDoc.getIDocumentSettingAccess().get(DocumentSettingId::TABS_RELATIVE_TO_INDENT)) - tabsOffset = m_rExport.GetItem(RES_LR_SPACE).GetTextLeft(); + tabsOffset = m_rExport.GetItem(RES_MARGIN_TEXTLEFT).GetTextLeft(); // clear unused inherited tabs - otherwise the style will add them back in sal_Int32 nCurrTab = 0; @@ -8848,10 +8858,67 @@ void DocxAttributeOutput::FormatPaperBin( const SvxPaperBinItem& ) SAL_INFO("sw.ww8", "TODO DocxAttributeOutput::FormatPaperBin()" ); } +void DocxAttributeOutput::FormatFirstLineIndent(SvxFirstLineIndentItem const& rFirstLine) +{ + sal_Int32 const nFirstLineAdjustment(rFirstLine.GetTextFirstLineOffset()); + if (nFirstLineAdjustment > 0) + { + AddToAttrList(m_pLRSpaceAttrList, 1, FSNS(XML_w, XML_firstLine), + OString::number(nFirstLineAdjustment).getStr()); + } + else + { + AddToAttrList(m_pLRSpaceAttrList, 1, FSNS(XML_w, XML_hanging), + OString::number(- nFirstLineAdjustment).getStr()); + } +} + +void DocxAttributeOutput::FormatTextLeftMargin(SvxTextLeftMarginItem const& rTextLeftMargin) +{ + SvxTextLeftMarginItem const* pTextLeftMargin(&rTextLeftMargin); + ::std::optional oCopy; + if (dynamic_cast(GetExport().m_pOutFormatNode) != nullptr) + { + auto pTextNd(static_cast(GetExport().m_pOutFormatNode)); + // WW doesn't have a concept of a paragraph that's in a list but not + // counted in the list - see AttributeOutputBase::ParaNumRule() + // forcing non-existent numId="0" in this case. + // This means WW won't apply the indents from the numbering, + // so try to add them as paragraph properties here. + if (!pTextNd->IsCountedInList()) + { + SfxItemSetFixed temp(m_rExport.m_rDoc.GetAttrPool()); + pTextNd->GetParaAttr(temp, 0, 0, false, true, true, nullptr); + if (auto *const pItem = temp.GetItem(RES_MARGIN_TEXTLEFT)) + { + oCopy.emplace(*pItem); + pTextLeftMargin = &*oCopy; + } + } + } + bool const bEcma1st(m_rExport.GetFilter().getVersion() == oox::core::ECMA_376_1ST_EDITION); + AddToAttrList(m_pLRSpaceAttrList, 1, + FSNS(XML_w, (bEcma1st ? XML_left : XML_start)), + OString::number(pTextLeftMargin->GetTextLeft()).getStr()); +} + +void DocxAttributeOutput::FormatRightMargin(SvxRightMarginItem const& rRightMargin) +{ + // (paragraph case, this will be an else branch once others are converted) +#if 0 + else +#endif + { + bool const bEcma1st(m_rExport.GetFilter().getVersion() == oox::core::ECMA_376_1ST_EDITION); + AddToAttrList(m_pLRSpaceAttrList, 1, + FSNS(XML_w, (bEcma1st ? XML_right : XML_end)), + OString::number(rRightMargin.GetRight()).getStr()); + } +} + void DocxAttributeOutput::FormatLRSpace( const SvxLRSpaceItem& rLRSpace ) { bool const bEcma = m_rExport.GetFilter().getVersion() == oox::core::ECMA_376_1ST_EDITION; - if (m_rExport.SdrExporter().getTextFrameSyntax()) { m_rExport.SdrExporter().getTextFrameStyle().append(";mso-wrap-distance-left:" + OString::number(double(rLRSpace.GetLeft()) / 20) + "pt"); @@ -8889,29 +8956,10 @@ void DocxAttributeOutput::FormatLRSpace( const SvxLRSpaceItem& rLRSpace ) } else { + // note: this is not possible for SwTextNode but is for EditEngine! SvxLRSpaceItem const* pLRSpace(&rLRSpace); ::std::optional oLRSpace; - if (dynamic_cast(GetExport().m_pOutFormatNode) != nullptr) - { - auto pTextNd(static_cast(GetExport().m_pOutFormatNode)); - // WW doesn't have a concept of a paragraph that's in a list but not - // counted in the list - see AttributeOutputBase::ParaNumRule() - // forcing non-existent numId="0" in this case. - // This means WW won't apply the indents from the numbering, - // so try to add them as paragraph properties here. - if (!pTextNd->IsCountedInList()) - { - SfxItemSetFixed temp(m_rExport.m_rDoc.GetAttrPool()); - pTextNd->GetParaAttr(temp, 0, 0, false, true, true, nullptr); - if (auto *const pItem = temp.GetItem(RES_LR_SPACE)) - { - // but don't use first-line offset from list (should it be 0 or from node?) - oLRSpace.emplace(*pItem); - oLRSpace->SetTextFirstLineOffset(pLRSpace->GetTextFirstLineOffset()); - pLRSpace = &*oLRSpace; - } - } - } + assert(dynamic_cast(GetExport().m_pOutFormatNode) == nullptr); rtl::Reference pLRSpaceAttrList = FastSerializerHelper::createAttrList(); if ((0 != pLRSpace->GetTextLeft()) || (pLRSpace->IsExplicitZeroMarginValLeft())) { diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx index 867c6d72e810..99f7c7c55803 100644 --- a/sw/source/filter/ww8/docxattributeoutput.hxx +++ b/sw/source/filter/ww8/docxattributeoutput.hxx @@ -655,6 +655,13 @@ protected: /// Sfx item RES_PAPER_BIN virtual void FormatPaperBin( const SvxPaperBinItem& ) override; + /// Sfx item RES_MARGIN_FIRSTLINE + virtual void FormatFirstLineIndent(const SvxFirstLineIndentItem & rFirstLine) override; + /// Sfx item RES_MARGIN_TEXTLEFT + virtual void FormatTextLeftMargin(const SvxTextLeftMarginItem & rTextLeftMargin) override; + /// Sfx item RES_MARGIN_RIGHT + virtual void FormatRightMargin(const SvxRightMarginItem & rRightMargin) override; + /// Sfx item RES_LR_SPACE virtual void FormatLRSpace( const SvxLRSpaceItem& rLRSpace ) override; @@ -786,6 +793,7 @@ private: rtl::Reference m_pEastAsianLayoutAttrList; rtl::Reference m_pCharLangAttrList; rtl::Reference m_pSectionSpacingAttrList; + rtl::Reference m_pLRSpaceAttrList; rtl::Reference m_pParagraphSpacingAttrList; rtl::Reference m_pHyperlinkAttrList; std::shared_ptr m_pContentControl; diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx index 75a2b5b08f56..1b03e94d0a7c 100644 --- a/sw/source/filter/ww8/rtfattributeoutput.cxx +++ b/sw/source/filter/ww8/rtfattributeoutput.cxx @@ -2997,7 +2997,9 @@ void RtfAttributeOutput::ParaTabStop(const SvxTabStopItem& rTabStop) // Tabs are absolute by default. if (m_rExport.m_rDoc.getIDocumentSettingAccess().get( DocumentSettingId::TABS_RELATIVE_TO_INDENT)) - nOffset = m_rExport.GetItem(RES_LR_SPACE).GetTextLeft(); + { + nOffset = m_rExport.GetItem(RES_MARGIN_TEXTLEFT).GetTextLeft(); + } for (sal_uInt16 n = 0; n < rTabStop.Count(); n++) { @@ -3088,9 +3090,10 @@ void RtfAttributeOutput::ParaNumRule_Impl(const SwTextNode* pTextNd, sal_Int32 n m_aStyles.append(OOO_STRING_SVTOOLS_RTF_PLAIN); m_aStyles.append(' '); - SvxLRSpaceItem aLR(rNdSet.Get(RES_LR_SPACE)); - aLR.SetTextLeft(aLR.GetTextLeft() + pFormat->GetIndentAt()); - aLR.SetTextFirstLineOffset(pFormat->GetFirstLineOffset()); //TODO: overflow + SvxFirstLineIndentItem firstLine(rNdSet.Get(RES_MARGIN_FIRSTLINE)); + SvxTextLeftMarginItem leftMargin(rNdSet.Get(RES_MARGIN_TEXTLEFT)); + leftMargin.SetTextLeft(leftMargin.GetTextLeft() + pFormat->GetIndentAt()); + firstLine.SetTextFirstLineOffset(pFormat->GetFirstLineOffset()); //TODO: overflow sal_uInt16 nStyle = m_rExport.GetId(pFormat->GetCharFormat()); OString* pString = m_rExport.GetStyle(nStyle); @@ -3136,7 +3139,8 @@ void RtfAttributeOutput::ParaNumRule_Impl(const SwTextNode* pTextNd, sal_Int32 n m_aStyles.append(static_cast(m_rExport.GetNumberingId(*pRule)) + 1); m_aStyles.append(' '); } - FormatLRSpace(aLR); + FormatFirstLineIndent(firstLine); + FormatTextLeftMargin(leftMargin); } void RtfAttributeOutput::ParaScriptSpace(const SfxBoolItem& rScriptSpace) @@ -3208,6 +3212,34 @@ void RtfAttributeOutput::FormatPaperBin(const SvxPaperBinItem& /*rItem*/) SAL_INFO("sw.rtf", "TODO: " << __func__); } +void RtfAttributeOutput::FormatFirstLineIndent(SvxFirstLineIndentItem const& rFirstLine) +{ + m_aStyles.append(OOO_STRING_SVTOOLS_RTF_FI); + m_aStyles.append(static_cast(rFirstLine.GetTextFirstLineOffset())); +} + +void RtfAttributeOutput::FormatTextLeftMargin(SvxTextLeftMarginItem const& rTextLeftMargin) +{ + m_aStyles.append(OOO_STRING_SVTOOLS_RTF_LI); + m_aStyles.append(static_cast(rTextLeftMargin.GetTextLeft())); + m_aStyles.append(OOO_STRING_SVTOOLS_RTF_LIN); + m_aStyles.append(static_cast(rTextLeftMargin.GetTextLeft())); +} + +void RtfAttributeOutput::FormatRightMargin(SvxRightMarginItem const& rRightMargin) +{ +// (paragraph case, this will be an else branch once others are converted) +#if 0 + else +#endif + { + m_aStyles.append(OOO_STRING_SVTOOLS_RTF_RI); + m_aStyles.append(static_cast(rRightMargin.GetRight())); + m_aStyles.append(OOO_STRING_SVTOOLS_RTF_RIN); + m_aStyles.append(static_cast(rRightMargin.GetRight())); + } +} + void RtfAttributeOutput::FormatLRSpace(const SvxLRSpaceItem& rLRSpace) { if (!m_rExport.m_bOutFlyFrameAttrs) diff --git a/sw/source/filter/ww8/rtfattributeoutput.hxx b/sw/source/filter/ww8/rtfattributeoutput.hxx index 5042b523ba1a..985df695b2d9 100644 --- a/sw/source/filter/ww8/rtfattributeoutput.hxx +++ b/sw/source/filter/ww8/rtfattributeoutput.hxx @@ -399,6 +399,13 @@ protected: /// Sfx item RES_PAPER_BIN void FormatPaperBin(const SvxPaperBinItem& rItem) override; + /// Sfx item RES_MARGIN_FIRSTLINE + virtual void FormatFirstLineIndent(const SvxFirstLineIndentItem& rFirstLine) override; + /// Sfx item RES_MARGIN_TEXTLEFT + virtual void FormatTextLeftMargin(const SvxTextLeftMarginItem& rTextLeftMargin) override; + /// Sfx item RES_MARGIN_RIGHT + virtual void FormatRightMargin(const SvxRightMarginItem& rRightMargin) override; + /// Sfx item RES_LR_SPACE void FormatLRSpace(const SvxLRSpaceItem& rLRSpace) override; diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx index 2b741c322477..9bcc4e1e2d30 100644 --- a/sw/source/filter/ww8/wrtw8nds.cxx +++ b/sw/source/filter/ww8/wrtw8nds.cxx @@ -2638,13 +2638,13 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode ) { // Allow MSO to emulate LO footnote text starting at left margin - only meaningful with hanging indent sal_Int32 nFirstLineIndent=0; - SfxItemSetFixed aSet( m_rDoc.GetAttrPool() ); + SfxItemSetFixed aSet( m_rDoc.GetAttrPool() ); if ( pTextNode && pTextNode->GetAttr(aSet) ) { - const SvxLRSpaceItem* pLRSpace = aSet.GetItem(RES_LR_SPACE); - if ( pLRSpace ) - nFirstLineIndent = pLRSpace->GetTextFirstLineOffset(); + const SvxFirstLineIndentItem *const pFirstLine(aSet.GetItem(RES_MARGIN_FIRSTLINE)); + if (pFirstLine) + nFirstLineIndent = pFirstLine->GetTextFirstLineOffset(); } // Insert tab for aesthetic purposes #i24762# @@ -2932,12 +2932,13 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode ) if( !oTmpSet ) oTmpSet.emplace( rNode.GetSwAttrSet() ); - SvxLRSpaceItem aLR(oTmpSet->Get(RES_LR_SPACE)); + SvxFirstLineIndentItem firstLine(oTmpSet->Get(RES_MARGIN_FIRSTLINE)); + SvxTextLeftMarginItem leftMargin(oTmpSet->Get(RES_MARGIN_TEXTLEFT)); // #i86652# if ( pFormat->GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION ) { - aLR.SetTextLeft( aLR.GetTextLeft() + pFormat->GetAbsLSpace() ); + leftMargin.SetTextLeft(leftMargin.GetTextLeft() + pFormat->GetAbsLSpace()); } if( rNode.IsNumbered() && rNode.IsCountedInList() ) @@ -2948,11 +2949,11 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode ) { if (bParaRTL) { - aLR.SetTextFirstLineOffsetValue(aLR.GetTextFirstLineOffset() + pFormat->GetAbsLSpace() - pFormat->GetFirstLineOffset()); //TODO: overflow + firstLine.SetTextFirstLineOffsetValue(firstLine.GetTextFirstLineOffset() + pFormat->GetAbsLSpace() - pFormat->GetFirstLineOffset()); //TODO: overflow } else { - aLR.SetTextFirstLineOffset(aLR.GetTextFirstLineOffset() + GetWordFirstLineOffset(*pFormat)); + firstLine.SetTextFirstLineOffset(firstLine.GetTextFirstLineOffset() + GetWordFirstLineOffset(*pFormat)); } } @@ -2972,7 +2973,8 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode ) SvxNumberFormat::LABEL_ALIGNMENT && !rNode.AreListLevelIndentsApplicable() ) { - oTmpSet->Put( aLR ); + oTmpSet->Put(firstLine); + oTmpSet->Put(leftMargin); } } } @@ -2983,7 +2985,8 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode ) if ( pFormat->GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION ) { - oTmpSet->Put(aLR); + oTmpSet->Put(firstLine); + oTmpSet->Put(leftMargin); //#i21847# SvxTabStopItem aItem(oTmpSet->Get(RES_PARATR_TABSTOP)); @@ -3039,11 +3042,14 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode ) oTmpSet.emplace(rNode.GetSwAttrSet()); // create new LRSpace item, based on the current (if present) - const SfxPoolItem* pLrSpaceItem = oTmpSet->GetItemIfSet(RES_LR_SPACE); - SvxLRSpaceItem aLRSpace( - ( pLrSpaceItem == nullptr ) - ? SvxLRSpaceItem(0, 0, 0, RES_LR_SPACE) - : *static_cast( pLrSpaceItem ) ); + const SvxFirstLineIndentItem *const pFirstLineIndent(oTmpSet->GetItemIfSet(RES_MARGIN_FIRSTLINE)); + const SvxTextLeftMarginItem *const pTextLeftMargin(oTmpSet->GetItemIfSet(RES_MARGIN_TEXTLEFT)); + SvxFirstLineIndentItem firstLine(pFirstLineIndent + ? *pFirstLineIndent + : SvxFirstLineIndentItem(0, RES_MARGIN_FIRSTLINE)); + SvxTextLeftMarginItem leftMargin(pTextLeftMargin + ? *pTextLeftMargin + : SvxTextLeftMarginItem(0, RES_MARGIN_TEXTLEFT)); // new left margin = old left + label space const SwNumRule* pRule = rNode.GetNumRule(); @@ -3061,20 +3067,23 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode ) if ( rNumFormat.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION ) { - aLRSpace.SetTextLeft( aLRSpace.GetLeft() + rNumFormat.GetAbsLSpace() ); + leftMargin.SetTextLeft(leftMargin.GetLeft(firstLine) + rNumFormat.GetAbsLSpace()); } else { - aLRSpace.SetTextLeft( aLRSpace.GetLeft() + rNumFormat.GetIndentAt() ); + leftMargin.SetTextLeft(leftMargin.GetLeft(firstLine) + rNumFormat.GetIndentAt()); } // new first line indent = 0 // (first line indent is ignored) if (!bParaRTL) - aLRSpace.SetTextFirstLineOffset( 0 ); + { + firstLine.SetTextFirstLineOffset(0); + } // put back the new item - oTmpSet->Put( aLRSpace ); + oTmpSet->Put(firstLine); + oTmpSet->Put(leftMargin); // assure that numbering rule is in if (SfxItemState::SET != oTmpSet->GetItemState(RES_PARATR_NUMRULE, false) ) diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx index c76bb671c3f9..d36272ea4f72 100644 --- a/sw/source/filter/ww8/ww8atr.cxx +++ b/sw/source/filter/ww8/ww8atr.cxx @@ -342,10 +342,17 @@ void MSWordExportBase::OutputItemSet( const SfxItemSet& rSet, bool bPapFormat, b // switch off the numbering? const SfxPoolItem* pLRItem; if ( pRuleItem->GetValue().isEmpty() && - SfxItemState::SET != rSet.GetItemState( RES_LR_SPACE, false) && - (pLRItem = rSet.GetItemIfSet( RES_LR_SPACE )) ) + SfxItemState::SET != rSet.GetItemState(RES_MARGIN_FIRSTLINE, false) && + (pLRItem = rSet.GetItemIfSet(RES_MARGIN_FIRSTLINE)) ) { - // the set the LR-Space of the parentformat! + // set the LR-Space of the parentformat! + AttrOutput().OutputItem( *pLRItem ); + } + if ( pRuleItem->GetValue().isEmpty() && + SfxItemState::SET != rSet.GetItemState(RES_MARGIN_TEXTLEFT, false) && + (pLRItem = rSet.GetItemIfSet(RES_MARGIN_TEXTLEFT)) ) + { + // set the LR-Space of the parentformat! AttrOutput().OutputItem( *pLRItem ); } } @@ -866,12 +873,14 @@ void MSWordExportBase::OutputFormat( const SwFormat& rFormat, bool bPapFormat, b rNFormat.GetAbsLSpace() ) { SfxItemSet aSet( rFormat.GetAttrSet() ); - SvxLRSpaceItem aLR(aSet.Get(RES_LR_SPACE)); + SvxFirstLineIndentItem firstLine(aSet.Get(RES_MARGIN_FIRSTLINE)); + SvxTextLeftMarginItem leftMargin(aSet.Get(RES_MARGIN_TEXTLEFT)); - aLR.SetTextLeft( aLR.GetTextLeft() + rNFormat.GetAbsLSpace() ); - aLR.SetTextFirstLineOffset( GetWordFirstLineOffset(rNFormat)); + leftMargin.SetTextLeft(leftMargin.GetTextLeft() + rNFormat.GetAbsLSpace()); + firstLine.SetTextFirstLineOffset(GetWordFirstLineOffset(rNFormat)); - aSet.Put( aLR ); + aSet.Put(firstLine); + aSet.Put(leftMargin); CorrectTabStopInSet( aSet, rNFormat.GetAbsLSpace() ); OutputItemSet( aSet, bPapFormat, bChpFormat, i18n::ScriptType::LATIN, m_bExportModeRTF); @@ -888,8 +897,10 @@ void MSWordExportBase::OutputFormat( const SwFormat& rFormat, bool bPapFormat, b if ( m_bStyDef && DisallowInheritingOutlineNumbering(rFormat) ) { SfxItemSet aSet( rFormat.GetAttrSet() ); - const SvxLRSpaceItem& aLR = aSet.Get(RES_LR_SPACE); - aSet.Put( aLR ); + SvxFirstLineIndentItem const& rFirstLine(aSet.Get(RES_MARGIN_FIRSTLINE)); + SvxTextLeftMarginItem const& rLeftMargin(aSet.Get(RES_MARGIN_TEXTLEFT)); + aSet.Put(rFirstLine); + aSet.Put(rLeftMargin); OutputItemSet( aSet, bPapFormat, bChpFormat, css::i18n::ScriptType::LATIN, m_bExportModeRTF); bCallOutSet = false; @@ -4190,6 +4201,33 @@ void WW8AttributeOutput::FormatPaperBin( const SvxPaperBinItem& rPaperBin ) } } +void WW8AttributeOutput::FormatFirstLineIndent(SvxFirstLineIndentItem const& rFirstLine) +{ + // sprmPDxaLeft1 + m_rWW8Export.InsUInt16( 0x8460 ); //asian version ? + m_rWW8Export.InsUInt16( rFirstLine.GetTextFirstLineOffset() ); +} + +void WW8AttributeOutput::FormatTextLeftMargin(SvxTextLeftMarginItem const& rTextLeftMargin) +{ // normal paragraphs + // sprmPDxaLeft + m_rWW8Export.InsUInt16( 0x845E ); //asian version ? + m_rWW8Export.InsUInt16( o3tl::narrowing(rTextLeftMargin.GetTextLeft()) ); +} + +void WW8AttributeOutput::FormatRightMargin(SvxRightMarginItem const& rRightMargin) +{ + // (paragraph case, this will be an else branch once others are converted) +#if 0 + else +#endif + { // normal paragraphs + // sprmPDxaRight + m_rWW8Export.InsUInt16( 0x845D ); //asian version ? + m_rWW8Export.InsUInt16( o3tl::narrowing(rRightMargin.GetRight()) ); + } +} + void WW8AttributeOutput::FormatLRSpace( const SvxLRSpaceItem& rLR ) { // Flys are still missing ( see RTF ) @@ -5370,10 +5408,12 @@ void WW8AttributeOutput::ParaTabStop( const SvxTabStopItem& rTabStops ) tools::Long nCurrentLeft = 0; if ( bTabsRelativeToIndex ) { - if(const SfxPoolItem* pItem = m_rWW8Export.HasItem( RES_LR_SPACE )) + if (const SfxPoolItem* pItem = m_rWW8Export.HasItem(RES_MARGIN_TEXTLEFT)) { - if(const auto pLR = pItem->DynamicWhichCast(RES_LR_SPACE)) - nCurrentLeft = pLR->GetTextLeft(); + if (const auto pLeft = pItem->DynamicWhichCast(RES_MARGIN_TEXTLEFT)) + { + nCurrentLeft = pLeft->GetTextLeft(); + } else // FIXME: This fails in sw.ww8export/testCommentExport::Load_Verify_Reload_Verify SAL_WARN("sw.ww8", "m_rWW8Export has an RES_LR_SPACE item, but it's of the wrong type."); @@ -5398,8 +5438,8 @@ void WW8AttributeOutput::ParaTabStop( const SvxTabStopItem& rTabStops ) tools::Long nParentLeft = 0; if ( bTabsRelativeToIndex ) { - const SvxLRSpaceItem &rStyleLR = pParentStyle->GetAttrSet().Get( RES_LR_SPACE ); - nParentLeft = rStyleLR.GetTextLeft(); + SvxTextLeftMarginItem const& rLeftMargin(pParentStyle->GetAttrSet().Get(RES_MARGIN_TEXTLEFT)); + nParentLeft = rLeftMargin.GetTextLeft(); } ParaTabStopDelAdd( m_rWW8Export, aParentTabs, nParentLeft, rTabStops, nCurrentLeft ); @@ -5421,8 +5461,8 @@ void WW8AttributeOutput::ParaTabStop( const SvxTabStopItem& rTabStops ) tools::Long nStyleLeft = 0; if ( bTabsRelativeToIndex ) { - const SvxLRSpaceItem &rStyleLR = m_rWW8Export.m_pStyAttr->Get(RES_LR_SPACE); - nStyleLeft = rStyleLR.GetTextLeft(); + SvxTextLeftMarginItem const& rLeftMargin(m_rWW8Export.m_pStyAttr->Get(RES_MARGIN_TEXTLEFT)); + nStyleLeft = rLeftMargin.GetTextLeft(); } ParaTabStopDelAdd( m_rWW8Export, @@ -5610,6 +5650,15 @@ void AttributeOutputBase::OutputItem( const SfxPoolItem& rHt ) case RES_PAPER_BIN: FormatPaperBin( static_cast< const SvxPaperBinItem& >( rHt ) ); break; + case RES_MARGIN_FIRSTLINE: + FormatFirstLineIndent(static_cast(rHt)); + break; + case RES_MARGIN_TEXTLEFT: + FormatTextLeftMargin(static_cast(rHt)); + break; + case RES_MARGIN_RIGHT: + FormatRightMargin(static_cast(rHt)); + break; case RES_LR_SPACE: FormatLRSpace( static_cast< const SvxLRSpaceItem& >( rHt ) ); break; diff --git a/sw/source/filter/ww8/ww8attributeoutput.hxx b/sw/source/filter/ww8/ww8attributeoutput.hxx index e139ae71f906..a36d7481acb2 100644 --- a/sw/source/filter/ww8/ww8attributeoutput.hxx +++ b/sw/source/filter/ww8/ww8attributeoutput.hxx @@ -366,6 +366,13 @@ protected: /// Sfx item RES_PAPER_BIN virtual void FormatPaperBin( const SvxPaperBinItem& ) override; + /// Sfx item RES_MARGIN_FIRSTLINE + virtual void FormatFirstLineIndent(const SvxFirstLineIndentItem & rFirstLine) override; + /// Sfx item RES_MARGIN_TEXTLEFT + virtual void FormatTextLeftMargin(const SvxTextLeftMarginItem & rTextLeftMargin) override; + /// Sfx item RES_MARGIN_RIGHT + virtual void FormatRightMargin(const SvxRightMarginItem & rRightMargin) override; + /// Sfx item RES_LR_SPACE virtual void FormatLRSpace( const SvxLRSpaceItem& ) override; diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx index 48ad05bc1681..aac252d164a1 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -1226,14 +1226,15 @@ tools::Long GetListFirstLineIndent(const SwNumFormat &rFormat) return nReverseListIndented; } -static tools::Long lcl_GetTrueMargin(const SvxLRSpaceItem &rLR, const SwNumFormat &rFormat, +static tools::Long lcl_GetTrueMargin(SvxFirstLineIndentItem const& rFirstLine, + SvxTextLeftMarginItem const& rLeftMargin, const SwNumFormat &rFormat, tools::Long &rFirstLinePos) { OSL_ENSURE( rFormat.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION, " - misusage: position-and-space-mode does not equal LABEL_WIDTH_AND_POSITION" ); - const tools::Long nBodyIndent = rLR.GetTextLeft(); - const tools::Long nFirstLineDiff = rLR.GetTextFirstLineOffset(); + const tools::Long nBodyIndent = rLeftMargin.GetTextLeft(); + const tools::Long nFirstLineDiff = rFirstLine.GetTextFirstLineOffset(); rFirstLinePos = nBodyIndent + nFirstLineDiff; const auto nPseudoListBodyIndent = rFormat.GetAbsLSpace(); @@ -1245,7 +1246,8 @@ static tools::Long lcl_GetTrueMargin(const SvxLRSpaceItem &rLR, const SwNumForma // #i103711# // #i105414# -void SyncIndentWithList( SvxLRSpaceItem &rLR, +void SyncIndentWithList( SvxFirstLineIndentItem & rFirstLine, + SvxTextLeftMarginItem & rLeftMargin, const SwNumFormat &rFormat, const bool bFirstLineOfstSet, const bool bLeftIndentSet ) @@ -1253,31 +1255,31 @@ void SyncIndentWithList( SvxLRSpaceItem &rLR, if ( rFormat.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION ) { tools::Long nWantedFirstLinePos; - tools::Long nExtraListIndent = lcl_GetTrueMargin(rLR, rFormat, nWantedFirstLinePos); - rLR.SetTextLeft(nWantedFirstLinePos - nExtraListIndent); - rLR.SetTextFirstLineOffset(0); + tools::Long nExtraListIndent = lcl_GetTrueMargin(rFirstLine, rLeftMargin, rFormat, nWantedFirstLinePos); + rLeftMargin.SetTextLeft(nWantedFirstLinePos - nExtraListIndent); + rFirstLine.SetTextFirstLineOffset(0); } else if ( rFormat.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT ) { if ( !bFirstLineOfstSet && bLeftIndentSet && rFormat.GetFirstLineIndent() != 0 ) { - rLR.SetTextFirstLineOffset( rFormat.GetFirstLineIndent() ); + rFirstLine.SetTextFirstLineOffset(rFormat.GetFirstLineIndent()); } else if ( bFirstLineOfstSet && !bLeftIndentSet && rFormat.GetIndentAt() != 0 ) { - rLR.SetTextLeft( rFormat.GetIndentAt() ); + rLeftMargin.SetTextLeft(rFormat.GetIndentAt()); } else if (!bFirstLineOfstSet && !bLeftIndentSet ) { if ( rFormat.GetFirstLineIndent() != 0 ) { - rLR.SetTextFirstLineOffset( rFormat.GetFirstLineIndent() ); + rFirstLine.SetTextFirstLineOffset(rFormat.GetFirstLineIndent()); } if ( rFormat.GetIndentAt() != 0 ) { - rLR.SetTextLeft( rFormat.GetIndentAt() ); + rLeftMargin.SetTextLeft(rFormat.GetIndentAt()); } } } @@ -1341,6 +1343,10 @@ void SwWW8FltControlStack::SetAttrInDoc(const SwPosition& rTmpPos, switch (rEntry.m_pAttr->Which()) { case RES_LR_SPACE: + assert(false); + break; + case RES_MARGIN_FIRSTLINE: + case RES_MARGIN_TEXTLEFT: { /* Loop over the affected nodes and @@ -1352,7 +1358,19 @@ void SwWW8FltControlStack::SetAttrInDoc(const SwPosition& rTmpPos, SwPaM aRegion(rTmpPos); if (rEntry.MakeRegion(m_rDoc, aRegion, SwFltStackEntry::RegionMode::NoCheck)) { - SvxLRSpaceItem aNewLR( *static_cast(rEntry.m_pAttr.get()) ); + SvxFirstLineIndentItem firstLineNew(RES_MARGIN_FIRSTLINE); + SvxTextLeftMarginItem leftMarginNew(RES_MARGIN_TEXTLEFT); + if (rEntry.m_pAttr->Which() == RES_MARGIN_FIRSTLINE) + { + SvxFirstLineIndentItem const firstLineEntry(*static_cast(rEntry.m_pAttr.get())); + firstLineNew.SetTextFirstLineOffset(firstLineEntry.GetTextFirstLineOffset(), firstLineEntry.GetPropTextFirstLineOffset()); + firstLineNew.SetAutoFirst(firstLineEntry.IsAutoFirst()); + } + else + { + SvxTextLeftMarginItem const leftMarginEntry(*static_cast(rEntry.m_pAttr.get())); + leftMarginNew.SetTextLeft(leftMarginEntry.GetTextLeft(), leftMarginEntry.GetPropLeft()); + } SwNodeOffset nStart = aRegion.Start()->GetNodeIndex(); SwNodeOffset nEnd = aRegion.End()->GetNodeIndex(); for(; nStart <= nEnd; ++nStart) @@ -1362,7 +1380,17 @@ void SwWW8FltControlStack::SetAttrInDoc(const SwPosition& rTmpPos, continue; SwContentNode* pNd = static_cast(pNode); - SvxLRSpaceItem aOldLR = pNd->GetAttr(RES_LR_SPACE); + SvxFirstLineIndentItem firstLineOld(pNd->GetAttr(RES_MARGIN_FIRSTLINE)); + SvxTextLeftMarginItem leftMarginOld(pNd->GetAttr(RES_MARGIN_TEXTLEFT)); + if (rEntry.m_pAttr->Which() == RES_MARGIN_FIRSTLINE) + { + leftMarginNew.SetTextLeft(leftMarginOld.GetTextLeft(), leftMarginOld.GetPropLeft()); + } + else + { + firstLineNew.SetTextFirstLineOffset(firstLineOld.GetTextFirstLineOffset(), firstLineOld.GetPropTextFirstLineOffset()); + firstLineNew.SetAutoFirst(firstLineOld.IsAutoFirst()); + } SwTextNode *pTextNode = static_cast(pNode); @@ -1383,16 +1411,19 @@ void SwWW8FltControlStack::SetAttrInDoc(const SwPosition& rTmpPos, const bool bLeftIndentSet = ( m_rReader.m_aTextNodesHavingLeftIndentSet.end() != m_rReader.m_aTextNodesHavingLeftIndentSet.find( pNode ) ); - SyncIndentWithList( aNewLR, *pNum, + SyncIndentWithList(firstLineNew, leftMarginNew, *pNum, bFirstLineIndentSet, bLeftIndentSet ); } - if (aNewLR == aOldLR) - continue; - - pNd->SetAttr(aNewLR); - + if (firstLineNew != firstLineOld) + { + pNd->SetAttr(firstLineNew); + } + if (leftMarginNew != leftMarginOld) + { + pNd->SetAttr(leftMarginNew); + } } } } @@ -1462,13 +1493,28 @@ const SfxPoolItem* SwWW8FltControlStack::GetFormatAttr(const SwPosition& rPos, not writer format, because that's the style that the filter works in (naturally) */ - if (nWhich == RES_LR_SPACE) + if (nWhich == RES_MARGIN_FIRSTLINE + || nWhich == RES_MARGIN_TEXTLEFT + || nWhich == RES_MARGIN_RIGHT) { SfxItemState eState = SfxItemState::DEFAULT; if (const SfxItemSet *pSet = pNd->GetpSwAttrSet()) - eState = pSet->GetItemState(RES_LR_SPACE, false); + eState = pSet->GetItemState(nWhich, false); if (eState != SfxItemState::SET && m_rReader.m_nCurrentColl < m_rReader.m_vColl.size()) - pItem = m_rReader.m_vColl[m_rReader.m_nCurrentColl].maWordLR.get(); + { + switch (nWhich) + { + case RES_MARGIN_FIRSTLINE: + pItem = m_rReader.m_vColl[m_rReader.m_nCurrentColl].m_pWordFirstLine.get(); + break; + case RES_MARGIN_TEXTLEFT: + pItem = m_rReader.m_vColl[m_rReader.m_nCurrentColl].m_pWordLeftMargin.get(); + break; + case RES_MARGIN_RIGHT: + pItem = m_rReader.m_vColl[m_rReader.m_nCurrentColl].m_pWordRightMargin.get(); + break; + } + } } /* diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx index f283182137ba..a06d9ffce17a 100644 --- a/sw/source/filter/ww8/ww8par.hxx +++ b/sw/source/filter/ww8/ww8par.hxx @@ -249,7 +249,9 @@ public: sal_uInt16 m_n81Flags; // for bold, italic, ... sal_uInt16 m_n81BiDiFlags; // for bold, italic, ... - std::shared_ptr maWordLR; + std::shared_ptr m_pWordFirstLine; + std::shared_ptr m_pWordLeftMargin; + std::shared_ptr m_pWordRightMargin; bool m_bValid; // empty of valid bool m_bImported; // for recursive imports bool m_bColl; // true-> pFormat is SwTextFormatColl @@ -281,7 +283,9 @@ public: mnWW8OutlineLevel( MAXLEVEL ), m_n81Flags( 0 ), m_n81BiDiFlags(0), - maWordLR(std::make_shared(RES_LR_SPACE)), + m_pWordFirstLine(std::make_shared(RES_MARGIN_FIRSTLINE)), + m_pWordLeftMargin(std::make_shared(RES_MARGIN_TEXTLEFT)), + m_pWordRightMargin(std::make_shared(RES_MARGIN_RIGHT)), m_bValid(false), m_bImported(false), m_bColl(false), @@ -1951,7 +1955,8 @@ void UseListIndent(SwWW8StyInf &rStyle, const SwNumFormat &rFormat); void SetStyleIndent(SwWW8StyInf &rStyleInfo, const SwNumFormat &rFormat); // #i103711# // #i105414# -void SyncIndentWithList( SvxLRSpaceItem &rLR, +void SyncIndentWithList( SvxFirstLineIndentItem & rFirstLine, + SvxTextLeftMarginItem & rLeftMargin, const SwNumFormat &rFormat, const bool bFirstLineOfStSet, const bool bLeftIndentSet ); diff --git a/sw/source/filter/ww8/ww8par2.cxx b/sw/source/filter/ww8/ww8par2.cxx index 8b842557e8e4..bc15f0fc96d5 100644 --- a/sw/source/filter/ww8/ww8par2.cxx +++ b/sw/source/filter/ww8/ww8par2.cxx @@ -261,12 +261,14 @@ sal_uInt16 SwWW8ImplReader::End_Footnote() { // Allow MSO to emulate LO footnote text starting at left margin - only meaningful with hanging indent sal_Int32 nFirstLineIndent=0; - SfxItemSetFixed aSet( m_rDoc.GetAttrPool() ); + SfxItemSetFixed aSet(m_rDoc.GetAttrPool()); if ( pTNd->GetAttr(aSet) ) { - const SvxLRSpaceItem* pLRSpace = aSet.GetItem(RES_LR_SPACE); - if ( pLRSpace ) - nFirstLineIndent = pLRSpace->GetTextFirstLineOffset(); + const SvxFirstLineIndentItem *const pFirstLine(aSet.GetItem(RES_MARGIN_FIRSTLINE)); + if (pFirstLine) + { + nFirstLineIndent = pFirstLine->GetTextFirstLineOffset(); + } } rPaMPointPos.SetContent(0); diff --git a/sw/source/filter/ww8/ww8par3.cxx b/sw/source/filter/ww8/ww8par3.cxx index 451cae7b2778..dee6138bc2b1 100644 --- a/sw/source/filter/ww8/ww8par3.cxx +++ b/sw/source/filter/ww8/ww8par3.cxx @@ -1673,10 +1673,12 @@ void UseListIndent(SwWW8StyInf &rStyle, const SwNumFormat &rFormat) { const auto nAbsLSpace = rFormat.GetAbsLSpace(); const tools::Long nListFirstLineIndent = GetListFirstLineIndent(rFormat); - SvxLRSpaceItem aLR(rStyle.m_pFormat->GetFormatAttr(RES_LR_SPACE)); - aLR.SetTextLeft(nAbsLSpace); - aLR.SetTextFirstLineOffset(writer_cast(nListFirstLineIndent)); - rStyle.m_pFormat->SetFormatAttr(aLR); + SvxFirstLineIndentItem firstLine(rStyle.m_pFormat->GetFormatAttr(RES_MARGIN_FIRSTLINE)); + SvxTextLeftMarginItem leftMargin(rStyle.m_pFormat->GetFormatAttr(RES_MARGIN_TEXTLEFT)); + leftMargin.SetTextLeft(nAbsLSpace); + firstLine.SetTextFirstLineOffset(writer_cast(nListFirstLineIndent)); + rStyle.m_pFormat->SetFormatAttr(firstLine); + rStyle.m_pFormat->SetFormatAttr(leftMargin); rStyle.m_bListRelevantIndentSet = true; } } @@ -1686,18 +1688,20 @@ void SetStyleIndent(SwWW8StyInf &rStyle, const SwNumFormat &rFormat) if ( rFormat.GetPositionAndSpaceMode() != SvxNumberFormat::LABEL_WIDTH_AND_POSITION ) // #i86652# return; - SvxLRSpaceItem aLR(rStyle.m_pFormat->GetFormatAttr(RES_LR_SPACE)); + SvxFirstLineIndentItem firstLine(rStyle.m_pFormat->GetFormatAttr(RES_MARGIN_FIRSTLINE)); + SvxTextLeftMarginItem leftMargin(rStyle.m_pFormat->GetFormatAttr(RES_MARGIN_TEXTLEFT)); if (rStyle.m_bListRelevantIndentSet) { - SyncIndentWithList( aLR, rFormat, false, false ); // #i103711#, #i105414# + SyncIndentWithList(firstLine, leftMargin, rFormat, false, false); // #i103711#, #i105414# } else { - aLR.SetTextLeft(0); - aLR.SetTextFirstLineOffset(0); + leftMargin.SetTextLeft(0); + firstLine.SetTextFirstLineOffset(0); } - rStyle.m_pFormat->SetFormatAttr(aLR); + rStyle.m_pFormat->SetFormatAttr(firstLine); + rStyle.m_pFormat->SetFormatAttr(leftMargin); } void SwWW8ImplReader::SetStylesList(sal_uInt16 nStyle, sal_uInt16 nCurrentLFO, @@ -1743,7 +1747,9 @@ void SwWW8ImplReader::RegisterNumFormatOnStyle(sal_uInt16 nStyle) return; //Save old pre-list modified indent, which are the word indent values - rStyleInf.maWordLR.reset(rStyleInf.m_pFormat->GetFormatAttr(RES_LR_SPACE).Clone()); + rStyleInf.m_pWordFirstLine.reset(rStyleInf.m_pFormat->GetFormatAttr(RES_MARGIN_FIRSTLINE).Clone()); + rStyleInf.m_pWordLeftMargin.reset(rStyleInf.m_pFormat->GetFormatAttr(RES_MARGIN_TEXTLEFT).Clone()); + rStyleInf.m_pWordRightMargin.reset(rStyleInf.m_pFormat->GetFormatAttr(RES_MARGIN_RIGHT).Clone()); // Phase 2: refresh StyleDef after reading all Lists if (rStyleInf.m_nLFOIndex >= USHRT_MAX || rStyleInf.m_nListLevel >= WW8ListManager::nMaxLevel) @@ -1845,12 +1851,15 @@ void SwWW8ImplReader::RegisterNumFormatOnTextNode(sal_uInt16 nCurrentLFO, if (!bApplyListLevelIndentDirectlyAtPara) return; - auto xListIndent = std::make_unique(m_rDoc.GetAttrPool(), svl::Items); - const SvxLRSpaceItem *pItem = static_cast( - GetFormatAttr(RES_LR_SPACE)); + auto pListIndent = std::make_unique(m_rDoc.GetAttrPool(), svl::Items); + const SfxPoolItem *pItem; + pItem = GetFormatAttr(RES_MARGIN_FIRSTLINE); OSL_ENSURE(pItem, "impossible"); if (pItem) - xListIndent->Put(*pItem); + pListIndent->Put(*pItem); + pItem = GetFormatAttr(RES_MARGIN_TEXTLEFT); + if (pItem) + pListIndent->Put(*pItem); /* Take the original paragraph sprms attached to this list level @@ -1859,7 +1868,7 @@ void SwWW8ImplReader::RegisterNumFormatOnTextNode(sal_uInt16 nCurrentLFO, */ if (short nLen = static_cast< short >(aParaSprms.size())) { - std::unique_ptr xOldCurrentItemSet(SetCurrentItemSet(std::move(xListIndent))); + std::unique_ptr pOldCurrentItemSet(SetCurrentItemSet(std::move(pListIndent))); sal_uInt8* pSprms1 = aParaSprms.data(); while (0 < nLen) @@ -1869,13 +1878,18 @@ void SwWW8ImplReader::RegisterNumFormatOnTextNode(sal_uInt16 nCurrentLFO, pSprms1 += nL1; } - xListIndent = SetCurrentItemSet(std::move(xOldCurrentItemSet)); + pListIndent = SetCurrentItemSet(std::move(pOldCurrentItemSet)); } - if (const SvxLRSpaceItem *pLR = xListIndent->GetItem(RES_LR_SPACE)) + if (const SvxFirstLineIndentItem *const pFirstLine = pListIndent->GetItem(RES_MARGIN_FIRSTLINE)) + { + m_xCtrlStck->NewAttr(*m_pPaM->GetPoint(), *pFirstLine); + m_xCtrlStck->SetAttr(*m_pPaM->GetPoint(), RES_MARGIN_FIRSTLINE); + } + if (const SvxTextLeftMarginItem *const pLeftMargin = pListIndent->GetItem(RES_MARGIN_TEXTLEFT)) { - m_xCtrlStck->NewAttr(*m_pPaM->GetPoint(), *pLR); - m_xCtrlStck->SetAttr(*m_pPaM->GetPoint(), RES_LR_SPACE); + m_xCtrlStck->NewAttr(*m_pPaM->GetPoint(), *pLeftMargin); + m_xCtrlStck->SetAttr(*m_pPaM->GetPoint(), RES_MARGIN_TEXTLEFT); } } @@ -1976,7 +1990,9 @@ void SwWW8ImplReader::Read_LFOPosition(sal_uInt16, const sal_uInt8* pData, m_pCurrentColl->SetFormatAttr(*GetDfltAttr(RES_PARATR_NUMRULE)); // reset/blank the indent - m_pCurrentColl->SetFormatAttr(SvxLRSpaceItem(RES_LR_SPACE)); + m_pCurrentColl->SetFormatAttr(SvxFirstLineIndentItem(RES_MARGIN_FIRSTLINE)); + m_pCurrentColl->SetFormatAttr(SvxTextLeftMarginItem(RES_MARGIN_TEXTLEFT)); + m_pCurrentColl->SetFormatAttr(SvxRightMarginItem(RES_MARGIN_RIGHT)); // These sprmPIlfos are supposed to indicate "cancel" numbering. // Since m_nLFOPosition is "data - 1", then zero becomes USHRT_MAX @@ -1993,19 +2009,22 @@ void SwWW8ImplReader::Read_LFOPosition(sal_uInt16, const sal_uInt8* pData, pTextNode->SetAttr( aEmptyRule ); // create an empty SvxLRSpaceItem - std::shared_ptr aLR(std::make_shared(RES_LR_SPACE)); + std::shared_ptr pFirstLine(std::make_shared(RES_MARGIN_FIRSTLINE)); // replace it with the one of the current node if it exist - const SfxPoolItem* pLR = GetFormatAttr(RES_LR_SPACE); - if( pLR ) - aLR.reset(static_cast(pLR->Clone())); + const SfxPoolItem *const pItem = GetFormatAttr(RES_MARGIN_FIRSTLINE); + if (pItem) + { + pFirstLine.reset(static_cast(pItem->Clone())); + } // reset/blank the left indent (and only the left) - aLR->SetTextLeft(0); - aLR->SetTextFirstLineOffset(0); + pFirstLine->SetTextFirstLineOffset(0); + SvxTextLeftMarginItem leftMargin(0, RES_MARGIN_TEXTLEFT); // apply the modified SvxLRSpaceItem to the current paragraph - pTextNode->SetAttr( *aLR ); + pTextNode->SetAttr(*pFirstLine); + pTextNode->SetAttr(leftMargin); } m_nLFOPosition = USHRT_MAX; diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx index 7569ec903f06..4186bfbc3fc8 100644 --- a/sw/source/filter/ww8/ww8par6.cxx +++ b/sw/source/filter/ww8/ww8par6.cxx @@ -2618,12 +2618,12 @@ void SwWW8ImplReader::StripNegativeAfterIndent(SwFrameFormat const *pFlyFormat) SwTextNode *pNd = aIdx.GetNode().GetTextNode(); if (pNd) { - const SvxLRSpaceItem& rLR = pNd->GetAttr(RES_LR_SPACE); - if (rLR.GetRight() < 0) + const SvxRightMarginItem & rRightMargin(pNd->GetAttr(RES_MARGIN_RIGHT)); + if (rRightMargin.GetRight() < 0) { - SvxLRSpaceItem aLR(rLR); - aLR.SetRight(0); - pNd->SetAttr(aLR); + SvxRightMarginItem rightMargin(rRightMargin); + rightMargin.SetRight(0); + pNd->SetAttr(rightMargin); } } ++aIdx; @@ -4213,16 +4213,26 @@ void SwWW8ImplReader::Read_LR( sal_uInt16 nId, const sal_uInt8* pData, short nLe { if (nLen < 2) // end of attribute { - m_xCtrlStck->SetAttr(*m_pPaM->GetPoint(), RES_LR_SPACE); + m_xCtrlStck->SetAttr(*m_pPaM->GetPoint(), RES_MARGIN_FIRSTLINE); + m_xCtrlStck->SetAttr(*m_pPaM->GetPoint(), RES_MARGIN_TEXTLEFT); + m_xCtrlStck->SetAttr(*m_pPaM->GetPoint(), RES_MARGIN_RIGHT); return; } short nPara = SVBT16ToUInt16( pData ); - std::shared_ptr aLR(std::make_shared(RES_LR_SPACE)); - const SfxPoolItem* pLR = GetFormatAttr(RES_LR_SPACE); - if( pLR ) - aLR.reset(static_cast(pLR->Clone())); + SfxPoolItem const* pItem(GetFormatAttr(RES_MARGIN_FIRSTLINE)); + ::std::unique_ptr pFirstLine(pItem + ? static_cast(pItem->Clone()) + : new SvxFirstLineIndentItem(RES_MARGIN_FIRSTLINE)); + pItem = GetFormatAttr(RES_MARGIN_TEXTLEFT); + ::std::unique_ptr pLeftMargin(pItem + ? static_cast(pItem->Clone()) + : new SvxTextLeftMarginItem(RES_MARGIN_TEXTLEFT)); + pItem = GetFormatAttr(RES_MARGIN_RIGHT); + ::std::unique_ptr pRightMargin(pItem + ? static_cast(pItem->Clone()) + : new SvxRightMarginItem(RES_MARGIN_RIGHT)); // Fix the regression issue: #i99822#: Discussion? // Since the list level formatting doesn't apply into paragraph style @@ -4239,10 +4249,11 @@ void SwWW8ImplReader::Read_LR( sal_uInt16 nId, const sal_uInt8* pData, short nLe const SwNumFormat* pFormat = pNumRule->GetNumFormat( nLvl ); if ( pFormat && pFormat->GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT ) { - aLR->SetTextLeft( pFormat->GetIndentAt() ); - aLR->SetTextFirstLineOffset( static_cast(pFormat->GetFirstLineIndent()) ); + pLeftMargin->SetTextLeft(pFormat->GetIndentAt()); + pFirstLine->SetTextFirstLineOffset(static_cast(pFormat->GetFirstLineIndent())); // make paragraph have hard-set indent attributes - pTextNode->SetAttr( *aLR ); + pTextNode->SetAttr(*pLeftMargin); + pTextNode->SetAttr(*pFirstLine); } } } @@ -4282,7 +4293,7 @@ void SwWW8ImplReader::Read_LR( sal_uInt16 nId, const sal_uInt8* pData, short nLe case NS_sprm::v6::sprmPDxaLeft: case NS_sprm::PDxaLeft80::val: case NS_sprm::PDxaLeft::val: - aLR->SetTextLeft( nPara ); + pLeftMargin->SetTextLeft(nPara); if (m_pCurrentColl && m_nCurrentColl < m_vColl.size()) { m_vColl[m_nCurrentColl].m_bListRelevantIndentSet = true; @@ -4309,13 +4320,13 @@ void SwWW8ImplReader::Read_LR( sal_uInt16 nId, const sal_uInt8* pData, short nLe SprmResult aIsZeroed = m_xPlcxMan->GetPapPLCF()->HasSprm(NS_sprm::PIlfo::val); if (aIsZeroed.pSprm && aIsZeroed.nRemainingData >= 1 && *aIsZeroed.pSprm == 0) { - const SvxLRSpaceItem &rLR = - m_vColl[m_nCurrentColl].m_pFormat->GetFormatAttr(RES_LR_SPACE); - nPara = nPara - rLR.GetTextFirstLineOffset(); + const SvxFirstLineIndentItem & rFirstLine = + m_vColl[m_nCurrentColl].m_pFormat->GetFormatAttr(RES_MARGIN_FIRSTLINE); + nPara = nPara - rFirstLine.GetTextFirstLineOffset(); } } - aLR->SetTextFirstLineOffset(nPara); + pFirstLine->SetTextFirstLineOffset(nPara); if (!m_pCurrentColl) { @@ -4325,7 +4336,7 @@ void SwWW8ImplReader::Read_LR( sal_uInt16 nId, const sal_uInt8* pData, short nLe { if (!lcl_HasExplicitLeft(m_xPlcxMan.get(), m_bVer67)) { - aLR->SetTextLeft(pNumFormat->GetIndentAt()); + pLeftMargin->SetTextLeft(pNumFormat->GetIndentAt()); // If have not explicit left, set number format list tab position is doc default tab const SvxTabStopItem *pDefaultStopItem = m_rDoc.GetAttrPool().GetPoolDefaultItem(RES_PARATR_TABSTOP); @@ -4345,13 +4356,15 @@ void SwWW8ImplReader::Read_LR( sal_uInt16 nId, const sal_uInt8* pData, short nLe case NS_sprm::v6::sprmPDxaRight: case NS_sprm::PDxaRight80::val: case NS_sprm::PDxaRight::val: - aLR->SetRight( nPara ); + pRightMargin->SetRight(nPara); break; default: return; } - NewAttr( *aLR, bFirstLinOfstSet, bLeftIndentSet ); // #i103711#, #i105414# + NewAttr(*pFirstLine, bFirstLinOfstSet, false); // #i103711#, #i105414# + NewAttr(*pLeftMargin, false, bLeftIndentSet); + NewAttr(*pRightMargin, false, false); } // Sprm 20 diff --git a/sw/source/filter/xml/xmlexpit.cxx b/sw/source/filter/xml/xmlexpit.cxx index c912d4c8c58f..bcbe282b6a2b 100644 --- a/sw/source/filter/xml/xmlexpit.cxx +++ b/sw/source/filter/xml/xmlexpit.cxx @@ -368,6 +368,11 @@ bool SvXMLExportItemMapper::QueryXMLValue( switch ( rItem.Which() ) { + case RES_MARGIN_FIRSTLINE: + case RES_MARGIN_TEXTLEFT: + case RES_MARGIN_RIGHT: + assert(false); // is only called for frame formats? + break; case RES_LR_SPACE: { diff --git a/sw/source/filter/xml/xmlimpit.cxx b/sw/source/filter/xml/xmlimpit.cxx index b092fe85f8af..eaabf789e2ac 100644 --- a/sw/source/filter/xml/xmlimpit.cxx +++ b/sw/source/filter/xml/xmlimpit.cxx @@ -317,6 +317,12 @@ bool SvXMLImportItemMapper::PutXMLValue( switch (rItem.Which()) { + case RES_MARGIN_FIRSTLINE: + case RES_MARGIN_TEXTLEFT: + case RES_MARGIN_RIGHT: + assert(false); // is only called for frame formats? + break; + case RES_LR_SPACE: { SvxLRSpaceItem& rLRSpace = dynamic_cast(rItem); @@ -351,6 +357,7 @@ bool SvXMLImportItemMapper::PutXMLValue( case MID_FIRST_LINE_INDENT: { + assert(false); // it looks like this can't be called? (frame formats only, aTableItemMap) sal_Int32 nProp = 100; sal_Int32 nAbs = 0; @@ -366,6 +373,7 @@ bool SvXMLImportItemMapper::PutXMLValue( case MID_FIRST_AUTO: { + assert(false); // it looks like this can't be called? (frame formats only, aTableItemMap) bool bAutoFirst(false); bOk = ::sax::Converter::convertBool( bAutoFirst, rValue ); if( bOk ) diff --git a/sw/source/filter/xml/xmlitemm.cxx b/sw/source/filter/xml/xmlitemm.cxx index cd1b219ad894..1d610b6a9966 100644 --- a/sw/source/filter/xml/xmlitemm.cxx +++ b/sw/source/filter/xml/xmlitemm.cxx @@ -47,7 +47,6 @@ const SvXMLItemMapEntry aTableItemMap[] = M_E_SE( STYLE, REL_WIDTH, RES_FRM_SIZE, MID_FRMSIZE_REL_WIDTH ), // RES_PAPER_BIN // not required - // TODO: RES_LR_SPACE M_E_SE( FO, MARGIN, 0xFFFF/*invalid*/, MID_SW_FLAG_NO_ITEM_IMPORT), M_E_SIE( FO, MARGIN_LEFT, RES_LR_SPACE, MID_L_MARGIN ), M_E_SIE( FO, MARGIN_RIGHT, RES_LR_SPACE, MID_R_MARGIN ), diff --git a/sw/source/ui/envelp/envfmt.cxx b/sw/source/ui/envelp/envfmt.cxx index 818b913611cb..8250bdf8379c 100644 --- a/sw/source/ui/envelp/envfmt.cxx +++ b/sw/source/ui/envelp/envfmt.cxx @@ -217,7 +217,7 @@ void SwEnvFormatPage::Edit(std::string_view rIdent, bool bSender) aTmpSet.Put( aTabPos ); // left border as offset - const tools::Long nOff = aTmpSet.Get( RES_LR_SPACE ).GetTextLeft(); + const tools::Long nOff = aTmpSet.Get(RES_MARGIN_TEXTLEFT).GetTextLeft(); SfxInt32Item aOff( SID_ATTR_TABSTOP_OFFSET, nOff ); aTmpSet.Put( aOff ); @@ -269,7 +269,8 @@ SfxItemSet *SwEnvFormatPage::GetCollItemSet(SwTextFormatColl const * pColl, bool static WhichRangesContainer const aRanges(svl::Items< RES_PARATR_BEGIN, RES_PARATR_ADJUST, RES_PARATR_TABSTOP, RES_PARATR_END-1, - RES_LR_SPACE, RES_UL_SPACE, + RES_MARGIN_FIRSTLINE, RES_MARGIN_RIGHT, + RES_UL_SPACE, RES_UL_SPACE, RES_BACKGROUND, RES_SHADOW, SID_ATTR_TABSTOP_DEFAULTS, SID_ATTR_TABSTOP_DEFAULTS, SID_ATTR_TABSTOP_POS, SID_ATTR_TABSTOP_POS, diff --git a/sw/source/uibase/app/docstyle.cxx b/sw/source/uibase/app/docstyle.cxx index 563f7d2ea6f5..9c8f3c3eb4af 100644 --- a/sw/source/uibase/app/docstyle.cxx +++ b/sw/source/uibase/app/docstyle.cxx @@ -1437,10 +1437,10 @@ void SwDocStyleSheet::MergeIndentAttrsOfListStyle( SfxItemSet& rSet ) const SwNumFormat& rFormat = pRule->Get( 0 ); if ( rFormat.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT ) { - SvxLRSpaceItem aLR( RES_LR_SPACE ); - aLR.SetTextLeft( rFormat.GetIndentAt() ); - aLR.SetTextFirstLineOffset( static_cast(rFormat.GetFirstLineIndent()) ); - rSet.Put( aLR ); + SvxFirstLineIndentItem const firstLine(static_cast(rFormat.GetFirstLineIndent()), RES_MARGIN_FIRSTLINE); + SvxTextLeftMarginItem const leftMargin(rFormat.GetIndentAt(), RES_MARGIN_TEXTLEFT); + rSet.Put(firstLine); + rSet.Put(leftMargin); } } } @@ -1540,10 +1540,17 @@ void SwDocStyleSheet::SetItemSet( const SfxItemSet& rSet, } if ( bResetIndentAttrsAtParagraphStyle && rSet.GetItemState( RES_PARATR_NUMRULE, false ) == SfxItemState::SET && - rSet.GetItemState( RES_LR_SPACE, false ) != SfxItemState::SET && - m_pColl->GetItemState( RES_LR_SPACE, false ) == SfxItemState::SET ) + rSet.GetItemState(RES_MARGIN_FIRSTLINE, false) != SfxItemState::SET && + m_pColl->GetItemState(RES_MARGIN_FIRSTLINE, false) == SfxItemState::SET) { - m_rDoc.ResetAttrAtFormat( RES_LR_SPACE, *m_pColl ); + m_rDoc.ResetAttrAtFormat(RES_MARGIN_FIRSTLINE, *m_pColl); + } + if ( bResetIndentAttrsAtParagraphStyle && + rSet.GetItemState( RES_PARATR_NUMRULE, false ) == SfxItemState::SET && + rSet.GetItemState(RES_MARGIN_TEXTLEFT, false) != SfxItemState::SET && + m_pColl->GetItemState(RES_MARGIN_TEXTLEFT, false) == SfxItemState::SET) + { + m_rDoc.ResetAttrAtFormat(RES_MARGIN_TEXTLEFT, *m_pColl); } // #i56252: If a standard numbering style is assigned to a standard paragraph style diff --git a/sw/source/uibase/shells/textsh1.cxx b/sw/source/uibase/shells/textsh1.cxx index 60a608a04a70..4df9f6f39999 100644 --- a/sw/source/uibase/shells/textsh1.cxx +++ b/sw/source/uibase/shells/textsh1.cxx @@ -1494,8 +1494,8 @@ void SwTextShell::Execute(SfxRequest &rReq) // Left border as offset //#i24363# tab stops relative to indent - const tools::Long nOff = rWrtSh.getIDocumentSettingAccess().get(DocumentSettingId::TABS_RELATIVE_TO_INDENT) ? - aCoreSet.Get( RES_LR_SPACE ).GetTextLeft() : 0; + const tools::Long nOff = rWrtSh.getIDocumentSettingAccess().get(DocumentSettingId::TABS_RELATIVE_TO_INDENT) + ? aCoreSet.Get(RES_MARGIN_TEXTLEFT).GetTextLeft() : 0; SfxInt32Item aOff( SID_ATTR_TABSTOP_OFFSET, nOff ); aCoreSet.Put( aOff ); @@ -1531,8 +1531,16 @@ void SwTextShell::Execute(SfxRequest &rReq) if ( nSlot == SID_ATTR_PARA_LRSPACE) { SvxLRSpaceItem aParaMargin(static_cast(pArgs->Get(nSlot))); - aParaMargin.SetWhich( RES_LR_SPACE); - aCoreSet.Put(aParaMargin); + SvxFirstLineIndentItem firstLine(RES_MARGIN_FIRSTLINE); + SvxTextLeftMarginItem leftMargin(RES_MARGIN_TEXTLEFT); + SvxRightMarginItem rightMargin(RES_MARGIN_RIGHT); + firstLine.SetTextFirstLineOffset(aParaMargin.GetTextFirstLineOffset(), aParaMargin.GetPropTextFirstLineOffset()); + firstLine.SetAutoFirst(aParaMargin.IsAutoFirst()); + leftMargin.SetTextLeft(aParaMargin.GetTextLeft(), aParaMargin.GetPropLeft()); + rightMargin.SetRight(aParaMargin.GetRight(), aParaMargin.GetPropRight()); + aCoreSet.Put(firstLine); + aCoreSet.Put(leftMargin); + aCoreSet.Put(rightMargin); sw_ParagraphDialogResult(&aCoreSet, rWrtSh, rReq, pPaM); } diff --git a/sw/source/uibase/shells/txtattr.cxx b/sw/source/uibase/shells/txtattr.cxx index 8f5c87a8ffc4..6a916f2f5ced 100644 --- a/sw/source/uibase/shells/txtattr.cxx +++ b/sw/source/uibase/shells/txtattr.cxx @@ -745,10 +745,19 @@ void SwTextShell::GetAttrState(SfxItemSet &rSet) case SID_ATTR_PARA_RIGHTSPACE: case SID_ATTR_PARA_FIRSTLINESPACE: { - eState = aCoreSet.GetItemState(RES_LR_SPACE); + eState = aCoreSet.GetItemState(RES_MARGIN_FIRSTLINE); + eState = std::min(aCoreSet.GetItemState(RES_MARGIN_TEXTLEFT), eState); + eState = std::min(aCoreSet.GetItemState(RES_MARGIN_RIGHT), eState); if( eState >= SfxItemState::DEFAULT ) { - SvxLRSpaceItem aLR = aCoreSet.Get( RES_LR_SPACE ); + SvxLRSpaceItem aLR(RES_LR_SPACE); + SvxFirstLineIndentItem const& rFirstLine(aCoreSet.Get(RES_MARGIN_FIRSTLINE)); + SvxTextLeftMarginItem const& rLeftMargin(aCoreSet.Get(RES_MARGIN_TEXTLEFT)); + SvxRightMarginItem const& rRightMargin(aCoreSet.Get(RES_MARGIN_RIGHT)); + aLR.SetTextFirstLineOffset(rFirstLine.GetTextFirstLineOffset(), rFirstLine.GetPropTextFirstLineOffset()); + aLR.SetAutoFirst(rFirstLine.IsAutoFirst()); + aLR.SetTextLeft(rLeftMargin.GetTextLeft(), rLeftMargin.GetPropLeft()); + aLR.SetRight(rRightMargin.GetRight(), rRightMargin.GetPropRight()); aLR.SetWhich(nSlot); rSet.Put(aLR); } diff --git a/sw/source/uibase/uiview/viewsrch.cxx b/sw/source/uibase/uiview/viewsrch.cxx index f64b92f3171e..cec4fb8b695f 100644 --- a/sw/source/uibase/uiview/viewsrch.cxx +++ b/sw/source/uibase/uiview/viewsrch.cxx @@ -418,7 +418,8 @@ void SwView::ExecSearch(SfxRequest& rReq) /*16 */ RES_PARATR_LINESPACING, RES_PARATR_HYPHENZONE, /*18 */ RES_PARATR_REGISTER, RES_PARATR_REGISTER, /*20 */ RES_PARATR_VERTALIGN, RES_PARATR_VERTALIGN, -/*22 */ RES_LR_SPACE, RES_UL_SPACE, + RES_MARGIN_FIRSTLINE, RES_MARGIN_RIGHT, + RES_UL_SPACE, RES_UL_SPACE, /*24 */ SID_ATTR_PARA_MODEL, SID_ATTR_PARA_KEEP >); diff --git a/sw/source/uibase/uiview/viewtab.cxx b/sw/source/uibase/uiview/viewtab.cxx index c8b83129dd25..5d41fadf67ea 100644 --- a/sw/source/uibase/uiview/viewtab.cxx +++ b/sw/source/uibase/uiview/viewtab.cxx @@ -626,11 +626,11 @@ void SwView::ExecTabWin( SfxRequest const & rReq ) const SvxTabStopItem& rDefTabs = rSh.GetDefault(RES_PARATR_TABSTOP); // Default tab at pos 0 - SfxItemSetFixed aSet( GetPool() ); + SfxItemSetFixed aSet(GetPool()); rSh.GetCurAttr( aSet ); - const SvxLRSpaceItem& rLR = aSet.Get(RES_LR_SPACE); + const SvxFirstLineIndentItem & rFirstLine(aSet.Get(RES_MARGIN_FIRSTLINE)); - if ( rLR.GetTextFirstLineOffset() < 0 ) + if (rFirstLine.GetTextFirstLineOffset() < 0) { SvxTabStop aSwTabStop( 0, SvxTabAdjust::Default ); aTabStops.Insert( aSwTabStop ); @@ -703,41 +703,45 @@ void SwView::ExecTabWin( SfxRequest const & rReq ) { if (pReqArgs) { - SfxItemSetFixed aLRSpaceSet( GetPool() ); + SfxItemSetFixed aLRSpaceSet(GetPool()); rSh.GetCurAttr( aLRSpaceSet ); - SvxLRSpaceItem aParaMargin( aLRSpaceSet.Get( RES_LR_SPACE ) ); if (const SfxStringItem *fLineIndent = pReqArgs->GetItemIfSet(SID_PARAGRAPH_FIRST_LINE_INDENT)) { + SvxFirstLineIndentItem firstLine(aLRSpaceSet.Get(RES_MARGIN_FIRSTLINE)); const OUString ratio = fLineIndent->GetValue(); - aParaMargin.SetTextFirstLineOffset(nPageWidth * ratio.toFloat()); + firstLine.SetTextFirstLineOffset(nPageWidth * ratio.toFloat()); + rSh.SetAttrItem(firstLine); } else if (const SfxStringItem *pLeftIndent = pReqArgs->GetItemIfSet(SID_PARAGRAPH_LEFT_INDENT)) { + SvxTextLeftMarginItem leftMargin(aLRSpaceSet.Get(RES_MARGIN_TEXTLEFT)); const OUString ratio = pLeftIndent->GetValue(); - aParaMargin.SetLeft(nPageWidth * ratio.toFloat()); + // this used to call SetLeft() but was probably a bug + leftMargin.SetTextLeft(nPageWidth * ratio.toFloat()); + rSh.SetAttrItem(leftMargin); } else if (const SfxStringItem *pRightIndent = pReqArgs->GetItemIfSet(SID_PARAGRAPH_RIGHT_INDENT)) { + SvxRightMarginItem rightMargin(aLRSpaceSet.Get(RES_MARGIN_RIGHT)); const OUString ratio = pRightIndent->GetValue(); - aParaMargin.SetRight(nPageWidth * ratio.toFloat()); + rightMargin.SetRight(nPageWidth * ratio.toFloat()); + rSh.SetAttrItem(rightMargin); } - rSh.SetAttrItem(aParaMargin); } break; } case SID_HANGING_INDENT: { - SfxItemSetFixed aLRSpaceSet( GetPool() ); + SfxItemSetFixed aLRSpaceSet(GetPool()); rSh.GetCurAttr( aLRSpaceSet ); - SvxLRSpaceItem aParaMargin( aLRSpaceSet.Get( RES_LR_SPACE ) ); - - SvxLRSpaceItem aNewMargin( RES_LR_SPACE ); - aNewMargin.SetTextLeft( aParaMargin.GetTextLeft() + aParaMargin.GetTextFirstLineOffset() ); - aNewMargin.SetRight( aParaMargin.GetRight() ); - aNewMargin.SetTextFirstLineOffset( (aParaMargin.GetTextFirstLineOffset()) * -1 ); - - rSh.SetAttrItem( aNewMargin ); + SvxFirstLineIndentItem firstLine(aLRSpaceSet.Get(RES_MARGIN_FIRSTLINE)); + SvxTextLeftMarginItem leftMargin(aLRSpaceSet.Get(RES_MARGIN_TEXTLEFT)); + leftMargin.SetTextLeft(leftMargin.GetTextLeft() + firstLine.GetTextFirstLineOffset()); + firstLine.SetTextFirstLineOffset((firstLine.GetTextFirstLineOffset()) * -1); + firstLine.SetAutoFirst(false); // old code would do this, is it wanted? + rSh.SetAttrItem(firstLine); + rSh.SetAttrItem(leftMargin); break; } @@ -753,30 +757,42 @@ void SwView::ExecTabWin( SfxRequest const & rReq ) aParaMargin.SetWhich( RES_LR_SPACE ); SwTextFormatColl* pColl = rSh.GetCurTextFormatColl(); + SvxFirstLineIndentItem firstLine(RES_MARGIN_FIRSTLINE); + firstLine.SetTextFirstLineOffset(aParaMargin.GetTextFirstLineOffset(), aParaMargin.GetPropTextFirstLineOffset()); + firstLine.SetAutoFirst(aParaMargin.IsAutoFirst()); + SvxTextLeftMarginItem const leftMargin(aParaMargin.GetTextLeft(), RES_MARGIN_TEXTLEFT); + SvxRightMarginItem const rightMargin(aParaMargin.GetRight(), RES_MARGIN_RIGHT); + // #i23726# if (m_pNumRuleNodeFromDoc) { // --> #i42922# Mouse move of numbering label // has to consider the left indent of the paragraph - SfxItemSetFixed aSet( GetPool() ); + SfxItemSetFixed aSet( GetPool() ); rSh.GetCurAttr( aSet ); - const SvxLRSpaceItem& rLR = aSet.Get(RES_LR_SPACE); + const SvxTextLeftMarginItem & rLeftMargin(aSet.Get(RES_MARGIN_TEXTLEFT)); SwPosition aPos(*m_pNumRuleNodeFromDoc); // #i90078# - rSh.SetIndent( static_cast< short >(aParaMargin.GetTextLeft() - rLR.GetTextLeft()), aPos); + rSh.SetIndent(static_cast(aParaMargin.GetTextLeft() - rLeftMargin.GetTextLeft()), aPos); // #i42921# invalidate state of indent in order to get a ruler update. aParaMargin.SetWhich( nSlot ); GetViewFrame().GetBindings().SetState( aParaMargin ); } else if( pColl && pColl->IsAutoUpdateOnDirectFormat() ) { - SfxItemSetFixed aSet(GetPool()); - aSet.Put(aParaMargin); + SfxItemSetFixed aSet(GetPool()); + aSet.Put(firstLine); + aSet.Put(leftMargin); + aSet.Put(rightMargin); rSh.AutoUpdatePara( pColl, aSet); } else - rSh.SetAttrItem( aParaMargin ); + { + rSh.SetAttrItem(firstLine); + rSh.SetAttrItem(leftMargin); + rSh.SetAttrItem(rightMargin); + } if ( aParaMargin.GetTextFirstLineOffset() < 0 ) { @@ -1560,7 +1576,8 @@ void SwView::StateTabWin(SfxItemSet& rSet) ( nSelType & SelectionType::Graphic ) || ( nSelType & SelectionType::Frame ) || ( nSelType & SelectionType::Ole ) || - ( SfxItemState::DEFAULT > aCoreSet.GetItemState(RES_LR_SPACE) ) || + (aCoreSet.GetItemState(RES_MARGIN_FIRSTLINE) < SfxItemState::DEFAULT) || + (aCoreSet.GetItemState(RES_MARGIN_TEXTLEFT) < SfxItemState::DEFAULT) || (!bVerticalWriting && (SID_ATTR_TABSTOP_VERTICAL == nWhich) ) || ( bVerticalWriting && (RES_PARATR_TABSTOP == nWhich)) ) @@ -1606,7 +1623,7 @@ void SwView::StateTabWin(SfxItemSet& rSet) case SID_HANGING_INDENT: { - SfxItemState e = aCoreSet.GetItemState(RES_LR_SPACE); + SfxItemState e = aCoreSet.GetItemState(RES_MARGIN_FIRSTLINE); if( e == SfxItemState::DISABLED ) rSet.DisableItem(nWhich); break; @@ -1633,7 +1650,13 @@ void SwView::StateTabWin(SfxItemSet& rSet) std::shared_ptr aLR(std::make_shared(RES_LR_SPACE)); if ( !IsTabColFromDoc() ) { - aLR.reset(aCoreSet.Get(RES_LR_SPACE).Clone()); + SvxFirstLineIndentItem const& rFirstLine(aCoreSet.Get(RES_MARGIN_FIRSTLINE)); + SvxTextLeftMarginItem const& rLeftMargin(aCoreSet.Get(RES_MARGIN_TEXTLEFT)); + SvxRightMarginItem const& rRightMargin(aCoreSet.Get(RES_MARGIN_RIGHT)); + aLR->SetTextFirstLineOffset(rFirstLine.GetTextFirstLineOffset(), rFirstLine.GetPropTextFirstLineOffset()); + aLR->SetAutoFirst(rFirstLine.IsAutoFirst()); + aLR->SetTextLeft(rLeftMargin.GetTextLeft(), rLeftMargin.GetPropLeft()); + aLR->SetRight(rRightMargin.GetRight(), rRightMargin.GetPropRight()); // #i23726# if (m_pNumRuleNodeFromDoc) diff --git a/sw/source/uibase/wrtsh/delete.cxx b/sw/source/uibase/wrtsh/delete.cxx index ad49d66e58bf..7c6117b2518e 100644 --- a/sw/source/uibase/wrtsh/delete.cxx +++ b/sw/source/uibase/wrtsh/delete.cxx @@ -63,33 +63,35 @@ bool SwWrtShell::TryRemoveIndent() { bool bResult = false; - SfxItemSetFixed aAttrSet(GetAttrPool()); + SfxItemSetFixed aAttrSet(GetAttrPool()); GetCurAttr(aAttrSet); - SvxLRSpaceItem aItem = aAttrSet.Get(RES_LR_SPACE); - short aOldFirstLineOfst = aItem.GetTextFirstLineOffset(); + SvxFirstLineIndentItem firstLine(aAttrSet.Get(RES_MARGIN_FIRSTLINE)); + SvxTextLeftMarginItem leftMargin(aAttrSet.Get(RES_MARGIN_TEXTLEFT)); + short aOldFirstLineOfst = firstLine.GetTextFirstLineOffset(); if (aOldFirstLineOfst > 0) { - aItem.SetTextFirstLineOffset(0); + firstLine.SetTextFirstLineOffset(0); bResult = true; } else if (aOldFirstLineOfst < 0) { - aItem.SetTextFirstLineOffset(0); - aItem.SetLeft(aItem.GetLeft() + aOldFirstLineOfst); - + // this used to call SetLeft() but this should be the same result + firstLine.SetTextFirstLineOffset(0); + leftMargin.SetTextLeft(leftMargin.GetTextLeft() + aOldFirstLineOfst); bResult = true; } - else if (aItem.GetLeft() != 0) + else if (leftMargin.GetTextLeft() != 0) { - aItem.SetLeft(0); + leftMargin.SetTextLeft(0); bResult = true; } if (bResult) { - aAttrSet.Put(aItem); + aAttrSet.Put(firstLine); + aAttrSet.Put(leftMargin); SetAttrSet(aAttrSet); } -- cgit