📄 dvalparser.java
字号:
/*********************************************************************
*
* Copyright (C) 2004 Andrew Khan
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
***************************************************************************/
package jxl.biff;
import common.Logger;
import jxl.WorkbookSettings;
import jxl.biff.formula.ExternalSheet;
import jxl.biff.formula.FormulaParser;
import jxl.biff.formula.FormulaException;
/**
* Class which parses the binary data associated with Data Validity (DVal)
* setting
*/
public class DValParser
{
/**
* The logger
*/
private static Logger logger = Logger.getLogger(DValParser.class);
// The option masks
private static int PROMPT_BOX_VISIBLE_MASK = 0x1;
private static int PROMPT_BOX_AT_CELL_MASK = 0x2;
private static int VALIDITY_DATA_CACHED_MASK = 0x4;
/**
* Prompt box visible
*/
private boolean promptBoxVisible;
/**
* Empty cells allowed
*/
private boolean promptBoxAtCell;
/**
* Cell validity data cached in following DV records
*/
private boolean validityDataCached;
/**
* The number of following DV records
*/
private int numDVRecords;
/**
* Constructor
*/
public DValParser(byte[] data)
{
int options = IntegerHelper.getInt(data[0], data[1]);
promptBoxVisible = (options & PROMPT_BOX_VISIBLE_MASK) != 0;
promptBoxAtCell = (options & PROMPT_BOX_AT_CELL_MASK) != 0;
validityDataCached = (options & VALIDITY_DATA_CACHED_MASK) != 0;
numDVRecords = IntegerHelper.getInt(data[14], data[15],
data[16], data[17]);
}
/**
* Gets the data
*/
public byte[] getData()
{
byte[] data = new byte[18];
int options = 0;
if (promptBoxVisible)
{
options |= PROMPT_BOX_VISIBLE_MASK;
}
if (promptBoxAtCell)
{
options |= PROMPT_BOX_AT_CELL_MASK;
}
if (validityDataCached)
{
options |= VALIDITY_DATA_CACHED_MASK;
}
IntegerHelper.getFourBytes(0xffffffff, data, 10);
IntegerHelper.getFourBytes(numDVRecords, data, 14);
return data;
}
/**
* Called when a remove row or column results in one of DV records being
* removed
*/
public void dvRemoved()
{
numDVRecords--;
}
/**
* Accessor for the number of DV records
*
* @return the number of DV records for this list
*/
public int getNumberOfDVRecords()
{
return numDVRecords;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -