1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.officeimporter.internal.cleaner; |
21 |
|
|
22 |
|
import java.io.Reader; |
23 |
|
import java.util.ArrayList; |
24 |
|
import java.util.Arrays; |
25 |
|
import java.util.List; |
26 |
|
|
27 |
|
import javax.inject.Inject; |
28 |
|
import javax.inject.Named; |
29 |
|
import javax.inject.Singleton; |
30 |
|
|
31 |
|
import org.w3c.dom.Document; |
32 |
|
import org.xwiki.component.annotation.Component; |
33 |
|
import org.xwiki.xml.html.HTMLCleaner; |
34 |
|
import org.xwiki.xml.html.HTMLCleanerConfiguration; |
35 |
|
import org.xwiki.xml.html.filter.HTMLFilter; |
36 |
|
|
37 |
|
|
38 |
|
@link |
39 |
|
|
40 |
|
@version |
41 |
|
@since |
42 |
|
|
43 |
|
@Component |
44 |
|
@Named("wysiwyg") |
45 |
|
@Singleton |
|
|
| 20% |
Uncovered Elements: 8 (10) |
Complexity: 3 |
Complexity Density: 0.43 |
|
46 |
|
public class WysiwygHTMLCleaner implements HTMLCleaner |
47 |
|
{ |
48 |
|
|
49 |
|
|
50 |
|
|
51 |
|
@Inject |
52 |
|
private HTMLCleaner defaultHtmlCleaner; |
53 |
|
|
54 |
|
|
55 |
|
@link |
56 |
|
|
57 |
|
@Inject |
58 |
|
@Named("officeimporter/stripper") |
59 |
|
private HTMLFilter stripperFilter; |
60 |
|
|
61 |
|
|
62 |
|
@link |
63 |
|
|
64 |
|
@Inject |
65 |
|
@Named("officeimporter/style") |
66 |
|
private HTMLFilter styleFilter; |
67 |
|
|
68 |
|
|
69 |
|
@link |
70 |
|
|
71 |
|
@Inject |
72 |
|
@Named("officeimporter/redundancy") |
73 |
|
private HTMLFilter redundancyFilter; |
74 |
|
|
75 |
|
|
76 |
|
@link |
77 |
|
|
78 |
|
@Inject |
79 |
|
@Named("officeimporter/paragraph") |
80 |
|
private HTMLFilter paragraphFilter; |
81 |
|
|
82 |
|
|
83 |
|
@link |
84 |
|
|
85 |
|
@Inject |
86 |
|
@Named("officeimporter/image") |
87 |
|
private HTMLFilter imageFilter; |
88 |
|
|
89 |
|
|
90 |
|
@link |
91 |
|
|
92 |
|
@Inject |
93 |
|
@Named("officeimporter/list") |
94 |
|
private HTMLFilter listFilter; |
95 |
|
|
96 |
|
|
97 |
|
@link |
98 |
|
|
99 |
|
@Inject |
100 |
|
@Named("officeimporter/table") |
101 |
|
private HTMLFilter tableFilter; |
102 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
103 |
0 |
@Override... |
104 |
|
public Document clean(Reader originalHtmlContent) |
105 |
|
{ |
106 |
0 |
return clean(originalHtmlContent, getDefaultConfiguration()); |
107 |
|
} |
108 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
109 |
1 |
@Override... |
110 |
|
public Document clean(Reader originalHtmlContent, HTMLCleanerConfiguration configuration) |
111 |
|
{ |
112 |
1 |
return this.defaultHtmlCleaner.clean(originalHtmlContent, configuration); |
113 |
|
} |
114 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
115 |
0 |
@Override... |
116 |
|
public HTMLCleanerConfiguration getDefaultConfiguration() |
117 |
|
{ |
118 |
0 |
HTMLCleanerConfiguration configuration = this.defaultHtmlCleaner.getDefaultConfiguration(); |
119 |
|
|
120 |
|
|
121 |
0 |
List<HTMLFilter> filters = new ArrayList<HTMLFilter>(configuration.getFilters()); |
122 |
0 |
filters.addAll(Arrays.asList( |
123 |
|
this.stripperFilter, |
124 |
|
this.styleFilter, |
125 |
|
this.redundancyFilter, |
126 |
|
this.paragraphFilter, |
127 |
|
this.imageFilter, |
128 |
|
this.listFilter, |
129 |
|
this.tableFilter)); |
130 |
0 |
configuration.setFilters(filters); |
131 |
|
|
132 |
0 |
return configuration; |
133 |
|
} |
134 |
|
} |