diff options
author | Xisco Fauli <anistenis@gmail.com> | 2011-07-04 15:10:53 +0200 |
---|---|---|
committer | Xisco Fauli <anistenis@gmail.com> | 2011-07-04 15:10:53 +0200 |
commit | 71036e4051fe288abbba1c968cf72922d55eed45 (patch) | |
tree | 0a2062b0326363bcf24ff55b39ede9989cbf792d /wizards | |
parent | apply python style and fix some minor things (diff) | |
download | core-71036e4051fe288abbba1c968cf72922d55eed45.tar.gz core-71036e4051fe288abbba1c968cf72922d55eed45.zip |
Handle the letterhead layouts properly
Diffstat (limited to 'wizards')
3 files changed, 106 insertions, 102 deletions
diff --git a/wizards/com/sun/star/wizards/letter/LetterDocument.py b/wizards/com/sun/star/wizards/letter/LetterDocument.py index b5a172f8808c..517d0c669adb 100644 --- a/wizards/com/sun/star/wizards/letter/LetterDocument.py +++ b/wizards/com/sun/star/wizards/letter/LetterDocument.py @@ -156,104 +156,106 @@ class LetterDocument(TextDocument): except Exception: traceback.print_exc() - class BusinessPaperObject(object): +class BusinessPaperObject(object): - xFrame = None - - def __init__(self, FrameText, Width, Height, XPos, YPos): - self.iWidth = Width - self.iHeight = Height - self.iXPos = XPos - self.iYPos = YPos - try: - LetterDocument.BusinessPaperObject.xFrame = \ - TextDocument.xTextDocument.createInstance( - "com.sun.star.text.TextFrame") - self.setFramePosition() - Helper.setUnoPropertyValue( - LetterDocument.BusinessPaperObject.xFrame, - "AnchorType", AT_PAGE) - Helper.setUnoPropertyValue( - LetterDocument.BusinessPaperObject.xFrame, - "SizeType", FIX) + def __init__(self, FrameText, Width, Height, XPos, YPos): + self.iWidth = Width + self.iHeight = Height + self.iXPos = XPos + self.iYPos = YPos + self.xFrame = None + try: + self.xFrame = \ + TextDocument.xTextDocument.createInstance( + "com.sun.star.text.TextFrame") + self.setFramePosition() + Helper.setUnoPropertyValue( + self.xFrame, + "AnchorType", AT_PAGE) + Helper.setUnoPropertyValue( + self.xFrame, + "SizeType", FIX) - Helper.setUnoPropertyValue( - LetterDocument.BusinessPaperObject.xFrame, - "TextWrap", THROUGHT) - Helper.setUnoPropertyValue( - LetterDocument.BusinessPaperObject.xFrame, - "Opaque", True); - Helper.setUnoPropertyValue( - LetterDocument.BusinessPaperObject.xFrame, - "BackColor", 15790320) + Helper.setUnoPropertyValue( + self.xFrame, + "TextWrap", THROUGHT) + Helper.setUnoPropertyValue( + self.xFrame, + "Opaque", True); + Helper.setUnoPropertyValue( + self.xFrame, + "BackColor", 15790320) - myBorder = BorderLine() - myBorder.OuterLineWidth = 0 - Helper.setUnoPropertyValue( - LetterDocument.BusinessPaperObject.xFrame, - "LeftBorder", myBorder) - Helper.setUnoPropertyValue( - LetterDocument.BusinessPaperObject.xFrame, - "RightBorder", myBorder) - Helper.setUnoPropertyValue( - LetterDocument.BusinessPaperObject.xFrame, - "TopBorder", myBorder) - Helper.setUnoPropertyValue( - LetterDocument.BusinessPaperObject.xFrame, - "BottomBorder", myBorder) - Helper.setUnoPropertyValue( - LetterDocument.BusinessPaperObject.xFrame, - "Print", False) + myBorder = BorderLine() + myBorder.OuterLineWidth = 0 + Helper.setUnoPropertyValue( + self.xFrame, + "LeftBorder", myBorder) + Helper.setUnoPropertyValue( + self.xFrame, + "RightBorder", myBorder) + Helper.setUnoPropertyValue( + self.xFrame, + "TopBorder", myBorder) + Helper.setUnoPropertyValue( + self.xFrame, + "BottomBorder", myBorder) + Helper.setUnoPropertyValue( + self.xFrame, + "Print", False) - xTextCursor = \ - TextDocument.xTextDocument.Text.createTextCursor() - xTextCursor.gotoEnd(True) - xText = TextDocument.xTextDocument.Text - xText.insertTextContent( - xTextCursor, LetterDocument.BusinessPaperObject.xFrame, - False) + xTextCursor = \ + TextDocument.xTextDocument.Text.createTextCursor() + xTextCursor.gotoEnd(True) + xText = TextDocument.xTextDocument.Text + xText.insertTextContent( + xTextCursor, self.xFrame, + False) - xFrameText = LetterDocument.BusinessPaperObject.xFrame.Text - xFrameCursor = xFrameText.createTextCursor() - xFrameCursor.setPropertyValue("CharWeight", BOLD) - xFrameCursor.setPropertyValue("CharColor", 16777215) - xFrameCursor.setPropertyValue("CharFontName", "Albany") - xFrameCursor.setPropertyValue("CharHeight", 18) + xFrameText = self.xFrame.Text + xFrameCursor = xFrameText.createTextCursor() + xFrameCursor.setPropertyValue("CharWeight", BOLD) + xFrameCursor.setPropertyValue("CharColor", 16777215) + xFrameCursor.setPropertyValue("CharFontName", "Albany") + xFrameCursor.setPropertyValue("CharHeight", 18) - xFrameText.insertString(xFrameCursor, FrameText, False) - except Exception: - traceback.print_exc() + xFrameText.insertString(xFrameCursor, FrameText, False) + except Exception: + traceback.print_exc() - def setFramePosition(self): + def setFramePosition(self): + try: Helper.setUnoPropertyValue( - LetterDocument.BusinessPaperObject.xFrame, + self.xFrame, "HoriOrient", NONEHORI) Helper.setUnoPropertyValue( - LetterDocument.BusinessPaperObject.xFrame, + self.xFrame, "VertOrient", NONEVERT) Helper.setUnoPropertyValue( - LetterDocument.BusinessPaperObject.xFrame, + self.xFrame, PropertyNames.PROPERTY_HEIGHT, self.iHeight) Helper.setUnoPropertyValue( - LetterDocument.BusinessPaperObject.xFrame, + self.xFrame, PropertyNames.PROPERTY_WIDTH, self.iWidth) Helper.setUnoPropertyValue( - LetterDocument.BusinessPaperObject.xFrame, + self.xFrame, "HoriOrientPosition", self.iXPos) Helper.setUnoPropertyValue( - LetterDocument.BusinessPaperObject.xFrame, + self.xFrame, "VertOrientPosition", self.iYPos) Helper.setUnoPropertyValue( - LetterDocument.BusinessPaperObject.xFrame, + self.xFrame, "HoriOrientRelation", PAGE_FRAME) Helper.setUnoPropertyValue( - LetterDocument.BusinessPaperObject.xFrame, + self.xFrame, "VertOrientRelation", PAGE_FRAME) + except Exception: + traceback.print_exc() - def removeFrame(self): - if LetterDocument.BusinessPaperObject.xFrame is not None: - try: - TextDocument.xTextDocument.Text.removeTextContent( - LetterDocument.BusinessPaperObject.xFrame) - except Exception: - traceback.print_exc() + def removeFrame(self): + if self.xFrame is not None: + try: + TextDocument.xTextDocument.Text.removeTextContent( + self.xFrame) + except Exception: + traceback.print_exc() diff --git a/wizards/com/sun/star/wizards/letter/LetterWizardDialogImpl.py b/wizards/com/sun/star/wizards/letter/LetterWizardDialogImpl.py index f1eb6af81293..d24728612947 100644 --- a/wizards/com/sun/star/wizards/letter/LetterWizardDialogImpl.py +++ b/wizards/com/sun/star/wizards/letter/LetterWizardDialogImpl.py @@ -405,39 +405,39 @@ class LetterWizardDialogImpl(LetterWizardDialog): self.activate() def numLogoHeightTextChanged(self): - self.BusCompanyLogo.iHeight = numLogoHeight.Value * 1000 + self.BusCompanyLogo.iHeight = int(self.numLogoHeight.Value * 1000) self.BusCompanyLogo.setFramePosition() def numLogoWidthTextChanged(self): - self.BusCompanyLogo.iWidth = numLogoWidth.Value * 1000 + self.BusCompanyLogo.iWidth = int(self.numLogoWidth.Value * 1000) self.BusCompanyLogo.setFramePosition() def numLogoXTextChanged(self): - self.BusCompanyLogo.iXPos = numLogoX.Value * 1000 + self.BusCompanyLogo.iXPos = int(self.numLogoX.Value * 1000) self.BusCompanyLogo.setFramePosition() def numLogoYTextChanged(self): - self.BusCompanyLogo.iYPos = numLogoY.Value * 1000 + self.BusCompanyLogo.iYPos = int(self.numLogoY.Value * 1000) self.BusCompanyLogo.setFramePosition() def numAddressWidthTextChanged(self): - self.BusCompanyAddress.iWidth = self.numAddressWidth.Value * 1000 + self.BusCompanyAddress.iWidth = int(self.numAddressWidth.Value * 1000) self.BusCompanyAddress.setFramePosition() def numAddressXTextChanged(self): - self.BusCompanyAddress.iXPos = self.numAddressX.Value * 1000 + self.BusCompanyAddress.iXPos = int(self.numAddressX.Value * 1000) self.BusCompanyAddress.setFramePosition() def numAddressYTextChanged(self): - self.BusCompanyAddress.iYPos = self.numAddressY.Value * 1000 + self.BusCompanyAddress.iYPos = int(self.numAddressY.Value * 1000) self.BusCompanyAddress.setFramePosition() def numAddressHeightTextChanged(self): - self.BusCompanyAddress.iHeight = self.numAddressHeight.Value * 1000 + self.BusCompanyAddress.iHeight = int(self.numAddressHeight.Value * 1000) self.BusCompanyAddress.setFramePosition() def numFooterHeightTextChanged(self): - self.BusFooter.iHeight = self.numFooterHeight.Value * 1000 + self.BusFooter.iHeight = int(self.numFooterHeight.Value * 1000) self.BusFooter.iYPos = \ self.myLetterDoc.DocSize.Height - self.BusFooter.iHeight self.BusFooter.setFramePosition() @@ -449,9 +449,10 @@ class LetterWizardDialogImpl(LetterWizardDialog): if self.numLogoHeight.Value == 0: self.numLogoHeight.Value = 0.1 - self.BusCompanyLogo = LetterDocument.BusinessPaperObject( - "Company Logo", self.numLogoWidth.Value * 1000, - self.numLogoHeight.Value * 1000, self.numLogoX.Value * 1000, + self.BusCompanyLogo = BusinessPaperObject( + "Company Logo", int(self.numLogoWidth.Value * 1000), + int(self.numLogoHeight.Value * 1000), + int(self.numLogoX.Value * 1000), self.numLogoY.Value * 1000) self.setControlProperty( "numLogoHeight", PropertyNames.PROPERTY_ENABLED, True) @@ -500,10 +501,11 @@ class LetterWizardDialogImpl(LetterWizardDialog): if self.numAddressHeight.Value == 0: self.numAddressHeight.Value = 0.1 - self.BusCompanyAddress = LetterDocument.BusinessPaperObject( - "Company Address", self.numAddressWidth.Value * 1000, - self.numAddressHeight.Value * 1000, - self.numAddressX.Value * 1000, self.numAddressY.Value * 1000) + self.BusCompanyAddress = BusinessPaperObject( + "Company Address", int(self.numAddressWidth.Value * 1000), + int(self.numAddressHeight.Value * 1000), + int(self.numAddressX.Value * 1000), + int(self.numAddressY.Value * 1000)) self.setControlProperty( "self.numAddressHeight", PropertyNames.PROPERTY_ENABLED, True) self.setControlProperty( @@ -571,10 +573,9 @@ class LetterWizardDialogImpl(LetterWizardDialog): iFrameY = int(Helper.getUnoPropertyValue( xReceiverFrame, "VertOrientPosition")) iReceiverHeight = int(0.5 * 1000) - self.BusCompanyAddressReceiver = \ - LetterDocument.BusinessPaperObject( - " ", iFrameWidth, iReceiverHeight, iFrameX, - iFrameY - iReceiverHeight) + self.BusCompanyAddressReceiver = BusinessPaperObject( + " ", iFrameWidth, iReceiverHeight, iFrameX, + iFrameY - iReceiverHeight) self.setPossibleAddressReceiver(False) except NoSuchElementException: traceback.print_exc() @@ -601,11 +602,11 @@ class LetterWizardDialogImpl(LetterWizardDialog): if self.numFooterHeight.Value == 0: self.numFooterHeight.Value = 0.1 - self.BusFooter = LetterDocument.BusinessPaperObject( + self.BusFooter = BusinessPaperObject( "Footer", self.myLetterDoc.DocSize.Width, - self.numFooterHeight.Value * 1000, 0, - self.myLetterDoc.DocSize.Height - \ - (self.numFooterHeight.Value * 1000)) + int(self.numFooterHeight.Value * 1000), 0, + int(self.myLetterDoc.DocSize.Height - \ + (self.numFooterHeight.Value * 1000))) self.setControlProperty( "self.numFooterHeight", PropertyNames.PROPERTY_ENABLED, True) self.setControlProperty( @@ -619,7 +620,7 @@ class LetterWizardDialogImpl(LetterWizardDialog): "self.numFooterHeight", PropertyNames.PROPERTY_ENABLED, False) self.setControlProperty( "lblFooterHeight", PropertyNames.PROPERTY_ENABLED, False) - setPossibleFooter(True) + self.setPossibleFooter(True) def chkUseLogoItemChanged(self): try: diff --git a/wizards/com/sun/star/wizards/text/TextDocument.py b/wizards/com/sun/star/wizards/text/TextDocument.py index ebff4a4c1fba..9a4e741cb14d 100644 --- a/wizards/com/sun/star/wizards/text/TextDocument.py +++ b/wizards/com/sun/star/wizards/text/TextDocument.py @@ -251,6 +251,7 @@ class TextDocument(object): def removeTextContent(self, oTextContent): try: self.xText.removeTextContent(oxTextContent) + print "remove" return True except NoSuchElementException, e: traceback.print_exc() |