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

Akash Shetye shetyeakash at gmail.com
Mon Jun 24 07:25:07 PDT 2013


 sc/inc/globstr.hrc             |    5 +++-
 sc/source/core/data/global.cxx |   20 ++++++++---------
 sc/source/ui/src/globstr.src   |    8 ++++++
 sc/source/ui/view/gridwin5.cxx |   48 +++++++++++++++++++++++++++++++++++++----
 4 files changed, 66 insertions(+), 15 deletions(-)

New commits:
commit c13daee32de1be4b96d6a948cfca4aa0bdf8c4db
Author: Akash Shetye <shetyeakash at gmail.com>
Date:   Mon May 27 17:37:54 2013 +0530

    fdo#51296 Helptext added for hyperlinks, hlinks behave as in writer
    
    Added prefixed of "ctrl+click to open hyperlink" to hlinks depending on the security setting. Now clicking links behave as in writer.
    
    Change-Id: I87d0fecb6268463cd99478b70eb081ed958976be
    Reviewed-on: https://gerrit.libreoffice.org/4051
    Signed-off-by: Luboš Luňák <l.lunak at suse.cz>

diff --git a/sc/inc/globstr.hrc b/sc/inc/globstr.hrc
index f9fda26..314f29a 100644
--- a/sc/inc/globstr.hrc
+++ b/sc/inc/globstr.hrc
@@ -678,7 +678,10 @@
 #define STR_COPYFROM                549
 #define STR_COPYERR                 550
 
-#define STR_COUNT                   551
+#define STR_CTRLCLICKHYPERLINK      551
+#define STR_CLICKHYPERLINK          552
+
+#define STR_COUNT                   553
 
 #endif
 
diff --git a/sc/source/core/data/global.cxx b/sc/source/core/data/global.cxx
index 95084a9..a34b1de 100644
--- a/sc/source/core/data/global.cxx
+++ b/sc/source/core/data/global.cxx
@@ -925,20 +925,20 @@ void ScGlobal::OpenURL( const String& rURL, const String& rTarget )
     //  aufgerufen, darum stimmen pScActiveViewShell und nScClickMouseModifier.
     //SvtSecurityOptions to access Libreoffice global security parameters
     SvtSecurityOptions aSecOpt;
-    bool bProceedHyperlink = false;
-    if ( (nScClickMouseModifier & KEY_MOD1) && aSecOpt.IsOptionSet( SvtSecurityOptions::E_CTRLCLICK_HYPERLINK ))     // control-click -> into new window
+    bool bCtrlClickHappened = (nScClickMouseModifier & KEY_MOD1);
+    bool bCtrlClickSecOption = aSecOpt.IsOptionSet( SvtSecurityOptions::E_CTRLCLICK_HYPERLINK );
+    if( bCtrlClickHappened && !( bCtrlClickSecOption ) )
     {
-        //Ctrl key is pressed and ctrl+click hyperlink security control is set
-        bProceedHyperlink = true;
+        //return since ctrl+click happened when the
+        //ctrl+click security option was disabled, link should not open
+        return;
     }
-    else if( !aSecOpt.IsOptionSet( SvtSecurityOptions::E_CTRLCLICK_HYPERLINK ) )
+    else if( !( bCtrlClickHappened ) && bCtrlClickSecOption )
     {
-        //ctrl+click hyperlink security control is disabled just click will do
-        bProceedHyperlink = true;
-    }
-    if ( !bProceedHyperlink )
+        //ctrl+click did not happen; only click happened maybe with some
+        //other key combo. and security option is set, so return
         return;
-
+    }
     SfxStringItem aUrl( SID_FILE_NAME, rURL );
     SfxStringItem aTarget( SID_TARGETNAME, rTarget );
     aTarget.SetValue(OUString("_blank"));
diff --git a/sc/source/ui/src/globstr.src b/sc/source/ui/src/globstr.src
index af236f9..bd9579c 100644
--- a/sc/source/ui/src/globstr.src
+++ b/sc/source/ui/src/globstr.src
@@ -2081,6 +2081,14 @@ Resource RID_GLOBSTR
     {
         Text [ en-US ] = "Cells without text have been ignored." ;
     };
+    String STR_CTRLCLICKHYPERLINK
+    {
+        Text [ en-US ] = "ctrl+click to open hyperlink:";
+    };
+    String STR_CLICKHYPERLINK
+    {
+        Text [ en-US ] = "click to open hyperlink:";
+    };
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/gridwin5.cxx b/sc/source/ui/view/gridwin5.cxx
index 756f75c..ee357f6 100644
--- a/sc/source/ui/view/gridwin5.cxx
+++ b/sc/source/ui/view/gridwin5.cxx
@@ -31,6 +31,7 @@
 #include <sfx2/viewfrm.hxx>
 
 #include <unotools/localedatawrapper.hxx>
+#include <unotools/securityoptions.hxx>
 
 #include "viewuno.hxx"
 #include "AccessibleDocument.hxx"
@@ -49,7 +50,8 @@
 #include "tabvwsh.hxx"
 #include "userdat.hxx"
 #include "postit.hxx"
-
+#include "global.hxx"
+#include "globstr.hrc"
 // -----------------------------------------------------------------------
 
 bool ScGridWindow::ShowNoteMarker( SCsCOL nPosX, SCsROW nPosY, bool bKeyboard )
@@ -241,16 +243,21 @@ bool ScGridWindow::ShowNoteMarker( SCsCOL nPosX, SCsROW nPosY, bool bKeyboard )
 
 void ScGridWindow::RequestHelp(const HelpEvent& rHEvt)
 {
+    //To know whether to prefix STR_CTRLCLICKHYERLINK or STR_CLICKHYPERLINK
+    //to hyperlink tooltips/help text
+    SvtSecurityOptions aSecOpt;
+    bool bCtrlClickHlink = aSecOpt.IsOptionSet( SvtSecurityOptions::E_CTRLCLICK_HYPERLINK );
+    //Global string STR_CTRLCLICKHYPERLINK i.e, "ctrl+click to open hyperlink:"
+    OUString aCtrlClickHlinkStr = ScGlobal::GetRscString( STR_CTRLCLICKHYPERLINK );
+    //Global string STR_CLICKHYPERLINK i.e, "click to open hyperlink"
+    OUString aClickHlinkStr = ScGlobal::GetRscString( STR_CLICKHYPERLINK );
     sal_Bool bDone = false;
     sal_Bool bHelpEnabled = ( rHEvt.GetMode() & ( HELPMODE_BALLOON | HELPMODE_QUICK ) ) != 0;
     SdrView* pDrView = pViewData->GetScDrawView();
-
     sal_Bool bDrawTextEdit = false;
     if (pDrView)
         bDrawTextEdit = pDrView->IsTextEdit();
-
     //  notes or change tracking
-
     if ( bHelpEnabled && !bDrawTextEdit )
     {
         Point       aPosPixel = ScreenToOutputPixel( rHEvt.GetMousePosPixel() );
@@ -304,6 +311,16 @@ void ScGridWindow::RequestHelp(const HelpEvent& rHEvt)
                         aHelpText = pIMapObj->GetAltText();
                         if (!aHelpText.Len())
                             aHelpText = pIMapObj->GetURL();
+                        if( bCtrlClickHlink )
+                        {
+                            //prefix STR_CTRLCLICKHYPERLINK to aHelpText
+                            aHelpText = aCtrlClickHlinkStr + aHelpText;
+                        }
+                        else
+                        {
+                            //Option not set, so prefix STR_CLICKHYPERLINK
+                            aHelpText = aClickHlinkStr + aHelpText;
+                        }
                         aPixRect = LogicToPixel(aVEvt.pObj->GetLogicRect());
                     }
                 }
@@ -333,6 +350,17 @@ void ScGridWindow::RequestHelp(const HelpEvent& rHEvt)
                             {
                                 aPixRect = LogicToPixel(aVEvt.pObj->GetLogicRect());
                                 aHelpText = pInfo->GetHlink();
+                                if( bCtrlClickHlink )
+                                {
+                                    //prefix STR_CTRLCLICKHYPERLINK to aHelpText
+                                    aHelpText = aCtrlClickHlinkStr + aHelpText;
+                                }
+                                else
+                                {
+                                    //Option not set, so prefix STR_CLICKHYPERLINK
+                                    aHelpText = aClickHlinkStr + aHelpText;
+                                }
+
                             }
                         }
                     }
@@ -348,6 +376,18 @@ void ScGridWindow::RequestHelp(const HelpEvent& rHEvt)
                 aHelpText = INetURLObject::decode( aUrl, INET_HEX_ESCAPE,
                     INetURLObject::DECODE_UNAMBIGUOUS );
 
+                if( bCtrlClickHlink )
+                {
+                    //prefix STR_CTRLCLICKHYPERLINK to aHelpText
+                    aHelpText = aCtrlClickHlinkStr + aHelpText;
+                }
+                else
+                {
+                    //Option not set, so prefix STR_CLICKHYPERLINK
+                    aHelpText = aClickHlinkStr + aHelpText;
+                }
+
+
                 ScDocument* pDoc = pViewData->GetDocument();
                 SCsCOL nPosX;
                 SCsROW nPosY;


More information about the Libreoffice-commits mailing list