The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

ODF::lpOD::Common - Common utlities provided by the Perl lpOD library

DESCRIPTION

This manual page describes miscellaneous functions and auxiliary features of the lpOD Perl implementation that are not directly linked to the lpOD functional specification.

Data conversion utilities

The utilities introduced in this section are implemented as exported functions. They may be used without package or object reference.

is_true(value),

Returns TRUE if the given value may be regarded as true (in the Perl lpOD implementation). The usual Perl true values are interpreted as TRUE, with the a few exceptions. The strings 'false', 'no', and 'off', like 0, undef, and the empty string, are regarded as FALSE.

The common constants TRUE and FALSE (corresponding to 1 and 0) may be used by the applications.

is_false(value)

Returns TRUE if the given value is undef, zero, an empty string, 'false', 'no', 'off'. Returns FALSE otherwise.

odf_boolean(value)

Translates in an ODF-compliant boolean value (i.e. 'true' or 'false') a Perl/lpOD boolean value. The result may be used as the value of any ODF boolean attribute.

is_odf_datatype(type)

Returns TRUE if the given argument is the name of a valid ODF data type for table cells or variable fields, FALSE otherwise. For example, the first instruction below returns TRUE and the second one returns FALSE:

        $check1 = is_odf_datatype('float');
        $check2 = is_odf_datatype('complexType');

odf_value(value, type)

Converts the given value according to the given type (which must be a regular ODF datatype), and checks it if the value is already in ODF format.

The following example formats the current system date so the result may be used as the value of a date field in a document:

        $odf_date = odf_value(time(), 'date');

This function returns undef if the given value is not compatible with the given type.

Note: this function doesn't work for any type in the present developement version.

iso_date(time)

Translates a numeric time into an ISO-8601, ODF-compliant date.

numeric_date(odf_date)

Translates an ISO-8601 date, coming from an ODF document, into a Perl computable time value.

General configuration

Some methods are provided by the lpod pseudo-object in order to get or set some configuration parameters.

Installation information

The info method returns some informations about the current lpOD installation, as a string in scalar context, or as a hash in array context.

Example:

        say scalar lpod->info;

The installation_path method returns the path of the ODF::lpOD module installation in the user's filesystem.

Local encoding

All the text/attribute oriented methods of the odf_element may automatically convert the processed content from or to the local encoding of the user. The local encoding is utf8 by default. It may be get or set using the common get_local_encoding or set_local_encoding. The latter must be called with an encoding name that is supported by the Perl Encode module (an alert is issued and nothing is changed if the given encoding is not supported).

Example:

        my $old_encoding = $lpod->get_local_encoding;
        lpod->set_local_encoding('iso8859-1');

Warning information

The debug method, when called with TRUE as argument, specifies that the lpOD-issued warnings must display the call stack.

COPYRIGHT & LICENSE

Copyright (c) 2010 Ars Aperta, Itaapy, Pierlis, Talend.

This work was sponsored by the Agence Nationale de la Recherche (http://www.agence-nationale-recherche.fr).

lpOD is free software; you can redistribute it and/or modify it under the terms of either:

a) the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. lpOD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with lpOD. If not, see http://www.gnu.org/licenses/.

b) the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0