/************************************************************************ * * MetaData.java * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License version 2.1, as published by the Free Software Foundation. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA * * Copyright: 2002-2014 by Henrik Just * * All Rights Reserved. * * Version 1.4 (2014-09-16) * */ package writer2latex.office; import java.util.HashMap; import java.util.Map; import org.w3c.dom.Document; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import writer2latex.util.*; //import writer2latex.office.*; /** *
This class represents the metadata of an OOo Writer document.
*/ public class MetaData implements writer2latex.api.MetaData { // Dublin Core private String sTitle = ""; private String sCreator = ""; private String sInitialCreator = ""; private String sDate = ""; private String sDescription = ""; private String sLanguage = ""; private String sSubject = ""; // Keywords private String sKeywords = ""; // User-defined private MapConstruct a new instance from an OOo Writer document.
* @param oooDoc is the OOo document */ public MetaData(OfficeDocument oooDoc) { // get the DOM (either package or flat) Document dom = oooDoc.getMetaDOM(); if (dom==null) { dom = oooDoc.getContentDOM(); } // get the office:meta element NodeList list = dom.getElementsByTagName(XMLString.OFFICE_META); if (list.getLength() == 0) { return; } // oops, no metadata - fails silently Node meta = list.item(0); if (!meta.hasChildNodes()) { return; } // traverse the metadata CSVList keywords = new CSVList(", "); list = meta.getChildNodes(); int nLen = list.getLength(); for (int i=0; iGet the creator of this document (may be empty)
* @return the creator of the document (or the initial creator if none is specified) */ public String getCreator() { return sCreator==null ? sInitialCreator : sCreator; } /**Get the initial creator of this document (may be empty)
* @return the initial creator of the document */ public String getInitialCreator() { return sInitialCreator; } /**Get the date of this document (may be empty)
* @return the date of the document */ public String getDate() { return sDate; } /**Get the description of this document (may be empty)
* @return the description of the document */ public String getDescription() { return sDescription; } /**Get the language of this document (may be empty)
* @return the language of the document */ public String getLanguage() { return sLanguage; } public void setLanguage(String sLanguage) { this.sLanguage = sLanguage; } /**Get the subject of this document (may be empty)
* @return the subject of the document */ public String getSubject() { return sSubject; } /**Get the keywords of this document as a comma separated list (may be epmty)
* @return the keywords of the document */ public String getKeywords() { return sKeywords; } /** Get the user-defined meta data * * @return the user-defined meta data as a name-value map */ public Map