sc/source/ui/navipi/content.cxx | 38 +++++++++++++++++++++++++++++++++++ sc/source/ui/view/viewfun6.cxx | 6 +++++ sc/uiconfig/scalc/ui/dropmenu.ui | 42 +++++++++++++++++++++++---------------- 3 files changed, 69 insertions(+), 17 deletions(-)
New commits: commit 46c1ce9ac9fa8eff069d5998a6d96a639f277a8e Author: Rafael Lima <rafael.palma.l...@gmail.com> AuthorDate: Tue Dec 12 01:35:46 2023 +0100 Commit: Thorsten Behrens <thorsten.behr...@allotropia.de> CommitDate: Sat Dec 16 01:24:38 2023 +0100 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.behr...@allotropia.de> 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(); diff --git a/sc/uiconfig/scalc/ui/dropmenu.ui b/sc/uiconfig/scalc/ui/dropmenu.ui index 9dca85a62552..7ed44d4093d0 100644 --- a/sc/uiconfig/scalc/ui/dropmenu.ui +++ b/sc/uiconfig/scalc/ui/dropmenu.ui @@ -1,28 +1,28 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.36.0 --> +<!-- Generated with glade 3.40.0 --> <interface domain="sc"> <requires lib="gtk+" version="3.20"/> <object class="GtkMenu" id="contextmenu"> <property name="visible">True</property> - <property name="can_focus">False</property> + <property name="can-focus">False</property> <child> <object class="GtkMenuItem" id="dragmodeitem"> <property name="visible">True</property> - <property name="can_focus">False</property> + <property name="can-focus">False</property> <property name="label" translatable="yes" context="dropmenu|SCSTR_DRAGMODE">Drag Mode</property> - <property name="use_underline">True</property> + <property name="use-underline">True</property> <child type="submenu"> <object class="GtkMenu" id="dragmodesubmenu"> <property name="visible">True</property> - <property name="can_focus">False</property> + <property name="can-focus">False</property> <child> <object class="GtkRadioMenuItem" id="hyperlink"> <property name="visible">True</property> - <property name="can_focus">False</property> + <property name="can-focus">False</property> <property name="label" translatable="yes" context="dropmenu|hyperlink">Insert as Hyperlink</property> - <property name="use_underline">True</property> + <property name="use-underline">True</property> <property name="active">True</property> - <property name="draw_as_radio">True</property> + <property name="draw-as-radio">True</property> <child internal-child="accessible"> <object class="AtkObject" id="hyperlink-atkobject"> <property name="AtkObject::accessible-description" translatable="yes" context="dropmenu|extended_tip|hyperlink">Inserts a hyperlink when you drag-and-drop an object from the Navigator into a document.</property> @@ -33,10 +33,10 @@ <child> <object class="GtkRadioMenuItem" id="link"> <property name="visible">True</property> - <property name="can_focus">False</property> + <property name="can-focus">False</property> <property name="label" translatable="yes" context="dropmenu|link">Insert as Link</property> - <property name="use_underline">True</property> - <property name="draw_as_radio">True</property> + <property name="use-underline">True</property> + <property name="draw-as-radio">True</property> <property name="group">hyperlink</property> <child internal-child="accessible"> <object class="AtkObject" id="link-atkobject"> @@ -48,10 +48,10 @@ <child> <object class="GtkRadioMenuItem" id="copy"> <property name="visible">True</property> - <property name="can_focus">False</property> + <property name="can-focus">False</property> <property name="label" translatable="yes" context="dropmenu|copy">Insert as Copy</property> - <property name="use_underline">True</property> - <property name="draw_as_radio">True</property> + <property name="use-underline">True</property> + <property name="draw-as-radio">True</property> <property name="group">hyperlink</property> <child internal-child="accessible"> <object class="AtkObject" id="copy-atkobject"> @@ -67,16 +67,24 @@ <child> <object class="GtkMenuItem" id="displayitem"> <property name="visible">True</property> - <property name="can_focus">False</property> + <property name="can-focus">False</property> <property name="label" translatable="yes" context="dropmenu|SCSTR_DISPLAY">Display</property> - <property name="use_underline">True</property> + <property name="use-underline">True</property> <child type="submenu"> <object class="GtkMenu" id="displaymenu"> <property name="visible">True</property> - <property name="can_focus">False</property> + <property name="can-focus">False</property> </object> </child> </object> </child> + <child> + <object class="GtkMenuItem" id="edit"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="label" translatable="yes" context="dropmenu|SCSTR_EDIT">Edit Comment</property> + <property name="use-underline">True</property> + </object> + </child> </object> </interface>