Overview
| Comment: | [lo] Enumerator: use tokenizer of Grammalecte instead of LO <gotoNextWord> | 
|---|---|
| Downloads: | Tarball | ZIP archive | SQL archive | 
| Timelines: | family | ancestors | descendants | both | trunk | lo | 
| Files: | files | file ages | folders | 
| SHA3-256: | 
6c8016e88a3561bf6b9ea2e42b2eb7f7 | 
| User & Date: | olr on 2018-02-24 09:47:24 | 
| Other Links: | manifest | tags | 
Context
| 
   2018-02-24 
 | ||
| 10:25 | [lo] Enumerator: tag several words at once check-in: 8e05358b14 user: olr tags: trunk, lo | |
| 09:47 | [lo] Enumerator: use tokenizer of Grammalecte instead of LO <gotoNextWord> check-in: 6c8016e88a user: olr tags: trunk, lo | |
| 08:20 | [graphspell] spellchecker: new function getTokenizer() check-in: aae2892638 user: olr tags: trunk, graphspell | |
Changes
Modified gc_lang/fr/oxt/Lexicographer/Enumerator.py from [fb0c4a2aa0] to [40df986240].
| ︙ | ︙ | |||
52 53 54 55 56 57 58 59 60 61 62 63 64 65  | 
        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
 | >  | 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66  | 
        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
        self.oTokenizer = 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
 | 
| ︙ | ︙ | |||
263 264 265 266 267 268 269 270  | 
    @_waitPointer
    def tagText (self, sWord, sAction=""):
        if not sAction:
            return
        self.xProgressBar.ProgressValueMax = self._countParagraph()
        self.xProgressBar.ProgressValue = 0
        xCursor = self.xDocument.Text.createTextCursor()
 | > > < < < < | < < < < | < | > > > > | | | | | | | | | | | | | >  | 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303  | 
    @_waitPointer
    def tagText (self, sWord, sAction=""):
        if not sAction:
            return
        self.xProgressBar.ProgressValueMax = self._countParagraph()
        self.xProgressBar.ProgressValue = 0
        if not self.oTokenizer:
            self.oTokenizer = self.oSpellChecker.getTokenizer()
        xCursor = self.xDocument.Text.createTextCursor()
        xCursor.gotoStart(False)
        self._tagParagraph(xCursor, sWord, sAction)
        while xCursor.gotoNextParagraph(False):
            self._tagParagraph(xCursor, sWord, sAction)
        self.xProgressBar.ProgressValue = self.xProgressBar.ProgressValueMax
    def _tagParagraph (self, xCursor, sWord, sAction):
        xCursor.gotoEndOfParagraph(True)
        sParagraph = xCursor.getString()
        xCursor.gotoStartOfParagraph(False)
        nPos = 0
        for dToken in self.oTokenizer.genTokens(sParagraph):
            if dToken["sValue"] == sWord:
                xCursor.goRight(dToken["nStart"]-nPos, False) # start of token
                nPos = dToken["nEnd"]
                xCursor.goRight(nPos-dToken["nStart"], True) # end of token
                if sAction == "underline":
                    xCursor.CharBackColor = hexToRBG("AA0000")
                elif sAction == "nounderline":
                    xCursor.CharBackColor = hexToRBG("FFFFFF")
                elif sAction == "accentuation":
                    xCursor.CharStyleName = "Emphasis"
                elif sAction == "noaccentuation":
                    #xCursor.CharStyleName = "Default Style"     # doesn’t work
                    xCursor.setPropertyToDefault("CharStyleName")
        self.xProgressBar.ProgressValue += 1
#g_ImplementationHelper = unohelper.ImplementationHelper()
#g_ImplementationHelper.addImplementation(Enumerator, 'net.grammalecte.enumerator', ('com.sun.star.task.Job',))
 |