com.sun.star.uno.Type Java Examples

The following examples show how to use com.sun.star.uno.Type. 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: MemoryUsage.java    From kkFileViewOfficeEdit with Apache License 2.0 6 votes vote down vote up
private XSpreadsheet createSpreadsheet(XScriptContext ctxt)
    throws Exception
{
    XComponentLoader loader = (XComponentLoader)
        UnoRuntime.queryInterface(
            XComponentLoader.class, ctxt.getDesktop());

    XComponent comp = loader.loadComponentFromURL(
        "private:factory/scalc", "_blank", 4, new PropertyValue[0]);

    XSpreadsheetDocument doc = (XSpreadsheetDocument)
        UnoRuntime.queryInterface(XSpreadsheetDocument.class, comp);

    XIndexAccess index = (XIndexAccess)
        UnoRuntime.queryInterface(XIndexAccess.class, doc.getSheets());

    XSpreadsheet sheet = (XSpreadsheet) AnyConverter.toObject(
        new Type(com.sun.star.sheet.XSpreadsheet.class), index.getByIndex(0));

    return sheet;
}
 
Example #2
Source File: MemoryUsage.java    From kkFileView with Apache License 2.0 6 votes vote down vote up
private XSpreadsheet createSpreadsheet(XScriptContext ctxt)
    throws Exception
{
    XComponentLoader loader = (XComponentLoader)
        UnoRuntime.queryInterface(
            XComponentLoader.class, ctxt.getDesktop());

    XComponent comp = loader.loadComponentFromURL(
        "private:factory/scalc", "_blank", 4, new PropertyValue[0]);

    XSpreadsheetDocument doc = (XSpreadsheetDocument)
        UnoRuntime.queryInterface(XSpreadsheetDocument.class, comp);

    XIndexAccess index = (XIndexAccess)
        UnoRuntime.queryInterface(XIndexAccess.class, doc.getSheets());

    XSpreadsheet sheet = (XSpreadsheet) AnyConverter.toObject(
        new Type(com.sun.star.sheet.XSpreadsheet.class), index.getByIndex(0));

    return sheet;
}
 
Example #3
Source File: TableManager.java    From yarg with Apache License 2.0 6 votes vote down vote up
public void selectRow(XController xController, int row) throws com.sun.star.uno.Exception {
    List<String> thisRowCells = getCellNamesForTheRow(row);
    String firstCellName = thisRowCells.get(0);
    String lastCellName = thisRowCells.get(thisRowCells.size() - 1);


    XTextTableCursor xTextTableCursor = xTextTable.createCursorByCellName(firstCellName);
    xTextTableCursor.gotoCellByName(lastCellName, true);
    // It works only if XCellRange was created via cursor. why????
    if (firstCellName.equalsIgnoreCase(lastCellName)) {
        XCell cell = as(XCellRange.class, xTextTable).getCellByPosition(0, row);
        as(XSelectionSupplier.class, xController).select(new Any(new Type(XCell.class), cell));
    } else {
        XCellRange xCellRange = as(XCellRange.class, xTextTable).getCellRangeByName(xTextTableCursor.getRangeName());
        // and why do we need Any here?
        as(XSelectionSupplier.class, xController).select(new Any(new Type(XCellRange.class), xCellRange));
    }
}
 
Example #4
Source File: HighlightText.java    From kkFileViewOfficeEdit with Apache License 2.0 4 votes vote down vote up
private boolean tryLoadingLibrary(
    XMultiComponentFactory xmcf, XScriptContext context, String name)
{
    System.err.println("Try to load ScriptBindingLibrary");

    try {
        Object obj = xmcf.createInstanceWithContext(
           "com.sun.star.script.Application" + name + "LibraryContainer",
           context.getComponentContext());

        XLibraryContainer xLibraryContainer = (XLibraryContainer)
            UnoRuntime.queryInterface(XLibraryContainer.class, obj);

        System.err.println("Got XLibraryContainer");

        Object serviceObj = context.getComponentContext().getValueByName(
            "/singletons/com.sun.star.util.theMacroExpander");
                                                                            
        XMacroExpander xme = (XMacroExpander) AnyConverter.toObject(
            new Type(XMacroExpander.class), serviceObj);
                                                                            
        String bootstrapName = "bootstraprc";
        if (System.getProperty("os.name").startsWith("Windows")) {
            bootstrapName = "bootstrap.ini";
        }

        String libURL = xme.expandMacros(
            "${$OOO_BASE_DIR/program/" + bootstrapName + "::BaseInstallation}" +
            "/share/basic/ScriptBindingLibrary/" +
            name.toLowerCase() + ".xlb/");

        System.err.println("libURL is: " + libURL);

        xLibraryContainer.createLibraryLink(
            "ScriptBindingLibrary", libURL, false);

        System.err.println("liblink created");

    } catch (com.sun.star.uno.Exception e) {
        System.err.println("Got an exception loading lib: " + e.getMessage());
        return false;
    }
    return true;
}
 
Example #5
Source File: HighlightText.java    From kkFileView with Apache License 2.0 4 votes vote down vote up
private boolean tryLoadingLibrary(
    XMultiComponentFactory xmcf, XScriptContext context, String name)
{
    System.err.println("Try to load ScriptBindingLibrary");

    try {
        Object obj = xmcf.createInstanceWithContext(
           "com.sun.star.script.Application" + name + "LibraryContainer",
           context.getComponentContext());

        XLibraryContainer xLibraryContainer = (XLibraryContainer)
            UnoRuntime.queryInterface(XLibraryContainer.class, obj);

        System.err.println("Got XLibraryContainer");

        Object serviceObj = context.getComponentContext().getValueByName(
            "/singletons/com.sun.star.util.theMacroExpander");
                                                                            
        XMacroExpander xme = (XMacroExpander) AnyConverter.toObject(
            new Type(XMacroExpander.class), serviceObj);
                                                                            
        String bootstrapName = "bootstraprc";
        if (System.getProperty("os.name").startsWith("Windows")) {
            bootstrapName = "bootstrap.ini";
        }

        String libURL = xme.expandMacros(
            "${$OOO_BASE_DIR/program/" + bootstrapName + "::BaseInstallation}" +
            "/share/basic/ScriptBindingLibrary/" +
            name.toLowerCase() + ".xlb/");

        System.err.println("libURL is: " + libURL);

        xLibraryContainer.createLibraryLink(
            "ScriptBindingLibrary", libURL, false);

        System.err.println("liblink created");

    } catch (com.sun.star.uno.Exception e) {
        System.err.println("Got an exception loading lib: " + e.getMessage());
        return false;
    }
    return true;
}
 
Example #6
Source File: UnoConverter.java    From yarg with Apache License 2.0 4 votes vote down vote up
public static Any createAny(Object o) {
    return new Any(new Type(o.getClass()), o);
}