Beispiel #1
0
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_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)
Beispiel #3
0
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_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= 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  
Beispiel #7
0
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  
Beispiel #8
0
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_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
Beispiel #10
0
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))
Beispiel #11
0
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 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)
Beispiel #16
0
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) 
Beispiel #17
0
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)  
Beispiel #18
0
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)
Beispiel #19
0
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)  
Beispiel #20
0
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 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)
Beispiel #23
0
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) 
Beispiel #24
0
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= 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)
Beispiel #27
0
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)
Beispiel #28
0
    def render_lifetime_graph(self):
        """ Renders a lifetime summary graph """
        url = render_lifetime_graph(self.client.get_lifetime_summary(), self.client.date.strftime("%b %y"), self.client.config['contract_hours'], self.client.name)
        text = self.document.Text
        replace_desc = self.document.createReplaceDescriptor()
        replace_desc.setSearchString("{{lifetime_summary}}")

        find_iter = self.document.findFirst(replace_desc)
        c = text.createTextCursorByRange(find_iter.Start)
        find_iter.String = ""
        image = self.document.createInstance('com.sun.star.drawing.GraphicObjectShape')
        size = Size()
        image.GraphicURL = "file:///" + url
        size.Height = 5315
        size.Width = 16000
        image.setSize(size)
        text.insertTextContent(c, image, False)
Beispiel #29
0
 def __optimizeSize(self, f, shape):
     f.flush()
     f.seek(0)
     im = Image.open(f)
     f.seek(0)
     h_prop = float(im.size[1]) / float(im.size[0])
     newsize = [im.size[0], im.size[1]]
     if im.size[0] > 800:
         newsize[0] = 800
         newsize[1] = int(newsize[0] * h_prop)
     w_prop = float(newsize[0]) / float(newsize[1])
     if newsize[1] > 700:
         newsize[1] = 700
         newsize[0] = int(newsize[1] * w_prop)        
     size = Size()
     size.Width = newsize[0] * 20
     size.Height = newsize[1] * 20
     shape.setSize(size)
     self.logger.debug('Nuevo tamaño %s -> %s -> %s' % (str(im.size), str(newsize), str((size.Width, size.Height))))