Support EPUB style resources - a few bugfixes and improvements
git-svn-id: svn://svn.code.sf.net/p/writer2latex/code/trunk@109 f0f2a975-2e09-46c8-9428-3b39399b9f3c
This commit is contained in:
parent
ef05312e21
commit
8e07ca2338
6 changed files with 97 additions and 45 deletions
|
@ -2,6 +2,8 @@ Changelog for Writer2LaTeX version 1.0 -> 1.2
|
||||||
|
|
||||||
---------- version 1.1.8 ----------
|
---------- version 1.1.8 ----------
|
||||||
|
|
||||||
|
[w2x] In EPUB export, a large image is now automatically placed in a separate file as a full screen image
|
||||||
|
|
||||||
[w2x] The EPUB export now supports additional resource files (e.g. images, fonts) to the custom style sheet
|
[w2x] The EPUB export now supports additional resource files (e.g. images, fonts) to the custom style sheet
|
||||||
- using the readResource method of the converter API
|
- using the readResource method of the converter API
|
||||||
- using the -resource method of the command line application
|
- using the -resource method of the command line application
|
||||||
|
|
|
@ -16,16 +16,17 @@
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||||
* MA 02111-1307 USA
|
* MA 02111-1307 USA
|
||||||
*
|
*
|
||||||
* Copyright: 2002-2010 by Henrik Just
|
* Copyright: 2002-2011 by Henrik Just
|
||||||
*
|
*
|
||||||
* All Rights Reserved.
|
* All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Version 1.2 (2010-04-12)
|
* Version 1.2 (2010-06-11)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.openoffice.da.comp.w2lcommon.helper;
|
package org.openoffice.da.comp.w2lcommon.helper;
|
||||||
|
|
||||||
|
import com.sun.star.lang.IllegalArgumentException;
|
||||||
import com.sun.star.lang.XComponent;
|
import com.sun.star.lang.XComponent;
|
||||||
import com.sun.star.ui.dialogs.ExecutableDialogResults;
|
import com.sun.star.ui.dialogs.ExecutableDialogResults;
|
||||||
import com.sun.star.ui.dialogs.XExecutableDialog;
|
import com.sun.star.ui.dialogs.XExecutableDialog;
|
||||||
|
@ -35,7 +36,10 @@ import com.sun.star.uno.XComponentContext;
|
||||||
|
|
||||||
public class FilePicker {
|
public class FilePicker {
|
||||||
|
|
||||||
private XComponentContext xContext;
|
private XComponentContext xContext;
|
||||||
|
|
||||||
|
// The default directory for the dialog
|
||||||
|
private String sDirectoryURL;
|
||||||
|
|
||||||
/** Convenience wrapper class for the UNO file picker service
|
/** Convenience wrapper class for the UNO file picker service
|
||||||
*
|
*
|
||||||
|
@ -43,41 +47,81 @@ public class FilePicker {
|
||||||
*/
|
*/
|
||||||
public FilePicker(XComponentContext xContext) {
|
public FilePicker(XComponentContext xContext) {
|
||||||
this.xContext = xContext;
|
this.xContext = xContext;
|
||||||
|
sDirectoryURL = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Get one or more user selected paths with a file picker
|
||||||
|
*
|
||||||
|
* Warning: This does not work on all platforms when using native file pickers
|
||||||
|
* (but always when using Office file pickers)
|
||||||
|
*
|
||||||
|
* @return array containing the path URLs or null if the dialog is canceled
|
||||||
|
*/
|
||||||
|
public String[] getPaths() {
|
||||||
|
return getPaths(true);
|
||||||
|
}
|
||||||
|
|
||||||
/** Get a user selected path with a file picker
|
/** Get a user selected path with a file picker
|
||||||
*
|
*
|
||||||
* @return the path or null if the dialog is canceled
|
* @return the path URL or null if the dialog is canceled
|
||||||
*/
|
*/
|
||||||
public String getPath() {
|
public String getPath() {
|
||||||
|
String[] sPaths = getPaths(false);
|
||||||
|
if (sPaths!=null && sPaths.length>0) {
|
||||||
|
return sPaths[0];
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String[] getPaths(boolean bAllowMultiSelection) {
|
||||||
// Create FilePicker
|
// Create FilePicker
|
||||||
Object filePicker = null;
|
Object filePicker = null;
|
||||||
try {
|
try {
|
||||||
|
// Note: Could be changed for OfficeFilePicker to always use internal file pickers
|
||||||
filePicker = xContext.getServiceManager().createInstanceWithContext("com.sun.star.ui.dialogs.FilePicker", xContext);
|
filePicker = xContext.getServiceManager().createInstanceWithContext("com.sun.star.ui.dialogs.FilePicker", xContext);
|
||||||
}
|
}
|
||||||
catch (com.sun.star.uno.Exception e) {
|
catch (com.sun.star.uno.Exception e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Display the FilePicker
|
// Get the required interfaces
|
||||||
XFilePicker xFilePicker = (XFilePicker) UnoRuntime.queryInterface(XFilePicker.class, filePicker);
|
XFilePicker xFilePicker = (XFilePicker) UnoRuntime.queryInterface(XFilePicker.class, filePicker);
|
||||||
XExecutableDialog xExecutable = (XExecutableDialog) UnoRuntime.queryInterface(XExecutableDialog.class, xFilePicker);
|
XExecutableDialog xExecutable = (XExecutableDialog) UnoRuntime.queryInterface(XExecutableDialog.class, xFilePicker);
|
||||||
|
|
||||||
// Get the path
|
|
||||||
String sPath = null;
|
|
||||||
|
|
||||||
|
// Configure the file picker
|
||||||
|
xFilePicker.setMultiSelectionMode(bAllowMultiSelection);
|
||||||
|
if (sDirectoryURL!=null) {
|
||||||
|
try {
|
||||||
|
xFilePicker.setDisplayDirectory(sDirectoryURL);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the paths
|
||||||
|
String[] sPaths = null;
|
||||||
if (xExecutable.execute() == ExecutableDialogResults.OK) {
|
if (xExecutable.execute() == ExecutableDialogResults.OK) {
|
||||||
|
sDirectoryURL = xFilePicker.getDisplayDirectory();
|
||||||
String[] sPathList = xFilePicker.getFiles();
|
String[] sPathList = xFilePicker.getFiles();
|
||||||
if (sPathList.length > 0) {
|
int nCount = sPathList.length;
|
||||||
sPath = sPathList[0];
|
if (nCount>1) {
|
||||||
}
|
// According to the spec, the first entry is the path and remaining entries are file names
|
||||||
|
sPaths = new String[nCount-1];
|
||||||
|
for (int i=1; i<nCount; i++) {
|
||||||
|
sPaths[i-1]=sPathList[0] + sPathList[i];
|
||||||
|
System.out.println("File "+sPaths[i-1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (nCount==1) {
|
||||||
|
sPaths = sPathList;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dispose the file picker
|
// Dispose the file picker
|
||||||
XComponent xComponent = (XComponent) UnoRuntime.queryInterface(XComponent.class, xFilePicker);
|
XComponent xComponent = (XComponent) UnoRuntime.queryInterface(XComponent.class, xFilePicker);
|
||||||
xComponent.dispose();
|
xComponent.dispose();
|
||||||
|
|
||||||
return sPath;
|
return sPaths;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
*
|
*
|
||||||
* All Rights Reserved.
|
* All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Version 1.2 (2011-06-06)
|
* Version 1.2 (2011-06-11)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -266,22 +266,23 @@ public class ConfigurationDialog extends ConfigurationDialogBase implements XSer
|
||||||
}
|
}
|
||||||
|
|
||||||
private void newResourceClick(DialogAccess dlg) {
|
private void newResourceClick(DialogAccess dlg) {
|
||||||
FilePicker filePicker = new FilePicker(xContext);
|
String[] sFileNames=filePicker.getPaths();
|
||||||
String sFileName=filePicker.getPath();
|
if (sFileNames!=null) {
|
||||||
if (sFileName!=null) {
|
createResourceDir();
|
||||||
createResourceDir();
|
for (String sFileName : sFileNames) {
|
||||||
String sBaseFileName = sFileName.substring(sFileName.lastIndexOf('/'));
|
String sBaseFileName = sFileName.substring(sFileName.lastIndexOf('/')+1);
|
||||||
try {
|
try {
|
||||||
String sTargetFileName = sResourceDirName+"/"+sBaseFileName;
|
String sTargetFileName = sResourceDirName+"/"+sBaseFileName;
|
||||||
if (fileExists(sTargetFileName)) { killFile(sTargetFileName); }
|
if (fileExists(sTargetFileName)) { killFile(sTargetFileName); }
|
||||||
sfa2.copy(sFileName, sTargetFileName);
|
sfa2.copy(sFileName, sTargetFileName);
|
||||||
} catch (CommandAbortedException e) {
|
} catch (CommandAbortedException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
updateResources(dlg);
|
}
|
||||||
}
|
updateResources(dlg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deleteResourceClick(DialogAccess dlg) {
|
private void deleteResourceClick(DialogAccess dlg) {
|
||||||
|
@ -295,19 +296,8 @@ public class ConfigurationDialog extends ConfigurationDialogBase implements XSer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createResourceDir() {
|
|
||||||
try {
|
|
||||||
if (!sfa2.isFolder(sResourceDirName)) {
|
|
||||||
sfa2.createFolder(sResourceDirName);
|
|
||||||
}
|
|
||||||
} catch (CommandAbortedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateResources(DialogAccess dlg) {
|
private void updateResources(DialogAccess dlg) {
|
||||||
|
createResourceDir();
|
||||||
try {
|
try {
|
||||||
String[] sFiles = sfa2.getFolderContents(sResourceDirName, false); // do not include folders
|
String[] sFiles = sfa2.getFolderContents(sResourceDirName, false); // do not include folders
|
||||||
int nCount = sFiles.length;
|
int nCount = sFiles.length;
|
||||||
|
@ -322,6 +312,18 @@ public class ConfigurationDialog extends ConfigurationDialogBase implements XSer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void createResourceDir() {
|
||||||
|
try {
|
||||||
|
if (!sfa2.isFolder(sResourceDirName)) {
|
||||||
|
sfa2.createFolder(sResourceDirName);
|
||||||
|
}
|
||||||
|
} catch (CommandAbortedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class Styles1Handler extends StylesPageHandler {
|
private class Styles1Handler extends StylesPageHandler {
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
*
|
*
|
||||||
* All Rights Reserved.
|
* All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Version 1.2 (2011-06-07)
|
* Version 1.2 (2011-06-11)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ public class ConverterFactory {
|
||||||
|
|
||||||
// Version information
|
// Version information
|
||||||
private static final String VERSION = "1.1.8";
|
private static final String VERSION = "1.1.8";
|
||||||
private static final String DATE = "2011-06-07";
|
private static final String DATE = "2011-06-11";
|
||||||
|
|
||||||
/** Return the Writer2LaTeX version in the form
|
/** Return the Writer2LaTeX version in the form
|
||||||
* (major version).(minor version).(patch level)<br/>
|
* (major version).(minor version).(patch level)<br/>
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
*
|
*
|
||||||
* All Rights Reserved.
|
* All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Version 1.2 (2011-03-29)
|
* Version 1.2 (2011-06-08)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -97,6 +97,9 @@ public class DrawConverter extends ConverterHelper {
|
||||||
private Vector<Element> frames = new Vector<Element>();
|
private Vector<Element> frames = new Vector<Element>();
|
||||||
// This flag determines whether to collect frames or insert them immediately
|
// This flag determines whether to collect frames or insert them immediately
|
||||||
private boolean bCollectFrames = false;
|
private boolean bCollectFrames = false;
|
||||||
|
|
||||||
|
// Large images (for full screen) in EPUB export are collected here
|
||||||
|
private Vector<Element> fullscreenFrames = new Vector<Element>();
|
||||||
|
|
||||||
public DrawConverter(OfficeReader ofr, XhtmlConfig config, Converter converter) {
|
public DrawConverter(OfficeReader ofr, XhtmlConfig config, Converter converter) {
|
||||||
super(ofr,config,converter);
|
super(ofr,config,converter);
|
||||||
|
|
|
@ -56,7 +56,8 @@
|
||||||
<bookmark xml-lang="en-US" branch="hid/org.openoffice.da.writer2xhtml.oxt:NewResource" id="bm_newresource"/>
|
<bookmark xml-lang="en-US" branch="hid/org.openoffice.da.writer2xhtml.oxt:NewResource" id="bm_newresource"/>
|
||||||
<paragraph role="heading" level="3" xml-lang="en-US">New...</paragraph>
|
<paragraph role="heading" level="3" xml-lang="en-US">New...</paragraph>
|
||||||
<paragraph role="paragraph" xml-lang="en-US">Click this to add a new resource file to the list. Select the file and press
|
<paragraph role="paragraph" xml-lang="en-US">Click this to add a new resource file to the list. Select the file and press
|
||||||
<emph>Open</emph>. This will create a copy of the original file. If you change, move or delete the original file, nothing
|
<emph>Open</emph> (On some systems you can select more than one file).
|
||||||
|
This will create a copy of the original file. If you change, move or delete the original file, nothing
|
||||||
will happen to the resource file. If you want to update the resource file with a new version of the original file, click
|
will happen to the resource file. If you want to update the resource file with a new version of the original file, click
|
||||||
this button again.</paragraph>
|
this button again.</paragraph>
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue