Compare commits
9 commits
Author | SHA1 | Date | |
---|---|---|---|
72f2892d30 | |||
0bb7490ac2 | |||
ff556c19dd | |||
a6e85d367a | |||
19b17c5b58 | |||
7d03b2a02d | |||
56a44ea1fd | |||
f5bf88532d | |||
1454d68b4a |
30 changed files with 186 additions and 188 deletions
48
build.gradle
48
build.gradle
|
@ -16,40 +16,37 @@ sourceSets {
|
|||
regressionTests {
|
||||
java {
|
||||
compileClasspath += main.output + test.output
|
||||
runtimeClasspath += main.output + files('src/main/java')
|
||||
java.srcDir file('src/r_tests/java')
|
||||
runtimeClasspath += main.output + test.output + files('src/main/java')
|
||||
srcDir file('src/r_tests/java')
|
||||
}
|
||||
}
|
||||
}
|
||||
sourceCompatibility = 1.8
|
||||
configurations{
|
||||
bundledLibs
|
||||
regressionTestsCompile.extendsFrom mainCompile
|
||||
regressionTestsRuntime.extendsFrom mainRuntime
|
||||
regressionTestsRuntime.extendsFrom bundledLibs
|
||||
regressionTestsRuntime.extendsFrom compileClasspath
|
||||
regressionTestsImplementation.extendsFrom compileClasspath
|
||||
}
|
||||
dependencies{
|
||||
regressionTestsImplementation group: 'commons-io', name: 'commons-io', version: '2.8.0'
|
||||
regressionTestsImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.7.1'
|
||||
regressionTestsImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.7.1'
|
||||
regressionTestsRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
|
||||
regressionTestsImplementation 'org.junit.jupiter:junit-jupiter-engine'
|
||||
|
||||
bundledLibs 'org.libreoffice:jurt:5.3.2'
|
||||
bundledLibs 'org.libreoffice:juh:5.3.2'
|
||||
bundledLibs 'org.libreoffice:ridl:5.3.2'
|
||||
bundledLibs 'org.libreoffice:unoil:5.3.2'
|
||||
bundledLibs 'org.json:json:20190722'
|
||||
bundledLibs group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3'
|
||||
bundledLibs group: 'ch.qos.logback', name: 'logback-core', version: '1.2.3'
|
||||
bundledLibs group: 'com.miglayout', name: 'miglayout-swing', version: '5.2'
|
||||
bundledLibs group: 'org.apache.jena', name: 'jena-core', version: '3.15.0'
|
||||
bundledLibs group: 'org.apache.jena', name: 'jena-arq', version: '3.15.0'
|
||||
bundledLibs group: 'org.slf4j', name: 'slf4j-api', version: '1.7.30'
|
||||
bundledLibs group: 'com.opencsv', name: 'opencsv', version: '5.1'
|
||||
bundledLibs group: 'org.imgscalr', name: 'imgscalr-lib', version: '4.2'
|
||||
bundledLibs group: 'org.apache.commons', name: 'commons-imaging', version: '1.0-alpha2'
|
||||
compileClasspath 'org.libreoffice:jurt:5.3.2'
|
||||
compileClasspath 'org.libreoffice:juh:5.3.2'
|
||||
compileClasspath 'org.libreoffice:ridl:5.3.2'
|
||||
compileClasspath 'org.libreoffice:unoil:5.3.2'
|
||||
compileClasspath 'org.json:json:20190722'
|
||||
compileClasspath group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3'
|
||||
compileClasspath group: 'ch.qos.logback', name: 'logback-core', version: '1.2.3'
|
||||
compileClasspath group: 'com.miglayout', name: 'miglayout-swing', version: '5.2'
|
||||
compileClasspath group: 'org.apache.jena', name: 'jena-core', version: '3.15.0'
|
||||
compileClasspath group: 'org.slf4j', name: 'slf4j-api', version: '1.7.30'
|
||||
compileClasspath group: 'com.opencsv', name: 'opencsv', version: '5.1'
|
||||
compileClasspath group: 'org.imgscalr', name: 'imgscalr-lib', version: '4.2'
|
||||
compileClasspath group: 'org.apache.commons', name: 'commons-imaging', version: '1.0-alpha2'
|
||||
|
||||
configurations.compile.extendsFrom(configurations.bundledLibs)
|
||||
}
|
||||
jar {
|
||||
archiveName 'w2phtml.jar'
|
||||
|
@ -60,8 +57,9 @@ jar {
|
|||
"Class-Path" : "jasp.jar parser.jar")
|
||||
}
|
||||
|
||||
duplicatesStrategy = 'exclude'
|
||||
from {
|
||||
configurations.bundledLibs.collect { it.isDirectory() ? it : zipTree(it) }
|
||||
configurations.compileClasspath.collect { it.isDirectory() ? it : zipTree(it) }
|
||||
}
|
||||
from('src/main/java') {
|
||||
include '**/*.properties'
|
||||
|
@ -85,9 +83,10 @@ task xhtml(type: Jar) {
|
|||
"RegistrationClassName" : "pro.litvinovg.w2phtml.RegistrationHandler",
|
||||
"Class-Path" : "jasp.jar parser.jar")
|
||||
}
|
||||
duplicatesStrategy = 'exclude'
|
||||
baseName = "writer2phtml"
|
||||
from {
|
||||
configurations.bundledLibs.collect {
|
||||
configurations.compileClasspath.collect {
|
||||
exclude 'module-info.class'
|
||||
exclude '.gradle'
|
||||
exclude '**/LICENSE*'
|
||||
|
@ -108,6 +107,7 @@ task xhtml(type: Jar) {
|
|||
include 'etc/*'
|
||||
include 'com/**'
|
||||
include 'com/**/*'
|
||||
exclude '**/DEPENDENCIES'
|
||||
include 'w2phtml/pageSplitters/**/*.class'
|
||||
include 'pro/litvinovg/**/*.class'
|
||||
include 'pro/litvinovg/**/*.png'
|
||||
|
@ -130,6 +130,7 @@ task xhtml(type: Jar) {
|
|||
exclude '.gradle'
|
||||
}
|
||||
from ('src/main/java'){
|
||||
exclude '**/DEPENDENCIES'
|
||||
exclude '.gradle'
|
||||
include 'w2phtml/xhtml/**/*.properties'
|
||||
include 'w2phtml/xhtml/**/**/*.properties'
|
||||
|
@ -164,6 +165,7 @@ task oxt(type: Zip){
|
|||
from 'releasenotes.txt'
|
||||
include '*'
|
||||
}
|
||||
|
||||
task regressionTests(type: Test) {
|
||||
testClassesDirs = sourceSets.regressionTests.output.classesDirs
|
||||
classpath = sourceSets.regressionTests.runtimeClasspath
|
||||
|
|
|
@ -1 +1 @@
|
|||
version=0.9.27
|
||||
version=0.9.29
|
||||
|
|
|
@ -25,7 +25,7 @@ import org.slf4j.LoggerFactory;
|
|||
import com.sun.star.uno.XComponentContext;
|
||||
|
||||
import w2phtml.Application;
|
||||
import w2phtml.rdf.Metadata;
|
||||
import w2phtml.rdf.MetadataContainer;
|
||||
|
||||
public class ConversionExecutor {
|
||||
|
||||
|
|
|
@ -263,14 +263,14 @@ public class EpubPanel extends JPanel {
|
|||
|
||||
JCheckBox addPagination(HashMap<String, Component> configuration, UIPreferences preferences) {
|
||||
cb_Pagination_1 = new JCheckBox(Localizer.get(LABEL_PAGINATION));
|
||||
cb_Pagination_1.setSelected(Boolean.getBoolean(preferences.get(PREF_PAGINATION)));
|
||||
cb_Pagination_1.setSelected(Boolean.valueOf(preferences.get(PREF_PAGINATION)));
|
||||
configuration.put(ARG_PAGINATION, cb_Pagination_1);
|
||||
return cb_Pagination_1;
|
||||
}
|
||||
|
||||
JCheckBox addConvertToPX(HashMap<String, Component> configuration, UIPreferences preferences) {
|
||||
cb_convertToPx_1 = new JCheckBox(Localizer.get(LABEL_CONVERT_TO_PX));
|
||||
cb_convertToPx_1.setSelected(Boolean.getBoolean(preferences.get(PREF_CONVERT_TO_PX)));
|
||||
cb_convertToPx_1.setSelected(Boolean.valueOf(preferences.get(PREF_CONVERT_TO_PX)));
|
||||
configuration.put(ARG_CONVERT_TO_PX, cb_convertToPx_1);
|
||||
return cb_convertToPx_1;
|
||||
}
|
||||
|
|
|
@ -303,14 +303,14 @@ public class HTMLPanel extends JPanel{
|
|||
|
||||
JCheckBox addPagination(HashMap<String, Component> configuration, UIPreferences preferences) {
|
||||
cb_Pagination_1 = new JCheckBox(Localizer.get(LABEL_PAGINATION));
|
||||
cb_Pagination_1.setSelected(Boolean.getBoolean(preferences.get(PREF_PAGINATION)));
|
||||
cb_Pagination_1.setSelected(Boolean.valueOf(preferences.get(PREF_PAGINATION)));
|
||||
configuration.put(ARG_PAGINATION, cb_Pagination_1);
|
||||
return cb_Pagination_1;
|
||||
}
|
||||
|
||||
JCheckBox addConvertToPX(HashMap<String, Component> configuration, UIPreferences preferences) {
|
||||
cb_convertToPx_1 = new JCheckBox(Localizer.get(LABEL_CONVERT_TO_PX));
|
||||
cb_convertToPx_1.setSelected(Boolean.getBoolean(preferences.get(PREF_CONVERT_TO_PX)));
|
||||
cb_convertToPx_1.setSelected(Boolean.valueOf(preferences.get(PREF_CONVERT_TO_PX)));
|
||||
configuration.put(ARG_CONVERT_TO_PX, cb_convertToPx_1);
|
||||
return cb_convertToPx_1;
|
||||
}
|
||||
|
|
|
@ -340,14 +340,14 @@ public class RDFPanel extends JPanel {
|
|||
|
||||
JCheckBox addPagination(HashMap<String, Component> configuration, UIPreferences preferences) {
|
||||
cb_Pagination_1 = new JCheckBox(Localizer.get(LABEL_PAGINATION));
|
||||
cb_Pagination_1.setSelected(Boolean.getBoolean(preferences.get(PREF_PAGINATION)));
|
||||
cb_Pagination_1.setSelected(Boolean.valueOf(preferences.get(PREF_PAGINATION)));
|
||||
configuration.put(ARG_PAGINATION, cb_Pagination_1);
|
||||
return cb_Pagination_1;
|
||||
}
|
||||
|
||||
JCheckBox addConvertToPX(HashMap<String, Component> configuration, UIPreferences preferences) {
|
||||
cb_convertToPx_1 = new JCheckBox(Localizer.get(LABEL_CONVERT_TO_PX));
|
||||
cb_convertToPx_1.setSelected(Boolean.getBoolean(preferences.get(PREF_CONVERT_TO_PX)));
|
||||
cb_convertToPx_1.setSelected(Boolean.valueOf(preferences.get(PREF_CONVERT_TO_PX)));
|
||||
configuration.put(ARG_CONVERT_TO_PX, cb_convertToPx_1);
|
||||
return cb_convertToPx_1;
|
||||
}
|
||||
|
|
|
@ -6,13 +6,11 @@ import static w2phtml.office.XMLString.TEXT_LIST_ITEM;
|
|||
import static w2phtml.office.XMLString.TEXT_LIST;
|
||||
import static w2phtml.office.XMLString.TEXT_SOFT_PAGE_BREAK;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import pro.litvinovg.xml.Debug;
|
||||
import w2phtml.office.OfficeReader;
|
||||
|
||||
public class ListSplitter extends BasicSplitter implements ISplitter {
|
||||
|
@ -101,7 +99,7 @@ public class ListSplitter extends BasicSplitter implements ISplitter {
|
|||
while (freeNodes.getLength() > 0) {
|
||||
Node freeNode = freeNodes.item(i);
|
||||
String freeNodeName = freeNode.getNodeName();
|
||||
if (StringUtils.equals(TEXT_LIST, freeNodeName)) {
|
||||
if (TEXT_LIST.equals(freeNodeName)) {
|
||||
break;
|
||||
}
|
||||
parent.insertBefore(freeNode, list);
|
||||
|
|
|
@ -37,9 +37,9 @@ public class DocumentPart {
|
|||
private String parentPath;
|
||||
private String name = null;
|
||||
private String order = null;
|
||||
private Metadata metadata = null;
|
||||
private MetadataContainer metadata = null;
|
||||
|
||||
public DocumentPart(XhtmlDocument document,Metadata metadata) {
|
||||
public DocumentPart(XhtmlDocument document,MetadataContainer metadata) {
|
||||
this.excerptDoc = document;
|
||||
this.metadata = metadata;
|
||||
extractPath();
|
||||
|
@ -50,7 +50,7 @@ public class DocumentPart {
|
|||
extractAnnotationMetadata();
|
||||
}
|
||||
|
||||
public DocumentPart(String path, Metadata metadata) {
|
||||
public DocumentPart(String path, MetadataContainer metadata) {
|
||||
this.path = path;
|
||||
this.metadata = metadata;
|
||||
this.name = "";
|
||||
|
|
|
@ -19,28 +19,28 @@ import org.slf4j.LoggerFactory;
|
|||
import com.opencsv.CSVReaderHeaderAware;
|
||||
import com.opencsv.exceptions.CsvValidationException;
|
||||
|
||||
public class Metadata {
|
||||
public class MetadataContainer {
|
||||
private static final String SUBTITLE = "subtitle";
|
||||
private static final String FILENAME = "Filename";
|
||||
private static final String SECTION = "Section";
|
||||
private static final Logger logger = LoggerFactory.getLogger(Metadata.class);
|
||||
private static final Logger logger = LoggerFactory.getLogger(MetadataContainer.class);
|
||||
|
||||
private HashMap<String, ArrayList<Map<String, String>>> sectionsMetadata;
|
||||
|
||||
public Metadata() {
|
||||
public MetadataContainer() {
|
||||
sectionsMetadata = new HashMap<String, ArrayList<Map<String, String>>>();
|
||||
|
||||
}
|
||||
|
||||
public void read(String metadataFilePath) {
|
||||
if (metadataFilePath == null) {
|
||||
public void read(String filePath) {
|
||||
if (filePath == null) {
|
||||
return;
|
||||
}
|
||||
File file = new File(metadataFilePath);
|
||||
File file = new File(filePath);
|
||||
if (!file.exists() || !file.canRead()) {
|
||||
return;
|
||||
}
|
||||
readCSVFile(metadataFilePath);
|
||||
readCSVFile(filePath);
|
||||
}
|
||||
|
||||
private void readCSVFile(String filePath) {
|
|
@ -20,6 +20,7 @@ import org.apache.jena.rdf.model.Resource;
|
|||
import org.apache.jena.vocabulary.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import static w2phtml.util.Transliteration.*;
|
||||
|
||||
import w2phtml.xhtml.XhtmlConfig;
|
||||
import w2phtml.xhtml.XhtmlDocument;
|
||||
|
@ -27,36 +28,32 @@ import w2phtml.xhtml.XhtmlDocument;
|
|||
import org.apache.jena.rdf.model.Property;
|
||||
|
||||
|
||||
public class DocumentStructure {
|
||||
public class RDFDocument {
|
||||
|
||||
private static final String FORMAT_RDF = "RDF/XML-ABBREV";
|
||||
private static final String AFFILIATED_ORGANIZATION_POSTAL_CODE = "affiliated organization postal code";
|
||||
|
||||
private static final String AFFILIATED_ORGANIZATION_ADDRESS = "affiliated organization address";
|
||||
|
||||
private static final String AFFILIATED_ORGANIZATION_OFFICIAL_NAME = "affiliated organization official name";
|
||||
|
||||
private static final String AFFILIATED_ORGANIZATION_NAME = "affiliated organization name";
|
||||
|
||||
private static final String AUTHOR_INITIALS = "author initials";
|
||||
|
||||
private static final String AUTHOR_EMAIL = "author email";
|
||||
|
||||
private static final String AUTHOR_FAMILY = "author family";
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(DocumentStructure.class);
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(RDFDocument.class);
|
||||
private static final String AUTHOR_GIVEN_NAME = "author given name";
|
||||
private static final String MODIFICATION_TIME = "modificationTime";
|
||||
private static final String HTML_EXCERPT_PROPERTY = "htmlExcerpt";
|
||||
private static final String TOCITEM = "TOCItem";
|
||||
private static final String TOC_ITEM = "TOCItem";
|
||||
private static final String TS = "https://litvinovg.pro/text_structures#";
|
||||
private static final String POINTS_TO = TS + "pointsTo";
|
||||
private static final String ITEM_NUMBER = TS + "itemNumber";
|
||||
private static final String HAS_TOC_ITEM = TS + "hasTOCItem";
|
||||
private static final String HAS_TEXT = TS + "hasText";
|
||||
//private static final String PARSERNAME = "w2phtml";
|
||||
private static final String TEXT_EXCERPT = "textExcerpt";
|
||||
private static final String TOC_LEVEL = "TOCLevel";
|
||||
private static final String TABLE_OF_CONTENTS = "TOC";
|
||||
private static final String PARTICIPANT = "publicationParticipant";
|
||||
private static final String ORGANIZATION = "organization";
|
||||
|
||||
private static final String PUBLICATION = "publication";
|
||||
private static final String BOOK = "book";
|
||||
private static final String JOURNAL = "journal";
|
||||
|
@ -81,10 +78,10 @@ public class DocumentStructure {
|
|||
|
||||
private HashMap<String, Resource> tocLevels;
|
||||
private HashMap<String, DocumentPart> inputParts;
|
||||
private Metadata metadata;
|
||||
private MetadataContainer metadata;
|
||||
private Date currentTime;
|
||||
|
||||
public DocumentStructure(Vector<XhtmlDocument> files,String fileName, XhtmlConfig config,Metadata metadata) {
|
||||
public RDFDocument(Vector<XhtmlDocument> files,String fileName, XhtmlConfig config, MetadataContainer metadata) {
|
||||
this.tocLevels = new HashMap<String, Resource>();
|
||||
this.inputParts = new HashMap<String, DocumentPart>();
|
||||
this.m = ModelFactory.createOntologyModel();
|
||||
|
@ -94,11 +91,10 @@ public class DocumentStructure {
|
|||
this.tocClass = textOntology.createClass(TS + TABLE_OF_CONTENTS);
|
||||
this.organizationClass = textOntology.createClass(TS + ORGANIZATION);
|
||||
this.participantClass = textOntology.createClass(TS + PARTICIPANT);
|
||||
this.itemClass = textOntology.createClass(TS + TOCITEM);
|
||||
setDocID(fileName);
|
||||
this.itemClass = textOntology.createClass(TS + TOC_ITEM);
|
||||
formatDocID(fileName);
|
||||
this.currentTime = Calendar.getInstance().getTime();
|
||||
String publicationType = config.getRDFType();
|
||||
setPublicationType(publicationType);
|
||||
setPublicationType(config.getRDFType());
|
||||
this.documentClass = textOntology.createClass(TS + documentType);
|
||||
this.excerptClass = textOntology.createClass(TS + excerptType);
|
||||
for(int i = 0 ; i< files.size();i++) {
|
||||
|
@ -108,6 +104,12 @@ public class DocumentStructure {
|
|||
addPart(part);
|
||||
}
|
||||
addEmptyParts();
|
||||
createElements();
|
||||
createTOCItems();
|
||||
}
|
||||
|
||||
public void printModel(OutputStream os) {
|
||||
m.write(os,FORMAT_RDF);
|
||||
}
|
||||
|
||||
private void setPublicationType(String publicationType) {
|
||||
|
@ -156,30 +158,6 @@ public class DocumentStructure {
|
|||
return emptyPath.toString();
|
||||
}
|
||||
|
||||
public void printModel(String fileName) {
|
||||
File outFile = new File(fileName + ".rdf");
|
||||
FileWriter fw = null;
|
||||
try {
|
||||
outFile.createNewFile();
|
||||
fw = new FileWriter(outFile);
|
||||
m.write(fw,"RDF/XML-ABBREV");
|
||||
|
||||
} catch (IOException e) {
|
||||
System.out.println("File couldn't be created");
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
fw.close();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
public void printModel(OutputStream os) {
|
||||
m.write(os,"RDF/XML-ABBREV");
|
||||
}
|
||||
|
||||
private void addPart(DocumentPart docExcerpt) {
|
||||
inputParts.put(docExcerpt.getPath(), docExcerpt);
|
||||
}
|
||||
|
@ -273,13 +251,13 @@ public class DocumentStructure {
|
|||
Property initialsProperty = m.createProperty(TS + "participantInitials");
|
||||
participant.addProperty( initialsProperty, authorInitials.trim());
|
||||
}
|
||||
attachOrganization(participant, map, order, postfix);
|
||||
addOrganization(participant, map, order, postfix);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void attachOrganization(Resource participant, Map<String, String> map, String order, String postfix) {
|
||||
private void addOrganization(Resource participant, Map<String, String> map, String order, String postfix) {
|
||||
String orgName = map.get(AFFILIATED_ORGANIZATION_NAME + postfix);
|
||||
if (orgName == null) {
|
||||
System.out.println(orgName + " not found");
|
||||
|
@ -402,19 +380,18 @@ public class DocumentStructure {
|
|||
return true;
|
||||
}
|
||||
private void createTOCItem(DocumentPart docPart) {
|
||||
String tocItemName = TS + TOCITEM + "/" + docID + docPart.getSafePath();
|
||||
Resource tocItem = m.createIndividual(tocItemName,itemClass);
|
||||
String tocItemUri = TS + TOC_ITEM + "/" + docID + docPart.getSafePath();
|
||||
Resource tocItem = m.createIndividual(tocItemUri,itemClass);
|
||||
tocItem.addProperty( RDFS.label, docPart.getName());
|
||||
Property pointsTo = m.createProperty(TS + "pointsTo");
|
||||
Property itemNumber = m.createProperty(TS + "itemNumber");
|
||||
Property hasTOCItem = m.createProperty(TS + "hasTOCItem");
|
||||
Property pointsTo = m.createProperty(POINTS_TO);
|
||||
Property itemNumber = m.createProperty(ITEM_NUMBER);
|
||||
Property hasTOCItem = m.createProperty(HAS_TOC_ITEM);
|
||||
tocItem.addLiteral(itemNumber, docPart.getNumber());
|
||||
m.add(tocItem, pointsTo, tocLevels.get(docPart.getPath()));
|
||||
if (!docPart.getPath().isEmpty()) {
|
||||
Resource parent = tocLevels.get(docPart.getParentPath());
|
||||
m.add(parent, hasTOCItem, tocItem);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void attachExcerpt(DocumentPart docPart, Resource element) {
|
||||
|
@ -426,7 +403,7 @@ public class DocumentStructure {
|
|||
}
|
||||
Resource excerpt = createExcerpt(docPart);
|
||||
excerpt.addProperty( RDFS.label, docPart.getName());
|
||||
Property hasText = m.createProperty(TS + "hasText");
|
||||
Property hasText = m.createProperty(HAS_TEXT);
|
||||
element.addProperty(hasText, excerpt);
|
||||
if (!docPart.isMasterPart()) {
|
||||
addMetadataProperties(excerpt, docPart);
|
||||
|
@ -435,11 +412,6 @@ public class DocumentStructure {
|
|||
}
|
||||
}
|
||||
|
||||
public void createTree() {
|
||||
createElements();
|
||||
createTOCItems();
|
||||
}
|
||||
|
||||
private void createTOCItems() {
|
||||
Set<String> paths = inputParts.keySet();
|
||||
for (String path : paths) {
|
||||
|
@ -462,48 +434,10 @@ public class DocumentStructure {
|
|||
}
|
||||
}
|
||||
|
||||
private void setDocID(String fileName) {
|
||||
private void formatDocID(String fileName) {
|
||||
String identifier = fileName.replaceAll("\\s+", "_");
|
||||
identifier = transliterateToEn(identifier);
|
||||
identifier = identifier.replaceAll("[^a-zA-Z0-9_.-]", "");
|
||||
this.docID = identifier;
|
||||
}
|
||||
|
||||
private String transliterateToEn(String fileName) {
|
||||
return fileName
|
||||
.replaceAll("[аА]", "a")
|
||||
.replaceAll("[бБ]", "b")
|
||||
.replaceAll("[вВ]", "v")
|
||||
.replaceAll("[гГ]", "g")
|
||||
.replaceAll("[дД]", "d")
|
||||
.replaceAll("[еЕ]", "e")
|
||||
.replaceAll("[ёЁ]", "e")
|
||||
.replaceAll("[жЖ]", "zh")
|
||||
.replaceAll("[зЗ]", "z")
|
||||
.replaceAll("[иИ]", "i")
|
||||
.replaceAll("[йЙ]", "y")
|
||||
.replaceAll("[кК]", "k")
|
||||
.replaceAll("[лЛ]", "l")
|
||||
.replaceAll("[мМ]", "m")
|
||||
.replaceAll("[нН]", "n")
|
||||
.replaceAll("[оО]", "o")
|
||||
.replaceAll("[пП]", "p")
|
||||
.replaceAll("[рР]", "r")
|
||||
.replaceAll("[сС]", "s")
|
||||
.replaceAll("[тТ]", "t")
|
||||
.replaceAll("[уУ]", "u")
|
||||
.replaceAll("[фФ]", "f")
|
||||
.replaceAll("[хХ]", "kh")
|
||||
.replaceAll("[цЦ]", "ts")
|
||||
.replaceAll("[чЧ]", "ch")
|
||||
.replaceAll("[шШ]", "sh")
|
||||
.replaceAll("[щЩ]", "sch")
|
||||
.replaceAll("[ъЪ]", "")
|
||||
.replaceAll("[ыЫ]", "y")
|
||||
.replaceAll("[ьЬ]", "")
|
||||
.replaceAll("[эЭ]", "e")
|
||||
.replaceAll("[юЮ]", "yu")
|
||||
.replaceAll("[яЯ]", "ya");
|
||||
}
|
||||
|
||||
}
|
|
@ -17,17 +17,15 @@ public class RDFDocumentResult implements OutputFile {
|
|||
private ConverterResult xhtmlResult;
|
||||
private String sFileName;
|
||||
private XhtmlConfig config;
|
||||
private DocumentStructure rdfStructure = null;
|
||||
private RDFDocument rdfDocument = null;
|
||||
|
||||
|
||||
public RDFDocumentResult(Vector<XhtmlDocument> outFiles, String fileName, XhtmlConfig config) {
|
||||
this.sFileName = Misc.removeExtension(fileName);
|
||||
this.config = config;
|
||||
Metadata metadata = new Metadata();
|
||||
MetadataContainer metadata = new MetadataContainer();
|
||||
metadata.read(config.getCSVMetadataFile());
|
||||
rdfStructure = new DocumentStructure(outFiles,sFileName,config,metadata);
|
||||
rdfStructure.createTree();
|
||||
|
||||
rdfDocument = new RDFDocument(outFiles,sFileName,config,metadata);
|
||||
}
|
||||
|
||||
|
||||
|
@ -48,7 +46,7 @@ public class RDFDocumentResult implements OutputFile {
|
|||
}
|
||||
|
||||
@Override public void write(OutputStream os) throws IOException {
|
||||
rdfStructure.printModel(os);
|
||||
rdfDocument.printModel(os);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>The package writer2latex.util</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<p>Some general utility classes.</p>
|
||||
</body>
|
||||
</html>
|
41
src/main/java/w2phtml/util/Transliteration.java
Normal file
41
src/main/java/w2phtml/util/Transliteration.java
Normal file
|
@ -0,0 +1,41 @@
|
|||
package w2phtml.util;
|
||||
|
||||
public class Transliteration {
|
||||
|
||||
public static String transliterateToEn(String fileName) {
|
||||
return fileName
|
||||
.replaceAll("[аА]", "a")
|
||||
.replaceAll("[бБ]", "b")
|
||||
.replaceAll("[вВ]", "v")
|
||||
.replaceAll("[гГ]", "g")
|
||||
.replaceAll("[дД]", "d")
|
||||
.replaceAll("[еЕ]", "e")
|
||||
.replaceAll("[ёЁ]", "e")
|
||||
.replaceAll("[жЖ]", "zh")
|
||||
.replaceAll("[зЗ]", "z")
|
||||
.replaceAll("[иИ]", "i")
|
||||
.replaceAll("[йЙ]", "y")
|
||||
.replaceAll("[кК]", "k")
|
||||
.replaceAll("[лЛ]", "l")
|
||||
.replaceAll("[мМ]", "m")
|
||||
.replaceAll("[нН]", "n")
|
||||
.replaceAll("[оО]", "o")
|
||||
.replaceAll("[пП]", "p")
|
||||
.replaceAll("[рР]", "r")
|
||||
.replaceAll("[сС]", "s")
|
||||
.replaceAll("[тТ]", "t")
|
||||
.replaceAll("[уУ]", "u")
|
||||
.replaceAll("[фФ]", "f")
|
||||
.replaceAll("[хХ]", "kh")
|
||||
.replaceAll("[цЦ]", "ts")
|
||||
.replaceAll("[чЧ]", "ch")
|
||||
.replaceAll("[шШ]", "sh")
|
||||
.replaceAll("[щЩ]", "sch")
|
||||
.replaceAll("[ъЪ]", "")
|
||||
.replaceAll("[ыЫ]", "y")
|
||||
.replaceAll("[ьЬ]", "")
|
||||
.replaceAll("[эЭ]", "e")
|
||||
.replaceAll("[юЮ]", "yu")
|
||||
.replaceAll("[яЯ]", "ya");
|
||||
}
|
||||
}
|
|
@ -6,7 +6,6 @@ import java.util.List;
|
|||
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
@ -25,6 +24,6 @@ public class PageBreaksBeforeHeading {
|
|||
w2phtml.Application.main(arguments.toArray(new String[0]));
|
||||
File result = new File("./testdocuments/output/heading_with_page_break_before.html");
|
||||
File model = new File("./testdocuments/model/heading_with_page_break_before.html");
|
||||
assertTrue( FileUtils.contentEquals(result, model),"The files differ!");
|
||||
assertTrue( TestFiles.equals(result, model),"The files differ!");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package w2phtml.regressionTests;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class TestFiles {
|
||||
public static boolean equals(File file1, File file2) {
|
||||
byte[] f1;
|
||||
byte[] f2;
|
||||
try {
|
||||
f1 = Files.readAllBytes(file1.toPath());
|
||||
f2 = Files.readAllBytes(file2.toPath());
|
||||
return Arrays.equals(f1, f2);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -5,6 +5,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
|||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import w2phtml.regressionTests.TestFiles;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
|
@ -26,6 +27,6 @@ public class BreakAfterTest {
|
|||
w2phtml.Application.main(arguments.toArray(new String[0]));
|
||||
File result = new File("./testdocuments/output/" + name + ".html");
|
||||
File model = new File("./testdocuments/model/" + name + ".html");
|
||||
assertTrue(FileUtils.contentEquals(result, model), "The files differ!");
|
||||
assertTrue(TestFiles.equals(result, model), "The files differ!");
|
||||
}
|
||||
}
|
|
@ -6,10 +6,11 @@ import java.io.File;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import w2phtml.regressionTests.TestFiles;
|
||||
|
||||
public class BulletList {
|
||||
@Test
|
||||
@DisplayName("List on multiple pages")
|
||||
|
@ -26,6 +27,6 @@ public class BulletList {
|
|||
w2phtml.Application.main(arguments.toArray(new String[0]));
|
||||
File result = new File("./testdocuments/output/" + name + ".html");
|
||||
File model = new File("./testdocuments/model/" + name + ".html");
|
||||
assertTrue(FileUtils.contentEquals(result, model), "The files differ!");
|
||||
assertTrue(TestFiles.equals(result, model), "The files differ!");
|
||||
}
|
||||
}
|
|
@ -6,10 +6,11 @@ import java.io.File;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import w2phtml.regressionTests.TestFiles;
|
||||
|
||||
public class GreenstoneHeadings {
|
||||
@Test
|
||||
@DisplayName("Greenstone3 tags headings")
|
||||
|
@ -25,6 +26,6 @@ public class GreenstoneHeadings {
|
|||
w2phtml.Application.main(arguments.toArray(new String[0]));
|
||||
File result = new File("./testdocuments/output/" + testName + ".html");
|
||||
File model = new File("./testdocuments/model/" + testName + ".html");
|
||||
assertTrue(FileUtils.contentEquals(result, model), "The files differ!");
|
||||
assertTrue(TestFiles.equals(result, model), "The files differ!");
|
||||
}
|
||||
}
|
|
@ -6,10 +6,11 @@ import java.io.File;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import w2phtml.regressionTests.TestFiles;
|
||||
|
||||
public class HardPageBreaksInLists {
|
||||
@Test
|
||||
@DisplayName("Hard page breaks inside list")
|
||||
|
@ -26,6 +27,6 @@ public class HardPageBreaksInLists {
|
|||
w2phtml.Application.main(arguments.toArray(new String[0]));
|
||||
File result = new File("./testdocuments/output/" + name + ".html");
|
||||
File model = new File("./testdocuments/model/" + name + ".html");
|
||||
assertTrue(FileUtils.contentEquals(result, model), "The files differ!");
|
||||
assertTrue(TestFiles.equals(result, model), "The files differ!");
|
||||
}
|
||||
}
|
|
@ -6,10 +6,11 @@ import java.io.File;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import w2phtml.regressionTests.TestFiles;
|
||||
|
||||
public class HeadingWithSections {
|
||||
@Test
|
||||
@DisplayName("Heading with sections")
|
||||
|
@ -24,6 +25,6 @@ public class HeadingWithSections {
|
|||
w2phtml.Application.main(arguments.toArray(new String[0]));
|
||||
File result = new File("./testdocuments/output/"+testName+".html");
|
||||
File model = new File("./testdocuments/model/"+testName+".html");
|
||||
assertTrue( FileUtils.contentEquals(result, model),"The files differ!");
|
||||
assertTrue(TestFiles.equals(result, model),"The files differ!");
|
||||
}
|
||||
}
|
|
@ -6,10 +6,11 @@ import java.io.File;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import w2phtml.regressionTests.TestFiles;
|
||||
|
||||
public class ImageAfterSection {
|
||||
@Test
|
||||
@DisplayName("image after section")
|
||||
|
@ -24,6 +25,6 @@ public class ImageAfterSection {
|
|||
w2phtml.Application.main(arguments.toArray(new String[0]));
|
||||
File result = new File("./testdocuments/output/" + testName + ".html");
|
||||
File model = new File("./testdocuments/model/" + testName + ".html");
|
||||
assertTrue(FileUtils.contentEquals(result, model), "The files differ!");
|
||||
assertTrue(TestFiles.equals(result, model), "The files differ!");
|
||||
}
|
||||
}
|
|
@ -6,10 +6,11 @@ import java.io.File;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import w2phtml.regressionTests.TestFiles;
|
||||
|
||||
public class ListAfterText {
|
||||
@Test
|
||||
@DisplayName("List after soft page break")
|
||||
|
@ -26,6 +27,6 @@ public class ListAfterText {
|
|||
w2phtml.Application.main(arguments.toArray(new String[0]));
|
||||
File result = new File("./testdocuments/output/" + name + ".html");
|
||||
File model = new File("./testdocuments/model/" + name + ".html");
|
||||
assertTrue(FileUtils.contentEquals(result, model), "The files differ!");
|
||||
assertTrue(TestFiles.equals(result, model), "The files differ!");
|
||||
}
|
||||
}
|
|
@ -6,10 +6,11 @@ import java.io.File;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import w2phtml.regressionTests.TestFiles;
|
||||
|
||||
public class ListInSection {
|
||||
@Test
|
||||
@DisplayName("List in section")
|
||||
|
@ -26,6 +27,6 @@ public class ListInSection {
|
|||
w2phtml.Application.main(arguments.toArray(new String[0]));
|
||||
File result = new File("./testdocuments/output/" + name + ".html");
|
||||
File model = new File("./testdocuments/model/" + name + ".html");
|
||||
assertTrue(FileUtils.contentEquals(result, model), "The files differ!");
|
||||
assertTrue(TestFiles.equals(result, model), "The files differ!");
|
||||
}
|
||||
}
|
|
@ -6,10 +6,11 @@ import java.io.File;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import w2phtml.regressionTests.TestFiles;
|
||||
|
||||
public class ListInTable {
|
||||
@Test
|
||||
@DisplayName("list in table")
|
||||
|
@ -24,6 +25,6 @@ public class ListInTable {
|
|||
w2phtml.Application.main(arguments.toArray(new String[0]));
|
||||
File result = new File("./testdocuments/output/" + testName + ".html");
|
||||
File model = new File("./testdocuments/model/" + testName + ".html");
|
||||
assertTrue(FileUtils.contentEquals(result, model), "The files differ!");
|
||||
assertTrue(TestFiles.equals(result, model), "The files differ!");
|
||||
}
|
||||
}
|
|
@ -6,10 +6,11 @@ import java.io.File;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import w2phtml.regressionTests.TestFiles;
|
||||
|
||||
public class ListTableSection {
|
||||
@Test
|
||||
@DisplayName("list in table in section")
|
||||
|
@ -24,6 +25,6 @@ public class ListTableSection {
|
|||
w2phtml.Application.main(arguments.toArray(new String[0]));
|
||||
File result = new File("./testdocuments/output/" + testName + ".html");
|
||||
File model = new File("./testdocuments/model/" + testName + ".html");
|
||||
assertTrue(FileUtils.contentEquals(result, model), "The files differ!");
|
||||
assertTrue(TestFiles.equals(result, model), "The files differ!");
|
||||
}
|
||||
}
|
|
@ -6,10 +6,11 @@ import java.io.File;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import w2phtml.regressionTests.TestFiles;
|
||||
|
||||
public class PageStartWith10 {
|
||||
@Test
|
||||
@DisplayName("start page from 10 in section")
|
||||
|
@ -24,6 +25,6 @@ public class PageStartWith10 {
|
|||
w2phtml.Application.main(arguments.toArray(new String[0]));
|
||||
File result = new File("./testdocuments/output/" + testName + ".html");
|
||||
File model = new File("./testdocuments/model/" + testName + ".html");
|
||||
assertTrue(FileUtils.contentEquals(result, model), "The files differ!");
|
||||
assertTrue(TestFiles.equals(result, model), "The files differ!");
|
||||
}
|
||||
}
|
|
@ -6,10 +6,11 @@ import java.io.File;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import w2phtml.regressionTests.TestFiles;
|
||||
|
||||
public class PageStartWith10InSection {
|
||||
@Test
|
||||
@DisplayName("start page from 10")
|
||||
|
@ -24,6 +25,6 @@ public class PageStartWith10InSection {
|
|||
w2phtml.Application.main(arguments.toArray(new String[0]));
|
||||
File result = new File("./testdocuments/output/" + testName + ".html");
|
||||
File model = new File("./testdocuments/model/" + testName + ".html");
|
||||
assertTrue(FileUtils.contentEquals(result, model), "The files differ!");
|
||||
assertTrue(TestFiles.equals(result, model), "The files differ!");
|
||||
}
|
||||
}
|
|
@ -6,10 +6,11 @@ import java.io.File;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import w2phtml.regressionTests.TestFiles;
|
||||
|
||||
public class SoftPageBreakInListTest {
|
||||
@Test
|
||||
@DisplayName("Soft page break in list")
|
||||
|
@ -26,6 +27,6 @@ public class SoftPageBreakInListTest {
|
|||
w2phtml.Application.main(arguments.toArray(new String[0]));
|
||||
File result = new File("./testdocuments/output/" + name + ".html");
|
||||
File model = new File("./testdocuments/model/" + name + ".html");
|
||||
assertTrue(FileUtils.contentEquals(result, model), "The files differ!");
|
||||
assertTrue(TestFiles.equals(result, model), "The files differ!");
|
||||
}
|
||||
}
|
|
@ -6,10 +6,11 @@ import java.io.File;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import w2phtml.regressionTests.TestFiles;
|
||||
|
||||
public class SplitFilesAlignToPages {
|
||||
@Test
|
||||
@DisplayName("Split files align to pages")
|
||||
|
@ -28,8 +29,8 @@ public class SplitFilesAlignToPages {
|
|||
File result2 = new File("./testdocuments/output/" + testName + "1.html");
|
||||
File model1 = new File("./testdocuments/model/" + testName + ".html");
|
||||
File model2 = new File("./testdocuments/model/" + testName + "1.html");
|
||||
assertTrue(FileUtils.contentEquals(result1, model1), "The files differ!");
|
||||
assertTrue(FileUtils.contentEquals(result2, model2), "The files differ!");
|
||||
assertTrue(TestFiles.equals(result1, model1), "The files differ!");
|
||||
assertTrue(TestFiles.equals(result2, model2), "The files differ!");
|
||||
|
||||
}
|
||||
}
|
|
@ -2,9 +2,9 @@
|
|||
<description xmlns="http://openoffice.org/extensions/update/2006"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<identifier value="pro.litvinovg.writer2paginatedhtml"/>
|
||||
<version value="0.9.28" />
|
||||
<version value="0.9.29" />
|
||||
<update-download>
|
||||
<src xlink:href="https://dev.litvinovg.pro/litvinovg/w2phtml/uploads/caa40399eb4e4446b275ca669cd64dda/w2phtml.oxt" />
|
||||
<src xlink:href="https://dev.litvinovg.pro/litvinovg/w2phtml/uploads/649b20bfbf3225a7c11ee1a01fdf6cf9/w2phtml.oxt" />
|
||||
</update-download>
|
||||
<release-notes>
|
||||
<src xlink:href="https://dev.litvinovg.pro/litvinovg/w2phtml/-/raw/master/src/main/oxt/releasenotes.txt" lang="en" />
|
||||
|
|
Loading…
Add table
Reference in a new issue