diff options
-rw-r--r-- | sc/qa/unit/tiledrendering/data/small.ods | bin | 0 -> 7755 bytes | |||
-rw-r--r-- | sc/qa/unit/tiledrendering/tiledrendering.cxx | 42 | ||||
-rw-r--r-- | sc/source/ui/view/tabview3.cxx | 7 | ||||
-rw-r--r-- | sw/source/core/view/viewsh.cxx | 4 |
4 files changed, 46 insertions, 7 deletions
diff --git a/sc/qa/unit/tiledrendering/data/small.ods b/sc/qa/unit/tiledrendering/data/small.ods Binary files differnew file mode 100644 index 000000000000..ebaae64a0954 --- /dev/null +++ b/sc/qa/unit/tiledrendering/data/small.ods diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx index 5857dabb726b..1801e220acde 100644 --- a/sc/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx @@ -28,6 +28,7 @@ #include <svl/srchitem.hxx> #include <comphelper/lok.hxx> +#include <comphelper/propertyvalue.hxx> #include <sfx2/lokhelper.hxx> #include <tabvwsh.hxx> @@ -55,6 +56,7 @@ public: void testDocumentSize(); void testViewCursors(); void testTextViewSelection(); + void testDocumentSizeChanged(); CPPUNIT_TEST_SUITE(ScTiledRenderingTest); CPPUNIT_TEST(testRowColumnSelections); @@ -63,6 +65,7 @@ public: CPPUNIT_TEST(testDocumentSize); CPPUNIT_TEST(testViewCursors); CPPUNIT_TEST(testTextViewSelection); + CPPUNIT_TEST(testDocumentSizeChanged); CPPUNIT_TEST_SUITE_END(); private: @@ -72,6 +75,7 @@ private: /// document size changed callback. osl::Condition m_aDocSizeCondition; + Size m_aDocumentSize; uno::Reference<lang::XComponent> mxComponent; // TODO various test-related members - when needed @@ -142,12 +146,18 @@ static void lcl_convertRectangle(const OUString& rString, Rectangle& rRectangle) } */ -void ScTiledRenderingTest::callbackImpl(int nType, const char* /*pPayload*/) +void ScTiledRenderingTest::callbackImpl(int nType, const char* pPayload) { switch (nType) { case LOK_CALLBACK_DOCUMENT_SIZE_CHANGED: { + OString aPayload(pPayload); + sal_Int32 nIndex = 0; + OString aToken = aPayload.getToken(0, ',', nIndex); + m_aDocumentSize.setWidth(aToken.toInt32()); + aToken = aPayload.getToken(0, ',', nIndex); + m_aDocumentSize.setHeight(aToken.toInt32()); m_aDocSizeCondition.set(); } break; @@ -397,7 +407,7 @@ void ScTiledRenderingTest::testViewCursors() comphelper::LibreOfficeKit::setActive(false); } -void lcl_dispatchCommand(const uno::Reference<lang::XComponent>& xComponent, const OUString& rCommand) +void lcl_dispatchCommand(const uno::Reference<lang::XComponent>& xComponent, const OUString& rCommand, const uno::Sequence<beans::PropertyValue>& rArguments) { uno::Reference<frame::XController> xController = uno::Reference<frame::XModel>(xComponent, uno::UNO_QUERY)->getCurrentController(); CPPUNIT_ASSERT(xController.is()); @@ -408,7 +418,7 @@ void lcl_dispatchCommand(const uno::Reference<lang::XComponent>& xComponent, con uno::Reference<frame::XDispatchHelper> xDispatchHelper(frame::DispatchHelper::create(xContext)); CPPUNIT_ASSERT(xDispatchHelper.is()); - xDispatchHelper->executeDispatch(xFrame, rCommand, OUString(), 0, {}); + xDispatchHelper->executeDispatch(xFrame, rCommand, OUString(), 0, rArguments); } void ScTiledRenderingTest::testTextViewSelection() @@ -426,7 +436,7 @@ void ScTiledRenderingTest::testTextViewSelection() // Create a selection on two cells in the second view, that's a text selection in LOK terms. aView1.m_bTextViewSelectionInvalidated = false; - lcl_dispatchCommand(mxComponent, ".uno:GoRightSel"); + lcl_dispatchCommand(mxComponent, ".uno:GoRightSel", {}); Scheduler::ProcessEventsToIdle(); // Make sure the first view got its notification. CPPUNIT_ASSERT(aView1.m_bTextViewSelectionInvalidated); @@ -436,6 +446,30 @@ void ScTiledRenderingTest::testTextViewSelection() comphelper::LibreOfficeKit::setActive(false); } +void ScTiledRenderingTest::testDocumentSizeChanged() +{ + comphelper::LibreOfficeKit::setActive(); + + // Load a document that doesn't have much content. + createDoc("small.ods"); + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ScTiledRenderingTest::callback, this); + + // Go to the A30 cell -- that will extend the document size. + uno::Sequence<beans::PropertyValue> aPropertyValues = + { + comphelper::makePropertyValue("ToPoint", OUString("$A$30")), + }; + lcl_dispatchCommand(mxComponent, ".uno:GoToCell", aPropertyValues); + Scheduler::ProcessEventsToIdle(); + // Assert that the size in the payload is not 0. + CPPUNIT_ASSERT(m_aDocumentSize.getWidth() > 0); + CPPUNIT_ASSERT(m_aDocumentSize.getHeight() > 0); + + mxComponent->dispose(); + mxComponent.clear(); + comphelper::LibreOfficeKit::setActive(false); +} + } CPPUNIT_TEST_SUITE_REGISTRATION(ScTiledRenderingTest); diff --git a/sc/source/ui/view/tabview3.cxx b/sc/source/ui/view/tabview3.cxx index 50114379e8c6..440a41874383 100644 --- a/sc/source/ui/view/tabview3.cxx +++ b/sc/source/ui/view/tabview3.cxx @@ -322,7 +322,12 @@ void ScTabView::SetCursor( SCCOL nPosX, SCROW nPosY, bool bNew ) if (pDocSh) { - aViewData.GetViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_DOCUMENT_SIZE_CHANGED, ""); + // Provide size in the payload, so clients don't have to + // call lok::Document::getDocumentSize(). + std::stringstream ss; + ss << aNewSize.Width() << ", " << aNewSize.Height(); + OString sSize = ss.str().c_str(); + aViewData.GetViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_DOCUMENT_SIZE_CHANGED, sSize.getStr()); // New area extended to the right of the sheet after last column // including overlapping area with aNewRowArea diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx index b6606746a2bf..1affa5d44f5d 100644 --- a/sw/source/core/view/viewsh.cxx +++ b/sw/source/core/view/viewsh.cxx @@ -1010,8 +1010,8 @@ void SwViewShell::SizeChgNotify() Size aDocSize = GetDocSize(); std::stringstream ss; ss << aDocSize.Width() + 2L * DOCUMENTBORDER << ", " << aDocSize.Height() + 2L * DOCUMENTBORDER; - OString sRect = ss.str().c_str(); - GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_DOCUMENT_SIZE_CHANGED, sRect.getStr()); + OString sSize = ss.str().c_str(); + GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_DOCUMENT_SIZE_CHANGED, sSize.getStr()); } } } |