[Libreoffice-commits] core.git: comphelper/source desktop/README.vars desktop/source libreofficekit/qa sc/qa sd/qa sw/qa

Miklos Vajna vmiklos at collabora.co.uk
Thu Jun 16 16:19:43 UTC 2016


 comphelper/source/misc/lok.cxx                      |    2 -
 desktop/README.vars                                 |    2 -
 desktop/source/lib/init.cxx                         |    2 -
 libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx |    2 -
 sc/qa/unit/tiledrendering/tiledrendering.cxx        |   14 ++++++------
 sd/qa/unit/tiledrendering/tiledrendering.cxx        |   22 ++++++++++++--------
 sw/qa/extras/tiledrendering/tiledrendering.cxx      |   22 ++++++++++++--------
 7 files changed, 39 insertions(+), 27 deletions(-)

New commits:
commit 5bf3ae663a2189e37959235cda8c6a4051e10a1a
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Jun 16 16:45:21 2016 +0200

    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 at collabora.co.uk>
    Tested-by: Jenkins <ci at libreoffice.org>

diff --git a/comphelper/source/misc/lok.cxx b/comphelper/source/misc/lok.cxx
index 279ec65..f9c9031 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 b84a270..39e3aaa 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 5237d29..bd31b9b5 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 7a261be..60c8bd7 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 858ed3a..168987c 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 1d5fb5c..4d3ed11 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 d0203af..5eed6d1 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.


More information about the Libreoffice-commits mailing list