本文整理汇总了Java中com.sun.star.uno.Exception类的典型用法代码示例。如果您正苦于以下问题:Java Exception类的具体用法?Java Exception怎么用?Java Exception使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Exception类属于com.sun.star.uno包,在下文中一共展示了Exception类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: showMessageBox
import com.sun.star.uno.Exception; //导入依赖的package包/类
public static void showMessageBox(XComponentContext context, XDialog dialog, MessageBoxType type, String sTitle, String sMessage) {
XToolkit xToolkit;
try {
xToolkit = UnoRuntime.queryInterface(XToolkit.class,
context.getServiceManager().createInstanceWithContext("com.sun.star.awt.Toolkit", context));
} catch (Exception e) {
return;
}
XMessageBoxFactory xMessageBoxFactory = UnoRuntime.queryInterface(XMessageBoxFactory.class, xToolkit);
XWindowPeer xParentWindowPeer = UnoRuntime.queryInterface(XWindowPeer.class, dialog);
XMessageBox xMessageBox = xMessageBoxFactory.createMessageBox(xParentWindowPeer, type,
com.sun.star.awt.MessageBoxButtons.BUTTONS_OK, sTitle, sMessage);
if (xMessageBox == null)
return;
xMessageBox.execute();
}
示例2: invoke
import com.sun.star.uno.Exception; //导入依赖的package包/类
public Object invoke()
{
if (method == null)
{
throw new UnoReflectionException("No method selected. Call 'method' before 'invoke'.");
}
try
{
return method.invoke(object, new Object[][] { args.toArray() });
}
catch (Exception e)
{
throw new UnoReflectionException(e);
}
}
示例3: createDialog
import com.sun.star.uno.Exception; //导入依赖的package包/类
/**
* Create a dialog from an xdl file.
*
* @param xdlFile
* The filename in the `dialog` folder
* @param context
* @return XDialog
*/
public static XDialog createDialog(String xdlFile, XComponentContext context, XDialogEventHandler handler) {
Object oDialogProvider;
try {
oDialogProvider = context.getServiceManager().createInstanceWithContext("com.sun.star.awt.DialogProvider2",
context);
XDialogProvider2 xDialogProv = (XDialogProvider2) UnoRuntime.queryInterface(XDialogProvider2.class,
oDialogProvider);
File dialogFile = FileHelper.getDialogFilePath(xdlFile, context);
return xDialogProv.createDialogWithHandler(convertToURL(context, dialogFile), handler);
} catch (Exception e) {
return null;
}
}
示例4: convertToURL
import com.sun.star.uno.Exception; //导入依赖的package包/类
/** Returns a URL to be used with XDialogProvider to create a dialog */
public static String convertToURL(XComponentContext xContext, File dialogFile) {
String sURL = null;
try {
com.sun.star.ucb.XFileIdentifierConverter xFileConverter = (com.sun.star.ucb.XFileIdentifierConverter) UnoRuntime
.queryInterface(com.sun.star.ucb.XFileIdentifierConverter.class, xContext.getServiceManager()
.createInstanceWithContext("com.sun.star.ucb.FileContentProvider", xContext));
sURL = xFileConverter.getFileURLFromSystemPath("", dialogFile.getAbsolutePath());
} catch (com.sun.star.uno.Exception ex) {
return null;
}
return sURL;
}
示例5: getWriterDocument
import com.sun.star.uno.Exception; //导入依赖的package包/类
public static XTextDocument getWriterDocument() throws Exception {
XMultiComponentFactory xMngr = UnoSuite.getComponentContext().getServiceManager();
Object oDesktop = xMngr.createInstanceWithContext("com.sun.star.frame.Desktop", UnoSuite.getComponentContext());
XComponentLoader xLoader = (XComponentLoader)UnoRuntime.queryInterface(
XComponentLoader.class, oDesktop);
XComponent xDoc = xLoader.loadComponentFromURL("private:factory/swriter", "_default",
FrameSearchFlag.ALL, new PropertyValue[0]);
return (XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, xDoc);
}
示例6: connect
import com.sun.star.uno.Exception; //导入依赖的package包/类
/**
* (non-Javadoc)
* @see net.heartsome.cat.converter.ooconnect.OPconnect#connect()
* @throws ConnectException
*/
public void connect() throws ConnectException {
try {
XComponentContext localContext;
localContext = Bootstrap.createInitialComponentContext(null);
XMultiComponentFactory localServiceManager = localContext.getServiceManager();
XConnector connector = (XConnector) UnoRuntime.queryInterface(XConnector.class, localServiceManager
.createInstanceWithContext("com.sun.star.connection.Connector", localContext)); //$NON-NLS-1$
XConnection connection = connector.connect(strConnection);
XBridgeFactory bridgeFactory = (XBridgeFactory) UnoRuntime.queryInterface(XBridgeFactory.class,
localServiceManager.createInstanceWithContext("com.sun.star.bridge.BridgeFactory", localContext)); //$NON-NLS-1$
bridge = bridgeFactory.createBridge("ms2ooBridge", "urp", connection, null); //$NON-NLS-1$ //$NON-NLS-2$
bgComponent = (XComponent) UnoRuntime.queryInterface(XComponent.class, bridge);
// bgComponent.addEventListener(this);
serviceMg = (XMultiComponentFactory) UnoRuntime.queryInterface(XMultiComponentFactory.class, bridge
.getInstance("StarOffice.ServiceManager")); //$NON-NLS-1$
XPropertySet properties = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, serviceMg);
componentContext = (XComponentContext) UnoRuntime.queryInterface(XComponentContext.class, properties
.getPropertyValue("DefaultContext")); //$NON-NLS-1$
connected = true;
if (connected) {
System.out.println("has already connected"); //$NON-NLS-1$
} else {
System.out.println("connect to Openoffice fail,please check OpenOffice service that have to open"); //$NON-NLS-1$
}
} catch (NoConnectException connectException) {
throw new ConnectException(MessageFormat.format(Messages.getString("ooconnect.OPConnection.msg"), strConnection + ": " + connectException.getMessage())); //$NON-NLS-1$ //$NON-NLS-2$
} catch (Exception exception) {
throw new OPException(MessageFormat.format(Messages.getString("ooconnect.OPConnection.msg"), strConnection), exception); //$NON-NLS-1$
} catch (java.lang.Exception e) {
if (Converter.DEBUG_MODE) {
e.printStackTrace();
}
}
}
示例7: createButton
import com.sun.star.uno.Exception; //导入依赖的package包/类
/**
* Erzeugt einen Button mit Label und ActionListener.
*
* @param xMCF
* @param context
* @param toolkit
* @param windowPeer
* @param label
* @param listener
* @param size
* @return
* @throws com.sun.star.uno.Exception
*/
public static XControl createButton(XMultiComponentFactory xMCF,
XComponentContext context, XToolkit toolkit, XWindowPeer windowPeer,
String label, XActionListener listener, Rectangle size)
throws com.sun.star.uno.Exception
{
XControl buttonCtrl =
createControl(xMCF, context, toolkit, windowPeer,
"com.sun.star.awt.UnoControlButton", null, null, size);
XButton button = UnoRuntime.queryInterface(XButton.class, buttonCtrl);
button.setLabel(label);
button.addActionListener(listener);
return buttonCtrl;
}
示例8: createTextfield
import com.sun.star.uno.Exception; //导入依赖的package包/类
/**
* Erzeugt ein Texteingabefeld.
*
* @param xMCF
* @param context
* @param toolkit
* @param windowPeer
* @param text
* @param size
* @return
* @throws com.sun.star.uno.Exception
*/
public static XControl createTextfield(XMultiComponentFactory xMCF,
XComponentContext context, XToolkit toolkit, XWindowPeer windowPeer,
String text, Rectangle size) throws com.sun.star.uno.Exception
{
XControl buttonCtrl =
createControl(xMCF, context, toolkit, windowPeer,
"com.sun.star.awt.UnoControlEdit", null, null, size);
XTextComponent txt = UnoRuntime.queryInterface(XTextComponent.class, buttonCtrl);
txt.setText(text);
return buttonCtrl;
}
示例9: createTree
import com.sun.star.uno.Exception; //导入依赖的package包/类
/**
* Erzeugt ein Baum-Steuerelement mit einem vorgegebenen Datenmodell.
* Das Datenmodel kann mit {@link #createTreeModel(XMultiComponentFactory, XComponentContext)}
* erzeugt werden.
*
* @param xMCF
* @param context
* @param toolkit
* @param windowPeer
* @param dataModel
* @return
* @throws Exception
*/
public static XControl createTree(XMultiComponentFactory xMCF,
XComponentContext context, XToolkit toolkit, XWindowPeer windowPeer, XMutableTreeDataModel dataModel) throws Exception
{
XControl treeCtrl =
GuiFactory.createControl(xMCF, context, toolkit, windowPeer,
"com.sun.star.awt.tree.TreeControl", null, null, new Rectangle(0, 0,
400, 400));
XPropertySet props =
UnoRuntime.queryInterface(XPropertySet.class, treeCtrl.getModel());
props.setPropertyValue("DataModel", dataModel);
return treeCtrl;
}
示例10: createCombobox
import com.sun.star.uno.Exception; //导入依赖的package包/类
public static XControl createCombobox(XMultiComponentFactory xMCF,
XComponentContext context, XToolkit toolkit, XWindowPeer windowPeer, String text, Rectangle size)
{
XControl ctrl =
createControl(xMCF, context, toolkit, windowPeer,
"com.sun.star.awt.UnoControlComboBox", null, null, size);
XTextComponent tf = UnoRuntime.queryInterface(XTextComponent.class, ctrl);
tf.setText(text);
XComboBox cmb = UnoRuntime.queryInterface(XComboBox.class, ctrl);
cmb.setDropDownLineCount((short) 10);
try
{
XControlModel model = ctrl.getModel();
// UnoRuntime.queryInterface(XControlModel.class,
// xMCF.createInstanceWithContext("com.sun.star.awt.UnoControlComboBoxModel", context));
XPropertySet props =
UnoRuntime.queryInterface(XPropertySet.class, model);
props.setPropertyValue("Dropdown", Boolean.TRUE);
//props.setPropertyValue("ReadOnly", Boolean.TRUE);
props.setPropertyValue("Autocomplete", Boolean.FALSE);
props.setPropertyValue("HideInactiveSelection", Boolean.TRUE);
ctrl.setModel(model);
ctrl.getPeer().invalidate(InvalidateStyle.UPDATE);
}
catch (Exception e)
{
Logger.error(e);
}
return ctrl;
}
示例11: getXDispatchHelper
import com.sun.star.uno.Exception; //导入依赖的package包/类
public XDispatchHelper getXDispatchHelper() {
try {
return createXDispatchHelper();
} catch (Exception e) {
throw new OpenOfficeException("Unable to create Open office components.", e);
}
}
示例12: getXComponentLoader
import com.sun.star.uno.Exception; //导入依赖的package包/类
public XComponentLoader getXComponentLoader() {
try {
return as(XComponentLoader.class, createDesktop());
} catch (Exception e) {
throw new OpenOfficeException("Unable to create Open office components.", e);
}
}
示例13: convert
import com.sun.star.uno.Exception; //导入依赖的package包/类
private static ByteArrayOutputStream convert(
ByteArrayOutputStream odxStream, String targetFormat,
Map<String, Object> filterParameters) throws BootstrapException,
Exception, IOException {
// TODO: Can this be done once during app init?
XComponentContext xContext = Bootstrap.bootstrap();
OOoStreamConverter converter = new OOoStreamConverter(xContext);
ByteArrayOutputStream generatedPDFOutputStream = new ByteArrayOutputStream();
OOoOutputStream convertedOutputStream = null;
OOoInputStream generatedODFInputStream = null;
try {
convertedOutputStream = null;
generatedODFInputStream = new OOoInputStream(
odxStream.toByteArray());
convertedOutputStream = new OOoOutputStream();
converter.convert(generatedODFInputStream, convertedOutputStream,
targetFormat, filterParameters);
generatedPDFOutputStream.write(convertedOutputStream.toByteArray());
} finally {
IOUtils.closeQuietly(generatedODFInputStream);
IOUtils.closeQuietly(convertedOutputStream);
}
return generatedPDFOutputStream;
}
示例14: createControl
import com.sun.star.uno.Exception; //导入依赖的package包/类
/**
* Eine allgemeine Hilfsfunktion, mit der UNO-Steuerelemente erzeugt werden.
*
* @param xMCF
* @param xContext
* @param toolkit
* @param windowPeer
* @param type Klasse des Steuerelements, das erzeugt werden soll.
* @param propNames
* @param propValues
* @param rectangle
* @return
*/
public static XControl createControl(XMultiComponentFactory xMCF,
XComponentContext xContext, XToolkit toolkit, XWindowPeer windowPeer,
String type, String[] propNames, Object[] propValues, Rectangle rectangle)
{
try
{
XControl control =
UnoRuntime.queryInterface(XControl.class,
xMCF.createInstanceWithContext(type, xContext));
XControlModel controlModel =
UnoRuntime.queryInterface(XControlModel.class,
xMCF.createInstanceWithContext(type + "Model", xContext));
control.setModel(controlModel);
XMultiPropertySet properties =
UnoRuntime.queryInterface(XMultiPropertySet.class, control.getModel());
SortedMap<String, Object> props = new TreeMap<String, Object>();
if (type.equals("com.sun.star.awt.UnoControlImageControl"))
{
props.put("Border", (short) 0);
}
else if (type.equals("com.sun.star.awt.UnoControlEdit"))
{
props.put("MultiLine", false);
props.put("ReadOnly", false);
props.put("VScroll", false);
}
if (propNames != null)
{
for (int i = 0; i < propNames.length; i++)
{
props.put(propNames[i], propValues[i]);
}
}
if (props.size() > 0)
{
properties.setPropertyValues(
props.keySet().toArray(new String[props.size()]),
props.values().toArray(new Object[props.size()]));
}
control.createPeer(toolkit, windowPeer);
XWindow controlWindow = UnoRuntime.queryInterface(XWindow.class, control);
setWindowPosSize(controlWindow, rectangle);
return control;
}
catch (com.sun.star.uno.Exception ex)
{
Logger.debug(ex);
return null;
}
}
示例15: OfficeResourceProvider
import com.sun.star.uno.Exception; //导入依赖的package包/类
public OfficeResourceProvider(XComponentContext xComponentContext, OfficeIntegration officeIntegration) throws Exception {
this.xComponentContext = xComponentContext;
this.officeIntegration = officeIntegration;
}