summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennard Wasserthal <Wasserthal@nefkom.net>2013-02-09 14:31:21 +0100
committerTor Lillqvist <tml@iki.fi>2013-02-11 10:10:29 +0000
commite80a8b6f14fac6bb6cc7ea55b118f95472d5b654 (patch)
tree7b3cf8169527aed8af7236ebd982b64673468d21
parent847749e975a7111ea306909a29fddb5df13e9a70 (diff)
fdo#55430 switches off text mode when clicking an other object.
This patch complements 85ea03ae536831649b104694d08dced4d4c8663f (and 6fbba11da54b52554941f00b07e42cc5d7a1643c, which didn't work correctly before) This also fixes issues when clicking on another object to stop text editing. Switches off text mode, and instantaneously selects the other object. (Rotation doesn't belong into the ./sd/ text routine AT ALL, which also caused bug 37482, which is resolved differently from now on) (Creating text fields doesn't belong into the ./sc/ shape text routine either, and if this executed, it causes funny glitches) Known issues: text mode stays on when you use drag'n drop (the one WITH waiting, to move to other applications etc). Change-Id: I3c8cdedbfae58165ebeda5887c1b6573832eb495 Signed-off-by: Lennard Wasserthal <Wasserthal@nefkom.net> Reviewed-on: https://gerrit.libreoffice.org/1344 Reviewed-by: Tor Lillqvist <tml@iki.fi> Tested-by: Tor Lillqvist <tml@iki.fi>
-rw-r--r--sc/source/ui/drawfunc/fusel.cxx28
-rw-r--r--sc/source/ui/drawfunc/futext.cxx41
-rw-r--r--sd/source/ui/func/fusel.cxx5
-rw-r--r--sd/source/ui/func/futext.cxx22
-rw-r--r--sw/source/ui/docvw/edtwin.cxx8
5 files changed, 77 insertions, 27 deletions
diff --git a/sc/source/ui/drawfunc/fusel.cxx b/sc/source/ui/drawfunc/fusel.cxx
index 4968f15e47c0..a3568b0992fb 100644
--- a/sc/source/ui/drawfunc/fusel.cxx
+++ b/sc/source/ui/drawfunc/fusel.cxx
@@ -53,6 +53,8 @@
// Maximal erlaubte Mausbewegung um noch Drag&Drop zu starten
//! fusel,fuconstr,futext - zusammenfassen!
#define SC_MAXDRAGMOVE 3
+// Min necessary mouse motion for normal dragging
+#define SC_MINDRAGMOVE 2
// -----------------------------------------------------------------------
@@ -381,11 +383,14 @@ sal_Bool FuSelection::MouseButtonUp(const MouseEvent& rMEvt)
sal_Bool bReturn = FuDraw::MouseButtonUp(rMEvt);
sal_Bool bOle = pViewShell->GetViewFrame()->GetFrame().IsInPlace();
+ SdrObject* pObj = NULL;
+ SdrPageView* pPV = NULL;
if (aDragTimer.IsActive() )
{
aDragTimer.Stop();
}
+ sal_uInt16 nDrgLog = sal_uInt16 ( pWindow->PixelToLogic(Size(SC_MINDRAGMOVE,0)).Width() );
Point aPnt( pWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
bool bCopy = false;
@@ -416,7 +421,7 @@ sal_Bool FuSelection::MouseButtonUp(const MouseEvent& rMEvt)
for ( sal_uLong i = 0; i < nMarkCount; ++i )
{
SdrMark* pMark = rSdrMarkList.GetMark( i );
- SdrObject* pObj = ( pMark ? pMark->GetMarkedSdrObj() : NULL );
+ pObj = ( pMark ? pMark->GetMarkedSdrObj() : NULL );
if ( pObj )
{
ScChartHelper::AddRangesIfProtectedChart( aProtectedChartRangesVector, pDocument, pObj );
@@ -426,6 +431,21 @@ sal_Bool FuSelection::MouseButtonUp(const MouseEvent& rMEvt)
bCopy = true;
}
+ if (!rMEvt.IsShift() && !rMEvt.IsMod1() && !rMEvt.IsMod2() &&
+ Abs(aPnt.X() - aMDPos.X()) < nDrgLog &&
+ Abs(aPnt.Y() - aMDPos.Y()) < nDrgLog)
+ {
+ /*************************************************************
+ * If a user wants to click on an object in front of a marked
+ * one, he releases the mouse button immediately
+ **************************************************************/
+ if (pView->PickObj(aMDPos, pView->getHitTolLog(), pObj, pPV, SDRSEARCH_ALSOONMASTER | SDRSEARCH_BEFOREMARK))
+ {
+ pView->UnmarkAllObj();
+ pView->MarkObj(pObj,pPV,false,false);
+ return (sal_True);
+ }
+ }
pView->EndDragObj( rMEvt.IsMod1() );
pView->ForceMarkedToAnotherPage();
@@ -433,7 +453,7 @@ sal_Bool FuSelection::MouseButtonUp(const MouseEvent& rMEvt)
if (rMarkList.GetMarkCount() == 1)
{
SdrMark* pMark = rMarkList.GetMark(0);
- SdrObject* pObj = pMark->GetMarkedSdrObj();
+ pObj = pMark->GetMarkedSdrObj();
FuPoor* pPoor = pViewShell->GetViewData()->GetView()->GetDrawFuncPtr();
FuText* pText = static_cast<FuText*>(pPoor);
pText->StopDragMode(pObj );
@@ -458,7 +478,7 @@ sal_Bool FuSelection::MouseButtonUp(const MouseEvent& rMEvt)
bool bFound = false;
for( sal_uLong nIdx = 0; !bFound && (nIdx < nCount); ++nIdx )
{
- SdrObject* pObj = rMarkList.GetMark( nIdx )->GetMarkedSdrObj();
+ pObj = rMarkList.GetMark( nIdx )->GetMarkedSdrObj();
bFound = ScDrawLayer::IsNoteCaption( pObj );
if( bFound )
{
@@ -494,7 +514,7 @@ sal_Bool FuSelection::MouseButtonUp(const MouseEvent& rMEvt)
if (rMarkList.GetMarkCount() == 1)
{
SdrMark* pMark = rMarkList.GetMark(0);
- SdrObject* pObj = pMark->GetMarkedSdrObj();
+ pObj = pMark->GetMarkedSdrObj();
// aktivieren nur, wenn die Maus auch (noch) ueber dem
// selektierten Objekt steht
diff --git a/sc/source/ui/drawfunc/futext.cxx b/sc/source/ui/drawfunc/futext.cxx
index 6be3b9d641de..b1963c281d35 100644
--- a/sc/source/ui/drawfunc/futext.cxx
+++ b/sc/source/ui/drawfunc/futext.cxx
@@ -125,6 +125,7 @@ sal_Bool FuText::MouseButtonDown(const MouseEvent& rMEvt)
{
// remember button state for creation of own MouseEvents
SetMouseButtonCode(rMEvt.GetButtons());
+ sal_Bool bStraightEnter = true;
if ( pView->MouseButtonDown(rMEvt, pWindow) )
return (sal_True); // Event von der SdrView ausgewertet
@@ -132,7 +133,13 @@ sal_Bool FuText::MouseButtonDown(const MouseEvent& rMEvt)
if ( pView->IsTextEdit() )
{
if( !IsSizingOrMovingNote(rMEvt) )
+ {
StopEditMode(); // Danebengeklickt, Ende mit Edit
+ pView->UnmarkAll();
+ bStraightEnter = false;
+ ScViewData& rViewData = *pViewShell->GetViewData();
+ rViewData.GetDispatcher().Execute(aSfxRequest.GetSlot(), SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD);
+ }
pView->SetCreateMode();
}
@@ -302,18 +309,30 @@ sal_Bool FuText::MouseButtonDown(const MouseEvent& rMEvt)
}
else
{
- /**********************************************************
- * Objekt erzeugen
- **********************************************************/
- // Hack to align object to nearest grid position where object
- // would be anchored ( if it were cell anchored )
- // Get grid offset for current position ( note: aPnt is
- // also adjusted )
- Point aGridOff = CurrentGridSyncOffsetAndPos( aMDPos );
-
- bool bRet = pView->BegCreateObj(aMDPos, (OutputDevice*) NULL);
- if ( bRet )
+ if (bStraightEnter)//Hack for that silly idea that creating text fields is inside the text routine
+ {
+ /**********************************************************
+ * Objekt erzeugen
+ **********************************************************/
+ // Hack to align object to nearest grid position where object
+ // would be anchored ( if it were cell anchored )
+ // Get grid offset for current position ( note: aPnt is
+ // also adjusted )
+ Point aGridOff = CurrentGridSyncOffsetAndPos( aMDPos );
+
+ bool bRet = pView->BegCreateObj(aMDPos, (OutputDevice*) NULL);
+ if ( bRet )
pView->GetCreateObj()->SetGridOffset( aGridOff );
+ }
+ else if (pView->PickObj(aMDPos, pView->getHitTolLog(), pObj, pPV, SDRSEARCH_ALSOONMASTER | SDRSEARCH_BEFOREMARK))
+ {
+ pView->UnmarkAllObj();
+ pView->MarkObj(pObj,pPV,false,false);
+
+ pHdl=pView->PickHandle(aMDPos);
+ pView->BegDragObj(aMDPos, (OutputDevice*) NULL, pHdl);
+ return(sal_True);
+ }
}
}
}
diff --git a/sd/source/ui/func/fusel.cxx b/sd/source/ui/func/fusel.cxx
index 827099e62ccd..196a3ccff05c 100644
--- a/sd/source/ui/func/fusel.cxx
+++ b/sd/source/ui/func/fusel.cxx
@@ -687,15 +687,14 @@ sal_Bool FuSelection::MouseButtonUp(const MouseEvent& rMEvt)
Abs(aPnt.Y() - aMDPos.Y()) < nDrgLog)
{
/*************************************************************
- * If a user wants to click on an object in front of a masked
+ * If a user wants to click on an object in front of a marked
* one, he releases the mouse button immediately
**************************************************************/
if (mpView->PickObj(aMDPos, mpView->getHitTolLog(), pObj, pPV, SDRSEARCH_ALSOONMASTER | SDRSEARCH_BEFOREMARK))
{
- //not Needed in the ordinary pick routine for some reason...
mpView->UnmarkAllObj();
mpView->MarkObj(pObj,pPV,false,false);
- return (bReturn);
+ return (sal_True);
}
/**************************************************************
* Toggle between selection and rotation
diff --git a/sd/source/ui/func/futext.cxx b/sd/source/ui/func/futext.cxx
index 49c4b1aa46ad..2b5d3ceb4443 100644
--- a/sd/source/ui/func/futext.cxx
+++ b/sd/source/ui/func/futext.cxx
@@ -251,6 +251,7 @@ void FuText::DoExecute( SfxRequest& )
sal_Bool FuText::MouseButtonDown(const MouseEvent& rMEvt)
{
bMBDown = sal_True;
+ bJustEndedEdit = false;
sal_Bool bReturn = FuDraw::MouseButtonDown(rMEvt);
@@ -674,14 +675,18 @@ sal_Bool FuText::MouseButtonUp(const MouseEvent& rMEvt)
sal_uInt16 nDrgLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
- if ( mpView->IsRotateAllowed() && mpViewShell->GetFrameView()->IsClickChangeRotation() && (rMEvt.GetClicks() != 2) && !bJustEndedEdit &&
+ if (bJustEndedEdit)
+ {
+ bJustEndedEdit = false;
+ FuPoor::cancel();
+ }
+ if ((rMEvt.GetClicks() != 2) &&
!rMEvt.IsShift() && !rMEvt.IsMod1() && !rMEvt.IsMod2() && !rMEvt.IsRight() &&
Abs(aPnt.X() - aMDPos.X()) < nDrgLog &&
Abs(aPnt.Y() - aMDPos.Y()) < nDrgLog)
{
/*************************************************************
- * If a user wants to click on an object in front of a masked
- * one, he releases the mouse button immediately
+ * From text mode, you don't want to rotate immediately.
**************************************************************/
if (mpView->PickObj(aMDPos, mpView->getHitTolLog(), pObj, pPV, SDRSEARCH_ALSOONMASTER | SDRSEARCH_BEFOREMARK))
{
@@ -689,12 +694,7 @@ sal_Bool FuText::MouseButtonUp(const MouseEvent& rMEvt)
mpView->MarkObj(pObj,pPV,false,false);
return (bReturn);
}
- // toggle to rotation mode
- mpViewShell->GetViewFrame()->GetDispatcher()->Execute( SID_OBJECT_ROTATE, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD );
}
-
- if( bJustEndedEdit )
- bJustEndedEdit = false;
}
else if( mpView && mpView->IsCreateObj() && rMEvt.IsLeft())
{
@@ -914,7 +914,11 @@ sal_Bool FuText::MouseButtonUp(const MouseEvent& rMEvt)
SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD );
}
}
-
+ if (bJustEndedEdit)
+ {
+ bJustEndedEdit = false;
+ FuPoor::cancel();
+ }
bMBDown = sal_False;
FuConstruct::MouseButtonUp(rMEvt);
return (bReturn);
diff --git a/sw/source/ui/docvw/edtwin.cxx b/sw/source/ui/docvw/edtwin.cxx
index 6ea4fec80a64..5258143ae667 100644
--- a/sw/source/ui/docvw/edtwin.cxx
+++ b/sw/source/ui/docvw/edtwin.cxx
@@ -2726,6 +2726,8 @@ void SwEditWin::MouseButtonDown(const MouseEvent& _rMEvt)
{
SwWrtShell &rSh = rView.GetWrtShell();
+ SdrObject* pObj;
+ SdrPageView* pPV;
// We have to check if a context menu is shown and we have an UI
// active inplace client. In that case we have to ignore the mouse
// button down event. Otherwise we would crash (context menu has been
@@ -3035,6 +3037,12 @@ void SwEditWin::MouseButtonDown(const MouseEvent& _rMEvt)
// only if no position to size was hit.
if (!bHitHandle)
{
+ if (pSdrView->PickObj(aDocPos, pSdrView->getHitTolLog(), pObj, pPV, SDRSEARCH_ALSOONMASTER | SDRSEARCH_BEFOREMARK))
+ {
+ pSdrView->UnmarkAllObj();
+ pSdrView->MarkObj(pObj,pPV,false,false);
+ return;
+ }
StartDDTimer();
SwEditWin::nDDStartPosY = aDocPos.Y();
SwEditWin::nDDStartPosX = aDocPos.X();