diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-09-02 14:21:18 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-09-02 14:58:13 +0200 |
commit | 3fd4c40a8706de03a56b152385551a3a9159f563 (patch) | |
tree | df1068803bf973981c8b759f96dbfe5f777ce23b | |
parent | c7e48d8bf23e0fce7af5fa90ac173f0d477d7aac (diff) |
svx: move GetSfxViewShell() to SdrMarkView
... from SdrObjEditView. This way SdrMarkView can avoid
SfxViewShell::Current() calls, and it can avoid clearing the LOK graphic
selection of the old view when constructing a new view.
With this, an existing graphic selection in an Impress LOK view is no
longer cleared when creating a new view, thanks to the
sd::View::GetSfxViewShell() override.
Change-Id: I70a287aa9c2265bf59a9fb18e0c3839b8f119bbc
Reviewed-on: https://gerrit.libreoffice.org/28618
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
(cherry picked from commit c152008943160fa901ef8a356515a6a074370ff0)
-rw-r--r-- | include/svx/svdedxv.hxx | 3 | ||||
-rw-r--r-- | include/svx/svdmrkv.hxx | 4 | ||||
-rw-r--r-- | sd/qa/unit/tiledrendering/tiledrendering.cxx | 33 | ||||
-rw-r--r-- | svx/source/svdraw/svdedxv.cxx | 5 | ||||
-rw-r--r-- | svx/source/svdraw/svdmrkv.cxx | 15 |
5 files changed, 47 insertions, 13 deletions
diff --git a/include/svx/svdedxv.hxx b/include/svx/svdedxv.hxx index 628faee5622e..5b2d3b2c1abb 100644 --- a/include/svx/svdedxv.hxx +++ b/include/svx/svdedxv.hxx @@ -35,7 +35,6 @@ class ImpSdrEditPara; struct PasteOrDropInfos; class SdrUndoManager; class TextChainCursorManager; -class SfxViewShell; namespace com { namespace sun { namespace star { namespace uno { class Any; @@ -159,8 +158,6 @@ public: SdrPageView* ShowSdrPage(SdrPage* pPage) override; void HideSdrPage() override; - /// Get access to the view shell owning this draw view, if any. - virtual SfxViewShell* GetSfxViewShell() const; virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override; virtual void ModelHasChanged() override; diff --git a/include/svx/svdmrkv.hxx b/include/svx/svdmrkv.hxx index 1605d6fee6ee..2706f771cee4 100644 --- a/include/svx/svdmrkv.hxx +++ b/include/svx/svdmrkv.hxx @@ -27,6 +27,8 @@ #include <svx/svxdllapi.h> #include <o3tl/typed_flags_set.hxx> +class SfxViewShell; + // The following is not yet implemented, or just partially: enum class SdrSearchOptions { @@ -448,6 +450,8 @@ public: // End point of the axis of reflextion const Point& GetRef2() const { return maRef1; } void SetRef2(const Point& rPt); + /// Get access to the view shell owning this draw view, if any. + virtual SfxViewShell* GetSfxViewShell() const; }; diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx index 77f4ab196a47..45b1034f5088 100644 --- a/sd/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx @@ -70,6 +70,7 @@ public: void testCursorViews(); void testViewLock(); void testUndoLimiting(); + void testCreateViewGraphicSelection(); CPPUNIT_TEST_SUITE(SdTiledRenderingTest); CPPUNIT_TEST(testRegisterCallback); @@ -95,6 +96,7 @@ public: CPPUNIT_TEST(testCursorViews); CPPUNIT_TEST(testViewLock); CPPUNIT_TEST(testUndoLimiting); + CPPUNIT_TEST(testCreateViewGraphicSelection); CPPUNIT_TEST_SUITE_END(); private: @@ -1106,6 +1108,37 @@ void SdTiledRenderingTest::testUndoLimiting() comphelper::LibreOfficeKit::setActive(false); } +void SdTiledRenderingTest::testCreateViewGraphicSelection() +{ + comphelper::LibreOfficeKit::setActive(); + + // Load a document and register a callback. + SdXImpressDocument* pXImpressDocument = createDoc("shape.odp"); + pXImpressDocument->initializeForTiledRendering({}); + ViewCallback aView1; + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1); + + // Select the only shape in the document and assert that the graphic selection is changed. + sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell(); + SdPage* pActualPage = pViewShell->GetActualPage(); + SdrObject* pObject = pActualPage->GetObj(0); + SdrView* pView = pViewShell->GetView(); + aView1.m_bGraphicSelectionInvalidated = false; + pView->MarkObj(pObject, pView->GetSdrPageView()); + CPPUNIT_ASSERT(aView1.m_bGraphicSelectionInvalidated); + + // Now create a new view. + aView1.m_bGraphicSelectionInvalidated = false; + SfxLokHelper::createView(); + // This failed, creating a new view affected the graphic selection of an + // existing view. + CPPUNIT_ASSERT(!aView1.m_bGraphicSelectionInvalidated); + + mxComponent->dispose(); + mxComponent.clear(); + comphelper::LibreOfficeKit::setActive(false); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SdTiledRenderingTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx index 5c719e1076bd..8960aeed10ca 100644 --- a/svx/source/svdraw/svdedxv.cxx +++ b/svx/source/svdraw/svdedxv.cxx @@ -213,11 +213,6 @@ void SdrObjEditView::TakeActionRect(Rectangle& rRect) const } } -SfxViewShell* SdrObjEditView::GetSfxViewShell() const -{ - return nullptr; -} - void SdrObjEditView::Notify(SfxBroadcaster& rBC, const SfxHint& rHint) { SdrGlueEditView::Notify(rBC,rHint); diff --git a/svx/source/svdraw/svdmrkv.cxx b/svx/source/svdraw/svdmrkv.cxx index df1abb7f3632..b5c62272f549 100644 --- a/svx/source/svdraw/svdmrkv.cxx +++ b/svx/source/svdraw/svdmrkv.cxx @@ -231,7 +231,7 @@ void SdrMarkView::ModelHasChanged() sSelection = aSelection.toString(); } - if(SfxViewShell* pViewShell = SfxViewShell::Current()) + if(SfxViewShell* pViewShell = GetSfxViewShell()) pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_INVALIDATE_TILES, sSelection.getStr()); } } @@ -714,7 +714,7 @@ void SdrMarkView::SetMarkHandles() if (bTiledRendering) { // Suppress handles -> empty graphic selection. - if(SfxViewShell* pViewShell = SfxViewShell::Current()) + if(SfxViewShell* pViewShell = GetSfxViewShell()) { pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_GRAPHIC_SELECTION, "EMPTY"); SfxLokHelper::notifyOtherViews(pViewShell, LOK_CALLBACK_GRAPHIC_VIEW_SELECTION, "selection", "EMPTY"); @@ -738,7 +738,7 @@ void SdrMarkView::SetMarkHandles() if (xController.is() && xController->hasSelectedCells()) { // The table shape has selected cells, which provide text selection already -> no graphic selection. - if(SfxViewShell* pViewShell = SfxViewShell::Current()) + if(SfxViewShell* pViewShell = GetSfxViewShell()) { pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_GRAPHIC_SELECTION, "EMPTY"); SfxLokHelper::notifyOtherViews(pViewShell, LOK_CALLBACK_GRAPHIC_VIEW_SELECTION, "selection", "EMPTY"); @@ -771,10 +771,10 @@ void SdrMarkView::SetMarkHandles() sSelection = aSelection.toString(); // hide the text selection too - if(SfxViewShell* pViewShell = SfxViewShell::Current()) + if(SfxViewShell* pViewShell = GetSfxViewShell()) pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION, ""); } - if(SfxViewShell* pViewShell = SfxViewShell::Current()) + if(SfxViewShell* pViewShell = GetSfxViewShell()) { pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_GRAPHIC_SELECTION, sSelection.getStr()); SfxLokHelper::notifyOtherViews(pViewShell, LOK_CALLBACK_GRAPHIC_VIEW_SELECTION, "selection", sSelection); @@ -1263,6 +1263,11 @@ void SdrMarkView::SetRef2(const Point& rPt) } } +SfxViewShell* SdrMarkView::GetSfxViewShell() const +{ + return SfxViewShell::Current(); +} + bool SdrPageView::IsObjSelectable(SdrObject *pObj) const { SdrLayerID nLay=pObj->GetLayer(); |