mirror of https://github.com/apache/poi.git
Javadoc fixes and cleanup.
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@353600 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e222dc1047
commit
de1c655726
|
@ -28,188 +28,229 @@ import org.apache.poi.hssf.record.HeaderRecord;
|
||||||
* that return the characters used to represent these. One can also change the
|
* that return the characters used to represent these. One can also change the
|
||||||
* fonts by using similar methods.
|
* fonts by using similar methods.
|
||||||
* <P>
|
* <P>
|
||||||
|
*
|
||||||
* @author Shawn Laubach (slaubach at apache dot org)
|
* @author Shawn Laubach (slaubach at apache dot org)
|
||||||
*/
|
*/
|
||||||
public class HSSFHeader extends Object {
|
public class HSSFHeader
|
||||||
|
{
|
||||||
|
|
||||||
HeaderRecord headerRecord;
|
HeaderRecord headerRecord;
|
||||||
String left;
|
String left;
|
||||||
String center;
|
String center;
|
||||||
String right;
|
String right;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor. Creates a new header interface from a header record
|
* Constructor. Creates a new header interface from a header record
|
||||||
* @param headerRecord Header record to create the header with
|
*
|
||||||
*/
|
* @param headerRecord Header record to create the header with
|
||||||
protected HSSFHeader(HeaderRecord headerRecord) {
|
*/
|
||||||
this.headerRecord = headerRecord;
|
protected HSSFHeader( HeaderRecord headerRecord )
|
||||||
String head = headerRecord.getHeader();
|
{
|
||||||
while (head != null && head.length() > 1) {
|
this.headerRecord = headerRecord;
|
||||||
int pos = head.length();
|
String head = headerRecord.getHeader();
|
||||||
switch (head.substring(1, 2).charAt(0)) {
|
while ( head != null && head.length() > 1 )
|
||||||
case 'L' :
|
{
|
||||||
if (head.indexOf("&C") >= 0) {
|
int pos = head.length();
|
||||||
pos = Math.min(pos, head.indexOf("&C"));
|
switch ( head.substring( 1, 2 ).charAt( 0 ) )
|
||||||
}
|
{
|
||||||
if (head.indexOf("&R") >= 0) {
|
case 'L':
|
||||||
pos = Math.min(pos, head.indexOf("&R"));
|
if ( head.indexOf( "&C" ) >= 0 )
|
||||||
}
|
{
|
||||||
left = head.substring(2, pos);
|
pos = Math.min( pos, head.indexOf( "&C" ) );
|
||||||
head = head.substring(pos);
|
}
|
||||||
break;
|
if ( head.indexOf( "&R" ) >= 0 )
|
||||||
case 'C' :
|
{
|
||||||
if (head.indexOf("&L") >= 0) {
|
pos = Math.min( pos, head.indexOf( "&R" ) );
|
||||||
pos = Math.min(pos, head.indexOf("&L"));
|
}
|
||||||
}
|
left = head.substring( 2, pos );
|
||||||
if (head.indexOf("&R") >= 0) {
|
head = head.substring( pos );
|
||||||
pos = Math.min(pos, head.indexOf("&R"));
|
break;
|
||||||
}
|
case 'C':
|
||||||
center = head.substring(2, pos);
|
if ( head.indexOf( "&L" ) >= 0 )
|
||||||
head = head.substring(pos);
|
{
|
||||||
break;
|
pos = Math.min( pos, head.indexOf( "&L" ) );
|
||||||
case 'R' :
|
}
|
||||||
if (head.indexOf("&C") >= 0) {
|
if ( head.indexOf( "&R" ) >= 0 )
|
||||||
pos = Math.min(pos, head.indexOf("&C"));
|
{
|
||||||
}
|
pos = Math.min( pos, head.indexOf( "&R" ) );
|
||||||
if (head.indexOf("&L") >= 0) {
|
}
|
||||||
pos = Math.min(pos, head.indexOf("&L"));
|
center = head.substring( 2, pos );
|
||||||
}
|
head = head.substring( pos );
|
||||||
right = head.substring(2, pos);
|
break;
|
||||||
head = head.substring(pos);
|
case 'R':
|
||||||
break;
|
if ( head.indexOf( "&C" ) >= 0 )
|
||||||
default : head = null;
|
{
|
||||||
}
|
pos = Math.min( pos, head.indexOf( "&C" ) );
|
||||||
|
}
|
||||||
|
if ( head.indexOf( "&L" ) >= 0 )
|
||||||
|
{
|
||||||
|
pos = Math.min( pos, head.indexOf( "&L" ) );
|
||||||
|
}
|
||||||
|
right = head.substring( 2, pos );
|
||||||
|
head = head.substring( pos );
|
||||||
|
break;
|
||||||
|
default :
|
||||||
|
head = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the left side of the header.
|
* Get the left side of the header.
|
||||||
* @return The string representing the left side.
|
*
|
||||||
*/
|
* @return The string representing the left side.
|
||||||
public String getLeft() {
|
*/
|
||||||
return left;
|
public String getLeft()
|
||||||
}
|
{
|
||||||
|
return left;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the left string.
|
* Sets the left string.
|
||||||
* @newLeft The string to set as the left side.
|
*
|
||||||
*/
|
* @param newLeft The string to set as the left side.
|
||||||
public void setLeft(String newLeft) {
|
*/
|
||||||
left = newLeft;
|
public void setLeft( String newLeft )
|
||||||
createHeaderString();
|
{
|
||||||
}
|
left = newLeft;
|
||||||
|
createHeaderString();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the center of the header.
|
* Get the center of the header.
|
||||||
* @return The string representing the center.
|
*
|
||||||
*/
|
* @return The string representing the center.
|
||||||
public String getCenter() {
|
*/
|
||||||
return center;
|
public String getCenter()
|
||||||
}
|
{
|
||||||
|
return center;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the center string.
|
* Sets the center string.
|
||||||
* @newLeft The string to set as the center.
|
*
|
||||||
*/
|
* @param newCenter The string to set as the center.
|
||||||
public void setCenter(String newCenter) {
|
*/
|
||||||
center = newCenter;
|
public void setCenter( String newCenter )
|
||||||
createHeaderString();
|
{
|
||||||
}
|
center = newCenter;
|
||||||
|
createHeaderString();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the right side of the header.
|
* Get the right side of the header.
|
||||||
* @return The string representing the right side.
|
*
|
||||||
*/
|
* @return The string representing the right side.
|
||||||
public String getRight() {
|
*/
|
||||||
return right;
|
public String getRight()
|
||||||
}
|
{
|
||||||
|
return right;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the right string.
|
* Sets the right string.
|
||||||
* @newLeft The string to set as the right side.
|
*
|
||||||
*/
|
* @param newRight The string to set as the right side.
|
||||||
public void setRight(String newRight) {
|
*/
|
||||||
right = newRight;
|
public void setRight( String newRight )
|
||||||
createHeaderString();
|
{
|
||||||
}
|
right = newRight;
|
||||||
|
createHeaderString();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the complete header string based on the left, center, and middle
|
* Creates the complete header string based on the left, center, and middle
|
||||||
* strings.
|
* strings.
|
||||||
*/
|
*/
|
||||||
private void createHeaderString() {
|
private void createHeaderString()
|
||||||
headerRecord.setHeader(
|
{
|
||||||
"&C" + (center == null ? "" : center) +
|
headerRecord.setHeader( "&C" + ( center == null ? "" : center ) +
|
||||||
"&L" + (left == null ? "" : left) +
|
"&L" + ( left == null ? "" : left ) +
|
||||||
"&R" + (right == null ? "" : right));
|
"&R" + ( right == null ? "" : right ) );
|
||||||
headerRecord.setHeaderLength((byte)headerRecord.getHeader().length());
|
headerRecord.setHeaderLength( (byte) headerRecord.getHeader().length() );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the string that represents the change in font size.
|
* Returns the string that represents the change in font size.
|
||||||
* @param size the new font size
|
*
|
||||||
* @return The special string to represent a new font size
|
* @param size the new font size
|
||||||
*/
|
* @return The special string to represent a new font size
|
||||||
public static String fontSize(short size) {
|
*/
|
||||||
return "&" + size;
|
public static String fontSize( short size )
|
||||||
}
|
{
|
||||||
|
return "&" + size;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the string that represents the change in font.
|
* Returns the string that represents the change in font.
|
||||||
* @param font the new font
|
*
|
||||||
* @param style the fonts style
|
* @param font the new font
|
||||||
* @return The special string to represent a new font size
|
* @param style the fonts style
|
||||||
*/
|
* @return The special string to represent a new font size
|
||||||
public static String font(String font, String style) {
|
*/
|
||||||
return "&\"" + font + "," + style + "\"";
|
public static String font( String font, String style )
|
||||||
}
|
{
|
||||||
|
return "&\"" + font + "," + style + "\"";
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the string representing the current page number
|
* Returns the string representing the current page number
|
||||||
* @return The special string for page number
|
*
|
||||||
*/
|
* @return The special string for page number
|
||||||
public static String page() {
|
*/
|
||||||
return "&P";
|
public static String page()
|
||||||
}
|
{
|
||||||
|
return "&P";
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the string representing the number of pages.
|
* Returns the string representing the number of pages.
|
||||||
* @return The special string for the number of pages
|
*
|
||||||
*/
|
* @return The special string for the number of pages
|
||||||
public static String numPages() {
|
*/
|
||||||
return "&N";
|
public static String numPages()
|
||||||
}
|
{
|
||||||
|
return "&N";
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the string representing the current date
|
* Returns the string representing the current date
|
||||||
* @return The special string for the date
|
*
|
||||||
*/
|
* @return The special string for the date
|
||||||
public static String date() {
|
*/
|
||||||
return "&D";
|
public static String date()
|
||||||
}
|
{
|
||||||
|
return "&D";
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the string representing the current time
|
* Returns the string representing the current time
|
||||||
* @return The special string for the time
|
*
|
||||||
*/
|
* @return The special string for the time
|
||||||
public static String time() {
|
*/
|
||||||
return "&T";
|
public static String time()
|
||||||
}
|
{
|
||||||
|
return "&T";
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the string representing the current file name
|
* Returns the string representing the current file name
|
||||||
* @return The special string for the file name
|
*
|
||||||
*/
|
* @return The special string for the file name
|
||||||
public static String file() {
|
*/
|
||||||
return "&F";
|
public static String file()
|
||||||
}
|
{
|
||||||
|
return "&F";
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the string representing the current tab (sheet) name
|
* Returns the string representing the current tab (sheet) name
|
||||||
* @return The special string for tab name
|
*
|
||||||
*/
|
* @return The special string for tab name
|
||||||
public static String tab() {
|
*/
|
||||||
return "&A";
|
public static String tab()
|
||||||
}
|
{
|
||||||
|
return "&A";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue