#9 Get title from Title style

closed
nobody
None
5
2011-06-22
2010-10-13
No

odt2daisy currently uses the Title from ODF's document properties to fill in the Title field in the export dialogue. If the title in the document properties is empty, the Title field is also empty - this is what happens with most documents. Ideally, odt2daisy should check the (first) Title style in the document if the title in document properties is empty.
If the user fills in a title in the export dialogue, odt2daisy could save this value as metadata in the ODF file.
(I hope I can write a patch for this.)

Discussion

  • The following version of the method getODTTitleMeta() in com.versusoft.packages.ooo.odt2daisy.Odt2Daisy uses the Title style of Title in the Document Properties is empty:

    /**
    * Gets the document title from the document properties (dc:title).
    * If the title property is empty, the first Title style is used as a fallback.
    * @return Document title, as String
    * @throws MalformedURLException
    * @throws IOException
    */
    private String getODTTitleMeta() throws MalformedURLException, IOException {
    String title = "";
    title = XPathUtils.evaluateString(tmpFlatFile.toURL().openStream(),
    "/office:document/office:meta/dc:title/text()",
    Configuration.namespace);
    if (title.length() == 0) {
    title = XPathUtils.evaluateString(tmpFlatFile.toURL().openStream(),
    "/office:document/office:body/office:text/text:p[@text:style-name='Title'][1]/text()",
    Configuration.namespace);
    }
    logger.fine("DocumentTitle=\'" + title + "\'");
    return title;
    }

    What I don't have yet is a way to get the value from the Title field in the odt2daisy dialog into the document metadata.

     
    • status: open --> closed