Support the FilterOptions property as an alternative to FilterData

git-svn-id: svn://svn.code.sf.net/p/writer2latex/code/trunk@242 f0f2a975-2e09-46c8-9428-3b39399b9f3c
This commit is contained in:
henrikjust 2015-05-06 20:27:17 +00:00
parent 230e93587d
commit 7ee1e36f2f
4 changed files with 54 additions and 10 deletions

View file

@ -4,6 +4,12 @@ Changelog for Writer2LaTeX version 1.4 -> 1.6
Items marked with * are work in progress
[all] Using the filters from the command line with soffice --headless --convert-to is now documented in the user manual
[all] Filter API change: The filters now accepts the FilterOptions property as an alternative to FilterData.
This property accepts a comma separated string of option=value items. In particular this allows to pass option
from the command line (soffice --headless --convert-to).
[all] API change: The interface OutputFile now defines an additional method containsMath() which returns true if the file
contains mathematical formulas (only implemented for XHTML, currently always returns true for LaTeX)
@ -18,8 +24,6 @@ Items marked with * are work in progress
[all] Implementation detail: Moved descriptions to a separate folder within the extensions
[all] *Document the use of soffice --headless --convert-to
[all] The position of message boxes has changed from (0,0) to (200,100)
[w2l] Implementation detail: The dialog library W4LDialogs is now merged into W2LDialogs2. This avoids conflicts with

Binary file not shown.

View file

@ -16,11 +16,11 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
* Copyright: 2002-2011 by Henrik Just
* Copyright: 2002-2015 by Henrik Just
*
* All Rights Reserved.
*
* Version 1.2 (2011-06-07)
* Version 1.6 (2015-05-06)
*
*/
@ -88,8 +88,35 @@ public class FilterDataParser {
}
}
/** Apply the given FilterData property to the given converter
* @param data an Any containing the FilterData property
/** Apply the given FilterOptions property to the given converter.
* The property must be a comma separated list of name=value items.
* @param options an <code>Any</code> containing the FilterOptions property
* @param converter a <code>writer2latex.api.Converter</code> implementation
*/
public void applyFilterOptions(Object options, Converter converter) {
// Get the string from the data, if possible
if (AnyConverter.isString(options)) {
String sOptions = AnyConverter.toString(options);
if (sOptions!=null) {
// Convert to array
String[] sItems = sOptions.split(",");
int nItemCount = sItems.length;
PropertyValue[] filterData = new PropertyValue[nItemCount];
for (int i=0; i<nItemCount; i++) {
String[] sItem = sItems[i].split("=");
filterData[i] = new PropertyValue();
filterData[i].Name = sItem[0];
filterData[i].Value = sItem.length>1 ? sItem[1] : "";
System.out.println(filterData[i].Name+" "+filterData[i].Value);
}
applyParsedFilterData(filterData,converter);
}
}
}
/** Apply the given FilterData property to the given converter.
* The property must be an array of PropertyValue objects.
* @param data an <code>Any</code> containing the FilterData property
* @param converter a <code>writer2latex.api.Converter</code> implementation
*/
public void applyFilterData(Object data, Converter converter) {
@ -100,14 +127,18 @@ public class FilterDataParser {
Object[] arrayData = (Object[]) AnyConverter.toArray(data);
if (arrayData instanceof PropertyValue[]) {
filterData = (PropertyValue[]) arrayData;
if (filterData!=null) {
applyParsedFilterData(filterData,converter);
}
}
}
catch (com.sun.star.lang.IllegalArgumentException e) {
// Failed to convert to array; should not happen - ignore
}
}
if (filterData==null) { return; }
}
private void applyParsedFilterData(PropertyValue[] filterData, Converter converter) {
PropertyHelper props = new PropertyHelper(filterData);
// Get the special properties TemplateURL, StyleSheetURL, ResourceURL, Resources, ConfigURL and AutoCreate

View file

@ -20,7 +20,7 @@
*
* All Rights Reserved.
*
* Version 1.6 (2015-01-13)
* Version 1.6 (2015-05-06)
*
*/
package org.openoffice.da.comp.w2lcommon.filter;
@ -65,7 +65,8 @@ public class UNOConverter {
/** Construct a new UNODocumentConverter from an array of arguments
*
* @param xComponentContext the component context used to instantiate new UNO services
* @param lArguments arguments providing FilterName, URL, OutputStream (optional) and FilterData (optional)
* @param lArguments arguments providing FilterName, URL, OutputStream (optional), FilterData (optional)
* and FilterOptions (optional, alternative to FilterData)
*/
public UNOConverter(PropertyValue[] lArguments, XComponentContext xComponentContext) {
this.xComponentContext = xComponentContext;
@ -86,6 +87,7 @@ public class UNOConverter {
// Get the arguments
Object filterData = null;
Object filterOptions = null;
PropertyValue[] pValue = lArguments;
for (int i = 0 ; i < pValue.length; i++) {
try {
@ -107,6 +109,9 @@ public class UNOConverter {
if (pValue[i].Name.compareTo("FilterData")==0) {
filterData = pValue[i].Value;
}
if (pValue[i].Name.compareTo("FilterOptions")==0) {
filterOptions = pValue[i].Value;
}
}
catch(com.sun.star.lang.IllegalArgumentException AnyExec){
System.err.println("\nIllegalArgumentException "+AnyExec);
@ -125,6 +130,10 @@ public class UNOConverter {
FilterDataParser fdp = new FilterDataParser(xComponentContext);
fdp.applyFilterData(filterData,converter);
}
else if (filterOptions!=null) {
FilterDataParser fdp = new FilterDataParser(xComponentContext);
fdp.applyFilterOptions(filterOptions,converter);
}
converter.setGraphicConverter(new GraphicConverterImpl(xComponentContext));
}