Link Here
|
21 |
import java.io.OutputStream; |
21 |
import java.io.OutputStream; |
22 |
import java.util.HashMap; |
22 |
import java.util.HashMap; |
23 |
import java.util.Map; |
23 |
import java.util.Map; |
|
|
24 |
import java.util.Map.Entry; |
25 |
import java.util.TreeMap; |
24 |
|
26 |
|
25 |
import org.apache.poi.POIXMLDocumentPart; |
27 |
import org.apache.poi.POIXMLDocumentPart; |
26 |
import org.apache.poi.openxml4j.opc.PackagePart; |
28 |
import org.apache.poi.openxml4j.opc.PackagePart; |
27 |
import org.apache.poi.openxml4j.opc.PackageRelationship; |
29 |
import org.apache.poi.openxml4j.opc.PackageRelationship; |
|
|
30 |
import org.apache.poi.ss.usermodel.Comment; |
31 |
import org.apache.poi.ss.util.CellAddress; |
28 |
import org.apache.poi.xssf.usermodel.XSSFComment; |
32 |
import org.apache.poi.xssf.usermodel.XSSFComment; |
29 |
import org.apache.xmlbeans.XmlException; |
33 |
import org.apache.xmlbeans.XmlException; |
30 |
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTComment; |
34 |
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTComment; |
Link Here
|
117 |
@SuppressWarnings("deprecation") //YK: getXYZArray() array accessors are deprecated in xmlbeans with JDK 1.5 support |
121 |
@SuppressWarnings("deprecation") //YK: getXYZArray() array accessors are deprecated in xmlbeans with JDK 1.5 support |
118 |
public CTComment getCTComment(String cellRef) { |
122 |
public CTComment getCTComment(String cellRef) { |
119 |
// Create the cache if needed |
123 |
// Create the cache if needed |
|
|
124 |
prepareCTCommentCache(); |
125 |
|
126 |
// Return the comment, or null if not known |
127 |
return commentRefs.get(cellRef); |
128 |
} |
129 |
|
130 |
public Map<CellAddress, Comment> getCellComments(){ |
131 |
prepareCTCommentCache(); |
132 |
final TreeMap<CellAddress, Comment> map = new TreeMap<CellAddress, Comment>(); |
133 |
|
134 |
for(final Entry<String, CTComment> e: commentRefs.entrySet()){ |
135 |
map.put(CellAddress.fromString(e.getKey()), new XSSFComment(this, e.getValue(), null)); |
136 |
} |
137 |
|
138 |
return map; |
139 |
} |
140 |
|
141 |
@SuppressWarnings("deprecation") //YK: getXYZArray() array accessors are deprecated in xmlbeans with JDK 1.5 support |
142 |
private void prepareCTCommentCache() { |
143 |
// Create the cache if needed |
120 |
if(commentRefs == null) { |
144 |
if(commentRefs == null) { |
121 |
commentRefs = new HashMap<String, CTComment>(); |
145 |
commentRefs = new HashMap<String, CTComment>(); |
122 |
for (CTComment comment : comments.getCommentList().getCommentArray()) { |
146 |
for (CTComment comment : comments.getCommentList().getCommentArray()) { |
123 |
commentRefs.put(comment.getRef(), comment); |
147 |
commentRefs.put(comment.getRef(), comment); |
124 |
} |
148 |
} |
125 |
} |
149 |
} |
126 |
|
|
|
127 |
// Return the comment, or null if not known |
128 |
return commentRefs.get(cellRef); |
129 |
} |
150 |
} |
130 |
|
151 |
|
131 |
/** |
152 |
/** |