[Solved] Writer, Horizontal line

Java, C++, C#, Delphi... - Using the UNO bridges
Post Reply
lunter
Posts: 28
Joined: Fri May 29, 2009 9:16 am

[Solved] Writer, Horizontal line

Post by lunter »

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.
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
FJCC
Moderator
Posts: 9248
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: [Writer] Horizontal line

Post by FJCC »

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.
lunter
Posts: 28
Joined: Fri May 29, 2009 9:16 am

Re: [Writer] Horizontal line

Post by lunter »

Thanks, it works perfect!
OOo 3.3.X on MS Windows 7
Post Reply