[Libreoffice-commits] core.git: sw/qa writerfilter/source
Miklos Vajna
vmiklos at collabora.co.uk
Thu Oct 16 02:13:22 PDT 2014
sw/qa/extras/ooxmlexport/data/fdo77716.docx |binary
sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 8 ++++++
writerfilter/source/dmapper/StyleSheetTable.cxx | 28 ++++++++++++++++++++----
3 files changed, 32 insertions(+), 4 deletions(-)
New commits:
commit 3be8ff052f8aa67919343730d675493308759ffc
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Thu Oct 16 11:05:03 2014 +0200
fdo#77716 DOCX import: fix handling of user-defined Standard style
Change-Id: I2cbd9cc0848bfb302bfa0c463a810e7f8231e47b
diff --git a/sw/qa/extras/ooxmlexport/data/fdo77716.docx b/sw/qa/extras/ooxmlexport/data/fdo77716.docx
new file mode 100644
index 0000000..f706791
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/fdo77716.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 1101e2d..3d5d727 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -469,6 +469,14 @@ DECLARE_OOXMLEXPORT_TEST(testEm, "em.docx")
CPPUNIT_ASSERT_EQUAL(text::FontEmphasis::DOT_BELOW, getProperty<sal_Int16>(getRun(getParagraph(1), 5), "CharEmphasis"));
}
+DECLARE_OOXMLEXPORT_TEST(testFdo77716, "fdo77716.docx")
+{
+ // The problem was that there should be 200 twips spacing between the two paragraphs, but there wasn't any.
+ uno::Reference<beans::XPropertySet> xStyle(getStyles("ParagraphStyles")->getByName("Standard"), uno::UNO_QUERY);
+ // This was 0.
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(convertTwipToMm100(200)), getProperty<sal_Int32>(xStyle, "ParaBottomMargin"));
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/dmapper/StyleSheetTable.cxx b/writerfilter/source/dmapper/StyleSheetTable.cxx
index bd40814..9b3782c 100644
--- a/writerfilter/source/dmapper/StyleSheetTable.cxx
+++ b/writerfilter/source/dmapper/StyleSheetTable.cxx
@@ -38,6 +38,7 @@
#include <com/sun/star/text/WritingMode.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <map>
+#include <set>
#include <stdio.h>
#include <rtl/ustrbuf.hxx>
#include <comphelper/string.hxx>
@@ -293,6 +294,8 @@ struct StyleSheetTable_Impl
PropertyMapPtr m_pDefaultParaProps, m_pDefaultCharProps;
PropertyMapPtr m_pCurrentProps;
StringPairMap_t m_aStyleNameMap;
+ /// Style names which should not be used without a " (user)" suffix.
+ std::set<OUString> m_aReservedStyleNames;
ListCharStylePropertyVector_t m_aListCharStylePropertyVector;
bool m_bIsNewDoc;
@@ -1482,14 +1485,31 @@ OUString StyleSheetTable::ConvertStyleName( const OUString& rWWName, bool bExten
{
for( sal_uInt32 nPair = 0; nPair < sizeof(aStyleNamePairs) / sizeof( sal_Char*) / 2; ++nPair)
{
- m_pImpl->m_aStyleNameMap.insert( StringPairMap_t::value_type(
- OUString::createFromAscii(aStyleNamePairs[2 * nPair]),
- OUString::createFromAscii(aStyleNamePairs[2 * nPair + 1]) ));
+ OUString aFrom = OUString::createFromAscii(aStyleNamePairs[2 * nPair]);
+ OUString aTo = OUString::createFromAscii(aStyleNamePairs[2 * nPair + 1]);
+ if (!aTo.isEmpty())
+ {
+ m_pImpl->m_aStyleNameMap.insert( StringPairMap_t::value_type(aFrom, aTo));
+ m_pImpl->m_aReservedStyleNames.insert(aTo);
+ }
}
}
StringPairMap_t::iterator aIt = m_pImpl->m_aStyleNameMap.find( sRet );
- if(aIt != m_pImpl->m_aStyleNameMap.end() && !aIt->second.isEmpty())
+ bool bConverted = false;
+ if (aIt != m_pImpl->m_aStyleNameMap.end())
+ {
+ bConverted = true;
sRet = aIt->second;
+ }
+
+ if (!bConverted)
+ {
+ // SwStyleNameMapper doc says: If the UI style name equals a
+ // programmatic name, then it must append " (user)" to the end.
+ std::set<OUString>::iterator aReservedIt = m_pImpl->m_aReservedStyleNames.find(sRet);
+ if (aReservedIt != m_pImpl->m_aReservedStyleNames.end())
+ sRet += " (user)";
+ }
return sRet;
}
More information about the Libreoffice-commits
mailing list