Exemplo n.º 1
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  
Exemplo n.º 2
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
Exemplo n.º 3
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))
Exemplo n.º 4
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))
Exemplo n.º 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
Exemplo n.º 6
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  
Exemplo n.º 7
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
Exemplo n.º 8
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    
Exemplo n.º 9
0
 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)
Exemplo n.º 10
0
 def test_Struct(self):
     point1 = Point(100, 200)
     point2 = Point(100, 200)
     point3 = Point(0, 10)
     self.assertEqual(point1, point1)
     self.assertEqual(point1, point2)
     self.assertFalse((point1 != point2))
     self.assertNotEqual(point1, point3)
Exemplo n.º 11
0
 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)
Exemplo n.º 12
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)
Exemplo n.º 13
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)  
Exemplo n.º 14
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) 
Exemplo n.º 15
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)
Exemplo n.º 16
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)  
Exemplo n.º 17
0
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)
Exemplo n.º 18
0
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)
Exemplo n.º 19
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) 
Exemplo n.º 20
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)  
Exemplo n.º 21
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)  
Exemplo n.º 22
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) 
Exemplo n.º 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) 
Exemplo n.º 24
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)
Exemplo n.º 25
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)
Exemplo n.º 26
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)
Exemplo n.º 27
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)     
Exemplo n.º 28
0
Arquivo: draw.py Projeto: KAMI911/loec
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
Exemplo n.º 29
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)     
Exemplo n.º 30
0
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
Exemplo n.º 31
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)
Exemplo n.º 32
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)
Exemplo n.º 33
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
Exemplo n.º 34
0
 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'))
Exemplo n.º 35
0
 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'))
Exemplo n.º 36
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)
Exemplo n.º 37
0
 def mouseReleased(self, ev):
     if ev.Buttons == MB_RIGHT and ev.ClickCount == 1:
         if not self.popup:
             self.popup = self._create_popup()
             if not self.popup: return
         pos = ev.Source.getPosSize()
         if self.use_point:
             _pos = Point(pos.X + ev.X, pos.Y + ev.Y)
         else:
             _pos = Rectangle(pos.X + ev.X, pos.Y + ev.Y, 0, 0)
         n = self.popup.execute(ev.Source.getPeer(), _pos, 0)
         if n > 0:
             self.do_command(ev, n)
Exemplo n.º 38
0
    def trigger(self, args):
        # access the current writer document
        desktop = self.ctx.ServiceManager.createInstanceWithContext(
            "com.sun.star.frame.Desktop", self.ctx)

        model = desktop.getCurrentComponent()
        controller = model.getCurrentController()
        presentation = model.Presentation

        pages = model.getDrawPages()
        credits = []
        for page_num in range(pages.getCount()):
            page = pages.getByIndex(page_num)
            for shape_num in range(page.getCount()):
                shape = page.getByIndex(shape_num)
                try:
                    rdf = shape.UserDefinedAttributes.getByName(
                        "cm-metadata").Value
                    credit = libcredit.Credit(rdf)
                    credits.append(credit)
                except NoSuchElementException:
                    pass

        # create a TextShape with credits on the current page
        page = controller.getCurrentPage()
        shape = model.createInstance("com.sun.star.drawing.TextShape")
        shape.TextAutoGrowHeight = True
        shape.TextAutoGrowWidth = True

        page.add(shape)

        text = shape.Text
        cursor = text.createTextCursor()
        text.insertString(cursor,
                          "This presentation includes the following works:", 0)
        text.insertControlCharacter(cursor, PARAGRAPH_BREAK, 0)
        text.insertControlCharacter(cursor, PARAGRAPH_BREAK, 0)
        cursor.gotoEnd(False)

        for credit in credits:
            # in Impress cursor seems to support com.sun.star.style.CharacterProperties
            # but trying to set HyperLinkURL property raises an UnknownPropertyException
            # so let's just disable hyperlinks for now
            tf = LOCreditFormatter(text, cursor, hyperlinks=False)
            credit.format(tf, source_depth=0)
            text.insertControlCharacter(cursor, PARAGRAPH_BREAK, 0)

        size = shape.Size
        shape.setPosition(
            Point(int((page.Width - size.Width) / 2),
                  int((page.Height - size.Height) / 2)))
Exemplo n.º 39
0
 def position_button_pushed(self):
     if not self.menu:
         self.menu = self.create_service("com.sun.star.awt.PopupMenu")
         self.menu.addMenuListener(self.PositionMenuListener(self))
     self.menu.clear()
     try:
         self.fill_menu(self.menu)
         pos = self.get(3, self.ID_BTN_POSITION).getPosSize()
         if self.use_point:
             pos = Point(pos.X, pos.Y)
         n = self.menu.execute(self.pages[3].getPeer(), pos, 0)
         if 0 < n:
             command = self.menu.getCommand(n)
             self.selected_position = "%s\%s" % (self.get_selected_menu(), command)
             self.set_position_label(self.menu.getItemText(n))
     except Exception as e:
         print(e)
Exemplo n.º 40
0
 def mousePressed(self, ev):
     if ev.Buttons == MB_RIGHT and ev.ClickCount == 1:
         if not self.popup:
             self.popup = self._create_popup()
             if not self.popup: return
         
         grid_model = ev.Source.getModel()
         if grid_model.ShowColumnHeader:
             if hasattr(grid_model, "ColumnHeaderHeight"):
                 header_height = grid_model.ColumnHeaderHeight
             else:
                 header_height = grid_model.ColumnModel.ColumnHeaderHeight
             if header_height is None: header_height = 20
             if ev.Y <= header_height:
                 return
         try:
             index = self.cast.pages.get_active()
             if index == 0:
                 # properties
                 self._update_popup_states(((2, True), (4, True), (8, False), (512, True)))
                 properties_title = ('Name', 'Value Type', 'Value', 'Info.', 'Attr.')
                 copy_cell_popup = self.popup.getPopupMenu(512)
                 for i, label in zip(range(513, 518), properties_title):
                     copy_cell_popup.setItemText(i, label)
             elif index == 1:
                 # methods
                 self._update_popup_states(((2, False), (4, False), (8, True), (512, True)))
                 
                 methods_title = ('Name', 'Arguments', 'Return Type', 'Declaring Class', 'Exceptions')
                 copy_cell_popup = self.popup.getPopupMenu(512)
                 for i, label in zip(range(513, 518), methods_title):
                     copy_cell_popup.setItemText(i, label)
             else:
                 self._update_popup_states(((2, False), (4, False), (8, False), (512, False)))
             
             pos = ev.Source.getPosSize()
             if self.use_point:
                 _pos = Point(pos.X + ev.X, pos.Y + ev.Y)
             else:
                 _pos = Rectangle(pos.X + ev.X, pos.Y + ev.Y, 0, 0)
             n = self.popup.execute(ev.Source.getPeer(), _pos, 0)
             if n > 0:
                 self.do_command(n)
         except Exception as e:
             print(e)
Exemplo n.º 41
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
Exemplo n.º 42
0
 def maTopx(x, y):  # maをpxに変換する。
     point = window.convertPointToPixel(Point(X=x, Y=y),
                                        MeasureUnit.APPFONT)
     return point.X, point.Y
Exemplo n.º 43
0
def getDialogPoint(
    doc, enhancedmouseevent
):  # クリックした位置x yのタプルで返す。但し、一部しか見えてないセルの場合はNoneが返る。TaskCreatorのRectangleには画面の左角からの座標を渡すが、ウィンドウタイトルバーは含まれない。
    controller = doc.getCurrentController()  # 現在のコントローラを取得。
    docframe = controller.getFrame()  # フレームを取得。
    containerwindow = docframe.getContainerWindow()  # コンテナウィドウの取得。
    accessiblecontextparent = containerwindow.getAccessibleContext(
    ).getAccessibleParent(
    )  # コンテナウィンドウの親AccessibleContextを取得する。フレームの子AccessibleContextになる。
    accessiblecontext = accessiblecontextparent.getAccessibleContext(
    )  # AccessibleContextを取得。
    for i in range(accessiblecontext.getAccessibleChildCount()):
        childaccessiblecontext = accessiblecontext.getAccessibleChild(
            i).getAccessibleContext()
        if childaccessiblecontext.getAccessibleRole() == 49:  # ROOT_PANEの時。
            rootpanebounds = childaccessiblecontext.getBounds(
            )  # Yアトリビュートがウィンドウタイトルバーの高さになる。
            break
    else:
        return  # ウィンドウタイトルバーのAccessibleContextが取得できなかった時はNoneを返す。
    componentwindow = docframe.getComponentWindow()  # コンポーネントウィンドウを取得。
    border = controller.getBorder()  # 行ヘッダの幅と列ヘッダの高さの取得のため。
    accessiblecontext = componentwindow.getAccessibleContext(
    )  # コンポーネントウィンドウのAccessibleContextを取得。
    for i in range(accessiblecontext.getAccessibleChildCount()
                   ):  # 子AccessibleContextについて。
        childaccessiblecontext = accessiblecontext.getAccessibleChild(
            i).getAccessibleContext()  # 子AccessibleContextのAccessibleContext。
        if childaccessiblecontext.getAccessibleRole() == 51:  # SCROLL_PANEの時。
            for j in range(childaccessiblecontext.getAccessibleChildCount()
                           ):  # 孫AccessibleContextについて。
                grandchildaccessiblecontext = childaccessiblecontext.getAccessibleChild(
                    j).getAccessibleContext(
                    )  # 孫AccessibleContextのAccessibleContext。
                if grandchildaccessiblecontext.getAccessibleRole(
                ) == 84:  # DOCUMENT_SPREADSHEETの時。これが枠。
                    bounds = grandchildaccessiblecontext.getBounds(
                    )  # 枠の位置と大きさを取得(SCROLL_PANEの左上角が原点)。
                    if bounds.X == border.Left and bounds.Y == border.Top:  # SCROLL_PANEに対する相対座標が行ヘッダと列ヘッダと一致する時は左上枠。
                        for k, subcontroller in enumerate(
                                controller):  # 各枠のコントローラについて。インデックスも取得する。
                            cellrange = subcontroller.getReferredCells(
                            )  # 見えているセル範囲を取得。一部しかみえていないセルは含まれない。
                            if len(
                                    cellrange.queryIntersection(
                                        enhancedmouseevent.Target.
                                        getRangeAddress())
                            ):  # ターゲットが含まれるセル範囲コレクションが返る時その枠がクリックした枠。「ウィンドウの分割」では正しいiは必ずしも取得できない。
                                sourcepointonscreen = grandchildaccessiblecontext.getLocationOnScreen(
                                )  # 左上枠の左上角の点を取得(画面の左上角が原点)。
                                if k == 1:  # 左下枠の時。
                                    sourcepointonscreen = Point(
                                        X=sourcepointonscreen.X,
                                        Y=sourcepointonscreen.Y +
                                        bounds.Height)
                                elif k == 2:  # 右上枠の時。
                                    sourcepointonscreen = Point(
                                        X=sourcepointonscreen.X + bounds.Width,
                                        Y=sourcepointonscreen.Y)
                                elif k == 3:  # 右下枠の時。
                                    sourcepointonscreen = Point(
                                        X=sourcepointonscreen.X + bounds.Width,
                                        Y=sourcepointonscreen.Y +
                                        bounds.Height)
                                x = sourcepointonscreen.X + enhancedmouseevent.X  # クリックした位置の画面の左上角からのXの取得。
                                y = sourcepointonscreen.Y + enhancedmouseevent.Y + rootpanebounds.Y  # クリックした位置からメニューバーの高さ分下の位置の画面の左上角からのYの取得
                                return x, y
Exemplo n.º 44
0
    def trigger(self, args):
        desktop = self.ctx.ServiceManager.createInstanceWithContext(
            "com.sun.star.frame.Desktop", self.ctx)

        model = desktop.getCurrentComponent()
        controller = model.getCurrentController()

        image_with_metadata = self._get_image_with_metadata()
        if not image_with_metadata:
            # just paste whatever is in clipboard
            dispatch_helper = self.ctx.ServiceManager.createInstance(
                "com.sun.star.frame.DispatchHelper")
            dispatch_helper.executeDispatch(controller, ".uno:Paste", "", 0,
                                            tuple())
            return

        rdf, descriptor, graphic = image_with_metadata
        img_size = descriptor.getPropertyValue("SizePixel")

        if model.supportsService("com.sun.star.text.TextDocument"):
            # Metadata is only supported in text documents
            metadata = Metadata(self.ctx, model)

            # create a frame to hold the image with caption
            text_frame = model.createInstance("com.sun.star.text.TextFrame")
            text_frame.setSize(Size(15000, 400))
            text_frame.setPropertyValue("AnchorType", AT_PARAGRAPH)

            # duplicate current cursor
            view_cursor = controller.getViewCursor()
            cursor = view_cursor.getText().createTextCursorByRange(view_cursor)
            cursor.gotoStartOfSentence(False)
            cursor.gotoEndOfSentence(True)

            # insert text frame
            text = model.Text
            text.insertTextContent(cursor, text_frame, 0)
            frame_text = text_frame.getText()

            cursor = frame_text.createTextCursor()

            # Add a <text:bookmark> tag to serve as anchor for the RDF
            # and give us a subject URI.  Ideally, we would get this
            # from the image but that isn't possible with current
            # APIs.

            bookmark = model.createInstance("com.sun.star.text.Bookmark")
            frame_text.insertTextContent(cursor, bookmark, False)
            bookmark.ensureMetadataReference()
            bookmark.setName(BOOKMARK_BASE_NAME + bookmark.LocalName)
            cursor.gotoEnd(False)

            # create a TextGraphicObject to hold the image
            image = model.createInstance("com.sun.star.text.TextGraphicObject")
            image.setPropertyValue("Graphic", graphic)
            # hack to enlarge the tiny pasted images
            image.setPropertyValue("Width", img_size.Width * 20)
            image.setPropertyValue("Height", img_size.Height * 20)
            image.setName(bookmark.getName())

            frame_text.insertTextContent(cursor, image, False)

            # add the credit as text below the image
            credit = libcredit.Credit(rdf)
            credit_writer = LOCreditFormatter(frame_text,
                                              cursor,
                                              metadata=metadata)
            credit.format(credit_writer, subject_uri=bookmark.StringValue)

            # scale the image to fit the frame
            image.setPropertyValue("RelativeWidth", 100)
            #image.setPropertyValue("RelativeHeight", 100)
            image.setPropertyValue("IsSyncHeightToWidth", True)

            # set image title (no sources)
            credit_writer = libcredit.TextCreditFormatter()
            credit.format(credit_writer, source_depth=0)
            image.setPropertyValue("Title", credit_writer.get_text())

            # set image title (credit with sources)
            credit_writer = libcredit.TextCreditFormatter()
            credit.format(credit_writer)
            image.setPropertyValue("Description", credit_writer.get_text())

            # DEBUG:
            # metadata.dump_graph()

        elif model.supportsService(
                "com.sun.star.presentation.PresentationDocument"):
            page = controller.getCurrentPage()

            # begin pasting
            shape = model.createInstance(
                "com.sun.star.drawing.GraphicObjectShape")
            shape.Graphic = graphic
            shape.setSize(Size(img_size.Width * 20, img_size.Height * 20))

            page.add(shape)

            attr = uno.createUnoStruct("com.sun.star.xml.AttributeData")
            attr.Value = rdf

            attributes = shape.UserDefinedAttributes
            attributes.insertByName("cm-metadata", attr)
            shape.UserDefinedAttributes = attributes

            size = shape.Size
            shape.setPosition(
                Point(int((page.Width - size.Width) / 2),
                      int((page.Height - size.Height) / 2)))