예제 #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;
            List <SubRecord> records = obj.SubRecords;
            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);
        }
예제 #2
0
        public NewRecordViewModel(DayViewModel vm, NoteRecord record = null)
        {
            DayViewModel = vm;

            if (record != null)
            {
                NoteTime = record.NoteDate.TimeOfDay;
                Note     = record.Note;

                if (record.NotifyDate.HasValue)
                {
                    NotifyTime = record.NotifyDate.Value.TimeOfDay;
                    IsNotifyOn = true;
                }

                if (record.RepeatCode != RepeatInfo.NoRepeatCode)
                {
                    RepeatIndex = record.RepeatCode;
                    IsRepeatOn  = true;
                }

                newRecord = record;
            }

            AddRecordCommand = new Command(AddRecord);
        }
예제 #3
0
        public async Task <NoteRecord> UpdateAsync(NoteRecord note)
        {
            try
            {
                using (var db = GetDbContext())
                {
                    var existing = await db.Notes.FindAsync(note.Id).ConfigureAwait(false);

                    if (existing == null)
                    {
                        return(null);
                    }
                    db.Configuration.AutoDetectChangesEnabled = true;
                    db.Entry(existing).CurrentValues.SetValues(note);

                    await db.SaveChangesAsync().ConfigureAwait(false);

                    return(existing);
                }
            }
            catch (Exception ex)
            {
                _logger.LogError($"Failed whilst creating note {note.Id}", ex);
                throw;
            }
        }
예제 #4
0
        private NoteRecord CreateNoteRecord()
        {
            NoteRecord note = new NoteRecord();

            note.Flags  = (NoteRecord.NOTE_HIDDEN);
            note.Author = ("");
            return(note);
        }
예제 #5
0
 public NoteCRVM cast2NoteCRVM(NoteRecord note2BCasted)
 {
     return(new NoteCRVM
     {
         UserName = note2BCasted.UserName,
         Note = note2BCasted.Note
     });
 }
예제 #6
0
        private static void WriteOneNote(StreamWriter file, NoteRecord noteRecord)
        {
            //file.WriteLine("0 @{0}@ NOTE", noteRecord.Ident);
            var tag = string.Format("@{0}@ NOTE", noteRecord.Ident);

            WriteCommon.writeExtended(file, 0, tag, noteRecord.Text);

            WriteCommon.writeRecordTrailer(file, noteRecord, 1);
        }
예제 #7
0
        public override bool Equals(Object obj)
        {
            if (!(obj is HSSFComment))
            {
                return(false);
            }
            HSSFComment other = (HSSFComment)obj;

            return(NoteRecord.Equals(other.NoteRecord));
        }
예제 #8
0
        /// <summary>
        /// Creates the low level NoteRecord
        /// which holds the comment attributes.
        /// </summary>
        /// <param name="shape">The shape.</param>
        /// <param name="shapeId">The shape id.</param>
        /// <returns></returns>
        private NoteRecord CreateNoteRecord(HSSFComment shape, int shapeId)
        {
            NoteRecord note = new NoteRecord();

            note.Column  = shape.Column;
            note.Row     = shape.Row;
            note.Flags   = (shape.Visible ? NoteRecord.NOTE_VISIBLE : NoteRecord.NOTE_HIDDEN);
            note.ShapeId = shapeId;
            note.Author  = (shape.Author == null ? "" : shape.Author);
            return(note);
        }
예제 #9
0
        internal override HSSFShape CloneShape()
        {
            TextObjectRecord      txo         = (TextObjectRecord)GetTextObjectRecord().CloneViaReserialise();
            EscherContainerRecord spContainer = new EscherContainerRecord();

            byte[] inSp = GetEscherContainer().Serialize();
            spContainer.FillFields(inSp, 0, new DefaultEscherRecordFactory());
            ObjRecord  obj  = (ObjRecord)GetObjRecord().CloneViaReserialise();
            NoteRecord note = (NoteRecord)NoteRecord.CloneViaReserialise();

            return(new HSSFComment(spContainer, obj, txo, note));
        }
예제 #10
0
        public void TestRead()
        {
            NoteRecord record = new NoteRecord(TestcaseRecordInputStream.Create(NoteRecord.sid, data));

            Assert.AreEqual(NoteRecord.sid, record.Sid);

            Assert.AreEqual(6, record.Row);
            Assert.AreEqual(1, record.Column);
            Assert.AreEqual(NoteRecord.NOTE_VISIBLE, record.Flags);
            Assert.AreEqual(1026, record.ShapeId);
            Assert.AreEqual("Apache Software Foundation", record.Author);
        }
예제 #11
0
        public void TestWrite()
        {
            NoteRecord record = new NoteRecord();

            Assert.AreEqual(NoteRecord.sid, record.Sid);

            record.Row     = ((short)6);
            record.Column  = ((short)1);
            record.Flags   = (NoteRecord.NOTE_VISIBLE);
            record.ShapeId = ((short)1026);
            record.Author  = ("Apache Software Foundation");

            byte[] ser = record.Serialize();
            TestcaseRecordInputStream.ConfirmRecordEncoding(NoteRecord.sid, testData, ser);
        }
예제 #12
0
        public void TestUnicodeAuthor()
        {
            // This sample data was created by setting the 'user name' field in the 'Personalize'
            // section of Excel's options to \u30A2\u30D1\u30C3\u30C1\u65CF, and then
            // creating a cell comment.
            byte[] data = HexRead.ReadFromString("01 00 01 00 00 00 03 00 " +
                                                 "05 00 01 " +                      // len=5, 16bit
                                                 "A2 30 D1 30 C3 30 C1 30 CF 65 " + // character data
                                                 "00 "                              // padding byte
                                                 );
            RecordInputStream in1 = TestcaseRecordInputStream.Create(NoteRecord.sid, data);
            NoteRecord        nr  = new NoteRecord(in1);

            if ("\u00A2\u0030\u00D1\u0030\u00C3".Equals(nr.Author))
            {
                throw new AssertionException("Identified bug in reading note with unicode author");
            }
            Assert.AreEqual("\u30A2\u30D1\u30C3\u30C1\u65CF", nr.Author);
            Assert.IsTrue(nr.AuthorIsMultibyte);

            byte[] ser = nr.Serialize();
            TestcaseRecordInputStream.ConfirmRecordEncoding(NoteRecord.sid, data, ser);

            // Re-check
            in1 = TestcaseRecordInputStream.Create(ser);
            nr  = new NoteRecord(in1);
            Assert.AreEqual("\u30A2\u30D1\u30C3\u30C1\u65CF", nr.Author);
            Assert.IsTrue(nr.AuthorIsMultibyte);


            // Change to a non unicode author, will stop being unicode
            nr.Author = ("Simple");
            ser       = nr.Serialize();
            in1       = TestcaseRecordInputStream.Create(ser);
            nr        = new NoteRecord(in1);

            Assert.AreEqual("Simple", nr.Author);
            Assert.IsFalse(nr.AuthorIsMultibyte);

            // Now set it back again
            nr.Author = ("Unicode\u1234");
            ser       = nr.Serialize();
            in1       = TestcaseRecordInputStream.Create(ser);
            nr        = new NoteRecord(in1);

            Assert.AreEqual("Unicode\u1234", nr.Author);
            Assert.IsTrue(nr.AuthorIsMultibyte);
        }
예제 #13
0
        /// <summary>
        /// Construct a new comment with the given parent and anchor.
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="anchor">defines position of this anchor in the sheet</param>
        public HSSFComment(HSSFShape parent, HSSFAnchor anchor)
            : base(parent, anchor)
        {
            _note = CreateNoteRecord();

            //default color for comments
            this.FillColor = 0x08000050;

            //by default comments are hidden
            Visible = false;

            Author = "";
            CommonObjectDataSubRecord cod = (CommonObjectDataSubRecord)GetObjRecord().SubRecords[0];

            cod.ObjectType = CommonObjectType.Comment;
        }
예제 #14
0
 public async Task CreateAsync(NoteRecord note)
 {
     try
     {
         using (var db = GetDbContext())
         {
             db.Notes.Add(note);
             await db.SaveChangesAsync().ConfigureAwait(false);
         }
     }
     catch (Exception ex)
     {
         _logger.LogError($"Failed whilst creating note", ex);
         throw;
     }
 }
예제 #15
0
        public async Task <IHttpActionResult> PostAsync(NoteRecord note)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    await _noteProvider.CreateAsync(note);

                    return(Created($"{Request.RequestUri}/{note.Id}", note));
                }

                return(BadRequest(ModelState));
            }
            catch (Exception e)
            {
                _logger.LogError("Error when posting note", e);
                return(InternalServerError(e));
            }
        }
예제 #16
0
        public void TestWrite()
        {
            NoteRecord record = new NoteRecord();

            Assert.AreEqual(NoteRecord.sid, record.Sid);

            record.Row     = ((short)6);
            record.Column  = ((short)1);
            record.Flags   = (NoteRecord.NOTE_VISIBLE);
            record.ShapeId = ((short)1026);
            record.Author  = ("Apache Software Foundation");

            byte[] ser = record.Serialize();
            Assert.AreEqual(ser.Length - 4, data.Length);

            byte[] recdata = new byte[ser.Length - 4];
            System.Array.Copy(ser, 4, recdata, 0, recdata.Length);
            Assert.IsTrue(NPOI.Util.Arrays.Equals(data, recdata));
        }
예제 #17
0
        public void TestClone()
        {
            NoteRecord record = new NoteRecord();

            record.Row     = ((short)1);
            record.Column  = ((short)2);
            record.Flags   = (NoteRecord.NOTE_VISIBLE);
            record.ShapeId = ((short)1026);
            record.Author  = ("Apache Software Foundation");

            NoteRecord cloned = (NoteRecord)record.Clone();

            Assert.AreEqual(record.Row, cloned.Row);
            Assert.AreEqual(record.Column, cloned.Column);
            Assert.AreEqual(record.Flags, cloned.Flags);
            Assert.AreEqual(record.ShapeId, cloned.ShapeId);
            Assert.AreEqual(record.Author, cloned.Author);

            //finally check that the Serialized data is1 the same
            byte[] src = record.Serialize();
            byte[] cln = cloned.Serialize();
            Assert.IsTrue(NPOI.Util.Arrays.Equals(src, cln));
        }
예제 #18
0
        public async Task <IHttpActionResult> PutAsync(NoteRecord note)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var updated = await _noteProvider.UpdateAsync(note);

                    if (updated != null)
                    {
                        return(Ok(updated));
                    }

                    return(NotFound());
                }

                return(BadRequest(ModelState));
            }
            catch (Exception e)
            {
                _logger.LogError("Error when putting note", e);
                return(InternalServerError(e));
            }
        }
예제 #19
0
        /// <summary>
        /// Process an HSSF Record. Called when a record occurs in an HSSF file.
        /// </summary>
        /// <param name="record"></param>
        public void ProcessRecord(Record record)
        {
            int thisRow;
            int thisColumn;

            CellValueRecordInterface[] expandedRecords = null;

            if (record is CellValueRecordInterface)
            {
                CellValueRecordInterface valueRec = (CellValueRecordInterface)record;
                thisRow    = valueRec.Row;
                thisColumn = valueRec.Column;
            }
            else
            {
                thisRow    = -1;
                thisColumn = -1;

                switch (record.Sid)
                {
                // the BOFRecord can represent either the beginning of a sheet or the workbook
                case BOFRecord.sid:
                    BOFRecord bof = (BOFRecord)record;
                    if (bof.Type == BOFRecord.TYPE_WORKBOOK || bof.Type == BOFRecord.TYPE_WORKSHEET)
                    {
                        // Reset the row and column counts - new workbook / worksheet
                        ResetCounts();
                    }
                    break;

                case RowRecord.sid:
                    RowRecord rowrec = (RowRecord)record;
                    //Console.WriteLine("Row " + rowrec.RowNumber + " found, first column at "
                    //        + rowrec.GetFirstCol() + " last column at " + rowrec.GetLastCol());

                    // If there's a jump in rows, fire off missing row records
                    if (lastRowRow + 1 < rowrec.RowNumber)
                    {
                        for (int i = (lastRowRow + 1); i < rowrec.RowNumber; i++)
                        {
                            MissingRowDummyRecord dr = new MissingRowDummyRecord(i);
                            childListener.ProcessRecord(dr);
                        }
                    }

                    // Record this as the last row we saw
                    lastRowRow = rowrec.RowNumber;
                    break;

                case SharedFormulaRecord.sid:
                    // SharedFormulaRecord occurs after the first FormulaRecord of the cell range.
                    // There are probably (but not always) more cell records after this
                    // - so don't fire off the LastCellOfRowDummyRecord yet
                    childListener.ProcessRecord(record);
                    return;

                case MulBlankRecord.sid:
                    // These appear in the middle of the cell records, to
                    //  specify that the next bunch are empty but styled
                    // Expand this out into multiple blank cells
                    MulBlankRecord mbr = (MulBlankRecord)record;
                    expandedRecords = RecordFactory.ConvertBlankRecords(mbr);
                    break;

                case MulRKRecord.sid:
                    // This is multiple consecutive number cells in one record
                    // Exand this out into multiple regular number cells
                    MulRKRecord mrk = (MulRKRecord)record;
                    expandedRecords = RecordFactory.ConvertRKRecords(mrk);
                    break;

                case NoteRecord.sid:
                    NoteRecord nrec = (NoteRecord)record;
                    thisRow    = nrec.Row;
                    thisColumn = nrec.Column;
                    break;

                default:
                    //Console.WriteLine(record.GetClass());
                    break;
                }
            }

            // First part of expanded record handling
            if (expandedRecords != null && expandedRecords.Length > 0)
            {
                thisRow    = expandedRecords[0].Row;
                thisColumn = expandedRecords[0].Column;
            }

            // If we're on cells, and this cell isn't in the same
            //  row as the last one, then fire the
            //  dummy end-of-row records
            if (thisRow != lastCellRow && lastCellRow > -1)
            {
                for (int i = lastCellRow; i < thisRow; i++)
                {
                    int cols = -1;
                    if (i == lastCellRow)
                    {
                        cols = lastCellColumn;
                    }
                    childListener.ProcessRecord(new LastCellOfRowDummyRecord(i, cols));
                }
            }

            // If we've just finished with the cells, then fire the
            // final dummy end-of-row record
            if (lastCellRow != -1 && lastCellColumn != -1 && thisRow == -1)
            {
                childListener.ProcessRecord(new LastCellOfRowDummyRecord(lastCellRow, lastCellColumn));

                lastCellRow    = -1;
                lastCellColumn = -1;
            }

            // If we've moved onto a new row, the ensure we re-set
            //  the column counter
            if (thisRow != lastCellRow)
            {
                lastCellColumn = -1;
            }

            // If there's a gap in the cells, then fire
            //  the dummy cell records
            if (lastCellColumn != thisColumn - 1)
            {
                for (int i = lastCellColumn + 1; i < thisColumn; i++)
                {
                    childListener.ProcessRecord(new MissingCellDummyRecord(thisRow, i));
                }
            }

            // Next part of expanded record handling
            if (expandedRecords != null && expandedRecords.Length > 0)
            {
                thisColumn = expandedRecords[expandedRecords.Length - 1].Column;
            }


            // Update cell and row counts as needed
            if (thisColumn != -1)
            {
                lastCellColumn = thisColumn;
                lastCellRow    = thisRow;
            }

            // Pass along the record(s)
            if (expandedRecords != null && expandedRecords.Length > 0)
            {
                foreach (CellValueRecordInterface r in expandedRecords)
                {
                    childListener.ProcessRecord((Record)r);
                }
            }
            else
            {
                childListener.ProcessRecord(record);
            }
        }
예제 #20
0
        public void TestCreateAggregate()
        {
            string msoDrawingRecord1 =
                "0F 00 02 F0 20 01 00 00 10 00 08 F0 08 00 00 00 \n" +
                "03 00 00 00 02 04 00 00 0F 00 03 F0 08 01 00 00 \n" +
                "0F 00 04 F0 28 00 00 00 01 00 09 F0 10 00 00 00 \n" +
                "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 \n" +
                "02 00 0A F0 08 00 00 00 00 04 00 00 05 00 00 00 \n" +
                "0F 00 04 F0 64 00 00 00 42 01 0A F0 08 00 00 00 \n" +
                "01 04 00 00 00 0A 00 00 73 00 0B F0 2A 00 00 00 \n" +
                "BF 00 08 00 08 00 44 01 04 00 00 00 7F 01 00 00 \n" +
                "01 00 BF 01 00 00 11 00 C0 01 40 00 00 08 FF 01 \n" +
                "10 00 10 00 BF 03 00 00 08 00 00 00 10 F0 12 00 \n" +
                "00 00 00 00 01 00 54 00 05 00 45 00 01 00 88 03 \n" +
                "05 00 94 00 00 00 11 F0 00 00 00 00";

            string msoDrawingRecord2 =
                "0F 00 04 F0 64 00 00 00 42 01 0A F0 08 00 00 00 " +
                "02 04 00 00 80 0A 00 00 73 00 0B F0 2A 00 00 00 " +
                "BF 00 08 00 08 00 44 01 04 00 00 00 7F 01 00 00 " +
                "01 00 BF 01 00 00 11 00 C0 01 40 00 00 08 FF 01 " +
                "10 00 10 00 BF 03 00 00 08 00 00 00 10 F0 12 00 " +
                "00 00 00 00 01 00 8D 03 05 00 E4 00 03 00 4D 03 " +
                "0B 00 0C 00 00 00 11 F0 00 00 00 00";

            DrawingRecord d1 = new DrawingRecord();

            d1.Data = HexRead.ReadFromString(msoDrawingRecord1);

            ObjRecord r1 = new ObjRecord();

            DrawingRecord d2 = new DrawingRecord();

            d2.Data = (HexRead.ReadFromString(msoDrawingRecord2));

            TextObjectRecord r2 = new TextObjectRecord();

            r2.Str = (new HSSFRichTextString("Aggregated"));
            NoteRecord n2 = new NoteRecord();

            List <RecordBase> recordStream = new List <RecordBase>();

            recordStream.Add(InternalSheet.CreateBOF());
            recordStream.Add(d1);
            recordStream.Add(r1);
            recordStream.Add(CreateWindow2Record());
            recordStream.Add(EOFRecord.instance);

            ConfirmAggregatedRecords(recordStream);


            recordStream = new List <RecordBase>();
            recordStream.Add(InternalSheet.CreateBOF());
            recordStream.Add(d1);
            recordStream.Add(r1);
            recordStream.Add(d2);
            recordStream.Add(r2);
            recordStream.Add(CreateWindow2Record());
            recordStream.Add(EOFRecord.instance);

            ConfirmAggregatedRecords(recordStream);

            recordStream = new List <RecordBase>();
            recordStream.Add(InternalSheet.CreateBOF());
            recordStream.Add(d1);
            recordStream.Add(r1);
            recordStream.Add(d2);
            recordStream.Add(r2);
            recordStream.Add(n2);
            recordStream.Add(CreateWindow2Record());
            recordStream.Add(EOFRecord.instance);

            ConfirmAggregatedRecords(recordStream);
        }
예제 #21
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HSSFComment"/> class.
 /// </summary>
 /// <param name="note">The note.</param>
 /// <param name="txo">The txo.</param>
 public HSSFComment(NoteRecord note, TextObjectRecord txo) : this((HSSFShape)null, (HSSFAnchor)null)
 {
     this.txo  = txo;
     this.note = note;
 }
예제 #22
0
 public NoteRecord CreateNoteRecord(NoteRecord newNoteRecord)
 {
     return(_repo.CreateNoteRecord(newNoteRecord));
 }
예제 #23
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HSSFComment"/> class.
 /// </summary>
 /// <param name="note">The note.</param>
 /// <param name="txo">The txo.</param>
 public HSSFComment(NoteRecord note, TextObjectRecord txo)
     : this((HSSFShape)null, new HSSFClientAnchor())
 {
     this._note = note;
 }
예제 #24
0
        public void ResultEqualsToNonExistingAbstractShape()
        {
            HSSFWorkbook  wb        = new HSSFWorkbook();
            HSSFSheet     sh        = wb.CreateSheet() as HSSFSheet;
            HSSFPatriarch patriarch = sh.CreateDrawingPatriarch() as HSSFPatriarch;

            HSSFComment comment = patriarch.CreateCellComment(new HSSFClientAnchor()) as HSSFComment;
            HSSFRow     row     = sh.CreateRow(0) as HSSFRow;
            HSSFCell    cell    = row.CreateCell(0) as HSSFCell;

            cell.CellComment = (comment);

            Assert.AreEqual(comment.GetEscherContainer().ChildRecords.Count, 5);

            //sp record
            byte[] expected = TestDrawingAggregate.decompress("H4sIAAAAAAAAAFvEw/WBg4GBgZEFSHAxMAAA9gX7nhAAAAA=");
            byte[] actual   = comment.GetEscherContainer().GetChild(0).Serialize();

            Assert.AreEqual(expected.Length, actual.Length);
            Assert.IsTrue(Arrays.Equals(expected, actual));

            expected = TestDrawingAggregate.decompress("H4sIAAAAAAAAAGNgEPggxIANAABK4+laGgAAAA==");
            actual   = comment.GetEscherContainer().GetChild(2).Serialize();

            Assert.AreEqual(expected.Length, actual.Length);
            Assert.IsTrue(Arrays.Equals(expected, actual));

            expected = TestDrawingAggregate.decompress("H4sIAAAAAAAAAGNgEPzAAAQACl6c5QgAAAA=");
            actual   = comment.GetEscherContainer().GetChild(3).Serialize();

            Assert.AreEqual(expected.Length, actual.Length);
            Assert.IsTrue(Arrays.Equals(expected, actual));

            expected = TestDrawingAggregate.decompress("H4sIAAAAAAAAAGNg4P3AAAQA6pyIkQgAAAA=");
            actual   = comment.GetEscherContainer().GetChild(4).Serialize();

            Assert.AreEqual(expected.Length, actual.Length);
            Assert.IsTrue(Arrays.Equals(expected, actual));

            ObjRecord obj = comment.GetObjRecord();

            expected = TestDrawingAggregate.decompress("H4sIAAAAAAAAAItlMGEQZRBikGRgZBF0YEACvAxiDLgBAJZsuoU4AAAA");
            actual   = obj.Serialize();

            Assert.AreEqual(expected.Length, actual.Length);
            //assertArrayEquals(expected, actual);

            TextObjectRecord tor = comment.GetTextObjectRecord();

            expected = TestDrawingAggregate.decompress("H4sIAAAAAAAAANvGKMQgxMSABgBGi8T+FgAAAA==");
            actual   = tor.Serialize();

            Assert.AreEqual(expected.Length, actual.Length);
            Assert.IsTrue(Arrays.Equals(expected, actual));

            NoteRecord note = comment.NoteRecord;

            expected = TestDrawingAggregate.decompress("H4sIAAAAAAAAAJNh4GGAAEYWEAkAS0KXuRAAAAA=");
            actual   = note.Serialize();

            Assert.AreEqual(expected.Length, actual.Length);
            Assert.IsTrue(Arrays.Equals(expected, actual));

            wb.Close();
        }
예제 #25
0
 //private TextObjectRecord txo = null;
 public HSSFComment(EscherContainerRecord spContainer, ObjRecord objRecord, TextObjectRecord textObjectRecord, NoteRecord _note)
     : base(spContainer, objRecord, textObjectRecord)
 {
     this._note = _note;
 }
예제 #26
0
파일: Recorder.cs 프로젝트: bknie1/Compose
    //--------------------------------------------------------------------------
    /// <summary>
    /// Adds the note to our recording.
    /// </summary>
    /// <param name="noteIndex">Note index.</param>
    /// <param name="time">Time played.</param>
    public void addNote(int noteIndex, float time)
    {
        NoteRecord nrm = new NoteRecord(noteIndex, time);

        recording.Add(nrm);
    }
예제 #27
0
            /// <summary>
            /// Process an HSSF Record. Called when a record occurs in an HSSF file.
            /// </summary>
            /// <param name="record"></param>
            public void ProcessRecord(Record record)
            {
                String thisText = null;
                int    thisRow  = -1;

                switch (record.Sid)
                {
                case BoundSheetRecord.sid:
                    BoundSheetRecord sr = (BoundSheetRecord)record;
                    sheetNames.Add(sr.Sheetname);
                    break;

                case BOFRecord.sid:
                    BOFRecord bof = (BOFRecord)record;
                    if (bof.Type == BOFRecordType.Worksheet)
                    {
                        sheetNum++;
                        rowNum = -1;

                        if (includeSheetNames)
                        {
                            if (text.Length > 0)
                            {
                                text.Append("\n");
                            }
                            text.Append(sheetNames[sheetNum]);
                        }
                    }
                    break;

                case SSTRecord.sid:
                    sstRecord = (SSTRecord)record;
                    break;

                case FormulaRecord.sid:
                    FormulaRecord frec = (FormulaRecord)record;
                    thisRow = frec.Row;

                    if (formulasNotResults)
                    {
                        thisText = HSSFFormulaParser.ToFormulaString((HSSFWorkbook)null, frec.ParsedExpression);
                    }
                    else
                    {
                        if (frec.HasCachedResultString)
                        {
                            // Formula result is a string
                            // This is stored in the next record
                            outputNextStringValue = true;
                            nextRow = frec.Row;
                        }
                        else
                        {
                            thisText = FormatNumberDateCell(frec, frec.Value);
                        }
                    }
                    break;

                case StringRecord.sid:
                    if (outputNextStringValue)
                    {
                        // String for formula
                        StringRecord srec = (StringRecord)record;
                        thisText = srec.String;
                        thisRow  = nextRow;
                        outputNextStringValue = false;
                    }
                    break;

                case LabelRecord.sid:
                    LabelRecord lrec = (LabelRecord)record;
                    thisRow  = lrec.Row;
                    thisText = lrec.Value;
                    break;

                case LabelSSTRecord.sid:
                    LabelSSTRecord lsrec = (LabelSSTRecord)record;
                    thisRow = lsrec.Row;
                    if (sstRecord == null)
                    {
                        throw new Exception("No SST record found");
                    }
                    thisText = sstRecord.GetString(lsrec.SSTIndex).ToString();
                    break;

                case NoteRecord.sid:
                    NoteRecord nrec = (NoteRecord)record;
                    thisRow = nrec.Row;
                    // TODO: Find object to match nrec.GetShapeId()
                    break;

                case NumberRecord.sid:
                    NumberRecord numrec = (NumberRecord)record;
                    thisRow  = numrec.Row;
                    thisText = FormatNumberDateCell(numrec, numrec.Value);
                    break;

                default:
                    break;
                }

                if (thisText != null)
                {
                    if (thisRow != rowNum)
                    {
                        rowNum = thisRow;
                        if (text.Length > 0)
                        {
                            text.Append("\n");
                        }
                    }
                    else
                    {
                        text.Append("\t");
                    }
                    text.Append(thisText);
                }
            }
예제 #28
0
        public void TestResultEqualsToAbstractShape()
        {
            HSSFWorkbook  wb        = new HSSFWorkbook();
            HSSFSheet     sh        = wb.CreateSheet() as HSSFSheet;
            HSSFPatriarch patriarch = sh.CreateDrawingPatriarch() as HSSFPatriarch;

            HSSFComment comment = patriarch.CreateCellComment(new HSSFClientAnchor()) as HSSFComment;
            HSSFRow     row     = sh.CreateRow(0) as HSSFRow;
            HSSFCell    cell    = row.CreateCell(0) as HSSFCell;

            cell.CellComment = (comment);

            CommentShape commentShape = HSSFTestModelHelper.CreateCommentShape(1025, comment);

            Assert.AreEqual(comment.GetEscherContainer().ChildRecords.Count, 5);
            Assert.AreEqual(commentShape.SpContainer.ChildRecords.Count, 5);

            //sp record
            byte[] expected = commentShape.SpContainer.GetChild(0).Serialize();
            byte[] actual   = comment.GetEscherContainer().GetChild(0).Serialize();

            Assert.AreEqual(expected.Length, actual.Length);
            Assert.IsTrue(Arrays.Equals(expected, actual));

            expected = commentShape.SpContainer.GetChild(2).Serialize();
            actual   = comment.GetEscherContainer().GetChild(2).Serialize();

            Assert.AreEqual(expected.Length, actual.Length);
            Assert.IsTrue(Arrays.Equals(expected, actual));

            expected = commentShape.SpContainer.GetChild(3).Serialize();
            actual   = comment.GetEscherContainer().GetChild(3).Serialize();

            Assert.AreEqual(expected.Length, actual.Length);
            Assert.IsTrue(Arrays.Equals(expected, actual));

            expected = commentShape.SpContainer.GetChild(4).Serialize();
            actual   = comment.GetEscherContainer().GetChild(4).Serialize();

            Assert.AreEqual(expected.Length, actual.Length);
            Assert.IsTrue(Arrays.Equals(expected, actual));

            ObjRecord obj      = comment.GetObjRecord();
            ObjRecord objShape = commentShape.ObjRecord;

            expected = obj.Serialize();
            actual   = objShape.Serialize();

            Assert.AreEqual(expected.Length, actual.Length);
            //assertArrayEquals(expected, actual);


            TextObjectRecord tor      = comment.GetTextObjectRecord();
            TextObjectRecord torShape = commentShape.TextObjectRecord;

            expected = tor.Serialize();
            actual   = torShape.Serialize();

            Assert.AreEqual(expected.Length, actual.Length);
            Assert.IsTrue(Arrays.Equals(expected, actual));

            NoteRecord note      = comment.NoteRecord;
            NoteRecord noteShape = commentShape.NoteRecord;

            expected = note.Serialize();
            actual   = noteShape.Serialize();

            Assert.AreEqual(expected.Length, actual.Length);
            Assert.IsTrue(Arrays.Equals(expected, actual));

            wb.Close();
        }
예제 #29
0
 public NoteRecord CreateNoteRecord(NoteRecord newNoteRecord)
 {
     _context.NoteRecords.Add(newNoteRecord);
     _context.SaveChanges();
     return(newNoteRecord);
 }