summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPranav Kant <pranavk@collabora.co.uk>2017-11-28 02:53:48 +0530
committerJan Holesovsky <kendy@collabora.com>2017-11-28 19:49:30 +0100
commit880239709c1fcf24e96c4e7b3989e7b8b321c052 (patch)
treeda9909612512452af809f1e5f60b922996eb1aeb
parentf2fad6dcc1404e8358e348a91a06f5c7e9369384 (diff)
lokdialog: Remove getDialogInfo + update gtktiledviewer accordingly.
Change-Id: I6f810c97f2fadd3b1ea602a97e24c8b42f4a84b9
-rw-r--r--desktop/source/lib/init.cxx33
-rw-r--r--include/LibreOfficeKit/LibreOfficeKit.h5
-rw-r--r--include/LibreOfficeKit/LibreOfficeKit.hxx17
-rw-r--r--libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx17
-rw-r--r--libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx23
5 files changed, 28 insertions, 67 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 8d61d405f501..4810f9b59039 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -635,9 +635,6 @@ static void doc_paintDialog(LibreOfficeKitDocument* pThis, unsigned nLOKWindowId
const int nX, const int nY,
const int nWidth, const int nHeight);
-static void doc_getDialogInfo(LibreOfficeKitDocument* pThis, unsigned nLOKWindowId,
- char** pDialogTitle, int* nWidth, int* nHeight);
-
static void doc_paintActiveFloatingWindow(LibreOfficeKitDocument* pThis, unsigned nLOKWindowId, unsigned char* pBuffer, int* nWidth, int* nHeight);
LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XComponent> &xComponent)
@@ -690,7 +687,6 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XCompone
m_pDocumentClass->getPartHash = doc_getPartHash;
m_pDocumentClass->paintDialog = doc_paintDialog;
- m_pDocumentClass->getDialogInfo = doc_getDialogInfo;
m_pDocumentClass->paintActiveFloatingWindow = doc_paintActiveFloatingWindow;
gDocumentClass = m_pDocumentClass;
@@ -3287,35 +3283,6 @@ unsigned char* doc_renderFont(LibreOfficeKitDocument* /*pThis*/,
return nullptr;
}
-static void doc_getDialogInfo(LibreOfficeKitDocument* pThis, unsigned nLOKWindowId,
- char** pDialogTitle, int* nWidth, int* nHeight)
-{
- // FIXME - I guess we should kill this one, and use only the callback
- // "created"?
-
- SolarMutexGuard aGuard;
-
- VclPtr<Window> pWindow = vcl::Window::FindLOKWindow(nLOKWindowId);
- if (!pWindow)
- {
- gImpl->maLastExceptionMsg = "Document doesn't support dialog rendering, or window not found.";
- return;
- }
-
- OUString aDialogTitle(pWindow->GetText());
- const Size aSize = pWindow->GetSizePixel();
- *nWidth = aSize.getWidth();
- *nHeight = aSize.getHeight();
-
- // copy dialog title
- if (!aDialogTitle.isEmpty())
- {
- OString aTitleString = OUStringToOString(aDialogTitle, RTL_TEXTENCODING_UTF8);
- *pDialogTitle = static_cast<char*>(malloc(aTitleString.getLength() + 1));
- strcpy(*pDialogTitle, aTitleString.getStr());
- }
-}
-
static void doc_paintDialog(LibreOfficeKitDocument* pThis, unsigned nLOKWindowId,
unsigned char* pBuffer,
const int nX, const int nY,
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index 4bd48c9b1756..355c44579933 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -262,11 +262,6 @@ struct _LibreOfficeKitDocumentClass
const int x, const int y,
const int width, const int height);
- /// Get info about dialog with given dialog id
- /// @see lok::Document::getDialogInfo().
- void (*getDialogInfo) (LibreOfficeKitDocument* pThis, unsigned nDialogId,
- char** pDialogTitle, int* pWidth, int* pHeight);
-
/// @see lok::Document::paintActiveFloatingWindow().
void (*paintActiveFloatingWindow) (LibreOfficeKitDocument* pThis, unsigned nDialogId, unsigned char* pBuffer, int* nWidth, int* nHeight);
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx
index dc623261036a..08fbcf857abc 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -177,23 +177,6 @@ public:
x, y, width, height);
}
- /* Get info about dialog with given dialog id
- *
- * @param nDialogId Unique dialog id for which to get info about
- * @param pDialogTitle Pointer to pointer pointing to string containing the
- * dialog title. Caller should the pointer to allocated string themselves.
- * @param pWidth The width of the dialog
- * @param pHeight The height of the dialog
- */
- void getDialogInfo(unsigned nDialogId,
- char** pDialogTitle,
- int& pWidth,
- int& pHeight)
- {
- return mpDoc->pClass->getDialogInfo(mpDoc, nDialogId, pDialogTitle, &pWidth, &pHeight);
-
- }
-
/**
* Renders the active floating window of a dialog
*
diff --git a/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx b/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx
index d95e417d89c6..8d757b4dde45 100644
--- a/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx
@@ -94,9 +94,9 @@ gtv_lok_dialog_draw(GtkWidget* pDialogDrawingArea, cairo_t* pCairo, gpointer)
GdkRectangle aRect;
gdk_cairo_get_clip_rectangle(pCairo, &aRect);
g_info("Painting dialog region: %d, %d, %d, %d", aRect.x, aRect.y, aRect.width, aRect.height);
+
int nWidth = priv->m_nWidth;
int nHeight = priv->m_nHeight;
- g_info("canvas width: %d and height %d", nWidth, nHeight);
if (aRect.width != 0 && aRect.height != 0)
{
nWidth = aRect.width;
@@ -106,18 +106,9 @@ 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));
- char* pDialogTitle = nullptr;
pDocument->pClass->paintDialog(pDocument, priv->dialogid, pBuffer, aRect.x, aRect.y, nWidth, nHeight);
- int outWidth = 0, outHeight = 0;
- pDocument->pClass->getDialogInfo(pDocument, priv->dialogid, &pDialogTitle, &outWidth, &outHeight);
- g_debug("getDialogInfo: width: %d, height: %d", outWidth, outHeight);
- if (pDialogTitle)
- {
- gtk_window_set_title(GTK_WINDOW(pDialog), pDialogTitle);
- free(pDialogTitle);
- }
- gtk_widget_set_size_request(GTK_WIDGET(pDialogDrawingArea), outWidth, outHeight);
+ gtk_widget_set_size_request(GTK_WIDGET(pDialogDrawingArea), priv->m_nWidth, priv->m_nHeight);
cairo_surface_flush(pSurface);
cairo_surface_mark_dirty(pSurface);
@@ -411,6 +402,9 @@ gtv_lok_dialog_set_property(GObject* object, guint propId, const GValue* value,
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, propId, pspec);
}
+
+ //if (propId == PROP_DIALOG_WIDTH || propId == PROP_DIALOG_HEIGHT)
+ // gtk_widget_set_size_request(GTK_WIDGET(priv->pDialogDrawingArea), priv->m_nWidth, priv->m_nHeight);
}
static void
@@ -692,6 +686,7 @@ void gtv_lok_dialog_child_close(GtvLokDialog* dialog)
GtkWidget*
gtv_lok_dialog_new(LOKDocView* pDocView, guint dialogId, guint width, guint height)
{
+ g_debug("Dialog [ %d ] of size: %d x %d created", dialogId, width, height);
GtkWindow* pWindow = GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(pDocView)));
return GTK_WIDGET(g_object_new(GTV_TYPE_LOK_DIALOG,
"lokdocview", pDocView,
diff --git a/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx b/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx
index 904662bbf718..cb46e777d598 100644
--- a/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx
@@ -331,14 +331,35 @@ void LOKDocViewSigHandlers::dialog(LOKDocView* pDocView, gchar* pPayload, gpoint
GList* pChildWins = gtv_application_window_get_all_child_windows(window);
GList* pIt = nullptr;
- for (pIt = pChildWins; pIt != nullptr; pIt = pIt->next)
+ bool found = false;
+ for (pIt = pChildWins; !found && pIt != nullptr; pIt = pIt->next)
{
guint nChildDialogId = 0;
g_object_get(pIt->data, "dialogid", &nChildDialogId, nullptr);
if (nDialogId == nChildDialogId)
{
+ found = true;
+
if (aAction == "close")
gtk_widget_destroy(GTK_WIDGET(pIt->data));
+ else if (aAction == "size_changed")
+ {
+ const std::string aSize = aRoot.get<std::string>("size");
+ std::vector<int> aSizePoints = GtvHelpers::splitIntoIntegers(aSize, ", ", 2);
+ if (aSizePoints.size() != 2)
+ {
+ g_error("Malformed size_changed callback");
+ break;
+ }
+
+ g_object_set(G_OBJECT(pIt->data),
+ "width", aSizePoints[0],
+ "height", aSizePoints[1],
+ nullptr);
+
+ GdkRectangle aGdkRectangle = {0, 0, 0, 0};
+ gtv_lok_dialog_invalidate(GTV_LOK_DIALOG(pIt->data), aGdkRectangle);
+ }
else if (aAction == "invalidate")
{
GdkRectangle aGdkRectangle = {0, 0, 0, 0};