Kaydet (Commit) e2cdde1f authored tarafından Miklos Vajna's avatar Miklos Vajna

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
üst 19ea624c
......@@ -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 \
......
......@@ -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: */
......@@ -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<
......
......@@ -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...
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment