cui/source/dialogs/insdlg.cxx |   28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

New commits:
commit 0713d278f5bf232bad819dd46dc19d34ed807b12
Author:     Miklos Vajna <vmik...@collabora.com>
AuthorDate: Tue Sep 28 17:54:27 2021 +0200
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Tue Sep 28 19:45:40 2021 +0200

    cui: add a status indicator for the OLE insert dialog
    
    Inserting a large file can take a while, and we do it on the main
    thread, so the UI is frozen during the operation.
    
    Create a statusbar and tell the user what's happening, even if the
    underlying CreateObjectFromFile() and OleSave() functions don't report
    their progress, so effectively this is more like a spinner than a
    progressbar.
    
    Change-Id: Ib5d90e214c556b43f170538fc152a9e27193773f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122781
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>
    Tested-by: Jenkins

diff --git a/cui/source/dialogs/insdlg.cxx b/cui/source/dialogs/insdlg.cxx
index 7e411d3c021d..e811ad033f69 100644
--- a/cui/source/dialogs/insdlg.cxx
+++ b/cui/source/dialogs/insdlg.cxx
@@ -27,6 +27,7 @@
 #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
 #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
 #include <com/sun/star/ui/dialogs/XFilePicker3.hpp>
+#include <com/sun/star/task/XStatusIndicatorFactory.hpp>
 #include <comphelper/processfactory.hxx>
 
 #include <insdlg.hxx>
@@ -48,6 +49,9 @@
 #include <sfx2/frmdescr.hxx>
 #include <sfx2/viewsh.hxx>
 #include <comphelper/seqstream.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <svx/strings.hrc>
+#include <svx/dialmgr.hxx>
 
 #include <strings.hrc>
 
@@ -276,10 +280,34 @@ short SvInsertOleDlg::run()
                 aMedium[1].Value <<= xInteraction;
 
                 // create object from media descriptor
+
+                uno::Reference<task::XStatusIndicator> xProgress;
+                SfxViewFrame* pFrame = SfxViewFrame::Current();
+                if (pFrame)
+                {
+                    // Have a current frame, create visual indication that 
insert is in progress.
+                    uno::Reference<frame::XFrame> xFrame = 
pFrame->GetFrame().GetFrameInterface();
+                    uno::Reference<task::XStatusIndicatorFactory> 
xProgressFactory(xFrame, uno::UNO_QUERY);
+                    if (xProgressFactory.is())
+                    {
+                        xProgress = xProgressFactory->createStatusIndicator();
+                        if (xProgress)
+                        {
+                            OUString aDocLoad(SvxResId(RID_SVXSTR_DOC_LOAD));
+                            xProgress->start(aDocLoad, 100);
+                        }
+                    }
+                }
+
                 if ( bLink )
                     m_xObj = aCnt.InsertEmbeddedLink( aMedium, aName );
                 else
                     m_xObj = aCnt.InsertEmbeddedObject( aMedium, aName );
+
+                if (xProgress.is())
+                {
+                    xProgress->end();
+                }
             }
 
             if ( !m_xObj.is() )

Reply via email to