summaryrefslogtreecommitdiff
path: root/svtools
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-10-15 08:48:36 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-10-17 08:25:06 +0200
commit16690220ed6e68f2e9674a09b5008f38c5e6ed8d (patch)
tree2f830b7ac23f136585e7dc4adf5d456f4995cc99 /svtools
parent86d70dc840b88ed827d6d8febaf512264009951d (diff)
loplugin:singlevalfields
tighten up the handling of binary operators Change-Id: I262ec57bf7142fa094d240738150a94d83fd15ee Reviewed-on: https://gerrit.libreoffice.org/61777 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svtools')
-rw-r--r--svtools/source/control/ctrlbox.cxx136
1 files changed, 4 insertions, 132 deletions
diff --git a/svtools/source/control/ctrlbox.cxx b/svtools/source/control/ctrlbox.cxx
index 6efb5c2a9777..4044ad61da84 100644
--- a/svtools/source/control/ctrlbox.cxx
+++ b/svtools/source/control/ctrlbox.cxx
@@ -1261,7 +1261,6 @@ void FontSizeBox::ImplInit()
{
EnableAutocomplete( false );
- bRelativeMode = false;
bPtRelative = false;
bRelative = false;
bStdSize = false;
@@ -1277,69 +1276,14 @@ void FontSizeBox::ImplInit()
void FontSizeBox::Reformat()
{
FontSizeNames aFontSizeNames( GetSettings().GetUILanguageTag().getLanguageType() );
- if ( !bRelativeMode || !aFontSizeNames.IsEmpty() )
+ long nNewValue = aFontSizeNames.Name2Size( GetText() );
+ if ( nNewValue)
{
- long nNewValue = aFontSizeNames.Name2Size( GetText() );
- if ( nNewValue)
- {
- mnLastValue = nNewValue;
- return;
- }
- }
-
- MetricBox::Reformat();
-}
-
-void FontSizeBox::Modify()
-{
- MetricBox::Modify();
-
- if ( !bRelativeMode )
+ mnLastValue = nNewValue;
return;
-
- OUString aStr = comphelper::string::stripStart(GetText(), ' ');
-
- bool bNewMode = bRelative;
- bool bOldPtRelMode = bPtRelative;
-
- if ( bRelative )
- {
- bPtRelative = false;
- const sal_Unicode* pStr = aStr.getStr();
- while ( *pStr )
- {
- if ( ((*pStr < '0') || (*pStr > '9')) && (*pStr != '%') && !unicode::isSpace(*pStr) )
- {
- if ( ('-' == *pStr || '+' == *pStr) && !bPtRelative )
- bPtRelative = true;
- else if ( bPtRelative && 'p' == *pStr && 't' == *++pStr )
- ;
- else
- {
- bNewMode = false;
- break;
- }
- }
- pStr++;
- }
- }
- else if (!aStr.isEmpty())
- {
- if ( -1 != aStr.indexOf('%') )
- {
- bNewMode = true;
- bPtRelative = false;
- }
-
- if ( '-' == aStr[0] || '+' == aStr[0] )
- {
- bNewMode = true;
- bPtRelative = true;
- }
}
- if ( bNewMode != bRelative || bPtRelative != bOldPtRelMode )
- SetRelative( bNewMode );
+ MetricBox::Reformat();
}
void FontSizeBox::Fill( const FontMetric* pFontMetric, const FontList* pList )
@@ -1430,78 +1374,6 @@ void FontSizeBox::Fill( const FontMetric* pFontMetric, const FontList* pList )
SetSelection( aSelection );
}
-void FontSizeBox::SetRelative( bool bNewRelative )
-{
- if ( !bRelativeMode )
- return;
-
- Selection aSelection = GetSelection();
- OUString aStr = comphelper::string::stripStart(GetText(), ' ');
-
- if ( bNewRelative )
- {
- bRelative = true;
- bStdSize = false;
-
- if ( bPtRelative )
- {
- Clear(); //clear early because SetDecimalDigits is a slow recalc
-
- SetDecimalDigits( 1 );
- SetMin( nPtRelMin );
- SetMax( nPtRelMax );
- SetUnit( FUNIT_POINT );
-
- short i = nPtRelMin, n = 0;
- // JP 30.06.98: more than 100 values are not useful
- while ( i <= nPtRelMax && n++ < 100 )
- {
- InsertValue( i );
- i = i + nPtRelStep;
- }
- }
- else
- {
- Clear(); //clear early because SetDecimalDigits is a slow recalc
-
- SetDecimalDigits( 0 );
- SetMin( nRelMin );
- SetMax( nRelMax );
- SetUnit( FUNIT_PERCENT );
-
- sal_uInt16 i = nRelMin;
- while ( i <= nRelMax )
- {
- InsertValue( i );
- i = i + nRelStep;
- }
- }
- }
- else
- {
- if (pFontList)
- Clear(); //clear early because SetDecimalDigits is a slow recalc
- bRelative = bPtRelative = false;
- SetDecimalDigits( 1 );
- SetMin( 20 );
- SetMax( 9999 );
- SetUnit( FUNIT_POINT );
- if ( pFontList )
- Fill( &aFontMetric, pFontList );
- }
-
- SetText( aStr );
- SetSelection( aSelection );
-}
-
-OUString FontSizeBox::CreateFieldText( sal_Int64 nValue ) const
-{
- OUString sRet( MetricBox::CreateFieldText( nValue ) );
- if ( bRelativeMode && bPtRelative && (0 <= nValue) && !sRet.isEmpty() )
- sRet = "+" + sRet;
- return sRet;
-}
-
void FontSizeBox::SetValue( sal_Int64 nNewValue, FieldUnit eInUnit )
{
if ( !bRelative )