Kaydet (Commit) 68bc8af6 authored tarafından Michael Stahl's avatar Michael Stahl

SvxRelativeField: set the unit from the passed stringmap

In the Paragraph "Indents & Spacing" tab there are fields with unit:
<object class="svxlo-SvxRelativeField" id="spinED_LEFTINDENT:0cm">

But the unit is effectively ignored, and the resulting SvxRelativeField
with FUNIT_NONE and 9999 max somehow results in 0.18cm max when the
dialog sets cm as unit.

Change-Id: I6001c93079fd7d899f1e119913b29ea4898b1c34
üst 35199df7
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#ifndef INCLUDED_SVX_RELFLD_HXX #ifndef INCLUDED_SVX_RELFLD_HXX
#define INCLUDED_SVX_RELFLD_HXX #define INCLUDED_SVX_RELFLD_HXX
#include <tools/fldunit.hxx>
#include <vcl/field.hxx> #include <vcl/field.hxx>
#include <svx/svxdllapi.h> #include <svx/svxdllapi.h>
...@@ -39,7 +40,7 @@ protected: ...@@ -39,7 +40,7 @@ protected:
void Modify() SAL_OVERRIDE; void Modify() SAL_OVERRIDE;
public: public:
SvxRelativeField( Window* pParent, WinBits nBits); SvxRelativeField(Window* pParent, WinBits nBits, FieldUnit eUnit);
void EnableRelativeMode( sal_uInt16 nMin = 50, sal_uInt16 nMax = 150, void EnableRelativeMode( sal_uInt16 nMin = 50, sal_uInt16 nMax = 150,
sal_uInt16 nStep = 5 ); sal_uInt16 nStep = 5 );
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include <typeinfo> #include <typeinfo>
#include <osl/module.hxx> #include <osl/module.hxx>
#include <tools/resmgr.hxx> #include <tools/resmgr.hxx>
#include <tools/fldunit.hxx>
#include <vcl/dllapi.h> #include <vcl/dllapi.h>
#include <vcl/window.hxx> #include <vcl/window.hxx>
#include <xmlreader/xmlreader.hxx> #include <xmlreader/xmlreader.hxx>
...@@ -303,6 +304,7 @@ public: ...@@ -303,6 +304,7 @@ public:
static OString convertMnemonicMarkup(const OString &rIn); static OString convertMnemonicMarkup(const OString &rIn);
static OString extractCustomProperty(stringmap &rMap); static OString extractCustomProperty(stringmap &rMap);
static FieldUnit detectUnit(OString const&);
static bool extractDropdown(stringmap &rMap); static bool extractDropdown(stringmap &rMap);
......
...@@ -22,7 +22,8 @@ ...@@ -22,7 +22,8 @@
SvxRelativeField::SvxRelativeField( Window* pParent, WinBits nBits) SvxRelativeField::SvxRelativeField(
Window *const pParent, WinBits const nBits, FieldUnit const eUnit)
: MetricField( pParent, nBits) : MetricField( pParent, nBits)
, nRelMin(0) , nRelMin(0)
, nRelMax(0) , nRelMax(0)
...@@ -32,15 +33,20 @@ SvxRelativeField::SvxRelativeField( Window* pParent, WinBits nBits) ...@@ -32,15 +33,20 @@ SvxRelativeField::SvxRelativeField( Window* pParent, WinBits nBits)
, bNegativeEnabled(false) , bNegativeEnabled(false)
{ {
SetUnit(eUnit);
SetDecimalDigits( 2 ); SetDecimalDigits( 2 );
SetMin( 0 ); SetMin( 0 );
SetMax( 9999 ); SetMax( 9999 );
} }
extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeSvxRelativeField(Window *pParent, VclBuilder::stringmap &) extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL
makeSvxRelativeField(Window *const pParent, VclBuilder::stringmap & rMap)
{ {
return new SvxRelativeField(pParent, WB_BORDER | WB_SPIN | WB_REPEAT | WB_LEFT | WB_GROUP); OString const custom(VclBuilder::extractCustomProperty(rMap));
FieldUnit const eUnit(VclBuilder::detectUnit(custom));
SvxRelativeField *const pRet = new SvxRelativeField(pParent,
WB_BORDER | WB_SPIN | WB_REPEAT | WB_LEFT | WB_GROUP, eUnit);
return pRet;
} }
......
...@@ -904,6 +904,12 @@ namespace ...@@ -904,6 +904,12 @@ namespace
} }
} }
FieldUnit VclBuilder::detectUnit(OString const& rString)
{
OString const unit(extractUnit(rString));
return detectMetricUnit(unit);
}
void VclBuilder::ensureDefaultWidthChars(VclBuilder::stringmap &rMap) void VclBuilder::ensureDefaultWidthChars(VclBuilder::stringmap &rMap)
{ {
OString sWidthChars("width-chars"); OString sWidthChars("width-chars");
......
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