aboutsummaryrefslogtreecommitdiffstats
path: root/src/org/apache/fop/fo/flow/BidiOverride.java
blob: e23403339428010e83e3bdffdc06cdf1a5535996 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/*
 * $Id$
 * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
 * For details on use and redistribution please refer to the
 * LICENSE file included with these sources.
 */

package org.apache.fop.fo.flow;

// FOP
import org.apache.fop.fo.*;
import org.apache.fop.layout.AuralProps;
import org.apache.fop.layout.RelativePositionProps;
import org.apache.fop.fo.flow.*;
import org.apache.fop.fo.properties.*;
import org.apache.fop.apps.FOPException;

import org.apache.fop.layoutmgr.LeafNodeLayoutManager;
import org.apache.fop.layoutmgr.LayoutManager;
import org.apache.fop.area.inline.InlineArea;
import org.apache.fop.area.inline.Word;

import java.util.List;
import java.util.ArrayList;

/**
 */
public class BidiOverride extends FObjMixed {

    public BidiOverride(FONode parent) {
        super(parent);
    }

    public void addLayoutManager(List list) {
        if (false) {
            super.addLayoutManager(list);
        } else {
            ArrayList childList = new ArrayList();
            super.addLayoutManager(childList);
            for (int count = childList.size() - 1; count >= 0; count--) {
                LayoutManager lm = (LayoutManager) childList.get(count);
                if (lm.generatesInlineAreas()) {
                    list.add( new BidiLayoutManager(this,
                                                    (LeafNodeLayoutManager) lm));
                } else {
                    list.add(lm);
                }
            }
        }
    }

    public void setup() {

        // Common Aural Properties
        AuralProps mAurProps = propMgr.getAuralProps();

        // Common Font Properties
        //this.fontState = propMgr.getFontState(area.getFontInfo());

        // Common Margin Properties-Inline
        RelativePositionProps mProps = propMgr.getRelativePositionProps();

        // this.properties.get("color");
        // this.properties.get("direction");
        setupID();
        // this.properties.get("letter-spacing");
        // this.properties.get("line-height");
        // this.properties.get("line-height-shift-adjustment");
        // this.properties.get("score-spaces");
        // this.properties.get("text-shadow");
        // this.properties.get("text-transform");
        // this.properties.get("unicode-bidi");
        // this.properties.get("word-spacing");

    }

    protected boolean containsMarkers() {
        return true;
    }

    /**
     * If this bidi has a different writing mode direction
     * ltr or rtl than its parent writing mode then this
     * reverses the inline areas (at the character level).
     */
    class BidiLayoutManager extends LeafNodeLayoutManager {
        List childs;

        BidiLayoutManager(FObj obj, LeafNodeLayoutManager cLM) {
            super(obj);
            childs = new ArrayList();
/*            for (int count = cLM.size() - 1; count >= 0; count--) {
                InlineArea ia = cLM.get(count);
                if (ia instanceof Word) {
                    // reverse word
                    Word word = (Word) ia;
                    StringBuffer sb = new StringBuffer(word.getWord());
                    word.setWord(sb.reverse().toString());
                }
                childs.add(ia);
            }
*/        }

        public int size() {
            return childs.size();
        }

        public InlineArea get(int index) {
            return (InlineArea) childs.get(index);
        }
    }
}