diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-01-07 12:30:23 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-01-07 15:35:52 +0100 |
commit | 03e9fe02ff6ffd81f9af773a8effb154838eaf83 (patch) | |
tree | 19d32201880202c9edddd966a1826b86a2eac1ea | |
parent | 9bf1a4dfadd4c10bd01f84e085c9c02158326d5b (diff) |
tdf#96943 sw Hide Whitespace: don't create pages for widow / orphan ...
... paragraphs that would otherwise fit nominal size of the page frame
(cherry picked from commit 6d8da2b2deb4be2182ca1852cec7eb38a4c654eb)
Conflicts:
sw/source/core/text/widorp.cxx
Change-Id: I90c3de9150b17c951e1ac4158babb7a71afee9ee
-rw-r--r-- | sw/qa/extras/uiwriter/data/tdf96943.odt | bin | 0 -> 8797 bytes | |||
-rw-r--r-- | sw/qa/extras/uiwriter/uiwriter.cxx | 19 | ||||
-rw-r--r-- | sw/source/core/text/widorp.cxx | 22 |
3 files changed, 40 insertions, 1 deletions
diff --git a/sw/qa/extras/uiwriter/data/tdf96943.odt b/sw/qa/extras/uiwriter/data/tdf96943.odt Binary files differnew file mode 100644 index 000000000000..1ee5b9f91ce7 --- /dev/null +++ b/sw/qa/extras/uiwriter/data/tdf96943.odt diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index ca57c28bae4a..59ffbf218276 100644 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -106,6 +106,7 @@ public: void testTdf89954(); void testTdf89720(); void testTdf96515(); + void testTdf96943(); void testTdf96536(); CPPUNIT_TEST_SUITE(SwUiWriterTest); @@ -150,6 +151,7 @@ public: CPPUNIT_TEST(testTdf89954); CPPUNIT_TEST(testTdf89720); CPPUNIT_TEST(testTdf96515); + CPPUNIT_TEST(testTdf96943); CPPUNIT_TEST(testTdf96536); CPPUNIT_TEST_SUITE_END(); @@ -1174,6 +1176,23 @@ void SwUiWriterTest::testTdf96515() CPPUNIT_ASSERT_EQUAL(1, getPages()); } +void SwUiWriterTest::testTdf96943() +{ + // Enable hide whitespace mode. + SwDoc* pDoc = createDoc("tdf96943.odt"); + SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); + SwViewOption aViewOptions(*pWrtShell->GetViewOptions()); + aViewOptions.SetHideWhitespaceMode(true); + pWrtShell->ApplyViewOptions(aViewOptions); + + // Insert a new character at the end of the document. + pWrtShell->SttEndDoc(/*bStt=*/false); + pWrtShell->Insert("d"); + + // This was 2, a new page was created for the new layout line. + CPPUNIT_ASSERT_EQUAL(1, getPages()); +} + void SwUiWriterTest::testTdf96536() { // Enable hide whitespace mode. diff --git a/sw/source/core/text/widorp.cxx b/sw/source/core/text/widorp.cxx index f526c28cb2e2..08edff18cd83 100644 --- a/sw/source/core/text/widorp.cxx +++ b/sw/source/core/text/widorp.cxx @@ -37,6 +37,10 @@ #include "itrtxt.hxx" #include "sectfrm.hxx" #include "ftnfrm.hxx" +#include "rootfrm.hxx" +#include "viewopt.hxx" +#include "pagefrm.hxx" +#include "fmtfsize.hxx" #undef WIDOWTWIPS @@ -128,8 +132,24 @@ bool SwTextFrmBreak::IsInside( SwTextMargin &rLine ) const // The Frm has a height to fit on the page. SwTwips nHeight = (*fnRect->fnYDiff)( (pFrm->GetUpper()->*fnRect->fnGetPrtBottom)(), nOrigin ); + SwTwips nDiff = nHeight - nLineHeight; + + SwViewShell* pShell = pFrm->getRootFrm()->GetCurrShell(); + if (pShell && pShell->GetViewOptions()->IsWhitespaceHidden()) + { + if (nDiff < 0) + { + SwPageFrm* pPageFrame = pFrm->FindPageFrm(); + const SwFrameFormat* pPageFormat = static_cast<const SwFrameFormat*>(pPageFrame->GetRegisteredIn()); + const Size& rPageSize = pPageFormat->GetFrmSize().GetSize(); + long nWhitespace = rPageSize.getHeight() - pPageFrame->Frm().Height(); + if (nWhitespace > -nDiff) + nDiff = 0; + } + } + // If everything is inside the existing frame the result is true; - bFit = nHeight >= nLineHeight; + bFit = nDiff >= 0; // --> OD #i103292# if ( !bFit ) |