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

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Fri Feb 19 14:56:51 UTC 2021


 svx/inc/pch/precompiled_svxcore.hxx |    3 +
 svx/source/stbctrls/pszctrl.cxx     |   55 ++++++++++++++++++++----------------
 2 files changed, 33 insertions(+), 25 deletions(-)

New commits:
commit a6f364433b0bd5e1d51c775ad10099004a20140b
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Fri Feb 19 12:22:33 2021 +0000
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Fri Feb 19 15:56:09 2021 +0100

    weld FunctionPopup_Impl
    
    Change-Id: I1489f545af75fc93cf37c4399217cd91ca464243
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111212
    Tested-by: Caolán McNamara <caolanm at redhat.com>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/svx/inc/pch/precompiled_svxcore.hxx b/svx/inc/pch/precompiled_svxcore.hxx
index 3af3a93cd751..de853a2a8359 100644
--- a/svx/inc/pch/precompiled_svxcore.hxx
+++ b/svx/inc/pch/precompiled_svxcore.hxx
@@ -13,7 +13,7 @@
  manual changes will be rewritten by the next run of update_pch.sh (which presumably
  also fixes all possible problems, so it's usually better to use it).
 
- Generated on 2021-02-05 16:11:24 using:
+ Generated on 2021-02-19 12:23:00 using:
  ./bin/update_pch svx svxcore --cutoff=7 --exclude:system --include:module --exclude:local
 
  If after updating build fails, use the following command to locate conflicting headers:
@@ -377,6 +377,7 @@
 #include <svtools/svtdllapi.h>
 #include <svtools/valueset.hxx>
 #include <toolkit/helper/vclunohelper.hxx>
+#include <tools/UnitConversion.hxx>
 #include <tools/bigint.hxx>
 #include <tools/color.hxx>
 #include <tools/date.hxx>
diff --git a/svx/source/stbctrls/pszctrl.cxx b/svx/source/stbctrls/pszctrl.cxx
index 4dee38e06930..2c2ef29b1574 100644
--- a/svx/source/stbctrls/pszctrl.cxx
+++ b/svx/source/stbctrls/pszctrl.cxx
@@ -17,7 +17,6 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#include <vcl/builder.hxx>
 #include <vcl/commandevent.hxx>
 #include <vcl/event.hxx>
 #include <vcl/fieldvalues.hxx>
@@ -26,6 +25,8 @@
 #include <vcl/image.hxx>
 #include <vcl/settings.hxx>
 #include <vcl/svapp.hxx>
+#include <vcl/weld.hxx>
+#include <vcl/weldutils.hxx>
 #include <svl/stritem.hxx>
 #include <svl/ptitem.hxx>
 #include <sfx2/module.hxx>
@@ -92,15 +93,18 @@ namespace {
 
 class FunctionPopup_Impl
 {
-    VclBuilder        m_aBuilder;
-    VclPtr<PopupMenu> m_xMenu;
+    std::unique_ptr<weld::Builder> m_xBuilder;
+    std::unique_ptr<weld::Menu> m_xMenu;
     sal_uInt32        m_nSelected;
     static sal_uInt16 id_to_function(std::string_view rIdent);
-    sal_uInt16 function_to_id(sal_uInt16 nFunc) const;
+    static OString function_to_id(sal_uInt16 nFunc);
 public:
-    explicit FunctionPopup_Impl( sal_uInt32 nCheckEncoded );
-    sal_uInt16 Execute(vcl::Window* pWindow, const Point& rPopupPos) { return m_xMenu->Execute(pWindow, rPopupPos); }
-    sal_uInt32 GetSelected() const;
+    explicit FunctionPopup_Impl(sal_uInt32 nCheckEncoded);
+    OString Execute(weld::Window* pParent, const tools::Rectangle& rRect)
+    {
+        return m_xMenu->popup_at_rect(pParent, rRect);
+    }
+    sal_uInt32 GetSelected(std::string_view curident) const;
 };
 
 }
@@ -126,44 +130,44 @@ sal_uInt16 FunctionPopup_Impl::id_to_function(std::string_view rIdent)
     return 0;
 }
 
-sal_uInt16 FunctionPopup_Impl::function_to_id(sal_uInt16 nFunc) const
+OString FunctionPopup_Impl::function_to_id(sal_uInt16 nFunc)
 {
     switch (nFunc)
     {
         case PSZ_FUNC_AVG:
-            return m_xMenu->GetItemId("avg");
+            return "avg";
         case PSZ_FUNC_COUNT2:
-            return m_xMenu->GetItemId("counta");
+            return "counta";
         case PSZ_FUNC_COUNT:
-            return m_xMenu->GetItemId("count");
+            return "count";
         case PSZ_FUNC_MAX:
-            return m_xMenu->GetItemId("max");
+            return "max";
         case PSZ_FUNC_MIN:
-            return m_xMenu->GetItemId("min");
+            return "min";
         case PSZ_FUNC_SUM:
-            return m_xMenu->GetItemId("sum");
+            return "sum";
         case PSZ_FUNC_SELECTION_COUNT:
-            return m_xMenu->GetItemId("selection");
+            return "selection";
         case PSZ_FUNC_NONE:
-            return m_xMenu->GetItemId("none");
+            return "none";
     }
-    return 0;
+    return OString();
 }
 
 FunctionPopup_Impl::FunctionPopup_Impl(sal_uInt32 nCheckEncoded)
-    : m_aBuilder(nullptr, AllSettings::GetUIRootDir(), "svx/ui/functionmenu.ui", "")
-    , m_xMenu(m_aBuilder.get_menu("menu"))
+    : m_xBuilder(Application::CreateBuilder(nullptr, "svx/ui/functionmenu.ui"))
+    , m_xMenu(m_xBuilder->weld_menu("menu"))
     , m_nSelected(nCheckEncoded)
 {
     for ( sal_uInt16 nCheck = 1; nCheck < 32; ++nCheck )
         if ( nCheckEncoded & (1 << nCheck) )
-            m_xMenu->CheckItem(function_to_id(nCheck));
+            m_xMenu->set_active(function_to_id(nCheck), true);
 }
 
-sal_uInt32 FunctionPopup_Impl::GetSelected() const
+sal_uInt32 FunctionPopup_Impl::GetSelected(std::string_view curident) const
 {
     sal_uInt32 nSelected = m_nSelected;
-    sal_uInt16 nCurItemId = id_to_function(m_xMenu->GetCurItemIdent());
+    sal_uInt16 nCurItemId = id_to_function(curident);
     if ( nCurItemId == PSZ_FUNC_NONE )
         nSelected = ( 1 << PSZ_FUNC_NONE );
     else
@@ -349,10 +353,13 @@ void SvxPosSizeStatusBarControl::Command( const CommandEvent& rCEvt )
         sal_uInt32 nSelect = pImpl->nFunctionSet;
         if (!nSelect)
             nSelect = ( 1 << PSZ_FUNC_NONE );
+        tools::Rectangle aRect(rCEvt.GetMousePosPixel(), Size(1,1));
+        weld::Window* pParent = weld::GetPopupParent(GetStatusBar(), aRect);
         FunctionPopup_Impl aMenu(nSelect);
-        if (aMenu.Execute(&GetStatusBar(), rCEvt.GetMousePosPixel()))
+        OString sIdent = aMenu.Execute(pParent, aRect);
+        if (!sIdent.isEmpty())
         {
-            nSelect = aMenu.GetSelected();
+            nSelect = aMenu.GetSelected(sIdent);
             if (nSelect)
             {
                 if (nSelect == (1 << PSZ_FUNC_NONE))


More information about the Libreoffice-commits mailing list