loleaflet/build/build.js                     |    1 
 loleaflet/main.js                            |    1 
 loleaflet/src/control/Control.ContextMenu.js |    3 
 loleaflet/src/control/Control.Menubar.js     |  249 +++++++++++++--------------
 loleaflet/unocommands.js                     |  173 ++++++++++++++++--
 scripts/unocommands.py                       |  136 ++++++++++++++
 6 files changed, 422 insertions(+), 141 deletions(-)

New commits:
commit 5b87f2fca5d6f84d0ac637021e87e2dc41dd13c7
Author: Jan Holesovsky <[email protected]>
Date:   Wed Dec 6 20:20:46 2017 +0100

    l10n: Don't repeat the strings in the menu definition, use the uno commands.
    
    Change-Id: If8ccd753cd88056c64c10e3f9f7b951208fafdb8
    Reviewed-on: https://gerrit.libreoffice.org/45983
    Reviewed-by: Andras Timar <[email protected]>
    Tested-by: Andras Timar <[email protected]>

diff --git a/loleaflet/build/build.js b/loleaflet/build/build.js
index 33f782dc..2c5baa0c 100644
--- a/loleaflet/build/build.js
+++ b/loleaflet/build/build.js
@@ -13,6 +13,7 @@ var JSBundleFiles = [
        'main.js',
        'dist/leaflet-src.js',
        'dist/errormessages.js',
+       'unocommands.js',
        'dist/plugins/draw-0.2.4/dist/leaflet.draw.js'
 ];
 
diff --git a/loleaflet/main.js b/loleaflet/main.js
index ca143017..4b0894ee 100644
--- a/loleaflet/main.js
+++ b/loleaflet/main.js
@@ -40,6 +40,7 @@ vex.defaultOptions.className = 'vex-theme-plain';
 global.vex = vex;
 
 var errorMessages = require('./dist/errormessages');
+require('./unocommands');
 
 function getParameterByName(name) {
     name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
diff --git a/loleaflet/src/control/Control.Menubar.js 
b/loleaflet/src/control/Control.Menubar.js
index 5a77aea5..07e69bdc 100644
--- a/loleaflet/src/control/Control.Menubar.js
+++ b/loleaflet/src/control/Control.Menubar.js
@@ -2,7 +2,7 @@
 * Control.Menubar
 */
 
-/* global $ _ map vex revHistoryEnabled closebutton L */
+/* global $ _ _UNO map vex revHistoryEnabled closebutton L */
 L.Control.Menubar = L.Control.extend({
        // TODO: Some mechanism to stop the need to copy duplicate menus (eg. 
Help)
        options: {
@@ -26,26 +26,26 @@ L.Control.Menubar = L.Control.extend({
                                        {name: _('Microsoft Word (.docx)'), id: 
'downloadas-docx', type: 'action'}]}]
                        },
                        {name: _('Edit'), type: 'menu', menu: [
-                               {name: _('Undo'), type: 'unocommand', uno: 
'.uno:Undo'},
-                               {name: _('Redo'), type: 'unocommand', uno: 
'.uno:Redo'},
+                               {type: 'unocommand', uno: '.uno:Undo'},
+                               {type: 'unocommand', uno: '.uno:Redo'},
                                {name: _('Repair'), id: 'repair',  type: 
'action'},
                                {type: 'separator'},
-                               {name: _('Cut'), type: 'unocommand', uno: 
'.uno:Cut'},
-                               {name: _('Copy'), type: 'unocommand', uno: 
'.uno:Copy'},
-                               {name: _('Paste'), type: 'unocommand', uno: 
'.uno:Paste'},
-                               {name: _('Select all'), type: 'unocommand', 
uno: '.uno:SelectAll'},
+                               {type: 'unocommand', uno: '.uno:Cut'},
+                               {type: 'unocommand', uno: '.uno:Copy'},
+                               {type: 'unocommand', uno: '.uno:Paste'},
+                               {type: 'unocommand', uno: '.uno:SelectAll'},
                                {type: 'separator'},
                                {name: _('Find & Replace...'), uno: 
'.uno:SearchDialog', type: 'unocommand'},
                                {type: 'separator'},
                                {name: _('Track Changes'), type: 'menu', menu: [
-                                       {name: _('Record'), type: 'unocommand', 
uno: '.uno:TrackChanges'},
-                                       {name: _('Show'), type: 'unocommand', 
uno: '.uno:ShowTrackedChanges'},
+                                       {type: 'unocommand', uno: 
'.uno:TrackChanges'},
+                                       {type: 'unocommand', uno: 
'.uno:ShowTrackedChanges'},
                                        {type: 'separator'},
                                        {name: _('Manage Changes...'), uno: 
'.uno:AcceptTrackedChanges', type: 'unocommand'},
-                                       {name: _('Accept All'), type: 
'unocommand', uno: '.uno:AcceptAllTrackedChanges'},
-                                       {name: _('Reject All'), type: 
'unocommand', uno: '.uno:RejectAllTrackedChanges'},
-                                       {name: _('Previous'), type: 
'unocommand', uno: '.uno:PreviousTrackedChange'},
-                                       {name: _('Next'), type: 'unocommand', 
uno: '.uno:NextTrackedChange'}
+                                       {type: 'unocommand', uno: 
'.uno:AcceptAllTrackedChanges'},
+                                       {type: 'unocommand', uno: 
'.uno:RejectAllTrackedChanges'},
+                                       {type: 'unocommand', uno: 
'.uno:PreviousTrackedChange'},
+                                       {type: 'unocommand', uno: 
'.uno:NextTrackedChange'}
                                ]},
                                {name: _('Edit Style...'), uno: 
'.uno:EditStyle', type: 'unocommand'},
                        ]},
@@ -56,106 +56,106 @@ L.Control.Menubar = L.Control.extend({
                                {name: _('Zoom out'), id: 'zoomout', type: 
'action'},
                                {name: _('Reset zoom'), id: 'zoomreset', type: 
'action'},
                                {type: 'separator'},
-                               {name: _('Formatting Marks'), type: 
'unocommand', uno: '.uno:ControlCodes'},
+                               {type: 'unocommand', uno: '.uno:ControlCodes'},
                        ]
                        },
                        {name: _('Insert'), type: 'menu', menu: [
                                {name: _('Image'), id: 'insertgraphic', type: 
'action'},
                                {name: _('Comment...'), id: 'insertcomment', 
type: 'action'},
                                {type: 'separator'},
-                               {name: _('Footnote'), type: 'unocommand', uno: 
'.uno:InsertFootnote'},
-                               {name: _('Endnote'), type: 'unocommand', uno: 
'.uno:InsertEndnote'},
+                               {type: 'unocommand', uno: 
'.uno:InsertFootnote'},
+                               {type: 'unocommand', uno: '.uno:InsertEndnote'},
                                {type: 'separator'},
-                               {name: _('Page break'), type: 'unocommand', 
uno: '.uno:InsertPageBreak'},
-                               {name: _('Column break'), type: 'unocommand', 
uno: '.uno:InsertColumnBreak'},
+                               {type: 'unocommand', uno: 
'.uno:InsertPageBreak'},
+                               {type: 'unocommand', uno: 
'.uno:InsertColumnBreak'},
                                {type: 'separator'},
                                {name: _('Hyperlink...'), uno: 
'.uno:HyperlinkDialog', type: 'unocommand'},
                                {name: _('Special character...'), id: 
'specialcharacter', type: 'action'},
                                {name: _('Formatting mark'), type: 'menu', 
menu: [
-                                       {name: _('Non-breaking space'), type: 
'unocommand', uno: '.uno:InsertNonBreakingSpace'},
-                                       {name: _('Non-breaking hyphen'), type: 
'unocommand', uno: '.uno:InsertHardHyphen'},
-                                       {name: _('Soft hyphen'), type: 
'unocommand', uno: '.uno:InsertSoftHyphen'},
-                                       {name: _('No-width optional break'), 
type: 'unocommand', uno: '.uno:InsertZWSP'},
-                                       {name: _('No-width no break'), type: 
'unocommand', uno: '.uno:InsertZWNBSP'},
-                                       {name: _('Left-to-right mark'), type: 
'unocommand', uno: '.uno:InsertLRM'},
-                                       {name: _('Right-to-left mark'), type: 
'unocommand', uno: '.uno:InsertRLM'}]},
+                                       {type: 'unocommand', uno: 
'.uno:InsertNonBreakingSpace'},
+                                       {type: 'unocommand', uno: 
'.uno:InsertHardHyphen'},
+                                       {type: 'unocommand', uno: 
'.uno:InsertSoftHyphen'},
+                                       {type: 'unocommand', uno: 
'.uno:InsertZWSP'},
+                                       {type: 'unocommand', uno: 
'.uno:InsertZWNBSP'},
+                                       {type: 'unocommand', uno: 
'.uno:InsertLRM'},
+                                       {type: 'unocommand', uno: 
'.uno:InsertRLM'}]},
                                {name: _('Index Entry...'), uno: 
'.uno:InsertIndexesEntry', type: 'unocommand'}
                        ]
                        },
                        {name: _('Format'), type: 'menu', menu: [
                                {name: _('Text'), type: 'menu', menu: [
-                                       {name: _('Bold'), type: 'unocommand', 
uno: '.uno:Bold'},
-                                       {name: _('Italic'), type: 'unocommand', 
uno: '.uno:Italic'},
-                                       {name: _('Underline'), type: 
'unocommand', uno: '.uno:Underline'},
-                                       {name: _('Double underline'), type: 
'unocommand', uno: '.uno:UnderlineDouble'},
-                                       {name: _('Strikethrough'), type: 
'unocommand', uno: '.uno:Strikeout'},
-                                       {name: _('Overline'), type: 
'unocommand', uno: '.uno:Overline'},
+                                       {type: 'unocommand', uno: '.uno:Bold'},
+                                       {type: 'unocommand', uno: 
'.uno:Italic'},
+                                       {type: 'unocommand', uno: 
'.uno:Underline'},
+                                       {type: 'unocommand', uno: 
'.uno:UnderlineDouble'},
+                                       {type: 'unocommand', uno: 
'.uno:Strikeout'},
+                                       {type: 'unocommand', uno: 
'.uno:Overline'},
                                        {type: 'separator'},
-                                       {name: _('Superscript'), type: 
'unocommand', uno: '.uno:SuperScript'},
-                                       {name: _('Subscript'), type: 
'unocommand', uno: '.uno:SubScript'},
-                                       {name: _('ꜱᴍᴀʟʟ ᴄᴀᴘꜱ'), 
type: 'unocommand', uno: '.uno:SmallCaps'},
+                                       {type: 'unocommand', uno: 
'.uno:SuperScript'},
+                                       {type: 'unocommand', uno: 
'.uno:SubScript'},
+                                       {type: 'unocommand', uno: 
'.uno:SmallCaps'},
                                        {type: 'separator'},
-                                       {name: _('Shadow'), type: 'unocommand', 
uno: '.uno:Shadowed'},
-                                       {name: _('Outline'), type: 
'unocommand', uno: '.uno:OutlineFont'},
+                                       {type: 'unocommand', uno: 
'.uno:Shadowed'},
+                                       {type: 'unocommand', uno: 
'.uno:OutlineFont'},
                                        {type: 'separator'},
-                                       {name: _('Increase size'), type: 
'unocommand', uno: '.uno:Grow'},
-                                       {name: _('Decrease size'), type: 
'unocommand', uno: '.uno:Shrink'},
+                                       {type: 'unocommand', uno: '.uno:Grow'},
+                                       {type: 'unocommand', uno: 
'.uno:Shrink'},
                                        {type: 'separator'},
-                                       {name: _('UPPERCASE'), type: 
'unocommand', uno: '.uno:ChangeCaseToUpper'},
-                                       {name: _('lowercase'), type: 
'unocommand', uno: '.uno:ChangeCaseToLower'},
-                                       {name: _('Cycle case'), type: 
'unocommand', uno: '.uno:ChangeCaseRotateCase'},
+                                       {type: 'unocommand', uno: 
'.uno:ChangeCaseToUpper'},
+                                       {type: 'unocommand', uno: 
'.uno:ChangeCaseToLower'},
+                                       {type: 'unocommand', uno: 
'.uno:ChangeCaseRotateCase'},
                                        {type: 'separator'},
-                                       {name: _('Sentence case'), type: 
'unocommand', uno: '.uno:ChangeCaseToSentenceCase'},
-                                       {name: _('Capitalize Every Word'), 
type: 'unocommand', uno: '.uno:ChangeCaseToTitleCase'},
-                                       {name: _('tOGGLE cASE'), type: 
'unocommand', uno: '.uno:ChangeCaseToToggleCase'}]},
+                                       {type: 'unocommand', uno: 
'.uno:ChangeCaseToSentenceCase'},
+                                       {type: 'unocommand', uno: 
'.uno:ChangeCaseToTitleCase'},
+                                       {type: 'unocommand', uno: 
'.uno:ChangeCaseToToggleCase'}]},
                                {name: _('Text orientation'), type: 'menu', 
menu: [
-                                       {name: _('Set paragraph 
left-to-right'), type: 'unocommand', uno: '.uno:ParaLeftToRight'},
-                                       {name: _('Set paragraph 
right-to-left'), type: 'unocommand', uno: '.uno:ParaRightToLeft'}]},
+                                       {type: 'unocommand', uno: 
'.uno:ParaLeftToRight'},
+                                       {type: 'unocommand', uno: 
'.uno:ParaRightToLeft'}]},
                                {name: _('Spacing'), type: 'menu', menu: [
-                                       {name: _('Line spacing: 1'), type: 
'unocommand', uno: '.uno:SpacePara1'},
-                                       {name: _('Line spacing: 1.5'), type: 
'unocommand', uno: '.uno:SpacePara15'},
-                                       {name: _('Line spacing: 2'), type: 
'unocommand', uno: '.uno:SpacePara2'},
+                                       {type: 'unocommand', uno: 
'.uno:SpacePara1'},
+                                       {type: 'unocommand', uno: 
'.uno:SpacePara15'},
+                                       {type: 'unocommand', uno: 
'.uno:SpacePara2'},
                                        {type: 'separator'},
-                                       {name: _('Increase paragraph spacing'), 
type: 'unocommand', uno: '.uno:ParaspaceIncrease'},
-                                       {name: _('Decrease paragraph spacing'), 
type: 'unocommand', uno: '.uno:ParaspaceDecrease'},
+                                       {type: 'unocommand', uno: 
'.uno:ParaspaceIncrease'},
+                                       {type: 'unocommand', uno: 
'.uno:ParaspaceDecrease'},
                                        {type: 'separator'},
-                                       {name: _('Increase indent'), type: 
'unocommand', uno: '.uno:IncrementIndent'},
-                                       {name: _('Decrease indent'), type: 
'unocommand', uno: '.uno:DecrementIndent'}]},
+                                       {type: 'unocommand', uno: 
'.uno:IncrementIndent'},
+                                       {type: 'unocommand', uno: 
'.uno:DecrementIndent'}]},
                                {name: _('Align'), type: 'menu', menu: [
-                                       {name: _('Left'), type: 'unocommand', 
uno: '.uno:CommonAlignLeft'},
-                                       {name: _('Centered'), type: 
'unocommand', uno: '.uno:CommonAlignHorizontalCenter'},
-                                       {name: _('Right'), type: 'unocommand', 
uno: '.uno:CommonAlignRight'},
-                                       {name: _('Justified'), type: 
'unocommand', uno: '.uno:CommonAlignJustified'},
+                                       {type: 'unocommand', uno: 
'.uno:CommonAlignLeft'},
+                                       {type: 'unocommand', uno: 
'.uno:CommonAlignHorizontalCenter'},
+                                       {type: 'unocommand', uno: 
'.uno:CommonAlignRight'},
+                                       {type: 'unocommand', uno: 
'.uno:CommonAlignJustified'},
                                        {type: 'separator'},
-                                       {name: _('Top'), type: 'unocommand', 
uno: '.uno:CommonAlignTop'},
-                                       {name: _('Center'), type: 'unocommand', 
uno: '.uno:CommonAlignVerticalcenter'},
-                                       {name: _('Bottom'), type: 'unocommand', 
uno: '.uno:CommonAlignBottom'}]},
+                                       {type: 'unocommand', uno: 
'.uno:CommonAlignTop'},
+                                       {type: 'unocommand', uno: 
'.uno:CommonAlignVerticalcenter'},
+                                       {type: 'unocommand', uno: 
'.uno:CommonAlignBottom'}]},
                                {name: _('Lists'), type: 'menu', menu: [
-                                       {name: _('Bullets on/off'), type: 
'unocommand', uno: '.uno:DefaultBullet'},
-                                       {name: _('Numbering on/off'), type: 
'unocommand', uno: '.uno:DefaultNumbering'},
+                                       {type: 'unocommand', uno: 
'.uno:DefaultBullet'},
+                                       {type: 'unocommand', uno: 
'.uno:DefaultNumbering'},
                                        {type: 'separator'},
-                                       {name: _('Demote one level'), type: 
'unocommand', uno: '.uno:DecrementLevel'},
-                                       {name: _('Promote one level'), type: 
'unocommand', uno: '.uno:IncrementLevel'},
-                                       {name: _('Demote one level with 
subpoints'), type: 'unocommand', uno: '.uno:DecrementSublevels'},
-                                       {name: _('Promote one level with 
subpoints'), type: 'unocommand', uno: '.uno:IncrementSubLevels'},
+                                       {type: 'unocommand', uno: 
'.uno:DecrementLevel'},
+                                       {type: 'unocommand', uno: 
'.uno:IncrementLevel'},
+                                       {type: 'unocommand', uno: 
'.uno:DecrementSublevels'},
+                                       {type: 'unocommand', uno: 
'.uno:IncrementSubLevels'},
                                        {type: 'separator'},
-                                       {name: _('Move down'), type: 
'unocommand', uno: '.uno:MoveDown'},
-                                       {name: _('Move up'), type: 
'unocommand', uno: '.uno:MoveUp'},
-                                       {name: _('Move down with subpoints'), 
type: 'unocommand', uno: '.uno:MoveDownSubItems'},
-                                       {name: _('Move up with subpoints'), 
type: 'unocommand', uno: '.uno:MoveUpSubItems'},
+                                       {type: 'unocommand', uno: 
'.uno:MoveDown'},
+                                       {type: 'unocommand', uno: 
'.uno:MoveUp'},
+                                       {type: 'unocommand', uno: 
'.uno:MoveDownSubItems'},
+                                       {type: 'unocommand', uno: 
'.uno:MoveUpSubItems'},
                                        {type: 'separator'},
-                                       {name: _('Insert unnumbered entry'), 
type: 'unocommand', uno: '.uno:InsertNeutralParagraph'},
-                                       {name: _('Restart numbering'), type: 
'unocommand', uno: '.uno:NumberingStart'},
+                                       {type: 'unocommand', uno: 
'.uno:InsertNeutralParagraph'},
+                                       {type: 'unocommand', uno: 
'.uno:NumberingStart'},
                                        {type: 'separator'},
-                                       {name: _('To next paragraph in level'), 
type: 'unocommand', uno: '.uno:JumpDownThisLevel'},
-                                       {name: _('To previous paragraph in 
level'), type: 'unocommand', uno: '.uno:JumpUpThisLevel'},
-                                       {name: _('Continue previous 
numbering'), type: 'unocommand', uno: '.uno:ContinueNumbering'}]},
+                                       {type: 'unocommand', uno: 
'.uno:JumpDownThisLevel'},
+                                       {type: 'unocommand', uno: 
'.uno:JumpUpThisLevel'},
+                                       {type: 'unocommand', uno: 
'.uno:ContinueNumbering'}]},
                                {type: 'separator'},
                                {name: _('Character...'), uno: 
'.uno:FontDialog', type: 'unocommand'},
                                {name: _('Paragraph...'), uno: 
'.uno:ParagraphDialog', type: 'unocommand'},
                                {name: _('Bullets and Numbering...'), uno: 
'.uno:OutlineBullet', type: 'unocommand'},
                                {type: 'separator'},
-                               {name: _('Clear direct formatting'), type: 
'unocommand', uno: '.uno:ResetAttributes'},
+                               {type: 'unocommand', uno: 
'.uno:ResetAttributes'},
                                {name: _('Page'), type: 'menu', menu: [
                                        {name: 'A4, ' + _('Portrait'), type: 
'action', id: 'a4portrait'},
                                        {name: 'A4, ' + _('Landscape'), type: 
'action', id: 'a4landscape'},
@@ -168,27 +168,27 @@ L.Control.Menubar = L.Control.extend({
                        },
                        {name: _('Tables'), type: 'menu', menu: [
                                {name: _('Insert'), type: 'menu', menu: [
-                                       {name: _('Rows before'), type: 
'unocommand', uno: '.uno:InsertRowsBefore'},
-                                       {name: _('Rows after'), type: 
'unocommand', uno: '.uno:InsertRowsAfter'},
+                                       {type: 'unocommand', uno: 
'.uno:InsertRowsBefore'},
+                                       {type: 'unocommand', uno: 
'.uno:InsertRowsAfter'},
                                        {type: 'separator'},
-                                       {name: _('Columns left'), type: 
'unocommand', uno: '.uno:InsertColumnsBefore'},
-                                       {name: _('Columns right'), type: 
'unocommand', uno: '.uno:InsertColumnsAfter'}]},
+                                       {type: 'unocommand', uno: 
'.uno:InsertColumnsBefore'},
+                                       {type: 'unocommand', uno: 
'.uno:InsertColumnsAfter'}]},
                                {name: _('Delete'), type: 'menu', menu: [
-                                       {name: _('Rows'), type: 'unocommand', 
uno: '.uno:DeleteRows'},
-                                       {name: _('Columns'), type: 
'unocommand', uno: '.uno:DeleteColumns'},
-                                       {name: _('Table'), type: 'unocommand', 
uno: '.uno:DeleteTable'}]},
+                                       {type: 'unocommand', uno: 
'.uno:DeleteRows'},
+                                       {type: 'unocommand', uno: 
'.uno:DeleteColumns'},
+                                       {type: 'unocommand', uno: 
'.uno:DeleteTable'}]},
                                {name: _('Select'), type: 'menu', menu: [
-                                       {name: _('Table'), type: 'unocommand', 
uno: '.uno:SelectTable'},
-                                       {name: _('Row'), type: 'unocommand', 
uno: '.uno:EntireRow'},
-                                       {name: _('Column'), type: 'unocommand', 
uno: '.uno:EntireColumn'},
-                                       {name: _('Cell'), type: 'unocommand', 
uno: '.uno:EntireCell'}]},
-                               {name: _('Merge cells'), type: 'unocommand', 
uno: '.uno:MergeCells'},
+                                       {type: 'unocommand', uno: 
'.uno:SelectTable'},
+                                       {type: 'unocommand', uno: 
'.uno:EntireRow'},
+                                       {type: 'unocommand', uno: 
'.uno:EntireColumn'},
+                                       {type: 'unocommand', uno: 
'.uno:EntireCell'}]},
+                               {type: 'unocommand', uno: '.uno:MergeCells'},
                                {type: 'separator'},
                                {name: _('Properties...'), uno: 
'.uno:TableDialog', type: 'unocommand'}
                        ]},
                        {name: _('Tools'), id: 'tools', type: 'menu', menu: [
                                {name: _('Spelling...'), uno: 
'.uno:SpellingAndGrammarDialog', type: 'unocommand'},
-                               {name: _('Automatic spell checking'), type: 
'unocommand', uno: '.uno:SpellOnline'},
+                               {type: 'unocommand', uno: '.uno:SpellOnline'},
                                {name: _('Language for selection'), type: 
'menu', menu: [
                                        {name: _('None (Do not check 
spelling)'), id: 'noneselection', type: 'unocommand', uno: 
'.uno:LanguageStatus?Language:string=Current_LANGUAGE_NONE'}]},
                                {name: _('Language for paragraph'), type: 
'menu', menu: [
@@ -217,14 +217,14 @@ L.Control.Menubar = L.Control.extend({
                                        {name: _('Microsoft Powerpoint 
(.pptx)'), id: 'downloadas-pptx', type: 'action'}]}]
                        },
                        {name: _('Edit'), type: 'menu', menu: [
-                               {name: _('Undo'), type: 'unocommand', uno: 
'.uno:Undo'},
-                               {name: _('Redo'), type: 'unocommand', uno: 
'.uno:Redo'},
+                               {type: 'unocommand', uno: '.uno:Undo'},
+                               {type: 'unocommand', uno: '.uno:Redo'},
                                {name: _('Repair'), id: 'repair',  type: 
'action'},
                                {type: 'separator'},
-                               {name: _('Cut'), type: 'unocommand', uno: 
'.uno:Cut'},
-                               {name: _('Copy'), type: 'unocommand', uno: 
'.uno:Copy'},
-                               {name: _('Paste'), type: 'unocommand', uno: 
'.uno:Paste'},
-                               {name: _('Select all'), type: 'unocommand', 
uno: '.uno:SelectAll'},
+                               {type: 'unocommand', uno: '.uno:Cut'},
+                               {type: 'unocommand', uno: '.uno:Copy'},
+                               {type: 'unocommand', uno: '.uno:Paste'},
+                               {type: 'unocommand', uno: '.uno:SelectAll'},
                                {type: 'separator'},
                                {name: _('Find & Replace...'), uno: 
'.uno:SearchDialog', type: 'unocommand'}
                        ]},
@@ -246,15 +246,15 @@ L.Control.Menubar = L.Control.extend({
                        ]},
                        {name: _('Tables'), type: 'menu', menu: [
                                {name: _('Insert'), type: 'menu', menu: [
-                                       {name: _('Rows before'), type: 
'unocommand', uno: '.uno:InsertRowsBefore'},
-                                       {name: _('Rows after'), type: 
'unocommand', uno: '.uno:InsertRowsAfter'},
+                                       {type: 'unocommand', uno: 
'.uno:InsertRowsBefore'},
+                                       {type: 'unocommand', uno: 
'.uno:InsertRowsAfter'},
                                        {type: 'separator'},
-                                       {name: _('Columns left'), type: 
'unocommand', uno: '.uno:InsertColumnsBefore'},
-                                       {name: _('Columns right'), type: 
'unocommand', uno: '.uno:InsertColumnsAfter'}]},
+                                       {type: 'unocommand', uno: 
'.uno:InsertColumnsBefore'},
+                                       {type: 'unocommand', uno: 
'.uno:InsertColumnsAfter'}]},
                                {name: _('Delete'), type: 'menu', menu: [
-                                       {name: _('Rows'), type: 'unocommand', 
uno: '.uno:DeleteRows'},
-                                       {name: _('Columns'), type: 
'unocommand', uno: '.uno:DeleteColumns'}]},
-                               {name: _('Merge cells'), type: 'unocommand', 
uno: '.uno:MergeCells'}]
+                                       {type: 'unocommand', uno: 
'.uno:DeleteRows'},
+                                       {type: 'unocommand', uno: 
'.uno:DeleteColumns'}]},
+                               {type: 'unocommand', uno: '.uno:MergeCells'}]
                        },
                        {name: _('Slide'), type: 'menu', menu: [
                                {name: _('New slide'), id: 'insertpage', type: 
'action'},
@@ -264,7 +264,7 @@ L.Control.Menubar = L.Control.extend({
                                {name: _('Fullscreen presentation'), id: 
'fullscreen-presentation', type: 'action'}]
                        },
                        {name: _('Tools'), id: 'tools', type: 'menu', menu: [
-                               {name: _('Automatic spell checking'), type: 
'unocommand', uno: '.uno:SpellOnline'},
+                               {type: 'unocommand', uno: '.uno:SpellOnline'},
                                {name: _('Language'), type: 'menu', menu: [
                                        {name: _('None (Do not check 
spelling)'), id: 'nonelanguage', type: 'unocommand', uno: 
'.uno:LanguageStatus?Language:string=Default_LANGUAGE_NONE'}]}
                        ]},
@@ -288,14 +288,14 @@ L.Control.Menubar = L.Control.extend({
                                        {name: _('Microsoft Excel (.xlsx)'), 
id: 'downloadas-xlsx', type: 'action'}]}
                        ]},
                        {name: _('Edit'), type: 'menu', menu: [
-                               {name: _('Undo'), type: 'unocommand', uno: 
'.uno:Undo'},
-                               {name: _('Redo'), type: 'unocommand', uno: 
'.uno:Redo'},
+                               {type: 'unocommand', uno: '.uno:Undo'},
+                               {type: 'unocommand', uno: '.uno:Redo'},
                                {name: _('Repair'), id: 'repair',  type: 
'action'},
                                {type: 'separator'},
-                               {name: _('Cut'), type: 'unocommand', uno: 
'.uno:Cut'},
-                               {name: _('Copy'), type: 'unocommand', uno: 
'.uno:Copy'},
-                               {name: _('Paste'), type: 'unocommand', uno: 
'.uno:Paste'},
-                               {name: _('Select all'), type: 'unocommand', 
uno: '.uno:SelectAll'},
+                               {type: 'unocommand', uno: '.uno:Cut'},
+                               {type: 'unocommand', uno: '.uno:Copy'},
+                               {type: 'unocommand', uno: '.uno:Paste'},
+                               {type: 'unocommand', uno: '.uno:SelectAll'},
                                {type: 'separator'},
                                {name: _('Find & Replace...'), uno: 
'.uno:SearchDialog', type: 'unocommand'}
                        ]},
@@ -306,33 +306,33 @@ L.Control.Menubar = L.Control.extend({
                                {name: _('Image'), id: 'insertgraphic', type: 
'action'},
                                {name: _('Comment...'), id: 'insertcomment', 
type: 'action'},
                                {type: 'separator'},
-                               {name: _('Row'), type: 'unocommand', uno: 
'.uno:InsertRows'},
-                               {name: _('Column'), type: 'unocommand', uno: 
'.uno:InsertColumns'},
+                               {type: 'unocommand', uno: '.uno:InsertRows'},
+                               {type: 'unocommand', uno: '.uno:InsertColumns'},
                                {type: 'separator'},
                                {name: _('Special character...'), id: 
'specialcharacter', type: 'action'}
                        ]},
                        {name: _('Format'), type: 'menu', menu: [
-                               {name: _('Clear direct formatting'), type: 
'unocommand', uno: '.uno:ResetAttributes'},
+                               {type: 'unocommand', uno: 
'.uno:ResetAttributes'},
                                {name: _('Cells...'), type: 'unocommand', uno: 
'.uno:FormatCellDialog'}
                        ]},
                        {name: _('Sheet'), type: 'menu', menu: [
-                               {name: _('Insert row'), type: 'unocommand', 
uno: '.uno:InsertRows'},
-                               {name: _('Insert column'), type: 'unocommand', 
uno: '.uno:InsertColumns'},
+                               {type: 'unocommand', uno: '.uno:InsertRows'},
+                               {type: 'unocommand', uno: '.uno:InsertColumns'},
                                {type: 'separator'},
-                               {name: _('Delete row'), type: 'unocommand', 
uno: '.uno:DeleteRows'},
-                               {name: _('Delete column'), type: 'unocommand', 
uno: '.uno:DeleteColumns'}
+                               {type: 'unocommand', uno: '.uno:DeleteRows'},
+                               {type: 'unocommand', uno: '.uno:DeleteColumns'}
                        ]},
                        {name: _('Data'), type: 'menu', menu: [
-                               {name: _('Group'), type: 'unocommand', uno: 
'.uno:Group'},
-                               {name: _('Ungroup'), type: 'unocommand', uno: 
'.uno:Ungroup'},
+                               {type: 'unocommand', uno: '.uno:Group'},
+                               {type: 'unocommand', uno: '.uno:Ungroup'},
                                {type: 'separator'},
-                               {name: _('Remove Outline'), type: 'unocommand', 
uno: '.uno:ClearOutline'},
+                               {type: 'unocommand', uno: '.uno:ClearOutline'},
                                {type: 'separator'},
-                               {name: _('Show Details'), type: 'unocommand', 
uno: '.uno:ShowDetail'},
-                               {name: _('Hide Details'), type: 'unocommand', 
uno: '.uno:HideDetail'}
+                               {type: 'unocommand', uno: '.uno:ShowDetail'},
+                               {type: 'unocommand', uno: '.uno:HideDetail'}
                        ]},
                        {name: _('Tools'), id: 'tools', type: 'menu', menu: [
-                               {name: _('Automatic spell checking'), type: 
'unocommand', uno: '.uno:SpellOnline'},
+                               {type: 'unocommand', uno: '.uno:SpellOnline'},
                                {name: _('Language'), type: 'menu', menu: [
                                        {name: _('None (Do not check 
spelling)'), id: 'nonelanguage', type: 'unocommand', uno: 
'.uno:LanguageStatus?Language:string=Default_LANGUAGE_NONE'}]}
                        ]},
@@ -506,6 +506,11 @@ L.Control.Menubar = L.Control.extend({
                        if (map._permission === 'edit') {
                                if (type === 'unocommand') { // enable all 
depending on stored commandStates
                                        var unoCommand = $(aItem).data('uno');
+                                       if ($(aItem).data('name') === 
undefined) {
+                                               var text = _UNO(unoCommand);
+                                               $(aItem).data('name', text);
+                                               aItem.innerHTML = text;
+                                       }
                                        var itemState = 
map['stateChangeHandler'].getItemValue(unoCommand);
                                        if (itemState === 'disabled') {
                                                $(aItem).addClass('disabled');
diff --git a/loleaflet/unocommands.js b/loleaflet/unocommands.js
index 4f9e0053..eb81e92a 100644
--- a/loleaflet/unocommands.js
+++ b/loleaflet/unocommands.js
@@ -1,19 +1,154 @@
-var CopyHyperlinkLocation = _('Copy Hyperlink');
-var DecrementLevel = _('Down One Level');
-var IncrementLevel = _('Up One Level');
-var EditAnnotation = _('Edit Comment');
-var InsertAnnotation = _('Insert Comment');
-var Merge = _('Merge');
-var MergeCells = _('Merge Cells...');
-var ObjectBackOne = _('Bring Forward');
-var ObjectForwardOne = _('Send Backward');
-var PasteSpecial = _('Paste Special');
-var PasteUnformatted = _('Unformatted Text');
-var NoWrap = _('No Wrap');
-var WrapBefore = _('Wrap Before');
-var WrapAfter = _('Wrap After');
-var EnableContour = _('Enable Contour');
-var UpdateTOC = _('Update Index or Table of Contents');
-var DeleteTOC = _('Delete Index or Table of Contents');
-var ReplyToComment = _('Reply');
-var RecalcPivotTable = _('Refresh');
+// Don't modify, generated using unocommands.py
+
+var unoCommandsArray = {
+    AcceptAllTrackedChanges: _('Accept All'),
+    AcceptTrackedChanges: _('~Manage...'),
+    AnchorMenu: _('Change Anchor'),
+    ArrangeFrameMenu: _('Arrange'),
+    ArrangeMenu: _('A~rrange'),
+    Bold: _('Bold'),
+    BringToFront: _('~Bring to Front'),
+    ChangeCaseRotateCase: _('Cycle Case (Title Case, UPPERCASE, lowercase)'),
+    ChangeCaseToLower: _('~lowercase'),
+    ChangeCaseToSentenceCase: _('~Sentence case'),
+    ChangeCaseToTitleCase: _('~Capitalize Every Word'),
+    ChangeCaseToToggleCase: _('~tOGGLE cASE'),
+    ChangeCaseToUpper: _('~UPPERCASE'),
+    ClearOutline: _('~Remove Outline'),
+    CommonAlignBottom: _('Bottom'),
+    CommonAlignHorizontalCenter: _('Centered'),
+    CommonAlignJustified: _('Justified'),
+    CommonAlignLeft: _('Left'),
+    CommonAlignRight: _('Right'),
+    CommonAlignTop: _('Top'),
+    ContinueNumbering: _('Continue previous numbering'),
+    ControlCodes: _('Formatting Marks'),
+    Copy: _('~Copy'),
+    CopyHyperlinkLocation: _('Copy Link Location'),
+    Cut: _('~Cut'),
+    DecrementIndent: _('Decrease'),
+    DecrementLevel: _('Demote One Level'),
+    DefaultBullet: _('Bullets'),
+    DefaultNumbering: _('Numbering'),
+    DeleteAllNotes: _('Delete All Comments'),
+    DeleteAuthor: _('Delete All Comments by This Author'),
+    DeleteColumns: _('Delete Columns'),
+    DeleteComment: _('Delete Comment'),
+    DeleteRows: _('Delete Rows'),
+    DeleteTable: _('Delete Table'),
+    EditStyle: _('E~dit Style...'),
+    EntireCell: _('Select Cell'),
+    EntireColumn: _('Select Column'),
+    EntireRow: _('Select Rows'),
+    FontDialog: _('Character...'),
+    FormatCellDialog: _('Format ~Cells...'),
+    Group: _('~Group...'),
+    Grow: _('Increase'),
+    HideDetail: _('~Hide Details'),
+    HyperlinkDialog: _('~Link...'),
+    IncrementIndent: _('Increase'),
+    IncrementLevel: _('Promote One Level'),
+    IncrementSubLevels: _('Promote One Level With Subpoints'),
+    InsertColumnBreak: _('Insert ~Column Break'),
+    InsertColumns: _('Insert Co~lumns Left'),
+    InsertColumnsAfter: _('Insert Co~lumns Right'),
+    InsertColumnsBefore: _('Insert Co~lumns Left'),
+    InsertEndnote: _('~Endnote'),
+    InsertFootnote: _('~Footnote'),
+    InsertHardHyphen: _('Non-br~eaking hyphen'),
+    InsertIndexesEntry: _('~Index Entry...'),
+    InsertLRM: _('~Left-to-right mark'),
+    InsertNeutralParagraph: _('Insert Unnumbered Entry'),
+    InsertNonBreakingSpace: _('~Non-breaking space'),
+    InsertRLM: _('~Right-to-left mark'),
+    InsertRows: _('Insert ~Rows Above'),
+    InsertRowsAfter: _('Insert ~Rows Below'),
+    InsertRowsBefore: _('Insert ~Rows Above'),
+    InsertSoftHyphen: _('S~oft hyphen'),
+    InsertZWNBSP: _('No-width no ~break'),
+    InsertZWSP: _('No-~width optional break'),
+    Italic: _('Italic'),
+    JumpDownThisLevel: _('To Next Paragraph in Level'),
+    JumpUpThisLevel: _('To Previous Paragraph in Level'),
+    MergeCells: _('Merge Cells'),
+    MoveDown: _('Move Down'),
+    MoveDownSubItems: _('Move Down with Subpoints'),
+    MoveUp: _('Move Up'),
+    MoveUpSubItems: _('Move Up with Subpoints'),
+    NextTrackedChange: _('Next'),
+    NumberingStart: _('Restart Numbering'),
+    ObjectBackOne: _('Back One'),
+    ObjectForwardOne: _('Forward One'),
+    OpenHyperlinkOnCursor: _('Open Link'),
+    OutlineBullet: _('~Bullets and Numbering...'),
+    OutlineFont: _('Outline'),
+    Overline: _('Overline'),
+    ParaLeftToRight: _('Left-To-Right'),
+    ParaRightToLeft: _('Right-To-Left'),
+    ParagraphDialog: _('P~aragraph...'),
+    ParaspaceDecrease: _('Decrease'),
+    ParaspaceIncrease: _('Increase'),
+    Paste: _('~Paste'),
+    PasteSpecialMenu: _('Paste ~Special'),
+    PasteUnformatted: _('Paste Unformatted Text'),
+    PreviousTrackedChange: _('Pr~evious'),
+    RecalcPivotTable: _('~Refresh Pivot Table'),
+    Redo: _('~Redo'),
+    RejectAllTrackedChanges: _('Reject All'),
+    RemoveHyperlink: _('Remove Link'),
+    RemoveTableOf: _('Delete index'),
+    ReplyComment: _('Reply Comment'),
+    ResetAttributes: _('Clear ~Direct Formatting'),
+    RotateLeft: _('Rotate 90° ~Left'),
+    RotateMenu: _('Rot~ate'),
+    RotateRight: _('Rotate 90° ~Right'),
+    SearchDialog: _('Find & Rep~lace...'),
+    SelectAll: _('Select ~All'),
+    SelectTable: _('Select Table'),
+    SendToBack: _('~Send to Back'),
+    SetAnchorAtChar: _('Anchor to Character'),
+    SetAnchorToChar: _('Anchor as Character'),
+    SetAnchorToFrame: _('Anchor To Frame'),
+    SetAnchorToPage: _('Anchor: To P~age'),
+    SetAnchorToPara: _('Anchor To Paragraph'),
+    SetOptimalColumnWidth: _('~Optimal Column Width...'),
+    Shadowed: _('Shadow'),
+    ShowDetail: _('~Show Details'),
+    ShowTrackedChanges: _('~Show'),
+    Shrink: _('Decrease'),
+    SmallCaps: _('Small capitals'),
+    SpacePara1: _('Line Spacing: 1'),
+    SpacePara15: _('Line Spacing: 1.5'),
+    SpacePara2: _('Line Spacing: 2'),
+    SpellOnline: _('Auto Spellcheck'),
+    SpellingAndGrammarDialog: _('Spelling'),
+    Strikeout: _('Strikethrough'),
+    SubScript: _('Subscript'),
+    SuperScript: _('Superscript'),
+    TableDeleteMenu: _('~Delete'),
+    TableDialog: _('Ta~ble Properties...'),
+    TableInsertMenu: _('~Insert'),
+    TrackChanges: _('~Record'),
+    Underline: _('Underline'),
+    UnderlineDouble: _('Underline: Double'),
+    Undo: _('Undo'),
+    Ungroup: _('~Ungroup...'),
+    UpdateCurIndex: _('Update Index'),
+    WordCountDialog: _('~Word Count'),
+    WrapAnchorOnly: _('Wrap First Paragraph'),
+    WrapContour: _('Wrap Contour On'),
+    WrapIdeal: _('~Optimal Page Wrap'),
+    WrapLeft: _('Wrap Left'),
+    WrapMenu: _('~Wrap'),
+    WrapOff: _('Wrap Off'),
+    WrapOn: _('~Page Wrap'),
+    WrapRight: _('Wrap Right'),
+    WrapThrough: _('~Wrap Through'),
+    WrapThroughTransparent: _('In ~Background'),
+};
+
+global._UNO = function(string) {
+        var text = unoCommandsArray[string.substr(5)];
+        text = text.replace('~', '');
+        return text;
+}
diff --git a/scripts/unocommands.py b/scripts/unocommands.py
index 0a91b348..4f88ceb4 100755
--- a/scripts/unocommands.py
+++ b/scripts/unocommands.py
@@ -1,4 +1,12 @@
 #!/usr/bin/env python
+# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
+#
+# 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/.
+#
 
 import os
 import re
@@ -20,7 +28,7 @@ def commandsFromLine(line):
             inCommand = not inCommand
             # command ended, collect it
             if not inCommand and command != '':
-                commands += [ '.uno:' + command ]
+                commands += [ command ]
                 command = ''
         elif inCommand:
             command += c
@@ -31,7 +39,7 @@ def commandsFromLine(line):
 def commandFromMenuLine(line):
     commands = []
 
-    m = re.search(r"\buno: *'([^']*)'", line)
+    m = re.search(r"\buno: *'\.uno:([^']*)'", line)
     if m:
         commands = [ m.group(1) ]
 
@@ -67,7 +75,7 @@ def extractCommands(path):
 
 # Create mapping between the commands and appropriate strings
 def printCommandsFromXCU(xcu, commands):
-    usedCommands = []
+    descriptions = {}
 
     root = etree.parse(xcu)
     nodes = root.xpath("/oor:component-data/node/node/node", namespaces = {
@@ -76,6 +84,7 @@ def printCommandsFromXCU(xcu, commands):
     for node in nodes:
         # extract the uno command name
         unoCommand = node.get('{http://openoffice.org/2001/registry}name')
+        unoCommand = unoCommand[5:]
 
         if unoCommand in commands:
             textElement = node.xpath('prop[@oor:name="Label"]/value', 
namespaces = {
@@ -85,11 +94,9 @@ def printCommandsFromXCU(xcu, commands):
             if len(textElement) == 1:
                 # extract the uno command's English text
                 text = ''.join(textElement[0].itertext())
-                print ('    ' + unoCommand[5:] + ": _('" + text + 
"'),").encode('utf-8')
+                descriptions[unoCommand] = text
 
-               usedCommands += [ unoCommand ]
-
-    return usedCommands
+    return descriptions
 
 if __name__ == "__main__":
     if len(sys.argv) != 3:
@@ -98,19 +105,32 @@ if __name__ == "__main__":
 
     commands = extractCommands(sys.argv[2])
 
+    # build the uno descriptions from all the xcu files
+    descriptions = {}
+    dir = sys.argv[1] + '/officecfg/registry/data/org/openoffice/Office/UI'
+    for file in os.listdir(dir):
+        if file.endswith(".xcu"):
+            descriptions.update(printCommandsFromXCU(os.path.join(dir, file), 
commands))
+
+    # output the unocommands.js
     print '''// Don't modify, generated using unocommands.py
 
 var unoCommandsArray = {'''
 
-    # try all xcu files
-    usedCommands = []
-    dir = sys.argv[1] + '/officecfg/registry/data/org/openoffice/Office/UI'
-    for file in os.listdir(dir):
-        if file.endswith(".xcu"):
-            usedCommands += printCommandsFromXCU(os.path.join(dir, file), 
commands)
+    for key in sorted(descriptions.keys()):
+        print ('    ' + key + ": _('" + descriptions[key] + 
"'),").encode('utf-8')
 
-    print '};'
+    print '''};
 
-    dif = commands - set(usedCommands)
+global._UNO = function(string) {
+        var text = unoCommandsArray[string.substr(5)];
+        text = text.replace('~', '');
+        return text;
+}'''
+
+    # check that we have translations for everything
+    dif = commands - set(descriptions.keys())
     if len(dif) > 0:
-       sys.stderr.write("ERROR: The following commands are not covered:\n\n" + 
'\n'.join(dif) + "\n")
+        sys.stderr.write("ERROR: The following commands are not 
covered:\n\n.uno:" + '\n.uno:'.join(dif) + "\n")
+
+# vim: set shiftwidth=4 softtabstop=4 expandtab:
commit 99161841dcee3b066153a7f7af0e98d6ef7f8a2c
Author: Jan Holesovsky <[email protected]>
Date:   Wed Dec 6 18:36:14 2017 +0100

    l10n: New script for collecting the used .uno: commands.
    
    Change-Id: I9c6f3f03a4042f8e5ba1f258ce468fc0f4abd169
    Reviewed-on: https://gerrit.libreoffice.org/45981
    Reviewed-by: Andras Timar <[email protected]>
    Tested-by: Andras Timar <[email protected]>

diff --git a/loleaflet/src/control/Control.ContextMenu.js 
b/loleaflet/src/control/Control.ContextMenu.js
index a2e407f5..743c7f3f 100644
--- a/loleaflet/src/control/Control.ContextMenu.js
+++ b/loleaflet/src/control/Control.ContextMenu.js
@@ -10,6 +10,8 @@ L.Control.ContextMenu = L.Control.extend({
                 * Enter UNO commands that should appear in the context menu.
                 * Entering a UNO command under `general' would enable it for 
all types
                 * of documents. If you do not want that, whitelist it in 
document specific filter.
+                *
+                * UNOCOMMANDS_EXTRACT_START <- don't remove this line, it's 
used by unocommands.py
                 */
                whitelist: {
                        /*
@@ -40,6 +42,7 @@ L.Control.ContextMenu = L.Control.extend({
                        presentation: ['EditStyle'],
                        drawing: []
                }
+               // UNOCOMMANDS_EXTRACT_END <- don't remove this line, it's used 
by unocommands.py
        },
 
 
diff --git a/scripts/unocommands.py b/scripts/unocommands.py
new file mode 100755
index 00000000..0a91b348
--- /dev/null
+++ b/scripts/unocommands.py
@@ -0,0 +1,116 @@
+#!/usr/bin/env python
+
+import os
+import re
+import sys
+from lxml import etree
+
+def usage():
+    message = """usage: {program} loffice_srcdir online_srcdir"""
+    print(message.format(program = os.path.basename(sys.argv[0])))
+
+# Extract uno commands name from lines like "  'Command1', 'Command2',"
+def commandsFromLine(line):
+    commands = []
+
+    inCommand = False
+    command = ''
+    for c in line:
+        if c == "'":
+            inCommand = not inCommand
+            # command ended, collect it
+            if not inCommand and command != '':
+                commands += [ '.uno:' + command ]
+                command = ''
+        elif inCommand:
+            command += c
+
+    return commands
+
+# Extract uno commands name from lines like "  type: 'unocommand', uno: 
'.uno:Command3',"
+def commandFromMenuLine(line):
+    commands = []
+
+    m = re.search(r"\buno: *'([^']*)'", line)
+    if m:
+        commands = [ m.group(1) ]
+
+    return commands
+
+# Extract all the uno commands we are using in the Online
+def extractCommands(path):
+    commands = []
+
+    #files = { path + '/loleaflet/src/control/Control.ContextMenu.js',
+    #    path + '/loleaflet/src/control/Control.Menubar.js'
+    #}
+
+    # extract from the comments whitelist
+    f = open(path + '/loleaflet/src/control/Control.ContextMenu.js', 'r')
+    readingCommands = False
+    for line in f:
+        if line.find('UNOCOMMANDS_EXTRACT_START') >= 0:
+            readingCommands = True
+        elif line.find('UNOCOMMANDS_EXTRACT_END') >= 0:
+            readingCommands = False
+        elif readingCommands:
+            commands += commandsFromLine(line)
+
+    # extract from the menu specifications
+    f = open(path + '/loleaflet/src/control/Control.Menubar.js', 'r')
+    for line in f:
+        if line.find("'unocommand'") >= 0:
+            commands += commandFromMenuLine(line)
+
+    # may the list unique
+    return set(commands)
+
+# Create mapping between the commands and appropriate strings
+def printCommandsFromXCU(xcu, commands):
+    usedCommands = []
+
+    root = etree.parse(xcu)
+    nodes = root.xpath("/oor:component-data/node/node/node", namespaces = {
+        'oor': 'http://openoffice.org/2001/registry',
+        })
+    for node in nodes:
+        # extract the uno command name
+        unoCommand = node.get('{http://openoffice.org/2001/registry}name')
+
+        if unoCommand in commands:
+            textElement = node.xpath('prop[@oor:name="Label"]/value', 
namespaces = {
+                'oor': 'http://openoffice.org/2001/registry',
+                })
+
+            if len(textElement) == 1:
+                # extract the uno command's English text
+                text = ''.join(textElement[0].itertext())
+                print ('    ' + unoCommand[5:] + ": _('" + text + 
"'),").encode('utf-8')
+
+               usedCommands += [ unoCommand ]
+
+    return usedCommands
+
+if __name__ == "__main__":
+    if len(sys.argv) != 3:
+        usage()
+        exit(1)
+
+    commands = extractCommands(sys.argv[2])
+
+    print '''// Don't modify, generated using unocommands.py
+
+var unoCommandsArray = {'''
+
+    # try all xcu files
+    usedCommands = []
+    dir = sys.argv[1] + '/officecfg/registry/data/org/openoffice/Office/UI'
+    for file in os.listdir(dir):
+        if file.endswith(".xcu"):
+            usedCommands += printCommandsFromXCU(os.path.join(dir, file), 
commands)
+
+    print '};'
+
+    dif = commands - set(usedCommands)
+    if len(dif) > 0:
+       sys.stderr.write("ERROR: The following commands are not covered:\n\n" + 
'\n'.join(dif) + "\n")
_______________________________________________
Libreoffice-commits mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to