Source Code Cross Referenced for RtfListItem.java in  » PDF » pdf-itext » com » lowagie » text » rtf » list » 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 » PDF » pdf itext » com.lowagie.text.rtf.list 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id: RtfListItem.java 2811 2007-05-31 18:51:52Z hallm $
003:         * $Name:  $
004:         *
005:         * Copyright 2001, 2002, 2003, 2004, 2005 by Mark Hall
006:         *
007:         * The contents of this file are subject to the Mozilla Public License Version 1.1
008:         * (the "License"); you may not use this file except in compliance with the License.
009:         * You may obtain a copy of the License at http://www.mozilla.org/MPL/
010:         *
011:         * Software distributed under the License is distributed on an "AS IS" basis,
012:         * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
013:         * for the specific language governing rights and limitations under the License.
014:         *
015:         * The Original Code is 'iText, a free JAVA-PDF library'.
016:         *
017:         * The Initial Developer of the Original Code is Bruno Lowagie. Portions created by
018:         * the Initial Developer are Copyright (C) 1999, 2000, 2001, 2002 by Bruno Lowagie.
019:         * All Rights Reserved.
020:         * Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer
021:         * are Copyright (C) 2000, 2001, 2002 by Paulo Soares. All Rights Reserved.
022:         *
023:         * Contributor(s): all the names of the contributors are added in the source code
024:         * where applicable.
025:         *
026:         * Alternatively, the contents of this file may be used under the terms of the
027:         * LGPL license (the ?GNU LIBRARY GENERAL PUBLIC LICENSE?), in which case the
028:         * provisions of LGPL are applicable instead of those above.  If you wish to
029:         * allow use of your version of this file only under the terms of the LGPL
030:         * License and not to allow others to use your version of this file under
031:         * the MPL, indicate your decision by deleting the provisions above and
032:         * replace them with the notice and other provisions required by the LGPL.
033:         * If you do not delete the provisions above, a recipient may use your version
034:         * of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE.
035:         *
036:         * This library is free software; you can redistribute it and/or modify it
037:         * under the terms of the MPL as stated above or under the terms of the GNU
038:         * Library General Public License as published by the Free Software Foundation;
039:         * either version 2 of the License, or any later version.
040:         *
041:         * This library is distributed in the hope that it will be useful, but WITHOUT
042:         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
043:         * FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more
044:         * details.
045:         *
046:         * If you didn't download this code from the following link, you should check if
047:         * you aren't using an obsolete version:
048:         * http://www.lowagie.com/iText/
049:         */
050:
051:        package com.lowagie.text.rtf.list;
052:
053:        import java.io.ByteArrayOutputStream;
054:        import java.io.IOException;
055:        import java.io.OutputStream;
056:
057:        import com.lowagie.text.ListItem;
058:        import com.lowagie.text.rtf.RtfBasicElement;
059:        import com.lowagie.text.rtf.document.RtfDocument;
060:        import com.lowagie.text.rtf.style.RtfParagraphStyle;
061:        import com.lowagie.text.rtf.text.RtfChunk;
062:        import com.lowagie.text.rtf.text.RtfParagraph;
063:
064:        /**
065:         * The RtfListItem acts as a wrapper for a ListItem.
066:         * 
067:         * @version $Id: RtfListItem.java 2811 2007-05-31 18:51:52Z hallm $
068:         * @author Mark Hall (mhall@edu.uni-klu.ac.at)
069:         * @author Thomas Bickel (tmb99@inode.at)
070:         */
071:        public class RtfListItem extends RtfParagraph {
072:
073:            /**
074:             * The RtfList this RtfListItem belongs to.
075:             */
076:            private RtfList parentList = null;
077:            /**
078:             * Whether this RtfListItem contains further RtfLists.
079:             */
080:            private boolean containsInnerList = false;
081:
082:            /**
083:             * Constructs a RtfListItem for a ListItem belonging to a RtfDocument.
084:             * 
085:             * @param doc The RtfDocument this RtfListItem belongs to.
086:             * @param listItem The ListItem this RtfListItem is based on.
087:             */
088:            public RtfListItem(RtfDocument doc, ListItem listItem) {
089:                super (doc, listItem);
090:            }
091:
092:            /**
093:             * Writes the content of this RtfListItem.
094:             * 
095:             * @return A byte array with the content of this RtfListItem.
096:             * @deprecated replaced by {@link #writeContent(OutputStream)}
097:             */
098:            public byte[] write() {
099:                ByteArrayOutputStream result = new ByteArrayOutputStream();
100:                try {
101:                    writeContent(result);
102:                } catch (IOException ioe) {
103:                    ioe.printStackTrace();
104:                }
105:                return result.toByteArray();
106:            }
107:
108:            /**
109:             * Writes the content of this RtfListItem.
110:             */
111:            public void writeContent(final OutputStream result)
112:                    throws IOException {
113:                if (this .paragraphStyle.getSpacingBefore() > 0) {
114:                    result.write(RtfParagraphStyle.SPACING_BEFORE);
115:                    result.write(intToByteArray(paragraphStyle
116:                            .getSpacingBefore()));
117:                }
118:                if (this .paragraphStyle.getSpacingAfter() > 0) {
119:                    result.write(RtfParagraphStyle.SPACING_AFTER);
120:                    result.write(intToByteArray(this .paragraphStyle
121:                            .getSpacingAfter()));
122:                }
123:                for (int i = 0; i < chunks.size(); i++) {
124:                    RtfBasicElement rtfElement = (RtfBasicElement) chunks
125:                            .get(i);
126:                    if (rtfElement instanceof  RtfChunk) {
127:                        ((RtfChunk) rtfElement).setSoftLineBreaks(true);
128:                    } else if (rtfElement instanceof  RtfList) {
129:                        result.write(RtfParagraph.PARAGRAPH);
130:                        this .containsInnerList = true;
131:                    }
132:                    //.result.write(rtfElement.write());
133:                    rtfElement.writeContent(result);
134:                    if (rtfElement instanceof  RtfList) {
135:                        result.write(this .parentList.writeListBeginning());
136:                        result.write("\\tab".getBytes());
137:                    }
138:                }
139:            }
140:
141:            /**
142:             * Returns the definition of the first list contained in this RtfListItem or
143:             * an empty byte array if no inner RtfLists exist.
144:             * 
145:             * @return The definition of the first inner RtfList or an empty byte array.
146:             * @deprecated replaced by {@link #writeDefinition(OutputStream)}
147:             */
148:            public byte[] writeDefinition() {
149:                for (int i = 0; i < chunks.size(); i++) {
150:                    RtfBasicElement rtfElement = (RtfBasicElement) chunks
151:                            .get(i);
152:                    if (rtfElement instanceof  RtfList) {
153:                        return ((RtfList) rtfElement).writeDefinition();
154:                    }
155:                }
156:                return new byte[0];
157:            }
158:
159:            /**
160:             * Writes the definition of the first element in this RtfListItem that is
161:             * an instanceof {@link RtfList} to the given stream.<br> 
162:             * If this item does not contain a {@link RtfList} element nothing is written
163:             * and the method returns <code>false</code>.
164:             * 
165:             * @param out destination stream
166:             * @return <code>true</code> if a RtfList definition was written, <code>false</code> otherwise
167:             * @throws IOException
168:             */
169:            public boolean writeDefinition(OutputStream out) throws IOException {
170:                for (int i = 0; i < chunks.size(); i++) {
171:                    RtfBasicElement rtfElement = (RtfBasicElement) chunks
172:                            .get(i);
173:                    if (rtfElement instanceof  RtfList) {
174:                        RtfList rl = (RtfList) rtfElement;
175:                        rl.writeDefinition(out);
176:                        return (true);
177:                    }
178:                }
179:                return (false);
180:            }
181:
182:            /**
183:             * Inherit the list settings from the parent list to RtfLists that
184:             * are contained in this RtfListItem.
185:             * 
186:             * @param listNumber The list number to inherit.
187:             * @param listLevel The list level to inherit.
188:             */
189:            public void inheritListSettings(int listNumber, int listLevel) {
190:                for (int i = 0; i < chunks.size(); i++) {
191:                    RtfBasicElement rtfElement = (RtfBasicElement) chunks
192:                            .get(i);
193:                    if (rtfElement instanceof  RtfList) {
194:                        ((RtfList) rtfElement).setListNumber(listNumber);
195:                        ((RtfList) rtfElement).setListLevel(listLevel);
196:                        ((RtfList) rtfElement).setParent(this .parentList);
197:                    }
198:                }
199:            }
200:
201:            /**
202:             * Correct the indentation of RtfLists in this RtfListItem by adding left/first line indentation
203:             * from the parent RtfList. Also calls correctIndentation on all child RtfLists.
204:             */
205:            protected void correctIndentation() {
206:                for (int i = 0; i < chunks.size(); i++) {
207:                    RtfBasicElement rtfElement = (RtfBasicElement) chunks
208:                            .get(i);
209:                    if (rtfElement instanceof  RtfList) {
210:                        ((RtfList) rtfElement).correctIndentation();
211:                    }
212:                }
213:            }
214:
215:            /**
216:             * Set the parent RtfList.
217:             * 
218:             * @param parentList The parent RtfList to use.
219:             */
220:            public void setParent(RtfList parentList) {
221:                this .parentList = parentList;
222:            }
223:
224:            /**
225:             * Gets whether this RtfListItem contains further RtfLists.
226:             * 
227:             * @return Whether this RtfListItem contains further RtfLists.
228:             */
229:            public boolean isContainsInnerList() {
230:                return this.containsInnerList;
231:            }
232:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.