summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2018-03-26 21:52:05 +0200
committerCaolán McNamara <caolanm@redhat.com>2018-04-30 11:58:00 +0200
commit82f6da65acaf02bc3b9d6b2039a4c307d5593423 (patch)
tree9d659c4bb9fb349f2ee0dfc21ba22fefbbe5fc89
parent9e0b21e416470d826f6f27d463ba2e42bee5222d (diff)
tdf#116410 DOCX import: restrict increased object spacing to multiple shapes
This anchored object handling is just there to be bug-compatible with Word, it's not needed for the case when there is a single shape in the paragraph. (cherry picked from commit 2c4d84e93901571ead79c85aa3894ef4e10bf5af) Also: Related: tdf#115719 DOCX import: fix ignore of increased anchored obj spacing If there is only a single anchored object, then ignore only the current paragraph, not all paragraphs of the section. (cherry picked from commit 599ff05300599d4e4ce818092f18e76e738b921e) Conflicts: sw/qa/extras/ooxmlexport/ooxmlexport11.cxx Change-Id: I5e3dc4ba9a4a6f459ec6217e8974ebc2d7303bcc Reviewed-on: https://gerrit.libreoffice.org/52981 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--sw/qa/extras/ooxmlexport/data/tdf116410.docxbin0 -> 49192 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport9.cxx6
-rw-r--r--sw/qa/extras/ooxmlimport/data/tdf115719b.docxbin0 -> 16677 bytes
-rw-r--r--sw/qa/extras/ooxmlimport/ooxmlimport.cxx6
-rw-r--r--writerfilter/source/dmapper/PropertyMap.cxx4
5 files changed, 16 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf116410.docx b/sw/qa/extras/ooxmlexport/data/tdf116410.docx
new file mode 100644
index 000000000000..5352a233ed70
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf116410.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
index f5553c5b7d1d..8ffe76e77f55 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
@@ -710,6 +710,12 @@ DECLARE_OOXMLEXPORT_TEST(testTdf115719, "tdf115719.docx")
CPPUNIT_ASSERT_EQUAL(2, getPages());
}
+DECLARE_OOXMLEXPORT_TEST(testTdf116410, "tdf116410.docx")
+{
+ // Opposite of the above, was 2 pages, should be 1 page.
+ CPPUNIT_ASSERT_EQUAL(1, getPages());
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/extras/ooxmlimport/data/tdf115719b.docx b/sw/qa/extras/ooxmlimport/data/tdf115719b.docx
new file mode 100644
index 000000000000..551b9871fe60
--- /dev/null
+++ b/sw/qa/extras/ooxmlimport/data/tdf115719b.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index d84bffd0f4cf..5e915c61803f 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -348,6 +348,12 @@ xray ThisComponent.StyleFamilies.PageStyles.Default.Width
CPPUNIT_ASSERT( pos.X > width / 2 );
}
+DECLARE_OOXMLIMPORT_TEST(testTdf115719b, "tdf115719b.docx")
+{
+ // This was 0, 4th (last) paragraph had no increased spacing.
+ CPPUNIT_ASSERT(getProperty<sal_Int32>(getParagraph(4), "ParaTopMargin") > 0);
+}
+
DECLARE_OOXMLIMPORT_TEST(testN766477, "n766477.docx")
{
/*
diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx
index c00e4bfec593..8c87c2c91286 100644
--- a/writerfilter/source/dmapper/PropertyMap.cxx
+++ b/writerfilter/source/dmapper/PropertyMap.cxx
@@ -1135,6 +1135,10 @@ void SectionPropertyMap::HandleIncreasedAnchoredObjectSpacing(DomainMapper_Impl&
std::vector<AnchoredObjectInfo>& rAnchoredObjectAnchors = rDM_Impl.m_aAnchoredObjectAnchors;
for (auto& rAnchor : rAnchoredObjectAnchors)
{
+ // Ignore this paragraph when there is a single shape only.
+ if (rAnchor.m_aAnchoredObjects.size() < 2)
+ continue;
+
// Analyze the anchored objects of this paragraph, now that we know the
// page width.
sal_Int32 nShapesWidth = 0;