Kaydet (Commit) 16fe20b6 authored tarafından Jan Holesovsky's avatar Jan Holesovsky

widget layout: Take decimal digits into account for MetricBoxes.

Change-Id: I2870dbf9dc1f7fb84adfe81b9be8f4060677e6d0
üst 7e71abad
...@@ -234,7 +234,7 @@ ...@@ -234,7 +234,7 @@
<property name="orientation">vertical</property> <property name="orientation">vertical</property>
<property name="spacing">6</property> <property name="spacing">6</property>
<child> <child>
<object class="GtkComboBox" id="rotation:0degrees"> <object class="GtkComboBox" id="rotation:0.00degrees">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="has_tooltip">True</property> <property name="has_tooltip">True</property>
......
...@@ -754,6 +754,25 @@ namespace ...@@ -754,6 +754,25 @@ namespace
return sUnit; return sUnit;
} }
int extractDecimalDigits(const OString& sPattern)
{
int nDigits = 0;
bool bAfterPoint = false;
for (sal_Int32 i = 0; i < sPattern.getLength(); ++i)
{
if (sPattern[i] == '.' || sPattern[i] == ',')
bAfterPoint = true;
else if (sPattern[i] == '0')
{
if (bAfterPoint)
++nDigits;
}
else
break;
}
return nDigits;
}
FieldUnit detectMetricUnit(OString sUnit) FieldUnit detectMetricUnit(OString sUnit)
{ {
FieldUnit eUnit = FUNIT_NONE; FieldUnit eUnit = FUNIT_NONE;
...@@ -1199,6 +1218,7 @@ Window *VclBuilder::makeObject(Window *pParent, const OString &name, const OStri ...@@ -1199,6 +1218,7 @@ Window *VclBuilder::makeObject(Window *pParent, const OString &name, const OStri
MetricBox *pBox = new MetricBox(pParent, nBits); MetricBox *pBox = new MetricBox(pParent, nBits);
pBox->EnableAutoSize(true); pBox->EnableAutoSize(true);
pBox->SetUnit(eUnit); pBox->SetUnit(eUnit);
pBox->SetDecimalDigits(extractDecimalDigits(sPattern));
if (eUnit == FUNIT_CUSTOM) if (eUnit == FUNIT_CUSTOM)
pBox->SetCustomUnitText(OStringToOUString(sUnit, RTL_TEXTENCODING_UTF8)); pBox->SetCustomUnitText(OStringToOUString(sUnit, RTL_TEXTENCODING_UTF8));
pWindow = pBox; pWindow = pBox;
......
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