2 messages in org.openoffice.fr.prog[prog] Liste énumérée, récupération d...
FromSent OnAttachments
BobOct 23, 2004 7:36 am 
Bernard MarcellyOct 27, 2004 2:28 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] Liste énumérée, récupération du caractère "puce" (BulletChar)Actions...
From:Bob (mlo@bobiciel.com)
Date:Oct 23, 2004 7:36:21 am
List:org.openoffice.fr.prog

Bonjour,

Pour ajouter le support des listes à ma macro copier/coller pour WikiWiki, je souhaite récupérer le caractère puce qui est éventuellement associé à un paragraphe d'une liste énumérée. Je me suis inspiré d'un exemple de code d'Andrew Pitonyak sur OOoForum, ça marche, mais ma solution ne m'a pas l'air très optimisée. J'ai essayé d'approfondir les choses avec XRay (excellent millésime, cette version 4 :-) merci Bernard), mais j'aurai besoin de vos lumières car je ne comprends pas tout.

Je suppose qu'il doit être possible d'accéder à la propriété (ou pseudo-propriété ?) "BulletChar" sans parcourir toute la boucle comme dans le code ci-dessous ? (RMQ 1)

D'autre part, pour que ça marche avec la boucle for/next, je suis obligé d'affecter des variables sName et sValue (RMQ2) ! Si j'écris directement la ligne sous RMQ 3, ça ne marche pas ! je ne comprends pas pourquoi.

Si vous pouviez me donner un coup de main, ce serait sympa

D'avance merci

Bob

La macro WikiWiki (Spip, Wikipedia, Wikini) : http://www.bobiciel.com/maxopeninfo/default_zone/fr/html/page-271.html

<code> function BulletChar(oTheParagraph as object) as string dim sName as string dim sValue as string dim oRules dim oX dim i as Integer on error resume next

BulletChar = "" if (not isNull(oTheParagraph.NumberingRules) and not isEmpty(oTheParagraph.NumberingRules)) then oRules = oTheParagraph.NumberingRules oX = oRules.getByIndex(oTheParagraph.NumberingLevel) ' XRay.XRay oRules ' XRay.XRay oX

' RMQ 1: voir si l'on ne peut pas faire un getPropertyValue("BulletChar") plutot que cette boucle for i = lbound(oX) to ubound(oX) ' RMQ 2: voir pourquoi il faut passer par cette affectation dans 2 string pour que ca marche !!! sName = oX(i).Name sValue = oX(i).Value ' RMQ 3: voir pourquoi cette ligne ne marche pas !!! ' if (oX(i).Name = "BulletChar") and (oX(i).Value <> "") then if (sName = "BulletChar") and (sValue <> "") then BulletChar = oX(i).Value ' RMQ: pour debug 'MsgBox "bullet=" & oX(i).Value exit for end if next end if

end function

</code>