von Butch » Do, 20.04.2017 14:34
Trara!
Mit viel Mühe habe ich schließlich eine fast komplette Lösung erarbeitet.
B.
Code: Alles auswählen
Sub BildEinfuegen
Dim oDoc As Object
Dim oViewCursor
Dim oGraph
Dim oText
Dim Var
oDoc = ThisComponent
oText = oDoc.getText()
oViewCursor = ThisComponent.CurrentController.getViewCursor()
oGraph = oDoc.createInstance("com.sun.star.text.GraphicObject")
With oGraph
.GraphicURL = "file:///C:/Homepage/media/bild.png"
.AnchorType = 3 ' 1 as char, 2 to page, 3 to para, 4 to char (*)
.Width = 550 ' in 1/1000 cm
.Height = 700
.LeftMargin = 0
.RightMargin = 200
.TopMargin = 0
.BottomMargin = 50
.HoriOrient = 0 ' 1 2 3 = right center left, 0 from ... (1)
.VertOrient = 1 ' 1 2 3 = top center bottom, 0 from ... (2)
.HoriOrientRelation = 1 ' (3)
.VertOrientRelation = 1 ' (4)
.HoriOrientPosition = 10 ' by ...
.VertOrientPosition = 0
.Surround = 2 ' 0 none 1 through 2 parallel 3 optimal 4 before 5 after
End With
oText.insertTextContent(oViewCursor, oGraph, False)
' (1)
' with to page: to entire page
' with to para: to para area
' with to char: to para area
' with as char: of course no influence (is a 'character'!)
' (2)
' with to page: to entire page
' with to para: to margin
' with to char: to margin
' !!! with as char: 1 2 3 to base line, 4 5 6 to char, 7 8 9 to row (!!!!!!)
' (3)
' with to page: 1+2 pag te ar, 3 le pag bo, 4 ri pag bo, 5 le pag bo, 6 ri pag bo, 7 ent pag
' with to para: 1 par te ar, 2 pag te ar, 3 le pag bo, 4 ri pag bo, 5 le par bo, 6 ri par bo, 7 ent pa
' with to char: 1 par te ar, 2 char, 3 le pag bo, 4 ri pag bo, 5 le par bo, 6 ri par bo, 7 ent pag, 8 pag te ar, 9 char
' with as char: of course no influence!
' (4)
' with to page: 1+2 pag te ar, 34567 ent pag
' with to para: 1 par te ar, 2 pag te ar, 3+4+5+6 mar, 7 ent pa
' with to char: 1 par te ar, 2 char, 3+4+5+6 mar, 7 ent pag, 8 pag te ar, 9 li of t
' with as char: no influence, setting is done via VertOrient (!!!!!!)
' Bugs (?):
' with to page: 2 pag te ar, but placed vert rel to entire page
' with to page: 9 pag te ar, but placed vert&hor rel to entire page
' (*) Alternativ:
' .AnchorType = com.sun.star.text.TextContentAnchorType.AS_CHARACTER
' (other types: .AT_PARAGRAPH, .AT_PAGE, .AT_FRAME, .AT_CHARACTER).
' https://www.openoffice.org/api/docs/common/ref/com/sun/star/text/Shape.html
End Sub
Trara!
Mit viel Mühe habe ich schließlich eine fast komplette Lösung erarbeitet.
B.
[code]Sub BildEinfuegen
Dim oDoc As Object
Dim oViewCursor
Dim oGraph
Dim oText
Dim Var
oDoc = ThisComponent
oText = oDoc.getText()
oViewCursor = ThisComponent.CurrentController.getViewCursor()
oGraph = oDoc.createInstance("com.sun.star.text.GraphicObject")
With oGraph
.GraphicURL = "file:///C:/Homepage/media/bild.png"
.AnchorType = 3 ' 1 as char, 2 to page, 3 to para, 4 to char (*)
.Width = 550 ' in 1/1000 cm
.Height = 700
.LeftMargin = 0
.RightMargin = 200
.TopMargin = 0
.BottomMargin = 50
.HoriOrient = 0 ' 1 2 3 = right center left, 0 from ... (1)
.VertOrient = 1 ' 1 2 3 = top center bottom, 0 from ... (2)
.HoriOrientRelation = 1 ' (3)
.VertOrientRelation = 1 ' (4)
.HoriOrientPosition = 10 ' by ...
.VertOrientPosition = 0
.Surround = 2 ' 0 none 1 through 2 parallel 3 optimal 4 before 5 after
End With
oText.insertTextContent(oViewCursor, oGraph, False)
' (1)
' with to page: to entire page
' with to para: to para area
' with to char: to para area
' with as char: of course no influence (is a 'character'!)
' (2)
' with to page: to entire page
' with to para: to margin
' with to char: to margin
' !!! with as char: 1 2 3 to base line, 4 5 6 to char, 7 8 9 to row (!!!!!!)
' (3)
' with to page: 1+2 pag te ar, 3 le pag bo, 4 ri pag bo, 5 le pag bo, 6 ri pag bo, 7 ent pag
' with to para: 1 par te ar, 2 pag te ar, 3 le pag bo, 4 ri pag bo, 5 le par bo, 6 ri par bo, 7 ent pa
' with to char: 1 par te ar, 2 char, 3 le pag bo, 4 ri pag bo, 5 le par bo, 6 ri par bo, 7 ent pag, 8 pag te ar, 9 char
' with as char: of course no influence!
' (4)
' with to page: 1+2 pag te ar, 34567 ent pag
' with to para: 1 par te ar, 2 pag te ar, 3+4+5+6 mar, 7 ent pa
' with to char: 1 par te ar, 2 char, 3+4+5+6 mar, 7 ent pag, 8 pag te ar, 9 li of t
' with as char: no influence, setting is done via VertOrient (!!!!!!)
' Bugs (?):
' with to page: 2 pag te ar, but placed vert rel to entire page
' with to page: 9 pag te ar, but placed vert&hor rel to entire page
' (*) Alternativ:
' .AnchorType = com.sun.star.text.TextContentAnchorType.AS_CHARACTER
' (other types: .AT_PARAGRAPH, .AT_PAGE, .AT_FRAME, .AT_CHARACTER).
' https://www.openoffice.org/api/docs/common/ref/com/sun/star/text/Shape.html
End Sub[/code]