diff options
Diffstat (limited to 'sd/source/ui/func')
-rw-r--r-- | sd/source/ui/func/fusnapln.cxx | 57 |
1 files changed, 39 insertions, 18 deletions
diff --git a/sd/source/ui/func/fusnapln.cxx b/sd/source/ui/func/fusnapln.cxx index dfd50a00ec5d..28bb58538d85 100644 --- a/sd/source/ui/func/fusnapln.cxx +++ b/sd/source/ui/func/fusnapln.cxx @@ -49,6 +49,7 @@ #include "sdenumdef.hxx" #include "sdresid.hxx" #include "sdabstdlg.hxx" +#include "app.hrc" #include <svx/svdpagv.hxx> namespace sd { @@ -81,32 +82,52 @@ void FuSnapLine::DoExecute( SfxRequest& rReq ) USHORT nHelpLine = 0; BOOL bCreateNew = TRUE; - if ( !pArgs ) + // Get index of snap line or snap point from the request. + SFX_REQUEST_ARG (rReq, pHelpLineIndex, SfxUInt32Item, ID_VAL_INDEX, FALSE); + if (pHelpLineIndex != NULL) { - SfxItemSet aNewAttr(mpViewShell->GetPool(), ATTR_SNAPLINE_START, - ATTR_SNAPLINE_END); - Point aLinePos = static_cast<DrawViewShell*>(mpViewShell)->GetMousePos(); - static_cast<DrawViewShell*>(mpViewShell)->SetMousePosFreezed( FALSE ); - BOOL bLineExist = FALSE; + nHelpLine = static_cast<USHORT>(pHelpLineIndex->GetValue()); + // Reset the argument pointer to trigger the display of the dialog. + pArgs = NULL; + } + if ( !pArgs ) + { + SfxItemSet aNewAttr(mpViewShell->GetPool(), ATTR_SNAPLINE_START, ATTR_SNAPLINE_END); + bool bLineExist (false); pPV = mpView->GetSdrPageView(); + Point aLinePos; - if ( aLinePos.X() >= 0 ) + if (pHelpLineIndex == NULL) { - aLinePos = mpWindow->PixelToLogic(aLinePos); - USHORT nHitLog = (USHORT) mpWindow->PixelToLogic(Size(HITPIX,0)).Width(); - bLineExist = mpView->PickHelpLine(aLinePos, nHitLog, *mpWindow, - nHelpLine, pPV); - if ( bLineExist ) - aLinePos = (pPV->GetHelpLines())[nHelpLine].GetPos(); - else - pPV = mpView->GetSdrPageView(); + // The index of the snap line is not provided as argument to the + // request. Determine it from the mouse position. + + aLinePos = static_cast<DrawViewShell*>(mpViewShell)->GetMousePos(); + static_cast<DrawViewShell*>(mpViewShell)->SetMousePosFreezed( FALSE ); + - pPV->LogicToPagePos(aLinePos); + if ( aLinePos.X() >= 0 ) + { + aLinePos = mpWindow->PixelToLogic(aLinePos); + USHORT nHitLog = (USHORT) mpWindow->PixelToLogic(Size(HITPIX,0)).Width(); + bLineExist = mpView->PickHelpLine(aLinePos, nHitLog, *mpWindow, nHelpLine, pPV); + if ( bLineExist ) + aLinePos = (pPV->GetHelpLines())[nHelpLine].GetPos(); + else + pPV = mpView->GetSdrPageView(); + + pPV->LogicToPagePos(aLinePos); + } + else + aLinePos = Point(0,0); } else - aLinePos = Point(0,0); - + { + OSL_ASSERT(pPV!=NULL); + aLinePos = (pPV->GetHelpLines())[nHelpLine].GetPos(); + bLineExist = true; + } aNewAttr.Put(SfxUInt32Item(ATTR_SNAPLINE_X, aLinePos.X())); aNewAttr.Put(SfxUInt32Item(ATTR_SNAPLINE_Y, aLinePos.Y())); |