[Libreoffice-commits] core.git: 2 commits - editeng/inc editeng/Module_editeng.mk editeng/source editeng/uiconfig editeng/UIConfig_editeng.mk include/editeng Repository.mk vcl/source

Caolán McNamara caolanm at redhat.com
Fri Feb 17 15:34:31 UTC 2017


 Repository.mk                       |    1 
 editeng/Module_editeng.mk           |    1 
 editeng/UIConfig_editeng.mk         |   16 +++++++
 editeng/inc/editeng.hrc             |   11 -----
 editeng/inc/helpid.hrc              |    4 -
 editeng/source/editeng/editeng.src  |   49 -----------------------
 editeng/source/editeng/editview.cxx |   32 +++++++++------
 editeng/uiconfig/ui/spellmenu.ui    |   74 ++++++++++++++++++++++++++++++++++++
 include/editeng/editrids.hrc        |    2 
 vcl/source/window/builder.cxx       |   30 +++++++++++---
 10 files changed, 139 insertions(+), 81 deletions(-)

New commits:
commit 5d6a605a698239638e0a1282e3e99a704b7f3654
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Feb 17 13:39:24 2017 +0000

    convert editeng spell menu to .ui format
    
    Change-Id: Iaae8e6d6ee3c9cafad343fefb4f357b080df3a08

diff --git a/Repository.mk b/Repository.mk
index e612fc7..2272747 100644
--- a/Repository.mk
+++ b/Repository.mk
@@ -1105,6 +1105,7 @@ $(eval $(call gb_Helper_register_uiconfigs,\
 	cui \
 	$(call gb_Helper_optional,DBCONNECTIVITY,dbaccess) \
 	desktop \
+	editeng \
 	filter \
 	formula \
 	fps \
diff --git a/editeng/Module_editeng.mk b/editeng/Module_editeng.mk
index f48dde9..4bed89d 100644
--- a/editeng/Module_editeng.mk
+++ b/editeng/Module_editeng.mk
@@ -26,6 +26,7 @@ $(eval $(call gb_Module_add_targets,editeng,\
 
 $(eval $(call gb_Module_add_l10n_targets,editeng,\
 	AllLangResTarget_editeng \
+	UIConfig_editeng \
 ))
 
 $(eval $(call gb_Module_add_check_targets,editeng,\
diff --git a/editeng/UIConfig_editeng.mk b/editeng/UIConfig_editeng.mk
new file mode 100644
index 0000000..dbe62f5
--- /dev/null
+++ b/editeng/UIConfig_editeng.mk
@@ -0,0 +1,16 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+$(eval $(call gb_UIConfig_UIConfig,editeng))
+
+$(eval $(call gb_UIConfig_add_uifiles,editeng,\
+	editeng/uiconfig/ui/spellmenu \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/editeng/inc/editeng.hrc b/editeng/inc/editeng.hrc
index e4b00b4..18c6208 100644
--- a/editeng/inc/editeng.hrc
+++ b/editeng/inc/editeng.hrc
@@ -21,15 +21,8 @@
 
 #include <editeng/editrids.hrc>
 
-#define MN_SPELLING           1
-#define MN_INSERT             2
-#define MN_IGNORE             3
-#define MN_AUTOCORR           4
-#define MN_WORDLANGUAGE       5
-#define MN_PARALANGUAGE       6
-#define MN_INSERT_SINGLE      7
-#define MN_AUTO_CORRECT_DLG   8
-
+#define MN_WORDLANGUAGE  998
+#define MN_PARALANGUAGE  999
 #define MN_ALTSTART     1000
 #define MN_AUTOSTART    2000
 #define MN_DICTSTART    3000
diff --git a/editeng/inc/helpid.hrc b/editeng/inc/helpid.hrc
index 60bba79f..018a50f 100644
--- a/editeng/inc/helpid.hrc
+++ b/editeng/inc/helpid.hrc
@@ -21,10 +21,6 @@
 
 #define HID_EDITENG_SPELLER_WORDLANGUAGE                   "EDITENG_HID_EDITENG_SPELLER_WORDLANGUAGE"
 #define HID_EDITENG_SPELLER_PARALANGUAGE                   "EDITENG_HID_EDITENG_SPELLER_PARALANGUAGE"
-#define HID_EDITENG_SPELLER_ADDWORD                        "EDITENG_HID_EDITENG_SPELLER_ADDWORD"
-#define HID_EDITENG_SPELLER_AUTOCORRECT                    "EDITENG_HID_EDITENG_SPELLER_AUTOCORRECT"
-#define HID_EDITENG_SPELLER_IGNORE                         "EDITENG_HID_EDITENG_SPELLER_IGNORE"
-#define HID_EDITENG_SPELLER_START                          "EDITENG_HID_EDITENG_SPELLER_START"
 
 #endif
 
diff --git a/editeng/source/editeng/editeng.src b/editeng/source/editeng/editeng.src
index 36d9210..7d49a54 100644
--- a/editeng/source/editeng/editeng.src
+++ b/editeng/source/editeng/editeng.src
@@ -65,55 +65,6 @@ String RID_EDITUNDO_TRANSLITERATE
     Text [ en-US ] = "Change Case";
 };
 
-Menu RID_MENU_SPELL
-{
-    ItemList =
-    {
-        MenuItem
-        {
-            Identifier = MN_IGNORE ;
-            HelpId = HID_EDITENG_SPELLER_IGNORE;
-            Text [ en-US ] = "I~gnore All" ;
-        };
-        MenuItem
-        {
-            Identifier = MN_INSERT ;
-            HelpId = HID_EDITENG_SPELLER_ADDWORD;
-            SubMenu = Menu
-            {
-            };
-            Text [ en-US ] = "~Add to Dictionary" ;
-        };
-        MenuItem
-        {
-            Identifier = MN_INSERT_SINGLE ;
-            HelpId = HID_EDITENG_SPELLER_ADDWORD;
-            Text [ en-US ] = "~Add to Dictionary" ;
-        };
-        MenuItem
-        {
-            Identifier = MN_SPELLING ;
-            HelpId = HID_EDITENG_SPELLER_START;
-            Text [ en-US ] = "~Spellcheck..." ;
-        };
-        MenuItem { Separator = TRUE ; };
-        MenuItem
-        {
-            Identifier = MN_AUTOCORR ;
-            HelpId = HID_EDITENG_SPELLER_AUTOCORRECT;
-            SubMenu = Menu
-            {
-            };
-            Text [ en-US ] = "AutoCorrect ~To" ;
-        };
-        MenuItem
-        {
-            Identifier = MN_AUTO_CORRECT_DLG ;
-            Text [ en-US ] = "Auto~Correct Options..." ;
-        };
-    };
-};
-
 String RID_STR_WORD
 {
     Text [ en-US ] = "Word is %x";
diff --git a/editeng/source/editeng/editview.cxx b/editeng/source/editeng/editview.cxx
index 75774fb..4f72ae7 100644
--- a/editeng/source/editeng/editview.cxx
+++ b/editeng/source/editeng/editview.cxx
@@ -817,10 +817,17 @@ void EditView::ExecuteSpellPopup( const Point& rPosPixel, Link<SpellCallbackInfo
     ESelection aOldSel = GetSelection();
     if ( xSpeller.is() && pImpEditView->IsWrongSpelledWord( aPaM, true ) )
     {
-        ScopedVclPtrInstance<PopupMenu> aPopupMenu( EditResId( RID_MENU_SPELL ) );
-        PopupMenu *pAutoMenu = aPopupMenu->GetPopupMenu( MN_AUTOCORR );
-        PopupMenu *pInsertMenu = aPopupMenu->GetPopupMenu( MN_INSERT );  // add word to user-dictionaries
+        VclBuilder aBuilder(nullptr, VclBuilderContainer::getUIRootDir(), "editeng/ui/spellmenu.ui", "");
+        VclPtr<PopupMenu> aPopupMenu(aBuilder.get_menu("menu"));
+        const sal_uInt16 nAutoCorrId = aPopupMenu->GetItemId("autocorrect");
+        PopupMenu *pAutoMenu = aPopupMenu->GetPopupMenu(nAutoCorrId);
+        const sal_uInt16 nInsertId = aPopupMenu->GetItemId("insert");
+        PopupMenu *pInsertMenu = aPopupMenu->GetPopupMenu(nInsertId);  // add word to user-dictionaries
         pInsertMenu->SetMenuFlags( MenuFlags::NoAutoMnemonics );         //! necessary to retrieve the correct dictionary names later
+        const sal_uInt16 nAddId = aPopupMenu->GetItemId("add");
+        const sal_uInt16 nIgnoreId = aPopupMenu->GetItemId("ignore");
+        const sal_uInt16 nCheckId = aPopupMenu->GetItemId("check");
+        const sal_uInt16 nAutoCorrectDlgId = aPopupMenu->GetItemId("autocorrectdlg");
 
         EditPaM aPaM2( aPaM );
         aPaM2.SetIndex( aPaM2.GetIndex()+1 );
@@ -910,7 +917,7 @@ void EditView::ExecuteSpellPopup( const Point& rPosPixel, Link<SpellCallbackInfo
             aPopupMenu->InsertSeparator(OString(), nWords);
         }
         else
-            aPopupMenu->RemoveItem( MN_AUTOCORR );   // delete?
+            aPopupMenu->RemoveItem(nAutoCorrId);   // delete?
 
         SvtLinguConfig aCfg;
 
@@ -963,10 +970,11 @@ void EditView::ExecuteSpellPopup( const Point& rPosPixel, Link<SpellCallbackInfo
                 }
             }
         }
-        if ( pInsertMenu->GetItemCount() != 1)
-            aPopupMenu->EnableItem( MN_INSERT_SINGLE, false );
-        if ( pInsertMenu->GetItemCount() < 2 )
-            aPopupMenu->EnableItem( MN_INSERT, false );
+
+        if (pInsertMenu->GetItemCount() != 1)
+            aPopupMenu->EnableItem(nAddId, false);
+        if (pInsertMenu->GetItemCount() < 2)
+            aPopupMenu->EnableItem(nInsertId, false);
 
         aPopupMenu->RemoveDisabledEntries( true, true );
 
@@ -976,7 +984,7 @@ void EditView::ExecuteSpellPopup( const Point& rPosPixel, Link<SpellCallbackInfo
         aTempRect = pImpEditView->GetWindow()->LogicToPixel( Rectangle(aScreenPos, aTempRect.GetSize() ));
 
         sal_uInt16 nId = aPopupMenu->Execute( pImpEditView->GetWindow(), aTempRect, PopupMenuFlags::NoMouseUpClose );
-        if ( nId == MN_IGNORE )
+        if (nId == nIgnoreId)
         {
             OUString aWord = pImpEditView->SpellIgnoreWord();
             if ( pCallBack )
@@ -1015,7 +1023,7 @@ void EditView::ExecuteSpellPopup( const Point& rPosPixel, Link<SpellCallbackInfo
             }
             SetSelection( aOldSel );
         }
-        else if ( nId == MN_SPELLING )
+        else if (nId == nCheckId)
         {
             if ( !pCallBack )
             {
@@ -1033,12 +1041,12 @@ void EditView::ExecuteSpellPopup( const Point& rPosPixel, Link<SpellCallbackInfo
                 pCallBack->Call( aInf );
             }
         }
-        else if ( nId == MN_AUTO_CORRECT_DLG && pCallBack)
+        else if (nId == nAutoCorrectDlgId && pCallBack)
         {
             SpellCallbackInfo aInf( SpellCallbackCommand::AUTOCORRECT_OPTIONS, OUString() );
             pCallBack->Call( aInf );
         }
-        else if ( nId >= MN_DICTSTART || nId == MN_INSERT_SINGLE )
+        else if ( nId >= MN_DICTSTART || nId == nAddId)
         {
             OUString aDicName;
             if (nId >= MN_DICTSTART)
diff --git a/editeng/uiconfig/ui/spellmenu.ui b/editeng/uiconfig/ui/spellmenu.ui
new file mode 100644
index 0000000..365de28
--- /dev/null
+++ b/editeng/uiconfig/ui/spellmenu.ui
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.20.0 -->
+<interface>
+  <requires lib="gtk+" version="3.10"/>
+  <object class="GtkMenu" id="menu">
+    <property name="visible">True</property>
+    <property name="can_focus">False</property>
+    <child>
+      <object class="GtkMenuItem" id="ignore">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="label" translatable="yes">I_gnore All</property>
+      </object>
+    </child>
+    <child>
+      <object class="GtkMenuItem" id="insert">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="label" translatable="yes">_Add to Dictionary</property>
+        <property name="use_underline">True</property>
+        <child type="submenu">
+          <object class="GtkMenu">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+          </object>
+        </child>
+      </object>
+    </child>
+    <child>
+      <object class="GtkMenuItem" id="add">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="label" translatable="yes">_Add to Dictionary</property>
+        <property name="use_underline">True</property>
+      </object>
+    </child>
+    <child>
+      <object class="GtkMenuItem" id="check">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="label" translatable="yes">_Spellcheck...</property>
+        <property name="use_underline">True</property>
+      </object>
+    </child>
+    <child>
+      <object class="GtkSeparatorMenuItem" id="menuitem1">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+      </object>
+    </child>
+    <child>
+      <object class="GtkMenuItem" id="autocorrect">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="label" translatable="yes">AutoCorrect _To</property>
+        <property name="use_underline">True</property>
+        <child type="submenu">
+          <object class="GtkMenu">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+          </object>
+        </child>
+      </object>
+    </child>
+    <child>
+      <object class="GtkMenuItem" id="autocorrectdlg">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="label" translatable="yes">Auto_Correct Options...</property>
+        <property name="use_underline">True</property>
+      </object>
+    </child>
+  </object>
+</interface>
diff --git a/include/editeng/editrids.hrc b/include/editeng/editrids.hrc
index cff44d4..5a1defa 100644
--- a/include/editeng/editrids.hrc
+++ b/include/editeng/editrids.hrc
@@ -358,7 +358,7 @@
 #define RID_EDITUNDO_RESETATTRIBS           (RID_EDIT_START + 308)
 #define RID_EDITUNDO_INDENT                 (RID_EDIT_START + 309)
 #define RID_EDITUNDO_TRANSLITERATE          (RID_EDIT_START + 310)
-#define RID_MENU_SPELL                      (RID_EDIT_START + 311)
+//free
 #define RID_STR_PARAGRAPH                   (RID_EDIT_START + 312)
 #define RID_STR_WORD                        (RID_EDIT_START + 313)
 #define RID_SVXSTR_A11Y_IMAGEBULLET_DESCRIPTION (RID_EDIT_START + 314)
commit b64bdb8d75105d08fff11beca4bbba128d214d5e
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Feb 17 15:29:55 2017 +0000

    support submenu entries of menus in vcl builder
    
    Change-Id: Ia6f80871ccf56527bb1338a288554bc37cd699e2

diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx
index ac2d869..709c51e 100644
--- a/vcl/source/window/builder.cxx
+++ b/vcl/source/window/builder.cxx
@@ -2592,6 +2592,8 @@ void VclBuilder::handleMenuObject(PopupMenu *pParent, xmlreader::XmlReader &read
     if (!sCustomProperty.isEmpty())
         aProperties[OString("customproperty")] = sCustomProperty;
 
+    bool bInserted = false;
+
     while(true)
     {
         xmlreader::XmlReader::Result res = reader.nextItem(
@@ -2602,11 +2604,22 @@ void VclBuilder::handleMenuObject(PopupMenu *pParent, xmlreader::XmlReader &read
 
         if (res == xmlreader::XmlReader::Result::Begin)
         {
-            ++nLevel;
-            if (name.equals("property"))
-                collectProperty(reader, sID, aProperties);
-            else if (name.equals("accelerator"))
-                collectAccelerator(reader, aAccelerators);
+            if (name.equals("child"))
+            {
+                insertMenuObject(pParent, sClass, sID, aProperties, aAccelerators);
+                VclPtr<PopupMenu> xSubMenu = VclPtr<PopupMenu>::Create();
+                pParent->SetPopupMenu(pParent->GetItemCount(), xSubMenu);
+                handleMenuChild(xSubMenu, reader);
+                bInserted = true;
+            }
+            else
+            {
+                ++nLevel;
+                if (name.equals("property"))
+                    collectProperty(reader, sID, aProperties);
+                else if (name.equals("accelerator"))
+                    collectAccelerator(reader, aAccelerators);
+            }
         }
 
         if (res == xmlreader::XmlReader::Result::End)
@@ -2618,6 +2631,9 @@ void VclBuilder::handleMenuObject(PopupMenu *pParent, xmlreader::XmlReader &read
             break;
     }
 
+    if (bInserted)
+        return;
+
     insertMenuObject(pParent, sClass, sID, aProperties, aAccelerators);
 }
 
@@ -2722,6 +2738,9 @@ namespace
 void VclBuilder::insertMenuObject(PopupMenu *pParent, const OString &rClass, const OString &rID,
     stringmap &rProps, accelmap &rAccels)
 {
+    if (rClass == "GtkMenu")
+        return;
+
     sal_uInt16 nOldCount = pParent->GetItemCount();
     sal_uInt16 nNewId = nOldCount + 1;
 
@@ -2746,7 +2765,6 @@ void VclBuilder::insertMenuObject(PopupMenu *pParent, const OString &rClass, con
         pParent->InsertItem(nNewId, sLabel, MenuItemBits::CHECKABLE | MenuItemBits::RADIOCHECK, rID);
         pParent->SetItemCommand(nNewId, aCommand);
     }
-
     else if (rClass == "GtkSeparatorMenuItem")
     {
         pParent->InsertSeparator(rID);


More information about the Libreoffice-commits mailing list