summaryrefslogtreecommitdiffstats
path: root/src/java
diff options
context:
space:
mode:
authorYegor Kozlov <yegor@apache.org>2007-01-31 16:14:23 +0000
committerYegor Kozlov <yegor@apache.org>2007-01-31 16:14:23 +0000
commit579c07e3bfa4e8ca7b37fae1831c21ab96a6f4f8 (patch)
tree2e313acde9c590cf571f25bd357753721abb9e0f /src/java
parent5fdbf9130111de0eee6da78f6cb340b42b645e26 (diff)
downloadpoi-579c07e3bfa4e8ca7b37fae1831c21ab96a6f4f8.tar.gz
poi-579c07e3bfa4e8ca7b37fae1831c21ab96a6f4f8.zip
changing attributes of existing cell comments is reflected after save
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@501875 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java')
-rw-r--r--src/java/org/apache/poi/hssf/usermodel/HSSFCell.java2
-rw-r--r--src/java/org/apache/poi/hssf/usermodel/HSSFComment.java27
2 files changed, 24 insertions, 5 deletions
diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java b/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java
index ec81c0d614..7d41f6d135 100644
--- a/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java
+++ b/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java
@@ -986,7 +986,7 @@ public class HSSFCell
NoteRecord note = (NoteRecord)rec;
if (note.getRow() == record.getRow() && note.getColumn() == record.getColumn()){
TextObjectRecord txo = (TextObjectRecord)txshapes.get(new Integer(note.getShapeId()));
- comment = new HSSFComment(null, null);
+ comment = new HSSFComment(note, txo);
comment.setRow(note.getRow());
comment.setColumn(note.getColumn());
comment.setAuthor(note.getAuthor());
diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFComment.java b/src/java/org/apache/poi/hssf/usermodel/HSSFComment.java
index d56db733a3..258f26e228 100644
--- a/src/java/org/apache/poi/hssf/usermodel/HSSFComment.java
+++ b/src/java/org/apache/poi/hssf/usermodel/HSSFComment.java
@@ -28,7 +28,7 @@ import java.util.Iterator;
/**
* Represents a cell comment - a sticky note associated with a cell.
*
- * @author Yegor Kolzlov
+ * @author Yegor Kozlov
*/
public class HSSFComment extends HSSFTextbox {
@@ -36,6 +36,9 @@ public class HSSFComment extends HSSFTextbox {
private short col, row;
private String author;
+ private NoteRecord note = null;
+ private TextObjectRecord txo = null;
+
/**
* Construct a new comment with the given parent and anchor.
*
@@ -56,6 +59,12 @@ public class HSSFComment extends HSSFTextbox {
author = "";
}
+ protected HSSFComment( NoteRecord note, TextObjectRecord txo )
+ {
+ this( (HSSFShape)null, (HSSFAnchor)null );
+ this.txo = txo;
+ this.note = note;
+ }
/**
* Returns whether this comment is visible.
@@ -63,6 +72,7 @@ public class HSSFComment extends HSSFTextbox {
* @param visible <code>true</code> if the comment is visible, <code>false</code> otherwise
*/
public void setVisible(boolean visible){
+ if(note != null) note.setFlags(visible ? NoteRecord.NOTE_VISIBLE : NoteRecord.NOTE_HIDDEN);
this.visible = visible;
}
@@ -90,6 +100,7 @@ public class HSSFComment extends HSSFTextbox {
* @param row the 0-based row of the cell that contains the comment
*/
public void setRow(int row){
+ if(note != null) note.setRow((short)row);
this.row = (short)row;
}
@@ -108,6 +119,7 @@ public class HSSFComment extends HSSFTextbox {
* @param col the 0-based column of the cell that contains the comment
*/
public void setColumn(short col){
+ if(note != null) note.setColumn(col);
this.col = col;
}
@@ -126,6 +138,7 @@ public class HSSFComment extends HSSFTextbox {
* @param author the name of the original author of the comment
*/
public void setAuthor(String author){
+ if(note != null) note.setAuthor(author);
this.author = author;
}
@@ -134,10 +147,16 @@ public class HSSFComment extends HSSFTextbox {
*
* @param string Sets the rich text string used by this object.
*/
- public void setString( HSSFRichTextString string )
- {
- //if font is not set we must set the default one implicitly
+ public void setString( HSSFRichTextString string ) {
+ //if font is not set we must set the default one
if (string.numFormattingRuns() == 0) string.applyFont((short)0);
+
+ if (txo != null) {
+ int frLength = ( string.numFormattingRuns() + 1 ) * 8;
+ txo.setFormattingRunLength( (short) frLength );
+ txo.setTextLength( (short) string.length() );
+ txo.setStr( string );
+ }
super.setString(string);
}
}