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 .
19 #ifndef INCLUDED_SFX2_EVENT_HXX
20 #define INCLUDED_SFX2_EVENT_HXX
22 #include <sal/config.h>
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>
38 namespace com::sun::star::beans
{ struct PropertyValue
; }
41 these values get stored in streams in a 16-bit value
43 enum class SvMacroItemId
: sal_uInt16
{
46 // used by SwHTMLForm_Impl
56 // used by SwHTMLParser
62 // Events for Controls etc.
67 OnImageLoadDone
= 10000,
68 OnImageLoadCancel
= 10001,
69 OnImageLoadError
= 10002,
71 SwObjectSelect
= 20000,
72 SwStartInsGlossary
= 20001,
73 SwEndInsGlossary
= 20002,
74 SwFrmKeyInputAlpha
= 20004,
75 SwFrmKeyInputNoAlpha
= 20005,
80 template< typename charT
, typename traits
>
81 inline std::basic_ostream
<charT
, traits
> & operator <<(
82 std::basic_ostream
<charT
, traits
> & stream
, const SvMacroItemId
& 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
{
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
)
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
;
196 SfxEventHintId nEventId
;
199 SfxEventHint(SfxEventHintId nId
, OUString aName
, SfxObjectShell
*pObj
)
200 : SfxHint(SfxHintId::ThisIsAnSfxEventHint
)
202 , aEventName(std::move(aName
))
207 SfxEventHintId
GetEventId() const
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
;
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
;
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
)
247 SfxEventHintId::PrintDoc
,
248 GlobalEventConfig::GetEventName( GlobalEventId::PRINTDOC
),
251 , mnPrintableState( nState
)
255 SfxPrintingHint( css::view::PrintableState nState
)
257 SfxEventHintId::PrintDoc
,
258 GlobalEventConfig::GetEventName( GlobalEventId::PRINTDOC
),
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
; }
270 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */