Kaydet (Commit) 6d8da2b2 authored tarafından Miklos Vajna's avatar Miklos Vajna

tdf#96943 sw Hide Whitespace: don't create pages for widow / orphan ...

... paragraphs that would otherwise fit nominal size of the page frame

Change-Id: I90c3de9150b17c951e1ac4158babb7a71afee9ee
üst e035b03a
...@@ -177,6 +177,7 @@ public: ...@@ -177,6 +177,7 @@ public:
void testTdf77014(); void testTdf77014();
void testTdf92648(); void testTdf92648();
void testTdf96515(); void testTdf96515();
void testTdf96943();
void testTdf96536(); void testTdf96536();
void testTdf96479(); void testTdf96479();
...@@ -262,6 +263,7 @@ public: ...@@ -262,6 +263,7 @@ public:
CPPUNIT_TEST(testTdf77014); CPPUNIT_TEST(testTdf77014);
CPPUNIT_TEST(testTdf92648); CPPUNIT_TEST(testTdf92648);
CPPUNIT_TEST(testTdf96515); CPPUNIT_TEST(testTdf96515);
CPPUNIT_TEST(testTdf96943);
CPPUNIT_TEST(testTdf96536); CPPUNIT_TEST(testTdf96536);
CPPUNIT_TEST(testTdf96479); CPPUNIT_TEST(testTdf96479);
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
...@@ -2945,6 +2947,23 @@ void SwUiWriterTest::testTdf96515() ...@@ -2945,6 +2947,23 @@ void SwUiWriterTest::testTdf96515()
CPPUNIT_ASSERT_EQUAL(1, getPages()); 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() void SwUiWriterTest::testTdf96536()
{ {
// Enable hide whitespace mode. // Enable hide whitespace mode.
......
...@@ -37,6 +37,10 @@ ...@@ -37,6 +37,10 @@
#include "itrtxt.hxx" #include "itrtxt.hxx"
#include "sectfrm.hxx" #include "sectfrm.hxx"
#include "ftnfrm.hxx" #include "ftnfrm.hxx"
#include "rootfrm.hxx"
#include "viewopt.hxx"
#include "pagefrm.hxx"
#include "fmtfsize.hxx"
#undef WIDOWTWIPS #undef WIDOWTWIPS
...@@ -126,8 +130,24 @@ bool SwTextFrameBreak::IsInside( SwTextMargin &rLine ) const ...@@ -126,8 +130,24 @@ bool SwTextFrameBreak::IsInside( SwTextMargin &rLine ) const
// The Frame has a height to fit on the page. // The Frame has a height to fit on the page.
SwTwips nHeight = SwTwips nHeight =
(*fnRect->fnYDiff)( (m_pFrame->GetUpper()->*fnRect->fnGetPrtBottom)(), m_nOrigin ); (*fnRect->fnYDiff)( (m_pFrame->GetUpper()->*fnRect->fnGetPrtBottom)(), m_nOrigin );
SwTwips nDiff = nHeight - nLineHeight;
SwViewShell* pShell = m_pFrame->getRootFrame()->GetCurrShell();
if (pShell && pShell->GetViewOptions()->IsWhitespaceHidden())
{
if (nDiff < 0)
{
SwPageFrame* pPageFrame = m_pFrame->FindPageFrame();
const SwFrameFormat* pPageFormat = static_cast<const SwFrameFormat*>(pPageFrame->GetRegisteredIn());
const Size& rPageSize = pPageFormat->GetFrameSize().GetSize();
long nWhitespace = rPageSize.getHeight() - pPageFrame->Frame().Height();
if (nWhitespace > -nDiff)
nDiff = 0;
}
}
// If everything is inside the existing frame the result is true; // If everything is inside the existing frame the result is true;
bFit = nHeight >= nLineHeight; bFit = nDiff >= 0;
// --> OD #i103292# // --> OD #i103292#
if ( !bFit ) if ( !bFit )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment