You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by fa...@apache.org on 2018/07/25 21:24:30 UTC

svn commit: r1836674 - in /poi/trunk/src: examples/src/org/apache/poi/xssf/eventusermodel/ ooxml/java/org/apache/poi/xssf/binary/ ooxml/java/org/apache/poi/xssf/eventusermodel/ ooxml/java/org/apache/poi/xssf/extractor/ ooxml/java/org/apache/poi/xssf/mo...

Author: fanningpj
Date: Wed Jul 25 21:24:29 2018
New Revision: 1836674

URL: http://svn.apache.org/viewvc?rev=1836674&view=rev
Log:
add SharedStrings interface to allow our XSSF code to more easily extended by external projects

Added:
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/SharedStrings.java
      - copied, changed from r1836648, poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/SharedStringsTable.java
Modified:
    poi/trunk/src/examples/src/org/apache/poi/xssf/eventusermodel/XLSX2CSV.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/binary/XSSFBSharedStringsTable.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/binary/XSSFBSheetHandler.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/eventusermodel/ReadOnlySharedStringsTable.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/eventusermodel/XSSFSheetXMLHandler.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFBEventBasedExcelExtractor.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFEventBasedExcelExtractor.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/SharedStringsTable.java

Modified: poi/trunk/src/examples/src/org/apache/poi/xssf/eventusermodel/XLSX2CSV.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/examples/src/org/apache/poi/xssf/eventusermodel/XLSX2CSV.java?rev=1836674&r1=1836673&r2=1836674&view=diff
==============================================================================
--- poi/trunk/src/examples/src/org/apache/poi/xssf/eventusermodel/XLSX2CSV.java (original)
+++ poi/trunk/src/examples/src/org/apache/poi/xssf/eventusermodel/XLSX2CSV.java Wed Jul 25 21:24:29 2018
@@ -33,6 +33,7 @@ import org.apache.poi.ss.util.CellRefere
 import org.apache.poi.ooxml.util.SAXHelper;
 import org.apache.poi.xssf.eventusermodel.XSSFSheetXMLHandler.SheetContentsHandler;
 import org.apache.poi.xssf.extractor.XSSFEventBasedExcelExtractor;
+import org.apache.poi.xssf.model.SharedStrings;
 import org.apache.poi.xssf.model.StylesTable;
 import org.apache.poi.xssf.usermodel.XSSFComment;
 import org.xml.sax.ContentHandler;
@@ -180,7 +181,7 @@ public class XLSX2CSV {
      */
     public void processSheet(
             StylesTable styles,
-            ReadOnlySharedStringsTable strings,
+            SharedStrings strings,
             SheetContentsHandler sheetHandler, 
             InputStream sheetInputStream) throws IOException, SAXException {
         DataFormatter formatter = new DataFormatter();

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/binary/XSSFBSharedStringsTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/binary/XSSFBSharedStringsTable.java?rev=1836674&r1=1836673&r2=1836674&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/binary/XSSFBSharedStringsTable.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/binary/XSSFBSharedStringsTable.java Wed Jul 25 21:24:29 2018
@@ -24,15 +24,19 @@ import java.util.List;
 
 import org.apache.poi.openxml4j.opc.OPCPackage;
 import org.apache.poi.openxml4j.opc.PackagePart;
+import org.apache.poi.ss.usermodel.RichTextString;
 import org.apache.poi.util.Internal;
 import org.apache.poi.util.LittleEndian;
+import org.apache.poi.util.Removal;
+import org.apache.poi.xssf.model.SharedStrings;
+import org.apache.poi.xssf.usermodel.XSSFRichTextString;
 import org.xml.sax.SAXException;
 
 /**
  * @since 3.16-beta3
  */
 @Internal
-public class XSSFBSharedStringsTable {
+public class XSSFBSharedStringsTable implements SharedStrings {
 
     /**
      * An integer representing the total count of strings in the workbook. This count does not
@@ -83,17 +87,37 @@ public class XSSFBSharedStringsTable {
     }
 
     /**
+     * Return all the strings.
+     * Formatting is ignored.
      *
-     * @return a defensive copy of strings
+     * @return a list with all the shared strings.
+     * @deprecated use <code>getItemAt</code> instead
      */
+    @Removal(version = "4.2")
+    @Deprecated
     public List<String> getItems() {
         List<String> ret = new ArrayList<>(strings.size());
         ret.addAll(strings);
         return ret;
     }
 
-    public String getEntryAt(int i) {
-        return strings.get(i);
+    /**
+     * Return the string at a given index.
+     * Formatting is ignored.
+     *
+     * @param idx index of item to return.
+     * @return the item at the specified position in this Shared String table.
+     * @deprecated use <code>getItemAt</code> instead
+     */
+    @Removal(version = "4.2")
+    @Deprecated
+    public String getEntryAt(int idx) {
+        return strings.get(idx);
+    }
+
+    @Override
+    public RichTextString getItemAt(int idx) {
+        return new XSSFRichTextString(getEntryAt(idx));
     }
 
     /**
@@ -102,6 +126,7 @@ public class XSSFBSharedStringsTable {
      *
      * @return the total count of strings in the workbook
      */
+    @Override
     public int getCount() {
         return this.count;
     }
@@ -113,6 +138,7 @@ public class XSSFBSharedStringsTable {
      *
      * @return the total count of unique strings in the workbook
      */
+    @Override
     public int getUniqueCount() {
         return this.uniqueCount;
     }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/binary/XSSFBSheetHandler.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/binary/XSSFBSheetHandler.java?rev=1836674&r1=1836673&r2=1836674&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/binary/XSSFBSheetHandler.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/binary/XSSFBSheetHandler.java Wed Jul 25 21:24:29 2018
@@ -23,12 +23,13 @@ import java.util.Queue;
 
 import org.apache.poi.ss.usermodel.BuiltinFormats;
 import org.apache.poi.ss.usermodel.DataFormatter;
+import org.apache.poi.ss.usermodel.RichTextString;
 import org.apache.poi.ss.util.CellAddress;
 import org.apache.poi.util.Internal;
 import org.apache.poi.util.LittleEndian;
 import org.apache.poi.xssf.eventusermodel.XSSFSheetXMLHandler;
+import org.apache.poi.xssf.model.SharedStrings;
 import org.apache.poi.xssf.usermodel.XSSFComment;
-import org.apache.poi.xssf.usermodel.XSSFRichTextString;
 
 /**
  * @since 3.16-beta3
@@ -38,7 +39,7 @@ public class XSSFBSheetHandler extends X
 
     private static final int CHECK_ALL_ROWS = -1;
 
-    private final XSSFBSharedStringsTable stringsTable;
+    private final SharedStrings stringsTable;
     private final XSSFSheetXMLHandler.SheetContentsHandler handler;
     private final XSSFBStylesTable styles;
     private final XSSFBCommentsTable comments;
@@ -56,7 +57,7 @@ public class XSSFBSheetHandler extends X
     public XSSFBSheetHandler(InputStream is,
                              XSSFBStylesTable styles,
                              XSSFBCommentsTable comments,
-                             XSSFBSharedStringsTable strings,
+                             SharedStrings strings,
                              XSSFSheetXMLHandler.SheetContentsHandler sheetContentsHandler,
                              DataFormatter dataFormatter,
                              boolean formulasNotResults) {
@@ -208,7 +209,7 @@ public class XSSFBSheetHandler extends X
     private void handleBrtCellIsst(byte[] data) {
         beforeCellValue(data);
         int idx = XSSFBUtils.castToInt(LittleEndian.getUInt(data, XSSFBCellHeader.length));
-        XSSFRichTextString rtss = new XSSFRichTextString(stringsTable.getEntryAt(idx));
+        RichTextString rtss = stringsTable.getItemAt(idx);
         handleCellValue(rtss.getString());
     }
 

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/eventusermodel/ReadOnlySharedStringsTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/eventusermodel/ReadOnlySharedStringsTable.java?rev=1836674&r1=1836673&r2=1836674&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/eventusermodel/ReadOnlySharedStringsTable.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/eventusermodel/ReadOnlySharedStringsTable.java Wed Jul 25 21:24:29 2018
@@ -28,7 +28,11 @@ import java.util.List;
 import org.apache.poi.openxml4j.opc.OPCPackage;
 import org.apache.poi.openxml4j.opc.PackagePart;
 import org.apache.poi.ooxml.util.SAXHelper;
+import org.apache.poi.ss.usermodel.RichTextString;
+import org.apache.poi.util.Removal;
+import org.apache.poi.xssf.model.SharedStrings;
 import org.apache.poi.xssf.usermodel.XSSFRelation;
+import org.apache.poi.xssf.usermodel.XSSFRichTextString;
 import org.xml.sax.Attributes;
 import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
@@ -75,7 +79,7 @@ import org.xml.sax.helpers.DefaultHandle
 * </pre>
  *
  */
-public class ReadOnlySharedStringsTable extends DefaultHandler {
+public class ReadOnlySharedStringsTable extends DefaultHandler implements SharedStrings {
 
     protected final boolean includePhoneticRuns;
 
@@ -205,15 +209,32 @@ public class ReadOnlySharedStringsTable
      *
      * @param idx index of item to return.
      * @return the item at the specified position in this Shared String table.
+     * @deprecated use <code>getItemAt</code> instead
      */
+    @Removal(version = "4.2")
+    @Deprecated
     public String getEntryAt(int idx) {
         return strings.get(idx);
     }
 
+    /**
+     * Returns all the strings.
+     * Formatting is ignored.
+     *
+     * @return a list with all the strings
+     * @deprecated use <code>getItemAt</code> instead
+     */
+    @Removal(version = "4.2")
+    @Deprecated
     public List<String> getItems() {
         return strings;
     }
 
+    @Override
+    public RichTextString getItemAt(int idx) {
+        return new XSSFRichTextString(getEntryAt(idx));
+    }
+
     //// ContentHandler methods ////
 
     private StringBuilder characters;

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/eventusermodel/XSSFSheetXMLHandler.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/eventusermodel/XSSFSheetXMLHandler.java?rev=1836674&r1=1836673&r2=1836674&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/eventusermodel/XSSFSheetXMLHandler.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/eventusermodel/XSSFSheetXMLHandler.java Wed Jul 25 21:24:29 2018
@@ -23,10 +23,12 @@ import java.util.Queue;
 
 import org.apache.poi.ss.usermodel.BuiltinFormats;
 import org.apache.poi.ss.usermodel.DataFormatter;
+import org.apache.poi.ss.usermodel.RichTextString;
 import org.apache.poi.ss.util.CellAddress;
 import org.apache.poi.util.POILogFactory;
 import org.apache.poi.util.POILogger;
 import org.apache.poi.xssf.model.CommentsTable;
+import org.apache.poi.xssf.model.SharedStrings;
 import org.apache.poi.xssf.model.StylesTable;
 import org.apache.poi.xssf.usermodel.XSSFCellStyle;
 import org.apache.poi.xssf.usermodel.XSSFComment;
@@ -72,7 +74,7 @@ public class XSSFSheetXMLHandler extends
     * Read only access to the shared strings table, for looking
     *  up (most) string cell's contents
     */
-   private ReadOnlySharedStringsTable sharedStringsTable;
+   private SharedStrings sharedStringsTable;
 
    /**
     * Where our text is going
@@ -117,7 +119,7 @@ public class XSSFSheetXMLHandler extends
    public XSSFSheetXMLHandler(
            StylesTable styles,
            CommentsTable comments,
-           ReadOnlySharedStringsTable strings,
+           SharedStrings strings,
            SheetContentsHandler sheetContentsHandler,
            DataFormatter dataFormatter,
            boolean formulasNotResults) {
@@ -139,7 +141,7 @@ public class XSSFSheetXMLHandler extends
     */
    public XSSFSheetXMLHandler(
            StylesTable styles,
-           ReadOnlySharedStringsTable strings,
+           SharedStrings strings,
            SheetContentsHandler sheetContentsHandler,
            DataFormatter dataFormatter,
            boolean formulasNotResults) {
@@ -154,7 +156,7 @@ public class XSSFSheetXMLHandler extends
     */
    public XSSFSheetXMLHandler(
            StylesTable styles,
-           ReadOnlySharedStringsTable strings,
+           SharedStrings strings,
            SheetContentsHandler sheetContentsHandler,
            boolean formulasNotResults) {
        this(styles, strings, sheetContentsHandler, new DataFormatter(), formulasNotResults);
@@ -351,7 +353,7 @@ public class XSSFSheetXMLHandler extends
                    String sstIndex = value.toString();
                    try {
                        int idx = Integer.parseInt(sstIndex);
-                       XSSFRichTextString rtss = new XSSFRichTextString(sharedStringsTable.getEntryAt(idx));
+                       RichTextString rtss = sharedStringsTable.getItemAt(idx);
                        thisStr = rtss.toString();
                    }
                    catch (NumberFormatException ex) {

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFBEventBasedExcelExtractor.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFBEventBasedExcelExtractor.java?rev=1836674&r1=1836673&r2=1836674&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFBEventBasedExcelExtractor.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFBEventBasedExcelExtractor.java Wed Jul 25 21:24:29 2018
@@ -32,6 +32,7 @@ import org.apache.poi.xssf.binary.XSSFBS
 import org.apache.poi.xssf.binary.XSSFBStylesTable;
 import org.apache.poi.xssf.eventusermodel.XSSFBReader;
 import org.apache.poi.xssf.eventusermodel.XSSFSheetXMLHandler.SheetContentsHandler;
+import org.apache.poi.xssf.model.SharedStrings;
 import org.apache.poi.xssf.usermodel.XSSFRelation;
 import org.apache.xmlbeans.XmlException;
 import org.xml.sax.SAXException;
@@ -94,7 +95,7 @@ public class XSSFBEventBasedExcelExtract
             SheetContentsHandler sheetContentsExtractor,
             XSSFBStylesTable styles,
             XSSFBCommentsTable comments,
-            XSSFBSharedStringsTable strings,
+            SharedStrings strings,
             InputStream sheetInputStream)
             throws IOException, SAXException {
 

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFEventBasedExcelExtractor.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFEventBasedExcelExtractor.java?rev=1836674&r1=1836673&r2=1836674&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFEventBasedExcelExtractor.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFEventBasedExcelExtractor.java Wed Jul 25 21:24:29 2018
@@ -40,6 +40,7 @@ import org.apache.poi.xssf.eventusermode
 import org.apache.poi.xssf.eventusermodel.XSSFSheetXMLHandler;
 import org.apache.poi.xssf.eventusermodel.XSSFSheetXMLHandler.SheetContentsHandler;
 import org.apache.poi.xssf.model.CommentsTable;
+import org.apache.poi.xssf.model.SharedStrings;
 import org.apache.poi.xssf.model.StylesTable;
 import org.apache.poi.xssf.usermodel.XSSFComment;
 import org.apache.poi.xssf.usermodel.XSSFShape;
@@ -232,7 +233,7 @@ public class XSSFEventBasedExcelExtracto
             SheetContentsHandler sheetContentsExtractor,
             StylesTable styles,
             CommentsTable comments,
-            ReadOnlySharedStringsTable strings,
+            SharedStrings strings,
             InputStream sheetInputStream)
             throws IOException, SAXException {
 
@@ -255,12 +256,17 @@ public class XSSFEventBasedExcelExtracto
         }
     }
 
+    protected SharedStrings createSharedStringsTable(OPCPackage container, boolean concatenatePhoneticRuns)
+            throws IOException, SAXException {
+        return new ReadOnlySharedStringsTable(container, concatenatePhoneticRuns);
+    }
+
     /**
      * Processes the file and returns the text
      */
     public String getText() {
         try {
-            ReadOnlySharedStringsTable strings = new ReadOnlySharedStringsTable(container, concatenatePhoneticRuns);
+            SharedStrings strings = createSharedStringsTable(container, concatenatePhoneticRuns);
             XSSFReader xssfReader = new XSSFReader(container);
             StylesTable styles = xssfReader.getStylesTable();
             XSSFReader.SheetIterator iter = (XSSFReader.SheetIterator) xssfReader.getSheetsData();

Copied: poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/SharedStrings.java (from r1836648, poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/SharedStringsTable.java)
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/SharedStrings.java?p2=poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/SharedStrings.java&p1=poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/SharedStringsTable.java&r1=1836648&r2=1836674&rev=1836674&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/SharedStringsTable.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/SharedStrings.java Wed Jul 25 21:24:29 2018
@@ -17,29 +17,7 @@
 
 package org.apache.poi.xssf.model;
 
-import static org.apache.poi.ooxml.POIXMLTypeLoader.DEFAULT_XML_OPTIONS;
-import static org.apache.poi.xssf.usermodel.XSSFRelation.NS_SPREADSHEETML;
-
-import java.io.Closeable;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.poi.ooxml.POIXMLDocumentPart;
-import org.apache.poi.openxml4j.opc.PackagePart;
 import org.apache.poi.ss.usermodel.RichTextString;
-import org.apache.poi.util.Removal;
-import org.apache.poi.xssf.usermodel.XSSFRichTextString;
-import org.apache.xmlbeans.XmlException;
-import org.apache.xmlbeans.XmlOptions;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRst;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSst;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.SstDocument;
 
 /**
  * Table of strings shared across all sheets in a workbook.
@@ -62,104 +40,15 @@ import org.openxmlformats.schemas.spread
  * properties, and phonetic properties (for East Asian languages).
  * </p>
  */
-public class SharedStringsTable extends POIXMLDocumentPart implements Closeable {
-
-    /**
-     *  Array of individual string items in the Shared String table.
-     */
-    private final List<CTRst> strings = new ArrayList<>();
-
-    /**
-     *  Maps strings and their indexes in the <code>strings</code> arrays
-     */
-    private final Map<String, Integer> stmap = new HashMap<>();
-
-    /**
-     * An integer representing the total count of strings in the workbook. This count does not
-     * include any numbers, it counts only the total of text strings in the workbook.
-     */
-    protected int count;
-
-    /**
-     * An integer representing the total count of unique strings in the Shared String Table.
-     * A string is unique even if it is a copy of another string, but has different formatting applied
-     * at the character level.
-     */
-    protected int uniqueCount;
-
-    private SstDocument _sstDoc;
-
-    private static final XmlOptions options = new XmlOptions();
-    static {
-        options.put( XmlOptions.SAVE_INNER );
-        options.put( XmlOptions.SAVE_AGGRESSIVE_NAMESPACES );
-        options.put( XmlOptions.SAVE_USE_DEFAULT_NAMESPACE );
-        options.setSaveImplicitNamespaces(Collections.singletonMap("", NS_SPREADSHEETML));
-    }
-
-    public SharedStringsTable() {
-        super();
-        _sstDoc = SstDocument.Factory.newInstance();
-        _sstDoc.addNewSst();
-    }
-
-    /**
-     * @since POI 3.14-Beta1
-     */
-    public SharedStringsTable(PackagePart part) throws IOException {
-        super(part);
-        readFrom(part.getInputStream());
-    }
-
-    /**
-     * Read this shared strings table from an XML file.
-     *
-     * @param is The input stream containing the XML document.
-     * @throws IOException if an error occurs while reading.
-     */
-    public void readFrom(InputStream is) throws IOException {
-        try {
-            int cnt = 0;
-            _sstDoc = SstDocument.Factory.parse(is, DEFAULT_XML_OPTIONS);
-            CTSst sst = _sstDoc.getSst();
-            count = (int)sst.getCount();
-            uniqueCount = (int)sst.getUniqueCount();
-            //noinspection deprecation
-            for (CTRst st : sst.getSiArray()) {
-                stmap.put(xmlText(st), cnt);
-                strings.add(st);
-                cnt++;
-            }
-        } catch (XmlException e) {
-            throw new IOException("unable to parse shared strings table", e);
-        }
-    }
-
-    protected String xmlText(CTRst st) {
-        return st.xmlText(options);
-    }
+public interface SharedStrings {
 
     /**
      * Return a string item by index
      *
      * @param idx index of item to return.
      * @return the item at the specified position in this Shared String table.
-     * @deprecated use <code>getItemAt(int idx)</code> instead
      */
-    @Removal(version = "4.2")
-    public CTRst getEntryAt(int idx) {
-        return strings.get(idx);
-    }
-
-    /**
-     * Return a string item by index
-     *
-     * @param idx index of item to return.
-     * @return the item at the specified position in this Shared String table.
-     */
-    public RichTextString getItemAt(int idx) {
-        return new XSSFRichTextString(strings.get(idx));
-    }
+    public RichTextString getItemAt(int idx);
 
     /**
      * Return an integer representing the total count of strings in the workbook. This count does not
@@ -167,9 +56,7 @@ public class SharedStringsTable extends
      *
      * @return the total count of strings in the workbook
      */
-    public int getCount(){
-        return count;
-    }
+    public int getCount();
 
     /**
      * Returns an integer representing the total count of unique strings in the Shared String Table.
@@ -178,121 +65,5 @@ public class SharedStringsTable extends
      *
      * @return the total count of unique strings in the workbook
      */
-    public int getUniqueCount(){
-        return uniqueCount;
-    }
-
-    /**
-     * Add an entry to this Shared String table (a new value is appended to the end).
-     *
-     * <p>
-     * If the Shared String table already contains this <code>CTRst</code> bean, its index is returned.
-     * Otherwise a new entry is aded.
-     * </p>
-     *
-     * @param st the entry to add
-     * @return index the index of added entry
-     * @deprecated use <code>addSharedStringItem(RichTextString string)</code> instead
-     */
-    @Removal(version = "4.2") //make private in 4.2
-    public int addEntry(CTRst st) {
-        String s = xmlText(st);
-        count++;
-        if (stmap.containsKey(s)) {
-            return stmap.get(s);
-        }
-
-        uniqueCount++;
-        //create a CTRst bean attached to this SstDocument and copy the argument CTRst into it
-        CTRst newSt = _sstDoc.getSst().addNewSi();
-        newSt.set(st);
-        int idx = strings.size();
-        stmap.put(s, idx);
-        strings.add(newSt);
-        return idx;
-    }
-
-    /**
-     * Add an entry to this Shared String table (a new value is appended to the end).
-     *
-     * <p>
-     * If the Shared String table already contains this string entry, its index is returned.
-     * Otherwise a new entry is added.
-     * </p>
-     *
-     * @param string the entry to add
-     * @since POI 4.0.0
-     * @return index the index of added entry
-     */
-    public int addSharedStringItem(RichTextString string) {
-        if(!(string instanceof XSSFRichTextString)){
-            throw new IllegalArgumentException("Only XSSFRichTextString argument is supported");
-        }
-        return addEntry(((XSSFRichTextString) string).getCTRst());
-    }
-
-    /**
-     * Provide low-level access to the underlying array of CTRst beans
-     *
-     * @return array of CTRst beans
-     * @deprecated use <code>getSharedStringItems</code> instead
-     */
-    @Removal(version = "4.2")
-    public List<CTRst> getItems() {
-        return Collections.unmodifiableList(strings);
-    }
-
-    /**
-     * Provide access to the strings in the SharedStringsTable
-     *
-     * @return list of shared string instances
-     */
-    public List<RichTextString> getSharedStringItems() {
-        ArrayList<RichTextString> items = new ArrayList<>();
-        for (CTRst rst : strings) {
-            items.add(new XSSFRichTextString(rst));
-        }
-        return Collections.unmodifiableList(items);
-    }
-
-    /**
-     * Write this table out as XML.
-     *
-     * @param out The stream to write to.
-     * @throws IOException if an error occurs while writing.
-     */
-    public void writeTo(OutputStream out) throws IOException {
-        XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS);
-        // the following two lines turn off writing CDATA
-        // see Bugzilla 48936
-        xmlOptions.setSaveCDataLengthThreshold(1000000);
-        xmlOptions.setSaveCDataEntityCountThreshold(-1);
-
-        //re-create the sst table every time saving a workbook
-        CTSst sst = _sstDoc.getSst();
-        sst.setCount(count);
-        sst.setUniqueCount(uniqueCount);
-
-        _sstDoc.save(out, xmlOptions);
-    }
-
-    @Override
-    protected void commit() throws IOException {
-        PackagePart part = getPackagePart();
-        try (OutputStream out = part.getOutputStream()) {
-            writeTo(out);
-        }
-    }
-
-    /**
-     * Close any open resources, like temp files. This method is called by <code>XSSFWorkbook#close()</code>.
-     * <p>
-     *     This implementation is empty but subclasses may need to implement some logic.
-     * </p>
-     *
-     * @since 4.0.0
-     * @throws IOException if an error occurs while closing.
-     */
-    @Override
-    public void close() throws IOException {}
+    public int getUniqueCount();
 }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/SharedStringsTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/SharedStringsTable.java?rev=1836674&r1=1836673&r2=1836674&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/SharedStringsTable.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/SharedStringsTable.java Wed Jul 25 21:24:29 2018
@@ -62,7 +62,7 @@ import org.openxmlformats.schemas.spread
  * properties, and phonetic properties (for East Asian languages).
  * </p>
  */
-public class SharedStringsTable extends POIXMLDocumentPart implements Closeable {
+public class SharedStringsTable extends POIXMLDocumentPart implements SharedStrings, Closeable {
 
     /**
      *  Array of individual string items in the Shared String table.
@@ -157,6 +157,7 @@ public class SharedStringsTable extends
      * @param idx index of item to return.
      * @return the item at the specified position in this Shared String table.
      */
+    @Override
     public RichTextString getItemAt(int idx) {
         return new XSSFRichTextString(strings.get(idx));
     }
@@ -167,6 +168,7 @@ public class SharedStringsTable extends
      *
      * @return the total count of strings in the workbook
      */
+    @Override
     public int getCount(){
         return count;
     }
@@ -178,6 +180,7 @@ public class SharedStringsTable extends
      *
      * @return the total count of unique strings in the workbook
      */
+    @Override
     public int getUniqueCount(){
         return uniqueCount;
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org