diff options
20 files changed, 31 insertions, 1053 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 5d0e39c419cc..9e0dc77ff681 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -83,7 +83,6 @@ #include <vcl/sysdata.hxx> #include <vcl/virdev.hxx> #include <vcl/ITiledRenderable.hxx> -#include <vcl/IDialogRenderable.hxx> #include <unicode/uchar.h> #include <unotools/configmgr.hxx> #include <unotools/syslocaleoptions.hxx> @@ -543,11 +542,6 @@ static void doc_postKeyEvent(LibreOfficeKitDocument* pThis, int nType, int nCharCode, int nKeyCode); -static void doc_postDialogKeyEvent(LibreOfficeKitDocument* pThis, - const char* pDialogId, - int nType, - int nCharCode, - int nKeyCode); static void doc_postMouseEvent (LibreOfficeKitDocument* pThis, int nType, int nX, @@ -555,22 +549,6 @@ static void doc_postMouseEvent (LibreOfficeKitDocument* pThis, int nCount, int nButtons, int nModifier); -static void doc_postDialogMouseEvent (LibreOfficeKitDocument* pThis, - const char* pDialogId, - int nType, - int nX, - int nY, - int nCount, - int nButtons, - int 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_postUnoCommand(LibreOfficeKitDocument* pThis, const char* pCommand, const char* pArguments, @@ -611,15 +589,6 @@ 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, - 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); - LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XComponent> &xComponent) : mxComponent(xComponent) { @@ -645,10 +614,7 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XCompone m_pDocumentClass->initializeForRendering = doc_initializeForRendering; m_pDocumentClass->registerCallback = doc_registerCallback; m_pDocumentClass->postKeyEvent = doc_postKeyEvent; - m_pDocumentClass->postDialogKeyEvent = doc_postDialogKeyEvent; m_pDocumentClass->postMouseEvent = doc_postMouseEvent; - m_pDocumentClass->postDialogMouseEvent = doc_postDialogMouseEvent; - m_pDocumentClass->postDialogChildMouseEvent = doc_postDialogChildMouseEvent; m_pDocumentClass->postUnoCommand = doc_postUnoCommand; m_pDocumentClass->setTextSelection = doc_setTextSelection; m_pDocumentClass->getTextSelection = doc_getTextSelection; @@ -669,10 +635,6 @@ 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->getDialogInfo = doc_getDialogInfo; - m_pDocumentClass->paintActiveFloatingWindow = doc_paintActiveFloatingWindow; - gDocumentClass = m_pDocumentClass; } pClass = m_pDocumentClass.get(); @@ -790,7 +752,6 @@ 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: { const auto& pos = std::find_if(m_queue.rbegin(), m_queue.rend(), [type] (const queue_type::value_type& elem) { return (elem.first == type); }); @@ -1022,139 +983,6 @@ void CallbackFlushHandler::queue(const int type, const char* data) } } break; - - case LOK_CALLBACK_DIALOG: - { - // reading JSON by boost might be slow? - 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", ""); - 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 - if (aRectStr.empty()) - { - removeAll([&aDialogId] (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", ""); - if (aOldTree.get<std::string>("action", "") == "invalidate" && - aDialogId == aOldDialogId) - { - return true; - } - } - return false; - }); - } - else - { - // 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) - { - if (elem.first != LOK_CALLBACK_DIALOG) - return false; - - 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", ""); - if (aOldTree.get<std::string>("action", "") == "invalidate" && - aDialogId == aOldDialogId && - aOldTree.get<std::string>("rectangle", "").empty()) - { - return true; - } - return false; - }); - - // we found a invalidate-all dialog callback - if (pos != m_queue.rend()) - { - SAL_INFO("lok.dialog", "Skipping queue [" << type << "]: [" << payload << "] since whole dialog needs to be invalidated."); - return; - } - - std::istringstream aRectStream(aRectStr); - long nLeft, nTop, nWidth, nHeight; - char nComma; - 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, ¤tIsRedundant] (const queue_type::value_type& elem) { - if (elem.first != LOK_CALLBACK_DIALOG) - return false; - - boost::property_tree::ptree aOldTree; - std::stringstream aOldStream(elem.second); - boost::property_tree::read_json(aOldStream, aOldTree); - if (aOldTree.get<std::string>("action", "") == "invalidate") - { - const std::string aOldDialogId = aOldTree.get<std::string>("dialogId", ""); - std::string aOldRectStr = aOldTree.get<std::string>("rectangle", ""); - // not possible that we encounter an empty - // rectangle here; we already handled this - // case before - std::istringstream aOldRectStream(aOldRectStr); - long nOldLeft, nOldTop, nOldWidth, nOldHeight; - char nOldComma; - aOldRectStream >> nOldLeft >> nOldComma >> nOldTop >> nOldComma >> nOldWidth >> nOldComma >> nOldHeight; - tools::Rectangle aOldRect = tools::Rectangle(nOldLeft, nOldTop, nOldLeft + nOldWidth, nOldTop + nOldHeight); - - if (aDialogId == aOldDialogId) - { - // new one engulfs the old one? - if (aNewRect.IsInside(aOldRect)) - { - SAL_INFO("lok.dialog", "New " << aNewRect.toString() << " engulfs old " << aOldRect.toString() << "."); - return true; - } - // old one engulfs the new one? - else if (aOldRect.IsInside(aNewRect)) - { - SAL_INFO("lok.dialog", "Old " << aOldRect.toString() << " engulfs new " << aNewRect.toString() << "."); - // we have a rectangle in the queue - // already that makes the current - // Callback useless - currentIsRedundant = true; - return false; - } - else - { - SAL_INFO("lok.dialog", "Merging " << aNewRect.toString() << " & " << aOldRect.toString()); - aNewRect.Union(aOldRect); - SAL_INFO("lok.dialog", "Merged: " << aNewRect.toString()); - return true; - } - } - } - - // keep rest - return false; - }); - - if (currentIsRedundant) - { - SAL_INFO("lok.dialog", "Current payload is engulfed by one already in the queue. Skipping redundant payload: " << aNewRect.toString()); - return; - } - - aTree.put("rectangle", aNewRect.toString().getStr()); - std::stringstream aJSONStream; - boost::property_tree::write_json(aJSONStream, aTree); - payload = aJSONStream.str(); - } - } - } - break; } } @@ -1322,12 +1150,6 @@ ITiledRenderable* getTiledRenderable(LibreOfficeKitDocument* pThis) return dynamic_cast<ITiledRenderable*>(pDocument->mxComponent.get()); } -IDialogRenderable* getDialogRenderable(LibreOfficeKitDocument* pThis) -{ - LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis); - return dynamic_cast<IDialogRenderable*>(pDocument->mxComponent.get()); -} - } // anonymous namespace // Wonder global state ... @@ -2257,21 +2079,6 @@ 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) -{ - SolarMutexGuard aGuard; - - IDialogRenderable* pDoc = getDialogRenderable(pThis); - if (!pDoc) - { - gImpl->maLastExceptionMsg = "Document doesn't support dialog rendering"; - return; - } - - vcl::DialogID aDialogID = OUString::createFromAscii(pDialogId); - pDoc->postDialogKeyEvent(aDialogID, nType, nCharCode, nKeyCode); -} - /** Class to react on finishing of a dispatched command. This will call a LOK_COMMAND_FINISHED callback when postUnoCommand was @@ -2423,36 +2230,6 @@ 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) -{ - SolarMutexGuard aGuard; - - IDialogRenderable* pDoc = getDialogRenderable(pThis); - if (!pDoc) - { - gImpl->maLastExceptionMsg = "Document doesn't support dialog rendering"; - return; - } - - vcl::DialogID aDialogID = OUString::createFromAscii(pDialogId); - pDoc->postDialogMouseEvent(aDialogID, 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) -{ - SolarMutexGuard aGuard; - - IDialogRenderable* pDoc = getDialogRenderable(pThis); - if (!pDoc) - { - gImpl->maLastExceptionMsg = "Document doesn't support dialog rendering"; - return; - } - - vcl::DialogID aDialogID = OUString::createFromAscii(pDialogId); - pDoc->postDialogChildMouseEvent(aDialogID, nType, nX, nY, nCount, nButtons, nModifier); -} - static void doc_setTextSelection(LibreOfficeKitDocument* pThis, int nType, int nX, int nY) { SolarMutexGuard aGuard; @@ -3229,68 +3006,6 @@ unsigned char* doc_renderFont(SAL_UNUSED_PARAMETER LibreOfficeKitDocument* /*pTh 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, - unsigned char* pBuffer, - const int nX, const int nY, - const int nWidth, const int nHeight) -{ - SolarMutexGuard aGuard; - - IDialogRenderable* pDialogRenderable = getDialogRenderable(pThis); - - 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); - - 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()); - comphelper::LibreOfficeKit::setDialogPainting(false); -} - -static void doc_paintActiveFloatingWindow(LibreOfficeKitDocument* pThis, const char* pDialogId, unsigned char* pBuffer, int* nWidth, int* nHeight) -{ - SolarMutexGuard aGuard; - - IDialogRenderable* pDialogRenderable = getDialogRenderable(pThis); - - 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); - - vcl::DialogID aDialogID = OUString::createFromAscii(pDialogId); - - comphelper::LibreOfficeKit::setDialogPainting(true); - pDialogRenderable->paintActiveFloatingWindow(aDialogID, *pDevice.get(), *nWidth, *nHeight); - comphelper::LibreOfficeKit::setDialogPainting(false); -} - static char* lo_getError (LibreOfficeKit *pThis) { SolarMutexGuard aGuard; diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h index 14824821cfd7..0633f46f97e2 100644 --- a/include/LibreOfficeKit/LibreOfficeKit.h +++ b/include/LibreOfficeKit/LibreOfficeKit.h @@ -266,48 +266,6 @@ struct _LibreOfficeKitDocumentClass int* pArray, size_t nSize); - /// Paints dialog with given dialog id to the buffer - /// @see lok::Document::paintDialog(). - void (*paintDialog) (LibreOfficeKitDocument* pThis, const char* pDialogId, - 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, - char** pDialogTitle, int* pWidth, int* pHeight); - - /// @see lok::Document::paintActiveFloatingWindow(). - void (*paintActiveFloatingWindow) (LibreOfficeKitDocument* pThis, const char* pDialogId, unsigned char* pBuffer, int* nWidth, int* nHeight); - - /// @see lok::Document::postDialogKeyEvent(). - void (*postDialogKeyEvent) (LibreOfficeKitDocument* pThis, - const char* pDialogId, - int nType, - int nCharCode, - int nKeyCode); - - /// @see lok::Document::postDialogMouseEvent(). - void (*postDialogMouseEvent) (LibreOfficeKitDocument* pThis, - const char* pDialogId, - int nType, - int nX, - int nY, - int nCount, - int nButtons, - int nModifier); - - /// @see lok::Document::postDialogChildMouseEvent(). - void (*postDialogChildMouseEvent) (LibreOfficeKitDocument* pThis, - const char* pDialogId, - int nType, - int nX, - int nY, - int nCount, - int nButtons, - int nModifier); - #endif // defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY }; diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx index 19e121fe6573..0781e7d1e083 100644 --- a/include/LibreOfficeKit/LibreOfficeKit.hxx +++ b/include/LibreOfficeKit/LibreOfficeKit.hxx @@ -156,65 +156,6 @@ public: } /** - * Renders a dialog with give dialog id and writes the width and height of the rendered dialog - * - * 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 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, - 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->getDialogInfo(mpDoc, pDialogId, pDialogTitle, &pWidth, &pHeight); - - } - - /** - * Renders the active floating window of a dialog - * - * Client must truncate pBuffer according to the nWidth and nHeight returned after the call. - * - * @param pDialogId 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, - unsigned char* pBuffer, - int& nWidth, - int& nHeight) - { - return mpDoc->pClass->paintActiveFloatingWindow(mpDoc, pDialogId, pBuffer, - &nWidth, &nHeight); - } - - /** * Gets the tile mode: the pixel format used for the pBuffer of paintTile(). * * @return an element of the LibreOfficeKitTileMode enum. @@ -280,19 +221,6 @@ public: } /** - * Posts a keyboard event to the dialog - * - * @param pDialogId 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) - { - mpDoc->pClass->postDialogKeyEvent(mpDoc, pDialogId, nType, nCharCode, nKeyCode); - } - - /** * Posts a mouse event to the document. * * @param nType Event type, like down, move or up. @@ -308,39 +236,6 @@ public: } /** - * Posts a mouse event to the dialog with given id. - * - * @param pDialogId 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 - * @param nCount number of clicks: 1 for single click, 2 for double click - * @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) - { - mpDoc->pClass->postDialogMouseEvent(mpDoc, pDialogId, nType, nX, nY, nCount, nButtons, nModifier); - } - - /** - * Posts a mouse event to the child of a dialog with given id. - * - * @param aDialogId 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 - * @param nCount number of clicks: 1 for single click, 2 for double click - * @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) - { - mpDoc->pClass->postDialogChildMouseEvent(mpDoc, pDialogId, nType, nX, nY, nCount, nButtons, nModifier); - } - - - /** * Posts an UNO command to the document. * * Example argument string: diff --git a/include/LibreOfficeKit/LibreOfficeKitEnums.h b/include/LibreOfficeKit/LibreOfficeKitEnums.h index 62b9faf7ecb4..451ed2c959c7 100644 --- a/include/LibreOfficeKit/LibreOfficeKitEnums.h +++ b/include/LibreOfficeKit/LibreOfficeKitEnums.h @@ -522,29 +522,6 @@ typedef enum * Here all aproperties are same as described in svxruler. */ LOK_CALLBACK_RULER_UPDATE = 35, - /** - * Dialog invalidation - */ - LOK_CALLBACK_DIALOG = 36, - - /** - * Invalidation corresponding to dialog's children. - * Eg: Floating window etc. - * - * Payload example: - * { - * "dialogID": "SpellDialog", - * "action": "close" - * } - * - * - dialogID is the UNO command of the dialog - * - action can be - * - close, means dialog child window is closed now - * - invalidate, means dialog child window is invalidated - * It also means that dialog child window is created if it's the first - * invalidate - */ - LOK_CALLBACK_DIALOG_CHILD = 37 } LibreOfficeKitCallbackType; diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx index e22017c8eccc..9cf98fa40c88 100644 --- a/include/sfx2/lokhelper.hxx +++ b/include/sfx2/lokhelper.hxx @@ -10,7 +10,6 @@ #ifndef INCLUDED_SFX2_LOKHELPER_HXX #define INCLUDED_SFX2_LOKHELPER_HXX -#include <vcl/IDialogRenderable.hxx> #include <sfx2/dllapi.h> #include <sfx2/viewsh.hxx> #include <cstddef> @@ -41,12 +40,6 @@ public: static void notifyOtherViews(SfxViewShell* pThisView, int nType, const OString& rKey, const OString& rPayload); /// 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, - const OUString& rAction, - const std::vector<vcl::LOKPayloadItem>& rPayload); - /// Emits a LOK_CALLBACK_DIALOG_CHILD - static void notifyDialogChild(const OUString& rDialogID, 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/libreofficekit/Executable_gtktiledviewer.mk b/libreofficekit/Executable_gtktiledviewer.mk index 5dd89e6065f6..f0667e247680 100644 --- a/libreofficekit/Executable_gtktiledviewer.mk +++ b/libreofficekit/Executable_gtktiledviewer.mk @@ -9,14 +9,10 @@ $(eval $(call gb_Executable_Executable,gtktiledviewer)) -$(eval $(call gb_Library_use_sdk_api,gtktiledviewer)) - $(eval $(call gb_Executable_set_include,gtktiledviewer,\ $$(INCLUDE) \ -I$(SRCDIR)/desktop/inc \ -I$(SRCDIR)/libreofficekit/qa/gtktiledviewer/ \ - -I$(WORKDIR)/UnoApiHeadersTarget/offapi/normal/ \ - -I$(WORKDIR)/UnoApiHeadersTarget/udkapi/normal/ \ )) $(eval $(call gb_Executable_use_externals,gtktiledviewer,\ @@ -57,7 +53,6 @@ $(eval $(call gb_Executable_add_exception_objects,gtktiledviewer,\ libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers \ libreofficekit/qa/gtktiledviewer/gtv-calc-header-bar \ libreofficekit/qa/gtktiledviewer/gtv-comments-sidebar \ - libreofficekit/qa/gtktiledviewer/gtv-lok-dialog \ )) # vim: set noet sw=4 ts=4: diff --git a/libreofficekit/qa/gtktiledviewer/gtv-application-window.cxx b/libreofficekit/qa/gtktiledviewer/gtv-application-window.cxx index 118be6c0100d..0b403514e631 100644 --- a/libreofficekit/qa/gtktiledviewer/gtv-application-window.cxx +++ b/libreofficekit/qa/gtktiledviewer/gtv-application-window.cxx @@ -31,13 +31,10 @@ struct GtvApplicationWindowPrivate GtkWidget* gridcontainer; GtkWidget* toolbarcontainer; GtkWidget* scrolledwindowcontainer; - GtkWidget* lokDialog; gboolean toolbarBroadcast; gboolean partSelectorBroadcast; - GList* m_pChildWindows; - // Rendering args; options with which lokdocview was rendered in this window GtvRenderingArgs* m_pRenderingArgs; }; @@ -107,7 +104,6 @@ gtv_application_window_init(GtvApplicationWindow* win) gtk_container_add(GTK_CONTAINER(win), priv->container); - priv->m_pChildWindows = nullptr; priv->m_pRenderingArgs = new GtvRenderingArgs(); } @@ -314,8 +310,6 @@ static void setupDocView(GtvApplicationWindow* window) g_signal_connect(window->lokdocview, "formula-changed", G_CALLBACK(LOKDocViewSigHandlers::formulaChanged), nullptr); g_signal_connect(window->lokdocview, "password-required", G_CALLBACK(LOKDocViewSigHandlers::passwordRequired), nullptr); g_signal_connect(window->lokdocview, "comment", G_CALLBACK(LOKDocViewSigHandlers::comment), nullptr); - g_signal_connect(window->lokdocview, "dialog", G_CALLBACK(LOKDocViewSigHandlers::dialog), nullptr); - g_signal_connect(window->lokdocview, "dialog-child", G_CALLBACK(LOKDocViewSigHandlers::dialogChild), nullptr); g_signal_connect(window->lokdocview, "configure-event", G_CALLBACK(LOKDocViewSigHandlers::configureEvent), nullptr); } @@ -399,60 +393,6 @@ gtv_application_window_get_part_broadcast(GtvApplicationWindow* window) return priv->partSelectorBroadcast; } -void -gtv_application_window_register_child_window(GtvApplicationWindow* window, GtkWindow* pChildWin) -{ - GtvApplicationWindowPrivate* priv = getPrivate(window); - if (pChildWin) - priv->m_pChildWindows = g_list_append(priv->m_pChildWindows, pChildWin); -} - -void -gtv_application_window_unregister_child_window(GtvApplicationWindow* window, GtkWindow* pChildWin) -{ - GtvApplicationWindowPrivate* priv = getPrivate(window); - if (pChildWin) - priv->m_pChildWindows = g_list_remove(priv->m_pChildWindows, pChildWin); -} - -GtkWindow* -gtv_application_window_get_child_window_by_id(GtvApplicationWindow* window, const gchar* pWinId) -{ - GtvApplicationWindowPrivate* priv = getPrivate(window); - GList* pIt = nullptr; - GtkWindow* ret = nullptr; - // For now, only dialogs are registered as child window - for (pIt = priv->m_pChildWindows; pIt != nullptr; pIt = pIt->next) - { - gchar* dialogId = nullptr; - g_object_get(G_OBJECT(pIt->data), "dialogid", &dialogId, nullptr); - - // prepend .uno: - gchar* completeWinId = nullptr; - if (pWinId != nullptr) - { - completeWinId = g_strconcat(".uno:", pWinId, nullptr); - } - - if (dialogId != nullptr && g_str_equal(dialogId, completeWinId)) - { - ret = GTK_WINDOW(pIt->data); - break; - } - } - return ret; -} - -// temporary function to invalidate all opened dialogs -// because currently the dialog id returned in dialog invalidation payload -// doesn't match our hard-coded list of dialog ids (uno commands) for some dialogs -GList* -gtv_application_window_get_all_child_windows(GtvApplicationWindow* window) -{ - GtvApplicationWindowPrivate* priv = getPrivate(window); - return priv->m_pChildWindows; -} - GtvApplicationWindow* gtv_application_window_new(GtkApplication* app) { diff --git a/libreofficekit/qa/gtktiledviewer/gtv-application-window.hxx b/libreofficekit/qa/gtktiledviewer/gtv-application-window.hxx index f0d5afc0513c..8451da564c09 100644 --- a/libreofficekit/qa/gtktiledviewer/gtv-application-window.hxx +++ b/libreofficekit/qa/gtktiledviewer/gtv-application-window.hxx @@ -99,14 +99,6 @@ void gtv_application_window_set_part_broadcast(GtvApplicationWindow* window, boo gboolean gtv_application_window_get_part_broadcast(GtvApplicationWindow* window); -void gtv_application_window_register_child_window(GtvApplicationWindow* window, GtkWindow* pChildWin); - -void gtv_application_window_unregister_child_window(GtvApplicationWindow* window, GtkWindow* pChildWin); - -GtkWindow* gtv_application_window_get_child_window_by_id(GtvApplicationWindow* window, const gchar* pWinId); - -GList* gtv_application_window_get_all_child_windows(GtvApplicationWindow* window); - G_END_DECLS #endif /* GTV_APPLICATION_WINDOW_H */ diff --git a/libreofficekit/qa/gtktiledviewer/gtv-helpers.cxx b/libreofficekit/qa/gtktiledviewer/gtv-helpers.cxx index 9dee02a0ac45..5dca746d5f25 100644 --- a/libreofficekit/qa/gtktiledviewer/gtv-helpers.cxx +++ b/libreofficekit/qa/gtktiledviewer/gtv-helpers.cxx @@ -148,23 +148,4 @@ const std::string GtvHelpers::getDirPath(const std::string& filePath) return dirPath; } -const std::vector<int> GtvHelpers::splitIntoIntegers(const std::string& aPayload, const std::string& aDelim, const int nItems) -{ - std::vector<int> aRet; - - if (!aPayload.empty()) - { - gchar** ppCoordinates = g_strsplit(aPayload.c_str(), aDelim.c_str(), nItems); - gchar** ppCoordinate = ppCoordinates; - while (*ppCoordinate) - { - aRet.push_back(atoi(*ppCoordinate)); - ++ppCoordinate; - } - g_strfreev(ppCoordinates); - } - - return aRet; -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/libreofficekit/qa/gtktiledviewer/gtv-helpers.hxx b/libreofficekit/qa/gtktiledviewer/gtv-helpers.hxx index 9e984846f0ab..e0a2defa72d9 100644 --- a/libreofficekit/qa/gtktiledviewer/gtv-helpers.hxx +++ b/libreofficekit/qa/gtktiledviewer/gtv-helpers.hxx @@ -38,8 +38,6 @@ namespace GtvHelpers GtkWidget* createCommentBox(const boost::property_tree::ptree& aComment); const std::string getDirPath(const std::string& filePath); - - const std::vector<int> splitIntoIntegers(const std::string& aPayload, const std::string& aDelim, const int nItems); } #endif diff --git a/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx b/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx index dfdbc3bc6ca6..f0d926425a5f 100644 --- a/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx +++ b/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx @@ -15,13 +15,10 @@ #include "gtv-calc-header-bar.hxx" #include "gtv-comments-sidebar.hxx" #include "gtv-lokdocview-signal-handlers.hxx" -#include "gtv-lok-dialog.hxx" #include <boost/property_tree/json_parser.hpp> #include <boost/optional.hpp> -#include <iostream> - void LOKDocViewSigHandlers::editChanged(LOKDocView* pDocView, gboolean bWasEdit, gpointer) { GtvApplicationWindow* window = GTV_APPLICATION_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(pDocView))); @@ -283,90 +280,6 @@ void LOKDocViewSigHandlers::comment(LOKDocView* pDocView, gchar* pComment, gpoin } } -void LOKDocViewSigHandlers::dialog(LOKDocView* pDocView, gchar* pPayload, gpointer) -{ - GtvApplicationWindow* window = GTV_APPLICATION_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(pDocView))); - - 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 std::string aAction = aRoot.get<std::string>("action"); - - // we only understand 'invalidate' and 'close' as of now - if (aAction != "invalidate" && aAction != "close") - return; - - GList* pChildWins = gtv_application_window_get_all_child_windows(window); - 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) - { - if (aAction == "close") - gtk_widget_destroy(GTK_WIDGET(pIt->data)); - else if (aAction == "invalidate") - { - GdkRectangle aGdkRectangle = {0, 0, 0, 0}; - try - { - const std::string aRectangle = aRoot.get<std::string>("rectangle"); - std::vector<int> aRectPoints = GtvHelpers::splitIntoIntegers(aRectangle, ", ", 4); - if (aRectPoints.size() == 4) - aGdkRectangle = {aRectPoints[0], aRectPoints[1], aRectPoints[2], aRectPoints[3]}; - } - catch(const std::exception& e) - {} - - gtv_lok_dialog_invalidate(GTV_LOK_DIALOG(pIt->data), aGdkRectangle); - } - } - g_free(pChildDialogId); - } -} - -void LOKDocViewSigHandlers::dialogChild(LOKDocView* pDocView, gchar* pPayload, gpointer) -{ - GtvApplicationWindow* window = GTV_APPLICATION_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(pDocView))); - - 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"); - gchar** ppCoordinates = g_strsplit(aPos.c_str(), ", ", 2); - gchar** ppCoordinate = ppCoordinates; - int nX = 0; - int nY = 0; - - if (*ppCoordinate) - nX = atoi(*ppCoordinate); - ++ppCoordinate; - if (*ppCoordinate) - nY = atoi(*ppCoordinate); - - g_strfreev(ppCoordinates); - - GList* pChildWins = gtv_application_window_get_all_child_windows(window); - 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) - { - 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); - } -} - gboolean LOKDocViewSigHandlers::configureEvent(GtkWidget* pWidget, GdkEventConfigure* /*pEvent*/, gpointer /*pData*/) { GtvApplicationWindow* window = GTV_APPLICATION_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(pWidget))); diff --git a/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.hxx b/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.hxx index 54f54b396bf3..724f2031d4f5 100644 --- a/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.hxx +++ b/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.hxx @@ -25,8 +25,6 @@ namespace LOKDocViewSigHandlers { void formulaChanged(LOKDocView* pDocView, char* pPayload, gpointer); void passwordRequired(LOKDocView* pDocView, char* pUrl, gboolean bModify, gpointer); void comment(LOKDocView* pDocView, gchar* pComment, gpointer); - void dialog(LOKDocView* pDocView, gchar* pDialogId, gpointer); - void dialogChild(LOKDocView* pDocView, gchar* pPayload, gpointer); gboolean configureEvent(GtkWidget* pWidget, GdkEventConfigure* pEvent, gpointer pData); } diff --git a/libreofficekit/qa/gtktiledviewer/gtv-main-toolbar.cxx b/libreofficekit/qa/gtktiledviewer/gtv-main-toolbar.cxx index d18482447a7e..9e280c9d0f1c 100644 --- a/libreofficekit/qa/gtktiledviewer/gtv-main-toolbar.cxx +++ b/libreofficekit/qa/gtktiledviewer/gtv-main-toolbar.cxx @@ -14,7 +14,6 @@ #include "gtv-signal-handlers.hxx" #include "gtv-helpers.hxx" #include "gtv-calc-header-bar.hxx" -#include "gtv-lok-dialog.hxx" #include <map> #include <memory> @@ -35,7 +34,6 @@ struct GtvMainToolbarPrivateImpl GtkWidget* m_pDeleteComment; GtkWidget* m_pPartSelector; GtkWidget* m_pPartModeSelector; - GtkWidget* m_pDialogSelector; /// Sensitivity (enabled or disabled) for each tool item, ignoring edit state std::map<GtkToolItem*, bool> m_aToolItemSensitivities; @@ -50,8 +48,7 @@ struct GtvMainToolbarPrivateImpl m_pJustifypara(nullptr), m_pDeleteComment(nullptr), m_pPartSelector(nullptr), - m_pPartModeSelector(nullptr), - m_pDialogSelector(nullptr) + m_pPartModeSelector(nullptr) { } }; @@ -98,8 +95,6 @@ gtv_main_toolbar_init(GtvMainToolbar* toolbar) priv->m_pDeleteComment = GTK_WIDGET(gtk_builder_get_object(builder.get(), "btn_removeannotation")); priv->m_pPartSelector = GTK_WIDGET(gtk_builder_get_object(builder.get(), "combo_partselector")); priv->m_pPartModeSelector = GTK_WIDGET(gtk_builder_get_object(builder.get(), "combo_partsmodeselector")); - priv->m_pDialogSelector = GTK_WIDGET(gtk_builder_get_object(builder.get(), "combo_dialogselector")); - toolbar->m_pAddressbar = GTK_WIDGET(gtk_builder_get_object(builder.get(), "addressbar_entry")); toolbar->m_pFormulabar = GTK_WIDGET(gtk_builder_get_object(builder.get(), "formulabar_entry")); @@ -119,7 +114,6 @@ gtv_main_toolbar_init(GtvMainToolbar* toolbar) gtk_builder_add_callback_symbol(builder.get(), "documentRepair", G_CALLBACK(documentRepair)); gtk_builder_add_callback_symbol(builder.get(), "signalAddressbar", G_CALLBACK(signalAddressbar)); gtk_builder_add_callback_symbol(builder.get(), "signalFormulabar", G_CALLBACK(signalFormulabar)); - gtk_builder_add_callback_symbol(builder.get(), "openLokDialog", G_CALLBACK(openLokDialog)); // find toolbar // Note: These buttons are not the part of GtvMainToolbar @@ -182,22 +176,6 @@ static void populatePartSelector(GtvMainToolbar* toolbar) gtv_application_window_set_part_broadcast(window, true); } -static void populateDialogSelector(GtvMainToolbar* toolbar) -{ - GtvMainToolbarPrivate& priv = getPrivate(toolbar); - - GtkComboBoxText* pSelector = GTK_COMBO_BOX_TEXT(priv->m_pDialogSelector); - gtk_combo_box_text_append_text( pSelector, ".uno:SearchDialog" ); - gtk_combo_box_text_append_text( pSelector, ".uno:AcceptTrackedChanges" ); - gtk_combo_box_text_append_text( pSelector, ".uno:SpellingAndGrammarDialog" ); - gtk_combo_box_text_append_text( pSelector, ".uno:InsertField" ); - gtk_combo_box_text_append_text( pSelector, ".uno:ImageMapDialog" ); - gtk_combo_box_text_append_text( pSelector, ".uno:WordCountDialog" ); - gtk_combo_box_text_append_text( pSelector, ".uno:HyperlinkDialog" ); - gtk_combo_box_text_append_text( pSelector, ".uno:InsertIndexesEntry" ); - gtk_combo_box_text_append_text( pSelector, ".uno:InsertAuthoritiesEntry"); -} - void gtv_main_toolbar_doc_loaded(GtvMainToolbar* toolbar, LibreOfficeKitDocumentType eDocType, bool bEditMode) { @@ -224,8 +202,6 @@ gtv_main_toolbar_doc_loaded(GtvMainToolbar* toolbar, LibreOfficeKitDocumentType // populate combo boxes populatePartSelector(toolbar); - // populate dialogs - populateDialogSelector(toolbar); } GtkContainer* diff --git a/libreofficekit/qa/gtktiledviewer/gtv-signal-handlers.cxx b/libreofficekit/qa/gtktiledviewer/gtv-signal-handlers.cxx index fee24c6a0f25..60068a8f89d7 100644 --- a/libreofficekit/qa/gtktiledviewer/gtv-signal-handlers.cxx +++ b/libreofficekit/qa/gtktiledviewer/gtv-signal-handlers.cxx @@ -12,7 +12,6 @@ #include "gtv-application-window.hxx" #include "gtv-helpers.hxx" #include "gtv-lokdocview-signal-handlers.hxx" -#include "gtv-lok-dialog.hxx" #include <sal/types.h> @@ -290,40 +289,6 @@ void changePartMode( GtkWidget* pSelector, gpointer /* pItem */ ) } } -static gboolean deleteLokDialog(GtkWidget* pWidget, GdkEvent* /*event*/, gpointer userdata) -{ - GtvApplicationWindow* window = GTV_APPLICATION_WINDOW(userdata); - g_info("deleteLokDialog"); - gtv_application_window_unregister_child_window(window, GTK_WINDOW(pWidget)); - - return FALSE; -} - -static gboolean destroyLokDialog(GtkWidget* pWidget, gpointer userdata) -{ - GtvApplicationWindow* window = GTV_APPLICATION_WINDOW(userdata); - g_info("destroyLokDialog"); - gtv_application_window_unregister_child_window(window, GTK_WINDOW(pWidget)); - - return FALSE; -} - -void openLokDialog( GtkWidget* pSelector, gpointer /*pItem*/ ) -{ - GtvApplicationWindow* window = GTV_APPLICATION_WINDOW(gtk_widget_get_toplevel(pSelector)); - gchar* pDialogId = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(pSelector)); - GtkWidget* pDialog = gtv_lok_dialog_new(LOK_DOC_VIEW(window->lokdocview), pDialogId); - gtv_application_window_register_child_window(window, GTK_WINDOW(pDialog)); - g_signal_connect(pDialog, "destroy", G_CALLBACK(destroyLokDialog), window); - g_signal_connect(pDialog, "delete-event", G_CALLBACK(deleteLokDialog), window); - g_free(pDialogId); - - g_info("openLokDialog"); - gtk_window_set_resizable(GTK_WINDOW(pDialog), false); - gtk_widget_show_all(GTK_WIDGET(pDialog)); - gtk_window_present(GTK_WINDOW(pDialog)); -} - void changeZoom( GtkWidget* pButton, gpointer /* pItem */ ) { static const float fZooms[] = { 0.25, 0.5, 0.75, 1.0, 1.5, 2.0, 3.0, 5.0 }; diff --git a/libreofficekit/qa/gtktiledviewer/gtv-signal-handlers.hxx b/libreofficekit/qa/gtktiledviewer/gtv-signal-handlers.hxx index 80c5c6061f9a..2f9948fe61d7 100644 --- a/libreofficekit/qa/gtktiledviewer/gtv-signal-handlers.hxx +++ b/libreofficekit/qa/gtktiledviewer/gtv-signal-handlers.hxx @@ -30,8 +30,6 @@ void changePartMode( GtkWidget* pSelector, gpointer /* pItem */ ); void changePart( GtkWidget* pSelector, gpointer /*pItem*/ ); -void openLokDialog( GtkWidget* pSelector, gpointer /*pItem*/ ); - void changeZoom( GtkWidget* pButton, gpointer /* pItem */ ); void toggleFindbar(GtkWidget* pButton, gpointer /*pItem*/); diff --git a/libreofficekit/qa/gtktiledviewer/gtv.ui b/libreofficekit/qa/gtktiledviewer/gtv.ui index 7030ecaead5b..966c97e46967 100644 --- a/libreofficekit/qa/gtktiledviewer/gtv.ui +++ b/libreofficekit/qa/gtktiledviewer/gtv.ui @@ -445,23 +445,6 @@ </packing> </child> <child> - <object class="GtkToolItem" id="dialogselectortoolitem"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <child> - <object class="GtkComboBoxText" id="combo_dialogselector"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <signal name="changed" handler="openLokDialog" swapped="no"/> - </object> - </child> - </object> - <packing> - <property name="expand">False</property> - <property name="homogeneous">True</property> - </packing> - </child> - <child> <object class="GtkToggleToolButton" id="btn_editmode"> <property name="visible">True</property> <property name="can_focus">False</property> diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx index 607a8624ecc3..3abc2949cae4 100644 --- a/libreofficekit/source/gtk/lokdocview.cxx +++ b/libreofficekit/source/gtk/lokdocview.cxx @@ -277,8 +277,6 @@ enum PASSWORD_REQUIRED, COMMENT, RULER, - DIALOG, - DIALOG_CHILD, LAST_SIGNAL }; @@ -436,10 +434,6 @@ callbackTypeToString (int nType) return "LOK_CALLBACK_COMMENT"; case LOK_CALLBACK_RULER_UPDATE: return "LOK_CALLBACK_RULER_UPDATE"; - case LOK_CALLBACK_DIALOG: - return "LOK_CALLBACK_DIALOG"; - case LOK_CALLBACK_DIALOG_CHILD: - return "LOK_CALLBACK_DIALOG_CHILD"; } g_assert(false); return nullptr; @@ -816,19 +810,38 @@ signalKey (GtkWidget* pWidget, GdkEventKey* pEvent) } } - GTask* task = g_task_new(pDocView, nullptr, nullptr, nullptr); - LOEvent* pLOEvent = new LOEvent(LOK_POST_KEY); - pLOEvent->m_nKeyEvent = pEvent->type == GDK_KEY_RELEASE ? LOK_KEYEVENT_KEYUP : LOK_KEYEVENT_KEYINPUT; - pLOEvent->m_nCharCode = nCharCode; - pLOEvent->m_nKeyCode = nKeyCode; - g_task_set_task_data(task, pLOEvent, LOEvent::destroy); - g_thread_pool_push(priv->lokThreadPool, g_object_ref(task), &error); - if (error != nullptr) + if (pEvent->type == GDK_KEY_RELEASE) { - g_warning("Unable to call LOK_POST_KEY: %s", error->message); - g_clear_error(&error); + GTask* task = g_task_new(pDocView, nullptr, nullptr, nullptr); + LOEvent* pLOEvent = new LOEvent(LOK_POST_KEY); + pLOEvent->m_nKeyEvent = LOK_KEYEVENT_KEYUP; + pLOEvent->m_nCharCode = nCharCode; + pLOEvent->m_nKeyCode = nKeyCode; + g_task_set_task_data(task, pLOEvent, LOEvent::destroy); + g_thread_pool_push(priv->lokThreadPool, g_object_ref(task), &error); + if (error != nullptr) + { + g_warning("Unable to call LOK_POST_KEY: %s", error->message); + g_clear_error(&error); + } + g_object_unref(task); + } + else + { + GTask* task = g_task_new(pDocView, nullptr, nullptr, nullptr); + LOEvent* pLOEvent = new LOEvent(LOK_POST_KEY); + pLOEvent->m_nKeyEvent = LOK_KEYEVENT_KEYINPUT; + pLOEvent->m_nCharCode = nCharCode; + pLOEvent->m_nKeyCode = nKeyCode; + g_task_set_task_data(task, pLOEvent, LOEvent::destroy); + g_thread_pool_push(priv->lokThreadPool, g_object_ref(task), &error); + if (error != nullptr) + { + g_warning("Unable to call LOK_POST_KEY: %s", error->message); + g_clear_error(&error); + } + g_object_unref(task); } - g_object_unref(task); return FALSE; } @@ -1413,12 +1426,6 @@ callback (gpointer pData) case LOK_CALLBACK_RULER_UPDATE: g_signal_emit(pCallback->m_pDocView, doc_view_signals[RULER], 0, pCallback->m_aPayload.c_str()); break; - case LOK_CALLBACK_DIALOG: - g_signal_emit(pCallback->m_pDocView, doc_view_signals[DIALOG], 0, pCallback->m_aPayload.c_str()); - break; - case LOK_CALLBACK_DIALOG_CHILD: - g_signal_emit(pCallback->m_pDocView, doc_view_signals[DIALOG_CHILD], 0, pCallback->m_aPayload.c_str()); - break; default: g_assert(false); break; @@ -3215,52 +3222,6 @@ static void lok_doc_view_class_init (LOKDocViewClass* pClass) g_cclosure_marshal_generic, G_TYPE_NONE, 1, G_TYPE_STRING); - - /** - * LOKDocView::dialog-invalidate: - * @pDocView: the #LOKDocView on which the signal is emitted - * @pDialogId: The uno command for the dialog (dialog ID) - */ - doc_view_signals[DIALOG] = - g_signal_new("dialog", - G_TYPE_FROM_CLASS(pGObjectClass), - G_SIGNAL_RUN_FIRST, - 0, - nullptr, nullptr, - g_cclosure_marshal_generic, - G_TYPE_NONE, 1, - G_TYPE_STRING); - - /** - * LOKDocView::dialog-child: - * @pDocView: the #LOKDocView on which the signal is emitted - * @pPayload: JSON described below: - * - * Invalidation corresponding to dialog's children. - * Eg: Floating window etc. - * - * Payload example: - * { - * "dialogID": "SpellDialog", - * "action": "close" - * } - * - * - dialogID is the UNO command of the dialog - * - action can be - * - close, means dialog child window is closed now - * - invalidate, means dialog child window is invalidated - * It also means that dialog child window is created if it's the first - * invalidate - */ - doc_view_signals[DIALOG_CHILD] = - g_signal_new("dialog-child", - G_TYPE_FROM_CLASS(pGObjectClass), - G_SIGNAL_RUN_FIRST, - 0, - nullptr, nullptr, - g_cclosure_marshal_generic, - G_TYPE_NONE, 1, - G_TYPE_STRING); } SAL_DLLPUBLIC_EXPORT GtkWidget* diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx index 33464711852f..1597174af5b0 100644 --- a/sfx2/source/view/lokhelper.cxx +++ b/sfx2/source/view/lokhelper.cxx @@ -144,52 +144,6 @@ void SfxLokHelper::notifyOtherViews(SfxViewShell* pThisView, int nType, const OS } } -void SfxLokHelper::notifyDialog(const OUString& rDialogID, - const OUString& rAction, - const std::vector<vcl::LOKPayloadItem>& rPayload) -{ - if (SfxLokHelper::getViewsCount() <= 0 || rDialogID.isEmpty()) - return; - - SfxViewShell* pViewShell = SfxViewShell::GetFirst(); - OString aPayload = OString("{ \"dialogId\": \"") + OUStringToOString(rDialogID, RTL_TEXTENCODING_UTF8).getStr() + OString("\""); - aPayload += OString(", \"action\": \"") + OUStringToOString(rAction, RTL_TEXTENCODING_UTF8).getStr() + OString("\""); - - for (const auto& rItem: rPayload) - { - if (!rItem.first.isEmpty() && !rItem.second.isEmpty()) - { - aPayload += OString(", \"") + rItem.first + OString("\": \"") + - rItem.second + OString("\""); - } - } - aPayload += "}"; - - while (pViewShell) - { - pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_DIALOG, aPayload.getStr()); - pViewShell = SfxViewShell::GetNext(*pViewShell); - } -} - -void SfxLokHelper::notifyDialogChild(const OUString& rDialogID, const OUString& rAction, const Point& rPos) -{ - if (SfxLokHelper::getViewsCount() <= 0 || rDialogID.isEmpty()) - return; - - SfxViewShell* pViewShell = SfxViewShell::GetFirst(); - const OString aPayload = OString("{ \"dialogId\": \"") + OUStringToOString(rDialogID, RTL_TEXTENCODING_UTF8).getStr() + - OString("\", \"action\": \"") + OUStringToOString(rAction, RTL_TEXTENCODING_UTF8).getStr() + - OString("\", \"position\": \"") + OString::number(rPos.getX()) + OString(", ") + OString::number(rPos.getY()) + - + "\" }"; - - while (pViewShell) - { - pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_DIALOG_CHILD, aPayload.getStr()); - pViewShell = SfxViewShell::GetNext(*pViewShell); - } -} - void SfxLokHelper::notifyInvalidation(SfxViewShell const* pThisView, const OString& rPayload) { OStringBuffer aBuf; diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx index e8a995ee3142..3f202c88ae54 100644 --- a/sw/inc/unotxdoc.hxx +++ b/sw/inc/unotxdoc.hxx @@ -70,7 +70,6 @@ #include <cppuhelper/implbase.hxx> #include <vcl/event.hxx> #include <vcl/ITiledRenderable.hxx> -#include <vcl/IDialogRenderable.hxx> #include <com/sun/star/tiledrendering/XTiledRenderable.hpp> #include "unobaseclass.hxx" @@ -132,7 +131,6 @@ class SW_DLLPUBLIC SwXTextDocument : public SwXTextDocumentBaseClass, public SvxFmMSFactory, public SfxBaseModel, public vcl::ITiledRenderable, - public vcl::IDialogRenderable, public css::tiledrendering::XTiledRenderable { private: @@ -431,24 +429,6 @@ public: /// @see vcl::ITiledRenderable::getPostIts(). OUString getPostIts() 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; - - void postDialogMouseEvent(const vcl::DialogID& rDialogID, int nType, int nX, int nY, - int nCount, int nButtons, int nModifier) override; - - void postDialogChildMouseEvent(const vcl::DialogID& rDialogID, int nType, int nX, int nY, - int nCount, int nButtons, int nModifier) override; - - void notifyDialog(const vcl::DialogID& rDialogID, - const OUString& rAction, - const std::vector<vcl::LOKPayloadItem>& rPayload = std::vector<vcl::LOKPayloadItem>()) override; - - void notifyDialogChild(const vcl::DialogID& rDialogID, const OUString& rAction, const Point& rPos) override; - // css::tiledrendering::XTiledRenderable virtual void SAL_CALL paintTile( const ::css::uno::Any& Parent, ::sal_Int32 nOutputWidth, ::sal_Int32 nOutputHeight, ::sal_Int32 nTilePosX, ::sal_Int32 nTilePosY, ::sal_Int32 nTileWidth, ::sal_Int32 nTileHeight ) override; diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx index ce4988f6adc0..a6431a67975f 100644 --- a/sw/source/uibase/uno/unotxdoc.cxx +++ b/sw/source/uibase/uno/unotxdoc.cxx @@ -3639,200 +3639,6 @@ void SAL_CALL SwXTextDocument::paintTile( const ::css::uno::Any& Parent, ::sal_I #endif } -void SwXTextDocument::paintDialog(const vcl::DialogID& rDialogID, VirtualDevice& rDevice) -{ - 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) - { - pViewFrame->ToggleChildWindow(pSlot->GetSlotId()); - pChild = pViewFrame->GetChildWindow(pSlot->GetSlotId()); - if (!pChild) - { - SAL_WARN("lok.dialog", "Dialog " << rDialogID << " is not supported"); - return; - } - } - - Dialog* pDlg = static_cast<Dialog*>(pChild->GetWindow()); - // 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; - - Dialog* pDlg = static_cast<Dialog*>(pChild->GetWindow()); - rDialogTitle = pDlg->GetText(); - const Size aSize = pDlg->GetOptimalSize(); - rWidth = aSize.getWidth(); - rHeight = aSize.getHeight(); -} - -void SwXTextDocument::postDialogKeyEvent(const vcl::DialogID& rDialogID, int nType, int nCharCode, int nKeyCode) -{ - SolarMutexGuard aGuard; - - // check if dialog is already open - 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) - { - Dialog* pDialog = static_cast<Dialog*>(pChild->GetWindow()); - KeyEvent aEvent(nCharCode, nKeyCode, 0); - - switch (nType) - { - case LOK_KEYEVENT_KEYINPUT: - pDialog->LOKKeyInput(aEvent); - break; - case LOK_KEYEVENT_KEYUP: - pDialog->LOKKeyUp(aEvent); - break; - default: - assert(false); - break; - } - } -} - -void SwXTextDocument::postDialogMouseEvent(const vcl::DialogID& rDialogID, int nType, int nX, int nY, - int nCount, int nButtons, int nModifier) -{ - SolarMutexGuard aGuard; - - // check if dialog is already open - 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) - { - Dialog* pDialog = static_cast<Dialog*>(pChild->GetWindow()); - Point aPos(nX , nY); - MouseEvent aEvent(aPos, nCount, MouseEventModifiers::SIMPLECLICK, nButtons, nModifier); - - switch (nType) - { - case LOK_MOUSEEVENT_MOUSEBUTTONDOWN: - pDialog->LogicMouseButtonDown(aEvent); - break; - case LOK_MOUSEEVENT_MOUSEBUTTONUP: - pDialog->LogicMouseButtonUp(aEvent); - break; - case LOK_MOUSEEVENT_MOUSEMOVE: - pDialog->LogicMouseMove(aEvent); - break; - default: - assert(false); - break; - } - } -} - - -void SwXTextDocument::postDialogChildMouseEvent(const vcl::DialogID& rDialogID, int nType, int nX, int nY, - int nCount, int nButtons, int nModifier) -{ - SolarMutexGuard aGuard; - - // check if dialog is already open - 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) - { - Dialog* pDialog = static_cast<Dialog*>(pChild->GetWindow()); - Point aPos(nX , nY); - MouseEvent aEvent(aPos, nCount, MouseEventModifiers::SIMPLECLICK, nButtons, nModifier); - - switch (nType) - { - case LOK_MOUSEEVENT_MOUSEBUTTONDOWN: - pDialog->LogicMouseButtonDownChild(aEvent); - break; - case LOK_MOUSEEVENT_MOUSEBUTTONUP: - pDialog->LogicMouseButtonUpChild(aEvent); - break; - case LOK_MOUSEEVENT_MOUSEMOVE: - pDialog->LogicMouseMoveChild(aEvent); - break; - default: - assert(false); - break; - } - } -} - -void SwXTextDocument::notifyDialog(const vcl::DialogID& rDialogID, - const OUString& rAction, - const std::vector<vcl::LOKPayloadItem>& rPayload) -{ - SfxLokHelper::notifyDialog(rDialogID, rAction, rPayload); -} - -void SwXTextDocument::notifyDialogChild(const vcl::DialogID& rDialogID, const OUString& rAction, const Point& rPos) -{ - SfxLokHelper::notifyDialogChild(rDialogID, rAction, rPos); -} - -void SwXTextDocument::paintActiveFloatingWindow(const vcl::DialogID& rDialogID, VirtualDevice& rDevice, int& nWidth, int& nHeight) -{ - 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; - - Dialog* pDlg = static_cast<Dialog*>(pChild->GetWindow()); - const Size aSize = pDlg->PaintActiveFloatingWindow(rDevice); - nWidth = aSize.getWidth(); - nHeight = aSize.getHeight(); -} - void * SAL_CALL SwXTextDocument::operator new( size_t t) throw() { return SwXTextDocumentBaseClass::operator new(t); |