summaryrefslogtreecommitdiff
path: root/writerfilter
diff options
context:
space:
mode:
authorJustin Luth <justin_luth@sil.org>2019-08-09 19:16:10 +0300
committerCaolán McNamara <caolanm@redhat.com>2019-08-10 12:39:04 +0200
commitdc7b997bb45fcdf3e03da7d94f46e0ca55f86fde (patch)
treeb378407b0894e15e6e0f6fbe755be2e7d6534bab /writerfilter
parent3c367de9893b1e2d352585a42cbbd25052bb7376 (diff)
tdf#118936 writerfilter: MultiPropertySet retry on exception
Applying the same logic as in PropertyMap - if the efficient multipropertyset fails, then re-apply each property one at a time. This effectively reverts 9a19a1235c301f2699157ab44049bdfd54955e8a The "assert" idea of identifying and fixing invalid properties failed spectacularly with RTF - where paragraph properties seem to be routinely applied to character styles. No docx examples were found - unless they were the novell examples which I don't have access to. Change-Id: I4b733d52de93dfb6beb1da35e0813fd1b0396da7 Reviewed-on: https://gerrit.libreoffice.org/77221 Tested-by: Jenkins Reviewed-by: Justin Luth <justin_luth@sil.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/source/dmapper/StyleSheetTable.cxx27
1 files changed, 21 insertions, 6 deletions
diff --git a/writerfilter/source/dmapper/StyleSheetTable.cxx b/writerfilter/source/dmapper/StyleSheetTable.cxx
index d3630e7a6f97..32f4d401d781 100644
--- a/writerfilter/source/dmapper/StyleSheetTable.cxx
+++ b/writerfilter/source/dmapper/StyleSheetTable.cxx
@@ -861,6 +861,7 @@ public:
void Insert(const beans::PropertyValue& rVal);
uno::Sequence< uno::Any > getValues();
uno::Sequence< OUString > getNames();
+ std::vector<beans::PropertyValue> getProperties() { return m_aValues; };
};
void PropValVector::Insert(const beans::PropertyValue& rVal)
@@ -913,7 +914,6 @@ void StyleSheetTable::ApplyStyleSheets( const FontTablePtr& rFontTable )
if( pEntry->nStyleTypeCode == STYLE_TYPE_CHAR || pEntry->nStyleTypeCode == STYLE_TYPE_PARA || pEntry->nStyleTypeCode == STYLE_TYPE_LIST )
{
bool bParaStyle = pEntry->nStyleTypeCode == STYLE_TYPE_PARA;
- bool bCharStyle = pEntry->nStyleTypeCode == STYLE_TYPE_CHAR;
bool bListStyle = pEntry->nStyleTypeCode == STYLE_TYPE_LIST;
bool bInsert = false;
uno::Reference< container::XNameContainer > xStyles = bParaStyle ? xParaStyles : (bListStyle ? xNumberingStyles : xCharStyles);
@@ -1099,8 +1099,7 @@ void StyleSheetTable::ApplyStyleSheets( const FontTablePtr& rFontTable )
// Don't add the style name properties
bool bIsParaStyleName = rValue.Name == "ParaStyleName";
bool bIsCharStyleName = rValue.Name == "CharStyleName";
- bool bDirectFormattingOnly = bCharStyle && rValue.Name == "CharShadingValue";
- if ( !bIsParaStyleName && !bIsCharStyleName && !bDirectFormattingOnly )
+ if ( !bIsParaStyleName && !bIsCharStyleName )
{
aSortedPropVals.Insert(rValue);
}
@@ -1109,8 +1108,25 @@ void StyleSheetTable::ApplyStyleSheets( const FontTablePtr& rFontTable )
try
{
uno::Reference< beans::XMultiPropertySet > xMultiPropertySet( xStyle, uno::UNO_QUERY_THROW);
- xMultiPropertySet->setPropertyValues( aSortedPropVals.getNames(), aSortedPropVals.getValues() );
-
+ try
+ {
+ xMultiPropertySet->setPropertyValues( aSortedPropVals.getNames(), aSortedPropVals.getValues() );
+ }
+ catch ( const uno::Exception& )
+ {
+ uno::Reference<beans::XPropertySet> xPropertySet(xStyle, uno::UNO_QUERY_THROW);
+ for ( const beans::PropertyValue& rValue : aSortedPropVals.getProperties() )
+ {
+ try
+ {
+ xPropertySet->setPropertyValue( rValue.Name, rValue.Value );
+ }
+ catch ( const uno::Exception& )
+ {
+ SAL_WARN( "writerfilter", "StyleSheetTable::ApplyStyleSheets could not set property " << rValue.Name );
+ }
+ }
+ }
// Duplicate MSWord's single footnote reference into Footnote Characters and Footnote anchor
if( pEntry->sStyleName.equalsIgnoreAsciiCase("footnote reference")
|| pEntry->sStyleName.equalsIgnoreAsciiCase("endnote reference") )
@@ -1135,7 +1151,6 @@ void StyleSheetTable::ApplyStyleSheets( const FontTablePtr& rFontTable )
aMessage += ": " + aUnknownPropertyException.Message;
SAL_WARN("writerfilter", aMessage);
- assert (false && "SERIOUS: remaining alphabetically sorted properties were lost");
#else
(void) rWrapped;
#endif