1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
XTextDocument xDoc = getInterface(XTextDocument.class, oDoc);
XTextFieldsSupplier tfs = getInterface(XTextFieldsSupplier.class, oDoc);
XEnumeration fields = tfs.getTextFields().createEnumeration();
XRefreshable xRefreshable = (XRefreshable) UnoRuntime.queryInterface(XRefreshable.class, tfs.getTextFields());
String[] fieldMasters = tfs.getTextFieldMasters().getElementNames();
if (fieldMasters != null) {
for (String fieldMaster : fieldMasters) {
XPropertySet props = getInterface(XPropertySet.class, tfs.getTextFieldMasters().getByName(fieldMaster));
if (isSupportedService("com.sun.star.text.fieldmaster.Database", tfs.getTextFieldMasters().getByName(fieldMaster))) {
if (oldDataSourceName.equals(props.getPropertyValue("DataBaseName"))
&& oldDataTableName.equals(props.getPropertyValue("DataTableName"))) {
props.setPropertyValue("DataBaseName", dataSourceName);
props.setPropertyValue("DataTableName", dataTableName);
}
}
}
}
while (fields.hasMoreElements()) {
Object o = fields.nextElement();
XPropertySet props = ConnexionOO.getInterface(XPropertySet.class, o);
if (isSupportedService("com.sun.star.text.textfield.DatabaseNextSet", o)) {
if (oldDataSourceName.equals(props.getPropertyValue("DataBaseName"))
&& oldDataTableName.equals(props.getPropertyValue("DataTableName"))) {
props.setPropertyValue("DataBaseName", dataSourceName);
props.setPropertyValue("DataTableName", dataTableName);
}
}
if (isSupportedService("com.sun.star.text.textfield.HiddenText", o)
|| isSupportedService("com.sun.star.text.textfield.HiddenParagraph", o)
|| isSupportedService("com.sun.star.text.textfield.ConditionalText", o)) {
String condition = (String) props.getPropertyValue("Condition");
props.setPropertyValue("Condition", condition.replaceAll(oldDataSourceName + "\\." + oldDataTableName, dataSourceName + "."
+ dataTableName));
}
}
xRefreshable.refresh();
getStorable(oDoc).store(); |
Partager