desktop/qa/desktop_lib/test_desktop_lib.cxx | 4 - desktop/source/lib/init.cxx | 18 +++-- framework/source/dispatch/dispatchdisabler.cxx | 2 include/LibreOfficeKit/LibreOfficeKit.h | 8 +- include/LibreOfficeKit/LibreOfficeKitEnums.h | 17 +++++ include/sal/log-areas.dox | 1 include/sfx2/lokhelper.hxx | 9 +- include/sfx2/objsh.hxx | 7 -- libreofficekit/source/gtk/lokdocview.cxx | 63 ++++++++++++++++--- sc/Module_sc.mk | 7 +- sc/qa/unit/tiledrendering/tiledrendering.cxx | 79 +++++++++++++++++++------ sc/source/ui/docshell/docsh.cxx | 4 - sc/source/ui/inc/docsh.hxx | 2 sc/source/ui/view/gridwin.cxx | 3 sd/source/ui/docshell/docshell.cxx | 4 - sd/source/ui/inc/DrawDocShell.hxx | 2 sfx2/source/doc/objcont.cxx | 5 - sfx2/source/view/lokhelper.cxx | 35 ++++++++--- sw/inc/docsh.hxx | 2 sw/qa/extras/tiledrendering/tiledrendering.cxx | 49 +++++++++++++++ sw/source/core/crsr/viscrs.cxx | 4 - sw/source/uibase/app/docsh.cxx | 4 - 22 files changed, 238 insertions(+), 91 deletions(-)
New commits: commit aac2c25b2396e8df3fd6ae072c22dbe57d1cd33d Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Fri Jul 1 15:04:55 2016 +0200 sc: add LOK_CALLBACK_CELL_VIEW_CURSOR testcase Fails with the sc/source part of commit (sc lok: add LOK_CALLBACK_CELL_VIEW_CURSOR, 2016-07-01) reverted. Reviewed-on: https://gerrit.libreoffice.org/26856 Reviewed-by: Miklos Vajna <vmik...@collabora.co.uk> Tested-by: Jenkins <c...@libreoffice.org> (cherry picked from commit e3c36c789f481b855c0fb556a09f4b81401ed3db) Conflicts: sc/qa/unit/tiledrendering/tiledrendering.cxx Change-Id: I4a1a7d97b744dd089fe15bd58af6cca5e0b79e8f diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx index a5fe1ab6..46b85e6 100644 --- a/sc/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx @@ -12,7 +12,6 @@ #include <test/xmltesttools.hxx> #include <boost/property_tree/json_parser.hpp> -#define LOK_USE_UNSTABLE_API #include <LibreOfficeKit/LibreOfficeKitEnums.h> #include <com/sun/star/frame/Desktop.hpp> #include <comphelper/dispatchcommand.hxx> @@ -28,6 +27,7 @@ #include <svl/srchitem.hxx> #include <comphelper/lok.hxx> +#include <sfx2/lokhelper.hxx> #include <tabvwsh.hxx> #include <docsh.hxx> @@ -36,7 +36,10 @@ using namespace css; -static const char* DATA_DIRECTORY = "/sc/qa/unit/tiledrendering/data/"; +namespace +{ + +const char* DATA_DIRECTORY = "/sc/qa/unit/tiledrendering/data/"; class ScTiledRenderingTest : public test::BootstrapFixture, public unotest::MacrosTest, public XmlTestTools { @@ -49,12 +52,14 @@ public: void testSortAscendingDescending(); void testPartHash(); void testDocumentSize(); + void testViewCursors(); CPPUNIT_TEST_SUITE(ScTiledRenderingTest); CPPUNIT_TEST(testRowColumnSelections); CPPUNIT_TEST(testSortAscendingDescending); CPPUNIT_TEST(testPartHash); CPPUNIT_TEST(testDocumentSize); + CPPUNIT_TEST(testViewCursors); CPPUNIT_TEST_SUITE_END(); private: @@ -325,6 +330,63 @@ void ScTiledRenderingTest::testDocumentSize() comphelper::LibreOfficeKit::setActive(false); } +class ViewCallback +{ +public: + bool m_bOwnCursorInvalidated; + bool m_bViewCursorInvalidated; + + ViewCallback() + : m_bOwnCursorInvalidated(false), + m_bViewCursorInvalidated(false) + { + } + + static void callback(int nType, const char* pPayload, void* pData) + { + static_cast<ViewCallback*>(pData)->callbackImpl(nType, pPayload); + } + + void callbackImpl(int nType, const char* /*pPayload*/) + { + switch (nType) + { + case LOK_CALLBACK_CELL_CURSOR: + { + m_bOwnCursorInvalidated = true; + } + break; + case LOK_CALLBACK_CELL_VIEW_CURSOR: + { + m_bViewCursorInvalidated = true; + } + break; + } + } +}; + + +void ScTiledRenderingTest::testViewCursors() +{ + comphelper::LibreOfficeKit::setActive(); + + ScModelObj* pModelObj = createDoc("select-row-cols.ods"); + ViewCallback aView1; + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1); + SfxLokHelper::createView(); + ViewCallback aView2; + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView2); + pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::DOWN); + pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::DOWN); + Scheduler::ProcessEventsToIdle(); + SfxLokHelper::destroyView(SfxLokHelper::getView()); + CPPUNIT_ASSERT(aView1.m_bViewCursorInvalidated); + + comphelper::LibreOfficeKit::setActive(false); +} + +} + CPPUNIT_TEST_SUITE_REGISTRATION(ScTiledRenderingTest); CPPUNIT_PLUGIN_IMPLEMENT(); commit ebdab327c911e84ca4325d3216cd3a0cd204dff6 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Fri Jul 1 12:00:44 2016 +0200 CppunitTest_sc_tiledrendering: replace ifdefs with a single makefile condition Reviewed-on: https://gerrit.libreoffice.org/26849 Reviewed-by: Miklos Vajna <vmik...@collabora.co.uk> Tested-by: Jenkins <c...@libreoffice.org> (cherry picked from commit 8e3451c096987e6fc7eaca409fd45a62e13ae4c5) Conflicts: sc/qa/unit/tiledrendering/tiledrendering.cxx Change-Id: I1dded11e0572dee7cd917a1aa8c2e2ca53b81d84 diff --git a/sc/Module_sc.mk b/sc/Module_sc.mk index e135e30..438b861 100644 --- a/sc/Module_sc.mk +++ b/sc/Module_sc.mk @@ -47,9 +47,14 @@ $(eval $(call gb_Module_add_check_targets,sc,\ CppunitTest_sc_filters_test \ CppunitTest_sc_rangelst_test \ CppunitTest_sc_core \ - CppunitTest_sc_tiledrendering \ )) +ifeq ($(OS),LINUX) +$(eval $(call gb_Module_add_check_targets,sc,\ + CppunitTest_sc_tiledrendering \ +)) +endif + $(eval $(call gb_Module_add_slowcheck_targets,sc, \ CppunitTest_sc_condformats \ CppunitTest_sc_new_cond_format_api \ diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx index ea042d8..a5fe1ab6 100644 --- a/sc/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx @@ -36,9 +36,7 @@ using namespace css; -#if !defined(WNT) && !defined(MACOSX) static const char* DATA_DIRECTORY = "/sc/qa/unit/tiledrendering/data/"; -#endif class ScTiledRenderingTest : public test::BootstrapFixture, public unotest::MacrosTest, public XmlTestTools { @@ -47,42 +45,32 @@ public: virtual void setUp() SAL_OVERRIDE; virtual void tearDown() SAL_OVERRIDE; -#if !defined(WNT) && !defined(MACOSX) void testRowColumnSelections(); void testSortAscendingDescending(); void testPartHash(); void testDocumentSize(); -#endif CPPUNIT_TEST_SUITE(ScTiledRenderingTest); -#if !defined(WNT) && !defined(MACOSX) CPPUNIT_TEST(testRowColumnSelections); CPPUNIT_TEST(testSortAscendingDescending); CPPUNIT_TEST(testPartHash); CPPUNIT_TEST(testDocumentSize); -#endif CPPUNIT_TEST_SUITE_END(); private: -#if !defined(WNT) && !defined(MACOSX) ScModelObj* createDoc(const char* pName); static void callback(int nType, const char* pPayload, void* pData); void callbackImpl(int nType, const char* pPayload); /// document size changed callback. osl::Condition m_aDocSizeCondition; -#endif uno::Reference<lang::XComponent> mxComponent; -#if !defined(WNT) && !defined(MACOSX) // TODO various test-related members - when needed -#endif }; ScTiledRenderingTest::ScTiledRenderingTest() -#if !defined(WNT) && !defined(MACOSX) // TODO various test-related members - when needed -#endif { } @@ -101,7 +89,6 @@ void ScTiledRenderingTest::tearDown() test::BootstrapFixture::tearDown(); } -#if !defined(WNT) && !defined(MACOSX) ScModelObj* ScTiledRenderingTest::createDoc(const char* pName) { if (mxComponent.is()) @@ -338,8 +325,6 @@ void ScTiledRenderingTest::testDocumentSize() comphelper::LibreOfficeKit::setActive(false); } -#endif - CPPUNIT_TEST_SUITE_REGISTRATION(ScTiledRenderingTest); CPPUNIT_PLUGIN_IMPLEMENT(); commit 47d95f1166a2d2855e9a1fe3c9810bed6c2f0831 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Fri Jul 1 10:55:27 2016 +0200 sc lok: add LOK_CALLBACK_CELL_VIEW_CURSOR So a view can be aware where the cell cursors of other views are. Change-Id: Ifcf06c0019c6af8b859e2e92222e4f3fd18da74f Reviewed-on: https://gerrit.libreoffice.org/26844 Reviewed-by: Miklos Vajna <vmik...@collabora.co.uk> Tested-by: Jenkins <c...@libreoffice.org> (cherry picked from commit 68c5c0bb7eed007bbfbb2e51107fc0196825e85a) diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 1d14d75..e8df4df 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -478,6 +478,7 @@ CallbackFlushHandler::CallbackFlushHandler(LibreOfficeKitDocument* pDocument, Li m_states.emplace(LOK_CALLBACK_STATE_CHANGED, "NIL"); m_states.emplace(LOK_CALLBACK_MOUSE_POINTER, "NIL"); m_states.emplace(LOK_CALLBACK_CELL_CURSOR, "NIL"); + m_states.emplace(LOK_CALLBACK_CELL_VIEW_CURSOR, "NIL"); m_states.emplace(LOK_CALLBACK_CELL_FORMULA, "NIL"); m_states.emplace(LOK_CALLBACK_CURSOR_VISIBLE, "NIL"); m_states.emplace(LOK_CALLBACK_SET_PART, "NIL"); @@ -580,6 +581,7 @@ void CallbackFlushHandler::queue(const int type, const char* data) case LOK_CALLBACK_GRAPHIC_SELECTION: case LOK_CALLBACK_MOUSE_POINTER: case LOK_CALLBACK_CELL_CURSOR: + case LOK_CALLBACK_CELL_VIEW_CURSOR: case LOK_CALLBACK_CELL_FORMULA: case LOK_CALLBACK_CURSOR_VISIBLE: case LOK_CALLBACK_SET_PART: diff --git a/include/LibreOfficeKit/LibreOfficeKitEnums.h b/include/LibreOfficeKit/LibreOfficeKitEnums.h index 4dfb8be..c687879 100644 --- a/include/LibreOfficeKit/LibreOfficeKitEnums.h +++ b/include/LibreOfficeKit/LibreOfficeKitEnums.h @@ -329,7 +329,7 @@ typedef enum LOK_CALLBACK_INVALIDATE_VIEW_CURSOR, /** - * The the text selection in one of the other views has changed. + * The text selection in one of the other views has changed. * * The payload format: * @@ -343,6 +343,21 @@ typedef enum */ LOK_CALLBACK_TEXT_VIEW_SELECTION, + /** + * The cell cursor in one of the other views has changed. + * + * The payload format: + * + * { + * "viewId": "..." + * "rectangle": "..." + * } + * + * - viewId is a value returned earlier by lok::Document::createView() + * - rectangle uses the format of LOK_CALLBACK_CELL_CURSOR. + */ + LOK_CALLBACK_CELL_VIEW_CURSOR, + } LibreOfficeKitCallbackType; diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx index e36a1c3..c79e098 100644 --- a/libreofficekit/source/gtk/lokdocview.cxx +++ b/libreofficekit/source/gtk/lokdocview.cxx @@ -102,6 +102,9 @@ struct LOKDocViewPrivateImpl GdkRectangle m_aTextSelectionEnd; GdkRectangle m_aGraphicSelection; GdkRectangle m_aCellCursor; + /// Position and size of the cell view cursors. The current view can only + //see / them, can't modify them. Key is the view id. + std::map<int, GdkRectangle> m_aCellViewCursors; gboolean m_bInDragGraphicSelection; /// @name Start/middle/end handle. @@ -355,7 +358,12 @@ callbackTypeToString (int nType) return "LOK_CALLBACK_INVALIDATE_VIEW_CURSOR"; case LOK_CALLBACK_TEXT_VIEW_SELECTION: return "LOK_CALLBACK_TEXT_VIEW_SELECTION"; + case LOK_CALLBACK_CELL_VIEW_CURSOR: + return "LOK_CALLBACK_CELL_VIEW_CURSOR"; + case LOK_CALLBACK_CELL_FORMULA: + return "LOK_CALLBACK_CELL_FORMULA"; } + g_assert(false); return nullptr; } @@ -1187,6 +1195,24 @@ callback (gpointer pData) gtk_widget_queue_draw(GTK_WIDGET(pDocView)); break; } + case LOK_CALLBACK_CELL_VIEW_CURSOR: + { + std::stringstream aStream(pCallback->m_aPayload); + boost::property_tree::ptree aTree; + boost::property_tree::read_json(aStream, aTree); + int nViewId = aTree.get<int>("viewId"); + const std::string& rRectangle = aTree.get<std::string>("rectangle"); + if (rRectangle != "EMPTY") + priv->m_aCellViewCursors[nViewId] = payloadToRectangle(pDocView, rRectangle.c_str()); + else + { + auto it = priv->m_aCellViewCursors.find(nViewId); + if (it != priv->m_aCellViewCursors.end()) + priv->m_aCellViewCursors.erase(it); + } + gtk_widget_queue_draw(GTK_WIDGET(pDocView)); + break; + } default: g_assert(false); break; @@ -1574,6 +1600,7 @@ renderOverlay(LOKDocView* pDocView, cairo_t* pCairo) g_free (handleGraphicPath); } + // Draw the cell cursor. if (!isEmptyRectangle(priv->m_aCellCursor)) { cairo_set_source_rgb(pCairo, 0, 0, 0); @@ -1590,6 +1617,22 @@ renderOverlay(LOKDocView* pDocView, cairo_t* pCairo) cairo_stroke(pCairo); } + // Cell view cursors: they are colored. + for (auto& rPair : priv->m_aCellViewCursors) + { + GdkRectangle& rCursor = rPair.second; + + const GdkRGBA& rDark = getDarkColor(rPair.first); + cairo_set_source_rgb(pCairo, rDark.red, rDark.green, rDark.blue); + cairo_rectangle(pCairo, + twipToPixel(rCursor.x, priv->m_fZoom), + twipToPixel(rCursor.y, priv->m_fZoom), + twipToPixel(rCursor.width, priv->m_fZoom), + twipToPixel(rCursor.height, priv->m_fZoom)); + cairo_set_line_width(pCairo, 2.0); + cairo_stroke(pCairo); + } + return FALSE; } diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index e279da2..4e6d9c6 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -136,6 +136,7 @@ #include <svx/sdr/overlay/overlayselection.hxx> #include <comphelper/string.hxx> #include <comphelper/lok.hxx> +#include <sfx2/lokhelper.hxx> #include <LibreOfficeKit/LibreOfficeKitEnums.h> #include <comphelper/lok.hxx> @@ -5853,6 +5854,7 @@ void ScGridWindow::updateLibreOfficeKitCellCursor() OString aCursor = getCellCursor(pViewData->GetZoomX(), pViewData->GetZoomY()); ScTabViewShell* pViewShell = pViewData->GetViewShell(); pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_CELL_CURSOR, aCursor.getStr()); + SfxLokHelper::notifyOtherViews(pViewShell, LOK_CALLBACK_CELL_VIEW_CURSOR, "rectangle", aCursor); } void ScGridWindow::CursorChanged() @@ -5897,6 +5899,7 @@ void ScGridWindow::DeleteCursorOverlay() { ScTabViewShell* pViewShell = pViewData->GetViewShell(); pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_CELL_CURSOR, "EMPTY"); + SfxLokHelper::notifyOtherViews(pViewShell, LOK_CALLBACK_CELL_VIEW_CURSOR, "rectangle", "EMPTY"); mpOOCursors.reset(); } commit 0c93c4b9788dd3746a43556ea683465b16d5660a Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Thu Jun 30 12:40:49 2016 +0200 sw lok: mix missing invalidation due to page calc in visible cursor change Steps to reproduce in gtktiledviewer: - two windows, then enable edit in both - view #0: go inside a word - view #1: select the same word - press Del in view #1 -> no invalidation Fix the problem by changing the LOK-specific GetPageNum() call in SwVisibleCursor::SetPosAndShow(), so that it doesn't re-calculate the frame, that way later when SwLayAction::TurboAction_() attempts to re-calculate the layout, then the frame will be still invalid, and that re-calculation then triggers the necessary invalidations. Change-Id: I8c4472b9809537fcbd4a20c73f39be7ebca16b1f Reviewed-on: https://gerrit.libreoffice.org/26802 Reviewed-by: Miklos Vajna <vmik...@collabora.co.uk> Tested-by: Jenkins <c...@libreoffice.org> (cherry picked from commit 6168f10b6280b2d60de44a333f3f1dc23cbb9bcf) diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx index 6998023..e43d0717 100644 --- a/sw/qa/extras/tiledrendering/tiledrendering.cxx +++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx @@ -53,6 +53,7 @@ public: void testPageDownInvalidation(); void testPartHash(); void testViewCursors(); + void testMissingInvalidation(); CPPUNIT_TEST_SUITE(SwTiledRenderingTest); CPPUNIT_TEST(testRegisterCallback); @@ -72,6 +73,7 @@ public: CPPUNIT_TEST(testPageDownInvalidation); CPPUNIT_TEST(testPartHash); CPPUNIT_TEST(testViewCursors); + CPPUNIT_TEST(testMissingInvalidation); CPPUNIT_TEST_SUITE_END(); private: @@ -551,12 +553,14 @@ public: bool m_bViewCursorInvalidated; bool m_bOwnSelectionSet; bool m_bViewSelectionSet; + bool m_bTilesInvalidated; ViewCallback() : m_bOwnCursorInvalidated(false), m_bViewCursorInvalidated(false), m_bOwnSelectionSet(false), - m_bViewSelectionSet(false) + m_bViewSelectionSet(false), + m_bTilesInvalidated(false) { } @@ -569,6 +573,11 @@ public: { switch (nType) { + case LOK_CALLBACK_INVALIDATE_TILES: + { + m_bTilesInvalidated = true; + } + break; case LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR: { m_bOwnCursorInvalidated = true; @@ -593,6 +602,44 @@ public: } }; +void SwTiledRenderingTest::testMissingInvalidation() +{ + comphelper::LibreOfficeKit::setActive(); + + // Create two views. + SwXTextDocument* pXTextDocument = createDoc("dummy.fodt"); + ViewCallback aView1; + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1); + int nView1 = SfxLokHelper::getView(); + SfxLokHelper::createView(); + ViewCallback aView2; + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView2); + int nView2 = SfxLokHelper::getView(); + + // First view: put the cursor into the first word. + SfxLokHelper::setView(nView1); + SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell(); + pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/false, 1, /*bBasicCall=*/false); + + // Second view: select the first word. + SfxLokHelper::setView(nView2); + CPPUNIT_ASSERT(pXTextDocument->GetDocShell()->GetWrtShell() != pWrtShell); + pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell(); + pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/false, 1, /*bBasicCall=*/false); + pWrtShell->SelWrd(); + + // Now delete the selected word and make sure both views are invalidated. + aView1.m_bTilesInvalidated = false; + aView2.m_bTilesInvalidated = false; + pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::DELETE); + pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::DELETE); + Scheduler::ProcessEventsToIdle(); + CPPUNIT_ASSERT(aView1.m_bTilesInvalidated); + CPPUNIT_ASSERT(aView2.m_bTilesInvalidated); + + comphelper::LibreOfficeKit::setActive(false); +} + void SwTiledRenderingTest::testViewCursors() { comphelper::LibreOfficeKit::setActive(); diff --git a/sw/source/core/crsr/viscrs.cxx b/sw/source/core/crsr/viscrs.cxx index 585a0f4..2c0ca9e 100644 --- a/sw/source/core/crsr/viscrs.cxx +++ b/sw/source/core/crsr/viscrs.cxx @@ -186,7 +186,9 @@ void SwVisibleCursor::_SetPosAndShow() { // notify about page number change (if that happened) sal_uInt16 nPage, nVirtPage; - const_cast<SwCursorShell*>(m_pCursorShell)->GetPageNum(nPage, nVirtPage); + // bCalcFrame=false is important to avoid calculating the layout when + // we're in the middle of doing that already. + const_cast<SwCursorShell*>(m_pCursorShell)->GetPageNum(nPage, nVirtPage, /*bAtCursorPos=*/true, /*bCalcFrame=*/false); if (nPage != m_nPageLastTime) { m_nPageLastTime = nPage; commit 8e739f68cc863107e9782f1453f2c6370c6874ec Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Thu Jun 30 09:13:52 2016 +0200 lokdocview: avoid pointless setView() before getView() This fixes the following use-case: 1) Start gtktiledviewer, click New View 2) Click Edit in the first view 3) Click somewhere in the document in the first view -> nothing happens Change-Id: I79d63538607f03b78851a639adf158d918745276 Reviewed-on: https://gerrit.libreoffice.org/26789 Reviewed-by: Miklos Vajna <vmik...@collabora.co.uk> Tested-by: Jenkins <c...@libreoffice.org> (cherry picked from commit bfd4234fd863ee75f4f07d9bded061063bbde3d4) diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx index e1eca74..e36a1c3 100644 --- a/libreofficekit/source/gtk/lokdocview.cxx +++ b/libreofficekit/source/gtk/lokdocview.cxx @@ -842,10 +842,6 @@ static gboolean postDocumentLoad(gpointer pData) LOKDocViewPrivate& priv = getPrivate(pLOKDocView); std::unique_lock<std::mutex> aGuard(g_aLOKMutex); - std::stringstream ss; - ss << "lok::Document::setView(" << priv->m_nViewId << ")"; - g_info("%s", ss.str().c_str()); - priv->m_pDocument->pClass->setView(priv->m_pDocument, priv->m_nViewId); priv->m_pDocument->pClass->initializeForRendering(priv->m_pDocument, priv->m_aRenderingArguments.c_str()); priv->m_nViewId = priv->m_pDocument->pClass->getView(priv->m_pDocument); priv->m_pDocument->pClass->registerCallback(priv->m_pDocument, callbackWorker, pLOKDocView); commit 87251b0c5d769020a8469064a7e4be9c36a5f1ee Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Wed Jun 29 17:27:04 2016 +0200 LOK: change back type of view ids to int Commit 45c2410041c48c22bd860efb42d4daadad7869b0 (LOK: change type of view ids to uintptr_t, 2016-06-17) fixed the problem of view IDs being reused for the price of random IDs, which makes debugging harder. Implement a simple shellToView() function that makes sure view IDs are not reused, and stop exposing view shell pointer addresses, which allows reverting the LOK API change. Change-Id: I63089e6de08ee7e1c7706757d43a11f6cf4d6e06 Reviewed-on: https://gerrit.libreoffice.org/26773 Reviewed-by: Miklos Vajna <vmik...@collabora.co.uk> Tested-by: Jenkins <c...@libreoffice.org> (cherry picked from commit 615c37503cffa92a663245d7cb140f316ace0506) diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index f59370b..74a75ed 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -294,8 +294,8 @@ void DesktopLOKTest::testCreateView() LibLODocument_Impl* pDocument = loadDoc("blank_text.odt"); CPPUNIT_ASSERT_EQUAL(1, pDocument->m_pDocumentClass->getViews(pDocument)); - std::uintptr_t nId0 = pDocument->m_pDocumentClass->getView(pDocument); - std::uintptr_t nId1 = pDocument->m_pDocumentClass->createView(pDocument); + int nId0 = pDocument->m_pDocumentClass->getView(pDocument); + int nId1 = pDocument->m_pDocumentClass->createView(pDocument); CPPUNIT_ASSERT_EQUAL(2, pDocument->m_pDocumentClass->getViews(pDocument)); // Make sure the created view is the active one, then switch to the old diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 6f7df98..1d14d75 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -392,10 +392,10 @@ static void doc_setClientZoom(LibreOfficeKitDocument* pThis, int nTileTwipWidth, int nTileTwipHeight); static void doc_setClientVisibleArea(LibreOfficeKitDocument* pThis, int nX, int nY, int nWidth, int nHeight); -static uintptr_t doc_createView(LibreOfficeKitDocument* pThis); -static void doc_destroyView(LibreOfficeKitDocument* pThis, uintptr_t nId); -static void doc_setView(LibreOfficeKitDocument* pThis, uintptr_t nId); -static uintptr_t doc_getView(LibreOfficeKitDocument* pThis); +static int doc_createView(LibreOfficeKitDocument* pThis); +static void doc_destroyView(LibreOfficeKitDocument* pThis, int nId); +static void doc_setView(LibreOfficeKitDocument* pThis, int nId); +static int doc_getView(LibreOfficeKitDocument* pThis); static int doc_getViews(LibreOfficeKitDocument* pThis); static unsigned char* doc_renderFont(LibreOfficeKitDocument* pThis, const char *pFontName, @@ -1937,28 +1937,28 @@ static void doc_setClientVisibleArea(LibreOfficeKitDocument* pThis, int nX, int pDoc->setClientVisibleArea(aRectangle); } -static uintptr_t doc_createView(LibreOfficeKitDocument* /*pThis*/) +static int doc_createView(LibreOfficeKitDocument* /*pThis*/) { SolarMutexGuard aGuard; return SfxLokHelper::createView(); } -static void doc_destroyView(LibreOfficeKitDocument* /*pThis*/, uintptr_t nId) +static void doc_destroyView(LibreOfficeKitDocument* /*pThis*/, int nId) { SolarMutexGuard aGuard; SfxLokHelper::destroyView(nId); } -static void doc_setView(LibreOfficeKitDocument* /*pThis*/, uintptr_t nId) +static void doc_setView(LibreOfficeKitDocument* /*pThis*/, int nId) { SolarMutexGuard aGuard; SfxLokHelper::setView(nId); } -static uintptr_t doc_getView(LibreOfficeKitDocument* /*pThis*/) +static int doc_getView(LibreOfficeKitDocument* /*pThis*/) { SolarMutexGuard aGuard; diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h index 559d28a..81d65c1 100644 --- a/include/LibreOfficeKit/LibreOfficeKit.h +++ b/include/LibreOfficeKit/LibreOfficeKit.h @@ -212,13 +212,13 @@ struct _LibreOfficeKitDocumentClass void (*setClientVisibleArea) (LibreOfficeKitDocument* pThis, int nX, int nY, int nWidth, int nHeight); /// @see lok::Document::createView(). - uintptr_t (*createView) (LibreOfficeKitDocument* pThis); + int (*createView) (LibreOfficeKitDocument* pThis); /// @see lok::Document::destroyView(). - void (*destroyView) (LibreOfficeKitDocument* pThis, uintptr_t nId); + void (*destroyView) (LibreOfficeKitDocument* pThis, int nId); /// @see lok::Document::setView(). - void (*setView) (LibreOfficeKitDocument* pThis, uintptr_t nId); + void (*setView) (LibreOfficeKitDocument* pThis, int nId); /// @see lok::Document::getView(). - uintptr_t (*getView) (LibreOfficeKitDocument* pThis); + int (*getView) (LibreOfficeKitDocument* pThis); /// @see lok::Document::getViews(). int (*getViews) (LibreOfficeKitDocument* pThis); diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx index 4cfe081..e7dfed4 100644 --- a/include/sfx2/lokhelper.hxx +++ b/include/sfx2/lokhelper.hxx @@ -12,7 +12,6 @@ #include <sfx2/dllapi.h> #include <cstddef> -#include <cstdint> #include <rtl/string.hxx> class SfxViewShell; @@ -21,13 +20,13 @@ class SFX2_DLLPUBLIC SfxLokHelper { public: /// Create a new view shell from the current view frame. - static std::uintptr_t createView(); + static int createView(); /// Destroy a view shell from the global shell list. - static void destroyView(std::uintptr_t nId); + static void destroyView(int nId); /// Set a view shell as current one. - static void setView(std::uintptr_t nId); + static void setView(int nId); /// Get the currently active view. - static std::uintptr_t getView(SfxViewShell* pViewShell = nullptr); + static int getView(SfxViewShell* pViewShell = nullptr); /// Get the number of views of the current object shell. static std::size_t getViews(); diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx index 6e2a343..e1eca74 100644 --- a/libreofficekit/source/gtk/lokdocview.cxx +++ b/libreofficekit/source/gtk/lokdocview.cxx @@ -78,7 +78,7 @@ struct LOKDocViewPrivateImpl GdkRectangle m_aVisibleCursor; /// Position and size of the view cursors. The current view can only see /// them, can't modify them. Key is the view id. - std::map<std::uintptr_t, GdkRectangle> m_aViewCursors; + std::map<int, GdkRectangle> m_aViewCursors; /// Cursor overlay is visible or hidden (for blinking). gboolean m_bCursorOverlayVisible; /// Cursor is visible or hidden (e.g. for graphic selection). @@ -95,7 +95,7 @@ struct LOKDocViewPrivateImpl std::vector<GdkRectangle> m_aTextSelectionRectangles; /// Rectangles of view selections. The current view can only see /// them, can't modify them. Key is the view id. - std::map<std::uintptr_t, std::vector<GdkRectangle>> m_aTextViewSelectionRectangles; + std::map<int, std::vector<GdkRectangle>> m_aTextViewSelectionRectangles; /// Position and size of the selection start (as if there would be a cursor caret there). GdkRectangle m_aTextSelectionStart; /// Position and size of the selection end. @@ -137,7 +137,7 @@ struct LOKDocViewPrivateImpl ///@} /// View ID, returned by createView() or 0 by default. - std::uintptr_t m_nViewId; + int m_nViewId; /** * Contains a freshly set zoom level: logic size of a tile. @@ -1174,7 +1174,7 @@ callback (gpointer pData) std::stringstream aStream(pCallback->m_aPayload); boost::property_tree::ptree aTree; boost::property_tree::read_json(aStream, aTree); - std::uintptr_t nViewId = aTree.get<std::uintptr_t>("viewId"); + int nViewId = aTree.get<int>("viewId"); const std::string& rRectangle = aTree.get<std::string>("rectangle"); priv->m_aViewCursors[nViewId] = payloadToRectangle(pDocView, rRectangle.c_str()); gtk_widget_queue_draw(GTK_WIDGET(pDocView)); @@ -1185,7 +1185,7 @@ callback (gpointer pData) std::stringstream aStream(pCallback->m_aPayload); boost::property_tree::ptree aTree; boost::property_tree::read_json(aStream, aTree); - std::uintptr_t nViewId = aTree.get<std::uintptr_t>("viewId"); + int nViewId = aTree.get<int>("viewId"); const std::string& rSelection = aTree.get<std::string>("selection"); priv->m_aTextViewSelectionRectangles[nViewId] = payloadToRectangles(pDocView, rSelection.c_str()); gtk_widget_queue_draw(GTK_WIDGET(pDocView)); @@ -1428,9 +1428,9 @@ renderDocument(LOKDocView* pDocView, cairo_t* pCairo) return FALSE; } -static const GdkRGBA& getDarkColor(std::uintptr_t nViewId) +static const GdkRGBA& getDarkColor(int nViewId) { - static std::map<std::uintptr_t, GdkRGBA> aColorMap; + static std::map<int, GdkRGBA> aColorMap; auto it = aColorMap.find(nViewId); if (it != aColorMap.end()) return it->second; @@ -1550,7 +1550,7 @@ renderOverlay(LOKDocView* pDocView, cairo_t* pCairo) } // Selections of other views. - for (std::pair<const std::uintptr_t, std::vector<GdkRectangle>>& rPair : priv->m_aTextViewSelectionRectangles) + for (std::pair<const int, std::vector<GdkRectangle>>& rPair : priv->m_aTextViewSelectionRectangles) { for (GdkRectangle& rRectangle : rPair.second) { diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx index b44392c..653dd7f 100644 --- a/sfx2/source/view/lokhelper.cxx +++ b/sfx2/source/view/lokhelper.cxx @@ -17,23 +17,42 @@ #include <shellimpl.hxx> -std::uintptr_t SfxLokHelper::createView() +namespace +{ + +/// Assigns a view ID to a view shell. +int shellToView(SfxViewShell* pViewShell) +{ + // Deleted view shells are not removed from this map, so view IDs are not + // reused when deleting, then creating a view. + static std::map<SfxViewShell*, int> aViewMap; + auto it = aViewMap.find(pViewShell); + if (it != aViewMap.end()) + return it->second; + + int nViewId = aViewMap.size(); + aViewMap[pViewShell] = nViewId; + return nViewId; +} +} + +int SfxLokHelper::createView() { SfxViewFrame* pViewFrame = SfxViewFrame::Current(); SfxRequest aRequest(pViewFrame, SID_NEWWINDOW); pViewFrame->ExecView_Impl(aRequest); - return reinterpret_cast<std::uintptr_t>(SfxViewShell::Current()); + return shellToView(SfxViewShell::Current()); } -void SfxLokHelper::destroyView(std::uintptr_t nId) +void SfxLokHelper::destroyView(int nId) { SfxViewShellArr_Impl& rViewArr = SfxGetpApp()->GetViewShells_Impl(); for (std::size_t i = 0; i < rViewArr.size(); ++i) { SfxViewShell* pViewShell = rViewArr[i]; - if (reinterpret_cast<std::uintptr_t>(pViewShell) == nId) + if (shellToView(pViewShell) == nId) { SfxViewFrame* pViewFrame = pViewShell->GetViewFrame(); SfxRequest aRequest(pViewFrame, SID_CLOSEWIN); @@ -43,14 +62,14 @@ void SfxLokHelper::destroyView(std::uintptr_t nId) } } -void SfxLokHelper::setView(std::uintptr_t nId) +void SfxLokHelper::setView(int nId) { SfxViewShellArr_Impl& rViewArr = SfxGetpApp()->GetViewShells_Impl(); for (std::size_t i = 0; i < rViewArr.size(); ++i) { SfxViewShell* pViewShell = rViewArr[i]; - if (reinterpret_cast<std::uintptr_t>(pViewShell) == nId) + if (shellToView(pViewShell) == nId) { if (pViewShell == SfxViewShell::Current()) return; @@ -63,11 +82,11 @@ void SfxLokHelper::setView(std::uintptr_t nId) } -std::uintptr_t SfxLokHelper::getView(SfxViewShell* pViewShell) +int SfxLokHelper::getView(SfxViewShell* pViewShell) { if (!pViewShell) pViewShell = SfxViewShell::Current(); - return reinterpret_cast<std::uintptr_t>(pViewShell); + return shellToView(pViewShell); } std::size_t SfxLokHelper::getViews() commit 43ebf466fef79b055e4a905ab4abf18da190180a Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Wed Jun 29 15:55:11 2016 +0200 framework: fix typo in dispatchdisabler maDisabledURLs is a set, aDisabledURLs is a sequence, the intention is to copy the set into the sequence, not to copy the (empty) set into itself. Change-Id: Ib262e863b1f1aa4c455bd7552df3dc2c3f73a400 Reviewed-on: https://gerrit.libreoffice.org/26765 Reviewed-by: Miklos Vajna <vmik...@collabora.co.uk> Tested-by: Jenkins <c...@libreoffice.org> (cherry picked from commit f4f580f4a4683ab09c94cfd2dfa9d203881e3eb5) diff --git a/framework/source/dispatch/dispatchdisabler.cxx b/framework/source/dispatch/dispatchdisabler.cxx index 608b18d..5f410af 100644 --- a/framework/source/dispatch/dispatchdisabler.cxx +++ b/framework/source/dispatch/dispatchdisabler.cxx @@ -95,7 +95,7 @@ uno::Sequence< OUString > SAL_CALL { uno::Sequence< OUString > aDisabledURLs(maDisabledURLs.size()); sal_Int32 n = 0; - for (auto i = aDisabledURLs.begin(); i != aDisabledURLs.end(); ++i) + for (auto i = maDisabledURLs.begin(); i != maDisabledURLs.end(); ++i) aDisabledURLs[n++] = *i; return aDisabledURLs; } commit 918a02ba8ba9a35fdd2c2ea2ad6864de0c7cb7c5 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Thu Jun 23 08:47:05 2016 +0200 Remove unused SfxObjectShell::libreOfficeKitCallback() All clients have been converted to use SfxViewShell::libreOfficeKitViewCallback() instead. Change-Id: I793dad5194769f331037b12a1b1afba96ddea4ba Reviewed-on: https://gerrit.libreoffice.org/26584 Reviewed-by: Miklos Vajna <vmik...@collabora.co.uk> Tested-by: Jenkins <c...@libreoffice.org> (cherry picked from commit ed2d342e97e43ff25f450ab6a5752baded6813e4) diff --git a/include/sal/log-areas.dox b/include/sal/log-areas.dox index 310fb12..04ad05a 100644 --- a/include/sal/log-areas.dox +++ b/include/sal/log-areas.dox @@ -305,7 +305,6 @@ certain functionality. @li @c sfx.doc @li @c sfx.notify @li @c sfx.sidebar -@li @c sfx.tiledrendering @li @c sfx.view @section slideshow diff --git a/include/sfx2/objsh.hxx b/include/sfx2/objsh.hxx index d799846..edc3ee4 100644 --- a/include/sfx2/objsh.hxx +++ b/include/sfx2/objsh.hxx @@ -723,13 +723,6 @@ public: SAL_DLLPRIVATE void CancelCheckOut( ); SAL_DLLPRIVATE void CheckIn( ); SAL_DLLPRIVATE css::uno::Sequence< css::document::CmisVersion > GetCmisVersions(); - - /** - * Interface shared by document shell. Allow LOK calls from sfx. - * Default behavior doesn't do anything. relevant SfxObjectShells should override - * the default behavior and implements LOK calls. - */ - virtual void libreOfficeKitCallback(int nType, const char* pPayload) const; }; #define SFX_GLOBAL_CLASSID \ diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx index a2ac691..73936d6 100644 --- a/sc/source/ui/docshell/docsh.cxx +++ b/sc/source/ui/docshell/docsh.cxx @@ -3195,8 +3195,4 @@ bool ScDocShell::GetProtectionHash( /*out*/ css::uno::Sequence< sal_Int8 > &rPas return bRes; } -void ScDocShell::libreOfficeKitCallback(int /*nType*/, const char* /*pPayload*/) const -{ -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/docsh.hxx b/sc/source/ui/inc/docsh.hxx index bf228f7..7780e7d 100644 --- a/sc/source/ui/inc/docsh.hxx +++ b/sc/source/ui/inc/docsh.hxx @@ -422,8 +422,6 @@ public: virtual bool GetProtectionHash( /*out*/ css::uno::Sequence< sal_Int8 > &rPasswordHash ) override; void SnapVisArea( Rectangle& rRect ) const; - - virtual void libreOfficeKitCallback(int nType, const char* pPayload) const override; }; void UpdateAcceptChangesDialog(); diff --git a/sd/source/ui/docshell/docshell.cxx b/sd/source/ui/docshell/docshell.cxx index e9afba0..4c2e87d 100644 --- a/sd/source/ui/docshell/docshell.cxx +++ b/sd/source/ui/docshell/docshell.cxx @@ -464,10 +464,6 @@ void DrawDocShell::ClearUndoBuffer() pUndoManager->Clear(); } -void DrawDocShell::libreOfficeKitCallback(int /*nType*/, const char* /*pPayload*/) const -{ -} - } // end of namespace sd /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/inc/DrawDocShell.hxx b/sd/source/ui/inc/DrawDocShell.hxx index b43f84b..b355c59 100644 --- a/sd/source/ui/inc/DrawDocShell.hxx +++ b/sd/source/ui/inc/DrawDocShell.hxx @@ -203,8 +203,6 @@ public: void ClearUndoBuffer(); - virtual void libreOfficeKitCallback(int nType, const char* pPayload) const override; - protected: SdDrawDocument* mpDoc; diff --git a/sfx2/source/doc/objcont.cxx b/sfx2/source/doc/objcont.cxx index bd8d904..1b5584c 100644 --- a/sfx2/source/doc/objcont.cxx +++ b/sfx2/source/doc/objcont.cxx @@ -652,9 +652,4 @@ bool SfxObjectShell::IsModifyPasswordEntered() return pImp->m_bModifyPasswordEntered; } -void SfxObjectShell::libreOfficeKitCallback(int /*nType*/, const char* /*pPayload*/) const -{ - SAL_INFO("sfx.tiledrendering", "SfxObjectShell::libreOfficeKitCallback interface not overridden for SfxObjectShell subclass typeId: " << typeid(*this).name()); -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/inc/docsh.hxx b/sw/inc/docsh.hxx index 84774c17..83e4fad 100644 --- a/sw/inc/docsh.hxx +++ b/sw/inc/docsh.hxx @@ -308,8 +308,6 @@ public: virtual void SetChangeRecording( bool bActivate ) override; virtual bool SetProtectionPassword( const OUString &rPassword ) override; virtual bool GetProtectionHash( /*out*/ css::uno::Sequence< sal_Int8 > &rPasswordHash ) override; - - virtual void libreOfficeKitCallback(int nType, const char* pPayload) const override; }; /** Find the right DocShell and create a new one: diff --git a/sw/source/uibase/app/docsh.cxx b/sw/source/uibase/app/docsh.cxx index efd8962..e112b71 100644 --- a/sw/source/uibase/app/docsh.cxx +++ b/sw/source/uibase/app/docsh.cxx @@ -1337,8 +1337,4 @@ bool SwDocShell::GetProtectionHash( /*out*/ css::uno::Sequence< sal_Int8 > &rPas return bRes; } -void SwDocShell::libreOfficeKitCallback(int /*nType*/, const char* /*pPayload*/) const -{ -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits