summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2020-07-03 17:20:50 +0100
committerCaolán McNamara <caolanm@redhat.com>2020-07-05 16:44:27 +0200
commitef371319fa5f6b076d6d2edc8f252bbb94fd77f0 (patch)
treeea3b16b17962492bc70496e53e6096cd4a5ccbf8 /vcl
parent95cfa85395f983df3ba044192b29ce0bbc5e6085 (diff)
return a reference instead of a pointer
Change-Id: Ib8b9133991a9c36e737171ae6dfb6a87cc91e1ac Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97888 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/inc/salvtables.hxx2
-rw-r--r--vcl/source/app/salvtables.cxx40
-rw-r--r--vcl/source/control/fmtfield.cxx81
-rw-r--r--vcl/source/uitest/uiobject.cxx2
-rw-r--r--vcl/source/window/builder.cxx12
5 files changed, 68 insertions, 69 deletions
diff --git a/vcl/inc/salvtables.hxx b/vcl/inc/salvtables.hxx
index 6eb671fa820c..3ee8f111bdff 100644
--- a/vcl/inc/salvtables.hxx
+++ b/vcl/inc/salvtables.hxx
@@ -618,7 +618,7 @@ class SalInstanceSpinButton : public SalInstanceEntry, public virtual weld::Spin
{
private:
VclPtr<FormattedField> m_xButton;
- Formatter* m_pFormatter;
+ Formatter& m_rFormatter;
DECL_LINK(UpDownHdl, SpinField&, void);
DECL_LINK(LoseFocusHdl, Control&, void);
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index f646beb64d9a..0d86ac4871f9 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -5208,14 +5208,14 @@ SalInstanceSpinButton::SalInstanceSpinButton(FormattedField* pButton, SalInstanc
bool bTakeOwnership)
: SalInstanceEntry(pButton, pBuilder, bTakeOwnership)
, m_xButton(pButton)
- , m_pFormatter(m_xButton->GetFormatter())
+ , m_rFormatter(m_xButton->GetFormatter())
{
- m_pFormatter->SetThousandsSep(false); //off by default, MetricSpinButton enables it
+ m_rFormatter.SetThousandsSep(false); //off by default, MetricSpinButton enables it
m_xButton->SetUpHdl(LINK(this, SalInstanceSpinButton, UpDownHdl));
m_xButton->SetDownHdl(LINK(this, SalInstanceSpinButton, UpDownHdl));
m_xButton->SetLoseFocusHdl(LINK(this, SalInstanceSpinButton, LoseFocusHdl));
- m_pFormatter->SetOutputHdl(LINK(this, SalInstanceSpinButton, OutputHdl));
- m_pFormatter->SetInputHdl(LINK(this, SalInstanceSpinButton, InputHdl));
+ m_rFormatter.SetOutputHdl(LINK(this, SalInstanceSpinButton, OutputHdl));
+ m_rFormatter.SetInputHdl(LINK(this, SalInstanceSpinButton, InputHdl));
if (Edit* pEdit = m_xButton->GetSubEdit())
pEdit->SetActivateHdl(LINK(this, SalInstanceSpinButton, ActivateHdl));
else
@@ -5224,40 +5224,40 @@ SalInstanceSpinButton::SalInstanceSpinButton(FormattedField* pButton, SalInstanc
int SalInstanceSpinButton::get_value() const
{
- return fromField(m_pFormatter->GetValue());
+ return fromField(m_rFormatter.GetValue());
}
void SalInstanceSpinButton::set_value(int value)
{
- m_pFormatter->SetValue(toField(value));
+ m_rFormatter.SetValue(toField(value));
}
void SalInstanceSpinButton::set_range(int min, int max)
{
- m_pFormatter->SetMinValue(toField(min));
- m_pFormatter->SetMaxValue(toField(max));
+ m_rFormatter.SetMinValue(toField(min));
+ m_rFormatter.SetMaxValue(toField(max));
}
void SalInstanceSpinButton::get_range(int& min, int& max) const
{
- min = fromField(m_pFormatter->GetMinValue());
- max = fromField(m_pFormatter->GetMaxValue());
+ min = fromField(m_rFormatter.GetMinValue());
+ max = fromField(m_rFormatter.GetMaxValue());
}
void SalInstanceSpinButton::set_increments(int step, int /*page*/)
{
- m_pFormatter->SetSpinSize(toField(step));
+ m_rFormatter.SetSpinSize(toField(step));
}
void SalInstanceSpinButton::get_increments(int& step, int& page) const
{
- step = fromField(m_pFormatter->GetSpinSize());
- page = fromField(m_pFormatter->GetSpinSize());
+ step = fromField(m_rFormatter.GetSpinSize());
+ page = fromField(m_rFormatter.GetSpinSize());
}
void SalInstanceSpinButton::set_digits(unsigned int digits)
{
- m_pFormatter->SetDecimalDigits(digits);
+ m_rFormatter.SetDecimalDigits(digits);
}
// SpinButton may be comprised of multiple subwidgets, consider the lot as
@@ -5270,18 +5270,18 @@ bool SalInstanceSpinButton::has_focus() const
//so with hh::mm::ss, incrementing mm will not reset ss
void SalInstanceSpinButton::DisableRemainderFactor()
{
- m_pFormatter->DisableRemainderFactor();
+ m_rFormatter.DisableRemainderFactor();
}
//off by default for direct SpinButtons, MetricSpinButton enables it
void SalInstanceSpinButton::SetUseThousandSep()
{
- m_pFormatter->SetThousandsSep(true);
+ m_rFormatter.SetThousandsSep(true);
}
unsigned int SalInstanceSpinButton::get_digits() const
{
- return m_pFormatter->GetDecimalDigits();
+ return m_rFormatter.GetDecimalDigits();
}
SalInstanceSpinButton::~SalInstanceSpinButton()
@@ -5290,8 +5290,8 @@ SalInstanceSpinButton::~SalInstanceSpinButton()
pEdit->SetActivateHdl(Link<Edit&, bool>());
else
m_xButton->SetActivateHdl(Link<Edit&, bool>());
- m_pFormatter->SetInputHdl(Link<sal_Int64*, TriState>());
- m_pFormatter->SetOutputHdl(Link<LinkParamNone*, bool>());
+ m_rFormatter.SetInputHdl(Link<sal_Int64*, TriState>());
+ m_rFormatter.SetOutputHdl(Link<LinkParamNone*, bool>());
m_xButton->SetLoseFocusHdl(Link<Control&, void>());
m_xButton->SetDownHdl(Link<SpinField&, void>());
m_xButton->SetUpHdl(Link<SpinField&, void>());
@@ -5357,7 +5357,7 @@ public:
virtual Formatter& GetFormatter() override
{
- return *m_xButton->GetFormatter();
+ return m_xButton->GetFormatter();
}
};
diff --git a/vcl/source/control/fmtfield.cxx b/vcl/source/control/fmtfield.cxx
index 5f1cb134b9d4..40f3e4c0a711 100644
--- a/vcl/source/control/fmtfield.cxx
+++ b/vcl/source/control/fmtfield.cxx
@@ -448,7 +448,6 @@ void Formatter::ImplSetTextImpl(const OUString& rNew, Selection const * pNewSel)
void Formatter::ImplSetFormatKey(sal_uLong nFormatKey)
{
-
m_nFormatKey = nFormatKey;
bool bNeedFormatter = (m_pFormatter == nullptr) && (nFormatKey != 0);
if (bNeedFormatter)
@@ -1020,8 +1019,8 @@ DoubleNumericField::~DoubleNumericField() = default;
void DoubleNumericField::ResetConformanceTester()
{
// the thousands and the decimal separator are language dependent
- Formatter* pFormatter = GetFormatter();
- const SvNumberformat* pFormatEntry = pFormatter->GetOrCreateFormatter()->GetEntry(pFormatter->GetFormatKey());
+ Formatter& rFormatter = GetFormatter();
+ const SvNumberformat* pFormatEntry = rFormatter.GetOrCreateFormatter()->GetEntry(rFormatter.GetFormatKey());
sal_Unicode cSeparatorThousand = ',';
sal_Unicode cSeparatorDecimal = '.';
@@ -1153,21 +1152,21 @@ FormattedField::FormattedField(vcl::Window* pParent, WinBits nStyle)
void FormattedField::SetText(const OUString& rStr)
{
- GetFormatter()->SetFieldText(rStr, Selection(0, 0));
+ GetFormatter().SetFieldText(rStr, Selection(0, 0));
}
void FormattedField::SetText(const OUString& rStr, const Selection& rNewSelection)
{
- GetFormatter()->SetFieldText(rStr, rNewSelection);
+ GetFormatter().SetFieldText(rStr, rNewSelection);
SetSelection(rNewSelection);
}
bool FormattedField::set_property(const OString &rKey, const OUString &rValue)
{
if (rKey == "digits")
- GetFormatter()->SetDecimalDigits(rValue.toInt32());
+ GetFormatter().SetDecimalDigits(rValue.toInt32());
else if (rKey == "wrap")
- GetFormatter()->SetWrapOnLimits(toBool(rValue));
+ GetFormatter().SetWrapOnLimits(toBool(rValue));
else
return SpinField::set_property(rKey, rValue);
return true;
@@ -1175,19 +1174,19 @@ bool FormattedField::set_property(const OString &rKey, const OUString &rValue)
void FormattedField::Up()
{
- Formatter* pFormatter = GetFormatter();
- auto nScale = weld::SpinButton::Power10(pFormatter->GetDecimalDigits());
+ Formatter& rFormatter = GetFormatter();
+ auto nScale = weld::SpinButton::Power10(rFormatter.GetDecimalDigits());
- sal_Int64 nValue = std::round(pFormatter->GetValue() * nScale);
- sal_Int64 nSpinSize = std::round(pFormatter->GetSpinSize() * nScale);
- sal_Int64 nRemainder = pFormatter->GetDisableRemainderFactor() ? 0 : nValue % nSpinSize;
+ sal_Int64 nValue = std::round(rFormatter.GetValue() * nScale);
+ sal_Int64 nSpinSize = std::round(rFormatter.GetSpinSize() * nScale);
+ sal_Int64 nRemainder = rFormatter.GetDisableRemainderFactor() ? 0 : nValue % nSpinSize;
if (nValue >= 0)
nValue = (nRemainder == 0) ? nValue + nSpinSize : nValue + nSpinSize - nRemainder;
else
nValue = (nRemainder == 0) ? nValue + nSpinSize : nValue - nRemainder;
// setValue handles under- and overflows (min/max) automatically
- pFormatter->SetValue(static_cast<double>(nValue) / nScale);
+ rFormatter.SetValue(static_cast<double>(nValue) / nScale);
SetModifyFlag();
Modify();
@@ -1196,19 +1195,19 @@ void FormattedField::Up()
void FormattedField::Down()
{
- Formatter* pFormatter = GetFormatter();
- auto nScale = weld::SpinButton::Power10(pFormatter->GetDecimalDigits());
+ Formatter& rFormatter = GetFormatter();
+ auto nScale = weld::SpinButton::Power10(rFormatter.GetDecimalDigits());
- sal_Int64 nValue = std::round(pFormatter->GetValue() * nScale);
- sal_Int64 nSpinSize = std::round(pFormatter->GetSpinSize() * nScale);
- sal_Int64 nRemainder = pFormatter->GetDisableRemainderFactor() ? 0 : nValue % nSpinSize;
+ sal_Int64 nValue = std::round(rFormatter.GetValue() * nScale);
+ sal_Int64 nSpinSize = std::round(rFormatter.GetSpinSize() * nScale);
+ sal_Int64 nRemainder = rFormatter.GetDisableRemainderFactor() ? 0 : nValue % nSpinSize;
if (nValue >= 0)
nValue = (nRemainder == 0) ? nValue - nSpinSize : nValue - nRemainder;
else
nValue = (nRemainder == 0) ? nValue - nSpinSize : nValue - nSpinSize - nRemainder;
// setValue handles under- and overflows (min/max) automatically
- pFormatter->SetValue(static_cast<double>(nValue) / nScale);
+ rFormatter.SetValue(static_cast<double>(nValue) / nScale);
SetModifyFlag();
Modify();
@@ -1217,10 +1216,10 @@ void FormattedField::Down()
void FormattedField::First()
{
- Formatter* pFormatter = GetFormatter();
- if (pFormatter->HasMinValue())
+ Formatter& rFormatter = GetFormatter();
+ if (rFormatter.HasMinValue())
{
- pFormatter->SetValue(pFormatter->GetMinValue());
+ rFormatter.SetValue(rFormatter.GetMinValue());
SetModifyFlag();
Modify();
}
@@ -1230,10 +1229,10 @@ void FormattedField::First()
void FormattedField::Last()
{
- Formatter* pFormatter = GetFormatter();
- if (pFormatter->HasMaxValue())
+ Formatter& rFormatter = GetFormatter();
+ if (rFormatter.HasMaxValue())
{
- pFormatter->SetValue(pFormatter->GetMaxValue());
+ rFormatter.SetValue(rFormatter.GetMaxValue());
SetModifyFlag();
Modify();
}
@@ -1243,13 +1242,13 @@ void FormattedField::Last()
void FormattedField::Modify()
{
- GetFormatter()->Modify();
+ GetFormatter().Modify();
}
bool FormattedField::PreNotify(NotifyEvent& rNEvt)
{
if (rNEvt.GetType() == MouseNotifyEvent::KEYINPUT)
- GetFormatter()->SetLastSelection(GetSelection());
+ GetFormatter().SetLastSelection(GetSelection());
return SpinField::PreNotify(rNEvt);
}
@@ -1266,8 +1265,8 @@ bool FormattedField::EventNotify(NotifyEvent& rNEvt)
case KEY_PAGEUP:
case KEY_PAGEDOWN:
{
- Formatter* pFormatter = GetFormatter();
- if (!nMod && pFormatter->GetOrCreateFormatter()->IsTextFormat(pFormatter->GetFormatKey()))
+ Formatter& rFormatter = GetFormatter();
+ if (!nMod && rFormatter.GetOrCreateFormatter()->IsTextFormat(rFormatter.GetFormatKey()))
{
// the base class would translate this into calls to Up/Down/First/Last,
// but we don't want this if we are text-formatted
@@ -1283,9 +1282,9 @@ bool FormattedField::EventNotify(NotifyEvent& rNEvt)
if (pCommand->GetCommand() == CommandEventId::Wheel)
{
const CommandWheelData* pData = rNEvt.GetCommandEvent()->GetWheelData();
- Formatter* pFormatter = GetFormatter();
+ Formatter& rFormatter = GetFormatter();
if ((pData->GetMode() == CommandWheelMode::SCROLL) &&
- pFormatter->GetOrCreateFormatter()->IsTextFormat(pFormatter->GetFormatKey()))
+ rFormatter.GetOrCreateFormatter()->IsTextFormat(rFormatter.GetFormatKey()))
{
// same as above : prevent the base class from doing Up/Down-calls
// (normally I should put this test into the Up/Down methods itself, shouldn't I ?)
@@ -1296,16 +1295,16 @@ bool FormattedField::EventNotify(NotifyEvent& rNEvt)
}
if (rNEvt.GetType() == MouseNotifyEvent::LOSEFOCUS)
- GetFormatter()->EntryLostFocus();
+ GetFormatter().EntryLostFocus();
return SpinField::EventNotify( rNEvt );
}
-Formatter* FormattedField::GetFormatter()
+Formatter& FormattedField::GetFormatter()
{
if (!m_xFormatter)
m_xFormatter.reset(new FieldFormatter(*this));
- return m_xFormatter.get();
+ return *m_xFormatter;
}
void FormattedField::SetFormatter(Formatter* pFormatter)
@@ -1318,13 +1317,13 @@ void FormattedField::SetValueFromString(const OUString& rStr)
{
sal_Int32 nEnd;
rtl_math_ConversionStatus eStatus;
- Formatter* pFormatter = GetFormatter();
- double fValue = ::rtl::math::stringToDouble(rStr, '.', pFormatter->GetDecimalDigits(), &eStatus, &nEnd );
+ Formatter& rFormatter = GetFormatter();
+ double fValue = ::rtl::math::stringToDouble(rStr, '.', rFormatter.GetDecimalDigits(), &eStatus, &nEnd );
if (eStatus == rtl_math_ConversionStatus_Ok &&
nEnd == rStr.getLength())
{
- pFormatter->SetValue(fValue);
+ rFormatter.SetValue(fValue);
SetModifyFlag();
Modify();
@@ -1340,10 +1339,10 @@ void FormattedField::SetValueFromString(const OUString& rStr)
void FormattedField::DumpAsPropertyTree(tools::JsonWriter& rJsonWriter)
{
SpinField::DumpAsPropertyTree(rJsonWriter);
- Formatter* pFormatter = GetFormatter();
- rJsonWriter.put("min", pFormatter->GetMinValue());
- rJsonWriter.put("max", pFormatter->GetMaxValue());
- rJsonWriter.put("value", pFormatter->GetValue());
+ Formatter& rFormatter = GetFormatter();
+ rJsonWriter.put("min", rFormatter.GetMinValue());
+ rJsonWriter.put("max", rFormatter.GetMaxValue());
+ rJsonWriter.put("value", rFormatter.GetValue());
}
FactoryFunction FormattedField::GetUITestFactory() const
diff --git a/vcl/source/uitest/uiobject.cxx b/vcl/source/uitest/uiobject.cxx
index c8170a17caee..f7c3c79de9d3 100644
--- a/vcl/source/uitest/uiobject.cxx
+++ b/vcl/source/uitest/uiobject.cxx
@@ -1374,7 +1374,7 @@ void FormattedFieldUIObject::execute(const OUString& rAction,
StringMap FormattedFieldUIObject::get_state()
{
StringMap aMap = EditUIObject::get_state();
- aMap["Value"] = OUString::number(mxFormattedField->GetFormatter()->GetValue());
+ aMap["Value"] = OUString::number(mxFormattedField->GetFormatter().GetValue());
return aMap;
}
diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx
index 85ee2ca4f4f1..c31611e89a2b 100644
--- a/vcl/source/window/builder.cxx
+++ b/vcl/source/window/builder.cxx
@@ -1951,7 +1951,7 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString &
{
connectFormattedFormatterAdjustment(id, sAdjustment);
VclPtrInstance<FormattedField> xField(pParent, nBits);
- xField->GetFormatter()->SetMinValue(0);
+ xField->GetFormatter().SetMinValue(0);
xWindow = xField;
}
}
@@ -4411,11 +4411,11 @@ void VclBuilder::mungeAdjustment(FormattedField &rTarget, const Adjustment &rAdj
SAL_INFO("vcl.builder", "unhandled property :" << rKey);
}
- Formatter* pFormatter = rTarget.GetFormatter();
- pFormatter->SetMinValue(nMinValue);
- pFormatter->SetMaxValue(nMaxValue);
- pFormatter->SetValue(nValue);
- pFormatter->SetSpinSize(nSpinSize);
+ Formatter& rFormatter = rTarget.GetFormatter();
+ rFormatter.SetMinValue(nMinValue);
+ rFormatter.SetMaxValue(nMaxValue);
+ rFormatter.SetValue(nValue);
+ rFormatter.SetSpinSize(nSpinSize);
}
void VclBuilder::mungeAdjustment(ScrollBar &rTarget, const Adjustment &rAdjustment)