def draw_house_window_frame(doc): '''French windows - 5 x vertical and 4 x horizontal lines.''' # Draw the vertical lines for i in range(5): shape_position = Point() shape_position.X = 16000 + i * 1000 shape_position.Y = 10000 shape_size = Size() shape_size.Width= 0 shape_size.Height= 3000 line = make_line_shape(doc, shape_position, shape_size) line.LineColor = 0xffffff line.LineWidth = 100 doc.DrawPages.page1.add(line) # Draw the horizontal lines for i in range(4): shape_position = Point() shape_position.X = 16000 shape_position.Y = 10000 + i * 1000 shape_size = Size() shape_size.Width= 4000 shape_size.Height= 0 line = make_line_shape(doc, shape_position, shape_size) line.LineColor = 0xffffff line.LineWidth = 100 doc.DrawPages.page1.add(line)
def draw_sign_uni(doc): '''Add sign. Warning: Steps below must be performed in order''' # Step1: Create the text box shape shape_position = Point() shape_position.X = 10000 shape_position.Y = 10000 shape_size = Size() shape_size.Width= 4000 shape_size.Height= 5000 textbox = make_text_shape(doc, shape_position, shape_size) # Step 2: Add the shape to the draw document doc.DrawPages.page1.add(textbox) # Step 3: get the object getText() and pass the heading string textboxtext = textbox.getText() textboxtext.setString("Waikato\nUniversity\n\nMS4.G.02") # Make modifications to the text textboxtext.CharFontName = "FreeSans" textboxtext.CharHeight = 16 textboxtext.CharColor = 0xffffff textboxtext.CharWeight = 200 textboxtext.FillStyle = NONE #textboxtext.FillBackground = 0xffffff #textboxtext.FillTransparence = 0 textboxtext.LineStyle = lsNONE textboxtext.LineColor = 0x000000 #textboxtext.LineTransparence = 0 #textboxtext.LineWidth = 80 #textboxtext.TextHorizontalAdjust = CENTER textboxtext.ParaAdjust = paCENTER #<-- Cant use CENTER need paCENTER
def draw_sign_next_meeting(doc): '''Add sign. Warning: Steps below must be performed in order''' # Step1: Create the text box shape shape_position = Point() shape_position.X = 14500 shape_position.Y = 13300 shape_size = Size() shape_size.Width= 7000 shape_size.Height= 2000 textbox = make_text_shape(doc, shape_position, shape_size) # Step 2: Add the shape to the draw document doc.DrawPages.page1.add(textbox) # Step 3: get the object getText() and pass the heading string textboxtext = textbox.getText() textboxtext.setString("Next Meeting:\n7pm Monday\n11 April 2016") # Make modifications to the text textboxtext.CharFontName = "FreeSans" textboxtext.CharHeight = 18 textboxtext.CharColor = 0x000000 textboxtext.CharWeight = 200 textboxtext.FillStyle = SOLID #<-- FillStyle is using SOLID textboxtext.FillBackground = 0xffffff textboxtext.FillTransparence = 0 textboxtext.LineStyle = lsSOLID #<-- Cant use SOLID. Used for FillStyle textboxtext.LineColor = 0x000000 textboxtext.LineTransparence = 0 textboxtext.LineWidth = 80 textboxtext.TextHorizontalAdjust = CENTER
def draw_text(doc): '''Add message. Warning: Steps below must be performed in order''' # Step1: Create the text box shape shape_position = Point() shape_position.X = 1500 shape_position.Y = 18200 shape_size = Size() shape_size.Width= 24000 shape_size.Height= 1000 textbox = make_text_shape(doc, shape_position, shape_size) # Step 2: Add the shape to the draw document doc.DrawPages.page1.add(textbox) # Step 3: get the object getText() and pass the heading string textboxtext = textbox.getText() label = ("The python program establishes a connection to libreoffice " \ "and creates a draw document. The draw document is set to A4 " \ "landscape. Drawing shapes are added to the document.") textboxtext.setString(label) # Make modifications to the text #textboxtext.TextAutoGrowHeight = True #textboxtext.TextAutoGrowWidth = True #textboxtext.CharFontName = "Times New Roman" textboxtext.CharFontName = "Purisa" textboxtext.CharHeight = 12 textboxtext.CharColor = 0x000000 textboxtext.CharColor = 0xffffff textboxtext.CharWeight = 200
def draw_sign(doc): '''Add sign. Warning: Steps below must be performed in order''' # Step1: Create the text box shape shape_position = Point() shape_position.X = 8500 shape_position.Y = 8300 shape_size = Size() shape_size.Width= 13000 shape_size.Height= 1000 textbox = make_text_shape(doc, shape_position, shape_size) # Step 2: Add the shape to the draw document doc.DrawPages.page1.add(textbox) # Step 3: get the object getText() and pass the heading string textboxtext = textbox.getText() textboxtext.setString("Hamilton Python User Group") # Make modifications to the text textboxtext.CharFontName = "FreeSans" textboxtext.CharHeight = 24 textboxtext.CharColor = 0x000000 textboxtext.CharWeight = 200 textboxtext.FillStyle = SOLID #<-- FillStyle is using SOLID textboxtext.FillBackground = 0xffffff textboxtext.FillTransparence = 0 textboxtext.LineStyle = lsSOLID #<-- Cant use SOLID. Used for FillStyle textboxtext.LineColor = 0x000000 textboxtext.LineTransparence = 0 textboxtext.LineWidth = 80 textboxtext.TextHorizontalAdjust = CENTER
def draw_heading(doc): '''Add the heading text. Warning: Steps below must be performed in order''' # Step1: Create the text box shape shape_position = Point() shape_position.X = 8000 shape_position.Y = 1500 shape_size = Size() shape_size.Width= 16000 shape_size.Height= 1000 textbox = make_text_shape(doc, shape_position, shape_size) # Step 2: Add the shape to the draw document doc.DrawPages.page1.add(textbox) # Step 3: get the object getText() and pass the heading string textboxtext = textbox.getText() textboxtext.setString("Python House") # Make modifications to the text textboxtext.TextAutoGrowHeight = True textboxtext.TextAutoGrowWidth = True #textboxtext.CharFontName = "Times New Roman" #textboxtext.CharFontName = "Purisa" #textboxtext.CharHeight = 80 #textboxtext.CharColor = 0xff00ff # Alternative method of setting properties textboxtext.setPropertyValue("CharFontName", "Purisa") textboxtext.setPropertyValue("CharHeight", 80) textboxtext.setPropertyValue("CharColor", 0xff00ff) textboxtext.setPropertyValue("CharShadowed", uno.Bool(1))
def draw_text(doc): '''Add message. Warning: Steps below must be performed in order''' # Step1: Create the text box shape shape_position = Point() shape_position.X = 1500 shape_position.Y = 18200 shape_size = Size() shape_size.Width= 26000 shape_size.Height= 1000 textbox = make_text_shape(doc, shape_position, shape_size) # Step 2: Add the shape to the draw document doc.DrawPages.page1.add(textbox) # Step 3: get the object getText() and pass the heading string textboxtext = textbox.getText() label = ("The python program establishes a connection to libreoffice " \ "and creates a draw document. The draw document is set to A4 " \ "landscape. Drawing shapes are added to the document.") textboxtext.setString(label) # Make modifications to the text #textboxtext.TextAutoGrowHeight = True #textboxtext.TextAutoGrowWidth = True #textboxtext.CharFontName = "Times New Roman" textboxtext.CharFontName = "Purisa" textboxtext.CharHeight = 12 textboxtext.CharColor = 0x000000 textboxtext.CharColor = 0xffffff textboxtext.CharWeight = 200
def actionPerformed(self, actionEvent): for n,i in OOoRTC.draw_comp.InPorts.items(): i._obj.RotateAngle = i._r t_pos = Point() t_pos.X = i._x t_pos.Y = i._y i._obj.setPosition(t_pos)
def draw_house_window(doc): '''Draw House Window''' shape_position = Point() shape_position.X = 16000 shape_position.Y = 10000 shape_size = Size() shape_size.Width= 4000 shape_size.Height= 3000 rectangle = make_rectangle_shape(doc, shape_position, shape_size) rectangle.FillColor = 0xc0c0c0 #0x0000ff rectangle.LineColor = 0xc0c0c0 #0x0000ff doc.DrawPages.page1.add(rectangle)
def draw_house_doorknob(doc): '''Draw doorknob''' shape_position = Point() shape_position.X = 13500 shape_position.Y = 14000 shape_size = Size() shape_size.Width= 300 shape_size.Height= 300 circle = make_ellipse_shape(doc, shape_position, shape_size) circle.FillColor = 0xe0e000 circle.LineColor = 0xe0e000 doc.DrawPages.page1.add(circle)
def draw_house_base(doc): ''' Draw House Base''' shape_position = Point() shape_position.X = 8000 shape_position.Y = 8000 shape_size = Size() shape_size.Width= 14000 shape_size.Height= 10000 rectangle = make_rectangle_shape(doc, shape_position, shape_size) rectangle.FillColor = 0xff8000 rectangle.LineColor = 0xff8000 doc.DrawPages.page1.add(rectangle)
def draw_sun(doc): '''Draw the sun''' shape_position = Point() shape_position.X = 3000 shape_position.Y = 2000 shape_size = Size() shape_size.Width= 2000 shape_size.Height= 2000 ellipse = make_ellipse_shape(doc, shape_position, shape_size) ellipse.FillColor = 0xffff00 ellipse.LineColor = 0xffff00 doc.DrawPages.page1.add(ellipse)
def draw_grass(doc): '''Draw the grass''' shape_position = Point() shape_position.X = 1000 shape_position.Y = 15000 shape_size = Size() shape_size.Width= 26000 shape_size.Height= 5000 rectangle = make_rectangle_shape(doc, shape_position, shape_size) rectangle.FillColor = 0x00c000 rectangle.LineColor = 0x00c000 doc.DrawPages.page1.add(rectangle)
def ObjSetPos(_port, _x, _y): size = _port._obj.Size t_pos = Point() t_rot = math.atan2(size.Height, size.Width) rot = -(_port._obj.RotateAngle / 100.) * 3.141592/180. + t_rot leng = math.sqrt(size.Width*size.Width + size.Height*size.Height) t_pos.X = long(_x*_port._sx/100.*10. - leng*math.cos(rot)/2.) + _port._ox t_pos.Y = long(_y*_port._sy/100.*10. - leng*math.sin(rot)/2.) + _port._oy _port._obj.setPosition(t_pos)
def draw_grass(doc): '''Draw the grass''' shape_position = Point() shape_position.X = 1000 shape_position.Y = 15000 shape_size = Size() shape_size.Width= 27700 shape_size.Height= 5000 rectangle = make_rectangle_shape(doc, shape_position, shape_size) rectangle.FillColor = 0x00c000 rectangle.LineColor = 0x00c000 doc.DrawPages.page1.add(rectangle)
def draw_house_roof(doc): '''Draw House Roof''' shape_position = Point() shape_position.X = 7000 shape_position.Y = 6000 shape_size = Size() shape_size.Width= 16000 shape_size.Height= 2000 rectangle = make_rectangle_shape(doc, shape_position, shape_size) rectangle.FillColor = 0xff0000 rectangle.LineColor = 0xff0000 doc.DrawPages.page1.add(rectangle)
def createPolygon( model, page, coordss, color = None, type = 'PolyPolygon' ): shape = createShape( model, page, type, color ) from com.sun.star.awt import Point lines = [] for coords in coordss: line = [] for x, y in coords: p = Point() p.X = int( x ) p.Y = -int( y ) line.append( p ) lines.append( tuple( line ) ) shape.PolyPolygon = tuple( lines ) return shape
def draw_border(doc): '''Draw border''' shape_position = Point() shape_position.X = 1000 shape_position.Y = 1000 shape_size = Size() shape_size.Width= 27700 shape_size.Height= 19000 rectangle = make_rectangle_shape(doc, shape_position, shape_size) rectangle.FillStyle = NONE rectangle.FillTransparence = 100 rectangle.LineColor = 0x808080 #rectangle.LineStyle = SOLID #<-- cant reuse SOLID used by FillStyle rectangle.LineWidth = 200 doc.DrawPages.page1.add(rectangle)
def draw_border(doc): '''Draw border''' shape_position = Point() shape_position.X = 1000 shape_position.Y = 1000 shape_size = Size() shape_size.Width= 26000 shape_size.Height= 19000 rectangle = make_rectangle_shape(doc, shape_position, shape_size) rectangle.FillStyle = NONE rectangle.FillTransparence = 100 rectangle.LineColor = 0x808080 #rectangle.LineStyle = SOLID #<-- cant reuse SOLID used by FillStyle rectangle.LineWidth = 200 doc.DrawPages.page1.add(rectangle)
def draw_sky(doc): '''Draw sky''' shape_position = Point() # from com.sun.star.awt import Point shape_position.X = 1000 shape_position.Y = 1000 shape_size = Size() # from com.sun.star.awt import Size shape_size.Width= 27700 shape_size.Height= 19000 #print(dir(oDoc.DrawPages.page1)) rectangle = make_rectangle_shape(doc, shape_position, shape_size) # Set colours #print(dir(rectangle)) #print(len(dir(rectangle))) # 255 properties and methods for the rectangle rectangle.FillColor = 0x00c0ff rectangle.LineColor = 0xffc0ff doc.DrawPages.page1.add(rectangle)
def draw_sky(doc): '''Draw sky''' shape_position = Point() # from com.sun.star.awt import Point shape_position.X = 1000 shape_position.Y = 1000 shape_size = Size() # from com.sun.star.awt import Size shape_size.Width= 26000 shape_size.Height= 19000 #print(dir(oDoc.DrawPages.page1)) rectangle = make_rectangle_shape(doc, shape_position, shape_size) # Set colours #print(dir(rectangle)) #print(len(dir(rectangle))) # 255 properties and methods for the rectangle rectangle.FillColor = 0x00c0ff rectangle.LineColor = 0xffc0ff doc.DrawPages.page1.add(rectangle)
def get_pos_size(data): default = 500 size = Size() pos = Point() if not data: size.Width = default size.Height = default return pos, size if data.Width: size.Width = data.Width else: size.Width = default if data.Height: size.Height = data.Height else: size.Height = default pos.X = data.X pos.Y = data.Y return pos, size
def actionPerformed(self, actionEvent): objectTree = self.dlg_control.getControl(ControlName.RTCTreeName) t_comp, nd = OOoRTC.JudgePort(objectTree, self._paths) if t_comp: for n,i in OOoRTC.draw_comp.InPorts.items(): if i._port_a[0] == t_comp[0]: i._obj.RotateAngle = i._r t_pos = Point() t_pos.X = i._x t_pos.Y = i._y i._obj.setPosition(t_pos) return else: MyMsgBox(OOoRTC.SetCoding('エラー','utf-8'),OOoRTC.SetCoding('データポートを選択してください','utf-8')) return MyMsgBox(OOoRTC.SetCoding('エラー','utf-8'),OOoRTC.SetCoding('削除済みです','utf-8'))