KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > fop > render > rtf > rtflib > rtfdoc > RtfList


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18 /* $Id: RtfList.java 426576 2006-07-28 15:44:37Z jeremias $ */
19
20 package org.apache.fop.render.rtf.rtflib.rtfdoc;
21
22 /*
23  * This file is part of the RTF library of the FOP project, which was originally
24  * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and by other
25  * contributors to the jfor project (www.jfor.org), who agreed to donate jfor to
26  * the FOP project.
27  */

28
29 import java.io.Writer JavaDoc;
30 import java.io.IOException JavaDoc;
31 import java.util.Date JavaDoc;
32 import java.util.Random JavaDoc;
33
34 /**
35  * Model of an RTF list, which can contain RTF list items
36  * @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
37  * @author Christopher Scott, scottc@westinghouse.com
38  * @author Peter Herweg, pherweg@web.de
39  */

40 public class RtfList extends RtfContainer {
41     private RtfListItem item;
42     private RtfListTable listTable;
43     private final boolean hasTableParent;
44     private RtfListStyle defaultListStyle;
45     private Integer JavaDoc listTemplateId = null;
46     private Integer JavaDoc listId = null;
47     private static Random JavaDoc listIdGenerator = new Random JavaDoc(0);
48
49     /** Create an RTF list as a child of given container with given attributes */
50     RtfList(RtfContainer parent, Writer JavaDoc w, RtfAttributes attr) throws IOException JavaDoc {
51         super((RtfContainer)parent, w, attr);
52
53         //random number generator for ids
54
listId = new Integer JavaDoc(listIdGenerator.nextInt());
55         listTemplateId = new Integer JavaDoc(listIdGenerator.nextInt());
56
57         //create a new list table entry for the list
58
listTable = getRtfFile().startListTable(attr);
59         listTable.addList(this);
60
61         // find out if we are nested in a table
62
hasTableParent = this.getParentOfClass(RtfTable.class) != null;
63         
64         this.setRtfListStyle(new RtfListStyleBullet());
65     }
66
67     /**
68      * Close current list item and start a new one
69      * @return new RtfListItem
70      * @throws IOException for I/O problems
71      */

72     public RtfListItem newListItem() throws IOException JavaDoc {
73         if (item != null) {
74             item.close();
75         }
76         item = new RtfListItem(this, writer);
77         return item;
78     }
79
80     /**
81      * Returns the Id of the list.
82      * @return Id of the list
83      */

84     public Integer JavaDoc getListId() {
85         return listId;
86     }
87     
88     /**
89      * Returns the Id of the list template.
90      * @return Id of the list template
91      */

92     public Integer JavaDoc getListTemplateId() {
93         return listTemplateId;
94     }
95     
96     /**
97      * Change list style
98      * @param ls ListStyle to set
99      */

100     public void setRtfListStyle(RtfListStyle ls) {
101         defaultListStyle = ls;
102     }
103
104     /**
105      * Get list style
106      * @return ListSytle of the List
107      */

108     public RtfListStyle getRtfListStyle() {
109         return defaultListStyle;
110     }
111     
112     /**
113      * Returns true, if the list has a parent table.
114      * @return true, if the list has a parent table
115      */

116     public boolean getHasTableParent() {
117         return hasTableParent;
118     }
119 }
Popular Tags