Date: prev next · Thread: first prev next last
2020 Archives by date, by thread · List index


Bonjour oj,

tu y étais presque... Il manquait l'insertion de la section créée dans le texte ;)

Code testé fonctionnel (remplacer l'adresse de l'image par qqch d'utile) :

8< ----------------------------------------------------------

Option Explicit

Sub Main

        Dim lo_Doc As Object
        Dim lo_Sec As Object
        Dim lo_TCur As Object

        lo_Doc = ThisComponent
        lo_TCur = lo_Doc.Text.createTextCursor
        lo_TCur.gotoEnd(False)

lo_Sec = CreateSectionAtCursor(ThisComponent, lo_TCur, "MaSection", "/home/jean-francois/Images/Debian.png")
        
End Sub 'Main

Function CreateSectionAtCursor(ByRef pDoc As Object, pCursor As Object, pSecName As String, pBGName As String) As Object
'creates a section within a given document.
'Input:
'-- pDoc: the target document.
'-- pCursor: the text cursor where to insert the section.
'-- pSecName: the section name.
'-- pBGName: the section background image file name (in URL or OS form).
'Output: the created section object or Null if an error occurred.

        Dim lo_Sec As Object
        
        On Local Error Goto ErrHandler
        
        lo_Sec = pDoc.createInstance("com.sun.star.text.TextSection")
        lo_Sec.Name = pSecName
        lo_Sec.backgraphicURL = ConvertToURL(pBGName)
        pDoc.Text.insertTextContent(pCursor, lo_Sec, False)
        
        ErrHandler:
                'do nothing

        CreateSectionAtCursor = lo_Sec
End Function 'CreateSectionAtCursor

---------------------------------------------------------- >8


Si vous répondez, merci de penser à utiliser la fonction "répondre à tous" de votre logiciel de courrier électronique de façon que la liste reçoive une copie de votre réponse.

Bien cordialement,
Si vous répondez, merci de penser à utiliser la fonction "répondre à tous" de votre logiciel de courrier électronique de façon que la liste reçoive une copie de votre réponse.

Bien cordialement,
--
Jean-Francois Nifenecker, Bordeaux


--
Envoyez un mail à users+unsubscribe@fr.libreoffice.org pour vous désinscrire
Les archives de la liste sont disponibles à https://listarchives.libreoffice.org/fr/users/
Privacy Policy: https://www.documentfoundation.org/privacy

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.