Afficher le code html de la selection courante avec DOM
bonjour
Helo je veux savoir comment récupérer les propriétés (la source, hauteur, largeur ...) une image chargée avec gecko (gecko sdk delphi). xpcom aide. Voici la fonction Ajouter :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
| procedure inserer_image()
var
ss,src,dest,dest1:string;
img,br: nsIDOMElement;
s1,s2: IInterfacedString;
EditorDocument: nsIDOMNSHTMLDocument;
begin
//Insérer un Elèment image
s1:=NewString('img');
img:=mDocument.CreateElement(s1.AString);
//border
s1:=NewString('border');
s2:=NewString(FormValideEditionImage.Edit_LargeurBordure.text);
img.SetAttribute(s1.AString,s2.AString);
//
s1:=NewString('src');
s2:=NewString('file:///'+c:/image.png);
img.SetAttribute(s1.AString,s2.AString);
......
InsertNode(img);
end;
procedure TForm6.InsertNode(const aInsertNode: nsIDOMElement);
var
mDocument: nsIDOMDocument;
Sel: nsISelection;
Range: nsIDOMRange;
Container: nsIDOMNode;
DocR: nsIDOMDocumentRange;
iPos: PRUint32;
NodeValue: IInterfacedString;
AfterNode: nsIDOMNode;
BeforeNode: nsIDOMNode;
TextNode: nsIDOMNode;
TextBefore,TextAfter: WideString;
begin
// récupèrer la l'objet sélectioné
Sel:=GeckoBrowser1.ContentWindow.GetSelection;
Range:=Sel.GetRangeAt(0); // le premier élément selectioné
// tout déselectionner
sel.RemoveAllRanges();
// supprimer le contenu de la sélection en cours du document
range.deleteContents();
// obtenir l'alocation de la sélection courante
Container:=Range.StartContainer;
ipos:=Range.startOffset;
// faire une nouvelle Range pour la nouvelle sélection
DocR:=mDocument as nsIDOMDocumentRange;
Range:=DocR.CreateRange;
if (Container.NodeType=3) and (aInsertNode.NodeType=3) then
begin
// if we insert text in a textnode, do optimized insertion
NodeValue:=NewString;
aInsertNode.GetNodeValue(NodeValue.AString);
(Container as nsIDOMCharacterData).InsertData(iPos, NodeValue.AString);
// put cursor after inserted text
Range.SetEnd(Container, iPos+(aInsertNode as nsIDOMCharacterData).Length);
Range.SetStart(Container, iPos+(aInsertNode as nsIDOMCharacterData).Length);
....
....
// insert the 3 new nodes before the old one
Container.InsertBefore(AfterNode, TextNode);
Container.InsertBefore(aInsertNode, AfterNode);
Container.InsertBefore(BeforeNode, aInsertNode);
// remove the old node
Container.RemoveChild(TextNode);
end
else
begin
// else simply insert the node
AfterNode:=Container.ChildNodes.Item(ipos);
Container.InsertBefore(aInsertNode, AfterNode);
end;
Range.SetEnd(AfterNode, 0);
Range.SetStart(AfterNode, 0);
end;
Sel.AddRange(Range);
end; |
Je veux récupérer le code html de l'image sélectionné quand je double clic sur l'image.
Avez vous une piste pour résoudre ce problème (en Delphi ou dans autre langage de programmation )
Merci