26import java.io.FileOutputStream;
27import java.io.IOException;
29import java.util.Iterator;
31import javax.xml.parsers.ParserConfigurationException;
51import com.
sun.
star.
lib.uno.adapter.XInputStreamToInputStreamAdapter;
52import com.
sun.
star.
lib.uno.adapter.XOutputStreamToOutputStreamAdapter;
69 private static XMultiServiceFactory
xMSF;
73 private static XOutputStream
xos =
null;
95 Type[] typeReturn = {};
98 typeReturn =
new Type[] {
99 new Type( XTypeProvider.class ),
100 new Type( XImportFilter.class ),
101 new Type( XExportFilter.class ),
102 new Type( XServiceName.class ),
103 new Type( XServiceInfo.class ) };
117 if(origName.equalsIgnoreCase(
""))
120 if (origName.lastIndexOf(
"/")>=0){
121 origName=origName.substring(origName.lastIndexOf(
"/")+1,origName.length());
123 if (origName.lastIndexOf(
".")>=0){
124 name = origName.substring(0, origName.lastIndexOf(
"."));
139 String[] msUserData)
throws com.
sun.
star.
uno.RuntimeException {
149 for (
int i = 0 ;
i < pValue.length;
i++)
153 if (pValue[
i].
Name.equals(
"InputStream")){
156 if (pValue[
i].
Name.equals(
"FileName")){
162 System.out.println(
"\nIllegalArgumentException "+AnyExec);
169 Object xCfgMgrObj=
xMSF.createInstance(
"com.sun.star.config.SpecialConfigManager");
170 XConfigManager xCfgMgr = UnoRuntime.queryInterface(
171 XConfigManager.class , xCfgMgrObj );
172 String PathString=xCfgMgr.substituteVariables(
"$(progurl)" );
173 PathString= PathString.concat(
"/");
176 Object xPipeObj=
xMSF.createInstance(
"com.sun.star.io.Pipe");
178 XInputStream.class , xPipeObj );
180 XOutputStream.class , xPipeObj );
182 Object xSaxParserObj=
xMSF.createInstance(
"com.sun.star.xml.sax.Parser");
184 XParser xParser = UnoRuntime.queryInterface(
185 XParser.class , xSaxParserObj );
187 InputSource aInput =
new InputSource();
193 xParser.setDocumentHandler ( xDocHandler );
195 xParser.parseStream ( aInput );
200 catch (IOException e){
210 String[] msUserData)
throws com.
sun.
star.
uno.RuntimeException{
219 for (
int i = 0 ;
i < pValue.length;
i++)
223 if (pValue[
i].
Name.equals(
"OutputStream")){
227 if (pValue[
i].
Name.equals(
"FileName")){
231 if (pValue[
i].
Name.equals(
"URL")){
236 System.out.println(
"\nIllegalArgumentException "+AnyExec);
246 Object xCfgMgrObj=
xMSF.createInstance(
"com.sun.star.config.SpecialConfigManager");
247 XConfigManager xCfgMgr = UnoRuntime.queryInterface(
248 XConfigManager.class , xCfgMgrObj );
250 String PathString=xCfgMgr.substituteVariables(
"$(progurl)" );
251 PathString= PathString.concat(
"/");
254 Object xPipeObj=
xMSF.createInstance(
"com.sun.star.io.Pipe");
256 XInputStream.class , xPipeObj );
258 XOutputStream.class , xPipeObj );
261 System.out.println(
"Exception "+e);
269 if (origString.contains(
"&")) {
270 origString = origString.replace(
"&",
"&");
272 if (origString.contains(
"\"")) {
273 origString = origString.replace(
"\"",
""");
275 if (origString.contains(
"<")) {
276 origString = origString.replace(
"<",
"<");
278 if (origString.contains(
">")) {
279 origString = origString.replace(
">",
">");
295 catch (IOException e){
311 str= str.concat(
" ");
312 int len=xattribs.getLength();
313 for (
short i=0;
i<len;
i++)
315 str=str.concat(xattribs.getNameByIndex(
i));
316 str=str.concat(
"=\"");
317 str=str.concat(
needsMask(xattribs.getValueByIndex(
i)));
318 str=str.concat(
"\" ");
327 System.out.println(
"\n"+e);
334 str=
"</".concat(str);
341 System.out.println(
"\n"+e);
351 System.out.println(
"\n"+e);
367 private static void close(FileOutputStream c)
throws IOException {
368 if (c ==
null)
return;
373 boolean convertFromOffice,String pluginUrl,String FileName,String
offMime,String
sdMime)
throws com.
sun.
star.
uno.RuntimeException, IOException {
375 String jarName = pluginUrl;
378 Iterator<ConverterInfo> ciEnum=
null;
380 XInputStreamToInputStreamAdapter xis =
new XInputStreamToInputStreamAdapter(xml);
382 XOutputStreamToOutputStreamAdapter newxos =
new XOutputStreamToOutputStreamAdapter(device);
390 catch (ParserConfigurationException pexc){
391 System.out.println(
"Error:"+pexc);
393 catch (
org.xml.sax.SAXException pexc){
394 System.out.println(
"Error:"+pexc);
397 System.out.println(
"Error:"+e);
400 if (convertFromOffice)
412 System.out.println(
"\nNo plug-in exists to convert from <staroffice/sxw> to <specified format> ");
422 if (docEnum.hasNext()){
424 docOut.
write(newxos);
431 while (docEnum.hasNext() &&
sURL.startsWith(
"file:")) {
433 URI uri=
new URI(
sURL);
437 if (newFileName.lastIndexOf(
".")!=-1){
438 newFile =
new File(newFileName.substring(0,newFileName.lastIndexOf(
"."))+
String.valueOf(
i)+newFileName.substring(newFileName.lastIndexOf(
".")));
441 newFile =
new File(newFileName.concat(
String.valueOf(
i)));
444 FileOutputStream fos =
null;
446 fos =
new FileOutputStream(newFile);
462 IOException ex2 =
new IOException();
475 System.out.println(
"\nNo plug-in exists to convert to <staroffice/sxw> from <specified format>");
483 while (docEnum.hasNext()) {
484 OfficeDocument docIn = (OfficeDocument)docEnum.next();
486 docIn.write(newxos,
false);
493 catch (StackOverflowError sOE){
494 System.out.println(
"\nERROR : Stack Overflow. \n Increase of the JRE by adding the following line to the end of the javarc file \n \"-Xss1m\"\n");
497 IOException ex2 =
new IOException();
508 }
catch (IOException e) {
517 String path = uri.getPath();
519 if(opSys.contains(
"Windows")){
520 path= path.replace(
'/',
'\\');
521 path = path.substring(1);
547 return stringSupportedServiceNames;
566 XMultiServiceFactory multiFactory,
567 XRegistryKey regKey) {
569 XSingleServiceFactory xSingleServiceFactory =
null;
571 xSingleServiceFactory = FactoryHelper.getServiceFactory(
_XMergeBridge.class,
577 return xSingleServiceFactory;
This inner class provides the component as a concrete implementation of the service description.
byte[] getImplementationId()
void endElement(String str)
boolean exporter(com.sun.star.beans.PropertyValue[] aSourceData, String[] msUserData)
String getImplementationName()
static final String __serviceName
The component will be registered under this name.
com.sun.star.uno.Type[] getTypes()
void characters(String str)
void startElement(String str, com.sun.star.xml.sax.XAttributeList xattribs)
void setDocumentLocator(com.sun.star.xml.sax.XLocator xLocator)
void processingInstruction(String aTarget, String aData)
boolean supportsService(String stringServiceName)
boolean importer(com.sun.star.beans.PropertyValue[] aSourceData, com.sun.star.xml.sax.XDocumentHandler xDocHandler, String[] msUserData)
String needsMask(String origString)
void convert(com.sun.star.io.XInputStream xml, com.sun.star.io.XOutputStream device, boolean convertFromOffice, String pluginUrl, String FileName, String offMime, String sdMime)
String getFileName(String origName)
static void close(FileOutputStream c)
String[] getSupportedServiceNames()
void ignorableWhitespace(String str)
This outer class provides an inner class to implement the service description and a method to instant...
static XMultiServiceFactory xMSF
static XSingleServiceFactory __getServiceFactory(String implName, XMultiServiceFactory multiFactory, XRegistryKey regKey)
Returns a factory for creating the service.
static XOutputStream xOutStream
static XInputStream xInStream
ConvertData is used as a container for passing Document objects in and out of the Convert class.
Iterator< Object > getDocumentEnumeration()
Gets an Enumeration to access the Vector of Document objects.
The Convert class manages a conversion from one mime-type to another.
void addInputStream(String name, InputStream is)
Adds an InputStream to be used as input by the Convert class.
ConvertData convert()
Convert the input specified in calls to the addInputStream method to the output format specified by t...
Factory that provides access to Convert objects, which are used to do a conversion.
Convert getConverter(String mimeTypeIn, String mimeTypeOut)
Returns the Convert object that converts the specified device/office mime type conversion.
Manages the converter plug-ins that are currently active.
static boolean removeByJar(String jar)
Removes any ConverterInfo object from the registry that have the specified jar name value.
static void addPlugIn(ConverterInfo ci)
Adds a converter plug-in to the registry.
static ConverterInfo findConverterInfo(String deviceMime, String officeMime)
Returns the ConverterInfo object that supports the specified device/office mime type conversion.
The ConverterInfoReader pulls a META-INF/converter.xml file out of a jar file and parses it,...
Iterator< ConverterInfo > getConverterInfoEnumeration()
Returns an Enumeration of ConverterInfo objects.
Class for storing the information about a converter plug-in.
A Document represents any Document to be converted and the resulting Document from any conversion.
void write(OutputStream os)
Writes out the Document content to the specified OutputStream.
Document and PluginFactory implementations for XML based formats.
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...