View | Details | Raw Unified | Return to bug 51519
Collapse All | Expand All

(-)a/src/ooxml/java/org/apache/poi/xssf/eventusermodel/ReadOnlySharedStringsTable.java (-4 / +11 lines)
Lines 29-35 import org.apache.poi.openxml4j.opc.OPCPackage; Link Here
29
import org.apache.poi.openxml4j.opc.PackagePart;
29
import org.apache.poi.openxml4j.opc.PackagePart;
30
import org.apache.poi.openxml4j.opc.PackageRelationship;
30
import org.apache.poi.openxml4j.opc.PackageRelationship;
31
import org.apache.poi.xssf.usermodel.XSSFRelation;
31
import org.apache.poi.xssf.usermodel.XSSFRelation;
32
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRst;
33
import org.xml.sax.Attributes;
32
import org.xml.sax.Attributes;
34
import org.xml.sax.InputSource;
33
import org.xml.sax.InputSource;
35
import org.xml.sax.SAXException;
34
import org.xml.sax.SAXException;
Lines 41-47 import org.xml.sax.helpers.DefaultHandler; Link Here
41
 *  table. Most of the text cells will reference something
40
 *  table. Most of the text cells will reference something
42
 *  from in here.
41
 *  from in here.
43
 * <p>Note that each SI entry can have multiple T elements, if the
42
 * <p>Note that each SI entry can have multiple T elements, if the
44
 *  string is made up of bits with different formatting.
43
 *  string is made up of bits with different formatting, though not
44
 *  all of these elements should be included. T elements within
45
 *  RPH elements, for example, are phonetic representations of the
46
 *  text and not part of the text itself.
45
 * <p>Example input:
47
 * <p>Example input:
46
 * <pre>
48
 * <pre>
47
&lt;?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
49
&lt;?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
Lines 186-191 public class ReadOnlySharedStringsTable extends DefaultHandler { Link Here
186
188
187
    private StringBuffer characters;
189
    private StringBuffer characters;
188
    private boolean tIsOpen;
190
    private boolean tIsOpen;
191
    private boolean rPhIsOpen;
189
192
190
    public void startElement(String uri, String localName, String name,
193
    public void startElement(String uri, String localName, String name,
191
                             Attributes attributes) throws SAXException {
194
                             Attributes attributes) throws SAXException {
Lines 202-207 public class ReadOnlySharedStringsTable extends DefaultHandler { Link Here
202
            characters.setLength(0);
205
            characters.setLength(0);
203
        } else if ("t".equals(name)) {
206
        } else if ("t".equals(name)) {
204
            tIsOpen = true;
207
            tIsOpen = true;
208
        } else if ("rPh".equals(name)) {
209
            rPhIsOpen = true;
205
        }
210
        }
206
    }
211
    }
207
212
Lines 211-225 public class ReadOnlySharedStringsTable extends DefaultHandler { Link Here
211
            strings.add(characters.toString());
216
            strings.add(characters.toString());
212
        } else if ("t".equals(name)) {
217
        } else if ("t".equals(name)) {
213
           tIsOpen = false;
218
           tIsOpen = false;
219
        } else if ("rPh".equals(name)) {
220
            rPhIsOpen = false;
214
        }
221
        }
215
    }
222
    }
216
223
217
    /**
224
    /**
218
     * Captures characters only if a t(ext) element is open.
225
     * Captures characters only if a (non-phonetic) t(ext) element is open.
219
     */
226
     */
220
    public void characters(char[] ch, int start, int length)
227
    public void characters(char[] ch, int start, int length)
221
            throws SAXException {
228
            throws SAXException {
222
        if (tIsOpen)
229
        if (tIsOpen && !rPhIsOpen)
223
            characters.append(ch, start, length);
230
            characters.append(ch, start, length);
224
    }
231
    }
225
232

Return to bug 51519