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>
This commit is contained in:
Pranav Kant
2017-10-26 18:31:39 -07:00
committed by pranavk
parent 79fa071767
commit fdb56a741a
7 changed files with 33 additions and 13 deletions

View File

@@ -610,7 +610,7 @@ static unsigned char* doc_renderFont(LibreOfficeKitDocument* pThis,
int* pFontHeight); int* pFontHeight);
static char* doc_getPartHash(LibreOfficeKitDocument* pThis, int nPart); 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); 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; 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; SolarMutexGuard aGuard;
@@ -3103,7 +3103,16 @@ static void doc_paintDialog(LibreOfficeKitDocument* pThis, const char* pDialogId
vcl::DialogID aDialogID = OUString::createFromAscii(pDialogId); vcl::DialogID aDialogID = OUString::createFromAscii(pDialogId);
comphelper::LibreOfficeKit::setDialogPainting(true); 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); comphelper::LibreOfficeKit::setDialogPainting(false);
} }

View File

@@ -268,7 +268,7 @@ struct _LibreOfficeKitDocumentClass
/// Paints dialog with given dialog id to the buffer /// Paints dialog with given dialog id to the buffer
/// @see lok::Document::paintDialog(). /// @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(). /// @see lok::Document::paintActiveFloatingWindow().
void (*paintActiveFloatingWindow) (LibreOfficeKitDocument* pThis, const char* pDialogId, unsigned char* pBuffer, int* nWidth, int* nHeight); void (*paintActiveFloatingWindow) (LibreOfficeKitDocument* pThis, const char* pDialogId, unsigned char* pBuffer, int* nWidth, int* nHeight);

View File

@@ -162,16 +162,19 @@ public:
* *
* @param pDialogId Unique dialog id to be painted * @param pDialogId Unique dialog id to be painted
* @param pBuffer Buffer with enough memory allocated to render any dialog * @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 nWidth output parameter returning the width of the rendered dialog.
* @param nHeight output parameter returning the height of the rendered dialog * @param nHeight output parameter returning the height of the rendered dialog
*/ */
void paintDialog(const char* pDialogId, void paintDialog(const char* pDialogId,
unsigned char* pBuffer, unsigned char* pBuffer,
char** pDialogTitle,
int& nWidth, int& nWidth,
int& nHeight) int& nHeight)
{ {
return mpDoc->pClass->paintDialog(mpDoc, pDialogId, pBuffer, return mpDoc->pClass->paintDialog(mpDoc, pDialogId, pBuffer,
&nWidth, &nHeight); pDialogTitle, &nWidth, &nHeight);
} }
/** /**

View File

@@ -29,7 +29,7 @@ public:
virtual ~IDialogRenderable(); virtual ~IDialogRenderable();
virtual void paintDialog(const DialogID& rDialogID, VirtualDevice &rDevice, 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, virtual void paintActiveFloatingWindow(const DialogID& rDialogID, VirtualDevice &rDevice,
int& nOutputWidth, int& nOutputHeight) = 0; int& nOutputWidth, int& nOutputHeight) = 0;

View File

@@ -87,14 +87,20 @@ gtv_lok_dialog_draw(GtkWidget* pDialogDrawingArea, cairo_t* pCairo, gpointer)
GtvLokDialog* pDialog = GTV_LOK_DIALOG(gtk_widget_get_toplevel(pDialogDrawingArea)); GtvLokDialog* pDialog = GTV_LOK_DIALOG(gtk_widget_get_toplevel(pDialogDrawingArea));
GtvLokDialogPrivate* priv = getPrivate(pDialog); GtvLokDialogPrivate* priv = getPrivate(pDialog);
g_info("panting dialog");
g_info("painting dialog");
int nWidth = 1024; int nWidth = 1024;
int nHeight = 768; int nHeight = 768;
cairo_surface_t* pSurface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, nWidth, nHeight); cairo_surface_t* pSurface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, nWidth, nHeight);
unsigned char* pBuffer = cairo_image_surface_get_data(pSurface); unsigned char* pBuffer = cairo_image_surface_get_data(pSurface);
LibreOfficeKitDocument* pDocument = lok_doc_view_get_document(LOK_DOC_VIEW(priv->lokdocview)); 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); gtk_widget_set_size_request(GTK_WIDGET(pDialogDrawingArea), nWidth, nHeight);
cairo_surface_flush(pSurface); cairo_surface_flush(pSurface);
@@ -472,7 +478,6 @@ gtv_lok_dialog_invalidate(GtvLokDialog* dialog)
{ {
GtvLokDialogPrivate* priv = getPrivate(dialog); GtvLokDialogPrivate* priv = getPrivate(dialog);
// trigger a draw on the dialog drawing area
gtk_widget_queue_draw(priv->pDialogDrawingArea); 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"); g_info("Dialog's floating window invalidate");
GtvLokDialogPrivate* priv = getPrivate(dialog); GtvLokDialogPrivate* priv = getPrivate(dialog);
// remove any existing floating windows, for now // create new if doesn't exist
if (!priv->pFloatingWin) if (!priv->pFloatingWin)
{ {
priv->pFloatingWin = gtk_window_new(GTK_WINDOW_POPUP); priv->pFloatingWin = gtk_window_new(GTK_WINDOW_POPUP);

View File

@@ -431,7 +431,7 @@ public:
/// @see vcl::ITiledRenderable::getPostIts(). /// @see vcl::ITiledRenderable::getPostIts().
OUString getPostIts() override; 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 paintActiveFloatingWindow(const vcl::DialogID& rDialogID, VirtualDevice& rDevice, int& nWidth, int& nHeight) override;
void postDialogKeyEvent(const vcl::DialogID& rDialogID, int nType, void postDialogKeyEvent(const vcl::DialogID& rDialogID, int nType,
int nCharCode, int nKeyCode) override; int nCharCode, int nKeyCode) override;

View File

@@ -3639,7 +3639,7 @@ void SAL_CALL SwXTextDocument::paintTile( const ::css::uno::Any& Parent, ::sal_I
#endif #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(); SfxViewFrame* pViewFrame = pDocShell->GetView()->GetViewFrame();
SfxSlotPool* pSlotPool = SW_MOD()->GetSlotPool(); 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 // register the instance so that vcl::Dialog can emit LOK callbacks
pDlg->registerDialogRenderable(this, rDialogID); pDlg->registerDialogRenderable(this, rDialogID);
pDlg->paintDialog(rDevice); pDlg->paintDialog(rDevice);
// set outparams
rDialogTitle = pDlg->GetText();
const Size aSize = pDlg->GetOptimalSize(); const Size aSize = pDlg->GetOptimalSize();
nWidth = aSize.getWidth(); nWidth = aSize.getWidth();
nHeight = aSize.getHeight(); nHeight = aSize.getHeight();