[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.1' - 3 commits - sw/inc sw/qa sw/source
Miklos Vajna
vmiklos at collabora.co.uk
Tue Sep 13 06:55:18 UTC 2016
sw/inc/viscrs.hxx | 2
sw/qa/extras/tiledrendering/tiledrendering.cxx | 75 +++++++++++++++++++++++++
sw/source/core/crsr/crsrsh.cxx | 15 +++--
sw/source/core/crsr/viscrs.cxx | 18 +++++-
sw/source/core/draw/dview.cxx | 5 +
sw/source/core/inc/dview.hxx | 3 +
sw/source/uibase/uiview/viewprt.cxx | 2
7 files changed, 109 insertions(+), 11 deletions(-)
New commits:
commit 176c7905f469bcefb06dc0772a6bbadfc8a8833f
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Mon Sep 12 17:05:10 2016 +0200
sw: emit LOK_CALLBACK_TEXT_VIEW_SELECTION as part of registerCallback()
Have a Writer text selection in the first view, create a new view, the
second view doesn't see the selection. But the same works if the text
selection is created when the second view was created earlier.
Emit the selection state as part of SwCursorShell::NotifyCursor() to fix
the problem.
Reviewed-on: https://gerrit.libreoffice.org/28844
Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
Tested-by: Jenkins <ci at libreoffice.org>
(cherry picked from commit c4224e6cafa5aa5c604dfdc0daf7f145aa6c08be)
Conflicts:
sw/source/core/crsr/crsrsh.cxx
Change-Id: I7d71c9b58941c8ca8720b0e63e54bc757b1aaf61
diff --git a/sw/inc/viscrs.hxx b/sw/inc/viscrs.hxx
index 6fd615f..b1ec305 100644
--- a/sw/inc/viscrs.hxx
+++ b/sw/inc/viscrs.hxx
@@ -137,7 +137,7 @@ public:
/// @see SwSelPaintRects::FillStartEnd(), override for text selections.
virtual void FillStartEnd(SwRect& rStart, SwRect& rEnd) const override;
- void Show(); // Update and display all selections.
+ void Show(SfxViewShell* pViewShell); // Update and display all selections.
void Hide(); // Hide all selections.
void Invalidate( const SwRect& rRect );
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 142ca10..048ade6 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -73,6 +73,7 @@ public:
void testRedlineUpdateCallback();
void testSetViewGraphicSelection();
void testCreateViewGraphicSelection();
+ void testCreateViewTextSelection();
CPPUNIT_TEST_SUITE(SwTiledRenderingTest);
CPPUNIT_TEST(testRegisterCallback);
@@ -110,6 +111,7 @@ public:
CPPUNIT_TEST(testRedlineUpdateCallback);
CPPUNIT_TEST(testSetViewGraphicSelection);
CPPUNIT_TEST(testCreateViewGraphicSelection);
+ CPPUNIT_TEST(testCreateViewTextSelection);
CPPUNIT_TEST_SUITE_END();
private:
@@ -604,6 +606,7 @@ public:
bool m_bViewCursorInvalidated;
bool m_bOwnSelectionSet;
bool m_bViewSelectionSet;
+ OString m_aViewSelection;
bool m_bTilesInvalidated;
bool m_bViewCursorVisible;
bool m_bGraphicViewSelection;
@@ -656,6 +659,7 @@ public:
case LOK_CALLBACK_TEXT_VIEW_SELECTION:
{
m_bViewSelectionSet = true;
+ m_aViewSelection = aPayload;
}
break;
case LOK_CALLBACK_VIEW_CURSOR_VISIBLE:
@@ -1310,6 +1314,39 @@ void SwTiledRenderingTest::testCreateViewGraphicSelection()
comphelper::LibreOfficeKit::setActive(false);
}
+void SwTiledRenderingTest::testCreateViewTextSelection()
+{
+ // Load a document.
+ comphelper::LibreOfficeKit::setActive();
+ SwXTextDocument* pXTextDocument = createDoc("dummy.fodt");
+ ViewCallback aView1;
+ SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1);
+
+ // Create a text selection:
+ SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+ // Move the cursor into the second word.
+ pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/false, 5, /*bBasicCall=*/false);
+ // Create a selection on the word.
+ pWrtShell->SelWrd();
+ SwShellCursor* pShellCursor = pWrtShell->getShellCursor(false);
+ // Did we indeed manage to select the second word?
+ CPPUNIT_ASSERT_EQUAL(OUString("bbb"), pShellCursor->GetText());
+
+ // Create a second view.
+ SfxLokHelper::createView();
+
+ // Make sure that the text selection is visible in the second view.
+ ViewCallback aView2;
+ aView2.m_bViewSelectionSet = true;
+ SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView2);
+ // This failed, the second view didn't get the text selection of the first view.
+ CPPUNIT_ASSERT(!aView2.m_aViewSelection.isEmpty());
+
+ mxComponent->dispose();
+ mxComponent.clear();
+ comphelper::LibreOfficeKit::setActive(false);
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SwTiledRenderingTest);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx
index d0da782..72ed33c 100644
--- a/sw/source/core/crsr/crsrsh.cxx
+++ b/sw/source/core/crsr/crsrsh.cxx
@@ -1226,7 +1226,10 @@ OUString SwCursorShell::getPageRectangles()
void SwCursorShell::NotifyCursor(SfxViewShell* pViewShell) const
{
+ // Cursor position and visibility.
m_pVisibleCursor->_SetPosAndShow(pViewShell);
+ // Text selection.
+ m_pCurrentCursor->Show(pViewShell);
}
/// go to the next SSelection
@@ -1243,7 +1246,7 @@ bool SwCursorShell::GoNextCursor()
if( !ActionPend() )
{
UpdateCursor();
- m_pCurrentCursor->Show();
+ m_pCurrentCursor->Show(nullptr);
}
return true;
}
@@ -1262,7 +1265,7 @@ bool SwCursorShell::GoPrevCursor()
if( !ActionPend() )
{
UpdateCursor();
- m_pCurrentCursor->Show();
+ m_pCurrentCursor->Show(nullptr);
}
return true;
}
@@ -1294,7 +1297,7 @@ void SwCursorShell::Paint(vcl::RenderContext& rRenderContext, const Rectangle &r
{
// so that right/bottom borders will not be cropped
pAktCursor->Invalidate( VisArea() );
- pAktCursor->Show();
+ pAktCursor->Show(nullptr);
}
else
pAktCursor->Invalidate( aRect );
@@ -1586,7 +1589,7 @@ void SwCursorShell::UpdateCursor( sal_uInt16 eFlags, bool bIdleEnd )
if( m_pTableCursor->IsCursorMovedUpdate() )
GetLayout()->MakeTableCursors( *m_pTableCursor );
if( m_bHasFocus && !m_bBasicHideCursor )
- m_pTableCursor->Show();
+ m_pTableCursor->Show(nullptr);
// set Cursor-Points to the new Positions
m_pTableCursor->GetPtPos().setX(m_aCharRect.Left());
@@ -2137,7 +2140,7 @@ void SwCursorShell::ShowCursors( bool bCursorVis )
SET_CURR_SHELL( this );
SwShellCursor* pAktCursor = m_pTableCursor ? m_pTableCursor : m_pCurrentCursor;
- pAktCursor->Show();
+ pAktCursor->Show(nullptr);
if( m_bSVCursorVis && bCursorVis ) // also show SV cursor again
m_pVisibleCursor->Show();
@@ -2414,7 +2417,7 @@ bool SwCursorShell::SetVisibleCursor( const Point &rPt )
if( IsScrollMDI( this, m_aCharRect ))
{
MakeVisible( m_aCharRect );
- m_pCurrentCursor->Show();
+ m_pCurrentCursor->Show(nullptr);
}
{
diff --git a/sw/source/core/crsr/viscrs.cxx b/sw/source/core/crsr/viscrs.cxx
index 126df5f..4ac52fb 100644
--- a/sw/source/core/crsr/viscrs.cxx
+++ b/sw/source/core/crsr/viscrs.cxx
@@ -600,7 +600,7 @@ void SwShellCursor::FillRects()
GetShell()->GetLayout()->CalcFrameRects( *this );
}
-void SwShellCursor::Show()
+void SwShellCursor::Show(SfxViewShell* pViewShell)
{
std::vector<OString> aSelectionRectangles;
for(SwPaM& rPaM : GetRingContainer())
@@ -621,8 +621,17 @@ void SwShellCursor::Show()
aRect.push_back(rSelectionRectangle);
}
OString sRect = comphelper::string::join("; ", aRect);
- GetShell()->GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION, sRect.getStr());
- SfxLokHelper::notifyOtherViews(GetShell()->GetSfxViewShell(), LOK_CALLBACK_TEXT_VIEW_SELECTION, "selection", sRect);
+ if (pViewShell)
+ {
+ // Just notify pViewShell about our existing selection.
+ if (pViewShell != GetShell()->GetSfxViewShell())
+ SfxLokHelper::notifyOtherView(GetShell()->GetSfxViewShell(), pViewShell, LOK_CALLBACK_TEXT_VIEW_SELECTION, "selection", sRect);
+ }
+ else
+ {
+ GetShell()->GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION, sRect.getStr());
+ SfxLokHelper::notifyOtherViews(GetShell()->GetSfxViewShell(), LOK_CALLBACK_TEXT_VIEW_SELECTION, "selection", sRect);
+ }
}
}
commit 50b66e4d3ef790b4228a3cc099346edf1838f2e7
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Mon Sep 12 13:35:11 2016 +0200
sw: emit LOK_CALLBACK_VIEW_CURSOR_VISIBLE as part of registerCallback()
Have a graphic selection (and thus a hidden text cursor) in the first
view, create a second view. The view text cursors should be hidden in
the second view as well.
Change-Id: Ic22db84aab62c8f43c2da3d4a19b56c993c9f012
Reviewed-on: https://gerrit.libreoffice.org/28836
Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
Tested-by: Jenkins <ci at libreoffice.org>
(cherry picked from commit ab6dcd326ad7bf8c47a820514440bf8ac5f0d5f3)
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index c8dbaa4..142ca10 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -1297,6 +1297,14 @@ void SwTiledRenderingTest::testCreateViewGraphicSelection()
// first one.
CPPUNIT_ASSERT(aView1.m_bGraphicSelection);
+ // Make sure that the hidden text cursor isn't visible in the second view, either.
+ ViewCallback aView2;
+ aView2.m_bViewCursorVisible = true;
+ SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView2);
+ // This was true, the second view didn't get the visibility of the text
+ // cursor of the first view.
+ CPPUNIT_ASSERT(!aView2.m_bViewCursorVisible);
+
mxComponent->dispose();
mxComponent.clear();
comphelper::LibreOfficeKit::setActive(false);
diff --git a/sw/source/core/crsr/viscrs.cxx b/sw/source/core/crsr/viscrs.cxx
index b9e9d01..126df5f 100644
--- a/sw/source/core/crsr/viscrs.cxx
+++ b/sw/source/core/crsr/viscrs.cxx
@@ -204,7 +204,10 @@ void SwVisibleCursor::_SetPosAndShow(SfxViewShell* 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);
+ SfxLokHelper::notifyOtherView(m_pCursorShell->GetSfxViewShell(), pViewShell, LOK_CALLBACK_VIEW_CURSOR_VISIBLE, "visible", OString::boolean(m_bIsVisible));
+ }
}
else
{
commit 1cabcedcff279b95635e457ef36bb4a07f7947aa
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Mon Sep 12 11:56:02 2016 +0200
sw: implement SdrMarkView::GetSfxViewShell() API
With this, the graphic selection is no longer lost when creating a new
view. That happened as the SwView ctor calls
SdrMarkView::SetMarkHandles() while the new view is not yet current,
which resulted clearing the graphic selection in the old view, not in
the new one.
A side-effect of introducing SwDrawView::GetSfxViewShell() is that now
SwView::getPart() is called from the SwView dtor, guard against doing
any real work there in that situation to avoid potentially reading
already deleted data.
Change-Id: I4fab39a907d2cbe228c0fc8d44bedc64893387d1
Reviewed-on: https://gerrit.libreoffice.org/28832
Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
Tested-by: Jenkins <ci at libreoffice.org>
(cherry picked from commit 65828fa693507d699369f0dbc3c0bfc31638d945)
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 4861f12..c8dbaa4 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -72,6 +72,7 @@ public:
void testTrackChangesCallback();
void testRedlineUpdateCallback();
void testSetViewGraphicSelection();
+ void testCreateViewGraphicSelection();
CPPUNIT_TEST_SUITE(SwTiledRenderingTest);
CPPUNIT_TEST(testRegisterCallback);
@@ -108,6 +109,7 @@ public:
CPPUNIT_TEST(testTrackChangesCallback);
CPPUNIT_TEST(testRedlineUpdateCallback);
CPPUNIT_TEST(testSetViewGraphicSelection);
+ CPPUNIT_TEST(testCreateViewGraphicSelection);
CPPUNIT_TEST_SUITE_END();
private:
@@ -1272,6 +1274,34 @@ void SwTiledRenderingTest::testSetViewGraphicSelection()
comphelper::LibreOfficeKit::setActive(false);
}
+void SwTiledRenderingTest::testCreateViewGraphicSelection()
+{
+ // Load a document.
+ comphelper::LibreOfficeKit::setActive();
+ SwXTextDocument* pXTextDocument = createDoc("frame.odt");
+ ViewCallback aView1;
+ SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1);
+
+ // Mark the textframe in the first view.
+ SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+ SdrPage* pPage = pWrtShell->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0);
+ SdrObject* pObject = pPage->GetObj(0);
+ SdrView* pView = pWrtShell->GetDrawView();
+ aView1.m_bGraphicSelection = true;
+ pView->MarkObj(pObject, pView->GetSdrPageView());
+ CPPUNIT_ASSERT(aView1.m_bGraphicSelection);
+
+ // Create a second view.
+ SfxLokHelper::createView();
+ // This was false, creating a second view cleared the selection of the
+ // first one.
+ CPPUNIT_ASSERT(aView1.m_bGraphicSelection);
+
+ mxComponent->dispose();
+ mxComponent.clear();
+ comphelper::LibreOfficeKit::setActive(false);
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SwTiledRenderingTest);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/core/draw/dview.cxx b/sw/source/core/draw/dview.cxx
index ad6f7df..ab5df7c 100644
--- a/sw/source/core/draw/dview.cxx
+++ b/sw/source/core/draw/dview.cxx
@@ -919,6 +919,11 @@ void SwDrawView::ReplaceMarkedDrawVirtObjs( SdrMarkView& _rMarkView )
}
}
+SfxViewShell* SwDrawView::GetSfxViewShell() const
+{
+ return rImp.GetShell()->GetSfxViewShell();
+}
+
void SwDrawView::DeleteMarked()
{
SwDoc* pDoc = Imp().GetShell()->GetDoc();
diff --git a/sw/source/core/inc/dview.hxx b/sw/source/core/inc/dview.hxx
index 9bf76c1..4145c51 100644
--- a/sw/source/core/inc/dview.hxx
+++ b/sw/source/core/inc/dview.hxx
@@ -112,6 +112,9 @@ public:
// method to replace marked/selected <SwDrawVirtObj>
// by its reference object for delete of selection and group selection
static void ReplaceMarkedDrawVirtObjs( SdrMarkView& _rMarkView );
+
+ /// See SdrMarkView::GetSfxViewShell().
+ SfxViewShell* GetSfxViewShell() const override;
};
#endif
diff --git a/sw/source/uibase/uiview/viewprt.cxx b/sw/source/uibase/uiview/viewprt.cxx
index 0724784..3317aca 100644
--- a/sw/source/uibase/uiview/viewprt.cxx
+++ b/sw/source/uibase/uiview/viewprt.cxx
@@ -250,7 +250,7 @@ void SwView::ExecutePrint(SfxRequest& rReq)
int SwView::getPart() const
{
- if (!m_pWrtShell)
+ if (m_bInDtor || !m_pWrtShell)
return 0;
sal_uInt16 nPage, nLogPage;
More information about the Libreoffice-commits
mailing list