Kaydet (Commit) ad6f9f2f authored tarafından Norbert Thiebaud's avatar Norbert Thiebaud

String=>OUString of svl's urihelper

Change-Id: Ib4d9175ce4661140a147962b8f45be40f800d85a
üst c7709b46
...@@ -278,16 +278,16 @@ String EditorWindow::GetWordAtCursor() ...@@ -278,16 +278,16 @@ String EditorWindow::GetWordAtCursor()
const TextSelection& rSelection = pEditView->GetSelection(); const TextSelection& rSelection = pEditView->GetSelection();
const TextPaM& rSelStart = rSelection.GetStart(); const TextPaM& rSelStart = rSelection.GetStart();
const TextPaM& rSelEnd = rSelection.GetEnd(); const TextPaM& rSelEnd = rSelection.GetEnd();
String aText = pTextEngine->GetText( rSelEnd.GetPara() ); OUString aText = pTextEngine->GetText( rSelEnd.GetPara() );
CharClass aClass( ::comphelper::getProcessComponentContext() , Application::GetSettings().GetLanguageTag() ); CharClass aClass( ::comphelper::getProcessComponentContext() , Application::GetSettings().GetLanguageTag() );
xub_StrLen nSelStart = static_cast< xub_StrLen >( rSelStart.GetIndex() ); sal_Int32 nSelStart = rSelStart.GetIndex();
xub_StrLen nSelEnd = static_cast< xub_StrLen >( rSelEnd.GetIndex() ); sal_Int32 nSelEnd = rSelEnd.GetIndex();
xub_StrLen nLength = static_cast< xub_StrLen >( aText.Len() ); sal_Int32 nLength = aText.getLength();
xub_StrLen nStart = 0; sal_Int32 nStart = 0;
xub_StrLen nEnd = nLength; sal_Int32 nEnd = nLength;
while ( nStart < nLength ) while ( nStart < nLength )
{ {
String aURL( URIHelper::FindFirstURLInText( aText, nStart, nEnd, aClass ) ); OUString aURL( URIHelper::FindFirstURLInText( aText, nStart, nEnd, aClass ) );
INetURLObject aURLObj( aURL ); INetURLObject aURLObj( aURL );
if ( aURLObj.GetProtocol() == INET_PROT_VND_SUN_STAR_HELP if ( aURLObj.GetProtocol() == INET_PROT_VND_SUN_STAR_HELP
&& nSelStart >= nStart && nSelStart <= nEnd && nSelEnd >= nStart && nSelEnd <= nEnd ) && nSelStart >= nStart && nSelStart <= nEnd && nSelEnd >= nStart && nSelEnd <= nEnd )
......
...@@ -690,8 +690,13 @@ sal_Bool SvxAutoCorrect::FnSetINetAttr( SvxAutoCorrDoc& rDoc, const String& rTxt ...@@ -690,8 +690,13 @@ sal_Bool SvxAutoCorrect::FnSetINetAttr( SvxAutoCorrDoc& rDoc, const String& rTxt
xub_StrLen nSttPos, xub_StrLen nEndPos, xub_StrLen nSttPos, xub_StrLen nEndPos,
LanguageType eLang ) LanguageType eLang )
{ {
String sURL( URIHelper::FindFirstURLInText( rTxt, nSttPos, nEndPos, sal_Int32 nStart(nSttPos);
sal_Int32 nEnd(nEndPos);
String sURL( URIHelper::FindFirstURLInText( rTxt, nStart, nEnd,
GetCharClass( eLang ) )); GetCharClass( eLang ) ));
nSttPos = (xub_StrLen)nStart;
nEndPos = (xub_StrLen)nEnd;
sal_Bool bRet = 0 != sURL.Len(); sal_Bool bRet = 0 != sURL.Len();
if( bRet ) // also Attribut setzen: if( bRet ) // also Attribut setzen:
rDoc.SetINetAttr( nSttPos, nEndPos, sURL ); rDoc.SetINetAttr( nSttPos, nEndPos, sURL );
......
...@@ -32,7 +32,7 @@ namespace com { namespace sun { namespace star { ...@@ -32,7 +32,7 @@ namespace com { namespace sun { namespace star {
namespace uno { class XComponentContext; } namespace uno { class XComponentContext; }
namespace uri { class XUriReference; } namespace uri { class XUriReference; }
} } } } } }
namespace rtl { class OUString; }
class CharClass; class CharClass;
//============================================================================ //============================================================================
...@@ -51,19 +51,16 @@ namespace URIHelper { ...@@ -51,19 +51,16 @@ namespace URIHelper {
existence (see URIHelper::GetMaybeFileHdl), or use bCheckFileExists = false existence (see URIHelper::GetMaybeFileHdl), or use bCheckFileExists = false
if you want to generate file URLs without checking for their existence. if you want to generate file URLs without checking for their existence.
*/ */
SVL_DLLPUBLIC rtl::OUString SVL_DLLPUBLIC OUString SmartRel2Abs(INetURLObject const & rTheBaseURIRef,
SmartRel2Abs(INetURLObject const & rTheBaseURIRef, OUString const & rTheRelURIRef,
rtl::OUString const & rTheRelURIRef, Link const & rMaybeFileHdl = Link(),
Link const & rMaybeFileHdl = Link(), bool bCheckFileExists = true,
bool bCheckFileExists = true, bool bIgnoreFragment = false,
bool bIgnoreFragment = false, INetURLObject::EncodeMechanism eEncodeMechanism = INetURLObject::WAS_ENCODED,
INetURLObject::EncodeMechanism eEncodeMechanism INetURLObject::DecodeMechanism eDecodeMechanism = INetURLObject::DECODE_TO_IURI,
= INetURLObject::WAS_ENCODED, rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8,
INetURLObject::DecodeMechanism eDecodeMechanism bool bRelativeNonURIs = false,
= INetURLObject::DECODE_TO_IURI, INetURLObject::FSysStyle eStyle = INetURLObject::FSYS_DETECT);
rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8,
bool bRelativeNonURIs = false,
INetURLObject::FSysStyle eStyle = INetURLObject::FSYS_DETECT);
//============================================================================ //============================================================================
SVL_DLLPUBLIC void SetMaybeFileHdl(Link const & rTheMaybeFileHdl); SVL_DLLPUBLIC void SetMaybeFileHdl(Link const & rTheMaybeFileHdl);
...@@ -119,20 +116,17 @@ normalizedMakeRelative( ...@@ -119,20 +116,17 @@ normalizedMakeRelative(
@deprecated @deprecated
No code should rely on the default component context. No code should rely on the default component context.
*/ */
SVL_DLLPUBLIC rtl::OUString simpleNormalizedMakeRelative( SVL_DLLPUBLIC OUString simpleNormalizedMakeRelative( OUString const & baseUriReference,
rtl::OUString const & baseUriReference, rtl::OUString const & uriReference); OUString const & uriReference);
//============================================================================ //============================================================================
SVL_DLLPUBLIC rtl::OUString SVL_DLLPUBLIC OUString FindFirstURLInText(OUString const & rText,
FindFirstURLInText(rtl::OUString const & rText, sal_Int32 & rBegin,
xub_StrLen & rBegin, sal_Int32 & rEnd,
xub_StrLen & rEnd, CharClass const & rCharClass,
CharClass const & rCharClass, INetURLObject::EncodeMechanism eMechanism = INetURLObject::WAS_ENCODED,
INetURLObject::EncodeMechanism eMechanism rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8,
= INetURLObject::WAS_ENCODED, INetURLObject::FSysStyle eStyle = INetURLObject::FSYS_DETECT);
rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8,
INetURLObject::FSysStyle eStyle
= INetURLObject::FSYS_DETECT);
//============================================================================ //============================================================================
/** Remove any password component from both absolute and relative URLs. /** Remove any password component from both absolute and relative URLs.
...@@ -160,13 +154,10 @@ FindFirstURLInText(rtl::OUString const & rText, ...@@ -160,13 +154,10 @@ FindFirstURLInText(rtl::OUString const & rText,
@return The input URI with any password component removed. @return The input URI with any password component removed.
*/ */
SVL_DLLPUBLIC rtl::OUString SVL_DLLPUBLIC OUString removePassword(OUString const & rURI,
removePassword(rtl::OUString const & rURI, INetURLObject::EncodeMechanism eEncodeMechanism = INetURLObject::WAS_ENCODED,
INetURLObject::EncodeMechanism eEncodeMechanism INetURLObject::DecodeMechanism eDecodeMechanism = INetURLObject::DECODE_TO_IURI,
= INetURLObject::WAS_ENCODED, rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8);
INetURLObject::DecodeMechanism eDecodeMechanism
= INetURLObject::DECODE_TO_IURI,
rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8);
} }
#endif // SVTOOLS_URIHELPER_HXX #endif // SVTOOLS_URIHELPER_HXX
......
...@@ -301,8 +301,8 @@ void Test::testFindFirstURLInText() { ...@@ -301,8 +301,8 @@ void Test::testFindFirstURLInText() {
struct Data { struct Data {
char const * input; char const * input;
char const * result; char const * result;
xub_StrLen begin; sal_Int32 begin;
xub_StrLen end; sal_Int32 end;
}; };
static Data const tests[] = { static Data const tests[] = {
{ "...ftp://bla.bla.bla/blubber/...", { "...ftp://bla.bla.bla/blubber/...",
...@@ -390,8 +390,8 @@ void Test::testFindFirstURLInText() { ...@@ -390,8 +390,8 @@ void Test::testFindFirstURLInText() {
CharClass charClass( m_context, LanguageTag( com::sun::star::lang::Locale("en", "US", ""))); CharClass charClass( m_context, LanguageTag( com::sun::star::lang::Locale("en", "US", "")));
for (std::size_t i = 0; i < SAL_N_ELEMENTS(tests); ++i) { for (std::size_t i = 0; i < SAL_N_ELEMENTS(tests); ++i) {
rtl::OUString input(rtl::OUString::createFromAscii(tests[i].input)); rtl::OUString input(rtl::OUString::createFromAscii(tests[i].input));
xub_StrLen begin = 0; sal_Int32 begin = 0;
xub_StrLen end = static_cast< xub_StrLen >(input.getLength()); sal_Int32 end = input.getLength();
rtl::OUString result( rtl::OUString result(
URIHelper::FindFirstURLInText(input, begin, end, charClass)); URIHelper::FindFirstURLInText(input, begin, end, charClass));
bool ok = tests[i].result == 0 bool ok = tests[i].result == 0
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment