Fix inconsistent whitespace/formatting
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1691046 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
777806d350
commit
e349269fcf
@ -25,11 +25,8 @@ import org.apache.poi.util.LittleEndianOutput;
|
||||
|
||||
/**
|
||||
* Border Formatting Block of the Conditional Formatting Rule Record.
|
||||
*
|
||||
* @author Dmitriy Kumshayev
|
||||
*/
|
||||
public final class BorderFormatting {
|
||||
|
||||
/** No border */
|
||||
public final static short BORDER_NONE = 0x0;
|
||||
/** Thin border */
|
||||
|
@ -23,97 +23,93 @@ import java.util.List;
|
||||
import org.apache.poi.ss.util.CellRangeAddress;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Dmitriy Kumshayev
|
||||
* TODO Should this move to org.apache.poi.ss.util ?
|
||||
*/
|
||||
public final class CellRangeUtil
|
||||
{
|
||||
|
||||
private CellRangeUtil() {
|
||||
// no instance of this class
|
||||
}
|
||||
|
||||
public static final int NO_INTERSECTION = 1;
|
||||
public static final int OVERLAP = 2;
|
||||
/** first range is within the second range */
|
||||
public static final int INSIDE = 3;
|
||||
/** first range encloses or is equal to the second */
|
||||
public static final int ENCLOSES = 4;
|
||||
|
||||
/**
|
||||
* Intersect this range with the specified range.
|
||||
*
|
||||
* @param crB - the specified range
|
||||
* @return code which reflects how the specified range is related to this range.<br/>
|
||||
* Possible return codes are:
|
||||
* NO_INTERSECTION - the specified range is outside of this range;<br/>
|
||||
* OVERLAP - both ranges partially overlap;<br/>
|
||||
* INSIDE - the specified range is inside of this one<br/>
|
||||
* ENCLOSES - the specified range encloses (possibly exactly the same as) this range<br/>
|
||||
*/
|
||||
public static int intersect(CellRangeAddress crA, CellRangeAddress crB )
|
||||
{
|
||||
|
||||
int firstRow = crB.getFirstRow();
|
||||
int lastRow = crB.getLastRow();
|
||||
int firstCol = crB.getFirstColumn();
|
||||
int lastCol = crB.getLastColumn();
|
||||
|
||||
if
|
||||
(
|
||||
public final class CellRangeUtil {
|
||||
private CellRangeUtil() {
|
||||
// no instance of this class
|
||||
}
|
||||
|
||||
public static final int NO_INTERSECTION = 1;
|
||||
public static final int OVERLAP = 2;
|
||||
/** first range is within the second range */
|
||||
public static final int INSIDE = 3;
|
||||
/** first range encloses or is equal to the second */
|
||||
public static final int ENCLOSES = 4;
|
||||
|
||||
/**
|
||||
* Intersect this range with the specified range.
|
||||
*
|
||||
* @param crB - the specified range
|
||||
* @return code which reflects how the specified range is related to this range.<br/>
|
||||
* Possible return codes are:
|
||||
* NO_INTERSECTION - the specified range is outside of this range;<br/>
|
||||
* OVERLAP - both ranges partially overlap;<br/>
|
||||
* INSIDE - the specified range is inside of this one<br/>
|
||||
* ENCLOSES - the specified range encloses (possibly exactly the same as) this range<br/>
|
||||
*/
|
||||
public static int intersect(CellRangeAddress crA, CellRangeAddress crB )
|
||||
{
|
||||
|
||||
int firstRow = crB.getFirstRow();
|
||||
int lastRow = crB.getLastRow();
|
||||
int firstCol = crB.getFirstColumn();
|
||||
int lastCol = crB.getLastColumn();
|
||||
|
||||
if
|
||||
(
|
||||
gt(crA.getFirstRow(),lastRow) ||
|
||||
lt(crA.getLastRow(),firstRow) ||
|
||||
gt(crA.getFirstColumn(),lastCol) ||
|
||||
lt(crA.getLastColumn(),firstCol)
|
||||
)
|
||||
{
|
||||
return NO_INTERSECTION;
|
||||
}
|
||||
else if( contains(crA, crB) )
|
||||
{
|
||||
return INSIDE;
|
||||
}
|
||||
else if( contains(crB, crA))
|
||||
{
|
||||
return ENCLOSES;
|
||||
}
|
||||
else
|
||||
{
|
||||
return OVERLAP;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Do all possible cell merges between cells of the list so that:<br>
|
||||
* <li>if a cell range is completely inside of another cell range, it gets removed from the list
|
||||
* <li>if two cells have a shared border, merge them into one bigger cell range
|
||||
* @param cellRanges
|
||||
* @return updated List of cell ranges
|
||||
*/
|
||||
public static CellRangeAddress[] mergeCellRanges(CellRangeAddress[] cellRanges) {
|
||||
if(cellRanges.length < 1) {
|
||||
return cellRanges;
|
||||
}
|
||||
)
|
||||
{
|
||||
return NO_INTERSECTION;
|
||||
}
|
||||
else if( contains(crA, crB) )
|
||||
{
|
||||
return INSIDE;
|
||||
}
|
||||
else if( contains(crB, crA))
|
||||
{
|
||||
return ENCLOSES;
|
||||
}
|
||||
else
|
||||
{
|
||||
return OVERLAP;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Do all possible cell merges between cells of the list so that:<br>
|
||||
* <li>if a cell range is completely inside of another cell range, it gets removed from the list
|
||||
* <li>if two cells have a shared border, merge them into one bigger cell range
|
||||
* @param cellRanges
|
||||
* @return updated List of cell ranges
|
||||
*/
|
||||
public static CellRangeAddress[] mergeCellRanges(CellRangeAddress[] cellRanges) {
|
||||
if(cellRanges.length < 1) {
|
||||
return cellRanges;
|
||||
}
|
||||
|
||||
List<CellRangeAddress> lst = new ArrayList<CellRangeAddress>();
|
||||
for(CellRangeAddress cr : cellRanges) {
|
||||
lst.add(cr);
|
||||
}
|
||||
List<CellRangeAddress> temp = mergeCellRanges(lst);
|
||||
return toArray(temp);
|
||||
}
|
||||
return toArray(temp);
|
||||
}
|
||||
|
||||
private static List<CellRangeAddress> mergeCellRanges(List<CellRangeAddress> cellRangeList)
|
||||
{
|
||||
// loop until either only one item is left or we did not merge anything any more
|
||||
private static List<CellRangeAddress> mergeCellRanges(List<CellRangeAddress> cellRangeList)
|
||||
{
|
||||
// loop until either only one item is left or we did not merge anything any more
|
||||
while (cellRangeList.size() > 1) {
|
||||
boolean somethingGotMerged = false;
|
||||
|
||||
// look at all cell-ranges
|
||||
for (int i = 0; i < cellRangeList.size(); i++) {
|
||||
CellRangeAddress range1 = cellRangeList.get(i);
|
||||
|
||||
|
||||
// compare each cell range to all other cell-ranges
|
||||
for (int j = i + 1; j < cellRangeList.size(); j++) {
|
||||
CellRangeAddress range2 = cellRangeList.get(j);
|
||||
@ -139,16 +135,16 @@ public final class CellRangeUtil
|
||||
}
|
||||
}
|
||||
|
||||
return cellRangeList;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the new range(s) to replace the supplied ones. <code>null</code> if no merge is possible
|
||||
*/
|
||||
private static CellRangeAddress[] mergeRanges(CellRangeAddress range1, CellRangeAddress range2) {
|
||||
int x = intersect(range1, range2);
|
||||
switch(x)
|
||||
{
|
||||
return cellRangeList;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the new range(s) to replace the supplied ones. <code>null</code> if no merge is possible
|
||||
*/
|
||||
private static CellRangeAddress[] mergeRanges(CellRangeAddress range1, CellRangeAddress range2) {
|
||||
int x = intersect(range1, range2);
|
||||
switch(x)
|
||||
{
|
||||
case CellRangeUtil.NO_INTERSECTION:
|
||||
// nothing in common: at most they could be adjacent to each other and thus form a single bigger area
|
||||
if(hasExactSharedBorder(range1, range2)) {
|
||||
@ -171,108 +167,103 @@ public final class CellRangeUtil
|
||||
throw new RuntimeException("unexpected intersection result (" + x + ")");
|
||||
}
|
||||
|
||||
|
||||
private static CellRangeAddress[] toArray(List<CellRangeAddress> temp) {
|
||||
CellRangeAddress[] result = new CellRangeAddress[temp.size()];
|
||||
temp.toArray(result);
|
||||
return result;
|
||||
}
|
||||
private static CellRangeAddress[] toArray(List<CellRangeAddress> temp) {
|
||||
CellRangeAddress[] result = new CellRangeAddress[temp.size()];
|
||||
temp.toArray(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the specified range is located inside of this cell range.
|
||||
*
|
||||
* @param crB
|
||||
* @return true if this cell range contains the argument range inside if it's area
|
||||
*/
|
||||
public static boolean contains(CellRangeAddress crA, CellRangeAddress crB)
|
||||
{
|
||||
int firstRow = crB.getFirstRow();
|
||||
int lastRow = crB.getLastRow();
|
||||
int firstCol = crB.getFirstColumn();
|
||||
int lastCol = crB.getLastColumn();
|
||||
return le(crA.getFirstRow(), firstRow) && ge(crA.getLastRow(), lastRow)
|
||||
&& le(crA.getFirstColumn(), firstCol) && ge(crA.getLastColumn(), lastCol);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the two cell ranges have a shared border.
|
||||
*
|
||||
* @return <code>true</code> if the ranges have a complete shared border (i.e.
|
||||
* the two ranges together make a simple rectangular region.
|
||||
*/
|
||||
public static boolean hasExactSharedBorder(CellRangeAddress crA, CellRangeAddress crB) {
|
||||
int oFirstRow = crB.getFirstRow();
|
||||
int oLastRow = crB.getLastRow();
|
||||
int oFirstCol = crB.getFirstColumn();
|
||||
int oLastCol = crB.getLastColumn();
|
||||
|
||||
/**
|
||||
* Check if the specified range is located inside of this cell range.
|
||||
*
|
||||
* @param crB
|
||||
* @return true if this cell range contains the argument range inside if it's area
|
||||
*/
|
||||
public static boolean contains(CellRangeAddress crA, CellRangeAddress crB)
|
||||
{
|
||||
int firstRow = crB.getFirstRow();
|
||||
int lastRow = crB.getLastRow();
|
||||
int firstCol = crB.getFirstColumn();
|
||||
int lastCol = crB.getLastColumn();
|
||||
return le(crA.getFirstRow(), firstRow) && ge(crA.getLastRow(), lastRow)
|
||||
&& le(crA.getFirstColumn(), firstCol) && ge(crA.getLastColumn(), lastCol);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the two cell ranges have a shared border.
|
||||
*
|
||||
* @return <code>true</code> if the ranges have a complete shared border (i.e.
|
||||
* the two ranges together make a simple rectangular region.
|
||||
*/
|
||||
public static boolean hasExactSharedBorder(CellRangeAddress crA, CellRangeAddress crB) {
|
||||
int oFirstRow = crB.getFirstRow();
|
||||
int oLastRow = crB.getLastRow();
|
||||
int oFirstCol = crB.getFirstColumn();
|
||||
int oLastCol = crB.getLastColumn();
|
||||
|
||||
if (crA.getFirstRow() > 0 && crA.getFirstRow()-1 == oLastRow ||
|
||||
oFirstRow > 0 && oFirstRow-1 == crA.getLastRow()) {
|
||||
// ranges have a horizontal border in common
|
||||
// make sure columns are identical:
|
||||
return crA.getFirstColumn() == oFirstCol && crA.getLastColumn() == oLastCol;
|
||||
}
|
||||
if (crA.getFirstRow() > 0 && crA.getFirstRow()-1 == oLastRow ||
|
||||
oFirstRow > 0 && oFirstRow-1 == crA.getLastRow()) {
|
||||
// ranges have a horizontal border in common
|
||||
// make sure columns are identical:
|
||||
return crA.getFirstColumn() == oFirstCol && crA.getLastColumn() == oLastCol;
|
||||
}
|
||||
|
||||
if (crA.getFirstColumn()>0 && crA.getFirstColumn() - 1 == oLastCol ||
|
||||
oFirstCol>0 && crA.getLastColumn() == oFirstCol -1) {
|
||||
// ranges have a vertical border in common
|
||||
// make sure rows are identical:
|
||||
return crA.getFirstRow() == oFirstRow && crA.getLastRow() == oLastRow;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an enclosing CellRange for the two cell ranges.
|
||||
*
|
||||
* @return enclosing CellRange
|
||||
*/
|
||||
public static CellRangeAddress createEnclosingCellRange(CellRangeAddress crA, CellRangeAddress crB) {
|
||||
if( crB == null) {
|
||||
return crA.copy();
|
||||
}
|
||||
|
||||
return
|
||||
new CellRangeAddress(
|
||||
lt(crB.getFirstRow(), crA.getFirstRow()) ?crB.getFirstRow() :crA.getFirstRow(),
|
||||
gt(crB.getLastRow(), crA.getLastRow()) ?crB.getLastRow() :crA.getLastRow(),
|
||||
lt(crB.getFirstColumn(),crA.getFirstColumn())?crB.getFirstColumn():crA.getFirstColumn(),
|
||||
gt(crB.getLastColumn(), crA.getLastColumn()) ?crB.getLastColumn() :crA.getLastColumn()
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if a < b
|
||||
*/
|
||||
private static boolean lt(int a, int b)
|
||||
{
|
||||
return a == -1 ? false : (b == -1 ? true : a < b);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if a <= b
|
||||
*/
|
||||
private static boolean le(int a, int b)
|
||||
{
|
||||
return a == b || lt(a,b);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if a > b
|
||||
*/
|
||||
private static boolean gt(int a, int b)
|
||||
{
|
||||
return lt(b,a);
|
||||
}
|
||||
if (crA.getFirstColumn()>0 && crA.getFirstColumn() - 1 == oLastCol ||
|
||||
oFirstCol>0 && crA.getLastColumn() == oFirstCol -1) {
|
||||
// ranges have a vertical border in common
|
||||
// make sure rows are identical:
|
||||
return crA.getFirstRow() == oFirstRow && crA.getLastRow() == oLastRow;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if a >= b
|
||||
*/
|
||||
private static boolean ge(int a, int b)
|
||||
{
|
||||
return !lt(a,b);
|
||||
}
|
||||
/**
|
||||
* Create an enclosing CellRange for the two cell ranges.
|
||||
*
|
||||
* @return enclosing CellRange
|
||||
*/
|
||||
public static CellRangeAddress createEnclosingCellRange(CellRangeAddress crA, CellRangeAddress crB) {
|
||||
if( crB == null) {
|
||||
return crA.copy();
|
||||
}
|
||||
|
||||
return new CellRangeAddress(
|
||||
lt(crB.getFirstRow(), crA.getFirstRow()) ?crB.getFirstRow() :crA.getFirstRow(),
|
||||
gt(crB.getLastRow(), crA.getLastRow()) ?crB.getLastRow() :crA.getLastRow(),
|
||||
lt(crB.getFirstColumn(),crA.getFirstColumn())?crB.getFirstColumn():crA.getFirstColumn(),
|
||||
gt(crB.getLastColumn(), crA.getLastColumn()) ?crB.getLastColumn() :crA.getLastColumn()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if a < b
|
||||
*/
|
||||
private static boolean lt(int a, int b)
|
||||
{
|
||||
return a == -1 ? false : (b == -1 ? true : a < b);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if a <= b
|
||||
*/
|
||||
private static boolean le(int a, int b)
|
||||
{
|
||||
return a == b || lt(a,b);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if a > b
|
||||
*/
|
||||
private static boolean gt(int a, int b)
|
||||
{
|
||||
return lt(b,a);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if a >= b
|
||||
*/
|
||||
private static boolean ge(int a, int b)
|
||||
{
|
||||
return !lt(a,b);
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -24,8 +24,6 @@ import org.apache.poi.util.LittleEndianOutput;
|
||||
|
||||
/**
|
||||
* Pattern Formatting Block of the Conditional Formatting Rule Record.
|
||||
*
|
||||
* @author Dmitriy Kumshayev
|
||||
*/
|
||||
public final class PatternFormatting implements Cloneable {
|
||||
/** No background */
|
||||
|
@ -25,57 +25,54 @@ import org.apache.poi.ss.usermodel.Color;
|
||||
* High level representation for Font Formatting component
|
||||
* of Conditional Formatting settings
|
||||
*/
|
||||
public final class HSSFFontFormatting implements org.apache.poi.ss.usermodel.FontFormatting
|
||||
{
|
||||
/** Underline type - None */
|
||||
public final static byte U_NONE = FontFormatting.U_NONE;
|
||||
/** Underline type - Single */
|
||||
public final static byte U_SINGLE = FontFormatting.U_SINGLE;
|
||||
/** Underline type - Double */
|
||||
public final static byte U_DOUBLE = FontFormatting.U_DOUBLE;
|
||||
/** Underline type - Single Accounting */
|
||||
public final static byte U_SINGLE_ACCOUNTING = FontFormatting.U_SINGLE_ACCOUNTING;
|
||||
/** Underline type - Double Accounting */
|
||||
public final static byte U_DOUBLE_ACCOUNTING = FontFormatting.U_DOUBLE_ACCOUNTING;
|
||||
public final class HSSFFontFormatting implements org.apache.poi.ss.usermodel.FontFormatting {
|
||||
/** Underline type - None */
|
||||
public final static byte U_NONE = FontFormatting.U_NONE;
|
||||
/** Underline type - Single */
|
||||
public final static byte U_SINGLE = FontFormatting.U_SINGLE;
|
||||
/** Underline type - Double */
|
||||
public final static byte U_DOUBLE = FontFormatting.U_DOUBLE;
|
||||
/** Underline type - Single Accounting */
|
||||
public final static byte U_SINGLE_ACCOUNTING = FontFormatting.U_SINGLE_ACCOUNTING;
|
||||
/** Underline type - Double Accounting */
|
||||
public final static byte U_DOUBLE_ACCOUNTING = FontFormatting.U_DOUBLE_ACCOUNTING;
|
||||
|
||||
private final FontFormatting fontFormatting;
|
||||
private final HSSFWorkbook workbook;
|
||||
|
||||
protected HSSFFontFormatting(CFRuleBase cfRuleRecord, HSSFWorkbook workbook)
|
||||
{
|
||||
this.fontFormatting = cfRuleRecord.getFontFormatting();
|
||||
this.workbook = workbook;
|
||||
}
|
||||
|
||||
protected FontFormatting getFontFormattingBlock()
|
||||
{
|
||||
return fontFormatting;
|
||||
}
|
||||
private final FontFormatting fontFormatting;
|
||||
private final HSSFWorkbook workbook;
|
||||
|
||||
/**
|
||||
* get the type of super or subscript for the font
|
||||
*
|
||||
* @return super or subscript option
|
||||
* @see #SS_NONE
|
||||
* @see #SS_SUPER
|
||||
* @see #SS_SUB
|
||||
*/
|
||||
public short getEscapementType()
|
||||
{
|
||||
return fontFormatting.getEscapementType();
|
||||
}
|
||||
protected HSSFFontFormatting(CFRuleBase cfRuleRecord, HSSFWorkbook workbook) {
|
||||
this.fontFormatting = cfRuleRecord.getFontFormatting();
|
||||
this.workbook = workbook;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return font color index
|
||||
*/
|
||||
public short getFontColorIndex()
|
||||
{
|
||||
return fontFormatting.getFontColorIndex();
|
||||
}
|
||||
protected FontFormatting getFontFormattingBlock() {
|
||||
return fontFormatting;
|
||||
}
|
||||
|
||||
public HSSFColor getFontColor() {
|
||||
return workbook.getCustomPalette().getColor(
|
||||
getFontColorIndex()
|
||||
/**
|
||||
* get the type of super or subscript for the font
|
||||
*
|
||||
* @return super or subscript option
|
||||
* @see #SS_NONE
|
||||
* @see #SS_SUPER
|
||||
* @see #SS_SUB
|
||||
*/
|
||||
public short getEscapementType()
|
||||
{
|
||||
return fontFormatting.getEscapementType();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return font color index
|
||||
*/
|
||||
public short getFontColorIndex()
|
||||
{
|
||||
return fontFormatting.getFontColorIndex();
|
||||
}
|
||||
|
||||
public HSSFColor getFontColor() {
|
||||
return workbook.getCustomPalette().getColor(
|
||||
getFontColorIndex()
|
||||
);
|
||||
}
|
||||
|
||||
@ -83,7 +80,7 @@ public final class HSSFFontFormatting implements org.apache.poi.ss.usermodel.Fon
|
||||
if (color != null && !(color instanceof HSSFColor)) {
|
||||
throw new IllegalArgumentException("Only HSSFColor objects are supported");
|
||||
}
|
||||
|
||||
|
||||
HSSFColor hcolor = (HSSFColor)color;
|
||||
if (hcolor == null) {
|
||||
fontFormatting.setFontColorIndex((short)0);
|
||||
@ -93,328 +90,319 @@ public final class HSSFFontFormatting implements org.apache.poi.ss.usermodel.Fon
|
||||
}
|
||||
|
||||
/**
|
||||
* gets the height of the font in 1/20th point units
|
||||
*
|
||||
* @return fontheight (in points/20); or -1 if not modified
|
||||
*/
|
||||
public int getFontHeight()
|
||||
{
|
||||
return fontFormatting.getFontHeight();
|
||||
}
|
||||
* gets the height of the font in 1/20th point units
|
||||
*
|
||||
* @return fontheight (in points/20); or -1 if not modified
|
||||
*/
|
||||
public int getFontHeight() {
|
||||
return fontFormatting.getFontHeight();
|
||||
}
|
||||
|
||||
/**
|
||||
* get the font weight for this font (100-1000dec or 0x64-0x3e8). Default is
|
||||
* 0x190 for normal and 0x2bc for bold
|
||||
*
|
||||
* @return bw - a number between 100-1000 for the fonts "boldness"
|
||||
*/
|
||||
/**
|
||||
* get the font weight for this font (100-1000dec or 0x64-0x3e8). Default is
|
||||
* 0x190 for normal and 0x2bc for bold
|
||||
*
|
||||
* @return bw - a number between 100-1000 for the fonts "boldness"
|
||||
*/
|
||||
public short getFontWeight() {
|
||||
return fontFormatting.getFontWeight();
|
||||
}
|
||||
|
||||
public short getFontWeight()
|
||||
{
|
||||
return fontFormatting.getFontWeight();
|
||||
}
|
||||
/**
|
||||
* @see org.apache.poi.hssf.record.cf.FontFormatting#getRawRecord()
|
||||
*/
|
||||
protected byte[] getRawRecord() {
|
||||
return fontFormatting.getRawRecord();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.apache.poi.hssf.record.cf.FontFormatting#getRawRecord()
|
||||
*/
|
||||
protected byte[] getRawRecord()
|
||||
{
|
||||
return fontFormatting.getRawRecord();
|
||||
}
|
||||
/**
|
||||
* get the type of underlining for the font
|
||||
*
|
||||
* @return font underlining type
|
||||
*
|
||||
* @see #U_NONE
|
||||
* @see #U_SINGLE
|
||||
* @see #U_DOUBLE
|
||||
* @see #U_SINGLE_ACCOUNTING
|
||||
* @see #U_DOUBLE_ACCOUNTING
|
||||
*/
|
||||
public short getUnderlineType()
|
||||
{
|
||||
return fontFormatting.getUnderlineType();
|
||||
}
|
||||
|
||||
/**
|
||||
* get the type of underlining for the font
|
||||
*
|
||||
* @return font underlining type
|
||||
*
|
||||
* @see #U_NONE
|
||||
* @see #U_SINGLE
|
||||
* @see #U_DOUBLE
|
||||
* @see #U_SINGLE_ACCOUNTING
|
||||
* @see #U_DOUBLE_ACCOUNTING
|
||||
*/
|
||||
public short getUnderlineType()
|
||||
{
|
||||
return fontFormatting.getUnderlineType();
|
||||
}
|
||||
/**
|
||||
* get whether the font weight is set to bold or not
|
||||
*
|
||||
* @return bold - whether the font is bold or not
|
||||
*/
|
||||
public boolean isBold()
|
||||
{
|
||||
return fontFormatting.isFontWeightModified() && fontFormatting.isBold();
|
||||
}
|
||||
|
||||
/**
|
||||
* get whether the font weight is set to bold or not
|
||||
*
|
||||
* @return bold - whether the font is bold or not
|
||||
*/
|
||||
public boolean isBold()
|
||||
{
|
||||
return fontFormatting.isFontWeightModified() && fontFormatting.isBold();
|
||||
}
|
||||
/**
|
||||
* @return true if escapement type was modified from default
|
||||
*/
|
||||
public boolean isEscapementTypeModified()
|
||||
{
|
||||
return fontFormatting.isEscapementTypeModified();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if escapement type was modified from default
|
||||
*/
|
||||
public boolean isEscapementTypeModified()
|
||||
{
|
||||
return fontFormatting.isEscapementTypeModified();
|
||||
}
|
||||
/**
|
||||
* @return true if font cancellation was modified from default
|
||||
*/
|
||||
public boolean isFontCancellationModified()
|
||||
{
|
||||
return fontFormatting.isFontCancellationModified();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if font cancellation was modified from default
|
||||
*/
|
||||
public boolean isFontCancellationModified()
|
||||
{
|
||||
return fontFormatting.isFontCancellationModified();
|
||||
}
|
||||
/**
|
||||
* @return true if font outline type was modified from default
|
||||
*/
|
||||
public boolean isFontOutlineModified()
|
||||
{
|
||||
return fontFormatting.isFontOutlineModified();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if font outline type was modified from default
|
||||
*/
|
||||
public boolean isFontOutlineModified()
|
||||
{
|
||||
return fontFormatting.isFontOutlineModified();
|
||||
}
|
||||
/**
|
||||
* @return true if font shadow type was modified from default
|
||||
*/
|
||||
public boolean isFontShadowModified()
|
||||
{
|
||||
return fontFormatting.isFontShadowModified();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if font shadow type was modified from default
|
||||
*/
|
||||
public boolean isFontShadowModified()
|
||||
{
|
||||
return fontFormatting.isFontShadowModified();
|
||||
}
|
||||
/**
|
||||
* @return true if font style was modified from default
|
||||
*/
|
||||
public boolean isFontStyleModified()
|
||||
{
|
||||
return fontFormatting.isFontStyleModified();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if font style was modified from default
|
||||
*/
|
||||
public boolean isFontStyleModified()
|
||||
{
|
||||
return fontFormatting.isFontStyleModified();
|
||||
}
|
||||
/**
|
||||
* @return true if font style was set to <i>italic</i>
|
||||
*/
|
||||
public boolean isItalic()
|
||||
{
|
||||
return fontFormatting.isFontStyleModified() && fontFormatting.isItalic();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if font style was set to <i>italic</i>
|
||||
*/
|
||||
public boolean isItalic()
|
||||
{
|
||||
return fontFormatting.isFontStyleModified() && fontFormatting.isItalic();
|
||||
}
|
||||
/**
|
||||
* @return true if font outline is on
|
||||
*/
|
||||
public boolean isOutlineOn()
|
||||
{
|
||||
return fontFormatting.isFontOutlineModified() && fontFormatting.isOutlineOn();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if font outline is on
|
||||
*/
|
||||
public boolean isOutlineOn()
|
||||
{
|
||||
return fontFormatting.isFontOutlineModified() && fontFormatting.isOutlineOn();
|
||||
}
|
||||
/**
|
||||
* @return true if font shadow is on
|
||||
*/
|
||||
public boolean isShadowOn()
|
||||
{
|
||||
return fontFormatting.isFontOutlineModified() && fontFormatting.isShadowOn();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if font shadow is on
|
||||
*/
|
||||
public boolean isShadowOn()
|
||||
{
|
||||
return fontFormatting.isFontOutlineModified() && fontFormatting.isShadowOn();
|
||||
}
|
||||
/**
|
||||
* @return true if font strikeout is on
|
||||
*/
|
||||
public boolean isStruckout()
|
||||
{
|
||||
return fontFormatting.isFontCancellationModified() && fontFormatting.isStruckout();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if font strikeout is on
|
||||
*/
|
||||
public boolean isStruckout()
|
||||
{
|
||||
return fontFormatting.isFontCancellationModified() && fontFormatting.isStruckout();
|
||||
}
|
||||
/**
|
||||
* @return true if font underline type was modified from default
|
||||
*/
|
||||
public boolean isUnderlineTypeModified()
|
||||
{
|
||||
return fontFormatting.isUnderlineTypeModified();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if font underline type was modified from default
|
||||
*/
|
||||
public boolean isUnderlineTypeModified()
|
||||
{
|
||||
return fontFormatting.isUnderlineTypeModified();
|
||||
}
|
||||
/**
|
||||
* @return true if font weight was modified from default
|
||||
*/
|
||||
public boolean isFontWeightModified()
|
||||
{
|
||||
return fontFormatting.isFontWeightModified();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if font weight was modified from default
|
||||
*/
|
||||
public boolean isFontWeightModified()
|
||||
{
|
||||
return fontFormatting.isFontWeightModified();
|
||||
}
|
||||
/**
|
||||
* set font style options.
|
||||
*
|
||||
* @param italic - if true, set posture style to italic, otherwise to normal
|
||||
* @param bold if true, set font weight to bold, otherwise to normal
|
||||
*/
|
||||
|
||||
/**
|
||||
* set font style options.
|
||||
*
|
||||
* @param italic - if true, set posture style to italic, otherwise to normal
|
||||
* @param bold if true, set font weight to bold, otherwise to normal
|
||||
*/
|
||||
|
||||
public void setFontStyle(boolean italic, boolean bold)
|
||||
{
|
||||
boolean modified = italic || bold;
|
||||
fontFormatting.setItalic(italic);
|
||||
fontFormatting.setBold(bold);
|
||||
fontFormatting.setFontStyleModified(modified);
|
||||
fontFormatting.setFontWieghtModified(modified);
|
||||
}
|
||||
public void setFontStyle(boolean italic, boolean bold)
|
||||
{
|
||||
boolean modified = italic || bold;
|
||||
fontFormatting.setItalic(italic);
|
||||
fontFormatting.setBold(bold);
|
||||
fontFormatting.setFontStyleModified(modified);
|
||||
fontFormatting.setFontWieghtModified(modified);
|
||||
}
|
||||
|
||||
/**
|
||||
* set font style options to default values (non-italic, non-bold)
|
||||
*/
|
||||
public void resetFontStyle()
|
||||
{
|
||||
setFontStyle(false,false);
|
||||
}
|
||||
/**
|
||||
* set font style options to default values (non-italic, non-bold)
|
||||
*/
|
||||
public void resetFontStyle()
|
||||
{
|
||||
setFontStyle(false,false);
|
||||
}
|
||||
|
||||
/**
|
||||
* set the escapement type for the font
|
||||
*
|
||||
* @param escapementType super or subscript option
|
||||
* @see #SS_NONE
|
||||
* @see #SS_SUPER
|
||||
* @see #SS_SUB
|
||||
*/
|
||||
public void setEscapementType(short escapementType)
|
||||
{
|
||||
switch(escapementType)
|
||||
{
|
||||
case HSSFFontFormatting.SS_SUB:
|
||||
case HSSFFontFormatting.SS_SUPER:
|
||||
fontFormatting.setEscapementType(escapementType);
|
||||
fontFormatting.setEscapementTypeModified(true);
|
||||
break;
|
||||
case HSSFFontFormatting.SS_NONE:
|
||||
fontFormatting.setEscapementType(escapementType);
|
||||
fontFormatting.setEscapementTypeModified(false);
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
/**
|
||||
* set the escapement type for the font
|
||||
*
|
||||
* @param escapementType super or subscript option
|
||||
* @see #SS_NONE
|
||||
* @see #SS_SUPER
|
||||
* @see #SS_SUB
|
||||
*/
|
||||
public void setEscapementType(short escapementType) {
|
||||
switch(escapementType) {
|
||||
case HSSFFontFormatting.SS_SUB:
|
||||
case HSSFFontFormatting.SS_SUPER:
|
||||
fontFormatting.setEscapementType(escapementType);
|
||||
fontFormatting.setEscapementTypeModified(true);
|
||||
break;
|
||||
case HSSFFontFormatting.SS_NONE:
|
||||
fontFormatting.setEscapementType(escapementType);
|
||||
fontFormatting.setEscapementTypeModified(false);
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param modified
|
||||
* @see org.apache.poi.hssf.record.cf.FontFormatting#setEscapementTypeModified(boolean)
|
||||
*/
|
||||
public void setEscapementTypeModified(boolean modified)
|
||||
{
|
||||
fontFormatting.setEscapementTypeModified(modified);
|
||||
}
|
||||
/**
|
||||
* @param modified
|
||||
* @see org.apache.poi.hssf.record.cf.FontFormatting#setEscapementTypeModified(boolean)
|
||||
*/
|
||||
public void setEscapementTypeModified(boolean modified) {
|
||||
fontFormatting.setEscapementTypeModified(modified);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param modified
|
||||
* @see org.apache.poi.hssf.record.cf.FontFormatting#setFontCancellationModified(boolean)
|
||||
*/
|
||||
public void setFontCancellationModified(boolean modified)
|
||||
{
|
||||
fontFormatting.setFontCancellationModified(modified);
|
||||
}
|
||||
/**
|
||||
* @param modified
|
||||
* @see org.apache.poi.hssf.record.cf.FontFormatting#setFontCancellationModified(boolean)
|
||||
*/
|
||||
public void setFontCancellationModified(boolean modified)
|
||||
{
|
||||
fontFormatting.setFontCancellationModified(modified);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param fci
|
||||
* @see org.apache.poi.hssf.record.cf.FontFormatting#setFontColorIndex(short)
|
||||
*/
|
||||
public void setFontColorIndex(short fci)
|
||||
{
|
||||
fontFormatting.setFontColorIndex(fci);
|
||||
}
|
||||
/**
|
||||
* @param fci
|
||||
* @see org.apache.poi.hssf.record.cf.FontFormatting#setFontColorIndex(short)
|
||||
*/
|
||||
public void setFontColorIndex(short fci)
|
||||
{
|
||||
fontFormatting.setFontColorIndex(fci);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param height
|
||||
* @see org.apache.poi.hssf.record.cf.FontFormatting#setFontHeight(int)
|
||||
*/
|
||||
public void setFontHeight(int height)
|
||||
{
|
||||
fontFormatting.setFontHeight(height);
|
||||
}
|
||||
/**
|
||||
* @param height
|
||||
* @see org.apache.poi.hssf.record.cf.FontFormatting#setFontHeight(int)
|
||||
*/
|
||||
public void setFontHeight(int height)
|
||||
{
|
||||
fontFormatting.setFontHeight(height);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param modified
|
||||
* @see org.apache.poi.hssf.record.cf.FontFormatting#setFontOutlineModified(boolean)
|
||||
*/
|
||||
public void setFontOutlineModified(boolean modified)
|
||||
{
|
||||
fontFormatting.setFontOutlineModified(modified);
|
||||
}
|
||||
/**
|
||||
* @param modified
|
||||
* @see org.apache.poi.hssf.record.cf.FontFormatting#setFontOutlineModified(boolean)
|
||||
*/
|
||||
public void setFontOutlineModified(boolean modified)
|
||||
{
|
||||
fontFormatting.setFontOutlineModified(modified);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param modified
|
||||
* @see org.apache.poi.hssf.record.cf.FontFormatting#setFontShadowModified(boolean)
|
||||
*/
|
||||
public void setFontShadowModified(boolean modified)
|
||||
{
|
||||
fontFormatting.setFontShadowModified(modified);
|
||||
}
|
||||
/**
|
||||
* @param modified
|
||||
* @see org.apache.poi.hssf.record.cf.FontFormatting#setFontShadowModified(boolean)
|
||||
*/
|
||||
public void setFontShadowModified(boolean modified)
|
||||
{
|
||||
fontFormatting.setFontShadowModified(modified);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param modified
|
||||
* @see org.apache.poi.hssf.record.cf.FontFormatting#setFontStyleModified(boolean)
|
||||
*/
|
||||
public void setFontStyleModified(boolean modified)
|
||||
{
|
||||
fontFormatting.setFontStyleModified(modified);
|
||||
}
|
||||
/**
|
||||
* @param modified
|
||||
* @see org.apache.poi.hssf.record.cf.FontFormatting#setFontStyleModified(boolean)
|
||||
*/
|
||||
public void setFontStyleModified(boolean modified)
|
||||
{
|
||||
fontFormatting.setFontStyleModified(modified);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param on
|
||||
* @see org.apache.poi.hssf.record.cf.FontFormatting#setOutline(boolean)
|
||||
*/
|
||||
public void setOutline(boolean on)
|
||||
{
|
||||
fontFormatting.setOutline(on);
|
||||
fontFormatting.setFontOutlineModified(on);
|
||||
}
|
||||
/**
|
||||
* @param on
|
||||
* @see org.apache.poi.hssf.record.cf.FontFormatting#setOutline(boolean)
|
||||
*/
|
||||
public void setOutline(boolean on)
|
||||
{
|
||||
fontFormatting.setOutline(on);
|
||||
fontFormatting.setFontOutlineModified(on);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param on
|
||||
* @see org.apache.poi.hssf.record.cf.FontFormatting#setShadow(boolean)
|
||||
*/
|
||||
public void setShadow(boolean on)
|
||||
{
|
||||
fontFormatting.setShadow(on);
|
||||
fontFormatting.setFontShadowModified(on);
|
||||
}
|
||||
/**
|
||||
* @param on
|
||||
* @see org.apache.poi.hssf.record.cf.FontFormatting#setShadow(boolean)
|
||||
*/
|
||||
public void setShadow(boolean on)
|
||||
{
|
||||
fontFormatting.setShadow(on);
|
||||
fontFormatting.setFontShadowModified(on);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param strike
|
||||
* @see org.apache.poi.hssf.record.cf.FontFormatting#setStrikeout(boolean)
|
||||
*/
|
||||
public void setStrikeout(boolean strike)
|
||||
{
|
||||
fontFormatting.setStrikeout(strike);
|
||||
fontFormatting.setFontCancellationModified(strike);
|
||||
}
|
||||
/**
|
||||
* @param strike
|
||||
* @see org.apache.poi.hssf.record.cf.FontFormatting#setStrikeout(boolean)
|
||||
*/
|
||||
public void setStrikeout(boolean strike)
|
||||
{
|
||||
fontFormatting.setStrikeout(strike);
|
||||
fontFormatting.setFontCancellationModified(strike);
|
||||
}
|
||||
|
||||
/**
|
||||
* set the type of underlining type for the font
|
||||
*
|
||||
* @param underlineType super or subscript option
|
||||
*
|
||||
* @see #U_NONE
|
||||
* @see #U_SINGLE
|
||||
* @see #U_DOUBLE
|
||||
* @see #U_SINGLE_ACCOUNTING
|
||||
* @see #U_DOUBLE_ACCOUNTING
|
||||
*/
|
||||
public void setUnderlineType(short underlineType)
|
||||
{
|
||||
switch(underlineType)
|
||||
{
|
||||
case HSSFFontFormatting.U_SINGLE:
|
||||
case HSSFFontFormatting.U_DOUBLE:
|
||||
case HSSFFontFormatting.U_SINGLE_ACCOUNTING:
|
||||
case HSSFFontFormatting.U_DOUBLE_ACCOUNTING:
|
||||
fontFormatting.setUnderlineType(underlineType);
|
||||
setUnderlineTypeModified(true);
|
||||
break;
|
||||
|
||||
case HSSFFontFormatting.U_NONE:
|
||||
fontFormatting.setUnderlineType(underlineType);
|
||||
setUnderlineTypeModified(false);
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
/**
|
||||
* set the type of underlining type for the font
|
||||
*
|
||||
* @param underlineType super or subscript option
|
||||
*
|
||||
* @see #U_NONE
|
||||
* @see #U_SINGLE
|
||||
* @see #U_DOUBLE
|
||||
* @see #U_SINGLE_ACCOUNTING
|
||||
* @see #U_DOUBLE_ACCOUNTING
|
||||
*/
|
||||
public void setUnderlineType(short underlineType) {
|
||||
switch(underlineType) {
|
||||
case HSSFFontFormatting.U_SINGLE:
|
||||
case HSSFFontFormatting.U_DOUBLE:
|
||||
case HSSFFontFormatting.U_SINGLE_ACCOUNTING:
|
||||
case HSSFFontFormatting.U_DOUBLE_ACCOUNTING:
|
||||
fontFormatting.setUnderlineType(underlineType);
|
||||
setUnderlineTypeModified(true);
|
||||
break;
|
||||
|
||||
case HSSFFontFormatting.U_NONE:
|
||||
fontFormatting.setUnderlineType(underlineType);
|
||||
setUnderlineTypeModified(false);
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param modified
|
||||
* @see org.apache.poi.hssf.record.cf.FontFormatting#setUnderlineTypeModified(boolean)
|
||||
*/
|
||||
public void setUnderlineTypeModified(boolean modified)
|
||||
{
|
||||
fontFormatting.setUnderlineTypeModified(modified);
|
||||
}
|
||||
/**
|
||||
* @param modified
|
||||
* @see org.apache.poi.hssf.record.cf.FontFormatting#setUnderlineTypeModified(boolean)
|
||||
*/
|
||||
public void setUnderlineTypeModified(boolean modified)
|
||||
{
|
||||
fontFormatting.setUnderlineTypeModified(modified);
|
||||
}
|
||||
}
|
||||
|
@ -22,9 +22,6 @@ package org.apache.poi.ss.usermodel;
|
||||
/**
|
||||
* High level representation for Font Formatting component
|
||||
* of Conditional Formatting settings
|
||||
*
|
||||
* @author Dmitriy Kumshayev
|
||||
* @author Yegor Kozlov
|
||||
*/
|
||||
public interface FontFormatting {
|
||||
/** Escapement type - None */
|
||||
|
Loading…
Reference in New Issue
Block a user