summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--desktop/source/lib/init.cxx27
-rw-r--r--include/LibreOfficeKit/LibreOfficeKit.h7
-rw-r--r--include/LibreOfficeKit/LibreOfficeKit.hxx20
-rw-r--r--include/LibreOfficeKit/LibreOfficeKitEnums.h6
-rw-r--r--libreofficekit/qa/gtktiledviewer/gtv-application-window.cxx6
-rw-r--r--libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx2
6 files changed, 56 insertions, 12 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 1c4922eacacf..02790af6b2f4 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -613,12 +613,14 @@ static unsigned char* doc_renderFont(LibreOfficeKitDocument* pThis,
int* pFontHeight);
static char* doc_getPartHash(LibreOfficeKitDocument* pThis, int nPart);
-static void doc_paintDialog(LibreOfficeKitDocument* pThis, unsigned nLOKWindowId, unsigned char* pBuffer,
+static void doc_paintWindow(LibreOfficeKitDocument* pThis, unsigned nLOKWindowId, unsigned char* pBuffer,
const int nX, const int nY,
const int nWidth, const int nHeight);
static void doc_paintActiveFloatingWindow(LibreOfficeKitDocument* pThis, unsigned nLOKWindowId, unsigned char* pBuffer, int* nWidth, int* nHeight);
+static void doc_postWindow(LibreOfficeKitDocument* pThis, unsigned nLOKWindowId, int nAction);
+
LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XComponent> &xComponent)
: mxComponent(xComponent)
{
@@ -669,8 +671,9 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XCompone
m_pDocumentClass->renderFont = doc_renderFont;
m_pDocumentClass->getPartHash = doc_getPartHash;
- m_pDocumentClass->paintDialog = doc_paintDialog;
+ m_pDocumentClass->paintWindow = doc_paintWindow;
m_pDocumentClass->paintActiveFloatingWindow = doc_paintActiveFloatingWindow;
+ m_pDocumentClass->postWindow = doc_postWindow;
gDocumentClass = m_pDocumentClass;
}
@@ -3283,7 +3286,7 @@ unsigned char* doc_renderFont(SAL_UNUSED_PARAMETER LibreOfficeKitDocument* /*pTh
return nullptr;
}
-static void doc_paintDialog(LibreOfficeKitDocument* /*pThis*/, unsigned nLOKWindowId,
+static void doc_paintWindow(LibreOfficeKitDocument* /*pThis*/, unsigned nLOKWindowId,
unsigned char* pBuffer,
const int nX, const int nY,
const int nWidth, const int nHeight)
@@ -3334,6 +3337,24 @@ static void doc_paintActiveFloatingWindow(LibreOfficeKitDocument* /*pThis*/, uns
comphelper::LibreOfficeKit::setDialogPainting(false);
}
+static void doc_postWindow(LibreOfficeKitDocument* /*pThis*/, unsigned nLOKWindowId, int nAction)
+{
+ SolarMutexGuard aGuard;
+
+ VclPtr<Window> pWindow = vcl::Window::FindLOKWindow(nLOKWindowId);
+ if (!pWindow)
+ {
+ gImpl->maLastExceptionMsg = "Document doesn't support dialog rendering, or window not found.";
+ return;
+ }
+
+ if (Dialog* pDialog = dynamic_cast<Dialog*>(pWindow.get()))
+ {
+ if (nAction == LOK_WINDOW_CLOSE)
+ pDialog->EndDialog( RET_CANCEL );
+ }
+}
+
static char* lo_getError (LibreOfficeKit *pThis)
{
SolarMutexGuard aGuard;
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index 68b5f7338032..350dd03dbc5f 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -271,8 +271,8 @@ struct _LibreOfficeKitDocumentClass
size_t nSize);
/// Paints dialog with given dialog id to the buffer
- /// @see lok::Document::paintDialog().
- void (*paintDialog) (LibreOfficeKitDocument* pThis, unsigned nDialogId,
+ /// @see lok::Document::paintWindow().
+ void (*paintWindow) (LibreOfficeKitDocument* pThis, unsigned nWindowId,
unsigned char* pBuffer,
const int x, const int y,
const int width, const int height);
@@ -280,6 +280,9 @@ struct _LibreOfficeKitDocumentClass
/// @see lok::Document::paintActiveFloatingWindow().
void (*paintActiveFloatingWindow) (LibreOfficeKitDocument* pThis, unsigned nDialogId, unsigned char* pBuffer, int* nWidth, int* nHeight);
+ /// @see lok::Document::postWindow().
+ void (*postWindow) (LibreOfficeKitDocument* pThis, unsigned nWindowId, int nAction);
+
/// @see lok::Document::postDialogKeyEvent().
void (*postDialogKeyEvent) (LibreOfficeKitDocument* pThis,
unsigned nDialogId,
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx
index 2b3d26bb0778..3c1d27b48d49 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -156,25 +156,23 @@ public:
}
/**
- * Renders a dialog with give dialog id and writes the width and height of the rendered dialog
+ * Renders a window (dialog, popup, etc.) with give id
*
- * Client must truncate pBuffer according to the nWidth and nHeight returned after the call.
- *
- * @param nDialogId Unique dialog id to be painted
+ * @param nWindowId
* @param pBuffer Buffer with enough memory allocated to render any dialog
* @param x x-coordinate from where the dialog should start painting
* @param y y-coordinate from where the dialog should start painting
* @param width The width of the dialog image to be painted
* @param height The height of the dialog image to be painted
*/
- void paintDialog(unsigned nDialogId,
+ void paintWindow(unsigned nWindowId,
unsigned char* pBuffer,
const int x,
const int y,
const int width,
const int height)
{
- return mpDoc->pClass->paintDialog(mpDoc, nDialogId, pBuffer,
+ return mpDoc->pClass->paintWindow(mpDoc, nWindowId, pBuffer,
x, y, width, height);
}
@@ -198,6 +196,16 @@ public:
}
/**
+ * Posts a command to the window (dialog, popup, etc.) with given id
+ *
+ * @param nWindowid
+ */
+ void postWindow(unsigned nWindowId, int nAction)
+ {
+ return mpDoc->pClass->postWindow(mpDoc, nWindowId, nAction);
+ }
+
+ /**
* Gets the tile mode: the pixel format used for the pBuffer of paintTile().
*
* @return an element of the LibreOfficeKitTileMode enum.
diff --git a/include/LibreOfficeKit/LibreOfficeKitEnums.h b/include/LibreOfficeKit/LibreOfficeKitEnums.h
index 62b9faf7ecb4..facbd351633d 100644
--- a/include/LibreOfficeKit/LibreOfficeKitEnums.h
+++ b/include/LibreOfficeKit/LibreOfficeKitEnums.h
@@ -40,6 +40,12 @@ typedef enum
}
LibreOfficeKitTileMode;
+typedef enum
+{
+ LOK_WINDOW_CLOSE
+}
+LibreOfficeKitWindowAction;
+
/** Optional features of LibreOfficeKit, in particular callbacks that block
* LibreOfficeKit until the corresponding reply is received, which would
* deadlock if the client does not support the feature.
diff --git a/libreofficekit/qa/gtktiledviewer/gtv-application-window.cxx b/libreofficekit/qa/gtktiledviewer/gtv-application-window.cxx
index 118be6c0100d..e5b67d18c57c 100644
--- a/libreofficekit/qa/gtktiledviewer/gtv-application-window.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtv-application-window.cxx
@@ -412,7 +412,13 @@ gtv_application_window_unregister_child_window(GtvApplicationWindow* window, Gtk
{
GtvApplicationWindowPrivate* priv = getPrivate(window);
if (pChildWin)
+ {
priv->m_pChildWindows = g_list_remove(priv->m_pChildWindows, pChildWin);
+ LibreOfficeKitDocument* pDocument = lok_doc_view_get_document(LOK_DOC_VIEW(window->lokdocview));
+ guint dialogId = 0;
+ g_object_get(G_OBJECT(pChildWin), "dialogid", &dialogId, nullptr);
+ pDocument->pClass->postWindow(pDocument, dialogId, LOK_WINDOW_CLOSE);
+ }
}
GtkWindow*
diff --git a/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx b/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx
index 9cad1e8fb117..bb206acb109e 100644
--- a/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx
@@ -106,7 +106,7 @@ gtv_lok_dialog_draw(GtkWidget* pDialogDrawingArea, cairo_t* pCairo, gpointer)
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, aRect.x, aRect.y, nWidth, nHeight);
+ pDocument->pClass->paintWindow(pDocument, priv->dialogid, pBuffer, aRect.x, aRect.y, nWidth, nHeight);
gtk_widget_set_size_request(GTK_WIDGET(pDialogDrawingArea), priv->m_nWidth, priv->m_nHeight);