Grammalecte  Check-in [6a5d9d3cff]

Overview
Comment:[lo] option to launch Python console at start
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | lo
Files: files | file ages | folders
SHA3-256: 6a5d9d3cff555a35b06280a14e3e549c73ea2708d555802a05c8202ac4502e35
User & Date: olr on 2019-07-13 06:25:29
Other Links: manifest | tags
Context
2019-07-13
12:51
[fr] confusion tâche/tache check-in: ecc24d681f user: olr tags: trunk, fr
06:25
[lo] option to launch Python console at start check-in: 6a5d9d3cff user: olr tags: trunk, lo
2019-07-12
17:40
[lo] update helpers check-in: cec1932c20 user: olr tags: trunk, lo
Changes

Modified gc_core/py/oxt/Grammalecte.py from [f43a616444] to [3e7e733b85].

28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
        self.ImplementationName = "org.openoffice.comp.pyuno.Lightproof." + gce.pkg
        self.SupportedServiceNames = (self.ServiceName, )
        self.locales = []
        for i in gce.locales:
            l = gce.locales[i]
            self.locales.append(Locale(l[0], l[1], l[2]))
        self.locales = tuple(self.locales)
        xCurCtx = uno.getComponentContext()
        # init
        gce.load("Writer", "nInt")
        # GC options
        # opt_handler.load(xCurCtx)
        dOpt = Options.load(xCurCtx)
        gce.setOptions(dOpt)
        # dictionaries options
        self.loadUserDictionaries()
        # underlining options
        self.setWriterUnderliningStyle()
        # store for results of big paragraphs
        self.dResult = {}







|



|
|







28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
        self.ImplementationName = "org.openoffice.comp.pyuno.Lightproof." + gce.pkg
        self.SupportedServiceNames = (self.ServiceName, )
        self.locales = []
        for i in gce.locales:
            l = gce.locales[i]
            self.locales.append(Locale(l[0], l[1], l[2]))
        self.locales = tuple(self.locales)
        xContext = uno.getComponentContext()
        # init
        gce.load("Writer", "nInt")
        # GC options
        # opt_handler.load(xContext)
        dOpt = Options.load(xContext)
        gce.setOptions(dOpt)
        # dictionaries options
        self.loadUserDictionaries()
        # underlining options
        self.setWriterUnderliningStyle()
        # store for results of big paragraphs
        self.dResult = {}

Modified gc_core/py/oxt/OptionsDialog.xcs from [72f0992f92] to [22cc8bb99e].

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
    <info>
        <desc>Contains the options data used for the extension.</desc>
    </info>

    <templates>
        <group oor:name="${lang}">
            <info>
                <desc>The data for one leaf.</desc>
            </info>
            ${xcs_options}
        </group>

        <group oor:name="o_${lang}">
            <info>
                <desc>The data for one leaf.</desc>
            </info>
            <!-- spelling options -->
            <prop oor:name="use_graphspell" oor:type="xs:int"><value>1</value></prop>
            <prop oor:name="use_graphspell_sugg" oor:type="xs:int"><value>1</value></prop>
            <prop oor:name="use_community_dic" oor:type="xs:int"><value>0</value></prop>
            <prop oor:name="use_personal_dic" oor:type="xs:int"><value>1</value></prop>
            <prop oor:name="main_dic_name" oor:type="xs:string"><value>classic</value></prop>
            <prop oor:name="community_dic" oor:type="xs:string"><value></value></prop>
            <prop oor:name="personal_dic" oor:type="xs:string"><value></value></prop>
            <!-- graphic options -->
            <prop oor:name="line_multicolor" oor:type="xs:int"><value>1</value></prop>
            <prop oor:name="line_type" oor:type="xs:string"><value>BOLDWAVE</value></prop>


        </group>
    </templates>

    <component>
        <group oor:name="Leaves">
            <node-ref oor:name="${lang}" oor:node-type="${lang}" />
        </group>







|






|












>
>







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
    <info>
        <desc>Contains the options data used for the extension.</desc>
    </info>

    <templates>
        <group oor:name="${lang}">
            <info>
                <desc>Grammar options for language ${lang}.</desc>
            </info>
            ${xcs_options}
        </group>

        <group oor:name="o_${lang}">
            <info>
                <desc>Other options for language ${lang}.</desc>
            </info>
            <!-- spelling options -->
            <prop oor:name="use_graphspell" oor:type="xs:int"><value>1</value></prop>
            <prop oor:name="use_graphspell_sugg" oor:type="xs:int"><value>1</value></prop>
            <prop oor:name="use_community_dic" oor:type="xs:int"><value>0</value></prop>
            <prop oor:name="use_personal_dic" oor:type="xs:int"><value>1</value></prop>
            <prop oor:name="main_dic_name" oor:type="xs:string"><value>classic</value></prop>
            <prop oor:name="community_dic" oor:type="xs:string"><value></value></prop>
            <prop oor:name="personal_dic" oor:type="xs:string"><value></value></prop>
            <!-- graphic options -->
            <prop oor:name="line_multicolor" oor:type="xs:int"><value>1</value></prop>
            <prop oor:name="line_type" oor:type="xs:string"><value>BOLDWAVE</value></prop>
            <!-- misc options -->
            <prop oor:name="start_console" oor:type="xs:int"><value>0</value></prop>
        </group>
    </templates>

    <component>
        <group oor:name="Leaves">
            <node-ref oor:name="${lang}" oor:node-type="${lang}" />
        </group>

Modified gc_core/py/oxt/helpers.py from [4f4ff311ba] to [5f06fa2952].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# Helpers for LibreOffice extension

import os
import traceback
import subprocess

import uno

from com.sun.star.beans import PropertyValue
from com.sun.star.uno import RuntimeException as _rtex


def start_console ():
    "open console from APSO extension"
    try:
        xContext = uno.getComponentContext()
        xContext.ServiceManager.createInstance("apso.python.script.organizer.impl")
        # now we can import apso_utils library
        from apso_utils import console
        console()












|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# Helpers for LibreOffice extension

import os
import traceback
import subprocess

import uno

from com.sun.star.beans import PropertyValue
from com.sun.star.uno import RuntimeException as _rtex


def startConsole ():
    "open console from APSO extension"
    try:
        xContext = uno.getComponentContext()
        xContext.ServiceManager.createInstance("apso.python.script.organizer.impl")
        # now we can import apso_utils library
        from apso_utils import console
        console()

Modified gc_lang/fr/oxt/About/About.py from [cd8f9ad8dc] to [4ef478c592].

33
34
35
36
37
38
39

40
41
42
43
44
45
46
            setattr(xWidget, k, w)
        self.xDialog.insertByName(name, xWidget)
        return xWidget

    def run (self, sLang):
        try:
            dUI = ab_strings.getUI(sLang)


            # dialog
            self.xDialog = self.xSvMgr.createInstanceWithContext('com.sun.star.awt.UnoControlDialogModel', self.ctx)
            self.xDialog.Width = 160
            self.xDialog.Height = 320
            self.xDialog.Title = dUI.get('windowtitle', "#err")
            xWindowSize = helpers.getWindowSize()







>







33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
            setattr(xWidget, k, w)
        self.xDialog.insertByName(name, xWidget)
        return xWidget

    def run (self, sLang):
        try:
            dUI = ab_strings.getUI(sLang)
            self.xGLOptionNode = helpers.getConfigSetting("/org.openoffice.Lightproof_grammalecte/Other/", True)

            # dialog
            self.xDialog = self.xSvMgr.createInstanceWithContext('com.sun.star.awt.UnoControlDialogModel', self.ctx)
            self.xDialog.Width = 160
            self.xDialog.Height = 320
            self.xDialog.Title = dUI.get('windowtitle', "#err")
            xWindowSize = helpers.getWindowSize()
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







            # Infos
            self._addWidget('lblVersion', 'FixedText', 10, 90, nLblWidth, 10, Label = dUI.get('version', "#err"), Align = 1, FontDescriptor = xFD2)
            self._addWidget('lblLicence', 'FixedText', 10, 100, nLblWidth, 10, Label = dUI.get('license', "#err"), Align = 1, FontDescriptor = xFD2)
            self._addWidget('lblWebsite', 'FixedHyperlink', 10, 110, nLblWidth, 10, Label = dUI.get('website', "#err"), Align = 1, \
                            URL="https://grammalecte.net/?from=grammalecte-lo", FontDescriptor = xFD1, TextColor = nURLcolor)

            # Python
            self._addWidget('lblpython', 'FixedText', 10, 125, nLblWidth-50, 10, Align = 1, TextColor = 0x666666, FontDescriptor = xFD2, \
                            Label = dUI.get('pythonver', "#err") + "{0[0]}.{0[1]}.{0[2]}".format(sys.version_info))
            xConsoleButton = self._addWidget('console_button', 'Button', nLblWidth-30, 124, 40, 10, \
                                             Label = dUI.get('console', "#err"), FontDescriptor = xFD2, TextColor = 0x666666)



            # other
            self._addWidget('line', 'FixedLine', 10, 140, nLblWidth, 10)

            # sponsors
            self._addWidget('lblMsg', 'FixedText', 10, 155, nLblWidth, 10, Label = dUI.get('message', "#err"), FontDescriptor = xFD2, Align = 1)
            self._addWidget('lblURL1', 'FixedHyperlink', 10, 170, nLblWidth, 10, Label = dUI.get('sponsor', "#err"), \
                            Align = 1, URL="http://lamouette.org/?from=grammalecte-lo", FontDescriptor = xFD3, TextColor = nURLcolor)
            self._addWidget('imgSponsor', 'ImageControl', 5, 180, 150, 50, ImageURL = sExtPath+"/img/LaMouette_small.png", Border = 0, ScaleMode = 1)
            self._addWidget('lblURL2', 'FixedHyperlink', 10, 235, nLblWidth, 10, Label = dUI.get('sponsor2', "#err"), \
                            Align = 1, URL="https://www.algoo.fr/?from=grammalecte-lo", FontDescriptor = xFD3, TextColor = nURLcolor)
            self._addWidget('imgSponsor2', 'ImageControl', 5, 245, 150, 50, ImageURL = sExtPath+"/img/Algoo_logo.png", Border = 0, ScaleMode = 1)
            self._addWidget('lblURL3', 'FixedHyperlink', 10, 300, nLblWidth, 10, Label = dUI.get('link', "#err"), \
                            Align = 1, URL="https://grammalecte.net/#thanks", FontDescriptor = xFD1, TextColor = nURLcolor)



            # container
            self.xContainer = self.xSvMgr.createInstanceWithContext('com.sun.star.awt.UnoControlDialog', self.ctx)
            self.xContainer.setModel(self.xDialog)
            self.xContainer.getControl('console_button').addActionListener(self)
            self.xContainer.getControl('console_button').setActionCommand('Console')


            self.xContainer.setVisible(False)
            xToolkit = self.xSvMgr.createInstanceWithContext('com.sun.star.awt.ExtToolkit', self.ctx)
            self.xContainer.createPeer(xToolkit, None)
            self.xContainer.execute()
        except:
            traceback.print_exc()

    # XActionListener
    def actionPerformed (self, xActionEvent):
        try:
            if xActionEvent.ActionCommand == 'Console':
                helpers.start_console()




            else:
                self.xContainer.endExecute()
        except:
            traceback.print_exc()














|

|
|
>
>















>
>





>
>











|
>
>
>
>




>
>
>
>
>
>
>
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
            # Infos
            self._addWidget('lblVersion', 'FixedText', 10, 90, nLblWidth, 10, Label = dUI.get('version', "#err"), Align = 1, FontDescriptor = xFD2)
            self._addWidget('lblLicence', 'FixedText', 10, 100, nLblWidth, 10, Label = dUI.get('license', "#err"), Align = 1, FontDescriptor = xFD2)
            self._addWidget('lblWebsite', 'FixedHyperlink', 10, 110, nLblWidth, 10, Label = dUI.get('website', "#err"), Align = 1, \
                            URL="https://grammalecte.net/?from=grammalecte-lo", FontDescriptor = xFD1, TextColor = nURLcolor)

            # Python
            self._addWidget('lblpython', 'FixedText', 10, 125, 60, 10, Align = 1, TextColor = 0x666666, FontDescriptor = xFD2, \
                            Label = dUI.get('pythonver', "#err") + "{0[0]}.{0[1]}.{0[2]}".format(sys.version_info))
            self._addWidget('console_button', 'Button', 70, 124, 40, 10, \
                            Label = dUI.get('console', "#err"), FontDescriptor = xFD2, TextColor = 0x666666)
            self.xAutoConsole = self._addWidget('autoconsole', 'CheckBox', 120, 125, 40, 10, \
                                                Label = dUI.get('autoconsole', "#err"), HelpText = dUI.get("autoconsole_descr", "#err"))

            # other
            self._addWidget('line', 'FixedLine', 10, 140, nLblWidth, 10)

            # sponsors
            self._addWidget('lblMsg', 'FixedText', 10, 155, nLblWidth, 10, Label = dUI.get('message', "#err"), FontDescriptor = xFD2, Align = 1)
            self._addWidget('lblURL1', 'FixedHyperlink', 10, 170, nLblWidth, 10, Label = dUI.get('sponsor', "#err"), \
                            Align = 1, URL="http://lamouette.org/?from=grammalecte-lo", FontDescriptor = xFD3, TextColor = nURLcolor)
            self._addWidget('imgSponsor', 'ImageControl', 5, 180, 150, 50, ImageURL = sExtPath+"/img/LaMouette_small.png", Border = 0, ScaleMode = 1)
            self._addWidget('lblURL2', 'FixedHyperlink', 10, 235, nLblWidth, 10, Label = dUI.get('sponsor2', "#err"), \
                            Align = 1, URL="https://www.algoo.fr/?from=grammalecte-lo", FontDescriptor = xFD3, TextColor = nURLcolor)
            self._addWidget('imgSponsor2', 'ImageControl', 5, 245, 150, 50, ImageURL = sExtPath+"/img/Algoo_logo.png", Border = 0, ScaleMode = 1)
            self._addWidget('lblURL3', 'FixedHyperlink', 10, 300, nLblWidth, 10, Label = dUI.get('link', "#err"), \
                            Align = 1, URL="https://grammalecte.net/#thanks", FontDescriptor = xFD1, TextColor = nURLcolor)

            self._loadOptions()

            # container
            self.xContainer = self.xSvMgr.createInstanceWithContext('com.sun.star.awt.UnoControlDialog', self.ctx)
            self.xContainer.setModel(self.xDialog)
            self.xContainer.getControl('console_button').addActionListener(self)
            self.xContainer.getControl('console_button').setActionCommand('Console')
            self.xContainer.getControl('autoconsole').addActionListener(self)
            self.xContainer.getControl('autoconsole').setActionCommand('AutoConsole')
            self.xContainer.setVisible(False)
            xToolkit = self.xSvMgr.createInstanceWithContext('com.sun.star.awt.ExtToolkit', self.ctx)
            self.xContainer.createPeer(xToolkit, None)
            self.xContainer.execute()
        except:
            traceback.print_exc()

    # XActionListener
    def actionPerformed (self, xActionEvent):
        try:
            if xActionEvent.ActionCommand == 'Console':
                helpers.startConsole()
            elif xActionEvent.ActionCommand == "AutoConsole":
                xChild = self.xGLOptionNode.getByName("o_fr")
                xChild.setPropertyValue("start_console", self.xAutoConsole.State)
                self.xGLOptionNode.commitChanges()
            else:
                self.xContainer.endExecute()
        except:
            traceback.print_exc()

    def _loadOptions (self):
        try:
            xChild = self.xGLOptionNode.getByName("o_fr")
            self.xAutoConsole.State = xChild.getPropertyValue("start_console")
        except:
            traceback.print_exc()

Modified gc_lang/fr/oxt/About/ab_strings.py from [4684039c06] to [8f55eaf617].

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
    "fr": {
            "windowtitle": "À propos…",
            "title": "Grammalecte",
            "version": "Version : ${version}",
            "license": "Licence : GPL 3",
            "website": "Site web",

            "pythonver": "Machine Python : v",
            "console": "Console",



            "message": "Avec le soutien de",
            "sponsor": "La Mouette…",
            "sponsor2": "Algoo…",
            "link": "… et de nombreux contributeurs.",

            "close": "~OK"
          },
    "en": {
            "windowtitle": "About…",
            "title": "Grammalecte",
            "version": "Version: ${version}",
            "license": "License: GPL 3",
            "website": "Web site",

            "pythonver": "Python machine: v",
            "console": "Console",



            "message": "With the support of",
            "sponsor": "La Mouette…",
            "sponsor2": "Algoo…",
            "link": "… and many contributors.",

            "close": "~OK"
          }
}







|

>
>















|

>
>









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
    "fr": {
            "windowtitle": "À propos…",
            "title": "Grammalecte",
            "version": "Version : ${version}",
            "license": "Licence : GPL 3",
            "website": "Site web",

            "pythonver": "Python v",
            "console": "Console",
            "autoconsole": "Auto",
            "autoconsole_descr": "Lance la console au démarrage de LibreOffice",

            "message": "Avec le soutien de",
            "sponsor": "La Mouette…",
            "sponsor2": "Algoo…",
            "link": "… et de nombreux contributeurs.",

            "close": "~OK"
          },
    "en": {
            "windowtitle": "About…",
            "title": "Grammalecte",
            "version": "Version: ${version}",
            "license": "License: GPL 3",
            "website": "Web site",

            "pythonver": "Python v",
            "console": "Console",
            "autoconsole": "Auto",
            "autoconsole_descr": "Launch the console at the start of LibreOffice",

            "message": "With the support of",
            "sponsor": "La Mouette…",
            "sponsor2": "Algoo…",
            "link": "… and many contributors.",

            "close": "~OK"
          }
}

Modified gc_lang/fr/oxt/AppLauncher.py from [e69ae3b8a0] to [d099028ae8].

1
2
3
4
5
6
7
8
# -*- coding: utf8 -*-
# Grammalecte AppLauncher
# by Olivier R.
# License: MPL 2

import unohelper
import uno
import traceback
<








1
2
3
4
5
6
7

# Grammalecte AppLauncher
# by Olivier R.
# License: MPL 2

import unohelper
import uno
import traceback
19
20
21
22
23
24
25





26
27
28
29
30
31
32
    def __init__ (self, ctx):
        self.ctx = ctx
        # In this extension, French is default language.
        # It is assumed that those who need to use the French dictionaries understand French and may not understand English.
        xSettings = helpers.getConfigSetting("/org.openoffice.Setup/L10N", False)
        sLocale = xSettings.getByName("ooLocale")  # Note: look at ooSetupSystemLocale value?
        self.sLang = sLocale[0:2]






    # XJobExecutor
    def trigger (self, sCmd):
        try:
            if sCmd == "About":
                import About
                xDialog = About.AboutGrammalecte(self.ctx)







>
>
>
>
>







18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
    def __init__ (self, ctx):
        self.ctx = ctx
        # In this extension, French is default language.
        # It is assumed that those who need to use the French dictionaries understand French and may not understand English.
        xSettings = helpers.getConfigSetting("/org.openoffice.Setup/L10N", False)
        sLocale = xSettings.getByName("ooLocale")  # Note: look at ooSetupSystemLocale value?
        self.sLang = sLocale[0:2]
        # console
        xSettings = helpers.getConfigSetting("/org.openoffice.Lightproof_grammalecte/Other/", False)
        xChild = xSettings.getByName("o_fr")
        if xChild.getPropertyValue("start_console"):
            helpers.startConsole()

    # XJobExecutor
    def trigger (self, sCmd):
        try:
            if sCmd == "About":
                import About
                xDialog = About.AboutGrammalecte(self.ctx)