libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx | 9 ++++-- sd/qa/unit/tiledrendering/tiledrendering.cxx | 19 ++++++++++++ sd/source/ui/view/ViewShellBase.cxx | 17 ++++++++++- sw/qa/extras/uiwriter/uiwriter.cxx | 30 ++++++++++++++++++-- sw/sdi/swriter.sdi | 3 -- sw/source/uibase/uiview/view2.cxx | 16 +++++++++- 6 files changed, 83 insertions(+), 11 deletions(-)
New commits: commit 5cd5f66c42b9bf8cdb6b6065dd0877a50e343294 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Thu Sep 15 16:04:05 2016 +0200 sw: allow select of redline by index Previously .uno:NextTrackedChange always worked by cursor position, but redlines are stored in the redline table, so they have a unique index. Allow specifying that index when invoking the command, and in that case ignore the cursor position. (cherry picked from commit 84e91157c674b0b78b792fc1d4f841fe50b1dd9b) Change-Id: I7dbe8044feca8fcc48635482a22317b024f40ffa diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx index 01290d4..b8a90afbc 100644 --- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx +++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx @@ -482,6 +482,8 @@ static void documentRedline(GtkWidget* pButton, gpointer /*pItem*/) GTK_RESPONSE_YES, "Reject", GTK_RESPONSE_NO, + "Jump", + GTK_RESPONSE_APPLY, nullptr); GtkWidget* pContentArea = gtk_dialog_get_content_area(GTK_DIALOG (pDialog)); @@ -518,7 +520,7 @@ static void documentRedline(GtkWidget* pButton, gpointer /*pItem*/) gint res = gtk_dialog_run(GTK_DIALOG(pDialog)); // Dispatch the matching command, if necessary. - if (res == GTK_RESPONSE_YES || res == GTK_RESPONSE_NO) + if (res == GTK_RESPONSE_YES || res == GTK_RESPONSE_NO || res == GTK_RESPONSE_APPLY) { GtkTreeSelection* pSelection = gtk_tree_view_get_selection(GTK_TREE_VIEW(pTreeView)); GtkTreeIter aTreeIter; @@ -531,8 +533,11 @@ static void documentRedline(GtkWidget* pButton, gpointer /*pItem*/) std::string aCommand; if (res == GTK_RESPONSE_YES) aCommand = ".uno:AcceptTrackedChange"; - else + else if (res == GTK_RESPONSE_NO) aCommand = ".uno:RejectTrackedChange"; + else + // Just select the given redline, don't accept or reject it. + aCommand = ".uno:NextTrackedChange"; // Without the '.uno:' prefix. std::string aKey = aCommand.substr(strlen(".uno:")); diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index 656eb76..d63b3fc 100644 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -3281,15 +3281,39 @@ void SwUiWriterTest::testRedlineParam() pWrtShell->EndDoc(); pWrtShell->Insert("zzz"); - // Move the cursor to the start again, and reject the second change. + // Select the first redline. pWrtShell->SttDoc(); uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence( { - {"RejectTrackedChange", uno::makeAny(static_cast<sal_uInt16>(1))} + {"NextTrackedChange", uno::makeAny(static_cast<sal_uInt16>(0))} })); - lcl_dispatchCommand(mxComponent, ".uno:RejectTrackedChange", aPropertyValues); + lcl_dispatchCommand(mxComponent, ".uno:NextTrackedChange", aPropertyValues); Scheduler::ProcessEventsToIdle(); SwShellCursor* pShellCursor = pWrtShell->getShellCursor(false); + // This failed: the parameter wasn't handled so the next change (zzz) was + // selected, not the first one (aaa). + CPPUNIT_ASSERT_EQUAL(OUString("aaa"), pShellCursor->GetText()); + + // Select the second redline. + pWrtShell->SttDoc(); + aPropertyValues = comphelper::InitPropertySequence( + { + {"NextTrackedChange", uno::makeAny(static_cast<sal_uInt16>(1))} + }); + lcl_dispatchCommand(mxComponent, ".uno:NextTrackedChange", aPropertyValues); + Scheduler::ProcessEventsToIdle(); + pShellCursor = pWrtShell->getShellCursor(false); + CPPUNIT_ASSERT_EQUAL(OUString("zzz"), pShellCursor->GetText()); + + // Move the cursor to the start again, and reject the second change. + pWrtShell->SttDoc(); + aPropertyValues = comphelper::InitPropertySequence( + { + {"RejectTrackedChange", uno::makeAny(static_cast<sal_uInt16>(1))} + }); + lcl_dispatchCommand(mxComponent, ".uno:RejectTrackedChange", aPropertyValues); + Scheduler::ProcessEventsToIdle(); + pShellCursor = pWrtShell->getShellCursor(false); // This was 'middlezzz', the uno command rejected the redline under the // cursor, instead of the requested one. diff --git a/sw/sdi/swriter.sdi b/sw/sdi/swriter.sdi index f7e7291..c0ba826 100644 --- a/sw/sdi/swriter.sdi +++ b/sw/sdi/swriter.sdi @@ -9972,6 +9972,7 @@ SfxVoidItem RejectTrackedChange FN_REDLINE_REJECT_DIRECT ] SfxVoidItem NextTrackedChange FN_REDLINE_NEXT_CHANGE +( SfxUInt16Item NextTrackedChange FN_REDLINE_NEXT_CHANGE ) [ /* flags: */ AutoUpdate = FALSE, @@ -9986,8 +9987,6 @@ SfxVoidItem NextTrackedChange FN_REDLINE_NEXT_CHANGE RecordPerSet; Asynchron; - Readonly = FALSE, - /* config: */ AccelConfig = TRUE, MenuConfig = TRUE, diff --git a/sw/source/uibase/uiview/view2.cxx b/sw/source/uibase/uiview/view2.cxx index 70dd0b3..08a7ac2 100644 --- a/sw/source/uibase/uiview/view2.cxx +++ b/sw/source/uibase/uiview/view2.cxx @@ -726,8 +726,20 @@ void SwView::Execute(SfxRequest &rReq) case FN_REDLINE_NEXT_CHANGE: { + // If a parameter is provided, try going to the nth change, not to + // the next one. + sal_uInt16 nRedline = USHRT_MAX; + if (pArgs && pArgs->GetItemState(nSlot, false, &pItem) == SfxItemState::SET) + nRedline = static_cast<const SfxUInt16Item*>(pItem)->GetValue(); + const SwRangeRedline *pCurrent = m_pWrtShell->GetCurrRedline(); - const SwRangeRedline *pNext = m_pWrtShell->SelNextRedline(); + SwDoc* pDoc = m_pWrtShell->GetDoc(); + const SwRedlineTable& rTable = pDoc->getIDocumentRedlineAccess().GetRedlineTable(); + const SwRangeRedline *pNext = nullptr; + if (nRedline < rTable.size()) + pNext = m_pWrtShell->GotoRedline(nRedline, true); + else + pNext = m_pWrtShell->SelNextRedline(); // FN_REDLINE_PREV_CHANGE leaves the selection point at the start of the redline. // In such cases, SelNextRedline (which starts searching from the selection point) @@ -735,7 +747,7 @@ void SwView::Execute(SfxRequest &rReq) // This behavior means that PREV_CHANGE followed by NEXT_CHANGE would not change // the current redline, so we detect it and select the next redline again. - if (pCurrent && pCurrent == pNext) + if (pCurrent && pCurrent == pNext && nRedline == USHRT_MAX) pNext = m_pWrtShell->SelNextRedline(); if (pNext) commit 6be239a1595fbe74a138123e155fd432cf1362b3 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Thu Sep 15 12:17:14 2016 +0200 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) diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx index 38c79b4..38e9174 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 94a41f8..ad60dd7 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 ========================================= _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits