don't crash on formatting outline level 10 in master view

There are only 9 outline level styles, but we are allowed
(for some nutball reason) to create 10 levels, trying
to change the format of level 10 will then crash when
trying to apply its formatting to the non-existent
underlying style

Change-Id: Ic240322f98d832bc59edb502dd6d4988aa022481
This commit is contained in:
Caolán McNamara
2014-05-21 15:02:28 +01:00
parent 67444a92e4
commit 583619b771

View File

@@ -197,35 +197,40 @@ bool DrawView::SetAttributes(const SfxItemSet& rSet,
OUString aName = rPage.GetLayoutName() + " " +
OUString::number((nDepth <= 0) ? 1 : nDepth + 1);
SfxStyleSheet* pSheet = (SfxStyleSheet*)pStShPool->Find(aName, SD_STYLE_FAMILY_MASTERPAGE);
DBG_ASSERT(pSheet, "StyleSheet not found");
SfxItemSet aTempSet( pSheet->GetItemSet() );
aTempSet.Put( rSet );
aTempSet.ClearInvalidItems();
if( nDepth > 0 && aTempSet.GetItemState( EE_PARA_NUMBULLET ) == SFX_ITEM_ON )
//We have no stylesheet if we access outline level 10
//in the master preview, there is no true style backing
//that entry
SAL_WARN_IF(!pSheet, "sd", "StyleSheet " << aName << " not found");
if (pSheet)
{
// no SvxNumBulletItem in outline level 1 to 8!
aTempSet.ClearItem( EE_PARA_NUMBULLET );
}
SfxItemSet aTempSet( pSheet->GetItemSet() );
aTempSet.Put( rSet );
aTempSet.ClearInvalidItems();
// Undo-Action
StyleSheetUndoAction* pAction = new StyleSheetUndoAction(&mrDoc, pSheet, &aTempSet);
mpDocSh->GetUndoManager()->AddUndoAction(pAction);
if( nDepth > 0 && aTempSet.GetItemState( EE_PARA_NUMBULLET ) == SFX_ITEM_ON )
{
// no SvxNumBulletItem in outline level 1 to 8!
aTempSet.ClearItem( EE_PARA_NUMBULLET );
}
pSheet->GetItemSet().Put(aTempSet);
pSheet->Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED));
// Undo-Action
StyleSheetUndoAction* pAction = new StyleSheetUndoAction(&mrDoc, pSheet, &aTempSet);
mpDocSh->GetUndoManager()->AddUndoAction(pAction);
// now also broadcast any child sheets
sal_Int16 nChild;
for( nChild = nDepth + 1; nChild < 9; nChild++ )
{
OUString aSheetName = rPage.GetLayoutName() + " " +
OUString::number((nChild <= 0) ? 1 : nChild + 1);
SfxStyleSheet* pOutlSheet = static_cast< SfxStyleSheet* >(pStShPool->Find(aSheetName, SD_STYLE_FAMILY_MASTERPAGE));
pSheet->GetItemSet().Put(aTempSet);
pSheet->Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED));
if( pOutlSheet )
pOutlSheet->Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED));
// now also broadcast any child sheets
sal_Int16 nChild;
for( nChild = nDepth + 1; nChild < 9; nChild++ )
{
OUString aSheetName = rPage.GetLayoutName() + " " +
OUString::number((nChild <= 0) ? 1 : nChild + 1);
SfxStyleSheet* pOutlSheet = static_cast< SfxStyleSheet* >(pStShPool->Find(aSheetName, SD_STYLE_FAMILY_MASTERPAGE));
if( pOutlSheet )
pOutlSheet->Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED));
}
}
++iter;