From a0ced657b7eb3051ac5fdf3fef74b6dba7443b23 Mon Sep 17 00:00:00 2001 From: Oliver Bolte Date: Wed, 17 Mar 2004 12:05:57 +0000 Subject: INTEGRATION: CWS jl5vba (1.35.8); FILE MERGED 2004/01/20 16:20:53 tbe 1.35.8.1: #109415# VBA Migration: Support help URI's in StarBasic comment fields --- basctl/source/basicide/baside2b.cxx | 70 +++++++++++++++++++++++++++++++------ 1 file changed, 60 insertions(+), 10 deletions(-) diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx index 73599cbf0505..0f3dc0d2ef5d 100644 --- a/basctl/source/basicide/baside2b.cxx +++ b/basctl/source/basicide/baside2b.cxx @@ -2,9 +2,9 @@ * * $RCSfile: baside2b.cxx,v $ * - * $Revision: 1.35 $ + * $Revision: 1.36 $ * - * last change: $Author: vg $ $Date: 2004-01-06 17:11:44 $ + * last change: $Author: obo $ $Date: 2004-03-17 13:05:57 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -67,6 +67,16 @@ #pragma hdrstop +#ifndef _URLOBJ_HXX +#include +#endif +#ifndef _UNOTOOLS_CHARCLASS_HXX +#include +#endif +#ifndef SVTOOLS_URIHELPER_HXX +#include +#endif + #ifndef _SBXCLASS_HXX //autogen #include #endif @@ -103,6 +113,10 @@ #ifndef _COM_SUN_STAR_SCRIPT_XLIBRYARYCONTAINER2_HPP_ #include #endif +#ifndef _COMPHELPER_PROCESSFACTORY_HXX_ +#include +#endif + using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -405,14 +419,50 @@ __EXPORT EditorWindow::~EditorWindow() String EditorWindow::GetWordAtCursor() { -// ESelection aESel( pEditView->GetSelection() ); - // Nicht den Selektierten Bereich, sondern an der CursorPosition, - // falls Teil eines Worts markiert. - String aWord( pEditView->GetTextEngine()->GetWord( pEditView->GetSelection().GetEnd() ) ); - // Kann leer sein, wenn komplettes Word markiert, da Cursor dahinter. - if ( !aWord.Len() && pEditView->HasSelection() ) - aWord = pEditView->GetTextEngine()->GetWord( pEditView->GetSelection().GetStart() ); - return aWord ; + String aWord; + + if ( pEditView ) + { + TextEngine* pTextEngine = pEditView->GetTextEngine(); + if ( pTextEngine ) + { + // check first, if the cursor is at a help URL + const TextSelection& rSelection = pEditView->GetSelection(); + const TextPaM& rSelStart = rSelection.GetStart(); + const TextPaM& rSelEnd = rSelection.GetEnd(); + String aText = pTextEngine->GetText( rSelEnd.GetPara() ); + CharClass aClass( ::comphelper::getProcessServiceFactory() , Application::GetSettings().GetLocale() ); + xub_StrLen nSelStart = static_cast< xub_StrLen >( rSelStart.GetIndex() ); + xub_StrLen nSelEnd = static_cast< xub_StrLen >( rSelEnd.GetIndex() ); + xub_StrLen nLength = static_cast< xub_StrLen >( aText.Len() ); + xub_StrLen nStart = 0; + xub_StrLen nEnd = nLength; + while ( nStart < nLength ) + { + String aURL( URIHelper::FindFirstURLInText( aText, nStart, nEnd, aClass ) ); + INetURLObject aURLObj( aURL ); + if ( aURLObj.GetProtocol() == INET_PROT_VND_SUN_STAR_HELP + && nSelStart >= nStart && nSelStart <= nEnd && nSelEnd >= nStart && nSelEnd <= nEnd ) + { + aWord = aURL; + break; + } + nStart = nEnd; + nEnd = nLength; + } + + // Nicht den Selektierten Bereich, sondern an der CursorPosition, + // falls Teil eines Worts markiert. + if ( !aWord.Len() ) + aWord = pTextEngine->GetWord( rSelEnd ); + + // Kann leer sein, wenn komplettes Word markiert, da Cursor dahinter. + if ( !aWord.Len() && pEditView->HasSelection() ) + aWord = pTextEngine->GetWord( rSelStart ); + } + } + + return aWord; } void __EXPORT EditorWindow::RequestHelp( const HelpEvent& rHEvt ) -- cgit v1.2.3