Merge changes from 1.0 final + more config ui work
git-svn-id: svn://svn.code.sf.net/p/writer2latex/code/trunk@34 f0f2a975-2e09-46c8-9428-3b39399b9f3c
This commit is contained in:
parent
e8bba32302
commit
a0384669cc
46 changed files with 1671 additions and 90 deletions
|
@ -20,36 +20,29 @@
|
|||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.2 (2009-09-06)
|
||||
* Version 1.2 (2009-09-20)
|
||||
*
|
||||
*/
|
||||
|
||||
package org.openoffice.da.comp.writer2latex;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.URI;
|
||||
import java.util.Vector;
|
||||
import java.util.Set;
|
||||
|
||||
import com.sun.star.awt.XControl;
|
||||
import com.sun.star.awt.XControlContainer;
|
||||
import com.sun.star.awt.XControlModel;
|
||||
import com.sun.star.awt.XContainerWindowEventHandler;
|
||||
import com.sun.star.awt.XDialog;
|
||||
import com.sun.star.awt.XDialogProvider2;
|
||||
import com.sun.star.awt.XWindow;
|
||||
import com.sun.star.beans.XPropertySet;
|
||||
import com.sun.star.io.NotConnectedException;
|
||||
import com.sun.star.io.XInputStream;
|
||||
import com.sun.star.io.XOutputStream;
|
||||
import com.sun.star.lang.XComponent;
|
||||
import com.sun.star.lang.XMultiComponentFactory;
|
||||
import com.sun.star.lang.XServiceInfo;
|
||||
import com.sun.star.ucb.CommandAbortedException;
|
||||
import com.sun.star.ucb.XSimpleFileAccess2;
|
||||
import com.sun.star.ui.dialogs.ExecutableDialogResults;
|
||||
import com.sun.star.ui.dialogs.XExecutableDialog;
|
||||
import com.sun.star.ui.dialogs.XFilePicker;
|
||||
import com.sun.star.uno.AnyConverter;
|
||||
import com.sun.star.uno.UnoRuntime;
|
||||
import com.sun.star.uno.XComponentContext;
|
||||
|
@ -71,10 +64,11 @@ import org.openoffice.da.comp.w2lcommon.helper.DialogAccess;
|
|||
public final class ConfigurationDialog extends WeakBase
|
||||
implements XServiceInfo, XContainerWindowEventHandler {
|
||||
|
||||
//private XComponentContext xContext;
|
||||
private XComponentContext xContext;
|
||||
private XSimpleFileAccess2 sfa2;
|
||||
private String sConfigFileName = null;
|
||||
Config config;
|
||||
String sCurrentText = null;
|
||||
private String sTitle = null;
|
||||
private DialogAccess dlg = null;
|
||||
|
||||
|
@ -88,7 +82,7 @@ public final class ConfigurationDialog extends WeakBase
|
|||
|
||||
/** Create a new ConfigurationDialog */
|
||||
public ConfigurationDialog(XComponentContext xContext) {
|
||||
//this.xContext = xContext;
|
||||
this.xContext = xContext;
|
||||
|
||||
// Get the SimpleFileAccess service
|
||||
sfa2 = null;
|
||||
|
@ -128,10 +122,32 @@ public final class ConfigurationDialog extends WeakBase
|
|||
if (sMethod.equals("external_event") ){
|
||||
return handleExternalEvent(event);
|
||||
}
|
||||
// Documentclass page
|
||||
else if (sMethod.equals("NoPreambleChange")) {
|
||||
enableDocumentclassControls();
|
||||
return true;
|
||||
}
|
||||
// Headings page
|
||||
else if (sMethod.equals("MaxLevelChange")) {
|
||||
enableHeadingsControls();
|
||||
return true;
|
||||
}
|
||||
// Styles page
|
||||
// Formatting page
|
||||
else if (sMethod.equals("FormattingChange")) {
|
||||
enableFormattingControls();
|
||||
return true;
|
||||
}
|
||||
else if (sMethod.equals("UseColorChange")) {
|
||||
enableFormattingControls();
|
||||
return true;
|
||||
}
|
||||
else if (sMethod.equals("UseSoulChange")) {
|
||||
enableFormattingControls();
|
||||
return true;
|
||||
}
|
||||
// Fonts page
|
||||
// Pages page
|
||||
else if (sMethod.equals("ExportGeometryChange")) {
|
||||
enablePagesControls();
|
||||
return true;
|
||||
|
@ -140,6 +156,7 @@ public final class ConfigurationDialog extends WeakBase
|
|||
enablePagesControls();
|
||||
return true;
|
||||
}
|
||||
// Tables page
|
||||
else if (sMethod.equals("NoTablesChange")) {
|
||||
enableTablesControls();
|
||||
return true;
|
||||
|
@ -152,6 +169,28 @@ public final class ConfigurationDialog extends WeakBase
|
|||
enableTablesControls();
|
||||
return true;
|
||||
}
|
||||
// Figures page
|
||||
else if (sMethod.equals("NoImagesChange")) {
|
||||
enableFiguresControls();
|
||||
return true;
|
||||
}
|
||||
// Text and math page
|
||||
else if (sMethod.equals("NewSymbolClick")) {
|
||||
appendItem("MathSymbolName");
|
||||
return true;
|
||||
}
|
||||
else if (sMethod.equals("DeleteSymbolClick")) {
|
||||
deleteCurrentItem("MathSymbolName");
|
||||
return true;
|
||||
}
|
||||
else if (sMethod.equals("NewTextClick")) {
|
||||
appendItem("TextInput");
|
||||
return true;
|
||||
}
|
||||
else if (sMethod.equals("DeleteTextClick")) {
|
||||
deleteCurrentItem("TextInput");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (com.sun.star.uno.RuntimeException e) {
|
||||
throw e;
|
||||
|
@ -163,7 +202,15 @@ public final class ConfigurationDialog extends WeakBase
|
|||
}
|
||||
|
||||
public String[] getSupportedMethodNames() {
|
||||
String[] sNames = { "external_event", "NoPreambleChange", "ExportGeometryChange", "ExportHeaderAndFooterChange", "NoTablesChange", "UseSupertabularChange", "UseLongtableChange" };
|
||||
String[] sNames = { "external_event",
|
||||
"NoPreambleChange", // Documentclass
|
||||
"MaxLevelChange", // Headings
|
||||
"FormattingChange", "UseColorChange", "UseSoulChange", // Formatting
|
||||
"ExportGeometryChange", "ExportHeaderAndFooterChange", // Pages
|
||||
"NoTablesChange", "UseSupertabularChange", "UseLongtableChange", // Tables
|
||||
"NoImagesChange", // Images
|
||||
"NewSymbolClick", "DeleteSymbolClick", "NewTextClick", "DeleteTextClick" // Text and Math
|
||||
};
|
||||
return sNames;
|
||||
}
|
||||
|
||||
|
@ -204,6 +251,78 @@ public final class ConfigurationDialog extends WeakBase
|
|||
return false;
|
||||
}
|
||||
|
||||
// Display a dialog
|
||||
private XDialog getDialog(String sDialogName) {
|
||||
XMultiComponentFactory xMCF = xContext.getServiceManager();
|
||||
try {
|
||||
Object provider = xMCF.createInstanceWithContext(
|
||||
"com.sun.star.awt.DialogProvider2", xContext);
|
||||
XDialogProvider2 xDialogProvider = (XDialogProvider2)
|
||||
UnoRuntime.queryInterface(XDialogProvider2.class, provider);
|
||||
String sDialogUrl = "vnd.sun.star.script:"+sDialogName+"?location=application";
|
||||
return xDialogProvider.createDialogWithHandler(sDialogUrl, this);
|
||||
}
|
||||
catch (Exception e) {
|
||||
System.out.println(e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean deleteItem() {
|
||||
XDialog xDialog=getDialog("W2LDialogs2.DeleteDialog");
|
||||
if (xDialog!=null) {
|
||||
boolean bDelete = xDialog.execute()==ExecutableDialogResults.OK;
|
||||
xDialog.endExecute();
|
||||
return bDelete;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void deleteCurrentItem(String sListName) {
|
||||
String[] sItems = dlg.getListBoxStringItemList(sListName);
|
||||
short nSelected = dlg.getListBoxSelectedItem(sListName);
|
||||
if (nSelected>=0 && deleteItem()) {
|
||||
int nOldLen = sItems.length;
|
||||
String[] sNewItems = new String[nOldLen-1];
|
||||
if (nSelected>0) {
|
||||
System.arraycopy(sItems, 0, sNewItems, 0, nSelected);
|
||||
}
|
||||
if (nSelected<nOldLen-1) {
|
||||
System.arraycopy(sItems, nSelected+1, sNewItems, nSelected, nOldLen-1-nSelected);
|
||||
}
|
||||
dlg.setListBoxStringItemList(sListName, sNewItems);
|
||||
short nNewSelected = nSelected<nOldLen-1 ? nSelected : (short)(nSelected-1);
|
||||
dlg.setListBoxSelectedItem(sListName, nNewSelected);
|
||||
}
|
||||
}
|
||||
|
||||
private String newItem() {
|
||||
XDialog xDialog=getDialog("W2LDialogs2.NewDialog");
|
||||
if (xDialog!=null) {
|
||||
String sResult = null;
|
||||
if (xDialog.execute()==ExecutableDialogResults.OK) {
|
||||
DialogAccess dlg = new DialogAccess(xDialog);
|
||||
sResult = dlg.getTextFieldText("Name");
|
||||
}
|
||||
xDialog.endExecute();
|
||||
return sResult;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void appendItem(String sListName) {
|
||||
String[] sItems = dlg.getListBoxStringItemList(sListName);
|
||||
String sNewItem = newItem();
|
||||
if (sNewItem!=null) {
|
||||
int nOldLen = sItems.length;
|
||||
String[] sNewItems = new String[nOldLen+1];
|
||||
System.arraycopy(sItems, 0, sNewItems, 0, nOldLen);
|
||||
sNewItems[nOldLen]=sNewItem;
|
||||
dlg.setListBoxStringItemList(sListName, sNewItems);
|
||||
dlg.setListBoxSelectedItem(sListName, (short)nOldLen);
|
||||
}
|
||||
}
|
||||
|
||||
// Load the user configuration from file
|
||||
private void loadConfig() {
|
||||
if (sfa2!=null && sConfigFileName!=null) {
|
||||
|
@ -268,12 +387,30 @@ public final class ConfigurationDialog extends WeakBase
|
|||
if ("Documentclass".equals(sTitle)) {
|
||||
loadDocumentclass();
|
||||
}
|
||||
else if ("Headings".equals(sTitle)) {
|
||||
loadHeadings();
|
||||
}
|
||||
else if ("Styles".equals(sTitle)) {
|
||||
loadStyles();
|
||||
}
|
||||
else if ("Formatting".equals(sTitle)) {
|
||||
loadFormatting();
|
||||
}
|
||||
else if ("Fonts".equals(sTitle)) {
|
||||
loadFonts();
|
||||
}
|
||||
else if ("Pages".equals(sTitle)) {
|
||||
loadPages();
|
||||
}
|
||||
else if ("Tables".equals(sTitle)) {
|
||||
loadTables();
|
||||
}
|
||||
else if ("Figures".equals(sTitle)) {
|
||||
loadFigures();
|
||||
}
|
||||
else if ("TextAndMath".equals(sTitle)) {
|
||||
loadTextAndMath();
|
||||
}
|
||||
}
|
||||
|
||||
// Change the config based on the controls
|
||||
|
@ -281,12 +418,30 @@ public final class ConfigurationDialog extends WeakBase
|
|||
if ("Documentclass".equals(sTitle)) {
|
||||
saveDocumentclass();
|
||||
}
|
||||
else if ("Headings".equals(sTitle)) {
|
||||
saveHeadings();
|
||||
}
|
||||
else if ("Styles".equals(sTitle)) {
|
||||
saveStyles();
|
||||
}
|
||||
else if ("Formatting".equals(sTitle)) {
|
||||
saveFormatting();
|
||||
}
|
||||
else if ("Fonts".equals(sTitle)) {
|
||||
saveFonts();
|
||||
}
|
||||
else if ("Pages".equals(sTitle)) {
|
||||
savePages();
|
||||
}
|
||||
else if ("Tables".equals(sTitle)) {
|
||||
saveTables();
|
||||
}
|
||||
else if ("Figures".equals(sTitle)) {
|
||||
saveFigures();
|
||||
}
|
||||
else if ("TextAndMath".equals(sTitle)) {
|
||||
saveTextAndMath();
|
||||
}
|
||||
}
|
||||
|
||||
// The page "Documentclass"
|
||||
|
@ -296,7 +451,7 @@ public final class ConfigurationDialog extends WeakBase
|
|||
dlg.setCheckBoxStateAsBoolean("NoPreamble","true".equals(config.getOption("no_preamble")));
|
||||
dlg.setTextFieldText("Documentclass",config.getOption("documentclass"));
|
||||
dlg.setTextFieldText("GlobalOptions",config.getOption("global_options"));
|
||||
//dlg.setTextFieldText("CustomPreamble",config.getLongOption("custom-preamble"));
|
||||
//TODO: dlg.setTextFieldText("CustomPreamble",config.getLongOption("custom-preamble"));
|
||||
enableDocumentclassControls();
|
||||
}
|
||||
|
||||
|
@ -304,7 +459,7 @@ public final class ConfigurationDialog extends WeakBase
|
|||
config.setOption("no_preamble", Boolean.toString(dlg.getCheckBoxStateAsBoolean("NoPreamble")));
|
||||
config.setOption("documentclass", dlg.getTextFieldText("Documentclass"));
|
||||
config.setOption("global_options", dlg.getTextFieldText("GlobalOptions"));
|
||||
//config.setLongOption("custom-preamble", dlg.getTextFieldText("CustomPreamble"));
|
||||
//TODO: config.setLongOption("custom-preamble", dlg.getTextFieldText("CustomPreamble"));
|
||||
}
|
||||
|
||||
private void enableDocumentclassControls() {
|
||||
|
@ -317,22 +472,206 @@ public final class ConfigurationDialog extends WeakBase
|
|||
dlg.setControlEnabled("CustomPreamble",bPreamble);
|
||||
}
|
||||
|
||||
// The page "Headings"
|
||||
// This page handles the heading map as well as the option no_index
|
||||
|
||||
private void loadHeadings() {
|
||||
// TODO: Load heading map
|
||||
dlg.setCheckBoxStateAsBoolean("NoIndex","true".equals(config.getOption("no_index")));
|
||||
enableHeadingsControls();
|
||||
}
|
||||
|
||||
private void saveHeadings() {
|
||||
// TODO: Save heading map
|
||||
config.setOption("no_index", Boolean.toString(dlg.getCheckBoxStateAsBoolean("NoIndex")));
|
||||
}
|
||||
|
||||
private void enableHeadingsControls() {
|
||||
boolean bEnable = dlg.getListBoxSelectedItem("MaxLevel")>0;
|
||||
dlg.setControlEnabled("WriterLevelLabel", bEnable);
|
||||
dlg.setControlEnabled("WriterLevel", bEnable);
|
||||
dlg.setControlEnabled("LaTeXLevelLabel", bEnable);
|
||||
dlg.setControlEnabled("LaTeXLevel", bEnable);
|
||||
dlg.setControlEnabled("LaTeXNameLabel", bEnable);
|
||||
dlg.setControlEnabled("LaTeXName", bEnable);
|
||||
}
|
||||
|
||||
// The page "Styles"
|
||||
// This page handles the various style maps as well as the option other_styles
|
||||
|
||||
private void loadStyles() {
|
||||
// TODO
|
||||
enableStylesControls();
|
||||
}
|
||||
|
||||
private void saveStyles() {
|
||||
// TODO
|
||||
}
|
||||
|
||||
private void enableStylesControls() {
|
||||
// TODO
|
||||
}
|
||||
|
||||
// The page "Formatting"
|
||||
// This page handles the options formatting, use_color, use_colortbl, use_soul, use_ulem,
|
||||
// use_hyperref, use_titlesec, use_titletoc
|
||||
|
||||
private void loadFormatting() {
|
||||
String sFormatting = config.getOption("formatting");
|
||||
if ("ignore_all".equals(sFormatting)) {
|
||||
dlg.setListBoxSelectedItem("Formatting", (short)0);
|
||||
}
|
||||
else if ("ignore_most".equals(sFormatting)) {
|
||||
dlg.setListBoxSelectedItem("Formatting", (short)1);
|
||||
}
|
||||
else if ("convert_most".equals(sFormatting)) {
|
||||
dlg.setListBoxSelectedItem("Formatting", (short)3);
|
||||
}
|
||||
else if ("convert_all".equals(sFormatting)) {
|
||||
dlg.setListBoxSelectedItem("Formatting", (short)4);
|
||||
}
|
||||
else {
|
||||
dlg.setListBoxSelectedItem("Formatting", (short)2);
|
||||
}
|
||||
|
||||
dlg.setCheckBoxStateAsBoolean("UseHyperref","true".equals(config.getOption("use_hyperref")));
|
||||
dlg.setCheckBoxStateAsBoolean("UseColor","true".equals(config.getOption("use_color")));
|
||||
dlg.setCheckBoxStateAsBoolean("UseColortbl","true".equals(config.getOption("use_colortbl")));
|
||||
dlg.setCheckBoxStateAsBoolean("UseSoul","true".equals(config.getOption("use_soul")));
|
||||
dlg.setCheckBoxStateAsBoolean("UseUlem","true".equals(config.getOption("use_ulem")));
|
||||
dlg.setCheckBoxStateAsBoolean("UseTitlesec","true".equals(config.getOption("use_titlesec")));
|
||||
dlg.setCheckBoxStateAsBoolean("UseTitletoc","true".equals(config.getOption("use_titletoc")));
|
||||
|
||||
enableFormattingControls();
|
||||
}
|
||||
|
||||
private void saveFormatting() {
|
||||
switch (dlg.getListBoxSelectedItem("Formatting")) {
|
||||
case 0: config.setOption("formatting", "ignore_all"); break;
|
||||
case 1: config.setOption("formatting", "ignore_most"); break;
|
||||
case 2: config.setOption("formatting", "convert_basic"); break;
|
||||
case 3: config.setOption("formatting", "convert_most"); break;
|
||||
case 4: config.setOption("formatting", "convert_all");
|
||||
}
|
||||
|
||||
config.setOption("use_hyperref", Boolean.toString(dlg.getCheckBoxStateAsBoolean("UseHyperref")));
|
||||
config.setOption("use_color", Boolean.toString(dlg.getCheckBoxStateAsBoolean("UseColor")));
|
||||
config.setOption("use_colortbl", Boolean.toString(dlg.getCheckBoxStateAsBoolean("UseColortbl")));
|
||||
config.setOption("use_soul", Boolean.toString(dlg.getCheckBoxStateAsBoolean("UseSoul")));
|
||||
config.setOption("use_ulem", Boolean.toString(dlg.getCheckBoxStateAsBoolean("UseUlem")));
|
||||
config.setOption("use_titlesec", Boolean.toString(dlg.getCheckBoxStateAsBoolean("UseTitlesec")));
|
||||
config.setOption("use_titletoc", Boolean.toString(dlg.getCheckBoxStateAsBoolean("UseTitletoc")));
|
||||
}
|
||||
|
||||
private void enableFormattingControls() {
|
||||
short nFormatting = dlg.getListBoxSelectedItem("Formatting");
|
||||
boolean bUseColor = dlg.getCheckBoxStateAsBoolean("UseColor");
|
||||
//boolean bUseSoul = dlg.getCheckBoxStateAsBoolean("UseSoul");
|
||||
|
||||
dlg.setControlEnabled("UseColor", nFormatting>0);
|
||||
dlg.setControlEnabled("UseColortbl", nFormatting>0 && bUseColor);
|
||||
// Until implemented...
|
||||
dlg.setControlEnabled("UseSoul", false);
|
||||
dlg.setControlEnabled("UseUlem", nFormatting>0);
|
||||
dlg.setControlEnabled("UseTitlesec", false);
|
||||
dlg.setControlEnabled("UseTitletoc", false);
|
||||
// After which it should be...
|
||||
//dlg.setControlEnabled("UseSoul", nFormatting>0);
|
||||
//dlg.setControlEnabled("UseUlem", nFormatting>0 && !bUseSoul);
|
||||
//dlg.setControlEnabled("UseTitlesec", nFormatting>2);
|
||||
//dlg.setControlEnabled("UseTitletoc", nFormatting>2);
|
||||
}
|
||||
|
||||
// The page "Fonts"
|
||||
// This page handles the options use_fontspec, use_pifont, use_tipa, use_eurosym, use_wasysym,
|
||||
// use_ifsym, use_bbding
|
||||
|
||||
private void loadFonts() {
|
||||
System.out.println("Loading fonts, f.eks. use_pifont="+config.getOption("use_pifont"));
|
||||
dlg.setCheckBoxStateAsBoolean("UseFontspec","true".equals(config.getOption("use_fontspec")));
|
||||
dlg.setCheckBoxStateAsBoolean("UsePifont","true".equals(config.getOption("use_pifont")));
|
||||
dlg.setCheckBoxStateAsBoolean("UseTipa","true".equals(config.getOption("use_tipa")));
|
||||
dlg.setCheckBoxStateAsBoolean("UseEurosym","true".equals(config.getOption("use_eurosym")));
|
||||
dlg.setCheckBoxStateAsBoolean("UseWasysym","true".equals(config.getOption("use_wasysym")));
|
||||
dlg.setCheckBoxStateAsBoolean("UseIfsym","true".equals(config.getOption("use_ifsym")));
|
||||
dlg.setCheckBoxStateAsBoolean("UseBbding","true".equals(config.getOption("use_bbding")));
|
||||
|
||||
enableFontsControls();
|
||||
}
|
||||
|
||||
private void saveFonts() {
|
||||
config.setOption("use_fontspec", Boolean.toString(dlg.getCheckBoxStateAsBoolean("UseFontspec")));
|
||||
config.setOption("use_pifont", Boolean.toString(dlg.getCheckBoxStateAsBoolean("UsePifont")));
|
||||
config.setOption("use_tipa", Boolean.toString(dlg.getCheckBoxStateAsBoolean("UseTipa")));
|
||||
config.setOption("use_eurosym", Boolean.toString(dlg.getCheckBoxStateAsBoolean("UseEurosym")));
|
||||
config.setOption("use_wasysym", Boolean.toString(dlg.getCheckBoxStateAsBoolean("UseWasysym")));
|
||||
config.setOption("use_ifsym", Boolean.toString(dlg.getCheckBoxStateAsBoolean("UseIfsym")));
|
||||
config.setOption("use_bbding", Boolean.toString(dlg.getCheckBoxStateAsBoolean("UseBbding")));
|
||||
}
|
||||
|
||||
private void enableFontsControls() {
|
||||
// Until implemented...
|
||||
dlg.setControlEnabled("UseFontspec", false);
|
||||
// Nothing to do
|
||||
}
|
||||
|
||||
// The page "Pages"
|
||||
// This page handles the options page_formatting, use_geometry, use_fancyhdr, use_lastpage and use_endnotes
|
||||
|
||||
private void loadPages() {
|
||||
String sPageFormatting = config.getOption("page_formatting");
|
||||
if ("ignore_all".equals(sPageFormatting)) {
|
||||
dlg.setCheckBoxStateAsBoolean("ExportGeometry", false);
|
||||
dlg.setCheckBoxStateAsBoolean("ExportHeaderFooter", false);
|
||||
}
|
||||
else if ("convert_geometry".equals(sPageFormatting)) {
|
||||
dlg.setCheckBoxStateAsBoolean("ExportGeometry", true);
|
||||
dlg.setCheckBoxStateAsBoolean("ExportHeaderFooter", false);
|
||||
}
|
||||
else if ("convert_header_footer".equals(sPageFormatting)) {
|
||||
dlg.setCheckBoxStateAsBoolean("ExportGeometry", false);
|
||||
dlg.setCheckBoxStateAsBoolean("ExportHeaderFooter", true);
|
||||
}
|
||||
else if ("convert_all".equals(sPageFormatting)) {
|
||||
dlg.setCheckBoxStateAsBoolean("ExportGeometry", true);
|
||||
dlg.setCheckBoxStateAsBoolean("ExportHeaderFooter", true);
|
||||
}
|
||||
|
||||
dlg.setCheckBoxStateAsBoolean("UseGeometry", "true".equals(config.getOption("use_geometry")));
|
||||
dlg.setCheckBoxStateAsBoolean("UseFancyhdr", "true".equals(config.getOption("use_fancyhdr")));
|
||||
dlg.setCheckBoxStateAsBoolean("UseLastpage", "true".equals(config.getOption("use_lastpage")));
|
||||
dlg.setCheckBoxStateAsBoolean("UseEndnotes", "true".equals(config.getOption("use_endnotes")));
|
||||
|
||||
enablePagesControls();
|
||||
}
|
||||
|
||||
private void savePages() {
|
||||
boolean bGeometry = dlg.getCheckBoxStateAsBoolean("ExportGeometry");
|
||||
boolean bHeaderFooter = dlg.getCheckBoxStateAsBoolean("ExportHeaderFooter");
|
||||
if (bGeometry && bHeaderFooter) {
|
||||
config.setOption("page_formatting", "convert_all");
|
||||
}
|
||||
else if (bGeometry && !bHeaderFooter) {
|
||||
config.setOption("page_formatting", "convert_geometry");
|
||||
}
|
||||
else if (!bGeometry && bHeaderFooter) {
|
||||
config.setOption("page_formatting", "convert_header_footer");
|
||||
}
|
||||
else {
|
||||
config.setOption("page_formatting", "ignore_all");
|
||||
}
|
||||
|
||||
config.setOption("use_geometry", Boolean.toString(dlg.getCheckBoxStateAsBoolean("UseGeometry")));
|
||||
config.setOption("use_fancyhdr", Boolean.toString(dlg.getCheckBoxStateAsBoolean("UseFancyhdr")));
|
||||
config.setOption("use_lastpage", Boolean.toString(dlg.getCheckBoxStateAsBoolean("UseLastpage")));
|
||||
config.setOption("use_endnotes", Boolean.toString(dlg.getCheckBoxStateAsBoolean("UseEndnotes")));
|
||||
}
|
||||
|
||||
private void enablePagesControls() {
|
||||
boolean bExportGeometry = dlg.getCheckBoxStateAsBoolean("ExportGeometry");
|
||||
dlg.setControlEnabled("UseGeometry",bExportGeometry);
|
||||
|
||||
boolean bExport = dlg.getCheckBoxStateAsBoolean("ExportHeaderAndFooter");
|
||||
boolean bExport = dlg.getCheckBoxStateAsBoolean("ExportHeaderFooter");
|
||||
dlg.setControlEnabled("UseFancyhdr",bExport);
|
||||
}
|
||||
|
||||
|
@ -388,6 +727,64 @@ public final class ConfigurationDialog extends WeakBase
|
|||
dlg.setControlEnabled("TableSequenceName", !bNoTables);
|
||||
|
||||
}
|
||||
|
||||
// The page "Figures"
|
||||
// This page handles the options use_caption, align_frames, figure_sequence_name, image_content,
|
||||
// remove_graphics_extension and image_options
|
||||
// Limitation: Cannot handle the values "error" and "warning" for image_content
|
||||
|
||||
private void loadFigures() {
|
||||
dlg.setCheckBoxStateAsBoolean("UseCaption", "true".equals(config.getOption("use_caption")));
|
||||
dlg.setCheckBoxStateAsBoolean("AlignFrames", "true".equals(config.getOption("align_frames")));
|
||||
dlg.setTextFieldText("FigureSequenceName", config.getOption("figure_sequence_name"));
|
||||
dlg.setCheckBoxStateAsBoolean("NoImages", !"accept".equals(config.getOption("image_content")));
|
||||
dlg.setCheckBoxStateAsBoolean("RemoveGraphicsExtension", "true".equals(config.getOption("remove_graphics_extension")));
|
||||
dlg.setTextFieldText("ImageOptions", config.getOption("image_options"));
|
||||
enableFiguresControls();
|
||||
}
|
||||
|
||||
private void saveFigures() {
|
||||
config.setOption("use_caption", Boolean.toString(dlg.getCheckBoxStateAsBoolean("UseCaption")));
|
||||
config.setOption("align_frames", Boolean.toString(dlg.getCheckBoxStateAsBoolean("AlignFrames")));
|
||||
config.setOption("figure_sequence_name", dlg.getTextFieldText("FigureSequenceName"));
|
||||
config.setOption("image_content", dlg.getCheckBoxStateAsBoolean("NoImages") ? "ignore" : "accept");
|
||||
config.setOption("remove_graphics_extension", Boolean.toString(dlg.getCheckBoxStateAsBoolean("RemoveGraphicsExtension")));
|
||||
config.setOption("image_options", dlg.getTextFieldText("ImageOptions"));
|
||||
}
|
||||
|
||||
private void enableFiguresControls() {
|
||||
boolean bNoImages = dlg.getCheckBoxStateAsBoolean("NoImages");
|
||||
dlg.setControlEnabled("RemoveGraphicsExtension", !bNoImages);
|
||||
dlg.setControlEnabled("ImageOptionsLabel", !bNoImages);
|
||||
dlg.setControlEnabled("ImageOptions", !bNoImages);
|
||||
}
|
||||
|
||||
// The page "TextAndMath"
|
||||
// This page handles the options use_ooomath and tabstop as well as the
|
||||
// text replacements and math symbol definitions
|
||||
|
||||
private void loadTextAndMath() {
|
||||
Set<String> names = config.getComplexOptions("string-replace");
|
||||
String[] sNames = new String[names.size()];
|
||||
int i=0;
|
||||
for (String s : names) {
|
||||
sNames[i++] = s;
|
||||
}
|
||||
System.out.println("Found "+sNames.length+" string replacements");
|
||||
dlg.setListBoxStringItemList("TextInput", sNames);
|
||||
dlg.setListBoxSelectedItem("TextInput", (short)0);
|
||||
enableTextAndMathControls();
|
||||
}
|
||||
|
||||
private void saveTextAndMath() {
|
||||
|
||||
}
|
||||
|
||||
private void enableTextAndMathControls() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -41,9 +41,9 @@ class StreamGobbler extends Thread {
|
|||
try {
|
||||
InputStreamReader isr = new InputStreamReader(is);
|
||||
BufferedReader br = new BufferedReader(isr);
|
||||
String line=null;
|
||||
while ( (line = br.readLine()) != null) {
|
||||
//while ( br.readLine() != null) {
|
||||
//String line=null;
|
||||
//while ( (line = br.readLine()) != null) {
|
||||
while ( br.readLine() != null) {
|
||||
// Do nothing...
|
||||
//System.out.println(type + ">" + line);
|
||||
}
|
||||
|
|
|
@ -16,11 +16,11 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
* Copyright: 2002-2008 by Henrik Just
|
||||
* Copyright: 2002-2009 by Henrik Just
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.0 (2008-11-23)
|
||||
* Version 1.2 (2009-09-20)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -31,6 +31,8 @@ import java.io.InputStream;
|
|||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.lang.IllegalArgumentException;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/** This is an interface for configuration of a {@link Converter}.
|
||||
* A configuration always supports simple name/value options.
|
||||
|
@ -94,6 +96,28 @@ public interface Config {
|
|||
* not exist or the given name is null
|
||||
*/
|
||||
public String getOption(String sName);
|
||||
|
||||
/** Set a complex option
|
||||
*
|
||||
* @param sGroup the group to which this option belongs
|
||||
* @param sName the name of this option
|
||||
* @param attributes the attributes defining the values of this option
|
||||
*/
|
||||
public void setComplexOption(String sGroup, String sName, Map<String,String> attributes);
|
||||
|
||||
/** Get a complex option
|
||||
*
|
||||
* @param sGroup the group to which this option belongs
|
||||
* @param sName the name of this option
|
||||
* @return the attributes defining the values of this option
|
||||
*/
|
||||
public Map<String,String> getComplexOption(String sGroup, String sName);
|
||||
|
||||
/** Get the collection of complex options in a specific groups
|
||||
*
|
||||
* @param sGroup the name of the group of options
|
||||
* @return the names of the currently defined options in this group
|
||||
*/
|
||||
public Set<String> getComplexOptions(String sGroup);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.2 (2009-08-23)
|
||||
* Version 1.2 (2009-09-17)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -33,7 +33,7 @@ public class ConverterFactory {
|
|||
|
||||
// Version information
|
||||
private static final String VERSION = "1.1.1";
|
||||
private static final String DATE = "2008-09-07";
|
||||
private static final String DATE = "2008-09-17";
|
||||
|
||||
/** Return version information
|
||||
* @return the Writer2LaTeX version in the form
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.2 (2009-05-31)
|
||||
* Version 1.2 (2009-09-20)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -28,7 +28,10 @@ package writer2latex.latex;
|
|||
|
||||
import java.util.LinkedList;
|
||||
import java.util.Hashtable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Node;
|
||||
|
@ -40,6 +43,7 @@ import writer2latex.base.Option;
|
|||
import writer2latex.latex.util.HeadingMap;
|
||||
import writer2latex.latex.i18n.ClassicI18n;
|
||||
import writer2latex.latex.i18n.ReplacementTrie;
|
||||
import writer2latex.latex.i18n.ReplacementTrieNode;
|
||||
import writer2latex.latex.util.StyleMap;
|
||||
import writer2latex.util.Misc;
|
||||
|
||||
|
@ -69,6 +73,8 @@ public class LaTeXConfig extends writer2latex.base.ConfigBase {
|
|||
public static final int CONVERT_ALL = 4;
|
||||
// Page formatting
|
||||
public static final int CONVERT_HEADER_FOOTER = 5;
|
||||
public static final int CONVERT_GEOMETRY = 6;
|
||||
|
||||
// Handling of other formatting
|
||||
public static final int IGNORE = 0;
|
||||
public static final int ACCEPT = 1;
|
||||
|
@ -224,6 +230,7 @@ public class LaTeXConfig extends writer2latex.base.ConfigBase {
|
|||
super.setString(sValue);
|
||||
if ("convert_all".equals(sValue)) nValue = CONVERT_ALL;
|
||||
else if ("convert_header_footer".equals(sValue)) nValue = CONVERT_HEADER_FOOTER;
|
||||
else if ("convert_geometry".equals(sValue)) nValue = CONVERT_GEOMETRY;
|
||||
else if ("ignore_all".equals(sValue)) nValue = IGNORE_ALL;
|
||||
}
|
||||
};
|
||||
|
@ -295,6 +302,36 @@ public class LaTeXConfig extends writer2latex.base.ConfigBase {
|
|||
//stringReplace.put("\u00AB\u00A0","\u00AB ",I18n.readFontencs("any"));
|
||||
//stringReplace.put("\u00A0\u00BB"," \u00BB",I18n.readFontencs("any"));
|
||||
}
|
||||
|
||||
public void setComplexOption(String sGroup, String sName, Map<String,String> attributes) {
|
||||
if ("string-replace".equals(sGroup)) {
|
||||
String sLaTeXCode = attributes.get("latex-code");
|
||||
String sFontencs = attributes.get("fontencs");
|
||||
if (sLaTeXCode!=null) {
|
||||
int nFontencs = ClassicI18n.readFontencs(sFontencs!=null && sFontencs.length()>0 ? sFontencs : "any");
|
||||
stringReplace.put(sName,sLaTeXCode,nFontencs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String,String> getComplexOption(String sGroup, String sName) {
|
||||
if ("string-replace".equals(sGroup)) {
|
||||
ReplacementTrieNode node = stringReplace.get(sName);
|
||||
if (node!=null) {
|
||||
HashMap<String,String> attributes = new HashMap<String,String>();
|
||||
attributes.put("latex-code", node.getLaTeXCode());
|
||||
attributes.put("fontencs", "(todo)");
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Set<String> getComplexOptions(String sGroup) {
|
||||
if ("string-replace".equals(sGroup)) {
|
||||
return stringReplace.getInputStrings();
|
||||
}
|
||||
return new java.util.HashSet<String>();
|
||||
}
|
||||
|
||||
protected void readInner(Element elm) {
|
||||
if (elm.getTagName().equals("style-map")) {
|
||||
|
@ -400,24 +437,21 @@ public class LaTeXConfig extends writer2latex.base.ConfigBase {
|
|||
hlmNode.setAttribute("level",Integer.toString(headingMap.getLevel(i)));
|
||||
hmNode.appendChild(hlmNode);
|
||||
}
|
||||
|
||||
// TODO: Export string replacements
|
||||
//String[] sInputStrings = stringReplace.getInputStrings();
|
||||
/*
|
||||
int nSize = sInputStrings.size();
|
||||
for (int i=0; i<nSize; i++) {
|
||||
String sInput = sInputStrings[i];
|
||||
|
||||
Set<String> inputStrings = stringReplace.getInputStrings();
|
||||
for (String sInput : inputStrings) {
|
||||
System.out.println("Writing input "+sInput);
|
||||
ReplacementTrieNode node = stringReplace.get(sInput);
|
||||
Element srNode = dom.createElement("string-replace");
|
||||
srNode.setAttribute("input",sInput);
|
||||
srNode.setAttribute("latex-code",node.getLaTeXCode());
|
||||
srNode.setAttribute("fontenc",I18n.writeFontencs(node.getFontencs()));
|
||||
hmNode.appendChild(srNode);
|
||||
srNode.setAttribute("fontenc","(todo)");
|
||||
//srNode.setAttribute("fontenc",ClassicI18n.writeFontencs(node.getFontencs()));
|
||||
dom.getDocumentElement().appendChild(srNode);
|
||||
}
|
||||
*/
|
||||
|
||||
writeContent(dom,customPreamble,"custom-preamble");
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void writeStyleMap(Document dom, StyleMap sm, String sFamily) {
|
||||
|
|
|
@ -16,11 +16,11 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
* Copyright: 2002-2008 by Henrik Just
|
||||
* Copyright: 2002-2009 by Henrik Just
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.0 (2008-11-22)
|
||||
* Version 1.2 (2009-09-20)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -171,6 +171,9 @@ public final class MathmlConverter extends ConverterHelper {
|
|||
else if (XMLString.TEXT_TAB_STOP.equals(sName)) { // old
|
||||
// Tab stops are allowed
|
||||
}
|
||||
else if (XMLString.TEXT_SOFT_PAGE_BREAK.equals(sName)) { // since ODF 1.1
|
||||
// Soft page breaks are allowed
|
||||
}
|
||||
else {
|
||||
// Other elements -> not a display
|
||||
return false;
|
||||
|
|
|
@ -16,11 +16,11 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
* Copyright: 2002-2008 by Henrik Just
|
||||
* Copyright: 2002-2009 by Henrik Just
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.0 (2008-11-23)
|
||||
* Version 1.2 (2009-09-17)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -130,7 +130,7 @@ public class PageStyleConverter extends StyleConverter {
|
|||
* @param ba the <code>BeforeAfter</code> to add code to.
|
||||
*/
|
||||
private void applyMasterPage(String sName, BeforeAfter ba) {
|
||||
if (config.pageFormatting()==LaTeXConfig.IGNORE_ALL) return;
|
||||
if (config.pageFormatting()==LaTeXConfig.IGNORE_ALL || config.pageFormatting()==LaTeXConfig.CONVERT_GEOMETRY) return;
|
||||
MasterPage style = ofr.getMasterPage(sName);
|
||||
if (style==null) { return; }
|
||||
String sNextName = style.getProperty(XMLString.STYLE_NEXT_STYLE_NAME);
|
||||
|
@ -150,7 +150,7 @@ public class PageStyleConverter extends StyleConverter {
|
|||
* Process header or footer contents
|
||||
*/
|
||||
private void convertMasterPages(LaTeXDocumentPortion ldp) {
|
||||
if (config.pageFormatting()==LaTeXConfig.IGNORE_ALL) { return; }
|
||||
if (config.pageFormatting()==LaTeXConfig.IGNORE_ALL || config.pageFormatting()==LaTeXConfig.CONVERT_GEOMETRY) { return; }
|
||||
|
||||
Context context = new Context();
|
||||
context.resetFormattingFromStyle(ofr.getDefaultParStyle());
|
||||
|
@ -357,7 +357,7 @@ public class PageStyleConverter extends StyleConverter {
|
|||
|
||||
// TODO: Reenable several geometries per document??
|
||||
private void convertPageMasterGeometry(LaTeXDocumentPortion pack, LaTeXDocumentPortion ldp) {
|
||||
if (config.pageFormatting()!=LaTeXConfig.CONVERT_ALL) { return; }
|
||||
if (config.pageFormatting()!=LaTeXConfig.CONVERT_ALL && config.pageFormatting()!=LaTeXConfig.CONVERT_GEOMETRY) { return; }
|
||||
if (mainPageLayout==null) { return; }
|
||||
|
||||
// Set global document options
|
||||
|
|
|
@ -313,6 +313,10 @@ public class ClassicI18n extends I18n {
|
|||
pack.append("\\usepackage[")
|
||||
.append(babelopt.toString())
|
||||
.append("]{babel}").nl();
|
||||
// For Polish we must undefine \lll which is later defined by ams
|
||||
if (languages.contains("pl")) {
|
||||
pack.append("\\let\\lll\\undefined").nl();
|
||||
}
|
||||
}
|
||||
|
||||
// usepackage tipa
|
||||
|
|
|
@ -16,16 +16,19 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
* Copyright: 2002-2006 by Henrik Just
|
||||
* Copyright: 2002-2009 by Henrik Just
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 0.5 (2006-11-02)
|
||||
* Version 1.2 (2009-09-20)
|
||||
*
|
||||
*/
|
||||
|
||||
package writer2latex.latex.i18n;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/** This class contains a trie of string -> LaTeX code replacements
|
||||
*/
|
||||
public class ReplacementTrie extends ReplacementTrieNode {
|
||||
|
@ -48,8 +51,10 @@ public class ReplacementTrie extends ReplacementTrieNode {
|
|||
else { super.put(sInput,sLaTeXCode,nFontencs); }
|
||||
}
|
||||
|
||||
public String[] getInputStrings() {
|
||||
return null; //TODO
|
||||
public Set<String> getInputStrings() {
|
||||
HashSet<String> strings = new HashSet<String>();
|
||||
collectStrings(strings,"");
|
||||
return strings;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -16,16 +16,18 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
* Copyright: 2002-2006 by Henrik Just
|
||||
* Copyright: 2002-2009 by Henrik Just
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 0.5 (2006-11-02)
|
||||
* Version 1.2 (2009-09-20)
|
||||
*
|
||||
*/
|
||||
|
||||
package writer2latex.latex.i18n;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/** This class contains a node in a trie of string -> LaTeX code replacements
|
||||
*/
|
||||
public class ReplacementTrieNode {
|
||||
|
@ -114,6 +116,18 @@ public class ReplacementTrieNode {
|
|||
child.setFontencs(nFontencs);
|
||||
}
|
||||
}
|
||||
|
||||
protected void collectStrings(Set<String> strings, String sPrefix) {
|
||||
ReplacementTrieNode child = this.getFirstChild();
|
||||
while (child!=null) {
|
||||
if (child.getLaTeXCode()!=null) {
|
||||
strings.add(sPrefix+child.getLetter());
|
||||
System.out.println("Found "+sPrefix+child.getLetter());
|
||||
}
|
||||
child.collectStrings(strings, sPrefix+child.getLetter());
|
||||
child = child.getNextSibling();
|
||||
}
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
String s = Character.toString(cLetter);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<!-- This is a datafile used by Writer2LaTeX
|
||||
Version 1.0 (2008-12-03)
|
||||
Version 1.0 (2009-09-07)
|
||||
|
||||
The definitions for greek characters are contributed by interzone, info@interzone.gr
|
||||
and extended by Johannis Likos. Additional bugfixes by Alexej Kryukov
|
||||
|
@ -1273,8 +1273,8 @@ PART I: Common symbols, ascii only
|
|||
<symbol char="227D" math="{\succcurlyeq}"/>
|
||||
<symbol char="227E" math="{\precsim}"/>
|
||||
<symbol char="227F" math="{\succsim}"/>
|
||||
<symbol char="2280" math="{\nsucc}"/>
|
||||
<symbol char="2281" math="{\nprec}"/>
|
||||
<symbol char="2280" math="{\nprec}"/>
|
||||
<symbol char="2281" math="{\nsucc}"/>
|
||||
<symbol char="2282" math="{\subset}"/>
|
||||
<symbol char="2283" math="{\supset}"/>
|
||||
<symbol char="2284" math="{\not\subset}"/>
|
||||
|
|
|
@ -16,13 +16,13 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
* Copyright: 2002-2008 by Henrik Just
|
||||
* Copyright: 2002-2009 by Henrik Just
|
||||
*
|
||||
* Version 1.0 (2009-09-14)
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*/
|
||||
|
||||
// Version 1.0 (2008-11-22)
|
||||
|
||||
package writer2latex.office;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
@ -52,6 +52,9 @@ public class TableReader {
|
|||
private String sTableWidth;
|
||||
private String sRelTableWidth;
|
||||
private Vector<TableRange> printRanges;
|
||||
|
||||
private int nRowCount;
|
||||
private int nEmptyRowCount;
|
||||
|
||||
/**
|
||||
* <p> The constructor reads a table from a table:table or table:sub-table
|
||||
|
@ -63,6 +66,10 @@ public class TableReader {
|
|||
//this.ofr = ofr;
|
||||
this.tableNode = tableNode;
|
||||
if (!tableNode.hasChildNodes()) { return; } // empty table!
|
||||
|
||||
// Count the actual number of rows (trailing repeated rows are ignored)
|
||||
countTableRows(tableNode);
|
||||
|
||||
NodeList nl = tableNode.getChildNodes();
|
||||
int nLen = nl.getLength();
|
||||
for (int i = 0; i < nLen; i++) {
|
||||
|
@ -224,7 +231,7 @@ public class TableReader {
|
|||
private void readTableRow(Node node, boolean bHeader, boolean bDisplay) {
|
||||
int nRepeat = Misc.getPosInteger(Misc.getAttribute(node,
|
||||
XMLString.TABLE_NUMBER_ROWS_REPEATED),1);
|
||||
while (nRepeat-->0) {
|
||||
while (nRepeat-->0 && rows.size()<nRowCount) {
|
||||
rows.add(new TableLine(node,bHeader,bDisplay));
|
||||
|
||||
// Read the cells in the row
|
||||
|
@ -303,6 +310,98 @@ public class TableReader {
|
|||
private void readTableHeaderRows(Node node, boolean bHeader, boolean bDisplay) {
|
||||
readTableRows(node,true,bDisplay);
|
||||
}
|
||||
|
||||
private void countTableRows(Element table) {
|
||||
nRowCount = 0;
|
||||
nEmptyRowCount = 0;
|
||||
Node child = table.getFirstChild();
|
||||
while (child!=null) {
|
||||
if (child.getNodeType() == Node.ELEMENT_NODE) {
|
||||
String sName = child.getNodeName();
|
||||
if (sName.equals(XMLString.TABLE_TABLE_ROW)) {
|
||||
countTableRow(child);
|
||||
}
|
||||
else if (sName.equals(XMLString.TABLE_TABLE_ROWS)) {
|
||||
countTableRows(child);
|
||||
}
|
||||
else if (sName.equals(XMLString.TABLE_TABLE_ROW_GROUP)) {
|
||||
countTableRowGroup(child);
|
||||
}
|
||||
else if (sName.equals(XMLString.TABLE_TABLE_HEADER_ROWS)) {
|
||||
countTableHeaderRows(child);
|
||||
}
|
||||
}
|
||||
child = child.getNextSibling();
|
||||
}
|
||||
// We will accept only one trailing empty row
|
||||
if (nEmptyRowCount>1) { nRowCount-=nEmptyRowCount-1; }
|
||||
}
|
||||
|
||||
private void countTableRow(Node node) {
|
||||
int nRepeat = Misc.getPosInteger(Misc.getAttribute(node,
|
||||
XMLString.TABLE_NUMBER_ROWS_REPEATED),1);
|
||||
nRowCount += nRepeat;
|
||||
if (isEmptyRow(node)) {
|
||||
nEmptyRowCount+=nRepeat;
|
||||
}
|
||||
else {
|
||||
nEmptyRowCount = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isEmptyRow(Node node) {
|
||||
Node child = node.getFirstChild();
|
||||
while (child!=null) {
|
||||
if (child.getNodeType() == Node.ELEMENT_NODE) {
|
||||
Element cell = (Element) child;
|
||||
String sName = cell.getTagName();
|
||||
if (sName.equals(XMLString.TABLE_TABLE_CELL)) {
|
||||
if (cell.hasChildNodes()) { return false; }
|
||||
}
|
||||
}
|
||||
child = child.getNextSibling();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void countTableRows(Node node) {
|
||||
Node child = node.getFirstChild();
|
||||
while (child!=null) {
|
||||
if (child.getNodeType() == Node.ELEMENT_NODE) {
|
||||
String sName = child.getNodeName();
|
||||
if (sName.equals(XMLString.TABLE_TABLE_ROW)) {
|
||||
countTableRow(child);
|
||||
}
|
||||
else if (sName.equals(XMLString.TABLE_TABLE_ROW_GROUP)) {
|
||||
countTableRowGroup(child);
|
||||
}
|
||||
}
|
||||
child = child.getNextSibling();
|
||||
}
|
||||
}
|
||||
|
||||
private void countTableRowGroup(Node node) {
|
||||
Node child = node.getFirstChild();
|
||||
while (child!=null) {
|
||||
if (child.getNodeType() == Node.ELEMENT_NODE) {
|
||||
String sName = child.getNodeName();
|
||||
if (sName.equals(XMLString.TABLE_TABLE_HEADER_ROWS)) {
|
||||
countTableHeaderRows(child);
|
||||
}
|
||||
else if (sName.equals(XMLString.TABLE_TABLE_ROW)) {
|
||||
countTableRow(child);
|
||||
}
|
||||
else if (sName.equals(XMLString.TABLE_TABLE_ROW_GROUP)) {
|
||||
countTableRowGroup(child);
|
||||
}
|
||||
}
|
||||
child = child.getNextSibling();
|
||||
}
|
||||
}
|
||||
|
||||
private void countTableHeaderRows(Node node) {
|
||||
countTableRows(node);
|
||||
}
|
||||
|
||||
public String getTableName() {
|
||||
return tableNode.getAttribute(XMLString.TABLE_NAME);
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.2 (2009-09-07)
|
||||
* Version 1.2 (2009-09-20)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -321,6 +321,8 @@ public class XMLString {
|
|||
public static final String TEXT_FOOTNOTE_REF="text:footnote-ref";
|
||||
public static final String TEXT_ENDNOTE_REF="text:endnote-ref";
|
||||
public static final String TEXT_NOTE_REF="text:note-ref"; // oasis
|
||||
public static final String TEXT_SOFT_PAGE_BREAK="text:soft-page-break"; // ODF 1.1
|
||||
|
||||
// text namespace - attributes
|
||||
public static final String TEXT_USE_OUTLINE_LEVEL="text:use-outline-level";
|
||||
public static final String TEXT_USE_INDEX_SOURCE_STYLES="text:use-index-source-styles";
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.2 (2009-05-29)
|
||||
* Version 1.2 (2009-09-15)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -109,6 +109,48 @@ public class L10n {
|
|||
case DOCUMENT: return "Documento";
|
||||
}
|
||||
}
|
||||
if (sLocale.startsWith("pt")) { // (brazilian) portuguese
|
||||
switch (nString) {
|
||||
case UP: return "Acima";
|
||||
case FIRST : return "Primeiro";
|
||||
case PREVIOUS : return "Anterior";
|
||||
case NEXT : return "Pr\u00f3ximo";
|
||||
case LAST : return "\u00daltimo";
|
||||
case CONTENTS : return "Conte\u00fado";
|
||||
case INDEX : return "\u00cdndice";
|
||||
case HOME : return "Home";
|
||||
case DIRECTORY: return "Diret\u00f3rio";
|
||||
case DOCUMENT: return "Documento";
|
||||
}
|
||||
}
|
||||
if (sLocale.startsWith("cs")) { // czech
|
||||
switch (nString) {
|
||||
case UP: return "Nahoru";
|
||||
case FIRST : return "Prvn\u00ed";
|
||||
case PREVIOUS : return "P\u0159edchoz\u00ed";
|
||||
case NEXT : return "Dal\u0161\u00ed";
|
||||
case LAST : return "Posledn\u00ed";
|
||||
case CONTENTS : return "Obsah";
|
||||
case INDEX : return "Rejst\u0159\u00edk";
|
||||
case HOME : return "Dom\u016f";
|
||||
case DIRECTORY: return "Adres\u00e1\u0159 (slo\u017eka)";
|
||||
case DOCUMENT: return "Dokument";
|
||||
}
|
||||
}
|
||||
if (sLocale.startsWith("nl")) { // dutch
|
||||
switch (nString) {
|
||||
case UP: return "Omhoog";
|
||||
case FIRST : return "Eerste";
|
||||
case PREVIOUS : return "Vorige";
|
||||
case NEXT : return "Volgende";
|
||||
case LAST : return "Laatste";
|
||||
case CONTENTS : return "Inhoud";
|
||||
case INDEX : return "Index";
|
||||
case HOME : return "Hoofdpagina";
|
||||
case DIRECTORY: return "Directory";
|
||||
case DOCUMENT: return "Document";
|
||||
}
|
||||
}
|
||||
if (sLocale.startsWith("da")) { // danish
|
||||
switch (nString) {
|
||||
case UP: return "Op";
|
||||
|
|
|
@ -20,13 +20,15 @@
|
|||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.2 (2009-09-05)
|
||||
* Version 1.2 (2009-09-20)
|
||||
*
|
||||
*/
|
||||
|
||||
package writer2latex.xhtml;
|
||||
|
||||
import java.util.Enumeration;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
|
@ -152,8 +154,23 @@ public class XhtmlConfig extends writer2latex.base.ConfigBase {
|
|||
options[DIRECTORY_ICON] = new Option("directory_icon","");
|
||||
options[DOCUMENT_ICON] = new Option("document_icon","");
|
||||
}
|
||||
|
||||
// Dummy implementation of complex options
|
||||
public void setComplexOption(String sGroup, String sName, Map<String,String> attributes) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
public Map<String,String> getComplexOption(String sGroup, String sName) {
|
||||
// no options are defined, return null in all cases
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void readInner(Element elm) {
|
||||
public Set<String> getComplexOptions(String sGroup) {
|
||||
// Always an empty set
|
||||
return new java.util.HashSet<String>();
|
||||
}
|
||||
|
||||
protected void readInner(Element elm) {
|
||||
if (elm.getTagName().equals("xhtml-style-map")) {
|
||||
String sName = elm.getAttribute("name");
|
||||
String sFamily = elm.getAttribute("family");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue