LibreOffice Module xmerge (master) 1
PluginFactoryImpl.java
Go to the documentation of this file.
1/*
2 * This file is part of the LibreOffice project.
3 *
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 *
8 * This file incorporates work covered by the following license notice:
9 *
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
17 */
18
19package org.openoffice.xmerge.converter.xml.xslt;
20
21import java.io.IOException;
22import java.io.InputStream;
23import java.util.Iterator;
24import java.util.Properties;
25
38
53public final class PluginFactoryImpl extends PluginFactory
55{
56
58 super(ci);
59 }
60
62 private static final ConverterCapabilities converterCap =
64
74 return new DocumentSerializerImpl(this,doc);
75 }
76
87 return new DocumentDeserializerImpl(this,cd);
88 }
89
90 @Override
92 java.io.InputStream inputStream) throws java.io.IOException {
93 String ext = this.getDeviceFileExtension();
94 DOMDocument domDoc = new DOMDocument(str,ext);
95 domDoc.read(inputStream);
96 return domDoc;
97 }
98
99 @Override
100 public Document createOfficeDocument(String name, InputStream is)
101 throws IOException {
102
103 // read zipped XML stream
105 doc.read(is);
106 return doc;
107 }
108
109 @Override
110 public Document createOfficeDocument(String name, InputStream is, boolean isZip)
111 throws IOException {
112
113 // read zipped XML stream
115 doc.read(is,isZip);
116 return doc;
117 }
118
130 Class<? extends PluginFactoryImpl> c = this.getClass();
131 InputStream is = c.getResourceAsStream("XsltPlugin.properties");
133 String ext = ".txt";
134 String mimeType = null;
136 Iterator<String> enumerate = ci.getDeviceMime();
137 while (enumerate.hasNext()) {
138 mimeType = enumerate.next();
139 }
140 try {
141 props.load(is);
142
143 String info = mimeType != null ? props.getProperty(mimeType) : null;
144 if (info != null) {
145 ext = info;
146 }
147 } catch (Exception e) {
148
149 // It is okay for the property file to not exist.
150 } finally {
151 try {
152 if (is != null) {
153 is.close();
154 }
155 } catch (IOException ex) {
156 }
157 }
158 return ext;
159 }
160
171 DocumentMergerImpl merger = new DocumentMergerImpl(doc, cc);
172 return merger;
173 }
174}
ConvertData is used as a container for passing Document objects in and out of the Convert class.
A PluginFactory encapsulates the conversions from one Document format to another.
ConverterInfo getConverterInfo()
Returns the ConvertInfo that corresponds to this plug-in.
An implementation of Document for StarOffice documents.
void read(InputStream is)
Read the Office Document from the specified InputStream.
Xslt implementation of ConverterCapabilities for the PluginFactoryImpl.
Xslt implementation of org.openoffice.xmerge.DocumentSerializer for the PluginFactoryImpl.
Xslt implementation of DocumentMerger for the PluginFactoryImpl.
Xslt implementation of org.openoffice.xmerge.DocumentSerializer for the PluginFactoryImpl.
This class is an implementation of OfficeDocument for the generic office format.
Document createOfficeDocument(String name, InputStream is)
Create a Document object that corresponds to the Office data passed in via the InputStream object.
DocumentDeserializer createDocumentDeserializer(ConvertData cd)
Returns an instance of DocumentDeserializerImpl, which is an implementation of the DocumentDeserializ...
String getDeviceFileExtension()
Returns a String containing the file extension of a Document.
Document createOfficeDocument(String name, InputStream is, boolean isZip)
Create a Document object that corresponds to the Office data passed in via the InputStream object.
DocumentMerger createDocumentMerger(Document doc)
Returns an instance of DocumentMergerImpl, which is an implementation of the DocumentMerger interface...
static final ConverterCapabilities converterCap
ConverterCapabilities object for this type of conversion.
DocumentSerializer createDocumentSerializer(Document doc)
Returns an instance of DocumentSerializerImpl, which is an implementation of the DocumentSerializer i...
org.openoffice.xmerge.Document createDeviceDocument(String str, java.io.InputStream inputStream)
Class for storing the information about a converter plug-in.
Iterator< String > getDeviceMime()
Returns an Enumeration of String objects indicating the device mime-type.
const char * name
A ConverterCapabilities object is used by DocumentMerger implementations.
A DocumentDeserializer object is used to convert from the "Device" Document format to the "Office" Do...
A DocumentDeserializer represents a converter that converts "Device" Document objects into the "Offic...
All plug-in implementations of the PluginFactory interface that also support merging must also implem...
A DocumentMerger can merge changes from a modified "Device" Document to the assigned original "Office...
A DocumentSerializer object is used to convert from the "Office" Document format to the "Device" Docu...
A DocumentSerializer represents a converter that converts a "Office" Document to a "Device" Document ...
A Document represents any Document to be converted and the resulting Document from any conversion.
Definition: Document.java:36
This is an interface used by the DiffAlgorithm and MergeAlgorithm to access a Document.
Definition: Iterator.java:27
Object next()
Move to next element in the sequence.
@ Exception
Provides classes for converting basic document types to/from a DOMDocument object,...
Provides an interface for plug-in registration.
Provides general purpose utilities.
Provides interfaces for converting between two Document formats, and supports a "merge" interface for...
Definition: Convert.java:19
dictionary props
PyRef getClass(const OUString &name, const Runtime &runtime)