mirror of
https://github.com/apache/poi.git
synced 2026-02-27 20:40:08 +08:00
https://svn.apache.org/repos/asf/poi/trunk ........ r703100 | josh | 2008-10-09 01:33:54 -0700 (Thu, 09 Oct 2008) | 1 line Removed last occurrences of storing Ptg arrays in Stacks. Some related clean-up. ........ r703197 | josh | 2008-10-09 09:10:39 -0700 (Thu, 09 Oct 2008) | 1 line Should have been submitted with r703100 (changes to Ptg) ........ r703302 | josh | 2008-10-09 17:40:58 -0700 (Thu, 09 Oct 2008) | 1 line Fix for bug 45964 - support for link formulas in Text Objects ........ r703596 | josh | 2008-10-10 15:59:14 -0700 (Fri, 10 Oct 2008) | 1 line Made RecordInputStream final (major clean-up in test cases and BiffViewer) ........ r703620 | josh | 2008-10-10 18:11:05 -0700 (Fri, 10 Oct 2008) | 2 lines fix for bug 45866 - allowed for change of unicode compression across Continue records ........ r703645 | yegor | 2008-10-11 03:31:24 -0700 (Sat, 11 Oct 2008) | 1 line fixed error in eval.xml: use < instead of '<' ........ r703651 | yegor | 2008-10-11 05:01:42 -0700 (Sat, 11 Oct 2008) | 1 line set trunk version.id=3.3-alpha1 ........ r706540 | yegor | 2008-10-20 23:47:35 -0700 (Mon, 20 Oct 2008) | 1 line updated release version on the index page, started a new section in the change log ........ git-svn-id: https://svn.apache.org/repos/asf/poi/branches/ooxml@707807 13f79535-47bb-0310-9956-ffa450edef68
166 lines
4.8 KiB
Java
166 lines
4.8 KiB
Java
/* ====================================================================
|
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
|
contributor license agreements. See the NOTICE file distributed with
|
|
this work for additional information regarding copyright ownership.
|
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
|
(the "License"); you may not use this file except in compliance with
|
|
the License. You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
==================================================================== */
|
|
package org.apache.poi.hssf.usermodel;
|
|
|
|
import org.apache.poi.hssf.record.NoteRecord;
|
|
import org.apache.poi.hssf.record.TextObjectRecord;
|
|
import org.apache.poi.ss.usermodel.Comment;
|
|
import org.apache.poi.ss.usermodel.RichTextString;
|
|
|
|
/**
|
|
* Represents a cell comment - a sticky note associated with a cell.
|
|
*
|
|
* @author Yegor Kozlov
|
|
*/
|
|
public class HSSFComment extends HSSFTextbox implements Comment {
|
|
|
|
private boolean visible;
|
|
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.
|
|
*
|
|
* @param parent
|
|
* @param anchor defines position of this anchor in the sheet
|
|
*/
|
|
public HSSFComment( HSSFShape parent, HSSFAnchor anchor )
|
|
{
|
|
super( parent, anchor );
|
|
setShapeType(OBJECT_TYPE_COMMENT);
|
|
|
|
//default color for comments
|
|
fillColor = 0x08000050;
|
|
|
|
//by default comments are hidden
|
|
visible = false;
|
|
|
|
author = "";
|
|
}
|
|
|
|
protected HSSFComment( NoteRecord note, TextObjectRecord txo )
|
|
{
|
|
this( (HSSFShape)null, (HSSFAnchor)null );
|
|
this.txo = txo;
|
|
this.note = note;
|
|
}
|
|
|
|
/**
|
|
* Returns whether this comment is visible.
|
|
*
|
|
* @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;
|
|
}
|
|
|
|
/**
|
|
* Sets whether this comment is visible.
|
|
*
|
|
* @return <code>true</code> if the comment is visible, <code>false</code> otherwise
|
|
*/
|
|
public boolean isVisible(){
|
|
return this.visible;
|
|
}
|
|
|
|
/**
|
|
* Return the row of the cell that contains the comment
|
|
*
|
|
* @return the 0-based row of the cell that contains the comment
|
|
*/
|
|
public int getRow(){
|
|
return row;
|
|
}
|
|
|
|
/**
|
|
* Set the row of the cell that contains the comment
|
|
*
|
|
* @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;
|
|
}
|
|
|
|
/**
|
|
* Return the column of the cell that contains the comment
|
|
*
|
|
* @return the 0-based column of the cell that contains the comment
|
|
*/
|
|
public int getColumn(){
|
|
return col;
|
|
}
|
|
|
|
/**
|
|
* Set the column of the cell that contains the comment
|
|
*
|
|
* @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;
|
|
}
|
|
|
|
/**
|
|
* Name of the original comment author
|
|
*
|
|
* @return the name of the original author of the comment
|
|
*/
|
|
public String getAuthor(){
|
|
return author;
|
|
}
|
|
|
|
/**
|
|
* Name of the original comment author
|
|
*
|
|
* @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;
|
|
}
|
|
|
|
/**
|
|
* Sets the rich text string used by this comment.
|
|
*
|
|
* @param string Sets the rich text string used by this object.
|
|
*/
|
|
public void setString( RichTextString string ) {
|
|
HSSFRichTextString hstring = (HSSFRichTextString) string;
|
|
//if font is not set we must set the default one
|
|
if (hstring.numFormattingRuns() == 0) hstring.applyFont((short)0);
|
|
|
|
if (txo != null) {
|
|
txo.setStr(hstring);
|
|
}
|
|
super.setString(string);
|
|
}
|
|
|
|
/**
|
|
* Returns the underlying Note record
|
|
*/
|
|
protected NoteRecord getNoteRecord() { return note; }
|
|
/**
|
|
* Returns the underlying Text record
|
|
*/
|
|
protected TextObjectRecord getTextObjectRecord() { return txo; }
|
|
}
|