summaryrefslogtreecommitdiff
path: root/sw/source/core/text/txttab.cxx
diff options
context:
space:
mode:
authorJustin Luth <justin_luth@sil.org>2021-06-11 16:19:12 +0200
committerJustin Luth <justin_luth@sil.org>2021-06-19 20:13:49 +0200
commitb85491e40ccb83ff78c7c4b2c0d535eafa5d23ed (patch)
tree9f62cea1b8ff1b51ef5ed046354e5ca998396b9f /sw/source/core/text/txttab.cxx
parentce762a7ab170aa1115cfb0dd68f1c50abf5a86f3 (diff)
tdf#142404 DOCX c15: handle remaining TabOverSpacing tabs
The previous commit handled the case where a non-first LEFT tab was beyond the text area. But the remaining cases were still being (mis)treated as automatic tabs. We won't worry about the impact where compatibilityMode is less than 15/2013+ since Word is absolutely goofy, and LO doesn't even come close to matching it. But in compat15 mode, the end result of having a non-LEFT tab over the margin effecively means that the text will flow backwards from the right margin, just as if it was a RIGHT tabstop. So treat all of the remaining tabs as a right-tab at the end of the paragraph-area. Change-Id: I43a38516c0639c56341bdba0213ffb4a7d5cbf3c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117340 Tested-by: Jenkins Reviewed-by: Justin Luth <justin_luth@sil.org>
Diffstat (limited to 'sw/source/core/text/txttab.cxx')
-rw-r--r--sw/source/core/text/txttab.cxx23
1 files changed, 19 insertions, 4 deletions
diff --git a/sw/source/core/text/txttab.cxx b/sw/source/core/text/txttab.cxx
index 4039509dd4ae..d3319dea4a7a 100644
--- a/sw/source/core/text/txttab.cxx
+++ b/sw/source/core/text/txttab.cxx
@@ -131,6 +131,7 @@ SwTabPortion *SwTextFormatter::NewTabPortion( SwTextFormatInfo &rInf, bool bAuto
}
SwTwips nNextPos = 0;
+ bool bAbsoluteNextPos = false;
// #i24363# tab stops relative to indent
// nSearchPos: The current position relative to the tabs origin
@@ -149,8 +150,7 @@ SwTabPortion *SwTextFormatter::NewTabPortion( SwTextFormatInfo &rInf, bool bAuto
const SvxTabStop* pTabStop = m_aLineInf.GetTabStop( nSearchPos, nMyRight );
if (!nMyRight)
nMyRight = nOldRight;
- if (pTabStop &&
- (pTabStop->GetTabPos() <= nMyRight || pTabStop->GetAdjustment() == SvxTabAdjust::Left))
+ if (pTabStop)
{
cFill = ' ' != pTabStop->GetFill() ? pTabStop->GetFill() : 0;
cDec = pTabStop->GetDecimal();
@@ -161,6 +161,21 @@ SwTabPortion *SwTextFormatter::NewTabPortion( SwTextFormatInfo &rInf, bool bAuto
//calculate default tab position of default tabs in negative indent
nNextPos = ( nSearchPos / nNextPos ) * nNextPos;
}
+ else if (pTabStop->GetTabPos() > nMyRight
+ && pTabStop->GetAdjustment() != SvxTabAdjust::Left)
+ {
+ // A rather special situation. The tabstop found is:
+ // 1.) in a document compatible with MS formats
+ // 2.) not a left tabstop.
+ // 3.) not the first tabstop (in that case nMyRight was adjusted to match tabPos).
+ // 4.) beyond the end of the text area
+ // Therefore, they act like right-tabstops at the edge of the para area.
+ // This benefits DOCX 2013+, and doesn't hurt the earlier formats,
+ // since up till now these were just treated as automatic tabstops.
+ eAdj = SvxTabAdjust::Right;
+ bAbsoluteNextPos = true;
+ nNextPos = rInf.Width();
+ }
bAutoTabStop = false;
}
else
@@ -196,7 +211,6 @@ SwTabPortion *SwTextFormatter::NewTabPortion( SwTextFormatInfo &rInf, bool bAuto
}
cFill = 0;
eAdj = SvxTabAdjust::Left;
- pTabStop = nullptr;
}
// #i115705# - correction and refactoring:
@@ -265,7 +279,8 @@ SwTabPortion *SwTextFormatter::NewTabPortion( SwTextFormatInfo &rInf, bool bAuto
}
}
- nNextPos += bRTL ? nLinePos - nTabLeft : nTabLeft - nLinePos;
+ if (!bAbsoluteNextPos)
+ nNextPos += bRTL ? nLinePos - nTabLeft : nTabLeft - nLinePos;
OSL_ENSURE( nNextPos >= 0, "GetTabStop: Don't go back!" );
nNewTabPos = sal_uInt16(nNextPos);
}