From ab10f03ec4dc7d5d7659fb62c59972c80221f733 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Thu, 16 Mar 2017 10:50:37 +0000 Subject: Resolves: tdf#106557 don't crash on missing line spacing argument this is all a bit addled, but at least don't crash Change-Id: I19c35205446cebc83b8299839bcab8e02ff7c07d --- sd/source/ui/view/drviews3.cxx | 351 ++++++++++++++++++++--------------------- 1 file changed, 174 insertions(+), 177 deletions(-) diff --git a/sd/source/ui/view/drviews3.cxx b/sd/source/ui/view/drviews3.cxx index f3b6e8be4ff3..68d0971029a5 100644 --- a/sd/source/ui/view/drviews3.cxx +++ b/sd/source/ui/view/drviews3.cxx @@ -493,167 +493,166 @@ void DrawViewShell::ExecRuler(SfxRequest& rReq) switch ( rReq.GetSlot() ) { case SID_ATTR_LONG_LRSPACE: - { - SdUndoGroup* pUndoGroup = new SdUndoGroup(GetDoc()); - pUndoGroup->SetComment(SdResId(STR_UNDO_CHANGE_PAGEBORDER)); + if (pArgs) + { + SdUndoGroup* pUndoGroup = new SdUndoGroup(GetDoc()); + pUndoGroup->SetComment(SdResId(STR_UNDO_CHANGE_PAGEBORDER)); - const SvxLongLRSpaceItem& rLRSpace = static_cast( - pArgs->Get(GetPool().GetWhich(SID_ATTR_LONG_LRSPACE))); + const SvxLongLRSpaceItem& rLRSpace = static_cast( + pArgs->Get(GetPool().GetWhich(SID_ATTR_LONG_LRSPACE))); - if( mpDrawView->IsTextEdit() ) - { - Rectangle aRect = maMarkRect; - aRect.SetPos(aRect.TopLeft() + aPagePos); - aRect.Left() = rLRSpace.GetLeft(); - aRect.Right() = aViewSize.Width() - rLRSpace.GetRight(); - aRect.SetPos(aRect.TopLeft() - aPagePos); - if ( aRect != maMarkRect) + if( mpDrawView->IsTextEdit() ) { - mpDrawView->SetAllMarkedRect(aRect); - maMarkRect = mpDrawView->GetAllMarkedRect(); - Invalidate( SID_RULER_OBJECT ); + Rectangle aRect = maMarkRect; + aRect.SetPos(aRect.TopLeft() + aPagePos); + aRect.Left() = rLRSpace.GetLeft(); + aRect.Right() = aViewSize.Width() - rLRSpace.GetRight(); + aRect.SetPos(aRect.TopLeft() - aPagePos); + if ( aRect != maMarkRect) + { + mpDrawView->SetAllMarkedRect(aRect); + maMarkRect = mpDrawView->GetAllMarkedRect(); + Invalidate( SID_RULER_OBJECT ); + } + } + else + { + long nLeft = std::max(0L, rLRSpace.GetLeft() - aPagePos.X()); + long nRight = std::max(0L, rLRSpace.GetRight() + aPagePos.X() + + aPageSize.Width() - aViewSize.Width()); + + sal_uInt16 nPageCnt = GetDoc()->GetSdPageCount(mePageKind); + sal_uInt16 i; + for ( i = 0; i < nPageCnt; i++) + { + SdPage* pPage = GetDoc()->GetSdPage(i, mePageKind); + SdUndoAction* pUndo = new SdPageLRUndoAction(GetDoc(), + pPage, + pPage->GetLftBorder(), + pPage->GetRgtBorder(), + nLeft, nRight); + pUndoGroup->AddAction(pUndo); + pPage->SetLftBorder(nLeft); + pPage->SetRgtBorder(nRight); + } + nPageCnt = GetDoc()->GetMasterSdPageCount(mePageKind); + + for (i = 0; i < nPageCnt; i++) + { + SdPage* pPage = GetDoc()->GetMasterSdPage(i, mePageKind); + SdUndoAction* pUndo = new SdPageLRUndoAction(GetDoc(), + pPage, + pPage->GetLftBorder(), + pPage->GetRgtBorder(), + nLeft, nRight); + pUndoGroup->AddAction(pUndo); + pPage->SetLftBorder(nLeft); + pPage->SetRgtBorder(nRight); + } + InvalidateWindows(); } + + // give the undo group to the undo manager + GetViewFrame()->GetObjectShell()->GetUndoManager()-> + AddUndoAction(pUndoGroup); } - else + break; + case SID_ATTR_LONG_ULSPACE: + if (pArgs) { - long nLeft = std::max(0L, rLRSpace.GetLeft() - aPagePos.X()); - long nRight = std::max(0L, rLRSpace.GetRight() + aPagePos.X() + - aPageSize.Width() - aViewSize.Width()); + SdUndoGroup* pUndoGroup = new SdUndoGroup(GetDoc()); + pUndoGroup->SetComment(SdResId(STR_UNDO_CHANGE_PAGEBORDER)); - sal_uInt16 nPageCnt = GetDoc()->GetSdPageCount(mePageKind); - sal_uInt16 i; - for ( i = 0; i < nPageCnt; i++) - { - SdPage* pPage = GetDoc()->GetSdPage(i, mePageKind); - SdUndoAction* pUndo = new SdPageLRUndoAction(GetDoc(), - pPage, - pPage->GetLftBorder(), - pPage->GetRgtBorder(), - nLeft, nRight); - pUndoGroup->AddAction(pUndo); - pPage->SetLftBorder(nLeft); - pPage->SetRgtBorder(nRight); - } - nPageCnt = GetDoc()->GetMasterSdPageCount(mePageKind); + const SvxLongULSpaceItem& rULSpace = static_cast( + pArgs->Get(GetPool().GetWhich(SID_ATTR_LONG_ULSPACE))); - for (i = 0; i < nPageCnt; i++) + if( mpDrawView->IsTextEdit() ) { - SdPage* pPage = GetDoc()->GetMasterSdPage(i, mePageKind); - SdUndoAction* pUndo = new SdPageLRUndoAction(GetDoc(), - pPage, - pPage->GetLftBorder(), - pPage->GetRgtBorder(), - nLeft, nRight); - pUndoGroup->AddAction(pUndo); - pPage->SetLftBorder(nLeft); - pPage->SetRgtBorder(nRight); + Rectangle aRect = maMarkRect; + aRect.SetPos(aRect.TopLeft() + aPagePos); + aRect.Top() = rULSpace.GetUpper(); + aRect.Bottom() = aViewSize.Height() - rULSpace.GetLower(); + aRect.SetPos(aRect.TopLeft() - aPagePos); + + if ( aRect != maMarkRect) + { + mpDrawView->SetAllMarkedRect(aRect); + maMarkRect = mpDrawView->GetAllMarkedRect(); + Invalidate( SID_RULER_OBJECT ); + } } - InvalidateWindows(); - } + else + { + long nUpper = std::max(0L, rULSpace.GetUpper() - aPagePos.Y()); + long nLower = std::max(0L, rULSpace.GetLower() + aPagePos.Y() + + aPageSize.Height() - aViewSize.Height()); - // give the undo group to the undo manager - GetViewFrame()->GetObjectShell()->GetUndoManager()-> - AddUndoAction(pUndoGroup); - break; - } - case SID_ATTR_LONG_ULSPACE: - { - SdUndoGroup* pUndoGroup = new SdUndoGroup(GetDoc()); - pUndoGroup->SetComment(SdResId(STR_UNDO_CHANGE_PAGEBORDER)); + sal_uInt16 nPageCnt = GetDoc()->GetSdPageCount(mePageKind); + sal_uInt16 i; + for ( i = 0; i < nPageCnt; i++) + { + SdPage* pPage = GetDoc()->GetSdPage(i, mePageKind); + SdUndoAction* pUndo = new SdPageULUndoAction(GetDoc(), + pPage, + pPage->GetUppBorder(), + pPage->GetLwrBorder(), + nUpper, nLower); + pUndoGroup->AddAction(pUndo); + pPage->SetUppBorder(nUpper); + pPage->SetLwrBorder(nLower); + } + nPageCnt = GetDoc()->GetMasterSdPageCount(mePageKind); - const SvxLongULSpaceItem& rULSpace = static_cast( - pArgs->Get(GetPool().GetWhich(SID_ATTR_LONG_ULSPACE))); + for (i = 0; i < nPageCnt; i++) + { + SdPage* pPage = GetDoc()->GetMasterSdPage(i, mePageKind); + SdUndoAction* pUndo = new SdPageULUndoAction(GetDoc(), + pPage, + pPage->GetUppBorder(), + pPage->GetLwrBorder(), + nUpper, nLower); + pUndoGroup->AddAction(pUndo); + pPage->SetUppBorder(nUpper); + pPage->SetLwrBorder(nLower); + } + InvalidateWindows(); + } - if( mpDrawView->IsTextEdit() ) + // give the undo group to the undo manager + GetViewFrame()->GetObjectShell()->GetUndoManager()-> + AddUndoAction(pUndoGroup); + } + break; + case SID_RULER_OBJECT: + if (pArgs) { Rectangle aRect = maMarkRect; aRect.SetPos(aRect.TopLeft() + aPagePos); - aRect.Top() = rULSpace.GetUpper(); - aRect.Bottom() = aViewSize.Height() - rULSpace.GetLower(); - aRect.SetPos(aRect.TopLeft() - aPagePos); - if ( aRect != maMarkRect) + const SvxObjectItem& rOI = static_cast( + pArgs->Get(GetPool().GetWhich(SID_RULER_OBJECT))); + + if ( rOI.GetStartX() != rOI.GetEndX() ) { - mpDrawView->SetAllMarkedRect(aRect); - maMarkRect = mpDrawView->GetAllMarkedRect(); - Invalidate( SID_RULER_OBJECT ); + aRect.Left() = rOI.GetStartX(); + aRect.Right() = rOI.GetEndX(); } - } - else - { - long nUpper = std::max(0L, rULSpace.GetUpper() - aPagePos.Y()); - long nLower = std::max(0L, rULSpace.GetLower() + aPagePos.Y() + - aPageSize.Height() - aViewSize.Height()); - - sal_uInt16 nPageCnt = GetDoc()->GetSdPageCount(mePageKind); - sal_uInt16 i; - for ( i = 0; i < nPageCnt; i++) + if ( rOI.GetStartY() != rOI.GetEndY() ) { - SdPage* pPage = GetDoc()->GetSdPage(i, mePageKind); - SdUndoAction* pUndo = new SdPageULUndoAction(GetDoc(), - pPage, - pPage->GetUppBorder(), - pPage->GetLwrBorder(), - nUpper, nLower); - pUndoGroup->AddAction(pUndo); - pPage->SetUppBorder(nUpper); - pPage->SetLwrBorder(nLower); + aRect.Top() = rOI.GetStartY(); + aRect.Bottom() = rOI.GetEndY(); } - nPageCnt = GetDoc()->GetMasterSdPageCount(mePageKind); - - for (i = 0; i < nPageCnt; i++) + aRect.SetPos(aRect.TopLeft() - aPagePos); + if ( aRect != maMarkRect) { - SdPage* pPage = GetDoc()->GetMasterSdPage(i, mePageKind); - SdUndoAction* pUndo = new SdPageULUndoAction(GetDoc(), - pPage, - pPage->GetUppBorder(), - pPage->GetLwrBorder(), - nUpper, nLower); - pUndoGroup->AddAction(pUndo); - pPage->SetUppBorder(nUpper); - pPage->SetLwrBorder(nLower); + mpDrawView->SetAllMarkedRect(aRect); + maMarkRect = mpDrawView->GetAllMarkedRect(); + Invalidate( SID_RULER_OBJECT ); } - InvalidateWindows(); } - - // give the undo group to the undo manager - GetViewFrame()->GetObjectShell()->GetUndoManager()-> - AddUndoAction(pUndoGroup); - break; - } - - case SID_RULER_OBJECT: - { - Rectangle aRect = maMarkRect; - aRect.SetPos(aRect.TopLeft() + aPagePos); - - const SvxObjectItem& rOI = static_cast( - pArgs->Get(GetPool().GetWhich(SID_RULER_OBJECT))); - - if ( rOI.GetStartX() != rOI.GetEndX() ) - { - aRect.Left() = rOI.GetStartX(); - aRect.Right() = rOI.GetEndX(); - } - if ( rOI.GetStartY() != rOI.GetEndY() ) - { - aRect.Top() = rOI.GetStartY(); - aRect.Bottom() = rOI.GetEndY(); - } - aRect.SetPos(aRect.TopLeft() - aPagePos); - if ( aRect != maMarkRect) - { - mpDrawView->SetAllMarkedRect(aRect); - maMarkRect = mpDrawView->GetAllMarkedRect(); - Invalidate( SID_RULER_OBJECT ); - } - break; - } - case SID_ATTR_TABSTOP: - { - if( mpDrawView->IsTextEdit() ) + if (pArgs && mpDrawView->IsTextEdit()) { const SvxTabStopItem& rItem = static_cast( pArgs->Get( EE_PARA_TABS )); @@ -666,23 +665,22 @@ void DrawViewShell::ExecRuler(SfxRequest& rReq) Invalidate(SID_ATTR_TABSTOP); } break; - } - case SID_ATTR_PARA_LINESPACE: - { - sal_uInt16 nSlot = SID_ATTR_PARA_LINESPACE; - SvxLineSpacingItem aParaLineSP = static_cast(pArgs->Get( - GetPool().GetWhich(nSlot))); + if (pArgs) + { + sal_uInt16 nSlot = SID_ATTR_PARA_LINESPACE; + SvxLineSpacingItem aParaLineSP = static_cast(pArgs->Get( + GetPool().GetWhich(nSlot))); - SfxItemSet aEditAttr( GetPool(), EE_PARA_SBL, EE_PARA_SBL ); - aParaLineSP.SetWhich( EE_PARA_SBL ); + SfxItemSet aEditAttr( GetPool(), EE_PARA_SBL, EE_PARA_SBL ); + aParaLineSP.SetWhich( EE_PARA_SBL ); - aEditAttr.Put( aParaLineSP ); - mpDrawView->SetAttributes( aEditAttr ); + aEditAttr.Put( aParaLineSP ); + mpDrawView->SetAttributes( aEditAttr ); - Invalidate(SID_ATTR_PARA_LINESPACE); - } - break; + Invalidate(SID_ATTR_PARA_LINESPACE); + } + break; case SID_ATTR_PARA_ADJUST_LEFT: { SvxAdjustItem aItem( SvxAdjust::Left, EE_PARA_JUST ); @@ -692,8 +690,8 @@ void DrawViewShell::ExecRuler(SfxRequest& rReq) mpDrawView->SetAttributes( aEditAttr ); Invalidate(SID_ATTR_PARA_ADJUST_LEFT); + break; } - break; case SID_ATTR_PARA_ADJUST_CENTER: { SvxAdjustItem aItem( SvxAdjust::Center, EE_PARA_JUST ); @@ -703,8 +701,8 @@ void DrawViewShell::ExecRuler(SfxRequest& rReq) mpDrawView->SetAttributes( aEditAttr ); Invalidate(SID_ATTR_PARA_ADJUST_CENTER); + break; } - break; case SID_ATTR_PARA_ADJUST_RIGHT: { SvxAdjustItem aItem( SvxAdjust::Right, EE_PARA_JUST ); @@ -714,8 +712,8 @@ void DrawViewShell::ExecRuler(SfxRequest& rReq) mpDrawView->SetAttributes( aEditAttr ); Invalidate(SID_ATTR_PARA_ADJUST_RIGHT); + break; } - break; case SID_ATTR_PARA_ADJUST_BLOCK: { SvxAdjustItem aItem( SvxAdjust::Block, EE_PARA_JUST ); @@ -725,41 +723,41 @@ void DrawViewShell::ExecRuler(SfxRequest& rReq) mpDrawView->SetAttributes( aEditAttr ); Invalidate(SID_ATTR_PARA_ADJUST_BLOCK); + break; } - break; case SID_ATTR_PARA_ULSPACE: - { - sal_uInt16 nSlot = SID_ATTR_PARA_ULSPACE; - SvxULSpaceItem aULSP = static_cast(pArgs->Get( - GetPool().GetWhich(nSlot))); - SfxItemSet aEditAttr( GetPool(), EE_PARA_ULSPACE, EE_PARA_ULSPACE ); - aULSP.SetWhich( EE_PARA_ULSPACE ); - - aEditAttr.Put( aULSP ); - mpDrawView->SetAttributes( aEditAttr ); + if (pArgs) + { + sal_uInt16 nSlot = SID_ATTR_PARA_ULSPACE; + SvxULSpaceItem aULSP = static_cast(pArgs->Get( + GetPool().GetWhich(nSlot))); + SfxItemSet aEditAttr( GetPool(), EE_PARA_ULSPACE, EE_PARA_ULSPACE ); + aULSP.SetWhich( EE_PARA_ULSPACE ); - Invalidate(SID_ATTR_PARA_ULSPACE); - } - break; + aEditAttr.Put( aULSP ); + mpDrawView->SetAttributes( aEditAttr ); + Invalidate(SID_ATTR_PARA_ULSPACE); + } + break; case SID_ATTR_PARA_LRSPACE: - { - sal_uInt16 nSlot = SID_ATTR_PARA_LRSPACE; - SvxLRSpaceItem aLRSpace = static_cast(pArgs->Get( - GetPool().GetWhich(nSlot))); + if (pArgs) + { + sal_uInt16 nSlot = SID_ATTR_PARA_LRSPACE; + SvxLRSpaceItem aLRSpace = static_cast(pArgs->Get( + GetPool().GetWhich(nSlot))); - SfxItemSet aEditAttr( GetPool(), EE_PARA_LRSPACE, EE_PARA_LRSPACE ); - aLRSpace.SetWhich( EE_PARA_LRSPACE ); + SfxItemSet aEditAttr( GetPool(), EE_PARA_LRSPACE, EE_PARA_LRSPACE ); + aLRSpace.SetWhich( EE_PARA_LRSPACE ); - aEditAttr.Put( aLRSpace ); - mpDrawView->SetAttributes( aEditAttr ); + aEditAttr.Put( aLRSpace ); + mpDrawView->SetAttributes( aEditAttr ); - Invalidate(SID_ATTR_PARA_LRSPACE); + Invalidate(SID_ATTR_PARA_LRSPACE); + } break; - } case SID_ATTR_LRSPACE: - { - if( mpDrawView->IsTextEdit() ) + if (pArgs && mpDrawView->IsTextEdit()) { sal_uInt16 nId = SID_ATTR_PARA_LRSPACE; const SvxLRSpaceItem& rItem = static_cast( @@ -846,7 +844,6 @@ void DrawViewShell::ExecRuler(SfxRequest& rReq) Invalidate(SID_ATTR_PARA_LRSPACE); } break; - } } } -- cgit v1.2.3