1. Project Clover database Sat Feb 2 2019 06:45:20 CET
  2. Package org.xwiki.rendering.internal.renderer.xhtml.image

File AnnotatedXHTMLImageRenderer.java

 

Coverage histogram

../../../../../../../img/srcFileCovDistChart10.png
0% of files have more coverage

Code metrics

0
7
3
1
83
40
3
0.43
2.33
3
1

Classes

Class Line # Actions
AnnotatedXHTMLImageRenderer 44 7 0% 3 0
1.0100%
 

Contributing tests

This file is covered by 21 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.image;
21   
22    import java.util.Map;
23   
24    import javax.inject.Inject;
25    import javax.inject.Named;
26   
27    import org.xwiki.component.annotation.Component;
28    import org.xwiki.component.annotation.InstantiationStrategy;
29    import org.xwiki.component.descriptor.ComponentInstantiationStrategy;
30    import org.xwiki.rendering.listener.reference.ResourceReference;
31    import org.xwiki.rendering.renderer.printer.XHTMLWikiPrinter;
32    import org.xwiki.rendering.renderer.reference.ResourceReferenceSerializer;
33   
34    /**
35    * Render images as XHTML, using annotations (see
36    * {@link org.xwiki.rendering.internal.renderer.xhtml.AnnotatedXHTMLRenderer} for more details).
37    *
38    * @version $Id: 0ccd08ce6bf78eddcb87a3d2eaa19912794c54f8 $
39    * @since 2.0M3
40    */
41    @Component
42    @Named("annotated")
43    @InstantiationStrategy(ComponentInstantiationStrategy.PER_LOOKUP)
 
44    public class AnnotatedXHTMLImageRenderer implements XHTMLImageRenderer
45    {
46    /**
47    * Used to print Image reference as XHTML comments.
48    */
49    @Inject
50    @Named("xhtmlmarker")
51    private ResourceReferenceSerializer xhtmlMarkerSerializer;
52   
53    /**
54    * The default XHTML Link Renderer that we're wrapping.
55    */
56    @Inject
57    private XHTMLImageRenderer defaultImageRenderer;
58   
 
59  26 toggle @Override
60    public void setXHTMLWikiPrinter(XHTMLWikiPrinter printer)
61    {
62  26 this.defaultImageRenderer.setXHTMLWikiPrinter(printer);
63    }
64   
 
65  52 toggle @Override
66    public XHTMLWikiPrinter getXHTMLWikiPrinter()
67    {
68  52 return this.defaultImageRenderer.getXHTMLWikiPrinter();
69    }
70   
 
71  26 toggle @Override
72    public void onImage(ResourceReference reference, boolean freestanding, Map<String, String> parameters)
73    {
74    // We need to save the image location in XML comment so that it can be reconstructed later on when moving
75    // from XHTML to wiki syntax.
76  26 StringBuilder builder = new StringBuilder("startimage:");
77  26 builder.append(this.xhtmlMarkerSerializer.serialize(reference));
78   
79  26 getXHTMLWikiPrinter().printXMLComment(builder.toString(), true);
80  26 this.defaultImageRenderer.onImage(reference, freestanding, parameters);
81  26 getXHTMLWikiPrinter().printXMLComment("stopimage");
82    }
83    }