Exemplo n.º 1
0
    def showDlg(self):
        logger.debug(util.funcName(obj=self))
        dlg = dutil.createDialog(self.unoObjs, _dlgdef)
        if not dlg:
            return
        ctrl_getter = dutil.ControlGetter(dlg)
        app = BulkConversion(self.unoObjs)
        self.step1Form = FormStep1(ctrl_getter, app)
        self.step1Form.start_working()
        self.step2Form = FormStep2(ctrl_getter, app)
        self.step2Form.start_working()
        stepper = DlgStepper(dlg)
        advancer = AdvanceHandler(
            ctrl_getter, stepper, self.step1Form, self.step2Form)
        advancer.start_working()
        closingButtons = ClosingButtons(ctrl_getter, dlg.endExecute)
        closingButtons.start_working()

        ## Display the dialog

        dlg.execute()
        if stepper.on_step1():
            self.step1Form.store_results()
        if stepper.on_step2():
            self.step2Form.store_results()
        if closingButtons.convertOnClose:
            try:
                app.doConversions()
            except exceptions.MessageError as exc:
                msgbox = MessageBox(self.unoObjs)
                msgbox.displayExc(exc)
                return
        dlg.dispose()
Exemplo n.º 2
0
 def __init__(self, calcUnoObjs, colOrder):
     self.unoObjs = calcUnoObjs
     self.colOrder = colOrder
     self.msgbox = MessageBox(self.unoObjs)
     self.progressRanges = None
     self.sheet = None
     self.listDoc = None
 def __init__(self, unoObjs):
     self.unoObjs = unoObjs
     self.userVars = UserVars(Prefix.PHONOLOGY, unoObjs.document, logger)
     self.msgbox = MessageBox(unoObjs)
     self.dlgCtrls = None
     self.evtHandler = None
     self.dlgClose = None
 def __init__(self, unoObjs):
     self.unoObjs = unoObjs
     self.msgbox = MessageBox(unoObjs)
     self.foundSomething = False
     self.search = None
     self.foundString = None
     logger.debug("ExampleSearch init() finished")
Exemplo n.º 5
0
class DlgSpellingReplace:
    """Main class for this dialog."""

    def __init__(self, unoObjs):
        self.unoObjs = unoObjs
        self.msgbox = MessageBox(unoObjs)
        self.dlgCtrls = None
        self.evtHandler = None
        self.buttonPressed = ""
        self.changeTo = None
        self.doExecute = None
        self.doEndExecute = None
        self.doDispose = None

    def makeDlg(self):
        """This method will neither show nor destroy the dialog.
        That is left up to the calling code, via
        doExecute() and doDispose().
        """
        logger.debug(util.funcName(obj=self))
        dlg = dutil.createDialog(self.unoObjs, _dlgdef)
        if not dlg:
            return
        ctrl_getter = dutil.ControlGetter(dlg)
        self.evtHandler = DlgEventHandler(self)
        self.dlgCtrls = DlgControls(
            self.unoObjs, ctrl_getter, self.evtHandler)
        self.evtHandler.setCtrls(self.dlgCtrls)

        ## Methods to display and close the dialog

        self.doExecute = dlg.execute
        # hides the dialog and cause the execute() method to return
        self.doEndExecute = dlg.endExecute
        # destroys the dialog
        self.doDispose = dlg.dispose

    def setContents(self, textFound, suggestions, context):
        self.buttonPressed = ""
        self.changeTo = textFound
        self.dlgCtrls.lblFoundText.setText(textFound)
        self.dlgCtrls.lblContext.setText(context)
        self.dlgCtrls.txtChangeTo.setText(textFound)
        logger.debug(repr(suggestions))
        dutil.fill_list_ctrl(self.dlgCtrls.listSuggestions, suggestions)
        logger.debug(util.funcName('end'))

    def finish(self, buttonPressed):
        if buttonPressed in ['Change', 'ChangeAll']:
            if (self.dlgCtrls.txtChangeTo.getText() ==
                    self.dlgCtrls.lblFoundText.getText()):
                self.msgbox.display(
                    "You did not make any changes to the word.")
                return
        self.buttonPressed = buttonPressed
        self.changeTo = self.dlgCtrls.txtChangeTo.getText()
        self.doEndExecute()   # return from the execute() loop

    def getResults(self):
        return self.buttonPressed, self.changeTo
Exemplo n.º 6
0
 def __init__(self, unoObjs):
     self.unoObjs = unoObjs
     self.userVars = UserVars(Prefix.PHONOLOGY, unoObjs.document, logger)
     self.msgbox = MessageBox(unoObjs)
     self.app = lingexamples.ExServices(EXTYPE_PHONOLOGY, unoObjs)
     self.dlgCtrls = None
     self.evtHandler = None
     self.dlgClose = None
Exemplo n.º 7
0
 def __init__(self, calcUnoObjs, userVars):
     self.unoObjs = calcUnoObjs
     self.userVars = userVars
     self.msgbox = MessageBox(self.unoObjs)
     self.script = ""
     self.charsComp = []  # lines of chars to compare
     self.datalist = None
     self.displayResults = True
Exemplo n.º 8
0
 def __init__(self, writerUnoObjs, userVars):
     self.unoObjs = writerUnoObjs
     self.msgbox = MessageBox(self.unoObjs)
     self.userVars = userVars
     self.goodList = GoodList(self.msgbox)
     self.wordAsker = WordAsker(self.unoObjs, self.goodList)
     self.config = None
     self.numChanges = 0
 def __init__(self, writerUnoObjs, fileItems, columnOrder, userVars):
     self.unoObjs = writerUnoObjs
     self.fileItems = fileItems    # FileItemList of WordListFileItem
     self.columnOrder = columnOrder
     self.userVars = userVars
     self.msgbox = MessageBox(self.unoObjs)
     self.words = []
     self.progressBar = None
 def __init__(self, calcUnoObjs, userVars):
     self.unoObjs = calcUnoObjs
     self.userVars = userVars
     self.msgbox = MessageBox(self.unoObjs)
     self.filepath = ""
     self.matchPartial = False
     self.exportType = ""
     self.xpathExprs = ""
     self.sfMarkers = ""
class ChangerMaker:
    """Save a CC table or XSLT file from data in the spreadsheet."""
    def __init__(self, calcUnoObjs, userVars):
        self.unoObjs = calcUnoObjs
        self.userVars = userVars
        self.msgbox = MessageBox(self.unoObjs)
        self.filepath = ""
        self.matchPartial = False
        self.exportType = ""
        self.xpathExprs = ""
        self.sfMarkers = ""

    def setFilepath(self, newVal):
        self.filepath = newVal

    def setExportType(self, newVal):
        self.exportType = newVal

    def setSFM(self, newVal):
        self.sfMarkers = newVal

    def setMatchPartial(self, newVal):
        self.matchPartial = newVal

    def setXpathExprs(self, newVal):
        """Value should be an iterable containing strings."""
        self.xpathExprs = newVal

    def make(self):
        logger.debug(util.funcName('begin'))
        progressBar = ProgressBar(self.unoObjs, "Getting data...")
        progressBar.show()
        progressBar.updateBeginning()
        try:
            columnOrder = ColumnOrder(self.userVars)
            columnOrder.loadUserVars()
            changeList = getChangeList(self.unoObjs, columnOrder)
            progressBar.updateFinishing()
        except exceptions.DocAccessError:
            self.msgbox.display("Error reading spreadsheet.")
        progressBar.close()
        progressBar = ProgressBar(self.unoObjs, "Saving file...")
        progressBar.show()
        progressBar.updatePercent(50)
        if self.exportType == "ReplacementCCT":
            outputter = CCT_Writer(self.filepath)
            outputter.writeSimpleReplacements(changeList)
        elif self.exportType == "SFM_CCT":
            outputter = CCT_Writer(self.filepath)
            outputter.writeComplete(changeList, self.sfMarkers)
        elif self.exportType == "XSLT":
            outputter = XSLT_Writer(self.filepath)
            outputter.write(changeList, self.xpathExprs, self.matchPartial)
        progressBar.updateFinishing()
        progressBar.close()
        logger.debug(util.funcName('end'))
Exemplo n.º 12
0
 def __init__(self, unoObjs):
     self.unoObjs = unoObjs
     self.msgbox = MessageBox(unoObjs)
     self.dlgCtrls = None
     self.evtHandler = None
     self.buttonPressed = ""
     self.changeTo = None
     self.doExecute = None
     self.doEndExecute = None
     self.doDispose = None
 def __init__(self, calcUnoObjs):
     self.unoObjs = calcUnoObjs
     self.msgbox = MessageBox(self.unoObjs)
     self.userVars = uservars.UserVars(uservars.Prefix.SPELLING,
                                       calcUnoObjs.document, logger)
     self.app = ChangerMaker(self.unoObjs, self.userVars)
     self.exportOnClose = False
     self.dlgCtrls = None
     self.evtHandler = None
     self.dlgClose = None
Exemplo n.º 14
0
 def __init__(self, calcUnoObjs, userVars):
     self.unoObjs = calcUnoObjs
     self.userVars = userVars
     self.msgbox = MessageBox(self.unoObjs)
     self.suggestions = SpellingSuggestions(self.msgbox)
     self.suggListSet = False
     self.wantSuggestions = True
     self.currentRow = -1
     self.datalist = []  # List of wordlist_structs.WordInList items.
     self.columnOrder = None
Exemplo n.º 15
0
 def __init__(self, unoObjs):
     self.unoObjs = unoObjs
     self.msgbox = MessageBox(self.unoObjs)
     self.userVars = uservars.UserVars(uservars.Prefix.MAKE_OXT,
                                       unoObjs.document, logger)
     self.settings = None
     self.runOnClose = False
     self.dlgCtrls = None
     self.evtHandler = None
     self.dlgClose = None
Exemplo n.º 16
0
 def __init__(self, unoObjs):
     self.unoObjs = unoObjs
     self.userVars = UserVars(Prefix.ABBREVIATIONS, unoObjs.document,
                              logger)
     self.msgbox = MessageBox(unoObjs)
     self.abbrevList = abbreviations.AbbrevList(self.unoObjs, self.userVars)
     self.selectedIndex = -1  # position in abbrevList and listboxAbbrevs
     self.selectedAbbrev = None
     self.dlgCtrls = None
     self.evtHandler = None
     self.dlgClose = None
 def __init__(self, calcUnoObjs):
     self.unoObjs = calcUnoObjs
     self.userVars = uservars.UserVars(uservars.Prefix.SPELLING,
                                       calcUnoObjs.document, logger)
     self.app = SpellingStepper(self.unoObjs, self.userVars)
     self.msgbox = MessageBox(self.unoObjs)
     self.maxRow = -1
     self.scrollbarAlreadyMoved = False
     self.dlgCtrls = None
     self.evtHandler = None
     self.dlgClose = None
Exemplo n.º 18
0
 def __init__(self, unoObjs):
     self.unoObjs = unoObjs
     self.userVars = uservars.UserVars(uservars.Prefix.GRAMMAR,
                                       unoObjs.document, logger)
     self.msgbox = MessageBox(unoObjs)
     self.fileItems = fileitemlist.FileItemList(fileitemlist.LingExFileItem,
                                                self.userVars)
     self.selectedIndex = -1  # position in listboxFiles
     self.dlgCtrls = None
     self.evtHandler = None
     self.dlgClose = None
class AbbrevManager:
    """Sends output to the Writer doc."""
    def __init__(self, unoObjs, styles):
        self.unoObjs = unoObjs
        self.msgbox = MessageBox(unoObjs)
        self.styleNames = styles.styleNames
        self.styles = styles
        logger.debug("AbbrevManager init() finished")

    def outputList(self, abbrevList):
        logger.debug(util.funcName('begin'))

        ## Start with default formatting at the beginning

        oVC = self.unoObjs.viewcursor
        if oVC.TextTable or oVC.TextFrame:
            self.msgbox.display(
                "The cursor cannot be inside a table or frame.")
            return
        elif oVC.getText().getImplementationName() == "SwXHeadFootText":
            self.msgbox.display("The cursor cannot be in a header or footer.")
            return
        textcursor = self.unoObjs.text.createTextCursorByRange(
            self.unoObjs.viewcursor.getStart())
        logger.debug("Created a text cursor.")
        textcursor.setPropertyValue('ParaStyleName', 'Standard')
        textcursor.setPropertyToDefault('CharStyleName')

        didOutput = False
        for abbr in abbrevList:
            if not abbr.shouldOutput():
                logger.debug("Skipping abbrev %s.", abbr.abbrevText)
                continue
            logger.debug("Outputting abbrev %s.", abbr.abbrevText)
            didOutput = True
            self.styles.requireParaStyle('abbr')
            textcursor.setPropertyValue("ParaStyleName",
                                        self.styleNames['abbr'])
            abbr_str = abbr.abbrevText + "\t" + abbr.fullName
            self.unoObjs.text.insertString(textcursor, abbr_str, 0)
            self.unoObjs.text.insertControlCharacter(textcursor,
                                                     PARAGRAPH_BREAK, 0)

        if didOutput:
            self.unoObjs.text.insertControlCharacter(textcursor,
                                                     PARAGRAPH_BREAK, 0)
            textcursor.setPropertyValue("ParaStyleName", "Standard")
        else:
            self.unoObjs.text.insertString(textcursor,
                                           "No abbreviations found.", 0)
            self.unoObjs.text.insertControlCharacter(textcursor,
                                                     PARAGRAPH_BREAK, 0)
        logger.debug(util.funcName('end'))
Exemplo n.º 20
0
 def __init__(self, drawingUnoObjs):
     self.unoObjs = drawingUnoObjs
     self.userVars = uservars.UserVars(uservars.Prefix.DATA_CONV_DRAW,
                                       drawingUnoObjs.document, logger)
     self.msgbox = MessageBox(self.unoObjs)
     self.styleFonts = styles.StyleFonts(self.unoObjs)
     self.app = DataConversion(self.unoObjs, self.userVars, self.styleFonts)
     self.dlgCtrls = None
     self.evtHandler = None
     self.config = None
     self.converter = None
     self.convertOnClose = False
     self.dlgClose = None
 def __init__(self, calcUnoObjs):
     self.unoObjs = calcUnoObjs
     self.msgbox = MessageBox(self.unoObjs)
     self.userVars = uservars.UserVars(uservars.Prefix.WORD_LIST,
                                       calcUnoObjs.document, logger)
     self.app = DataConversion(self.unoObjs, self.userVars, styleFonts=None)
     self.sourceCol = ""
     self.targetCol = ""
     self.skipFirstRow = True
     self.convertOnClose = False
     self.dlgCtrls = None
     self.evtHandler = None
     self.dlgClose = None
Exemplo n.º 22
0
 def __init__(self, calcUnoObjs):
     self.unoObjs = calcUnoObjs
     self.msgbox = MessageBox(self.unoObjs)
     finder = uservars.SettingsDocFinder(uservars.Prefix.SPELLING,
                                         self.unoObjs)
     self.writerUnoObjs = finder.getWriterDoc()
     self.userVars = uservars.UserVars(uservars.Prefix.SPELLING,
                                       self.writerUnoObjs.document, logger)
     self.app = ChangerMaker(self.unoObjs, self.userVars)
     self.exportOnClose = False
     self.dlgCtrls = None
     self.evtHandler = None
     self.dlgClose = None
Exemplo n.º 23
0
def createDialog(uno_objs, definition_class):
    """:param definition_class: class from lingt.utils.dlgdefs"""
    logger.debug("Creating dialog...")
    dlg_getter = DialogGetter(uno_objs, definition_class)
    dlg = None
    try:
        dlg = dlg_getter.create_and_verify()
    except exceptions.DialogError as exc:
        msgbox = MessageBox(uno_objs)
        msgbox.displayExc(exc)
        return None
    logger.debug("Created dialog.")
    return dlg
Exemplo n.º 24
0
 def __init__(self, unoObjs):
     self.unoObjs = unoObjs
     self.userVars = uservars.UserVars(
         uservars.Prefix.DATA_CONVERSION, unoObjs.document, logger)
     self.msgbox = MessageBox(unoObjs)
     self.styleFonts = styles.StyleFonts(unoObjs)
     self.app = DataConversion(unoObjs, self.userVars, self.styleFonts)
     self.dlgCtrls = None
     self.evtHandler = None
     self.charStyleNames = []
     self.paraStyleNames = []
     self.config = None
     self.converter = None
     self.convertOnClose = False
     self.dlgClose = None
Exemplo n.º 25
0
 def __init__(self, exType, unoObjs):
     self.exType = exType
     self.unoObjs = unoObjs
     if self.exType == EXTYPE_PHONOLOGY:
         USERVAR_PREFIX = Prefix.PHONOLOGY
     else:
         USERVAR_PREFIX = Prefix.GRAMMAR
     self.userVars = UserVars(
         USERVAR_PREFIX, unoObjs.document, logger)
     self.msgbox = MessageBox(unoObjs)
     self.settings = ExSettings(self.exType, self.unoObjs, self.userVars)
     self.operations = ExOperations(
         self.exType, self.unoObjs, self.userVars, self.settings)
     self.replacingRefs = True  # find and replace ref numbers
     logger.debug("ExGrabber init() finished")
 def __init__(self, docUnoObjs, userVars, styleFonts=None):
     """unoObjs needs to be for a writer doc if calling
     doConversions_writer(),
     and for a calc spreadsheet if calling doConversion_calc().
     Set styleFonts if calling setAndVerifyConfig(),
     which is probably only for the DlgBulkConv dialog.
     """
     self.unoObjs = docUnoObjs
     self.userVars = userVars
     self.changerSettings = TextChangerSettings()
     self.changerSettings.load_userVars(userVars)
     self.styleFonts = styleFonts
     self.msgbox = MessageBox(self.unoObjs)
     self.secCall = SEC_wrapper(self.msgbox, userVars)
     self.config = None
Exemplo n.º 27
0
 def __init__(self, config, outerTable, unoObjs):
     """config should be of type outputmanager.InterlinSettings."""
     self.config = config
     self.outerTable = outerTable
     self.unoObjs = unoObjs
     self.msgbox = MessageBox(unoObjs)
     self.wrappingManager = WrappingManager(config, outerTable, unoObjs)
Exemplo n.º 28
0
 def __init__(self, exType, unoObjs):
     self.exType = exType
     self.unoObjs = unoObjs
     logger.debug("DlgGrabExamples() %s", exType)
     self.msgbox = MessageBox(unoObjs)
     if exType == EXTYPE_PHONOLOGY:
         USERVAR_PREFIX = Prefix.PHONOLOGY
         self.titleText = theLocale.getText("Get Phonology Examples")
     else:
         USERVAR_PREFIX = Prefix.INTERLINEAR
         self.titleText = theLocale.getText("Get Interlinear Examples")
     self.userVars = UserVars(USERVAR_PREFIX, unoObjs.document, logger)
     self.app = lingexamples.ExServices(exType, unoObjs)
     self.dlgCtrls = None
     self.evtHandler = None
     self.dlgClose = None
     logger.debug("DlgGrabExamples init() finished")
Exemplo n.º 29
0
 def __init__(self, unoObjs):
     self.unoObjs = unoObjs
     self.msgbox = MessageBox(unoObjs)
     self.selectionFound = None
     self.alreadyAskedList = []
     self.searchConfig = None
     self.currentAbbrevList = None
     self.possibilities = []
     logger.debug("AbbrevSearch init() finished")
Exemplo n.º 30
0
 def __init__(self, unoObjs):
     self.unoObjs = unoObjs
     uservars.SettingsDocPreparer(uservars.Prefix.SCRIPT_PRACTICE,
                                  unoObjs).prepare()
     self.userVars = uservars.UserVars(uservars.Prefix.SCRIPT_PRACTICE,
                                       unoObjs.document, logger)
     self.msgbox = MessageBox(unoObjs)
     self.script = scriptpractice.Script(self.unoObjs)
     self.questions = scriptpractice.PracticeQuestions(
         self.unoObjs, self.script)
     self.stats = scriptpractice.Stats()
     self.wordList = []
     self.whichSource = ""
     self.step = self.STEP_SETTINGS
     self.dlg = None
     self.dlgCtrls = None
     self.evtHandler = None
     self.dlgClose = None