Config ui + Writer4LaTeX
git-svn-id: svn://svn.code.sf.net/p/writer2latex/code/trunk@41 f0f2a975-2e09-46c8-9428-3b39399b9f3c
This commit is contained in:
parent
97144ad818
commit
04ed9dae7a
23 changed files with 886 additions and 239 deletions
|
@ -2,7 +2,7 @@
|
|||
############################################################################
|
||||
# This is the Ant build file for writer2latex
|
||||
# Original: Sep 2004 (mgn)
|
||||
# version 1.2 (2009-03-30)
|
||||
# version 1.2 (2009-11-23)
|
||||
############################################################################
|
||||
-->
|
||||
<project name="w2l" default="help" basedir=".">
|
||||
|
@ -46,6 +46,7 @@
|
|||
<property name="target" location="target"/>
|
||||
<property name="target.lib" location="target/lib"/>
|
||||
<property name="source.idl" location="source/idl"/>
|
||||
<property name="source.dll" location="source/dll"/>
|
||||
<!-- classpath for the application; needs java-uno classes -->
|
||||
<path id="main.class.path">
|
||||
<!-- java uno classes -->
|
||||
|
@ -196,8 +197,14 @@
|
|||
<patternset>
|
||||
<include name="org/openoffice/da/comp/w2lcommon/helper/**/*"/>
|
||||
<include name="org/openoffice/da/comp/writer4latex/**/*"/>
|
||||
<include name="com/sun/star/lib/loader/**/*"/>
|
||||
</patternset>
|
||||
</fileset>
|
||||
<fileset dir="${source.dll}">
|
||||
<patternset>
|
||||
<include name="com/sun/star/lib/loader/win/unowinreg.dll"/>
|
||||
</patternset>
|
||||
</fileset>
|
||||
<manifest>
|
||||
<attribute name="Built-By" value="${user.name}"/>
|
||||
<attribute name="Class-Path" value="jaxp.jar parser.jar"/>
|
||||
|
|
BIN
source/dll/com/sun/star/lib/loader/win/unowinreg.dll
Normal file
BIN
source/dll/com/sun/star/lib/loader/win/unowinreg.dll
Normal file
Binary file not shown.
203
source/java/com/sun/star/lib/loader/WinRegKey.java
Normal file
203
source/java/com/sun/star/lib/loader/WinRegKey.java
Normal file
|
@ -0,0 +1,203 @@
|
|||
/*************************************************************************
|
||||
*
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* Copyright 2008 by Sun Microsystems, Inc.
|
||||
*
|
||||
* OpenOffice.org - a multi-platform office productivity suite
|
||||
*
|
||||
* $RCSfile: WinRegKey.java,v $
|
||||
* $Revision: 1.4 $
|
||||
*
|
||||
* This file is part of OpenOffice.org.
|
||||
*
|
||||
* OpenOffice.org is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License version 3
|
||||
* only, as published by the Free Software Foundation.
|
||||
*
|
||||
* OpenOffice.org is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License version 3 for more details
|
||||
* (a copy is included in the LICENSE file that accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* version 3 along with OpenOffice.org. If not, see
|
||||
* <http://www.openoffice.org/license.html>
|
||||
* for a copy of the LGPLv3 License.
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
package com.sun.star.lib.loader;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStream;
|
||||
|
||||
|
||||
/**
|
||||
* This class provides functionality for reading string values from the
|
||||
* Windows Registry. It requires the native library unowinreg.dll.
|
||||
*/
|
||||
final class WinRegKey {
|
||||
|
||||
private String m_rootKeyName;
|
||||
private String m_subKeyName;
|
||||
|
||||
// native methods to access the windows registry
|
||||
private static native boolean winreg_RegOpenClassesRoot( long[] hkresult );
|
||||
private static native boolean winreg_RegOpenCurrentConfig(
|
||||
long[] hkresult );
|
||||
private static native boolean winreg_RegOpenCurrentUser( long[] hkresult );
|
||||
private static native boolean winreg_RegOpenLocalMachine( long[] hkresult );
|
||||
private static native boolean winreg_RegOpenUsers( long[] hkresult );
|
||||
private static native boolean winreg_RegOpenKeyEx( long parent, String name,
|
||||
long[] hkresult );
|
||||
private static native boolean winreg_RegCloseKey( long hkey );
|
||||
private static native boolean winreg_RegQueryValueEx(
|
||||
long hkey, String value, long[] type,
|
||||
byte[] data, long[] size );
|
||||
private static native boolean winreg_RegQueryInfoKey(
|
||||
long hkey, long[] subkeys, long[] maxSubkeyLen,
|
||||
long[] values, long[] maxValueNameLen,
|
||||
long[] maxValueLen, long[] secDescriptor );
|
||||
|
||||
// load the native library unowinreg.dll
|
||||
static {
|
||||
try {
|
||||
ClassLoader cl = WinRegKey.class.getClassLoader();
|
||||
InputStream is = cl.getResourceAsStream( "win/unowinreg.dll" );
|
||||
if ( is != null ) {
|
||||
// generate a temporary name for lib file and write to temp
|
||||
// location
|
||||
BufferedInputStream istream = new BufferedInputStream( is );
|
||||
File libfile = File.createTempFile( "unowinreg", ".dll" );
|
||||
libfile.deleteOnExit(); // ensure deletion
|
||||
BufferedOutputStream ostream = new BufferedOutputStream(
|
||||
new FileOutputStream( libfile ) );
|
||||
int bsize = 2048; int n = 0;
|
||||
byte[] buffer = new byte[bsize];
|
||||
while ( ( n = istream.read( buffer, 0, bsize ) ) != -1 ) {
|
||||
ostream.write( buffer, 0, n );
|
||||
}
|
||||
istream.close();
|
||||
ostream.close();
|
||||
// load library
|
||||
System.load( libfile.getPath() );
|
||||
} else {
|
||||
// If the library cannot be found as a class loader resource,
|
||||
// try the global System.loadLibrary(). The JVM will look for
|
||||
// it in the java.library.path.
|
||||
System.loadLibrary( "unowinreg" );
|
||||
}
|
||||
} catch ( java.lang.Exception e ) {
|
||||
System.err.println( "com.sun.star.lib.loader.WinRegKey: " +
|
||||
"loading of native library failed!" + e );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a <code>WinRegKey</code>.
|
||||
*/
|
||||
public WinRegKey( String rootKeyName, String subKeyName ) {
|
||||
m_rootKeyName = rootKeyName;
|
||||
m_subKeyName = subKeyName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a string value for the specified value name.
|
||||
*/
|
||||
public String getStringValue( String valueName ) throws WinRegKeyException {
|
||||
byte[] data = getValue( valueName );
|
||||
// remove terminating null character
|
||||
return new String( data, 0, data.length - 1 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a value for the specified value name.
|
||||
*/
|
||||
private byte[] getValue( String valueName ) throws WinRegKeyException {
|
||||
|
||||
byte[] result = null;
|
||||
long[] hkey = {0};
|
||||
|
||||
// open the specified registry key
|
||||
boolean bRet = false;
|
||||
long[] hroot = {0};
|
||||
if ( m_rootKeyName.equals( "HKEY_CLASSES_ROOT" ) ) {
|
||||
bRet = winreg_RegOpenClassesRoot( hroot );
|
||||
} else if ( m_rootKeyName.equals( "HKEY_CURRENT_CONFIG" ) ) {
|
||||
bRet = winreg_RegOpenCurrentConfig( hroot );
|
||||
} else if ( m_rootKeyName.equals( "HKEY_CURRENT_USER" ) ) {
|
||||
bRet = winreg_RegOpenCurrentUser( hroot );
|
||||
} else if ( m_rootKeyName.equals( "HKEY_LOCAL_MACHINE" ) ) {
|
||||
bRet = winreg_RegOpenLocalMachine( hroot );
|
||||
} else if ( m_rootKeyName.equals( "HKEY_USERS" ) ) {
|
||||
bRet = winreg_RegOpenUsers( hroot );
|
||||
} else {
|
||||
throw new WinRegKeyException( "unknown root registry key!");
|
||||
}
|
||||
if ( !bRet ) {
|
||||
throw new WinRegKeyException( "opening root registry key " +
|
||||
"failed!" );
|
||||
}
|
||||
if ( !winreg_RegOpenKeyEx( hroot[0], m_subKeyName, hkey ) ) {
|
||||
if ( !winreg_RegCloseKey( hroot[0] ) ) {
|
||||
throw new WinRegKeyException( "opening registry key and " +
|
||||
"releasing root registry key handle failed!" );
|
||||
}
|
||||
throw new WinRegKeyException( "opening registry key failed!" );
|
||||
}
|
||||
|
||||
// get the size of the longest data component among the key's values
|
||||
long[] subkeys = {0};
|
||||
long[] maxSubkeyLen = {0};
|
||||
long[] values = {0};
|
||||
long[] maxValueNameLen = {0};
|
||||
long[] maxValueLen = {0};
|
||||
long[] secDescriptor = {0};
|
||||
if ( !winreg_RegQueryInfoKey( hkey[0], subkeys, maxSubkeyLen,
|
||||
values, maxValueNameLen, maxValueLen, secDescriptor ) ) {
|
||||
if ( !winreg_RegCloseKey( hkey[0] ) ||
|
||||
!winreg_RegCloseKey( hroot[0] ) ) {
|
||||
throw new WinRegKeyException( "retrieving information about " +
|
||||
"the registry key and releasing registry key handles " +
|
||||
"failed!" );
|
||||
}
|
||||
throw new WinRegKeyException( "retrieving information about " +
|
||||
"the registry key failed!" );
|
||||
}
|
||||
|
||||
// get the data for the specified value name
|
||||
byte[] buffer = new byte[ (int) maxValueLen[0] ];
|
||||
long[] size = new long[1];
|
||||
size[0] = buffer.length;
|
||||
long[] type = new long[1];
|
||||
type[0] = 0;
|
||||
if ( !winreg_RegQueryValueEx( hkey[0], valueName, type, buffer,
|
||||
size ) ) {
|
||||
if ( !winreg_RegCloseKey( hkey[0] ) ||
|
||||
!winreg_RegCloseKey( hroot[0] ) ) {
|
||||
throw new WinRegKeyException( "retrieving data for the " +
|
||||
"specified value name and releasing registry key handles " +
|
||||
"failed!" );
|
||||
}
|
||||
throw new WinRegKeyException( "retrieving data for the " +
|
||||
"specified value name failed!" );
|
||||
}
|
||||
|
||||
// release registry key handles
|
||||
if ( !winreg_RegCloseKey( hkey[0] ) ||
|
||||
!winreg_RegCloseKey( hroot[0] ) ) {
|
||||
throw new WinRegKeyException( "releasing registry key handles " +
|
||||
"failed!" );
|
||||
}
|
||||
|
||||
result = new byte[ (int) size[0] ];
|
||||
System.arraycopy( buffer, 0, result, 0, (int)size[0] );
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
54
source/java/com/sun/star/lib/loader/WinRegKeyException.java
Normal file
54
source/java/com/sun/star/lib/loader/WinRegKeyException.java
Normal file
|
@ -0,0 +1,54 @@
|
|||
/*************************************************************************
|
||||
*
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* Copyright 2008 by Sun Microsystems, Inc.
|
||||
*
|
||||
* OpenOffice.org - a multi-platform office productivity suite
|
||||
*
|
||||
* $RCSfile: WinRegKeyException.java,v $
|
||||
* $Revision: 1.4 $
|
||||
*
|
||||
* This file is part of OpenOffice.org.
|
||||
*
|
||||
* OpenOffice.org is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License version 3
|
||||
* only, as published by the Free Software Foundation.
|
||||
*
|
||||
* OpenOffice.org is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License version 3 for more details
|
||||
* (a copy is included in the LICENSE file that accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* version 3 along with OpenOffice.org. If not, see
|
||||
* <http://www.openoffice.org/license.html>
|
||||
* for a copy of the LGPLv3 License.
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
package com.sun.star.lib.loader;
|
||||
|
||||
/**
|
||||
* WinRegKeyException is a checked exception.
|
||||
*/
|
||||
final class WinRegKeyException extends java.lang.Exception {
|
||||
|
||||
/**
|
||||
* Constructs a <code>WinRegKeyException</code>.
|
||||
*/
|
||||
public WinRegKeyException() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a <code>WinRegKeyException</code> with the specified
|
||||
* detail message.
|
||||
*
|
||||
* @param message the detail message
|
||||
*/
|
||||
public WinRegKeyException( String message ) {
|
||||
super( message );
|
||||
}
|
||||
}
|
|
@ -29,7 +29,6 @@ package org.openoffice.da.comp.w2lcommon.helper;
|
|||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.sun.star.beans.UnknownPropertyException;
|
||||
import com.sun.star.beans.XPropertySet;
|
||||
|
|
|
@ -73,7 +73,7 @@ public class Mouth {
|
|||
}
|
||||
|
||||
private class Eyes {
|
||||
private BufferedReader br; // The inpuy
|
||||
private BufferedReader br; // The input
|
||||
private String sLine; // The current line
|
||||
private int nLen; // The length of the current line
|
||||
private int nIndex; // The current index in the current line
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.2 (2009-11-08)
|
||||
* Version 1.2 (2009-11-19)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -88,13 +88,13 @@ public final class ConfigurationDialog extends WeakBase
|
|||
short nCurrentFamily = -1;
|
||||
String sCurrentStyleName = null;
|
||||
short nCurrentAttribute = -1;
|
||||
short nCurrentMaxLevel = -1;
|
||||
short nCurrentWriterLevel = 0;
|
||||
String sCurrentMathSymbol = null;
|
||||
String sCurrentText = null;
|
||||
private String sTitle = null;
|
||||
private DialogAccess dlg = null;
|
||||
private StyleNameProvider styleNameProvider = null;
|
||||
private CustomSymbolNameProvider customSymbolNameProvider = null;
|
||||
|
||||
/** The component will be registered under this name.
|
||||
*/
|
||||
|
@ -143,6 +143,7 @@ public final class ConfigurationDialog extends WeakBase
|
|||
stringReplace = new ComplexOption();
|
||||
|
||||
styleNameProvider = new StyleNameProvider(xContext);
|
||||
customSymbolNameProvider = new CustomSymbolNameProvider(xContext);
|
||||
}
|
||||
|
||||
// Implement XContainerWindowEventHandler
|
||||
|
@ -163,12 +164,10 @@ public final class ConfigurationDialog extends WeakBase
|
|||
}
|
||||
// Headings page
|
||||
else if (sMethod.equals("MaxLevelChange")) {
|
||||
saveHeadings();
|
||||
updateHeadingsControls();
|
||||
return true;
|
||||
}
|
||||
else if (sMethod.equals("WriterLevelChange")) {
|
||||
saveHeadings();
|
||||
updateHeadingsControls();
|
||||
return true;
|
||||
}
|
||||
|
@ -178,39 +177,31 @@ public final class ConfigurationDialog extends WeakBase
|
|||
}
|
||||
// Styles page
|
||||
else if (sMethod.equals("StyleFamilyChange")) {
|
||||
saveStyles();
|
||||
updateStylesControls();
|
||||
return true;
|
||||
}
|
||||
else if (sMethod.equals("StyleNameChange")) {
|
||||
saveStyles();
|
||||
updateStylesControls();
|
||||
return true;
|
||||
}
|
||||
else if (sMethod.equals("NewStyleClick")) {
|
||||
if (nCurrentFamily>-1) {
|
||||
String sNewName = appendItem("StyleName",styleNameProvider.getInternalNames(sOOoFamilyNames[nCurrentFamily]).keySet());
|
||||
if (sNewName!=null) {
|
||||
Map<String,String> attr = new HashMap<String,String>();
|
||||
attr.put("before", "");
|
||||
attr.put("after", "");
|
||||
attr.put("after", "");
|
||||
attr.put("verbatim", "");
|
||||
attr.put("line-break","");
|
||||
styleMap[nCurrentFamily].put(sNewName, attr);
|
||||
}
|
||||
saveStyles();
|
||||
updateStylesControls();
|
||||
}
|
||||
newStyleClick();
|
||||
return true;
|
||||
}
|
||||
else if (sMethod.equals("DeleteStyleClick")) {
|
||||
if (nCurrentFamily>-1 && sCurrentStyleName!=null) {
|
||||
if (deleteCurrentItem("StyleName")) {
|
||||
styleMap[nCurrentFamily].remove(sCurrentStyleName);
|
||||
updateStylesControls();
|
||||
}
|
||||
}
|
||||
deleteStyleClick();
|
||||
return true;
|
||||
}
|
||||
else if (sMethod.equals("AddNextClick")) {
|
||||
addNextClick();
|
||||
return true;
|
||||
}
|
||||
else if (sMethod.equals("RemoveNextClick")) {
|
||||
removeNextClick();
|
||||
return true;
|
||||
}
|
||||
else if (sMethod.equals("LoadDefaultsClick")) {
|
||||
loadDefaultsClick();
|
||||
return true;
|
||||
}
|
||||
// Characters page
|
||||
|
@ -219,7 +210,6 @@ public final class ConfigurationDialog extends WeakBase
|
|||
return true;
|
||||
}
|
||||
else if (sMethod.equals("FormattingAttributeChange")) {
|
||||
saveCharacters();
|
||||
updateCharactersControls();
|
||||
return true;
|
||||
}
|
||||
|
@ -257,50 +247,27 @@ public final class ConfigurationDialog extends WeakBase
|
|||
}
|
||||
// Text and math page
|
||||
else if (sMethod.equals("MathSymbolNameChange")) {
|
||||
saveTextAndMath();
|
||||
updateTextAndMathControls();
|
||||
return true;
|
||||
}
|
||||
else if (sMethod.equals("NewSymbolClick")) {
|
||||
String sNewName = appendItem("MathSymbolName",new HashSet<String>());
|
||||
if (sNewName!=null) {
|
||||
Map<String,String> attr = new HashMap<String,String>();
|
||||
attr.put("latex", "");
|
||||
mathSymbols.put(sNewName, attr);
|
||||
}
|
||||
saveTextAndMath();
|
||||
updateTextAndMathControls();
|
||||
newSymbolClick();
|
||||
return true;
|
||||
}
|
||||
else if (sMethod.equals("DeleteSymbolClick")) {
|
||||
if (deleteCurrentItem("MathSymbolName")) {
|
||||
mathSymbols.remove(sCurrentMathSymbol);
|
||||
updateTextAndMathControls();
|
||||
}
|
||||
deleteSymbolClick();
|
||||
return true;
|
||||
}
|
||||
else if (sMethod.equals("TextInputChange")) {
|
||||
saveTextAndMath();
|
||||
updateTextAndMathControls();
|
||||
return true;
|
||||
}
|
||||
else if (sMethod.equals("NewTextClick")) {
|
||||
String sNewName = appendItem("TextInput", new HashSet<String>());
|
||||
if (sNewName!=null) {
|
||||
Map<String,String> attr = new HashMap<String,String>();
|
||||
attr.put("latex-code", "");
|
||||
attr.put("fontenc", "any");
|
||||
stringReplace.put(sNewName, attr);
|
||||
}
|
||||
saveTextAndMath();
|
||||
updateTextAndMathControls();
|
||||
newTextClick();
|
||||
return true;
|
||||
}
|
||||
else if (sMethod.equals("DeleteTextClick")) {
|
||||
if (deleteCurrentItem("TextInput")) {
|
||||
stringReplace.remove(sCurrentText);
|
||||
updateTextAndMathControls();
|
||||
}
|
||||
deleteTextClick();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -317,7 +284,7 @@ public final class ConfigurationDialog extends WeakBase
|
|||
String[] sNames = { "external_event",
|
||||
"NoPreambleChange", // Documentclass
|
||||
"MaxLevelChange", "WriterLevelChange", "NoIndexChange", // Headings
|
||||
"StyleFamilyChange", "StyleNameChange", "NewStyleClick", "DeleteStyleClick", // Styles
|
||||
"StyleFamilyChange", "StyleNameChange", "NewStyleClick", "DeleteStyleClick", "AddNextClick", "RemoveNextClick", "LoadDefaultsClick", // Styles
|
||||
"UseSoulChange", "FormattingAttributeChange", "CustomAttributeChange", // Characters
|
||||
"ExportGeometryChange", "ExportHeaderAndFooterChange", // Pages
|
||||
"NoTablesChange", "UseSupertabularChange", "UseLongtableChange", // Tables
|
||||
|
@ -342,7 +309,7 @@ public final class ConfigurationDialog extends WeakBase
|
|||
return sSupportedServiceNames;
|
||||
}
|
||||
|
||||
// Private stuff
|
||||
// Private stuff
|
||||
private boolean handleExternalEvent(Object aEventObject)
|
||||
throws com.sun.star.uno.Exception {
|
||||
try {
|
||||
|
@ -350,55 +317,11 @@ public final class ConfigurationDialog extends WeakBase
|
|||
if (sMethod.equals("ok")) {
|
||||
loadConfig();
|
||||
getControls();
|
||||
for (int i=0; i<5; i++) {
|
||||
ComplexOption configMap = config.getComplexOption(sFamilyNames[i]+"-map");
|
||||
configMap.clear();
|
||||
Map<String,String> internalNames = styleNameProvider.getInternalNames(sOOoFamilyNames[i]);
|
||||
for (String sDisplayName : styleMap[i].keySet()) {
|
||||
String sName = sDisplayName;
|
||||
if (internalNames!=null && internalNames.containsKey(sDisplayName)) {
|
||||
sName = internalNames.get(sDisplayName);
|
||||
}
|
||||
configMap.copy(sName, styleMap[i].get(sDisplayName));
|
||||
}
|
||||
}
|
||||
config.getComplexOption("text-attribute-map").clear();
|
||||
config.getComplexOption("text-attribute-map").copyAll(attributeMap);
|
||||
if (nCurrentMaxLevel>-1) {
|
||||
for (int i=nCurrentMaxLevel+1; i<11; i++) {
|
||||
headingMap.remove(Integer.toString(i));
|
||||
}
|
||||
}
|
||||
config.getComplexOption("heading-map").clear();
|
||||
config.getComplexOption("heading-map").copyAll(headingMap);
|
||||
config.getComplexOption("math-symbol-map").clear();
|
||||
config.getComplexOption("math-symbol-map").copyAll(mathSymbols);
|
||||
config.getComplexOption("string-replace").clear();
|
||||
config.getComplexOption("string-replace").copyAll(stringReplace);
|
||||
saveConfig();
|
||||
return true;
|
||||
} else if (sMethod.equals("back") || sMethod.equals("initialize")) {
|
||||
}
|
||||
else if (sMethod.equals("back") || sMethod.equals("initialize")) {
|
||||
loadConfig();
|
||||
for (int i=0; i<5; i++) {
|
||||
ComplexOption configMap = config.getComplexOption(sFamilyNames[i]+"-map");
|
||||
styleMap[i].clear();
|
||||
Map<String,String> displayNames = styleNameProvider.getDisplayNames(sOOoFamilyNames[i]);
|
||||
for (String sName : configMap.keySet()) {
|
||||
String sDisplayName = sName;
|
||||
if (displayNames!=null && displayNames.containsKey(sName)) {
|
||||
sDisplayName = displayNames.get(sName);
|
||||
}
|
||||
styleMap[i].copy(sDisplayName, configMap.get(sName));
|
||||
}
|
||||
}
|
||||
attributeMap.clear();
|
||||
attributeMap.copyAll(config.getComplexOption("text-attribute-map"));
|
||||
headingMap.clear();
|
||||
headingMap.copyAll(config.getComplexOption("heading-map"));
|
||||
mathSymbols.clear();
|
||||
mathSymbols.copyAll(config.getComplexOption("math-symbol-map"));
|
||||
stringReplace.clear();
|
||||
stringReplace.copyAll(config.getComplexOption("string-replace"));
|
||||
setControls();
|
||||
return true;
|
||||
}
|
||||
|
@ -657,13 +580,17 @@ public final class ConfigurationDialog extends WeakBase
|
|||
// This page handles the heading map as well as the options no_index, use_titlesec and use_titletoc
|
||||
|
||||
private void loadHeadings() {
|
||||
// Load heading map from config
|
||||
headingMap.clear();
|
||||
headingMap.copyAll(config.getComplexOption("heading-map"));
|
||||
nCurrentWriterLevel = -1;
|
||||
|
||||
// Determine the max level (from 0 to 10)
|
||||
Set<String> writerLevels = headingMap.keySet();
|
||||
nCurrentMaxLevel = 0;
|
||||
while(nCurrentMaxLevel<10 && writerLevels.contains(Integer.toString(nCurrentMaxLevel+1))) {
|
||||
nCurrentMaxLevel++;
|
||||
short nMaxLevel = 0;
|
||||
while(nMaxLevel<10 && headingMap.containsKey(Integer.toString(nMaxLevel+1))) {
|
||||
nMaxLevel++;
|
||||
}
|
||||
dlg.setListBoxSelectedItem("MaxLevel", nCurrentMaxLevel);
|
||||
dlg.setListBoxSelectedItem("MaxLevel", nMaxLevel);
|
||||
|
||||
dlg.setCheckBoxStateAsBoolean("UseTitlesec","true".equals(config.getOption("use_titlesec")));
|
||||
dlg.setCheckBoxStateAsBoolean("NoIndex","true".equals(config.getOption("no_index")));
|
||||
|
@ -673,6 +600,23 @@ public final class ConfigurationDialog extends WeakBase
|
|||
}
|
||||
|
||||
private void saveHeadings() {
|
||||
updateHeadingMap();
|
||||
|
||||
// Save heading map to config
|
||||
config.getComplexOption("heading-map").clear();
|
||||
int nMaxLevel = dlg.getListBoxSelectedItem("MaxLevel");
|
||||
for (int i=1; i<=nMaxLevel; i++) {
|
||||
String sLevel = Integer.toString(i);
|
||||
config.getComplexOption("heading-map").copy(sLevel,headingMap.get(sLevel));
|
||||
}
|
||||
|
||||
// Save other controls to config
|
||||
config.setOption("use_titlesec", Boolean.toString(dlg.getCheckBoxStateAsBoolean("UseTitlesec")));
|
||||
config.setOption("no_index", Boolean.toString(dlg.getCheckBoxStateAsBoolean("NoIndex")));
|
||||
config.setOption("use_titletoc", Boolean.toString(dlg.getCheckBoxStateAsBoolean("UseTitletoc")));
|
||||
}
|
||||
|
||||
private void updateHeadingMap() {
|
||||
// Save the current writer level in our cache
|
||||
if (nCurrentWriterLevel>-1) {
|
||||
Map<String,String> attr = new HashMap<String,String>();
|
||||
|
@ -680,32 +624,30 @@ public final class ConfigurationDialog extends WeakBase
|
|||
attr.put("level", dlg.getComboBoxText("LaTeXLevel"));
|
||||
headingMap.put(Integer.toString(nCurrentWriterLevel+1), attr);
|
||||
}
|
||||
|
||||
config.setOption("use_titlesec", Boolean.toString(dlg.getCheckBoxStateAsBoolean("UseTitlesec")));
|
||||
config.setOption("no_index", Boolean.toString(dlg.getCheckBoxStateAsBoolean("NoIndex")));
|
||||
config.setOption("use_titletoc", Boolean.toString(dlg.getCheckBoxStateAsBoolean("UseTitletoc")));
|
||||
}
|
||||
|
||||
private void updateHeadingsControls() {
|
||||
updateHeadingMap();
|
||||
|
||||
// Adjust the presented writer levels to the max level
|
||||
nCurrentMaxLevel = dlg.getListBoxSelectedItem("MaxLevel");
|
||||
int nMaxLevel = dlg.getListBoxSelectedItem("MaxLevel");
|
||||
nCurrentWriterLevel = dlg.getListBoxSelectedItem("WriterLevel");
|
||||
String[] sWriterLevels = new String[nCurrentMaxLevel];
|
||||
for (int i=0; i<nCurrentMaxLevel; i++) {
|
||||
String[] sWriterLevels = new String[nMaxLevel];
|
||||
for (int i=0; i<nMaxLevel; i++) {
|
||||
sWriterLevels[i]=Integer.toString(i+1);
|
||||
}
|
||||
dlg.setListBoxStringItemList("WriterLevel", sWriterLevels);
|
||||
if (nCurrentWriterLevel+1>nCurrentMaxLevel) { nCurrentWriterLevel = (short)(nCurrentMaxLevel-1); }
|
||||
else if (nCurrentWriterLevel<0 && nCurrentMaxLevel>0) { nCurrentWriterLevel=0; }
|
||||
if (nCurrentWriterLevel+1>nMaxLevel) { nCurrentWriterLevel = (short)(nMaxLevel-1); }
|
||||
else if (nCurrentWriterLevel<0 && nMaxLevel>0) { nCurrentWriterLevel=0; }
|
||||
dlg.setListBoxSelectedItem("WriterLevel", nCurrentWriterLevel);
|
||||
|
||||
// Load the values for the current level
|
||||
if (nCurrentWriterLevel>-1) {
|
||||
String sLevel = Integer.toString(nCurrentWriterLevel+1);
|
||||
if (headingMap.keySet().contains(sLevel)) {
|
||||
if (headingMap.containsKey(sLevel)) {
|
||||
Map<String,String> attr = headingMap.get(sLevel);
|
||||
dlg.setComboBoxText("LaTeXLevel", attr.get("level"));
|
||||
dlg.setComboBoxText("LaTeXName", attr.get("name"));
|
||||
dlg.setComboBoxText("LaTeXLevel", attr.containsKey("level") ? attr.get("level") : "");
|
||||
dlg.setComboBoxText("LaTeXName", attr.containsKey("name") ? attr.get("name") : "");
|
||||
}
|
||||
else {
|
||||
dlg.setListBoxSelectedItem("LaTeXLevel", (short)2);
|
||||
|
@ -728,14 +670,36 @@ public final class ConfigurationDialog extends WeakBase
|
|||
dlg.setControlEnabled("UseTitletoc", false);
|
||||
//boolean bNoIndex = dlg.getCheckBoxStateAsBoolean("NoIndex");
|
||||
//dlg.setControlEnabled("UseTitletoc", !bNoIndex);
|
||||
|
||||
}
|
||||
|
||||
// The page "Styles"
|
||||
// This page handles the various style maps as well as the options other_styles and formatting
|
||||
// Limitation: Cannot handle the values "error" and "warning" for other_styles
|
||||
|
||||
private void loadStyles() {
|
||||
String sFormatting = config.getOption("formatting");
|
||||
// Display paragraph maps first
|
||||
dlg.setListBoxSelectedItem("StyleFamily", (short)1);
|
||||
nCurrentFamily = -1;
|
||||
sCurrentStyleName = null;
|
||||
|
||||
// Load style maps from config (translating keys to display names)
|
||||
for (int i=0; i<5; i++) {
|
||||
ComplexOption configMap = config.getComplexOption(sFamilyNames[i]+"-map");
|
||||
styleMap[i].clear();
|
||||
Map<String,String> displayNames = styleNameProvider.getDisplayNames(sOOoFamilyNames[i]);
|
||||
copyStyles(configMap, styleMap[i], displayNames);
|
||||
}
|
||||
|
||||
// Load other controls from config
|
||||
String sOtherStyles = config.getOption("other_styles");
|
||||
if ("accept".equals(sOtherStyles)) {
|
||||
dlg.setListBoxSelectedItem("OtherStyles", (short)1);
|
||||
}
|
||||
else {
|
||||
dlg.setListBoxSelectedItem("OtherStyles", (short)0);
|
||||
}
|
||||
|
||||
String sFormatting = config.getOption("formatting");
|
||||
if ("ignore_all".equals(sFormatting)) {
|
||||
dlg.setListBoxSelectedItem("Formatting", (short)0);
|
||||
}
|
||||
|
@ -756,13 +720,46 @@ public final class ConfigurationDialog extends WeakBase
|
|||
}
|
||||
|
||||
private void saveStyles() {
|
||||
updateStyleMaps();
|
||||
|
||||
// Save style maps to config (translating keys back to internal names)
|
||||
for (int i=0; i<5; i++) {
|
||||
ComplexOption configMap = config.getComplexOption(sFamilyNames[i]+"-map");
|
||||
configMap.clear();
|
||||
Map<String,String> internalNames = styleNameProvider.getInternalNames(sOOoFamilyNames[i]);
|
||||
copyStyles(styleMap[i], configMap, internalNames);
|
||||
}
|
||||
|
||||
// Save other controls to config
|
||||
switch (dlg.getListBoxSelectedItem("OtherStyles")) {
|
||||
case 0: config.setOption("other_styles", "ignore"); break;
|
||||
case 1: config.setOption("other_styles", "accept");
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
private void updateStyleMaps() {
|
||||
// Save the current style map, if any
|
||||
if (nCurrentFamily>-1 && sCurrentStyleName!=null) {
|
||||
Map<String,String> attr=new HashMap<String,String>();
|
||||
attr.put("before", dlg.getTextFieldText("Before"));
|
||||
attr.put("after", dlg.getTextFieldText("After"));
|
||||
if (dlg.getControlEnabled("Next")) {
|
||||
attr.put("next", dlg.getTextFieldText("Next"));
|
||||
String[] sNextItems = dlg.getListBoxStringItemList("Next");
|
||||
int nCount = sNextItems.length;
|
||||
String sList = "";
|
||||
for (int i=0; i<nCount; i++) {
|
||||
if (i>0) sList+=";";
|
||||
sList+=sNextItems[i];
|
||||
}
|
||||
attr.put("next", sList);
|
||||
}
|
||||
if (dlg.getControlEnabled("LineBreak")) {
|
||||
attr.put("line-break", Boolean.toString(dlg.getCheckBoxStateAsBoolean("LineBreak")));
|
||||
|
@ -772,18 +769,11 @@ public final class ConfigurationDialog extends WeakBase
|
|||
}
|
||||
styleMap[nCurrentFamily].put(sCurrentStyleName, attr);
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void updateStylesControls() {
|
||||
updateStyleMaps();
|
||||
|
||||
short nNewFamily = dlg.getListBoxSelectedItem("StyleFamily");
|
||||
if (nNewFamily>-1 && nNewFamily!=nCurrentFamily) {
|
||||
// The user has changed the family; load and display the corresponding style names
|
||||
|
@ -798,6 +788,8 @@ public final class ConfigurationDialog extends WeakBase
|
|||
dlg.setListBoxSelectedItem("StyleName", (short)Math.min(sStyleNames.length-1, 0));
|
||||
dlg.setControlEnabled("NextLabel", nNewFamily==2);
|
||||
dlg.setControlEnabled("Next", nNewFamily==2);
|
||||
dlg.setControlEnabled("AddNextButton", nNewFamily==2);
|
||||
dlg.setControlEnabled("RemoveNextButton", nNewFamily==2);
|
||||
dlg.setControlEnabled("Verbatim", nNewFamily<2);
|
||||
dlg.setControlEnabled("LineBreak", nNewFamily==1);
|
||||
nCurrentFamily = nNewFamily;
|
||||
|
@ -810,17 +802,27 @@ public final class ConfigurationDialog extends WeakBase
|
|||
|
||||
Map<String,String> attr = styleMap[nCurrentFamily].get(sCurrentStyleName);
|
||||
dlg.setTextFieldText("Before", attr.containsKey("before") ? attr.get("before") : "");
|
||||
dlg.setTextFieldText("After", attr.containsKey("after") ? attr.get("before") : "");
|
||||
dlg.setTextFieldText("Next", attr.containsKey("next") ? attr.get("next") : "");
|
||||
dlg.setTextFieldText("Verbatim", attr.containsKey("verbatim") ? attr.get("verbatim") : "");
|
||||
dlg.setTextFieldText("LineBreak", attr.containsKey("line-break") ? attr.get("line-break") : "");
|
||||
dlg.setTextFieldText("After", attr.containsKey("after") ? attr.get("after") : "");
|
||||
String[] sNextItems;
|
||||
if (attr.containsKey("next")) {
|
||||
sNextItems = attr.get("next").split(";");
|
||||
}
|
||||
else {
|
||||
sNextItems = new String[0];
|
||||
}
|
||||
dlg.setListBoxStringItemList("Next", sNextItems);
|
||||
dlg.setListBoxSelectedItem("Next", (short)Math.min(sNextItems.length-1, 0));
|
||||
dlg.setCheckBoxStateAsBoolean("Verbatim",
|
||||
attr.containsKey("verbatim") ? "true".equals(attr.get("verbatim")) : false);
|
||||
dlg.setCheckBoxStateAsBoolean("LineBreak",
|
||||
attr.containsKey("line-break") ? "true".equals(attr.get("line-break")) : false);
|
||||
dlg.setControlEnabled("DeleteStyleButton", true);
|
||||
}
|
||||
else {
|
||||
sCurrentStyleName = null;
|
||||
dlg.setTextFieldText("Before", "");
|
||||
dlg.setTextFieldText("After", "");
|
||||
dlg.setTextFieldText("Next", "");
|
||||
dlg.setListBoxStringItemList("Next", new String[0]);
|
||||
dlg.setCheckBoxStateAsBoolean("Verbatim", false);
|
||||
dlg.setCheckBoxStateAsBoolean("LineBreak", false);
|
||||
dlg.setControlEnabled("DeleteStyleButton", false);
|
||||
|
@ -828,11 +830,114 @@ public final class ConfigurationDialog extends WeakBase
|
|||
}
|
||||
}
|
||||
|
||||
private void newStyleClick() {
|
||||
if (nCurrentFamily>-1) {
|
||||
String sNewName = appendItem("StyleName",styleNameProvider.getInternalNames(sOOoFamilyNames[nCurrentFamily]).keySet());
|
||||
if (sNewName!=null) {
|
||||
Map<String,String> attr = new HashMap<String,String>();
|
||||
attr.put("before", "");
|
||||
attr.put("after", "");
|
||||
attr.put("after", "");
|
||||
attr.put("verbatim", "");
|
||||
attr.put("line-break","");
|
||||
styleMap[nCurrentFamily].put(sNewName, attr);
|
||||
}
|
||||
saveStyles();
|
||||
updateStylesControls();
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteStyleClick() {
|
||||
if (nCurrentFamily>-1 && sCurrentStyleName!=null) {
|
||||
if (deleteCurrentItem("StyleName")) {
|
||||
styleMap[nCurrentFamily].remove(sCurrentStyleName);
|
||||
sCurrentStyleName = null;
|
||||
updateStylesControls();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addNextClick() {
|
||||
appendItem("Next",styleNameProvider.getInternalNames(sOOoFamilyNames[nCurrentFamily]).keySet());
|
||||
saveStyles();
|
||||
updateStylesControls();
|
||||
}
|
||||
|
||||
private void removeNextClick() {
|
||||
deleteCurrentItem("Next");
|
||||
updateStylesControls();
|
||||
}
|
||||
|
||||
private void loadDefaultsClick() {
|
||||
saveStyles();
|
||||
// Force update of the ui
|
||||
nCurrentFamily = -1;
|
||||
sCurrentStyleName = null;
|
||||
|
||||
// Count styles that we will overwrite
|
||||
Config clean = ConverterFactory.createConverter("application/x-latex").getConfig();
|
||||
clean.readDefaultConfig("clean.xml");
|
||||
|
||||
int nCount = 0;
|
||||
for (int i=0; i<5; i++) {
|
||||
ComplexOption cleanMap = clean.getComplexOption(sFamilyNames[i]+"-map");
|
||||
Map<String,String> displayNames = styleNameProvider.getDisplayNames(sOOoFamilyNames[i]);
|
||||
for (String sName : cleanMap.keySet()) {
|
||||
String sDisplayName = (displayNames!=null && displayNames.containsKey(sName)) ? displayNames.get(sName) : "";
|
||||
if (styleMap[i].containsKey(sDisplayName)) { nCount++; }
|
||||
}
|
||||
}
|
||||
|
||||
// Display confirmation dialog
|
||||
boolean bConfirm = false;
|
||||
XDialog xDialog=getDialog("W2LDialogs2.LoadDefaults");
|
||||
if (xDialog!=null) {
|
||||
DialogAccess ldlg = new DialogAccess(xDialog);
|
||||
if (nCount>0) {
|
||||
String sLabel = ldlg.getLabelText("OverwriteLabel");
|
||||
sLabel = sLabel.replaceAll("%s", Integer.toString(nCount));
|
||||
ldlg.setLabelText("OverwriteLabel", sLabel);
|
||||
}
|
||||
else {
|
||||
ldlg.setLabelText("OverwriteLabel", "");
|
||||
}
|
||||
bConfirm = xDialog.execute()==ExecutableDialogResults.OK;
|
||||
xDialog.endExecute();
|
||||
}
|
||||
|
||||
// Do the replacement
|
||||
if (bConfirm) {
|
||||
for (int i=0; i<5; i++) {
|
||||
ComplexOption cleanMap = clean.getComplexOption(sFamilyNames[i]+"-map");
|
||||
Map<String,String> displayNames = styleNameProvider.getDisplayNames(sOOoFamilyNames[i]);
|
||||
copyStyles(cleanMap, styleMap[i], displayNames);
|
||||
}
|
||||
}
|
||||
updateStylesControls();
|
||||
}
|
||||
|
||||
private void copyStyles(ComplexOption source, ComplexOption target, Map<String,String> nameTranslation) {
|
||||
for (String sName : source.keySet()) {
|
||||
String sNewName = sName;
|
||||
if (nameTranslation!=null && nameTranslation.containsKey(sName)) {
|
||||
sNewName = nameTranslation.get(sName);
|
||||
}
|
||||
target.copy(sNewName, source.get(sName));
|
||||
}
|
||||
}
|
||||
|
||||
// The page "Characters"
|
||||
// This page handles the options use_color, use_soul, use_ulem and use_hyperref
|
||||
// In addition it handles style maps for formatting attributes
|
||||
|
||||
private void loadCharacters() {
|
||||
// Load attribute style map from config
|
||||
attributeMap.clear();
|
||||
attributeMap.copyAll(config.getComplexOption("text-attribute-map"));
|
||||
nCurrentAttribute = -1;
|
||||
dlg.setListBoxSelectedItem("FormattingAttribute", (short)0);
|
||||
|
||||
// Load other controls from config
|
||||
dlg.setCheckBoxStateAsBoolean("UseHyperref","true".equals(config.getOption("use_hyperref")));
|
||||
dlg.setCheckBoxStateAsBoolean("UseColor","true".equals(config.getOption("use_color")));
|
||||
dlg.setCheckBoxStateAsBoolean("UseSoul","true".equals(config.getOption("use_soul")));
|
||||
|
@ -842,35 +947,48 @@ public final class ConfigurationDialog extends WeakBase
|
|||
}
|
||||
|
||||
private void saveCharacters() {
|
||||
// Save the current attribute map, if any
|
||||
if (nCurrentAttribute>-1) {
|
||||
if (dlg.getCheckBoxStateAsBoolean("CustomAttribute")) {
|
||||
HashMap<String,String> attr = new HashMap<String,String>();
|
||||
attr.put("before", dlg.getTextFieldText("Before"));
|
||||
attr.put("after", dlg.getTextFieldText("After"));
|
||||
attributeMap.put(sAttributeNames[nCurrentAttribute], attr);
|
||||
}
|
||||
else {
|
||||
attributeMap.remove(sAttributeNames[nCurrentAttribute]);
|
||||
updateCharactersMap();
|
||||
|
||||
// Save the attribute style map to config
|
||||
config.getComplexOption("text-attribute-map").clear();
|
||||
for (String s : attributeMap.keySet()) {
|
||||
if (!attributeMap.get(s).containsKey("deleted")) {
|
||||
config.getComplexOption("text-attribute-map").copy(s, attributeMap.get(s));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Save other controls to config
|
||||
config.setOption("use_hyperref", Boolean.toString(dlg.getCheckBoxStateAsBoolean("UseHyperref")));
|
||||
config.setOption("use_color", Boolean.toString(dlg.getCheckBoxStateAsBoolean("UseColor")));
|
||||
config.setOption("use_soul", Boolean.toString(dlg.getCheckBoxStateAsBoolean("UseSoul")));
|
||||
config.setOption("use_ulem", Boolean.toString(dlg.getCheckBoxStateAsBoolean("UseUlem")));
|
||||
}
|
||||
|
||||
private void updateCharactersMap() {
|
||||
// Save the current attribute map, if any
|
||||
if (nCurrentAttribute>-1) {
|
||||
HashMap<String,String> attr = new HashMap<String,String>();
|
||||
if (!dlg.getCheckBoxStateAsBoolean("CustomAttribute")) {
|
||||
// don't delete the map now, but defer this to the dialog is closed
|
||||
attr.put("deleted", "true");
|
||||
}
|
||||
attr.put("before", dlg.getTextFieldText("Before"));
|
||||
attr.put("after", dlg.getTextFieldText("After"));
|
||||
attributeMap.put(sAttributeNames[nCurrentAttribute], attr);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateCharactersControls() {
|
||||
updateCharactersMap();
|
||||
|
||||
short nNewAttribute = dlg.getListBoxSelectedItem("FormattingAttribute");
|
||||
if (nNewAttribute>-1 && nCurrentAttribute!=nNewAttribute) {
|
||||
String sName = sAttributeNames[nNewAttribute];
|
||||
if (attributeMap.keySet().contains(sName)) {
|
||||
dlg.setCheckBoxStateAsBoolean("CustomAttribute", true);
|
||||
dlg.setTextFieldText("Before",
|
||||
attributeMap.get(sName).containsKey("before") ? attributeMap.get(sName).get("before") : "");
|
||||
dlg.setTextFieldText("After",
|
||||
attributeMap.get(sName).containsKey("after") ? attributeMap.get(sName).get("after") : "");
|
||||
if (attributeMap.containsKey(sName)) {
|
||||
Map<String,String> attr = attributeMap.get(sName);
|
||||
dlg.setCheckBoxStateAsBoolean("CustomAttribute", !attr.containsKey("deleted"));
|
||||
dlg.setTextFieldText("Before", attr.containsKey("before") ? attr.get("before") : "");
|
||||
dlg.setTextFieldText("After", attr.containsKey("after") ? attr.get("after") : "");
|
||||
}
|
||||
else {
|
||||
dlg.setCheckBoxStateAsBoolean("CustomAttribute", false);
|
||||
|
@ -1036,7 +1154,6 @@ public final class ConfigurationDialog extends WeakBase
|
|||
dlg.setControlEnabled("TableLastFootStyle", !bNoTables && (bSupertabular || bLongtable));
|
||||
dlg.setControlEnabled("TableSequenceLabel", !bNoTables);
|
||||
dlg.setControlEnabled("TableSequenceName", !bNoTables);
|
||||
|
||||
}
|
||||
|
||||
// The page "Figures"
|
||||
|
@ -1075,45 +1192,53 @@ public final class ConfigurationDialog extends WeakBase
|
|||
// text replacements and math symbol definitions
|
||||
|
||||
private void loadTextAndMath() {
|
||||
// Get math symbols from config
|
||||
if (mathSymbols!=null) { mathSymbols.clear(); }
|
||||
else { mathSymbols = new ComplexOption(); }
|
||||
mathSymbols.copyAll(config.getComplexOption("math-symbol-map"));
|
||||
sCurrentMathSymbol = null;
|
||||
dlg.setListBoxStringItemList("MathSymbolName", sortStringSet(mathSymbols.keySet()));
|
||||
dlg.setListBoxSelectedItem("MathSymbolName", (short)Math.min(0,mathSymbols.keySet().size()-1));
|
||||
|
||||
// Get string replace from config
|
||||
if (stringReplace!=null) { stringReplace.clear(); }
|
||||
else { stringReplace = new ComplexOption(); }
|
||||
stringReplace.copyAll(config.getComplexOption("string-replace"));
|
||||
sCurrentText = null;
|
||||
dlg.setListBoxStringItemList("TextInput", sortStringSet(stringReplace.keySet()));
|
||||
dlg.setListBoxSelectedItem("TextInput", (short)Math.min(0,stringReplace.keySet().size()-1));
|
||||
|
||||
// Get other options from config
|
||||
dlg.setCheckBoxStateAsBoolean("UseOoomath","true".equals(config.getOption("use_ooomath")));
|
||||
|
||||
Set<String> symbolnames = config.getComplexOption("math-symbol-map").keySet();
|
||||
String[] sSymbolNames = new String[symbolnames.size()];
|
||||
int i=0;
|
||||
for (String s : symbolnames) {
|
||||
sSymbolNames[i++] = s;
|
||||
}
|
||||
sortStringArray(sSymbolNames);
|
||||
dlg.setListBoxStringItemList("MathSymbolName", sSymbolNames);
|
||||
dlg.setListBoxSelectedItem("MathSymbolName", (short)0);
|
||||
//sCurrentMathSymbol = symbolnames.size()>0 ? sSymbolNames[0] : null;
|
||||
|
||||
Set<String> names = config.getComplexOption("string-replace").keySet();
|
||||
String[] sNames = new String[names.size()];
|
||||
int j=0;
|
||||
for (String s : names) {
|
||||
sNames[j++] = s;
|
||||
}
|
||||
sortStringArray(sNames);
|
||||
dlg.setListBoxStringItemList("TextInput", sNames);
|
||||
dlg.setListBoxSelectedItem("TextInput", (short)0);
|
||||
//sCurrentText = sNames[0];
|
||||
|
||||
dlg.setTextFieldText("TabStopLaTeX", config.getOption("tabstop"));
|
||||
|
||||
updateTextAndMathControls();
|
||||
}
|
||||
|
||||
private void saveTextAndMath() {
|
||||
config.setOption("use_ooomath", Boolean.toString(dlg.getCheckBoxStateAsBoolean("UseOoomath")));
|
||||
updateTextAndMathMaps();
|
||||
|
||||
// Save math symbols to config
|
||||
config.getComplexOption("math-symbol-map").clear();
|
||||
config.getComplexOption("math-symbol-map").copyAll(mathSymbols);
|
||||
|
||||
// Save string replace to config
|
||||
config.getComplexOption("string-replace").clear();
|
||||
config.getComplexOption("string-replace").copyAll(stringReplace);
|
||||
|
||||
// Save other options to config
|
||||
config.setOption("use_ooomath", Boolean.toString(dlg.getCheckBoxStateAsBoolean("UseOoomath")));
|
||||
config.setOption("tabstop", dlg.getTextFieldText("TabStopLaTeX"));
|
||||
}
|
||||
|
||||
private void updateTextAndMathMaps() {
|
||||
// Save the current math symbol in our cache
|
||||
if (sCurrentMathSymbol!=null) {
|
||||
Map<String,String> attr = new HashMap<String,String>();
|
||||
attr.put("latex", dlg.getTextFieldText("MathLaTeX"));
|
||||
mathSymbols.put(sCurrentMathSymbol, attr);
|
||||
}
|
||||
|
||||
|
||||
// Save the current string replace in our cache
|
||||
if (sCurrentText!=null) {
|
||||
Map<String,String> attr = new HashMap<String,String>();
|
||||
|
@ -1121,11 +1246,11 @@ public final class ConfigurationDialog extends WeakBase
|
|||
attr.put("fontenc", "any");
|
||||
stringReplace.put(sCurrentText, attr);
|
||||
}
|
||||
|
||||
config.setOption("tabstop", dlg.getTextFieldText("TabStopLaTeX"));
|
||||
}
|
||||
|
||||
private void updateTextAndMathControls() {
|
||||
updateTextAndMathMaps();
|
||||
|
||||
// Get the current math symbol, if any
|
||||
short nSymbolItem = dlg.getListBoxSelectedItem("MathSymbolName");
|
||||
if (nSymbolItem>=0) {
|
||||
|
@ -1163,7 +1288,56 @@ public final class ConfigurationDialog extends WeakBase
|
|||
|
||||
}
|
||||
|
||||
private void newSymbolClick() {
|
||||
String sNewName = appendItem("MathSymbolName",customSymbolNameProvider.getNames());
|
||||
if (sNewName!=null) {
|
||||
Map<String,String> attr = new HashMap<String,String>();
|
||||
attr.put("latex", "");
|
||||
mathSymbols.put(sNewName, attr);
|
||||
}
|
||||
saveTextAndMath();
|
||||
updateTextAndMathControls();
|
||||
}
|
||||
|
||||
private void deleteSymbolClick() {
|
||||
if (deleteCurrentItem("MathSymbolName")) {
|
||||
mathSymbols.remove(sCurrentMathSymbol);
|
||||
sCurrentMathSymbol = null;
|
||||
updateTextAndMathControls();
|
||||
}
|
||||
}
|
||||
|
||||
private void newTextClick() {
|
||||
String sNewName = appendItem("TextInput", new HashSet<String>());
|
||||
if (sNewName!=null) {
|
||||
Map<String,String> attr = new HashMap<String,String>();
|
||||
attr.put("latex-code", "");
|
||||
attr.put("fontenc", "any");
|
||||
stringReplace.put(sNewName, attr);
|
||||
}
|
||||
saveTextAndMath();
|
||||
updateTextAndMathControls();
|
||||
}
|
||||
|
||||
private void deleteTextClick() {
|
||||
if (deleteCurrentItem("TextInput")) {
|
||||
stringReplace.remove(sCurrentText);
|
||||
sCurrentText = null;
|
||||
updateTextAndMathControls();
|
||||
}
|
||||
}
|
||||
|
||||
// Utilities
|
||||
private String[] sortStringSet(Set<String> theSet) {
|
||||
String[] theArray = new String[theSet.size()];
|
||||
int i=0;
|
||||
for (String s : theSet) {
|
||||
theArray[i++] = s;
|
||||
}
|
||||
sortStringArray(theArray);
|
||||
return theArray;
|
||||
}
|
||||
|
||||
private void sortStringArray(String[] theArray) {
|
||||
// TODO: Get locale from OOo rather than the system
|
||||
Collator collator = Collator.getInstance();
|
||||
|
|
|
@ -0,0 +1,86 @@
|
|||
/**
|
||||
* CustomSymbolNameProvider.java
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License version 2.1, as published by the Free Software Foundation.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
* Copyright: 2002-2009 by Henrik Just
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.2 (2009-11-09)
|
||||
*
|
||||
*/
|
||||
package org.openoffice.da.comp.writer2latex;
|
||||
|
||||
import org.openoffice.da.comp.w2lcommon.helper.RegistryHelper;
|
||||
import org.openoffice.da.comp.w2lcommon.helper.XPropertySetHelper;
|
||||
|
||||
import com.sun.star.beans.XPropertySet;
|
||||
import com.sun.star.container.XNameAccess;
|
||||
import com.sun.star.uno.UnoRuntime;
|
||||
import com.sun.star.uno.XComponentContext;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/** This class provides access to the names of all user defined symbols in math
|
||||
*
|
||||
*/
|
||||
public class CustomSymbolNameProvider {
|
||||
Set<String> names;
|
||||
|
||||
/** Construct a new <code>CustomSymbolNameProvider</code>
|
||||
*
|
||||
* @param xContext the component context providing access to the api
|
||||
*/
|
||||
public CustomSymbolNameProvider(XComponentContext xContext) {
|
||||
names = new HashSet<String>();
|
||||
|
||||
RegistryHelper registry = new RegistryHelper(xContext);
|
||||
try {
|
||||
// Prepare registry view
|
||||
Object view = registry.getRegistryView("/org.openoffice.Office.Math/",false);
|
||||
XPropertySet xProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,view);
|
||||
|
||||
// Get the list of symbols
|
||||
Object symbols = XPropertySetHelper.getPropertyValue(xProps,"SymbolList");
|
||||
XNameAccess xSymbols = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class,symbols);
|
||||
String[] sNames = xSymbols.getElementNames();
|
||||
int nCount = sNames.length;
|
||||
for (int i=0; i<nCount; i++) {
|
||||
Object config = xSymbols.getByName(sNames[i]);
|
||||
XPropertySet xSymbolProps = (XPropertySet)
|
||||
UnoRuntime.queryInterface(XPropertySet.class,config);
|
||||
if (!XPropertySetHelper.getPropertyValueAsBoolean(xSymbolProps,"Predefined")) {
|
||||
names.add(sNames[i]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception e) {
|
||||
// failed to get registry view, ignore
|
||||
}
|
||||
}
|
||||
|
||||
/** Return the names of all user defined symbols (excluding the predefined symbols such as ALPHA etc)
|
||||
*
|
||||
* @return a read only string set of symbols names
|
||||
*/
|
||||
public Set<String> getNames() {
|
||||
return Collections.unmodifiableSet(names);
|
||||
}
|
||||
|
||||
}
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.2 (2009-06-19)
|
||||
* Version 1.2 (2009-11-19)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -35,9 +35,12 @@ 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.lang.XComponent;
|
||||
import com.sun.star.lang.XMultiComponentFactory;
|
||||
import com.sun.star.lang.XServiceInfo;
|
||||
import com.sun.star.ui.dialogs.ExecutableDialogResults;
|
||||
import com.sun.star.ui.dialogs.XExecutableDialog;
|
||||
|
@ -48,6 +51,8 @@ import com.sun.star.uno.XComponentContext;
|
|||
|
||||
import com.sun.star.lib.uno.helper.WeakBase;
|
||||
|
||||
import org.openoffice.da.comp.w2lcommon.helper.DialogAccess;
|
||||
|
||||
/** This class provides a uno component which implements the configuration
|
||||
* of Writer4LaTeX
|
||||
*/
|
||||
|
@ -247,12 +252,30 @@ public final class ConfigurationDialog
|
|||
}
|
||||
}
|
||||
|
||||
// Unix: Configure a certain application, reporting the availability
|
||||
private boolean configureApp(String sName, String sAppName, String sArguments, StringBuffer info) {
|
||||
if (hasApp(sAppName)) {
|
||||
externalApps.setApplication(sName, sAppName, sArguments);
|
||||
info.append("Found "+sAppName+" - OK\n");
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
externalApps.setApplication(sName, "???", "???");
|
||||
info.append("Failed to find "+sAppName+"\n");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Unix: Configure a certain application testing the availability
|
||||
// This variant uses an array of potential apps
|
||||
private boolean configureApp(String sName, String[] sAppNames, String sArguments) {
|
||||
private boolean configureApp(String sName, String[] sAppNames, String sArguments, StringBuffer info) {
|
||||
for (String sAppName : sAppNames) {
|
||||
if (configureApp(sName, sAppName, sArguments)) { return true; }
|
||||
if (configureApp(sName, sAppName, sArguments)) {
|
||||
info.append("Found "+sName+": "+sAppName+" - OK\n");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
info.append("Failed to find "+sName+"\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -273,23 +296,28 @@ public final class ConfigurationDialog
|
|||
// And assume gsview for pdf and ps
|
||||
// gsview32 may not be in the path, but at least this helps a bit
|
||||
externalApps.setApplication(ExternalApps.PDFVIEWER, "gsview32.exe", "-e \"%s\"");
|
||||
externalApps.setApplication(ExternalApps.POSTSCRIPTVIEWER, "gsview32.exe", "-e \"%s\"");
|
||||
externalApps.setApplication(ExternalApps.POSTSCRIPTVIEWER, "gsview32.exe", "-e \"%s\"");
|
||||
displayAutoConfigInfo("Configured for MikTeX...");
|
||||
}
|
||||
else { // Assume a unix-like system supporting the "which" command
|
||||
configureApp(ExternalApps.LATEX, "latex", "--interaction=batchmode %s");
|
||||
configureApp(ExternalApps.PDFLATEX, "pdflatex", "--interaction=batchmode %s");
|
||||
configureApp(ExternalApps.XELATEX, "xelatex", "--interaction=batchmode %s");
|
||||
configureApp(ExternalApps.DVIPS, "dvips", "%s");
|
||||
configureApp(ExternalApps.BIBTEX, "bibtex", "%s");
|
||||
configureApp(ExternalApps.MAKEINDEX, "makeindex", "%s");
|
||||
configureApp(ExternalApps.MK4HT, "mk4ht", "%c %s");
|
||||
StringBuffer info = new StringBuffer();
|
||||
info.append("Results of configuration:\n\n");
|
||||
configureApp(ExternalApps.LATEX, "latex", "--interaction=batchmode %s",info);
|
||||
configureApp(ExternalApps.PDFLATEX, "pdflatex", "--interaction=batchmode %s",info);
|
||||
configureApp(ExternalApps.XELATEX, "xelatex", "--interaction=batchmode %s",info);
|
||||
configureApp(ExternalApps.DVIPS, "dvips", "%s",info);
|
||||
configureApp(ExternalApps.BIBTEX, "bibtex", "%s",info);
|
||||
configureApp(ExternalApps.MAKEINDEX, "makeindex", "%s",info);
|
||||
configureApp(ExternalApps.MK4HT, "mk4ht", "%c %s",info);
|
||||
// We have several possible viewers
|
||||
String[] sDviViewers = {"evince", "okular", "xdvi"};
|
||||
configureApp(ExternalApps.DVIVIEWER, sDviViewers, "%s");
|
||||
configureApp(ExternalApps.DVIVIEWER, sDviViewers, "%s",info);
|
||||
String[] sPdfViewers = {"evince", "okular", "xpdf"};
|
||||
configureApp(ExternalApps.PDFVIEWER, sPdfViewers, "%s");
|
||||
configureApp(ExternalApps.PDFVIEWER, sPdfViewers, "%s",info);
|
||||
String[] sPsViewers = {"evince", "okular", "ghostview"};
|
||||
configureApp(ExternalApps.POSTSCRIPTVIEWER, sPsViewers, "%s");
|
||||
configureApp(ExternalApps.POSTSCRIPTVIEWER, sPsViewers, "%s",info);
|
||||
|
||||
displayAutoConfigInfo(info.toString());
|
||||
}
|
||||
changeApplication(xWindow);
|
||||
return true;
|
||||
|
@ -313,6 +341,32 @@ public final class ConfigurationDialog
|
|||
return "???";
|
||||
}
|
||||
|
||||
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) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void displayAutoConfigInfo(String sText) {
|
||||
XDialog xDialog = getDialog("W4LDialogs.AutoConfigInfo");
|
||||
if (xDialog!=null) {
|
||||
DialogAccess info = new DialogAccess(xDialog);
|
||||
info.setTextFieldText("Info", sText);
|
||||
xDialog.execute();
|
||||
xDialog.endExecute();
|
||||
}
|
||||
}
|
||||
|
||||
// Some helpers copied from DialogBase
|
||||
private XPropertySet getControlProperties(XWindow xWindow, String sControlName) {
|
||||
XControlContainer xContainer = (XControlContainer)
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.2 (2009-06-19)
|
||||
* Version 1.2 (2009-11-19)
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
|
@ -77,8 +77,9 @@ public final class TeXify {
|
|||
* @param nBackend the desired backend format (generic, dvips, pdftex)
|
||||
* @param bView set the true if the result should be displayed in the viewer
|
||||
* @throws IOException if the document cannot be read
|
||||
* @return true if the first LaTeX run was succesful
|
||||
*/
|
||||
public void process(File file, short nBackend, boolean bView) throws IOException {
|
||||
public boolean process(File file, short nBackend, boolean bView) throws IOException {
|
||||
// Remove extension from file
|
||||
if (file.getName().endsWith(".tex")) {
|
||||
file = new File(file.getParentFile(),
|
||||
|
@ -89,8 +90,10 @@ public final class TeXify {
|
|||
externalApps.load();
|
||||
|
||||
// Process LaTeX document
|
||||
boolean bResult = false;
|
||||
if (nBackend==GENERIC) {
|
||||
doTeXify(genericTexify, file);
|
||||
bResult = doTeXify(genericTexify, file);
|
||||
if (!bResult) return false;
|
||||
if (externalApps.execute(ExternalApps.DVIVIEWER,
|
||||
new File(file.getParentFile(),file.getName()+".dvi").getPath(),
|
||||
file.getParentFile(), false)>0) {
|
||||
|
@ -98,7 +101,8 @@ public final class TeXify {
|
|||
}
|
||||
}
|
||||
else if (nBackend==PDFTEX) {
|
||||
doTeXify(pdfTexify, file);
|
||||
bResult = doTeXify(pdfTexify, file);
|
||||
if (!bResult) return false;
|
||||
if (externalApps.execute(ExternalApps.PDFVIEWER,
|
||||
new File(file.getParentFile(),file.getName()+".pdf").getPath(),
|
||||
file.getParentFile(), false)>0) {
|
||||
|
@ -106,7 +110,8 @@ public final class TeXify {
|
|||
}
|
||||
}
|
||||
else if (nBackend==DVIPS) {
|
||||
doTeXify(dvipsTexify, file);
|
||||
bResult = doTeXify(dvipsTexify, file);
|
||||
if (!bResult) return false;
|
||||
if (externalApps.execute(ExternalApps.POSTSCRIPTVIEWER,
|
||||
new File(file.getParentFile(),file.getName()+".ps").getPath(),
|
||||
file.getParentFile(), false)>0) {
|
||||
|
@ -114,25 +119,30 @@ public final class TeXify {
|
|||
}
|
||||
}
|
||||
else if (nBackend==XETEX) {
|
||||
doTeXify(xeTexify, file);
|
||||
bResult = doTeXify(xeTexify, file);
|
||||
if (!bResult) return false;
|
||||
if (externalApps.execute(ExternalApps.PDFVIEWER,
|
||||
new File(file.getParentFile(),file.getName()+".pdf").getPath(),
|
||||
file.getParentFile(), false)>0) {
|
||||
throw new IOException("Error executing pdf viewer");
|
||||
}
|
||||
}
|
||||
return bResult;
|
||||
|
||||
}
|
||||
|
||||
private void doTeXify(String[] sAppList, File file) throws IOException {
|
||||
private boolean doTeXify(String[] sAppList, File file) throws IOException {
|
||||
for (int i=0; i<sAppList.length; i++) {
|
||||
// Execute external application
|
||||
int nReturnCode = externalApps.execute(
|
||||
sAppList[i], file.getName(), file.getParentFile(), true);
|
||||
if (nReturnCode>0) {
|
||||
System.out.println("Return code from "+sAppList[i]+": "+nReturnCode);
|
||||
if (i==0 && nReturnCode>0) {
|
||||
return false;
|
||||
//throw new IOException("Error executing "+sAppList[i]);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.2 (2009-06-19)
|
||||
* Version 1.2 (2009-11-19)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -223,27 +223,35 @@ public final class Writer4LaTeX extends WeakBase
|
|||
|
||||
if (texify==null) { texify = new TeXify(m_xContext); }
|
||||
File file = new File(urlToFile(sBasePath),sBaseFileName);
|
||||
|
||||
boolean bResult = true;
|
||||
|
||||
try {
|
||||
if (sBackend=="pdftex") {
|
||||
texify.process(file, TeXify.PDFTEX, true);
|
||||
bResult = texify.process(file, TeXify.PDFTEX, true);
|
||||
}
|
||||
else if (sBackend=="dvips") {
|
||||
texify.process(file, TeXify.DVIPS, true);
|
||||
bResult = texify.process(file, TeXify.DVIPS, true);
|
||||
}
|
||||
else if (sBackend=="xetex") {
|
||||
texify.process(file, TeXify.XETEX, true);
|
||||
bResult = texify.process(file, TeXify.XETEX, true);
|
||||
}
|
||||
else if (sBackend=="generic") {
|
||||
texify.process(file, TeXify.GENERIC, true);
|
||||
bResult = texify.process(file, TeXify.GENERIC, true);
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
MessageBox msgBox = new MessageBox(m_xContext, m_xFrame);
|
||||
msgBox.showMessage("Writer4LaTeX Error",e.getMessage());
|
||||
}
|
||||
|
||||
xStatus.setValue(10); // The user will not really see this...
|
||||
|
||||
xStatus.setValue(10); // The user will usually not see this...
|
||||
|
||||
if (!bResult) {
|
||||
MessageBox msgBox = new MessageBox(m_xContext, m_xFrame);
|
||||
msgBox.showMessage("Writer4LaTeX Error","Failed to execute LaTeX - see log for details");
|
||||
}
|
||||
|
||||
xStatus.end();
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.2 (2009-11-08)
|
||||
* Version 1.2 (2009-11-19)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -107,6 +107,15 @@ public class ComplexOption {
|
|||
return options.keySet();
|
||||
}
|
||||
|
||||
/** Test if this complex options contains a specific option name
|
||||
*
|
||||
* @param sName the name to test
|
||||
* @return true if the name exists
|
||||
*/
|
||||
public boolean containsKey(String sName) {
|
||||
return options.containsKey(sName);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.2 (2009-11-08)
|
||||
* Version 1.2 (2009-11-23)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -33,7 +33,7 @@ public class ConverterFactory {
|
|||
|
||||
// Version information
|
||||
private static final String VERSION = "1.1.1";
|
||||
private static final String DATE = "2009-11-08";
|
||||
private static final String DATE = "2009-11-23";
|
||||
|
||||
/** Return version information
|
||||
* @return the Writer2LaTeX version in the form
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
</dlg:styles>
|
||||
<dlg:bulletinboard>
|
||||
<dlg:fixedline dlg:id="FixedLine1" dlg:tab-index="0" dlg:left="6" dlg:top="32" dlg:width="248" dlg:height="2"/>
|
||||
<dlg:img dlg:style-id="0" dlg:id="ImageControl1" dlg:tab-index="1" dlg:left="8" dlg:top="6" dlg:width="21" dlg:height="21" dlg:scale-image="false" dlg:src="file:///home/henrik/workspace/Writer2LaTeX%20trunk/source/oxt/writer2latex/images/w2licon.png"/>
|
||||
<dlg:img dlg:style-id="0" dlg:id="ImageControl1" dlg:tab-index="1" dlg:left="8" dlg:top="6" dlg:width="21" dlg:height="21" dlg:scale-image="false" dlg:src="../images/w2licon.png"/>
|
||||
<dlg:text dlg:style-id="1" dlg:id="Label1" dlg:tab-index="2" dlg:left="34" dlg:top="10" dlg:width="193" dlg:height="16" dlg:value="Writer2LaTeX Custom Configuration"/>
|
||||
<dlg:text dlg:id="Label2" dlg:tab-index="3" dlg:left="34" dlg:top="43" dlg:width="194" dlg:height="78" dlg:value="This is where you create a custom configuration for the Writer2LaTeX export filter. You can define how to convert text, tables, figures etc. to LaTeX code. Creating a custom configuration requires some knowledge of LaTeX.
You can export your configuration as an extension, that can be deployed to another OpenOffice.org installation." dlg:multiline="true"/>
|
||||
<dlg:button dlg:id="ExportButton" dlg:tab-index="4" dlg:left="34" dlg:top="140" dlg:width="190" dlg:height="12" dlg:value="Export as extension..."/>
|
||||
<dlg:button dlg:id="ExportButton" dlg:tab-index="4" dlg:left="34" dlg:top="140" dlg:width="190" dlg:height="12" dlg:value="Export as extension..." dlg:disabled="true" />
|
||||
</dlg:bulletinboard>
|
||||
</dlg:window>
|
|
@ -36,7 +36,7 @@
|
|||
</dlg:menupopup>
|
||||
<script:event script:event-name="on-itemstatechange" script:macro-name="vnd.sun.star.UNO:WriterLevelChange" script:language="UNO"/>
|
||||
</dlg:menulist>
|
||||
<dlg:text dlg:id="LaTeXLevelLabel" dlg:tab-index="5" dlg:left="10" dlg:top="56" dlg:width="100" dlg:height="12" dlg:value="LaTeX level"/>
|
||||
<dlg:text dlg:id="LaTeXLevelLabel" dlg:tab-index="5" dlg:left="15" dlg:top="56" dlg:width="95" dlg:height="12" dlg:value="LaTeX level"/>
|
||||
<dlg:combobox dlg:id="LaTeXLevel" dlg:tab-index="6" dlg:left="140" dlg:top="54" dlg:width="40" dlg:height="12" dlg:spin="true" dlg:linecount="7">
|
||||
<dlg:menupopup>
|
||||
<dlg:menuitem dlg:value="-1"/>
|
||||
|
@ -48,7 +48,7 @@
|
|||
<dlg:menuitem dlg:value="5"/>
|
||||
</dlg:menupopup>
|
||||
</dlg:combobox>
|
||||
<dlg:text dlg:id="LaTeXNameLabel" dlg:tab-index="7" dlg:left="10" dlg:top="70" dlg:width="100" dlg:height="12" dlg:value="LaTeX heading name"/>
|
||||
<dlg:text dlg:id="LaTeXNameLabel" dlg:tab-index="7" dlg:left="15" dlg:top="70" dlg:width="95" dlg:height="12" dlg:value="LaTeX heading name"/>
|
||||
<dlg:combobox dlg:id="LaTeXName" dlg:tab-index="8" dlg:left="140" dlg:top="68" dlg:width="100" dlg:height="12" dlg:spin="true" dlg:linecount="7">
|
||||
<dlg:menupopup>
|
||||
<dlg:menuitem dlg:value="part"/>
|
||||
|
|
10
source/oxt/writer2latex/W2LDialogs2/LoadDefaults.xdl
Normal file
10
source/oxt/writer2latex/W2LDialogs2/LoadDefaults.xdl
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE dlg:window PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "dialog.dtd">
|
||||
<dlg:window xmlns:dlg="http://openoffice.org/2000/dialog" xmlns:script="http://openoffice.org/2000/script" dlg:id="LoadDefaults" dlg:left="255" dlg:top="145" dlg:width="160" dlg:height="64" dlg:closeable="true" dlg:moveable="true" dlg:title="Load default mappings">
|
||||
<dlg:bulletinboard>
|
||||
<dlg:text dlg:id="InfoLabel" dlg:tab-index="0" dlg:left="5" dlg:top="8" dlg:width="150" dlg:height="12" dlg:value="Do you wish to load the default mappings?"/>
|
||||
<dlg:text dlg:id="OverwriteLabel" dlg:tab-index="1" dlg:left="5" dlg:top="22" dlg:width="150" dlg:height="12" dlg:value="(This will overwrite %s existing mappings)"/>
|
||||
<dlg:button dlg:id="YesButton" dlg:tab-index="2" dlg:left="5" dlg:top="42" dlg:width="50" dlg:height="12" dlg:value="Yes" dlg:button-type="ok"/>
|
||||
<dlg:button dlg:id="NoButton" dlg:tab-index="3" dlg:left="60" dlg:top="42" dlg:width="50" dlg:height="12" dlg:value="No" dlg:button-type="cancel"/>
|
||||
</dlg:bulletinboard>
|
||||
</dlg:window>
|
|
@ -13,32 +13,38 @@
|
|||
</dlg:menupopup>
|
||||
<script:event script:event-name="on-itemstatechange" script:macro-name="vnd.sun.star.UNO:StyleFamilyChange" script:language="UNO"/>
|
||||
</dlg:menulist>
|
||||
<dlg:menulist dlg:id="StyleName" dlg:tab-index="2" dlg:left="80" dlg:top="26" dlg:width="80" dlg:height="12" dlg:spin="true">
|
||||
<script:event script:event-name="on-itemstatechange" script:macro-name="vnd.sun.star.UNO:StyleNameChange" script:language="UNO"/>
|
||||
<dlg:menulist dlg:id="StyleName" dlg:tab-index="2" dlg:left="80" dlg:top="26" dlg:width="80" dlg:height="12" dlg:spin="true" dlg:linecount="10">
|
||||
<script:event script:event-name="on-itemstatechange" script:macro-name="vnd.sun.star.UNO:StyleNameChange" script:language="UNO"/>
|
||||
</dlg:menulist>
|
||||
<dlg:text dlg:id="StyleNameLabel" dlg:tab-index="3" dlg:left="10" dlg:top="28" dlg:width="60" dlg:height="12" dlg:value="Style name"/>
|
||||
<dlg:button dlg:id="NewStyleButton" dlg:tab-index="4" dlg:left="165" dlg:top="26" dlg:width="40" dlg:height="12" dlg:value="New...">
|
||||
<script:event script:event-name="on-mouseup" script:macro-name="vnd.sun.star.UNO:NewStyleClick" script:language="UNO"/>
|
||||
<script:event script:event-name="on-mouseup" script:macro-name="vnd.sun.star.UNO:NewStyleClick" script:language="UNO"/>
|
||||
</dlg:button>
|
||||
<dlg:button dlg:id="DeleteStyleButton" dlg:tab-index="5" dlg:left="210" dlg:top="26" dlg:width="40" dlg:height="12" dlg:value="Delete...">
|
||||
<script:event script:event-name="on-mouseup" script:macro-name="vnd.sun.star.UNO:DeleteStyleClick" script:language="UNO"/>
|
||||
<script:event script:event-name="on-mouseup" script:macro-name="vnd.sun.star.UNO:DeleteStyleClick" script:language="UNO"/>
|
||||
</dlg:button>
|
||||
<dlg:text dlg:id="BeforeLabel" dlg:tab-index="6" dlg:left="15" dlg:top="42" dlg:width="60" dlg:height="12" dlg:value="LaTeX code before"/>
|
||||
<dlg:textfield dlg:id="Before" dlg:tab-index="7" dlg:left="80" dlg:top="40" dlg:width="170" dlg:height="12"/>
|
||||
<dlg:text dlg:id="AfterLabel" dlg:tab-index="8" dlg:left="15" dlg:top="56" dlg:width="60" dlg:height="12" dlg:value="LaTeX code after"/>
|
||||
<dlg:textfield dlg:id="After" dlg:tab-index="9" dlg:left="80" dlg:top="54" dlg:width="170" dlg:height="12"/>
|
||||
<dlg:text dlg:id="NextLabel" dlg:tab-index="10" dlg:left="15" dlg:top="70" dlg:width="60" dlg:height="12" dlg:value="Next style(s)"/>
|
||||
<dlg:textfield dlg:id="Next" dlg:tab-index="11" dlg:left="80" dlg:top="68" dlg:width="170" dlg:height="12"/>
|
||||
<dlg:checkbox dlg:id="LineBreak" dlg:tab-index="13" dlg:left="15" dlg:top="98" dlg:width="235" dlg:height="12" dlg:value="Line break inside" dlg:checked="false"/>
|
||||
<dlg:text dlg:id="OtherStylesLabel" dlg:tab-index="14" dlg:left="10" dlg:top="118" dlg:width="100" dlg:height="12" dlg:value="Other styles"/>
|
||||
<dlg:menulist dlg:id="OtherStyles" dlg:tab-index="15" dlg:left="120" dlg:top="116" dlg:width="130" dlg:height="12" dlg:spin="true">
|
||||
<dlg:menulist dlg:id="Next" dlg:tab-index="10" dlg:left="80" dlg:top="68" dlg:width="80" dlg:height="12" dlg:spin="true"/>
|
||||
<dlg:button dlg:id="AddNextButton" dlg:tab-index="11" dlg:left="165" dlg:top="68" dlg:width="40" dlg:height="12" dlg:value="Add...">
|
||||
<script:event script:event-name="on-mouseup" script:macro-name="vnd.sun.star.UNO:AddNextClick" script:language="UNO"/>
|
||||
</dlg:button>
|
||||
<dlg:button dlg:id="RemoveNextButton" dlg:tab-index="12" dlg:left="210" dlg:top="68" dlg:width="40" dlg:height="12" dlg:value="Remove...">
|
||||
<script:event script:event-name="on-mouseup" script:macro-name="vnd.sun.star.UNO:RemoveNextClick" script:language="UNO"/>
|
||||
</dlg:button>
|
||||
<dlg:text dlg:id="NextLabel" dlg:tab-index="13" dlg:left="15" dlg:top="70" dlg:width="60" dlg:height="12" dlg:value="Next style(s)"/>
|
||||
<dlg:checkbox dlg:id="LineBreak" dlg:tab-index="15" dlg:left="15" dlg:top="98" dlg:width="235" dlg:height="12" dlg:value="Line break inside" dlg:checked="false"/>
|
||||
<dlg:text dlg:id="OtherStylesLabel" dlg:tab-index="17" dlg:left="10" dlg:top="138" dlg:width="65" dlg:height="12" dlg:value="Other styles"/>
|
||||
<dlg:menulist dlg:id="OtherStyles" dlg:tab-index="18" dlg:left="80" dlg:top="136" dlg:width="170" dlg:height="12" dlg:spin="true">
|
||||
<dlg:menupopup>
|
||||
<dlg:menuitem dlg:value="Ignore"/>
|
||||
<dlg:menuitem dlg:value="Convert"/>
|
||||
</dlg:menupopup>
|
||||
</dlg:menulist>
|
||||
<dlg:checkbox dlg:id="Verbatim" dlg:tab-index="12" dlg:left="15" dlg:top="84" dlg:width="235" dlg:height="12" dlg:value="Verbatim content" dlg:checked="false"/>
|
||||
<dlg:menulist dlg:id="Formatting" dlg:tab-index="17" dlg:left="120" dlg:top="136" dlg:width="130" dlg:height="12" dlg:spin="true">
|
||||
<dlg:checkbox dlg:id="Verbatim" dlg:tab-index="14" dlg:left="15" dlg:top="84" dlg:width="235" dlg:height="12" dlg:value="Verbatim content" dlg:checked="false"/>
|
||||
<dlg:menulist dlg:id="Formatting" dlg:tab-index="20" dlg:left="80" dlg:top="150" dlg:width="170" dlg:height="12" dlg:spin="true">
|
||||
<dlg:menupopup>
|
||||
<dlg:menuitem dlg:value="Ignore all"/>
|
||||
<dlg:menuitem dlg:value="Ignore most"/>
|
||||
|
@ -47,6 +53,9 @@
|
|||
<dlg:menuitem dlg:value="Convert all"/>
|
||||
</dlg:menupopup>
|
||||
</dlg:menulist>
|
||||
<dlg:text dlg:id="FormattingLabel" dlg:tab-index="16" dlg:left="10" dlg:top="138" dlg:width="100" dlg:height="12" dlg:value="Other formatting"/>
|
||||
<dlg:text dlg:id="FormattingLabel" dlg:tab-index="19" dlg:left="10" dlg:top="152" dlg:width="65" dlg:height="12" dlg:value="Other formatting"/>
|
||||
<dlg:button dlg:id="LoadDefaults" dlg:tab-index="16" dlg:left="10" dlg:top="112" dlg:width="120" dlg:height="14" dlg:value="Load default mappings">
|
||||
<script:event script:event-name="on-mouseup" script:macro-name="vnd.sun.star.UNO:LoadDefaultsClick" script:language="UNO"/>
|
||||
</dlg:button>
|
||||
</dlg:bulletinboard>
|
||||
</dlg:window>
|
|
@ -13,4 +13,5 @@
|
|||
<library:element library:name="TextAndMath"/>
|
||||
<library:element library:name="NewDialog"/>
|
||||
<library:element library:name="Characters"/>
|
||||
<library:element library:name="LoadDefaults"/>
|
||||
</library:library>
|
8
source/oxt/writer4latex/W4LDialogs/AutoConfigInfo.xdl
Normal file
8
source/oxt/writer4latex/W4LDialogs/AutoConfigInfo.xdl
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE dlg:window PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "dialog.dtd">
|
||||
<dlg:window xmlns:dlg="http://openoffice.org/2000/dialog" xmlns:script="http://openoffice.org/2000/script" dlg:id="AutoConfigInfo" dlg:left="211" dlg:top="115" dlg:width="250" dlg:height="205" dlg:closeable="true" dlg:moveable="true" dlg:title="Automatic configuration">
|
||||
<dlg:bulletinboard>
|
||||
<dlg:textfield dlg:id="Info" dlg:tab-index="0" dlg:left="10" dlg:top="10" dlg:width="230" dlg:height="160" dlg:hscroll="true" dlg:vscroll="true" dlg:multiline="true" dlg:readonly="true"/>
|
||||
<dlg:button dlg:id="OKButton" dlg:tab-index="1" dlg:left="10" dlg:top="180" dlg:width="70" dlg:height="12" dlg:value="Close" dlg:button-type="ok"/>
|
||||
</dlg:bulletinboard>
|
||||
</dlg:window>
|
|
@ -3,4 +3,5 @@
|
|||
<library:library xmlns:library="http://openoffice.org/2000/library" library:name="W4LDialogs" library:readonly="false" library:passwordprotected="false">
|
||||
<library:element library:name="Configuration"/>
|
||||
<library:element library:name="LogViewer"/>
|
||||
<library:element library:name="AutoConfigInfo"/>
|
||||
</library:library>
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
<node oor:name="Filters">
|
||||
|
||||
<!-- Temp. disable TeX import for 1.1.1 alpha release
|
||||
<node oor:name="org.openoffice.da.writer4latex.latex" oor:op="replace" oor:finalized="true" oor:mandatory="true">
|
||||
<prop oor:name="UIName"><value>LaTeX</value></prop>
|
||||
<prop oor:name="Type"><value>org.openoffice.da.writer4latex.LaTeX_File</value></prop>
|
||||
|
@ -25,7 +26,7 @@
|
|||
<prop oor:name="UserData"/>
|
||||
<prop oor:name="FileFormatVersion"><value>0</value></prop>
|
||||
<prop oor:name="TemplateName"/>
|
||||
</node>
|
||||
</node>-->
|
||||
|
||||
</node>
|
||||
|
||||
|
|
|
@ -22,6 +22,20 @@ The source of Writer2LaTeX consists of three major parts:
|
|||
Currently parts of the source for Writer2LaTeX are somewhat messy and
|
||||
undocumented. This situation is improving from time to time :-)
|
||||
|
||||
Third-party software
|
||||
--------------------
|
||||
|
||||
Writer2LaTeX includes some classes from the OpenOffice.org project
|
||||
* com.sun.star.lib.loader.* are part of the SDK for OOo
|
||||
* writer2latex.xmerge.* contains some classes which are part of the xmerge
|
||||
project within OOo (some of the classes are slightly modified)
|
||||
See copyright notices within the source files
|
||||
|
||||
Also, the windows DLL file unowinreg.dll is part of the SDK for OOo,
|
||||
the source can be found at http://svn.services.openoffice.org/
|
||||
|
||||
Finally, writer2latex.util.Base64 is Harald Harders public domain Base64 class
|
||||
|
||||
|
||||
Building Writer2LaTeX
|
||||
---------------------
|
||||
|
@ -35,11 +49,10 @@ these are jurt.jar, unoil.jar, ridl.jar and juh.jar.
|
|||
To make these files available for the compiler, edit the file build.xml in
|
||||
the writer2latex09 directory as follows:
|
||||
|
||||
The line
|
||||
<property name="OFFICE_HOME" location=""/>
|
||||
should be edited to contain the path to your OOo installation, e.g.
|
||||
<property name="OFFICE_HOME" location="C:/Program Files/OpenOffice.org 2.0.4"/>
|
||||
|
||||
The lines
|
||||
<property name="OFFICE_HOME" location="/opt/openoffice.org/basis3.0" />
|
||||
<property name="URE_HOME" location="/opt/openoffice.org/ure" />
|
||||
should be modified to point to your OOo installation
|
||||
|
||||
To build, open a command shell, navigate to the writer2latex09 directory and type
|
||||
|
||||
|
@ -61,7 +74,7 @@ In addition to oxt, the build file supports the following targets:
|
|||
clean
|
||||
|
||||
|
||||
Henrik Just, September 2009
|
||||
Henrik Just, November 2009
|
||||
|
||||
|
||||
Thanks to Michael Niedermair for writing the original ant build file
|
||||
|
|
Loading…
Add table
Reference in a new issue