Example usage for org.apache.poi.openxml4j.opc PackageRelationship getId

List of usage examples for org.apache.poi.openxml4j.opc PackageRelationship getId

Introduction

In this page you can find the example usage for org.apache.poi.openxml4j.opc PackageRelationship getId.

Prototype

public String getId() 

Source Link

Usage

From source file:AddAudioToPptx.java

License:Apache License

static void addAudio(XMLSlideShow pptx, XSLFSlide slide1, PackagePart videoPart, XSLFPictureShape pic1,
        double seconds) throws IOException {

    // add video shape
    PackagePartName partName = videoPart.getPartName();
    PackageRelationship prsEmbed1 = slide1.getPackagePart().addRelationship(partName, TargetMode.INTERNAL,
            "http://schemas.microsoft.com/office/2007/relationships/media");
    PackageRelationship prsExec1 = slide1.getPackagePart().addRelationship(partName, TargetMode.INTERNAL,
            "http://schemas.openxmlformats.org/officeDocument/2006/relationships/audio");
    CTPicture xpic1 = (CTPicture) pic1.getXmlObject();
    CTHyperlink link1 = xpic1.getNvPicPr().getCNvPr().addNewHlinkClick();
    link1.setId("");
    link1.setAction("ppaction://media");

    // add video relation
    CTApplicationNonVisualDrawingProps nvPr = xpic1.getNvPicPr().getNvPr();
    nvPr.addNewVideoFile().setLink(prsExec1.getId());
    CTExtension ext = nvPr.addNewExtLst().addNewExt();
    // see http://msdn.microsoft.com/en-us/library/dd950140(v=office.12).aspx
    ext.setUri("{DAA4B4D4-6D71-4841-9C94-3DE7FCFB9230}");
    String p14Ns = "http://schemas.microsoft.com/office/powerpoint/2010/main";
    XmlCursor cur = ext.newCursor();/*from  www.  j ava 2s.co  m*/
    cur.toEndToken();
    cur.beginElement(new QName(p14Ns, "media", "p14"));
    cur.insertNamespace("p14", p14Ns);
    cur.insertAttributeWithValue(new QName(STRelationshipId.type.getName().getNamespaceURI(), "embed"),
            prsEmbed1.getId());
    cur.beginElement(new QName(p14Ns, "trim", "p14"));
    cur.insertAttributeWithValue("st", df_time.format(seconds * 1000.0));
    cur.dispose();

}

From source file:AddVideoToPptx.java

License:Apache License

static void addVideo(XMLSlideShow pptx, XSLFSlide slide1, PackagePart videoPart, XSLFPictureShape pic1,
        double seconds) throws IOException {

    // add video shape
    PackagePartName partName = videoPart.getPartName();
    PackageRelationship prsEmbed1 = slide1.getPackagePart().addRelationship(partName, TargetMode.INTERNAL,
            "http://schemas.microsoft.com/office/2007/relationships/media");
    PackageRelationship prsExec1 = slide1.getPackagePart().addRelationship(partName, TargetMode.INTERNAL,
            "http://schemas.openxmlformats.org/officeDocument/2006/relationships/video");
    CTPicture xpic1 = (CTPicture) pic1.getXmlObject();
    CTHyperlink link1 = xpic1.getNvPicPr().getCNvPr().addNewHlinkClick();
    link1.setId("");
    link1.setAction("ppaction://media");

    // add video relation
    CTApplicationNonVisualDrawingProps nvPr = xpic1.getNvPicPr().getNvPr();
    nvPr.addNewVideoFile().setLink(prsExec1.getId());
    CTExtension ext = nvPr.addNewExtLst().addNewExt();
    // see http://msdn.microsoft.com/en-us/library/dd950140(v=office.12).aspx
    ext.setUri("{DAA4B4D4-6D71-4841-9C94-3DE7FCFB9230}");
    String p14Ns = "http://schemas.microsoft.com/office/powerpoint/2010/main";
    XmlCursor cur = ext.newCursor();/* w w w .j a v a2 s. com*/
    cur.toEndToken();
    cur.beginElement(new QName(p14Ns, "media", "p14"));
    cur.insertNamespace("p14", p14Ns);
    cur.insertAttributeWithValue(new QName(STRelationshipId.type.getName().getNamespaceURI(), "embed"),
            prsEmbed1.getId());
    cur.beginElement(new QName(p14Ns, "trim", "p14"));
    cur.insertAttributeWithValue("st", df_time.format(seconds * 1000.0));
    cur.dispose();

}

From source file:com.hp.autonomy.frontend.reports.powerpoint.PowerPointServiceImpl.java

License:MIT License

/**
 * Internal implementation to add an image (a world map, though other image data is also fine) to a slide.
 *   Preserves the original image's aspect ratio, leaving blank space below and to the sides of the image.
 * @param slide the slide to add to.//from ww  w  .ja  va 2  s  .  c om
 * @param anchor bounding rectangle to draw onto, in PowerPoint coordinates.
 * @param picture the picture data.
 * @param markers an array of markers to draw over the map.
 * @param polygons
 * @return the picture shape object added to the slide.
 */
private static XSLFPictureShape addMap(final XSLFSlide slide, final Rectangle2D.Double anchor,
        final XSLFPictureData picture, final Marker[] markers, final MapData.Polygon[] polygons) {
    double tgtW = anchor.getWidth(), tgtH = anchor.getHeight();

    final Dimension size = picture.getImageDimension();
    final double ratio = size.getWidth() / size.getHeight();

    if (ratio > tgtW / tgtH) {
        // source image is wider than target, clip fixed width variable height
        tgtH = tgtW / ratio;
    } else {
        tgtW = tgtH * ratio;
    }

    final XSLFPictureShape canvas = slide.createPicture(picture);
    // Vertically align top, horizontally-align center
    final double offsetX = anchor.getMinX() + 0.5 * (anchor.getWidth() - tgtW), offsetY = anchor.getMinY();
    canvas.setAnchor(new Rectangle2D.Double(offsetX, offsetY, tgtW, tgtH));

    if (polygons != null) {
        for (MapData.Polygon polygon : polygons) {
            final Color color = Color.decode(polygon.getColor());
            final double[][] shapes = polygon.getPoints();
            // The ESRI spec version 1.2.1 from http://www.opengeospatial.org/standards/sfa has section 6.1.11.1,
            //    which defines polygons as follows:
            /// A Polygon is a planar Surface defined by 1 exterior boundary and 0 or more interior boundaries.
            //    Each interior boundary defines a hole in the Polygon. A Triangle is a polygon with 3 distinct,
            //    non-collinear vertices and no interior boundary.
            /// The exterior boundary LinearRing defines the top? of the surface which is the side of the surface
            //    from which the exterior boundary appears to traverse the boundary in a counter clockwise direction.
            //    The interior LinearRings will have the opposite orientation, and appear as clockwise
            //    when viewed from the top?
            // so it's even-odd winding (whereas the Path2D default is non-zero-winding).
            final Path2D.Double path = new Path2D.Double(Path2D.WIND_EVEN_ODD);

            for (final double[] points : shapes) {
                for (int ii = 0; ii < points.length; ii += 2) {
                    final double x1 = offsetX + points[ii] * tgtW;
                    final double y1 = offsetY + points[ii + 1] * tgtH;
                    if (ii == 0) {
                        path.moveTo(x1, y1);
                    } else {
                        path.lineTo(x1, y1);
                    }
                }
                path.closePath();
            }

            final XSLFFreeformShape freeform = slide.createFreeform();
            freeform.setPath(path);
            freeform.setStrokeStyle(0.5);
            // There's a 0.5 alpha transparency on the stroke, and a 0.2 alpha transparency on the polygon fill.
            freeform.setLineColor(transparentColor(color, 128));
            freeform.setFillColor(transparentColor(color, 51));

            if (StringUtils.isNotEmpty(polygon.getText())) {
                final PackageRelationship rel = freeform.getSheet().getPackagePart().addRelationship(
                        slide.getPackagePart().getPartName(), TargetMode.INTERNAL,
                        XSLFRelation.SLIDE.getRelation());
                // We create a hyperlink which links back to this slide; so we get hover-over-detail-text on the polygon
                final CTHyperlink link = ((CTShape) freeform.getXmlObject()).getNvSpPr().getCNvPr()
                        .addNewHlinkClick();
                link.setTooltip(polygon.getText());
                link.setId(rel.getId());
                link.setAction("ppaction://hlinksldjump");
            }
        }
    }

    for (Marker marker : markers) {
        final Color color = Color.decode(marker.getColor());
        final double centerX = offsetX + marker.getX() * tgtW;
        final double centerY = offsetY + marker.getY() * tgtH;

        if (marker.isCluster()) {
            final XSLFGroupShape group = slide.createGroup();
            double halfMark = 10;
            double mark = halfMark * 2;
            double innerHalfMark = 7;
            double innerMark = innerHalfMark * 2;
            // align these so the middle is the latlng position
            final Rectangle2D.Double groupAnchor = new Rectangle2D.Double(centerX - halfMark,
                    centerY - halfMark, mark, mark);

            group.setAnchor(groupAnchor);
            group.setInteriorAnchor(groupAnchor);

            final XSLFAutoShape shape = group.createAutoShape();
            shape.setShapeType(ShapeType.ELLIPSE);
            final boolean fade = marker.isFade();
            // There's a 0.3 alpha transparency (255 * 0.3 is 76) when a marker is faded out
            final int FADE_ALPHA = 76;
            shape.setFillColor(transparentColor(color, fade ? 47 : 154));
            shape.setAnchor(groupAnchor);

            final XSLFAutoShape inner = group.createAutoShape();
            inner.setFillColor(fade ? transparentColor(color, FADE_ALPHA) : color);
            inner.setLineWidth(0.1);
            inner.setLineColor(new Color((int) (color.getRed() * 0.9), (int) (color.getGreen() * 0.9),
                    (int) (color.getBlue() * 0.9), fade ? FADE_ALPHA : 255));
            inner.setShapeType(ShapeType.ELLIPSE);
            inner.setHorizontalCentered(true);
            inner.setWordWrap(false);
            inner.setVerticalAlignment(VerticalAlignment.MIDDLE);
            inner.clearText();
            final XSLFTextParagraph para = inner.addNewTextParagraph();
            para.setTextAlign(TextParagraph.TextAlign.CENTER);
            final XSLFTextRun text = para.addNewTextRun();
            text.setFontSize(6.0);
            final Color fontColor = Color.decode(StringUtils.defaultString(marker.getFontColor(), "#000000"));
            text.setFontColor(fade ? transparentColor(fontColor, FADE_ALPHA) : fontColor);
            text.setText(marker.getText());
            inner.setAnchor(new Rectangle2D.Double(centerX - innerHalfMark, centerY - innerHalfMark, innerMark,
                    innerMark));
        } else {
            final XSLFGroupShape group = slide.createGroup();

            final XSLFFreeformShape shape = group.createFreeform();
            shape.setHorizontalCentered(true);
            shape.setWordWrap(false);

            shape.setVerticalAlignment(VerticalAlignment.BOTTOM);
            shape.setLineWidth(0.5);
            shape.setLineColor(color.darker());
            shape.setFillColor(transparentColor(color, 210));

            final double halfMark = 8, mark = halfMark * 2, extension = 0.85,
                    markerHeight = (0.5 + extension) * mark, angle = Math.asin(0.5 / extension) * 180 / Math.PI;

            // Set group position
            group.setAnchor(
                    new Rectangle2D.Double(centerX - halfMark, centerY - markerHeight, mark, markerHeight));
            group.setInteriorAnchor(new Rectangle2D.Double(0, 0, mark, markerHeight));

            // Draw a semicircle and a triangle to represent the marker, pointing at the precise x,y location
            final Path2D.Double path = new Path2D.Double();
            path.moveTo(halfMark, markerHeight);
            path.append(new Arc2D.Double(0, 0, mark, mark, -angle, 180 + angle + angle, Arc2D.OPEN), true);
            path.lineTo(halfMark, markerHeight);
            shape.setPath(path);
            shape.setAnchor(new Rectangle2D.Double(0, 0, mark, markerHeight));

            final XSLFAutoShape disc = group.createAutoShape();
            disc.setShapeType(ShapeType.DONUT);
            final double discRadius = 0.25 * mark;
            final double discDiameter = 2 * discRadius;
            disc.setAnchor(new Rectangle2D.Double(halfMark - discRadius, halfMark - discRadius, discDiameter,
                    discDiameter));
            disc.setFillColor(Color.WHITE);
            disc.setLineColor(Color.WHITE);

            if (StringUtils.isNotEmpty(marker.getText())) {
                final PackageRelationship rel = shape.getSheet().getPackagePart().addRelationship(
                        slide.getPackagePart().getPartName(), TargetMode.INTERNAL,
                        XSLFRelation.SLIDE.getRelation());
                // We create a hyperlink which links back to this slide; so we get hover-over-detail-text on the marker
                // Annoyingly, you can't put a link on the group, just on the individual shapes.
                for (XSLFShape clickable : group.getShapes()) {
                    final CTHyperlink link = ((CTShape) clickable.getXmlObject()).getNvSpPr().getCNvPr()
                            .addNewHlinkClick();
                    link.setTooltip(marker.getText());
                    link.setId(rel.getId());
                    link.setAction("ppaction://hlinksldjump");
                }
            }
        }
    }

    return canvas;
}

From source file:com.vodafone.poms.ii.helpers.ExportManager.java

private static String addFile(XSSFSheet sh, String filePath, double oleId)
        throws IOException, InvalidFormatException {
    File file = new File(filePath);
    FileInputStream fin = new FileInputStream(file);
    byte[] data;/*from  w  w w .j a v a2  s .co m*/
    data = new byte[fin.available()];
    fin.read(data);
    Ole10Native ole10 = new Ole10Native(file.getAbsolutePath(), file.getAbsolutePath(), file.getAbsolutePath(),
            data);

    ByteArrayOutputStream bos = new ByteArrayOutputStream(500);
    ole10.writeOut(bos);

    POIFSFileSystem poifs = new POIFSFileSystem();
    poifs.getRoot().createDocument(Ole10Native.OLE10_NATIVE, new ByteArrayInputStream(bos.toByteArray()));

    poifs.getRoot().setStorageClsid(ClassID.OLE10_PACKAGE);

    final PackagePartName pnOLE = PackagingURIHelper
            .createPartName("/xl/embeddings/oleObject" + oleId + Math.random() + ".bin");
    final PackagePart partOLE = sh.getWorkbook().getPackage().createPart(pnOLE,
            "application/vnd.openxmlformats-officedocument.oleObject");
    PackageRelationship prOLE = sh.getPackagePart().addRelationship(pnOLE, TargetMode.INTERNAL,
            POIXMLDocument.OLE_OBJECT_REL_TYPE);
    OutputStream os = partOLE.getOutputStream();
    poifs.writeFilesystem(os);
    os.close();
    poifs.close();

    return prOLE.getId();

}

From source file:com.vodafone.poms.ii.helpers.ExportManager.java

private static String addImageToSheet(XSSFSheet sh, int imgId, int pictureType) throws InvalidFormatException {
    final PackagePartName pnIMG = PackagingURIHelper.createPartName(
            "/xl/media/image" + (imgId + 1) + (pictureType == Workbook.PICTURE_TYPE_PNG ? ".png" : ".jpeg"));
    PackageRelationship prIMG = sh.getPackagePart().addRelationship(pnIMG, TargetMode.INTERNAL,
            PackageRelationshipTypes.IMAGE_PART);
    return prIMG.getId();
}

From source file:de.kiwiwings.jasperreports.exporter.PptxShapeExporter.java

License:Open Source License

protected void setHyperlinkURL(JRCommonElement jrShape, XSLFShape hyperlinkTarget) {
    if (hyperlinkTarget == null || !(jrShape instanceof JRPrintHyperlink))
        return;/*from   ww w.j  a v a 2s.  c o  m*/

    // http://openxmldeveloper.org/discussions/formats/f/15/t/304.aspx

    JRPrintHyperlink link = (JRPrintHyperlink) jrShape;
    JRHyperlinkProducer customHandler = getHyperlinkProducer(link);
    PackageRelationship rel = null;
    String action = null;

    if (customHandler != null) {
        String href = customHandler.getHyperlink(link);
        if (href != null) {
            rel = slide.getPackagePart().addExternalRelationship(href, XSLFRelation.HYPERLINK.getRelation());
        }
    }

    switch (link.getHyperlinkTypeValue()) {
    case REFERENCE: {
        String href = link.getHyperlinkReference();
        if (href != null) {
            rel = slide.getPackagePart().addExternalRelationship(href, XSLFRelation.HYPERLINK.getRelation());
        }
        break;
    }
    case LOCAL_PAGE: {
        XSLFSheet targetSlide = slideList.get(link.getHyperlinkPage());
        rel = slide.getPackagePart().addRelationship(targetSlide.getPackagePart().getPartName(),
                TargetMode.INTERNAL, XSLFRelation.SLIDE.getRelation());
        action = "ppaction://hlinksldjump";
        break;
    }
    case REMOTE_PAGE: {
        String href = link.getHyperlinkReference();
        if (href != null) {
            rel = slide.getPackagePart().addExternalRelationship(href, XSLFRelation.HYPERLINK.getRelation());
        }
        Integer page = link.getHyperlinkPage();
        if (page != null) {
            action = "ppaction://hlinkpres?slideindex=" + page;
            if (link.getHyperlinkParameters() != null) {
                List<JRPrintHyperlinkParameter> plist = link.getHyperlinkParameters().getParameters();
                if (plist != null) {
                    for (JRPrintHyperlinkParameter p : plist) {
                        if ("slidetitle".equals(p.getName())) {
                            action += "&slidetitle=" + p.getValue().toString();
                            break;
                        }
                    }
                }
            }
        }
        break;
    }

    case NONE:
    default:
    case LOCAL_ANCHOR:
    case REMOTE_ANCHOR:
        // not implemented ... only pages (not elements) can be referenced in powerpoint
        break;
    }

    if (rel != null) {
        CTHyperlink hlink = XSLFSimpleShapeHelper.addHyperlink(hyperlinkTarget);
        if (hlink == null) {
            slide.getPackagePart().removeRelationship(rel.getId());
        } else {
            hlink.setId(rel.getId());
            if (action != null) {
                hlink.setAction(action);
            }
        }
    }
}

From source file:de.kiwiwings.jasperreports.exporter.PptxShapeExporter.java

License:Open Source License

protected void embedFonts() throws JRException, IOException {
    RepositoryUtil ru = RepositoryUtil.getInstance(jasperReportsContext);

    List<FontFamily> ferList = jasperReportsContext.getExtensions(FontFamily.class);
    if (ferList == null || ferList.size() == 0)
        return;// ww w . j  a v  a 2s.c  o  m

    FontFactory fontfac = FontFactory.getInstance();
    EOTWriter conv = new EOTWriter(true); // generate MicroTypeExpress (mtx) fonts

    CTEmbeddedFontList fontList = null;

    boolean anyFontsEmbedded = false;
    for (FontFamily ff : ferList) {
        if (!"embed".equals(ff.getExportFont(PPTX_EXPORTER_KEY))) {
            // don't export font
            continue;
        }
        anyFontsEmbedded = true;

        // "<p:font typeface=\"AllianzLogo\" pitchFamily=\"49\" charset=\"2\"/><p:regular r:id=\"rId13\"/>"
        FontFace ffTypes[] = { ff.getNormalFace(), ff.getBoldFace(), ff.getItalicFace(),
                ff.getBoldItalicFace() };

        CTEmbeddedFontListEntry fntEntry = null;

        for (int i = 0; i < 4; i++) {
            if (ffTypes[i] == null)
                continue;
            String fileRelPath = ffTypes[i].getTtf();
            String fntDataName = fileRelPath.replaceAll(".*/(.*).ttf", "$1.fntdata");
            byte fontBytes[] = ru.getBytesFromLocation(fileRelPath);

            Font fonts[] = fontfac.loadFonts(fontBytes);
            assert (fonts != null && fonts.length == 1);

            WritableFontData eotFont = conv.convert(fonts[0]);

            PackagePartName partName;
            try {
                partName = PackagingURIHelper.createPartName("/ppt/fonts/" + fntDataName);
            } catch (InvalidFormatException e) {
                throw new IOException(e);
            }
            PackagePart part = ppt.getPackage().createPart(partName, "application/x-fontdata");
            OutputStream partOs = part.getOutputStream();
            eotFont.copyTo(partOs);
            partOs.close();

            PackageRelationship prs = ppt.getPackagePart().addRelationship(partName, TargetMode.INTERNAL,
                    "http://schemas.openxmlformats.org/officeDocument/2006/relationships/font");

            if (fontList == null) {
                fontList = ppt.getCTPresentation().addNewEmbeddedFontLst();
            }
            if (fntEntry == null) {
                fntEntry = fontList.addNewEmbeddedFont();
                CTTextFont fnt = fntEntry.addNewFont();
                fnt.setTypeface(ff.getName());
                // TODO set charset / pitchFamily
            }

            CTEmbeddedFontDataId fntId = null;
            switch (i) {
            case 0:
                fntId = fntEntry.addNewRegular();
                break;
            case 1:
                fntId = fntEntry.addNewBold();
                break;
            case 2:
                fntId = fntEntry.addNewItalic();
                break;
            case 3:
                fntId = fntEntry.addNewBoldItalic();
                break;
            }

            fntId.setId(prs.getId());
        }
    }

    if (anyFontsEmbedded) {
        CTPresentation pres = ppt.getCTPresentation();
        pres.setEmbedTrueTypeFonts(true);
        pres.setSaveSubsetFonts(true);
    }
}

From source file:mj.ocraptor.extraction.tika.parser.microsoft.ooxml.AbstractOOXMLExtractor.java

License:Apache License

private void handleEmbeddedParts(ContentHandler handler) throws TikaException, IOException, SAXException {
    try {/*from   w w  w  .ja  va 2s  . c o m*/
        for (PackagePart source : getMainDocumentParts()) {
            for (PackageRelationship rel : source.getRelationships()) {

                URI sourceURI = rel.getSourceURI();
                String sourceDesc;
                if (sourceURI != null) {
                    sourceDesc = getJustFileName(sourceURI.getPath());
                    if (sourceDesc.startsWith("slide")) {
                        sourceDesc += "_";
                    } else {
                        sourceDesc = "";
                    }
                } else {
                    sourceDesc = "";
                }
                if (rel.getTargetMode() == TargetMode.INTERNAL) {
                    PackagePart target;

                    try {
                        target = source.getRelatedPart(rel);
                    } catch (IllegalArgumentException ex) {
                        continue;
                    }

                    String type = rel.getRelationshipType();
                    if (RELATION_OLE_OBJECT.equals(type) && TYPE_OLE_OBJECT.equals(target.getContentType())) {
                        handleEmbeddedOLE(target, handler, sourceDesc + rel.getId());
                    } else if (RELATION_AUDIO.equals(type) || RELATION_IMAGE.equals(type)
                            || RELATION_PACKAGE.equals(type) || RELATION_OLE_OBJECT.equals(type)) {
                        handleEmbeddedFile(target, handler, sourceDesc + rel.getId());
                    }
                }
            }
        }
    } catch (InvalidFormatException e) {
        throw new TikaException("Broken OOXML file", e);
    }
}

From source file:org.apache.tika.parser.microsoft.ooxml.xwpf.XWPFEventBasedWordExtractor.java

License:Apache License

private Map<String, String> loadHyperlinkRelationships(PackagePart bodyPart) {
    Map<String, String> hyperlinks = new HashMap<>();
    try {/*from ww w .java 2s. co m*/
        PackageRelationshipCollection prc = bodyPart
                .getRelationshipsByType(XWPFRelation.HYPERLINK.getRelation());
        for (int i = 0; i < prc.size(); i++) {
            PackageRelationship pr = prc.getRelationship(i);
            if (pr == null) {
                continue;
            }
            String id = pr.getId();
            String url = (pr.getTargetURI() == null) ? null : pr.getTargetURI().toString();
            if (id != null && url != null) {
                hyperlinks.put(id, url);
            }
        }
    } catch (InvalidFormatException e) {
    }
    return hyperlinks;
}

From source file:org.roda.common.certification.OOXMLSignatureUtils.java

public static void runDigitalSignatureStrip(Path input, Path output)
        throws IOException, InvalidFormatException {

    CopyOption[] copyOptions = new CopyOption[] { StandardCopyOption.REPLACE_EXISTING };
    Files.copy(input, output, copyOptions);
    OPCPackage pkg = OPCPackage.open(output.toString(), PackageAccess.READ_WRITE);

    ArrayList<PackagePart> pps = pkg.getPartsByContentType(SIGN_CONTENT_TYPE_OOXML);
    for (PackagePart pp : pps) {
        pkg.removePart(pp);//  ww  w  .  jav  a 2  s.  c o m
    }

    ArrayList<PackagePart> ppct = pkg.getPartsByRelationshipType(SIGN_REL_TYPE_OOXML);
    for (PackagePart pp : ppct) {
        pkg.removePart(pp);
    }

    for (PackageRelationship r : pkg.getRelationships()) {
        if (r.getRelationshipType().equals(SIGN_REL_TYPE_OOXML)) {
            pkg.removeRelationship(r.getId());
        }
    }

    pkg.close();
}