Package org.apache.fop.fo

Examples of org.apache.fop.fo.RecursiveCharIterator


         * True if the last non white space char seen was a linefeed.
         * We start from the beginning of a line so it defaults to True.
         */
        boolean prevWasLF = true;

        RecursiveCharIterator charIter =
          new RecursiveCharIterator(this, firstInlineChild);
        EOLchecker lfCheck = new EOLchecker(charIter);

        while (charIter.hasNext()) {
            char currentChar = charIter.nextChar();
            int currentCharClass = CharUtilities.classOf(currentChar);
            if (currentCharClass == CharUtilities.LINEFEED
                && linefeedTreatment == EN_TREAT_AS_SPACE) {
                // if we have a linefeed and it is suppose to be treated
                // like a space, that's what we do and continue
                currentChar = ' ';
                charIter.replaceChar(' ');
                currentCharClass = CharUtilities.classOf(currentChar);
            }
            switch (CharUtilities.classOf(currentChar)) {
                case CharUtilities.XMLWHITESPACE:
                    /* Some kind of whitespace character, except linefeed. */
                    if (inWS && whiteSpaceCollapse == EN_TRUE) {
                        // We are in a run of whitespace and should collapse
                        // Just delete the char
                        charIter.remove();
                    } else {
                        // Do the white space treatment here
                        boolean bIgnore = false;

                        switch (whiteSpaceTreatment) {
                            case Constants.EN_IGNORE:
                                bIgnore = true;
                                break;
                            case Constants.EN_IGNORE_IF_BEFORE_LINEFEED:
                                bIgnore = linefeedTreatment == Constants.EN_PRESERVE
                                            && lfCheck.nextIsLF();
                                break;
                            case Constants.EN_IGNORE_IF_SURROUNDING_LINEFEED:
                                bIgnore = (prevWasLF
                                           || (linefeedTreatment == Constants.EN_PRESERVE
                                               && lfCheck.nextIsLF()));
                                break;
                            case Constants.EN_IGNORE_IF_AFTER_LINEFEED:
                                bIgnore = prevWasLF;
                                break;
                            case Constants.EN_PRESERVE:
                                // nothing to do now, replacement takes place later
                                break;
                        }
                        // Handle ignore and replacement
                        if (bIgnore) {
                            charIter.remove();
                        } else {
                            // this is to retain a single space between words
                            inWS = true;
                            if (currentChar != '\u0020') {
                                charIter.replaceChar('\u0020');
                            }
                        }
                    }
                    break;

                case CharUtilities.LINEFEED:
                    /* A linefeed */
                    switch (linefeedTreatment) {
                        case Constants.EN_IGNORE:
                            charIter.remove();
                            break;
                        case Constants.EN_TREAT_AS_ZERO_WIDTH_SPACE:
                            charIter.replaceChar(CharUtilities.ZERO_WIDTH_SPACE);
                            inWS = false;
                            break;
                        case Constants.EN_PRESERVE:
                            lfCheck.reset();
                            inWS = false;
View Full Code Here


         * True if the last non white space char seen was a linefeed.
         * We start from the beginning of a line so it defaults to True.
         */
        boolean prevWasLF = true;

        RecursiveCharIterator charIter =
          new RecursiveCharIterator(this, firstInlineChild);
        EOLchecker lfCheck = new EOLchecker(charIter);

        while (charIter.hasNext()) {
            char currentChar = charIter.nextChar();
            int currentCharClass = CharUtilities.classOf(currentChar);
            if (currentCharClass == CharUtilities.LINEFEED
                && linefeedTreatment == EN_TREAT_AS_SPACE) {
                // if we have a linefeed and it is suppose to be treated
                // like a space, that's what we do and continue
                currentChar = ' ';
                charIter.replaceChar(' ');
                currentCharClass = CharUtilities.classOf(currentChar);
            }
            switch (CharUtilities.classOf(currentChar)) {
                case CharUtilities.XMLWHITESPACE:
                    /* Some kind of whitespace character, except linefeed. */
                    if (inWS && whiteSpaceCollapse == EN_TRUE) {
                        // We are in a run of whitespace and should collapse
                        // Just delete the char
                        charIter.remove();
                    } else {
                        // Do the white space treatment here
                        boolean bIgnore = false;

                        switch (whiteSpaceTreatment) {
                            case Constants.EN_IGNORE:
                                bIgnore = true;
                                break;
                            case Constants.EN_IGNORE_IF_BEFORE_LINEFEED:
                                bIgnore = linefeedTreatment == Constants.EN_PRESERVE
                                            && lfCheck.nextIsLF();
                                break;
                            case Constants.EN_IGNORE_IF_SURROUNDING_LINEFEED:
                                bIgnore = (prevWasLF
                                           || (linefeedTreatment == Constants.EN_PRESERVE
                                               && lfCheck.nextIsLF()));
                                break;
                            case Constants.EN_IGNORE_IF_AFTER_LINEFEED:
                                bIgnore = prevWasLF;
                                break;
                            case Constants.EN_PRESERVE:
                                // nothing to do now, replacement takes place later
                                break;
                        }
                        // Handle ignore and replacement
                        if (bIgnore) {
                            charIter.remove();
                        } else {
                            // this is to retain a single space between words
                            inWS = true;
                            if (currentChar != '\u0020') {
                                charIter.replaceChar('\u0020');
                            }
                        }
                    }
                    break;

                case CharUtilities.LINEFEED:
                    /* A linefeed */
                    switch (linefeedTreatment) {
                        case Constants.EN_IGNORE:
                            charIter.remove();
                            break;
                        case Constants.EN_TREAT_AS_ZERO_WIDTH_SPACE:
                            charIter.replaceChar(CharUtilities.ZERO_WIDTH_SPACE);
                            inWS = false;
                            break;
                        case Constants.EN_PRESERVE:
                            lfCheck.reset();
                            inWS = false;
View Full Code Here

TOP

Related Classes of org.apache.fop.fo.RecursiveCharIterator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.