001: /*
002: * Copyright (c) 1998-2000 Caucho Technology -- all rights reserved
003: *
004: * This file is part of Resin(R) Open Source
005: *
006: * Each copy or derived work must preserve the copyright notice and this
007: * notice unmodified.
008: *
009: * Resin Open Source is free software; you can redistribute it and/or modify
010: * it under the terms of the GNU General Public License as published by
011: * the Free Software Foundation; either version 2 of the License, or
012: * (at your option) any later version.
013: *
014: * Resin Open Source is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
017: * of NON-INFRINGEMENT. See the GNU General Public License for more
018: * details.
019: *
020: * You should have received a copy of the GNU General Public License
021: * along with Resin Open Source; if not, write to the
022: *
023: * Free Software Foundation, Inc.
024: * 59 Temple Place, Suite 330
025: * Boston, MA 02111-1307 USA
026: *
027: * @author Emil Ong
028: */
029:
030: package com.caucho.xtpdoc;
031:
032: import com.caucho.config.Config;
033: import com.caucho.vfs.Path;
034: import com.caucho.vfs.Vfs;
035:
036: import java.io.IOException;
037: import java.io.PrintWriter;
038: import java.util.logging.Logger;
039:
040: public class LinkedChapterSection extends ChapterSection {
041: private static final Logger log = Logger.getLogger(Anchor.class
042: .getName());
043: private String _link;
044:
045: public void setLink(String link) {
046: _link = link;
047: }
048:
049: private Document configureDocument(Path xtpFile) {
050: Document document = new Document(xtpFile, null);
051:
052: try {
053: //org.w3c.dom.Node node = LooseToStrictHtml.looseToStrictHtml(xtpFile);
054:
055: Config config = new Config();
056:
057: config.configure(document, xtpFile);
058:
059: return document;
060: } catch (Exception e) {
061: System.err.println("Error configuring document (" + xtpFile
062: + "): " + e);
063:
064: if (e.getCause() != null)
065: e.getCause().printStackTrace();
066: else
067: e.printStackTrace();
068:
069: return null;
070: }
071: }
072:
073: public void writeLaTeX(PrintWriter out) throws IOException {
074: Path xtpFile = Vfs.lookup(_link);
075: Document document = configureDocument(xtpFile);
076:
077: try {
078: if (document != null)
079: document.writeLaTeX(out);
080: } catch (Exception e) {
081: System.err.println("Error configuring document (" + xtpFile
082: + "): " + e);
083:
084: if (e.getCause() != null)
085: e.getCause().printStackTrace();
086: else
087: e.printStackTrace();
088:
089: return;
090: }
091: }
092:
093: public void writeLaTeXEnclosed(PrintWriter out) throws IOException {
094: Path xtpFile = Vfs.lookup(_link);
095: Document document = configureDocument(xtpFile);
096:
097: try {
098: if (document != null)
099: document.writeLaTeXEnclosed(out);
100: } catch (Exception e) {
101: System.err.println("Error configuring document (" + xtpFile
102: + "): " + e);
103:
104: if (e.getCause() != null)
105: e.getCause().printStackTrace();
106: else
107: e.printStackTrace();
108:
109: return;
110: }
111: }
112: }
|