KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jxl > biff > drawing > NoteRecord


1 /*********************************************************************
2 *
3 * Copyright (C) 2004 Andrew Khan
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 ***************************************************************************/

19
20 package jxl.biff.drawing;
21
22 import common.Logger;
23 import jxl.biff.IntegerHelper;
24 import jxl.biff.StringHelper;
25 import jxl.biff.WritableRecordData;
26 import jxl.biff.Type;
27 import jxl.read.biff.Record;
28
29 /**
30  * A Note (TXO) record which contains the information for comments
31  */

32 public class NoteRecord extends WritableRecordData
33 {
34   /**
35    * The logger
36    */

37   private static Logger logger = Logger.getLogger(NoteRecord.class);
38
39   /**
40    * The raw drawing data which was read in
41    */

42   private byte[] data;
43
44   /**
45    * The row
46    */

47   private int row;
48
49   /**
50    * The column
51    */

52   private int column;
53
54   /**
55    * The object id
56    */

57   private int objectId;
58
59   /**
60    * Constructs this object from the raw data
61    *
62    * @param t the raw data
63    */

64   public NoteRecord(Record t)
65   {
66     super(t);
67     data = getRecord().getData();
68     row = IntegerHelper.getInt(data[0], data[1]);
69     column = IntegerHelper.getInt(data[2], data[3]);
70     objectId = IntegerHelper.getInt(data[6], data[7]);
71   }
72
73   /**
74    * Constructor
75    *
76    * @param d the drawing data
77    */

78   public NoteRecord(byte[] d)
79   {
80     super(Type.NOTE);
81     data = d;
82   }
83
84   /**
85    * Constructor used when writing a Note
86    */

87   public NoteRecord(int c, int r, int id)
88   {
89     super(Type.NOTE);
90     row = r;
91     column = c;
92     objectId = id;
93   }
94
95   /**
96    * Expose the protected function to the SheetImpl in this package
97    *
98    * @return the raw record data
99    */

100   public byte[] getData()
101   {
102     if (data != null)
103     {
104       return data;
105     }
106
107     String JavaDoc author = "";
108     data = new byte[8 + author.length() + 4];
109
110     // the row
111
IntegerHelper.getTwoBytes(row, data, 0);
112     
113     // the column
114
IntegerHelper.getTwoBytes(column, data, 2);
115     
116     // the object id
117
IntegerHelper.getTwoBytes(objectId, data, 6);
118
119     // the length of the string
120
IntegerHelper.getTwoBytes(author.length(), data, 8);
121     
122     // the string
123
// StringHelper.getBytes(author, data, 11);
124

125     // data[data.length-1]=(byte)0x24;
126

127     return data;
128   }
129
130   /**
131    * Accessor for the row
132    */

133   int getRow()
134   {
135     return row;
136   }
137
138   /**
139    * Accessor for the column
140    */

141   int getColumn()
142   {
143     return column;
144   }
145
146   /**
147    * Accessor for the object id
148    */

149   public int getObjectId()
150   {
151     return objectId;
152   }
153 }
154
155
156
157
158
Popular Tags