Kaydet (Commit) b7ae863e authored tarafından Miklos Vajna's avatar Miklos Vajna

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.

Change-Id: I336cf347698187cdede47be2659cec51e4381e85
Reviewed-on: https://gerrit.libreoffice.org/54965Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
üst 535f3141
File mode changed from 100755 to 100644
......@@ -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))
......
......@@ -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"));
......
......@@ -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: */
......@@ -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,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment