1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.rendering.wikimodel.xhtml

File PrintListener.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart10.png
0% of files have more coverage

Code metrics

16
50
39
1
328
257
47
0.94
1.28
39
1.21

Classes

Class Line # Actions
PrintListener 30 50 0% 47 1
0.990476299%
 

Contributing tests

This file is covered by 132 tests. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.rendering.wikimodel.xhtml;
21   
22    import org.xwiki.rendering.wikimodel.IWikiPrinter;
23    import org.xwiki.rendering.wikimodel.WikiPageUtil;
24    import org.xwiki.rendering.wikimodel.WikiParameters;
25   
26    /**
27    * @version $Id: 9304f8d0f244ffb7478f54accaae75fe4a48617d $
28    * @since 4.0M1
29    */
 
30    public class PrintListener extends PrintInlineListener
31    {
32    /**
33    * @param printer
34    */
 
35  4 toggle public PrintListener(IWikiPrinter printer)
36    {
37  4 super(printer);
38    }
39   
 
40  1337 toggle public PrintListener(IWikiPrinter printer, boolean supportImage, boolean supportDownload)
41    {
42  1337 super(printer, supportImage, supportDownload);
43    }
44   
 
45  32 toggle @Override
46    public void beginDefinitionDescription()
47    {
48  32 print(" <dd>");
49    }
50   
 
51  32 toggle @Override
52    public void beginDefinitionList(WikiParameters parameters)
53    {
54  32 println("<dl>");
55    }
56   
 
57  33 toggle @Override
58    public void beginDefinitionTerm()
59    {
60  33 print(" <dt>");
61    }
62   
 
63  1454 toggle @Override
64    public void beginDocument(WikiParameters params)
65    {
66  1454 println("<div class='wikimodel-document'" + params + ">");
67    }
68   
 
69  149 toggle @Override
70    public void beginHeader(int headerLevel, WikiParameters params)
71    {
72  149 print("<h" + headerLevel + params + ">");
73    }
74   
 
75  7 toggle @Override
76    public void beginInfoBlock(String infoType, WikiParameters params)
77    {
78  7 print("<table" + params + "><tr><th>" + infoType + "</th><td>");
79    }
80   
 
81  152 toggle @Override
82    public void beginList(WikiParameters parameters, boolean ordered)
83    {
84  152 if (ordered) {
85  27 println("<ol" + parameters + ">");
86    } else {
87  125 println("<ul" + parameters + ">");
88    }
89    }
90   
 
91  223 toggle @Override
92    public void beginListItem()
93    {
94  223 print(" <li>");
95    }
96   
 
97  1040 toggle @Override
98    public void beginParagraph(WikiParameters params)
99    {
100  1040 print("<p" + params + ">");
101    }
102   
 
103  35 toggle @Override
104    public void beginPropertyBlock(String propertyUri, boolean doc)
105    {
106  35 print("<div class='wikimodel-property' url='"
107    + WikiPageUtil.escapeXmlAttribute(propertyUri)
108    + "'>");
109  35 if (doc) {
110  8 println("");
111    }
112    }
113   
 
114  52 toggle @Override
115    public void beginQuotation(WikiParameters params)
116    {
117  52 println("<blockquote" + params + ">");
118    }
119   
 
120  72 toggle @Override
121    public void beginQuotationLine()
122    {
123    // print("<p>");
124    }
125   
 
126  128 toggle @Override
127    public void beginTable(WikiParameters params)
128    {
129  128 println("<table" + params + "><tbody>");
130    }
131   
 
132  306 toggle @Override
133    public void beginTableCell(boolean tableHead, WikiParameters params)
134    {
135  306 String str = tableHead ? "<th" : "<td";
136  306 print(str + params + ">");
137    }
138   
 
139  180 toggle @Override
140    public void beginTableRow(WikiParameters params)
141    {
142  180 print(" <tr" + params + ">");
143    }
144   
 
145  32 toggle @Override
146    public void endDefinitionDescription()
147    {
148  32 println("</dd>");
149    }
150   
 
151  32 toggle @Override
152    public void endDefinitionList(WikiParameters parameters)
153    {
154  32 println("</dl>");
155    }
156   
 
157  33 toggle @Override
158    public void endDefinitionTerm()
159    {
160  33 println("</dt>");
161    }
162   
 
163  1454 toggle @Override
164    public void endDocument(WikiParameters params)
165    {
166  1454 println("</div>");
167    }
168   
 
169  149 toggle @Override
170    public void endHeader(int headerLevel, WikiParameters params)
171    {
172  149 println("</h" + headerLevel + ">");
173    }
174   
 
175  7 toggle @Override
176    public void endInfoBlock(String infoType, WikiParameters params)
177    {
178  7 println("</td></tr></table>");
179    }
180   
 
181  152 toggle @Override
182    public void endList(WikiParameters parameters, boolean ordered)
183    {
184  152 if (ordered) {
185  27 println("</ol>");
186    } else {
187  125 println("</ul>");
188    }
189    }
190   
 
191  223 toggle @Override
192    public void endListItem()
193    {
194  223 println("</li>");
195    }
196   
 
197  1040 toggle @Override
198    public void endParagraph(WikiParameters params)
199    {
200  1040 println("</p>");
201    }
202   
 
203  35 toggle @Override
204    public void endPropertyBlock(String propertyUri, boolean doc)
205    {
206  35 println("</div>");
207    }
208   
 
209  52 toggle @Override
210    public void endQuotation(WikiParameters params)
211    {
212  52 println("</blockquote>");
213    }
214   
 
215  72 toggle @Override
216    public void endQuotationLine()
217    {
218  72 println("");
219    }
220   
 
221  128 toggle @Override
222    public void endTable(WikiParameters params)
223    {
224  128 println("</tbody></table>");
225    }
226   
 
227  306 toggle @Override
228    public void endTableCell(boolean tableHead, WikiParameters params)
229    {
230  306 String str = tableHead ? "</th>" : "</td>";
231  306 print(str);
232    }
233   
 
234  180 toggle @Override
235    public void endTableRow(WikiParameters params)
236    {
237  180 println("</tr>");
238    }
239   
 
240  28 toggle @Override
241    public void onEmptyLines(int count)
242    {
243  28 if (count > 1) {
244  14 println("<div style='height:" + count + "em;'></div>");
245    }
246    }
247   
248    /**
249    * @see PrintInlineListener#onExtensionBlock(java.lang.String,
250    * org.xwiki.rendering.wikimodel.WikiParameters)
251    */
 
252  8 toggle @Override
253    public void onExtensionBlock(String extensionName, WikiParameters params)
254    {
255  8 println("<div class='wikimodel-extension' extension='"
256    + extensionName
257    + "'"
258    + params
259    + "/>");
260    }
261   
 
262  31 toggle @Override
263    public void onHorizontalLine(WikiParameters params)
264    {
265  31 println("<hr" + params + " />");
266    }
267   
 
268  244 toggle @Override
269    public void onMacroBlock(
270    String macroName,
271    WikiParameters params,
272    String content)
273    {
274  244 if (content == null) {
275  62 println("<pre class='wikimodel-macro' macroName='"
276    + macroName
277    + "'"
278    + params
279    + "/>");
280    } else {
281  182 println("<pre class='wikimodel-macro' macroName='"
282    + macroName
283    + "'"
284    + params
285    + "><![CDATA["
286    + content
287    + "]]></pre>");
288    }
289    }
290   
 
291  97 toggle @Override
292    public void onMacroInline(
293    String macroName,
294    WikiParameters params,
295    String content)
296    {
297  97 if (content == null) {
298  32 print("<span class='wikimodel-macro' macroName='"
299    + macroName
300    + "'"
301    + params
302    + "/>");
303    } else {
304  65 print("<span class='wikimodel-macro' macroName='"
305    + macroName
306    + "'"
307    + params
308    + "><![CDATA["
309    + content
310    + "]]></span>");
311    }
312    }
313   
 
314  0 toggle @Override
315    public void onTableCaption(String str)
316    {
317    }
318   
 
319  84 toggle @Override
320    public void onVerbatimBlock(String str, WikiParameters params)
321    {
322  84 println("<pre"
323    + params
324    + ">"
325    + WikiPageUtil.escapeXmlString(str)
326    + "</pre>");
327    }
328    }