include/LibreOfficeKit/LibreOfficeKitEnums.h | 4 ++++ include/sfx2/lokhelper.hxx | 3 +++ sc/qa/unit/tiledrendering/tiledrendering.cxx | 8 ++++---- sc/source/core/data/document.cxx | 13 +++++++++---- sc/source/ui/docshell/docsh3.cxx | 4 +++- sc/source/ui/view/tabview.cxx | 7 ++++--- sc/source/ui/view/tabview3.cxx | 3 ++- sc/source/ui/view/tabview5.cxx | 3 ++- sd/qa/unit/tiledrendering/tiledrendering.cxx | 2 +- sd/source/core/drawdoc2.cxx | 8 ++++++-- sd/source/ui/sidebar/SlideBackground.cxx | 5 ++++- sfx2/source/view/lokhelper.cxx | 20 ++++++++++++++++++++ sw/qa/extras/tiledrendering/tiledrendering.cxx | 2 +- sw/source/core/view/viewsh.cxx | 12 +++++++++++- 14 files changed, 74 insertions(+), 20 deletions(-)
New commits: commit 844ad20c4103663e36e4da1f485c7413e81a0db4 Author: Tamás Zolnai <tamas.zol...@collabora.com> AuthorDate: Fri Sep 27 19:16:07 2019 +0200 Commit: Tamás Zolnai <tamas.zol...@collabora.com> CommitDate: Sat Sep 28 03:30:53 2019 +0200 lok: send an invalidation by document size change It was sent by the kit code earlier. Now we move it to the LO core code, so we can optimize it later. co-author: Michael Meeks <michael.me...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/79491 Reviewed-by: Tamás Zolnai <tamas.zol...@collabora.com> Tested-by: Tamás Zolnai <tamas.zol...@collabora.com> (cherry picked from commit cd7ff1797d754018db1d47888781c9d7ecb24dcf) Change-Id: Id0a8991016dbe8d13891071e2d5b4c9250720da9 Reviewed-on: https://gerrit.libreoffice.org/79617 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Tamás Zolnai <tamas.zol...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/79760 diff --git a/include/LibreOfficeKit/LibreOfficeKitEnums.h b/include/LibreOfficeKit/LibreOfficeKitEnums.h index 4f0d31f50817..535d72e41033 100644 --- a/include/LibreOfficeKit/LibreOfficeKitEnums.h +++ b/include/LibreOfficeKit/LibreOfficeKitEnums.h @@ -253,6 +253,10 @@ typedef enum * * Payload format is "width, height", i.e. clients get the new size without * having to do an explicit lok::Document::getDocumentSize() call. + * + * A size change is always preceeded by a series of + * LOK_CALLBACK_INVALIDATE_TILES events invalidating any areas + * need re-rendering to adapt. */ LOK_CALLBACK_DOCUMENT_SIZE_CHANGED = 13, diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx index 5ef2b3f7d182..8a5503d85c2c 100644 --- a/include/sfx2/lokhelper.hxx +++ b/include/sfx2/lokhelper.hxx @@ -11,6 +11,7 @@ #define INCLUDED_SFX2_LOKHELPER_HXX #include <vcl/IDialogRenderable.hxx> +#include <vcl/ITiledRenderable.hxx> #include <sfx2/dllapi.h> #include <sfx2/viewsh.hxx> #include <cstddef> @@ -48,6 +49,8 @@ public: vcl::LOKWindowId nWindowId, const OUString& rAction, const std::vector<vcl::LOKPayloadItem>& rPayload = std::vector<vcl::LOKPayloadItem>()); + /// Emits a LOK_CALLBACK_DOCUMENT_SIZE_CHANGED - if @bInvalidateAll - first invalidates all parts + static void notifyDocumentSizeChanged(SfxViewShell const* pThisView, const OString& rPayload, vcl::ITiledRenderable* pDoc, bool bInvalidateAll = true); /// Emits a LOK_CALLBACK_INVALIDATE_TILES, but tweaks it according to setOptionalFeatures() if needed. static void notifyInvalidation(SfxViewShell const* pThisView, const OString& rPayload); /// Emits a LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR, but tweaks it according to setOptionalFeatures() if needed. diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx index 12ac20e380bd..e196bb788ec0 100644 --- a/sc/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx @@ -510,7 +510,7 @@ public: else { uno::Sequence<OUString> aSeq = comphelper::string::convertCommaSeparated(OUString::createFromAscii(pPayload)); - CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(4), aSeq.getLength()); + CPPUNIT_ASSERT(aSeq.getLength() == 4 || aSeq.getLength() == 5); tools::Rectangle aInvalidationRect; aInvalidationRect.setX(aSeq[0].toInt32()); aInvalidationRect.setY(aSeq[1].toInt32()); @@ -1042,7 +1042,7 @@ void ScTiledRenderingTest::testInvalidateOnInserRowCol() comphelper::dispatchCommand(".uno:InsertRows", aArgs); Scheduler::ProcessEventsToIdle(); CPPUNIT_ASSERT(aView.m_bInvalidateTiles); - CPPUNIT_ASSERT_EQUAL(size_t(1), aView.m_aInvalidations.size()); + CPPUNIT_ASSERT_EQUAL(size_t(2), aView.m_aInvalidations.size()); CPPUNIT_ASSERT_EQUAL(tools::Rectangle(-75, 50985, 32212230, 63990), aView.m_aInvalidations[0]); // move on the right @@ -1059,7 +1059,7 @@ void ScTiledRenderingTest::testInvalidateOnInserRowCol() comphelper::dispatchCommand(".uno:InsertColumns", aArgs); Scheduler::ProcessEventsToIdle(); CPPUNIT_ASSERT(aView.m_bInvalidateTiles); - CPPUNIT_ASSERT_EQUAL(size_t(1), aView.m_aInvalidations.size()); + CPPUNIT_ASSERT_EQUAL(size_t(2), aView.m_aInvalidations.size()); CPPUNIT_ASSERT_EQUAL(tools::Rectangle(253650, -15, 32212230, 63990), aView.m_aInvalidations[0]); } @@ -1728,7 +1728,7 @@ void ScTiledRenderingTest::testSheetChangeInvalidation() pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::PAGEDOWN | KEY_MOD1); Scheduler::ProcessEventsToIdle(); CPPUNIT_ASSERT(aView1.m_bInvalidateTiles); - CPPUNIT_ASSERT_EQUAL(size_t(1), aView1.m_aInvalidations.size()); + CPPUNIT_ASSERT_EQUAL(size_t(3), aView1.m_aInvalidations.size()); CPPUNIT_ASSERT_EQUAL(tools::Rectangle(0, 0, 1310720, 268435456), aView1.m_aInvalidations[0]); } diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx index 7d6d0c24f3a3..d7b973e88b4c 100644 --- a/sc/source/core/data/document.cxx +++ b/sc/source/core/data/document.cxx @@ -112,6 +112,7 @@ #include <LibreOfficeKit/LibreOfficeKitEnums.h> #include <mtvelements.hxx> +#include <sfx2/lokhelper.hxx> using ::editeng::SvxBorderLine; using namespace ::com::sun::star; @@ -594,7 +595,8 @@ bool ScDocument::InsertTab( SfxViewShell* pViewShell = SfxViewShell::GetFirst(); while (pViewShell) { - pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_DOCUMENT_SIZE_CHANGED, ""); + ScModelObj* pModel = ScModelObj::getImplementation(pViewShell->GetCurrentDocument()); + SfxLokHelper::notifyDocumentSizeChanged(pViewShell, "", pModel); pViewShell = SfxViewShell::GetNext(*pViewShell); } } @@ -773,7 +775,8 @@ bool ScDocument::DeleteTab( SCTAB nTab ) SfxViewShell* pViewShell = SfxViewShell::GetFirst(); while (pViewShell) { - pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_DOCUMENT_SIZE_CHANGED, ""); + ScModelObj* pModel = ScModelObj::getImplementation(pViewShell->GetCurrentDocument()); + SfxLokHelper::notifyDocumentSizeChanged(pViewShell, "", pModel); pViewShell = SfxViewShell::GetNext(*pViewShell); } } @@ -882,7 +885,8 @@ bool ScDocument::DeleteTabs( SCTAB nTab, SCTAB nSheets ) SfxViewShell* pViewShell = SfxViewShell::GetFirst(); while (pViewShell) { - pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_DOCUMENT_SIZE_CHANGED, ""); + ScModelObj* pModel = ScModelObj::getImplementation(pViewShell->GetCurrentDocument()); + SfxLokHelper::notifyDocumentSizeChanged(pViewShell, "", pModel); pViewShell = SfxViewShell::GetNext(*pViewShell); } } @@ -933,7 +937,8 @@ bool ScDocument::RenameTab( SCTAB nTab, const OUString& rName, bool bExternalDoc SfxViewShell* pViewShell = SfxViewShell::GetFirst(); while (pViewShell) { - pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_DOCUMENT_SIZE_CHANGED, ""); + ScModelObj* pModel = ScModelObj::getImplementation(pViewShell->GetCurrentDocument()); + SfxLokHelper::notifyDocumentSizeChanged(pViewShell, "", pModel); pViewShell = SfxViewShell::GetNext(*pViewShell); } } diff --git a/sc/source/ui/docshell/docsh3.cxx b/sc/source/ui/docshell/docsh3.cxx index 68f974a19f53..70a43e3def5a 100644 --- a/sc/source/ui/docshell/docsh3.cxx +++ b/sc/source/ui/docshell/docsh3.cxx @@ -65,6 +65,7 @@ #include <comphelper/lok.hxx> #include <LibreOfficeKit/LibreOfficeKitEnums.h> +#include <sfx2/lokhelper.hxx> // Redraw - Notifications @@ -170,7 +171,8 @@ void ScDocShell::PostPaint( const ScRangeList& rRanges, PaintPartFlags nPart, sa SfxViewShell* pViewShell = SfxViewShell::GetFirst(); while (pViewShell) { - pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_DOCUMENT_SIZE_CHANGED, ""); + ScModelObj* pModel = ScModelObj::getImplementation(pViewShell->GetCurrentDocument()); + SfxLokHelper::notifyDocumentSizeChanged(pViewShell, "", pModel); pViewShell = SfxViewShell::GetNext(*pViewShell); } } diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx index febe50df5f73..210308caf3f3 100644 --- a/sc/source/ui/view/tabview.cxx +++ b/sc/source/ui/view/tabview.cxx @@ -2569,7 +2569,8 @@ OUString ScTabView::getRowColumnHeaders(const tools::Rectangle& rRectangle) std::stringstream ss; ss << aNewSize.Width() << ", " << aNewSize.Height(); OString sSize = ss.str().c_str(); - aViewData.GetViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_DOCUMENT_SIZE_CHANGED, sSize.getStr()); + ScModelObj* pModel = ScModelObj::getImplementation(aViewData.GetViewShell()->GetCurrentDocument()); + SfxLokHelper::notifyDocumentSizeChanged(aViewData.GetViewShell(), sSize, pModel); // New area extended to the bottom of the sheet after last row // excluding overlapping area with aNewColArea @@ -2711,8 +2712,8 @@ OUString ScTabView::getRowColumnHeaders(const tools::Rectangle& rRectangle) std::stringstream ss; ss << aNewSize.Width() << ", " << aNewSize.Height(); OString sSize = ss.str().c_str(); - aViewData.GetViewShell()->libreOfficeKitViewCallback( - LOK_CALLBACK_DOCUMENT_SIZE_CHANGED, sSize.getStr()); + ScModelObj* pModel = ScModelObj::getImplementation(aViewData.GetViewShell()->GetCurrentDocument()); + SfxLokHelper::notifyDocumentSizeChanged(aViewData.GetViewShell(), sSize, pModel); } // New area extended to the right of the sheet after last column diff --git a/sc/source/ui/view/tabview3.cxx b/sc/source/ui/view/tabview3.cxx index 48a0880c3964..f64b8d35ecfe 100644 --- a/sc/source/ui/view/tabview3.cxx +++ b/sc/source/ui/view/tabview3.cxx @@ -387,7 +387,8 @@ void ScTabView::SetCursor( SCCOL nPosX, SCROW nPosY, bool bNew ) std::stringstream ss; ss << aNewSize.Width() << ", " << aNewSize.Height(); OString sSize = ss.str().c_str(); - aViewData.GetViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_DOCUMENT_SIZE_CHANGED, sSize.getStr()); + ScModelObj* pModel = ScModelObj::getImplementation(aViewData.GetViewShell()->GetCurrentDocument()); + SfxLokHelper::notifyDocumentSizeChanged(aViewData.GetViewShell(), sSize, pModel); // New area extended to the right of the sheet after last column // including overlapping area with aNewRowArea diff --git a/sc/source/ui/view/tabview5.cxx b/sc/source/ui/view/tabview5.cxx index a041e53e712a..88d35b111ed3 100644 --- a/sc/source/ui/view/tabview5.cxx +++ b/sc/source/ui/view/tabview5.cxx @@ -329,7 +329,8 @@ void ScTabView::TabChanged( bool bSameTabButMoved ) ss << aDocSize.Width() << ", " << aDocSize.Height(); OString sRect = ss.str().c_str(); ScTabViewShell* pViewShell = aViewData.GetViewShell(); - pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_DOCUMENT_SIZE_CHANGED, sRect.getStr()); + ScModelObj* pModel = ScModelObj::getImplementation(pViewShell->GetCurrentDocument()); + SfxLokHelper::notifyDocumentSizeChanged(pViewShell, sRect, pModel); } } } diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx index 44dec150a6ab..6ad6faa8c866 100644 --- a/sd/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx @@ -251,7 +251,7 @@ static std::vector<OUString> lcl_convertSeparated(const OUString& rString, sal_U static void lcl_convertRectangle(const OUString& rString, ::tools::Rectangle& rRectangle) { uno::Sequence<OUString> aSeq = comphelper::string::convertCommaSeparated(rString); - CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(4), aSeq.getLength()); + CPPUNIT_ASSERT(aSeq.getLength() == 4 || aSeq.getLength() == 5); rRectangle.setX(aSeq[0].toInt32()); rRectangle.setY(aSeq[1].toInt32()); rRectangle.setWidth(aSeq[2].toInt32()); diff --git a/sd/source/core/drawdoc2.cxx b/sd/source/core/drawdoc2.cxx index 652206824822..7aabcc7007c4 100644 --- a/sd/source/core/drawdoc2.cxx +++ b/sd/source/core/drawdoc2.cxx @@ -61,6 +61,8 @@ #include <imapinfo.hxx> #include <cusshow.hxx> #include <undo/undomanager.hxx> +#include <sfx2/lokhelper.hxx> +#include <unomodel.hxx> #include <DrawDocShell.hxx> #include <FrameView.hxx> @@ -413,7 +415,8 @@ void SdDrawDocument::InsertPage(SdrPage* pPage, sal_uInt16 nPos) SfxViewShell* pViewShell = SfxViewShell::GetFirst(); while (pViewShell) { - pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_DOCUMENT_SIZE_CHANGED, ""); + SdXImpressDocument* pModel = SdXImpressDocument::getImplementation(this->getUnoModel()); + SfxLokHelper::notifyDocumentSizeChanged(pViewShell, "", pModel); pViewShell = SfxViewShell::GetNext(*pViewShell); } } @@ -446,7 +449,8 @@ SdrPage* SdDrawDocument::RemovePage(sal_uInt16 nPgNum) SfxViewShell* pViewShell = SfxViewShell::GetFirst(); while (pViewShell) { - pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_DOCUMENT_SIZE_CHANGED, ""); + SdXImpressDocument* pModel = SdXImpressDocument::getImplementation(this->getUnoModel()); + SfxLokHelper::notifyDocumentSizeChanged(pViewShell, "", pModel); pViewShell = SfxViewShell::GetNext(*pViewShell); } } diff --git a/sd/source/ui/sidebar/SlideBackground.cxx b/sd/source/ui/sidebar/SlideBackground.cxx index 9f464dd97928..af300693ccb3 100644 --- a/sd/source/ui/sidebar/SlideBackground.cxx +++ b/sd/source/ui/sidebar/SlideBackground.cxx @@ -71,6 +71,8 @@ #include <svl/itemset.hxx> #include <comphelper/lok.hxx> #include <LibreOfficeKit/LibreOfficeKitEnums.h> +#include <unomodel.hxx> +#include <sfx2/lokhelper.hxx> using namespace ::com::sun::star; @@ -1021,7 +1023,8 @@ IMPL_LINK_NOARG(SlideBackground, PaperSizeModifyHdl, ListBox&, void) SfxViewShell* pViewShell = SfxViewShell::GetFirst(); while (pViewShell) { - pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_DOCUMENT_SIZE_CHANGED, ""); + SdXImpressDocument* pModel = SdXImpressDocument::getImplementation(pViewShell->GetCurrentDocument()); + SfxLokHelper::notifyDocumentSizeChanged(pViewShell, "", pModel); pViewShell = SfxViewShell::GetNext(*pViewShell); } } diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx index 98b76d43514c..790227f8487c 100644 --- a/sfx2/source/view/lokhelper.cxx +++ b/sfx2/source/view/lokhelper.cxx @@ -202,6 +202,26 @@ void SfxLokHelper::notifyInvalidation(SfxViewShell const* pThisView, const OStri pThisView->libreOfficeKitViewCallback(LOK_CALLBACK_INVALIDATE_TILES, aBuf.makeStringAndClear().getStr()); } +void SfxLokHelper::notifyDocumentSizeChanged(SfxViewShell const* pThisView, const OString& rPayload, vcl::ITiledRenderable* pDoc, bool bInvalidateAll) +{ + if (!comphelper::LibreOfficeKit::isActive()) + return; + + if (!pDoc) + return; + + if (bInvalidateAll) + { + for (int i = 0; i < pDoc->getParts(); ++i) + { + tools::Rectangle aRectangle(0, 0, 1000000000, 1000000000); + OString sPayload = aRectangle.toString() + OString(", ") + OString::number(i); + pThisView->libreOfficeKitViewCallback(LOK_CALLBACK_INVALIDATE_TILES, sPayload.getStr()); + } + } + pThisView->libreOfficeKitViewCallback(LOK_CALLBACK_DOCUMENT_SIZE_CHANGED, rPayload.getStr()); +} + void SfxLokHelper::notifyVisCursorInvalidation(OutlinerViewShell const* pThisView, const OString& rRectangle) { OString sPayload; diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx index 701c135a579e..49fde5be7f3d 100644 --- a/sw/qa/extras/tiledrendering/tiledrendering.cxx +++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx @@ -257,7 +257,7 @@ void SwTiledRenderingTest::callbackImpl(int nType, const char* pPayload) uno::Sequence<OUString> aSeq = comphelper::string::convertCommaSeparated(OUString::createFromAscii(pPayload)); if (OString("EMPTY") == pPayload) return; - CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(4), aSeq.getLength()); + CPPUNIT_ASSERT(aSeq.getLength() == 4 || aSeq.getLength() == 5); m_aInvalidation.setX(aSeq[0].toInt32()); m_aInvalidation.setY(aSeq[1].toInt32()); m_aInvalidation.setWidth(aSeq[2].toInt32()); diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx index c4f7d2df30a3..aec41eb350ec 100644 --- a/sw/source/core/view/viewsh.cxx +++ b/sw/source/core/view/viewsh.cxx @@ -20,6 +20,7 @@ #include <config_features.h> #include <com/sun/star/accessibility/XAccessible.hpp> +#include <com/sun/star/lang/XUnoTunnel.hpp> #include <sfx2/viewfrm.hxx> #include <sfx2/progress.hxx> #include <svx/srchdlg.hxx> @@ -73,6 +74,7 @@ #include <wrtsh.hxx> #include <DocumentSettingManager.hxx> +#include <unotxdoc.hxx> #include <view.hxx> #include <PostItMgr.hxx> #include <unotools/configmgr.hxx> @@ -83,6 +85,7 @@ #include <svx/sdr/overlay/overlaymanager.hxx> #include <LibreOfficeKit/LibreOfficeKitEnums.h> #include <comphelper/lok.hxx> +#include <sfx2/lokhelper.hxx> #if !HAVE_FEATURE_DESKTOP #include <vcl/sysdata.hxx> @@ -1054,7 +1057,14 @@ void SwViewShell::SizeChgNotify() std::stringstream ss; ss << aDocSize.Width() + 2 * DOCUMENTBORDER << ", " << aDocSize.Height() + 2 * DOCUMENTBORDER; OString sSize = ss.str().c_str(); - GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_DOCUMENT_SIZE_CHANGED, sSize.getStr()); + + uno::Reference< css::lang::XUnoTunnel > xTunnel(GetSfxViewShell()->GetCurrentDocument(), uno::UNO_QUERY); + if(xTunnel.is()) + { + SwXTextDocument* pXDoc = reinterpret_cast< SwXTextDocument * >( + sal::static_int_cast< sal_IntPtr >(xTunnel->getSomething(SwXTextDocument::getUnoTunnelId()))); + SfxLokHelper::notifyDocumentSizeChanged(GetSfxViewShell(), sSize, pXDoc); + } } } } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits