diff options
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport16.cxx | 6 | ||||
-rw-r--r-- | sw/source/core/text/txttab.cxx | 23 |
2 files changed, 25 insertions, 4 deletions
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx index 408f0e608da0..5d567543bcec 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx @@ -254,6 +254,12 @@ DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf142404_tabOverSpacingC15, "tdf142404_ CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Big tab: full paragraph area used", 737, nLineWidth, 100); // Pages 2/3 are TabOverMargin - in this particular case tabs should not go over margin. + CPPUNIT_ASSERT_EQUAL(OUString("A right tab positioned at"), parseDump("//page[2]/body/txt[6]/Text[1]", "Portion")); + sal_Int32 nParaWidth = parseDump("//page[2]/body/txt[6]/infos/prtBounds", "width").toInt32(); + // the clearest non-first-line visual example is this second tab in the right-tab paragraph. + nLineWidth = parseDump("//page[2]/body/txt[6]/LineBreak[4]", "nWidth").toInt32(); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Full paragraph area used", nLineWidth, nParaWidth); + CPPUNIT_ASSERT_EQUAL(OUString("TabOverflow does what?"), parseDump("//page[3]/body/txt[2]/Text[1]", "Portion")); // Not 1 line high (Word 2010 DOCX and ODT), or 4 lines high (prev LO DOCX), // but 8 lines high. 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); } |