Source Code Cross Referenced for FontTable.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 java.io.IOException;
021:        import org.apache.poi.hwpf.model.io.HWPFFileSystem;
022:        import org.apache.poi.hwpf.model.io.HWPFOutputStream;
023:        import org.apache.poi.util.LittleEndian;
024:
025:        /**
026:         * FontTable or in MS terminology sttbfffn is a common data structure written in all
027:         * Word files. The sttbfffn is an sttbf where each string is an FFN structure instead
028:         * of pascal-style strings. An sttbf is a string Table stored in file. Thus sttbffn
029:         * is like an Sttbf with an array of FFN structures that stores the font name strings
030:         *
031:         * @author Praveen Mathew
032:         */
033:        public class FontTable {
034:            private short _stringCount;// how many strings are included in the string table
035:            private short _extraDataSz;// size in bytes of the extra data
036:
037:            // added extra facilitator members
038:            private int lcbSttbfffn;// count of bytes in sttbfffn
039:            private int fcSttbfffn;// table stream offset for sttbfffn
040:
041:            // FFN structure containing strings of font names
042:            private Ffn[] _fontNames = null;
043:
044:            public FontTable(byte[] buf, int offset, int lcbSttbfffn) {
045:                this .lcbSttbfffn = lcbSttbfffn;
046:                this .fcSttbfffn = offset;
047:
048:                _stringCount = LittleEndian.getShort(buf, offset);
049:                offset += LittleEndian.SHORT_SIZE;
050:                _extraDataSz = LittleEndian.getShort(buf, offset);
051:                offset += LittleEndian.SHORT_SIZE;
052:
053:                _fontNames = new Ffn[_stringCount]; //Ffn corresponds to a Pascal style String in STTBF.
054:
055:                for (int i = 0; i < _stringCount; i++) {
056:                    _fontNames[i] = new Ffn(buf, offset);
057:                    offset += _fontNames[i].getSize();
058:                }
059:            }
060:
061:            public short getStringCount() {
062:                return _stringCount;
063:            }
064:
065:            public short getExtraDataSz() {
066:                return _extraDataSz;
067:            }
068:
069:            public Ffn[] getFontNames() {
070:                return _fontNames;
071:            }
072:
073:            public int getSize() {
074:                return lcbSttbfffn;
075:            }
076:
077:            public String getMainFont(int chpFtc) {
078:                if (chpFtc >= _stringCount) {
079:                    System.out.println("Mismatch in chpFtc with stringCount");
080:                    return null;
081:                }
082:
083:                return _fontNames[chpFtc].getMainFontName();
084:            }
085:
086:            public String getAltFont(int chpFtc) {
087:                if (chpFtc >= _stringCount) {
088:                    System.out.println("Mismatch in chpFtc with stringCount");
089:                    return null;
090:                }
091:
092:                return _fontNames[chpFtc].getAltFontName();
093:            }
094:
095:            public void setStringCount(short stringCount) {
096:                this ._stringCount = stringCount;
097:            }
098:
099:            public void writeTo(HWPFFileSystem sys) throws IOException {
100:                HWPFOutputStream tableStream = sys.getStream("1Table");
101:
102:                byte[] buf = new byte[LittleEndian.SHORT_SIZE];
103:                LittleEndian.putShort(buf, _stringCount);
104:                tableStream.write(buf);
105:                LittleEndian.putShort(buf, _extraDataSz);
106:                tableStream.write(buf);
107:
108:                for (int i = 0; i < _fontNames.length; i++) {
109:                    tableStream.write(_fontNames[i].toByteArray());
110:                }
111:
112:            }
113:
114:            public boolean equals(Object o) {
115:                boolean retVal = true;
116:
117:                if (((FontTable) o).getStringCount() == _stringCount) {
118:                    if (((FontTable) o).getExtraDataSz() == _extraDataSz) {
119:                        Ffn[] fontNamesNew = ((FontTable) o).getFontNames();
120:                        for (int i = 0; i < _stringCount; i++) {
121:                            if (!(_fontNames[i].equals(fontNamesNew[i])))
122:                                retVal = false;
123:                        }
124:                    } else
125:                        retVal = false;
126:                } else
127:                    retVal = false;
128:
129:                return retVal;
130:            }
131:
132:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.