diff options
author | Akash Shetye <shetyeakash@gmail.com> | 2013-05-27 17:37:54 +0530 |
---|---|---|
committer | Luboš Luňák <l.lunak@suse.cz> | 2013-06-24 16:24:43 +0200 |
commit | c13daee32de1be4b96d6a948cfca4aa0bdf8c4db (patch) | |
tree | 37f13768740e22d37d0f7df4e0ceb19857a4f7b7 | |
parent | 669ad519902e21e0cb3537fb7e203987f75a4077 (diff) |
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@suse.cz>
-rw-r--r-- | sc/inc/globstr.hrc | 5 | ||||
-rw-r--r-- | sc/source/core/data/global.cxx | 20 | ||||
-rw-r--r-- | sc/source/ui/src/globstr.src | 8 | ||||
-rw-r--r-- | sc/source/ui/view/gridwin5.cxx | 48 |
4 files changed, 66 insertions, 15 deletions
diff --git a/sc/inc/globstr.hrc b/sc/inc/globstr.hrc index f9fda26cf0ce..314f29adc7f9 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 95084a94f71d..a34b1de2c6a2 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 af236f9ed89b..bd9579c001df 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 756f75c3176f..ee357f629d61 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; |