Kaydet (Commit) 39a4f21f authored tarafından Justin Luth's avatar Justin Luth

tdf#102619 writerfilter: first create style, then set FollowStyle

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.
So svl code was warning
  "svl.items", "StyleSheet-Follow not found"

This section of code should really be cleaned up, but that will
happen in a separate commit.

Change-Id: Iae79fac917f64cdaa14ca6568e7d903ec6dc60fa
Reviewed-on: https://gerrit.libreoffice.org/57074
Tested-by: Jenkins
Reviewed-by: 's avatarJustin Luth <justin_luth@sil.org>
üst a7699fc2
......@@ -818,6 +818,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")
......
......@@ -903,6 +903,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() )
......@@ -1133,10 +1134,16 @@ void StyleSheetTable::ApplyStyleSheets( const FontTablePtr& rFontTable )
{
if (!(*it)->sStyleName.isEmpty() && (*it)->sStyleIdentifierD == pEntry->sNextStyleIdentifier)
{
beans::PropertyValue aNew;
aNew.Name = "FollowStyle";
aNew.Value <<= ConvertStyleName((*it)->sStyleName);
aSortedPropVals.Insert(aNew);
const OUString sFollowStyle = ConvertStyleName((*it)->sStyleName);
if ( !xStyles->hasByName( sFollowStyle ) )
aMissingFollow.emplace_back( sFollowStyle, xStyle );
else
{
beans::PropertyValue aNew;
aNew.Name = "FollowStyle";
aNew.Value <<= sFollowStyle;
aSortedPropVals.Insert(aNew);
}
break;
}
}
......@@ -1210,12 +1217,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.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment