summaryrefslogtreecommitdiff
path: root/svl
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-10-20 07:38:42 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-10-22 07:55:46 +0200
commitb979e7181ff8c089b7809571791f7f287d01ae83 (patch)
tree659b9e39cde19d3e5fa418187893df93aeb89ac4 /svl
parent7ea01578eed8459678369d0256de016930b3af40 (diff)
loplugin:singlevalfields look for fields that can be bool
Change-Id: Ief773b661a8378a10db56943b32127c7a2c86d11 Reviewed-on: https://gerrit.libreoffice.org/62037 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svl')
-rw-r--r--svl/source/numbers/zforfind.cxx50
-rw-r--r--svl/source/numbers/zforfind.hxx4
2 files changed, 27 insertions, 27 deletions
diff --git a/svl/source/numbers/zforfind.cxx b/svl/source/numbers/zforfind.cxx
index 590cc0aabb54..59140e770717 100644
--- a/svl/source/numbers/zforfind.cxx
+++ b/svl/source/numbers/zforfind.cxx
@@ -66,7 +66,7 @@ const sal_uInt8 ImpSvNumberInputScan::nMatchedUsedAsReturn = 0x10;
static const sal_Unicode cNoBreakSpace = 0xA0;
static const sal_Unicode cNarrowNoBreakSpace = 0x202F;
-static const sal_Int16 kDefaultEra = 1; // Gregorian CE, positive year
+static const bool kDefaultEra = true; // Gregorian CE, positive year
ImpSvNumberInputScan::ImpSvNumberInputScan( SvNumberFormatter* pFormatterP )
:
@@ -99,7 +99,7 @@ void ImpSvNumberInputScan::Reset()
nSign = 0;
nESign = 0;
nDecPos = 0;
- nNegCheck = 0;
+ bNegCheck = false;
nStringsCnt = 0;
nNumericsCnt = 0;
nThousand = 0;
@@ -107,7 +107,7 @@ void ImpSvNumberInputScan::Reset()
nAmPm = 0;
nPosThousandString = 0;
nLogical = 0;
- mnEra = kDefaultEra;
+ mbEraCE = kDefaultEra;
nStringScanNumFor = 0;
nStringScanSign = 0;
nMatchedAllStrings = nMatchedVirgin;
@@ -871,7 +871,7 @@ inline bool ImpSvNumberInputScan::GetTime100SecSep( const OUString& rString, sal
* Read a sign including brackets
* '+' => 1
* '-' => -1
- * '(' => -1, nNegCheck = 1
+ * '(' => -1, bNegCheck = 1
* else => 0
*/
int ImpSvNumberInputScan::GetSign( const OUString& rString, sal_Int32& nPos )
@@ -883,7 +883,7 @@ int ImpSvNumberInputScan::GetSign( const OUString& rString, sal_Int32& nPos )
nPos++;
return 1;
case '(': // '(' similar to '-' ?!?
- nNegCheck = 1;
+ bNegCheck = true;
SAL_FALLTHROUGH;
case '-':
nPos++;
@@ -1050,7 +1050,7 @@ sal_uInt16 ImpSvNumberInputScan::ImplGetYear( sal_uInt16 nIndex )
// A year in another, not Gregorian CE era is never expanded.
// A year < 100 entered with at least 3 digits with leading 0 is taken
// as is without expansion.
- if (mnEra == kDefaultEra && nYear < 100 && nLen < 3)
+ if (mbEraCE == kDefaultEra && nYear < 100 && nLen < 3)
{
nYear = SvNumberFormatter::ExpandTwoDigitYear( nYear, nYear2000 );
}
@@ -2072,8 +2072,8 @@ input for the following reasons:
break;
} // switch (nNumericsCnt)
- if (mnEra != kDefaultEra)
- pCal->setValue( CalendarFieldIndex::ERA, mnEra );
+ if (mbEraCE != kDefaultEra)
+ pCal->setValue( CalendarFieldIndex::ERA, mbEraCE ? 1 : 0);
if ( res && pCal->isValid() )
{
@@ -2523,10 +2523,10 @@ bool ImpSvNumberInputScan::ScanMidString( const OUString& rString, sal_uInt16 nS
}
if (bSignedYear)
{
- if (mnEra != kDefaultEra) // signed year twice?
+ if (mbEraCE != kDefaultEra) // signed year twice?
return MatchedReturn();
- mnEra = 0; // BCE
+ mbEraCE = false; // BCE
}
}
@@ -2784,7 +2784,7 @@ bool ImpSvNumberInputScan::ScanEndString( const OUString& rString )
//!? catch time too?
{ // not signed yet
nSign = GetSign(rString, nPos); // 1- DM
- if (nNegCheck) // '(' as sign
+ if (bNegCheck) // '(' as sign
{
return MatchedReturn();
}
@@ -2795,9 +2795,9 @@ bool ImpSvNumberInputScan::ScanEndString( const OUString& rString )
}
SkipBlanks(rString, nPos);
- if (nNegCheck && SkipChar(')', rString, nPos)) // skip ')' if appropriate
+ if (bNegCheck && SkipChar(')', rString, nPos)) // skip ')' if appropriate
{
- nNegCheck = 0;
+ bNegCheck = false;
SkipBlanks(rString, nPos);
}
@@ -2816,15 +2816,15 @@ bool ImpSvNumberInputScan::ScanEndString( const OUString& rString )
{
nSign = GetSign(rString, nPos); // DM -
SkipBlanks(rString, nPos);
- if (nNegCheck) // 3 DM (
+ if (bNegCheck) // 3 DM (
{
return MatchedReturn();
}
}
- if ( nNegCheck && eScannedType == SvNumFormatType::CURRENCY &&
+ if ( bNegCheck && eScannedType == SvNumFormatType::CURRENCY &&
SkipChar(')', rString, nPos) )
{
- nNegCheck = 0; // ')' skipped
+ bNegCheck = false; // ')' skipped
SkipBlanks(rString, nPos); // only if currency
}
}
@@ -2967,11 +2967,11 @@ bool ImpSvNumberInputScan::ScanEndString( const OUString& rString )
}
}
- if ( nNegCheck && SkipChar(')', rString, nPos) )
+ if ( bNegCheck && SkipChar(')', rString, nPos) )
{
if (eScannedType == SvNumFormatType::CURRENCY) // only if currency
{
- nNegCheck = 0; // skip ')'
+ bNegCheck = false; // skip ')'
SkipBlanks(rString, nPos);
}
else
@@ -3216,7 +3216,7 @@ bool ImpSvNumberInputScan::IsNumberFormatMain( const OUString& rString, /
GetNextNumber(i,j); // i=1,2
if (eSetType == SvNumFormatType::FRACTION) // Fraction -1 = -1/1
{
- if (nSign && !nNegCheck && // Sign +, -
+ if (nSign && !bNegCheck && // Sign +, -
eScannedType == SvNumFormatType::UNDEFINED && // not date or currency
nDecPos == 0 && // no previous decimal separator
(i >= nStringsCnt || // no end string nor decimal separator
@@ -3254,7 +3254,7 @@ bool ImpSvNumberInputScan::IsNumberFormatMain( const OUString& rString, /
}
if (eSetType == SvNumFormatType::FRACTION) // -1,200. as fraction
{
- if (!nNegCheck && // no sign '('
+ if (!bNegCheck && // no sign '('
eScannedType == SvNumFormatType::UNDEFINED &&
(nDecPos == 0 || nDecPos == 3) // no decimal separator or at end
)
@@ -3302,7 +3302,7 @@ bool ImpSvNumberInputScan::IsNumberFormatMain( const OUString& rString, /
}
if (eSetType == SvNumFormatType::FRACTION) // -1,200,100. as fraction
{
- if (!nNegCheck && // no sign '('
+ if (!bNegCheck && // no sign '('
eScannedType == SvNumFormatType::UNDEFINED &&
(nDecPos == 0 || nDecPos == 3) // no decimal separator or at end
)
@@ -3376,7 +3376,7 @@ bool ImpSvNumberInputScan::IsNumberFormatMain( const OUString& rString, /
}
if (eSetType == SvNumFormatType::FRACTION) // -1,200,100. as fraction
{
- if (!nNegCheck && // no sign '('
+ if (!bNegCheck && // no sign '('
eScannedType == SvNumFormatType::UNDEFINED &&
(nDecPos == 0 || nDecPos == 3) // no decimal separator or at end
)
@@ -3641,7 +3641,7 @@ bool ImpSvNumberInputScan::IsNumberFormat( const OUString& rString, // s
// Accept only if the year immediately follows the sign character with
// no space in between.
if (nSign && (eScannedType == SvNumFormatType::DATE ||
- eScannedType == SvNumFormatType::DATETIME) && mnEra == kDefaultEra &&
+ eScannedType == SvNumFormatType::DATETIME) && mbEraCE == kDefaultEra &&
(IsDatePatternNumberOfType(0,'Y') || (MayBeIso8601() && sStrArray[nNums[0]].getLength() >= 4)))
{
const sal_Unicode c = sStrArray[0][sStrArray[0].getLength()-1];
@@ -3649,11 +3649,11 @@ bool ImpSvNumberInputScan::IsNumberFormat( const OUString& rString, // s
{
// A '+' sign doesn't change the era.
if (nSign < 0)
- mnEra = 0; // BCE
+ mbEraCE = false; // BCE
nSign = 0;
}
}
- if ( nNegCheck || // ')' not found for '('
+ if ( bNegCheck || // ')' not found for '('
(nSign && (eScannedType == SvNumFormatType::DATE ||
eScannedType == SvNumFormatType::DATETIME))) // signed date/datetime
{
diff --git a/svl/source/numbers/zforfind.hxx b/svl/source/numbers/zforfind.hxx
index e7ddb7e6f1d9..dfa9b6df4ed7 100644
--- a/svl/source/numbers/zforfind.hxx
+++ b/svl/source/numbers/zforfind.hxx
@@ -108,11 +108,11 @@ private:
int nDayOfWeek; // Temporary (!) day of week (1..7,-1..-7) if date
sal_uInt16 nTimePos; // Index of first time separator (+1)
short nDecPos; // Index of substring containing "," (+1)
- short nNegCheck; // '( )' for negative
+ bool bNegCheck; // '( )' for negative
short nESign; // Sign of exponent
short nAmPm; // +1 AM, -1 PM, 0 if none
short nLogical; // -1 => False, 1 => True
- sal_Int16 mnEra; // Era if date, 0 => BCE, 1 => CE (currently only Gregorian)
+ bool mbEraCE; // Era if date, 0 => BCE, 1 => CE (currently only Gregorian)
sal_uInt16 nThousand; // Count of group (AKA thousand) separators
sal_uInt16 nPosThousandString; // Position of concatenated 000,000,000 string
SvNumFormatType eScannedType; // Scanned type