Java Code Examples for com.sun.star.beans.XPropertySet#getPropertyValue()

The following examples show how to use com.sun.star.beans.XPropertySet#getPropertyValue() . 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: VariableTextFieldHelper.java    From noa-libre with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Applies the given number format to the given variable text field.
 * 
 * @param numberFormat the number format to be set
 * @param variableTextField the variable text field to set number forma for
 * @param isFormula if the variable text field is a formula
 * @param numberFormatService the number format service to be used
 * 
 * @throws NOAException if setting the number format fails
 * 
 * @author Markus Krüger
 * @date 27.07.2007
 */
public static void applyNumberFormat(INumberFormat numberFormat, ITextField variableTextField,
    boolean isFormula, INumberFormatService numberFormatService) throws NOAException {
  try {
    if(numberFormat == null || variableTextField == null || numberFormatService == null)
      return;
    XPropertySet xPropertySetField = 
      (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, variableTextField.getXTextContent());
    String content = (String)xPropertySetField.getPropertyValue("Content");      
    xPropertySetField.setPropertyValue("NumberFormat", new Integer(numberFormat.getFormatKey()));
    setContent(content,variableTextField,isFormula,numberFormatService);
  }
  catch(Throwable throwable) {
    throw new NOAException(throwable);
  }
}
 
Example 2
Source File: NumberFormatService.java    From noa-libre with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Returns number format on the basis of the submitted key.
 * 
 * @param key key of the number format
 * 
 * @return number format on the basis of the submitted key
 * 
 * @throws UtilException if the number format is not available
 * 
 * @author Andreas Bröker
 * @author Markus Krüger
 */
public INumberFormat getNumberFormat(int key) throws UtilException {
  INumberFormat[] allFormats = getNumberFormats();
  for(int i = 0; i < allFormats.length; i++) {
    if(key == allFormats[i].getFormatKey())
      return allFormats[i];
  }
  try {
    XNumberFormats xNumberFormats = xNumberFormatsSupplier.getNumberFormats();
    XPropertySet docProps = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, textDocument.getXTextDocument());
    Locale docLocale = (Locale) docProps.getPropertyValue("CharLocale");
    XNumberFormatTypes numberFormatTypes = (XNumberFormatTypes)UnoRuntime.queryInterface(XNumberFormatTypes.class, xNumberFormats);
    int newKey = numberFormatTypes.getFormatForLocale(key,docLocale);
    for(int i = 0; i < allFormats.length; i++) {
      if(newKey == allFormats[i].getFormatKey())
        return allFormats[i];
    }
  }
  catch(Exception exception) {
    UtilException utilException = new UtilException(exception.getMessage());
    utilException.initCause(exception);
    throw utilException;
  }
  throw new UtilException("The number format is not available.");
}
 
Example 3
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 4
Source File: RemoteOfficeConnection.java    From noa-libre with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Opens connection to OpenOffice.org.
 * 
 * @return information whether the connection is available
 * 
 * @throws Exception if any error occurs
 */
public boolean openConnection() throws Exception {
  String unoUrl = "uno:socket,host=" + host + ",port=" + port +";urp;StarOffice.ServiceManager";
  XComponentContext xLocalContext = Bootstrap.createInitialComponentContext(null);
  Object connector = xLocalContext.getServiceManager().createInstanceWithContext("com.sun.star.connection.Connector", xLocalContext);
  XConnector xConnector = (XConnector) UnoRuntime.queryInterface(XConnector.class, connector);
  
  String url[] = parseUnoUrl(unoUrl);
  if (null == url) {
    throw new com.sun.star.uno.Exception("Couldn't parse UNO URL "+ unoUrl);
  }
  
  XConnection connection = xConnector.connect(url[0]);
  Object bridgeFactory = xLocalContext.getServiceManager().createInstanceWithContext("com.sun.star.bridge.BridgeFactory", xLocalContext);
  XBridgeFactory xBridgeFactory = (XBridgeFactory) UnoRuntime.queryInterface(XBridgeFactory.class, bridgeFactory);
  xBridge = xBridgeFactory.createBridge("", url[1], connection ,null);
  bridgeFactory = xBridge.getInstance(url[2]);
  xMultiComponentFactory = (XMultiComponentFactory)UnoRuntime.queryInterface(XMultiComponentFactory.class, bridgeFactory);
  XPropertySet xProperySet = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xMultiComponentFactory);
  Object remoteContext = xProperySet.getPropertyValue("DefaultContext");
  xRemoteContext = (XComponentContext) UnoRuntime.queryInterface(XComponentContext.class, remoteContext);
  xMultiServiceFactory = (XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class, xMultiComponentFactory);
  isConnectionEstablished = true;
  return true;      
}
 
Example 5
Source File: TextContentEnumeration.java    From noa-libre with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Returns all available text fields.
 * 
 * @return all available text fields
 * 
 * @author Andreas Bröker
 */
public ITextField[] getTextFields() {
  ArrayList arrayList = new ArrayList();    
  XTextCursor textCursor = xTextRange.getText().createTextCursorByRange(xTextRange.getStart());
  XTextRangeCompare xTextRangeCompare = (XTextRangeCompare)UnoRuntime.queryInterface(XTextRangeCompare.class, xTextRange.getText());
  try {      
    while(xTextRangeCompare.compareRegionEnds(textCursor.getStart(), xTextRange.getEnd()) != -1) {
      XPropertySet propertySet = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, textCursor);
      Any any = (Any)propertySet.getPropertyValue("TextField");
      XTextField xTextField = (XTextField)any.getObject();  
      if(xTextField != null)
        arrayList.add(new TextField(textDocument, xTextField));
      if(!textCursor.goRight((short)1, false)) 
        break;
    }
  }
  catch(Exception exception) {
    //do nothing
  }
  
  ITextField[] textFields = new ITextField[arrayList.size()];
  return (ITextField[])arrayList.toArray(textFields);    
}
 
Example 6
Source File: TextTableCell.java    From noa-libre with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Returns text table of the cell.
 * 
 * @return text table of the cell
 * 
 * @throws TextException if the text table is not available
 * 
 * @author Andreas Bröker
 * @author Markus Krüger
 */
public ITextTable getTextTable() throws TextException {
  if(textTable == null) {
    try {
      XText xText = (XText)UnoRuntime.queryInterface(XText.class, xCell);
      XPropertySet xPropertySet = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xText.getStart());
      Any any = (Any)xPropertySet.getPropertyValue("TextTable");
      XTextTable xTextTable = (XTextTable)any.getObject();
      textTable =  new TextTable(textDocument, xTextTable);
    }
    catch(Exception exception) {
      TextException textException = new TextException(exception.getMessage());
      textException.initCause(exception);
      throw textException;
    }
  }
  return textTable;
}
 
Example 7
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 8
Source File: TextTableRow.java    From noa-libre with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Returns the row height.
 * 
 * @return the row height
 * 
 * @author Markus Krüger
 */
public int getHeight() {
  if(textTableCellRange == null)
    return 0;
  try {
    
    XTextTable xTextTable = (XTextTable)textTableCellRange.getCell(0,0).getTextTable().getXTextContent();
    XTableRows tableRows = xTextTable.getRows();
    Object row = tableRows.getByIndex(textTableCellRange.getRangeName().getRangeStartRowIndex());
    XPropertySet propertySetRow = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, row);
    Integer rowHeight = (Integer)propertySetRow.getPropertyValue("Height");
    return rowHeight.intValue();
  }
  catch (Exception exception) {
    return 0;
  }
}
 
Example 9
Source File: TextTableRow.java    From noa-libre with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Returns if the row height is set to automatically be adjusted or not.
 * 
 * @return if the row height is set to automatically be adjusted or not
 * 
 * @author Markus Krüger
 */
public boolean getAutoHeight() {
  if(textTableCellRange == null)
    return false;
  try {      
    XTextTable xTextTable = (XTextTable)textTableCellRange.getCell(0,0).getTextTable().getXTextContent();
    XTableRows tableRows = xTextTable.getRows();
    int rowIndex = textTableCellRange.getRangeName().getRangeStartRowIndex();
    Object row = tableRows.getByIndex(rowIndex);
    XPropertySet propertySetRow = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, row);
    Boolean rowAutoHeight = (Boolean)propertySetRow.getPropertyValue("IsAutoHeight");      
    return rowAutoHeight.booleanValue();
  }
  catch (Exception exception) {
    return false;
  }
}
 
Example 10
Source File: AbstractInliner.java    From yarg with Apache License 2.0 5 votes vote down vote up
protected void setImageSize(int width, int height, Object oImage, XPropertySet imageProperties)
        throws Exception {
    Size aActualSize = (Size) imageProperties.getPropertyValue("ActualSize");
    aActualSize.Height = height * IMAGE_FACTOR;
    aActualSize.Width = width * IMAGE_FACTOR;
    XShape xShape = as(XShape.class, oImage);
    xShape.setSize(aActualSize);
}
 
Example 11
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 12
Source File: NumberFormatService.java    From noa-libre with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Returns all available number formats of the given type.
 * 
 * @param type the type to get all number formats for as constants of {@link com.sun.star.util.NumberFormat}
 * 
 * @return all available number formats of the given type
 * 
 * @throws UtilException if the number formats are not available
 * 
 * @author Markus Krüger
 * @date 25.07.2007
 */
public INumberFormat[] getNumberFormats(short type) throws UtilException {
  try {
    XNumberFormats xNumberFormats = xNumberFormatsSupplier.getNumberFormats();
    XPropertySet docProps = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, textDocument.getXTextDocument());
    Locale docLocale = (Locale) docProps.getPropertyValue("CharLocale");
    //XNumberFormatTypes numberFormatTypes = (XNumberFormatTypes)UnoRuntime.queryInterface(XNumberFormatTypes.class, xNumberFormats);
    int[] keys = xNumberFormats.queryKeys(type,docLocale,true);
    List<INumberFormat> formats = new ArrayList<INumberFormat>();
    boolean additionalCurrenciesSet = false;
    for(int i = 0; i < keys.length; i++) {
      int key = keys[i];
      XPropertySet xProp = xNumberFormats.getByKey(key);
      if(((Short)xProp.getPropertyValue("Type")).equals(new Short(com.sun.star.util.NumberFormat.CURRENCY)) &&
          !additionalCurrenciesSet) {
        for(int j = 0; j < ADDITIONAL_CURRENCY_KEYS.length; j++) {
          XPropertySet xPropAdd = xNumberFormats.getByKey(ADDITIONAL_CURRENCY_KEYS[j]);
          formats.add(new NumberFormat(ADDITIONAL_CURRENCY_KEYS[j],xPropAdd,this));
        }
        additionalCurrenciesSet = true;
      }
      formats.add(new NumberFormat(key,xProp,this));
    }
    return formats.toArray(new INumberFormat[formats.size()]);
  }
  catch(Exception exception) {
    UtilException utilException = new UtilException(exception.getMessage());
    utilException.initCause(exception);
    throw utilException;
  }
}
 
Example 13
Source File: Frame.java    From noa-libre with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Returns layout manager of the frame. Returns null if a layout manager
 * is not available.
 * 
 * @return layout manager of the frame or null if a layout manager
 * is not available
 * 
 * @throws NOAException if the layout manager can not be requested
 * 
 * @author Andreas Bröker
 * @date 2006/02/05
 */
public ILayoutManager getLayoutManager() throws NOAException {
	try {
		XPropertySet propertySet = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xFrame);
		Object object = propertySet.getPropertyValue("LayoutManager");
		XLayoutManager layoutManager = (XLayoutManager)UnoRuntime.queryInterface(XLayoutManager.class, object);
		if(layoutManager != null)
			return new LayoutManager(layoutManager);
	}
	catch(Throwable throwable) {
		throw new NOAException(throwable);
	}
	return null;
}
 
Example 14
Source File: TextTable.java    From noa-libre with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Marks the table.
 * 
 * @author Markus Krüger
 * @date 06.08.2007
 */
public void markTable() {
  try {
    String firstCell = "A1";
    String range = firstCell + ":";
    ITextTableRow[] rows = getRows();
    if (rows.length > 0) {
      ITextTableCell[] cells = rows[rows.length - 1].getCells();
      String lastCellName = cells[cells.length - 1].getName().getName();
      range = range + TextTableCellNameHelper.getColumnCharacter(lastCellName)
          + TextTableCellNameHelper.getRowCounterValue(lastCellName);
      ITextTableCellRange cellRange = getCellRange(range);
      ITextDocument textDocument = getTextDocument();
      if (textDocument.isOpen()) {
        XCell cell = getXTextTable().getCellByName(firstCell);
        XPropertySet xPropertySet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,
            cell);
        if (xPropertySet != null) {
          Object value = xPropertySet.getPropertyValue("TextSection");
          boolean select = true;
          XTextSection xTextSection = (XTextSection) UnoRuntime.queryInterface(XTextSection.class,
              value);
          if (xTextSection != null) {
            XPropertySet xTextSectionPropertySet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,
                xTextSection);
            if (xTextSectionPropertySet != null) {
              Boolean visible = (Boolean) xTextSectionPropertySet.getPropertyValue("IsVisible");
              select = visible.booleanValue();
            }
          }
          if (select)
            textDocument.setSelection(new XInterfaceObjectSelection(cellRange.getXCellRange()));
        }
      }
    }
  }
  catch (Throwable throwable) {
    //no marking possible
  }
}
 
Example 15
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 16
Source File: OpenOfficeWorker.java    From scipio-erp with Apache License 2.0 5 votes vote down vote up
public static List<String> getFilterNames(XMultiComponentFactory xmulticomponentfactory) throws Exception {
    XPropertySet xPropertySet = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xmulticomponentfactory);
    Object oDefaultContext = xPropertySet.getPropertyValue("DefaultContext");
    XComponentContext xComponentContext = (XComponentContext) UnoRuntime.queryInterface(XComponentContext.class, oDefaultContext);


    Object filterFactory = xmulticomponentfactory.createInstanceWithContext("com.sun.star.document.FilterFactory", xComponentContext);
    XNameAccess xNameAccess = (XNameAccess)UnoRuntime.queryInterface(XNameAccess.class, filterFactory);
    String [] filterNames = xNameAccess.getElementNames();

    //String [] serviceNames = filterFactory.getAvailableServiceNames();
    for (int i=0; i < filterNames.length; i++) {
        String s = filterNames[i];
        Debug.logInfo(s, module);
        /*
        if (s.toLowerCase().indexOf("filter") >= 0) {
            Debug.logInfo("FILTER: " + s, module);
        }
        if (s.toLowerCase().indexOf("desktop") >= 0) {
            Debug.logInfo("DESKTOP: " + s, module);
        }
        */
    }

    List<String> filterNameList = UtilMisc.toListArray(filterNames);
    return filterNameList;
}
 
Example 17
Source File: OpenOfficeWorker.java    From scipio-erp with Apache License 2.0 4 votes vote down vote up
public static OpenOfficeByteArrayOutputStream convertOODocByteStreamToByteStream(XMultiComponentFactory xmulticomponentfactory,
        OpenOfficeByteArrayInputStream is, String inputMimeType, String outputMimeType) throws Exception {

    // Query for the XPropertySet interface.
    XPropertySet xpropertysetMultiComponentFactory = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xmulticomponentfactory);

    // Get the default context from the office server.
    Object objectDefaultContext = xpropertysetMultiComponentFactory.getPropertyValue("DefaultContext");

    // Query for the interface XComponentContext.
    XComponentContext xcomponentcontext = (XComponentContext) UnoRuntime.queryInterface(XComponentContext.class, objectDefaultContext);

    /* A desktop environment contains tasks with one or more
       frames in which components can be loaded. Desktop is the
       environment for components which can instanciate within
       frames. */

    Object desktopObj = xmulticomponentfactory.createInstanceWithContext("com.sun.star.frame.Desktop", xcomponentcontext);
    //XDesktop desktop = (XDesktop) UnoRuntime.queryInterface(XDesktop.class, desktopObj);
    XComponentLoader xcomponentloader = (XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class, desktopObj);

    // Preparing properties for loading the document
    PropertyValue propertyvalue[] = new PropertyValue[2];
    // Setting the flag for hidding the open document
    propertyvalue[0] = new PropertyValue();
    propertyvalue[0].Name = "Hidden";
    propertyvalue[0].Value = Boolean.TRUE;
    //
    propertyvalue[1] = new PropertyValue();
    propertyvalue[1].Name = "InputStream";
    propertyvalue[1].Value = is;

    // Loading the wanted document
    Object objectDocumentToStore = xcomponentloader.loadComponentFromURL("private:stream", "_blank", 0, propertyvalue);
    if (objectDocumentToStore == null) {
        Debug.logError("Could not get objectDocumentToStore object from xcomponentloader.loadComponentFromURL", module);
    }

    // Getting an object that will offer a simple way to store a document to a URL.
    XStorable xstorable = (XStorable) UnoRuntime.queryInterface(XStorable.class, objectDocumentToStore);
    if (xstorable == null) {
        Debug.logError("Could not get XStorable object from UnoRuntime.queryInterface", module);
    }

    // Preparing properties for converting the document
    String filterName = getFilterNameFromMimeType(outputMimeType);
    propertyvalue = new PropertyValue[4];

    propertyvalue[0] = new PropertyValue();
    propertyvalue[0].Name = "OutputStream";
    OpenOfficeByteArrayOutputStream os = new OpenOfficeByteArrayOutputStream();
    propertyvalue[0].Value = os;
    // Setting the filter name
    propertyvalue[1] = new PropertyValue();
    propertyvalue[1].Name = "FilterName";
    propertyvalue[1].Value = filterName;
    // Setting the flag for overwriting
    propertyvalue[3] = new PropertyValue();
    propertyvalue[3].Name = "Overwrite";
    propertyvalue[3].Value = Boolean.TRUE;
    // For PDFs
    propertyvalue[2] = new PropertyValue();
    propertyvalue[2].Name = "CompressionMode";
    propertyvalue[2].Value = "1";

    xstorable.storeToURL("private:stream", propertyvalue);
    //xstorable.storeToURL("file:///home/byersa/testdoc1_file.pdf", propertyvalue);

    // Getting the method dispose() for closing the document
    XComponent xcomponent = (XComponent) UnoRuntime.queryInterface(XComponent.class, xstorable);

    // Closing the converted document
    xcomponent.dispose();

    return os;
}
 
Example 18
Source File: OpenOfficeWorker.java    From scipio-erp with Apache License 2.0 4 votes vote down vote up
public static void convertOODocToFile(XMultiComponentFactory xmulticomponentfactory, String fileInPath, String fileOutPath, String outputMimeType) throws FileNotFoundException, IOException, MalformedURLException, Exception {
    // Converting the document to the favoured type
    // Query for the XPropertySet interface.
    XPropertySet xpropertysetMultiComponentFactory = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xmulticomponentfactory);

    // Get the default context from the office server.
    Object objectDefaultContext = xpropertysetMultiComponentFactory.getPropertyValue("DefaultContext");

    // Query for the interface XComponentContext.
    XComponentContext xcomponentcontext = (XComponentContext) UnoRuntime.queryInterface(XComponentContext.class, objectDefaultContext);

    /* A desktop environment contains tasks with one or more
       frames in which components can be loaded. Desktop is the
       environment for components which can instanciate within
       frames. */

    Object desktopObj = xmulticomponentfactory.createInstanceWithContext("com.sun.star.frame.Desktop", xcomponentcontext);
    //XDesktop desktop = (XDesktop) UnoRuntime.queryInterface(XDesktop.class, desktopObj);
    XComponentLoader xcomponentloader = (XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class, desktopObj);


    // Preparing properties for loading the document
    PropertyValue propertyvalue[] = new PropertyValue[ 2 ];
    // Setting the flag for hidding the open document
    propertyvalue[ 0 ] = new PropertyValue();
    propertyvalue[ 0 ].Name = "Hidden";
    propertyvalue[ 0 ].Value = Boolean.valueOf(false);

    propertyvalue[ 1 ] = new PropertyValue();
    propertyvalue[ 1 ].Name = "UpdateDocMode";
    propertyvalue[ 1 ].Value = "1";

    // Loading the wanted document
    String stringUrl = convertToUrl(fileInPath, xcomponentcontext);
    Debug.logInfo("stringUrl:" + stringUrl, module);
    Object objectDocumentToStore = xcomponentloader.loadComponentFromURL(stringUrl, "_blank", 0, propertyvalue);

    // Getting an object that will offer a simple way to store a document to a URL.
    XStorable xstorable = (XStorable) UnoRuntime.queryInterface(XStorable.class, objectDocumentToStore);

    // Preparing properties for converting the document
    propertyvalue = new PropertyValue[ 3 ];
    // Setting the flag for overwriting
    propertyvalue[ 0 ] = new PropertyValue();
    propertyvalue[ 0 ].Name = "Overwrite";
    propertyvalue[ 0 ].Value = Boolean.valueOf(true);
    // Setting the filter name
    // Preparing properties for converting the document
    String filterName = getFilterNameFromMimeType(outputMimeType);

    propertyvalue[ 1 ] = new PropertyValue();
    propertyvalue[ 1 ].Name = "FilterName";
    propertyvalue[ 1 ].Value = filterName;

    propertyvalue[2] = new PropertyValue();
    propertyvalue[2].Name = "CompressionMode";
    propertyvalue[2].Value = "1";

    // Storing and converting the document
    //File newFile = new File(stringConvertedFile);
    //newFile.createNewFile();

    String stringConvertedFile = convertToUrl(fileOutPath, xcomponentcontext);
    Debug.logInfo("stringConvertedFile: "+stringConvertedFile, module);
    xstorable.storeToURL(stringConvertedFile, propertyvalue);

    // Getting the method dispose() for closing the document
    XComponent xcomponent = (XComponent) UnoRuntime.queryInterface(XComponent.class, xstorable);

    // Closing the converted document
    xcomponent.dispose();
    return;
}