Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
esa.mo.tools.stubgen.GeneratorDocx Maven / Gradle / Ivy
/* ----------------------------------------------------------------------------
* Copyright (C) 2013 European Space Agency
* European Space Operations Centre
* Darmstadt
* Germany
* ----------------------------------------------------------------------------
* System : CCSDS MO Service Stub Generator
* ----------------------------------------------------------------------------
* Licensed under the European Space Agency Public License, Version 2.0
* You may not use this file except in compliance with the License.
*
* Except as expressly set forth in this License, the Software is provided to
* You on an "as is" basis and without warranties of any kind, including without
* limitation merchantability, fitness for a particular purpose, absence of
* defects or errors, accuracy or non-infringement of intellectual property rights.
*
* See the License for the specific language governing permissions and
* limitations under the License.
* ----------------------------------------------------------------------------
*/
package esa.mo.tools.stubgen;
import esa.mo.tools.stubgen.docx.DocxNumberingWriter;
import esa.mo.tools.stubgen.docx.DocxBaseWriter;
import esa.mo.tools.stubgen.docx.GeneratorUtils;
import esa.mo.tools.stubgen.docx.DocxWriter;
import esa.mo.tools.stubgen.specification.CompositeField;
import esa.mo.tools.stubgen.specification.StdStrings;
import esa.mo.tools.stubgen.specification.TypeUtils;
import esa.mo.tools.stubgen.specification.TypeRef;
import esa.mo.xsd.*;
import esa.mo.xsd.EnumerationType.Item;
import esa.mo.xsd.util.XmlSpecification;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
import org.apache.batik.transcoder.TranscoderException;
import org.apache.maven.plugin.logging.Log;
/**
* Generates a MS Word compliant docx file of the service specification.
*/
public class GeneratorDocx extends GeneratorDocument {
private static final String STD_COLOUR = null;
private static final String HEADER_COLOUR = "00CCFF";
private static final String FIXED_COLOUR = "E0E0E0";
private static final int[] SERVICE_OVERVIEW_TABLE_WIDTHS = new int[]{
2250, 2801, 1382, 1185, 1382
};
private static final int[] SERVICE_COM_TYPES_TABLE_WIDTHS = new int[]{
2250, 1685, 2801, 1185, 1185
};
private static final int[] OPERATION_OVERVIEW_TABLE_WIDTHS = new int[]{
2200, 1700, 800, 4300
};
private static final int[] OPERATION_ERROR_TABLE_WIDTHS = new int[]{
1500, 1500, 2500, 3500
};
private static final int[] ERROR_TABLE_WIDTHS = new int[]{
2302, 1430, 5268
};
private static final int[] ENUM_TABLE_WIDTHS = new int[]{
2302, 2430, 4268
};
private static final int[] LIST_TABLE_WIDTHS = new int[]{
2302, 6698
};
private static final int[] COMPOSITE_TABLE_WIDTHS = new int[]{
2302, 1830, 1100, 3768
};
private boolean includeMessageFieldNames = true;
private boolean includeDiagrams = true;
private boolean oldStyle = false;
private final Log logger;
/**
* Constructor.
*
* @param logger The logger to use.
*/
public GeneratorDocx(org.apache.maven.plugin.logging.Log logger) {
super(new GeneratorConfiguration("", "", "", "",
"", "", "", "", "", "", "", ""));
this.logger = logger;
}
@Override
public String getShortName() {
return "DOCX";
}
@Override
public String getDescription() {
return "Generates a document of the service specification.";
}
@Override
public void init(String destinationFolderName, boolean generateStructures,
boolean generateCOM, Map packageBindings,
Map extraProperties) throws IOException {
super.init(destinationFolderName, generateStructures, generateCOM, packageBindings, extraProperties);
if (extraProperties.containsKey("docx.includeMessageFieldNames")) {
includeMessageFieldNames = Boolean.parseBoolean(extraProperties.get("docx.includeMessageFieldNames"));
}
if (extraProperties.containsKey("docx.includeDiagrams")) {
includeDiagrams = Boolean.parseBoolean(extraProperties.get("docx.includeDiagrams"));
}
if (extraProperties.containsKey("docx.oldStyle")) {
oldStyle = Boolean.parseBoolean(extraProperties.get("docx.oldStyle"));
}
}
@Override
public void generate(String destFolderName, XmlSpecification xml,
JAXBElement rootNode) throws IOException, JAXBException {
SpecificationType spec = xml.getSpecType();
for (AreaType area : spec.getArea()) {
String destinationFolderName = destFolderName + "/" + area.getName();
String folder = destinationFolderName + "/word";
String ext = "xml";
logger.info("Creating file " + folder + " numbering." + ext);
DocxNumberingWriter docxNumberingFile = new DocxNumberingWriter(folder, "numbering", ext);
logger.info("Creating file " + folder + " document." + ext);
DocxWriter docxServiceFile = new DocxWriter(folder, "document", ext, docxNumberingFile);
DocxBaseWriter docxDataFile = new DocxBaseWriter();
// create DOCX target area
StubUtils.createResource(destinationFolderName, "[Content_Types]", ext, " ");
StubUtils.createResource(destinationFolderName + "/_rels", "", "rels", " ");
// Original Calibri Style
//StubUtils.createResource(folder, "styles", ext, " ");
// Times New Roman Style
//StubUtils.createResource(folder, "styles", ext, "