コード例 #1
0
ファイル: pythonhouse.py プロジェクト: irsbugs/meetings
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  
コード例 #2
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))
コード例 #3
0
ファイル: pythonhouse.py プロジェクト: irsbugs/meetings
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
コード例 #4
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= 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  
コード例 #5
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
コード例 #6
0
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    
コード例 #7
0
ファイル: pythonhouse.py プロジェクト: irsbugs/meetings
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))
コード例 #8
0
ファイル: pythonhouse.py プロジェクト: irsbugs/meetings
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
コード例 #9
0
ファイル: writer.py プロジェクト: fakabbir/sdk-examples
 def add_embedded_image(self,
                        url=None,
                        width=None,
                        height=None,
                        paraadjust=None):
     dpi = self.dpi
     scale = 1000 * 2.54 / float(dpi)
     doc = self.edit_doc
     cursor = doc.Text.createTextCursor()
     cursor.gotoEnd(False)
     try:
         fileurl = unohelper.systemPathToFileUrl(url)
         graphic = self.graphicprovider.queryGraphic(
             (PropertyValue('URL', 0, fileurl, 0), ))
         if graphic.SizePixel is None:
             # Then we're likely dealing with vector graphics. Then we try to
             # get the "real" size, which is enough information to
             # determine the aspect ratio
             original_size = graphic.Size100thMM
         else:
             original_size = graphic.SizePixel
         graphic_object_shape = doc.createInstance(
             'com.sun.star.drawing.GraphicObjectShape')
         graphic_object_shape.Graphic = graphic
         if width and height:
             size = Size(int(width * scale), int(height * scale))
         elif width:
             size = Size(
                 int(width * scale),
                 int((float(width) / original_size.Width) *
                     original_size.Height * scale))
         elif height:
             size = Size(
                 int((float(height) / original_size.Height) *
                     original_size.Width * scale), int(height * scale))
         else:
             size = Size(int(original_size.Width * scale),
                         original_size.Height * scale)
         graphic_object_shape.setSize(size)
         # doc.Text.insertTextContent(cursor, graphic_object_shape, False)
         thisgraphicobject = doc.createInstance(
             "com.sun.star.text.TextGraphicObject")
         thisgraphicobject.Graphic = graphic_object_shape.Graphic
         thisgraphicobject.setSize(size)
         if paraadjust:
             oldparaadjust = cursor.ParaAdjust
             cursor.ParaAdjust = paraadjust
         doc.Text.insertTextContent(cursor, thisgraphicobject, False)
         os.unlink(url)
         if paraadjust:
             cursor.ParaAdjust = oldparaadjust
     except Exception as e:
         print(e)
コード例 #10
0
ファイル: pythonhouse.py プロジェクト: irsbugs/meetings
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) 
コード例 #11
0
ファイル: pythonhouse.py プロジェクト: irsbugs/meetings
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) 
コード例 #12
0
ファイル: pythonhouse.py プロジェクト: irsbugs/meetings
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)  
コード例 #13
0
ファイル: pythonhouse.py プロジェクト: irsbugs/meetings
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)
コード例 #14
0
ファイル: pythonhouse.py プロジェクト: irsbugs/meetings
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)
コード例 #15
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)
コード例 #16
0
 def buildStepX(self):
     self.ilLayouts = ImageList()
     self.ilLayouts.pos = Size(97, 38)
     self.ilLayouts.imageSize = Size(34, 30)
     self.ilLayouts.cols = 5
     self.ilLayouts.rows = 3
     self.ilLayouts.step = 3
     self.ilLayouts.showButtons = False
     self.ilLayouts.renderer = self.LayoutRenderer()
     self.ilLayouts.scaleImages = False
     self.ilLayouts.tabIndex = 31
     self.ilLayouts.helpURL = HID3_IL_LAYOUTS_IMG1
コード例 #17
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= 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)
コード例 #18
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) 
コード例 #19
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)  
コード例 #20
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)  
コード例 #21
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) 
コード例 #22
0
ファイル: pythonhouse.py プロジェクト: irsbugs/meetings
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)  
コード例 #23
0
ファイル: pythonhouse.py プロジェクト: irsbugs/meetings
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)
コード例 #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= 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)     
コード例 #25
0
ファイル: pythonhouse.py プロジェクト: irsbugs/meetings
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)     
コード例 #26
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= 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)
コード例 #27
0
ファイル: eyes17.py プロジェクト: Jayandi/expeyes-programs
    def adjustSize(self, size, dpi=150, width="", height=""):
        """
        Adjust the size of an image to fit the TextDocument
        :param size: the image's native size
        :param dpi: dots per inch, defaults to 150 dpi
        :param width: maybe used in future enhancements
        :param height: maybe used in future enhancements
        :return: a Size object for the Text document
        """
        scale = 1000 * 2.54 / dpi
        w = int(size.Width * scale)
        h = int(size.Height * scale)

        ## for future enhancements: take in account width and height ##
        if width and height:  ##
            w = int(float(width) * scale)  ##
            h = int(float(height) * scale)  ##
        elif width:  ##
            w = int(float(width) * scale)  ##
            h = int(w / size.Width * size.Height)  ##
        elif height:  ##
            h = int(float(height) * scale)  ##
            w = int(h / size.Height * size.Width)  ##
        ###############################################################

        return Size(w, h)
コード例 #28
0
ファイル: pythonhouse.py プロジェクト: irsbugs/meetings
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)
コード例 #29
0
ファイル: renderer.py プロジェクト: moniquehw/slareport
    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)
コード例 #30
0
 def __init__(self):
     self.benabled = True
     self.gap = Size(4, 4)
     self.cols = 4
     self.rows = 3
     self.imageSize = Size(20, 20)
     self.selectionGap = Size(2, 2)
     self.showButtons = True
     self.refreshOverNull = True
     self.imageTextLines = 1
     self.rowSelect = False
     self.scaleImages = True
     self.name = "il"
     self.selected = -1
     self.pageStart = 0
     self.helpURL = 0
     self.counterRenderer = self.SimpleCounterRenderer()
     self.MOVE_SELECTION_VALS = range(3)
コード例 #31
0
def daisyAlignFrames(currentDoc, textWidth=11000, color = 0):
    textPtr = currentDoc.Text
    frameStyle = "Frame"
    for i in range(0, currentDoc.TextFrames.getCount()):
        activeFrame = currentDoc.TextFrames.getByIndex(i)
        activeFrame.setPropertyValue( "FrameStyleName", frameStyle)
        activeFrame.setSize(Size(textWidth, 1))
        activeFrame.setPropertyValue( "BackColor", color)
        activeFrame.setPropertyValue( "FrameIsAutomaticHeight", True )
コード例 #32
0
ファイル: calc.py プロジェクト: ishanthilina/cc.libreoffice
    def insertVisibleNotice(self, xSpreadsheet=None):
        """Create and insert an auto-text containing the license(
        if spreadsheet is given,to it)

        Arguments:
        - `xSpreadsheet`:xSpreadsheet- Spread sheet to insert the text
        """
        try:
            if xSpreadsheet is None:
                xDocModel = self.component
                xController = xDocModel.getCurrentController()
                xSpreadsheet = xController.getActiveSheet()

            docLicense = super(Calc, self).getDocumentLicense()

            #xDrawPageSupplier=xSpreadsheet
            xPage = xSpreadsheet.getDrawPage()

            #xShapes=xPage

            aLineSpacing = LineSpacing()
            aLineSpacing.Mode = PROP

            #first shape
            acrSc = self.__getActiveCellsRange(self.component).StartColumn
            acrSr = self.__getActiveCellsRange(self.component).StartRow + 3

            absCellPos = self.__getAbsoluteCellPosition(xSpreadsheet,
                                                        acrSc, acrSr)

            xRectangle = createShape(
                self.component, absCellPos, Size(15000, 1500),
                                   "com.sun.star.drawing.RectangleShape")
            xPage.add(xRectangle)

            xShapePropSet = xRectangle

            xRectangle.setPropertyValue("TextAutoGrowHeight", True)
            xShapePropSet.setPropertyValue("TextAutoGrowWidth", True)
            noneLineStyle = uno.getConstantByName(
                "com.sun.star.drawing.LineStyle.NONE")
            xShapePropSet.setPropertyValue("LineStyle", noneLineStyle)
            noneFillStyle = uno.getConstantByName(
                "com.sun.star.drawing.FillStyle.NONE")
            xShapePropSet.setPropertyValue("FillStyle", noneFillStyle)
            xShapePropSet.setPropertyValue("Name", "ccoo:licenseText")

            #first paragraph
            xTextPropSet = addPortion(xRectangle, docLicense.name, False)
            #TODO-has this been done correctly??
            xTextPropSet.setPropertyValue("CharColor", int(0x000000))

            #insert the graphic
            self.__embedGraphic(docLicense.imageUrl, xSpreadsheet)
        except Exception, e:
            traceback.print_exc()
コード例 #33
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))))
コード例 #34
0
    def insertFrame(self):
        textFrame = self.document.createInstance("com.sun.star.text.TextFrame")
        textFrame.setSize(Size(150000, 1))
        textFrame.setPropertyValue("AnchorType" , AS_CHARACTER)
 
        self.text.insertTextContent(self.cursor, textFrame, 0)
 
        textInTextFrame = textFrame.getText()
        cursorInTextFrame = textInTextFrame.createTextCursor()
        textInTextFrame.insertString(cursorInTextFrame, "The first line in the newly created text frame.", 0)
        textInTextFrame.insertString(cursorInTextFrame, "\nWith this second line the height of the rame raises.", 0)
        text.insertControlCharacter(self.cursor, PARAGRAPH_BREAK, 0)
コード例 #35
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)
コード例 #36
0
ファイル: writer.py プロジェクト: fakabbir/sdk-examples
 def add_linked_image(self, url=None, width=None, height=None):
     dpi = self.dpi
     scale = 1000 * 2.54 / float(dpi)
     doc = self.edit_doc
     cursor = doc.Text.createTextCursor()
     cursor.gotoEnd(False)
     try:
         fileurl = unohelper.systemPathToFileUrl(url)
         thisgraphicobject = doc.createInstance(
             "com.sun.star.text.TextGraphicObject")
         thisgraphicobject.Surround = 'NONE'
         thisgraphicobject.GraphicURL = fileurl
         if thisgraphicobject.Graphic.SizePixel is None:
             # Then we're likely dealing with vector graphics. Then we try to
             # get the "real" size, which is enough information to
             # determine the aspect ratio
             original_size = thisgraphicobject.Graphic.Size100thMM
         else:
             original_size = thisgraphicobject.Graphic.SizePixel
         if width and height:
             size = Size(int(width * scale), int(height * scale))
         elif width:
             size = Size(
                 int(width * scale),
                 int((float(width) / original_size.Width) *
                     original_size.Height * scale))
         elif height:
             size = Size(
                 int((float(height) / original_size.Height) *
                     original_size.Width * scale), int(height * scale))
         else:
             size = Size(int(original_size.Width * scale),
                         original_size.Height * scale)
         thisgraphicobject.setSize(size)
         doc.Text.insertTextContent(cursor, thisgraphicobject, False)
     except Exception as e:
         print(e)
コード例 #37
0
ファイル: calc.py プロジェクト: ishanthilina/cc.libreoffice
    def __embedGraphic(self, imgURL, xSpreadsheet):
        """Insert the license image to the document.

        Arguments:
        - `imgURL`:String-URL to the license image
        - `xSpreadsheet`:xSpreadsheet-Spread sheet to insert the image
        """
        try:
            xSheetDoc = self.component
            #xSpreadsheetFactory=xSheetDoc
            #xDrawPageSupplier=xSpreadsheet
            xPage = xSpreadsheet.getDrawPage()

            xBitmapContainer = xSheetDoc.createInstance(
                "com.sun.star.drawing.BitmapTable")

            xGraphicShape = xSheetDoc.createInstance(
                    "com.sun.star.drawing.GraphicObjectShape")
            xGraphicShape.setSize(Size(3104, 1093))

            acrSc = self.__getActiveCellsRange(self.component).StartColumn
            acrSr = self.__getActiveCellsRange(self.component).StartRow

            #add to current cell
            xGraphicShape.setPosition(self.__getAbsoluteCellPosition(
                xSpreadsheet, acrSc, acrSr))

            xProps = xGraphicShape

            #helper-stuff to let OOo create an internal name of the graphic
            #that can be used later (internal name consists of
            #various checksums)
            xBitmapContainer.insertByName("imgID", imgURL)

            internalURL = xBitmapContainer.getByName("imgID")

            xProps.setPropertyValue("AnchorType", AS_CHARACTER)
            xProps.setPropertyValue("GraphicURL", internalURL)
            xProps.setPropertyValue("Width", 4000)  # original: 88 px
            xProps.setPropertyValue("Height", 1550)  # original: 31 px
            xProps.setPropertyValue("Name", "ccoo:licenseImage")

            #inser the graphic at the cursor position
            xPage.add(xGraphicShape)
            #remove the helper-entry
            xBitmapContainer.removeByName("imgID")
        except Exception, e:
            traceback.print_exc()
            raise e
コード例 #38
0
ファイル: comun.py プロジェクト: sonnysk76/easydev
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
コード例 #39
0
 def addNewButton(self):
     logger.debug(util.funcName())
     oControlShape = self.writerDoc.document.createInstance(
         "com.sun.star.drawing.ControlShape")
     aPoint = Point(1000, 1000)
     oControlShape.setPosition(aPoint)
     aSize = Size(6000, 800)
     #aSize.Width = 6000
     #aSize.Height = 800
     oControlShape.setSize(aSize)
     oControlShape.AnchorType = AS_CHARACTER
     oButtonModel = self.mainDoc.smgr.createInstance(
         "com.sun.star.form.component.CommandButton")
     oButtonModel.Label = "Go to example in main document"
     oControlShape.setControl(oButtonModel)
     self.writerDoc.text.insertTextContent(self.writerDoc.viewcursor,
                                           oControlShape, False)
     return oButtonModel
コード例 #40
0
 def __init__(self, xmsf, set_, resources):
     super(BackgroundsDialog, self).__init__(
         xmsf, HID_BG,
         (resources.resBackgroundsDialog,
          resources.resBackgroundsDialogCaption, resources.resOK,
          resources.resCancel, resources.resHelp, resources.resDeselect,
          resources.resOther, resources.resCounter))
     self.sd = SystemDialog.createOpenDialog(xmsf)
     self.sd.addFilter(resources.resImages, "*.jpg;*.jpeg;*.jpe;*.gif",
                       True)
     self.sd.addFilter(resources.resAllFiles, "*.*", False)
     self.settings = set_.root
     self.fileAccess = FileAccess(xmsf)
     #COMMENTED
     #self.il.setListModel(Model(set_))
     self.il.listModel = self.Model(set_, self)
     self.il.imageSize = Size(40, 40)
     self.il.renderer = self.BGRenderer(0, self)
     self.build()
コード例 #41
0
ファイル: pythonhouse.py プロジェクト: irsbugs/meetings
def createframe(doc,text,cursor):
    '''Two lines of text in a frame'''
    textFrame = doc.createInstance("com.sun.star.text.TextFrame")
    textFrame.setSize(Size(15000,400))
    # Done in import stage
    #from com.sun.star.text.TextContentAnchorType import AS_CHARACTER
    textFrame.setPropertyValue("AnchorType" , AS_CHARACTER)

    text.insertTextContent(cursor, textFrame, 0)

    textInTextFrame = textFrame.getText()
    cursorInTextFrame = textInTextFrame.createTextCursor()
    textInTextFrame.insertString(cursorInTextFrame, 
        "The first line in the newly created text frame.", 0)
    textInTextFrame.insertString(cursorInTextFrame,
        "\nWith this second line the height of the frame raises.",0)
    text.insertControlCharacter(cursor, PARAGRAPH_BREAK, 0)

    cursor.setPropertyValue("CharColor", 65536)
    cursor.setPropertyValue("CharShadowed", uno.Bool(0))
コード例 #42
0
    def windowResized(self, ev):
        min_size = Size(150, 240)
        try:
            # extends inner window to match with the outer window
            if self.dialog:
                if (ev.Width >= min_size.Width) and (ev.Height >=
                                                     min_size.Height):
                    self.dialog.setPosSize(0, 0, ev.Width, ev.Height, SIZE)

                    # resize dialog elements
                    tf_title = self.dialog.getControl("TextField_Title")
                    tf_title_height = tf_title.getPosSize().Height
                    tf_title.setPosSize(0, 0, ev.Width - 20, tf_title_height,
                                        SIZE)
                    tf_desc = self.dialog.getControl("TextField_Desc")
                    tf_desc_height = tf_desc.getPosSize().Height
                    tf_desc.setPosSize(0, 0, ev.Width - 20, tf_desc_height,
                                       SIZE)

                else:  # ToDo: no resize if minimum size is reached
                    pass

        except Exception as e:
            print(e)
コード例 #43
0
    def __init__(self, xmsf, set_, resources):
        super(IconsDialog, self).__init__(
            xmsf, HID_IS,
            (resources.resIconsDialog, resources.resIconsDialogCaption,
             resources.resOK, resources.resCancel, resources.resHelp,
             resources.resDeselect, resources.resOther, resources.resCounter))
        self.htmlexpDirectory = FileAccess.getOfficePath2(
            xmsf, "Gallery", "share", "")
        self.icons = \
            ["firs", "prev", "next", "last", "nav", "text", "up", "down"]
        self.set = set_
        self.objects = range(self.set.getSize() * len(self.icons))

        self.il.listModel = self
        self.il.renderer = self
        self.il.rows = 4
        self.il.cols = 8
        self.il.ImageSize = Size(20, 20)
        self.il.showButtons = False
        self.il.rowSelect = True
        self.il.scaleImages = False
        self.showDeselectButton = True
        self.showOtherButton = False
        self.build()