diff options
author | Michael Stahl <michael.stahl@allotropia.de> | 2023-02-14 18:03:55 +0100 |
---|---|---|
committer | Michael Stahl <michael.stahl@allotropia.de> | 2023-02-24 07:32:23 +0000 |
commit | db115bec9254417ef7a3faf687478fe5424ab378 (patch) | |
tree | 0b5f58cda73137302fd955db3e0958dda71358fb /sw/source/uibase | |
parent | 7e7b69829db63e64b8aed8d03c6eaed6d8f1a27c (diff) |
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 <michael.stahl@allotropia.de>
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
Diffstat (limited to 'sw/source/uibase')
-rw-r--r-- | sw/source/uibase/app/docstyle.cxx | 21 | ||||
-rw-r--r-- | sw/source/uibase/shells/textsh1.cxx | 16 | ||||
-rw-r--r-- | sw/source/uibase/shells/txtattr.cxx | 13 | ||||
-rw-r--r-- | sw/source/uibase/uiview/viewsrch.cxx | 3 | ||||
-rw-r--r-- | sw/source/uibase/uiview/viewtab.cxx | 77 | ||||
-rw-r--r-- | sw/source/uibase/wrtsh/delete.cxx | 22 |
6 files changed, 101 insertions, 51 deletions
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<short>(rFormat.GetFirstLineIndent()) ); - rSet.Put( aLR ); + SvxFirstLineIndentItem const firstLine(static_cast<short>(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<const SvxLRSpaceItem&>(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<RES_LR_SPACE, RES_LR_SPACE> aSet( GetPool() ); + SfxItemSetFixed<RES_MARGIN_FIRSTLINE, RES_MARGIN_FIRSTLINE> 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<RES_LR_SPACE, RES_LR_SPACE> aLRSpaceSet( GetPool() ); + SfxItemSetFixed<RES_MARGIN_FIRSTLINE, RES_MARGIN_RIGHT> 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<RES_LR_SPACE, RES_LR_SPACE> aLRSpaceSet( GetPool() ); + SfxItemSetFixed<RES_MARGIN_FIRSTLINE, RES_MARGIN_RIGHT> 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<RES_LR_SPACE, RES_LR_SPACE> aSet( GetPool() ); + SfxItemSetFixed<RES_MARGIN_TEXTLEFT, RES_MARGIN_TEXTLEFT> 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<short>(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<RES_LR_SPACE, RES_LR_SPACE> aSet(GetPool()); - aSet.Put(aParaMargin); + SfxItemSetFixed<RES_MARGIN_FIRSTLINE, RES_MARGIN_RIGHT> 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<SvxLRSpaceItem> aLR(std::make_shared<SvxLRSpaceItem>(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<RES_LR_SPACE, RES_LR_SPACE> aAttrSet(GetAttrPool()); + SfxItemSetFixed<RES_MARGIN_FIRSTLINE, RES_MARGIN_FIRSTLINE> 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); } |