Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef _SVTOOLS_STATUSBARCONTROLLER_HXX
21 : #define _SVTOOLS_STATUSBARCONTROLLER_HXX
22 :
23 : #include "svtools/svtdllapi.h"
24 : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
25 : #include <com/sun/star/lang/XInitialization.hpp>
26 : #include <com/sun/star/util/XUpdatable.hpp>
27 : #include <com/sun/star/frame/XFrame.hpp>
28 : #include <com/sun/star/frame/XDispatch.hpp>
29 : #include <com/sun/star/frame/XStatusListener.hpp>
30 : #include <com/sun/star/frame/XStatusbarController.hpp>
31 : #include <com/sun/star/util/XURLTransformer.hpp>
32 : #include <com/sun/star/frame/XLayoutManager.hpp>
33 : #include <cppuhelper/weak.hxx>
34 : #include <cppuhelper/interfacecontainer.hxx>
35 : #include <comphelper/broadcasthelper.hxx>
36 :
37 : #include <boost/unordered_map.hpp>
38 :
39 : #include <tools/gen.hxx>
40 :
41 : namespace svt
42 : {
43 :
44 : class SVT_DLLPUBLIC StatusbarController : public ::com::sun::star::frame::XStatusListener,
45 : public ::com::sun::star::frame::XStatusbarController,
46 : public ::com::sun::star::lang::XInitialization,
47 : public ::com::sun::star::util::XUpdatable,
48 : public ::com::sun::star::lang::XComponent,
49 : public ::comphelper::OBaseMutex,
50 : public ::cppu::OWeakObject
51 : {
52 : public:
53 : StatusbarController( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rServiceManager,
54 : const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame,
55 : const rtl::OUString& aCommandURL,
56 : unsigned short nID );
57 : StatusbarController();
58 : virtual ~StatusbarController();
59 :
60 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > getFrameInterface() const;
61 : ::com::sun::star::uno::Reference< ::com::sun::star::util::XURLTransformer > getURLTransformer() const;
62 :
63 : ::Rectangle getControlRect() const;
64 :
65 : // XInterface
66 : virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) throw (::com::sun::star::uno::RuntimeException);
67 : virtual void SAL_CALL acquire() throw ();
68 : virtual void SAL_CALL release() throw ();
69 :
70 : // XInitialization
71 : 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);
72 :
73 : // XUpdatable
74 : virtual void SAL_CALL update() throw (::com::sun::star::uno::RuntimeException);
75 :
76 : // XComponent
77 : virtual void SAL_CALL dispose() throw (::com::sun::star::uno::RuntimeException);
78 : virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
79 : virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
80 :
81 : // XEventListener
82 : virtual void SAL_CALL disposing( const com::sun::star::lang::EventObject& Source ) throw ( ::com::sun::star::uno::RuntimeException );
83 :
84 : // XStatusListener
85 : virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException );
86 :
87 : // XStatusbarController
88 : virtual ::sal_Bool SAL_CALL mouseButtonDown( const ::com::sun::star::awt::MouseEvent& aMouseEvent ) throw (::com::sun::star::uno::RuntimeException);
89 : virtual ::sal_Bool SAL_CALL mouseMove( const ::com::sun::star::awt::MouseEvent& aMouseEvent ) throw (::com::sun::star::uno::RuntimeException);
90 : virtual ::sal_Bool SAL_CALL mouseButtonUp( const ::com::sun::star::awt::MouseEvent& aMouseEvent ) throw (::com::sun::star::uno::RuntimeException);
91 : virtual void SAL_CALL command( const ::com::sun::star::awt::Point& aPos,
92 : ::sal_Int32 nCommand,
93 : ::sal_Bool bMouseEvent,
94 : const ::com::sun::star::uno::Any& aData ) throw (::com::sun::star::uno::RuntimeException);
95 : virtual void SAL_CALL paint( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XGraphics >& xGraphics,
96 : const ::com::sun::star::awt::Rectangle& rOutputRectangle,
97 : ::sal_Int32 nItemId, ::sal_Int32 nStyle ) throw (::com::sun::star::uno::RuntimeException);
98 : virtual void SAL_CALL click() throw (::com::sun::star::uno::RuntimeException);
99 : virtual void SAL_CALL doubleClick() throw (::com::sun::star::uno::RuntimeException);
100 :
101 : protected:
102 0 : struct Listener
103 : {
104 0 : Listener( const ::com::sun::star::util::URL& rURL, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch >& rDispatch ) :
105 0 : aURL( rURL ), xDispatch( rDispatch ) {}
106 :
107 : ::com::sun::star::util::URL aURL;
108 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > xDispatch;
109 : };
110 :
111 : typedef ::boost::unordered_map< ::rtl::OUString,
112 : com::sun::star::uno::Reference< com::sun::star::frame::XDispatch >,
113 : ::rtl::OUStringHash,
114 : ::std::equal_to< ::rtl::OUString > > URLToDispatchMap;
115 :
116 : // methods to support status forwarder, known by the old sfx2 toolbox controller implementation
117 : void addStatusListener( const rtl::OUString& aCommandURL );
118 : void bindListener();
119 :
120 : // execute methods
121 : // execute bound status bar controller command/execute various commands
122 : void execute( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArgs );
123 : void execute( const rtl::OUString& aCommand, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArgs );
124 :
125 : sal_Bool m_bInitialized : 1,
126 : m_bDisposed : 1;
127 : unsigned short m_nID;
128 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > m_xFrame;
129 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > m_xParentWindow;
130 : ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xServiceManager;
131 : rtl::OUString m_aCommandURL;
132 : URLToDispatchMap m_aListenerMap;
133 : ::cppu::OMultiTypeInterfaceContainerHelper m_aListenerContainer; /// container for ALL Listener
134 : mutable ::com::sun::star::uno::Reference< ::com::sun::star::util::XURLTransformer > m_xURLTransformer;
135 : };
136 :
137 : }
138 :
139 : #endif // _SVTOOLS_TOOLBOXCONTROLLER_HXX
140 :
141 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|