diff options
author | Justin Luth <justin_luth@sil.org> | 2021-06-03 13:38:33 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2021-06-08 15:23:29 +0200 |
commit | a2d8a737f41cbb0ed8a51a99b1c233b25e433d1c (patch) | |
tree | ccdd9e7607b7b0d08aff136181132009b0775a79 /sw/source/core/text | |
parent | c4c8202359e574bce784f6b40ce95e49e983c7bb (diff) |
tdf#142404 DOCX c15: add compat flag TabOverSpacing
DOCX in 2013 (compatibilityMode 15) no longer supports
TabOverMargin (i.e. the text margin),
but it does a similar kind of thing if the tab goes
into the spacing-after of a paragraph.
So add a compat flag to handle this in-between
kind of situation.
I grepped -i "tab_*over_*margin" to see if I was missing
anything. Decimal/Center proved to be only tabOverMargin.
IsInSect shouldn't matter since it fits inside the printing range.
The other places where I didn't insert TabOverSpacing
didn't seem relevant based on a code read.
Tab-after-tab still doesn't work great, but what we have is
already a massive house of cards that will just collapse if changed.
No real provision for handling tabs-over-paragraph-end.
-auto-tabs are created instead of "beyond nMyRight" tab,
unless it is the first tab defined.
-doesn't allow auto-tabs to fill the remaining space.
But on the other hand, MS Word's implementation of tabs
follows some kind of incomprehensible bizarre logic,
so just ignore the tabs completely, please.
Change-Id: I3723107b29ec3e287ea8661544711c13eee3ca48
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116667
Tested-by: Jenkins
Reviewed-by: Justin Luth <justin_luth@sil.org>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sw/source/core/text')
-rw-r--r-- | sw/source/core/text/inftxt.cxx | 10 | ||||
-rw-r--r-- | sw/source/core/text/itrcrsr.cxx | 4 | ||||
-rw-r--r-- | sw/source/core/text/txttab.cxx | 22 |
3 files changed, 28 insertions, 8 deletions
diff --git a/sw/source/core/text/inftxt.cxx b/sw/source/core/text/inftxt.cxx index 476c4dacb7f5..f43f811bd744 100644 --- a/sw/source/core/text/inftxt.cxx +++ b/sw/source/core/text/inftxt.cxx @@ -1761,7 +1761,9 @@ SwTwips SwTextFormatInfo::GetLineWidth() const bool bTabOverMargin = GetTextFrame()->GetDoc().getIDocumentSettingAccess().get( DocumentSettingId::TAB_OVER_MARGIN); - if (!bTabOverMargin) + const bool bTabOverSpacing = GetTextFrame()->GetDoc().getIDocumentSettingAccess().get( + DocumentSettingId::TAB_OVER_SPACING); + if (!bTabOverMargin && !bTabOverSpacing) return nLineWidth; SwTabPortion* pLastTab = GetLastTab(); @@ -1792,6 +1794,12 @@ SwTwips SwTextFormatInfo::GetLineWidth() // text frame area to the right (RR above, but not LL). nLineWidth = nTextFrameWidth - X(); + if (!bTabOverMargin) // thus bTabOverSpacing only + { + // right, center, decimal can back-fill all the available space - same as TabOverMargin + if (pLastTab->GetWhichPor() == PortionType::TabLeft) + nLineWidth = nTextFrameWidth - pLastTab->GetTabPos(); + } return nLineWidth; } diff --git a/sw/source/core/text/itrcrsr.cxx b/sw/source/core/text/itrcrsr.cxx index 933de96b9acd..138359e68c41 100644 --- a/sw/source/core/text/itrcrsr.cxx +++ b/sw/source/core/text/itrcrsr.cxx @@ -1223,7 +1223,9 @@ void SwTextCursor::GetCharRect( SwRect* pOrig, TextFrameIndex const nOfst, pCMS->m_x2Lines->aPortion.Pos().AdjustY(aCharPos.Y() ); } - const bool bTabOverMargin = GetTextFrame()->GetDoc().getIDocumentSettingAccess().get(DocumentSettingId::TAB_OVER_MARGIN); + const IDocumentSettingAccess& rIDSA = GetTextFrame()->GetDoc().getIDocumentSettingAccess(); + const bool bTabOverMargin = rIDSA.get(DocumentSettingId::TAB_OVER_MARGIN) + || rIDSA.get(DocumentSettingId::TAB_OVER_SPACING); // Make sure the cursor respects the right margin, unless in compat mode, where the tab size has priority over the margin size. if( pOrig->Left() > nTmpRight && !bTabOverMargin) pOrig->Pos().setX( nTmpRight ); diff --git a/sw/source/core/text/txttab.cxx b/sw/source/core/text/txttab.cxx index ae8b69ba3bf9..e12d31c64251 100644 --- a/sw/source/core/text/txttab.cxx +++ b/sw/source/core/text/txttab.cxx @@ -329,6 +329,7 @@ bool SwTabPortion::PreFormat( SwTextFormatInfo &rInf ) const bool bTabCompat = rIDSA.get(DocumentSettingId::TAB_COMPAT); const bool bTabOverflow = rIDSA.get(DocumentSettingId::TAB_OVERFLOW); const bool bTabOverMargin = rIDSA.get(DocumentSettingId::TAB_OVER_MARGIN); + const bool bTabOverSpacing = rIDSA.get(DocumentSettingId::TAB_OVER_SPACING); // The minimal width of a tab is one blank at least. // #i37686# In compatibility mode, the minimum width @@ -381,10 +382,13 @@ bool SwTabPortion::PreFormat( SwTextFormatInfo &rInf ) case PortionType::TabLeft: { // handle this case in PostFormat - if( bTabOverMargin && !m_bAutoTabStop && GetTabPos() > rInf.Width() ) + if ((bTabOverMargin || bTabOverSpacing) && !m_bAutoTabStop && GetTabPos() > rInf.Width()) { - rInf.SetLastTab( this ); - break; + if (bTabOverMargin || GetTabPos() < rInf.GetTextFrame()->getFrameArea().Width()) + { + rInf.SetLastTab(this); + break; + } } PrtWidth( o3tl::narrowing<sal_uInt16>(GetTabPos() - rInf.X()) ); @@ -443,13 +447,19 @@ bool SwTabPortion::PostFormat( SwTextFormatInfo &rInf ) { bool bTabOverMargin = rInf.GetTextFrame()->GetDoc().getIDocumentSettingAccess().get( DocumentSettingId::TAB_OVER_MARGIN); - + bool bTabOverSpacing = rInf.GetTextFrame()->GetDoc().getIDocumentSettingAccess().get( + DocumentSettingId::TAB_OVER_SPACING); if (rInf.GetTextFrame()->IsInSct()) bTabOverMargin = false; // If the tab position is larger than the right margin, it gets scaled down by default. // However, if compat mode enabled, we allow tabs to go over the margin: the rest of the paragraph is not broken into lines. - const sal_uInt16 nRight = bTabOverMargin ? GetTabPos() : std::min(GetTabPos(), rInf.Width()); + const sal_uInt16 nRight + = bTabOverMargin + ? GetTabPos() + : bTabOverSpacing + ? std::min<long>(GetTabPos(), rInf.GetTextFrame()->getFrameArea().Right()) + : std::min(GetTabPos(), rInf.Width()); const SwLinePortion *pPor = GetNextPortion(); sal_uInt16 nPorWidth = 0; @@ -462,7 +472,7 @@ bool SwTabPortion::PostFormat( SwTextFormatInfo &rInf ) const PortionType nWhich = GetWhichPor(); const bool bTabCompat = rInf.GetTextFrame()->GetDoc().getIDocumentSettingAccess().get(DocumentSettingId::TAB_COMPAT); - if ( bTabOverMargin && PortionType::TabLeft == nWhich ) + if ((bTabOverMargin || bTabOverSpacing) && PortionType::TabLeft == nWhich) { nPorWidth = 0; } |