summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorPranav Kant <pranavk@collabora.co.uk>2017-12-01 13:54:45 +0530
committerJan Holesovsky <kendy@collabora.com>2017-12-05 12:11:17 +0100
commit6d9db952e8b3cff75ace140a4d51e41e975861d5 (patch)
tree2eda467e8cc177a484e9c817e080f4e3ee817f19 /desktop
parent0b28b6015c52753fa3f8f081c65cb07d396bf8d7 (diff)
lokdialog: Simplify; make the LOK dialog API more generic
Merge the dialog floating window callbacks and function calls into one. Unique window ids across vcl::Window is enough to distinguish between them. Floating windows don't have a LOK notifier as they are created in the vcl itself (so we can't access them from sfx2). Use the parent LOK notifier in that case (which would be a dialog). This API should also help in autopopup filter tunneling later. Change-Id: I63a2c97ffdd84695dc967e14c793089a7c50b41b
Diffstat (limited to 'desktop')
-rw-r--r--desktop/source/lib/init.cxx55
1 files changed, 14 insertions, 41 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 98d3ac7c86a7..ef2d45dce173 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -637,8 +637,6 @@ static void doc_paintWindow(LibreOfficeKitDocument* pThis, unsigned nLOKWindowId
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)
@@ -692,7 +690,6 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XCompone
m_pDocumentClass->getPartHash = doc_getPartHash;
m_pDocumentClass->paintWindow = doc_paintWindow;
- m_pDocumentClass->paintActiveFloatingWindow = doc_paintActiveFloatingWindow;
m_pDocumentClass->postWindow = doc_postWindow;
gDocumentClass = m_pDocumentClass;
@@ -812,8 +809,7 @@ void CallbackFlushHandler::queue(const int type, const char* data)
case LOK_CALLBACK_SET_PART:
case LOK_CALLBACK_TEXT_VIEW_SELECTION:
case LOK_CALLBACK_INVALIDATE_HEADER:
- case LOK_CALLBACK_DIALOG:
- case LOK_CALLBACK_DIALOG_CHILD:
+ case LOK_CALLBACK_WINDOW:
{
const auto& pos = std::find_if(m_queue.rbegin(), m_queue.rend(),
[type] (const queue_type::value_type& elem) { return (elem.first == type); });
@@ -1046,27 +1042,27 @@ void CallbackFlushHandler::queue(const int type, const char* data)
}
break;
- case LOK_CALLBACK_DIALOG:
+ case LOK_CALLBACK_WINDOW:
{
// reading JSON by boost might be slow?
boost::property_tree::ptree aTree;
std::stringstream aStream(payload);
boost::property_tree::read_json(aStream, aTree);
- const unsigned nLOKWindowId = aTree.get<unsigned>("dialogId", 0);
+ const unsigned nLOKWindowId = aTree.get<unsigned>("id", 0);
if (aTree.get<std::string>("action", "") == "invalidate")
{
std::string aRectStr = aTree.get<std::string>("rectangle", "");
- // no 'rectangle' field => invalidate all of the dialog =>
- // remove all previous dialog part invalidations
+ // no 'rectangle' field => invalidate all of the window =>
+ // remove all previous window part invalidations
if (aRectStr.empty())
{
removeAll([&nLOKWindowId] (const queue_type::value_type& elem) {
- if (elem.first == LOK_CALLBACK_DIALOG)
+ if (elem.first == LOK_CALLBACK_WINDOW)
{
boost::property_tree::ptree aOldTree;
std::stringstream aOldStream(elem.second);
boost::property_tree::read_json(aOldStream, aOldTree);
- const unsigned nOldDialogId = aOldTree.get<unsigned>("dialogId", 0);
+ const unsigned nOldDialogId = aOldTree.get<unsigned>("id", 0);
if (aOldTree.get<std::string>("action", "") == "invalidate" &&
nLOKWindowId == nOldDialogId)
{
@@ -1078,18 +1074,18 @@ void CallbackFlushHandler::queue(const int type, const char* data)
}
else
{
- // if we have to invalidate all of the dialog, ignore
+ // if we have to invalidate all of the window, ignore
// any part invalidation message
const auto& pos = std::find_if(m_queue.rbegin(), m_queue.rend(),
[&nLOKWindowId] (const queue_type::value_type& elem)
{
- if (elem.first != LOK_CALLBACK_DIALOG)
+ if (elem.first != LOK_CALLBACK_WINDOW)
return false;
boost::property_tree::ptree aOldTree;
std::stringstream aOldStream(elem.second);
boost::property_tree::read_json(aOldStream, aOldTree);
- const unsigned nOldDialogId = aOldTree.get<unsigned>("dialogId", 0);
+ const unsigned nOldDialogId = aOldTree.get<unsigned>("id", 0);
if (aOldTree.get<std::string>("action", "") == "invalidate" &&
nLOKWindowId == nOldDialogId &&
aOldTree.get<std::string>("rectangle", "").empty())
@@ -1099,10 +1095,10 @@ void CallbackFlushHandler::queue(const int type, const char* data)
return false;
});
- // we found a invalidate-all dialog callback
+ // we found a invalidate-all window callback
if (pos != m_queue.rend())
{
- SAL_INFO("lok.dialog", "Skipping queue [" << type << "]: [" << payload << "] since whole dialog needs to be invalidated.");
+ SAL_INFO("lok.dialog", "Skipping queue [" << type << "]: [" << payload << "] since whole window needs to be invalidated.");
return;
}
@@ -1113,7 +1109,7 @@ void CallbackFlushHandler::queue(const int type, const char* data)
Rectangle aNewRect = Rectangle(nLeft, nTop, nLeft + nWidth, nTop + nHeight);
bool currentIsRedundant = false;
removeAll([&aNewRect, &nLOKWindowId, &currentIsRedundant] (const queue_type::value_type& elem) {
- if (elem.first != LOK_CALLBACK_DIALOG)
+ if (elem.first != LOK_CALLBACK_WINDOW)
return false;
boost::property_tree::ptree aOldTree;
@@ -1121,7 +1117,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 unsigned nOldDialogId = aOldTree.get<unsigned>("dialogId", 0);
+ const unsigned nOldDialogId = aOldTree.get<unsigned>("id", 0);
std::string aOldRectStr = aOldTree.get<std::string>("rectangle", "");
// not possible that we encounter an empty
// rectangle here; we already handled this
@@ -3341,29 +3337,6 @@ static void doc_paintWindow(LibreOfficeKitDocument* /*pThis*/, unsigned nLOKWind
comphelper::LibreOfficeKit::setDialogPainting(false);
}
-static void doc_paintActiveFloatingWindow(LibreOfficeKitDocument* /*pThis*/, unsigned nLOKWindowId, unsigned char* pBuffer, int* nWidth, int* nHeight)
-{
- SolarMutexGuard aGuard;
-
- VclPtr<Window> pWindow = vcl::Window::FindLOKWindow(nLOKWindowId);
- if (!pWindow)
- {
- gImpl->maLastExceptionMsg = "Document doesn't support dialog rendering, or window not found.";
- return;
- }
-
- 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);
-
- comphelper::LibreOfficeKit::setDialogPainting(true);
- const Size aSize = pWindow->PaintActiveFloatingWindow(*pDevice.get());
- *nWidth = aSize.getWidth();
- *nHeight = aSize.getHeight();
- comphelper::LibreOfficeKit::setDialogPainting(false);
-}
-
static void doc_postWindow(LibreOfficeKitDocument* /*pThis*/, unsigned nLOKWindowId, int nAction)
{
SolarMutexGuard aGuard;