Update git submodules
[LibreOffice.git] / include / sfx2 / event.hxx
blob021472830ab820cbc0889cb066dee67a2f9d0ea7
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 <sfx2/dllapi.h>
27 #include <svl/hint.hxx>
28 #include <unotools/eventcfg.hxx>
29 #include <rtl/ustring.hxx>
31 #include <com/sun/star/uno/Sequence.hxx>
32 #include <com/sun/star/frame/XController2.hpp>
33 #include <com/sun/star/view/PrintableState.hpp>
34 #include <utility>
36 namespace com::sun::star::beans { struct PropertyValue; }
38 /**
39 these values get stored in streams in a 16-bit value
41 enum class SvMacroItemId : sal_uInt16 {
42 NONE = 0,
44 // used by SwHTMLForm_Impl
45 HtmlOnSubmitForm,
46 HtmlOnResetForm,
47 HtmlOnGetFocus,
48 HtmlOnLoseFocus,
49 HtmlOnClick,
50 HtmlOnClickItem,
51 HtmlOnChange,
52 HtmlOnSelect,
54 // used by SwHTMLParser
55 OpenDoc,
56 PrepareCloseDoc,
57 ActivateDoc,
58 DeactivateDoc,
60 // Events for Controls etc.
61 OnMouseOver = 5100,
62 OnClick = 5101,
63 OnMouseOut = 5102,
65 OnImageLoadDone = 10000,
66 OnImageLoadCancel = 10001,
67 OnImageLoadError = 10002,
69 SwObjectSelect = 20000,
70 SwStartInsGlossary = 20001,
71 SwEndInsGlossary = 20002,
72 SwFrmKeyInputAlpha = 20004,
73 SwFrmKeyInputNoAlpha = 20005,
74 SwFrmResize = 20006,
75 SwFrmMove = 20007,
78 template< typename charT, typename traits >
79 inline std::basic_ostream<charT, traits> & operator <<(
80 std::basic_ostream<charT, traits> & stream, const SvMacroItemId& id )
82 switch(id)
84 case SvMacroItemId::NONE: return stream << "NONE";
85 case SvMacroItemId::HtmlOnSubmitForm: return stream << "HtmlOnSubmitForm";
86 case SvMacroItemId::HtmlOnResetForm: return stream << "HtmlOnResetForm";
87 case SvMacroItemId::HtmlOnGetFocus: return stream << "HtmlOnGetFocus";
88 case SvMacroItemId::HtmlOnLoseFocus: return stream << "HtmlOnLoseFocus";
89 case SvMacroItemId::HtmlOnClick: return stream << "HtmlOnClick";
90 case SvMacroItemId::HtmlOnClickItem: return stream << "HtmlOnClickItem";
91 case SvMacroItemId::HtmlOnChange: return stream << "HtmlOnChange";
92 case SvMacroItemId::HtmlOnSelect: return stream << "HtmlOnSelect";
93 case SvMacroItemId::OpenDoc: return stream << "OpenDoc";
94 case SvMacroItemId::PrepareCloseDoc: return stream << "PrepareCloseDoc";
95 case SvMacroItemId::ActivateDoc: return stream << "ActivateDoc";
96 case SvMacroItemId::DeactivateDoc: return stream << "DeactivateDoc";
97 case SvMacroItemId::OnMouseOver: return stream << "OnMouseOver";
98 case SvMacroItemId::OnClick: return stream << "OnClick";
99 case SvMacroItemId::OnMouseOut: return stream << "OnMouseOut";
100 case SvMacroItemId::OnImageLoadDone: return stream << "OnImageLoadDone";
101 case SvMacroItemId::OnImageLoadCancel: return stream << "OnImageLoadCancel";
102 case SvMacroItemId::OnImageLoadError: return stream << "OnImageLoadError";
103 case SvMacroItemId::SwObjectSelect: return stream << "SwObjectSelect";
104 case SvMacroItemId::SwStartInsGlossary: return stream << "SwStartInsGlossary";
105 case SvMacroItemId::SwEndInsGlossary: return stream << "SwEndInsGlossary";
106 case SvMacroItemId::SwFrmKeyInputAlpha: return stream << "SwFrmKeyInputAlpha";
107 case SvMacroItemId::SwFrmKeyInputNoAlpha: return stream << "SwFrmKeyInputNoAlpha";
108 case SvMacroItemId::SwFrmResize: return stream << "SwFrmResize";
109 case SvMacroItemId::SwFrmMove: return stream << "SwFrmMove";
110 default: return stream << "unk(" << std::to_string(int(id)) << ")";
114 class SfxObjectShell;
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 SfxObjectShell* pObjShell;
195 OUString aEventName;
196 SfxEventHintId nEventId;
198 public:
199 SfxEventHint( SfxEventHintId nId, OUString aName, SfxObjectShell *pObj )
200 : pObjShell(pObj),
201 aEventName(std::move(aName)),
202 nEventId(nId)
205 SfxEventHintId GetEventId() const
206 { return nEventId; }
208 const OUString& GetEventName() const
209 { return aEventName; }
211 SfxObjectShell* GetObjShell() const
212 { return pObjShell; }
216 class SFX2_DLLPUBLIC SfxViewEventHint : public SfxEventHint
218 css::uno::Reference< css::frame::XController2 > xViewController;
220 public:
221 SfxViewEventHint( SfxEventHintId nId, const OUString& aName, SfxObjectShell *pObj, const css::uno::Reference< css::frame::XController >& xController )
222 : SfxEventHint( nId, aName, pObj )
223 , xViewController( xController, css::uno::UNO_QUERY )
226 SfxViewEventHint( SfxEventHintId nId, const OUString& aName, SfxObjectShell *pObj, css::uno::Reference< css::frame::XController2 > xController )
227 : SfxEventHint( nId, aName, pObj )
228 , xViewController(std::move( xController ))
231 const css::uno::Reference< css::frame::XController2 >& GetController() const
232 { return xViewController; }
235 class SfxPrintingHint final : public SfxViewEventHint
237 css::view::PrintableState mnPrintableState;
238 css::uno::Sequence < css::beans::PropertyValue > aOpts;
239 public:
240 SfxPrintingHint(
241 css::view::PrintableState nState,
242 const css::uno::Sequence < css::beans::PropertyValue >& rOpts,
243 SfxObjectShell *pObj,
244 const css::uno::Reference< css::frame::XController2 >& xController )
245 : SfxViewEventHint(
246 SfxEventHintId::PrintDoc,
247 GlobalEventConfig::GetEventName( GlobalEventId::PRINTDOC ),
248 pObj,
249 xController )
250 , mnPrintableState( nState )
251 , aOpts( rOpts )
254 SfxPrintingHint( css::view::PrintableState nState )
255 : SfxViewEventHint(
256 SfxEventHintId::PrintDoc,
257 GlobalEventConfig::GetEventName( GlobalEventId::PRINTDOC ),
258 nullptr,
259 css::uno::Reference< css::frame::XController >() )
260 , mnPrintableState( nState )
263 css::view::PrintableState GetWhich() const { return mnPrintableState; }
264 const css::uno::Sequence < css::beans::PropertyValue >& GetOptions() const { return aOpts; }
267 #endif
269 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */