[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.0' - 3 commits - sw/qa sw/source
Miklos Vajna
vmiklos at collabora.co.uk
Fri Jan 8 08:50:13 PST 2016
sw/qa/extras/uiwriter/uiwriter.cxx | 33 ++++++++++++++++++++++++++++++---
sw/source/core/layout/calcmove.cxx | 5 +++--
sw/source/core/layout/wsfrm.cxx | 18 ++++++++++++++++--
3 files changed, 49 insertions(+), 7 deletions(-)
New commits:
commit 8094e313c0d8b517c124cb86fb10ff8f911d2744
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Fri Jan 8 17:10:17 2016 +0100
tdf#96961 sw Hide Whitespace: still show whitespace on the last page
Mainly to match Word's hide whitespace behavior.
(cherry picked from commit 49b67cdc36b599f865d4a6de214d901861f27196)
Conflicts:
sw/qa/extras/uiwriter/uiwriter.cxx
sw/source/core/layout/calcmove.cxx
Change-Id: Ica09bca5004adbfa14d1c9aca04079129f8a1a68
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 64ded0d..ce38f1e 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -108,6 +108,7 @@ public:
void testTdf96515();
void testTdf96943();
void testTdf96536();
+ void testTdf96961();
CPPUNIT_TEST_SUITE(SwUiWriterTest);
CPPUNIT_TEST(testReplaceForward);
@@ -153,6 +154,7 @@ public:
CPPUNIT_TEST(testTdf96515);
CPPUNIT_TEST(testTdf96943);
CPPUNIT_TEST(testTdf96536);
+ CPPUNIT_TEST(testTdf96961);
CPPUNIT_TEST_SUITE_END();
@@ -1221,6 +1223,26 @@ void SwUiWriterTest::testTdf96536()
CPPUNIT_ASSERT(parseDump("/root/page[1]/infos/bounds", "height").toInt32() <= 276);
}
+void SwUiWriterTest::testTdf96961()
+{
+ // Insert a page break.
+ SwDoc* pDoc = createDoc();
+ SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+ pWrtShell->InsertPageBreak();
+
+ // Enable hide whitespace mode.
+ SwViewOption aViewOptions(*pWrtShell->GetViewOptions());
+ aViewOptions.SetHideWhitespaceMode(true);
+ pWrtShell->ApplyViewOptions(aViewOptions);
+
+ calcLayout();
+
+ // Assert that the height of the last page is larger than the height of other pages.
+ sal_Int32 nOther = parseDump("/root/page[1]/infos/bounds", "height").toInt32();
+ sal_Int32 nLast = parseDump("/root/page[2]/infos/bounds", "height").toInt32();
+ CPPUNIT_ASSERT(nLast > nOther);
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/core/layout/calcmove.cxx b/sw/source/core/layout/calcmove.cxx
index 148a953..62d5682 100644
--- a/sw/source/core/layout/calcmove.cxx
+++ b/sw/source/core/layout/calcmove.cxx
@@ -738,7 +738,8 @@ void SwPageFrm::MakeAll(vcl::RenderContext* pRenderContext)
}
assert(pAttrs);
- SwViewShell *pSh = getRootFrm()->GetCurrShell();
+ SwRootFrm* pRootFrame = getRootFrm();
+ SwViewShell* pSh = pRootFrame->GetCurrShell();
if (pSh && pSh->GetViewOptions()->getBrowseMode())
{
// In BrowseView, we use fixed settings
@@ -785,7 +786,7 @@ void SwPageFrm::MakeAll(vcl::RenderContext* pRenderContext)
mbValidSize = mbValidPrtArea = true;
continue;
}
- else if (pSh && pSh->GetViewOptions()->IsWhitespaceHidden())
+ else if (pSh && pSh->GetViewOptions()->IsWhitespaceHidden() && pRootFrame->GetLastPage() != this)
{
long height = 0;
SwLayoutFrm *pBody = FindBodyCont();
diff --git a/sw/source/core/layout/wsfrm.cxx b/sw/source/core/layout/wsfrm.cxx
index 205f704..2973033 100644
--- a/sw/source/core/layout/wsfrm.cxx
+++ b/sw/source/core/layout/wsfrm.cxx
@@ -2947,11 +2947,25 @@ void SwLayoutFrm::Format( vcl::RenderContext* /*pRenderContext*/, const SwBorder
if ( mbValidPrtArea && mbValidSize )
return;
+ bool bHideWhitespace = false;
+ if (IsPageFrm())
+ {
+ SwViewShell* pShell = getRootFrm()->GetCurrShell();
+ if (pShell && pShell->GetViewOptions()->IsWhitespaceHidden())
+ {
+ // This is needed so that no space is reserved for the margin on
+ // the last page of the document. Other pages would have no margin
+ // set even without this, as their frame height is the content
+ // height already.
+ bHideWhitespace = true;
+ }
+ }
+
const sal_uInt16 nLeft = (sal_uInt16)pAttrs->CalcLeft(this);
- const sal_uInt16 nUpper = pAttrs->CalcTop();
+ const sal_uInt16 nUpper = bHideWhitespace ? 0 : pAttrs->CalcTop();
const sal_uInt16 nRight = (sal_uInt16)pAttrs->CalcRight(this);
- const sal_uInt16 nLower = pAttrs->CalcBottom();
+ const sal_uInt16 nLower = bHideWhitespace ? 0 : pAttrs->CalcBottom();
const bool bVert = IsVertical() && !IsPageFrm();
SwRectFn fnRect = bVert ? ( IsVertLR() ? fnRectVertL2R : fnRectVert ) : fnRectHori;
commit cbf2d103a67b2a1b2a55989cca71ee99bfa4a329
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Fri Jan 8 14:56:26 2016 +0100
CppunitTest_sw_uiwriter: don't assert the size of the last page
The size of the last page will change in a bit in Hide Whitespace mode,
the intention of the test is to check the behavior of the normal
(non-last) pages.
Change-Id: I69b9072c59b6ca4dc5d93062c21726a0f5c03c05
(cherry picked from commit cd51e0153a25f3950be54dd7fd58a0de6e148ae2)
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 47924fe..64ded0d 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -1202,7 +1202,11 @@ void SwUiWriterTest::testTdf96536()
aViewOptions.SetHideWhitespaceMode(true);
pWrtShell->ApplyViewOptions(aViewOptions);
- // Insert a new paragraph at the end of the document, and then delete it.
+ // Insert a page break and go back to the first page.
+ pWrtShell->InsertPageBreak();
+ pWrtShell->SttEndDoc(/*bStt=*/true);
+
+ // Insert a new paragraph at the end of the page, and then delete it.
uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
uno::Reference<text::XParagraphAppend> xParagraphAppend(xTextDocument->getText(), uno::UNO_QUERY);
xParagraphAppend->finishParagraph(uno::Sequence<beans::PropertyValue>());
@@ -1214,7 +1218,7 @@ void SwUiWriterTest::testTdf96536()
// This was 552, page did not shrink after deleting the second paragraph.
// Expected 276, which is 12pt font size + default line spacing (15%), but
// tolerate some difference to that.
- CPPUNIT_ASSERT(parseDump("/root/infos/bounds", "height").toInt32() <= 276);
+ CPPUNIT_ASSERT(parseDump("/root/page[1]/infos/bounds", "height").toInt32() <= 276);
}
CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest);
commit 4eb1bb9ab40df27ceb1b3c386d4f70d3bca00d10
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Tue Jan 5 12:31:50 2016 +0100
CppunitTest_sw_uiwriter: tolerate lower than 276 in testTdf96536()
Seen on an OS X tinderbox from time to time, but not always.
Change-Id: Ie6796de5095a6d3b583fa8494444f4d662db8b12
(cherry picked from commit af47b54d49355a003deda722b5d0112a7b746485)
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 59ffbf2..47924fe 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -1212,8 +1212,9 @@ void SwUiWriterTest::testTdf96536()
calcLayout();
// This was 552, page did not shrink after deleting the second paragraph.
- // 276 is 12pt font size + default line spacing (15%).
- CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(276), parseDump("/root/infos/bounds", "height").toInt32());
+ // Expected 276, which is 12pt font size + default line spacing (15%), but
+ // tolerate some difference to that.
+ CPPUNIT_ASSERT(parseDump("/root/infos/bounds", "height").toInt32() <= 276);
}
CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest);
More information about the Libreoffice-commits
mailing list