diff options
author | Pranav Kant <pranavk@collabora.co.uk> | 2017-10-26 18:31:39 -0700 |
---|---|---|
committer | pranavk <pranavk@collabora.co.uk> | 2017-10-28 17:07:19 +0200 |
commit | fdb56a741a66e152f0f120d00bf62049fe566a79 (patch) | |
tree | 8fca2c834d462d80a02de22c61f2be61107bb17b | |
parent | 79fa071767c7c6b88950b82143fa76df63b172e6 (diff) |
lokdialog: Tunnel dialog title to lokclient as outparam
Change-Id: I1beb5ab3f06debdca7ebf999af7ac879a41ea47e
Reviewed-on: https://gerrit.libreoffice.org/43959
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: pranavk <pranavk@collabora.co.uk>
-rw-r--r-- | desktop/source/lib/init.cxx | 15 | ||||
-rw-r--r-- | include/LibreOfficeKit/LibreOfficeKit.h | 2 | ||||
-rw-r--r-- | include/LibreOfficeKit/LibreOfficeKit.hxx | 5 | ||||
-rw-r--r-- | include/vcl/IDialogRenderable.hxx | 2 | ||||
-rw-r--r-- | libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx | 15 | ||||
-rw-r--r-- | sw/inc/unotxdoc.hxx | 2 | ||||
-rw-r--r-- | sw/source/uibase/uno/unotxdoc.cxx | 5 |
7 files changed, 33 insertions, 13 deletions
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(); |