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.Vector;
25 
26 import javax.xml.stream.Location;
27 
28 import org.apache.openoffice.ooxml.framework.part.Part;
29 import org.apache.openoffice.ooxml.framework.part.parser.ParserFactory;
30 import org.apache.openoffice.ooxml.parser.ElementContext;
31 import org.apache.openoffice.ooxml.parser.Parser;
32 import org.apache.openoffice.ooxml.parser.action.ActionTrigger;
33 import org.apache.openoffice.ooxml.parser.action.IAction;
34 
35 public class SlideParser
36 {
SlideParser(final Part aPart)37     SlideParser (final Part aPart)
38     {
39         maParser = ParserFactory.getParser(
40             aPart.getContentType(),
41             aPart.getStream(),
42             new Vector<String>());
43         mnShapeCount = 0;
44 
45         maParser.GetActionManager().AddElementStartAction(
46             "p06_CT_Shape",
47             new IAction()
48             {
49                 @Override public void Run(ActionTrigger eTrigger, ElementContext aContext,
50                     String sText, Location aStartLocation, Location aEndLocation)
51                 {
52                     SlideParser.this.IncreaseShapeCount();
53                 }
54             });
55     }
56 
57 
58 
59 
ParseSlide(final int nSlideIndex)60     Slide ParseSlide (final int nSlideIndex)
61     {
62         maParser.Parse();
63         final Slide aSlide = new Slide("slide "+nSlideIndex, mnShapeCount);
64         return aSlide;
65     }
66 
67 
68 
69 
IncreaseShapeCount()70     private void IncreaseShapeCount ()
71     {
72         ++mnShapeCount;
73     }
74 
75 
76 
77 
78     private final Parser maParser;
79     private int mnShapeCount;
80 }
81