26 import java.io.FileOutputStream;
27 import java.io.IOException;
29 import java.util.Iterator;
31 import javax.xml.parsers.ParserConfigurationException;
51 import com.
sun.
star.
lib.uno.adapter.XInputStreamToInputStreamAdapter;
52 import 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 {
143 udJarPath=msUserData[1];
144 offMime =msUserData[4];
145 sdMime = msUserData[5];
149 for (
int i = 0 ;
i < pValue.length;
i++)
153 if (pValue[
i].
Name.equals(
"InputStream")){
156 if (pValue[
i].
Name.equals(
"FileName")){
157 sFileName=(
String)AnyConverter.toObject(
new Type(
String.class), pValue[
i].Value);
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(
"/");
174 udJarPath= PathString.concat(udJarPath);
176 Object xPipeObj=xMSF.createInstance(
"com.sun.star.io.Pipe");
177 xInStream = UnoRuntime.queryInterface(
178 XInputStream.class , xPipeObj );
179 xOutStream = UnoRuntime.queryInterface(
180 XOutputStream.class , xPipeObj );
181 convert (xis,xOutStream,
false,udJarPath,sFileName,offMime,sdMime);
182 Object xSaxParserObj=xMSF.createInstance(
"com.sun.star.xml.sax.Parser");
184 XParser xParser = UnoRuntime.queryInterface(
185 XParser.class , xSaxParserObj );
186 xOutStream.closeOutput();
187 InputSource aInput =
new InputSource();
188 if (sFileName==null){
193 xParser.setDocumentHandler ( xDocHandler );
195 xParser.parseStream ( aInput );
196 xOutStream.closeOutput();
197 xInStream.closeInput();
210 String[] msUserData)
throws com.
sun.
star.
uno.RuntimeException{
214 udJarPath=msUserData[1];
215 offMime =msUserData[4];
216 sdMime = msUserData[5];
219 for (
int i = 0 ;
i < pValue.length;
i++)
223 if (pValue[
i].
Name.equals(
"OutputStream")){
227 if (pValue[
i].
Name.equals(
"FileName")){
228 sFileName=(
String)AnyConverter.toObject(
new Type(
String.class), pValue[
i].Value);
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(
"/");
252 udJarPath= PathString.concat(udJarPath);
254 Object xPipeObj=xMSF.createInstance(
"com.sun.star.io.Pipe");
255 xInStream = UnoRuntime.queryInterface(
256 XInputStream.class , xPipeObj );
257 xOutStream = UnoRuntime.queryInterface(
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(
">",
">");
291 xOutStream.closeOutput();
292 convert (xInStream,xos,
true,udJarPath,sURL,offMime,sdMime);
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(
"\" ");
324 xOutStream.writeBytes(str.getBytes(
"UTF-8"));
327 System.out.println(
"\n"+e);
334 str=
"</".concat(str);
337 xOutStream.writeBytes(str.getBytes(
"UTF-8"));
341 System.out.println(
"\n"+e);
348 xOutStream.writeBytes(str.getBytes(
"UTF-8"));
351 System.out.println(
"\n"+e);
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> ");
420 Iterator<Object> docEnum = dataOut.getDocumentEnumeration();
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);
475 System.out.println(
"\nNo plug-in exists to convert to <staroffice/sxw> from <specified format>");
482 Iterator<Object> docEnum = dataIn.getDocumentEnumeration();
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");
517 String path = uri.getPath();
519 if(opSys.contains(
"Windows")){
520 path= path.replace(
'/',
'\\');
521 path = path.substring(1);
538 return stringServiceName.equals( __serviceName );
546 String[] stringSupportedServiceNames = { __serviceName };
547 return stringSupportedServiceNames;
566 XMultiServiceFactory multiFactory,
567 XRegistryKey regKey) {
569 XSingleServiceFactory xSingleServiceFactory = null;
571 xSingleServiceFactory = FactoryHelper.getServiceFactory(
_XMergeBridge.class,
577 return xSingleServiceFactory;
Factory that provides access to.
void convert(com.sun.star.io.XInputStream xml, com.sun.star.io.XOutputStream device, boolean convertFromOffice, String pluginUrl, String FileName, String offMime, String sdMime)
exports com.sun.star. xml
Provides general purpose utilities.
String[] getSupportedServiceNames()
static boolean removeByJar(String jar)
Removes any.
Provides an interface for plug-in registration.
static final String __serviceName
The component will be registered under this name.
void endElement(String str)
String needsMask(String origString)
void setDocumentLocator(com.sun.star.xml.sax.XLocator xLocator)
static XSingleServiceFactory __getServiceFactory(String implName, XMultiServiceFactory multiFactory, XRegistryKey regKey)
Returns a factory for creating the service.
Convert getConverter(String mimeTypeIn, String mimeTypeOut)
Returns the.
This inner class provides the component as a concrete implementation of the service description...
exports com.sun.star. java
static XMultiServiceFactory xMSF
boolean exporter(com.sun.star.beans.PropertyValue[] aSourceData, String[] msUserData)
String getImplementationName()
com.sun.star.uno.Type[] getTypes()
static XOutputStream xOutStream
void startElement(String str, com.sun.star.xml.sax.XAttributeList xattribs)
Manages the converter plug-ins that are currently active.
boolean importer(com.sun.star.beans.PropertyValue[] aSourceData, com.sun.star.xml.sax.XDocumentHandler xDocHandler, String[] msUserData)
static void addPlugIn(ConverterInfo ci)
Adds a converter plug-in to the registry.
static ConverterInfo findConverterInfo(String deviceMime, String officeMime)
Returns the.
String getFileName(String origName)
void characters(String str)
static XInputStream xInStream
byte[] getImplementationId()
This outer class provides an inner class to implement the service description and a method to instant...
void ignorableWhitespace(String str)
static void close(FileOutputStream c)
void write(OutputStream os)
Writes out the.
Class for storing the information about a converter plug-in.
Provides interfaces for converting between two.
void addInputStream(String name, InputStream is)
Adds an.
boolean supportsService(String stringServiceName)
ConvertData convert()
Convert the input specified in calls to the.
Iterator< ConverterInfo > getConverterInfoEnumeration()
Returns an.
void processingInstruction(String aTarget, String aData)
exports com.sun.star. uri