sw/source/ui/docvw/edtwin.cxx | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-)
New commits: commit 3925a10d4784cf5966c5ee182dd64296b1cfba21 Author: Miklos Vajna <vmik...@suse.cz> Date: Tue Sep 11 11:02:22 2012 +0200 n#778148 SwEditWin::MouseButtonDown: prefer url over hell frames on ctrl-click This reverts commit 549da29af80c9d5b64b4c1bcec40b9c81f471a4f and fixes the problem without breaking text selection in front of background images. To reproduce, create a large XShape, put it to the background, set wrap style to 'through', then add some text, including a hyperlink. Click should select text, ctrl-click should select the hyperlink, or in case the text is normal, the shape. Change-Id: I6cd62af30b58555f8b58c7db4648444fceba83dc diff --git a/sw/source/ui/docvw/edtwin.cxx b/sw/source/ui/docvw/edtwin.cxx index 1188c61..ad26ab3 100644 --- a/sw/source/ui/docvw/edtwin.cxx +++ b/sw/source/ui/docvw/edtwin.cxx @@ -492,12 +492,10 @@ void SwEditWin::UpdatePointer(const Point &rLPt, sal_uInt16 nModifier ) } else { - // Background images don't count. - SdrObject* pSelectableObj = rSh.GetObjAt(rLPt); // dvo: IsObjSelectable() eventually calls SdrView::PickObj, so // apparently this is used to determine whether this is a // drawling layer object or not. - if ( rSh.IsObjSelectable( rLPt ) && pSelectableObj->GetLayer() != rSh.GetDoc()->GetHellId()) + if ( rSh.IsObjSelectable( rLPt ) ) { if (pSdrView->IsTextEdit()) { @@ -525,7 +523,10 @@ void SwEditWin::UpdatePointer(const Point &rLPt, sal_uInt16 nModifier ) (rSh.IsObjSelected() || rSh.IsFrmSelected()) && (!rSh.IsSelObjProtected(FLYPROTECT_POS)); - eStyle = bMovable ? POINTER_MOVE : POINTER_ARROW; + SdrObject* pSelectableObj = rSh.GetObjAt(rLPt); + // Don't update pointer if this is a background image only. + if (pSelectableObj->GetLayer() != rSh.GetDoc()->GetHellId()) + eStyle = bMovable ? POINTER_MOVE : POINTER_ARROW; aActHitType = SDRHIT_OBJECT; } } @@ -2750,6 +2751,18 @@ void SwEditWin::RstMBDownFlags() ReleaseMouse(); } +/** + * Determines if the current position has a clickable url over a background + * frame. In that case, ctrl-click should select the url, not the frame. + */ +bool lcl_urlOverBackground(SwWrtShell& rSh, const Point& rDocPos) +{ + SwContentAtPos aSwContentAtPos(SwContentAtPos::SW_INETATTR); + SdrObject* pSelectableObj = rSh.GetObjAt(rDocPos); + + return rSh.GetContentAtPos(rDocPos, aSwContentAtPos) && pSelectableObj->GetLayer() == rSh.GetDoc()->GetHellId(); +} + void SwEditWin::MouseButtonDown(const MouseEvent& _rMEvt) { SwWrtShell &rSh = rView.GetWrtShell(); @@ -3370,7 +3383,7 @@ void SwEditWin::MouseButtonDown(const MouseEvent& _rMEvt) case KEY_MOD1: if ( !bExecDrawTextLink ) { - if ( !bInsDraw && IsDrawObjSelectable( rSh, aDocPos ) ) + if ( !bInsDraw && IsDrawObjSelectable( rSh, aDocPos ) && !lcl_urlOverBackground( rSh, aDocPos ) ) { rView.NoRotate(); rSh.HideCrsr(); @@ -3566,9 +3579,9 @@ void SwEditWin::MouseButtonDown(const MouseEvent& _rMEvt) const int nSelType = rSh.GetSelectionType(); // Check in general, if an object is selectable at given position. // Thus, also text fly frames in background become selectable via Ctrl-Click. - if ( nSelType & nsSelectionType::SEL_OLE || + if ( ( nSelType & nsSelectionType::SEL_OLE || nSelType & nsSelectionType::SEL_GRF || - rSh.IsObjSelectable( aDocPos ) ) + rSh.IsObjSelectable( aDocPos ) ) && !lcl_urlOverBackground( rSh, aDocPos ) ) { SwMvContext aMvContext( &rSh ); if( !rSh.IsFrmSelected() ) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits