sw/qa/extras/layout/data/tdf135035.docx |binary
 sw/qa/extras/layout/data/tdf135035.odt  |binary
 sw/qa/extras/layout/layout.cxx          |   19 +++++++++++++++++++
 sw/source/core/layout/fly.cxx           |    6 +++---
 4 files changed, 22 insertions(+), 3 deletions(-)

New commits:
commit d003c23abf5092d5030fdacda1efb7cb54b5a258
Author:     Attila Szűcs <szucs.atti...@nisz.hu>
AuthorDate: Fri Jul 24 09:10:41 2020 +0200
Commit:     Gabor Kelemen <kelemen.gab...@nisz.hu>
CommitDate: Wed Jan 6 13:06:24 2021 +0100

    tdf#135035 DOCX import: fix auto frame width in columns
    
    in compatibility mode FRAME_AUTOWIDTH_WITH_MORE_PARA:
    use paragraph width instead of page print area width
    for frames with multiple paragraphs anchored to columns.
    
    Co-authored-by: Tibor Nagy (NISZ)
    
    Change-Id: I73c9eff960e72ebffddfa778798918ff79a4b417
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99346
    Tested-by: László Németh <nem...@numbertext.org>
    Reviewed-by: László Németh <nem...@numbertext.org>
    (cherry picked from commit 9e44075af76822106f738855bf36f0428088336d)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108859
    Tested-by: Gabor Kelemen <kelemen.gab...@nisz.hu>
    Reviewed-by: Gabor Kelemen <kelemen.gab...@nisz.hu>

diff --git a/sw/qa/extras/layout/data/tdf135035.docx 
b/sw/qa/extras/layout/data/tdf135035.docx
new file mode 100644
index 000000000000..f314f29d2b8b
Binary files /dev/null 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
new file mode 100644
index 000000000000..479dab14c937
Binary files /dev/null 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 f3854db62f0b..fd486657a7c0 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -4356,6 +4356,25 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf124423)
     CPPUNIT_ASSERT_LESS(nPageWidth / 2, nFly1Width);
 }
 
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf135035)
+{
+    createDoc("tdf135035.docx");
+    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 nParentWidth = getXPath(pXmlDoc, "(//txt)[1]/infos/prtBounds", 
"width").toInt32();
+    CPPUNIT_ASSERT_EQUAL(nParentWidth, nFly2Width);
+    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();
+    nParentWidth = getXPath(pXmlDoc, "(//txt)[1]/infos/prtBounds", 
"width").toInt32();
+    CPPUNIT_ASSERT_LESS(nParentWidth / 2, nFly2Width);
+    CPPUNIT_ASSERT_LESS(nParentWidth / 2, nFly1Width);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx
index bf59ef5a2efb..d5366ca991b0 100644
--- a/sw/source/core/layout/fly.cxx
+++ b/sw/source/core/layout/fly.cxx
@@ -2562,11 +2562,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 
(PagePrintArea) if it contains at least 2 paragraphs.
+    // 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 SwPageFrame* pPage = pFrame->FindPageFrame();
-        return pFrame->GetUpper()->IsVertical() ? 
pPage->getFramePrintArea().Height() : pPage->getFramePrintArea().Width();
+        const SwFrame* pFrameRect = rFrame.IsFlyFrame() ? static_cast<const 
SwFlyFrame*>(&rFrame)->GetAnchorFrame() : pFrame->FindPageFrame();
+        return rFrame.IsVertical() ? pFrameRect->getFramePrintArea().Height() 
: pFrameRect->getFramePrintArea().Width();
     }
 
     while ( pFrame )
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to