Java Code Examples for com.sun.star.frame.XModel#getCurrentController()

The following examples show how to use com.sun.star.frame.XModel#getCurrentController() . 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: 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 3
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 4
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 5
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 6
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());
}