Kaydet (Commit) fc2f3ce3 authored tarafından Caolán McNamara's avatar Caolán McNamara

add a mechanism to load date fields from .ui files

Change-Id: If546e2f5c0f4b58d1306c737bf69799e8033c5c0
üst d48d8c5d
......@@ -23,11 +23,9 @@
<property name="page_increment">10</property>
</object>
<object class="GtkAdjustment" id="adjustment4">
<property name="lower">1</property>
<property name="upper">1439</property>
<property name="value">10</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
<property name="lower">10000</property>
<property name="upper">23590000</property>
<property name="value">100000</property>
</object>
<object class="GtkBox" id="OptMemoryPage">
<property name="visible">True</property>
......
......@@ -23,6 +23,7 @@ class ListBox;
class NumericFormatter;
class PopupMenu;
class ScrollBar;
class DateField;
class TimeField;
class VclMultiLineEdit;
......@@ -129,6 +130,7 @@ private:
typedef stringmap Adjustment;
const Adjustment *get_adjustment_by_name(OString sID) const;
static void mungeAdjustment(NumericFormatter &rTarget, const Adjustment &rAdjustment);
static void mungeAdjustment(DateField &rTarget, const Adjustment &rAdjustment);
static void mungeAdjustment(TimeField &rTarget, const Adjustment &rAdjustment);
static void mungeAdjustment(ScrollBar &rTarget, const Adjustment &rAdjustment);
......@@ -169,6 +171,7 @@ private:
std::vector<WidgetAdjustmentMap> m_aNumericFormatterAdjustmentMaps;
std::vector<WidgetAdjustmentMap> m_aTimeFormatterAdjustmentMaps;
std::vector<WidgetAdjustmentMap> m_aDateFormatterAdjustmentMaps;
std::vector<WidgetAdjustmentMap> m_aScrollAdjustmentMaps;
std::map<OString, Adjustment> m_aAdjustments;
......@@ -263,6 +266,7 @@ private:
void connectNumericFormatterAdjustment(const OString &id, const OString &rAdjustment);
void connectTimeFormatterAdjustment(const OString &id, const OString &rAdjustment);
void connectDateFormatterAdjustment(const OString &id, const OString &rAdjustment);
bool extractGroup(const OString &id, stringmap &rVec);
bool extractModel(const OString &id, stringmap &rVec);
......
......@@ -256,6 +256,16 @@ VclBuilder::VclBuilder(Window *pParent, OUString sUIDir, OUString sUIFile, OStri
mungeAdjustment(*pTarget, *pAdjustment);
}
for (std::vector<WidgetAdjustmentMap>::iterator aI = m_pParserState->m_aDateFormatterAdjustmentMaps.begin(),
aEnd = m_pParserState->m_aDateFormatterAdjustmentMaps.end(); aI != aEnd; ++aI)
{
DateField *pTarget = dynamic_cast<DateField*>(get<Window>(aI->m_sID));
const Adjustment *pAdjustment = get_adjustment_by_name(aI->m_sValue);
SAL_WARN_IF(!pTarget || !pAdjustment, "vcl", "missing elements of spinbutton/adjustment");
if (pTarget && pAdjustment)
mungeAdjustment(*pTarget, *pAdjustment);
}
//Set ScrollBar adjustments when everything has been imported
for (std::vector<WidgetAdjustmentMap>::iterator aI = m_pParserState->m_aScrollAdjustmentMaps.begin(),
aEnd = m_pParserState->m_aScrollAdjustmentMaps.end(); aI != aEnd; ++aI)
......@@ -715,6 +725,12 @@ void VclBuilder::connectTimeFormatterAdjustment(const OString &id, const OString
m_pParserState->m_aTimeFormatterAdjustmentMaps.push_back(WidgetAdjustmentMap(id, rAdjustment));
}
void VclBuilder::connectDateFormatterAdjustment(const OString &id, const OString &rAdjustment)
{
if (!rAdjustment.isEmpty())
m_pParserState->m_aDateFormatterAdjustmentMaps.push_back(WidgetAdjustmentMap(id, rAdjustment));
}
bool VclBuilder::extractScrollAdjustment(const OString &id, VclBuilder::stringmap &rMap)
{
VclBuilder::stringmap::iterator aFind = rMap.find(OString("adjustment"));
......@@ -1024,6 +1040,13 @@ Window *VclBuilder::makeObject(Window *pParent, const OString &name, const OStri
TimeField *pField = new TimeField(pParent, nBits);
pWindow = pField;
}
else if (sPattern == "yy:mm:dd")
{
connectDateFormatterAdjustment(id, sAdjustment);
SAL_INFO("vcl.layout", "making date field for " << name.getStr() << " " << sUnit.getStr());
DateField *pField = new DateField(pParent, nBits);
pWindow = pField;
}
else
{
connectNumericFormatterAdjustment(id, sAdjustment);
......@@ -2540,7 +2563,6 @@ void VclBuilder::mungeAdjustment(NumericFormatter &rTarget, const Adjustment &rA
}
}
//assume all in minutes for the moment
void VclBuilder::mungeAdjustment(TimeField &rTarget, const Adjustment &rAdjustment)
{
for (stringmap::const_iterator aI = rAdjustment.begin(), aEnd = rAdjustment.end(); aI != aEnd; ++aI)
......@@ -2550,19 +2572,19 @@ void VclBuilder::mungeAdjustment(TimeField &rTarget, const Adjustment &rAdjustme
if (rKey == "upper")
{
Time aUpper(0, rValue.toInt32());
Time aUpper(rValue.toInt32());
rTarget.SetMax(aUpper);
rTarget.SetLast(aUpper);
}
else if (rKey == "lower")
{
Time aLower(0, rValue.toInt32());
Time aLower(rValue.toInt32());
rTarget.SetMin(aLower);
rTarget.SetFirst(aLower);
}
else if (rKey == "value")
{
Time aValue(0, rValue.toInt32());
Time aValue(rValue.toInt32());
rTarget.SetTime(aValue);
}
else
......@@ -2572,6 +2594,36 @@ void VclBuilder::mungeAdjustment(TimeField &rTarget, const Adjustment &rAdjustme
}
}
void VclBuilder::mungeAdjustment(DateField &rTarget, const Adjustment &rAdjustment)
{
for (stringmap::const_iterator aI = rAdjustment.begin(), aEnd = rAdjustment.end(); aI != aEnd; ++aI)
{
const OString &rKey = aI->first;
const OString &rValue = aI->second;
if (rKey == "upper")
{
Date aUpper(rValue.toInt32());
rTarget.SetMax(aUpper);
rTarget.SetLast(aUpper);
}
else if (rKey == "lower")
{
Date aLower(rValue.toInt32());
rTarget.SetMin(aLower);
rTarget.SetFirst(aLower);
}
else if (rKey == "value")
{
Date aValue(rValue.toInt32());
rTarget.SetDate(aValue);
}
else
{
SAL_INFO("vcl.layout", "unhandled property :" << rKey.getStr());
}
}
}
void VclBuilder::mungeAdjustment(ScrollBar &rTarget, const Adjustment &rAdjustment)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment