summaryrefslogtreecommitdiff
path: root/wizards/com/sun/star/wizards
diff options
context:
space:
mode:
authorXisco Fauli <anistenis@gmail.com>2012-09-27 22:12:21 +0200
committerXisco Fauli <anistenis@gmail.com>2012-09-27 22:14:06 +0200
commit74e4137cf89d3e1e8b73853702636e3ff70a3b4e (patch)
tree116a0ad9efd8a975740049d32f4904705834eec1 /wizards/com/sun/star/wizards
parent0e66cce3a146023fe3509217d32223ba162150b7 (diff)
pyfax: Translate the template at run-time
Change-Id: Ied94eaeb33dcfab582ac1d4702b736cf81c5d7ca
Diffstat (limited to 'wizards/com/sun/star/wizards')
-rw-r--r--wizards/com/sun/star/wizards/common/TextElement.py41
-rw-r--r--wizards/com/sun/star/wizards/fax/CallWizard.py1
-rw-r--r--wizards/com/sun/star/wizards/fax/FaxDocument.py9
-rw-r--r--wizards/com/sun/star/wizards/fax/FaxWizardDialogImpl.py34
-rw-r--r--wizards/com/sun/star/wizards/fax/FaxWizardDialogResources.py31
5 files changed, 106 insertions, 10 deletions
diff --git a/wizards/com/sun/star/wizards/common/TextElement.py b/wizards/com/sun/star/wizards/common/TextElement.py
new file mode 100644
index 000000000000..f035808c4892
--- /dev/null
+++ b/wizards/com/sun/star/wizards/common/TextElement.py
@@ -0,0 +1,41 @@
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# This file incorporates work covered by the following license notice:
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed
+# with this work for additional information regarding copyright
+# ownership. The ASF licenses this file to you under the Apache
+# License, Version 2.0 (the "License"); you may not use this file
+# except in compliance with the License. You may obtain a copy of
+# the License at http://www.apache.org/licenses/LICENSE-2.0 .
+#
+import traceback
+from .Helper import Helper
+from com.sun.star.text.PlaceholderType import TEXT
+
+class TextElement(object):
+
+ def __init__(self, item, placeHolderText, hint, xmsf):
+ self.item = item
+ self.placeHolderText = placeHolderText
+ self.xmsf = xmsf
+ self.paraStyle = Helper.getUnoPropertyValue(
+ item.Start, "ParaStyleName")
+
+ def write(self):
+ try:
+ if self.item is not None:
+ self.item.String = ""
+ cursor = self.item.Text.createTextCursorByRange(
+ self.item.Start)
+ cursor.String = self.placeHolderText
+ Helper.setUnoPropertyValue(
+ cursor, "ParaStyleName", self.paraStyle)
+ except Exception, e:
+ traceback.print_exc()
diff --git a/wizards/com/sun/star/wizards/fax/CallWizard.py b/wizards/com/sun/star/wizards/fax/CallWizard.py
index 427a7036bdd0..8ef1d24fa4ab 100644
--- a/wizards/com/sun/star/wizards/fax/CallWizard.py
+++ b/wizards/com/sun/star/wizards/fax/CallWizard.py
@@ -30,7 +30,6 @@ class CallWizard(unohelper.Base, XJobExecutor):
self.ctx = ctx
def trigger(self, args):
- print "hello"
try:
fw = FaxWizardDialogImpl(self.ctx.ServiceManager)
fw.startWizard(self.ctx.ServiceManager)
diff --git a/wizards/com/sun/star/wizards/fax/FaxDocument.py b/wizards/com/sun/star/wizards/fax/FaxDocument.py
index 95072de8266f..f86a3f5ba981 100644
--- a/wizards/com/sun/star/wizards/fax/FaxDocument.py
+++ b/wizards/com/sun/star/wizards/fax/FaxDocument.py
@@ -15,9 +15,9 @@
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
-
-from ..text.TextDocument import TextDocument, traceback, Helper,\
- TextFieldHandler, Configuration
+from ..text.TextDocument import *
+ #TextDocument, traceback, Helper,\
+ #TextFieldHandler, Configuration
from ..text.TextSectionHandler import TextSectionHandler
from ..common.PropertyNames import PropertyNames
@@ -51,8 +51,8 @@ class FaxDocument(TextDocument):
def switchFooter(self, sPageStyle, bState, bPageNumber, sText):
if TextDocument.xTextDocument is not None:
- TextDocument.xTextDocument.lockControllers()
try:
+ TextDocument.xTextDocument.lockControllers()
xPageStyleCollection = \
TextDocument.xTextDocument.StyleFamilies.getByName("PageStyles")
xPageStyle = xPageStyleCollection.getByName(sPageStyle)
@@ -84,6 +84,7 @@ class FaxDocument(TextDocument):
TextDocument.xTextDocument.unlockControllers()
except Exception:
+ TextDocument.xTextDocument.lockControllers()
traceback.print_exc()
def hasElement(self, sElement):
diff --git a/wizards/com/sun/star/wizards/fax/FaxWizardDialogImpl.py b/wizards/com/sun/star/wizards/fax/FaxWizardDialogImpl.py
index e008aeb6011d..249c2491bc14 100644
--- a/wizards/com/sun/star/wizards/fax/FaxWizardDialogImpl.py
+++ b/wizards/com/sun/star/wizards/fax/FaxWizardDialogImpl.py
@@ -32,6 +32,7 @@ from ..common.NoValidPathException import NoValidPathException
from ..common.HelpIds import HelpIds
from ..common.FileAccess import FileAccess
from ..common.Desktop import Desktop
+from ..common.TextElement import TextElement
from ..document.OfficeDocument import OfficeDocument
from com.sun.star.awt.VclWindowPeerAttribute import YES_NO, DEF_NO
@@ -67,15 +68,17 @@ class FaxWizardDialogImpl(FaxWizardDialog):
@classmethod
def main(self, args):
- #only being called when starting wizard remotely
+ #Call the wizard remotely
try:
ConnectStr = \
"uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext"
xLocMSF = Desktop.connect(ConnectStr)
lw = FaxWizardDialogImpl(xLocMSF)
lw.startWizard(xLocMSF)
- except Exception, e:
- traceback.print_exc()
+ except Exception as e:
+ print ("Wizard failure exception " + str(type(e)) +
+ " message " + str(e) + " args " + str(e.args) +
+ traceback.format_exc())
def startWizard(self, xMSF):
self.running = True
@@ -232,6 +235,30 @@ class FaxWizardDialogImpl(FaxWizardDialog):
except CloseVetoException, e:
traceback.print_exc()
+ def drawConstants(self):
+ '''Localise the template'''
+ constRangeList = self.searchFillInItems(1)
+
+ for i in xrange(constRangeList.Count):
+ item = constRangeList.getByIndex(i)
+ text = item.String.lower()
+ aux = TextElement(item, self.resources.dictConstants[text],
+ "hint", self.xMSF)
+ aux.write()
+
+ def searchFillInItems(self, typeSearch):
+ sd = TextDocument.xTextDocument.createSearchDescriptor()
+
+ if typeSearch == 0:
+ sd.setSearchString("<[^>]+>")
+ elif typeSearch == 1:
+ sd.setSearchString("#[^#]+#")
+
+ sd.setPropertyValue("SearchRegularExpression", True)
+ sd.setPropertyValue("SearchWords", True)
+
+ return TextDocument.xTextDocument.findAll(sd)
+
def insertRoadmap(self):
self.addRoadmap()
self.insertRoadMapItems(
@@ -430,6 +457,7 @@ class FaxWizardDialogImpl(FaxWizardDialog):
self.BusinessFiles[1][selectedItemPos], False)
self.initializeElements()
self.setElements()
+ self.drawConstants()
def optPrivateFaxItemChanged(self):
FaxWizardDialogImpl.lstBusinessStylePos = None
diff --git a/wizards/com/sun/star/wizards/fax/FaxWizardDialogResources.py b/wizards/com/sun/star/wizards/fax/FaxWizardDialogResources.py
index c057a5afc6ed..ef60232fc7b0 100644
--- a/wizards/com/sun/star/wizards/fax/FaxWizardDialogResources.py
+++ b/wizards/com/sun/star/wizards/fax/FaxWizardDialogResources.py
@@ -25,6 +25,15 @@ class FaxWizardDialogResources(Resource):
RID_FAXWIZARDSALUTATION_START = 3290
RID_FAXWIZARDROADMAP_START = 3300
RID_RID_COMMON_START = 500
+
+ resToPlaceHolder = "#to#"
+ resFromPlaceHolder = "#from#"
+ resFaxconstPlaceHolder = "#faxconst#"
+ resTelconstPlaceHolder = "#telconst#"
+ resEmailconstPlaceHolder = "#emailconst#"
+ resConsist1PlaceHolder = "#consist1#"
+ resConsist2PlaceHolder = "#consist2#"
+ resConsist3PlaceHolder = "#consist3#"
def __init__(self, xmsf):
@@ -40,8 +49,6 @@ class FaxWizardDialogResources(Resource):
self.resFaxWizardDialog_title = self.getResText(
FaxWizardDialogResources.RID_FAXWIZARDDIALOG_START + 1)
- self.resLabel9_value = self.getResText(
- FaxWizardDialogResources.RID_FAXWIZARDDIALOG_START + 2)
self.resoptBusinessFax_value = self.getResText(
FaxWizardDialogResources.RID_FAXWIZARDDIALOG_START + 3)
self.resoptPrivateFax_value = self.getResText(
@@ -118,6 +125,26 @@ class FaxWizardDialogResources(Resource):
FaxWizardDialogResources.RID_FAXWIZARDDIALOG_START + 39)
self.resLabel2_value = self.getResText(
FaxWizardDialogResources.RID_FAXWIZARDDIALOG_START + 40)
+
+ #Create a Dictionary for the constants values.
+ self.dictConstants = {
+ FaxWizardDialogResources.resToPlaceHolder : self.getResText(
+ FaxWizardDialogResources.RID_FAXWIZARDDIALOG_START + 41),
+ FaxWizardDialogResources.resFromPlaceHolder : self.getResText(
+ FaxWizardDialogResources.RID_FAXWIZARDDIALOG_START + 42),
+ FaxWizardDialogResources.resFaxconstPlaceHolder : self.getResText(
+ FaxWizardDialogResources.RID_FAXWIZARDDIALOG_START + 43),
+ FaxWizardDialogResources.resTelconstPlaceHolder : self.getResText(
+ FaxWizardDialogResources.RID_FAXWIZARDDIALOG_START + 44),
+ FaxWizardDialogResources.resEmailconstPlaceHolder : self.getResText(
+ FaxWizardDialogResources.RID_FAXWIZARDDIALOG_START + 45),
+ FaxWizardDialogResources.resConsist1PlaceHolder : self.getResText(
+ FaxWizardDialogResources.RID_FAXWIZARDDIALOG_START + 46),
+ FaxWizardDialogResources.resConsist2PlaceHolder : self.getResText(
+ FaxWizardDialogResources.RID_FAXWIZARDDIALOG_START + 47),
+ FaxWizardDialogResources.resConsist3PlaceHolder : self.getResText(
+ FaxWizardDialogResources.RID_FAXWIZARDDIALOG_START + 48)}
+
self.loadRoadmapResources()
self.loadSalutationResources()
self.loadGreetingResources()