| | |
| | | |
| | | // 创建新的run并设置文本 |
| | | XWPFRun newRun = paragraph.insertNewRun(info.startRun); |
| | | newRun.setText(info.replacementText); |
| | | // 如果有回车符,则插入一个空行 |
| | | if (info.replacementText.contains("\n") || info.replacementText.contains("\r") || info.replacementText.contains("\r\n")) { |
| | | log.info("info.originalText=================: {}", info.replacementText); |
| | | // 每一个\n,\r,\r\n都插入一个空行,并且最后的文本进行换行,为一整个文本 |
| | | String[] s = info.replacementText.split("\r\n"); |
| | | for (int i = 0; i < s.length; i++) { |
| | | if (i == 0) { |
| | | newRun.setText(s[i] + " "); |
| | | }else { |
| | | // newRun.addCarriageReturn(); |
| | | newRun.setText(s[i] + " "); |
| | | } |
| | | } |
| | | }else { |
| | | newRun.setText(info.replacementText); |
| | | } |
| | | |
| | | // 应用样式 |
| | | style.applyStyle(newRun); |