int + sal_True/sal_False ==> bool, and reduce scope of a static variable

Change-Id: I8006aaa4474f086ce5381f59afcf7a5f15279b55
This commit is contained in:
Matteo Casalin
2014-11-09 22:58:58 +01:00
parent b60d741be6
commit f2eb1eabd5
8 changed files with 45 additions and 44 deletions

View File

@@ -691,7 +691,7 @@ bool SwAttrCheckArr::CheckStack()
return nFound == aCmpSet.Count();
}
static int lcl_SearchForward( const SwTxtNode& rTxtNd, SwAttrCheckArr& rCmpArr,
static bool lcl_SearchForward( const SwTxtNode& rTxtNd, SwAttrCheckArr& rCmpArr,
SwPaM& rPam )
{
sal_Int32 nEndPos;
@@ -699,10 +699,10 @@ static int lcl_SearchForward( const SwTxtNode& rTxtNd, SwAttrCheckArr& rCmpArr,
if( !rTxtNd.HasHints() )
{
if( !rCmpArr.Found() )
return sal_False;
return false;
nEndPos = rCmpArr.GetNdEnd();
lcl_SetAttrPam( rPam, rCmpArr.GetNdStt(), &nEndPos, true );
return sal_True;
return true;
}
const SwpHints& rHtArr = rTxtNd.GetSwpHints();
@@ -720,7 +720,7 @@ static int lcl_SearchForward( const SwTxtNode& rTxtNd, SwAttrCheckArr& rCmpArr,
// found end
lcl_SetAttrPam( rPam, rCmpArr.GetNdStt(),
&pAttr->GetStart(), true );
return sal_True;
return true;
}
// continue search
break;
@@ -731,7 +731,7 @@ static int lcl_SearchForward( const SwTxtNode& rTxtNd, SwAttrCheckArr& rCmpArr,
// found
nEndPos = rCmpArr.GetNdEnd();
lcl_SetAttrPam( rPam, rCmpArr.GetNdStt(), &nEndPos, true );
return sal_True;
return true;
}
}
@@ -751,21 +751,21 @@ static int lcl_SearchForward( const SwTxtNode& rTxtNd, SwAttrCheckArr& rCmpArr,
// then we have our search area
if( (nSttPos = rCmpArr.Start()) > (nEndPos = rCmpArr.End()) )
return sal_False;
return false;
lcl_SetAttrPam( rPam, nSttPos, &nEndPos, true );
return sal_True;
return true;
}
if( !rCmpArr.CheckStack() ||
(nSttPos = rCmpArr.Start()) > (nEndPos = rCmpArr.End()) )
return sal_False;
return false;
lcl_SetAttrPam( rPam, nSttPos, &nEndPos, true );
return sal_True;
return true;
}
static int lcl_SearchBackward( const SwTxtNode& rTxtNd, SwAttrCheckArr& rCmpArr,
static bool lcl_SearchBackward( const SwTxtNode& rTxtNd, SwAttrCheckArr& rCmpArr,
SwPaM& rPam )
{
sal_Int32 nEndPos;
@@ -773,10 +773,10 @@ static int lcl_SearchBackward( const SwTxtNode& rTxtNd, SwAttrCheckArr& rCmpArr,
if( !rTxtNd.HasHints() )
{
if( !rCmpArr.Found() )
return sal_False;
return false;
nEndPos = rCmpArr.GetNdEnd();
lcl_SetAttrPam( rPam, rCmpArr.GetNdStt(), &nEndPos, false );
return sal_True;
return true;
}
const SwpHints& rHtArr = rTxtNd.GetSwpHints();
@@ -796,7 +796,7 @@ static int lcl_SearchBackward( const SwTxtNode& rTxtNd, SwAttrCheckArr& rCmpArr,
// found end
nEndPos = rCmpArr.GetNdEnd();
lcl_SetAttrPam( rPam, nSttPos, &nEndPos, false );
return sal_True;
return true;
}
// continue search
@@ -808,7 +808,7 @@ static int lcl_SearchBackward( const SwTxtNode& rTxtNd, SwAttrCheckArr& rCmpArr,
// found
nEndPos = rCmpArr.GetNdEnd();
lcl_SetAttrPam( rPam, rCmpArr.GetNdStt(), &nEndPos, false );
return sal_True;
return true;
}
}
@@ -829,25 +829,25 @@ static int lcl_SearchBackward( const SwTxtNode& rTxtNd, SwAttrCheckArr& rCmpArr,
// then we have our search area
if( (nSttPos = rCmpArr.Start()) > (nEndPos = rCmpArr.End()) )
return sal_False;
return false;
lcl_SetAttrPam( rPam, nSttPos, &nEndPos, false );
return sal_True;
return true;
}
if( !rCmpArr.CheckStack() ||
(nSttPos = rCmpArr.Start()) > (nEndPos = rCmpArr.End()) )
return sal_False;
return false;
lcl_SetAttrPam( rPam, nSttPos, &nEndPos, false );
return sal_True;
return true;
}
static int lcl_Search( const SwCntntNode& rCNd, const SfxItemSet& rCmpSet, bool bNoColls )
static bool lcl_Search( const SwCntntNode& rCNd, const SfxItemSet& rCmpSet, bool bNoColls )
{
// search only hard attribution?
if( bNoColls && !rCNd.HasSwAttrSet() )
return sal_False;
return false;
const SfxItemSet& rNdSet = rCNd.GetSwAttrSet();
SfxItemIter aIter( rCmpSet );
@@ -862,21 +862,21 @@ static int lcl_Search( const SwCntntNode& rCNd, const SfxItemSet& rCmpSet, bool
nWhich = rCmpSet.GetWhichByPos( aIter.GetCurPos() );
if( SfxItemState::SET != rNdSet.GetItemState( nWhich, !bNoColls, &pNdItem )
|| CmpAttr( *pNdItem, rNdSet.GetPool()->GetDefaultItem( nWhich ) ))
return sal_False;
return false;
}
else
{
nWhich = pItem->Which();
if( !CmpAttr( rNdSet.Get( nWhich, !bNoColls ), *pItem ))
return sal_False;
return false;
}
if( aIter.IsAtEnd() )
break;
pItem = aIter.NextItem();
}
return sal_True; // found
return true; // found
}
bool SwPaM::Find( const SfxPoolItem& rAttr, bool bValue, SwMoveFn fnMove,
@@ -959,7 +959,7 @@ bool SwPaM::Find( const SfxPoolItem& rAttr, bool bValue, SwMoveFn fnMove,
return bFound;
}
typedef int (*FnSearchAttr)( const SwTxtNode&, SwAttrCheckArr&, SwPaM& );
typedef bool (*FnSearchAttr)( const SwTxtNode&, SwAttrCheckArr&, SwPaM& );
bool SwPaM::Find( const SfxItemSet& rSet, bool bNoColls, SwMoveFn fnMove,
const SwPaM *pRegion, bool bInReadOnly, bool bMoveFirst )

View File

@@ -495,7 +495,7 @@ void SwDoc::ResetAttrAtFormat( const sal_uInt16 nWhichId,
delete pUndo;
}
static int lcl_SetNewDefTabStops( SwTwips nOldWidth, SwTwips nNewWidth,
static bool lcl_SetNewDefTabStops( SwTwips nOldWidth, SwTwips nNewWidth,
SvxTabStopItem& rChgTabStop )
{
// Set the default values of all TabStops to the new value.
@@ -505,7 +505,7 @@ static int lcl_SetNewDefTabStops( SwTwips nOldWidth, SwTwips nNewWidth,
sal_uInt16 nOldCnt = rChgTabStop.Count();
if( !nOldCnt || nOldWidth == nNewWidth )
return sal_False;
return false;
// Find the default's beginning
sal_uInt16 n;
@@ -515,7 +515,7 @@ static int lcl_SetNewDefTabStops( SwTwips nOldWidth, SwTwips nNewWidth,
++n;
if( n < nOldCnt ) // delete the DefTabStops
rChgTabStop.Remove( n, nOldCnt - n );
return sal_True;
return true;
}
/// Set the attribute as new default attribute in this document.
@@ -614,7 +614,7 @@ void SwDoc::SetDefault( const SfxItemSet& rSet )
SwTwips nNewWidth = (*static_cast<const SvxTabStopItem*>(pTmpItem))[ 0 ].GetTabPos(),
nOldWidth = static_cast<const SvxTabStopItem&>(aOld.Get(RES_PARATR_TABSTOP))[ 0 ].GetTabPos();
int bChg = sal_False;
bool bChg = false;
sal_uInt32 nMaxItems = GetAttrPool().GetItemCount2( RES_PARATR_TABSTOP );
for( sal_uInt32 n = 0; n < nMaxItems; ++n )
if( 0 != (pTmpItem = GetAttrPool().GetItem2( RES_PARATR_TABSTOP, n ) ))

View File

@@ -102,7 +102,7 @@ public:
// Search for fields. If no valid found, disconnect.
SwMsgPoolItem aUpdateDDE( RES_UPDATEDDETBL );
int bCallModify = sal_False;
bool bCallModify = false;
rFldType.LockModify();
SwClientIter aIter( rFldType ); // TODO
@@ -121,7 +121,7 @@ public:
pSh->StartAction();
}
pLast->ModifyNotification( 0, &aUpdateDDE );
bCallModify = sal_True;
bCallModify = true;
}
} while( 0 != ( pLast = ++aIter ));

View File

@@ -440,10 +440,8 @@ Writer& OutHTML_SwFmtFld( Writer& rWrt, const SfxPoolItem& rHt )
if( RES_SETEXPFLD == pFldTyp->Which() &&
(nsSwGetSetExpType::GSE_STRING & pFld->GetSubType()) )
{
int bOn = sal_False;
if (pFldTyp->GetName() == "HTML_ON")
bOn = sal_True;
else if (pFldTyp->GetName() != "HTML_OFF")
const bool bOn = pFldTyp->GetName() == "HTML_ON";
if (!bOn && pFldTyp->GetName() != "HTML_OFF")
return rWrt;
OUString rTxt(comphelper::string::strip(pFld->GetPar2(), ' '));

View File

@@ -3132,8 +3132,6 @@ static CSS1PropEntry aCSS1PropFnTab[] =
CSS1_PROP_ENTRY(so_language)
};
static int bSortedPropFns = sal_False;
extern "C"
{
static int SAL_CALL CSS1PropEntryCompare( const void *pFirst, const void *pSecond)
@@ -3167,13 +3165,15 @@ void SvxCSS1Parser::ParseProperty( const OUString& rProperty,
{
OSL_ENSURE( pItemSet, "DeclarationParsed() without ItemSet" );
static bool bSortedPropFns = false;
if( !bSortedPropFns )
{
qsort( (void*) aCSS1PropFnTab,
sizeof( aCSS1PropFnTab ) / sizeof( CSS1PropEntry ),
sizeof( CSS1PropEntry ),
CSS1PropEntryCompare );
bSortedPropFns = sal_True;
bSortedPropFns = true;
}
OUString aTmp( rProperty.toAsciiLowerCase() );

View File

@@ -633,7 +633,7 @@ void SwTextShell::StateField( SfxItemSet &rSet )
SwWrtShell& rSh = GetShell();
SfxWhichIter aIter( rSet );
const SwField* pField = 0;
int bGetField = sal_False;
bool bGetField = false;
sal_uInt16 nWhich = aIter.FirstWhich();
while (nWhich)
@@ -664,7 +664,7 @@ void SwTextShell::StateField( SfxItemSet &rSet )
if( !bGetField )
{
pField = rSh.GetCurFld();
bGetField = sal_True;
bGetField = true;
}
sal_uInt16 nTempWhich = pField ? pField->GetTyp()->Which() : USHRT_MAX;
@@ -687,7 +687,7 @@ void SwTextShell::StateField( SfxItemSet &rSet )
if(!bGetField)
{
pField = rSh.GetCurFld();
bGetField = sal_True;
bGetField = true;
}
if(!pField || pField->GetTyp()->Which() != RES_MACROFLD)
rSet.DisableItem(nWhich);

View File

@@ -68,7 +68,7 @@ void SwView::GetState(SfxItemSet &rSet)
SfxWhichIter aIter(rSet);
sal_uInt16 nWhich = aIter.FirstWhich();
sal_uInt16 eFrmType = FRMTYPE_NONE;
int bGetFrmType = sal_False;
bool bGetFrmType = false;
bool bWeb = 0 != PTR_CAST(SwWebView, this);
while(nWhich)
@@ -96,7 +96,10 @@ void SwView::GetState(SfxItemSet &rSet)
{
// There are captions for graphics, OLE objects, frames and tables
if( !bGetFrmType )
eFrmType = m_pWrtShell->GetFrmType(0,true), bGetFrmType = sal_True;
{
eFrmType = m_pWrtShell->GetFrmType(0, true);
bGetFrmType = true;
}
if (! ( ((eFrmType & FRMTYPE_FLY_ANY) && m_nSelectionType != nsSelectionType::SEL_DRW_TXT)||
m_nSelectionType & nsSelectionType::SEL_TBL ||
m_nSelectionType & nsSelectionType::SEL_DRW) )

View File

@@ -1746,7 +1746,7 @@ void SwWrtShell::ChangeHeaderOrFooter(
for( sal_uInt16 nFrom = 0, nTo = GetPageDescCnt();
nFrom < nTo; ++nFrom )
{
int bChgd = sal_False;
bool bChgd = false;
SwPageDesc aDesc( GetPageDesc( nFrom ));
OUString sTmp(aDesc.GetName());
if( rStyleName.isEmpty() || rStyleName == sTmp )
@@ -1771,7 +1771,7 @@ void SwWrtShell::ChangeHeaderOrFooter(
}
if( bExecute )
{
bChgd = sal_True;
bChgd = true;
SwFrmFmt &rMaster = aDesc.GetMaster();
if(bHeader)
rMaster.SetFmtAttr( SwFmtHeader( bOn ));