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

Miklos Vajna vmiklos at collabora.co.uk
Thu Sep 25 01:41:40 PDT 2014


 sw/qa/extras/ooxmlexport/data/numbering-font.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport.cxx          |    7 +++++++
 writerfilter/source/dmapper/DomainMapper.cxx      |    9 +++++++++
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   16 +++++++++++++++-
 4 files changed, 31 insertions(+), 1 deletion(-)

New commits:
commit f5ba3098b4406ff8656f2710df8af6ca6edcddc8
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Sep 25 10:12:14 2014 +0200

    fdo#83465 writerfilter: import font of numbering
    
    Change-Id: I0afe389fa6ea8b4c701232c6ecb425d5fdcde5fe

diff --git a/sw/qa/extras/ooxmlexport/data/numbering-font.docx b/sw/qa/extras/ooxmlexport/data/numbering-font.docx
new file mode 100644
index 0000000..ccbbd9e
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/numbering-font.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index af4e9dd..0b2c78f 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -283,6 +283,13 @@ DECLARE_OOXMLEXPORT_TEST(testPositionAndRotation, "position-and-rotation.docx")
     CPPUNIT_ASSERT(xShape->getPosition().Y < 100);
 }
 
+DECLARE_OOXMLEXPORT_TEST(testNumberingFont, "numbering-font.docx")
+{
+    uno::Reference<beans::XPropertySet> xStyle(getStyles("CharacterStyles")->getByName("ListLabel 1"), uno::UNO_QUERY);
+    // This was Calibri, i.e. custom font of the numbering itself ("1.\t") was lost on import.
+    CPPUNIT_ASSERT_EQUAL(OUString("Verdana"), getProperty<OUString>(xStyle, "CharFontName"));
+}
+
 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 2fe97d9..417655e 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -306,7 +306,16 @@ void DomainMapper::lcl_attribute(Id nName, Value & val)
 
         case NS_ooxml::LN_CT_Fonts_ascii:
             if (m_pImpl->GetTopContext())
+            {
                 m_pImpl->GetTopContext()->Insert(PROP_CHAR_FONT_NAME, uno::makeAny( sStringValue ));
+                if (m_pImpl->GetTopContextType() == CONTEXT_PARAGRAPH && m_pImpl->GetTopContext()->isSet(PROP_NUMBERING_RULES))
+                {
+                    // Font of the paragraph mark should be used for the numbering as well.
+                    uno::Reference<beans::XPropertySet> xCharStyle(m_pImpl->GetCurrentNumberingCharStyle());
+                    if (xCharStyle.is())
+                        xCharStyle->setPropertyValue("CharFontName", uno::makeAny(sStringValue));
+                }
+            }
             break;
         case NS_ooxml::LN_CT_Fonts_asciiTheme:
             m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "asciiTheme", ThemeTable::getStringForTheme(nIntValue));
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index bf5a748..0259aca 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -4816,7 +4816,21 @@ uno::Reference<beans::XPropertySet> DomainMapper_Impl::GetCurrentNumberingCharSt
         sal_Int32 nListLevel = -1;
         uno::Reference<container::XIndexAccess> xLevels = GetCurrentNumberingRules(&nListLevel);
         if (!xLevels.is())
-            return xRet;
+        {
+            // In case numbering rules is not found via a style, try the direct formatting instead.
+            boost::optional<PropertyMap::Property> oProp = m_pTopContext->getProperty(PROP_NUMBERING_RULES);
+            if (oProp)
+            {
+                xLevels.set(oProp->second, uno::UNO_QUERY);
+                // Found the rules, then also try to look up our numbering level.
+                oProp = m_pTopContext->getProperty(PROP_NUMBERING_LEVEL);
+                if (oProp)
+                    oProp->second >>= nListLevel;
+            }
+
+            if (!xLevels.is())
+                return xRet;
+        }
         uno::Sequence<beans::PropertyValue> aProps;
         xLevels->getByIndex(nListLevel) >>= aProps;
         for (int i = 0; i < aProps.getLength(); ++i)


More information about the Libreoffice-commits mailing list