source: trunk/docx4j/src/main/java/org/docx4j/openpackaging/parts/WordprocessingML/BibliographyPart.java @ 1493

Revision 1493, 1.5 KB checked in by jharrop, 12 months ago (diff)

BibliographyPart?.

Line 
1package org.docx4j.openpackaging.parts.WordprocessingML;
2
3import javax.xml.bind.JAXBContext;
4import javax.xml.bind.JAXBElement;
5
6import org.apache.log4j.Logger;
7import org.docx4j.XmlUtils;
8import org.docx4j.bibliography.CTSourceType;
9import org.docx4j.bibliography.CTSources;
10import org.docx4j.openpackaging.exceptions.InvalidFormatException;
11import org.docx4j.openpackaging.parts.PartName;
12import org.docx4j.openpackaging.parts.opendope.JaxbCustomXmlDataStoragePart;
13
14/**
15 * @since 2.7
16 */
17public class BibliographyPart extends JaxbCustomXmlDataStoragePart<JAXBElement<org.docx4j.bibliography.CTSources>> {
18       
19        private static Logger log = Logger.getLogger(BibliographyPart.class);           
20
21        public BibliographyPart() throws InvalidFormatException {
22                super(new PartName("/customXml/item1.xml"));
23                init();
24        }
25       
26       
27        public BibliographyPart(PartName partName) throws InvalidFormatException {
28                super(partName);
29                init();
30        }
31
32        public BibliographyPart(PartName partName, JAXBContext jc) throws InvalidFormatException {
33                super(partName, jc);
34                init();
35        }
36       
37        public void importSources(BibliographyPart otherPart) {
38               
39                org.docx4j.bibliography.CTSources ourSources = (CTSources)XmlUtils.unwrap(this.getJaxbElement());
40               
41                org.docx4j.bibliography.CTSources otherSourcesTmp = (CTSources)XmlUtils.unwrap(otherPart.getJaxbElement());             
42                org.docx4j.bibliography.CTSources otherSourcesCloned = XmlUtils.deepCopy(otherSourcesTmp);
43               
44                for (CTSourceType sourceType : otherSourcesCloned.getSource()) {
45               
46                        // TODO duplicate detection.
47                       
48                        ourSources.getSource().add(sourceType);
49                }
50        }
51
52}
Note: See TracBrowser for help on using the repository browser.