Ejemplo n.º 1
0
        /// <summary>
        /// Creates the low-level records for a comment.
        /// </summary>
        /// <param name="hssfShape">The highlevel shape.</param>
        /// <param name="shapeId">The shape id to use for this shape.</param>
        public CommentShape(HSSFComment hssfShape, int shapeId)
            : base(hssfShape, shapeId)
        {
            note = CreateNoteRecord(hssfShape, shapeId);

            ObjRecord obj     = ObjRecord;
            IList     records = obj.GetSubRecords();
            int       cmoIdx  = 0;

            for (int i = 0; i < records.Count; i++)
            {
                Object r = records[i];

                if (r is CommonObjectDataSubRecord)
                {
                    //modify autoFill attribute inherited from <c>TextObjectRecord</c>
                    CommonObjectDataSubRecord cmo = (CommonObjectDataSubRecord)r;
                    cmo.IsAutoFill = (false);
                    cmoIdx         = i;
                }
            }
            //Add NoteStructure sub record
            //we don't know it's format, for now the record data Is empty
            NoteStructureSubRecord u = new NoteStructureSubRecord();

            obj.AddSubRecord(cmoIdx + 1, u);
        }
Ejemplo n.º 2
0
        public void TestConstruct()
        {
            ObjRecord record = new ObjRecord();
            CommonObjectDataSubRecord ftCmo = new CommonObjectDataSubRecord();

            ftCmo.ObjectType  = (CommonObjectType.COMMENT);
            ftCmo.ObjectId    = ((short)1024);
            ftCmo.IsLocked    = (true);
            ftCmo.IsPrintable = (true);
            ftCmo.IsAutoFill  = (true);
            ftCmo.IsAutoline  = (true);
            record.AddSubRecord(ftCmo);
            EndSubRecord ftEnd = new EndSubRecord();

            record.AddSubRecord(ftEnd);

            //Serialize and Read again
            byte[] recordBytes = record.Serialize();
            //cut off the record header
            byte[] bytes = new byte[recordBytes.Length - 4];
            System.Array.Copy(recordBytes, 4, bytes, 0, bytes.Length);

            record = new ObjRecord(TestcaseRecordInputStream.Create(ObjRecord.sid, bytes));
            IList subrecords = record.GetSubRecords();

            Assert.AreEqual(2, subrecords.Count);
            Assert.IsTrue(subrecords[0] is CommonObjectDataSubRecord);
            Assert.IsTrue(subrecords[1] is EndSubRecord);
        }
Ejemplo n.º 3
0
        public void TestLoad()
        {
            ObjRecord record = new ObjRecord(TestcaseRecordInputStream.Create(ObjRecord.sid, recdata));

            Assert.AreEqual(26, record.RecordSize - 4);

            IList subrecords = record.GetSubRecords();

            Assert.AreEqual(2, subrecords.Count);
            Assert.IsTrue(subrecords[0] is CommonObjectDataSubRecord);
            Assert.IsTrue(subrecords[1] is EndSubRecord);
        }
Ejemplo n.º 4
0
        /**
         * Finds the EmbeddedObjectRefSubRecord, or throws an
         *  Exception if there wasn't one
         */
        public EmbeddedObjectRefSubRecord FindObjectRecord()
        {
            IEnumerator subRecordIter = record.GetSubRecords().GetEnumerator();

            while (subRecordIter.MoveNext())
            {
                Object subRecord = subRecordIter.Current;
                if (subRecord is EmbeddedObjectRefSubRecord)
                {
                    return((EmbeddedObjectRefSubRecord)subRecord);
                }
            }

            throw new InvalidOperationException("Object data does not contain a reference to an embedded object OLE2 directory");
        }
Ejemplo n.º 5
0
        public void TestReadWriteWithPadding_bug45133()
        {
            ObjRecord record = new ObjRecord(TestcaseRecordInputStream.Create(ObjRecord.sid, recdataNeedingPadding));

            if (record.RecordSize == 34)
            {
                throw new AssertFailedException("Identified bug 45133");
            }

            Assert.AreEqual(36, record.RecordSize);

            IList subrecords = record.GetSubRecords();

            Assert.AreEqual(3, subrecords.Count);
            Assert.AreEqual(typeof(CommonObjectDataSubRecord), subrecords[0].GetType());
            Assert.AreEqual(typeof(GroupMarkerSubRecord), subrecords[1].GetType());
            Assert.AreEqual(typeof(EndSubRecord), subrecords[2].GetType());
        }