Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1521,10 +1521,10 @@ private void _getText(XmlObject o, StringBuilder text) {

if (o instanceof CTText) {
final Node node = o.getDomNode();
// Field Codes (w:instrText, defined in spec sec. 17.16.23)
// Field Codes (w:instrText, defined in spec sec. 17.16.23 and w:delInstrText, defined in spec sec. 17.16.13)
// come up as instances of CTText, but we don't want them
// in the normal text output
if (!("instrText".equals(node.getLocalName()) && XSSFRelation.NS_WORDPROCESSINGML.equals(node.getNamespaceURI()))) {
if (!(("instrText".equals(node.getLocalName()) || "delInstrText".equals(node.getLocalName())) && XSSFRelation.NS_WORDPROCESSINGML.equals(node.getNamespaceURI()))) {
String textValue = ((CTText) o).getStringValue();
if (textValue != null) {
if (isCapitalized() || isSmallCaps()) {
Expand Down Expand Up @@ -1564,6 +1564,9 @@ private void _getText(XmlObject o, StringBuilder text) {
final Node node = o.getDomNode();
if (XSSFRelation.NS_WORDPROCESSINGML.equals(node.getNamespaceURI())) {
switch (node.getLocalName()) {
case "noBreakHyphen":
text.append('‑');
break;
case "tab":
text.append('\t');
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,17 @@ void testSetGetText() {
//fail("Position wrong");
}

@Test
void testText() {
ctRun.addNewT().setStringValue("TEST STRING 1");
ctRun.addNewInstrText().setStringValue("InstrText");
ctRun.addNewNoBreakHyphen();
ctRun.addNewDelInstrText().setStringValue("DelInstrText");
ctRun.addNewT().setStringValue("1");
XWPFRun run = new XWPFRun(ctRun, irb);
assertEquals("TEST STRING 1‑1", run.text());
}

/*
* bug 59208
* Purpose: test all valid boolean-like values
Expand Down