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>
This commit is contained in:
@@ -17,7 +17,7 @@ namespace LibreOfficeKit
|
|||||||
|
|
||||||
static bool g_bActive(false);
|
static bool g_bActive(false);
|
||||||
|
|
||||||
static bool g_bViewCallback(false);
|
static bool g_bViewCallback(true);
|
||||||
|
|
||||||
void setActive(bool bActive)
|
void setActive(bool bActive)
|
||||||
{
|
{
|
||||||
|
@@ -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_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.
|
||||||
|
@@ -2136,7 +2136,7 @@ static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath, const char
|
|||||||
if (eStage != SECOND_INIT)
|
if (eStage != SECOND_INIT)
|
||||||
comphelper::LibreOfficeKit::setActive();
|
comphelper::LibreOfficeKit::setActive();
|
||||||
|
|
||||||
static bool bViewCallback = getenv("LOK_VIEW_CALLBACK");
|
static bool bViewCallback = !getenv("LOK_MODEL_CALLBACK");
|
||||||
comphelper::LibreOfficeKit::setViewCallback(bViewCallback);
|
comphelper::LibreOfficeKit::setViewCallback(bViewCallback);
|
||||||
|
|
||||||
if (eStage != PRE_INIT)
|
if (eStage != PRE_INIT)
|
||||||
|
@@ -1314,7 +1314,7 @@ static GtkWidget* createWindow(TiledWindow& rWindow)
|
|||||||
gtk_toolbar_insert(GTK_TOOLBAR(pUpperToolbar), pUnoCmdDebugger, -1);
|
gtk_toolbar_insert(GTK_TOOLBAR(pUpperToolbar), pUnoCmdDebugger, -1);
|
||||||
g_signal_connect(G_OBJECT(pUnoCmdDebugger), "clicked", G_CALLBACK(unoCommandDebugger), nullptr);
|
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)
|
if (bViewCallback)
|
||||||
{
|
{
|
||||||
GtkToolItem* pNewViewButton = gtk_tool_button_new( nullptr, nullptr);
|
GtkToolItem* pNewViewButton = gtk_tool_button_new( nullptr, nullptr);
|
||||||
|
@@ -308,19 +308,19 @@ void ScTiledRenderingTest::testDocumentSize()
|
|||||||
{
|
{
|
||||||
comphelper::LibreOfficeKit::setActive();
|
comphelper::LibreOfficeKit::setActive();
|
||||||
ScModelObj* pModelObj = createDoc("sort-range.ods");
|
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() );
|
ScDocShell* pDocSh = dynamic_cast< ScDocShell* >( pModelObj->GetEmbeddedObject() );
|
||||||
CPPUNIT_ASSERT(pDocSh);
|
CPPUNIT_ASSERT(pDocSh);
|
||||||
|
|
||||||
ScTabViewShell* pViewShell = pDocSh->GetBestViewShell(false);
|
ScTabViewShell* pViewShell = pDocSh->GetBestViewShell(false);
|
||||||
CPPUNIT_ASSERT(pViewShell);
|
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
|
// Set cursor column
|
||||||
pViewShell->SetCursor(100, 0);
|
pViewShell->SetCursor(100, 0);
|
||||||
// 2 seconds
|
// 2 seconds
|
||||||
|
@@ -28,6 +28,7 @@
|
|||||||
#include <svx/svdotable.hxx>
|
#include <svx/svdotable.hxx>
|
||||||
|
|
||||||
#include <DrawDocShell.hxx>
|
#include <DrawDocShell.hxx>
|
||||||
|
#include <ViewShellBase.hxx>
|
||||||
#include <ViewShell.hxx>
|
#include <ViewShell.hxx>
|
||||||
#include <sdpage.hxx>
|
#include <sdpage.hxx>
|
||||||
#include <unomodel.hxx>
|
#include <unomodel.hxx>
|
||||||
@@ -258,8 +259,8 @@ xmlDocPtr SdTiledRenderingTest::parseXmlDump()
|
|||||||
void SdTiledRenderingTest::testRegisterCallback()
|
void SdTiledRenderingTest::testRegisterCallback()
|
||||||
{
|
{
|
||||||
SdXImpressDocument* pXImpressDocument = createDoc("dummy.odp");
|
SdXImpressDocument* pXImpressDocument = createDoc("dummy.odp");
|
||||||
pXImpressDocument->registerCallback(&SdTiledRenderingTest::callback, this);
|
|
||||||
sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
|
sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
|
||||||
|
pViewShell->GetViewShellBase().registerLibreOfficeKitViewCallback(&SdTiledRenderingTest::callback, this);
|
||||||
|
|
||||||
// Start text edit of the empty title shape.
|
// Start text edit of the empty title shape.
|
||||||
SdPage* pActualPage = pViewShell->GetActualPage();
|
SdPage* pActualPage = pViewShell->GetActualPage();
|
||||||
@@ -443,14 +444,14 @@ void SdTiledRenderingTest::testSearch()
|
|||||||
{
|
{
|
||||||
comphelper::LibreOfficeKit::setActive();
|
comphelper::LibreOfficeKit::setActive();
|
||||||
SdXImpressDocument* pXImpressDocument = createDoc("dummy.odp");
|
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<container::XIndexAccess> xDrawPage(pXImpressDocument->getDrawPages()->getByIndex(0), uno::UNO_QUERY);
|
||||||
uno::Reference<text::XTextRange> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY);
|
uno::Reference<text::XTextRange> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY);
|
||||||
xShape->setString("Aaa bbb.");
|
xShape->setString("Aaa bbb.");
|
||||||
|
|
||||||
lcl_search("bbb");
|
lcl_search("bbb");
|
||||||
|
|
||||||
sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
|
|
||||||
SdrView* pView = pViewShell->GetView();
|
SdrView* pView = pViewShell->GetView();
|
||||||
EditView& rEditView = pView->GetTextEditOutlinerView()->GetEditView();
|
EditView& rEditView = pView->GetTextEditOutlinerView()->GetEditView();
|
||||||
// Did we indeed manage to select the second word?
|
// Did we indeed manage to select the second word?
|
||||||
@@ -478,7 +479,8 @@ void SdTiledRenderingTest::testSearchAll()
|
|||||||
{
|
{
|
||||||
comphelper::LibreOfficeKit::setActive();
|
comphelper::LibreOfficeKit::setActive();
|
||||||
SdXImpressDocument* pXImpressDocument = createDoc("search-all.odp");
|
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);
|
lcl_search("match", /*bFindAll=*/true);
|
||||||
|
|
||||||
@@ -498,7 +500,8 @@ void SdTiledRenderingTest::testSearchAllSelections()
|
|||||||
{
|
{
|
||||||
comphelper::LibreOfficeKit::setActive();
|
comphelper::LibreOfficeKit::setActive();
|
||||||
SdXImpressDocument* pXImpressDocument = createDoc("search-all.odp");
|
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("third", /*bFindAll=*/true);
|
||||||
// Make sure this is found on the 3rd slide.
|
// Make sure this is found on the 3rd slide.
|
||||||
@@ -512,7 +515,8 @@ void SdTiledRenderingTest::testSearchAllNotifications()
|
|||||||
{
|
{
|
||||||
comphelper::LibreOfficeKit::setActive();
|
comphelper::LibreOfficeKit::setActive();
|
||||||
SdXImpressDocument* pXImpressDocument = createDoc("search-all.odp");
|
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("third", /*bFindAll=*/true);
|
||||||
// Make sure that we get no notifications about selection changes during search.
|
// Make sure that we get no notifications about selection changes during search.
|
||||||
@@ -526,7 +530,8 @@ void SdTiledRenderingTest::testSearchAllFollowedBySearch()
|
|||||||
{
|
{
|
||||||
comphelper::LibreOfficeKit::setActive();
|
comphelper::LibreOfficeKit::setActive();
|
||||||
SdXImpressDocument* pXImpressDocument = createDoc("search-all.odp");
|
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("third", /*bFindAll=*/true);
|
||||||
lcl_search("match" /*,bFindAll=false*/);
|
lcl_search("match" /*,bFindAll=false*/);
|
||||||
@@ -559,7 +564,8 @@ void SdTiledRenderingTest::testInsertDeletePage()
|
|||||||
{
|
{
|
||||||
comphelper::LibreOfficeKit::setActive();
|
comphelper::LibreOfficeKit::setActive();
|
||||||
SdXImpressDocument* pXImpressDocument = createDoc("insert-delete.odp");
|
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();
|
SdDrawDocument* pDoc = pXImpressDocument->GetDocShell()->GetDoc();
|
||||||
CPPUNIT_ASSERT(pDoc);
|
CPPUNIT_ASSERT(pDoc);
|
||||||
|
@@ -25,6 +25,7 @@
|
|||||||
#include <drawdoc.hxx>
|
#include <drawdoc.hxx>
|
||||||
#include <ndtxt.hxx>
|
#include <ndtxt.hxx>
|
||||||
#include <wrtsh.hxx>
|
#include <wrtsh.hxx>
|
||||||
|
#include <sfx2/viewsh.hxx>
|
||||||
|
|
||||||
static const char* DATA_DIRECTORY = "/sw/qa/extras/tiledrendering/data/";
|
static const char* DATA_DIRECTORY = "/sw/qa/extras/tiledrendering/data/";
|
||||||
|
|
||||||
@@ -169,8 +170,8 @@ void SwTiledRenderingTest::testRegisterCallback()
|
|||||||
{
|
{
|
||||||
comphelper::LibreOfficeKit::setActive();
|
comphelper::LibreOfficeKit::setActive();
|
||||||
SwXTextDocument* pXTextDocument = createDoc("dummy.fodt");
|
SwXTextDocument* pXTextDocument = createDoc("dummy.fodt");
|
||||||
pXTextDocument->registerCallback(&SwTiledRenderingTest::callback, this);
|
|
||||||
SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
|
SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
|
||||||
|
pWrtShell->GetSfxViewShell()->registerLibreOfficeKitViewCallback(&SwTiledRenderingTest::callback, this);
|
||||||
// Insert a character at the beginning of the document.
|
// Insert a character at the beginning of the document.
|
||||||
pWrtShell->Insert("x");
|
pWrtShell->Insert("x");
|
||||||
|
|
||||||
@@ -339,8 +340,8 @@ void SwTiledRenderingTest::testSearch()
|
|||||||
comphelper::LibreOfficeKit::setActive();
|
comphelper::LibreOfficeKit::setActive();
|
||||||
|
|
||||||
SwXTextDocument* pXTextDocument = createDoc("search.odt");
|
SwXTextDocument* pXTextDocument = createDoc("search.odt");
|
||||||
pXTextDocument->registerCallback(&SwTiledRenderingTest::callback, this);
|
|
||||||
SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
|
SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
|
||||||
|
pWrtShell->GetSfxViewShell()->registerLibreOfficeKitViewCallback(&SwTiledRenderingTest::callback, this);
|
||||||
std::size_t nNode = pWrtShell->getShellCursor(false)->Start()->nNode.GetNode().GetIndex();
|
std::size_t nNode = pWrtShell->getShellCursor(false)->Start()->nNode.GetNode().GetIndex();
|
||||||
|
|
||||||
// First hit, in the second paragraph, before the shape.
|
// First hit, in the second paragraph, before the shape.
|
||||||
@@ -408,7 +409,8 @@ void SwTiledRenderingTest::testSearchTextFrame()
|
|||||||
comphelper::LibreOfficeKit::setActive();
|
comphelper::LibreOfficeKit::setActive();
|
||||||
|
|
||||||
SwXTextDocument* pXTextDocument = createDoc("search.odt");
|
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(
|
uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence(
|
||||||
{
|
{
|
||||||
{"SearchItem.SearchString", uno::makeAny(OUString("TextFrame"))},
|
{"SearchItem.SearchString", uno::makeAny(OUString("TextFrame"))},
|
||||||
@@ -424,7 +426,8 @@ void SwTiledRenderingTest::testSearchTextFrame()
|
|||||||
void SwTiledRenderingTest::testSearchTextFrameWrapAround()
|
void SwTiledRenderingTest::testSearchTextFrameWrapAround()
|
||||||
{
|
{
|
||||||
SwXTextDocument* pXTextDocument = createDoc("search.odt");
|
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(
|
uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence(
|
||||||
{
|
{
|
||||||
{"SearchItem.SearchString", uno::makeAny(OUString("TextFrame"))},
|
{"SearchItem.SearchString", uno::makeAny(OUString("TextFrame"))},
|
||||||
@@ -442,8 +445,8 @@ void SwTiledRenderingTest::testDocumentSizeChanged()
|
|||||||
comphelper::LibreOfficeKit::setActive();
|
comphelper::LibreOfficeKit::setActive();
|
||||||
// Get the current document size.
|
// Get the current document size.
|
||||||
SwXTextDocument* pXTextDocument = createDoc("2-pages.odt");
|
SwXTextDocument* pXTextDocument = createDoc("2-pages.odt");
|
||||||
pXTextDocument->registerCallback(&SwTiledRenderingTest::callback, this);
|
|
||||||
SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
|
SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
|
||||||
|
pWrtShell->GetSfxViewShell()->registerLibreOfficeKitViewCallback(&SwTiledRenderingTest::callback, this);
|
||||||
Size aSize = pXTextDocument->getDocumentSize();
|
Size aSize = pXTextDocument->getDocumentSize();
|
||||||
|
|
||||||
// Delete the second page and see how the size changes.
|
// Delete the second page and see how the size changes.
|
||||||
@@ -461,7 +464,8 @@ void SwTiledRenderingTest::testSearchAll()
|
|||||||
comphelper::LibreOfficeKit::setActive();
|
comphelper::LibreOfficeKit::setActive();
|
||||||
|
|
||||||
SwXTextDocument* pXTextDocument = createDoc("search.odt");
|
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(
|
uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence(
|
||||||
{
|
{
|
||||||
{"SearchItem.SearchString", uno::makeAny(OUString("shape"))},
|
{"SearchItem.SearchString", uno::makeAny(OUString("shape"))},
|
||||||
@@ -481,7 +485,8 @@ void SwTiledRenderingTest::testSearchAllNotifications()
|
|||||||
{
|
{
|
||||||
comphelper::LibreOfficeKit::setActive();
|
comphelper::LibreOfficeKit::setActive();
|
||||||
SwXTextDocument* pXTextDocument = createDoc("search.odt");
|
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(
|
uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence(
|
||||||
{
|
{
|
||||||
{"SearchItem.SearchString", uno::makeAny(OUString("shape"))},
|
{"SearchItem.SearchString", uno::makeAny(OUString("shape"))},
|
||||||
@@ -509,7 +514,8 @@ void SwTiledRenderingTest::testPageDownInvalidation()
|
|||||||
{".uno:HideWhitespace", uno::makeAny(true)},
|
{".uno:HideWhitespace", uno::makeAny(true)},
|
||||||
}));
|
}));
|
||||||
pXTextDocument->initializeForTiledRendering(aPropertyValues);
|
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>());
|
comphelper::dispatchCommand(".uno:PageDown", uno::Sequence<beans::PropertyValue>());
|
||||||
|
|
||||||
// This was 2.
|
// This was 2.
|
||||||
|
Reference in New Issue
Block a user