1 | /* | |
2 | * $Id: MarkedSection.java 3373 2008-05-12 16:21:24Z xlv $ | |
3 | * | |
4 | * Copyright 2007 by Bruno Lowagie. | |
5 | * | |
6 | * The contents of this file are subject to the Mozilla Public License Version 1.1 | |
7 | * (the "License"); you may not use this file except in compliance with the License. | |
8 | * You may obtain a copy of the License at http://www.mozilla.org/MPL/ | |
9 | * | |
10 | * Software distributed under the License is distributed on an "AS IS" basis, | |
11 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |
12 | * for the specific language governing rights and limitations under the License. | |
13 | * | |
14 | * The Original Code is 'iText, a free JAVA-PDF library'. | |
15 | * | |
16 | * The Initial Developer of the Original Code is Bruno Lowagie. Portions created by | |
17 | * the Initial Developer are Copyright (C) 1999-2007 by Bruno Lowagie. | |
18 | * All Rights Reserved. | |
19 | * Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer | |
20 | * are Copyright (C) 2000-2007 by Paulo Soares. All Rights Reserved. | |
21 | * | |
22 | * Contributor(s): all the names of the contributors are added in the source code | |
23 | * where applicable. | |
24 | * | |
25 | * Alternatively, the contents of this file may be used under the terms of the | |
26 | * LGPL license (the "GNU LIBRARY GENERAL PUBLIC LICENSE"), in which case the | |
27 | * provisions of LGPL are applicable instead of those above. If you wish to | |
28 | * allow use of your version of this file only under the terms of the LGPL | |
29 | * License and not to allow others to use your version of this file under | |
30 | * the MPL, indicate your decision by deleting the provisions above and | |
31 | * replace them with the notice and other provisions required by the LGPL. | |
32 | * If you do not delete the provisions above, a recipient may use your version | |
33 | * of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE. | |
34 | * | |
35 | * This library is free software; you can redistribute it and/or modify it | |
36 | * under the terms of the MPL as stated above or under the terms of the GNU | |
37 | * Library General Public License as published by the Free Software Foundation; | |
38 | * either version 2 of the License, or any later version. | |
39 | * | |
40 | * This library is distributed in the hope that it will be useful, but WITHOUT | |
41 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
42 | * FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more | |
43 | * details. | |
44 | * | |
45 | * If you didn't download this code from the following link, you should check if | |
46 | * you aren't using an obsolete version: | |
47 | * http://www.lowagie.com/iText/ | |
48 | */ | |
49 | ||
50 | package com.lowagie.text; | |
51 | ||
52 | import java.util.Collection; | |
53 | ||
54 | /** | |
55 | * Wrapper that allows to add properties to a Chapter/Section object. | |
56 | * Before iText 1.5 every 'basic building block' implemented the MarkupAttributes interface. | |
57 | * By setting attributes, you could add markup to the corresponding XML and/or HTML tag. | |
58 | * This functionality was hardly used by anyone, so it was removed, and replaced by | |
59 | * the MarkedObject functionality. | |
60 | */ | |
61 | ||
62 | public class MarkedSection extends MarkedObject { | |
63 | ||
64 | /** This is the title of this section. */ | |
65 | protected MarkedObject title = null; | |
66 | | |
67 | /** | |
68 | * Creates a MarkedObject with a Section or Chapter object. | |
69 | * @param section the marked section | |
70 | */ | |
71 | public MarkedSection(Section section) { | |
72 | super(); | |
73 |
1
1. |
if (section.title != null) { |
74 | title = new MarkedObject(section.title); | |
75 |
1
1. |
section.setTitle(null); |
76 | } | |
77 | this.element = section; | |
78 | } | |
79 | | |
80 | /** | |
81 | * Adds a <CODE>Paragraph</CODE>, <CODE>List</CODE> or <CODE>Table</CODE> | |
82 | * to this <CODE>Section</CODE>. | |
83 | * | |
84 | * @param index index at which the specified element is to be inserted | |
85 | * @param o an object of type <CODE>Paragraph</CODE>, <CODE>List</CODE> or <CODE>Table</CODE>= | |
86 | * @throws ClassCastException if the object is not a <CODE>Paragraph</CODE>, <CODE>List</CODE> or <CODE>Table</CODE> | |
87 | */ | |
88 | public void add(int index, Object o) { | |
89 |
1
1. add : removed call to com/lowagie/text/Section::add → NO_COVERAGE |
((Section)element).add(index, o); |
90 | } | |
91 | | |
92 | /** | |
93 | * Adds a <CODE>Paragraph</CODE>, <CODE>List</CODE>, <CODE>Table</CODE> or another <CODE>Section</CODE> | |
94 | * to this <CODE>Section</CODE>. | |
95 | * | |
96 | * @param o an object of type <CODE>Paragraph</CODE>, <CODE>List</CODE>, <CODE>Table</CODE> or another <CODE>Section</CODE> | |
97 | * @return a boolean | |
98 | * @throws ClassCastException if the object is not a <CODE>Paragraph</CODE>, <CODE>List</CODE>, <CODE>Table</CODE> or <CODE>Section</CODE> | |
99 | */ | |
100 | public boolean add(Object o) { | |
101 |
1
1. add : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return ((Section)element).add(o); |
102 | } | |
103 | ||
104 | /** | |
105 | * Processes the element by adding it (or the different parts) to an | |
106 | * <CODE>ElementListener</CODE>. | |
107 | * | |
108 | * @param listener an <CODE>ElementListener</CODE> | |
109 | * @return <CODE>true</CODE> if the element was processed successfully | |
110 | */ | |
111 | public boolean process(ElementListener listener) { | |
112 | try { | |
113 | Element element; | |
114 | for (Object o : ((Section) this.element)) { | |
115 | element = (Element) o; | |
116 | listener.add(element); | |
117 | } | |
118 |
1
1. process : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return true; |
119 | } | |
120 | catch(DocumentException de) { | |
121 |
1
1. process : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return false; |
122 | } | |
123 | } | |
124 | | |
125 | /** | |
126 | * Adds a collection of <CODE>Element</CODE>s | |
127 | * to this <CODE>Section</CODE>. | |
128 | * | |
129 | * @param collection a collection of <CODE>Paragraph</CODE>s, <CODE>List</CODE>s and/or <CODE>Table</CODE>s | |
130 | * @return <CODE>true</CODE> if the action succeeded, <CODE>false</CODE> if not. | |
131 | * @throws ClassCastException if one of the objects isn't a <CODE>Paragraph</CODE>, <CODE>List</CODE>, <CODE>Table</CODE> | |
132 | */ | |
133 | public boolean addAll(Collection collection) { | |
134 |
1
1. addAll : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return ((Section)element).addAll(collection); |
135 | } | |
136 | | |
137 | /** | |
138 | * Creates a <CODE>Section</CODE>, adds it to this <CODE>Section</CODE> and returns it. | |
139 | * | |
140 | * @param indentation the indentation of the new section | |
141 | * @param numberDepth the numberDepth of the section | |
142 | * @return a new Section object | |
143 | */ | |
144 | public MarkedSection addSection(float indentation, int numberDepth) { | |
145 | MarkedSection section = ((Section)element).addMarkedSection(); | |
146 |
1
1. addSection : removed call to com/lowagie/text/MarkedSection::setIndentation → NO_COVERAGE |
section.setIndentation(indentation); |
147 |
1
1. addSection : removed call to com/lowagie/text/MarkedSection::setNumberDepth → NO_COVERAGE |
section.setNumberDepth(numberDepth); |
148 |
1
1. addSection : mutated return of Object value for com/lowagie/text/MarkedSection::addSection to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return section; |
149 | } | |
150 | | |
151 | /** | |
152 | * Creates a <CODE>Section</CODE>, adds it to this <CODE>Section</CODE> and returns it. | |
153 | * | |
154 | * @param indentation the indentation of the new section | |
155 | * @return a new Section object | |
156 | */ | |
157 | public MarkedSection addSection(float indentation) { | |
158 | MarkedSection section = ((Section)element).addMarkedSection(); | |
159 |
1
1. addSection : removed call to com/lowagie/text/MarkedSection::setIndentation → NO_COVERAGE |
section.setIndentation(indentation); |
160 |
1
1. addSection : mutated return of Object value for com/lowagie/text/MarkedSection::addSection to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return section; |
161 | } | |
162 | | |
163 | /** | |
164 | * Creates a <CODE>Section</CODE>, add it to this <CODE>Section</CODE> and returns it. | |
165 | * | |
166 | * @param numberDepth the numberDepth of the section | |
167 | * @return a new Section object | |
168 | */ | |
169 | public MarkedSection addSection(int numberDepth) { | |
170 | MarkedSection section = ((Section)element).addMarkedSection(); | |
171 |
1
1. addSection : removed call to com/lowagie/text/MarkedSection::setNumberDepth → NO_COVERAGE |
section.setNumberDepth(numberDepth); |
172 |
1
1. addSection : mutated return of Object value for com/lowagie/text/MarkedSection::addSection to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return section; |
173 | } | |
174 | | |
175 | /** | |
176 | * Creates a <CODE>Section</CODE>, adds it to this <CODE>Section</CODE> and returns it. | |
177 | * | |
178 | * @return a new Section object | |
179 | */ | |
180 | public MarkedSection addSection() { | |
181 |
1
1. addSection : mutated return of Object value for com/lowagie/text/MarkedSection::addSection to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return ((Section)element).addMarkedSection(); |
182 | } | |
183 | | |
184 | // public methods | |
185 | | |
186 | /** | |
187 | * Sets the title of this section. | |
188 | * | |
189 | * @param title the new title | |
190 | */ | |
191 | public void setTitle(MarkedObject title) { | |
192 |
1
1. setTitle : negated conditional → NO_COVERAGE |
if (title.element instanceof Paragraph) |
193 | this.title = title; | |
194 | } | |
195 | ||
196 | /** | |
197 | * Gets the title of this MarkedSection. | |
198 | * @return a MarkObject with a Paragraph containing the title of a Section | |
199 | * @since iText 2.0.8 | |
200 | */ | |
201 | public MarkedObject getTitle() { | |
202 | Paragraph result = Section.constructTitle((Paragraph)title.element, ((Section)element).numbers, ((Section)element).numberDepth, ((Section)element).numberStyle); | |
203 | MarkedObject mo = new MarkedObject(result); | |
204 | mo.markupAttributes = title.markupAttributes; | |
205 |
1
1. getTitle : mutated return of Object value for com/lowagie/text/MarkedSection::getTitle to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return mo; |
206 | } | |
207 | | |
208 | /** | |
209 | * Sets the depth of the sectionnumbers that will be shown preceding the title. | |
210 | * <P> | |
211 | * If the numberdepth is 0, the sections will not be numbered. If the numberdepth | |
212 | * is 1, the section will be numbered with their own number. If the numberdepth is | |
213 | * higher (for instance x > 1), the numbers of x - 1 parents will be shown. | |
214 | * | |
215 | * @param numberDepth the new numberDepth | |
216 | */ | |
217 | public void setNumberDepth(int numberDepth) { | |
218 |
1
1. setNumberDepth : removed call to com/lowagie/text/Section::setNumberDepth → NO_COVERAGE |
((Section)element).setNumberDepth(numberDepth); |
219 | } | |
220 | | |
221 | /** | |
222 | * Sets the indentation of this <CODE>Section</CODE> on the left side. | |
223 | * | |
224 | * @param indentation the indentation | |
225 | */ | |
226 | public void setIndentationLeft(float indentation) { | |
227 |
1
1. setIndentationLeft : removed call to com/lowagie/text/Section::setIndentationLeft → NO_COVERAGE |
((Section)element).setIndentationLeft(indentation); |
228 | } | |
229 | | |
230 | /** | |
231 | * Sets the indentation of this <CODE>Section</CODE> on the right side. | |
232 | * | |
233 | * @param indentation the indentation | |
234 | */ | |
235 | public void setIndentationRight(float indentation) { | |
236 |
1
1. setIndentationRight : removed call to com/lowagie/text/Section::setIndentationRight → NO_COVERAGE |
((Section)element).setIndentationRight(indentation); |
237 | } | |
238 | | |
239 | /** | |
240 | * Sets the indentation of the content of this <CODE>Section</CODE>. | |
241 | * | |
242 | * @param indentation the indentation | |
243 | */ | |
244 | public void setIndentation(float indentation) { | |
245 |
1
1. setIndentation : removed call to com/lowagie/text/Section::setIndentation → NO_COVERAGE |
((Section)element).setIndentation(indentation); |
246 | } | |
247 | | |
248 | /** Setter for property bookmarkOpen. | |
249 | * @param bookmarkOpen false if the bookmark children are not | |
250 | * visible. | |
251 | */ | |
252 | public void setBookmarkOpen(boolean bookmarkOpen) { | |
253 |
1
1. setBookmarkOpen : removed call to com/lowagie/text/Section::setBookmarkOpen → NO_COVERAGE |
((Section)element).setBookmarkOpen(bookmarkOpen); |
254 | } | |
255 | | |
256 | /** | |
257 | * Setter for property triggerNewPage. | |
258 | * @param triggerNewPage true if a new page has to be triggered. | |
259 | */ | |
260 | public void setTriggerNewPage(boolean triggerNewPage) { | |
261 |
1
1. setTriggerNewPage : removed call to com/lowagie/text/Section::setTriggerNewPage → NO_COVERAGE |
((Section)element).setTriggerNewPage(triggerNewPage); |
262 | } | |
263 | | |
264 | /** | |
265 | * Sets the bookmark title. The bookmark title is the same as the section title but | |
266 | * can be changed with this method. | |
267 | * @param bookmarkTitle the bookmark title | |
268 | */ | |
269 | public void setBookmarkTitle(String bookmarkTitle) { | |
270 |
1
1. setBookmarkTitle : removed call to com/lowagie/text/Section::setBookmarkTitle → NO_COVERAGE |
((Section)element).setBookmarkTitle(bookmarkTitle); |
271 | } | |
272 | ||
273 | /** | |
274 | * Adds a new page to the section. | |
275 | * @since 2.1.1 | |
276 | */ | |
277 | public void newPage() { | |
278 |
1
1. newPage : removed call to com/lowagie/text/Section::newPage → NO_COVERAGE |
((Section)element).newPage(); |
279 | } | |
280 | } | |
Mutations | ||
73 |
1.1 |
|
75 |
1.1 |
|
89 |
1.1 |
|
101 |
1.1 |
|
118 |
1.1 |
|
121 |
1.1 |
|
134 |
1.1 |
|
146 |
1.1 |
|
147 |
1.1 |
|
148 |
1.1 |
|
159 |
1.1 |
|
160 |
1.1 |
|
171 |
1.1 |
|
172 |
1.1 |
|
181 |
1.1 |
|
192 |
1.1 |
|
205 |
1.1 |
|
218 |
1.1 |
|
227 |
1.1 |
|
236 |
1.1 |
|
245 |
1.1 |
|
253 |
1.1 |
|
261 |
1.1 |
|
270 |
1.1 |
|
278 |
1.1 |