这是indexloc提供的服务,不要输入任何密码
Skip to content

replace_placeholders

Jochen Staerk edited this page Dec 21, 2015 · 1 revision

Source: Markus Krüger (NOA developer)

The following code shows how to replace OpenOffice.org placeholders added via 'Insert -> Field -> Others... -> Functions -> Placeholder (Text)':

  ...
  ITextDocument textDocument = ...;
  ITextFieldService textFieldService = textDocument.getTextFieldService();
  ITextField[] placeholders = textFieldService.getPlaceholderFields();
  for (int i = 0; i < placeholders.length; i++) {
    String placeholderDisplayText = placeholders[i].getDisplayText();
    placeholders[i].getTextRange().setText("Text for " + placeholderDisplayText);
  }

It is important to know, that the array of placeholders is not in any order, so you have to use the method "getDisplayText()" to check if it is the correct placeholder you want to replace.

Clone this wiki locally