writerfilter/source/dmapper/StyleSheetTable.cxx | 25 ++++++++++++++++++++++-- writerfilter/source/rtftok/rtfdocumentimpl.cxx | 4 +-- 2 files changed, 25 insertions(+), 4 deletions(-)
New commits: commit b9b9fea12ed1d87d34f84f51574c10e2345d9ac7 Author: Michael Stahl <mst...@redhat.com> Date: Thu Jul 31 11:42:52 2014 +0200 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 diff --git a/writerfilter/source/dmapper/StyleSheetTable.cxx b/writerfilter/source/dmapper/StyleSheetTable.cxx index 8f50037..7c698ef 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 8ff911a..3bba4c4 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; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits