NAME
OpenOffice::OODoc::Text - The text processing submodule of OpenOffice::OODoc
DESCRIPTION
This manual chapter describes the text-oriented methods of OpenOffice::OODoc, implemented by the OpenOffice::OODoc::Text class, and inherited by the OpenOffice::OODoc::Document class.
These methods are not essentially dedicated to string processing; they are more precisely focused on text containers. A text container is a document element which can (and must) be used in order to support a text and integrate it at the right place and according to the right presentation rules. The OpenDocument specification defines a lot of such containers, and the present API supports many of them, such as paragraphs, headings, tables (or spreadsheets), lists, sections, and draw pages. Some of these containers can host other containers: for example, a table contains rows, a row contains cells, a section can contain almost everything including other sections, etc.
These features are text-oriented, but can be used on documents of any class, such as spreadsheets or presentations as well as text documents. So, the 'Text' word doesn't mean that the features described in the present manual chapter are dedicated to OpenDocument Text (ODT) documents only. In the other hand, a few methods can't apply to any document class (ex: creating or retrieving draw pages makes sense with presentation and drawing documents only).
OODoc::Text should not be explicitly used in an ordinary application, because all its features are available through the OpenOffice::OODoc::Document class, in combination with other features. Practically, the present manual is provided to describe the text-oriented features of OpenOffice::OODoc::Document (knowing that these features are technically supported by the OpenOffice::OODoc::Text component of the API).
The OpenOffice::OODoc::Text class is a specialist derivative of OpenOffice::OODoc::XPath for XML elements which describe the text content of OOo/ODF documents. Here, "text content" means containers that can host text containers (i.e. tables, lists...) as well as flat text.
Knowing that the "styles.xml" member of an OpenDocument file can contain text (because some style definitions, such as page headers or footers, can contain text), the presently described features can be used against this member as well as the "content.xml" member.
This module should be used in combination with OpenOffice::OODoc::Styles, via the OpenOffice::OODoc::Document class, if the application has to handle detailed presentation parameters of text elements. This is because such parameters are held in styles elements and not in the text elements themselves, according to the principle of separation of content and presentation which is one of the foundations of the OpenDocument format.
Methods
Constructor : OpenOffice::OODoc::Text->new(<parameters>)
Short Form: odfText(<parameters>)This constructor should not be explicitly used in ordinary applicationsknowing that all the features of the returned object are inherited byany Document object.See OpenOffice::OODoc::XPath->new for common arguments.Returns an OODoc::XPath OpenDocument connector with additionalfeatures mainly focused on text containers.This constructor is generally not explicitly called, knowing thatit's automatically triggered each time a Document object is created.The XML member loaded by default is 'content.xml'. The most commoncreation method is like this:my $doc = odfText(file => 'my_file.odt');This constructor should generally not be called directly, because it'sinherited by odfDocument().Other parameters can be supplied as options (see the properties listat the end of the chapter).Example:my %delim =('text:h' =>{begin => '\sect{',end => '}'},'text:list-item' =>{begin => '\item'}'text:footnote-body' =>{begin => '\footnote{',end => '}'});my $doc = odfText(file => 'filename.odt',paragraph_style => 'My Paragraphs',heading_style => 'My Headings',delimiters => { %delim });This technique gives the default styles to be used when creating newtext elements. It also gives the particular delimiters (in this caseLaTeX style markers) to be used at the beginning or end of someelements (in this case headings, list elements, footers) where thetext is to be exported "as is". See the getText method ofOODoc::Text for information about exporting text.
appendDrawPage([options])
In a presentation or drawing document, appends a new page at the enof the document.Possible options are:name => page name (unique)id => page numeric ID (unique)style => page style namemaster => master page nameReturns the new draw page element if successful, undef if not.
appendHeading([options])
Creates a new heading of any level and appends it to the end of thedocument.Options are given as a hash [key => value]:'text' => <heading text>'level' => heading level, default is 1'style' => heading style, default is 'Heading 1'Examples:$doc->appendHeading(text => 'Next section');adds the text 'Next section' as a level 1 heading.$doc->appendHeading(text => 'Chapter Conclusion',level => '2',style => 'Heading_20_2');adds a level 2 heading to the end of the text body. 'Heading_20_n'styles, where 'n' is the level number, are presently available bydefault in OpenOffice.org.You can give any XML attribute to the new heading except for style orheading level. In this case, the program must construct a hashcontaining pairs of key-values for the attributes you want to createand pass it using the 'attribute' option. Example:my %attr = ( 'att1' => 'value1', 'att2' => 'value2' );$doc->appendHeading(text => 'Attributes are important',level => '1',style => 'Chapter heading',attributes => {%attr});If the 'text' option is empty, the heading is created with an emptycontent.Caution, creating headings with level attributes is not alwayssufficient to produce the needed result. For example, in order togenerate headings with appropriate levels of numbering, each onemust be attached to the right position in a hierarchy of lists,in combination with appendItemList(), insertItemList(), andappendListItem().Note: this method can only be used with a new header i.e. it addswhile it creates. To add an already available element usinggetHeading() from the same document or from another document, usethe appendElement() method instead which is inherited fromOODoc::XPath.
appendItem(list [, text => text ,style => style ,[other_options]])
See appendListItem().
appendItemList([type => list_type, [style => style [, options]]])
Creates a new (empty) list and appends it to the end of thedocument.In OpenOffice.org 1 documents, an unordered list is the default,and if the 'type' option is given with the value 'ordered', then anordered list is created. In Open Documents, the 'type' option isignored because there are generic lists only (a list is ordered or"bulleted" according to a style, and not natively).The 'style' options controls the list's style (as opposed to eachitem's style). If absent, the list takes the default paragraph style(see appendParagraph).Like appendParagraph, this method actually creates a new listelement. To copy an existing list in the same document or inanother, use appendElement or replicateElement instead.
appendListItem(list [, text => text ,style => style ,[other_options]])
Adds a new item to a list (ordered or unordered).The first argument is the existing list element (created usinggetOrderedList or getUnorderedList, for example). Options are thesame as for appendParagraph.If the 'style' option is absent, the element is inserted accordingto the following rule:- if the new item is not the first one of the list, it takes thesame style as the first item;- otherwise, it takes the default paragraph style of the document.The new item is created as a paragraph container by default. A'type' option may be provided in order to require another type.Possible values are 'header', 'paragraph' or the XML name of anyOpenDocument-compliant text container.If the type is provided and set to undef, the new item is createdas an empty element, so it could/should receive a content later.An empty item could be used as the attachment point of anotherlist, in order to create a hierarchy of lists.
appendParagraph(<options>)
Creates a new paragraph and appends it to the document.Options:'text' => <paragraph text>'style' => <paragraph style>An 'attribute' option is also available under the same conditions asfor the appendHeading method (see above).If the 'text' option is empty, calling this method is the equivalentof adding a line feed.If the 'style' option is empty, the style from the 'paragraph_style'property of the OODoc::Text instance is used.By default, the new paragraph takes place at the end of the document.But it's possible to attach it as the last child of an existingtext container (ex: a table cell). To do so, the container must beprovided through an 'attachment' option. For example, to append a newparagraph in a table cell, one can writemy $cell = $doc->getTableCell("Table1", "B12");$doc->appendParagraph(text => "The cell, reloaded",attachment => $cell);Note: this method can only be used with a new paragraph i.e. it addswhile it creates. To add an already existing paragraph usinggetParagraph from the same document or from another document, usethe appendElement, insertElement or replicateElement methods insteadwhich are inherited from OODoc::XPath.Note: The repeated spaces are not properly processed, so any sequenceof spaces (whatever its length) in the 'text' string is replaced by asingle space in the target document. See setText() and extendText().
appendRow(table [, options])
Appends a row to the end of the given table either by reference, bylogical name or by sequential number. By default, the new row issimply an exact copy of the preceding row (in terms of content andpresentation). You can pass an options hash which will give certainattributes to the created row, under the same conditions as for theappendElement method of OODoc::XPath. The returned value is thecreated row element.Example:open SRC, '<', 'data.txt';my $table = $doc->getTable("Table1");my ($h, $l) = $doc->getTableSize($table);for (my $i = 0 ; my $record = <SRC> ; $i++){last unless $record;chomp $record;my @data = split ';', $record;my $row = $i < $h ?$doc->getRow($table, $i) :$doc->appendRow($table);for (my $j = 0 ; $j < $l ; $j++){$doc->cellValue($row, $j, $data[$j]);}}The above program reads a CSV format data file sequentially (onerecord per line, comma-separated fields). Each record is split andput into a row in table Table1. On reading each new record, thereference for the following row is loaded by getRow, until the totalnumber of rows is reached (total obtained previously usinggetTableSize). If the table is already full, it is lengthened by arow using appendRow. The internal loop loads the read data into therow's cells (pre-existing or newly created). See the sections ongetTable, getRow, getTableSize and cellValue for a betterunderstanding of this example.However, if good performance is what you are after, massiverepetition of this method is not recommended (e.g. for lengthening atable dynamically, row by row, whilst loading external data intoit). Rather than running dozens or hundreds of successiveappendRows, it would be better for the application to read the totalnumber of records to be loaded (using, for example, select count iffrom a relational database or otherwise preloading the data into anordinary Perl table) and create a table of appropriate size inadvance using insertTable() or appendTable().
appendSection(name [, options])
Creates a new section with the given name, and appends it by defaultto the end of the document body. If the "attachment" option isprovided, with an existing element as its value, the new section isappended in the context of this element. For example, if the valueof "attachment" is an existing section, the new section is appendedas the last sub-section of the existing one.A section may be used either to hold a local content or to inserta subdocument which can be reached through an external link.In order to insert a subdocument link instead of an ordinary section,the application must provide a "link" option whose value is either alocal file path or an URL.Example:$doc->appendSection("Article",link => "http://mycompany.com/doc/article.odt");Other possible options:'style' allows the application to explicitly select a stylefor the new section'protected' write-protects the section when the document isedited; "true" or "false", default "false"'key' in combination with "protected" => "true", write-protects the section by password (the value of"key" is not the real password, but an encryptedpassword, so the end-user will never remove theprotection by simply typing the key as it iswritten in the program); see lockSection(),unlockSection() and sectionProtectionKey()
appendTable(name, rows, columns [, options])
Creates a new table with the given name, number of rows and numberof columns, and appends it by default to the end of the documentbody. The name must be unique within the document (the call isrejected if the name already exists). Returns the created tableelement if successful.Beware: Creating simple tables from scratch is very easy; however,for a realistic application, it's strongly recommended to replicateXML table templates previously created with an ODF-compatible editingsoftware. A reasonably sophisticated table implies dozens of styledefinitions and would require a lot of perl code and a deep knowledgeof the ODF specification, while it could be created in a few minutesthrough a WYSIWYG tool.'rows' and/or 'columns', if omitted, are replaced by the 'max_rows'and 'max_cols' properties of the document (see the properties below).By default, the table is set to fit the entire width between theleft and right margins with equal sized columns, cells of typestring and without borders or background colour.Possible options:'table-style' => table style'cell-type' => default cell type'cell-style' => default cell style'text-style' => default cell text styleThe first option is the name of a table style which definescertain global properties for the table (width, background colour,etc.). See the OpenOffice::OODoc::Styles manual for information aboutstyles.The second option is the cells' default data type. The main typesavailable are string, float, currency, date, percentage. Caution: tobe properly treated as having a numeric format in OOo/ODF, acell needs more than to be just marked 'numeric'. If the cell reallyneeds to be treated properly as a number, you must also give it acell style which itself refers to a number style. The cell-styleparameter can do this. However, even though the OODoc::Styles moduleis there to otherwise help you create and add styles from a program,this type of exercise can become very labour-intensive. We thereforerecommend using basic tables created in advance from documenttemplates or style libraries created from an office application,rather than creating complex number tables from code.The text-style option selects the paragraph style applicable to thetext displayed in each cell.Once the table is created, you can obviously modify each cell's typeand style individually.Example:my $table = $doc->appendTable("Rate", 22, 5,'table-style' => 'Table1','text-style' => 'Text body');
appendTableRow(table)
See appendRow.
autoSheetNormalizationOff()
Deactivates the automatic sheet normalization.See autoSheetNormalizationOn().
autoSheetNormalizationOn('full')
autoSheetNormalizationOn(height, width)
Activates the automatic normalization of any used table.This method instructs the API to automatically normalize anythingtable or sheet as soon as it's reached through getTable() or anothertable-related access method. The automatic normalization is notactivated by default. It can be deactivated at any time usingautoSheetNormalizationOff().See normalizeSheet() for details about the arguments and theeffects.
bibliographyEntryContent(id [, key1 => value1, key2 => value2, ...])
Gets, and optionally sets, the properties of a given (existing)bibliographic entry. The optionally updated properties are providesas a hash. The returned description is a hash.The first argument can be either the logical identifier of the entry(as it appears for the end-user) or a previously found bibliographyentry element (see getBibliographyElements()).Example:my %desc = $doc->bibliographyEntryContent("GEN99",author => 'Genicorp',pages => 62);This sequence updates the "Author" and "Pages" values of the "GEN99"entry, then returns all the content of the entry in %desc.Caution: Several bibliography entries can have the same identifier.This method processes one element at a time. In the example above,only the first occurrence of the "GEN99" entries is updated. So, ifthe user needs to ensure that all the entries with the same identifierhave the same content, the appropriate code should be something like:my @entries = $doc->getBibliographyElements("^GEN99$");foreach my $entry (@entries){$doc->bibliographyEntryContent($entry,author => 'Genicorp',pages => 62)}Caution: This method allows the user to create any new property andto put any value in any property, without control. For informationabout the legal and/or recommended properties, see the OpenDocumentspecification and the OpenOffice.org bibliographic project(http://bibliographic.openoffice.org).
bookmarkElement(element, name [, offset])
See setBookmark().
cellCurrency(table, row, column [, currency])
cellCurrency(cell [, currency])
Get/set the currency unit of a cell.If a currency is provided, the cell value type is automaticallyswitched to 'currency'.
cellFormula(table, row, column [, formula])
cellFormula(cell [, formula])
Accessor which returns the formula (or function) contained in thegiven table cell. Returns undef if no formula is found in the cell.The cell address is the same as for getCellValue().If a formula is given as the last argument, it is put into the cell,overwriting any existing formula. No check of the syntax is carriedout on the inserted formula. It is up to the application to insert aformula which conforms to OOo/ODF syntax. Example:$doc->cellFormula(1,3,2, "sum <C2:C5>");Note 1: inserting or replacing a formula does not directly modifythe value or text of the cell. Proper interpretation of a formuladoes not happen until the fields are updated when the document isreloaded into the office software.Note 2: syntax and functionality of cell formulae differ greatlybetween office applications.
cellSpan(table, row, column [, hspan [, vspan]])
cellSpan(cell [, hspan [, vspan]])
In a spreadsheet document, get/set the span of a table cell,knowing that this span can be one or more columns. The cell addressingis the same as with getTableCell().Example:$doc->cellSpan($table, "B4", 3);creates a 3-cell span from B4 in a spreadsheet.With only one span argument, this method works for horizontal, left toright expansion. With an additional argument, the expansion is bi-directional, covering one or more rows below the given cell. Thehorizontal span should be set to 1 in order to get a vertical spanonly.The text of the covered cells (if any) is concatenated to the originalcontent of the expanded cell (as in OOo Writer or Calc).The user should make sure that the cell expansion will not invade thespan of another, previously expanded cell. Assuming A is a the targetof cellSpan(), B is an existing expanded cell, and C is a covered cellin the span of B, the following rules apply:If B is to be covered by the span of A, the span of B is automaticallyreset to 1, so C becomes visible, then B is covered by A. But if C isin the target range of cellSpan() while B is not, the method producesan inconsistency in the table (this inconsistency doesn't preventOpenOffice.org and KSpread from loading the file but the span of A isjust ignored).In list context, the method returns the horizontal span, then thevertical span. In scalar context, it returns the horizontal span only.Caution: when related to table cells, "span" has not the samemeaning as when related to flat text (see getSpan() and setTextSpan()).
cellStyle(table, row, column [, stylename])
cellStyle(cell [, stylename])
Get or set the style of a table cell.
cellValue(table, row, column [, value [, text]])
cellValue(cell [, value [, text]])
Without the "value" argument: see getCellValue().With "value" (and, optionally, "text"): see updateCell().
cellValueType(table, row, column [, type])
cellValueType(cell [, type])
Get/set the data type of a table cell.Possible value types are 'string', 'float', 'percentage', 'currency','date', 'time', 'boolean'.Note: If an application must convert a 'string' cell to a numericone and fill it with a numeric value, cellValueType() must be called*before* cellValue(). Ex:my $cell = $doc->getTableCell('Sheet1', 4, 8);$doc->cellValueType($cell, 'float');$doc->cellValue($cell, 12.34);
checkIndexMark(name, type [, context])
Checks the existence and validity of an index mark (see setIndexMark()for details about range index marks). The mandatory argument are theindex entry identifier and the index entry type (namely 'toc' or'alphabetical index'. A context element may provided in order torestrict the search context.This method may return 1, 0 or undef.'1' means that the index mark is present and consistent;'0' means that the index mark is present in the context but not valid;undef means that the index mark doesn't exist in the context.If the result is 0, the are 2 possible reasons: the start point or theend point of the index mark has been found, but not both, or both havebeen found but there relative positions are wrong (the end is locatedbefore the start). Whatever the explanation, this result means that somecleaning should be done (see deleteIndexMark()).
checkRangeBookmark(name [, context])
Checks the existence and validity of a range bookmark (see setBookmark()for details about range bookmarks). The mandatory argument is thebookmark name. A context element may provided in order to restrict thesearch context.This method may return 1, 0 or undef.'1' means that the range bookmark is present and in the right order;'0' means that the bookmark is present in the context but not valid;undef means that the bookmark doesn't exist in the context.If the result is 0, the are 2 possible reasons: the start point or theend point of the range has been found, but not both, or both have beenfound but there relative positions are wrong (the end is located beforethe start). Whatever the explanation, this result means that somecleaning should be done (see deleteBookmark()).
columnStyle(column_element [, style])
columnStyle(table, column [, style])
Returns the style name of the given column or replaces it with a newone. A column can be indicated either directly by reference or bythe pair [table, column number]. The table itself can be indicatedeither by a table element, its number or its logical name. If the'style' argument is given, it replaces the old column style.Giving a column a style is actually the only way to control thewidth of a column in a table.Example:$doc->columnStyle('Table1', 2, 'NewStyle');Caution: columns are numbered beginning at 0.
copyRowToHeader(table, rownum)
copyRowToHeader(row)
This method appends a copy of a given table row to the header of thetable. It may be called repeatedly, allowing multi-row headercreation.A table header is a row, or a sequence of rows, that is displayed atthe top of a table and repeated at the top of every page if the tableis spanned across more than one page.The given row remains in place unchanged; it's used as a template forthe new header row.
createParagraph([text [, style]])
Creates a free paragraph for later use. Unlike appendParagraph() orinsertParagraph(), this method doesn't attach the new paragraph tothe document.Without arguments, the paragraph is created empty. The first argument,if any, provides the text content of the paragraph. The second one,if any, is regarded as the style name; the default style is"Standard".
createTextBox(options)
Creates a new text box. Can apply to any document class, but mostlyused in presentations or drawings (where text boxes are required tohost text content).Text boxes are implemented through frame element, so you should seecreateFrame() in the OpenOffice::OODoc::XPath manual chapter in orderto understand the meaning of every option.The following options are allowed (and generally required in orderto make a text box really visible and properly rendered):page: the page where the box must be attached; in presentations ordrawings, this option should be set with the page name;name: the (unique) name of the text box;size: the size of the box;position: the page-relative position;style: the graphic style of the box; like an image box, a text boxoften requires a style to be properly displayed;content: the content to be displayed in the box; if this option isset to a literal, the given content is inserted as a paragraph inthe box; if the given value is the reference of an element, thiselement is attached as is in the box (so it's possible to insertany complex object, such as a table, an item list, etc).The method returns the reference of the new text box element.The example below creates an graphic style ("TB"), then a text box("The Box") which uses the new style. See O::O::Styles for commentsabout createStyle(). The text box is attached in a presentation pageidentified by its name ("AnyPageName"). The size (width then height)and position (x, y) options are provided in centimeters (other unitsare allowed), each one in a single string.$doc->createStyle("TB",family => "graphic",parent => "objectwithshadow",properties =>{'style:vertical-pos' => 'from-top','style:horizontal-pos' => 'from-left','style:vertical-rel' => 'page','style:horizontal-rel' => 'page'});$doc->createTextBox(page => "AnyPageName",name => "The Box",size => '12cm, 4cm',position => '8cm, 14cm',style => 'TB',content => "The text in the box");In this example, the content option is set to a flat text, soit will be inserted as a standard paragraph. If we want to inserta paragraph with a non-default style, this option must be set tothe reference of an existing paragraph (which may have been createdusing createParagraph() or copied from another place).
defaultOutputTerminator([chars])
Get or set the default terminator character for text export.Example:$doc->defaultOutputTerminator("\n");After this instruction, a line-break will be appended at the end ofevery paragraph or header exported by getText(), selectTextContent()or other text extracting methods.To reverse this behaviour, the user can call this method with anempty string.Without argument, returns the currently selected terminator, if any.
deleteBookmark(name [, context])
Deletes the bookmark owning the given name (if defined).A context optional argument is provided; if so, the bookmark is deletedonly if it's located in the given context.If several bookmarks wrongly own the same name, they are removed.The method returns the number of physical deleted elements, i.e. 1 fora regular position bookmark, 2 for a range bookmark, 0 for nothing. Anyother return value means that deleteBookmark() has cleaned up a strangesituation (ex: more than one bookmark for a single name, a positionbookmark with one start and many ends, and so on).Warning: if the context argument is set (or if the default currentcontext is not the whole document), and if the bookmark to be deletedis not entirely included in the context, the result may be a partiallydeleted bookmark (wrong).See also deleteBookmarks().
deleteBookmarks([context])
Delete all the bookmarks in the current context (by default the wholedocument) or in a given optional context, and returns the number ofphysical deleted elements (that may be greater than the number ofdeleted bookmarks, knowing that a bookmark may be stored a one or twoXML elements).Warning: some inconsistencies may result if the context is not the wholedocument, knowing that a range bookmark could run across the border ofthe restricted context.See also deleteBookmark().
deleteColumn(table, col_num)
deleteColumn(col_elt)
Deletes a given column in a given table.Caution: Before using this method, the application should ensure thatthe whole area from the beginning of the table to the last cell of thecolumn to be deleted is "normalized". See normalizeSheet() for detailsabout table normalization.
deleteHeading()
See removeHeading().
deleteRow(table, row_num)
deleteRow(row_elt)
Deletes a given row in a table.
deleteIndexMark(id [, type [, context]])
Deletes the index mark owning the given identifier (if defined).The first argument (mandatory) is the index mark identifier. The secondargument is the index type ('alphabetical index' or 'toc', the first oneis the default).A context optional argument is provided; if so, the index entry isdeleted only if it's located in the given context.If several index marks wrongly own the same identifier, they areremoved.The method returns the number of physical deleted elements, that shouldbe 0 (if the index mark did not exist) or 2 (the start and the endpoints). Any other return value means that deleteIndexMark() has cleanedup a strange situation (less or more than two range delimiters).See also deleteIndexMarks().
deleteIndexMarks([type [, context])
Without argument, deletes all the TOC marks and alphabetical index marksin the document (or the default context).The first argument, if set, non-blank and non-empty, restricts thedeletion to one type of index marks; it should be either 'toc' or'alphabetical index' (unless the user need to remove non standard indexmarks).A particular context may set through the third argument in order torestrict the index mark removal to the content of a particular element.See also deleteIndexMark().
drawPageId(page [, new_id])
Returns the internal identifier of a presentation page, and changesit if a second argument is provided. The page id is a positiveinteger.The first argument must comply to the same rules as with getDrawPage.
drawPageName(page [, newname])
Returns the visible name of a presentation or drawing page.The first argument can be a page order number, a page element or thepresent page name (see getDrawPage). The page is renamed if asecond argument is provided. Example:$doc->drawPageName("oldname", "newname");
deleteTableColumn(table, col_num)
See deleteColumn().
deleteTableRow(table, row_num)
See deleteRow().
expandSheet()
Synonym of expandTable().
expandTable(table, height, width)
Increases the size of the given table or spreadsheet.This method silently executes a full normalization of the table beforeresizing it. See normalizeSheet() for details about this operation.This method is specially useful in order to ensure the availability ofan appropriate workspace in a spreadsheet whose apparent size isalmost unlimited through the GUI of a typical desktop software butbut whose real size is unknown and/or doesn't include all the targetarea of the application.The vertical expansion is implemented by repetitive replication of thelast row, while the horizontal expansion is implemented by repetitivereplication of the last cell of the last row. So the new cells in theright side are copies of the old bottom-right cell, while the new rowsare copies of the old last row.Any size argument which is not larger than the previous height or widthis silently ignored, so method produces the same effect asnormalizeSheet() with the "full" parameter.The return value is the table element itself in scalar context, orthe table size in array context.Note that there is no direct method to shrink a table. However, it'spossible to do the job by deleting selected rows and or columnsthrough deleteTableColumn() and/or deleteTableRow().
extendText(element, text [, style [, offset]])
Inserts the text provided as the second argument into the elementspecified by the first argument. The second argument may be either aflat string or another existing text element.If the 'text' argument is a paragraph or heading element, the textcontent (and not the element itself) is inserted. But if 'text' isany other element (for example: a variable text field or a sequenceof spaces), its inserted as is.This method is an improvement of the general extendText() methodwhich is documented in the OpenOffice::OODoc::XPath manual page.If a third argument is provided and is neither 0 nor an empty string,it's regarded as the desired style of the new text, which is insertedas a "styled span" (see setTextSpan() for details about text "spans").By default, the text is inserted without any special style (i.e. withthe same style as the containing element).The new text is, by default, appended to the existing content of theelement. However, if a valid numeric value is provided as the fourthargument, the new text is inserted within the existing content, at thegiven offset. If the offset is negative, it's counted backwards fromthe end of the string. If it's set to 0, the insertion takes place atthe beginning.$doc->createStyle("BlueYellow",family => "text",properties =>{"fo:color" => odfColor("blue"),"fo:background-color" => odfColor("yellow")});my $p = $doc->getParagraph(4);$doc->extendText($p, "New text", "BlueYellow", 5);In the example above, "New text" is inserted at the offset 5 withinthe 5th paragraph, in blue letters on a yellow background.Of course, the offset argument can't be passed unless the style one ispresent. However, in order to pass an offset without setting a style,the application has just to provide a 0 or an empty string as thethird argument. Example:$doc->extendText($p, "New text", "", 5);Caution: the use of extendText() with the style and offset optionalarguments is allowed for some simple situations; however, there aremore powerful methods to insert additional text, with or without aparticular style, within en existing element. See updatetext() andsetTextSpan().
getBibliographyElements([id])
Returns the list of the bibliographic entry elements contained in thedocument.If an argument is provided, the returned list is restricted to thebibliographic entries matching it (this argument can be a regexp).Example:my @biblio = $doc->getBibliographyElements("^W3C");returns the bibliographic entries where the identifier begins with"W3C".
getBookmark(name)
Returns the bookmark element (if defined) corresponding to the givenbookmark name.If the bookmark covers a range of text (i.e. if it's not a position),the returned element is the "bookmark start" one.
getCell()
Synonym of getTableCell().
getCellParagraph(table, row, column)
getCellParagraph(cell)
Returns the paragraph element contained in a given table cell, ifthe cell contains a paragraph. If the cell contains more than oneparagraph, returns the first one.
getCellParagraphs(table, row, column)
getCellParagraphs(cell)
Returns the list of the paragraph elements contained in a giventable cell (knowing that a single cell can contain one or moreparagraphs).
getCellPosition(cell)
Returns an array corresponding to the zero-based, numeric coordinatesof a table cell in a document, which can be used later to retrievea cell at the same location through getCell(). The return valuesrepresent, in this order, the table, the row and the column. The headerrows of the table, if any, are not counted.Example:my @coord = $doc->getCellPosition($cell);A triplet such as (2, 4, 9) tells that the cell is located at the10th position in the 5th row of the 3rd table of the document.In scalar context, this method returns nothing more than the firstelement of the triplet, i.e. the zero-based position of the tablein the order of the document. However, if the real need is to retrievethe table element itself, $cell->parent->parent is more efficient.This method produces a warning and returns undef if the argument isnot a table cell.Caution: getCellPostion(), like any other accessor using objectcoordinates related, works only with normalized tables.
getCellValue(table, row, column)
getCellValue(cell)
Returns the value of a table cell, if the cell is defined anduncovered. Caution, in order to get the cell element itself forfurther processing, use getCell() instead.The first form indicates a cell by its 3D coordinates, as withgetCell().The second form (quicker) takes a cell element as its only argument(e.g. as returned by a previous getCell call).This method behaves in two different ways depending on the celltype. The displayable text of the cell is regarded as the cell valueif the cell type is 'string'. If the cell type is one of the possiblenumeric types ('float', 'currency', 'date'), the returned value is theinternal, numeric value.This difference in handling is designed to allow programs to usereturned numeric values directly in calculations.See also cellValueType().Note: To get information about a cell other than its value or valuetype (numeric, etc.), the best way is first to get its elementreference with getCell() and then use it with getAttribute.
getChapterContent(heading [, options])
This method returns the list of the elements depending (from theend-user's point of view) on a given heading element, not includingthe heading element itself. The argument and the options are thesame as with getHeading().Examples:my @list = $doc->getChapterContent(2, level => 3);foreach my $element (@list){my $text = $doc->getText($element);print "$text\n";}The code above selects and prints all the text elements below thethird level 3 heading of the document (not including the content ofthe header itself. The following example creates a new section whosecontent is made of a heading and the content of the depending chapter(the heading text is used as the section name):my $heading = $doc->getHeading(2, level => 3);my $heading_text = $doc->getFlatText($heading);my $section = $doc->appendSection($heading_text);my @content = $doc->getChapterBodyElements($heading);$doc->moveElementsToSection($section, $heading, @content);(See appendSection(), getHeading(), moveElementsToSection() in thepresent manual chapter, and getFlatText() in OpenOffice::OODoc::XPath)Caution, this method returns a list of elements and not an element.Chapters, unlike sections, are not defined in OpenDocument. So,getChapterContent() should be used as a possible workaround in orderto isolate a logical set of content elements which is not packaged ina section.
getColumn(table, column)
Returns the element reference of the given column in the giventable. The first argument is either the table's sequential number inthe document, logical name or element reference. The second argumentis the column's number in the table. Synonym: getTableColumn.Caution: The application should ensure that the area including theneeded column is "normalized". See normalizeSheet() for details abouttable normalization.
getDrawPage(pos/name)
For presentation and drawing documents.Returns the element reference of the given page name or position.If the argument contains an integer, the page is selected according toits zero-based position. If the value is negative, the position iscounted backwards from the end.If the argument is alphanumeric, it's regarded as a page name, and thepage is selected accordingly.Caution: This method can't retrieve a page by name if the namecontains numeric characters only; selectDrawPageByName() should bepreferred to do so.
getEndnoteCitationList()
Returns the list of all the endnote citations (i.e. references tofootnotes included in the text) contained in the document.
getEndnoteList()
Returns the list of all the endnote body elements contained in thedocument. Should be replaced by getNoteList() with the "class" optionset to "endnote".
getFootnoteCitationList()
Returns the list of all the footnote citations (i.e. references tofootnotes included in the text) contained in the document.
getFootnoteList()
Returns the list of all the footnote body elements contained in thedocument. Should be replaced by getNoteList() with the "class" optionset to "footnote".
getHeading(n [, options])
Returns the nth+1 heading element.If n is negative, headings are counted backwards from the last.getHeader(-1) returns the last heading element of the document.The only one possible option is "level". It allows the applicationto select the nth+1 heading element for a given level.Example:my $heading = $doc->getHeading(2, level => 3);selects the third level 3 heading in the whole document.See also getChapterContent().Caution: without the "level" option, this method counts sequentiallythrough all headings along a single plane, irrespective of theirlevel. E.g. if you have a level 1 heading then two level 2 headingsthen a level 1 heading, the call getHeading(3) returns the lastlevel 1 heading.
getHeadingList([level => value])
Returns a list of heading elements (i.e. elements called 'text:h' inthe document body).If the "level" option is provided, the list is restricted to theheadings having the given level.
getHeaderRow(table [, row_number])
See getTableHeaderRow().
getHeadingText(n)
Returns the text of the nth+1 heading element. Elements are countedin the same way as for getHeading().
getHeadingTextList()
Returns a list of document heading texts.In a list context, the result is returned in the form of a list ofcharacter strings. In a scalar context, the result is a singlestring in which the headings are separated by a line-break character("\n").Note: This list is "flat". It contains no information about theheadings' hierarchy. To get a hierarchical contents list, you muststart with the list of headings obtained using getHeadingList andcheck each element's level attribute ('text:level').
getItemElementList(list)
Returns a list of elements which represent items of an ordered orunordered list. The argument is a "list" element (obtainedpreviously e.g. using getItemList, getOrderedList orgetUnorderedList). Each element in this list can be used with itemhandling methods.
getItemList(n)
Returns the element which represents the nth+1 list in a documentif found.WARNING: In the OpenOffice.org 1 documents, only "ordered lists" and"unordered lists" can be present. In the Open Document format, thereare generic list objects only, and each one is made "ordered" or"unordered" by its style. So, this method will never return anythingfrom an OOo 1 document.
getLevel(element)
See getOutlineLevel().
getList(n)
See getItemList().
getListItem(list, n)
Returns the nth+1 item in a given list if found.The list (1st argument) may be given either by its order number inthe document, or directly as an element reference.
getNoteCitationList()
For OpenDocument only (doesn't work on old OpenOffice.org documents).Returns the list of all the note citation elements (whatever theirnote class, i.e. "endnote" or "footnote").
getNoteClass(note_element)
Returns the class of the given note element. Possible values arepresently "endnote" and "footnote". Returns undef unless the givenelement is a note.
getNoteElement(class => $note_class, citation => $note_citation)
Returns the first note element matching the given class and citation,if any. Returns undef if the target note element doesn't exist.The "class" parameter is either "endnote" or "footnote".The "citation" parameter is the numeric or literal which refers tothe note, as it's visible for the end user.Caution: The uniqueness of a note citation in a given note class isnot a general rule. The citation is an identifier when it belongs toan ordered sequence (such as 1, 2, 3... or "i", "ii", "iii"...). Butthe author is allowed to use the same citation (ex: an asterisk) formore than one footnote or endnote. In such a situation, the methodreturns the first note matching the given citation and the givenclass. As a consequence, the note identifier, if known, is a betteroption (see the second form of getNoteElement()).
getNoteElement(id => $note_identifier)
Returns the note element matching the given internal note identifier(which is a "text:id" attribute according to the ODF specification).This internal identifier is unique, whatever the note class, so the"class" parameter is not needed. However, "class" may be provided asan additional filter; if so, the method will return undef if theelement matching the identifier doesn't match the class.
getNoteElementList()
Returns the list of the endnote and footnote main elements.
getNoteList()
Returns the list of the endnote and footnote body elements.
getOrderedList(n)
Returns the element which represents the nth+1 ordered list in adocument if found.WARNING: Ordered lists are possible in the OpenOffice.org 1 formatonly. Don't use it against OpenDocument.
getOutlineLevel(element)
Returns the level number of a text element, or undef if the givenelement don't have a level number. Every heading element should havea level, while ordinary text body elements should not. Example:my $level = $doc->getOutlineLevel($element);if ($level){print "There is a level $level heading\n";}else{print "Non-heading element\n";}
getParagraph(n)
Returns the nth+1 paragraph in the document body, or undef if thegiven number is greater than or equal to the total number ofparagraphs in the document.You can also pass a negative argument, in which case paragraphs arecounted backwards from the end (-1 being the last paragraph).By paragraphs we mean 'text:p' elements, which excludes headers butincludes non-empty table cells, contents of list items andfootnotes.Returned value is an element and not the text of the paragraph. Allread/write operations involving attributes and content can use thiselement.
getParagraphList()
Returns a list of paragraph elements (i.e. 'text:p' elements in thedocument body).
getParagraphText(n)
Returns the text of the nth+1 paragraph, counted using the samerules as for getParagraph.
getParagraphTextList([filter])
Returns a list of texts contained in the paragraphs of a document('text:p' elements).A filter can be passed as an optional argument (literal or regularexpression). In this case, only paragraph texts whose content matchthe filter are returned.In a list context, the result is returned in the form of a list ofcharacter strings. In a scalar context, the result is a singlestring in which the paragraphs are separated by a line-feedcharacter ("\n").
getRow(table, row_num)
Returns the element reference which corresponds to a row in a table.The first argument is either the table's sequential number in thedocument, logical name or element reference. The second argument isthe row number in the table. Synonym: getTableRow.This methods ignores the table header (if any). It can retrieve arow in the table body only. See getTableHeaderRow().
getRowCells(table, row)
getRowCells(row)
Returns the list of the uncovered cell elements corresponding to agiven table row. The row can be provided either by table ID and rownumber or by direct row object.
getSection(name/number)
If the first argument is a number, returns the nth+1 section in adocument (section numbers are zero-based; if the argument is negative,the sections are counted from the end).The second form allows you to select a section by its logical name (asit would appear to the end user when editing the section'sproperties). This name is obviously easier to use than a number.Moreover, this type of selection means the application will stillwork even if a section changes position within a document.The returned object is a "handle" that can be used for subsequentelement creations or retrievals in the selected section.
getSpanList([context])
Returns a list of elements, in the given context, which correspondto texts which "stand out" from the regular flat text, i.e. which havebeen given a style which makes them stand out from the rest of theparagraph containing them. The context may be a paragraph, a section,or any other text container. The context argument is optional; thedefault context is the whole document.For example, a word in italics or in font size 12 in a paragraph ofmostly standard characters in font size 10 is a 'span' element andwould therefore appear in a list returned by getSpanList().
getSpanTextList([filter])
Gets a list of texts which "stand out" in the same way asgetSpanList() and returns it under the same conditions asgetParagraphTextList() or getHeadingTextList(), with optional filter.
getStyle(path, position)
getStyle(element)
Obsolete. See textStyle().
getTable(number_or_name [, 'normalize'])
getTable(number_or_name [, length, width])
Returns the reference of a table, selected by name or number, in ascalar context. In an array context, returns the table size, likegetTableSize().This method works with spreadsheets as well as with tables includedin other documents.If the first argument is a number, returns the nth+1 table in adocument (table numbers are zero-based; if the argument is negative,the tables are counted from the end). If it's a string, the table isselected by its its logical name (as it would appear to the end userwhen editing the table's properties). This name is obviously easierto use than a number. Moreover, this type of selection means theapplication will still work even if a table changes position withina document. But the retrieval by name works with two restrictions:- if a table name is made of digits only, or if if represents anumeric expression, it's automatically regarded as a table number andthe table is selected according to its sequential (zero-based)position in the document; if (and only if) the given number is greaterthan the position of the last table, the given argument is regarded asa name (for example, if the document contains 3 tables, getTable(365)will attempt to retrieve a table whose name is "365"); in order toavoid any retrieval by number, use getTableByName();- getTable() can't retrieve a table by name if the name containsone or more "$", "{" or "}" characters; these characters are allowedin the table names in text documents (ODT), but not allowedin spreadsheets (ODS).The returned object is a "handle" that can be used for subsequentaccesses to its components (rows, cells).The additional arguments, if any, instruct OODoc to normalize theytarget table in order to allow subsequent addressing of its content.If the "normalize" keyword is provided, the table will be fullynormalized. If length and width arguments are provided instead,only an accordingly limited area, beginning at the "A1" position.Practically, getTable() uses normalizeSheet() in order to performthis job, so you should have a look at the normalizeSheet()documentation (in the same chapter) for explanations.Examples:my $sheet = $doc->getTable('Checklist');returns the reference of the sheet (or table) corresponding to thegiven name, without processingmy $first_sheet = $doc->getTable(0);my $last_sheet = $doc->getTable(-1);returns the references of the first and the last tables according tothe physical order of the document($lines, $columns) = $doc->getTable('Friends', 'normalize');fully normalizes the table whose title is "Friends" and returns itselfsize.
getTableByName(name [, 'normalize'])
getTableByName(name [, length, width])
Retrieves a table according to its name (if it exists). This methodsallows the retrieval of a table whose name is made of digits withoutpossible confusion between names and numeric positions.The optional arguments and the limits are the same as for getTable().
getTableCell(table, row, column)
getTableCell(table, coord)
getTableCell(row, column)
Returns the element which represents the given cell. Possiblearguments are respectively: the table number or its reference in thedocument, row number and column number. Each table cell contained inthe body of an OOo/ODF document can be referenced in thismanner, as if it belonged to a single 3D table irrespective of therest of the document.If the cell is defined in the spreadsheet but covered (because of acell merge), the return value is undef. In other words, this methoddoesn't provide access to a covered cell.The first argument can be either the sequential number of the table(starting at 0), the logical name of the table, or a 'table' object(which can be retrieved in advance using getTable). If it's a numberor a name, getTable() is automatically called by getTableCell() inorder to convert it in a 'table' object. However, if the firstargument is a row object (previously obtained via getRow() orgetHeaderRow()), the second one is processed as the column number.Before using several cells in the same row, it's a good idea to getthe row object and then to use it in every cell selection, in orderto minimize the coordinates calculation.In tables including one or more header rows, the best way to get aheader cell is to use a header row (previously obtained usinggetHeaderRow()) as the first argument. If the first argument is atable, getCell() looks in the table body only.Alternatively, the user can provide the cell coordinates in a singlealphanumeric argument, beginning with one or two letters and endingwith one or more decimal digits, according to the same logic as in aspreadsheet. So, for example$doc->getTableCell($table, 'B12');is equivalent to$doc->getTableCell($table, 11, 1);(Remember that, with the numeric coordinates, the row number is thefirst argument, while with the alphanumeric, spreadsheet-like ones,the column letter(s) come first.)Numbers can also be negative, where position -1 is the last. Forexample:$cell = $doc->getCell(-1, -1, -1);returns the very bottom right cell of the very last table in thedocument $doc.Returns a null value if the given cell does not exist or if it'scovered by the span of another cell.Any cellXXX() method in this module uses the same cell addressinglogic as getTableCell().CAUTION: Remember that OODoc works with the XML representation ofthe tables, and not with the tables themselves. The [x,y] directaddressing feature works as long as there is a continuous, one-to-onemapping between the logical view and the physical XML storage of thetable. But, according to the OpenDocument specification, severalcontiguous objects (cells or rows) are allowed to be mapped to asingle XML object when they have the same content and the samestyle, in order to save some storage space. This optimization issystematically used, for example, by OpenOffice.org Calc. In addition,OODoc can't address a cell that could be displayed through the GUIof a typical interactive spreadsheet software but that isn't storedbecause it's not initialized yet. As a consequence, the directaddressing logic of getTableCell() may require some preprocessing.See normalizeSheet() and/or expandTable() about such preprocessing.Remember that the table addressing is zero-based andthe row comes before the column in OpenOffice::OODoc, so, forexample:$cell1 = $doc->getTableCell($table, 0, 0);$cell2 = $doc->getTableCell($table, 31, 25);returns respectively the A1 and Z32 cells.Note: in a spreadsheet, (0,0) are the coordinates of the "A1" cell,and, for example, (16, 25) are the coordinates of the "Z17" cell.
getTableColumn(table, column)
See getColumn.
getTableHeaderRow(table [, row_num])
Returns the element reference which corresponds to a row in a tableheader, or undef if the given table has no header row.The arguments are processes in the same way as with getRow(), butthe second argument is optional; it's required only if the tablehas more than one header row (the 1st header row is returned bydefault).The returned elements can be used with subsequent cell access methodsin order to process header cells (see getTableCell()).
getTableList()
Returns a list of table elements in a document.
getTableRow(table, row)
See getRow.
getTableRows(table)
Returns the list of the rows contained in the given table.When the user needs to process every row in large tables, this methodallows some performance improvements, because it's less costly thana lot of successive getRow() calls.
getTableSize(table)
Returns the size of a table as a pair of values which represent thenumber of rows and columns. The table can be specified either bynumber, logical name or reference.Example:my ($rows, $columns) = $doc->getTableSize("Table1");
getTableText(n)
Returns the content of a table, if found, whose number or referenceis given as an argument. If not found, returns undef.The content of each cell is extracted according to the rules ofgetCellValue.In a list context, the returned value is a 2D table with eachelement containing the corresponding cell in the document.In a scalar context, the content is returned as a single string inCSV format. In this case, the rows are separated by a delimiter setby the instance variable 'line_separator' and the fields by thevariable 'field_separator' in the OODoc::Text object. (Thesedelimiters are by default "\n" and ";" respectively.)
getText(path, position)
getText(element)
Exports the text contained in the given element according to themeans appropriate to that type of element.If the 'use_delimiters' flag is set to 'on' (default), the contentof each element (others than ordinary paragraphs, table cell,headers) is preceded and/or followed by a character string dependingon the type of the element. This also depends on the settings givento the delimiter values 'begin' and 'end' by the 'delimiters' hash.In a default configuration where the application has not providedany specific delimiters, the following delimiters are used:- '<<' before and '>>' after sections of text highlighted withinan element (e.g. words in bold or underlined within a paragraphof 'standard' font characters).footnote citations (in text body) are placed between squarebrackets.'{NOTE:' and '}' for the content of footnotes.(Footnotes are physically inserted into the text at the placewhere they are called, just after the link element indicating thefootnote's number. Its display at the foot of the page or elsewhereis a trick of the graphical interface.)An application can change these delimiters, add more for other typesof elements (e.g. paragraphs, headers, tables cells, etc.), ordeactivate them using outputDelimitersOff. This depends on where thetext is exported to e.g. display in editable "flat" format,conversion to non-OpenDocument XML or a markup language other thanXML, generating code from text, etc..A default export (ex: "\n") terminator can be set for any element thatis not listed in the 'delimiters' hash (see defaultOutputTerminator()above).If the element is an ordered or unordered list, the text produced isa concatenation of all the lines in the list, each separated by aline-break in addition to any delimiters. The default line breakcharacter is "\n", but it can be set to any other string (includingan empty string) through the 'line_separator' property of the documentobject.If the element is a string table cell, getText behaves likegetCellValue. If the cell contains more than one paragraph, the textproduced is a concatenation of all the paragraph contents, eachseparated in the same way as list items.If the element is a table, getText behaves like getTableText.
getTextBoxElement(name/number)
Retrieves a text box element by its unique name or by its ordernumber in the document (or in the current context).
getTextContent()
Returns the text of a document, as "flat" editable text.In a list context, the content is returned as a table with one textelement (header or paragraph) per element.In a scalar context, the content is returned as a single characterstring with each text unit (header or paragraph) separated by aline-feed ("\n").The returned text contains no style or level information, so thereis nothing to distinguish a header from a paragraph.Same as selectTextContent('.*').
getTextElementList([context])
Returns the list of all the text elements, including headers,paragraphs and item lists, that directly belong to an optional givencontext. Without context argument, the default context is the documentbody.
getTopParagraph(n)
Same as getParagraph but only considers top level paragraphs. Thecontents of lists, tables and footnotes are excluded.
getUnorderedList(n)
Returns the element which represents the nth+1 unordered list in adocument, if found.WARNING: Ordered lists are possible in the OpenOffice.org 1 formatonly. Don't use it against OpenDocument.
hyperlinkURL(hyperlink [, url])
Get/set the URL of an hyperlink element. The first argument may bea previously retrieved hyperlink element (see selectHyperlinkElementbelow), or the URL of an existing hyperlink. If a second argument isprovided, it replaces the URL of the hyperlink element.With only one argument, just returns the existing URL of the link,or undef if the first argument doesn't match an existing hyperlinkelement.
inputTextConversion(text)
Returns the UTF8 conversion of the given text, supposed to be inthe local character set of the document (see the 'local_encoding'property).
insertColumn(table, col_num [, options])
Inserts a new column in an existing table at a given position.The second argument must be the number of an existing column.Caution: this argument must be a column number, and not a columnelement.The new column is created as a copy of the column a the givenposition. It's inserted before or after the existing one, accordingto an optional "position" parameter (default 'before').Caution: before using insertColumn() against a spreadsheet, theapplication should ensure that the whole rectangular area from the topleft cell ("A1") to the last used cell of the column at the targetposition is "normalized" (see normalizeSheet() for details about thetable normalization).
insertDrawPage(page/pos [, options])
In a presentation or drawing document, inserts a new page beforeor after an existing page.Possible options are the same as for appendDrawPage(), with anadditional one:position => 'before' or 'after' (default 'before')The new page is inserted before or after the reference page, accordingto the 'position' option.The first argument can be a draw page element reference (recommended)previously returned, for example, by a previous page retrieval orcreation method call. Alternatively, it can be a page position orvisible name, so it's regarded in the same way as in getDrawPage().Returns the new page element, or undef in case of failure.
insertHeading(path, position, options)
insertHeading(element, options)
Same as appendHeading, but inserts the new heading before or afteranother element.Position is that of an existing element which can be another headingor a paragraph. Can be given by [path, position] or by elementreference.Possible options are the same as for appendHeading, with theadditional option 'position' which determines if the heading isinserted before or after the element at the given position. Possiblevalues for this option are 'before' and 'after'. By default, the newelement is inserted before the given element.
insertItemList(path, position [, options])
insertItemList(element [, options])
Same as appendItemList, but a new list is inserted at the givenposition. The point of insertion can be given either by the pair[path, position] or by element reference. Options are the same asfor insertParagraph.
insertParagraph(path, position [, options])
insertParagraph(element [, options])
Same as appendParagraph, but a new paragraph is inserted at thegiven position.Position is that of an existing element which can be anotherparagraph or a header. Can be given by [path, position] or byelement reference.Options are the same as for appendParagraph, with the additionaloption 'position' which determines whether the paragraph is insertedbefore or after the element at the given position. Possible valuesfor this options are 'before' and 'after'. By default, the elementis inserted before the given element.
insertRow(table, row [, options])
insertRow(row_element [, options])
Inserts a new row into a table. In its first form, pass the table(reference, logical name or number) and the position number in thetable. In its second form, pass the element reference of theexisting row which is directly before or after the position whereyou want to make the insertion.By default, the new row is inserted at the position of thereferenced row, which displaces it and the rest of the table down byone row position. However, you can insert it after by using the'position => after' option. By default, the new row is an exact copyof the referenced row, but you can assign particular attributes toit in the same manner as the insertElement method of OODoc::XPath.
insertSection(path, position, name [, options])
insertSection(element, name [, options])
Creates a new section and inserts it immediately before or afteran existing element (paragraph, header, table). The referenced elementcan be indicated as in insertParagraph.There is a "position" option which works in the same way as withinsertParagraph() or insertRow().For other options, see appendSection(). For example, insertSection()may be used in order to insert a subdocument in a master document.
insertString(path, position, text, offset)
insertString(element, text, offset)
Inserts a flat character string in a given element (whatever the typeof element) at the given offset. If the offset is not defined, thetext is appended to the end of the element (however, if the offset isprovided and set to zero, the string is inserted at the beginning).
insertTable(path, position, name, rows, columns [, options])
insertTable(element, name, rows, columns [, options])
Creates a new table and inserts it immediately before or afteranother element (paragraph, header, table). The referenced elementcan be indicated as in insertParagraph. The other arguments andoptions are the same as for appendTable with the additional option'position' as in insertParagraph.
insertTableColumn(table, col_num [, options])
See insertColumn().
insertTableRow(table, row [, options])
insertTableRow(row_element [, options])
See insertRow().
lockSection(section [, key])
Installs a write protection on the given section.If a second argument is provided, it's stored as an encrypted keywhich is associated to the write protection. Caution, it's not thekey as it should be typed by the OOo end-user.Such a write protection works only when the document is edited throughan OpenOffice.org-compatible desktop software. It doesn't prevent theprograms using OpenOffice::OODoc from deleting or updating theprotected sections.
makeHeading([options])
Creates a new heading element, or marks as a heading an existingelement.Options:element => an arbitrary existing elementIf this option is provided, the given element is converted in placeto a heading, whatever its original type and position. No elementis created.Without the 'element' option, a new heading element is created andreturned for later use. This element is free; it's not automaticallyattached somewhere in the document. For direct heading creation andattachment, you should prefer appendHeading() or insertHeading().level => a numeric, positive integer valueSets the hierarchical level of the heading (remember 1 is the topheading level). Caution: no default value.style => the name of a convenient heading styleWhile it's not mandatory, the 'style' option and a properly definedheading style are generally required in order to allow the officesoftware to really process and display the element as a heading withthe right hierarchical level. Of course, any previously existinghierarchical style is reusable here.The main purpose of this method is to allow quick heading hierarchycreation in a "flat" document. For exemple, an application can selecta set of flat paragraphs matching a given condition and convert eachone in place to a heading with a given level.
moveElementsToSection(section, list)
Moves a list of elements from any place to a section.The section may be passed by name or by element reference; it must bean existing one (no new section is created).The list is a set of arbitrary elements (including sections). Each oneis cut from its previous place and appended to the section in theorder of the list, without document consistency check.
normalizeSheet(sheet, rows, columns)
normalizeSheet(sheet, 'full')
This method preprocesses a given sheet so its components (rows,cells) become available for all the table-oriented methods describedin this chapter. In some situations, this method must be used beforeany attempt to address any individual table component (column, row orcell). The return value is the target table object in a scalar contextand the size (height, width) in an array context.This method works with any kind of ODF tables, whatever the containingdocument, and not only with spreadsheets.In the first form, the 2nd and 3rd arguments define the size of arectangular area, beginning at the first cell ([0, 0] or "A1"), tobe processed, in order to save time and CPU resources when theapplication needs to address objects only in the first corner of a hugetable.The second form allows the OODoc to normalize the whole table,whatever the size. It's certainly the preferred form, as long asthe target sheets are reasonably sized or the hardware is powerfulenough.The processed area becomes a workspace which is safelyaddressable by any cell/row/column processing method. Thispreprocessing is sometimes required, sometimes not. For example,it's required on present OpenOffice.org Calc spreadsheets, anduseless on present OpenOffice.org Text tables.It's automatically executed when getTable() is called with sizearguments (or with the "normalize" option); therefore it's not alwaysexplicitly invoked by the applications. However, it's useful to knowits purpose.The object addressing logic (which, for example, allows a program todirectly reach a cell using its coordinates) relies on a continuous,regular mapping between the user's view and the physical XML storageof the tables. However, the OpenDocument specification allows anyconforming application to map more than one table element to asingle XML element. When two or more contiguous objects containthe same value and have the same style and the same data type, they*may* be mapped to a single XML element with a repetition attribute.As a consequence, the position of the appropriate XML element can't bedirectly calculated from the logical coordinates of the object, andOODoc needs to scan the table in order to get all the repetitionattributes and calculate the real mapping. In addition, updating anobject whose the XML corresponding element has a repetition attributewould automatically update all the objects mapped to the same element,producing unpredictable and generally wrong results.OpenOffice.org Calc systematically uses this storage optimization inspreadsheets, while OpenOffice.org Writer doesn't use it for tables intext documents. In Calc (sxc/ods) documents, the XML mapping of thewhole content is "denormalized" in order to save memory: several tablecomponents can be mapped to a single XML element, so the XML addressof each one can't be simply calculated from its logical coordinates.In order to allow the spreadsheet components to be addressed with thesame methods as the Writer table components, normalizeSheet()reorganizes the XML mapping of the given sheet.Caution: The OpenDocument specification doesn't make any differenceabout this point between tables included in text documents and tablesin spreadsheet-only documents. So any ODF-compliant application*could* denormalize the XML storage of any table and use therepetition attributes. As a consequence, normalizeSheet() *could* berequired in the future for other documents than OOo Calc ones.This method is not (presently) always needed for tables includedin OpenOffice.org Writer (odt/sxw) documents, because their storage is"normalized" (i.e. each component is mapped to an exclusive XMLelement), with the exception of the column objects. So,normalizeSheet() is required with these tables when the applicationneeds to use a column-focused method such as getColumn(),insertColumn() or deleteColumn().In the other hand, normalizeSheet() is not required to address a sheetwhich has been created through the OODoc methods (provided that thedocument has not been edited with another application software in themeantime). These methods, i.e. appendTable() and insertTable(), createnormalized tables, whatever the document class.Because this method is time and memory consuming, it should neverbe used to reorganize the largest possible area of a sheet (meaningthousands of rows and hundreds of columns that will probably never beused). So it's action is limited to a given area, controlled by therows, columns arguments. When these arguments are not provided, themethod uses the 'max_rows' and 'max_cols' properties instead (see theProperties section for other explanations). The processed area shouldbe sized in order to cover all the cells to be reached by the program,and nothing more.The first argument can be either the logical name of the sheet (asit's shown in the bottom tab by OOo Calc), the sheet number, or atable object reference, previously returned by getTable(). The returnvalue is the table object (or undef in case of failure).Example:$doc = odfDocument(file => 'report.ods');my $sheet = $doc->normalizeSheet('Sheet1', 7, 9);my $result = $doc->cellValue($sheet, 5, 6);In the sequence above, a top left area of 7 rows by 8 columns ispre-processed, so the cells from A1 to H6 of this sheet can bereached according to the same addressing scheme as in Writer tables.The last instruction gets the content of G6. Note that the second lineof this example could be replaced bymy sheet = $doc->getTable('Sheet1', 7, 9);knowing that, when called with size arguments, getTable() automaticallyexecutes normalizeSheet().The following code normalizes the whole table, whatever its size (butI don't recommend this option for tables containing thousands of rowsby hundred of columns):$doc->normalizeSheet('Sheet1', 'full');This last instruction could be automatically and silently executedthrough the following one:$doc->getTable('Sheet1', 'normalize');The transformed sheets, of course, are readable by OOo Calc.They simply take some more disk space when the processed spreadsheetis saved. If the document is later read then written by OOo Calc,the storage is optimized again, so the effects of normalizeSheet()disappear.normalizeSheet() is neutral against already normalized tables.An explicit call to this method can be replaced by getTable() with theadditional length and width parameters. In addition, normalizeSheet()is automatically executed before resizing each time a table isprocessed by expandTable().
normalizeTable(table [, rows [, columns]])
See normalizeSheet().
outputDelimitersOn()
outputDelimitersOff()
Turns delimiters on or off. Used to mark up text exported by certainmethods like getText or selectTextContent.The delimiters actually used depends on the table loaded into theOODoc::Text instance via the 'delimiters' property.
outputTextConversion(text)
Returns the conversion in local character set of the given text,supposed to be in UTF8. The local character set of the documentis used (see the 'local_encoding' property).
removeBookmark(id)
See deleteBookmark().
removeHeading(position [, level => level_no])
removeHeading(element)
Removes the given heading element.Example:$doc->removeHeading(4);removes the 5th heading (whatever its level) counted from thebeginning of the document.See getHeading() for the argument and option.If the argument is an element reference (second form), the type isnot checked and this method becomes the equivalent of removeElement()(which is documented with OpenOffice::OODoc::XPath generic methods).
removeHyperlink(path, position)
removeHyperlink(element)
Removes any hyperlink contained in the given element, leavingin place the previously hyperlinked text.
removeParagraph(position)
removeParagraph(element)
Removes the paragraph at the given position (first form).The paragraph to be removed can be indicated by element reference(second form). In this case, the type of element is not checked andthis method becomes the equivalent of removeElement.
removeCellSpan($cell)
Removes the multi-column, multi-row span of a table cell. The widthand height of the cell are reduced to one column and one row.Theuncovered cells take the same style and data type as the reduced cell.Caution: This method works with cells that heve been expanded usingthe "number-rows-spanned" and "number-columns-spanned" OpenDocumentattributes. The cell expansion is done this way by the cellSpan()method, as well as with the present version of OpenOffice.org Calc.But other applications (including the present version ofOpenOffice.org Writer) can implement the cell merge using subtablesinstead of span attributes.
removeSpan()
See removeTextStyleChanges().
removeTextStyleChanges(path, position)
removeTextStyleChanges(element)
Removes all the text style that apply to particular text spans in theparagraph or a heading provided as argument, so all the content will bedisplayed according to the text style that is defined at the paragraphlevel (font, colors, etc).Works with paragraphs or headings only.For a more drastic result, see flatten() in OpenOffice::OODoc::XPath.See also setTextSpan(). Caution: there is no symmetry betweensetTextSpan() and removeTextStyleChanges(). The first one creates onestyled text span at a time in a given context that may be larger thana single paragraph. The second one removes all the styled text spansin the given context, but the context is a paragraph or a heading only.
renameSection(section, newname)
Renames an existing section using the second argument.
renameTable(table, newname)
Renames an existing table using the second argument.
replaceText(path, position, filter, replacement)
replaceText(element, filter, replacement)
Replaces all sub-strings which match "filter" with "replacement" inthe text of an element (and its descendants) indicated by[path, position] or by reference and returns the modified text. The"filter" string can be an "exact" literal or a regular expression.Example:$doc->replaceText($p, "C(LIENT|USTOMER)", $contact);replaces each occurrence of "CLIENT" and "CUSTOMER" with the contentof the $contact variable in the paragraph $p of document $doc.The "replacement" argument can be a function reference. In whichcase, the function is called each time the string is matched, andthe value returned by the function is used as the replacement value.sub action {my $arg = shift;my $text = shift;print "$arg : $text\n";return "OK";}$doc->replaceText($p, $expression, \&action, "Found");displays "Found: <text>" (where <text> is the text retrieved) eachtime a string matches $expression and replaces this string with"OK". If $expression contains an "exact" string (not a regexp), thenclearly the text displayed will always be the same string. However,if it happens to be a regular expression, it is in effect the textretrieved which will be displayed.Generally speaking, if the replacement value is a functionreference, the called function receives the remainder of thearguments which follow it, in this order:1) all the arguments following the function reference in thereplaceText() call, in the same order;2) the string that matches the filter argument.See also substituteText(), which should be preferred in mostsituations.
rowStyle(row_element [, style])
rowStyle(table, row [, style])
Reads or modifies a table row's style, in the same way ascolumnStyle does for columns.
sectionProtectionKey(section)
Returns the encrypted key which is associated to the given section,if the section is write-protected by key.This method can't provide the real key (as it should be typed bythe end-user to unlock the section), but the returned value may bereused in order to protect more than one section with the samepassword.See also unlockSection().
sectionStyle(section, [newstylename])
Without argument, returns the current style of a given section.If an argument is provided, it becomes the new style of the section.
selectDrawPageByName(name)
In a presentation or drawing document, returns the page elementidentified by the given name, or undef if the name is unknown.The names to be used correspond to the displayed page names inOpenOffice.org Impress.
selectElementByBookmark(name)
Returns the element containing the given bookmark.Caution: this method works with position bookmarks only, not withrange bookmarks (a range bookmark can be spread over several textelements).
selectElementByContent([context,] filter [...])
Returns the first text element whose content matches the 'filter'(which can be an exact string or a regular expression), or undefif no matching content is found.With additional arguments after the filter, this method can be used forreplacement operations, or user-defined function triggering, in the sameconditions as selectElementsByContent().The retrieval functionality of selectElementByContent() is the sameas selectElementsByContent(). See selectElementsByContent() forlimits.
selectElementsByContent([context,] filter)
selectElementsByContent([context,] filter, replacement)
selectElementsByContent([context,] filter, action [, other_arguments])
This method returns the text elements whose content matches the searchcriteria contained in 'filter' (a string that may be a regexp).Note that this method can be used with a "non-filtering" regularexpression (".*") for unconditional movement through all text elements.The default scope is the current context (practically it's the wholedocument unless it has been changed using the currentContext() method).However a context element may provided before the filter argument inorder to restrict the search space.Be careful: if the search is successful, the returned elements may beof various kinds; they are not always paragraphs or headings. Theymay be, for example lower level text elements contained in paragraphs,such as text spans or text hyperlinks.The first form simply returns the given list without modifying thetext.The second form returns the same list, but replaces all stringswhich match the search criteria with the 'replacement' string as itgoes.The third form, where the 'action' argument is a program functionreference, launches the given function each time the filter stringis matched. If defined, the value returned by the function is usedas the replacement value. If the function returns a null value(undef) then no replacement is made. If it returns an empty string,the retrieved text is deleted. The called function receives the restof the arguments, in this order:1) all remaining arguments after 'action' ('other_arguments'), if any.2) the element containing the retrieved text.3) the string actually selected. If the filter is an exact string,it is equal to the filter. If the filter is a regular expression,it matches the "real" text retrieved.The returned text (if any) must be encoded in UTF8.The returned list is the same one returned by the first two forms.Example:sub action{my ($d, $element, $value) = @_;if ($value < 100){$d->removeElement($element);return undef;}else{return $value * 2;}}@list =$doc->selectElementsByContent("[0-9]+", \&action, $doc);In the above code, the subroutine "action" is called each time aninteger (one or more digits) is found. The subroutine receives thedocument reference itself as its first argument (an OODoc::Textobject given by the application). Next, it automatically receivesthe reference of the element in which the search string was found(i.e. an integer) and, finally, it receives the exact number foundas its second-last and last arguments respectively. If this numberis less than 100, the element is removed. This is why the subroutineneeded the $doc object, used to invoke the removeElement method. Ifmore than 100, the number is multiplied by two and the resultreplaces the original value in the element. The list returned byselectElementsByContent contains all elements which contain thesearch string, including any which might have been removed by thecalled function while it was running.It is the "main" elements containing strings which matched thefilter which are returned and not any of their sub-elements. Forexample, if the returned string is found in one of the items in anunordered list, the list element is selected and not the item.Similarly, the table is selected when one of its cells matches thefilter, and the paragraph which is selected when the search stringis found in an attached footnote.Important limit: This method can't retrieve elements whose displaycontent apparently matches the given filter but whose internalstorage doesn't. For example, a paragraph containing "foo bar" willnever be selected through selectElementByContent() if "foo" and "bar"have different text styles. In the same way, a substring containingmultiple successive whitespaces will never match, because, accordingto the ODF standard, multiple spaces (like tabs or line breaks) arestored as special XML element instead of flat text. A character stringcannot be considered to match the filter unless it is entirely withinthe same sub-element and all its characters have the same style. Moregenerally, a substring can match the filter if and only if it'srepresented with only one style and if it doesn't contain multiplespaces, tab stops or line breaks.
selectHyperlinkElement(url_filter)
Retrieves the first hyperlink element (if any) whose the URL matchesthe argument. Example:my $e = $doc->selectHyperlinkElement("cpan");could return an hyperlink element containing "www.cpan.org" aswell as "search.cpan.org", etc. The URL filter is processed asa regexp.Note: In order to get the text container (ex: paragraph) where thehyperlink is located, the application can use the parent() elementmethod. Example:my $e = $doc->selectHyperlinkElement("www.cpan.org");my $p = $e->parent if $e;
selectHyperlinkElements(url_filter)
Returns the list of the hyperlink elements whose the URL matchesthe argument (and not only the first one).
selectParagraphByStyle(stylename)
Returns the first paragraph (if any) using the given style.
selectParagraphsByStyle(stylename)
Returns the list of the paragraphs using the given style.
selectTextContent(filter)
selectTextContent(filter, replacement)
selectTextContent(filter, action [, other_arguments])
Returns a list of header texts and/or paragraphs (in the document'sown order) which match the given search criteria.The filter can be an exact string or a regular expression. A filterset to ".*" (no selection) will result in an export of the entiretext.In all three forms, this method behaves likeselectElementsByContent, except that it returns text instead of alist of elements.Depending on the context (list or scalar), the result is returned inthe form of a list of rows or in the form of a single characterstring where the elements are separated by a line-feed ("\n").Note: called with a "non-filtering" regular expression, this methodwill result in a "flat" export of the document:print $doc->selectTextContent('.*');
setAnnotation(element [, options])
Creates and inserts an annotation in a given element.The possible options are:'date' => the date/time of the annotation (ISO-8601 format); the defaultis the current system date/time'author' => the name of the author of the annotation; unless thisoption is provided; the default is the current system user name'text' => the text content of the annotation (no default)'style' => a paragraph style for the annotation (no default)'offset' => an integer value that specifies the position of theinsertion point of the annotation (default=0); a negative value meansthat the position is counted backward from the end'before' => a regular expression; specifies that the insertion pointshould be before the first match'after' => same as 'before' but the insertion point should be after thefirst match'replace' => same as 'before', but the matching substring is deletedand replaced by the annotationIf 'before', 'after' or 'replace' (which are mutually exclusive) is set,the 'offset' option, if provided too, specifies a search spacerestriction and a search way. If 'offset' is positive, the search spaceruns from 'offset' to the end; if 'offset' is negative, the search spaceruns from the end and its size is the absolute value of 'offset'.If 'offset' is 0, then it's possible to force the search backward fromthe end to the beginning using an additional 'way' parameter whosepossible values are 'backward' and 'forward' (if 'way' is 'backward',then 'offset' is regarded as negative whatever its sign).Note that the 'capture' option doesn't work with annotations.Returns the reference of the annotation element. Note that thisreference could be used later as a context for additional insertions(for example in order to append several paragraphs to the content ofthe annotation).
setBibliographyMark(element, [, position_options][attributes])
Creates a new bibliography mark within a given text element.The content of the new bibliography entry may be initialized througha 'attributes' parameter whose value is a hash.All the possible attributes of an ODF-compliant bibliography entry,such as author, editor, isbn, title, year, and many others, areallowed. A 'identifier' parameter is mandatory in order to get avisible mark; note that this identifier is bibliography-specific andis not the same as the generic identifier that could be get or setusing getIdentifier() and setIdentifier(). Other attributes are optional(but, of course, an entry with nothing more than an identifier would notbe very useful in a final document).By default, the object is inserted at the beginning of the target textelement. But, thanks to the optional position parameters, it can be putanywhere within the text of the bookmarked element. The positionparameters are 'offset', 'before', 'after', 'replace', and 'way' andthey work like with setAnnotation().$para = $doc->selectElementByContent("ODF-related book");$doc->setBibliographyMark ($para,offset => -20,replace => "reference needed",attributes => {identifier => "JDE",title => "OASIS OpenDocument Essentials",author => "J. David Eisenberg",year => 2005,isbn => "1-4116-6832-4"});This sequence replaces a "reference needed" substring in a givenparagraph by a bibliography mark that will be displayed by default as"[JDE" and that contains various attributes. The 'replace' option meansthat the given substring will be deleted and replaced by the mark. Thegiven (negative) offset means that the substring must be searchedbackward and that the last 20 characters of the paragraph must beexcluded from the search space.
setBookmark(element, name [, position_options])
According to the structure of the optional parameters, this method maybe used either to set a position bookmark (i.e. a named place holderat some point of the text content in a pararaph) or to set a rangebookmark (i.e. a range of text that may spread across paragraphboundaries and that is delimited by a bookmark start and a bookmark endelements).The first form is illustrated by the following example:$doc->setBookmark($paragraph, "BM001",offset => -20before => "xyz");This sequence puts a bookmark identified by "BM001" in a givenparagraph, immediately before the first "xyz" substring found in abackward search among the last 20 characters.The mandatory arguments are the target text element and the name of thenew bookmark (that should be unique).By default, the object is inserted at the beginning of the text. But,thanks to the optional position parameters, it can be put anywherewithin the text of the bookmarked element. The position parametersare 'offset', 'before', 'after', 'replace', and 'way', and they worklike with setAnnotation(). See also setChildElement() in OODoc::XPath.However, the 'text' option is ignored, knowing that a bookmark has notext content. If the 'replace' option is used, the matching substringis deleted and replaced by the bookmark, but the deleted text is notreused.The second form requires a bookmark name as the 1st argument, thena 'start' and a 'end' parameters are required; each one is a hash ofparameters that specifies the position of one mark according to the sameoptions as for a position bookmark (namely with 'offset', 'before','after', 'replace', and 'way'). In addition, each of the 'start' and'end hashes may contain an additional 'context' parameter that specifiesthe elements that will contain the start and end marks, respectively.The following example creates a range bookmark that starts after the15th character of $p1 and ends before the "xyz" substring in $p2,assuming that $p1 and $p2 are previously selected paragraphs in theright order:$doc->setBookmark("BM002",start => {context => $p1,offset => 15},end => {context => $p2,before => "xyz"});The user is not prevented by default from creating a range bookmarkwhose start point is after the end point of a range bookmark. However,it's possible to force an order check using a boolean 'check' option.If 'check' is 'true' while the order is wrong, the bookmark is notcreated.Note that the second form of setBookmark() is the same assetRangeBookmark().
setHyperlink(path, position, [context,] expression, url)
setHyperlink(element, expression, url [, options])
Puts an hyperlink on a text area in a given text element.The first substring matching the given "expression" argument in thetext element (if any) will become the hyperlinked text. The "url"argument is, of course, the URL of the hyperlink. If successful, themethod returns the new hyperlink element, or undef otherwise.This short example illustrates the simplest use:$doc->setHyperlink($para, "CPAN", "http://www.cpan.org");This method works in the same way as setTextSpan(), described below,but the text span is hyperlinked, and not only presented according toa particular style. So, the third argument must be an URL insteadof a style.A set of hyperlink attributes may be optionally provided as a hashthrough an optional 'attributes' parameter. For example, the applicationcan provide a 'style-name' and a 'visited-style-name' as shown below:$doc->setHyperlink ($para, "CPAN", "http://www.cpan.org",attributes => {'style-name' => "ToBeVisited",'visited-style-name' => "Visited"});'style-name' selects the style which applies to the text of thehyperlink, as long as the URL is not visited, while'visited-style-name' indicates, of course, the style in use if thelink location was already visited. These styles must belong to the'text' family.Other allowed hyperlink attributes are listed in the §5.1.4 of theOASIS OpenDocument specification. They may be set through the'attributes' options or later through the common setAttributes() method(that may apply to the object returned by setHyperlink).Note: The hyperlink is not always a remote URL, such as in theexample above. Internal references ere allowed as well. Aninternal reference is prefixed by "#". If an internal referenceis a heading, it's prefixed by "#" and suffixed by "|outline".An hyperlink may be aimed at a location inside another document;such a link is the concatenation of a file path, a "#", and a localname that makes sense in the target document (bookmark, heading...).
setIndexMark(element, id [, options][, start =>{}, end =>{}])
Creates an alphabetical index entry in a given element. The firstarguments are the target element (generally a paragraph) and amandatory identifier (that should be unique).A 'type' parameter allows one to select the type of index; possiblevalues are 'alphabetical-index' or 'toc' (the last one stands for"table of contents index mark"). The default is 'alphabetical-index'(it may be wrote 'alphabetical index', knowing that every space isautomatically interpreted as a '-').A 'content' parameter allows one to specify an expression; the firstsubstring in the element that matches this expression will become theindexed substring. It's possible to restrict the search area using a'offset' option, a positive or negative integer; a positive value meansthat the search space runs from the beginning to the given offset; anegative value means that it runs backward from the end to the givenoffset. In addition, a 'way' option whose legal values are 'forward' or'backward' may control the search way: if 'way' is 'backward' then thesearch is done backward even if 'offset' is not provided, and 'offset'is regarded as negative even if it's provided without the minus sign.Unless 'offset' is defined and negative, the default way is 'forward'.The code below puts an index entry, identified by "idx001" and relatedto the first match of a "xyz" expression:setIndexMark($paragraph, "idx001",type => 'alphabetical index',content => "xyz");Note that the 'type' option is provided for clarity only, knowing that'alphabetical-index' is the default.The following variant puts a TOC mark, searched backward from the endof a given paragraph, within a 20-character-long area:setIndexMark($paragraph, "idx001",type => 'toc',content => "xyz",offset => 20,way => 'backward');The same result in this second example could be obtained without the'way' option, with -20 instead of 20 as the 'offset' value.A more sophisticated set or parameters may be provided in order tospecify the beginning and the end of the index mark separately. To doso, 'content' must be omitted and replaced by the 'start' and 'end'parameters, each one being a hash, just like with the second form ofsetBookmark() that created a range bookmark, with a restriction:The 'start' and 'end' optional parameters allows one to specify the startand the end positions of the index mark. Each one is a hash that maycontain the same options as with setBookmark() described below, namely'offset', 'before', 'after', 'replace', and 'way', with the exceptionof 'context', because (unlike a bookmark) an index mark is entirelyincluded in a single paragraph; its start and its end belong to the samecontext, that is specified by the first argument.The following example creates an alphabetical index mark that isassociated to a text range running from the "xyz" substring to the endof the given paragraph:$doc->setIndexMark($paragraph, "idx002",type => 'alphabetical index',start => {before => "xyz"},end => {offset => 'end'});
setNote(path, position, text [, options])
setNote(element [, options])
Creates and inserts a footnote or an endnote in the given element withthe given text as the note content. Returns the new note element incase of success, or undef if the target element doesn't exist.Supported options are:'text' => the text content of the note'class' => specifies the display class of the now note; may be 'footnote'or 'endnote', default is 'footnote';'id' => a note identifier, must be provided by the application and mustbe unique for the class (be careful, the uniqueness is not automaticallychecked and no default is provided);'citation' => specifies the character string to display as note citation(at the place in the host element where the note is anchored);'label' => this option, if provided, means that the note should not beprocessed as automatically numbered by the printing/editing applicationsand that it should be represented by the given (arbitrary) string; if'label' is defined, it becomes the default value of 'citation';'style' => specifies the style of the note content (should be a regularparagraph style).By default, the object is inserted at the beginning of the text. But,thanks to the optional position parameters, it can be put anywherewithin the text of the bookmarked element. The position parametersare 'offset', 'before', 'after', 'replace', and 'way' and they worklike with setAnnotation().
setRangeBookmark(name, start => {options}, end => {options}, ...)
Like the second form of setBookmark(): creates a range bookmarkaccording to a mandatory name (1st argument) and position optionsprovided through 'start' and 'end' parameters, each one being a hashof options. See setBookmark() above for details.
setSpan()
Deprecated.See textStyle(), setTextSpan() and setTextSpans(), more powerful butusing different options.
setStyle(path, position, style_name)
setStyle(element, style_name)
Obsolete. See textStyle().
setText(element, text ,[text, ...])
Alters the setText method of OODoc::XPath, so that it can handlecomplex text elements. Please read the setText() entry inOpenOffice::OODoc::XPath before the present entry.If the element is a paragraph, a header or a list item (ordered orunordered), its content is replaced by the 'text' argument. Caution:setText() deletes and replaces the previous content of the paragraph.If the element is a table cell, this method is the same asupdateCell.If the element is a list (ordered or unordered), the content of each'text' argument (however many) forces the creation of a new itemwhich is appended to the list (existing items remain unchanged).Example:$doc->setText($element, "Peter", "Paul", "John")adds three items to the list if $element is a list. If $element is,for example, a paragraph, then the second argument ("Peter") becomesthe content of the paragraph and the other arguments are ignored.If the element is a note element or a note body, the given textbecomes the content of the note body.If the element is a section, the whole content of the section isdeleted and replaced by a single paragraph containing the given text.For all other types of $element, setText() behaves normally as definedin OODoc::XPath.Note: setText(), as any other text input method, doesn't properlyprocess repeated spaces by default. So, a sequence of spaces, whateverits length, is replaced by a single space. See setText() andextendText() in OpenOffice::OODoc::XPath.
setTextBoxContent(text_box, content)
Fills the given text box according to the given content.The first argument may be the unique name, the order number or thereference of a text box. The content is processed in the same wayas the content option in createTextBox().
setTextField(element, field-type [, options])
Puts a variable text field in a given text element.The 2nd argument specifies the type of field. The offical types aredescribed in §6.2 and §6.4 in the OpenDocument 1.1 specification,corresponding to the so-called "document fields" and "metadata fields".Examples of possible field type arguments are 'page number', 'chapter','paragraph count', 'time', 'file name', 'creator', 'creation date', etc.The full syntax of the ODF field tags is not mandatory; the rightnamespace prefix is automatically added if the given type indicatordoesn't contain a semicolon, and every space is replaced by a '-'. So,a field type like, say "text:word-count" may be specified as"word count".This method may be used in order to display a declared user field. Todo so, the field type must be 'variable' instead of a regular ODFtext field, and a 'name' parameter must be provided with the name of anexisting (ot to be created) user field declaration.While the content of a text field is often computed and displayeddynamically by ODF-compliant viewers, it's possible to provide analternative text that will be persistently stored in the field andavailable for applications which are note able to compute the contentand/or for users who need to know the last displayed value. Such analternative content is provided through a 'text' option.It's possible to provide the new text field with one or more attributesas a hash through a 'attributes' parameter. The most common attributesare 'fixed' and 'style'; the first one is a boolean, thesecond one is the name of a display format. The 'fixed' attribute, if'true', prevents the ODF-compliant editors and viewers from refreshingthe content of the field (for example a fixed date field displays thesame date forever instead of the current date). The 'style' attributeis the name of a display format (it's recommended to associate everydate, time or numeric field to a display format, while the defaultdisplay format of some ODF editors may be convenient for some needs).Here the 'style' attribute is a shorcut for 'style:data-style-name';see the ODF 1.1 specification §6.7.7 for a full description of thiskind of styles.Other attributes depend on the kind of content. The following examplecreates a fixed time field; the time value is stored as standard(ISO 8601) date format and the alternative text is an arbitrary localrepresentation of the same; the presentation style (for applicationsthat can deal with ODF number styles) is "MyTimeStyle" (that is supposedto be the name of a time style defined as an automatic style in thedocument):$doc->setTextField ($paragraph, 'time',text => "17:03:25",attributes => {fixed => 'true','time value' => "2010-02-25T17:03:25",style => "MyTimeStyle");Note that in this example, if 'fixed' was 'false' or undef, a fullyfunctional ODF editor could dynamically update the 'time value'according to the current date and the text content according to thecurrent time and the given style. Here the internal value is a'time value'; it would be the same for any field type containing atime value (such as, say, a 'print time' or a 'creation time' field).For other field types, the corresponding attribute would be'date value', 'string value', 'boolean value', or just 'value'. Forany detailed information about the possible attribute combinationsaccording to the field types, have a look at the chapter 6 of ODF 1.1.By default, the field is inserted at the beginning of the given textelement. But, thanks to the optional position parameters, it can be putanywhere within the text of the element. The position parametersare 'offset', 'before', 'after', 'replace', and 'way', and they worklike with setBookmark() and other methods. See also setChildElement()in OODoc::XPath. If the 'replace' option is used, the matching substringis deleted and replaced by the text field. The next example insertsthe name of the author of the last change (i.e. the 'creator', accordingto the ODF vocabulary) as a replacement of a "AUTHOR HERE" substringsearched backward somewhere in a 50-character-long area at the end ofthe target element:$doc->setTextField ($paragraph, 'creator',replace => "AUTHOR HERE",offset => 50,way => 'backward');and the code below appends after the last character of the paragraph a'file name' field that will display the full path of the file:$doc->setTextField ($paragraph, 'file name',offset => 'end',attributes => {display => 'full'});The last example creates a display area in a given paragraph after agiven substring for a declared variable whose name is "Amount" (seesetUserFieldDeclaration() in OpenOffice::OODoc::XPath to see how sucha variable may be declared):$doc->setTextField ($paragraph, 'variable',name => "Amount",replace => "AMOUNT HERE");
setTextFields(element, expression, field-type [, options])
Replaces every substring that matches the given expression in the giventext element by a variable text field. See textField() in the presentmanual chapter for some information about text fields.This method works the same way as setTextSpans() to retrieve the stringsto be replaced. However, each matching string becomes invisible andis replaced by the variable field.Optional field attributes are allowed after the field type in the sameconditions as for textField().The following example replaces every occurrence of "TIMESTAMP" in agiven section by a variable field displaying a time which is 2 hourslater than the current time:$section = $doc->getSection("Variables");$doc->setTextFields($section, "TIMESTAMP", 'time','time-adjust' => 'PT02H');This method returns the text field elements as a list.See also setTextField().
setTextSpan(path, position, style [, options])
setTextSpan(element, style [, options])
Inserts a substring with a special text style in a selected positionwithin the content of an existing text element (namely a paragraph ora heading). Unlike setTextSpans() and the 3-argument use of textStyle(),inserts only one span (or nothing if the conditions are not met).A "text span" is a substring whose presentation style differs from thestyle of the text element to which it belongs. For example, a given"span" could be in italics while the rest of the paragraph is in normalcharacters. A text span is a special element that contains text but thatmust be included in a paragraph or a heading. Caution: the same word hasa different meaning when it's used about table cells (see cellSpan()).The properties of a text span can be related to any kind of characterstring presentation, such as font, font size, font weight, fontstyle, and colors (background and foreground). Whatever theseproperties, they apply through a style.setTextSpan() works on any kind of text container, whatever itshierarchical level. For example, if the given element is a table,the span style attribution applies to every cell of the table. Andthe same change can be done in all the displayable content notincluding page headers, page footers, and page backgrounds througha single setTextSpans() call, if the given element is the document bodyitself (see getBody() in OpenOffice::OODoc::XPath).The first argument is the target element, the second one is the name ofa text style (existing of to be defined). The optional parameters thatfollow specify how and where the text span should be inserted.The method returns the new text span object, or undef in case offailure.The location of the text span may be specified using the same options asthe setChildElement() which is described in the OODoc::XPath manual.A 'capture' parameter, whose value is a string, means that the firstsubstring that matches it should become the content of the new textspan. The following instruction replaces the first appearance of the"ODF" substring in a given paragraph by a text span whose content willbe "ODF" and whose style will be "Standout"; in other words, it tellsthat the style "Standout" will apply to the first "ODF" substring:$doc->setTextSpan($paragraph, 'Standout', capture => "ODF");It's possible to apply a text style and to change the text content ina single operation using both the 'replace' and the 'text' options.If 'text' is set, its value is used as the text of the new span element.In the next example, the "ODF" substring will be removed and replacedby a text span whose style will be "Standout" and content will be"OpenDocument" instead of "ODF":$doc->setTextSpan($paragraph, "Standout",replace => "ODF",text => "OpenDocument");Note that there is no default text, so if 'replace' is set while 'text'is not set, the matching substring is deleted and replaced by a textspan with a style but without content, resulting in useless markup(there are more convenient ways to just delete a substring).Practically, if both 'text' and 'capture' are set, the result is thesame as with 'replace'; however, as soon as the aim is to replace asubstring by a text span and not to capture the content of the substringin the text span, I encourage the use of 'replace' in order to get amore self-documented code.It's possible to provide a search string with a 'after' or 'before'option instead of 'replace'. If so, the new text span is insertedafter of before the first match, and no text is removed or moved intothe text span element, that may receive the value of 'text' (if set).The example below creates a text span with the "Standout" style andwhose content is "OpenDocument" immediately after a the substring "thebest document format is ":$doc->setTextSpan($paragraph, "Standout",after => "the best document format is ",text => "OpenDocument");While the 'replace', 'after' or 'before' parameter automatically selectsthe first match, it's possible to reverse the search, thanks to the'way' option, whose possible values are 'forward' and 'backward'(default='forward').Caution: A substring located partly in a "span" and partly outside itwill never match. In addition, while a text span is allowed insideanother text span, a text span can not be spread across elementboundaries.The 'offset' parameter is a positive or negative integer that specifiesthe start position of the span in the text. So, this parameter allowsto insert a text span at an arbitrary position (counted forward from thestart or backward from the end).If 'before', 'after' or 'replace' (which are mutually exclusive) is set,the 'offset' option, if provided too, specifies a search spacerestriction and a search way. If 'offset' is positive, the search spaceruns from 'offset' to the end; if 'offset' is negative, the startposition is counted from the end and the search space runs backwardfrom the given position and the beginning of the context.More generally, this method uses the logic and the search options ofsetChildElement() to compute the insert point, like setAnnotation() andother special intra-paragraph markup insertion methods;setChildElement() is described in the OODoc::XPath manual page.Remember that setTextSpan() creates only one text span with variousoptions; if the aim is to automatically create a text span for everymatch of a given substring, see setTextSpans() or textStyle().
setTextSpans(element, style [, options])
Applies a special text style to all the substrings of a given textelement that match a given expression. See setTextSpan() forexplanations about the meaning of "text span". The main differencewith setTextSpan() is that setTextSpans() operates repeatedly so itmay apply the given style to every substring that matches the givenconditions.The context element and the style to apply are provided as mandatoryarguments. They are followed by the named search parameters. Theseparameters are the same as for setTextSpan(). Warning: the user mustensure that the provided search parameters make sense and can't resultin an infinite loop. For example, the following instruction willattempt to create an infinite sequence of continuous bookmarks beforethe first occurrence of "xyz" substring, if this substring exists:$doc->setTextSpans( # Wrong !$paragraph, "SomeStyle",before => "xyz");Taking the following paragraph as an example:"OpenOffice.org includes Writer, Calc, Draw and Impress"Assuming this text is contained in a $p element, the followinginstruction gives the "Highlight" style to the "OpenOffice.org","Writer", "Calc", "Draw", and "Impress" substrings:$doc->setTextSpans($p, "HighLight",capture => 'OpenOffice\.org|Writer|Draw|Calc|Impress');Note that the instruction above produces the same result as:$doc->textStyle($p, "HighLight",'OpenOffice\.org|Writer|Draw|Calc|Impress');While the 3-argument use of textStyle() is appropriate as long as theaim is to unconditionally apply the given style to every matching stringin the context, setTextSpans() allows much more selective operations.The given context may be any element, including the whole document,and not only a paragraph. This last example produces the same effectas the previous one, but it operates between two given arbitrary textbookmarks that may be in different paragraphs in the document, whilethe context is the document body:$doc->setTextSpans($doc->getBody(), "HighLight",capture => 'OpenOffice\.org|Writer|Draw|Calc|Impress',start_mark => $doc->getBookmark("BM1"),end_mark => $doc->getBookmark("BM2"));See also setTextSpan(), removeStyleChanges(), textStyle() andsetHyperlink().
setUserFieldDeclaration(name [, options])
Creates a user field declaration for the document. Allowed optionsare:'type' => the data type (default=string)'value' => the initial value (default="")Returns the new variable element if successful. Does nothing andreturns undef if the variable already exists. The example below createsa declaration for a variable whose name="Amount", type=float andvalue=1234.56$doc->setUserFieldDeclaration("Amount",type => 'float',value => 1234.56);See also getUserField(), userFieldValue(), setTextField().
substituteText(element, filter, replacement)
Replaces any substring in a given element and its descendants,matching a given filter (regexp) by a given replacement string.It "replacement" is a string, this method produces the same result asreplaceText(), and it should be preferred.If "replacement" is a function reference, the replacement value is thereturn value of the function. But, unlike replaceText(), any argumentafter "replacement" is ignored.This method is a wrapper for the subs_text() method provided by theXML::Twig::Elt class. See the XML::Twig documentation for advanceddetails.
tableName(table [, newname])
Returns the current name of a given table, or replaces it with a newname given as the second argument. The table can be indicatedby number, logical name or reference.Returns undef unless the given table is defined.If the new name is the name of an existing table, the table is notrenamed and an error message is produced.
tableStyle(table [, style])
Returns the current style of a given table, or replaces it with anew style given as the second argument. The table can be indicatedby number, logical name or reference.
textBoxCoordinates(text_box [, new_coord])
Gets or sets the position of a text box. The new coordinates, ifany, must be provided using the same syntax and units as withthe "position" option in createTextBox().
textBoxDescription(text_box, [, new_desc])
Gets or sets the optional description (long label) of the giventext box.
textBoxName(text_box [, new_name])
Allows the applications to get the name of the given text box(which makes sense if the name is unknown, i.e. if the firstargument is the element reference or the order number and notthe name itself, of course). If a literal is passed as a secondargument, the text box is renamed accordingly.
textId(element [, text_id])
This accessor gets or sets the "text identifier", an optionalattribute of any text container. This attribute is presently usedfor a few elements by OpenOffice.org (ex: the notes).With one argument only, returns the existing identifier of the givenelement, or undef if the element doesn't own a text identifier.If a second argument is provided, its value replaces any previousvalue of the identifier, and the text identifier is created if needed.The new value is not checked, so the application should take care ofits uniqueness.The text identifier can be used as a bookmark, knowing that, unlike abookmark, this attribute is not visible for the end user.See also selectElementByTextId().Caution: The text identifiers created or changed by other applicationsare presently *not* preserved when the document is edited throughOpenOffice.org.
textField(type [, options])
Creates and returns a variable field to be inserted within a textelement.Such a field doesn't contain any static text by itself. Whenincluded in a text container, it tells the editing/printing softwareto display dynamic context data, such as date, time, file name,page number, page count, author, etc. Variable text fields are mainlyused in page headers or footers, but they are allowed in the pagebodies as well. Remember that a text field must be attached as a childelement of a text container (paragraph or heading) in order to bedisplayed. However, the text container itself may be attached toanything anywhere (ex: a page header, a table cell, a list item, etc).The first argument (mandatory) is the field type. Many field typesare allowed, so they are not all listed here. For some of them,options are allowed or required.To get the full list of field types, and their possible options,look at the chapter 6 "Text fields" in the OpenDocument 1.0specification. However, a few ones are presented below as examples.The field type, as well as each field option, must be provided as itappears in the OpenDocument specification, without the "text:" prefix(this prefix is automatically added). However, the application canforce any arbitrary field name and/or field option such as 'xxx:yyy'(any name or option including a ':' is accepted as is).Caution: textField() allows the user to create any kind of field,without OpenDocument compliance check. So it can be used to insertapplication-specific markup in any place. This feature could proveuseful in some situations, but remember that a typo in a field typeor option will not be automatically detected. In the other hand, everynon-OpenDocument field is silently removed if the document is lateredited and saved through OpenOffice.org.Knowing that the created element is not attached to a text container,it must be inserted or appended through another method. For example,the following sequence creates a paragraph displaying "This documentcontains <page-count> pages and we are in the page <page-number>":$para = $doc->appendParagraph(text => "This document contains ",style => "Standard");$pg = $doc->textField('page-count');$doc->appendElement($para, $pg);$doc->extendText($para, " pages and we are in the page ");$pg = $doc->textField('page-number');$doc->appendElement($para, $pg);The 'page-number' field type, introduced above, could be adjusted inorder to display the page number of any following or preceding page.To do so, a 'page-adjust' option, set with a positive or negativeinteger value, should be provided to createField():$pg = $doc->textField('page-number', 'page-adjust' => -2);Note that, if the arithmetic sum of the real page number and the'page-adjust' value doesn't match an existing page, the editingapplication should display nothing.As another example, a 'chapter' field displays the current chapternumber or title. It requires 2 options: 'outline-level', an integerwhich selects the hierarchical heading level to be regarded as thechapter level, and 'display' which controls the value to display(chapter number, chapter name or both). The following instructioncreates a field displaying the number and the name of the currentlevel 1 heading:$chapter_field = $doc->textField('chapter','outline-level' => 1,'display' => 'number-and-name');Other possible fields display the current date or time (see thesetTextField() example about a time field with an optional ajustment),the author's name, the file path or name, and many other variable orfixed values, according to many options.
textStyle(path, position [, style [, expression]])
textStyle(element [, style [, expression]])
Reads the name of a text element's style or, if a 'style' argument isgiven, changes it. The text element may be a section, paragraph, aheading, or a text span included in a paragraph or a heading.The element can be indicated by the pair [path, position] or byreference.If a style is provided as the second argument, it's applied to the textelement (and it replaces the previously set style, if any).If a text string is provided as the third argument, the given styleapplies to every matching substring in the element, and not to theelement itself. In this case, the given style must be a text style,while it must be a paragraph style otherwise.The returned value is a literal style identifier, i.e. the valueof the element's 'text:style-name' attribute. This identifier couldbe used to retrieve the style element itself, through another methodsuch as getStyleElement() (see OpenOffice::OODoc::Styles).In the following example, the 1st instruction just returns the currentstyle of a given paragraph, the 2nd one sets the style of the givenparagraph to "New Paragraph Style", and the 3rd applies the "New TextStyle" to every substring matching "foo" in the given paragraph:$current_style = $doc->textStyle($paragraph);$doc->textStyle($paragraph, "New Paragraph Style");$doc->textStyle($paragraph, "New Text Style", "foo");For more selective ways to apply a text style to a portion of paragraph,see setTextSpan().
unlockSection(section)
Removes the write protection (if any) of the given section. If thesection was key-protected, the key is removed and provides the returnvalue of the method.Example:my $key = $doc->unlockSection("Section1");$doc->lockSection("Section2", $key);The two lines above remove the protection of "Section1" and protect"Section2" with the password which previously protected "Section1".
unlockSections()
Removes the write protection of every section in the document.
updateCell(table, row, column, value [, text])
updateCell(element, value [, text])
Modifies the content of a table cell.In its first form, indicates a cell by its 3D coordinates, as withgetTableCell(). In its second form, indicates a cell by its elementreference.If the cell is set to literal, its content is limited to its text.In this case, the optional argument "text" is of no use (the textequals the value).If the cell is set to numeric (float, currency, date, etc.), youshould generally pass a literal argument as well as the value.This method can be replaced by cellValue() which allows reads andwrites.
updateText(element [, options])
Changes some text content in the given element or its descendants,according to the given options:'text': a text string that will be inserted somewhere within theelement, at a position which depends on other options, by default atthe beginning.Alternatively, the 'text' option may be a reference to a user-providedfunction whose return value will be used as the text to be inserted;this function will be called with the document object as its firstargument (so it can use document-based methods), the current text nodeas its second argument and optionally with a text string (that dependson other options, see below) as its third argument. (Be careful, a"text run", or "text node", is not always an element; it may be a localtext segment within an element.) The user-provided function is notsupposed to update the text node by itself. If the return value isundef, or an empty string, nothing is inserted.'replace': a search string (regex) whose first match will be deleted(and, of course, replaced by the value of the 'text' option , if any).'after': a search string (regex) whose first match will be followed bythe new inserted text.'before': a search string (regex) whose first march will be preceded bythe new inserted text.Note that 'replace', 'before' and 'after' are mutually exclusive. If'text' is set with a function reference, the corresponding functionwill be called with the matching substring as its second argument; ifnone of the allowed search string options is set, this function will becalled with the document argument only.'way': an indicator, whose allowed values are 'forward' and 'backward'(default 'forward'), that specifies the search way. If 'way' is'backward', the provided search string (if any) is searched backwardfrom the end (i.e. the first match is the last match in the order of thedocument), and the 'offset' is counted back from the end (note that anegative offset automatically switches the 'way' to 'backward'). If theresult doesn't depend on the search way, the 'way' option should beomitted or set to 'forward'.'offset': a numeric position that specifies the point where the contentof the 'text' option will be inserted; if 'offset' and one of theallowed search strings (after, before or replace) are provided, then'offset' specifies the limit of the search area instead of a insertionpoint; if 'offset' is positive and 'way' is 'forward' (or not set), thesearch is done from 'offset' to the end; if 'offset' is negative or'way' is 'backward', the search is done backward from the given offsetto the beginning; a negative 'offset' means a backward 'way' (but if'way' is 'backward', the sign of 'offset' is ignored, in order to avoiduseless complications).'repeat': if set to 'true', specifies that the action must be donerepeatedly in a way that depends on the other options. If 'repeat' isset to 'true' while none of the search string options (after, before orreplace) is set, the result depends on the 'offset'. If 'offset' is 0or undef, then the 'repeat' option is ignored (avoiding an infiniteloop!). If only 'offset' and 'text' are provided, the new text isrepeatedly inserted with 'offset' as the interval.Note: for repetitive and unconditional text replacements in a givencontext (i.e. when no parameter other than the context, the searchfilter and the replacement string is required), substituteText() shouldbe preferred (see substituteText() in OODoc::XPath).The following example replaces the last match of "old" by "new" in agiven paragraph:$doc->updateText($paragraph,replace => "old",text => "new",way => 'backward');The same, but the replacement is done for the whole paragraph (note thatthe 'way' option is omitted, knowing that in such situation the resultwill be the same whatever the search way, so 'forward' is OK):$doc->updateText($paragraph,replace => "old",text => "new",repeat => 'true');The next instruction makes sure that "Smith" becomes "Mr. Smith"everywhere between the bookmarks "BM1" and "BM2" (because such a spacemay spread over various and multiple elements, the whole document bodyis specified as the search context instead of a paragraph):$doc->updateText($doc->getBody,before => "Smith",text => "Mr. ",start_mark => $doc->getBookmark("BM1"),end_mark => $doc->getBookmark("BM2"),repeat => 'true');
updateUserFieldReferences(user_field [, context])
Forces an immediate update of the display representation(s) ofa given user field, according to the actual value of the field.It's possible to restrict the scope to a particular context, thatmay be provided as an optional argument.
OpenOffice::OODoc::Element methods
While all the methods above belong to the document object, someadditional methods are defined for individual text containers. Thesemethods belong to the OpenOffice::OODoc::Element class. The mostgeneral of them are described in the OpenOffice::OODoc::XPath manual.Some of them (listed below) are simple read-only accessors allowingthe user to check the type of any element.
isXXX() methods
A set of "isXXX" methods, returning true or false, allow to checkthe type of a given element. Caution, this methods belong to theelements, not to the document.Example:print "This is a list" if $element->isItemList;Here is the list of element type indicators:isBibliographyMark bibliography mark (in the doc. body)isCovered covered (invisible) table cellisDrawPage presentation or drawing pageisEndnote endnote main elementisEndnoteBody endnote body elementisEndnoteCitation endnote citation elementisFootnote footnote main elementisFootnoteBody footnote body elementisFootnoteCitation footnote citation elementisHeading headingisItemList list (ordered or unordered)isListItem list itemisNote main note element (end- or footnote)isNoteBody note body (in end- or footnote)isOrderedList ordered list (OOo only)isParagraph paragraphisSection sectionisSequenceDeclarations set of sequence declarationsisSpan span element (see setTextSpan)isTable tableisTableCell table cellisTableRow table rowisUnorderedList unordered list (OOo only)
Other element methods
For a neater and more direct access to element types, see thegetName method of XML::Twig::Elt. A call to $element->getNamereturns the element's XML name including its namespace prefixe.g. 'text:p' for a paragraph or 'table:table-row' for a tablerow. Remember that all the features of XML::Twig::Elt areavailable for any text container.
Properties
No class variables are exported.Instance properties are the same as for OODoc::XPath, plus:'delimiters' => delimiter tablehash giving the relation between element types and the delimiters touse when exporting text (see getText).'use_delimiters' => delimiter usage (see getText)indicates whether delimiters are to be used by getText or not whenexporting text. Set to 'on' by default. Can be set to 'off' oranother value to stop or limit use of delimiters.'heading_style' => default header styleindicates the default header style to be used by element creationmethods when no style is specified. Set to 'Heading 1' by default.'paragraph_style' => default paragraph styleindicates the default paragraph style to be used by element creationmethods when no style is specified. Set to 'Standard' by default.'field_separator' => field separatorcontains the character string to be used as the field separator whenexporting tables. By default it is ";".'line_separator' => line separatorcontains the string to be used to separate lines when exporting"flat" text. By default, it is a line-feed ("\n").'max_rows' => max table length (default 32)'max_cols' => max table width (default 26)these 2 properties control the size of the "managed area" in aspreadsheet; the default "managed area" is the A1:Z31 rectangle,corresponding to the (0,0)-(31,25) coordinates; see getTable() andgetTableCell() and normalizeSheet() for more explanations.'expand_tables' => table transformation usageindicates whether the XML representation of the spreadsheets are tobe expanded in order to allow the same cell/row addressing schemeas with the tables belonging to text documents; by default, thisproperty is not set. If this property is set to 'on', the firstaccess to any sheet will automatically trigger this transformation,so the explicit normalizeSheet() method will not be needed.However, this automatic (but costly) transformation has a drawback:it uses the same 'max_rows' and 'max_cols' values for every targetedsheet, whatever the really needed managed area for each one.
AUTHOR/COPYRIGHT
Developer/Maintainer: Jean-Marie Gouarne <http://jean.marie.gouarne.online.fr>
Contact: [email protected]
Copyright 2004-2008 by Genicorp, S.A. <http://www.genicorp.com>
Initial English version of the reference manual by Graeme A. Hunter ([email protected]).
License: GNU Lesser General Public License v2.1
POD ERRORS
Hey! The above document had some coding errors, which are explained below:
- Around line 2672:
-
Non-ASCII character seen before =encoding in '§5.1.4'. Assuming CP1252