View | Details | Raw Unified | Return to bug 51486
Collapse All | Expand All

(-)src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRelation.java (-3 / +3 lines)
Lines 114-123 Link Here
114
            null
114
            null
115
    );
115
    );
116
    public static final XWPFRelation FOOTNOTE = new XWPFRelation(
116
    public static final XWPFRelation FOOTNOTE = new XWPFRelation(
117
            null,
117
    		"application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml",
118
            "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes",
118
            "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes",
119
            null,
119
    		"/word/footnotes.xml",
120
            null
120
            XWPFFootnotes.class
121
    );
121
    );
122
    public static final XWPFRelation ENDNOTE = new XWPFRelation(
122
    public static final XWPFRelation ENDNOTE = new XWPFRelation(
123
            null,
123
            null,
(-)src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java (-9 / +27 lines)
Lines 100-109 Link Here
100
    protected List<IBodyElement> bodyElements = new ArrayList<IBodyElement>();
100
    protected List<IBodyElement> bodyElements = new ArrayList<IBodyElement>();
101
    protected List<XWPFPictureData> pictures = new ArrayList<XWPFPictureData>();
101
    protected List<XWPFPictureData> pictures = new ArrayList<XWPFPictureData>();
102
    protected Map<Long, List<XWPFPictureData>> packagePictures = new HashMap<Long, List<XWPFPictureData>>();
102
    protected Map<Long, List<XWPFPictureData>> packagePictures = new HashMap<Long, List<XWPFPictureData>>();
103
    protected Map<Integer, XWPFFootnote> footnotes = new HashMap<Integer, XWPFFootnote>();
104
    protected Map<Integer, XWPFFootnote> endnotes = new HashMap<Integer, XWPFFootnote>();
103
    protected Map<Integer, XWPFFootnote> endnotes = new HashMap<Integer, XWPFFootnote>();
105
    protected XWPFNumbering numbering;
104
    protected XWPFNumbering numbering;
106
    protected XWPFStyles styles;
105
    protected XWPFStyles styles;
106
	protected XWPFFootnotes footnotes;
107
107
108
    /** Handles the joy of different headers/footers for different pages */
108
    /** Handles the joy of different headers/footers for different pages */
109
    private XWPFHeaderFooterPolicy headerFooterPolicy;
109
    private XWPFHeaderFooterPolicy headerFooterPolicy;
Lines 216-224 Link Here
216
            String relation = p.getPackageRelationship().getRelationshipType();
216
            String relation = p.getPackageRelationship().getRelationshipType();
217
            if(relation.equals(XWPFRelation.FOOTNOTE.getRelation())){
217
            if(relation.equals(XWPFRelation.FOOTNOTE.getRelation())){
218
                FootnotesDocument footnotesDocument = FootnotesDocument.Factory.parse(p.getPackagePart().getInputStream());
218
                FootnotesDocument footnotesDocument = FootnotesDocument.Factory.parse(p.getPackagePart().getInputStream());
219
				this.footnotes = (XWPFFootnotes)p;
220
				this.footnotes.onDocumentRead();
219
221
220
                for(CTFtnEdn ctFtnEdn : footnotesDocument.getFootnotes().getFootnoteList()) {
222
                for(CTFtnEdn ctFtnEdn : footnotesDocument.getFootnotes().getFootnoteList()) {
221
                    footnotes.put(ctFtnEdn.getId().intValue(), new XWPFFootnote(this, ctFtnEdn));
223
					footnotes.addFootnote(ctFtnEdn);
222
                }
224
                }
223
            } else if (relation.equals(XWPFRelation.ENDNOTE.getRelation())){
225
            } else if (relation.equals(XWPFRelation.ENDNOTE.getRelation())){
224
                EndnotesDocument endnotesDocument = EndnotesDocument.Factory.parse(p.getPackagePart().getInputStream());
226
                EndnotesDocument endnotesDocument = EndnotesDocument.Factory.parse(p.getPackagePart().getInputStream());
Lines 349-363 Link Here
349
    }
351
    }
350
352
351
    public XWPFFootnote getFootnoteByID(int id) {
353
    public XWPFFootnote getFootnoteByID(int id) {
352
        return footnotes.get(id);
354
        return footnotes.getFootnoteById(id);
353
    }
355
    }
354
356
355
    public XWPFFootnote getEndnoteByID(int id) {
357
    public XWPFFootnote getEndnoteByID(int id) {
356
        return endnotes.get(id);
358
        return endnotes.get(id);
357
    }
359
    }
358
360
359
    public Collection<XWPFFootnote> getFootnotes() {
361
    public List<XWPFFootnote> getFootnotes() {
360
        return Collections.unmodifiableCollection(footnotes == null ? new ArrayList<XWPFFootnote>() : footnotes.values());
362
		return footnotes.getFootnotesList();
361
    }
363
    }
362
364
363
    public XWPFHyperlink[] getHyperlinks() {
365
    public XWPFHyperlink[] getHyperlinks() {
Lines 745-758 Link Here
745
       return styles;
747
       return styles;
746
    }
748
    }
747
749
750
    /**
751
     * Creates an empty footnotes element for the document if one does not already exist
752
     * @return footnotes
753
     */
754
    public XWPFFootnotes createFootnotes() {
755
       if(footnotes == null) {
756
          FootnotesDocument footnotesDoc = FootnotesDocument.Factory.newInstance();
748
757
749
    public XWPFFootnote addEndnote(CTFtnEdn note) {
758
          XWPFRelation relation = XWPFRelation.FOOTNOTE;
750
       XWPFFootnote footnote = new XWPFFootnote(this, note); 
759
          int i = getRelationIndex(relation);
751
       footnotes.put(note.getId().intValue(), footnote);
760
752
       return footnote;
761
          XWPFFootnotes wrapper = (XWPFFootnotes)createRelationship(relation, XWPFFactory.getInstance(), i);
762
          wrapper.setFootnotes(footnotesDoc.addNewFootnotes());
763
          footnotes = wrapper;
764
       }
765
766
       return footnotes;
753
    }
767
    }
754
768
755
    public XWPFFootnote addFootnote(CTFtnEdn note) {
769
    public XWPFFootnote addFootnote(CTFtnEdn note) {
770
       return footnotes.addFootnote(note);
771
    }
772
773
    public XWPFFootnote addEndnote(CTFtnEdn note) {
756
       XWPFFootnote endnote = new XWPFFootnote(this, note); 
774
       XWPFFootnote endnote = new XWPFFootnote(this, note); 
757
       endnotes.put(note.getId().intValue(), endnote);
775
       endnotes.put(note.getId().intValue(), endnote);
758
       return endnote;
776
       return endnote;
(-)src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFFootnotes.java (+164 lines)
Line 0 Link Here
1
/* ====================================================================
2
   Licensed to the Apache Software Foundation (ASF) under one or more
3
   contributor license agreements.  See the NOTICE file distributed with
4
   this work for additional information regarding copyright ownership.
5
   The ASF licenses this file to You under the Apache License, Version 2.0
6
   (the "License"); you may not use this file except in compliance with
7
   the License.  You may obtain a copy of the License at
8
9
       http://www.apache.org/licenses/LICENSE-2.0
10
11
   Unless required by applicable law or agreed to in writing, software
12
   distributed under the License is distributed on an "AS IS" BASIS,
13
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
   See the License for the specific language governing permissions and
15
   limitations under the License.
16
==================================================================== */
17
18
package org.apache.poi.xwpf.usermodel;
19
20
import java.io.IOException;
21
import java.io.InputStream;
22
import java.io.OutputStream;
23
import java.util.ArrayList;
24
import java.util.HashMap;
25
import java.util.List;
26
import java.util.Map;
27
28
import javax.xml.namespace.QName;
29
30
import org.apache.poi.POIXMLDocumentPart;
31
import org.apache.poi.POIXMLException;
32
import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
33
import org.apache.poi.openxml4j.opc.PackagePart;
34
import org.apache.poi.openxml4j.opc.PackageRelationship;
35
import org.apache.xmlbeans.XmlException;
36
import org.apache.xmlbeans.XmlOptions;
37
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTP;
38
39
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTFtnEdn;
40
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTFootnotes;
41
import org.openxmlformats.schemas.wordprocessingml.x2006.main.FootnotesDocument;
42
/**
43
 * @author Mike McEuen (mceuen@hp.com)
44
 *
45
 */
46
public class XWPFFootnotes extends POIXMLDocumentPart {
47
    
48
    private List<XWPFFootnote> listFootnote = new ArrayList<XWPFFootnote>();
49
    private CTFootnotes ctFootnotes;
50
51
	protected XWPFDocument document;
52
53
    /**
54
     * Construct XWPFFootnotes from a package part
55
     *
56
     * @param part the package part holding the data of the footnotes,
57
     * @param rel  the package relationship of type "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes"
58
     */
59
60
	public XWPFFootnotes(PackagePart part, PackageRelationship rel) throws IOException, OpenXML4JException{
61
		super(part, rel);
62
	}
63
64
	/**
65
	 * Construct XWPFFootnotes from scratch for a new document.
66
	 */
67
	public XWPFFootnotes() {
68
	}
69
70
	/**
71
	 * Read document
72
	 */
73
	@Override
74
	protected void onDocumentRead () throws IOException {
75
		FootnotesDocument notesDoc;
76
		try {
77
			InputStream is = getPackagePart().getInputStream();
78
			notesDoc = FootnotesDocument.Factory.parse(is);
79
	        ctFootnotes = notesDoc.getFootnotes();
80
	        
81
		} catch (XmlException e) {
82
			throw new POIXMLException();
83
		}
84
        //get any Footnote
85
        for(CTFtnEdn note : ctFootnotes.getFootnoteList()) {
86
            listFootnote.add(new XWPFFootnote(note, this));
87
        }
88
	}
89
	
90
	@Override
91
	protected void commit() throws IOException {
92
		XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS);
93
		xmlOptions.setSaveSyntheticDocumentElement(new QName(CTFootnotes.type.getName().getNamespaceURI(), "footnotes"));
94
		Map<String,String> map = new HashMap<String,String>();
95
		map.put("http://schemas.openxmlformats.org/officeDocument/2006/relationships", "r");
96
		map.put("http://schemas.openxmlformats.org/wordprocessingml/2006/main", "w");
97
		xmlOptions.setSaveSuggestedPrefixes(map);
98
		PackagePart part = getPackagePart();
99
		OutputStream out = part.getOutputStream();
100
		ctFootnotes.save(out, xmlOptions);
101
		out.close();
102
	}
103
104
	public List<XWPFFootnote> getFootnotesList() {
105
		return listFootnote;
106
	}
107
108
	public XWPFFootnote getFootnoteById(int id) {
109
		for(XWPFFootnote note : listFootnote) {
110
			if(note.getCTFtnEdn().getId().intValue() == id)
111
				return note;
112
		}
113
114
		return null;
115
	}
116
	
117
    /**
118
     * Sets the ctFootnotes
119
     * @param footnotes
120
     */
121
    public void setFootnotes(CTFootnotes footnotes) {
122
       ctFootnotes = footnotes;
123
    }
124
125
	/**
126
	 * add an XWPFFootnote to the document
127
	 * @param footnote
128
	 * @throws IOException		 
129
	 */
130
	public void addFootnote(XWPFFootnote footnote){
131
		listFootnote.add(footnote);
132
		ctFootnotes.addNewFootnote().set(footnote.getCTFtnEdn());
133
	}
134
135
	/**
136
	 * add a footnote to the document
137
	 * @param footnote
138
	 * @throws IOException		 
139
	 */
140
	public XWPFFootnote addFootnote(CTFtnEdn note){
141
		CTFtnEdn newNote = ctFootnotes.addNewFootnote();
142
		newNote.set(note);
143
		XWPFFootnote xNote = new XWPFFootnote(newNote, this);
144
		listFootnote.add(xNote);
145
		return xNote;
146
	}
147
148
	public void setXWPFDocument(XWPFDocument doc) {
149
		document = doc;
150
	}
151
152
	/**
153
	 * @see org.apache.poi.xwpf.usermodel.IBody#getPart()
154
	 */
155
	public XWPFDocument getXWPFDocument() {
156
		if ( document != null) {
157
			return document;
158
		} else {
159
			return (XWPFDocument)getParent();
160
		}
161
	}
162
163
}//end class
164
(-)src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFFootnote.java (-1 / +298 lines)
Lines 20-31 Link Here
20
import java.util.Iterator;
20
import java.util.Iterator;
21
import java.util.List;
21
import java.util.List;
22
22
23
import org.apache.poi.POIXMLDocumentPart;
24
import org.apache.poi.POIXMLException;
25
import org.apache.xmlbeans.XmlObject;
26
import org.apache.xmlbeans.XmlCursor;
27
23
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTFtnEdn;
28
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTFtnEdn;
24
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTP;
29
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTP;
25
30
26
public class XWPFFootnote implements Iterable<XWPFParagraph> {
31
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTc;
32
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTbl;
33
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRow;
34
35
public class XWPFFootnote implements Iterable<XWPFParagraph>,IBody {
27
    private List<XWPFParagraph> paragraphs = new ArrayList<XWPFParagraph>();
36
    private List<XWPFParagraph> paragraphs = new ArrayList<XWPFParagraph>();
37
    private List<XWPFTable> tables= new ArrayList<XWPFTable>();
38
    private List<XWPFPictureData> pictures = new ArrayList<XWPFPictureData>();
39
    private List<IBodyElement> bodyElements = new ArrayList<IBodyElement>();
28
40
41
	private CTFtnEdn ctFtnEdn;
42
	private XWPFFootnotes footnotes;
43
44
	public XWPFFootnote(CTFtnEdn note, XWPFFootnotes xFootnotes) {
45
		footnotes = xFootnotes;
46
		ctFtnEdn = note;
47
        for (CTP p : ctFtnEdn.getPList())	{
48
            paragraphs.add(new XWPFParagraph(p, this));
49
        }
50
	}
51
29
    public XWPFFootnote(XWPFDocument document, CTFtnEdn body) {
52
    public XWPFFootnote(XWPFDocument document, CTFtnEdn body) {
30
        for (CTP p : body.getPList())	{
53
        for (CTP p : body.getPList())	{
31
            paragraphs.add(new XWPFParagraph(p, document));
54
            paragraphs.add(new XWPFParagraph(p, document));
Lines 38-43 Link Here
38
61
39
    public Iterator<XWPFParagraph> iterator(){
62
    public Iterator<XWPFParagraph> iterator(){
40
        return paragraphs.iterator();
63
        return paragraphs.iterator();
64
	}
65
66
    public List<XWPFTable> getTables() {
67
        return tables;
41
    }
68
    }
42
69
70
    public List<XWPFPictureData> getPictures() {
71
        return pictures;
72
    }
73
74
    public List<IBodyElement> getBodyElements() {
75
        return bodyElements;
76
    }
77
78
	public CTFtnEdn getCTFtnEdn() {
79
		return ctFtnEdn;
80
	}
81
82
	public void setCTFtnEdn(CTFtnEdn footnote) {
83
		ctFtnEdn = footnote;
84
	}
85
86
    /**
87
	 * @param position in table array
88
	 * @return The table at position pos
89
     * @see org.apache.poi.xwpf.usermodel.IBody#getTableArray(int)
90
     */
91
    public XWPFTable getTableArray(int pos) {
92
93
        if(pos > 0 && pos < tables.size()){
94
            return tables.get(pos);
95
        }
96
        return null;
97
    }
98
99
    /**
100
     * inserts an existing XWPFTable to the arrays bodyElements and tables
101
     * @param pos
102
     * @param table
103
	 * @see org.apache.poi.xwpf.usermodel.IBody#insertTable(int pos, XWPFTable table)
104
     */
105
    public void insertTable(int pos, XWPFTable table) {
106
        bodyElements.add(pos, table);
107
        int i;
108
        for (i = 0; i < ctFtnEdn.getTblList().size(); i++) {
109
            CTTbl tbl = ctFtnEdn.getTblArray(i);
110
            if(tbl == table.getCTTbl()){
111
                break;
112
            }
113
        }
114
        tables.add(i, table);
115
116
    }
117
118
    /**
119
     * if there is a corresponding {@link XWPFTable} of the parameter ctTable in the tableList of this header
120
     * the method will return this table
121
     * if there is no corresponding {@link XWPFTable} the method will return null 
122
     * @param ctTable
123
	 * @see org.apache.poi.xwpf.usermodel.IBody#getTable(CTTbl ctTable)
124
     */
125
    public XWPFTable getTable(CTTbl ctTable){
126
        for (XWPFTable table : tables) {
127
            if(table==null)
128
                return null;
129
            if(table.getCTTbl().equals(ctTable))
130
                return table;	
131
        }
132
        return null;
133
    }
134
135
    /**
136
     * if there is a corresponding {@link XWPFParagraph} of the parameter ctTable in the paragraphList of this header or footer
137
     * the method will return this paragraph
138
     * if there is no corresponding {@link XWPFParagraph} the method will return null 
139
     * @param p is instance of CTP and is searching for an XWPFParagraph
140
     * @return null if there is no XWPFParagraph with an corresponding CTPparagraph in the paragraphList of this header or footer
141
     * 		   XWPFParagraph with the correspondig CTP p
142
	 * @see org.apache.poi.xwpf.usermodel.IBody#getParagraph(CTP p)
143
     */
144
    public XWPFParagraph getParagraph(CTP p){
145
        for (XWPFParagraph paragraph : paragraphs) {
146
            if(paragraph.getCTP().equals(p))
147
                return paragraph;
148
        }
149
        return null;
150
    }
151
152
    /**
153
     * Returns the paragraph that holds
154
     *  the text of the header or footer.
155
	 * @see org.apache.poi.xwpf.usermodel.IBody#getParagraphArray(int pos)
156
     */
157
    public XWPFParagraph getParagraphArray(int pos) {
158
159
        return paragraphs.get(pos);
160
    }
161
162
    /**
163
     * get the TableCell which belongs to the TableCell
164
     * @param cell
165
	 * @see org.apache.poi.xwpf.usermodel.IBody#getTableCell(CTTc cell)
166
     */
167
    public XWPFTableCell getTableCell(CTTc cell) {
168
        XmlCursor cursor = cell.newCursor();
169
        cursor.toParent();
170
        XmlObject o = cursor.getObject();
171
        if(!(o instanceof CTRow)){
172
            return null;
173
        }
174
        CTRow row = (CTRow)o;
175
        cursor.toParent();
176
        o = cursor.getObject();
177
        cursor.dispose();
178
        if(! (o instanceof CTTbl)){
179
            return null;
180
        }
181
        CTTbl tbl = (CTTbl) o;
182
        XWPFTable table = getTable(tbl);
183
        if(table == null){
184
            return null;
185
        }
186
        XWPFTableRow tableRow = table.getRow(row);
187
        if(row == null){
188
            return null;
189
        }
190
        return tableRow.getTableCell(cell);
191
    }
192
193
    /**
194
     * verifies that cursor is on the right position
195
     * @param cursor
196
     */
197
    private boolean isCursorInFtn(XmlCursor cursor) {
198
        XmlCursor verify = cursor.newCursor();
199
        verify.toParent();
200
        if(verify.getObject() == this.ctFtnEdn){
201
            return true;
202
        }
203
        return false;
204
    }
205
206
    public POIXMLDocumentPart getOwner(){
207
        return footnotes;
208
    }
209
210
    /**
211
     * 
212
     * @param cursor
213
     * @return the inserted table
214
	 * @see org.apache.poi.xwpf.usermodel.IBody#insertNewTbl(XmlCursor cursor)
215
     */
216
    public XWPFTable insertNewTbl(XmlCursor cursor) {
217
        if(isCursorInFtn(cursor)){
218
            String uri = CTTbl.type.getName().getNamespaceURI();
219
            String localPart = "tbl";
220
            cursor.beginElement(localPart,uri);
221
            cursor.toParent();
222
            CTTbl t = (CTTbl)cursor.getObject();
223
            XWPFTable newT = new XWPFTable(t, this);
224
            cursor.removeXmlContents();
225
            XmlObject o = null;
226
            while(!(o instanceof CTTbl)&&(cursor.toPrevSibling())){
227
                o = cursor.getObject();
228
            }
229
            if(!(o instanceof CTTbl)){
230
                tables.add(0, newT);
231
            }
232
            else{
233
                int pos = tables.indexOf(getTable((CTTbl)o))+1;
234
                tables.add(pos,newT);
235
            }
236
            int i=0;
237
            cursor = t.newCursor();
238
            while(cursor.toPrevSibling()){
239
                o =cursor.getObject();
240
                if(o instanceof CTP || o instanceof CTTbl)
241
                    i++;
242
            }
243
            bodyElements.add(i, newT);
244
            cursor = t.newCursor();
245
            cursor.toEndToken();
246
            return newT;
247
        }
248
        return null;
249
    }
250
251
    /**
252
     * add a new paragraph at position of the cursor
253
     * @param cursor
254
     * @return the inserted paragraph
255
	 * @see org.apache.poi.xwpf.usermodel.IBody#insertNewParagraph(XmlCursor cursor)
256
     */
257
    public XWPFParagraph insertNewParagraph(XmlCursor cursor){
258
        if(isCursorInFtn(cursor)){
259
            String uri = CTP.type.getName().getNamespaceURI();
260
            String localPart = "p";
261
            cursor.beginElement(localPart,uri);
262
            cursor.toParent();
263
            CTP p = (CTP)cursor.getObject();
264
            XWPFParagraph newP = new XWPFParagraph(p, this);
265
            XmlObject o = null;
266
            while(!(o instanceof CTP)&&(cursor.toPrevSibling())){
267
                o = cursor.getObject();
268
            }
269
            if((!(o instanceof CTP)) || (CTP)o == p){
270
                paragraphs.add(0, newP);
271
            }
272
            else{
273
                int pos = paragraphs.indexOf(getParagraph((CTP)o))+1;
274
                paragraphs.add(pos,newP);
275
            }
276
            int i=0;
277
            cursor.toCursor(p.newCursor());
278
            while(cursor.toPrevSibling()){
279
                o =cursor.getObject();
280
                if(o instanceof CTP || o instanceof CTTbl)
281
                    i++;
282
            }
283
            bodyElements.add(i, newP);
284
            cursor.toCursor(p.newCursor());
285
            cursor.toEndToken();
286
            return newP;
287
        }
288
        return null;
289
    }
290
291
	/**
292
	 * add a new table to the end of the footnote
293
	 * @param table
294
	 * @return the added XWPFTable
295
	 */
296
    public XWPFTable addNewTbl(CTTbl table) {
297
		CTTbl newTable = ctFtnEdn.addNewTbl();
298
		newTable.set(table);
299
		XWPFTable xTable = new XWPFTable(newTable, this);
300
		tables.add(xTable);
301
		return xTable;
302
    }
303
	
304
	/**
305
	 * add a new paragraph to the end of the footnote
306
	 * @param paragraph
307
	 * @return the added XWPFParagraph
308
	 */
309
    public XWPFParagraph addNewParagraph(CTP paragraph) {
310
		CTP newPara = ctFtnEdn.addNewP();
311
		newPara.set(paragraph);
312
		XWPFParagraph xPara = new XWPFParagraph(newPara, this);
313
		paragraphs.add(xPara);
314
		return xPara;
315
    }
316
	
317
	/**
318
	 * @see org.apache.poi.xwpf.usermodel.IBody#getXWPFDocument()
319
	 */
320
	public  XWPFDocument getXWPFDocument() {
321
		return footnotes.getXWPFDocument();
322
	}
323
324
    /**
325
     * returns the Part, to which the body belongs, which you need for adding relationship to other parts
326
     * @see org.apache.poi.xwpf.usermodel.IBody#getPart()
327
     */
328
    public POIXMLDocumentPart getPart() {
329
        return footnotes;
330
    }
331
332
    /**
333
     * get the PartType of the body
334
     * @see org.apache.poi.xwpf.usermodel.IBody#getPartType()
335
     */
336
    public BodyType getPartType() {
337
        return BodyType.FOOTNOTE;
338
    }
43
}
339
}
340
(-)src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFHeaderFooter.java (+4 lines)
Lines 498-503 Link Here
498
        return tableRow.getTableCell(cell);
498
        return tableRow.getTableCell(cell);
499
    }
499
    }
500
500
501
	public void setXWPFDocument(XWPFDocument doc) {
502
        document = doc;
503
	}
504
501
    public XWPFDocument getXWPFDocument() {
505
    public XWPFDocument getXWPFDocument() {
502
        if (document!=null) {
506
        if (document!=null) {
503
            return document;
507
            return document;

Return to bug 51486