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

Pranav Kant pranavk at collabora.co.uk
Sat Oct 28 15:07:43 UTC 2017


 desktop/source/lib/init.cxx                         |   15 ++++++++++++---
 include/LibreOfficeKit/LibreOfficeKit.h             |    2 +-
 include/LibreOfficeKit/LibreOfficeKit.hxx           |    5 ++++-
 include/vcl/IDialogRenderable.hxx                   |    2 +-
 libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx |   15 ++++++++++-----
 sw/inc/unotxdoc.hxx                                 |    2 +-
 sw/source/uibase/uno/unotxdoc.cxx                   |    5 ++++-
 7 files changed, 33 insertions(+), 13 deletions(-)

New commits:
commit fdb56a741a66e152f0f120d00bf62049fe566a79
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Thu Oct 26 18:31:39 2017 -0700

    lokdialog: Tunnel dialog title to lokclient as outparam
    
    Change-Id: I1beb5ab3f06debdca7ebf999af7ac879a41ea47e
    Reviewed-on: https://gerrit.libreoffice.org/43959
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: pranavk <pranavk at collabora.co.uk>

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index bd09ed1dd987..906e271f5c30 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -610,7 +610,7 @@ static unsigned char* doc_renderFont(LibreOfficeKitDocument* pThis,
                           int* pFontHeight);
 static char* doc_getPartHash(LibreOfficeKitDocument* pThis, int nPart);
 
-static void doc_paintDialog(LibreOfficeKitDocument* pThis, const char* pDialogId, unsigned char* pBuffer, int* nWidth, int* nHeight);
+static void doc_paintDialog(LibreOfficeKitDocument* pThis, const char* pDialogId, unsigned char* pBuffer, char** pDialogTitle, int* nWidth, int* nHeight);
 
 static void doc_paintActiveFloatingWindow(LibreOfficeKitDocument* pThis, const char* pDialogId, unsigned char* pBuffer, int* nWidth, int* nHeight);
 
@@ -3089,7 +3089,7 @@ unsigned char* doc_renderFont(SAL_UNUSED_PARAMETER LibreOfficeKitDocument* /*pTh
     return nullptr;
 }
 
-static void doc_paintDialog(LibreOfficeKitDocument* pThis, const char* pDialogId, unsigned char* pBuffer, int* nWidth, int* nHeight)
+static void doc_paintDialog(LibreOfficeKitDocument* pThis, const char* pDialogId, unsigned char* pBuffer, char** pDialogTitle, int* nWidth, int* nHeight)
 {
     SolarMutexGuard aGuard;
 
@@ -3103,7 +3103,16 @@ static void doc_paintDialog(LibreOfficeKitDocument* pThis, const char* pDialogId
     vcl::DialogID aDialogID = OUString::createFromAscii(pDialogId);
 
     comphelper::LibreOfficeKit::setDialogPainting(true);
-    pDialogRenderable->paintDialog(aDialogID, *pDevice.get(), *nWidth, *nHeight);
+
+    // copy the title of the dialog to outparam
+    OUString aDialogTitle;
+    pDialogRenderable->paintDialog(aDialogID, *pDevice.get(), aDialogTitle, *nWidth, *nHeight);
+    if (!aDialogTitle.isEmpty())
+    {
+        OString aTitleString = OUStringToOString(aDialogTitle, RTL_TEXTENCODING_UTF8);
+        *pDialogTitle = static_cast<char*>(malloc(aTitleString.getLength() + 1));
+        strcpy(*pDialogTitle, aTitleString.getStr());
+    }
     comphelper::LibreOfficeKit::setDialogPainting(false);
 }
 
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index cf030a7f69e8..cc4752e04ab2 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -268,7 +268,7 @@ struct _LibreOfficeKitDocumentClass
 
     /// Paints dialog with given dialog id to the buffer
     /// @see lok::Document::paintDialog().
-    void (*paintDialog) (LibreOfficeKitDocument* pThis, const char* pDialogId, unsigned char* pBuffer, int* nWidth, int* nHeight);
+    void (*paintDialog) (LibreOfficeKitDocument* pThis, const char* pDialogId, unsigned char* pBuffer, char** pDialogTitle, int* nWidth, int* nHeight);
 
     /// @see lok::Document::paintActiveFloatingWindow().
     void (*paintActiveFloatingWindow) (LibreOfficeKitDocument* pThis, const char* pDialogId, unsigned char* pBuffer, int* nWidth, int* nHeight);
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx
index e573a88249a9..ad5e6d74e878 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -162,16 +162,19 @@ public:
      *
      * @param pDialogId Unique dialog id to be painted
      * @param pBuffer Buffer with enough memory allocated to render any dialog
+     * @param pDialogTitle output parameter pointing to a dialog title
+     * string. Should be freed by the caller.
      * @param nWidth output parameter returning the width of the rendered dialog.
      * @param nHeight output parameter returning the height of the rendered dialog
      */
     void paintDialog(const char* pDialogId,
                      unsigned char* pBuffer,
+                     char** pDialogTitle,
                      int& nWidth,
                      int& nHeight)
     {
         return mpDoc->pClass->paintDialog(mpDoc, pDialogId, pBuffer,
-                                          &nWidth, &nHeight);
+                                          pDialogTitle, &nWidth, &nHeight);
     }
 
     /**
diff --git a/include/vcl/IDialogRenderable.hxx b/include/vcl/IDialogRenderable.hxx
index 3fd6b6c93bd8..645ceef643b5 100644
--- a/include/vcl/IDialogRenderable.hxx
+++ b/include/vcl/IDialogRenderable.hxx
@@ -29,7 +29,7 @@ public:
     virtual ~IDialogRenderable();
 
     virtual void paintDialog(const DialogID& rDialogID, VirtualDevice &rDevice,
-                             int& nOutputWidth, int& nOutputHeight) = 0;
+                             OUString& rDialogTitle, int& nOutputWidth, int& nOutputHeight) = 0;
 
     virtual void paintActiveFloatingWindow(const DialogID& rDialogID, VirtualDevice &rDevice,
                                            int& nOutputWidth, int& nOutputHeight) = 0;
diff --git a/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx b/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx
index 6948b842f633..f65f2f023bef 100644
--- a/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx
@@ -87,14 +87,20 @@ gtv_lok_dialog_draw(GtkWidget* pDialogDrawingArea, cairo_t* pCairo, gpointer)
     GtvLokDialog* pDialog = GTV_LOK_DIALOG(gtk_widget_get_toplevel(pDialogDrawingArea));
     GtvLokDialogPrivate* priv = getPrivate(pDialog);
 
-
-    g_info("painting dialog");
+    g_info("panting dialog");
     int nWidth = 1024;
     int nHeight = 768;
     cairo_surface_t* pSurface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, nWidth, nHeight);
     unsigned char* pBuffer = cairo_image_surface_get_data(pSurface);
     LibreOfficeKitDocument* pDocument = lok_doc_view_get_document(LOK_DOC_VIEW(priv->lokdocview));
-    pDocument->pClass->paintDialog(pDocument, priv->dialogid, pBuffer, &nWidth, &nHeight);
+    char* pDialogTitle = nullptr;
+    pDocument->pClass->paintDialog(pDocument, priv->dialogid, pBuffer, &pDialogTitle, &nWidth, &nHeight);
+    if (pDialogTitle)
+    {
+        gtk_window_set_title(GTK_WINDOW(pDialog), pDialogTitle);
+        free(pDialogTitle);
+    }
+
     gtk_widget_set_size_request(GTK_WIDGET(pDialogDrawingArea), nWidth, nHeight);
 
     cairo_surface_flush(pSurface);
@@ -472,7 +478,6 @@ gtv_lok_dialog_invalidate(GtvLokDialog* dialog)
 {
     GtvLokDialogPrivate* priv = getPrivate(dialog);
 
-    // trigger a draw on the dialog drawing area
     gtk_widget_queue_draw(priv->pDialogDrawingArea);
 }
 
@@ -597,7 +602,7 @@ void gtv_lok_dialog_child_invalidate(GtvLokDialog* dialog, int nX, int nY)
     g_info("Dialog's floating window invalidate");
 
     GtvLokDialogPrivate* priv = getPrivate(dialog);
-    // remove any existing floating windows, for now
+    // create new if doesn't exist
     if (!priv->pFloatingWin)
     {
         priv->pFloatingWin = gtk_window_new(GTK_WINDOW_POPUP);
diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx
index e6d0770374d3..a35610e71e12 100644
--- a/sw/inc/unotxdoc.hxx
+++ b/sw/inc/unotxdoc.hxx
@@ -431,7 +431,7 @@ public:
     /// @see vcl::ITiledRenderable::getPostIts().
     OUString getPostIts() override;
 
-    void paintDialog(const vcl::DialogID& rDialogID, VirtualDevice& rDevice, int& nWidth, int& nHeight) override;
+    void paintDialog(const vcl::DialogID& rDialogID, VirtualDevice& rDevice, OUString& rDialogTitle, int& nWidth, int& nHeight) override;
     void paintActiveFloatingWindow(const vcl::DialogID& rDialogID, VirtualDevice& rDevice, int& nWidth, int& nHeight) override;
     void postDialogKeyEvent(const vcl::DialogID& rDialogID, int nType,
                             int nCharCode, int nKeyCode) override;
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index 818a47ff5a83..cdff7acc2018 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -3639,7 +3639,7 @@ void SAL_CALL SwXTextDocument::paintTile( const ::css::uno::Any& Parent, ::sal_I
     #endif
 }
 
-void SwXTextDocument::paintDialog(const vcl::DialogID& rDialogID, VirtualDevice& rDevice, int& nWidth, int& nHeight)
+void SwXTextDocument::paintDialog(const vcl::DialogID& rDialogID, VirtualDevice& rDevice, OUString& rDialogTitle, int& nWidth, int& nHeight)
 {
     SfxViewFrame* pViewFrame = pDocShell->GetView()->GetViewFrame();
     SfxSlotPool* pSlotPool = SW_MOD()->GetSlotPool();
@@ -3665,6 +3665,9 @@ void SwXTextDocument::paintDialog(const vcl::DialogID& rDialogID, VirtualDevice&
     // register the instance so that vcl::Dialog can emit LOK callbacks
     pDlg->registerDialogRenderable(this, rDialogID);
     pDlg->paintDialog(rDevice);
+
+    // set outparams
+    rDialogTitle = pDlg->GetText();
     const Size aSize = pDlg->GetOptimalSize();
     nWidth = aSize.getWidth();
     nHeight = aSize.getHeight();


More information about the Libreoffice-commits mailing list