[Libreoffice-commits] .: Branch 'libreoffice-4-0' - sc/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Dec 11 09:13:20 PST 2012


 sc/source/core/tool/address.cxx |   17 ++++++++++++++
 sc/source/ui/view/gridwin.cxx   |   47 +++++++++++++++++++++++++++++++++++++++-
 2 files changed, 63 insertions(+), 1 deletion(-)

New commits:
commit 3f69a82ceab665224dc39067f4d686e2be9c5eb5
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Tue Dec 11 12:09:21 2012 -0500

    Support non 'Calc A1' reference syntax in HYPERLINK function.
    
    It uses the current formula syntax set in the Formula options page
    to interpret the URL in HYPERLINK function.
    
    Change-Id: Ic394d10b1e781fcd6a6949f62949c5cb137328bc

diff --git a/sc/source/core/tool/address.cxx b/sc/source/core/tool/address.cxx
index 34a7306..08e29de 100644
--- a/sc/source/core/tool/address.cxx
+++ b/sc/source/core/tool/address.cxx
@@ -156,7 +156,24 @@ static bool lcl_ScRange_External_TabSpan(
 
     ScExternalRefManager* pRefMgr = pDoc->GetExternalRefManager();
     if (pRefMgr->isOwnDocument( rExternDocName))
+    {
+        // This is an internal document.  Get the sheet positions from the
+        // ScDocument instance.
+        if (rStartTabName.Len())
+        {
+            SCTAB nTab;
+            if (pDoc->GetTable(rStartTabName, nTab))
+                rRange.aStart.SetTab(nTab);
+        }
+
+        if (rEndTabName.Len())
+        {
+            SCTAB nTab;
+            if (pDoc->GetTable(rEndTabName, nTab))
+                rRange.aEnd.SetTab(nTab);
+        }
         return !pExtInfo || !pExtInfo->mbExternal;
+    }
 
     sal_uInt16 nFileId = pRefMgr->getExternalFileId( rExternDocName);
 
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index c116d43..be9520d 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -119,6 +119,7 @@
 #include "markdata.hxx"
 #include "checklistmenu.hrc"
 #include "strload.hxx"
+#include "externalrefmgr.hxx"
 
 #include <svx/sdrpagewindow.hxx>
 #include <svx/sdr/overlay/overlaymanager.hxx>
@@ -2371,7 +2372,51 @@ void ScGridWindow::MouseButtonUp( const MouseEvent& rMEvt )
         if ( GetEditUrl( rMEvt.GetPosPixel(), &aName, &aUrl, &aTarget ) )
         {
             nMouseStatus = SC_GM_NONE;              // keinen Doppelklick anfangen
-            ScGlobal::OpenURL( aUrl, aTarget );
+
+            // ScGlobal::OpenURL() only understands Calc A1 style syntax.
+            // Convert it to Calc A1 before calling OpenURL().
+
+            if (pDoc->GetAddressConvention() == formula::FormulaGrammar::CONV_OOO)
+                ScGlobal::OpenURL(aUrl, aTarget);
+            else
+            {
+                ScAddress aTempAddr;
+                ScAddress::ExternalInfo aExtInfo;
+                sal_uInt16 nRes = aTempAddr.Parse(aUrl, pDoc, pDoc->GetAddressConvention(), &aExtInfo);
+                if (!(nRes & SCA_VALID))
+                {
+                    // Not a reference string. Pass it through unmodified.
+                    ScGlobal::OpenURL(aUrl, aTarget);
+                    return;
+                }
+
+                OUStringBuffer aBuf;
+                if (aExtInfo.mbExternal)
+                {
+                    // External reference.
+                    ScExternalRefManager* pRefMgr = pDoc->GetExternalRefManager();
+                    const OUString* pStr = pRefMgr->getExternalFileName(aExtInfo.mnFileId);
+                    if (pStr)
+                        aBuf.append(*pStr);
+
+                    aBuf.append('#');
+                    aBuf.append(aExtInfo.maTabName);
+                    aBuf.append('.');
+                    OUString aRefCalcA1;
+                    aTempAddr.Format(aRefCalcA1, SCA_ABS, NULL, formula::FormulaGrammar::CONV_OOO);
+                    aBuf.append(aRefCalcA1);
+                    ScGlobal::OpenURL(aBuf.makeStringAndClear(), aTarget);
+                }
+                else
+                {
+                    // Internal reference.
+                    aBuf.append('#');
+                    OUString aUrlCalcA1;
+                    aTempAddr.Format(aUrlCalcA1, SCA_ABS_3D, pDoc, formula::FormulaGrammar::CONV_OOO);
+                    aBuf.append(aUrlCalcA1);
+                    ScGlobal::OpenURL(aBuf.makeStringAndClear(), aTarget);
+                }
+            }
 
             // fire worksheet_followhyperlink event
             uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents = pDoc->GetVbaEventProcessor();


More information about the Libreoffice-commits mailing list