diff options
author | Nikhil Walvekar <nikhil.walvekar@synerzip.com> | 2013-11-01 23:25:41 +0530 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2013-11-15 17:01:35 +0100 |
commit | 68e538ea6d6b2308de7c9390116fa06cd8c02d18 (patch) | |
tree | c7a6c36f815d4e5c06617dd8105ae7ee7a5bb12d /sw | |
parent | b2a94ccdf91c9ea41fbde13ebfb5031ae76bc102 (diff) |
Resolved: Preservation of para before and after auto spacing.
During import a flag and fixed value is stored in InteropGrabBag and
during export we check for fixed value and value available in para spacing
object. Write autospacing only if para spacing values are not modified during
edit.
Reviewed on:
https://gerrit.libreoffice.org/6575
Change-Id: If34c5b61c3180b01e68dfe83862784c3d6f33981
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/para-auto-spacing.docx | bin | 0 -> 28793 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 6 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 52 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.hxx | 4 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxtablestyleexport.cxx | 10 |
5 files changed, 62 insertions, 10 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/para-auto-spacing.docx b/sw/qa/extras/ooxmlexport/data/para-auto-spacing.docx Binary files differnew file mode 100644 index 000000000000..c7604bf7672a --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/para-auto-spacing.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index 1bf422ff368c..23fe7cd53b52 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -1833,6 +1833,12 @@ DECLARE_OOXML_TEST(testFdo71646, "fdo71646.docx") CPPUNIT_ASSERT_EQUAL(text::WritingMode2::LR_TB, nLRDir); } +DECLARE_OOXML_TEST(testParaAutoSpacing, "para-auto-spacing.docx") +{ + xmlDocPtr pXmlDoc = parseExport(); + CPPUNIT_ASSERT(getXPath(pXmlDoc, "/w:document/w:body/w:p/w:pPr/w:spacing", "beforeAutospacing").match("1")); + CPPUNIT_ASSERT(getXPath(pXmlDoc, "/w:document/w:body/w:p/w:pPr/w:spacing", "afterAutospacing").match("1")); +} #endif CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 9e41119da272..6bfc91dbf243 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -5643,10 +5643,32 @@ void DocxAttributeOutput::FormatULSpace( const SvxULSpaceItem& rULSpace ) { if ( !m_pParagraphSpacingAttrList ) m_pParagraphSpacingAttrList = m_pSerializer->createAttrList(); - m_pParagraphSpacingAttrList->add( FSNS( XML_w, XML_before ), - OString::number( rULSpace.GetUpper() ) ); - m_pParagraphSpacingAttrList->add( FSNS( XML_w, XML_after ), - OString::number( rULSpace.GetLower() ) ); + SAL_INFO("sw.ww8", "DocxAttributeOutput::FormatULSpace: setting spacing" << rULSpace.GetUpper() ); + // check if before auto spacing was set during import and spacing we get from actual object is same + // that we set in import. If yes just write beforeAutoSpacing tag. + if (m_bParaBeforeAutoSpacing && m_iParaBeforeSpacing == rULSpace.GetUpper()) + { + m_pParagraphSpacingAttrList->add( FSNS( XML_w, XML_beforeAutospacing ), + "1" ); + } + else + { + m_pParagraphSpacingAttrList->add( FSNS( XML_w, XML_before ), + OString::number( rULSpace.GetUpper() ) ); + } + // check if after auto spacing was set during import and spacing we get from actual object is same + // that we set in import. If yes just write afterAutoSpacing tag. + if (m_bParaAfterAutoSpacing && m_iParaAfterSpacing == rULSpace.GetLower()) + { + m_pParagraphSpacingAttrList->add( FSNS( XML_w, XML_afterAutospacing ), + "1" ); + } + else + { + m_pParagraphSpacingAttrList->add( FSNS( XML_w, XML_after ), + OString::number( rULSpace.GetLower()) ); + } + if (rULSpace.GetContext()) m_pSerializer->singleElementNS( XML_w, XML_contextualSpacing, FSEND ); } @@ -6169,8 +6191,24 @@ void DocxAttributeOutput::ParaGrabBag(const SfxGrabBagItem& rItem) { if (i->first == "MirrorIndents") m_pSerializer->singleElementNS(XML_w, XML_mirrorIndents, FSEND); + else if (i->first == "ParaTopMarginBeforeAutoSpacing") + { + m_bParaBeforeAutoSpacing = true; + // get fixed value which was set during import + i->second >>= m_iParaBeforeSpacing; + m_iParaBeforeSpacing = MM100_TO_TWIP(m_iParaBeforeSpacing); + SAL_INFO("sw.ww8", "DocxAttributeOutput::ParaGrabBag: property =" << i->first << " : m_iParaBeforeSpacing= " << m_iParaBeforeSpacing); + } + else if (i->first == "ParaBottomMarginAfterAutoSpacing") + { + m_bParaAfterAutoSpacing = true; + // get fixed value which was set during import + i->second >>= m_iParaAfterSpacing; + m_iParaAfterSpacing = MM100_TO_TWIP(m_iParaAfterSpacing); + SAL_INFO("sw.ww8", "DocxAttributeOutput::ParaGrabBag: property =" << i->first << " : m_iParaBeforeSpacing= " << m_iParaAfterSpacing); + } else - SAL_INFO("sw.ww8", "DocxAttributeOutput::ParaGrabBag: unhandled grab bag property " << i->first); + SAL_INFO("sw.ww8", "DocxAttributeOutput::ParaGrabBag: unhandled grab bag property " << i->first ); } } @@ -6222,7 +6260,9 @@ DocxAttributeOutput::DocxAttributeOutput( DocxExport &rExport, FSHelperPtr pSeri m_nextFontId( 1 ), m_bBtLr(false), m_bFrameBtLr(false), - m_pTableStyleExport(new DocxTableStyleExport(rExport.pDoc, pSerializer)) + m_pTableStyleExport(new DocxTableStyleExport(rExport.pDoc, pSerializer)), + m_bParaBeforeAutoSpacing(false), + m_bParaAfterAutoSpacing(false) { } diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx index 1c8239b0d9e9..14b22b2ab4c5 100644 --- a/sw/source/filter/ww8/docxattributeoutput.hxx +++ b/sw/source/filter/ww8/docxattributeoutput.hxx @@ -779,6 +779,10 @@ private: PageMargins m_pageMargins; boost::shared_ptr<DocxTableStyleExport> m_pTableStyleExport; + // flag to check if auto spacing was set in original file + bool m_bParaBeforeAutoSpacing,m_bParaAfterAutoSpacing; + // store hardcoded value which was set during import. + sal_Int32 m_iParaBeforeSpacing,m_iParaAfterSpacing; public: DocxAttributeOutput( DocxExport &rExport, ::sax_fastparser::FSHelperPtr pSerializer, oox::drawingml::DrawingML* pDrawingML ); diff --git a/sw/source/filter/ww8/docxtablestyleexport.cxx b/sw/source/filter/ww8/docxtablestyleexport.cxx index 3fc7246e8ad0..af96d5f4bfa5 100644 --- a/sw/source/filter/ww8/docxtablestyleexport.cxx +++ b/sw/source/filter/ww8/docxtablestyleexport.cxx @@ -277,12 +277,14 @@ void DocxTableStyleExport::Impl::tableStylePSpacing(uno::Sequence<beans::Propert pAttributeList->add(FSNS(XML_w, XML_lineRule), OUStringToOString(rSpacing[i].Value.get<OUString>(), RTL_TEXTENCODING_UTF8).getStr()); else if (rSpacing[i].Name == "beforeLines") pAttributeList->add(FSNS(XML_w, XML_beforeLines), OUStringToOString(rSpacing[i].Value.get<OUString>(), RTL_TEXTENCODING_UTF8).getStr()); - else if (rSpacing[i].Name == "beforeAutospacing") - pAttributeList->add(FSNS(XML_w, XML_beforeAutospacing), OUStringToOString(rSpacing[i].Value.get<OUString>(), RTL_TEXTENCODING_UTF8).getStr()); + else if (rSpacing[i].Name == "ParaTopMarginBeforeAutoSpacing") + // Auto spacing will be available in grab bag only if it was set to true + pAttributeList->add(FSNS(XML_w, XML_beforeAutospacing), "1"); else if (rSpacing[i].Name == "afterLines") pAttributeList->add(FSNS(XML_w, XML_afterLines), OUStringToOString(rSpacing[i].Value.get<OUString>(), RTL_TEXTENCODING_UTF8).getStr()); - else if (rSpacing[i].Name == "afterAutospacing") - pAttributeList->add(FSNS(XML_w, XML_afterAutospacing), OUStringToOString(rSpacing[i].Value.get<OUString>(), RTL_TEXTENCODING_UTF8).getStr()); + else if (rSpacing[i].Name == "ParaBottomMarginAfterAutoSpacing") + // Auto spacing will be available in grab bag only if it was set to true + pAttributeList->add(FSNS(XML_w, XML_afterAutospacing), "1"); } sax_fastparser::XFastAttributeListRef xAttributeList(pAttributeList); m_pSerializer->singleElementNS(XML_w, XML_spacing, xAttributeList); |