source: trunk/docx4j/src/main/java/org/docx4j/wml/P.java @ 1473

Revision 1473, 30.7 KB checked in by jharrop, 13 months ago (diff)

Implement ContentAccessor? interface

Line 
1/*
2 *  Copyright 2007-2008, Plutext Pty Ltd.
3 *   
4 *  This file is part of docx4j.
5
6    docx4j is licensed under the Apache License, Version 2.0 (the "License");
7    you may not use this file except in compliance with the License.
8
9    You may obtain a copy of the License at
10
11        http://www.apache.org/licenses/LICENSE-2.0
12
13    Unless required by applicable law or agreed to in writing, software
14    distributed under the License is distributed on an "AS IS" BASIS,
15    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16    See the License for the specific language governing permissions and
17    limitations under the License.
18
19 */
20
21
22package org.docx4j.wml;
23
24import java.util.ArrayList;
25import java.util.List;
26import javax.xml.bind.JAXBElement;
27import javax.xml.bind.Unmarshaller;
28import javax.xml.bind.annotation.XmlAccessType;
29import javax.xml.bind.annotation.XmlAccessorType;
30import javax.xml.bind.annotation.XmlAttribute;
31import javax.xml.bind.annotation.XmlElementRef;
32import javax.xml.bind.annotation.XmlElementRefs;
33import javax.xml.bind.annotation.XmlRootElement;
34import javax.xml.bind.annotation.XmlTransient;
35import javax.xml.bind.annotation.XmlType;
36import org.docx4j.math.CTOMath;
37import org.docx4j.math.CTOMathPara;
38import org.apache.log4j.Logger;
39import org.jvnet.jaxb2_commons.ppp.Child;
40
41
42/**
43 * <p>Java class for anonymous complex type.
44 *
45 * <p>The following schema fragment specifies the expected content contained within this class.
46 *
47 * <pre>
48 * &lt;complexType>
49 *   &lt;complexContent>
50 *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
51 *       &lt;sequence>
52 *         &lt;element name="pPr" type="{http://schemas.openxmlformats.org/wordprocessingml/2006/main}CT_PPr" minOccurs="0"/>
53 *         &lt;group ref="{http://schemas.openxmlformats.org/wordprocessingml/2006/main}EG_PContent" maxOccurs="unbounded" minOccurs="0"/>
54 *       &lt;/sequence>
55 *       &lt;attribute name="rsidRPr" type="{http://schemas.openxmlformats.org/wordprocessingml/2006/main}ST_LongHexNumber" />
56 *       &lt;attribute name="rsidR" type="{http://schemas.openxmlformats.org/wordprocessingml/2006/main}ST_LongHexNumber" />
57 *       &lt;attribute name="rsidDel" type="{http://schemas.openxmlformats.org/wordprocessingml/2006/main}ST_LongHexNumber" />
58 *       &lt;attribute name="rsidP" type="{http://schemas.openxmlformats.org/wordprocessingml/2006/main}ST_LongHexNumber" />
59 *       &lt;attribute name="rsidRDefault" type="{http://schemas.openxmlformats.org/wordprocessingml/2006/main}ST_LongHexNumber" />
60 *     &lt;/restriction>
61 *   &lt;/complexContent>
62 * &lt;/complexType>
63 * </pre>
64 *
65 *
66 */
67@XmlAccessorType(XmlAccessType.FIELD)
68@XmlType(name = "", propOrder = {
69    "pPr",
70    "paragraphContent"
71})
72@XmlRootElement(name = "p")
73public class P implements Child, ContentAccessor
74{
75        private static Logger log = Logger.getLogger(P.class); 
76
77    protected PPr pPr;
78    @XmlElementRefs({
79        @XmlElementRef(name = "bookmarkStart", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
80        @XmlElementRef(name = "customXmlMoveToRangeEnd", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
81        @XmlElementRef(name = "moveTo", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
82        @XmlElementRef(name = "moveFrom", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
83        @XmlElementRef(name = "bookmarkEnd", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
84        @XmlElementRef(name = "customXmlInsRangeStart", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
85        @XmlElementRef(name = "commentRangeStart", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = CommentRangeStart.class),
86        @XmlElementRef(name = "hyperlink", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
87        @XmlElementRef(name = "moveToRangeEnd", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
88        @XmlElementRef(name = "permStart", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
89        @XmlElementRef(name = "sdt", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
90        @XmlElementRef(name = "ins", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = RunIns.class),
91        @XmlElementRef(name = "r", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = R.class),
92        @XmlElementRef(name = "oMath", namespace = "http://schemas.openxmlformats.org/officeDocument/2006/math", type = JAXBElement.class),
93        @XmlElementRef(name = "customXmlDelRangeStart", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
94        @XmlElementRef(name = "smartTag", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
95        @XmlElementRef(name = "customXmlMoveFromRangeEnd", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
96        @XmlElementRef(name = "commentRangeEnd", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = CommentRangeEnd.class),
97        @XmlElementRef(name = "permEnd", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
98        @XmlElementRef(name = "fldSimple", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
99        @XmlElementRef(name = "proofErr", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = ProofErr.class),
100        @XmlElementRef(name = "moveFromRangeEnd", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
101        @XmlElementRef(name = "del", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = RunDel.class),
102        @XmlElementRef(name = "subDoc", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
103        @XmlElementRef(name = "customXmlInsRangeEnd", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
104        @XmlElementRef(name = "customXmlDelRangeEnd", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
105        @XmlElementRef(name = "oMathPara", namespace = "http://schemas.openxmlformats.org/officeDocument/2006/math", type = JAXBElement.class),
106        @XmlElementRef(name = "moveToRangeStart", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
107        @XmlElementRef(name = "customXml", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
108        @XmlElementRef(name = "moveFromRangeStart", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
109        @XmlElementRef(name = "customXmlMoveToRangeStart", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
110        @XmlElementRef(name = "customXmlMoveFromRangeStart", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class)
111    })
112    protected List<Object> paragraphContent;
113    @XmlAttribute(namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main")
114    protected String rsidRPr;
115    @XmlAttribute(namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main")
116    protected String rsidR;
117    @XmlAttribute(namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main")
118    protected String rsidDel;
119    @XmlAttribute(namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main")
120    protected String rsidP;
121    @XmlAttribute(namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main")
122    protected String rsidRDefault;
123    @XmlTransient
124    private Object parent;
125
126    /**
127     * Gets the value of the pPr property.
128     *
129     * @return
130     *     possible object is
131     *     {@link PPr }
132     *     
133     */
134    public PPr getPPr() {
135        return pPr;
136    }
137
138    /**
139     * Sets the value of the pPr property.
140     *
141     * @param value
142     *     allowed object is
143     *     {@link PPr }
144     *     
145     */
146    public void setPPr(PPr value) {
147        this.pPr = value;
148    }
149
150    /**
151     * Gets the value of the paragraphContent property.
152     *
153     * <p>
154     * This accessor method returns a reference to the live list,
155     * not a snapshot. Therefore any modification you make to the
156     * returned list will be present inside the JAXB object.
157     * This is why there is not a <CODE>set</CODE> method for the paragraphContent property.
158     *
159     * <p>
160     * For example, to add a new item, do as follows:
161     * <pre>
162     *    getParagraphContent().add(newItem);
163     * </pre>
164     *
165     *
166     * <p>
167     * Objects of the following type(s) are allowed in the list
168     * {@link JAXBElement }{@code <}{@link CTBookmark }{@code >}
169     * {@link JAXBElement }{@code <}{@link CTMarkup }{@code >}
170     * {@link JAXBElement }{@code <}{@link RunTrackChange }{@code >}
171     * {@link JAXBElement }{@code <}{@link RunTrackChange }{@code >}
172     * {@link JAXBElement }{@code <}{@link CTMarkupRange }{@code >}
173     * {@link JAXBElement }{@code <}{@link CTTrackChange }{@code >}
174     * {@link CommentRangeStart }
175     * {@link JAXBElement }{@code <}{@link P.Hyperlink }{@code >}
176     * {@link JAXBElement }{@code <}{@link CTMarkupRange }{@code >}
177     * {@link JAXBElement }{@code <}{@link RangePermissionStart }{@code >}
178     * {@link JAXBElement }{@code <}{@link SdtRun }{@code >}
179     * {@link RunIns }
180     * {@link R }
181     * {@link JAXBElement }{@code <}{@link CTOMath }{@code >}
182     * {@link JAXBElement }{@code <}{@link CTTrackChange }{@code >}
183     * {@link JAXBElement }{@code <}{@link CTSmartTagRun }{@code >}
184     * {@link JAXBElement }{@code <}{@link CTMarkup }{@code >}
185     * {@link CommentRangeEnd }
186     * {@link JAXBElement }{@code <}{@link CTPerm }{@code >}
187     * {@link JAXBElement }{@code <}{@link CTSimpleField }{@code >}
188     * {@link ProofErr }
189     * {@link JAXBElement }{@code <}{@link CTMarkupRange }{@code >}
190     * {@link RunDel }
191     * {@link JAXBElement }{@code <}{@link CTRel }{@code >}
192     * {@link JAXBElement }{@code <}{@link CTMarkup }{@code >}
193     * {@link JAXBElement }{@code <}{@link CTMarkup }{@code >}
194     * {@link JAXBElement }{@code <}{@link CTOMathPara }{@code >}
195     * {@link JAXBElement }{@code <}{@link CTCustomXmlRun }{@code >}
196     * {@link JAXBElement }{@code <}{@link CTMoveBookmark }{@code >}
197     * {@link JAXBElement }{@code <}{@link CTMoveBookmark }{@code >}
198     * {@link JAXBElement }{@code <}{@link CTTrackChange }{@code >}
199     * {@link JAXBElement }{@code <}{@link CTTrackChange }{@code >}
200     *
201     *
202     */
203    @Deprecated
204    public List<Object> getParagraphContent() {
205        if (paragraphContent == null) {
206            paragraphContent = new ArrayList<Object>();
207        }
208        return this.paragraphContent;
209    }
210
211    /**
212     * Get the content of this element.
213     * @since 2.7
214     */   
215    public List<Object> getContent() {
216        if (paragraphContent == null) {
217            paragraphContent = new ArrayList<Object>();
218        }
219        return this.paragraphContent;
220    }
221   
222    /**
223     * Gets the value of the rsidRPr property.
224     *
225     * @return
226     *     possible object is
227     *     {@link String }
228     *     
229     */
230    public String getRsidRPr() {
231        return rsidRPr;
232    }
233
234    /**
235     * Sets the value of the rsidRPr property.
236     *
237     * @param value
238     *     allowed object is
239     *     {@link String }
240     *     
241     */
242    public void setRsidRPr(String value) {
243        this.rsidRPr = value;
244    }
245
246    /**
247     * Gets the value of the rsidR property.
248     *
249     * @return
250     *     possible object is
251     *     {@link String }
252     *     
253     */
254    public String getRsidR() {
255        return rsidR;
256    }
257
258    /**
259     * Sets the value of the rsidR property.
260     *
261     * @param value
262     *     allowed object is
263     *     {@link String }
264     *     
265     */
266    public void setRsidR(String value) {
267        this.rsidR = value;
268    }
269
270    /**
271     * Gets the value of the rsidDel property.
272     *
273     * @return
274     *     possible object is
275     *     {@link String }
276     *     
277     */
278    public String getRsidDel() {
279        return rsidDel;
280    }
281
282    /**
283     * Sets the value of the rsidDel property.
284     *
285     * @param value
286     *     allowed object is
287     *     {@link String }
288     *     
289     */
290    public void setRsidDel(String value) {
291        this.rsidDel = value;
292    }
293
294    /**
295     * Gets the value of the rsidP property.
296     *
297     * @return
298     *     possible object is
299     *     {@link String }
300     *     
301     */
302    public String getRsidP() {
303        return rsidP;
304    }
305
306    /**
307     * Sets the value of the rsidP property.
308     *
309     * @param value
310     *     allowed object is
311     *     {@link String }
312     *     
313     */
314    public void setRsidP(String value) {
315        this.rsidP = value;
316    }
317
318    /**
319     * Gets the value of the rsidRDefault property.
320     *
321     * @return
322     *     possible object is
323     *     {@link String }
324     *     
325     */
326    public String getRsidRDefault() {
327        return rsidRDefault;
328    }
329
330    /**
331     * Sets the value of the rsidRDefault property.
332     *
333     * @param value
334     *     allowed object is
335     *     {@link String }
336     *     
337     */
338    public void setRsidRDefault(String value) {
339        this.rsidRDefault = value;
340    }
341
342    /**
343     * Gets the parent object in the object tree representing the unmarshalled xml document.
344     *
345     * @return
346     *     The parent object.
347     */
348    public Object getParent() {
349        return this.parent;
350    }
351
352    public void setParent(Object parent) {
353        this.parent = parent;
354    }
355
356    /**
357     * This method is invoked by the JAXB implementation on each instance when unmarshalling completes.
358     *
359     * @param parent
360     *     The parent object in the object tree.
361     * @param unmarshaller
362     *     The unmarshaller that generated the instance.
363     */
364    public void afterUnmarshal(Unmarshaller unmarshaller, Object parent) {
365        setParent(parent);
366    }
367
368
369    /**
370     * Hyperlink
371     *
372     * <p>Java class for anonymous complex type.
373     *
374     * <p>The following schema fragment specifies the expected content contained within this class.
375     *
376     * <pre>
377     * &lt;complexType>
378     *   &lt;complexContent>
379     *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
380     *       &lt;group ref="{http://schemas.openxmlformats.org/wordprocessingml/2006/main}EG_PContent" maxOccurs="unbounded" minOccurs="0"/>
381     *       &lt;attribute name="tgtFrame" type="{http://schemas.openxmlformats.org/wordprocessingml/2006/main}ST_String" />
382     *       &lt;attribute name="tooltip" type="{http://schemas.openxmlformats.org/wordprocessingml/2006/main}ST_String" />
383     *       &lt;attribute name="docLocation" type="{http://schemas.openxmlformats.org/wordprocessingml/2006/main}ST_String" />
384     *       &lt;attribute name="history" type="{http://www.w3.org/2001/XMLSchema}boolean" default="true" />
385     *       &lt;attribute name="anchor" type="{http://schemas.openxmlformats.org/wordprocessingml/2006/main}ST_String" />
386     *       &lt;attribute ref="{http://schemas.openxmlformats.org/officeDocument/2006/relationships}id"/>
387     *     &lt;/restriction>
388     *   &lt;/complexContent>
389     * &lt;/complexType>
390     * </pre>
391     *
392     *
393     */
394    @XmlAccessorType(XmlAccessType.FIELD)
395    @XmlType(name = "", propOrder = {
396        "paragraphContent"
397    })
398    @XmlRootElement(name = "hyperlink")   
399    public static class Hyperlink
400        implements Child, ContentAccessor
401    {
402
403        @XmlElementRefs({
404            @XmlElementRef(name = "subDoc", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
405            @XmlElementRef(name = "customXmlInsRangeStart", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
406            @XmlElementRef(name = "sdt", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
407            @XmlElementRef(name = "commentRangeStart", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = CommentRangeStart.class),
408            @XmlElementRef(name = "moveTo", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
409            @XmlElementRef(name = "customXmlDelRangeEnd", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
410            @XmlElementRef(name = "smartTag", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
411            @XmlElementRef(name = "ins", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = RunIns.class),
412            @XmlElementRef(name = "fldSimple", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
413            @XmlElementRef(name = "bookmarkEnd", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
414            @XmlElementRef(name = "bookmarkStart", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
415            @XmlElementRef(name = "customXmlDelRangeStart", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
416            @XmlElementRef(name = "customXmlMoveToRangeStart", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
417            @XmlElementRef(name = "oMath", namespace = "http://schemas.openxmlformats.org/officeDocument/2006/math", type = JAXBElement.class),
418            @XmlElementRef(name = "r", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = R.class),
419            @XmlElementRef(name = "moveFromRangeStart", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
420            @XmlElementRef(name = "permEnd", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
421            @XmlElementRef(name = "commentRangeEnd", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = CommentRangeEnd.class),
422            @XmlElementRef(name = "moveToRangeEnd", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
423            @XmlElementRef(name = "hyperlink", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
424            @XmlElementRef(name = "customXmlMoveFromRangeStart", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
425            @XmlElementRef(name = "moveFromRangeEnd", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
426            @XmlElementRef(name = "proofErr", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = ProofErr.class),
427            @XmlElementRef(name = "del", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = RunDel.class),
428            @XmlElementRef(name = "permStart", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
429            @XmlElementRef(name = "oMathPara", namespace = "http://schemas.openxmlformats.org/officeDocument/2006/math", type = JAXBElement.class),
430            @XmlElementRef(name = "customXml", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
431            @XmlElementRef(name = "customXmlMoveFromRangeEnd", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
432            @XmlElementRef(name = "moveFrom", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
433            @XmlElementRef(name = "customXmlInsRangeEnd", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
434            @XmlElementRef(name = "customXmlMoveToRangeEnd", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
435            @XmlElementRef(name = "moveToRangeStart", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class)
436        })
437        protected List<Object> paragraphContent;
438        @XmlAttribute(namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main")
439        protected String tgtFrame;
440        @XmlAttribute(namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main")
441        protected String tooltip;
442        @XmlAttribute(namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main")
443        protected String docLocation;
444        @XmlAttribute(namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main")
445        protected Boolean history;
446        @XmlAttribute(namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main")
447        protected String anchor;
448        @XmlAttribute(namespace = "http://schemas.openxmlformats.org/officeDocument/2006/relationships")
449        protected String id;
450        @XmlTransient
451        private Object parent;
452
453        /**
454         * Gets the value of the paragraphContent property.
455         *
456         * <p>
457         * This accessor method returns a reference to the live list,
458         * not a snapshot. Therefore any modification you make to the
459         * returned list will be present inside the JAXB object.
460         * This is why there is not a <CODE>set</CODE> method for the paragraphContent property.
461         *
462         * <p>
463         * For example, to add a new item, do as follows:
464         * <pre>
465         *    getParagraphContent().add(newItem);
466         * </pre>
467         *
468         *
469         * <p>
470         * Objects of the following type(s) are allowed in the list
471         * {@link JAXBElement }{@code <}{@link CTRel }{@code >}
472         * {@link JAXBElement }{@code <}{@link CTTrackChange }{@code >}
473         * {@link JAXBElement }{@code <}{@link SdtRun }{@code >}
474         * {@link CommentRangeStart }
475         * {@link JAXBElement }{@code <}{@link RunTrackChange }{@code >}
476         * {@link JAXBElement }{@code <}{@link CTMarkup }{@code >}
477         * {@link JAXBElement }{@code <}{@link CTSmartTagRun }{@code >}
478         * {@link RunIns }
479         * {@link JAXBElement }{@code <}{@link CTSimpleField }{@code >}
480         * {@link JAXBElement }{@code <}{@link CTMarkupRange }{@code >}
481         * {@link JAXBElement }{@code <}{@link CTBookmark }{@code >}
482         * {@link JAXBElement }{@code <}{@link CTTrackChange }{@code >}
483         * {@link JAXBElement }{@code <}{@link CTTrackChange }{@code >}
484         * {@link JAXBElement }{@code <}{@link CTOMath }{@code >}
485         * {@link R }
486         * {@link JAXBElement }{@code <}{@link CTMoveBookmark }{@code >}
487         * {@link JAXBElement }{@code <}{@link CTPerm }{@code >}
488         * {@link CommentRangeEnd }
489         * {@link JAXBElement }{@code <}{@link CTMarkupRange }{@code >}
490         * {@link JAXBElement }{@code <}{@link P.Hyperlink }{@code >}
491         * {@link JAXBElement }{@code <}{@link CTTrackChange }{@code >}
492         * {@link JAXBElement }{@code <}{@link CTMarkupRange }{@code >}
493         * {@link ProofErr }
494         * {@link RunDel }
495         * {@link JAXBElement }{@code <}{@link RangePermissionStart }{@code >}
496         * {@link JAXBElement }{@code <}{@link CTOMathPara }{@code >}
497         * {@link JAXBElement }{@code <}{@link CTCustomXmlRun }{@code >}
498         * {@link JAXBElement }{@code <}{@link CTMarkup }{@code >}
499         * {@link JAXBElement }{@code <}{@link RunTrackChange }{@code >}
500         * {@link JAXBElement }{@code <}{@link CTMarkup }{@code >}
501         * {@link JAXBElement }{@code <}{@link CTMarkup }{@code >}
502         * {@link JAXBElement }{@code <}{@link CTMoveBookmark }{@code >}
503         *
504         *
505         */
506        @Deprecated
507        public List<Object> getParagraphContent() {
508            if (paragraphContent == null) {
509                paragraphContent = new ArrayList<Object>();
510            }
511            return this.paragraphContent;
512        }
513
514        /**
515         * Get the content of this element.
516         * @since 2.7
517         */       
518        public List<Object> getContent() {
519            if (paragraphContent == null) {
520                paragraphContent = new ArrayList<Object>();
521            }
522            return this.paragraphContent;
523        }
524       
525        /**
526         * Gets the value of the tgtFrame property.
527         *
528         * @return
529         *     possible object is
530         *     {@link String }
531         *     
532         */
533        public String getTgtFrame() {
534            return tgtFrame;
535        }
536
537        /**
538         * Sets the value of the tgtFrame property.
539         *
540         * @param value
541         *     allowed object is
542         *     {@link String }
543         *     
544         */
545        public void setTgtFrame(String value) {
546            this.tgtFrame = value;
547        }
548
549        /**
550         * Gets the value of the tooltip property.
551         *
552         * @return
553         *     possible object is
554         *     {@link String }
555         *     
556         */
557        public String getTooltip() {
558            return tooltip;
559        }
560
561        /**
562         * Sets the value of the tooltip property.
563         *
564         * @param value
565         *     allowed object is
566         *     {@link String }
567         *     
568         */
569        public void setTooltip(String value) {
570            this.tooltip = value;
571        }
572
573        /**
574         * Gets the value of the docLocation property.
575         *
576         * @return
577         *     possible object is
578         *     {@link String }
579         *     
580         */
581        public String getDocLocation() {
582            return docLocation;
583        }
584
585        /**
586         * Sets the value of the docLocation property.
587         *
588         * @param value
589         *     allowed object is
590         *     {@link String }
591         *     
592         */
593        public void setDocLocation(String value) {
594            this.docLocation = value;
595        }
596
597        /**
598         * Gets the value of the history property.
599         *
600         * @return
601         *     possible object is
602         *     {@link Boolean }
603         *     
604         */
605        public boolean isHistory() {
606            if (history == null) {
607                return true;
608            } else {
609                return history;
610            }
611        }
612
613        /**
614         * Sets the value of the history property.
615         *
616         * @param value
617         *     allowed object is
618         *     {@link Boolean }
619         *     
620         */
621        public void setHistory(Boolean value) {
622            this.history = value;
623        }
624
625        /**
626         * Gets the value of the anchor property.
627         *
628         * @return
629         *     possible object is
630         *     {@link String }
631         *     
632         */
633        public String getAnchor() {
634            return anchor;
635        }
636
637        /**
638         * Sets the value of the anchor property.
639         *
640         * @param value
641         *     allowed object is
642         *     {@link String }
643         *     
644         */
645        public void setAnchor(String value) {
646            this.anchor = value;
647        }
648
649        /**
650         *
651         *                                                              Hyperlink Target
652         *                                                     
653         *
654         * @return
655         *     possible object is
656         *     {@link String }
657         *     
658         */
659        public String getId() {
660            return id;
661        }
662
663        /**
664         * Sets the value of the id property.
665         *
666         * @param value
667         *     allowed object is
668         *     {@link String }
669         *     
670         */
671        public void setId(String value) {
672            this.id = value;
673        }
674
675        /**
676         * Gets the parent object in the object tree representing the unmarshalled xml document.
677         *
678         * @return
679         *     The parent object.
680         */
681        public Object getParent() {
682            return this.parent;
683        }
684
685        public void setParent(Object parent) {
686            this.parent = parent;
687        }
688
689        /**
690         * This method is invoked by the JAXB implementation on each instance when unmarshalling completes.
691         *
692         * @param parent
693         *     The parent object in the object tree.
694         * @param unmarshaller
695         *     The unmarshaller that generated the instance.
696         */
697        public void afterUnmarshal(Unmarshaller unmarshaller, Object parent) {
698            setParent(parent);
699        }
700
701    }
702
703    // Not generated
704    /** Get the text content of all runs in the P.  WARNING: this only gets ./w:r/w:t.
705     *  That is incomplete.  Try org.docx4j.TextUtils.extractText instead.  */
706    @Deprecated
707    public String toString() {
708
709        StringBuilder result = new StringBuilder();
710       
711        List<Object> children = getParagraphContent();
712       
713//      System.out.println("p.toString");
714       
715                for (Object o : children ) {                                   
716//                      System.out.println("  " + o.getClass().getName() );
717                        if ( o instanceof org.docx4j.wml.R) {
718//                      System.out.println("Hit R");
719                                org.docx4j.wml.R  run = (org.docx4j.wml.R)o;
720                        List runContent = run.getContent();
721                                for (Object o2 : runContent ) {                                 
722                                        if ( o2 instanceof javax.xml.bind.JAXBElement) {
723                                                // TODO - unmarshall directly to Text.
724                                                if ( ((JAXBElement)o2).getDeclaredType().getName().equals("org.docx4j.wml.Text") ) {
725//                                              System.out.println("Found Text");
726                                                        org.docx4j.wml.Text t = (org.docx4j.wml.Text)((JAXBElement)o2).getValue();
727                                                        result.append( t.getValue() );                                 
728                                                }
729                                        } else {
730//                                      System.out.println(o2.getClass().getName());                                           
731                                        }
732                                }
733                        } 
734                }
735                return result.toString();
736       
737    }
738
739    public void replaceElement(Object current, List insertions) {
740
741        int index = paragraphContent.indexOf(current);         
742        if (index > -1 ) {             
743                paragraphContent.addAll(index+1, insertions); 
744                Object removed = paragraphContent.remove(index);
745                // sanity check
746                if (!current.equals(removed)) {
747                        log.error("removed wrong object?");
748                }               
749        } else {
750                // Not found
751                log.error("Couldn't find replacement target.");
752        }
753    }   
754   
755}
Note: See TracBrowser for help on using the repository browser.