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 
23 package com.sun.star.report.pentaho.parser.draw;
24 
25 import com.sun.star.report.pentaho.OfficeNamespaces;
26 import com.sun.star.report.pentaho.model.ObjectOleElement;
27 import com.sun.star.report.pentaho.parser.ElementReadHandler;
28 
29 import org.jfree.report.structure.Element;
30 
31 import org.xml.sax.Attributes;
32 import org.xml.sax.SAXException;
33 
34 /**
35  *
36  * @author Ocke Janssen
37  */
38 public class ObjectOleReadHandler extends ElementReadHandler
39 {
40 
41     private final static String RPT_CHART_CLASS_ID = "80243D39-6741-46C5-926E-069164FF87BB";
42     private final static String OOO_CHART_CLASS_ID = "12DCAE26-281F-416F-A234-C3086127382E";
43     private final ObjectOleElement element;
44 
ObjectOleReadHandler(final ObjectOleElement element)45     public ObjectOleReadHandler(final ObjectOleElement element)
46     {
47         this.element = element;
48     }
49 
50     /**
51      * Starts parsing.
52      *
53      * @param attrs the attributes.
54      * @throws org.xml.sax.SAXException if there is a parsing error.
55      */
startParsing(final Attributes attrs)56     protected void startParsing(final Attributes attrs) throws SAXException
57     {
58         super.startParsing(attrs);
59 
60         final String url = attrs.getValue(OfficeNamespaces.XLINK_NS, "href");
61         if (url != null)
62         {
63             element.setUrl(url);
64         }
65 
66         String classid = attrs.getValue(OfficeNamespaces.DRAWING_NS, "class-id");
67         if (classid != null)
68         {
69             if (classid.equalsIgnoreCase(RPT_CHART_CLASS_ID))
70             {
71                 classid = OOO_CHART_CLASS_ID;
72             }
73             element.setClassId(classid);
74         }
75     }
76 
getElement()77     public Element getElement()
78     {
79         return element;
80     }
81 }
82