com.sun.star.frame.XModel Java Examples
The following examples show how to use
com.sun.star.frame.XModel.
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 |
/** * 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 |
/** * Returns information wheter the document is open. * * @return information wheter the document is open * * @author Andreas Bröker */ public boolean isOpen() { if (xComponent != null) { try { XModel xModel = (XModel) UnoRuntime.queryInterface( XModel.class, xComponent); if (xModel != null) { xModel.getURL(); return true; } else { return false; } } catch (Exception exception) { return false; } } else { return false; } }
Example #3
Source File: AbstractDocument.java From noa-libre with GNU Lesser General Public License v2.1 | 6 votes |
/** * 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: OOPresentation.java From Quelea with GNU General Public License v3.0 | 5 votes |
/** * Create a new presentation from a particular file. This must be the path * to a presentation file that openoffice supports - so either odp, ppt or * pptx at the time of writing. Note that the static init() method on this * class must be called successfully before attempting to create any * presentation objects, otherwise an IllegalStateException will be thrown. * * @param file the path to the presentation file. * @throws Exception if something goes wrong creating the presentation. */ public OOPresentation(String file) throws Exception { if (!init) { LOGGER.log(Level.SEVERE, "BUG: Tried to create OOPresentation before it was initialised"); throw new IllegalStateException("I'm not initialised yet! init() needs to be called before creating presentations."); } slideListeners = new ArrayList<>(); File sourceFile = new File(file); StringBuilder sURL = new StringBuilder("file:///"); sURL.append(sourceFile.getCanonicalPath().replace('\\', '/')); PropertyValue[] props = new PropertyValue[1]; props[0] = new PropertyValue(); props[0].Name = "Silent"; props[0].Value = true; doc = Helper.createDocument(xOfficeContext, sURL.toString(), "_blank", 0, props); XModel xModel = UnoRuntime.queryInterface(XModel.class, doc); XEventBroadcaster xDocEventBroadcaster = UnoRuntime.queryInterface(com.sun.star.document.XEventBroadcaster.class, xModel); xDocEventBroadcaster.addEventListener(this); xModel.getCurrentController().getFrame().getContainerWindow().setPosSize(0, 0, 1, 1, PosSize.SIZE); xModel.getCurrentController().getFrame().getContainerWindow().setVisible(false); XPresentationSupplier xPresSupplier = UnoRuntime.queryInterface(XPresentationSupplier.class, doc); XPresentation xPresentation_ = xPresSupplier.getPresentation(); xPresentation = UnoRuntime.queryInterface(XPresentation2.class, xPresentation_); Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { checkDisposed(); } }); }
Example #5
Source File: TextDocument.java From noa-libre with GNU Lesser General Public License v2.1 | 5 votes |
/** * 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: AbstractDocument.java From noa-libre with GNU Lesser General Public License v2.1 | 5 votes |
/** * Returns location of the document. Returns null if the URL is not * available. * * @return location of the document * * @throws DocumentException * if the URL is not valid * * @deprecated Use the IPersistenceService instead. * * @author Andreas Bröker */ public URL getLocationURL() throws DocumentException { XModel xModel = (XModel) UnoRuntime.queryInterface(XModel.class, xComponent); String documentURL = xModel.getURL(); if (documentURL == null) { return null; } try { URL url = new URL(documentURL); return url; } catch (Throwable throwable) { throw new DocumentException(throwable); } }
Example #7
Source File: OOPresentation.java From Quelea with GNU General Public License v3.0 | 4 votes |
@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: DocumentHelper.java From libreoffice-starter-extension with MIT License | 4 votes |
/** Returns the current frame */ public static XFrame getCurrentFrame(XComponentContext xContext) { XModel xModel = (XModel) UnoRuntime.queryInterface(XModel.class, getCurrentComponent(xContext)); return xModel.getCurrentController().getFrame(); }
Example #9
Source File: AbstractDocument.java From noa-libre with GNU Lesser General Public License v2.1 | 3 votes |
/** * 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 #10
Source File: AbstractDocument.java From noa-libre with GNU Lesser General Public License v2.1 | 3 votes |
/** * 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()); }