summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2014-04-28 19:16:20 +0200
committerLuboš Luňák <l.lunak@collabora.com>2014-04-28 19:21:02 +0200
commit4a60f9387ddd832f7c164102b76351e5e520d920 (patch)
tree07dc158abde9787098a040cf1e64a3298a831584
parent160e93607f6c2c3981823b30ee981ca23d4e1a0d (diff)
allow accepting/rejecting changes in a selection (bnc#874790)
Adds 'Accept Changes'/'Reject Changes' to the RMB popup if appropriate, more convenient than handling them one by one. Change-Id: I4e2670aa9fdacaaaa1b7ecca36b9c150c82e2e72
-rw-r--r--sw/inc/cmdid.h2
-rw-r--r--sw/inc/editsh.hxx2
-rw-r--r--sw/inc/swcommands.h2
-rw-r--r--sw/sdi/_viewsh.sdi12
-rw-r--r--sw/sdi/swriter.sdi50
-rw-r--r--sw/source/core/edit/edredln.cxx18
-rw-r--r--sw/source/core/uibase/inc/redline_tmpl.hrc12
-rw-r--r--sw/source/core/uibase/lingu/olmenu.cxx10
-rw-r--r--sw/source/core/uibase/uiview/view2.cxx10
-rw-r--r--sw/source/core/uibase/uiview/viewstat.cxx39
10 files changed, 154 insertions, 3 deletions
diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h
index 8f4967585d0d..721b3f4b6009 100644
--- a/sw/inc/cmdid.h
+++ b/sw/inc/cmdid.h
@@ -163,6 +163,8 @@
#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 */
+#define FN_REDLINE_ACCEPT_DIRECT_SELECTION (FN_EDIT2 + 43) /* accept redlines in the selection */
+#define FN_REDLINE_REJECT_DIRECT_SELECTION (FN_EDIT2 + 44) /* reject redlines in the selection */
/*--------------------------------------------------------------------
Region: Edit
diff --git a/sw/inc/editsh.hxx b/sw/inc/editsh.hxx
index 70c18cb84d13..31a1b0e0b07d 100644
--- a/sw/inc/editsh.hxx
+++ b/sw/inc/editsh.hxx
@@ -890,6 +890,8 @@ public:
const SwRangeRedline& GetRedline( sal_uInt16 nPos ) const;
sal_Bool AcceptRedline( sal_uInt16 nPos );
sal_Bool RejectRedline( sal_uInt16 nPos );
+ bool AcceptRedlinesInSelection();
+ bool RejectRedlinesInSelection();
/** Search Redline for this Data and @return position in array.
If not found, return USHRT_MAX. */
diff --git a/sw/inc/swcommands.h b/sw/inc/swcommands.h
index cc9bc07d0f42..aa580e31e7b0 100644
--- a/sw/inc/swcommands.h
+++ b/sw/inc/swcommands.h
@@ -122,6 +122,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_ACCEPT_DIRECT_SELECTION ".uno:AcceptTracedChangesInSelection"
+#define CMD_FN_REDLINE_REJECT_DIRECT_SELECTION ".uno:RejectTracedChangesInSelection"
#define CMD_FN_REDLINE_NEXT_CHANGE ".uno:NextTrackedChange"
#define CMD_FN_REDLINE_PREV_CHANGE ".uno:PreviousTrackedChange"
#define CMD_FN_REMOVE_HYPERLINK ".uno:RemoveHyperlink"
diff --git a/sw/sdi/_viewsh.sdi b/sw/sdi/_viewsh.sdi
index 40ec958f82ee..7c8f2ad114cf 100644
--- a/sw/sdi/_viewsh.sdi
+++ b/sw/sdi/_viewsh.sdi
@@ -142,6 +142,18 @@ interface BaseTextEditView
StateMethod = GetState ;
DisableFlags="SW_DISABLE_ON_MAILBOX_EDITOR";
]
+ FN_REDLINE_ACCEPT_DIRECT_SELECTION
+ [
+ ExecMethod = Execute ;
+ StateMethod = GetState ;
+ DisableFlags="SW_DISABLE_ON_MAILBOX_EDITOR";
+ ]
+ FN_REDLINE_REJECT_DIRECT_SELECTION
+ [
+ ExecMethod = Execute ;
+ StateMethod = GetState ;
+ DisableFlags="SW_DISABLE_ON_MAILBOX_EDITOR";
+ ]
FN_REDLINE_NEXT_CHANGE
[
ExecMethod = Execute ;
diff --git a/sw/sdi/swriter.sdi b/sw/sdi/swriter.sdi
index 9bde88a4149a..1ddeba3ab9bf 100644
--- a/sw/sdi/swriter.sdi
+++ b/sw/sdi/swriter.sdi
@@ -9823,6 +9823,56 @@ SfxVoidItem RejectTracedChange FN_REDLINE_REJECT_DIRECT
GroupId = GID_EDIT;
]
+SfxVoidItem AcceptTracedChangeInSelection FN_REDLINE_ACCEPT_DIRECT_SELECTION
+[
+ /* 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 RejectTracedChangeInSelection FN_REDLINE_REJECT_DIRECT_SELECTION
+[
+ /* 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 NextTrackedChange FN_REDLINE_NEXT_CHANGE
[
/* flags: */
diff --git a/sw/source/core/edit/edredln.cxx b/sw/source/core/edit/edredln.cxx
index eaf439427044..e0fad1901f50 100644
--- a/sw/source/core/edit/edredln.cxx
+++ b/sw/source/core/edit/edredln.cxx
@@ -91,6 +91,24 @@ sal_Bool SwEditShell::RejectRedline( sal_uInt16 nPos )
return bRet;
}
+bool SwEditShell::AcceptRedlinesInSelection()
+{
+ SET_CURR_SHELL( this );
+ StartAllAction();
+ sal_Bool bRet = GetDoc()->AcceptRedline( *GetCrsr(), true );
+ EndAllAction();
+ return bRet;
+}
+
+bool SwEditShell::RejectRedlinesInSelection()
+{
+ SET_CURR_SHELL( this );
+ StartAllAction();
+ sal_Bool bRet = GetDoc()->RejectRedline( *GetCrsr(), true );
+ EndAllAction();
+ return bRet;
+}
+
// Set the comment at the Redline
sal_Bool SwEditShell::SetRedlineComment( const OUString& rS )
{
diff --git a/sw/source/core/uibase/inc/redline_tmpl.hrc b/sw/source/core/uibase/inc/redline_tmpl.hrc
index 42717089947b..8212465d994c 100644
--- a/sw/source/core/uibase/inc/redline_tmpl.hrc
+++ b/sw/source/core/uibase/inc/redline_tmpl.hrc
@@ -25,6 +25,18 @@
}; \
MenuItem \
{ \
+ Identifier = FN_REDLINE_ACCEPT_DIRECT_SELECTION; \
+ HelpId = CMD_FN_REDLINE_ACCEPT_DIRECT_SELECTION ; \
+ Text [ en-US ] = "Accept Changes" ; \
+ }; \
+ MenuItem \
+ { \
+ Identifier = FN_REDLINE_REJECT_DIRECT_SELECTION ; \
+ HelpId = CMD_FN_REDLINE_REJECT_DIRECT_SELECTION ; \
+ Text [ en-US ] = "Reject Changes" ; \
+ }; \
+ MenuItem \
+ { \
Identifier = FN_REDLINE_NEXT_CHANGE; \
HelpId = CMD_FN_REDLINE_NEXT_CHANGE ; \
Text [ en-US ] = "Next Change" ; \
diff --git a/sw/source/core/uibase/lingu/olmenu.cxx b/sw/source/core/uibase/lingu/olmenu.cxx
index 682df9aebb34..8694eabe21f7 100644
--- a/sw/source/core/uibase/lingu/olmenu.cxx
+++ b/sw/source/core/uibase/lingu/olmenu.cxx
@@ -610,10 +610,12 @@ void SwSpellPopup::checkRedline()
FN_REDLINE_ACCEPT_DIRECT,
FN_REDLINE_REJECT_DIRECT,
FN_REDLINE_NEXT_CHANGE,
- FN_REDLINE_PREV_CHANGE
+ FN_REDLINE_PREV_CHANGE,
+ FN_REDLINE_ACCEPT_DIRECT_SELECTION,
+ FN_REDLINE_REJECT_DIRECT_SELECTION
};
SwDoc *pDoc = m_pSh->GetDoc();
- SfxItemSet aSet(pDoc->GetAttrPool(), FN_REDLINE_ACCEPT_DIRECT, FN_REDLINE_PREV_CHANGE);
+ SfxItemSet aSet(pDoc->GetAttrPool(), FN_REDLINE_ACCEPT_DIRECT, FN_REDLINE_REJECT_DIRECT_SELECTION);
for (size_t i = 0; i < SAL_N_ELEMENTS(pRedlineIds); ++i)
{
const sal_uInt16 nWhich = pRedlineIds[i];
@@ -808,7 +810,9 @@ void SwSpellPopup::Execute( sal_uInt16 nId )
}
}
else if (nId == FN_REDLINE_ACCEPT_DIRECT || nId == FN_REDLINE_REJECT_DIRECT
- || nId == FN_REDLINE_NEXT_CHANGE || nId == FN_REDLINE_PREV_CHANGE)
+ || nId == FN_REDLINE_NEXT_CHANGE || nId == FN_REDLINE_PREV_CHANGE
+ || nId == FN_REDLINE_ACCEPT_DIRECT_SELECTION
+ || nId == FN_REDLINE_REJECT_DIRECT_SELECTION)
{
// Let SwView::Execute() handle the redline actions.
SfxRequest aReq(m_pSh->GetView().GetViewFrame(), nId);
diff --git a/sw/source/core/uibase/uiview/view2.cxx b/sw/source/core/uibase/uiview/view2.cxx
index 2b398ad3b919..cf2d68a077aa 100644
--- a/sw/source/core/uibase/uiview/view2.cxx
+++ b/sw/source/core/uibase/uiview/view2.cxx
@@ -684,6 +684,16 @@ void SwView::Execute(SfxRequest &rReq)
}
break;
+ case FN_REDLINE_ACCEPT_DIRECT_SELECTION:
+ case FN_REDLINE_REJECT_DIRECT_SELECTION:
+ {
+ if (FN_REDLINE_ACCEPT_DIRECT_SELECTION == nSlot)
+ m_pWrtShell->AcceptRedlinesInSelection();
+ else
+ m_pWrtShell->RejectRedlinesInSelection();
+ }
+ break;
+
case FN_REDLINE_NEXT_CHANGE:
{
const SwRangeRedline *pCurrent = m_pWrtShell->GetCurrRedline();
diff --git a/sw/source/core/uibase/uiview/viewstat.cxx b/sw/source/core/uibase/uiview/viewstat.cxx
index aded9e11f98d..195889b84b77 100644
--- a/sw/source/core/uibase/uiview/viewstat.cxx
+++ b/sw/source/core/uibase/uiview/viewstat.cxx
@@ -53,6 +53,8 @@
#include <svl/stritem.hxx>
#include <unotools/moduleoptions.hxx>
#include <svl/visitem.hxx>
+#include <redline.hxx>
+#include <docary.hxx>
#include <cmdid.h>
@@ -297,6 +299,43 @@ void SwView::GetState(SfxItemSet &rSet)
rSet.DisableItem(nWhich);
}
break;
+ case FN_REDLINE_ACCEPT_DIRECT_SELECTION:
+ case FN_REDLINE_REJECT_DIRECT_SELECTION:
+ {
+ // If the selection does not contain a redline, disable
+ // accepting/rejecting changes.
+ SwDoc *pDoc = m_pWrtShell->GetDoc();
+ SwPaM *pCursor = m_pWrtShell->GetCrsr();
+ if (GetDocShell()->HasChangeRecordProtection())
+ rSet.DisableItem(nWhich);
+ else if (!pCursor->HasMark())
+ rSet.DisableItem(nWhich);
+ else
+ {
+ sal_uInt16 index = 0;
+ const SwRedlineTbl& table = pDoc->GetRedlineTbl();
+ const SwRangeRedline* redline = table.FindAtPosition( *pCursor->Start(), index );
+ if( redline != NULL && *redline->Start() == *pCursor->End())
+ redline = NULL;
+ if( redline == NULL )
+ {
+ for(; index < table.size(); ++index )
+ {
+ const SwRangeRedline* tmp = table[ index ];
+ if( *tmp->Start() >= *pCursor->End())
+ break;
+ if( tmp->HasMark() && tmp->IsVisible())
+ {
+ redline = tmp;
+ break;
+ }
+ }
+ }
+ if( redline == NULL )
+ rSet.DisableItem(nWhich);
+ }
+ }
+ break;
case FN_REDLINE_NEXT_CHANGE:
case FN_REDLINE_PREV_CHANGE: