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

tdf#113686 sw: handle sections when counting height of first content line

When moving back a row that has a single text frame, it should not
matter if that text frame is in a section frame or not.

The problem was that the bugdoc has a split (outer) table, the follow's
ShouldBwdMoved() returned false, as
SwTabFrame::CalcHeightOfFirstContentLine() returned USHRT_MAX, as it had
no idea how to calc the height of a text frame in a section frame.

Fix this by looking "through" the section frame, and handling "text
frame" and "text frame in section frame" the same way.

Change-Id: Ic3605a1e2d28bfaa69bf18f31cfbf1e6e681c04f
Reviewed-on: https://gerrit.libreoffice.org/44393Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
Tested-by: 's avatarJenkins <ci@libreoffice.org>
üst 9858edd6
This diff is collapsed.
...@@ -278,6 +278,7 @@ public: ...@@ -278,6 +278,7 @@ public:
void testTdf112860(); void testTdf112860();
void testTdf113287(); void testTdf113287();
void testTdf113445(); void testTdf113445();
void testTdf113686();
#endif #endif
void testLinesInSectionInTable(); void testLinesInSectionInTable();
void testParagraphOfTextRange(); void testParagraphOfTextRange();
...@@ -444,6 +445,7 @@ public: ...@@ -444,6 +445,7 @@ public:
CPPUNIT_TEST(testTdf112860); CPPUNIT_TEST(testTdf112860);
CPPUNIT_TEST(testTdf113287); CPPUNIT_TEST(testTdf113287);
CPPUNIT_TEST(testTdf113445); CPPUNIT_TEST(testTdf113445);
CPPUNIT_TEST(testTdf113686);
#endif #endif
CPPUNIT_TEST(testLinesInSectionInTable); CPPUNIT_TEST(testLinesInSectionInTable);
CPPUNIT_TEST(testParagraphOfTextRange); CPPUNIT_TEST(testParagraphOfTextRange);
...@@ -5381,6 +5383,32 @@ void SwUiWriterTest::testTdf113445() ...@@ -5381,6 +5383,32 @@ void SwUiWriterTest::testTdf113445()
CPPUNIT_ASSERT_EQUAL(nCell3Top, nCell4Top); CPPUNIT_ASSERT_EQUAL(nCell3Top, nCell4Top);
} }
void SwUiWriterTest::testTdf113686()
{
SwDoc* pDoc = createDoc("tdf113686.fodt");
xmlDocPtr pXmlDoc = parseLayoutDump();
assertXPath(pXmlDoc, "/root/page", 2);
sal_uInt32 nPage1LastNode = getXPath(pXmlDoc, "/root/page[1]/body/tab/row/cell[1]/tab/row/cell[1]/txt[last()]", "txtNodeIndex").toUInt32();
CPPUNIT_ASSERT_EQUAL(OUString("Table2:A1-P10"), pDoc->GetNodes()[nPage1LastNode]->GetTextNode()->GetText());
sal_uInt32 nPage2FirstNode = getXPath(pXmlDoc, "/root/page[2]/body/tab/row/cell[1]/section/txt[1]", "txtNodeIndex").toUInt32();
CPPUNIT_ASSERT_EQUAL(OUString("Table1:A1"), pDoc->GetNodes()[nPage2FirstNode]->GetTextNode()->GetText());
// Remove page 2.
SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
while (pWrtShell->GetCursor()->Start()->nNode.GetIndex() < nPage1LastNode)
pWrtShell->Down(/*bSelect=*/false);
pWrtShell->EndPara();
for (int i = 0; i < 3; ++i)
pWrtShell->Up(/*bSelect=*/true);
pWrtShell->DelLeft();
// Assert that the second page is removed.
discardDumpedLayout();
pXmlDoc = parseLayoutDump();
// This was still 2, content from 2nd page was not moved.
assertXPath(pXmlDoc, "/root/page", 1);
}
void SwUiWriterTest::testTableInSectionInTable() void SwUiWriterTest::testTableInSectionInTable()
{ {
// The document has a table, containing a section, containing a nested // The document has a table, containing a section, containing a nested
......
...@@ -5378,9 +5378,16 @@ static SwTwips lcl_CalcHeightOfFirstContentLine( const SwRowFrame& rSourceLine ) ...@@ -5378,9 +5378,16 @@ static SwTwips lcl_CalcHeightOfFirstContentLine( const SwRowFrame& rSourceLine )
{ {
nTmpHeight = static_cast<const SwTabFrame*>(pTmp)->CalcHeightOfFirstContentLine(); nTmpHeight = static_cast<const SwTabFrame*>(pTmp)->CalcHeightOfFirstContentLine();
} }
else if ( pTmp->IsTextFrame() ) else if (pTmp->IsTextFrame() || (pTmp->IsSctFrame() && pTmp->GetLower() && pTmp->GetLower()->IsTextFrame()))
{ {
SwTextFrame* pTextFrame = const_cast<SwTextFrame*>(static_cast<const SwTextFrame*>(pTmp)); // Section frames don't influence the size/position of text
// frames, so 'text frame' and 'text frame in section frame' is
// the same case.
SwTextFrame* pTextFrame = nullptr;
if (pTmp->IsTextFrame())
pTextFrame = const_cast<SwTextFrame*>(static_cast<const SwTextFrame*>(pTmp));
else
pTextFrame = const_cast<SwTextFrame*>(static_cast<const SwTextFrame*>(pTmp->GetLower()));
pTextFrame->GetFormatted(); pTextFrame->GetFormatted();
nTmpHeight = pTextFrame->FirstLineHeight(); nTmpHeight = pTextFrame->FirstLineHeight();
} }
......
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