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