[Libreoffice-commits] core.git: sw/qa writerfilter/source

Miklos Vajna vmiklos at collabora.co.uk
Fri Oct 17 01:20:16 PDT 2014


 sw/qa/extras/ooxmlexport/data/afterlines.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport.cxx      |    6 ++++++
 writerfilter/source/dmapper/DomainMapper.cxx  |   12 ++++++++----
 3 files changed, 14 insertions(+), 4 deletions(-)

New commits:
commit 9e7eb63989ef1cf4b9a0e0404b84ef890db3d8e3
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Fri Oct 17 09:59:38 2014 +0200

    DOCX import: parse <w:spacing>'s w:before/afterLines attribute
    
    Change-Id: I63b3afda5e8915b562de51aa31e420c135f919ba

diff --git a/sw/qa/extras/ooxmlexport/data/afterlines.docx b/sw/qa/extras/ooxmlexport/data/afterlines.docx
new file mode 100644
index 0000000..296f91e
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/afterlines.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 3d5d727..395c753 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -477,6 +477,12 @@ DECLARE_OOXMLEXPORT_TEST(testFdo77716, "fdo77716.docx")
     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(convertTwipToMm100(200)), getProperty<sal_Int32>(xStyle, "ParaBottomMargin"));
 }
 
+DECLARE_OOXMLEXPORT_TEST(testAfterlines, "afterlines.docx")
+{
+    // This was 353, i.e. the value of <w:spacing w:after="200"> from <w:pPrDefault>, instead of <w:spacing w:afterLines="100"/> from <w:pPr>.
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(423), getProperty<sal_Int32>(getParagraph(1), "ParaBottomMargin"));
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index e8c6e42..c7762f6 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -184,6 +184,7 @@ void DomainMapper::lcl_attribute(Id nName, Value & val)
         return;
 
     static OUString sLocalBookmarkName;
+    static const int nSingleLineSpacing = 240;
     sal_Int32 nIntValue = val.getInt();
     OUString sStringValue = val.getString();
 
@@ -370,6 +371,8 @@ void DomainMapper::lcl_attribute(Id nName, Value & val)
             break;
         case NS_ooxml::LN_CT_Spacing_beforeLines:
                 m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "beforeLines", OUString::number(nIntValue));
+                if (m_pImpl->GetTopContext())
+                    m_pImpl->GetTopContext()->Insert(PROP_PARA_TOP_MARGIN, uno::makeAny(ConversionHelper::convertTwipToMM100(nIntValue * nSingleLineSpacing / 100)), false);
             break;
         case NS_ooxml::LN_CT_Spacing_after:
             m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "after", OUString::number(nIntValue));
@@ -379,11 +382,12 @@ void DomainMapper::lcl_attribute(Id nName, Value & val)
             break;
         case NS_ooxml::LN_CT_Spacing_afterLines:
             m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "afterLines", OUString::number(nIntValue));
+            if (m_pImpl->GetTopContext())
+                m_pImpl->GetTopContext()->Insert(PROP_PARA_BOTTOM_MARGIN, uno::makeAny(ConversionHelper::convertTwipToMM100(nIntValue * nSingleLineSpacing / 100)), false);
             break;
         case NS_ooxml::LN_CT_Spacing_line: //91434
         case NS_ooxml::LN_CT_Spacing_lineRule: //91435
         {
-#define SINGLE_LINE_SPACING 240
             style::LineSpacing aSpacing;
             PropertyMapPtr pTopContext = m_pImpl->GetTopContext();
             boost::optional<PropertyMap::Property> aLineSpacingVal;
@@ -395,14 +399,14 @@ void DomainMapper::lcl_attribute(Id nName, Value & val)
             {
                 //default to single line spacing
                 aSpacing.Mode = style::LineSpacingMode::FIX;
-                aSpacing.Height = sal_Int16(ConversionHelper::convertTwipToMM100( SINGLE_LINE_SPACING ));
+                aSpacing.Height = sal_Int16(ConversionHelper::convertTwipToMM100( nSingleLineSpacing ));
             }
             if( nName == NS_ooxml::LN_CT_Spacing_line )
             {
                 m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "line", OUString::number(nIntValue));
                 //now set the value depending on the Mode
                 if( aSpacing.Mode == style::LineSpacingMode::PROP )
-                    aSpacing.Height = sal_Int16(sal_Int32(nIntValue) * 100 / SINGLE_LINE_SPACING );
+                    aSpacing.Height = sal_Int16(sal_Int32(nIntValue) * 100 / nSingleLineSpacing );
                 else
                     aSpacing.Height = sal_Int16(ConversionHelper::convertTwipToMM100( nIntValue ));
 
@@ -422,7 +426,7 @@ void DomainMapper::lcl_attribute(Id nName, Value & val)
                         m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "lineRule", "auto");
                         aSpacing.Mode = style::LineSpacingMode::PROP;
                         //reinterpret the already set value
-                        aSpacing.Height = sal_Int16( aSpacing.Height * 100 /  ConversionHelper::convertTwipToMM100( SINGLE_LINE_SPACING ));
+                        aSpacing.Height = sal_Int16( aSpacing.Height * 100 /  ConversionHelper::convertTwipToMM100( nSingleLineSpacing ));
                     }
                     else if( sal::static_int_cast<Id>(nIntValue) == NS_ooxml::LN_Value_doc_ST_LineSpacingRule_atLeast)
                     {


More information about the Libreoffice-commits mailing list