[BASIC} où trouver les paramètres de .uno:InsertIndexesEntry

Bonjour,

Pour écrire une macro, où trouver les paramètres de .uno:InsertIndexesEntry ?

Quand j'enregistre en macro la commande Insertion | Entrée d'index, la ligne est sans paramètres et commentée.

Merci

Bonjour,

Bon, aucune info sur la macro enregistrée.

J'ai trouvé un prog C++, il faut maintenant le convertir en BASIC :

/** This method demonstrates how to insert indexes and index marks */
protected void IndexExample () {
   try { // Go to the end of the document
     xDocCursor.gotoEnd( false ); // Insert a new paragraph and position the cursor in it
     mxDocText.insertControlCharacter ( mxDocCursor,
       ControlCharacter.PARAGRAPH_BREAK, false );

     XParagraphCursor xParaCursor = (XParagraphCursor)
       UnoRuntime.queryInterface( XParagraphCursor.class, mxDocCursor );
     xParaCursor.gotoPreviousParagraph ( false );

     // Create a new ContentIndexMark and get it's XPropertySet interface
     XPropertySet xEntry = (XPropertySet)
       UnoRuntime.queryInterface( XPropertySet.class,
         mxDocFactory.createInstance ( "com.sun.star.text.ContentIndexMark" ) );

     // Set the text to be displayed in the index
     xEntry.setPropertyValue ( "AlternativeText", "Big dogs! Falling on my head!" );

     // The Level property _must_ be set
     xEntry.setPropertyValue ( "Level", new Short ( (short) 1 ) );

     // Create a ContentIndex and access it's XPropertySet interface
     XPropertySet xIndex = (XPropertySet)
       UnoRuntime.queryInterface( XPropertySet.class,
         mxDocFactory.createInstance ( "com.sun.star.text.ContentIndex" ) );

     // Again, the Level property _must_ be set
     xIndex.setPropertyValue( "Level", new Short ( (short) 10 ) );

     // Access the XTextContent interfaces of both the Index and the IndexMark
     XTextContent xIndexContent = (XTextContent)
       UnoRuntime.queryInterface( XTextContent.class, xIndex );

     XTextContent xEntryContent =(XTextContent)
       UnoRuntime.queryInterface( XTextContent.class, xEntry );

     // Insert both in the document
     mxDocText.insertTextContent( mxDocCursor, xEntryContent, false );

     mxDocText.insertTextContent( mxDocCursor, xIndexContent, false );

     // Get the XDocumentIndex interface of the Index
     XDocumentIndex xDocIndex = (XDocumentIndex)
     UnoRuntime.queryInterface( XDocumentIndex.class, xIndex );

     // And call it's update method
     xDocIndex.update();
   } catch (Exception e) {
     e.printStackTrace ( System.out );
   }
}

Bonjour,

Je devrais trouver mon bonheur ici :
https://api.libreoffice.org/examples/basic/text/creating_an_index/

Bonne journée

Bonjour Stéphane,

Bonjour,

Je devrais trouver mon bonheur ici :
https://api.libreoffice.org/examples/basic/text/creating_an_index/

c'est bien quand on répond à ses propres questionnements :wink:

Merci pour l'info !

Bien cordialement,

Bonjour,

Un extrait reconstitué et utilisable :

sub es2
   Dim oDoc as Object
   oDoc = ThisComponent

   Dim oText as Object
   oText = oDoc.Text

   Dim oCursor as Object
   oCursor = oText.createTextCursor

   Dim oCurSelection as Object
   oCurSelection = thisComponent.getCurrentSelection()

'https://api.libreoffice.org/docs/idl/ref/servicecom_1_1sun_1_1star_1_1text_1_1DocumentIndexMark.html#a120a1795ce3b74d5569c626f3316fed0

   Dim oIndexEntry as Object
   oIndexEntry = oDoc.createInstance( "com.sun.star.text.DocumentIndexMark")
   oIndexEntry.AlternativeText = "MonEntree"
   oDoc.text.insertTextContent( oCursor, oIndexEntry, TRUE)

   oCursor.GotoEnd( FALSE)
   oText.insertControlCharacter(oCursor,_
     com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK, FALSE)
   oText.insertControlCharacter(oCursor,_
     com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK, FALSE)
   oCursor.goLeft(1, FALSE)

   Dim oIndex as Object
   oIndex = oDoc.createInstance("com.sun.star.text.DocumentIndex")
   oIndex.UseCombinedEntries = TRUE
   oIndex.Title = "Index"
   oIndex.UsePP = TRUE
   oText.insertTextContent(oCursor, oIndex, FALSE)
   oIndex.update()

end sub

Bonjour,

Un extrait reconstitué et utilisable :

Merci Stéphane ! Je vais (re)garder ce bout de code pour usage ultérieur...

Bien cordialement,