Clover Coverage Report - XWiki Rendering - Parent POM 4.0-SNAPSHOT (Aggregated)
Coverage timestamp: Mon Mar 12 2012 18:03:13 CET
../../../../../../img/srcFileCovDistChart9.png 55% of files have more coverage
7   83   6   1.75
4   33   0.86   4
4     1.5  
1    
 
  AnnotatedXHTMLChainingRenderer       Line # 35 7 0% 6 2 86.7% 0.8666667
 
  (48)
 
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: dee4160c78a232883473e0a0a95c7902c8809e3f $
33    * @since 2.0M2
34    */
 
35    public class AnnotatedXHTMLChainingRenderer extends XHTMLChainingRenderer
36    {
37    private XHTMLMacroRenderer macroRenderer;
38   
39    /**
40    * @param linkRenderer the object to render link events into XHTML. This is done so that it's pluggable because link
41    * rendering depends on how the underlying system wants to handle it. For example for XWiki we check if
42    * the document exists, we get the document URL, etc.
43    * @param imageRenderer the object to render image events into XHTML. This is done so that it's pluggable because
44    * image rendering depends on how the underlying system wants to handle it. For example for XWiki we
45    * check if the image exists as a document attachments, we get its URL, etc.
46    * @param listenerChain the chain of listener filters used to compute various states
47    */
 
48  48 toggle public AnnotatedXHTMLChainingRenderer(XHTMLLinkRenderer linkRenderer,
49    XHTMLImageRenderer imageRenderer, ListenerChain listenerChain)
50    {
51  48 super(linkRenderer, imageRenderer, listenerChain);
52   
53  48 this.macroRenderer = new XHTMLMacroRenderer();
54    }
55   
 
56  8 toggle @Override
57    public void onMacro(String id, Map<String, String> parameters, String content, boolean isInline)
58    {
59    // Do not do any rendering but we still need to save the macro definition in some hidden XHTML
60    // so that the macro can be reconstructed when moving back from XHTML to XDOM.
61  8 this.macroRenderer.render(getXHTMLWikiPrinter(), id, parameters, content);
62    }
63   
 
64  12 toggle @Override
65    public void beginMacroMarker(String name, Map<String, String> parameters, String content, boolean isInline)
66    {
67  12 if (getBlockState().getMacroDepth() == 1) {
68    // Do not do any rendering but we still need to save the macro definition in some hidden XHTML
69    // so that the macro can be reconstructed when moving back from XHTML to XDOM.
70  12 this.macroRenderer.beginRender(getXHTMLWikiPrinter(), name, parameters, content);
71    }
72    }
73   
 
74  12 toggle @Override
75    public void endMacroMarker(String name, Map<String, String> parameters, String content, boolean isInline)
76    {
77  12 if (getBlockState().getMacroDepth() == 1) {
78    // Do not do any rendering but we still need to save the macro definition in some hidden XHTML
79    // so that the macro can be reconstructed when moving back from XHTML to XDOM.
80  12 this.macroRenderer.endRender(getXHTMLWikiPrinter());
81    }
82    }
83    }