Overview
| Comment: | [lo] New feature: enumerator |
|---|---|
| Downloads: | Tarball | ZIP archive | SQL archive |
| Timelines: | family | ancestors | descendants | both | trunk | new_feature | lo |
| Files: | files | file ages | folders |
| SHA3-256: |
860712215716c3aa45eb79013fb25aa6 |
| User & Date: | olr on 2018-02-21 19:16:47 |
| Other Links: | manifest | tags |
Context
|
2018-02-22
| ||
| 06:41 | [lo] update the enumerator check-in: ff502ce05c user: olr tags: trunk, lo | |
|
2018-02-21
| ||
| 19:16 | [lo] New feature: enumerator check-in: 8607122157 user: olr tags: trunk, new_feature, lo | |
| 19:14 | [graphspell][py] defaut module import check-in: 31837970bd user: olr tags: trunk, graphspell | |
Changes
Modified gc_lang/fr/config.ini from [e2c23eef6d] to [93df40f5c3].
| ︙ | ︙ | |||
88 89 90 91 92 93 94 95 96 97 98 99 | oxt/ContextMenu/ContextMenu.py = ContextMenu.py oxt/ContextMenu/jobs.xcu = config/jobs.xcu # TextFormatter oxt/TextFormatter/TextFormatter.py = pythonpath/TextFormatter.py oxt/TextFormatter/tf_strings.py = pythonpath/tf_strings.py oxt/TextFormatter/tf_options.py = pythonpath/tf_options.py oxt/TextFormatter/tf_tabrep.py = pythonpath/tf_tabrep.py # Conjugueur oxt/Conjugueur/Conjugueur.py = pythonpath/Conjugueur.py # Modify author oxt/ChangeAuthor/Author.py = pythonpath/Author.py oxt/ChangeAuthor/ca_strings.py = pythonpath/ca_strings.py | > > > | 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | oxt/ContextMenu/ContextMenu.py = ContextMenu.py oxt/ContextMenu/jobs.xcu = config/jobs.xcu # TextFormatter oxt/TextFormatter/TextFormatter.py = pythonpath/TextFormatter.py oxt/TextFormatter/tf_strings.py = pythonpath/tf_strings.py oxt/TextFormatter/tf_options.py = pythonpath/tf_options.py oxt/TextFormatter/tf_tabrep.py = pythonpath/tf_tabrep.py # Lexicographer oxt/Lexicographer/Enumerator.py = pythonpath/Enumerator.py oxt/Lexicographer/enum_strings.py = pythonpath/enum_strings.py # Conjugueur oxt/Conjugueur/Conjugueur.py = pythonpath/Conjugueur.py # Modify author oxt/ChangeAuthor/Author.py = pythonpath/Author.py oxt/ChangeAuthor/ca_strings.py = pythonpath/ca_strings.py |
Modified gc_lang/fr/oxt/AppLauncher.py from [30bcae4623] to [f6fd0dec5a].
| ︙ | ︙ | |||
50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
import Author
xDialog = Author.Author(self.ctx)
xDialog.run(self.sLang)
elif sCmd == "OP":
import Options
xDialog = Options.GC_Options(self.ctx)
xDialog.run(self.sLang)
elif sCmd.startswith("FA/"):
findAll(sCmd[6:], (sCmd[3:4] == "y"), (sCmd[4:5] == "y"))
# elif sCmd.startswith("URL/"):
# # Call from context menu to launch URL?
# # http://opengrok.libreoffice.org/xref/core/sw/source/ui/lingu/olmenu.cxx#785
# xSystemShellExecute = self.ctx.getServiceManager().createInstanceWithContext('com.sun.star.system.SystemShellExecute', self.ctx)
# xSystemShellExecute.execute(url, "", uno.getConstantByName("com.sun.star.system.SystemShellExecuteFlags.URIS_ONLY"))
| > > > > | 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
import Author
xDialog = Author.Author(self.ctx)
xDialog.run(self.sLang)
elif sCmd == "OP":
import Options
xDialog = Options.GC_Options(self.ctx)
xDialog.run(self.sLang)
elif sCmd == "EN":
import Enumerator
xDialog = Enumerator.Enumerator(self.ctx)
xDialog.run(self.sLang)
elif sCmd.startswith("FA/"):
findAll(sCmd[6:], (sCmd[3:4] == "y"), (sCmd[4:5] == "y"))
# elif sCmd.startswith("URL/"):
# # Call from context menu to launch URL?
# # http://opengrok.libreoffice.org/xref/core/sw/source/ui/lingu/olmenu.cxx#785
# xSystemShellExecute = self.ctx.getServiceManager().createInstanceWithContext('com.sun.star.system.SystemShellExecute', self.ctx)
# xSystemShellExecute.execute(url, "", uno.getConstantByName("com.sun.star.system.SystemShellExecuteFlags.URIS_ONLY"))
|
| ︙ | ︙ |
Added gc_lang/fr/oxt/Lexicographer/Enumerator.py version [96cb003561].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 |
# Dictionary Options
# by Olivier R.
# License: MPL 2
import unohelper
import uno
import traceback
import time
import helpers
import enum_strings
import grammalecte.graphspell as sc
from com.sun.star.task import XJobExecutor
from com.sun.star.awt import XActionListener
from com.sun.star.beans import PropertyValue
class Enumerator (unohelper.Base, XActionListener, XJobExecutor):
def __init__ (self, ctx):
self.ctx = ctx
self.xSvMgr = self.ctx.ServiceManager
self.xDesktop = self.xSvMgr.createInstanceWithContext("com.sun.star.frame.Desktop", self.ctx)
self.xDocument = self.xDesktop.getCurrentComponent()
self.xContainer = None
self.xDialog = None
self.oSpellChecker = None
def _addWidget (self, name, wtype, x, y, w, h, **kwargs):
xWidget = self.xDialog.createInstance('com.sun.star.awt.UnoControl%sModel' % wtype)
xWidget.Name = name
xWidget.PositionX = x
xWidget.PositionY = y
xWidget.Width = w
xWidget.Height = h
for k, w in kwargs.items():
setattr(xWidget, k, w)
self.xDialog.insertByName(name, xWidget)
return xWidget
def _addGrid (self, name, x, y, w, h, columns, **kwargs):
xGridModel = self.xDialog.createInstance('com.sun.star.awt.grid.UnoControlGridModel')
xGridModel.Name = name
xGridModel.PositionX = x
xGridModel.PositionY = y
xGridModel.Width = w
xGridModel.Height = h
xColumnModel = xGridModel.ColumnModel
for e in columns:
xCol = xColumnModel.createColumn()
for k, w in e.items():
setattr(xCol, k, w)
xColumnModel.addColumn(xCol)
for k, w in kwargs.items():
setattr(xGridModel, k, w)
self.xDialog.insertByName(name, xGridModel)
return xGridModel
def run (self, sLang):
dUI = enum_strings.getUI(sLang)
# dialog
self.xDialog = self.xSvMgr.createInstanceWithContext('com.sun.star.awt.UnoControlDialogModel', self.ctx)
self.xDialog.Width = 240
self.xDialog.Height = 280
self.xDialog.Title = dUI.get('title', "#title#")
xWindowSize = helpers.getWindowSize()
self.xDialog.PositionX = int((xWindowSize.Width / 2) - (self.xDialog.Width / 2))
self.xDialog.PositionY = int((xWindowSize.Height / 2) - (self.xDialog.Height / 2))
# fonts
xFDTitle = uno.createUnoStruct("com.sun.star.awt.FontDescriptor")
xFDTitle.Height = 9
xFDTitle.Weight = uno.getConstantByName("com.sun.star.awt.FontWeight.BOLD")
xFDTitle.Name = "Verdana"
xFDSubTitle = uno.createUnoStruct("com.sun.star.awt.FontDescriptor")
xFDSubTitle.Height = 8
xFDSubTitle.Weight = uno.getConstantByName("com.sun.star.awt.FontWeight.BOLD")
xFDSubTitle.Name = "Verdana"
# widget
nX = 10
nY1 = 10
nY2 = nY1 + 225
nWidth = self.xDialog.Width - 20
nHeight = 10
# List
self._addWidget("list_section", 'FixedLine', nX, nY1, nWidth, nHeight, Label = dUI.get("list_section", "#err"), FontDescriptor = xFDTitle)
self._addWidget('count_button', 'Button', nX, nY1+12, 70, 10, Label = dUI.get('count_button', "#err"))
self._addWidget('count2_button', 'Button', nX+75, nY1+12, 70, 10, Label = dUI.get('count2_button', "#err"))
self._addWidget('unknown_button', 'Button', nX+150, nY1+12, 70, 10, Label = dUI.get('unknown_button', "#err"))
self.xGridModel = self._addGrid("list_grid", nX, nY1+25, nWidth, 180, [
{"Title": "Mot", "ColumnWidth": 180},
{"Title": "Occur.", "ColumnWidth": 40}
])
self._addWidget('num_of_words', 'FixedText', nX, nY1+210, 60, nHeight, Label = dUI.get('num_of_words', "#err"), Align = 2)
self.xNumWord = self._addWidget('num_of_words_res', 'FixedText', nX+65, nY1+210, 30, nHeight, Label = "—")
self._addWidget('tot_of_words', 'FixedText', nX+100, nY1+210, 60, nHeight, Label = dUI.get('tot_of_words', "#err"), Align = 2)
self.xTotWord = self._addWidget('total_words_res', 'FixedText', nX+165, nY1+210, 30, nHeight, Label = "—")
# Tag
self._addWidget("tag_section", 'FixedLine', nX, nY2, nWidth, nHeight, Label = dUI.get("tag_section", "#err"), FontDescriptor = xFDTitle)
self._addWidget('tag_button', 'Button', nX, self.xDialog.Height-25, 50, 14, Label = dUI.get('tag_button', "#err"), FontDescriptor = xFDTitle, TextColor = 0x000000)
# Close
self._addWidget('close_button', 'Button', self.xDialog.Width-60, self.xDialog.Height-25, 50, 14, Label = dUI.get('close_button', "#err"), FontDescriptor = xFDTitle, TextColor = 0x550000)
# container
self.xContainer = self.xSvMgr.createInstanceWithContext('com.sun.star.awt.UnoControlDialog', self.ctx)
self.xContainer.setModel(self.xDialog)
self.xContainer.getControl('count_button').addActionListener(self)
self.xContainer.getControl('count_button').setActionCommand('Count')
self.xContainer.getControl('count2_button').addActionListener(self)
self.xContainer.getControl('count2_button').setActionCommand('CountByLemma')
self.xContainer.getControl('unknown_button').addActionListener(self)
self.xContainer.getControl('unknown_button').setActionCommand('UnknownWords')
self.xContainer.getControl('tag_button').addActionListener(self)
self.xContainer.getControl('tag_button').setActionCommand('Tag')
self.xContainer.getControl('close_button').addActionListener(self)
self.xContainer.getControl('close_button').setActionCommand('Close')
self.xContainer.setVisible(False)
toolkit = self.xSvMgr.createInstanceWithContext('com.sun.star.awt.ExtToolkit', self.ctx)
self.xContainer.createPeer(toolkit, None)
self.xContainer.execute()
# XActionListener
def actionPerformed (self, xActionEvent):
try:
if xActionEvent.ActionCommand == "Count":
self.count()
elif xActionEvent.ActionCommand == "CountByLemma":
self.count(bByLemma=True)
elif xActionEvent.ActionCommand == "UnknownWords":
self.count(bOnlyUnknownWords=True)
elif xActionEvent.ActionCommand == "Tag":
pass
elif xActionEvent.ActionCommand == "Close":
self.xContainer.endExecute()
except:
traceback.print_exc()
# XJobExecutor
def trigger (self, args):
try:
xDialog = Enumerator(self.ctx)
xDialog.run()
except:
traceback.print_exc()
# Code
def getParagraphsOfText (self):
"generator: returns full document text paragraph by paragraph"
xCursor = self.xDocument.Text.createTextCursor()
xCursor.gotoStart(False)
xCursor.gotoEndOfParagraph(True)
yield xCursor.getString()
while xCursor.gotoNextParagraph(False):
xCursor.gotoEndOfParagraph(True)
yield xCursor.getString()
def count (self, bByLemma=False, bOnlyUnknownWords=False):
# change pointer
xPointer = self.xSvMgr.createInstanceWithContext("com.sun.star.awt.Pointer", self.ctx)
xPointer.setType(uno.getConstantByName("com.sun.star.awt.SystemPointer.WAIT"))
xWindowPeer = self.xContainer.getPeer()
xWindowPeer.setPointer(xPointer)
for x in xWindowPeer.Windows:
x.setPointer(xPointer)
# processing
if not self.oSpellChecker:
self.oSpellChecker = sc.SpellChecker("fr")
xGridDataModel = self.xGridModel.GridDataModel
xGridDataModel.removeAllRows()
dWord = {}
for sParagraph in self.getParagraphsOfText():
dWord = self.oSpellChecker.countWordsOccurrences(sParagraph, bByLemma, bOnlyUnknownWords, dWord)
i = 0
nTotOccur = 0
for k, w in sorted(dWord.items(), key=lambda t: t[1], reverse=True):
xGridDataModel.addRow(i, (k, w))
i += 1
nTotOccur += w
self.xNumWord.Label = str(i)
self.xTotWord.Label = str(nTotOccur)
# end of processing
xPointer.setType(uno.getConstantByName("com.sun.star.awt.SystemPointer.ARROW"))
xWindowPeer.setPointer(xPointer)
for x in xWindowPeer.Windows:
x.setPointer(xPointer)
self.xContainer.setVisible(True) # seems necessary to refresh the dialog box and text widgets (why?)
#g_ImplementationHelper = unohelper.ImplementationHelper()
#g_ImplementationHelper.addImplementation(Enumerator, 'net.grammalecte.enumerator', ('com.sun.star.task.Job',))
|
Added gc_lang/fr/oxt/Lexicographer/enum_strings.py version [9bc4695a29].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
def getUI (sLang):
if sLang in dStrings:
return dStrings[sLang]
return dStrings["fr"]
dStrings = {
"fr": {
"title": "Grammalecte · Recenseur",
"list_section": "Calcul des occurrences des mots",
"count_button": "Compter tout",
"count2_button": "Compter par lemme",
"unknown_button": "Mots inconnus",
"num_of_words": "Nombre de mots :",
"tot_of_words": "Total des mots :",
"tag_section": "Formatage",
"tag": "Taguer",
"close_button": "Fermer",
},
"en": {
"title": "Grammalecte · Enumerator",
"list_section": "Words",
"count_button": "Count all",
"count2_button": "Count by lemma",
"unknown_button": "Unknown words",
"num_of_words": "Number of words:",
"tot_of_words": "Total of words:",
"tag_section": "Format",
"tag": "Tag",
"close_button": "Close",
},
}
|
Modified gc_lang/fr/oxt/addons.xcu from [1d834d2bae] to [4bcce6ed7d].
| ︙ | ︙ | |||
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
<value>_self</value>
</prop>
<prop oor:name="Context" oor:type="xs:string">
<value>com.sun.star.text.TextDocument,com.sun.star.text.GlobalDocument,com.sun.star.text.WebDocument,com.sun.star.presentation.PresentationDocument</value>
</prop>
</node>
<node oor:name="m3" oor:op="replace">
<!--<prop oor:name="URL" oor:type="xs:string">
<value>vnd.sun.star.script:basiclib.Module1.EditAuthorField?language=Basic&location=application</value>
</prop>-->
<prop oor:name="URL" oor:type="xs:string">
<value>service:net.grammalecte.AppLauncher?MA</value>
</prop>
<prop oor:name="Title" oor:type="xs:string">
<value/>
<value xml:lang="fr">~Modifier le champ “Auteur”…</value>
<value xml:lang="en-US">~Modify the field “Author”…</value>
</prop>
<prop oor:name="Target" oor:type="xs:string">
<value>_self</value>
</prop>
<prop oor:name="Context" oor:type="xs:string">
<value>com.sun.star.text.TextDocument,com.sun.star.text.GlobalDocument,com.sun.star.text.WebDocument</value>
</prop>
</node>
| > > > > > > > > > > > > > > > > | | | 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
<value>_self</value>
</prop>
<prop oor:name="Context" oor:type="xs:string">
<value>com.sun.star.text.TextDocument,com.sun.star.text.GlobalDocument,com.sun.star.text.WebDocument,com.sun.star.presentation.PresentationDocument</value>
</prop>
</node>
<node oor:name="m3" oor:op="replace">
<prop oor:name="URL" oor:type="xs:string">
<value>service:net.grammalecte.AppLauncher?EN</value>
</prop>
<prop oor:name="Title" oor:type="xs:string">
<value/>
<value xml:lang="fr">~Recenseur…</value>
<value xml:lang="en-US">~Enumerator…</value>
</prop>
<prop oor:name="Target" oor:type="xs:string">
<value>_self</value>
</prop>
<prop oor:name="Context" oor:type="xs:string">
<value>com.sun.star.text.TextDocument,com.sun.star.text.GlobalDocument,com.sun.star.text.WebDocument,com.sun.star.presentation.PresentationDocument</value>
</prop>
</node>
<node oor:name="m4" oor:op="replace">
<!--<prop oor:name="URL" oor:type="xs:string">
<value>vnd.sun.star.script:basiclib.Module1.EditAuthorField?language=Basic&location=application</value>
</prop>-->
<prop oor:name="URL" oor:type="xs:string">
<value>service:net.grammalecte.AppLauncher?MA</value>
</prop>
<prop oor:name="Title" oor:type="xs:string">
<value/>
<value xml:lang="fr">~Modifier le champ “Auteur”…</value>
<value xml:lang="en-US">~Modify the field “Author”…</value>
</prop>
<prop oor:name="Target" oor:type="xs:string">
<value>_self</value>
</prop>
<prop oor:name="Context" oor:type="xs:string">
<value>com.sun.star.text.TextDocument,com.sun.star.text.GlobalDocument,com.sun.star.text.WebDocument</value>
</prop>
</node>
<node oor:name="m5" oor:op="replace">
<prop oor:name="URL" oor:type="xs:string">
<value>private:separator</value>
</prop>
<prop oor:name="Context" oor:type="xs:string">
<value>com.sun.star.text.TextDocument,com.sun.star.text.GlobalDocument,com.sun.star.text.WebDocument,com.sun.star.presentation.PresentationDocument</value>
</prop>
</node>
<node oor:name="m6" oor:op="replace">
<prop oor:name="URL" oor:type="xs:string">
<value>service:net.grammalecte.AppLauncher?OP</value>
</prop>
<!--<prop oor:name="URL" oor:type="xs:string">
<value>.uno:OptionsTreeDialog?OptionsPageURL:string=%origin%/dialog/fr.xdl</value>
</prop>-->
<prop oor:name="Title" oor:type="xs:string">
|
| ︙ | ︙ | |||
115 116 117 118 119 120 121 |
<prop oor:name="Context" oor:type="xs:string">
<value>com.sun.star.text.TextDocument,com.sun.star.text.GlobalDocument,com.sun.star.text.WebDocument</value>
</prop>
<prop oor:name="ImageIdentifier" oor:type="xs:string">
<value>org.dicollecte.images:Grammalecte</value>
</prop>
</node>
| | | | | 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
<prop oor:name="Context" oor:type="xs:string">
<value>com.sun.star.text.TextDocument,com.sun.star.text.GlobalDocument,com.sun.star.text.WebDocument</value>
</prop>
<prop oor:name="ImageIdentifier" oor:type="xs:string">
<value>org.dicollecte.images:Grammalecte</value>
</prop>
</node>
<node oor:name="m7" oor:op="replace">
<prop oor:name="URL" oor:type="xs:string">
<value>service:net.grammalecte.AppLauncher?DS</value>
</prop>
<prop oor:name="Title" oor:type="xs:string">
<value/>
<value xml:lang="fr">~Options orthographiques…</value>
<value xml:lang="en-US">Spelling ~options…</value>
</prop>
<prop oor:name="Target" oor:type="xs:string">
<value>_self</value>
</prop>
<prop oor:name="Context" oor:type="xs:string">
<value>com.sun.star.text.TextDocument,com.sun.star.text.GlobalDocument,com.sun.star.text.WebDocument,com.sun.star.presentation.PresentationDocument</value>
</prop>
<prop oor:name="ImageIdentifier" oor:type="xs:string">
<value>org.dicollecte.images:Frenchflag</value>
</prop>
</node>
<node oor:name="m8" oor:op="replace">
<prop oor:name="URL" oor:type="xs:string">
<value>private:separator</value>
</prop>
<prop oor:name="Context" oor:type="xs:string">
<value>com.sun.star.text.TextDocument,com.sun.star.text.GlobalDocument,com.sun.star.text.WebDocument,com.sun.star.presentation.PresentationDocument</value>
</prop>
</node>
<node oor:name="m9" oor:op="replace">
<prop oor:name="URL" oor:type="xs:string">
<value>service:net.grammalecte.AppLauncher?About</value>
</prop>
<prop oor:name="Title" oor:type="xs:string">
<value/>
<value xml:lang="fr">À ~propos de Grammalecte…</value>
<value xml:lang="en-US">~About Grammalecte…</value>
|
| ︙ | ︙ |