diff options
author | Muhammad Haggag <mhaggag@gmail.com> | 2012-11-23 20:15:41 +0200 |
---|---|---|
committer | Bosdonnat Cedric <cedric.bosdonnat@free.fr> | 2012-11-27 13:53:09 +0000 |
commit | a0a58556f36cbf396f5139e18881720ed838ddd4 (patch) | |
tree | a8b0643c0184b348aed040389e42fce0e98a92bc /sw | |
parent | d5b7bcbd263162b31780b53070f90fe8b3366786 (diff) |
fdo#48317 - Support jumping to next/previous change
Added two new writer commands: NextTrackedChange (FN_REDLINE_NEXT_CHANGE) and
PreviousTrackedChange (FN_REDLINE_PREV_CHANGE).
Rewrote the logic for Accept/Reject change (FN_REDLINE_ACCEPT_DIRECT and
FN_REDLINE_REJECT_DIRECT) to work well with the newly introduced commands.
Change-Id: I03d583bef4225409f69934f16db1854564c2db5f
Reviewed-on: https://gerrit.libreoffice.org/1156
Reviewed-by: Bosdonnat Cedric <cedric.bosdonnat@free.fr>
Tested-by: Bosdonnat Cedric <cedric.bosdonnat@free.fr>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/cmdid.h | 2 | ||||
-rw-r--r-- | sw/inc/swcommands.h | 2 | ||||
-rw-r--r-- | sw/sdi/_viewsh.sdi | 12 | ||||
-rw-r--r-- | sw/sdi/swriter.sdi | 52 | ||||
-rw-r--r-- | sw/source/ui/app/mn.src | 12 | ||||
-rw-r--r-- | sw/source/ui/uiview/view2.cxx | 75 | ||||
-rw-r--r-- | sw/source/ui/uiview/viewstat.cxx | 23 | ||||
-rw-r--r-- | sw/uiconfig/sglobal/menubar/menubar.xml | 2 | ||||
-rw-r--r-- | sw/uiconfig/swform/menubar/menubar.xml | 2 | ||||
-rw-r--r-- | sw/uiconfig/swreport/menubar/menubar.xml | 2 | ||||
-rw-r--r-- | sw/uiconfig/swriter/menubar/menubar.xml | 2 | ||||
-rw-r--r-- | sw/uiconfig/swxform/menubar/menubar.xml | 2 |
12 files changed, 168 insertions, 20 deletions
diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h index 4660bae22025..524adcdc4ddd 100644 --- a/sw/inc/cmdid.h +++ b/sw/inc/cmdid.h @@ -168,6 +168,8 @@ included in c-context files, so c++ style stuff will cause problems. #define FN_REDLINE_REJECT_DIRECT (FN_EDIT2 + 38) /* reject redline at current position*/ #define FN_REMOVE_HYPERLINK (FN_EDIT2 + 39) /* remove hyperlink attribute */ #define FN_COPY_HYPERLINK_LOCATION (FN_EDIT2 + 40) /* copy hyperlink URL to clipboard */ +#define FN_REDLINE_NEXT_CHANGE (FN_EDIT2 + 41) /* Go to the next change */ +#define FN_REDLINE_PREV_CHANGE (FN_EDIT2 + 42) /* Go to the previous change */ /*-------------------------------------------------------------------- Region: Edit diff --git a/sw/inc/swcommands.h b/sw/inc/swcommands.h index 74a93ad512ad..1037141d4a5a 100644 --- a/sw/inc/swcommands.h +++ b/sw/inc/swcommands.h @@ -121,6 +121,8 @@ #define CMD_FN_HIDE_ALL_NOTES ".uno:HideAllNotes" #define CMD_FN_REDLINE_ACCEPT_DIRECT ".uno:AcceptTracedChange" #define CMD_FN_REDLINE_REJECT_DIRECT ".uno:RejectTracedChange" +#define CMD_FN_REDLINE_NEXT_CHANGE ".uno:NextTrackedChange" +#define CMD_FN_REDLINE_PREV_CHANGE ".uno:PreviousTrackedChange" #define CMD_FN_REMOVE_HYPERLINK ".uno:RemoveHyperlink" #define CMD_FN_COPY_HYPERLINK_LOCATION ".uno:CopyHyperlinkLocation" #define CMD_FN_HEADERFOOTER_EDIT ".uno:HeaderFooterEdit" diff --git a/sw/sdi/_viewsh.sdi b/sw/sdi/_viewsh.sdi index d4486af83a36..605ce54d79a2 100644 --- a/sw/sdi/_viewsh.sdi +++ b/sw/sdi/_viewsh.sdi @@ -144,6 +144,18 @@ interface BaseTextEditView StateMethod = GetState ; DisableFlags="SW_DISABLE_ON_MAILBOX_EDITOR"; ] + FN_REDLINE_NEXT_CHANGE + [ + ExecMethod = Execute ; + StateMethod = GetState ; + DisableFlags="SW_DISABLE_ON_MAILBOX_EDITOR"; + ] + FN_REDLINE_PREV_CHANGE + [ + ExecMethod = Execute ; + StateMethod = GetState ; + DisableFlags="SW_DISABLE_ON_MAILBOX_EDITOR"; + ] SID_DOCUMENT_COMPARE // status(play) [ diff --git a/sw/sdi/swriter.sdi b/sw/sdi/swriter.sdi index dc8f8bcb872a..290f671150c6 100644 --- a/sw/sdi/swriter.sdi +++ b/sw/sdi/swriter.sdi @@ -10215,6 +10215,58 @@ SfxVoidItem RejectTracedChange FN_REDLINE_REJECT_DIRECT ] //-------------------------------------------------------------------------- +SfxVoidItem NextTrackedChange FN_REDLINE_NEXT_CHANGE +[ + /* flags: */ + AutoUpdate = FALSE, + Cachable = Cachable, + FastCall = FALSE, + HasCoreId = FALSE, + HasDialog = FALSE, + ReadOnlyDoc = FALSE, + Toggle = FALSE, + Container = FALSE, + RecordAbsolute = FALSE, + RecordPerSet; + Asynchron; + + Readonly = FALSE, + + /* config: */ + AccelConfig = TRUE, + MenuConfig = TRUE, + StatusBarConfig = FALSE, + ToolBoxConfig = TRUE, + GroupId = GID_EDIT; +] + +//-------------------------------------------------------------------------- +SfxVoidItem PreviousTrackedChange FN_REDLINE_PREV_CHANGE +[ + /* flags: */ + AutoUpdate = FALSE, + Cachable = Cachable, + FastCall = FALSE, + HasCoreId = FALSE, + HasDialog = FALSE, + ReadOnlyDoc = FALSE, + Toggle = FALSE, + Container = FALSE, + RecordAbsolute = FALSE, + RecordPerSet; + Asynchron; + + Readonly = FALSE, + + /* config: */ + AccelConfig = TRUE, + MenuConfig = TRUE, + StatusBarConfig = FALSE, + ToolBoxConfig = TRUE, + GroupId = GID_EDIT; +] + +//-------------------------------------------------------------------------- SfxVoidItem RemoveHyperlink FN_REMOVE_HYPERLINK [ /* flags: */ diff --git a/sw/source/ui/app/mn.src b/sw/source/ui/app/mn.src index 837fb1f279f8..888b58e088dd 100644 --- a/sw/source/ui/app/mn.src +++ b/sw/source/ui/app/mn.src @@ -239,6 +239,18 @@ location: <project>/uiconfig/[swriter|sweb|sglobal]/menubar/menubar.xml HelpId = CMD_FN_REDLINE_REJECT_DIRECT ; \ Text [ en-US ] = "Reject Change" ; \ }; \ + MenuItem \ + { \ + Identifier = FN_REDLINE_NEXT_CHANGE; \ + HelpId = CMD_FN_REDLINE_NEXT_CHANGE ; \ + Text [ en-US ] = "Next Change" ; \ + };\ + MenuItem \ + { \ + Identifier = FN_REDLINE_PREV_CHANGE; \ + HelpId = CMD_FN_REDLINE_PREV_CHANGE ; \ + Text [ en-US ] = "Previous Change" ; \ + };\ SEPARATOR ; #define _MN_EDIT_BIB_ENTRY_DLG \ MenuItem \ diff --git a/sw/source/ui/uiview/view2.cxx b/sw/source/ui/uiview/view2.cxx index 88cade72cf52..afeb9f484ac9 100644 --- a/sw/source/ui/uiview/view2.cxx +++ b/sw/source/ui/uiview/view2.cxx @@ -630,26 +630,69 @@ void SwView::Execute(SfxRequest &rReq) case FN_REDLINE_ACCEPT_DIRECT: case FN_REDLINE_REJECT_DIRECT: { - SwContentAtPos aCntntAtPos( SwContentAtPos::SW_REDLINE ); - Point aCrsrPos = pWrtShell->GetCrsrDocPos( sal_True ); - if( pWrtShell->GetContentAtPos( aCrsrPos, aCntntAtPos ) ) + // We check for a redline at the start of the selection/cursor, not the point. + // This ensures we work properly with FN_REDLINE_NEXT_CHANGE, which leaves the + // point at the *end* of the redline and the mark at the start (so GetRedline + // would return NULL if called on the point) + SwDoc *pDoc = pWrtShell->GetDoc(); + SwPaM *pCursor = pWrtShell->GetCrsr(); + + sal_uInt16 nRedline = 0; + const SwRedline *pRedline = pDoc->GetRedline(*pCursor->Start(), &nRedline); + assert(pRedline != 0); + if (pRedline) + { + if (FN_REDLINE_ACCEPT_DIRECT == nSlot) + pWrtShell->AcceptRedline(nRedline); + else + pWrtShell->RejectRedline(nRedline); + } + } + break; + + case FN_REDLINE_NEXT_CHANGE: + { + const SwRedline *pCurrent = pWrtShell->GetCurrRedline(); + const SwRedline *pNext = 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) + // immediately finds the current redline and advances the selection point to its end. + // + // 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) + pNext = pWrtShell->SelNextRedline(); + + if (pNext) + pWrtShell->SetInSelect(); + } + break; + + case FN_REDLINE_PREV_CHANGE: + { + const SwPaM *pCursor = pWrtShell->GetCrsr(); + const SwPosition initialCursorStart = *pCursor->Start(); + const SwRedline *pPrev = pWrtShell->SelPrevRedline(); + + if (pPrev) { - sal_uInt16 nCount = pWrtShell->GetRedlineCount(); - for( sal_uInt16 nRedline = 0; nRedline < nCount; ++nRedline ) - { - const SwRedline& rRedline = pWrtShell->GetRedline( nRedline ); - if( *aCntntAtPos.aFnd.pRedl == rRedline ) - { - if( FN_REDLINE_ACCEPT_DIRECT == nSlot ) - pWrtShell->AcceptRedline( nRedline ); - else - pWrtShell->RejectRedline( nRedline ); - break; - } - } + // FN_REDLINE_NEXT_CHANGE leaves the selection point at the end of the redline. + // In such cases, SelPrevRedline (which starts searching from the selection point) + // immediately finds the current redline and advances the selection point to its + // start. + // + // This behavior means that NEXT_CHANGE followed by PREV_CHANGE would not change + // the current redline, so we detect it and move to the previous redline again. + if (initialCursorStart == *pPrev->Start()) + pPrev = pWrtShell->SelPrevRedline(); } + + if (pPrev) + pWrtShell->SetInSelect(); } break; + case SID_DOCUMENT_COMPARE: case SID_DOCUMENT_MERGE: { diff --git a/sw/source/ui/uiview/viewstat.cxx b/sw/source/ui/uiview/viewstat.cxx index cfa97d377cbf..c7d765607af8 100644 --- a/sw/source/ui/uiview/viewstat.cxx +++ b/sw/source/ui/uiview/viewstat.cxx @@ -65,6 +65,7 @@ #include <cmdid.h> #include <IDocumentRedlineAccess.hxx> +#include <doc.hxx> using namespace ::com::sun::star; @@ -274,12 +275,26 @@ void SwView::GetState(SfxItemSet &rSet) case FN_REDLINE_ACCEPT_DIRECT: case FN_REDLINE_REJECT_DIRECT: { - SwContentAtPos aCntntAtPos( SwContentAtPos::SW_REDLINE ); - Point aCrsrPos = pWrtShell->GetCrsrDocPos( sal_True ); - if( !pWrtShell->GetContentAtPos( aCrsrPos, aCntntAtPos ) ) - rSet.DisableItem( nWhich ); + // If the selection/cursor start position isn't on a redline, disable + // accepting/rejecting changes. + SwDoc *pDoc = pWrtShell->GetDoc(); + SwPaM *pCursor = pWrtShell->GetCrsr(); + if (0 == pDoc->GetRedline(*pCursor->Start(), 0)) + rSet.DisableItem(nWhich); } break; + + case FN_REDLINE_NEXT_CHANGE: + case FN_REDLINE_PREV_CHANGE: + { + // Enable change navigation if we have any redlines. Ideally we should disable + // "Next Change" if we're at or past the last change, and similarly for + // "Previous Change" + if (0 == pWrtShell->GetRedlineCount()) + rSet.DisableItem(nWhich); + } + break; + case SID_THESAURUS: { SwWrtShell &rSh = GetWrtShell(); diff --git a/sw/uiconfig/sglobal/menubar/menubar.xml b/sw/uiconfig/sglobal/menubar/menubar.xml index ae37597f1e98..84f75455fa10 100644 --- a/sw/uiconfig/sglobal/menubar/menubar.xml +++ b/sw/uiconfig/sglobal/menubar/menubar.xml @@ -84,6 +84,8 @@ <menu:menuseparator/> <menu:menuitem menu:id=".uno:AcceptTrackedChanges"/> <menu:menuitem menu:id=".uno:CommentChangeTracking"/> + <menu:menuitem menu:id=".uno:NextTrackedChange"/> + <menu:menuitem menu:id=".uno:PreviousTrackedChange"/> <menu:menuseparator/> <menu:menuitem menu:id=".uno:MergeDocuments"/> </menu:menupopup> diff --git a/sw/uiconfig/swform/menubar/menubar.xml b/sw/uiconfig/swform/menubar/menubar.xml index a0c80fe78f87..beb36a61cc96 100644 --- a/sw/uiconfig/swform/menubar/menubar.xml +++ b/sw/uiconfig/swform/menubar/menubar.xml @@ -84,6 +84,8 @@ <menu:menuseparator/> <menu:menuitem menu:id=".uno:AcceptTrackedChanges"/> <menu:menuitem menu:id=".uno:CommentChangeTracking"/> + <menu:menuitem menu:id=".uno:NextTrackedChange"/> + <menu:menuitem menu:id=".uno:PreviousTrackedChange"/> <menu:menuseparator/> <menu:menuitem menu:id=".uno:MergeDocuments"/> </menu:menupopup> diff --git a/sw/uiconfig/swreport/menubar/menubar.xml b/sw/uiconfig/swreport/menubar/menubar.xml index e93a3dd96140..d4a0e41c1043 100644 --- a/sw/uiconfig/swreport/menubar/menubar.xml +++ b/sw/uiconfig/swreport/menubar/menubar.xml @@ -84,6 +84,8 @@ <menu:menuseparator/> <menu:menuitem menu:id=".uno:AcceptTrackedChanges"/> <menu:menuitem menu:id=".uno:CommentChangeTracking"/> + <menu:menuitem menu:id=".uno:NextTrackedChange"/> + <menu:menuitem menu:id=".uno:PreviousTrackedChange"/> <menu:menuseparator/> <menu:menuitem menu:id=".uno:MergeDocuments"/> </menu:menupopup> diff --git a/sw/uiconfig/swriter/menubar/menubar.xml b/sw/uiconfig/swriter/menubar/menubar.xml index 473cebf12a45..d53ba3d9eba4 100644 --- a/sw/uiconfig/swriter/menubar/menubar.xml +++ b/sw/uiconfig/swriter/menubar/menubar.xml @@ -87,6 +87,8 @@ <menu:menuseparator/> <menu:menuitem menu:id=".uno:AcceptTrackedChanges"/> <menu:menuitem menu:id=".uno:CommentChangeTracking"/> + <menu:menuitem menu:id=".uno:NextTrackedChange"/> + <menu:menuitem menu:id=".uno:PreviousTrackedChange"/> <menu:menuseparator/> <menu:menuitem menu:id=".uno:MergeDocuments"/> </menu:menupopup> diff --git a/sw/uiconfig/swxform/menubar/menubar.xml b/sw/uiconfig/swxform/menubar/menubar.xml index 9f43e34d364b..429b9c370e52 100644 --- a/sw/uiconfig/swxform/menubar/menubar.xml +++ b/sw/uiconfig/swxform/menubar/menubar.xml @@ -85,6 +85,8 @@ <menu:menuseparator/> <menu:menuitem menu:id=".uno:AcceptTrackedChanges"/> <menu:menuitem menu:id=".uno:CommentChangeTracking"/> + <menu:menuitem menu:id=".uno:NextTrackedChange"/> + <menu:menuitem menu:id=".uno:PreviousTrackedChange"/> <menu:menuseparator/> <menu:menuitem menu:id=".uno:MergeDocuments"/> </menu:menupopup> |