Kaydet (Commit) 0b5c4d38 authored tarafından Henry Castro's avatar Henry Castro Kaydeden (comit) Miklos Vajna

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
Reviewed-on: https://gerrit.libreoffice.org/29094Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
Tested-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
üst 28447258
...@@ -62,6 +62,7 @@ public: ...@@ -62,6 +62,7 @@ public:
void testViewLock(); void testViewLock();
void testColRowResize(); void testColRowResize();
void testUndoShells(); void testUndoShells();
void testCreateViewGraphicSelection();
CPPUNIT_TEST_SUITE(ScTiledRenderingTest); CPPUNIT_TEST_SUITE(ScTiledRenderingTest);
CPPUNIT_TEST(testRowColumnSelections); CPPUNIT_TEST(testRowColumnSelections);
...@@ -75,6 +76,7 @@ public: ...@@ -75,6 +76,7 @@ public:
CPPUNIT_TEST(testViewLock); CPPUNIT_TEST(testViewLock);
CPPUNIT_TEST(testColRowResize); CPPUNIT_TEST(testColRowResize);
CPPUNIT_TEST(testUndoShells); CPPUNIT_TEST(testUndoShells);
CPPUNIT_TEST(testCreateViewGraphicSelection);
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
private: private:
...@@ -377,6 +379,8 @@ public: ...@@ -377,6 +379,8 @@ public:
bool m_bOwnCursorInvalidated; bool m_bOwnCursorInvalidated;
bool m_bViewCursorInvalidated; bool m_bViewCursorInvalidated;
bool m_bTextViewSelectionInvalidated; bool m_bTextViewSelectionInvalidated;
bool m_bGraphicSelection;
bool m_bGraphicViewSelection;
bool m_bViewLock; bool m_bViewLock;
ViewCallback() ViewCallback()
...@@ -419,6 +423,16 @@ public: ...@@ -419,6 +423,16 @@ public:
m_bViewLock = aTree.get_child("rectangle").get_value<std::string>() != "EMPTY"; m_bViewLock = aTree.get_child("rectangle").get_value<std::string>() != "EMPTY";
} }
break; break;
case LOK_CALLBACK_GRAPHIC_SELECTION:
{
m_bGraphicSelection = true;
}
break;
case LOK_CALLBACK_GRAPHIC_VIEW_SELECTION:
{
m_bGraphicViewSelection = true;
}
break;
} }
} }
}; };
...@@ -611,6 +625,43 @@ void ScTiledRenderingTest::testUndoShells() ...@@ -611,6 +625,43 @@ void ScTiledRenderingTest::testUndoShells()
comphelper::LibreOfficeKit::setActive(false); 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); CPPUNIT_TEST_SUITE_REGISTRATION(ScTiledRenderingTest);
......
...@@ -155,6 +155,9 @@ public: ...@@ -155,6 +155,9 @@ public:
static void CheckOle( const SdrMarkList& rMarkList, bool& rAnyOle, bool& rOneOle ); static void CheckOle( const SdrMarkList& rMarkList, bool& rAnyOle, bool& rOneOle );
void SyncForGrid( SdrObject* pObj ); void SyncForGrid( SdrObject* pObj );
/// See SdrMarkView::GetSfxViewShell().
SfxViewShell* GetSfxViewShell() const override;
}; };
#endif #endif
......
...@@ -845,6 +845,11 @@ void ScDrawView::MakeVisible( const Rectangle& rRect, vcl::Window& rWin ) ...@@ -845,6 +845,11 @@ void ScDrawView::MakeVisible( const Rectangle& rRect, vcl::Window& rWin )
pViewData->GetView()->MakeVisible( rRect ); pViewData->GetView()->MakeVisible( rRect );
} }
SfxViewShell* ScDrawView::GetSfxViewShell() const
{
return pViewData->GetViewShell();
}
void ScDrawView::DeleteMarked() void ScDrawView::DeleteMarked()
{ {
// try to delete a note caption object with its cell note in the Calc document // try to delete a note caption object with its cell note in the Calc document
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include <vcl/msgbox.hxx> #include <vcl/msgbox.hxx>
#include <sfx2/childwin.hxx> #include <sfx2/childwin.hxx>
#include <sfx2/dispatch.hxx> #include <sfx2/dispatch.hxx>
#include <editeng/editview.hxx>
#include "tabvwsh.hxx" #include "tabvwsh.hxx"
#include "sc.hrc" #include "sc.hrc"
...@@ -514,13 +515,31 @@ int ScTabViewShell::getPart() const ...@@ -514,13 +515,31 @@ int ScTabViewShell::getPart() const
return GetViewData().GetTabNo(); return GetViewData().GetTabNo();
} }
void ScTabViewShell::NotifyCursor(SfxViewShell* pViewShell) const void ScTabViewShell::NotifyCursor(SfxViewShell* pOtherShell) const
{ {
const ScGridWindow* pGridWindow = GetViewData().GetActiveWin(); ScDrawView* pDrView = const_cast<ScTabViewShell*>(this)->GetScDrawView();
if (!pGridWindow) if (pDrView)
return; {
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: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment