1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.rendering.internal.renderer.tex; |
21 |
|
|
22 |
|
import java.util.Map; |
23 |
|
|
24 |
|
import javax.inject.Named; |
25 |
|
|
26 |
|
import org.xwiki.component.annotation.Component; |
27 |
|
import org.xwiki.component.annotation.InstantiationStrategy; |
28 |
|
import org.xwiki.component.descriptor.ComponentInstantiationStrategy; |
29 |
|
import org.xwiki.rendering.internal.renderer.wikimodel.WikiModelGeneratorListener; |
30 |
|
import org.xwiki.rendering.internal.renderer.wikimodel.WikiModelPrinterAdapter; |
31 |
|
import org.xwiki.rendering.listener.Format; |
32 |
|
import org.xwiki.rendering.listener.WrappingListener; |
33 |
|
import org.xwiki.rendering.renderer.PrintRenderer; |
34 |
|
import org.xwiki.rendering.renderer.printer.WikiPrinter; |
35 |
|
import org.xwiki.rendering.wikimodel.tex.TexSerializer; |
36 |
|
|
37 |
|
|
38 |
|
@link |
39 |
|
|
40 |
|
@version |
41 |
|
@since |
42 |
|
|
43 |
|
@Component |
44 |
|
@Named("tex/1.0") |
45 |
|
@InstantiationStrategy(ComponentInstantiationStrategy.PER_LOOKUP) |
|
|
| 85.2% |
Uncovered Elements: 4 (27) |
Complexity: 10 |
Complexity Density: 0.43 |
|
46 |
|
public class TexRenderer extends WrappingListener implements PrintRenderer |
47 |
|
{ |
48 |
|
|
49 |
|
|
50 |
|
|
51 |
|
private WikiPrinter printer; |
52 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
53 |
24 |
@Override... |
54 |
|
public WikiPrinter getPrinter() |
55 |
|
{ |
56 |
24 |
return this.printer; |
57 |
|
} |
58 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
59 |
12 |
@Override... |
60 |
|
public void setPrinter(WikiPrinter printer) |
61 |
|
{ |
62 |
12 |
this.printer = printer; |
63 |
12 |
setWrappedListener(new WikiModelGeneratorListener(new TexSerializer(new WikiModelPrinterAdapter(getPrinter()), |
64 |
|
null, null, null))); |
65 |
|
} |
66 |
|
|
|
|
| 83.3% |
Uncovered Elements: 2 (12) |
Complexity: 4 |
Complexity Density: 0.33 |
|
67 |
6 |
@Override... |
68 |
|
public void beginFormat(Format format, Map<String, String> parameters) |
69 |
|
{ |
70 |
6 |
switch (format) { |
71 |
3 |
case BOLD: |
72 |
3 |
this.printer.print("\\textbf{"); |
73 |
3 |
break; |
74 |
2 |
case ITALIC: |
75 |
2 |
this.printer.print("\\textit{"); |
76 |
2 |
break; |
77 |
1 |
case MONOSPACE: |
78 |
1 |
this.printer.print("\\texttt{"); |
79 |
1 |
break; |
80 |
0 |
default: |
81 |
|
|
82 |
0 |
break; |
83 |
|
} |
84 |
|
} |
85 |
|
|
|
|
| 75% |
Uncovered Elements: 2 (8) |
Complexity: 4 |
Complexity Density: 0.5 |
|
86 |
6 |
@Override... |
87 |
|
public void endFormat(Format format, Map<String, String> parameters) |
88 |
|
{ |
89 |
6 |
switch (format) { |
90 |
3 |
case BOLD: |
91 |
2 |
case ITALIC: |
92 |
1 |
case MONOSPACE: |
93 |
6 |
this.printer.print("}"); |
94 |
6 |
break; |
95 |
0 |
default: |
96 |
|
|
97 |
0 |
break; |
98 |
|
} |
99 |
|
} |
100 |
|
} |