diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2015-10-22 01:33:07 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2015-10-22 23:49:13 +0200 |
commit | 66a25e96ca961e676f34ad1c118f9673123f86cc (patch) | |
tree | 4d17faa2091b0f7de19b24c2d484a32997c1d6e1 | |
parent | 73cfe5fece97c90505a24a3fb6daae2e7e27fcef (diff) |
make it harder to use the API wrongly, tdf#95056
Change-Id: I07129285ac7f00513802a60c31d5de27f6f4a5d6
-rw-r--r-- | chart2/source/controller/sidebar/ChartErrorBarPanel.cxx | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/chart2/source/controller/sidebar/ChartErrorBarPanel.cxx b/chart2/source/controller/sidebar/ChartErrorBarPanel.cxx index f4b66354d1fc..04d5aefd5ab4 100644 --- a/chart2/source/controller/sidebar/ChartErrorBarPanel.cxx +++ b/chart2/source/controller/sidebar/ChartErrorBarPanel.cxx @@ -45,6 +45,12 @@ namespace chart { namespace sidebar { namespace { +enum class ErrorBarDirection +{ + POSITIVE, + NEGATIVE +}; + css::uno::Reference<css::beans::XPropertySet> getErrorBarPropSet( css::uno::Reference<css::frame::XModel> xModel, const OUString& rCID) { @@ -175,7 +181,7 @@ void setTypePos(css::uno::Reference<css::frame::XModel> xModel, } double getValue(css::uno::Reference<css::frame::XModel> xModel, - const OUString& rCID, bool bNeg) + const OUString& rCID, ErrorBarDirection eDir) { css::uno::Reference<css::beans::XPropertySet> xPropSet = getErrorBarPropSet(xModel, rCID); @@ -184,7 +190,7 @@ double getValue(css::uno::Reference<css::frame::XModel> xModel, return 0; OUString aName = "PositiveError"; - if (bNeg) + if (eDir == ErrorBarDirection::NEGATIVE) aName = "NegativeError"; css::uno::Any aAny = xPropSet->getPropertyValue(aName); @@ -199,7 +205,7 @@ double getValue(css::uno::Reference<css::frame::XModel> xModel, } void setValue(css::uno::Reference<css::frame::XModel> xModel, - const OUString& rCID, double nVal, bool bPos) + const OUString& rCID, double nVal, ErrorBarDirection eDir) { css::uno::Reference<css::beans::XPropertySet> xPropSet = getErrorBarPropSet(xModel, rCID); @@ -208,7 +214,7 @@ void setValue(css::uno::Reference<css::frame::XModel> xModel, return; OUString aName = "PositiveError"; - if (!bPos) + if (eDir == ErrorBarDirection::NEGATIVE) aName = "NegativeError"; xPropSet->setPropertyValue(aName, css::uno::makeAny(nVal)); @@ -337,8 +343,8 @@ void ChartErrorBarPanel::updateData() else mpMFNeg->Disable(); - double nValPos = getValue(mxModel, aCID, true); - double nValNeg = getValue(mxModel, aCID, false); + double nValPos = getValue(mxModel, aCID, ErrorBarDirection::POSITIVE); + double nValNeg = getValue(mxModel, aCID, ErrorBarDirection::NEGATIVE); mpMFPos->SetValue(nValPos); mpMFNeg->SetValue(nValNeg); @@ -428,9 +434,9 @@ IMPL_LINK_TYPED(ChartErrorBarPanel, NumericFieldHdl, Edit&, rMetricField, void) OUString aCID = getCID(mxModel); double nVal = static_cast<NumericField&>(rMetricField).GetValue(); if (&rMetricField == mpMFPos.get()) - setValue(mxModel, aCID, nVal, true); + setValue(mxModel, aCID, nVal, ErrorBarDirection::POSITIVE); else if (&rMetricField == mpMFNeg.get()) - setValue(mxModel, aCID, nVal, false); + setValue(mxModel, aCID, nVal, ErrorBarDirection::NEGATIVE); } }} // end of namespace ::chart::sidebar |