diff options
author | Xisco Fauli <anistenis@gmail.com> | 2011-06-20 02:42:24 +0200 |
---|---|---|
committer | Xisco Fauli <anistenis@gmail.com> | 2011-06-20 02:42:24 +0200 |
commit | 7173989ae6a8f4bf71191021a35ecd075245cc6a (patch) | |
tree | 1e0e90c58086a73080f30097a2bbf41e6dcdc156 /wizards | |
parent | Avoid crashing after finnish button is clicked (diff) | |
download | core-7173989ae6a8f4bf71191021a35ecd075245cc6a.tar.gz core-7173989ae6a8f4bf71191021a35ecd075245cc6a.zip |
a bit of optimitation
Diffstat (limited to 'wizards')
10 files changed, 50 insertions, 72 deletions
diff --git a/wizards/com/sun/star/wizards/common/ConfigGroup.py b/wizards/com/sun/star/wizards/common/ConfigGroup.py index 2cd261831dd9..a5824e803f81 100644 --- a/wizards/com/sun/star/wizards/common/ConfigGroup.py +++ b/wizards/com/sun/star/wizards/common/ConfigGroup.py @@ -16,13 +16,14 @@ class ConfigGroup(ConfigNode): def writeField(self, field, configView, prefix): propertyName = field[len(prefix):] field = getattr(self,field) - fieldType = type(field) + if isinstance(field, ConfigNode): pass - #COMMENTED + #print configView #childView = Configuration.addConfigNode(configView, propertyName) #self.writeConfiguration(childView, prefix) else: + #print type(field) Configuration.Set(self.convertValue(field), propertyName, configView) diff --git a/wizards/com/sun/star/wizards/common/FileAccess.py b/wizards/com/sun/star/wizards/common/FileAccess.py index 6f8e16bb2880..8c58091c75c9 100644 --- a/wizards/com/sun/star/wizards/common/FileAccess.py +++ b/wizards/com/sun/star/wizards/common/FileAccess.py @@ -109,15 +109,9 @@ class FileAccess(object): Template_user = xPathInterface.getPropertyValue( sPath + "_user") if type(Template_internal) is not types.InstanceType: - if isinstance(Template_internal,tuple): - ReadPaths = ReadPaths + Template_internal - else: - ReadPaths = ReadPaths + (Template_internal,) + ReadPaths = ReadPaths + Template_internal if type(Template_user) is not types.InstanceType: - if isinstance(Template_user,tuple): - ReadPaths = ReadPaths + Template_user - else: - ReadPaths = ReadPaths + (Template_internal,) + ReadPaths = ReadPaths + Template_user ReadPaths = ReadPaths + (Template_writable,) if sType.lower() == "user": ResultPath = Template_writable diff --git a/wizards/com/sun/star/wizards/common/Helper.py b/wizards/com/sun/star/wizards/common/Helper.py index 32cdb72a22d1..f2c6d69445cd 100644 --- a/wizards/com/sun/star/wizards/common/Helper.py +++ b/wizards/com/sun/star/wizards/common/Helper.py @@ -42,14 +42,11 @@ class Helper(object): @classmethod def getPropertyValue(self, CurPropertyValue, PropertyName): - MaxCount = len(CurPropertyValue) - i = 0 - while i < MaxCount: - if CurPropertyValue[i] is not None: - if CurPropertyValue[i].Name.equals(PropertyName): - return CurPropertyValue[i].Value - - i += 1 + for i in CurPropertyValue: + if i is not None: + if i.Name == PropertyName: + return i.Value + raise RuntimeException() @classmethod @@ -117,11 +114,9 @@ class Helper(object): uno.invoke(xMultiPSetLst, "setPropertyValues", (PropertyNames, PropertyValues)) else: - i = 0 - while i < len(PropertyNames): + for i in xrange(len(PropertyNames)): self.setUnoPropertyValue(xMultiPSetLst, PropertyNames[i], PropertyValues[i]) - i += 1 except Exception, e: traceback.print_exc() diff --git a/wizards/com/sun/star/wizards/common/NumberFormatter.py b/wizards/com/sun/star/wizards/common/NumberFormatter.py index eff9f16c220c..a3deb173022f 100644 --- a/wizards/com/sun/star/wizards/common/NumberFormatter.py +++ b/wizards/com/sun/star/wizards/common/NumberFormatter.py @@ -59,7 +59,6 @@ class NumberFormatter(object): Type, Locale()) def convertNumberToString(self, _nkey, _dblValue, _xNumberFormatter=None): - print "yepa" if _xNumberFormatter is None: return self.xNumberFormatter.convertNumberToString( _nkey, _dblValue) diff --git a/wizards/com/sun/star/wizards/fax/FaxWizardDialogImpl.py b/wizards/com/sun/star/wizards/fax/FaxWizardDialogImpl.py index 58ee5ac8a3d3..32ce4b80859a 100644 --- a/wizards/com/sun/star/wizards/fax/FaxWizardDialogImpl.py +++ b/wizards/com/sun/star/wizards/fax/FaxWizardDialogImpl.py @@ -523,6 +523,9 @@ class FaxWizardDialogImpl(FaxWizardDialog): PropertyNames.PROPERTY_ENABLED, True) self.setControlProperty("txtSenderFax", PropertyNames.PROPERTY_ENABLED, True) + + self.myFieldHandler = TextFieldHandler(self.myFaxDoc.xMSF, + self.xTextDocument) self.txtSenderNameTextChanged() self.txtSenderStreetTextChanged() self.txtSenderPostCodeTextChanged() @@ -545,39 +548,28 @@ class FaxWizardDialogImpl(FaxWizardDialog): self.bEditTemplate = True def txtSenderNameTextChanged(self): - myFieldHandler = TextFieldHandler(self.myFaxDoc.xMSF, - self.xTextDocument) - myFieldHandler.changeUserFieldContent("Company", - self.txtSenderName.Text) + self.myFieldHandler.changeUserFieldContent( + "Company", self.txtSenderName.Text) def txtSenderStreetTextChanged(self): - myFieldHandler = TextFieldHandler(self.myFaxDoc.xMSF, - self.xTextDocument) - myFieldHandler.changeUserFieldContent("Street", - self.txtSenderStreet.Text) + self.myFieldHandler.changeUserFieldContent( + "Street", self.txtSenderStreet.Text) def txtSenderCityTextChanged(self): - myFieldHandler = TextFieldHandler(self.myFaxDoc.xMSF, - self.xTextDocument) - myFieldHandler.changeUserFieldContent("City", - self.txtSenderCity.Text) + self.myFieldHandler.changeUserFieldContent( + "City", self.txtSenderCity.Text) def txtSenderPostCodeTextChanged(self): - myFieldHandler = TextFieldHandler(self.myFaxDoc.xMSF, - self.xTextDocument) - myFieldHandler.changeUserFieldContent("PostCode", - self.txtSenderPostCode.Text) + self.myFieldHandler.changeUserFieldContent( + "PostCode", self.txtSenderPostCode.Text) def txtSenderStateTextChanged(self): - myFieldHandler = TextFieldHandler(self.myFaxDoc.xMSF, - self.xTextDocument) - myFieldHandler.changeUserFieldContent(PropertyNames.PROPERTY_STATE, - self.txtSenderState.Text) + self.myFieldHandler.changeUserFieldContent( + PropertyNames.PROPERTY_STATE, self.txtSenderState.Text) def txtSenderFaxTextChanged(self): - myFieldHandler = TextFieldHandler(self.myFaxDoc.xMSF, - self.xTextDocument) - myFieldHandler.changeUserFieldContent("Fax", self.txtSenderFax.Text) + self.myFieldHandler.changeUserFieldContent( + "Fax", self.txtSenderFax.Text) #switch Elements on/off -------------------------------------------------- diff --git a/wizards/com/sun/star/wizards/text/TextDocument.py b/wizards/com/sun/star/wizards/text/TextDocument.py index c432ee7a1902..fb97048d63b5 100644 --- a/wizards/com/sun/star/wizards/text/TextDocument.py +++ b/wizards/com/sun/star/wizards/text/TextDocument.py @@ -124,12 +124,15 @@ class TextDocument(object): mode in order to avoid the 'do u want to save' box''' if self.xTextDocument is not None: try: - self.xTextDocument.setModified(False) + self.xTextDocument.Modified = False except PropertyVetoException, e1: traceback.print_exc() + self.xTextDocument = OfficeDocument.load( self.xFrame, sDefaultTemplate, "_self", loadValues) + self.DocSize = self.getPageSize() + myViewHandler = ViewHandler(self.xTextDocument, self.xTextDocument) try: myViewHandler.setViewSetting( @@ -142,7 +145,7 @@ class TextDocument(object): def getPageSize(self): try: - xNameAccess = self.xTextDocument.getStyleFamilies() + xNameAccess = self.xTextDocument.StyleFamilies xPageStyleCollection = xNameAccess.getByName("PageStyles") xPageStyle = xPageStyleCollection.getByName("First Page") return Helper.getUnoPropertyValue(xPageStyle, "Size") diff --git a/wizards/com/sun/star/wizards/text/TextFieldHandler.py b/wizards/com/sun/star/wizards/text/TextFieldHandler.py index d9e3ed8428ff..22f94a3866fd 100644 --- a/wizards/com/sun/star/wizards/text/TextFieldHandler.py +++ b/wizards/com/sun/star/wizards/text/TextFieldHandler.py @@ -14,6 +14,7 @@ class TextFieldHandler(object): ''' xTextFieldsSupplierAux = None + arrayTextFields = None dictTextFields = None def __init__(self, xMSF, xTextDocument): @@ -73,10 +74,12 @@ class TextFieldHandler(object): try: if self.xTextFieldsSupplier.TextFields.hasElements(): TextFieldHandler.dictTextFields = {} + TextFieldHandler.arrayTextFields = [] xEnum = \ self.xTextFieldsSupplier.TextFields.createEnumeration() while xEnum.hasMoreElements(): oTextField = xEnum.nextElement() + TextFieldHandler.arrayTextFields.append(oTextField) xPropertySet = oTextField.TextFieldMaster if len(xPropertySet.Name) is not 0: TextFieldHandler.dictTextFields[xPropertySet.Name] = \ @@ -118,47 +121,41 @@ class TextFieldHandler(object): def updateDocInfoFields(self): try: - xEnum = self.xTextFieldsSupplier.TextFields.createEnumeration() - while xEnum.hasMoreElements(): - oTextField = xEnum.nextElement() - if oTextField.supportsService( + for i in TextFieldHandler.arrayTextFields: + if i.supportsService( "com.sun.star.text.TextField.ExtendedUser"): - oTextField.update() + i.update() - if oTextField.supportsService( + if i.supportsService( "com.sun.star.text.TextField.User"): - oTextField.update() + i.update() except Exception, e: traceback.print_exc() def updateDateFields(self): try: - xEnum = self.xTextFieldsSupplier.TextFields.createEnumeration() now = time.localtime(time.time()) dt = DateTime() dt.Day = time.strftime("%d", now) dt.Year = time.strftime("%Y", now) dt.Month = time.strftime("%m", now) dt.Month += 1 - while xEnum.hasMoreElements(): - oTextField = xEnum.nextElement() - if oTextField.supportsService( + for i in TextFieldHandler.arrayTextFields: + if i.supportsService( "com.sun.star.text.TextField.DateTime"): - oTextField.setPropertyValue("IsFixed", False) - oTextField.setPropertyValue("DateTimeValue", dt) + i.setPropertyValue("IsFixed", False) + i.setPropertyValue("DateTimeValue", dt) except Exception, e: traceback.print_exc() def fixDateFields(self, _bSetFixed): try: - xEnum = self.xTextFieldsSupplier.TextFields.createEnumeration() - while xEnum.hasMoreElements(): - oTextField = xEnum.nextElement() - if oTextField.supportsService( + for i in TextFieldHandler.arrayTextFields: + if i.supportsService( "com.sun.star.text.TextField.DateTime"): - oTextField.setPropertyValue("IsFixed", _bSetFixed) + i.setPropertyValue("IsFixed", _bSetFixed) except Exception, e: traceback.print_exc() diff --git a/wizards/com/sun/star/wizards/ui/PathSelection.py b/wizards/com/sun/star/wizards/ui/PathSelection.py index b8487990cead..b7ea23c48d38 100644 --- a/wizards/com/sun/star/wizards/ui/PathSelection.py +++ b/wizards/com/sun/star/wizards/ui/PathSelection.py @@ -89,8 +89,6 @@ class PathSelection(object): def triggerPathPicker(self): try: - print self.iTransferMode - print self.TransferMode.SAVE if self.iTransferMode == self.TransferMode.SAVE: if self.iDialogType == self.DialogTypes.FOLDER: #TODO: write code for picking a folder for saving diff --git a/wizards/com/sun/star/wizards/ui/UnoDialog.py b/wizards/com/sun/star/wizards/ui/UnoDialog.py index baacd58c5c84..fc63ddbc41c6 100644 --- a/wizards/com/sun/star/wizards/ui/UnoDialog.py +++ b/wizards/com/sun/star/wizards/ui/UnoDialog.py @@ -47,7 +47,7 @@ class UnoDialog(object): def setControlProperty(self, ControlName, PropertyName, PropertyValue): try: if PropertyValue is not None: - if self.xDialogModel.hasByName(ControlName) == False: + if not self.xDialogModel.hasByName(ControlName): return xPSet = self.xDialogModel.getByName(ControlName) if isinstance(PropertyValue,bool): diff --git a/wizards/com/sun/star/wizards/ui/WizardDialog.py b/wizards/com/sun/star/wizards/ui/WizardDialog.py index 874f5407e715..377cffd7a2d6 100644 --- a/wizards/com/sun/star/wizards/ui/WizardDialog.py +++ b/wizards/com/sun/star/wizards/ui/WizardDialog.py @@ -161,14 +161,13 @@ class WizardDialog(UnoDialog2): def getRoadmapItemByID(self, _ID): try: - i = 0 - while i < self.oRoadmap.Count: - CurRoadmapItem = self.oRoadmap.getByIndex(i) + getByIndex = self.oRoadmap.getByIndex + for i in xrange(self.oRoadmap.Count): + CurRoadmapItem = getByIndex(i) CurID = int(Helper.getUnoPropertyValue(CurRoadmapItem, "ID")) if CurID == _ID: return CurRoadmapItem - i += 1 return None except UnoException, exception: traceback.print_exc() |