sc/qa/unit/tiledrendering/tiledrendering.cxx | 51 +++++++++++++++++++++++++++ sc/source/ui/inc/drawview.hxx | 3 + sc/source/ui/view/drawview.cxx | 5 ++ sc/source/ui/view/tabvwshc.cxx | 29 ++++++++++++--- 4 files changed, 83 insertions(+), 5 deletions(-)
New commits: commit 6bfc623153e1d9b5279c0df08955b68c40b305c0 Author: Henry Castro <hcas...@collabora.com> Date: Tue Sep 20 10:25:05 2016 -0400 sc draw: emit LOK_CALLBACK_GRAPHIC_VIEW_SELECTION when view is created In multiple view environment, when a new view is created ensure to notify other views graphic view selections. Change-Id: If75f9525af6e851e096b6d273957b94882c441cf diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx index a61397a..82e3919 100644 --- a/sc/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx @@ -61,6 +61,7 @@ public: void testViewLock(); void testColRowResize(); void testUndoShells(); + void testCreateViewGraphicSelection(); CPPUNIT_TEST_SUITE(ScTiledRenderingTest); CPPUNIT_TEST(testRowColumnSelections); @@ -73,6 +74,7 @@ public: CPPUNIT_TEST(testViewLock); CPPUNIT_TEST(testColRowResize); CPPUNIT_TEST(testUndoShells); + CPPUNIT_TEST(testCreateViewGraphicSelection); CPPUNIT_TEST_SUITE_END(); private: @@ -355,6 +357,8 @@ public: bool m_bOwnCursorInvalidated; bool m_bViewCursorInvalidated; bool m_bTextViewSelectionInvalidated; + bool m_bGraphicSelection; + bool m_bGraphicViewSelection; bool m_bViewLock; ViewCallback() @@ -397,6 +401,16 @@ public: m_bViewLock = aTree.get_child("rectangle").get_value<std::string>() != "EMPTY"; } break; + case LOK_CALLBACK_GRAPHIC_SELECTION: + { + m_bGraphicSelection = true; + } + break; + case LOK_CALLBACK_GRAPHIC_VIEW_SELECTION: + { + m_bGraphicViewSelection = true; + } + break; } } }; @@ -589,6 +603,43 @@ void ScTiledRenderingTest::testUndoShells() comphelper::LibreOfficeKit::setActive(false); } +void ScTiledRenderingTest::testCreateViewGraphicSelection() +{ + // Load a document + comphelper::LibreOfficeKit::setActive(); + + // Load a document that has a shape and create two views. + ScModelObj* pModelObj = createDoc("shape.ods"); + ViewCallback aView1; + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1); + + // Mark the graphic in the first view. + const ScViewData* pViewData = ScDocShell::GetViewData(); + ScTabViewShell* pViewShell = pViewData->GetViewShell(); + CPPUNIT_ASSERT(pViewShell); + SdrModel* pDrawModel = pViewData->GetDocument()->GetDrawLayer(); + SdrPage* pDrawPage = pDrawModel->GetPage(0); + SdrObject* pObject = pDrawPage->GetObj(0); + SdrView* pView = pViewShell->GetSdrView(); + aView1.m_bGraphicSelection = false; + aView1.m_bGraphicViewSelection = false; + pView->MarkObj(pObject, pView->GetSdrPageView()); + CPPUNIT_ASSERT(aView1.m_bGraphicSelection); + + // Create a second view. + SfxLokHelper::createView(); + ViewCallback aView2; + aView2.m_bGraphicViewSelection = false; + pModelObj->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>()); + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView2); + CPPUNIT_ASSERT(aView2.m_bGraphicViewSelection); + CPPUNIT_ASSERT(aView1.m_bGraphicViewSelection); + + mxComponent->dispose(); + mxComponent.clear(); + comphelper::LibreOfficeKit::setActive(false); +} + } CPPUNIT_TEST_SUITE_REGISTRATION(ScTiledRenderingTest); diff --git a/sc/source/ui/inc/drawview.hxx b/sc/source/ui/inc/drawview.hxx index 0705153..f9d1119 100644 --- a/sc/source/ui/inc/drawview.hxx +++ b/sc/source/ui/inc/drawview.hxx @@ -155,6 +155,9 @@ public: static void CheckOle( const SdrMarkList& rMarkList, bool& rAnyOle, bool& rOneOle ); void SyncForGrid( SdrObject* pObj ); + + /// See SdrMarkView::GetSfxViewShell(). + SfxViewShell* GetSfxViewShell() const override; }; #endif diff --git a/sc/source/ui/view/drawview.cxx b/sc/source/ui/view/drawview.cxx index 8efac68..7d82d9a 100644 --- a/sc/source/ui/view/drawview.cxx +++ b/sc/source/ui/view/drawview.cxx @@ -845,6 +845,11 @@ void ScDrawView::MakeVisible( const Rectangle& rRect, vcl::Window& rWin ) pViewData->GetView()->MakeVisible( rRect ); } +SfxViewShell* ScDrawView::GetSfxViewShell() const +{ + return pViewData->GetViewShell(); +} + void ScDrawView::DeleteMarked() { // try to delete a note caption object with its cell note in the Calc document diff --git a/sc/source/ui/view/tabvwshc.cxx b/sc/source/ui/view/tabvwshc.cxx index e84893b..caac7ec 100644 --- a/sc/source/ui/view/tabvwshc.cxx +++ b/sc/source/ui/view/tabvwshc.cxx @@ -23,6 +23,7 @@ #include <vcl/msgbox.hxx> #include <sfx2/childwin.hxx> #include <sfx2/dispatch.hxx> +#include <editeng/editview.hxx> #include "tabvwsh.hxx" #include "sc.hrc" @@ -541,13 +542,31 @@ int ScTabViewShell::getPart() const return GetViewData().GetTabNo(); } -void ScTabViewShell::NotifyCursor(SfxViewShell* pViewShell) const +void ScTabViewShell::NotifyCursor(SfxViewShell* pOtherShell) const { - const ScGridWindow* pGridWindow = GetViewData().GetActiveWin(); - if (!pGridWindow) - return; + ScDrawView* pDrView = const_cast<ScTabViewShell*>(this)->GetScDrawView(); + if (pDrView) + { + if (pDrView->GetTextEditObject()) + { + // Blinking cursor. + EditView& rEditView = pDrView->GetTextEditOutlinerView()->GetEditView(); + rEditView.RegisterOtherShell(pOtherShell); + rEditView.ShowCursor(); + rEditView.RegisterOtherShell(nullptr); + // Text selection, if any. + rEditView.DrawSelection(pOtherShell); + } + else + { + // Graphic selection. + pDrView->AdjustMarkHdl(pOtherShell); + } + } - pGridWindow->updateLibreOfficeKitCellCursor(pViewShell); + const ScGridWindow* pWin = GetViewData().GetActiveWin(); + if (pWin) + pWin->updateLibreOfficeKitCellCursor(pOtherShell); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits