Hi Mathias

Adding a new CharacterStyle to a text document (with Java via
xFamily.insertByName()) succeeds and gives the appropriate entry in the
"Styles and Formatting" window. But applying it to any text yields a
document which can't be saved. Trying to save it gives a "Error in
writing sub-document content.xml" message. Doing the very same with a
ParagraphStyle doesn't result in that error message and the file gets
saved successfully. I'm using OOo 2.0.4.
Your mail is quite old now and I discovered it only accidently. I would
like to hear if you solved the problem by yourself. If it still appears
perhaps you can describe how you created the style you have inserted.

No, I unfortunately didn't have time to look at it any closer. The code is along the lines attached below. The cases for ParagraphStyle and CharacterStyle share the same code and getPropertyType() and getFamilyType are helper functions inside my code that differentiate between them.

Did you run into the same problem? I didn't find time yet to try it with OOo 2.1.

Regards

Arthur


com.sun.star.lang.XMultiServiceFactory mxFactory = (com.sun.star.lang.XMultiServiceFactory)com.sun.star.uno.UnoRuntime .queryInterface(com.sun.star.lang.XMultiServiceFactory.class, doc);

 xStyle = (com.sun.star.style.XStyle)com.sun.star.uno.UnoRuntime
            .queryInterface(com.sun.star.style.XStyle.class, mxFactory
                  .createInstance(getPropertyType()));

// applying some properties to the style here...

com.sun.star.style.XStyleFamiliesSupplier xSupplier = (com.sun.star.style.XStyleFamiliesSupplier)com.sun.star.uno.UnoRuntime
.queryInterface(com.sun.star.style.XStyleFamiliesSupplier.class, doc);

com.sun.star.container.XNameAccess xFamilies = (com.sun.star.container.XNameAccess)com.sun.star.uno.UnoRuntime .queryInterface(com.sun.star.container.XNameAccess.class, xSupplier.getStyleFamilies());

com.sun.star.container.XNameContainer xFamily = (com.sun.star.container.XNameContainer)com.sun.star.uno.UnoRuntime
            .queryInterface(com.sun.star.container.XNameContainer.class,
                  xFamilies.getByName(getFamilyType()));

 xFamily.insertByName(name, xStyle);

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to