本文整理汇总了Java中com.sun.star.beans.XPropertySet类的典型用法代码示例。如果您正苦于以下问题:Java XPropertySet类的具体用法?Java XPropertySet怎么用?Java XPropertySet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
XPropertySet类属于com.sun.star.beans包,在下文中一共展示了XPropertySet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getText
import com.sun.star.beans.XPropertySet; //导入依赖的package包/类
/**
* Returns the text content of the annotation, or null if text content is not available.
*
* @return the text content of the annotation, or null
*
* @author Markus Krüger
* @date 13.07.2006
*/
public String getText() {
XServiceInfo info = (XServiceInfo) UnoRuntime.queryInterface(XServiceInfo.class, getXTextContent());
if(info.supportsService(ITextFieldService.ANNOTATION_TEXTFIELD_ID)) {
XPropertySet properties = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, getXTextContent());
try {
return (String) properties.getPropertyValue("Content");
}
catch(UnknownPropertyException unknownPropertyException) {
//TODO exception handling if needed, do nothing for now
}
catch(WrappedTargetException wrappedTargetException) {
//TODO exception handling if needed, do nothing for now
}
}
return null;
}
示例2: hideElement
import com.sun.star.beans.XPropertySet; //导入依赖的package包/类
/**
* Hide UI element with the submitted resource URL.
*
* @param resourceURL URL of the UI resource to be hidden
* @param if changes should be persistent
*
* @return information whether the UI resource is hidden after method call
*
* @author Markus Krüger
* @date 06.05.2010
*/
public boolean hideElement(String resourceURL, boolean persistent) {
if (resourceURL != null) {
try {
XUIElement element = xLayoutManager.getElement(resourceURL);
if (element != null) {
XPropertySet xps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, element);
xps.setPropertyValue("Persistent", new Boolean(persistent));
return xLayoutManager.hideElement(resourceURL);
}
}
catch (Exception e) {
//ignore and return false
}
}
return false;
}
示例3: showElement
import com.sun.star.beans.XPropertySet; //导入依赖的package包/类
/**
* Shows UI element with the submitted resource URL.
*
* @param resourceURL URL of the UI resource to be shown
* @param if changes should be persistent
*
* @return information whether the UI resource is visible after method call
*
* @author Markus Krüger
* @date 06.05.2010
*/
public boolean showElement(String resourceURL, boolean persistent) {
if (resourceURL != null) {
try {
XUIElement element = xLayoutManager.getElement(resourceURL);
if (element == null) {
xLayoutManager.createElement(resourceURL);
}
element = xLayoutManager.getElement(resourceURL);
if (element != null) {
XPropertySet xps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, element);
xps.setPropertyValue("Persistent", new Boolean(persistent));
return xLayoutManager.showElement(resourceURL);
}
}
catch (Exception e) {
//ignore and return false
}
}
return false;
}
示例4: openConnection
import com.sun.star.beans.XPropertySet; //导入依赖的package包/类
/**
* Opens connection to OpenOffice.org.
*
* @return information whether the connection is available
*
* @throws Exception if any error occurs
*/
public boolean openConnection() throws Exception {
String unoUrl = "uno:socket,host=" + host + ",port=" + port +";urp;StarOffice.ServiceManager";
XComponentContext xLocalContext = Bootstrap.createInitialComponentContext(null);
Object connector = xLocalContext.getServiceManager().createInstanceWithContext("com.sun.star.connection.Connector", xLocalContext);
XConnector xConnector = (XConnector) UnoRuntime.queryInterface(XConnector.class, connector);
String url[] = parseUnoUrl(unoUrl);
if (null == url) {
throw new com.sun.star.uno.Exception("Couldn't parse UNO URL "+ unoUrl);
}
XConnection connection = xConnector.connect(url[0]);
Object bridgeFactory = xLocalContext.getServiceManager().createInstanceWithContext("com.sun.star.bridge.BridgeFactory", xLocalContext);
XBridgeFactory xBridgeFactory = (XBridgeFactory) UnoRuntime.queryInterface(XBridgeFactory.class, bridgeFactory);
xBridge = xBridgeFactory.createBridge("", url[1], connection ,null);
bridgeFactory = xBridge.getInstance(url[2]);
xMultiComponentFactory = (XMultiComponentFactory)UnoRuntime.queryInterface(XMultiComponentFactory.class, bridgeFactory);
XPropertySet xProperySet = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xMultiComponentFactory);
Object remoteContext = xProperySet.getPropertyValue("DefaultContext");
xRemoteContext = (XComponentContext) UnoRuntime.queryInterface(XComponentContext.class, remoteContext);
xMultiServiceFactory = (XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class, xMultiComponentFactory);
isConnectionEstablished = true;
return true;
}
示例5: constructNewVariableTextField
import com.sun.star.beans.XPropertySet; //导入依赖的package包/类
/**
* Constructs new variable text field on the basis of this variable text field master.
* TODO maybe some more parameters are needed???
*
* @param content the content of the variable textfield
* @param visible if the variable should be visible
* @param numberFormat the number format used for the variable
* @param isFormula if the given content is a formula
*
* @return new constructed variable text field on the basis of this variable text field master
*
* @throws NOAException if the new variable text field can not be constructed
*
* @author Markus Krüger
* @date 30.05.2007
*/
public ITextField constructNewVariableTextField(String content, boolean visible,
INumberFormat numberFormat, boolean isFormula) throws NOAException {
try {
XMultiServiceFactory xMultiServiceFactory = (XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class, textDocument.getXTextDocument());
Object textField = xMultiServiceFactory.createInstance(ITextFieldService.VARIABLES_TEXTFIELD_ID);
XDependentTextField xDependentTextField = (XDependentTextField)UnoRuntime.queryInterface(XDependentTextField.class, textField);
xDependentTextField.attachTextFieldMaster(xPropertySet);
XPropertySet xPropertySetField = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xDependentTextField);
xPropertySetField.setPropertyValue("IsVisible", new Boolean(visible));
xPropertySetField.setPropertyValue("IsFixedLanguage", new Boolean(false));
ITextField variableTextField = new TextField(textDocument, xDependentTextField);
INumberFormatService numberFormatService = textDocument.getNumberFormatService();
VariableTextFieldHelper.setContent(content,variableTextField,isFormula,numberFormatService);
if(numberFormat != null)
VariableTextFieldHelper.applyNumberFormat(numberFormat,variableTextField,isFormula,numberFormatService);
return variableTextField;
}
catch(Throwable throwable) {
throw new NOAException(throwable);
}
}
示例6: getTextFields
import com.sun.star.beans.XPropertySet; //导入依赖的package包/类
/**
* Returns all available text fields.
*
* @return all available text fields
*
* @author Andreas Bröker
*/
public ITextField[] getTextFields() {
ArrayList arrayList = new ArrayList();
XTextCursor textCursor = xTextRange.getText().createTextCursorByRange(xTextRange.getStart());
XTextRangeCompare xTextRangeCompare = (XTextRangeCompare)UnoRuntime.queryInterface(XTextRangeCompare.class, xTextRange.getText());
try {
while(xTextRangeCompare.compareRegionEnds(textCursor.getStart(), xTextRange.getEnd()) != -1) {
XPropertySet propertySet = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, textCursor);
Any any = (Any)propertySet.getPropertyValue("TextField");
XTextField xTextField = (XTextField)any.getObject();
if(xTextField != null)
arrayList.add(new TextField(textDocument, xTextField));
if(!textCursor.goRight((short)1, false))
break;
}
}
catch(Exception exception) {
//do nothing
}
ITextField[] textFields = new ITextField[arrayList.size()];
return (ITextField[])arrayList.toArray(textFields);
}
示例7: getTextTable
import com.sun.star.beans.XPropertySet; //导入依赖的package包/类
/**
* Returns text table of the cell.
*
* @return text table of the cell
*
* @throws TextException if the text table is not available
*
* @author Andreas Bröker
* @author Markus Krüger
*/
public ITextTable getTextTable() throws TextException {
if(textTable == null) {
try {
XText xText = (XText)UnoRuntime.queryInterface(XText.class, xCell);
XPropertySet xPropertySet = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xText.getStart());
Any any = (Any)xPropertySet.getPropertyValue("TextTable");
XTextTable xTextTable = (XTextTable)any.getObject();
textTable = new TextTable(textDocument, xTextTable);
}
catch(Exception exception) {
TextException textException = new TextException(exception.getMessage());
textException.initCause(exception);
throw textException;
}
}
return textTable;
}
示例8: getHeight
import com.sun.star.beans.XPropertySet; //导入依赖的package包/类
/**
* Returns the row height.
*
* @return the row height
*
* @author Markus Krüger
*/
public int getHeight() {
if(textTableCellRange == null)
return 0;
try {
XTextTable xTextTable = (XTextTable)textTableCellRange.getCell(0,0).getTextTable().getXTextContent();
XTableRows tableRows = xTextTable.getRows();
Object row = tableRows.getByIndex(textTableCellRange.getRangeName().getRangeStartRowIndex());
XPropertySet propertySetRow = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, row);
Integer rowHeight = (Integer)propertySetRow.getPropertyValue("Height");
return rowHeight.intValue();
}
catch (Exception exception) {
return 0;
}
}
示例9: getAutoHeight
import com.sun.star.beans.XPropertySet; //导入依赖的package包/类
/**
* Returns if the row height is set to automatically be adjusted or not.
*
* @return if the row height is set to automatically be adjusted or not
*
* @author Markus Krüger
*/
public boolean getAutoHeight() {
if(textTableCellRange == null)
return false;
try {
XTextTable xTextTable = (XTextTable)textTableCellRange.getCell(0,0).getTextTable().getXTextContent();
XTableRows tableRows = xTextTable.getRows();
int rowIndex = textTableCellRange.getRangeName().getRangeStartRowIndex();
Object row = tableRows.getByIndex(rowIndex);
XPropertySet propertySetRow = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, row);
Boolean rowAutoHeight = (Boolean)propertySetRow.getPropertyValue("IsAutoHeight");
return rowAutoHeight.booleanValue();
}
catch (Exception exception) {
return false;
}
}
示例10: getNumberFormat
import com.sun.star.beans.XPropertySet; //导入依赖的package包/类
/**
* Returns number format on the basis of the submitted key.
*
* @param key key of the number format
*
* @return number format on the basis of the submitted key
*
* @throws UtilException if the number format is not available
*
* @author Andreas Bröker
* @author Markus Krüger
*/
public INumberFormat getNumberFormat(int key) throws UtilException {
INumberFormat[] allFormats = getNumberFormats();
for(int i = 0; i < allFormats.length; i++) {
if(key == allFormats[i].getFormatKey())
return allFormats[i];
}
try {
XNumberFormats xNumberFormats = xNumberFormatsSupplier.getNumberFormats();
XPropertySet docProps = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, textDocument.getXTextDocument());
Locale docLocale = (Locale) docProps.getPropertyValue("CharLocale");
XNumberFormatTypes numberFormatTypes = (XNumberFormatTypes)UnoRuntime.queryInterface(XNumberFormatTypes.class, xNumberFormats);
int newKey = numberFormatTypes.getFormatForLocale(key,docLocale);
for(int i = 0; i < allFormats.length; i++) {
if(newKey == allFormats[i].getFormatKey())
return allFormats[i];
}
}
catch(Exception exception) {
UtilException utilException = new UtilException(exception.getMessage());
utilException.initCause(exception);
throw utilException;
}
throw new UtilException("The number format is not available.");
}
示例11: constructDatabaseDocument
import com.sun.star.beans.XPropertySet; //导入依赖的package包/类
/**
* Constructs new database document.
*
* @return new constructed database document
*
* @throws NOAException if the new database document can not be constructed
*
* @author Andreas Bröker
* @date 16.03.2006
*/
private IDatabaseDocument constructDatabaseDocument() throws NOAException {
try {
Object dataSource = officeConnection.getXMultiComponentFactory().createInstanceWithContext("com.sun.star.sdb.DataSource",
officeConnection.getXComponentContext());
XPropertySet propertySet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,
dataSource);
propertySet.setPropertyValue("URL", "sdbc:embedded:hsqldb");
XDocumentDataSource documentDataSource = (XDocumentDataSource) UnoRuntime.queryInterface(XDocumentDataSource.class,
dataSource);
XOfficeDatabaseDocument officeDatabaseDocument = documentDataSource.getDatabaseDocument();
return new DatabaseDocument(officeDatabaseDocument, null);
}
catch (Throwable throwable) {
throw new NOAException(throwable);
}
}
示例12: applyNumberFormat
import com.sun.star.beans.XPropertySet; //导入依赖的package包/类
/**
* Applies the given number format to the given variable text field.
*
* @param numberFormat the number format to be set
* @param variableTextField the variable text field to set number forma for
* @param isFormula if the variable text field is a formula
* @param numberFormatService the number format service to be used
*
* @throws NOAException if setting the number format fails
*
* @author Markus Krüger
* @date 27.07.2007
*/
public static void applyNumberFormat(INumberFormat numberFormat, ITextField variableTextField,
boolean isFormula, INumberFormatService numberFormatService) throws NOAException {
try {
if(numberFormat == null || variableTextField == null || numberFormatService == null)
return;
XPropertySet xPropertySetField =
(XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, variableTextField.getXTextContent());
String content = (String)xPropertySetField.getPropertyValue("Content");
xPropertySetField.setPropertyValue("NumberFormat", new Integer(numberFormat.getFormatKey()));
setContent(content,variableTextField,isFormula,numberFormatService);
}
catch(Throwable throwable) {
throw new NOAException(throwable);
}
}
示例13: fixPageCountFields
import com.sun.star.beans.XPropertySet; //导入依赖的package包/类
/**
* Ersetzt alle TextFields des Typs PageCount in textFields durch den Wert
* pageCount.
*
* @author Matthias Benkmann (D-III-ITD 5.1)
* @throws WrappedTargetException
* @throws NoSuchElementException
* sollte nie geworfen werden
*/
private static void fixPageCountFields(XEnumerationAccess textFields, int pageCount)
throws NoSuchElementException, WrappedTargetException
{
String pc = "" + pageCount;
XEnumeration enu = textFields.createEnumeration();
while (enu.hasMoreElements())
{
Object textfield = enu.nextElement();
// Der eigentlich redundante Test auf das Property NumberingType ist eine
// Optimierung, da supportsService sehr langsam ist.
if (UNO.getProperty(textfield, "NumberingType") != null
&& UNO.supportsService(textfield, "com.sun.star.text.textfield.PageCount"))
{
XTextRange range = UNO.XTextContent(textfield).getAnchor();
XTextCursor cursor =
range.getText().createTextCursorByRange(range.getStart());
cursor.setString(pc);
TextDocument.copyDirectValueCharAttributes(UNO.XPropertyState(range),
UNO.XPropertySet(cursor));
range.setString("");
}
}
}
示例14: getUserFieldMaster
import com.sun.star.beans.XPropertySet; //导入依赖的package包/类
/**
* Diese Methode liefert den TextFieldMaster, der für Zugriffe auf das Benutzerfeld
* mit den Namen userFieldName zuständig ist.
*
* @param userFieldName
* @return den TextFieldMaster oder null, wenn das Benutzerfeld userFieldName nicht
* existiert.
*
* @author Christoph Lutz (D-III-ITD-5.1)
*/
private XPropertySet getUserFieldMaster(String userFieldName)
{
XNameAccess masters = UNO.XTextFieldsSupplier(model.doc).getTextFieldMasters();
String elementName = "com.sun.star.text.FieldMaster.User." + userFieldName;
if (masters.hasByName(elementName))
{
try
{
return UNO.XPropertySet(masters.getByName(elementName));
}
catch (java.lang.Exception e)
{
Logger.error(e);
}
}
return null;
}
示例15: insertTextAtCurrentLocation
import com.sun.star.beans.XPropertySet; //导入依赖的package包/类
public static void insertTextAtCurrentLocation(XText text, XTextCursor cursor, String string, String parStyle)
throws WrappedTargetException, PropertyVetoException, UnknownPropertyException,
UndefinedParagraphFormatException {
text.insertString(cursor, string, true);
XParagraphCursor parCursor = UnoRuntime.queryInterface(
XParagraphCursor.class, cursor);
// Access the property set of the cursor, and set the currently selected text
// (which is the string we just inserted) to be bold
XPropertySet props = UnoRuntime.queryInterface(
XPropertySet.class, parCursor);
try {
props.setPropertyValue(PARA_STYLE_NAME, parStyle);
} catch (IllegalArgumentException ex) {
throw new UndefinedParagraphFormatException(parStyle);
}
cursor.collapseToEnd();
}