xref: /AOO41X/main/unotools/inc/unotools/eventcfg.hxx (revision bae3752ec30c258ca902793e4eea3c818b0bcaad)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _EVENTCFG_HXX
24 #define _EVENTCFG_HXX
25 
26 #include "unotools/unotoolsdllapi.h"
27 #include <unotools/configitem.hxx>
28 #include <com/sun/star/document/XEventsSupplier.hpp>
29 #include <com/sun/star/container/XNameReplace.hpp>
30 #include <com/sun/star/frame/XFrame.hpp>
31 #include <cppuhelper/weakref.hxx>
32 #include <cppuhelper/implbase2.hxx>
33 #include <hash_map>
34 #include <vector>
35 
36 #define STR_EVENT_STARTAPP                   0
37 #define STR_EVENT_CLOSEAPP                   1
38 #define STR_EVENT_DOCCREATED                 2
39 #define STR_EVENT_CREATEDOC                  3
40 #define STR_EVENT_LOADFINISHED               4
41 #define STR_EVENT_OPENDOC                    5
42 #define STR_EVENT_PREPARECLOSEDOC            6
43 #define STR_EVENT_CLOSEDOC                   7
44 #define STR_EVENT_SAVEDOC                    8
45 #define STR_EVENT_SAVEDOCDONE                9
46 #define STR_EVENT_SAVEDOCFAILED             10
47 #define STR_EVENT_SAVEASDOC                 11
48 #define STR_EVENT_SAVEASDOCDONE             12
49 #define STR_EVENT_SAVEASDOCFAILED           13
50 #define STR_EVENT_SAVETODOC                 14
51 #define STR_EVENT_SAVETODOCDONE             15
52 #define STR_EVENT_SAVETODOCFAILED           16
53 #define STR_EVENT_ACTIVATEDOC               17
54 #define STR_EVENT_DEACTIVATEDOC             18
55 #define STR_EVENT_PRINTDOC                  19
56 #define STR_EVENT_VIEWCREATED               20
57 #define STR_EVENT_PREPARECLOSEVIEW          21
58 #define STR_EVENT_CLOSEVIEW                 22
59 #define STR_EVENT_MODIFYCHANGED             23
60 #define STR_EVENT_TITLECHANGED              24
61 #define STR_EVENT_VISAREACHANGED            25
62 #define STR_EVENT_MODECHANGED               26
63 #define STR_EVENT_STORAGECHANGED            27
64 
65 typedef ::std::hash_map< ::rtl::OUString, ::rtl::OUString, ::rtl::OUStringHash, ::std::equal_to< ::rtl::OUString > > EventBindingHash;
66 typedef ::std::vector< ::com::sun::star::uno::WeakReference< ::com::sun::star::frame::XFrame > > FrameVector;
67 typedef ::std::vector< ::rtl::OUString > SupportedEventsVector;
68 
69 class GlobalEventConfig_Impl : public utl::ConfigItem
70 {
71     EventBindingHash m_eventBindingHash;
72     FrameVector m_lFrames;
73     SupportedEventsVector m_supportedEvents;
74 
75     void initBindingInfo();
76 
77 public:
78     GlobalEventConfig_Impl( );
79     ~GlobalEventConfig_Impl( );
80 
81     void EstablishFrameCallback(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame);
82     void            Notify( const com::sun::star::uno::Sequence<rtl::OUString>& aPropertyNames);
83     void            Commit();
84 
85     ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameReplace > SAL_CALL getEvents(  ) throw (::com::sun::star::uno::RuntimeException);
86     void SAL_CALL replaceByName( const ::rtl::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);
87     ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
88     ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames(  ) throw (::com::sun::star::uno::RuntimeException);
89     ::sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw (::com::sun::star::uno::RuntimeException);
90     ::com::sun::star::uno::Type SAL_CALL getElementType(  ) throw (::com::sun::star::uno::RuntimeException);
91     ::sal_Bool SAL_CALL hasElements(  ) throw (::com::sun::star::uno::RuntimeException);
92     ::rtl::OUString GetEventName( sal_Int32 nID );
93 };
94 
95 class UNOTOOLS_DLLPUBLIC GlobalEventConfig:
96         public ::cppu::WeakImplHelper2 < ::com::sun::star::document::XEventsSupplier, ::com::sun::star::container::XNameReplace >
97 {
98     public:
99         GlobalEventConfig( );
100         ~GlobalEventConfig( );
101         static ::osl::Mutex& GetOwnStaticMutex();
102 
103         void EstablishFrameCallback(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame);
104         ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameReplace > SAL_CALL getEvents(  ) throw (::com::sun::star::uno::RuntimeException);
105         void SAL_CALL replaceByName( const ::rtl::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);
106         ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
107         ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames(  ) throw (::com::sun::star::uno::RuntimeException);
108         ::sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw (::com::sun::star::uno::RuntimeException);
109         ::com::sun::star::uno::Type SAL_CALL getElementType(  ) throw (::com::sun::star::uno::RuntimeException);
110         ::sal_Bool SAL_CALL hasElements(  ) throw (::com::sun::star::uno::RuntimeException);
111         static ::rtl::OUString GetEventName( sal_Int32 nID );
112 
113     private:
114         static GlobalEventConfig_Impl* m_pImpl;
115         static sal_Int32 m_nRefCount;
116 };
117 
118 #endif // _EVENTCFG_HXX
119