1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 package org.apache.openoffice.ooxml.viewer.content; 23 24 import javax.swing.JTree; 25 import javax.swing.tree.DefaultMutableTreeNode; 26 import javax.swing.tree.DefaultTreeModel; 27 import javax.swing.tree.TreeModel; 28 29 import org.apache.openoffice.ooxml.framework.part.OOXMLPackage; 30 import org.apache.openoffice.ooxml.viewer.DetailViewManager; 31 32 /** Overview of the individual parts/streams in an OOXML file. 33 */ 34 @SuppressWarnings("serial") 35 public class ContentView 36 extends JTree 37 { ContentView( final DetailViewManager aDetailViewManager, final OOXMLPackage aPackage)38 public ContentView ( 39 final DetailViewManager aDetailViewManager, 40 final OOXMLPackage aPackage) 41 { 42 TreeModel aModel = null; 43 switch(aPackage.getOfficeDocumentPart().getContentType()) 44 { 45 case PmlDocument: 46 aModel = CreateTreeForPresentationModel(new PresentationImporter().importModel( 47 aPackage.getOfficeDocumentPart())); 48 break; 49 //case SmlDocument: 50 //case WmlDocument: 51 default: 52 break; 53 } 54 if (aModel != null) 55 setModel(aModel); 56 } 57 58 59 60 61 62 CreateTreeForPresentationModel(final PresentationModel aModel)63 private TreeModel CreateTreeForPresentationModel (final PresentationModel aModel) 64 { 65 final DefaultMutableTreeNode aRootNode = new DefaultMutableTreeNode( 66 "presentation"); 67 final DefaultTreeModel aTreeModel = new DefaultTreeModel(aRootNode); 68 69 for (final Slide aSlide : aModel.GetSlideManager().GetSlides()) 70 { 71 DefaultMutableTreeNode aNode = new DefaultMutableTreeNode( 72 aSlide.toString()); 73 aRootNode.add(aNode); 74 } 75 return aTreeModel; 76 } 77 } 78