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>
diff --git a/compilerplugins/clang/badstatics.cxx b/compilerplugins/clang/badstatics.cxx
index 1c099a1..5f1edea 100644
--- a/compilerplugins/clang/badstatics.cxx
+++ b/compilerplugins/clang/badstatics.cxx
@@ -159,8 +159,7 @@
            && pVarDecl->isThisDeclarationADefinition())
        {
            auto const name(pVarDecl->getName());
            if (   name == "g_pI18NStatusInstance" // I18NStatus::free()
                || name == "s_pPreviousView" // not an owning pointer
            if (   name == "s_pPreviousView" // not an owning pointer
                || name == "s_pDefCollapsed" // SvImpLBox::~SvImpLBox()
                || name == "s_pDefExpanded"  // SvImpLBox::~SvImpLBox()
                || name == "g_pDDSource" // SvTreeListBox::dispose()
diff --git a/compilerplugins/clang/unusedenumconstants.writeonly.results b/compilerplugins/clang/unusedenumconstants.writeonly.results
index e1a9019..38d6a17 100644
--- a/compilerplugins/clang/unusedenumconstants.writeonly.results
+++ b/compilerplugins/clang/unusedenumconstants.writeonly.results
@@ -10414,8 +10414,6 @@
    enum SalFrameStyleFlags NOSHADOW
vcl/inc/salptype.hxx:32
    enum JobSetFlags ALL
vcl/inc/svdata.hxx:134
    enum ImplSVAppData::ImeStatusWindowMode ImeStatusWindowMode_UNKNOWN
vcl/inc/unx/desktops.hxx:29
    enum DesktopType DESKTOP_UNKNOWN
vcl/inc/unx/i18n_cb.hxx:67
diff --git a/include/sfx2/sfxsids.hrc b/include/sfx2/sfxsids.hrc
index 1dcc40f..80c92e1 100644
--- a/include/sfx2/sfxsids.hrc
+++ b/include/sfx2/sfxsids.hrc
@@ -211,7 +211,6 @@
#define SID_INTERACTIONHANDLER              (SID_SFX_START + 1675)
#define SID_OPENHYPERLINK                   (SID_SFX_START + 1676)
#define SID_CONTENT                         (SID_SFX_START + 1679)
#define SID_SHOW_IME_STATUS_WINDOW          (SID_SFX_START + 1680)
#define SID_VIEWONLY                        (SID_SFX_START + 1682)
#define SID_REPAIRPACKAGE                       (SID_SFX_START + 1683)
#define SID_MINIMIZED                       (SID_SFX_START + 1687)
diff --git a/include/vcl/svapp.hxx b/include/vcl/svapp.hxx
index 8fc5d0d..16b8015 100644
--- a/include/vcl/svapp.hxx
+++ b/include/vcl/svapp.hxx
@@ -1253,48 +1253,6 @@

    ///@}

    /** @name IME Status Window Control
    */
    ///@{

    /** Determine application can toggle the IME status window on and off.

      @attention Must only be called with the Solar mutex locked.

      @return true if any IME status window can be toggled on and off
            externally.

      @see ShowImeStatusWindow, GetShowImeStatusWindowDefault,
           GetShowImeStatusWindowDefault
     */
    static bool                 CanToggleImeStatusWindow();

    /** Toggle any IME status window on and off.

     This only works if CanToggleImeStatusWindow returns true (otherwise,
     any calls of this method are ignored).

     @remark Can be called without the Solar mutex locked.

     @param      bShow       If true, then show the IME status window

     @see GetShowImeStatusWindowDefault, CanToggleImeStatusWindow,
          GetShowImeStatusWindow
    */
    static void                 ShowImeStatusWindow(bool bShow);

    /** Determines if the IME status window should be turned of by default.

      @return true if any IME status window should be turned on by default
      (this decision can be locale dependent, for example).

      @see ShowImeStatusWindow, GetShowImeStatusWindowDefault,
           CanToggleImeStatusWindow
     */
    static bool                 GetShowImeStatusWindowDefault();

    ///@}

    /** Get the desktop environment the process is currently running in

     @returns String representing the desktop environment
diff --git a/sfx2/Library_sfx.mk b/sfx2/Library_sfx.mk
index 2ca2943..2973fd0 100644
--- a/sfx2/Library_sfx.mk
+++ b/sfx2/Library_sfx.mk
@@ -98,7 +98,6 @@
    sfx2/source/appl/fwkhelper \
    sfx2/source/appl/helpdispatch \
    sfx2/source/appl/helpinterceptor \
    sfx2/source/appl/imestatuswindow \
    sfx2/source/appl/impldde \
    sfx2/source/appl/linkmgr2 \
    sfx2/source/appl/linksrc \
diff --git a/sfx2/sdi/appslots.sdi b/sfx2/sdi/appslots.sdi
index c1444d4..1d8ac05 100644
--- a/sfx2/sdi/appslots.sdi
+++ b/sfx2/sdi/appslots.sdi
@@ -111,11 +111,6 @@
        ExecMethod = MiscExec_Impl ;
        StateMethod = MiscState_Impl ;
    ]
    SID_SHOW_IME_STATUS_WINDOW
    [
        ExecMethod = MiscExec_Impl ;
        StateMethod = MiscState_Impl ;
    ]
    SID_SEND_FEEDBACK
    [
        ExecMethod = MiscExec_Impl ;
diff --git a/sfx2/sdi/sfx.sdi b/sfx2/sdi/sfx.sdi
index 29bef29..87a478d 100644
--- a/sfx2/sdi/sfx.sdi
+++ b/sfx2/sdi/sfx.sdi
@@ -4867,25 +4867,6 @@
    GroupId = SfxGroupId::View;
]


SfxBoolItem ShowImeStatusWindow SID_SHOW_IME_STATUS_WINDOW
[
    AutoUpdate = FALSE,
    FastCall = FALSE,
    ReadOnlyDoc = TRUE,
    Toggle = FALSE,
    Container = TRUE,
    RecordAbsolute = FALSE,
    RecordPerSet;


    AccelConfig = FALSE,
    MenuConfig = FALSE,
    ToolBoxConfig = FALSE,
    GroupId = SfxGroupId::View;
]


SfxVoidItem SendFeedback SID_SEND_FEEDBACK
()
[
diff --git a/sfx2/source/appl/app.cxx b/sfx2/source/appl/app.cxx
index e919d86..a8a5b58 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 @@
    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 a3e786b..cc6a0ce 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 @@
    , 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 4235186..cc892ba 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 @@
            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 @@
                    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 4fad9d3..0000000
--- 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 79bf806..0000000
--- 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 5f89244..b38779d 100644
--- a/sfx2/source/inc/appdata.hxx
+++ b/sfx2/source/inc/appdata.hxx
@@ -58,7 +58,6 @@
class SfxBasicManagerCreationListener;

namespace sfx2 {
    namespace appl { class ImeStatusWindow; }
    namespace sidebar { class Theme; }
}

@@ -101,8 +100,6 @@
    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;
diff --git a/solenv/clang-format/blacklist b/solenv/clang-format/blacklist
index 9a9845a..97aa283 100644
--- a/solenv/clang-format/blacklist
+++ b/solenv/clang-format/blacklist
@@ -12629,8 +12629,6 @@
sfx2/source/appl/helpdispatch.hxx
sfx2/source/appl/helpinterceptor.cxx
sfx2/source/appl/helpinterceptor.hxx
sfx2/source/appl/imestatuswindow.cxx
sfx2/source/appl/imestatuswindow.hxx
sfx2/source/appl/impldde.cxx
sfx2/source/appl/impldde.hxx
sfx2/source/appl/linkmgr2.cxx
@@ -17360,7 +17358,6 @@
vcl/inc/salgdi.hxx
vcl/inc/salgdiimpl.hxx
vcl/inc/salgeom.hxx
vcl/inc/salimestatus.hxx
vcl/inc/salinst.hxx
vcl/inc/sallayout.hxx
vcl/inc/salmenu.hxx
@@ -17419,7 +17416,6 @@
vcl/inc/unx/i18n_ic.hxx
vcl/inc/unx/i18n_im.hxx
vcl/inc/unx/i18n_keysym.hxx
vcl/inc/unx/i18n_status.hxx
vcl/inc/unx/i18n_xkb.hxx
vcl/inc/unx/nativewindowhandleprovider.hxx
vcl/inc/unx/pixmap.hxx
@@ -18039,7 +18035,6 @@
vcl/unx/generic/app/i18n_ic.cxx
vcl/unx/generic/app/i18n_im.cxx
vcl/unx/generic/app/i18n_keysym.cxx
vcl/unx/generic/app/i18n_status.cxx
vcl/unx/generic/app/i18n_xkb.cxx
vcl/unx/generic/app/keysymnames.cxx
vcl/unx/generic/app/randrwrapper.cxx
diff --git a/vcl/Library_vclplug_gen.mk b/vcl/Library_vclplug_gen.mk
index 8781324..01189a1 100644
--- a/vcl/Library_vclplug_gen.mk
+++ b/vcl/Library_vclplug_gen.mk
@@ -72,7 +72,6 @@
    vcl/unx/generic/app/i18n_ic \
    vcl/unx/generic/app/i18n_im \
    vcl/unx/generic/app/i18n_keysym \
    vcl/unx/generic/app/i18n_status \
    vcl/unx/generic/app/i18n_xkb \
    vcl/unx/generic/app/keysymnames \
    vcl/unx/generic/app/randrwrapper \
diff --git a/vcl/inc/pch/precompiled_vcl.hxx b/vcl/inc/pch/precompiled_vcl.hxx
index 5e0540f..2bec1f8 100644
--- a/vcl/inc/pch/precompiled_vcl.hxx
+++ b/vcl/inc/pch/precompiled_vcl.hxx
@@ -251,7 +251,6 @@
#include <salframe.hxx>
#include <salgdi.hxx>
#include <salgdiimpl.hxx>
#include <salimestatus.hxx>
#include <sallayout.hxx>
#include <salmenu.hxx>
#include <salobj.hxx>
diff --git a/vcl/inc/salimestatus.hxx b/vcl/inc/salimestatus.hxx
deleted file mode 100644
index 1b97d5d..0000000
--- a/vcl/inc/salimestatus.hxx
+++ /dev/null
@@ -1,39 +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_VCL_INC_SALIMESTATUS_HXX
#define INCLUDED_VCL_INC_SALIMESTATUS_HXX

#include <vcl/dllapi.h>

class VCL_PLUGIN_PUBLIC SalI18NImeStatus
{
public:
    SalI18NImeStatus() {}
    virtual ~SalI18NImeStatus();

    // asks whether there is a status window available
    // to toggle into menubar
    virtual bool canToggle() { return false; }
    virtual void toggle() {}
};

#endif

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/salinst.hxx b/vcl/inc/salinst.hxx
index 5ac470b3..f8935ba 100644
--- a/vcl/inc/salinst.hxx
+++ b/vcl/inc/salinst.hxx
@@ -65,7 +65,6 @@
class SalPrinter;
class SalTimer;
class ImplPrnQueueList;
class SalI18NImeStatus;
class SalSystem;
class SalBitmap;
struct SalItemParams;
@@ -128,9 +127,6 @@

    // SalTimer
    virtual SalTimer*       CreateSalTimer() = 0;
    // interface to ime status window, only used by the X11 backend
    virtual std::unique_ptr<SalI18NImeStatus>
                            CreateI18NImeStatus();
    // SalSystem
    virtual SalSystem*      CreateSalSystem() = 0;
    // SalBitmap
diff --git a/vcl/inc/svdata.hxx b/vcl/inc/svdata.hxx
index 747adb1..0e6fde8 100644
--- a/vcl/inc/svdata.hxx
+++ b/vcl/inc/svdata.hxx
@@ -84,7 +84,6 @@
class GraphicConverter;
class ImplWheelWindow;
class SalTimer;
class SalI18NImeStatus;
class DockingManager;
class VclEventListeners2;
class SalData;
@@ -129,12 +128,6 @@
struct ImplSVAppData
{
    ~ImplSVAppData();
    enum ImeStatusWindowMode
    {
        ImeStatusWindowMode_UNKNOWN,
        ImeStatusWindowMode_HIDE,
        ImeStatusWindowMode_SHOW
    };

    std::unique_ptr<AllSettings> mpSettings;           // Application settings
    LocaleConfigurationListener* mpCfgListener = nullptr;
@@ -160,13 +153,6 @@
    DialogCancelMode meDialogCancel = DialogCancelMode::Off; // true: All Dialog::Execute() calls will be terminated immediately with return false
    bool mbRenderToBitmaps = false; // set via svp / headless plugin

    /** Controls whether showing any IME status window is toggled on or off.

        Only meaningful if showing IME status windows can be toggled on and off
        externally (see Application::CanToggleImeStatusWindow).
     */
    ImeStatusWindowMode meShowImeStatusWindow = ImeStatusWindowMode_UNKNOWN;

    SvFileStream*       mpEventTestInput = nullptr;
    Idle*               mpEventTestingIdle = nullptr;
    int                 mnEventTestLimit = 0;
@@ -356,7 +342,6 @@
    Application*            mpApp = nullptr;                // pApp
    VclPtr<WorkWindow>      mpDefaultWin;                   // Default-Window
    bool                    mbDeInit = false;               // Is VCL deinitializing
    std::unique_ptr<SalI18NImeStatus> mpImeStatus;          // interface to ime status window, only used by the X11 backend
    std::unique_ptr<SalSystem> mpSalSystem;                 // SalSystem interface
    int                     mnFontUpdatesLockCount = 0;     // avoid repeated font updates
    bool                    mbFontUpdatesPending = false;   // need to update font data after unlock
diff --git a/vcl/inc/unx/gtk/gtkinst.hxx b/vcl/inc/unx/gtk/gtkinst.hxx
index 2ed92b0..e7543c5 100644
--- a/vcl/inc/unx/gtk/gtkinst.hxx
+++ b/vcl/inc/unx/gtk/gtkinst.hxx
@@ -205,9 +205,6 @@
    virtual SalFrame*           CreateFrame( SalFrame* pParent, SalFrameStyleFlags nStyle ) override;
    virtual SalFrame*           CreateChildFrame( SystemParentData* pParent, SalFrameStyleFlags nStyle ) override;
    virtual SalObject*          CreateObject( SalFrame* pParent, SystemWindowData* pWindowData, bool bShow ) override;
#if !GTK_CHECK_VERSION(3,0,0)
    virtual std::unique_ptr<SalI18NImeStatus> CreateI18NImeStatus() override;
#endif
    virtual SalSystem*          CreateSalSystem() override;
    virtual SalInfoPrinter*     CreateInfoPrinter(SalPrinterQueueInfo* pPrinterQueueInfo, ImplJobSetup* pJobSetup) override;
    virtual std::unique_ptr<SalPrinter> CreatePrinter( SalInfoPrinter* pInfoPrinter ) override;
diff --git a/vcl/inc/unx/i18n_ic.hxx b/vcl/inc/unx/i18n_ic.hxx
index 055b861..f38c1b7 100644
--- a/vcl/inc/unx/i18n_ic.hxx
+++ b/vcl/inc/unx/i18n_ic.hxx
@@ -62,7 +62,7 @@

    void ExtendEventMask(  ::Window aFocusWindow );
    void SetICFocus( SalFrame* pFocusFrame );
    void UnsetICFocus( SalFrame const * pFrame );
    void UnsetICFocus();
    void HandleDestroyIM();

    void EndExtTextInput();
@@ -70,7 +70,7 @@
    int  UpdateSpotLocation();

    void Map( SalFrame *pFrame );
    void Unmap( SalFrame const * pFrame );
    void Unmap();

    SalI18N_InputContext( SalFrame *aFrame );
    ~SalI18N_InputContext();
diff --git a/vcl/inc/unx/i18n_status.hxx b/vcl/inc/unx/i18n_status.hxx
deleted file mode 100644
index 9a87959..0000000
--- a/vcl/inc/unx/i18n_status.hxx
+++ /dev/null
@@ -1,89 +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_VCL_INC_UNX_I18N_STATUS_HXX
#define INCLUDED_VCL_INC_UNX_I18N_STATUS_HXX

#include <rtl/ustring.hxx>
#include <salimestatus.hxx>
#include <vcl/vclptr.hxx>

class SalFrame;
class WorkWindow;
class ListBox;
class FixedText;
class PushButton;
class SalI18N_InputContext;

namespace vcl
{

class StatusWindow;

class X11ImeStatus : public SalI18NImeStatus
{
public:
    X11ImeStatus() {}
    virtual ~X11ImeStatus() override;

    virtual bool canToggle() override;
    virtual void toggle() override;
};

class I18NStatus
{
private:
    SalFrame*                       m_pParent;
    VclPtr<StatusWindow>            m_pStatusWindow;
    OUString const                  m_aCurrentIM;

    I18NStatus();
    ~I18NStatus();

    static bool getStatusWindowMode();

public:
    static I18NStatus& get();
    static bool exists();
    static void free();

    void setParent( SalFrame* pParent );
    SalFrame* getParent() const { return  m_pParent; }
    SalFrame* getStatusFrame() const;

    void setStatusText( const OUString& rText );

    enum ShowReason { focus, presentation, contextmap };
    void show( bool bShow, ShowReason eReason );

    // External Control:

    /** Toggle the status window on or off.

        This only works if canToggleStatusWindow returns true (otherwise, any
        calls of this method are ignored).
     */
    void toggleStatusWindow();
};

} // namespace

#endif // INCLUDED_VCL_INC_UNX_I18N_STATUS_HXX

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/unx/salinst.h b/vcl/inc/unx/salinst.h
index 9ef55fb..e91e179 100644
--- a/vcl/inc/unx/salinst.h
+++ b/vcl/inc/unx/salinst.h
@@ -67,7 +67,6 @@
    virtual GenPspGraphics     *CreatePrintGraphics() override;

    virtual SalTimer*           CreateSalTimer() override;
    virtual std::unique_ptr<SalI18NImeStatus> CreateI18NImeStatus() override;
    virtual SalSystem*          CreateSalSystem() override;
    virtual std::shared_ptr<SalBitmap>  CreateSalBitmap() override;
    virtual std::unique_ptr<SalSession> CreateSalSession() override;
diff --git a/vcl/osx/salinst.cxx b/vcl/osx/salinst.cxx
index 6ed28b7..4a23166 100644
--- a/vcl/osx/salinst.cxx
+++ b/vcl/osx/salinst.cxx
@@ -59,7 +59,6 @@
#include <osx/runinmain.hxx>

#include <print.h>
#include <salimestatus.hxx>

#include <comphelper/processfactory.hxx>

diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index 4cd82ef..bf8ac3d 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -24,7 +24,6 @@
#include <salvd.hxx>
#include <salprn.hxx>
#include <saltimer.hxx>
#include <salimestatus.hxx>
#include <salsession.hxx>
#include <salsys.hxx>
#include <salbmp.hxx>
@@ -144,11 +143,6 @@
    return m_pEventInst.is() && m_pEventInst->dispatchEvent( pEvent, nBytes );
}

std::unique_ptr<SalI18NImeStatus> SalInstance::CreateI18NImeStatus()
{
    return std::unique_ptr<SalI18NImeStatus>(new SalI18NImeStatus);
}

SalTimer::~SalTimer() COVERITY_NOEXCEPT_FALSE
{
}
@@ -168,10 +162,6 @@
    DropScaledCache();
}

SalI18NImeStatus::~SalI18NImeStatus()
{
}

SalSystem::~SalSystem()
{
}
diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx
index 28ab180..e0846a5 100644
--- a/vcl/source/app/svapp.cxx
+++ b/vcl/source/app/svapp.cxx
@@ -55,7 +55,6 @@
#include <salframe.hxx>
#include <salsys.hxx>
#include <svdata.hxx>
#include <salimestatus.hxx>
#include <displayconnectiondispatch.hxx>
#include <window.h>
#include <accmgr.hxx>
@@ -1553,34 +1552,6 @@
    }
}

bool Application::CanToggleImeStatusWindow()
{
    ImplSVData* pSVData = ImplGetSVData();
    if( ! pSVData->mpImeStatus )
        pSVData->mpImeStatus  = pSVData->mpDefInst->CreateI18NImeStatus();
    return pSVData->mpImeStatus->canToggle();
}

void Application::ShowImeStatusWindow(bool bShow)
{
    ImplGetSVData()->maAppData.meShowImeStatusWindow = bShow
        ? ImplSVAppData::ImeStatusWindowMode_SHOW
        : ImplSVAppData::ImeStatusWindowMode_HIDE;

    ImplSVData* pSVData = ImplGetSVData();
    if( ! pSVData->mpImeStatus )
        pSVData->mpImeStatus  = pSVData->mpDefInst->CreateI18NImeStatus();
    pSVData->mpImeStatus->toggle();
}

bool Application::GetShowImeStatusWindowDefault()
{
    rtl_TextEncodingInfo aInfo;
    aInfo.StructSize = sizeof aInfo;
    return rtl_getTextEncodingInfo(osl_getThreadTextEncoding(), &aInfo)
        && aInfo.MaximumCharSize > 1;
}

const OUString& Application::GetDesktopEnvironment()
{
    if (IsHeadlessModeEnabled())
diff --git a/vcl/source/app/svdata.cxx b/vcl/source/app/svdata.cxx
index 936ddf5..ede298e7 100644
--- a/vcl/source/app/svdata.cxx
+++ b/vcl/source/app/svdata.cxx
@@ -40,7 +40,6 @@
#include <salinst.hxx>
#include <salgdi.hxx>
#include <svdata.hxx>
#include <salimestatus.hxx>
#include <salsys.hxx>
#include <units.hrc>
#include <print.h>
diff --git a/vcl/source/app/svmain.cxx b/vcl/source/app/svmain.cxx
index c6aa487..afeaaf6 100644
--- a/vcl/source/app/svmain.cxx
+++ b/vcl/source/app/svmain.cxx
@@ -73,7 +73,6 @@
#include <print.h>
#include <salsys.hxx>
#include <saltimer.hxx>
#include <salimestatus.hxx>
#include <displayconnectiondispatch.hxx>

#include <config_features.h>
@@ -424,9 +423,6 @@

    vcl::DeleteOnDeinitBase::ImplDeleteOnDeInit();

    // give ime status a chance to destroy its own windows
    pSVData->mpImeStatus.reset();

#if OSL_DEBUG_LEVEL > 0
    OStringBuffer aBuf( 256 );
    aBuf.append( "DeInitVCL: some top Windows are still alive\n" );
diff --git a/vcl/unx/generic/app/i18n_cb.cxx b/vcl/unx/generic/app/i18n_cb.cxx
index 3706df0..2e8f22d 100644
--- a/vcl/unx/generic/app/i18n_cb.cxx
+++ b/vcl/unx/generic/app/i18n_cb.cxx
@@ -31,7 +31,6 @@
#include <unx/salunx.h>
#include <unx/XIM.h>
#include <unx/i18n_cb.hxx>
#include <unx/i18n_status.hxx>
#include <unx/i18n_ic.hxx>
#include <unx/i18n_im.hxx>
#include <salframe.hxx>
@@ -498,7 +497,6 @@
            if( nLength )
                aText = OUString( pMBString, nLength, osl_getThreadTextEncoding() );
        }
        vcl::I18NStatus::get().setStatusText( aText );
    }
#if OSL_DEBUG_LEVEL > 1
    else
diff --git a/vcl/unx/generic/app/i18n_ic.cxx b/vcl/unx/generic/app/i18n_ic.cxx
index fbb58ea..0456606 100644
--- a/vcl/unx/generic/app/i18n_ic.cxx
+++ b/vcl/unx/generic/app/i18n_ic.cxx
@@ -29,7 +29,6 @@
#include <unx/XIM.h>
#include <unx/i18n_ic.hxx>
#include <unx/i18n_im.hxx>
#include <unx/i18n_status.hxx>

#include <unx/salframe.h>
#include <unx/saldisp.hxx>
@@ -361,16 +360,9 @@
// unmap it the hard way

void
SalI18N_InputContext::Unmap( SalFrame const * pFrame )
SalI18N_InputContext::Unmap()
{
    if ( maContext != nullptr )
    {
        I18NStatus& rStatus( I18NStatus::get() );
        if( rStatus.getParent() == pFrame )
            rStatus.show( false, I18NStatus::contextmap );

    }
    UnsetICFocus( pFrame );
    UnsetICFocus();
    maClientData.pFrame = nullptr;
}

@@ -379,11 +371,8 @@
{
    if( mbUseable )
    {
        I18NStatus& rStatus(I18NStatus::get() );
        rStatus.setParent( pFrame );
        if( pFrame )
        {
            rStatus.show( true, I18NStatus::contextmap );
            if ( maContext == nullptr )
            {
                SalI18N_InputMethod *pInputMethod;
@@ -548,8 +537,6 @@
    XSetICValues(maContext, XNPreeditAttributes, preedit_attr, nullptr);
    XFree(preedit_attr);

    I18NStatus::get().show( true, I18NStatus::contextmap );

    return 0;
}

@@ -560,7 +547,6 @@
void
SalI18N_InputContext::SetICFocus( SalFrame* pFocusFrame )
{
    I18NStatus::get().setParent( pFocusFrame );
    if ( mbUseable && (maContext != nullptr)  )
    {
        maClientData.pFrame = pFocusFrame;
@@ -586,11 +572,8 @@
}

void
SalI18N_InputContext::UnsetICFocus( SalFrame const * pFrame )
SalI18N_InputContext::UnsetICFocus()
{
    I18NStatus& rStatus( I18NStatus::get() );
    if( rStatus.getParent() == pFrame )
        rStatus.setParent( nullptr );

    if ( mbUseable && (maContext != nullptr) )
    {
diff --git a/vcl/unx/generic/app/i18n_im.cxx b/vcl/unx/generic/app/i18n_im.cxx
index 8e9e8a9..8be7bb7 100644
--- a/vcl/unx/generic/app/i18n_im.cxx
+++ b/vcl/unx/generic/app/i18n_im.cxx
@@ -35,7 +35,6 @@
#include <unx/salunx.h>
#include <unx/saldisp.hxx>
#include <unx/i18n_im.hxx>
#include <unx/i18n_status.hxx>

#include <osl/thread.h>
#include <osl/process.h>
@@ -249,7 +248,6 @@

SalI18N_InputMethod::~SalI18N_InputMethod()
{
    vcl::I18NStatus::free();
    if ( mpStyles != nullptr )
        XFree( mpStyles );
    if ( maMethod != nullptr )
diff --git a/vcl/unx/generic/app/i18n_status.cxx b/vcl/unx/generic/app/i18n_status.cxx
deleted file mode 100644
index 6a27ed8..0000000
--- a/vcl/unx/generic/app/i18n_status.cxx
+++ /dev/null
@@ -1,439 +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 .
 */

#if OSL_DEBUG_LEVEL > 1
#include <stdio.h>
#endif

#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <unx/XIM.h>

#include <unx/salunx.h>
#include <unx/i18n_status.hxx>
#include <unx/i18n_ic.hxx>
#include <unx/saldisp.hxx>
#include <unx/salframe.h>
#include <unx/salinst.h>

#include <vcl/wrkwin.hxx>
#include <vcl/fixed.hxx>
#include <vcl/menubtn.hxx>
#include <vcl/menu.hxx>
#include <vcl/svapp.hxx>
#include <vcl/sysdata.hxx>

#include <svdata.hxx>

using namespace vcl;

namespace vcl {

class StatusWindow : public WorkWindow
{
protected:
    explicit StatusWindow( WinBits nWinBits );
public:

    virtual void setPosition( SalFrame* );
    virtual void setText( const OUString & ) = 0;
    virtual void show( bool bShow, I18NStatus::ShowReason eReason ) = 0;
    virtual void toggle( bool bOn ) = 0;
};

}

StatusWindow::StatusWindow( WinBits nWinBits ) :
        WorkWindow( nullptr, nWinBits )
{
}

void StatusWindow::setPosition( SalFrame* )
{
}

namespace vcl {

class XIMStatusWindow : public StatusWindow
{
    VclPtr<FixedText>       m_aStatusText;
    SalFrame*               m_pLastParent;
    Size                    m_aWindowSize;
    bool                    m_bAnchoredAtRight;
        // true if the right edge (instead of the left edge) should stay at a
        // fixed position when re-sizing the window

    // for delayed showing
    bool                    m_bDelayedShow;
    ImplSVEvent *           m_nDelayedEvent;
    // for toggling
    bool                    m_bOn;

    Point updatePosition();
    void layout();
    bool checkLastParent() const;

    DECL_LINK( DelayedShowHdl, void*, void );
public:
    explicit XIMStatusWindow( bool bOn );
    virtual ~XIMStatusWindow() override;

    virtual void setPosition( SalFrame* ) override;
    virtual void setText( const OUString & ) override;
    virtual void show( bool bShow, I18NStatus::ShowReason eReason ) override;
    virtual void toggle( bool bOn ) override;
    virtual void dispose() override;

    // override WorkWindow::DataChanged
    virtual void DataChanged( const DataChangedEvent& rEvt ) override;
};

}

XIMStatusWindow::XIMStatusWindow( bool bOn ) :
        StatusWindow( WB_BORDER | WB_SYSTEMFLOATWIN | WB_TOOLTIPWIN ),
        m_aStatusText(VclPtr<FixedText>::Create(this, 0)),
        m_pLastParent( nullptr ),
        m_bAnchoredAtRight( false ),
        m_bDelayedShow( false ),
        m_nDelayedEvent( nullptr ),
        m_bOn( bOn )
{
    layout();
}

XIMStatusWindow::~XIMStatusWindow()
{
    disposeOnce();
}

void XIMStatusWindow::dispose()
{
    if( m_nDelayedEvent )
        Application::RemoveUserEvent( m_nDelayedEvent );
    m_aStatusText.disposeAndClear();
    StatusWindow::dispose();
}

void XIMStatusWindow::toggle( bool bOn )
{
    m_bOn = bOn;
    show( bOn, I18NStatus::contextmap );
}

void XIMStatusWindow::layout()
{
    m_aWindowSize.setWidth( m_aStatusText->GetTextWidth( m_aStatusText->GetText() )+8 );
    Font aFont( m_aStatusText->GetFont() );
    m_aWindowSize.setHeight( aFont.GetFontHeight()+10 );
    m_aWindowSize = LogicToPixel( m_aWindowSize );

    Size aControlSize( m_aWindowSize );
    aControlSize.AdjustWidth( -4 );
    aControlSize.AdjustHeight( -4 );

    m_aStatusText->SetPosSizePixel( Point( 1, 1 ), aControlSize );
    m_aStatusText->SetFont( aFont );
    m_aStatusText->Show();

    if (m_bAnchoredAtRight && IsVisible())
    {
        SalFrame* pFrame = static_cast<SalFrame*>(GetSystemData()->pSalFrame);
        long nDelta = pFrame->maGeometry.nWidth - m_aWindowSize.Width();
        pFrame->SetPosSize( pFrame->maGeometry.nX + nDelta,
                            pFrame->maGeometry.nY,
                            m_aWindowSize.Width(),
                            m_aWindowSize.Height(),
                            SAL_FRAME_POSSIZE_X | SAL_FRAME_POSSIZE_Y | SAL_FRAME_POSSIZE_WIDTH | SAL_FRAME_POSSIZE_HEIGHT );
    }
    else
        SetOutputSizePixel( m_aWindowSize );
}

bool XIMStatusWindow::checkLastParent() const
{
    if( m_pLastParent )
    {
        auto rFrameList = vcl_sal::getSalDisplay(GetGenericUnixSalData())->getFrames();
        auto it = rFrameList.find( m_pLastParent );
        return it != rFrameList.end();
    }
    return false;
}

void XIMStatusWindow::DataChanged( const DataChangedEvent& )
{
    m_aStatusText->SetSettings( GetSettings() );
    layout();
}

Point XIMStatusWindow::updatePosition()
{
    Point aRet;
    if( checkLastParent() )
    {
        const SystemEnvData* pParentEnvData = m_pLastParent->GetSystemData();

        SalExtTextInputPosEvent aPosEvent;
        m_pLastParent->CallCallback( SalEvent::ExtTextInputPos, static_cast<void*>(&aPosEvent) );
        int x, y;
        ::Window aChild;
        XTranslateCoordinates( static_cast<Display*>(pParentEnvData->pDisplay),
                               static_cast<::Window>(pParentEnvData->aShellWindow),
                               vcl_sal::getSalDisplay(GetGenericUnixSalData())->GetRootWindow( vcl_sal::getSalDisplay(GetGenericUnixSalData())->GetDefaultXScreen() ),
                               0, 0,
                               &x, &y,
                               &aChild );

        // TODO:  Currently, place the status window to the (physical) left of
        // the cursor iff in vertical mode (assuming that the columns in
        // vertical mode are always written from right to left, this causes the
        // status window to keep out of the text already written).  This
        // heuristic would break if there is ever a vertical mode in which the
        // columns are written from left to right.  Also, more elaborate
        // positioning for (both horizontal and vertical) left-to-right and
        // right-to-left text would be possible.
        bool bLeft = aPosEvent.mbVertical;
            // true if status window is to the left of the cursor

        int const nGap = 4; // between cursor and status window
        if (aPosEvent.mbVertical)
        {
            aRet.setX( x + aPosEvent.mnX + (bLeft
                                            ? -m_aWindowSize.Width() - nGap
                                            : aPosEvent.mnHeight + nGap) );
            aRet.setY( y + aPosEvent.mnY );
        }
        else
        {
            aRet.setX( x + aPosEvent.mnX + (bLeft ? -m_aWindowSize.Width() : 0) );
            aRet.setY( y + aPosEvent.mnY+aPosEvent.mnHeight + nGap );
        }

        m_bAnchoredAtRight = bLeft;
    }
    return aRet;
}

void XIMStatusWindow::setPosition( SalFrame* pParent )
{
    if( pParent )
    {
        if( pParent != m_pLastParent )
        {
            setText( OUString() );
            m_pLastParent = pParent;
            Show( false, ShowFlags::NoActivate );
        }
        if( IsVisible() )
        {
            const SystemEnvData* pEnvData = GetSystemData();
            SalFrame* pStatusFrame = static_cast<SalFrame*>(pEnvData->pSalFrame);
            Point aPoint = updatePosition();
            pStatusFrame->SetPosSize( aPoint.X(), aPoint.Y(), m_aWindowSize.Width(), m_aWindowSize.Height(), SAL_FRAME_POSSIZE_X | SAL_FRAME_POSSIZE_Y | SAL_FRAME_POSSIZE_WIDTH | SAL_FRAME_POSSIZE_HEIGHT );
        }
    }
}

IMPL_LINK_NOARG(XIMStatusWindow, DelayedShowHdl, void*, void)
{
    m_nDelayedEvent = nullptr;
    const SystemEnvData* pData = GetSystemData();
    SalFrame* pStatusFrame = static_cast<SalFrame*>(pData->pSalFrame);
    if( m_bDelayedShow )
    {
        Size aControlSize( m_aWindowSize.Width()-4, m_aWindowSize.Height()-4 );
        m_aStatusText->SetPosSizePixel( Point( 1, 1 ), aControlSize );
        Point aPoint = updatePosition();
        pStatusFrame->SetPosSize( aPoint.X(), aPoint.Y(), m_aWindowSize.Width(), m_aWindowSize.Height(), SAL_FRAME_POSSIZE_X | SAL_FRAME_POSSIZE_Y | SAL_FRAME_POSSIZE_WIDTH | SAL_FRAME_POSSIZE_HEIGHT );
    }
    Show( m_bDelayedShow && m_bOn, ShowFlags::NoActivate );
    if( m_bDelayedShow )
    {
        XRaiseWindow( static_cast<Display*>(pData->pDisplay),
                      static_cast<::Window>(pData->aShellWindow) );
    }
}

void XIMStatusWindow::show( bool bShow, I18NStatus::ShowReason )
{
    if( bShow && m_aStatusText->GetText().isEmpty() )
        bShow = false;

    m_bDelayedShow = bShow;
    if( ! m_nDelayedEvent )
        m_nDelayedEvent = Application::PostUserEvent( LINK( this, XIMStatusWindow, DelayedShowHdl ), nullptr, true );
}

void XIMStatusWindow::setText( const OUString& rText )
{
    m_aStatusText->SetText( rText );
    m_aWindowSize.setWidth( m_aStatusText->GetTextWidth( rText )+8 );
}

/*
 *  I18NStatus
 */

static I18NStatus* g_pI18NStatusInstance = nullptr;

I18NStatus& I18NStatus::get()
{
    if (!g_pI18NStatusInstance)
        g_pI18NStatusInstance = new I18NStatus();
    return *g_pI18NStatusInstance;
}

bool I18NStatus::exists()
{
    return g_pI18NStatusInstance != nullptr;
}

void I18NStatus::free()
{
    if (g_pI18NStatusInstance)
    {
        delete g_pI18NStatusInstance;
        g_pI18NStatusInstance = nullptr;
    }
}

I18NStatus::I18NStatus() :
        m_pParent( nullptr ),
        m_pStatusWindow( nullptr )
{
}

I18NStatus::~I18NStatus()
{
    m_pStatusWindow.disposeAndClear();
    if( g_pI18NStatusInstance == this )
        g_pI18NStatusInstance = nullptr;
}

void I18NStatus::setParent( SalFrame* pParent )
{
    m_pParent = pParent;
    if( ! m_pStatusWindow )
    {
        m_pStatusWindow = VclPtr<XIMStatusWindow>::Create( getStatusWindowMode() );
        setStatusText( m_aCurrentIM );
    }
    m_pStatusWindow->setPosition( m_pParent );
}

void I18NStatus::show( bool bShow, ShowReason eReason )
{
    if( m_pStatusWindow )
    {
        m_pStatusWindow->setPosition( m_pParent );
        m_pStatusWindow->show( bShow, eReason );
    }
}

void I18NStatus::setStatusText( const OUString& rText )
{
    if( m_pStatusWindow )
    {
        /*
         *  #93614# convert fullwidth ASCII forms to ascii
         */
        int nChars = rText.getLength();
        rtl_uString *pStr = rtl_uString_alloc(nChars);
        sal_Unicode *pBuffer = pStr->buffer;
        for( int i = 0; i < nChars; i++ )
        {
            if( rText[i] >=0xff00 && rText[i] <= 0xff5f )
                pBuffer[i] = (rText[i] & 0xff) + 0x20;
            else
                pBuffer[i] = rText[i];
        }
        OUString aText(pStr, SAL_NO_ACQUIRE);
        m_pStatusWindow->setText( aText );
        m_pStatusWindow->setPosition( m_pParent );

        bool bVisible = true;
        if( m_pParent )
        {
            long w, h;
            m_pParent->GetClientSize( w, h );
            if( w == 0 || h == 0 )
            {
                bVisible = false;
            }
        }

        m_pStatusWindow->show( bVisible, contextmap );
    }
}

SalFrame* I18NStatus::getStatusFrame() const
{
    SalFrame* pRet = nullptr;
    if( m_pStatusWindow )
    {
        const SystemEnvData* pData = m_pStatusWindow->GetSystemData();
        pRet = static_cast<SalFrame*>(pData->pSalFrame);
    }
    return pRet;
}

void I18NStatus::toggleStatusWindow()
{
    if (m_pStatusWindow != nullptr)
        m_pStatusWindow->toggle(getStatusWindowMode());
}

bool I18NStatus::getStatusWindowMode()
{
    switch (ImplGetSVData()->maAppData.meShowImeStatusWindow)
    {
    default: // ImplSVAppData::ImeStatusWindowMode_UNKNOWN
        return Application::GetShowImeStatusWindowDefault();
    case ImplSVAppData::ImeStatusWindowMode_HIDE:
        return false;
    case ImplSVAppData::ImeStatusWindowMode_SHOW:
        return true;
    }
}

/*
 * X11ImeStatus
 */
X11ImeStatus::~X11ImeStatus()
{
    vcl::I18NStatus::free();
}

bool X11ImeStatus::canToggle()
{
    return true;
}

void X11ImeStatus::toggle()
{
    vcl::I18NStatus::get().toggleStatusWindow();
}

std::unique_ptr<SalI18NImeStatus> X11SalInstance::CreateI18NImeStatus()
{
    return std::unique_ptr<SalI18NImeStatus>(new X11ImeStatus());
}

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/generic/window/salframe.cxx b/vcl/unx/generic/window/salframe.cxx
index b18fc5c..62c3fa9 100644
--- a/vcl/unx/generic/window/salframe.cxx
+++ b/vcl/unx/generic/window/salframe.cxx
@@ -54,7 +54,6 @@
#include <unx/salbmp.h>
#include <unx/i18n_ic.hxx>
#include <unx/i18n_keysym.hxx>
#include <unx/i18n_status.hxx>
#include <unx/x11/xlimits.hxx>
#include <opengl/zone.hxx>

@@ -915,8 +914,8 @@

    if( mpInputContext )
    {
        mpInputContext->UnsetICFocus( this );
        mpInputContext->Unmap( this );
        mpInputContext->UnsetICFocus();
        mpInputContext->Unmap();
        mpInputContext.reset();
    }

@@ -948,19 +947,6 @@
    }

    XDestroyWindow( GetXDisplay(), mhWindow );

    /*
     *  check if there is only the status frame left
     *  if so, free it
     */
    auto &rFrames = GetDisplay()->getFrames();
    if( ! rFrames.empty() && vcl::I18NStatus::exists() )
    {
        SalFrame* pStatusFrame = vcl::I18NStatus::get().getStatusFrame();
        auto sit = rFrames.begin();
        if( pStatusFrame && *sit == pStatusFrame && ++sit == rFrames.end() )
            vcl::I18NStatus::free();
    }
}

void X11SalFrame::SetExtendedFrameStyle( SalExtStyle nStyle )
@@ -1373,7 +1359,7 @@
    else
    {
        if( getInputContext() )
            getInputContext()->Unmap( this );
            getInputContext()->Unmap();

        if( ! IsChildWindow() )
        {
@@ -2228,8 +2214,6 @@
                                    mhWindow,
                                    GetXDisplay() );

    vcl::I18NStatus::get().show( !bStart, vcl::I18NStatus::presentation );

    if( ! bStart && hPresentationWindow != None )
        doReparentPresentationDialogues( GetDisplay() );
    hPresentationWindow = (bStart && IsOverrideRedirect() ) ? GetWindow() : None;
@@ -2337,7 +2321,7 @@
    if (!(pContext->mnOptions & InputContextFlags::Text))
    {
        if( mpInputContext )
            mpInputContext->Unmap( this );
            mpInputContext->Unmap();
        return;
    }

@@ -2346,8 +2330,6 @@

    if (mpInputContext == nullptr)
    {
        vcl::I18NStatus& rStatus( vcl::I18NStatus::get() );
        rStatus.setParent( this );
        mpInputContext.reset( new SalI18N_InputContext( this ) );
        if (mpInputContext->UseContext())
        {
@@ -2457,8 +2439,8 @@
    updateGraphics(true);
    if( mpInputContext )
    {
        mpInputContext->UnsetICFocus( this );
        mpInputContext->Unmap( this );
        mpInputContext->UnsetICFocus();
        mpInputContext->Unmap();
    }
    if( GetWindow() == hPresentationWindow )
    {
@@ -3324,15 +3306,6 @@
    {
        if( FocusIn == pEvent->type )
            mpInputContext->SetICFocus( this );
        else
        {
            /*
             *  do not unset the IC focus here because would kill
             *  a lookup choice windows that might have the focus now
             *      mpInputContext->UnsetICFocus( this );
             */
            vcl::I18NStatus::get().show( false, vcl::I18NStatus::focus );
        }
    }

    if ( pEvent->mode == NotifyNormal || pEvent->mode == NotifyWhileGrabbed ||
@@ -3945,17 +3918,6 @@
                    CallCallback( SalEvent::Resize, nullptr );

                    bool bSetFocus = m_bSetFocusOnMap;
                    /*  another workaround for sawfish: if a transient window for the same parent is shown
                     *  sawfish does not set the focus to it. Applies only for click to focus mode.
                     */
                    if( ! (nStyle_ & SalFrameStyleFlags::FLOAT ) && mbInShow && GetDisplay()->getWMAdaptor()->getWindowManagerName() == "Sawfish" )
                    {
                        // don't set the focus into the IME status window
                        // since this will lead to a parent loss of focus, close status,
                        // reget focus, open status, .... flicker loop
                        if ( vcl::I18NStatus::get().getStatusFrame() != this )
                            bSetFocus = true;
                    }

                    /*
                     *  sometimes a message box/dialogue is brought up when a frame is not mapped
@@ -3999,7 +3961,7 @@
                    bViewable_ = false;
                    nRet = true;
                    if ( mpInputContext != nullptr )
                        mpInputContext->Unmap( this );
                        mpInputContext->Unmap();
                    CallCallback( SalEvent::Resize, nullptr );
                }
                break;
diff --git a/vcl/unx/gtk/gtkinst.cxx b/vcl/unx/gtk/gtkinst.cxx
index 9719265..40cd9769 100644
--- a/vcl/unx/gtk/gtkinst.cxx
+++ b/vcl/unx/gtk/gtkinst.cxx
@@ -31,7 +31,6 @@
#include <unx/gtk/gtksalmenu.hxx>
#include <headless/svpvd.hxx>
#include <headless/svpbmp.hxx>
#include <salimestatus.hxx>
#include <vcl/inputtypes.hxx>
#include <unx/genpspgraphics.h>
#include <rtl/strbuf.hxx>
@@ -233,16 +232,6 @@
    return new GtkSalObject( static_cast<GtkSalFrame*>(pParent), bShow );
}

#if !GTK_CHECK_VERSION(3,0,0)
std::unique_ptr<SalI18NImeStatus> GtkInstance::CreateI18NImeStatus()
{
    //we want the default SalInstance::CreateI18NImeStatus returns the no-op
    //stub here, not the X11Instance::CreateI18NImeStatus which the gtk2
    //one would use otherwise
    return SalInstance::CreateI18NImeStatus();
}
#endif

extern "C"
{
    typedef void*(* getDefaultFnc)();
diff --git a/vcl/win/app/salinst.cxx b/vcl/win/app/salinst.cxx
index 9fa7445..d203477 100644
--- a/vcl/win/app/salinst.cxx
+++ b/vcl/win/app/salinst.cxx
@@ -47,7 +47,6 @@
#include <win/salbmp.h>
#include <win/winlayout.hxx>

#include <salimestatus.hxx>
#include <salsys.hxx>

#include <desktop/crashreport.hxx>