The Example Listings
- Common Properties
- Font-specific Properties
- Other Common Properties
- Property Propagation Between Model and Control
- Common Workflow to add Controls
- The Example Listings
- Label Field
- Command Button
- Image Control
- Check Box
- Radio Button
- Scroll Bar
- List Box
- Combo Box
- Progress Bar
- Horizontal/Vertical Line Control
- Group Box
- Text Field
- Text Field Extensions
- Formatted Field
- Numeric Field
- Currency Field
- Date Field
- Time Field
- Pattern Field
- Roadmap Control
- File Control
- File Picker
- Message Box
As is generally known, an example is worth a thousand words. This is especially true for UNO. Sourcecode written in UNO is very often self-explanatory and for this reason the following sections provide a large set of example listings. Some of them are ready-to-use, whereas the focus of other examples is on demonstrating concepts.
All coding examples that demonstrate how to insert controls into a dialog make use of the following method:
/** makes a String unique by appending a numerical suffix * @param _xElementContainer the com.sun.star.container.XNameAccess container * that the new Element is going to be inserted to * @param _sElementName the StemName of the Element */ public static String createUniqueName(XNameAccess _xElementContainer, String _sElementName) { boolean bElementexists = true; int i = 1; String BaseName = _sElementName; while (bElementexists) { bElementexists = _xElementContainer.hasByName(_sElementName); if (bElementexists) { i += 1; _sElementName = BaseName + Integer.toString(i); } } return _sElementName; }
As already explained, the dialog keeps the controls in a NamedContainer
that implements com.sun.star.container.XNameAccess. It is absolutely necessary for the controls to have a unique name before they are added to the dialog to prevent a com.sun.star.container.ElementExistException. This method appends a suffix to the scheduled name of the control to make sure that the name is unique.
Content on this page is licensed under the Public Documentation License (PDL). |