From 2cf317089657c36d0fd1050a54f80e650c64f8c0 Mon Sep 17 00:00:00 2001 From: Pranav Kant Date: Fri, 28 Jul 2017 18:05:20 +0530 Subject: lokdialog: Better dialog rendering API After painting the dialog, also write width and height of the rendered dialog. The dialog is rendered always on the top left of the given canvas, so client can crop the canvas accordingly. Change-Id: If052058a6db8a85d4e28ec88cffcca05564b17f0 --- sw/inc/unotxdoc.hxx | 7 +++---- sw/source/uibase/uno/unotxdoc.cxx | 43 ++++++++++++++++++++++----------------- 2 files changed, 27 insertions(+), 23 deletions(-) (limited to 'sw') diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx index 0711f4317bbc..249eeacc0420 100644 --- a/sw/inc/unotxdoc.hxx +++ b/sw/inc/unotxdoc.hxx @@ -452,12 +452,11 @@ public: /// @see vcl::ITiledRenderable::getPostIts(). OUString getPostIts() override; - vcl::DialogID findDialog() override; - void paintDialog(vcl::DialogID rDialogID, VirtualDevice &rDevice, int nWidth, int nHeight) override; - void postDialogMouseEvent(vcl::DialogID rDialogID, int nType, + void paintDialog(const vcl::DialogID& rDialogID, VirtualDevice& rDevice, int& nWidth, int& nHeight) override; + void postDialogMouseEvent(const vcl::DialogID& rDialogID, int nType, int nCharCode, int nKeyCode) override; - void postDialogKeyEvent(vcl::DialogID rDialogID, int nType, int nX, int nY, + void postDialogKeyEvent(const vcl::DialogID& rDialogID, int nType, int nX, int nY, int nCount, int nButtons, int nModifier) override; // css::tiledrendering::XTiledRenderable diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx index 1abd5c818edf..2c6f82bb1310 100644 --- a/sw/source/uibase/uno/unotxdoc.cxx +++ b/sw/source/uibase/uno/unotxdoc.cxx @@ -33,6 +33,8 @@ #include #include #include +#include +#include #include #include #include @@ -3708,32 +3710,35 @@ void SAL_CALL SwXTextDocument::paintTile( const ::css::uno::Any& Parent, ::sal_I #endif } -vcl::DialogID SwXTextDocument::findDialog() +void SwXTextDocument::paintDialog(const vcl::DialogID& rDialogID, VirtualDevice& rDevice, int& nWidth, int& nHeight) { - return vcl::DialogID(0); -} - -void SwXTextDocument::paintDialog(vcl::DialogID /*rDialogID*/, VirtualDevice& rDevice, int nWidth, int nHeight) -{ - SfxViewShell* pViewShell = pDocShell->GetView(); - SfxViewFrame* pViewFrame = pViewShell->GetViewFrame(); - SfxChildWindow* pSfxChildWindow = SwSpellDialogChildWindow::CreateImpl(&pViewFrame->GetWindow(), SwSpellDialogChildWindow::GetChildWindowId(), - &pViewFrame->GetBindings(), nullptr); - - Size aSize(nWidth, nHeight); - - vcl::Window* pWindow = pSfxChildWindow->GetWindow(); + SfxViewFrame* pViewFrame = pDocShell->GetView()->GetViewFrame(); + SfxSlotPool* pSlotPool = SW_MOD()->GetSlotPool(); + const SfxSlot* pSlot = pSlotPool->GetUnoSlot(rDialogID); + SfxChildWindow* pChild = pViewFrame->GetChildWindow(pSlot->GetSlotId()); + if (!pChild) + { + pViewFrame->ToggleChildWindow(pSlot->GetSlotId()); + pChild = pViewFrame->GetChildWindow(pSlot->GetSlotId()); + if (!pChild) + { + SAL_WARN("lok.dialog", "Dialog " << rDialogID << " is not supported"); + return; + } + } - pWindow->SetSizePixel(aSize); - pWindow->Show(); - pWindow->Paint(rDevice, tools::Rectangle(Point(), aSize)); + Dialog* pDlg = static_cast(pChild->GetWindow()); + pDlg->paintDialog(rDevice); + const Size aSize = pDlg->GetOptimalSize(); + nWidth = aSize.getWidth(); + nHeight = aSize.getHeight(); } -void SwXTextDocument::postDialogMouseEvent(vcl::DialogID /*rDialogID*/, int /*nType*/, int /*nCharCode*/, int /*nKeyCode*/) +void SwXTextDocument::postDialogMouseEvent(const vcl::DialogID& /*rDialogID*/, int /*nType*/, int /*nCharCode*/, int /*nKeyCode*/) { } -void SwXTextDocument::postDialogKeyEvent(vcl::DialogID /*rDialogID*/, int /*nType*/, int /*nX*/, int /*nY*/, +void SwXTextDocument::postDialogKeyEvent(const vcl::DialogID& /*rDialogID*/, int /*nType*/, int /*nX*/, int /*nY*/, int /*nCount*/, int /*nButtons*/, int /*nModifier*/) { } -- cgit