macro : bordure de tableau dans Writer

Bonjour,

Je cherche à rajouter des bordures doubles dans un tableau sous writer par macro.

En cherchant sur le Net, j'ai trouvé borderline2 qui comprend un élément style permettant à priori de définir le style d'encadrement.

Par contre dans l'objet "TextTables" l'élément style n'existe pas et donc le type de bordure ne se met pas à jour.

Quelqu'un connaît-il un moyen d'y parvenir ?

Voici un extrait de ma macro

option explicit

sub FormatTableau

dim UnTableau as object, BordureTableau as object
dim Bordure as new com.sun.star.table.BorderLine2

with Bordure
    .Color = 26316
    .InnerLineWidth = 1
    .LineDistance = 0
    .OuterLineWidth = 10
    .linestyle = 5
end with

UnTableau = thiscomponent.TextTables(0)
BordureTableau = UnTableau.TableBorder
BordureTableau.LeftLine = Bordure
UnTableau.TableBorder = BordureTableau

end sub

merci

Claude

Bonjour

Le fil suivant contient des exemples :
http://nabble.documentfoundation.org/Writer-Macro-formatage-de-tableau-td3266372i20.html#a3278699

Ci-dessous adapté pour réaliser une bordure double extérieure
(et enlever les bordures internes). Le programme travaille sur le
tableau "courant" (le curseur doit être dans un tableau).

Nota: passer un fort zoom pour visualiser la bordure double...

Cordialement
Pierre-Yves

option explicit
sub PysTableFull

dim PysCursor as object, PysTable as object, PysTableBorder as object
dim PysLine as new com.sun.star.table.BorderLine
dim PysNoLine as new com.sun.star.table.BorderLine

PysCursor = thisComponent.currentController.viewCursor

if (isEmpty(PysCursor.textTable)) then
  msgbox "Le curseur n'est pas dans un tableau", 64, "Mise en forme du
tableau"
else
  with PysLine
    .Color = 0
    .InnerLineWidth = 12
    .LineDistance = 12
    .OuterLineWidth = 12
  end with
  with PysNoLine
    .Color = 0
    .InnerLineWidth = 0
    .LineDistance = 0
    .OuterLineWidth = 0
  end with

  PysTable = PysCursor.TextTable
  PysTableBorder = PysTable.TableBorder
  PysTableBorder.IsLeftLineValid = true
  PysTableBorder.IsRightLineValid = true
  PysTableBorder.IsTopLineValid = true
  PysTableBorder.IsBottomLineValid = true
  PysTableBorder.IsHorizontalLineValid = true
  PysTableBorder.IsVerticalLineValid = true
  PysTableBorder.LeftLine = PysLine
  PysTableBorder.RightLine = PysLine
  PysTableBorder.TopLine = PysLine
  PysTableBorder.BottomLine = PysLine
  PysTableBorder.HorizontalLine = PysNoLine
  PysTableBorder.VerticalLine = PysNoLine
  PysTable.TableBorder = PysTableBorder
  PysTable.HoriOrient = com.sun.star.text.HoriOrientation.FULL
end if

end sub

Suite...

En complément un exemple utilisant une structure BorderLine2
pour modifier cette fois une cellule:

sub PysBorderCell

dim PysTable as object
dim PysCell as object
dim PysLine as new com.sun.star.table.BorderLine2

with PysLine
  .Color = 0
  .InnerLineWidth = 10
  .LineDistance = 60
  .LineStyle = com.sun.star.table.BorderLineStyle.DOUBLE
  .LineWidth = 2
  .OuterLineWidth = 10
end with

PysTable = thiscomponent.TextTables.getByName("Tableau1")
PysCell = PysTable.getCellByName("B2")

with PysCell
  .LeftBorder = PysLine
  .LeftBorderDistance = 100
  .RightBorder = PysLine
  .RightBorderDistance = 100
  .TopBorder = PysLine
  .TopBorderDistance = 100
  .BottomBorder = PysLine
  .BottomBorderDistance = 100
end with

end sub

Bonjour,

Merci cela fonctionne en passant par les cellules.

Bonne journée

Claude

-------- Message original --------
Sujet : [fr-users] Re: macro : bordure de tableau dans Writer
Pour : users@fr.libreoffice.org