Check-in [df208eb46c]
Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | more renaming for OOo registration |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
df208eb46cc611f62751703d55d26a15 |
User & Date: | mario 2020-05-02 16:49:22 |
Context
2020-05-02
| ||
23:03 | Try to traverse TextTable cells (seemingly no compatible Enumerator interface for that) check-in: 4996dce9a8 user: mario tags: trunk | |
16:49 | more renaming for OOo registration check-in: df208eb46c user: mario tags: trunk | |
16:24 | More comments, add traceback.format_exc import check-in: 11b8a41e7b user: mario tags: trunk | |
Changes
Added Makefile.
> > | 1 2 | oxt: zip pagetranslate.oxt -r icons registry pagetranslate.py META-INF pkg-desc description.xml registration/lgpl-en.txt |
Changes to pagetranslate.py.
︙ | ︙ | |||
14 15 16 17 18 19 20 | # since all paragraphs are piped through the remote service one by one. # # Possiby going to reenable the cursor/selection mode later on. Perhaps even # the language configurability. # | | < < > > | | > > > > > | < | | 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 | # since all paragraphs are piped through the remote service one by one. # # Possiby going to reenable the cursor/selection mode later on. Perhaps even # the language configurability. # # OpenOffice UNO bridge import uno, unohelper from com.sun.star.task import XJobExecutor from com.sun.star.awt.MessageBoxButtons import BUTTONS_OK, BUTTONS_OK_CANCEL, BUTTONS_YES_NO, BUTTONS_YES_NO_CANCEL, BUTTONS_RETRY_CANCEL, BUTTONS_ABORT_IGNORE_RETRY from com.sun.star.awt.MessageBoxButtons import 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 MESSAGEBOX, INFOBOX, WARNINGBOX, ERRORBOX, QUERYBOX from com.sun.star.beans import PropertyValue # sys modules import string import json import sys from traceback import format_exc # http preparations import urllib from urllib.request import urlopen, Request from urllib.parse import urlencode, quote, quote_plus ssl_args = dict() if sys.platform != 'win32': import ssl myssl = ssl.create_default_context(); myssl.check_hostname = False myssl.verify_mode = ssl.CERT_NONE ssl_args["context"] = myssl http_headers = { "User-Agent": "Mozilla/5.0 (X11; Linux; LibreOffice/6.3; TradutorLibreText/1.3.7)" } # log file import logging logging.basicConfig(filename='/tmp/pagetranslate-libreoffice.log', level=logging.INFO) # regex import re rx_gtrans = re.compile('class="t0">(.+?)</div>', re.S) rx_splitpara = re.compile("(.{1,35\.}|.{1,20}\s|.*$)", re.S) class selectsize(Exception): def __init__(self, size,langcode): Exception.__init__(self) if langcode=='pt-BR': self.size ='selecione de 2 h\xE1 1900 caracteres ( Total selecionado ( ' + size + ' ))' else : self.size = 'You have selected 0 or more than 1900 characters (Total selected ( '+ size +'))' class pagetranslate(unohelper.Base, XJobExecutor): def __init__(self, ctx): logging.info("init") self.ctx = ctx desktop = self.ctx.ServiceManager.createInstanceWithContext( "com.sun.star.frame.Desktop", self.ctx ) self.document = desktop.getCurrentComponent() |
︙ | ︙ | |||
195 196 197 198 199 200 201 | myBox = sv.createMessageBox(ParentWin, MsgType, MsgButtons, MsgTitle, MsgText) return myBox.execute() | | | | < | | > | 199 200 201 202 203 204 205 206 207 208 209 210 211 | myBox = sv.createMessageBox(ParentWin, MsgType, MsgButtons, MsgTitle, MsgText) return myBox.execute() # register with LibreOffice unohelper.ImplementationHelper().addImplementation( pagetranslate, "org.openoffice.comp.pyuno.pagetranslate", ("com.sun.star.task.Job",), ) |