I am looking for the simplest way to insert into document (Writer) horizontal line (from page left to page right excepting margins) and set its color and height.
Thanks for the example code.
[Solved] Writer, Horizontal line
[Solved] Writer, Horizontal line
Last edited by lunter on Sun May 31, 2009 10:25 pm, edited 1 time in total.
OOo 3.3.X on MS Windows 7
Re: [Writer] Horizontal line
I don't know if this is the easiest way. This example adds a wide red line at the end of the document.
Code: Select all
Dim oSize as New com.sun.star.awt.Size
oSize.width = 17576.8 'length in units of 1/100 mm
oSize.height = 0
REM Put a Cursor at the desired position of the line
Doc = ThisComponent
oText = Doc.Text
Curs = oText.CreateTextCursor
Curs.gotoEnd(False) 'go to the end of the document
Curs.setString(Chr(13)) 'insert a carriage return to start a new line
REM Make a line and set the size and color
oLine = Doc.createInstance("com.sun.star.drawing.LineShape")
oLine.setSize(oSize)
oLine.LineColor = RGB(255,0,0)
oLine.Linewidth = 100 'units of 1/100 mm
oLine.attach(Curs.End) 'Attach the Line to the TextRange Curs.End
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.