本文整理汇总了Java中com.sun.star.beans.XPropertySet.setPropertyValue方法的典型用法代码示例。如果您正苦于以下问题:Java XPropertySet.setPropertyValue方法的具体用法?Java XPropertySet.setPropertyValue怎么用?Java XPropertySet.setPropertyValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.star.beans.XPropertySet
的用法示例。
在下文中一共展示了XPropertySet.setPropertyValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: 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);
}
}
示例4: 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);
}
}
示例5: 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);
}
}
示例6: 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();
}
示例7: buildImageProperties
import com.sun.star.beans.XPropertySet; //导入方法依赖的package包/类
protected XPropertySet buildImageProperties(XGraphicProvider xGraphicProvider, Object oImage, byte[] imageContent)
throws Exception {
XPropertySet imageProperties = as(XPropertySet.class, oImage);
PropertyValue[] propValues = new PropertyValue[]{new PropertyValue()};
propValues[0].Name = "InputStream";
propValues[0].Value = new ByteArrayToXInputStreamAdapter(imageContent);
XGraphic graphic = xGraphicProvider.queryGraphic(propValues);
if (graphic != null) {
imageProperties.setPropertyValue("Graphic", graphic);
imageProperties.setPropertyValue("HoriOrient", HoriOrientation.NONE);
imageProperties.setPropertyValue("VertOrient", HoriOrientation.NONE);
imageProperties.setPropertyValue("HoriOrientPosition", 0);
imageProperties.setPropertyValue("VertOrientPosition", 0);
}
return imageProperties;
}
示例8: EnableButton
import com.sun.star.beans.XPropertySet; //导入方法依赖的package包/类
public static void EnableButton(XDialog dialog, String componentId, boolean enable) {
XControlContainer xDlgContainer = (XControlContainer) UnoRuntime.queryInterface(XControlContainer.class,
dialog);
// retrieve the control that we want to disable or enable
XControl xControl = UnoRuntime.queryInterface(XControl.class, xDlgContainer.getControl(componentId));
XPropertySet xModelPropertySet = UnoRuntime.queryInterface(XPropertySet.class, xControl.getModel());
try {
xModelPropertySet.setPropertyValue("Enabled", Boolean.valueOf(enable));
} catch (IllegalArgumentException | UnknownPropertyException | PropertyVetoException
| WrappedTargetException e) {
return;
}
}
示例9: setPosition
import com.sun.star.beans.XPropertySet; //导入方法依赖的package包/类
public static void setPosition(XDialog dialog, int posX, int posY) {
XControlModel xDialogModel = UnoRuntime.queryInterface(XControl.class, dialog).getModel();
XPropertySet xPropSet = UnoRuntime.queryInterface(XPropertySet.class, xDialogModel);
try {
xPropSet.setPropertyValue("PositionX", posX);
xPropSet.setPropertyValue("PositionY", posY);
} catch (com.sun.star.lang.IllegalArgumentException | UnknownPropertyException | PropertyVetoException
| WrappedTargetException e) {
return;
}
}
示例10: copyTo
import com.sun.star.beans.XPropertySet; //导入方法依赖的package包/类
/**
* Copies the properties for the given keys of this properties into the given properties.
*
* @param propertyKeys the keys of the properties to be copied
* @param properties the properties to copy properties into
*
* @throws OfficeException if copy failed
*
* @author Markus Krüger
*/
public void copyTo(String[] propertyKeys, IProperties properties) throws OfficeException {
XPropertySet foreignPropertySet = properties.getXPropertySet();
for(int i = 0; i < propertyKeys.length; i++) {
try {
String key = propertyKeys[i];
foreignPropertySet.setPropertyValue(key,xPropertySet.getPropertyValue(key));
}
catch(Exception exception) {
OfficeException officeException = new OfficeException(exception.getMessage());
officeException.initCause(exception);
throw officeException;
}
}
}
示例11: insertPageBreak
import com.sun.star.beans.XPropertySet; //导入方法依赖的package包/类
/**
* Inserts page break at the current cursor position.
*
* @throws NOAException if the page break can not be set
*
* @author Andreas Bröker
* @date 19.09.2006
*/
public void insertPageBreak() throws NOAException {
try {
XCell xCell = (XCell)UnoRuntime.queryInterface(XCell.class, xTextCursor.getText());
XPropertySet propertySet = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
propertySet.setPropertyValue("BreakType", BreakType.PAGE_AFTER);
if(xCell == null) {
xTextCursor.getText().insertControlCharacter(xTextCursor, ControlCharacter.PARAGRAPH_BREAK, false);
}
}
catch(Throwable throwable) {
throw new NOAException("Error inserting page break.",throwable);
}
}
示例12: zoom
import com.sun.star.beans.XPropertySet; //导入方法依赖的package包/类
/**
* 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);
}
}
示例13: addUserTextField
import com.sun.star.beans.XPropertySet; //导入方法依赖的package包/类
/**
* Adds new user textfield.
*
* @param name
* name of the textfield
* @param content
* content of the textfield
*
* @return new textfield
*
* @throws TextException
* if any error occurs during textfield creation
*
* @author Andreas Bröker
*/
public ITextField addUserTextField(String name, String content)
throws TextException {
try {
XMultiServiceFactory xMultiServiceFactory = (XMultiServiceFactory) UnoRuntime
.queryInterface(XMultiServiceFactory.class,
textDocument.getXTextDocument());
Object textField = xMultiServiceFactory
.createInstance(ITextFieldService.USER_TEXTFIELD_ID);
XDependentTextField xDependentTextField = (XDependentTextField) UnoRuntime
.queryInterface(XDependentTextField.class, textField);
Object oFieldMaster = xMultiServiceFactory
.createInstance(ITextFieldService.USER_TEXTFIELD_MASTER_ID);
XPropertySet xPropertySet = (XPropertySet) UnoRuntime
.queryInterface(XPropertySet.class, oFieldMaster);
xPropertySet.setPropertyValue("Name", name);
xPropertySet.setPropertyValue("Content", content);
xDependentTextField.attachTextFieldMaster(xPropertySet);
return new TextField(textDocument, xDependentTextField);
} catch (Exception exception) {
throw new TextException(exception);
}
}
示例14: createPlaceholderTextField
import com.sun.star.beans.XPropertySet; //导入方法依赖的package包/类
/**
* Creates a new placeholder textfield.
*
* @param name
* name of the placeholder textfield
* @param hint
* the hint of the placeholder textfield, may be null
* @param placeholderType
* the type of the placeholder found in static members of
* com.sun.star.text.PlaceholderType (i.e. PlaceholderType.TEXT)
*
* @return new placeholder textfield
*
* @throws TextException
* if any error occurs during placeholder textfield creation
*
* @author Markus Krüger
* @date 30.05.2007
*/
public ITextField createPlaceholderTextField(String name, String hint,
short placeholderType) throws TextException {
try {
if (name == null) {
throw new TextException(
"The placeholders name to create can not be null.");
}
if (placeholderType < 0 || placeholderType > 4) {
throw new TextException(
"The placeholder type must be one of the valid static members of com.sun.star.text.PlaceholderType.");
}
XMultiServiceFactory xMultiServiceFactory = (XMultiServiceFactory) UnoRuntime
.queryInterface(XMultiServiceFactory.class,
textDocument.getXTextDocument());
Object textField = xMultiServiceFactory
.createInstance(ITextFieldService.PLACEHOLDER_TEXTFIELD_ID);
XTextField xTextField = (XTextField) UnoRuntime.queryInterface(
XTextField.class, textField);
XPropertySet xPropertySet = (XPropertySet) UnoRuntime
.queryInterface(XPropertySet.class, xTextField);
// Grundeinstellung festlegen
xPropertySet.setPropertyValue("PlaceHolder", name);
xPropertySet.setPropertyValue("PlaceHolderType", new Short(
placeholderType));
if (hint != null) {
xPropertySet.setPropertyValue("Hint", hint);
}
return new TextField(textDocument, xTextField);
} catch (Exception exception) {
throw new TextException(exception);
}
}
示例15: createVariableTextFieldMaster
import com.sun.star.beans.XPropertySet; //导入方法依赖的package包/类
/**
* Creates a new variable textfield master and returns it, or returns the
* one that already exists, if it does. TODO maybe some more parameters are
* needed???
*
* @param name
* name of the variable textfield master
* @param variableType
* the type of the variable master found in static members of
* com.sun.star.text.SetVariableType (i.e.
* SetVariableType.STRING)
*
* @return the variable textfield master with the given name
*
* @throws TextException
* if any error occurs during variable textfield master creation
*
* @author Markus Krüger
* @date 30.05.2007
*/
public IVariableTextFieldMaster createVariableTextFieldMaster(String name,
short variableType) throws TextException {
try {
if (name == null) {
throw new TextException(
"The variable name to create can not be null.");
}
if (variableType < 0 || variableType > 3) {
throw new TextException(
"The variable type must be one of the valid static members of com.sun.star.text.SetVariableType.");
}
XMultiServiceFactory xMultiServiceFactory = (XMultiServiceFactory) UnoRuntime
.queryInterface(XMultiServiceFactory.class,
textDocument.getXTextDocument());
Object oFieldMaster = xMultiServiceFactory
.createInstance(ITextFieldService.VARIABLES_TEXTFIELD_MASTER_ID);
XPropertySet xMasterPropertySet = (XPropertySet) UnoRuntime
.queryInterface(XPropertySet.class, oFieldMaster);
// Grundeinstellung festlegen
xMasterPropertySet.setPropertyValue("Name", name);
xMasterPropertySet.setPropertyValue("SubType", new Short(
variableType));
return new VariableTextFieldMaster(textDocument, xMasterPropertySet);
} catch (Exception exception) {
throw new TextException(exception);
}
}