[Libreoffice-commits] core.git: include/vcl svx/source svx/uiconfig vcl/source vcl/unx

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Feb 20 21:10:12 UTC 2019


 include/vcl/weld.hxx                         |    2 
 svx/source/dialog/docrecovery.cxx            |   89 +++++++++++++++++++--------
 svx/source/inc/docrecovery.hxx               |   40 ++++++++++--
 svx/uiconfig/ui/docrecoveryprogressdialog.ui |   12 ++-
 vcl/source/app/salvtables.cxx                |   10 +++
 vcl/unx/gtk3/gtk3gtkinst.cxx                 |   12 +++
 6 files changed, 131 insertions(+), 34 deletions(-)

New commits:
commit e3294b1b8af992419ed20a14df3006595454cd4c
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Wed Feb 20 16:46:59 2019 +0000
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Wed Feb 20 22:09:40 2019 +0100

    weld SaveProgressDialog
    
    Change-Id: Iad1786962dedb6cae0cf8720022498bfd793feb1
    Reviewed-on: https://gerrit.libreoffice.org/68105
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx
index d3e0b09ba6b3..aa0394d0ea87 100644
--- a/include/vcl/weld.hxx
+++ b/include/vcl/weld.hxx
@@ -811,6 +811,8 @@ class VCL_DLLPUBLIC ProgressBar : virtual public Widget
 public:
     //0-100
     virtual void set_percentage(int value) = 0;
+    virtual OUString get_text() const = 0;
+    virtual void set_text(const OUString& rText) = 0;
 };
 
 class VCL_DLLPUBLIC Entry : virtual public Widget
diff --git a/svx/source/dialog/docrecovery.cxx b/svx/source/dialog/docrecovery.cxx
index c2f0690d6b94..baaaa04db053 100644
--- a/svx/source/dialog/docrecovery.cxx
+++ b/svx/source/dialog/docrecovery.cxx
@@ -591,6 +591,60 @@ void SAL_CALL PluginProgress::reset()
         m_xProgress->reset();
 }
 
+WeldPluginProgress::WeldPluginProgress(weld::ProgressBar* pProgressBar)
+    : m_pProgressBar(pProgressBar)
+    , m_nRange(100)
+{
+}
+
+WeldPluginProgress::~WeldPluginProgress()
+{
+}
+
+void SAL_CALL WeldPluginProgress::dispose()
+{
+    m_pProgressBar = nullptr;
+}
+
+void SAL_CALL WeldPluginProgress::addEventListener(const css::uno::Reference< css::lang::XEventListener >& )
+{
+}
+
+
+void SAL_CALL WeldPluginProgress::removeEventListener( const css::uno::Reference< css::lang::XEventListener >& )
+{
+}
+
+void SAL_CALL WeldPluginProgress::start(const OUString&, sal_Int32 nRange)
+{
+    m_nRange = nRange;
+    if (m_pProgressBar)
+        m_pProgressBar->set_percentage(0);
+}
+
+void SAL_CALL WeldPluginProgress::end()
+{
+    if (m_pProgressBar)
+        m_pProgressBar->set_percentage(m_nRange);
+}
+
+void SAL_CALL WeldPluginProgress::setText(const OUString& rText)
+{
+    if (m_pProgressBar)
+        m_pProgressBar->set_text(rText);
+}
+
+void SAL_CALL WeldPluginProgress::setValue(sal_Int32 nValue)
+{
+    if (m_pProgressBar)
+        m_pProgressBar->set_percentage((nValue * 100) / m_nRange);
+}
+
+void SAL_CALL WeldPluginProgress::reset()
+{
+    if (m_pProgressBar)
+        m_pProgressBar->set_percentage(0);
+}
 
 SaveDialog::SaveDialog(vcl::Window* pParent, RecoveryCore* pCore)
     : Dialog(pParent, "DocRecoverySaveDialog",
@@ -637,9 +691,9 @@ void SaveDialog::dispose()
 IMPL_LINK_NOARG(SaveDialog, OKButtonHdl, Button*, void)
 {
     // start crash-save with progress
-    ScopedVclPtrInstance< SaveProgressDialog > pProgress(this, m_pCore);
-    short nResult = pProgress->Execute();
-    pProgress.disposeAndClear();
+    std::unique_ptr<SaveProgressDialog> xProgress(new SaveProgressDialog(GetFrameWeld(), m_pCore));
+    short nResult = xProgress->run();
+    xProgress.reset();
 
     // if "CANCEL" => return "CANCEL"
     // if "OK"     => "AUTOLUNCH" always !
@@ -649,36 +703,28 @@ IMPL_LINK_NOARG(SaveDialog, OKButtonHdl, Button*, void)
     EndDialog(nResult);
 }
 
-SaveProgressDialog::SaveProgressDialog(vcl::Window* pParent, RecoveryCore* pCore)
-    : ModalDialog(pParent, "DocRecoveryProgressDialog",
-        "svx/ui/docrecoveryprogressdialog.ui")
+SaveProgressDialog::SaveProgressDialog(weld::Window* pParent, RecoveryCore* pCore)
+    : GenericDialogController(pParent, "svx/ui/docrecoveryprogressdialog.ui", "DocRecoveryProgressDialog")
     , m_pCore(pCore)
+    , m_xProgressBar(m_xBuilder->weld_progress_bar("progress"))
 {
-    get(m_pProgrParent, "progress");
-
-    PluginProgress* pProgress   = new PluginProgress(m_pProgrParent, pCore->getComponentContext());
+    m_xProgressBar->set_size_request(m_xProgressBar->get_approximate_digit_width() * 50, -1);
+    WeldPluginProgress* pProgress = new WeldPluginProgress(m_xProgressBar.get());
     m_xProgress.set(static_cast< css::task::XStatusIndicator* >(pProgress), css::uno::UNO_QUERY_THROW);
 }
 
 SaveProgressDialog::~SaveProgressDialog()
 {
-    disposeOnce();
-}
-
-void SaveProgressDialog::dispose()
-{
-    m_pProgrParent.clear();
-    ModalDialog::dispose();
 }
 
-short SaveProgressDialog::Execute()
+short SaveProgressDialog::run()
 {
     ::SolarMutexGuard aLock;
 
     m_pCore->setProgressHandler(m_xProgress);
     m_pCore->setUpdateListener(this);
     m_pCore->doEmergencySave();
-    short nRet = ModalDialog::Execute();
+    short nRet = DialogController::run();
     m_pCore->setUpdateListener(nullptr);
     return nRet;
 }
@@ -687,7 +733,6 @@ void SaveProgressDialog::updateItems()
 {
 }
 
-
 void SaveProgressDialog::stepNext(TURLInfo* )
 {
     /* TODO
@@ -698,24 +743,20 @@ void SaveProgressDialog::stepNext(TURLInfo* )
     */
 }
 
-
 void SaveProgressDialog::start()
 {
 }
 
-
 void SaveProgressDialog::end()
 {
-    EndDialog(DLG_RET_OK);
+    m_xDialog->response(DLG_RET_OK);
 }
 
-
 RecovDocListEntry::RecovDocListEntry( const OUString&        sText )
     : SvLBoxString( sText )
 {
 }
 
-
 void RecovDocListEntry::Paint(const Point& aPos, SvTreeListBox& aDevice, vcl::RenderContext& rRenderContext,
                               const SvViewDataEntry* /*pView*/, const SvTreeListEntry& rEntry)
 {
diff --git a/svx/source/inc/docrecovery.hxx b/svx/source/inc/docrecovery.hxx
index c6c8a0138214..3a4c1f769c9b 100644
--- a/svx/source/inc/docrecovery.hxx
+++ b/svx/source/inc/docrecovery.hxx
@@ -354,6 +354,33 @@ class PluginProgress : public ::cppu::WeakImplHelper< css::task::XStatusIndicato
         virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener) override;
 };
 
+class WeldPluginProgress : public ::cppu::WeakImplHelper<css::task::XStatusIndicator, css::lang::XComponent>
+{
+// member
+private:
+    weld::ProgressBar* m_pProgressBar;
+    int m_nRange;
+
+// native interface
+public:
+    WeldPluginProgress(weld::ProgressBar* pProgressBar);
+    virtual ~WeldPluginProgress() override;
+
+// uno interface
+public:
+    // XStatusIndicator
+    virtual void SAL_CALL start(const OUString& sText, sal_Int32 nRange) override;
+    virtual void SAL_CALL end() override;
+    virtual void SAL_CALL setText(const OUString& sText) override;
+    virtual void SAL_CALL setValue(sal_Int32 nValue) override;
+    virtual void SAL_CALL reset() override;
+
+    // XComponent
+    virtual void SAL_CALL dispose() override;
+    virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener >& xListener) override;
+    virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener) override;
+};
+
 class SaveDialog : public Dialog
 {
     // member
@@ -386,16 +413,16 @@ class SaveDialog : public Dialog
         DECL_LINK(OKButtonHdl, Button*, void);
 };
 
-class SaveProgressDialog : public ModalDialog
+class SaveProgressDialog : public weld::GenericDialogController
                          , public IRecoveryUpdateListener
 {
     // member
     private:
-        VclPtr<vcl::Window>       m_pProgrParent;
-
         // @short   TODO
         RecoveryCore* m_pCore;
 
+        std::unique_ptr<weld::ProgressBar> m_xProgressBar;
+
         // @short   TODO
         css::uno::Reference< css::task::XStatusIndicator > m_xProgress;
     // interface
@@ -413,13 +440,12 @@ class SaveProgressDialog : public ModalDialog
             @param  pCore
                     used to start emergency save.
          */
-        SaveProgressDialog(vcl::Window*       pParent,
-                           RecoveryCore* pCore  );
+        SaveProgressDialog(weld::Window* pParent,
+                           RecoveryCore* pCore);
         virtual ~SaveProgressDialog() override;
-        virtual void dispose() override;
 
         /** @short  start the emergency save operation. */
-        virtual short Execute() override;
+        virtual short run() override;
 
         // IRecoveryUpdateListener
         virtual void updateItems() override;
diff --git a/svx/uiconfig/ui/docrecoveryprogressdialog.ui b/svx/uiconfig/ui/docrecoveryprogressdialog.ui
index a382fda27c99..9fb10d280d2f 100644
--- a/svx/uiconfig/ui/docrecoveryprogressdialog.ui
+++ b/svx/uiconfig/ui/docrecoveryprogressdialog.ui
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.18.3 -->
+<!-- Generated with glade 3.22.1 -->
 <interface domain="svx">
   <requires lib="gtk+" version="3.18"/>
   <object class="GtkDialog" id="DocRecoveryProgressDialog">
@@ -7,7 +7,13 @@
     <property name="border_width">6</property>
     <property name="title" translatable="yes" context="docrecoveryprogressdialog|DocRecoveryProgressDialog">Documents Are Being Saved</property>
     <property name="resizable">False</property>
+    <property name="modal">True</property>
+    <property name="default_width">0</property>
+    <property name="default_height">0</property>
     <property name="type_hint">dialog</property>
+    <child>
+      <placeholder/>
+    </child>
     <child internal-child="vbox">
       <object class="GtkBox" id="dialog-vbox1">
         <property name="can_focus">False</property>
@@ -38,9 +44,9 @@
               <object class="GtkLabel" id="label2">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <property name="xalign">0</property>
                 <property name="label" translatable="yes" context="docrecoveryprogressdialog|label2">Progress of saving:</property>
                 <property name="use_underline">True</property>
+                <property name="xalign">0</property>
               </object>
               <packing>
                 <property name="left_attach">0</property>
@@ -48,7 +54,7 @@
               </packing>
             </child>
             <child>
-              <object class="GtkDrawingArea" id="progress">
+              <object class="GtkProgressBar" id="progress">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
                 <property name="hexpand">True</property>
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index 827256ca41d7..54faef46fec7 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -1820,6 +1820,16 @@ public:
     {
         m_xProgressBar->SetValue(value);
     }
+
+    virtual OUString get_text() const override
+    {
+        return m_xProgressBar->GetText();
+    }
+
+    virtual void set_text(const OUString& rText) override
+    {
+        m_xProgressBar->SetText(rText);
+    }
 };
 
 class SalInstanceImage : public SalInstanceWidget, public virtual weld::Image
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index 51b52a6626a6..a1b709b08b6a 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -4603,6 +4603,18 @@ public:
     {
         gtk_progress_bar_set_fraction(m_pProgressBar, value / 100.0);
     }
+
+    virtual OUString get_text() const override
+    {
+        const gchar* pText = gtk_progress_bar_get_text(m_pProgressBar);
+        OUString sRet(pText, pText ? strlen(pText) : 0, RTL_TEXTENCODING_UTF8);
+        return sRet;
+    }
+
+    virtual void set_text(const OUString& rText) override
+    {
+        gtk_progress_bar_set_text(m_pProgressBar, OUStringToOString(rText, RTL_TEXTENCODING_UTF8).getStr());
+    }
 };
 
 class GtkInstanceImage : public GtkInstanceWidget, public virtual weld::Image


More information about the Libreoffice-commits mailing list