[Libreoffice-commits] core.git: 2 commits - desktop/qa desktop/source include/LibreOfficeKit include/sal include/vcl sw/inc sw/source vcl/source

Pranav Kant pranavk at collabora.co.uk
Mon Oct 2 05:26:22 UTC 2017


 desktop/qa/desktop_lib/test_desktop_lib.cxx |    2 +
 desktop/source/lib/init.cxx                 |   10 +++---
 include/LibreOfficeKit/LibreOfficeKit.h     |    2 -
 include/sal/log-areas.dox                   |    1 
 include/vcl/IDialogRenderable.hxx           |   17 ++++++-----
 include/vcl/dialog.hxx                      |    3 +
 sw/inc/unotxdoc.hxx                         |    7 +---
 sw/source/uibase/uno/unotxdoc.cxx           |   43 +++++++++++++++-------------
 vcl/source/window/dialog.cxx                |   12 +++++++
 9 files changed, 61 insertions(+), 36 deletions(-)

New commits:
commit 0f58e974a7d6a88491a97ea3d0f30755ec330253
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Fri Jul 28 18:05:20 2017 +0530

    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

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 88b9df5a34fb..cd60aec267ee 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -18,6 +18,8 @@
 #include <com/sun/star/util/XModifiable.hpp>
 #include <com/sun/star/text/TextContentAnchorType.hpp>
 #include <boost/property_tree/json_parser.hpp>
+
+#include <vcl/scheduler.hxx>
 #include <comphelper/processfactory.hxx>
 #include <rtl/uri.hxx>
 #include <sfx2/objsh.hxx>
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 476b283c9104..3b8982553dfb 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -591,7 +591,7 @@ static unsigned char* doc_renderFont(LibreOfficeKitDocument* pThis,
                           int* pFontHeight);
 static char* doc_getPartHash(LibreOfficeKitDocument* pThis, int nPart);
 
-static void doc_paintDialog(LibreOfficeKitDocument* pThis, unsigned char* pBuffer, int nWidth, int nHeight);
+static void doc_paintDialog(LibreOfficeKitDocument* pThis, const char* pDialogId, unsigned char* pBuffer, int* nWidth, int* nHeight);
 
 LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XComponent> &xComponent)
     : mxComponent(xComponent)
@@ -3012,7 +3012,7 @@ unsigned char* doc_renderFont(SAL_UNUSED_PARAMETER LibreOfficeKitDocument* /*pTh
     return nullptr;
 }
 
-static void doc_paintDialog(LibreOfficeKitDocument* pThis, unsigned char* pBuffer, int nWidth, int nHeight)
+static void doc_paintDialog(LibreOfficeKitDocument* pThis, const char* pDialogId, unsigned char* pBuffer, int* nWidth, int* nHeight)
 {
     SolarMutexGuard aGuard;
 
@@ -3021,11 +3021,11 @@ static void doc_paintDialog(LibreOfficeKitDocument* pThis, unsigned char* pBuffe
     ScopedVclPtrInstance<VirtualDevice> pDevice(nullptr, Size(1, 1), DeviceFormat::DEFAULT);
     pDevice->SetBackground(Wallpaper(Color(COL_TRANSPARENT)));
 
-    pDevice->SetOutputSizePixelScaleOffsetAndBuffer(Size(nWidth, nHeight), Fraction(1.0), Point(), pBuffer);
+    pDevice->SetOutputSizePixelScaleOffsetAndBuffer(Size(*nWidth, *nHeight), Fraction(1.0), Point(), pBuffer);
 
-    vcl::DialogID aDialogID(pDialogRenderable->findDialog());
+    vcl::DialogID aDialogID = OUString::createFromAscii(pDialogId);
 
-    pDialogRenderable->paintDialog(aDialogID, *pDevice.get(), nWidth, nHeight);
+    pDialogRenderable->paintDialog(aDialogID, *pDevice.get(), *nWidth, *nHeight);
 }
 
 static char* lo_getError (LibreOfficeKit *pThis)
diff --git a/include/sal/log-areas.dox b/include/sal/log-areas.dox
index 8539f4755cd6..b8004d4f4fb4 100644
--- a/include/sal/log-areas.dox
+++ b/include/sal/log-areas.dox
@@ -293,6 +293,7 @@ certain functionality.
 
 @li @c lok
 @li @c lok.tiledrendering
+ at li @c lok.dialog
 
 @section l10ntools
 
diff --git a/include/vcl/IDialogRenderable.hxx b/include/vcl/IDialogRenderable.hxx
index 18694092c2fa..2621ec03947a 100644
--- a/include/vcl/IDialogRenderable.hxx
+++ b/include/vcl/IDialogRenderable.hxx
@@ -14,26 +14,29 @@
 #include <tools/gen.hxx>
 #include <vcl/pointr.hxx>
 #include <vcl/virdev.hxx>
+#include <vcl/window.hxx>
+
+#include "IDialogRenderable.hxx"
+
+#include <map>
 
 namespace vcl
 {
 
-typedef sal_Int32 DialogID;
+typedef OUString DialogID;
 
 class VCL_DLLPUBLIC IDialogRenderable
 {
 public:
     virtual ~IDialogRenderable();
 
-    virtual DialogID findDialog() = 0;
-
-    virtual void paintDialog(DialogID rDialogID, VirtualDevice &rDevice,
-                             int nOutputWidth, int nOutputHeight) = 0;
+    virtual void paintDialog(const DialogID& rDialogID, VirtualDevice &rDevice,
+                             int& nOutputWidth, int& nOutputHeight) = 0;
 
-    virtual void postDialogMouseEvent(DialogID rDialogID, int nType,
+    virtual void postDialogMouseEvent(const DialogID& rDialogID, int nType,
                                       int nCharCode, int nKeyCode) = 0;
 
-    virtual void postDialogKeyEvent(DialogID rDialogID, int nType, int nX, int nY,
+    virtual void postDialogKeyEvent(const DialogID& rDialogID, int nType, int nX, int nY,
                                     int nCount, int nButtons, int nModifier) = 0;
 };
 
diff --git a/include/vcl/dialog.hxx b/include/vcl/dialog.hxx
index 1ddbf016b88c..457943c08d37 100644
--- a/include/vcl/dialog.hxx
+++ b/include/vcl/dialog.hxx
@@ -114,6 +114,9 @@ public:
     virtual void PrePaint(vcl::RenderContext& rRenderContext) override;
     virtual void PostPaint(vcl::RenderContext& rRenderContext) override;
 
+    // Paints the current dialog to the given virtual device
+    void paintDialog(VirtualDevice& rDevice);
+
     // ensureRepaint - triggers Application::Yield until the dialog is
     // completely repainted. Sometimes needed for dialogs showing progress
     // during actions
diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx
index 0d782213ce61..0f8bc11d4da5 100644
--- a/sw/inc/unotxdoc.hxx
+++ b/sw/inc/unotxdoc.hxx
@@ -431,12 +431,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 78d3ffe123fc..2a5152bbf431 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -33,6 +33,8 @@
 #include <sfx2/viewfrm.hxx>
 #include <sfx2/sfxbasecontroller.hxx>
 #include <sfx2/docfile.hxx>
+#include <sfx2/msg.hxx>
+#include <sfx2/msgpool.hxx>
 #include <sfx2/printer.hxx>
 #include <toolkit/helper/vclunohelper.hxx>
 #include <toolkit/awt/vclxdevice.hxx>
@@ -3636,32 +3638,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<Dialog*>(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*/)
 {
 }
diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx
index e4aac9dbf322..679c83ba462b 100644
--- a/vcl/source/window/dialog.cxx
+++ b/vcl/source/window/dialog.cxx
@@ -51,6 +51,7 @@
 #include <vcl/settings.hxx>
 #include <vcl/uitest/uiobject.hxx>
 #include <vcl/uitest/logger.hxx>
+#include <vcl/virdev.hxx>
 #include <salframe.hxx>
 
 #include <iostream>
@@ -857,6 +858,17 @@ bool Dialog::selectPageByUIXMLDescription(const OString& /*rUIXMLDescription*/)
     return true;
 }
 
+void Dialog::paintDialog(VirtualDevice& rDevice)
+{
+    setDeferredProperties();
+    ImplAdjustNWFSizes();
+    Show();
+    ToTop();
+    ensureRepaint();
+
+    PaintToDevice(&rDevice, Point(0, 0), Size());
+}
+
 void Dialog::ensureRepaint()
 {
     // ensure repaint
commit 1325fabbdd2e52169a7d1a1b9a6b9b59d908e8bb
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Fri Jul 28 16:34:56 2017 +0530

    Include dialogID in paintDialog API
    
    Change-Id: I6bc624272138f0e23d2e3abfd82b857fed12e12c

diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index 2f0702c67ca8..46ecb6c83372 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -267,7 +267,7 @@ struct _LibreOfficeKitDocumentClass
                        size_t nSize);
 
     /// WIP
-    void (*paintDialog) (LibreOfficeKitDocument* pThis, unsigned char* pBuffer, int nWidth, int nHeight);
+    void (*paintDialog) (LibreOfficeKitDocument* pThis, const char* pDialogId, unsigned char* pBuffer, int* nWidth, int* nHeight);
 
 #endif // defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY
 };


More information about the Libreoffice-commits mailing list