From d758875cd0ea87f8c7bbe1bbb78e49d06254cbee Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Fri, 16 May 2014 15:03:31 -0400 Subject: fdo#77315: When in cell edit mode, use the EditView instance already there. This prevents creation of a temporary EditView instance which would mess up the cursor state while the mouse pointer is hovering. (cherry picked from commit df51f7d486cafb2795a38ae9fedd8fde8827d8a4) (cherry picked from commit 8c8de51cc954aaae07f76732e6202398e33afeb7) Conflicts: sc/source/ui/view/gridwin.cxx Change-Id: I7759667b105b4389dd4de2673cd2fbe32082c95d Reviewed-on: https://gerrit.libreoffice.org/9386 Tested-by: Markus Mohrhard Reviewed-by: Markus Mohrhard --- sc/source/ui/view/gridwin.cxx | 55 ++++++++++++++++++++++++++----------------- 1 file changed, 34 insertions(+), 21 deletions(-) diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index c49d9ea826f4..1fa83c563e6e 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -63,6 +63,7 @@ #include #include #include +#include #include "gridwin.hxx" #include "tabvwsh.hxx" @@ -5190,11 +5191,43 @@ boost::shared_ptr createEditEngine( ScDocShell* pDocSh, const return pEngine; } +bool extractURLInfo( const SvxFieldItem* pFieldItem, OUString* pName, OUString* pUrl, OUString* pTarget ) +{ + if (!pFieldItem) + return false; + + const SvxFieldData* pField = pFieldItem->GetField(); + if (pField->GetClassId() != text::textfield::Type::URL) + return false; + + const SvxURLField* pURLField = static_cast(pField); + + if (pName) + *pName = pURLField->GetRepresentation(); + if (pUrl) + *pUrl = pURLField->GetURL(); + if (pTarget) + *pTarget = pURLField->GetTargetFrame(); + + return true; +} + } bool ScGridWindow::GetEditUrl( const Point& rPos, OUString* pName, OUString* pUrl, OUString* pTarget ) { + ScTabViewShell* pViewSh = pViewData->GetViewShell(); + ScInputHandler* pInputHdl = NULL; + if (pViewSh) + pInputHdl = pViewSh->GetInputHandler(); + + if (pInputHdl && pInputHdl->IsInputMode()) + { + EditView* pView = pInputHdl->GetTableView(); + return extractURLInfo(pView->GetFieldUnderMousePointer(), pName, pUrl, pTarget); + } + //! nPosX/Y mit uebergeben? SCsCOL nPosX; SCsROW nPosY; @@ -5303,27 +5336,7 @@ bool ScGridWindow::GetEditUrl( const Point& rPos, sal_Bool bRet = false; MapMode aOld = GetMapMode(); SetMapMode(aEditMode); // kein return mehr - - const SvxFieldItem* pFieldItem = aTempView.GetFieldUnderMousePointer(); - if (pFieldItem) - { - const SvxFieldData* pField = pFieldItem->GetField(); - if ( pField && pField->ISA(SvxURLField) ) - { - if ( pName || pUrl || pTarget ) - { - const SvxURLField* pURLField = (const SvxURLField*)pField; - if (pName) - *pName = pURLField->GetRepresentation(); - if (pUrl) - *pUrl = pURLField->GetURL(); - if (pTarget) - *pTarget = pURLField->GetTargetFrame(); - } - bRet = sal_True; - } - } - + bRet = extractURLInfo(aTempView.GetFieldUnderMousePointer(), pName, pUrl, pTarget); SetMapMode(aOld); return bRet; -- cgit v1.2.3