summaryrefslogtreecommitdiff
path: root/vbahelper
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2020-01-26 15:10:03 +0100
committerStephan Bergmann <sbergman@redhat.com>2020-01-26 17:34:15 +0100
commit0288c8ffecff4956a52b9147d441979941e8b87f (patch)
treef1b8758bec896b4abb7e458a4eb395fce6f43c9b /vbahelper
parent2f019777fbbd2a1f9821f5d19608cc2a36413d9d (diff)
Rephrase cast from sal_Int32 to sal_uInt32
...to avoid false positives with upcoming loplugin:unsignedcompare: > vbahelper/source/msforms/vbacontrol.cxx:730:12: error: explicit cast from 'sal_Int32' (aka 'int') to 'sal_uInt32' (aka 'unsigned int') (of equal rank) in comparison against 'sal_uInt32': if the cast value is known to be non-negative, use o3tl::make_unsigned instead of the cast [loplugin:unsignedcompare] > if ( ( static_cast<sal_uInt32>(nBackColor) >= sal_uInt32(0x80000000) ) && > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > vbahelper/source/msforms/vbacontrol.cxx:731:12: error: explicit cast from 'sal_Int32' (aka 'int') to 'sal_uInt32' (aka 'unsigned int') (of equal rank) in comparison against 'unsigned long': if the cast value is known to be non-negative, use o3tl::make_unsigned instead of the cast [loplugin:unsignedcompare] > ( static_cast<sal_uInt32>(nBackColor) <= sal_uInt32(0x80000000) + SAL_N_ELEMENTS(nSysCols) ) ) > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ (This is the only case I found where the plugin's heuristics failed.) Change-Id: I36d12caa0f837b8ba860eaf33b3e166a4f1001fb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87454 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'vbahelper')
-rw-r--r--vbahelper/source/msforms/vbacontrol.cxx7
1 files changed, 4 insertions, 3 deletions
diff --git a/vbahelper/source/msforms/vbacontrol.cxx b/vbahelper/source/msforms/vbacontrol.cxx
index 1e877c66d063..bcbbbdcd446e 100644
--- a/vbahelper/source/msforms/vbacontrol.cxx
+++ b/vbahelper/source/msforms/vbacontrol.cxx
@@ -727,10 +727,11 @@ sal_Int32 ScVbaControl::getBackColor()
void ScVbaControl::setBackColor( sal_Int32 nBackColor )
{
- if ( ( static_cast<sal_uInt32>(nBackColor) >= sal_uInt32(0x80000000) ) &&
- ( static_cast<sal_uInt32>(nBackColor) <= sal_uInt32(0x80000000) + SAL_N_ELEMENTS(nSysCols) ) )
+ auto const col = static_cast<sal_uInt32>(nBackColor);
+ if ( ( col >= sal_uInt32(0x80000000) ) &&
+ ( col <= sal_uInt32(0x80000000) + SAL_N_ELEMENTS(nSysCols) ) )
{
- nBackColor = nSysCols[ nBackColor & 0x0FF];
+ nBackColor = nSysCols[ col & 0x0FF];
}
m_xProps->setPropertyValue( "BackgroundColor" , uno::makeAny( XLRGBToOORGB( nBackColor ) ) );
}