summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2018-05-28 21:59:27 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2018-05-29 16:31:46 +0200
commit02a924831933d964cda209897bab27c48803c891 (patch)
tree2946becf71cf3db6143dd35bf14651166d06d627
parentf78dbaad37f7b0ec08686a6aa31984ad11c631aa (diff)
tdf#117503 DOCX import: fix out of sync first/later top margin
Improve the synchronization between the first page and follow page style, so that when the DOC export invokes sw::util::IsPlausableSingleWordSection(), it recognizes that originally these were the same Word section. If they don't match up, then the exporter will insert an explicit section break, meaning we get one more page in the export result compared to the original. (cherry picked from commit b7ae863efeb082816cc4fe660527a9650d90e186) Change-Id: I336cf347698187cdede47be2659cec51e4381e85 Reviewed-on: https://gerrit.libreoffice.org/54988 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
-rw-r--r--[-rwxr-xr-x]sw/CppunitTest_sw_ooxmllinks.mk0
-rw-r--r--sw/CppunitTest_sw_ww8export2.mk34
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport6.cxx4
-rw-r--r--sw/qa/extras/ww8export/data/tdf117503.docxbin0 -> 23567 bytes
-rw-r--r--sw/qa/extras/ww8export/ww8export2.cxx7
-rw-r--r--writerfilter/source/dmapper/PropertyMap.cxx27
6 files changed, 36 insertions, 36 deletions
diff --git a/sw/CppunitTest_sw_ooxmllinks.mk b/sw/CppunitTest_sw_ooxmllinks.mk
index 78b81d4a14b4..78b81d4a14b4 100755..100644
--- a/sw/CppunitTest_sw_ooxmllinks.mk
+++ b/sw/CppunitTest_sw_ooxmllinks.mk
diff --git a/sw/CppunitTest_sw_ww8export2.mk b/sw/CppunitTest_sw_ww8export2.mk
index 5ece5d90a0a3..616347d52904 100644
--- a/sw/CppunitTest_sw_ww8export2.mk
+++ b/sw/CppunitTest_sw_ww8export2.mk
@@ -47,39 +47,7 @@ $(eval $(call gb_CppunitTest_use_sdk_api,sw_ww8export2))
$(eval $(call gb_CppunitTest_use_ure,sw_ww8export2))
$(eval $(call gb_CppunitTest_use_vcl,sw_ww8export2))
-$(eval $(call gb_CppunitTest_use_components,sw_ww8export2,\
- basic/util/sb \
- comphelper/util/comphelp \
- configmgr/source/configmgr \
- dbaccess/util/dba \
- embeddedobj/util/embobj \
- emfio/emfio \
- filter/source/config/cache/filterconfig1 \
- filter/source/storagefilterdetect/storagefd \
- forms/util/frm \
- framework/util/fwk \
- i18npool/util/i18npool \
- linguistic/source/lng \
- package/source/xstor/xstor \
- package/util/package2 \
- sax/source/expatwrap/expwrap \
- sw/util/msword \
- sw/util/sw \
- sw/util/swd \
- sfx2/util/sfx \
- svl/source/fsstor/fsstorage \
- svtools/util/svt \
- toolkit/util/tk \
- ucb/source/core/ucb1 \
- ucb/source/ucp/file/ucpfile1 \
- unotools/util/utl \
- unoxml/source/service/unoxml \
- unoxml/source/rdf/unordf \
- uui/util/uui \
- $(if $(filter DESKTOP,$(BUILD_TYPE)),xmlhelp/util/ucpchelp1) \
- vcl/vcl.common \
- xmloff/util/xo \
-))
+$(eval $(call gb_CppunitTest_use_rdb,sw_ww8export2,services))
$(eval $(call gb_CppunitTest_use_configuration,sw_ww8export2))
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx
index 099566cd8072..837111995c79 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx
@@ -454,7 +454,7 @@ DECLARE_OOXMLEXPORT_TEST(testVMLData, "TestVMLData.docx")
{
// The problem was exporter was exporting vml data for shape in w:rPr element.
// vml data should not come under w:rPr element.
- xmlDocPtr pXmlDoc = parseExport("word/header1.xml");
+ xmlDocPtr pXmlDoc = parseExport("word/header2.xml");
if (!pXmlDoc)
return;
CPPUNIT_ASSERT(getXPath(pXmlDoc, "/w:hdr/w:p/w:r/mc:AlternateContent/mc:Fallback/w:pict/v:shape", "stroked").match("f"));
@@ -464,7 +464,7 @@ DECLARE_OOXMLEXPORT_TEST(testImageData, "image_data.docx")
{
// The problem was exporter was exporting v:imagedata data for shape in w:pict as v:fill w element.
- xmlDocPtr pXmlDoc = parseExport("word/header1.xml");
+ xmlDocPtr pXmlDoc = parseExport("word/header2.xml");
if (!pXmlDoc)
return;
CPPUNIT_ASSERT(getXPath(pXmlDoc, "/w:hdr/w:p/w:r/mc:AlternateContent/mc:Fallback/w:pict/v:shape/v:imagedata", "detectmouseclick").match("t"));
diff --git a/sw/qa/extras/ww8export/data/tdf117503.docx b/sw/qa/extras/ww8export/data/tdf117503.docx
new file mode 100644
index 000000000000..f817f035b5cf
--- /dev/null
+++ b/sw/qa/extras/ww8export/data/tdf117503.docx
Binary files differ
diff --git a/sw/qa/extras/ww8export/ww8export2.cxx b/sw/qa/extras/ww8export/ww8export2.cxx
index bc9a104740bb..f7ec720bce99 100644
--- a/sw/qa/extras/ww8export/ww8export2.cxx
+++ b/sw/qa/extras/ww8export/ww8export2.cxx
@@ -814,6 +814,13 @@ DECLARE_WW8EXPORT_TEST(testTdf112118_DOC, "tdf112118.doc")
}
}
+DECLARE_WW8EXPORT_TEST(testTdf117503, "tdf117503.docx")
+{
+ // This was 3, first page + standard page styles were not merged together
+ // on export.
+ CPPUNIT_ASSERT_EQUAL(2, getPages());
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx
index f9a09b31df61..7289a744c3f4 100644
--- a/writerfilter/source/dmapper/PropertyMap.cxx
+++ b/writerfilter/source/dmapper/PropertyMap.cxx
@@ -899,7 +899,8 @@ void SectionPropertyMap::CopyLastHeaderFooter( bool bFirstPage, DomainMapper_Imp
void SectionPropertyMap::PrepareHeaderFooterProperties( bool bFirstPage )
{
- if (bFirstPage && m_bTitlePage && m_aFollowPageStyle.is())
+ bool bCopyFirstToFollow = bFirstPage && m_bTitlePage && m_aFollowPageStyle.is();
+ if (bCopyFirstToFollow)
{
// This is a first page and has a follow style, then enable the
// header/footer there as well to be consistent.
@@ -932,6 +933,13 @@ void SectionPropertyMap::PrepareHeaderFooterProperties( bool bFirstPage )
Insert( PROP_HEADER_BODY_DISTANCE, uno::makeAny( nHeaderTop - MIN_HEAD_FOOT_HEIGHT ) );// ULSpace.Top()
Insert( PROP_HEADER_HEIGHT, uno::makeAny( nHeaderTop ) );
+ if (bCopyFirstToFollow && HasHeader(/*bFirstPage=*/true))
+ {
+ m_aFollowPageStyle->setPropertyValue("HeaderDynamicSpacing",
+ getProperty(PROP_HEADER_DYNAMIC_SPACING)->second);
+ m_aFollowPageStyle->setPropertyValue("HeaderHeight",
+ getProperty(PROP_HEADER_HEIGHT)->second);
+ }
}
else
{
@@ -962,6 +970,14 @@ void SectionPropertyMap::PrepareHeaderFooterProperties( bool bFirstPage )
Insert( PROP_FOOTER_DYNAMIC_SPACING, uno::makeAny( true ) );
Insert( PROP_FOOTER_BODY_DISTANCE, uno::makeAny( nHeaderBottom - MIN_HEAD_FOOT_HEIGHT ) );
Insert( PROP_FOOTER_HEIGHT, uno::makeAny( nHeaderBottom ) );
+
+ if (bCopyFirstToFollow && HasFooter(/*bFirstPage=*/true))
+ {
+ m_aFollowPageStyle->setPropertyValue("FooterDynamicSpacing",
+ getProperty(PROP_FOOTER_DYNAMIC_SPACING)->second);
+ m_aFollowPageStyle->setPropertyValue("FooterHeight",
+ getProperty(PROP_FOOTER_HEIGHT)->second);
+ }
}
else
{
@@ -976,6 +992,15 @@ void SectionPropertyMap::PrepareHeaderFooterProperties( bool bFirstPage )
//now set the top/bottom margin for the follow page style
Insert( PROP_TOP_MARGIN, uno::makeAny( std::max<sal_Int32>(nTopMargin, 0) ) );
Insert( PROP_BOTTOM_MARGIN, uno::makeAny( std::max<sal_Int32>(nBottomMargin, 0) ) );
+
+ if (bCopyFirstToFollow)
+ {
+ if (HasHeader(/*bFirstPage=*/true))
+ m_aFollowPageStyle->setPropertyValue("TopMargin", getProperty(PROP_TOP_MARGIN)->second);
+ if (HasFooter(/*bFirstPage=*/true))
+ m_aFollowPageStyle->setPropertyValue("BottomMargin",
+ getProperty(PROP_BOTTOM_MARGIN)->second);
+ }
}
uno::Reference< beans::XPropertySet > lcl_GetRangeProperties( bool bIsFirstSection,