tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / include / sfx2 / event.hxx
blob0e4fd8977a7d81b18d63148c9755a143f5f4df77
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
19 #ifndef INCLUDED_SFX2_EVENT_HXX
20 #define INCLUDED_SFX2_EVENT_HXX
22 #include <sal/config.h>
24 #include <ostream>
26 #include <unotools/weakref.hxx>
27 #include <sfx2/dllapi.h>
28 #include <svl/hint.hxx>
29 #include <unotools/eventcfg.hxx>
30 #include <rtl/ustring.hxx>
31 #include <sfx2/objsh.hxx>
33 #include <com/sun/star/uno/Sequence.hxx>
34 #include <com/sun/star/frame/XController2.hpp>
35 #include <com/sun/star/view/PrintableState.hpp>
36 #include <utility>
38 namespace com::sun::star::beans { struct PropertyValue; }
40 /**
41 these values get stored in streams in a 16-bit value
43 enum class SvMacroItemId : sal_uInt16 {
44 NONE = 0,
46 // used by SwHTMLForm_Impl
47 HtmlOnSubmitForm,
48 HtmlOnResetForm,
49 HtmlOnGetFocus,
50 HtmlOnLoseFocus,
51 HtmlOnClick,
52 HtmlOnClickItem,
53 HtmlOnChange,
54 HtmlOnSelect,
56 // used by SwHTMLParser
57 OpenDoc,
58 PrepareCloseDoc,
59 ActivateDoc,
60 DeactivateDoc,
62 // Events for Controls etc.
63 OnMouseOver = 5100,
64 OnClick = 5101,
65 OnMouseOut = 5102,
67 OnImageLoadDone = 10000,
68 OnImageLoadCancel = 10001,
69 OnImageLoadError = 10002,
71 SwObjectSelect = 20000,
72 SwStartInsGlossary = 20001,
73 SwEndInsGlossary = 20002,
74 SwFrmKeyInputAlpha = 20004,
75 SwFrmKeyInputNoAlpha = 20005,
76 SwFrmResize = 20006,
77 SwFrmMove = 20007,
80 template< typename charT, typename traits >
81 inline std::basic_ostream<charT, traits> & operator <<(
82 std::basic_ostream<charT, traits> & stream, const SvMacroItemId& id )
84 switch(id)
86 case SvMacroItemId::NONE: return stream << "NONE";
87 case SvMacroItemId::HtmlOnSubmitForm: return stream << "HtmlOnSubmitForm";
88 case SvMacroItemId::HtmlOnResetForm: return stream << "HtmlOnResetForm";
89 case SvMacroItemId::HtmlOnGetFocus: return stream << "HtmlOnGetFocus";
90 case SvMacroItemId::HtmlOnLoseFocus: return stream << "HtmlOnLoseFocus";
91 case SvMacroItemId::HtmlOnClick: return stream << "HtmlOnClick";
92 case SvMacroItemId::HtmlOnClickItem: return stream << "HtmlOnClickItem";
93 case SvMacroItemId::HtmlOnChange: return stream << "HtmlOnChange";
94 case SvMacroItemId::HtmlOnSelect: return stream << "HtmlOnSelect";
95 case SvMacroItemId::OpenDoc: return stream << "OpenDoc";
96 case SvMacroItemId::PrepareCloseDoc: return stream << "PrepareCloseDoc";
97 case SvMacroItemId::ActivateDoc: return stream << "ActivateDoc";
98 case SvMacroItemId::DeactivateDoc: return stream << "DeactivateDoc";
99 case SvMacroItemId::OnMouseOver: return stream << "OnMouseOver";
100 case SvMacroItemId::OnClick: return stream << "OnClick";
101 case SvMacroItemId::OnMouseOut: return stream << "OnMouseOut";
102 case SvMacroItemId::OnImageLoadDone: return stream << "OnImageLoadDone";
103 case SvMacroItemId::OnImageLoadCancel: return stream << "OnImageLoadCancel";
104 case SvMacroItemId::OnImageLoadError: return stream << "OnImageLoadError";
105 case SvMacroItemId::SwObjectSelect: return stream << "SwObjectSelect";
106 case SvMacroItemId::SwStartInsGlossary: return stream << "SwStartInsGlossary";
107 case SvMacroItemId::SwEndInsGlossary: return stream << "SwEndInsGlossary";
108 case SvMacroItemId::SwFrmKeyInputAlpha: return stream << "SwFrmKeyInputAlpha";
109 case SvMacroItemId::SwFrmKeyInputNoAlpha: return stream << "SwFrmKeyInputNoAlpha";
110 case SvMacroItemId::SwFrmResize: return stream << "SwFrmResize";
111 case SvMacroItemId::SwFrmMove: return stream << "SwFrmMove";
112 default: return stream << "unk(" << std::to_string(int(id)) << ")";
116 enum class SfxEventHintId {
117 NONE = 0,
118 ActivateDoc,
119 CloseDoc,
120 CloseView,
121 CreateDoc,
122 DeactivateDoc,
123 DocCreated,
124 LoadFinished,
125 ModifyChanged,
126 OpenDoc,
127 PrepareCloseDoc,
128 PrepareCloseView,
129 PrintDoc,
130 SaveAsDoc,
131 SaveAsDocDone,
132 SaveAsDocFailed,
133 SaveDoc,
134 SaveDocDone,
135 SaveDocFailed,
136 SaveToDoc,
137 SaveToDocDone,
138 SaveToDocFailed,
139 StorageChanged,
140 ViewCreated,
141 VisAreaChanged,
142 // SW events
143 SwMailMerge,
144 SwMailMergeEnd,
145 SwEventPageCount,
146 SwEventFieldMerge,
147 SwEventFieldMergeFinished,
148 SwEventLayoutFinished,
151 template< typename charT, typename traits >
152 inline std::basic_ostream<charT, traits> & operator <<(
153 std::basic_ostream<charT, traits> & stream, const SfxEventHintId& id )
155 switch(id)
157 case SfxEventHintId::NONE: return stream << "NONE";
158 case SfxEventHintId::ActivateDoc: return stream << "ActivateDoc";
159 case SfxEventHintId::CloseDoc: return stream << "CloseDoc";
160 case SfxEventHintId::CloseView: return stream << "CloseView";
161 case SfxEventHintId::CreateDoc: return stream << "CreateDoc";
162 case SfxEventHintId::DeactivateDoc: return stream << "DeactivateDoc";
163 case SfxEventHintId::DocCreated: return stream << "DocCreated";
164 case SfxEventHintId::LoadFinished: return stream << "LoadFinished";
165 case SfxEventHintId::ModifyChanged: return stream << "ModifyChanged";
166 case SfxEventHintId::OpenDoc: return stream << "OpenDoc";
167 case SfxEventHintId::PrepareCloseDoc: return stream << "PrepareCloseDoc";
168 case SfxEventHintId::PrepareCloseView: return stream << "PrepareCloseView";
169 case SfxEventHintId::PrintDoc: return stream << "PrintDoc";
170 case SfxEventHintId::SaveAsDoc: return stream << "SaveAsDoc";
171 case SfxEventHintId::SaveAsDocDone: return stream << "SaveAsDocDone";
172 case SfxEventHintId::SaveAsDocFailed: return stream << "SaveAsDocFailed";
173 case SfxEventHintId::SaveDoc: return stream << "SaveDoc";
174 case SfxEventHintId::SaveDocDone: return stream << "SaveDocDone";
175 case SfxEventHintId::SaveDocFailed: return stream << "SaveDocFailed";
176 case SfxEventHintId::SaveToDoc: return stream << "SaveToDoc";
177 case SfxEventHintId::SaveToDocDone: return stream << "SaveToDocDone";
178 case SfxEventHintId::SaveToDocFailed: return stream << "SaveToDocFailed";
179 case SfxEventHintId::StorageChanged: return stream << "StorageChanged";
180 case SfxEventHintId::ViewCreated: return stream << "ViewCreated";
181 case SfxEventHintId::VisAreaChanged: return stream << "VisAreaChanged";
182 case SfxEventHintId::SwMailMerge: return stream << "SwMailMerge";
183 case SfxEventHintId::SwMailMergeEnd: return stream << "SwMailMergeEnd";
184 case SfxEventHintId::SwEventPageCount: return stream << "SwEventPageCount";
185 case SfxEventHintId::SwEventFieldMerge: return stream << "SwEventFieldMerge";
186 case SfxEventHintId::SwEventFieldMergeFinished: return stream << "SwEventFieldMergeFinished";
187 case SfxEventHintId::SwEventLayoutFinished: return stream << "SwEventLayoutFinished";
188 default: return stream << "unk(" << std::to_string(int(id)) << ")";
192 class SFX2_DLLPUBLIC SfxEventHint : public SfxHint
194 unotools::WeakReference<SfxObjectShell> pObjShell;
195 OUString aEventName;
196 SfxEventHintId nEventId;
198 public:
199 SfxEventHint(SfxEventHintId nId, OUString aName, SfxObjectShell *pObj)
200 : SfxHint(SfxHintId::ThisIsAnSfxEventHint)
201 , pObjShell(pObj)
202 , aEventName(std::move(aName))
203 , nEventId(nId)
207 SfxEventHintId GetEventId() const
208 { return nEventId; }
210 const OUString& GetEventName() const
211 { return aEventName; }
213 rtl::Reference<SfxObjectShell> GetObjShell() const { return pObjShell.get(); }
217 class SFX2_DLLPUBLIC SfxViewEventHint : public SfxEventHint
219 css::uno::Reference< css::frame::XController2 > xViewController;
221 public:
222 SfxViewEventHint( SfxEventHintId nId, const OUString& aName, SfxObjectShell *pObj, const css::uno::Reference< css::frame::XController >& xController )
223 : SfxEventHint( nId, aName, pObj )
224 , xViewController( xController, css::uno::UNO_QUERY )
227 SfxViewEventHint( SfxEventHintId nId, const OUString& aName, SfxObjectShell *pObj, css::uno::Reference< css::frame::XController2 > xController )
228 : SfxEventHint( nId, aName, pObj )
229 , xViewController(std::move( xController ))
232 const css::uno::Reference< css::frame::XController2 >& GetController() const
233 { return xViewController; }
236 class SfxPrintingHint final : public SfxViewEventHint
238 css::view::PrintableState mnPrintableState;
239 css::uno::Sequence < css::beans::PropertyValue > aOpts;
240 public:
241 SfxPrintingHint(
242 css::view::PrintableState nState,
243 const css::uno::Sequence < css::beans::PropertyValue >& rOpts,
244 SfxObjectShell *pObj,
245 const css::uno::Reference< css::frame::XController2 >& xController )
246 : SfxViewEventHint(
247 SfxEventHintId::PrintDoc,
248 GlobalEventConfig::GetEventName( GlobalEventId::PRINTDOC ),
249 pObj,
250 xController )
251 , mnPrintableState( nState )
252 , aOpts( rOpts )
255 SfxPrintingHint( css::view::PrintableState nState )
256 : SfxViewEventHint(
257 SfxEventHintId::PrintDoc,
258 GlobalEventConfig::GetEventName( GlobalEventId::PRINTDOC ),
259 nullptr,
260 css::uno::Reference< css::frame::XController >() )
261 , mnPrintableState( nState )
264 css::view::PrintableState GetWhich() const { return mnPrintableState; }
265 const css::uno::Sequence < css::beans::PropertyValue >& GetOptions() const { return aOpts; }
268 #endif
270 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */