1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir #ifndef __FRAMEWORK_DISPATCH_HELPAGENTDISPATCHER_HXX_ 29*cdf0e10cSrcweir #define __FRAMEWORK_DISPATCH_HELPAGENTDISPATCHER_HXX_ 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include <threadhelp/threadhelpbase.hxx> 32*cdf0e10cSrcweir #include <macros/xinterface.hxx> 33*cdf0e10cSrcweir #include <macros/xtypeprovider.hxx> 34*cdf0e10cSrcweir #include <com/sun/star/frame/XDispatch.hpp> 35*cdf0e10cSrcweir #include <com/sun/star/frame/XFrame.hpp> 36*cdf0e10cSrcweir #include <com/sun/star/awt/XWindowListener.hpp> 37*cdf0e10cSrcweir #include <com/sun/star/awt/XWindow.hpp> 38*cdf0e10cSrcweir #include <svtools/helpagentwindow.hxx> 39*cdf0e10cSrcweir #include <vcl/timer.hxx> 40*cdf0e10cSrcweir #include <vcl/evntpost.hxx> 41*cdf0e10cSrcweir #include <cppuhelper/weak.hxx> 42*cdf0e10cSrcweir 43*cdf0e10cSrcweir //........................................................................ 44*cdf0e10cSrcweir namespace framework 45*cdf0e10cSrcweir { 46*cdf0e10cSrcweir 47*cdf0e10cSrcweir // define css alias ... and undefine it at the end of this file !!! 48*cdf0e10cSrcweir #ifdef css 49*cdf0e10cSrcweir #error "I tried to use css as namespace define inside non exported header ... but it was already defined by somwhere else. .-)" 50*cdf0e10cSrcweir #else 51*cdf0e10cSrcweir #define css ::com::sun::star 52*cdf0e10cSrcweir #endif 53*cdf0e10cSrcweir 54*cdf0e10cSrcweir //........................................................................ 55*cdf0e10cSrcweir 56*cdf0e10cSrcweir class HelpAgentDispatcher : public css::lang::XTypeProvider 57*cdf0e10cSrcweir , public css::frame::XDispatch 58*cdf0e10cSrcweir , public css::awt::XWindowListener // => css::lang::XEventListener 59*cdf0e10cSrcweir , public ::svt::IHelpAgentCallback 60*cdf0e10cSrcweir , private ThreadHelpBase 61*cdf0e10cSrcweir , public ::cppu::OWeakObject 62*cdf0e10cSrcweir { 63*cdf0e10cSrcweir private: 64*cdf0e10cSrcweir 65*cdf0e10cSrcweir //--------------------------------------- 66*cdf0e10cSrcweir /// @short represent the current active help URL, which must be used to show the right help page 67*cdf0e10cSrcweir ::rtl::OUString m_sCurrentURL; 68*cdf0e10cSrcweir 69*cdf0e10cSrcweir //--------------------------------------- 70*cdf0e10cSrcweir /// @short parent of the agent window. 71*cdf0e10cSrcweir css::uno::Reference< css::awt::XWindow > m_xContainerWindow; 72*cdf0e10cSrcweir 73*cdf0e10cSrcweir //--------------------------------------- 74*cdf0e10cSrcweir /// @short the agent window itself (implemented in svtools) 75*cdf0e10cSrcweir css::uno::Reference< css::awt::XWindow > m_xAgentWindow; 76*cdf0e10cSrcweir 77*cdf0e10cSrcweir //--------------------------------------- 78*cdf0e10cSrcweir /// @short the timer for showing the agent window 79*cdf0e10cSrcweir Timer m_aTimer; 80*cdf0e10cSrcweir 81*cdf0e10cSrcweir //--------------------------------------- 82*cdf0e10cSrcweir /** @short hold this dispatcher alive till the timer was killed or expired! 83*cdf0e10cSrcweir @descr Because the vcl timer knows us by using a pointer ... and our instance is used 84*cdf0e10cSrcweir ref counted normaly it can happen that our reference goes down to 0 ... and the timer 85*cdf0e10cSrcweir runs into some trouble. So we hold us self alive till the timer could be stopped or expired. 86*cdf0e10cSrcweir */ 87*cdf0e10cSrcweir css::uno::Reference< css::uno::XInterface > m_xSelfHold; 88*cdf0e10cSrcweir 89*cdf0e10cSrcweir public: 90*cdf0e10cSrcweir 91*cdf0e10cSrcweir HelpAgentDispatcher(const css::uno::Reference< css::frame::XFrame >& xParentFrame); 92*cdf0e10cSrcweir 93*cdf0e10cSrcweir FWK_DECLARE_XINTERFACE 94*cdf0e10cSrcweir FWK_DECLARE_XTYPEPROVIDER 95*cdf0e10cSrcweir 96*cdf0e10cSrcweir // css::frame::XDispatch 97*cdf0e10cSrcweir virtual void SAL_CALL dispatch(const css::util::URL& sURL , 98*cdf0e10cSrcweir const css::uno::Sequence< css::beans::PropertyValue >& lArgs) 99*cdf0e10cSrcweir throw(css::uno::RuntimeException); 100*cdf0e10cSrcweir virtual void SAL_CALL addStatusListener(const css::uno::Reference< css::frame::XStatusListener >& xListener, 101*cdf0e10cSrcweir const css::util::URL& aURL ) 102*cdf0e10cSrcweir throw(css::uno::RuntimeException); 103*cdf0e10cSrcweir virtual void SAL_CALL removeStatusListener(const css::uno::Reference< css::frame::XStatusListener >& xListener, 104*cdf0e10cSrcweir const css::util::URL& aURL ) 105*cdf0e10cSrcweir throw(css::uno::RuntimeException); 106*cdf0e10cSrcweir 107*cdf0e10cSrcweir // css::awt::XWindowListener 108*cdf0e10cSrcweir virtual void SAL_CALL windowResized(const css::awt::WindowEvent& aSource) 109*cdf0e10cSrcweir throw(css::uno::RuntimeException); 110*cdf0e10cSrcweir virtual void SAL_CALL windowMoved(const css::awt::WindowEvent& aSource) 111*cdf0e10cSrcweir throw(css::uno::RuntimeException); 112*cdf0e10cSrcweir virtual void SAL_CALL windowShown(const css::lang::EventObject& aSource) 113*cdf0e10cSrcweir throw(css::uno::RuntimeException); 114*cdf0e10cSrcweir virtual void SAL_CALL windowHidden(const css::lang::EventObject& aSource) 115*cdf0e10cSrcweir throw(css::uno::RuntimeException); 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir // css::lang::XEventListener 118*cdf0e10cSrcweir virtual void SAL_CALL disposing(const css::lang::EventObject& aSource) 119*cdf0e10cSrcweir throw(css::uno::RuntimeException); 120*cdf0e10cSrcweir 121*cdf0e10cSrcweir protected: 122*cdf0e10cSrcweir 123*cdf0e10cSrcweir ~HelpAgentDispatcher(); 124*cdf0e10cSrcweir 125*cdf0e10cSrcweir protected: 126*cdf0e10cSrcweir 127*cdf0e10cSrcweir /// IHelpAgentCallback overridables 128*cdf0e10cSrcweir virtual void helpRequested(); 129*cdf0e10cSrcweir virtual void closeAgent(); 130*cdf0e10cSrcweir 131*cdf0e10cSrcweir private: 132*cdf0e10cSrcweir 133*cdf0e10cSrcweir //--------------------------------------- 134*cdf0e10cSrcweir /** @short mark the current set URL as "accepted by user" and show the right help window 135*cdf0e10cSrcweir */ 136*cdf0e10cSrcweir void implts_acceptCurrentURL(); 137*cdf0e10cSrcweir 138*cdf0e10cSrcweir //--------------------------------------- 139*cdf0e10cSrcweir /** @short mark the current set URL as "ignored by user" 140*cdf0e10cSrcweir */ 141*cdf0e10cSrcweir void implts_ignoreCurrentURL(); 142*cdf0e10cSrcweir 143*cdf0e10cSrcweir //--------------------------------------- 144*cdf0e10cSrcweir /** @short ensures that the agent's window exists 145*cdf0e10cSrcweir @descr We create the agent window on demand. But afterwards we hold it alive till 146*cdf0e10cSrcweir this helpagent dispatcher dies. The agent window will be made visible/hidden 147*cdf0e10cSrcweir in case a new dispatch occures or in case the timer expired. 148*cdf0e10cSrcweir 149*cdf0e10cSrcweir @return [sal_Bool] 150*cdf0e10cSrcweir sal_True in case the member m_xAgentWindow is a valid reference; 151*cdf0e10cSrcweir sal_False otherwise. 152*cdf0e10cSrcweir */ 153*cdf0e10cSrcweir css::uno::Reference< css::awt::XWindow > implts_ensureAgentWindow(); 154*cdf0e10cSrcweir 155*cdf0e10cSrcweir //--------------------------------------- 156*cdf0e10cSrcweir /** @short show the agent window. 157*cdf0e10cSrcweir @descr If the agent window does not exists, it will be created on demand. 158*cdf0e10cSrcweir (see implts_ensureAgentWindow). Further it's checked if the parent container 159*cdf0e10cSrcweir window is currently visible or not. Only if its visible the agent window will 160*cdf0e10cSrcweir be shown too. 161*cdf0e10cSrcweir */ 162*cdf0e10cSrcweir void implts_showAgentWindow(); 163*cdf0e10cSrcweir 164*cdf0e10cSrcweir //--------------------------------------- 165*cdf0e10cSrcweir /** @short hide the agent window. 166*cdf0e10cSrcweir */ 167*cdf0e10cSrcweir void implts_hideAgentWindow(); 168*cdf0e10cSrcweir 169*cdf0e10cSrcweir //--------------------------------------- 170*cdf0e10cSrcweir /** @short set the new position and size of the agent window. 171*cdf0e10cSrcweir @descr If the agent window does not exists, it will be created on demand. 172*cdf0e10cSrcweir (see implts_ensureAgentWindow). 173*cdf0e10cSrcweir If the agent window exists, its position and size will be calculated 174*cdf0e10cSrcweir and set. 175*cdf0e10cSrcweir */ 176*cdf0e10cSrcweir void implts_positionAgentWindow(); 177*cdf0e10cSrcweir 178*cdf0e10cSrcweir //--------------------------------------- 179*cdf0e10cSrcweir /** @short starts the timer for showing the agent window. 180*cdf0e10cSrcweir @descr The timer wont be started twice ... this method checks the current running state .-) 181*cdf0e10cSrcweir */ 182*cdf0e10cSrcweir void implts_startTimer(); 183*cdf0e10cSrcweir 184*cdf0e10cSrcweir //--------------------------------------- 185*cdf0e10cSrcweir /** @short stop the timer. 186*cdf0e10cSrcweir @descr The timer wont be stopped twice ... this method checks the current running state .-) 187*cdf0e10cSrcweir Further this method marks the current help URL (m_xCurrentURL) as "ignorable". 188*cdf0e10cSrcweir Cause the user ignored it ! 189*cdf0e10cSrcweir */ 190*cdf0e10cSrcweir void implts_stopTimer(); 191*cdf0e10cSrcweir 192*cdf0e10cSrcweir //--------------------------------------- 193*cdf0e10cSrcweir /** @short callback of our internal timer. 194*cdf0e10cSrcweir */ 195*cdf0e10cSrcweir DECL_LINK(implts_timerExpired, void*); 196*cdf0e10cSrcweir }; 197*cdf0e10cSrcweir 198*cdf0e10cSrcweir #undef css 199*cdf0e10cSrcweir 200*cdf0e10cSrcweir //........................................................................ 201*cdf0e10cSrcweir } // namespace framework 202*cdf0e10cSrcweir //........................................................................ 203*cdf0e10cSrcweir 204*cdf0e10cSrcweir #endif // _FRAMEWORK_DISPATCH_HELPAGENTDISPATCHER_HXX_ 205*cdf0e10cSrcweir 206