Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright 2010, Plutext Pty Ltd.
*
* This file is part of docx4j.
docx4j is licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package org.docx4j.openpackaging.parts.DrawingML;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
import javax.xml.bind.JAXBElement;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.io.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.docx4j.TraversalUtil;
import org.docx4j.XmlUtils;
import org.docx4j.TraversalUtil.Callback;
import org.docx4j.dml.CTTextBody;
import org.docx4j.dml.diagram.CTCxn;
import org.docx4j.dml.diagram.CTDataModel;
import org.docx4j.dml.diagram.CTElemPropSet;
import org.docx4j.dml.diagram.CTPt;
import org.docx4j.dml.diagram.STCxnType;
import org.docx4j.dml.diagram.STPtType;
import org.docx4j.dml.wordprocessingDrawing.Inline;
import org.docx4j.openpackaging.exceptions.InvalidFormatException;
import org.docx4j.openpackaging.io.SaveToZipFile;
import org.docx4j.openpackaging.packages.WordprocessingMLPackage;
import org.docx4j.openpackaging.parts.JaxbXmlPart;
import org.docx4j.openpackaging.parts.PartName;
import org.docx4j.openpackaging.parts.WordprocessingML.BinaryPartAbstractImage;
import org.docx4j.openpackaging.parts.relationships.Namespaces;
import org.docx4j.relationships.Relationship;
public final class DiagramDataPart extends JaxbDmlPart {
private static Logger log = LoggerFactory.getLogger(DiagramDataPart.class);
public DiagramDataPart(PartName partName) throws InvalidFormatException {
super(partName);
init();
}
public DiagramDataPart() throws InvalidFormatException {
super(new PartName("/word/diagrams/data1.xml"));
init();
}
public void init() {
// Used if this Part is added to [Content_Types].xml
setContentType(new org.docx4j.openpackaging.contenttype.ContentType(
org.docx4j.openpackaging.contenttype.ContentTypes.DRAWINGML_DIAGRAM_DATA));
// Used when this Part is added to a rels
setRelationshipType(Namespaces.DRAWINGML_DIAGRAM_DATA);
}
/**
* This method ensures generated IDs are
* valid and (subject to that constraint)
* easy-ish to understand.
*/
public static void setFriendlyIds(Object jaxbElement) {
map = new HashMap();
// Go through once creating a map of IDs
generateIdMap(jaxbElement);
// Go through again, replacing
ReplaceIds(jaxbElement);
}
static HashMap map;
static int index = 0;
protected static void generateIdMap(Object jaxbElement) {
new TraversalUtil(jaxbElement,
new Callback() {
// Unfortunately, the schema says
// a model id must be an int or a GUID.
// Word 2007 won't open a docx which violates that.
@Override
public List