summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/tiledrendering/tiledrendering.cxx37
-rw-r--r--sw/source/core/crsr/crsrsh.cxx23
2 files changed, 54 insertions, 6 deletions
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index ada126f2723c..10cd61ec5f14 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -603,7 +603,9 @@ class ViewCallback
{
public:
bool m_bOwnCursorInvalidated;
+ Rectangle m_aOwnCursor;
bool m_bViewCursorInvalidated;
+ Rectangle m_aViewCursor;
bool m_bOwnSelectionSet;
bool m_bViewSelectionSet;
OString m_aViewSelection;
@@ -644,11 +646,33 @@ public:
case LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR:
{
m_bOwnCursorInvalidated = true;
+
+ uno::Sequence<OUString> aSeq = comphelper::string::convertCommaSeparated(OUString::fromUtf8(aPayload));
+ if (OString("EMPTY") == pPayload)
+ return;
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(4), aSeq.getLength());
+ m_aOwnCursor.setX(aSeq[0].toInt32());
+ m_aOwnCursor.setY(aSeq[1].toInt32());
+ m_aOwnCursor.setWidth(aSeq[2].toInt32());
+ m_aOwnCursor.setHeight(aSeq[3].toInt32());
}
break;
case LOK_CALLBACK_INVALIDATE_VIEW_CURSOR:
{
m_bViewCursorInvalidated = true;
+ std::stringstream aStream(pPayload);
+ boost::property_tree::ptree aTree;
+ boost::property_tree::read_json(aStream, aTree);
+ OString aRect = aTree.get_child("rectangle").get_value<std::string>().c_str();
+
+ uno::Sequence<OUString> aSeq = comphelper::string::convertCommaSeparated(OUString::fromUtf8(aRect));
+ if (OString("EMPTY") == pPayload)
+ return;
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(4), aSeq.getLength());
+ m_aViewCursor.setX(aSeq[0].toInt32());
+ m_aViewCursor.setY(aSeq[1].toInt32());
+ m_aViewCursor.setWidth(aSeq[2].toInt32());
+ m_aViewCursor.setHeight(aSeq[3].toInt32());
}
break;
case LOK_CALLBACK_TEXT_SELECTION:
@@ -1149,6 +1173,8 @@ void SwTiledRenderingTest::testShapeTextUndoGroupShells()
// Load a document and create a view.
comphelper::LibreOfficeKit::setActive();
SwXTextDocument* pXTextDocument = createDoc("shape.fodt");
+ ViewCallback aView1;
+ SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1);
sal_Int32 nView1 = SfxLokHelper::getView();
// Begin text edit.
@@ -1169,6 +1195,17 @@ void SwTiledRenderingTest::testShapeTextUndoGroupShells()
// This was -1: the view shell id for the (top) undo list action wasn't known.
CPPUNIT_ASSERT_EQUAL(nView1, rUndoManager.GetUndoAction()->GetViewShellId());
+ // Create a second view, and make sure that the new view sees the same
+ // cursor position as the old one.
+ SfxLokHelper::createView();
+ pXTextDocument->initializeForTiledRendering({});
+ ViewCallback aView2;
+ aView2.m_aViewCursor = Rectangle();
+ SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView2);
+ // Difference was 935 twips, the new view didn't see the editeng cursor of
+ // the old one. The new difference should be <1px, but here we deal with twips.
+ CPPUNIT_ASSERT(std::abs(aView1.m_aOwnCursor.Top() - aView2.m_aViewCursor.Top()) < 10);
+
mxComponent->dispose();
mxComponent.clear();
comphelper::LibreOfficeKit::setActive(false);
diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx
index d88d21c52c02..44776817a9d4 100644
--- a/sw/source/core/crsr/crsrsh.cxx
+++ b/sw/source/core/crsr/crsrsh.cxx
@@ -66,6 +66,7 @@
#include <comphelper/lok.hxx>
#include <sfx2/lokhelper.hxx>
#include <comphelper/string.hxx>
+#include <editeng/editview.hxx>
#include <PostItMgr.hxx>
using namespace com::sun::star;
@@ -1226,13 +1227,23 @@ OUString SwCursorShell::getPageRectangles()
void SwCursorShell::NotifyCursor(SfxViewShell* pOtherShell) const
{
- // Cursor position and visibility.
- m_pVisibleCursor->_SetPosAndShow(pOtherShell);
- // Text selection.
- m_pCurrentCursor->Show(pOtherShell);
- // Graphic selection.
auto pView = const_cast<SdrView*>(GetDrawView());
- pView->AdjustMarkHdl(pOtherShell);
+ if (pView->GetTextEditObject())
+ {
+ EditView& rEditView = pView->GetTextEditOutlinerView()->GetEditView();
+ rEditView.RegisterOtherShell(pOtherShell);
+ rEditView.ShowCursor();
+ rEditView.RegisterOtherShell(nullptr);
+ }
+ else
+ {
+ // Cursor position and visibility.
+ m_pVisibleCursor->_SetPosAndShow(pOtherShell);
+ // Text selection.
+ m_pCurrentCursor->Show(pOtherShell);
+ // Graphic selection.
+ pView->AdjustMarkHdl(pOtherShell);
+ }
}
/// go to the next SSelection