Kaydet (Commit) 185dae19 authored tarafından Caolán McNamara's avatar Caolán McNamara

Resolves: fdo#86451 guard all the tops post pop

Change-Id: Ic89edb94c6c12a66fd46e0630115a458857cc6cc
üst 9a038e5e
...@@ -5790,7 +5790,7 @@ int RTFDocumentImpl::popState() ...@@ -5790,7 +5790,7 @@ int RTFDocumentImpl::popState()
case DESTINATION_PARAGRAPHNUMBERING: case DESTINATION_PARAGRAPHNUMBERING:
{ {
RTFValue::Pointer_t pIdValue = aState.aTableAttributes.find(NS_ooxml::LN_CT_AbstractNum_nsid); RTFValue::Pointer_t pIdValue = aState.aTableAttributes.find(NS_ooxml::LN_CT_AbstractNum_nsid);
if (pIdValue.get()) if (pIdValue.get() && !m_aStates.empty())
{ {
// Abstract numbering // Abstract numbering
RTFSprms aLeveltextAttributes; RTFSprms aLeveltextAttributes;
...@@ -5859,87 +5859,98 @@ int RTFDocumentImpl::popState() ...@@ -5859,87 +5859,98 @@ int RTFDocumentImpl::popState()
} }
break; break;
case DESTINATION_PARAGRAPHNUMBERING_TEXTAFTER: case DESTINATION_PARAGRAPHNUMBERING_TEXTAFTER:
{ if (!m_aStates.empty())
// FIXME: don't use pDestinationText, points to popped state {
RTFValue::Pointer_t pValue(new RTFValue(aState.aDestinationText.makeStringAndClear(), true)); // FIXME: don't use pDestinationText, points to popped state
m_aStates.top().aTableAttributes.set(NS_ooxml::LN_CT_LevelSuffix_val, pValue); RTFValue::Pointer_t pValue(new RTFValue(aState.aDestinationText.makeStringAndClear(), true));
} m_aStates.top().aTableAttributes.set(NS_ooxml::LN_CT_LevelSuffix_val, pValue);
}
break; break;
case DESTINATION_PARAGRAPHNUMBERING_TEXTBEFORE: case DESTINATION_PARAGRAPHNUMBERING_TEXTBEFORE:
{ if (!m_aStates.empty())
// FIXME: don't use pDestinationText, points to popped state {
RTFValue::Pointer_t pValue(new RTFValue(aState.aDestinationText.makeStringAndClear(), true)); // FIXME: don't use pDestinationText, points to popped state
m_aStates.top().aTableAttributes.set(NS_ooxml::LN_CT_LevelText_val, pValue); RTFValue::Pointer_t pValue(new RTFValue(aState.aDestinationText.makeStringAndClear(), true));
} m_aStates.top().aTableAttributes.set(NS_ooxml::LN_CT_LevelText_val, pValue);
}
break; break;
case DESTINATION_LISTNAME: case DESTINATION_LISTNAME:
break; break;
case DESTINATION_LISTLEVEL: case DESTINATION_LISTLEVEL:
{ 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 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)); RTFValue::Pointer_t pValue(new RTFValue(aState.aTableAttributes, aState.aTableSprms));
if (m_aStates.top().nDestinationState != DESTINATION_LFOLEVEL) if (m_aStates.top().nDestinationState != DESTINATION_LFOLEVEL)
m_aStates.top().aListLevelEntries.set(NS_ooxml::LN_CT_AbstractNum_lvl, pValue, OVERWRITE_NO_APPEND); m_aStates.top().aListLevelEntries.set(NS_ooxml::LN_CT_AbstractNum_lvl, pValue, OVERWRITE_NO_APPEND);
else else
m_aStates.top().aTableSprms.set(NS_ooxml::LN_CT_NumLvl_lvl, pValue); m_aStates.top().aTableSprms.set(NS_ooxml::LN_CT_NumLvl_lvl, pValue);
} }
break; break;
case DESTINATION_LFOLEVEL: case DESTINATION_LFOLEVEL:
{ 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 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)); RTFValue::Pointer_t pValue(new RTFValue(aState.aTableAttributes, aState.aTableSprms));
m_aStates.top().aTableSprms.set(NS_ooxml::LN_CT_Num_lvlOverride, pValue); m_aStates.top().aTableSprms.set(NS_ooxml::LN_CT_Num_lvlOverride, pValue);
} }
break; break;
// list override table // list override table
case DESTINATION_LISTOVERRIDEENTRY: case DESTINATION_LISTOVERRIDEENTRY:
{ if (!m_aStates.empty())
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( if (m_aStates.top().nDestinationState == DESTINATION_LISTOVERRIDEENTRY)
aState.aTableAttributes, aState.aTableSprms)); {
m_aListTableSprms.set(NS_ooxml::LN_CT_Numbering_num, pValue, OVERWRITE_NO_APPEND); // 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; break;
case DESTINATION_LEVELTEXT: case DESTINATION_LEVELTEXT:
{ if (!m_aStates.empty())
RTFValue::Pointer_t pValue(new RTFValue(aState.aTableAttributes)); {
m_aStates.top().aTableSprms.set(NS_ooxml::LN_CT_Lvl_lvlText, pValue); RTFValue::Pointer_t pValue(new RTFValue(aState.aTableAttributes));
} m_aStates.top().aTableSprms.set(NS_ooxml::LN_CT_Lvl_lvlText, pValue);
}
break; break;
case DESTINATION_LEVELNUMBERS: case DESTINATION_LEVELNUMBERS:
m_aStates.top().aTableSprms = aState.aTableSprms; if (!m_aStates.empty())
m_aStates.top().aTableSprms = aState.aTableSprms;
break; break;
case DESTINATION_FIELDINSTRUCTION: case DESTINATION_FIELDINSTRUCTION:
m_aStates.top().nFieldStatus = FIELD_INSTRUCTION; if (!m_aStates.empty())
m_aStates.top().nFieldStatus = FIELD_INSTRUCTION;
break; break;
case DESTINATION_FIELDRESULT: case DESTINATION_FIELDRESULT:
m_aStates.top().nFieldStatus = FIELD_RESULT; if (!m_aStates.empty())
m_aStates.top().nFieldStatus = FIELD_RESULT;
break; break;
case DESTINATION_FIELD: case DESTINATION_FIELD:
if (aState.nFieldStatus == FIELD_INSTRUCTION) if (aState.nFieldStatus == FIELD_INSTRUCTION)
singleChar(0x15); singleChar(0x15);
break; break;
case DESTINATION_SHAPEPROPERTYVALUEPICT: case DESTINATION_SHAPEPROPERTYVALUEPICT:
{ 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().aPicture = aState.aPicture;
m_aStates.top().aDestinationText = aState.aDestinationText; // both \sp and \sv are destinations, copy the text up-ward for later
} m_aStates.top().aDestinationText = aState.aDestinationText;
}
break; break;
case DESTINATION_FALT: case DESTINATION_FALT:
m_aStates.top().aTableSprms = aState.aTableSprms; if (!m_aStates.empty())
m_aStates.top().aTableSprms = aState.aTableSprms;
break; break;
case DESTINATION_SHAPEPROPERTYNAME: case DESTINATION_SHAPEPROPERTYNAME:
case DESTINATION_SHAPEPROPERTYVALUE: case DESTINATION_SHAPEPROPERTYVALUE:
...@@ -5970,27 +5981,30 @@ int RTFDocumentImpl::popState() ...@@ -5970,27 +5981,30 @@ int RTFDocumentImpl::popState()
} }
break; break;
case DESTINATION_SHAPETEXT: 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.empty())
if (m_aStates.top().nDestinationState != DESTINATION_SHAPETEXT && !m_aStates.top().aDrawingObject.bHadShapeText)
{ {
m_aStates.top().bHadShapeText = true; // 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().pCurrentBuffer) if (m_aStates.top().nDestinationState != DESTINATION_SHAPETEXT && !m_aStates.top().aDrawingObject.bHadShapeText)
m_pSdrImport->close(); {
else m_aStates.top().bHadShapeText = true;
m_aStates.top().pCurrentBuffer->push_back( if (!m_aStates.top().pCurrentBuffer)
Buf_t(BUFFER_ENDSHAPE)); m_pSdrImport->close();
} else
m_aStates.top().pCurrentBuffer->push_back(
// It's allowed to declare these inside the shape text, and they Buf_t(BUFFER_ENDSHAPE));
// are expected to have an effect for the whole shape. }
if (aState.aDrawingObject.nLeft)
m_aStates.top().aDrawingObject.nLeft = aState.aDrawingObject.nLeft; // It's allowed to declare these inside the shape text, and they
if (aState.aDrawingObject.nTop) // are expected to have an effect for the whole shape.
m_aStates.top().aDrawingObject.nTop = aState.aDrawingObject.nTop; if (aState.aDrawingObject.nLeft)
if (aState.aDrawingObject.nRight) m_aStates.top().aDrawingObject.nLeft = aState.aDrawingObject.nLeft;
m_aStates.top().aDrawingObject.nRight = aState.aDrawingObject.nRight; if (aState.aDrawingObject.nTop)
if (aState.aDrawingObject.nBottom) m_aStates.top().aDrawingObject.nTop = aState.aDrawingObject.nTop;
m_aStates.top().aDrawingObject.nBottom = aState.aDrawingObject.nBottom; 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; break;
default: default:
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment