summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2017-03-16 10:50:37 +0000
committerMichael Stahl <mstahl@redhat.com>2017-03-21 15:23:42 +0000
commit5d1c37e416d856a07c3dc6a51381eabb13c467ae (patch)
treeebf913e83d7855028ae4c5cd049406d83aea657b
parent248aec4e966a99e411f46950722f0684b6286b2c (diff)
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 (cherry picked from commit ab10f03ec4dc7d5d7659fb62c59972c80221f733) Reviewed-on: https://gerrit.libreoffice.org/35262 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Michael Stahl <mstahl@redhat.com>
-rw-r--r--sd/source/ui/view/drviews3.cxx351
1 files changed, 174 insertions, 177 deletions
diff --git a/sd/source/ui/view/drviews3.cxx b/sd/source/ui/view/drviews3.cxx
index 307ee4f4db9f..aae1b9e91ec4 100644
--- a/sd/source/ui/view/drviews3.cxx
+++ b/sd/source/ui/view/drviews3.cxx
@@ -496,167 +496,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<const SvxLongLRSpaceItem&>(
- pArgs->Get(GetPool().GetWhich(SID_ATTR_LONG_LRSPACE)));
+ const SvxLongLRSpaceItem& rLRSpace = static_cast<const SvxLongLRSpaceItem&>(
+ 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<const SvxLongULSpaceItem&>(
+ 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<const SvxLongULSpaceItem&>(
- 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<const SvxObjectItem&>(
+ 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<const SvxObjectItem&>(
- 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<const SvxTabStopItem&>(
pArgs->Get( EE_PARA_TABS ));
@@ -669,23 +668,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<const SvxLineSpacingItem&>(pArgs->Get(
- GetPool().GetWhich(nSlot)));
+ if (pArgs)
+ {
+ sal_uInt16 nSlot = SID_ATTR_PARA_LINESPACE;
+ SvxLineSpacingItem aParaLineSP = static_cast<const SvxLineSpacingItem&>(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( SVX_ADJUST_LEFT, EE_PARA_JUST );
@@ -695,8 +693,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( SVX_ADJUST_CENTER, EE_PARA_JUST );
@@ -706,8 +704,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( SVX_ADJUST_RIGHT, EE_PARA_JUST );
@@ -717,8 +715,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( SVX_ADJUST_BLOCK, EE_PARA_JUST );
@@ -728,41 +726,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<const SvxULSpaceItem&>(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<const SvxULSpaceItem&>(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<const SvxLRSpaceItem&>(pArgs->Get(
- GetPool().GetWhich(nSlot)));
+ if (pArgs)
+ {
+ sal_uInt16 nSlot = SID_ATTR_PARA_LRSPACE;
+ SvxLRSpaceItem aLRSpace = static_cast<const SvxLRSpaceItem&>(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<const SvxLRSpaceItem&>(
@@ -849,7 +847,6 @@ void DrawViewShell::ExecRuler(SfxRequest& rReq)
Invalidate(SID_ATTR_PARA_LRSPACE);
}
break;
- }
}
}