summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPranav Kant <pranavk@collabora.co.uk>2017-11-05 18:40:52 +0530
committerJan Holesovsky <kendy@collabora.com>2017-11-15 17:07:18 +0100
commit3bf083c40e8fcd543a7dbbb399cb3bd3f541edd8 (patch)
treec7146d0b67dc31a8d3b3cca7de818d73b5162725
parentf13dfb4c018080e94d8ed247984bf2f37e0653b8 (diff)
lokdialog: Move getting dialog information in separate LOK call
Using outparameters to get the dialog information with the paintDialog call was quite confusing. Change-Id: Ief331b251dc66e66084b827ce5b025ba6c9ce7d2 Reviewed-on: https://gerrit.libreoffice.org/44473 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: pranavk <pranavk@collabora.co.uk>
-rw-r--r--desktop/source/lib/init.cxx46
-rw-r--r--include/LibreOfficeKit/LibreOfficeKit.h10
-rw-r--r--include/LibreOfficeKit/LibreOfficeKit.hxx40
-rw-r--r--include/vcl/IDialogRenderable.hxx5
-rw-r--r--libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx6
-rw-r--r--sw/inc/unotxdoc.hxx3
-rw-r--r--sw/source/uibase/uno/unotxdoc.cxx24
7 files changed, 91 insertions, 43 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 55a9e18b27fa..8603a3232faa 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -631,7 +631,12 @@ 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, const int x, const int y, unsigned char* pBuffer, char** pDialogTitle, int* nWidth, int* nHeight);
+static void doc_paintDialog(LibreOfficeKitDocument* pThis, const char* pDialogId, unsigned char* pBuffer,
+ const int nX, const int nY,
+ const int nWidth, const int nHeight);
+
+static void doc_getDialogInfo(LibreOfficeKitDocument* pThis, const char* pDialogId,
+ char** pDialogTitle, int* nWidth, int* nHeight);
static void doc_paintActiveFloatingWindow(LibreOfficeKitDocument* pThis, const char* pDialogId, unsigned char* pBuffer, int* nWidth, int* nHeight);
@@ -685,6 +690,7 @@ 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;
@@ -3112,11 +3118,29 @@ unsigned char* doc_renderFont(LibreOfficeKitDocument* /*pThis*/,
return nullptr;
}
+static void doc_getDialogInfo(LibreOfficeKitDocument* pThis, const char* pDialogId,
+ char** pDialogTitle, int* nWidth, int* nHeight)
+{
+ SolarMutexGuard aGuard;
+
+ IDialogRenderable* pDialogRenderable = getDialogRenderable(pThis);
+ vcl::DialogID aDialogID = OUString::createFromAscii(pDialogId);
+ OUString aDialogTitle;
+ pDialogRenderable->getDialogInfo(aDialogID, aDialogTitle, *nWidth, *nHeight);
+
+ // 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, const char* pDialogId,
- const int x, const int y,
unsigned char* pBuffer,
- char** pDialogTitle,
- int* nWidth, int* nHeight)
+ const int nX, const int nY,
+ const int nWidth, const int nHeight)
{
SolarMutexGuard aGuard;
@@ -3125,24 +3149,16 @@ static void doc_paintDialog(LibreOfficeKitDocument* pThis, const char* pDialogId
ScopedVclPtrInstance<VirtualDevice> pDevice(nullptr, Size(1, 1), DeviceFormat::DEFAULT);
pDevice->SetBackground(Wallpaper(Color(COL_TRANSPARENT)));
- pDevice->SetOutputSizePixelScaleOffsetAndBuffer(Size(*nWidth, *nHeight), Fraction(1.0), Point(), pBuffer);
+ pDevice->SetOutputSizePixelScaleOffsetAndBuffer(Size(nWidth, nHeight), Fraction(1.0), Point(), pBuffer);
vcl::DialogID aDialogID = OUString::createFromAscii(pDialogId);
MapMode aMapMode(pDevice->GetMapMode());
- aMapMode.SetOrigin(Point(-x, -y));
+ aMapMode.SetOrigin(Point(-nX, -nY));
pDevice->SetMapMode(aMapMode);
comphelper::LibreOfficeKit::setDialogPainting(true);
- // 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());
- }
+ pDialogRenderable->paintDialog(aDialogID, *pDevice.get());
comphelper::LibreOfficeKit::setDialogPainting(false);
}
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index 3941b329a97d..792f5af9e4ab 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -255,10 +255,14 @@ struct _LibreOfficeKitDocumentClass
/// Paints dialog with given dialog id to the buffer
/// @see lok::Document::paintDialog().
void (*paintDialog) (LibreOfficeKitDocument* pThis, const char* pDialogId,
- const int x, const int y,
unsigned char* pBuffer,
- char** pDialogTitle,
- int* nWidth, int* nHeight);
+ 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, const char* pDialogId,
+ char** pDialogTitle, int* pWidth, int* pHeight);
/// @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 b029aa001ad1..d595b7f2dbf5 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -160,28 +160,38 @@ public:
* Client must truncate pBuffer according to the nWidth and nHeight returned after the call.
*
* @param pDialogId Unique dialog id to be painted
+ * @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 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 in/out parameter returning the width of the rendered
- * dialog. The input width value is used to determined the size of the
- * image to be painted.
- * @param nHeight in/out parameter returning the height of the rendered
- * dialog. The input height value is used to determine the size of the
- * image to be painted.
+ * @param width The width of the dialog image to be painted
+ * @param height The height of the dialog image to be painted
*/
void paintDialog(const char* pDialogId,
+ unsigned char* pBuffer,
const int x,
const int y,
- unsigned char* pBuffer,
- char** pDialogTitle,
- int& nWidth,
- int& nHeight)
+ const int width,
+ const int height)
+ {
+ return mpDoc->pClass->paintDialog(mpDoc, pDialogId, pBuffer,
+ x, y, width, height);
+ }
+
+ /* Get info about dialog with given dialog id
+ *
+ * @param pDialogId 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(const char* pDialogId,
+ char** pDialogTitle,
+ int& pWidth,
+ int& pHeight)
{
- return mpDoc->pClass->paintDialog(mpDoc, pDialogId, x, y, pBuffer,
- pDialogTitle, &nWidth, &nHeight);
+ return mpDoc->pClass->getDialogInfo(mpDoc, pDialogId, pDialogTitle, &pWidth, &pHeight);
+
}
/**
diff --git a/include/vcl/IDialogRenderable.hxx b/include/vcl/IDialogRenderable.hxx
index 94d8a1f4e9e7..357926b40446 100644
--- a/include/vcl/IDialogRenderable.hxx
+++ b/include/vcl/IDialogRenderable.hxx
@@ -30,8 +30,9 @@ class VCL_DLLPUBLIC IDialogRenderable
public:
virtual ~IDialogRenderable();
- virtual void paintDialog(const DialogID& rDialogID, VirtualDevice &rDevice,
- OUString& rDialogTitle, int& nOutputWidth, int& nOutputHeight) = 0;
+ virtual void paintDialog(const DialogID& rDialogID, VirtualDevice &rDevice) = 0;
+
+ virtual void getDialogInfo(const DialogID& rDialogID, OUString& rDialogTitle, int& rWidth, int& rHeight) = 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 2c9ae8b71003..8225d980c2c1 100644
--- a/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx
@@ -102,14 +102,16 @@ gtv_lok_dialog_draw(GtkWidget* pDialogDrawingArea, cairo_t* pCairo, gpointer)
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, aRect.x, aRect.y, pBuffer, &pDialogTitle, &nWidth, &nHeight);
+ 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);
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), outWidth, outHeight);
cairo_surface_flush(pSurface);
cairo_surface_mark_dirty(pSurface);
diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx
index bb6dc4d6dbc5..00b2887e60c6 100644
--- a/sw/inc/unotxdoc.hxx
+++ b/sw/inc/unotxdoc.hxx
@@ -452,7 +452,8 @@ public:
/// @see vcl::ITiledRenderable::getPostIts().
OUString getPostIts() override;
- void paintDialog(const vcl::DialogID& rDialogID, VirtualDevice& rDevice, OUString& rDialogTitle, int& nWidth, int& nHeight) override;
+ void paintDialog(const vcl::DialogID& rDialogID, VirtualDevice& rDevice) override;
+ void getDialogInfo(const vcl::DialogID& rDialogID, OUString& rDialogTitle, int& rWidth, int& rHeight) 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 ee9413b1231c..45e905646ed0 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -3711,7 +3711,7 @@ void SAL_CALL SwXTextDocument::paintTile( const ::css::uno::Any& Parent, ::sal_I
#endif
}
-void SwXTextDocument::paintDialog(const vcl::DialogID& rDialogID, VirtualDevice& rDevice, OUString& rDialogTitle, int& nWidth, int& nHeight)
+void SwXTextDocument::paintDialog(const vcl::DialogID& rDialogID, VirtualDevice& rDevice)
{
SfxViewFrame* pViewFrame = pDocShell->GetView()->GetViewFrame();
SfxSlotPool* pSlotPool = SW_MOD()->GetSlotPool();
@@ -3737,12 +3737,27 @@ 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);
+}
+
+void SwXTextDocument::getDialogInfo(const vcl::DialogID& rDialogID, OUString& rDialogTitle, int& rWidth, int& rHeight)
+{
+ SfxViewFrame* pViewFrame = pDocShell->GetView()->GetViewFrame();
+ SfxSlotPool* pSlotPool = SW_MOD()->GetSlotPool();
+ const SfxSlot* pSlot = pSlotPool->GetUnoSlot(rDialogID);
+ if (!pSlot)
+ {
+ SAL_WARN("lok.dialog", "No slot found for " << rDialogID);
+ return;
+ }
+ SfxChildWindow* pChild = pViewFrame->GetChildWindow(pSlot->GetSlotId());
+ if (!pChild)
+ return;
- // set outparams
+ Dialog* pDlg = static_cast<Dialog*>(pChild->GetWindow());
rDialogTitle = pDlg->GetText();
const Size aSize = pDlg->GetOptimalSize();
- nWidth = aSize.getWidth();
- nHeight = aSize.getHeight();
+ rWidth = aSize.getWidth();
+ rHeight = aSize.getHeight();
}
void SwXTextDocument::postDialogKeyEvent(const vcl::DialogID& rDialogID, int nType, int nCharCode, int nKeyCode)
@@ -3883,7 +3898,6 @@ void SwXTextDocument::paintActiveFloatingWindow(const vcl::DialogID& rDialogID,
return;
Dialog* pDlg = static_cast<Dialog*>(pChild->GetWindow());
- // register the instance so that vcl::Dialog can emit LOK callbacks
const Size aSize = pDlg->PaintActiveFloatingWindow(rDevice);
nWidth = aSize.getWidth();
nHeight = aSize.getHeight();