Grammalecte  Diff

Differences From Artifact [fbd244567c]:

To Artifact [ab6e7468d1]:


1
2
3
4
5
6
7

8
9
10
11
12
13
14
15
16













17
18
19
20
21
22
23
# Search
# by Olivier R.
# License: MPL 2

import unohelper
import uno
import traceback


import helpers
import sw_strings
import grammalecte.graphspell as sc
import grammalecte.graphspell.ibdawg as ibdawg

from com.sun.star.task import XJobExecutor
from com.sun.star.awt import XActionListener















def _waitPointer (funcDecorated):
    def wrapper (*args, **kwargs):
        # self is the first parameter if the decorator is applied on a object
        self = args[0]
        # before
        xPointer = self.xSvMgr.createInstanceWithContext("com.sun.star.awt.Pointer", self.ctx)







>









>
>
>
>
>
>
>
>
>
>
>
>
>







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
# Search
# by Olivier R.
# License: MPL 2

import unohelper
import uno
import traceback
import re

import helpers
import sw_strings
import grammalecte.graphspell as sc
import grammalecte.graphspell.ibdawg as ibdawg

from com.sun.star.task import XJobExecutor
from com.sun.star.awt import XActionListener


from com.sun.star.awt.MessageBoxButtons import BUTTONS_OK
# BUTTONS_OK, BUTTONS_OK_CANCEL, BUTTONS_YES_NO, BUTTONS_YES_NO_CANCEL, BUTTONS_RETRY_CANCEL, BUTTONS_ABORT_IGNORE_RETRY
# DEFAULT_BUTTON_OK, DEFAULT_BUTTON_CANCEL, DEFAULT_BUTTON_RETRY, DEFAULT_BUTTON_YES, DEFAULT_BUTTON_NO, DEFAULT_BUTTON_IGNORE
from com.sun.star.awt.MessageBoxType import INFOBOX, ERRORBOX # MESSAGEBOX, INFOBOX, WARNINGBOX, ERRORBOX, QUERYBOX

def MessageBox (xDocument, sMsg, sTitle, nBoxType=INFOBOX, nBoxButtons=BUTTONS_OK):
    xParentWin = xDocument.CurrentController.Frame.ContainerWindow
    ctx = uno.getComponentContext()
    xToolkit = ctx.ServiceManager.createInstanceWithContext("com.sun.star.awt.Toolkit", ctx) 
    xMsgBox = xToolkit.createMessageBox(xParentWin, nBoxType, nBoxButtons, sTitle, sMsg)
    return xMsgBox.execute()


def _waitPointer (funcDecorated):
    def wrapper (*args, **kwargs):
        # self is the first parameter if the decorator is applied on a object
        self = args[0]
        # before
        xPointer = self.xSvMgr.createInstanceWithContext("com.sun.star.awt.Pointer", self.ctx)
186
187
188
189
190
191
192










193
194
195
196
197
198
199
                xGridDataModel.addRow(i, aEntry)

    @_waitPointer
    def searchRegex (self):
        self.initSpellChecker()
        sFlexPattern = self.xFlexion.Text.strip()
        sTagsPattern = self.xTags.Text.strip()










        xGridDataModel = self.xGridModel.GridDataModel
        xGridDataModel.removeAllRows()
        for i, aEntry in enumerate(self.oSpellChecker.select(sFlexPattern, sTagsPattern)):
            xGridDataModel.addRow(i, aEntry)
            i += 1
            if i >= 2000:
                break







>
>
>
>
>
>
>
>
>
>







200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
                xGridDataModel.addRow(i, aEntry)

    @_waitPointer
    def searchRegex (self):
        self.initSpellChecker()
        sFlexPattern = self.xFlexion.Text.strip()
        sTagsPattern = self.xTags.Text.strip()
        try:
            if sFlexPattern:
                re.compile(sFlexPattern)
        except:
            MessageBox(self.xDocument, self.dUI.get("regex_error_flexion", "#err"), self.dUI.get("error", "#err"), nBoxType=ERRORBOX)
        try:
            if sTagsPattern:
                re.compile(sTagsPattern)
        except:
            MessageBox(self.xDocument, self.dUI.get("regex_error_tags", "#err"), self.dUI.get("error", "#err"), nBoxType=ERRORBOX)
        xGridDataModel = self.xGridModel.GridDataModel
        xGridDataModel.removeAllRows()
        for i, aEntry in enumerate(self.oSpellChecker.select(sFlexPattern, sTagsPattern)):
            xGridDataModel.addRow(i, aEntry)
            i += 1
            if i >= 2000:
                break