diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2015-07-18 19:36:23 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2015-07-26 00:22:00 +0200 |
commit | c8b5979309311a0878e9fe0041423ff0620052bf (patch) | |
tree | 6d1bec3b34c73b8c3ac4d98c1f556af856efd265 /chart2 | |
parent | 3dec38c9a9fdbe56a4ff7ffb6e4b3a9e9114b0f9 (diff) |
finish error bar panel
Change-Id: I954b858ea76c949fe3e5de15e3ed45a7aba6bb2d
Diffstat (limited to 'chart2')
-rw-r--r-- | chart2/source/controller/sidebar/ChartErrorBarPanel.cxx | 167 | ||||
-rw-r--r-- | chart2/source/controller/sidebar/ChartErrorBarPanel.hxx | 8 | ||||
-rw-r--r-- | chart2/uiconfig/ui/sidebarerrorbar.ui | 27 |
3 files changed, 199 insertions, 3 deletions
diff --git a/chart2/source/controller/sidebar/ChartErrorBarPanel.cxx b/chart2/source/controller/sidebar/ChartErrorBarPanel.cxx index 278d2deafc54..b5a5075a9e99 100644 --- a/chart2/source/controller/sidebar/ChartErrorBarPanel.cxx +++ b/chart2/source/controller/sidebar/ChartErrorBarPanel.cxx @@ -22,6 +22,7 @@ #include <sfx2/sidebar/ControlFactory.hxx> #include <com/sun/star/chart/ChartAxisLabelPosition.hpp> +#include <com/sun/star/chart/ErrorBarStyle.hpp> #include "ChartErrorBarPanel.hxx" #include "ChartController.hxx" @@ -112,6 +113,107 @@ void setShowNegativeError(css::uno::Reference<css::frame::XModel> xModel, xPropSet->setPropertyValue("ShowNegativeError", css::uno::makeAny(bShow)); } +struct ErrorBarTypeMap +{ + sal_Int32 nPos; + sal_Int32 nApi; +}; + +ErrorBarTypeMap aErrorBarType[] = { + { 0, css::chart::ErrorBarStyle::ABSOLUTE }, + { 1, css::chart::ErrorBarStyle::RELATIVE }, + { 2, css::chart::ErrorBarStyle::FROM_DATA }, + { 3, css::chart::ErrorBarStyle::STANDARD_DEVIATION }, + { 4, css::chart::ErrorBarStyle::STANDARD_ERROR }, + { 5, css::chart::ErrorBarStyle::VARIANCE}, + { 6, css::chart::ErrorBarStyle::ERROR_MARGIN }, +}; + +sal_Int32 getTypePos(css::uno::Reference<css::frame::XModel> xModel, + const OUString& rCID) +{ + css::uno::Reference<css::beans::XPropertySet> xPropSet = + getErrorBarPropSet(xModel, rCID); + + if (!xPropSet.is()) + return 0; + + css::uno::Any aAny = xPropSet->getPropertyValue("ErrorBarStyle"); + + if (!aAny.hasValue()) + return 0; + + sal_Int32 nApi = 0; + aAny >>= nApi; + + for (size_t i = 0; i < SAL_N_ELEMENTS(aErrorBarType); ++i) + { + if (aErrorBarType[i].nApi == nApi) + return aErrorBarType[i].nPos; + } + + return 0; +} + +void setTypePos(css::uno::Reference<css::frame::XModel> xModel, + const OUString& rCID, sal_Int32 nPos) +{ + css::uno::Reference<css::beans::XPropertySet> xPropSet = + getErrorBarPropSet(xModel, rCID); + + if (!xPropSet.is()) + return; + + sal_Int32 nApi = 0; + for (size_t i = 0; i < SAL_N_ELEMENTS(aErrorBarType); ++i) + { + if (aErrorBarType[i].nPos == nPos) + nApi = aErrorBarType[i].nApi; + } + + xPropSet->setPropertyValue("ErrorBarStyle", css::uno::makeAny(nApi)); +} + +double getValue(css::uno::Reference<css::frame::XModel> xModel, + const OUString& rCID, bool bNeg) +{ + css::uno::Reference<css::beans::XPropertySet> xPropSet = + getErrorBarPropSet(xModel, rCID); + + if (!xPropSet.is()) + return 0; + + OUString aName = "PositiveError"; + if (bNeg) + aName = "NegativeError"; + + css::uno::Any aAny = xPropSet->getPropertyValue(aName); + + if (!aAny.hasValue()) + return 0; + + double nVal = 0; + aAny >>= nVal; + + return nVal; +} + +void setValue(css::uno::Reference<css::frame::XModel> xModel, + const OUString& rCID, double nVal, bool bPos) +{ + css::uno::Reference<css::beans::XPropertySet> xPropSet = + getErrorBarPropSet(xModel, rCID); + + if (!xPropSet.is()) + return; + + OUString aName = "PositiveError"; + if (!bPos) + aName = "NegativeError"; + + xPropSet->setPropertyValue(aName, css::uno::makeAny(nVal)); +} + OUString getCID(css::uno::Reference<css::frame::XModel> xModel) { css::uno::Reference<css::frame::XController> xController(xModel->getCurrentController()); @@ -149,6 +251,11 @@ ChartErrorBarPanel::ChartErrorBarPanel( get(mpRBPos, "radiobutton_positive"); get(mpRBNeg, "radiobutton_negative"); + get(mpLBType, "comboboxtext_type"); + + get(mpMFPos, "spinbutton_pos"); + get(mpMFNeg, "spinbutton_neg"); + Initialize(); } @@ -166,6 +273,11 @@ void ChartErrorBarPanel::dispose() mpRBPos.clear(); mpRBNeg.clear(); + mpLBType.clear(); + + mpMFPos.clear(); + mpMFNeg.clear(); + PanelLayout::dispose(); } @@ -180,6 +292,12 @@ void ChartErrorBarPanel::Initialize() mpRBPosAndNeg->SetToggleHdl(aLink); mpRBPos->SetToggleHdl(aLink); mpRBNeg->SetToggleHdl(aLink); + + mpLBType->SetSelectHdl(LINK(this, ChartErrorBarPanel, ListBoxHdl)); + + aLink = LINK(this, ChartErrorBarPanel, NumericFieldHdl); + mpMFPos->SetModifyHdl(aLink); + mpMFNeg->SetModifyHdl(aLink); } void ChartErrorBarPanel::updateData() @@ -196,6 +314,33 @@ void ChartErrorBarPanel::updateData() mpRBPos->Check(true); else if (bNeg) mpRBNeg->Check(true); + + sal_Int32 nTypePos = getTypePos(mxModel, aCID); + mpLBType->SelectEntryPos(nTypePos); + + if (nTypePos <= 1) + { + if (bPos) + mpMFPos->Enable(); + else + mpMFPos->Disable(); + + if (bNeg) + mpMFNeg->Enable(); + else + mpMFNeg->Disable(); + + double nValPos = getValue(mxModel, aCID, true); + double nValNeg = getValue(mxModel, aCID, false); + + mpMFPos->SetValue(nValPos); + mpMFNeg->SetValue(nValNeg); + } + else + { + mpMFPos->Disable(); + mpMFNeg->Disable(); + } } VclPtr<vcl::Window> ChartErrorBarPanel::Create ( @@ -248,6 +393,28 @@ IMPL_LINK_NOARG(ChartErrorBarPanel, RadioBtnHdl) return 0; } +IMPL_LINK_NOARG(ChartErrorBarPanel, ListBoxHdl) +{ + OUString aCID = getCID(mxModel); + sal_Int32 nPos = mpLBType->GetSelectEntryPos(); + + setTypePos(mxModel, aCID, nPos); + + return 0; +} + +IMPL_LINK(ChartErrorBarPanel, NumericFieldHdl, NumericField*, pMetricField) +{ + OUString aCID = getCID(mxModel); + double nVal = pMetricField->GetValue(); + if (pMetricField == mpMFPos.get()) + setValue(mxModel, aCID, nVal, true); + else if (pMetricField == mpMFNeg.get()) + setValue(mxModel, aCID, nVal, false); + + return 0; +} + }} // end of namespace ::chart::sidebar /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/controller/sidebar/ChartErrorBarPanel.hxx b/chart2/source/controller/sidebar/ChartErrorBarPanel.hxx index 7586570d48d6..84d4b9ccd896 100644 --- a/chart2/source/controller/sidebar/ChartErrorBarPanel.hxx +++ b/chart2/source/controller/sidebar/ChartErrorBarPanel.hxx @@ -22,6 +22,7 @@ class FixedText; class ListBox; class NumericField; +class MetricField; namespace chart { @@ -69,6 +70,11 @@ private: VclPtr<RadioButton> mpRBPos; VclPtr<RadioButton> mpRBNeg; + VclPtr<ListBox> mpLBType; + + VclPtr<NumericField> mpMFPos; + VclPtr<NumericField> mpMFNeg; + css::uno::Reference<css::frame::XFrame> mxFrame; css::uno::Reference<css::frame::XModel> mxModel; @@ -77,6 +83,8 @@ private: void Initialize(); DECL_LINK(RadioBtnHdl, void*); + DECL_LINK(ListBoxHdl, void*); + DECL_LINK(NumericFieldHdl, NumericField*); }; } } // end of namespace ::chart::sidebar diff --git a/chart2/uiconfig/ui/sidebarerrorbar.ui b/chart2/uiconfig/ui/sidebarerrorbar.ui index 12a112681550..252009efbc92 100644 --- a/chart2/uiconfig/ui/sidebarerrorbar.ui +++ b/chart2/uiconfig/ui/sidebarerrorbar.ui @@ -32,7 +32,7 @@ </packing> </child> <child> - <object class="GtkComboBoxText" id="comboboxtext1"> + <object class="GtkComboBoxText" id="comboboxtext_type"> <property name="visible">True</property> <property name="can_focus">False</property> <items> @@ -120,10 +120,31 @@ </packing> </child> <child> - <placeholder/> + <object class="GtkSpinButton" id="spinbutton_pos"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="max_width_chars">1</property> + <property name="climb_rate">1</property> + <property name="digits">2</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">2</property> + </packing> </child> <child> - <placeholder/> + <object class="GtkSpinButton" id="spinbutton_neg"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="progress_fraction">0.019999999552965164</property> + <property name="input_purpose">alpha</property> + <property name="climb_rate">1</property> + <property name="digits">2</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">3</property> + </packing> </child> <child> <placeholder/> |