[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-4.1' - 2 commits - l10ntools/source sw/source

Andras Timar andras.timar at collabora.com
Fri Oct 18 00:49:59 PDT 2013


 l10ntools/source/localize.cxx |    1 +
 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, 76 insertions(+), 27 deletions(-)

New commits:
commit e61f4927eebce4b8f458276e8725bd9c4f71a99f
Author: Andras Timar <andras.timar at collabora.com>
Date:   Fri Oct 11 18:44:42 2013 +0200

    add sw/source/ui/inc/misc.hrc
    
    Change-Id: Id1e0d4241a356bdb08a44b3ae87c3d1023c4669e

diff --git a/l10ntools/source/localize.cxx b/l10ntools/source/localize.cxx
index 8b93ec9..2062491 100644
--- a/l10ntools/source/localize.cxx
+++ b/l10ntools/source/localize.cxx
@@ -119,6 +119,7 @@ bool passesPositiveList(const OUString& rUrl) {
         { RTL_CONSTASCII_STRINGPARAM(
             "/svx/source/unodialogs/textconversiondlgs/"
             "chinese_direction_tmpl.hrc") },
+        { RTL_CONSTASCII_STRINGPARAM("/sw/source/ui/inc/misc.hrc") },
         { RTL_CONSTASCII_STRINGPARAM("/sw/source/ui/inc/swacc_tmpl.hrc") },
         { RTL_CONSTASCII_STRINGPARAM("/sw/source/ui/inc/swmn_tmpl.hrc") },
         { RTL_CONSTASCII_STRINGPARAM("/sw/source/ui/inc/toolbox_tmpl.hrc") }
commit 2633842561d67dc6db9120bb70db91a2a1d9a9ef
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/source/ui/app/mn.src b/sw/source/ui/app/mn.src
index e8175e2..cf57a95 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 aa37171a..645f08a 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_DOC_FOOTNOTE            (RC_MISC_BEGIN + 13)
 #define DLG_INSERT_BOOKMARK         (RC_MISC_BEGIN + 17)
@@ -56,6 +57,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 2a56b37..b71fea6 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 a444910..f0ee849 100644
--- a/sw/source/ui/lingu/olmenu.cxx
+++ b/sw/source/ui/lingu/olmenu.cxx
@@ -472,6 +472,7 @@ SwSpellPopup::SwSpellPopup(
 
     //////////////////////////////////////////////////////////////////////////////////
 
+    checkRedline();
     RemoveDisabledEntries( sal_True, sal_True );
 }
 
@@ -627,9 +628,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 )
 {
@@ -801,6 +833,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