3 messages in org.openoffice.fr.prog[prog] Soustraction de secteurs circu...
FromSent OnAttachments
Agnès SimonetJan 12, 2005 11:31 am 
Bernard MarcellyJan 14, 2005 7:11 am 
Agnès SimonetJan 14, 2005 10:05 am 
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:[prog] Soustraction de secteurs circulairesActions...
From:Agnès Simonet (agne@laposte.net)
Date:Jan 12, 2005 11:31:51 am
List:org.openoffice.fr.prog

Bonjour,

J'ai un problème que je n'arrive pas à résoudre. Par macro (voir ci-dessous), je trace un premier secteur de cercle puis un second plus petit et avec un angle au centre plus ouvert. Ensuite je les soustrait. Tout va bien sauf si les positions des 2 secteurs sont telles qu'ils aient le même centre. Dans ce cas j'obtiens une forme combinée et le résultat est très différent de celui escompté.

Je crois d'ailleurs que la macro n'y est pour rien puisque je peux reproduire le problème en dessinant à la main.

Quoiqu'il en soit si quelqu'un pouvait m'aider à m'en sortir, j'en serais ravie.

Agnès S.

********************* LA MACRO ******************************* Option Explicit

Sub SoustractionCercles

Dim Doc As Object , Control As Object Dim Frame As Object, LaPage As Object Dim GrandCercle As Object,PetitCercle As Object Dim tailleForme As New com.sun.star.awt.Size Dim positionForme As New com.sun.star.awt.Point Dim Collection As Object Dim Dispatcher As Object Dim arg() As new com.sun.star.beans.PropertyValue '------------- 'là où il faut '------------- Doc = ThisComponent ' document model Control = Doc.getCurrentController() ' get document controller from the model Frame = Control.getFrame() ' get the frame from the controller LaPage = Control.CurrentPage '------ 'dessin '------ GrandCercle = Doc.createInstance("com.sun.star.drawing.EllipseShape") tailleForme.Width = 4000 tailleForme.Height = 4000 positionForme.x = 5000 positionForme.y = 5000 GrandCercle.Size = tailleForme GrandCercle.Position = positionForme GrandCercle.CircleKind = com.sun.star.drawing.CircleKind.SECTION GrandCercle.CircleStartAngle = -4500 GrandCercle.CircleEndAngle = 4500 LaPage.add(GrandCercle)

PetitCercle = Doc.createInstance("com.sun.star.drawing.EllipseShape") tailleForme.Width = 2000 tailleForme.Height = 2000 'il suffit de mettre 6001 dans la ligne suivante 'pour que le problème disparaisse positionForme.x = 6000 'donc même centre que GrandCercle positionForme.y = 6000 PetitCercle.Size = tailleForme PetitCercle.Position = positionForme PetitCercle.CircleKind = com.sun.star.drawing.CircleKind.SECTION PetitCercle.CircleStartAngle = -5500 PetitCercle.CircleEndAngle = 5500 LaPage.add(PetitCercle)

'------------ 'soustraction '------------ 'place les formes dans une collection Collection = createUnoService("com.sun.star.drawing.ShapeCollection") Collection.add(GrandCercle) Collection.add(PetitCercle) 'sélectionne la collection Control.Select(Collection) 'soustrait les 2 formes Dispatcher = createUnoService( "com.sun.star.frame.DispatchHelper" ) Dispatcher.executeDispatch( Frame, ".uno:Substract", "", 0, arg())

End Sub **************************************************************