Debian Codegraph @

texk/tex4htk/java/OomFilter.java

raw
1 package tex4ht;
2 /**********************************************************/
3 /* OomFilterImpl.java 2009-03-11-03:09 */
4 /* Copyright (C) 2006--2009 Eitan M. Gurari */
5 /* */
6 /* This work may be distributed and/or modified under the */
7 /* conditions of the LaTeX Project Public License, either */
8 /* version 1.3 of this license or (at your option) any */
9 /* later version. The latest version of this license is */
10 /* in */
11 /* http://www.latex-project.org/lppl.txt */
12 /* and version 1.3 or later is part of all distributions */
13 /* of LaTeX version 2003/12/01 or later. */
14 /* */
15 /* This work has the LPPL maintenance status "maintained".*/
16 /* */
17 /* This Current Maintainer of this work */
18 /* is Eitan M. Gurari. */
19 /* */
20 /* [email protected] */
21 /* http://www.cse.ohio-state.edu/~gurari */
22 /**********************************************************/
23
24
25 import org.xml.sax.helpers.*;
26 import org.xml.sax.*;
27 import java.io.PrintWriter;
28
29 public class OomFilter extends XMLFilterImpl {
30 PrintWriter out = null;
31 boolean mtext = false;
32 public OomFilter( PrintWriter out,
33 PrintWriter log, boolean trace ){
34 this.out = out;
35 }
36 public void startElement(String ns, String sName,
37 String qName, Attributes attr) {
38 if( qName.equals( "math:mtext" ) ){ mtext = true; }
39 try{
40 super.startElement(ns, sName, qName, attr);
41 } catch( Exception e ){
42 System.err.println( "--- OomFilter Error 1 --- " + e);
43 }
44 }
45 public void endElement(String ns, String sName, String qName){
46 if( qName.equals( "math:mtext" ) ){ mtext = false; }
47 try{
48 super.endElement(ns, sName, qName);
49 } catch( Exception e ){
50 System.err.println( "--- OomFilter Error 2 --- " + e);
51 } }
52 public void characters(char[] ch, int start, int length){
53 try{
54 if ( mtext ) {
55 for(int i = start; i<start+length; i++){
56 if( ch[i] == 160 ){ ch[i] = ' '; }
57 } }
58 super.characters(ch, start, length);
59 } catch( Exception e ){
60 System.out.println( "--- OomFilter Error 3 --- " + e);
61 } } }
62