diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-06-16 16:45:21 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-06-16 16:19:10 +0000 |
commit | 5bf3ae663a2189e37959235cda8c6a4051e10a1a (patch) | |
tree | 8f5c8348355a009425c7c82780a6b63605775ef9 | |
parent | e841ed93d6c6d817be1f7fdc18ff971325c861cc (diff) |
comphelper: enable LibreOfficeKit::isViewCallback() by default
This requires porting the sw/sd/sc_tiledrendering test code to the new
internal API, as only the public LOK API is unchanged.
Change-Id: Ic6a2f96421da4a16bdee7d0cbb3f6e35bc6ddff9
Reviewed-on: https://gerrit.libreoffice.org/26379
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
-rw-r--r-- | comphelper/source/misc/lok.cxx | 2 | ||||
-rw-r--r-- | desktop/README.vars | 2 | ||||
-rw-r--r-- | desktop/source/lib/init.cxx | 2 | ||||
-rw-r--r-- | libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx | 2 | ||||
-rw-r--r-- | sc/qa/unit/tiledrendering/tiledrendering.cxx | 14 | ||||
-rw-r--r-- | sd/qa/unit/tiledrendering/tiledrendering.cxx | 22 | ||||
-rw-r--r-- | sw/qa/extras/tiledrendering/tiledrendering.cxx | 22 |
7 files changed, 39 insertions, 27 deletions
diff --git a/comphelper/source/misc/lok.cxx b/comphelper/source/misc/lok.cxx index 279ec65c600c..f9c9031d05cb 100644 --- a/comphelper/source/misc/lok.cxx +++ b/comphelper/source/misc/lok.cxx @@ -17,7 +17,7 @@ namespace LibreOfficeKit static bool g_bActive(false); -static bool g_bViewCallback(false); +static bool g_bViewCallback(true); void setActive(bool bActive) { diff --git a/desktop/README.vars b/desktop/README.vars index b84a2700c710..39e3aaa20436 100644 --- a/desktop/README.vars +++ b/desktop/README.vars @@ -13,4 +13,4 @@ LibreOfficeKit -------------- LOK_DEBUG - Draw a small red rectangle in the top left corner so that it's easy to see where a new tile begins. -LOK_VIEW_CALLBACK - Use incomplete per-view callbacks instead of a single one. +LOK_MODEL_CALLBACK - Use old document-global callback instead of multiple per-view ones. diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 5237d2942a4e..bd31b9b54e2a 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -2136,7 +2136,7 @@ static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath, const char if (eStage != SECOND_INIT) comphelper::LibreOfficeKit::setActive(); - static bool bViewCallback = getenv("LOK_VIEW_CALLBACK"); + static bool bViewCallback = !getenv("LOK_MODEL_CALLBACK"); comphelper::LibreOfficeKit::setViewCallback(bViewCallback); if (eStage != PRE_INIT) diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx index 7a261be03bee..60c8bd713ac1 100644 --- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx +++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx @@ -1314,7 +1314,7 @@ static GtkWidget* createWindow(TiledWindow& rWindow) gtk_toolbar_insert(GTK_TOOLBAR(pUpperToolbar), pUnoCmdDebugger, -1); g_signal_connect(G_OBJECT(pUnoCmdDebugger), "clicked", G_CALLBACK(unoCommandDebugger), nullptr); - static bool bViewCallback = getenv("LOK_VIEW_CALLBACK"); + static bool bViewCallback = !getenv("LOK_MODEL_CALLBACK"); if (bViewCallback) { GtkToolItem* pNewViewButton = gtk_tool_button_new( nullptr, nullptr); diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx index 858ed3a6a8d9..168987ca7ed5 100644 --- a/sc/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx @@ -308,19 +308,19 @@ void ScTiledRenderingTest::testDocumentSize() { comphelper::LibreOfficeKit::setActive(); ScModelObj* pModelObj = createDoc("sort-range.ods"); - pModelObj->registerCallback(&ScTiledRenderingTest::callback, this); - - // check initial document size - Size aDocSize = pModelObj->getDocumentSize(); - CPPUNIT_ASSERT(aDocSize.Width() > 0); - CPPUNIT_ASSERT(aDocSize.Height() > 0); - ScDocShell* pDocSh = dynamic_cast< ScDocShell* >( pModelObj->GetEmbeddedObject() ); CPPUNIT_ASSERT(pDocSh); ScTabViewShell* pViewShell = pDocSh->GetBestViewShell(false); CPPUNIT_ASSERT(pViewShell); + pViewShell->registerLibreOfficeKitViewCallback(&ScTiledRenderingTest::callback, this); + + // check initial document size + Size aDocSize = pModelObj->getDocumentSize(); + CPPUNIT_ASSERT(aDocSize.Width() > 0); + CPPUNIT_ASSERT(aDocSize.Height() > 0); + // Set cursor column pViewShell->SetCursor(100, 0); // 2 seconds diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx index 1d5fb5c78232..4d3ed11e4218 100644 --- a/sd/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx @@ -28,6 +28,7 @@ #include <svx/svdotable.hxx> #include <DrawDocShell.hxx> +#include <ViewShellBase.hxx> #include <ViewShell.hxx> #include <sdpage.hxx> #include <unomodel.hxx> @@ -258,8 +259,8 @@ xmlDocPtr SdTiledRenderingTest::parseXmlDump() void SdTiledRenderingTest::testRegisterCallback() { SdXImpressDocument* pXImpressDocument = createDoc("dummy.odp"); - pXImpressDocument->registerCallback(&SdTiledRenderingTest::callback, this); sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell(); + pViewShell->GetViewShellBase().registerLibreOfficeKitViewCallback(&SdTiledRenderingTest::callback, this); // Start text edit of the empty title shape. SdPage* pActualPage = pViewShell->GetActualPage(); @@ -443,14 +444,14 @@ void SdTiledRenderingTest::testSearch() { comphelper::LibreOfficeKit::setActive(); SdXImpressDocument* pXImpressDocument = createDoc("dummy.odp"); - pXImpressDocument->registerCallback(&SdTiledRenderingTest::callback, this); + sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell(); + pViewShell->GetViewShellBase().registerLibreOfficeKitViewCallback(&SdTiledRenderingTest::callback, this); uno::Reference<container::XIndexAccess> xDrawPage(pXImpressDocument->getDrawPages()->getByIndex(0), uno::UNO_QUERY); uno::Reference<text::XTextRange> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY); xShape->setString("Aaa bbb."); lcl_search("bbb"); - sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell(); SdrView* pView = pViewShell->GetView(); EditView& rEditView = pView->GetTextEditOutlinerView()->GetEditView(); // Did we indeed manage to select the second word? @@ -478,7 +479,8 @@ void SdTiledRenderingTest::testSearchAll() { comphelper::LibreOfficeKit::setActive(); SdXImpressDocument* pXImpressDocument = createDoc("search-all.odp"); - pXImpressDocument->registerCallback(&SdTiledRenderingTest::callback, this); + sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell(); + pViewShell->GetViewShellBase().registerLibreOfficeKitViewCallback(&SdTiledRenderingTest::callback, this); lcl_search("match", /*bFindAll=*/true); @@ -498,7 +500,8 @@ void SdTiledRenderingTest::testSearchAllSelections() { comphelper::LibreOfficeKit::setActive(); SdXImpressDocument* pXImpressDocument = createDoc("search-all.odp"); - pXImpressDocument->registerCallback(&SdTiledRenderingTest::callback, this); + sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell(); + pViewShell->GetViewShellBase().registerLibreOfficeKitViewCallback(&SdTiledRenderingTest::callback, this); lcl_search("third", /*bFindAll=*/true); // Make sure this is found on the 3rd slide. @@ -512,7 +515,8 @@ void SdTiledRenderingTest::testSearchAllNotifications() { comphelper::LibreOfficeKit::setActive(); SdXImpressDocument* pXImpressDocument = createDoc("search-all.odp"); - pXImpressDocument->registerCallback(&SdTiledRenderingTest::callback, this); + sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell(); + pViewShell->GetViewShellBase().registerLibreOfficeKitViewCallback(&SdTiledRenderingTest::callback, this); lcl_search("third", /*bFindAll=*/true); // Make sure that we get no notifications about selection changes during search. @@ -526,7 +530,8 @@ void SdTiledRenderingTest::testSearchAllFollowedBySearch() { comphelper::LibreOfficeKit::setActive(); SdXImpressDocument* pXImpressDocument = createDoc("search-all.odp"); - pXImpressDocument->registerCallback(&SdTiledRenderingTest::callback, this); + sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell(); + pViewShell->GetViewShellBase().registerLibreOfficeKitViewCallback(&SdTiledRenderingTest::callback, this); lcl_search("third", /*bFindAll=*/true); lcl_search("match" /*,bFindAll=false*/); @@ -559,7 +564,8 @@ void SdTiledRenderingTest::testInsertDeletePage() { comphelper::LibreOfficeKit::setActive(); SdXImpressDocument* pXImpressDocument = createDoc("insert-delete.odp"); - pXImpressDocument->registerCallback(&SdTiledRenderingTest::callback, this); + sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell(); + pViewShell->GetViewShellBase().registerLibreOfficeKitViewCallback(&SdTiledRenderingTest::callback, this); SdDrawDocument* pDoc = pXImpressDocument->GetDocShell()->GetDoc(); CPPUNIT_ASSERT(pDoc); diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx index d0203afde5b9..5eed6d174683 100644 --- a/sw/qa/extras/tiledrendering/tiledrendering.cxx +++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx @@ -25,6 +25,7 @@ #include <drawdoc.hxx> #include <ndtxt.hxx> #include <wrtsh.hxx> +#include <sfx2/viewsh.hxx> static const char* DATA_DIRECTORY = "/sw/qa/extras/tiledrendering/data/"; @@ -169,8 +170,8 @@ void SwTiledRenderingTest::testRegisterCallback() { comphelper::LibreOfficeKit::setActive(); SwXTextDocument* pXTextDocument = createDoc("dummy.fodt"); - pXTextDocument->registerCallback(&SwTiledRenderingTest::callback, this); SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell(); + pWrtShell->GetSfxViewShell()->registerLibreOfficeKitViewCallback(&SwTiledRenderingTest::callback, this); // Insert a character at the beginning of the document. pWrtShell->Insert("x"); @@ -339,8 +340,8 @@ void SwTiledRenderingTest::testSearch() comphelper::LibreOfficeKit::setActive(); SwXTextDocument* pXTextDocument = createDoc("search.odt"); - pXTextDocument->registerCallback(&SwTiledRenderingTest::callback, this); SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell(); + pWrtShell->GetSfxViewShell()->registerLibreOfficeKitViewCallback(&SwTiledRenderingTest::callback, this); std::size_t nNode = pWrtShell->getShellCursor(false)->Start()->nNode.GetNode().GetIndex(); // First hit, in the second paragraph, before the shape. @@ -408,7 +409,8 @@ void SwTiledRenderingTest::testSearchTextFrame() comphelper::LibreOfficeKit::setActive(); SwXTextDocument* pXTextDocument = createDoc("search.odt"); - pXTextDocument->registerCallback(&SwTiledRenderingTest::callback, this); + SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell(); + pWrtShell->GetSfxViewShell()->registerLibreOfficeKitViewCallback(&SwTiledRenderingTest::callback, this); uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence( { {"SearchItem.SearchString", uno::makeAny(OUString("TextFrame"))}, @@ -424,7 +426,8 @@ void SwTiledRenderingTest::testSearchTextFrame() void SwTiledRenderingTest::testSearchTextFrameWrapAround() { SwXTextDocument* pXTextDocument = createDoc("search.odt"); - pXTextDocument->registerCallback(&SwTiledRenderingTest::callback, this); + SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell(); + pWrtShell->GetSfxViewShell()->registerLibreOfficeKitViewCallback(&SwTiledRenderingTest::callback, this); uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence( { {"SearchItem.SearchString", uno::makeAny(OUString("TextFrame"))}, @@ -442,8 +445,8 @@ void SwTiledRenderingTest::testDocumentSizeChanged() comphelper::LibreOfficeKit::setActive(); // Get the current document size. SwXTextDocument* pXTextDocument = createDoc("2-pages.odt"); - pXTextDocument->registerCallback(&SwTiledRenderingTest::callback, this); SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell(); + pWrtShell->GetSfxViewShell()->registerLibreOfficeKitViewCallback(&SwTiledRenderingTest::callback, this); Size aSize = pXTextDocument->getDocumentSize(); // Delete the second page and see how the size changes. @@ -461,7 +464,8 @@ void SwTiledRenderingTest::testSearchAll() comphelper::LibreOfficeKit::setActive(); SwXTextDocument* pXTextDocument = createDoc("search.odt"); - pXTextDocument->registerCallback(&SwTiledRenderingTest::callback, this); + SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell(); + pWrtShell->GetSfxViewShell()->registerLibreOfficeKitViewCallback(&SwTiledRenderingTest::callback, this); uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence( { {"SearchItem.SearchString", uno::makeAny(OUString("shape"))}, @@ -481,7 +485,8 @@ void SwTiledRenderingTest::testSearchAllNotifications() { comphelper::LibreOfficeKit::setActive(); SwXTextDocument* pXTextDocument = createDoc("search.odt"); - pXTextDocument->registerCallback(&SwTiledRenderingTest::callback, this); + SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell(); + pWrtShell->GetSfxViewShell()->registerLibreOfficeKitViewCallback(&SwTiledRenderingTest::callback, this); uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence( { {"SearchItem.SearchString", uno::makeAny(OUString("shape"))}, @@ -509,7 +514,8 @@ void SwTiledRenderingTest::testPageDownInvalidation() {".uno:HideWhitespace", uno::makeAny(true)}, })); pXTextDocument->initializeForTiledRendering(aPropertyValues); - pXTextDocument->registerCallback(&SwTiledRenderingTest::callback, this); + SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell(); + pWrtShell->GetSfxViewShell()->registerLibreOfficeKitViewCallback(&SwTiledRenderingTest::callback, this); comphelper::dispatchCommand(".uno:PageDown", uno::Sequence<beans::PropertyValue>()); // This was 2. |