Hello!
When editing font options locally (Tools → Options → LibreOffice Writer → Basic Fonts (Western)) my opened document changes, but when I’m doing it via UNO nothing happens and fonts are not applied. What am I doing wrong?
Here’s listing:
private void setTimesNewRomanByDefault()
throws com.sun.star.uno.Exception {
XMultiServiceFactory configProvider = UnoRuntime.queryInterface(XMultiServiceFactory.class,
_context.getServiceManager().createInstanceWithContext("com.sun.star.configuration.ConfigurationProvider", _context));
PropertyValue nodePath = new PropertyValue();
nodePath.Name = "nodepath";
nodePath.Value = "/org.openoffice.Office.Writer/DefaultFont";
Object updater = configProvider.createInstanceWithArguments("com.sun.star.configuration.ConfigurationUpdateAccess",
new PropertyValue[] { nodePath });
XNameReplace replacer = UnoRuntime.queryInterface(XNameReplace.class, updater);
replacer.replaceByName("Document", false); // I tried without this one, didn't work either
for (String name : new String[] { "List", "Index", "Caption", "Heading", "Standard" }) {
replacer.replaceByName(name, "Times New Roman");
}
UnoRuntime.queryInterface(XChangesBatch.class, updater).commitChanges();
UnoRuntime.queryInterface(XComponent.class, updater).dispose();
}