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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Thu Feb 7 17:19:20 UTC 2019


 basctl/source/dlged/managelang.cxx             |  121 ++++++++++++------------
 basctl/source/inc/managelang.hxx               |   23 ++--
 basctl/uiconfig/basicide/ui/defaultlanguage.ui |  126 ++++++++++++++++++++++---
 include/svx/langbox.hxx                        |    3 
 svx/source/dialog/langbox.cxx                  |    5 
 5 files changed, 195 insertions(+), 83 deletions(-)

New commits:
commit 85fc36b9e181c99c6033c99d70cb9066aac0687a
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Thu Feb 7 15:44:51 2019 +0000
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Thu Feb 7 18:18:54 2019 +0100

    weld ManageLanguageDialog
    
    Change-Id: I03dfa49f4a8b269408d9037feb9c5c984f6c3c52
    Reviewed-on: https://gerrit.libreoffice.org/67511
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/basctl/source/dlged/managelang.cxx b/basctl/source/dlged/managelang.cxx
index e3a9021824ff..81a74b030f71 100644
--- a/basctl/source/dlged/managelang.cxx
+++ b/basctl/source/dlged/managelang.cxx
@@ -29,6 +29,7 @@
 #include <com/sun/star/i18n/Boundary.hpp>
 #include <com/sun/star/i18n/WordType.hpp>
 #include <com/sun/star/i18n/XBreakIterator.hpp>
+#include <comphelper/sequence.hxx>
 #include <editeng/unolingu.hxx>
 #include <sfx2/bindings.hxx>
 #include <svtools/langtab.hxx>
@@ -146,13 +147,13 @@ void ManageLanguageDialog::ClearLanguageBox()
 
 IMPL_LINK_NOARG(ManageLanguageDialog, AddHdl, Button*, void)
 {
-    VclPtr< SetDefaultLanguageDialog > pDlg = VclPtr<SetDefaultLanguageDialog>::Create(this, m_xLocalizationMgr);
-    pDlg->StartExecuteAsync([pDlg,this](sal_Int32 nResult)
+    std::shared_ptr<SetDefaultLanguageDialog> xDlg(new SetDefaultLanguageDialog(GetFrameWeld(), m_xLocalizationMgr));
+    weld::DialogController::runAsync(xDlg, [xDlg,this](sal_Int32 nResult)
         {
             if (!nResult )
                 return;
             // add new locales
-            Sequence< Locale > aLocaleSeq = pDlg->GetLocales();
+            Sequence< Locale > aLocaleSeq = xDlg->GetLocales();
             m_xLocalizationMgr->handleAddLocales( aLocaleSeq );
             // update listbox
             ClearLanguageBox();
@@ -224,31 +225,34 @@ IMPL_LINK_NOARG(ManageLanguageDialog, SelectHdl, ListBox&, void)
 
 // class SetDefaultLanguageDialog -----------------------------------------------
 
-SetDefaultLanguageDialog::SetDefaultLanguageDialog(vcl::Window* pParent, std::shared_ptr<LocalizationMgr> const & xLMgr)
-    : ModalDialog(pParent, "DefaultLanguageDialog", "modules/BasicIDE/ui/defaultlanguage.ui")
-    , m_pCheckLangLB(nullptr)
+SetDefaultLanguageDialog::SetDefaultLanguageDialog(weld::Window* pParent, std::shared_ptr<LocalizationMgr> const & xLMgr)
+    : GenericDialogController(pParent, "modules/BasicIDE/ui/defaultlanguage.ui", "DefaultLanguageDialog")
     , m_xLocalizationMgr(xLMgr)
+    , m_xLanguageFT(m_xBuilder->weld_label("defaultlabel"))
+    , m_xLanguageLB(m_xBuilder->weld_tree_view("entries"))
+    , m_xCheckLangFT(m_xBuilder->weld_label("checkedlabel"))
+    , m_xCheckLangLB(m_xBuilder->weld_tree_view("checkedentries"))
+    , m_xDefinedFT(m_xBuilder->weld_label("defined"))
+    , m_xAddedFT(m_xBuilder->weld_label("added"))
+    , m_xAltTitle(m_xBuilder->weld_label("alttitle"))
+    , m_xLanguageCB(new LanguageBox(m_xBuilder->weld_combo_box("hidden")))
 {
-    get(m_pLanguageLB, "entries");
-    get(m_pCheckLangLB, "checkedentries");
-    get(m_pDefinedFT, "defined");
-    get(m_pAddedFT, "added");
-    get(m_pLanguageFT, "defaultlabel");
-    get(m_pCheckLangFT, "checkedlabel");
-
-    m_pLanguageLB->set_height_request(m_pLanguageLB->GetTextHeight() * 10);
-    m_pCheckLangLB->set_height_request(m_pCheckLangLB->GetTextHeight() * 10);
+    m_xLanguageLB->set_size_request(-1, m_xLanguageLB->get_height_rows(10));
+    m_xCheckLangLB->set_size_request(-1, m_xCheckLangLB->get_height_rows(10));
+    std::vector<int> aWidths;
+    aWidths.push_back(m_xCheckLangLB->get_approximate_digit_width() * 3 + 6);
+    m_xCheckLangLB->set_column_fixed_widths(aWidths);
 
     if (m_xLocalizationMgr->isLibraryLocalized())
     {
         // change to "Add Interface Language" mode
-        m_pLanguageLB->Hide();
-        m_pCheckLangLB->Show();
-        SetText(get<FixedText>("alttitle")->GetText());
-        m_pLanguageFT->Hide();
-        m_pCheckLangFT->Show();
-        m_pDefinedFT->Hide();
-        m_pAddedFT->Show();
+        m_xLanguageLB->set_visible(false);
+        m_xCheckLangLB->set_visible(true);
+        m_xDialog->set_title(m_xAltTitle->get_label());
+        m_xLanguageFT->set_visible(false);
+        m_xCheckLangFT->set_visible(true);
+        m_xDefinedFT->set_visible(false);
+        m_xAddedFT->set_visible(true);
     }
 
     FillLanguageBox();
@@ -256,72 +260,73 @@ SetDefaultLanguageDialog::SetDefaultLanguageDialog(vcl::Window* pParent, std::sh
 
 SetDefaultLanguageDialog::~SetDefaultLanguageDialog()
 {
-    disposeOnce();
-}
-
-void SetDefaultLanguageDialog::dispose()
-{
-    m_pLanguageFT.clear();
-    m_pLanguageLB.clear();
-    m_pCheckLangFT.clear();
-    m_pCheckLangLB.clear();
-    m_pDefinedFT.clear();
-    m_pAddedFT.clear();
-    ModalDialog::dispose();
 }
 
 void SetDefaultLanguageDialog::FillLanguageBox()
 {
     // fill list with all languages
-    m_pLanguageLB->SetLanguageList( SvxLanguageListFlags::ALL, false );
+    m_xLanguageCB->SetLanguageList(SvxLanguageListFlags::ALL, false);
 
-    if ( m_xLocalizationMgr->isLibraryLocalized() )
+    if (m_xLocalizationMgr->isLibraryLocalized())
     {
         // remove the already localized languages
         Sequence< Locale > aLocaleSeq = m_xLocalizationMgr->getStringResourceManager()->getLocales();
         const Locale* pLocale = aLocaleSeq.getConstArray();
         const sal_Int32 nCountLoc = aLocaleSeq.getLength();
         for ( sal_Int32 i = 0;  i < nCountLoc;  ++i )
-            m_pLanguageLB->RemoveLanguage( LanguageTag::convertToLanguageType( pLocale[i] ) );
+            m_xLanguageCB->remove_id(LanguageTag::convertToLanguageType(pLocale[i]));
 
         // fill checklistbox if not in default mode
-        const sal_Int32 nCountLang = m_pLanguageLB->GetEntryCount();
-        for ( sal_Int32 j = 0;  j < nCountLang;  ++j )
+        const sal_Int32 nCountLang = m_xLanguageCB->get_count();
+        for (sal_Int32 j = 0;  j < nCountLang; ++j)
         {
-            m_pCheckLangLB->InsertEntry(
-                m_pLanguageLB->GetEntry(j), LISTBOX_APPEND, m_pLanguageLB->GetEntryData(j) );
+            LanguageType eLang = m_xLanguageCB->get_id(j);
+            m_xCheckLangLB->insert(nullptr, -1, nullptr, nullptr, nullptr,
+                                   nullptr, nullptr, false);
+            const int nRow = m_xCheckLangLB->n_children() - 1;
+            m_xCheckLangLB->set_toggle(nRow, false, 0);
+            m_xCheckLangLB->set_text(nRow, m_xLanguageCB->get_text(j), 1);
+            m_xCheckLangLB->set_id(nRow, OUString::number(eLang.get()));
         }
-        m_pLanguageLB = nullptr;
+        m_xLanguageCB.reset();
+        m_xLanguageLB.reset();
     }
     else
+    {
+        const sal_Int32 nCountLang = m_xLanguageCB->get_count();
+        for (sal_Int32 j = 0;  j < nCountLang; ++j)
+        {
+            LanguageType eLang = m_xLanguageCB->get_id(j);
+            m_xLanguageLB->append(OUString::number(eLang.get()), m_xLanguageCB->get_text(j));
+        }
+        m_xLanguageCB.reset();
+
         // preselect current UI language
-        m_pLanguageLB->SelectLanguage( Application::GetSettings().GetUILanguageTag().getLanguageType() );
+        m_xLanguageLB->select_id(OUString::number(Application::GetSettings().GetUILanguageTag().getLanguageType().get()));
+    }
 }
 
 Sequence< Locale > SetDefaultLanguageDialog::GetLocales() const
 {
     bool bNotLocalized = !m_xLocalizationMgr->isLibraryLocalized();
-    sal_Int32 nSize = bNotLocalized ? 1 : m_pCheckLangLB->GetCheckedEntryCount();
-    Sequence< Locale > aLocaleSeq( nSize );
-    if ( bNotLocalized )
+    if (bNotLocalized)
     {
-        aLocaleSeq[0] = LanguageTag( m_pLanguageLB->GetSelectedLanguage() ).getLocale();
+        LanguageType eType = LanguageType(m_xLanguageLB->get_selected_id().toUInt32());
+        Sequence<Locale> aLocaleSeq(1);
+        aLocaleSeq[0] = LanguageTag(eType).getLocale();
+        return aLocaleSeq;
     }
-    else
+    std::vector<Locale> aLocaleSeq;
+    const sal_Int32 nCount = m_xCheckLangLB->n_children();
+    for (sal_Int32 i = 0; i < nCount; ++i)
     {
-        const sal_Int32 nCount = m_pCheckLangLB->GetEntryCount();
-        sal_Int32 j = 0;
-        for ( sal_Int32 i = 0; i < nCount; ++i )
+        if (m_xCheckLangLB->get_toggle(i, 0))
         {
-            if ( m_pCheckLangLB->IsChecked(i) )
-            {
-                LanguageType eType = LanguageType( reinterpret_cast<sal_uLong>(m_pCheckLangLB->GetEntryData(i)) );
-                aLocaleSeq[j++] = LanguageTag::convertToLocale( eType );
-            }
+            LanguageType eType = LanguageType(m_xCheckLangLB->get_id(i).toUInt32());
+            aLocaleSeq.push_back(LanguageTag::convertToLocale(eType));
         }
-        DBG_ASSERT( nSize == j, "SetDefaultLanguageDialog::GetLocales(): invalid indexes" );
     }
-    return aLocaleSeq;
+    return comphelper::containerToSequence(aLocaleSeq);
 }
 
 } // namespace basctl
diff --git a/basctl/source/inc/managelang.hxx b/basctl/source/inc/managelang.hxx
index a965416254a1..243ea35605d9 100644
--- a/basctl/source/inc/managelang.hxx
+++ b/basctl/source/inc/managelang.hxx
@@ -25,7 +25,7 @@
 #include <vcl/dialog.hxx>
 #include <vcl/fixed.hxx>
 
-class SvxLanguageBox;
+class LanguageBox;
 
 namespace basctl
 {
@@ -74,24 +74,25 @@ public:
     virtual void dispose() override;
 };
 
-class SetDefaultLanguageDialog : public ModalDialog
+class SetDefaultLanguageDialog : public weld::GenericDialogController
 {
 private:
-    VclPtr<FixedText>          m_pLanguageFT;
-    VclPtr<SvxLanguageBox>     m_pLanguageLB;
-    VclPtr<FixedText>          m_pCheckLangFT;
-    VclPtr<SvxCheckListBox>    m_pCheckLangLB;
-    VclPtr<FixedText>          m_pDefinedFT;
-    VclPtr<FixedText>          m_pAddedFT;
-
     std::shared_ptr<LocalizationMgr> m_xLocalizationMgr;
 
     void                FillLanguageBox();
 
+    std::unique_ptr<weld::Label> m_xLanguageFT;
+    std::unique_ptr<weld::TreeView> m_xLanguageLB;
+    std::unique_ptr<weld::Label> m_xCheckLangFT;
+    std::unique_ptr<weld::TreeView> m_xCheckLangLB;
+    std::unique_ptr<weld::Label> m_xDefinedFT;
+    std::unique_ptr<weld::Label> m_xAddedFT;
+    std::unique_ptr<weld::Label> m_xAltTitle;
+    std::unique_ptr<::LanguageBox> m_xLanguageCB;
+
 public:
-    SetDefaultLanguageDialog(vcl::Window* pParent, std::shared_ptr<LocalizationMgr> const & xLMgr);
+    SetDefaultLanguageDialog(weld::Window* pParent, std::shared_ptr<LocalizationMgr> const & xLMgr);
     virtual ~SetDefaultLanguageDialog() override;
-    virtual void dispose() override;
 
     css::uno::Sequence< css::lang::Locale >   GetLocales() const;
 };
diff --git a/basctl/uiconfig/basicide/ui/defaultlanguage.ui b/basctl/uiconfig/basicide/ui/defaultlanguage.ui
index 943b912728aa..59215e56e48b 100644
--- a/basctl/uiconfig/basicide/ui/defaultlanguage.ui
+++ b/basctl/uiconfig/basicide/ui/defaultlanguage.ui
@@ -1,14 +1,37 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.18.3 -->
+<!-- Generated with glade 3.22.1 -->
 <interface domain="basctl">
   <requires lib="gtk+" version="3.18"/>
-  <requires lib="LibreOffice" version="1.0"/>
+  <object class="GtkTreeStore" id="liststore1">
+    <columns>
+      <!-- column-name check1 -->
+      <column type="gboolean"/>
+      <!-- column-name text -->
+      <column type="gchararray"/>
+      <!-- column-name id -->
+      <column type="gchararray"/>
+      <!-- column-name checkvis1 -->
+      <column type="gboolean"/>
+    </columns>
+  </object>
+  <object class="GtkTreeStore" id="liststore2">
+    <columns>
+      <!-- column-name text -->
+      <column type="gchararray"/>
+      <!-- column-name id -->
+      <column type="gchararray"/>
+    </columns>
+  </object>
   <object class="GtkDialog" id="DefaultLanguageDialog">
     <property name="can_focus">False</property>
     <property name="border_width">6</property>
     <property name="title" translatable="yes" context="defaultlanguage|DefaultLanguageDialog">Set Default User Interface Language</property>
     <property name="resizable">False</property>
+    <property name="modal">True</property>
     <property name="type_hint">dialog</property>
+    <child>
+      <placeholder/>
+    </child>
     <child internal-child="vbox">
       <object class="GtkBox" id="dialog-vbox1">
         <property name="can_focus">False</property>
@@ -89,10 +112,10 @@
                   <object class="GtkLabel" id="defaultlabel">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
                     <property name="label" translatable="yes" context="defaultlanguage|defaultlabel">Default language:</property>
                     <property name="use_underline">True</property>
-                    <property name="mnemonic_widget">entries:border</property>
+                    <property name="mnemonic_widget">entries</property>
+                    <property name="xalign">0</property>
                   </object>
                   <packing>
                     <property name="left_attach">0</property>
@@ -100,12 +123,40 @@
                   </packing>
                 </child>
                 <child>
-                  <object class="svxcorelo-SvxLanguageBox" id="entries:border">
+                  <object class="GtkScrolledWindow">
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
                     <property name="hexpand">True</property>
                     <property name="vexpand">True</property>
-                    <property name="dropdown">False</property>
+                    <property name="shadow_type">in</property>
+                    <child>
+                      <object class="GtkTreeView" id="entries">
+                        <property name="width_request">-1</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">True</property>
+                        <property name="hexpand">True</property>
+                        <property name="vexpand">True</property>
+                        <property name="model">liststore2</property>
+                        <property name="headers_visible">False</property>
+                        <property name="search_column">1</property>
+                        <property name="enable_tree_lines">True</property>
+                        <child internal-child="selection">
+                          <object class="GtkTreeSelection" id="Macro Library List-selection1"/>
+                        </child>
+                        <child>
+                          <object class="GtkTreeViewColumn" id="treeviewcolumn3">
+                            <property name="spacing">6</property>
+                            <child>
+                              <object class="GtkCellRendererText" id="cellrenderertext2"/>
+                              <attributes>
+                                <attribute name="text">0</attribute>
+                              </attributes>
+                            </child>
+                          </object>
+                        </child>
+                      </object>
+                    </child>
                   </object>
                   <packing>
                     <property name="left_attach">0</property>
@@ -113,13 +164,44 @@
                   </packing>
                 </child>
                 <child>
-                  <object class="svxcorelo-SvxCheckListBox" id="checkedentries:border">
+                  <object class="GtkScrolledWindow">
                     <property name="can_focus">True</property>
-                    <property name="no_show_all">True</property>
                     <property name="hexpand">True</property>
                     <property name="vexpand">True</property>
-                    <child internal-child="selection">
-                      <object class="GtkTreeSelection" id="Check List Box-selection1"/>
+                    <property name="shadow_type">in</property>
+                    <child>
+                      <object class="GtkTreeView" id="checkedentries">
+                        <property name="width_request">-1</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">True</property>
+                        <property name="hexpand">True</property>
+                        <property name="vexpand">True</property>
+                        <property name="model">liststore1</property>
+                        <property name="headers_visible">False</property>
+                        <property name="search_column">1</property>
+                        <property name="enable_tree_lines">True</property>
+                        <child internal-child="selection">
+                          <object class="GtkTreeSelection" id="Macro Library List-selection2"/>
+                        </child>
+                        <child>
+                          <object class="GtkTreeViewColumn" id="treeviewcolumn2">
+                            <property name="spacing">6</property>
+                            <child>
+                              <object class="GtkCellRendererToggle" id="cellrenderer5"/>
+                              <attributes>
+                                <attribute name="visible">3</attribute>
+                                <attribute name="active">0</attribute>
+                              </attributes>
+                            </child>
+                            <child>
+                              <object class="GtkCellRendererText" id="cellrenderertext1"/>
+                              <attributes>
+                                <attribute name="text">1</attribute>
+                              </attributes>
+                            </child>
+                          </object>
+                        </child>
+                      </object>
                     </child>
                   </object>
                   <packing>
@@ -131,16 +213,32 @@
                   <object class="GtkLabel" id="checkedlabel">
                     <property name="can_focus">False</property>
                     <property name="no_show_all">True</property>
-                    <property name="xalign">0</property>
                     <property name="label" translatable="yes" context="defaultlanguage|checkedlabel">Available languages:</property>
                     <property name="use_underline">True</property>
-                    <property name="mnemonic_widget">checkedentries:border</property>
+                    <property name="mnemonic_widget">checkedentries</property>
+                    <property name="xalign">0</property>
                   </object>
                   <packing>
                     <property name="left_attach">0</property>
                     <property name="top_attach">1</property>
                   </packing>
                 </child>
+                <child>
+                  <object class="GtkComboBoxText" id="hidden">
+                    <property name="can_focus">False</property>
+                    <property name="no_show_all">True</property>
+                    <property name="has_entry">True</property>
+                    <child internal-child="entry">
+                      <object class="GtkEntry">
+                        <property name="can_focus">False</property>
+                      </object>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="left_attach">0</property>
+                    <property name="top_attach">4</property>
+                  </packing>
+                </child>
               </object>
               <packing>
                 <property name="left_attach">0</property>
@@ -151,11 +249,11 @@
               <object class="GtkLabel" id="defined">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <property name="xalign">0</property>
                 <property name="label" translatable="yes" context="defaultlanguage|defined">Select a language to define the default user interface language. All currently present strings will be assigned to the resources created for the selected language.</property>
                 <property name="wrap">True</property>
                 <property name="wrap_mode">word-char</property>
                 <property name="max_width_chars">72</property>
+                <property name="xalign">0</property>
               </object>
               <packing>
                 <property name="left_attach">0</property>
@@ -166,11 +264,11 @@
               <object class="GtkLabel" id="added">
                 <property name="can_focus">False</property>
                 <property name="no_show_all">True</property>
-                <property name="xalign">0</property>
                 <property name="label" translatable="yes" context="defaultlanguage|added">Select languages to be added. Resources for these languages will be created in the library. Strings of the current default user interface language will be copied to these new resources by default.</property>
                 <property name="wrap">True</property>
                 <property name="wrap_mode">word-char</property>
                 <property name="max_width_chars">72</property>
+                <property name="xalign">0</property>
               </object>
               <packing>
                 <property name="left_attach">0</property>
diff --git a/include/svx/langbox.hxx b/include/svx/langbox.hxx
index 7c94d60eaafd..d707f84a6052 100644
--- a/include/svx/langbox.hxx
+++ b/include/svx/langbox.hxx
@@ -174,10 +174,13 @@ public:
     bool get_visible() const { return m_xControl->get_visible(); }
     LanguageType get_active_id() const;
     int find_id(const LanguageType eLangType) const;
+    LanguageType get_id(int nPos) const;
     void set_id(int nPos, const LanguageType eLangType);
     void remove_id(const LanguageType eLangType);
     void append(const LanguageType eLangType, const OUString& rStr);
     int find_text(const OUString& rStr) const { return m_xControl->find_text(rStr); }
+    OUString get_text(int nPos) const { return m_xControl->get_text(nPos); }
+    int get_count() const { return m_xControl->get_count(); }
     const weld::ComboBox* get_widget() const { return m_xControl.get(); }
 };
 
diff --git a/svx/source/dialog/langbox.cxx b/svx/source/dialog/langbox.cxx
index ba244f38e4f6..8ca6689381b7 100644
--- a/svx/source/dialog/langbox.cxx
+++ b/svx/source/dialog/langbox.cxx
@@ -477,6 +477,11 @@ void LanguageBox::set_id(int pos, const LanguageType eLangType)
     m_xControl->set_id(pos, OUString::number(static_cast<sal_uInt16>(eLangType)));
 }
 
+LanguageType LanguageBox::get_id(int pos) const
+{
+    return LanguageType(m_xControl->get_id(pos).toInt32());
+}
+
 void LanguageBox::remove_id(const LanguageType eLangType)
 {
     m_xControl->remove_id(OUString::number(static_cast<sal_uInt16>(eLangType)));


More information about the Libreoffice-commits mailing list