Footnotes and Endnotes

From Apache OpenOffice Wiki
< Documentation‎ | DevGuide
Revision as of 14:30, 3 January 2021 by DiGro (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Footnotes and endnotes are text contents that provide background information for the reader that appears in page footers or at the end of a document.

Footnotes and endnotes implement the service that includes The Footnote service has the interfaces and that inherit from The XFootnote introduces the following methods:

 string getLabel()
 void setLabel( [in] string aLabel)

The Footnote service defines a property ReferenceId that is used for import and export, and contains an internal sequential number.

The interface which is provided by the service accesses the text object in the footnote area where the footnote text is located. It is not allowed to insert text tables into this text object.

While footnotes can be placed at the end of a page or the end of a document, endnotes always appear at the end of a document. Endnote numbering is separate from footnote numbering. Footnotes are accessed using the interface of the text document through the method getFootNotes(). Endnotes are accessed similarly by calling getEndnotes() at the text document's interface. Both of these methods return a

A label is set for a footnote or endnote to determine if automatic footnote numbering is used. If no label is set (= empty string), the footnote is labeled automatically. There are footnote and endnote settings that specify how the automatic labeling is formatted. These settings are obtained from the document model using the interfaces and The corresponding methods are getFootnoteSettings() and getEndnoteSettings(). The object received is a and has the properties described in

Properties of
AnchorCharStyleName string - Contains the name of the character style that is used for the label in the document text.
CharStyleName string - Contains the name of the character style that is used for the label in front of the footnote/endnote text.
NumberingType short - Contains the numbering type for the numbering of the footnotes or endnotes.
PageStyleName string - Contains the page style that is used for the page that contains the footnote or endnote texts.
ParaStyleName string - Contains the paragraph style that is used for the footnote or endnote text.
Prefix string - Contains the prefix for the footnote or endnote symbol.
StartAt short - Contains the first number of the automatic numbering of footnotes or endnotes.
Suffix string - Contains the suffix for the footnote/endnote symbol.
BeginNotice [optional] string - Contains the string at the restart of the footnote text after a break.
EndNotice [optional] string - Contains the string at the end of a footnote part in front of a break.
FootnoteCounting [optional] boolean - Contains the type of the counting for the footnote numbers
PositionEndOfDoc [optional] boolean - If true, the footnote text is shown at the end of the document.

The Footnotes service applies to footnotes and endnotes.

The following sample works with footnotes

  /** This method demonstrates how to create and insert footnotes, and how to access the
      XFootnotesSupplier interface of the document
  protected void FootnoteExample ()
          // Create a new footnote from the document factory and get it's
          // XFootnote interface
          XFootnote xFootnote = (XFootnote) UnoRuntime.queryInterface( XFootnote.class, 
              mxDocFactory.createInstance ( "" ) );
          // Set the label to 'Numbers'
          xFootnote.setLabel ( "Numbers" );
          // Get the footnotes XTextContent interface so we can...
          XTextContent xContent = ( XTextContent ) UnoRuntime.queryInterface ( 
              XTextContent.class, xFootnote );
          // ...insert it into the document
          mxDocText.insertTextContent ( mxDocCursor, xContent, false );
          // Get the XFootnotesSupplier interface of the document
          XFootnotesSupplier xFootnoteSupplier = (XFootnotesSupplier) UnoRuntime.queryInterface(
              XFootnotesSupplier.class, mxDoc );
          // Get an XIndexAccess interface to all footnotes
          XIndexAccess xFootnotes = ( XIndexAccess ) UnoRuntime.queryInterface (
              XIndexAccess.class, xFootnoteSupplier.getFootnotes() );
          // Get the XFootnote interface to the first footnote inserted ('Numbers')
          XFootnote xNumbers = ( XFootnote ) UnoRuntime.queryInterface ( 
              XFootnote.class, xFootnotes.getByIndex( 0 ) );
          // Get the XSimpleText interface to the Footnote
          XSimpleText xSimple = (XSimpleText ) UnoRuntime.queryInterface (
              XSimpleText.class, xNumbers );
          // Create a text cursor for the foot note text
          XTextRange xRange = (XTextRange ) UnoRuntime.queryInterface (
              XTextRange.class, xSimple.createTextCursor() );
          // And insert the actual text of the footnote.
          xSimple.insertString ( 
              xRange, " The numbers were generated by using java.util.Random", false );
      catch (Exception e) 
          e.printStackTrace ( System.out );
Content on this page is licensed under the Public Documentation License (PDL).
Personal tools
In other languages