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

File AnnotatedXHTMLChainingRenderer.java

 

Coverage histogram

../../../../../../img/srcFileCovDistChart9.png
38% of files have more coverage

Code metrics

4
7
4
1
86
34
6
0.86
1.75
4
1.5

Classes

Class Line # Actions
AnnotatedXHTMLChainingRenderer 35 7 0% 6 2
0.866666786.7%
 

Contributing tests

This file is covered by 92 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.internal.renderer.xhtml;
21   
22    import java.util.Map;
23   
24    import org.xwiki.rendering.internal.renderer.xhtml.image.XHTMLImageRenderer;
25    import org.xwiki.rendering.internal.renderer.xhtml.link.XHTMLLinkRenderer;
26    import org.xwiki.rendering.listener.chaining.ListenerChain;
27   
28    /**
29    * Convert listener events to annotated XHTML. See {@link AnnotatedXHTMLChainingRenderer} for more details on
30    * what Annotated XHTML is.
31    *
32    * @version $Id: b75b78ac5120114ea6e35cb66285df5e15e2ee07 $
33    * @since 2.0M2
34    */
 
35    public class AnnotatedXHTMLChainingRenderer extends XHTMLChainingRenderer
36    {
37    /**
38    * Renders a Macro definition into Annotated XHTML.
39    */
40    private XHTMLMacroRenderer macroRenderer;
41   
42    /**
43    * @param linkRenderer the object to render link events into XHTML. This is done so that it's pluggable because link
44    * rendering depends on how the underlying system wants to handle it. For example for XWiki we check if
45    * the document exists, we get the document URL, etc.
46    * @param imageRenderer the object to render image events into XHTML. This is done so that it's pluggable because
47    * image rendering depends on how the underlying system wants to handle it. For example for XWiki we
48    * check if the image exists as a document attachments, we get its URL, etc.
49    * @param listenerChain the chain of listener filters used to compute various states
50    */
 
51  114 toggle public AnnotatedXHTMLChainingRenderer(XHTMLLinkRenderer linkRenderer,
52    XHTMLImageRenderer imageRenderer, ListenerChain listenerChain)
53    {
54  114 super(linkRenderer, imageRenderer, listenerChain);
55   
56  114 this.macroRenderer = new XHTMLMacroRenderer();
57    }
58   
 
59  9 toggle @Override
60    public void onMacro(String id, Map<String, String> parameters, String content, boolean inline)
61    {
62    // Do not do any rendering but we still need to save the macro definition in some hidden XHTML
63    // so that the macro can be reconstructed when moving back from XHTML to XDOM.
64  9 this.macroRenderer.render(getXHTMLWikiPrinter(), id, parameters, content);
65    }
66   
 
67  13 toggle @Override
68    public void beginMacroMarker(String name, Map<String, String> parameters, String content, boolean isInline)
69    {
70  13 if (getBlockState().getMacroDepth() == 1) {
71    // Do not do any rendering but we still need to save the macro definition in some hidden XHTML
72    // so that the macro can be reconstructed when moving back from XHTML to XDOM.
73  13 this.macroRenderer.beginRender(getXHTMLWikiPrinter(), name, parameters, content);
74    }
75    }
76   
 
77  13 toggle @Override
78    public void endMacroMarker(String name, Map<String, String> parameters, String content, boolean isInline)
79    {
80  13 if (getBlockState().getMacroDepth() == 1) {
81    // Do not do any rendering but we still need to save the macro definition in some hidden XHTML
82    // so that the macro can be reconstructed when moving back from XHTML to XDOM.
83  13 this.macroRenderer.endRender(getXHTMLWikiPrinter());
84    }
85    }
86    }