summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-09-15 12:17:14 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-09-16 09:23:01 +0200
commit6be239a1595fbe74a138123e155fd432cf1362b3 (patch)
treea0721d5ce4ad3ca9244fe43e31a850325e547fd2 /sd
parentc0dd075d52409031876f5bc3923062ba5847fd53 (diff)
sd draw text: emit LOK_CALLBACK_TEXT_VIEW_SELECTION from registerCallback()
This is basically the Impress equivalent of commit 2ea385a54b53797ab3960869012f3ce3268eab2c (sw draw text: emit LOK_CALLBACK_TEXT_VIEW_SELECTION from registerCallback(), 2016-09-13). Change-Id: Ib138845de6db2a8ad49dc8596af3e05ec5278610 (cherry picked from commit e93b30c9d9f4deba597b73e04df7d4082b779b69)
Diffstat (limited to 'sd')
-rw-r--r--sd/qa/unit/tiledrendering/tiledrendering.cxx19
-rw-r--r--sd/source/ui/view/ViewShellBase.cxx17
2 files changed, 34 insertions, 2 deletions
diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index 38c79b411081..38e917439dc1 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -870,6 +870,7 @@ public:
bool m_bTilesInvalidated;
std::map<int, bool> m_aViewCursorInvalidations;
std::map<int, bool> m_aViewCursorVisibilities;
+ bool m_bViewSelectionSet;
ViewCallback()
: m_bGraphicSelectionInvalidated(false),
@@ -877,7 +878,8 @@ public:
m_nPart(0),
m_bCursorVisibleChanged(false),
m_bViewLock(false),
- m_bTilesInvalidated(false)
+ m_bTilesInvalidated(false),
+ m_bViewSelectionSet(false)
{
}
@@ -941,6 +943,11 @@ public:
m_aViewCursorVisibilities[nViewId] = OString("true") == pPayload;
}
break;
+ case LOK_CALLBACK_TEXT_VIEW_SELECTION:
+ {
+ m_bViewSelectionSet = true;
+ }
+ break;
}
}
};
@@ -1189,6 +1196,12 @@ void SdTiledRenderingTest::testCreateViewTextCursor()
SdrView* pSdrView = pViewShell->GetView();
CPPUNIT_ASSERT(pSdrView->IsTextEdit());
+ // Create an editeng text selection.
+ EditView& rEditView = pSdrView->GetTextEditOutlinerView()->GetEditView();
+ // 0th para, 0th char -> 0th para, 1st char.
+ ESelection aWordSelection(0, 0, 0, 1);
+ rEditView.SetSelection(aWordSelection);
+
// Make sure that creating a new view either doesn't affect the previous
// one, or at least the effect is not visible at the end.
aView1.m_aViewCursorInvalidations.clear();
@@ -1196,6 +1209,7 @@ void SdTiledRenderingTest::testCreateViewTextCursor()
SfxLokHelper::createView();
pXImpressDocument->initializeForTiledRendering({});
ViewCallback aView2;
+ aView2.m_bViewSelectionSet = false;
SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView2);
bool bFoundCursor = false;
for (const auto& rInvalidation : aView1.m_aViewCursorInvalidations)
@@ -1211,6 +1225,9 @@ void SdTiledRenderingTest::testCreateViewTextCursor()
// This failed: the second view created an unexpected view cursor in the
// first view.
CPPUNIT_ASSERT(!bFoundCursor);
+ // This failed: the text view selection of the first view wasn't seen by
+ // the second view.
+ CPPUNIT_ASSERT(aView2.m_bViewSelectionSet);
mxComponent->dispose();
mxComponent.clear();
diff --git a/sd/source/ui/view/ViewShellBase.cxx b/sd/source/ui/view/ViewShellBase.cxx
index 94a41f82341c..ad60dd74442f 100644
--- a/sd/source/ui/view/ViewShellBase.cxx
+++ b/sd/source/ui/view/ViewShellBase.cxx
@@ -86,6 +86,7 @@
#include <tools/diagnose_ex.h>
#include <sfx2/lokhelper.hxx>
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
+#include <editeng/editview.hxx>
#include "fubullet.hxx"
#include "drawview.hxx"
@@ -1061,7 +1062,21 @@ void ViewShellBase::NotifyCursor(SfxViewShell* pOtherShell) const
if (!pDrawView)
return;
- pDrawView->AdjustMarkHdl(pOtherShell);
+ if (pDrawView->GetTextEditObject())
+ {
+ // Blinking cursor.
+ EditView& rEditView = pDrawView->GetTextEditOutlinerView()->GetEditView();
+ rEditView.RegisterOtherShell(pOtherShell);
+ rEditView.ShowCursor();
+ rEditView.RegisterOtherShell(nullptr);
+ // Text selection, if any.
+ rEditView.DrawSelection(pOtherShell);
+ }
+ else
+ {
+ // Graphic selection.
+ pDrawView->AdjustMarkHdl(pOtherShell);
+ }
}
//===== ViewShellBase::Implementation =========================================