[Libreoffice-commits] core.git: Branch 'libreoffice-4-2' - include/svx include/vcl svx/source vcl/source

Michael Stahl mstahl at redhat.com
Wed May 21 06:13:31 PDT 2014


 include/svx/relfld.hxx        |    3 ++-
 include/vcl/builder.hxx       |    2 ++
 svx/source/dialog/relfld.cxx  |   13 ++++++++++---
 vcl/source/window/builder.cxx |    6 ++++++
 4 files changed, 20 insertions(+), 4 deletions(-)

New commits:
commit ae25bede31aba18d7fa0ed90050f6e82f0507514
Author: Michael Stahl <mstahl at redhat.com>
Date:   Tue May 20 16:20:42 2014 +0200

    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.
    
    (cherry picked from commit 68bc8af6b6c4d0399bd10ed450d81aa2f17931a1)
    
    Conflicts:
    	svx/source/dialog/relfld.cxx
    
    Change-Id: I6001c93079fd7d899f1e119913b29ea4898b1c34
    Reviewed-on: https://gerrit.libreoffice.org/9416
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/include/svx/relfld.hxx b/include/svx/relfld.hxx
index 80fa2c4..c9fbe41 100644
--- a/include/svx/relfld.hxx
+++ b/include/svx/relfld.hxx
@@ -19,6 +19,7 @@
 #ifndef INCLUDED_SVX_RELFLD_HXX
 #define INCLUDED_SVX_RELFLD_HXX
 
+#include <tools/fldunit.hxx>
 #include <vcl/field.hxx>
 #include <svx/svxdllapi.h>
 
@@ -39,7 +40,7 @@ protected:
     void            Modify();
 
 public:
-    SvxRelativeField( Window* pParent, WinBits nBits);
+    SvxRelativeField(Window* pParent, WinBits nBits, FieldUnit eUnit);
 
     void            EnableRelativeMode( sal_uInt16 nMin = 50, sal_uInt16 nMax = 150,
                                         sal_uInt16 nStep = 5 );
diff --git a/include/vcl/builder.hxx b/include/vcl/builder.hxx
index 8cd25a0..e975534 100644
--- a/include/vcl/builder.hxx
+++ b/include/vcl/builder.hxx
@@ -13,6 +13,7 @@
 #include <typeinfo>
 #include <osl/module.hxx>
 #include <tools/resmgr.hxx>
+#include <tools/fldunit.hxx>
 #include <vcl/dllapi.h>
 #include <vcl/window.hxx>
 #include <xmlreader/xmlreader.hxx>
@@ -293,6 +294,7 @@ public:
     static OString convertMnemonicMarkup(const OString &rIn);
 
     static OString extractCustomProperty(stringmap &rMap);
+    static FieldUnit detectUnit(OString const&);
 
     static bool extractDropdown(stringmap &rMap);
 
diff --git a/svx/source/dialog/relfld.cxx b/svx/source/dialog/relfld.cxx
index 67a4a59..52479b5 100644
--- a/svx/source/dialog/relfld.cxx
+++ b/svx/source/dialog/relfld.cxx
@@ -22,21 +22,28 @@
 
 // -----------------------------------------------------------------------
 
-SvxRelativeField::SvxRelativeField( Window* pParent, WinBits nBits) :
+SvxRelativeField::SvxRelativeField(Window* pParent, WinBits nBits, FieldUnit const eUnit)
+    :
     MetricField( pParent, nBits)
 {
     bNegativeEnabled = sal_False;
     bRelativeMode = sal_False;
     bRelative     = sal_False;
 
+    SetUnit(eUnit);
     SetDecimalDigits( 2 );
     SetMin( 0 );
     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;
 }
 // -----------------------------------------------------------------------
 
diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx
index 577eb86..d97d1d6 100644
--- a/vcl/source/window/builder.cxx
+++ b/vcl/source/window/builder.cxx
@@ -884,6 +884,12 @@ namespace
     }
 }
 
+FieldUnit VclBuilder::detectUnit(OString const& rString)
+{
+    OString const unit(extractUnit(rString));
+    return detectMetricUnit(unit);
+}
+
 void VclBuilder::ensureDefaultWidthChars(VclBuilder::stringmap &rMap)
 {
     OString sWidthChars("width-chars");


More information about the Libreoffice-commits mailing list