connectivity: add neutral context parser
[LibreOffice.git] / include / sfx2 / event.hxx
blob9f7cd304a038bb59714457b8382c4a870247ca9d
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>
35 namespace com::sun::star::beans { struct PropertyValue; }
37 /**
38 these values get stored in streams in a 16-bit value
40 enum class SvMacroItemId : sal_uInt16 {
41 NONE = 0,
43 // used by SwHTMLForm_Impl
44 HtmlOnSubmitForm,
45 HtmlOnResetForm,
46 HtmlOnGetFocus,
47 HtmlOnLoseFocus,
48 HtmlOnClick,
49 HtmlOnClickItem,
50 HtmlOnChange,
51 HtmlOnSelect,
53 // used by SwHTMLParser
54 OpenDoc,
55 PrepareCloseDoc,
56 ActivateDoc,
57 DeactivateDoc,
59 // Events for Controls etc.
60 OnMouseOver = 5100,
61 OnClick = 5101,
62 OnMouseOut = 5102,
64 OnImageLoadDone = 10000,
65 OnImageLoadCancel = 10001,
66 OnImageLoadError = 10002,
68 SwObjectSelect = 20000,
69 SwStartInsGlossary = 20001,
70 SwEndInsGlossary = 20002,
71 SwFrmKeyInputAlpha = 20004,
72 SwFrmKeyInputNoAlpha = 20005,
73 SwFrmResize = 20006,
74 SwFrmMove = 20007,
77 template< typename charT, typename traits >
78 inline std::basic_ostream<charT, traits> & operator <<(
79 std::basic_ostream<charT, traits> & stream, const SvMacroItemId& id )
81 switch(id)
83 case SvMacroItemId::NONE: return stream << "NONE";
84 case SvMacroItemId::HtmlOnSubmitForm: return stream << "HtmlOnSubmitForm";
85 case SvMacroItemId::HtmlOnResetForm: return stream << "HtmlOnResetForm";
86 case SvMacroItemId::HtmlOnGetFocus: return stream << "HtmlOnGetFocus";
87 case SvMacroItemId::HtmlOnLoseFocus: return stream << "HtmlOnLoseFocus";
88 case SvMacroItemId::HtmlOnClick: return stream << "HtmlOnClick";
89 case SvMacroItemId::HtmlOnClickItem: return stream << "HtmlOnClickItem";
90 case SvMacroItemId::HtmlOnChange: return stream << "HtmlOnChange";
91 case SvMacroItemId::HtmlOnSelect: return stream << "HtmlOnSelect";
92 case SvMacroItemId::OpenDoc: return stream << "OpenDoc";
93 case SvMacroItemId::PrepareCloseDoc: return stream << "PrepareCloseDoc";
94 case SvMacroItemId::ActivateDoc: return stream << "ActivateDoc";
95 case SvMacroItemId::DeactivateDoc: return stream << "DeactivateDoc";
96 case SvMacroItemId::OnMouseOver: return stream << "OnMouseOver";
97 case SvMacroItemId::OnClick: return stream << "OnClick";
98 case SvMacroItemId::OnMouseOut: return stream << "OnMouseOut";
99 case SvMacroItemId::OnImageLoadDone: return stream << "OnImageLoadDone";
100 case SvMacroItemId::OnImageLoadCancel: return stream << "OnImageLoadCancel";
101 case SvMacroItemId::OnImageLoadError: return stream << "OnImageLoadError";
102 case SvMacroItemId::SwObjectSelect: return stream << "SwObjectSelect";
103 case SvMacroItemId::SwStartInsGlossary: return stream << "SwStartInsGlossary";
104 case SvMacroItemId::SwEndInsGlossary: return stream << "SwEndInsGlossary";
105 case SvMacroItemId::SwFrmKeyInputAlpha: return stream << "SwFrmKeyInputAlpha";
106 case SvMacroItemId::SwFrmKeyInputNoAlpha: return stream << "SwFrmKeyInputNoAlpha";
107 case SvMacroItemId::SwFrmResize: return stream << "SwFrmResize";
108 case SvMacroItemId::SwFrmMove: return stream << "SwFrmMove";
109 default: return stream << "unk(" << std::to_string(int(id)) << ")";
113 class SfxObjectShell;
115 enum class SfxEventHintId {
116 NONE = 0,
117 ActivateDoc,
118 CloseDoc,
119 CloseView,
120 CreateDoc,
121 DeactivateDoc,
122 DocCreated,
123 LoadFinished,
124 ModifyChanged,
125 OpenDoc,
126 PrepareCloseDoc,
127 PrepareCloseView,
128 PrintDoc,
129 SaveAsDoc,
130 SaveAsDocDone,
131 SaveAsDocFailed,
132 SaveDoc,
133 SaveDocDone,
134 SaveDocFailed,
135 SaveToDoc,
136 SaveToDocDone,
137 SaveToDocFailed,
138 StorageChanged,
139 ViewCreated,
140 VisAreaChanged,
141 // SW events
142 SwMailMerge,
143 SwMailMergeEnd,
144 SwEventPageCount,
145 SwEventFieldMerge,
146 SwEventFieldMergeFinished,
147 SwEventLayoutFinished,
150 template< typename charT, typename traits >
151 inline std::basic_ostream<charT, traits> & operator <<(
152 std::basic_ostream<charT, traits> & stream, const SfxEventHintId& id )
154 switch(id)
156 case SfxEventHintId::NONE: return stream << "NONE";
157 case SfxEventHintId::ActivateDoc: return stream << "ActivateDoc";
158 case SfxEventHintId::CloseDoc: return stream << "CloseDoc";
159 case SfxEventHintId::CloseView: return stream << "CloseView";
160 case SfxEventHintId::CreateDoc: return stream << "CreateDoc";
161 case SfxEventHintId::DeactivateDoc: return stream << "DeactivateDoc";
162 case SfxEventHintId::DocCreated: return stream << "DocCreated";
163 case SfxEventHintId::LoadFinished: return stream << "LoadFinished";
164 case SfxEventHintId::ModifyChanged: return stream << "ModifyChanged";
165 case SfxEventHintId::OpenDoc: return stream << "OpenDoc";
166 case SfxEventHintId::PrepareCloseDoc: return stream << "PrepareCloseDoc";
167 case SfxEventHintId::PrepareCloseView: return stream << "PrepareCloseView";
168 case SfxEventHintId::PrintDoc: return stream << "PrintDoc";
169 case SfxEventHintId::SaveAsDoc: return stream << "SaveAsDoc";
170 case SfxEventHintId::SaveAsDocDone: return stream << "SaveAsDocDone";
171 case SfxEventHintId::SaveAsDocFailed: return stream << "SaveAsDocFailed";
172 case SfxEventHintId::SaveDoc: return stream << "SaveDoc";
173 case SfxEventHintId::SaveDocDone: return stream << "SaveDocDone";
174 case SfxEventHintId::SaveDocFailed: return stream << "SaveDocFailed";
175 case SfxEventHintId::SaveToDoc: return stream << "SaveToDoc";
176 case SfxEventHintId::SaveToDocDone: return stream << "SaveToDocDone";
177 case SfxEventHintId::SaveToDocFailed: return stream << "SaveToDocFailed";
178 case SfxEventHintId::StorageChanged: return stream << "StorageChanged";
179 case SfxEventHintId::ViewCreated: return stream << "ViewCreated";
180 case SfxEventHintId::VisAreaChanged: return stream << "VisAreaChanged";
181 case SfxEventHintId::SwMailMerge: return stream << "SwMailMerge";
182 case SfxEventHintId::SwMailMergeEnd: return stream << "SwMailMergeEnd";
183 case SfxEventHintId::SwEventPageCount: return stream << "SwEventPageCount";
184 case SfxEventHintId::SwEventFieldMerge: return stream << "SwEventFieldMerge";
185 case SfxEventHintId::SwEventFieldMergeFinished: return stream << "SwEventFieldMergeFinished";
186 case SfxEventHintId::SwEventLayoutFinished: return stream << "SwEventLayoutFinished";
187 default: return stream << "unk(" << std::to_string(int(id)) << ")";
191 class SFX2_DLLPUBLIC SfxEventHint : public SfxHint
193 SfxObjectShell* pObjShell;
194 OUString aEventName;
195 SfxEventHintId nEventId;
197 public:
198 SfxEventHint( SfxEventHintId nId, const OUString& aName, SfxObjectShell *pObj )
199 : pObjShell(pObj),
200 aEventName(aName),
201 nEventId(nId)
204 SfxEventHintId GetEventId() const
205 { return nEventId; }
207 const OUString& GetEventName() const
208 { return aEventName; }
210 SfxObjectShell* GetObjShell() const
211 { return pObjShell; }
215 class SFX2_DLLPUBLIC SfxViewEventHint : public SfxEventHint
217 css::uno::Reference< css::frame::XController2 > xViewController;
219 public:
220 SfxViewEventHint( SfxEventHintId nId, const OUString& aName, SfxObjectShell *pObj, const css::uno::Reference< css::frame::XController >& xController )
221 : SfxEventHint( nId, aName, pObj )
222 , xViewController( xController, css::uno::UNO_QUERY )
225 SfxViewEventHint( SfxEventHintId nId, const OUString& aName, SfxObjectShell *pObj, const css::uno::Reference< css::frame::XController2 >& xController )
226 : SfxEventHint( nId, aName, pObj )
227 , xViewController( xController )
230 const css::uno::Reference< css::frame::XController2 >& GetController() const
231 { return xViewController; }
234 class SfxPrintingHint final : public SfxViewEventHint
236 css::view::PrintableState mnPrintableState;
237 css::uno::Sequence < css::beans::PropertyValue > aOpts;
238 public:
239 SfxPrintingHint(
240 css::view::PrintableState nState,
241 const css::uno::Sequence < css::beans::PropertyValue >& rOpts,
242 SfxObjectShell *pObj,
243 const css::uno::Reference< css::frame::XController2 >& xController )
244 : SfxViewEventHint(
245 SfxEventHintId::PrintDoc,
246 GlobalEventConfig::GetEventName( GlobalEventId::PRINTDOC ),
247 pObj,
248 xController )
249 , mnPrintableState( nState )
250 , aOpts( rOpts )
253 SfxPrintingHint( css::view::PrintableState nState )
254 : SfxViewEventHint(
255 SfxEventHintId::PrintDoc,
256 GlobalEventConfig::GetEventName( GlobalEventId::PRINTDOC ),
257 nullptr,
258 css::uno::Reference< css::frame::XController >() )
259 , mnPrintableState( nState )
262 css::view::PrintableState GetWhich() const { return mnPrintableState; }
263 const css::uno::Sequence < css::beans::PropertyValue >& GetOptions() const { return aOpts; }
266 #endif
268 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */