[Libreoffice-commits] core.git: include/svx svx/inc svx/source sw/inc sw/source sw/uiconfig

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Thu Nov 1 13:38:13 UTC 2018


 include/svx/spacinglistbox.hxx                 |    3 +
 svx/inc/spacing.hrc                            |   62 +++++++++++++++++++++----
 svx/source/dialog/spacinglistbox.cxx           |   30 ++++++++++--
 sw/inc/pageformatpanel.hrc                     |   43 +++++++++++++++++
 sw/source/uibase/sidebar/PageFooterPanel.cxx   |    5 ++
 sw/source/uibase/sidebar/PageFormatPanel.cxx   |   14 +++++
 sw/source/uibase/sidebar/PageHeaderPanel.cxx   |    5 ++
 sw/source/uibase/sidebar/WrapPropertyPanel.cxx |    4 +
 sw/uiconfig/swriter/ui/pageformatpanel.ui      |   10 ----
 9 files changed, 154 insertions(+), 22 deletions(-)

New commits:
commit 6d9a2557a0f0366fff169f3c3581414b3cec80bd
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Wed Oct 31 15:14:47 2018 +0000
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Thu Nov 1 14:37:43 2018 +0100

    Resolves: tdf#105081 and tdf#113420
    
    separate translations for Spacing: vs Margins:
    separate translations for Inch vs cm
    
    Change-Id: I9a2d8fe3ad0edde5afefe00258f1309f898130e8
    Reviewed-on: https://gerrit.libreoffice.org/62699
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/include/svx/spacinglistbox.hxx b/include/svx/spacinglistbox.hxx
index 2e2ca5280398..59ece06a10a9 100644
--- a/include/svx/spacinglistbox.hxx
+++ b/include/svx/spacinglistbox.hxx
@@ -23,11 +23,14 @@
 #include <svx/svxdllapi.h>
 #include <vcl/lstbox.hxx>
 
+enum class SpacingType { SPACING_INCH, MARGINS_INCH, SPACING_CM, MARGINS_CM };
+
 /// Custom Widget ListBox to hold entries for Spacing & Margin settings of Header/Footer
 class SVX_DLLPUBLIC SpacingListBox : public ListBox
 {
 public:
     SpacingListBox( vcl::Window* pParent );
+    void Init(SpacingType eType);
     Size GetOptimalSize() const override;
 };
 
diff --git a/svx/inc/spacing.hrc b/svx/inc/spacing.hrc
index 2e41d505015f..2f2b219f5242 100644
--- a/svx/inc/spacing.hrc
+++ b/svx/inc/spacing.hrc
@@ -13,16 +13,60 @@
 
 #define NC_(Context, String) (Context "\004" u8##String)
 
-const std::pair<const char*, int> RID_SVXSTRARY_SPACING[] =
+// To translators: this is a listbox labelled by "Spacing:", inch units
+const std::pair<const char*, int> RID_SVXSTRARY_SPACING_INCH[] =
 {
-    { NC_("RID_SVXSTRARY_SPACING", "None"),                    0 },
-    { NC_("RID_SVXSTRARY_SPACING", "Extra Small (1/16\")"),   91 },
-    { NC_("RID_SVXSTRARY_SPACING", "Small (1/8\")"),         181 },
-    { NC_("RID_SVXSTRARY_SPACING", "Small Medium (1/4\")"),  363 },
-    { NC_("RID_SVXSTRARY_SPACING", "Medium (3/8\")"),        539 },
-    { NC_("RID_SVXSTRARY_SPACING", "Medium Large (1/2\")"),  720 },
-    { NC_("RID_SVXSTRARY_SPACING", "Large (3/4\")"),        1077 },
-    { NC_("RID_SVXSTRARY_SPACING", "Extra Large (1\")"),    1440 }
+    { NC_("RID_SVXSTRARY_SPACING_INCH", "None"),                    0 },
+    { NC_("RID_SVXSTRARY_SPACING_INCH", "Extra Small (1/16\")"),   91 },
+    { NC_("RID_SVXSTRARY_SPACING_INCH", "Small (1/8\")"),         181 },
+    { NC_("RID_SVXSTRARY_SPACING_INCH", "Small Medium (1/4\")"),  363 },
+    { NC_("RID_SVXSTRARY_SPACING_INCH", "Medium (3/8\")"),        539 },
+    { NC_("RID_SVXSTRARY_SPACING_INCH", "Medium Large (1/2\")"),  720 },
+    { NC_("RID_SVXSTRARY_SPACING_INCH", "Large (3/4\")"),        1077 },
+    { NC_("RID_SVXSTRARY_SPACING_INCH", "Extra Large (1\")"),    1440 },
+    { nullptr, 0 }
+};
+
+// To translators: this is a listbox labelled by "Spacing:", cm units
+const std::pair<const char*, int> RID_SVXSTRARY_SPACING_CM[] =
+{
+    { NC_("RID_SVXSTRARY_SPACING_CM", "None"),                    0 },
+    { NC_("RID_SVXSTRARY_SPACING_CM", "Extra Small (0.16cm)"),   91 },
+    { NC_("RID_SVXSTRARY_SPACING_CM", "Small (0.32cm)"),        181 },
+    { NC_("RID_SVXSTRARY_SPACING_CM", "Small Medium (0.64cm)"), 363 },
+    { NC_("RID_SVXSTRARY_SPACING_CM", "Medium (0.95cm)"),       539 },
+    { NC_("RID_SVXSTRARY_SPACING_CM", "Medium Large (1.27cm)"), 720 },
+    { NC_("RID_SVXSTRARY_SPACING_CM", "Large (1.9cm)"),        1077 },
+    { NC_("RID_SVXSTRARY_SPACING_CM", "Extra Large (2.54cm)"), 1440 },
+    { nullptr, 0 }
+};
+
+// To translators: this is a listbox labelled by "Margins:", inch units
+const std::pair<const char*, int> RID_SVXSTRARY_MARGINS_INCH[] =
+{
+    { NC_("RID_SVXSTRARY_MARGINS_INCH", "None"),                    0 },
+    { NC_("RID_SVXSTRARY_MARGINS_INCH", "Extra Small (1/16\")"),   91 },
+    { NC_("RID_SVXSTRARY_MARGINS_INCH", "Small (1/8\")"),         181 },
+    { NC_("RID_SVXSTRARY_MARGINS_INCH", "Small Medium (1/4\")"),  363 },
+    { NC_("RID_SVXSTRARY_MARGINS_INCH", "Medium (3/8\")"),        539 },
+    { NC_("RID_SVXSTRARY_MARGINS_INCH", "Medium Large (1/2\")"),  720 },
+    { NC_("RID_SVXSTRARY_MARGINS_INCH", "Large (3/4\")"),        1077 },
+    { NC_("RID_SVXSTRARY_MARGINS_INCH", "Extra Large (1\")"),    1440 },
+    { nullptr, 0 }
+};
+
+// To translators: this is a listbox labelled by "Margins:", cm units
+const std::pair<const char*, int> RID_SVXSTRARY_MARGINS_CM[] =
+{
+    { NC_("RID_SVXSTRARY_MARGINS_CM", "None"),                    0 },
+    { NC_("RID_SVXSTRARY_MARGINS_CM", "Extra Small (0.16cm)"),   91 },
+    { NC_("RID_SVXSTRARY_MARGINS_CM", "Small (0.32cm)"),        181 },
+    { NC_("RID_SVXSTRARY_MARGINS_CM", "Small Medium (0.64cm)"), 363 },
+    { NC_("RID_SVXSTRARY_MARGINS_CM", "Medium (0.95cm)"),       539 },
+    { NC_("RID_SVXSTRARY_MARGINS_CM", "Medium Large (1.27cm)"), 720 },
+    { NC_("RID_SVXSTRARY_MARGINS_CM", "Large (1.9cm)"),        1077 },
+    { NC_("RID_SVXSTRARY_MARGINS_CM", "Extra Large (2.54cm)"), 1440 },
+    { nullptr, 0 }
 };
 
 #endif
diff --git a/svx/source/dialog/spacinglistbox.cxx b/svx/source/dialog/spacinglistbox.cxx
index db238a415178..e0a508e9830a 100644
--- a/svx/source/dialog/spacinglistbox.cxx
+++ b/svx/source/dialog/spacinglistbox.cxx
@@ -25,13 +25,37 @@
 SpacingListBox::SpacingListBox(vcl::Window* pParent)
     : ListBox( pParent, WB_BORDER | WB_DROPDOWN)
 {
-    for (size_t i = 0; i < SAL_N_ELEMENTS(RID_SVXSTRARY_SPACING); ++i)
+}
+
+void SpacingListBox::Init(SpacingType eType)
+{
+    const std::pair<const char*, int>* pResources;
+    switch (eType)
     {
-        OUString aStr = SvxResId(RID_SVXSTRARY_SPACING[i].first);
-        sal_uInt16 nData = RID_SVXSTRARY_SPACING[i].second;
+        case SpacingType::SPACING_INCH:
+            pResources = RID_SVXSTRARY_SPACING_INCH;
+            break;
+        case SpacingType::MARGINS_INCH:
+            pResources = RID_SVXSTRARY_MARGINS_INCH;
+            break;
+        case SpacingType::SPACING_CM:
+            pResources = RID_SVXSTRARY_SPACING_CM;
+            break;
+        default:
+        case SpacingType::MARGINS_CM:
+            pResources = RID_SVXSTRARY_MARGINS_CM;
+            break;
+    }
+
+    while (pResources->first)
+    {
+        OUString aStr = SvxResId(pResources->first);
+        sal_uInt16 nData = pResources->second;
         sal_Int32 nPos = InsertEntry( aStr );
         SetEntryData( nPos, reinterpret_cast<void*>(static_cast<sal_uLong>(nData)) );
+        ++pResources;
     }
+
     SetDropDownLineCount(8);
     SelectEntryPos(0);
 }
diff --git a/sw/inc/pageformatpanel.hrc b/sw/inc/pageformatpanel.hrc
new file mode 100644
index 000000000000..e35bd64c4997
--- /dev/null
+++ b/sw/inc/pageformatpanel.hrc
@@ -0,0 +1,43 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * 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/.
+ */
+
+#ifndef INCLUDED_SW_INC_PAGEFORMATPANEL_HRC
+#define INCLUDED_SW_INC_PAGEFORMATPANEL_HRC
+
+#define NC_(Context, String) (Context "\004" u8##String)
+
+// To translators: this is a listbox labelled by "Margins:", inch units
+const char* RID_PAGEFORMATPANEL_MARGINS_INCH[] =
+{
+    NC_("RID_PAGEFORMATPANEL_MARGINS_INCH", "None"),
+    NC_("RID_PAGEFORMATPANEL_MARGINS_INCH", "Narrow"),
+    NC_("RID_PAGEFORMATPANEL_MARGINS_INCH", "Moderate"),
+    NC_("RID_PAGEFORMATPANEL_MARGINS_INCH", "Normal (0.75\")"),
+    NC_("RID_PAGEFORMATPANEL_MARGINS_INCH", "Normal (1\")"),
+    NC_("RID_PAGEFORMATPANEL_MARGINS_INCH", "Normal (1.25\")"),
+    NC_("RID_PAGEFORMATPANEL_MARGINS_INCH", "Wide"),
+    NC_("RID_PAGEFORMATPANEL_MARGINS_INCH", "Mirrored")
+};
+
+// To translators: this is a listbox labelled by "Margins:", cm units
+const char* RID_PAGEFORMATPANEL_MARGINS_CM[] =
+{
+    NC_("RID_PAGEFORMATPANEL_MARGINS_CM", "None"),
+    NC_("RID_PAGEFORMATPANEL_MARGINS_CM", "Narrow"),
+    NC_("RID_PAGEFORMATPANEL_MARGINS_CM", "Moderate"),
+    NC_("RID_PAGEFORMATPANEL_MARGINS_CM", "Normal (1.9cm)"),
+    NC_("RID_PAGEFORMATPANEL_MARGINS_CM", "Normal (2.54cm)"),
+    NC_("RID_PAGEFORMATPANEL_MARGINS_CM", "Normal (3.18cm)"),
+    NC_("RID_PAGEFORMATPANEL_MARGINS_CM", "Wide"),
+    NC_("RID_PAGEFORMATPANEL_MARGINS_CM", "Mirrored")
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/sw/source/uibase/sidebar/PageFooterPanel.cxx b/sw/source/uibase/sidebar/PageFooterPanel.cxx
index e600a80b0ef5..c3b6f751bfb7 100644
--- a/sw/source/uibase/sidebar/PageFooterPanel.cxx
+++ b/sw/source/uibase/sidebar/PageFooterPanel.cxx
@@ -25,12 +25,14 @@
 #include <svx/svxids.hrc>
 #include <svx/dlgutil.hxx>
 #include <svx/rulritem.hxx>
+#include <svx/svdtrans.hxx>
 #include "PageFooterPanel.hxx"
 #include <sfx2/sidebar/ControlFactory.hxx>
 #include <sfx2/dispatch.hxx>
 #include <sfx2/bindings.hxx>
 #include <sfx2/viewsh.hxx>
 #include <sfx2/objsh.hxx>
+#include <uitool.hxx>
 #include <cmdid.h>
 
 namespace sw { namespace sidebar{
@@ -66,8 +68,11 @@ PageFooterPanel::PageFooterPanel(
 {
     get(mpFooterToggle, "footertoggle");
     get(mpFooterSpacingLB, "spacingpreset");
+    FieldUnit eMetric = ::GetDfltMetric(false);
+    mpFooterSpacingLB->Init(IsInch(eMetric) ? SpacingType::SPACING_INCH : SpacingType::SPACING_CM);
     get(mpFooterLayoutLB, "samecontentLB");
     get(mpFooterMarginPresetLB, "footermarginpreset");
+    mpFooterMarginPresetLB->Init(IsInch(GetModuleFieldUnit()) ? SpacingType::MARGINS_INCH : SpacingType::MARGINS_CM);
     get(mpCustomEntry, "customlabel");
 
     Initialize();
diff --git a/sw/source/uibase/sidebar/PageFormatPanel.cxx b/sw/source/uibase/sidebar/PageFormatPanel.cxx
index bda95ea0dd34..a256e0be0e1d 100644
--- a/sw/source/uibase/sidebar/PageFormatPanel.cxx
+++ b/sw/source/uibase/sidebar/PageFormatPanel.cxx
@@ -25,6 +25,7 @@
 #include <svx/svxids.hrc>
 #include <svx/dlgutil.hxx>
 #include <svx/rulritem.hxx>
+#include <svx/svdtrans.hxx>
 #include "PageFormatPanel.hxx"
 #include "PageMarginUtils.hxx"
 #include <sfx2/sidebar/ControlFactory.hxx>
@@ -32,7 +33,9 @@
 #include <sfx2/bindings.hxx>
 #include <sfx2/viewsh.hxx>
 #include <sfx2/objsh.hxx>
+#include <pageformatpanel.hrc>
 #include <cmdid.h>
+#include <uitool.hxx>
 #include <svtools/unitconv.hxx>
 #include <svtools/optionsdrawinglayer.hxx>
 
@@ -75,6 +78,17 @@ PageFormatPanel::PageFormatPanel(
     get(mpPaperHeight, "paperheight");
     get(mpPaperOrientation, "paperorientation");
     get(mpMarginSelectBox, "marginLB");
+    FieldUnit eMetric = ::GetDfltMetric(false);
+    if (IsInch(eMetric))
+    {
+        for (size_t i = 0; i < SAL_N_ELEMENTS(RID_PAGEFORMATPANEL_MARGINS_INCH); ++i)
+            mpMarginSelectBox->InsertEntry(SwResId(RID_PAGEFORMATPANEL_MARGINS_INCH[i]));
+    }
+    else
+    {
+        for (size_t i = 0; i < SAL_N_ELEMENTS(RID_PAGEFORMATPANEL_MARGINS_CM); ++i)
+            mpMarginSelectBox->InsertEntry(SwResId(RID_PAGEFORMATPANEL_MARGINS_CM[i]));
+    }
     get(mpCustomEntry, "customlabel");
     Initialize();
 }
diff --git a/sw/source/uibase/sidebar/PageHeaderPanel.cxx b/sw/source/uibase/sidebar/PageHeaderPanel.cxx
index b5206aeec426..7bd73b01cdd1 100644
--- a/sw/source/uibase/sidebar/PageHeaderPanel.cxx
+++ b/sw/source/uibase/sidebar/PageHeaderPanel.cxx
@@ -25,12 +25,14 @@
 #include <svx/svxids.hrc>
 #include <svx/dlgutil.hxx>
 #include <svx/rulritem.hxx>
+#include <svx/svdtrans.hxx>
 #include "PageHeaderPanel.hxx"
 #include <sfx2/sidebar/ControlFactory.hxx>
 #include <sfx2/dispatch.hxx>
 #include <sfx2/bindings.hxx>
 #include <sfx2/viewsh.hxx>
 #include <sfx2/objsh.hxx>
+#include <uitool.hxx>
 #include <cmdid.h>
 
 namespace sw { namespace sidebar{
@@ -69,8 +71,11 @@ PageHeaderPanel::PageHeaderPanel(
 {
     get(mpHeaderToggle, "headertoggle");
     get(mpHeaderSpacingLB, "spacingpreset");
+    FieldUnit eMetric = ::GetDfltMetric(false);
+    mpHeaderSpacingLB->Init(IsInch(eMetric) ? SpacingType::SPACING_INCH : SpacingType::SPACING_CM);
     get(mpHeaderLayoutLB, "samecontentLB");
     get(mpHeaderMarginPresetLB, "headermarginpreset");
+    mpHeaderMarginPresetLB->Init(IsInch(eMetric) ? SpacingType::MARGINS_INCH : SpacingType::MARGINS_CM);
     get(mpCustomEntry, "customlabel");
 
     Initialize();
diff --git a/sw/source/uibase/sidebar/WrapPropertyPanel.cxx b/sw/source/uibase/sidebar/WrapPropertyPanel.cxx
index 0d6e2623748c..c51d4f7844a1 100644
--- a/sw/source/uibase/sidebar/WrapPropertyPanel.cxx
+++ b/sw/source/uibase/sidebar/WrapPropertyPanel.cxx
@@ -22,6 +22,7 @@
 #include <cmdid.h>
 #include <swtypes.hxx>
 #include <svx/svxids.hrc>
+#include <svx/svdtrans.hxx>
 #include <sfx2/bindings.hxx>
 #include <sfx2/dispatch.hxx>
 #include <sfx2/sidebar/ControlFactory.hxx>
@@ -33,6 +34,7 @@
 #include <editeng/lrspitem.hxx>
 #include <editeng/ulspitem.hxx>
 #include <hintids.hxx>
+#include <uitool.hxx>
 #include <com/sun/star/lang/IllegalArgumentException.hpp>
 
 const char UNO_WRAPOFF[] = ".uno:WrapOff";
@@ -96,6 +98,8 @@ WrapPropertyPanel::WrapPropertyPanel(
     get(mpEnableContour, "enablecontour");
     get(mpEditContour, "editcontour");
     get(mpSpacingLB, "spacingLB");
+    FieldUnit eMetric = ::GetDfltMetric(false);
+    mpSpacingLB->Init(IsInch(eMetric) ? SpacingType::SPACING_INCH : SpacingType::SPACING_CM);
     get(mpCustomEntry, "customlabel");
 
     Initialize();
diff --git a/sw/uiconfig/swriter/ui/pageformatpanel.ui b/sw/uiconfig/swriter/ui/pageformatpanel.ui
index 579db0800223..5dc85d0b78e5 100644
--- a/sw/uiconfig/swriter/ui/pageformatpanel.ui
+++ b/sw/uiconfig/swriter/ui/pageformatpanel.ui
@@ -139,16 +139,6 @@
           <object class="GtkComboBoxText" id="marginLB">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
-            <items>
-              <item translatable="yes" context="pageformatpanel|marginLB">None</item>
-              <item translatable="yes" context="pageformatpanel|marginLB">Narrow</item>
-              <item translatable="yes" context="pageformatpanel|marginLB">Moderate</item>
-              <item translatable="yes" context="pageformatpanel|marginLB">Normal 0.75"</item>
-              <item translatable="yes" context="pageformatpanel|marginLB">Normal 1"</item>
-              <item translatable="yes" context="pageformatpanel|marginLB">Normal 1.25"</item>
-              <item translatable="yes" context="pageformatpanel|marginLB">Wide</item>
-              <item translatable="yes" context="pageformatpanel|marginLB">Mirrored</item>
-            </items>
           </object>
           <packing>
             <property name="left_attach">1</property>


More information about the Libreoffice-commits mailing list