summaryrefslogtreecommitdiff
path: root/sc/source
diff options
context:
space:
mode:
authorRafael Lima <rafael.palma.lima@gmail.com>2023-12-12 01:35:46 +0100
committerThorsten Behrens <thorsten.behrens@allotropia.de>2023-12-16 01:24:38 +0100
commit46c1ce9ac9fa8eff069d5998a6d96a639f277a8e (patch)
treef2bd46676e487131e3abdef912e17c3dc021ec8f /sc/source
parent7f4841946962ffd0d457574721601dc2e6b372a1 (diff)
tdf#158514 Add "Edit Comment" entry to the navigator popup
Clicking this option will show the comment and enter edit mode. Change-Id: Ia9d10e5e03229c48120c27de0a623de5c5cf50d3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160582 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <thorsten.behrens@allotropia.de>
Diffstat (limited to 'sc/source')
-rw-r--r--sc/source/ui/navipi/content.cxx38
-rw-r--r--sc/source/ui/view/viewfun6.cxx6
2 files changed, 44 insertions, 0 deletions
diff --git a/sc/source/ui/navipi/content.cxx b/sc/source/ui/navipi/content.cxx
index 89d77642558a..9e1cc51afd44 100644
--- a/sc/source/ui/navipi/content.cxx
+++ b/sc/source/ui/navipi/content.cxx
@@ -24,6 +24,7 @@
#include <svx/svditer.hxx>
#include <svx/svdobj.hxx>
#include <svx/svdview.hxx>
+#include <svx/svdocapt.hxx>
#include <sfx2/linkmgr.hxx>
#include <sfx2/docfile.hxx>
#include <sfx2/viewfrm.hxx>
@@ -38,6 +39,7 @@
#include <navipi.hxx>
#include <global.hxx>
#include <docsh.hxx>
+#include <docfunc.hxx>
#include <scmod.hxx>
#include <rangenam.hxx>
#include <dbdata.hxx>
@@ -368,6 +370,17 @@ IMPL_LINK_NOARG(ScContentTree, ContentDoubleClickHdl, weld::TreeView&, bool)
ScAddress aPos = GetNotePos( nChild );
pParentWindow->SetCurrentTable( aPos.Tab() );
pParentWindow->SetCurrentCell( aPos.Col(), aPos.Row() );
+ // Check whether the comment is currently visible and toggle its visibility
+ ScDocument* pSrcDoc = GetSourceDocument();
+ if (ScPostIt* pNote = pSrcDoc->GetNote(aPos.Col(), aPos.Row(), aPos.Tab()))
+ {
+ bool bVisible = pNote->IsCaptionShown();
+ // Effectivelly set the visibility of the comment
+ GetManualOrCurrent()->GetDocFunc().ShowNote(aPos, !bVisible);
+ // Put the note in edit mode
+ ScTabViewShell* pScTabViewShell = ScNavigatorDlg::GetTabViewShell();
+ pScTabViewShell->EditNote();
+ }
}
break;
@@ -525,6 +538,13 @@ IMPL_LINK(ScContentTree, CommandHdl, const CommandEvent&, rCEvt, bool)
{
bool bDone = false;
+ ScContentId nType;
+ sal_uLong nChild;
+ std::unique_ptr<weld::TreeIter> xEntry(m_xTreeView->make_iterator());
+ if (!m_xTreeView->get_cursor(xEntry.get()))
+ xEntry.reset();
+ GetEntryIndexes(nType, nChild, xEntry.get());
+
switch ( rCEvt.GetCommand() )
{
case CommandEventId::ContextMenu:
@@ -581,6 +601,10 @@ IMPL_LINK(ScContentTree, CommandHdl, const CommandEvent&, rCEvt, bool)
sActive = sId;
xDocMenu->set_active(sActive, true);
+ // Edit Comments entry is only visible for comments
+ if (nType != ScContentId::NOTE)
+ xPop->set_visible("edit", false);
+
OUString sIdent = xPop->popup_at_rect(m_xTreeView.get(), tools::Rectangle(rCEvt.GetMousePosPixel(), Size(1, 1)));
if (sIdent == "hyperlink")
pParentWindow->SetDropMode(0);
@@ -593,6 +617,20 @@ IMPL_LINK(ScContentTree, CommandHdl, const CommandEvent&, rCEvt, bool)
OUString aName = xDocMenu->get_label(sIdent);
SelectDoc(aName);
}
+ else if (sIdent == "edit")
+ {
+ ScAddress aPos = GetNotePos( nChild );
+ pParentWindow->SetCurrentTable( aPos.Tab() );
+ pParentWindow->SetCurrentCell( aPos.Col(), aPos.Row() );
+ ScDocument* pSrcDoc = GetSourceDocument();
+ if (pSrcDoc->GetNote(aPos.Col(), aPos.Row(), aPos.Tab()))
+ {
+ // Make the note visible and put it in edit mode
+ GetManualOrCurrent()->GetDocFunc().ShowNote(aPos, true);
+ ScTabViewShell* pScTabViewShell = ScNavigatorDlg::GetTabViewShell();
+ pScTabViewShell->EditNote();
+ }
+ }
}
break;
default: break;
diff --git a/sc/source/ui/view/viewfun6.cxx b/sc/source/ui/view/viewfun6.cxx
index a840670dfce2..95d7cc2c2038 100644
--- a/sc/source/ui/view/viewfun6.cxx
+++ b/sc/source/ui/view/viewfun6.cxx
@@ -28,6 +28,8 @@
#include <svl/zformat.hxx>
#include <vcl/uitest/logger.hxx>
#include <vcl/uitest/eventdescription.hxx>
+#include <vcl/keycod.hxx>
+#include <vcl/keycodes.hxx>
#include <editeng/editview.hxx>
#include <rtl/math.hxx>
#include <sal/log.hxx>
@@ -507,6 +509,10 @@ void ScViewFunc::ShowNote( bool bShow )
void ScViewFunc::EditNote()
{
+ // HACK: If another text object is selected, make sure it gets unselected
+ if (FuText* pOldFuText = dynamic_cast<FuText*>(GetDrawFuncPtr()))
+ pOldFuText->KeyInput(KeyEvent(0, vcl::KeyCode(KEY_ESCAPE)));
+
// for editing display and activate
ScDocShell* pDocSh = GetViewData().GetDocShell();