[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.0' - sw/qa sw/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Fri Jul 20 10:15:11 UTC 2018
sw/qa/extras/uiwriter/data/tdf116403-considerborders.odt |binary
sw/qa/extras/uiwriter/uiwriter.cxx | 26 +++++++++++++++
sw/source/core/tox/ToxTabStopTokenHandler.cxx | 5 ++
3 files changed, 31 insertions(+)
New commits:
commit aca48fbf7b7c33ebabf6f1e479959838693e2508
Author: Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Fri Mar 16 11:22:41 2018 +0300
Commit: Jan Holesovsky <kendy at collabora.com>
CommitDate: Fri Jul 20 12:14:42 2018 +0200
tdf#116403: consider borders when updating right-aligned tab in index
Change-Id: I415d8fcfdd75e6d608ec2e3ba228146cf8139278
Reviewed-on: https://gerrit.libreoffice.org/51388
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
(cherry picked from commit 1f3630e2fb35389835cb326a46bd539660942632)
Reviewed-on: https://gerrit.libreoffice.org/57625
Tested-by: Mike Kaganski <mike.kaganski at collabora.com>
Reviewed-by: Jan Holesovsky <kendy at collabora.com>
diff --git a/sw/qa/extras/uiwriter/data/tdf116403-considerborders.odt b/sw/qa/extras/uiwriter/data/tdf116403-considerborders.odt
new file mode 100644
index 000000000000..c0fb91ad7eb3
Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf116403-considerborders.odt differ
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index a103ab5f52a8..4ea7de52b6a7 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -305,6 +305,7 @@ public:
void testTdf108048();
void testTdf115132();
void testXDrawPagesSupplier();
+ void testTdf116403();
CPPUNIT_TEST_SUITE(SwUiWriterTest);
CPPUNIT_TEST(testReplaceForward);
@@ -489,6 +490,7 @@ public:
CPPUNIT_TEST(testTdf108048);
CPPUNIT_TEST(testTdf115132);
CPPUNIT_TEST(testXDrawPagesSupplier);
+ CPPUNIT_TEST(testTdf116403);
CPPUNIT_TEST_SUITE_END();
private:
@@ -5940,6 +5942,30 @@ void SwUiWriterTest::testXDrawPagesSupplier()
xDrawPage.get(), xDrawPageFromXDrawPages.get());
}
+void SwUiWriterTest::testTdf116403()
+{
+ createDoc("tdf116403-considerborders.odt");
+ // Check that before ToX update, the tab stop position is the old one
+ uno::Reference<text::XTextRange> xParagraph = getParagraph(2, "1\t1");
+ auto aTabs = getProperty<uno::Sequence<style::TabStop>>(xParagraph, "ParaTabStops");
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), aTabs.getLength());
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(17000), aTabs[0].Position);
+
+ SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument *>(mxComponent.get());
+ CPPUNIT_ASSERT(pTextDoc);
+ SwWrtShell* pWrtShell = pTextDoc->GetDocShell()->GetWrtShell();
+ const SwTOXBase* pTOX = pWrtShell->GetTOX(0);
+ CPPUNIT_ASSERT(pTOX);
+ pWrtShell->UpdateTableOf(*pTOX);
+
+ xParagraph = getParagraph(2, "1\t1");
+ aTabs = getProperty<uno::Sequence<style::TabStop>>(xParagraph, "ParaTabStops");
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), aTabs.getLength());
+ // This was still 17000, refreshing ToX didn't take borders spacings and widths into account
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Page borders must be considered for right-aligned tabstop",
+ static_cast<sal_Int32>(17000 - 2 * 500 - 2 * 1), aTabs[0].Position);
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/core/tox/ToxTabStopTokenHandler.cxx b/sw/source/core/tox/ToxTabStopTokenHandler.cxx
index 6de76cb4f2c7..3fd3abb8abb1 100644
--- a/sw/source/core/tox/ToxTabStopTokenHandler.cxx
+++ b/sw/source/core/tox/ToxTabStopTokenHandler.cxx
@@ -93,6 +93,11 @@ DefaultToxTabStopTokenHandler::CalculatePageMarginFromPageDescription(const SwTe
const SwFrameFormat& rPgDscFormat = pPageDesc->GetMaster();
long result = rPgDscFormat.GetFrameSize().GetWidth() - rPgDscFormat.GetLRSpace().GetLeft()
- rPgDscFormat.GetLRSpace().GetRight();
+ // Also consider borders
+ const SvxBoxItem& rBox = rPgDscFormat.GetBox();
+ for (SvxBoxItemLine eLine : { SvxBoxItemLine::LEFT, SvxBoxItemLine::RIGHT })
+ if (const editeng::SvxBorderLine* pBorder = rBox.GetLine(eLine))
+ result -= pBorder->GetWidth() + rBox.GetDistance(eLine);
return result;
}
More information about the Libreoffice-commits
mailing list