Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER Copyright 2010 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.common.navigation;
 
Based on TextSelection, CellSelection updates table cell value and value type when the cell text is replaced by other content. This is a more complete realization than TextSelection for cell content replacement, which keeps the synchronization among cell value, value type and display text.

 
 public class CellSelection extends TextSelection {
 
 	private Cell mCell;

Constructor of CellSelection.

Parameters:
text the text content of this CellSelection
containerElement the paragraph element that contains this CellSelection
index the start index of the text content of the container element
cell the table cell which is selected
 
 	CellSelection(String textOdfElement containerElementint indexCell cell) {
 		super(textcontainerElementindex);
 		 = cell;
 	}

Replace the text content of selection with a new string. The cell value type will be updated as "string" after replacement.

 
 	public void replaceWith(String newTextthrows InvalidNavigationException {
 		super.replaceWith(newText);
 		if ( != null) {
 			// update mCell value and value type to string.
 			String text = .getDisplayText();
 		}
 	}

Replace the text content of selection with a new string. The cell value and value type will be updated follow by the rules which are designed in the CellValueAdapter.

Parameters:
newText the replace text String
adapter the CellValueAdapter used to adapt cell value and value type
Throws:
InvalidNavigationException if the selection is unavailable.
See also:
replaceWith(java.lang.String)
org.odftoolkit.simple.table.CellValueAdapter
 
 	public void advancedReplaceWith(String newTextCellValueAdapter adapterthrows InvalidNavigationException {
		super.replaceWith(newText);
		if ( != null) {
			// update mCell value and value type.
			.setDisplayText(textadapter);
		}
	}

Replace the text content of selection with a new string. The cell value and value type will be updated follow by the rules which are designed in the DefaultCellValueAdapter.

Parameters:
newText the replace text String
Throws:
InvalidNavigationException if the selection is unavailable.
See also:
org.odftoolkit.simple.table.DefaultCellValueAdapter
	public void advancedReplaceWith(String newTextthrows InvalidNavigationException {
	}

Get the selected table cell.

Returns:
the selected table cell
	public Cell getCell() {
		return ;
	}
New to GrepCode? Check out our FAQ X