[Libreoffice-commits] core.git: 2 commits - sc/source sc/uiconfig
Markus Mohrhard
markus.mohrhard at collabora.co.uk
Thu Apr 2 18:22:05 PDT 2015
sc/source/ui/condformat/colorformat.cxx | 71 ++++++++++++++++++++++--
sc/source/ui/inc/colorformat.hxx | 4 +
sc/uiconfig/scalc/ui/databaroptions.ui | 93 +++++++++++++++++++++++++++++++-
3 files changed, 162 insertions(+), 6 deletions(-)
New commits:
commit fefe034126e45db005f7fc45e5162c41ae69b05a
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Fri Apr 3 03:14:35 2015 +0200
use correct double to string functions
Change-Id: I4fe1dfdb02a28d2d283057921483faa6020caf92
diff --git a/sc/source/ui/condformat/colorformat.cxx b/sc/source/ui/condformat/colorformat.cxx
index c29f0fb..dc044be4 100644
--- a/sc/source/ui/condformat/colorformat.cxx
+++ b/sc/source/ui/condformat/colorformat.cxx
@@ -48,12 +48,20 @@ void GetType(const ListBox& rLstBox, const Edit& rEd, ScColorScaleEntry* pEntry,
}
}
-void SetValue( ScColorScaleEntry* pEntry, Edit& aEdit)
+OUString convertNumberToString(double nVal, ScDocument* pDoc)
+{
+ SvNumberFormatter* pNumberFormatter = pDoc->GetFormatTable();
+ OUString aText;
+ pNumberFormatter->GetInputLineString(nVal, 0, aText);
+ return aText;
+}
+
+void SetValue( ScDocument* pDoc, ScColorScaleEntry* pEntry, Edit& aEdit)
{
if(pEntry->GetType() == COLORSCALE_FORMULA)
aEdit.SetText(pEntry->GetFormula(formula::FormulaGrammar::GRAM_DEFAULT));
else if(pEntry->GetType() != COLORSCALE_MIN && pEntry->GetType() != COLORSCALE_MAX)
- aEdit.SetText(OUString::number(pEntry->GetValue()));
+ aEdit.SetText(convertNumberToString(pEntry->GetValue(), pDoc));
else
aEdit.Disable();
}
@@ -103,10 +111,10 @@ ScDataBarSettingsDlg::ScDataBarSettingsDlg(vcl::Window* pWindow, const ScDataBar
}
::SetType(rData.mpLowerLimit.get(), *mpLbTypeMin);
::SetType(rData.mpUpperLimit.get(), *mpLbTypeMax);
- SetValue(rData.mpLowerLimit.get(), *mpEdMin);
- SetValue(rData.mpUpperLimit.get(), *mpEdMax);
- mpLenMin->SetText(OUString::number(rData.mnMinLength));
- mpLenMax->SetText(OUString::number(rData.mnMaxLength));
+ SetValue(mpDoc, rData.mpLowerLimit.get(), *mpEdMin);
+ SetValue(mpDoc, rData.mpUpperLimit.get(), *mpEdMax);
+ mpLenMin->SetText(convertNumberToString(rData.mnMinLength, mpDoc));
+ mpLenMax->SetText(convertNumberToString(rData.mnMaxLength, mpDoc));
mpLbAxisCol->SelectEntry(rData.maAxisColor);
TypeSelectHdl(NULL);
commit 2390d3b6064d3fc0ec814620947ce18410d657f6
Author: Benjamin Ni <benjaminniri at hotmail.com>
Date: Thu Apr 2 16:00:10 2015 +0100
added UI part for minLength and maxLength databar property, tdf#90197
Change-Id: I82a3655864b56d9b749e85443ca10ea9ab7a0c36
diff --git a/sc/source/ui/condformat/colorformat.cxx b/sc/source/ui/condformat/colorformat.cxx
index 8b02134..c29f0fb 100644
--- a/sc/source/ui/condformat/colorformat.cxx
+++ b/sc/source/ui/condformat/colorformat.cxx
@@ -77,6 +77,8 @@ ScDataBarSettingsDlg::ScDataBarSettingsDlg(vcl::Window* pWindow, const ScDataBar
get( mpLbAxisCol, "axis_colour" );
get( mpEdMin, "min_value" );
get( mpEdMax, "max_value" );
+ get( mpLenMin, "min_length" );
+ get( mpLenMax, "max_length" );
maStrWarnSameValue = get<FixedText>("str_same_value")->GetText();
@@ -103,9 +105,12 @@ ScDataBarSettingsDlg::ScDataBarSettingsDlg(vcl::Window* pWindow, const ScDataBar
::SetType(rData.mpUpperLimit.get(), *mpLbTypeMax);
SetValue(rData.mpLowerLimit.get(), *mpEdMin);
SetValue(rData.mpUpperLimit.get(), *mpEdMax);
+ mpLenMin->SetText(OUString::number(rData.mnMinLength));
+ mpLenMax->SetText(OUString::number(rData.mnMaxLength));
mpLbAxisCol->SelectEntry(rData.maAxisColor);
TypeSelectHdl(NULL);
+ PosSelectHdl(NULL);
}
void ScDataBarSettingsDlg::Init()
@@ -150,6 +155,7 @@ void ScDataBarSettingsDlg::Init()
mpLbTypeMin->SetSelectHdl( LINK( this, ScDataBarSettingsDlg, TypeSelectHdl ) );
mpLbTypeMax->SetSelectHdl( LINK( this, ScDataBarSettingsDlg, TypeSelectHdl ) );
+ mpLbAxisPos->SetSelectHdl( LINK( this, ScDataBarSettingsDlg, PosSelectHdl ) );
}
@@ -171,6 +177,18 @@ void GetAxesPosition(ScDataBarFormatData* pData, const ListBox* rLbox)
}
}
+void SetBarLength(ScDataBarFormatData* pData, OUString minStr, OUString maxStr, SvNumberFormatter* mpNumberFormatter)
+{
+ double nMinValue = 0;
+ sal_uInt32 nIndex = 0;
+ (void)mpNumberFormatter->IsNumberFormat(minStr, nIndex, nMinValue);
+ nIndex = 0;
+ double nMaxValue = 0;
+ (void)mpNumberFormatter->IsNumberFormat(maxStr, nIndex, nMaxValue);
+ pData->mnMinLength = nMinValue;
+ pData->mnMaxLength = nMaxValue;
+}
+
}
ScDataBarFormatData* ScDataBarSettingsDlg::GetData()
@@ -186,6 +204,7 @@ ScDataBarFormatData* ScDataBarSettingsDlg::GetData()
::GetType(*mpLbTypeMin, *mpEdMin, pData->mpLowerLimit.get(), mpNumberFormatter, mpDoc, maPos);
::GetType(*mpLbTypeMax, *mpEdMax, pData->mpUpperLimit.get(), mpNumberFormatter, mpDoc, maPos);
GetAxesPosition(pData, mpLbAxisPos);
+ SetBarLength(pData, mpLenMin->GetText(), mpLenMax->GetText(), mpNumberFormatter);
return pData;
}
@@ -200,7 +219,19 @@ IMPL_LINK_NOARG( ScDataBarSettingsDlg, OkBtnHdl )
sal_Int32 nSelectMax = mpLbTypeMax->GetSelectEntryPos();
if( nSelectMax == COLORSCALE_MIN )
bWarn = true;
-
+ if(!bWarn) // databar length checks
+ {
+ OUString aMinString = mpLenMin->GetText();
+ OUString aMaxString = mpLenMax->GetText();
+ double nMinValue = 0;
+ sal_uInt32 nIndex = 0;
+ (void)mpNumberFormatter->IsNumberFormat(aMinString, nIndex, nMinValue);
+ nIndex = 0;
+ double nMaxValue = 0;
+ (void)mpNumberFormatter->IsNumberFormat(aMaxString, nIndex, nMaxValue);
+ if(rtl::math::approxEqual(nMinValue, nMaxValue) || nMinValue > nMaxValue || nMaxValue > 100 || nMinValue < 0)
+ bWarn = true;
+ }
if(!bWarn && mpLbTypeMin->GetSelectEntryPos() == mpLbTypeMax->GetSelectEntryPos())
{
@@ -266,4 +297,26 @@ IMPL_LINK_NOARG( ScDataBarSettingsDlg, TypeSelectHdl )
return 0;
}
+IMPL_LINK_NOARG( ScDataBarSettingsDlg, PosSelectHdl )
+{
+ sal_Int32 axisPos = mpLbAxisPos->GetSelectEntryPos();
+ if(axisPos != 2) // disable if axis vertical position is anything other than none
+ {
+ mpLenMin->Disable();
+ mpLenMax->Disable();
+ }
+ else
+ {
+ mpLenMin->Enable();
+ mpLenMax->Enable();
+ if(mpLenMin->GetText().isEmpty())
+ {
+ mpLenMin->SetText(OUString::number(0));
+ mpLenMax->SetText(OUString::number(100));
+ }
+ }
+ return 0;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
+
diff --git a/sc/source/ui/inc/colorformat.hxx b/sc/source/ui/inc/colorformat.hxx
index 23f036c..672ce74 100644
--- a/sc/source/ui/inc/colorformat.hxx
+++ b/sc/source/ui/inc/colorformat.hxx
@@ -37,6 +37,8 @@ private:
Edit* mpEdMin;
Edit* mpEdMax;
+ Edit* mpLenMin;
+ Edit* mpLenMax;
OUString maStrWarnSameValue;
SvNumberFormatter* mpNumberFormatter;
@@ -46,6 +48,7 @@ private:
DECL_LINK(OkBtnHdl, void*);
DECL_LINK(TypeSelectHdl, void*);
+ DECL_LINK(PosSelectHdl, void*);
void Init();
@@ -58,3 +61,4 @@ public:
#endif // INCLUDED_SC_SOURCE_UI_INC_COLORFORMAT_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
+
diff --git a/sc/uiconfig/scalc/ui/databaroptions.ui b/sc/uiconfig/scalc/ui/databaroptions.ui
index 1fa0f68..c534769 100644
--- a/sc/uiconfig/scalc/ui/databaroptions.ui
+++ b/sc/uiconfig/scalc/ui/databaroptions.ui
@@ -406,6 +406,97 @@
</packing>
</child>
<child>
+
+ <object class="GtkFrame" id="frame4">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <object class="GtkAlignment" id="alignment3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="top_padding">6</property>
+ <property name="left_padding">12</property>
+ <child>
+ <object class="GtkGrid" id="grid3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ <property name="row_spacing">6</property>
+ <property name="column_spacing">6</property>
+ <child>
+ <object class="GtkLabel" id="label10">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">end</property>
+ <property name="label" translatable="yes">Minimum bar length (%):</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">minLength</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label11">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">end</property>
+ <property name="label" translatable="yes">Maximum bar length (%):</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">maxLength</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="min_length">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">●</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="max_length">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">●</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label12">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Bar lengths</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ </child>
+ </object>
+
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">3</property>
+ </packing>
<object class="GtkLabel" id="str_same_value">
<property name="can_focus">False</property>
<property name="label" translatable="yes">Min value must be smaller than max value!</property>
@@ -414,7 +505,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
- <property name="position">3</property>
+ <property name="position">4</property>
</packing>
</child>
</object>
More information about the Libreoffice-commits
mailing list