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 , mxLbPos(new
ColorListBox(m_xBuilder->weld_menu_button(
"positive_colour"), [this]{
return m_xDialog.get(); }))
78 , mxLbNeg(
new ColorListBox(m_xBuilder->weld_menu_button(
"negative_colour"), [
this]{ return m_xDialog.get(); }))
79 , mxLbAxisCol(
new ColorListBox(m_xBuilder->weld_menu_button(
"axis_colour"), [
this]{ return m_xDialog.get(); }))
80 , mxLbFillType(m_xBuilder->weld_combo_box(
"fill_type"))
81 , mxLbTypeMin(m_xBuilder->weld_combo_box(
"min"))
82 , mxLbTypeMax(m_xBuilder->weld_combo_box(
"max"))
83 , mxLbAxisPos(m_xBuilder->weld_combo_box(
"axis_pos"))
84 , mxEdMin(m_xBuilder->weld_entry(
"min_value"))
85 , mxEdMax(m_xBuilder->weld_entry(
"max_value"))
86 , mxLenMin(m_xBuilder->weld_entry(
"min_length"))
87 , mxLenMax(m_xBuilder->weld_entry(
"max_length"))
88 , mxCbOnlyBar(m_xBuilder->weld_check_button(
"only_bar"))
89 , mxStrSameValueFT(m_xBuilder->weld_label(
"str_same_value"))
91 maStrWarnSameValue = mxStrSameValueFT->get_label();
95 mxLbPos->SelectEntry(rData.maPositiveColor);
96 mxLbFillType->set_active( rData.mbGradient ? 1 : 0 );
97 if (rData.mxNegativeColor)
98 mxLbNeg->SelectEntry(*rData.mxNegativeColor);
100 switch (rData.meAxisPosition)
103 mxLbAxisPos->set_active(2);
106 mxLbAxisPos->set_active(0);
109 mxLbAxisPos->set_active(1);
112 ::SetType(rData.mpLowerLimit.get(), *mxLbTypeMin);
113 ::SetType(rData.mpUpperLimit.get(), *mxLbTypeMax);
114 SetValue(mpDoc, rData.mpLowerLimit.get(), *mxEdMin);
115 SetValue(mpDoc, rData.mpUpperLimit.get(), *mxEdMax);
116 mxLenMin->set_text(convertNumberToString(rData.mnMinLength, mpDoc));
117 mxLenMax->set_text(convertNumberToString(rData.mnMaxLength, mpDoc));
118 mxLbAxisCol->SelectEntry(rData.maAxisColor);
119 mxCbOnlyBar->set_active(rData.mbOnlyBar);
121 TypeSelectHdl(*mxLbTypeMin);
122 PosSelectHdl(*mxLbTypeMin);
133 mxLbPos->SelectEntry(0x2a6099);
162 double nMinValue = 0;
164 (void)mpNumberFormatter->
IsNumberFormat(minStr, nIndex, nMinValue);
166 double nMaxValue = 0;
167 (void)mpNumberFormatter->
IsNumberFormat(maxStr, nIndex, nMaxValue);
168 pData->mnMinLength = nMinValue;
169 pData->mnMaxLength = nMaxValue;
177 pData->maPositiveColor =
mxLbPos->GetSelectEntryColor();
178 pData->mxNegativeColor =
mxLbNeg->GetSelectEntryColor();
197 int nSelectMin = mxLbTypeMin->get_active();
200 int nSelectMax = mxLbTypeMax->get_active();
205 OUString aMinString = mxLenMin->get_text();
206 OUString aMaxString = mxLenMax->get_text();
207 double nMinValue = 0;
209 (void)mpNumberFormatter->IsNumberFormat(aMinString,
nIndex, nMinValue);
211 double nMaxValue = 0;
212 (void)mpNumberFormatter->IsNumberFormat(aMaxString,
nIndex, nMaxValue);
213 if(rtl::math::approxEqual(nMinValue, nMaxValue) || nMinValue > nMaxValue || nMaxValue > 100 || nMinValue < 0)
216 if (!bWarn && mxLbTypeMin->get_active() == mxLbTypeMax->get_active())
221 OUString aMinString = mxEdMin->get_text();
222 OUString aMaxString = mxEdMax->get_text();
223 double nMinValue = 0;
225 (void)mpNumberFormatter->IsNumberFormat(aMinString,
nIndex, nMinValue);
227 double nMaxValue = 0;
228 (void)mpNumberFormatter->IsNumberFormat(aMaxString,
nIndex, nMaxValue);
229 if(rtl::math::approxEqual(nMinValue, nMaxValue) || nMinValue > nMaxValue)
238 VclMessageType::Warning, VclButtonsType::Ok,
239 maStrWarnSameValue));
250 int nSelectMin = mxLbTypeMin->get_active();
252 mxEdMin->set_sensitive(
false);
255 mxEdMin->set_sensitive(
true);
256 if(mxEdMin->get_text().isEmpty())
259 mxEdMin->set_text(OUString::number(50));
261 mxEdMin->set_text(OUString::number(0));
265 int nSelectMax = mxLbTypeMax->get_active();
267 mxEdMax->set_sensitive(
false);
270 mxEdMax->set_sensitive(
true);
271 if (mxEdMax->get_text().isEmpty())
274 mxEdMax->set_text(OUString::number(50));
276 mxEdMax->set_text(OUString::number(0));
283 int axisPos = mxLbAxisPos->get_active();
284 if(axisPos != 2 && axisPos != 1)
286 mxLenMin->set_sensitive(
false);
287 mxLenMax->set_sensitive(
false);
291 mxLenMin->set_sensitive(
true);
292 mxLenMax->set_sensitive(
true);
293 if(mxLenMin->get_text().isEmpty())
295 mxLenMin->set_text(OUString::number(0));
296 mxLenMax->set_text(OUString::number(100));
Reference< XExecutableDialog > m_xDialog
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, const ILibreOfficeKitNotifier *pNotifier=nullptr)
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