[Libreoffice-commits] online.git: 2 commits - kit/ChildSession.cpp loleaflet/src scripts/unocommands.py

Tamás Zolnai (via logerrit) logerrit at kemper.freedesktop.org
Sun Nov 24 13:12:48 UTC 2019


 kit/ChildSession.cpp                         |    8 ++++++
 loleaflet/src/control/Control.ContextMenu.js |   31 ++++++++++++++++++++++-----
 loleaflet/src/unocommands.js                 |    8 ++++++
 scripts/unocommands.py                       |    6 +++++
 4 files changed, 48 insertions(+), 5 deletions(-)

New commits:
commit 19e576772aceb4fab4178677b6774055a8e0cdfc
Author:     Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Tue Nov 19 17:13:10 2019 +0100
Commit:     Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Sun Nov 24 14:12:42 2019 +0100

    SpellingPopup: Handle sapces in suggestion.
    
    Change-Id: I09db2cd1db67797a50bc2943200f97aabb004fc6
    Reviewed-on: https://gerrit.libreoffice.org/83607
    Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
    Tested-by: Tamás Zolnai <tamas.zolnai at collabora.com>

diff --git a/kit/ChildSession.cpp b/kit/ChildSession.cpp
index 98101b6b1..677505ad9 100644
--- a/kit/ChildSession.cpp
+++ b/kit/ChildSession.cpp
@@ -364,6 +364,14 @@ bool ChildSession::_handleInput(const char *buffer, int length)
         }
         else if (tokens[0] == "uno")
         {
+            // SpellCheckApplySuggestion might contain non separator spaces
+            if (tokens[1].find(".uno:SpellCheckApplySuggestion") != std::string::npos)
+            {
+                std::vector<std::string> newTokens;
+                newTokens.push_back(tokens[0]);
+                newTokens.push_back(firstLine.substr(4)); // Copy the remaining part.
+                return unoCommand(buffer, length, newTokens);
+            }
             return unoCommand(buffer, length, tokens);
         }
         else if (tokens[0] == "selecttext")
diff --git a/loleaflet/src/control/Control.ContextMenu.js b/loleaflet/src/control/Control.ContextMenu.js
index 00f5f959d..6a28637bc 100644
--- a/loleaflet/src/control/Control.ContextMenu.js
+++ b/loleaflet/src/control/Control.ContextMenu.js
@@ -164,6 +164,7 @@ L.Control.ContextMenu = L.Control.extend({
 
 				if (hasParam || commandName === 'None' || commandName === 'FontDialogForParagraph') {
 					itemName = window.removeAccessKey(item.text);
+					itemName = itemName.replace(' ', '\u00a0');
 				} else {
 					// Get the translated text associated with the command
 					itemName = _UNO(item.command, docType, true);
commit 7041d5c5b035007f09f092d15b40aae4731803a6
Author:     Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Sun Nov 17 15:38:05 2019 +0100
Commit:     Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Sun Nov 24 14:12:30 2019 +0100

    Update conext menu code to handle Spelling Popup
    
    * Use unique IDs for sub menus.
    * Handle uno command's parameter.
    * When there is any parameter, we use the menu text.
    * Avoid to enable FontDialog on other conext menus
    * Introduce the command ".uno:None" to indicate that the
    menu item can't be executed.
    * Whitelisted spelling context menu's uno commands.
    * Add a black list in unocommands.py to list those uno
    commands which have no text in xcu file. In this case,
    we can use the text sent in the menu structure.
    
    Change-Id: Ie84fcb7d6c7a2f4cd50c666dbcd8c77cf42731de
    Reviewed-on: https://gerrit.libreoffice.org/83606
    Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
    Tested-by: Tamás Zolnai <tamas.zolnai at collabora.com>

diff --git a/loleaflet/src/control/Control.ContextMenu.js b/loleaflet/src/control/Control.ContextMenu.js
index bd5e3c400..00f5f959d 100644
--- a/loleaflet/src/control/Control.ContextMenu.js
+++ b/loleaflet/src/control/Control.ContextMenu.js
@@ -36,7 +36,9 @@ L.Control.ContextMenu = L.Control.extend({
 				   'DeleteRows', 'DeleteColumns', 'DeleteTable',
 				   'MergeCells', 'SetOptimalColumnWidth', 'SetOptimalRowHeight',
 				   'UpdateCurIndex','RemoveTableOf',
-				   'ReplyComment', 'DeleteComment', 'DeleteAuthor', 'DeleteAllNotes'],
+				   'ReplyComment', 'DeleteComment', 'DeleteAuthor', 'DeleteAllNotes',
+				   'SpellingAndGrammarDialog', 'LanguageStatus', 'FontDialog', 'FontDialogForParagraph',
+				   'SpellCheckIgnore', 'SpellCheckIgnoreAll', 'SpellCheckApplySuggestion'],
 
 			spreadsheet: ['MergeCells', 'SplitCell', 'RecalcPivotTable', 'FormatCellDialog',
 						  'ShowNote', 'DeleteNote'],
@@ -116,6 +118,7 @@ L.Control.ContextMenu = L.Control.extend({
 		var docType = this._map.getDocType();
 		var contextMenu = {};
 		var sepIdx = 1, itemName;
+		var subMenuIdx = 1;
 		var isLastItemText = false;
 		for (var idx in obj.menu) {
 			var item = obj.menu[idx];
@@ -133,7 +136,20 @@ L.Control.ContextMenu = L.Control.extend({
 				// Only show whitelisted items
 				// Command name (excluding '.uno:') starts from index = 5
 				var commandName = item.command.substring(5);
-				if (this.options.whitelist.general.indexOf(commandName) === -1 &&
+
+				// Command might have paramateres (e.g. .uno:SpellCheckIgnore?Type:string=Grammar)
+				var hasParam = false;
+				if (commandName.indexOf('?')!== -1) {
+					commandName = commandName.substring(0, commandName.indexOf('?'));
+					hasParam = true;
+				}
+
+				// We use a special character dialog in spelling context menu with a parameter
+				if (commandName === 'FontDialog' && !hasParam)
+					continue;
+
+				if (commandName !== 'None' &&
+					this.options.whitelist.general.indexOf(commandName) === -1 &&
 					!(docType === 'text' && this.options.whitelist.text.indexOf(commandName) !== -1) &&
 					!(docType === 'spreadsheet' && this.options.whitelist.spreadsheet.indexOf(commandName) !== -1) &&
 					!(docType === 'presentation' && this.options.whitelist.presentation.indexOf(commandName) !== -1) &&
@@ -146,8 +162,12 @@ L.Control.ContextMenu = L.Control.extend({
 						item.command = '.uno:HideNote';
 				}
 
-				// Get the translated text associated with the command
-				itemName = _UNO(item.command, docType, true);
+				if (hasParam || commandName === 'None' || commandName === 'FontDialogForParagraph') {
+					itemName = window.removeAccessKey(item.text);
+				} else {
+					// Get the translated text associated with the command
+					itemName = _UNO(item.command, docType, true);
+				}
 
 				contextMenu[item.command] = {
 					// Using 'click' and <a href='#' is vital for copy/paste security context.
@@ -178,7 +198,7 @@ L.Control.ContextMenu = L.Control.extend({
 					continue;
 				}
 
-				contextMenu[item.command] = {
+				contextMenu['submenu' + subMenuIdx++] = {
 					name: _(itemName).replace(/\(~[A-Za-z]\)/, '').replace('~', ''),
 					items: submenu
 				};
diff --git a/loleaflet/src/unocommands.js b/loleaflet/src/unocommands.js
index f6fcc3e6c..deb7e70b0 100644
--- a/loleaflet/src/unocommands.js
+++ b/loleaflet/src/unocommands.js
@@ -154,6 +154,7 @@ var unoCommandsArray = {
 	JumpUpThisLevel:{text:{menu:_('To Previous Paragraph in Level'),},},
 	JustifyPara:{global:{menu:_('Justified'),},},
 	LanguageMenu:{global:{menu:_('Language'),},},
+	LanguageStatus:{global:{menu:_('Language Status'),},},
 	LayoutStatus:{presentation:{menu:_('Layout'),},},
 	LeftPara:{global:{context:_('Align Left'),menu:_('Left'),},},
 	MergeCells:{presentation:{menu:_('Merge Cells'),},spreadsheet:{menu:_('Merge Cells'),},text:{menu:_('Merge Cells'),},},
@@ -241,6 +242,9 @@ var unoCommandsArray = {
 	SpacePara1:{global:{menu:_('Line Spacing: 1'),},},
 	SpacePara15:{global:{menu:_('Line Spacing: 1.5'),},},
 	SpacePara2:{global:{menu:_('Line Spacing: 2'),},},
+	SpellCheckApplySuggestion:{global:{menu:_('Apply Suggestion'),},},
+	SpellCheckIgnore:{global:{menu:_('Ignore'),},},
+	SpellCheckIgnoreAll:{global:{menu:_('IgnoreAll'),},},
 	SpellDialog:{global:{menu:_('~Spelling...'),},},
 	SpellOnline:{global:{menu:_('~Automatic Spell Checking'),},},
 	SpellingAndGrammarDialog:{global:{menu:_('~Spelling...'),},},
@@ -311,6 +315,10 @@ window._UNO = function(string, component, isContext) {
 		}
 	}
 
+	return this.removeAccessKey(text);
+}
+
+window.removeAccessKey = function(text) {
 	// Remove access key markers from translated strings
 	// 1. access key in parenthesis in case of non-latin scripts
 	text = text.replace(/\(~[A-Za-z]\)/, '');
diff --git a/scripts/unocommands.py b/scripts/unocommands.py
index e4dc45ef4..59aa19d84 100755
--- a/scripts/unocommands.py
+++ b/scripts/unocommands.py
@@ -86,6 +86,7 @@ def extractMenuCommands(path):
 
 # Extract all the uno commands we are using in the Online context menu
 def extractContextCommands(path):
+    commandsToIgnore = ["FontDialogForParagraph"]
     commands = []
 
     # extract from the comments whitelist
@@ -114,6 +115,7 @@ def extractContextCommands(path):
         if line.find("_UNO(") >= 0:
             commands += commandFromMenuLine(line)
 
+    commands = [command for command in commands if command not in commandsToIgnore]
     # may the list unique
     return set(commands)
 
@@ -242,6 +244,10 @@ window._UNO = function(string, component, isContext) {
 \t\t}
 \t}
 
+\treturn this.removeAccessKey(text);
+}
+
+window.removeAccessKey = function(text) {
 \t// Remove access key markers from translated strings
 \t// 1. access key in parenthesis in case of non-latin scripts
 \ttext = text.replace(/\(~[A-Za-z]\)/, '');


More information about the Libreoffice-commits mailing list