diff options
author | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2019-03-08 16:38:49 +0100 |
---|---|---|
committer | Thorsten Behrens <Thorsten.Behrens@CIB.de> | 2019-05-13 19:51:04 +0200 |
commit | a663c7beae8f0900285bd9a6c9f1dd9566522975 (patch) | |
tree | 594bd58d9d3887affc56135c722ca17a11f1b7e6 | |
parent | 6df3a7f377770eb644abc7d43e4c5011c3a4b100 (diff) |
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.
Reviewed-on: https://gerrit.libreoffice.org/68927
Tested-by: Jenkins
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
(cherry picked from commit 86567ebde2d38c44aae93064b8c102f365641f81)
Change-Id: I31df9140174c40cf4cf39891490301cbe4c5806a
-rw-r--r-- | sw/qa/extras/layout/data/tdf123898.odt | bin | 0 -> 9642 bytes | |||
-rwxr-xr-x | sw/qa/extras/layout/layout.cxx | 14 | ||||
-rw-r--r-- | sw/source/core/txtnode/txtedt.cxx | 56 |
3 files changed, 17 insertions, 53 deletions
diff --git a/sw/qa/extras/layout/data/tdf123898.odt b/sw/qa/extras/layout/data/tdf123898.odt Binary files differnew file mode 100644 index 000000000000..31800aadb18b --- /dev/null +++ b/sw/qa/extras/layout/data/tdf123898.odt diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx index b1ef14cbbad8..1e9047f855c2 100755 --- a/sw/qa/extras/layout/layout.cxx +++ b/sw/qa/extras/layout/layout.cxx @@ -33,6 +33,7 @@ public: void testTdf119875(); void testTdf116989(); void testTdf122607(); + void testTdf123898(); CPPUNIT_TEST_SUITE(SwLayoutWriter); CPPUNIT_TEST(testTdf116830); @@ -51,6 +52,7 @@ public: CPPUNIT_TEST(testTdf119875); CPPUNIT_TEST(testTdf116989); CPPUNIT_TEST(testTdf122607); + CPPUNIT_TEST(testTdf123898); CPPUNIT_TEST_SUITE_END(); private: @@ -320,6 +322,18 @@ void SwLayoutWriter::testTdf122607() "nWidth", "428"); } +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_PLUGIN_IMPLEMENT(); diff --git a/sw/source/core/txtnode/txtedt.cxx b/sw/source/core/txtnode/txtedt.cxx index 7a646fc2b8ed..7b88b14ff5b9 100644 --- a/sw/source/core/txtnode/txtedt.cxx +++ b/sw/source/core/txtnode/txtedt.cxx @@ -204,71 +204,21 @@ static SwRect lcl_CalculateRepaintRect( SwTextFrame & rTextFrame, SwTextNode & rNode, sal_Int32 const nChgStart, sal_Int32 const nChgEnd) { - SwRect aRect; - TextFrameIndex const iChgStart(rTextFrame.MapModelToView(&rNode, nChgStart)); TextFrameIndex const iChgEnd(rTextFrame.MapModelToView(&rNode, nChgEnd)); - SwPosition aPos( rNode, nChgEnd ); - SwCursorMoveState aTmpState( MV_NONE ); - aTmpState.m_b2Lines = true; - rTextFrame.GetCharRect( aRect, aPos, &aTmpState ); - // information about end of repaint area - Sw2LinesPos* pEnd2Pos = aTmpState.m_p2Lines; - - const SwTextFrame *pEndFrame = &rTextFrame; + SwRect aRect = rTextFrame.GetPaintArea(); + SwRect aTmp = rTextFrame.GetPaintArea(); - while( pEndFrame->HasFollow() && - iChgEnd >= pEndFrame->GetFollow()->GetOfst()) - pEndFrame = pEndFrame->GetFollow(); - - if ( pEnd2Pos ) - { - // 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) ); - delete pEnd2Pos; - } - - 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; while( pStartFrame->HasFollow() && iChgStart >= pStartFrame->GetFollow()->GetOfst()) pStartFrame = pStartFrame->GetFollow(); - pEndFrame = pStartFrame; + const SwTextFrame* pEndFrame = pStartFrame; while( pEndFrame->HasFollow() && iChgEnd >= pEndFrame->GetFollow()->GetOfst()) pEndFrame = pEndFrame->GetFollow(); - // information about start of repaint area - Sw2LinesPos* pSt2Pos = aTmpState.m_p2Lines; - if ( pSt2Pos ) - { - // 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) ); - delete pSt2Pos; - } - bool bSameFrame = true; if( rTextFrame.HasFollow() ) |