Kaydet (Commit) 86567ebd authored tarafından Samuel Mehrbrodt's avatar Samuel Mehrbrodt

tdf#123898 Fix frame content misaligned

Frame was correctly formatted until spellchecker comes and
calls GetCharRect which somehow reformats the frame causes the misalignment.

So instead of calling GetCharRect, just call GetPaintArea as the frame is already
formatted at this point.

Change-Id: I31df9140174c40cf4cf39891490301cbe4c5806a
Reviewed-on: https://gerrit.libreoffice.org/68927
Tested-by: Jenkins
Reviewed-by: 's avatarSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
üst 73e32aff
...@@ -71,6 +71,7 @@ public: ...@@ -71,6 +71,7 @@ public:
void testTdf115094(); void testTdf115094();
void testTdf122607(); void testTdf122607();
void testBtlrCell(); void testBtlrCell();
void testTdf123898();
CPPUNIT_TEST_SUITE(SwLayoutWriter); CPPUNIT_TEST_SUITE(SwLayoutWriter);
CPPUNIT_TEST(testRedlineFootnotes); CPPUNIT_TEST(testRedlineFootnotes);
...@@ -112,6 +113,7 @@ public: ...@@ -112,6 +113,7 @@ public:
CPPUNIT_TEST(testTdf115094); CPPUNIT_TEST(testTdf115094);
CPPUNIT_TEST(testTdf122607); CPPUNIT_TEST(testTdf122607);
CPPUNIT_TEST(testBtlrCell); CPPUNIT_TEST(testBtlrCell);
CPPUNIT_TEST(testTdf123898);
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
private: private:
...@@ -2895,6 +2897,18 @@ void SwLayoutWriter::testBtlrCell() ...@@ -2895,6 +2897,18 @@ void SwLayoutWriter::testBtlrCell()
#endif #endif
} }
void SwLayoutWriter::testTdf123898()
{
createDoc("tdf123898.odt");
// Make sure spellchecker has done its job already
Scheduler::ProcessEventsToIdle();
xmlDocPtr pXmlDoc = parseLayoutDump();
// Make sure that the arrow on the left is not there (there are 43 children if it's there)
assertXPathChildren(pXmlDoc, "/root/page/body/txt/anchored/fly/txt", 42);
}
CPPUNIT_TEST_SUITE_REGISTRATION(SwLayoutWriter); CPPUNIT_TEST_SUITE_REGISTRATION(SwLayoutWriter);
CPPUNIT_PLUGIN_IMPLEMENT(); CPPUNIT_PLUGIN_IMPLEMENT();
......
...@@ -221,71 +221,21 @@ static SwRect lcl_CalculateRepaintRect( ...@@ -221,71 +221,21 @@ static SwRect lcl_CalculateRepaintRect(
SwTextFrame & rTextFrame, SwTextNode & rNode, SwTextFrame & rTextFrame, SwTextNode & rNode,
sal_Int32 const nChgStart, sal_Int32 const nChgEnd) sal_Int32 const nChgStart, sal_Int32 const nChgEnd)
{ {
SwRect aRect;
TextFrameIndex const iChgStart(rTextFrame.MapModelToView(&rNode, nChgStart)); TextFrameIndex const iChgStart(rTextFrame.MapModelToView(&rNode, nChgStart));
TextFrameIndex const iChgEnd(rTextFrame.MapModelToView(&rNode, nChgEnd)); TextFrameIndex const iChgEnd(rTextFrame.MapModelToView(&rNode, nChgEnd));
SwPosition aPos( rNode, nChgEnd ); SwRect aRect = rTextFrame.GetPaintArea();
SwCursorMoveState aTmpState( MV_NONE ); SwRect aTmp = rTextFrame.GetPaintArea();
aTmpState.m_b2Lines = true;
rTextFrame.GetCharRect( aRect, aPos, &aTmpState );
const SwTextFrame *pEndFrame = &rTextFrame;
while( pEndFrame->HasFollow() &&
iChgEnd >= pEndFrame->GetFollow()->GetOfst())
pEndFrame = pEndFrame->GetFollow();
// information about end of repaint area
if ( aTmpState.m_p2Lines )
{
Sw2LinesPos* pEnd2Pos = aTmpState.m_p2Lines.get();
// we are inside a special portion, take left border
SwRectFnSet aRectFnSet(pEndFrame);
aRectFnSet.SetTop( aRect, aRectFnSet.GetTop(pEnd2Pos->aLine) );
if ( pEndFrame->IsRightToLeft() )
aRectFnSet.SetLeft( aRect, aRectFnSet.GetLeft(pEnd2Pos->aPortion) );
else
aRectFnSet.SetLeft( aRect, aRectFnSet.GetRight(pEnd2Pos->aPortion) );
aRectFnSet.SetWidth( aRect, 1 );
aRectFnSet.SetHeight( aRect, aRectFnSet.GetHeight(pEnd2Pos->aLine) );
aTmpState.m_p2Lines.reset();
}
aTmpState.m_p2Lines = nullptr;
SwRect aTmp;
aPos = SwPosition( rNode, nChgStart );
rTextFrame.GetCharRect( aTmp, aPos, &aTmpState );
// i63141: GetCharRect(..) could cause a formatting,
// during the formatting SwTextFrames could be joined, deleted, created...
// => we have to reinit pStartFrame and pEndFrame after the formatting
const SwTextFrame* pStartFrame = &rTextFrame; const SwTextFrame* pStartFrame = &rTextFrame;
while( pStartFrame->HasFollow() && while( pStartFrame->HasFollow() &&
iChgStart >= pStartFrame->GetFollow()->GetOfst()) iChgStart >= pStartFrame->GetFollow()->GetOfst())
pStartFrame = pStartFrame->GetFollow(); pStartFrame = pStartFrame->GetFollow();
pEndFrame = pStartFrame; const SwTextFrame* pEndFrame = pStartFrame;
while( pEndFrame->HasFollow() && while( pEndFrame->HasFollow() &&
iChgEnd >= pEndFrame->GetFollow()->GetOfst()) iChgEnd >= pEndFrame->GetFollow()->GetOfst())
pEndFrame = pEndFrame->GetFollow(); pEndFrame = pEndFrame->GetFollow();
// information about start of repaint area
if ( aTmpState.m_p2Lines )
{
Sw2LinesPos* pSt2Pos = aTmpState.m_p2Lines.get();
// we are inside a special portion, take right border
SwRectFnSet aRectFnSet(pStartFrame);
aRectFnSet.SetTop( aTmp, aRectFnSet.GetTop(pSt2Pos->aLine) );
if ( pStartFrame->IsRightToLeft() )
aRectFnSet.SetLeft( aTmp, aRectFnSet.GetRight(pSt2Pos->aPortion) );
else
aRectFnSet.SetLeft( aTmp, aRectFnSet.GetLeft(pSt2Pos->aPortion) );
aRectFnSet.SetWidth( aTmp, 1 );
aRectFnSet.SetHeight( aTmp, aRectFnSet.GetHeight(pSt2Pos->aLine) );
aTmpState.m_p2Lines.reset();
}
bool bSameFrame = true; bool bSameFrame = true;
if( rTextFrame.HasFollow() ) if( rTextFrame.HasFollow() )
......
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