merge the formfield patch from ooo-build
[ooovba.git] / svtools / inc / eventcfg.hxx
blobf5edb614030b8cf05e6459136251070fcf09d69e
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: eventcfg.hxx,v $
10 * $Revision: 1.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef _EVENTCFG_HXX
31 #define _EVENTCFG_HXX
33 #include "svtools/svldllapi.h"
34 #include <unotools/configitem.hxx>
35 #include <com/sun/star/document/XEventsSupplier.hpp>
36 #include <com/sun/star/container/XNameReplace.hpp>
37 #include <com/sun/star/frame/XFrame.hpp>
38 #include <cppuhelper/weakref.hxx>
39 #include <cppuhelper/implbase2.hxx>
40 #include <hash_map>
41 #include <vector>
43 #define STR_EVENT_STARTAPP 0
44 #define STR_EVENT_CLOSEAPP 1
45 #define STR_EVENT_DOCCREATED 2
46 #define STR_EVENT_CREATEDOC 3
47 #define STR_EVENT_LOADFINISHED 4
48 #define STR_EVENT_OPENDOC 5
49 #define STR_EVENT_PREPARECLOSEDOC 6
50 #define STR_EVENT_CLOSEDOC 7
51 #define STR_EVENT_SAVEDOC 8
52 #define STR_EVENT_SAVEDOCDONE 9
53 #define STR_EVENT_SAVEDOCFAILED 10
54 #define STR_EVENT_SAVEASDOC 11
55 #define STR_EVENT_SAVEASDOCDONE 12
56 #define STR_EVENT_SAVEASDOCFAILED 13
57 #define STR_EVENT_SAVETODOC 14
58 #define STR_EVENT_SAVETODOCDONE 15
59 #define STR_EVENT_SAVETODOCFAILED 16
60 #define STR_EVENT_ACTIVATEDOC 17
61 #define STR_EVENT_DEACTIVATEDOC 18
62 #define STR_EVENT_PRINTDOC 19
63 #define STR_EVENT_VIEWCREATED 20
64 #define STR_EVENT_PREPARECLOSEVIEW 21
65 #define STR_EVENT_CLOSEVIEW 22
66 #define STR_EVENT_MODIFYCHANGED 23
67 #define STR_EVENT_TITLECHANGED 24
68 #define STR_EVENT_VISAREACHANGED 25
69 #define STR_EVENT_MODECHANGED 26
70 #define STR_EVENT_STORAGECHANGED 27
72 typedef ::std::hash_map< ::rtl::OUString, ::rtl::OUString, ::rtl::OUStringHash, ::std::equal_to< ::rtl::OUString > > EventBindingHash;
73 typedef ::std::vector< ::com::sun::star::uno::WeakReference< ::com::sun::star::frame::XFrame > > FrameVector;
74 typedef ::std::vector< ::rtl::OUString > SupportedEventsVector;
76 class GlobalEventConfig_Impl : public utl::ConfigItem
78 EventBindingHash m_eventBindingHash;
79 FrameVector m_lFrames;
80 SupportedEventsVector m_supportedEvents;
82 void initBindingInfo();
84 public:
85 GlobalEventConfig_Impl( );
86 ~GlobalEventConfig_Impl( );
88 void EstablishFrameCallback(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame);
89 void Notify( const com::sun::star::uno::Sequence<rtl::OUString>& aPropertyNames);
90 void Commit();
92 ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameReplace > SAL_CALL getEvents( ) throw (::com::sun::star::uno::RuntimeException);
93 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);
94 ::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);
95 ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames( ) throw (::com::sun::star::uno::RuntimeException);
96 ::sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw (::com::sun::star::uno::RuntimeException);
97 ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw (::com::sun::star::uno::RuntimeException);
98 ::sal_Bool SAL_CALL hasElements( ) throw (::com::sun::star::uno::RuntimeException);
99 ::rtl::OUString GetEventName( sal_Int32 nID );
102 class SVL_DLLPUBLIC GlobalEventConfig:
103 public ::cppu::WeakImplHelper2 < ::com::sun::star::document::XEventsSupplier, ::com::sun::star::container::XNameReplace >
105 public:
106 GlobalEventConfig( );
107 ~GlobalEventConfig( );
108 static ::osl::Mutex& GetOwnStaticMutex();
110 void EstablishFrameCallback(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame);
111 ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameReplace > SAL_CALL getEvents( ) throw (::com::sun::star::uno::RuntimeException);
112 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);
113 ::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);
114 ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames( ) throw (::com::sun::star::uno::RuntimeException);
115 ::sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw (::com::sun::star::uno::RuntimeException);
116 ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw (::com::sun::star::uno::RuntimeException);
117 ::sal_Bool SAL_CALL hasElements( ) throw (::com::sun::star::uno::RuntimeException);
118 static ::rtl::OUString GetEventName( sal_Int32 nID );
120 private:
121 static GlobalEventConfig_Impl* m_pImpl;
122 static sal_Int32 m_nRefCount;
125 #endif // _EVENTCFG_HXX