summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/sfx2/lokhelper.hxx2
-rw-r--r--include/sfx2/viewsh.hxx2
-rw-r--r--sfx2/source/view/lokhelper.cxx26
-rw-r--r--sfx2/source/view/viewsh.cxx9
-rw-r--r--sw/inc/crsrsh.hxx3
-rw-r--r--sw/inc/view.hxx2
-rw-r--r--sw/inc/viscrs.hxx4
-rw-r--r--sw/source/core/crsr/crsrsh.cxx5
-rw-r--r--sw/source/core/crsr/viscrs.cxx18
-rw-r--r--sw/source/uibase/uiview/viewprt.cxx5
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 0bda74393033..d74e8b73579c 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 41131604709a..68707875bf0d 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -88,6 +88,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)
@@ -97,17 +110,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 694ea7d6dc58..de2f3e82a547 100644
--- a/sfx2/source/view/viewsh.cxx
+++ b/sfx2/source/view/viewsh.cxx
@@ -1609,12 +1609,11 @@ void SfxViewShell::registerLibreOfficeKitViewCallback(LibreOfficeKitCallback pCa
pImp->m_pLibreOfficeKitViewCallback = pCallback;
pImp->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);
}
}
@@ -1642,6 +1641,10 @@ void SfxViewShell::libreOfficeKitViewCallback(int nType, const char* pPayload) c
pImp->m_pLibreOfficeKitViewCallback(nType, pPayload, pImp->m_pLibreOfficeKitViewData);
}
+void SfxViewShell::NotifyCursor(SfxViewShell* /*pViewShell*/) const
+{
+}
+
void SfxViewShell::setTiledSearching(bool bTiledSearching)
{
pImp->m_bTiledSearching = bTiledSearching;
diff --git a/sw/inc/crsrsh.hxx b/sw/inc/crsrsh.hxx
index c0fa6735b7f0..1848de50640d 100644
--- a/sw/inc/crsrsh.hxx
+++ b/sw/inc/crsrsh.hxx
@@ -847,6 +847,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 acaff3e80585..aaeba12e8645 100644
--- a/sw/inc/view.hxx
+++ b/sw/inc/view.hxx
@@ -655,6 +655,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 701e9cd486ed..6fd615f8ac3e 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 4b2bb2398506..d0da7829cb09 100644
--- a/sw/source/core/crsr/crsrsh.cxx
+++ b/sw/source/core/crsr/crsrsh.cxx
@@ -1224,6 +1224,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 2c0ca9e2073e..b9e9d012109d 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 00f0f5bcad13..072478439803 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,