include/svx/dialogs.hrc        |    3 -
 include/vcl/field.hxx          |    1 
 svx/UIConfig_svx.mk            |    1 
 svx/source/dialog/ruler.hrc    |   32 -------------
 svx/source/dialog/ruler.src    |   73 ------------------------------
 svx/source/dialog/svxruler.cxx |   25 +++++-----
 svx/uiconfig/ui/rulermenu.ui   |   97 +++++++++++++++++++++++++++++++++++++++++
 vcl/source/control/field.cxx   |    6 +-
 8 files changed, 116 insertions(+), 122 deletions(-)

New commits:
commit 3927105e19d335da6461d853ba5cedda788067da
Author: Caolán McNamara <caol...@redhat.com>
Date:   Tue Apr 11 13:11:08 2017 +0100

    convert ruler menu to .ui
    
    Change-Id: I5f9b0033288ccd4b58e055998834185970f987b0

diff --git a/include/svx/dialogs.hrc b/include/svx/dialogs.hrc
index 5f98695ecace..9e29d67ad793 100644
--- a/include/svx/dialogs.hrc
+++ b/include/svx/dialogs.hrc
@@ -171,9 +171,6 @@
 #define RID_SVXBMP_EDIT                     (RID_SVX_START +  90)
 #define RID_SVXBMP_REMOVE                   (RID_SVX_START +  91)
 
-// Menu for the ruler
-#define RID_SVXMN_RULER                     (RID_SVX_START +  92)
-
 #define RID_SVXSTR_FRMSEL_TEXTS             (RID_SVX_START +  93)
 #define RID_SVXSTR_FRMSEL_DESCRIPTIONS      (RID_SVX_START +  94)
 #define RID_SVXBMP_FRMSEL_ARROW1            (RID_SVX_START +  95)
diff --git a/include/vcl/field.hxx b/include/vcl/field.hxx
index 973f12421347..f78a565d9374 100644
--- a/include/vcl/field.hxx
+++ b/include/vcl/field.hxx
@@ -232,6 +232,7 @@ public:
 
     void                    SetCustomConvertHdl( const 
Link<MetricFormatter&,void>& rLink ) { maCustomConvertLink = rLink; }
 
+    static FieldUnit        StringToMetric(const OUString &rMetricString);
 protected:
     sal_Int64               mnBaseValue;
     FieldUnit               meUnit;
diff --git a/svx/UIConfig_svx.mk b/svx/UIConfig_svx.mk
index e073234f3540..ab20c8360c73 100644
--- a/svx/UIConfig_svx.mk
+++ b/svx/UIConfig_svx.mk
@@ -65,6 +65,7 @@ $(eval $(call gb_UIConfig_add_uifiles,svx,\
        svx/uiconfig/ui/redlinecontrol \
        svx/uiconfig/ui/redlinefilterpage \
        svx/uiconfig/ui/redlineviewpage \
+       svx/uiconfig/ui/rulermenu \
        svx/uiconfig/ui/safemodedialog \
        svx/uiconfig/ui/savemodifieddialog \
        svx/uiconfig/ui/sidebararea \
diff --git a/svx/source/dialog/ruler.hrc b/svx/source/dialog/ruler.hrc
deleted file mode 100644
index a4ce17b89c29..000000000000
--- a/svx/source/dialog/ruler.hrc
+++ /dev/null
@@ -1,32 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- *   Licensed to the Apache Software Foundation (ASF) under one or more
- *   contributor license agreements. See the NOTICE file distributed
- *   with this work for additional information regarding copyright
- *   ownership. The ASF licenses this file to you under the Apache
- *   License, Version 2.0 (the "License"); you may not use this file
- *   except in compliance with the License. You may obtain a copy of
- *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-//!! Dependence on sv.hxx
-#define ID_MM 1
-#define ID_CM 2
-#define ID_M 3
-#define ID_KM 4
-#define ID_INCH 8
-#define ID_FOOT 9
-#define ID_MILE 10
-#define ID_POINT 6
-#define ID_PICA 7
-#define ID_CHAR 11
-#define ID_LINE 12
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/ruler.src b/svx/source/dialog/ruler.src
index b1942de57a8d..0e8cc51b89ff 100644
--- a/svx/source/dialog/ruler.src
+++ b/svx/source/dialog/ruler.src
@@ -17,80 +17,7 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 #include <svx/dialogs.hrc>
-#include "ruler.hrc"
 
-Menu RID_SVXMN_RULER
-{
-    ItemList =
-    {
-        MenuItem
-        {
-            Identifier = ID_MM ;
-            RadioCheck = TRUE ;
-            Text [ en-US ] = "Millimeter" ;
-        };
-        MenuItem
-        {
-            Identifier = ID_CM ;
-            RadioCheck = TRUE ;
-            Text [ en-US ] = "Centimeter" ;
-        };
-        MenuItem
-        {
-            Identifier = ID_M ;
-            RadioCheck = TRUE ;
-            Text [ en-US ] = "Meter" ;
-        };
-        MenuItem
-        {
-            Identifier = ID_KM ;
-            RadioCheck = TRUE ;
-            Text [ en-US ] = "Kilometer" ;
-        };
-        MenuItem
-        {
-            Identifier = ID_INCH ;
-            RadioCheck = TRUE ;
-            Text [ en-US ] = "Inch" ;
-        };
-        MenuItem
-        {
-            Identifier = ID_FOOT ;
-            RadioCheck = TRUE ;
-            Text [ en-US ] = "Foot" ;
-        };
-        MenuItem
-        {
-            Identifier = ID_MILE ;
-            RadioCheck = TRUE ;
-            Text [ en-US ] = "Miles" ;
-        };
-        MenuItem
-        {
-            Identifier = ID_POINT ;
-            RadioCheck = TRUE ;
-            Text [ en-US ] = "Point" ;
-        };
-        MenuItem
-        {
-            Identifier = ID_PICA ;
-            RadioCheck = TRUE ;
-            Text [ en-US ] = "Pica" ;
-        };
-        MenuItem
-        {
-            Identifier = ID_CHAR ;
-            RadioCheck = TRUE ;
-            Text[ en-US ] = "Char" ;
-        };
-        MenuItem
-        {
-            Identifier = ID_LINE ;
-            RadioCheck = TRUE ;
-            Text[ en-US ] = "Line" ;
-        };
-    };
-};
 String RID_SVXSTR_RULER_TAB_LEFT
 {
     Text [ en-US ] = "Left" ;
diff --git a/svx/source/dialog/svxruler.cxx b/svx/source/dialog/svxruler.cxx
index ec43c43eb1a8..7aa3cbb9ccec 100644
--- a/svx/source/dialog/svxruler.cxx
+++ b/svx/source/dialog/svxruler.cxx
@@ -20,6 +20,7 @@
 #include <cstring>
 #include <climits>
 
+#include <vcl/builder.hxx>
 #include <vcl/image.hxx>
 #include <vcl/svapp.hxx>
 #include <vcl/settings.hxx>
@@ -3342,11 +3343,10 @@ void SvxRuler::Notify(SfxBroadcaster&, const SfxHint& 
rHint)
     }
 }
 
-
 IMPL_LINK( SvxRuler, MenuSelect, Menu *, pMenu, bool )
 {
     /* Handler of the context menus for switching the unit of measurement */
-    SetUnit(FieldUnit(pMenu->GetCurItemId()));
+    
SetUnit(MetricFormatter::StringToMetric(OUString::fromUtf8(pMenu->GetCurItemIdent())));
     return false;
 }
 
@@ -3404,7 +3404,8 @@ void SvxRuler::Command( const CommandEvent& rCommandEvent 
)
         }
         else
         {
-            ScopedVclPtrInstance<PopupMenu> aMenu(ResId(RID_SVXMN_RULER, 
DIALOG_MGR()));
+            VclBuilder aBuilder(nullptr, VclBuilderContainer::getUIRootDir(), 
"svx/ui/rulermenu.ui", "");
+            VclPtr<PopupMenu> aMenu(aBuilder.get_menu("menu"));
             aMenu->SetSelectHdl(LINK(this, SvxRuler, MenuSelect));
             FieldUnit eUnit = GetUnit();
             const sal_uInt16 nCount = aMenu->GetItemCount();
@@ -3412,22 +3413,24 @@ void SvxRuler::Command( const CommandEvent& 
rCommandEvent )
             bool bReduceMetric = bool(nFlags & 
SvxRulerSupportFlags::REDUCED_METRIC);
             for ( sal_uInt16 i = nCount; i; --i )
             {
-                const sal_uInt16 nId = aMenu->GetItemId(i - 1);
-                aMenu->CheckItem(nId, nId == (sal_uInt16)eUnit);
+                sal_uInt16 nId = aMenu->GetItemId(i - 1);
+                OString sIdent = aMenu->GetItemIdent(nId);
+                FieldUnit eMenuUnit = 
MetricFormatter::StringToMetric(OUString::fromUtf8(sIdent));
+                aMenu->CheckItem(nId, eMenuUnit == eUnit);
                 if( bReduceMetric )
                 {
-                    if ( nId == FUNIT_M    ||
-                         nId == FUNIT_KM   ||
-                         nId == FUNIT_FOOT ||
-                         nId == FUNIT_MILE )
+                    if (eMenuUnit == FUNIT_M    ||
+                        eMenuUnit == FUNIT_KM   ||
+                        eMenuUnit == FUNIT_FOOT ||
+                        eMenuUnit == FUNIT_MILE)
                     {
                         aMenu->RemoveItem(i - 1);
                     }
-                    else if (( nId == FUNIT_CHAR ) && !bHorz )
+                    else if (( eMenuUnit == FUNIT_CHAR ) && !bHorz )
                     {
                         aMenu->RemoveItem(i - 1);
                     }
-                    else if (( nId == FUNIT_LINE ) && bHorz )
+                    else if (( eMenuUnit == FUNIT_LINE ) && bHorz )
                     {
                         aMenu->RemoveItem(i - 1);
                     }
diff --git a/svx/uiconfig/ui/rulermenu.ui b/svx/uiconfig/ui/rulermenu.ui
new file mode 100644
index 000000000000..163f6b9497c6
--- /dev/null
+++ b/svx/uiconfig/ui/rulermenu.ui
@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.20.0 -->
+<interface>
+  <requires lib="gtk+" version="3.10"/>
+  <object class="GtkMenu" id="menu">
+    <property name="visible">True</property>
+    <property name="can_focus">False</property>
+    <child>
+      <object class="GtkRadioMenuItem" id="mm">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="label" translatable="yes">Millimeter</property>
+        <property name="use_underline">True</property>
+      </object>
+    </child>
+    <child>
+      <object class="GtkRadioMenuItem" id="cm">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="label" translatable="yes">Centimeter</property>
+        <property name="use_underline">True</property>
+      </object>
+    </child>
+    <child>
+      <object class="GtkRadioMenuItem" id="m">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="label" translatable="yes">Meter</property>
+        <property name="use_underline">True</property>
+      </object>
+    </child>
+    <child>
+      <object class="GtkRadioMenuItem" id="km">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="label" translatable="yes">Kilometer</property>
+        <property name="use_underline">True</property>
+      </object>
+    </child>
+    <child>
+      <object class="GtkRadioMenuItem" id="in">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="label" translatable="yes">Inch</property>
+        <property name="use_underline">True</property>
+      </object>
+    </child>
+    <child>
+      <object class="GtkRadioMenuItem" id="ft">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="label" translatable="yes">Foot</property>
+        <property name="use_underline">True</property>
+      </object>
+    </child>
+    <child>
+      <object class="GtkRadioMenuItem" id="mile">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="label" translatable="yes">Miles</property>
+        <property name="use_underline">True</property>
+      </object>
+    </child>
+    <child>
+      <object class="GtkRadioMenuItem" id="pt">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="label" translatable="yes">Point</property>
+        <property name="use_underline">True</property>
+      </object>
+    </child>
+    <child>
+      <object class="GtkRadioMenuItem" id="pc">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="label" translatable="yes">Pica</property>
+        <property name="use_underline">True</property>
+      </object>
+    </child>
+    <child>
+      <object class="GtkRadioMenuItem" id="ch">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="label" translatable="yes">Char</property>
+        <property name="use_underline">True</property>
+      </object>
+    </child>
+    <child>
+      <object class="GtkRadioMenuItem" id="line">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="label" translatable="yes">Line</property>
+        <property name="use_underline">True</property>
+      </object>
+    </child>
+  </object>
+</interface>
diff --git a/vcl/source/control/field.cxx b/vcl/source/control/field.cxx
index 394fb8f73bf9..68baa147006a 100644
--- a/vcl/source/control/field.cxx
+++ b/vcl/source/control/field.cxx
@@ -1023,7 +1023,7 @@ static const OUString ImplMetricToString( FieldUnit rUnit 
)
     return OUString();
 }
 
-static FieldUnit ImplStringToMetric(const OUString &rMetricString)
+FieldUnit MetricFormatter::StringToMetric(const OUString &rMetricString)
 {
     FieldUnitStringList* pList = ImplGetCleanedFieldUnits();
     if( pList )
@@ -1042,8 +1042,8 @@ static FieldUnit ImplStringToMetric(const OUString 
&rMetricString)
 
 static FieldUnit ImplMetricGetUnit(const OUString& rStr)
 {
-    OUString aStr = ImplMetricGetUnitText( rStr );
-    return ImplStringToMetric( aStr );
+    OUString aStr = ImplMetricGetUnitText(rStr);
+    return MetricFormatter::StringToMetric(aStr);
 }
 
 #define K *1000L
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to