

![]() | Start a set with this search |
![]() | Include this search in one of my sets |
![]() | Exclude this search from one of my sets |
![]() | Permalink to these results Paste this link in email or IM: |
| Atom feed for tracking future search results Paste this URL into your reader: |
5 messages in org.openoffice.fr.progRe: [prog] Draw : récupérer les coord...| From | Sent On | Attachments |
|---|---|---|
| Matthieu Coutiere | Apr 15, 2004 1:53 am | |
| gerard | Apr 16, 2004 1:54 am | |
| Matthieu Coutiere | Apr 16, 2004 9:38 am | |
| gerard | Apr 16, 2004 11:30 am | |
| Matthieu Coutière | Apr 19, 2004 1:15 am |

![]() | Permalink for this message Paste this link in email or IM: |
![]() | Permalink for this thread Paste this link in email or IM: |
| Atom feed for this thread Paste this URL into your reader: |
| Subject: | Re: [prog] Draw : récupérer les coord. de points | Actions... |
|---|---|---|
| From: | gerard (gera...@oreka.com) | |
| Date: | Apr 16, 2004 11:30:46 am | |
| List: | org.openoffice.fr.prog | |
On Friday 16 April 2004 18:39, Matthieu Coutiere wrote:
Bonjour, Bonjour, aSelected = ThisComponent.getCurrentSelection()
et là, je n'ai pas trouvé comment obtenir ma suite d'objets "LineShape" ou autres.
aSelected est une ShapeCollection, et je n'arrive pas à sélectionner ma première Shape (j'obtiens un objet proche du Text)
Voici un petit exemple qui trace un segment parallèle au(x) segment(s) sélectionné(s). Sub Decale ' Un ou plusieurs segments, étant ' sélectionnés, une nouvelle entité est créée décalée ' d une certaine distance Dim oCoord as New com.sun.star.awt.Point Dim oSize as New com.sun.star.awt.Size Dim oNewShape as Object Dim nDist as Long, nAngle as Long, nUnit as Long Dim dScale as Double Dim sRep as String
oDoc = ThisComponent oDrawPage = oDoc.DrawPages(0) settings = oDoc.createInstance("com.sun.star.drawing.DocumentSettings") nUnit = settings.getPropertyValue("MeasureUnit") dScale = CDbl(settings.ScaleNumerator) / CDbl(settings.ScaleDenominator) MsgBox "echelle : " & dScale
oShapes = oDoc.getCurrentSelection() nbEntitySelected = oShapes.getCount() MsgBox "nombre entités sélectionnées " & nbEntitySelected If nbEntitySelected = 0 Then MsgBox "Une entité doit être sélectionnée" Exit Sub End If For i = 0 To nbEntitySelected-1 MsgBox "type de polygone " & oShapes(i).PolygonKind poly = oShapes(i).PolyPolygon point = poly(0) sRep = inputBox("Indiquer le décalage", "à droite = < 0 ; à gauche = > 0", "1234") nDist = CLng(CDbl(sRep) * dScale * 100) nAngle = oShapes(i).getPropertyValue("RotateAngle") oCoord.X = Iif(point(0).X <= point(1).X, point(0).X, point(1).X) + nDist * cos(nAngle * Pi / 18000 + Pi / 2) oCoord.Y = Iif(point(0).Y <= point(1).Y, point(0).Y, point(1).Y) - nDist * sin(nAngle * Pi / 18000 + Pi / 2) oNewShape = oDoc.createInstance("com.sun.star.drawing.LineShape") oNewShape.setPosition(oCoord) oNewShape.setSize(oShapes(i).Size) oDrawPage.add(oNewShape) Next i End Sub
J'ai aussi essayé aType = (PolygonShape) aSelected.getByIndex(0) mais cela ne marche pas (erreur de syntaxe...)
On ne peut pas faire de "cast" en BASIC
ou : xDrawPage = ThisComponent.getDrawPages() xShapes = UnoRuntime.queryInterface(XShapes.class, xDrawPage); mais ça ne marche pas non-plus (exemple issu du SDK).
Les exemples du SDK sont la plupart en java, pour le BASIC les interfaces sont pour la plupart directement disponibles
Est-ce difficile ? Ou suis-je médiocre ?
Au début j'ai galéré pour comprendre le SDK, mais à force de fouiller dedans on saisit le schéma de fonctionnement et cela semble plus facile (quoique souvent il faut que je relise quatre fois pour comprendre)
Merci !
J'espère avoir un peu mieux aidé ce coup-ci.
-- gerard deneux







