1 message in org.openoffice.fr.progRe: [prog] Déconnecter un lien par l'API
FromSent OnAttachments
Marceau GUIHARDSep 25, 2006 2:17 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:Re: [prog] Déconnecter un lien par l'APIActions...
From:Marceau GUIHARD (marc@wanadoo.fr)
Date:Sep 25, 2006 2:17:15 am
List:org.openoffice.fr.prog

Merci de ta réponse, je vais essayer de traduire ça en OOo Basic. Cordialement

Marceau

emma@fr.thalesgroup.com a écrit :

Bonjour,

Il est tout à fait possible d'intégrer une image dans le document via l'API (sans lien). Le code n'est pas trivial, mais je l'utilise et ça fonctionne très bien. Je l'ai récupérer sur le forum anglophone : http://www.oooforum.org

Voici le code en C++ (pour un document "writer") :

char aFileName[200]; // nom de l'image avec chemin complet strcpy(aFileName, "IMAGE A INSERER");

char aStr[1024]; OUString sGraphicUrl, anOUString;

// Création d'un objet graphique Reference <XPropertySet> xGraphic = Reference <XPropertySet> ( mDocFactory->createInstance(OUString(
RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.GraphicObject" ))), UNO_QUERY );

sprintf (aStr, "file://%s", aFileName); // chemin + nom de l'image à insérer sGraphicUrl = OUString (aStr,
(sal_Int32)strlen(aStr),RTL_TEXTENCODING_ISO_8859_1 );

// Créer une image dans le document pour ne plus avoir de lien avec le fichier Reference <XNameContainer> xBitmap= Reference <XNameContainer>
(mDocFactory->createInstance(OUString(
RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.BitmapTable" ))), UNO_QUERY );

sprintf (aStr, "InternalImage_%s", aFileName); // création d'une bitmap dans
le document // avec un nom au choix

xBitmap->insertByName(OUString::createFromAscii(aStr), makeAny(sGraphicUrl));
// remplissage des pixels de la bitmap avec ceux de l'image à intégrer et intégration dans le
doc xBitmap->getByName(OUString::createFromAscii(aStr)) >>= anOUString; //
récupération de l'URL // de l'image intégrée dans le document (URL créée automatiquement par OO)

xGraphic->setPropertyValue(OUString::createFromAscii("GraphicURL"),
makeAny(anOUString)); // utilisation de l'URL pour l'objet graphique.

Intégrer ensuite l'objet graphique dans le document à l'emplacement souhaité.

Cordialement, Emmanuel