summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorKohei Yoshida <kyoshida@novell.com>2011-07-30 10:55:52 -0400
committerKohei Yoshida <kyoshida@novell.com>2011-07-30 10:57:17 -0400
commit90404a7dbab20c4fef8da6a3583b4b501fe89591 (patch)
tree8b1f06b93c1f452a39aa24eb6084f454e933613a /framework
parent406f61ae748f588d0f80bec295ec7b7b18de5755 (diff)
Removed duplicated svt::AcceleratorExecute implementation.
There is already one implemented in svtools, which is the one that we use.
Diffstat (limited to 'framework')
-rw-r--r--framework/source/accelerators/acceleratorexecute.cxx371
-rw-r--r--framework/source/accelerators/acceleratorexecute.hxx246
2 files changed, 0 insertions, 617 deletions
diff --git a/framework/source/accelerators/acceleratorexecute.cxx b/framework/source/accelerators/acceleratorexecute.cxx
deleted file mode 100644
index 1b5b37f439c8..000000000000
--- a/framework/source/accelerators/acceleratorexecute.cxx
+++ /dev/null
@@ -1,371 +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.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_framework.hxx"
-#include "acceleratorexecute.hxx"
-
-//===============================================
-// includes
-
-#include <com/sun/star/frame/XModuleManager.hpp>
-
-#include <com/sun/star/ui/XUIConfigurationManager.hpp>
-
-#include <com/sun/star/ui/XModuleUIConfigurationManagerSupplier.hpp>
-
-#include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp>
-
-#include <com/sun/star/awt/KeyModifier.hpp>
-
-#include <com/sun/star/uno/Sequence.hxx>
-
-#include <com/sun/star/beans/PropertyValue.hpp>
-
-//===============================================
-// namespace
-
-namespace svt
-{
-
-namespace css = ::com::sun::star;
-
-//===============================================
-// definitions
-
-//-----------------------------------------------
-AcceleratorExecute::AcceleratorExecute()
- : TMutexInit ( )
- , m_aAsyncCallback(LINK(this, AcceleratorExecute, impl_ts_asyncCallback))
-{
-}
-
-//-----------------------------------------------
-AcceleratorExecute::AcceleratorExecute(const AcceleratorExecute& rCopy)
- : TMutexInit ( )
- , m_aAsyncCallback(LINK(this, AcceleratorExecute, impl_ts_asyncCallback))
-{
- // copy construction sint supported in real ...
- // but we need this ctor to init our async callback ...
-}
-
-//-----------------------------------------------
-AcceleratorExecute::~AcceleratorExecute()
-{
- // does nothing real
-}
-
-//-----------------------------------------------
-AcceleratorExecute* AcceleratorExecute::createAcceleratorHelper()
-{
- AcceleratorExecute* pNew = new AcceleratorExecute();
- return pNew;
-}
-
-//-----------------------------------------------
-void AcceleratorExecute::init(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR,
- const css::uno::Reference< css::frame::XFrame >& xEnv )
-{
- // SAFE -> ----------------------------------
- ::osl::ResettableMutexGuard aLock(m_aLock);
-
- // take over the uno service manager
- m_xSMGR = xSMGR;
-
- // specify our internal dispatch provider
- // frame or desktop?! => document or global config.
- sal_Bool bDesktopIsUsed = sal_False;
- m_xDispatcher = css::uno::Reference< css::frame::XDispatchProvider >(xEnv, css::uno::UNO_QUERY);
- if (!m_xDispatcher.is())
- {
- aLock.clear();
- // <- SAFE ------------------------------
-
- css::uno::Reference< css::frame::XDispatchProvider > xDispatcher(
- xSMGR->createInstance(SERVICENAME_DESKTOP),
- css::uno::UNO_QUERY_THROW);
-
- // SAFE -> ------------------------------
- aLock.reset();
-
- m_xDispatcher = xDispatcher;
- bDesktopIsUsed = sal_True;
- }
-
- aLock.clear();
- // <- SAFE ----------------------------------
-
- // open all needed configuration objects
- css::uno::Reference< css::ui::XAcceleratorConfiguration > xGlobalCfg;
- css::uno::Reference< css::ui::XAcceleratorConfiguration > xModuleCfg;
- css::uno::Reference< css::ui::XAcceleratorConfiguration > xDocCfg ;
-
- // global cfg
- xGlobalCfg = AcceleratorExecute::impl_st_openGlobalConfig(xSMGR);
- if (!bDesktopIsUsed)
- {
- // module cfg
- xModuleCfg = AcceleratorExecute::impl_st_openModuleConfig(xSMGR, xEnv);
-
- // doc cfg
- css::uno::Reference< css::frame::XController > xController;
- css::uno::Reference< css::frame::XModel > xModel;
- xController = xEnv->getController();
- if (xController.is())
- xModel = xController->getModel();
- if (xModel.is())
- xDocCfg = AcceleratorExecute::impl_st_openDocConfig(xModel);
- }
-
- // SAFE -> ------------------------------
- aLock.reset();
-
- m_xGlobalCfg = xGlobalCfg;
- m_xModuleCfg = xModuleCfg;
- m_xDocCfg = xDocCfg ;
-
- aLock.clear();
- // <- SAFE ----------------------------------
-}
-
-//-----------------------------------------------
-void AcceleratorExecute::execute(const KeyCode& aVCLKey)
-{
- css::awt::KeyEvent aAWTKey = AcceleratorExecute::st_VCLKey2AWTKey(aVCLKey);
- execute(aAWTKey);
-}
-
-//-----------------------------------------------
-void AcceleratorExecute::execute(const css::awt::KeyEvent& aAWTKey)
-{
- ::rtl::OUString sCommand = impl_ts_findCommand(aAWTKey);
-
- // No Command found? Do nothing! User isnt interested on any error handling .-)
- if (!sCommand.getLength())
- return;
-
- // SAFE -> ----------------------------------
- ::osl::ResettableMutexGuard aLock(m_aLock);
-
- m_lCommandQueue.push_back(sCommand);
- m_aAsyncCallback.Post(0);
-
- aLock.clear();
- // <- SAFE ----------------------------------
-}
-
-//-----------------------------------------------
-css::awt::KeyEvent AcceleratorExecute::st_VCLKey2AWTKey(const KeyCode& aVCLKey)
-{
- css::awt::KeyEvent aAWTKey;
- aAWTKey.Modifiers = 0;
- aAWTKey.KeyCode = (sal_Int16)aVCLKey.GetCode();
-
- if (aVCLKey.IsShift())
- aAWTKey.Modifiers |= css::awt::KeyModifier::SHIFT;
- if (aVCLKey.IsMod1())
- aAWTKey.Modifiers |= css::awt::KeyModifier::MOD1;
- if (aVCLKey.IsMod2())
- aAWTKey.Modifiers |= css::awt::KeyModifier::MOD2;
- if (aVCLKey.IsMod3())
- aAWTKey.Modifiers |= css::awt::KeyModifier::MOD3;
-
- return aAWTKey;
-}
-
-/*
-ViewFrame->GetObjectShell
-ObjectShell->GetStyleSheetPool
-*/
-
-//-----------------------------------------------
-KeyCode AcceleratorExecute::st_AWTKey2VCLKey(const css::awt::KeyEvent& aAWTKey)
-{
- sal_Bool bShift = ((aAWTKey.Modifiers & css::awt::KeyModifier::SHIFT) == css::awt::KeyModifier::SHIFT );
- sal_Bool bMod1 = ((aAWTKey.Modifiers & css::awt::KeyModifier::MOD1 ) == css::awt::KeyModifier::MOD1 );
- sal_Bool bMod2 = ((aAWTKey.Modifiers & css::awt::KeyModifier::MOD2 ) == css::awt::KeyModifier::MOD2 );
- sal_Bool bMod3 = ((aAWTKey.Modifiers & css::awt::KeyModifier::MOD3 ) == css::awt::KeyModifier::MOD3 );
- sal_uInt16 nKey = (sal_uInt16)aAWTKey.KeyCode;
-
- return KeyCode(nKey, bShift, bMod1, bMod2, bMod3);
-}
-
-//-----------------------------------------------
-::rtl::OUString AcceleratorExecute::impl_ts_findCommand(const css::awt::KeyEvent& aKey)
-{
- // SAFE -> ----------------------------------
- ::osl::ResettableMutexGuard aLock(m_aLock);
-
- css::uno::Reference< css::ui::XAcceleratorConfiguration > xGlobalCfg = m_xGlobalCfg;
- css::uno::Reference< css::ui::XAcceleratorConfiguration > xModuleCfg = m_xModuleCfg;
- css::uno::Reference< css::ui::XAcceleratorConfiguration > xDocCfg = m_xDocCfg ;
-
- aLock.clear();
- // <- SAFE ----------------------------------
-
- ::rtl::OUString sCommand;
- try
- {
- if (xDocCfg.is())
- sCommand = xDocCfg->getCommandByKeyEvent(aKey);
- }
- catch(const css::container::NoSuchElementException&)
- {
- try
- {
- if (xModuleCfg.is())
- sCommand = xModuleCfg->getCommandByKeyEvent(aKey);
- }
- catch(const css::container::NoSuchElementException&)
- {
- try
- {
- if (xGlobalCfg.is())
- sCommand = xGlobalCfg->getCommandByKeyEvent(aKey);
- }
- catch(const css::container::NoSuchElementException&)
- {}
- }
- }
-
- return sCommand;
-}
-
-//-----------------------------------------------
-css::uno::Reference< css::ui::XAcceleratorConfiguration > AcceleratorExecute::impl_st_openGlobalConfig(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR)
-{
- css::uno::Reference< css::ui::XAcceleratorConfiguration > xAccCfg(
- xSMGR->createInstance(SERVICENAME_GLOBALACCELERATORCONFIGURATION),
- css::uno::UNO_QUERY_THROW);
- return xAccCfg;
-}
-
-//-----------------------------------------------
-css::uno::Reference< css::ui::XAcceleratorConfiguration > AcceleratorExecute::impl_st_openModuleConfig(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR ,
- const css::uno::Reference< css::frame::XFrame >& xFrame)
-{
- css::uno::Reference< css::frame::XModuleManager > xModuleDetection(
- xSMGR->createInstance(SERVICENAME_MODULEMANAGER),
- css::uno::UNO_QUERY_THROW);
-
- ::rtl::OUString sModule;
- try
- {
- sModule = xModuleDetection->identify(xFrame);
- }
- catch(const css::uno::RuntimeException& exRuntime)
- { throw exRuntime; }
- catch(const css::uno::Exception&)
- { return css::uno::Reference< css::ui::XAcceleratorConfiguration >(); }
-
- css::uno::Reference< css::ui::XModuleUIConfigurationManagerSupplier > xUISupplier(
- xSMGR->createInstance(SERVICENAME_MODULEUICONFIGURATIONMANAGERSUPPLIER),
- css::uno::UNO_QUERY_THROW);
-
- css::uno::Reference< css::ui::XUIConfigurationManager > xUIManager = xUISupplier->getUIConfigurationManager(sModule);
- css::uno::Reference< css::ui::XAcceleratorConfiguration > xAccCfg (xUIManager->getShortCutManager(), css::uno::UNO_QUERY_THROW);
- return xAccCfg;
-}
-
-//-----------------------------------------------
-css::uno::Reference< css::ui::XAcceleratorConfiguration > AcceleratorExecute::impl_st_openDocConfig(const css::uno::Reference< css::frame::XModel >& xModel)
-{
- css::uno::Reference< css::ui::XUIConfigurationManagerSupplier > xUISupplier(xModel, css::uno::UNO_QUERY_THROW);
- css::uno::Reference< css::ui::XUIConfigurationManager > xUIManager = xUISupplier->getUIConfigurationManager();
- css::uno::Reference< css::ui::XAcceleratorConfiguration > xAccCfg (xUIManager->getShortCutManager(), css::uno::UNO_QUERY_THROW);
- return xAccCfg;
-}
-
-//-----------------------------------------------
-css::uno::Reference< css::util::XURLTransformer > AcceleratorExecute::impl_ts_getURLParser()
-{
- // SAFE -> ----------------------------------
- ::osl::ResettableMutexGuard aLock(m_aLock);
-
- if (m_xURLParser.is())
- return m_xURLParser;
- css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR = m_xSMGR;
-
- aLock.clear();
- // <- SAFE ----------------------------------
-
- css::uno::Reference< css::util::XURLTransformer > xParser(
- xSMGR->createInstance(SERVICENAME_URLTRANSFORMER),
- css::uno::UNO_QUERY_THROW);
-
- // SAFE -> ----------------------------------
- aLock.reset();
- m_xURLParser = xParser;
- aLock.clear();
- // <- SAFE ----------------------------------
-
- return xParser;
-}
-
-//-----------------------------------------------
-IMPL_LINK(AcceleratorExecute, impl_ts_asyncCallback, void*, pVoid)
-{
- // SAFE -> ----------------------------------
- ::osl::ResettableMutexGuard aLock(m_aLock);
-
- TCommandQueue::iterator pIt = m_lCommandQueue.begin();
- if (pIt == m_lCommandQueue.end())
- return 0;
- ::rtl::OUString sCommand = *pIt;
- m_lCommandQueue.erase(pIt);
-
- css::uno::Reference< css::frame::XDispatchProvider > xProvider = m_xDispatcher;
-
- aLock.clear();
- // <- SAFE ----------------------------------
-
- // convert command in URL structure
- css::uno::Reference< css::util::XURLTransformer > xParser = impl_ts_getURLParser();
- css::util::URL aURL;
- aURL.Complete = sCommand;
- xParser->parseStrict(aURL);
-
- // ask for dispatch object
- css::uno::Reference< css::frame::XDispatch > xDispatch = xProvider->queryDispatch(aURL, ::rtl::OUString(), 0);
- css::uno::Sequence< css::beans::PropertyValue> aArgs;
- if (xDispatch.is())
- {
- if(::comphelper::UiEventsLogger::isEnabled()) //#i88653#
- {
- Sequence<css::beans::PropertyValue> source;
- ::comphelper::UiEventsLogger::appendDispatchOrigin(OUString(RTL_CONSTASCII_USTRINGPARAM("AcceleratorExecute")));
- ::comphelper::UiEventsLogger::logDispatch(aURL, source);
- }
- xDispatch->dispatch(aURL, css::uno::Sequence< css::beans::PropertyValue >());
- }
- return 0;
-}
-
-} // namespace svt
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/source/accelerators/acceleratorexecute.hxx b/framework/source/accelerators/acceleratorexecute.hxx
deleted file mode 100644
index a733e55a550c..000000000000
--- a/framework/source/accelerators/acceleratorexecute.hxx
+++ /dev/null
@@ -1,246 +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 INCLUDED_SVTOOLS_ACCELERATOREXECUTE_HXX
-#define INCLUDED_SVTOOLS_ACCELERATOREXECUTE_HXX
-
-//===============================================
-// includes
-
-#include <vector>
-
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
-
-#include <com/sun/star/frame/XFrame.hpp>
-
-#include <com/sun/star/frame/XDispatchProvider.hpp>
-
-#include <com/sun/star/ui/XAcceleratorConfiguration.hpp>
-
-#include <com/sun/star/util/XURLTransformer.hpp>
-
-#include <com/sun/star/awt/KeyEvent.hpp>
-#include <vcl/keycod.hxx>
-#include <vcl/evntpost.hxx>
-#include <osl/mutex.h>
-
-//===============================================
-// namespace
-
-namespace svt
-{
-
-#ifdef css
- #error "Who define css? I need it as namespace alias."
-#else
- #define css ::com::sun::star
-#endif
-
-//===============================================
-// definitions
-
-struct TMutexInit
-{
- ::osl::Mutex m_aLock;
-};
-
-//===============================================
-/**
- @descr implements a helper, which can be used to
- convert vcl key codes into awt key codes ...
- and reverse.
-
- Further such key code can be triggered.
- Doing so different accelerator
- configurations are merged together; a suitable
- command registered for the given key code is searched
- and will be dispatched.
-
- @attention
-
- Because exceution of an accelerator command can be dangerous
- (in case it force an office shutdown for key "ALT+F4"!)
- all internal dispatches are done asynchronous.
- Menas that the trigger call doesnt wait till the dispatch
- is finished. You can call very often. All requests will be
- queued internal and dispatched ASAP.
-
- Of course this queue will be stopped if the environment
- will be destructed ...
- */
-class AcceleratorExecute : private TMutexInit
-{
- //-------------------------------------------
- // const, types
- private:
-
- /** TODO document me */
- typedef ::std::vector< ::rtl::OUString > TCommandQueue;
-
- //-------------------------------------------
- // member
- private:
-
- /** TODO document me */
- css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMGR;
-
- /** TODO document me */
- css::uno::Reference< css::util::XURLTransformer > m_xURLParser;
-
- /** TODO document me */
- css::uno::Reference< css::frame::XDispatchProvider > m_xDispatcher;
-
- /** TODO document me */
- css::uno::Reference< css::ui::XAcceleratorConfiguration > m_xGlobalCfg;
- css::uno::Reference< css::ui::XAcceleratorConfiguration > m_xModuleCfg;
- css::uno::Reference< css::ui::XAcceleratorConfiguration > m_xDocCfg;
-
- /** TODO document me */
- TCommandQueue m_lCommandQueue;
-
- /** TODO document me */
- ::vcl::EventPoster m_aAsyncCallback;
-
- //-------------------------------------------
- // interface
- public:
-
- //---------------------------------------
- /** @short factory method to create new accelerator
- helper instance.
-
- @descr Such helper instance must be initialized at first.
- So it can know its environment (global/module or
- document specific).
-
- Afterwards it can be used to execute incoming
- accelerator requests.
-
- The "end of life" of such helper can be reached as follow:
-
- - delete the object
- => If it stands currently in its execute method, they will
- be finished. All further queued requests will be removed
- and further not executed!
-
- Other modes are possible and will be implemented ASAP :-)
- */
- static AcceleratorExecute* createAcceleratorHelper();
-
- //---------------------------------------
- /** @short fight against inlining ... */
- virtual ~AcceleratorExecute();
-
- //---------------------------------------
- /** @short init this instance.
-
- @descr It must be called as first method after creation.
- And further it can be called more then once ...
- but at least its should be used one times only.
- Otherwhise nobody can say, which asynchronous
- executions will be used inside the old and which one
- will be used inside the new environment.
-
- @param xSMGR
- reference to an uno service manager.
-
- @param xEnv
- if it points to a valid frame it will be used
- to execute the dispatch there. Further the frame
- is used to locate the right module configuration
- and use it merged together with the document and
- the global configuration.
-
- If this parameter is set to NULL, the global configuration
- is used only. Further the global Desktop instance is
- used for dispatch.
- */
- virtual void init(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR,
- const css::uno::Reference< css::frame::XFrame >& xEnv );
-
- //---------------------------------------
- /** @short trigger this accelerator.
-
- @descr The internal configuartions are used to find
- as suitable command for this key code.
- This command will be queued and executed later
- asynchronous.
-
- @param aKey
- specify the accelerator for execute.
- */
- virtual void execute(const KeyCode& aKey);
- virtual void execute(const css::awt::KeyEvent& aKey);
-
- //---------------------------------------
- /** TODO document me */
- static css::awt::KeyEvent st_VCLKey2AWTKey(const KeyCode& aKey);
- static KeyCode st_AWTKey2VCLKey(const css::awt::KeyEvent& aKey);
-
- //-------------------------------------------
- // internal
- private:
-
- //---------------------------------------
- /** @short allow creation of instances of this class
- by using our factory only!
- */
- AcceleratorExecute();
- AcceleratorExecute(const AcceleratorExecute& rCopy);
- void operator=(const AcceleratorExecute& rCopy) {};
-
- //---------------------------------------
- /** TODO document me */
- css::uno::Reference< css::ui::XAcceleratorConfiguration > impl_st_openGlobalConfig(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR);
-
- css::uno::Reference< css::ui::XAcceleratorConfiguration > impl_st_openModuleConfig(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR ,
- const css::uno::Reference< css::frame::XFrame >& xFrame);
-
- css::uno::Reference< css::ui::XAcceleratorConfiguration > impl_st_openDocConfig(const css::uno::Reference< css::frame::XModel >& xModel);
-
- //---------------------------------------
- /** TODO document me */
- ::rtl::OUString impl_ts_findCommand(const css::awt::KeyEvent& aKey);
-
- //---------------------------------------
- /** TODO document me */
- css::uno::Reference< css::util::XURLTransformer > impl_ts_getURLParser();
-
- //---------------------------------------
- /** TODO document me */
- DECL_LINK(impl_ts_asyncCallback, void*);
-};
-
-#undef css
-#undef css
-
-} // namespace svt
-
-#endif // INCLUDED_SVTOOLS_ACCELERATOREXECUTE_HXX
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */