View | Details | Raw Unified | Return to bug 65678
Collapse All | Expand All

(-)a/poi-ooxml/src/test/java/org/apache/poi/xslf/usermodel/TestXSLFGraphicFrame.java (+36 lines)
Added Link Here
1
/* ====================================================================
2
   Licensed to the Apache Software Foundation (ASF) under one or more
3
   contributor license agreements.  See the NOTICE file distributed with
4
   this work for additional information regarding copyright ownership.
5
   The ASF licenses this file to You under the Apache License, Version 2.0
6
   (the "License"); you may not use this file except in compliance with
7
   the License.  You may obtain a copy of the License at
8
9
       http://www.apache.org/licenses/LICENSE-2.0
10
11
   Unless required by applicable law or agreed to in writing, software
12
   distributed under the License is distributed on an "AS IS" BASIS,
13
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
   See the License for the specific language governing permissions and
15
   limitations under the License.
16
==================================================================== */
17
package org.apache.poi.xslf.usermodel;
18
19
import org.junit.jupiter.api.Test;
20
import java.io.IOException;
21
22
import static org.junit.jupiter.api.Assertions.*;
23
import static org.apache.poi.xslf.XSLFTestDataSamples.openSampleDocument;
24
25
class TestXSLFGraphicFrame {
26
27
    @Test
28
    void testHasDiagram() throws IOException {
29
        try (XMLSlideShow ppt = openSampleDocument("SmartArt.pptx")) {
30
            XSLFSlide slide = ppt.getSlides().get(0);
31
            XSLFGraphicFrame gf = (XSLFGraphicFrame) slide.getShapes().get(0);
32
33
            assertTrue(gf.hasDiagram());
34
        }
35
    }
36
}
(-)a/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFGraphicFrame.java (-1 / +7 lines)
Lines 51-56 Link Here
51
@Beta
51
@Beta
52
public class XSLFGraphicFrame extends XSLFShape implements GraphicalFrame<XSLFShape, XSLFTextParagraph> {
52
public class XSLFGraphicFrame extends XSLFShape implements GraphicalFrame<XSLFShape, XSLFTextParagraph> {
53
    private static final String DRAWINGML_CHART_URI = "http://schemas.openxmlformats.org/drawingml/2006/chart";
53
    private static final String DRAWINGML_CHART_URI = "http://schemas.openxmlformats.org/drawingml/2006/chart";
54
    private static final String DRAWINGML_DIAGRAM_URI = "http://schemas.openxmlformats.org/drawingml/2006/diagram";
54
    private static final Logger LOG = LogManager.getLogger(XSLFGraphicFrame.class);
55
    private static final Logger LOG = LogManager.getLogger(XSLFGraphicFrame.class);
55
56
56
    /*package*/ XSLFGraphicFrame(CTGraphicalObjectFrame shape, XSLFSheet sheet){
57
    /*package*/ XSLFGraphicFrame(CTGraphicalObjectFrame shape, XSLFSheet sheet){
Lines 169-174 Link Here
169
        return uri.equals(DRAWINGML_CHART_URI);
170
        return uri.equals(DRAWINGML_CHART_URI);
170
    }
171
    }
171
172
173
    public boolean hasDiagram() {
174
        String uri = getGraphicalData().getUri();
175
        return uri.equals(DRAWINGML_DIAGRAM_URI);
176
    }
177
172
    private CTGraphicalObjectData getGraphicalData() {
178
    private CTGraphicalObjectData getGraphicalData() {
173
        return ((CTGraphicalObjectFrame)getXmlObject()).getGraphic().getGraphicData();
179
        return ((CTGraphicalObjectFrame)getXmlObject()).getGraphic().getGraphicData();
174
    }
180
    }
Lines 200-206 Link Here
200
206
201
        CTGraphicalObjectData data = getGraphicalData();
207
        CTGraphicalObjectData data = getGraphicalData();
202
        String uri = data.getUri();
208
        String uri = data.getUri();
203
        if(uri.equals("http://schemas.openxmlformats.org/drawingml/2006/diagram")){
209
        if(uri.equals(DRAWINGML_DIAGRAM_URI)){
204
            copyDiagram(data, (XSLFGraphicFrame)sh);
210
            copyDiagram(data, (XSLFGraphicFrame)sh);
205
        } if(uri.equals(DRAWINGML_CHART_URI)){
211
        } if(uri.equals(DRAWINGML_CHART_URI)){
206
            copyChart(data, (XSLFGraphicFrame)sh);
212
            copyChart(data, (XSLFGraphicFrame)sh);

Return to bug 65678