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

Use more proper types, constify, avoid magic numbers

Change-Id: I15d0fd7de815398ae7323209c5e1d3613b722401
üst 698ee302
...@@ -250,7 +250,7 @@ SwTwips SwTxtFrm::EmptyHeight() const ...@@ -250,7 +250,7 @@ SwTwips SwTxtFrm::EmptyHeight() const
const IDocumentRedlineAccess* pIDRA = rTxtNode.getIDocumentRedlineAccess(); const IDocumentRedlineAccess* pIDRA = rTxtNode.getIDocumentRedlineAccess();
if( IDocumentRedlineAccess::IsShowChanges( pIDRA->GetRedlineMode() ) ) if( IDocumentRedlineAccess::IsShowChanges( pIDRA->GetRedlineMode() ) )
{ {
sal_uInt16 nRedlPos = pIDRA->GetRedlinePos( rTxtNode, USHRT_MAX ); const sal_uInt16 nRedlPos = pIDRA->GetRedlinePos( rTxtNode, USHRT_MAX );
if( USHRT_MAX != nRedlPos ) if( USHRT_MAX != nRedlPos )
{ {
SwAttrHandler aAttrHandler; SwAttrHandler aAttrHandler;
...@@ -405,7 +405,7 @@ bool SwTxtFrm::FillRegister( SwTwips& rRegStart, sal_uInt16& rRegDiff ) ...@@ -405,7 +405,7 @@ bool SwTxtFrm::FillRegister( SwTwips& rRegStart, sal_uInt16& rRegDiff )
break; break;
case SVX_LINE_SPACE_MIN: case SVX_LINE_SPACE_MIN:
{ {
if( rRegDiff < sal_uInt16( rSpace.GetLineHeight() ) ) if( rRegDiff < rSpace.GetLineHeight() )
rRegDiff = rSpace.GetLineHeight(); rRegDiff = rSpace.GetLineHeight();
break; break;
} }
......
...@@ -470,7 +470,7 @@ void SwTxtPortion::FormatEOL( SwTxtFormatInfo &rInf ) ...@@ -470,7 +470,7 @@ void SwTxtPortion::FormatEOL( SwTxtFormatInfo &rInf )
{ {
// calculate number of blanks // calculate number of blanks
sal_Int32 nX = rInf.GetIdx() - 1; sal_Int32 nX = rInf.GetIdx() - 1;
sal_uInt16 nHoleLen = 1; sal_Int32 nHoleLen = 1;
while( nX && nHoleLen < GetLen() && CH_BLANK == rInf.GetChar( --nX ) ) while( nX && nHoleLen < GetLen() && CH_BLANK == rInf.GetChar( --nX ) )
nHoleLen++; nHoleLen++;
......
...@@ -94,16 +94,15 @@ void SwAttrIter::CtorInitAttrIter( SwTxtNode& rTxtNode, SwScriptInfo& rScrInf, S ...@@ -94,16 +94,15 @@ void SwAttrIter::CtorInitAttrIter( SwTxtNode& rTxtNode, SwScriptInfo& rScrInf, S
pFnt->SetActual( SwScriptInfo::WhichFont( 0, 0, pScriptInfo ) ); pFnt->SetActual( SwScriptInfo::WhichFont( 0, 0, pScriptInfo ) );
sal_Int32 nChg = 0; sal_Int32 nChg = 0;
sal_uInt16 nCnt = 0; size_t nCnt = 0;
do do
{ {
if ( nCnt >= pScriptInfo->CountScriptChg() ) if ( nCnt >= pScriptInfo->CountScriptChg() )
break; break;
nChg = pScriptInfo->GetScriptChg( nCnt ); nChg = pScriptInfo->GetScriptChg( nCnt );
sal_uInt16 nScript = pScriptInfo->GetScriptType( nCnt++ ); int nTmp = SW_SCRIPTS;
sal_uInt8 nTmp = 4; switch ( pScriptInfo->GetScriptType( nCnt++ ) ) {
switch ( nScript ) {
case i18n::ScriptType::ASIAN : case i18n::ScriptType::ASIAN :
if( !aMagicNo[SW_CJK] ) nTmp = SW_CJK; break; if( !aMagicNo[SW_CJK] ) nTmp = SW_CJK; break;
case i18n::ScriptType::COMPLEX : case i18n::ScriptType::COMPLEX :
...@@ -111,7 +110,7 @@ void SwAttrIter::CtorInitAttrIter( SwTxtNode& rTxtNode, SwScriptInfo& rScrInf, S ...@@ -111,7 +110,7 @@ void SwAttrIter::CtorInitAttrIter( SwTxtNode& rTxtNode, SwScriptInfo& rScrInf, S
default: default:
if( !aMagicNo[SW_LATIN ] ) nTmp = SW_LATIN; if( !aMagicNo[SW_LATIN ] ) nTmp = SW_LATIN;
} }
if( nTmp < 4 ) if( nTmp < SW_SCRIPTS )
{ {
pFnt->ChkMagic( pShell, nTmp ); pFnt->ChkMagic( pShell, nTmp );
pFnt->GetMagic( aMagicNo[ nTmp ], aFntIdx[ nTmp ], nTmp ); pFnt->GetMagic( aMagicNo[ nTmp ], aFntIdx[ nTmp ], nTmp );
...@@ -133,7 +132,7 @@ void SwAttrIter::CtorInitAttrIter( SwTxtNode& rTxtNode, SwScriptInfo& rScrInf, S ...@@ -133,7 +132,7 @@ void SwAttrIter::CtorInitAttrIter( SwTxtNode& rTxtNode, SwScriptInfo& rScrInf, S
const bool bShow = IDocumentRedlineAccess::IsShowChanges( pIDRA->GetRedlineMode() ); const bool bShow = IDocumentRedlineAccess::IsShowChanges( pIDRA->GetRedlineMode() );
if( pExtInp || bShow ) if( pExtInp || bShow )
{ {
sal_uInt16 nRedlPos = pIDRA->GetRedlinePos( rTxtNode, USHRT_MAX ); const sal_uInt16 nRedlPos = pIDRA->GetRedlinePos( rTxtNode, USHRT_MAX );
if( pExtInp || USHRT_MAX != nRedlPos ) if( pExtInp || USHRT_MAX != nRedlPos )
{ {
const std::vector<sal_uInt16> *pArr = 0; const std::vector<sal_uInt16> *pArr = 0;
...@@ -364,7 +363,7 @@ bool SwRedlineItr::_ChkSpecialUnderline() const ...@@ -364,7 +363,7 @@ bool SwRedlineItr::_ChkSpecialUnderline() const
// below the base line // below the base line
for (size_t i = 0; i < m_Hints.size(); ++i) for (size_t i = 0; i < m_Hints.size(); ++i)
{ {
sal_uInt16 nWhich = m_Hints[i]->Which(); const sal_uInt16 nWhich = m_Hints[i]->Which();
if( RES_CHRATR_UNDERLINE == nWhich || if( RES_CHRATR_UNDERLINE == nWhich ||
RES_CHRATR_ESCAPEMENT == nWhich ) RES_CHRATR_ESCAPEMENT == nWhich )
return true; return true;
...@@ -442,11 +441,11 @@ short SwExtend::Enter(SwFont& rFnt, sal_Int32 nNew) ...@@ -442,11 +441,11 @@ short SwExtend::Enter(SwFont& rFnt, sal_Int32 nNew)
bool SwExtend::_Leave(SwFont& rFnt, sal_Int32 nNew) bool SwExtend::_Leave(SwFont& rFnt, sal_Int32 nNew)
{ {
OSL_ENSURE( Inside(), "SwExtend: Leave without Enter" ); OSL_ENSURE( Inside(), "SwExtend: Leave without Enter" );
sal_uInt16 nOldAttr = rArr[ nPos - nStart ]; const sal_uInt16 nOldAttr = rArr[ nPos - nStart ];
nPos = nNew; nPos = nNew;
if( Inside() ) if( Inside() )
{ // We stayed within the ExtendText-section { // We stayed within the ExtendText-section
sal_uInt16 nAttr = rArr[ nPos - nStart ]; const sal_uInt16 nAttr = rArr[ nPos - nStart ];
if( nOldAttr != nAttr ) // Is there an (inner) change of attributes? if( nOldAttr != nAttr ) // Is there an (inner) change of attributes?
{ {
rFnt = *pFnt; rFnt = *pFnt;
...@@ -473,8 +472,8 @@ sal_Int32 SwExtend::Next( sal_Int32 nNext ) ...@@ -473,8 +472,8 @@ sal_Int32 SwExtend::Next( sal_Int32 nNext )
else if( nPos < nEnd ) else if( nPos < nEnd )
{ {
sal_Int32 nIdx = nPos - nStart; sal_Int32 nIdx = nPos - nStart;
sal_uInt16 nAttr = rArr[ nIdx ]; const sal_uInt16 nAttr = rArr[ nIdx ];
while( ++nIdx < (sal_Int32)rArr.size() && nAttr == rArr[ nIdx ] ) while( static_cast<size_t>(++nIdx) < rArr.size() && nAttr == rArr[ nIdx ] )
; //nothing ; //nothing
nIdx = nIdx + nStart; nIdx = nIdx + nStart;
if( nNext > nIdx ) if( nNext > nIdx )
......
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