diff --git a/source/java/org/openoffice/da/comp/writer4latex/LaTeXImporter.java b/source/java/org/openoffice/da/comp/writer4latex/LaTeXImporter.java
deleted file mode 100644
index c3c601a..0000000
--- a/source/java/org/openoffice/da/comp/writer4latex/LaTeXImporter.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/************************************************************************
- *
- * LaTeXImporter.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-05-01)
- *
- */
-
-package org.openoffice.da.comp.writer4latex;
-
-import java.io.File;
-import java.net.URI;
-
-import com.sun.star.beans.PropertyValue;
-import com.sun.star.frame.XComponentLoader;
-import com.sun.star.uno.UnoRuntime;
-import com.sun.star.uno.XComponentContext;
-
-public class LaTeXImporter {
-
- private XComponentContext xContext;
-
- private ExternalApps externalApps;
-
- public LaTeXImporter(XComponentContext xContext) {
- this.xContext = xContext;
- externalApps = new ExternalApps(xContext);
- externalApps.load();
- }
-
- public void importLaTeX(String sURL) {
- // Get the LaTeX file
- File file = null;
- try {
- file = new File(new URI(sURL));
- }
- catch (java.net.URISyntaxException e) {
- // Could not use the URL provided
- return;
- }
-
- // Protect the ODT file if it already exists
- String sBaseName = file.getName();
- if (sBaseName.endsWith(".tex")) { sBaseName = sBaseName.substring(0, sBaseName.length()-4); }
- File odtFile = new File(file.getParentFile(),sBaseName+".odt");
- File tempFile = null;
- if (odtFile.exists()) {
- try {
- tempFile = File.createTempFile("w4l", ".tmp", file.getParentFile());
- }
- catch (java.io.IOException e) {
- // Failed to protect the ODT file, give up
- return;
- }
- odtFile.renameTo(tempFile);
- }
-
- externalApps.execute(ExternalApps.MK4HT, file.getName(), file.getParentFile(), true);
-
- // Assemble the URL of the ODT file
- String sODTURL = sURL;
- if (sODTURL.endsWith(".tex")) { sODTURL = sODTURL.substring(0, sODTURL.length()-4); }
- sODTURL += ".odt";
-
- // Get the component loader
- Object desktop;
- try {
- desktop = xContext.getServiceManager().createInstanceWithContext(
- "com.sun.star.frame.Desktop", xContext);
-
- XComponentLoader xComponentLoader = (XComponentLoader)UnoRuntime.queryInterface(
- XComponentLoader.class, desktop);
-
- // Load the file
- PropertyValue[] props = new PropertyValue[1];
- props[0] = new PropertyValue();
- props[0].Name = "AsTemplate";
- props[0].Value = new Boolean(true);
-
- xComponentLoader.loadComponentFromURL(sODTURL, "_blank", 0, props);
- }
- catch (com.sun.star.lang.IllegalArgumentException e) {
- System.out.println("Fejler med illegalargumentexception");
- }
- catch (com.sun.star.io.IOException e) {
- System.out.println("Fejler med ioexception");
- }
- catch (com.sun.star.uno.Exception e) {
- System.out.println("Failed to get desktop");
- }
- finally {
- odtFile.delete();
- // Restore origninal ODT file, if any
- if (tempFile!=null) {
- tempFile.renameTo(odtFile);
- }
- }
- }
-
-}
diff --git a/source/java/org/openoffice/da/comp/writer4latex/StreamGobbler.java b/source/java/org/openoffice/da/comp/writer4latex/StreamGobbler.java
index c8e802e..1c48926 100644
--- a/source/java/org/openoffice/da/comp/writer4latex/StreamGobbler.java
+++ b/source/java/org/openoffice/da/comp/writer4latex/StreamGobbler.java
@@ -45,7 +45,7 @@ class StreamGobbler extends Thread {
while ( (line = br.readLine()) != null) {
//while ( br.readLine() != null) {
// Do nothing...
- System.out.println(type + ">" + line);
+ //System.out.println(type + ">" + line);
}
}
catch (IOException ioe) {
diff --git a/source/java/org/openoffice/da/comp/writer4latex/TeXDetectService.java b/source/java/org/openoffice/da/comp/writer4latex/TeXDetectService.java
new file mode 100644
index 0000000..89b932d
--- /dev/null
+++ b/source/java/org/openoffice/da/comp/writer4latex/TeXDetectService.java
@@ -0,0 +1,93 @@
+/************************************************************************
+ *
+ * TeXDetectService.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-05-20)
+ *
+ */
+
+package org.openoffice.da.comp.writer4latex;
+
+import com.sun.star.lib.uno.helper.WeakBase;
+
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.document.XExtendedFilterDetection;
+import com.sun.star.task.XStatusIndicator;
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.uno.XComponentContext;
+
+/** This class provides detect services for TeX documents
+ * It is thus an implementation of the service com.sun.star.document.ExtendedTypeDetection
+ */
+
+public class TeXDetectService extends WeakBase implements XExtendedFilterDetection {
+
+ // Constants
+
+ // Identify this service
+ public static final String __implementationName = TeXDetectService.class.getName();
+ public static final String __serviceName = "com.sun.star.document.ExtendedTypeDetection";
+ private static final String[] m_serviceNames = { __serviceName };
+
+ // From constructor+initialization
+ private final XComponentContext m_xContext;
+
+ /** Construct a new TeXDetectService
+ *
+ * @param xContext The Component Context
+ */
+ public TeXDetectService( XComponentContext xContext ) {
+ m_xContext = xContext;
+ }
+
+ // Implement XExtendedFilterDetection
+ public String detect(PropertyValue[][] mediaDescriptor) {
+ // Read the media properties
+ String sURL = null;
+ String sTypeName = null;
+ if (mediaDescriptor.length>0) {
+ int nLength = mediaDescriptor[0].length;
+ for (int i=0; iTeXImportFilter
+ *
+ * @param xContext The Component Context
+ */
+ public TeXImportFilter( XComponentContext xContext ) {
+ m_xContext = xContext;
+ m_sFilterName = "";
+ m_xTargetDoc = null;
+ m_nState = FILTERPROC_STOPPED;
+ }
+
+ // Implement com.sun.star.lang.XServiceInfo:
+ public String getImplementationName() {
+ return __implementationName;
+ }
+
+ public boolean supportsService( String sService ) {
+ int len = m_serviceNames.length;
+
+ for(int i=0; i < len; i++) {
+ if (sService.equals(m_serviceNames[i]))
+ return true;
+ }
+ return false;
+ }
+
+ public String[] getSupportedServiceNames() {
+ return m_serviceNames;
+ }
+
+ // The following methods may be called from multiple threads (eg. if someone wants to cancel the filtering),
+ // thus all access to class members must be synchronized
+
+ // Implement XInitialization:
+ public void initialize( Object[] arguments ) throws com.sun.star.uno.Exception {
+ if (arguments.length>0) {
+ // The first argument contains configuration data, from which we extract the filter name for further reference
+ // We need this to know which flavour of TeX we're supposed to handle
+ PropertyValue[] config = (PropertyValue[]) arguments[0];
+ int nLen = config.length;
+ for (int i=0; i 0) {
- sPath = sPathList[0];
- }
- }
- }
- catch (com.sun.star.uno.Exception e) {
- }
- finally{
- // Always dispose the FilePicker component
- if (xComponent!=null) {
- xComponent.dispose();
- }
- }
- return sPath;
- }
-
-
private void prepareMediaProperties() {
// Create inital media properties
mediaProps = new PropertyValue[2];
@@ -533,19 +457,6 @@ public final class Writer4LaTeX extends WeakBase
registry.disposeRegistryView(view);
- // Write out the filter data
- /*PropertyValue[] props = filterData.toArray();
- for (int i=0; icom.sun.star.text.TextDocument
- Run LaTeX...
- Kør LaTeX...
+ Run ~LaTeX...
+ Kør ~LaTeX...
_self
@@ -40,8 +40,8 @@
com.sun.star.text.TextDocument
- Run LaTeX directly
- Kør LaTeX direkte
+ Run LaTe~X directly
+ Kør LaTe~X direkte
_self
@@ -58,8 +58,8 @@
com.sun.star.text.TextDocument
- View Log files
- Vis logfiler
+ View Lo~g files
+ Vis lo~gfiler
_self
@@ -71,69 +71,6 @@
-
-
-
- private:separator
-
-
-
-
- com.sun.star.text.TextDocument
-
-
- Import LaTeX...
- Importer LaTeX...
-
-
- _self
-
-
- org.openoffice.da.writer4latex:ImportLaTeX
-
-
-
-
-
-
diff --git a/source/oxt/writer4latex/META-INF/manifest.xml b/source/oxt/writer4latex/META-INF/manifest.xml
index e2f136d..1d8e87b 100644
--- a/source/oxt/writer4latex/META-INF/manifest.xml
+++ b/source/oxt/writer4latex/META-INF/manifest.xml
@@ -29,6 +29,14 @@
manifest:full-path="Paths.xcu"
manifest:media-type="application/vnd.sun.star.configuration-data"/>
+
+
+
+
diff --git a/source/oxt/writer4latex/w4l_filters.xcu b/source/oxt/writer4latex/w4l_filters.xcu
new file mode 100644
index 0000000..1b8851a
--- /dev/null
+++ b/source/oxt/writer4latex/w4l_filters.xcu
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+ LaTeX
+ org.openoffice.da.writer4latex.LaTeX_File
+ com.sun.star.text.TextDocument
+ org.openoffice.da.comp.writer4latex.TeXImportFilter
+
+ IMPORT TEMPLATE TEMPLATEPATH ALIEN 3RDPARTYFILTER
+
+ 0
+
+
+
+
+
+
diff --git a/source/oxt/writer4latex/w4l_types.xcu b/source/oxt/writer4latex/w4l_types.xcu
new file mode 100644
index 0000000..2889305
--- /dev/null
+++ b/source/oxt/writer4latex/w4l_types.xcu
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+ LaTeX File
+
+
+
+ tex
+ true
+ org.openoffice.da.comp.writer4latex.TeXDetectService
+ org.openoffice.da.writer4latex.latex
+
+
+
+