summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAttila Szűcs <szucs.attila3@nisz.hu>2020-07-24 09:10:41 +0200
committerGabor Kelemen <kelemen.gabor2@nisz.hu>2020-09-18 08:59:40 +0200
commit0b6f91e50904f0a157c9519631978a3e3bf374ed (patch)
tree41af85b82d1ac695539f200f839c304a02564592
parenta3f1a891ba347f4035ba2925f9f05aa6f1cf9bf1 (diff)
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) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99346 Tested-by: László Németh <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org> (cherry picked from commit 9e44075af76822106f738855bf36f0428088336d) Change-Id: I73c9eff960e72ebffddfa778798918ff79a4b417 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102932 Tested-by: Gabor Kelemen <kelemen.gabor2@nisz.hu> Reviewed-by: Gabor Kelemen <kelemen.gabor2@nisz.hu>
-rw-r--r--sw/qa/extras/layout/data/tdf135035.docxbin0 -> 13527 bytes
-rw-r--r--sw/qa/extras/layout/data/tdf135035.odtbin0 -> 9070 bytes
-rw-r--r--sw/qa/extras/layout/layout.cxx19
-rw-r--r--sw/source/core/layout/fly.cxx6
4 files changed, 22 insertions, 3 deletions
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
--- /dev/null
+++ b/sw/qa/extras/layout/data/tdf135035.docx
Binary files 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
--- /dev/null
+++ b/sw/qa/extras/layout/data/tdf135035.odt
Binary files differ
diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index ade9607847de..b8272d9bc514 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -4126,6 +4126,25 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf124423)
CPPUNIT_ASSERT_LESS(nPageWidth / 2, nFly1Width);
}
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf135035)
+{
+ createDoc("tdf135035.docx");
+ xmlDocPtr 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 215e53b59dde..9f3e5192c0b2 100644
--- a/sw/source/core/layout/fly.cxx
+++ b/sw/source/core/layout/fly.cxx
@@ -2531,11 +2531,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 )