示例#1
0
 public void TestUnicodeReadName()
 {
     byte[] data = HexRead.ReadFromString(
             "11 00 09 00 01 38 5E C4 89 5F 00 53 00 68 00 65 00 65 00 74 00 31 00");
     RecordInputStream in1 = TestcaseRecordInputStream.Create(StyleRecord.sid, data);
     StyleRecord sr = new StyleRecord(in1);
     Assert.AreEqual("\u5E38\u89C4_Sheet1", sr.Name); // "<Conventional>_Sheet1"
     byte[] ser;
     try
     {
         ser = sr.Serialize();
     }
     catch (InvalidOperationException e)
     {
         if (e.Message.Equals("Incorrect number of bytes written - expected 27 but got 18"))
         {
             throw new AssertionException("Identified bug 46385");
         }
         throw e;
     }
     TestcaseRecordInputStream.ConfirmRecordEncoding(StyleRecord.sid, data, ser);
 }
示例#2
0
    /**
 * Creates a new StyleRecord, for the given Extended
 *  Format index, and adds it onto the end of the
 *  records collection
 */
    public StyleRecord CreateStyleRecord(int xfIndex) {
        // Style records always follow after 
        //  the ExtendedFormat records
        StyleRecord newSR = new StyleRecord();
        newSR.XFIndex = (short)xfIndex;
        
        // Find the spot
        int addAt = -1;
        for(int i=records.Xfpos; i<records.Count &&
                addAt == -1; i++) {
            Record r = records[i];
            if(r is ExtendedFormatRecord ||
                    r is StyleRecord) {
                // Keep going
            } else {
                addAt = i;
            }
        }
        if(addAt == -1) {
            throw new InvalidOperationException("No XF Records found!");
        }
        records.Add(addAt, newSR);
        
        return newSR;
  }
示例#3
0
        /**
         * Creates a StyleRecord object
         * @param id        the number of the style record to Create (meaning its position in
         *                  a file as MS Excel would Create it.
         * @return record containing a StyleRecord
         * @see org.apache.poi.hssf.record.StyleRecord
         * @see org.apache.poi.hssf.record.Record
         */

        private static Record CreateStyle(int id)
        {   // we'll need multiple editions
            StyleRecord retval = new StyleRecord();

            switch (id)
            {

                case 0:
                    retval.XFIndex = (unchecked((short)0xffff8010));
                    retval.SetBuiltinStyle(3);
                    retval.OutlineStyleLevel= (unchecked((byte)0xffffffff));
                    break;

                case 1:
                    retval.XFIndex = (unchecked((short)0xffff8011));
                    retval.SetBuiltinStyle(6);
                    retval.OutlineStyleLevel= (unchecked((byte)0xffffffff));
                    break;

                case 2:
                    retval.XFIndex = (unchecked((short)0xffff8012));
                    retval.SetBuiltinStyle(4);
                    retval.OutlineStyleLevel= (unchecked((byte)0xffffffff));
                    break;

                case 3:
                    retval.XFIndex = (unchecked((short)0xffff8013));
                    retval.SetBuiltinStyle(7);
                    retval.OutlineStyleLevel= (unchecked((byte)0xffffffff));
                    break;

                case 4:
                    retval.XFIndex = (unchecked((short)0xffff8000));
                    retval.SetBuiltinStyle(0);
                    retval.OutlineStyleLevel= (unchecked((byte)0xffffffff));
                    break;

                case 5:
                    retval.XFIndex = (unchecked((short)0xffff8014));
                    retval.SetBuiltinStyle(5);
                    retval.OutlineStyleLevel= (unchecked((byte)0xffffffff));
                    break;
            }
            return retval;
        }
示例#4
0
        /**
         * Creates a StyleRecord object
         * @param id        the number of the style record to Create (meaning its position in
         *                  a file as MS Excel would Create it.
         * @return record containing a StyleRecord
         * @see org.apache.poi.hssf.record.StyleRecord
         * @see org.apache.poi.hssf.record.Record
         */

        protected Record CreateStyle(int id)
        {   // we'll need multiple editions
            StyleRecord retval = new StyleRecord();

            switch (id)
            {

                case 0:
                    retval.Index = (unchecked((short)0xffff8010));
                    retval.Builtin= ((byte)3);
                    retval.OutlineStyleLevel= (unchecked((byte)0xffffffff));
                    break;

                case 1:
                    retval.Index = (unchecked((short)0xffff8011));
                    retval.Builtin= ((byte)6);
                    retval.OutlineStyleLevel= (unchecked((byte)0xffffffff));
                    break;

                case 2:
                    retval.Index = (unchecked((short)0xffff8012));
                    retval.Builtin= ((byte)4);
                    retval.OutlineStyleLevel= (unchecked((byte)0xffffffff));
                    break;

                case 3:
                    retval.Index = (unchecked((short)0xffff8013));
                    retval.Builtin= ((byte)7);
                    retval.OutlineStyleLevel= (unchecked((byte)0xffffffff));
                    break;

                case 4:
                    retval.Index = (unchecked((short)0xffff8000));
                    retval.Builtin= ((byte)0);
                    retval.OutlineStyleLevel= (unchecked((byte)0xffffffff));
                    break;

                case 5:
                    retval.Index = (unchecked((short)0xffff8014));
                    retval.Builtin= ((byte)5);
                    retval.OutlineStyleLevel= (unchecked((byte)0xffffffff));
                    break;
            }
            return retval;
        }