summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPranav Kant <pranavk@collabora.co.uk>2017-11-24 01:20:56 +0530
committerJan Holesovsky <kendy@collabora.com>2017-11-29 10:16:53 +0100
commitf3f4c039072657739d2bedb7210f2a22b85fdb55 (patch)
tree62c9bb21bee0ac5e497416be7e3b4ba00866aa85
parent2798e1aae5311094c30d8e667c1e8be4e4314f8d (diff)
lokdialog: Make vcl::DialogID an integer
This will help launching multiple instances of dialog from multiple views. The earlier approach of using the UNO command strings as dialog id would not have been useful for multi-view case. Change-Id: I01cfb3c8b204d5654df2417efdac6b50dc920f0e
-rw-r--r--desktop/source/lib/init.cxx64
-rw-r--r--include/LibreOfficeKit/LibreOfficeKit.h12
-rw-r--r--include/LibreOfficeKit/LibreOfficeKit.hxx36
-rw-r--r--include/sfx2/lokhelper.hxx4
-rw-r--r--include/sfx2/viewsh.hxx10
-rw-r--r--include/vcl/IDialogRenderable.hxx2
-rw-r--r--include/vcl/dialog.hxx6
-rw-r--r--libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx56
-rw-r--r--libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.hxx2
-rw-r--r--libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx26
-rw-r--r--sfx2/source/view/lokhelper.cxx12
-rw-r--r--sfx2/source/view/viewsh.cxx27
-rw-r--r--vcl/source/window/dialog.cxx13
13 files changed, 125 insertions, 145 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 5d0e39c419cc..b40ff1a609e4 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -544,7 +544,7 @@ static void doc_postKeyEvent(LibreOfficeKitDocument* pThis,
int nCharCode,
int nKeyCode);
static void doc_postDialogKeyEvent(LibreOfficeKitDocument* pThis,
- const char* pDialogId,
+ unsigned nDialogId,
int nType,
int nCharCode,
int nKeyCode);
@@ -556,7 +556,7 @@ static void doc_postMouseEvent (LibreOfficeKitDocument* pThis,
int nButtons,
int nModifier);
static void doc_postDialogMouseEvent (LibreOfficeKitDocument* pThis,
- const char* pDialogId,
+ unsigned nDialogId,
int nType,
int nX,
int nY,
@@ -564,7 +564,7 @@ static void doc_postDialogMouseEvent (LibreOfficeKitDocument* pThis,
int nButtons,
int nModifier);
static void doc_postDialogChildMouseEvent (LibreOfficeKitDocument* pThis,
- const char* pDialogId,
+ unsigned nDialogId,
int nType,
int nX,
int nY,
@@ -611,14 +611,14 @@ 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,
+static void doc_paintDialog(LibreOfficeKitDocument* pThis, unsigned nDialogId, unsigned char* pBuffer,
const int nX, const int nY,
const int nWidth, const int nHeight);
-static void doc_getDialogInfo(LibreOfficeKitDocument* pThis, const char* pDialogId,
+static void doc_getDialogInfo(LibreOfficeKitDocument* pThis, unsigned nDialogId,
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, unsigned nDialogId, unsigned char* pBuffer, int* nWidth, int* nHeight);
LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XComponent> &xComponent)
: mxComponent(xComponent)
@@ -1029,7 +1029,7 @@ void CallbackFlushHandler::queue(const int type, const char* data)
boost::property_tree::ptree aTree;
std::stringstream aStream(payload);
boost::property_tree::read_json(aStream, aTree);
- const std::string aDialogId = aTree.get<std::string>("dialogId", "");
+ const unsigned nDialogId = aTree.get<unsigned>("dialogId", 0);
if (aTree.get<std::string>("action", "") == "invalidate")
{
std::string aRectStr = aTree.get<std::string>("rectangle", "");
@@ -1037,15 +1037,15 @@ void CallbackFlushHandler::queue(const int type, const char* data)
// remove all previous dialog part invalidations
if (aRectStr.empty())
{
- removeAll([&aDialogId] (const queue_type::value_type& elem) {
+ removeAll([&nDialogId] (const queue_type::value_type& elem) {
if (elem.first == LOK_CALLBACK_DIALOG)
{
boost::property_tree::ptree aOldTree;
std::stringstream aOldStream(elem.second);
boost::property_tree::read_json(aOldStream, aOldTree);
- const std::string aOldDialogId = aOldTree.get<std::string>("dialogId", "");
+ const unsigned nOldDialogId = aOldTree.get<unsigned>("dialogId", 0);
if (aOldTree.get<std::string>("action", "") == "invalidate" &&
- aDialogId == aOldDialogId)
+ nDialogId == nOldDialogId)
{
return true;
}
@@ -1058,7 +1058,7 @@ void CallbackFlushHandler::queue(const int type, const char* data)
// if we have to invalidate all of the dialog, ignore
// any part invalidation message
const auto& pos = std::find_if(m_queue.rbegin(), m_queue.rend(),
- [&aDialogId] (const queue_type::value_type& elem)
+ [&nDialogId] (const queue_type::value_type& elem)
{
if (elem.first != LOK_CALLBACK_DIALOG)
return false;
@@ -1066,9 +1066,9 @@ void CallbackFlushHandler::queue(const int type, const char* data)
boost::property_tree::ptree aOldTree;
std::stringstream aOldStream(elem.second);
boost::property_tree::read_json(aOldStream, aOldTree);
- const std::string aOldDialogId = aOldTree.get<std::string>("dialogId", "");
+ const unsigned nOldDialogId = aOldTree.get<unsigned>("dialogId", 0);
if (aOldTree.get<std::string>("action", "") == "invalidate" &&
- aDialogId == aOldDialogId &&
+ nDialogId == nOldDialogId &&
aOldTree.get<std::string>("rectangle", "").empty())
{
return true;
@@ -1089,7 +1089,7 @@ void CallbackFlushHandler::queue(const int type, const char* data)
aRectStream >> nLeft >> nComma >> nTop >> nComma >> nWidth >> nComma >> nHeight;
tools::Rectangle aNewRect = tools::Rectangle(nLeft, nTop, nLeft + nWidth, nTop + nHeight);
bool currentIsRedundant = false;
- removeAll([&aNewRect, &aDialogId, &currentIsRedundant] (const queue_type::value_type& elem) {
+ removeAll([&aNewRect, &nDialogId, &currentIsRedundant] (const queue_type::value_type& elem) {
if (elem.first != LOK_CALLBACK_DIALOG)
return false;
@@ -1098,7 +1098,7 @@ void CallbackFlushHandler::queue(const int type, const char* data)
boost::property_tree::read_json(aOldStream, aOldTree);
if (aOldTree.get<std::string>("action", "") == "invalidate")
{
- const std::string aOldDialogId = aOldTree.get<std::string>("dialogId", "");
+ const unsigned nOldDialogId = aOldTree.get<unsigned>("dialogId", 0);
std::string aOldRectStr = aOldTree.get<std::string>("rectangle", "");
// not possible that we encounter an empty
// rectangle here; we already handled this
@@ -1109,7 +1109,7 @@ void CallbackFlushHandler::queue(const int type, const char* data)
aOldRectStream >> nOldLeft >> nOldComma >> nOldTop >> nOldComma >> nOldWidth >> nOldComma >> nOldHeight;
tools::Rectangle aOldRect = tools::Rectangle(nOldLeft, nOldTop, nOldLeft + nOldWidth, nOldTop + nOldHeight);
- if (aDialogId == aOldDialogId)
+ if (nDialogId == nOldDialogId)
{
// new one engulfs the old one?
if (aNewRect.IsInside(aOldRect))
@@ -2257,7 +2257,7 @@ static void doc_postKeyEvent(LibreOfficeKitDocument* pThis, int nType, int nChar
pDoc->postKeyEvent(nType, nCharCode, nKeyCode);
}
-static void doc_postDialogKeyEvent(LibreOfficeKitDocument* pThis, const char* pDialogId, int nType, int nCharCode, int nKeyCode)
+static void doc_postDialogKeyEvent(LibreOfficeKitDocument* pThis, unsigned nDialogId, int nType, int nCharCode, int nKeyCode)
{
SolarMutexGuard aGuard;
@@ -2268,8 +2268,7 @@ static void doc_postDialogKeyEvent(LibreOfficeKitDocument* pThis, const char* pD
return;
}
- vcl::DialogID aDialogID = OUString::createFromAscii(pDialogId);
- pDoc->postDialogKeyEvent(aDialogID, nType, nCharCode, nKeyCode);
+ pDoc->postDialogKeyEvent(nDialogId, nType, nCharCode, nKeyCode);
}
/** Class to react on finishing of a dispatched command.
@@ -2423,7 +2422,7 @@ static void doc_postMouseEvent(LibreOfficeKitDocument* pThis, int nType, int nX,
}
}
-static void doc_postDialogMouseEvent(LibreOfficeKitDocument* pThis, const char* pDialogId, int nType, int nX, int nY, int nCount, int nButtons, int nModifier)
+static void doc_postDialogMouseEvent(LibreOfficeKitDocument* pThis, unsigned nDialogId, int nType, int nX, int nY, int nCount, int nButtons, int nModifier)
{
SolarMutexGuard aGuard;
@@ -2434,11 +2433,10 @@ static void doc_postDialogMouseEvent(LibreOfficeKitDocument* pThis, const char*
return;
}
- vcl::DialogID aDialogID = OUString::createFromAscii(pDialogId);
- pDoc->postDialogMouseEvent(aDialogID, nType, nX, nY, nCount, nButtons, nModifier);
+ pDoc->postDialogMouseEvent(nDialogId, nType, nX, nY, nCount, nButtons, nModifier);
}
-static void doc_postDialogChildMouseEvent(LibreOfficeKitDocument* pThis, const char* pDialogId, int nType, int nX, int nY, int nCount, int nButtons, int nModifier)
+static void doc_postDialogChildMouseEvent(LibreOfficeKitDocument* pThis, unsigned nDialogId, int nType, int nX, int nY, int nCount, int nButtons, int nModifier)
{
SolarMutexGuard aGuard;
@@ -2449,8 +2447,7 @@ static void doc_postDialogChildMouseEvent(LibreOfficeKitDocument* pThis, const c
return;
}
- vcl::DialogID aDialogID = OUString::createFromAscii(pDialogId);
- pDoc->postDialogChildMouseEvent(aDialogID, nType, nX, nY, nCount, nButtons, nModifier);
+ pDoc->postDialogChildMouseEvent(nDialogId, nType, nX, nY, nCount, nButtons, nModifier);
}
static void doc_setTextSelection(LibreOfficeKitDocument* pThis, int nType, int nX, int nY)
@@ -3229,15 +3226,14 @@ unsigned char* doc_renderFont(SAL_UNUSED_PARAMETER LibreOfficeKitDocument* /*pTh
return nullptr;
}
-static void doc_getDialogInfo(LibreOfficeKitDocument* pThis, const char* pDialogId,
+static void doc_getDialogInfo(LibreOfficeKitDocument* pThis, unsigned nDialogId,
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);
+ pDialogRenderable->getDialogInfo(nDialogId, aDialogTitle, *nWidth, *nHeight);
// copy dialog title
if (!aDialogTitle.isEmpty())
@@ -3248,7 +3244,7 @@ static void doc_getDialogInfo(LibreOfficeKitDocument* pThis, const char* pDialog
}
}
-static void doc_paintDialog(LibreOfficeKitDocument* pThis, const char* pDialogId,
+static void doc_paintDialog(LibreOfficeKitDocument* pThis, unsigned nDialogId,
unsigned char* pBuffer,
const int nX, const int nY,
const int nWidth, const int nHeight)
@@ -3262,18 +3258,16 @@ static void doc_paintDialog(LibreOfficeKitDocument* pThis, const char* pDialogId
pDevice->SetOutputSizePixelScaleOffsetAndBuffer(Size(nWidth, nHeight), Fraction(1.0), Point(), pBuffer);
- vcl::DialogID aDialogID = OUString::createFromAscii(pDialogId);
-
MapMode aMapMode(pDevice->GetMapMode());
aMapMode.SetOrigin(Point(-nX, -nY));
pDevice->SetMapMode(aMapMode);
comphelper::LibreOfficeKit::setDialogPainting(true);
- pDialogRenderable->paintDialog(aDialogID, *pDevice.get());
+ pDialogRenderable->paintDialog(nDialogId, *pDevice.get());
comphelper::LibreOfficeKit::setDialogPainting(false);
}
-static void doc_paintActiveFloatingWindow(LibreOfficeKitDocument* pThis, const char* pDialogId, unsigned char* pBuffer, int* nWidth, int* nHeight)
+static void doc_paintActiveFloatingWindow(LibreOfficeKitDocument* pThis, unsigned nDialogId, unsigned char* pBuffer, int* nWidth, int* nHeight)
{
SolarMutexGuard aGuard;
@@ -3284,10 +3278,8 @@ static void doc_paintActiveFloatingWindow(LibreOfficeKitDocument* pThis, const c
pDevice->SetOutputSizePixelScaleOffsetAndBuffer(Size(*nWidth, *nHeight), Fraction(1.0), Point(), pBuffer);
- vcl::DialogID aDialogID = OUString::createFromAscii(pDialogId);
-
comphelper::LibreOfficeKit::setDialogPainting(true);
- pDialogRenderable->paintActiveFloatingWindow(aDialogID, *pDevice.get(), *nWidth, *nHeight);
+ pDialogRenderable->paintActiveFloatingWindow(nDialogId, *pDevice.get(), *nWidth, *nHeight);
comphelper::LibreOfficeKit::setDialogPainting(false);
}
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index 14824821cfd7..071da712703e 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -268,29 +268,29 @@ struct _LibreOfficeKitDocumentClass
/// Paints dialog with given dialog id to the buffer
/// @see lok::Document::paintDialog().
- void (*paintDialog) (LibreOfficeKitDocument* pThis, const char* pDialogId,
+ void (*paintDialog) (LibreOfficeKitDocument* pThis, unsigned nDialogId,
unsigned char* pBuffer,
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,
+ void (*getDialogInfo) (LibreOfficeKitDocument* pThis, unsigned nDialogId,
char** pDialogTitle, int* pWidth, int* pHeight);
/// @see lok::Document::paintActiveFloatingWindow().
- void (*paintActiveFloatingWindow) (LibreOfficeKitDocument* pThis, const char* pDialogId, unsigned char* pBuffer, int* nWidth, int* nHeight);
+ void (*paintActiveFloatingWindow) (LibreOfficeKitDocument* pThis, unsigned nDialogId, unsigned char* pBuffer, int* nWidth, int* nHeight);
/// @see lok::Document::postDialogKeyEvent().
void (*postDialogKeyEvent) (LibreOfficeKitDocument* pThis,
- const char* pDialogId,
+ unsigned nDialogId,
int nType,
int nCharCode,
int nKeyCode);
/// @see lok::Document::postDialogMouseEvent().
void (*postDialogMouseEvent) (LibreOfficeKitDocument* pThis,
- const char* pDialogId,
+ unsigned nDialogId,
int nType,
int nX,
int nY,
@@ -300,7 +300,7 @@ struct _LibreOfficeKitDocumentClass
/// @see lok::Document::postDialogChildMouseEvent().
void (*postDialogChildMouseEvent) (LibreOfficeKitDocument* pThis,
- const char* pDialogId,
+ unsigned nDialogId,
int nType,
int nX,
int nY,
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx
index 19e121fe6573..c99b425daff6 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -160,38 +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 nDialogId 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 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,
+ void paintDialog(unsigned nDialogId,
unsigned char* pBuffer,
const int x,
const int y,
const int width,
const int height)
{
- return mpDoc->pClass->paintDialog(mpDoc, pDialogId, pBuffer,
+ return mpDoc->pClass->paintDialog(mpDoc, nDialogId, 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 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(const char* pDialogId,
+ void getDialogInfo(unsigned nDialogId,
char** pDialogTitle,
int& pWidth,
int& pHeight)
{
- return mpDoc->pClass->getDialogInfo(mpDoc, pDialogId, pDialogTitle, &pWidth, &pHeight);
+ return mpDoc->pClass->getDialogInfo(mpDoc, nDialogId, pDialogTitle, &pWidth, &pHeight);
}
@@ -200,17 +200,17 @@ public:
*
* Client must truncate pBuffer according to the nWidth and nHeight returned after the call.
*
- * @param pDialogId Unique dialog id
+ * @param nDialogId Unique dialog id
* @param pBuffer Buffer with enough memory allocated to render any dialog
* @param nWidth output parameter returning the width of the rendered dialog.
* @param nHeight output parameter returning the height of the rendered dialog
*/
- void paintActiveFloatingWindow(const char* pDialogId,
+ void paintActiveFloatingWindow(unsigned nDialogId,
unsigned char* pBuffer,
int& nWidth,
int& nHeight)
{
- return mpDoc->pClass->paintActiveFloatingWindow(mpDoc, pDialogId, pBuffer,
+ return mpDoc->pClass->paintActiveFloatingWindow(mpDoc, nDialogId, pBuffer,
&nWidth, &nHeight);
}
@@ -282,14 +282,14 @@ public:
/**
* Posts a keyboard event to the dialog
*
- * @param pDialogId Dialog id on which key event should be posted
+ * @param nDialogId Dialog id on which key event should be posted
* @param nType Event type, like press or release.
* @param nCharCode contains the Unicode character generated by this event or 0
* @param nKeyCode contains the integer code representing the key of the event (non-zero for control keys)
*/
- void postDialogKeyEvent(const char* pDialogId, int nType, int nCharCode, int nKeyCode)
+ void postDialogKeyEvent(unsigned nDialogId, int nType, int nCharCode, int nKeyCode)
{
- mpDoc->pClass->postDialogKeyEvent(mpDoc, pDialogId, nType, nCharCode, nKeyCode);
+ mpDoc->pClass->postDialogKeyEvent(mpDoc, nDialogId, nType, nCharCode, nKeyCode);
}
/**
@@ -310,7 +310,7 @@ public:
/**
* Posts a mouse event to the dialog with given id.
*
- * @param pDialogId Dialog id where mouse event is to be posted
+ * @param nDialogId Dialog id where mouse event is to be posted
* @param nType Event type, like down, move or up.
* @param nX horizontal position in document coordinates
* @param nY vertical position in document coordinates
@@ -318,15 +318,15 @@ public:
* @param nButtons: which mouse buttons: 1 for left, 2 for middle, 4 right
* @param nModifier: which keyboard modifier: (see include/vcl/vclenum.hxx for possible values)
*/
- void postDialogMouseEvent(const char* pDialogId, int nType, int nX, int nY, int nCount, int nButtons, int nModifier)
+ void postDialogMouseEvent(unsigned nDialogId, int nType, int nX, int nY, int nCount, int nButtons, int nModifier)
{
- mpDoc->pClass->postDialogMouseEvent(mpDoc, pDialogId, nType, nX, nY, nCount, nButtons, nModifier);
+ mpDoc->pClass->postDialogMouseEvent(mpDoc, nDialogId, nType, nX, nY, nCount, nButtons, nModifier);
}
/**
* Posts a mouse event to the child of a dialog with given id.
*
- * @param aDialogId Dialog id
+ * @param nDialogId Dialog id
* @param nType Event type, like down, move or up.
* @param nX horizontal position in document coordinates
* @param nY vertical position in document coordinates
@@ -334,9 +334,9 @@ public:
* @param nButtons: which mouse buttons: 1 for left, 2 for middle, 4 right
* @param nModifier: which keyboard modifier: (see include/vcl/vclenum.hxx for possible values)
*/
- void postDialogChildMouseEvent(const char* pDialogId, int nType, int nX, int nY, int nCount, int nButtons, int nModifier)
+ void postDialogChildMouseEvent(unsigned nDialogId, int nType, int nX, int nY, int nCount, int nButtons, int nModifier)
{
- mpDoc->pClass->postDialogChildMouseEvent(mpDoc, pDialogId, nType, nX, nY, nCount, nButtons, nModifier);
+ mpDoc->pClass->postDialogChildMouseEvent(mpDoc, nDialogId, nType, nX, nY, nCount, nButtons, nModifier);
}
diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx
index 93d61fc311fa..24e59d097393 100644
--- a/include/sfx2/lokhelper.hxx
+++ b/include/sfx2/lokhelper.hxx
@@ -42,11 +42,11 @@ public:
/// Same as notifyOtherViews(), but works on a selected "other" view, not on all of them.
static void notifyOtherView(SfxViewShell* pThisView, SfxViewShell const* pOtherView, int nType, const OString& rKey, const OString& rPayload);
/// Emits a LOK_CALLBACK_DIALOG
- static void notifyDialog(const OUString& rDialogId,
+ static void notifyDialog(vcl::DialogID nDialogId,
const OUString& rAction,
const std::vector<vcl::LOKPayloadItem>& rPayload = std::vector<vcl::LOKPayloadItem>());
/// Emits a LOK_CALLBACK_DIALOG_CHILD
- static void notifyDialogChild(const OUString& rDialogID, const OUString& rAction, const Point& rPos);
+ static void notifyDialogChild(vcl::DialogID nDialogId, const OUString& rAction, const Point& rPos);
/// Emits a LOK_CALLBACK_INVALIDATE_TILES, but tweaks it according to setOptionalFeatures() if needed.
static void notifyInvalidation(SfxViewShell const* pThisView, const OString& rPayload);
/// A special value to signify 'infinity'.
diff --git a/include/sfx2/viewsh.hxx b/include/sfx2/viewsh.hxx
index ed0ea3f3817b..e6687ff7d5a7 100644
--- a/include/sfx2/viewsh.hxx
+++ b/include/sfx2/viewsh.hxx
@@ -222,13 +222,13 @@ public:
virtual SfxShell* GetFormShell() { return nullptr; };
virtual const SfxShell* GetFormShell() const { return nullptr; };
- void RegisterDlg(const vcl::DialogID& rDialogId, VclPtr<Dialog> pDlg);
- VclPtr<Dialog> GetOpenedDlg(const vcl::DialogID& rDialogId);
- void UnregisterDlg(const vcl::DialogID& rDialogId);
+ void RegisterDlg(vcl::DialogID nDialogId, VclPtr<Dialog> pDlg);
+ VclPtr<Dialog> GetOpenedDlg(vcl::DialogID nDialogId);
+ void UnregisterDlg(vcl::DialogID nDialogId);
// IDialogNotifier
- virtual void notifyDialog(const vcl::DialogID& rDialogID, const OUString& rAction, const std::vector<vcl::LOKPayloadItem>& rPayload = std::vector<vcl::LOKPayloadItem>()) override;
- virtual void notifyDialogChild(const vcl::DialogID& rDialogID, const OUString& rAction, const Point& rPos) override;
+ virtual void notifyDialog(const vcl::DialogID& rDialogId, const OUString& rAction, const std::vector<vcl::LOKPayloadItem>& rPayload = std::vector<vcl::LOKPayloadItem>()) override;
+ virtual void notifyDialogChild(const vcl::DialogID& rDialogId, const OUString& rAction, const Point& rPos) override;
// Focus, KeyInput, Cursor
virtual void ShowCursor( bool bOn = true );
diff --git a/include/vcl/IDialogRenderable.hxx b/include/vcl/IDialogRenderable.hxx
index 9a63830566f0..f606782692e3 100644
--- a/include/vcl/IDialogRenderable.hxx
+++ b/include/vcl/IDialogRenderable.hxx
@@ -23,7 +23,7 @@ namespace vcl
typedef std::pair<const OString, const OString> LOKPayloadItem;
-typedef OUString DialogID;
+typedef sal_uInt32 DialogID;
class VCL_DLLPUBLIC IDialogRenderable
{
diff --git a/include/vcl/dialog.hxx b/include/vcl/dialog.hxx
index 874828f92a0e..e4d9f88f6d83 100644
--- a/include/vcl/dialog.hxx
+++ b/include/vcl/dialog.hxx
@@ -59,6 +59,8 @@ private:
vcl::IDialogNotifier* mpDialogNotifier; // to emit LOK callbacks
+ static vcl::DialogID mnLastDialogId;
+
SAL_DLLPRIVATE void ImplInitDialogData();
SAL_DLLPRIVATE void ImplInitSettings();
SAL_DLLPRIVATE VclPtr<vcl::Window> AddBorderWindow(vcl::Window* pParent, WinBits nBits);
@@ -73,8 +75,8 @@ private:
protected:
using Window::ImplInit;
SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle, InitFlag eFlag = InitFlag::Default );
- /// Dialog ID (UNO name) for this dialog
- OUString maID;
+ /// Dialog ID (used for LOK)
+ vcl::DialogID maID;
/// Necessary to register dialog notifier instance to emit LOK callbacks
void registerDialogNotifier(vcl::IDialogNotifier* pDialogNotifier);
diff --git a/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx b/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx
index 176fa91fffaa..b5325cf853c0 100644
--- a/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx
@@ -48,7 +48,7 @@ struct GtvLokDialogPrivate
guint32 m_nChildKeyModifier;
guint32 m_nChildLastButtonPressed;
- gchar* dialogid;
+ guint dialogid;
};
G_DEFINE_TYPE_WITH_PRIVATE(GtvLokDialog, gtv_lok_dialog, GTK_TYPE_DIALOG);
@@ -400,7 +400,7 @@ gtv_lok_dialog_set_property(GObject* object, guint propId, const GValue* value,
priv->lokdocview = LOK_DOC_VIEW(g_value_get_object(value));
break;
case PROP_DIALOG_ID:
- priv->dialogid = g_value_dup_string(value);
+ priv->dialogid = g_value_get_uint(value);
break;
case PROP_DIALOG_WIDTH:
priv->m_nWidth = g_value_get_uint(value);
@@ -425,7 +425,7 @@ gtv_lok_dialog_get_property(GObject* object, guint propId, GValue* value, GParam
g_value_set_object(value, priv->lokdocview);
break;
case PROP_DIALOG_ID:
- g_value_set_string(value, priv->dialogid);
+ g_value_set_uint(value, priv->dialogid);
break;
case PROP_DIALOG_WIDTH:
g_value_set_uint(value, priv->m_nWidth);
@@ -439,22 +439,10 @@ gtv_lok_dialog_get_property(GObject* object, guint propId, GValue* value, GParam
}
static void
-gtv_lok_dialog_finalize(GObject* object)
-{
- GtvLokDialog* self = GTV_LOK_DIALOG(object);
- GtvLokDialogPrivate* priv = getPrivate(self);
-
- g_free(priv->dialogid);
-
- G_OBJECT_CLASS(gtv_lok_dialog_parent_class)->finalize(object);
-}
-
-static void
gtv_lok_dialog_class_init(GtvLokDialogClass* klass)
{
G_OBJECT_CLASS(klass)->get_property = gtv_lok_dialog_get_property;
G_OBJECT_CLASS(klass)->set_property = gtv_lok_dialog_set_property;
- G_OBJECT_CLASS(klass)->finalize = gtv_lok_dialog_finalize;
properties[PROP_LOKDOCVIEW_CONTEXT] = g_param_spec_object("lokdocview",
"LOKDocView Context",
@@ -464,29 +452,29 @@ gtv_lok_dialog_class_init(GtvLokDialogClass* klass)
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS));
- properties[PROP_DIALOG_ID] = g_param_spec_string("dialogid",
- "Dialog identifier",
- "Unique dialog identifier; UNO command for now",
- nullptr,
- static_cast<GParamFlags>(G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS));
+ properties[PROP_DIALOG_ID] = g_param_spec_uint("dialogid",
+ "Dialog identifier",
+ "Unique dialog identifier",
+ 0, G_MAXUINT, 0,
+ static_cast<GParamFlags>(G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS));
properties[PROP_DIALOG_WIDTH] = g_param_spec_uint("width",
- "Dialog width",
- "Dialog width",
- 0, 1024, 0,
- static_cast<GParamFlags>(G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS));
+ "Dialog width",
+ "Dialog width",
+ 0, 1024, 0,
+ static_cast<GParamFlags>(G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS));
properties[PROP_DIALOG_HEIGHT] = g_param_spec_uint("height",
"Dialog height",
- "Dialog height",
- 0, 1024, 0,
- static_cast<GParamFlags>(G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS));
+ "Dialog height",
+ 0, 1024, 0,
+ static_cast<GParamFlags>(G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS));
g_object_class_install_properties (G_OBJECT_CLASS(klass), PROP_LAST, properties);
}
@@ -702,7 +690,7 @@ void gtv_lok_dialog_child_close(GtvLokDialog* dialog)
GtkWidget*
-gtv_lok_dialog_new(LOKDocView* pDocView, const gchar* dialogId, guint width, guint height)
+gtv_lok_dialog_new(LOKDocView* pDocView, guint dialogId, guint width, guint height)
{
GtkWindow* pWindow = GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(pDocView)));
return GTK_WIDGET(g_object_new(GTV_TYPE_LOK_DIALOG,
diff --git a/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.hxx b/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.hxx
index 8f2161ef5f27..0f7002c359d7 100644
--- a/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.hxx
+++ b/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.hxx
@@ -35,7 +35,7 @@ struct GtvLokDialogClass
GType gtv_lok_dialog_get_type (void) G_GNUC_CONST;
-GtkWidget* gtv_lok_dialog_new(LOKDocView* pDocView, const gchar* dialogId, guint width, guint height);
+GtkWidget* gtv_lok_dialog_new(LOKDocView* pDocView, guint dialogId, guint width, guint height);
void gtv_lok_dialog_invalidate(GtvLokDialog* dialog, const GdkRectangle& aRectangle);
diff --git a/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx b/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx
index 03e54afd1d22..62f639957d2b 100644
--- a/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx
@@ -308,15 +308,15 @@ void LOKDocViewSigHandlers::dialog(LOKDocView* pDocView, gchar* pPayload, gpoint
std::stringstream aStream(pPayload);
boost::property_tree::ptree aRoot;
boost::property_tree::read_json(aStream, aRoot);
- const std::string aDialogId = aRoot.get<std::string>("dialogId");
+ const unsigned nDialogId = aRoot.get<unsigned>("dialogId");
const std::string aAction = aRoot.get<std::string>("action");
if (aAction == "created")
{
const std::string aSize = aRoot.get<std::string>("size");
std::vector<int> aPoints = GtvHelpers::splitIntoIntegers(aSize, ", ", 2);
- GtkWidget* pDialog = gtv_lok_dialog_new(pDocView, aDialogId.c_str(), aPoints[0], aPoints[1]);
- g_info("created dialog, for dialogid: %s with size: %s", aDialogId.c_str(), aSize.c_str());
+ GtkWidget* pDialog = gtv_lok_dialog_new(pDocView, nDialogId, aPoints[0], aPoints[1]);
+ g_info("created dialog, for dialogid: %d with size: %s", nDialogId, aSize.c_str());
gtv_application_window_register_child_window(window, GTK_WINDOW(pDialog));
g_signal_connect(pDialog, "destroy", G_CALLBACK(destroyLokDialog), window);
@@ -333,9 +333,9 @@ void LOKDocViewSigHandlers::dialog(LOKDocView* pDocView, gchar* pPayload, gpoint
GList* pIt = nullptr;
for (pIt = pChildWins; pIt != nullptr; pIt = pIt->next)
{
- gchar* pChildDialogId = nullptr;
- g_object_get(pIt->data, "dialogid", &pChildDialogId, nullptr);
- if (g_strcmp0(pChildDialogId, aDialogId.c_str()) == 0)
+ guint nChildDialogId = 0;
+ g_object_get(pIt->data, "dialogid", &nChildDialogId, nullptr);
+ if (nDialogId == nChildDialogId)
{
if (aAction == "close")
gtk_widget_destroy(GTK_WIDGET(pIt->data));
@@ -355,7 +355,6 @@ void LOKDocViewSigHandlers::dialog(LOKDocView* pDocView, gchar* pPayload, gpoint
gtv_lok_dialog_invalidate(GTV_LOK_DIALOG(pIt->data), aGdkRectangle);
}
}
- g_free(pChildDialogId);
}
}
@@ -366,9 +365,9 @@ void LOKDocViewSigHandlers::dialogChild(LOKDocView* pDocView, gchar* pPayload, g
std::stringstream aStream(pPayload);
boost::property_tree::ptree aRoot;
boost::property_tree::read_json(aStream, aRoot);
- std::string aDialogId = aRoot.get<std::string>("dialogId");
- std::string aAction = aRoot.get<std::string>("action");
- std::string aPos = aRoot.get<std::string>("position");
+ const unsigned nDialogId = aRoot.get<unsigned>("dialogId");
+ const std::string aAction = aRoot.get<std::string>("action");
+ const std::string aPos = aRoot.get<std::string>("position");
gchar** ppCoordinates = g_strsplit(aPos.c_str(), ", ", 2);
gchar** ppCoordinate = ppCoordinates;
int nX = 0;
@@ -386,16 +385,15 @@ void LOKDocViewSigHandlers::dialogChild(LOKDocView* pDocView, gchar* pPayload, g
GList* pIt = nullptr;
for (pIt = pChildWins; pIt != nullptr; pIt = pIt->next)
{
- gchar* pChildDialogId = nullptr;
- g_object_get(pIt->data, "dialogid", &pChildDialogId, nullptr);
- if (g_strcmp0(pChildDialogId, aDialogId.c_str()) == 0)
+ guint nChildDialogId = 0;
+ g_object_get(pIt->data, "dialogid", &nChildDialogId, nullptr);
+ if (nDialogId == nChildDialogId)
{
if (aAction == "invalidate")
gtv_lok_dialog_child_invalidate(GTV_LOK_DIALOG(pIt->data), nX, nY);
else if (aAction == "close")
gtv_lok_dialog_child_close(GTV_LOK_DIALOG(pIt->data));
}
- g_free(pChildDialogId);
}
}
diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx
index 33464711852f..9af028916b69 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -144,15 +144,15 @@ void SfxLokHelper::notifyOtherViews(SfxViewShell* pThisView, int nType, const OS
}
}
-void SfxLokHelper::notifyDialog(const OUString& rDialogID,
+void SfxLokHelper::notifyDialog(vcl::DialogID nDialogID,
const OUString& rAction,
const std::vector<vcl::LOKPayloadItem>& rPayload)
{
- if (SfxLokHelper::getViewsCount() <= 0 || rDialogID.isEmpty())
+ if (SfxLokHelper::getViewsCount() <= 0 || nDialogID == 0)
return;
SfxViewShell* pViewShell = SfxViewShell::GetFirst();
- OString aPayload = OString("{ \"dialogId\": \"") + OUStringToOString(rDialogID, RTL_TEXTENCODING_UTF8).getStr() + OString("\"");
+ OString aPayload = OString("{ \"dialogId\": \"") + OString::number(nDialogID) + OString("\"");
aPayload += OString(", \"action\": \"") + OUStringToOString(rAction, RTL_TEXTENCODING_UTF8).getStr() + OString("\"");
for (const auto& rItem: rPayload)
@@ -172,13 +172,13 @@ void SfxLokHelper::notifyDialog(const OUString& rDialogID,
}
}
-void SfxLokHelper::notifyDialogChild(const OUString& rDialogID, const OUString& rAction, const Point& rPos)
+void SfxLokHelper::notifyDialogChild(vcl::DialogID nDialogID, const OUString& rAction, const Point& rPos)
{
- if (SfxLokHelper::getViewsCount() <= 0 || rDialogID.isEmpty())
+ if (SfxLokHelper::getViewsCount() <= 0 || nDialogID == 0)
return;
SfxViewShell* pViewShell = SfxViewShell::GetFirst();
- const OString aPayload = OString("{ \"dialogId\": \"") + OUStringToOString(rDialogID, RTL_TEXTENCODING_UTF8).getStr() +
+ const OString aPayload = OString("{ \"dialogId\": \"") + OString::number(nDialogID) +
OString("\", \"action\": \"") + OUStringToOString(rAction, RTL_TEXTENCODING_UTF8).getStr() +
OString("\", \"position\": \"") + OString::number(rPos.getX()) + OString(", ") + OString::number(rPos.getY()) +
+ "\" }";
diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx
index 2d4d8af19a70..92dcfa48cdcf 100644
--- a/sfx2/source/view/viewsh.cxx
+++ b/sfx2/source/view/viewsh.cxx
@@ -1948,31 +1948,28 @@ Reference< view::XRenderable > SfxViewShell::GetRenderable()
return xRender;
}
-void SfxViewShell::notifyDialog(const vcl::DialogID& rDialogID, const OUString& rAction, const std::vector<vcl::LOKPayloadItem>& rPayload)
+void SfxViewShell::notifyDialog(const vcl::DialogID& rDialogId, const OUString& rAction, const std::vector<vcl::LOKPayloadItem>& rPayload)
{
- SfxLokHelper::notifyDialog(rDialogID, rAction, rPayload);
+ SfxLokHelper::notifyDialog(rDialogId, rAction, rPayload);
}
-void SfxViewShell::notifyDialogChild(const vcl::DialogID& rDialogID, const OUString& rAction, const Point& rPos)
+void SfxViewShell::notifyDialogChild(const vcl::DialogID& rDialogId, const OUString& rAction, const Point& rPos)
{
- SfxLokHelper::notifyDialog(rDialogID, rAction);
+ SfxLokHelper::notifyDialog(rDialogId, rAction);
}
-void SfxViewShell::RegisterDlg(const vcl::DialogID& rDialogId, VclPtr<Dialog> pDlg)
+void SfxViewShell::RegisterDlg(vcl::DialogID nDialogId, VclPtr<Dialog> pDlg)
{
if (pDlg)
- maOpenedDialogs.push_back(std::make_pair(rName, pDlg));
+ maOpenedDialogs.push_back(std::make_pair(nDialogId, pDlg));
}
-VclPtr<Dialog> SfxViewShell::GetOpenedDlg(const vcl::DialogID& rDialogId)
+VclPtr<Dialog> SfxViewShell::GetOpenedDlg(vcl::DialogID nDialogId)
{
- if (rName.startsWith(".uno:"))
- rName = rName.replaceFirst(".uno:", "");
-
const auto it = std::find_if(maOpenedDialogs.begin(),
maOpenedDialogs.end(),
- [&rDialogId](const std::pair<vcl::DialogID, VclPtr<Dialog>> aItem) {
- return rDialogId == aItem.first;
+ [&nDialogId](const std::pair<vcl::DialogID, VclPtr<Dialog>> aItem) {
+ return nDialogId == aItem.first;
});
Dialog* ret = nullptr;
@@ -1983,12 +1980,12 @@ VclPtr<Dialog> SfxViewShell::GetOpenedDlg(const vcl::DialogID& rDialogId)
return ret;
}
-void SfxViewShell::UnregisterDlg(const OUString& rName)
+void SfxViewShell::UnregisterDlg(vcl::DialogID nDialogId)
{
maOpenedDialogs.erase(std::remove_if(maOpenedDialogs.begin(),
maOpenedDialogs.end(),
- [&rDialogId](const std::pair<vcl::DialogID, VclPtr<Dialog>> aItem) {
- return aItem.first == rDialogId;
+ [&nDialogId](const std::pair<vcl::DialogID, VclPtr<Dialog>> aItem) {
+ return aItem.first == nDialogId;
}));
}
diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx
index 96ba71ffe888..bbde33d08e16 100644
--- a/vcl/source/window/dialog.cxx
+++ b/vcl/source/window/dialog.cxx
@@ -346,6 +346,7 @@ struct DialogImpl
void Dialog::ImplInitDialogData()
{
+ maID = mnLastDialogId++;
mpDialogNotifier = nullptr;
mpWindowImpl->mbDialog = true;
mpPrevExecuteDlg = nullptr;
@@ -490,6 +491,8 @@ void Dialog::ImplInitSettings()
SetBackground(GetSettings().GetStyleSettings().GetDialogColor());
}
+vcl::DialogID Dialog::mnLastDialogId = 1;
+
Dialog::Dialog( WindowType nType )
: SystemWindow( nType )
, mbForceBorderWindow(false)
@@ -957,7 +960,7 @@ void Dialog::LogicMouseMoveChild(const MouseEvent& rMouseEvent)
void Dialog::InvalidateFloatingWindow(const Point& rPos)
{
- if (comphelper::LibreOfficeKit::isActive() && mpDialogNotifier && !maID.isEmpty())
+ if (comphelper::LibreOfficeKit::isActive() && mpDialogNotifier && maID != 0)
{
mpDialogNotifier->notifyDialogChild(maID, "invalidate", rPos);
}
@@ -965,7 +968,7 @@ void Dialog::InvalidateFloatingWindow(const Point& rPos)
void Dialog::CloseFloatingWindow()
{
- if (comphelper::LibreOfficeKit::isActive() && mpDialogNotifier && !maID.isEmpty())
+ if (comphelper::LibreOfficeKit::isActive() && mpDialogNotifier && maID != 0)
{
mpDialogNotifier->notifyDialogChild(maID, "close", Point(0, 0));
}
@@ -973,7 +976,7 @@ void Dialog::CloseFloatingWindow()
void Dialog::LogicInvalidate(const tools::Rectangle* pRectangle)
{
- if (!comphelper::LibreOfficeKit::isDialogPainting() && mpDialogNotifier && !maID.isEmpty())
+ if (!comphelper::LibreOfficeKit::isDialogPainting() && mpDialogNotifier && maID != 0)
{
std::vector<vcl::LOKPayloadItem> aPayload;
if (pRectangle)
@@ -1025,7 +1028,7 @@ void Dialog::LOKCursor(const OUString& rAction, const std::vector<vcl::LOKPayloa
{
assert(comphelper::LibreOfficeKit::isActive());
- if (!comphelper::LibreOfficeKit::isDialogPainting() && mpDialogNotifier && !maID.isEmpty())
+ if (!comphelper::LibreOfficeKit::isDialogPainting() && mpDialogNotifier && maID != 0)
{
mpDialogNotifier->notifyDialog(maID, rAction, rPayload);
}
@@ -1348,7 +1351,7 @@ void Dialog::Resize()
SystemWindow::Resize();
// inform LOK clients
- if (!comphelper::LibreOfficeKit::isDialogPainting() && mpDialogNotifier && !maID.isEmpty())
+ if (!comphelper::LibreOfficeKit::isDialogPainting() && mpDialogNotifier && maID != 0)
{
mpDialogNotifier->notifyDialog(maID, "invalidate");
}