public void RemoveComment() { CommentsTable sheetComments = new CommentsTable(); CT_Comment a1 = sheetComments.NewComment("A1"); CT_Comment a2 = sheetComments.NewComment("A2"); CT_Comment a3 = sheetComments.NewComment("A3"); Assert.AreSame(a1, sheetComments.GetCTComment("A1")); Assert.AreSame(a2, sheetComments.GetCTComment("A2")); Assert.AreSame(a3, sheetComments.GetCTComment("A3")); Assert.AreEqual(3, sheetComments.GetNumberOfComments()); Assert.IsTrue(sheetComments.RemoveComment("A1")); Assert.AreEqual(2, sheetComments.GetNumberOfComments()); Assert.IsNull(sheetComments.GetCTComment("A1")); Assert.AreSame(a2, sheetComments.GetCTComment("A2")); Assert.AreSame(a3, sheetComments.GetCTComment("A3")); Assert.IsTrue(sheetComments.RemoveComment("A2")); Assert.AreEqual(1, sheetComments.GetNumberOfComments()); Assert.IsNull(sheetComments.GetCTComment("A1")); Assert.IsNull(sheetComments.GetCTComment("A2")); Assert.AreSame(a3, sheetComments.GetCTComment("A3")); Assert.IsTrue(sheetComments.RemoveComment("A3")); Assert.AreEqual(0, sheetComments.GetNumberOfComments()); Assert.IsNull(sheetComments.GetCTComment("A1")); Assert.IsNull(sheetComments.GetCTComment("A2")); Assert.IsNull(sheetComments.GetCTComment("A3")); }
public void RemoveComment() { CellAddress addrA1 = new CellAddress("A1"); CellAddress addrA2 = new CellAddress("A2"); CellAddress addrA3 = new CellAddress("A3"); CommentsTable sheetComments = new CommentsTable(); CT_Comment a1 = sheetComments.NewComment(addrA1); CT_Comment a2 = sheetComments.NewComment(addrA2); CT_Comment a3 = sheetComments.NewComment(addrA3); Assert.AreSame(a1, sheetComments.GetCTComment(addrA1)); Assert.AreSame(a2, sheetComments.GetCTComment(addrA2)); Assert.AreSame(a3, sheetComments.GetCTComment(addrA3)); Assert.AreEqual(3, sheetComments.GetNumberOfComments()); Assert.IsTrue(sheetComments.RemoveComment(addrA1)); Assert.AreEqual(2, sheetComments.GetNumberOfComments()); Assert.IsNull(sheetComments.GetCTComment(addrA1)); Assert.AreSame(a2, sheetComments.GetCTComment(addrA2)); Assert.AreSame(a3, sheetComments.GetCTComment(addrA3)); Assert.IsTrue(sheetComments.RemoveComment(addrA2)); Assert.AreEqual(1, sheetComments.GetNumberOfComments()); Assert.IsNull(sheetComments.GetCTComment(addrA1)); Assert.IsNull(sheetComments.GetCTComment(addrA2)); Assert.AreSame(a3, sheetComments.GetCTComment(addrA3)); Assert.IsTrue(sheetComments.RemoveComment(addrA3)); Assert.AreEqual(0, sheetComments.GetNumberOfComments()); Assert.IsNull(sheetComments.GetCTComment(addrA1)); Assert.IsNull(sheetComments.GetCTComment(addrA2)); Assert.IsNull(sheetComments.GetCTComment(addrA3)); }
public void GetCellComment() { CommentsTable sheetComments = new CommentsTable(); CT_Comments comments = sheetComments.GetCTComments(); CT_CommentList commentList = comments.commentList; // Create 2 comments for A1 and A" cells CT_Comment comment0 = commentList.InsertNewComment(0); comment0.@ref = "A1"; CT_Rst ctrst0 = new CT_Rst(); ctrst0.t = (TEST_A1_TEXT); comment0.text = (ctrst0); CT_Comment comment1 = commentList.InsertNewComment(0); comment1.@ref = ("A2"); CT_Rst ctrst1 = new CT_Rst(); ctrst1.t = (TEST_A2_TEXT); comment1.text = (ctrst1); // Test Finding the right comment for a cell Assert.AreSame(comment0, sheetComments.GetCTComment("A1")); Assert.AreSame(comment1, sheetComments.GetCTComment("A2")); Assert.IsNull(sheetComments.GetCTComment("A3")); }
public void SetString() { XSSFWorkbook wb = new XSSFWorkbook(); XSSFSheet sh = (XSSFSheet)wb.CreateSheet(); XSSFComment comment = (XSSFComment)sh.CreateDrawingPatriarch().CreateCellComment(new XSSFClientAnchor()); //passing HSSFRichTextString is incorrect try { comment.String = (new HSSFRichTextString(TEST_RICHTEXTSTRING)); Assert.Fail("expected exception"); } catch (ArgumentException e) { Assert.AreEqual("Only XSSFRichTextString argument is supported", e.Message); } //simple string argument comment.SetString(TEST_RICHTEXTSTRING); Assert.AreEqual(TEST_RICHTEXTSTRING, comment.String.String); //if the text is already Set, it should be overridden, not Added twice! comment.SetString(TEST_RICHTEXTSTRING); CT_Comment ctComment = comment.GetCTComment(); // Assert.Fail("TODO test case incomplete!?"); //XmlObject[] obj = ctComment.selectPath( // "declare namespace w='http://schemas.Openxmlformats.org/spreadsheetml/2006/main' .//w:text"); //Assert.AreEqual(1, obj.Length); Assert.AreEqual(TEST_RICHTEXTSTRING, comment.String.String); //sequential call of comment.String should return the same XSSFRichTextString object Assert.AreSame(comment.String, comment.String); XSSFRichTextString richText = new XSSFRichTextString(TEST_RICHTEXTSTRING); XSSFFont font1 = (XSSFFont)wb.CreateFont(); font1.FontName = ("Tahoma"); font1.FontHeight = 8.5; font1.IsItalic = true; font1.Color = IndexedColors.BlueGrey.Index; richText.ApplyFont(0, 5, font1); //check the low-level stuff comment.String = richText; //obj = ctComment.selectPath( // "declare namespace w='http://schemas.Openxmlformats.org/spreadsheetml/2006/main' .//w:text"); //Assert.AreEqual(1, obj.Length); Assert.AreSame(comment.String, richText); //check that the rich text is Set in the comment CT_RPrElt rPr = richText.GetCTRst().GetRArray(0).rPr; Assert.AreEqual(true, rPr.GetIArray(0).val); Assert.AreEqual(8.5, rPr.GetSzArray(0).val); Assert.AreEqual(IndexedColors.BlueGrey.Index, (short)rPr.GetColorArray(0).indexed); Assert.AreEqual("Tahoma", rPr.GetRFontArray(0).val); Assert.IsNotNull(XSSFTestDataSamples.WriteOutAndReadBack(wb)); }
/** * Remove the comment at cellRef location, if one exists * * @param cellRef the location of the comment to remove * @return returns true if a comment was removed */ public bool RemoveComment(CellAddress cellRef) { String stringRef = cellRef.FormatAsString(); CT_CommentList lst = comments.commentList; if (lst != null) { CT_Comment[] commentArray = lst.GetCommentArray(); for (int i = 0; i < commentArray.Length; i++) { CT_Comment comment = commentArray[i]; if (stringRef.Equals(comment.@ref)) { lst.RemoveComment(i); if (commentRefs != null) { commentRefs.Remove(cellRef); } return(true); } } } return(false); }
/** * Called after the reference is updated, so that * we can reflect that in our cache * @param oldReference the comment to remove from the commentRefs map * @param comment the comment to replace in the commentRefs map */ public void ReferenceUpdated(CellAddress oldReference, CT_Comment comment) { if (commentRefs != null) { commentRefs.Remove(oldReference); commentRefs[new CellAddress(comment.@ref)] = comment; } }
/** * Called after the reference is updated, so that * we can reflect that in our cache */ public void ReferenceUpdated(String oldReference, CT_Comment comment) { if (commentRefs != null) { commentRefs.Remove(oldReference); commentRefs[comment.@ref] = comment; } }
public void ReferenceUpdated(string oldReference, CT_Comment comment) { if (this.commentRefs == null) { return; } this.commentRefs.Remove(oldReference); this.commentRefs[comment.@ref] = comment; }
public XSSFComment FindCellComment(string cellRef) { CT_Comment ctComment = this.GetCTComment(cellRef); if (ctComment != null) { return(new XSSFComment(this, ctComment, (CT_Shape)null)); } return((XSSFComment)null); }
public XWPFComment(CT_Comment comment, XWPFDocument document) { this.text = new StringBuilder(); this.id = comment.id.ToString(); this.author = comment.author; foreach (CT_P prgrph in (IEnumerable <CT_P>)comment.GetPList()) { this.text.Append(new XWPFParagraph(prgrph, (IBody)document).GetText()); } }
public XWPFComment(CT_Comment comment, XWPFDocument document) { text = new StringBuilder(); id = comment.id.ToString(); author = comment.author; foreach(CT_P ctp in comment.GetPList()) { XWPFParagraph p = new XWPFParagraph(ctp, document); text.Append(p.Text); } }
public CT_Comment CreateComment() { CT_Comment ctComment = this.comments.commentList.AddNewComment(); ctComment.@ref = "A1"; ctComment.authorId = 0U; if (this.commentRefs != null) { this.commentRefs[ctComment.@ref] = ctComment; } return(ctComment); }
public XWPFComment(CT_Comment comment, XWPFDocument document) { text = new StringBuilder(); id = comment.id.ToString(); author = comment.author; foreach (CT_P ctp in comment.GetPList()) { XWPFParagraph p = new XWPFParagraph(ctp, document); text.Append(p.Text); } }
public CT_Comment CreateComment() { CT_Comment ct = comments.commentList.AddNewComment(); ct.@ref = "A1"; ct.authorId = 0; if (commentRefs != null) { commentRefs[ct.@ref] = ct; } return(ct); }
public CT_Comment NewComment(String ref1) { CT_Comment ct = comments.commentList.AddNewComment(); ct.@ref = (ref1); ct.authorId = (0); if (commentRefs != null) { commentRefs[ct.@ref] = ct; } return(ct); }
/** * Create a new comment located` at cell address * * @param ref the location to add the comment * @return a new CTComment located at ref with default author */ public CT_Comment NewComment(CellAddress ref1) { CT_Comment ct = comments.commentList.AddNewComment(); ct.@ref = ref1.FormatAsString(); ct.authorId = (uint)DEFAULT_AUTHOR_ID; if (commentRefs != null) { commentRefs.Add(ref1, ct); } return(ct); }
public void Author() { CommentsTable sheetComments = new CommentsTable(); CT_Comment ctComment = sheetComments.NewComment("A1"); Assert.AreEqual(1, sheetComments.GetNumberOfAuthors()); XSSFComment comment = new XSSFComment(sheetComments, ctComment, null); Assert.AreEqual("", comment.Author); comment.Author = ("Apache POI"); Assert.AreEqual("Apache POI", comment.Author); Assert.AreEqual(2, sheetComments.GetNumberOfAuthors()); comment.Author = ("Apache POI"); Assert.AreEqual(2, sheetComments.GetNumberOfAuthors()); comment.Author = (""); Assert.AreEqual("", comment.Author); Assert.AreEqual(2, sheetComments.GetNumberOfAuthors()); }
public void GetSetRow() { CommentsTable sheetComments = new CommentsTable(); XSSFVMLDrawing vml = new XSSFVMLDrawing(); CT_Comment ctComment = sheetComments.NewComment("A1"); CT_Shape vmlShape = vml.newCommentShape(); XSSFComment comment = new XSSFComment(sheetComments, ctComment, vmlShape); comment.Row = (1); Assert.AreEqual(1, comment.Row); Assert.AreEqual(1, new CellReference(ctComment.@ref).Row); Assert.AreEqual(1, vmlShape.GetClientDataArray(0).GetRowArray(0)); comment.Row = (5); Assert.AreEqual(5, comment.Row); Assert.AreEqual(5, new CellReference(ctComment.@ref).Row); Assert.AreEqual(5, vmlShape.GetClientDataArray(0).GetRowArray(0)); }
public void GetSetCol() { CommentsTable sheetComments = new CommentsTable(); XSSFVMLDrawing vml = new XSSFVMLDrawing(); CT_Comment ctComment = sheetComments.NewComment(CellAddress.A1); CT_Shape vmlShape = vml.newCommentShape(); XSSFComment comment = new XSSFComment(sheetComments, ctComment, vmlShape); comment.Column = (1); Assert.AreEqual(1, comment.Column); Assert.AreEqual(1, new CellReference(ctComment.@ref).Col); Assert.AreEqual(1, vmlShape.GetClientDataArray(0).GetColumnArray(0)); comment.Column = (5); Assert.AreEqual(5, comment.Column); Assert.AreEqual(5, new CellReference(ctComment.@ref).Col); Assert.AreEqual(5, vmlShape.GetClientDataArray(0).GetColumnArray(0)); }
public void Constructor() { CommentsTable sheetComments = new CommentsTable(); Assert.IsNotNull(sheetComments.GetCTComments().commentList); Assert.IsNotNull(sheetComments.GetCTComments().authors); Assert.AreEqual(1, sheetComments.GetCTComments().authors.SizeOfAuthorArray()); Assert.AreEqual(1, sheetComments.GetNumberOfAuthors()); CT_Comment ctComment = sheetComments.NewComment("A1"); CT_Shape vmlShape = new CT_Shape(); XSSFComment comment = new XSSFComment(sheetComments, ctComment, vmlShape); Assert.AreEqual(null, comment.String.String); Assert.AreEqual(0, comment.Row); Assert.AreEqual(0, comment.Column); Assert.AreEqual("", comment.Author); Assert.AreEqual(false, comment.Visible); }
public CT_Comment CreateComment() { CT_Comment ct = comments.commentList.AddNewComment(); ct.@ref = "A1"; ct.authorId = 0; if (commentRefs != null) { if (commentRefs.ContainsKey(ct.@ref)) { commentRefs[ct.@ref] = ct; } else { commentRefs.Add(ct.@ref, ct); } } return(ct); }
/** * Creates a new XSSFComment, associated with a given * low level comment object. */ public XSSFComment(CommentsTable comments, CT_Comment comment, CT_Shape vmlShape) { _comment = comment; _comments = comments; _vmlShape = vmlShape; // we potentially need to adjust the column/row information in the shape // the same way as we do in setRow()/setColumn() if (vmlShape != null && vmlShape.SizeOfClientDataArray() > 0) { CellReference ref1 = new CellReference(comment.@ref); CT_ClientData clientData = vmlShape.GetClientDataArray(0); clientData.SetRowArray(0, ref1.Row); clientData.SetColumnArray(0, ref1.Col); // There is a very odd xmlbeans bug when changing the row // arrays which can lead to corrupt pointer // This call seems to fix them again... See bug #50795 //vmlShape.GetClientDataList().ToString(); } }
public bool RemoveComment(string cellRef) { CT_CommentList commentList = this.comments.commentList; if (commentList != null) { for (int index = 0; index < commentList.SizeOfCommentArray(); ++index) { CT_Comment commentArray = commentList.GetCommentArray(index); if (cellRef.Equals(commentArray.@ref)) { commentList.RemoveComment(index); if (this.commentRefs != null) { this.commentRefs.Remove(cellRef); } return(true); } } } return(false); }
public bool RemoveComment(String cellRef) { CT_CommentList lst = comments.commentList; if (lst != null) { for (int i = 0; i < lst.SizeOfCommentArray(); i++) { CT_Comment comment = lst.GetCommentArray(i); if (cellRef.Equals(comment.@ref)) { lst.RemoveComment(i); if (commentRefs != null) { commentRefs.Remove(cellRef); } return(true); } } } return(false); }
public XSSFComment(CommentsTable comments, CT_Comment comment, CT_Shape vmlShape) { this._comment = comment; this._comments = comments; this._vmlShape = vmlShape; }
/** * Creates a new XSSFComment, associated with a given * low level comment object. */ public XSSFComment(CommentsTable comments, CT_Comment comment, CT_Shape vmlShape) { _comment = comment; _comments = comments; _vmlShape = vmlShape; }
public XSSFComment FindCellComment(String cellRef) { CT_Comment ct = GetCTComment(cellRef); return(ct == null ? null : new XSSFComment(this, ct, null)); }
public void ReferenceUpdated(String oldReference, CT_Comment comment) { ReferenceUpdated(new CellAddress(oldReference), comment); }
/** * Finds the cell comment at cellAddress, if one exists * * @param cellAddress the address of the cell to find a comment * @return cell comment if one exists, otherwise returns null */ public XSSFComment FindCellComment(CellAddress cellAddress) { CT_Comment ct = GetCTComment(cellAddress); return(ct == null ? null : new XSSFComment(this, ct, null)); }