diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2016-12-05 08:47:18 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2016-12-05 12:49:02 +0200 |
commit | bfde4866e07746eafa2f0d6173c29d805cc35ad0 (patch) | |
tree | be939a44eb70c7187fa5536089b782326b160013 /tools | |
parent | 803215142efa6437515348f63bd70ffdcf5d45f1 (diff) |
convert DecodeMechanism to scoped enum
Change-Id: I5c56634b1bca8e37fa73d02d2428645301b6c547
Diffstat (limited to 'tools')
-rw-r--r-- | tools/qa/cppunit/test_urlobj.cxx | 56 | ||||
-rw-r--r-- | tools/source/fsys/urlobj.cxx | 42 |
2 files changed, 49 insertions, 49 deletions
diff --git a/tools/qa/cppunit/test_urlobj.cxx b/tools/qa/cppunit/test_urlobj.cxx index 161455739d95..c2f2cf78d3bf 100644 --- a/tools/qa/cppunit/test_urlobj.cxx +++ b/tools/qa/cppunit/test_urlobj.cxx @@ -49,18 +49,18 @@ namespace tools_urlobj { INetURLObject aUrl( OUString( "file://10.10.1.1/sampledir/sample.file" ) ); #ifdef LINUX - CPPUNIT_ASSERT( aUrl.GetMainURL( INetURLObject::NO_DECODE ) + CPPUNIT_ASSERT( aUrl.GetMainURL( INetURLObject::DecodeMechanism::NONE ) == "smb://10.10.1.1/sampledir/sample.file" ); CPPUNIT_ASSERT( aUrl.GetProtocol( ) == INetProtocol::Smb ); #endif #ifdef _WIN32 - CPPUNIT_ASSERT( aUrl.GetMainURL( INetURLObject::NO_DECODE ) + CPPUNIT_ASSERT( aUrl.GetMainURL( INetURLObject::DecodeMechanism::NONE ) == "file://10.10.1.1/sampledir/sample.file" ); CPPUNIT_ASSERT( aUrl.GetProtocol( ) == INetProtocol::File ); #endif - CPPUNIT_ASSERT( aUrl.GetHost( INetURLObject::NO_DECODE ) + CPPUNIT_ASSERT( aUrl.GetHost( INetURLObject::DecodeMechanism::NONE ) == "10.10.1.1" ); - CPPUNIT_ASSERT( aUrl.GetURLPath( INetURLObject::NO_DECODE ) + CPPUNIT_ASSERT( aUrl.GetURLPath( INetURLObject::DecodeMechanism::NONE ) == "/sampledir/sample.file" ); CPPUNIT_ASSERT( aUrl.getName( ) == "sample.file" ); @@ -75,18 +75,18 @@ namespace tools_urlobj setFSysPath( "\\\\137.65.170.24\\c$\\Img0001.jpg", INetURLObject::FSYS_DETECT ); #ifdef LINUX - CPPUNIT_ASSERT( aUrl.GetMainURL( INetURLObject::NO_DECODE ) + CPPUNIT_ASSERT( aUrl.GetMainURL( INetURLObject::DecodeMechanism::NONE ) == "smb://137.65.170.24/c$/Img0001.jpg" ); CPPUNIT_ASSERT( aUrl.GetProtocol( ) == INetProtocol::Smb ); #endif #ifdef _WIN32 - CPPUNIT_ASSERT( aUrl.GetMainURL( INetURLObject::NO_DECODE ) + CPPUNIT_ASSERT( aUrl.GetMainURL( INetURLObject::DecodeMechanism::NONE ) == "file://137.65.170.24/c$/Img0001.jpg" ); CPPUNIT_ASSERT( aUrl.GetProtocol( ) == INetProtocol::File ); #endif - CPPUNIT_ASSERT( aUrl.GetHost( INetURLObject::NO_DECODE ) + CPPUNIT_ASSERT( aUrl.GetHost( INetURLObject::DecodeMechanism::NONE ) == "137.65.170.24" ); - CPPUNIT_ASSERT( aUrl.GetURLPath( INetURLObject::NO_DECODE ) + CPPUNIT_ASSERT( aUrl.GetURLPath( INetURLObject::DecodeMechanism::NONE ) == "/c$/Img0001.jpg" ); CPPUNIT_ASSERT( aUrl.getName( ) == "Img0001.jpg" ); CPPUNIT_ASSERT( aUrl.getBase( ) == "Img0001" ); @@ -101,18 +101,18 @@ namespace tools_urlobj setFSysPath( "\\\\hive-winxp-x86\\pmladek\\test2.odt", INetURLObject::FSYS_DETECT ); #ifdef LINUX - CPPUNIT_ASSERT( aUrl.GetMainURL( INetURLObject::NO_DECODE ) + CPPUNIT_ASSERT( aUrl.GetMainURL( INetURLObject::DecodeMechanism::NONE ) == "smb://hive-winxp-x86/pmladek/test2.odt" ); CPPUNIT_ASSERT( aUrl.GetProtocol( ) == INetProtocol::Smb ); #endif #ifdef _WIN32 - CPPUNIT_ASSERT( aUrl.GetMainURL( INetURLObject::NO_DECODE ) + CPPUNIT_ASSERT( aUrl.GetMainURL( INetURLObject::DecodeMechanism::NONE ) == "file://hive-winxp-x86/pmladek/test2.odt" ); CPPUNIT_ASSERT( aUrl.GetProtocol( ) == INetProtocol::File ); #endif - CPPUNIT_ASSERT( aUrl.GetHost( INetURLObject::NO_DECODE ) + CPPUNIT_ASSERT( aUrl.GetHost( INetURLObject::DecodeMechanism::NONE ) == "hive-winxp-x86" ); - CPPUNIT_ASSERT( aUrl.GetURLPath( INetURLObject::NO_DECODE ) + CPPUNIT_ASSERT( aUrl.GetURLPath( INetURLObject::DecodeMechanism::NONE ) == "/pmladek/test2.odt" ); } @@ -120,18 +120,18 @@ namespace tools_urlobj { INetURLObject aUrl( OUString( "smb://10.10.1.1/sampledir/sample.file" ) ); #ifdef LINUX - CPPUNIT_ASSERT( aUrl.GetMainURL( INetURLObject::NO_DECODE ) + CPPUNIT_ASSERT( aUrl.GetMainURL( INetURLObject::DecodeMechanism::NONE ) == "smb://10.10.1.1/sampledir/sample.file" ); CPPUNIT_ASSERT( aUrl.GetProtocol( ) == INetProtocol::Smb ); #endif #ifdef _WIN32 - CPPUNIT_ASSERT( aUrl.GetMainURL( INetURLObject::NO_DECODE ) + CPPUNIT_ASSERT( aUrl.GetMainURL( INetURLObject::DecodeMechanism::NONE ) == "file://10.10.1.1/sampledir/sample.file" ); CPPUNIT_ASSERT( aUrl.GetProtocol( ) == INetProtocol::File ); #endif - CPPUNIT_ASSERT( aUrl.GetHost( INetURLObject::NO_DECODE ) + CPPUNIT_ASSERT( aUrl.GetHost( INetURLObject::DecodeMechanism::NONE ) == "10.10.1.1" ); - CPPUNIT_ASSERT( aUrl.GetURLPath( INetURLObject::NO_DECODE ) + CPPUNIT_ASSERT( aUrl.GetURLPath( INetURLObject::DecodeMechanism::NONE ) == "/sampledir/sample.file" ); CPPUNIT_ASSERT( aUrl.getName( ) == "sample.file" ); CPPUNIT_ASSERT( aUrl.getBase( ) == "sample" ); @@ -144,18 +144,18 @@ namespace tools_urlobj aUrl.setFSysPath( "//137.65.170.24/c$/Img0001.jpg", INetURLObject::FSYS_DETECT ); #ifdef LINUX - CPPUNIT_ASSERT( aUrl.GetMainURL( INetURLObject::NO_DECODE ) + CPPUNIT_ASSERT( aUrl.GetMainURL( INetURLObject::DecodeMechanism::NONE ) == "smb://137.65.170.24/c$/Img0001.jpg" ); CPPUNIT_ASSERT( aUrl.GetProtocol( ) == INetProtocol::Smb ); #endif #ifdef _WIN32 - CPPUNIT_ASSERT( aUrl.GetMainURL( INetURLObject::NO_DECODE ) + CPPUNIT_ASSERT( aUrl.GetMainURL( INetURLObject::DecodeMechanism::NONE ) == "file://137.65.170.24/c$/Img0001.jpg" ); CPPUNIT_ASSERT( aUrl.GetProtocol( ) == INetProtocol::File ); #endif - CPPUNIT_ASSERT( aUrl.GetHost( INetURLObject::NO_DECODE ) + CPPUNIT_ASSERT( aUrl.GetHost( INetURLObject::DecodeMechanism::NONE ) == "137.65.170.24" ); - CPPUNIT_ASSERT( aUrl.GetURLPath( INetURLObject::NO_DECODE ) + CPPUNIT_ASSERT( aUrl.GetURLPath( INetURLObject::DecodeMechanism::NONE ) == "/c$/Img0001.jpg" ); CPPUNIT_ASSERT( aUrl.getName( ) == "Img0001.jpg" ); CPPUNIT_ASSERT( aUrl.getBase( ) == "Img0001" ); @@ -169,18 +169,18 @@ namespace tools_urlobj aUrl.setFSysPath( "//hive-winxp-x86/pmladek/test2.odt", INetURLObject::FSYS_DETECT ); #ifdef LINUX - CPPUNIT_ASSERT( aUrl.GetMainURL( INetURLObject::NO_DECODE ) + CPPUNIT_ASSERT( aUrl.GetMainURL( INetURLObject::DecodeMechanism::NONE ) == "smb://hive-winxp-x86/pmladek/test2.odt" ); CPPUNIT_ASSERT( aUrl.GetProtocol( ) == INetProtocol::Smb ); #endif #ifdef _WIN32 - CPPUNIT_ASSERT( aUrl.GetMainURL( INetURLObject::NO_DECODE ) + CPPUNIT_ASSERT( aUrl.GetMainURL( INetURLObject::DecodeMechanism::NONE ) == "file://hive-winxp-x86/pmladek/test2.odt" ); CPPUNIT_ASSERT( aUrl.GetProtocol( ) == INetProtocol::File ); #endif - CPPUNIT_ASSERT( aUrl.GetHost( INetURLObject::NO_DECODE ) + CPPUNIT_ASSERT( aUrl.GetHost( INetURLObject::DecodeMechanism::NONE ) == "hive-winxp-x86" ); - CPPUNIT_ASSERT( aUrl.GetURLPath( INetURLObject::NO_DECODE ) + CPPUNIT_ASSERT( aUrl.GetURLPath( INetURLObject::DecodeMechanism::NONE ) == "/pmladek/test2.odt" ); } @@ -190,10 +190,10 @@ namespace tools_urlobj { INetURLObject aUrl( OUString( "vnd.libreoffice.cmis://username@http:%2F%2Ffoo.bar.com:8080%2Fmy%2Fcmis%2Fatom%23repo-id-encoded/path/to/content" ) ); CPPUNIT_ASSERT_EQUAL( std::string( "http://foo.bar.com:8080/my/cmis/atom#repo-id-encoded" ), - OUSTR_TO_STDSTR( aUrl.GetHost( INetURLObject::DECODE_WITH_CHARSET ) ) ); + OUSTR_TO_STDSTR( aUrl.GetHost( INetURLObject::DecodeMechanism::WithCharset ) ) ); CPPUNIT_ASSERT_EQUAL( std::string( "username" ), OUSTR_TO_STDSTR( aUrl.GetUser( ) ) ); CPPUNIT_ASSERT_EQUAL( std::string( "/path/to/content" ), - OUSTR_TO_STDSTR( aUrl.GetURLPath( INetURLObject::NO_DECODE ) ) ); + OUSTR_TO_STDSTR( aUrl.GetURLPath( INetURLObject::DecodeMechanism::NONE ) ) ); CPPUNIT_ASSERT_EQUAL_MESSAGE( "Wrong protocol found", INetProtocol::Cmis, aUrl.GetProtocol( ) ); } @@ -202,10 +202,10 @@ namespace tools_urlobj INetURLObject aUrl( OUString( "vnd.libreoffice.cmis://http:%2F%2Ffoo.bar.com:8080%2Fmy%2Fcmis%2Fatom%23repo-id-encoded/path/to/content" ) ); CPPUNIT_ASSERT_EQUAL( std::string( "http://foo.bar.com:8080/my/cmis/atom#repo-id-encoded" ), - OUSTR_TO_STDSTR( aUrl.GetHost( INetURLObject::DECODE_WITH_CHARSET ) ) ); + OUSTR_TO_STDSTR( aUrl.GetHost( INetURLObject::DecodeMechanism::WithCharset ) ) ); CPPUNIT_ASSERT( !aUrl.HasUserData() ); CPPUNIT_ASSERT_EQUAL( std::string( "/path/to/content" ), - OUSTR_TO_STDSTR( aUrl.GetURLPath( INetURLObject::NO_DECODE ) ) ); + OUSTR_TO_STDSTR( aUrl.GetURLPath( INetURLObject::DecodeMechanism::NONE ) ) ); CPPUNIT_ASSERT_EQUAL_MESSAGE( "Wrong protocol found", INetProtocol::Cmis, aUrl.GetProtocol( ) ); } } diff --git a/tools/source/fsys/urlobj.cxx b/tools/source/fsys/urlobj.cxx index 7d3669630c4c..73384cde65cf 100644 --- a/tools/source/fsys/urlobj.cxx +++ b/tools/source/fsys/urlobj.cxx @@ -583,7 +583,7 @@ std::unique_ptr<SvMemoryStream> INetURLObject::getData() return nullptr; } - OUString sURLPath = GetURLPath( DECODE_WITH_CHARSET, RTL_TEXTENCODING_ISO_8859_1 ); + OUString sURLPath = GetURLPath( DecodeMechanism::WithCharset, RTL_TEXTENCODING_ISO_8859_1 ); sal_Unicode const * pSkippedMediatype = INetMIME::scanContentType( sURLPath.getStr(), sURLPath.getStr() + sURLPath.getLength() ); sal_Int32 nCharactersSkipped = pSkippedMediatype == nullptr ? 0 : pSkippedMediatype-sURLPath.getStr(); @@ -1730,7 +1730,7 @@ bool INetURLObject::convertRelToAbs(OUString const & rTheRelURIRef, HasError(), "tools.urlobj", "cannot make <" << rTheRelURIRef << "> absolute against broken base <" - << GetMainURL(NO_DECODE) << ">"); + << GetMainURL(DecodeMechanism::NONE) << ">"); rWasAbsolute = false; return false; } @@ -1858,7 +1858,7 @@ bool INetURLObject::convertRelToAbs(OUString const & rTheRelURIRef, SAL_WARN_IF( HasError(), "tools.urlobj", "cannot make <" << rTheRelURIRef - << "> absolute against broken base <" << GetMainURL(NO_DECODE) + << "> absolute against broken base <" << GetMainURL(DecodeMechanism::NONE) << ">"); rWasAbsolute = false; return false; @@ -3388,10 +3388,10 @@ OUString INetURLObject::decode(sal_Unicode const * pBegin, { switch (eMechanism) { - case NO_DECODE: + case DecodeMechanism::NONE: return OUString(pBegin, pEnd - pBegin); - case DECODE_TO_IURI: + case DecodeMechanism::ToIUri: eCharset = RTL_TEXTENCODING_UTF8; break; @@ -3418,9 +3418,9 @@ OUString INetURLObject::decode(sal_Unicode const * pBegin, if ( rtl::isAscii(nUTF32) && ( - eMechanism == DECODE_TO_IURI || + eMechanism == DecodeMechanism::ToIUri || ( - eMechanism == DECODE_UNAMBIGUOUS && + eMechanism == DecodeMechanism::Unambiguous && mustEncode(nUTF32, PART_UNAMBIGUOUS) ) ) @@ -3645,16 +3645,16 @@ bool INetURLObject::operator ==(INetURLObject const & rObject) const if ((m_aScheme.compare( rObject.m_aScheme, m_aAbsURIRef, rObject.m_aAbsURIRef) != 0) - || GetUser(NO_DECODE) != rObject.GetUser(NO_DECODE) - || GetPass(NO_DECODE) != rObject.GetPass(NO_DECODE) - || !GetHost(NO_DECODE).equalsIgnoreAsciiCase( - rObject.GetHost(NO_DECODE)) + || GetUser(DecodeMechanism::NONE) != rObject.GetUser(DecodeMechanism::NONE) + || GetPass(DecodeMechanism::NONE) != rObject.GetPass(DecodeMechanism::NONE) + || !GetHost(DecodeMechanism::NONE).equalsIgnoreAsciiCase( + rObject.GetHost(DecodeMechanism::NONE)) || GetPort() != rObject.GetPort() || HasParam() != rObject.HasParam() || GetParam() != rObject.GetParam()) return false; - OUString aPath1(GetURLPath(NO_DECODE)); - OUString aPath2(rObject.GetURLPath(NO_DECODE)); + OUString aPath1(GetURLPath(DecodeMechanism::NONE)); + OUString aPath2(rObject.GetURLPath(DecodeMechanism::NONE)); switch (m_eScheme) { case INetProtocol::File: @@ -3841,7 +3841,7 @@ OUString INetURLObject::GetAbsURL(OUString const & rTheBaseURIRef, eCharset, bIgnoreFragment, false, false, FSYS_DETECT) || eEncodeMechanism != EncodeMechanism::WasEncoded - || eDecodeMechanism != DECODE_TO_IURI + || eDecodeMechanism != DecodeMechanism::ToIUri || eCharset != RTL_TEXTENCODING_UTF8 ? aTheAbsURIRef.GetMainURL(eDecodeMechanism, eCharset) : rTheRelURIRef; @@ -4462,11 +4462,11 @@ OUString INetURLObject::getFSysPath(FSysStyle eStyle, OUStringBuffer aSynFSysPath; aSynFSysPath.append("//"); if (m_aHost.isPresent() && m_aHost.getLength() > 0) - aSynFSysPath.append(decode(m_aHost, DECODE_WITH_CHARSET, + aSynFSysPath.append(decode(m_aHost, DecodeMechanism::WithCharset, RTL_TEXTENCODING_UTF8)); else aSynFSysPath.append('.'); - aSynFSysPath.append(decode(m_aPath, DECODE_WITH_CHARSET, + aSynFSysPath.append(decode(m_aPath, DecodeMechanism::WithCharset, RTL_TEXTENCODING_UTF8)); return aSynFSysPath.makeStringAndClear(); } @@ -4479,7 +4479,7 @@ OUString INetURLObject::getFSysPath(FSysStyle eStyle, if (pDelimiter) *pDelimiter = '/'; - return decode(m_aPath, DECODE_WITH_CHARSET, RTL_TEXTENCODING_UTF8); + return decode(m_aPath, DecodeMechanism::WithCharset, RTL_TEXTENCODING_UTF8); } case FSYS_DOS: @@ -4491,7 +4491,7 @@ OUString INetURLObject::getFSysPath(FSysStyle eStyle, if (m_aHost.isPresent() && m_aHost.getLength() > 0) { aSynFSysPath.append("\\\\"); - aSynFSysPath.append(decode(m_aHost, DECODE_WITH_CHARSET, + aSynFSysPath.append(decode(m_aHost, DecodeMechanism::WithCharset, RTL_TEXTENCODING_UTF8)); aSynFSysPath.append('\\'); } @@ -4855,7 +4855,7 @@ OUString INetURLObject::GetPartBeforeLastName() aTemp.clearQuery(); aTemp.removeSegment(LAST_SEGMENT, false); aTemp.setFinalSlash(); - return aTemp.GetMainURL(DECODE_TO_IURI); + return aTemp.GetMainURL(DecodeMechanism::ToIUri); } OUString INetURLObject::GetLastName(DecodeMechanism eMechanism, @@ -4887,7 +4887,7 @@ OUString INetURLObject::PathToFileName() const if (osl::FileBase::getSystemPathFromFileURL( decode(m_aAbsURIRef.getStr(), m_aAbsURIRef.getStr() + m_aPath.getEnd(), - NO_DECODE, RTL_TEXTENCODING_UTF8), + DecodeMechanism::NONE, RTL_TEXTENCODING_UTF8), aSystemPath) != osl::FileBase::E_None) return OUString(); @@ -4916,7 +4916,7 @@ void INetURLObject::SetBase(OUString const & rTheBase) OUString INetURLObject::GetBase() const { - return getBase(LAST_SEGMENT, true, DECODE_WITH_CHARSET); + return getBase(LAST_SEGMENT, true, DecodeMechanism::WithCharset); } void INetURLObject::SetName(OUString const & rTheName, |