Compare commits

..

No commits in common. "master" and "0.9.21" have entirely different histories.

82 changed files with 1614 additions and 2291 deletions

View file

@ -1,4 +1,4 @@
image: gradle:jdk11-alpine image: gradle:alpine
stages: stages:
- build - build

View file

@ -2,21 +2,22 @@
<projectDescription> <projectDescription>
<name>w2phtml</name> <name>w2phtml</name>
<comment></comment> <comment></comment>
<projects/> <projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures> <natures>
<nature>org.eclipse.jdt.core.javanature</nature> <nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature> <nature>org.eclipse.buildship.core.gradleprojectnature</nature>
</natures> </natures>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments/>
</buildCommand>
<buildCommand>
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
<arguments/>
</buildCommand>
</buildSpec>
<linkedResources/>
<filteredResources/>
</projectDescription> </projectDescription>

View file

@ -16,37 +16,40 @@ sourceSets {
regressionTests { regressionTests {
java { java {
compileClasspath += main.output + test.output compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output + files('src/main/java') runtimeClasspath += main.output + files('src/main/java')
srcDir file('src/r_tests/java') java.srcDir file('src/r_tests/java')
} }
} }
} }
sourceCompatibility = 1.8 sourceCompatibility = 1.8
configurations{ configurations{
bundledLibs
regressionTestsCompile.extendsFrom mainCompile regressionTestsCompile.extendsFrom mainCompile
regressionTestsRuntime.extendsFrom mainRuntime regressionTestsRuntime.extendsFrom mainRuntime
regressionTestsRuntime.extendsFrom compileClasspath regressionTestsRuntime.extendsFrom bundledLibs
regressionTestsImplementation.extendsFrom compileClasspath
} }
dependencies{ 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-api', version: '5.7.1'
regressionTestsImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.7.1' regressionTestsImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.7.1'
regressionTestsImplementation 'org.junit.jupiter:junit-jupiter-engine' regressionTestsRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
compileClasspath 'org.libreoffice:jurt:5.3.2' bundledLibs 'org.libreoffice:jurt:5.3.2'
compileClasspath 'org.libreoffice:juh:5.3.2' bundledLibs 'org.libreoffice:juh:5.3.2'
compileClasspath 'org.libreoffice:ridl:5.3.2' bundledLibs 'org.libreoffice:ridl:5.3.2'
compileClasspath 'org.libreoffice:unoil:5.3.2' bundledLibs 'org.libreoffice:unoil:5.3.2'
compileClasspath 'org.json:json:20190722' bundledLibs 'org.json:json:20190722'
compileClasspath group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3' bundledLibs group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3'
compileClasspath group: 'ch.qos.logback', name: 'logback-core', version: '1.2.3' bundledLibs group: 'ch.qos.logback', name: 'logback-core', version: '1.2.3'
compileClasspath group: 'com.miglayout', name: 'miglayout-swing', version: '5.2' bundledLibs group: 'com.miglayout', name: 'miglayout-swing', version: '5.2'
compileClasspath group: 'org.apache.jena', name: 'jena-core', version: '3.15.0' bundledLibs group: 'org.apache.jena', name: 'jena-core', version: '3.15.0'
compileClasspath group: 'org.slf4j', name: 'slf4j-api', version: '1.7.30' bundledLibs group: 'org.apache.jena', name: 'jena-arq', version: '3.15.0'
compileClasspath group: 'com.opencsv', name: 'opencsv', version: '5.1' bundledLibs group: 'org.slf4j', name: 'slf4j-api', version: '1.7.30'
compileClasspath group: 'org.imgscalr', name: 'imgscalr-lib', version: '4.2' bundledLibs group: 'com.opencsv', name: 'opencsv', version: '5.1'
compileClasspath group: 'org.apache.commons', name: 'commons-imaging', version: '1.0-alpha2' bundledLibs group: 'org.imgscalr', name: 'imgscalr-lib', version: '4.2'
bundledLibs group: 'org.apache.commons', name: 'commons-imaging', version: '1.0-alpha2'
configurations.compile.extendsFrom(configurations.bundledLibs)
} }
jar { jar {
archiveName 'w2phtml.jar' archiveName 'w2phtml.jar'
@ -57,9 +60,8 @@ jar {
"Class-Path" : "jasp.jar parser.jar") "Class-Path" : "jasp.jar parser.jar")
} }
duplicatesStrategy = 'exclude'
from { from {
configurations.compileClasspath.collect { it.isDirectory() ? it : zipTree(it) } configurations.bundledLibs.collect { it.isDirectory() ? it : zipTree(it) }
} }
from('src/main/java') { from('src/main/java') {
include '**/*.properties' include '**/*.properties'
@ -83,10 +85,9 @@ task xhtml(type: Jar) {
"RegistrationClassName" : "pro.litvinovg.w2phtml.RegistrationHandler", "RegistrationClassName" : "pro.litvinovg.w2phtml.RegistrationHandler",
"Class-Path" : "jasp.jar parser.jar") "Class-Path" : "jasp.jar parser.jar")
} }
duplicatesStrategy = 'exclude'
baseName = "writer2phtml" baseName = "writer2phtml"
from { from {
configurations.compileClasspath.collect { configurations.bundledLibs.collect {
exclude 'module-info.class' exclude 'module-info.class'
exclude '.gradle' exclude '.gradle'
exclude '**/LICENSE*' exclude '**/LICENSE*'
@ -107,7 +108,6 @@ task xhtml(type: Jar) {
include 'etc/*' include 'etc/*'
include 'com/**' include 'com/**'
include 'com/**/*' include 'com/**/*'
exclude '**/DEPENDENCIES'
include 'w2phtml/pageSplitters/**/*.class' include 'w2phtml/pageSplitters/**/*.class'
include 'pro/litvinovg/**/*.class' include 'pro/litvinovg/**/*.class'
include 'pro/litvinovg/**/*.png' include 'pro/litvinovg/**/*.png'
@ -130,7 +130,6 @@ task xhtml(type: Jar) {
exclude '.gradle' exclude '.gradle'
} }
from ('src/main/java'){ from ('src/main/java'){
exclude '**/DEPENDENCIES'
exclude '.gradle' exclude '.gradle'
include 'w2phtml/xhtml/**/*.properties' include 'w2phtml/xhtml/**/*.properties'
include 'w2phtml/xhtml/**/**/*.properties' include 'w2phtml/xhtml/**/**/*.properties'
@ -162,10 +161,10 @@ task oxt(type: Zip){
from ('build/libs/writer2phtml.jar'){ from ('build/libs/writer2phtml.jar'){
include '*' include '*'
} }
from 'idl/writer2paginatedhtml.rdb'
from 'releasenotes.txt' from 'releasenotes.txt'
include '*' include '*'
} }
task regressionTests(type: Test) { task regressionTests(type: Test) {
testClassesDirs = sourceSets.regressionTests.output.classesDirs testClassesDirs = sourceSets.regressionTests.output.classesDirs
classpath = sourceSets.regressionTests.runtimeClasspath classpath = sourceSets.regressionTests.runtimeClasspath

View file

@ -1 +1 @@
version=0.9.29 version=0.9.20

52
idl/XBatchConverter.idl Normal file
View file

@ -0,0 +1,52 @@
#ifndef __org_openoffice_da_writer2xhtml_XBatchConverter_idl__
#define __org_openoffice_da_writer2xhtml_XBatchConverter_idl__
#include <com/sun/star/uno/XInterface.idl>
#include <com/sun/star/beans/PropertyValue.idl>
module org { module openoffice { module da { module writer2xhtml {
// This interface is an IDL version of the java interface (writer2latex.api.BatchHandler)
interface XBatchHandler : com::sun::star::uno::XInterface
{
// method org::openoffice::da::writer2xhtml::XBatchHandler::startConversion
void startConversion ();
// method org::openoffice::da::writer2xhtml::XBatchHandler::endConversion
void endConversion ();
// method org::openoffice::da::writer2xhtml::XBatchHandler::startDirectory
void startDirectory ( [in] string sName );
// method org::openoffice::da::writer2xhtml::XBatchHandler::endDirectory
void endDirectory ( [in] string sName, [in] boolean bSuccess );
// method org::openoffice::da::writer2xhtml::XBatchHandler::startFile
void startFile ( [in] string sName );
// method org::openoffice::da::writer2xhtml::XBatchHandler::endFile
void endFile ( [in] string sName, [in] boolean bSuccess );
// method org::openoffice::da::writer2xhtml::XBatchHandler::cancel
boolean cancel ();
};
// This interface is an IDL version of the java interface (writer2latex.api.BatchConverter)
interface XBatchConverter : com::sun::star::uno::XInterface
{
// method org::openoffice::da::writer2xhtml::XBatchConverter::convert
void convert ( [in] string sSourceURL,
[in] string sTargetURL,
[in] sequence< com::sun::star::beans::PropertyValue > lArguments,
[in] XBatchHandler handler );
} ;
}; }; }; };
#endif

View file

@ -0,0 +1,12 @@
#ifndef __org_libreoffice_example_writer2latex_idl__
#define __org_libreoffice_example_writer2latex_idl__
#include <org/libreoffice/example/XWriter2latex.idl>
module org { module libreoffice { module example {
service Writer2latex : org::libreoffice::example::XWriter2latex {
};
}; }; };
#endif

View file

@ -0,0 +1,11 @@
#ifndef __org_libreoffice_example_xwriter2latex_idl__
#define __org_libreoffice_example_xwriter2latex_idl__
module org { module libreoffice { module example {
interface XWriter2latex {
};
}; }; };
#endif

View file

@ -0,0 +1,13 @@
package org.libreoffice.example;
/**
* org/libreoffice/example/XWriter2latex.java .
* Generated by the IDL-to-Java compiler (portable), version "3.2"
* from XWriter2latex.idl
* Friday, 7 July 2017 12:51:34 o'clock MSK
*/
public interface XWriter2latex extends XWriter2latexOperations, org.omg.CORBA.Object, org.omg.CORBA.portable.IDLEntity
{
} // interface XWriter2latex

View file

@ -0,0 +1,85 @@
package org.libreoffice.example;
/**
* org/libreoffice/example/XWriter2latexHelper.java .
* Generated by the IDL-to-Java compiler (portable), version "3.2"
* from XWriter2latex.idl
* Friday, 7 July 2017 12:51:34 o'clock MSK
*/
abstract public class XWriter2latexHelper
{
private static String _id = "IDL:org/libreoffice/example/XWriter2latex:1.0";
public static void insert (org.omg.CORBA.Any a, org.libreoffice.example.XWriter2latex that)
{
org.omg.CORBA.portable.OutputStream out = a.create_output_stream ();
a.type (type ());
write (out, that);
a.read_value (out.create_input_stream (), type ());
}
public static org.libreoffice.example.XWriter2latex extract (org.omg.CORBA.Any a)
{
return read (a.create_input_stream ());
}
private static org.omg.CORBA.TypeCode __typeCode = null;
synchronized public static org.omg.CORBA.TypeCode type ()
{
if (__typeCode == null)
{
__typeCode = org.omg.CORBA.ORB.init ().create_interface_tc (org.libreoffice.example.XWriter2latexHelper.id (), "XWriter2latex");
}
return __typeCode;
}
public static String id ()
{
return _id;
}
public static org.libreoffice.example.XWriter2latex read (org.omg.CORBA.portable.InputStream istream)
{
return narrow (istream.read_Object (_XWriter2latexStub.class));
}
public static void write (org.omg.CORBA.portable.OutputStream ostream, org.libreoffice.example.XWriter2latex value)
{
ostream.write_Object ((org.omg.CORBA.Object) value);
}
public static org.libreoffice.example.XWriter2latex narrow (org.omg.CORBA.Object obj)
{
if (obj == null)
return null;
else if (obj instanceof org.libreoffice.example.XWriter2latex)
return (org.libreoffice.example.XWriter2latex)obj;
else if (!obj._is_a (id ()))
throw new org.omg.CORBA.BAD_PARAM ();
else
{
org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate ();
org.libreoffice.example._XWriter2latexStub stub = new org.libreoffice.example._XWriter2latexStub ();
stub._set_delegate(delegate);
return stub;
}
}
public static org.libreoffice.example.XWriter2latex unchecked_narrow (org.omg.CORBA.Object obj)
{
if (obj == null)
return null;
else if (obj instanceof org.libreoffice.example.XWriter2latex)
return (org.libreoffice.example.XWriter2latex)obj;
else
{
org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate ();
org.libreoffice.example._XWriter2latexStub stub = new org.libreoffice.example._XWriter2latexStub ();
stub._set_delegate(delegate);
return stub;
}
}
}

View file

@ -0,0 +1,38 @@
package org.libreoffice.example;
/**
* org/libreoffice/example/XWriter2latexHolder.java .
* Generated by the IDL-to-Java compiler (portable), version "3.2"
* from XWriter2latex.idl
* Friday, 7 July 2017 12:51:34 o'clock MSK
*/
public final class XWriter2latexHolder implements org.omg.CORBA.portable.Streamable
{
public org.libreoffice.example.XWriter2latex value = null;
public XWriter2latexHolder ()
{
}
public XWriter2latexHolder (org.libreoffice.example.XWriter2latex initialValue)
{
value = initialValue;
}
public void _read (org.omg.CORBA.portable.InputStream i)
{
value = org.libreoffice.example.XWriter2latexHelper.read (i);
}
public void _write (org.omg.CORBA.portable.OutputStream o)
{
org.libreoffice.example.XWriter2latexHelper.write (o, value);
}
public org.omg.CORBA.TypeCode _type ()
{
return org.libreoffice.example.XWriter2latexHelper.type ();
}
}

View file

@ -0,0 +1,13 @@
package org.libreoffice.example;
/**
* org/libreoffice/example/XWriter2latexOperations.java .
* Generated by the IDL-to-Java compiler (portable), version "3.2"
* from XWriter2latex.idl
* Friday, 7 July 2017 12:51:34 o'clock MSK
*/
public interface XWriter2latexOperations
{
} // interface XWriter2latexOperations

View file

@ -0,0 +1,50 @@
package org.libreoffice.example;
/**
* org/libreoffice/example/_XWriter2latexStub.java .
* Generated by the IDL-to-Java compiler (portable), version "3.2"
* from XWriter2latex.idl
* Friday, 7 July 2017 12:51:34 o'clock MSK
*/
public class _XWriter2latexStub extends org.omg.CORBA.portable.ObjectImpl implements org.libreoffice.example.XWriter2latex
{
// Type-specific CORBA::Object operations
private static String[] __ids = {
"IDL:org/libreoffice/example/XWriter2latex:1.0"};
public String[] _ids ()
{
return (String[])__ids.clone ();
}
private void readObject (java.io.ObjectInputStream s) throws java.io.IOException
{
String str = s.readUTF ();
String[] args = null;
java.util.Properties props = null;
org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init (args, props);
try {
org.omg.CORBA.Object obj = orb.string_to_object (str);
org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl) obj)._get_delegate ();
_set_delegate (delegate);
} finally {
orb.destroy() ;
}
}
private void writeObject (java.io.ObjectOutputStream s) throws java.io.IOException
{
String[] args = null;
java.util.Properties props = null;
org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init (args, props);
try {
String str = orb.object_to_string (this);
s.writeUTF (str);
} finally {
orb.destroy() ;
}
}
} // class _XWriter2latexStub

Binary file not shown.

BIN
idl/writer2xhtml.rdb Normal file

Binary file not shown.

View file

@ -0,0 +1,30 @@
This directory contains idl specifications for the custom uno interfaces
defined by the Writer2LaTeX and Writer2xhtml extensions
To avoid dependencies on the OOo SDK in the build process, compiled versions
are included here.
If you need to rebuild it, the complete SDK is required. These are the steps:
To create the registry database for Writer2LaTeX:
idlc -I<path to SDK>\idl XW2LStarMathConverter.idl
regmerge writer2latex.rdb /UCR XW2LStarMathConverter.urd
To create the java interface
javamaker -BUCR -Torg.openoffice.da.writer2latex.XW2LStarMathConverter -nD <path to the OOo installation>\program\types.rdb writer2latex.rdb
and likewise for Writer2xhtml:
idlc -I<path to SDK>\idl XBatchConverter.idl
regmerge writer2xhtml.rdb /UCR XBatchConverter.urd
To create the java interfaces
javamaker -BUCR -Torg.openoffice.da.writer2xhtml.XBatchConverter -nD <path to the OOo installation>\program\types.rdb writer2xhtml.rdb
javamaker -BUCR -Torg.openoffice.da.writer2xhtml.XBatchHandler -nD <path to the OOo installation>\program\types.rdb writer2xhtml.rdb
If you need to use the interfaces from C++ you will also need to run cppumaker

View file

@ -0,0 +1,22 @@
#ifndef __org_openoffice_da_writer2latex_XW2LStarMathConverter_idl__
#define __org_openoffice_da_writer2latex_XW2LStarMathConverter_idl__
#include <com/sun/star/uno/XInterface.idl>
module org { module openoffice { module da { module writer2latex {
interface XW2LStarMathConverter : com::sun::star::uno::XInterface
{
// method org::openoffice::da::writer2latex::XW2LStarMathConverter::convertFormula
string convertFormula ( [in] string sStarMathFormula );
// method org::openoffice::da::writer2latex::XW2LStarMathConverter::getPreamble
string getPreamble ( );
};
}; }; }; };
#endif

Binary file not shown.

View file

@ -0,0 +1,52 @@
#ifndef __org_openoffice_da_writer2xhtml_XBatchConverter_idl__
#define __org_openoffice_da_writer2xhtml_XBatchConverter_idl__
#include <com/sun/star/uno/XInterface.idl>
#include <com/sun/star/beans/PropertyValue.idl>
module org { module openoffice { module da { module writer2xhtml {
// This interface is an IDL version of the java interface (writer2latex.api.BatchHandler)
interface XBatchHandler : com::sun::star::uno::XInterface
{
// method org::openoffice::da::writer2xhtml::XBatchHandler::startConversion
void startConversion ();
// method org::openoffice::da::writer2xhtml::XBatchHandler::endConversion
void endConversion ();
// method org::openoffice::da::writer2xhtml::XBatchHandler::startDirectory
void startDirectory ( [in] string sName );
// method org::openoffice::da::writer2xhtml::XBatchHandler::endDirectory
void endDirectory ( [in] string sName, [in] boolean bSuccess );
// method org::openoffice::da::writer2xhtml::XBatchHandler::startFile
void startFile ( [in] string sName );
// method org::openoffice::da::writer2xhtml::XBatchHandler::endFile
void endFile ( [in] string sName, [in] boolean bSuccess );
// method org::openoffice::da::writer2xhtml::XBatchHandler::cancel
boolean cancel ();
};
// This interface is an IDL version of the java interface (writer2latex.api.BatchConverter)
interface XBatchConverter : com::sun::star::uno::XInterface
{
// method org::openoffice::da::writer2xhtml::XBatchConverter::convert
void convert ( [in] string sSourceURL,
[in] string sTargetURL,
[in] sequence< com::sun::star::beans::PropertyValue > lArguments,
[in] XBatchHandler handler );
} ;
}; }; }; };
#endif

Binary file not shown.

View file

@ -0,0 +1,256 @@
package pro.litvinovg.w2phtml.gui;
import static pro.litvinovg.w2phtml.gui.Contstants.*;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.util.HashMap;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
public class BasePanel extends JPanel {
/**
*
*/
private static final long serialVersionUID = 1L;
private Localizer localizer = null;
private JFrame singleFrame = null;
private UIPreferences preferences = null;
private HashMap<String, Component> configuration = null;
public BasePanel(Localizer localizer, JFrame singleFrame, HashMap<String, Component> configuration, UIPreferences preferences) {
this.localizer = localizer;
this.singleFrame = singleFrame;
this.configuration = configuration;
this.preferences = preferences;
}
public BasePanel(Localizer localizer, JFrame singleFrame) {
this.localizer = localizer;
this.singleFrame = singleFrame;
}
protected JCheckBox addMathJaxCB(Localizer localizer, UIPreferences preferences) {
JCheckBox cb_UseMathJax = new JCheckBox(localizer.getTranslation(LABEL_USE_MATHJAX));
cb_UseMathJax.setSelected(Boolean.parseBoolean(preferences.get(PREF_USE_MATHJAX)));
return cb_UseMathJax;
}
protected void setOutputFilePath(String newFilePath, JTextField tf_OutputFile, String extension) {
File inputFile = new File(newFilePath);
if (!inputFile.exists()) {
return;
}
if (!inputFile.isDirectory()) {
File parent = inputFile.getParentFile();
if (parent == null) {
return;
}
if (!parent.canWrite()) {
JOptionPane.showMessageDialog(singleFrame, localizer.getTranslation(CANT_WRITE_MESSAGE));
}
}
if (newFilePath.length() < 3) {
return;
}
String exportPath;
if (inputFile.isDirectory()) {
exportPath = newFilePath;
tf_OutputFile.setText(exportPath);
} else {
String importExt = newFilePath.substring(newFilePath.length() - 3, newFilePath.length()).toLowerCase();
if (importExt.equals(ODT_FILE_EXTENSION)) {
exportPath = newFilePath.substring(0, newFilePath.length() - 3) + extension;
tf_OutputFile.setText(exportPath);
}
}
}
protected JCheckBox addIgnoreEmptyParsCB() {
JCheckBox cb_IgnoreEmptyParagraphs = new JCheckBox(localizer.getTranslation(LABEL_INGNORE_EMPTY_PARS));
cb_IgnoreEmptyParagraphs.setSelected(Boolean.parseBoolean(preferences.get(PREF_IGNORE_EMPTY_PARS)));
configuration.put(ARG_IGNORE_EMPTY_PARAGRAPHS, cb_IgnoreEmptyParagraphs);
return cb_IgnoreEmptyParagraphs;
}
protected JCheckBox addSplitWholePagesOnly() {
JCheckBox cb_SplitWholePagesOnly = new JCheckBox(localizer.getTranslation(LABEL_SPLIT_WHOLE_PAGES_ONLY));
cb_SplitWholePagesOnly.setSelected(Boolean.parseBoolean(preferences.get(PREF_SPLIT_WHOLE_PAGES)));
configuration.put(ARG_ALIGN_SPLITS_TO_PAGES, cb_SplitWholePagesOnly);
return cb_SplitWholePagesOnly;
}
protected JCheckBox addMathJaxCB() {
JCheckBox cb_UseMathJax = new JCheckBox(localizer.getTranslation(LABEL_USE_MATHJAX));
cb_UseMathJax.setSelected(Boolean.parseBoolean(preferences.get(PREF_USE_MATHJAX)));
configuration.put(ARG_USE_MATHJAX, cb_UseMathJax);
return cb_UseMathJax;
}
protected JCheckBox addIgnoreHardLineBreaks() {
JCheckBox cb_IgnoreHardLineBreaks = new JCheckBox(localizer.getTranslation(LABEL_FILETER_HARD_LINE_BREAKS));
cb_IgnoreHardLineBreaks.setSelected(Boolean.parseBoolean(preferences.get(PREF_IGNORE_HARD_BREAKS)));
configuration.put(ARG_IGNORE_HARD_LINE_BREAKS, cb_IgnoreHardLineBreaks);
return cb_IgnoreHardLineBreaks;
}
protected JTextField addLetterSpacingFilter() {
JTextField tf_FilterLetterSpacing = new JTextField();
tf_FilterLetterSpacing.setText(preferences.get(PREF_LETTER_SPACING));
configuration.put(ARG_MIN_LETTER_SPACING, tf_FilterLetterSpacing);
tf_FilterLetterSpacing.setColumns(10);
return tf_FilterLetterSpacing;
}
protected JTextField addSplitByLevel() {
JTextField tf_SplitByLevel = new JTextField();
configuration.put(ARG_SPLIT_LEVEL, tf_SplitByLevel);
tf_SplitByLevel.setText(preferences.get(PREF_SPLIT_BY_LEVEL));
tf_SplitByLevel.setColumns(10);
return tf_SplitByLevel;
}
protected JCheckBox addInlineStyles() {
JCheckBox cb_InlineStyles = new JCheckBox(localizer.getTranslation(LABEL_INLINE_STYLES));
cb_InlineStyles.setSelected(Boolean.parseBoolean(preferences.get(PREF_INLINE_STYLES)));
configuration.put(ARG_CSS_INLINE, cb_InlineStyles);
return cb_InlineStyles;
}
protected JCheckBox addGreenstoneTags() {
JCheckBox cb_Greenstone = new JCheckBox(localizer.getTranslation(LABEL_GREENSTONE_SPLIT));
configuration.put(ARG_GREENSTONE, cb_Greenstone);
cb_Greenstone.setSelected(Boolean.parseBoolean(preferences.get(PREF_GREENSTONE_TAGS)));
return cb_Greenstone;
}
protected JTextField addOutputFileTextField() {
JTextField tf_OutputFile = new JTextField("");
configuration.put(ARG_OUTPUT_FILE, tf_OutputFile);
tf_OutputFile.setColumns(10);
return tf_OutputFile;
}
protected JCheckBox addPagination() {
JCheckBox cb_Pagination = new JCheckBox(localizer.getTranslation(LABEL_PAGINATION));
cb_Pagination.setSelected(Boolean.getBoolean(preferences.get(PREF_PAGINATION)));
configuration.put(ARG_PAGINATION, cb_Pagination);
return cb_Pagination;
}
protected JCheckBox addConvertToPX() {
JCheckBox cb_convertToPx = new JCheckBox(localizer.getTranslation(LABEL_CONVERT_TO_PX));
cb_convertToPx.setSelected(Boolean.getBoolean(preferences.get(PREF_CONVERT_TO_PX)));
configuration.put(ARG_CONVERT_TO_PX, cb_convertToPx);
return cb_convertToPx;
}
protected JTextField addPageBreakStyle() {
JTextField tf_pageBreakInlineStyle = new JTextField(preferences.get(PREF_PAGEBREAK_STYLES));
tf_pageBreakInlineStyle.setColumns(10);
configuration.put(ARG_PAGE_BREAK_STYLE, tf_pageBreakInlineStyle);
return tf_pageBreakInlineStyle;
}
protected JLabel addTargetFormat(String format) {
JLabel lb_TargetFormat = new JLabel(format);
configuration.put(ARG_TARGET_FORMAT, lb_TargetFormat);
return lb_TargetFormat;
}
protected JTextField addScaling() {
JTextField tf_Scale = new JTextField();
tf_Scale.setText(preferences.get(PREF_SCALING));
tf_Scale.setColumns(10);
configuration.put(ARG_SCALING, tf_Scale);
return tf_Scale;
}
protected JTextField addInputFile() {
JTextField tf_inputFile = new JTextField(preferences.getSourceFileName());
tf_inputFile.setColumns(10);
configuration.put(ARG_INPUT_FILE, tf_inputFile);
return tf_inputFile;
}
protected JComboBox addImageResolution() {
JComboBox cbox_image_resolution = new JComboBox(preferences.getAll(PREF_RESOLUTIONS));
cbox_image_resolution.setSelectedIndex(Integer.parseInt(preferences.get(PREF_DEFAULT_IMAGE_RESOLUTION)));
configuration.put(ARG_IMAGE_RESOLUTION, cbox_image_resolution);
return cbox_image_resolution;
}
protected JTextField addMaxWidth() {
JTextField tf_MaxWidth = new JTextField(preferences.get(PREF_MAX_WIDTH));
tf_MaxWidth.setColumns(10);
configuration.put(ARG_MAX_WIDTH, tf_MaxWidth);
return tf_MaxWidth;
}
protected JCheckBox addEmbedRasterImages() {
JCheckBox cb_EmbedRaster = new JCheckBox(localizer.getTranslation(LABEL_EMBED_RASTER));
cb_EmbedRaster.setSelected(Boolean.parseBoolean(preferences.get(PREF_EMBED_RASTER)));
configuration.put(ARG_EMBED_IMG, cb_EmbedRaster);
return cb_EmbedRaster;
}
protected JCheckBox addEmbedVectorImages() {
JCheckBox cb_EmbedVectorImages = new JCheckBox(localizer.getTranslation(LABEL_EMBED_VECTOR));
cb_EmbedVectorImages.setSelected(Boolean.parseBoolean(preferences.get(PREF_EMBED_VECTOR)));
configuration.put(ARG_EMBED_SVG, cb_EmbedVectorImages);
return cb_EmbedVectorImages;
}
protected JButton addChooseOutputButton(JTextField tf_OutputFile, String fileExtension) {
JButton btn_ChooseOutputFile = new JButton(localizer.getTranslation(LABEL_BUTTON_CHOOSE));
btn_ChooseOutputFile.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
FileDialog fileDialog = new FileDialog();
String newFilePath = fileDialog.chooseFile(tf_OutputFile.getText(),fileExtension);
if (newFilePath != null && !newFilePath.isEmpty()) {
tf_OutputFile.setText(newFilePath);
}
}
});
return btn_ChooseOutputFile;
}
protected void setMetadataFilePath(String newFilePath, JTextField tf_MetadataFile, String extension) {
File inputFile = new File(newFilePath);
if (!inputFile.exists()) {
return;
}
if (inputFile.isDirectory()) {
tf_MetadataFile.setText(newFilePath);
} else {
File parent = inputFile.getParentFile();
if (parent == null) {
return;
}
if (newFilePath.length() < 3) {
return;
}
String importExt = newFilePath.substring(newFilePath.length()-3, newFilePath.length()).toLowerCase();
if (importExt.equals(ODT_FILE_EXTENSION)) {
String metadataPath = newFilePath.substring(0, newFilePath.length()-3) + extension;
File metaFile = new File(metadataPath);
if (metaFile.exists() && metaFile.canRead()){
tf_MetadataFile.setText(metadataPath);
} else {
tf_MetadataFile.setText("");
}
}
}
}
}

View file

@ -8,7 +8,6 @@ import java.awt.GridLayout;
import java.awt.Toolkit; import java.awt.Toolkit;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.io.File;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.io.StringWriter; import java.io.StringWriter;
import java.util.HashMap; import java.util.HashMap;
@ -34,16 +33,12 @@ public class ConfigurationWindow extends JFrame {
private static JFrame singleFrame = null; private static JFrame singleFrame = null;
public static JFrame getSingleFrame() {
return singleFrame;
}
/** /**
* Launch the application. * Launch the application.
*/ */
public static void main(String[] args) { public static void main(String[] args) {
runGUI(""); runGUI(null);
} }
private XComponentContext context; private XComponentContext context;
@ -54,20 +49,18 @@ public class ConfigurationWindow extends JFrame {
* Create the application. * Create the application.
*/ */
public ConfigurationWindow() { public ConfigurationWindow() {
this.localizer = Localizer.getInstance(); initializeConfigurationWindow();
initializePreferences();
setTitle(localizer.getTranslation(CONVERTER_TITLE_LABEL));
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setIconImage(Toolkit.getDefaultToolkit().getImage(ConfigurationWindow.class.getResource("/pro/litvinovg/w2phtml/gui/resources/w2phtml.png")));
initComponents();
createEvents();
} }
public ConfigurationWindow(XComponentContext context, ODTDocument doc) { public ConfigurationWindow(XComponentContext context, ODTDocument doc) {
this.context = context; this.context = context;
this.localizer = Localizer.getInstance(); initializeConfigurationWindow();
initializePreferences();
storage.setSourceFileName(doc.getFileName()); storage.setSourceFileName(doc.getFileName());
}
private void initializeConfigurationWindow() {
this.localizer = new Localizer();
initializePreferences();
setTitle(localizer.getTranslation(CONVERTER_TITLE_LABEL)); setTitle(localizer.getTranslation(CONVERTER_TITLE_LABEL));
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setIconImage(Toolkit.getDefaultToolkit().getImage(ConfigurationWindow.class.getResource("/pro/litvinovg/w2phtml/gui/resources/w2phtml.png"))); setIconImage(Toolkit.getDefaultToolkit().getImage(ConfigurationWindow.class.getResource("/pro/litvinovg/w2phtml/gui/resources/w2phtml.png")));
@ -88,11 +81,10 @@ public class ConfigurationWindow extends JFrame {
getContentPane().setLayout(new GridLayout(1, 0, 0, 0)); getContentPane().setLayout(new GridLayout(1, 0, 0, 0));
JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.LEFT); JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.LEFT);
getContentPane().add(tabbedPane); getContentPane().add(tabbedPane);
PanelFactory panelFactory = new PanelFactory(localizer, storage, tabbedPane); PanelFactory panelFactory = new PanelFactory(localizer, singleFrame, storage, tabbedPane);
panelFactory.createPanels(); JPanel html = panelFactory.createPanel(HTML,HTML);
JPanel epub = panelFactory.createPanel(EPUB); JPanel rdf = panelFactory.createPanel(RDF,RDF);
JPanel rdf = panelFactory.createPanel(RDF); JPanel epub = panelFactory.createPanel(EPUB,EPUB);
JPanel html = panelFactory.createPanel(HTML);
} }
public static void runGUI(XComponentContext context) { public static void runGUI(XComponentContext context) {
@ -124,35 +116,4 @@ public class ConfigurationWindow extends JFrame {
}); });
} }
public static void runGUI(String fileName) {
ODTDocument doc = new ODTDocument(fileName);
if (singleFrame != null) {
singleFrame.dispose();
}
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Throwable e) {
String message = e.getLocalizedMessage();
JOptionPane.showMessageDialog(singleFrame, message);
}
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
ConfigurationWindow frame = new ConfigurationWindow(null,doc);
singleFrame = frame;
frame.setBounds(100, 100, 1100, 800);
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.setVisible(true);
} catch (Throwable e) {
String message = e.getLocalizedMessage();
e.printStackTrace();
JOptionPane.showMessageDialog(singleFrame, message);
}
}
});
}
} }

View file

@ -12,90 +12,42 @@ import javax.swing.GroupLayout;
import javax.swing.JButton; import javax.swing.JButton;
import javax.swing.JFrame; import javax.swing.JFrame;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import javax.swing.JPanel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.swing.GroupLayout.Alignment; import javax.swing.GroupLayout.Alignment;
import javax.swing.LayoutStyle.ComponentPlacement;
public class ControlPanel extends JPanel { public class ControlPanel extends BasePanel {
private static final Logger logger = LoggerFactory.getLogger(ControlPanel.class); public ControlPanel(HashMap<String,Component> configuration,Localizer localizer, JFrame singleFrame) {
private PreferencesStorage storage; super(localizer, singleFrame);
private String configName;
private String configType;
private PanelFactory factory = null;
public void setFactory(PanelFactory factory) {
this.factory = factory;
}
public ControlPanel(HashMap<String,Component> configuration, PreferencesStorage storage, String configName, String configType) {
this.storage = storage;
this.configName = configName;
this.configType = configType;
JButton btn_Exit = new JButton(Localizer.get(BUTTON_EXIT_LABEL)); JButton btn_Exit = new JButton(localizer.getTranslation(BUTTON_EXIT_LABEL));
btn_Exit.addActionListener(new ActionListener() { btn_Exit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
ConfigurationWindow.getSingleFrame().setVisible(false); singleFrame.setVisible(false);
ConfigurationWindow.getSingleFrame().dispose(); singleFrame.dispose();
} }
}); });
JButton btn_SaveAs = new JButton(Localizer.get(BUTTON_SAVEAS_LABEL)); JButton btn_SaveAs = new JButton(localizer.getTranslation(BUTTON_SAVEAS_LABEL));
btn_SaveAs.addActionListener(new ActionListener() { btn_SaveAs.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent actionEvent) { public void actionPerformed(ActionEvent actionEvent) {
String newConfigName = JOptionPane.showInputDialog(Localizer.get(ENTER_NEW_CONFIG_NAME)); JOptionPane.showMessageDialog(singleFrame, localizer.getTranslation(MESSAGE_NOT_IMPLEMENTED));
if (newConfigName == null || newConfigName.isEmpty()) {
return;
}
if (storage.has(newConfigName)) {
JOptionPane.showMessageDialog(ConfigurationWindow.getSingleFrame(), Localizer.get(CONFIG_NAME_IS_ALREADY_IN_USE));
return;
}
UIPreferences newPrefs = storage.get(configName).clone();
newPrefs.updateFrom(configuration);
storage.put(newConfigName, newPrefs);
if (factory != null) {
factory.createPanel(newConfigName);
}
storage.save();
} }
}); });
JButton btn_Save = new JButton(localizer.getTranslation(BUTTON_SAVE_LABEL));
JButton btn_Save = new JButton(Localizer.get(BUTTON_SAVE_LABEL));
btn_Save.addActionListener(new ActionListener() { btn_Save.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent actionEvent) { public void actionPerformed(ActionEvent actionEvent) {
storage.get(configName).updateFrom(configuration); JOptionPane.showMessageDialog(singleFrame, localizer.getTranslation(MESSAGE_NOT_IMPLEMENTED));
storage.save();
JOptionPane.showMessageDialog(ConfigurationWindow.getSingleFrame(), Localizer.get(SUCCESSFULLY_SAVED));
} }
}); });
JButton btn_startConversion = new JButton(localizer.getTranslation(BUTTON_CONVERT_LABEL));
JButton btn_delete = new JButton(Localizer.get(BUTTON_DELETE_LABEL));
btn_delete.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent actionEvent) {
storage.remove(configName);
factory.removeCurPanel();
storage.save();
}
});
if (configName == HTML || configName == RDF || configName == EPUB) {
btn_Save.setVisible(false);
btn_delete.setVisible(false);
}
JButton btn_startConversion = new JButton(Localizer.get(BUTTON_CONVERT_LABEL));
btn_startConversion.addActionListener(new ActionListener() { btn_startConversion.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent actionEvent) { public void actionPerformed(ActionEvent actionEvent) {
try { try {
ConversionExecutor executor = new ConversionExecutor(configuration, ConfigurationWindow.getSingleFrame()); ConversionExecutor executor = new ConversionExecutor(configuration, singleFrame);
executor.convert(); executor.convert();
} catch(Throwable e) { } catch(Throwable e) {
StringWriter errors = new StringWriter(); StringWriter errors = new StringWriter();
e.printStackTrace(new PrintWriter(errors)); e.printStackTrace(new PrintWriter(errors));
JOptionPane.showMessageDialog(ConfigurationWindow.getSingleFrame(),errors.toString()); JOptionPane.showMessageDialog(singleFrame,errors.toString());
} }
} }
@ -111,23 +63,20 @@ public class ControlPanel extends JPanel {
.addComponent(btn_SaveAs, GroupLayout.PREFERRED_SIZE, 140, GroupLayout.PREFERRED_SIZE) .addComponent(btn_SaveAs, GroupLayout.PREFERRED_SIZE, 140, GroupLayout.PREFERRED_SIZE)
.addGap(18) .addGap(18)
.addComponent(btn_Save, GroupLayout.PREFERRED_SIZE, 120, GroupLayout.PREFERRED_SIZE) .addComponent(btn_Save, GroupLayout.PREFERRED_SIZE, 120, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.UNRELATED) .addGap(18)
.addComponent(btn_delete, GroupLayout.PREFERRED_SIZE, 120, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(btn_startConversion, GroupLayout.PREFERRED_SIZE, 100, GroupLayout.PREFERRED_SIZE) .addComponent(btn_startConversion, GroupLayout.PREFERRED_SIZE, 100, GroupLayout.PREFERRED_SIZE)
.addContainerGap(86, Short.MAX_VALUE)) .addContainerGap(427, Short.MAX_VALUE))
); );
gl_panel_control.setVerticalGroup( gl_panel_control.setVerticalGroup(
gl_panel_control.createParallelGroup(Alignment.LEADING) gl_panel_control.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panel_control.createSequentialGroup() .addGroup(gl_panel_control.createSequentialGroup()
.addContainerGap() .addContainerGap()
.addGroup(gl_panel_control.createParallelGroup(Alignment.TRAILING, false) .addGroup(gl_panel_control.createParallelGroup(Alignment.BASELINE)
.addComponent(btn_startConversion, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(btn_SaveAs)
.addComponent(btn_delete, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(btn_Save)
.addComponent(btn_SaveAs, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(btn_Exit)
.addComponent(btn_Save, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(btn_startConversion))
.addComponent(btn_Exit, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap(54, Short.MAX_VALUE))
); );
this.setLayout(gl_panel_control); this.setLayout(gl_panel_control);

View file

@ -4,11 +4,8 @@ public class Contstants {
public static final String LABEL_HTML5 = "label_html5"; public static final String LABEL_HTML5 = "label_html5";
public static final String BUTTON_CONVERT_LABEL = "button_convert_label"; public static final String BUTTON_CONVERT_LABEL = "button_convert_label";
public static final String MESSAGE_NOT_IMPLEMENTED = "message_not_implemented"; public static final String MESSAGE_NOT_IMPLEMENTED = "message_not_implemented";
public static final String CONFIG_NAME_IS_ALREADY_IN_USE = "config_name_is_already_in_use";
public static final String BUTTON_EXIT_LABEL = "button_exit_label"; public static final String BUTTON_EXIT_LABEL = "button_exit_label";
public static final String BUTTON_SAVE_LABEL = "button_save_label"; public static final String BUTTON_SAVE_LABEL = "button_save_label";
public static final String BUTTON_DELETE_LABEL = "button_delete_label";
public static final String ENTER_NEW_CONFIG_NAME = "enter_new_config_name";
public static final String BUTTON_SAVEAS_LABEL = "button_saveas_label"; public static final String BUTTON_SAVEAS_LABEL = "button_saveas_label";
public static final String ARG_PAGINATION = "pagination"; public static final String ARG_PAGINATION = "pagination";
public static final String ARG_IMAGE_RESOLUTION = "image_resolution"; public static final String ARG_IMAGE_RESOLUTION = "image_resolution";
@ -17,8 +14,6 @@ public class Contstants {
public static final String CSV_FILE_EXTENSION = "csv"; public static final String CSV_FILE_EXTENSION = "csv";
public static final String RDF_FILE_EXTENSION = "rdf"; public static final String RDF_FILE_EXTENSION = "rdf";
public static final String CANT_WRITE_MESSAGE = "error_cant_write"; public static final String CANT_WRITE_MESSAGE = "error_cant_write";
public static final String DEFAULT_CONFIG_CANT_BE_CHANGED = "default_config_cant_be_saved";
public static final String SUCCESSFULLY_SAVED = "successfully_saved_config";
public static final String HTML_FILE_EXTENSION = "html"; public static final String HTML_FILE_EXTENSION = "html";
public static final String ARG_MAX_WIDTH = "max_width"; public static final String ARG_MAX_WIDTH = "max_width";
public static final String LABEL_SPLIT_BY_HEADING = "label_split_by_heading"; public static final String LABEL_SPLIT_BY_HEADING = "label_split_by_heading";
@ -74,26 +69,23 @@ public class Contstants {
public static final String RDF = "RDF"; public static final String RDF = "RDF";
public static final String PREF_RESOLUTIONS = "resolutions"; public static final String PREF_RESOLUTIONS = "resolutions";
public static final String PREF_PUBLICATION_TYPES = "publication_types"; public static final String PREF_PUBLICATION_TYPES = "publication_types";
public static final String PREF_DEFAULT_PUBLICATION_TYPE = ARG_RDF_TYPE; public static final String PREF_DEFAULT_PUBLICATION_TYPE = "default_publication_type";
public static final String PREF_DEFAULT_IMAGE_RESOLUTION = ARG_IMAGE_RESOLUTION; public static final String PREF_DEFAULT_IMAGE_RESOLUTION = "default_image_resolution";
public static final String PREF_USE_MATHJAX = ARG_USE_MATHJAX; public static final String PREF_USE_MATHJAX = "use_mathjax";
public static final String PREF_IGNORE_EMPTY_PARS = ARG_IGNORE_EMPTY_PARAGRAPHS; public static final String PREF_IGNORE_EMPTY_PARS = "ignore_empty_paragraphs";
public static final String PREF_IGNORE_HARD_BREAKS = ARG_IGNORE_HARD_LINE_BREAKS; public static final String PREF_IGNORE_HARD_BREAKS = "ignore_hard_breaks";
public static final String PREF_SPLIT_BY_LEVEL = ARG_SPLIT_LEVEL; public static final String PREF_SPLIT_BY_LEVEL = "split_by_level";
public static final String PREF_GREENSTONE_TAGS = ARG_GREENSTONE; public static final String PREF_GREENSTONE_TAGS = "greenstone_tags";
public static final String PREF_SPLIT_WHOLE_PAGES = ARG_ALIGN_SPLITS_TO_PAGES; public static final String PREF_SPLIT_WHOLE_PAGES = "split_whole_pages";
public static final String PREF_LETTER_SPACING = ARG_MIN_LETTER_SPACING; public static final String PREF_LETTER_SPACING = "letter_spacing_filter";
public static final String PREF_INLINE_STYLES = ARG_CSS_INLINE; public static final String PREF_INLINE_STYLES = "inline_styles";
public static final String PREF_EMBED_RASTER = ARG_EMBED_IMG; public static final String PREF_EMBED_RASTER = "embed_raster";
public static final String PREF_EMBED_VECTOR = ARG_EMBED_SVG; public static final String PREF_EMBED_VECTOR = "embed_vector";
public static final String PREF_SCALING = ARG_SCALING; public static final String PREF_SCALING = "scaling";
public static final String PREF_MAX_WIDTH = ARG_MAX_WIDTH; public static final String PREF_MAX_WIDTH = "max_width";
public static final String PREF_PAGEBREAK_STYLES = ARG_PAGE_BREAK_STYLE; public static final String PREF_PAGEBREAK_STYLES = "pagebreak_styles";
public static final String PREF_CONVERT_TO_PX = ARG_CONVERT_TO_PX; public static final String PREF_CONVERT_TO_PX = "convert_to_px";
public static final String PREF_PAGINATION = ARG_PAGINATION; public static final String PREF_PAGINATION = "pagination";
public static final String PREF_TYPE = "preferences_type";
public static final String PREF_SPLIT_LEVELS = "split_levels";
public static final String TAB_PREFERENCES = "tab_preferences";
} }

View file

@ -25,7 +25,7 @@ import org.slf4j.LoggerFactory;
import com.sun.star.uno.XComponentContext; import com.sun.star.uno.XComponentContext;
import w2phtml.Application; import w2phtml.Application;
import w2phtml.rdf.MetadataContainer; import w2phtml.rdf.Metadata;
public class ConversionExecutor { public class ConversionExecutor {
@ -200,7 +200,6 @@ public class ConversionExecutor {
} catch (Exception e ) { } catch (Exception e ) {
logger.error("Conversion failed."); logger.error("Conversion failed.");
logger.error("Params: " + Arrays.toString(prepareArgs())); logger.error("Params: " + Arrays.toString(prepareArgs()));
logger.error(e.getLocalizedMessage());
} }
} }

View file

@ -3,420 +3,198 @@ package pro.litvinovg.w2phtml.gui;
import java.awt.Component; import java.awt.Component;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.io.File;
import java.util.HashMap; import java.util.HashMap;
import javax.swing.GroupLayout; import javax.swing.GroupLayout;
import javax.swing.JButton; import javax.swing.JButton;
import javax.swing.JCheckBox; import javax.swing.JCheckBox;
import javax.swing.JComboBox; import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField; import javax.swing.JTextField;
import javax.swing.GroupLayout.Alignment; import javax.swing.GroupLayout.Alignment;
import javax.swing.LayoutStyle.ComponentPlacement; import javax.swing.LayoutStyle.ComponentPlacement;
import static pro.litvinovg.w2phtml.gui.Contstants.*; import static pro.litvinovg.w2phtml.gui.Contstants.*;
import net.miginfocom.swing.MigLayout;
public class EpubPanel extends JPanel {
public class EpubPanel extends BasePanel {
/**
*
*/
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private UIPreferences preferences;
private HashMap<String, Component> configuration;
private JTextField tf_pageBreakInlineStyle_1;
private JComboBox cbox_image_resolution_1;
private JCheckBox cb_Pagination_1;
private JTextField tf_Scale_1;
private JTextField tf_FilterLetterSpacing_1;
private JCheckBox cb_convertToPx_1;
private JCheckBox cb_IgnoreHardLineBreaks_1;
private JCheckBox cb_IgnoreEmptyParagraphs_1;
private JCheckBox cb_UseMathJax_1;
private JCheckBox cb_EmbedVectorImages_1;
private JCheckBox cb_InlineStyles_1;
private JCheckBox cb_EmbedRaster_1;
private JTextField tf_OutputFile_1;
private JButton btn_ChooseOutputFile_1;
private JLabel lb_TargetFormat_1;
private JTextField tf_inputFile_1;
private JButton btn_chooseFile_1;
public EpubPanel() { public EpubPanel(HashMap<String, Component> configuration, Localizer localizer, UIPreferences preferences,JFrame singleFrame) {
this.preferences = PreferencesStorage.getDefaultEpub(null); super(localizer, singleFrame, configuration, preferences);
this.configuration = new HashMap<String, Component>();
initComponents();
}
public EpubPanel(HashMap<String, Component> configuration, UIPreferences preferences) { JLabel lb_FilterLetterSpacing = new JLabel(localizer.getTranslation(LABEL_MIN_LETTER_SPACING));
this.configuration = configuration; JLabel lb_TargetFormat_description = new JLabel(localizer.getTranslation(LABEL_TARGET_FORMAT));
this.preferences = preferences; JLabel lb_Scale = new JLabel(localizer.getTranslation(LABEL_SCALE));
initComponents(); JLabel lb_FilePath = new JLabel(localizer.getTranslation(LABEL_INPUT_FILE_PATH));
} JLabel lb_TargetFormat = addTargetFormat(EPUB3_TARGET_FORMAT);
JLabel lb_ImageResolution = new JLabel(localizer.getTranslation(LABEL_IMAGE_RESOLUTION));
JLabel lb_OutFilePath = new JLabel(localizer.getTranslation(OUTPUT_FILE_PATH));
JLabel lb_pageBreakInlineStyle = new JLabel(localizer.getTranslation(LABEL_BREAK_STYLE));
private void initComponents() { JTextField tf_FilterLetterSpacing = addLetterSpacingFilter();
JLabel lb_FilterLetterSpacing = new JLabel(Localizer.get(LABEL_MIN_LETTER_SPACING)); JTextField tf_OutputFile = addOutputFileTextField();
JLabel lb_TargetFormat_description = new JLabel(Localizer.get(LABEL_TARGET_FORMAT)); JTextField tf_inputFile = addInputFile();
JLabel lb_Scale = new JLabel(Localizer.get(LABEL_SCALE)); JTextField tf_Scale = addScaling();
JLabel lb_FilePath = new JLabel(Localizer.get(LABEL_INPUT_FILE_PATH)); JTextField tf_pageBreakInlineStyle = addPageBreakStyle();
JLabel lb_TargetFormat = addTargetFormat(EPUB3_TARGET_FORMAT, configuration);
JLabel lb_ImageResolution = new JLabel(Localizer.get(LABEL_IMAGE_RESOLUTION));
JLabel lb_OutFilePath = new JLabel(Localizer.get(OUTPUT_FILE_PATH));
JLabel lb_pageBreakInlineStyle = new JLabel(Localizer.get(LABEL_BREAK_STYLE));
JTextField tf_FilterLetterSpacing = addLetterSpacingFilter(configuration,preferences); JCheckBox cb_UseMathJax = addMathJaxCB();
JTextField tf_OutputFile = addOutputFileTextField(configuration,preferences); JCheckBox cb_IgnoreEmptyParagraphs = addIgnoreEmptyParsCB();
JTextField tf_inputFile = addInputFile(configuration,preferences); JCheckBox cb_IgnoreHardLineBreaks = addIgnoreHardLineBreaks();
JTextField tf_Scale = addScaling(configuration,preferences); JCheckBox cb_InlineStyles = addInlineStyles();
JTextField tf_pageBreakInlineStyle = addPageBreakStyle(configuration,preferences); JCheckBox cb_EmbedVectorImages = addEmbedVectorImages();
JCheckBox cb_EmbedRaster = addEmbedRasterImages();
JCheckBox cb_convertToPx = addConvertToPX();
JCheckBox cb_Pagination = addPagination();
JCheckBox cb_UseMathJax = addMathJaxCB(configuration,preferences); JComboBox cbox_image_resolution = addImageResolution();
JCheckBox cb_IgnoreEmptyParagraphs = addIgnoreEmptyParsCB(configuration,preferences);
JCheckBox cb_IgnoreHardLineBreaks = addIgnoreHardLineBreaks(configuration,preferences);
JCheckBox cb_InlineStyles = addInlineStyles(configuration,preferences);
JCheckBox cb_EmbedVectorImages = addEmbedVectorImages(configuration,preferences);
JCheckBox cb_EmbedRaster = addEmbedRasterImages(configuration,preferences);
JCheckBox cb_convertToPx = addConvertToPX(configuration,preferences);
JCheckBox cb_Pagination = addPagination(configuration,preferences);
JComboBox cbox_image_resolution = addImageResolution(configuration,preferences);
JButton btn_ChooseOutputFile = addChooseOutputButton(tf_OutputFile, EPUB_FILE_EXTENSION); JButton btn_ChooseOutputFile = addChooseOutputButton(tf_OutputFile, EPUB_FILE_EXTENSION);
JButton btn_chooseFile = addButtonChooseFile(tf_OutputFile, tf_inputFile); JButton btn_chooseFile = addButtonChooseFile(localizer, tf_OutputFile, tf_inputFile);
GroupLayout groupLayout = new GroupLayout(this);
groupLayout.setHorizontalGroup( GroupLayout gl_panel_configHTML = new GroupLayout(this);
groupLayout.createParallelGroup(Alignment.LEADING) gl_panel_configHTML.setHorizontalGroup(
.addGroup(groupLayout.createSequentialGroup() gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addGap(6) .addGroup(gl_panel_configHTML.createSequentialGroup()
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING) .addGap(34)
.addGroup(groupLayout.createSequentialGroup() .addComponent(lb_pageBreakInlineStyle, GroupLayout.PREFERRED_SIZE, 184, GroupLayout.PREFERRED_SIZE)
.addComponent(lb_OutFilePath, GroupLayout.PREFERRED_SIZE, 201, GroupLayout.PREFERRED_SIZE) .addGap(7)
.addGap(19) .addComponent(tf_pageBreakInlineStyle, GroupLayout.DEFAULT_SIZE, 802, Short.MAX_VALUE)
.addComponent(tf_OutputFile_1, GroupLayout.DEFAULT_SIZE, 413, Short.MAX_VALUE) .addGap(60))
.addGap(12) .addGroup(gl_panel_configHTML.createSequentialGroup()
.addComponent(btn_ChooseOutputFile_1, GroupLayout.PREFERRED_SIZE, 107, GroupLayout.PREFERRED_SIZE)) .addGap(32)
.addGroup(groupLayout.createSequentialGroup() .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addComponent(lb_pageBreakInlineStyle, GroupLayout.PREFERRED_SIZE, 201, GroupLayout.PREFERRED_SIZE) .addGroup(gl_panel_configHTML.createSequentialGroup()
.addGap(19) .addComponent(lb_ImageResolution, GroupLayout.PREFERRED_SIZE, 336, GroupLayout.PREFERRED_SIZE)
.addComponent(tf_pageBreakInlineStyle_1, GroupLayout.DEFAULT_SIZE, 532, Short.MAX_VALUE))
.addComponent(cb_InlineStyles_1, GroupLayout.PREFERRED_SIZE, 492, GroupLayout.PREFERRED_SIZE)
.addComponent(cb_EmbedVectorImages_1, GroupLayout.PREFERRED_SIZE, 362, GroupLayout.PREFERRED_SIZE)
.addComponent(cb_EmbedRaster_1, GroupLayout.PREFERRED_SIZE, 492, GroupLayout.PREFERRED_SIZE)
.addComponent(cb_convertToPx_1)
.addComponent(cb_IgnoreHardLineBreaks_1, GroupLayout.PREFERRED_SIZE, 492, GroupLayout.PREFERRED_SIZE)
.addComponent(cb_IgnoreEmptyParagraphs_1, GroupLayout.PREFERRED_SIZE, 492, GroupLayout.PREFERRED_SIZE)
.addComponent(cb_UseMathJax_1, GroupLayout.PREFERRED_SIZE, 492, GroupLayout.PREFERRED_SIZE)
.addComponent(cb_Pagination_1, GroupLayout.PREFERRED_SIZE, 362, GroupLayout.PREFERRED_SIZE)
.addGroup(groupLayout.createSequentialGroup()
.addComponent(lb_ImageResolution, GroupLayout.PREFERRED_SIZE, 249, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.RELATED) .addPreferredGap(ComponentPlacement.RELATED)
.addComponent(cbox_image_resolution_1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addComponent(cbox_image_resolution, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addGroup(groupLayout.createSequentialGroup() .addContainerGap())
.addPreferredGap(ComponentPlacement.RELATED) .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addComponent(lb_Scale, GroupLayout.PREFERRED_SIZE, 91, GroupLayout.PREFERRED_SIZE) .addComponent(cb_Pagination, GroupLayout.PREFERRED_SIZE, 303, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.RELATED) .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addComponent(tf_Scale_1, GroupLayout.PREFERRED_SIZE, 61, GroupLayout.PREFERRED_SIZE)) .addGroup(gl_panel_configHTML.createSequentialGroup()
.addGroup(groupLayout.createSequentialGroup() .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addComponent(lb_FilterLetterSpacing, GroupLayout.PREFERRED_SIZE, 218, GroupLayout.PREFERRED_SIZE) .addGroup(gl_panel_configHTML.createSequentialGroup()
.addPreferredGap(ComponentPlacement.RELATED) .addComponent(lb_Scale, GroupLayout.PREFERRED_SIZE, 175, GroupLayout.PREFERRED_SIZE)
.addComponent(tf_FilterLetterSpacing_1, GroupLayout.PREFERRED_SIZE, 50, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.RELATED)
.addGroup(groupLayout.createSequentialGroup() .addComponent(tf_Scale, GroupLayout.PREFERRED_SIZE, 175, GroupLayout.PREFERRED_SIZE))
.addGroup(groupLayout.createParallelGroup(Alignment.TRAILING, false) .addGroup(gl_panel_configHTML.createSequentialGroup()
.addComponent(lb_TargetFormat_description, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(lb_FilterLetterSpacing, GroupLayout.DEFAULT_SIZE, 307, Short.MAX_VALUE)
.addGroup(Alignment.LEADING, groupLayout.createSequentialGroup() .addPreferredGap(ComponentPlacement.RELATED)
.addGap(1) .addComponent(tf_FilterLetterSpacing, GroupLayout.PREFERRED_SIZE, 58, GroupLayout.PREFERRED_SIZE)
.addComponent(lb_FilePath, GroupLayout.PREFERRED_SIZE, 201, GroupLayout.PREFERRED_SIZE))) .addGap(215))
.addPreferredGap(ComponentPlacement.UNRELATED) .addComponent(cb_convertToPx, GroupLayout.PREFERRED_SIZE, 592, GroupLayout.PREFERRED_SIZE)
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING) .addComponent(cb_IgnoreHardLineBreaks, GroupLayout.PREFERRED_SIZE, 389, GroupLayout.PREFERRED_SIZE)
.addGroup(groupLayout.createSequentialGroup() .addComponent(cb_IgnoreEmptyParagraphs, GroupLayout.PREFERRED_SIZE, 405, GroupLayout.PREFERRED_SIZE)
.addComponent(tf_inputFile_1, GroupLayout.DEFAULT_SIZE, 413, Short.MAX_VALUE) .addComponent(cb_UseMathJax, GroupLayout.PREFERRED_SIZE, 409, GroupLayout.PREFERRED_SIZE)
.addComponent(cb_EmbedVectorImages, GroupLayout.PREFERRED_SIZE, 313, GroupLayout.PREFERRED_SIZE)
.addComponent(cb_InlineStyles, GroupLayout.PREFERRED_SIZE, 349, GroupLayout.PREFERRED_SIZE)
.addComponent(cb_EmbedRaster, GroupLayout.PREFERRED_SIZE, 416, GroupLayout.PREFERRED_SIZE))
.addGap(463))
.addGroup(gl_panel_configHTML.createSequentialGroup()
.addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panel_configHTML.createSequentialGroup()
.addGap(1)
.addComponent(lb_OutFilePath, GroupLayout.PREFERRED_SIZE, 184, GroupLayout.PREFERRED_SIZE)
.addGap(10)
.addComponent(tf_OutputFile, GroupLayout.DEFAULT_SIZE, 668, Short.MAX_VALUE)
.addGap(21)
.addComponent(btn_ChooseOutputFile, GroupLayout.PREFERRED_SIZE, 113, GroupLayout.PREFERRED_SIZE)
.addGap(10))
.addGroup(gl_panel_configHTML.createSequentialGroup()
.addComponent(lb_TargetFormat_description)
.addPreferredGap(ComponentPlacement.UNRELATED)
.addComponent(lb_TargetFormat, GroupLayout.PREFERRED_SIZE, 111, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_panel_configHTML.createSequentialGroup()
.addGap(3)
.addComponent(lb_FilePath, GroupLayout.PREFERRED_SIZE, 178, GroupLayout.PREFERRED_SIZE)
.addGap(14)
.addComponent(tf_inputFile, GroupLayout.DEFAULT_SIZE, 667, Short.MAX_VALUE)
.addGap(22)
.addComponent(btn_chooseFile, GroupLayout.PREFERRED_SIZE, 113, GroupLayout.PREFERRED_SIZE)
.addGap(10)))
.addGap(48))))))
);
gl_panel_configHTML.setVerticalGroup(
gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panel_configHTML.createSequentialGroup()
.addContainerGap()
.addGroup(gl_panel_configHTML.createParallelGroup(Alignment.TRAILING)
.addGroup(gl_panel_configHTML.createSequentialGroup()
.addGroup(gl_panel_configHTML.createParallelGroup(Alignment.BASELINE)
.addComponent(lb_TargetFormat_description)
.addComponent(lb_TargetFormat))
.addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panel_configHTML.createSequentialGroup()
.addGap(16)
.addComponent(tf_inputFile, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_panel_configHTML.createSequentialGroup()
.addGap(12) .addGap(12)
.addComponent(btn_chooseFile_1, GroupLayout.PREFERRED_SIZE, 107, GroupLayout.PREFERRED_SIZE)) .addComponent(lb_FilePath, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE)))
.addComponent(lb_TargetFormat_1)))) .addGap(2))
.addGap(6)) .addGroup(gl_panel_configHTML.createSequentialGroup()
); .addComponent(btn_chooseFile)
groupLayout.setVerticalGroup( .addPreferredGap(ComponentPlacement.RELATED)))
groupLayout.createParallelGroup(Alignment.LEADING) .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addGroup(groupLayout.createSequentialGroup() .addGroup(gl_panel_configHTML.createSequentialGroup()
.addGap(6) .addGap(7)
.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE) .addComponent(btn_ChooseOutputFile))
.addComponent(lb_TargetFormat_description) .addGroup(gl_panel_configHTML.createSequentialGroup()
.addComponent(lb_TargetFormat_1)) .addGap(8)
.addGap(6) .addComponent(tf_OutputFile, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING) .addGroup(gl_panel_configHTML.createSequentialGroup()
.addGroup(groupLayout.createSequentialGroup() .addGap(10)
.addGap(5) .addComponent(lb_OutFilePath)))
.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE) .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addComponent(tf_inputFile_1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addGroup(gl_panel_configHTML.createSequentialGroup()
.addComponent(lb_FilePath))) .addGap(8)
.addGroup(groupLayout.createSequentialGroup() .addComponent(tf_pageBreakInlineStyle, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addGap(3) .addGroup(gl_panel_configHTML.createSequentialGroup()
.addComponent(btn_chooseFile_1))) .addGap(7)
.addGap(6) .addComponent(lb_pageBreakInlineStyle)))
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING) .addGap(22)
.addGroup(groupLayout.createSequentialGroup() .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addGap(5) .addGroup(gl_panel_configHTML.createSequentialGroup()
.addComponent(lb_OutFilePath)) .addGap(2)
.addGroup(groupLayout.createSequentialGroup() .addComponent(lb_Scale))
.addGap(3) .addComponent(tf_Scale, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addComponent(tf_OutputFile_1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addComponent(btn_ChooseOutputFile_1))
.addGap(6)
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
.addComponent(lb_pageBreakInlineStyle)
.addGroup(groupLayout.createSequentialGroup()
.addGap(1)
.addComponent(tf_pageBreakInlineStyle_1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))
.addGap(8) .addGap(8)
.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE) .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.BASELINE)
.addComponent(lb_Scale) .addComponent(lb_FilterLetterSpacing, GroupLayout.PREFERRED_SIZE, 18, GroupLayout.PREFERRED_SIZE)
.addComponent(tf_Scale_1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addComponent(tf_FilterLetterSpacing, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addGap(8) .addPreferredGap(ComponentPlacement.RELATED)
.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE) .addComponent(cb_InlineStyles)
.addComponent(lb_FilterLetterSpacing, GroupLayout.PREFERRED_SIZE, 19, GroupLayout.PREFERRED_SIZE) .addGap(7)
.addComponent(tf_FilterLetterSpacing_1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addComponent(cb_EmbedVectorImages)
.addGap(6) .addGap(7)
.addComponent(cb_InlineStyles_1) .addComponent(cb_EmbedRaster)
.addGap(6) .addGap(7)
.addComponent(cb_EmbedVectorImages_1) .addComponent(cb_convertToPx)
.addGap(6) .addPreferredGap(ComponentPlacement.RELATED)
.addComponent(cb_EmbedRaster_1) .addComponent(cb_IgnoreHardLineBreaks)
.addGap(6) .addGap(7)
.addComponent(cb_convertToPx_1) .addComponent(cb_IgnoreEmptyParagraphs)
.addGap(6) .addPreferredGap(ComponentPlacement.UNRELATED)
.addComponent(cb_IgnoreHardLineBreaks_1) .addComponent(cb_UseMathJax)
.addGap(6) .addPreferredGap(ComponentPlacement.RELATED)
.addComponent(cb_IgnoreEmptyParagraphs_1) .addComponent(cb_Pagination)
.addGap(6) .addGap(7)
.addComponent(cb_UseMathJax_1) .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.BASELINE)
.addGap(6)
.addComponent(cb_Pagination_1)
.addGap(11)
.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
.addComponent(lb_ImageResolution) .addComponent(lb_ImageResolution)
.addComponent(cbox_image_resolution_1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addComponent(cbox_image_resolution, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addGap(4)) .addContainerGap(118, Short.MAX_VALUE))
); );
setLayout(groupLayout); this.setLayout(gl_panel_configHTML);
} }
private JButton addButtonChooseFile(Localizer localizer, JTextField tf_OutputFile, JTextField tf_inputFile) {
//Shared methods added here to make WindowBuilder work JButton btn_chooseFile = new JButton(localizer.getTranslation(LABEL_BUTTON_CHOOSE));
btn_chooseFile.addActionListener(new ActionListener() {
JCheckBox addMathJaxCB(HashMap<String, Component> configuration, UIPreferences preferences) {
cb_UseMathJax_1 = new JCheckBox(Localizer.get(LABEL_USE_MATHJAX));
cb_UseMathJax_1.setSelected(Boolean.parseBoolean(preferences.get(PREF_USE_MATHJAX)));
configuration.put(ARG_USE_MATHJAX, cb_UseMathJax_1);
return cb_UseMathJax_1;
}
JCheckBox addIgnoreEmptyParsCB(HashMap<String, Component> configuration, UIPreferences preferences) {
cb_IgnoreEmptyParagraphs_1 = new JCheckBox(Localizer.get(LABEL_INGNORE_EMPTY_PARS));
cb_IgnoreEmptyParagraphs_1.setSelected(Boolean.parseBoolean(preferences.get(PREF_IGNORE_EMPTY_PARS)));
configuration.put(ARG_IGNORE_EMPTY_PARAGRAPHS, cb_IgnoreEmptyParagraphs_1);
return cb_IgnoreEmptyParagraphs_1;
}
JCheckBox addSplitWholePagesOnly(HashMap<String, Component> configuration, UIPreferences preferences) {
JCheckBox cb_SplitWholePagesOnly = new JCheckBox(Localizer.get(LABEL_SPLIT_WHOLE_PAGES_ONLY));
cb_SplitWholePagesOnly.setSelected(Boolean.parseBoolean(preferences.get(PREF_SPLIT_WHOLE_PAGES)));
configuration.put(ARG_ALIGN_SPLITS_TO_PAGES, cb_SplitWholePagesOnly);
return cb_SplitWholePagesOnly;
}
JCheckBox addIgnoreHardLineBreaks(HashMap<String, Component> configuration, UIPreferences preferences) {
cb_IgnoreHardLineBreaks_1 = new JCheckBox(Localizer.get(LABEL_FILETER_HARD_LINE_BREAKS));
cb_IgnoreHardLineBreaks_1.setSelected(Boolean.parseBoolean(preferences.get(PREF_IGNORE_HARD_BREAKS)));
configuration.put(ARG_IGNORE_HARD_LINE_BREAKS, cb_IgnoreHardLineBreaks_1);
return cb_IgnoreHardLineBreaks_1;
}
JTextField addLetterSpacingFilter(HashMap<String, Component> configuration, UIPreferences preferences) {
tf_FilterLetterSpacing_1 = new JTextField();
tf_FilterLetterSpacing_1.setText(preferences.get(PREF_LETTER_SPACING));
configuration.put(ARG_MIN_LETTER_SPACING, tf_FilterLetterSpacing_1);
tf_FilterLetterSpacing_1.setColumns(10);
return tf_FilterLetterSpacing_1;
}
JCheckBox addInlineStyles(HashMap<String, Component> configuration, UIPreferences preferences) {
cb_InlineStyles_1 = new JCheckBox(Localizer.get(LABEL_INLINE_STYLES));
cb_InlineStyles_1.setSelected(Boolean.parseBoolean(preferences.get(PREF_INLINE_STYLES)));
configuration.put(ARG_CSS_INLINE, cb_InlineStyles_1);
return cb_InlineStyles_1;
}
JCheckBox addGreenstoneTags(HashMap<String, Component> configuration, UIPreferences preferences) {
JCheckBox cb_Greenstone = new JCheckBox(Localizer.get(LABEL_GREENSTONE_SPLIT));
configuration.put(ARG_GREENSTONE, cb_Greenstone);
cb_Greenstone.setSelected(Boolean.parseBoolean(preferences.get(PREF_GREENSTONE_TAGS)));
return cb_Greenstone;
}
JTextField addOutputFileTextField(HashMap<String, Component> configuration, UIPreferences preferences) {
tf_OutputFile_1 = new JTextField("");
configuration.put(ARG_OUTPUT_FILE, tf_OutputFile_1);
tf_OutputFile_1.setColumns(10);
return tf_OutputFile_1;
}
JCheckBox addPagination(HashMap<String, Component> configuration, UIPreferences preferences) {
cb_Pagination_1 = new JCheckBox(Localizer.get(LABEL_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.valueOf(preferences.get(PREF_CONVERT_TO_PX)));
configuration.put(ARG_CONVERT_TO_PX, cb_convertToPx_1);
return cb_convertToPx_1;
}
JTextField addPageBreakStyle(HashMap<String, Component> configuration, UIPreferences preferences) {
tf_pageBreakInlineStyle_1 = new JTextField(preferences.get(PREF_PAGEBREAK_STYLES));
tf_pageBreakInlineStyle_1.setColumns(10);
configuration.put(ARG_PAGE_BREAK_STYLE, tf_pageBreakInlineStyle_1);
return tf_pageBreakInlineStyle_1;
}
JLabel addTargetFormat(String format, HashMap<String, Component> configuration) {
lb_TargetFormat_1 = new JLabel(format);
configuration.put(ARG_TARGET_FORMAT, lb_TargetFormat_1);
return lb_TargetFormat_1;
}
JTextField addScaling(HashMap<String, Component> configuration, UIPreferences preferences) {
tf_Scale_1 = new JTextField();
tf_Scale_1.setText(preferences.get(PREF_SCALING));
tf_Scale_1.setColumns(10);
configuration.put(ARG_SCALING, tf_Scale_1);
return tf_Scale_1;
}
JTextField addInputFile(HashMap<String, Component> configuration, UIPreferences preferences) {
tf_inputFile_1 = new JTextField(preferences.getSourceFileName());
tf_inputFile_1.setColumns(10);
configuration.put(ARG_INPUT_FILE, tf_inputFile_1);
return tf_inputFile_1;
}
JComboBox addImageResolution(HashMap<String, Component> configuration, UIPreferences preferences) {
cbox_image_resolution_1 = new JComboBox(preferences.getAll(PREF_RESOLUTIONS));
cbox_image_resolution_1.setSelectedIndex(Integer.parseInt(preferences.get(PREF_DEFAULT_IMAGE_RESOLUTION)));
configuration.put(ARG_IMAGE_RESOLUTION, cbox_image_resolution_1);
return cbox_image_resolution_1;
}
JComboBox addSplitByLevel(HashMap<String, Component> configuration, UIPreferences preferences) {
JComboBox cbox_SplitByLevel = new JComboBox(preferences.getAll(PREF_SPLIT_LEVELS));
configuration.put(ARG_SPLIT_LEVEL, cbox_SplitByLevel);
cbox_SplitByLevel.setSelectedIndex(Integer.parseInt(preferences.get(PREF_SPLIT_BY_LEVEL)));
return cbox_SplitByLevel;
}
JTextField addMaxWidth(HashMap<String, Component> configuration, UIPreferences preferences) {
JTextField tf_MaxWidth = new JTextField(preferences.get(PREF_MAX_WIDTH));
tf_MaxWidth.setColumns(10);
configuration.put(ARG_MAX_WIDTH, tf_MaxWidth);
return tf_MaxWidth;
}
JCheckBox addEmbedRasterImages(HashMap<String, Component> configuration, UIPreferences preferences) {
cb_EmbedRaster_1 = new JCheckBox(Localizer.get(LABEL_EMBED_RASTER));
cb_EmbedRaster_1.setSelected(Boolean.parseBoolean(preferences.get(PREF_EMBED_RASTER)));
configuration.put(ARG_EMBED_IMG, cb_EmbedRaster_1);
return cb_EmbedRaster_1;
}
JCheckBox addEmbedVectorImages(HashMap<String, Component> configuration, UIPreferences preferences) {
cb_EmbedVectorImages_1 = new JCheckBox(Localizer.get(LABEL_EMBED_VECTOR));
cb_EmbedVectorImages_1.setSelected(Boolean.parseBoolean(preferences.get(PREF_EMBED_VECTOR)));
configuration.put(ARG_EMBED_SVG, cb_EmbedVectorImages_1);
return cb_EmbedVectorImages_1;
}
void setOutputFilePath(String newFilePath, JTextField tf_OutputFile, String extension) {
File inputFile = new File(newFilePath);
if (!inputFile.exists()) {
return;
}
if (!inputFile.isDirectory()) {
File parent = inputFile.getParentFile();
if (parent == null) {
return;
}
if (!parent.canWrite()) {
JOptionPane.showMessageDialog(ConfigurationWindow.getSingleFrame(), Localizer.get(CANT_WRITE_MESSAGE));
}
}
if (newFilePath.length() < 3) {
return;
}
String exportPath;
if (inputFile.isDirectory()) {
exportPath = newFilePath;
tf_OutputFile.setText(exportPath);
} else {
String importExt = newFilePath.substring(newFilePath.length() - 3, newFilePath.length()).toLowerCase();
if (importExt.equals(ODT_FILE_EXTENSION)) {
exportPath = newFilePath.substring(0, newFilePath.length() - 3) + extension;
tf_OutputFile.setText(exportPath);
}
}
}
JButton addChooseOutputButton(JTextField tf_OutputFile, String fileExtension) {
btn_ChooseOutputFile_1 = new JButton(Localizer.get(LABEL_BUTTON_CHOOSE));
btn_ChooseOutputFile_1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
FileDialog fileDialog = new FileDialog();
String newFilePath = fileDialog.chooseFile(tf_OutputFile.getText(),fileExtension);
if (newFilePath != null && !newFilePath.isEmpty()) {
tf_OutputFile.setText(newFilePath);
}
}
});
return btn_ChooseOutputFile_1;
}
public void setMetadataFilePath(String newFilePath, JTextField tf_MetadataFile, String extension) {
File inputFile = new File(newFilePath);
if (!inputFile.exists()) {
return;
}
if (inputFile.isDirectory()) {
tf_MetadataFile.setText(newFilePath);
} else {
File parent = inputFile.getParentFile();
if (parent == null) {
return;
}
if (newFilePath.length() < 3) {
return;
}
String importExt = newFilePath.substring(newFilePath.length()-3, newFilePath.length()).toLowerCase();
if (importExt.equals(ODT_FILE_EXTENSION)) {
String metadataPath = newFilePath.substring(0, newFilePath.length()-3) + extension;
File metaFile = new File(metadataPath);
if (metaFile.exists() && metaFile.canRead()){
tf_MetadataFile.setText(metadataPath);
} else {
tf_MetadataFile.setText("");
}
}
}
}
JButton addButtonChooseFile(JTextField tf_OutputFile, JTextField tf_inputFile) {
btn_chooseFile_1 = new JButton(Localizer.get(LABEL_BUTTON_CHOOSE));
btn_chooseFile_1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
FileDialog fileDialog = new FileDialog(); FileDialog fileDialog = new FileDialog();
String newFilePath = fileDialog.chooseFile(tf_inputFile.getText(),ODT_FILE_EXTENSION); String newFilePath = fileDialog.chooseFile(tf_inputFile.getText(),ODT_FILE_EXTENSION);
@ -426,6 +204,10 @@ public class EpubPanel extends JPanel {
} }
} }
}); });
return btn_chooseFile_1; return btn_chooseFile;
} }
} }

View file

@ -37,11 +37,7 @@ public class FileDialog extends JFrame {
int result = fileChooser.showOpenDialog(null); int result = fileChooser.showOpenDialog(null);
if (result == fileChooser.APPROVE_OPTION){ if (result == fileChooser.APPROVE_OPTION){
selected = fileChooser.getSelectedFile(); selected = fileChooser.getSelectedFile();
if (selected.isDirectory()) { return selected.getAbsolutePath();
return selected.getAbsolutePath() + File.separator;
} else {
return selected.getAbsolutePath();
}
} else { } else {
return ""; return "";
} }

View file

@ -3,460 +3,225 @@ package pro.litvinovg.w2phtml.gui;
import java.awt.Component; import java.awt.Component;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.io.File;
import java.util.HashMap; import java.util.HashMap;
import javax.swing.GroupLayout; import javax.swing.GroupLayout;
import javax.swing.JButton; import javax.swing.JButton;
import javax.swing.JCheckBox; import javax.swing.JCheckBox;
import javax.swing.JComboBox; import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField; import javax.swing.JTextField;
import javax.swing.GroupLayout.Alignment; import javax.swing.GroupLayout.Alignment;
import javax.swing.LayoutStyle.ComponentPlacement; import javax.swing.LayoutStyle.ComponentPlacement;
import static pro.litvinovg.w2phtml.gui.Contstants.*; import static pro.litvinovg.w2phtml.gui.Contstants.*;
import javax.swing.SpringLayout;
import net.miginfocom.swing.MigLayout;
public class HTMLPanel extends JPanel{
public class HTMLPanel extends BasePanel{
/**
*
*/
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private HashMap<String, Component> configuration = null; public HTMLPanel(HashMap<String, Component> configuration, Localizer localizer, UIPreferences preferences,JFrame singleFrame) {
private UIPreferences preferences = null; super(localizer, singleFrame, configuration, preferences);
private JComboBox cbox_SplitByLevel_1;
private JCheckBox cb_Greenstone_1;
private JCheckBox cb_IgnoreEmptyParagraphs_1;
private JCheckBox cb_IgnoreHardLineBreaks_1;
private JCheckBox cb_convertToPx_1;
private JCheckBox cb_EmbedRaster_1;
private JCheckBox cb_EmbedVectorImages_1;
private JCheckBox cb_InlineStyles_1;
private JTextField tf_FilterLetterSpacing_1;
private JLabel lb_TargetFormat_1;
private JTextField tf_OutputFile_1;
private JTextField tf_inputFile_1;
private JButton btn_ChooseOutputFile_1;
private JButton btn_chooseFile_1;
private JCheckBox cb_UseMathJax_1;
private JCheckBox cb_SplitWholePagesOnly_1;
private JTextField tf_Scale_1;
private JTextField tf_pageBreakInlineStyle_1;
private JTextField tf_MaxWidth_1;
private JCheckBox cb_Pagination_1;
private JComboBox cbox_image_resolution_1;
JLabel lb_SplitByLevel = new JLabel(localizer.getTranslation(LABEL_SPLIT_BY_HEADING));
JLabel lb_FilterLetterSpacing = new JLabel(localizer.getTranslation(LABEL_MIN_LETTER_SPACING));
JLabel lb_TargetFormat = addTargetFormat(HTML5_TARGET_FORMAT);
JLabel lb_Scale = new JLabel(localizer.getTranslation(LABEL_SCALE));
JLabel lb_MaxWidth = new JLabel(localizer.getTranslation(LABEL_MAX_BODY_WIDTH));
JLabel lb_FilePath = new JLabel(localizer.getTranslation(LABEL_INPUT_FILE_PATH));
JLabel lb_TargetFormat_description = new JLabel(localizer.getTranslation(LABEL_TARGET_FORMAT));
JLabel lb_OutFilePath = new JLabel(localizer.getTranslation(OUTPUT_FILE_PATH));
JLabel lb_ImageResolution = new JLabel(localizer.getTranslation(LABEL_IMAGE_RESOLUTION));
JLabel lb_pageBreakInlineStyle = new JLabel(localizer.getTranslation(LABEL_BREAK_STYLE));
public HTMLPanel() { JTextField tf_FilterLetterSpacing = addLetterSpacingFilter();
this.preferences = PreferencesStorage.getDefaultHTML(null); JTextField tf_SplitByLevel = addSplitByLevel();
this.configuration = new HashMap<String, Component>(); JTextField tf_Scale = addScaling();
initComponents(); JTextField tf_MaxWidth = addMaxWidth();
} JTextField tf_inputFile = addInputFile();
JTextField tf_OutputFile = addOutputFileTextField();
JTextField tf_pageBreakInlineStyle = addPageBreakStyle();
public HTMLPanel(HashMap<String, Component> configuration, UIPreferences preferences) { JCheckBox cb_UseMathJax = addMathJaxCB();
this.configuration = configuration; JCheckBox cb_IgnoreEmptyParagraphs = addIgnoreEmptyParsCB();
this.preferences = preferences; JCheckBox cb_IgnoreHardLineBreaks = addIgnoreHardLineBreaks();
initComponents(); JCheckBox cb_SplitWholePagesOnly = addSplitWholePagesOnly();
} JCheckBox cb_Greenstone = addGreenstoneTags();
private void initComponents() { JCheckBox cb_InlineStyles = addInlineStyles();
JLabel lb_SplitByLevel = new JLabel(Localizer.get(LABEL_SPLIT_BY_HEADING)); JCheckBox cb_EmbedRaster = addEmbedRasterImages();
JLabel lb_FilterLetterSpacing = new JLabel(Localizer.get(LABEL_MIN_LETTER_SPACING)); JCheckBox cb_EmbedVectorImages = addEmbedVectorImages();
JLabel lb_TargetFormat = addTargetFormat(HTML5_TARGET_FORMAT, configuration); JCheckBox cb_convertToPx = addConvertToPX();
JLabel lb_Scale = new JLabel(Localizer.get(LABEL_SCALE)); JCheckBox cb_Pagination = addPagination();
JLabel lb_MaxWidth = new JLabel(Localizer.get(LABEL_MAX_BODY_WIDTH));
JLabel lb_FilePath = new JLabel(Localizer.get(LABEL_INPUT_FILE_PATH));
JLabel lb_TargetFormat_description = new JLabel(Localizer.get(LABEL_TARGET_FORMAT));
JLabel lb_OutFilePath = new JLabel(Localizer.get(OUTPUT_FILE_PATH));
JLabel lb_ImageResolution = new JLabel(Localizer.get(LABEL_IMAGE_RESOLUTION));
JLabel lb_pageBreakInlineStyle = new JLabel(Localizer.get(LABEL_BREAK_STYLE));
JTextField tf_FilterLetterSpacing = addLetterSpacingFilter(configuration,preferences); JComboBox cbox_image_resolution = addImageResolution();
JTextField tf_Scale = addScaling(configuration,preferences);
JTextField tf_MaxWidth = addMaxWidth(configuration,preferences);
JTextField tf_inputFile = addInputFile(configuration,preferences);
JTextField tf_OutputFile = addOutputFileTextField(configuration,preferences);
JTextField tf_pageBreakInlineStyle = addPageBreakStyle(configuration,preferences);
JCheckBox cb_UseMathJax = addMathJaxCB(configuration,preferences); JButton btn_chooseFile = addButtonChooseFile(localizer, tf_inputFile, tf_OutputFile);
JCheckBox cb_IgnoreEmptyParagraphs = addIgnoreEmptyParsCB(configuration,preferences);
JCheckBox cb_IgnoreHardLineBreaks = addIgnoreHardLineBreaks(configuration,preferences);
JCheckBox cb_SplitWholePagesOnly = addSplitWholePagesOnly(configuration,preferences);
JCheckBox cb_Greenstone = addGreenstoneTags(configuration,preferences);
JCheckBox cb_InlineStyles = addInlineStyles(configuration,preferences);
JCheckBox cb_EmbedRaster = addEmbedRasterImages(configuration,preferences);
JCheckBox cb_EmbedVectorImages = addEmbedVectorImages(configuration,preferences);
JCheckBox cb_convertToPx = addConvertToPX(configuration,preferences);
JCheckBox cb_Pagination = addPagination(configuration,preferences);
JComboBox cbox_image_resolution = addImageResolution(configuration,preferences);
JComboBox cbox_SplitByLevel = addSplitByLevel(configuration,preferences);
JButton btn_chooseFile = addButtonChooseFile( tf_inputFile, tf_OutputFile);
JButton btn_ChooseOutputFile = addChooseOutputButton(tf_OutputFile, HTML_FILE_EXTENSION); JButton btn_ChooseOutputFile = addChooseOutputButton(tf_OutputFile, HTML_FILE_EXTENSION);
GroupLayout groupLayout = new GroupLayout(this);
groupLayout.setHorizontalGroup( GroupLayout gl_panel_configHTML = new GroupLayout(this);
groupLayout.createParallelGroup(Alignment.LEADING) gl_panel_configHTML.setHorizontalGroup(
.addGroup(groupLayout.createSequentialGroup() gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addGap(6) .addGroup(gl_panel_configHTML.createSequentialGroup()
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING) .addGap(32)
.addGroup(groupLayout.createSequentialGroup() .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addComponent(lb_TargetFormat_description, GroupLayout.PREFERRED_SIZE, 218, GroupLayout.PREFERRED_SIZE) .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addGap(12) .addGroup(gl_panel_configHTML.createSequentialGroup()
.addComponent(lb_TargetFormat_1)) .addComponent(lb_SplitByLevel, GroupLayout.PREFERRED_SIZE, 454, GroupLayout.PREFERRED_SIZE)
.addGroup(groupLayout.createSequentialGroup() .addPreferredGap(ComponentPlacement.RELATED)
.addComponent(lb_FilePath, GroupLayout.PREFERRED_SIZE, 193, GroupLayout.PREFERRED_SIZE) .addComponent(tf_SplitByLevel, GroupLayout.PREFERRED_SIZE, 48, GroupLayout.PREFERRED_SIZE)
.addGap(37) .addGap(541))
.addComponent(tf_inputFile_1, GroupLayout.DEFAULT_SIZE, 468, Short.MAX_VALUE) .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addGap(12) .addGroup(gl_panel_configHTML.createSequentialGroup()
.addComponent(btn_chooseFile_1, GroupLayout.PREFERRED_SIZE, 104, GroupLayout.PREFERRED_SIZE)) .addComponent(cb_Greenstone, GroupLayout.PREFERRED_SIZE, 482, GroupLayout.PREFERRED_SIZE)
.addGroup(groupLayout.createSequentialGroup() .addContainerGap())
.addComponent(lb_OutFilePath, GroupLayout.PREFERRED_SIZE, 193, GroupLayout.PREFERRED_SIZE) .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addGap(37) .addComponent(cb_IgnoreEmptyParagraphs, GroupLayout.PREFERRED_SIZE, 441, GroupLayout.PREFERRED_SIZE)
.addComponent(tf_OutputFile_1, GroupLayout.DEFAULT_SIZE, 468, Short.MAX_VALUE) .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addGap(12) .addGroup(gl_panel_configHTML.createSequentialGroup()
.addComponent(btn_ChooseOutputFile_1, GroupLayout.PREFERRED_SIZE, 104, GroupLayout.PREFERRED_SIZE)) .addComponent(cb_IgnoreHardLineBreaks, GroupLayout.PREFERRED_SIZE, 341, GroupLayout.PREFERRED_SIZE)
.addGroup(groupLayout.createSequentialGroup() .addContainerGap())
.addComponent(lb_pageBreakInlineStyle, GroupLayout.PREFERRED_SIZE, 193, GroupLayout.PREFERRED_SIZE) .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addGap(37) .addGroup(gl_panel_configHTML.createSequentialGroup()
.addComponent(tf_pageBreakInlineStyle_1, GroupLayout.DEFAULT_SIZE, 584, Short.MAX_VALUE)) .addComponent(cb_convertToPx, GroupLayout.PREFERRED_SIZE, 592, GroupLayout.PREFERRED_SIZE)
.addGroup(groupLayout.createSequentialGroup() .addContainerGap())
.addComponent(lb_Scale, GroupLayout.PREFERRED_SIZE, 193, GroupLayout.PREFERRED_SIZE) .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addGap(37) .addGroup(gl_panel_configHTML.createSequentialGroup()
.addComponent(tf_Scale_1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addComponent(cb_EmbedRaster)
.addGroup(groupLayout.createSequentialGroup() .addContainerGap())
.addComponent(lb_MaxWidth, GroupLayout.PREFERRED_SIZE, 193, GroupLayout.PREFERRED_SIZE) .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addGap(37) .addGroup(gl_panel_configHTML.createSequentialGroup()
.addComponent(tf_MaxWidth_1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addComponent(cb_EmbedVectorImages, GroupLayout.PREFERRED_SIZE, 276, GroupLayout.PREFERRED_SIZE)
.addGroup(groupLayout.createSequentialGroup() .addContainerGap())
.addComponent(lb_FilterLetterSpacing, GroupLayout.PREFERRED_SIZE, 218, GroupLayout.PREFERRED_SIZE) .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addGap(37) .addGroup(gl_panel_configHTML.createSequentialGroup()
.addComponent(tf_FilterLetterSpacing_1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addComponent(cb_InlineStyles, GroupLayout.PREFERRED_SIZE, 322, GroupLayout.PREFERRED_SIZE)
.addComponent(cb_InlineStyles_1) .addContainerGap())
.addComponent(cb_EmbedVectorImages_1) .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addComponent(cb_EmbedRaster_1) .addGroup(gl_panel_configHTML.createSequentialGroup()
.addComponent(cb_convertToPx_1, GroupLayout.PREFERRED_SIZE, 698, GroupLayout.PREFERRED_SIZE) .addComponent(lb_FilterLetterSpacing, GroupLayout.PREFERRED_SIZE, 350, GroupLayout.PREFERRED_SIZE)
.addComponent(cb_IgnoreHardLineBreaks_1) .addPreferredGap(ComponentPlacement.RELATED)
.addComponent(cb_IgnoreEmptyParagraphs_1, GroupLayout.PREFERRED_SIZE, 698, GroupLayout.PREFERRED_SIZE) .addComponent(tf_FilterLetterSpacing, GroupLayout.PREFERRED_SIZE, 58, GroupLayout.PREFERRED_SIZE)
.addComponent(cb_Greenstone_1) .addGap(635))
.addGroup(groupLayout.createSequentialGroup() .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addComponent(lb_SplitByLevel, GroupLayout.PREFERRED_SIZE, 193, GroupLayout.PREFERRED_SIZE) .addGroup(gl_panel_configHTML.createSequentialGroup()
.addGap(12) .addComponent(lb_MaxWidth, GroupLayout.PREFERRED_SIZE, 175, GroupLayout.PREFERRED_SIZE)
.addComponent(cbox_SplitByLevel_1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addContainerGap())
.addComponent(cb_SplitWholePagesOnly_1) .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addComponent(cb_UseMathJax_1) .addGroup(gl_panel_configHTML.createSequentialGroup()
.addComponent(cb_Pagination_1) .addComponent(lb_Scale, GroupLayout.PREFERRED_SIZE, 168, GroupLayout.PREFERRED_SIZE)
.addGroup(groupLayout.createSequentialGroup() .addContainerGap())
.addComponent(lb_ImageResolution, GroupLayout.PREFERRED_SIZE, 249, GroupLayout.PREFERRED_SIZE) .addGroup(gl_panel_configHTML.createSequentialGroup()
.addGap(6) .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addComponent(cbox_image_resolution_1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))) .addGroup(gl_panel_configHTML.createSequentialGroup()
.addGap(6)) .addComponent(lb_TargetFormat_description, GroupLayout.PREFERRED_SIZE, 178, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(lb_TargetFormat, GroupLayout.PREFERRED_SIZE, 111, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_panel_configHTML.createSequentialGroup()
.addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addComponent(lb_FilePath, GroupLayout.PREFERRED_SIZE, 193, GroupLayout.PREFERRED_SIZE)
.addComponent(lb_OutFilePath, GroupLayout.PREFERRED_SIZE, 191, GroupLayout.PREFERRED_SIZE))
.addPreferredGap(ComponentPlacement.RELATED)
.addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addComponent(tf_OutputFile, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 586, Short.MAX_VALUE)
.addComponent(tf_inputFile, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 586, Short.MAX_VALUE))
.addPreferredGap(ComponentPlacement.RELATED)
.addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addComponent(btn_ChooseOutputFile, GroupLayout.PREFERRED_SIZE, 113, GroupLayout.PREFERRED_SIZE)
.addComponent(btn_chooseFile, GroupLayout.PREFERRED_SIZE, 113, GroupLayout.PREFERRED_SIZE)))
.addComponent(cb_UseMathJax, GroupLayout.PREFERRED_SIZE, 352, GroupLayout.PREFERRED_SIZE)
.addComponent(cb_SplitWholePagesOnly, GroupLayout.PREFERRED_SIZE, 323, GroupLayout.PREFERRED_SIZE)
.addGroup(gl_panel_configHTML.createSequentialGroup()
.addComponent(lb_pageBreakInlineStyle, GroupLayout.PREFERRED_SIZE, 191, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.RELATED)
.addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addComponent(tf_Scale, GroupLayout.PREFERRED_SIZE, 175, GroupLayout.PREFERRED_SIZE)
.addComponent(tf_pageBreakInlineStyle, GroupLayout.DEFAULT_SIZE, 707, Short.MAX_VALUE)
.addComponent(tf_MaxWidth, GroupLayout.PREFERRED_SIZE, 175, GroupLayout.PREFERRED_SIZE))))
.addGap(145)))))))))))))
.addGroup(gl_panel_configHTML.createSequentialGroup()
.addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addComponent(cb_Pagination, GroupLayout.PREFERRED_SIZE, 303, GroupLayout.PREFERRED_SIZE)
.addGroup(gl_panel_configHTML.createSequentialGroup()
.addComponent(lb_ImageResolution, GroupLayout.PREFERRED_SIZE, 366, GroupLayout.PREFERRED_SIZE)
.addGap(4)
.addComponent(cbox_image_resolution, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)))
.addGap(615))))
); );
groupLayout.setVerticalGroup( gl_panel_configHTML.setVerticalGroup(
groupLayout.createParallelGroup(Alignment.LEADING) gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addGroup(groupLayout.createSequentialGroup() .addGroup(gl_panel_configHTML.createSequentialGroup()
.addGap(6) .addGap(12)
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING) .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.BASELINE)
.addComponent(lb_TargetFormat_description) .addComponent(lb_TargetFormat_description)
.addGroup(groupLayout.createSequentialGroup() .addComponent(lb_TargetFormat))
.addGap(6) .addPreferredGap(ComponentPlacement.UNRELATED)
.addComponent(lb_TargetFormat_1))) .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addGap(6) .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.BASELINE)
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING) .addComponent(tf_inputFile, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addGroup(groupLayout.createSequentialGroup() .addComponent(btn_chooseFile))
.addGap(10) .addGroup(gl_panel_configHTML.createSequentialGroup()
.addComponent(lb_FilePath))
.addGroup(groupLayout.createSequentialGroup()
.addGap(6)
.addComponent(tf_inputFile_1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addComponent(btn_chooseFile_1))
.addGap(6)
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
.addGroup(groupLayout.createSequentialGroup()
.addGap(5)
.addComponent(lb_OutFilePath))
.addGroup(groupLayout.createSequentialGroup()
.addGap(6)
.addComponent(tf_OutputFile_1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addComponent(btn_ChooseOutputFile_1))
.addGap(6)
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
.addGroup(groupLayout.createSequentialGroup()
.addGap(2) .addGap(2)
.addComponent(lb_pageBreakInlineStyle)) .addComponent(lb_FilePath)))
.addComponent(tf_pageBreakInlineStyle_1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.UNRELATED)
.addGap(6) .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.BASELINE)
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING) .addComponent(lb_OutFilePath)
.addGroup(groupLayout.createSequentialGroup() .addComponent(tf_OutputFile, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addGap(2) .addComponent(btn_ChooseOutputFile))
.addComponent(lb_Scale)) .addGap(12)
.addComponent(tf_Scale_1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.BASELINE)
.addGap(6) .addComponent(lb_pageBreakInlineStyle)
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING) .addComponent(tf_pageBreakInlineStyle, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addGroup(groupLayout.createSequentialGroup() .addGap(18)
.addGap(2) .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.BASELINE)
.addComponent(lb_MaxWidth)) .addComponent(lb_Scale)
.addComponent(tf_MaxWidth_1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addComponent(tf_Scale, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addGap(6) .addPreferredGap(ComponentPlacement.UNRELATED)
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING) .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.BASELINE)
.addGroup(groupLayout.createSequentialGroup() .addComponent(lb_MaxWidth)
.addGap(2) .addComponent(tf_MaxWidth, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addComponent(lb_FilterLetterSpacing)) .addPreferredGap(ComponentPlacement.RELATED)
.addComponent(tf_FilterLetterSpacing_1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.BASELINE)
.addGap(6) .addComponent(lb_FilterLetterSpacing)
.addComponent(cb_InlineStyles_1) .addComponent(tf_FilterLetterSpacing, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addGap(6) .addPreferredGap(ComponentPlacement.UNRELATED)
.addComponent(cb_EmbedVectorImages_1) .addComponent(cb_InlineStyles)
.addGap(6) .addPreferredGap(ComponentPlacement.UNRELATED)
.addComponent(cb_EmbedRaster_1) .addComponent(cb_EmbedVectorImages)
.addGap(6) .addPreferredGap(ComponentPlacement.UNRELATED)
.addComponent(cb_convertToPx_1) .addComponent(cb_EmbedRaster)
.addGap(6) .addPreferredGap(ComponentPlacement.UNRELATED)
.addComponent(cb_IgnoreHardLineBreaks_1) .addComponent(cb_convertToPx)
.addGap(6) .addPreferredGap(ComponentPlacement.UNRELATED)
.addComponent(cb_IgnoreEmptyParagraphs_1) .addComponent(cb_IgnoreHardLineBreaks)
.addGap(6) .addPreferredGap(ComponentPlacement.UNRELATED)
.addComponent(cb_Greenstone_1) .addComponent(cb_IgnoreEmptyParagraphs)
.addGap(6) .addPreferredGap(ComponentPlacement.UNRELATED)
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING) .addComponent(cb_Greenstone)
.addGroup(groupLayout.createSequentialGroup() .addPreferredGap(ComponentPlacement.UNRELATED)
.addGap(5) .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.BASELINE)
.addComponent(lb_SplitByLevel)) .addComponent(lb_SplitByLevel, GroupLayout.PREFERRED_SIZE, 16, GroupLayout.PREFERRED_SIZE)
.addComponent(cbox_SplitByLevel_1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addComponent(tf_SplitByLevel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addGap(6) .addPreferredGap(ComponentPlacement.RELATED)
.addComponent(cb_SplitWholePagesOnly_1) .addComponent(cb_SplitWholePagesOnly)
.addGap(6) .addPreferredGap(ComponentPlacement.UNRELATED)
.addComponent(cb_UseMathJax_1) .addComponent(cb_UseMathJax)
.addGap(6) .addPreferredGap(ComponentPlacement.UNRELATED)
.addComponent(cb_Pagination_1) .addComponent(cb_Pagination)
.addGap(6) .addPreferredGap(ComponentPlacement.RELATED)
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING) .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.BASELINE)
.addGroup(groupLayout.createSequentialGroup() .addComponent(lb_ImageResolution)
.addGap(5) .addComponent(cbox_image_resolution, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addComponent(lb_ImageResolution)) .addGap(101))
.addComponent(cbox_image_resolution_1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))
); );
setLayout(groupLayout); this.setLayout(gl_panel_configHTML);
} }
private JButton addButtonChooseFile(Localizer localizer, JTextField tf_inputFile, JTextField tf_OutputFile) {
JButton btn_chooseFile = new JButton(localizer.getTranslation(LABEL_BUTTON_CHOOSE));
//Shared methods added here to make WindowBuilder work btn_chooseFile.addActionListener(new ActionListener() {
JCheckBox addMathJaxCB(HashMap<String, Component> configuration, UIPreferences preferences) {
cb_UseMathJax_1 = new JCheckBox(Localizer.get(LABEL_USE_MATHJAX));
cb_UseMathJax_1.setSelected(Boolean.parseBoolean(preferences.get(PREF_USE_MATHJAX)));
configuration.put(ARG_USE_MATHJAX, cb_UseMathJax_1);
return cb_UseMathJax_1;
}
JCheckBox addIgnoreEmptyParsCB(HashMap<String, Component> configuration, UIPreferences preferences) {
cb_IgnoreEmptyParagraphs_1 = new JCheckBox(Localizer.get(LABEL_INGNORE_EMPTY_PARS));
cb_IgnoreEmptyParagraphs_1.setSelected(Boolean.parseBoolean(preferences.get(PREF_IGNORE_EMPTY_PARS)));
configuration.put(ARG_IGNORE_EMPTY_PARAGRAPHS, cb_IgnoreEmptyParagraphs_1);
return cb_IgnoreEmptyParagraphs_1;
}
JCheckBox addSplitWholePagesOnly(HashMap<String, Component> configuration, UIPreferences preferences) {
cb_SplitWholePagesOnly_1 = new JCheckBox(Localizer.get(LABEL_SPLIT_WHOLE_PAGES_ONLY));
cb_SplitWholePagesOnly_1.setSelected(Boolean.parseBoolean(preferences.get(PREF_SPLIT_WHOLE_PAGES)));
configuration.put(ARG_ALIGN_SPLITS_TO_PAGES, cb_SplitWholePagesOnly_1);
return cb_SplitWholePagesOnly_1;
}
JCheckBox addIgnoreHardLineBreaks(HashMap<String, Component> configuration, UIPreferences preferences) {
cb_IgnoreHardLineBreaks_1 = new JCheckBox(Localizer.get(LABEL_FILETER_HARD_LINE_BREAKS));
cb_IgnoreHardLineBreaks_1.setSelected(Boolean.parseBoolean(preferences.get(PREF_IGNORE_HARD_BREAKS)));
configuration.put(ARG_IGNORE_HARD_LINE_BREAKS, cb_IgnoreHardLineBreaks_1);
return cb_IgnoreHardLineBreaks_1;
}
JTextField addLetterSpacingFilter(HashMap<String, Component> configuration, UIPreferences preferences) {
tf_FilterLetterSpacing_1 = new JTextField();
tf_FilterLetterSpacing_1.setText(preferences.get(PREF_LETTER_SPACING));
configuration.put(ARG_MIN_LETTER_SPACING, tf_FilterLetterSpacing_1);
tf_FilterLetterSpacing_1.setColumns(10);
return tf_FilterLetterSpacing_1;
}
JCheckBox addInlineStyles(HashMap<String, Component> configuration, UIPreferences preferences) {
cb_InlineStyles_1 = new JCheckBox(Localizer.get(LABEL_INLINE_STYLES));
cb_InlineStyles_1.setSelected(Boolean.parseBoolean(preferences.get(PREF_INLINE_STYLES)));
configuration.put(ARG_CSS_INLINE, cb_InlineStyles_1);
return cb_InlineStyles_1;
}
JCheckBox addGreenstoneTags(HashMap<String, Component> configuration, UIPreferences preferences) {
cb_Greenstone_1 = new JCheckBox(Localizer.get(LABEL_GREENSTONE_SPLIT));
configuration.put(ARG_GREENSTONE, cb_Greenstone_1);
cb_Greenstone_1.setSelected(Boolean.parseBoolean(preferences.get(PREF_GREENSTONE_TAGS)));
return cb_Greenstone_1;
}
JTextField addOutputFileTextField(HashMap<String, Component> configuration, UIPreferences preferences) {
tf_OutputFile_1 = new JTextField("");
configuration.put(ARG_OUTPUT_FILE, tf_OutputFile_1);
tf_OutputFile_1.setColumns(10);
return tf_OutputFile_1;
}
JCheckBox addPagination(HashMap<String, Component> configuration, UIPreferences preferences) {
cb_Pagination_1 = new JCheckBox(Localizer.get(LABEL_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.valueOf(preferences.get(PREF_CONVERT_TO_PX)));
configuration.put(ARG_CONVERT_TO_PX, cb_convertToPx_1);
return cb_convertToPx_1;
}
JTextField addPageBreakStyle(HashMap<String, Component> configuration, UIPreferences preferences) {
tf_pageBreakInlineStyle_1 = new JTextField(preferences.get(PREF_PAGEBREAK_STYLES));
tf_pageBreakInlineStyle_1.setColumns(10);
configuration.put(ARG_PAGE_BREAK_STYLE, tf_pageBreakInlineStyle_1);
return tf_pageBreakInlineStyle_1;
}
JLabel addTargetFormat(String format, HashMap<String, Component> configuration) {
lb_TargetFormat_1 = new JLabel(format);
configuration.put(ARG_TARGET_FORMAT, lb_TargetFormat_1);
return lb_TargetFormat_1;
}
JTextField addScaling(HashMap<String, Component> configuration, UIPreferences preferences) {
tf_Scale_1 = new JTextField();
tf_Scale_1.setText(preferences.get(PREF_SCALING));
tf_Scale_1.setColumns(10);
configuration.put(ARG_SCALING, tf_Scale_1);
return tf_Scale_1;
}
JTextField addInputFile(HashMap<String, Component> configuration, UIPreferences preferences) {
tf_inputFile_1 = new JTextField(preferences.getSourceFileName());
tf_inputFile_1.setColumns(10);
configuration.put(ARG_INPUT_FILE, tf_inputFile_1);
return tf_inputFile_1;
}
JComboBox addImageResolution(HashMap<String, Component> configuration, UIPreferences preferences) {
cbox_image_resolution_1 = new JComboBox(preferences.getAll(PREF_RESOLUTIONS));
cbox_image_resolution_1.setSelectedIndex(Integer.parseInt(preferences.get(PREF_DEFAULT_IMAGE_RESOLUTION)));
configuration.put(ARG_IMAGE_RESOLUTION, cbox_image_resolution_1);
return cbox_image_resolution_1;
}
JComboBox addSplitByLevel(HashMap<String, Component> configuration, UIPreferences preferences) {
cbox_SplitByLevel_1 = new JComboBox(preferences.getAll(PREF_SPLIT_LEVELS));
configuration.put(ARG_SPLIT_LEVEL, cbox_SplitByLevel_1);
cbox_SplitByLevel_1.setSelectedIndex(Integer.parseInt(preferences.get(PREF_SPLIT_BY_LEVEL)));
return cbox_SplitByLevel_1;
}
JTextField addMaxWidth(HashMap<String, Component> configuration, UIPreferences preferences) {
tf_MaxWidth_1 = new JTextField(preferences.get(PREF_MAX_WIDTH));
tf_MaxWidth_1.setColumns(10);
configuration.put(ARG_MAX_WIDTH, tf_MaxWidth_1);
return tf_MaxWidth_1;
}
JCheckBox addEmbedRasterImages(HashMap<String, Component> configuration, UIPreferences preferences) {
cb_EmbedRaster_1 = new JCheckBox(Localizer.get(LABEL_EMBED_RASTER));
cb_EmbedRaster_1.setSelected(Boolean.parseBoolean(preferences.get(PREF_EMBED_RASTER)));
configuration.put(ARG_EMBED_IMG, cb_EmbedRaster_1);
return cb_EmbedRaster_1;
}
JCheckBox addEmbedVectorImages(HashMap<String, Component> configuration, UIPreferences preferences) {
cb_EmbedVectorImages_1 = new JCheckBox(Localizer.get(LABEL_EMBED_VECTOR));
cb_EmbedVectorImages_1.setSelected(Boolean.parseBoolean(preferences.get(PREF_EMBED_VECTOR)));
configuration.put(ARG_EMBED_SVG, cb_EmbedVectorImages_1);
return cb_EmbedVectorImages_1;
}
void setOutputFilePath(String newFilePath, JTextField tf_OutputFile, String extension) {
File inputFile = new File(newFilePath);
if (!inputFile.exists()) {
return;
}
if (!inputFile.isDirectory()) {
File parent = inputFile.getParentFile();
if (parent == null) {
return;
}
if (!parent.canWrite()) {
JOptionPane.showMessageDialog(ConfigurationWindow.getSingleFrame(), Localizer.get(CANT_WRITE_MESSAGE));
}
}
if (newFilePath.length() < 3) {
return;
}
String exportPath;
if (inputFile.isDirectory()) {
exportPath = newFilePath;
tf_OutputFile.setText(exportPath);
} else {
String importExt = newFilePath.substring(newFilePath.length() - 3, newFilePath.length()).toLowerCase();
if (importExt.equals(ODT_FILE_EXTENSION)) {
exportPath = newFilePath.substring(0, newFilePath.length() - 3) + extension;
tf_OutputFile.setText(exportPath);
}
}
}
JButton addChooseOutputButton(JTextField tf_OutputFile, String fileExtension) {
btn_ChooseOutputFile_1 = new JButton(Localizer.get(LABEL_BUTTON_CHOOSE));
btn_ChooseOutputFile_1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
FileDialog fileDialog = new FileDialog();
String newFilePath = fileDialog.chooseFile(tf_OutputFile.getText(),fileExtension);
if (newFilePath != null && !newFilePath.isEmpty()) {
tf_OutputFile.setText(newFilePath);
}
}
});
return btn_ChooseOutputFile_1;
}
public void setMetadataFilePath(String newFilePath, JTextField tf_MetadataFile, String extension) {
File inputFile = new File(newFilePath);
if (!inputFile.exists()) {
return;
}
if (inputFile.isDirectory()) {
tf_MetadataFile.setText(newFilePath);
} else {
File parent = inputFile.getParentFile();
if (parent == null) {
return;
}
if (newFilePath.length() < 3) {
return;
}
String importExt = newFilePath.substring(newFilePath.length()-3, newFilePath.length()).toLowerCase();
if (importExt.equals(ODT_FILE_EXTENSION)) {
String metadataPath = newFilePath.substring(0, newFilePath.length()-3) + extension;
File metaFile = new File(metadataPath);
if (metaFile.exists() && metaFile.canRead()){
tf_MetadataFile.setText(metadataPath);
} else {
tf_MetadataFile.setText("");
}
}
}
}
JButton addButtonChooseFile(JTextField tf_inputFile, JTextField tf_OutputFile) {
btn_chooseFile_1 = new JButton(Localizer.get(LABEL_BUTTON_CHOOSE));
btn_chooseFile_1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
String newFilePath = FileDialog.chooseFile(tf_inputFile.getText(),ODT_FILE_EXTENSION); String newFilePath = FileDialog.chooseFile(tf_inputFile.getText(),ODT_FILE_EXTENSION);
if (newFilePath != null && !newFilePath.isEmpty()) { if (newFilePath != null && !newFilePath.isEmpty()) {
@ -465,6 +230,9 @@ public class HTMLPanel extends JPanel{
} }
} }
}); });
return btn_chooseFile_1; return btn_chooseFile;
} }
} }

View file

@ -13,25 +13,12 @@ public class Localizer {
private String resourceBundle = "pro.litvinovg.w2phtml.gui.localizations.w2phtml"; private String resourceBundle = "pro.litvinovg.w2phtml.gui.localizations.w2phtml";
private ResourceBundle translations; private ResourceBundle translations;
private boolean isOld = false; private boolean isOld = false;
private static Localizer localizer = null; public Localizer() {
private Localizer() {
currentLocale = Locale.getDefault(); currentLocale = Locale.getDefault();
translations = ResourceBundle.getBundle(resourceBundle, currentLocale); translations = ResourceBundle.getBundle(resourceBundle, currentLocale);
this.isOld = isOldJava(); this.isOld = isOldJava();
} }
public static Localizer getInstance() {
if (localizer != null) {
return localizer;
}
localizer = new Localizer();
return localizer;
}
public static String get(String name) {
Localizer.getInstance();
return localizer.getTranslation(name);
}
public String getTranslation(String name) { public String getTranslation(String name) {
if (translations != null && translations.containsKey(name)) { if (translations != null && translations.containsKey(name)) {
String translation = translations.getString(name); String translation = translations.getString(name);

View file

@ -41,10 +41,6 @@ public class ODTDocument {
private XDispatchProvider dispatchProvider; private XDispatchProvider dispatchProvider;
XTextDocument textDocument; XTextDocument textDocument;
public ODTDocument(String fileName) {
this.fileName = fileName;
}
public ODTDocument(XComponentContext componentContext) { public ODTDocument(XComponentContext componentContext) {
if (componentContext != null) { if (componentContext != null) {
context = componentContext; context = componentContext;

View file

@ -2,7 +2,6 @@ package pro.litvinovg.w2phtml.gui;
import java.awt.Component; import java.awt.Component;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map;
import javax.swing.GroupLayout; import javax.swing.GroupLayout;
import javax.swing.JFrame; import javax.swing.JFrame;
@ -10,51 +9,39 @@ import javax.swing.JPanel;
import javax.swing.JTabbedPane; import javax.swing.JTabbedPane;
import javax.swing.GroupLayout.Alignment; import javax.swing.GroupLayout.Alignment;
import javax.swing.LayoutStyle.ComponentPlacement; import javax.swing.LayoutStyle.ComponentPlacement;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static pro.litvinovg.w2phtml.gui.Contstants.*; import static pro.litvinovg.w2phtml.gui.Contstants.*;
public class PanelFactory { public class PanelFactory {
private Localizer localizer; private Localizer localizer;
private JFrame singleFrame;
private PreferencesStorage storage; private PreferencesStorage storage;
private JTabbedPane tabbedPane; private JTabbedPane tabbedPane;
private static final Logger logger = LoggerFactory.getLogger(PanelFactory.class);
public PanelFactory(Localizer localizer, PreferencesStorage storage,JTabbedPane tabbedPane) { public PanelFactory(Localizer localizer,JFrame singleFrame, PreferencesStorage preferences,JTabbedPane tabbedPane) {
this.localizer = localizer; this.localizer = localizer;
this.storage = storage; this.singleFrame = singleFrame;
this.storage = preferences;
this.tabbedPane = tabbedPane; this.tabbedPane = tabbedPane;
} }
public JPanel createPanel(String name) { public JPanel createPanel(String type, String name) {
UIPreferences prefs = storage.get(name);
String type = prefs.get(PREF_TYPE);
JPanel panel = new JPanel(); JPanel panel = new JPanel();
HashMap<String, Component> configuration = new HashMap<String, Component>(); HashMap<String, Component> configuration = new HashMap<String, Component>();
ControlPanel panel_control = new ControlPanel(configuration, storage, name, type); JPanel panel_control = new ControlPanel(configuration, localizer, singleFrame);
panel_control.setFactory(this);
JPanel panel_configuration = null; JPanel panel_configuration = null;
if (EPUB.equals(type)){ if (EPUB.equals(type)){
panel_configuration = new EpubPanel(configuration, storage.get(name)); panel_configuration = new EpubPanel(configuration, localizer, storage.get(name,type),singleFrame);
} else if (RDF.equals(type)) { } else if (RDF.equals(type)) {
panel_configuration = new RDFPanel(configuration, storage.get(name)); panel_configuration = new RDFPanel(configuration, localizer, storage.get(name,type),singleFrame);
} else { } else {
panel_configuration = new HTMLPanel(configuration, storage.get(name)); panel_configuration = new HTMLPanel(configuration, localizer, storage.get(name,type),singleFrame);
} }
applyDefaultLayout(panel, panel_configuration, panel_control); applyDefaultLayout(panel, panel_configuration, panel_control);
tabbedPane.addTab(name, null, panel, null); tabbedPane.addTab(name, null, panel, null);
tabbedPane.setSelectedComponent(panel);
return panel; return panel;
} }
public void removeCurPanel() {
tabbedPane.removeTabAt(tabbedPane.getSelectedIndex());
}
private void applyDefaultLayout(JPanel tabbedPanel, JPanel configPanel, JPanel controlPanel) { private void applyDefaultLayout(JPanel tabbedPanel, JPanel configPanel, JPanel controlPanel) {
GroupLayout gl_panel_html = new GroupLayout(tabbedPanel); GroupLayout gl_panel_html = new GroupLayout(tabbedPanel);
@ -68,12 +55,5 @@ public class PanelFactory {
.addComponent(controlPanel, GroupLayout.PREFERRED_SIZE, 48, GroupLayout.PREFERRED_SIZE))); .addComponent(controlPanel, GroupLayout.PREFERRED_SIZE, 48, GroupLayout.PREFERRED_SIZE)));
tabbedPanel.setLayout(gl_panel_html); tabbedPanel.setLayout(gl_panel_html);
} }
public void createPanels() {
for (String name : storage.getTabNames()) {
if (!name.equals(HTML) && !name.equals(EPUB) && !name.equals(RDF)) {
createPanel(name);
}
}
}
} }

View file

@ -4,15 +4,10 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Set;
import java.util.prefs.Preferences; import java.util.prefs.Preferences;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import static pro.litvinovg.w2phtml.gui.Contstants.*; import static pro.litvinovg.w2phtml.gui.Contstants.*;
@ -21,180 +16,110 @@ import static pro.litvinovg.w2phtml.gui.Contstants.*;
public class PreferencesStorage { public class PreferencesStorage {
private static final Logger logger = LoggerFactory.getLogger(PreferencesStorage.class); private static final Logger logger = LoggerFactory.getLogger(PreferencesStorage.class);
private Map<String,UIPreferences> tabs; private Map<String,UIPreferences> preferences;
private Preferences storage; private Preferences storage;
public PreferencesStorage() { public PreferencesStorage() {
storage = Preferences.userRoot().node(this.getClass().getName()); initializeDefaults();
tabs = new HashMap(); storage = Preferences.userRoot();
read(); }
private void initializeDefaults() {
preferences = new HashMap();
initializeDefault(); initializeDefault();
} }
private void initializeDefault() { private void initializeDefault() {
tabs.put(HTML, getDefaultHTML(this)); initializeDefaultHTML();
tabs.put(EPUB,getDefaultEpub(this)); initializeDefaultEpub();
tabs.put(RDF,getDefaultRDF(this)); initializeDefaultRDF();
} }
public static UIPreferences getDefaultHTML(PreferencesStorage store) { private void initializeDefaultHTML() {
UIPreferences prefs = new UIPreferences(store); UIPreferences prefs = new UIPreferences();
prefs.put(PREF_RESOLUTIONS, new String[]{"0","72","150","300","600","1200","2400"} ); add(PREF_RESOLUTIONS, new String[]{"0","72","150","300","600","1200","2400"} , prefs);
prefs.put(PREF_DEFAULT_IMAGE_RESOLUTION,"2"); add(PREF_DEFAULT_IMAGE_RESOLUTION,"2", prefs);
prefs.put(PREF_USE_MATHJAX,"true"); add(PREF_USE_MATHJAX,"true", prefs);
prefs.put(PREF_IGNORE_EMPTY_PARS,"false"); add(PREF_IGNORE_EMPTY_PARS,"false", prefs);
prefs.put(PREF_IGNORE_HARD_BREAKS,"false"); add(PREF_IGNORE_HARD_BREAKS,"false", prefs);
prefs.put(PREF_GREENSTONE_TAGS,"false"); add(PREF_GREENSTONE_TAGS,"false", prefs);
prefs.put(PREF_LETTER_SPACING,"0.15"); add(PREF_LETTER_SPACING,"0.15",prefs);
prefs.put(PREF_INLINE_STYLES,"true"); add(PREF_INLINE_STYLES,"true", prefs);
prefs.put(PREF_EMBED_RASTER,"true"); add(PREF_EMBED_RASTER,"true", prefs);
prefs.put(PREF_EMBED_VECTOR,"true"); add(PREF_EMBED_VECTOR,"true", prefs);
prefs.put(PREF_CONVERT_TO_PX,"false"); add(PREF_PAGEBREAK_STYLES,DEFAULT_PAGEBREAK_STYLE_SETTINGS,prefs);
prefs.put(PREF_PAGEBREAK_STYLES,DEFAULT_PAGEBREAK_STYLE_SETTINGS); add(PREF_PAGINATION,"true",prefs);
prefs.put(PREF_PAGINATION,"true");
prefs.put(PREF_SPLIT_LEVELS, new String[]{"0","1","2","3","4","5","6","7","8","9","10"} ); preferences.put(HTML, prefs);
prefs.put(PREF_SPLIT_BY_LEVEL,"0");
prefs.put(PREF_TYPE,HTML);
prefs.put(PREF_MAX_WIDTH,"");
prefs.put(PREF_SPLIT_WHOLE_PAGES,"false");
prefs.put(PREF_SCALING, SCALING_DEFAULT_VALUE);
prefs.setDefault(true);
return prefs;
} }
public static UIPreferences getDefaultEpub(PreferencesStorage store) { private void initializeDefaultEpub() {
UIPreferences prefs = new UIPreferences(store); UIPreferences prefs = new UIPreferences();
prefs.put(PREF_RESOLUTIONS, new String[]{"0","72","150","300","600","1200","2400"}); add(PREF_RESOLUTIONS, new String[]{"0","72","150","300","600","1200","2400"} , prefs);
prefs.put(PREF_DEFAULT_IMAGE_RESOLUTION,"2"); add(PREF_DEFAULT_IMAGE_RESOLUTION,"2", prefs);
prefs.put(PREF_USE_MATHJAX,"true"); add(PREF_USE_MATHJAX,"true", prefs);
prefs.put(PREF_IGNORE_EMPTY_PARS,"false"); add(PREF_IGNORE_EMPTY_PARS,"false", prefs);
prefs.put(PREF_IGNORE_HARD_BREAKS,"false"); add(PREF_IGNORE_HARD_BREAKS,"false", prefs);
prefs.put(PREF_LETTER_SPACING,"0.15"); add(PREF_LETTER_SPACING,"0.15",prefs);
prefs.put(PREF_INLINE_STYLES,"true"); add(PREF_INLINE_STYLES,"true", prefs);
prefs.put(PREF_EMBED_RASTER,"true"); add(PREF_EMBED_RASTER,"true", prefs);
prefs.put(PREF_EMBED_VECTOR,"true"); add(PREF_EMBED_VECTOR,"true", prefs);
prefs.put(PREF_CONVERT_TO_PX,"false"); add(PREF_SCALING, SCALING_DEFAULT_VALUE, prefs);
prefs.put(PREF_SCALING, SCALING_DEFAULT_VALUE); add(PREF_PAGEBREAK_STYLES,DEFAULT_PAGEBREAK_STYLE_SETTINGS,prefs);
prefs.put(PREF_PAGEBREAK_STYLES,DEFAULT_PAGEBREAK_STYLE_SETTINGS); add(PREF_PAGINATION,"true",prefs);
prefs.put(PREF_PAGINATION,"true");
prefs.put(PREF_TYPE,EPUB); preferences.put(EPUB, prefs);
prefs.setDefault(true);
return prefs;
} }
public static UIPreferences getDefaultRDF(PreferencesStorage store) { private void initializeDefaultRDF() {
UIPreferences prefs = new UIPreferences(store); UIPreferences prefs = new UIPreferences();
prefs.put(PREF_PUBLICATION_TYPES, new String[]{"elenphArticle", "encArticle", "book", "journal"} ); add(PREF_PUBLICATION_TYPES, new String[]{"elenphArticle", "encArticle", "book", "journal"} , prefs);
prefs.put(PREF_RESOLUTIONS, new String[]{"0","72","150","300","600","1200","2400"} ); add(PREF_RESOLUTIONS, new String[]{"0","72","150","300","600","1200","2400"} , prefs);
prefs.put(PREF_DEFAULT_IMAGE_RESOLUTION,"2"); add(PREF_DEFAULT_IMAGE_RESOLUTION,"2", prefs);
prefs.put(PREF_DEFAULT_PUBLICATION_TYPE,"0"); add(PREF_DEFAULT_PUBLICATION_TYPE,"0", prefs);
prefs.put(PREF_USE_MATHJAX,"true"); add(PREF_USE_MATHJAX,"true", prefs);
prefs.put(PREF_IGNORE_EMPTY_PARS,"false"); add(PREF_IGNORE_EMPTY_PARS,"false", prefs);
prefs.put(PREF_IGNORE_HARD_BREAKS,"false"); add(PREF_IGNORE_HARD_BREAKS,"false", prefs);
prefs.put(PREF_LETTER_SPACING,"0.15"); add(PREF_LETTER_SPACING,"0.15",prefs);
prefs.put(PREF_INLINE_STYLES,"true"); add(PREF_INLINE_STYLES,"true", prefs);
prefs.put(PREF_EMBED_RASTER,"true"); add(PREF_EMBED_RASTER,"true", prefs);
prefs.put(PREF_EMBED_VECTOR,"true"); add(PREF_EMBED_VECTOR,"true", prefs);
prefs.put(PREF_CONVERT_TO_PX,"false"); add(PREF_PAGEBREAK_STYLES,DEFAULT_PAGEBREAK_STYLE_SETTINGS,prefs);
prefs.put(PREF_PAGEBREAK_STYLES,DEFAULT_PAGEBREAK_STYLE_SETTINGS); add(PREF_PAGINATION,"true",prefs);
prefs.put(PREF_TYPE,RDF);
prefs.put(PREF_SCALING, SCALING_DEFAULT_VALUE);
prefs.put(PREF_PAGINATION,"true");
prefs.setDefault(true);
return prefs;
}
public void put(String prefName, UIPreferences newPreferences) { preferences.put(RDF, prefs);
tabs.put(prefName, newPreferences);
}
public boolean has(String configName) {
return tabs.containsKey(configName);
} }
private void add(String key, String[] strings,UIPreferences prefs) { private void add(String key, String[] strings,UIPreferences prefs) {
prefs.put(key, strings); ArrayList<String> values = new ArrayList<String>(Arrays.asList(strings));
prefs.put(key, values);
} }
private void add(String key, String value,UIPreferences prefs) { private void add(String key, String value,UIPreferences prefs) {
prefs.put(key, new String[] {value}); ArrayList<String> values = new ArrayList<String>();
values.add(value);
prefs.put(key, values);
} }
public UIPreferences get(String name) { public UIPreferences get(String name, String type) {
if (tabs.containsKey(name)) { if (preferences.containsKey(name)) {
return tabs.get(name); return preferences.get(name);
} else { } else {
logger.error("Prefereneces with name " + name + " not found."); return preferences.get(type);
return null;
} }
} }
public void remove(String name) {
tabs.remove(name);
}
public void setSourceFileName(String fileName) { public void setSourceFileName(String fileName) {
Iterator<Entry<String, UIPreferences>> it = tabs.entrySet().iterator(); Iterator<Entry<String, UIPreferences>> it = preferences.entrySet().iterator();
while (it.hasNext()) { while (it.hasNext()) {
Entry<String, UIPreferences> pair = it.next(); Entry<String, UIPreferences> pair = it.next();
UIPreferences value = (UIPreferences) pair.getValue(); UIPreferences value = (UIPreferences) pair.getValue();
value.setSourceFileName(fileName); value.setSourceFileName(fileName);
} }
} }
public void save() {
String jsonPrefereneces = convertAllToJSON();
storage.put(TAB_PREFERENCES, jsonPrefereneces);
}
private String convertAllToJSON() {
JSONObject json = new JSONObject();
for (Map.Entry<String, UIPreferences> entry : tabs.entrySet()) {
String name = entry.getKey();
UIPreferences prefs = entry.getValue();
JSONObject json_prefs = prefs.getJSON();
json.put(name, json_prefs);
}
return json.toString();
}
public Set<String> getTabNames() {
return tabs.keySet();
}
private void read() {
String data = storage.get(TAB_PREFERENCES, null);
if (data == null) {
return;
}
try {
JSONObject json = new JSONObject(data);
Set<String> prefTabNames = json.keySet();
for (String prefTabName : prefTabNames) {
UIPreferences newPref = new UIPreferences(this);
JSONObject tabData = (JSONObject) json.get(prefTabName);
Set<String> prefKeys = tabData.keySet();
for (String name : prefKeys) {
JSONArray values = (JSONArray) tabData.get(name);
if (values != null) {
String[] valueArray = new String[values.length()];
for (int i=0;i<values.length();i++){
valueArray[i] = values.getString(i);
}
newPref.put(name, valueArray);
}
}
tabs.put(prefTabName, newPref);
}
} catch (JSONException e) {
logger.error("JSON parsing exception " + e.getLocalizedMessage());
e.printStackTrace();
} catch (Exception e) {
logger.error("JSON parsing exception " + e.getLocalizedMessage());
e.printStackTrace();
}
}
} }

View file

@ -3,242 +3,232 @@ package pro.litvinovg.w2phtml.gui;
import java.awt.Component; import java.awt.Component;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.io.File;
import java.util.HashMap; import java.util.HashMap;
import javax.swing.GroupLayout; import javax.swing.GroupLayout;
import javax.swing.JButton; import javax.swing.JButton;
import javax.swing.JCheckBox; import javax.swing.JCheckBox;
import javax.swing.JComboBox; import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField; import javax.swing.JTextField;
import javax.swing.GroupLayout.Alignment; import javax.swing.GroupLayout.Alignment;
import javax.swing.LayoutStyle.ComponentPlacement; import javax.swing.LayoutStyle.ComponentPlacement;
import static pro.litvinovg.w2phtml.gui.Contstants.*; import static pro.litvinovg.w2phtml.gui.Contstants.*;
import net.miginfocom.swing.MigLayout;
public class RDFPanel extends JPanel {
public class RDFPanel extends BasePanel {
/** /**
* *
*/ */
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private UIPreferences preferences;
private HashMap<String, Component> configuration;
private JComboBox cbox_image_resolution_1;
private JCheckBox cb_Pagination_1;
private JCheckBox cb_convertToPx_1;
private JCheckBox cb_EmbedRaster_1;
private JCheckBox cb_EmbedVectorImages_1;
private JTextField tf_FilterLetterSpacing_1;
private JCheckBox cb_InlineStyles_1;
private JLabel lb_TargetFormat_1;
private JTextField tf_OutputFile_1;
private JTextField tf_metadataPath_1;
private JTextField tf_inputFile_1;
private JButton btnChooseFile;
private JButton btn_metadataChoose_1;
private JButton btn_ChooseOutputFile_1;
private JTextField tf_pageBreakInlineStyle_1;
private JTextField tf_Scale_1;
private JComboBox cbox_type_1;
private JCheckBox cb_IgnoreEmptyParagraphs_1;
private JCheckBox cb_UseMathJax_1;
private JCheckBox cb_IgnoreHardLineBreaks_1;
public RDFPanel() { public RDFPanel(HashMap<String, Component> configuration, Localizer localizer, UIPreferences preferences,JFrame singleFrame) {
this.preferences = PreferencesStorage.getDefaultRDF(null); super(localizer, singleFrame, configuration, preferences);
this.configuration = new HashMap<String, Component>();
initComponents();
}
public RDFPanel(HashMap<String, Component> configuration, UIPreferences preferences) { JLabel lb_FilterLetterSpacing = new JLabel(localizer.getTranslation(LABEL_MIN_LETTER_SPACING));
this.configuration = configuration; JLabel lb_TargetFormat = addTargetFormat(RDF_TARGET_FORMAT);
this.preferences = preferences; JLabel lb_Scale = new JLabel(localizer.getTranslation(LABEL_SCALE));
initComponents(); JLabel lb_FilePath = new JLabel(localizer.getTranslation(LABEL_INPUT_FILE_PATH));
} JLabel lb_TargetFormat_description = new JLabel(localizer.getTranslation(LABEL_TARGET_FORMAT));
JLabel lb_OutFilePath = new JLabel(localizer.getTranslation(OUTPUT_FILE_PATH));
JLabel lb_ImageResolution = new JLabel(localizer.getTranslation(LABEL_IMAGE_RESOLUTION));
JLabel lb_type = new JLabel(localizer.getTranslation(LABEL_TYPE));
JLabel lb_metadataFilePath = new JLabel(localizer.getTranslation(LABEL_METADATA_PATH));
JLabel lb_pageBreakInlineStyle = new JLabel(localizer.getTranslation(LABEL_BREAK_STYLE));
private void initComponents() { JTextField tf_OutputFile = addOutputFileTextField();
JLabel lb_FilterLetterSpacing = new JLabel(Localizer.get(LABEL_MIN_LETTER_SPACING)); JTextField tf_FilterLetterSpacing = addLetterSpacingFilter();
JLabel lb_TargetFormat = addTargetFormat(RDF_TARGET_FORMAT,configuration); JTextField tf_Scale = addScaling();
JLabel lb_Scale = new JLabel(Localizer.get(LABEL_SCALE)); JTextField tf_inputFile = addInputFile();
JLabel lb_FilePath = new JLabel(Localizer.get(LABEL_INPUT_FILE_PATH));
JLabel lb_TargetFormat_description = new JLabel(Localizer.get(LABEL_TARGET_FORMAT));
JLabel lb_OutFilePath = new JLabel(Localizer.get(OUTPUT_FILE_PATH));
JLabel lb_ImageResolution = new JLabel(Localizer.get(LABEL_IMAGE_RESOLUTION));
JLabel lb_type = new JLabel(Localizer.get(LABEL_TYPE));
JLabel lb_metadataFilePath = new JLabel(Localizer.get(LABEL_METADATA_PATH));
JLabel lb_pageBreakInlineStyle = new JLabel(Localizer.get(LABEL_BREAK_STYLE));
JTextField tf_OutputFile = addOutputFileTextField(configuration,preferences);
JTextField tf_FilterLetterSpacing = addLetterSpacingFilter(configuration,preferences);
JTextField tf_Scale = addScaling(configuration,preferences);
JTextField tf_inputFile = addInputFile(configuration,preferences);
JTextField tf_metadataPath = addMetadataPath(configuration); JTextField tf_metadataPath = addMetadataPath(configuration);
JTextField tf_pageBreakInlineStyle = addPageBreakStyle(configuration,preferences); JTextField tf_pageBreakInlineStyle = addPageBreakStyle();
JCheckBox cb_UseMathJax = addMathJaxCB(configuration,preferences); JCheckBox cb_UseMathJax = addMathJaxCB();
JCheckBox cb_IgnoreEmptyParagraphs = addIgnoreEmptyParsCB(configuration,preferences); JCheckBox cb_IgnoreEmptyParagraphs = addIgnoreEmptyParsCB();
JCheckBox cb_IgnoreHardLineBreaks = addIgnoreHardLineBreaks(configuration,preferences); JCheckBox cb_IgnoreHardLineBreaks = addIgnoreHardLineBreaks();
JCheckBox cb_InlineStyles = addInlineStyles(configuration,preferences); JCheckBox cb_InlineStyles = addInlineStyles();
cb_InlineStyles.setEnabled(false); cb_InlineStyles.setEnabled(false);
JCheckBox cb_EmbedVectorImages = addEmbedVectorImages(configuration,preferences); JCheckBox cb_EmbedVectorImages = addEmbedVectorImages();
cb_EmbedVectorImages.setEnabled(false); cb_EmbedVectorImages.setEnabled(false);
JCheckBox cb_EmbedRaster = addEmbedRasterImages(configuration,preferences); JCheckBox cb_EmbedRaster = addEmbedRasterImages();
cb_EmbedRaster.setEnabled(false); cb_EmbedRaster.setEnabled(false);
JCheckBox cb_convertToPx = addConvertToPX(configuration,preferences); JCheckBox cb_convertToPx = addConvertToPX();
JCheckBox cb_Pagination = addPagination(configuration,preferences); JCheckBox cb_Pagination = addPagination();
JComboBox cbox_image_resolution = addImageResolution(configuration,preferences); JComboBox cbox_image_resolution = addImageResolution();
JComboBox cbox_type = addPubTypes(configuration, preferences); JComboBox cbox_type = addPubTypes(configuration, preferences);
JButton btn_ChooseOutputFile = addChooseOutputButton(tf_OutputFile, RDF_FILE_EXTENSION); JButton btn_ChooseOutputFile = addChooseOutputButton(tf_OutputFile, RDF_FILE_EXTENSION);
JButton btn_ChooseFile = addChooseFile(tf_OutputFile, tf_inputFile, tf_metadataPath); JButton btn_ChooseFile = addChooseFile(localizer, tf_OutputFile, tf_inputFile, tf_metadataPath);
JButton btn_metadataChoose = addMetadataButton(tf_metadataPath); JButton btn_metadataChoose = addMetadataButton(localizer, tf_metadataPath);
GroupLayout groupLayout = new GroupLayout(this);
groupLayout.setHorizontalGroup( GroupLayout gl_panel_configHTML = new GroupLayout(this);
groupLayout.createParallelGroup(Alignment.LEADING) gl_panel_configHTML.setHorizontalGroup(
.addGroup(groupLayout.createSequentialGroup() gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addGap(6) .addGroup(gl_panel_configHTML.createSequentialGroup()
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING) .addGap(32)
.addGroup(groupLayout.createSequentialGroup() .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addComponent(lb_metadataFilePath, GroupLayout.PREFERRED_SIZE, 198, GroupLayout.PREFERRED_SIZE) .addGroup(gl_panel_configHTML.createSequentialGroup()
.addGap(12) .addComponent(lb_ImageResolution, GroupLayout.PREFERRED_SIZE, 369, GroupLayout.PREFERRED_SIZE)
.addComponent(tf_metadataPath_1, GroupLayout.DEFAULT_SIZE, 448, Short.MAX_VALUE) .addGap(4)
.addGap(19) .addComponent(cbox_image_resolution, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
.addComponent(btn_metadataChoose_1, GroupLayout.PREFERRED_SIZE, 115, GroupLayout.PREFERRED_SIZE)) .addContainerGap())
.addGroup(groupLayout.createSequentialGroup() .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addComponent(lb_OutFilePath, GroupLayout.PREFERRED_SIZE, 198, GroupLayout.PREFERRED_SIZE) .addGroup(gl_panel_configHTML.createSequentialGroup()
.addGap(12) .addComponent(cb_Pagination, GroupLayout.PREFERRED_SIZE, 303, GroupLayout.PREFERRED_SIZE)
.addComponent(tf_OutputFile_1, GroupLayout.DEFAULT_SIZE, 448, Short.MAX_VALUE) .addContainerGap())
.addGap(19) .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addComponent(btn_ChooseOutputFile_1, GroupLayout.PREFERRED_SIZE, 115, GroupLayout.PREFERRED_SIZE)) .addGroup(gl_panel_configHTML.createSequentialGroup()
.addGroup(groupLayout.createSequentialGroup() .addComponent(cb_convertToPx, GroupLayout.PREFERRED_SIZE, 592, GroupLayout.PREFERRED_SIZE)
.addComponent(lb_pageBreakInlineStyle, GroupLayout.PREFERRED_SIZE, 198, GroupLayout.PREFERRED_SIZE) .addContainerGap())
.addGap(12) .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addComponent(tf_pageBreakInlineStyle_1, GroupLayout.DEFAULT_SIZE, 582, Short.MAX_VALUE)) .addGroup(gl_panel_configHTML.createSequentialGroup()
.addGroup(groupLayout.createSequentialGroup() .addComponent(cb_EmbedRaster)
.addComponent(lb_type, GroupLayout.PREFERRED_SIZE, 71, GroupLayout.PREFERRED_SIZE) .addContainerGap())
.addGap(27) .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addComponent(cbox_type_1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addGroup(gl_panel_configHTML.createSequentialGroup()
.addComponent(cb_InlineStyles_1) .addComponent(cb_EmbedVectorImages)
.addComponent(cb_EmbedVectorImages_1) .addContainerGap())
.addComponent(cb_EmbedRaster_1) .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addComponent(cb_convertToPx_1, GroupLayout.PREFERRED_SIZE, 658, GroupLayout.PREFERRED_SIZE) .addGroup(gl_panel_configHTML.createSequentialGroup()
.addComponent(cb_IgnoreHardLineBreaks_1, GroupLayout.PREFERRED_SIZE, 382, GroupLayout.PREFERRED_SIZE) .addComponent(lb_FilterLetterSpacing)
.addComponent(cb_IgnoreEmptyParagraphs_1, GroupLayout.PREFERRED_SIZE, 382, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED)
.addComponent(cb_UseMathJax_1, GroupLayout.PREFERRED_SIZE, 382, GroupLayout.PREFERRED_SIZE) .addComponent(tf_FilterLetterSpacing, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(cb_Pagination_1, GroupLayout.PREFERRED_SIZE, 382, GroupLayout.PREFERRED_SIZE) .addGap(599))
.addGroup(groupLayout.createSequentialGroup() .addGroup(gl_panel_configHTML.createSequentialGroup()
.addPreferredGap(ComponentPlacement.RELATED) .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addComponent(lb_ImageResolution, GroupLayout.PREFERRED_SIZE, 245, GroupLayout.PREFERRED_SIZE) .addComponent(cb_InlineStyles)
.addPreferredGap(ComponentPlacement.RELATED) .addGroup(gl_panel_configHTML.createSequentialGroup()
.addComponent(cbox_image_resolution_1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.RELATED)
.addGroup(groupLayout.createSequentialGroup() .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addComponent(lb_Scale, GroupLayout.PREFERRED_SIZE, 83, GroupLayout.PREFERRED_SIZE) .addComponent(lb_TargetFormat_description, GroupLayout.PREFERRED_SIZE, 311, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.RELATED) .addGroup(gl_panel_configHTML.createSequentialGroup()
.addComponent(tf_Scale_1, GroupLayout.PREFERRED_SIZE, 60, GroupLayout.PREFERRED_SIZE)) .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addGroup(groupLayout.createSequentialGroup() .addComponent(lb_FilePath, GroupLayout.PREFERRED_SIZE, 176, GroupLayout.PREFERRED_SIZE)
.addComponent(lb_FilterLetterSpacing) .addComponent(lb_metadataFilePath, GroupLayout.PREFERRED_SIZE, 177, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.RELATED) .addComponent(lb_OutFilePath, GroupLayout.PREFERRED_SIZE, 187, GroupLayout.PREFERRED_SIZE))
.addComponent(tf_FilterLetterSpacing_1, GroupLayout.PREFERRED_SIZE, 52, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.RELATED)
.addGroup(groupLayout.createSequentialGroup() .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addGroup(groupLayout.createParallelGroup(Alignment.TRAILING, false) .addComponent(lb_TargetFormat, GroupLayout.PREFERRED_SIZE, 68, GroupLayout.PREFERRED_SIZE)
.addComponent(lb_TargetFormat_description, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(tf_OutputFile, GroupLayout.DEFAULT_SIZE, 561, Short.MAX_VALUE)
.addComponent(lb_FilePath, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 198, Short.MAX_VALUE)) .addGroup(gl_panel_configHTML.createSequentialGroup()
.addGap(12) .addComponent(tf_metadataPath, GroupLayout.DEFAULT_SIZE, 560, Short.MAX_VALUE)
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING) .addGap(1))
.addComponent(lb_TargetFormat_1, GroupLayout.PREFERRED_SIZE, 29, GroupLayout.PREFERRED_SIZE) .addGroup(gl_panel_configHTML.createSequentialGroup()
.addGroup(groupLayout.createSequentialGroup() .addComponent(tf_inputFile, GroupLayout.DEFAULT_SIZE, 558, Short.MAX_VALUE)
.addComponent(tf_inputFile_1, GroupLayout.DEFAULT_SIZE, 448, Short.MAX_VALUE) .addGap(3)))))
.addGap(19) .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addComponent(btnChooseFile, GroupLayout.PREFERRED_SIZE, 115, GroupLayout.PREFERRED_SIZE))))) .addGroup(gl_panel_configHTML.createSequentialGroup()
.addGap(6)) .addGap(11)
.addComponent(btn_ChooseFile, GroupLayout.PREFERRED_SIZE, 113, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_panel_configHTML.createSequentialGroup()
.addGap(12)
.addComponent(btn_metadataChoose, GroupLayout.PREFERRED_SIZE, 113, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_panel_configHTML.createSequentialGroup()
.addGap(11)
.addComponent(btn_ChooseOutputFile, GroupLayout.PREFERRED_SIZE, 113, GroupLayout.PREFERRED_SIZE)))
.addGap(149))
.addGroup(gl_panel_configHTML.createSequentialGroup()
.addComponent(lb_pageBreakInlineStyle, GroupLayout.PREFERRED_SIZE, 196, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(tf_pageBreakInlineStyle, GroupLayout.DEFAULT_SIZE, 681, Short.MAX_VALUE)
.addGap(145))
.addGroup(gl_panel_configHTML.createSequentialGroup()
.addComponent(lb_type, GroupLayout.PREFERRED_SIZE, 148, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.RELATED)
.addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addComponent(tf_Scale, GroupLayout.PREFERRED_SIZE, 98, GroupLayout.PREFERRED_SIZE)
.addComponent(cbox_type, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))))
.addGap(21))
.addGroup(gl_panel_configHTML.createSequentialGroup()
.addComponent(lb_Scale, GroupLayout.PREFERRED_SIZE, 137, GroupLayout.PREFERRED_SIZE)
.addContainerGap())))))
.addGroup(gl_panel_configHTML.createSequentialGroup()
.addComponent(cb_IgnoreEmptyParagraphs, GroupLayout.PREFERRED_SIZE, 339, GroupLayout.PREFERRED_SIZE)
.addContainerGap())
.addGroup(gl_panel_configHTML.createSequentialGroup()
.addComponent(cb_UseMathJax, GroupLayout.PREFERRED_SIZE, 345, GroupLayout.PREFERRED_SIZE)
.addContainerGap())
.addGroup(gl_panel_configHTML.createSequentialGroup()
.addComponent(cb_IgnoreHardLineBreaks, GroupLayout.PREFERRED_SIZE, 344, GroupLayout.PREFERRED_SIZE)
.addContainerGap()))))
); );
groupLayout.setVerticalGroup( gl_panel_configHTML.setVerticalGroup(
groupLayout.createParallelGroup(Alignment.LEADING) gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addGroup(groupLayout.createSequentialGroup() .addGroup(gl_panel_configHTML.createSequentialGroup()
.addGap(6) .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING) .addGroup(gl_panel_configHTML.createSequentialGroup()
.addComponent(lb_TargetFormat_description) .addContainerGap()
.addComponent(lb_TargetFormat_1)) .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.BASELINE)
.addPreferredGap(ComponentPlacement.RELATED) .addComponent(lb_TargetFormat_description)
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING) .addComponent(lb_TargetFormat))
.addGroup(groupLayout.createSequentialGroup() .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addGap(5) .addGroup(gl_panel_configHTML.createSequentialGroup()
.addComponent(lb_FilePath)) .addGap(22)
.addGroup(groupLayout.createSequentialGroup() .addComponent(tf_inputFile, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addGap(3) .addGroup(gl_panel_configHTML.createSequentialGroup()
.addComponent(tf_inputFile_1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addGap(24)
.addComponent(btnChooseFile)) .addComponent(lb_FilePath, GroupLayout.PREFERRED_SIZE, 19, GroupLayout.PREFERRED_SIZE)))
.addGap(6)
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
.addGroup(groupLayout.createSequentialGroup()
.addGap(5)
.addComponent(lb_metadataFilePath))
.addGroup(groupLayout.createSequentialGroup()
.addGap(6)
.addComponent(tf_metadataPath_1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addComponent(btn_metadataChoose_1))
.addGap(6)
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
.addGroup(groupLayout.createSequentialGroup()
.addGap(5)
.addComponent(lb_OutFilePath))
.addGroup(groupLayout.createSequentialGroup()
.addGap(3)
.addComponent(tf_OutputFile_1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addComponent(btn_ChooseOutputFile_1))
.addGap(6)
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
.addComponent(lb_pageBreakInlineStyle, GroupLayout.PREFERRED_SIZE, 23, GroupLayout.PREFERRED_SIZE)
.addGroup(groupLayout.createSequentialGroup()
.addGap(2)
.addComponent(tf_pageBreakInlineStyle_1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
.addGroup(groupLayout.createSequentialGroup()
.addGap(11)
.addComponent(lb_type))
.addGroup(groupLayout.createSequentialGroup()
.addPreferredGap(ComponentPlacement.UNRELATED) .addPreferredGap(ComponentPlacement.UNRELATED)
.addComponent(cbox_type_1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))) .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.LEADING)
.addGap(8) .addComponent(tf_metadataPath, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE) .addComponent(lb_metadataFilePath, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE))
.addPreferredGap(ComponentPlacement.UNRELATED)
.addGroup(gl_panel_configHTML.createParallelGroup(Alignment.BASELINE)
.addComponent(lb_OutFilePath, GroupLayout.PREFERRED_SIZE, 18, GroupLayout.PREFERRED_SIZE)
.addComponent(tf_OutputFile, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))
.addGroup(gl_panel_configHTML.createSequentialGroup()
.addGap(46)
.addComponent(btn_ChooseFile)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(btn_metadataChoose)
.addGap(7)
.addComponent(btn_ChooseOutputFile)))
.addGap(20)
.addGroup(gl_panel_configHTML.createParallelGroup(Alignment.BASELINE)
.addComponent(lb_pageBreakInlineStyle, GroupLayout.PREFERRED_SIZE, 23, GroupLayout.PREFERRED_SIZE)
.addComponent(tf_pageBreakInlineStyle, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addGap(18)
.addGroup(gl_panel_configHTML.createParallelGroup(Alignment.BASELINE)
.addComponent(lb_type)
.addComponent(cbox_type, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addPreferredGap(ComponentPlacement.UNRELATED)
.addGroup(gl_panel_configHTML.createParallelGroup(Alignment.BASELINE)
.addComponent(lb_Scale) .addComponent(lb_Scale)
.addComponent(tf_Scale_1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addComponent(tf_Scale, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addGap(10) .addPreferredGap(ComponentPlacement.UNRELATED)
.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE) .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.BASELINE)
.addComponent(lb_FilterLetterSpacing) .addComponent(lb_FilterLetterSpacing)
.addComponent(tf_FilterLetterSpacing_1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addComponent(tf_FilterLetterSpacing, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addGap(8) .addGap(10)
.addComponent(cb_InlineStyles_1) .addComponent(cb_InlineStyles)
.addGap(6) .addPreferredGap(ComponentPlacement.UNRELATED)
.addComponent(cb_EmbedVectorImages_1) .addComponent(cb_EmbedVectorImages)
.addGap(6) .addPreferredGap(ComponentPlacement.UNRELATED)
.addComponent(cb_EmbedRaster_1) .addComponent(cb_EmbedRaster)
.addGap(6) .addPreferredGap(ComponentPlacement.UNRELATED)
.addComponent(cb_convertToPx_1) .addComponent(cb_convertToPx)
.addGap(6) .addPreferredGap(ComponentPlacement.UNRELATED)
.addComponent(cb_IgnoreHardLineBreaks_1) .addComponent(cb_IgnoreHardLineBreaks)
.addGap(6) .addPreferredGap(ComponentPlacement.UNRELATED)
.addComponent(cb_IgnoreEmptyParagraphs_1) .addComponent(cb_IgnoreEmptyParagraphs)
.addGap(6) .addPreferredGap(ComponentPlacement.UNRELATED)
.addComponent(cb_UseMathJax_1) .addComponent(cb_UseMathJax)
.addGap(6) .addPreferredGap(ComponentPlacement.RELATED)
.addComponent(cb_Pagination_1) .addComponent(cb_Pagination)
.addGap(11) .addPreferredGap(ComponentPlacement.RELATED)
.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE) .addGroup(gl_panel_configHTML.createParallelGroup(Alignment.BASELINE)
.addComponent(lb_ImageResolution, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(lb_ImageResolution)
.addComponent(cbox_image_resolution_1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addComponent(cbox_image_resolution, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addContainerGap()) .addContainerGap(87, Short.MAX_VALUE))
); );
setLayout(groupLayout); this.setLayout(gl_panel_configHTML);
} }
private JButton addMetadataButton( JTextField tf_metadataPath) { private JButton addMetadataButton(Localizer localizer, JTextField tf_metadataPath) {
btn_metadataChoose_1 = new JButton(Localizer.get(LABEL_BUTTON_CHOOSE)); JButton btn_metadataChoose = new JButton(localizer.getTranslation(LABEL_BUTTON_CHOOSE));
btn_metadataChoose_1.addActionListener(new ActionListener() { btn_metadataChoose.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
String newFilePath = FileDialog.chooseFile(tf_metadataPath.getText(),CSV_FILE_EXTENSION); String newFilePath = FileDialog.chooseFile(tf_metadataPath.getText(),CSV_FILE_EXTENSION);
if (newFilePath != null && !newFilePath.isEmpty()) { if (newFilePath != null && !newFilePath.isEmpty()) {
@ -246,19 +236,19 @@ public class RDFPanel extends JPanel {
} }
} }
}); });
return btn_metadataChoose_1; return btn_metadataChoose;
} }
private JTextField addMetadataPath(HashMap<String, Component> configuration) { private JTextField addMetadataPath(HashMap<String, Component> configuration) {
tf_metadataPath_1 = new JTextField(""); JTextField tf_metadataPath = new JTextField("");
tf_metadataPath_1.setColumns(10); tf_metadataPath.setColumns(10);
configuration.put(ARG_CSV_METADATA, tf_metadataPath_1); configuration.put(ARG_CSV_METADATA, tf_metadataPath);
return tf_metadataPath_1; return tf_metadataPath;
} }
private JButton addChooseFile( JTextField tf_OutputFile, JTextField tf_inputFile, private JButton addChooseFile(Localizer localizer, JTextField tf_OutputFile, JTextField tf_inputFile,
JTextField tf_metadataPath) { JTextField tf_metadataPath) {
btnChooseFile = new JButton(Localizer.get(LABEL_BUTTON_CHOOSE)); JButton btnChooseFile = new JButton(localizer.getTranslation(LABEL_BUTTON_CHOOSE));
btnChooseFile.addActionListener(new ActionListener() { btnChooseFile.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
String newFilePath = FileDialog.chooseFile(tf_inputFile.getText(),ODT_FILE_EXTENSION); String newFilePath = FileDialog.chooseFile(tf_inputFile.getText(),ODT_FILE_EXTENSION);
@ -273,222 +263,11 @@ public class RDFPanel extends JPanel {
} }
private JComboBox addPubTypes(HashMap<String, Component> configuration, UIPreferences preferences) { private JComboBox addPubTypes(HashMap<String, Component> configuration, UIPreferences preferences) {
cbox_type_1 = new JComboBox(preferences.getAll(PREF_PUBLICATION_TYPES)); JComboBox cbox_type = new JComboBox(preferences.getAll(PREF_PUBLICATION_TYPES));
cbox_type_1.setSelectedIndex(Integer.parseInt(preferences.get(PREF_DEFAULT_PUBLICATION_TYPE))); cbox_type.setSelectedIndex(Integer.parseInt(preferences.get(PREF_DEFAULT_PUBLICATION_TYPE)));
configuration.put(ARG_RDF_TYPE, cbox_type_1); configuration.put(ARG_RDF_TYPE, cbox_type);
return cbox_type_1; return cbox_type;
}
//Shared methods added here to make WindowBuilder work
JCheckBox addMathJaxCB(HashMap<String, Component> configuration, UIPreferences preferences) {
cb_UseMathJax_1 = new JCheckBox(Localizer.get(LABEL_USE_MATHJAX));
cb_UseMathJax_1.setSelected(Boolean.parseBoolean(preferences.get(PREF_USE_MATHJAX)));
configuration.put(ARG_USE_MATHJAX, cb_UseMathJax_1);
return cb_UseMathJax_1;
} }
JCheckBox addIgnoreEmptyParsCB(HashMap<String, Component> configuration, UIPreferences preferences) {
cb_IgnoreEmptyParagraphs_1 = new JCheckBox(Localizer.get(LABEL_INGNORE_EMPTY_PARS));
cb_IgnoreEmptyParagraphs_1.setSelected(Boolean.parseBoolean(preferences.get(PREF_IGNORE_EMPTY_PARS)));
configuration.put(ARG_IGNORE_EMPTY_PARAGRAPHS, cb_IgnoreEmptyParagraphs_1);
return cb_IgnoreEmptyParagraphs_1;
}
JCheckBox addSplitWholePagesOnly(HashMap<String, Component> configuration, UIPreferences preferences) {
JCheckBox cb_SplitWholePagesOnly = new JCheckBox(Localizer.get(LABEL_SPLIT_WHOLE_PAGES_ONLY));
cb_SplitWholePagesOnly.setSelected(Boolean.parseBoolean(preferences.get(PREF_SPLIT_WHOLE_PAGES)));
configuration.put(ARG_ALIGN_SPLITS_TO_PAGES, cb_SplitWholePagesOnly);
return cb_SplitWholePagesOnly;
}
JCheckBox addIgnoreHardLineBreaks(HashMap<String, Component> configuration, UIPreferences preferences) {
cb_IgnoreHardLineBreaks_1 = new JCheckBox(Localizer.get(LABEL_FILETER_HARD_LINE_BREAKS));
cb_IgnoreHardLineBreaks_1.setSelected(Boolean.parseBoolean(preferences.get(PREF_IGNORE_HARD_BREAKS)));
configuration.put(ARG_IGNORE_HARD_LINE_BREAKS, cb_IgnoreHardLineBreaks_1);
return cb_IgnoreHardLineBreaks_1;
}
JTextField addLetterSpacingFilter(HashMap<String, Component> configuration, UIPreferences preferences) {
tf_FilterLetterSpacing_1 = new JTextField();
tf_FilterLetterSpacing_1.setText(preferences.get(PREF_LETTER_SPACING));
configuration.put(ARG_MIN_LETTER_SPACING, tf_FilterLetterSpacing_1);
tf_FilterLetterSpacing_1.setColumns(10);
return tf_FilterLetterSpacing_1;
}
JCheckBox addInlineStyles(HashMap<String, Component> configuration, UIPreferences preferences) {
cb_InlineStyles_1 = new JCheckBox(Localizer.get(LABEL_INLINE_STYLES));
cb_InlineStyles_1.setSelected(Boolean.parseBoolean(preferences.get(PREF_INLINE_STYLES)));
configuration.put(ARG_CSS_INLINE, cb_InlineStyles_1);
return cb_InlineStyles_1;
}
JCheckBox addGreenstoneTags(HashMap<String, Component> configuration, UIPreferences preferences) {
JCheckBox cb_Greenstone = new JCheckBox(Localizer.get(LABEL_GREENSTONE_SPLIT));
configuration.put(ARG_GREENSTONE, cb_Greenstone);
cb_Greenstone.setSelected(Boolean.parseBoolean(preferences.get(PREF_GREENSTONE_TAGS)));
return cb_Greenstone;
}
JTextField addOutputFileTextField(HashMap<String, Component> configuration, UIPreferences preferences) {
tf_OutputFile_1 = new JTextField("");
configuration.put(ARG_OUTPUT_FILE, tf_OutputFile_1);
tf_OutputFile_1.setColumns(10);
return tf_OutputFile_1;
}
JCheckBox addPagination(HashMap<String, Component> configuration, UIPreferences preferences) {
cb_Pagination_1 = new JCheckBox(Localizer.get(LABEL_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.valueOf(preferences.get(PREF_CONVERT_TO_PX)));
configuration.put(ARG_CONVERT_TO_PX, cb_convertToPx_1);
return cb_convertToPx_1;
}
JTextField addPageBreakStyle(HashMap<String, Component> configuration, UIPreferences preferences) {
tf_pageBreakInlineStyle_1 = new JTextField(preferences.get(PREF_PAGEBREAK_STYLES));
tf_pageBreakInlineStyle_1.setColumns(10);
configuration.put(ARG_PAGE_BREAK_STYLE, tf_pageBreakInlineStyle_1);
return tf_pageBreakInlineStyle_1;
}
JLabel addTargetFormat(String format, HashMap<String, Component> configuration) {
lb_TargetFormat_1 = new JLabel(format);
configuration.put(ARG_TARGET_FORMAT, lb_TargetFormat_1);
return lb_TargetFormat_1;
}
JTextField addScaling(HashMap<String, Component> configuration, UIPreferences preferences) {
tf_Scale_1 = new JTextField();
tf_Scale_1.setText(preferences.get(PREF_SCALING));
tf_Scale_1.setColumns(10);
configuration.put(ARG_SCALING, tf_Scale_1);
return tf_Scale_1;
}
JTextField addInputFile(HashMap<String, Component> configuration, UIPreferences preferences) {
tf_inputFile_1 = new JTextField(preferences.getSourceFileName());
tf_inputFile_1.setColumns(10);
configuration.put(ARG_INPUT_FILE, tf_inputFile_1);
return tf_inputFile_1;
}
JComboBox addImageResolution(HashMap<String, Component> configuration, UIPreferences preferences) {
cbox_image_resolution_1 = new JComboBox(preferences.getAll(PREF_RESOLUTIONS));
cbox_image_resolution_1.setSelectedIndex(Integer.parseInt(preferences.get(PREF_DEFAULT_IMAGE_RESOLUTION)));
configuration.put(ARG_IMAGE_RESOLUTION, cbox_image_resolution_1);
return cbox_image_resolution_1;
}
JComboBox addSplitByLevel(HashMap<String, Component> configuration, UIPreferences preferences) {
JComboBox cbox_SplitByLevel = new JComboBox(preferences.getAll(PREF_SPLIT_LEVELS));
configuration.put(ARG_SPLIT_LEVEL, cbox_SplitByLevel);
cbox_SplitByLevel.setSelectedIndex(Integer.parseInt(preferences.get(PREF_SPLIT_BY_LEVEL)));
return cbox_SplitByLevel;
}
JTextField addMaxWidth(HashMap<String, Component> configuration, UIPreferences preferences) {
JTextField tf_MaxWidth = new JTextField(preferences.get(PREF_MAX_WIDTH));
tf_MaxWidth.setColumns(10);
configuration.put(ARG_MAX_WIDTH, tf_MaxWidth);
return tf_MaxWidth;
}
JCheckBox addEmbedRasterImages(HashMap<String, Component> configuration, UIPreferences preferences) {
cb_EmbedRaster_1 = new JCheckBox(Localizer.get(LABEL_EMBED_RASTER));
cb_EmbedRaster_1.setSelected(Boolean.parseBoolean(preferences.get(PREF_EMBED_RASTER)));
configuration.put(ARG_EMBED_IMG, cb_EmbedRaster_1);
return cb_EmbedRaster_1;
}
JCheckBox addEmbedVectorImages(HashMap<String, Component> configuration, UIPreferences preferences) {
cb_EmbedVectorImages_1 = new JCheckBox(Localizer.get(LABEL_EMBED_VECTOR));
cb_EmbedVectorImages_1.setSelected(Boolean.parseBoolean(preferences.get(PREF_EMBED_VECTOR)));
configuration.put(ARG_EMBED_SVG, cb_EmbedVectorImages_1);
return cb_EmbedVectorImages_1;
}
void setOutputFilePath(String newFilePath, JTextField tf_OutputFile, String extension) {
File inputFile = new File(newFilePath);
if (!inputFile.exists()) {
return;
}
if (!inputFile.isDirectory()) {
File parent = inputFile.getParentFile();
if (parent == null) {
return;
}
if (!parent.canWrite()) {
JOptionPane.showMessageDialog(ConfigurationWindow.getSingleFrame(), Localizer.get(CANT_WRITE_MESSAGE));
}
}
if (newFilePath.length() < 3) {
return;
}
String exportPath;
if (inputFile.isDirectory()) {
exportPath = newFilePath;
tf_OutputFile.setText(exportPath);
} else {
String importExt = newFilePath.substring(newFilePath.length() - 3, newFilePath.length()).toLowerCase();
if (importExt.equals(ODT_FILE_EXTENSION)) {
exportPath = newFilePath.substring(0, newFilePath.length() - 3) + extension;
tf_OutputFile.setText(exportPath);
}
}
}
JButton addChooseOutputButton(JTextField tf_OutputFile, String fileExtension) {
btn_ChooseOutputFile_1 = new JButton(Localizer.get(LABEL_BUTTON_CHOOSE));
btn_ChooseOutputFile_1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
FileDialog fileDialog = new FileDialog();
String newFilePath = fileDialog.chooseFile(tf_OutputFile.getText(),fileExtension);
if (newFilePath != null && !newFilePath.isEmpty()) {
tf_OutputFile.setText(newFilePath);
}
}
});
return btn_ChooseOutputFile_1;
}
public void setMetadataFilePath(String newFilePath, JTextField tf_MetadataFile, String extension) {
File inputFile = new File(newFilePath);
if (!inputFile.exists()) {
return;
}
if (inputFile.isDirectory()) {
tf_MetadataFile.setText(newFilePath);
} else {
File parent = inputFile.getParentFile();
if (parent == null) {
return;
}
if (newFilePath.length() < 3) {
return;
}
String importExt = newFilePath.substring(newFilePath.length()-3, newFilePath.length()).toLowerCase();
if (importExt.equals(ODT_FILE_EXTENSION)) {
String metadataPath = newFilePath.substring(0, newFilePath.length()-3) + extension;
File metaFile = new File(metadataPath);
if (metaFile.exists() && metaFile.canRead()){
tf_MetadataFile.setText(metadataPath);
} else {
tf_MetadataFile.setText("");
}
}
}
}
} }

View file

@ -2,10 +2,12 @@ package pro.litvinovg.w2phtml.gui;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.FlowLayout; import java.awt.FlowLayout;
import java.util.Iterator;
import java.util.Map;
import javax.swing.JButton; import javax.swing.JButton;
import javax.swing.JDialog; import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.border.EmptyBorder; import javax.swing.border.EmptyBorder;
@ -14,20 +16,16 @@ import pro.litvinovg.w2phtml.SingleLogArray;
import javax.swing.GroupLayout; import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment; import javax.swing.GroupLayout.Alignment;
import javax.swing.JTextArea; import javax.swing.JTextArea;
import javax.swing.JLabel;
import javax.swing.JScrollPane; import javax.swing.JScrollPane;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.Color; import java.awt.Color;
import javax.swing.LayoutStyle.ComponentPlacement; import javax.swing.LayoutStyle.ComponentPlacement;
import java.awt.Toolkit; import java.awt.Toolkit;
import javax.swing.ScrollPaneConstants;
public class ResultsDialog extends JDialog { public class ResultsDialog extends JDialog {
/**
*
*/
private static final long serialVersionUID = 1L;
private final JPanel contentPanel = new JPanel(); private final JPanel contentPanel = new JPanel();
private JTextArea txt_conversionLogs; private JTextArea txt_conversionLogs;
private static ResultsDialog dialog = null; private static ResultsDialog dialog = null;
@ -40,8 +38,6 @@ public class ResultsDialog extends JDialog {
dialog = new ResultsDialog(); dialog = new ResultsDialog();
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
dialog.setVisible(true); dialog.setVisible(true);
dialog.setModal(true);
dialog.setModalityType (ModalityType.APPLICATION_MODAL);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -64,7 +60,6 @@ public class ResultsDialog extends JDialog {
SingleLogArray singleLogArray = SingleLogArray.create(); SingleLogArray singleLogArray = SingleLogArray.create();
JScrollPane scrollPane = new JScrollPane(); JScrollPane scrollPane = new JScrollPane();
scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
JTextArea txtrConversionCompleted = new JTextArea(); JTextArea txtrConversionCompleted = new JTextArea();
txtrConversionCompleted.setBackground(Color.WHITE); txtrConversionCompleted.setBackground(Color.WHITE);

View file

@ -1,63 +1,33 @@
package pro.litvinovg.w2phtml.gui; package pro.litvinovg.w2phtml.gui;
import java.awt.Component;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map; import java.util.Map;
import java.util.Set;
import java.util.Map.Entry; import java.util.Map.Entry;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JTextField;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static pro.litvinovg.w2phtml.gui.Contstants.*;
public class UIPreferences { public class UIPreferences {
private static final Logger logger = LoggerFactory.getLogger(UIPreferences.class); private Map<String,ArrayList<String>> prefs;
private Map<String,String[]> prefs;
private String sourceFileName = ""; private String sourceFileName = "";
private boolean defaultTemplate = false; public UIPreferences() {
prefs = new HashMap<String,ArrayList<String>>();
private PreferencesStorage storage;
public void setDefault(boolean defaultTemplate) {
this.defaultTemplate = defaultTemplate;
} }
public UIPreferences(PreferencesStorage storage) { public UIPreferences(Map<String,ArrayList<String>> sourcePrefs) {
this.storage = storage; Iterator<Entry<String, ArrayList<String>>> it = sourcePrefs.entrySet().iterator();
prefs = new HashMap<String,String[]>();
}
public UIPreferences(Map<String,String[]> sourcePrefs) {
Iterator<Entry<String, String[]>> it = sourcePrefs.entrySet().iterator();
prefs = new HashMap<String,String[]>();
while (it.hasNext()) { while (it.hasNext()) {
Entry<String, String[]> pair = (Entry<String, String[]>) it.next(); Entry<String, ArrayList<String>> pair = (Entry<String, ArrayList<String>>) it.next();
prefs.put(new String(pair.getKey()), Arrays.copyOf(pair.getValue(), pair.getValue().length)); prefs = new HashMap<String,ArrayList<String>>();
prefs.put(new String(pair.getKey()), new ArrayList<String>(pair.getValue()));
} }
} }
public void put(String name, String[]values) { public void put(String name, ArrayList<String>values) {
prefs.put(name, values); prefs.put(name, values);
} }
public void put(String name, String value) {
prefs.put(name, new String[] {value});
}
public String getSourceFileName() { public String getSourceFileName() {
return sourceFileName; return sourceFileName;
} }
@ -68,27 +38,18 @@ public class UIPreferences {
public String[] getAll(String name) { public String[] getAll(String name) {
if (prefs.containsKey(name)) { if (prefs.containsKey(name)) {
return prefs.get(name); return (String[]) prefs.get(name).toArray(new String[0]);
} else {
return new String[0];
} }
if (defaultTemplate) {
logger.error("Default preferences doesn't have values for " + name);
return new String[]{""};
}
String[] type = prefs.get(PREF_TYPE);
if (type == null) {
logger.error("Tab preferences doesn't have type!");
return new String[] {""};
}
if (storage == null) {
logger.error("Storage is null");
return new String[] {""};
}
UIPreferences defaultPreferences = storage.get(type[0]);
return defaultPreferences.getAll(name);
} }
public String get(String name) { public String get(String name) {
return getAll(name)[0]; if (prefs.containsKey(name)) {
return prefs.get(name).get(0);
} else {
return "";
}
} }
public UIPreferences clone() { public UIPreferences clone() {
@ -96,31 +57,4 @@ public class UIPreferences {
clonedPrefs.setSourceFileName(sourceFileName); clonedPrefs.setSourceFileName(sourceFileName);
return clonedPrefs; return clonedPrefs;
} }
public void updateFrom(HashMap<String, Component> configuration) {
Set<String> keys = configuration.keySet();
for (String key : keys) {
String value = null;
Component component = configuration.get(key);
if (component.getClass().equals(JTextField.class)) {
value = ((JTextField) component).getText();
} else if (component.getClass().equals(JCheckBox.class)) {
value = Boolean.toString(((JCheckBox) component).isSelected());
} else if (component.getClass().equals(JLabel.class)) {
value = ((JLabel) component).getText();
} else if (component.getClass().equals(JComboBox.class)) {
value = Integer.toString(((JComboBox) component).getSelectedIndex());
}
prefs.put(key, new String[] {value});
}
}
public JSONObject getJSON() {
JSONObject prefObject = new JSONObject();
for (Map.Entry<String, String[]> entry : prefs.entrySet()) {
String name = entry.getKey();
String[] values = entry.getValue();
prefObject.put(name, values);
}
return prefObject;
}
} }

View file

@ -23,13 +23,8 @@ label_use_mathjax=Use MathJax
label_fileter_hard_line_breaks=Filter hard line breaks label_fileter_hard_line_breaks=Filter hard line breaks
label_metadata_path=Metadata path label_metadata_path=Metadata path
label_type=Type label_type=Type
label_split_by_heading=Split by heading level label_split_by_heading=Split into multiple files by heading level
label_html5=html5 label_html5=html5
error_cant_write=Attention. Can't save file in output directory. error_cant_write=Attention. Can't save file in output directory.
message_not_implemented=Not implemented message_not_implemented=Not implemented
label_image_resolution=Resize image resolution to (PPI) label_image_resolution=Resize image resolution to (PPI)
enter_new_config_name=Enter name for new tab
config_name_is_already_in_use=Config name is already in use
default_config_cant_be_saved=Default tabs configuration can't be saved
successfully_saved_config=Tab configuration saved
button_delete_label=Delete

View file

@ -7,13 +7,13 @@ label_target_format=Целевой формат файла
label_input_file_path=Путь к входному файлу label_input_file_path=Путь к входному файлу
label_output_file_path=Путь к выходному файлу label_output_file_path=Путь к выходному файлу
label_convert_to_px=Конвертировать в пиксели (вместо rem) label_convert_to_px=Конвертировать в пиксели (вместо rem)
label_scale=Масштаб label_scale=Масштабирование
label_embed_raster=Встроить растровые изображения label_embed_raster=Встроить растровые изображения
label_embed_vector=Встроить векторные изображения label_embed_vector=Встроить векторные изображения
label_inline_styles=Применить стили внутри html элементов label_inline_styles=Применить стили внутри html элементов
label_button_choose=Выбрать label_button_choose=Выбрать
label_max_body_width=Максимальная ширина label_max_body_width=Максимальная ширина
label_min_letter_spacing=Фильтр утяжки символов label_min_letter_spacing=Отбросить межсимвольные расстояния меньше
label_ingnore_empty_pars=Не конвертировать пустые параграфы label_ingnore_empty_pars=Не конвертировать пустые параграфы
label_greenstone_split=Встроить комментарии для содержаний в Greenstone label_greenstone_split=Встроить комментарии для содержаний в Greenstone
label_break_style=Стиль разрывов страниц label_break_style=Стиль разрывов страниц
@ -22,14 +22,9 @@ label_split_whole_pages_only=Разрывы только по границам
label_use_mathjax=Встроить библиотеку MathJax для формул label_use_mathjax=Встроить библиотеку MathJax для формул
label_fileter_hard_line_breaks=Не конвертировать жесткие разрывы строк label_fileter_hard_line_breaks=Не конвертировать жесткие разрывы строк
label_metadata_path=Путь к метаданным label_metadata_path=Путь к метаданным
label_type=Вид label_type=Тип документа
label_split_by_heading=Разделять по заголовкам label_split_by_heading=Разделить на файлы по заголовкам до уровня (включительно)
label_html5=html5 label_html5=html5
error_cant_write=Ошибка. Не удалось сохранить файл в целевую директорию error_cant_write=Ошибка. Не удалось сохранить файл в целевую директорию
message_not_implemented=Данная функциональность еще не реализована message_not_implemented=Данная функциональность еще не реализована
label_image_resolution=Разрешение изображений (PPI) label_image_resolution=Уменьшить разрешение изображений до (PPI)
enter_new_config_name=Введите имя новой вкладки
config_name_is_already_in_use=Такое имя вкладки уже используется
default_config_cant_be_saved=Настройки вкладок по умолчанию нельзя сохранять
successfully_saved_config=Настройки вкладки сохранены
button_delete_label=Удалить

View file

@ -67,13 +67,9 @@ public final class Application {
* The argument passed on the command line. * The argument passed on the command line.
*/ */
public static final void main(String[] args) throws Exception { public static final void main(String[] args) throws Exception {
if (args.length < 2) { if (args.length == 0) {
showUsage(""); showUsage("");
String fileName = ""; ConfigurationWindow.runGUI(null);
if (args.length == 1){
fileName = args[0];
}
ConfigurationWindow.runGUI(fileName);
} else { } else {
try { try {
long time = System.currentTimeMillis(); long time = System.currentTimeMillis();

View file

@ -55,11 +55,10 @@ import w2phtml.xhtml.XhtmlConfig;
*/ */
public class BinaryGraphicsDocument implements OutputFile { public class BinaryGraphicsDocument implements OutputFile {
private String sFileName; private String sFileName;
private String sMimeType; private String sMimeType;
private String imageName = "";
private boolean bAcceptedFormat; private boolean bAcceptedFormat;
private boolean bRecycled = false; private boolean bRecycled = false;
@ -97,7 +96,6 @@ public class BinaryGraphicsDocument implements OutputFile {
this.sMimeType = bgd.getMIMEType(); this.sMimeType = bgd.getMIMEType();
this.blob = bgd.getData(); this.blob = bgd.getData();
this.bAcceptedFormat = bgd.isAcceptedFormat(); this.bAcceptedFormat = bgd.isAcceptedFormat();
this.imageName = bgd.getImageName();
this.bRecycled = true; this.bRecycled = true;
} }
@ -114,7 +112,7 @@ public class BinaryGraphicsDocument implements OutputFile {
this.horizontalPPI = widthDPI; this.horizontalPPI = widthDPI;
} }
} catch (ImageReadException | IOException e) { } catch (ImageReadException | IOException e) {
logger.error("Image " + getImageName() + " error reading image info."); logger.error("Image " + sFileName + "error reading image info.");
e.printStackTrace(); e.printStackTrace();
} }
@ -234,43 +232,31 @@ public class BinaryGraphicsDocument implements OutputFile {
return; return;
} }
ByteArrayInputStream bis = new ByteArrayInputStream(blob); ByteArrayInputStream bis = new ByteArrayInputStream(blob);
try { try {
BufferedImage image = ImageIO.read(bis); BufferedImage image = ImageIO.read(bis);
if (image == null) { if (image == null) {
logger.error("Image " + getImageName() + " couldn't be processed as it is damaged or has unknown format."); logger.error("Image " + sFileName + " couldn't be processed as it is damaged or has unknown format.");
return; return;
} }
int height = image.getHeight(); int height = image.getHeight();
int width = image.getWidth(); int width = image.getWidth();
int leftOffset = offsets[3]; int leftOffset = offsets[3];
int topOffset = offsets[0]; int topOffset = offsets[0];
int croppedWidth = width - offsets[3] - offsets[1]; int newWidth = width - offsets[3] - offsets[1];
int croppedHeight = height - offsets[0] - offsets[2]; int newHeight = height - offsets[0] - offsets[2];
if ( croppedHeight <= 0) { BufferedImage croppedImage = image.getSubimage(leftOffset, topOffset, newWidth , newHeight );
throw new IOException("Cropped image height < 0"); ByteArrayOutputStream baos = new ByteArrayOutputStream();
}
if ( croppedWidth <= 0 ) {
throw new IOException("Cropped image width < 0");
}
BufferedImage croppedImage = new BufferedImage(croppedWidth, croppedHeight, BufferedImage.TYPE_3BYTE_BGR);
int px[] = new int[croppedWidth * croppedHeight];
image.getRGB(leftOffset, topOffset, croppedWidth, croppedHeight, px, 0, croppedWidth);
croppedImage.setRGB(0, 0, croppedWidth, croppedHeight, px, 0, croppedWidth);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(croppedImage, "JPG", baos); ImageIO.write(croppedImage, "JPG", baos);
sMimeType = MIMETypes.JPEG; sMimeType = MIMETypes.JPEG;
this.blob = baos.toByteArray(); this.blob = baos.toByteArray();
if (blob.length == 0) {
throw new IOException();
}
this.cropped = true; this.cropped = true;
updateFileName(offsets); updateFileName(offsets);
} catch (IOException e) { } catch (IOException e) {
logger.error("Error. Image " + getImageName() + " " + e.getLocalizedMessage()); logger.error("Image " + sFileName + " " + e.getLocalizedMessage());
e.printStackTrace(); e.printStackTrace();
} catch (RasterFormatException e ) { } catch (RasterFormatException e ) {
logger.error("Error. Image " + getImageName() + " " + e.getLocalizedMessage()); logger.error("Image " + sFileName + " " + e.getLocalizedMessage());
e.printStackTrace(); e.printStackTrace();
} }
} }
@ -292,38 +278,28 @@ public class BinaryGraphicsDocument implements OutputFile {
try { try {
BufferedImage image = ImageIO.read(bis); BufferedImage image = ImageIO.read(bis);
if (image == null) { if (image == null) {
logger.error("Image " + getImageName() + " couldn't be processed as it is damaged or has unknown format."); logger.error("Image " + sFileName + " couldn't be processed as it is damaged or has unknown format.");
return; return;
} }
int width = image.getWidth(); int width = image.getWidth();
if (width > 0) { if (width > 0) {
Integer newWidth = (int) ( width/divider); Integer newWidth = (int) ( width/divider);
BufferedImage resizedImage = Scalr.resize(image, newWidth); BufferedImage resizedImage = Scalr.resize(image, newWidth);
BufferedImage jpgImage = getJPGImage(resizedImage);
ByteArrayOutputStream baos = new ByteArrayOutputStream(); ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(jpgImage, "JPG", baos); ImageIO.write(resizedImage, "JPG", baos);
this.blob = baos.toByteArray(); this.blob = baos.toByteArray();
extractPPI(); extractPPI();
//logger.error(sFileName + " Vertical PPI " + this.verticalPPI);
//logger.error(sFileName + " Horizontal PPI " + this.horizontalPPI);
} else { } else {
logger.error("Error. Image " + getImageName() + " width = 0"); logger.error("Image " + sFileName + " width = 0");
} }
} catch (IOException e) { } catch (IOException e) {
logger.error("Error. Image " + getImageName() + " " + e.getLocalizedMessage()); logger.error("Image " + sFileName + " " + e.getLocalizedMessage());
e.printStackTrace(); e.printStackTrace();
} }
} }
private BufferedImage getJPGImage(BufferedImage resizedImage) {
if (resizedImage.getType() == BufferedImage.TYPE_3BYTE_BGR){
return resizedImage;
}
BufferedImage jpgImage = new BufferedImage(resizedImage.getWidth(), resizedImage.getHeight(), BufferedImage.TYPE_3BYTE_BGR);
int px[] = new int[resizedImage.getWidth() * resizedImage.getHeight()];
resizedImage.getRGB(0, 0, resizedImage.getWidth(), resizedImage.getHeight(), px, 0, resizedImage.getWidth());
jpgImage.setRGB(0, 0, resizedImage.getWidth(), resizedImage.getHeight(), px, 0, resizedImage.getWidth());
return jpgImage;
}
private boolean isNotCropped(int[] offsets) { private boolean isNotCropped(int[] offsets) {
return offsets[0] == 0 && offsets[1] == 0 && offsets[2] == 0 && offsets[3] == 0; return offsets[0] == 0 && offsets[1] == 0 && offsets[2] == 0 && offsets[3] == 0;
} }
@ -370,16 +346,6 @@ public class BinaryGraphicsDocument implements OutputFile {
return offsets; return offsets;
} }
public void setImageName(String imageName) {
this.imageName = imageName;
}
public String getImageName() {
if (imageName == null || imageName.isEmpty()) {
return sFileName;
}
return imageName;
}
/** Does this document contain formulas? /** Does this document contain formulas?
* *
* @return false - a graphics file does not contain formulas * @return false - a graphics file does not contain formulas

View file

@ -195,7 +195,6 @@ public final class ImageConverter {
private BinaryGraphicsDocument getImage(Element node, String sName) { private BinaryGraphicsDocument getImage(Element node, String sName) {
assert(XMLString.DRAW_IMAGE.equals(node.getTagName())); assert(XMLString.DRAW_IMAGE.equals(node.getTagName()));
String imageName = getImageName(node);
// Image data // Image data
String sExt = null; String sExt = null;
String sMIME = null; String sMIME = null;
@ -235,8 +234,8 @@ public final class ImageConverter {
// This is a linked image // This is a linked image
// TODO: Add option to download image from the URL? // TODO: Add option to download image from the URL?
String sFileName = ofr.fixRelativeLink(sHref); String sFileName = ofr.fixRelativeLink(sHref);
BinaryGraphicsDocument bgd = new BinaryGraphicsDocument(sFileName,null); BinaryGraphicsDocument bgd
bgd.setImageName(imageName); = new BinaryGraphicsDocument(sFileName,null);
return bgd; return bgd;
} }
} }
@ -282,8 +281,8 @@ public final class ImageConverter {
int[] offlen = new int[2]; int[] offlen = new int[2];
if (SVMReader.readSVM(blob,offlen)) { if (SVMReader.readSVM(blob,offlen)) {
String sFileName = sName+MIMETypes.EPS_EXT; String sFileName = sName+MIMETypes.EPS_EXT;
BinaryGraphicsDocument bgd = new BinaryGraphicsDocument(sFileName, MIMETypes.EPS); BinaryGraphicsDocument bgd
bgd.setImageName(imageName); = new BinaryGraphicsDocument(sFileName, MIMETypes.EPS);
bgd.setData(blob,offlen[0],offlen[1],true); bgd.setData(blob,offlen[0],offlen[1],true);
return bgd; return bgd;
} }
@ -320,7 +319,6 @@ public final class ImageConverter {
if (isAcceptedFormat(sMIME) || bAcceptOtherFormats) { if (isAcceptedFormat(sMIME) || bAcceptOtherFormats) {
String sFileName = sName+sExt; String sFileName = sName+sExt;
BinaryGraphicsDocument bgd = new BinaryGraphicsDocument(sFileName,sMIME); BinaryGraphicsDocument bgd = new BinaryGraphicsDocument(sFileName,sMIME);
bgd.setImageName(imageName);
bgd.setData(blob,isAcceptedFormat(sMIME)); bgd.setData(blob,isAcceptedFormat(sMIME));
if (sId!=null) { if (sId!=null) {
recycledImages.put(sId, new BinaryGraphicsDocument(bgd)); recycledImages.put(sId, new BinaryGraphicsDocument(bgd));
@ -332,23 +330,13 @@ public final class ImageConverter {
} }
} }
private String getImageName(Element node) { private Element getAlternativeImage(Element node) {
Node parent = node.getParentNode(); Node sibling = node.getNextSibling();
if (parent == null || parent.getNodeType() != Node.ELEMENT_NODE || parent.getNodeName() != XMLString.DRAW_FRAME) { if (sibling!=null && Misc.isElement(sibling, XMLString.DRAW_IMAGE)) {
return null; return (Element) sibling;
} }
Element frame = (Element) parent; return null;
String name = frame.getAttribute(XMLString.DRAW_NAME); }
return name;
}
private Element getAlternativeImage(Element node) {
Node sibling = node.getNextSibling();
if (sibling != null && Misc.isElement(sibling, XMLString.DRAW_IMAGE)) {
return (Element) sibling;
}
return null;
}
// Create a fingerprint of a blob. The fingerprint concatenates the MD5 hash with the first 10 bytes of the blob. // Create a fingerprint of a blob. The fingerprint concatenates the MD5 hash with the first 10 bytes of the blob.
private String createId(byte[] blob) { private String createId(byte[] blob) {

View file

@ -111,13 +111,13 @@ public class ListCounter {
} }
public String getLabelAndSuffix() { public String getLabelAndSuffix() {
String sLabel="";
if (style != null && style.isNumber(nLevel)) { if (style != null && style.isNumber(nLevel)) {
String sLabel="";
if (sNumFormat[nLevel]==null) return ""; if (sNumFormat[nLevel]==null) return "";
int nLevels = Misc.getPosInteger(style.getLevelProperty(nLevel, int nLevels = Misc.getPosInteger(style.getLevelProperty(nLevel,
XMLString.TEXT_DISPLAY_LEVELS),1); XMLString.TEXT_DISPLAY_LEVELS),1);
String sSuffix = getSuffix(); String sSuffix = style.getLevelProperty(nLevel,XMLString.STYLE_NUM_SUFFIX);
String sSpace = getSpace(); String sSpace = "nothing".equals(style.getLevelStyleProperty(nLevel, XMLString.TEXT_LABEL_FOLLOWED_BY)) ? "" : " ";
for (int j=nLevel-nLevels+1; j<nLevel; j++) { for (int j=nLevel-nLevels+1; j<nLevel; j++) {
sLabel+=formatNumber(nCounter[j],sNumFormat[j],true)+"."; sLabel+=formatNumber(nCounter[j],sNumFormat[j],true)+".";
} }
@ -125,24 +125,16 @@ public class ListCounter {
sLabel+=formatNumber(nCounter[nLevel],sNumFormat[nLevel],true); sLabel+=formatNumber(nCounter[nLevel],sNumFormat[nLevel],true);
if (sSuffix!=null) { sLabel+=sSuffix; } if (sSuffix!=null) { sLabel+=sSuffix; }
if (sLabel.length()>0 && sSpace!=null) { sLabel+=sSpace; } if (sLabel.length()>0 && sSpace!=null) { sLabel+=sSpace; }
return sLabel;
} }
else if (style != null && style.isBullet(nLevel)) { else if (style != null && style.isBullet(nLevel)) {
sLabel = style.getLevelProperty(nLevel,XMLString.TEXT_BULLET_CHAR); return style.getLevelProperty(nLevel,XMLString.TEXT_BULLET_CHAR);
String sSpace = getSpace(); }
if (sLabel.length()>0 && sSpace!=null) { sLabel+=sSpace; } else {
return "";
} }
return sLabel;
} }
private String getSpace() {
return "nothing".equals(style.getLevelStyleProperty(nLevel, XMLString.TEXT_LABEL_FOLLOWED_BY)) ? "" : " ";
}
private String getSuffix() {
return style.getLevelProperty(nLevel,XMLString.STYLE_NUM_SUFFIX);
}
// Utility method to generate number // Utility method to generate number
private String formatNumber(int number,String sStyle,boolean bLetterSync) { private String formatNumber(int number,String sStyle,boolean bLetterSync) {
if ("a".equals(sStyle)) { return Misc.int2alph(number,bLetterSync); } if ("a".equals(sStyle)) { return Misc.int2alph(number,bLetterSync); }

View file

@ -1,73 +0,0 @@
package w2phtml.pageSplitters;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import pro.litvinovg.w2phtml.gui.ConversionExecutor;
import pro.litvinovg.xml.Debug;
import w2phtml.office.OfficeReader;
import w2phtml.office.StyleWithProperties;
import w2phtml.util.Misc;
import static w2phtml.office.XMLString.TEXT_LIST_ITEM;
import static w2phtml.office.XMLString.TEXT_SOFT_PAGE_BREAK;
import static w2phtml.office.XMLString.TEXT_STYLE_NAME;
import java.util.Iterator;
import static w2phtml.office.XMLString.TEXT_P;
import static w2phtml.office.XMLString.TEXT_H;
import static w2phtml.office.XMLString.FO_BREAK_BEFORE;
public class ListBreaksFix {
private static final Logger logger = LoggerFactory.getLogger(ListBreaksFix.class);
private OfficeReader ofr;
public ListBreaksFix(OfficeReader ofr) {
this.ofr = ofr;
}
// Hack to fix hard breaks splitting in lists
public void addSPBsBeforeBreaksInLists(Node onode) {
try {
DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = builderFactory.newDocumentBuilder();
Document document = onode.getOwnerDocument();
XPath xPath = XPathFactory.newInstance().newXPath();
String expression = "//*[starts-with(local-name(),'list-item')]//*[starts-with(local-name(),'p') ]";
NodeList nodeList = (NodeList) xPath.compile(expression).evaluate(document, XPathConstants.NODESET);
for (int i = 0; i < nodeList.getLength(); i++) {
Node paragraph = nodeList.item(i);
if (hasBreakBefore(paragraph)) {
Node spb = document.createElement(TEXT_SOFT_PAGE_BREAK);
paragraph.getParentNode().insertBefore(spb, paragraph);
}
}
} catch (XPathExpressionException e) {
logger.error("Error fixing hard breaks in lists" + e.getLocalizedMessage());
e.printStackTrace();
} catch (ParserConfigurationException e) {
logger.error("Error fixing hard breaks in lists" + e.getLocalizedMessage());
e.printStackTrace();
}
}
private boolean hasBreakBefore(Node node) {
StyleWithProperties style = ofr.getParStyle(Misc.getAttribute(node,TEXT_STYLE_NAME));
if (style != null && "page".equals(style.getProperty(FO_BREAK_BEFORE))) {
return true;
}
return false;
}
}

View file

@ -6,11 +6,13 @@ import static w2phtml.office.XMLString.TEXT_LIST_ITEM;
import static w2phtml.office.XMLString.TEXT_LIST; import static w2phtml.office.XMLString.TEXT_LIST;
import static w2phtml.office.XMLString.TEXT_SOFT_PAGE_BREAK; import static w2phtml.office.XMLString.TEXT_SOFT_PAGE_BREAK;
import org.apache.commons.lang3.StringUtils;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.Element; import org.w3c.dom.Element;
import org.w3c.dom.Node; import org.w3c.dom.Node;
import org.w3c.dom.NodeList; import org.w3c.dom.NodeList;
import pro.litvinovg.xml.Debug;
import w2phtml.office.OfficeReader; import w2phtml.office.OfficeReader;
public class ListSplitter extends BasicSplitter implements ISplitter { public class ListSplitter extends BasicSplitter implements ISplitter {
@ -58,14 +60,9 @@ public class ListSplitter extends BasicSplitter implements ISplitter {
} else { } else {
list.removeChild(child); list.removeChild(child);
} }
} else {
//Debug.printNode(child);
//Found SPB at start of the list
//Add SPB before the list
if (isRootElement(list)) {
parent.insertBefore(softPageBreak, list);
}
} }
// Debug.printNode(child);
break; break;
} else { } else {
// Not with SPB yet, move node, set dataMoved=true // Not with SPB yet, move node, set dataMoved=true
@ -99,7 +96,7 @@ public class ListSplitter extends BasicSplitter implements ISplitter {
while (freeNodes.getLength() > 0) { while (freeNodes.getLength() > 0) {
Node freeNode = freeNodes.item(i); Node freeNode = freeNodes.item(i);
String freeNodeName = freeNode.getNodeName(); String freeNodeName = freeNode.getNodeName();
if (TEXT_LIST.equals(freeNodeName)) { if (StringUtils.equals(TEXT_LIST, freeNodeName)) {
break; break;
} }
parent.insertBefore(freeNode, list); parent.insertBefore(freeNode, list);

View file

@ -37,9 +37,9 @@ public class DocumentPart {
private String parentPath; private String parentPath;
private String name = null; private String name = null;
private String order = null; private String order = null;
private MetadataContainer metadata = null; private Metadata metadata = null;
public DocumentPart(XhtmlDocument document,MetadataContainer metadata) { public DocumentPart(XhtmlDocument document,Metadata metadata) {
this.excerptDoc = document; this.excerptDoc = document;
this.metadata = metadata; this.metadata = metadata;
extractPath(); extractPath();
@ -50,7 +50,7 @@ public class DocumentPart {
extractAnnotationMetadata(); extractAnnotationMetadata();
} }
public DocumentPart(String path, MetadataContainer metadata) { public DocumentPart(String path, Metadata metadata) {
this.path = path; this.path = path;
this.metadata = metadata; this.metadata = metadata;
this.name = ""; this.name = "";

View file

@ -20,7 +20,6 @@ import org.apache.jena.rdf.model.Resource;
import org.apache.jena.vocabulary.*; import org.apache.jena.vocabulary.*;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import static w2phtml.util.Transliteration.*;
import w2phtml.xhtml.XhtmlConfig; import w2phtml.xhtml.XhtmlConfig;
import w2phtml.xhtml.XhtmlDocument; import w2phtml.xhtml.XhtmlDocument;
@ -28,32 +27,36 @@ import w2phtml.xhtml.XhtmlDocument;
import org.apache.jena.rdf.model.Property; import org.apache.jena.rdf.model.Property;
public class RDFDocument { public class DocumentStructure {
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_POSTAL_CODE = "affiliated organization postal code";
private static final String AFFILIATED_ORGANIZATION_ADDRESS = "affiliated organization address"; 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_OFFICIAL_NAME = "affiliated organization official name";
private static final String AFFILIATED_ORGANIZATION_NAME = "affiliated organization name"; private static final String AFFILIATED_ORGANIZATION_NAME = "affiliated organization name";
private static final String AUTHOR_INITIALS = "author initials"; private static final String AUTHOR_INITIALS = "author initials";
private static final String AUTHOR_EMAIL = "author email"; private static final String AUTHOR_EMAIL = "author email";
private static final String AUTHOR_FAMILY = "author family"; private static final String AUTHOR_FAMILY = "author family";
private static final Logger logger = LoggerFactory.getLogger(RDFDocument.class);
private static final Logger logger = LoggerFactory.getLogger(DocumentStructure.class);
private static final String AUTHOR_GIVEN_NAME = "author given name"; private static final String AUTHOR_GIVEN_NAME = "author given name";
private static final String MODIFICATION_TIME = "modificationTime"; private static final String MODIFICATION_TIME = "modificationTime";
private static final String HTML_EXCERPT_PROPERTY = "htmlExcerpt"; private static final String HTML_EXCERPT_PROPERTY = "htmlExcerpt";
private static final String TOC_ITEM = "TOCItem"; private static final String TOCITEM = "TOCItem";
private static final String TS = "https://litvinovg.pro/text_structures#"; private static final String TS = "https://litvinovg.pro/text_structures#";
private static final String POINTS_TO = TS + "pointsTo"; private static final String PARSERNAME = "w2phtml";
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 TEXT_EXCERPT = "textExcerpt";
private static final String TOC_LEVEL = "TOCLevel"; private static final String TOC_LEVEL = "TOCLevel";
private static final String TABLE_OF_CONTENTS = "TOC"; private static final String TABLE_OF_CONTENTS = "TOC";
private static final String PARTICIPANT = "publicationParticipant"; private static final String PARTICIPANT = "publicationParticipant";
private static final String ORGANIZATION = "organization"; private static final String ORGANIZATION = "organization";
private static final String PUBLICATION = "publication"; private static final String PUBLICATION = "publication";
private static final String BOOK = "book"; private static final String BOOK = "book";
private static final String JOURNAL = "journal"; private static final String JOURNAL = "journal";
@ -78,10 +81,10 @@ public class RDFDocument {
private HashMap<String, Resource> tocLevels; private HashMap<String, Resource> tocLevels;
private HashMap<String, DocumentPart> inputParts; private HashMap<String, DocumentPart> inputParts;
private MetadataContainer metadata; private Metadata metadata;
private Date currentTime; private Date currentTime;
public RDFDocument(Vector<XhtmlDocument> files,String fileName, XhtmlConfig config, MetadataContainer metadata) { public DocumentStructure(Vector<XhtmlDocument> files,String fileName, XhtmlConfig config,Metadata metadata) {
this.tocLevels = new HashMap<String, Resource>(); this.tocLevels = new HashMap<String, Resource>();
this.inputParts = new HashMap<String, DocumentPart>(); this.inputParts = new HashMap<String, DocumentPart>();
this.m = ModelFactory.createOntologyModel(); this.m = ModelFactory.createOntologyModel();
@ -91,10 +94,11 @@ public class RDFDocument {
this.tocClass = textOntology.createClass(TS + TABLE_OF_CONTENTS); this.tocClass = textOntology.createClass(TS + TABLE_OF_CONTENTS);
this.organizationClass = textOntology.createClass(TS + ORGANIZATION); this.organizationClass = textOntology.createClass(TS + ORGANIZATION);
this.participantClass = textOntology.createClass(TS + PARTICIPANT); this.participantClass = textOntology.createClass(TS + PARTICIPANT);
this.itemClass = textOntology.createClass(TS + TOC_ITEM); this.itemClass = textOntology.createClass(TS + TOCITEM);
formatDocID(fileName); this.docID = fileName;
this.currentTime = Calendar.getInstance().getTime(); this.currentTime = Calendar.getInstance().getTime();
setPublicationType(config.getRDFType()); String publicationType = config.getRDFType();
setPublicationType(publicationType);
this.documentClass = textOntology.createClass(TS + documentType); this.documentClass = textOntology.createClass(TS + documentType);
this.excerptClass = textOntology.createClass(TS + excerptType); this.excerptClass = textOntology.createClass(TS + excerptType);
for(int i = 0 ; i< files.size();i++) { for(int i = 0 ; i< files.size();i++) {
@ -104,12 +108,6 @@ public class RDFDocument {
addPart(part); addPart(part);
} }
addEmptyParts(); addEmptyParts();
createElements();
createTOCItems();
}
public void printModel(OutputStream os) {
m.write(os,FORMAT_RDF);
} }
private void setPublicationType(String publicationType) { private void setPublicationType(String publicationType) {
@ -158,12 +156,36 @@ public class RDFDocument {
return emptyPath.toString(); 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) { private void addPart(DocumentPart docExcerpt) {
inputParts.put(docExcerpt.getPath(), docExcerpt); inputParts.put(docExcerpt.getPath(), docExcerpt);
} }
private Resource createExcerpt(DocumentPart docExcerpt) { private Resource createExcerpt(DocumentPart docExcerpt) {
String excerptName = TS + excerptType + "/" + docID + docExcerpt.getSafePath(); String excerptName = TS + excerptType + "/" + PARSERNAME + "_" + docID + docExcerpt.getSafePath();
Resource excerpt = m.createIndividual(excerptName, excerptClass); Resource excerpt = m.createIndividual(excerptName, excerptClass);
addModificationTime(excerpt); addModificationTime(excerpt);
if (!docExcerpt.getBody().isEmpty()) { if (!docExcerpt.getBody().isEmpty()) {
@ -174,7 +196,7 @@ public class RDFDocument {
} }
private void createTOCLevel(DocumentPart docPart) { private void createTOCLevel(DocumentPart docPart) {
String levelName = TS + TOC_LEVEL + "/" + docID + docPart.getSafePath(); String levelName = TS + TOC_LEVEL + "/" + PARSERNAME + "_" + docID + docPart.getSafePath();
Resource level = m.createIndividual(levelName,tocLevelClass); Resource level = m.createIndividual(levelName,tocLevelClass);
level.addProperty( RDFS.label, docPart.getName()); level.addProperty( RDFS.label, docPart.getName());
tocLevels.put(docPart.getPath(), level); tocLevels.put(docPart.getPath(), level);
@ -182,13 +204,13 @@ public class RDFDocument {
} }
private void createDocument(DocumentPart docPart) { private void createDocument(DocumentPart docPart) {
String documentURI = TS + documentType + "/" + docID ; String documentURI = TS + documentType + "/" + PARSERNAME + "_" + docID ;
Resource mainResource = m.createResource(documentURI, documentClass); Resource mainResource = m.createResource(documentURI, documentClass);
mainResource.addProperty( RDFS.label, docPart.getName()); mainResource.addProperty( RDFS.label, docPart.getName());
addModificationTime(mainResource); addModificationTime(mainResource);
String tocURI = TS + TABLE_OF_CONTENTS + "/" + docID ; String tocURI = TS + TABLE_OF_CONTENTS + "/" + PARSERNAME + "_" + docID ;
Resource toc = m.createResource(tocURI, tocClass); Resource toc = m.createResource(tocURI, tocClass);
toc.addProperty( RDFS.label, docPart.getName()); toc.addProperty( RDFS.label, docPart.getName());
@ -222,7 +244,7 @@ public class RDFDocument {
+ postfix + " found. Author givenName field is " + givenNameKey ); + postfix + " found. Author givenName field is " + givenNameKey );
System.exit(1); System.exit(1);
} }
String participantURI = TS + PARTICIPANT + "/" + docID + order + "author" + postfix; String participantURI = TS + PARTICIPANT + "/" + PARSERNAME + "_" + docID + order + "author" + postfix;
Resource participant = m.createResource(participantURI, participantClass); Resource participant = m.createResource(participantURI, participantClass);
Property hasAuthor = m.createProperty(TS + "hasAuthor"); Property hasAuthor = m.createProperty(TS + "hasAuthor");
excerpt.addProperty(hasAuthor, participant); excerpt.addProperty(hasAuthor, participant);
@ -251,20 +273,20 @@ public class RDFDocument {
Property initialsProperty = m.createProperty(TS + "participantInitials"); Property initialsProperty = m.createProperty(TS + "participantInitials");
participant.addProperty( initialsProperty, authorInitials.trim()); participant.addProperty( initialsProperty, authorInitials.trim());
} }
addOrganization(participant, map, order, postfix); attachOrganization(participant, map, order, postfix);
} }
} }
} }
} }
private void addOrganization(Resource participant, Map<String, String> map, String order, String postfix) { private void attachOrganization(Resource participant, Map<String, String> map, String order, String postfix) {
String orgName = map.get(AFFILIATED_ORGANIZATION_NAME + postfix); String orgName = map.get(AFFILIATED_ORGANIZATION_NAME + postfix);
if (orgName == null) { if (orgName == null) {
System.out.println(orgName + " not found"); System.out.println(orgName + " not found");
logger.warn("No " + AFFILIATED_ORGANIZATION_NAME + postfix + " found."); logger.warn("No " + AFFILIATED_ORGANIZATION_NAME + postfix + " found.");
return; return;
} }
String organizationUri = TS + ORGANIZATION + "/" + docID + order + "author" + postfix; String organizationUri = TS + ORGANIZATION + "/" + PARSERNAME + "_" + docID + order + "author" + postfix;
Resource organization = m.createResource(organizationUri, organizationClass); Resource organization = m.createResource(organizationUri, organizationClass);
Property affiliatedWith = m.createProperty(TS + "affiliatedWith"); Property affiliatedWith = m.createProperty(TS + "affiliatedWith");
participant.addProperty(affiliatedWith, organization); participant.addProperty(affiliatedWith, organization);
@ -380,18 +402,19 @@ public class RDFDocument {
return true; return true;
} }
private void createTOCItem(DocumentPart docPart) { private void createTOCItem(DocumentPart docPart) {
String tocItemUri = TS + TOC_ITEM + "/" + docID + docPart.getSafePath(); String tocItemName = TS + TOCITEM + "/" + PARSERNAME + "_" + docID + docPart.getSafePath();
Resource tocItem = m.createIndividual(tocItemUri,itemClass); Resource tocItem = m.createIndividual(tocItemName,itemClass);
tocItem.addProperty( RDFS.label, docPart.getName()); tocItem.addProperty( RDFS.label, docPart.getName());
Property pointsTo = m.createProperty(POINTS_TO); Property pointsTo = m.createProperty(TS + "pointsTo");
Property itemNumber = m.createProperty(ITEM_NUMBER); Property itemNumber = m.createProperty(TS + "itemNumber");
Property hasTOCItem = m.createProperty(HAS_TOC_ITEM); Property hasTOCItem = m.createProperty(TS + "hasTOCItem");
tocItem.addLiteral(itemNumber, docPart.getNumber()); tocItem.addLiteral(itemNumber, docPart.getNumber());
m.add(tocItem, pointsTo, tocLevels.get(docPart.getPath())); m.add(tocItem, pointsTo, tocLevels.get(docPart.getPath()));
if (!docPart.getPath().isEmpty()) { if (!docPart.getPath().isEmpty()) {
Resource parent = tocLevels.get(docPart.getParentPath()); Resource parent = tocLevels.get(docPart.getParentPath());
m.add(parent, hasTOCItem, tocItem); m.add(parent, hasTOCItem, tocItem);
} }
} }
private void attachExcerpt(DocumentPart docPart, Resource element) { private void attachExcerpt(DocumentPart docPart, Resource element) {
@ -403,7 +426,7 @@ public class RDFDocument {
} }
Resource excerpt = createExcerpt(docPart); Resource excerpt = createExcerpt(docPart);
excerpt.addProperty( RDFS.label, docPart.getName()); excerpt.addProperty( RDFS.label, docPart.getName());
Property hasText = m.createProperty(HAS_TEXT); Property hasText = m.createProperty(TS + "hasText");
element.addProperty(hasText, excerpt); element.addProperty(hasText, excerpt);
if (!docPart.isMasterPart()) { if (!docPart.isMasterPart()) {
addMetadataProperties(excerpt, docPart); addMetadataProperties(excerpt, docPart);
@ -412,6 +435,11 @@ public class RDFDocument {
} }
} }
public void createTree() {
createElements();
createTOCItems();
}
private void createTOCItems() { private void createTOCItems() {
Set<String> paths = inputParts.keySet(); Set<String> paths = inputParts.keySet();
for (String path : paths) { for (String path : paths) {
@ -434,10 +462,4 @@ public class RDFDocument {
} }
} }
private void formatDocID(String fileName) {
String identifier = fileName.replaceAll("\\s+", "_");
identifier = transliterateToEn(identifier);
identifier = identifier.replaceAll("[^a-zA-Z0-9_.-]", "");
this.docID = identifier;
}
} }

View file

@ -19,28 +19,28 @@ import org.slf4j.LoggerFactory;
import com.opencsv.CSVReaderHeaderAware; import com.opencsv.CSVReaderHeaderAware;
import com.opencsv.exceptions.CsvValidationException; import com.opencsv.exceptions.CsvValidationException;
public class MetadataContainer { public class Metadata {
private static final String SUBTITLE = "subtitle"; private static final String SUBTITLE = "subtitle";
private static final String FILENAME = "Filename"; private static final String FILENAME = "Filename";
private static final String SECTION = "Section"; private static final String SECTION = "Section";
private static final Logger logger = LoggerFactory.getLogger(MetadataContainer.class); private static final Logger logger = LoggerFactory.getLogger(Metadata.class);
private HashMap<String, ArrayList<Map<String, String>>> sectionsMetadata; private HashMap<String, ArrayList<Map<String, String>>> sectionsMetadata;
public MetadataContainer() { public Metadata() {
sectionsMetadata = new HashMap<String, ArrayList<Map<String, String>>>(); sectionsMetadata = new HashMap<String, ArrayList<Map<String, String>>>();
} }
public void read(String filePath) { public void read(String metadataFilePath) {
if (filePath == null) { if (metadataFilePath == null) {
return; return;
} }
File file = new File(filePath); File file = new File(metadataFilePath);
if (!file.exists() || !file.canRead()) { if (!file.exists() || !file.canRead()) {
return; return;
} }
readCSVFile(filePath); readCSVFile(metadataFilePath);
} }
private void readCSVFile(String filePath) { private void readCSVFile(String filePath) {

View file

@ -17,15 +17,17 @@ public class RDFDocumentResult implements OutputFile {
private ConverterResult xhtmlResult; private ConverterResult xhtmlResult;
private String sFileName; private String sFileName;
private XhtmlConfig config; private XhtmlConfig config;
private RDFDocument rdfDocument = null; private DocumentStructure rdfStructure = null;
public RDFDocumentResult(Vector<XhtmlDocument> outFiles, String fileName, XhtmlConfig config) { public RDFDocumentResult(Vector<XhtmlDocument> outFiles, String fileName, XhtmlConfig config) {
this.sFileName = Misc.removeExtension(fileName); this.sFileName = Misc.removeExtension(fileName);
this.config = config; this.config = config;
MetadataContainer metadata = new MetadataContainer(); Metadata metadata = new Metadata();
metadata.read(config.getCSVMetadataFile()); metadata.read(config.getCSVMetadataFile());
rdfDocument = new RDFDocument(outFiles,sFileName,config,metadata); rdfStructure = new DocumentStructure(outFiles,sFileName,config,metadata);
rdfStructure.createTree();
} }
@ -46,7 +48,7 @@ public class RDFDocumentResult implements OutputFile {
} }
@Override public void write(OutputStream os) throws IOException { @Override public void write(OutputStream os) throws IOException {
rdfDocument.printModel(os); rdfStructure.printModel(os);
} }
} }

View file

@ -0,0 +1,11 @@
<!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>

View file

@ -1,41 +0,0 @@
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");
}
}

View file

@ -209,7 +209,7 @@ public class XhtmlConfig extends w2phtml.base.ConfigBase {
else { nValue = ABSOLUTE; } else { nValue = ABSOLUTE; }
} }
}; };
options[LIST_FORMATTING] = new IntegerOption("list_formatting","hard_labels") { options[LIST_FORMATTING] = new IntegerOption("list_formatting","css1_hack") {
@Override public void setString(String sValue) { @Override public void setString(String sValue) {
super.setString(sValue); super.setString(sValue);
if ("css1_hack".equals(sValue)) { nValue = CSS1_HACK; } if ("css1_hack".equals(sValue)) { nValue = CSS1_HACK; }

View file

@ -63,8 +63,8 @@ public class ListParser extends Parser {
} }
} }
protected void insertListLabel(ListStyle style, String sDefaultStyle, String sPrefix, Element hnode) { protected void insertListLabel(ListStyle style, int nLevel, String sDefaultStyle, String sPrefix, String sLabel, Element hnode) {
if (sCurrentListLabel!=null && sCurrentListLabel.length()>0) { if (sLabel!=null && sLabel.length()>0) {
if (sPrefix!=null) { if (sPrefix!=null) {
Element prefix = converter.createElement("span"); Element prefix = converter.createElement("span");
prefix.setAttribute("class", "chapter-name"); prefix.setAttribute("class", "chapter-name");
@ -73,7 +73,7 @@ public class ListParser extends Parser {
} }
StyleInfo info = new StyleInfo(); StyleInfo info = new StyleInfo();
if (style!=null) { if (style!=null) {
String sTextStyleName = style.getLevelProperty(nCurrentListLevel,TEXT_STYLE_NAME); String sTextStyleName = style.getLevelProperty(nLevel,TEXT_STYLE_NAME);
getTextSP().readStyle(sTextStyleName, info); getTextSP().readStyle(sTextStyleName, info);
} }
@ -83,8 +83,7 @@ public class ListParser extends Parser {
Element content = converter.createElement(info.sTagName); Element content = converter.createElement(info.sTagName);
getTextSP().writeStyle(info, content); getTextSP().writeStyle(info, content);
hnode.appendChild(content); hnode.appendChild(content);
content.appendChild( converter.createTextNode(sCurrentListLabel) ); content.appendChild( converter.createTextNode(sLabel) );
sCurrentListLabel = "";
} }
} }
@ -119,7 +118,6 @@ public class ListParser extends Parser {
Element list = converter.createElement("ul"); Element list = converter.createElement("ul");
StyleInfo listInfo = new StyleInfo(); StyleInfo listInfo = new StyleInfo();
getListSP().applyStyle(nLevel,sStyleName,listInfo); getListSP().applyStyle(nLevel,sStyleName,listInfo);
getListSP().readParentStyle(nLevel, sStyleName, listInfo);
writeStyle(listInfo,list); writeStyle(listInfo,list);
hnode.appendChild(list); hnode.appendChild(list);
traverseList(onode,nLevel,sStyleName,list); traverseList(onode,nLevel,sStyleName,list);

View file

@ -43,7 +43,6 @@ import w2phtml.office.OfficeStyle;
import w2phtml.office.PageLayout; import w2phtml.office.PageLayout;
import w2phtml.office.StyleWithProperties; import w2phtml.office.StyleWithProperties;
import w2phtml.office.XMLString; import w2phtml.office.XMLString;
import w2phtml.pageSplitters.ListBreaksFix;
import w2phtml.pageSplitters.SplitFactory; import w2phtml.pageSplitters.SplitFactory;
import w2phtml.util.Misc; import w2phtml.util.Misc;
import w2phtml.xhtml.Converter; import w2phtml.xhtml.Converter;
@ -74,7 +73,9 @@ public class TextParser extends Parser {
Element[] currentHeading = new Element[7]; // Last headings (repeated when splitting) Element[] currentHeading = new Element[7]; // Last headings (repeated when splitting)
// Counters for generated numbers // Counters for generated numbers
private String sCurrentListLabel = null;
private ListStyle currentListStyle = null; private ListStyle currentListStyle = null;
private int nCurrentListLevel = 0;
public Separator docSep = null; public Separator docSep = null;
@ -173,8 +174,6 @@ public class TextParser extends Parser {
//ODFPageSplitter.splitOfficeText(onode, ofr); //ODFPageSplitter.splitOfficeText(onode, ofr);
//Debug.prettyPrintXml(onode.getOwnerDocument()); //Debug.prettyPrintXml(onode.getOwnerDocument());
SplitFactory splitters = new SplitFactory(ofr); SplitFactory splitters = new SplitFactory(ofr);
ListBreaksFix listBreaksFix = new ListBreaksFix(ofr);
listBreaksFix.addSPBsBeforeBreaksInLists(onode);
splitters.split(onode); splitters.split(onode);
//Debug.prettyPrintXml(onode.getOwnerDocument()); //Debug.prettyPrintXml(onode.getOwnerDocument());
} }
@ -600,7 +599,7 @@ public class TextParser extends Parser {
// Prepend numbering // Prepend numbering
if (!bUnNumbered) { if (!bUnNumbered) {
getListParser().insertListLabel(listStyle, "SectionNumber", null, heading); getListParser().insertListLabel(listStyle, nListLevel, "SectionNumber", null, sLabel, heading);
} }
// Add to toc // Add to toc
@ -665,18 +664,21 @@ public class TextParser extends Parser {
hnode.appendChild(temp.getFirstChild()); hnode.appendChild(temp.getFirstChild());
// Maybe add to toc // Maybe add to toc
tocParser.handleParagraph((Element)onode, par, sCurrentListLabel);
if (!isEmptyParagraph) { if (!isEmptyParagraph) {
par = createTextBackground(par, styleName); par = createTextBackground(par, styleName);
if (config.listFormatting()==XhtmlConfig.HARD_LABELS) { if (config.listFormatting()==XhtmlConfig.HARD_LABELS) {
getListParser().insertListLabel(currentListStyle, "ItemNumber", null, par); getListParser().insertListLabel(currentListStyle, nCurrentListLevel, "ItemNumber", null, sCurrentListLabel, par);
} }
sCurrentListLabel = null;
traverseInlineText(onode,par); traverseInlineText(onode,par);
} }
else { else {
// An empty paragraph (this includes paragraphs that only contains // An empty paragraph (this includes paragraphs that only contains
// whitespace) is ignored by the browser, hence we add &nbsp; // whitespace) is ignored by the browser, hence we add &nbsp;
par.appendChild( converter.createTextNode("\u00A0") ); par.appendChild( converter.createTextNode("\u00A0") );
sCurrentListLabel = null;
} }
if (converter.isOPS() && !par.hasChildNodes()) { if (converter.isOPS() && !par.hasChildNodes()) {

View file

@ -6,6 +6,7 @@ import java.util.List;
import static org.junit.jupiter.api.Assertions.assertTrue; 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.DisplayName;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -24,6 +25,6 @@ public class PageBreaksBeforeHeading {
w2phtml.Application.main(arguments.toArray(new String[0])); w2phtml.Application.main(arguments.toArray(new String[0]));
File result = new File("./testdocuments/output/heading_with_page_break_before.html"); File result = new File("./testdocuments/output/heading_with_page_break_before.html");
File model = new File("./testdocuments/model/heading_with_page_break_before.html"); File model = new File("./testdocuments/model/heading_with_page_break_before.html");
assertTrue( TestFiles.equals(result, model),"The files differ!"); assertTrue( FileUtils.contentEquals(result, model),"The files differ!");
} }
} }

View file

@ -5,7 +5,6 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import w2phtml.regressionTests.TestFiles;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.DisplayName;
@ -27,6 +26,6 @@ public class BreakAfterTest {
w2phtml.Application.main(arguments.toArray(new String[0])); w2phtml.Application.main(arguments.toArray(new String[0]));
File result = new File("./testdocuments/output/" + name + ".html"); File result = new File("./testdocuments/output/" + name + ".html");
File model = new File("./testdocuments/model/" + name + ".html"); File model = new File("./testdocuments/model/" + name + ".html");
assertTrue(TestFiles.equals(result, model), "The files differ!"); assertTrue(FileUtils.contentEquals(result, model), "The files differ!");
} }
} }

View file

@ -6,11 +6,10 @@ import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.apache.commons.io.FileUtils;
import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import w2phtml.regressionTests.TestFiles;
public class BulletList { public class BulletList {
@Test @Test
@DisplayName("List on multiple pages") @DisplayName("List on multiple pages")
@ -27,6 +26,6 @@ public class BulletList {
w2phtml.Application.main(arguments.toArray(new String[0])); w2phtml.Application.main(arguments.toArray(new String[0]));
File result = new File("./testdocuments/output/" + name + ".html"); File result = new File("./testdocuments/output/" + name + ".html");
File model = new File("./testdocuments/model/" + name + ".html"); File model = new File("./testdocuments/model/" + name + ".html");
assertTrue(TestFiles.equals(result, model), "The files differ!"); assertTrue(FileUtils.contentEquals(result, model), "The files differ!");
} }
} }

View file

@ -6,11 +6,10 @@ import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.apache.commons.io.FileUtils;
import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import w2phtml.regressionTests.TestFiles;
public class GreenstoneHeadings { public class GreenstoneHeadings {
@Test @Test
@DisplayName("Greenstone3 tags headings") @DisplayName("Greenstone3 tags headings")
@ -26,6 +25,6 @@ public class GreenstoneHeadings {
w2phtml.Application.main(arguments.toArray(new String[0])); w2phtml.Application.main(arguments.toArray(new String[0]));
File result = new File("./testdocuments/output/" + testName + ".html"); File result = new File("./testdocuments/output/" + testName + ".html");
File model = new File("./testdocuments/model/" + testName + ".html"); File model = new File("./testdocuments/model/" + testName + ".html");
assertTrue(TestFiles.equals(result, model), "The files differ!"); assertTrue(FileUtils.contentEquals(result, model), "The files differ!");
} }
} }

View file

@ -6,11 +6,10 @@ import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.apache.commons.io.FileUtils;
import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import w2phtml.regressionTests.TestFiles;
public class HeadingWithSections { public class HeadingWithSections {
@Test @Test
@DisplayName("Heading with sections") @DisplayName("Heading with sections")
@ -25,6 +24,6 @@ public class HeadingWithSections {
w2phtml.Application.main(arguments.toArray(new String[0])); w2phtml.Application.main(arguments.toArray(new String[0]));
File result = new File("./testdocuments/output/"+testName+".html"); File result = new File("./testdocuments/output/"+testName+".html");
File model = new File("./testdocuments/model/"+testName+".html"); File model = new File("./testdocuments/model/"+testName+".html");
assertTrue(TestFiles.equals(result, model),"The files differ!"); assertTrue( FileUtils.contentEquals(result, model),"The files differ!");
} }
} }

View file

@ -6,11 +6,10 @@ import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.apache.commons.io.FileUtils;
import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import w2phtml.regressionTests.TestFiles;
public class ImageAfterSection { public class ImageAfterSection {
@Test @Test
@DisplayName("image after section") @DisplayName("image after section")
@ -25,6 +24,6 @@ public class ImageAfterSection {
w2phtml.Application.main(arguments.toArray(new String[0])); w2phtml.Application.main(arguments.toArray(new String[0]));
File result = new File("./testdocuments/output/" + testName + ".html"); File result = new File("./testdocuments/output/" + testName + ".html");
File model = new File("./testdocuments/model/" + testName + ".html"); File model = new File("./testdocuments/model/" + testName + ".html");
assertTrue(TestFiles.equals(result, model), "The files differ!"); assertTrue(FileUtils.contentEquals(result, model), "The files differ!");
} }
} }

View file

@ -6,11 +6,10 @@ import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.apache.commons.io.FileUtils;
import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import w2phtml.regressionTests.TestFiles;
public class ListInSection { public class ListInSection {
@Test @Test
@DisplayName("List in section") @DisplayName("List in section")
@ -27,6 +26,6 @@ public class ListInSection {
w2phtml.Application.main(arguments.toArray(new String[0])); w2phtml.Application.main(arguments.toArray(new String[0]));
File result = new File("./testdocuments/output/" + name + ".html"); File result = new File("./testdocuments/output/" + name + ".html");
File model = new File("./testdocuments/model/" + name + ".html"); File model = new File("./testdocuments/model/" + name + ".html");
assertTrue(TestFiles.equals(result, model), "The files differ!"); assertTrue(FileUtils.contentEquals(result, model), "The files differ!");
} }
} }

View file

@ -6,11 +6,10 @@ import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.apache.commons.io.FileUtils;
import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import w2phtml.regressionTests.TestFiles;
public class ListInTable { public class ListInTable {
@Test @Test
@DisplayName("list in table") @DisplayName("list in table")
@ -25,6 +24,6 @@ public class ListInTable {
w2phtml.Application.main(arguments.toArray(new String[0])); w2phtml.Application.main(arguments.toArray(new String[0]));
File result = new File("./testdocuments/output/" + testName + ".html"); File result = new File("./testdocuments/output/" + testName + ".html");
File model = new File("./testdocuments/model/" + testName + ".html"); File model = new File("./testdocuments/model/" + testName + ".html");
assertTrue(TestFiles.equals(result, model), "The files differ!"); assertTrue(FileUtils.contentEquals(result, model), "The files differ!");
} }
} }

View file

@ -6,11 +6,10 @@ import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.apache.commons.io.FileUtils;
import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import w2phtml.regressionTests.TestFiles;
public class ListTableSection { public class ListTableSection {
@Test @Test
@DisplayName("list in table in section") @DisplayName("list in table in section")
@ -25,6 +24,6 @@ public class ListTableSection {
w2phtml.Application.main(arguments.toArray(new String[0])); w2phtml.Application.main(arguments.toArray(new String[0]));
File result = new File("./testdocuments/output/" + testName + ".html"); File result = new File("./testdocuments/output/" + testName + ".html");
File model = new File("./testdocuments/model/" + testName + ".html"); File model = new File("./testdocuments/model/" + testName + ".html");
assertTrue(TestFiles.equals(result, model), "The files differ!"); assertTrue(FileUtils.contentEquals(result, model), "The files differ!");
} }
} }

View file

@ -6,11 +6,10 @@ import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.apache.commons.io.FileUtils;
import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import w2phtml.regressionTests.TestFiles;
public class PageStartWith10 { public class PageStartWith10 {
@Test @Test
@DisplayName("start page from 10 in section") @DisplayName("start page from 10 in section")
@ -25,6 +24,6 @@ public class PageStartWith10 {
w2phtml.Application.main(arguments.toArray(new String[0])); w2phtml.Application.main(arguments.toArray(new String[0]));
File result = new File("./testdocuments/output/" + testName + ".html"); File result = new File("./testdocuments/output/" + testName + ".html");
File model = new File("./testdocuments/model/" + testName + ".html"); File model = new File("./testdocuments/model/" + testName + ".html");
assertTrue(TestFiles.equals(result, model), "The files differ!"); assertTrue(FileUtils.contentEquals(result, model), "The files differ!");
} }
} }

View file

@ -6,11 +6,10 @@ import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.apache.commons.io.FileUtils;
import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import w2phtml.regressionTests.TestFiles;
public class PageStartWith10InSection { public class PageStartWith10InSection {
@Test @Test
@DisplayName("start page from 10") @DisplayName("start page from 10")
@ -25,6 +24,6 @@ public class PageStartWith10InSection {
w2phtml.Application.main(arguments.toArray(new String[0])); w2phtml.Application.main(arguments.toArray(new String[0]));
File result = new File("./testdocuments/output/" + testName + ".html"); File result = new File("./testdocuments/output/" + testName + ".html");
File model = new File("./testdocuments/model/" + testName + ".html"); File model = new File("./testdocuments/model/" + testName + ".html");
assertTrue(TestFiles.equals(result, model), "The files differ!"); assertTrue(FileUtils.contentEquals(result, model), "The files differ!");
} }
} }

View file

@ -6,11 +6,10 @@ import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.apache.commons.io.FileUtils;
import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import w2phtml.regressionTests.TestFiles;
public class SoftPageBreakInListTest { public class SoftPageBreakInListTest {
@Test @Test
@DisplayName("Soft page break in list") @DisplayName("Soft page break in list")
@ -27,6 +26,6 @@ public class SoftPageBreakInListTest {
w2phtml.Application.main(arguments.toArray(new String[0])); w2phtml.Application.main(arguments.toArray(new String[0]));
File result = new File("./testdocuments/output/" + name + ".html"); File result = new File("./testdocuments/output/" + name + ".html");
File model = new File("./testdocuments/model/" + name + ".html"); File model = new File("./testdocuments/model/" + name + ".html");
assertTrue(TestFiles.equals(result, model), "The files differ!"); assertTrue(FileUtils.contentEquals(result, model), "The files differ!");
} }
} }

View file

@ -6,11 +6,10 @@ import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.apache.commons.io.FileUtils;
import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import w2phtml.regressionTests.TestFiles;
public class SplitFilesAlignToPages { public class SplitFilesAlignToPages {
@Test @Test
@DisplayName("Split files align to pages") @DisplayName("Split files align to pages")
@ -29,8 +28,8 @@ public class SplitFilesAlignToPages {
File result2 = new File("./testdocuments/output/" + testName + "1.html"); File result2 = new File("./testdocuments/output/" + testName + "1.html");
File model1 = new File("./testdocuments/model/" + testName + ".html"); File model1 = new File("./testdocuments/model/" + testName + ".html");
File model2 = new File("./testdocuments/model/" + testName + "1.html"); File model2 = new File("./testdocuments/model/" + testName + "1.html");
assertTrue(TestFiles.equals(result1, model1), "The files differ!"); assertTrue(FileUtils.contentEquals(result1, model1), "The files differ!");
assertTrue(TestFiles.equals(result2, model2), "The files differ!"); assertTrue(FileUtils.contentEquals(result2, model2), "The files differ!");
} }
} }

View file

@ -1,23 +0,0 @@
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;
}
}

View file

@ -1,32 +0,0 @@
package w2phtml.regressionTests.html5;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
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")
void testExample() throws Exception {
String name = "list_hpb";
File input = new File("./testdocuments/input/" + name + ".odt");
assertTrue(input.exists());
List<String> arguments = new ArrayList<String>();
arguments.add("-page_break_style");
arguments.add("height:3em;margin-top:1em;margin-bottom:1em;background-color:red;");
arguments.add("-html5");
arguments.add("./testdocuments/input/" + name + ".odt");
arguments.add("./testdocuments/output/" + name + ".html");
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(TestFiles.equals(result, model), "The files differ!");
}
}

View file

@ -1,32 +0,0 @@
package w2phtml.regressionTests.html5;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
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")
void testExample() throws Exception {
String name = "list_after_spb";
File input = new File("./testdocuments/input/" + name + ".odt");
assertTrue(input.exists());
List<String> arguments = new ArrayList<String>();
arguments.add("-page_break_style");
arguments.add("height:3em;margin-top:1em;margin-bottom:1em;background-color:red;");
arguments.add("-html5");
arguments.add("./testdocuments/input/" + name + ".odt");
arguments.add("./testdocuments/output/" + name + ".html");
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(TestFiles.equals(result, model), "The files differ!");
}
}

Binary file not shown.

View file

@ -10,9 +10,9 @@
<body dir="ltr"> <body dir="ltr">
<div class="pageNum" page="1"> <div class="pageNum" page="1">
<div class="pageContainer" style="column-count: 1;"> <div class="pageContainer" style="column-count: 1;">
<ul style="margin-left:0;list-style-type:none;padding-left:0;clear:left;margin-top:0;font-family:OpenSymbol;margin-bottom:0;"> <ul style="list-style-type:disc;clear:left;margin-top:0;font-family:OpenSymbol;margin-bottom:0;">
<li> <li>
<p class="Textbody" style="margin-left:0;border:none;padding:0;text-indent:2.1259842rem;font-size:3.3333335rem;margin-top:0;font-family:&apos;IPH Astra Serif&apos;,serif;margin-bottom:0.58346456rem;margin-right:0;"><span class="ItemNumber"></span>Text text</p> <p class="Textbody" style="margin-left:0;border:none;padding:0;text-indent:2.1259842rem;font-size:3.3333335rem;margin-top:0;font-family:&apos;IPH Astra Serif&apos;,serif;margin-bottom:0.58346456rem;margin-right:0;">Text text</p>
</li> </li>
</ul> </ul>
</div> </div>
@ -20,9 +20,9 @@
<div class="pageBreak" style="height:3em;margin-top:1em;margin-bottom:1em;background-color:red;"> </div> <div class="pageBreak" style="height:3em;margin-top:1em;margin-bottom:1em;background-color:red;"> </div>
<div class="pageNum" page="2"> <div class="pageNum" page="2">
<div class="pageContainer" style="column-count: 1;"> <div class="pageContainer" style="column-count: 1;">
<ul style="margin-left:0;list-style-type:none;padding-left:0;clear:left;margin-top:0;font-family:OpenSymbol;margin-bottom:0;"> <ul start="2" style="list-style-type:disc;clear:left;margin-top:0;font-family:OpenSymbol;margin-bottom:0;">
<li> <li>
<p class="Textbody" style="margin-left:0;border:none;padding:0;text-indent:2.1259842rem;font-size:3.3333335rem;margin-top:0;font-family:&apos;IPH Astra Serif&apos;,serif;margin-bottom:0.58346456rem;margin-right:0;"><span class="ItemNumber"></span>text adfa </p> <p class="Textbody" style="margin-left:0;border:none;padding:0;text-indent:2.1259842rem;font-size:3.3333335rem;margin-top:0;font-family:&apos;IPH Astra Serif&apos;,serif;margin-bottom:0.58346456rem;margin-right:0;">text adfa </p>
</li> </li>
</ul> </ul>
</div> </div>

View file

@ -1,43 +0,0 @@
<!DOCTYPE html>
<html lang="ru-RU" xml:lang="ru-RU" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Default</title>
<meta charset="UTF-8" />
<style media="all" type="text/css">
body {margin-left:auto;max-width:800px;font-size:1.0rem;font-family:'IPH Lib Serif';margin-right:auto;}
</style>
</head>
<body dir="ltr">
<div class="pageNum" page="1">
<div class="pageContainer" style="column-count: 1;">
<p class="Textbody" style="margin-left:0;border:none;padding:0;text-indent:2.1259842rem;font-size:1.0rem;margin-top:0;font-family:&apos;IPH Astra Serif&apos;,serif;margin-bottom:0.58346456rem;margin-right:0;">text0</p>
</div>
</div>
<div class="pageBreak" style="height:3em;margin-top:1em;margin-bottom:1em;background-color:red;"> </div>
<div class="pageNum" page="2">
<div class="pageContainer" style="column-count: 1;">
<ul class="listlevel1List2" style="margin-left:0;list-style-type:none;padding-left:0;clear:left;margin-top:0;font-family:&apos;IPH Astra Serif&apos;,serif;margin-bottom:0;">
<li>
<p class="Textbody" style="margin-left:0;border:none;padding:0;text-indent:2.1259842rem;font-size:1.0rem;margin-top:0;font-family:&apos;IPH Astra Serif&apos;,serif;margin-bottom:0.58346456rem;margin-right:0;"><span class="ItemNumber"> </span>list1</p>
</li>
</ul>
</div>
</div>
<div class="pageBreak" style="height:3em;margin-top:1em;margin-bottom:1em;background-color:red;"> </div>
<div class="pageNum" page="3">
<div class="pageContainer" style="column-count: 1;">
<ul class="listlevel1List2" style="margin-left:0;list-style-type:none;padding-left:0;clear:left;margin-top:0;font-family:&apos;IPH Astra Serif&apos;,serif;margin-bottom:0;">
<li>
<p class="Textbody" style="margin-left:0;border:none;padding:0;text-indent:2.1259842rem;font-size:1.0rem;margin-top:0;font-family:&apos;IPH Astra Serif&apos;,serif;margin-bottom:0.58346456rem;margin-right:0;"><span class="ItemNumber"> </span>list2</p>
</li>
</ul>
</div>
</div>
<div class="pageBreak" style="height:3em;margin-top:1em;margin-bottom:1em;background-color:red;"> </div>
<div class="pageNum" page="4">
<div class="pageContainer" style="column-count: 1;">
<p class="Textbody" style="margin-left:0;border:none;padding:0;text-indent:2.1259842rem;font-size:1.0rem;margin-top:0;font-family:&apos;IPH Astra Serif&apos;,serif;margin-bottom:0.58346456rem;margin-right:0;">text4</p>
</div>
</div>
</body>
</html>

View file

@ -1,71 +0,0 @@
<!DOCTYPE html>
<html lang="ru-RU" xml:lang="ru-RU" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Default</title>
<meta charset="UTF-8" />
<style media="all" type="text/css">
body {margin-left:auto;max-width:800px;font-size:1.0rem;font-family:'IPH Lib Serif';margin-right:auto;}
</style>
</head>
<body dir="ltr">
<div class="pageNum" page="1">
<div class="pageContainer" style="column-count: 1;">
<ul style="margin-left:0;list-style-type:none;padding-left:0;clear:left;margin-top:0;font-family:OpenSymbol;margin-bottom:0;">
<li>
<p class="Textbody" style="margin-left:0;border:none;padding:0;text-indent:2.1259842rem;font-size:3.3333335rem;margin-top:0;font-family:&apos;IPH Astra Serif&apos;,serif;page-break-before:always;margin-bottom:0.58346456rem;margin-right:0;"><span class="ItemNumber"></span>text 1</p>
</li>
</ul>
</div>
</div>
<div class="pageBreak" style="height:3em;margin-top:1em;margin-bottom:1em;background-color:red;"> </div>
<div class="pageNum" page="2">
<div class="pageContainer" style="column-count: 1;">
<ul style="margin-left:0;list-style-type:none;padding-left:0;clear:left;margin-top:0;font-family:OpenSymbol;margin-bottom:0;">
<li>
<p class="Textbody" style="margin-left:0;border:none;padding:0;text-indent:2.1259842rem;font-size:3.3333335rem;margin-top:0;font-family:&apos;IPH Astra Serif&apos;,serif;page-break-before:always;margin-bottom:0.58346456rem;margin-right:0;"><span class="ItemNumber"></span>text 2</p>
</li>
</ul>
</div>
</div>
<div class="pageBreak" style="height:3em;margin-top:1em;margin-bottom:1em;background-color:red;"> </div>
<div class="pageNum" page="3">
<div class="pageContainer" style="column-count: 1;">
<ul style="margin-left:0;list-style-type:none;padding-left:0;clear:left;margin-top:0;font-family:OpenSymbol;margin-bottom:0;">
<li>
<p class="Textbody" style="margin-left:0;border:none;padding:0;text-indent:2.1259842rem;font-size:3.3333335rem;margin-top:0;font-family:&apos;IPH Astra Serif&apos;,serif;page-break-before:always;margin-bottom:0.58346456rem;margin-right:0;"><span class="ItemNumber"></span>text 3</p>
</li>
</ul>
</div>
</div>
<div class="pageBreak" style="height:3em;margin-top:1em;margin-bottom:1em;background-color:red;"> </div>
<div class="pageNum" page="4">
<div class="pageContainer" style="column-count: 1;">
<ol style="margin-left:0;list-style-type:none;padding-left:0;clear:left;margin-top:0;margin-bottom:0;">
<li>
<p class="Textbody" style="margin-left:0;border:none;padding:0;text-indent:2.1259842rem;font-size:3.3333335rem;margin-top:0;font-family:&apos;IPH Astra Serif&apos;,serif;page-break-before:always;margin-bottom:0.58346456rem;margin-right:0;"><span class="ItemNumber">1. </span>Text1</p>
</li>
</ol>
</div>
</div>
<div class="pageBreak" style="height:3em;margin-top:1em;margin-bottom:1em;background-color:red;"> </div>
<div class="pageNum" page="5">
<div class="pageContainer" style="column-count: 1;">
<ol style="margin-left:0;list-style-type:none;padding-left:0;clear:left;margin-top:0;margin-bottom:0;">
<li>
<p class="Textbody" style="margin-left:0;border:none;padding:0;text-indent:2.1259842rem;font-size:3.3333335rem;margin-top:0;font-family:&apos;IPH Astra Serif&apos;,serif;page-break-before:always;margin-bottom:0.58346456rem;margin-right:0;"><span class="ItemNumber">2. </span>Text2 </p>
</li>
</ol>
</div>
</div>
<div class="pageBreak" style="height:3em;margin-top:1em;margin-bottom:1em;background-color:red;"> </div>
<div class="pageNum" page="6">
<div class="pageContainer" style="column-count: 1;">
<ol style="margin-left:0;list-style-type:none;padding-left:0;clear:left;margin-top:0;margin-bottom:0;">
<li>
<p class="Textbody" style="margin-left:0;border:none;padding:0;text-indent:2.1259842rem;font-size:3.3333335rem;margin-top:0;font-family:&apos;IPH Astra Serif&apos;,serif;page-break-before:always;margin-bottom:0.58346456rem;margin-right:0;"><span class="ItemNumber">3. </span>Text3</p>
</li>
</ol>
</div>
</div>
</body>
</html>

View file

@ -10,12 +10,12 @@
<body dir="ltr"> <body dir="ltr">
<div class="pageNum" page="1"> <div class="pageNum" page="1">
<div class="pageContainer" style="column-count: 1;"> <div class="pageContainer" style="column-count: 1;">
<ul style="margin-left:0;list-style-type:none;padding-left:0;clear:left;margin-top:0;font-family:OpenSymbol;margin-bottom:0;"> <ul style="list-style-type:disc;clear:left;margin-top:0;font-family:OpenSymbol;margin-bottom:0;">
<li> <li>
<p class="Textbody" style="margin-left:0;border:none;padding:0;text-indent:2.1259842rem;font-size:1.0rem;margin-top:0;font-family:&apos;IPH Astra Serif&apos;,serif;margin-bottom:0.58346456rem;margin-right:0;"><span class="ItemNumber"></span>List first </p> <p class="Textbody" style="margin-left:0;border:none;padding:0;text-indent:2.1259842rem;font-size:1.0rem;margin-top:0;font-family:&apos;IPH Astra Serif&apos;,serif;margin-bottom:0.58346456rem;margin-right:0;">List first </p>
</li> </li>
<li> <li>
<p class="Textbody" style="margin-left:0;border:none;padding:0;text-indent:2.1259842rem;font-size:1.0rem;margin-top:0;font-family:&apos;IPH Astra Serif&apos;,serif;margin-bottom:0.58346456rem;margin-right:0;"><span class="ItemNumber"></span>text text text text text text text text text text text text text text text text text  text text text st1 </p> <p class="Textbody" style="margin-left:0;border:none;padding:0;text-indent:2.1259842rem;font-size:1.0rem;margin-top:0;font-family:&apos;IPH Astra Serif&apos;,serif;margin-bottom:0.58346456rem;margin-right:0;">text text text text text text text text text text text text text text text text text  text text text st1 </p>
</li> </li>
</ul> </ul>
</div> </div>
@ -42,9 +42,9 @@
<div class="pageNum" page="3"> <div class="pageNum" page="3">
<div class="pageContainer" style="column-count: 1;"> <div class="pageContainer" style="column-count: 1;">
<p class="Textbody" style="margin-left:0;border:none;padding:0;text-indent:0;font-size:1.0rem;margin-top:0;font-family:&apos;IPH Astra Serif&apos;,serif;margin-bottom:0.58346456rem;margin-right:0;">3test test test test test test www</p> <p class="Textbody" style="margin-left:0;border:none;padding:0;text-indent:0;font-size:1.0rem;margin-top:0;font-family:&apos;IPH Astra Serif&apos;,serif;margin-bottom:0.58346456rem;margin-right:0;">3test test test test test test www</p>
<ul style="margin-left:0;list-style-type:none;padding-left:0;clear:left;margin-top:0;font-family:OpenSymbol;margin-bottom:0;"> <ul start="3" style="list-style-type:disc;clear:left;margin-top:0;font-family:OpenSymbol;margin-bottom:0;">
<li> <li>
<p class="Textbody" style="margin-left:0;border:none;padding:0;text-indent:2.1259842rem;font-size:1.0rem;margin-top:0;font-family:&apos;IPH Astra Serif&apos;,serif;margin-bottom:0.58346456rem;margin-right:0;"><span class="ItemNumber"></span>text</p> <p class="Textbody" style="margin-left:0;border:none;padding:0;text-indent:2.1259842rem;font-size:1.0rem;margin-top:0;font-family:&apos;IPH Astra Serif&apos;,serif;margin-bottom:0.58346456rem;margin-right:0;">text</p>
</li> </li>
</ul> </ul>
</div> </div>

View file

@ -16,7 +16,7 @@
</colgroup> </colgroup>
<tbody> <tbody>
<tr> <tr>
<td style="border:0.004166667rem solid #000000;padding:0.11574804rem;vertical-align:top;"><ul style="margin-left:0;list-style-type:none;padding-left:0;clear:left;margin-top:0;font-family:OpenSymbol;margin-bottom:0;"><li><p class="Textbody" style="margin-left:0;border:none;padding:0;text-indent:2.1259842rem;font-size:1.0rem;margin-top:0;font-family:&apos;IPH Astra Serif&apos;,serif;margin-bottom:0.58346456rem;margin-right:0;"><span class="ItemNumber"></span><span style="font-size:3.3333335rem;font-family:&apos;IPH Astra Serif&apos;,serif;">text tex1 </span></p></li></ul></td> <td style="border:0.004166667rem solid #000000;padding:0.11574804rem;vertical-align:top;"><ul style="list-style-type:disc;clear:left;margin-top:0;font-family:OpenSymbol;margin-bottom:0;"><li><p class="Textbody" style="margin-left:0;border:none;padding:0;text-indent:2.1259842rem;font-size:1.0rem;margin-top:0;font-family:&apos;IPH Astra Serif&apos;,serif;margin-bottom:0.58346456rem;margin-right:0;"><span style="font-size:3.3333335rem;font-family:&apos;IPH Astra Serif&apos;,serif;">text tex1 </span></p></li></ul></td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
@ -37,7 +37,7 @@
</tr> </tr>
</tbody> </tbody>
</table> </table>
<ul style="margin-left:0;list-style-type:none;padding-left:0;clear:left;margin-top:0;font-family:OpenSymbol;margin-bottom:0;"> <ul start="2" style="list-style-type:disc;clear:left;margin-top:0;font-family:OpenSymbol;margin-bottom:0;">
<li style="list-style-type:none"> <li style="list-style-type:none">
<p class="Textbody" style="margin-left:0;border:none;padding:0;text-indent:2.1259842rem;font-size:1.0rem;margin-top:0;font-family:&apos;IPH Astra Serif&apos;,serif;margin-bottom:0.58346456rem;margin-right:0;"> </p> <p class="Textbody" style="margin-left:0;border:none;padding:0;text-indent:2.1259842rem;font-size:1.0rem;margin-top:0;font-family:&apos;IPH Astra Serif&apos;,serif;margin-bottom:0.58346456rem;margin-right:0;"> </p>
</li> </li>

View file

@ -20,7 +20,7 @@
<td style="vertical-align:top;"> <td style="vertical-align:top;">
<p style="margin:0;font-size:1px"> </p> <p style="margin:0;font-size:1px"> </p>
</td> </td>
<td style="vertical-align:top;"><ul style="margin-left:0;list-style-type:none;padding-left:0;clear:left;margin-top:0;font-family:OpenSymbol;margin-bottom:0;"><li><p class="Textbody" style="margin-left:0;border:none;padding:0;text-indent:2.1259842rem;font-size:1.0rem;margin-top:0;font-family:&apos;IPH Astra Serif&apos;,serif;margin-bottom:0.58346456rem;margin-right:0;"><span class="ItemNumber"></span>List first line</p></li><li><p class="Textbody" style="margin-left:0;border:none;padding:0;text-indent:2.1259842rem;font-size:1.0rem;margin-top:0;font-family:&apos;IPH Astra Serif&apos;,serif;margin-bottom:0.58346456rem;margin-right:0;"><span class="ItemNumber"></span>text text text text text text text tex1 </p></li></ul></td> <td style="vertical-align:top;"><ul style="list-style-type:disc;clear:left;margin-top:0;font-family:OpenSymbol;margin-bottom:0;"><li><p class="Textbody" style="margin-left:0;border:none;padding:0;text-indent:2.1259842rem;font-size:1.0rem;margin-top:0;font-family:&apos;IPH Astra Serif&apos;,serif;margin-bottom:0.58346456rem;margin-right:0;">List first line</p></li><li><p class="Textbody" style="margin-left:0;border:none;padding:0;text-indent:2.1259842rem;font-size:1.0rem;margin-top:0;font-family:&apos;IPH Astra Serif&apos;,serif;margin-bottom:0.58346456rem;margin-right:0;">text text text text text text text tex1 </p></li></ul></td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
@ -99,7 +99,7 @@
<td style="vertical-align:top;"> <td style="vertical-align:top;">
<p style="margin:0;font-size:1px"> </p> <p style="margin:0;font-size:1px"> </p>
</td> </td>
<td style="vertical-align:top;"><p class="Textbody" style="margin-left:0;border:none;padding:0;text-indent:0;font-size:1.0rem;margin-top:0;font-family:&apos;IPH Astra Serif&apos;,serif;margin-bottom:0.58346456rem;margin-right:0;">4text text text text text text text text</p><ul style="margin-left:0;list-style-type:none;padding-left:0;clear:left;margin-top:0;font-family:OpenSymbol;margin-bottom:0;"><li><p class="Textbody" style="margin-left:0;border:none;padding:0;text-indent:2.1259842rem;font-size:1.0rem;margin-top:0;font-family:&apos;IPH Astra Serif&apos;,serif;margin-bottom:0.58346456rem;margin-right:0;"><span class="ItemNumber"></span> text text text text4  </p></li></ul></td> <td style="vertical-align:top;"><p class="Textbody" style="margin-left:0;border:none;padding:0;text-indent:0;font-size:1.0rem;margin-top:0;font-family:&apos;IPH Astra Serif&apos;,serif;margin-bottom:0.58346456rem;margin-right:0;">4text text text text text text text text</p><ul start="3" style="list-style-type:disc;clear:left;margin-top:0;font-family:OpenSymbol;margin-bottom:0;"><li><p class="Textbody" style="margin-left:0;border:none;padding:0;text-indent:2.1259842rem;font-size:1.0rem;margin-top:0;font-family:&apos;IPH Astra Serif&apos;,serif;margin-bottom:0.58346456rem;margin-right:0;"> text text text text4  </p></li></ul></td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
@ -138,9 +138,9 @@
</tr> </tr>
</tbody> </tbody>
</table> </table>
<ul style="margin-left:0;list-style-type:none;padding-left:0;clear:left;margin-top:0;font-family:OpenSymbol;margin-bottom:0;"> <ul start="4" style="list-style-type:disc;clear:left;margin-top:0;font-family:OpenSymbol;margin-bottom:0;">
<li> <li>
<p class="Textbody" style="margin-left:0;border:none;padding:0;text-indent:2.1259842rem;font-size:1.0rem;margin-top:0;font-family:&apos;IPH Astra Serif&apos;,serif;margin-bottom:0.58346456rem;margin-right:0;"><span class="ItemNumber"></span>Numbering list 2</p> <p class="Textbody" style="margin-left:0;border:none;padding:0;text-indent:2.1259842rem;font-size:1.0rem;margin-top:0;font-family:&apos;IPH Astra Serif&apos;,serif;margin-bottom:0.58346456rem;margin-right:0;">Numbering list 2</p>
</li> </li>
</ul> </ul>
</div> </div>

View file

@ -12,16 +12,24 @@
<body dir="ltr"> <body dir="ltr">
<div class="pageNum" page="1"> <div class="pageNum" page="1">
<div class="pageContainer" style="column-count: 1;"> <div class="pageContainer" style="column-count: 1;">
<ol class="listlevel1Numbering123" style="margin-left:0;list-style-type:none;padding-left:0;clear:left;margin-top:0;font-family:&apos;IPH Astra Serif&apos;,serif;margin-bottom:0;"> <ol class="listlevel1Numbering123" style="list-style-type:decimal;clear:left;margin-top:0;font-family:&apos;IPH Astra Serif&apos;,serif;margin-bottom:0;">
<li><ol class="listlevel2Numbering123" style="margin-left:0;list-style-type:none;padding-left:0;clear:left;margin-top:0;font-family:&apos;IPH Astra Serif&apos;,serif;margin-bottom:0;"><li><p class="qwerty" style="margin-left:0;background-color:transparent;border:none;padding:0;text-indent:1.6535434rem;text-decoration:none;font-size:0.8333334rem;margin-top:0;font-family:&apos;IPH Astra Serif&apos;,serif;margin-bottom:0;margin-right:0;text-align:justify;"><span class="ItemNumber">1. </span><span lang="en-US" xml:lang="en-US">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum Page 1</span></p></li></ol></li> <ol class="listlevel2Numbering123" style="list-style-type:decimal;clear:left;margin-top:0;font-family:&apos;IPH Astra Serif&apos;,serif;margin-bottom:0;">
<li>
<p class="qwerty" style="margin-left:0;background-color:transparent;border:none;padding:0;text-indent:1.6535434rem;text-decoration:none;font-size:0.8333334rem;margin-top:0;font-family:&apos;IPH Astra Serif&apos;,serif;margin-bottom:0;margin-right:0;text-align:justify;"><span lang="en-US" xml:lang="en-US">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum Page 1</span></p>
</li>
</ol>
</ol> </ol>
</div> </div>
</div> </div>
<div class="pageBreak" style="height:3em;margin-top:1em;margin-bottom:1em;background-color:red;"> </div> <div class="pageBreak" style="height:3em;margin-top:1em;margin-bottom:1em;background-color:red;"> </div>
<div class="pageNum" page="2"> <div class="pageNum" page="2">
<div class="pageContainer" style="column-count: 1;"> <div class="pageContainer" style="column-count: 1;">
<ol class="listlevel1Numbering123" style="margin-left:0;list-style-type:none;padding-left:0;clear:left;margin-top:0;font-family:&apos;IPH Astra Serif&apos;,serif;margin-bottom:0;"> <ol class="listlevel1Numbering123" start="2" style="list-style-type:decimal;clear:left;margin-top:0;font-family:&apos;IPH Astra Serif&apos;,serif;margin-bottom:0;">
<li><ol class="listlevel2Numbering123" style="margin-left:0;list-style-type:none;padding-left:0;clear:left;margin-top:0;font-family:&apos;IPH Astra Serif&apos;,serif;margin-bottom:0;"><li><p class="qwerty" lang="en-US" style="margin-left:0;background-color:transparent;border:none;padding:0;text-indent:1.6535434rem;text-decoration:none;font-size:0.8333334rem;margin-top:0;font-family:&apos;IPH Astra Serif&apos;,serif;margin-bottom:0;margin-right:0;text-align:justify;" xml:lang="en-US"><span class="ItemNumber">1. </span>Page 2</p></li></ol></li> <ol class="listlevel2Numbering123" start="2" style="list-style-type:decimal;clear:left;margin-top:0;font-family:&apos;IPH Astra Serif&apos;,serif;margin-bottom:0;">
<li>
<p class="qwerty" lang="en-US" style="margin-left:0;background-color:transparent;border:none;padding:0;text-indent:1.6535434rem;text-decoration:none;font-size:0.8333334rem;margin-top:0;font-family:&apos;IPH Astra Serif&apos;,serif;margin-bottom:0;margin-right:0;text-align:justify;" xml:lang="en-US">Page 2</p>
</li>
</ol>
</ol> </ol>
</div> </div>
</div> </div>

View file

@ -2,9 +2,9 @@
<description xmlns="http://openoffice.org/extensions/update/2006" <description xmlns="http://openoffice.org/extensions/update/2006"
xmlns:xlink="http://www.w3.org/1999/xlink"> xmlns:xlink="http://www.w3.org/1999/xlink">
<identifier value="pro.litvinovg.writer2paginatedhtml"/> <identifier value="pro.litvinovg.writer2paginatedhtml"/>
<version value="0.9.29" /> <version value="0.9.20" />
<update-download> <update-download>
<src xlink:href="https://dev.litvinovg.pro/litvinovg/w2phtml/uploads/649b20bfbf3225a7c11ee1a01fdf6cf9/w2phtml.oxt" /> <src xlink:href="https://dev.litvinovg.pro/litvinovg/w2phtml/uploads/99f94da1146681d1c8a6cf7ecc13464c/w2phtml.oxt" />
</update-download> </update-download>
<release-notes> <release-notes>
<src xlink:href="https://dev.litvinovg.pro/litvinovg/w2phtml/-/raw/master/src/main/oxt/releasenotes.txt" lang="en" /> <src xlink:href="https://dev.litvinovg.pro/litvinovg/w2phtml/-/raw/master/src/main/oxt/releasenotes.txt" lang="en" />