summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikhil Walvekar <nikhil.walvekar@synerzip.com>2013-11-01 23:25:41 +0530
committerMiklos Vajna <vmiklos@collabora.co.uk>2013-11-15 17:01:35 +0100
commit68e538ea6d6b2308de7c9390116fa06cd8c02d18 (patch)
treec7a6c36f815d4e5c06617dd8105ae7ee7a5bb12d
parentb2a94ccdf91c9ea41fbde13ebfb5031ae76bc102 (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
-rw-r--r--sw/qa/extras/ooxmlexport/data/para-auto-spacing.docxbin0 -> 28793 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport.cxx6
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx52
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.hxx4
-rw-r--r--sw/source/filter/ww8/docxtablestyleexport.cxx10
-rw-r--r--writerfilter/source/dmapper/DomainMapper.cxx33
-rw-r--r--writerfilter/source/dmapper/PropertyIds.cxx2
-rw-r--r--writerfilter/source/dmapper/PropertyIds.hxx2
-rw-r--r--writerfilter/source/dmapper/PropertyMap.hxx1
9 files changed, 90 insertions, 20 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/para-auto-spacing.docx b/sw/qa/extras/ooxmlexport/data/para-auto-spacing.docx
new file mode 100644
index 000000000000..c7604bf7672a
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/para-auto-spacing.docx
Binary files differ
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);
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index 8a3f58976f5c..ae81ad54ef70 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -176,7 +176,7 @@ void DomainMapper::lcl_attribute(Id nName, Value & val)
OUString sStringValue = val.getString();
SectionPropertyMap * pSectionContext = m_pImpl->GetSectionContext();
-
+ PropertyMap::iterator oldPropValue;
if( nName >= NS_rtf::LN_WIDENT && nName <= NS_rtf::LN_LCBSTTBFUSSR )
m_pImpl->GetFIB().SetData( nName, nIntValue );
else
@@ -1188,18 +1188,33 @@ void DomainMapper::lcl_attribute(Id nName, Value & val)
break;
// See SwWW8ImplReader::GetParagraphAutoSpace() on why these are 100 and 280
case NS_ooxml::LN_CT_Spacing_beforeAutospacing:
- m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "beforeAutospacing", OUString::number(nIntValue));
+ {
+ sal_Int32 default_spacing = 100;
if (!m_pImpl->GetSettingsTable()->GetDoNotUseHTMLParagraphAutoSpacing())
- m_pImpl->GetTopContext()->Insert( PROP_PARA_TOP_MARGIN, uno::makeAny( ConversionHelper::convertTwipToMM100(280) ) );
- else
- m_pImpl->GetTopContext()->Insert( PROP_PARA_TOP_MARGIN, uno::makeAny( ConversionHelper::convertTwipToMM100(100) ) );
+ {
+ default_spacing = 280;
+ }
+ m_pImpl->GetTopContext()->Insert( PROP_PARA_TOP_MARGIN, uno::makeAny( ConversionHelper::convertTwipToMM100(default_spacing) ) );
+ if (nIntValue) // If auto spacing is set, then only store set value in InteropGrabBag
+ {
+ m_pImpl->GetTopContext()->Insert( PROP_PARA_TOP_MARGIN_BEFORE_AUTO_SPACING, uno::makeAny( ConversionHelper::convertTwipToMM100(default_spacing) ),true,true );
+ }
+ }
break;
case NS_ooxml::LN_CT_Spacing_afterAutospacing:
- m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "afterAutospacing", OUString::number(nIntValue));
+ {
+ sal_Int32 default_spacing = 100;
+
if (!m_pImpl->GetSettingsTable()->GetDoNotUseHTMLParagraphAutoSpacing())
- m_pImpl->GetTopContext()->Insert( PROP_PARA_BOTTOM_MARGIN, uno::makeAny( ConversionHelper::convertTwipToMM100(280) ) );
- else
- m_pImpl->GetTopContext()->Insert( PROP_PARA_BOTTOM_MARGIN, uno::makeAny( ConversionHelper::convertTwipToMM100(100) ) );
+ {
+ default_spacing = 280;
+ }
+ m_pImpl->GetTopContext()->Insert( PROP_PARA_BOTTOM_MARGIN, uno::makeAny( ConversionHelper::convertTwipToMM100(default_spacing) ) );
+ if (nIntValue) // If auto spacing is set, then only store set value in InteropGrabBag
+ {
+ m_pImpl->GetTopContext()->Insert( PROP_PARA_BOTTOM_MARGIN_AFTER_AUTO_SPACING, uno::makeAny( ConversionHelper::convertTwipToMM100(default_spacing) ),true,true );
+ }
+ }
break;
case NS_ooxml::LN_CT_SmartTagRun_uri:
case NS_ooxml::LN_CT_SmartTagRun_element:
diff --git a/writerfilter/source/dmapper/PropertyIds.cxx b/writerfilter/source/dmapper/PropertyIds.cxx
index 9cdd249472ec..b2848552308a 100644
--- a/writerfilter/source/dmapper/PropertyIds.cxx
+++ b/writerfilter/source/dmapper/PropertyIds.cxx
@@ -125,6 +125,8 @@ const OUString& PropertyNameSupplier::GetName( PropertyIds eId ) const
case PROP_PARA_FIRST_LINE_INDENT: sName = "ParaFirstLineIndent"; break;
case PROP_PARA_KEEP_TOGETHER: sName = "ParaKeepTogether"; break;
case PROP_PARA_TOP_MARGIN: sName = "ParaTopMargin"; break;
+ case PROP_PARA_TOP_MARGIN_BEFORE_AUTO_SPACING: sName = "ParaTopMarginBeforeAutoSpacing"; break;
+ case PROP_PARA_BOTTOM_MARGIN_AFTER_AUTO_SPACING: sName = "ParaBottomMarginAfterAutoSpacing"; break;
case PROP_PARA_CONTEXT_MARGIN: sName = "ParaContextMargin"; break;
case PROP_PARA_BOTTOM_MARGIN: sName = "ParaBottomMargin"; break;
case PROP_PARA_IS_HYPHENATION: sName = "ParaIsHyphenation"; break;
diff --git a/writerfilter/source/dmapper/PropertyIds.hxx b/writerfilter/source/dmapper/PropertyIds.hxx
index d6c25ffad73b..ee5045db6b3a 100644
--- a/writerfilter/source/dmapper/PropertyIds.hxx
+++ b/writerfilter/source/dmapper/PropertyIds.hxx
@@ -313,6 +313,8 @@ enum PropertyIds
,PROP_SURROUND_TEXT_WRAP_SMALL
,PROP_PARA_SHADOW_FORMAT
,PROP_FOOTNOTE_LINE_RELATIVE_WIDTH
+ ,PROP_PARA_TOP_MARGIN_BEFORE_AUTO_SPACING
+ ,PROP_PARA_BOTTOM_MARGIN_AFTER_AUTO_SPACING
};
struct PropertyNameSupplier_Impl;
class PropertyNameSupplier
diff --git a/writerfilter/source/dmapper/PropertyMap.hxx b/writerfilter/source/dmapper/PropertyMap.hxx
index 5086dfaa9e23..456a48098a10 100644
--- a/writerfilter/source/dmapper/PropertyMap.hxx
+++ b/writerfilter/source/dmapper/PropertyMap.hxx
@@ -111,7 +111,6 @@ public:
void Insert( PropertyIds eId, const ::com::sun::star::uno::Any& rAny, bool bOverwrite = true, bool bGrabBag = false );
void Insert( PropertyIds eId, const PropValue& rValue, bool bOverwrite = true );
void InsertProps(const boost::shared_ptr<PropertyMap> pMap);
-
const ::com::sun::star::uno::Reference< ::com::sun::star::text::XFootnote>& GetFootnote() const;
void SetFootnote( ::com::sun::star::uno::Reference< ::com::sun::star::text::XFootnote> xF ) { m_xFootnote = xF; }