View | Details | Raw Unified | Return to bug 48548
Collapse All | Expand All

(-)src/java/org/apache/fop/render/AbstractRenderer.java (+246 lines)
Lines 28-33 Link Here
28
import java.util.Iterator;
28
import java.util.Iterator;
29
import java.util.List;
29
import java.util.List;
30
import java.util.Set;
30
import java.util.Set;
31
import java.util.Vector;
31
32
32
import org.w3c.dom.Document;
33
import org.w3c.dom.Document;
33
34
Lines 68-74 Link Here
68
import org.apache.fop.area.inline.WordArea;
69
import org.apache.fop.area.inline.WordArea;
69
import org.apache.fop.events.ResourceEventProducer;
70
import org.apache.fop.events.ResourceEventProducer;
70
import org.apache.fop.fo.Constants;
71
import org.apache.fop.fo.Constants;
72
import org.apache.fop.fo.flow.ChangeBar;
71
import org.apache.fop.fonts.FontInfo;
73
import org.apache.fop.fonts.FontInfo;
74
import org.apache.fop.traits.BorderProps;
72
75
73
/**
76
/**
74
 * Abstract base class for all renderers. The Abstract renderer does all the
77
 * Abstract base class for all renderers. The Abstract renderer does all the
Lines 108-113 Link Here
108
     */
111
     */
109
    protected int containingIPPosition = 0;
112
    protected int containingIPPosition = 0;
110
113
114
    /**
115
     * The "start edge" IP Position of the current column (for change bars)
116
     */
117
    protected int columnStartIPPosition = 0;
118
    
119
    /**
120
     * The "end edge" IP Position of the current column (for change bars)
121
     */
122
    protected int columnEndIPPosition = 0;
123
    
124
    /**
125
     * The "left" position of the current column (for change bars)
126
     */
127
    protected int columnLeftIPPosition = 0;
128
    
129
    /**
130
     * The "right" position of the current column (for change bars)
131
     */
132
    protected int columnRightIPPosition = 0;
133
    
134
    /**
135
     * The number of columns in the span (for change bars)
136
     */
137
    protected int columnCount = 0;
138
    
139
    /**
140
     * The index number of the current column (for change bars)
141
     */
142
    protected int columnNumber = 0;
143
    
144
    /**
145
     * Is binding on start edge of column?
146
     */
147
    protected boolean bindingOnStartEdge = false;
148
    
149
    /**
150
     * Is binding on end edge of column?
151
     */
152
    protected boolean bindingOnEndEdge = false;
153
    
154
    
155
    
111
    /** the currently active PageViewport */
156
    /** the currently active PageViewport */
112
    protected PageViewport currentPageViewport;
157
    protected PageViewport currentPageViewport;
113
158
Lines 403-412 Link Here
403
        int saveSpanBPPos = saveBPPos;
448
        int saveSpanBPPos = saveBPPos;
404
        for (int count = 0; count < spans.size(); count++) {
449
        for (int count = 0; count < spans.size(); count++) {
405
            span = (Span) spans.get(count);
450
            span = (Span) spans.get(count);
451
            columnCount = span.getColumnCount();
452
            
406
            for (int c = 0; c < span.getColumnCount(); c++) {
453
            for (int c = 0; c < span.getColumnCount(); c++) {
454
                columnNumber = c;
455
                
407
                NormalFlow flow = span.getNormalFlow(c);
456
                NormalFlow flow = span.getNormalFlow(c);
408
457
458
                int writingMode = mr.getParent().getWritingMode();
459
                int referenceOrientation = mr.getParent().getReferenceOrientation();
460
                
461
                
462
409
                if (flow != null) {
463
                if (flow != null) {
464
                    columnStartIPPosition = currentIPPosition;
465
                    columnEndIPPosition = currentIPPosition + flow.getIPD() + mr.getColumnGap();
466
                    
467
                    // if direction is right to left, then end is left, else end is right edge
468
                    // if orientation is portrait, then binding edge is on left edge for odd pages
469
                    // and on right edge for even pages
470
                    int pageIndex = currentPageViewport.getPageIndex();
471
                    CTM trans = currentPageViewport.getBodyRegion().getCTM();
472
                    
473
                    bindingOnStartEdge = false;
474
                    bindingOnEndEdge = false;
475
                    
476
                    if (writingMode == Constants.EN_RL_TB)
477
                    {
478
                        columnLeftIPPosition = columnEndIPPosition;
479
                        columnRightIPPosition = columnStartIPPosition;
480
                        if (0 == referenceOrientation) {
481
                            if (pageIndex % 2 == 0 ) {
482
                                bindingOnEndEdge = true;
483
                            }
484
                            else {
485
                                bindingOnStartEdge = true;
486
                            }
487
                        }
488
                    }
489
                    else
490
                    {
491
                        columnLeftIPPosition = columnStartIPPosition;
492
                        columnRightIPPosition = columnEndIPPosition;
493
                        if (0 == referenceOrientation) {
494
                            if (pageIndex % 2 == 0 ) {
495
                                bindingOnStartEdge = true;
496
                            }
497
                            else {
498
                                bindingOnEndEdge = true;
499
                            }
500
                        }
501
                    }
502
                    
503
504
 
505
                    
506
                    
410
                    currentBPPosition = saveSpanBPPos;
507
                    currentBPPosition = saveSpanBPPos;
411
                    renderFlow(flow);
508
                    renderFlow(flow);
412
                    currentIPPosition += flow.getIPD();
509
                    currentIPPosition += flow.getIPD();
Lines 555-560 Link Here
555
     * @param block  The block area
652
     * @param block  The block area
556
     */
653
     */
557
    protected void renderBlock(Block block) {
654
    protected void renderBlock(Block block) {
655
        Vector changeBars = block.getChangeBars();
656
        
657
        if (null != changeBars && !changeBars.isEmpty()) {
658
            // this block has change bars attached to it
659
            int saveIP = currentIPPosition;
660
            int saveBP = currentBPPosition;
661
            
662
            drawChangeBars(block, changeBars);
663
            
664
            currentIPPosition = saveIP;
665
            currentBPPosition = saveBP;
666
        }
667
        
558
        List children = block.getChildAreas();
668
        List children = block.getChildAreas();
559
        if (block instanceof BlockViewport) {
669
        if (block instanceof BlockViewport) {
560
            if (children != null) {
670
            if (children != null) {
Lines 616-621 Link Here
616
     * @param inlineArea inline area text to render
726
     * @param inlineArea inline area text to render
617
     */
727
     */
618
    protected void renderInlineArea(InlineArea inlineArea) {
728
    protected void renderInlineArea(InlineArea inlineArea) {
729
        Vector changeBars = inlineArea.getChangeBars();
730
        
731
        if (null != changeBars && !changeBars.isEmpty()) {
732
            // area has change bar, handle
733
            drawChangeBars(inlineArea, changeBars);
734
        }
735
        
619
        if (inlineArea instanceof TextArea) {
736
        if (inlineArea instanceof TextArea) {
620
            renderText((TextArea) inlineArea);
737
            renderText((TextArea) inlineArea);
621
        //} else if (inlineArea instanceof Character) {
738
        //} else if (inlineArea instanceof Character) {
Lines 758-763 Link Here
758
     * (todo) Make renderImage() protected
875
     * (todo) Make renderImage() protected
759
     */
876
     */
760
    public void renderImage(Image image, Rectangle2D pos) {
877
    public void renderImage(Image image, Rectangle2D pos) {
878
        // handle change bars
879
        Vector changeBars = image.getChangeBars();
880
        
881
        if (null != changeBars && ! changeBars.isEmpty()) {
882
            drawChangeBars(image, changeBars);
883
        }
761
        // Default: do nothing.
884
        // Default: do nothing.
762
        // Some renderers (ex. Text) don't support images.
885
        // Some renderers (ex. Text) don't support images.
763
    }
886
    }
Lines 784-789 Link Here
784
     * (todo) Make renderForeignObject() protected
907
     * (todo) Make renderForeignObject() protected
785
     */
908
     */
786
    protected void renderForeignObject(ForeignObject fo, Rectangle2D pos) {
909
    protected void renderForeignObject(ForeignObject fo, Rectangle2D pos) {
910
        // handle change bars
911
        Vector changeBars = fo.getChangeBars();
912
        
913
        if (null != changeBars && !changeBars.isEmpty()) {
914
            drawChangeBars(fo, changeBars);
915
        }
916
        
787
        // Default: do nothing.
917
        // Default: do nothing.
788
        // Some renderers (ex. Text) don't support foreign objects.
918
        // Some renderers (ex. Text) don't support foreign objects.
789
    }
919
    }
Lines 856-859 Link Here
856
        matrix[5] = Math.round(matrix[5] * 1000);
986
        matrix[5] = Math.round(matrix[5] * 1000);
857
        return new AffineTransform(matrix);
987
        return new AffineTransform(matrix);
858
    }
988
    }
989
    
990
    /**
991
     * Draw all change bars associated with an area
992
     * 
993
     * @param block  The area to draw change bars for
994
     * @param changeBars The list of change bars affecting the area
995
     */
996
    private void drawChangeBars(Area block, Vector changeBars) {
997
        Block cbArea;
998
        
999
        int saveIP = currentIPPosition;
1000
        int saveBP = currentBPPosition;
1001
        
1002
        for (int idx = 0; idx < changeBars.size(); idx++) {
1003
            ChangeBar bar = (ChangeBar)changeBars.get(idx);
1004
            cbArea = new Block();
1005
1006
            currentIPPosition = 0;
1007
            currentBPPosition = saveBP;
1008
            
1009
            // offset by default is negative width for change bars placed on the start edge
1010
            // this will be overriden if placement is at the end edge
1011
            // xScale is for adding or subtracting the offset of the change bar depending on
1012
            //  placing the bar towards or away from the edge it is bound to
1013
            int xOffset = -bar.getWidth().getValue();
1014
            int xScale = 1;
1015
            
1016
            // determine currentIPPosition based on placement
1017
            switch (bar.getPlacement()) {
1018
            case EN_START:
1019
                xOffset += columnStartIPPosition;
1020
                xScale = -1;
1021
                break;
1022
            case EN_END:
1023
                xOffset = columnEndIPPosition;
1024
                break;
1025
            case EN_LEFT:
1026
                xOffset += columnLeftIPPosition;
1027
                xScale = -1;
1028
                break;
1029
            case EN_RIGHT:
1030
                xOffset = columnRightIPPosition;
1031
                break;
1032
            case EN_INSIDE:
1033
                if (bindingOnStartEdge) {
1034
                    xOffset += columnStartIPPosition;
1035
                    xScale = -1;
1036
                }
1037
                else if (bindingOnEndEdge) {
1038
                    xOffset = columnEndIPPosition;
1039
                }
1040
                else {
1041
                    xOffset += columnStartIPPosition;
1042
                    xScale = -1;
1043
                }
1044
                break;
1045
            case EN_OUTSIDE:
1046
                if (bindingOnStartEdge) {
1047
                    xOffset = columnEndIPPosition;
1048
                }
1049
                else if (bindingOnEndEdge) {
1050
                    xOffset += columnStartIPPosition;
1051
                    xScale = -1;
1052
                }
1053
                else {
1054
                    xOffset += columnStartIPPosition;
1055
                    xScale = -1;
1056
                }               
1057
                break;
1058
            case EN_ALTERNATE:
1059
                if (2 == columnCount) {
1060
                    if ( 0 == columnNumber) {
1061
                        xOffset += columnStartIPPosition;
1062
                        xScale = -1;
1063
                    }
1064
                    else {
1065
                        xOffset = columnEndIPPosition;
1066
                    }
1067
                }
1068
                else {
1069
                    if (bindingOnStartEdge) {
1070
                        xOffset = columnEndIPPosition;
1071
                    }
1072
                    else if (bindingOnEndEdge) {
1073
                        xOffset += columnStartIPPosition;
1074
                        xScale = -1;
1075
                    }
1076
                    else {
1077
                        xOffset = columnStartIPPosition;
1078
                        xScale = -1;
1079
                    }   
1080
                }
1081
                break;
1082
            }
1083
1084
            // Change bar area has 0 ipd, class xsl-absolute, no margin or padding
1085
            cbArea.setAreaClass(Area.CLASS_ABSOLUTE);
1086
            cbArea.setIPD(0);
1087
            cbArea.setPositioning(Block.ABSOLUTE);
1088
            cbArea.setBPD(block.getBPD());
1089
            BorderProps props = new BorderProps(bar.getStyle(), bar.getWidth().getValue(),
1090
                    bar.getColor(), BorderProps.SEPARATE);
1091
1092
            cbArea.addTrait(Trait.BORDER_END, props);
1093
 
1094
            cbArea.setXOffset(xOffset + xScale * bar.getOffset().getValue());
1095
            cbArea.setYOffset(block.getSpaceBefore());
1096
1097
            renderBlock(cbArea);
1098
1099
            // restore position on page
1100
            currentIPPosition = saveIP;
1101
            currentBPPosition = saveBP;
1102
                       
1103
        }
1104
    }
859
}
1105
}
(-)src/java/org/apache/fop/layoutmgr/ExternalDocumentLayoutManager.java (-2 / +4 lines)
Lines 178-186 Link Here
178
        Dimension imageSize = this.imageLayout.getViewportSize();
178
        Dimension imageSize = this.imageLayout.getViewportSize();
179
179
180
        Block blockArea = new Block();
180
        Block blockArea = new Block();
181
        blockArea.setChangeBars(getChangeBars());
182
        
181
        blockArea.setIPD(imageSize.width);
183
        blockArea.setIPD(imageSize.width);
182
        LineArea lineArea = new LineArea();
184
        LineArea lineArea = new LineArea();
183
185
        
184
        Image imageArea = new Image(uri);
186
        Image imageArea = new Image(uri);
185
        TraitSetter.setProducerID(imageArea, fobj.getId());
187
        TraitSetter.setProducerID(imageArea, fobj.getId());
186
        transferForeignAttributes(imageArea);
188
        transferForeignAttributes(imageArea);
Lines 246-252 Link Here
246
        rv.setClip(true);
248
        rv.setClip(true);
247
249
248
        BodyRegion body = new BodyRegion(Constants.FO_REGION_BODY,
250
        BodyRegion body = new BodyRegion(Constants.FO_REGION_BODY,
249
                "fop-image-region", rv, 1, 0);
251
                "fop-image-region", rv, 1, 0, pageSeq.getReferenceOrientation(), pageSeq.getReferenceOrientation());
250
        body.setIPD(imageSize.width);
252
        body.setIPD(imageSize.width);
251
        body.setBPD(imageSize.height);
253
        body.setBPD(imageSize.height);
252
        body.setCTM(pageCTM);
254
        body.setCTM(pageCTM);
(-)src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java (+1 lines)
Lines 418-423 Link Here
418
    public Area getParentArea(Area childArea) {
418
    public Area getParentArea(Area childArea) {
419
        if (curBlockArea == null) {
419
        if (curBlockArea == null) {
420
            curBlockArea = new Block();
420
            curBlockArea = new Block();
421
           curBlockArea.setChangeBars(getChangeBars());
421
422
422
            curBlockArea.setIPD(super.getContentAreaIPD());
423
            curBlockArea.setIPD(super.getContentAreaIPD());
423
424
(-)src/java/org/apache/fop/layoutmgr/LayoutManagerMapping.java (+4 lines)
Lines 38-43 Link Here
38
import org.apache.fop.fo.flow.BidiOverride;
38
import org.apache.fop.fo.flow.BidiOverride;
39
import org.apache.fop.fo.flow.Block;
39
import org.apache.fop.fo.flow.Block;
40
import org.apache.fop.fo.flow.BlockContainer;
40
import org.apache.fop.fo.flow.BlockContainer;
41
import org.apache.fop.fo.flow.ChangeBarBegin;
42
import org.apache.fop.fo.flow.ChangeBarEnd;
41
import org.apache.fop.fo.flow.Character;
43
import org.apache.fop.fo.flow.Character;
42
import org.apache.fop.fo.flow.ExternalGraphic;
44
import org.apache.fop.fo.flow.ExternalGraphic;
43
import org.apache.fop.fo.flow.Footnote;
45
import org.apache.fop.fo.flow.Footnote;
Lines 141-146 Link Here
141
        registerMaker(TableHeader.class, new Maker());
143
        registerMaker(TableHeader.class, new Maker());
142
        registerMaker(Wrapper.class, new WrapperLayoutManagerMaker());
144
        registerMaker(Wrapper.class, new WrapperLayoutManagerMaker());
143
        registerMaker(Title.class, new InlineLayoutManagerMaker());
145
        registerMaker(Title.class, new InlineLayoutManagerMaker());
146
        registerMaker(ChangeBarBegin.class, new Maker());
147
        registerMaker(ChangeBarEnd.class, new Maker());
144
    }
148
    }
145
149
146
    /**
150
    /**
(-)src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java (+1 lines)
Lines 238-243 Link Here
238
    public Area getParentArea(Area childArea) {
238
    public Area getParentArea(Area childArea) {
239
        if (curBlockArea == null) {
239
        if (curBlockArea == null) {
240
            curBlockArea = new Block();
240
            curBlockArea = new Block();
241
            curBlockArea.setChangeBars(getChangeBars());
241
242
242
            // Set up dimensions
243
            // Set up dimensions
243
            // Must get dimensions from parent area
244
            // Must get dimensions from parent area
(-)src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java (+1 lines)
Lines 602-607 Link Here
602
    public Area getParentArea(Area childArea) {
602
    public Area getParentArea(Area childArea) {
603
        if (curBlockArea == null) {
603
        if (curBlockArea == null) {
604
            curBlockArea = new Block();
604
            curBlockArea = new Block();
605
            curBlockArea.setChangeBars(getChangeBars());
605
606
606
            // Set up dimensions
607
            // Set up dimensions
607
            /*Area parentArea =*/ parentLayoutManager.getParentArea(curBlockArea);
608
            /*Area parentArea =*/ parentLayoutManager.getParentArea(curBlockArea);
(-)src/java/org/apache/fop/layoutmgr/list/ListItemContentLayoutManager.java (+2 lines)
Lines 192-197 Link Here
192
    public Area getParentArea(Area childArea) {
192
    public Area getParentArea(Area childArea) {
193
        if (curBlockArea == null) {
193
        if (curBlockArea == null) {
194
            curBlockArea = new Block();
194
            curBlockArea = new Block();
195
            curBlockArea.setChangeBars(getChangeBars());
196
            
195
            curBlockArea.setPositioning(Block.ABSOLUTE);
197
            curBlockArea.setPositioning(Block.ABSOLUTE);
196
            // set position
198
            // set position
197
            curBlockArea.setXOffset(xoffset);
199
            curBlockArea.setXOffset(xoffset);
(-)src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java (+2 lines)
Lines 85-90 Link Here
85
        // get breaks then add areas to title
85
        // get breaks then add areas to title
86
        this.parentLM = pslm;
86
        this.parentLM = pslm;
87
        holder = new LineArea();
87
        holder = new LineArea();
88
        holder.setChangeBars(getChangeBars());
88
89
89
        //        setUserAgent(foTitle.getUserAgent());
90
        //        setUserAgent(foTitle.getUserAgent());
90
91
Lines 161-166 Link Here
161
        childContext.setIPDAdjust(0.0);
162
        childContext.setIPDAdjust(0.0);
162
        childLM.addAreas(posIter, childContext);
163
        childLM.addAreas(posIter, childContext);
163
        ((InlineArea)holder).setIPD(savedIPD);
164
        ((InlineArea)holder).setIPD(savedIPD);
165
        
164
    }
166
    }
165
167
166
    public int getStackingSize() {
168
    public int getStackingSize() {
(-)src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java (+3 lines)
Lines 201-209 Link Here
201
        InlineArea area;
201
        InlineArea area;
202
        if (hasInlineParent) {
202
        if (hasInlineParent) {
203
            area = new InlineParent();
203
            area = new InlineParent();
204
            area.setChangeBars(getChangeBars());
204
            area.setOffset(0);
205
            area.setOffset(0);
205
        } else {
206
        } else {
206
            area = new InlineBlockParent();
207
            area = new InlineBlockParent();
208
            area.setChangeBars(getChangeBars());
207
        }
209
        }
208
        if (fobj instanceof Inline) {
210
        if (fobj instanceof Inline) {
209
            TraitSetter.setProducerID(area, getInlineFO().getId());
211
            TraitSetter.setProducerID(area, getInlineFO().getId());
Lines 518-523 Link Here
518
        context.setFlags(LayoutContext.LAST_AREA, isLast);
520
        context.setFlags(LayoutContext.LAST_AREA, isLast);
519
        areaCreated = true;
521
        areaCreated = true;
520
        checkEndOfLayout(lastPos);
522
        checkEndOfLayout(lastPos);
523
        
521
    }
524
    }
522
525
523
    /** {@inheritDoc} */
526
    /** {@inheritDoc} */
(-)src/java/org/apache/fop/layoutmgr/inline/WrapperLayoutManager.java (+3 lines)
Lines 68-83 Link Here
68
            if (parentLayoutManager instanceof BlockStackingLayoutManager
68
            if (parentLayoutManager instanceof BlockStackingLayoutManager
69
                    && !(parentLayoutManager instanceof BlockLayoutManager)) {
69
                    && !(parentLayoutManager instanceof BlockLayoutManager)) {
70
                Block helperBlock = new Block();
70
                Block helperBlock = new Block();
71
                helperBlock.setChangeBars(getChangeBars());
71
                TraitSetter.setProducerID(helperBlock, fobj.getId());
72
                TraitSetter.setProducerID(helperBlock, fobj.getId());
72
                parentLayoutManager.addChildArea(helperBlock);
73
                parentLayoutManager.addChildArea(helperBlock);
73
            } else {
74
            } else {
74
                InlineArea area = getEffectiveArea();
75
                InlineArea area = getEffectiveArea();
76
                area.setChangeBars(getChangeBars());
75
                parentLayoutManager.addChildArea(area);
77
                parentLayoutManager.addChildArea(area);
76
            }
78
            }
77
        }
79
        }
78
        while (posIter.hasNext()) {
80
        while (posIter.hasNext()) {
79
            posIter.next();
81
            posIter.next();
80
        }
82
        }
83
        
81
    }
84
    }
82
85
83
    /** {@inheritDoc} */
86
    /** {@inheritDoc} */
(-)src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLayoutManager.java (+2 lines)
Lines 70-75 Link Here
70
            int width = getStringWidth(str);
70
            int width = getStringWidth(str);
71
            text.setIPD(width);
71
            text.setIPD(width);
72
        }
72
        }
73
74
        text.setChangeBars(getChangeBars());
73
        updateTextAreaTraits(text);
75
        updateTextAreaTraits(text);
74
76
75
        return text;
77
        return text;
(-)src/java/org/apache/fop/layoutmgr/inline/ExternalGraphicLayoutManager.java (-2 / +4 lines)
Lines 42-49 Link Here
42
42
43
    /** {@inheritDoc} */
43
    /** {@inheritDoc} */
44
    protected Area getChildArea() {
44
    protected Area getChildArea() {
45
        return new Image(((ExternalGraphic) fobj).getSrc());
45
        Image im = new Image(((ExternalGraphic) fobj).getSrc());
46
    }
46
        im.setChangeBars(getChangeBars());
47
        return im;
48
     }
47
49
48
}
50
}
49
51
(-)src/java/org/apache/fop/layoutmgr/inline/InstreamForeignObjectLM.java (-1 / +3 lines)
Lines 46-52 Link Here
46
        org.w3c.dom.Document doc = child.getDOMDocument();
46
        org.w3c.dom.Document doc = child.getDOMDocument();
47
        String ns = child.getNamespaceURI();
47
        String ns = child.getNamespaceURI();
48
48
49
        return new ForeignObject(doc, ns);
49
        ForeignObject obj = new ForeignObject(doc, ns);
50
        obj.setChangeBars(getChangeBars());
51
        return obj;
50
    }
52
    }
51
53
52
}
54
}
(-)src/java/org/apache/fop/layoutmgr/inline/PageNumberLayoutManager.java (+4 lines)
Lines 77-82 Link Here
77
    public InlineArea get(LayoutContext context) {
77
    public InlineArea get(LayoutContext context) {
78
        // get page string from parent, build area
78
        // get page string from parent, build area
79
        TextArea text = new TextArea();
79
        TextArea text = new TextArea();
80
        text.setChangeBars(getChangeBars());
81
        
80
        String str = getCurrentPV().getPageNumberString();
82
        String str = getCurrentPV().getPageNumberString();
81
        int width = getStringWidth(str);
83
        int width = getStringWidth(str);
82
        text.addWord(str, 0);
84
        text.addWord(str, 0);
Lines 98-103 Link Here
98
        //TODO or even better: delay area creation until addAreas() stage
100
        //TODO or even better: delay area creation until addAreas() stage
99
        //TextArea is cloned because the LM is reused in static areas and the area can't be.
101
        //TextArea is cloned because the LM is reused in static areas and the area can't be.
100
        TextArea ta = new TextArea();
102
        TextArea ta = new TextArea();
103
        ta.setChangeBars(getChangeBars());
104
        
101
        TraitSetter.setProducerID(ta, fobj.getId());
105
        TraitSetter.setProducerID(ta, fobj.getId());
102
        ta.setIPD(baseArea.getIPD());
106
        ta.setIPD(baseArea.getIPD());
103
        ta.setBPD(baseArea.getBPD());
107
        ta.setBPD(baseArea.getBPD());
(-)src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java (+5 lines)
Lines 1451-1456 Link Here
1451
            }
1451
            }
1452
        }
1452
        }
1453
        setCurrentArea(null); // ?? necessary
1453
        setCurrentArea(null); // ?? necessary
1454
        
1454
    }
1455
    }
1455
1456
1456
    /**
1457
    /**
Lines 1471-1476 Link Here
1471
        LineArea lineArea = new LineArea(
1472
        LineArea lineArea = new LineArea(
1472
                (lbp.getLeafPos() < seq.size() - 1 ? textAlignment : textAlignmentLast),
1473
                (lbp.getLeafPos() < seq.size() - 1 ? textAlignment : textAlignmentLast),
1473
                lbp.difference, lbp.availableStretch, lbp.availableShrink);
1474
                lbp.difference, lbp.availableStretch, lbp.availableShrink);
1475
        lineArea.setChangeBars(getChangeBars());
1476
        
1474
        if (lbp.startIndent != 0) {
1477
        if (lbp.startIndent != 0) {
1475
            lineArea.addTrait(Trait.START_INDENT, new Integer(lbp.startIndent));
1478
            lineArea.addTrait(Trait.START_INDENT, new Integer(lbp.startIndent));
1476
        }
1479
        }
Lines 1609-1614 Link Here
1609
        }
1612
        }
1610
1613
1611
        LineArea lineArea = new LineArea();
1614
        LineArea lineArea = new LineArea();
1615
        lineArea.setChangeBars(getChangeBars());
1616
        
1612
        setCurrentArea(lineArea);
1617
        setCurrentArea(lineArea);
1613
        LayoutContext lc = new LayoutContext(0);
1618
        LayoutContext lc = new LayoutContext(0);
1614
        lc.setAlignmentContext(alignmentContext);
1619
        lc.setAlignmentContext(alignmentContext);
(-)src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java (+4 lines)
Lines 201-206 Link Here
201
                leaderArea.setBPD(fobj.getRuleThickness().getValue(this));
201
                leaderArea.setBPD(fobj.getRuleThickness().getValue(this));
202
            }
202
            }
203
        }
203
        }
204
        
205
       leaderArea.setChangeBars(getChangeBars());
206
       
204
        TraitSetter.setProducerID(leaderArea, fobj.getId());
207
        TraitSetter.setProducerID(leaderArea, fobj.getId());
205
        return leaderArea;
208
        return leaderArea;
206
     }
209
     }
Lines 233-238 Link Here
233
                posIter.next();
236
                posIter.next();
234
            }
237
            }
235
        }
238
        }
239
        
236
    }
240
    }
237
241
238
    /** {@inheritDoc} */
242
    /** {@inheritDoc} */
(-)src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java (+2 lines)
Lines 75-80 Link Here
75
75
76
    private TextArea getCharacterInlineArea(Character node) {
76
    private TextArea getCharacterInlineArea(Character node) {
77
        TextArea text = new TextArea();
77
        TextArea text = new TextArea();
78
        text.setChangeBars(getChangeBars());
79
        
78
        char ch = node.getCharacter();
80
        char ch = node.getCharacter();
79
        if (CharUtilities.isAnySpace(ch)) {
81
        if (CharUtilities.isAnySpace(ch)) {
80
            // add space unless it's zero-width:
82
            // add space unless it's zero-width:
(-)src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java (+1 lines)
Lines 198-203 Link Here
198
            if (iAdjust != 0) {
198
            if (iAdjust != 0) {
199
                //getLogger().debug("Add leading space: " + iAdjust);
199
                //getLogger().debug("Add leading space: " + iAdjust);
200
                Space ls = new Space();
200
                Space ls = new Space();
201
                ls.setChangeBars(getChangeBars());
201
                ls.setIPD(iAdjust);
202
                ls.setIPD(iAdjust);
202
                parentArea.addChildArea(ls);
203
                parentArea.addChildArea(ls);
203
            }
204
            }
(-)src/java/org/apache/fop/layoutmgr/inline/AbstractPageNumberCitationLayoutManager.java (+5 lines)
Lines 96-101 Link Here
96
        if (!resolved) {
96
        if (!resolved) {
97
            getPSLM().addUnresolvedArea(fobj.getRefId(), (Resolvable) curArea);
97
            getPSLM().addUnresolvedArea(fobj.getRefId(), (Resolvable) curArea);
98
        }
98
        }
99
        
99
    }
100
    }
100
101
101
    /**
102
    /**
Lines 112-117 Link Here
112
            String str = page.getPageNumberString();
113
            String str = page.getPageNumberString();
113
            // get page string from parent, build area
114
            // get page string from parent, build area
114
            text = new TextArea();
115
            text = new TextArea();
116
            text.setChangeBars(getChangeBars());
117
            
115
            int width = getStringWidth(str);
118
            int width = getStringWidth(str);
116
            text.addWord(str, 0);
119
            text.addWord(str, 0);
117
            text.setIPD(width);
120
            text.setIPD(width);
Lines 119-124 Link Here
119
        } else {
122
        } else {
120
            resolved = false;
123
            resolved = false;
121
            text = new UnresolvedPageNumber(fobj.getRefId(), font);
124
            text = new UnresolvedPageNumber(fobj.getRefId(), font);
125
            text.setChangeBars(getChangeBars());
126
            
122
            String str = "MMM"; // reserve three spaces for page number
127
            String str = "MMM"; // reserve three spaces for page number
123
            int width = getStringWidth(str);
128
            int width = getStringWidth(str);
124
            text.setIPD(width);
129
            text.setIPD(width);
(-)src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java (-1 / +5 lines)
Lines 297-302 Link Here
297
            addAreaInfoAreas(lastAreaInfo, wordSpaceCount, letterSpaceCount, firstAreaInfoIndex,
297
            addAreaInfoAreas(lastAreaInfo, wordSpaceCount, letterSpaceCount, firstAreaInfoIndex,
298
                    lastAreaInfoIndex, realWidth, context);
298
                    lastAreaInfoIndex, realWidth, context);
299
        }
299
        }
300
        
300
    }
301
    }
301
302
302
    private void addAreaInfoAreas(AreaInfo areaInfo, int wordSpaceCount, int letterSpaceCount,
303
    private void addAreaInfoAreas(AreaInfo areaInfo, int wordSpaceCount, int letterSpaceCount,
Lines 367-373 Link Here
367
368
368
        TextArea textArea = new TextAreaBuilder(realWidth, totalAdjust, context, firstAreaInfoIndex,
369
        TextArea textArea = new TextAreaBuilder(realWidth, totalAdjust, context, firstAreaInfoIndex,
369
                lastAreaInfoIndex, context.isLastArea(), areaInfo.font).build();
370
                lastAreaInfoIndex, context.isLastArea(), areaInfo.font).build();
370
371
        textArea.setChangeBars(getChangeBars());
372
        
371
        // wordSpaceDim is computed in relation to wordSpaceIPD.opt
373
        // wordSpaceDim is computed in relation to wordSpaceIPD.opt
372
        // but the renderer needs to know the adjustment in relation
374
        // but the renderer needs to know the adjustment in relation
373
        // to the size of the space character in the current font;
375
        // to the size of the space character in the current font;
Lines 459-464 Link Here
459
                textArea = new TextArea(width.getStretch(), width.getShrink(),
461
                textArea = new TextArea(width.getStretch(), width.getShrink(),
460
                        adjust);
462
                        adjust);
461
            }
463
            }
464
            
465
            textArea.setChangeBars(getChangeBars());
462
        }
466
        }
463
467
464
        private void setInlineProgressionDimension() {
468
        private void setInlineProgressionDimension() {
(-)src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLastLayoutManager.java (+1 lines)
Lines 75-80 Link Here
75
            resolved = true;
75
            resolved = true;
76
        }
76
        }
77
77
78
        text.setChangeBars(getChangeBars());
78
        updateTextAreaTraits(text);
79
        updateTextAreaTraits(text);
79
80
80
        return text;
81
        return text;
(-)src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java (+2 lines)
Lines 127-132 Link Here
127
        int sp = TraitSetter.getEffectiveSpace(adjust, minoptmax);
127
        int sp = TraitSetter.getEffectiveSpace(adjust, minoptmax);
128
        if (sp != 0) {
128
        if (sp != 0) {
129
            Block spacer = new Block();
129
            Block spacer = new Block();
130
           spacer.setChangeBars(getChangeBars());
131
           
130
            spacer.setBPD(sp);
132
            spacer.setBPD(sp);
131
            parentLayoutManager.addChildArea(spacer);
133
            parentLayoutManager.addChildArea(spacer);
132
        }
134
        }
(-)src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java (+2 lines)
Lines 402-407 Link Here
402
    public Area getParentArea(Area childArea) {
402
    public Area getParentArea(Area childArea) {
403
        if (curBlockArea == null) {
403
        if (curBlockArea == null) {
404
            curBlockArea = new Block();
404
            curBlockArea = new Block();
405
            curBlockArea.setChangeBars(getChangeBars());
406
            
405
            // Set up dimensions
407
            // Set up dimensions
406
            // Must get dimensions from parent area
408
            // Must get dimensions from parent area
407
            /*Area parentArea =*/ parentLayoutManager.getParentArea(curBlockArea);
409
            /*Area parentArea =*/ parentLayoutManager.getParentArea(curBlockArea);
(-)src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java (+10 lines)
Lines 405-414 Link Here
405
        if (usedBPD < cellBPD) {
405
        if (usedBPD < cellBPD) {
406
            if (getTableCell().getDisplayAlign() == EN_CENTER) {
406
            if (getTableCell().getDisplayAlign() == EN_CENTER) {
407
                Block space = new Block();
407
                Block space = new Block();
408
                space.setChangeBars(getChangeBars());
409
                
408
                space.setBPD((cellBPD - usedBPD) / 2);
410
                space.setBPD((cellBPD - usedBPD) / 2);
409
                curBlockArea.addBlock(space);
411
                curBlockArea.addBlock(space);
410
            } else if (getTableCell().getDisplayAlign() == EN_AFTER) {
412
            } else if (getTableCell().getDisplayAlign() == EN_AFTER) {
411
                Block space = new Block();
413
                Block space = new Block();
414
                space.setChangeBars(getChangeBars());
415
                
412
                space.setBPD(cellBPD - usedBPD);
416
                space.setBPD(cellBPD - usedBPD);
413
                curBlockArea.addBlock(space);
417
                curBlockArea.addBlock(space);
414
            }
418
            }
Lines 463-468 Link Here
463
            boolean outer) {
467
            boolean outer) {
464
        if (blocks[i][j] == null) {
468
        if (blocks[i][j] == null) {
465
            blocks[i][j] = new Block();
469
            blocks[i][j] = new Block();
470
            blocks[i][j].setChangeBars(getChangeBars());
471
            
466
            blocks[i][j].addTrait(Trait.IS_REFERENCE_AREA, Boolean.TRUE);
472
            blocks[i][j].addTrait(Trait.IS_REFERENCE_AREA, Boolean.TRUE);
467
            blocks[i][j].setPositioning(Block.ABSOLUTE);
473
            blocks[i][j].setPositioning(Block.ABSOLUTE);
468
        }
474
        }
Lines 493-498 Link Here
493
        int paddingEnd = padding.getPaddingEnd(false, this);
499
        int paddingEnd = padding.getPaddingEnd(false, this);
494
500
495
        Block block = new Block();
501
        Block block = new Block();
502
        block.setChangeBars(getChangeBars());
503
        
496
        TraitSetter.setProducerID(block, getTable().getId());
504
        TraitSetter.setProducerID(block, getTable().getId());
497
        block.setPositioning(Block.ABSOLUTE);
505
        block.setPositioning(Block.ABSOLUTE);
498
        block.setIPD(cellIPD + paddingStart + paddingEnd);
506
        block.setIPD(cellIPD + paddingStart + paddingEnd);
Lines 518-523 Link Here
518
    public Area getParentArea(Area childArea) {
526
    public Area getParentArea(Area childArea) {
519
        if (curBlockArea == null) {
527
        if (curBlockArea == null) {
520
            curBlockArea = new Block();
528
            curBlockArea = new Block();
529
            curBlockArea.setChangeBars(getChangeBars());
530
            
521
            curBlockArea.addTrait(Trait.IS_REFERENCE_AREA, Boolean.TRUE);
531
            curBlockArea.addTrait(Trait.IS_REFERENCE_AREA, Boolean.TRUE);
522
            TraitSetter.setProducerID(curBlockArea, getTableCell().getId());
532
            TraitSetter.setProducerID(curBlockArea, getTableCell().getId());
523
            curBlockArea.setPositioning(Block.ABSOLUTE);
533
            curBlockArea.setPositioning(Block.ABSOLUTE);
(-)src/java/org/apache/fop/layoutmgr/table/TableAndCaptionLayoutManager.java (+2 lines)
Lines 179-184 Link Here
179
    public Area getParentArea(Area childArea) {
179
    public Area getParentArea(Area childArea) {
180
        if (curBlockArea == null) {
180
        if (curBlockArea == null) {
181
            curBlockArea = new Block();
181
            curBlockArea = new Block();
182
           curBlockArea.setChangeBars(getChangeBars());
183
           
182
            // Set up dimensions
184
            // Set up dimensions
183
            // Must get dimensions from parent area
185
            // Must get dimensions from parent area
184
            Area parentArea = parentLayoutManager.getParentArea(curBlockArea);
186
            Area parentArea = parentLayoutManager.getParentArea(curBlockArea);
(-)src/java/org/apache/fop/layoutmgr/table/RowPainter.java (+2 lines)
Lines 465-470 Link Here
465
465
466
        //generate the block area
466
        //generate the block area
467
        Block block = new Block();
467
        Block block = new Block();
468
        block.setChangeBars(tclm.getTableLM().getFObj().getChangeBars());
469
        
468
        block.setPositioning(Block.ABSOLUTE);
470
        block.setPositioning(Block.ABSOLUTE);
469
        block.addTrait(Trait.IS_REFERENCE_AREA, Boolean.TRUE);
471
        block.addTrait(Trait.IS_REFERENCE_AREA, Boolean.TRUE);
470
        block.setIPD(ipd);
472
        block.setIPD(ipd);
(-)src/java/org/apache/fop/layoutmgr/table/TableCaptionLayoutManager.java (+2 lines)
Lines 175-180 Link Here
175
    public Area getParentArea(Area childArea) {
175
    public Area getParentArea(Area childArea) {
176
        if (curBlockArea == null) {
176
        if (curBlockArea == null) {
177
            curBlockArea = new Block();
177
            curBlockArea = new Block();
178
            curBlockArea.setChangeBars(getChangeBars());
179
            
178
            // Set up dimensions
180
            // Set up dimensions
179
            // Must get dimensions from parent area
181
            // Must get dimensions from parent area
180
            Area parentArea = parentLayoutManager.getParentArea(curBlockArea);
182
            Area parentArea = parentLayoutManager.getParentArea(curBlockArea);
(-)src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java (+4 lines)
Lines 1184-1189 Link Here
1184
            boolean allowBPDUpdate = autoHeight && !switchedProgressionDirection;
1184
            boolean allowBPDUpdate = autoHeight && !switchedProgressionDirection;
1185
1185
1186
            viewportBlockArea = new BlockViewport(allowBPDUpdate);
1186
            viewportBlockArea = new BlockViewport(allowBPDUpdate);
1187
            viewportBlockArea.setChangeBars(getChangeBars());
1188
            
1187
            viewportBlockArea.addTrait(Trait.IS_VIEWPORT_AREA, Boolean.TRUE);
1189
            viewportBlockArea.addTrait(Trait.IS_VIEWPORT_AREA, Boolean.TRUE);
1188
1190
1189
            viewportBlockArea.setIPD(getContentAreaIPD());
1191
            viewportBlockArea.setIPD(getContentAreaIPD());
Lines 1229-1234 Link Here
1229
            }
1231
            }
1230
1232
1231
            referenceArea = new Block();
1233
            referenceArea = new Block();
1234
            referenceArea.setChangeBars(getChangeBars());
1235
            
1232
            referenceArea.addTrait(Trait.IS_REFERENCE_AREA, Boolean.TRUE);
1236
            referenceArea.addTrait(Trait.IS_REFERENCE_AREA, Boolean.TRUE);
1233
            TraitSetter.setProducerID(referenceArea, getBlockContainerFO().getId());
1237
            TraitSetter.setProducerID(referenceArea, getBlockContainerFO().getId());
1234
1238
(-)src/java/org/apache/fop/layoutmgr/AbstractBaseLayoutManager.java (+18 lines)
Lines 21-26 Link Here
21
21
22
import java.util.List;
22
import java.util.List;
23
import java.util.Stack;
23
import java.util.Stack;
24
import java.util.Vector;
24
25
25
import org.apache.commons.logging.Log;
26
import org.apache.commons.logging.Log;
26
import org.apache.commons.logging.LogFactory;
27
import org.apache.commons.logging.LogFactory;
Lines 257-262 Link Here
257
        return fobj;
258
        return fobj;
258
    }
259
    }
259
260
261
    /**
262
     * Obtain vector of change bars affecting object in this layout.
263
     * @return Vector of all change bars affecting this or null
264
     */
265
    public Vector/*<ChangeBar>*/ getChangeBars()
266
    {
267
    	if (null == fobj)
268
    	{
269
    		return null;
270
    	}
271
    	else
272
    	{
273
    		return fobj.getChangeBars();
274
    	}
275
    }
276
277
    
260
    /** {@inheritDoc} */
278
    /** {@inheritDoc} */
261
    public void reset() {
279
    public void reset() {
262
        throw new UnsupportedOperationException("Not implemented");
280
        throw new UnsupportedOperationException("Not implemented");
(-)src/java/org/apache/fop/apps/FOUserAgent.java (+66 lines)
Lines 24-29 Link Here
24
import java.net.MalformedURLException;
24
import java.net.MalformedURLException;
25
import java.util.Date;
25
import java.util.Date;
26
import java.util.Map;
26
import java.util.Map;
27
import java.util.TreeMap;
28
import java.util.Vector;
27
29
28
import javax.xml.transform.Source;
30
import javax.xml.transform.Source;
29
import javax.xml.transform.TransformerException;
31
import javax.xml.transform.TransformerException;
Lines 46-51 Link Here
46
import org.apache.fop.events.FOPEventListenerProxy;
48
import org.apache.fop.events.FOPEventListenerProxy;
47
import org.apache.fop.events.LoggingEventListener;
49
import org.apache.fop.events.LoggingEventListener;
48
import org.apache.fop.fo.FOEventHandler;
50
import org.apache.fop.fo.FOEventHandler;
51
import org.apache.fop.fo.flow.ChangeBar;
49
import org.apache.fop.fonts.FontManager;
52
import org.apache.fop.fonts.FontManager;
50
import org.apache.fop.render.Renderer;
53
import org.apache.fop.render.Renderer;
51
import org.apache.fop.render.RendererFactory;
54
import org.apache.fop.render.RendererFactory;
Lines 82-88 Link Here
82
85
83
    private FopFactory factory;
86
    private FopFactory factory;
84
87
88
    
85
    /**
89
    /**
90
     * The names for classes already used
91
     */
92
    private static Map usedChangeBarNames = new TreeMap();;
93
    
94
    /**
95
     * The change bars encountered
96
     */
97
    private static Vector stackedChangeBars = new Vector();
98
99
    
100
    /**
86
     *  The base URL for all URL resolutions, especially for
101
     *  The base URL for all URL resolutions, especially for
87
     *  external-graphics.
102
     *  external-graphics.
88
     */
103
     */
Lines 692-696 Link Here
692
    public StructureTree getStructureTree() {
707
    public StructureTree getStructureTree() {
693
        return this.structureTree;
708
        return this.structureTree;
694
    }
709
    }
710
    
711
    /**
712
     * Add another change bar to the stack of active change bars
713
     * @param bar The change bar top add
714
     */
715
    public void pushChangeBar(ChangeBar bar)
716
    {
717
        stackedChangeBars.addElement(bar);
718
        usedChangeBarNames.put(bar.getCBClass(), "1");
719
    }
720
    
721
    
722
    /**
723
     * Remove top level change bar from stack
724
     */
725
    public void popChangeBar()
726
    {
727
        usedChangeBarNames.remove(topChangeBar().getCBClass());
728
        stackedChangeBars.removeElementAt(stackedChangeBars.size() - 1);
729
    }
730
    
731
    public ChangeBar topChangeBar()
732
    {
733
        if (stackedChangeBars.isEmpty())
734
        {
735
            return null;
736
        }
737
        else
738
        {
739
            return (ChangeBar)stackedChangeBars.lastElement();
740
        }
741
    }
742
    
743
    /**
744
     * Return the list of change bars in effect currently
745
     * @return The vector of change bars in effect currently
746
     */
747
    public Vector getChangeBars()
748
    {
749
        return stackedChangeBars;
750
    }
751
    
752
753
    /**
754
     * Copy the change bars in affect currently 
755
     * @return A copy of the change bars in effect currently
756
     */
757
    public  Vector copyChangeBars()
758
    {
759
        return (Vector)(stackedChangeBars.clone());        
760
    }
695
}
761
}
696
762
(-)src/java/org/apache/fop/fo/FOText.java (+6 lines)
Lines 28-33 Link Here
28
import org.apache.fop.apps.FOPException;
28
import org.apache.fop.apps.FOPException;
29
import org.apache.fop.datatypes.Length;
29
import org.apache.fop.datatypes.Length;
30
import org.apache.fop.fo.flow.Block;
30
import org.apache.fop.fo.flow.Block;
31
import org.apache.fop.fo.flow.ChangeBar;
31
import org.apache.fop.fo.properties.CommonFont;
32
import org.apache.fop.fo.properties.CommonFont;
32
import org.apache.fop.fo.properties.CommonHyphenation;
33
import org.apache.fop.fo.properties.CommonHyphenation;
33
import org.apache.fop.fo.properties.CommonTextDecoration;
34
import org.apache.fop.fo.properties.CommonTextDecoration;
Lines 90-95 Link Here
90
     */
91
     */
91
    public FOText(FONode parent) {
92
    public FOText(FONode parent) {
92
        super(parent);
93
        super(parent);
94
        // check if we are under the influence of change bars
95
        if (null != getUserAgent().topChangeBar()) {
96
            // OK, so copy over the stack of change bars
97
            affectedByChangeBars = getUserAgent().copyChangeBars();
98
        }
93
    }
99
    }
94
100
95
    /** {@inheritDoc} */
101
    /** {@inheritDoc} */
(-)src/java/org/apache/fop/fo/FONode.java (+15 lines)
Lines 22-27 Link Here
22
// Java
22
// Java
23
import java.util.ListIterator;
23
import java.util.ListIterator;
24
import java.util.Map;
24
import java.util.Map;
25
import java.util.Vector;
25
26
26
import org.xml.sax.Attributes;
27
import org.xml.sax.Attributes;
27
import org.xml.sax.Locator;
28
import org.xml.sax.Locator;
Lines 59-64 Link Here
59
    /** pointer to the sibling nodes */
60
    /** pointer to the sibling nodes */
60
    protected FONode[] siblings;
61
    protected FONode[] siblings;
61
62
63
    protected Vector affectedByChangeBars = null;
64
    
62
    /**
65
    /**
63
     * Marks the location of this object from the input FO
66
     * Marks the location of this object from the input FO
64
     *   <br>Call <code>locator.getSystemId()</code>,
67
     *   <br>Call <code>locator.getSystemId()</code>,
Lines 170-175 Link Here
170
    }
173
    }
171
174
172
    /**
175
    /**
176
     * Convenience function to check if this element is a change bar element
177
     * @param namespaceURI  The name space of the element
178
     * @param localName  The local name of the element
179
     * @return true if a member, false if not
180
     */
181
    public boolean isChangeBarElement(String namespaceURI, String localName) {
182
        return FO_URI.equals(namespaceURI) &&
183
                    ( "change-bar-begin".equals(localName) ||
184
                       "change-bar-end".equals(localName) );
185
    }
186
    
187
    /**
173
     * Returns the user agent that is associated with the
188
     * Returns the user agent that is associated with the
174
     * tree's <code>FOEventHandler</code>.
189
     * tree's <code>FOEventHandler</code>.
175
     *
190
     *
(-)src/java/org/apache/fop/fo/FObj.java (-1 / +27 lines)
Lines 26-31 Link Here
26
import java.util.Map;
26
import java.util.Map;
27
import java.util.NoSuchElementException;
27
import java.util.NoSuchElementException;
28
import java.util.Set;
28
import java.util.Set;
29
import java.util.Vector;
29
30
30
import org.xml.sax.Attributes;
31
import org.xml.sax.Attributes;
31
import org.xml.sax.Locator;
32
import org.xml.sax.Locator;
Lines 36-41 Link Here
36
import org.apache.fop.fo.extensions.ExtensionAttachment;
37
import org.apache.fop.fo.extensions.ExtensionAttachment;
37
import org.apache.fop.fo.flow.Marker;
38
import org.apache.fop.fo.flow.Marker;
38
import org.apache.fop.fo.properties.PropertyMaker;
39
import org.apache.fop.fo.properties.PropertyMaker;
40
import org.apache.fop.fo.flow.ChangeBar;
39
41
40
/**
42
/**
41
 * Base class for representation of formatting objects and their processing.
43
 * Base class for representation of formatting objects and their processing.
Lines 68-74 Link Here
68
70
69
    // The value of properties relevant for all fo objects
71
    // The value of properties relevant for all fo objects
70
    private String id = null;
72
    private String id = null;
71
    // End of property values
73
    // End of property values
74
    
72
75
73
    /**
76
    /**
74
     * Create a new formatting object.
77
     * Create a new formatting object.
Lines 152-160 Link Here
152
        if (id != null) {
155
        if (id != null) {
153
            checkId(id);
156
            checkId(id);
154
        }
157
        }
158
        
155
    }
159
    }
156
160
157
    /**
161
    /**
162
     * {@inheritDoc}
163
     * @throws FOPException FOP Exception
164
     */
165
     protected void endOfNode() throws FOPException {
166
        // check if we are under the influence of change bars
167
        if (null != getUserAgent().topChangeBar()) {
168
            // OK, so copy over the stack of change bars
169
            affectedByChangeBars = getUserAgent().copyChangeBars();
170
        }
171
172
        super.endOfNode();
173
    }
174
175
    /**
158
     * Setup the id for this formatting object.
176
     * Setup the id for this formatting object.
159
     * Most formatting objects can have an id that can be referenced.
177
     * Most formatting objects can have an id that can be referenced.
160
     * This methods checks that the id isn't already used by another FO
178
     * This methods checks that the id isn't already used by another FO
Lines 417-423 Link Here
417
        }
435
        }
418
    }
436
    }
419
437
420
    /**
438
    
439
    
440
     /**
421
     * Convenience method for validity checking.  Checks if the
441
     * Convenience method for validity checking.  Checks if the
422
     * incoming node is a member of the "%block;" parameter entity
442
     * incoming node is a member of the "%block;" parameter entity
423
     * as defined in Sect. 6.2 of the XSL 1.0 & 1.1 Recommendations
443
     * as defined in Sect. 6.2 of the XSL 1.0 & 1.1 Recommendations
Lines 610-615 Link Here
610
        return (super.toString() + "[@id=" + this.id + "]");
630
        return (super.toString() + "[@id=" + this.id + "]");
611
    }
631
    }
612
632
633
    public Vector/*<ChangeBar>*/getChangeBars()
634
    {
635
    	return affectedByChangeBars;
636
    }
637
    
638
    
613
    /** Basic {@link FONodeIterator} implementation */
639
    /** Basic {@link FONodeIterator} implementation */
614
    public class FObjIterator implements FONodeIterator {
640
    public class FObjIterator implements FONodeIterator {
615
641
(-)src/java/org/apache/fop/fo/FOElementMapping.java (+17 lines)
Lines 136-141 Link Here
136
            foObjs.put("marker", new MarkerMaker());
136
            foObjs.put("marker", new MarkerMaker());
137
            foObjs.put("retrieve-marker", new RetrieveMarkerMaker());
137
            foObjs.put("retrieve-marker", new RetrieveMarkerMaker());
138
            foObjs.put("retrieve-table-marker", new RetrieveTableMarkerMaker());
138
            foObjs.put("retrieve-table-marker", new RetrieveTableMarkerMaker());
139
            
140
            // change bars
141
            foObjs.put("change-bar-begin", new ChangeBarBeginMaker());
142
            foObjs.put("change-bar-end", new ChangeBarEndMaker());
139
        }
143
        }
140
    }
144
    }
141
145
Lines 520-523 Link Here
520
            return new org.apache.fop.fo.flow.RetrieveTableMarker(parent);
524
            return new org.apache.fop.fo.flow.RetrieveTableMarker(parent);
521
        }
525
        }
522
    }
526
    }
527
    
528
    static class ChangeBarBeginMaker extends ElementMapping.Maker {
529
        public FONode make(FONode parent) {
530
            return new org.apache.fop.fo.flow.ChangeBarBegin(parent);
531
        }
532
    }
533
    
534
    static class ChangeBarEndMaker extends ElementMapping.Maker {
535
        public FONode make(FONode parent) {
536
            return new org.apache.fop.fo.flow.ChangeBarEnd(parent);
537
        }
538
    }  
539
    
523
}
540
}
(-)src/java/org/apache/fop/fo/FOPropertyMapping.java (+51 lines)
Lines 313-318 Link Here
313
            gp.createTableProperties();
313
            gp.createTableProperties();
314
            gp.createWritingModeProperties();
314
            gp.createWritingModeProperties();
315
            gp.createMiscProperties();
315
            gp.createMiscProperties();
316
            gp.createChangeBarProperties();
316
317
317
            // Hardcode the subproperties.
318
            // Hardcode the subproperties.
318
            addSubpropMakerName("length", CP_LENGTH);
319
            addSubpropMakerName("length", CP_LENGTH);
Lines 2500-2505 Link Here
2500
        addPropertyMaker("writing-mode", m);
2501
        addPropertyMaker("writing-mode", m);
2501
    }
2502
    }
2502
2503
2504
    private void createChangeBarProperties() {
2505
        PropertyMaker m;
2506
        
2507
        // change-bar-class
2508
        m = new StringProperty.Maker(PR_CHANGE_BAR_CLASS);
2509
        m.setInherited(false);
2510
        m.setDefault("");
2511
        addPropertyMaker("change-bar-class", m);
2512
        
2513
        // change-bar-color
2514
        m  = new ColorProperty.Maker(PR_CHANGE_BAR_COLOR);
2515
        m.useGeneric(genericColor);
2516
        m.setInherited(true);
2517
        m.setDefault("black");
2518
        addPropertyMaker("change-bar-color", m);
2519
        
2520
        // change-bar-offset
2521
        m  = new LengthProperty.Maker(PR_CHANGE_BAR_OFFSET);
2522
        m.setInherited(true);
2523
        m.setDefault("6pt");
2524
        addPropertyMaker("change-bar-offset", m);      
2525
        
2526
        // change-bar-placement
2527
        m = new EnumProperty.Maker(PR_CHANGE_BAR_PLACEMENT);
2528
        m.setInherited(true);
2529
        m.setDefault("start");
2530
        m.addEnum("start", getEnumProperty(EN_START, "START"));
2531
        m.addEnum("end", getEnumProperty(EN_END, "END"));
2532
        m.addEnum("left", getEnumProperty(EN_LEFT, "LEFT"));
2533
        m.addEnum("right", getEnumProperty(EN_RIGHT, "RIGHT"));
2534
        m.addEnum("inside", getEnumProperty(EN_INSIDE, "INSIDE"));
2535
        m.addEnum("outside", getEnumProperty(EN_OUTSIDE, "OUTSIDE"));
2536
        m.addEnum("alternate", getEnumProperty(EN_ALTERNATE, "ALTERNATE"));
2537
        addPropertyMaker("change-bar-placement", m);
2538
        
2539
        // change-bar-style
2540
        m = new EnumProperty.Maker(PR_CHANGE_BAR_STYLE);
2541
        m.useGeneric(genericBorderStyle);      
2542
        m.setInherited(true); 
2543
        m.setDefault("solid");
2544
        addPropertyMaker("change-bar-style", m);
2545
        
2546
        // change-bar-width
2547
        // change-bar-offset
2548
        m  = new LengthProperty.Maker(PR_CHANGE_BAR_WIDTH);
2549
        m.setInherited(true);
2550
        m.setDefault("6pt");
2551
        addPropertyMaker("change-bar-width", m);      
2552
    }
2553
    
2503
    private void createMiscProperties() {
2554
    private void createMiscProperties() {
2504
        PropertyMaker m;
2555
        PropertyMaker m;
2505
2556
(-)src/java/org/apache/fop/fo/FOValidationEventProducer.java (+41 lines)
Lines 357-362 Link Here
357
            QName offendingNode, Locator loc);
357
            QName offendingNode, Locator loc);
358
358
359
    /**
359
    /**
360
     * A class for change bars is not unique.
361
     * @param source the event source
362
     * @param elementName the name of the context node
363
     * @param name the class name
364
     * @param loc the location of the error or null
365
     * @event.severity FATAL
366
     */
367
    void changeBarClassNotUnique(Object source, String elementName, String name,
368
            Locator loc);
369
    
370
    /**
371
     * Change bars were not stacked correctly
372
     * @param source the event source
373
     * @param elementName the name of the context node
374
     * @param beginName the class name of the beginning change bar
375
     * @param endName the class name of the ending change bar
376
     * @param loc the location of the error or null
377
     * @event.severity FATAL
378
     */
379
    void changeBarWrongStacking(Object source, String elementName, String beginName,
380
            String endName, Locator loc);
381
    
382
    /**
383
     * Change bar ended without a start of bar occurred
384
     * @param source the event source
385
     * @param elementName the name of the context node
386
     * @param loc the location of the error or null
387
     * @event.severity FATAL
388
     */
389
    void changeBarNoBegin(Object source, String elementName, 
390
            Locator loc);
391
    /**
392
     * Change bar not descendant of fo:flow or fo:static-content
393
     * @param source the event source
394
     * @param elementName the name of the context node
395
     * @param loc the location of the error or null
396
     * @event.severity FATAL
397
     */
398
    void changeBarWrongAncestor(Object source, String elementName, Locator loc);
399
400
    /**
360
     * Alternate text is missing for a graphic element.
401
     * Alternate text is missing for a graphic element.
361
     *
402
     *
362
     * @param source the event source
403
     * @param source the event source
(-)src/java/org/apache/fop/fo/FOTreeBuilder.java (-1 / +3 lines)
Lines 264-270 Link Here
264
            } else { // check that incoming node is valid for currentFObj
264
            } else { // check that incoming node is valid for currentFObj
265
                if (currentFObj.getNamespaceURI().equals(FOElementMapping.URI)
265
                if (currentFObj.getNamespaceURI().equals(FOElementMapping.URI)
266
                    || currentFObj.getNamespaceURI().equals(ExtensionElementMapping.URI)) {
266
                    || currentFObj.getNamespaceURI().equals(ExtensionElementMapping.URI)) {
267
                    currentFObj.validateChildNode(locator, namespaceURI, localName);
267
                    if (!currentFObj.isChangeBarElement(namespaceURI, localName)) {
268
                        currentFObj.validateChildNode(locator, namespaceURI, localName);
269
                    }
268
                }
270
                }
269
            }
271
            }
270
272
(-)src/java/org/apache/fop/events/EventFormatter.xml (+4 lines)
Lines 58-63 Link Here
58
  <message key="org.apache.fop.fo.FOValidationEventProducer.invalidFORoot">First element must be the fo:root formatting object. Found {elementName} instead. Please make sure you're producing a valid XSL-FO document.</message>
58
  <message key="org.apache.fop.fo.FOValidationEventProducer.invalidFORoot">First element must be the fo:root formatting object. Found {elementName} instead. Please make sure you're producing a valid XSL-FO document.</message>
59
  <message key="org.apache.fop.fo.FOValidationEventProducer.emptyDocument">Document is empty (something might be wrong with your XSLT stylesheet).</message>
59
  <message key="org.apache.fop.fo.FOValidationEventProducer.emptyDocument">Document is empty (something might be wrong with your XSLT stylesheet).</message>
60
  <message key="org.apache.fop.fo.FOValidationEventProducer.unknownFormattingObject">Unknown formatting object "{offendingNode}" encountered (a child of {elementName}}.{{locator}}</message>
60
  <message key="org.apache.fop.fo.FOValidationEventProducer.unknownFormattingObject">Unknown formatting object "{offendingNode}" encountered (a child of {elementName}}.{{locator}}</message>
61
  <message key="org.apache.fop.fo.FOValidationEventProducer.changeBarClassNotUnique">Class "{name}" of {elementName} not unique{{locator}}</message>
62
  <message key="org.apache.fop.fo.FOValidationEventProducer.changeBarWrongStacking">End class "{endName}" of {elementName} does not match latest starting class {beginName}.{{locator}}</message>
63
  <message key="org.apache.fop.fo.FOValidationEventProducer.changeBarNoBegin">An {elementName} without an fo:change-bar-begin found.{{locator}}</message>
64
  <message key="org.apache.fop.fo.FOValidationEventProducer.changeBarWrongAncestor">Element {elementName} not descendant of fo:flow or fo:static-content.{{locator}}</message>
61
  <message key="org.apache.fop.fo.flow.table.TableEventProducer.nonAutoBPDOnTable">Only a value of "auto" for block-progression-dimension has a well-specified behavior on fo:table. Falling back to "auto".{{locator}}</message>
65
  <message key="org.apache.fop.fo.flow.table.TableEventProducer.nonAutoBPDOnTable">Only a value of "auto" for block-progression-dimension has a well-specified behavior on fo:table. Falling back to "auto".{{locator}}</message>
62
  <message key="org.apache.fop.fo.flow.table.TableEventProducer.noTablePaddingWithCollapsingBorderModel">In collapsing border model a table does not have padding (see http://www.w3.org/TR/REC-CSS2/tables.html#collapsing-borders), but a non-zero value for padding was found. The padding will be ignored.{{locator}}</message>
66
  <message key="org.apache.fop.fo.flow.table.TableEventProducer.noTablePaddingWithCollapsingBorderModel">In collapsing border model a table does not have padding (see http://www.w3.org/TR/REC-CSS2/tables.html#collapsing-borders), but a non-zero value for padding was found. The padding will be ignored.{{locator}}</message>
63
  <message key="org.apache.fop.fo.flow.table.TableEventProducer.noMixRowsAndCells">Either fo:table-rows or fo:table-cells may be children of an {elementName} but not both.{{locator}}</message>
67
  <message key="org.apache.fop.fo.flow.table.TableEventProducer.noMixRowsAndCells">Either fo:table-rows or fo:table-cells may be children of an {elementName} but not both.{{locator}}</message>
(-)src/java/org/apache/fop/area/BodyRegion.java (-4 / +9 lines)
Lines 36-41 Link Here
36
    private int columnGap;
36
    private int columnGap;
37
    private int columnCount;
37
    private int columnCount;
38
38
39
    
39
    /**
40
    /**
40
     * Constructor which can read traits directly
41
     * Constructor which can read traits directly
41
     * from an fo:region-body formatting object.
42
     * from an fo:region-body formatting object.
Lines 43-49 Link Here
43
     * @param parent the parent region viewport
44
     * @param parent the parent region viewport
44
     */
45
     */
45
    public BodyRegion(RegionBody rb, RegionViewport parent) {
46
    public BodyRegion(RegionBody rb, RegionViewport parent) {
46
        this(rb.getNameId(), rb.getRegionName(), parent, rb.getColumnCount(), rb.getColumnGap());
47
        this(rb.getNameId(), rb.getRegionName(), parent, rb.getColumnCount(), rb.getColumnGap(),
48
                rb.getWritingMode(), rb.getReferenceOrientation());
47
    }
49
    }
48
50
49
    /**
51
    /**
Lines 54-63 Link Here
54
     * @param parent the parent region viewport
56
     * @param parent the parent region viewport
55
     * @param columnCount the number of columns
57
     * @param columnCount the number of columns
56
     * @param columnGap the gap between columns
58
     * @param columnGap the gap between columns
59
     * @param wrMode writing Mode
60
     * @param refOrient reference orientation
57
     */
61
     */
58
    public BodyRegion(int regionClass, String regionName, RegionViewport parent,
62
    public BodyRegion(int regionClass, String regionName, RegionViewport parent,
59
            int columnCount, int columnGap) {
63
            int columnCount, int columnGap, int wrMode, int refOrient) {
60
        super(regionClass, regionName, parent);
64
        super(regionClass, regionName, parent, wrMode, refOrient);
65
        
61
        this.columnCount = columnCount;
66
        this.columnCount = columnCount;
62
        this.columnGap = columnGap;
67
        this.columnGap = columnGap;
63
        mainReference = new MainReference(this);
68
        mainReference = new MainReference(this);
Lines 143-149 Link Here
143
     */
148
     */
144
    public Object clone() {
149
    public Object clone() {
145
        BodyRegion br = new BodyRegion(getRegionClass(), getRegionName(), regionViewport,
150
        BodyRegion br = new BodyRegion(getRegionClass(), getRegionName(), regionViewport,
146
                getColumnCount(), getColumnGap());
151
                getColumnCount(), getColumnGap(), getWritingMode(), getReferenceOrientation());
147
        br.setCTM(getCTM());
152
        br.setCTM(getCTM());
148
        br.setIPD(getIPD());
153
        br.setIPD(getIPD());
149
        br.beforeFloat = beforeFloat;
154
        br.beforeFloat = beforeFloat;
(-)src/java/org/apache/fop/area/MainReference.java (+3 lines)
Lines 125-129 Link Here
125
        return parent.getColumnGap();
125
        return parent.getColumnGap();
126
    }
126
    }
127
127
128
    public BodyRegion getParent() {
129
        return parent;
130
    }
128
}
131
}
129
132
(-)src/java/org/apache/fop/area/AreaTreeParser.java (-2 / +5 lines)
Lines 571-579 Link Here
571
                String regionName = attributes.getValue("name");
571
                String regionName = attributes.getValue("name");
572
                int columnCount = XMLUtil.getAttributeAsInt(attributes, "columnCount", 1);
572
                int columnCount = XMLUtil.getAttributeAsInt(attributes, "columnCount", 1);
573
                int columnGap = XMLUtil.getAttributeAsInt(attributes, "columnGap", 0);
573
                int columnGap = XMLUtil.getAttributeAsInt(attributes, "columnGap", 0);
574
                int wrMode = XMLUtil.getAttributeAsInt(attributes, "writingMode", Constants.EN_LR_TB);
575
                int refOrient = XMLUtil.getAttributeAsInt(attributes, "referenceOrientation", 0);
574
                RegionViewport rv = getCurrentRegionViewport();
576
                RegionViewport rv = getCurrentRegionViewport();
575
                body = new BodyRegion(Constants.FO_REGION_BODY,
577
                body = new BodyRegion(Constants.FO_REGION_BODY,
576
                        regionName, rv, columnCount, columnGap);
578
                        regionName, rv, columnCount, columnGap, wrMode, refOrient);
577
                transferForeignObjects(attributes, body);
579
                transferForeignObjects(attributes, body);
578
                body.setCTM(getAttributeAsCTM(attributes, "ctm"));
580
                body.setCTM(getAttributeAsCTM(attributes, "ctm"));
579
                setAreaAttributes(attributes, body);
581
                setAreaAttributes(attributes, body);
Lines 1019-1025 Link Here
1019
            String regionName = attributes.getValue("name");
1021
            String regionName = attributes.getValue("name");
1020
            RegionViewport rv = getCurrentRegionViewport();
1022
            RegionViewport rv = getCurrentRegionViewport();
1021
            RegionReference reg = new RegionReference(side,
1023
            RegionReference reg = new RegionReference(side,
1022
                    regionName, rv);
1024
                    regionName, rv, Integer.parseInt(attributes.getValue("writingMode")),
1025
                    Integer.parseInt(attributes.getValue("referenceOrientation")));
1023
            transferForeignObjects(attributes, reg);
1026
            transferForeignObjects(attributes, reg);
1024
            reg.setCTM(getAttributeAsCTM(attributes, "ctm"));
1027
            reg.setCTM(getAttributeAsCTM(attributes, "ctm"));
1025
            setAreaAttributes(attributes, reg);
1028
            setAreaAttributes(attributes, reg);
(-)src/java/org/apache/fop/area/inline/TextArea.java (+4 lines)
Lines 67-72 Link Here
67
     */
67
     */
68
    public void addWord(String word, int offset, int[] letterAdjust) {
68
    public void addWord(String word, int offset, int[] letterAdjust) {
69
        WordArea wordArea = new WordArea(word, offset, letterAdjust);
69
        WordArea wordArea = new WordArea(word, offset, letterAdjust);
70
        wordArea.setChangeBars(getChangeBars());
71
        
70
        addChildArea(wordArea);
72
        addChildArea(wordArea);
71
        wordArea.setParentArea(this);
73
        wordArea.setParentArea(this);
72
    }
74
    }
Lines 80-85 Link Here
80
     */
82
     */
81
    public void addSpace(char space, int offset, boolean adjustable) {
83
    public void addSpace(char space, int offset, boolean adjustable) {
82
        SpaceArea spaceArea = new SpaceArea(space, offset, adjustable);
84
        SpaceArea spaceArea = new SpaceArea(space, offset, adjustable);
85
       spaceArea.setChangeBars(getChangeBars());
86
       
83
        addChildArea(spaceArea);
87
        addChildArea(spaceArea);
84
        spaceArea.setParentArea(this);
88
        spaceArea.setParentArea(this);
85
    }
89
    }
(-)src/java/org/apache/fop/area/RegionReference.java (-4 / +24 lines)
Lines 22-27 Link Here
22
import java.util.ArrayList;
22
import java.util.ArrayList;
23
import java.util.List;
23
import java.util.List;
24
24
25
import org.apache.fop.datatypes.Numeric;
26
import org.apache.fop.fo.Constants;
25
import org.apache.fop.fo.pagination.Region;
27
import org.apache.fop.fo.pagination.Region;
26
28
27
/**
29
/**
Lines 36-43 Link Here
36
    private int regionClass;
38
    private int regionClass;
37
    private String regionName;
39
    private String regionName;
38
    private CTM ctm;
40
    private CTM ctm;
41
    private int writingMode;
42
    private int referenceOrientation;
39
43
40
41
    // the list of block areas from the static flow
44
    // the list of block areas from the static flow
42
    private ArrayList blocks = new ArrayList();
45
    private ArrayList blocks = new ArrayList();
43
46
Lines 51-57 Link Here
51
     * @param parent the viewport for this region.
54
     * @param parent the viewport for this region.
52
     */
55
     */
53
    public RegionReference(Region regionFO, RegionViewport parent) {
56
    public RegionReference(Region regionFO, RegionViewport parent) {
54
        this(regionFO.getNameId(), regionFO.getRegionName(), parent);
57
        this(regionFO.getNameId(), regionFO.getRegionName(), parent,
58
                Constants.EN_LR_TB, 0);
55
    }
59
    }
56
60
57
    /**
61
    /**
Lines 60-69 Link Here
60
     * @param regionClass the region class (as returned by Region.getNameId())
64
     * @param regionClass the region class (as returned by Region.getNameId())
61
     * @param regionName the name of the region (as returned by Region.getRegionName())
65
     * @param regionName the name of the region (as returned by Region.getRegionName())
62
     * @param parent the viewport for this region.
66
     * @param parent the viewport for this region.
67
     * @param wrMode writing mode
68
     * @param refOrient reference orientation
63
     */
69
     */
64
    public RegionReference(int regionClass, String regionName, RegionViewport parent) {
70
    public RegionReference(int regionClass, String regionName, RegionViewport parent,
71
            int wrMode, int refOrient) {
65
        this.regionClass = regionClass;
72
        this.regionClass = regionClass;
66
        this.regionName = regionName;
73
        this.regionName = regionName;
74
        this.writingMode = wrMode;
75
        this.referenceOrientation = refOrient;
76
        
67
        addTrait(Trait.IS_REFERENCE_AREA, Boolean.TRUE);
77
        addTrait(Trait.IS_REFERENCE_AREA, Boolean.TRUE);
68
        regionViewport = parent;
78
        regionViewport = parent;
69
    }
79
    }
Lines 141-147 Link Here
141
     * @return a copy of this region reference area
151
     * @return a copy of this region reference area
142
     */
152
     */
143
    public Object clone() {
153
    public Object clone() {
144
        RegionReference rr = new RegionReference(regionClass, regionName, regionViewport);
154
        RegionReference rr = new RegionReference(regionClass, regionName, regionViewport, writingMode, referenceOrientation);
145
        rr.ctm = ctm;
155
        rr.ctm = ctm;
146
        rr.setIPD(getIPD());
156
        rr.setIPD(getIPD());
147
        rr.blocks = (ArrayList)blocks.clone();
157
        rr.blocks = (ArrayList)blocks.clone();
Lines 157-160 Link Here
157
        sb.append("}");
167
        sb.append("}");
158
        return sb.toString();
168
        return sb.toString();
159
    }
169
    }
170
    
171
    
172
    public int getWritingMode() {
173
        return writingMode;
174
    }
175
    
176
    public int getReferenceOrientation() {
177
        return referenceOrientation;
178
    }
179
    
160
}
180
}
(-)src/java/org/apache/fop/area/Area.java (-1 / +20 lines)
Lines 21-26 Link Here
21
21
22
import java.io.Serializable;
22
import java.io.Serializable;
23
import java.util.Map;
23
import java.util.Map;
24
import java.util.Vector;
24
25
25
import org.apache.commons.logging.Log;
26
import org.apache.commons.logging.Log;
26
import org.apache.commons.logging.LogFactory;
27
import org.apache.commons.logging.LogFactory;
Lines 136-143 Link Here
136
     */
137
     */
137
    protected static Log log = LogFactory.getLog(Area.class);
138
    protected static Log log = LogFactory.getLog(Area.class);
138
139
139
140
    /**
140
    /**
141
     * The vector of change bars this arrea is affected by	
142
     */
143
    private Vector/*<ChangeBar>*/ changeBars = null;
144
    
145
    /**
146
     * Return the vector of change bars this area is affected by
147
     * @return Vector of change bars or null
148
     */
149
    public Vector/*<ChangeBar>*/ getChangeBars()
150
    {
151
    	return changeBars;
152
    }
153
    
154
    public void setChangeBars(Vector/*<ChangeBar>*/ cbs)
155
    {
156
    	changeBars = cbs;
157
    }
158
    
159
    /**
141
     * Get the area class of this area.
160
     * Get the area class of this area.
142
     *
161
     *
143
     * @return the area class
162
     * @return the area class
(-)src/java/org/apache/fop/fo/flow/ChangeBar.java (+189 lines)
Line 0 Link Here
1
/*
2
 * Licensed to the Apache Software Foundation (ASF) under one or more
3
 * contributor license agreements.  See the NOTICE file distributed with
4
 * this work for additional information regarding copyright ownership.
5
 * The ASF licenses this file to You under the Apache License, Version 2.0
6
 * (the "License"); you may not use this file except in compliance with
7
 * the License.  You may obtain a copy of the License at
8
 *
9
 *      http://www.apache.org/licenses/LICENSE-2.0
10
 *
11
 * Unless required by applicable law or agreed to in writing, software
12
 * distributed under the License is distributed on an "AS IS" BASIS,
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
 * See the License for the specific language governing permissions and
15
 * limitations under the License.
16
 */
17
18
/* $Id$ */
19
20
package org.apache.fop.fo.flow;
21
22
import java.awt.Color;
23
24
import java.util.Collections;
25
import java.util.Map;
26
import java.util.Vector;
27
import java.util.TreeMap;
28
    
29
import org.xml.sax.Attributes;
30
import org.xml.sax.Locator;
31
32
import org.apache.fop.apps.FOPException;
33
import org.apache.fop.fo.FONode;
34
import org.apache.fop.fo.FOTreeBuilderContext;
35
import org.apache.fop.fo.FObj;
36
import org.apache.fop.fo.FObjMixed;
37
import org.apache.fop.fo.PropertyList;
38
import org.apache.fop.fo.PropertyListMaker;
39
import org.apache.fop.fo.ValidationException;
40
import org.apache.fop.fo.properties.Property;
41
import org.apache.fop.fo.properties.PropertyCache;
42
import org.apache.fop.datatypes.Length;
43
44
/** Common change bar base class. Handles properties and local child validation */
45
public abstract class ChangeBar extends FObj {
46
47
    
48
    public ChangeBar(FONode parent) {
49
        super(parent);
50
51
        
52
    }
53
54
    
55
    /**
56
     * The class of the change bar, must be provided
57
     */
58
    protected String cbClass = null;
59
    
60
    /**
61
     * The color of the change bar
62
     */
63
    protected Color color = null;
64
    
65
    /**
66
     * The offset of the bar from the column
67
     */
68
    protected Length offset = null;
69
    
70
    /**
71
     * The placement of the bar
72
     */
73
    protected int placement = -1;
74
    
75
    /**
76
     * The style of the bar
77
     */
78
    protected int style = -1;
79
    
80
    /**
81
     * The width of the bar
82
     */
83
    protected Length width = null;
84
    
85
    
86
    /** {@inheritDoc} */
87
    public void bind(PropertyList pList) throws FOPException {
88
        super.bind(pList);
89
               
90
        cbClass = pList.get(PR_CHANGE_BAR_CLASS).getString();
91
        color = pList.get(PR_CHANGE_BAR_COLOR).getColor(getUserAgent());
92
        offset = pList.get(PR_CHANGE_BAR_OFFSET).getLength(); 
93
        placement = pList.get(PR_CHANGE_BAR_PLACEMENT).getEnum();
94
        style = pList.get(PR_CHANGE_BAR_STYLE).getEnum();
95
        width = pList.get(PR_CHANGE_BAR_WIDTH).getLength();
96
    }
97
    
98
    public String getCBClass()
99
    {
100
    	return cbClass;
101
    }
102
103
    /** {@inheritDoc} */
104
    protected void validateChildNode(
105
            Locator loc,
106
            String namespaceURI,
107
            String localName)
108
   throws ValidationException {
109
        // no children allowed
110
        invalidChildError(loc, namespaceURI, localName);
111
    }
112
113
    /** {@inheritDoc} */
114
    public void processNode(String elementName, Locator locator, Attributes attlist, PropertyList pList) throws FOPException {
115
        super.processNode(elementName, locator, attlist, pList);
116
        if (cbClass == null || "".equals(cbClass)) {
117
            missingPropertyError("change-bar-class");
118
        }
119
        
120
        if ( -1 == findAncestor(FO_FLOW)  &&
121
             -1 == findAncestor(FO_STATIC_CONTENT) ) {
122
            getFOValidationEventProducer().changeBarWrongAncestor(this, getName(), locator);
123
          }
124
    }
125
    
126
    /**
127
     * Check if a class name has already been used
128
     * @param className The name to check
129
     * @return true, if name had been used, false otherwise
130
     */
131
    protected boolean nameUsed(String className) {
132
        return this.getUserAgent().getChangeBars().contains(className);
133
    }
134
    
135
    
136
    /**
137
     * Push the current change bar on the stack
138
     */
139
    protected void push() {
140
        getUserAgent().pushChangeBar(this);
141
    }
142
    
143
    /**
144
     * Remove top level change bar from stack
145
     */
146
    protected void pop() {
147
        getUserAgent().popChangeBar();
148
 
149
    }
150
    
151
    protected ChangeBar top() {
152
        return getUserAgent().topChangeBar();
153
    }
154
155
    /**
156
     * @return the color
157
     */
158
    public Color getColor() {
159
        return color;
160
    }
161
162
    /**
163
     * @return the offset
164
     */
165
    public Length getOffset() {
166
        return offset;
167
    }
168
169
    /**
170
     * @return the placement
171
     */
172
    public int getPlacement() {
173
        return placement;
174
    }
175
176
    /**
177
     * @return the style
178
     */
179
    public int getStyle() {
180
        return style;
181
    }
182
183
    /**
184
     * @return the width
185
     */
186
    public Length getWidth() {
187
        return width;
188
    }
189
}
(-)src/java/org/apache/fop/fo/flow/ChangeBarBegin.java (+72 lines)
Line 0 Link Here
1
/*
2
 * Licensed to the Apache Software Foundation (ASF) under one or more
3
 * contributor license agreements.  See the NOTICE file distributed with
4
 * this work for additional information regarding copyright ownership.
5
 * The ASF licenses this file to You under the Apache License, Version 2.0
6
 * (the "License"); you may not use this file except in compliance with
7
 * the License.  You may obtain a copy of the License at
8
 *
9
 *      http://www.apache.org/licenses/LICENSE-2.0
10
 *
11
 * Unless required by applicable law or agreed to in writing, software
12
 * distributed under the License is distributed on an "AS IS" BASIS,
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
 * See the License for the specific language governing permissions and
15
 * limitations under the License.
16
 */
17
18
/* $Id$ */
19
package org.apache.fop.fo.flow;
20
21
import java.util.Collections;
22
import java.util.Map;
23
24
import org.xml.sax.Attributes;
25
import org.xml.sax.Locator;
26
27
import org.apache.fop.apps.FOPException;
28
import org.apache.fop.fo.FONode;
29
import org.apache.fop.fo.FOTreeBuilderContext;
30
import org.apache.fop.fo.FObj;
31
import org.apache.fop.fo.FObjMixed;
32
import org.apache.fop.fo.PropertyList;
33
import org.apache.fop.fo.PropertyListMaker;
34
import org.apache.fop.fo.ValidationException;
35
import org.apache.fop.fo.properties.Property;
36
import org.apache.fop.fo.properties.PropertyCache;
37
38
/**
39
 * Change bar begin element. Notes the beginning of change bar of a certain class.
40
 * 
41
 */
42
public class ChangeBarBegin extends ChangeBar {
43
44
    
45
    public ChangeBarBegin(FONode parent) {
46
        super(parent);
47
    }
48
49
    /** {@inheritDoc} */
50
    public String getLocalName() {
51
        return "change-bar-begin";
52
    }
53
54
55
    /**
56
     * {@inheritDoc}
57
     * @return {@link org.apache.fop.fo.Constants#FO_CHANGE_BAR_BEGIN}
58
     */
59
    public int getNameId() {
60
        return FO_CHANGE_BAR_BEGIN;
61
    }
62
    
63
    /** {@inheritDoc} */
64
    public void processNode(String elementName, Locator locator, Attributes attlist, PropertyList pList) throws FOPException {
65
        super.processNode(elementName, locator, attlist, pList);
66
        if (nameUsed(cbClass)) {
67
            getFOValidationEventProducer(). changeBarClassNotUnique(this, getName(), cbClass, locator);
68
        } else {
69
            push();
70
        }
71
    }
72
}
(-)src/java/org/apache/fop/fo/flow/ChangeBarEnd.java (+83 lines)
Line 0 Link Here
1
/*
2
 * Licensed to the Apache Software Foundation (ASF) under one or more
3
 * contributor license agreements.  See the NOTICE file distributed with
4
 * this work for additional information regarding copyright ownership.
5
 * The ASF licenses this file to You under the Apache License, Version 2.0
6
 * (the "License"); you may not use this file except in compliance with
7
 * the License.  You may obtain a copy of the License at
8
 *
9
 *      http://www.apache.org/licenses/LICENSE-2.0
10
 *
11
 * Unless required by applicable law or agreed to in writing, software
12
 * distributed under the License is distributed on an "AS IS" BASIS,
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
 * See the License for the specific language governing permissions and
15
 * limitations under the License.
16
 */
17
18
/* $Id$ */
19
20
package org.apache.fop.fo.flow;
21
22
import java.util.Collections;
23
import java.util.Map;
24
25
import org.xml.sax.Attributes;
26
import org.xml.sax.Locator;
27
28
import org.apache.fop.apps.FOPException;
29
import org.apache.fop.fo.FONode;
30
import org.apache.fop.fo.FOTreeBuilderContext;
31
import org.apache.fop.fo.FObj;
32
import org.apache.fop.fo.FObjMixed;
33
import org.apache.fop.fo.PropertyList;
34
import org.apache.fop.fo.PropertyListMaker;
35
import org.apache.fop.fo.ValidationException;
36
import org.apache.fop.fo.properties.Property;
37
import org.apache.fop.fo.properties.PropertyCache;
38
39
/**
40
 * End of a change bar element. Notes the end of the affected objects of a change bar.
41
 *  */
42
public class ChangeBarEnd extends ChangeBar {
43
44
    public ChangeBarEnd(FONode parent) {
45
        super(parent);
46
    }
47
48
    /** {@inheritDoc} */
49
    public String getLocalName() {
50
        return "change-bar-end";
51
    }
52
53
54
    /**
55
     * {@inheritDoc}
56
     * @return {@link org.apache.fop.fo.Constants#FO_CHANGE_BAR_END}
57
     */
58
    public int getNameId() {
59
        return FO_CHANGE_BAR_END;
60
    }
61
    
62
    /** {@inheritDoc} */
63
    public void processNode(String elementName, Locator locator, Attributes attlist, PropertyList pList) throws FOPException {
64
        super.processNode(elementName, locator, attlist, pList);
65
        
66
        // check if we have an element on the stack at all
67
        ChangeBar topElement = top();
68
        
69
        if (null == topElement) {
70
            getFOValidationEventProducer(). changeBarNoBegin(this, getName(),locator);
71
        } else {
72
            if (!topElement.cbClass.equals(cbClass))
73
            {
74
                getFOValidationEventProducer(). changeBarWrongStacking(this,
75
                        getName(), topElement.cbClass, cbClass, locator);
76
            }
77
            pop();
78
        }
79
        
80
        
81
    }
82
    
83
}

Return to bug 48548