[Libreoffice-commits] core.git: sw/source sw/uiconfig sw/UIConfig_swriter.mk
Caolán McNamara (via logerrit)
logerrit at kemper.freedesktop.org
Tue Feb 23 09:16:45 UTC 2021
sw/UIConfig_swriter.mk | 1
sw/source/uibase/utlui/bookctrl.cxx | 47 +++++++--------------------------
sw/uiconfig/swriter/ui/bookmarkmenu.ui | 9 ++++++
3 files changed, 21 insertions(+), 36 deletions(-)
New commits:
commit 2e7fe9f0048f5afb957278e87106a81ba818dd8a
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Mon Feb 22 20:14:58 2021 +0000
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Tue Feb 23 10:16:01 2021 +0100
replace BookmarkPopup_Impl
Change-Id: I87dda264ec61bbbfd6cf4eb0cbbe636724579537
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111360
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/sw/UIConfig_swriter.mk b/sw/UIConfig_swriter.mk
index 655341ff28b1..16aaf178b3e3 100644
--- a/sw/UIConfig_swriter.mk
+++ b/sw/UIConfig_swriter.mk
@@ -103,6 +103,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/swriter,\
sw/uiconfig/swriter/ui/autotext \
sw/uiconfig/swriter/ui/bibliographyentry \
sw/uiconfig/swriter/ui/bibliofragment \
+ sw/uiconfig/swriter/ui/bookmarkmenu \
sw/uiconfig/swriter/ui/bulletsandnumbering \
sw/uiconfig/swriter/ui/businessdatapage \
sw/uiconfig/swriter/ui/calendar \
diff --git a/sw/source/uibase/utlui/bookctrl.cxx b/sw/source/uibase/utlui/bookctrl.cxx
index d07744290151..f47bfe735ec9 100644
--- a/sw/source/uibase/utlui/bookctrl.cxx
+++ b/sw/source/uibase/utlui/bookctrl.cxx
@@ -28,7 +28,7 @@
#include <vcl/commandevent.hxx>
#include <vcl/event.hxx>
#include <vcl/status.hxx>
-#include <vcl/menu.hxx>
+#include <vcl/weldutils.hxx>
#include <cmdid.h>
#include <swmodule.hxx>
#include <wrtsh.hxx>
@@ -38,34 +38,6 @@
SFX_IMPL_STATUSBAR_CONTROL(SwBookmarkControl, SfxStringListItem);
-namespace {
-
-class BookmarkPopup_Impl : public PopupMenu
-{
-public:
- BookmarkPopup_Impl();
-
- sal_uInt16 GetCurId() const { return nCurId; }
-
-private:
- sal_uInt16 nCurId;
-
- virtual void Select() override;
-};
-
-}
-
-BookmarkPopup_Impl::BookmarkPopup_Impl() :
- PopupMenu(),
- nCurId(USHRT_MAX)
-{
-}
-
-void BookmarkPopup_Impl::Select()
-{
- nCurId = GetCurItemId();
-}
-
SwBookmarkControl::SwBookmarkControl( sal_uInt16 _nSlotId,
sal_uInt16 _nId,
StatusBar& rStb ) :
@@ -103,14 +75,16 @@ void SwBookmarkControl::Command( const CommandEvent& rCEvt )
GetStatusBar().GetItemText( GetId() ).isEmpty())
return;
- ScopedVclPtrInstance<BookmarkPopup_Impl> aPop;
SwWrtShell* pWrtShell = ::GetActiveWrtShell();
if( !(pWrtShell && pWrtShell->getIDocumentMarkAccess()->getAllMarksCount() > 0) )
return;
+ std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(nullptr, "modules/swriter/ui/bookmarkmenu.ui"));
+ std::unique_ptr<weld::Menu> xPopup(xBuilder->weld_menu("menu"));
+
IDocumentMarkAccess* const pMarkAccess = pWrtShell->getIDocumentMarkAccess();
IDocumentMarkAccess::const_iterator_t ppBookmarkStart = pMarkAccess->getBookmarksBegin();
- sal_uInt16 nPopupId = 1;
+ sal_uInt32 nPopupId = 1;
std::map<sal_Int32, sal_uInt16> aBookmarkIdx;
for(IDocumentMarkAccess::const_iterator_t ppBookmark = ppBookmarkStart;
ppBookmark != pMarkAccess->getBookmarksEnd();
@@ -118,16 +92,17 @@ void SwBookmarkControl::Command( const CommandEvent& rCEvt )
{
if(IDocumentMarkAccess::MarkType::BOOKMARK == IDocumentMarkAccess::GetType(**ppBookmark))
{
- aPop->InsertItem( nPopupId, (*ppBookmark)->GetName() );
+ xPopup->append(OUString::number(nPopupId), (*ppBookmark)->GetName());
aBookmarkIdx[nPopupId] = static_cast<sal_uInt16>(ppBookmark - ppBookmarkStart);
nPopupId++;
}
}
- aPop->Execute( &GetStatusBar(), rCEvt.GetMousePosPixel());
- sal_uInt16 nCurrId = aPop->GetCurId();
- if( nCurrId != USHRT_MAX)
+ ::tools::Rectangle aRect(rCEvt.GetMousePosPixel(), Size(1, 1));
+ weld::Window* pParent = weld::GetPopupParent(GetStatusBar(), aRect);
+ OString sResult = xPopup->popup_at_rect(pParent, aRect);
+ if (!sResult.isEmpty())
{
- SfxUInt16Item aBookmark( FN_STAT_BOOKMARK, aBookmarkIdx[nCurrId] );
+ SfxUInt16Item aBookmark( FN_STAT_BOOKMARK, aBookmarkIdx[sResult.toUInt32()] );
SfxViewFrame::Current()->GetDispatcher()->ExecuteList(FN_STAT_BOOKMARK,
SfxCallMode::ASYNCHRON|SfxCallMode::RECORD,
{ &aBookmark });
diff --git a/sw/uiconfig/swriter/ui/bookmarkmenu.ui b/sw/uiconfig/swriter/ui/bookmarkmenu.ui
new file mode 100644
index 000000000000..53f81216379e
--- /dev/null
+++ b/sw/uiconfig/swriter/ui/bookmarkmenu.ui
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.38.2 -->
+<interface domain="sw">
+ <requires lib="gtk+" version="3.20"/>
+ <object class="GtkMenu" id="menu">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ </object>
+</interface>
More information about the Libreoffice-commits
mailing list