Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef _SVTOOLS_STATUSBARCONTROLLER_HXX
30 : : #define _SVTOOLS_STATUSBARCONTROLLER_HXX
31 : :
32 : : #include "svtools/svtdllapi.h"
33 : : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
34 : : #include <com/sun/star/lang/XInitialization.hpp>
35 : : #include <com/sun/star/util/XUpdatable.hpp>
36 : : #include <com/sun/star/frame/XFrame.hpp>
37 : : #include <com/sun/star/frame/XDispatch.hpp>
38 : : #include <com/sun/star/frame/XStatusListener.hpp>
39 : : #include <com/sun/star/frame/XStatusbarController.hpp>
40 : : #include <com/sun/star/util/XURLTransformer.hpp>
41 : : #include <com/sun/star/frame/XLayoutManager.hpp>
42 : : #include <cppuhelper/weak.hxx>
43 : : #include <cppuhelper/interfacecontainer.hxx>
44 : : #include <comphelper/broadcasthelper.hxx>
45 : :
46 : : #include <boost/unordered_map.hpp>
47 : :
48 : : #include <tools/gen.hxx>
49 : :
50 : : namespace svt
51 : : {
52 : :
53 : : class SVT_DLLPUBLIC StatusbarController : public ::com::sun::star::frame::XStatusListener,
54 : : public ::com::sun::star::frame::XStatusbarController,
55 : : public ::com::sun::star::lang::XInitialization,
56 : : public ::com::sun::star::util::XUpdatable,
57 : : public ::com::sun::star::lang::XComponent,
58 : : public ::comphelper::OBaseMutex,
59 : : public ::cppu::OWeakObject
60 : : {
61 : : public:
62 : : StatusbarController( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rServiceManager,
63 : : const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame,
64 : : const rtl::OUString& aCommandURL,
65 : : unsigned short nID );
66 : : StatusbarController();
67 : : virtual ~StatusbarController();
68 : :
69 : : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > getFrameInterface() const;
70 : : ::com::sun::star::uno::Reference< ::com::sun::star::util::XURLTransformer > getURLTransformer() const;
71 : :
72 : : ::Rectangle getControlRect() const;
73 : :
74 : : // XInterface
75 : : virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) throw (::com::sun::star::uno::RuntimeException);
76 : : virtual void SAL_CALL acquire() throw ();
77 : : virtual void SAL_CALL release() throw ();
78 : :
79 : : // XInitialization
80 : : virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
81 : :
82 : : // XUpdatable
83 : : virtual void SAL_CALL update() throw (::com::sun::star::uno::RuntimeException);
84 : :
85 : : // XComponent
86 : : virtual void SAL_CALL dispose() throw (::com::sun::star::uno::RuntimeException);
87 : : virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
88 : : virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
89 : :
90 : : // XEventListener
91 : : virtual void SAL_CALL disposing( const com::sun::star::lang::EventObject& Source ) throw ( ::com::sun::star::uno::RuntimeException );
92 : :
93 : : // XStatusListener
94 : : virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException );
95 : :
96 : : // XStatusbarController
97 : : virtual ::sal_Bool SAL_CALL mouseButtonDown( const ::com::sun::star::awt::MouseEvent& aMouseEvent ) throw (::com::sun::star::uno::RuntimeException);
98 : : virtual ::sal_Bool SAL_CALL mouseMove( const ::com::sun::star::awt::MouseEvent& aMouseEvent ) throw (::com::sun::star::uno::RuntimeException);
99 : : virtual ::sal_Bool SAL_CALL mouseButtonUp( const ::com::sun::star::awt::MouseEvent& aMouseEvent ) throw (::com::sun::star::uno::RuntimeException);
100 : : virtual void SAL_CALL command( const ::com::sun::star::awt::Point& aPos,
101 : : ::sal_Int32 nCommand,
102 : : ::sal_Bool bMouseEvent,
103 : : const ::com::sun::star::uno::Any& aData ) throw (::com::sun::star::uno::RuntimeException);
104 : : virtual void SAL_CALL paint( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XGraphics >& xGraphics,
105 : : const ::com::sun::star::awt::Rectangle& rOutputRectangle,
106 : : ::sal_Int32 nItemId, ::sal_Int32 nStyle ) throw (::com::sun::star::uno::RuntimeException);
107 : : virtual void SAL_CALL click() throw (::com::sun::star::uno::RuntimeException);
108 : : virtual void SAL_CALL doubleClick() throw (::com::sun::star::uno::RuntimeException);
109 : :
110 : : protected:
111 : 53652 : struct Listener
112 : : {
113 : 15666 : Listener( const ::com::sun::star::util::URL& rURL, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch >& rDispatch ) :
114 : 15666 : aURL( rURL ), xDispatch( rDispatch ) {}
115 : :
116 : : ::com::sun::star::util::URL aURL;
117 : : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > xDispatch;
118 : : };
119 : :
120 : : typedef ::boost::unordered_map< ::rtl::OUString,
121 : : com::sun::star::uno::Reference< com::sun::star::frame::XDispatch >,
122 : : ::rtl::OUStringHash,
123 : : ::std::equal_to< ::rtl::OUString > > URLToDispatchMap;
124 : :
125 : : // methods to support status forwarder, known by the old sfx2 toolbox controller implementation
126 : : void addStatusListener( const rtl::OUString& aCommandURL );
127 : : void bindListener();
128 : :
129 : : // execute methods
130 : : // execute bound status bar controller command/execute various commands
131 : : void execute( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArgs );
132 : : void execute( const rtl::OUString& aCommand, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArgs );
133 : :
134 : : sal_Bool m_bInitialized : 1,
135 : : m_bDisposed : 1;
136 : : unsigned short m_nID;
137 : : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > m_xFrame;
138 : : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > m_xParentWindow;
139 : : ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xServiceManager;
140 : : rtl::OUString m_aCommandURL;
141 : : URLToDispatchMap m_aListenerMap;
142 : : ::cppu::OMultiTypeInterfaceContainerHelper m_aListenerContainer; /// container for ALL Listener
143 : : mutable ::com::sun::star::uno::Reference< ::com::sun::star::util::XURLTransformer > m_xURLTransformer;
144 : : };
145 : :
146 : : }
147 : :
148 : : #endif // _SVTOOLS_TOOLBOXCONTROLLER_HXX
149 : :
150 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|