/** * This property is very interesting. After setting URL of bitmap you get <code>XBitmap</code> * interface of the image file specified. The method first gets two different bitmaps and then * tests the property. */ public void _FillBitmap() { String propName = "FillBitmap"; XPropertySetInfo info = oObj.getPropertySetInfo(); if (!info.hasPropertyByName(propName)) { if (isOptional(propName)) { // skipping optional property test log.println("Property '" + propName + "' is optional and not supported"); tRes.tested(propName, true); return; } } else { try { oObj.setPropertyValue("FillBitmapURL", util.utils.getFullTestURL("crazy-blue.jpg")); the_bitmap = (XBitmap) AnyConverter.toObject(new Type(XBitmap.class), oObj.getPropertyValue("FillBitmap")); oObj.setPropertyValue("FillBitmapURL", util.utils.getFullTestURL("space-metal.jpg")); the_secondBitmap = (XBitmap) AnyConverter.toObject(new Type(XBitmap.class), oObj.getPropertyValue("FillBitmap")); testProperty("FillBitmap", BitmapTester); } catch (com.sun.star.beans.PropertyVetoException e) { log.println("Couldn't change Bitmap"); e.printStackTrace(log); tRes.tested("FillBitmap", false); } catch (com.sun.star.beans.UnknownPropertyException e) { log.println("Couldn't change Bitmap"); e.printStackTrace(log); tRes.tested("FillBitmap", false); } catch (com.sun.star.lang.WrappedTargetException e) { log.println("Couldn't change Bitmap"); e.printStackTrace(log); tRes.tested("FillBitmap", false); } catch (com.sun.star.lang.IllegalArgumentException e) { log.println("Couldn't change Bitmap"); e.printStackTrace(log); tRes.tested("FillBitmap", false); } } }
@Override public void handle(Object aFormComponent) throws com.sun.star.uno.Exception { // check if it's a button XPropertySet xProps = UNO.queryPropertySet(aFormComponent); XPropertySetInfo xPI = null; if (null != xProps) xPI = xProps.getPropertySetInfo(); if ((null != xPI) && xPI.hasPropertyByName("ClassId")) { Short nClassId = (Short) xProps.getPropertyValue("ClassId"); if (FormComponentType.COMMANDBUTTON == nClassId.shortValue()) { // yes, it is m_aOperator.revokeButton(xProps); } } // let the super class step down the tree (if possible) super.handle(aFormComponent); }
/** * creates a control in the document * * <p>Note that <em>control<em> here is an incorrect terminology. What the method really does is * it creates a control shape, together with a control model, and inserts them into the document * model. This will result in every view to this document creating a control described by the * model-shape pair. * * @param sFormComponentService the service name of the form component to create, e.g. "TextField" * @param nXPos the abscissa of the position of the newly inserted shape * @param nXPos the ordinate of the position of the newly inserted shape * @param nWidth the width of the newly inserted shape * @param nHeight the height of the newly inserted shape * @param xParentForm the form to use as parent for the newly create form component. May be null, * in this case a default parent is chosen by the implementation * @return the property access to the control's model */ protected XPropertySet createControlAndShape( String sFormComponentService, int nXPos, int nYPos, int nWidth, int nHeight, XIndexContainer xParentForm) throws java.lang.Exception { // let the document create a shape XMultiServiceFactory xDocAsFactory = UnoRuntime.queryInterface(XMultiServiceFactory.class, m_document.getDocument()); XControlShape xShape = UnoRuntime.queryInterface( XControlShape.class, xDocAsFactory.createInstance("com.sun.star.drawing.ControlShape")); // position and size of the shape xShape.setSize(new Size(nWidth * 100, nHeight * 100)); xShape.setPosition(new Point(nXPos * 100, nYPos * 100)); // adjust the anchor so that the control is tied to the page XPropertySet xShapeProps = UNO.queryPropertySet(xShape); TextContentAnchorType eAnchorType = TextContentAnchorType.AT_PARAGRAPH; xShapeProps.setPropertyValue("AnchorType", eAnchorType); // create the form component (the model of a form control) String sQualifiedComponentName = "com.sun.star.form.component." + sFormComponentService; XControlModel xModel = UnoRuntime.queryInterface( XControlModel.class, m_document.getOrb().createInstance(sQualifiedComponentName)); // insert the model into the form component hierarchy, if the caller gave us a location if (null != xParentForm) { xParentForm.insertByIndex(xParentForm.getCount(), xModel); } // knitt them xShape.setControl(xModel); // add the shape to the shapes collection of the document XDrawPage pageWhereToInsert = (m_insertPage != -1) ? m_document.getDrawPage(m_insertPage) : m_document.getMainDrawPage(); XShapes xDocShapes = UnoRuntime.queryInterface(XShapes.class, pageWhereToInsert); xDocShapes.add(xShape); // some initializations which are the same for all controls XPropertySet xModelProps = UNO.queryPropertySet(xModel); try { XPropertySetInfo xPSI = xModelProps.getPropertySetInfo(); if (xPSI.hasPropertyByName("Border")) { if (((Short) xModelProps.getPropertyValue("Border")).shortValue() == com.sun.star.awt.VisualEffect.LOOK3D) xModelProps.setPropertyValue("Border", Short.valueOf(com.sun.star.awt.VisualEffect.FLAT)); } if (xPSI.hasPropertyByName("VisualEffect")) xModelProps.setPropertyValue( "VisualEffect", Short.valueOf(com.sun.star.awt.VisualEffect.FLAT)); if (m_document.classify() != DocumentType.CALC) if (xPSI.hasPropertyByName("BorderColor")) xModelProps.setPropertyValue("BorderColor", Integer.valueOf(0x00C0C0C0)); } catch (com.sun.star.uno.Exception e) { System.err.println(e); e.printStackTrace(System.err); } return xModelProps; }