|
Hi, I would like to add an alien XML attribute to a text portion. But I don't understand very well how I can select only a text portion and add the attribute only to this text. Here is the Java code: -------------------------------- ..... XTextRange xEnd = xText.getEnd(); xEnd.setString(", Now I continue with a new Text Style...(T1)"); addAttributeToText(xEnd,"semantic-text:text1","N/A"); xEnd = xText.getEnd(); xEnd.setString("I continue again (T2)"); addAttributeToText(xEnd,"semantic-text:text2","N/A"); xText.insertControlCharacter(xTextCursor, ControlCharacter.PARAGRAPH_BREAK, false); ....... -------------------------------- Where addAttributeToText method is: -------------------------------- private void addAttributeToText(XTextRange xTextRange,String XMLAttrName,String XMLAttrVal) throws UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException { XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextRange); XNameContainer uda = createMyAttribute(xCursorProps,"TextUserDefinedAttributes","CDATA",XMLAttrName,XMLAttrVal); xCursorProps.setPropertyValue("TextUserDefinedAttributes", uda); } -------------------------------- When I look into the content.xml I have this result: -------------------------------- <style:style style:name="T1" style:family="text"> <style:text-properties semantic-text:text1="N/A" /> </style:style> <style:style style:name="T2" style:family="text"> <style:text-properties semantic-text:text1="N/A" semantic-text:text2="N/A" /> </style:style> .... <text:p text:style-name="P3"> This is the first Paragraph <text:span text:style-name="T1">, Now I continue with a new Text Style...(T1)</text:span> <text:span text:style-name="T2">I continue again (T2)</text:span> </text:p> <text:p text:style-name="P4"> <text:span text:style-name="T2">This is the second
Paragraph</text:span>
</text:p> - <text:p
text:style-name="Standard">
<text:span text:style-name="T2" />
</text:p>
But T2 is propagated onto next paragraphs too, why this? XTextRange xEnd = xText.getEnd() should be the range relative to the text portion added; so I thought that the alien attribute lived only in this text portion and not in the whole text. And why has T2 the alien attribute defined in T1 too. I would like to have an OD content.xml like this: -------------------------------- <style:style style:name="T1" style:family="text"> <style:text-properties semantic-text:text1="N/A" /> </style:style> <style:style style:name="T2" style:family="text">
<style:text-properties semantic-text:text2="N/A" /> </style:style> <text:p text:style-name="P3"> This is the
first Paragraph
<text:span text:style-name="T1">, Now I
continue with a new Text Style...(T1)</text:span>
<text:span text:style-name="T2">I continue again (T2)</text:span>
</text:p> <text:p text:style-name="P4">This is
the second Paragraph</text:span></text:p>
<text:p text:style-name="Standard"> </text:p>
Thanks Roberto --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] |
