com.sun.star.lang.WrappedTargetException Java Examples

The following examples show how to use com.sun.star.lang.WrappedTargetException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Annotation.java    From noa-libre with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Returns the text content of the annotation, or null if text content is not available.
 * 
 * @return the text content of the annotation, or null
 * 
 * @author Markus Krüger
 * @date 13.07.2006
 */
public String getText() {
  XServiceInfo info = (XServiceInfo) UnoRuntime.queryInterface(XServiceInfo.class, getXTextContent());
  if(info.supportsService(ITextFieldService.ANNOTATION_TEXTFIELD_ID)) {
    XPropertySet properties = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, getXTextContent());
    try {
      return (String) properties.getPropertyValue("Content");
    }
    catch(UnknownPropertyException unknownPropertyException) {
      //TODO exception handling if needed, do nothing for now
    }
    catch(WrappedTargetException wrappedTargetException) {
      //TODO exception handling if needed, do nothing for now
    }
  }
  return null;
}
 
Example #2
Source File: Annotation.java    From noa-libre with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Returns the text content of the annotation, or null if text content is not available.
 * 
 * @return the text content of the annotation, or null
 * 
 * @author Markus Krüger
 * @date 13.07.2006
 */
public String getText() {
  XServiceInfo info = (XServiceInfo) UnoRuntime.queryInterface(XServiceInfo.class, getXTextContent());
  if(info.supportsService(ITextFieldService.ANNOTATION_TEXTFIELD_ID)) {
    XPropertySet properties = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, getXTextContent());
    try {
      return (String) properties.getPropertyValue("Content");
    }
    catch(UnknownPropertyException unknownPropertyException) {
      //TODO exception handling if needed, do nothing for now
    }
    catch(WrappedTargetException wrappedTargetException) {
      //TODO exception handling if needed, do nothing for now
    }
  }
  return null;
}
 
Example #3
Source File: JodConverterMetadataExtracterWorker.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * OOo throws exceptions if we ask for properties that aren't there, so we'll tread carefully.
 * 
 * @param propSet
 * @param propertyName property name as used by the OOo API.
 * @return the propertyValue if it's there, else null.
 * @throws UnknownPropertyException
 * @throws WrappedTargetException
 */
private Object getPropertyValueIfAvailable(XPropertySet propSet, String propertyName)
        throws UnknownPropertyException, WrappedTargetException
{
    if (propSet.getPropertySetInfo().hasPropertyByName(propertyName))
    {
        return propSet.getPropertyValue(propertyName);
    }
    else
    {
        return null;
    }
}
 
Example #4
Source File: ActionOneDialog.java    From libreoffice-starter-extension with MIT License 5 votes vote down vote up
@Override
public boolean callHandlerMethod(XDialog dialog, Object eventObject, String methodName) throws WrappedTargetException {
	if (methodName.equals(actionOk)) {
		onOkButtonPressed();
		return true; // Event was handled
	}
	return false; // Event was not handled
}
 
Example #5
Source File: DialogHelper.java    From libreoffice-starter-extension with MIT License 5 votes vote down vote up
public static void EnableButton(XDialog dialog, String componentId, boolean enable) {
	XControlContainer xDlgContainer = (XControlContainer) UnoRuntime.queryInterface(XControlContainer.class,
			dialog);
	// retrieve the control that we want to disable or enable
	XControl xControl = UnoRuntime.queryInterface(XControl.class, xDlgContainer.getControl(componentId));
	XPropertySet xModelPropertySet = UnoRuntime.queryInterface(XPropertySet.class, xControl.getModel());
	try {
		xModelPropertySet.setPropertyValue("Enabled", Boolean.valueOf(enable));
	} catch (IllegalArgumentException | UnknownPropertyException | PropertyVetoException
			| WrappedTargetException e) {
		return;
	}
}
 
Example #6
Source File: DialogHelper.java    From libreoffice-starter-extension with MIT License 5 votes vote down vote up
public static void setPosition(XDialog dialog, int posX, int posY) {
	XControlModel xDialogModel = UnoRuntime.queryInterface(XControl.class, dialog).getModel();
	XPropertySet xPropSet = UnoRuntime.queryInterface(XPropertySet.class, xDialogModel);
	try {
		xPropSet.setPropertyValue("PositionX", posX);
		xPropSet.setPropertyValue("PositionY", posY);
	} catch (com.sun.star.lang.IllegalArgumentException | UnknownPropertyException | PropertyVetoException
			| WrappedTargetException e) {
		return;
	}
}
 
Example #7
Source File: DialogHelper.java    From libreoffice-starter-extension with MIT License 5 votes vote down vote up
public static Point getPosition(XDialog dialog) {
	int posX = 0;
	int posY = 0;
	XControlModel xDialogModel = UnoRuntime.queryInterface(XControl.class, dialog).getModel();
	XPropertySet xPropSet = UnoRuntime.queryInterface(XPropertySet.class, xDialogModel);
	try {
		posX = (int) xPropSet.getPropertyValue("PositionX");
		posY = (int) xPropSet.getPropertyValue("PositionY");
	} catch (UnknownPropertyException | WrappedTargetException e) {
	}
	return new Point(posX, posY);
}
 
Example #8
Source File: TextContentService.java    From noa-libre with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Some cleanup for text image.
 * 
 * @param textContent the text image as text content
 * 
 * @throws WrappedTargetException if cleanup fails
 * @throws NoSuchElementException if cleanup fails
 * 
 * @author Jan Reimann
 * @date 20.08.2009
 */
private void cleanupImage(ITextContent textContent) throws NoSuchElementException,
    WrappedTargetException {
  if (textContent instanceof ITextDocumentImage && imageToImageIds != null
      && xBitmapContainer != null) {
    String id = imageToImageIds.get(textContent);
    if (id != null) {
      imageToImageIds.remove(textContent);
      xBitmapContainer.removeByName(id);
    }
    ((ITextDocumentImage) textContent).getGraphicInfo().cleanUp();
  }
}
 
Example #9
Source File: TextContentService.java    From noa-libre with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Some cleanup for text shape.
 * 
 * @param textContent the text shape as text content
 * 
 * @throws WrappedTargetException if cleanup fails
 * @throws NoSuchElementException if cleanup fails
 * 
 * @author Jan Reimann
 * @date 20.08.2009
 */
private void cleanupTextShape(ITextContent textContent) throws NoSuchElementException,
    WrappedTargetException {
  if (textContent instanceof ITextDocumentTextShape && textShapeToTextShapeIds != null
      && xTextShapeContainer != null) {
    String id = textShapeToTextShapeIds.get(textContent);
    if (id != null) {
      textShapeToTextShapeIds.remove(textContent);
      xTextShapeContainer.removeByName(id);
    }
  }
}
 
Example #10
Source File: DocFormatter.java    From yarg with Apache License 2.0 5 votes vote down vote up
protected void fillRow(BandData band, TableManager tableManager, int row)
        throws com.sun.star.lang.IndexOutOfBoundsException, NoSuchElementException, WrappedTargetException {
    List<String> cellNamesForTheRow = tableManager.getCellNamesForTheRow(row);
    for (int col = 0; col < cellNamesForTheRow.size(); col++) {
        fillCell(band, tableManager.getXCell(col, row));
    }
}
 
Example #11
Source File: DocFormatter.java    From yarg with Apache License 2.0 5 votes vote down vote up
protected void fillCell(BandData band, XCell xCell) throws NoSuchElementException, WrappedTargetException {
    checkThreadInterrupted();
    XText xText = as(XText.class, xCell);
    String cellText = xText.getString();
    cellText = cellText.replace("\r\n", "\n");//just a workaround for Windows \r\n break symbol
    List<String> parametersToInsert = new ArrayList<String>();
    Matcher matcher = UNIVERSAL_ALIAS_PATTERN.matcher(cellText);
    while (matcher.find()) {
        parametersToInsert.add(unwrapParameterName(matcher.group()));
    }
    for (String parameterName : parametersToInsert) {
        XTextCursor xTextCursor = xText.createTextCursor();

        String paramStr = "${" + parameterName + "}";
        int index = cellText.indexOf(paramStr);
        while (index >= 0) {
            xTextCursor.gotoStart(false);
            xTextCursor.goRight((short) (index + paramStr.length()), false);
            xTextCursor.goLeft((short) paramStr.length(), true);

            insertValue(xText, xTextCursor, band, parameterName);
            cellText = formatCellText(xText.getString());

            index = cellText.indexOf(paramStr);
        }
    }
}
 
Example #12
Source File: TableManager.java    From yarg with Apache License 2.0 4 votes vote down vote up
public TableManager(XComponent xComponent, String tableName) throws NoSuchElementException, WrappedTargetException {
    xTextTable = getTableByName(xComponent, tableName);
    this.tableName = tableName;
}
 
Example #13
Source File: TableManager.java    From yarg with Apache License 2.0 4 votes vote down vote up
public static XTextTable getTableByName(XComponent xComponent, String tableName) throws NoSuchElementException, WrappedTargetException {
    XNameAccess tables = as(XTextTablesSupplier.class, xComponent).getTextTables();
    return (XTextTable) ((Any) tables.getByName(tableName)).getObject();
}