[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - include/svx svx/source sw/source

Szymon KÅ‚os (via logerrit) logerrit at kemper.freedesktop.org
Tue Jan 12 09:34:18 UTC 2021


 include/svx/fontworkgallery.hxx         |    6 ++-
 svx/source/tbxctrls/fontworkgallery.cxx |    9 +++--
 svx/source/toolbars/fontworkbar.cxx     |    4 +-
 sw/source/uibase/uiview/viewdraw.cxx    |   53 +++++++++++++++++---------------
 4 files changed, 40 insertions(+), 32 deletions(-)

New commits:
commit eeb5caddd6d09d0eb13d421e12415f6fb2c4af4f
Author:     Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Mon Jan 11 13:52:32 2021 +0100
Commit:     Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Tue Jan 12 10:33:44 2021 +0100

    Make Fontwork gallery dialog async
    
    Change-Id: I156dc1b505b01dc7520ccfe80bbf97eba881d653
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109092
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>

diff --git a/include/svx/fontworkgallery.hxx b/include/svx/fontworkgallery.hxx
index b8a3f954eb98..54bcb4008e85 100644
--- a/include/svx/fontworkgallery.hxx
+++ b/include/svx/fontworkgallery.hxx
@@ -49,7 +49,8 @@ class SAL_WARN_UNUSED SVX_DLLPUBLIC FontWorkGalleryDialog final : public weld::G
     sal_uInt16          mnThemeId;
     SdrView&            mrSdrView;
 
-    SdrObject**         mppSdrObject;
+    bool                mbInsertIntoPage;
+    SdrObject*          mppSdrObject;
     SdrModel*           mpDestModel;
 
     std::vector<VclPtr< VirtualDevice >> maFavoritesHorizontal;
@@ -69,7 +70,8 @@ public:
     virtual ~FontWorkGalleryDialog() override;
 
     // SJ: if the SdrObject** is set, the SdrObject is not inserted into the page when executing the dialog
-    void SetSdrObjectRef( SdrObject**, SdrModel* pModel );
+    void SetSdrObjectRef( SdrModel* pModel, bool bInsertIntoPage = true );
+    SdrObject* GetSdrObjectRef() { return mppSdrObject; }
 };
 
 }
diff --git a/svx/source/tbxctrls/fontworkgallery.cxx b/svx/source/tbxctrls/fontworkgallery.cxx
index 036060109918..69055a0be856 100644
--- a/svx/source/tbxctrls/fontworkgallery.cxx
+++ b/svx/source/tbxctrls/fontworkgallery.cxx
@@ -67,6 +67,7 @@ FontWorkGalleryDialog::FontWorkGalleryDialog(weld::Window* pParent, SdrView& rSd
     : GenericDialogController(pParent, "svx/ui/fontworkgallerydialog.ui", "FontworkGalleryDialog")
     , mnThemeId(0xffff)
     , mrSdrView(rSdrView)
+    , mbInsertIntoPage(true)
     , mppSdrObject(nullptr)
     , mpDestModel(nullptr)
     , maCtlFavorites(m_xBuilder->weld_icon_view("ctlFavoriteswin"))
@@ -146,9 +147,9 @@ void FontWorkGalleryDialog::fillFavorites(sal_uInt16 nThemeId)
         maCtlFavorites->select(0);
 }
 
-void FontWorkGalleryDialog::SetSdrObjectRef( SdrObject** ppSdrObject, SdrModel* pModel )
+void FontWorkGalleryDialog::SetSdrObjectRef( SdrModel* pModel, bool bInsertIntoPage )
 {
-    mppSdrObject = ppSdrObject;
+    mbInsertIntoPage = bInsertIntoPage;
     mpDestModel = pModel;
 }
 
@@ -172,7 +173,7 @@ void FontWorkGalleryDialog::insertSelectedFontwork()
                 // If this is not used, the correct SdrModel seems to be the one from
                 // the mrSdrView that is used to insert (InsertObjectAtView below) the
                 // cloned SdrObject.
-                const bool bUseSpecialCalcMode(nullptr != mppSdrObject && nullptr != mpDestModel);
+                const bool bUseSpecialCalcMode(!mbInsertIntoPage && nullptr != mpDestModel);
 
                 // center shape on current view
                 OutputDevice* pOutDev(mrSdrView.GetFirstOutputDevice());
@@ -206,7 +207,7 @@ void FontWorkGalleryDialog::insertSelectedFontwork()
 
                     if (bUseSpecialCalcMode)
                     {
-                        *mppSdrObject = pNewObject;
+                        mppSdrObject = pNewObject;
                     }
                     else
                     {
diff --git a/svx/source/toolbars/fontworkbar.cxx b/svx/source/toolbars/fontworkbar.cxx
index 8ca8a1c33f7e..3b6144c2e229 100644
--- a/svx/source/toolbars/fontworkbar.cxx
+++ b/svx/source/toolbars/fontworkbar.cxx
@@ -418,8 +418,8 @@ void FontworkBar::execute( SdrView& rSdrView, SfxRequest const & rReq, SfxBindin
     {
         case SID_FONTWORK_GALLERY_FLOATER:
         {
-            FontWorkGalleryDialog aDlg(rReq.GetFrameWeld(), rSdrView);
-            aDlg.run();
+            std::shared_ptr<FontWorkGalleryDialog> pDlg = std::make_shared<FontWorkGalleryDialog>(rReq.GetFrameWeld(), rSdrView);
+            weld::DialogController::runAsync(pDlg, [](int){});
         }
         break;
 
diff --git a/sw/source/uibase/uiview/viewdraw.cxx b/sw/source/uibase/uiview/viewdraw.cxx
index 465ab3dfc82d..cb06e3797264 100644
--- a/sw/source/uibase/uiview/viewdraw.cxx
+++ b/sw/source/uibase/uiview/viewdraw.cxx
@@ -157,35 +157,40 @@ void SwView::ExecDraw(SfxRequest& rReq)
         pSdrView = m_pWrtShell->GetDrawView();
         if (pSdrView)
         {
-            SdrObject* pObj = nullptr;
-            svx::FontWorkGalleryDialog aDlg(rWin.GetFrameWeld(), *pSdrView);
-            aDlg.SetSdrObjectRef( &pObj, pSdrView->GetModel() );
-            aDlg.run();
-            if ( pObj )
-            {
-                Size            aDocSize( m_pWrtShell->GetDocSize() );
-                const SwRect&   rVisArea = m_pWrtShell->VisArea();
-                Point           aPos( rVisArea.Center() );
-                Size            aSize;
-                Size            aPrefSize( pObj->GetSnapRect().GetSize() );
+            std::shared_ptr<svx::FontWorkGalleryDialog> pDlg = std::make_shared<svx::FontWorkGalleryDialog>(rWin.GetFrameWeld(), *pSdrView);
+            pDlg->SetSdrObjectRef( pSdrView->GetModel(), false );
+            weld::DialogController::runAsync(pDlg, [this, pDlg](int) {
+                vcl::Window& rWin2 = m_pWrtShell->GetView().GetViewFrame()->GetWindow();
 
-                if( rVisArea.Width() > aDocSize.Width())
-                    aPos.setX( aDocSize.Width() / 2 + rVisArea.Left() );
+                SdrObject* pObj = pDlg->GetSdrObjectRef();
+                if ( pObj )
+                {
+                    Size            aDocSize( m_pWrtShell->GetDocSize() );
+                    const SwRect&   rVisArea = m_pWrtShell->VisArea();
+                    Point           aPos( rVisArea.Center() );
+                    Size            aSize;
+                    Size            aPrefSize( pObj->GetSnapRect().GetSize() );
 
-                if(rVisArea.Height() > aDocSize.Height())
-                    aPos.setY( aDocSize.Height() / 2 + rVisArea.Top() );
+                    if( rVisArea.Width() > aDocSize.Width())
+                        aPos.setX( aDocSize.Width() / 2 + rVisArea.Left() );
 
-                if( aPrefSize.Width() && aPrefSize.Height() )
-                    aSize = rWin.PixelToLogic(aPrefSize, MapMode(MapUnit::MapTwip));
-                else
-                    aSize = Size( 2835, 2835 );
+                    if(rVisArea.Height() > aDocSize.Height())
+                        aPos.setY( aDocSize.Height() / 2 + rVisArea.Top() );
 
-                m_pWrtShell->EnterStdMode();
-                m_pWrtShell->SwFEShell::InsertDrawObj( *pObj, aPos );
-                rReq.Ignore ();
-            }
+                    if( aPrefSize.Width() && aPrefSize.Height() )
+                        aSize = rWin2.PixelToLogic(aPrefSize, MapMode(MapUnit::MapTwip));
+                    else
+                        aSize = Size( 2835, 2835 );
+
+                    m_pWrtShell->EnterStdMode();
+                    m_pWrtShell->SwFEShell::InsertDrawObj( *pObj, aPos );
+                }
+
+                rWin2.LeaveWait();
+            });
         }
-        rWin.LeaveWait();
+        else
+            rWin.LeaveWait();
     }
     else if ( m_nFormSfxId != USHRT_MAX )
         GetViewFrame()->GetDispatcher()->Execute( SID_FM_LEAVE_CREATE );


More information about the Libreoffice-commits mailing list