summaryrefslogtreecommitdiff
path: root/sw/source/uibase/utlui/content.cxx
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2023-06-15 23:36:20 +0200
committerLászló Németh <nemeth@numbertext.org>2023-06-16 11:16:21 +0200
commitc5b1578784c7179bde458640d78e1384ef190a21 (patch)
treee558ec53d4a872ee5c403f951d5f883a53721831 /sw/source/uibase/utlui/content.cxx
parent2b1b2a758cc4666c6cf6b147722223281dfe1f30 (diff)
tdf#154521 sw navigator: allow to query selected bookmark via UNO
If the hidden title of SwNavigatorPanel was emptied via UNO XPanel interface, store the name of the selected bookmark there. This allows to query the selected bookmark using UNO e.g. in add-ons, i.e. to disambiguate when multiple bookmarks are there on the selected text range. Note: this is a workaround because getDialog() of XPanel is not implemented for SwNavigatorPanel. Follow-up to commit c4a58634753a84b09f20f7271d6525a6656522d3 "tdf#154545 sw Navigator: select & track nested bookmarks" and commit 6eb1d540a1e599aa4fe0a321eddb9cc22e0546d3 "tdf#154521 sw Navigator: fix selection change event of bookmark". Change-Id: I94f79daf59516331155e0b36502821c769771207 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153162 Tested-by: László Németh <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sw/source/uibase/utlui/content.cxx')
-rw-r--r--sw/source/uibase/utlui/content.cxx42
1 files changed, 42 insertions, 0 deletions
diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx
index 6d22bc53a91e..1284dc7a0d0e 100644
--- a/sw/source/uibase/utlui/content.cxx
+++ b/sw/source/uibase/utlui/content.cxx
@@ -71,6 +71,11 @@
#include <com/sun/star/text/XBookmarksSupplier.hpp>
#include <com/sun/star/text/XTextEmbeddedObjectsSupplier.hpp>
#include <com/sun/star/text/XTextFramesSupplier.hpp>
+#include <com/sun/star/ui/XSidebarProvider.hpp>
+#include <com/sun/star/ui/XDecks.hpp>
+#include <com/sun/star/ui/XDeck.hpp>
+#include <com/sun/star/ui/XPanels.hpp>
+#include <com/sun/star/ui/XPanel.hpp>
#include <svx/svdpage.hxx>
#include <svx/svdview.hxx>
#include <SwRewriter.hxx>
@@ -5381,6 +5386,43 @@ void SwContentTree::GotoContent(const SwContent* pCnt)
m_pActiveShell->GotoMark(pCnt->GetName());
m_pActiveShell->EndAction();
m_sSelectedItem = pCnt->GetName();
+
+ // If the hidden title of SwNavigatorPanel was emptied via UNO XPanel interface,
+ // store the name of the selected bookmark there. This allows to query the
+ // selected bookmark using UNO e.g. in add-ons, i.e. to disambiguate when
+ // multiple bookmarks are there on the selected text range.
+ // Note: this is a workaround because getDialog() of XPanel is not implemented
+ // for SwNavigatorPanel.
+ uno::Reference< frame::XModel > xModel = m_pActiveShell->GetView().GetDocShell()->GetBaseModel();
+
+ Reference<frame::XController2> xController( xModel->getCurrentController(), uno::UNO_QUERY);
+ if ( !xController.is() )
+ break;
+
+ Reference<ui::XSidebarProvider> xSidebarProvider = xController->getSidebar();
+ if ( !xSidebarProvider.is() )
+ break;
+
+ Reference<ui::XDecks> xDecks = xSidebarProvider->getDecks();
+ if ( !xDecks.is() )
+ break;
+
+ Reference<ui::XDeck> xDeck ( xDecks->getByName("NavigatorDeck"), uno::UNO_QUERY);
+ if ( !xDeck.is() )
+ break;
+
+ Reference<ui::XPanels> xPanels = xDeck->getPanels();
+ if ( !xPanels.is() )
+ break;
+
+ if (xPanels->hasByName("SwNavigatorPanel"))
+ {
+ Reference<ui::XPanel> xPanel ( xPanels->getByName("SwNavigatorPanel"), uno::UNO_QUERY);
+ if ( !xPanel.is() || !xPanel->getTitle().isEmpty() )
+ break;
+
+ xPanel->setTitle( pCnt->GetName() );
+ }
}
break;
case ContentTypeId::REGION :