/**
- *
- */
+* Copyright (C) 2007 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
package eu.etaxonomy.cdm.print.out.odf;
import java.io.File;
import eu.etaxonomy.cdm.print.out.PublishOutputModuleBase;
/**
- * This output module will transform the given document into <a href="http://www.oasis-open.org/committees/office/">ODF</a> format for further editing in
+ * This output module will transform the given document into <a href="http://www.oasis-open.org/committees/office/">ODF</a> format for further editing in
* <a href="http://www.openoffice.org/">OpenOffice</a> or any other tool that understands ODF.
- *
+ *
* @author n.hoffmann
* @since Apr 20, 2010
- * @version 1.0
*/
public class OdfOutputModule extends PublishOutputModuleBase {
private static final Logger logger = Logger
.getLogger(OdfOutputModule.class);
-
+
public static String STYLESHEET_RESOURCE_DEFAULT = "/stylesheets/odf/cdmToOdfText.xsl";
-
+
private DocumentCreator documentCreator;
private Transformator transformator;
-
+
public OdfOutputModule() {
InputStream xslt = getXsltInputStream();
documentCreator = new DocumentCreator();
try {
- transformator = new Transformator(xslt);
- }
+ transformator = new Transformator(xslt);
+ }
catch (XSLTransformException e) {
logger.error("XSLTransformException while creating ODF output module", e);
}
}
-
- /* (non-Javadoc)
- * @see eu.etaxonomy.printpublisher.out.IPublishOutputModule#output(org.jdom.Document, java.io.File)
- */
- public void output(Document document, File exportFolder, IProgressMonitor progressMonitor) {
-
+ @Override
+ public void output(Document document, File exportFolder, IProgressMonitor progressMonitor) {
+
super.output(document, exportFolder, progressMonitor);
-
+
Document transformedDocument;
String filePath = getFilePath(exportFolder);
-
+
try{
transformedDocument = transformator.transform(document);
-
+
OdfTextDocument odfTextDocument = documentCreator.create(transformedDocument);
-
+
odfTextDocument.save(filePath);
logger.warn("ODF output written to disk: " + filePath);
}catch(Exception e){
throw new RuntimeException(e);
}
}
-
- /*
- * (non-Javadoc)
- * @see eu.etaxonomy.printpublisher.out.IPublishOutputModule#getOutputFileSuffix()
- */
- public String getOutputFileSuffix() {
+
+ @Override
+ public String getOutputFileSuffix() {
return "odf";
}
-
+
@Override
protected InputStream getDefaultXsltInputStream() {
return OdfOutputModule.class.getResourceAsStream(STYLESHEET_RESOURCE_DEFAULT);
}
-}
+}
\ No newline at end of file
/**
* Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy
+* European Distributed Institute of Taxonomy
* http://www.e-taxonomy.eu
-*
+*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* See LICENSE.TXT at the top of this package for the full license terms.
*/
-
package eu.etaxonomy.cdm.print.out.odf;
import org.apache.log4j.Logger;
/**
* @author n.hoffmann
* @since Apr 29, 2010
- * @version 1.0
*/
public class StylesFactory implements IStyleNames{
@SuppressWarnings("unused")
private static final Logger logger = Logger.getLogger(StylesFactory.class);
-
+
OdfOfficeStyles officeStyles;
OdfDefaultStyle defaultStyle;
StyleParagraphPropertiesElement paragraphProperties;
this.officeStyles = outputDocument.getOrCreateDocumentStyles();
init();
}
-
+
private void init() {
createDefaultStyles();
-
+
createHeadings();
-
+
}
public void createDefaultStyles(){
OdfStyleFamily.Paragraph);
setFontSize(defaultStyle, "10pt");
}
-
+
private void createHeadings(){
OdfStyle style;
-
+
style = officeStyles.newStyle(HEADING_ACCEPTED_TAXON,
OdfStyleFamily.Paragraph);
style.setStyleDisplayNameAttribute("Accepted Taxon Heading");
style.setProperty(StyleParagraphPropertiesElement.MarginBottom, "0.25cm");
setFontWeight(style, "bold");
setFontSize(style, "20pt");
-
+
style = officeStyles.newStyle(HEADING_FEATURE,
OdfStyleFamily.Paragraph);
style.setStyleDisplayNameAttribute("Feature Heading");
setFontWeight(style, "bold");
setFontSize(style, "14pt");
}
-
+
// @Deprecated // testing
// void addOfficeStyles() {
// OdfDefaultStyle defaultStyle;
// style.setProperty(OdfStyleParagraphProperties.MarginRight, "1cm");
// style.setProperty(OdfStyleParagraphProperties.TextIndent, "0.25cm");
// }
-
+
private void setFontWeight(OdfStyleBase style, String value) {
style.setProperty(StyleTextPropertiesElement.FontWeight, value);