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.macro.footnote; |
21 |
|
|
22 |
|
import java.util.Collections; |
23 |
|
import java.util.List; |
24 |
|
|
25 |
|
import javax.inject.Named; |
26 |
|
import javax.inject.Singleton; |
27 |
|
|
28 |
|
import org.xwiki.component.annotation.Component; |
29 |
|
import org.xwiki.rendering.block.Block; |
30 |
|
import org.xwiki.rendering.block.MacroBlock; |
31 |
|
import org.xwiki.rendering.block.match.MacroBlockMatcher; |
32 |
|
import org.xwiki.rendering.macro.AbstractMacro; |
33 |
|
import org.xwiki.rendering.macro.MacroExecutionException; |
34 |
|
import org.xwiki.rendering.macro.descriptor.DefaultContentDescriptor; |
35 |
|
import org.xwiki.rendering.macro.footnote.FootnoteMacroParameters; |
36 |
|
import org.xwiki.rendering.transformation.MacroTransformationContext; |
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
@version |
43 |
|
@since |
44 |
|
|
45 |
|
@Component |
46 |
|
@Named(FootnoteMacro.MACRO_NAME) |
47 |
|
@Singleton |
|
|
| 76.5% |
Uncovered Elements: 4 (17) |
Complexity: 5 |
Complexity Density: 0.45 |
|
48 |
|
public class FootnoteMacro extends AbstractMacro<FootnoteMacroParameters> |
49 |
|
{ |
50 |
|
|
51 |
|
public static final String MACRO_NAME = "footnote"; |
52 |
|
|
53 |
|
|
54 |
|
private static final String DESCRIPTION = "Generates a footnote to display at the end of the page."; |
55 |
|
|
56 |
|
|
57 |
|
private static final String CONTENT_DESCRIPTION = "the text to place in the footnote"; |
58 |
|
|
59 |
|
|
60 |
|
@link |
61 |
|
|
62 |
|
private static final MacroBlockMatcher MACRO_BLOCK_MATCHER = new MacroBlockMatcher(PutFootnotesMacro.MACRO_NAME); |
63 |
|
|
64 |
|
|
65 |
|
|
66 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
67 |
2 |
public FootnoteMacro()... |
68 |
|
{ |
69 |
2 |
super("Footnote", DESCRIPTION, new DefaultContentDescriptor(CONTENT_DESCRIPTION), |
70 |
|
FootnoteMacroParameters.class); |
71 |
2 |
setDefaultCategory(DEFAULT_CATEGORY_CONTENT); |
72 |
|
} |
73 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
74 |
2 |
@Override... |
75 |
|
public boolean supportsInlineMode() |
76 |
|
{ |
77 |
2 |
return true; |
78 |
|
} |
79 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
80 |
0 |
@Override... |
81 |
|
public int getPriority() |
82 |
|
{ |
83 |
0 |
return 500; |
84 |
|
} |
85 |
|
|
|
|
| 77.8% |
Uncovered Elements: 2 (9) |
Complexity: 2 |
Complexity Density: 0.29 |
|
86 |
2 |
@Override... |
87 |
|
public List<Block> execute(FootnoteMacroParameters parameters, String content, MacroTransformationContext context) |
88 |
|
throws MacroExecutionException |
89 |
|
{ |
90 |
2 |
Block root = context.getXDOM(); |
91 |
|
|
92 |
2 |
Block matchingBlock = root.getFirstBlock(MACRO_BLOCK_MATCHER, Block.Axes.DESCENDANT); |
93 |
2 |
if (matchingBlock != null) { |
94 |
0 |
return Collections.emptyList(); |
95 |
|
} |
96 |
|
|
97 |
2 |
Block putFootnotesMacro = |
98 |
|
new MacroBlock(PutFootnotesMacro.MACRO_NAME, Collections.<String, String>emptyMap(), false); |
99 |
2 |
root.addChild(putFootnotesMacro); |
100 |
|
|
101 |
2 |
return Collections.emptyList(); |
102 |
|
} |
103 |
|
} |