sw/qa/extras/layout/data/tdf135035.docx |binary sw/qa/extras/layout/data/tdf135035.odt |binary sw/qa/extras/layout/layout.cxx | 4 ++++ sw/source/core/layout/fly.cxx | 20 ++++++++++++++------ 4 files changed, 18 insertions(+), 6 deletions(-)
New commits: commit 25302321097afbde034196f1b6b00892fafbee1b Author: Attila Szűcs <szucs.atti...@nisz.hu> AuthorDate: Mon Sep 14 14:16:27 2020 +0200 Commit: László Németh <nem...@numbertext.org> CommitDate: Fri Sep 18 13:47:29 2020 +0200 tdf#135035 DOCX import: fix auto width of frame in column In compatibility mode FRAME_AUTOWIDTH_WITH_MORE_PARA no frames should be wider as the column it is anchored to, if the frame width is set to automatic. If there is a paragraph in the frame, that is longer then the parent width of frame, then the frame width will be set to the same size as its parents width. Co-authored-by: Tibor Nagy (NISZ) Change-Id: Ie5e7e94fd58219eb944ad9163b1ff2c1e7171858 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102671 Tested-by: László Németh <nem...@numbertext.org> Reviewed-by: László Németh <nem...@numbertext.org> diff --git a/sw/qa/extras/layout/data/tdf135035.docx b/sw/qa/extras/layout/data/tdf135035.docx index f314f29d2b8b..acd7b1493899 100644 Binary files a/sw/qa/extras/layout/data/tdf135035.docx and b/sw/qa/extras/layout/data/tdf135035.docx differ diff --git a/sw/qa/extras/layout/data/tdf135035.odt b/sw/qa/extras/layout/data/tdf135035.odt index 479dab14c937..bf84ec4457ee 100644 Binary files a/sw/qa/extras/layout/data/tdf135035.odt and b/sw/qa/extras/layout/data/tdf135035.odt differ diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx index 008419887c75..5c7bfdab7ab3 100644 --- a/sw/qa/extras/layout/layout.cxx +++ b/sw/qa/extras/layout/layout.cxx @@ -4425,17 +4425,21 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf135035) xmlDocUniquePtr pXmlDoc = parseLayoutDump(); sal_Int32 nFly1Width = getXPath(pXmlDoc, "(//fly)[1]/infos/prtBounds", "width").toInt32(); sal_Int32 nFly2Width = getXPath(pXmlDoc, "(//fly)[2]/infos/prtBounds", "width").toInt32(); + sal_Int32 nFly3Width = getXPath(pXmlDoc, "(//fly)[3]/infos/prtBounds", "width").toInt32(); sal_Int32 nParentWidth = getXPath(pXmlDoc, "(//txt)[1]/infos/prtBounds", "width").toInt32(); CPPUNIT_ASSERT_EQUAL(nParentWidth, nFly2Width); + CPPUNIT_ASSERT_EQUAL(nParentWidth, nFly3Width); CPPUNIT_ASSERT_LESS(nParentWidth / 2, nFly1Width); createDoc("tdf135035.odt"); pXmlDoc = parseLayoutDump(); nFly1Width = getXPath(pXmlDoc, "(//fly)[1]/infos/prtBounds", "width").toInt32(); nFly2Width = getXPath(pXmlDoc, "(//fly)[2]/infos/prtBounds", "width").toInt32(); + nFly3Width = getXPath(pXmlDoc, "(//fly)[3]/infos/prtBounds", "width").toInt32(); nParentWidth = getXPath(pXmlDoc, "(//txt)[1]/infos/prtBounds", "width").toInt32(); CPPUNIT_ASSERT_LESS(nParentWidth / 2, nFly2Width); CPPUNIT_ASSERT_LESS(nParentWidth / 2, nFly1Width); + CPPUNIT_ASSERT_GREATER(nParentWidth, nFly3Width); } CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx index 3757529b3cdd..5da3f7ec7f94 100644 --- a/sw/source/core/layout/fly.cxx +++ b/sw/source/core/layout/fly.cxx @@ -2517,15 +2517,11 @@ static SwTwips lcl_CalcAutoWidth( const SwLayoutFrame& rFrame ) // No autowidth defined for columned frames if ( !pFrame || pFrame->IsColumnFrame() ) return nRet; - // tdf#124423 In Microsoft compatibility mode: widen the frame to max (PrintArea of the frame it anchored to) if it contains at least 2 paragraphs. - if (rFrame.GetFormat()->getIDocumentSettingAccess().get(DocumentSettingId::FRAME_AUTOWIDTH_WITH_MORE_PARA) && pFrame && pFrame->GetNext()) - { - const SwFrame* pFrameRect = rFrame.IsFlyFrame() ? static_cast<const SwFlyFrame*>(&rFrame)->GetAnchorFrame() : pFrame->FindPageFrame(); - return rFrame.IsVertical() ? pFrameRect->getFramePrintArea().Height() : pFrameRect->getFramePrintArea().Width(); - } + int nParagraphCount = 0; while ( pFrame ) { + nParagraphCount++; if ( pFrame->IsSctFrame() ) { nMin = lcl_CalcAutoWidth( *static_cast<const SwSectionFrame*>(pFrame) ); @@ -2562,6 +2558,18 @@ static SwTwips lcl_CalcAutoWidth( const SwLayoutFrame& rFrame ) pFrame = pFrame->GetNext(); } + // tdf#124423 In Microsoft compatibility mode: widen the frame to max (PrintArea of the frame it anchored to) if it contains at least 2 paragraphs, + // or 1 paragraph wider then its parent area. + if (rFrame.GetFormat()->getIDocumentSettingAccess().get(DocumentSettingId::FRAME_AUTOWIDTH_WITH_MORE_PARA)) + { + const SwFrame* pFrameRect = rFrame.IsFlyFrame() ? static_cast<const SwFlyFrame*>(&rFrame)->GetAnchorFrame() : rFrame.Lower()->FindPageFrame(); + SwTwips nParentWidth = rFrame.IsVertical() ? pFrameRect->getFramePrintArea().Height() : pFrameRect->getFramePrintArea().Width(); + if (nParagraphCount > 1 || nRet > nParentWidth) + { + return nParentWidth; + } + } + return nRet; } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits