com.sun.star.util.XRefreshable Java Examples

The following examples show how to use com.sun.star.util.XRefreshable. 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: StandardConversionTask.java    From kkFileViewOfficeEdit with Apache License 2.0 5 votes vote down vote up
@Override
protected void modifyDocument(XComponent document) throws OfficeException {
    XRefreshable refreshable = cast(XRefreshable.class, document);
    if (refreshable != null) {
        refreshable.refresh();
    }
}
 
Example #2
Source File: StandardConversionTask.java    From kkFileView with Apache License 2.0 5 votes vote down vote up
@Override
protected void modifyDocument(XComponent document) throws OfficeException {
    XRefreshable refreshable = cast(XRefreshable.class, document);
    if (refreshable != null) {
        refreshable.refresh();
    }
}
 
Example #3
Source File: StandardConversionTask.java    From wenku with MIT License 5 votes vote down vote up
@Override
protected void modifyDocument(XComponent document) throws OfficeException {
    XRefreshable refreshable = cast(XRefreshable.class, document);
    if (refreshable != null) {
        refreshable.refresh();
    }
}
 
Example #4
Source File: TextFieldService.java    From noa-libre with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Refreshes all textfields.
 * 
 * @throws TextException
 *             if refresh fails
 * 
 * @author Markus Krüger
 * @date 29.05.2007
 */
public void refresh() throws TextException {
	try {
		XTextFieldsSupplier xTextFieldsSupplier = (XTextFieldsSupplier) UnoRuntime
				.queryInterface(XTextFieldsSupplier.class,
						textDocument.getXTextDocument());
		XRefreshable xRefreshable = (XRefreshable) UnoRuntime
				.queryInterface(XRefreshable.class,
						xTextFieldsSupplier.getTextFields());
		xRefreshable.refresh();
	} catch (Exception exception) {
		throw new TextException(exception);
	}
}
 
Example #5
Source File: AbstractOpenOfficeDocumentConverter.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Refresh document.
 * @param document
 *            the document
 */
protected void refreshDocument(XComponent document) {
	XRefreshable refreshable = (XRefreshable) UnoRuntime.queryInterface(XRefreshable.class, document);
	if (refreshable != null) {
		refreshable.refresh();
	}
}
 
Example #6
Source File: AbstractOpenOfficeDocumentConverter.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Refresh document.
 * @param document
 *            the document
 */
protected void refreshDocument(XComponent document) {
	XRefreshable refreshable = (XRefreshable) UnoRuntime.queryInterface(XRefreshable.class, document);
	if (refreshable != null) {
		refreshable.refresh();
	}
}
 
Example #7
Source File: JodConverterMetadataExtracterWorker.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void execute(OfficeContext context)
{
    if (logger.isDebugEnabled())
    {
        logger.debug("Extracting metadata from file " + inputFile);
    }

    XComponent document = null;
    try
    {
        if (!inputFile.exists())
        {
            throw new OfficeException("input document not found");
        }
        XComponentLoader loader = cast(XComponentLoader.class, context
                .getService(SERVICE_DESKTOP));
        
        // Need to set the Hidden property to ensure that OOo GUI does not appear.
        PropertyValue hiddenOOo = new PropertyValue();
        hiddenOOo.Name = "Hidden";
        hiddenOOo.Value = Boolean.TRUE;
        PropertyValue readOnly = new PropertyValue();
        readOnly.Name = "ReadOnly";
        readOnly.Value = Boolean.TRUE;

        try
        {
            document = loader.loadComponentFromURL(toUrl(inputFile), "_blank", 0,
                    new PropertyValue[]{hiddenOOo, readOnly});
        } 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();
        }

        XDocumentInfoSupplier docInfoSupplier = cast(XDocumentInfoSupplier.class, document);
        XPropertySet propSet = cast(XPropertySet.class, docInfoSupplier.getDocumentInfo());

        // The strings below are property names as used by OOo. They need upper-case
        // initial letters.
        Object author = getPropertyValueIfAvailable(propSet, "Author");
        Object description = getPropertyValueIfAvailable(propSet, "Subject");
        Object title = getPropertyValueIfAvailable(propSet, "Title");
        
        Map<String, Serializable> results = new HashMap<String, Serializable>(3);
        results.put(KEY_AUTHOR, author == null ? null : author.toString());
        results.put(KEY_DESCRIPTION, description == null ? null : description.toString());
        results.put(KEY_TITLE, title == null ? null : title.toString());
        callback.setResults(results);
    } 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();
            }
        }
    }
}
 
Example #8
Source File: TextDocument.java    From noa-libre with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * Updates/refreshes the document.
 * 
 * @author Markus Krüger
 * @date 11.02.2008
 */
public void update() {
  ((XRefreshable) UnoRuntime.queryInterface(XRefreshable.class, xTextDocument)).refresh();
}