summaryrefslogtreecommitdiff
path: root/wizards
diff options
context:
space:
mode:
authorKurt Zenker <kz@openoffice.org>2004-05-19 12:19:43 +0000
committerKurt Zenker <kz@openoffice.org>2004-05-19 12:19:43 +0000
commit266af1775100bc35f32ebd0377a4b4136182453b (patch)
tree4100a58f556a09f0bdab722aed517714edf422a1 /wizards
parent5d1eda40c600f454cb6bf6cf879659f222c040d8 (diff)
INTEGRATION: CWS qwizards1 (1.1.2); FILE ADDED
2004/03/12 16:17:00 rpiterman 1.1.2.4: documentation and small implementation-fixes 2004/03/05 19:11:52 rpiterman 1.1.2.3: Further developement 2004/02/13 15:44:09 rpiterman 1.1.2.2: added some storeToUrl(...) methods 2004/02/11 17:18:43 rpiterman 1.1.2.1: Abstract Implementation of Exporter, with uno open and store methods.
Diffstat (limited to 'wizards')
-rw-r--r--wizards/com/sun/star/wizards/web/export/AbstractExporter.java132
1 files changed, 132 insertions, 0 deletions
diff --git a/wizards/com/sun/star/wizards/web/export/AbstractExporter.java b/wizards/com/sun/star/wizards/web/export/AbstractExporter.java
new file mode 100644
index 000000000000..dd5469fa6314
--- /dev/null
+++ b/wizards/com/sun/star/wizards/web/export/AbstractExporter.java
@@ -0,0 +1,132 @@
+/*
+ * AbstractExporter.java
+ *
+ * Created on 1. Oktober 2003, 16:12
+ */
+
+package com.sun.star.wizards.web.export;
+
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.frame.XComponentLoader;
+import com.sun.star.frame.XDesktop;
+import com.sun.star.frame.XStorable;
+import com.sun.star.io.IOException;
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.wizards.common.Desktop;
+import com.sun.star.wizards.common.FileAccess;
+import com.sun.star.wizards.common.Properties;
+import com.sun.star.wizards.document.OfficeDocument;
+import com.sun.star.wizards.text.TextDocument;
+import com.sun.star.wizards.web.data.CGArgument;
+import com.sun.star.wizards.web.data.CGDocument;
+import com.sun.star.wizards.web.data.CGExporter;
+import com.sun.star.wizards.web.data.TypeDetection;
+
+/**
+ *
+ * @author rpiterman
+ */
+public abstract class AbstractExporter implements Exporter {
+ protected CGExporter exporter;
+ protected FileAccess fileAccess;
+
+ protected void storeToURL(Object officeDocument, Properties props, String targetUrl, String filterName, PropertyValue[] filterData)
+ throws IOException {
+
+ props = new Properties();
+ props.put("FilterName", filterName);
+
+ if (filterData.length>0)
+ props.put("FilterData", filterData);
+
+ XStorable xs = ((XStorable)UnoRuntime.queryInterface(XStorable.class,officeDocument));
+ PropertyValue[] o = props.getProperties();
+ xs.storeToURL(targetUrl, o);
+ }
+
+ protected void storeToURL(Object officeDocument, String targetUrl, String filterName, PropertyValue[] filterData)
+ throws IOException {
+
+ storeToURL(officeDocument, new Properties(), targetUrl, filterName, filterData);
+ }
+
+ protected void storeToURL(Object officeDocument, String targetUrl, String filterName )
+ throws IOException {
+
+ storeToURL(officeDocument, new Properties(), targetUrl, filterName, new PropertyValue[0]);
+
+ }
+
+ protected String getArgument(String name, CGExporter p) {
+ return ((CGArgument)p.cp_Arguments.getElement(name)).cp_Value;
+ }
+
+ protected Object openDocument(CGDocument doc, XMultiServiceFactory xmsf)
+ throws com.sun.star.io.IOException
+ {
+ Object document = null;
+ //open the document.
+ try {
+ XDesktop desktop = Desktop.getDesktop(xmsf);
+ Properties props = new Properties();
+ props.put("Hidden", Boolean.TRUE);
+ document = (
+ (XComponentLoader) UnoRuntime.queryInterface(
+ XComponentLoader.class,
+ desktop)).loadComponentFromURL(
+ doc.cp_URL,
+ "_blank",
+ 0,
+ props.getProperties());
+ } catch (com.sun.star.lang.IllegalArgumentException iaex) {
+ }
+ //try to get the number of pages in the document;
+ try {
+ pageCount(doc,document);
+ }
+ catch (Exception ex) {
+ //Here i do nothing since pages is not *so* important.
+ }
+ return document;
+ }
+
+ protected void closeDocument(Object doc,XMultiServiceFactory xmsf) {
+ OfficeDocument.dispose(
+ xmsf,
+ (XComponent) UnoRuntime.queryInterface(XComponent.class, doc));
+ }
+
+ private void pageCount(CGDocument doc, Object document) {
+ if (doc.appType.equals(TypeDetection.WRITER_DOC))
+ doc.pages = TextDocument.getPageCount(document);
+ else if (doc.appType.equals(TypeDetection.IMPRESS_DOC))
+ doc.pages = OfficeDocument.getSlideCount(document);
+ else if (doc.appType.equals(TypeDetection.DRAW_DOC))
+ doc.pages = OfficeDocument.getSlideCount(document);
+ }
+
+ public void init(CGExporter exporter_) {
+ exporter = exporter_;
+ }
+
+ protected FileAccess getFileAccess(XMultiServiceFactory xmsf) {
+ if ( fileAccess == null )
+ try {
+ fileAccess = new FileAccess(xmsf);
+ }
+ catch (Exception ex) {}
+ return fileAccess;
+ }
+
+ protected void calcFileSize(CGDocument doc, String url, XMultiServiceFactory xmsf) {
+ /*if the exporter exports to a
+ * binary format, get the size of the destination.
+ */
+ if (exporter.cp_Binary)
+ doc.sizeKB = getFileAccess(xmsf).getSize(url);
+
+ }
+
+}