[Libreoffice-commits] core.git: sc/source

Kohei Yoshida kohei.yoshida at collabora.com
Fri May 16 13:20:18 PDT 2014


 sc/source/ui/view/gridwin.cxx |   55 +++++++++++++++++++++++++-----------------
 1 file changed, 34 insertions(+), 21 deletions(-)

New commits:
commit df51f7d486cafb2795a38ae9fedd8fde8827d8a4
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Fri May 16 15:03:31 2014 -0400

    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.
    
    Change-Id: I7759667b105b4389dd4de2673cd2fbe32082c95d

diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 2226ab1..ff7693d 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -64,6 +64,7 @@
 #include <com/sun/star/awt/MouseButton.hpp>
 #include <com/sun/star/script/vba/VBAEventId.hpp>
 #include <com/sun/star/script/vba/XVBAEventProcessor.hpp>
+#include <com/sun/star/text/textfield/Type.hpp>
 
 #include "gridwin.hxx"
 #include "tabvwsh.hxx"
@@ -5205,11 +5206,43 @@ boost::shared_ptr<ScFieldEditEngine> 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<const SvxURLField*>(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->IsInputMode())
+    {
+        EditView* pView = pInputHdl->GetTableView();
+        return extractURLInfo(pView->GetFieldUnderMousePointer(), pName, pUrl, pTarget);
+    }
+
     //! nPosX/Y mit uebergeben?
     SCsCOL nPosX;
     SCsROW nPosY;
@@ -5318,27 +5351,7 @@ bool ScGridWindow::GetEditUrl( const Point& rPos,
         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 = true;
-            }
-        }
-
+        bRet = extractURLInfo(aTempView.GetFieldUnderMousePointer(), pName, pUrl, pTarget);
         SetMapMode(aOld);
 
         return bRet;


More information about the Libreoffice-commits mailing list