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 .
22 #include "unotools/unotoolsdllapi.h"
23 #include <unotools/configitem.hxx>
24 #include <com/sun/star/document/XEventsSupplier.hpp>
25 #include <com/sun/star/container/XNameReplace.hpp>
26 #include <com/sun/star/frame/XFrame.hpp>
27 #include <cppuhelper/weakref.hxx>
28 #include <cppuhelper/implbase2.hxx>
29 #include <boost/unordered_map.hpp>
32 #define STR_EVENT_STARTAPP 0
33 #define STR_EVENT_CLOSEAPP 1
34 #define STR_EVENT_DOCCREATED 2
35 #define STR_EVENT_CREATEDOC 3
36 #define STR_EVENT_LOADFINISHED 4
37 #define STR_EVENT_OPENDOC 5
38 #define STR_EVENT_PREPARECLOSEDOC 6
39 #define STR_EVENT_CLOSEDOC 7
40 #define STR_EVENT_SAVEDOC 8
41 #define STR_EVENT_SAVEDOCDONE 9
42 #define STR_EVENT_SAVEDOCFAILED 10
43 #define STR_EVENT_SAVEASDOC 11
44 #define STR_EVENT_SAVEASDOCDONE 12
45 #define STR_EVENT_SAVEASDOCFAILED 13
46 #define STR_EVENT_SAVETODOC 14
47 #define STR_EVENT_SAVETODOCDONE 15
48 #define STR_EVENT_SAVETODOCFAILED 16
49 #define STR_EVENT_ACTIVATEDOC 17
50 #define STR_EVENT_DEACTIVATEDOC 18
51 #define STR_EVENT_PRINTDOC 19
52 #define STR_EVENT_VIEWCREATED 20
53 #define STR_EVENT_PREPARECLOSEVIEW 21
54 #define STR_EVENT_CLOSEVIEW 22
55 #define STR_EVENT_MODIFYCHANGED 23
56 #define STR_EVENT_TITLECHANGED 24
57 #define STR_EVENT_VISAREACHANGED 25
58 #define STR_EVENT_MODECHANGED 26
59 #define STR_EVENT_STORAGECHANGED 27
61 typedef ::boost::unordered_map
< OUString
, OUString
, OUStringHash
, ::std::equal_to
< OUString
> > EventBindingHash
;
62 typedef ::std::vector
< ::com::sun::star::uno::WeakReference
< ::com::sun::star::frame::XFrame
> > FrameVector
;
63 typedef ::std::vector
< OUString
> SupportedEventsVector
;
65 class GlobalEventConfig_Impl
: public utl::ConfigItem
67 EventBindingHash m_eventBindingHash
;
68 FrameVector m_lFrames
;
69 SupportedEventsVector m_supportedEvents
;
71 void initBindingInfo();
74 GlobalEventConfig_Impl( );
75 ~GlobalEventConfig_Impl( );
77 void Notify( const com::sun::star::uno::Sequence
<OUString
>& aPropertyNames
);
80 void SAL_CALL
replaceByName( const OUString
& aName
, const ::com::sun::star::uno::Any
& aElement
) throw (::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::container::NoSuchElementException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
81 ::com::sun::star::uno::Any SAL_CALL
getByName( const OUString
& aName
) throw (::com::sun::star::container::NoSuchElementException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
82 ::com::sun::star::uno::Sequence
< OUString
> SAL_CALL
getElementNames( ) throw (::com::sun::star::uno::RuntimeException
);
83 ::sal_Bool SAL_CALL
hasByName( const OUString
& aName
) throw (::com::sun::star::uno::RuntimeException
);
84 ::com::sun::star::uno::Type SAL_CALL
getElementType( ) throw (::com::sun::star::uno::RuntimeException
);
85 ::sal_Bool SAL_CALL
hasElements( ) throw (::com::sun::star::uno::RuntimeException
);
86 OUString
GetEventName( sal_Int32 nID
);
89 class UNOTOOLS_DLLPUBLIC GlobalEventConfig
:
90 public ::cppu::WeakImplHelper2
< ::com::sun::star::document::XEventsSupplier
, ::com::sun::star::container::XNameReplace
>
94 ~GlobalEventConfig( );
95 static ::osl::Mutex
& GetOwnStaticMutex();
97 ::com::sun::star::uno::Reference
< ::com::sun::star::container::XNameReplace
> SAL_CALL
getEvents( ) throw (::com::sun::star::uno::RuntimeException
);
98 void SAL_CALL
replaceByName( const OUString
& aName
, const ::com::sun::star::uno::Any
& aElement
) throw (::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::container::NoSuchElementException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
99 ::com::sun::star::uno::Any SAL_CALL
getByName( const OUString
& aName
) throw (::com::sun::star::container::NoSuchElementException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
100 ::com::sun::star::uno::Sequence
< OUString
> SAL_CALL
getElementNames( ) throw (::com::sun::star::uno::RuntimeException
);
101 ::sal_Bool SAL_CALL
hasByName( const OUString
& aName
) throw (::com::sun::star::uno::RuntimeException
);
102 ::com::sun::star::uno::Type SAL_CALL
getElementType( ) throw (::com::sun::star::uno::RuntimeException
);
103 ::sal_Bool SAL_CALL
hasElements( ) throw (::com::sun::star::uno::RuntimeException
);
104 static OUString
GetEventName( sal_Int32 nID
);
107 static GlobalEventConfig_Impl
* m_pImpl
;
108 static sal_Int32 m_nRefCount
;
111 #endif // _EVENTCFG_HXX
113 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */