diff options
-rw-r--r-- | include/sfx2/viewsh.hxx | 2 | ||||
-rw-r--r-- | sc/source/ui/inc/tabvwsh.hxx | 2 | ||||
-rw-r--r-- | sc/source/ui/unoobj/docuno.cxx | 2 | ||||
-rw-r--r-- | sc/source/ui/view/tabvwshc.cxx | 5 | ||||
-rw-r--r-- | sd/qa/unit/tiledrendering/data/shape.odp | bin | 10159 -> 10446 bytes | |||
-rw-r--r-- | sd/qa/unit/tiledrendering/tiledrendering.cxx | 57 | ||||
-rw-r--r-- | sd/source/ui/inc/ViewShellBase.hxx | 2 | ||||
-rw-r--r-- | sd/source/ui/unoidl/unomodel.cxx | 3 | ||||
-rw-r--r-- | sd/source/ui/view/ViewShellBase.cxx | 13 | ||||
-rw-r--r-- | sfx2/source/view/lokhelper.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/view/viewsh.cxx | 5 | ||||
-rw-r--r-- | sw/inc/view.hxx | 2 | ||||
-rw-r--r-- | sw/source/uibase/uiview/viewprt.cxx | 12 | ||||
-rw-r--r-- | sw/source/uibase/uno/unotxdoc.cxx | 10 |
14 files changed, 104 insertions, 13 deletions
diff --git a/include/sfx2/viewsh.hxx b/include/sfx2/viewsh.hxx index fba08dfead2b..56888cad22fd 100644 --- a/include/sfx2/viewsh.hxx +++ b/include/sfx2/viewsh.hxx @@ -331,6 +331,8 @@ public: void setTiledSearching(bool bTiledSearching); /// Are we doing tiled searching? bool isTiledSearching() const; + /// See lok::Document::getPart(). + virtual int getPart() const; }; diff --git a/sc/source/ui/inc/tabvwsh.hxx b/sc/source/ui/inc/tabvwsh.hxx index b937da880376..6bae511512ef 100644 --- a/sc/source/ui/inc/tabvwsh.hxx +++ b/sc/source/ui/inc/tabvwsh.hxx @@ -384,6 +384,8 @@ public: // #i123629# bool GetForceFocusOnCurCell() const { return bForceFocusOnCurCell; } void SetForceFocusOnCurCell(bool bFlag) { bForceFocusOnCurCell=bFlag; } + /// See SfxViewShell::getPart(). + int getPart() const override; }; #endif diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx index af54d3886fa6..f7d8b91f7c4f 100644 --- a/sc/source/ui/unoobj/docuno.cxx +++ b/sc/source/ui/unoobj/docuno.cxx @@ -514,7 +514,7 @@ int ScModelObj::getParts() int ScModelObj::getPart() { ScViewData* pViewData = ScDocShell::GetViewData(); - return pViewData->GetTabNo(); + return pViewData->GetViewShell()->getPart(); } OUString ScModelObj::getPartName( int nPart ) diff --git a/sc/source/ui/view/tabvwshc.cxx b/sc/source/ui/view/tabvwshc.cxx index bfe6d8e72164..9cdc11ebaf82 100644 --- a/sc/source/ui/view/tabvwshc.cxx +++ b/sc/source/ui/view/tabvwshc.cxx @@ -536,4 +536,9 @@ VclPtr<SfxModelessDialog> ScTabViewShell::CreateRefDialog( return pResult; } +int ScTabViewShell::getPart() const +{ + return GetViewData().GetTabNo(); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/qa/unit/tiledrendering/data/shape.odp b/sd/qa/unit/tiledrendering/data/shape.odp Binary files differindex f73476140d73..b1ffa54e367f 100644 --- a/sd/qa/unit/tiledrendering/data/shape.odp +++ b/sd/qa/unit/tiledrendering/data/shape.odp diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx index a465b63ea93a..948f06d9a9a0 100644 --- a/sd/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx @@ -64,6 +64,7 @@ public: void testResizeTable(); void testResizeTableColumn(); void testViewCursors(); + void testViewCursorParts(); CPPUNIT_TEST_SUITE(SdTiledRenderingTest); CPPUNIT_TEST(testRegisterCallback); @@ -84,6 +85,7 @@ public: CPPUNIT_TEST(testResizeTable); CPPUNIT_TEST(testResizeTableColumn); CPPUNIT_TEST(testViewCursors); + CPPUNIT_TEST(testViewCursorParts); CPPUNIT_TEST_SUITE_END(); private: @@ -814,10 +816,13 @@ class ViewCallback public: bool m_bGraphicSelectionInvalidated; bool m_bGraphicViewSelectionInvalidated; + /// Our current part, to be able to decide if a view cursor/selection is relevant for us. + int m_nPart; ViewCallback() : m_bGraphicSelectionInvalidated(false), - m_bGraphicViewSelectionInvalidated(false) + m_bGraphicViewSelectionInvalidated(false), + m_nPart(0) { } @@ -826,7 +831,7 @@ public: static_cast<ViewCallback*>(pData)->callbackImpl(nType, pPayload); } - void callbackImpl(int nType, const char* /*pPayload*/) + void callbackImpl(int nType, const char* pPayload) { switch (nType) { @@ -837,7 +842,12 @@ public: break; case LOK_CALLBACK_GRAPHIC_VIEW_SELECTION: { - m_bGraphicViewSelectionInvalidated = true; + std::stringstream aStream(pPayload); + boost::property_tree::ptree aTree; + boost::property_tree::read_json(aStream, aTree); + if (aTree.get_child("part").get_value<int>() == m_nPart) + // Ignore callbacks which are for a different part. + m_bGraphicViewSelectionInvalidated = true; } break; } @@ -874,6 +884,47 @@ void SdTiledRenderingTest::testViewCursors() comphelper::LibreOfficeKit::setActive(false); } +void SdTiledRenderingTest::testViewCursorParts() +{ + comphelper::LibreOfficeKit::setActive(); + + // Create two views. + SdXImpressDocument* pXImpressDocument = createDoc("shape.odp"); + ViewCallback aView1; + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1); + SfxLokHelper::createView(); + pXImpressDocument->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>()); + ViewCallback aView2; + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView2); + + // Select the shape in the second view. + sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell(); + SdPage* pActualPage = pViewShell->GetActualPage(); + SdrObject* pObject = pActualPage->GetObj(0); + SdrView* pView = pViewShell->GetView(); + pView->MarkObj(pObject, pView->GetSdrPageView()); + Scheduler::ProcessEventsToIdle(); + // First view notices that there was a selection change in the other view. + CPPUNIT_ASSERT(aView1.m_bGraphicViewSelectionInvalidated); + pView->UnmarkAllObj(pView->GetSdrPageView()); + + // Now switch to the second part in the second view. + pXImpressDocument->setPart(1); + aView2.m_nPart = 1; + aView1.m_bGraphicViewSelectionInvalidated = false; + pActualPage = pViewShell->GetActualPage(); + pObject = pActualPage->GetObj(0); + pView->MarkObj(pObject, pView->GetSdrPageView()); + Scheduler::ProcessEventsToIdle(); + // First view ignores view selection, as it would be for part 1, and it's in part 0. + // This failed when the "part" was always 0 in the callback. + CPPUNIT_ASSERT(!aView1.m_bGraphicViewSelectionInvalidated); + + mxComponent->dispose(); + mxComponent.clear(); + comphelper::LibreOfficeKit::setActive(false); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SdTiledRenderingTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sd/source/ui/inc/ViewShellBase.hxx b/sd/source/ui/inc/ViewShellBase.hxx index 546dbef4acae..4d92b0d671fe 100644 --- a/sd/source/ui/inc/ViewShellBase.hxx +++ b/sd/source/ui/inc/ViewShellBase.hxx @@ -217,6 +217,8 @@ public: /** returns the ui descriptive name for the given uno slot. The result is taken from the configuration and not cached, so do not use it excessive (f.e. in status updates) */ OUString RetrieveLabelFromCommand( const OUString& aCmdURL ) const; + /// See SfxViewShell::getPart(). + int getPart() const override; protected: diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx index 6902bbade4fc..851f38c11a15 100644 --- a/sd/source/ui/unoidl/unomodel.cxx +++ b/sd/source/ui/unoidl/unomodel.cxx @@ -2309,8 +2309,7 @@ int SdXImpressDocument::getPart() if (!pViewSh) return 0; - // curPageId seems to start at 1 - return pViewSh->GetCurPageId() - 1; + return pViewSh->GetViewShellBase().getPart(); } OUString SdXImpressDocument::getPartName( int nPart ) diff --git a/sd/source/ui/view/ViewShellBase.cxx b/sd/source/ui/view/ViewShellBase.cxx index 3da448914465..f22a8a4a7486 100644 --- a/sd/source/ui/view/ViewShellBase.cxx +++ b/sd/source/ui/view/ViewShellBase.cxx @@ -1020,6 +1020,19 @@ OUString ViewShellBase::RetrieveLabelFromCommand( const OUString& aCmdURL ) cons return ImplRetrieveLabelFromCommand( xFrame, aCmdURL ); } +int ViewShellBase::getPart() const +{ + ViewShell* pViewShell = framework::FrameworkHelper::Instance(*const_cast<ViewShellBase*>(this))->GetViewShell(FrameworkHelper::msCenterPaneURL).get(); + + if (DrawViewShell* pDrawViewShell = dynamic_cast<DrawViewShell*>(pViewShell)) + { + // curPageId seems to start at 1 + return pDrawViewShell->GetCurPageId() - 1; + } + + return 0; +} + //===== ViewShellBase::Implementation ========================================= ViewShellBase::Implementation::Implementation (ViewShellBase& rBase) diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx index d027bad47f15..09d78cf8601d 100644 --- a/sfx2/source/view/lokhelper.cxx +++ b/sfx2/source/view/lokhelper.cxx @@ -108,6 +108,8 @@ void SfxLokHelper::notifyOtherViews(SfxViewShell* pThisView, int nType, const OS boost::property_tree::ptree aTree; aTree.put("viewId", SfxLokHelper::getView(pThisView)); aTree.put(rKey.getStr(), rPayload.getStr()); + aTree.put("part", pThisView->getPart()); + aTree.put(rKey.getStr(), rPayload.getStr()); std::stringstream aStream; boost::property_tree::write_json(aStream, aTree); OString aPayload = aStream.str().c_str(); diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx index d003d8842cc8..1bac0ac5d141 100644 --- a/sfx2/source/view/viewsh.cxx +++ b/sfx2/source/view/viewsh.cxx @@ -1496,6 +1496,11 @@ bool SfxViewShell::isTiledSearching() const return pImpl->m_bTiledSearching; } +int SfxViewShell::getPart() const +{ + return 0; +} + bool SfxViewShell::KeyInput( const KeyEvent &rKeyEvent ) /* [Description] diff --git a/sw/inc/view.hxx b/sw/inc/view.hxx index e1f7f3a88f91..a0b051973679 100644 --- a/sw/inc/view.hxx +++ b/sw/inc/view.hxx @@ -642,6 +642,8 @@ public: SAL_DLLPRIVATE virtual VclPtr<SfxTabPage> CreatePrintOptionsPage( vcl::Window* pParent, const SfxItemSet& rSet) override; static SvxSearchItem* GetSearchItem() { return m_pSrchItem; } + /// See SfxViewShell::getPart(). + int getPart() const override; }; inline long SwView::GetXScroll() const diff --git a/sw/source/uibase/uiview/viewprt.cxx b/sw/source/uibase/uiview/viewprt.cxx index 532b9e715cfd..f9a116b96428 100644 --- a/sw/source/uibase/uiview/viewprt.cxx +++ b/sw/source/uibase/uiview/viewprt.cxx @@ -246,6 +246,18 @@ void SwView::ExecutePrint(SfxRequest& rReq) } } +int SwView::getPart() const +{ + if (!m_pWrtShell) + return 0; + + sal_uInt16 nPage, nLogPage; + OUString sDisplay; + m_pWrtShell->GetPageNumber(-1, m_pWrtShell->IsCursorVisible(), nPage, nLogPage, sDisplay); + + return nPage - 1; +} + // Create page printer/additions for SwView and SwPagePreview VclPtr<SfxTabPage> CreatePrintOptionsPage( vcl::Window *pParent, diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx index a4290b8c94a3..2aab84f0eec9 100644 --- a/sw/source/uibase/uno/unotxdoc.cxx +++ b/sw/source/uibase/uno/unotxdoc.cxx @@ -3230,15 +3230,11 @@ int SwXTextDocument::getPart() { SolarMutexGuard aGuard; - SwWrtShell* pWrtShell = pDocShell->GetWrtShell(); - if (!pWrtShell) + SwView* pView = pDocShell->GetView(); + if (!pView) return 0; - sal_uInt16 nPage, nLogPage; - OUString sDisplay; - pWrtShell->GetPageNumber(-1, pWrtShell->IsCursorVisible(), nPage, nLogPage, sDisplay); - - return nPage - 1; + return pView->getPart(); } OUString SwXTextDocument::getPartName(int nPart) |