diff options
author | Szymon Kłos <szymon.klos@collabora.com> | 2021-01-11 13:52:32 +0100 |
---|---|---|
committer | Szymon Kłos <szymon.klos@collabora.com> | 2021-01-12 10:33:44 +0100 |
commit | eeb5caddd6d09d0eb13d421e12415f6fb2c4af4f (patch) | |
tree | f3207423ba8ceac28ba5b022379533313fd1e80a /sw | |
parent | 86eaeafcaf4ac16415941228a8fee33e6e295d14 (diff) |
Make Fontwork gallery dialog async
Change-Id: I156dc1b505b01dc7520ccfe80bbf97eba881d653
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109092
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/uibase/uiview/viewdraw.cxx | 53 |
1 files changed, 29 insertions, 24 deletions
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 ); |