diff options
-rw-r--r-- | include/sfx2/lokhelper.hxx | 2 | ||||
-rw-r--r-- | include/sfx2/viewsh.hxx | 2 | ||||
-rw-r--r-- | sfx2/source/view/lokhelper.cxx | 26 | ||||
-rw-r--r-- | sfx2/source/view/viewsh.cxx | 9 | ||||
-rw-r--r-- | sw/inc/crsrsh.hxx | 3 | ||||
-rw-r--r-- | sw/inc/view.hxx | 2 | ||||
-rw-r--r-- | sw/inc/viscrs.hxx | 4 | ||||
-rw-r--r-- | sw/source/core/crsr/crsrsh.cxx | 5 | ||||
-rw-r--r-- | sw/source/core/crsr/viscrs.cxx | 18 | ||||
-rw-r--r-- | sw/source/uibase/uiview/viewprt.cxx | 5 |
10 files changed, 56 insertions, 20 deletions
diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx index e7dfed49f511..852aa79af058 100644 --- a/include/sfx2/lokhelper.hxx +++ b/include/sfx2/lokhelper.hxx @@ -32,6 +32,8 @@ public: /// Invoke the LOK callback of all views except pThisView, with a payload of rKey-rPayload. static void notifyOtherViews(SfxViewShell* pThisView, int nType, const OString& rKey, const OString& rPayload); + /// Same as notifyOtherViews(), but works on a selected "other" view, not on all of them. + static void notifyOtherView(SfxViewShell* pThisView, SfxViewShell* pOtherView, int nType, const OString& rKey, const OString& rPayload); }; #endif diff --git a/include/sfx2/viewsh.hxx b/include/sfx2/viewsh.hxx index d20d4e35de55..1c7266a141b7 100644 --- a/include/sfx2/viewsh.hxx +++ b/include/sfx2/viewsh.hxx @@ -342,6 +342,8 @@ public: sal_uInt32 GetViewShellId() const override; /// See OutlinerViewShell::NotifyOtherViews(). void NotifyOtherViews(int nType, const OString& rKey, const OString& rPayload) override; + /// Ask this view to send its cursor position to pViewShell. + virtual void NotifyCursor(SfxViewShell* /*pViewShell*/) const; }; diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx index 7a23e1b5dbee..c5fb171f246b 100644 --- a/sfx2/source/view/lokhelper.cxx +++ b/sfx2/source/view/lokhelper.cxx @@ -92,6 +92,19 @@ std::size_t SfxLokHelper::getViews() return rViewArr.size(); } +void SfxLokHelper::notifyOtherView(SfxViewShell* pThisView, SfxViewShell* pOtherView, int nType, const OString& rKey, const OString& rPayload) +{ + 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(); + pOtherView->libreOfficeKitViewCallback(nType, aPayload.getStr()); +} + void SfxLokHelper::notifyOtherViews(SfxViewShell* pThisView, int nType, const OString& rKey, const OString& rPayload) { if (SfxLokHelper::getViews() <= 1) @@ -101,17 +114,8 @@ void SfxLokHelper::notifyOtherViews(SfxViewShell* pThisView, int nType, const OS while (pViewShell) { if (pViewShell != pThisView) - { - 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(); - pViewShell->libreOfficeKitViewCallback(nType, aPayload.getStr()); - } + notifyOtherView(pThisView, pViewShell, nType, rKey, rPayload); + pViewShell = SfxViewShell::GetNext(*pViewShell); } } diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx index f2d8e4875b2a..710c9cbb1189 100644 --- a/sfx2/source/view/viewsh.cxx +++ b/sfx2/source/view/viewsh.cxx @@ -1462,12 +1462,11 @@ void SfxViewShell::registerLibreOfficeKitViewCallback(LibreOfficeKitCallback pCa pImpl->m_pLibreOfficeKitViewCallback = pCallback; pImpl->m_pLibreOfficeKitViewData = pData; - // Ask other views to send their cursor position to the new view. + // Ask other views to tell us about their cursors. SfxViewShell* pViewShell = SfxViewShell::GetFirst(); while (pViewShell) { - pViewShell->ShowCursor(false); - pViewShell->ShowCursor(); + pViewShell->NotifyCursor(this); pViewShell = SfxViewShell::GetNext(*pViewShell); } } @@ -1495,6 +1494,10 @@ void SfxViewShell::libreOfficeKitViewCallback(int nType, const char* pPayload) c pImpl->m_pLibreOfficeKitViewCallback(nType, pPayload, pImpl->m_pLibreOfficeKitViewData); } +void SfxViewShell::NotifyCursor(SfxViewShell* /*pViewShell*/) const +{ +} + void SfxViewShell::setTiledSearching(bool bTiledSearching) { pImpl->m_bTiledSearching = bTiledSearching; diff --git a/sw/inc/crsrsh.hxx b/sw/inc/crsrsh.hxx index dbe62d646350..82671bfbb965 100644 --- a/sw/inc/crsrsh.hxx +++ b/sw/inc/crsrsh.hxx @@ -842,6 +842,9 @@ public: virtual void dumpAsXml(struct _xmlTextWriter* pWriter) const override; /// Implementation of lok::Document::getPartPageRectangles() for Writer. OUString getPageRectangles(); + + /// See SwView::NotifyCursor(). + void NotifyCursor(SfxViewShell* pViewShell) const; }; // Cursor Inlines: diff --git a/sw/inc/view.hxx b/sw/inc/view.hxx index dbae9adcfe6e..76d1a341c6ec 100644 --- a/sw/inc/view.hxx +++ b/sw/inc/view.hxx @@ -648,6 +648,8 @@ public: void dumpAsXml(struct _xmlTextWriter* pWriter) const override; void SetRedlineAuthor(const OUString& rAuthor); const OUString& GetRedlineAuthor(); + /// See SfxViewShell::NotifyCursor(). + void NotifyCursor(SfxViewShell* pViewShell) const override; }; inline long SwView::GetXScroll() const diff --git a/sw/inc/viscrs.hxx b/sw/inc/viscrs.hxx index cd7204dd9fcb..36350487c8e9 100644 --- a/sw/inc/viscrs.hxx +++ b/sw/inc/viscrs.hxx @@ -29,6 +29,7 @@ class SwCursorShell; class SwShellCursor; class SwTextInputField; +class SfxViewShell; // From here classes/methods for non-text cursor. @@ -46,8 +47,6 @@ class SwVisibleCursor /// For LibreOfficeKit only - remember what page we were at the last time. sal_uInt16 m_nPageLastTime; - void SetPosAndShow(); - public: SwVisibleCursor( const SwCursorShell * pCShell ); ~SwVisibleCursor(); @@ -57,6 +56,7 @@ public: bool IsVisible() const { return m_bIsVisible; } void SetDragCursor( bool bFlag = true ) { m_bIsDragCursor = bFlag; } + void SetPosAndShow(SfxViewShell* pViewShell); }; // From here classes/methods for selections. diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx index 1c24eb6be242..0e157784f126 100644 --- a/sw/source/core/crsr/crsrsh.cxx +++ b/sw/source/core/crsr/crsrsh.cxx @@ -1217,6 +1217,11 @@ OUString SwCursorShell::getPageRectangles() return OUString::fromUtf8(comphelper::string::join("; ", v).getStr()); } +void SwCursorShell::NotifyCursor(SfxViewShell* pViewShell) const +{ + m_pVisibleCursor->SetPosAndShow(pViewShell); +} + /// go to the next SSelection bool SwCursorShell::GoNextCursor() { diff --git a/sw/source/core/crsr/viscrs.cxx b/sw/source/core/crsr/viscrs.cxx index 3cb202167514..d2e0fb3e9e98 100644 --- a/sw/source/core/crsr/viscrs.cxx +++ b/sw/source/core/crsr/viscrs.cxx @@ -95,7 +95,7 @@ void SwVisibleCursor::Show() // display at all? if( m_pCursorShell->VisArea().IsOver( m_pCursorShell->m_aCharRect ) || comphelper::LibreOfficeKit::isActive() ) - SetPosAndShow(); + SetPosAndShow(nullptr); } } @@ -110,7 +110,7 @@ void SwVisibleCursor::Hide() } } -void SwVisibleCursor::SetPosAndShow() +void SwVisibleCursor::SetPosAndShow(SfxViewShell* pViewShell) { SwRect aRect; long nTmpY = m_pCursorShell->m_aCursorHeight.getY(); @@ -199,8 +199,18 @@ void SwVisibleCursor::SetPosAndShow() // notify about the cursor position & size Rectangle aSVRect(aRect.Pos().getX(), aRect.Pos().getY(), aRect.Pos().getX() + aRect.SSize().Width(), aRect.Pos().getY() + aRect.SSize().Height()); OString sRect = aSVRect.toString(); - m_pCursorShell->GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR, sRect.getStr()); - SfxLokHelper::notifyOtherViews(m_pCursorShell->GetSfxViewShell(), LOK_CALLBACK_INVALIDATE_VIEW_CURSOR, "rectangle", sRect); + if (pViewShell) + { + if (pViewShell == m_pCursorShell->GetSfxViewShell()) + pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR, sRect.getStr()); + else + SfxLokHelper::notifyOtherView(m_pCursorShell->GetSfxViewShell(), pViewShell, LOK_CALLBACK_INVALIDATE_VIEW_CURSOR, "rectangle", sRect); + } + else + { + m_pCursorShell->GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR, sRect.getStr()); + SfxLokHelper::notifyOtherViews(m_pCursorShell->GetSfxViewShell(), LOK_CALLBACK_INVALIDATE_VIEW_CURSOR, "rectangle", sRect); + } } if ( !m_pCursorShell->IsCursorReadonly() || m_pCursorShell->GetViewOptions()->IsSelectionInReadonly() ) diff --git a/sw/source/uibase/uiview/viewprt.cxx b/sw/source/uibase/uiview/viewprt.cxx index 9a0abf6024dd..44b472b05abf 100644 --- a/sw/source/uibase/uiview/viewprt.cxx +++ b/sw/source/uibase/uiview/viewprt.cxx @@ -279,6 +279,11 @@ const OUString& SwView::GetRedlineAuthor() return m_pViewImpl->m_sRedlineAuthor; } +void SwView::NotifyCursor(SfxViewShell* pViewShell) const +{ + m_pWrtShell->NotifyCursor(pViewShell); +} + // Create page printer/additions for SwView and SwPagePreview VclPtr<SfxTabPage> CreatePrintOptionsPage( vcl::Window *pParent, |