20#include <com/sun/star/chart/ErrorBarStyle.hpp>
21#include <com/sun/star/beans/XPropertySet.hpp>
31using namespace css::uno;
37enum class ErrorBarDirection
43css::uno::Reference<css::beans::XPropertySet> getErrorBarPropSet(
50 std::u16string_view rCID)
52 css::uno::Reference<css::beans::XPropertySet> xPropSet =
53 getErrorBarPropSet(xModel, rCID);
58 css::uno::Any aAny = xPropSet->getPropertyValue(
"ShowPositiveError");
69 std::u16string_view rCID)
71 css::uno::Reference<css::beans::XPropertySet> xPropSet =
72 getErrorBarPropSet(xModel, rCID);
77 css::uno::Any aAny = xPropSet->getPropertyValue(
"ShowNegativeError");
88 std::u16string_view rCID,
bool bShow)
90 css::uno::Reference<css::beans::XPropertySet> xPropSet =
91 getErrorBarPropSet(xModel, rCID);
96 xPropSet->setPropertyValue(
"ShowPositiveError", css::uno::Any(bShow));
100 std::u16string_view rCID,
bool bShow)
102 css::uno::Reference<css::beans::XPropertySet> xPropSet =
103 getErrorBarPropSet(xModel, rCID);
108 xPropSet->setPropertyValue(
"ShowNegativeError", css::uno::Any(bShow));
111struct ErrorBarTypeMap
117ErrorBarTypeMap
const aErrorBarType[] = {
118 { 0, css::chart::ErrorBarStyle::ABSOLUTE },
119 { 1, css::chart::ErrorBarStyle::RELATIVE },
120 { 2, css::chart::ErrorBarStyle::FROM_DATA },
121 { 3, css::chart::ErrorBarStyle::STANDARD_DEVIATION },
122 { 4, css::chart::ErrorBarStyle::STANDARD_ERROR },
123 { 5, css::chart::ErrorBarStyle::VARIANCE},
124 { 6, css::chart::ErrorBarStyle::ERROR_MARGIN },
128 std::u16string_view rCID)
130 css::uno::Reference<css::beans::XPropertySet> xPropSet =
131 getErrorBarPropSet(xModel, rCID);
136 css::uno::Any aAny = xPropSet->getPropertyValue(
"ErrorBarStyle");
138 if (!aAny.hasValue())
144 for (ErrorBarTypeMap
const & i : aErrorBarType)
154 std::u16string_view rCID, sal_Int32
nPos)
156 css::uno::Reference<css::beans::XPropertySet> xPropSet =
157 getErrorBarPropSet(xModel, rCID);
163 for (ErrorBarTypeMap
const & i : aErrorBarType)
169 xPropSet->setPropertyValue(
"ErrorBarStyle", css::uno::Any(
nApi));
173 std::u16string_view rCID, ErrorBarDirection eDir)
175 css::uno::Reference<css::beans::XPropertySet> xPropSet =
176 getErrorBarPropSet(xModel, rCID);
181 OUString
aName =
"PositiveError";
182 if (eDir == ErrorBarDirection::NEGATIVE)
183 aName =
"NegativeError";
185 css::uno::Any aAny = xPropSet->getPropertyValue(aName);
187 if (!aAny.hasValue())
197 std::u16string_view rCID,
double nVal, ErrorBarDirection eDir)
199 css::uno::Reference<css::beans::XPropertySet> xPropSet =
200 getErrorBarPropSet(xModel, rCID);
205 OUString
aName =
"PositiveError";
206 if (eDir == ErrorBarDirection::NEGATIVE)
207 aName =
"NegativeError";
209 xPropSet->setPropertyValue(aName, css::uno::Any(nVal));
214 css::uno::Reference<css::frame::XController>
xController(
xModel->getCurrentController());
215 css::uno::Reference<css::view::XSelectionSupplier> xSelectionSupplier(xController, css::uno::UNO_QUERY);
216 if (!xSelectionSupplier.is())
219 uno::Any aAny = xSelectionSupplier->getSelection();
223#if defined DBG_UTIL && !defined NDEBUG
228 SAL_WARN(
"chart2",
"Selected item is not an error bar");
238 :
PanelLayout(pParent,
"ChartErrorBarPanel",
"modules/schart/ui/sidebarerrorbar.ui")
239 , mxRBPosAndNeg(m_xBuilder->weld_radio_button(
"radiobutton_positive_negative"))
240 , mxRBPos(m_xBuilder->weld_radio_button(
"radiobutton_positive"))
241 , mxRBNeg(m_xBuilder->weld_radio_button(
"radiobutton_negative"))
242 , mxLBType(m_xBuilder->weld_combo_box(
"comboboxtext_type"))
243 , mxMFPos(m_xBuilder->weld_spin_button(
"spinbutton_pos"))
244 , mxMFNeg(m_xBuilder->weld_spin_button(
"spinbutton_neg"))
245 ,
mxModel(pController->getChartModel())
277 mxRBPos->connect_toggled(aLink);
278 mxRBNeg->connect_toggled(aLink);
283 mxMFPos->connect_value_changed(aLink2);
284 mxMFNeg->connect_value_changed(aLink2);
292 OUString aCID = getCID(
mxModel);
299 bool bPos = showPositiveError(
mxModel, aCID);
300 bool bNeg = showNegativeError(
mxModel, aCID);
311 sal_Int32 nTypePos = getTypePos(
mxModel, aCID);
343 if (pParent ==
nullptr)
344 throw lang::IllegalArgumentException(
"no parent Window given to ChartErrorBarPanel::Create",
nullptr, 0);
345 return std::make_unique<ChartErrorBarPanel>(pParent, pController);
390 ::chart::ChartModel* pModel =
dynamic_cast<::chart::ChartModel*
>(
xModel.get());
391 assert(!
xModel || pModel);
397 OUString aCID = getCID(
mxModel);
398 bool bPos = mxRBPosAndNeg->get_active() || mxRBPos->get_active();
399 bool bNeg = mxRBPosAndNeg->get_active() || mxRBNeg->get_active();
401 setShowPositiveError(
mxModel, aCID, bPos);
402 setShowNegativeError(
mxModel, aCID, bNeg);
407 OUString aCID = getCID(
mxModel);
408 sal_Int32
nPos = mxLBType->get_active();
415 OUString aCID = getCID(
mxModel);
416 double nVal = rMetricField.get_value();
417 if (&rMetricField == mxMFPos.get())
419 else if (&rMetricField == mxMFNeg.get())
css::uno::Reference< css::frame::XModel2 > mxModel
virtual void DataChanged(const DataChangedEvent &rEvent)
static css::uno::Reference< css::beans::XPropertySet > getObjectPropertySet(std::u16string_view rObjectCID, const rtl::Reference< ::chart::ChartModel > &xChartDocument)
ObjectType getObjectType() const
Reference< script::XScriptListener > mxListener
#define LINK(Instance, Class, Member)
#define SAL_WARN(area, stream)
@ OBJECTTYPE_DATA_ERRORS_X
@ OBJECTTYPE_DATA_ERRORS_Y
@ OBJECTTYPE_DATA_ERRORS_Z
css::beans::Optional< css::uno::Any > getValue(std::u16string_view id)
RegError REGISTRY_CALLTYPE setValue(RegKeyHandle hKey, rtl_uString *keyName, RegValueType valueType, RegValue pData, sal_uInt32 valueSize)
Reference< XController > xController
Reference< XModel > xModel