Source Code Cross Referenced for SlideIdListing.java in  » Collaboration » poi-3.0.2-beta2 » org » apache » poi » hslf » dev » 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.dev 
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.dev;
019:
020:        import org.apache.poi.hslf.*;
021:        import org.apache.poi.hslf.record.*;
022:        import org.apache.poi.hslf.usermodel.SlideShow;
023:
024:        import org.apache.poi.util.LittleEndian;
025:
026:        import java.io.*;
027:        import java.util.Hashtable;
028:
029:        /**
030:         * Gets all the different things that have Slide IDs (of sorts)
031:         *  in them, and displays them, so you can try to guess what they
032:         *  all mean
033:         */
034:        public class SlideIdListing {
035:            private static byte[] fileContents;
036:
037:            public static void main(String[] args) throws Exception {
038:                if (args.length < 1) {
039:                    System.err.println("Need to give a filename");
040:                    System.exit(1);
041:                }
042:
043:                // Create the slideshow object, for normal working with
044:                HSLFSlideShow hss = new HSLFSlideShow(args[0]);
045:                SlideShow ss = new SlideShow(hss);
046:
047:                // Grab the base contents
048:                fileContents = hss.getUnderlyingBytes();
049:                Record[] records = hss.getRecords();
050:                Record[] latestRecords = ss.getMostRecentCoreRecords();
051:
052:                // Grab any records that interest us
053:                Document document = null;
054:                for (int i = 0; i < latestRecords.length; i++) {
055:                    if (latestRecords[i] instanceof  Document) {
056:                        document = (Document) latestRecords[i];
057:                    }
058:                }
059:
060:                System.out.println("");
061:
062:                // Look for SlidePersistAtoms, and report what they have to
063:                //  say about possible slide IDs
064:                SlideListWithText[] slwts = document.getSlideListWithTexts();
065:                for (int i = 0; i < slwts.length; i++) {
066:                    Record[] cr = slwts[i].getChildRecords();
067:                    for (int j = 0; j < cr.length; j++) {
068:                        if (cr[j] instanceof  SlidePersistAtom) {
069:                            SlidePersistAtom spa = (SlidePersistAtom) cr[j];
070:                            System.out
071:                                    .println("SlidePersistAtom knows about slide:");
072:                            System.out.println("\t" + spa.getRefID());
073:                            System.out.println("\t" + spa.getSlideIdentifier());
074:                        }
075:                    }
076:                }
077:
078:                System.out.println("");
079:
080:                // Look for latest core records that are slides or notes
081:                for (int i = 0; i < latestRecords.length; i++) {
082:                    if (latestRecords[i] instanceof  Slide) {
083:                        Slide s = (Slide) latestRecords[i];
084:                        SlideAtom sa = s.getSlideAtom();
085:                        System.out
086:                                .println("Found the latest version of a slide record:");
087:                        System.out.println("\tCore ID is " + s.getSheetId());
088:                        System.out.println("\t(Core Records count is " + i
089:                                + ")");
090:                        System.out.println("\tDisk Position is "
091:                                + s.getLastOnDiskOffset());
092:                        System.out
093:                                .println("\tMaster ID is " + sa.getMasterID());
094:                        System.out.println("\tNotes ID is " + sa.getNotesID());
095:                    }
096:                }
097:                System.out.println("");
098:                for (int i = 0; i < latestRecords.length; i++) {
099:                    if (latestRecords[i] instanceof  Notes) {
100:                        Notes n = (Notes) latestRecords[i];
101:                        NotesAtom na = n.getNotesAtom();
102:                        System.out
103:                                .println("Found the latest version of a notes record:");
104:                        System.out.println("\tCore ID is " + n.getSheetId());
105:                        System.out.println("\t(Core Records count is " + i
106:                                + ")");
107:                        System.out.println("\tDisk Position is "
108:                                + n.getLastOnDiskOffset());
109:                        System.out.println("\tMatching slide is "
110:                                + na.getSlideID());
111:                    }
112:                }
113:
114:                System.out.println("");
115:
116:                // Find any persist ones first
117:                int pos = 0;
118:                for (int i = 0; i < records.length; i++) {
119:                    Record r = records[i];
120:
121:                    if (r.getRecordType() == 6001l) {
122:                        // PersistPtrFullBlock
123:                        System.out.println("Found PersistPtrFullBlock at "
124:                                + pos + " (" + Integer.toHexString(pos) + ")");
125:                    }
126:                    if (r.getRecordType() == 6002l) {
127:                        // PersistPtrIncrementalBlock
128:                        System.out
129:                                .println("Found PersistPtrIncrementalBlock at "
130:                                        + pos + " (" + Integer.toHexString(pos)
131:                                        + ")");
132:                        PersistPtrHolder pph = (PersistPtrHolder) r;
133:
134:                        // Check the sheet offsets
135:                        int[] sheetIDs = pph.getKnownSlideIDs();
136:                        Hashtable sheetOffsets = pph.getSlideLocationsLookup();
137:                        for (int j = 0; j < sheetIDs.length; j++) {
138:                            Integer id = new Integer(sheetIDs[j]);
139:                            Integer offset = (Integer) sheetOffsets.get(id);
140:
141:                            System.out.println("  Knows about sheet " + id);
142:                            System.out.println("    That sheet lives at "
143:                                    + offset);
144:
145:                            Record atPos = findRecordAtPos(offset.intValue());
146:                            System.out
147:                                    .println("    The record at that pos is of type "
148:                                            + atPos.getRecordType());
149:                            System.out
150:                                    .println("    The record at that pos has class "
151:                                            + atPos.getClass().getName());
152:
153:                            if (!(atPos instanceof  PositionDependentRecord)) {
154:                                System.out
155:                                        .println("    ** The record class isn't position aware! **");
156:                            }
157:                        }
158:                    }
159:
160:                    // Increase the position by the on disk size
161:                    ByteArrayOutputStream baos = new ByteArrayOutputStream();
162:                    r.writeOut(baos);
163:                    pos += baos.size();
164:                }
165:
166:                System.out.println("");
167:            }
168:
169:            // Finds the record at a given position
170:            public static Record findRecordAtPos(int pos) {
171:                long type = LittleEndian.getUShort(fileContents, pos + 2);
172:                long rlen = LittleEndian.getUInt(fileContents, pos + 4);
173:
174:                Record r = Record.createRecordForType(type, fileContents, pos,
175:                        (int) rlen + 8);
176:
177:                return r;
178:            }
179:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.