Java Code Examples for org.apache.poi.util.StringUtil#readUnicodeString()

The following examples show how to use org.apache.poi.util.StringUtil#readUnicodeString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ConstantValueParser.java    From lams with GNU General Public License v2.0 7 votes vote down vote up
private static Object readAConstantValue(LittleEndianInput in) {
	byte grbit = in.readByte();
	switch(grbit) {
		case TYPE_EMPTY:
			in.readLong(); // 8 byte 'not used' field
			return EMPTY_REPRESENTATION; 
		case TYPE_NUMBER:
			return new Double(in.readDouble());
		case TYPE_STRING:
			return StringUtil.readUnicodeString(in);
		case TYPE_BOOLEAN:
			return readBoolean(in);
		case TYPE_ERROR_CODE:
			int errCode = in.readUShort();
			// next 6 bytes are unused
			in.readUShort();
			in.readInt();
			return ErrorConstant.valueOf(errCode);
	}
	throw new RuntimeException("Unknown grbit value (" + grbit + ")");
}
 
Example 2
Source File: ViewDefinitionRecord.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public ViewDefinitionRecord(RecordInputStream in) {
	rwFirst = in.readUShort();
	rwLast = in.readUShort();
	colFirst = in.readUShort();
	colLast = in.readUShort();
	rwFirstHead = in.readUShort();
	rwFirstData = in.readUShort();
	colFirstData = in.readUShort();
	iCache = in.readUShort();
	reserved = in.readUShort();
	sxaxis4Data = in.readUShort();
	ipos4Data = in.readUShort();
	cDim = in.readUShort();
	cDimRw = in.readUShort();
	cDimCol = in.readUShort();
	cDimPg = in.readUShort();
	cDimData = in.readUShort();
	cRw = in.readUShort();
	cCol = in.readUShort();
	grbit = in.readUShort();
	itblAutoFmt = in.readUShort();
	int cchName = in.readUShort();
	int cchData = in.readUShort();

	name = StringUtil.readUnicodeString(in, cchName);
	dataField = StringUtil.readUnicodeString(in, cchData);
}
 
Example 3
Source File: ExternalNameRecord.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public ExternalNameRecord(RecordInputStream in) {
field_1_option_flag = in.readShort();
field_2_ixals       = in.readShort();
    field_3_not_used    = in.readShort();

      int numChars = in.readUByte();
      field_4_name = StringUtil.readUnicodeString(in, numChars);

      // the record body can take different forms.
      // The form is dictated by the values of 3-th and 4-th bits in field_1_option_flag
      if(!isOLELink() && !isStdDocumentNameIdentifier()){
          // another switch: the fWantAdvise bit specifies whether the body describes
          // an external defined name or a DDE data item
          if(isAutomaticLink()){
              if(in.available() > 0) {
                 //body specifies DDE data item
                 int nColumns = in.readUByte() + 1;
                 int nRows = in.readShort() + 1;
 
                 int totalCount = nRows * nColumns;
                 _ddeValues = ConstantValueParser.parse(in, totalCount);
                 _nColumns = nColumns;
                 _nRows = nRows;
              }
          } else {
              //body specifies an external defined name
              int formulaLen = in.readUShort();
              field_5_name_definition = Formula.read(formulaLen, in);
          }
      }
  }
 
Example 4
Source File: LbsDataSubRecord.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public LbsDropData(LittleEndianInput in){
    _wStyle = in.readUShort();
    _cLine = in.readUShort();
    _dxMin = in.readUShort();
    _str = StringUtil.readUnicodeString(in);
    if(StringUtil.getEncodedSize(_str) % 2 != 0){
        _unused = in.readByte();
    }
}
 
Example 5
Source File: FeatProtection.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public FeatProtection(RecordInputStream in) {
	fSD = in.readInt();
	passwordVerifier = in.readInt();
	
	title = StringUtil.readUnicodeString(in);
	
	securityDescriptor = in.readRemainder();
}
 
Example 6
Source File: LbsDataSubRecord.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
/**
 * @param in the stream to read data from
 * @param cbFContinued the seconf short in the record header
 * @param cmoOt the containing Obj's {@link CommonObjectDataSubRecord#field_1_objectType}
 */
public LbsDataSubRecord(LittleEndianInput in, int cbFContinued, int cmoOt) {
    _cbFContinued = cbFContinued;

    int encodedTokenLen = in.readUShort();
    if (encodedTokenLen > 0) {
        int formulaSize = in.readUShort();
        _unknownPreFormulaInt = in.readInt();

        Ptg[] ptgs = Ptg.readTokens(formulaSize, in);
        if (ptgs.length != 1) {
            throw new RecordFormatException("Read " + ptgs.length
                    + " tokens but expected exactly 1");
        }
        _linkPtg = ptgs[0];
        switch (encodedTokenLen - formulaSize - 6) {
            case 1:
                _unknownPostFormulaByte = in.readByte();
                break;
            case 0:
                _unknownPostFormulaByte = null;
                break;
            default:
                throw new RecordFormatException("Unexpected leftover bytes");
        }
    }

    _cLines = in.readUShort();
    _iSel = in.readUShort();
    _flags = in.readUShort();
    _idEdit = in.readUShort();

    // From [MS-XLS].pdf 2.5.147 FtLbsData:
    // This field MUST exist if and only if the containing Obj?s cmo.ot is equal to 0x14.
    if(cmoOt == 0x14) {
        _dropData = new LbsDropData(in);
    }

    // From [MS-XLS].pdf 2.5.147 FtLbsData:
    // This array MUST exist if and only if the fValidPlex flag (0x2) is set
    if((_flags & 0x2) != 0) {
        _rgLines = new String[_cLines];
        for(int i=0; i < _cLines; i++) {
            _rgLines[i] = StringUtil.readUnicodeString(in);
        }
    }

    // bits 5-6 in the _flags specify the type
    // of selection behavior this list control is expected to support

    // From [MS-XLS].pdf 2.5.147 FtLbsData:
    // This array MUST exist if and only if the wListType field is not equal to 0.
    if(((_flags >> 4) & 0x2) != 0) {
        _bsels = new boolean[_cLines];
        for(int i=0; i < _cLines; i++) {
            _bsels[i] = in.readByte() == 1;
        }
    }

}