sw/qa/extras/ooxmlexport/ooxmlexport5.cxx | 2 +- sw/qa/extras/ooxmlimport/data/tdf95213.docx |binary sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 14 ++++++++++++++ writerfilter/source/dmapper/DomainMapper.cxx | 4 ++-- writerfilter/source/dmapper/DomainMapper.hxx | 2 +- writerfilter/source/dmapper/NumberingManager.cxx | 2 +- writerfilter/source/dmapper/StyleSheetTable.cxx | 5 +++-- writerfilter/source/dmapper/StyleSheetTable.hxx | 2 +- 8 files changed, 23 insertions(+), 8 deletions(-)
New commits: commit af55185eb9ffcf903bba22cad736797162a7eb4d Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Thu Jan 7 08:19:17 2016 +0100 tdf#95213 DOCX import: don't reuse list label styles We used to optimize the creation of these styles, so in case two list label had the same character properties, then we could avoid creating two styles for those. This isn't correct though: it means if the style is changed later by the user, then unexpected other places in the document will change as well. Do what the binary DOC filter does: create one character style for each level of a numbering separately. (cherry picked from commit f9c8d97d82a85b897520a2fe897352ee5ad879d9) Conflicts: sw/qa/extras/ooxmlimport/ooxmlimport.cxx writerfilter/source/dmapper/DomainMapper.cxx writerfilter/source/dmapper/DomainMapper_Impl.cxx writerfilter/source/dmapper/NumberingManager.cxx Change-Id: I967b30fc078b1be30f7ef81b2706df2962fc3fb0 Reviewed-on: https://gerrit.libreoffice.org/21437 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Michael Stahl <mst...@redhat.com> diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx index c709513..7f1472f 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx @@ -460,7 +460,7 @@ DECLARE_OOXMLEXPORT_TEST(testfdo76934, "fdo76934.docx") return; // Ensure that after fix LO is preserving AutoSpacing property in styles.xml - assertXPath ( pXmlDoc, "/w:styles[1]/w:style[36]/w:pPr[1]/w:spacing[1]", "beforeAutospacing", "1" ); + assertXPath ( pXmlDoc, "/w:styles[1]/w:style[@w:styleId='Title']/w:pPr[1]/w:spacing[1]", "beforeAutospacing", "1" ); } DECLARE_OOXMLEXPORT_TEST(testfdo79540, "fdo79540.docx") diff --git a/sw/qa/extras/ooxmlimport/data/tdf95213.docx b/sw/qa/extras/ooxmlimport/data/tdf95213.docx new file mode 100644 index 0000000..831d543 Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/tdf95213.docx differ diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx index 17849e3..a83d683 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx @@ -2875,6 +2875,20 @@ DECLARE_OOXMLIMPORT_TEST(testTdf92045, "tdf92045.docx") CPPUNIT_ASSERT_EQUAL(false, getProperty<bool>(getRun(getParagraph(1), 1), "CharFlash")); } +DECLARE_OOXMLIMPORT_TEST(testTdf95213, "tdf95213.docx") +{ + // Get the second paragraph's numbering style's 2nd level's character style name. + uno::Reference<text::XTextRange> xParagraph = getParagraph(2); + auto xLevels = getProperty< uno::Reference<container::XIndexAccess> >(xParagraph, "NumberingRules"); + uno::Sequence<beans::PropertyValue> aLevel; + xLevels->getByIndex(1) >>= aLevel; // 2nd level + OUString aName = std::find_if(aLevel.begin(), aLevel.end(), [](const beans::PropertyValue& rValue) { return rValue.Name == "CharStyleName"; })->Value.get<OUString>(); + + uno::Reference<beans::XPropertySet> xStyle(getStyles("CharacterStyles")->getByName(aName), uno::UNO_QUERY); + // This was awt::FontWeight::BOLD. + CPPUNIT_ASSERT_EQUAL(awt::FontWeight::NORMAL, getProperty<float>(xStyle, "CharWeight")); +} + #endif CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx index 973151e..76db497 100644 --- a/writerfilter/source/dmapper/DomainMapper.cxx +++ b/writerfilter/source/dmapper/DomainMapper.cxx @@ -3426,10 +3426,10 @@ uno::Reference< text::XTextRange > DomainMapper::GetCurrentTextRange() return m_pImpl->GetTopTextAppend()->getEnd(); } -OUString DomainMapper::getOrCreateCharStyle( PropertyValueVector_t& rCharProperties ) +OUString DomainMapper::getOrCreateCharStyle( PropertyValueVector_t& rCharProperties, bool bAlwaysCreate ) { StyleSheetTablePtr pStyleSheets = m_pImpl->GetStyleSheetTable(); - return pStyleSheets->getOrCreateCharStyle( rCharProperties ); + return pStyleSheets->getOrCreateCharStyle( rCharProperties, bAlwaysCreate ); } StyleSheetTablePtr DomainMapper::GetStyleSheetTable( ) diff --git a/writerfilter/source/dmapper/DomainMapper.hxx b/writerfilter/source/dmapper/DomainMapper.hxx index 37a7d9e..772695a 100644 --- a/writerfilter/source/dmapper/DomainMapper.hxx +++ b/writerfilter/source/dmapper/DomainMapper.hxx @@ -106,7 +106,7 @@ public: void AddListIDToLFOTable( sal_Int32 nAbstractNumId ); css::uno::Reference<css::text::XTextRange> GetCurrentTextRange(); - OUString getOrCreateCharStyle( PropertyValueVector_t& rCharProperties ); + OUString getOrCreateCharStyle( PropertyValueVector_t& rCharProperties, bool bAlwaysCreate ); std::shared_ptr< StyleSheetTable > GetStyleSheetTable( ); GraphicZOrderHelper* graphicZOrderHelper(); diff --git a/writerfilter/source/dmapper/NumberingManager.cxx b/writerfilter/source/dmapper/NumberingManager.cxx index e9b8a46..200ddce 100644 --- a/writerfilter/source/dmapper/NumberingManager.cxx +++ b/writerfilter/source/dmapper/NumberingManager.cxx @@ -601,7 +601,7 @@ void ListDef::CreateNumberingRules( DomainMapper& rDMapper, //create (or find) a character style containing the character // attributes of the symbol and apply it to the numbering level - OUString sStyle = rDMapper.getOrCreateCharStyle( aStyleProps ); + OUString sStyle = rDMapper.getOrCreateCharStyle( aStyleProps, /*bAlwaysCreate=*/true ); aLvlProps.realloc( aLvlProps.getLength() + 1); aLvlProps[sal::static_int_cast<sal_uInt32>(aLvlProps.getLength()) - 1].Name = aPropNameSupplier.GetName( PROP_CHAR_STYLE_NAME ); aLvlProps[sal::static_int_cast<sal_uInt32>(aLvlProps.getLength()) - 1].Value <<= sStyle; diff --git a/writerfilter/source/dmapper/StyleSheetTable.cxx b/writerfilter/source/dmapper/StyleSheetTable.cxx index e95e755..f7e632d 100644 --- a/writerfilter/source/dmapper/StyleSheetTable.cxx +++ b/writerfilter/source/dmapper/StyleSheetTable.cxx @@ -1549,11 +1549,12 @@ void StyleSheetTable::applyDefaults(bool bParaProperties) } -OUString StyleSheetTable::getOrCreateCharStyle( PropertyValueVector_t& rCharProperties ) +OUString StyleSheetTable::getOrCreateCharStyle( PropertyValueVector_t& rCharProperties, bool bAlwaysCreate ) { //find out if any of the styles already has the required properties then return its name OUString sListLabel = m_pImpl->HasListCharStyle(rCharProperties); - if( !sListLabel.isEmpty() ) + // Don't try to reuse an existing character style if requested. + if( !sListLabel.isEmpty() && !bAlwaysCreate) return sListLabel; const char cListLabel[] = "ListLabel "; uno::Reference< style::XStyleFamiliesSupplier > xStylesSupplier( m_pImpl->m_xTextDocument, uno::UNO_QUERY_THROW ); diff --git a/writerfilter/source/dmapper/StyleSheetTable.hxx b/writerfilter/source/dmapper/StyleSheetTable.hxx index 44d33ea..16d79a1 100644 --- a/writerfilter/source/dmapper/StyleSheetTable.hxx +++ b/writerfilter/source/dmapper/StyleSheetTable.hxx @@ -101,7 +101,7 @@ public: OUString ConvertStyleName( const OUString& rWWName, bool bExtendedSearch = false ); - OUString getOrCreateCharStyle( PropertyValueVector_t& rCharProperties ); + OUString getOrCreateCharStyle( PropertyValueVector_t& rCharProperties, bool bAlwaysCreate ); /// Returns the default character properties. PropertyMapPtr GetDefaultCharProps(); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits