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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Oct 10 19:24:15 UTC 2018


 cui/source/dialogs/showcols.cxx  |   37 ++++++++++-----------------
 cui/source/factory/dlgfact.cxx   |   15 ++++++-----
 cui/source/factory/dlgfact.hxx   |   13 +++++++--
 cui/source/inc/showcols.hxx      |   19 ++++----------
 cui/uiconfig/ui/showcoldialog.ui |   52 +++++++++++++++++++++++++++++++++------
 include/svx/svxdlg.hxx           |    2 -
 svx/source/fmcomp/fmgridcl.cxx   |    2 -
 7 files changed, 86 insertions(+), 54 deletions(-)

New commits:
commit ddc44ac1773f00c90922216d7d3ba2cc0d230a7b
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Wed Oct 10 17:21:56 2018 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Wed Oct 10 21:23:48 2018 +0200

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

diff --git a/cui/source/dialogs/showcols.cxx b/cui/source/dialogs/showcols.cxx
index 7c7f7af3a081..66ee00b34b9c 100644
--- a/cui/source/dialogs/showcols.cxx
+++ b/cui/source/dialogs/showcols.cxx
@@ -26,38 +26,30 @@
 #define CUIFM_PROP_HIDDEN "Hidden"
 #define CUIFM_PROP_LABEL  "Label"
 
-FmShowColsDialog::FmShowColsDialog(vcl::Window* pParent)
-    : ModalDialog(pParent, "ShowColDialog", "cui/ui/showcoldialog.ui")
+FmShowColsDialog::FmShowColsDialog(weld::Window* pParent)
+    : GenericDialogController(pParent, "cui/ui/showcoldialog.ui", "ShowColDialog")
+    , m_xList(m_xBuilder->weld_tree_view("treeview"))
+    , m_xOK(m_xBuilder->weld_button("ok"))
 {
-    get(m_pOK, "ok");
-    get(m_pList, "treeview");
-    m_pList->set_height_request(m_pList->GetTextHeight() * 8);
-    m_pList->set_width_request(m_pList->approximate_char_width() * 56);
-    m_pList->EnableMultiSelection(true);
-    m_pOK->SetClickHdl( LINK( this, FmShowColsDialog, OnClickedOk ) );
+    m_xList->set_size_request(m_xList->get_approximate_digit_width() * 40, m_xList->get_height_rows(8));
+    m_xList->set_selection_mode(true);
+    m_xOK->connect_clicked(LINK(this, FmShowColsDialog, OnClickedOk));
 }
 
 FmShowColsDialog::~FmShowColsDialog()
 {
-    disposeOnce();
 }
 
-void FmShowColsDialog::dispose()
-{
-    m_pList.clear();
-    m_pOK.clear();
-    ModalDialog::dispose();
-}
-
-IMPL_LINK_NOARG(FmShowColsDialog, OnClickedOk, Button*, void)
+IMPL_LINK_NOARG(FmShowColsDialog, OnClickedOk, weld::Button&, void)
 {
     DBG_ASSERT(m_xColumns.is(), "FmShowColsDialog::OnClickedOk : you should call SetColumns before executing the dialog !");
     if (m_xColumns.is())
     {
         css::uno::Reference< css::beans::XPropertySet > xCol;
-        for (sal_Int32 i=0; i < m_pList->GetSelectedEntryCount(); ++i)
+        auto nSelectedRows = m_xList->get_selected_rows();
+        for (auto i : nSelectedRows)
         {
-            m_xColumns->getByIndex(sal::static_int_cast<sal_Int32>(reinterpret_cast<sal_uIntPtr>(m_pList->GetEntryData(m_pList->GetSelectedEntryPos(i))))) >>= xCol;
+            m_xColumns->getByIndex(m_xList->get_id(i).toInt32()) >>= xCol;
             if (xCol.is())
             {
                 try
@@ -72,10 +64,9 @@ IMPL_LINK_NOARG(FmShowColsDialog, OnClickedOk, Button*, void)
         }
     }
 
-    EndDialog(RET_OK);
+    m_xDialog->response(RET_OK);
 }
 
-
 void FmShowColsDialog::SetColumns(const css::uno::Reference< css::container::XIndexContainer>& xCols)
 {
     DBG_ASSERT(xCols.is(), "FmShowColsDialog::SetColumns : invalid columns !");
@@ -83,7 +74,7 @@ void FmShowColsDialog::SetColumns(const css::uno::Reference< css::container::XIn
         return;
     m_xColumns = xCols.get();
 
-    m_pList->Clear();
+    m_xList->clear();
 
     css::uno::Reference< css::beans::XPropertySet>  xCurCol;
     OUString sCurName;
@@ -108,7 +99,7 @@ void FmShowColsDialog::SetColumns(const css::uno::Reference< css::container::XIn
 
         // if the col is hidden, put it into the list
         if (bIsHidden)
-            m_pList->SetEntryData( m_pList->InsertEntry(sCurName), reinterpret_cast<void*>(static_cast<sal_Int64>(i)) );
+            m_xList->append(OUString::number(i), sCurName);
     }
 }
 
diff --git a/cui/source/factory/dlgfact.cxx b/cui/source/factory/dlgfact.cxx
index a49f2b240952..be648afb4361 100644
--- a/cui/source/factory/dlgfact.cxx
+++ b/cui/source/factory/dlgfact.cxx
@@ -114,7 +114,11 @@ short AbstractSvxDistributeDialog_Impl::Execute()
 }
 
 IMPL_ABSTDLG_BASE(AbstractHangulHanjaConversionDialog_Impl);
-IMPL_ABSTDLG_BASE(AbstractFmShowColsDialog_Impl);
+
+short AbstractFmShowColsDialog_Impl::Execute()
+{
+    return m_xDlg->run();
+}
 
 short AbstractHyphenWordDialog_Impl::Execute()
 {
@@ -540,9 +544,9 @@ SotClipboardFormatId AbstractPasteDialog_Impl::GetFormat( const TransferableData
     return m_xDlg->GetFormat(aHelper);
 }
 
-void  AbstractFmShowColsDialog_Impl::SetColumns(const ::Reference< css::container::XIndexContainer>& xCols)
+void AbstractFmShowColsDialog_Impl::SetColumns(const ::Reference< css::container::XIndexContainer>& xCols)
 {
-     pDlg->SetColumns(xCols);
+     m_xDlg->SetColumns(xCols);
 }
 
 void AbstractSvxZoomDialog_Impl::SetLimits( sal_uInt16 nMin, sal_uInt16 nMax )
@@ -1085,10 +1089,9 @@ VclPtr<AbstractHyphenWordDialog> AbstractDialogFactory_Impl::CreateHyphenWordDia
     return VclPtr<AbstractHyphenWordDialog_Impl>::Create(o3tl::make_unique<SvxHyphenWordDialog>(rWord, nLang, pParent, xHyphen, pWrapper));
 }
 
-VclPtr<AbstractFmShowColsDialog> AbstractDialogFactory_Impl::CreateFmShowColsDialog()
+VclPtr<AbstractFmShowColsDialog> AbstractDialogFactory_Impl::CreateFmShowColsDialog(weld::Window* pParent)
 {
-    VclPtrInstance<FmShowColsDialog> pDlg( nullptr );
-    return VclPtr<AbstractFmShowColsDialog_Impl>::Create( pDlg );
+    return VclPtr<AbstractFmShowColsDialog_Impl>::Create(o3tl::make_unique<FmShowColsDialog>(pParent));
 }
 
 VclPtr<AbstractSvxZoomDialog> AbstractDialogFactory_Impl::CreateSvxZoomDialog(weld::Window* pParent, const SfxItemSet& rCoreSet)
diff --git a/cui/source/factory/dlgfact.hxx b/cui/source/factory/dlgfact.hxx
index ba317dd531c8..bbf336099475 100644
--- a/cui/source/factory/dlgfact.hxx
+++ b/cui/source/factory/dlgfact.hxx
@@ -229,8 +229,15 @@ public:
 class FmShowColsDialog;
 class AbstractFmShowColsDialog_Impl : public AbstractFmShowColsDialog
 {
-    DECL_ABSTDLG_BASE(AbstractFmShowColsDialog_Impl,FmShowColsDialog)
-     virtual void   SetColumns(const css::uno::Reference< css::container::XIndexContainer>& xCols) override;
+protected:
+    std::unique_ptr<FmShowColsDialog> m_xDlg;
+public:
+    explicit AbstractFmShowColsDialog_Impl(std::unique_ptr<FmShowColsDialog> p)
+        : m_xDlg(std::move(p))
+    {
+    }
+    virtual short Execute() override;
+    virtual void SetColumns(const css::uno::Reference< css::container::XIndexContainer>& xCols) override;
 };
 
 class SvxZoomDialog;
@@ -724,7 +731,7 @@ public:
                                                 css::uno::Reference< css::linguistic2::XHyphenator >  &xHyphen,
                                                 SvxSpellWrapper* pWrapper) override;
 
-    virtual VclPtr<AbstractFmShowColsDialog> CreateFmShowColsDialog() override;
+    virtual VclPtr<AbstractFmShowColsDialog> CreateFmShowColsDialog(weld::Window* pParent) override;
     virtual VclPtr<AbstractSvxZoomDialog> CreateSvxZoomDialog(weld::Window* pParent, const SfxItemSet& rCoreSet) override;
    // add for SvxBorderBackgroundDlg
     virtual VclPtr<SfxAbstractTabDialog> CreateSvxBorderBackgroundDlg(
diff --git a/cui/source/inc/showcols.hxx b/cui/source/inc/showcols.hxx
index d3135f303a80..f98a7370bbd2 100644
--- a/cui/source/inc/showcols.hxx
+++ b/cui/source/inc/showcols.hxx
@@ -20,35 +20,28 @@
 #ifndef INCLUDED_CUI_SOURCE_INC_SHOWCOLS_HXX
 #define INCLUDED_CUI_SOURCE_INC_SHOWCOLS_HXX
 
-#include <vcl/dialog.hxx>
-#include <vcl/lstbox.hxx>
-#include <vcl/fixed.hxx>
-
-#include <vcl/button.hxx>
 #include <com/sun/star/uno/Reference.hxx>
 #include <com/sun/star/container/XNameAccess.hpp>
 #include <com/sun/star/container/XIndexContainer.hpp>
-
+#include <vcl/weld.hxx>
 
 //  FmShowColsDialog
 
-
-class FmShowColsDialog final : public ModalDialog
+class FmShowColsDialog final : public weld::GenericDialogController
 {
-    VclPtr<ListBox>        m_pList;
-    VclPtr<OKButton>       m_pOK;
+    std::unique_ptr<weld::TreeView> m_xList;
+    std::unique_ptr<weld::Button> m_xOK;
 
     css::uno::Reference< css::container::XIndexAccess >   m_xColumns;
 
 public:
-    FmShowColsDialog(vcl::Window* pParent);
+    FmShowColsDialog(weld::Window* pParent);
     virtual ~FmShowColsDialog() override;
-    virtual void dispose() override;
 
     void SetColumns(const css::uno::Reference< css::container::XIndexContainer>& xCols);
 
 private:
-    DECL_LINK(OnClickedOk, Button*, void);
+    DECL_LINK(OnClickedOk, weld::Button&, void);
 };
 
 #endif // INCLUDED_CUI_SOURCE_INC_SHOWCOLS_HXX
diff --git a/cui/uiconfig/ui/showcoldialog.ui b/cui/uiconfig/ui/showcoldialog.ui
index dec22bb6b8ff..8d2d95199934 100644
--- a/cui/uiconfig/ui/showcoldialog.ui
+++ b/cui/uiconfig/ui/showcoldialog.ui
@@ -1,13 +1,27 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.18.3 -->
+<!-- Generated with glade 3.22.1 -->
 <interface domain="cui">
   <requires lib="gtk+" version="3.18"/>
+  <object class="GtkListStore" id="liststore2">
+    <columns>
+      <!-- column-name text -->
+      <column type="gchararray"/>
+      <!-- column-name id -->
+      <column type="gchararray"/>
+    </columns>
+  </object>
   <object class="GtkDialog" id="ShowColDialog">
     <property name="can_focus">False</property>
     <property name="border_width">6</property>
     <property name="title" translatable="yes" context="showcoldialog|ShowColDialog">Show Columns</property>
     <property name="resizable">False</property>
+    <property name="modal">True</property>
+    <property name="default_width">0</property>
+    <property name="default_height">0</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>
@@ -66,12 +80,12 @@
               <object class="GtkLabel" id="label1">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <property name="xalign">0</property>
                 <property name="label" translatable="yes" context="showcoldialog|label1">The following columns are currently hidden. Please mark the fields you want to show and choose OK.</property>
                 <property name="use_underline">True</property>
                 <property name="wrap">True</property>
-                <property name="mnemonic_widget">treeview:border</property>
+                <property name="mnemonic_widget">treeview</property>
                 <property name="max_width_chars">56</property>
+                <property name="xalign">0</property>
               </object>
               <packing>
                 <property name="left_attach">0</property>
@@ -79,13 +93,37 @@
               </packing>
             </child>
             <child>
-              <object class="GtkTreeView" id="treeview:border">
+              <object class="GtkScrolledWindow">
                 <property name="visible">True</property>
-                <property name="can_focus">True</property>
+                <property name="can_focus">False</property>
                 <property name="hexpand">True</property>
                 <property name="vexpand">True</property>
-                <child internal-child="selection">
-                  <object class="GtkTreeSelection" id="treeview-selection1"/>
+                <property name="shadow_type">in</property>
+                <child>
+                  <object class="GtkTreeView" id="treeview">
+                    <property name="visible">True</property>
+                    <property name="can_focus">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="headers_clickable">False</property>
+                    <property name="search_column">0</property>
+                    <property name="show_expanders">False</property>
+                    <child internal-child="selection">
+                      <object class="GtkTreeSelection" id="treeview-selection1"/>
+                    </child>
+                    <child>
+                      <object class="GtkTreeViewColumn" id="treeviewcolumn1">
+                        <child>
+                          <object class="GtkCellRendererText" id="cellrenderertext1"/>
+                          <attributes>
+                            <attribute name="text">0</attribute>
+                          </attributes>
+                        </child>
+                      </object>
+                    </child>
+                  </object>
                 </child>
               </object>
               <packing>
diff --git a/include/svx/svxdlg.hxx b/include/svx/svxdlg.hxx
index afef5d3ed97c..5e34bf61d165 100644
--- a/include/svx/svxdlg.hxx
+++ b/include/svx/svxdlg.hxx
@@ -345,7 +345,7 @@ public:
     virtual VclPtr<AbstractSvxDistributeDialog>    CreateSvxDistributeDialog(weld::Window* pParent,
                                             const SfxItemSet& rAttr)= 0;
 
-    virtual VclPtr<AbstractFmShowColsDialog> CreateFmShowColsDialog() = 0;
+    virtual VclPtr<AbstractFmShowColsDialog> CreateFmShowColsDialog(weld::Window* pParent) = 0;
 
     virtual VclPtr<AbstractSvxZoomDialog> CreateSvxZoomDialog(weld::Window* pParent, const SfxItemSet& rCoreSet) = 0;
 
diff --git a/svx/source/fmcomp/fmgridcl.cxx b/svx/source/fmcomp/fmgridcl.cxx
index 2a344282a2cb..dc793ef7773d 100644
--- a/svx/source/fmcomp/fmgridcl.cxx
+++ b/svx/source/fmcomp/fmgridcl.cxx
@@ -891,7 +891,7 @@ void FmGridHeader::PostExecuteColumnContextMenu(sal_uInt16 nColId, const PopupMe
     else if (sExecutionResult == "more")
     {
         SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
-        ScopedVclPtr<AbstractFmShowColsDialog> pDlg(pFact->CreateFmShowColsDialog());
+        ScopedVclPtr<AbstractFmShowColsDialog> pDlg(pFact->CreateFmShowColsDialog(GetFrameWeld()));
         pDlg->SetColumns(xCols);
         pDlg->Execute();
     }


More information about the Libreoffice-commits mailing list