org.docx4j.toc.TocFinder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of docx4j-core Show documentation
Show all versions of docx4j-core Show documentation
docx4j is a library which helps you to work with the Office Open
XML file format as used in docx
documents, pptx presentations, and xlsx spreadsheets.
/*
* Copyright 2013-2016, Plutext Pty Ltd.
*
* This file is part of docx4j.
docx4j is 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
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.docx4j.toc;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.JAXBElement;
import org.docx4j.TraversalUtil;
import org.docx4j.TraversalUtil.CallbackImpl;
import org.docx4j.XmlUtils;
import org.docx4j.wml.CTSdtDocPart;
import org.docx4j.wml.CTSimpleField;
import org.docx4j.wml.P;
import org.docx4j.wml.SdtBlock;
import org.docx4j.wml.SdtPr;
import org.docx4j.wml.SectPr;
import org.docx4j.wml.Text;
import org.jvnet.jaxb2_commons.ppp.Child;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Don't attempt to reuse this; create a new TocFinder object each time you invoke it.
*
*/
public class TocFinder extends CallbackImpl {
private static Logger log = LoggerFactory.getLogger(TocFinder.class);
SdtBlock tocSDT = null;
/**
* @return
* @since 3.3.1
*/
public SdtBlock getTocSDT() {
return tocSDT;
}
/**
* The first sectPr after the ToC, so we can
* calculate right tab setting
*/
SectPr sectPr = null;
/**
* Paragraphs before the ToC proper are preserved.
*/
List tocHeadingP = new ArrayList
();
String tocInstruction = null;
private SdtBlock currentSDT = null;
private boolean foundToC = false;
@Override
public List