[Libreoffice-commits] core.git: sc/source sc/uiconfig solenv/sanitizers

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Fri Dec 20 17:03:53 UTC 2019


 sc/source/ui/formdlg/dwfunctr.cxx        |  115 +++++++++++++------------------
 sc/source/ui/inc/dwfunctr.hxx            |   17 ++--
 sc/uiconfig/scalc/ui/functionpanel.ui    |   86 ++++++++++++++++++-----
 solenv/sanitizers/ui/modules/scalc.suppr |    4 -
 4 files changed, 127 insertions(+), 95 deletions(-)

New commits:
commit ddd1d219beb74f55eefbccc3ab8a8883dd0b4b69
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Fri Dec 20 13:21:13 2019 +0000
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Fri Dec 20 18:02:40 2019 +0100

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

diff --git a/sc/source/ui/formdlg/dwfunctr.cxx b/sc/source/ui/formdlg/dwfunctr.cxx
index f62eb242de05..dd7be33c9070 100644
--- a/sc/source/ui/formdlg/dwfunctr.cxx
+++ b/sc/source/ui/formdlg/dwfunctr.cxx
@@ -46,38 +46,31 @@
 #************************************************************************/
 
 ScFunctionWin::ScFunctionWin(vcl::Window* pParent, const css::uno::Reference<css::frame::XFrame> &rFrame)
-    : PanelLayout(pParent, "FunctionPanel", "modules/scalc/ui/functionpanel.ui", rFrame)
+    : PanelLayout(pParent, "FunctionPanel", "modules/scalc/ui/functionpanel.ui", rFrame, true)
+    , xCatBox(m_xBuilder->weld_combo_box("category"))
+    , xFuncList(m_xBuilder->weld_tree_view("funclist"))
+    , xInsertButton(m_xBuilder->weld_button("insert"))
+    , xFiFuncDesc(m_xBuilder->weld_label("funcdesc"))
     , xConfigListener(new comphelper::ConfigurationListener("/org.openoffice.Office.Calc/Formula/Syntax"))
     , xConfigChange(std::make_unique<EnglishFunctionNameChange>(xConfigListener, this))
     , pFuncDesc(nullptr)
 {
-    get(aCatBox, "category");
-    get(aFuncList, "funclist");
-    aFuncList->set_height_request(10 * aFuncList->GetTextHeight());
-    get(aInsertButton, "insert");
-    get(aFiFuncDesc, "funcdesc");
+    xFuncList->set_size_request(-1, xFuncList->get_height_rows(10));
 
     InitLRUList();
 
-    aFiFuncDesc->SetUpdateMode(true);
     nArgs=0;
-    aCatBox->SetDropDownLineCount(9);
-    vcl::Font aFont=aFiFuncDesc->GetFont();
-    aFont.SetColor(COL_BLACK);
-    aFiFuncDesc->SetFont(aFont);
-    aFiFuncDesc->SetBackground( GetBackground() );       //! never transparent?
-    aFiFuncDesc->set_height_request(5 * aFiFuncDesc->GetTextHeight());
+    xFiFuncDesc->set_size_request(-1, 5 * xFiFuncDesc->get_text_height());
 
-    Link<ListBox&,void> aLink=LINK( this, ScFunctionWin, SelHdl);
-    aCatBox->SetSelectHdl(aLink);
-    aFuncList->SetSelectHdl(aLink);
+    xCatBox->connect_changed(LINK( this, ScFunctionWin, SelComboHdl));
+    xFuncList->connect_changed(LINK( this, ScFunctionWin, SelTreeHdl));
 
-    aFuncList->SetDoubleClickHdl(LINK( this, ScFunctionWin, SetSelectionHdl));
-    aInsertButton->SetClickHdl(LINK( this, ScFunctionWin, SetSelectionClickHdl));
+    xFuncList->connect_row_activated(LINK( this, ScFunctionWin, SetRowActivatedHdl));
+    xInsertButton->connect_clicked(LINK( this, ScFunctionWin, SetSelectionClickHdl));
 
-    aCatBox->SelectEntryPos(0);
+    xCatBox->set_active(0);
 
-    SelHdl(*aCatBox);
+    SelComboHdl(*xCatBox);
 }
 
 /*************************************************************************
@@ -107,10 +100,10 @@ void ScFunctionWin::dispose()
         xConfigListener->dispose();
         xConfigListener.clear();
     }
-    aCatBox.clear();
-    aFuncList.clear();
-    aInsertButton.clear();
-    aFiFuncDesc.clear();
+    xCatBox.reset();
+    xFuncList.reset();
+    xInsertButton.reset();
+    xFiFuncDesc.reset();
     PanelLayout::dispose();
 }
 
@@ -133,9 +126,9 @@ void ScFunctionWin::InitLRUList()
     ScFunctionMgr* pFuncMgr = ScGlobal::GetStarCalcFunctionMgr();
     pFuncMgr->fillLastRecentlyUsedFunctions(aLRUList);
 
-    sal_Int32  nSelPos   = aCatBox->GetSelectedEntryPos();
+    sal_Int32 nSelPos  = xCatBox->get_active();
 
-    if(nSelPos == 0)
+    if (nSelPos == 0)
         UpdateFunctionList();
 }
 
@@ -178,25 +171,20 @@ void ScFunctionWin::UpdateLRUList()
 
 void ScFunctionWin::SetDescription()
 {
-    aFiFuncDesc->SetText( EMPTY_OUSTRING );
+    xFiFuncDesc->set_label(EMPTY_OUSTRING);
     const ScFuncDesc* pDesc =
-             static_cast<const ScFuncDesc*>(aFuncList->GetEntryData(
-                    aFuncList->GetSelectedEntryPos() ));
+             reinterpret_cast<const ScFuncDesc*>(xFuncList->get_selected_id().toInt64());
     if (pDesc)
     {
         pDesc->initArgumentInfo();      // full argument info is needed
 
-        OUStringBuffer aBuf(aFuncList->GetSelectedEntry());
+        OUStringBuffer aBuf(xFuncList->get_selected_text());
         aBuf.append(":\n\n");
         aBuf.append(pDesc->GetParamList());
         aBuf.append("\n\n");
         aBuf.append(*pDesc->mxFuncDesc);
 
-        aFiFuncDesc->SetText(aBuf.makeStringAndClear());
-        aFiFuncDesc->StateChanged(StateChangedType::Text);
-        aFiFuncDesc->Invalidate();
-        aFiFuncDesc->Update();
-
+        xFiFuncDesc->set_label(aBuf.makeStringAndClear());
     }
 }
 
@@ -216,12 +204,12 @@ void ScFunctionWin::SetDescription()
 
 void ScFunctionWin::UpdateFunctionList()
 {
-    sal_Int32  nSelPos   = aCatBox->GetSelectedEntryPos();
-    sal_Int32  nCategory = ( LISTBOX_ENTRY_NOTFOUND != nSelPos )
+    sal_Int32  nSelPos   = xCatBox->get_active();
+    sal_Int32  nCategory = ( -1 != nSelPos )
                             ? (nSelPos-1) : 0;
 
-    aFuncList->Clear();
-    aFuncList->SetUpdateMode( false );
+    xFuncList->clear();
+    xFuncList->freeze();
 
     if ( nSelPos > 0 )
     {
@@ -230,9 +218,7 @@ void ScFunctionWin::UpdateFunctionList()
         const ScFuncDesc* pDesc = pFuncMgr->First( nCategory );
         while ( pDesc )
         {
-            aFuncList->SetEntryData(
-                aFuncList->InsertEntry( *(pDesc->mxFuncName) ),
-                const_cast<ScFuncDesc *>(pDesc) );
+            xFuncList->append(OUString::number(reinterpret_cast<sal_Int64>(pDesc)), *(pDesc->mxFuncName));
             pDesc = pFuncMgr->Next();
         }
     }
@@ -241,20 +227,22 @@ void ScFunctionWin::UpdateFunctionList()
         for (const formula::IFunctionDescription* pDesc : aLRUList)
         {
             if (pDesc)
-                aFuncList->SetEntryData( aFuncList->InsertEntry( pDesc->getFunctionName()), const_cast<formula::IFunctionDescription *>(pDesc));
+            {
+                xFuncList->append(OUString::number(reinterpret_cast<sal_Int64>(pDesc)), pDesc->getFunctionName());
+            }
         }
     }
 
-    aFuncList->SetUpdateMode( true );
+    xFuncList->thaw();
 
-    if ( aFuncList->GetEntryCount() > 0 )
+    if (xFuncList->n_children() > 0)
     {
-        aFuncList->Enable();
-        aFuncList->SelectEntryPos( 0 );
+        xFuncList->set_sensitive(true);
+        xFuncList->select(0);
     }
     else
     {
-        aFuncList->Disable();
+        xFuncList->set_sensitive(false);
     }
 }
 
@@ -277,7 +265,7 @@ void ScFunctionWin::DoEnter()
 {
     OUString aFirstArgStr;
     OUStringBuffer aArgStr;
-    OUString aString=aFuncList->GetSelectedEntry();
+    OUString aString=xFuncList->get_selected_text();
     SfxViewShell* pCurSh = SfxViewShell::Current();
     nArgs=0;
 
@@ -293,13 +281,12 @@ void ScFunctionWin::DoEnter()
             // the above call can result in us being disposed
             if (OutputDevice::isDisposed())
                 return;
-            aString = "=" + aFuncList->GetSelectedEntry();
+            aString = "=" + xFuncList->get_selected_text();
             if (pHdl)
                 pHdl->ClearText();
         }
         const ScFuncDesc* pDesc =
-             static_cast<const ScFuncDesc*>(aFuncList->GetEntryData(
-                    aFuncList->GetSelectedEntryPos() ));
+             reinterpret_cast<const ScFuncDesc*>(xFuncList->get_selected_id().toInt64());
         if (pDesc)
         {
             pFuncDesc=pDesc;
@@ -338,7 +325,7 @@ void ScFunctionWin::DoEnter()
         {
             if (pHdl->GetEditString().isEmpty())
             {
-                aString = "=" + aFuncList->GetSelectedEntry();
+                aString = "=" + xFuncList->get_selected_text();
             }
             EditView *pEdView=pHdl->GetActiveView();
             if(pEdView!=nullptr) // @ needed because of crash during setting a name
@@ -386,18 +373,15 @@ void ScFunctionWin::DoEnter()
 #*
 #************************************************************************/
 
-IMPL_LINK( ScFunctionWin, SelHdl, ListBox&, rLb, void )
+IMPL_LINK_NOARG(ScFunctionWin, SelComboHdl, weld::ComboBox&, void)
 {
-    if (&rLb == aCatBox.get())
-    {
-        UpdateFunctionList();
-        SetDescription();
-    }
+    UpdateFunctionList();
+    SetDescription();
+}
 
-    if (&rLb == aFuncList.get())
-    {
-        SetDescription();
-    }
+IMPL_LINK_NOARG(ScFunctionWin, SelTreeHdl, weld::TreeView&, void)
+{
+    SetDescription();
 }
 
 /*************************************************************************
@@ -414,14 +398,15 @@ IMPL_LINK( ScFunctionWin, SelHdl, ListBox&, rLb, void )
 #*
 #************************************************************************/
 
-IMPL_LINK_NOARG( ScFunctionWin, SetSelectionClickHdl, Button*, void )
+IMPL_LINK_NOARG( ScFunctionWin, SetSelectionClickHdl, weld::Button&, void )
 {
     DoEnter();          // saves the input
 }
 
-IMPL_LINK_NOARG( ScFunctionWin, SetSelectionHdl, ListBox&, void )
+IMPL_LINK_NOARG( ScFunctionWin, SetRowActivatedHdl, weld::TreeView&, bool )
 {
     DoEnter();          // saves the input
+    return true;
 }
 
 void EnglishFunctionNameChange::setProperty(const css::uno::Any &rProperty)
diff --git a/sc/source/ui/inc/dwfunctr.hxx b/sc/source/ui/inc/dwfunctr.hxx
index 3bf7158f5df7..cf93ae88221a 100644
--- a/sc/source/ui/inc/dwfunctr.hxx
+++ b/sc/source/ui/inc/dwfunctr.hxx
@@ -20,8 +20,6 @@
 #define INCLUDED_SC_SOURCE_UI_INC_DWFUNCTR_HXX
 
 #include <comphelper/configurationlistener.hxx>
-#include <vcl/lstbox.hxx>
-#include <vcl/button.hxx>
 #include <svx/sidebar/PanelLayout.hxx>
 
 class ScFuncDesc;
@@ -46,11 +44,11 @@ class ScFunctionWin : public PanelLayout
 {
 
 private:
-    VclPtr<ListBox>     aCatBox;
-    VclPtr<ListBox>     aFuncList;
+    std::unique_ptr<weld::ComboBox> xCatBox;
+    std::unique_ptr<weld::TreeView> xFuncList;
+    std::unique_ptr<weld::Button> xInsertButton;
+    std::unique_ptr<weld::Label> xFiFuncDesc;
 
-    VclPtr<PushButton>  aInsertButton;
-    VclPtr<FixedText>   aFiFuncDesc;
     rtl::Reference<comphelper::ConfigurationListener> xConfigListener;
     std::unique_ptr<EnglishFunctionNameChange> xConfigChange;
     const ScFuncDesc*   pFuncDesc;
@@ -62,9 +60,10 @@ private:
     void            DoEnter();
     void            SetDescription();
 
-                    DECL_LINK( SetSelectionHdl, ListBox&, void );
-                    DECL_LINK( SetSelectionClickHdl, Button*, void );
-                    DECL_LINK( SelHdl, ListBox&, void );
+                    DECL_LINK( SetRowActivatedHdl, weld::TreeView&, bool );
+                    DECL_LINK( SetSelectionClickHdl, weld::Button&, void );
+                    DECL_LINK( SelComboHdl, weld::ComboBox&, void );
+                    DECL_LINK( SelTreeHdl, weld::TreeView&, void );
 
 public:
     ScFunctionWin(vcl::Window* pParent, const css::uno::Reference<css::frame::XFrame> &rFrame);
diff --git a/sc/uiconfig/scalc/ui/functionpanel.ui b/sc/uiconfig/scalc/ui/functionpanel.ui
index 2c8f2f290fd7..ef3935a51ed7 100644
--- a/sc/uiconfig/scalc/ui/functionpanel.ui
+++ b/sc/uiconfig/scalc/ui/functionpanel.ui
@@ -1,10 +1,25 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.20.0 -->
+<!-- Generated with glade 3.22.1 -->
 <interface domain="sc">
   <requires lib="gtk+" version="3.18"/>
+  <object class="GtkImage" id="image1">
+    <property name="visible">True</property>
+    <property name="can_focus">False</property>
+    <property name="icon_name">sc/res/fx.png</property>
+  </object>
+  <object class="GtkTreeStore" id="liststore1">
+    <columns>
+      <!-- column-name text -->
+      <column type="gchararray"/>
+      <!-- column-name id -->
+      <column type="gchararray"/>
+    </columns>
+  </object>
   <object class="GtkGrid" id="FunctionPanel">
     <property name="visible">True</property>
     <property name="can_focus">False</property>
+    <property name="hexpand">True</property>
+    <property name="vexpand">True</property>
     <property name="border_width">6</property>
     <child>
       <object class="GtkGrid">
@@ -83,15 +98,36 @@
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkTreeView" id="funclist:border">
-                    <property name="name">functions</property>
+                  <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="show_expanders">False</property>
-                    <child internal-child="selection">
-                      <object class="GtkTreeSelection"/>
+                    <property name="shadow_type">in</property>
+                    <child>
+                      <object class="GtkTreeView" id="funclist">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="vexpand">True</property>
+                        <property name="model">liststore1</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>
@@ -102,21 +138,38 @@
               </object>
               <packing>
                 <property name="resize">True</property>
+                <property name="shrink">True</property>
               </packing>
             </child>
             <child>
-              <object class="GtkLabel" id="funcdesc:border">
-                <property name="name">funcdesc</property>
-                <property name="width_request">0</property>
+              <object class="GtkScrolledWindow" id="funcscroll">
                 <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="label" translatable="yes" context="functionpanel|funcdesc">label</property>
-                <property name="wrap">True</property>
-                <property name="xalign">0</property>
-                <property name="yalign">0</property>
+                <property name="can_focus">True</property>
+                <property name="hscrollbar_policy">never</property>
+                <property name="vscrollbar_policy">never</property>
+                <property name="shadow_type">in</property>
+                <child>
+                  <object class="GtkViewport">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <child>
+                      <object class="GtkLabel" id="funcdesc">
+                        <property name="name">funcdesc</property>
+                        <property name="width_request">0</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="label" translatable="yes" context="functionpanel|funcdesc">label</property>
+                        <property name="wrap">True</property>
+                        <property name="xalign">0</property>
+                        <property name="yalign">0</property>
+                      </object>
+                    </child>
+                  </object>
+                </child>
               </object>
               <packing>
                 <property name="resize">False</property>
+                <property name="shrink">True</property>
               </packing>
             </child>
           </object>
@@ -132,9 +185,4 @@
       </packing>
     </child>
   </object>
-  <object class="GtkImage" id="image1">
-    <property name="visible">True</property>
-    <property name="can_focus">False</property>
-    <property name="pixbuf">sc/res/fx.png</property>
-  </object>
 </interface>
diff --git a/solenv/sanitizers/ui/modules/scalc.suppr b/solenv/sanitizers/ui/modules/scalc.suppr
index dd73f5f56d5e..41587fb489c4 100644
--- a/solenv/sanitizers/ui/modules/scalc.suppr
+++ b/solenv/sanitizers/ui/modules/scalc.suppr
@@ -79,8 +79,8 @@ sc/uiconfig/scalc/ui/externaldata.ui://GtkTreeView[@id='ranges'] no-labelled-by
 sc/uiconfig/scalc/ui/externaldata.ui://GtkLabel[@id='secondsft'] orphan-label
 sc/uiconfig/scalc/ui/fourieranalysisdialog.ui://GtkLabel[@id='error-message'] orphan-label
 sc/uiconfig/scalc/ui/functionpanel.ui://GtkComboBoxText[@id='category'] no-labelled-by
-sc/uiconfig/scalc/ui/functionpanel.ui://GtkTreeView[@id='funclist:border'] no-labelled-by
-sc/uiconfig/scalc/ui/functionpanel.ui://GtkLabel[@id='funcdesc:border'] orphan-label
+sc/uiconfig/scalc/ui/functionpanel.ui://GtkTreeView[@id='funclist'] no-labelled-by
+sc/uiconfig/scalc/ui/functionpanel.ui://GtkLabel[@id='funcdesc'] orphan-label
 sc/uiconfig/scalc/ui/groupbynumber.ui://GtkEntry[@id='edit_by'] no-labelled-by
 sc/uiconfig/scalc/ui/headerfootercontent.ui://GtkLabel[@id='labelFT_H_CUSTOM'] orphan-label
 sc/uiconfig/scalc/ui/headerfootercontent.ui://GtkLabel[@id='labelFT_F_CUSTOM'] orphan-label


More information about the Libreoffice-commits mailing list