summaryrefslogtreecommitdiff
path: root/svtools
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-10-26 08:37:40 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-10-26 11:20:07 +0200
commitc0cc59adca23580864a2e5cdadf66212246cbfcc (patch)
tree57413c8efb3ca4a59f3699592353da1c575e345d /svtools
parent4bf2052e9dbdfcd32a749747c918f2d714010633 (diff)
loplugin:singlevalfields improvement
look for any kind of types, not just POD types, helps to find smart pointer fields that are only assigned nullptr Change-Id: I2d887e98db012f03b646e1023985bcc196285abc Reviewed-on: https://gerrit.libreoffice.org/62382 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svtools')
-rw-r--r--svtools/source/control/ctrlbox.cxx41
1 files changed, 15 insertions, 26 deletions
diff --git a/svtools/source/control/ctrlbox.cxx b/svtools/source/control/ctrlbox.cxx
index 43e8bb79e8e2..6346d3284ad2 100644
--- a/svtools/source/control/ctrlbox.cxx
+++ b/svtools/source/control/ctrlbox.cxx
@@ -1262,7 +1262,6 @@ void FontSizeBox::ImplInit()
{
EnableAutocomplete( false );
- bRelative = false;
bStdSize = false;
SetShowTrailingZeros( false );
@@ -1287,10 +1286,6 @@ void FontSizeBox::Reformat()
void FontSizeBox::Fill( const FontMetric* pFontMetric, const FontList* pList )
{
- // no font sizes need to be set for relative mode
- if ( bRelative )
- return;
-
// query font sizes
const sal_IntPtr* pTempAry;
const sal_IntPtr* pAry = nullptr;
@@ -1372,21 +1367,18 @@ void FontSizeBox::Fill( const FontMetric* pFontMetric, const FontList* pList )
void FontSizeBox::SetValue( sal_Int64 nNewValue, FieldUnit eInUnit )
{
- if ( !bRelative )
+ sal_Int64 nTempValue = MetricField::ConvertValue( nNewValue, GetBaseValue(), GetDecimalDigits(), eInUnit, GetUnit() );
+ FontSizeNames aFontSizeNames( GetSettings().GetUILanguageTag().getLanguageType() );
+ // conversion loses precision; however font sizes should
+ // never have a problem with that
+ OUString aName = aFontSizeNames.Size2Name( static_cast<long>(nTempValue) );
+ if ( !aName.isEmpty() && (GetEntryPos( aName ) != LISTBOX_ENTRY_NOTFOUND) )
{
- sal_Int64 nTempValue = MetricField::ConvertValue( nNewValue, GetBaseValue(), GetDecimalDigits(), eInUnit, GetUnit() );
- FontSizeNames aFontSizeNames( GetSettings().GetUILanguageTag().getLanguageType() );
- // conversion loses precision; however font sizes should
- // never have a problem with that
- OUString aName = aFontSizeNames.Size2Name( static_cast<long>(nTempValue) );
- if ( !aName.isEmpty() && (GetEntryPos( aName ) != LISTBOX_ENTRY_NOTFOUND) )
- {
- mnLastValue = nTempValue;
- SetText( aName );
- mnFieldValue = mnLastValue;
- SetEmptyFieldValueData( false );
- return;
- }
+ mnLastValue = nTempValue;
+ SetText( aName );
+ mnFieldValue = mnLastValue;
+ SetEmptyFieldValueData( false );
+ return;
}
MetricBox::SetValue( nNewValue, eInUnit );
@@ -1399,13 +1391,10 @@ void FontSizeBox::SetValue( sal_Int64 nNewValue )
sal_Int64 FontSizeBox::GetValueFromStringUnit(const OUString& rStr, FieldUnit eOutUnit) const
{
- if ( !bRelative )
- {
- FontSizeNames aFontSizeNames( GetSettings().GetUILanguageTag().getLanguageType() );
- sal_Int64 nValue = aFontSizeNames.Name2Size( rStr );
- if ( nValue )
- return MetricField::ConvertValue( nValue, GetBaseValue(), GetDecimalDigits(), GetUnit(), eOutUnit );
- }
+ FontSizeNames aFontSizeNames( GetSettings().GetUILanguageTag().getLanguageType() );
+ sal_Int64 nValue = aFontSizeNames.Name2Size( rStr );
+ if ( nValue )
+ return MetricField::ConvertValue( nValue, GetBaseValue(), GetDecimalDigits(), GetUnit(), eOutUnit );
return MetricBox::GetValueFromStringUnit( rStr, eOutUnit );
}