Hi stephan,
As u set i had set the property HyperLinkURL using the following code
// get the document container
XText xText = xTextDocument.getText();
// create text cursor for selecting and formatting
XTextCursor curText = xText.createTextCursor();
// get the XWordCursor interface of the document cursor
XWordCursor curWord = (XWordCursor)
UnoRuntime.queryInterface(XWordCursor.class, curText);
// get the XMultiServiceFactory interface
XMultiServiceFactory mxDocFactory = (XMultiServiceFactory)
UnoRuntime.queryInterface(XMultiServiceFactory.class,
xTextDocument);
// write some text
curText.setString("How to create and apply style.");
// create a new style
// get the CharacterStyle service
Object oCharacterStyle =
mxDocFactory.createInstance("com.sun.star.style.CharacterStyle");
// get the XStyle interface of it
XStyle xStyle = (XStyle)
UnoRuntime.queryInterface(XStyle.class, oCharacterStyle);
// get the XPropertySet interface of the new style
XPropertySet xStyleProps = (XPropertySet)
UnoRuntime.queryInterface (XPropertySet.class, xStyle);
// give the new style, hyper link
xStyleProps.setPropertyValue ("HyperLinkURL", new String("www.gmail.com
"));
// register the newly created style
// get the StyleFamiliesSupplier interface
XStyleFamiliesSupplier supStyleFamilies = (XStyleFamiliesSupplier)
UnoRuntime.queryInterface(XStyleFamiliesSupplier.class,
xTextDocument);
// get the XNameAccess interface of the actual style families
XNameAccess nStyleFamilies = (XNameAccess)
UnoRuntime.queryInterface (
XNameAccess.class, supStyleFamilies.getStyleFamilies());
// access the 'CharacterStyles' Family
XNameContainer xFamily = (XNameContainer)
UnoRuntime.queryInterface(
XNameContainer.class,
nStyleFamilies.getByName("CharacterStyles"));
// Insert the newly created style into the CharacterStyles family
xFamily.insertByName("Newly created Style", xStyle);
// ------------------------------
// select word to apply newly created style
// Select the first and sencond paragraph.
// the selection is defined between (false) to (true).
curWord.gotoNextWord(false);
curWord.gotoNextWord(false);
curWord.gotoNextWord(true);
curWord.gotoNextWord(true);
curWord.gotoNextWord(true);
// access the property set of the cursor selection
XPropertySet xCursorProps = (XPropertySet)
UnoRuntime.queryInterface(XPropertySet.class, curWord);
// ------------------------------
// set the style to the selection to our newly created style
//Helper.wrtMsg("Apply the style to the selection ");
xCursorProps.setPropertyValue("CharStyleName", "Newly created Style");
but it is showing the following exeception
Exception in thread "main" com.sun.star.beans.UnknownPropertyException:
Unknown property: HyperLinkURL at
com.sun.star.lib.uno.environments.remote.Job.remoteUnoRequestRaisedException
(Job.java:275)
but the same code works for CharHeight,Charweight and CharUnderline charcter
properties
what is wrong ?