diff options
author | August Sodora <augsod@gmail.com> | 2011-12-21 18:03:42 -0500 |
---|---|---|
committer | August Sodora <augsod@gmail.com> | 2011-12-21 22:34:54 -0500 |
commit | 66714f1888eaccef4eb5341971278ae7dfafa16b (patch) | |
tree | 455eb04fe7bc21b7008229ae1f741609557bcbad | |
parent | 881ea5470aa45c90a3a4b20d5126095ab353acc3 (diff) |
Remove HelpAgentWindow
-rw-r--r-- | framework/Library_fwk.mk | 1 | ||||
-rw-r--r-- | framework/inc/dispatch/dispatchprovider.hxx | 20 | ||||
-rw-r--r-- | framework/inc/dispatch/helpagentdispatcher.hxx | 207 | ||||
-rw-r--r-- | framework/inc/targets.h | 10 | ||||
-rw-r--r-- | framework/source/dispatch/dispatchprovider.cxx | 81 | ||||
-rw-r--r-- | framework/source/dispatch/helpagentdispatcher.cxx | 444 | ||||
-rw-r--r-- | framework/source/loadenv/targethelper.cxx | 13 | ||||
-rw-r--r-- | framework/source/services/desktop.cxx | 27 | ||||
-rw-r--r-- | framework/source/services/frame.cxx | 29 | ||||
-rw-r--r-- | svtools/Library_svt.mk | 1 | ||||
-rw-r--r-- | svtools/Package_inc.mk | 1 | ||||
-rw-r--r-- | svtools/inc/svtools/helpagentwindow.hxx | 90 | ||||
-rw-r--r-- | svtools/source/misc/helpagentwindow.cxx | 182 |
13 files changed, 1 insertions, 1105 deletions
diff --git a/framework/Library_fwk.mk b/framework/Library_fwk.mk index 81d0f904d9a0..7d8d064c90bb 100644 --- a/framework/Library_fwk.mk +++ b/framework/Library_fwk.mk @@ -82,7 +82,6 @@ $(eval $(call gb_Library_add_exception_objects,fwk,\ framework/source/dispatch/closedispatcher \ framework/source/dispatch/dispatchinformationprovider \ framework/source/dispatch/dispatchprovider \ - framework/source/dispatch/helpagentdispatcher \ framework/source/dispatch/interceptionhelper \ framework/source/dispatch/loaddispatcher \ framework/source/dispatch/menudispatcher \ diff --git a/framework/inc/dispatch/dispatchprovider.hxx b/framework/inc/dispatch/dispatchprovider.hxx index 9e095f69855a..e2a4107b0e3a 100644 --- a/framework/inc/dispatch/dispatchprovider.hxx +++ b/framework/inc/dispatch/dispatchprovider.hxx @@ -29,10 +29,6 @@ #ifndef __FRAMEWORK_DISPATCH_DISPATCHPROVIDER_HXX_ #define __FRAMEWORK_DISPATCH_DISPATCHPROVIDER_HXX_ -//_________________________________________________________________________________________________________________ -// my own includes -//_________________________________________________________________________________________________________________ - #include <services/frame.hxx> #include <classes/protocolhandlercache.hxx> @@ -45,29 +41,17 @@ #include <macros/generic.hxx> #include <stdtypes.h> -//_________________________________________________________________________________________________________________ -// interface includes -//_________________________________________________________________________________________________________________ #include <com/sun/star/lang/XTypeProvider.hpp> #include <com/sun/star/frame/XDispatchProvider.hpp> #include <com/sun/star/util/URL.hpp> #include <com/sun/star/frame/DispatchDescriptor.hpp> #include <com/sun/star/beans/PropertyValue.hpp> -//_________________________________________________________________________________________________________________ -// other includes -//_________________________________________________________________________________________________________________ #include <cppuhelper/weak.hxx> #include <cppuhelper/weakref.hxx> -//_________________________________________________________________________________________________________________ -// namespace -//_________________________________________________________________________________________________________________ - namespace framework{ -//_________________________________________________________________________________________________________________ - /** @descr We know some special dispatch objects with diffrent functionality. The can be created internaly by the following DispatchProvider. @@ -77,7 +61,6 @@ enum EDispatchHelper { E_DEFAULTDISPATCHER , E_MENUDISPATCHER , - E_HELPAGENTDISPATCHER , E_CREATEDISPATCHER , E_BLANKDISPATCHER , E_SELFDISPATCHER , @@ -85,8 +68,6 @@ enum EDispatchHelper E_STARTMODULEDISPATCHER }; -//_________________________________________________________________________________________________________________ - /** @short implement a helper for XDispatchProvider interface @descr The result of a queryDispatch() call depends from the owner, which use an instance of this class. @@ -124,7 +105,6 @@ class DispatchProvider : // interfaces css::uno::WeakReference< css::frame::XFrame > m_xFrame; /// different dispatcher to handle special dispatch calls, protocols or URLs (they will be created on demand.) css::uno::Reference< css::frame::XDispatch > m_xMenuDispatcher ; - css::uno::Reference< css::frame::XDispatch > m_xHelpAgentDispatcher; /// cache of some other dispatch provider which are registered inside configuration to handle special URL protocols HandlerCache m_aProtocolHandlerCache; diff --git a/framework/inc/dispatch/helpagentdispatcher.hxx b/framework/inc/dispatch/helpagentdispatcher.hxx deleted file mode 100644 index 56d092552a77..000000000000 --- a/framework/inc/dispatch/helpagentdispatcher.hxx +++ /dev/null @@ -1,207 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef __FRAMEWORK_DISPATCH_HELPAGENTDISPATCHER_HXX_ -#define __FRAMEWORK_DISPATCH_HELPAGENTDISPATCHER_HXX_ - -#include <threadhelp/threadhelpbase.hxx> -#include <macros/xinterface.hxx> -#include <macros/xtypeprovider.hxx> -#include <com/sun/star/frame/XDispatch.hpp> -#include <com/sun/star/frame/XFrame.hpp> -#include <com/sun/star/awt/XWindowListener.hpp> -#include <com/sun/star/awt/XWindow.hpp> -#include <svtools/helpagentwindow.hxx> -#include <vcl/timer.hxx> -#include <vcl/evntpost.hxx> -#include <cppuhelper/weak.hxx> - -//........................................................................ -namespace framework -{ - -// define css alias ... and undefine it at the end of this file !!! -#ifdef css - #error "I tried to use css as namespace define inside non exported header ... but it was already defined by somwhere else. .-)" -#else - #define css ::com::sun::star -#endif - -//........................................................................ - -class HelpAgentDispatcher : public css::lang::XTypeProvider - , public css::frame::XDispatch - , public css::awt::XWindowListener // => css::lang::XEventListener - , public ::svt::IHelpAgentCallback - , private ThreadHelpBase - , public ::cppu::OWeakObject -{ - private: - - //--------------------------------------- - /// @short represent the current active help URL, which must be used to show the right help page - ::rtl::OUString m_sCurrentURL; - - //--------------------------------------- - /// @short parent of the agent window. - css::uno::Reference< css::awt::XWindow > m_xContainerWindow; - - //--------------------------------------- - /// @short the agent window itself (implemented in svtools) - css::uno::Reference< css::awt::XWindow > m_xAgentWindow; - - //--------------------------------------- - /// @short the timer for showing the agent window - Timer m_aTimer; - - //--------------------------------------- - /** @short hold this dispatcher alive till the timer was killed or expired! - @descr Because the vcl timer knows us by using a pointer ... and our instance is used - ref counted normaly it can happen that our reference goes down to 0 ... and the timer - runs into some trouble. So we hold us self alive till the timer could be stopped or expired. - */ - css::uno::Reference< css::uno::XInterface > m_xSelfHold; - - public: - - HelpAgentDispatcher(const css::uno::Reference< css::frame::XFrame >& xParentFrame); - - FWK_DECLARE_XINTERFACE - FWK_DECLARE_XTYPEPROVIDER - - // css::frame::XDispatch - virtual void SAL_CALL dispatch(const css::util::URL& sURL , - const css::uno::Sequence< css::beans::PropertyValue >& lArgs) - throw(css::uno::RuntimeException); - virtual void SAL_CALL addStatusListener(const css::uno::Reference< css::frame::XStatusListener >& xListener, - const css::util::URL& aURL ) - throw(css::uno::RuntimeException); - virtual void SAL_CALL removeStatusListener(const css::uno::Reference< css::frame::XStatusListener >& xListener, - const css::util::URL& aURL ) - throw(css::uno::RuntimeException); - - // css::awt::XWindowListener - virtual void SAL_CALL windowResized(const css::awt::WindowEvent& aSource) - throw(css::uno::RuntimeException); - virtual void SAL_CALL windowMoved(const css::awt::WindowEvent& aSource) - throw(css::uno::RuntimeException); - virtual void SAL_CALL windowShown(const css::lang::EventObject& aSource) - throw(css::uno::RuntimeException); - virtual void SAL_CALL windowHidden(const css::lang::EventObject& aSource) - throw(css::uno::RuntimeException); - - // css::lang::XEventListener - virtual void SAL_CALL disposing(const css::lang::EventObject& aSource) - throw(css::uno::RuntimeException); - - protected: - - ~HelpAgentDispatcher(); - - protected: - - /// IHelpAgentCallback overridables - virtual void helpRequested(); - virtual void closeAgent(); - - private: - - //--------------------------------------- - /** @short mark the current set URL as "accepted by user" and show the right help window - */ - void implts_acceptCurrentURL(); - - //--------------------------------------- - /** @short mark the current set URL as "ignored by user" - */ - void implts_ignoreCurrentURL(); - - //--------------------------------------- - /** @short ensures that the agent's window exists - @descr We create the agent window on demand. But afterwards we hold it alive till - this helpagent dispatcher dies. The agent window will be made visible/hidden - in case a new dispatch occures or in case the timer expired. - - @return [sal_Bool] - sal_True in case the member m_xAgentWindow is a valid reference; - sal_False otherwise. - */ - css::uno::Reference< css::awt::XWindow > implts_ensureAgentWindow(); - - //--------------------------------------- - /** @short show the agent window. - @descr If the agent window does not exists, it will be created on demand. - (see implts_ensureAgentWindow). Further it's checked if the parent container - window is currently visible or not. Only if its visible the agent window will - be shown too. - */ - void implts_showAgentWindow(); - - //--------------------------------------- - /** @short hide the agent window. - */ - void implts_hideAgentWindow(); - - //--------------------------------------- - /** @short set the new position and size of the agent window. - @descr If the agent window does not exists, it will be created on demand. - (see implts_ensureAgentWindow). - If the agent window exists, its position and size will be calculated - and set. - */ - void implts_positionAgentWindow(); - - //--------------------------------------- - /** @short starts the timer for showing the agent window. - @descr The timer wont be started twice ... this method checks the current running state .-) - */ - void implts_startTimer(); - - //--------------------------------------- - /** @short stop the timer. - @descr The timer wont be stopped twice ... this method checks the current running state .-) - Further this method marks the current help URL (m_xCurrentURL) as "ignorable". - Cause the user ignored it ! - */ - void implts_stopTimer(); - - //--------------------------------------- - /** @short callback of our internal timer. - */ - DECL_LINK(implts_timerExpired, void*); -}; - -#undef css - -//........................................................................ -} // namespace framework -//........................................................................ - -#endif // _FRAMEWORK_DISPATCH_HELPAGENTDISPATCHER_HXX_ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/targets.h b/framework/inc/targets.h index cb5d84b52db1..fa4709e057fb 100644 --- a/framework/inc/targets.h +++ b/framework/inc/targets.h @@ -29,16 +29,8 @@ #ifndef __FRAMEWORK_TARGETS_H_ #define __FRAMEWORK_TARGETS_H_ -//_________________________________________________________________________________________________________________ -// includes -//_________________________________________________________________________________________________________________ - #include <macros/generic.hxx> -//_________________________________________________________________________________________________________________ -// namespace -//_________________________________________________________________________________________________________________ - namespace framework{ //_________________________________________________________________________________________________________________ @@ -52,7 +44,6 @@ namespace framework{ #define SPECIALTARGET_ASCII_DEFAULT "_default" // Create a new task or recycle an existing one #define SPECIALTARGET_ASCII_BEAMER "_beamer" // special frame in hierarchy #define SPECIALTARGET_ASCII_MENUBAR "_menubar" // special target for menubars -#define SPECIALTARGET_ASCII_HELPAGENT "_helpagent" // special target for the help agent window #define SPECIALTARGET_ASCII_HELPTASK "OFFICE_HELP_TASK" // special name for our help task #define SPECIALTARGET_SELF DECLARE_ASCII(SPECIALTARGET_ASCII_SELF ) @@ -62,7 +53,6 @@ namespace framework{ #define SPECIALTARGET_DEFAULT DECLARE_ASCII(SPECIALTARGET_ASCII_DEFAULT ) #define SPECIALTARGET_BEAMER DECLARE_ASCII(SPECIALTARGET_ASCII_BEAMER ) #define SPECIALTARGET_MENUBAR DECLARE_ASCII(SPECIALTARGET_ASCII_MENUBAR ) -#define SPECIALTARGET_HELPAGENT DECLARE_ASCII(SPECIALTARGET_ASCII_HELPAGENT ) #define SPECIALTARGET_HELPTASK DECLARE_ASCII(SPECIALTARGET_ASCII_HELPTASK ) } // namespace framework diff --git a/framework/source/dispatch/dispatchprovider.cxx b/framework/source/dispatch/dispatchprovider.cxx index 0ea4eeed1a1e..d54ffee4d692 100644 --- a/framework/source/dispatch/dispatchprovider.cxx +++ b/framework/source/dispatch/dispatchprovider.cxx @@ -26,18 +26,12 @@ * ************************************************************************/ - -//_________________________________________________________________________________________________________________ -// my own includes -//_________________________________________________________________________________________________________________ - #include <stdio.h> #include <dispatch/dispatchprovider.hxx> #include <loadenv/loadenv.hxx> #include <dispatch/loaddispatcher.hxx> #include <dispatch/closedispatcher.hxx> #include <dispatch/menudispatcher.hxx> -#include <dispatch/helpagentdispatcher.hxx> #include <dispatch/startmoduledispatcher.hxx> #include <pattern/window.hxx> @@ -50,41 +44,20 @@ #include <targets.h> #include <general.h> -//_________________________________________________________________________________________________________________ -// interface includes -//_________________________________________________________________________________________________________________ #include <com/sun/star/frame/FrameSearchFlag.hpp> #include <com/sun/star/uno/Exception.hpp> #include <com/sun/star/ucb/XContentProviderManager.hpp> #include <com/sun/star/document/XTypeDetection.hpp> #include <com/sun/star/lang/XInitialization.hpp> -//_________________________________________________________________________________________________________________ -// includes of other projects -//_________________________________________________________________________________________________________________ #include <osl/diagnose.h> #include <rtl/string.h> #include <rtl/ustring.hxx> #include <vcl/svapp.hxx> #include <rtl/ustrbuf.hxx> -//_________________________________________________________________________________________________________________ -// namespace -//_________________________________________________________________________________________________________________ namespace framework{ -//_________________________________________________________________________________________________________________ -// non exported const -//_________________________________________________________________________________________________________________ - -//_________________________________________________________________________________________________________________ -// non exported definitions -//_________________________________________________________________________________________________________________ - -//_________________________________________________________________________________________________________________ -// declarations -//_________________________________________________________________________________________________________________ - //***************************************************************************************************************** // XInterface, XTypeProvider //***************************************************************************************************************** @@ -99,8 +72,6 @@ DEFINE_XTYPEPROVIDER_2( DispatchProvider , css::frame::XDispatchProvider ) -//_________________________________________________________________________________________________________________ - /** @short standard ctor/dtor @descr These initialize a new instance of tihs class with needed informations for work. @@ -128,8 +99,6 @@ DispatchProvider::DispatchProvider( const css::uno::Reference< css::lang::XMulti { } -//_________________________________________________________________________________________________________________ - /** @short protected(!) dtor for deinitializing @descr We made it protected to prevent using of us as base class instead as a member. @@ -140,8 +109,6 @@ DispatchProvider::~DispatchProvider() { } -//_________________________________________________________________________________________________________________ - /** @interface XDispatchProvider @short search a dispatcher for given URL @@ -184,8 +151,6 @@ css::uno::Reference< css::frame::XDispatch > SAL_CALL DispatchProvider::queryDis return xDispatcher; } -//_________________________________________________________________________________________________________________ - /** @interface XDispatchProvider @short do the same like queryDispatch() ... but handle multiple dispatches at the same time @@ -220,15 +185,11 @@ css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > SAL_CALL Disp return lDispatcher; } -//_________________________________________________________________________________________________________________ - ::sal_Bool lcl_isStartModuleDispatch (const css::util::URL& aURL) { return (aURL.Complete.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(CMD_UNO_SHOWSTARTMODULE))); } -//_________________________________________________________________________________________________________________ - /** @short helper for queryDispatch() @descr Every member of the frame tree (frame, desktop) must handle such request @@ -247,7 +208,6 @@ css::uno::Reference< css::frame::XDispatch > DispatchProvider::implts_queryDeskt // ignore wrong requests which are not supported if ( (sTargetFrameName==SPECIALTARGET_MENUBAR ) || // valid for frame dispatches - not for desktop - (sTargetFrameName==SPECIALTARGET_HELPAGENT) || // valid for frame dispatches - not for desktop (sTargetFrameName==SPECIALTARGET_PARENT ) || // we have no parent by definition (sTargetFrameName==SPECIALTARGET_BEAMER ) // beamer frames are allowed as child of tasks only - // and they exist more then ones. We have no idea which our sub tasks is the right one @@ -378,28 +338,6 @@ css::uno::Reference< css::frame::XDispatch > DispatchProvider::implts_queryFrame } //----------------------------------------------------------------------------------------------------- - // I.III) "_helpagent" - // Special mode on frame or task to start the help agent. - // It's defined for top level frames only. - //----------------------------------------------------------------------------------------------------- - else - if (sTargetName==SPECIALTARGET_HELPAGENT) - { - if (WindowHelper::isTopWindow(xFrame->getContainerWindow())) - xDispatcher = implts_getOrCreateDispatchHelper( E_HELPAGENTDISPATCHER, xFrame ); - else - { - // Don''t use findFrame() here - because it's not possible to find - // a top lebel frame without knowing his name. And a frame with name - // "" can't be realy searched! That's why forward query to any parent - // explicitly. - css::uno::Reference< css::frame::XDispatchProvider > xProvider( xFrame->getCreator(), css::uno::UNO_QUERY ); - if (xProvider.is()) - xDispatcher = xProvider->queryDispatch(aURL,SPECIALTARGET_HELPAGENT,0); - } - } - - //----------------------------------------------------------------------------------------------------- // I.IV) "_helpagent" // Special sub frame of a top frame only. Search or create it. ... OK it's currently a little bit HACKI. // Only the sfx (means the controller) can create it it. @@ -697,25 +635,6 @@ css::uno::Reference< css::frame::XDispatch > DispatchProvider::implts_getOrCreat } break; - case E_HELPAGENTDISPATCHER : - { - // Attention: It's not a good idea to create this help agent twice for the same frame (window) - // May it will be shown twice too - and user activate the first one. Then he get the corresponding - // help window ... but there exist another help agent window on bottom side of the frame window. - // It's superflous. Create it on demand - but hold it alive till this provider dies. - /* SAFE { */ - WriteGuard aWriteLock( m_aLock ); - if ( ! m_xHelpAgentDispatcher.is() ) - { - HelpAgentDispatcher* pDispatcher = new HelpAgentDispatcher( xOwner ); - m_xHelpAgentDispatcher = css::uno::Reference< css::frame::XDispatch >( static_cast< ::cppu::OWeakObject* >(pDispatcher), css::uno::UNO_QUERY ); - } - xDispatchHelper = m_xHelpAgentDispatcher; - aWriteLock.unlock(); - /* } SAFE */ - } - break; - case E_CREATEDISPATCHER : { LoadDispatcher* pDispatcher = new LoadDispatcher(xFactory, xOwner, sTarget, nSearchFlags); diff --git a/framework/source/dispatch/helpagentdispatcher.cxx b/framework/source/dispatch/helpagentdispatcher.cxx deleted file mode 100644 index 8e3753cef326..000000000000 --- a/framework/source/dispatch/helpagentdispatcher.cxx +++ /dev/null @@ -1,444 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include <dispatch/helpagentdispatcher.hxx> -#include <threadhelp/readguard.hxx> -#include <threadhelp/writeguard.hxx> -#include <com/sun/star/awt/XWindow2.hpp> -#include <com/sun/star/awt/PosSize.hpp> -#include <com/sun/star/awt/Size.hpp> -#include <com/sun/star/awt/Rectangle.hpp> -#include <toolkit/helper/vclunohelper.hxx> -#include <svtools/helpopt.hxx> -#include <vcl/svapp.hxx> -#include <vcl/help.hxx> - -namespace css = ::com::sun::star; - -//........................................................................ -namespace framework -{ - -//----------------------------------------------- -DEFINE_XINTERFACE_4(HelpAgentDispatcher , - OWeakObject , - DIRECT_INTERFACE (css::lang::XTypeProvider ), - DIRECT_INTERFACE (css::frame::XDispatch ), - DIRECT_INTERFACE (css::awt::XWindowListener), - DIRECT_INTERFACE (css::lang::XEventListener)) - -//----------------------------------------------- -DEFINE_XTYPEPROVIDER_2(HelpAgentDispatcher , - css::lang::XTypeProvider, - css::frame::XDispatch ) - -//-------------------------------------------------------------------- -HelpAgentDispatcher::HelpAgentDispatcher( const css::uno::Reference< css::frame::XFrame >& xParentFrame) - : ThreadHelpBase (&Application::GetSolarMutex()) - , m_sCurrentURL ( ) - , m_xContainerWindow( ) - , m_xAgentWindow ( ) - , m_aTimer ( ) - , m_xSelfHold ( ) -{ - // It's required that this class has to be contructed with a valid frame. - // And "valid" means: the frame must already bound to a valid container window. - m_xContainerWindow = xParentFrame->getContainerWindow(); -} - -//-------------------------------------------------------------------- -HelpAgentDispatcher::~HelpAgentDispatcher() -{ - implts_stopTimer(); - implts_ignoreCurrentURL(); - - // Needed ... because it was create as "new VCLWindow()" ! Such windows must be disposed explicitly. - css::uno::Reference< css::lang::XComponent > xAgentWindow(m_xAgentWindow, css::uno::UNO_QUERY); - if (xAgentWindow.is()) - xAgentWindow->dispose(); -} - -//-------------------------------------------------------------------- -void SAL_CALL HelpAgentDispatcher::dispatch(const css::util::URL& aURL , - const css::uno::Sequence< css::beans::PropertyValue >&) - throw(css::uno::RuntimeException) -{ - // silently drop the request if the new URL was marked to be ignored next time. - sal_Int32 nAllowedToIgnore = SvtHelpOptions().getAgentIgnoreURLCounter(aURL.Complete); - if (nAllowedToIgnore < 1) - return; - - // stop the expiration timer for the old URL - // The timer will add the old URL to the list of ignorable URLs. - // So m_sCurrentURL must be set AFTER the timer was stopped !!! - implts_stopTimer(); - - // SAFE -> - WriteGuard aWriteLock(m_aLock); - m_sCurrentURL = aURL.Complete; - aWriteLock.unlock(); - // <- SAFE - - // start the expiration timer for the new URL - implts_startTimer(); - - // make sure the agent window is shown - implts_showAgentWindow(); -} - -//-------------------------------------------------------------------- -void SAL_CALL HelpAgentDispatcher::addStatusListener(const css::uno::Reference< css::frame::XStatusListener >&, - const css::util::URL&) - throw(css::uno::RuntimeException) -{ - // no status available -} - -//-------------------------------------------------------------------- -void SAL_CALL HelpAgentDispatcher::removeStatusListener(const css::uno::Reference< css::frame::XStatusListener >&, - const css::util::URL&) - throw(css::uno::RuntimeException) -{ - // no status available -} - -//-------------------------------------------------------------------- -void SAL_CALL HelpAgentDispatcher::windowResized(const css::awt::WindowEvent&) - throw(css::uno::RuntimeException) -{ - implts_positionAgentWindow(); -} - -//-------------------------------------------------------------------- -void SAL_CALL HelpAgentDispatcher::windowMoved(const css::awt::WindowEvent&) - throw(css::uno::RuntimeException) -{ - implts_positionAgentWindow(); -} - -//-------------------------------------------------------------------- -void SAL_CALL HelpAgentDispatcher::windowShown(const css::lang::EventObject&) - throw(css::uno::RuntimeException) -{ - implts_showAgentWindow(); -} - -//-------------------------------------------------------------------- -void SAL_CALL HelpAgentDispatcher::windowHidden(const css::lang::EventObject&) - throw(css::uno::RuntimeException) -{ - implts_hideAgentWindow(); -} - -//-------------------------------------------------------------------- -void SAL_CALL HelpAgentDispatcher::disposing(const css::lang::EventObject& aEvent) - throw(css::uno::RuntimeException) -{ - // SAFE -> - WriteGuard aWriteLock(m_aLock); - - // Already disposed ?! - if (! m_xContainerWindow.is()) - return; - // Wrong broadcaster ?! - if (aEvent.Source != m_xContainerWindow) - return; - - css::uno::Reference< css::uno::XInterface > xSelfHoldUntilMethodEnds(static_cast< css::frame::XDispatch* >(this), css::uno::UNO_QUERY_THROW); - m_xSelfHold.clear(); - - aWriteLock.unlock(); - // <- SAFE - - implts_stopTimer(); - implts_hideAgentWindow(); - implts_ignoreCurrentURL(); - - // SAFE -> - aWriteLock.lock(); - m_xContainerWindow.clear(); - css::uno::Reference< css::lang::XComponent > xAgentWindow(m_xAgentWindow, css::uno::UNO_QUERY); - m_xAgentWindow.clear(); - aWriteLock.unlock(); - // <- SAFE - - // Needed ... because it was create as "new VCLWindow()" ! Such windows must be disposed explicitly. - if (xAgentWindow.is()) - xAgentWindow->dispose(); -} - -//-------------------------------------------------------------------- -void HelpAgentDispatcher::helpRequested() -{ - implts_stopTimer(); - implts_hideAgentWindow(); - implts_acceptCurrentURL(); -} - -//----------------------------------------------- -void HelpAgentDispatcher::closeAgent() -{ - implts_stopTimer(); - implts_hideAgentWindow(); - implts_ignoreCurrentURL(); -} - -//-------------------------------------------------------------------- -void HelpAgentDispatcher::implts_acceptCurrentURL() -{ - // SAFE -> - WriteGuard aWriteLock(m_aLock); - - ::rtl::OUString sAcceptedURL = m_sCurrentURL; - m_sCurrentURL = ::rtl::OUString(); - - aWriteLock.unlock(); - // <- SAFE - - // We must make sure that this URL isnt marked as ignored by the user. - // Otherwhise the user wont see the corresponding help content in the future. - SvtHelpOptions().resetAgentIgnoreURLCounter(sAcceptedURL); - - // show the right help content - // SOLAR SAFE -> - { - SolarMutexGuard aSolarLock; - Help* pHelp = Application::GetHelp(); - if (pHelp) - pHelp->Start(sAcceptedURL, NULL); - } - // <- SOLAR SAFE -} - -//-------------------------------------------------------------------- -void HelpAgentDispatcher::implts_ignoreCurrentURL() -{ - // SAFE -> - WriteGuard aWriteLock(m_aLock); - - ::rtl::OUString sIgnoredURL = m_sCurrentURL; - m_sCurrentURL = ::rtl::OUString(); - - aWriteLock.unlock(); - // <- SAFE - - if (sIgnoredURL.getLength()) - SvtHelpOptions().decAgentIgnoreURLCounter(sIgnoredURL); -} - -//-------------------------------------------------------------------- -void HelpAgentDispatcher::implts_stopTimer() -{ - // SAFE -> - WriteGuard aWriteLock(m_aLock); - m_xSelfHold.clear(); - aWriteLock.unlock(); - // <- SAFE - - // SOLAR SAFE -> - // Timer access needs no "own lock" ! It lives if we live ... - // But it requires locking of the solar mutex ... because it's a vcl based timer. - { - SolarMutexGuard aSolarLock; - if (! m_aTimer.IsActive()) - return; - m_aTimer.Stop(); - } - // <- SOLAR SAFE -} - -//-------------------------------------------------------------------- -void HelpAgentDispatcher::implts_startTimer() -{ - // SOLAR SAFE -> - // Timer access needs no "own lock" ! It lives if we live ... - // But it requires locking of the solar mutex ... because it's a vcl based timer. - { - SolarMutexGuard aSolarLock; - if (m_aTimer.IsActive()) - return; - } - // <- SOLAR SAFE - - // SAFE -> - // Timer uses pointer to this help agent dispatcher ... - // But normaly we are ref counted. So we must make sure that this - // dispatcher isnt killed during the timer runs .-) - WriteGuard aWriteLock(m_aLock); - m_xSelfHold = css::uno::Reference< css::uno::XInterface >(static_cast< css::frame::XDispatch* >(this), css::uno::UNO_QUERY_THROW); - aWriteLock.unlock(); - // <- SAFE - - sal_Int32 nTime = SvtHelpOptions().GetHelpAgentTimeoutPeriod(); - - // SOLAR SAFE -> - // Timer access needs no "own lock" ! It lives if we live ... - // But it requires locking of the solar mutex ... because it's a vcl based timer. - { - SolarMutexGuard aSolarLock; - m_aTimer.SetTimeout(nTime*1000); // sec => ms ! - m_aTimer.Start(); - } -} - -//----------------------------------------------- -IMPL_LINK(HelpAgentDispatcher, implts_timerExpired, void*,) -{ - // This method is called by using a pointer to us. - // But we must be aware that we can be destroyed hardly - // if our uno reference will be gone! - // => Hold this object alive till this method finish its work. - // SAFE -> - WriteGuard aWriteLock(m_aLock); - css::uno::Reference< css::uno::XInterface > xSelfHoldUntilMethodEnds(static_cast< css::frame::XDispatch* >(this), css::uno::UNO_QUERY_THROW); - m_xSelfHold.clear(); - aWriteLock.unlock(); - // <- SAFE - - implts_hideAgentWindow(); - implts_ignoreCurrentURL(); - - return 0; -} - -//-------------------------------------------------------------------- -void HelpAgentDispatcher::implts_showAgentWindow() -{ - // SAFE -> - ReadGuard aReadLock(m_aLock); - css::uno::Reference< css::awt::XWindow2 > xContainerWindow(m_xContainerWindow, css::uno::UNO_QUERY_THROW); - aReadLock.unlock(); - // <- SAFE - - css::uno::Reference< css::awt::XWindow > xAgentWindow = implts_ensureAgentWindow(); - - if ( - (xContainerWindow.is() ) && - (xAgentWindow.is() ) && - (xContainerWindow->isVisible()) - ) - { - // make sure that agent window resists at the right place .-) - implts_positionAgentWindow(); - xAgentWindow->setVisible(sal_True); - } -} - -//-------------------------------------------------------------------- -void HelpAgentDispatcher::implts_hideAgentWindow() -{ - css::uno::Reference< css::awt::XWindow > xAgentWindow = implts_ensureAgentWindow(); - if (xAgentWindow.is()) - xAgentWindow->setVisible(sal_False); -} - -//-------------------------------------------------------------------- -void HelpAgentDispatcher::implts_positionAgentWindow() -{ - // SAFE -> - ReadGuard aReadLock(m_aLock); - css::uno::Reference< css::awt::XWindow > xContainerWindow = m_xContainerWindow; - aReadLock.unlock(); - // <- SAFE - - css::uno::Reference< css::awt::XWindow > xAgentWindow = implts_ensureAgentWindow(); - if ( - (! xContainerWindow.is()) || - (! xAgentWindow.is() ) - ) - return; - - ::svt::HelpAgentWindow* pAgentWindow = (::svt::HelpAgentWindow*)VCLUnoHelper::GetWindow(xAgentWindow); - const css::awt::Rectangle aContainerSize = xContainerWindow->getPosSize(); - const Size aAgentSize = pAgentWindow->getPreferredSizePixel(); - - sal_Int32 nW = aAgentSize.Width() ; - sal_Int32 nH = aAgentSize.Height(); - - if (nW < 1) - nW = 100; - if (nH < 1) - nH = 100; - - sal_Int32 nX = aContainerSize.Width - nW; - sal_Int32 nY = aContainerSize.Height - nH; - - // TODO: use a surrogate if the container window is too small to contain the full-sized agent window - xAgentWindow->setPosSize(nX, nY, nW, nH, css::awt::PosSize::POSSIZE); -} - -//-------------------------------------------------------------------- -css::uno::Reference< css::awt::XWindow > HelpAgentDispatcher::implts_ensureAgentWindow() -{ - // SAFE -> - ReadGuard aReadLock(m_aLock); - if (m_xAgentWindow.is()) - return m_xAgentWindow; - css::uno::Reference< css::awt::XWindow > xContainerWindow = m_xContainerWindow; - aReadLock.unlock(); - // <- SAFE - - if (!xContainerWindow.is()) - return css::uno::Reference< css::awt::XWindow >(); - - ::svt::HelpAgentWindow* pAgentWindow = 0; - // SOLAR SAFE -> - { - SolarMutexGuard aSolarLock; - // create the agent window - Window* pContainerWindow = VCLUnoHelper::GetWindow(xContainerWindow); - pAgentWindow = new ::svt::HelpAgentWindow(pContainerWindow); - pAgentWindow->setCallback(this); - } - // <- SOLAR SAFE - - // SAFE -> - WriteGuard aWriteLock(m_aLock); - m_xAgentWindow = VCLUnoHelper::GetInterface(pAgentWindow); - css::uno::Reference< css::awt::XWindow > xAgentWindow = m_xAgentWindow; - aWriteLock.unlock(); - // <- SAFE - - // add as window listener to the container window so we can maintain the property position of the agent window - xContainerWindow->addWindowListener(this); - - // SOLAR SAFE -> - { - SolarMutexGuard aSolarLock; - // establish callback for our internal used timer. - // Note: Its only active, if the timer will be started ... - m_aTimer.SetTimeoutHdl(LINK(this, HelpAgentDispatcher, implts_timerExpired)); - } - // <- SOLAR SAFE - - return xAgentWindow; -} - -} // namespace framework - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/source/loadenv/targethelper.cxx b/framework/source/loadenv/targethelper.cxx index 7a408f9ff64b..bfc61046f96e 100644 --- a/framework/source/loadenv/targethelper.cxx +++ b/framework/source/loadenv/targethelper.cxx @@ -26,20 +26,10 @@ * ************************************************************************/ - -//_______________________________________________ -// own includes - #include <loadenv/targethelper.hxx> -//_______________________________________________ -// namespace - namespace framework{ -//_______________________________________________ -// declarations - /*----------------------------------------------- 05.08.2003 09:08 -----------------------------------------------*/ @@ -72,9 +62,6 @@ sal_Bool TargetHelper::matchSpecialTarget(const ::rtl::OUString& sCheckTarget , case E_MENUBAR : return (sCheckTarget.equals(SPECIALTARGET_MENUBAR)); - case E_HELPAGENT : - return (sCheckTarget.equals(SPECIALTARGET_HELPAGENT)); - case E_HELPTASK : return (sCheckTarget.equals(SPECIALTARGET_HELPTASK)); default: diff --git a/framework/source/services/desktop.cxx b/framework/source/services/desktop.cxx index a65eb0996af7..c2b6d512f216 100644 --- a/framework/source/services/desktop.cxx +++ b/framework/source/services/desktop.cxx @@ -26,10 +26,6 @@ * ************************************************************************/ - -//_________________________________________________________________________________________________________________ -// my own includes -//_________________________________________________________________________________________________________________ #include <loadenv/loadenv.hxx> #include <loadenv/targethelper.hxx> @@ -50,9 +46,6 @@ #include <classes/resource.hrc> #include <classes/fwkresid.hxx> -//_________________________________________________________________________________________________________________ -// interface includes -//_________________________________________________________________________________________________________________ #include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/frame/FrameSearchFlag.hpp> #include <com/sun/star/awt/XToolkit.hpp> @@ -78,9 +71,6 @@ #include <com/sun/star/document/UpdateDocMode.hpp> #include <com/sun/star/frame/XTerminateListener2.hpp> -//_________________________________________________________________________________________________________________ -// includes of other projects -//_________________________________________________________________________________________________________________ #include <cppuhelper/queryinterface.hxx> #include <cppuhelper/typeprovider.hxx> #include <cppuhelper/factory.hxx> @@ -94,24 +84,8 @@ #include <fwkdllapi.h> -//_________________________________________________________________________________________________________________ -// namespace -//_________________________________________________________________________________________________________________ - namespace framework{ -//_________________________________________________________________________________________________________________ -// non exported const -//_________________________________________________________________________________________________________________ - -//_________________________________________________________________________________________________________________ -// non exported definitions -//_________________________________________________________________________________________________________________ - -//_________________________________________________________________________________________________________________ -// declarations -//_________________________________________________________________________________________________________________ - //***************************************************************************************************************** // XInterface, XTypeProvider, XServiceInfo //***************************************************************************************************************** @@ -1029,7 +1003,6 @@ css::uno::Reference< css::frame::XFrame > SAL_CALL Desktop::findFrame( const ::r if ( (sTargetFrameName==SPECIALTARGET_DEFAULT ) || // valid for dispatches - not for findFrame()! (sTargetFrameName==SPECIALTARGET_MENUBAR ) || // valid for dispatches - not for findFrame()! - (sTargetFrameName==SPECIALTARGET_HELPAGENT) || // valid for dispatches - not for findFrame()! (sTargetFrameName==SPECIALTARGET_PARENT ) || // we have no parent by definition (sTargetFrameName==SPECIALTARGET_BEAMER ) // beamer frames are allowed as child of tasks only - // and they exist more then ones. We have no idea which our sub tasks is the right one diff --git a/framework/source/services/frame.cxx b/framework/source/services/frame.cxx index 9d26f63c90b2..4c4108fc64d9 100644 --- a/framework/source/services/frame.cxx +++ b/framework/source/services/frame.cxx @@ -26,10 +26,6 @@ * ************************************************************************/ - -//_________________________________________________________________________________________________________________ -// my own includes -//_________________________________________________________________________________________________________________ #include <services/frame.hxx> #include <dispatch/dispatchprovider.hxx> @@ -51,9 +47,6 @@ #include <services.h> #include <properties.h> -//_________________________________________________________________________________________________________________ -// interface includes -//_________________________________________________________________________________________________________________ #include <com/sun/star/lang/XInitialization.hpp> #include <com/sun/star/lang/DisposedException.hpp> #include <com/sun/star/task/XJobExecutor.hpp> @@ -79,9 +72,6 @@ #include <com/sun/star/frame/XTitleChangeBroadcaster.hpp> -//_________________________________________________________________________________________________________________ -// includes of other projects -//_________________________________________________________________________________________________________________ #include <comphelper/sequenceashashmap.hxx> #include <cppuhelper/queryinterface.hxx> #include <cppuhelper/typeprovider.hxx> @@ -105,26 +95,10 @@ #include <vcl/menu.hxx> -//_________________________________________________________________________________________________________________ -// namespace -//_________________________________________________________________________________________________________________ - namespace framework{ -//_________________________________________________________________________________________________________________ -// non exported const -//_________________________________________________________________________________________________________________ - -//_________________________________________________________________________________________________________________ -// non exported definitions -//_________________________________________________________________________________________________________________ - css::uno::WeakReference< css::frame::XFrame > Frame::m_xCloserFrame = css::uno::WeakReference< css::frame::XFrame >(); -//_________________________________________________________________________________________________________________ -// declarations -//_________________________________________________________________________________________________________________ - //***************************************************************************************************************** // XInterface, XTypeProvider, XServiceInfo //***************************************************************************************************************** @@ -795,8 +769,7 @@ css::uno::Reference< css::frame::XFrame > SAL_CALL Frame::findFrame( const ::rtl //----------------------------------------------------------------------------------------------------- if ( (sTargetFrameName==SPECIALTARGET_DEFAULT ) || // valid for dispatches - not for findFrame()! - (sTargetFrameName==SPECIALTARGET_MENUBAR ) || // valid for dispatches - not for findFrame()! - (sTargetFrameName==SPECIALTARGET_HELPAGENT) // valid for dispatches - not for findFrame()! + (sTargetFrameName==SPECIALTARGET_MENUBAR ) // valid for dispatches - not for findFrame()! ) { return NULL; diff --git a/svtools/Library_svt.mk b/svtools/Library_svt.mk index 5f0cfc66084c..0cba018ca958 100644 --- a/svtools/Library_svt.mk +++ b/svtools/Library_svt.mk @@ -205,7 +205,6 @@ $(eval $(call gb_Library_add_exception_objects,svt,\ svtools/source/misc/embedhlp \ svtools/source/misc/embedtransfer \ svtools/source/misc/filechangedchecker \ - svtools/source/misc/helpagentwindow \ svtools/source/misc/imagemgr \ svtools/source/misc/imageresourceaccess \ svtools/source/misc/imap \ diff --git a/svtools/Package_inc.mk b/svtools/Package_inc.mk index e63c930fb396..2ba89dec29e7 100644 --- a/svtools/Package_inc.mk +++ b/svtools/Package_inc.mk @@ -80,7 +80,6 @@ $(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/generictoolboxcontroll $(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/genericunodialog.hxx,svtools/genericunodialog.hxx)) $(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/grfmgr.hxx,svtools/grfmgr.hxx)) $(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/headbar.hxx,svtools/headbar.hxx)) -$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/helpagentwindow.hxx,svtools/helpagentwindow.hxx)) $(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/helpid.hrc,svtools/helpid.hrc)) $(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/helpopt.hxx,svtools/helpopt.hxx)) $(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/htmlcfg.hxx,svtools/htmlcfg.hxx)) diff --git a/svtools/inc/svtools/helpagentwindow.hxx b/svtools/inc/svtools/helpagentwindow.hxx deleted file mode 100644 index 7d2987eb6f96..000000000000 --- a/svtools/inc/svtools/helpagentwindow.hxx +++ /dev/null @@ -1,90 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef _SVTOOLS_HELPAGENTWIDNOW_HXX_ -#define _SVTOOLS_HELPAGENTWIDNOW_HXX_ - -#include "svtools/svtdllapi.h" -#include <vcl/floatwin.hxx> -#include <vcl/image.hxx> - -//........................................................................ -namespace svt -{ -//........................................................................ - - //==================================================================== - //= IHelpAgentCallback - //==================================================================== - class IHelpAgentCallback - { - public: - virtual void helpRequested() = 0; - virtual void closeAgent() = 0; - }; - - //==================================================================== - //= HelpAgentWindow - //==================================================================== - class SVT_DLLPUBLIC HelpAgentWindow : public FloatingWindow - { - protected: - Window* m_pCloser; - IHelpAgentCallback* m_pCallback; - Size m_aPreferredSize; - Image m_aPicture; - - public: - HelpAgentWindow( Window* _pParent ); - ~HelpAgentWindow(); - - /// returns the preferred size of the window - const Size& getPreferredSizePixel() const { return m_aPreferredSize; } - - // callback handler maintainance - void setCallback(IHelpAgentCallback* _pCB) { m_pCallback = _pCB; } - IHelpAgentCallback* getCallback() const { return m_pCallback; } - - protected: - virtual void Resize(); - virtual void Paint( const Rectangle& rRect ); - virtual void MouseButtonUp( const MouseEvent& rMEvt ); - - DECL_LINK( OnButtonClicked, Window* ); - - private: - SVT_DLLPRIVATE Size implOptimalButtonSize( const Image& _rButtonImage ); - }; - -//........................................................................ -} // namespace svt -//........................................................................ - -#endif // _SVTOOLS_HELPAGENTWIDNOW_HXX_ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svtools/source/misc/helpagentwindow.cxx b/svtools/source/misc/helpagentwindow.cxx deleted file mode 100644 index e4b8326bfed9..000000000000 --- a/svtools/source/misc/helpagentwindow.cxx +++ /dev/null @@ -1,182 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include <svtools/helpagentwindow.hxx> -#include <osl/diagnose.h> -#include <vcl/button.hxx> -#include <vcl/bitmap.hxx> -#include <svtools/svtdata.hxx> -#include <svtools/svtools.hrc> -#include <svtools/helpid.hrc> - -#define WB_AGENT_STYLE 0 - -//........................................................................ -namespace svt -{ -//........................................................................ - - using namespace ::com::sun::star::uno; - using namespace ::com::sun::star::lang; - - //==================================================================== - //= CloserButton_Impl - //= overload of ImageButton, because sometimes vcl doesn't call the click handler - //==================================================================== - //-------------------------------------------------------------------- - class CloserButton_Impl : public ImageButton - { - public: - CloserButton_Impl( Window* pParent, WinBits nBits ) : ImageButton( pParent, nBits ) {} - - virtual void MouseButtonUp( const MouseEvent& rMEvt ); - }; - - //-------------------------------------------------------------------- - void CloserButton_Impl::MouseButtonUp( const MouseEvent& rMEvt ) - { - ImageButton::MouseButtonUp( rMEvt ); - GetClickHdl().Call( this ); - } - - //==================================================================== - //= HelpAgentWindow - //==================================================================== - //-------------------------------------------------------------------- - HelpAgentWindow::HelpAgentWindow( Window* _pParent ) - :FloatingWindow( _pParent, WB_AGENT_STYLE) - ,m_pCloser(NULL) - ,m_pCallback(NULL) - { - // ----------------- - // the closer button - Bitmap aCloserBitmap(SvtResId(BMP_HELP_AGENT_CLOSER)); - Image aCloserImage( aCloserBitmap, Color(COL_LIGHTMAGENTA) ); - m_pCloser = new CloserButton_Impl( this, WB_NOTABSTOP | WB_NOPOINTERFOCUS ); - static_cast<CloserButton_Impl*>(m_pCloser)->SetModeImage( aCloserImage ); - static_cast<CloserButton_Impl*>(m_pCloser)->SetClickHdl( LINK(this, HelpAgentWindow, OnButtonClicked) ); - m_pCloser->SetSizePixel( implOptimalButtonSize(aCloserImage) ); - m_pCloser->Show(); - m_pCloser->SetZOrder( NULL, WINDOW_ZORDER_LAST ); - - // ---------------------------- - // calculate our preferred size - Bitmap aHelpAgentBitmap(SvtResId(BMP_HELP_AGENT_IMAGE)); - m_aPicture = Image( aHelpAgentBitmap ); - m_aPreferredSize = m_aPicture.GetSizePixel(); - m_aPreferredSize.Width() += 2; - m_aPreferredSize.Height() += 2; - - Size aSize = GetSizePixel(); - Size aOutputSize = GetOutputSizePixel(); - m_aPreferredSize.Width() += aSize.Width() - aOutputSize.Width(); - m_aPreferredSize.Height() += aSize.Height() - aOutputSize.Height(); - - SetPointer(Pointer(POINTER_REFHAND)); - AlwaysEnableInput( sal_True, sal_True ); - } - - //-------------------------------------------------------------------- - HelpAgentWindow::~HelpAgentWindow() - { - if (m_pCloser && m_pCloser->IsTracking()) - m_pCloser->EndTracking(); - if (m_pCloser && m_pCloser->IsMouseCaptured()) - m_pCloser->ReleaseMouse(); - - delete m_pCloser; - } - - //-------------------------------------------------------------------- - void HelpAgentWindow::Paint( const Rectangle& rRect ) - { - FloatingWindow::Paint(rRect); - - Size aOutputSize( GetOutputSizePixel() ); - Point aPoint=Point(); - Rectangle aOutputRect( aPoint, aOutputSize ); - Rectangle aInnerRect( aOutputRect ); - - // paint the background - SetLineColor( GetSettings().GetStyleSettings().GetFaceColor() ); - SetFillColor( GetSettings().GetStyleSettings().GetFaceColor() ); - DrawRect( aOutputRect ); - - // paint the image - Size aPictureSize( m_aPicture.GetSizePixel() ); - Point aPicturePos( - aOutputRect.Left() + (aInnerRect.GetWidth() - aPictureSize.Width()) / 2, - aOutputRect.Top() + (aInnerRect.GetHeight() - aPictureSize.Height()) / 2 ); - - DrawImage( aPicturePos, m_aPicture, 0 ); - } - - //-------------------------------------------------------------------- - void HelpAgentWindow::MouseButtonUp( const MouseEvent& rMEvt ) - { - FloatingWindow::MouseButtonUp(rMEvt); - - if (m_pCallback) - m_pCallback->helpRequested(); - } - - //-------------------------------------------------------------------- - Size HelpAgentWindow::implOptimalButtonSize( const Image& _rButtonImage ) - { - Size aPreferredSize = _rButtonImage.GetSizePixel(); - // add a small frame, needed by the button - aPreferredSize.Width() += 5; - aPreferredSize.Height() += 5; - return aPreferredSize; - } - - //-------------------------------------------------------------------- - void HelpAgentWindow::Resize() - { - FloatingWindow::Resize(); - - Size aOutputSize = GetOutputSizePixel(); - Size aCloserSize = m_pCloser->GetSizePixel(); - if (m_pCloser) - m_pCloser->SetPosPixel( Point(aOutputSize.Width() - aCloserSize.Width() - 3, 4) ); - } - - //-------------------------------------------------------------------- - IMPL_LINK( HelpAgentWindow, OnButtonClicked, Window*, _pWhichOne ) - { - if (m_pCloser == _pWhichOne) - if (m_pCallback) - m_pCallback->closeAgent(); - return 0L; - } - -//........................................................................ -} // namespace svt -//........................................................................ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |