two changes of suspicious code (sc, sw)

Stephan Bergmann sbergman at redhat.com
Fri Apr 17 07:35:28 PDT 2015


The updated loplugin:implicitboolconversion now also warns about 
implicit conversions from bool to unsigned char (which had been left out 
in the past because it is hard to distinguish plain unsigned char from 
bool-like typedefs like sal_Bool, when the typedef is used as a type 
argument of a template specialization, as in 
css::uno::Sequence<sal_Bool>).  That flagged two places that I tried to 
fix as best I could, but wouldn't mind if others more familiar with the 
respective code would take a look, too:

One is in sc:

> commit c007829a67456ef01b82b8368f7ed3e5a3026c95
> Author: Stephan Bergmann <sbergman at redhat.com>
> Date:   Fri Apr 17 14:24:35 2015 +0200
>
>     Clean up conversions from ScBreakType (aka sal_uInt8) to bool
>
>     ...assuming these shall indeed all convert everything but BREAK_NONE to true?
>
>     Change-Id: Ib1c863bfbf9be58aa7867aa69c8347f6358f6550
>
> diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx
> index c2b9637..7fa734f 100644
> --- a/sc/source/ui/unoobj/cellsuno.cxx
> +++ b/sc/source/ui/unoobj/cellsuno.cxx
> @@ -8871,7 +8871,7 @@ void ScTableColumnObj::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pE
>          else if ( pEntry->nWID == SC_WID_UNO_NEWPAGE )
>          {
>              ScBreakType nBreak = rDoc.HasColBreak(nCol, nTab);
> -            ScUnoHelpFunctions::SetBoolInAny( rAny, nBreak );
> +            ScUnoHelpFunctions::SetBoolInAny( rAny, nBreak != BREAK_NONE );
>          }
>          else if ( pEntry->nWID == SC_WID_UNO_MANPAGE )
>          {
> @@ -9024,12 +9024,12 @@ void ScTableRowObj::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntr
>          else if ( pEntry->nWID == SC_WID_UNO_NEWPAGE )
>          {
>              ScBreakType nBreak = rDoc.HasRowBreak(nRow, nTab);
> -            ScUnoHelpFunctions::SetBoolInAny( rAny, nBreak );
> +            ScUnoHelpFunctions::SetBoolInAny( rAny, nBreak != BREAK_NONE );
>          }
>          else if ( pEntry->nWID == SC_WID_UNO_MANPAGE )
>          {
>              ScBreakType nBreak = (rDoc.HasRowBreak(nRow, nTab) & BREAK_MANUAL);
> -            ScUnoHelpFunctions::SetBoolInAny( rAny, nBreak );
> +            ScUnoHelpFunctions::SetBoolInAny( rAny, nBreak != BREAK_NONE );
>          }
>          else
>              ScCellRangeObj::GetOnePropertyValue(pEntry, rAny);
> diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
> index 20ffa33..6bbc540 100644
> --- a/sc/source/ui/unoobj/docuno.cxx
> +++ b/sc/source/ui/unoobj/docuno.cxx
> @@ -3543,7 +3543,7 @@ uno::Any SAL_CALL ScTableColumnsObj::getPropertyValue( const OUString& aProperty
>      else if ( aNameString == SC_UNONAME_NEWPAGE )
>      {
>          ScBreakType nBreak = rDoc.HasColBreak(nStartCol, nTab);
> -        ScUnoHelpFunctions::SetBoolInAny( aAny, nBreak );
> +        ScUnoHelpFunctions::SetBoolInAny( aAny, nBreak != BREAK_NONE );
>      }
>      else if ( aNameString == SC_UNONAME_MANPAGE )
>      {
> @@ -3820,7 +3820,7 @@ uno::Any SAL_CALL ScTableRowsObj::getPropertyValue( const OUString& aPropertyNam
>      else if ( aNameString == SC_UNONAME_NEWPAGE )
>      {
>          ScBreakType nBreak = rDoc.HasRowBreak(nStartRow, nTab);
> -        ScUnoHelpFunctions::SetBoolInAny( aAny, nBreak );
> +        ScUnoHelpFunctions::SetBoolInAny( aAny, nBreak != BREAK_NONE );
>      }
>      else if ( aNameString == SC_UNONAME_MANPAGE )
>      {

And the other is in sw:

> commit 0b49aaf09becf8775411b7082b95e87086e8b5d7
> Author: Stephan Bergmann <sbergman at redhat.com>
> Date:   Fri Apr 17 11:46:38 2015 +0200
>
>     loplugin:implicitboolconversion gold?
>
>     The code was like that ever since 84a3db80b4fd66c6854b3135b5f69b61fd828e62
>     "initial import" but looks very much like the intent was to make the conditional
>     operator bind tighter than the less-than operator.
>
>     Change-Id: I810aa5dc56f02e98111f4879db50c59a9b69b8d6
>
> diff --git a/sw/source/core/edit/ednumber.cxx b/sw/source/core/edit/ednumber.cxx
> index c885aac..ee3b3c8 100644
> --- a/sw/source/core/edit/ednumber.cxx
> +++ b/sw/source/core/edit/ednumber.cxx
> @@ -510,7 +510,7 @@ bool SwEditShell::MoveNumParas( bool bUpperLower, bool bUpperLeft )
>                  bRet = GetDoc()->MoveParagraph( aCrsr, nOffset );
>              }
>          }
> -        else if( bUpperLeft ? nUpperLevel : nLowerLevel+1 < MAXLEVEL )
> +        else if( (bUpperLeft ? nUpperLevel : nLowerLevel+1) < MAXLEVEL )
>          {
>              aCrsr.Move( fnMoveBackward, fnGoNode );
>              bRet = GetDoc()->NumUpDown( aCrsr, !bUpperLeft );


More information about the LibreOffice mailing list