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.transformation.macro; |
21 |
|
|
22 |
|
import java.util.Arrays; |
23 |
|
import java.util.Collections; |
24 |
|
import java.util.List; |
25 |
|
|
26 |
|
import javax.inject.Named; |
27 |
|
import javax.inject.Singleton; |
28 |
|
|
29 |
|
import org.xwiki.component.annotation.Component; |
30 |
|
import org.xwiki.rendering.block.Block; |
31 |
|
import org.xwiki.rendering.block.FormatBlock; |
32 |
|
import org.xwiki.rendering.block.WordBlock; |
33 |
|
import org.xwiki.rendering.block.match.ClassBlockMatcher; |
34 |
|
import org.xwiki.rendering.listener.Format; |
35 |
|
import org.xwiki.rendering.macro.AbstractNoParameterMacro; |
36 |
|
import org.xwiki.rendering.macro.MacroExecutionException; |
37 |
|
import org.xwiki.rendering.transformation.MacroTransformationContext; |
38 |
|
|
39 |
|
@Component |
40 |
|
@Named("testformatmacro") |
41 |
|
@Singleton |
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 3 |
Complexity Density: 0.6 |
|
42 |
|
public class TestFormatMacro extends AbstractNoParameterMacro |
43 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
44 |
8 |
public TestFormatMacro()... |
45 |
|
{ |
46 |
8 |
super("Format Macro"); |
47 |
8 |
setDefaultCategory("Test"); |
48 |
|
} |
49 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
50 |
5 |
@Override... |
51 |
|
public boolean supportsInlineMode() |
52 |
|
{ |
53 |
5 |
return true; |
54 |
|
} |
55 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
56 |
10 |
@Override... |
57 |
|
public List<Block> execute(Object parameters, String content, MacroTransformationContext context) |
58 |
|
throws MacroExecutionException |
59 |
|
{ |
60 |
10 |
int wordCount = context.getXDOM().getBlocks( |
61 |
|
new ClassBlockMatcher(WordBlock.class), Block.Axes.DESCENDANT).size(); |
62 |
10 |
return Arrays.<Block>asList(new FormatBlock(Arrays.<Block>asList( |
63 |
|
new WordBlock("formatmacro" + wordCount)), Format.NONE, Collections.singletonMap("param", "value"))); |
64 |
|
} |
65 |
|
} |