com.sun.star.uno.XInterface Java Examples

The following examples show how to use com.sun.star.uno.XInterface. 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 4 votes vote down vote up
private void addChart(XSpreadsheet sheet)
    throws Exception
{
    Rectangle rect = new Rectangle();
    rect.X = 500;
    rect.Y = 3000;
    rect.Width = 10000;
    rect.Height = 8000;

    XCellRange range = (XCellRange)
        UnoRuntime.queryInterface(XCellRange.class, sheet);

    XCellRange myRange =
        range.getCellRangeByName("A1:B2");

    XCellRangeAddressable rangeAddr = (XCellRangeAddressable)
        UnoRuntime.queryInterface(XCellRangeAddressable.class, myRange);

    CellRangeAddress myAddr = rangeAddr.getRangeAddress();

    CellRangeAddress[] addr = new CellRangeAddress[1];
    addr[0] = myAddr;

    XTableChartsSupplier supp = (XTableChartsSupplier)
        UnoRuntime.queryInterface( XTableChartsSupplier.class, sheet);

    XTableCharts charts = supp.getCharts();
    charts.addNewByName("Example", rect, addr, false, true);

    try { Thread.sleep(3000); } catch (java.lang.InterruptedException e) { }

    // get the diagram and Change some of the properties
    XNameAccess chartsAccess = (XNameAccess)
        UnoRuntime.queryInterface( XNameAccess.class, charts);

    XTableChart tchart = (XTableChart)
        UnoRuntime.queryInterface(
            XTableChart.class, chartsAccess.getByName("Example"));

    XEmbeddedObjectSupplier eos = (XEmbeddedObjectSupplier)
        UnoRuntime.queryInterface( XEmbeddedObjectSupplier.class, tchart );

    XInterface xifc = eos.getEmbeddedObject();

    XChartDocument xChart = (XChartDocument)
        UnoRuntime.queryInterface(XChartDocument.class, xifc);

    XMultiServiceFactory xDocMSF = (XMultiServiceFactory)
        UnoRuntime.queryInterface(XMultiServiceFactory.class, xChart);

    Object diagObject =
        xDocMSF.createInstance("com.sun.star.chart.PieDiagram");

    XDiagram xDiagram = (XDiagram)
        UnoRuntime.queryInterface(XDiagram.class, diagObject);

    xChart.setDiagram(xDiagram);

    XPropertySet propset = (XPropertySet)
        UnoRuntime.queryInterface( XPropertySet.class, xChart.getTitle() );
    propset.setPropertyValue("String", "JVM Memory Usage");
}
 
Example #2
Source File: MemoryUsage.java    From kkFileView with Apache License 2.0 4 votes vote down vote up
private void addChart(XSpreadsheet sheet)
    throws Exception
{
    Rectangle rect = new Rectangle();
    rect.X = 500;
    rect.Y = 3000;
    rect.Width = 10000;
    rect.Height = 8000;

    XCellRange range = (XCellRange)
        UnoRuntime.queryInterface(XCellRange.class, sheet);

    XCellRange myRange =
        range.getCellRangeByName("A1:B2");

    XCellRangeAddressable rangeAddr = (XCellRangeAddressable)
        UnoRuntime.queryInterface(XCellRangeAddressable.class, myRange);

    CellRangeAddress myAddr = rangeAddr.getRangeAddress();

    CellRangeAddress[] addr = new CellRangeAddress[1];
    addr[0] = myAddr;

    XTableChartsSupplier supp = (XTableChartsSupplier)
        UnoRuntime.queryInterface( XTableChartsSupplier.class, sheet);

    XTableCharts charts = supp.getCharts();
    charts.addNewByName("Example", rect, addr, false, true);

    try { Thread.sleep(3000); } catch (java.lang.InterruptedException e) { }

    // get the diagram and Change some of the properties
    XNameAccess chartsAccess = (XNameAccess)
        UnoRuntime.queryInterface( XNameAccess.class, charts);

    XTableChart tchart = (XTableChart)
        UnoRuntime.queryInterface(
            XTableChart.class, chartsAccess.getByName("Example"));

    XEmbeddedObjectSupplier eos = (XEmbeddedObjectSupplier)
        UnoRuntime.queryInterface( XEmbeddedObjectSupplier.class, tchart );

    XInterface xifc = eos.getEmbeddedObject();

    XChartDocument xChart = (XChartDocument)
        UnoRuntime.queryInterface(XChartDocument.class, xifc);

    XMultiServiceFactory xDocMSF = (XMultiServiceFactory)
        UnoRuntime.queryInterface(XMultiServiceFactory.class, xChart);

    Object diagObject =
        xDocMSF.createInstance("com.sun.star.chart.PieDiagram");

    XDiagram xDiagram = (XDiagram)
        UnoRuntime.queryInterface(XDiagram.class, diagObject);

    xChart.setDiagram(xDiagram);

    XPropertySet propset = (XPropertySet)
        UnoRuntime.queryInterface( XPropertySet.class, xChart.getTitle() );
    propset.setPropertyValue("String", "JVM Memory Usage");
}
 
Example #3
Source File: SearchService.java    From noa-libre with GNU Lesser General Public License v2.1 3 votes vote down vote up
/**
 * Looks for the first occurrences of the defined search.
 * 
 * @param searchDescriptor search descriptor to be used
 * 
 * @return result of the search
 * 
 * @author Andreas Bröker
 * @date 09.07.2006
 */
public ISearchResult findFirst(ISearchDescriptor searchDescriptor) {
	if(searchDescriptor == null || searchDescriptor.getSearchContent() == null)
		return new SearchResult(document);
	Object object =  xSearchable.findFirst(toXSearchDescriptor(searchDescriptor));
	if(object == null)
		return new SearchResult(document);
	return new SearchResult(document,(XInterface)object);
}
 
Example #4
Source File: IXInterfaceObjectSelection.java    From noa-libre with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * Returns object implementing XInterface of the selection.
 * 
 * @return object implementing XInterface of the selection
 * 
 * @author Markus Krüger
 * @date 01.08.2007
 */
public XInterface getXInterfaceObject();
 
Example #5
Source File: XInterfaceObjectSelection.java    From noa-libre with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * Constructs new XInterfaceObjectSelection.
 * 
 * @param interfaceObject object implementing XInterface to be used
 * 
 * @author Markus Krüger
 * @date 01.08.2007
 */
public XInterfaceObjectSelection(XInterface interfaceObject) {
	Assert.isNotNull(interfaceObject, XInterface.class, this);
	this.interfaceObject = interfaceObject;
}
 
Example #6
Source File: XInterfaceObjectSelection.java    From noa-libre with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * Returns object implementing XInterface of the selection.
 * 
 * @return object implementing XInterface of the selection
 * 
 * @author Markus Krüger
 * @date 01.08.2007
 */
public XInterface getXInterfaceObject() {
  return interfaceObject;
}
 
Example #7
Source File: TextRangeSelection.java    From noa-libre with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * Returns object implementing XInterface of the selection.
 * 
 * @return object implementing XInterface of the selection
 * 
 * @author Markus Krüger
 * @date 01.08.2007
 */
public XInterface getXInterfaceObject() {
  return textRange.getXTextRange();
}
 
Example #8
Source File: SearchResult.java    From noa-libre with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * Constructs new SearchResult.
 * 
  * @param document the document it is used in
 * @param xInterface OpenOffice.org XInterface interface
 * 
 * @author Andreas Bröker
 * @date 09.07.2006
 */
public SearchResult(IDocument document,XInterface xInterface) {
  this(document);
	Assert.isNotNull(xInterface, XInterface.class, this);
	this.xInterface = xInterface;
}