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.text.list;
 
 
NumberDecorator is an implementation of the ListDecorator interface, decorates a given List as number list. User can extend this class and realize their own list and list item style. For example, set a specifies list item with red color.

A NumberDecorator can be reused in the same Document.

Since:
0.4
 
 public class NumberDecorator implements ListDecorator {
 
 	private static String[] DEFAULT_TEXT_SPACE_BEFORE_ATTRIBUTES = { null"0.501cm""1cm""1.501cm""2cm",
 			"2.501cm""3.001cm""3.502cm""4.001cm""4.502cm" };
 	private static String DEFAULT_TEXT_MIN_LABEL_WIDTH = "0.499cm";
 	private static String DEFAULT_FONT_NAME = "Tahoma";
 	private static String DEFAULT_NUM_FORMAT = "1";
 	private static String DEFAULT_NUM_SUFFIX = ".";
 	private static String DEFAULT_NAME = "Simple_Default_Number_List";
 
Constructor with Document.

Parameters:
doc the Document which this NumberDecorator will be used on.
 
 	public NumberDecorator(Document doc) {
 		OdfContentDom contentDocument;
 		try {
 			contentDocument = doc.getContentDom();
 			 = contentDocument.getAutomaticStyles();
 			OdfOfficeStyles documentStyles = doc.getDocumentStyles();
 			// create number style
 			if ( == null) {
 				// <style:style style:name="Numbering_20_Symbols"
 				// style:display-name="Numbering Symbols" style:family="text" />
 				getOrCreateStyleByName(documentStyles"Numbering_20_Symbols".);
 				for (int i = 0; i < 10; i++) {
 							i + 1);
 					// get from default style element
 					listLevelElement.setTextStyleNameAttribute("Numbering_20_Symbols");
 					StyleListLevelPropertiesElement styleListLevelPropertiesElement = listLevelElement
 						styleListLevelPropertiesElement
 					}
 					StyleTextPropertiesElement styleTextPropertiesElement = listLevelElement
					styleTextPropertiesElement.setStyleFontNameAttribute();
				}
				// listStyle.setStyleNameAttribute(DEFAULT_NAME);
			}
			// create default paragraph style
			// <style:style style:name="P3" style:family="paragraph"
			// style:parent-style-name="Default_20_Text"
			// style:list-style-name="L1"
			// />
			// <style:style style:name="Default_20_Text"
			// style:display-name="Default Text" style:family="paragraph"
			// style:class="text" />
			// <style:style style:name="Standard" style:family="paragraph"
			// style:class="text" />
			getOrCreateStyleByName(documentStyles"Default_20_Text".);
catch (Exception e) {
			Logger.getLogger(NumberDecorator.class.getName()).log(.nulle);
		}
	}
	public void decorateList(List list) {
		TextListElement listElement = list.getOdfElement();
	}
	public void decorateListItem(ListItem item) {
		TextListItemElement listItemElement = item.getOdfElement();
		Node child = listItemElement.getFirstChild();
		while (child != null) {
			if (child instanceof TextPElement) {
				TextPElement pElement = (TextPElementchild;
			}
			child = child.getNextSibling();
		}
	}
	public ListType getListType() {
	}
			String styleNameOdfStyleFamily styleFamily) {
		OdfStyle odfStyle = documentStyles.getStyle(styleNamestyleFamily);
		if (odfStyle == null) {
			styles.getStyle(styleNamestyleFamily);
		}
		if (odfStyle == null) {
			odfStyle = styles.newStyle(styleFamily);
			odfStyle.setStyleNameAttribute(styleName);
			odfStyle.setStyleDisplayNameAttribute(styleName);
		}
		return odfStyle;
	}
New to GrepCode? Check out our FAQ X