当前位置: 首页>>代码示例>>Java>>正文


Java OfficeException类代码示例

本文整理汇总了Java中org.artofsolving.jodconverter.office.OfficeException的典型用法代码示例。如果您正苦于以下问题:Java OfficeException类的具体用法?Java OfficeException怎么用?Java OfficeException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


OfficeException类属于org.artofsolving.jodconverter.office包,在下文中一共展示了OfficeException类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: convert

import org.artofsolving.jodconverter.office.OfficeException; //导入依赖的package包/类
/**
 * Convert a document format to another one.
 */
public void convert(File inputFile, String mimeType, File outputFile) throws ConversionException {
	log.debug("convert({}, {}, {})", new Object[]{inputFile, mimeType, outputFile});

	if (Config.SYSTEM_OPENOFFICE_PATH.equals("") && Config.SYSTEM_OPENOFFICE_SERVER.equals("")) {
		throw new ConversionException(Config.PROPERTY_SYSTEM_OPENOFFICE_PATH + " or " + Config.PROPERTY_SYSTEM_OPENOFFICE_SERVER
				+ " not configured");
	}

	if (!validOpenOffice.contains(mimeType)) {
		throw new ConversionException("Invalid document conversion MIME type: " + mimeType);
	}

	try {
		if (!Config.SYSTEM_OPENOFFICE_PATH.equals("")) {
			// Document conversion managed by local OO instance
			OfficeDocumentConverter converter = new OfficeDocumentConverter(officeManager);
			converter.convert(inputFile, outputFile);
		} else if (!Config.SYSTEM_OPENOFFICE_SERVER.equals("")) {
			// Document conversion managed by remote conversion server
			remoteConvert(Config.SYSTEM_OPENOFFICE_SERVER, inputFile, mimeType, outputFile, MimeTypeConfig.MIME_PDF);
		}
	} catch (OfficeException e) {
		throw new ConversionException("Error converting document: " + e.getMessage());
	}
}
 
开发者ID:openkm,项目名称:document-management-system,代码行数:29,代码来源:DocConverter.java

示例2: loadDocument

import org.artofsolving.jodconverter.office.OfficeException; //导入依赖的package包/类
private XComponent loadDocument(OfficeContext context, File inputFile) throws OfficeException {
	if (!inputFile.exists()) {
		throw new OfficeException("input document not found");
	}
	XComponentLoader loader = cast(XComponentLoader.class, context.getService(SERVICE_DESKTOP));
	Map<String, ?> loadProperties = getLoadProperties(inputFile);
	XComponent document = null;
	try {
		document = loader.loadComponentFromURL(toUrl(inputFile), "_blank", 0, toUnoProperties(loadProperties));
	} catch (IllegalArgumentException illegalArgumentException) {
		throw new OfficeException("could not load document: " + inputFile.getName(), illegalArgumentException);
	} catch (ErrorCodeIOException errorCodeIOException) {
		throw new OfficeException("could not load document: " + inputFile.getName() + "; errorCode: "
				+ errorCodeIOException.ErrCode, errorCodeIOException);
	} catch (IOException ioException) {
		throw new OfficeException("could not load document: " + inputFile.getName(), ioException);
	}
	if (document == null) {
		throw new OfficeException("could not load document: " + inputFile.getName());
	}
	XRefreshable refreshable = cast(XRefreshable.class, document);
	if (refreshable != null) {
		refreshable.refresh();
	}
	return document;
}
 
开发者ID:kuzavas,项目名称:ephesoft,代码行数:27,代码来源:AbstractConversionTask.java

示例3: getDocumentFamily

import org.artofsolving.jodconverter.office.OfficeException; //导入依赖的package包/类
public static DocumentFamily getDocumentFamily(XComponent document) throws OfficeException {
    XServiceInfo serviceInfo = cast(XServiceInfo.class, document);
    if (serviceInfo.supportsService("com.sun.star.text.GenericTextDocument")) {
        // NOTE: a GenericTextDocument is either a TextDocument, a WebDocument, or a GlobalDocument
        // but this further distinction doesn't seem to matter for conversions
        return DocumentFamily.TEXT;
    } else if (serviceInfo.supportsService("com.sun.star.sheet.SpreadsheetDocument")) {
        return DocumentFamily.SPREADSHEET;
    } else if (serviceInfo.supportsService("com.sun.star.presentation.PresentationDocument")) {
        return DocumentFamily.PRESENTATION;
    } else if (serviceInfo.supportsService("com.sun.star.drawing.DrawingDocument")) {
        return DocumentFamily.DRAWING;
    } else {
        throw new OfficeException("document of unknown family: " + serviceInfo.getImplementationName());
    }
}
 
开发者ID:qjx378,项目名称:wenku,代码行数:17,代码来源:OfficeDocumentUtils.java

示例4: execute

import org.artofsolving.jodconverter.office.OfficeException; //导入依赖的package包/类
public void execute(OfficeContext context) throws OfficeException {
    XComponent document = null;
    try {
        document = loadDocument(context, inputFile);
        modifyDocument(document);
        storeDocument(document, outputFile);
    } catch (OfficeException officeException) {
        throw officeException;
    } catch (Exception exception) {
        throw new OfficeException("conversion failed", exception);
    } finally {
        if (document != null) {
            XCloseable closeable = cast(XCloseable.class, document);
            if (closeable != null) {
                try {
                    closeable.close(true);
                } catch (CloseVetoException closeVetoException) {
                    // whoever raised the veto should close the document
                }
            } else {
                document.dispose();
            }
        }
    }
}
 
开发者ID:qjx378,项目名称:wenku,代码行数:26,代码来源:AbstractConversionTask.java

示例5: loadDocument

import org.artofsolving.jodconverter.office.OfficeException; //导入依赖的package包/类
private XComponent loadDocument(OfficeContext context, File inputFile) throws OfficeException {
    if (!inputFile.exists()) {
        throw new OfficeException("input document not found");
    }
    XComponentLoader loader = cast(XComponentLoader.class, context.getService(SERVICE_DESKTOP));
    Map<String,?> loadProperties = getLoadProperties(inputFile);
    XComponent document = null;
    try {
        document = loader.loadComponentFromURL(toUrl(inputFile), "_blank", 0, toUnoProperties(loadProperties));
    } catch (IllegalArgumentException illegalArgumentException) {
        throw new OfficeException("could not load document: " + inputFile.getName(), illegalArgumentException);
    } catch (ErrorCodeIOException errorCodeIOException) {
        throw new OfficeException("could not load document: "  + inputFile.getName() + "; errorCode: " + errorCodeIOException.ErrCode, errorCodeIOException);
    } catch (IOException ioException) {
        throw new OfficeException("could not load document: "  + inputFile.getName(), ioException);
    }
    if (document == null) {
        throw new OfficeException("could not load document: "  + inputFile.getName());
    }
    return document;
}
 
开发者ID:qjx378,项目名称:wenku,代码行数:22,代码来源:AbstractConversionTask.java

示例6: storeDocument

import org.artofsolving.jodconverter.office.OfficeException; //导入依赖的package包/类
private void storeDocument(XComponent document, File outputFile) throws OfficeException {
	Map<String, ?> storeProperties = getStoreProperties(outputFile, document);
	if (storeProperties == null) {
		throw new OfficeException("unsupported conversion");
	}
	try {
		PropertyValue[] storeProps = new PropertyValue[1];
		storeProps[0] = new PropertyValue();
		storeProps[0].Name = "FilterName";
		storeProps[0].Value = "writer_pdf_Export";
		cast(XStorable.class, document).storeToURL(toUrl(outputFile), storeProps);
	} catch (ErrorCodeIOException errorCodeIOException) {
		throw new OfficeException("could not store document: " + outputFile.getName() + "; errorCode: "
				+ errorCodeIOException.ErrCode, errorCodeIOException);
	} catch (IOException ioException) {
		throw new OfficeException("could not store document: " + outputFile.getName(), ioException);
	}
}
 
开发者ID:kuzavas,项目名称:ephesoft,代码行数:19,代码来源:AbstractConversionTask.java

示例7: modifyDocument

import org.artofsolving.jodconverter.office.OfficeException; //导入依赖的package包/类
@Override
protected void modifyDocument(XComponent document) throws OfficeException {
    XRefreshable refreshable = cast(XRefreshable.class, document);
    if (refreshable != null) {
        refreshable.refresh();
    }
}
 
开发者ID:qjx378,项目名称:wenku,代码行数:8,代码来源:StandardConversionTask.java

示例8: convert

import org.artofsolving.jodconverter.office.OfficeException; //导入依赖的package包/类
public void convert(File inputFile, File outputFile, DocumentFormat outputFormat) throws OfficeException {
    String inputExtension = FilenameUtils.getExtension(inputFile.getName());
    DocumentFormat inputFormat = formatRegistry.getFormatByExtension(inputExtension);
    StandardConversionTask conversionTask = new StandardConversionTask(inputFile, outputFile, outputFormat);
    conversionTask.setDefaultLoadProperties(defaultLoadProperties);
    conversionTask.setInputFormat(inputFormat);
    officeManager.execute(conversionTask);
}
 
开发者ID:qjx378,项目名称:wenku,代码行数:9,代码来源:OfficeDocumentConverter.java

示例9: storeDocument

import org.artofsolving.jodconverter.office.OfficeException; //导入依赖的package包/类
private void storeDocument(XComponent document, File outputFile) throws OfficeException {
    Map<String,?> storeProperties = getStoreProperties(outputFile, document);
    if (storeProperties == null) {
        throw new OfficeException("unsupported conversion");
    }
    try {
        cast(XStorable.class, document).storeToURL(toUrl(outputFile), toUnoProperties(storeProperties));
    } catch (ErrorCodeIOException errorCodeIOException) {
        throw new OfficeException("could not store document: " + outputFile.getName() + "; errorCode: " + errorCodeIOException.ErrCode, errorCodeIOException);
    } catch (IOException ioException) {
        throw new OfficeException("could not store document: " + outputFile.getName(), ioException);
    }
}
 
开发者ID:qjx378,项目名称:wenku,代码行数:14,代码来源:AbstractConversionTask.java

示例10: execute

import org.artofsolving.jodconverter.office.OfficeException; //导入依赖的package包/类
/**
 * Execute method. 
 * @param context OfficeContext
 * @throws OfficeException in case of conversion failure
 */
public void execute(OfficeContext context) throws OfficeException {
	XComponent document = null;
	try {
		if (inputFile != null) {
			document = loadDocument(context, inputFile);
		} else {
			document = loadDocument(context, inputFileURL);
		}
		storeDocument(document, outputFile);
	} catch (OfficeException officeException) {
		throw officeException;
	} catch (Exception exception) {
		throw new OfficeException("conversion failed", exception);
	} finally {
		if (document != null) {
			XCloseable closeable = cast(XCloseable.class, document);
			if (closeable != null) {
				try {
					closeable.close(true);
				} catch (CloseVetoException closeVetoException) {
					// whoever raised the veto should close the document
				}
			} else {
				document.dispose();
			}
		}
	}
}
 
开发者ID:kuzavas,项目名称:ephesoft,代码行数:34,代码来源:AbstractConversionTask.java

示例11: destroy

import org.artofsolving.jodconverter.office.OfficeException; //导入依赖的package包/类
static void destroy() {
	try {
		officeManager.stop();
		log.debug("JOD OfficeManager stopped");
	} catch (OfficeException e) {
		log.debug("Fail to stop JOD Office Manager. I hope for the best...");
	}
	officeManager = null;
}
 
开发者ID:LeoFCardoso,项目名称:tudoToPDF,代码行数:10,代码来源:AppContext.java

示例12: modifyDocument

import org.artofsolving.jodconverter.office.OfficeException; //导入依赖的package包/类
/**
 * Override to modify the document after it has been loaded and before it gets
 * saved in the new format.
 * <p>
 * Does nothing by default.
 * 
 * @param document
 * @throws OfficeException
 */
protected void modifyDocument(XComponent document) throws OfficeException {
	// noop
}
 
开发者ID:qjx378,项目名称:wenku,代码行数:13,代码来源:AbstractConversionTask.java


注:本文中的org.artofsolving.jodconverter.office.OfficeException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。