Kaydet (Commit) 72f00672 authored tarafından Miklos Vajna's avatar Miklos Vajna

tdf#96536 sw Hide Whitespace: shrink oversized page frames on para delete

The body frame did get a request to shrink, but because it had fixed
size, nothing happened. Trigger a recalc that does the right thing wrt.
hidden whitespace.

Change-Id: I446978da8b33372c2ab30200b45b1bcec1dea7a0
üst 97361478
...@@ -177,6 +177,7 @@ public: ...@@ -177,6 +177,7 @@ public:
void testTdf77014(); void testTdf77014();
void testTdf92648(); void testTdf92648();
void testTdf96515(); void testTdf96515();
void testTdf96536();
CPPUNIT_TEST_SUITE(SwUiWriterTest); CPPUNIT_TEST_SUITE(SwUiWriterTest);
CPPUNIT_TEST(testReplaceForward); CPPUNIT_TEST(testReplaceForward);
...@@ -260,6 +261,7 @@ public: ...@@ -260,6 +261,7 @@ public:
CPPUNIT_TEST(testTdf77014); CPPUNIT_TEST(testTdf77014);
CPPUNIT_TEST(testTdf92648); CPPUNIT_TEST(testTdf92648);
CPPUNIT_TEST(testTdf96515); CPPUNIT_TEST(testTdf96515);
CPPUNIT_TEST(testTdf96536);
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
private: private:
...@@ -2941,6 +2943,29 @@ void SwUiWriterTest::testTdf96515() ...@@ -2941,6 +2943,29 @@ void SwUiWriterTest::testTdf96515()
CPPUNIT_ASSERT_EQUAL(1, getPages()); CPPUNIT_ASSERT_EQUAL(1, getPages());
} }
void SwUiWriterTest::testTdf96536()
{
// Enable hide whitespace mode.
SwDoc* pDoc = createDoc();
SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
SwViewOption aViewOptions(*pWrtShell->GetViewOptions());
aViewOptions.SetHideWhitespaceMode(true);
pWrtShell->ApplyViewOptions(aViewOptions);
// Insert a new paragraph at the end of the document, 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>());
calcLayout();
uno::Reference<lang::XComponent> xParagraph(getParagraph(2), uno::UNO_QUERY);
xParagraph->dispose();
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());
}
CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest); CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest);
CPPUNIT_PLUGIN_IMPLEMENT(); CPPUNIT_PLUGIN_IMPLEMENT();
......
...@@ -1522,7 +1522,8 @@ void SwContentFrame::MakeAll(vcl::RenderContext* /*pRenderContext*/) ...@@ -1522,7 +1522,8 @@ void SwContentFrame::MakeAll(vcl::RenderContext* /*pRenderContext*/)
const long nPrtBottom = (GetUpper()->*fnRect->fnGetPrtBottom)(); const long nPrtBottom = (GetUpper()->*fnRect->fnGetPrtBottom)();
long nBottomDist = (Frame().*fnRect->fnBottomDist)(nPrtBottom); long nBottomDist = (Frame().*fnRect->fnBottomDist)(nPrtBottom);
if (getRootFrame()->GetCurrShell()->GetViewOptions()->IsWhitespaceHidden()) SwViewShell* pShell = getRootFrame()->GetCurrShell();
if (pShell && pShell->GetViewOptions()->IsWhitespaceHidden())
{ {
// When whitespace is hidden, the page frame has two heights: the // When whitespace is hidden, the page frame has two heights: the
// nominal (defined by the frame format), and the actual (which is // nominal (defined by the frame format), and the actual (which is
......
...@@ -2358,6 +2358,21 @@ SwTwips SwLayoutFrame::ShrinkFrame( SwTwips nDist, bool bTst, bool bInfo ) ...@@ -2358,6 +2358,21 @@ SwTwips SwLayoutFrame::ShrinkFrame( SwTwips nDist, bool bTst, bool bInfo )
const SwViewShell *pSh = getRootFrame()->GetCurrShell(); const SwViewShell *pSh = getRootFrame()->GetCurrShell();
const bool bBrowse = pSh && pSh->GetViewOptions()->getBrowseMode(); const bool bBrowse = pSh && pSh->GetViewOptions()->getBrowseMode();
const sal_uInt16 nTmpType = bBrowse ? 0x2084: 0x2004; //Row+Cell, Browse by Body. const sal_uInt16 nTmpType = bBrowse ? 0x2084: 0x2004; //Row+Cell, Browse by Body.
if (pSh && pSh->GetViewOptions()->IsWhitespaceHidden())
{
if (IsBodyFrame())
{
// Whitespace is hidden and this body frame will not shrink, as it
// has a fix size.
// Invalidate the page frame size, so in case the reason for the
// shrink was that there is more whitespace on this page, the size
// without whitespace will be recalculated correctly.
SwPageFrame* pPageFrame = FindPageFrame();
pPageFrame->InvalidateSize();
}
}
if( !(GetType() & nTmpType) && HasFixSize() ) if( !(GetType() & nTmpType) && HasFixSize() )
return 0; return 0;
......
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