[Libreoffice-commits] .: 2 commits - writerfilter/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Thu Aug 23 08:35:12 PDT 2012


 writerfilter/source/dmapper/DomainMapper.cxx      |   41 ++++++----------------
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   31 ++++++++++++++++
 writerfilter/source/dmapper/DomainMapper_Impl.hxx |    3 +
 3 files changed, 47 insertions(+), 28 deletions(-)

New commits:
commit 5fd1516f82adf0330411adf90bee7e14cec856d5
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Thu Aug 23 17:32:05 2012 +0200

    refactor duplicated code to DomainMapper_Impl::getCurrentNumberingProperty
    
    Change-Id: Id68df67e1301d0eed74c3bdcaabc7c601d72770b

diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index 205f586..4866e2d 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -1037,35 +1037,8 @@ void DomainMapper::lcl_attribute(Id nName, Value & val)
             {
                 // Word inherits FirstLineIndent property of the numbering, even if ParaLeftMargin is set, Writer does not.
                 // So copy it explicitly, if necessary.
-                PropertyMapPtr pContext = m_pImpl->GetTopContext();
-                sal_Int32 nFirstLineIndent = 0;
-
-                // See if we have a FirstLineIndent
-                PropertyMap::iterator it = pContext->find(PropertyDefinition( PROP_NUMBERING_RULES, true ) );
-                uno::Reference<container::XIndexAccess> xNumberingRules;
-                if (it != pContext->end())
-                    xNumberingRules.set(it->second, uno::UNO_QUERY);
-                it = pContext->find(PropertyDefinition( PROP_NUMBERING_LEVEL, true ) );
-                sal_Int32 nNumberingLevel = -1;
-                if (it != pContext->end())
-                    it->second >>= nNumberingLevel;
-                if (xNumberingRules.is() && nNumberingLevel != -1)
-                {
-                    uno::Sequence<beans::PropertyValue> aProps;
-                    xNumberingRules->getByIndex(nNumberingLevel) >>= aProps;
-                    for (int i = 0; i < aProps.getLength(); ++i)
-                    {
-                        const beans::PropertyValue& rProp = aProps[i];
+                sal_Int32 nFirstLineIndent = m_pImpl->getCurrentNumberingProperty("FirstLineIndent");
 
-                        if (rProp.Name == "FirstLineIndent")
-                        {
-                            rProp.Value >>= nFirstLineIndent;
-                            break;
-                        }
-                    }
-                }
-
-                // Then copy it over.
                 if (nFirstLineIndent != 0)
                     m_pImpl->GetTopContext()->Insert(PROP_PARA_FIRST_LINE_INDENT, true, uno::makeAny(nFirstLineIndent));
 
@@ -1079,39 +1052,9 @@ void DomainMapper::lcl_attribute(Id nName, Value & val)
             {
                 // Word inherits FirstLineIndent/ParaLeftMargin property of the numbering, even if ParaRightMargin is set, Writer does not.
                 // So copy it explicitly, if necessary.
-                PropertyMapPtr pContext = m_pImpl->GetTopContext();
-                sal_Int32 nFirstLineIndent = 0;
-                sal_Int32 nParaLeftMargin = 0;
-
-                // See if we have a FirstLineIndent / ParaLeftMargin
-                PropertyMap::iterator it = pContext->find(PropertyDefinition( PROP_NUMBERING_RULES, true ) );
-                uno::Reference<container::XIndexAccess> xNumberingRules;
-                if (it != pContext->end())
-                    xNumberingRules.set(it->second, uno::UNO_QUERY);
-                it = pContext->find(PropertyDefinition( PROP_NUMBERING_LEVEL, true ) );
-                sal_Int32 nNumberingLevel = -1;
-                if (it != pContext->end())
-                    it->second >>= nNumberingLevel;
-                if (xNumberingRules.is() && nNumberingLevel != -1)
-                {
-                    uno::Sequence<beans::PropertyValue> aProps;
-                    xNumberingRules->getByIndex(nNumberingLevel) >>= aProps;
-                    for (int i = 0; i < aProps.getLength(); ++i)
-                    {
-                        const beans::PropertyValue& rProp = aProps[i];
-
-                        if (rProp.Name == "FirstLineIndent")
-                        {
-                            rProp.Value >>= nFirstLineIndent;
-                        }
-                        else if (rProp.Name == "IndentAt")
-                        {
-                            rProp.Value >>= nParaLeftMargin;
-                        }
-                    }
-                }
+                sal_Int32 nFirstLineIndent = m_pImpl->getCurrentNumberingProperty("FirstLineIndent");
+                sal_Int32 nParaLeftMargin = m_pImpl->getCurrentNumberingProperty("IndentAt");
 
-                // Then copy it over.
                 if (nFirstLineIndent != 0)
                     m_pImpl->GetTopContext()->Insert(PROP_PARA_FIRST_LINE_INDENT, true, uno::makeAny(nFirstLineIndent));
                 if (nParaLeftMargin != 0)
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 8bc7926..18e8c45 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -3747,6 +3747,37 @@ void DomainMapper_Impl::processDeferredCharacterProperties()
     }
 }
 
+sal_Int32 DomainMapper_Impl::getCurrentNumberingProperty(OUString aProp)
+{
+    sal_Int32 nRet = 0;
+
+    PropertyMap::iterator it = m_pTopContext->find(PropertyDefinition( PROP_NUMBERING_RULES, true ) );
+    uno::Reference<container::XIndexAccess> xNumberingRules;
+    if (it != m_pTopContext->end())
+        xNumberingRules.set(it->second, uno::UNO_QUERY);
+    it = m_pTopContext->find(PropertyDefinition( PROP_NUMBERING_LEVEL, true ) );
+    sal_Int32 nNumberingLevel = -1;
+    if (it != m_pTopContext->end())
+        it->second >>= nNumberingLevel;
+    if (xNumberingRules.is() && nNumberingLevel != -1)
+    {
+        uno::Sequence<beans::PropertyValue> aProps;
+        xNumberingRules->getByIndex(nNumberingLevel) >>= aProps;
+        for (int i = 0; i < aProps.getLength(); ++i)
+        {
+            const beans::PropertyValue& rProp = aProps[i];
+
+            if (rProp.Name == aProp)
+            {
+                rProp.Value >>= nRet;
+                break;
+            }
+        }
+    }
+
+    return nRet;
+}
+
 }}
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
index abe5ef4..55de1d4 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
@@ -643,6 +643,9 @@ public:
      CONTEXT_CHARACTER is going to be used (e.g. by appendText()).
     */
     void processDeferredCharacterProperties();
+
+    /// Get a property of the current numbering style's current level.
+    sal_Int32 getCurrentNumberingProperty(OUString aProp);
 };
 } //namespace dmapper
 } //namespace writerfilter
commit 25af4f283fd9e8520a17350fd5e980ba9eb67f24
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Thu Aug 23 17:10:41 2012 +0200

    n#775906 dmapper: fix inherited first/left margin vs w:ind/w:right
    
    This is similar to 89f208c, but here the direct right margin reset the
    left/first margin, inherited from the numbering style.
    
    Change-Id: I2d238740c24db7607719dcefb17565656592be44

diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index c4c03fa..205f586 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -1076,8 +1076,50 @@ void DomainMapper::lcl_attribute(Id nName, Value & val)
         case NS_ooxml::LN_CT_Ind_end:
         case NS_ooxml::LN_CT_Ind_right:
             if (m_pImpl->GetTopContext())
+            {
+                // Word inherits FirstLineIndent/ParaLeftMargin property of the numbering, even if ParaRightMargin is set, Writer does not.
+                // So copy it explicitly, if necessary.
+                PropertyMapPtr pContext = m_pImpl->GetTopContext();
+                sal_Int32 nFirstLineIndent = 0;
+                sal_Int32 nParaLeftMargin = 0;
+
+                // See if we have a FirstLineIndent / ParaLeftMargin
+                PropertyMap::iterator it = pContext->find(PropertyDefinition( PROP_NUMBERING_RULES, true ) );
+                uno::Reference<container::XIndexAccess> xNumberingRules;
+                if (it != pContext->end())
+                    xNumberingRules.set(it->second, uno::UNO_QUERY);
+                it = pContext->find(PropertyDefinition( PROP_NUMBERING_LEVEL, true ) );
+                sal_Int32 nNumberingLevel = -1;
+                if (it != pContext->end())
+                    it->second >>= nNumberingLevel;
+                if (xNumberingRules.is() && nNumberingLevel != -1)
+                {
+                    uno::Sequence<beans::PropertyValue> aProps;
+                    xNumberingRules->getByIndex(nNumberingLevel) >>= aProps;
+                    for (int i = 0; i < aProps.getLength(); ++i)
+                    {
+                        const beans::PropertyValue& rProp = aProps[i];
+
+                        if (rProp.Name == "FirstLineIndent")
+                        {
+                            rProp.Value >>= nFirstLineIndent;
+                        }
+                        else if (rProp.Name == "IndentAt")
+                        {
+                            rProp.Value >>= nParaLeftMargin;
+                        }
+                    }
+                }
+
+                // Then copy it over.
+                if (nFirstLineIndent != 0)
+                    m_pImpl->GetTopContext()->Insert(PROP_PARA_FIRST_LINE_INDENT, true, uno::makeAny(nFirstLineIndent));
+                if (nParaLeftMargin != 0)
+                    m_pImpl->GetTopContext()->Insert(PROP_PARA_LEFT_MARGIN, true, uno::makeAny(nParaLeftMargin));
+
                 m_pImpl->GetTopContext()->Insert(
                     PROP_PARA_RIGHT_MARGIN, true, uno::makeAny( ConversionHelper::convertTwipToMM100(nIntValue ) ));
+            }
             break;
         case NS_ooxml::LN_CT_Ind_hanging:
             if (m_pImpl->GetTopContext())


More information about the Libreoffice-commits mailing list