1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <AnnotationWin.hxx>
21 #include <strings.hrc>
23 #include <unotools/useroptions.hxx>
25 #include <vcl/event.hxx>
29 #include <swtypes.hxx>
31 namespace sw::annotation
{
33 IMPL_LINK(SwAnnotationWin
, SelectHdl
, const OUString
&, rIdent
, void)
38 // tdf#136682 ensure this is the currently active sidebar win so the command
39 // operates in an active sidebar context
40 bool bSwitchedFocus
= SetActiveSidebarWin();
42 if (rIdent
== "reply")
43 ExecuteCommand(FN_REPLY
);
44 if (rIdent
== "resolve" || rIdent
== "unresolve")
45 ExecuteCommand(FN_RESOLVE_NOTE
);
46 else if (rIdent
== "resolvethread" || rIdent
== "unresolvethread")
47 ExecuteCommand(FN_RESOLVE_NOTE_THREAD
);
48 else if (rIdent
== "delete")
49 ExecuteCommand(FN_DELETE_COMMENT
);
50 else if (rIdent
== "deletethread")
51 ExecuteCommand(FN_DELETE_COMMENT_THREAD
);
52 else if (rIdent
== "deleteby")
53 ExecuteCommand(FN_DELETE_NOTE_AUTHOR
);
54 else if (rIdent
== "deleteall")
55 ExecuteCommand(FN_DELETE_ALL_NOTES
);
56 else if (rIdent
== "formatall")
57 ExecuteCommand(FN_FORMAT_ALL_NOTES
);
60 UnsetActiveSidebarWin();
61 GrabFocusToDocument();
64 IMPL_LINK_NOARG(SwAnnotationWin
, ToggleHdl
, weld::Toggleable
&, void)
66 if (!mxMenuButton
->get_active())
69 bool bReadOnly
= IsReadOnly();
72 mxMenuButton
->set_item_visible("resolve", false);
73 mxMenuButton
->set_item_visible("unresolve", false);
74 mxMenuButton
->set_item_visible("resolvethread", false);
75 mxMenuButton
->set_item_visible("unresolvethread", false);
76 mxMenuButton
->set_item_visible("delete", false );
80 mxMenuButton
->set_item_visible("resolve", !IsResolved());
81 mxMenuButton
->set_item_visible("unresolve", IsResolved());
82 mxMenuButton
->set_item_visible("resolvethread", !IsThreadResolved());
83 mxMenuButton
->set_item_visible("unresolvethread", IsThreadResolved());
84 mxMenuButton
->set_item_visible("delete", !IsReadOnlyOrProtected());
87 mxMenuButton
->set_item_visible("deletethread", !bReadOnly
);
88 mxMenuButton
->set_item_visible("deleteby", !bReadOnly
);
89 mxMenuButton
->set_item_visible("deleteall", !bReadOnly
);
90 mxMenuButton
->set_item_visible("formatall", !bReadOnly
);
92 bool bReplyVis
= true;
94 // No answer possible if this note is in a protected section.
95 if (IsReadOnlyOrProtected())
97 mxMenuButton
->set_item_visible("reply", false);
102 SvtUserOptions aUserOpt
;
104 if ((sAuthor
= aUserOpt
.GetFullName()).isEmpty())
106 if ((sAuthor
= aUserOpt
.GetID()).isEmpty())
108 sAuthor
= SwResId(STR_REDLINE_UNKNOWN_AUTHOR
);
111 // do not allow to reply to ourself
112 bReplyVis
= sAuthor
!= GetAuthor();
114 mxMenuButton
->set_item_visible("reply", bReplyVis
);
115 mxMenuButton
->set_item_visible("sep1", bReplyVis
);
118 IMPL_LINK(SwAnnotationWin
, KeyInputHdl
, const KeyEvent
&, rKeyEvt
, bool)
120 const vcl::KeyCode
& rKeyCode
= rKeyEvt
.GetKeyCode();
121 if (rKeyCode
.GetCode() == KEY_TAB
)
130 } // end of namespace sw::annotation
132 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */