Source Code Cross Referenced for Document.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 org.apache.poi.util.POILogger;
021:
022:        import java.io.IOException;
023:        import java.io.OutputStream;
024:
025:        /**
026:         * Master container for Document. There is one of these for every 
027:         *  slideshow, and it holds lots of definitions, and some summaries.
028:         *
029:         * @author Nick Burch
030:         */
031:
032:        public class Document extends PositionDependentRecordContainer {
033:            private byte[] _header;
034:            private static long _type = 1000;
035:
036:            // Links to our more interesting children
037:            private DocumentAtom documentAtom;
038:            private Environment environment;
039:            private PPDrawingGroup ppDrawing;
040:            private SlideListWithText[] slwts;
041:            private ExObjList exObjList; // Can be null
042:
043:            /**
044:             * Returns the DocumentAtom of this Document
045:             */
046:            public DocumentAtom getDocumentAtom() {
047:                return documentAtom;
048:            }
049:
050:            /**
051:             * Returns the Environment of this Notes, which lots of
052:             *  settings for the document in it
053:             */
054:            public Environment getEnvironment() {
055:                return environment;
056:            }
057:
058:            /**
059:             * Returns the PPDrawingGroup, which holds an Escher Structure
060:             *  that contains information on pictures in the slides.
061:             */
062:            public PPDrawingGroup getPPDrawingGroup() {
063:                return ppDrawing;
064:            }
065:
066:            /**
067:             * Returns the ExObjList, which holds the references to 
068:             *  external objects used in the slides. This may be null, if
069:             *  there are no external references.
070:             */
071:            public ExObjList getExObjList() {
072:                return exObjList;
073:            }
074:
075:            /**
076:             * Returns all the SlideListWithTexts that are defined for
077:             *  this Document. They hold the text, and some of the text
078:             *  properties, which are referred to by the slides.
079:             * This will normally return an array of size 2 or 3
080:             */
081:            public SlideListWithText[] getSlideListWithTexts() {
082:                return slwts;
083:            }
084:
085:            /**
086:             * Returns the SlideListWithText that deals with the
087:             *  Master Slides 
088:             */
089:            public SlideListWithText getMasterSlideListWithText() {
090:                if (slwts.length > 0) {
091:                    return slwts[0];
092:                }
093:                return null;
094:            }
095:
096:            /**
097:             * Returns the SlideListWithText that deals with the
098:             *  Slides, or null if there isn't one
099:             */
100:            public SlideListWithText getSlideSlideListWithText() {
101:                if (slwts.length > 1) {
102:                    return slwts[1];
103:                }
104:                return null;
105:            }
106:
107:            /**
108:             * Returns the SlideListWithText that deals with the
109:             *  notes, or null if there isn't one
110:             */
111:            public SlideListWithText getNotesSlideListWithText() {
112:                if (slwts.length > 2) {
113:                    return slwts[2];
114:                }
115:                return null;
116:            }
117:
118:            /** 
119:             * Set things up, and find our more interesting children
120:             */
121:            protected Document(byte[] source, int start, int len) {
122:                // Grab the header
123:                _header = new byte[8];
124:                System.arraycopy(source, start, _header, 0, 8);
125:
126:                // Find our children
127:                _children = Record.findChildRecords(source, start + 8, len - 8);
128:
129:                // Our first one should be a document atom
130:                if (!(_children[0] instanceof  DocumentAtom)) {
131:                    throw new IllegalStateException(
132:                            "The first child of a Document must be a DocumentAtom");
133:                }
134:                documentAtom = (DocumentAtom) _children[0];
135:
136:                // Find how many SlideListWithTexts we have
137:                // Also, grab the Environment and PPDrawing records
138:                //  on our way past
139:                int slwtcount = 0;
140:                for (int i = 1; i < _children.length; i++) {
141:                    if (_children[i] instanceof  SlideListWithText) {
142:                        slwtcount++;
143:                    }
144:                    if (_children[i] instanceof  Environment) {
145:                        environment = (Environment) _children[i];
146:                    }
147:                    if (_children[i] instanceof  PPDrawingGroup) {
148:                        ppDrawing = (PPDrawingGroup) _children[i];
149:                    }
150:                    if (_children[i] instanceof  ExObjList) {
151:                        exObjList = (ExObjList) _children[i];
152:                    }
153:                }
154:
155:                // You should only every have 1, 2 or 3 SLWTs
156:                //  (normally it's 2, or 3 if you have notes)
157:                // Complain if it's not
158:                if (slwtcount == 0) {
159:                    logger
160:                            .log(POILogger.WARN,
161:                                    "No SlideListWithText's found - there should normally be at least one!");
162:                }
163:                if (slwtcount > 3) {
164:                    logger
165:                            .log(
166:                                    POILogger.WARN,
167:                                    "Found "
168:                                            + slwtcount
169:                                            + " SlideListWithTexts - normally there should only be three!");
170:                }
171:
172:                // Now grab all the SLWTs
173:                slwts = new SlideListWithText[slwtcount];
174:                slwtcount = 0;
175:                for (int i = 1; i < _children.length; i++) {
176:                    if (_children[i] instanceof  SlideListWithText) {
177:                        slwts[slwtcount] = (SlideListWithText) _children[i];
178:                        slwtcount++;
179:                    }
180:                }
181:            }
182:
183:            /**
184:             * Adds a new SlideListWithText record, at the appropriate 
185:             *  point in the child records.
186:             */
187:            public void addSlideListWithText(SlideListWithText slwt) {
188:                // The new SlideListWithText should go in 
189:                //  just before the EndDocumentRecord
190:                Record endDoc = _children[_children.length - 1];
191:                if (endDoc.getRecordType() != RecordTypes.EndDocument.typeID) {
192:                    throw new IllegalStateException(
193:                            "The last child record of a Document should be EndDocument, but it was "
194:                                    + endDoc);
195:                }
196:
197:                // Add in the record
198:                addChildBefore(slwt, endDoc);
199:
200:                // Updated our cached list of SlideListWithText records
201:                int newSize = slwts.length + 1;
202:                SlideListWithText[] nl = new SlideListWithText[newSize];
203:                System.arraycopy(slwts, 0, nl, 0, slwts.length);
204:                nl[nl.length - 1] = slwt;
205:                slwts = nl;
206:            }
207:
208:            /**
209:             * We are of type 1000
210:             */
211:            public long getRecordType() {
212:                return _type;
213:            }
214:
215:            /**
216:             * Write the contents of the record back, so it can be written
217:             *  to disk
218:             */
219:            public void writeOut(OutputStream out) throws IOException {
220:                writeOut(_header[0], _header[1], _type, _children, out);
221:            }
222:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.