[Libreoffice-commits] core.git: sw/qa writerfilter/source
Miklos Vajna
vmiklos at collabora.co.uk
Thu Sep 25 12:36:13 PDT 2014
sw/qa/extras/rtfexport/data/numbering-font.rtf | 22 ++++++++++++++++++++++
sw/qa/extras/rtfexport/rtfexport.cxx | 7 +++++++
writerfilter/source/dmapper/DomainMapper.cxx | 2 +-
writerfilter/source/dmapper/DomainMapper_Impl.cxx | 13 +++++++++++--
4 files changed, 41 insertions(+), 3 deletions(-)
New commits:
commit c1f8437dbed0e8b989e41a345ef7e658a6e8a4cd
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Thu Sep 25 21:29:00 2014 +0200
fdo#83465 RTF import: handle font of numbering
Change-Id: If0da6e0e34ce50bbe7dceda089b6bb81b4a63f36
diff --git a/sw/qa/extras/rtfexport/data/numbering-font.rtf b/sw/qa/extras/rtfexport/data/numbering-font.rtf
new file mode 100644
index 0000000..46fdb7e
--- /dev/null
+++ b/sw/qa/extras/rtfexport/data/numbering-font.rtf
@@ -0,0 +1,22 @@
+{\rtf1\adeflang1025\ansi\ansicpg1252\uc1\deff0\deflang1033
+{\fonttbl
+{\f0\fbidi \froman\fcharset238\fprq2 Times New Roman;}
+{\f40\fbidi \fswiss\fcharset238\fprq2 Verdana;}
+}
+{\*\listtable
+{\list\listtemplateid645944990
+{\listlevel\levelnfc0\leveljc0
+\levelfollow0\levelstartat1
+{\leveltext\'02\'00.;}
+{\levelnumbers\'01;}
+\rtlch \af0\afs18 \ltrch \fs18 \fi-360\li720\lin720 }
+{\listname ;}
+\listid1421871093}
+}
+{\*\listoverridetable
+{\listoverride\listid1421871093\listoverridecount0\ls30}
+}
+\pard\plain Before.\par
+\pard\plain \ls30\f40\fs18 First line.\par
+\pard\plain After.\par
+}
diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx
index bdcb26b..f0071cd 100644
--- a/sw/qa/extras/rtfexport/rtfexport.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport.cxx
@@ -691,6 +691,13 @@ DECLARE_RTFEXPORT_TEST(testAbi10076, "abi10076.odt")
// Just make sure that we don't crash after exporting a fully calculated layout.
}
+DECLARE_RTFEXPORT_TEST(testNumberingFont, "numbering-font.rtf")
+{
+ uno::Reference<beans::XPropertySet> xStyle(getStyles("CharacterStyles")->getByName("ListLabel 1"), uno::UNO_QUERY);
+ // This was Liberation Serif, i.e. custom font of the numbering itself ("1.\t") was lost on import.
+ CPPUNIT_ASSERT_EQUAL(OUString("Verdana"), getProperty<OUString>(xStyle, "CharFontName"));
+}
+
#endif
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index 417655e..5330076 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -308,7 +308,7 @@ void DomainMapper::lcl_attribute(Id nName, Value & val)
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))
+ if (m_pImpl->GetTopContextOfType(CONTEXT_PARAGRAPH) && m_pImpl->GetTopContextOfType(CONTEXT_PARAGRAPH)->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());
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 0259aca..471e59e 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -4817,15 +4817,24 @@ uno::Reference<beans::XPropertySet> DomainMapper_Impl::GetCurrentNumberingCharSt
uno::Reference<container::XIndexAccess> xLevels = GetCurrentNumberingRules(&nListLevel);
if (!xLevels.is())
{
+ // Looking up the paragraph context explicitly (and not just taking
+ // the top context) is necessary for RTF, where formatting of a run
+ // and of the paragraph mark is not separated.
+ PropertyMapPtr pContext = GetTopContextOfType(CONTEXT_PARAGRAPH);
+ if (!pContext)
+ 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);
+ boost::optional<PropertyMap::Property> oProp = pContext->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);
+ oProp = pContext->getProperty(PROP_NUMBERING_LEVEL);
if (oProp)
oProp->second >>= nListLevel;
+ else
+ nListLevel = 0;
}
if (!xLevels.is())
More information about the Libreoffice-commits
mailing list