Bonjour

Une première proposition, un peu bricolage, mais bon... elle pourra 
éventuellement inspirer des idées meilleures.

Je ne suis d'ailleurs pas sûr d'avoir bien compris le contexte. 
Ce que fait la macro ci-dessous : 

1. on suppose que le presse-papiers contient un objet formule
2.  la macro insère au point d'insertion un cadre 
- ancré comme caractère
- taille automatique (mais réduite au départ)
- sans bordures
3. Positionnement dans le cadre
4. Collage spécial GDI


sub PysFormuleGDI

dim document   as object
dim dispatcher as object
dim args1(4) as new com.sun.star.beans.PropertyValue
dim args2(0) as new com.sun.star.beans.PropertyValue
dim LibONoLine as new com.sun.star.table.BorderLine2
 
with LibONoLine
        .Color = 0
        .InnerLineWidth = 0
        .LineDistance = 0 
        .LineStyle = 0
        .LineWidth = 0
        .OuterLineWidth = 0
end with

document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

args1(0).Name = "AnchorType"
args1(0).Value = 1
args1(1).Name = "Pos.X"
args1(1).Value = 0
args1(2).Name = "Pos.Y"
args1(2).Value = 0
args1(3).Name = "Size.Width"
args1(3).Value = 340
args1(4).Name = "Size.Height"
args1(4).Value = 340

dispatcher.executeDispatch(document, ".uno:InsertFrame", "", 0, args1())

with thiscomponent.currentselection
        .FrameIsAutomaticHeight = true
        .WidthType = com.sun.star.text.SizeType.MIN ' 2
        .VertOrient = com.sun.star.text.VertOrientation.CHAR_CENTER     '5
        .string = " "
    .LeftBorder = LibONoLine
    .LeftBorderDistance = 0
    .RightBorder = LibONoLine
    .RightBorderDistance = 0
    .TopBorder = LibONoLine
    .TopBorderDistance = 0
    .BottomBorder = LibONoLine
    .BottomBorderDistance = 0
end with 

LibOText = thiscomponent.currentselection.Text
LibOCursor = LibOText.createTextCursor
LibOCursor.gotoEnd(true)

' Ci-dessous pour désactiver la sélection et entrer dans le cadre
dispatcher.executeDispatch(document, ".uno:Undo", "", 0, Array())

args2(0).Name = "SelectedFormat"
args2(0).Value = 3

dispatcher.executeDispatch(document, ".uno:ClipboardFormatItems", "", 0,
args2())


end sub



Cordialement
Pierre-Yves



--
View this message in context: 
http://nabble.documentfoundation.org/API-et-presse-papier-tp4018698p4018758.html
Sent from the Users mailing list archive at Nabble.com.

-- 
Envoyez un mail à users+h...@fr.libreoffice.org pour savoir comment vous 
désinscrire
Les archives de la liste sont disponibles à 
http://listarchives.libreoffice.org/fr/users/
Tous les messages envoyés sur cette liste seront archivés publiquement et ne 
pourront pas être supprimés

Répondre à