12 messages in org.openoffice.fr.progRe: [prog] [Fwd: Re: [users-fr] [text...
FromSent OnAttachments
Agnès SimonetJun 27, 2004 9:32 am 
Agnès SimonetJun 27, 2004 9:32 am 
Agnès SimonetJun 27, 2004 9:51 am 
Yves ChaufourJun 27, 2004 1:31 pm 
Agnès SimonetJun 27, 2004 2:06 pm 
Jean Michel PIERREJun 28, 2004 3:28 am 
Agnès SimonetJun 28, 2004 4:06 am 
Jean Michel PIERREJun 28, 2004 4:46 am 
Agnès SimonetJun 28, 2004 5:38 am 
Jean Michel PIERREJun 28, 2004 6:42 am 
Jean-Michel CHASTAGNIERJun 28, 2004 6:54 am 
Agnès SimonetJun 28, 2004 1:07 pm 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: [prog] [Fwd: Re: [users-fr] [texte] encadrement d'un mot]Actions...
From:Agnès Simonet (agne@laposte.net)
Date:Jun 28, 2004 4:06:35 am
List:org.openoffice.fr.prog

Le 28/06/04 12:28, Jean Michel PIERRE a écrit :

Agnès bonjour, Pourrais-tu, si cela t'est possible, me redonner le texte complet de macro (super travail !) avec cette correction pour que je teste ? merci. J.M

Le voici le voilà, sans erreur j'espère. Attention, ton programme de courrier (ou le mien ?) risque de sectionner certaines lignes trop longues en insérant une fin de paragraphe. Si tu fais un couper-coller, il faudra les supprimer après coup. C'est pourquoi j'ai indiqué entre parenthèses le nombre de ligne de code de chaque partie.

--------------------------- Sub encadre_selection

'à faire : gérer l'alignement vertical si plusieurs tailles 'de caractère dans la ligne

'à faire : macro inverse texterectangle ---> texte simple

'v0.2.0 'le texte sélectionné ne doit pas contenir des sauts de ligne 'ou des sauts de paragraphe sinon bizarreries

Dim MonDocument As Object, MonTexte As Object Dim MonCurseur As Object Dim CurseurVisible As Object Dim MonRectangle As Object Dim TailleRectangle As New com.sun.star.awt.Size Dim TexteDeLaSelection As String Dim TextRectangle As String Dim CurseurRectangle As Object

'récupère la sélection (4 lignes) MonDocument = ThisComponent MonTexte = MonDocument.Text CurseurVisible = MonDocument.currentcontroller.ViewCursor TexteDeLaSelection = CurseurVisible.String

'crée et positionne le curseur d'écriture (1 ligne) MonCurseur = MonTexte.createTextCursorByRange(CurseurVisible)

'crée un mini rectangle (5 lignes hors commentaires) TailleRectangle.Width = 1 TailleRectangle.Height = 1 'MonRectangle = MonDocument.createInstance("com.sun.star.drawing.RectangleShape") 'TextAutoGrowWidth ne fonctionne pas avec un rectangleshape MonRectangle=MonDocument.createInstance("com.sun.star.drawing.TextShape") MonTexte.insertTextContent( MonCurseur,MonRectangle,true) MonRectangle.Size = TailleRectangle

'ancrage comme caractère (1 ligne) MonRectangle.AnchorType = com.sun.star.text.TextContentAnchorType.AS_CHARACTER

'contour (1 ligne) MonRectangle.LineStyle = com.sun.star.drawing.LineStyle.SOLID

'centre le rectangle (1 ligne) MonRectangle.VertOrient = com.sun.star.text.VertOrientation.CHAR_CENTER

'centre verticalement le texte du rectangle (1 ligne) MonRectangle.TextVerticalAdjust = com.sun.star.drawing.TextVerticalAdjust.CENTER

'adapte la taille du rectangle à celle du texte (2 lignes) MonRectangle.TextAutoGrowWidth = true MonRectangle.TextAutoGrowHeight = true

'place un curseur dans le rectangle (2 lignes) TexteRectangle = MonRectangle.Text CurseurRectangle=TexteRectangle.createTextCursor

'écrire dans le rectangle 'récupère le format de caractère: 'police,taille,gras,italique,souligné,couleur (6 lignes) CurseurRectangle.CharFontName = CurseurVisible.CharFontName CurseurRectangle.CharHeight = CurseurVisible.CharHeight CurseurRectangle.CharWeight = CurseurVisible.CharWeight CurseurRectangle.CharPosture = CurseurVisible.CharPosture CurseurRectangle.CharUnderLine = CurseurVisible.CharUnderLine CurseurRectangle.CharColor = CurseurVisible.CharColor 'écrit avec format de caractère (1 ligne) TexteRectangle.insertString(CurseurRectangle,TexteDeLaSelection,TRUE) End sub