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

tdf#96515 sw Hide Whitespace: avoid creating unneeded page frames

(cherry picked from commit 2c23d4ee)

Conflicts:
	sw/qa/extras/uiwriter/uiwriter.cxx
	sw/source/core/layout/calcmove.cxx

Change-Id: I9b273543ccf2eaa87116c6e1475860e9e872c445
üst 21e52eab
......@@ -11,6 +11,7 @@
#include <com/sun/star/drawing/GraphicExportFilter.hpp>
#include <com/sun/star/i18n/TextConversionOption.hpp>
#include <com/sun/star/frame/DispatchHelper.hpp>
#include <com/sun/star/text/XParagraphAppend.hpp>
#include <swmodeltestbase.hxx>
#include <ndtxt.hxx>
#include <wrtsh.hxx>
......@@ -104,6 +105,7 @@ public:
void testDde();
void testTdf89954();
void testTdf89720();
void testTdf96515();
CPPUNIT_TEST_SUITE(SwUiWriterTest);
CPPUNIT_TEST(testReplaceForward);
......@@ -146,6 +148,7 @@ public:
CPPUNIT_TEST(testDde);
CPPUNIT_TEST(testTdf89954);
CPPUNIT_TEST(testTdf89720);
CPPUNIT_TEST(testTdf96515);
CPPUNIT_TEST_SUITE_END();
......@@ -1150,6 +1153,25 @@ void SwUiWriterTest::testTdf89720()
#endif
}
void SwUiWriterTest::testTdf96515()
{
// 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.
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();
// This was 2, a new page was created for the new paragraph.
CPPUNIT_ASSERT_EQUAL(1, getPages());
}
CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest);
CPPUNIT_PLUGIN_IMPLEMENT();
......
......@@ -1519,7 +1519,34 @@ void SwContentFrm::MakeAll(vcl::RenderContext* /*pRenderContext*/)
// Bottom(). This might happen with undersized TextFrms on the lower edge of a
// multi-column section
const long nPrtBottom = (GetUpper()->*fnRect->fnGetPrtBottom)();
const long nBottomDist = (Frm().*fnRect->fnBottomDist)( nPrtBottom );
long nBottomDist = (Frm().*fnRect->fnBottomDist)( nPrtBottom );
if (getRootFrm()->GetCurrShell()->GetViewOptions()->IsWhitespaceHidden())
{
// When whitespace is hidden, the page frame has two heights: the
// nominal (defined by the frame format), and the actual (which is
// at most the nominal height, but can be smaller in case there is
// no content for the whole page).
// The layout size is the actual one, but we want to move the
// content frame to a new page only in case it doesn't fit the
// nominal size.
if (nBottomDist < 0)
{
// Content frame doesn't fit the actual size, check if it fits the nominal one.
SwPageFrm* pPageFrame = 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 > -nBottomDist)
{
// It does: don't move it and invalidate our page frame so
// that it gets a larger height.
nBottomDist = 0;
pPageFrame->InvalidateSize();
}
}
}
if( nBottomDist >= 0 )
{
if ( bKeep && bMoveable )
......
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