summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Luth <justin_luth@sil.org>2018-07-06 10:03:07 +0300
committerMiklos Vajna <vmiklos@collabora.co.uk>2018-07-11 17:40:51 +0200
commit3d9e0874becde20d901fda561633202e2e478eff (patch)
treec373daf98e6d803483d4863e0fa7adb148c631ff
parent00f839e2315f52be2a73aec98161baaff03e636d (diff)
backport combined tdf#95115 and tdf#102619: writerfilter
Styles were having FollowStyle set to themselves (Heading 1), not to a defined follow (Text body). The style was being created with a FollowStyle property that identified a style which had not yet been created. And also some stylenames were not recognized since it didn't do an extended search. tdf#95114 writerfilter: follow correctly converted stylename commit ac540c1d743250062b3e71b094209ec1428872e9 tdf#102619 writerfilter: first create style, then set FollowStyle commit 39a4f21fc4a16f7c57a9b6f1ddd5ce2953781576 ~NFC related tdf#102619 writerfilter: use ConvertStyleName() commit d22bca292532ff58839bc593a7b3e1d3b6f3552c These commit were done separately to aid in regression testing in master, but logically all combine together for easy backporting. Change-Id: I77f143760c10be4b7853f16bce2b57474b70d3f1 Reviewed-on: https://gerrit.libreoffice.org/57073 Tested-by: Jenkins Reviewed-by: Justin Luth <justin_luth@sil.org> Reviewed-on: https://gerrit.libreoffice.org/57175 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport.cxx4
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport8.cxx4
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport9.cxx8
-rw-r--r--writerfilter/source/dmapper/StyleSheetTable.cxx44
4 files changed, 37 insertions, 23 deletions
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 0dc6ebe65b20..3056f5a43a9a 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -797,6 +797,10 @@ DECLARE_OOXMLEXPORT_TEST(testTdf89791, "tdf89791.docx")
uno::Reference<packages::zip::XZipFileAccess2> xNameAccess = packages::zip::ZipFileAccess::createWithURL(comphelper::getComponentContext(m_xSFactory), maTempFile.GetURL());
CPPUNIT_ASSERT_EQUAL(false, bool(xNameAccess->hasByName("docProps/custom.xml")));
}
+
+ //tdf#102619 - setting FollowStyle with a not-yet-created style was failing. (Titre is created before Corps de texte).
+ uno::Reference< beans::XPropertySet > properties(getStyles("ParagraphStyles")->getByName("Titre"), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("Corps de texte"), getProperty<OUString>(properties, "FollowStyle"));
}
DECLARE_OOXMLEXPORT_TEST(testTdf91261, "tdf91261.docx")
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx
index e3ae1ffad629..66e2228fb368 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx
@@ -559,6 +559,10 @@ DECLARE_OOXMLEXPORT_TEST(testN780853, "n780853.docx")
uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xIndexAccess(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount());
+
+ //tdf#102619 - I would have expected this to be "Standard", but MSO 2013/2010/2003 all give FollowStyle==Date
+ uno::Reference< beans::XPropertySet > properties(getStyles("ParagraphStyles")->getByName("Date"), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("Date"), getProperty<OUString>(properties, "FollowStyle"));
}
DECLARE_OOXMLEXPORT_TEST(testN780843, "n780843.docx")
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
index 9a10e7d0f2cb..096a711d113b 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
@@ -251,6 +251,10 @@ DECLARE_OOXMLEXPORT_TEST(testTdf97648_relativeWidth,"tdf97648_relativeWidth.docx
DECLARE_OOXMLEXPORT_TEST(testTdf104061_tableSectionColumns,"tdf104061_tableSectionColumns.docx")
{
CPPUNIT_ASSERT_MESSAGE("There should be two or three pages", getPages() <= 3 );
+
+ //tdf#95114 - follow style is Text Body - DOCX test
+ uno::Reference< beans::XPropertySet > properties(getStyles("ParagraphStyles")->getByName("annotation subject"), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("annotation text"), getProperty<OUString>(properties, "FollowStyle"));
}
DECLARE_OOXMLEXPORT_TEST(testTdf46940_dontEquallyDistributeColumns, "tdf46940_dontEquallyDistributeColumns.docx")
@@ -270,6 +274,10 @@ DECLARE_OOXMLEXPORT_TEST(testTdf98700_keepWithNext, "tdf98700_keepWithNext.odt")
CPPUNIT_ASSERT_EQUAL_MESSAGE("Heading 1 style inherits keeps with next", true, getProperty<bool>(getParagraph(3), "ParaKeepTogether"));
CPPUNIT_ASSERT_EQUAL_MESSAGE("Heading 2 style disabled keep with next", false, getProperty<bool>(getParagraph(4), "ParaKeepTogether"));
CPPUNIT_ASSERT_EQUAL_MESSAGE("Text Body style toggled off keep with next", false, getProperty<bool>(getParagraph(5), "ParaKeepTogether"));
+
+ //tdf#95114 - follow style is Text Body - ODT test
+ uno::Reference< beans::XPropertySet > properties(getStyles("ParagraphStyles")->getByName("Heading 1"), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("Text body"), getProperty<OUString>(properties, "FollowStyle"));
}
// base class to supply a helper method for testHFLinkToPrev
diff --git a/writerfilter/source/dmapper/StyleSheetTable.cxx b/writerfilter/source/dmapper/StyleSheetTable.cxx
index 7e28500a11c0..69a03c6e8ea0 100644
--- a/writerfilter/source/dmapper/StyleSheetTable.cxx
+++ b/writerfilter/source/dmapper/StyleSheetTable.cxx
@@ -904,6 +904,7 @@ void StyleSheetTable::ApplyStyleSheets( const FontTablePtr& rFontTable )
if(xCharStyles.is() && xParaStyles.is())
{
std::vector< ::std::pair<OUString, uno::Reference<style::XStyle>> > aMissingParent;
+ std::vector< ::std::pair<OUString, uno::Reference<style::XStyle>> > aMissingFollow;
std::vector<beans::PropertyValue> aTableStylesVec;
std::vector< StyleSheetEntryPtr >::iterator aIt = m_pImpl->m_aStyleSheetEntries.begin();
while( aIt != m_pImpl->m_aStyleSheetEntries.end() )
@@ -1060,15 +1061,18 @@ void StyleSheetTable::ApplyStyleSheets( const FontTablePtr& rFontTable )
}
auto aPropValues = comphelper::sequenceToContainer< std::vector<beans::PropertyValue> >(pEntry->pProperties->GetPropertyValues());
- bool bAddFollowStyle = false;
- if(bParaStyle && !pEntry->sNextStyleIdentifier.isEmpty() )
- {
- bAddFollowStyle = true;
- }
// remove Left/RightMargin values from TOX heading styles
if( bParaStyle )
{
+ // delay adding FollowStyle property: all styles need to be created first
+ if ( !pEntry->sNextStyleIdentifier.isEmpty() )
+ {
+ StyleSheetEntryPtr pFollowStyle = FindStyleSheetByISTD( pEntry->sNextStyleIdentifier );
+ if ( pFollowStyle && !pFollowStyle->sStyleName.isEmpty() )
+ aMissingFollow.emplace_back( ConvertStyleName( pFollowStyle->sStyleName ), xStyle );
+ }
+
// Set the outline levels
const StyleSheetPropertyMap* pStyleSheetProperties = dynamic_cast<const StyleSheetPropertyMap*>(pEntry ? pEntry->pProperties.get() : nullptr);
if ( pStyleSheetProperties )
@@ -1113,7 +1117,7 @@ void StyleSheetTable::ApplyStyleSheets( const FontTablePtr& rFontTable )
}
}
- if(bAddFollowStyle || !aPropValues.empty())
+ if ( !aPropValues.empty() )
{
PropValVector aSortedPropVals;
for (const beans::PropertyValue& rValue : aPropValues)
@@ -1126,22 +1130,6 @@ void StyleSheetTable::ApplyStyleSheets( const FontTablePtr& rFontTable )
aSortedPropVals.Insert(rValue);
}
}
- if(bAddFollowStyle)
- {
- //find the name of the Next style
- std::vector< StyleSheetEntryPtr >::iterator it = m_pImpl->m_aStyleSheetEntries.begin();
- for (; it != m_pImpl->m_aStyleSheetEntries.end(); ++it)
- {
- if (!(*it)->sStyleName.isEmpty() && (*it)->sStyleIdentifierD == pEntry->sNextStyleIdentifier)
- {
- beans::PropertyValue aNew;
- aNew.Name = "FollowStyle";
- aNew.Value <<= ConvertStyleName((*it)->sStyleIdentifierD);
- aSortedPropVals.Insert(aNew);
- break;
- }
- }
- }
try
{
@@ -1211,12 +1199,22 @@ void StyleSheetTable::ApplyStyleSheets( const FontTablePtr& rFontTable )
++aIt;
}
- // Update the styles that were created before their parents
+ // Update the styles that were created before their parents or next-styles
for( auto const & iter : aMissingParent )
{
iter.second->setParentStyle( iter.first );
}
+ for( auto const & iter : aMissingFollow )
+ {
+ try
+ {
+ uno::Reference<beans::XPropertySet> xPropertySet(iter.second, uno::UNO_QUERY);
+ xPropertySet->setPropertyValue( "FollowStyle", uno::makeAny(iter.first) );
+ }
+ catch( uno::Exception & ) {}
+ }
+
if (!aTableStylesVec.empty())
{
// If we had any table styles, add a new document-level InteropGrabBag entry for them.