[Libreoffice-commits] core.git: Branch 'libreoffice-6-3-1' - 2 commits - framework/inc framework/Library_fwk.mk framework/source include/svx sd/source svx/source sw/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Fri Aug 23 16:05:01 UTC 2019


 framework/Library_fwk.mk                           |    1 
 framework/inc/helper/statusindicatorfactory.hxx    |    7 --
 framework/inc/helper/wakeupthread.hxx              |   57 +++++++++++++++++++
 framework/source/helper/statusindicatorfactory.cxx |   25 ++++----
 framework/source/helper/wakeupthread.cxx           |   60 +++++++++++++++++++++
 include/svx/pszctrl.hxx                            |    2 
 include/svx/zoomctrl.hxx                           |    2 
 sd/source/ui/app/tmplctrl.cxx                      |    1 
 svx/source/stbctrls/insctrl.cxx                    |    1 
 svx/source/stbctrls/pszctrl.cxx                    |   31 ++++++++--
 svx/source/stbctrls/zoomctrl.cxx                   |   12 ++--
 sw/source/uibase/utlui/bookctrl.cxx                |    1 
 sw/source/uibase/utlui/tmplctrl.cxx                |    1 
 sw/source/uibase/utlui/zoomctrl.cxx                |    6 --
 14 files changed, 170 insertions(+), 37 deletions(-)

New commits:
commit cc730643359a000d61e8817fe0168e239678283d
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Fri Aug 16 15:33:15 2019 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Aug 23 18:04:21 2019 +0200

    tdf#126819 Can't retrieve the mouse position written in the statusbar
    
    regression from
        commit 77e260f915e0c77ddb1e915e9fd27ab0bdccc763
        Date:   Mon Jul 8 11:22:12 2019 +0200
        tdf#121793 speedup VCLXAccessibleStatusBarItem::GetItemText
    
    Make the custom StatusBarControls set better text on their parent
    StatusBar. Also remove some unnecessary work being done in the Paint
    methods, to reduce confusion.
    
    Change-Id: I3b0a0af3b01d3b01f85ab335a3eb5993c07a50f4
    Reviewed-on: https://gerrit.libreoffice.org/77586
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
    (cherry picked from commit c53f3f8f58f55d0978fb968446975856d72a52f8)
    Reviewed-on: https://gerrit.libreoffice.org/77697
    (cherry picked from commit 3638ac34cab9b8db8454267f53f43f216a373eda)
    Reviewed-on: https://gerrit.libreoffice.org/77705
    Tested-by: Xisco FaulĂ­ <xiscofauli at libreoffice.org>

diff --git a/include/svx/pszctrl.hxx b/include/svx/pszctrl.hxx
index d22e0ba05d18..faf8923d94cc 100644
--- a/include/svx/pszctrl.hxx
+++ b/include/svx/pszctrl.hxx
@@ -39,6 +39,8 @@ public:
     virtual void    StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState ) override;
     virtual void    Paint( const UserDrawEvent& rEvt ) override;
     virtual void    Command( const CommandEvent& rCEvt ) override;
+private:
+    void ImplUpdateItemText();
 };
 
 #endif
diff --git a/include/svx/zoomctrl.hxx b/include/svx/zoomctrl.hxx
index afd3130e2c20..e0daa4b971ca 100644
--- a/include/svx/zoomctrl.hxx
+++ b/include/svx/zoomctrl.hxx
@@ -40,6 +40,8 @@ public:
 
     SvxZoomStatusBarControl( sal_uInt16 nSlotId, sal_uInt16 nId, StatusBar& rStb );
 
+private:
+    void ImplUpdateItemText();
 };
 
 class SVX_DLLPUBLIC SvxZoomPageStatusBarControl : public SfxStatusBarControl
diff --git a/sd/source/ui/app/tmplctrl.cxx b/sd/source/ui/app/tmplctrl.cxx
index 2c27db05bafb..c78f1a3ef126 100644
--- a/sd/source/ui/app/tmplctrl.cxx
+++ b/sd/source/ui/app/tmplctrl.cxx
@@ -89,7 +89,6 @@ void SdTemplateControl::StateChanged(
 
 void SdTemplateControl::Paint( const UserDrawEvent&  )
 {
-    GetStatusBar().SetItemText( GetId(), msTemplate );
 }
 
 void SdTemplateControl::Command( const CommandEvent& rCEvt )
diff --git a/svx/source/stbctrls/insctrl.cxx b/svx/source/stbctrls/insctrl.cxx
index 952f82332f8e..eaad418e4909 100644
--- a/svx/source/stbctrls/insctrl.cxx
+++ b/svx/source/stbctrls/insctrl.cxx
@@ -65,7 +65,6 @@ void SvxInsertStatusBarControl::StateChanged( sal_uInt16 , SfxItemState eState,
 
 void SvxInsertStatusBarControl::Paint( const UserDrawEvent& )
 {
-    DrawItemText_Impl();
 }
 
 void SvxInsertStatusBarControl::DrawItemText_Impl()
diff --git a/svx/source/stbctrls/pszctrl.cxx b/svx/source/stbctrls/pszctrl.cxx
index 474ca2c81f0d..06877c8f06e4 100644
--- a/svx/source/stbctrls/pszctrl.cxx
+++ b/svx/source/stbctrls/pszctrl.cxx
@@ -231,6 +231,7 @@ SvxPosSizeStatusBarControl::SvxPosSizeStatusBarControl( sal_uInt16 _nSlotId,
     addStatusListener( STR_POSITION);         // SID_ATTR_POSITION
     addStatusListener( STR_TABLECELL);   // SID_TABLE_CELL
     addStatusListener( STR_FUNC);    // SID_PSZ_FUNCTION
+    ImplUpdateItemText();
 }
 
 /*  [Description]
@@ -334,12 +335,7 @@ void SvxPosSizeStatusBarControl::StateChanged( sal_uInt16 nSID, SfxItemState eSt
 
     GetStatusBar().SetItemData( GetId(), nullptr );
 
-    //  set only strings as text at the statusBar, so that the Help-Tips
-    //  can work with the text, when it is too long for the statusBar
-    OUString aText;
-    if ( pImpl->bTable )
-        aText = pImpl->aStr;
-    GetStatusBar().SetItemText( GetId(), aText );
+    ImplUpdateItemText();
 }
 
 
@@ -461,4 +457,27 @@ void SvxPosSizeStatusBarControl::Paint( const UserDrawEvent& rUsrEvt )
     pDev->SetFillColor( aOldFillColor );
 }
 
+void SvxPosSizeStatusBarControl::ImplUpdateItemText()
+{
+    //  set only strings as text at the statusBar, so that the Help-Tips
+    //  can work with the text, when it is too long for the statusBar
+    OUString aText;
+    if ( pImpl->bPos || pImpl->bSize )
+    {
+        aText = GetMetricStr_Impl( pImpl->aPos.X());
+        aText += " / ";
+        aText += GetMetricStr_Impl( pImpl->aPos.Y());
+        if ( pImpl->bSize )
+        {
+            aText += " ";
+            aText += GetMetricStr_Impl( pImpl->aSize.Width() );
+            aText += " x ";
+            aText += GetMetricStr_Impl( pImpl->aSize.Height() );
+        }
+    }
+    else if ( pImpl->bTable )
+       aText = pImpl->aStr;
+
+    GetStatusBar().SetItemText( GetId(), aText );
+}
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/stbctrls/zoomctrl.cxx b/svx/source/stbctrls/zoomctrl.cxx
index 34e0b26c5495..eac10c81fef6 100644
--- a/svx/source/stbctrls/zoomctrl.cxx
+++ b/svx/source/stbctrls/zoomctrl.cxx
@@ -111,6 +111,7 @@ SvxZoomStatusBarControl::SvxZoomStatusBarControl( sal_uInt16 _nSlotId,
     nValueSet( SvxZoomEnableFlags::ALL )
 {
     GetStatusBar().SetQuickHelpText(GetId(), SvxResId(RID_SVXSTR_ZOOMTOOL_HINT));
+    ImplUpdateItemText();
 }
 
 void SvxZoomStatusBarControl::StateChanged( sal_uInt16, SfxItemState eState,
@@ -124,9 +125,7 @@ void SvxZoomStatusBarControl::StateChanged( sal_uInt16, SfxItemState eState,
     else if ( auto pItem = dynamic_cast< const SfxUInt16Item* >(pState) )
     {
         nZoom = pItem->GetValue();
-
-        OUString aStr(unicode::formatPercent(nZoom, Application::GetSettings().GetUILanguageTag()));
-        GetStatusBar().SetItemText( GetId(), aStr );
+        ImplUpdateItemText();
 
         if ( auto pZoomItem = dynamic_cast<const SvxZoomItem*>(pState) )
         {
@@ -140,12 +139,16 @@ void SvxZoomStatusBarControl::StateChanged( sal_uInt16, SfxItemState eState,
     }
 }
 
-void SvxZoomStatusBarControl::Paint( const UserDrawEvent& )
+void SvxZoomStatusBarControl::ImplUpdateItemText()
 {
     OUString aStr(unicode::formatPercent(nZoom, Application::GetSettings().GetUILanguageTag()));
     GetStatusBar().SetItemText( GetId(), aStr );
 }
 
+void SvxZoomStatusBarControl::Paint( const UserDrawEvent& )
+{
+}
+
 void SvxZoomStatusBarControl::Command( const CommandEvent& rCEvt )
 {
     if ( CommandEventId::ContextMenu == rCEvt.GetCommand() && bool(nValueSet) )
@@ -156,6 +159,7 @@ void SvxZoomStatusBarControl::Command( const CommandEvent& rCEvt )
         if (aPop.Execute(&rStatusbar, rCEvt.GetMousePosPixel()) && (nZoom != aPop.GetZoom() || !nZoom))
         {
             nZoom = aPop.GetZoom();
+            ImplUpdateItemText();
             SvxZoomItem aZoom(SvxZoomType::PERCENT, nZoom, GetId());
 
             OString sIdent = aPop.GetCurItemIdent();
diff --git a/sw/source/uibase/utlui/bookctrl.cxx b/sw/source/uibase/utlui/bookctrl.cxx
index c432e3c6b003..348ffb5f0297 100644
--- a/sw/source/uibase/utlui/bookctrl.cxx
+++ b/sw/source/uibase/utlui/bookctrl.cxx
@@ -96,7 +96,6 @@ void SwBookmarkControl::StateChanged(
 
 void SwBookmarkControl::Paint( const UserDrawEvent&  )
 {
-    GetStatusBar().SetItemText( GetId(), sPageNumber );
 }
 
 void SwBookmarkControl::Command( const CommandEvent& rCEvt )
diff --git a/sw/source/uibase/utlui/tmplctrl.cxx b/sw/source/uibase/utlui/tmplctrl.cxx
index 11b304d660be..2ab9883d231f 100644
--- a/sw/source/uibase/utlui/tmplctrl.cxx
+++ b/sw/source/uibase/utlui/tmplctrl.cxx
@@ -88,7 +88,6 @@ void SwTemplateControl::StateChanged(
 
 void SwTemplateControl::Paint( const UserDrawEvent&  )
 {
-    GetStatusBar().SetItemText( GetId(), sTemplate );
 }
 
 void SwTemplateControl::Command( const CommandEvent& rCEvt )
diff --git a/sw/source/uibase/utlui/zoomctrl.cxx b/sw/source/uibase/utlui/zoomctrl.cxx
index 967a98ffbf2e..c1e9e95c5140 100644
--- a/sw/source/uibase/utlui/zoomctrl.cxx
+++ b/sw/source/uibase/utlui/zoomctrl.cxx
@@ -56,12 +56,8 @@ void SwZoomControl::StateChanged( sal_uInt16 nSID, SfxItemState eState,
     }
 }
 
-void SwZoomControl::Paint( const UserDrawEvent& rUsrEvt )
+void SwZoomControl::Paint( const UserDrawEvent& )
 {
-    if (sPreviewZoom.isEmpty())
-        SvxZoomStatusBarControl::Paint(rUsrEvt);
-    else
-        GetStatusBar().SetItemText(GetId(), sPreviewZoom);
 }
 
 void SwZoomControl::Command( const CommandEvent& rCEvt )
commit ee5d2fe74a189d8986a9ea1441c0841347a2d3bc
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Tue Aug 20 10:14:19 2019 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Aug 23 18:04:11 2019 +0200

    tdf#125869 LibreOffice UI freezes (shows not responding) while exporting a pdf
    
    Revert "use vcl::Timer in StatusIndicatorFactory"
    This reverts commit 848058625c7fad21e2469c95c2a2078678925a5a,
    which seems to have been a bad idea
    
    Change-Id: I68be1757717352f164ce27c300a4a0487680891c
    Reviewed-on: https://gerrit.libreoffice.org/77791
    Tested-by: Jenkins
    Reviewed-by: Xisco FaulĂ­ <xiscofauli at libreoffice.org>
    (cherry picked from commit ff3cfee4ebfcb412f54f17ffccc95512fdc15c8e)
    Reviewed-on: https://gerrit.libreoffice.org/77805
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
    Tested-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/framework/Library_fwk.mk b/framework/Library_fwk.mk
index 3957a5ace0ff..9057aaa6048a 100644
--- a/framework/Library_fwk.mk
+++ b/framework/Library_fwk.mk
@@ -88,6 +88,7 @@ $(eval $(call gb_Library_add_exception_objects,fwk,\
     framework/source/helper/uiconfigelementwrapperbase \
     framework/source/helper/uielementwrapperbase \
     framework/source/helper/vclstatusindicator \
+    framework/source/helper/wakeupthread \
     framework/source/interaction/quietinteraction \
     framework/source/jobs/job \
     framework/source/jobs/jobdata \
diff --git a/framework/inc/helper/statusindicatorfactory.hxx b/framework/inc/helper/statusindicatorfactory.hxx
index 1ad060516313..d343fe35395e 100644
--- a/framework/inc/helper/statusindicatorfactory.hxx
+++ b/framework/inc/helper/statusindicatorfactory.hxx
@@ -25,6 +25,7 @@
 #include <vector>
 
 // include files of own module
+#include <helper/wakeupthread.hxx>
 #include <general.h>
 
 // include uno interfaces
@@ -44,9 +45,7 @@
 #include <com/sun/star/uno/XComponentContext.hpp>
 
 #include <cppuhelper/supportsservice.hxx>
-#include <cppuhelper/weakref.hxx>
 #include <vcl/status.hxx>
-#include <vcl/timer.hxx>
 #include <cppuhelper/implbase.hxx>
 #include <osl/thread.hxx>
 
@@ -166,7 +165,7 @@ class StatusIndicatorFactory : public  ::cppu::WeakImplHelper<
 
         /** Notify us if a fix time is over. We use it to implement an
             intelligent "Reschedule" ... */
-        boost::optional<Timer> m_xWakeUpTimer;
+        rtl::Reference<WakeUpThread> m_pWakeUp;
 
         /** Our WakeUpThread calls us in our interface method "XUpdatable::update().
             There we set this member m_bAllowReschedule to sal_True. Next time if our impl_reschedule()
@@ -183,8 +182,6 @@ class StatusIndicatorFactory : public  ::cppu::WeakImplHelper<
         /** prevent recursive calling of Application::Reschedule(). */
         static sal_Int32 m_nInReschedule;
 
-        DECL_LINK( WakeupTimerHdl, Timer*, void );
-
     // interface
 
     public:
diff --git a/framework/inc/helper/wakeupthread.hxx b/framework/inc/helper/wakeupthread.hxx
new file mode 100644
index 000000000000..50e234f23713
--- /dev/null
+++ b/framework/inc/helper/wakeupthread.hxx
@@ -0,0 +1,57 @@
+/* -*- 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_FRAMEWORK_INC_HELPER_WAKEUPTHREAD_HXX
+#define INCLUDED_FRAMEWORK_INC_HELPER_WAKEUPTHREAD_HXX
+
+#include <sal/config.h>
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <cppuhelper/weakref.hxx>
+#include <osl/conditn.hxx>
+#include <osl/mutex.hxx>
+#include <sal/types.h>
+#include <salhelper/thread.hxx>
+
+namespace com { namespace sun { namespace star { namespace util {
+    class XUpdatable;
+} } } }
+
+namespace framework{
+
+class WakeUpThread: public salhelper::Thread {
+    css::uno::WeakReference<css::util::XUpdatable> updatable_;
+    osl::Condition condition_;
+
+    osl::Mutex mutex_;
+    bool terminate_;
+
+    void execute() override;
+
+public:
+    WakeUpThread(css::uno::Reference<css::util::XUpdatable> const & updatable);
+
+    void stop();
+};
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/source/helper/statusindicatorfactory.cxx b/framework/source/helper/statusindicatorfactory.cxx
index ee33a646cadd..5e4ba3adf4e3 100644
--- a/framework/source/helper/statusindicatorfactory.cxx
+++ b/framework/source/helper/statusindicatorfactory.cxx
@@ -537,27 +537,26 @@ void StatusIndicatorFactory::impl_startWakeUpThread()
     if (m_bDisableReschedule)
         return;
 
-    if (!m_xWakeUpTimer)
+    if (!m_pWakeUp.is())
     {
-        m_xWakeUpTimer = Timer();
-        m_xWakeUpTimer->SetInvokeHandler( LINK(this, StatusIndicatorFactory, WakeupTimerHdl) );
-        m_xWakeUpTimer->SetTimeout(25); // 25 msec
-        m_xWakeUpTimer->Start();
+        m_pWakeUp = new WakeUpThread(this);
+        m_pWakeUp->launch();
     }
 }
 
 void StatusIndicatorFactory::impl_stopWakeUpThread()
 {
-    if (m_xWakeUpTimer)
-        m_xWakeUpTimer->Stop();
-}
-
-IMPL_LINK_NOARG(StatusIndicatorFactory, WakeupTimerHdl, Timer *, void)
-{
-    update();
+    rtl::Reference<WakeUpThread> wakeUp;
+    {
+        osl::MutexGuard g(m_mutex);
+        std::swap(wakeUp, m_pWakeUp);
+    }
+    if (wakeUp.is())
+    {
+        wakeUp->stop();
+    }
 }
 
-
 } // namespace framework
 
 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
diff --git a/framework/source/helper/wakeupthread.cxx b/framework/source/helper/wakeupthread.cxx
new file mode 100644
index 000000000000..503f6707a010
--- /dev/null
+++ b/framework/source/helper/wakeupthread.cxx
@@ -0,0 +1,60 @@
+/* -*- 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 <sal/config.h>
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/util/XUpdatable.hpp>
+#include <osl/mutex.hxx>
+#include <osl/time.h>
+
+#include <helper/wakeupthread.hxx>
+
+void framework::WakeUpThread::execute() {
+    for (;;) {
+        TimeValue t{0, 25000000}; // 25 msec
+        condition_.wait(&t);
+        {
+            osl::MutexGuard g(mutex_);
+            if (terminate_) {
+                break;
+            }
+        }
+        css::uno::Reference<css::util::XUpdatable> up(updatable_);
+        if (up.is()) {
+            up->update();
+        }
+    }
+}
+
+framework::WakeUpThread::WakeUpThread(
+    css::uno::Reference<css::util::XUpdatable> const & updatable):
+    Thread("WakeUpThread"), updatable_(updatable), terminate_(false)
+{}
+
+void framework::WakeUpThread::stop() {
+    {
+        osl::MutexGuard g(mutex_);
+        terminate_ = true;
+    }
+    condition_.set();
+    join();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list