summaryrefslogtreecommitdiff
path: root/wizards
diff options
context:
space:
mode:
authorXisco Fauli <anistenis@gmail.com>2012-10-28 20:54:50 +0100
committerXisco Fauli <anistenis@gmail.com>2012-10-30 01:09:33 +0100
commit6fa0930ed4208e6fb13bc986616ad7441bbd4bd1 (patch)
treee9becd1f41fae09feaf28ec83fc3324617fd5b30 /wizards
parent4a11a47103fcbd7646234fc9565a409b8055507e (diff)
pyletter: Translate the templates at runtime
Change-Id: Ie0b149b4a8928e5b61153a6ed62b66d02f916f20
Diffstat (limited to 'wizards')
-rw-r--r--wizards/com/sun/star/wizards/fax/FaxWizardDialogImpl.py15
-rw-r--r--wizards/com/sun/star/wizards/fax/FaxWizardDialogResources.py27
-rw-r--r--wizards/com/sun/star/wizards/letter/CGLetter.py1
-rw-r--r--wizards/com/sun/star/wizards/letter/LetterWizardDialogImpl.py16
-rw-r--r--wizards/com/sun/star/wizards/letter/LetterWizardDialogResources.py5
-rw-r--r--wizards/com/sun/star/wizards/text/TextDocument.py61
6 files changed, 67 insertions, 58 deletions
diff --git a/wizards/com/sun/star/wizards/fax/FaxWizardDialogImpl.py b/wizards/com/sun/star/wizards/fax/FaxWizardDialogImpl.py
index 7bfbfba21845..70993e17c216 100644
--- a/wizards/com/sun/star/wizards/fax/FaxWizardDialogImpl.py
+++ b/wizards/com/sun/star/wizards/fax/FaxWizardDialogImpl.py
@@ -232,7 +232,7 @@ class FaxWizardDialogImpl(FaxWizardDialog):
def drawConstants(self):
'''Localise the template'''
- constRangeList = self.searchFillInItems(1)
+ constRangeList = TextDocument.searchFillInItems(1)
for i in xrange(constRangeList.Count):
item = constRangeList.getByIndex(i)
@@ -241,19 +241,6 @@ class FaxWizardDialogImpl(FaxWizardDialog):
"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(
diff --git a/wizards/com/sun/star/wizards/fax/FaxWizardDialogResources.py b/wizards/com/sun/star/wizards/fax/FaxWizardDialogResources.py
index 7cf37031a93b..a02835a0374f 100644
--- a/wizards/com/sun/star/wizards/fax/FaxWizardDialogResources.py
+++ b/wizards/com/sun/star/wizards/fax/FaxWizardDialogResources.py
@@ -25,15 +25,6 @@ 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):
super(FaxWizardDialogResources,self).__init__(xmsf,
@@ -121,24 +112,24 @@ 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(
+ "#to#" : self.getResText(
FaxWizardDialogResources.RID_FAXWIZARDDIALOG_START + 41),
- FaxWizardDialogResources.resFromPlaceHolder : self.getResText(
+ "#from#" : self.getResText(
FaxWizardDialogResources.RID_FAXWIZARDDIALOG_START + 42),
- FaxWizardDialogResources.resFaxconstPlaceHolder : self.getResText(
+ "#faxconst#" : self.getResText(
FaxWizardDialogResources.RID_FAXWIZARDDIALOG_START + 43),
- FaxWizardDialogResources.resTelconstPlaceHolder : self.getResText(
+ "#telconst#" : self.getResText(
FaxWizardDialogResources.RID_FAXWIZARDDIALOG_START + 44),
- FaxWizardDialogResources.resEmailconstPlaceHolder : self.getResText(
+ "#emailconst#" : self.getResText(
FaxWizardDialogResources.RID_FAXWIZARDDIALOG_START + 45),
- FaxWizardDialogResources.resConsist1PlaceHolder : self.getResText(
+ "#consist1#" : self.getResText(
FaxWizardDialogResources.RID_FAXWIZARDDIALOG_START + 46),
- FaxWizardDialogResources.resConsist2PlaceHolder : self.getResText(
+ "#consist2#" : self.getResText(
FaxWizardDialogResources.RID_FAXWIZARDDIALOG_START + 47),
- FaxWizardDialogResources.resConsist3PlaceHolder : self.getResText(
+ "#consist3#" : self.getResText(
FaxWizardDialogResources.RID_FAXWIZARDDIALOG_START + 48)}
#Create a dictionary for localising the private template
diff --git a/wizards/com/sun/star/wizards/letter/CGLetter.py b/wizards/com/sun/star/wizards/letter/CGLetter.py
index abed25080715..cf9bd76fe07f 100644
--- a/wizards/com/sun/star/wizards/letter/CGLetter.py
+++ b/wizards/com/sun/star/wizards/letter/CGLetter.py
@@ -28,7 +28,6 @@ class CGLetter(ConfigGroup):
self.cp_PaperCompanyAddressReceiverField = bool()
self.cp_PaperFooter = bool()
self.cp_PaperFooterHeight = float()
- self.cp_Norm = int()
self.cp_PrintCompanyLogo = bool()
self.cp_PrintCompanyAddressReceiverField = bool()
self.cp_PrintLetterSigns = bool()
diff --git a/wizards/com/sun/star/wizards/letter/LetterWizardDialogImpl.py b/wizards/com/sun/star/wizards/letter/LetterWizardDialogImpl.py
index 4f91d37291f7..bfdd6671ba4f 100644
--- a/wizards/com/sun/star/wizards/letter/LetterWizardDialogImpl.py
+++ b/wizards/com/sun/star/wizards/letter/LetterWizardDialogImpl.py
@@ -25,6 +25,7 @@ from ..common.FileAccess import FileAccess
from ..common.Configuration import Configuration
from ..common.SystemDialog import SystemDialog
from ..common.Desktop import Desktop
+from ..common.TextElement import TextElement
from ..ui.PathSelection import PathSelection
from ..ui.event.UnoDataAware import UnoDataAware
from ..ui.event.RadioDataAware import RadioDataAware
@@ -386,6 +387,7 @@ class LetterWizardDialogImpl(LetterWizardDialog):
self.initializeElements()
self.chkBusinessPaperItemChanged()
self.setElements(False)
+ self.drawConstants()
def lstPrivOfficialStyleItemChanged(self):
selectedItemPos = self.lstPrivOfficialStyle.SelectedItemPos
@@ -397,6 +399,7 @@ class LetterWizardDialogImpl(LetterWizardDialog):
self.initializeElements()
self.setPossibleSenderData(True)
self.setElements(False)
+ self.drawConstants()
def lstPrivateStyleItemChanged(self):
selectedItemPos = self.lstPrivateStyle.SelectedItemPos
@@ -981,7 +984,18 @@ class LetterWizardDialogImpl(LetterWizardDialog):
if self.optMakeChanges.State:
self.optMakeChangesItemChanged()
-
+
+ def drawConstants(self):
+ '''Localise the template'''
+ constRangeList = TextDocument.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 insertRoadmap(self):
self.addRoadmap()
diff --git a/wizards/com/sun/star/wizards/letter/LetterWizardDialogResources.py b/wizards/com/sun/star/wizards/letter/LetterWizardDialogResources.py
index 8e0a0162b2ba..64b45f76cc1b 100644
--- a/wizards/com/sun/star/wizards/letter/LetterWizardDialogResources.py
+++ b/wizards/com/sun/star/wizards/letter/LetterWizardDialogResources.py
@@ -208,6 +208,11 @@ class LetterWizardDialogResources(Resource):
self.reslblTitle6_value = \
self.getResText(
LetterWizardDialogResources.RID_LETTERWIZARDDIALOG_START + 58)
+
+ #Create a Dictionary for the constants values.
+ self.dictConstants = {
+ "#subjectconst#" : self.getResText(
+ LetterWizardDialogResources.RID_LETTERWIZARDDIALOG_START + 59)}
#Create a dictionary for localising the bussiness templates
self.dictBusinessTemplate = {
diff --git a/wizards/com/sun/star/wizards/text/TextDocument.py b/wizards/com/sun/star/wizards/text/TextDocument.py
index df0de967f971..0198d6d13735 100644
--- a/wizards/com/sun/star/wizards/text/TextDocument.py
+++ b/wizards/com/sun/star/wizards/text/TextDocument.py
@@ -34,13 +34,12 @@ from com.sun.star.beans.PropertyState import DIRECT_VALUE
class TextDocument(object):
- xTextDocument = None
-
def __init__(self, xMSF,listener=None,bShowStatusIndicator=None,
FrameName=None,_sPreviewURL=None,_moduleIdentifier=None,
_textDocument=None, xArgs=None):
self.xMSF = xMSF
+ self.xTextDocument = None
if listener is not None:
if FrameName is not None:
@@ -55,19 +54,19 @@ class TextDocument(object):
'''creates an instance of TextDocument by
loading a given URL as preview'''
self.xFrame = OfficeDocument.createNewFrame(xMSF, listener)
- TextDocument.xTextDocument = self.loadAsPreview(_sPreviewURL, True)
+ self.xTextDocument = self.loadAsPreview(_sPreviewURL, True)
elif xArgs is not None:
'''creates an instance of TextDocument
and creates a frame and loads a document'''
self.xDesktop = Desktop.getDesktop(xMSF);
self.xFrame = OfficeDocument.createNewFrame(xMSF, listener)
- TextDocument.xTextDocument = OfficeDocument.load(
+ self.xTextDocument = OfficeDocument.load(
xFrame, URL, "_self", xArgs);
self.xWindowPeer = xFrame.getComponentWindow()
- self.m_xDocProps = TextDocument.xTextDocument.DocumentProperties
+ self.m_xDocProps = self.xTextDocument.DocumentProperties
CharLocale = Helper.getUnoStructValue(
- TextDocument.xTextDocument, "CharLocale");
+ self.xTextDocument, "CharLocale");
return
else:
@@ -75,27 +74,27 @@ class TextDocument(object):
the desktop's current frame'''
self.xDesktop = Desktop.getDesktop(xMSF);
self.xFrame = self.xDesktop.getActiveFrame()
- TextDocument.xTextDocument = self.xFrame.getController().Model
+ self.xTextDocument = self.xFrame.getController().Model
elif _moduleIdentifier is not None:
try:
'''create the empty document, and set its module identifier'''
- TextDocument.xTextDocument = xMSF.createInstance(
+ self.xTextDocument = xMSF.createInstance(
"com.sun.star.text.TextDocument")
- TextDocument.xTextDocument.initNew()
- TextDocument.xTextDocument.setIdentifier(
+ self.xTextDocument.initNew()
+ self.xTextDocument.setIdentifier(
_moduleIdentifier.Identifier)
# load the document into a blank frame
xDesktop = Desktop.getDesktop(xMSF)
loadArgs = range(1)
loadArgs[0] = "Model"
loadArgs[0] = -1
- loadArgs[0] = TextDocument.xTextDocument
+ loadArgs[0] = self.xTextDocument
loadArgs[0] = DIRECT_VALUE
xDesktop.loadComponentFromURL(
"private:object", "_blank", 0, loadArgs)
# remember some things for later usage
- self.xFrame = TextDocument.xTextDocument.CurrentController.Frame
+ self.xFrame = self.xTextDocument.CurrentController.Frame
except Exception, e:
traceback.print_exc()
@@ -103,17 +102,17 @@ class TextDocument(object):
'''creates an instance of TextDocument
from a given XTextDocument'''
self.xFrame = _textDocument.CurrentController.Frame
- TextDocument.xTextDocument = _textDocument
+ self.xTextDocument = _textDocument
if bShowStatusIndicator:
self.showStatusIndicator()
self.init()
def init(self):
self.xWindowPeer = self.xFrame.getComponentWindow()
- self.m_xDocProps = TextDocument.xTextDocument.DocumentProperties
+ self.m_xDocProps = self.xTextDocument.DocumentProperties
self.CharLocale = Helper.getUnoStructValue(
- TextDocument.xTextDocument, "CharLocale")
- self.xText = TextDocument.xTextDocument.Text
+ self.xTextDocument, "CharLocale")
+ self.xText = self.xTextDocument.Text
def showStatusIndicator(self):
self.xProgressBar = self.xFrame.createStatusIndicator()
@@ -140,24 +139,24 @@ class TextDocument(object):
loadValues[2].Name = "Preview"
loadValues[2].Value = True
- TextDocument.xTextDocument = OfficeDocument.load(
+ self.xTextDocument = OfficeDocument.load(
self.xFrame, sDefaultTemplate, "_self", loadValues)
self.DocSize = self.getPageSize()
- myViewHandler = ViewHandler(TextDocument.xTextDocument, TextDocument.xTextDocument)
+ myViewHandler = ViewHandler(self.xTextDocument, self.xTextDocument)
try:
myViewHandler.setViewSetting(
"ZoomType", ENTIRE_PAGE)
except Exception, e:
traceback.print_exc()
- myFieldHandler = TextFieldHandler(self.xMSF, TextDocument.xTextDocument)
+ myFieldHandler = TextFieldHandler(self.xMSF, self.xTextDocument)
myFieldHandler.updateDocInfoFields()
- return TextDocument.xTextDocument
+ return self.xTextDocument
def getPageSize(self):
try:
- xNameAccess = TextDocument.xTextDocument.StyleFamilies
+ xNameAccess = self.xTextDocument.StyleFamilies
xPageStyleCollection = xNameAccess.getByName("PageStyles")
xPageStyle = xPageStyleCollection.getByName("First Page")
return Helper.getUnoPropertyValue(xPageStyle, "Size")
@@ -173,7 +172,7 @@ class TextDocument(object):
return xTextCursor
def refresh(self):
- TextDocument.xTextDocument.refresh()
+ self.xTextDocument.refresh()
'''
This method sets the Author of a Wizard-generated template correctly
@@ -197,10 +196,10 @@ class TextDocument(object):
day = time.strftime("%d", now)
dateObject = dateTimeObject(int(year), int(month), int(day))
- du = Helper.DateUtils(self.xMSF, TextDocument.xTextDocument)
+ du = Helper.DateUtils(self.xMSF, self.xTextDocument)
ff = du.getFormat(DATE_SYS_DDMMYY)
myDate = du.format(ff, dateObject)
- xDocProps2 = TextDocument.xTextDocument.DocumentProperties
+ xDocProps2 = self.xTextDocument.DocumentProperties
xDocProps2.Author = fullname
xDocProps2.ModifiedBy = fullname
description = xDocProps2.Description
@@ -238,3 +237,17 @@ class TextDocument(object):
return xTD.TextFrames.getByName(sFrameName)
return None
+
+ @classmethod
+ def searchFillInItems(self, typeSearch):
+ sd = self.xTextDocument.createSearchDescriptor()
+
+ if typeSearch == 0:
+ sd.setSearchString("<[^>]+>")
+ elif typeSearch == 1:
+ sd.setSearchString("#[^#]+#")
+
+ sd.setPropertyValue("SearchRegularExpression", True)
+ sd.setPropertyValue("SearchWords", True)
+
+ return self.xTextDocument.findAll(sd)