summaryrefslogtreecommitdiff
path: root/writerfilter
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2014-11-19 12:11:47 +0000
committerCaolán McNamara <caolanm@redhat.com>2014-11-19 12:12:21 +0000
commit185dae1969bb463ae1be8ea46a7780efa32372f5 (patch)
treed0bb884c5b5db05a0b62940daa48894c8d7f1641 /writerfilter
parent9a038e5e7b89822fb39064f63367be292999f8ea (diff)
Resolves: fdo#86451 guard all the tops post pop
Change-Id: Ic89edb94c6c12a66fd46e0630115a458857cc6cc
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.cxx156
1 files changed, 85 insertions, 71 deletions
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index a48553c269e9..1234e37e7e32 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -5790,7 +5790,7 @@ int RTFDocumentImpl::popState()
case DESTINATION_PARAGRAPHNUMBERING:
{
RTFValue::Pointer_t pIdValue = aState.aTableAttributes.find(NS_ooxml::LN_CT_AbstractNum_nsid);
- if (pIdValue.get())
+ if (pIdValue.get() && !m_aStates.empty())
{
// Abstract numbering
RTFSprms aLeveltextAttributes;
@@ -5859,87 +5859,98 @@ int RTFDocumentImpl::popState()
}
break;
case DESTINATION_PARAGRAPHNUMBERING_TEXTAFTER:
- {
- // FIXME: don't use pDestinationText, points to popped state
- RTFValue::Pointer_t pValue(new RTFValue(aState.aDestinationText.makeStringAndClear(), true));
- m_aStates.top().aTableAttributes.set(NS_ooxml::LN_CT_LevelSuffix_val, pValue);
- }
+ if (!m_aStates.empty())
+ {
+ // FIXME: don't use pDestinationText, points to popped state
+ RTFValue::Pointer_t pValue(new RTFValue(aState.aDestinationText.makeStringAndClear(), true));
+ m_aStates.top().aTableAttributes.set(NS_ooxml::LN_CT_LevelSuffix_val, pValue);
+ }
break;
case DESTINATION_PARAGRAPHNUMBERING_TEXTBEFORE:
- {
- // FIXME: don't use pDestinationText, points to popped state
- RTFValue::Pointer_t pValue(new RTFValue(aState.aDestinationText.makeStringAndClear(), true));
- m_aStates.top().aTableAttributes.set(NS_ooxml::LN_CT_LevelText_val, pValue);
- }
+ if (!m_aStates.empty())
+ {
+ // FIXME: don't use pDestinationText, points to popped state
+ RTFValue::Pointer_t pValue(new RTFValue(aState.aDestinationText.makeStringAndClear(), true));
+ m_aStates.top().aTableAttributes.set(NS_ooxml::LN_CT_LevelText_val, pValue);
+ }
break;
case DESTINATION_LISTNAME:
break;
case DESTINATION_LISTLEVEL:
- {
- RTFValue::Pointer_t pInnerValue(new RTFValue(m_aStates.top().nListLevelNum++));
- aState.aTableAttributes.set(NS_ooxml::LN_CT_Lvl_ilvl, pInnerValue);
+ if (!m_aStates.empty())
+ {
+ RTFValue::Pointer_t pInnerValue(new RTFValue(m_aStates.top().nListLevelNum++));
+ aState.aTableAttributes.set(NS_ooxml::LN_CT_Lvl_ilvl, pInnerValue);
- RTFValue::Pointer_t pValue(new RTFValue(aState.aTableAttributes, aState.aTableSprms));
- if (m_aStates.top().nDestinationState != DESTINATION_LFOLEVEL)
- m_aStates.top().aListLevelEntries.set(NS_ooxml::LN_CT_AbstractNum_lvl, pValue, OVERWRITE_NO_APPEND);
- else
- m_aStates.top().aTableSprms.set(NS_ooxml::LN_CT_NumLvl_lvl, pValue);
- }
+ RTFValue::Pointer_t pValue(new RTFValue(aState.aTableAttributes, aState.aTableSprms));
+ if (m_aStates.top().nDestinationState != DESTINATION_LFOLEVEL)
+ m_aStates.top().aListLevelEntries.set(NS_ooxml::LN_CT_AbstractNum_lvl, pValue, OVERWRITE_NO_APPEND);
+ else
+ m_aStates.top().aTableSprms.set(NS_ooxml::LN_CT_NumLvl_lvl, pValue);
+ }
break;
case DESTINATION_LFOLEVEL:
- {
- RTFValue::Pointer_t pInnerValue(new RTFValue(m_aStates.top().nListLevelNum++));
- aState.aTableAttributes.set(NS_ooxml::LN_CT_NumLvl_ilvl, pInnerValue);
+ if (!m_aStates.empty())
+ {
+ RTFValue::Pointer_t pInnerValue(new RTFValue(m_aStates.top().nListLevelNum++));
+ aState.aTableAttributes.set(NS_ooxml::LN_CT_NumLvl_ilvl, pInnerValue);
- RTFValue::Pointer_t pValue(new RTFValue(aState.aTableAttributes, aState.aTableSprms));
- m_aStates.top().aTableSprms.set(NS_ooxml::LN_CT_Num_lvlOverride, pValue);
- }
+ RTFValue::Pointer_t pValue(new RTFValue(aState.aTableAttributes, aState.aTableSprms));
+ m_aStates.top().aTableSprms.set(NS_ooxml::LN_CT_Num_lvlOverride, pValue);
+ }
break;
// list override table
case DESTINATION_LISTOVERRIDEENTRY:
- {
- if (m_aStates.top().nDestinationState == DESTINATION_LISTOVERRIDEENTRY)
- {
- // copy properties upwards so upper popState inserts it
- m_aStates.top().aTableAttributes = aState.aTableAttributes;
- m_aStates.top().aTableSprms = aState.aTableSprms;
- }
- else
+ if (!m_aStates.empty())
{
- RTFValue::Pointer_t pValue(new RTFValue(
- aState.aTableAttributes, aState.aTableSprms));
- m_aListTableSprms.set(NS_ooxml::LN_CT_Numbering_num, pValue, OVERWRITE_NO_APPEND);
+ if (m_aStates.top().nDestinationState == DESTINATION_LISTOVERRIDEENTRY)
+ {
+ // copy properties upwards so upper popState inserts it
+ m_aStates.top().aTableAttributes = aState.aTableAttributes;
+ m_aStates.top().aTableSprms = aState.aTableSprms;
+ }
+ else
+ {
+ RTFValue::Pointer_t pValue(new RTFValue(
+ aState.aTableAttributes, aState.aTableSprms));
+ m_aListTableSprms.set(NS_ooxml::LN_CT_Numbering_num, pValue, OVERWRITE_NO_APPEND);
+ }
}
- }
break;
case DESTINATION_LEVELTEXT:
- {
- RTFValue::Pointer_t pValue(new RTFValue(aState.aTableAttributes));
- m_aStates.top().aTableSprms.set(NS_ooxml::LN_CT_Lvl_lvlText, pValue);
- }
+ if (!m_aStates.empty())
+ {
+ RTFValue::Pointer_t pValue(new RTFValue(aState.aTableAttributes));
+ m_aStates.top().aTableSprms.set(NS_ooxml::LN_CT_Lvl_lvlText, pValue);
+ }
break;
case DESTINATION_LEVELNUMBERS:
- m_aStates.top().aTableSprms = aState.aTableSprms;
+ if (!m_aStates.empty())
+ m_aStates.top().aTableSprms = aState.aTableSprms;
break;
case DESTINATION_FIELDINSTRUCTION:
- m_aStates.top().nFieldStatus = FIELD_INSTRUCTION;
+ if (!m_aStates.empty())
+ m_aStates.top().nFieldStatus = FIELD_INSTRUCTION;
break;
case DESTINATION_FIELDRESULT:
- m_aStates.top().nFieldStatus = FIELD_RESULT;
+ if (!m_aStates.empty())
+ m_aStates.top().nFieldStatus = FIELD_RESULT;
break;
case DESTINATION_FIELD:
if (aState.nFieldStatus == FIELD_INSTRUCTION)
singleChar(0x15);
break;
case DESTINATION_SHAPEPROPERTYVALUEPICT:
- {
- m_aStates.top().aPicture = aState.aPicture;
- // both \sp and \sv are destinations, copy the text up-ward for later
- m_aStates.top().aDestinationText = aState.aDestinationText;
- }
+ if (!m_aStates.empty())
+ {
+ m_aStates.top().aPicture = aState.aPicture;
+ // both \sp and \sv are destinations, copy the text up-ward for later
+ m_aStates.top().aDestinationText = aState.aDestinationText;
+ }
break;
case DESTINATION_FALT:
- m_aStates.top().aTableSprms = aState.aTableSprms;
+ if (!m_aStates.empty())
+ m_aStates.top().aTableSprms = aState.aTableSprms;
break;
case DESTINATION_SHAPEPROPERTYNAME:
case DESTINATION_SHAPEPROPERTYVALUE:
@@ -5970,27 +5981,30 @@ int RTFDocumentImpl::popState()
}
break;
case DESTINATION_SHAPETEXT:
- // If we're leaving the shapetext group (it may have nested ones) and this is a shape, not an old drawingobject.
- if (m_aStates.top().nDestinationState != DESTINATION_SHAPETEXT && !m_aStates.top().aDrawingObject.bHadShapeText)
+ if (!m_aStates.empty())
{
- m_aStates.top().bHadShapeText = true;
- if (!m_aStates.top().pCurrentBuffer)
- m_pSdrImport->close();
- else
- m_aStates.top().pCurrentBuffer->push_back(
- Buf_t(BUFFER_ENDSHAPE));
- }
-
- // It's allowed to declare these inside the shape text, and they
- // are expected to have an effect for the whole shape.
- if (aState.aDrawingObject.nLeft)
- m_aStates.top().aDrawingObject.nLeft = aState.aDrawingObject.nLeft;
- if (aState.aDrawingObject.nTop)
- m_aStates.top().aDrawingObject.nTop = aState.aDrawingObject.nTop;
- if (aState.aDrawingObject.nRight)
- m_aStates.top().aDrawingObject.nRight = aState.aDrawingObject.nRight;
- if (aState.aDrawingObject.nBottom)
- m_aStates.top().aDrawingObject.nBottom = aState.aDrawingObject.nBottom;
+ // If we're leaving the shapetext group (it may have nested ones) and this is a shape, not an old drawingobject.
+ if (m_aStates.top().nDestinationState != DESTINATION_SHAPETEXT && !m_aStates.top().aDrawingObject.bHadShapeText)
+ {
+ m_aStates.top().bHadShapeText = true;
+ if (!m_aStates.top().pCurrentBuffer)
+ m_pSdrImport->close();
+ else
+ m_aStates.top().pCurrentBuffer->push_back(
+ Buf_t(BUFFER_ENDSHAPE));
+ }
+
+ // It's allowed to declare these inside the shape text, and they
+ // are expected to have an effect for the whole shape.
+ if (aState.aDrawingObject.nLeft)
+ m_aStates.top().aDrawingObject.nLeft = aState.aDrawingObject.nLeft;
+ if (aState.aDrawingObject.nTop)
+ m_aStates.top().aDrawingObject.nTop = aState.aDrawingObject.nTop;
+ if (aState.aDrawingObject.nRight)
+ m_aStates.top().aDrawingObject.nRight = aState.aDrawingObject.nRight;
+ if (aState.aDrawingObject.nBottom)
+ m_aStates.top().aDrawingObject.nBottom = aState.aDrawingObject.nBottom;
+ }
break;
default:
{