KickJava   Java API By Example, From Geeks To Geeks.

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


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.WritableRecordData;
24 import jxl.biff.Type;
25 import jxl.biff.IntegerHelper;
26 import jxl.read.biff.Record;
27
28 /**
29  * A TextObject (TXO) record which contains the information for comments
30  */

31 public class TextObjectRecord extends WritableRecordData
32 {
33   /**
34    * The logger
35    */

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

41   private byte[] data;
42   
43   /**
44    * The text
45    */

46   private int textLength;
47
48   /**
49    * Constructor invoked when writing out this object
50    */

51   TextObjectRecord(String JavaDoc t)
52   {
53     super(Type.TXO);
54     
55     textLength = t.length();
56   }
57
58   /**
59    * Constructs this object from the raw data
60    *
61    * @param t the raw data
62    */

63   public TextObjectRecord(Record t)
64   {
65     super(t);
66     data = getRecord().getData();
67     textLength = IntegerHelper.getInt(data[10], data[11]);
68   }
69
70   /**
71    * Constructor
72    *
73    * @param d the drawing data
74    */

75   public TextObjectRecord(byte[] d)
76   {
77     super(Type.TXO);
78     data = d;
79   }
80
81   /**
82    * Expose the protected function to the SheetImpl in this package
83    *
84    * @return the raw record data
85    */

86   public byte[] getData()
87   {
88     if (data != null)
89     {
90       return data;
91     }
92
93     data = new byte[18];
94     
95     // the options
96
int options = 0;
97     options |= (0x1 << 1); // horizontal alignment - left
98
options |= (0x1 << 4); // vertical alignment - top
99
options |= (0x1 << 9); // lock text
100
IntegerHelper.getTwoBytes(options, data, 0);
101
102     // the rotation
103
// no rotation
104

105     // Length of text
106
IntegerHelper.getTwoBytes(textLength, data, 10);
107
108     // Length of formatting runs
109
IntegerHelper.getTwoBytes(0x10, data, 12);
110
111     return data;
112   }
113 }
114
115
116
117
118
Popular Tags