diff options
author | Szabolcs Toth <szabolcs450@gmail.com> | 2019-08-12 10:58:40 +0200 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2019-09-04 09:12:32 +0200 |
commit | 5bfa8b8d5e1cf3cb572dbd91bf3b0cfcf29fb65a (patch) | |
tree | fae59caf6125e6fc9e88f04c74a0df5275e84a0b /sfx2/source | |
parent | e8b3df5b9b0eb0a93c25b6dc2e445ae44a7e3f78 (diff) |
tdf#118314 Code clean up on imestatuswindow
Change-Id: I8bc5a73a91f28fcfd22ef716e9cf87d53997b1ad
Reviewed-on: https://gerrit.libreoffice.org/77337
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sfx2/source')
-rw-r--r-- | sfx2/source/appl/app.cxx | 3 | ||||
-rw-r--r-- | sfx2/source/appl/appdata.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/appl/appserv.cxx | 26 | ||||
-rw-r--r-- | sfx2/source/appl/imestatuswindow.cxx | 229 | ||||
-rw-r--r-- | sfx2/source/appl/imestatuswindow.hxx | 119 | ||||
-rw-r--r-- | sfx2/source/inc/appdata.hxx | 3 |
6 files changed, 0 insertions, 382 deletions
diff --git a/sfx2/source/appl/app.cxx b/sfx2/source/appl/app.cxx index e919d86c28a9..a8a5b58f867d 100644 --- a/sfx2/source/appl/app.cxx +++ b/sfx2/source/appl/app.cxx @@ -66,7 +66,6 @@ #include <openflag.hxx> #include <sfx2/module.hxx> #include <sfx2/event.hxx> -#include "imestatuswindow.hxx" #include <workwin.hxx> #include <sfx2/sidebar/Theme.hxx> #include <sfx2/tbxctrl.hxx> @@ -174,8 +173,6 @@ SfxApplication::SfxApplication() if (!utl::ConfigManager::IsFuzzing()) SvtViewOptions::AcquireOptions(); - pImpl->m_xImeStatusWindow->init(); - SAL_INFO( "sfx.appl", "{ initialize DDE" ); bool bOk = InitializeDde(); diff --git a/sfx2/source/appl/appdata.cxx b/sfx2/source/appl/appdata.cxx index a3e786b4033c..cc6a0ce1a1ee 100644 --- a/sfx2/source/appl/appdata.cxx +++ b/sfx2/source/appl/appdata.cxx @@ -41,7 +41,6 @@ #include <sfx2/sidebar/Theme.hxx> #include <sfx2/unoctitm.hxx> #include <objshimp.hxx> -#include "imestatuswindow.hxx" #include <appbaslib.hxx> #include <childwinimpl.hxx> #include <svl/svdde.hxx> @@ -94,7 +93,6 @@ SfxAppData_Impl::SfxAppData_Impl() , pProgress(nullptr) , nDocModalMode(0) , nRescheduleLocks(0) - , m_xImeStatusWindow(new sfx2::appl::ImeStatusWindow(comphelper::getProcessComponentContext())) , pTbxCtrlFac(nullptr) , pStbCtrlFac(nullptr) , pViewFrames(nullptr) diff --git a/sfx2/source/appl/appserv.cxx b/sfx2/source/appl/appserv.cxx index 423518605fee..cc892ba1ad67 100644 --- a/sfx2/source/appl/appserv.cxx +++ b/sfx2/source/appl/appserv.cxx @@ -118,7 +118,6 @@ #include <sfx2/module.hxx> #include <sfx2/viewfrm.hxx> #include <sfxpicklist.hxx> -#include "imestatuswindow.hxx" #include <sfx2/sfxdlg.hxx> #include <sfx2/sfxsids.hrc> #include <sorgitm.hxx> @@ -703,21 +702,6 @@ void SfxApplication::MiscExec_Impl( SfxRequest& rReq ) break; #endif - case SID_SHOW_IME_STATUS_WINDOW: - if (sfx2::appl::ImeStatusWindow::canToggle()) - { - const SfxBoolItem * pItem = rReq.GetArg<SfxBoolItem>(SID_SHOW_IME_STATUS_WINDOW); - bool bShow = pItem == nullptr - ? !pImpl->m_xImeStatusWindow->isShowing() - : pItem->GetValue(); - pImpl->m_xImeStatusWindow->show(bShow); - if (pItem == nullptr) - rReq.AppendItem(SfxBoolItem(SID_SHOW_IME_STATUS_WINDOW, - bShow)); - } - bDone = true; - break; - case SID_ZOOM_50_PERCENT: case SID_ZOOM_75_PERCENT: case SID_ZOOM_100_PERCENT: @@ -1150,16 +1134,6 @@ void SfxApplication::MiscState_Impl(SfxItemSet &rSet) break; } - case SID_SHOW_IME_STATUS_WINDOW: - if (sfx2::appl::ImeStatusWindow::canToggle()) - rSet.Put(SfxBoolItem( - SID_SHOW_IME_STATUS_WINDOW, - pImpl->m_xImeStatusWindow-> - isShowing())); - else - rSet.DisableItem(SID_SHOW_IME_STATUS_WINDOW); - break; - case SID_TEMPLATE_MANAGER: { SvtMiscOptions aMiscOptions; diff --git a/sfx2/source/appl/imestatuswindow.cxx b/sfx2/source/appl/imestatuswindow.cxx deleted file mode 100644 index 4fad9d3e2732..000000000000 --- a/sfx2/source/appl/imestatuswindow.cxx +++ /dev/null @@ -1,229 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - - -#include "imestatuswindow.hxx" - -#include <sfx2/app.hxx> -#include <sfx2/sfxsids.hrc> - -#include <com/sun/star/beans/PropertyState.hpp> -#include <com/sun/star/beans/PropertyValue.hpp> -#include <com/sun/star/beans/XPropertySet.hpp> -#include <com/sun/star/configuration/theDefaultProvider.hpp> -#include <com/sun/star/lang/DisposedException.hpp> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <com/sun/star/uno/Any.hxx> -#include <com/sun/star/uno/Exception.hpp> -#include <com/sun/star/uno/Reference.hxx> -#include <com/sun/star/uno/RuntimeException.hpp> -#include <com/sun/star/uno/Sequence.hxx> -#include <com/sun/star/util/XChangesBatch.hpp> -#include <osl/diagnose.h> -#include <osl/mutex.hxx> -#include <rtl/ustring.h> -#include <rtl/ustring.hxx> -#include <sal/types.h> -#include <vcl/svapp.hxx> -#include <cppuhelper/implbase.hxx> -#include <cppuhelper/weakref.hxx> - -//TO-Do, merge into framework/inc/helpers/mischelpers.hxx and deliver -class WeakPropertyChangeListener : public ::cppu::WeakImplHelper<css::beans::XPropertyChangeListener> -{ - private: - css::uno::WeakReference<css::beans::XPropertyChangeListener> mxOwner; - - public: - explicit WeakPropertyChangeListener(css::uno::Reference<css::beans::XPropertyChangeListener> const & xOwner) - : mxOwner(xOwner) - { - } - - virtual void SAL_CALL propertyChange(const css::beans::PropertyChangeEvent &rEvent ) override - { - css::uno::Reference<css::beans::XPropertyChangeListener> xOwner(mxOwner.get(), - css::uno::UNO_QUERY); - if (xOwner.is()) - xOwner->propertyChange(rEvent); - - } - - // lang.XEventListener - virtual void SAL_CALL disposing(const css::lang::EventObject& rEvent) override - { - css::uno::Reference<css::beans::XPropertyChangeListener> xOwner(mxOwner.get(), - css::uno::UNO_QUERY); - if (xOwner.is()) - xOwner->disposing(rEvent); - - } -}; - -using sfx2::appl::ImeStatusWindow; - -ImeStatusWindow::ImeStatusWindow( - css::uno::Reference< css::uno::XComponentContext > const & rxContext): - m_xContext(rxContext), - m_bDisposed(false) -{} - -void ImeStatusWindow::init() -{ - if (!Application::CanToggleImeStatusWindow()) - return; - - try - { - bool bShow; - if (getConfig()->getPropertyValue("ShowStatusWindow") >>= bShow) - Application::ShowImeStatusWindow(bShow); - } - catch (css::uno::Exception &) - { - OSL_FAIL("com.sun.star.uno.Exception"); - // Degrade gracefully and use the VCL-supplied default if no - // configuration is available. - } -} - -bool ImeStatusWindow::isShowing() -{ - try - { - bool bShow(false); - if (getConfig()->getPropertyValue("ShowStatusWindow") >>= bShow) - return bShow; - } - catch (css::uno::Exception &) - { - OSL_FAIL("com.sun.star.uno.Exception"); - // Degrade gracefully and use the VCL-supplied default if no - // configuration is available. - } - return Application::GetShowImeStatusWindowDefault(); -} - -void ImeStatusWindow::show(bool bShow) -{ - try - { - css::uno::Reference< css::beans::XPropertySet > xConfig(getConfig()); - xConfig->setPropertyValue( - "ShowStatusWindow", - css::uno::makeAny(bShow)); - css::uno::Reference< css::util::XChangesBatch > xCommit( - xConfig, css::uno::UNO_QUERY); - // Degrade gracefully by not saving the settings permanently: - if (xCommit.is()) - xCommit->commitChanges(); - // Alternatively, setting the VCL status could be done even if updating - // the configuration failed: - Application::ShowImeStatusWindow(bShow); - } - catch (css::uno::Exception &) - { - OSL_FAIL("com.sun.star.uno.Exception"); - } -} - -bool ImeStatusWindow::canToggle() -{ - return Application::CanToggleImeStatusWindow(); -} - -ImeStatusWindow::~ImeStatusWindow() -{ - if (m_xConfig.is() && m_xConfigListener.is()) - // We should never get here, but just in case... - try - { - m_xConfig->removePropertyChangeListener( - "ShowStatusWindow", - m_xConfigListener); - } - catch (css::uno::Exception &) - { - OSL_FAIL("com.sun.star.uno.RuntimeException"); - } -} - -void SAL_CALL ImeStatusWindow::disposing(css::lang::EventObject const & ) -{ - osl::MutexGuard aGuard(m_aMutex); - m_xConfig = nullptr; - m_bDisposed = true; -} - -void SAL_CALL -ImeStatusWindow::propertyChange(css::beans::PropertyChangeEvent const & ) -{ - SolarMutexGuard aGuard; - SfxApplication* pApp = SfxApplication::Get(); - if (pApp) - pApp->Invalidate(SID_SHOW_IME_STATUS_WINDOW); -} - -css::uno::Reference< css::beans::XPropertySet > ImeStatusWindow::getConfig() -{ - css::uno::Reference< css::beans::XPropertySet > xConfig; - bool bAdd = false; - { - osl::MutexGuard aGuard(m_aMutex); - if (!m_xConfig.is()) - { - if (m_bDisposed) - throw css::lang::DisposedException(); - if (!m_xContext.is()) - throw css::uno::RuntimeException( - "null comphelper::getProcessServiceFactory", - nullptr); - css::uno::Reference< css::lang::XMultiServiceFactory > xProvider = - css::configuration::theDefaultProvider::get( m_xContext ); - css::beans::PropertyValue aArg( - "nodepath", -1, - css::uno::makeAny( - OUString( - "/org.openoffice.Office.Common/I18N/InputMethod")), - css::beans::PropertyState_DIRECT_VALUE); - css::uno::Sequence< css::uno::Any > aArgs(1); - aArgs[0] <<= aArg; - m_xConfig.set( - xProvider->createInstanceWithArguments( - "com.sun.star.configuration.ConfigurationUpdateAccess", - aArgs), - css::uno::UNO_QUERY_THROW); - bAdd = true; - } - xConfig = m_xConfig; - } - if (bAdd) - { - // Exceptions here could be handled individually, to support graceful - // degradation (no update notification mechanism in this case---but also - // no dispose notifications): - m_xConfigListener = new WeakPropertyChangeListener(this); - xConfig->addPropertyChangeListener( - "ShowStatusWindow", - m_xConfigListener); - } - return xConfig; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/appl/imestatuswindow.hxx b/sfx2/source/appl/imestatuswindow.hxx deleted file mode 100644 index 79bf806328b6..000000000000 --- a/sfx2/source/appl/imestatuswindow.hxx +++ /dev/null @@ -1,119 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_SFX2_SOURCE_APPL_IMESTATUSWINDOW_HXX -#define INCLUDED_SFX2_SOURCE_APPL_IMESTATUSWINDOW_HXX - -#include <com/sun/star/beans/XPropertyChangeListener.hpp> -#include <com/sun/star/uno/Reference.hxx> -#include <cppuhelper/implbase.hxx> -#include <osl/mutex.hxx> - -namespace com { namespace sun { namespace star { - namespace beans { class XPropertySet; } - namespace lang { class XMultiServiceFactory; } - namespace uno { class XComponentContext; } -} } } - -namespace sfx2 { namespace appl { - -// The MS compiler needs this typedef work-around to accept the using -// declarations within ImeStatusWindow: -typedef cppu::WeakImplHelper< css::beans::XPropertyChangeListener > ImeStatusWindow_Impl; - -/** Control the behavior of any (platform-dependent) IME status windows. - - The decision of whether a status window shall be displayed or not can be - stored permanently in the configuration (under key - org.openoffice.office.Common/I18N/InputMethod/ShowStatusWindow; if that - entry is nil, VCL is asked for a default). - */ -class ImeStatusWindow: private ImeStatusWindow_Impl -{ -public: - explicit ImeStatusWindow( css::uno::Reference< css::uno::XComponentContext > const& rxContext ); - - /** Set up VCL according to the configuration. - - Is it not strictly required that this method is called exactly once - (though that will be the typical use). - - Must only be called with the Solar mutex locked. - */ - void init(); - - /** Return true if the status window is toggled on. - - This is only meaningful when canToggle returns true. - - Can be called without the Solar mutex locked. - */ - bool isShowing(); - - /** Toggle the status window on or off. - - This only works if canToggle returns true (otherwise, any calls of this - method are ignored). - - Must only be called with the Solar mutex locked. - */ - void show(bool bShow); - - /** Return true if the status window can be toggled on and off externally. - - Must only be called with the Solar mutex locked. - */ - static bool canToggle(); - - using ImeStatusWindow_Impl::acquire; - using ImeStatusWindow_Impl::release; - using ImeStatusWindow_Impl::operator new; - using ImeStatusWindow_Impl::operator delete; - -private: - ImeStatusWindow(ImeStatusWindow const &) = delete; - void operator =(const ImeStatusWindow&) = delete; - - virtual ~ImeStatusWindow() override; - - virtual void SAL_CALL - disposing(css::lang::EventObject const & rSource) override; - - virtual void SAL_CALL - propertyChange(css::beans::PropertyChangeEvent const & rEvent) override; - - css::uno::Reference< css::beans::XPropertySet > - getConfig(); - - css::uno::Reference< css::uno::XComponentContext > - m_xContext; - - osl::Mutex m_aMutex; - css::uno::Reference< css::beans::XPropertySet > - m_xConfig; - css::uno::Reference< css::beans::XPropertyChangeListener > - m_xConfigListener; - bool m_bDisposed; -}; - -} } - -#endif // INCLUDED_SFX2_SOURCE_APPL_IMESTATUSWINDOW_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/inc/appdata.hxx b/sfx2/source/inc/appdata.hxx index 5f892442bc4a..b38779dd7c71 100644 --- a/sfx2/source/inc/appdata.hxx +++ b/sfx2/source/inc/appdata.hxx @@ -58,7 +58,6 @@ class SfxBasicManagerHolder; class SfxBasicManagerCreationListener; namespace sfx2 { - namespace appl { class ImeStatusWindow; } namespace sidebar { class Theme; } } @@ -101,8 +100,6 @@ public: sal_uInt16 nDocModalMode; // counts documents in modal mode sal_uInt16 nRescheduleLocks; - rtl::Reference< sfx2::appl::ImeStatusWindow > m_xImeStatusWindow; - SfxTbxCtrlFactArr_Impl* pTbxCtrlFac; SfxStbCtrlFactArr_Impl* pStbCtrlFac; SfxViewFrameArr_Impl* pViewFrames; |