diff --git a/build.gradle b/build.gradle
index 5998bea..b3c710b 100644
--- a/build.gradle
+++ b/build.gradle
@@ -33,6 +33,7 @@ dependencies{
bundledLibs group: 'org.apache.jena', name: 'jena-arq', version: '3.15.0'
bundledLibs group: 'org.slf4j', name: 'slf4j-simple', version: '1.7.30'
bundledLibs group: 'com.opencsv', name: 'opencsv', version: '5.1'
+ bundledLibs group: 'com.miglayout', name: 'miglayout-swing', version: '5.2'
bundledLibs files('idl')
configurations.compile.extendsFrom(configurations.bundledLibs)
}
@@ -95,9 +96,9 @@ task xhtml2(type: Jar) {
}
baseName = "writer2phtml"
from {
- configurations.bundledLibs.collect {
+ configurations.bundledLibs.collect {
it.isDirectory() ? it : zipTree(it)
- }
+ }
}
from sourceSets.main.output
exclude '**/*Test.class'
@@ -148,8 +149,7 @@ task oxtNew(type: Zip){
exclude '.gradle'
from 'build/libs/writer2phtml.jar'
include '*'
- from 'src/main/idl/writer2xhtml'
- include 'writer2xhtml.rdb'
+ from 'idl/writer2paginatedhtml.rdb'
from 'releasenotes.txt'
include '*'
}
diff --git a/src/main/java/pro/litvinovg/w2phtml/ActionOneDialog.java b/src/main/java/pro/litvinovg/w2phtml/ActionOneDialog.java
new file mode 100644
index 0000000..90fcdc3
--- /dev/null
+++ b/src/main/java/pro/litvinovg/w2phtml/ActionOneDialog.java
@@ -0,0 +1,43 @@
+package pro.litvinovg.w2phtml;
+
+
+
+import com.sun.star.awt.XDialog;
+import com.sun.star.awt.XDialogEventHandler;
+import com.sun.star.lang.WrappedTargetException;
+import com.sun.star.uno.XComponentContext;
+
+
+public class ActionOneDialog implements XDialogEventHandler {
+
+ private XDialog dialog;
+ private static final String actionOk = "actionOk";
+ private String[] supportedActions = new String[] { actionOk };
+
+ public ActionOneDialog(XComponentContext xContext) {
+ this.dialog = DialogHelper.createDialog("ActionOneDialog.xdl", xContext, this);
+ }
+
+ public void show() {
+ dialog.execute();
+ }
+
+ private void onOkButtonPressed() {
+ dialog.endExecute();
+ }
+
+ @Override
+ public boolean callHandlerMethod(XDialog dialog, Object eventObject, String methodName) throws WrappedTargetException {
+ if (methodName.equals(actionOk)) {
+ onOkButtonPressed();
+ return true; // Event was handled
+ }
+ return false; // Event was not handled
+ }
+
+ @Override
+ public String[] getSupportedMethodNames() {
+ return supportedActions;
+ }
+
+}
diff --git a/src/main/java/pro/litvinovg/w2phtml/DialogHelper.java b/src/main/java/pro/litvinovg/w2phtml/DialogHelper.java
new file mode 100644
index 0000000..4f23274
--- /dev/null
+++ b/src/main/java/pro/litvinovg/w2phtml/DialogHelper.java
@@ -0,0 +1,185 @@
+package pro.litvinovg.w2phtml;
+
+
+import java.io.File;
+
+import com.sun.star.awt.MessageBoxType;
+import com.sun.star.awt.Point;
+import com.sun.star.awt.XButton;
+import com.sun.star.awt.XComboBox;
+import com.sun.star.awt.XControl;
+import com.sun.star.awt.XControlContainer;
+import com.sun.star.awt.XControlModel;
+import com.sun.star.awt.XDialog;
+import com.sun.star.awt.XDialogEventHandler;
+import com.sun.star.awt.XDialogProvider2;
+import com.sun.star.awt.XFixedText;
+import com.sun.star.awt.XListBox;
+import com.sun.star.awt.XMessageBox;
+import com.sun.star.awt.XMessageBoxFactory;
+import com.sun.star.awt.XTextComponent;
+import com.sun.star.awt.XToolkit;
+import com.sun.star.awt.XWindow;
+import com.sun.star.awt.XWindowPeer;
+import com.sun.star.beans.PropertyVetoException;
+import com.sun.star.beans.UnknownPropertyException;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.lang.WrappedTargetException;
+import com.sun.star.uno.Exception;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+
+public class DialogHelper {
+
+ /**
+ * Create a dialog from an xdl file.
+ *
+ * @param xdlFile
+ * The filename in the `dialog` folder
+ * @param context
+ * @return XDialog
+ */
+ public static XDialog createDialog(String xdlFile, XComponentContext context, XDialogEventHandler handler) {
+ Object oDialogProvider;
+ try {
+ oDialogProvider = context.getServiceManager().createInstanceWithContext("com.sun.star.awt.DialogProvider2",
+ context);
+ XDialogProvider2 xDialogProv = (XDialogProvider2) UnoRuntime.queryInterface(XDialogProvider2.class,
+ oDialogProvider);
+ File dialogFile = FileHelper.getDialogFilePath(xdlFile, context);
+ return xDialogProv.createDialogWithHandler(convertToURL(context, dialogFile), handler);
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+ /** Returns a URL to be used with XDialogProvider to create a dialog */
+ public static String convertToURL(XComponentContext xContext, File dialogFile) {
+ String sURL = null;
+ try {
+ com.sun.star.ucb.XFileIdentifierConverter xFileConverter = (com.sun.star.ucb.XFileIdentifierConverter) UnoRuntime
+ .queryInterface(com.sun.star.ucb.XFileIdentifierConverter.class, xContext.getServiceManager()
+ .createInstanceWithContext("com.sun.star.ucb.FileContentProvider", xContext));
+ sURL = xFileConverter.getFileURLFromSystemPath("", dialogFile.getAbsolutePath());
+ } catch (com.sun.star.uno.Exception ex) {
+ return null;
+ }
+ return sURL;
+ }
+
+ /** Returns a button (XButton) from a dialog */
+ public static XButton getButton(XDialog dialog, String componentId) {
+ XControlContainer xDlgContainer = (XControlContainer) UnoRuntime.queryInterface(XControlContainer.class,
+ dialog);
+ Object control = xDlgContainer.getControl(componentId);
+ return (XButton) UnoRuntime.queryInterface(XButton.class, control);
+ }
+
+ /** Returns a text field (XTextComponent) from a dialog */
+ public static XTextComponent getEditField(XDialog dialog, String componentId) {
+ XControlContainer xDlgContainer = (XControlContainer) UnoRuntime.queryInterface(XControlContainer.class,
+ dialog);
+ Object control = xDlgContainer.getControl(componentId);
+ return (XTextComponent) UnoRuntime.queryInterface(XTextComponent.class, control);
+ }
+
+ /** Returns a Combo box (XComboBox) from a dialog */
+ public static XComboBox getCombobox(XDialog dialog, String componentId) {
+ XControlContainer xDlgContainer = (XControlContainer) UnoRuntime.queryInterface(XControlContainer.class,
+ dialog);
+ Object control = xDlgContainer.getControl(componentId);
+ return (XComboBox) UnoRuntime.queryInterface(XComboBox.class, control);
+ }
+
+ /** Returns a List box (XListBox) from a dialog */
+ public static XListBox getListBox(XDialog dialog, String componentId) {
+ XControlContainer xDlgContainer = (XControlContainer) UnoRuntime.queryInterface(XControlContainer.class,
+ dialog);
+ Object control = xDlgContainer.getControl(componentId);
+ return (XListBox) UnoRuntime.queryInterface(XListBox.class, control);
+ }
+
+ /** Returns a label (XFixedText) from a dialog */
+ public static XFixedText getLabel(XDialog dialog, String componentId) {
+ XControlContainer xDlgContainer = (XControlContainer) UnoRuntime.queryInterface(XControlContainer.class,
+ dialog);
+ Object control = xDlgContainer.getControl(componentId);
+ return (XFixedText) UnoRuntime.queryInterface(XFixedText.class, control);
+ }
+
+ public static void EnableButton(XDialog dialog, String componentId, boolean enable) {
+ XControlContainer xDlgContainer = (XControlContainer) UnoRuntime.queryInterface(XControlContainer.class,
+ dialog);
+ // retrieve the control that we want to disable or enable
+ XControl xControl = UnoRuntime.queryInterface(XControl.class, xDlgContainer.getControl(componentId));
+ XPropertySet xModelPropertySet = UnoRuntime.queryInterface(XPropertySet.class, xControl.getModel());
+ try {
+ xModelPropertySet.setPropertyValue("Enabled", Boolean.valueOf(enable));
+ } catch (IllegalArgumentException | UnknownPropertyException | PropertyVetoException
+ | WrappedTargetException e) {
+ return;
+ }
+ }
+
+ /** Set the focus to an input field */
+ public static void SetFocus(XTextComponent editField) {
+ XWindow xControlWindow = UnoRuntime.queryInterface(XWindow.class, editField);
+ xControlWindow.setFocus();
+ }
+
+ public static void setPosition(XDialog dialog, int posX, int posY) {
+ XControlModel xDialogModel = UnoRuntime.queryInterface(XControl.class, dialog).getModel();
+ XPropertySet xPropSet = UnoRuntime.queryInterface(XPropertySet.class, xDialogModel);
+ try {
+ xPropSet.setPropertyValue("PositionX", posX);
+ xPropSet.setPropertyValue("PositionY", posY);
+ } catch (com.sun.star.lang.IllegalArgumentException | UnknownPropertyException | PropertyVetoException
+ | WrappedTargetException e) {
+ return;
+ }
+ }
+
+ public static Point getPosition(XDialog dialog) {
+ int posX = 0;
+ int posY = 0;
+ XControlModel xDialogModel = UnoRuntime.queryInterface(XControl.class, dialog).getModel();
+ XPropertySet xPropSet = UnoRuntime.queryInterface(XPropertySet.class, xDialogModel);
+ try {
+ posX = (int) xPropSet.getPropertyValue("PositionX");
+ posY = (int) xPropSet.getPropertyValue("PositionY");
+ } catch (UnknownPropertyException | WrappedTargetException e) {
+ }
+ return new Point(posX, posY);
+ }
+
+ public static void showInfoMessage(XComponentContext context, XDialog dialog, String message) {
+ showMessageBox(context, dialog, MessageBoxType.INFOBOX, "Info", message);
+ }
+
+ public static void showWarningMessage(XComponentContext context, XDialog dialog, String message) {
+ showMessageBox(context, dialog, MessageBoxType.WARNINGBOX, "Warnung", message);
+ }
+
+ public static void showErrorMessage(XComponentContext context, XDialog dialog, String message) {
+ showMessageBox(context, dialog, MessageBoxType.ERRORBOX, "Fehler", message);
+ }
+
+ public static void showMessageBox(XComponentContext context, XDialog dialog, MessageBoxType type, String sTitle, String sMessage) {
+ XToolkit xToolkit;
+ try {
+ xToolkit = UnoRuntime.queryInterface(XToolkit.class,
+ context.getServiceManager().createInstanceWithContext("com.sun.star.awt.Toolkit", context));
+ } catch (Exception e) {
+ return;
+ }
+ XMessageBoxFactory xMessageBoxFactory = UnoRuntime.queryInterface(XMessageBoxFactory.class, xToolkit);
+ XWindowPeer xParentWindowPeer = UnoRuntime.queryInterface(XWindowPeer.class, dialog);
+ XMessageBox xMessageBox = xMessageBoxFactory.createMessageBox(xParentWindowPeer, type,
+ com.sun.star.awt.MessageBoxButtons.BUTTONS_OK, sTitle, sMessage);
+ if (xMessageBox == null)
+ return;
+
+ xMessageBox.execute();
+ }
+
+}
diff --git a/src/main/java/pro/litvinovg/w2phtml/FileHelper.java b/src/main/java/pro/litvinovg/w2phtml/FileHelper.java
new file mode 100644
index 0000000..24e959e
--- /dev/null
+++ b/src/main/java/pro/litvinovg/w2phtml/FileHelper.java
@@ -0,0 +1,60 @@
+package pro.litvinovg.w2phtml;
+
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URISyntaxException;
+import java.net.URL;
+
+import com.sun.star.deployment.PackageInformationProvider;
+import com.sun.star.deployment.XPackageInformationProvider;
+import com.sun.star.uno.Exception;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.util.XURLTransformer;
+
+public class FileHelper {
+
+ final static String DIALOG_RESOURCES = "dialog/";
+
+ /**
+ * Returns a path to a dialog file
+ */
+ public static File getDialogFilePath(String xdlFile, XComponentContext xContext) {
+ return getFilePath(DIALOG_RESOURCES + xdlFile, xContext);
+ }
+
+ /**
+ * Returns a file path for a file in the installed extension, or null on failure.
+ */
+ public static File getFilePath(String file, XComponentContext xContext) {
+ XPackageInformationProvider xPackageInformationProvider = PackageInformationProvider.get(xContext);
+ String location = xPackageInformationProvider.getPackageLocation("org.libreoffice.example.starterproject");
+ Object oTransformer;
+ try {
+ oTransformer = xContext.getServiceManager().createInstanceWithContext("com.sun.star.util.URLTransformer", xContext);
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ }
+ XURLTransformer xTransformer = (XURLTransformer)UnoRuntime.queryInterface(XURLTransformer.class, oTransformer);
+ com.sun.star.util.URL[] oURL = new com.sun.star.util.URL[1];
+ oURL[0] = new com.sun.star.util.URL();
+ oURL[0].Complete = location + "/" + file;
+ xTransformer.parseStrict(oURL);
+ URL url;
+ try {
+ url = new URL(oURL[0].Complete);
+ } catch (MalformedURLException e1) {
+ return null;
+ }
+ File f;
+ try {
+ f = new File(url.toURI());
+ } catch (URISyntaxException e1) {
+ return null;
+ }
+ return f;
+ }
+
+}
diff --git a/src/main/java/pro/litvinovg/w2phtml/W2PHTMLExtension.java b/src/main/java/pro/litvinovg/w2phtml/W2PHTMLExtension.java
index a9a86c1..f846643 100644
--- a/src/main/java/pro/litvinovg/w2phtml/W2PHTMLExtension.java
+++ b/src/main/java/pro/litvinovg/w2phtml/W2PHTMLExtension.java
@@ -36,7 +36,7 @@ public final class W2PHTMLExtension extends WeakBase
private XDocumentProperties documentProperties;
private XDocumentPropertiesSupplier documentPropertiesSupplier;
private static final String m_implementationName = W2PHTMLExtension.class.getName();
- private static final String[] m_serviceNames = { "pro.litvinovg.writer2paginatedhtml" };
+ private static final String[] m_serviceNames = { "pro.litvinovg.libreoffice.Writer2PaginatedHTML" };
public W2PHTMLExtension(XComponentContext componentContext) {
@@ -84,7 +84,12 @@ public final class W2PHTMLExtension extends WeakBase
case "openGUI":
ConfigurationWindow.runGUI();
break;
+ //case "actionOne":
+ // ActionOneDialog actionOneDialog = new ActionOneDialog(context);
+ // actionOneDialog.show();
+ // break;
default:
+ DialogHelper.showErrorMessage(context, null, "Unknown action: " + action);
}
}
diff --git a/src/main/java/pro/litvinovg/w2phtml/gui/ConfigurationWindow.java b/src/main/java/pro/litvinovg/w2phtml/gui/ConfigurationWindow.java
index d5f9f59..68b69c6 100644
--- a/src/main/java/pro/litvinovg/w2phtml/gui/ConfigurationWindow.java
+++ b/src/main/java/pro/litvinovg/w2phtml/gui/ConfigurationWindow.java
@@ -13,7 +13,6 @@ import javax.swing.JPanel;
public class ConfigurationWindow extends JFrame {
- private JFrame frame;
private static JFrame singleFrame = null;
diff --git a/src/main/oxt2/META-INF/manifest.xml b/src/main/oxt2/META-INF/manifest.xml
index 8b3bff3..91671a5 100644
--- a/src/main/oxt2/META-INF/manifest.xml
+++ b/src/main/oxt2/META-INF/manifest.xml
@@ -1,8 +1,8 @@
-
+
-
+
diff --git a/src/main/oxt2/description.xml b/src/main/oxt2/description.xml
index fd0025e..b6d973e 100644
--- a/src/main/oxt2/description.xml
+++ b/src/main/oxt2/description.xml
@@ -4,7 +4,9 @@
-
+
+
+
diff --git a/src/main/oxt2/description/desc_en.txt b/src/main/oxt2/description/desc_en.txt
new file mode 100644
index 0000000..c39c994
--- /dev/null
+++ b/src/main/oxt2/description/desc_en.txt
@@ -0,0 +1 @@
+Converter from ODT to HTML, EPUB, RDF with pagination
diff --git a/src/main/oxt2/miglayout15-swing.jar b/src/main/oxt2/miglayout15-swing.jar
new file mode 100644
index 0000000..6247241
Binary files /dev/null and b/src/main/oxt2/miglayout15-swing.jar differ
diff --git a/src/main/oxt2/registry/org/openoffice/Office/Addons.xcu b/src/main/oxt2/registry/org/openoffice/Office/Addons.xcu
index 8b6fb96..aad47c4 100644
--- a/src/main/oxt2/registry/org/openoffice/Office/Addons.xcu
+++ b/src/main/oxt2/registry/org/openoffice/Office/Addons.xcu
@@ -4,27 +4,27 @@
-
+
- service:pro.litvinovg.libreoffice.MetadataEditor?openGUI
+ service:pro.litvinovg.libreoffice.Writer2PaginatedHTML?openGUI
- vnd.sun.star.extension://pro.litvinovg.writer2paginatedhtml/icons/w2phtml.png
+ vnd.sun.star.extension://pro.litvinovg.writer2paginatedhtml2/images/w2phtml.png
-
+
Writer to paginated HTML converter panel
true
- service:pro.litvinovg.libreoffice.MetadataEditor?openGUI
+ service:pro.litvinovg.libreoffice.Writer2PaginatedHTML?openGUI
_self