Changeset 1493


Ignore:
Timestamp:
05/15/11 05:20:43 (13 months ago)
Author:
jharrop
Message:

BibliographyPart?.

Location:
trunk/docx4j/src/main/java/org/docx4j
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/docx4j/src/main/java/org/docx4j/convert/in/FlatOpcXmlImporter.java

    r1492 r1493  
    507507                                                                        (org.opendope.components.Components)o); 
    508508 
    509                                                 } else if (o instanceof org.docx4j.bibliography.CTSources) { 
    510                                                          
     509                                                } else if (o instanceof JAXBElement<?>  
     510                                                                && XmlUtils.unwrap(o) instanceof org.docx4j.bibliography.CTSources) { 
    511511                                                        part = new BibliographyPart(name); 
    512512                                                        ((BibliographyPart)part).setJaxbElement( 
    513                                                                         (org.docx4j.bibliography.CTSources)o); 
     513                                                                        (JAXBElement<org.docx4j.bibliography.CTSources>)o); 
    514514                                                                                                                 
    515515                                                } else { 
  • trunk/docx4j/src/main/java/org/docx4j/openpackaging/io/Load.java

    r1492 r1493  
    2727import java.util.Iterator; 
    2828 
     29import javax.xml.bind.JAXBElement; 
    2930import javax.xml.bind.Unmarshaller; 
    3031 
    3132import org.apache.log4j.Logger; 
     33import org.docx4j.XmlUtils; 
    3234import org.docx4j.jaxb.Context; 
    3335import org.docx4j.model.datastorage.BindingHandler; 
     
    205207                                                                        (org.opendope.components.Components)o); 
    206208 
    207                                                 } else if (o instanceof org.docx4j.bibliography.CTSources) { 
    208                                                          
     209                                                } else if (o instanceof JAXBElement<?> 
     210                                                                && XmlUtils.unwrap(o) instanceof org.docx4j.bibliography.CTSources) { 
    209211                                                        part = new BibliographyPart(name); 
    210                                                         ((BibliographyPart)part).setJaxbElement( 
    211                                                                         (org.docx4j.bibliography.CTSources)o); 
    212                                                          
     212                                                        ((BibliographyPart) part) 
     213                                                                        .setJaxbElement((JAXBElement<org.docx4j.bibliography.CTSources>)o); 
     214 
    213215                                                } else { 
    214216                                                         
  • trunk/docx4j/src/main/java/org/docx4j/openpackaging/io/LoadFromZipFile.java

    r1492 r1493  
    3434import java.util.zip.ZipFile; 
    3535 
     36import javax.xml.bind.JAXBElement; 
    3637import javax.xml.bind.Unmarshaller; 
    3738 
    3839import org.apache.log4j.Logger; 
     40import org.docx4j.XmlUtils; 
    3941import org.docx4j.jaxb.Context; 
    4042import org.docx4j.model.datastorage.CustomXmlDataStorage; 
     
    529531                                                                        (org.opendope.components.Components)o); 
    530532 
    531                                                 } else if (o instanceof org.docx4j.bibliography.CTSources) { 
    532                                                          
     533                                                } else if (o instanceof JAXBElement<?>  
     534                                                                && XmlUtils.unwrap(o) instanceof org.docx4j.bibliography.CTSources) { 
    533535                                                        part = new BibliographyPart(name); 
    534536                                                        ((BibliographyPart)part).setJaxbElement( 
    535                                                                         (org.docx4j.bibliography.CTSources)o);                                           
     537                                                                        (JAXBElement<org.docx4j.bibliography.CTSources>)o); 
    536538 
    537539                                                } else { 
  • trunk/docx4j/src/main/java/org/docx4j/openpackaging/io/LoadFromZipNG.java

    r1492 r1493  
    4141import java.util.zip.ZipInputStream; 
    4242 
     43import javax.xml.bind.JAXBElement; 
    4344import javax.xml.bind.Unmarshaller; 
    4445 
     
    588589                                                                        (org.opendope.components.Components)o); 
    589590 
    590                                                 } else if (o instanceof org.docx4j.bibliography.CTSources) { 
    591                                                          
     591                                                } else if (o instanceof JAXBElement<?>  
     592                                                                && XmlUtils.unwrap(o) instanceof org.docx4j.bibliography.CTSources) { 
    592593                                                        part = new BibliographyPart(name); 
    593594                                                        ((BibliographyPart)part).setJaxbElement( 
    594                                                                         (org.docx4j.bibliography.CTSources)o); 
     595                                                                        (JAXBElement<org.docx4j.bibliography.CTSources>)o); 
    595596                                                                                                                 
    596597                                                } else { 
  • trunk/docx4j/src/main/java/org/docx4j/openpackaging/parts/WordprocessingML/BibliographyPart.java

    r1492 r1493  
    22 
    33import javax.xml.bind.JAXBContext; 
     4import javax.xml.bind.JAXBElement; 
    45 
    56import org.apache.log4j.Logger; 
     7import org.docx4j.XmlUtils; 
     8import org.docx4j.bibliography.CTSourceType; 
     9import org.docx4j.bibliography.CTSources; 
    610import org.docx4j.openpackaging.exceptions.InvalidFormatException; 
    7 import org.docx4j.openpackaging.parts.CustomXmlDataStoragePart; 
    811import org.docx4j.openpackaging.parts.PartName; 
    912import org.docx4j.openpackaging.parts.opendope.JaxbCustomXmlDataStoragePart; 
    1013 
    11 public class BibliographyPart extends JaxbCustomXmlDataStoragePart<org.docx4j.bibliography.CTSources> { 
     14/** 
     15 * @since 2.7 
     16 */ 
     17public class BibliographyPart extends JaxbCustomXmlDataStoragePart<JAXBElement<org.docx4j.bibliography.CTSources>> { 
    1218         
    1319        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         
    1426         
    1527        public BibliographyPart(PartName partName) throws InvalidFormatException { 
     
    2335        } 
    2436         
     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        } 
    2551 
    2652} 
Note: See TracChangeset for help on using the changeset viewer.