1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 package de.bea.domingo.proxy;
24
25 import java.util.ArrayList;
26 import java.util.Iterator;
27 import java.util.List;
28 import java.util.Vector;
29
30 import lotus.domino.EmbeddedObject;
31 import lotus.domino.NotesException;
32 import lotus.domino.RichTextItem;
33 import de.bea.domingo.DBase;
34 import de.bea.domingo.DEmbeddedObject;
35 import de.bea.domingo.DNotesMonitor;
36 import de.bea.domingo.DRichTextItem;
37
38 /***
39 * This class represents the Domino-Class <code>RichTextItem</code>.
40 *
41 * @author <a href=mailto:kriede@users.sourceforge.net>Kurt Riede</a>
42 */
43 public final class RichTextItemProxy extends BaseItemProxy implements DRichTextItem {
44
45 /*** serial version ID for serialization. */
46 private static final long serialVersionUID = 3257850978240969009L;
47
48 /***
49 * Constructor for DRichTextItemImpl.
50 *
51 * @param theFactory the controlling factory
52 * @param parent the parent object
53 * @param theRichTextItem the Notes TichTextItem
54 * @param monitor the monitor
55 */
56 protected RichTextItemProxy(final NotesProxyFactory theFactory, final DBase parent,
57 final RichTextItem theRichTextItem, final DNotesMonitor monitor) {
58 super(theFactory, parent, theRichTextItem, monitor);
59 }
60
61 /***
62 * {@inheritDoc}
63 * @see de.bea.domingo.DRichTextItem#embedAttachment(java.lang.String)
64 */
65 public DEmbeddedObject embedAttachment(final String path) {
66 getFactory().preprocessMethod();
67 try {
68 final RichTextItem richTextItem = (RichTextItem) getNotesObject();
69 final EmbeddedObject eo = richTextItem.embedObject(EmbeddedObject.EMBED_ATTACHMENT, "", path, "");
70 final DEmbeddedObject proxy = EmbeddedObjectProxy.getInstance(getFactory(), this, eo, getMonitor());
71 return proxy;
72 } catch (NotesException e) {
73 throw newRuntimeException("Cannot embed attachment", e);
74 }
75 }
76
77 /***
78 * {@inheritDoc}
79 * @see de.bea.domingo.DRichTextItem#getEmbeddedAttachment(java.lang.String)
80 */
81 public DEmbeddedObject getEmbeddedAttachment(final String fileName) {
82 getFactory().preprocessMethod();
83 try {
84 final RichTextItem richTextItem = (RichTextItem) getNotesObject();
85 final EmbeddedObject eo = richTextItem.getEmbeddedObject(fileName);
86 final DEmbeddedObject proxy = EmbeddedObjectProxy.getInstance(getFactory(), this, eo, getMonitor());
87 return proxy;
88 } catch (NotesException e) {
89 throw newRuntimeException("Cannot get attachment " + fileName, e);
90 }
91 }
92
93 /***
94 * {@inheritDoc}
95 * @see de.bea.domingo.DRichTextItem#getEmbeddedObjects()
96 */
97 public Iterator getEmbeddedObjects() {
98 getFactory().preprocessMethod();
99 try {
100 final Vector vector = ((RichTextItem) getNotesObject()).getEmbeddedObjects();
101 final List list = new ArrayList();
102 for (final Iterator it = vector.iterator(); it.hasNext();) {
103 final EmbeddedObject eo = (EmbeddedObject) it.next();
104 final DEmbeddedObject deo = EmbeddedObjectProxy.getInstance(getFactory(), this, eo, getMonitor());
105 list.add(deo);
106 }
107 return new EmbeddedObjectsIterator(list);
108 } catch (NotesException e) {
109 throw newRuntimeException("Cannot get embedded objects", e);
110 }
111 }
112
113 /***
114 * {@inheritDoc}
115 * @see de.bea.domingo.DRichTextItem#appendText(java.lang.String)
116 */
117 public void appendText(final String text) {
118 getFactory().preprocessMethod();
119 final RichTextItem richTextItem = (RichTextItem) getNotesObject();
120 try {
121 richTextItem.appendText(text);
122 } catch (NotesException e) {
123 throw newRuntimeException("Cannot append text", e);
124 }
125 }
126
127 /***
128 * {@inheritDoc}
129 * @see de.bea.domingo.DRichTextItem#addNewLine()
130 */
131 public void addNewLine() {
132 getFactory().preprocessMethod();
133 final RichTextItem richTextItem = (RichTextItem) getNotesObject();
134 try {
135 richTextItem.addNewLine();
136 } catch (NotesException e) {
137 throw newRuntimeException("Cannot add a new line", e);
138 }
139 }
140
141 /***
142 * {@inheritDoc}
143 * @see de.bea.domingo.DRichTextItem#addNewLine(int)
144 */
145 public void addNewLine(final int n) {
146 getFactory().preprocessMethod();
147 final RichTextItem richTextItem = (RichTextItem) getNotesObject();
148 try {
149 richTextItem.addNewLine(n);
150 } catch (NotesException e) {
151 throw newRuntimeException("Cannot add new lines", e);
152 }
153 }
154
155 /***
156 * {@inheritDoc}
157 * @see de.bea.domingo.DRichTextItem#addNewLine(int, boolean)
158 */
159 public void addNewLine(final int n, final boolean newparagraph) {
160 getFactory().preprocessMethod();
161 final RichTextItem richTextItem = (RichTextItem) getNotesObject();
162 try {
163 richTextItem.addNewLine(n, newparagraph);
164 } catch (NotesException e) {
165 throw newRuntimeException("Cannot add new lines", e);
166 }
167 }
168
169 /***
170 * {@inheritDoc}
171 * @see de.bea.domingo.DRichTextItem#addTab()
172 */
173 public void addTab() {
174 getFactory().preprocessMethod();
175 final RichTextItem richTextItem = (RichTextItem) getNotesObject();
176 try {
177 richTextItem.addTab();
178 } catch (NotesException e) {
179 throw newRuntimeException("Cannot add tab", e);
180 }
181 }
182
183 /***
184 * {@inheritDoc}
185 * @see de.bea.domingo.DRichTextItem#addTab(int)
186 */
187 public void addTab(final int count) {
188 getFactory().preprocessMethod();
189 final RichTextItem richTextItem = (RichTextItem) getNotesObject();
190 try {
191 richTextItem.addTab(count);
192 } catch (NotesException e) {
193 throw newRuntimeException("Cannot add tabs", e);
194 }
195 }
196
197 /***
198 * {@inheritDoc}
199 * @see de.bea.domingo.DRichTextItem#getUnformattedText()
200 */
201 public String getUnformattedText() {
202 getFactory().preprocessMethod();
203 final RichTextItem richTextItem = (RichTextItem) getNotesObject();
204 try {
205 return richTextItem.getUnformattedText();
206 } catch (NotesException e) {
207 throw newRuntimeException("Cannot get unformatted text", e);
208 }
209 }
210
211
212
213
214
215 /***
216 * A <code>EmbeddedObjectsIterator</code> allows iteration over a set of
217 * <code>lotus.domino.EmbeddedObject</code>.
218 *
219 * #see de.bea.domingo.DEmbeddedObject
220 *
221 * @author <a href=mailto:kriede@users.sourceforge.net>Kurt Riede</a>
222 */
223 protected static final class EmbeddedObjectsIterator implements Iterator {
224
225 /*** The iterator of the notes items.*/
226 private final Iterator embeddedObjectsIterator;
227
228 /***
229 * Constructs an Iterator by use of a vector of
230 * <code>lotus.domino.EmbeddedObject</code>s.
231 *
232 * @param embeddedObjects a vector of <code>lotus.domino.EmbeddedObject</code>s
233 */
234 protected EmbeddedObjectsIterator(final List embeddedObjects) {
235 this.embeddedObjectsIterator = embeddedObjects.iterator();
236 }
237
238 /***
239 * Indicates whether this iterator has a next element or not.
240 *
241 * @return boolean true if there is a next
242 */
243 public boolean hasNext() {
244 return embeddedObjectsIterator.hasNext();
245 }
246
247 /***
248 * Returns the next element of this iterator (hasNext()==true)
249 * or <code>null</code> if hasNext()==false.
250 *
251 * @return an <code>DEmbeddedObject</code>
252 */
253 public Object next() {
254 return embeddedObjectsIterator.next();
255 }
256
257 /***
258 * Throws an UnsupportedOperationException: The <tt>remove</tt>
259 * operation is not supported by this Iterator.
260 */
261 public void remove() {
262 throw new UnsupportedOperationException();
263 }
264 }
265 }