/src/libreoffice/sw/source/uibase/docvw/AnnotationMenuButton.cxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
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/. |
8 | | * |
9 | | * This file incorporates work covered by the following license notice: |
10 | | * |
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 . |
18 | | */ |
19 | | |
20 | | #include <AnnotationWin.hxx> |
21 | | #include <strings.hrc> |
22 | | |
23 | | #include <unotools/useroptions.hxx> |
24 | | |
25 | | #include <vcl/event.hxx> |
26 | | |
27 | | #include <cmdid.h> |
28 | | |
29 | | #include <swtypes.hxx> |
30 | | |
31 | | namespace sw::annotation { |
32 | | |
33 | | IMPL_LINK(SwAnnotationWin, SelectHdl, const OUString&, rIdent, void) |
34 | 0 | { |
35 | 0 | if (rIdent.isEmpty()) |
36 | 0 | return; |
37 | | |
38 | | // tdf#136682 ensure this is the currently active sidebar win so the command |
39 | | // operates in an active sidebar context |
40 | 0 | bool bSwitchedFocus = SetActiveSidebarWin(); |
41 | |
|
42 | 0 | if (rIdent == "reply") |
43 | 0 | ExecuteCommand(FN_REPLY); |
44 | 0 | if (rIdent == "resolve" || rIdent == "unresolve") |
45 | 0 | ExecuteCommand(FN_RESOLVE_NOTE); |
46 | 0 | else if (rIdent == "resolvethread" || rIdent == "unresolvethread") |
47 | 0 | ExecuteCommand(FN_RESOLVE_NOTE_THREAD); |
48 | 0 | else if (rIdent == "delete") |
49 | 0 | ExecuteCommand(FN_DELETE_COMMENT); |
50 | 0 | else if (rIdent == "deletethread") |
51 | 0 | ExecuteCommand(FN_DELETE_COMMENT_THREAD); |
52 | 0 | else if (rIdent == "deleteby") |
53 | 0 | ExecuteCommand(FN_DELETE_NOTE_AUTHOR); |
54 | 0 | else if (rIdent == "deleteall") |
55 | 0 | ExecuteCommand(FN_DELETE_ALL_NOTES); |
56 | 0 | else if (rIdent == "formatall") |
57 | 0 | ExecuteCommand(FN_FORMAT_ALL_NOTES); |
58 | 0 | else if (rIdent == "promote") |
59 | 0 | ExecuteCommand(FN_PROMOTE_COMMENT); |
60 | |
|
61 | 0 | if (bSwitchedFocus) |
62 | 0 | UnsetActiveSidebarWin(); |
63 | 0 | GrabFocusToDocument(); |
64 | 0 | } |
65 | | |
66 | | void SwAnnotationWin::UpdateMenu() |
67 | 0 | { |
68 | 0 | bool bReadOnly = IsReadOnly(); |
69 | 0 | if (bReadOnly) |
70 | 0 | { |
71 | 0 | mxMenuButton->set_item_visible(u"reply"_ustr, false); |
72 | 0 | mxMenuButton->set_item_visible(u"sep1"_ustr, false); // Separator after reply button. |
73 | 0 | mxMenuButton->set_item_visible(u"resolve"_ustr, false); |
74 | 0 | mxMenuButton->set_item_visible(u"unresolve"_ustr, false); |
75 | 0 | mxMenuButton->set_item_visible(u"resolvethread"_ustr, false); |
76 | 0 | mxMenuButton->set_item_visible(u"unresolvethread"_ustr, false); |
77 | 0 | mxMenuButton->set_item_visible(u"delete"_ustr, false ); |
78 | 0 | mxMenuButton->set_item_visible(u"promote"_ustr, false); |
79 | 0 | } |
80 | 0 | else |
81 | 0 | { |
82 | 0 | mxMenuButton->set_item_visible(u"reply"_ustr, !IsReadOnlyOrProtected()); |
83 | 0 | mxMenuButton->set_item_visible(u"sep1"_ustr, !IsReadOnlyOrProtected()); |
84 | 0 | mxMenuButton->set_item_visible(u"resolve"_ustr, !IsResolved()); |
85 | 0 | mxMenuButton->set_item_visible(u"unresolve"_ustr, IsResolved()); |
86 | 0 | mxMenuButton->set_item_visible(u"resolvethread"_ustr, !IsThreadResolved()); |
87 | 0 | mxMenuButton->set_item_visible(u"unresolvethread"_ustr, IsThreadResolved()); |
88 | 0 | mxMenuButton->set_item_visible(u"delete"_ustr, !IsReadOnlyOrProtected()); |
89 | 0 | mxMenuButton->set_item_visible(u"promote"_ustr, !IsReadOnlyOrProtected() && !IsRootNote()); |
90 | 0 | } |
91 | |
|
92 | 0 | mxMenuButton->set_item_visible(u"deletethread"_ustr, !bReadOnly); |
93 | 0 | mxMenuButton->set_item_visible(u"deleteby"_ustr, !bReadOnly); |
94 | 0 | mxMenuButton->set_item_visible(u"deleteall"_ustr, !bReadOnly); |
95 | 0 | mxMenuButton->set_item_visible(u"formatall"_ustr, !bReadOnly); |
96 | 0 | } |
97 | | |
98 | | IMPL_LINK(SwAnnotationWin, KeyInputHdl, const KeyEvent&, rKeyEvt, bool) |
99 | 0 | { |
100 | 0 | const vcl::KeyCode& rKeyCode = rKeyEvt.GetKeyCode(); |
101 | 0 | if (rKeyCode.GetCode() == KEY_TAB) |
102 | 0 | { |
103 | 0 | ActivatePostIt(); |
104 | 0 | GrabFocus(); |
105 | 0 | return true; |
106 | 0 | } |
107 | 0 | return false; |
108 | 0 | } |
109 | | |
110 | | } // end of namespace sw::annotation |
111 | | |
112 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |