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 java.util.Map;
25 import java.util.TreeMap;
26 import java.util.Vector;
27 
28 import org.apache.openoffice.ooxml.framework.part.Part;
29 import org.apache.openoffice.ooxml.framework.part.PartName;
30 
31 public class SlideManager
32 {
SlideManager()33     SlideManager ()
34     {
35         maSlides = new Vector<>();
36         maPartNameToSlideMap = new TreeMap<>();
37     }
38 
39 
40 
AddSlide( final PartName aName, final Slide aSlide)41     public void AddSlide (
42         final PartName aName,
43         final Slide aSlide)
44     {
45         maSlides.add(aSlide);
46         maPartNameToSlideMap.put(aName, aSlide);
47     }
48 
49 
50 
51 
GetSlides()52     public Iterable<Slide> GetSlides ()
53     {
54         return maSlides;
55     }
56 
57 
58 
59 
GetSlideForPart(final Part aPart)60     public Slide GetSlideForPart (final Part aPart)
61     {
62         Slide aSlide = maPartNameToSlideMap.get(aPart.getPartName());
63         if (aSlide == null)
64         {
65             aSlide = new SlideParser(aPart).ParseSlide(maSlides.size());
66 
67             AddSlide(aPart.getPartName(), aSlide);
68         }
69         return aSlide;
70     }
71 
72 
73 
74 
75     private final Vector<Slide> maSlides;
76     private final Map<PartName,Slide> maPartNameToSlideMap;
77 }
78