[Solved] Writer, Horizontal line

Java, C++, C#, Delphi, ??? - Using the UNO bridges

[Solved] Writer, Horizontal line

Postby lunter » Sat May 30, 2009 6:42 pm

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

Re: [Writer] Horizontal line

Postby FJCC » Sun May 31, 2009 3:12 pm

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   Expand viewCollapse view
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.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
AOO 3.4 or 4.1 on MS Windows XP ( before 2013-08-03) or Windows 7
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
Posts: 6501
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: [Writer] Horizontal line

Postby lunter » Sun May 31, 2009 10:24 pm

Thanks, it works perfect!
OOo 3.3.X on MS Windows 7
Posts: 28
Joined: Fri May 29, 2009 9:16 am

Return to External Programs

Who is online

Users browsing this forum: No registered users and 2 guests