Source Code Cross Referenced for ExEmbed.java in  » Collaboration » poi-3.0.2-beta2 » org » apache » poi » hslf » record » 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.hslf.record 
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.hslf.record;
019:
020:        import java.io.OutputStream;
021:        import java.io.IOException;
022:
023:        import org.apache.poi.util.LittleEndian;
024:        import org.apache.poi.util.POILogger;
025:
026:        /**
027:         * This data represents an embedded object in the document.
028:         *
029:         * @author Daniel Noll
030:         */
031:        public class ExEmbed extends RecordContainer {
032:
033:            /**
034:             * Record header data.
035:             */
036:            private byte[] _header;
037:
038:            // Links to our more interesting children
039:            private ExEmbedAtom embedAtom;
040:            private ExOleObjAtom oleObjAtom;
041:            private CString menuName;
042:            private CString progId;
043:            private CString clipboardName;
044:
045:            /**
046:             * Set things up, and find our more interesting children
047:             *
048:             * @param source the source data as a byte array.
049:             * @param start the start offset into the byte array.
050:             * @param len the length of the slice in the byte array.
051:             */
052:            protected ExEmbed(byte[] source, int start, int len) {
053:                // Grab the header
054:                _header = new byte[8];
055:                System.arraycopy(source, start, _header, 0, 8);
056:
057:                // Find our children
058:                _children = Record.findChildRecords(source, start + 8, len - 8);
059:                findInterestingChildren();
060:            }
061:
062:            /**
063:             * Create a new ExEmbed, with blank fields
064:             */
065:            public ExEmbed() {
066:                _header = new byte[8];
067:                _children = new Record[5];
068:
069:                // Setup our header block
070:                _header[0] = 0x0f; // We are a container record
071:                LittleEndian.putShort(_header, 2, (short) getRecordType());
072:
073:                // Setup our child records
074:                CString cs1 = new CString();
075:                CString cs2 = new CString();
076:                CString cs3 = new CString();
077:                //        cs1.setCount(0x00);
078:                //        cs2.setCount(0x10);
079:                _children[0] = new ExEmbedAtom();
080:                _children[1] = new ExOleObjAtom();
081:                _children[2] = cs1;
082:                _children[3] = cs2;
083:                _children[4] = cs3;
084:                findInterestingChildren();
085:            }
086:
087:            /**
088:             * Go through our child records, picking out the ones that are
089:             * interesting, and saving those for use by the easy helper methods.
090:             */
091:            private void findInterestingChildren() {
092:
093:                // First child should be the ExHyperlinkAtom
094:                if (_children[0] instanceof  ExEmbedAtom) {
095:                    embedAtom = (ExEmbedAtom) _children[0];
096:                } else {
097:                    logger.log(POILogger.ERROR,
098:                            "First child record wasn't a ExEmbedAtom, was of type "
099:                                    + _children[0].getRecordType());
100:                }
101:
102:                // Second child should be the ExOleObjAtom
103:                if (_children[1] instanceof  ExOleObjAtom) {
104:                    oleObjAtom = (ExOleObjAtom) _children[1];
105:                } else {
106:                    logger.log(POILogger.ERROR,
107:                            "Second child record wasn't a ExOleObjAtom, was of type "
108:                                    + _children[1].getRecordType());
109:                }
110:
111:                for (int i = 2; i < _children.length; i++) {
112:                    if (_children[i] instanceof  CString) {
113:                        if (menuName == null)
114:                            menuName = (CString) _children[i];
115:                        else if (progId == null)
116:                            progId = (CString) _children[i];
117:                        else if (clipboardName == null)
118:                            clipboardName = (CString) _children[i];
119:                    } else {
120:                        logger.log(POILogger.ERROR,
121:                                "Record after atoms wasn't a CString, was of type "
122:                                        + _children[i].getRecordType());
123:                    }
124:                }
125:            }
126:
127:            /**
128:             * Gets the {@code ExEmbedAtom}.
129:             *
130:             * @return the {@code ExEmbedAtom}.
131:             */
132:            public ExEmbedAtom getExEmbedAtom() {
133:                return embedAtom;
134:            }
135:
136:            /**
137:             * Gets the {@code ExOleObjAtom}.
138:             *
139:             * @return the {@code ExOleObjAtom}.
140:             */
141:            public ExOleObjAtom getExOleObjAtom() {
142:                return oleObjAtom;
143:            }
144:
145:            /**
146:             * Gets the name used for menus and the Links dialog box.
147:             *
148:             * @return the name used for menus and the Links dialog box.
149:             */
150:            public String getMenuName() {
151:                return menuName == null ? null : menuName.getText();
152:            }
153:
154:            /**
155:             * Gets the OLE Programmatic Identifier.
156:             * 
157:             * @return the OLE Programmatic Identifier.
158:             */
159:            public String getProgId() {
160:                return progId == null ? null : progId.getText();
161:            }
162:
163:            /**
164:             * Gets the name that appears in the paste special dialog.
165:             *
166:             * @return the name that appears in the paste special dialog.
167:             */
168:            public String getClipboardName() {
169:                return clipboardName == null ? null : clipboardName.getText();
170:            }
171:
172:            /**
173:             * Returns the type (held as a little endian in bytes 3 and 4)
174:             * that this class handles.
175:             *
176:             * @return the record type.
177:             */
178:            public long getRecordType() {
179:                return RecordTypes.ExEmbed.typeID;
180:            }
181:
182:            /**
183:             * Have the contents printer out into an OutputStream, used when
184:             * writing a file back out to disk.
185:             *
186:             * @param out the output stream.
187:             * @throws IOException if there was an error writing to the stream.
188:             */
189:            public void writeOut(OutputStream out) throws IOException {
190:                writeOut(_header[0], _header[1], getRecordType(), _children,
191:                        out);
192:            }
193:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.