Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER Copyright 2011 IBM. All rights reserved. Use is subject to license terms. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0. You can also obtain a copy of the License at http://odftoolkit.org/docs/license.txt Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. /
 
 package org.odftoolkit.simple.draw;
 
 import java.util.List;
 
AbstractTextboxContainer is an abstract implementation of the TextboxContainer interface, with a default implementation for every method defined in TextboxContainer, except getFrameContainerElement(). A subclass must implement the abstract method getFrameContainerElement().

Since:
0.5
 
 public abstract class AbstractTextboxContainer extends AbstractFrameContainer implements TextboxContainer {
 
 	public Textbox addTextbox() {
 		Textbox textbox = Textbox.newTextbox(this);
 		return textbox;
 	}

Remove the text box.

Parameters:
box - the text box to be removed
Returns:
true if the text box is removed successfully, false if errors happen.
 
 	public boolean removeTextbox(Textbox box) {
 		OdfElement containerElement = getFrameContainerElement();
 		DrawFrameElement drawFrame = box.getDrawFrameElement();
 		try {
 			drawFrame.removeChild(box.getOdfElement());
 			if (drawFrame.hasChildNodes() == false)
 				containerElement.removeChild(box.getDrawFrameElement());
 		} catch (DOMException exception) {
 			return false;
 		}
 		return true;
 	}
 
 		return new SimpleTextboxIterator(this);
 	}
 
 	public Textbox addTextbox(FrameRectangle position) {
 		Textbox textbox = Textbox.newTextbox(this);
 		textbox.setRectangle(position);
 		return textbox;
 	}

Return a text box whose name is a given value.

Parameters:
name - the name of the text box
Returns:
a text box whose name is a given value
See also:
AbstractFrameContainer.getFrameByName(java.lang.String)
 
 	public Textbox getTextboxByName(String name) {
 		Frame frame = getFrameByName(name);
 		if (frame != null) {
 			DrawTextBoxElement boxElement = OdfElement.findFirstChildNode(DrawTextBoxElement.classframe
 			if (boxElement != null) {
 				Textbox box = Textbox.getInstanceof(boxElement);
 				box.mFrameContainer = frame.mFrameContainer;
				return box;
			}
		}
		return null;
	}

This method is only useful for presentation slides.

This method will return a list of text boxs by the usage defined in presentation slides.

Parameters:
usage - the usage description
Returns:
a list of text box Null will be returned if the owner document is not a presentation
See also:
AbstractFrameContainer.getFrameByPresentationclass(org.odftoolkit.simple.PresentationDocument.PresentationClass)
org.odftoolkit.simple.PresentationDocument.PresentationClass
		List<FrameframeList = getFrameByPresentationclass(usage);
		if (frameList == null)
			return null;
		for (int i = 0; i < frameList.size(); i++) {
			Frame frame = frameList.get(i);
			DrawTextBoxElement boxElement = OdfElement.findFirstChildNode(DrawTextBoxElement.classframe
			if (boxElement != null) {
				Textbox box = Textbox.getInstanceof(boxElement);
				box.mFrameContainer = frame.mFrameContainer;
				al.add(box);
			}
		}
		return al;
	}
	private class SimpleTextboxIterator implements Iterator<Textbox> {
		private Textbox nextElement = null;
		private Textbox tempElement = null;
		}
		public boolean hasNext() {
			return ( != null);
		}
		public Textbox next() {
			if ( != null) {
				 = null;
else {
			}
			if ( == null) {
				return null;
else {
				return ;
			}
		}
		public void remove() {
			if ( == null) {
				throw new IllegalStateException("please call next() first.");
			}
		}
		private Textbox findNext(Textbox thisBox) {
			DrawFrameElement nextFrame = null;
			if (thisBox == null) {
				nextFrame = OdfElement.findFirstChildNode(DrawFrameElement.class);
else {
				nextFrame = OdfElement.findNextChildNode(DrawFrameElement.classthisBox.getDrawFrameElement());
			}
			if (nextFrame != null) {
				DrawTextBoxElement nextbox = OdfElement.findFirstChildNode(DrawTextBoxElement.classnextFrame);
				return Textbox.getInstanceof(nextbox);
			}
			return null;
		}
	}
New to GrepCode? Check out our FAQ X