1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.seasar.tuigwaa.plugin.basic;
17
18 import java.util.Iterator;
19 import java.util.List;
20
21 import org.seasar.tuigwaa.cms.core.CmsRequest;
22 import org.seasar.tuigwaa.cms.core.CmsResponse;
23 import org.seasar.tuigwaa.cms.core.wiki.base.VisitorUtils;
24 import org.seasar.tuigwaa.plugin.PluginException;
25 import org.seasar.tuigwaa.plugin.PluginRequest;
26
27 import com.lowagie.text.Chunk;
28 import com.lowagie.text.Font;
29 import com.lowagie.text.Phrase;
30
31 public class PdfColorPlugin extends ColorPlugin {
32
33 public Object doPDFView(CmsRequest request, CmsResponse response, PluginRequest prequest) throws PluginException {
34
35 String[] array = prequest.getArgs();
36 Object child = prequest.getChild();
37
38 if(array == null) return child;
39
40 if(array.length >= 1){
41
42 String colorstr = array[0];
43 String bgcolorstr = null;
44 if(array.length >= 2) bgcolorstr = array[1];
45
46
47 if(child instanceof Phrase){
48 Phrase p = (Phrase) child;
49 List list = p.getChunks();
50 if(list != null){
51 for(Iterator i = list.iterator();i.hasNext();){
52 Chunk c = (Chunk)i.next();
53 Font nf = new Font(c.font());
54 nf.setColor(VisitorUtils.getColorByString(colorstr,true));
55 if(bgcolorstr !=null)
56 c.setBackground(VisitorUtils.getColorByString(bgcolorstr,false));
57 c.setFont(nf);
58 }
59 }
60 }
61 }
62 return child;
63 }
64
65 }