diff options
author | Michael Stahl <mstahl@redhat.com> | 2014-07-31 11:42:52 +0200 |
---|---|---|
committer | Mihai Varga <mihai.mv13@gmail.com> | 2014-07-31 15:15:26 +0300 |
commit | 63d24a964c1f40d4a3ace0fc4fd60b24c33e48c6 (patch) | |
tree | 776647506b426b3e4e38cad2ec5b335006e4c436 | |
parent | f916aa66359b947bc88395e436e561b948bef241 (diff) |
writerfilter: fix ubsan complaints about "-42" enum value
Apparently the StyleType enum is specific to the domain-mapper, the
OOXML filter has integer constants in its model.xml file...
Also surprisingly the section styles only exist in RTF; w_ST_StyleType
in "ECMA-376 3rd Edition" only contains the 4 values of StyleType enum.
Change-Id: I5407800f801824676df309b3705e233cf1382721
-rw-r--r-- | writerfilter/source/dmapper/StyleSheetTable.cxx | 25 | ||||
-rw-r--r-- | writerfilter/source/rtftok/rtfdocumentimpl.cxx | 4 |
2 files changed, 25 insertions, 4 deletions
diff --git a/writerfilter/source/dmapper/StyleSheetTable.cxx b/writerfilter/source/dmapper/StyleSheetTable.cxx index 8f5003784a9d..7c698efb25a1 100644 --- a/writerfilter/source/dmapper/StyleSheetTable.cxx +++ b/writerfilter/source/dmapper/StyleSheetTable.cxx @@ -427,7 +427,28 @@ void StyleSheetTable::lcl_attribute(Id Name, Value & val) { SAL_WARN_IF( m_pImpl->m_pCurrentEntry->nStyleTypeCode != STYLE_TYPE_UNKNOWN, "writerfilter", "Style type needs to be processed first" ); - StyleType nType = ( StyleType ) nIntValue; + StyleType nType(STYLE_TYPE_UNKNOWN); + switch (nIntValue) + { + case 1: + nType = STYLE_TYPE_PARA; + break; + case 2: + nType = STYLE_TYPE_CHAR; + break; + case 3: + nType = STYLE_TYPE_TABLE; + break; + case 4: + nType = STYLE_TYPE_LIST; + break; + default: + SAL_WARN("writerfilter", "unknown LN_CT_Style_type " << nType); + //fall-through + case 0: // explicit unknown set by tokenizer + break; + + } if ( nType == STYLE_TYPE_TABLE ) { StyleSheetEntryPtr pEntry = m_pImpl->m_pCurrentEntry; @@ -435,7 +456,7 @@ void StyleSheetTable::lcl_attribute(Id Name, Value & val) m_pImpl->m_pCurrentEntry = pTableEntry; } else - m_pImpl->m_pCurrentEntry->nStyleTypeCode = (StyleType)nIntValue; + m_pImpl->m_pCurrentEntry->nStyleTypeCode = nType; } break; case NS_ooxml::LN_CT_Style_default: diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index 8ff911a0d230..3bba4c451af9 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -3647,7 +3647,7 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam) if (m_aStates.top().nDestinationState == DESTINATION_STYLESHEET || m_aStates.top().nDestinationState == DESTINATION_STYLEENTRY) { m_nCurrentStyleIndex = nParam; - RTFValue::Pointer_t pValue(new RTFValue(-42)); // TODO no value in enum StyleType? + RTFValue::Pointer_t pValue(new RTFValue(0)); // TODO no value in enum StyleType? m_aStates.top().aTableAttributes.set(NS_ooxml::LN_CT_Style_type, pValue); // section style } break; @@ -3655,7 +3655,7 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam) if (m_aStates.top().nDestinationState == DESTINATION_STYLESHEET || m_aStates.top().nDestinationState == DESTINATION_STYLEENTRY) { m_nCurrentStyleIndex = nParam; - RTFValue::Pointer_t pValue(new RTFValue(-43)); // FIXME the correct value would be 3 but maybe table styles mess things up in dmapper, be cautious and disable them for now + RTFValue::Pointer_t pValue(new RTFValue(0)); // FIXME the correct value would be 3 but maybe table styles mess things up in dmapper, be cautious and disable them for now m_aStates.top().aTableAttributes.set(NS_ooxml::LN_CT_Style_type, pValue); // table style } break; |