13#include <document.hxx>
51OUString convertNumberToString(
double nVal,
const ScDocument* pDoc)
72 : GenericDialogController(pParent,
"modules/scalc/ui/databaroptions.ui",
"DataBarOptions")
73 , mpNumberFormatter(pDoc->GetFormatTable())
76 , mxBtnOk(m_xBuilder->weld_button(
"ok"))
77 , mxBtnCancel(m_xBuilder->weld_button(
"cancel"))
78 , mxLbPos(new
ColorListBox(m_xBuilder->weld_menu_button(
"positive_colour"), [this]{
return m_xDialog.get(); }))
79 , mxLbNeg(
new ColorListBox(m_xBuilder->weld_menu_button(
"negative_colour"), [
this]{ return m_xDialog.get(); }))
80 , mxLbAxisCol(
new ColorListBox(m_xBuilder->weld_menu_button(
"axis_colour"), [
this]{ return m_xDialog.get(); }))
81 , mxLbFillType(m_xBuilder->weld_combo_box(
"fill_type"))
82 , mxLbTypeMin(m_xBuilder->weld_combo_box(
"min"))
83 , mxLbTypeMax(m_xBuilder->weld_combo_box(
"max"))
84 , mxLbAxisPos(m_xBuilder->weld_combo_box(
"axis_pos"))
85 , mxEdMin(m_xBuilder->weld_entry(
"min_value"))
86 , mxEdMax(m_xBuilder->weld_entry(
"max_value"))
87 , mxLenMin(m_xBuilder->weld_entry(
"min_length"))
88 , mxLenMax(m_xBuilder->weld_entry(
"max_length"))
89 , mxCbOnlyBar(m_xBuilder->weld_check_button(
"only_bar"))
90 , mxStrSameValueFT(m_xBuilder->weld_label(
"str_same_value"))
92 maStrWarnSameValue = mxStrSameValueFT->get_label();
96 mxLbPos->SelectEntry(
rData.maPositiveColor);
97 mxLbFillType->set_active(
rData.mbGradient ? 1 : 0 );
98 if (
rData.mxNegativeColor)
99 mxLbNeg->SelectEntry(*
rData.mxNegativeColor);
101 switch (
rData.meAxisPosition)
104 mxLbAxisPos->set_active(2);
107 mxLbAxisPos->set_active(0);
110 mxLbAxisPos->set_active(1);
113 ::SetType(
rData.mpLowerLimit.get(), *mxLbTypeMin);
114 ::SetType(
rData.mpUpperLimit.get(), *mxLbTypeMax);
117 mxLenMin->set_text(convertNumberToString(
rData.mnMinLength, mpDoc));
118 mxLenMax->set_text(convertNumberToString(
rData.mnMaxLength, mpDoc));
119 mxLbAxisCol->SelectEntry(
rData.maAxisColor);
120 mxCbOnlyBar->set_active(
rData.mbOnlyBar);
122 TypeSelectHdl(*mxLbTypeMin);
123 PosSelectHdl(*mxLbTypeMin);
134 mxLbPos->SelectEntry(0x2a6099);
163 double nMinValue = 0;
165 (void)mpNumberFormatter->
IsNumberFormat(minStr, nIndex, nMinValue);
167 double nMaxValue = 0;
168 (void)mpNumberFormatter->
IsNumberFormat(maxStr, nIndex, nMaxValue);
169 pData->mnMinLength = nMinValue;
170 pData->mnMaxLength = nMaxValue;
178 pData->maPositiveColor =
mxLbPos->GetSelectEntryColor();
179 pData->mxNegativeColor =
mxLbNeg->GetSelectEntryColor();
198 int nSelectMin = mxLbTypeMin->get_active();
201 int nSelectMax = mxLbTypeMax->get_active();
206 OUString aMinString = mxLenMin->get_text();
207 OUString aMaxString = mxLenMax->get_text();
208 double nMinValue = 0;
210 (void)mpNumberFormatter->IsNumberFormat(aMinString,
nIndex, nMinValue);
212 double nMaxValue = 0;
213 (void)mpNumberFormatter->IsNumberFormat(aMaxString,
nIndex, nMaxValue);
214 if(rtl::math::approxEqual(nMinValue, nMaxValue) || nMinValue > nMaxValue || nMaxValue > 100 || nMinValue < 0)
217 if (!bWarn && mxLbTypeMin->get_active() == mxLbTypeMax->get_active())
222 OUString aMinString = mxEdMin->get_text();
223 OUString aMaxString = mxEdMax->get_text();
224 double nMinValue = 0;
226 (void)mpNumberFormatter->IsNumberFormat(aMinString,
nIndex, nMinValue);
228 double nMaxValue = 0;
229 (void)mpNumberFormatter->IsNumberFormat(aMaxString,
nIndex, nMaxValue);
230 if(rtl::math::approxEqual(nMinValue, nMaxValue) || nMinValue > nMaxValue)
239 VclMessageType::Warning, VclButtonsType::Ok,
240 maStrWarnSameValue));
251 int nSelectMin = mxLbTypeMin->get_active();
253 mxEdMin->set_sensitive(
false);
256 mxEdMin->set_sensitive(
true);
257 if(mxEdMin->get_text().isEmpty())
260 mxEdMin->set_text(OUString::number(50));
262 mxEdMin->set_text(OUString::number(0));
266 int nSelectMax = mxLbTypeMax->get_active();
268 mxEdMax->set_sensitive(
false);
271 mxEdMax->set_sensitive(
true);
272 if (mxEdMax->get_text().isEmpty())
275 mxEdMax->set_text(OUString::number(50));
277 mxEdMax->set_text(OUString::number(0));
284 int axisPos = mxLbAxisPos->get_active();
285 if(axisPos != 2 && axisPos != 1)
287 mxLenMin->set_sensitive(
false);
288 mxLenMax->set_sensitive(
false);
292 mxLenMin->set_sensitive(
true);
293 mxLenMax->set_sensitive(
true);
294 if(mxLenMin->get_text().isEmpty())
296 mxLenMin->set_text(OUString::number(0));
297 mxLenMax->set_text(OUString::number(100));
Reference< XExecutableDialog > m_xDialog
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, bool bMobile=false)
const ScTokenArray * GetFormula() const
void SetType(ScColorScaleEntryType eType)
ScColorScaleEntryType GetType() const
void SetFormula(const OUString &rFormula, ScDocument &rDoc, const ScAddress &rAddr, formula::FormulaGrammar::Grammar eGrammar=formula::FormulaGrammar::GRAM_DEFAULT)
void SetValue(double nValue)
std::unique_ptr< ColorListBox > mxLbNeg
std::unique_ptr< weld::CheckButton > mxCbOnlyBar
std::unique_ptr< ColorListBox > mxLbAxisCol
virtual ~ScDataBarSettingsDlg() override
ScDataBarSettingsDlg(weld::Window *pParent, const ScDataBarFormatData &rData, ScDocument *pDoc, const ScAddress &rPos)
std::unique_ptr< weld::Button > mxBtnOk
std::unique_ptr< weld::Entry > mxLenMin
SvNumberFormatter * mpNumberFormatter
std::unique_ptr< weld::Entry > mxEdMax
std::unique_ptr< weld::ComboBox > mxLbAxisPos
std::unique_ptr< weld::Entry > mxEdMin
std::unique_ptr< ColorListBox > mxLbPos
ScDataBarFormatData * GetData()
std::unique_ptr< weld::ComboBox > mxLbTypeMax
std::unique_ptr< weld::ComboBox > mxLbFillType
std::unique_ptr< weld::ComboBox > mxLbTypeMin
std::unique_ptr< weld::Entry > mxLenMax
SC_DLLPUBLIC SvNumberFormatter * GetFormatTable() const
virtual void set_active(int pos)=0
virtual int get_active() const=0
virtual void set_text(const OUString &rText)=0
virtual OUString get_text() const=0
std::shared_ptr< weld::Dialog > m_xDialog
constexpr ::Color COL_LIGHTRED(0xFF, 0x00, 0x00)
constexpr ::Color COL_BLACK(0x00, 0x00, 0x00)
virtual void SetValue(tools::Long nNew) override
#define LINK(Instance, Class, Member)
std::unique_ptr< sal_Int32[]> pData
const ContentProperties & rData