org.odftoolkit.simple.style.TOCStyle Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of simple-odf Show documentation
Show all versions of simple-odf Show documentation
A simple API for easy manipulation of ODF documents.
The newest version!
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you 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
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.style;
import java.util.HashMap;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* This class represents the additional paragraph styles list that you want to
* include in the TOC.
*
* @since 0.8.6
*/
public class TOCStyle {
HashMap stylelist=new HashMap();
/**
* Create an instance of TOCStyle
* @param doc
*/
public TOCStyle() {
}
/**
* Add an additional paragraph style to the style list that you want to
* include in the TOC.
*
* @param styleName
* - the style name
* @param level
* - the outline level of this style, level value is: [1,10]
*/
public void addStyle(String styleName, int level) {
if ((level >= 1) && (level <= 10)) {
stylelist.put(level, styleName);
} else {
Logger.getLogger(TOCStyle.class.getName()).log(
Level.SEVERE,
"Outline level:" + level + " is out of range[1,10] "
+ "TOCStyle.addStyle failed.");
throw new RuntimeException("Outline level:" + level
+ " is out of range[1,10] " + "TOCStyle.addStyle failed.");
}
}
public HashMap getStyle(){
return stylelist;
}
@Override
public String toString() {
StringBuilder strBuilder = new StringBuilder();
int size=stylelist.size();
strBuilder.append("The additional paragraph styles list that you want to include in the TOC.\n");
for(int i=0;i