diff options
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/tdf104713_undefinedStyles.docx | bin | 0 -> 2331 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 7 | ||||
-rw-r--r-- | writerfilter/source/dmapper/StyleSheetTable.cxx | 13 |
3 files changed, 18 insertions, 2 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf104713_undefinedStyles.docx b/sw/qa/extras/ooxmlexport/data/tdf104713_undefinedStyles.docx Binary files differnew file mode 100644 index 000000000000..5114a069351a --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/tdf104713_undefinedStyles.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index ef5857a6224e..a767a6e5955a 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -357,6 +357,13 @@ DECLARE_OOXMLEXPORT_TEST(testTdf53856_conflictingStyle, "tdf53856_conflictingSty CPPUNIT_ASSERT_EQUAL(awt::FontSlant_NONE, getProperty<awt::FontSlant>(xStyle, "CharPosture")); } +DECLARE_OOXMLEXPORT_TEST(testTdf104713_undefinedStyles, "tdf104713_undefinedStyles.docx") +{ + // Normal paragraph style was not defined, so don't replace conflicting styles + uno::Reference<beans::XPropertySet> xStyle(getStyles("ParagraphStyles")->getByName("Heading 1"), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(212), getProperty<sal_Int32>(xStyle, "ParaBottomMargin")); +} + DECLARE_OOXMLEXPORT_TEST(testDrawingmlFlipv, "drawingml-flipv.docx") { // The problem was that the shape had vertical flip only, but then we added rotation as well on export. diff --git a/writerfilter/source/dmapper/StyleSheetTable.cxx b/writerfilter/source/dmapper/StyleSheetTable.cxx index c9ef06025378..e2ee7b6c9fd0 100644 --- a/writerfilter/source/dmapper/StyleSheetTable.cxx +++ b/writerfilter/source/dmapper/StyleSheetTable.cxx @@ -267,6 +267,7 @@ struct StyleSheetTable_Impl /// Style names which should not be used without a " (user)" suffix. std::set<OUString> m_aReservedStyleNames; ListCharStylePropertyVector_t m_aListCharStylePropertyVector; + bool m_bHasImportedDefaultParaStyle; bool m_bIsNewDoc; StyleSheetTable_Impl(DomainMapper& rDMapper, uno::Reference< text::XTextDocument> const& xTextDocument, bool bIsNewDoc); @@ -289,6 +290,7 @@ StyleSheetTable_Impl::StyleSheetTable_Impl(DomainMapper& rDMapper, m_pCurrentEntry(), m_pDefaultParaProps(new PropertyMap), m_pDefaultCharProps(new PropertyMap), + m_bHasImportedDefaultParaStyle(false), m_bIsNewDoc(bIsNewDoc) { //set font height default to 10pt @@ -456,6 +458,9 @@ void StyleSheetTable::lcl_attribute(Id Name, Value & val) break; case NS_ooxml::LN_CT_Style_default: m_pImpl->m_pCurrentEntry->bIsDefaultStyle = (nIntValue != 0); + if (m_pImpl->m_pCurrentEntry->bIsDefaultStyle && m_pImpl->m_pCurrentEntry->nStyleTypeCode == STYLE_TYPE_PARA) + m_pImpl->m_bHasImportedDefaultParaStyle = true; + if (m_pImpl->m_pCurrentEntry->nStyleTypeCode != STYLE_TYPE_UNKNOWN) { beans::PropertyValue aValue; @@ -946,9 +951,13 @@ void StyleSheetTable::ApplyStyleSheets( const FontTablePtr& rFontTable ) { StyleSheetTable_Impl::SetPropertiesToDefault(xStyle); - // resolve import conflicts with built-in styles - if( pEntry->sBaseStyleIdentifier.isEmpty() && !xStyle->getParentStyle().isEmpty() ) + // resolve import conflicts with built-in styles (only if normal style has been defined) + if( m_pImpl->m_bHasImportedDefaultParaStyle + && pEntry->sBaseStyleIdentifier.isEmpty() + && !xStyle->getParentStyle().isEmpty() ) + { xStyle->setParentStyle( "Standard" ); + } } } else |