[Libreoffice-commits] core.git: sw/source

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Fri Feb 14 20:25:33 UTC 2020


 sw/source/ui/envelp/label1.cxx    |   24 ++++++++++++------------
 sw/source/uibase/inc/labimp.hxx   |    3 ---
 sw/source/uibase/inc/uitool.hxx   |    5 -----
 sw/source/uibase/utlui/uitool.cxx |   13 -------------
 4 files changed, 12 insertions(+), 33 deletions(-)

New commits:
commit 90fbc16b5667324ec5f4bf54b1b6fc0677958686
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Fri Feb 14 15:47:29 2020 +0000
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Fri Feb 14 21:25:00 2020 +0100

    remove MetricField use from sw
    
    Change-Id: Ib59efd309521db5dd568ae4f3353034839cb7e1e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88729
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sw/source/ui/envelp/label1.cxx b/sw/source/ui/envelp/label1.cxx
index 38bc29df5f57..4ac097718c0e 100644
--- a/sw/source/ui/envelp/label1.cxx
+++ b/sw/source/ui/envelp/label1.cxx
@@ -21,6 +21,7 @@
 #include <vcl/svapp.hxx>
 #include <rtl/ustring.hxx>
 #include <tools/lineend.hxx>
+#include <svtools/unitconv.hxx>
 #include <com/sun/star/uno/Sequence.h>
 #include <swtypes.hxx>
 #include <labimp.hxx>
@@ -388,24 +389,23 @@ IMPL_LINK_NOARG(SwLabPage, TypeHdl, weld::ComboBox&, void)
 
 void SwLabPage::DisplayFormat()
 {
-    ScopedVclPtrInstance< MetricField > aField(Application::GetDefDialogParent(), WinBits(0));
-    FieldUnit aMetric = ::GetDfltMetric(false);
-    SetMetric(*aField, aMetric);
-    aField->SetDecimalDigits(2);
-    aField->SetMin         (0);
-    aField->SetMax         (LONG_MAX);
+    std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(GetFrameWeld(), "cui/ui/spinbox.ui"));
+    std::unique_ptr<weld::MetricSpinButton> xField(xBuilder->weld_metric_spin_button("spin", FieldUnit::CM));
+    SetFieldUnit(*xField, ::GetDfltMetric(false));
+    xField->set_digits(2);
+    xField->set_range(0, INT_MAX - 1, FieldUnit::NONE);
 
     SwLabRec* pRec = GetSelectedEntryPos();
     aItem.m_aLstType = pRec->m_aType;
-    SETFLDVAL(*aField, pRec->m_nWidth);
-    aField->Reformat();
-    const OUString aWString = aField->GetText();
+    setfldval(*xField, pRec->m_nWidth);
+    xField->reformat();
+    const OUString aWString = xField->get_text();
 
-    SETFLDVAL(*aField, pRec->m_nHeight);
-    aField->Reformat();
+    setfldval(*xField, pRec->m_nHeight);
+    xField->reformat();
 
     OUString aText = pRec->m_aType + ": " + aWString +
-           " x " + aField->GetText() +
+           " x " + xField->get_text() +
            " (" + OUString::number( pRec->m_nCols ) +
            " x " + OUString::number( pRec->m_nRows ) + ")";
     m_xFormatInfo->set_label(aText);
diff --git a/sw/source/uibase/inc/labimp.hxx b/sw/source/uibase/inc/labimp.hxx
index 928ee86ec600..e8db8aab1140 100644
--- a/sw/source/uibase/inc/labimp.hxx
+++ b/sw/source/uibase/inc/labimp.hxx
@@ -21,9 +21,6 @@
 
 #include <vcl/weld.hxx>
 
-#define GETFLDVAL(rField)         (rField).Denormalize((rField).GetValue(FieldUnit::TWIP))
-#define SETFLDVAL(rField, lValue) (rField).SetValue((rField).Normalize(lValue), FieldUnit::TWIP)
-
 inline int getfldval(const weld::MetricSpinButton& rField)
 {
     return rField.denormalize(rField.get_value(FieldUnit::TWIP));
diff --git a/sw/source/uibase/inc/uitool.hxx b/sw/source/uibase/inc/uitool.hxx
index 867107bfffe3..0ecd18da1575 100644
--- a/sw/source/uibase/inc/uitool.hxx
+++ b/sw/source/uibase/inc/uitool.hxx
@@ -19,12 +19,10 @@
 #ifndef INCLUDED_SW_SOURCE_UIBASE_INC_UITOOL_HXX
 #define INCLUDED_SW_SOURCE_UIBASE_INC_UITOOL_HXX
 
-#include <vcl/field.hxx>
 #include <vcl/weld.hxx>
 #include <swtypes.hxx>
 #include <swdllapi.h>
 
-class MetricFormatter;
 class SfxItemSet;
 class SwPageDesc;
 class SvxTabStopItem;
@@ -38,9 +36,6 @@ class DateTime;
 class SfxViewFrame;
 class SwEditShell;
 
-// switch a metric
-SW_DLLPUBLIC void SetMetric(MetricFormatter& rCtrl, FieldUnit eUnit);
-
 // fill BoxInfo attribute
 SW_DLLPUBLIC void PrepareBoxInfo(SfxItemSet& rSet, const SwWrtShell& rSh);
 
diff --git a/sw/source/uibase/utlui/uitool.cxx b/sw/source/uibase/utlui/uitool.cxx
index 1acca5313503..cf82118f8ace 100644
--- a/sw/source/uibase/utlui/uitool.cxx
+++ b/sw/source/uibase/utlui/uitool.cxx
@@ -74,19 +74,6 @@ using namespace ::com::sun::star;
 
 // General list of string pointer
 
-// Switch metric
-
-void SetMetric(MetricFormatter& rCtrl, FieldUnit eUnit)
-{
-    SwTwips nMin = static_cast< SwTwips >(rCtrl.GetMin(FieldUnit::TWIP));
-    SwTwips nMax = static_cast< SwTwips >(rCtrl.GetMax(FieldUnit::TWIP));
-
-    rCtrl.SetUnit(eUnit);
-
-    rCtrl.SetMin(nMin, FieldUnit::TWIP);
-    rCtrl.SetMax(nMax, FieldUnit::TWIP);
-}
-
 // Set boxinfo attribute
 
 void PrepareBoxInfo(SfxItemSet& rSet, const SwWrtShell& rSh)


More information about the Libreoffice-commits mailing list