Kaydet (Commit) 54013188 authored tarafından Noel Grandin's avatar Noel Grandin Kaydeden (comit) Noel Grandin

cleanup some unnecessary direct usage of the OString/OUString C API.

Change-Id: I6edee95aae1c169ce70063562a0c1b287e0c4735
Reviewed-on: https://gerrit.libreoffice.org/16861Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noelgrandin@gmail.com>
üst fd274945
...@@ -305,12 +305,7 @@ bool OOp_COMPARE::operate(const OOperand* pLeft, const OOperand* pRight) const ...@@ -305,12 +305,7 @@ bool OOp_COMPARE::operate(const OOperand* pLeft, const OOperand* pRight) const
case DataType::LONGVARCHAR: case DataType::LONGVARCHAR:
{ {
OUString sLH = aLH, sRH = aRH; OUString sLH = aLH, sRH = aRH;
sal_Int32 nRes = rtl_ustr_compareIgnoreAsciiCase_WithLength sal_Int32 nRes = sLH.compareToIgnoreAsciiCase(sRH);
(
sLH.pData->buffer,
sLH.pData->length,
sRH.pData->buffer,
sRH.pData->length );
switch(aPredicateType) switch(aPredicateType)
{ {
case SQLFilterOperator::EQUAL: bResult = (nRes == 0); break; case SQLFilterOperator::EQUAL: bResult = (nRes == 0); break;
......
...@@ -769,9 +769,7 @@ OString extractSingleTableFromSelect( const OStringVector &vec ) ...@@ -769,9 +769,7 @@ OString extractSingleTableFromSelect( const OStringVector &vec )
token ++; token ++;
} }
if( token < vec.size() && rtl_str_compare_WithLength( if( token < vec.size() && vec[token] == "(" )
vec[token].getStr(), vec[token].getLength(),
RTL_CONSTASCII_STRINGPARAM("(") ) )
{ {
// it is a table or a function name // it is a table or a function name
OStringBuffer buf(128); OStringBuffer buf(128);
...@@ -783,9 +781,7 @@ OString extractSingleTableFromSelect( const OStringVector &vec ) ...@@ -783,9 +781,7 @@ OString extractSingleTableFromSelect( const OStringVector &vec )
if( token < vec.size() ) if( token < vec.size() )
{ {
if( rtl_str_compare_WithLength( if( vec[token] == "." )
vec[token].getStr(), vec[token].getLength(),
RTL_CONSTASCII_STRINGPARAM( "." ) ) == 0 )
{ {
buf.append( vec[token] ); buf.append( vec[token] );
token ++; token ++;
...@@ -803,9 +799,7 @@ OString extractSingleTableFromSelect( const OStringVector &vec ) ...@@ -803,9 +799,7 @@ OString extractSingleTableFromSelect( const OStringVector &vec )
ret = buf.makeStringAndClear(); ret = buf.makeStringAndClear();
// now got my table candidate // now got my table candidate
if( token < vec.size() && rtl_str_compare_WithLength( if( token < vec.size() && vec[token] == "(" )
vec[token].getStr(), vec[token].getLength(),
RTL_CONSTASCII_STRINGPARAM( "(" ) ) == 0 )
{ {
// whoops, it is a function // whoops, it is a function
ret.clear(); ret.clear();
...@@ -823,9 +817,7 @@ OString extractSingleTableFromSelect( const OStringVector &vec ) ...@@ -823,9 +817,7 @@ OString extractSingleTableFromSelect( const OStringVector &vec )
if( token < vec.size() ) if( token < vec.size() )
{ {
if( rtl_str_compare_WithLength( if( vec[token] == "," )
vec[token].getStr(), vec[token].getLength(),
RTL_CONSTASCII_STRINGPARAM( "," ) ) == 0 )
{ {
// whoops, multiple tables are used // whoops, multiple tables are used
ret.clear(); ret.clear();
......
...@@ -91,8 +91,7 @@ bool SAL_CALL osl_detail_ObjectRegistry_storeAddresses( char const* pName ) ...@@ -91,8 +91,7 @@ bool SAL_CALL osl_detail_ObjectRegistry_storeAddresses( char const* pName )
return false; return false;
// check for "all": // check for "all":
rtl::OString const& rFirst = rVec[0]; rtl::OString const& rFirst = rVec[0];
if (rtl_str_compare_WithLength( rFirst.getStr(), rFirst.getLength(), if ( rFirst == "all" )
RTL_CONSTASCII_STRINGPARAM("all") ) == 0)
return true; return true;
OStringVec::const_iterator const iEnd( rVec.end() ); OStringVec::const_iterator const iEnd( rVec.end() );
return std::find_if( rVec.begin(), iEnd, return std::find_if( rVec.begin(), iEnd,
......
...@@ -427,9 +427,7 @@ SAL_CALL osl_identicalDirectoryItem( oslDirectoryItem a, oslDirectoryItem b) ...@@ -427,9 +427,7 @@ SAL_CALL osl_identicalDirectoryItem( oslDirectoryItem a, oslDirectoryItem b)
if (a == b) if (a == b)
return sal_True; return sal_True;
/* same name => same item, unless renaming / moving madness has occurred */ /* same name => same item, unless renaming / moving madness has occurred */
if (rtl_ustr_compare_WithLength( if (pA->m_ustrFilePath == pB->m_ustrFilePath)
pA->m_ustrFilePath->buffer, pA->m_ustrFilePath->length,
pB->m_ustrFilePath->buffer, pB->m_ustrFilePath->length ) == 0)
return sal_True; return sal_True;
struct stat a_stat, b_stat; struct stat a_stat, b_stat;
......
...@@ -1151,9 +1151,7 @@ SAL_CALL osl_identicalDirectoryItem( oslDirectoryItem a, oslDirectoryItem b) ...@@ -1151,9 +1151,7 @@ SAL_CALL osl_identicalDirectoryItem( oslDirectoryItem a, oslDirectoryItem b)
if (a == b) if (a == b)
return sal_True; return sal_True;
/* same name => same item, unless renaming / moving madness has occurred */ /* same name => same item, unless renaming / moving madness has occurred */
if (rtl_ustr_compare_WithLength( if (pA->m_pFullPath == pB->m_pFullPath)
pA->m_pFullPath->buffer, pA->m_pFullPath->length,
pB->m_pFullPath->buffer, pB->m_pFullPath->length ) == 0)
return sal_True; return sal_True;
// FIXME: as/when/if this is used in anger on Windows we could // FIXME: as/when/if this is used in anger on Windows we could
......
...@@ -106,9 +106,8 @@ using ::oox::core::XmlFilterBase; ...@@ -106,9 +106,8 @@ using ::oox::core::XmlFilterBase;
bool IgnoreCaseCompare::operator()( const OUString& rName1, const OUString& rName2 ) const bool IgnoreCaseCompare::operator()( const OUString& rName1, const OUString& rName2 ) const
{ {
// there is no wrapper in OUString, TODO: compare with collator // TODO: compare with collator
return ::rtl_ustr_compareIgnoreAsciiCase_WithLength( return rName1.compareToIgnoreAsciiCase(rName2 ) < 0;
rName1.getStr(), rName1.getLength(), rName2.getStr(), rName2.getLength() ) < 0;
} }
class WorkbookGlobals : boost::noncopyable class WorkbookGlobals : boost::noncopyable
......
...@@ -380,8 +380,7 @@ bool FilePermission::implies( Permission const & perm ) const ...@@ -380,8 +380,7 @@ bool FilePermission::implies( Permission const & perm ) const
if (m_url.getLength() > demanded.m_url.getLength()) if (m_url.getLength() > demanded.m_url.getLength())
return false; return false;
// check /- wildcard: all files and recursive in that path // check /- wildcard: all files and recursive in that path
if (1 < m_url.getLength() && if (m_url.endsWith("/-"))
0 == ::rtl_ustr_ascii_compare_WithLength( m_url.getStr() + m_url.getLength() - 2, 2, "/-" ))
{ {
// demanded url must start with granted path (including path trailing path sep) // demanded url must start with granted path (including path trailing path sep)
sal_Int32 len = m_url.getLength() -1; sal_Int32 len = m_url.getLength() -1;
...@@ -394,8 +393,7 @@ bool FilePermission::implies( Permission const & perm ) const ...@@ -394,8 +393,7 @@ bool FilePermission::implies( Permission const & perm ) const
#endif #endif
} }
// check /* wildcard: all files in that path (not recursive!) // check /* wildcard: all files in that path (not recursive!)
if (1 < m_url.getLength() && if (m_url.endsWith("/*"))
0 == ::rtl_ustr_ascii_compare_WithLength( m_url.getStr() + m_url.getLength() - 2, 2, "/*" ))
{ {
// demanded url must start with granted path (including path trailing path sep) // demanded url must start with granted path (including path trailing path sep)
sal_Int32 len = m_url.getLength() -1; sal_Int32 len = m_url.getLength() -1;
......
...@@ -259,7 +259,7 @@ FileProvider::compareContentIds( ...@@ -259,7 +259,7 @@ FileProvider::compareContentIds(
error = osl::FileBase::getSystemPathFromFileURL( aStatus2.getFileURL(), aPath2 ); error = osl::FileBase::getSystemPathFromFileURL( aStatus2.getFileURL(), aPath2 );
if ( error == osl::FileBase::E_None ) if ( error == osl::FileBase::E_None )
iComp = rtl_ustr_compareIgnoreAsciiCase( aPath1.getStr(), aPath2.getStr() ); iComp = aPath1.compareToIgnoreAsciiCase( aPath2 );
} }
#endif #endif
} }
......
...@@ -484,27 +484,22 @@ SectionPropertyMap::~SectionPropertyMap() ...@@ -484,27 +484,22 @@ SectionPropertyMap::~SectionPropertyMap()
OUString lcl_FindUnusedPageStyleName(const uno::Sequence< OUString >& rPageStyleNames) OUString lcl_FindUnusedPageStyleName(const uno::Sequence< OUString >& rPageStyleNames)
{ {
static const sal_Char cDefaultStyle[] = "Converted"; static const char DEFAULT_STYLE[] = "Converted";
//find the hightest number x in each style with the name "cDefaultStyle+x" and //find the highest number x in each style with the name "DEFAULT_STYLE+x" and
//return an incremented name //return an incremented name
sal_Int32 nMaxIndex = 0; sal_Int32 nMaxIndex = 0;
const sal_Int32 nDefaultLength = sizeof(cDefaultStyle)/sizeof(sal_Char) - 1;
const OUString sDefaultStyle( cDefaultStyle, nDefaultLength, RTL_TEXTENCODING_ASCII_US );
const OUString* pStyleNames = rPageStyleNames.getConstArray(); const OUString* pStyleNames = rPageStyleNames.getConstArray();
for( sal_Int32 nStyle = 0; nStyle < rPageStyleNames.getLength(); ++nStyle) for( sal_Int32 nStyle = 0; nStyle < rPageStyleNames.getLength(); ++nStyle)
{ {
if( pStyleNames[nStyle].getLength() > nDefaultLength && if( pStyleNames[nStyle].startsWith(DEFAULT_STYLE) )
!rtl_ustr_compare_WithLength( sDefaultStyle.getStr(), nDefaultLength, pStyleNames[nStyle].getStr(), nDefaultLength))
{ {
sal_Int32 nIndex = pStyleNames[nStyle].copy( nDefaultLength ).toInt32(); sal_Int32 nIndex = pStyleNames[nStyle].copy( strlen(DEFAULT_STYLE) ).toInt32();
if( nIndex > nMaxIndex) if( nIndex > nMaxIndex)
nMaxIndex = nIndex; nMaxIndex = nIndex;
} }
} }
OUString sRet( sDefaultStyle ); return DEFAULT_STYLE + OUString::number( nMaxIndex + 1);
sRet += OUString::number( nMaxIndex + 1);
return sRet;
} }
......
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