com.sun.star.frame.XController Java Examples

The following examples show how to use com.sun.star.frame.XController. 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: PageService.java    From noa-libre with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Navigates to the page with the submitted index. The first page has the index 0.
 * 
 * @param index index of the page
 * 
 * @throws PresentationException if the page is not available
 * 
 * @author Markus Krüger
 * @date 07.01.2008
 */
public void goToPage(int index) throws PresentationException {    
  try {
    XDrawPagesSupplier dSupplier = (XDrawPagesSupplier) UnoRuntime.queryInterface(XDrawPagesSupplier.class, presentationDocument.getXComponent()); 
    XDrawPages pages = dSupplier.getDrawPages(); 

    UnoRuntime.queryInterface(XDrawPage.class, pages.getByIndex(index)); 
    XPresentationPage page = (XPresentationPage) UnoRuntime.queryInterface(XPresentationPage.class, pages.getByIndex(index)); 

    XModel xModel = (XModel) UnoRuntime.queryInterface(XModel.class, presentationDocument.getPresentationSupplier()); 
    XController xController = xModel.getCurrentController(); 
    XDrawView drawView = (XDrawView) UnoRuntime.queryInterface(XDrawView.class, xController); 
    drawView.setCurrentPage(page);
  }
  catch(Throwable throwable) {
    PresentationException textException = new PresentationException(throwable.getMessage());
    textException.initCause(throwable);
    throw textException;
  }
}
 
Example #2
Source File: PageService.java    From noa-libre with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Returns page with the submitted index. The first page has the index 0.
 * 
 * @param index index of the page
 *  
 * @return page with the submitted index
 * 
 * @throws TextException if the page is not available
 * 
 * @author Andreas Bröker
 */
public IPage getPage(int index) throws TextException {
  try {
    XController xController = textDocument.getXTextDocument().getCurrentController();
    XTextViewCursorSupplier xTextViewCursorSupplier = (XTextViewCursorSupplier)UnoRuntime.queryInterface(XTextViewCursorSupplier.class, xController);
    XTextViewCursor textViewCursor = xTextViewCursorSupplier.getViewCursor();
    XPageCursor pageCursor = (XPageCursor)UnoRuntime.queryInterface(XPageCursor.class, textViewCursor);
    pageCursor.jumpToPage((short)index);
    pageCursor.jumpToStartOfPage();
    XTextRange pageStart = textViewCursor.getStart();   
    PagePosition startPagePosition = new PagePosition(textDocument, pageStart);       
    pageCursor.jumpToEndOfPage();    
    XTextRange pageEnd = textViewCursor.getStart();
    PagePosition endPagePosition = new PagePosition(textDocument, pageEnd);
    return new Page(textDocument, startPagePosition, endPagePosition); 
  }
  catch(Exception exception) {
    TextException textException = new TextException(exception.getMessage());
    textException.initCause(exception);
    throw textException;
  }
}
 
Example #3
Source File: AbstractDocument.java    From noa-libre with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Sets selection on the XInterface object selection.
 * 
 * @param interfaceObject
 *            XInterface object selection to be set
 * 
 * @throws NOAException
 *             if the selection type is not supported
 * 
 * @author Andreas Bröker
 * @author Markus Krüger
 * @date 09.07.2006
 */
protected void setXInterfaceObjectSelection(
		IXInterfaceObjectSelection interfaceObject) throws NOAException {
	XModel xModel = (XModel) UnoRuntime.queryInterface(XModel.class,
			xComponent);
	if (xModel != null) {
		XController xController = xModel.getCurrentController();
		XSelectionSupplier selectionSupplier = (XSelectionSupplier) UnoRuntime
				.queryInterface(XSelectionSupplier.class, xController);
		if (selectionSupplier != null) {
			try {
				selectionSupplier.select(interfaceObject
						.getXInterfaceObject());
			} catch (Throwable throwable) {
				throw new NOAException(throwable);
			}
		}
	}
}
 
Example #4
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 #5
Source File: TextDocument.java    From noa-libre with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Sets the zoom of the document.
 * 
 * @param zoomType the type of the zoom as in class {@link DocumentZoomType}
 * @param zoomValue the value of the zoom, does only take afect if zoom type is
 * set to DocumentZoomType.BY_VALUE. Values between 20 and 600 are allowed.
 * 
 * @throws DocumentException if zoom fails
 * 
 * @author Markus Krüger
 * @date 06.07.2007
 */
public void zoom(short zoomType, short zoomValue) throws DocumentException {
  try {
    //zoomType valid?
    if (zoomType != DocumentZoomType.BY_VALUE && zoomType != DocumentZoomType.ENTIRE_PAGE
        && zoomType != DocumentZoomType.OPTIMAL
        && zoomType != DocumentZoomType.PAGE_WIDTH
        && zoomType != DocumentZoomType.PAGE_WIDTH_EXACT)
      throw new DocumentException("Invalid zoom type.");
    //zoomType valid?
    if (zoomType == DocumentZoomType.BY_VALUE && (zoomValue < 20 || zoomValue > 600))
      throw new DocumentException("Invalid zoom value. Use values between 20 and 600.");

    XModel xModel = (XModel) UnoRuntime.queryInterface(XModel.class, getXComponent());
    if (xModel != null) {
      XController xController = xModel.getCurrentController();
      XSelectionSupplier selectionSupplier = (XSelectionSupplier) UnoRuntime.queryInterface(XSelectionSupplier.class,
          xController);
      if (selectionSupplier != null) {
        XViewSettingsSupplier viewSettingsSupplier = (XViewSettingsSupplier) UnoRuntime.queryInterface(XViewSettingsSupplier.class,
            xController);
        if (viewSettingsSupplier != null) {
          XPropertySet propertySet = viewSettingsSupplier.getViewSettings();
          propertySet.setPropertyValue("ZoomType", new Short(zoomType));
          if (zoomType == DocumentZoomType.BY_VALUE)
            propertySet.setPropertyValue("ZoomValue", new Short(zoomValue));
        }
      }
    }
  }
  catch (Throwable throwable) {
    throw new DocumentException(throwable);
  }
}
 
Example #6
Source File: TableManager.java    From yarg with Apache License 2.0 5 votes vote down vote up
public void copyRow(XDispatchHelper xDispatchHelper, XController xController, int row) throws com.sun.star.uno.Exception {
    selectRow(xController, row);
    XDispatchProvider xDispatchProvider = as(XDispatchProvider.class, xController.getFrame());
    copy(xDispatchHelper, xDispatchProvider);
    insertEmptyRow(row);
    selectRow(xController, row + 1);
    paste(xDispatchHelper, xDispatchProvider);
}
 
Example #7
Source File: OOPresentation.java    From Quelea with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void notifyEvent(com.sun.star.document.EventObject ev) {
    XModel xModel = UnoRuntime.queryInterface(XModel.class, ev.Source);
    XController xController = xModel.getCurrentController();
    xController.getFrame().getContainerWindow().setEnable(false);
}
 
Example #8
Source File: AbstractDocument.java    From noa-libre with GNU Lesser General Public License v2.1 3 votes vote down vote up
/**
 * Returns OpenOffice.org XFrame interface.
 * 
 * @return OpenOffice.org XFrame interface
 * 
 * @author Markus Krüger
 * @date 01.08.2007
 */
public XFrame getXFrame() {
	XModel xModel = (XModel) UnoRuntime.queryInterface(XModel.class,
			getXComponent());
	XController xController = xModel.getCurrentController();
	return xController.getFrame();
}
 
Example #9
Source File: AbstractDocument.java    From noa-libre with GNU Lesser General Public License v2.1 3 votes vote down vote up
/**
 * Returns Frame of the document.
 * 
 * @return Frame of the document
 * 
 * @author Markus Krüger
 * @date 01.08.2007
 */
public IFrame getFrame() {
	XModel xModel = (XModel) UnoRuntime.queryInterface(XModel.class,
			getXComponent());
	XController xController = xModel.getCurrentController();
	XFrame xFrame = xController.getFrame();
	return new Frame(xFrame, getServiceProvider());
}
 
Example #10
Source File: ViewCursorService.java    From noa-libre with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * Returns view cursor.
 * 
 * @return view cursor
 * 
 * @author Andreas Bröker
 */
public IViewCursor getViewCursor() {
  XController xController = textDocument.getXTextDocument().getCurrentController();
  XTextViewCursorSupplier xTextViewCursorSupplier = (XTextViewCursorSupplier)UnoRuntime.queryInterface(XTextViewCursorSupplier.class, xController);
  return new ViewCursor(textDocument, xTextViewCursorSupplier.getViewCursor());
}