summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2014-10-16 11:05:03 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-10-16 11:12:04 +0200
commit3be8ff052f8aa67919343730d675493308759ffc (patch)
tree0abb7e5af06eb3a0dd6f069270da1b758fc63be7
parent9c9831f79cf0413c0cd947449bf8253fe09a224f (diff)
fdo#77716 DOCX import: fix handling of user-defined Standard style
Change-Id: I2cbd9cc0848bfb302bfa0c463a810e7f8231e47b
-rw-r--r--sw/qa/extras/ooxmlexport/data/fdo77716.docxbin0 -> 12915 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport.cxx8
-rw-r--r--writerfilter/source/dmapper/StyleSheetTable.cxx28
3 files changed, 32 insertions, 4 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/fdo77716.docx b/sw/qa/extras/ooxmlexport/data/fdo77716.docx
new file mode 100644
index 000000000000..f70679100423
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/fdo77716.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 1101e2d6765b..3d5d727027c1 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 bd408146e11b..9b3782c65fb4 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;
}