summaryrefslogtreecommitdiff
path: root/writerfilter
diff options
context:
space:
mode:
authorVasily Melenchuk <vasily.melenchuk@cib.de>2022-12-28 23:52:10 +0300
committerThorsten Behrens <thorsten.behrens@allotropia.de>2022-12-29 22:39:55 +0000
commitd5a9722874871576b864feb7bd815f9f8bfaac48 (patch)
tree80ef8068f32f5558a284fc9055167cf6d0761977 /writerfilter
parent37723413115baafdc7d13ad26d11aa5f917c2036 (diff)
ms format import: better handling for invalid styles
If referred paragraph style is not found or it is not a paragraph style, this can lead to exceptions in writer core and thus current paragraph can be not corretly initialized. For example, numbering can be not applied because of exception of not found style earlier. This is not a critical error, we should just not apply a style we could not resolve. Of course such documents are invalid but bit more tolerance to errors will not harm. Change-Id: I9150786e6357a7d6098440bac29ec501fc6aa802 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144852 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <thorsten.behrens@allotropia.de>
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.cxx10
1 files changed, 9 insertions, 1 deletions
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 377c133c8192..668f7f6758fe 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -1946,13 +1946,21 @@ void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap, con
#endif
const StyleSheetEntryPtr pEntry = GetStyleSheetTable()->FindStyleSheetByConvertedStyleName( GetCurrentParaStyleName() );
- OSL_ENSURE( pEntry, "no style sheet found" );
+ SAL_WARN_IF(!pEntry, "writerfilter.dmapper", "no style sheet found");
const StyleSheetPropertyMap* pStyleSheetProperties = pEntry ? pEntry->pProperties.get() : nullptr;
sal_Int32 nListId = pParaContext ? pParaContext->props().GetListId() : -1;
bool isNumberingViaStyle(false);
bool isNumberingViaRule = nListId > -1;
if ( !bRemove && pStyleSheetProperties && pParaContext )
{
+ if (!pEntry || pEntry->nStyleTypeCode != StyleType::STYLE_TYPE_PARA) {
+ // We could not resolve paragraph style or it is not a paragraph style
+ // Remove this style reference, otherwise it will cause exceptions during further
+ // processing and not all paragraph styles will be initialized.
+ SAL_WARN("writerfilter.dmapper", "Paragraph style is incorrect. Ignored");
+ pParaContext->Erase(PROP_PARA_STYLE_NAME);
+ }
+
bool bNumberingFromBaseStyle = false;
if (!isNumberingViaRule)
nListId = lcl_getListId(pEntry, GetStyleSheetTable(), bNumberingFromBaseStyle);