From 8e07ca2338c3b6bde2ca57260a5ef59efe9a0119 Mon Sep 17 00:00:00 2001 From: henrikjust Date: Tue, 14 Jun 2011 18:11:30 +0000 Subject: [PATCH] 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 --- source/distro/changelog.txt | 2 + .../da/comp/w2lcommon/helper/FilePicker.java | 68 +++++++++++++++---- .../writer2xhtml/ConfigurationDialog.java | 60 ++++++++-------- .../writer2latex/api/ConverterFactory.java | 4 +- .../writer2latex/xhtml/DrawConverter.java | 5 +- .../Configuration/Stylesheets.xhp | 3 +- 6 files changed, 97 insertions(+), 45 deletions(-) diff --git a/source/distro/changelog.txt b/source/distro/changelog.txt index 0835c1c..68d773f 100644 --- a/source/distro/changelog.txt +++ b/source/distro/changelog.txt @@ -2,6 +2,8 @@ Changelog for Writer2LaTeX version 1.0 -> 1.2 ---------- 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 - using the readResource method of the converter API - using the -resource method of the command line application diff --git a/source/java/org/openoffice/da/comp/w2lcommon/helper/FilePicker.java b/source/java/org/openoffice/da/comp/w2lcommon/helper/FilePicker.java index febe45b..42fd0c3 100644 --- a/source/java/org/openoffice/da/comp/w2lcommon/helper/FilePicker.java +++ b/source/java/org/openoffice/da/comp/w2lcommon/helper/FilePicker.java @@ -16,16 +16,17 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA * - * Copyright: 2002-2010 by Henrik Just + * Copyright: 2002-2011 by Henrik Just * * All Rights Reserved. * - * Version 1.2 (2010-04-12) + * Version 1.2 (2010-06-11) * */ package org.openoffice.da.comp.w2lcommon.helper; +import com.sun.star.lang.IllegalArgumentException; import com.sun.star.lang.XComponent; import com.sun.star.ui.dialogs.ExecutableDialogResults; import com.sun.star.ui.dialogs.XExecutableDialog; @@ -35,7 +36,10 @@ import com.sun.star.uno.XComponentContext; 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 * @@ -43,41 +47,81 @@ public class FilePicker { */ public FilePicker(XComponentContext 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 * - * @return the path or null if the dialog is canceled + * @return the path URL or null if the dialog is canceled */ 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 Object filePicker = null; try { + // Note: Could be changed for OfficeFilePicker to always use internal file pickers filePicker = xContext.getServiceManager().createInstanceWithContext("com.sun.star.ui.dialogs.FilePicker", xContext); } catch (com.sun.star.uno.Exception e) { return null; } - // Display the FilePicker + // Get the required interfaces XFilePicker xFilePicker = (XFilePicker) UnoRuntime.queryInterface(XFilePicker.class, filePicker); 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) { + sDirectoryURL = xFilePicker.getDisplayDirectory(); String[] sPathList = xFilePicker.getFiles(); - if (sPathList.length > 0) { - sPath = sPathList[0]; - } + int nCount = sPathList.length; + 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 diff --git a/source/java/writer2latex/xhtml/DrawConverter.java b/source/java/writer2latex/xhtml/DrawConverter.java index c4ba04f..79940f5 100644 --- a/source/java/writer2latex/xhtml/DrawConverter.java +++ b/source/java/writer2latex/xhtml/DrawConverter.java @@ -20,7 +20,7 @@ * * 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 frames = new Vector(); // This flag determines whether to collect frames or insert them immediately private boolean bCollectFrames = false; + + // Large images (for full screen) in EPUB export are collected here + private Vector fullscreenFrames = new Vector(); public DrawConverter(OfficeReader ofr, XhtmlConfig config, Converter converter) { super(ofr,config,converter); diff --git a/source/oxt/writer2xhtml/help/en/org.openoffice.da.writer2xhtml.oxt/Configuration/Stylesheets.xhp b/source/oxt/writer2xhtml/help/en/org.openoffice.da.writer2xhtml.oxt/Configuration/Stylesheets.xhp index a9b4a0f..8cf4613 100644 --- a/source/oxt/writer2xhtml/help/en/org.openoffice.da.writer2xhtml.oxt/Configuration/Stylesheets.xhp +++ b/source/oxt/writer2xhtml/help/en/org.openoffice.da.writer2xhtml.oxt/Configuration/Stylesheets.xhp @@ -56,7 +56,8 @@ New... Click this to add a new resource file to the list. Select the file and press - Open. This will create a copy of the original file. If you change, move or delete the original file, nothing + Open (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 this button again.