[Libreoffice-commits] core.git: sw/qa sw/source

Miklos Vajna vmiklos at collabora.co.uk
Fri Oct 11 09:20:34 PDT 2013


 sw/qa/extras/odfimport/data/spellmenu-redline.odt |binary
 sw/source/ui/app/mn.src                           |   30 +---------------
 sw/source/ui/inc/misc.hrc                         |   27 +++++++++++++++
 sw/source/ui/inc/olmenu.hxx                       |    3 +
 sw/source/ui/lingu/olmenu.cxx                     |   39 ++++++++++++++++++++++
 sw/source/ui/lingu/olmenu.src                     |    3 +
 6 files changed, 75 insertions(+), 27 deletions(-)

New commits:
commit e2cdde1f187de7b6fd0cab740ab7be54fc6fb1f0
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Fri Oct 11 17:54:15 2013 +0200

    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

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 0000000..268d15c
Binary files /dev/null and b/sw/qa/extras/odfimport/data/spellmenu-redline.odt differ
diff --git a/sw/source/ui/app/mn.src b/sw/source/ui/app/mn.src
index fb2c31e..7a762e9 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 95113ff..ff20090 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 c10712e..23d1fd3 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 4ce1612..be4dd09 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 00996ca..1af2d8e 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


More information about the Libreoffice-commits mailing list