Source Code Cross Referenced for RtfListItem.java in  » Graphic-Library » fop » org » apache » fop » render » rtf » rtflib » rtfdoc » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Graphic Library » fop » org.apache.fop.render.rtf.rtflib.rtfdoc 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         * 
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         * 
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:
018:        /* $Id: RtfListItem.java 426576 2006-07-28 15:44:37Z jeremias $ */
019:
020:        package org.apache.fop.render.rtf.rtflib.rtfdoc;
021:
022:        /*
023:         * This file is part of the RTF library of the FOP project, which was originally
024:         * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and by other
025:         * contributors to the jfor project (www.jfor.org), who agreed to donate jfor to
026:         * the FOP project.
027:         */
028:
029:        import java.io.Writer;
030:        import java.io.IOException;
031:
032:        import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTextrun;
033:
034:        /**  Model of an RTF list item, which can contain RTF paragraphs
035:         *  @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
036:         *  @author Andreas Putz a.putz@skynamics.com
037:         */
038:        public class RtfListItem extends RtfContainer implements 
039:                IRtfTextrunContainer, IRtfListContainer, IRtfParagraphContainer {
040:
041:            private RtfList parentList;
042:            private RtfParagraph paragraph;
043:            private RtfListStyle listStyle;
044:            private int number = 0;
045:
046:            /** 
047:             * special RtfParagraph that writes list item setup code before its content
048:             */
049:            private class RtfListItemParagraph extends RtfParagraph {
050:
051:                RtfListItemParagraph(RtfListItem rli, RtfAttributes attrs)
052:                        throws IOException {
053:                    super (rli, rli.writer, attrs);
054:                }
055:
056:                protected void writeRtfPrefix() throws IOException {
057:                    super .writeRtfPrefix();
058:                    getRtfListStyle().writeParagraphPrefix(this );
059:                }
060:            }
061:
062:            /** 
063:             * special RtfTextrun that is used as list item label
064:             */
065:            public class RtfListItemLabel extends RtfTextrun implements 
066:                    IRtfTextrunContainer {
067:
068:                private RtfListItem rtfListItem;
069:
070:                /**
071:                 * Constructs the RtfListItemLabel
072:                 * @param item The RtfListItem the label belongs to
073:                 * @throws IOException Thrown when an IO-problem occurs
074:                 */
075:                public RtfListItemLabel(RtfListItem item) throws IOException {
076:                    super (null, item.writer, null);
077:
078:                    rtfListItem = item;
079:                }
080:
081:                /**
082:                 * Returns the current RtfTextrun object.
083:                 * Opens a new one if necessary.
084:                 * @return The RtfTextrun object
085:                 * @throws IOException Thrown when an IO-problem occurs
086:                 */
087:                public RtfTextrun getTextrun() throws IOException {
088:                    return this ;
089:                }
090:
091:                /**
092:                 * Sets the content of the list item label.
093:                 * @param s Content of the list item label.
094:                 * @throws IOException Thrown when an IO-problem occurs
095:                 */
096:                public void addString(String s) throws IOException {
097:
098:                    final String label = s.trim();
099:                    if (label.length() > 0
100:                            && Character.isDigit(label.charAt(0))) {
101:                        rtfListItem.setRtfListStyle(new RtfListStyleNumber());
102:                    } else {
103:                        rtfListItem
104:                                .setRtfListStyle(new RtfListStyleText(label));
105:                    }
106:                }
107:            }
108:
109:            /** Create an RTF list item as a child of given container with default attributes */
110:            RtfListItem(RtfList parent, Writer w) throws IOException {
111:                super ((RtfContainer) parent, w);
112:                parentList = parent;
113:            }
114:
115:            /**
116:             * Close current paragraph if any and start a new one
117:             * @param attrs attributes of new paragraph
118:             * @return new RtfParagraph
119:             * @throws IOException Thrown when an IO-problem occurs
120:             */
121:            public RtfParagraph newParagraph(RtfAttributes attrs)
122:                    throws IOException {
123:                if (paragraph != null) {
124:                    paragraph.close();
125:                }
126:                paragraph = new RtfListItemParagraph(this , attrs);
127:                return paragraph;
128:            }
129:
130:            /**
131:             * Close current paragraph if any and start a new one with default attributes
132:             * @return new RtfParagraph
133:             * @throws IOException Thrown when an IO-problem occurs
134:             */
135:            public RtfParagraph newParagraph() throws IOException {
136:                return newParagraph(null);
137:            }
138:
139:            /** Create an RTF list item as a child of given container with given attributes */
140:            RtfListItem(RtfList parent, Writer w, RtfAttributes attr)
141:                    throws IOException {
142:                super ((RtfContainer) parent, w, attr);
143:                parentList = parent;
144:            }
145:
146:            /**
147:             * Get the current textrun.
148:             * @return current RtfTextrun object
149:             * @throws IOException Thrown when an IO-problem occurs
150:             */
151:            public RtfTextrun getTextrun() throws IOException {
152:                RtfTextrun textrun = RtfTextrun.getTextrun(this , writer, null);
153:                textrun.setRtfListItem(this );
154:                return textrun;
155:            }
156:
157:            /**
158:             * Start a new list after closing current paragraph, list and table
159:             * @param attrs attributes of new RftList object
160:             * @return new RtfList
161:             * @throws IOException for I/O problems
162:             */
163:            public RtfList newList(RtfAttributes attrs) throws IOException {
164:                RtfList list = new RtfList(this , writer, attrs);
165:                return list;
166:            }
167:
168:            /**
169:             * Overridden to setup the list: start a group with appropriate attributes
170:             * @throws IOException for I/O problems
171:             */
172:            protected void writeRtfPrefix() throws IOException {
173:
174:                // pard causes word97 (and sometimes 2000 too) to crash if the list is nested in a table
175:                if (!parentList.getHasTableParent()) {
176:                    writeControlWord("pard");
177:                }
178:
179:                writeOneAttribute(RtfText.LEFT_INDENT_FIRST, "360"); //attrib.getValue(RtfListTable.LIST_INDENT));
180:
181:                writeOneAttribute(RtfText.LEFT_INDENT_BODY, attrib
182:                        .getValue(RtfText.LEFT_INDENT_BODY));
183:
184:                // group for list setup info
185:                writeGroupMark(true);
186:
187:                writeStarControlWord("pn");
188:                //Modified by Chris Scott
189:                //fixes second line indentation
190:                getRtfListStyle().writeListPrefix(this );
191:
192:                writeGroupMark(false);
193:                writeOneAttribute(RtfListTable.LIST_NUMBER, new Integer(number));
194:            }
195:
196:            /**
197:             * End the list group
198:             * @throws IOException for I/O problems
199:             */
200:            protected void writeRtfSuffix() throws IOException {
201:                super .writeRtfSuffix();
202:
203:                /* reset paragraph defaults to make sure list ends
204:                 * but pard causes word97 (and sometimes 2000 too) to crash if the list
205:                 * is nested in a table
206:                 */
207:                if (!parentList.getHasTableParent()) {
208:                    writeControlWord("pard");
209:                }
210:
211:            }
212:
213:            /**
214:             * Change list style
215:             * @param ls ListStyle to set
216:             */
217:            public void setRtfListStyle(RtfListStyle ls) {
218:                listStyle = ls;
219:
220:                listStyle.setRtfListItem(this );
221:                number = getRtfFile().getListTable().addRtfListStyle(ls);
222:            }
223:
224:            /**
225:             * Get list style
226:             * @return ListSytle of the List
227:             */
228:            public RtfListStyle getRtfListStyle() {
229:                if (listStyle == null) {
230:                    return parentList.getRtfListStyle();
231:                } else {
232:                    return listStyle;
233:                }
234:            }
235:
236:            /**
237:             * Get the parent list.
238:             * @return the parent list
239:             */
240:            public RtfList getParentList() {
241:                return parentList;
242:            }
243:
244:            /**
245:             * Returns the list number
246:             * @return list number
247:             */
248:            public int getNumber() {
249:                return number;
250:            }
251:        }
w_ww___.j_av__a__2__s___.c_o_m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.