Kaydet (Commit) 1ccd386c authored tarafından Matteo Casalin's avatar Matteo Casalin

Use USHRT_MAX consistently, minor cleanups

Change-Id: I1a2906a350baf7af7141aaa6124930485578a604
üst ff61e912
...@@ -155,7 +155,7 @@ void SwXMLTextBlocks::AddName( const OUString& rShort, const OUString& rLong, ...@@ -155,7 +155,7 @@ void SwXMLTextBlocks::AddName( const OUString& rShort, const OUString& rLong,
const OUString& rPackageName, bool bOnlyTxt ) const OUString& rPackageName, bool bOnlyTxt )
{ {
sal_uInt16 nIdx = GetIndex( rShort ); sal_uInt16 nIdx = GetIndex( rShort );
if( nIdx != (sal_uInt16) -1 ) if (nIdx != USHRT_MAX)
{ {
delete aNames[nIdx]; delete aNames[nIdx];
aNames.erase( aNames.begin() + nIdx ); aNames.erase( aNames.begin() + nIdx );
...@@ -500,7 +500,7 @@ void SwXMLTextBlocks::CloseFile() ...@@ -500,7 +500,7 @@ void SwXMLTextBlocks::CloseFile()
void SwXMLTextBlocks::SetIsTextOnly( const OUString& rShort, bool bNewValue ) void SwXMLTextBlocks::SetIsTextOnly( const OUString& rShort, bool bNewValue )
{ {
sal_uInt16 nIdx = GetIndex ( rShort ); sal_uInt16 nIdx = GetIndex ( rShort );
if (nIdx != (sal_uInt16) -1 && nIdx != USHRT_MAX) if (nIdx != USHRT_MAX)
aNames[nIdx]->bIsOnlyTxt = bNewValue; aNames[nIdx]->bIsOnlyTxt = bNewValue;
} }
...@@ -513,7 +513,7 @@ bool SwXMLTextBlocks::IsOnlyTextBlock( const OUString& rShort ) const ...@@ -513,7 +513,7 @@ bool SwXMLTextBlocks::IsOnlyTextBlock( const OUString& rShort ) const
{ {
sal_uInt16 nIdx = GetIndex ( rShort ); sal_uInt16 nIdx = GetIndex ( rShort );
bool bRet = false; bool bRet = false;
if (nIdx != (sal_uInt16) -1 && nIdx != USHRT_MAX) if (nIdx != USHRT_MAX)
{ {
bRet = aNames[nIdx]->bIsOnlyTxt; bRet = aNames[nIdx]->bIsOnlyTxt;
} }
......
...@@ -90,7 +90,7 @@ SwImpBlocks::SwImpBlocks( const OUString& rFile, bool ) ...@@ -90,7 +90,7 @@ SwImpBlocks::SwImpBlocks( const OUString& rFile, bool )
: aFile( rFile ), : aFile( rFile ),
aDateModified( Date::EMPTY ), aDateModified( Date::EMPTY ),
aTimeModified( tools::Time::EMPTY ), aTimeModified( tools::Time::EMPTY ),
pDoc( 0 ), nCur( (sal_uInt16)-1 ), pDoc( 0 ), nCur( USHRT_MAX ),
bReadOnly( true ), bInPutMuchBlocks( false ), bReadOnly( true ), bInPutMuchBlocks( false ),
bInfoChanged(false) bInfoChanged(false)
{ {
...@@ -146,7 +146,7 @@ sal_uInt16 SwImpBlocks::GetIndex( const OUString& rShort ) const ...@@ -146,7 +146,7 @@ sal_uInt16 SwImpBlocks::GetIndex( const OUString& rShort ) const
&& pName->aShort == s ) && pName->aShort == s )
return i; return i;
} }
return (sal_uInt16) -1; return USHRT_MAX;
} }
sal_uInt16 SwImpBlocks::GetLongIndex( const OUString& rLong ) const sal_uInt16 SwImpBlocks::GetLongIndex( const OUString& rLong ) const
...@@ -159,7 +159,7 @@ sal_uInt16 SwImpBlocks::GetLongIndex( const OUString& rLong ) const ...@@ -159,7 +159,7 @@ sal_uInt16 SwImpBlocks::GetLongIndex( const OUString& rLong ) const
&& pName->aLong == rLong ) && pName->aLong == rLong )
return i; return i;
} }
return (sal_uInt16) -1; return USHRT_MAX;
} }
OUString SwImpBlocks::GetShortName( sal_uInt16 n ) const OUString SwImpBlocks::GetShortName( sal_uInt16 n ) const
...@@ -187,7 +187,7 @@ void SwImpBlocks::AddName( const OUString& rShort, const OUString& rLong, ...@@ -187,7 +187,7 @@ void SwImpBlocks::AddName( const OUString& rShort, const OUString& rLong,
bool bOnlyTxt ) bool bOnlyTxt )
{ {
sal_uInt16 nIdx = GetIndex( rShort ); sal_uInt16 nIdx = GetIndex( rShort );
if( nIdx != (sal_uInt16) -1 ) if( nIdx != USHRT_MAX )
{ {
delete aNames[nIdx]; delete aNames[nIdx];
aNames.erase( aNames.begin() + nIdx ); aNames.erase( aNames.begin() + nIdx );
...@@ -280,12 +280,12 @@ sal_uInt16 SwTextBlocks::GetCount() const ...@@ -280,12 +280,12 @@ sal_uInt16 SwTextBlocks::GetCount() const
sal_uInt16 SwTextBlocks::GetIndex( const OUString& r ) const sal_uInt16 SwTextBlocks::GetIndex( const OUString& r ) const
{ {
return pImp ? pImp->GetIndex( r ) : (sal_uInt16) -1; return pImp ? pImp->GetIndex( r ) : USHRT_MAX;
} }
sal_uInt16 SwTextBlocks::GetLongIndex( const OUString& r ) const sal_uInt16 SwTextBlocks::GetLongIndex( const OUString& r ) const
{ {
return pImp ? (sal_uInt16)(pImp->GetLongIndex( r )) : (sal_uInt16) -1; return pImp ? pImp->GetLongIndex( r ) : USHRT_MAX;
} }
OUString SwTextBlocks::GetShortName( sal_uInt16 n ) const OUString SwTextBlocks::GetShortName( sal_uInt16 n ) const
...@@ -317,7 +317,7 @@ bool SwTextBlocks::Delete( sal_uInt16 n ) ...@@ -317,7 +317,7 @@ bool SwTextBlocks::Delete( sal_uInt16 n )
pImp->aNames.erase( pImp->aNames.begin() + n ); pImp->aNames.erase( pImp->aNames.begin() + n );
} }
if( n == pImp->nCur ) if( n == pImp->nCur )
pImp->nCur = (sal_uInt16) -1; pImp->nCur = USHRT_MAX;
if( !nErr ) if( !nErr )
nErr = pImp->MakeBlockList(); nErr = pImp->MakeBlockList();
} }
...@@ -331,7 +331,7 @@ bool SwTextBlocks::Delete( sal_uInt16 n ) ...@@ -331,7 +331,7 @@ bool SwTextBlocks::Delete( sal_uInt16 n )
sal_uInt16 SwTextBlocks::Rename( sal_uInt16 n, const OUString* s, const OUString* l ) sal_uInt16 SwTextBlocks::Rename( sal_uInt16 n, const OUString* s, const OUString* l )
{ {
sal_uInt16 nIdx = (sal_uInt16)-1; sal_uInt16 nIdx = USHRT_MAX;
if( pImp && !pImp->bInPutMuchBlocks ) if( pImp && !pImp->bInPutMuchBlocks )
{ {
pImp->nCur = nIdx; pImp->nCur = nIdx;
...@@ -344,7 +344,8 @@ sal_uInt16 SwTextBlocks::Rename( sal_uInt16 n, const OUString* s, const OUString ...@@ -344,7 +344,8 @@ sal_uInt16 SwTextBlocks::Rename( sal_uInt16 n, const OUString* s, const OUString
if( aNew.isEmpty() ) if( aNew.isEmpty() )
{ {
OSL_ENSURE( false, "No short name provided in the rename" ); OSL_ENSURE( false, "No short name provided in the rename" );
nErr = ERR_SWG_INTERNAL_ERROR; return (sal_uInt16) -1; nErr = ERR_SWG_INTERNAL_ERROR;
return USHRT_MAX;
} }
if( pImp->IsFileChanged() ) if( pImp->IsFileChanged() )
...@@ -401,7 +402,7 @@ bool SwTextBlocks::BeginGetDoc( sal_uInt16 n ) ...@@ -401,7 +402,7 @@ bool SwTextBlocks::BeginGetDoc( sal_uInt16 n )
pImp->ClearDoc(); pImp->ClearDoc();
nErr = pImp->GetDoc( n ); nErr = pImp->GetDoc( n );
if( nErr ) if( nErr )
pImp->nCur = (sal_uInt16)-1; pImp->nCur = USHRT_MAX;
else else
pImp->nCur = n; pImp->nCur = n;
} }
...@@ -442,14 +443,14 @@ bool SwTextBlocks::BeginPutDoc( const OUString& s, const OUString& l ) ...@@ -442,14 +443,14 @@ bool SwTextBlocks::BeginPutDoc( const OUString& s, const OUString& l )
sal_uInt16 SwTextBlocks::PutDoc() sal_uInt16 SwTextBlocks::PutDoc()
{ {
sal_uInt16 nIdx = (sal_uInt16)-1; sal_uInt16 nIdx = USHRT_MAX;
if( pImp ) if( pImp )
{ {
nErr = pImp->PutDoc(); nErr = pImp->PutDoc();
if( !nErr ) if( !nErr )
{ {
pImp->nCur = GetIndex( pImp->aShort ); pImp->nCur = GetIndex( pImp->aShort );
if( pImp->nCur != (sal_uInt16) -1 ) if( pImp->nCur != USHRT_MAX )
pImp->aNames[ pImp->nCur ]->aLong = pImp->aLong; pImp->aNames[ pImp->nCur ]->aLong = pImp->aLong;
else else
{ {
...@@ -472,7 +473,7 @@ sal_uInt16 SwTextBlocks::PutDoc() ...@@ -472,7 +473,7 @@ sal_uInt16 SwTextBlocks::PutDoc()
sal_uInt16 SwTextBlocks::PutText( const OUString& rShort, const OUString& rName, sal_uInt16 SwTextBlocks::PutText( const OUString& rShort, const OUString& rName,
const OUString& rTxt ) const OUString& rTxt )
{ {
sal_uInt16 nIdx = (sal_uInt16) -1; sal_uInt16 nIdx = USHRT_MAX;
if( pImp ) if( pImp )
{ {
bool bOk = pImp->bInPutMuchBlocks; bool bOk = pImp->bInPutMuchBlocks;
...@@ -488,11 +489,11 @@ sal_uInt16 SwTextBlocks::PutText( const OUString& rShort, const OUString& rName, ...@@ -488,11 +489,11 @@ sal_uInt16 SwTextBlocks::PutText( const OUString& rShort, const OUString& rName,
{ {
OUString aNew = GetAppCharClass().uppercase( rShort ); OUString aNew = GetAppCharClass().uppercase( rShort );
nErr = pImp->PutText( aNew, rName, rTxt ); nErr = pImp->PutText( aNew, rName, rTxt );
pImp->nCur = (sal_uInt16) -1; pImp->nCur = USHRT_MAX;
if( !nErr ) if( !nErr )
{ {
nIdx = GetIndex( pImp->aShort ); nIdx = GetIndex( pImp->aShort );
if( nIdx != (sal_uInt16) -1 ) if( nIdx != USHRT_MAX )
pImp->aNames[ nIdx ]->aLong = rName; pImp->aNames[ nIdx ]->aLong = rName;
else else
{ {
...@@ -524,7 +525,7 @@ void SwTextBlocks::ClearDoc() ...@@ -524,7 +525,7 @@ void SwTextBlocks::ClearDoc()
if( pImp ) if( pImp )
{ {
pImp->ClearDoc(); pImp->ClearDoc();
pImp->nCur = (sal_uInt16) -1; pImp->nCur = USHRT_MAX;
} }
} }
......
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