summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2013-10-11 17:54:15 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2013-10-11 18:20:14 +0200
commite2cdde1f187de7b6fd0cab740ab7be54fc6fb1f0 (patch)
tree13895f97c9616aef32afe340c95c67980fa4a42e
parent19ea624c6dc779333e84ca937e2f90a3f39871b1 (diff)
sw: make it possible to accept/reject changes if they contain spelling errors
If there were spelling errors in a text portion that is to be accepted/rejected, right mouse click just shown the spellcheck menu, so oddly if an inserted text contained spelling mistakes and we wanted to reject them, Writer didn't allow that. Fix this by adding the redline operations (accept change, reject change, next change, previous change) to the spellcheck menu, but make it only a wrapper around the SwView code, so all the logic on what to do and when to hide these menu items is not duplicated. Change-Id: I76cad2f58a47575f8ef9517af51f1ffe7c4b6844
-rw-r--r--sw/qa/extras/odfimport/data/spellmenu-redline.odtbin0 -> 7959 bytes
-rw-r--r--sw/source/ui/app/mn.src30
-rw-r--r--sw/source/ui/inc/misc.hrc27
-rw-r--r--sw/source/ui/inc/olmenu.hxx3
-rw-r--r--sw/source/ui/lingu/olmenu.cxx39
-rw-r--r--sw/source/ui/lingu/olmenu.src3
6 files changed, 75 insertions, 27 deletions
diff --git a/sw/qa/extras/odfimport/data/spellmenu-redline.odt b/sw/qa/extras/odfimport/data/spellmenu-redline.odt
new file mode 100644
index 000000000000..268d15c2ccbe
--- /dev/null
+++ b/sw/qa/extras/odfimport/data/spellmenu-redline.odt
Binary files differ
diff --git a/sw/source/ui/app/mn.src b/sw/source/ui/app/mn.src
index fb2c31e0a64e..7a762e9244eb 100644
--- a/sw/source/ui/app/mn.src
+++ b/sw/source/ui/app/mn.src
@@ -24,6 +24,7 @@
#include "globals.hrc"
#include "helpid.h"
#include "popup.hrc"
+#include "misc.hrc"
/* --------------------- F O R M A T --------------------------------- */
#define SEPARATOR MenuItem { Separator = TRUE; }
@@ -218,32 +219,6 @@ location: <project>/uiconfig/[swriter|sweb|sglobal]/menubar/menubar.xml
Text [ en-US ] = "Inde~x Entry..." ; \
};
-#define _MN_EDIT_REDLINE \
- MenuItem \
- { \
- Identifier = FN_REDLINE_ACCEPT_DIRECT; \
- HelpId = CMD_FN_REDLINE_ACCEPT_DIRECT ; \
- Text [ en-US ] = "Accept Change" ; \
- };\
- MenuItem \
- { \
- Identifier = FN_REDLINE_REJECT_DIRECT ; \
- 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 \
{ \
@@ -296,7 +271,8 @@ location: <project>/uiconfig/[swriter|sweb|sglobal]/menubar/menubar.xml
_MN_EDIT_FOOTNOTE \
_MN_EDIT_IDX_ENTRY_DLG \
_MN_EDIT_BIB_ENTRY_DLG \
- _MN_EDIT_REDLINE \
+ MN_EDIT_REDLINE \
+ SEPARATOR ; \
MenuItem \
{ \
ITEM_POPUP_TEMPLATE_EDIT \
diff --git a/sw/source/ui/inc/misc.hrc b/sw/source/ui/inc/misc.hrc
index 95113ff989f2..ff200908babc 100644
--- a/sw/source/ui/inc/misc.hrc
+++ b/sw/source/ui/inc/misc.hrc
@@ -21,6 +21,7 @@
#define _MISC_HRC
#include "rcid.hrc"
+#include "cmdid.h"
#define DLG_INSERT_BOOKMARK (RC_MISC_BEGIN + 17)
#define DLG_NUM_NAMES (RC_MISC_BEGIN + 18)
@@ -55,6 +56,32 @@
#error Resource-Id Ueberlauf in #file, #line
#endif
+#define MN_EDIT_REDLINE \
+ MenuItem \
+ { \
+ Identifier = FN_REDLINE_ACCEPT_DIRECT; \
+ HelpId = CMD_FN_REDLINE_ACCEPT_DIRECT ; \
+ Text [ en-US ] = "Accept Change" ; \
+ };\
+ MenuItem \
+ { \
+ Identifier = FN_REDLINE_REJECT_DIRECT ; \
+ 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" ; \
+ };
+
#endif // _MISC_HRC
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/inc/olmenu.hxx b/sw/source/ui/inc/olmenu.hxx
index c10712ee284a..23d1fd315500 100644
--- a/sw/source/ui/inc/olmenu.hxx
+++ b/sw/source/ui/inc/olmenu.hxx
@@ -67,6 +67,9 @@ class SwSpellPopup : public PopupMenu
using PopupMenu::Execute;
+ /// Checks if any of the redline menu items should be hidden.
+ void checkRedline();
+
public:
SwSpellPopup( SwWrtShell *pWrtSh,
const ::com::sun::star::uno::Reference<
diff --git a/sw/source/ui/lingu/olmenu.cxx b/sw/source/ui/lingu/olmenu.cxx
index 4ce16129e7ed..be4dd09a8355 100644
--- a/sw/source/ui/lingu/olmenu.cxx
+++ b/sw/source/ui/lingu/olmenu.cxx
@@ -471,6 +471,7 @@ SwSpellPopup::SwSpellPopup(
//////////////////////////////////////////////////////////////////////////////////
+ checkRedline();
RemoveDisabledEntries( sal_True, sal_True );
}
@@ -625,9 +626,40 @@ aInfo16( SW_RES(IMG_INFO_16) )
//////////////////////////////////////////////////////////////////////////////////
+ checkRedline();
RemoveDisabledEntries( sal_True, sal_True );
}
+void SwSpellPopup::checkRedline()
+{
+ // Let SwView::GetState() already has the logic on when to disable the
+ // accept/reject and the next/prev change items, let it do the decision.
+
+ // Build an item set that contains a void item for each menu entry. The
+ // WhichId of each item is set, so SwView may clear it.
+ static const sal_uInt16 pRedlineIds[] = {
+ FN_REDLINE_ACCEPT_DIRECT,
+ FN_REDLINE_REJECT_DIRECT,
+ FN_REDLINE_NEXT_CHANGE,
+ FN_REDLINE_PREV_CHANGE
+ };
+ SwDoc *pDoc = pSh->GetDoc();
+ SfxItemSet aSet(pDoc->GetAttrPool(), FN_REDLINE_ACCEPT_DIRECT, FN_REDLINE_PREV_CHANGE);
+ for (size_t i = 0; i < SAL_N_ELEMENTS(pRedlineIds); ++i)
+ {
+ const sal_uInt16 nWhich = pRedlineIds[i];
+ aSet.Put(SfxVoidItem(nWhich), nWhich);
+ }
+ pSh->GetView().GetState(aSet);
+
+ // Enable/disable items based on if the which id of the void items are
+ // cleared or not.
+ for (size_t i = 0; i < SAL_N_ELEMENTS(pRedlineIds); ++i)
+ {
+ const sal_uInt16 nWhich = pRedlineIds[i];
+ EnableItem(nWhich, aSet.Get(nWhich).Which());
+ }
+}
sal_uInt16 SwSpellPopup::Execute( const Rectangle& rWordPos, Window* pWin )
{
@@ -799,6 +831,13 @@ void SwSpellPopup::Execute( sal_uInt16 nId )
aErrorBox.Execute();
}
}
+ else if (nId == FN_REDLINE_ACCEPT_DIRECT || nId == FN_REDLINE_REJECT_DIRECT
+ || nId == FN_REDLINE_NEXT_CHANGE || nId == FN_REDLINE_PREV_CHANGE)
+ {
+ // Let SwView::Execute() handle the redline actions.
+ SfxRequest aReq(pSh->GetView().GetViewFrame(), nId);
+ pSh->GetView().Execute(aReq);
+ }
else
{
// Set language for selection or for paragraph...
diff --git a/sw/source/ui/lingu/olmenu.src b/sw/source/ui/lingu/olmenu.src
index 00996ca3a195..1af2d8e40cf6 100644
--- a/sw/source/ui/lingu/olmenu.src
+++ b/sw/source/ui/lingu/olmenu.src
@@ -20,6 +20,7 @@
#include "olmenu.hrc"
#include "helpid.h"
+#include "misc.hrc"
#define MASKCOLOR MaskColor = Color { Red = 0xFFFF ; Green = 0x0000 ; Blue = 0xFFFF ; };
#define SEPARATOR MenuItem { Separator = TRUE; };
@@ -81,6 +82,8 @@ Menu MN_SPELL_POPUP
};
Text [ en-US ] = "Set Language for Paragraph" ;
};
+ SEPARATOR
+ MN_EDIT_REDLINE
};
};
String STR_WORD