How do I draw a bottom border line using macro in the header?

asked 2019-02-19 16:22:57 +0100

Craig22 gravatar image

Hello,

I have the intention to me a GUI programming, with which I am comfortable several new page templates can create.

If a page template with the same name exists, it will be deleted from the program. Then a new page template with the same name, created on the basis of the specified properties.

This can be done only partially. My problem is that I am not in the header, nor in the footer can draw a border line.

Using MRI are the correct struct properties are displayed:

REM Borderline Struct
REM Header = BottomBorder
REM Footer = TopBorder
Dim aLine as New com.sun.star.table.BorderLine
    aLine.OuterLineWidth = 35
    aLine.InnerLineWidth=10
    aLine.LineDistance = 10
    aLine.Color=RGB(255,0,0)
mri aLine

Now I tried in a simple way that struct the page template to assign:

oPageStyle.HeaderBottomBorder=aLine

This does not work.

Here is the entire code:

REM  *****  BASIC  *****

REM ╔═══════════════════════════════════════════════════════════════════════╗
REM ║                                                                       ║
REM ║   This macro creates a new page style with the defined properties.    ║
REM ║   If a page style with the same name exists,                          ║
REM ║   then the old style will be deleted                                  ║
REM ║                                                                       ║
REM ╚═══════════════════════════════════════════════════════════════════════╝

Dim oPageStyle as Object

Sub NewLeftPageStyle()
Dim oDoc As Object
'Dim oPageStyle as Object

Dim nCnt as Integer
Dim sStyle as String

oDoc=ThisComponent

REM Example:
REM sStyle= "My_Pagestyle Left Page"
sStyle= InputBox ("Please insert the new PageStyle Name: ","New PageStyle")

REM PageStyle-Objekt
oPageStyle = oDoc.createInstance( "com.sun.star.style.PageStyle" )

'mri oDoc.StyleFamilies.getByName("PageStyles")

REM PageStyle Counter for all existing Pagestyles
nCnt=oDoc.StyleFamilies.getByName("PageStyles").Count

    for i = 0 to nCnt-1
        ' If new PageStyle-Name = old PageStyle-Name, then delete old Pagestyle
        If sStyle=odoc.StyleFamilies.getByName("PageStyles").getByIndex(i).Name then
            ' delete
            odoc.StyleFamilies.getByName("PageStyles").removeByName(sStyle)
                exit for
        End if
    next i

REM Borderline Struct
REM Header = BottomBorder
REM Footer = TopBorder
Dim aLine as New com.sun.star.table.BorderLine
    aLine.OuterLineWidth = 35
    aLine.InnerLineWidth=10
    aLine.LineDistance = 10
    aLine.Color=RGB(255,0,0)

' mri aLine 
' mri oPageSTyle

    REM New PageStyle-Properties
    With oPageStyle
        ' Name
        .Name=sStyle
'       .BorderDistance
'       .BottomBorder=aLine
'       .BottomBorderDistance
        .BottomMargin=1000
        .FooterBodyDistance=1
        .FooterBorderDistance=10
'       .FooterBottomBorder=aLine
        .FooterBottomBorderDistance=12
        .FooterDynamicSpacing=100
        .FooterHeight=100
        .FooterIsDynamicHeight=true
        .FooterIsOn=True
        .FooterIsShared=False
        .FooterLeftMargin=100
        .FooterRightMargin=100
        .FooterTopBorderDistance=10
        .FootnoteHeight=100
        .HeaderIsOn=True
        .HeaderBackColor=RGB(255,0,0)
        .HeaderBodyDistance=100
        .HeaderBorderDistance=150
REM --> don't works 
REM there is no line in Header visible
        .HeaderBottomBorder=aLine
        .HeaderBottomBorderDistance=100
        .HeaderDynamicSpacing=100
        .HeaderHeight=1000
        .HeaderIsDynamicHeight=True
        .HeaderIsShared=False
        .HeaderLeftMargin=100
        .HeaderRightMargin=100
        .Height=21000
        .IsLandscape=False
        .LeftMargin=1000
        .RightMargin=1000
        .TopMargin=1000
        .Width=15000

    End With

    ' Create new PageStyle with the Properties above
    oDoc.StyleFamilies.getByName( "PageStyles" ).insertByName(sStyle,oPageStyle )
End Sub

Which Code statement is correct to draw a thin line under the header.

Cheers

Craig

edit retag flag offensive close merge delete