Source Code Cross Referenced for Ffn.java in  » Collaboration » poi-3.0.2-beta2 » org » apache » poi » hwpf » model » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Collaboration » poi 3.0.2 beta2 » org.apache.poi.hwpf.model 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* ====================================================================
002:         Licensed to the Apache Software Foundation (ASF) under one or more
003:         contributor license agreements.  See the NOTICE file distributed with
004:         this work for additional information regarding copyright ownership.
005:         The ASF licenses this file to You under the Apache License, Version 2.0
006:         (the "License"); you may not use this file except in compliance with
007:         the License.  You may obtain a copy of the License at
008:
009:         http://www.apache.org/licenses/LICENSE-2.0
010:
011:         Unless required by applicable law or agreed to in writing, software
012:         distributed under the License is distributed on an "AS IS" BASIS,
013:         WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         See the License for the specific language governing permissions and
015:         limitations under the License.
016:         ==================================================================== */
017:
018:        package org.apache.poi.hwpf.model;
019:
020:        import org.apache.poi.util.BitField;
021:        import org.apache.poi.util.BitFieldFactory;
022:        import org.apache.poi.util.LittleEndian;
023:        import java.util.Arrays;
024:
025:        /**
026:         * FFN - Font Family Name. FFN is a data structure that stores the names of the Main
027:         * Font and that of Alternate font as an array of characters. It has also a header
028:         * that stores info about the whole structure and the fonts
029:         *
030:         * @author Praveen Mathew
031:         */
032:        public class Ffn {
033:            private int _cbFfnM1;//total length of FFN - 1.
034:            private byte _info;
035:            private static BitField _prq = BitFieldFactory.getInstance(0x0003);// pitch request
036:            private static BitField _fTrueType = BitFieldFactory
037:                    .getInstance(0x0004);// when 1, font is a TrueType font
038:            private static BitField _ff = BitFieldFactory.getInstance(0x0070);
039:            private short _wWeight;// base weight of font
040:            private byte _chs;// character set identifier
041:            private byte _ixchSzAlt; // index into ffn.szFfn to the name of
042:            // the alternate font
043:            private byte[] _panose = new byte[10];//????
044:            private byte[] _fontSig = new byte[24];//????
045:
046:            // zero terminated string that records name of font, cuurently not
047:            // supporting Extended chars
048:            private char[] _xszFfn;
049:
050:            // extra facilitator members
051:            private int _xszFfnLength;
052:
053:            public Ffn(byte[] buf, int offset) {
054:                int offsetTmp = offset;
055:
056:                _cbFfnM1 = LittleEndian.getUnsignedByte(buf, offset);
057:                offset += LittleEndian.BYTE_SIZE;
058:                _info = buf[offset];
059:                offset += LittleEndian.BYTE_SIZE;
060:                _wWeight = LittleEndian.getShort(buf, offset);
061:                offset += LittleEndian.SHORT_SIZE;
062:                _chs = buf[offset];
063:                offset += LittleEndian.BYTE_SIZE;
064:                _ixchSzAlt = buf[offset];
065:                offset += LittleEndian.BYTE_SIZE;
066:
067:                // read panose and fs so we can write them back out.
068:                System.arraycopy(buf, offset, _panose, 0, _panose.length);
069:                offset += _panose.length;
070:                System.arraycopy(buf, offset, _fontSig, 0, _fontSig.length);
071:                offset += _fontSig.length;
072:
073:                offsetTmp = offset - offsetTmp;
074:                _xszFfnLength = (this .getSize() - offsetTmp) / 2;
075:                _xszFfn = new char[_xszFfnLength];
076:
077:                for (int i = 0; i < _xszFfnLength; i++) {
078:                    _xszFfn[i] = (char) LittleEndian.getShort(buf, offset);
079:                    offset += LittleEndian.SHORT_SIZE;
080:                }
081:
082:            }
083:
084:            public int get_cbFfnM1() {
085:                return _cbFfnM1;
086:            }
087:
088:            public short getWeight() {
089:                return _wWeight;
090:            }
091:
092:            public byte getChs() {
093:                return _chs;
094:            }
095:
096:            public byte[] getPanose() {
097:                return _panose;
098:            }
099:
100:            public byte[] getFontSig() {
101:                return _fontSig;
102:            }
103:
104:            public int getSize() {
105:                return (_cbFfnM1 + 1);
106:            }
107:
108:            public String getMainFontName() {
109:                int index = 0;
110:                for (; index < _xszFfnLength; index++) {
111:                    if (_xszFfn[index] == '\0') {
112:                        break;
113:                    }
114:                }
115:                return new String(_xszFfn, 0, index);
116:            }
117:
118:            public String getAltFontName() {
119:                int index = _ixchSzAlt;
120:                for (; index < _xszFfnLength; index++) {
121:                    if (_xszFfn[index] == '\0') {
122:                        break;
123:                    }
124:                }
125:                return new String(_xszFfn, _ixchSzAlt, index);
126:
127:            }
128:
129:            public void set_cbFfnM1(int _cbFfnM1) {
130:                this ._cbFfnM1 = _cbFfnM1;
131:            }
132:
133:            // changed protected to public
134:            public byte[] toByteArray() {
135:                int offset = 0;
136:                byte[] buf = new byte[this .getSize()];
137:
138:                buf[offset] = (byte) _cbFfnM1;
139:                offset += LittleEndian.BYTE_SIZE;
140:                buf[offset] = _info;
141:                offset += LittleEndian.BYTE_SIZE;
142:                LittleEndian.putShort(buf, offset, _wWeight);
143:                offset += LittleEndian.SHORT_SIZE;
144:                buf[offset] = _chs;
145:                offset += LittleEndian.BYTE_SIZE;
146:                buf[offset] = _ixchSzAlt;
147:                offset += LittleEndian.BYTE_SIZE;
148:
149:                System.arraycopy(_panose, 0, buf, offset, _panose.length);
150:                offset += _panose.length;
151:                System.arraycopy(_fontSig, 0, buf, offset, _fontSig.length);
152:                offset += _fontSig.length;
153:
154:                for (int i = 0; i < _xszFfn.length; i++) {
155:                    LittleEndian.putShort(buf, offset, (short) _xszFfn[i]);
156:                    offset += LittleEndian.SHORT_SIZE;
157:                }
158:
159:                return buf;
160:
161:            }
162:
163:            public boolean equals(Object o) {
164:                boolean retVal = true;
165:
166:                if (((Ffn) o).get_cbFfnM1() == _cbFfnM1) {
167:                    if (((Ffn) o)._info == _info) {
168:                        if (((Ffn) o)._wWeight == _wWeight) {
169:                            if (((Ffn) o)._chs == _chs) {
170:                                if (((Ffn) o)._ixchSzAlt == _ixchSzAlt) {
171:                                    if (Arrays.equals(((Ffn) o)._panose,
172:                                            _panose)) {
173:                                        if (Arrays.equals(((Ffn) o)._fontSig,
174:                                                _fontSig)) {
175:                                            if (!(Arrays.equals(
176:                                                    ((Ffn) o)._xszFfn, _xszFfn)))
177:                                                retVal = false;
178:                                        } else
179:                                            retVal = false;
180:                                    } else
181:                                        retVal = false;
182:                                } else
183:                                    retVal = false;
184:                            } else
185:                                retVal = false;
186:                        } else
187:                            retVal = false;
188:                    } else
189:                        retVal = false;
190:                } else
191:                    retVal = false;
192:
193:                return retVal;
194:            }
195:
196:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.