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

(-)src/documentation/content/xdocs/trunk/running.xml (-1 / +3 lines)
Lines 109-115 Link Here
109
      </p>
109
      </p>
110
      <source><![CDATA[
110
      <source><![CDATA[
111
USAGE
111
USAGE
112
Fop [options] [-fo|-xml] infile [-xsl file] [-awt|-pdf|-mif|-rtf|-tiff|-png|-pcl|-ps|-txt|-at [mime]|-print] <outfile>
112
Fop [options] [-fo|-xml] infile [-xsl file] [-awt|-pdf|-mif|-odt|-rtf|-tiff|-png|-pcl|-ps|-txt|-at [mime]|-print] <outfile>
113
 [OPTIONS]
113
 [OPTIONS]
114
  -version          print FOP version and exit
114
  -version          print FOP version and exit
115
  -d                debug mode
115
  -d                debug mode
Lines 164-169 Link Here
164
  -pdfa1b outfile   input will be rendered as PDF/A-1b compliant PDF
164
  -pdfa1b outfile   input will be rendered as PDF/A-1b compliant PDF
165
                    (outfile req'd, same as "-pdf outfile -pdfprofile PDF/A-1b")
165
                    (outfile req'd, same as "-pdf outfile -pdfprofile PDF/A-1b")
166
  -awt              input will be displayed on screen
166
  -awt              input will be displayed on screen
167
  -odt outfile      input will be rendered as ODT (outfile req'd)
167
  -rtf outfile      input will be rendered as RTF (outfile req'd)
168
  -rtf outfile      input will be rendered as RTF (outfile req'd)
168
  -pcl outfile      input will be rendered as PCL (outfile req'd)
169
  -pcl outfile      input will be rendered as PCL (outfile req'd)
169
  -ps outfile       input will be rendered as PostScript (outfile req'd)
170
  -ps outfile       input will be rendered as PostScript (outfile req'd)
Lines 197-202 Link Here
197
  fop -xml foo.xml -xsl foo.xsl -foout foo.fo
198
  fop -xml foo.xml -xsl foo.xsl -foout foo.fo
198
  fop -xml - -xsl foo.xsl -pdf -
199
  fop -xml - -xsl foo.xsl -pdf -
199
  fop foo.fo -mif foo.mif
200
  fop foo.fo -mif foo.mif
201
  fop foo.fo -odt foo.odt
200
  fop foo.fo -rtf foo.rtf
202
  fop foo.fo -rtf foo.rtf
201
  fop foo.fo -print
203
  fop foo.fo -print
202
  fop foo.fo -awt]]></source>
204
  fop foo.fo -awt]]></source>
(-)src/documentation/content/xdocs/trunk/output.xml (+9 lines)
Lines 1110-1115 Link Here
1110
      </section>
1110
      </section>
1111
    </section>
1111
    </section>
1112
  </section>
1112
  </section>
1113
<section id="odt">
1114
  <title>ODT</title>
1115
  <p>
1116
    An open source XSL-FO to ODT converter has been integrated into Apache FOP.
1117
    This will create an ODT (rich text format) document that will
1118
    attempt to contain as much information from the XSL-FO document as
1119
    possible.
1120
  </p>
1121
</section>
1113
<section id="rtf">
1122
<section id="rtf">
1114
  <title>RTF</title>
1123
  <title>RTF</title>
1115
  <p>
1124
  <p>
(-)src/java/org/apache/fop/render/odf/FopOdfConverter.java (+47 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
package org.apache.fop.render.odf;
19
20
import java.io.OutputStream;
21
22
import org.apache.fop.fo.FONode;
23
24
/**
25
 * Renderer that renders areas to odt.
26
 */
27
public interface FopOdfConverter {
28
29
    /**
30
     * Initialisation of converter
31
     * @throws OdfException
32
     */
33
    void init() throws OdfException;
34
35
    /**
36
     * Write created odf document to the output stream
37
     * @param os output stream
38
     */
39
    void writeToOutputStream(OutputStream os);
40
41
    /**
42
     * Convert FONode with its children to odf document holden by converter
43
     * @param foNode node of xslfo
44
     */
45
    void convertRecursively(FONode foNode);
46
47
}
(-)src/java/org/apache/fop/render/odf/OdfException.java (+32 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
package org.apache.fop.render.odf;
19
20
import org.apache.avalon.framework.CascadingException;
21
22
public class OdfException extends CascadingException {
23
24
    /**
25
     *
26
     */
27
    private static final long serialVersionUID = 6464226563894799824L;
28
29
    public OdfException(String message, Throwable throwable) {
30
        super(message, throwable);
31
    }
32
}
(-)src/java/org/apache/fop/render/odf/ODTHandler.java (+74 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
package org.apache.fop.render.odf;
19
20
import java.io.OutputStream;
21
22
import org.xml.sax.SAXException;
23
24
import org.apache.fop.apps.FOUserAgent;
25
import org.apache.fop.fo.FOEventHandler;
26
import org.apache.fop.fo.pagination.PageSequence;
27
28
import org.apache.fop.render.odf.odt.FopOdtConverter;
29
30
/**
31
 * ODT Handler: generates ODT output
32
 */
33
public class ODTHandler extends FOEventHandler {
34
35
    private FopOdfConverter converter = new FopOdtConverter();
36
37
    private final OutputStream os;
38
39
    /**
40
     * Constructor : keeping output stream
41
     */
42
    public ODTHandler(FOUserAgent userAgent, OutputStream os) {
43
        super(userAgent);
44
        this.os = os;
45
    }
46
47
    /**
48
     * {@inheritDoc}
49
     */
50
    @Override
51
    public void startDocument() throws SAXException {
52
        try {
53
            converter.init();
54
        } catch (OdfException e) {
55
            e.printStackTrace();
56
        }
57
    }
58
59
    /**
60
     * {@inheritDoc}
61
     */
62
    @Override
63
    public void endDocument() throws SAXException {
64
        converter.writeToOutputStream(os);
65
    }
66
67
    /**
68
     * {@inheritDoc}
69
     */
70
    @Override
71
    public void endPageSequence(PageSequence pageSeq) {
72
        converter.convertRecursively(pageSeq);
73
    }
74
}
(-)src/java/org/apache/fop/render/odf/FopTagType.java (+26 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
package org.apache.fop.render.odf;
19
20
/**
21
 * Defines START and END tags helping to detect hierachical structure of xslfo.
22
 */
23
public enum FopTagType {
24
    START,
25
    END;
26
}
(-)src/java/org/apache/fop/render/odf/odt/Namespace.java (+40 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
package org.apache.fop.render.odf.odt;
19
20
/**
21
 * Defines namespeces used for odf attributes.
22
 */
23
public final class Namespace {
24
25
    public static final String OFFICE = "urn:oasis:names:tc:opendocument:xmlns:office:1.0";
26
27
    public static final String FO     = "urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0";
28
29
    public static final String XLINK  = "http://www.w3.org/1999/xlink";
30
31
    public static final String SVG    = "urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0";
32
33
    public static final String TABLE  = "urn:oasis:names:tc:opendocument:xmlns:table:1.0";
34
35
    public static final String STYLE = "urn:oasis:names:tc:opendocument:xmlns:style:1.0";
36
37
    public static final String TEXT  = "urn:oasis:names:tc:opendocument:xmlns:text:1.0";
38
39
    private Namespace() {  }
40
}
(-)src/java/org/apache/fop/render/odf/odt/FopOdtConverter.java (+115 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
package org.apache.fop.render.odf.odt;
19
20
import java.io.OutputStream;
21
import java.util.Iterator;
22
23
import org.odftoolkit.odfdom.doc.OdfTextDocument;
24
25
import org.apache.fop.fo.FONode;
26
27
import org.apache.fop.render.odf.FopOdfConverter;
28
import org.apache.fop.render.odf.FopTagType;
29
import org.apache.fop.render.odf.OdfException;
30
import org.apache.fop.render.odf.odt.tags.RootTag;
31
import org.apache.fop.render.odf.odt.tags.Tag;
32
import org.apache.fop.render.odf.odt.tags.TagFactory;
33
34
/**
35
 * Renderer that renders areas to odt.
36
 */
37
public class FopOdtConverter implements FopOdfConverter {
38
39
    OdfTextDocument odt = null;
40
41
    private TagFactory factory = new TagFactory();
42
43
    private Tag actualTag = null;
44
45
    /**
46
     * {@inheritDoc}
47
     * @throws OdfException
48
     */
49
    public void init() throws OdfException {
50
51
        try {
52
            odt = OdfTextDocument.newTextDocument();
53
        } catch (Exception e) {
54
            throw new OdfException("Can't initialize the document", e);
55
        }
56
57
        actualTag = new RootTag(odt);
58
    }
59
60
    /**
61
     * {@inheritDoc}
62
     */
63
    public void writeToOutputStream(OutputStream os) {
64
65
        try {
66
            odt.save(os);
67
        } catch (Exception e) {
68
            System.err.println(e.getMessage());
69
            e.printStackTrace();
70
        }
71
    }
72
73
    /**
74
     * {@inheritDoc}
75
     */
76
    public void convertRecursively(FONode foNode) {
77
        this.convert(foNode, FopTagType.START);
78
79
        if (foNode.getChildNodes() != null) {
80
            for (Iterator<?> it = foNode.getChildNodes(); it.hasNext();) {
81
                FONode fn = (FONode) it.next();
82
                convertRecursively(fn);
83
            }
84
        }
85
86
        this.convert(foNode, FopTagType.END);
87
    }
88
89
    /**
90
     * Convert one tag to the element of odt.
91
     * @param image the image which will be painted
92
     * @param context the renderer context for the current renderer
93
     */
94
    private void convert(FONode foNode, FopTagType type) {
95
        if (type == FopTagType.START) {
96
            try {
97
                actualTag = factory.getTag(this, foNode, actualTag);
98
            } catch (OdfException e1) {
99
                e1.printStackTrace();
100
            }
101
            try {
102
                actualTag.execute();
103
            } catch (OdfException e) {
104
                e.printStackTrace();
105
            }
106
        } else if (type == FopTagType.END) {
107
            try {
108
                actualTag.closeIntercept();
109
            } catch (OdfException e) {
110
                e.printStackTrace();
111
            }
112
            actualTag = actualTag.getParent();
113
        }
114
    }
115
}
(-)src/java/org/apache/fop/render/odf/odt/tags/TableCellTag.java (+138 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
package org.apache.fop.render.odf.odt.tags;
19
20
import org.odftoolkit.odfdom.dom.element.style.StyleStyleElement;
21
import org.odftoolkit.odfdom.dom.element.style.StyleTableCellPropertiesElement;
22
import org.odftoolkit.odfdom.dom.element.table.TableTableCellElement;
23
import org.odftoolkit.odfdom.pkg.OdfXMLFactory;
24
25
import org.apache.fop.fo.flow.table.TableCell;
26
import org.apache.fop.render.odf.OdfException;
27
import org.apache.fop.render.odf.odt.Namespace;
28
29
/**
30
 * TableCell converter
31
 */
32
public class TableCellTag extends Tag {
33
34
    private TableCell tblCell = null;
35
36
    private TableTableCellElement tce = null;
37
38
    TableCellTag(Tag parent, TableCell tblCell) {
39
        super(parent);
40
        this.tblCell = tblCell;
41
    }
42
43
    public TableCell getTableCell() {
44
        return tblCell;
45
    }
46
47
    public TableTableCellElement getTableCellElement() {
48
        return tce;
49
    }
50
51
    /**
52
     * {@inheritDoc}
53
     * @throws OdfException
54
     */
55
    @Override
56
    public void execute() throws OdfException {
57
58
        try {
59
            tce = (TableTableCellElement) OdfXMLFactory.newOdfElement(this.getOdt().getContentDom(), TableTableCellElement.ELEMENT_NAME);
60
        } catch (Exception e) {
61
            throw new OdfException("Can't create table cell", e);
62
        }
63
64
        StyleStyleElement sse = null;
65
        try {
66
            sse = (StyleStyleElement) OdfXMLFactory.newOdfElement(this.getOdt().getContentDom(), StyleStyleElement.ELEMENT_NAME);
67
        } catch (Exception e) {
68
            throw new OdfException("Can't create the style for new table cell", e);
69
        }
70
71
        sse.setAttributeNS(Namespace.STYLE, "style:family", "table-cell");
72
73
        StyleTableCellPropertiesElement stcpe = null;
74
75
        try {
76
            stcpe = (StyleTableCellPropertiesElement) OdfXMLFactory.newOdfElement(this.getOdt().getContentDom(), StyleTableCellPropertiesElement.ELEMENT_NAME);
77
        } catch (Exception e) {
78
            throw new OdfException("Can't create style fot table cell", e);
79
        }
80
81
        float borderSize = Math.round(((float)tblCell.getCommonBorderPaddingBackground().getBorderStartWidth(false)) / 100);
82
        borderSize = borderSize / 10;
83
        stcpe.setAttributeNS(Namespace.FO, "fo:border-left", Float.toString(borderSize) + "pt solid #000000");
84
85
        borderSize = Math.round((float)tblCell.getCommonBorderPaddingBackground().getBorderEndWidth(false) / 100);
86
        borderSize = borderSize / 10;
87
        stcpe.setAttributeNS(Namespace.FO, "fo:border-right", Float.toString(borderSize) + "pt solid #000000");
88
89
        borderSize = Math.round((float)tblCell.getCommonBorderPaddingBackground().getBorderBeforeWidth(false) / 100);
90
        borderSize = borderSize / 10;
91
        stcpe.setAttributeNS(Namespace.FO, "fo:border-top", Float.toString(borderSize) + "pt solid #000000");
92
93
        borderSize = Math.round((float)tblCell.getCommonBorderPaddingBackground().getBorderAfterWidth(false) / 100);
94
        borderSize = borderSize / 10;
95
        stcpe.setAttributeNS(Namespace.FO, "fo:border-bottom", Float.toString(borderSize) + "pt solid #000000");
96
97
        float paddingSize = Math.round((float)tblCell.getCommonBorderPaddingBackground().getPaddingLengthProperty(0).getLengthValue() / 100);
98
        paddingSize = paddingSize / 10;
99
        stcpe.setAttributeNS(Namespace.FO, "fo:padding-left", Float.toString(paddingSize) + "pt");
100
101
        paddingSize = Math.round((float)tblCell.getCommonBorderPaddingBackground().getPaddingLengthProperty(1).getLengthValue() / 100);
102
        paddingSize = paddingSize / 10;
103
        stcpe.setAttributeNS(Namespace.FO, "fo:padding-top", Float.toString(paddingSize) + "pt");
104
105
        paddingSize = Math.round((float)tblCell.getCommonBorderPaddingBackground().getPaddingLengthProperty(2).getLengthValue() / 100);
106
        paddingSize = paddingSize / 10;
107
        stcpe.setAttributeNS(Namespace.FO, "fo:padding-right", Float.toString(paddingSize) + "pt");
108
109
        paddingSize = Math.round((float)tblCell.getCommonBorderPaddingBackground().getPaddingLengthProperty(3).getLengthValue() / 100);
110
        paddingSize = paddingSize / 10;
111
        stcpe.setAttributeNS(Namespace.FO, "fo:padding-bottom", Float.toString(paddingSize) + "pt");
112
113
        sse.appendChild(stcpe);
114
115
        tce.setAttributeNS(Namespace.TABLE, "table:number-columns-spanned", Integer.toString(tblCell.getNumberColumnsSpanned()));
116
        tce.setAttributeNS(Namespace.TABLE, "table:number-rows-spanned",     Integer.toString(tblCell.getNumberRowsSpanned()));
117
118
        tce.setStyleName(this.appendNewStyle(sse));
119
120
        parent.executeFromParent(this);
121
    }
122
123
    @Override
124
    public void execute(TableRowTag tag) throws OdfException {
125
        try {
126
            tag.getTableRow().appendChild(tce);
127
        } catch (Exception e) {
128
            throw new OdfException("Can't create table cell", e);
129
        }
130
    }
131
132
    public void executeFromParent(TagExecutable child) throws OdfException {
133
        if (this != child) {
134
            child.execute(this);
135
        }
136
    }
137
138
}
(-)src/java/org/apache/fop/render/odf/odt/tags/TableBodyTag.java (+45 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
package org.apache.fop.render.odf.odt.tags;
19
20
import org.apache.fop.fo.flow.table.TableBody;
21
import org.apache.fop.render.odf.OdfException;
22
23
/**
24
 * TableBody converter
25
 */
26
public class TableBodyTag extends Tag {
27
28
    TableBodyTag(Tag parent, TableBody tblBody) {
29
        super(parent);
30
    }
31
32
    /**
33
     * {@inheritDoc}
34
     */
35
    @Override
36
    public void execute() { }
37
38
    /**
39
     * {@inheritDoc}
40
     * @throws OdfException
41
     */
42
    public void executeFromParent(TagExecutable child) throws OdfException {
43
        parent.executeFromParent(child);
44
    }
45
}
(-)src/java/org/apache/fop/render/odf/odt/tags/InstreamForeignObjectTag.java (+46 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
package org.apache.fop.render.odf.odt.tags;
19
20
import org.apache.fop.fo.flow.InstreamForeignObject;
21
import org.apache.fop.render.odf.OdfException;
22
23
/**
24
 * InstreamForeignObject converter
25
 */
26
public class InstreamForeignObjectTag extends Tag {
27
28
    InstreamForeignObjectTag(Tag parent, InstreamForeignObject foNode) {
29
        super(parent);
30
    }
31
32
    /**
33
     * {@inheritDoc}
34
     */
35
    @Override
36
    public void execute() { }
37
38
    /**
39
     * {@inheritDoc}
40
     * @throws OdfException
41
     */
42
    public void executeFromParent(TagExecutable child) throws OdfException {
43
        child.execute(this);
44
    }
45
46
}
(-)src/java/org/apache/fop/render/odf/odt/tags/PageNumberCitationTag.java (+46 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
package org.apache.fop.render.odf.odt.tags;
19
20
import org.apache.fop.fo.flow.PageNumberCitation;
21
import org.apache.fop.render.odf.OdfException;
22
23
/**
24
 * PageNumberCitation converter
25
 */
26
public class PageNumberCitationTag extends Tag {
27
28
    PageNumberCitationTag(Tag parent, PageNumberCitation foNode) {
29
        super(parent);
30
    }
31
32
    /**
33
     * {@inheritDoc}
34
     */
35
    @Override
36
    public void execute() { }
37
38
    /**
39
     * {@inheritDoc}
40
     * @throws OdfException
41
     */
42
    public void executeFromParent(TagExecutable child) throws OdfException {
43
        child.execute(this);
44
    }
45
46
}
(-)src/java/org/apache/fop/render/odf/odt/tags/LeaderTag.java (+49 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
package org.apache.fop.render.odf.odt.tags;
19
20
import org.apache.fop.fo.flow.Leader;
21
import org.apache.fop.render.odf.OdfException;
22
23
/**
24
 * Leader converter
25
 */
26
public class LeaderTag extends Tag {
27
28
    protected LeaderTag(Tag parent, Leader foNode) {
29
        super(parent);
30
    }
31
32
    /**
33
     * {@inheritDoc}
34
     */
35
    @Override
36
    public void execute() {
37
        // TODO Auto-generated method stub
38
39
    }
40
41
    /**
42
     * {@inheritDoc}
43
     * @throws OdfException
44
     */
45
    public void executeFromParent(TagExecutable child) throws OdfException {
46
        child.execute(this);
47
    }
48
49
}
(-)src/java/org/apache/fop/render/odf/odt/tags/TagFactory.java (+116 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
package org.apache.fop.render.odf.odt.tags;
19
20
import org.apache.fop.fo.FONode;
21
import org.apache.fop.fo.FOText;
22
import org.apache.fop.fo.flow.BasicLink;
23
import org.apache.fop.fo.flow.Block;
24
import org.apache.fop.fo.flow.BlockContainer;
25
import org.apache.fop.fo.flow.Character;
26
import org.apache.fop.fo.flow.ExternalGraphic;
27
import org.apache.fop.fo.flow.Footnote;
28
import org.apache.fop.fo.flow.FootnoteBody;
29
import org.apache.fop.fo.flow.Inline;
30
import org.apache.fop.fo.flow.InstreamForeignObject;
31
import org.apache.fop.fo.flow.Leader;
32
import org.apache.fop.fo.flow.ListBlock;
33
import org.apache.fop.fo.flow.ListItem;
34
import org.apache.fop.fo.flow.ListItemBody;
35
import org.apache.fop.fo.flow.ListItemLabel;
36
import org.apache.fop.fo.flow.PageNumber;
37
import org.apache.fop.fo.flow.PageNumberCitation;
38
import org.apache.fop.fo.flow.table.Table;
39
import org.apache.fop.fo.flow.table.TableBody;
40
import org.apache.fop.fo.flow.table.TableCell;
41
import org.apache.fop.fo.flow.table.TableColumn;
42
import org.apache.fop.fo.flow.table.TableFooter;
43
import org.apache.fop.fo.flow.table.TableHeader;
44
import org.apache.fop.fo.flow.table.TableRow;
45
import org.apache.fop.fo.pagination.Flow;
46
import org.apache.fop.fo.pagination.PageSequence;
47
import org.apache.fop.fo.pagination.StaticContent;
48
import org.apache.fop.render.odf.OdfException;
49
import org.apache.fop.render.odf.odt.FopOdtConverter;
50
51
/**
52
 * Factory that creates tag converters
53
 */
54
public class TagFactory {
55
56
    public Tag getTag(FopOdtConverter converter, FONode foNode, Tag actualTag) throws OdfException {
57
        if (foNode instanceof PageSequence)            {
58
            return new PageSequenceTag(actualTag, (PageSequence) foNode, converter);
59
        } else if (foNode instanceof Flow) {
60
            return new FlowTag(actualTag, (Flow) foNode);
61
        } else if (foNode instanceof StaticContent) {
62
            return new StaticContentTag(actualTag, (StaticContent) foNode);
63
        } else if (foNode instanceof ExternalGraphic) {
64
            return new ExternalGraphicTag(actualTag, (ExternalGraphic) foNode);
65
        } else if (foNode instanceof InstreamForeignObject) {
66
            return new InstreamForeignObjectTag(actualTag, (InstreamForeignObject) foNode);
67
        } else if (foNode instanceof Block) {
68
            return new BlockTag(actualTag, (Block) foNode);
69
        } else if (foNode instanceof BlockContainer) {
70
            return new BlockContainerTag(actualTag, (BlockContainer) foNode);
71
        } else if (foNode instanceof BasicLink) {
72
            return new BasicLinkTag(actualTag, (BasicLink) foNode);
73
        } else if (foNode instanceof Inline) {
74
            return new InlineTag(actualTag, (Inline) foNode);
75
        } else if (foNode instanceof FOText) {
76
            return new Text(actualTag, (FOText) foNode);
77
        } else if (foNode instanceof Character) {
78
            return new CharacterTag(actualTag, (Character) foNode);
79
        } else if (foNode instanceof PageNumber) {
80
            return new PageNumberTag(actualTag, (PageNumber) foNode);
81
        } else if (foNode instanceof Footnote) {
82
            return new FootnoteTag(actualTag, (Footnote) foNode);
83
        } else if (foNode instanceof FootnoteBody) {
84
            return new FootnoteBodyTag(actualTag, (FootnoteBody) foNode);
85
        } else if (foNode instanceof ListBlock) {
86
            return new ListBlockTag(actualTag, (ListBlock) foNode);
87
        } else if (foNode instanceof ListItemBody) {
88
            return new ListItemBodyTag(actualTag, (ListItemBody) foNode);
89
        } else if (foNode instanceof ListItem) {
90
            return new ListItemTag(actualTag, (ListItem) foNode, converter);
91
        } else if (foNode instanceof ListItemLabel) {
92
            return new ListItemLabelTag(actualTag, (ListItemLabel) foNode);
93
        } else if (foNode instanceof Table) {
94
            return new TableTag(actualTag, (Table) foNode);
95
        } else if (foNode instanceof TableHeader) {
96
            return new TableHeaderTag(actualTag, (TableHeader) foNode);
97
        } else if (foNode instanceof TableFooter) {
98
            return new TableFooterTag(actualTag, (TableFooter) foNode);
99
        } else if (foNode instanceof TableBody) {
100
            return new TableBodyTag(actualTag, (TableBody) foNode);
101
        } else if (foNode instanceof TableColumn) {
102
            return new TableColumnTag(actualTag, (TableColumn) foNode);
103
        } else if (foNode instanceof TableRow) {
104
            return new TableRowTag(actualTag, (TableRow) foNode);
105
        } else if (foNode instanceof TableCell) {
106
            return new TableCellTag(actualTag, (TableCell) foNode);
107
        } else if (foNode instanceof Leader) {
108
            return new LeaderTag(actualTag, (Leader) foNode);
109
        } else if (foNode instanceof PageNumberCitation) {
110
            return new PageNumberCitationTag(actualTag, (PageNumberCitation) foNode);
111
        } else {
112
            return new UnknownTag(actualTag);
113
        }
114
    }
115
116
}
(-)src/java/org/apache/fop/render/odf/odt/tags/ListItemTag.java (+90 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
package org.apache.fop.render.odf.odt.tags;
19
20
import org.odftoolkit.odfdom.dom.element.text.TextListItemElement;
21
import org.odftoolkit.odfdom.pkg.OdfXMLFactory;
22
23
import org.apache.fop.fo.flow.ListItem;
24
import org.apache.fop.render.odf.OdfException;
25
import org.apache.fop.render.odf.odt.FopOdtConverter;
26
27
/**
28
 * ListItem converter
29
 */
30
public class ListItemTag extends Tag {
31
32
    private ListItem xslfoListItem = null;
33
34
    private TextListItemElement tlie = null;
35
36
    private FopOdtConverter converter = null;
37
38
    ListItemTag(Tag parent, ListItem foNode, FopOdtConverter converter) {
39
        super(parent);
40
        this.xslfoListItem = foNode;
41
        this.converter = converter;
42
    }
43
44
    public ListItem getXslfoListItem() {
45
        return xslfoListItem;
46
    }
47
48
    public TextListItemElement getTextListItemElement() {
49
        return tlie;
50
    }
51
52
    /**
53
     * {@inheritDoc}
54
     * @throws OdfException
55
     */
56
    @Override
57
    public void execute() throws OdfException {
58
        try {
59
            tlie = (TextListItemElement) OdfXMLFactory.newOdfElement(this.getOdt().getContentDom(), TextListItemElement.ELEMENT_NAME);
60
        } catch (Exception e) {
61
            throw new OdfException("Can't create List Item", e);
62
        }
63
64
        parent.executeFromParent(this);
65
66
        converter.convertRecursively(xslfoListItem.getBody());
67
    }
68
69
    /**
70
     * {@inheritDoc}
71
     * @throws OdfException
72
     */
73
    @Override
74
    public void execute(ListBlockTag tag) throws OdfException {
75
        try {
76
            tag.getTextListElement().appendChild(tlie);
77
        } catch (Exception e) {
78
            throw new OdfException("Can't create List Item", e);
79
        }
80
    }
81
82
    /**
83
     * {@inheritDoc}
84
     * @throws OdfException
85
     */
86
    public void executeFromParent(TagExecutable child) throws OdfException {
87
        child.execute(this);
88
    }
89
90
}
(-)src/java/org/apache/fop/render/odf/odt/tags/Tag.java (+227 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
package org.apache.fop.render.odf.odt.tags;
19
20
import java.util.Map;
21
import java.util.Random;
22
import java.util.Vector;
23
24
import org.odftoolkit.odfdom.doc.OdfTextDocument;
25
import org.odftoolkit.odfdom.dom.OdfContentDom;
26
import org.odftoolkit.odfdom.dom.element.style.StyleFontFaceElement;
27
import org.odftoolkit.odfdom.dom.element.style.StyleStyleElement;
28
import org.odftoolkit.odfdom.dom.element.text.TextPElement;
29
import org.odftoolkit.odfdom.pkg.OdfElement;
30
import org.odftoolkit.odfdom.pkg.OdfXMLFactory;
31
import org.w3c.dom.DOMException;
32
import org.w3c.dom.Node;
33
34
import org.apache.fop.fo.pagination.Flow;
35
import org.apache.fop.render.odf.FopTagType;
36
import org.apache.fop.render.odf.OdfException;
37
import org.apache.fop.render.odf.odt.Namespace;
38
import org.apache.fop.render.odf.odt.Style;
39
40
/**
41
 * Tag converter abstract class.
42
 */
43
public abstract class Tag implements TagExecutable, TagExecutor {
44
45
    protected Tag parent = null;
46
47
    protected Style currentStyle = null;
48
49
    private static Random rand = new Random();
50
51
    protected Tag(Tag parent) {
52
        this.parent = parent;
53
        if (parent != null) {
54
            currentStyle = new Style(parent.getStyle());
55
        } else {
56
            currentStyle = new Style();
57
        }
58
    }
59
60
    protected OdfTextDocument getOdt() {
61
        return parent != null ? parent.getOdt() : null;
62
    }
63
64
    protected Map<String, StyleStyleElement> getUsedStyles() {
65
        return parent.getUsedStyles();
66
    }
67
68
    protected Vector<String> getUsedFonts() {
69
        return parent.getUsedFonts();
70
    }
71
72
    protected void registerFont(String font) throws OdfException {
73
        if (!this.getUsedFonts().contains(font)) {
74
            StyleFontFaceElement sffe = null;
75
            try {
76
                sffe = (StyleFontFaceElement) OdfXMLFactory.newOdfElement(this.getOdt().getContentDom(), StyleFontFaceElement.ELEMENT_NAME);
77
            } catch (Exception e) {
78
                throw new OdfException("Can't create new style.", e);
79
            }
80
81
            if (isOnlyOneParagraph(this.getOdt())) {
82
                removeLastParagraph(this.getOdt());
83
            }
84
85
            sffe.setStyleNameAttribute(font);
86
            sffe.setAttributeNS(Namespace.SVG, "svg:font-family", font);
87
            try {
88
                this.getOdt().getContentDom().getElementsByTagNameNS(Namespace.OFFICE, "font-face-decls").item(0).appendChild(sffe);
89
            } catch (Exception e) {
90
                throw new OdfException("Can't register new font", e);
91
            }
92
            this.getUsedFonts().add(font);
93
        }
94
    }
95
96
    private boolean isOnlyOneParagraph(OdfTextDocument textDocument) {
97
        int i = 0;
98
        try {
99
            i = textDocument.getContentDom().getElementsByTagNameNS(Namespace.TEXT, "p").getLength();
100
        } catch (Exception e) {
101
            return false;
102
        }
103
        return i == 1 ? true : false;
104
    }
105
106
    private void removeLastParagraph(OdfTextDocument textDocument) {
107
        try {
108
            textDocument.getContentDom().getElementsByTagNameNS(Namespace.OFFICE, "text").item(0).removeChild(textDocument.getContentDom().getElementsByTagNameNS(Namespace.TEXT, "p").item(0));
109
        } catch (Exception e) {
110
            e.printStackTrace();
111
        }
112
    }
113
114
    protected Style getStyle() {
115
        return this.currentStyle;
116
    }
117
118
    public Tag getParent() {
119
        return parent;
120
    }
121
122
    protected OdfElement getTextContainer() {
123
        if (parent != null) {
124
            return parent.getTextContainer();
125
        } else {
126
            return null;
127
        }
128
    }
129
130
    protected TextPElement getParagraph() throws OdfException {
131
        return parent != null ? parent.getParagraph() : null;
132
    }
133
134
    protected OdfElement getParagraphContainer() {
135
        return parent != null ? parent.getParagraphContainer() : null;
136
    }
137
138
    protected TextPElement newParagraph(Node paragraphContainer) throws OdfException {
139
140
        TextPElement tpe = null;
141
142
        try {
143
            tpe = (TextPElement) OdfXMLFactory.newOdfElement(this.getOdt().getContentDom(), TextPElement.ELEMENT_NAME);
144
        } catch (Exception e1) {
145
            throw new OdfException("Can't create new style.", e1);
146
        }
147
148
        try {
149
            paragraphContainer.appendChild(tpe);
150
        } catch (DOMException e) {
151
            throw new OdfException("Can't create new paragraph", e);
152
        }
153
154
        return tpe;
155
    }
156
157
    protected String appendNewStyle(StyleStyleElement sse) throws OdfException {
158
159
        sse.setAttributeNS(Namespace.STYLE, "style:name", "");
160
161
        String styleName = Style.getStyleName(this.getUsedStyles(), sse);
162
163
        if (styleName == null) {
164
            styleName = generateName();
165
            sse.setAttributeNS(Namespace.STYLE, "style:name", styleName);
166
167
            try {
168
                OdfContentDom odf = this.getOdt().getContentDom();
169
                Node odfstyles = odf.getElementsByTagNameNS(Namespace.OFFICE, "automatic-styles").item(0);
170
                odfstyles.appendChild(sse);
171
            } catch (Exception e) {
172
                throw new OdfException("Can't create new style.", e);
173
            }
174
175
            this.getUsedStyles().put(styleName, sse);
176
        }
177
178
        return styleName;
179
    }
180
181
    private String generateName() {
182
        return Integer.toString(rand.nextInt());
183
    }
184
185
    public abstract void execute() throws OdfException;
186
187
    public Tag execute(Flow fl, FopTagType type) {
188
        return this;
189
    }
190
191
    public void closeIntercept() throws OdfException { }
192
193
    public void execute(Tag tag) throws OdfException { }
194
195
    public void execute(BlockTag tag) throws OdfException {
196
        this.execute((Tag) tag);
197
    }
198
199
    public void execute(InlineTag tag) throws OdfException {
200
        this.execute((Tag) tag);
201
    }
202
203
    public void execute(BasicLinkTag tag) throws OdfException {
204
        this.execute((Tag) tag);
205
    }
206
207
    public void execute(TableTag tag) throws OdfException {
208
        this.execute((Tag) tag);
209
    }
210
211
    public void execute(TableRowTag tag) throws OdfException {
212
        this.execute((Tag) tag);
213
    }
214
215
    public void execute(TableCellTag tag) throws OdfException {
216
        this.execute((Tag) tag);
217
    }
218
219
    public void execute(ListBlockTag tag) throws OdfException {
220
        this.execute((Tag) tag);
221
    }
222
223
    public void execute(ListItemTag tag) throws OdfException {
224
        this.execute((Tag) tag);
225
    }
226
227
}
(-)src/java/org/apache/fop/render/odf/odt/tags/Text.java (+132 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
package org.apache.fop.render.odf.odt.tags;
19
20
import org.odftoolkit.odfdom.dom.element.text.TextLineBreakElement;
21
import org.odftoolkit.odfdom.dom.element.text.TextSElement;
22
import org.odftoolkit.odfdom.dom.element.text.TextTabElement;
23
import org.odftoolkit.odfdom.pkg.OdfElement;
24
import org.odftoolkit.odfdom.pkg.OdfFileDom;
25
26
import org.apache.fop.fo.FOText;
27
import org.apache.fop.render.odf.OdfException;
28
29
/**
30
 * Text converter
31
 */
32
public class Text extends Tag {
33
34
    private String string = null;
35
36
    Text(Tag parent, FOText textFop) {
37
        super(parent);
38
        this.string = textFop.getCharSequence().toString();
39
    }
40
41
    @Override
42
    public void execute() throws OdfException {
43
44
        if (string.length() == 0) {
45
            return;
46
        }
47
48
        parent.executeFromParent(this);
49
    }
50
51
    @Override
52
    public void execute(Tag parent) throws OdfException {
53
        if (string != null && !string.equals("")) {
54
            appendTextElements(parent.getTextContainer(), string, true);
55
        }
56
    }
57
58
    public void executeFromParent(TagExecutable child) throws OdfException {
59
        if (this != child) {
60
            child.execute(this);
61
        }
62
    }
63
64
    /**
65
     * Function came from Apache simple-odf-0.6.6 (incubation)
66
     * Paragraph.java:667
67
     * http://incubator.apache.org/odftoolkit/simple/index.html
68
     * @param ownerElement
69
     * @param content
70
     * @param isWhitespaceCollapsed
71
     */
72
    private void appendTextElements(OdfElement ownerElement, String content, boolean isWhitespaceCollapsed) {
73
        OdfFileDom ownerDocument = (OdfFileDom) ownerElement.getOwnerDocument();
74
        if (isWhitespaceCollapsed) {
75
            int i = 0;
76
            int length = content.length();
77
            String str = "";
78
            while (i < length) {
79
                char ch = content.charAt(i);
80
                if (ch == ' ') {
81
                    int j = 1;
82
                    i++;
83
                    while ((i < length) && (content.charAt(i) == ' ')) {
84
                        j++;
85
                        i++;
86
                    }
87
                    if (j == 1) {
88
                        str += ' ';
89
                    } else {
90
                        str += ' ';
91
                        org.w3c.dom.Text textnode = ownerDocument.createTextNode(str);
92
                        ownerElement.appendChild(textnode);
93
                        str = "";
94
                        TextSElement spaceElement = ownerDocument.newOdfElement(TextSElement.class);
95
                        ownerElement.appendChild(spaceElement);
96
                        spaceElement.setTextCAttribute(j - 1);
97
                    }
98
                } else if (ch == '\n') {
99
                    if (str.length() > 0) {
100
                        org.w3c.dom.Text textnode = ownerDocument.createTextNode(str);
101
                        ownerElement.appendChild(textnode);
102
                        str = "";
103
                    }
104
                    TextLineBreakElement lineBreakElement = ownerDocument.newOdfElement(TextLineBreakElement.class);
105
                    ownerElement.appendChild(lineBreakElement);
106
                    i++;
107
                } else if (ch == '\t') {
108
                    if (str.length() > 0) {
109
                        org.w3c.dom.Text textnode = ownerElement.getOwnerDocument().createTextNode(str);
110
                        ownerElement.appendChild(textnode);
111
                        str = "";
112
                    }
113
                    TextTabElement tabElement = ownerDocument.newOdfElement(TextTabElement.class);
114
                    ownerElement.appendChild(tabElement);
115
                    i++;
116
                } else if (ch == '\r') {
117
                    i++;
118
                } else {
119
                    str += ch;
120
                    i++;
121
                }
122
            }
123
            if (str.length() > 0) {
124
                org.w3c.dom.Text textnode = ownerDocument.createTextNode(str);
125
                ownerElement.appendChild(textnode);
126
            }
127
        } else {
128
            org.w3c.dom.Text textnode = ownerDocument.createTextNode(content);
129
            ownerElement.appendChild(textnode);
130
        }
131
    }
132
}
(-)src/java/org/apache/fop/render/odf/odt/tags/TableFooterTag.java (+39 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
package org.apache.fop.render.odf.odt.tags;
19
20
import org.apache.fop.fo.flow.table.TableFooter;
21
import org.apache.fop.render.odf.OdfException;
22
23
/**
24
 * TableFooter converter
25
 */
26
public class TableFooterTag extends Tag {
27
28
    TableFooterTag(Tag parent, TableFooter tblFooter) {
29
        super(parent);
30
    }
31
32
    @Override
33
    public void execute() { }
34
35
    public void executeFromParent(TagExecutable child) throws OdfException {
36
        child.execute(this);
37
    }
38
39
}
(-)src/java/org/apache/fop/render/odf/odt/tags/BasicLinkTag.java (+117 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
package org.apache.fop.render.odf.odt.tags;
19
20
import org.odftoolkit.odfdom.dom.element.text.TextAElement;
21
import org.odftoolkit.odfdom.dom.element.text.TextBookmarkRefElement;
22
import org.odftoolkit.odfdom.pkg.OdfElement;
23
import org.odftoolkit.odfdom.pkg.OdfXMLFactory;
24
25
import org.w3c.dom.DOMException;
26
27
import org.apache.fop.fo.flow.BasicLink;
28
import org.apache.fop.render.odf.OdfException;
29
import org.apache.fop.render.odf.odt.Namespace;
30
import org.apache.fop.render.odf.odt.Style;
31
import org.apache.fop.render.odf.odt.Style.Params;
32
33
/**
34
 * VasicLink converter
35
 */
36
public class BasicLinkTag extends Tag {
37
38
    BasicLink basicLink = null;
39
40
    OdfElement oe = null;
41
42
    /**
43
     * Constructor.
44
     */
45
    public BasicLinkTag(Tag parent, BasicLink basicLink) {
46
        super(parent);
47
        this.basicLink = basicLink;
48
49
        this.currentStyle.getParameters().put(Params.FONT_NAME,                                 basicLink.getCommonFont().getFirstFontFamily().split(",")[0]);
50
        this.currentStyle.getParameters().put(Params.FONT_STYLE,  Style.fopFontToOdfFontStyle(  basicLink.getCommonFont()));
51
        this.currentStyle.getParameters().put(Params.FONT_WEIGHT, Style.fopFontToOdfFontWeight( basicLink.getCommonFont()));
52
        this.currentStyle.getParameters().put(Params.FONT_SIZE,   Style.fopLengthToPt(          basicLink.getCommonFont().getFontSize()));
53
        this.currentStyle.getParameters().put(Params.COLOR,       Style.awtColorToOdfColor(     basicLink.getColor()));
54
    }
55
56
    public OdfElement getLinkElement() {
57
        return oe;
58
    }
59
60
    @Override
61
    protected OdfElement getTextContainer() {
62
        if (this.oe != null) {
63
            return this.oe;
64
        } else {
65
            return parent.getTextContainer();
66
        }
67
    }
68
69
    /**
70
     * {@inheritDoc}
71
     */
72
    @Override
73
    public void execute() {
74
        if (basicLink.hasExternalDestination()) {
75
            try {
76
                oe = (TextAElement) OdfXMLFactory.newOdfElement(this.getOdt().getContentDom(), TextAElement.ELEMENT_NAME);
77
            } catch (Exception e1) {
78
                e1.printStackTrace();
79
            }
80
            String url = basicLink.getExternalDestination();
81
            if (url.startsWith("url")) {
82
                url = url.substring(5, url.length() - 2);
83
            }
84
            oe.setAttributeNS(Namespace.XLINK, "xlink:href", url);
85
            oe.setAttributeNS(Namespace.XLINK, "xlink:type", "simple");
86
        } else if (basicLink.hasInternalDestination()) {
87
            try {
88
                oe = (TextBookmarkRefElement) OdfXMLFactory.newOdfElement(this.getOdt().getContentDom(), TextBookmarkRefElement.ELEMENT_NAME);
89
            } catch (Exception e) {
90
                e.printStackTrace();
91
            }
92
            oe.setAttributeNS(Namespace.TEXT, "text:ref-name", basicLink.getInternalDestination());
93
            oe.setAttributeNS(Namespace.TEXT, "text:reference-format", "page");
94
        }
95
    }
96
97
    /**
98
     * {@inheritDoc}
99
     * @throws OdfException
100
     */
101
    @Override
102
    public void closeIntercept() throws OdfException {
103
        try {
104
            parent.getTextContainer().appendChild(oe);
105
        } catch (DOMException e) {
106
            e.printStackTrace();
107
        }
108
    }
109
110
    /**
111
     * {@inheritDoc}
112
     * @throws OdfException
113
     */
114
    public void executeFromParent(TagExecutable child) throws OdfException {
115
        child.execute(this);
116
    }
117
}
(-)src/java/org/apache/fop/render/odf/odt/tags/StaticTag.java (+37 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
package org.apache.fop.render.odf.odt.tags;
19
20
import org.apache.fop.render.odf.OdfException;
21
22
/**
23
 *
24
 */
25
public class StaticTag extends Tag {
26
27
    protected StaticTag(Tag parent) {
28
        super(parent);
29
    }
30
31
    @Override
32
    public void execute() { }
33
34
    public void executeFromParent(TagExecutable child) throws OdfException {
35
        child.execute(this);
36
    }
37
}
(-)src/java/org/apache/fop/render/odf/odt/tags/TableTag.java (+98 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
package org.apache.fop.render.odf.odt.tags;
19
20
import org.odftoolkit.odfdom.dom.element.table.TableTableColumnElement;
21
import org.odftoolkit.odfdom.dom.element.table.TableTableElement;
22
import org.odftoolkit.odfdom.pkg.OdfXMLFactory;
23
import org.w3c.dom.DOMException;
24
25
26
import org.apache.fop.fo.flow.table.Table;
27
import org.apache.fop.render.odf.OdfException;
28
import org.apache.fop.render.odf.odt.Namespace;
29
30
/**
31
 * Table converter
32
 */
33
public class TableTag extends Tag {
34
35
    private Table table = null;
36
37
    private TableTableElement tte = null;
38
39
    TableTag(Tag parent, Table table) {
40
        super(parent);
41
        this.table = table;
42
    }
43
44
    public TableTableElement getTable() {
45
        return tte;
46
    }
47
48
    /**
49
     * {@inheritDoc}
50
     * @throws OdfException
51
     */
52
    @Override
53
    public void execute() throws OdfException {
54
55
        try {
56
            tte = (TableTableElement) OdfXMLFactory.newOdfElement(this.getOdt().getContentDom(), TableTableElement.ELEMENT_NAME);
57
        } catch (Exception e) {
58
            throw new OdfException("Can't create new table.", e);
59
        }
60
        tte.setAttributeNS(Namespace.TABLE, "table:align", "margins");
61
62
        if (table.getColumns().size() > 1) {
63
            TableTableColumnElement tcne = null;
64
            try {
65
                tcne = (TableTableColumnElement) OdfXMLFactory.newOdfElement(this.getOdt().getContentDom(), TableTableColumnElement.ELEMENT_NAME);
66
            } catch (Exception e) {
67
                throw new OdfException("Can't create new table column.", e);
68
            }
69
            tcne.setAttributeNS(Namespace.TABLE,
70
                                "table:number-columns-repeated",
71
                                Integer.toString(table.getColumns().size()));
72
73
            try {
74
                tte.appendChild(tcne);
75
            } catch (Exception e) {
76
                throw new OdfException("Can't create table.", e);
77
            }
78
        }
79
    }
80
81
    /**
82
     * {@inheritDoc}
83
     */
84
    @Override
85
    public void closeIntercept() {
86
        try {
87
            this.getParagraphContainer().appendChild(tte);
88
        } catch (DOMException e) {
89
            e.printStackTrace();
90
        } catch (Exception e) {
91
            e.printStackTrace();
92
        }
93
    }
94
95
    public void executeFromParent(TagExecutable child) throws OdfException {
96
        child.execute(this);
97
    }
98
}
(-)src/java/org/apache/fop/render/odf/odt/tags/UnknownTag.java (+38 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
package org.apache.fop.render.odf.odt.tags;
19
20
import org.apache.fop.render.odf.OdfException;
21
22
/**
23
 * Unknown tag converter
24
 */
25
public class UnknownTag extends Tag {
26
27
    protected UnknownTag(Tag parent) {
28
        super(parent);
29
    }
30
31
    @Override
32
    public void execute() { }
33
34
    public void executeFromParent(TagExecutable child) throws OdfException {
35
        child.execute(this);
36
    }
37
38
}
(-)src/java/org/apache/fop/render/odf/odt/tags/FootnoteBodyTag.java (+46 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
package org.apache.fop.render.odf.odt.tags;
19
20
import org.apache.fop.fo.flow.FootnoteBody;
21
import org.apache.fop.render.odf.OdfException;
22
23
/**
24
 * FootnoteBodyConverter
25
 */
26
public class FootnoteBodyTag extends Tag {
27
28
    protected FootnoteBodyTag(Tag parent, FootnoteBody foNode) {
29
        super(parent);
30
    }
31
32
    /**
33
     * {@inheritDoc}
34
     */
35
    @Override
36
    public void execute() { }
37
38
    /**
39
     * {@inheritDoc}
40
     * @throws OdfException
41
     */
42
    public void executeFromParent(TagExecutable child) throws OdfException {
43
        child.execute(this);
44
    }
45
46
}
(-)src/java/org/apache/fop/render/odf/odt/tags/BlockContainerTag.java (+51 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
package org.apache.fop.render.odf.odt.tags;
19
20
import org.apache.fop.fo.flow.BlockContainer;
21
import org.apache.fop.render.odf.OdfException;
22
23
/**
24
 * BlockContainer converter
25
 */
26
public class BlockContainerTag extends Tag {
27
28
    /**
29
     * Constructor
30
     */
31
    protected BlockContainerTag(Tag parent, BlockContainer foNode) {
32
        super(parent);
33
    }
34
35
    /**
36
     * {@inheritDoc}
37
     */
38
    @Override
39
    public void execute() {
40
41
    }
42
43
    /**
44
     * {@inheritDoc}
45
     * @throws OdfException
46
     */
47
    public void executeFromParent(TagExecutable child) throws OdfException {
48
        child.execute(this);
49
    }
50
51
}
(-)src/java/org/apache/fop/render/odf/odt/tags/PageSequenceTag.java (+113 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
package org.apache.fop.render.odf.odt.tags;
19
20
import org.apache.fop.fo.pagination.PageSequence;
21
import org.apache.fop.fo.pagination.PageSequenceMaster;
22
import org.apache.fop.fo.pagination.SimplePageMaster;
23
import org.apache.fop.render.odf.OdfException;
24
import org.apache.fop.render.odf.odt.FopOdtConverter;
25
26
/**
27
 * Defines a number of standard constants (keys) for use by the RendererContext class.
28
 */
29
public class PageSequenceTag extends Tag {
30
31
    protected PageSequence pageSeq = null;
32
33
    protected FopOdtConverter converter = null;
34
35
    protected SimplePageMaster pagemaster = null;
36
37
    PageSequenceTag(Tag parent, PageSequence pageSeq, FopOdtConverter converter) {
38
        super(parent);
39
        this.pageSeq = pageSeq;
40
        this.converter = converter;
41
42
        String reference = pageSeq.getMasterReference();
43
        this.pagemaster = pageSeq.getRoot().getLayoutMasterSet().getSimplePageMaster(reference);
44
        if (pagemaster == null) {
45
            PageSequenceMaster master = pageSeq.getRoot().getLayoutMasterSet().getPageSequenceMaster(reference);
46
            this.pagemaster = master.getNextSimplePageMaster(false, false, false, false, "");
47
        }
48
49
        //if(!isFirstPageSequence()) this.getOdt().addPageBreak();
50
51
        //read page size and margins, if specified
52
        //only simple-page-master supported, so pagemaster may be null
53
54
        //builderContext.pushContainer(sect);
55
56
        //Calculate usable page width for this flow
57
        //int useAblePageWidth = pagemaster.getPageWidth().getValue()
58
        //    - pagemaster.getCommonMarginBlock().marginLeft.getValue()
59
        //    - pagemaster.getCommonMarginBlock().marginRight.getValue()
60
        //percentManager.setDimension(pageSeq, useAblePageWidth);
61
62
        //bHeaderSpecified = false;
63
        //bFooterSpecified = false;
64
65
        /*Region regionBefore = pagemaster.getRegion(Constants.FO_REGION_BEFORE);
66
        if (regionBefore != null) {
67
            FONode staticBefore = (FONode) pageSequence.getFlowMap().get(regionBefore.getRegionName());
68
            if (staticBefore != null) recurseFONode(staticBefore);
69
        }
70
71
        Region regionAfter = pagemaster.getRegion(Constants.FO_REGION_AFTER);
72
        if (regionAfter != null) {
73
            FONode staticAfter = (FONode) pageSequence.getFlowMap().get(regionAfter.getRegionName());
74
            if (staticAfter != null) recurseFONode(staticAfter);
75
        }*/
76
    }
77
78
    //private boolean isFirstPageSequence() {
79
        // TODO Auto-generated method stub
80
    //    return false;
81
    //}
82
83
    /**
84
     * {@inheritDoc}
85
     */
86
    @Override
87
    public void execute() {
88
        setMargins();
89
        converter.convertRecursively(pageSeq.getMainFlow());
90
    }
91
92
    private void setMargins() {
93
        //int a = this.pagemaster.getPageWidth().getValue();
94
        //int b = this.pagemaster.getPageHeight().getValue();
95
        //int c = this.pagemaster.getCommonMarginBlock().marginLeft.getValue();
96
        //int d = this.pagemaster.getCommonMarginBlock().marginRight.getValue();
97
    }
98
99
    /**
100
     * {@inheritDoc}
101
     */
102
    @Override
103
    public void closeIntercept() {
104
    }
105
106
    /**
107
     * {@inheritDoc}
108
     * @throws OdfException
109
     */
110
    public void executeFromParent(TagExecutable child) throws OdfException {
111
        child.execute(this);
112
    }
113
}
(-)src/java/org/apache/fop/render/odf/odt/tags/TableColumnTag.java (+46 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
package org.apache.fop.render.odf.odt.tags;
19
20
import org.apache.fop.fo.flow.table.TableColumn;
21
import org.apache.fop.render.odf.OdfException;
22
23
/**
24
 * TableColumn converter
25
 */
26
public class TableColumnTag extends Tag {
27
28
    TableColumnTag(Tag parent, TableColumn tblColumn) {
29
        super(parent);
30
    }
31
32
    /**
33
     * {@inheritDoc}
34
     */
35
    @Override
36
    public void execute() { }
37
38
    /**
39
     * {@inheritDoc}
40
     * @throws OdfException
41
     */
42
    public void executeFromParent(TagExecutable child) throws OdfException {
43
        child.execute(this);
44
    }
45
46
}
(-)src/java/org/apache/fop/render/odf/odt/tags/ListItemBodyTag.java (+46 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
package org.apache.fop.render.odf.odt.tags;
19
20
import org.apache.fop.fo.flow.ListItemBody;
21
import org.apache.fop.render.odf.OdfException;
22
23
/**
24
 * ListItemBody converter
25
 */
26
public class ListItemBodyTag extends Tag {
27
28
    protected ListItemBodyTag(Tag parent, ListItemBody foNode) {
29
        super(parent);
30
    }
31
32
    /**
33
     * {@inheritDoc}
34
     */
35
    @Override
36
    public void execute() { }
37
38
    /**
39
     * {@inheritDoc}
40
     * @throws OdfException
41
     */
42
    public void executeFromParent(TagExecutable child) throws OdfException {
43
        parent.executeFromParent(child);
44
    }
45
46
}
(-)src/java/org/apache/fop/render/odf/odt/tags/InlineTag.java (+130 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
package org.apache.fop.render.odf.odt.tags;
19
20
import org.odftoolkit.odfdom.dom.OdfContentDom;
21
import org.odftoolkit.odfdom.dom.element.style.StyleStyleElement;
22
import org.odftoolkit.odfdom.dom.element.style.StyleTextPropertiesElement;
23
import org.odftoolkit.odfdom.dom.element.text.TextSpanElement;
24
import org.odftoolkit.odfdom.pkg.OdfElement;
25
import org.odftoolkit.odfdom.pkg.OdfXMLFactory;
26
import org.w3c.dom.Node;
27
28
import org.apache.fop.fo.flow.Inline;
29
import org.apache.fop.render.odf.OdfException;
30
import org.apache.fop.render.odf.odt.Namespace;
31
import org.apache.fop.render.odf.odt.Style;
32
import org.apache.fop.render.odf.odt.Style.Params;
33
34
/**
35
 * Inline converter
36
 */
37
public class InlineTag extends Tag {
38
39
    protected TextSpanElement tse = null;
40
41
    InlineTag(Tag parent, Inline inl) throws OdfException {
42
        super(parent);
43
44
        this.currentStyle.getParameters().put(Params.FONT_NAME,                                 inl.getCommonFont().getFirstFontFamily().split(",")[0]);
45
        this.currentStyle.getParameters().put(Params.FONT_STYLE,  Style.fopFontToOdfFontStyle(  inl.getCommonFont()));
46
        this.currentStyle.getParameters().put(Params.FONT_WEIGHT, Style.fopFontToOdfFontWeight( inl.getCommonFont()));
47
        this.currentStyle.getParameters().put(Params.FONT_SIZE,   Style.fopLengthToPt(          inl.getCommonFont().getFontSize()));
48
        this.currentStyle.getParameters().put(Params.COLOR,       Style.awtColorToOdfColor(     inl.getColor()));
49
50
        registerFont(this.currentStyle.getParameters().get(Params.FONT_NAME));
51
    }
52
53
    public TextSpanElement getTextSpanElement() {
54
        return tse;
55
    }
56
57
    @Override
58
    protected OdfElement getTextContainer() {
59
        if (this.tse != null) {
60
            return this.tse;
61
        } else {
62
            return parent.getTextContainer();
63
        }
64
    }
65
    /**
66
     * {@inheritDoc}
67
     * @throws OdfException
68
     */
69
    @Override
70
    public void execute() throws OdfException {
71
        try {
72
            tse = (TextSpanElement) OdfXMLFactory.newOdfElement(this.getOdt().getContentDom(), TextSpanElement.ELEMENT_NAME);
73
        } catch (Exception e) {
74
            throw new OdfException("Can't create text span.", e);
75
        }
76
77
        StyleStyleElement sse = null;
78
        try {
79
            sse = (StyleStyleElement) OdfXMLFactory.newOdfElement(this.getOdt().getContentDom(), StyleStyleElement.ELEMENT_NAME);
80
        } catch (Exception e) {
81
            throw new OdfException("Can't create new style for text span.", e);
82
        }
83
84
        sse.setAttributeNS(Namespace.STYLE, "style:family", "text");
85
86
        StyleTextPropertiesElement stpe = null;
87
88
        try {
89
            stpe = (StyleTextPropertiesElement) OdfXMLFactory.newOdfElement(this.getOdt().getContentDom(), StyleTextPropertiesElement.ELEMENT_NAME);
90
        } catch (Exception e) {
91
            throw new OdfException("Can't create new style for text span.", e);
92
        }
93
94
        stpe.setAttributeNS(Namespace.FO,    "fo:font-size",    this.currentStyle.get(Params.FONT_SIZE));
95
        stpe.setAttributeNS(Namespace.FO,    "fo:font-weight",  this.currentStyle.get(Params.FONT_WEIGHT));
96
        stpe.setAttributeNS(Namespace.FO,    "fo:font-style",   this.currentStyle.get(Params.FONT_STYLE));
97
        stpe.setAttributeNS(Namespace.FO,    "fo:color",        this.currentStyle.get(Params.COLOR));
98
        stpe.setAttributeNS(Namespace.STYLE, "style:font-name", this.currentStyle.get(Params.FONT_NAME));
99
100
        sse.appendChild(stpe);
101
102
        try {
103
            OdfContentDom odf = this.getOdt().getContentDom();
104
            Node odfstyles = odf.getElementsByTagNameNS(Namespace.OFFICE, "automatic-styles").item(0);
105
            odfstyles.appendChild(sse);
106
        } catch (Exception e) {
107
            throw new OdfException("Can't create new style.", e);
108
        }
109
110
        tse.setStyleName(this.appendNewStyle(sse));
111
    }
112
113
    /**
114
     * {@inheritDoc}
115
     * @throws OdfException
116
     */
117
    @Override
118
    public void closeIntercept() throws OdfException {
119
        parent.getTextContainer().appendChild(tse);
120
    }
121
122
    /**
123
     * {@inheritDoc}
124
     * @throws OdfException
125
     */
126
    public void executeFromParent(TagExecutable child) throws OdfException {
127
        child.execute(this);
128
    }
129
130
}
(-)src/java/org/apache/fop/render/odf/odt/tags/CharacterTag.java (+46 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
package org.apache.fop.render.odf.odt.tags;
19
20
import org.apache.fop.fo.flow.Character;
21
import org.apache.fop.render.odf.OdfException;
22
23
/**
24
 * Character converter
25
 */
26
public class CharacterTag extends Tag {
27
28
    CharacterTag(Tag actualTag, Character foNode) {
29
        super(actualTag);
30
    }
31
32
    /**
33
     * {@inheritDoc}
34
     */
35
    @Override
36
    public void execute() { }
37
38
    /**
39
     * {@inheritDoc}
40
     * @throws OdfException
41
     */
42
    public void executeFromParent(TagExecutable child) throws OdfException {
43
        child.execute(this);
44
    }
45
46
}
(-)src/java/org/apache/fop/render/odf/odt/tags/FootnoteTag.java (+52 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
package org.apache.fop.render.odf.odt.tags;
19
20
import org.apache.fop.fo.flow.Footnote;
21
import org.apache.fop.render.odf.OdfException;
22
23
/**
24
 * Footnote converter
25
 */
26
public class FootnoteTag extends Tag {
27
28
    FootnoteTag(Tag parent, Footnote foNode) {
29
        super(parent);
30
    }
31
32
    /**
33
     * {@inheritDoc}
34
     */
35
    @Override
36
    public void execute() {
37
        /*Footnote fn = (Footnote)foNode;
38
39
        recurseFONode(fn.getFootnoteCitation());
40
        recurseFONode(fn.getFootnoteBody()); */
41
42
    }
43
44
    /**
45
     * {@inheritDoc}
46
     * @throws OdfException
47
     */
48
    public void executeFromParent(TagExecutable child) throws OdfException {
49
        child.execute(this);
50
    }
51
52
}
(-)src/java/org/apache/fop/render/odf/odt/tags/FlowTag.java (+45 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
package org.apache.fop.render.odf.odt.tags;
19
20
import org.apache.fop.fo.pagination.Flow;
21
import org.apache.fop.render.odf.OdfException;
22
23
/**
24
 * Flow converter.
25
 */
26
public class FlowTag extends Tag {
27
28
    FlowTag(Tag parent, Flow fl) {
29
        super(parent);
30
    }
31
32
    /**
33
     * {@inheritDoc}
34
     */
35
    @Override
36
    public void execute() { }
37
38
    /**
39
     * {@inheritDoc}
40
     * @throws OdfException
41
     */
42
    public void executeFromParent(TagExecutable child) throws OdfException {
43
        child.execute(this);
44
    }
45
}
(-)src/java/org/apache/fop/render/odf/odt/tags/PageNumberTag.java (+46 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
package org.apache.fop.render.odf.odt.tags;
19
20
import org.apache.fop.fo.flow.PageNumber;
21
import org.apache.fop.render.odf.OdfException;
22
23
/**
24
 * PageNumber converter
25
 */
26
public class PageNumberTag extends Tag {
27
28
    PageNumberTag(Tag parent, PageNumber foNode) {
29
        super(parent);
30
    }
31
32
    /**
33
     * {@inheritDoc}
34
     */
35
    @Override
36
    public void execute() { }
37
38
    /**
39
     * {@inheritDoc}
40
     * @throws OdfException
41
     */
42
    public void executeFromParent(TagExecutable child) throws OdfException {
43
        child.execute(this);
44
    }
45
46
}
(-)src/java/org/apache/fop/render/odf/odt/tags/BlockTag.java (+262 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
package org.apache.fop.render.odf.odt.tags;
19
20
import java.util.Iterator;
21
22
import org.odftoolkit.odfdom.dom.element.style.StyleParagraphPropertiesElement;
23
import org.odftoolkit.odfdom.dom.element.style.StyleStyleElement;
24
import org.odftoolkit.odfdom.dom.element.style.StyleTextPropertiesElement;
25
import org.odftoolkit.odfdom.dom.element.table.TableTableCellElement;
26
import org.odftoolkit.odfdom.dom.element.text.TextBookmarkElement;
27
import org.odftoolkit.odfdom.dom.element.text.TextLineBreakElement;
28
import org.odftoolkit.odfdom.dom.element.text.TextListItemElement;
29
import org.odftoolkit.odfdom.dom.element.text.TextPElement;
30
import org.odftoolkit.odfdom.pkg.OdfElement;
31
import org.odftoolkit.odfdom.pkg.OdfXMLFactory;
32
33
import org.apache.fop.fo.FONode;
34
import org.apache.fop.fo.FOText;
35
import org.apache.fop.fo.flow.Block;
36
import org.apache.fop.fo.flow.ListBlock;
37
import org.apache.fop.fo.flow.table.Table;
38
import org.apache.fop.layoutmgr.BlockLayoutManager;
39
import org.apache.fop.render.odf.OdfException;
40
import org.apache.fop.render.odf.odt.Namespace;
41
import org.apache.fop.render.odf.odt.Style;
42
import org.apache.fop.render.odf.odt.Style.Params;
43
/**
44
 * Block converter
45
 */
46
public class BlockTag extends Tag {
47
48
    private Block bl = null;
49
50
    private TextPElement paragraph = null;
51
52
    private OdfElement paragraphContainer = null;
53
54
    @Override
55
    protected OdfElement getTextContainer() {
56
        if (this.paragraph != null) {
57
            return this.paragraph;
58
        } else {
59
            return parent.getTextContainer();
60
        }
61
    }
62
63
    /**
64
     * {@inheritDoc}
65
     * @throws OdfException
66
     */
67
    @Override
68
    protected TextPElement getParagraph() throws OdfException {
69
        if (this.paragraph != null) {
70
            return this.paragraph;
71
        } else {
72
            return parent.getParagraph();
73
        }
74
    }
75
76
    /**
77
     * {@inheritDoc}
78
     */
79
    @Override
80
    protected OdfElement getParagraphContainer() {
81
        if (paragraphContainer != null) {
82
            return this.paragraphContainer;
83
        } else {
84
            return parent.getParagraphContainer();
85
        }
86
    }
87
88
    /**
89
     * Constructor
90
     * @throws OdfException
91
     */
92
    BlockTag(Tag parent, Block bl) throws OdfException {
93
        super(parent);
94
        this.bl = bl;
95
        this.currentStyle.getParameters().put(Params.FONT_NAME,                                         bl.getCommonFont().getFirstFontFamily().split(",")[0]);
96
        this.currentStyle.getParameters().put(Params.FONT_STYLE,          Style.fopFontToOdfFontStyle(  bl.getCommonFont()));
97
        this.currentStyle.getParameters().put(Params.FONT_WEIGHT,         Style.fopFontToOdfFontWeight( bl.getCommonFont()));
98
        this.currentStyle.getParameters().put(Params.FONT_SIZE,           Style.fopLengthToPt(          bl.getCommonFont().getFontSize()));
99
        this.currentStyle.getParameters().put(Params.COLOR,               Style.awtColorToOdfColor(     bl.getColor()));
100
        this.currentStyle.getParameters().put(Params.TEXT_ALIGN,          Style.fopAlignToOdfAlign(     bl.getTextAlign()));
101
        this.currentStyle.getParameters().put(Params.SPACE_BEFORE,        Style.fopSpaceBeforeToPt(     bl.getCommonMarginBlock().spaceBefore, new BlockLayoutManager(bl)));
102
        this.currentStyle.getParameters().put(Params.SPACE_AFTER,         Style.fopSpaceAfterToPt(      bl.getCommonMarginBlock().spaceAfter, new BlockLayoutManager(bl)));
103
        this.currentStyle.getParameters().put(Params.MARGIN_LEFT,         Style.fopLengthToPt(          bl.getCommonMarginBlock().marginLeft));
104
        this.currentStyle.getParameters().put(Params.MARGIN_RIGHT,        Style.fopLengthToPt(          bl.getCommonMarginBlock().marginRight));
105
        this.currentStyle.getParameters().put(Params.BACKGROUND_COLOR,    Style.awtColorToString(       bl.getCommonBorderPaddingBackground().backgroundColor));
106
107
        registerFont(this.currentStyle.getParameters().get(Params.FONT_NAME));
108
    }
109
110
    /**
111
     * {@inheritDoc}
112
     * @throws OdfException
113
     */
114
    @Override
115
    public void execute() throws OdfException {
116
        parent.executeFromParent(this);
117
    }
118
119
    /**
120
     * {@inheritDoc}
121
     * @throws OdfException
122
     */
123
    @Override
124
    public void execute(Tag tag) throws OdfException {
125
126
        if (!bl.hasChildren()) {
127
            addLineBreak();
128
        } else {
129
            if (!childrenAreOnlyBlocks(this.bl)) {
130
                this.paragraph = this.newParagraph(parent.getParagraphContainer());
131
132
                if (bl.getId() != null) {
133
                    insertBookmark(bl.getId());
134
                }
135
136
                StyleStyleElement sse = null;
137
                try {
138
                    sse = (StyleStyleElement) OdfXMLFactory.newOdfElement(this.getOdt().getContentDom(), StyleStyleElement.ELEMENT_NAME);
139
                } catch (Exception e) {
140
                    throw new OdfException("Can't create new pragraph.", e);
141
                }
142
143
                sse.setAttributeNS(Namespace.STYLE, "style:family", "paragraph");
144
145
                StyleParagraphPropertiesElement sppe = null;
146
                try {
147
                    sppe = (StyleParagraphPropertiesElement) OdfXMLFactory.newOdfElement(this.getOdt().getContentDom(), StyleParagraphPropertiesElement.ELEMENT_NAME);
148
                } catch (Exception e) {
149
                    throw new OdfException("Can't create new pragraph.", e);
150
                }
151
152
                sppe.setAttributeNS(Namespace.FO, "fo:margin-top",           this.currentStyle.get(Params.SPACE_BEFORE));
153
                sppe.setAttributeNS(Namespace.FO, "fo:margin-bottom",        this.currentStyle.get(Params.SPACE_AFTER));
154
                sppe.setAttributeNS(Namespace.FO, "fo:margin-left",          this.currentStyle.get(Params.MARGIN_LEFT));
155
                sppe.setAttributeNS(Namespace.FO, "fo:margin-right",         this.currentStyle.get(Params.MARGIN_RIGHT));
156
                sppe.setAttributeNS(Namespace.FO, "fo:background-color",     this.currentStyle.get(Params.BACKGROUND_COLOR));
157
                sppe.setAttributeNS(Namespace.FO, "fo:text-align",           this.currentStyle.get(Params.TEXT_ALIGN));
158
                sse.appendChild(sppe);
159
160
                StyleTextPropertiesElement stpe = null;
161
162
                try {
163
                    stpe = (StyleTextPropertiesElement) OdfXMLFactory.newOdfElement(this.getOdt().getContentDom(), StyleTextPropertiesElement.ELEMENT_NAME);
164
                } catch (Exception e) {
165
                    throw new OdfException("Can't create new pragraph.", e);
166
                }
167
168
                stpe.setAttributeNS(Namespace.STYLE, "style:font-name", this.currentStyle.get(Params.FONT_NAME));
169
                stpe.setAttributeNS(Namespace.FO,    "fo:color",        this.currentStyle.get(Params.COLOR));
170
                stpe.setAttributeNS(Namespace.FO,    "fo:font-size",    this.currentStyle.get(Params.FONT_SIZE));
171
                stpe.setAttributeNS(Namespace.FO,    "fo:font-style",   this.currentStyle.get(Params.FONT_STYLE));
172
                stpe.setAttributeNS(Namespace.FO,    "fo:font-weight",  this.currentStyle.get(Params.FONT_WEIGHT));
173
174
                sse.appendChild(stpe);
175
176
                this.paragraph.setStyleName(this.appendNewStyle(sse));
177
            }
178
        }
179
    }
180
181
    private void insertBookmark(String id) throws OdfException {
182
        TextBookmarkElement tbe = null;
183
        try {
184
            tbe = (TextBookmarkElement) OdfXMLFactory.newOdfElement(this.getOdt().getContentDom(), TextBookmarkElement.ELEMENT_NAME);
185
        } catch (Exception e) {
186
            throw new OdfException("Can't create link intern.", e);
187
        }
188
        tbe.setAttributeNS(Namespace.TEXT, "text:name", id);
189
        this.paragraph.appendChild(tbe);
190
    }
191
192
    /**
193
     * {@inheritDoc}
194
     * @throws OdfException
195
     */
196
    @Override
197
    public void execute(TableCellTag tag) throws OdfException {
198
        TableTableCellElement ttce = tag.getTableCellElement();
199
200
        this.paragraphContainer = ttce;
201
202
        if (!childrenAreOnlyBlocks(this.bl)) {
203
            this.paragraph = this.newParagraph(this.paragraphContainer);
204
        }
205
    }
206
207
    /**
208
     * {@inheritDoc}
209
     * @throws OdfException
210
     */
211
    @Override
212
    public void execute(ListItemTag tag) throws OdfException {
213
        TextListItemElement tlie = tag.getTextListItemElement();
214
215
        this.paragraphContainer = tlie;
216
217
        if (!childrenAreOnlyBlocks(this.bl)) {
218
            this.paragraph = this.newParagraph(this.paragraphContainer);
219
        }
220
    }
221
222
    private void addLineBreak() throws OdfException {
223
        TextLineBreakElement tlb = null;
224
        try {
225
            tlb = (TextLineBreakElement) OdfXMLFactory.newOdfElement(this.getOdt().getContentDom(), TextLineBreakElement.ELEMENT_NAME);
226
        } catch (Exception e) {
227
            e.printStackTrace();
228
        }
229
230
        this.getParagraph().appendChild(tlb);
231
    }
232
233
    private boolean childrenAreOnlyBlocks(Block bl) {
234
235
        if (bl.hasChildren()) {
236
            for (Iterator<?> it = bl.getChildNodes(); it.hasNext();) {
237
                FONode next = (FONode) it.next();
238
                if (!(next instanceof Block || next instanceof ListBlock || next instanceof Table) ) {
239
                    if (next instanceof FOText) {
240
                        if ( ((FOText) next).length() != 0) {
241
                            return false;
242
                        }
243
                    } else {
244
                        return false;
245
                    }
246
                }
247
            }
248
        } else {
249
            return false;
250
        }
251
252
        return true;
253
    }
254
255
    /**
256
     * {@inheritDoc}
257
     * @throws OdfException
258
     */
259
    public void executeFromParent(TagExecutable child) throws OdfException {
260
        child.execute(this);
261
    }
262
}
(-)src/java/org/apache/fop/render/odf/odt/tags/StaticContentTag.java (+46 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
package org.apache.fop.render.odf.odt.tags;
19
20
import org.apache.fop.fo.pagination.StaticContent;
21
import org.apache.fop.render.odf.OdfException;
22
23
/**
24
 *
25
 */
26
public class StaticContentTag extends Tag {
27
28
    protected StaticContentTag(Tag parent, StaticContent foNode) {
29
        super(parent);
30
    }
31
32
    /**
33
     * {@inheritDoc}
34
     */
35
    @Override
36
    public void execute() { }
37
38
    /**
39
     * {@inheritDoc}
40
     * @throws OdfException
41
     */
42
    public void executeFromParent(TagExecutable child) throws OdfException {
43
        child.execute(this);
44
    }
45
46
}
(-)src/java/org/apache/fop/render/odf/odt/tags/ListItemLabelTag.java (+46 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
package org.apache.fop.render.odf.odt.tags;
19
20
import org.apache.fop.fo.flow.ListItemLabel;
21
import org.apache.fop.render.odf.OdfException;
22
23
/**
24
 * ListItemLabel converter
25
 */
26
public class ListItemLabelTag extends Tag {
27
28
    ListItemLabelTag(Tag parent, ListItemLabel foNode) {
29
        super(parent);
30
    }
31
32
    /**
33
     * {@inheritDoc}
34
     */
35
    @Override
36
    public void execute() { }
37
38
    /**
39
     * {@inheritDoc}
40
     * @throws OdfException
41
     */
42
    public void executeFromParent(TagExecutable child) throws OdfException {
43
        child.execute(this);
44
    }
45
46
}
(-)src/java/org/apache/fop/render/odf/odt/tags/RootTag.java (+93 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
package org.apache.fop.render.odf.odt.tags;
19
20
import java.util.HashMap;
21
import java.util.Map;
22
import java.util.Vector;
23
24
import org.odftoolkit.odfdom.doc.OdfTextDocument;
25
import org.odftoolkit.odfdom.dom.element.style.StyleStyleElement;
26
import org.odftoolkit.odfdom.dom.element.text.TextPElement;
27
import org.odftoolkit.odfdom.pkg.OdfElement;
28
29
import org.apache.fop.render.odf.OdfException;
30
31
/**
32
 *
33
 */
34
public class RootTag extends Tag {
35
36
    private OdfTextDocument outputOdt = null;
37
38
    private Map<String, StyleStyleElement> usedStyles = new HashMap<String, StyleStyleElement>();
39
40
    private Vector<String> usedFonts = new Vector<String>();
41
42
    private TextPElement paragraph = null;
43
44
    public RootTag(OdfTextDocument odt) {
45
        super(null);
46
        this.outputOdt = odt;
47
    }
48
49
    protected OdfTextDocument getOdt() {
50
        return outputOdt;
51
    }
52
53
    @Override
54
    public Map<String, StyleStyleElement> getUsedStyles() {
55
        return usedStyles;
56
    }
57
58
    @Override
59
    public Vector<String> getUsedFonts() {
60
        return usedFonts;
61
    }
62
63
    @Override
64
    protected TextPElement getParagraph() throws OdfException {
65
        this.paragraph = this.newParagraph(getParagraphContainer());
66
        return this.paragraph;
67
    }
68
69
    @Override
70
    protected OdfElement getParagraphContainer() {
71
        try {
72
            return outputOdt.getContentRoot();
73
        } catch (Exception e) {
74
            e.printStackTrace();
75
        }
76
        return null;
77
    }
78
79
    /**
80
     * {@inheritDoc}
81
     */
82
    @Override
83
    public void execute() { }
84
85
    /**
86
     * {@inheritDoc}
87
     * @throws OdfException
88
     */
89
    public void executeFromParent(TagExecutable child) throws OdfException {
90
        child.execute(this);
91
    }
92
93
}
(-)src/java/org/apache/fop/render/odf/odt/tags/TableHeaderTag.java (+46 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
package org.apache.fop.render.odf.odt.tags;
19
20
import org.apache.fop.fo.flow.table.TableHeader;
21
import org.apache.fop.render.odf.OdfException;
22
23
/**
24
 * TableHeader converter
25
 */
26
public class TableHeaderTag extends Tag {
27
28
    TableHeaderTag(Tag parent, TableHeader tblHeader) {
29
        super(parent);
30
    }
31
32
    /**
33
     * {@inheritDoc}
34
     */
35
    @Override
36
    public void execute() { }
37
38
    /**
39
     * {@inheritDoc}
40
     * @throws OdfException
41
     */
42
    public void executeFromParent(TagExecutable child) throws OdfException {
43
        child.execute(this);
44
    }
45
46
}
(-)src/java/org/apache/fop/render/odf/odt/tags/ExternalGraphicTag.java (+251 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
package org.apache.fop.render.odf.odt.tags;
19
20
import java.io.IOException;
21
import java.io.InputStream;
22
import java.util.Map;
23
import java.util.Random;
24
25
import org.odftoolkit.odfdom.dom.element.draw.DrawFrameElement;
26
import org.odftoolkit.odfdom.dom.element.draw.DrawImageElement;
27
import org.odftoolkit.odfdom.dom.element.text.TextParagraphElementBase;
28
import org.odftoolkit.odfdom.pkg.OdfXMLFactory;
29
30
import org.apache.commons.io.IOUtils;
31
32
import org.apache.xmlgraphics.image.loader.Image;
33
import org.apache.xmlgraphics.image.loader.ImageFlavor;
34
import org.apache.xmlgraphics.image.loader.ImageInfo;
35
import org.apache.xmlgraphics.image.loader.ImageManager;
36
import org.apache.xmlgraphics.image.loader.ImageSessionContext;
37
import org.apache.xmlgraphics.image.loader.impl.ImageRawStream;
38
import org.apache.xmlgraphics.image.loader.util.ImageUtil;
39
40
import org.apache.fop.apps.FOUserAgent;
41
42
import org.apache.fop.datatypes.LengthBase;
43
import org.apache.fop.fo.FObj;
44
import org.apache.fop.fo.flow.AbstractGraphics;
45
import org.apache.fop.fo.flow.ExternalGraphic;
46
import org.apache.fop.layoutmgr.inline.ImageLayout;
47
import org.apache.fop.render.odf.OdfException;
48
import org.apache.fop.render.odf.odt.Namespace;
49
50
/**
51
 * External Graphic converter
52
 */
53
public class ExternalGraphicTag extends Tag {
54
55
    public static class PercentBaseContext implements org.apache.fop.datatypes.PercentBaseContext {
56
57
        Image image = null;
58
59
        public PercentBaseContext(Image image) {
60
            this.image = image;
61
        }
62
63
        public int getBaseLength(int lengthBase, FObj fobj) {
64
65
            final ImageInfo info = image.getInfo();
66
67
            switch (lengthBase) {
68
            case LengthBase.IMAGE_INTRINSIC_WIDTH:
69
                return info.getSize().getWidthMpt();
70
            case LengthBase.IMAGE_INTRINSIC_HEIGHT:
71
                return info.getSize().getHeightMpt();
72
            default:
73
                return info.getSize().getHeightMpt();
74
            }
75
        }
76
    }
77
78
    public static final String ODT_IMAGES_PATH = "Pictures/";
79
80
    ExternalGraphic eg = null;
81
82
    ExternalGraphicTag(Tag parent, ExternalGraphic eg) {
83
        super(parent);
84
        this.eg = eg;
85
    }
86
87
    /**
88
     * {@inheritDoc}
89
     * @throws OdfException
90
     */
91
    @Override
92
    public void execute() throws OdfException {
93
94
        ImageInfo info = null;
95
        FOUserAgent userAgent = eg.getUserAgent();
96
        ImageManager manager = userAgent.getImageManager();
97
98
        try {
99
            info = manager.getImageInfo(eg.getURL(), userAgent.getImageSessionContext());
100
            putGraphic(eg, info);
101
        } catch (Exception e) {
102
            throw new OdfException("Can't create an image.", e);
103
        }
104
    }
105
106
    private static final ImageFlavor[] FLAVORS = new ImageFlavor[] {
107
        ImageFlavor.RAW_EMF,
108
        ImageFlavor.RAW_PNG,
109
        ImageFlavor.RAW_JPEG
110
    };
111
112
    private void putGraphic(AbstractGraphics abstractGraphic, ImageInfo info)
113
            throws OdfException {
114
115
            FOUserAgent userAgent = abstractGraphic.getUserAgent();
116
            ImageManager manager = userAgent.getImageManager();
117
            ImageSessionContext sessionContext = userAgent.getImageSessionContext();
118
            Map<?, ?> hints = ImageUtil.getDefaultHints(sessionContext);
119
            Image image;
120
            try {
121
                image = manager.getImage(info, FLAVORS, hints, sessionContext);
122
            } catch (Exception e) {
123
                throw new OdfException("Can't create an image.", e);
124
            }
125
126
            putGraphic(abstractGraphic, image);
127
    }
128
129
    private void putGraphic(AbstractGraphics abstractGraphic, Image image)
130
            throws OdfException {
131
132
        byte[] rawData;
133
        try {
134
            rawData = getRawData(image);
135
        } catch (IOException e) {
136
            throw new OdfException("Can't create an image.", e);
137
        }
138
139
        if (rawData == null) {
140
            return;
141
        }
142
143
        ImageLayout layout = getImageLayout(abstractGraphic, image);
144
145
        String imageType = image.getInfo().getMimeType().split("/")[1];
146
147
        String filename = createFilename(imageType);
148
149
        putImageFileIntoOdt(rawData, filename, imageType);
150
151
        DrawImageElement die = createImage();
152
153
        die.setAttributeNS(Namespace.XLINK, "xlink:href", ODT_IMAGES_PATH + filename);
154
        die.setAttributeNS(Namespace.XLINK, "xlink:type", "simple");
155
        die.setAttributeNS(Namespace.XLINK, "xlink:show", "embed");
156
        die.setAttributeNS(Namespace.XLINK, "xlink:actuate", "onLoad");
157
158
        DrawFrameElement dfe = createImageFrame();
159
160
        dfe.setAttributeNS(Namespace.SVG, "svg:width", Double.valueOf(layout.getViewportSize().getWidth() / 1000) + "pt");
161
        dfe.setAttributeNS(Namespace.SVG, "svg:height", Double.valueOf(layout.getViewportSize().getHeight() / 1000) + "pt");
162
163
        addImageToImageFrame(die, dfe);
164
165
        addImageFrameToParagraph(dfe, this.getParagraph());
166
    }
167
168
    private byte[] getRawData(Image image) throws IOException {
169
170
        byte[] rawData = null;
171
172
        if (image instanceof ImageRawStream) {
173
            ImageRawStream rawImage = (ImageRawStream)image;
174
            InputStream in = rawImage.createInputStream();
175
            try {
176
                rawData = IOUtils.toByteArray(in);
177
            } finally {
178
                IOUtils.closeQuietly(in);
179
            }
180
        }
181
        return rawData;
182
    }
183
184
    private ImageLayout getImageLayout(AbstractGraphics abstractGraphic, Image image) {
185
186
        PercentBaseContext pContext = new ExternalGraphicTag.PercentBaseContext(image);
187
188
        return new ImageLayout( abstractGraphic,
189
                                pContext,
190
                                image.getInfo().getSize().getDimensionMpt());
191
    }
192
193
    private void putImageFileIntoOdt(byte[] rawData, String filename, String imageType) {
194
        this.getOdt().getPackage().insert(rawData, ODT_IMAGES_PATH + filename, imageType);
195
    }
196
197
    private String createFilename(String imageType) {
198
        String filename = null;
199
200
        do {
201
            Random randomGenerator = new Random();
202
            filename = randomGenerator.nextInt(100) + "." + imageType;
203
        } while(this.getOdt().getPackage().contains(ODT_IMAGES_PATH + filename));
204
205
        return filename;
206
    }
207
208
    private DrawImageElement createImage() throws OdfException {
209
        DrawImageElement die = null;
210
        try {
211
            die = (DrawImageElement) OdfXMLFactory.newOdfElement(this.getOdt().getContentDom(), DrawImageElement.ELEMENT_NAME);
212
        } catch (Exception e) {
213
            throw new OdfException("Can't create an image.", e);
214
        }
215
        return die;
216
    }
217
218
    private DrawFrameElement createImageFrame() {
219
        DrawFrameElement dfe = null;
220
        try {
221
            dfe = (DrawFrameElement) OdfXMLFactory.newOdfElement(this.getOdt().getContentDom(), DrawFrameElement.ELEMENT_NAME);
222
        } catch (Exception e) {
223
            e.printStackTrace();
224
        }
225
        return dfe;
226
    }
227
228
    private void addImageToImageFrame(DrawImageElement die, DrawFrameElement dfe) throws OdfException {
229
        try {
230
            dfe.appendChild(die);
231
        } catch (Exception e) {
232
            throw new OdfException("Can't create an image.", e);
233
        }
234
    }
235
236
    private void addImageFrameToParagraph(DrawFrameElement dfe, TextParagraphElementBase tpeb) {
237
        try {
238
            tpeb.appendChild(dfe);
239
        } catch (Exception e) {
240
            e.printStackTrace();
241
        }
242
    }
243
244
    /**
245
     * {@inheritDoc}
246
     * @throws OdfException
247
     */
248
    public void executeFromParent(TagExecutable child) throws OdfException {
249
        child.execute(this);
250
    }
251
}
(-)src/java/org/apache/fop/render/odf/odt/tags/ListBlockTag.java (+71 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
package org.apache.fop.render.odf.odt.tags;
19
20
import org.odftoolkit.odfdom.dom.element.text.TextListElement;
21
import org.odftoolkit.odfdom.pkg.OdfXMLFactory;
22
23
import org.apache.fop.fo.flow.ListBlock;
24
import org.apache.fop.render.odf.OdfException;
25
26
/**
27
 * ListBlock converter
28
 */
29
public class ListBlockTag extends Tag {
30
31
    protected TextListElement tle = null;
32
33
    ListBlockTag(Tag parent, ListBlock foNode) {
34
        super(parent);
35
    }
36
37
    public TextListElement getTextListElement() {
38
        return tle;
39
    }
40
41
    /**
42
     * {@inheritDoc}
43
     * @throws OdfException
44
     */
45
    @Override
46
    public void execute() throws OdfException {
47
        try {
48
            tle = (TextListElement) OdfXMLFactory.newOdfElement(this.getOdt().getContentDom(), TextListElement.ELEMENT_NAME);
49
        } catch (Exception e) {
50
            throw new OdfException("Can't create the list", e);
51
        }
52
    }
53
54
    @Override
55
    public void closeIntercept() throws OdfException {
56
        try {
57
            this.getParagraphContainer().appendChild(tle);
58
        } catch (Exception e) {
59
            throw new OdfException("Can't create the list", e);
60
        }
61
     }
62
63
    /**
64
     * {@inheritDoc}
65
     * @throws OdfException
66
     */
67
    public void executeFromParent(TagExecutable child) throws OdfException {
68
        child.execute(this);
69
    }
70
71
}
(-)src/java/org/apache/fop/render/odf/odt/tags/TagExecutor.java (+28 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
package org.apache.fop.render.odf.odt.tags;
19
20
import org.apache.fop.render.odf.OdfException;
21
22
/**
23
 * Interface of the converter class that wants to execute in order to its parent converter
24
 */
25
public interface TagExecutor {
26
27
    void executeFromParent(TagExecutable child) throws OdfException;
28
}
(-)src/java/org/apache/fop/render/odf/odt/tags/TagExecutable.java (+44 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
package org.apache.fop.render.odf.odt.tags;
19
20
import org.apache.fop.render.odf.OdfException;
21
22
/**
23
 * Interface for the class that accept parent visitor.
24
 */
25
public interface TagExecutable {
26
27
    void execute(Tag tag) throws OdfException;
28
29
    void execute(BlockTag tag) throws OdfException;
30
31
    void execute(InlineTag tag) throws OdfException;
32
33
    void execute(BasicLinkTag tag) throws OdfException;
34
35
    void execute(TableTag tag) throws OdfException;
36
37
    void execute(TableRowTag tag) throws OdfException;
38
39
    void execute(TableCellTag tag) throws OdfException;
40
41
    void execute(ListBlockTag tag) throws OdfException;
42
43
    void execute(ListItemTag tag) throws OdfException;
44
}
(-)src/java/org/apache/fop/render/odf/odt/tags/TableRowTag.java (+75 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
package org.apache.fop.render.odf.odt.tags;
19
20
import org.odftoolkit.odfdom.dom.element.table.TableTableRowElement;
21
import org.odftoolkit.odfdom.pkg.OdfXMLFactory;
22
23
import org.apache.fop.fo.flow.table.TableRow;
24
import org.apache.fop.render.odf.OdfException;
25
26
/**
27
 * TableRow converter
28
 */
29
public class TableRowTag extends Tag {
30
31
    private TableTableRowElement tre = null;
32
33
    TableRowTag(Tag parent, TableRow tblRow) {
34
        super(parent);
35
    }
36
37
    public TableTableRowElement getTableRow() {
38
        return this.tre;
39
    }
40
41
    /**
42
     * {@inheritDoc}
43
     * @throws OdfException
44
     */
45
    @Override
46
    public void execute() throws OdfException {
47
        try {
48
            tre = (TableTableRowElement) OdfXMLFactory.newOdfElement(this.getOdt().getContentDom(), TableTableRowElement.ELEMENT_NAME);
49
        } catch (Exception e) {
50
            throw new OdfException("Can't create table row.", e);
51
        }
52
53
        parent.executeFromParent(this);
54
    }
55
56
    /**
57
     * {@inheritDoc}
58
     */
59
    @Override
60
    public void execute(TableTag tag) {
61
        try {
62
            tag.getTable().appendChild(tre);
63
        } catch (Exception e) {
64
            e.printStackTrace();
65
        }
66
    }
67
68
    /**
69
     * {@inheritDoc}
70
     * @throws OdfException
71
     */
72
    public void executeFromParent(TagExecutable child) throws OdfException {
73
        child.execute(this);
74
    }
75
}
(-)src/java/org/apache/fop/render/odf/odt/Style.java (+172 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
package org.apache.fop.render.odf.odt;
19
20
import java.util.HashMap;
21
import java.util.Map;
22
import java.util.Map.Entry;
23
24
import org.odftoolkit.odfdom.dom.element.style.StyleStyleElement;
25
import org.odftoolkit.odfdom.type.Color;
26
27
import org.apache.fop.datatypes.Length;
28
import org.apache.fop.fo.Constants;
29
import org.apache.fop.fo.properties.CommonFont;
30
import org.apache.fop.fo.properties.SpaceProperty;
31
import org.apache.fop.layoutmgr.BlockLayoutManager;
32
33
/**
34
 * Main class for style management.
35
 */
36
public class Style {
37
38
    public enum Params {
39
        FONT_NAME,
40
        FONT_STYLE,
41
        FONT_WEIGHT,
42
        FONT_SIZE,
43
        COLOR,
44
        TEXT_ALIGN,
45
        SPACE_BEFORE,
46
        SPACE_AFTER,
47
        MARGIN_LEFT,
48
        MARGIN_RIGHT,
49
        BACKGROUND_COLOR
50
    }
51
52
    private Map<Params, String> parameters = new HashMap<Params, String>();
53
54
    private Style parentStyle = null;
55
56
    /**
57
     * Constructor
58
     */
59
    public Style(Style parentStyle) {
60
        this.parentStyle = parentStyle;
61
    }
62
63
    /**
64
     * Constructor Style for the root tag. Setting default style parameters
65
     */
66
    public Style() {
67
        parameters.put(Params.FONT_NAME, "Times New Roman");
68
        parameters.put(Params.FONT_SIZE, "12pt");
69
        parameters.put(Params.COLOR, "#000000");
70
        parameters.put(Params.TEXT_ALIGN, "left");
71
    }
72
73
    /**
74
     * Get all style parameters
75
     */
76
    public Map<Params, String> getParameters() {
77
        return parameters;
78
    }
79
80
    /**
81
     * get an object from parameters.
82
     */
83
    public String get(Params param) {
84
        String value = parameters.get(param);
85
86
        if (value == null && parentStyle != null) {
87
            value = parentStyle.get(param);
88
        }
89
90
        return value;
91
    }
92
93
    public static String getStyleName(Map<String, StyleStyleElement> styles, StyleStyleElement sse) {
94
        for (Entry<String, StyleStyleElement> entry : styles.entrySet()) {
95
            StyleStyleElement style = entry.getValue();
96
            if (style.equals(sse)) {
97
                return entry.getKey();
98
            }
99
        }
100
        return null;
101
    }
102
103
    public static Double fopLengthToDouble(Length length) {
104
        return Double.valueOf((double)length.getValue() / 1000);
105
    }
106
107
    public static String awtColorToOdfColor(java.awt.Color color) {
108
        if (color == null) {
109
            return null;
110
        } else {
111
            return new Color(color.getRed(),
112
                         color.getGreen(),
113
                         color.getBlue()).toString();
114
        }
115
    }
116
117
    public static String fopFontToOdfFontStyle(CommonFont commonFont) {
118
        return commonFont.getFontStyle() == Constants.EN_ITALIC ? "italic" : null;
119
    }
120
121
    public static String fopFontToOdfFontWeight(CommonFont commonFont) {
122
        return commonFont.getFontWeight() >= Constants.EN_700 ? "bold" : null;
123
    }
124
125
    public static String fopAlignToOdfAlign(int textAlign) {
126
127
        if (textAlign == Constants.EN_LEFT) {
128
            return "left";
129
        } else if (textAlign == Constants.EN_JUSTIFY) {
130
            return "justify";
131
        } else if (textAlign == Constants.EN_CENTER) {
132
            return "center";
133
        } else if (textAlign == 39) {
134
            return "right";
135
        } else {
136
            return null;
137
        }
138
    }
139
140
    public static String fopSpaceBeforeToPt(SpaceProperty spaceBefore, BlockLayoutManager context) {
141
        if (spaceBefore == null) {
142
            return null;
143
        }
144
        Double value = Double.valueOf((double) spaceBefore.getLengthRange().toMinOptMax(context).getOpt() / 1000);
145
        return value + "pt";
146
    }
147
148
    public static String fopSpaceAfterToPt(SpaceProperty spaceAfter, BlockLayoutManager context) {
149
        if (spaceAfter == null) {
150
            return null;
151
        }
152
        Double value = Double.valueOf((double) spaceAfter.getLengthRange().toMinOptMax(context).getOpt() / 1000);
153
        return value + "pt";
154
    }
155
156
    public static String fopLengthToPt(Length l) {
157
        if (l == null) {
158
            return null;
159
        }
160
        Double value = Double.valueOf((double)l.getValue() / 1000);
161
        return value + "pt";
162
    }
163
164
    public static String awtColorToString(java.awt.Color color) {
165
        if (color == null) {
166
            return null;
167
        }
168
        return "#" + Integer.toHexString(color.getRed())
169
                   + Integer.toHexString(color.getGreen())
170
                   + Integer.toHexString(color.getBlue());
171
    }
172
}
(-)src/java/org/apache/fop/render/odf/ODTFOEventHandlerMaker.java (+63 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
package org.apache.fop.render.odf;
19
20
import java.io.OutputStream;
21
22
import org.apache.fop.apps.FOUserAgent;
23
import org.apache.fop.apps.MimeConstants;
24
import org.apache.fop.fo.FOEventHandler;
25
import org.apache.fop.render.AbstractFOEventHandlerMaker;
26
27
/**
28
 * Maker class for ODT support.
29
 */
30
public class ODTFOEventHandlerMaker extends AbstractFOEventHandlerMaker {
31
32
    private static final String[] MIMES = new String[] {
33
        MimeConstants.MIME_ODT
34
    };
35
36
37
    /**
38
     * {@inheritDoc}
39
     * @param ua FOUserAgent
40
     * @param out OutputStream
41
     * @return created ODTHandler
42
     */
43
    public FOEventHandler makeFOEventHandler(FOUserAgent ua, OutputStream out) {
44
        return new ODTHandler(ua, out);
45
    }
46
47
    /**
48
     * {@inheritDoc}
49
     * @return true, if an outputstream is needed
50
     */
51
    public boolean needsOutputStream() {
52
        return true;
53
    }
54
55
    /**
56
     * {@inheritDoc}
57
     * @return array of MIME types
58
     */
59
    public String[] getSupportedMimeTypes() {
60
        return MIMES;
61
    }
62
63
}
(-)src/java/org/apache/fop/cli/CommandLineOptions.java (-1 / +16 lines)
Lines 324-329 Link Here
324
                i = i + parsePDFOutputOption(args, i, "PDF/A-1b");
324
                i = i + parsePDFOutputOption(args, i, "PDF/A-1b");
325
            } else if (args[i].equals("-mif")) {
325
            } else if (args[i].equals("-mif")) {
326
                i = i + parseMIFOutputOption(args, i);
326
                i = i + parseMIFOutputOption(args, i);
327
            } else if (args[i].equals("-odt")) {
328
                i = i + parseODTOutputOption(args, i);
327
            } else if (args[i].equals("-rtf")) {
329
            } else if (args[i].equals("-rtf")) {
328
                i = i + parseRTFOutputOption(args, i);
330
                i = i + parseRTFOutputOption(args, i);
329
            } else if (args[i].equals("-tiff")) {
331
            } else if (args[i].equals("-tiff")) {
Lines 526-531 Link Here
526
        }
528
        }
527
    }
529
    }
528
530
531
    private int parseODTOutputOption(String[] args, int i) throws FOPException {
532
        setOutputMode(MimeConstants.MIME_ODT);
533
        if ((i + 1 == args.length)
534
                || (isOption(args[i + 1]))) {
535
            throw new FOPException("you must specify the ODT output file");
536
        } else {
537
            setOutputFile(args[i + 1]);
538
            return 1;
539
        }
540
    }
541
529
    private void setOutputFile(String filename) {
542
    private void setOutputFile(String filename) {
530
        if (isSystemInOutFile(filename)) {
543
        if (isSystemInOutFile(filename)) {
531
            this.useStdOut = true;
544
            this.useStdOut = true;
Lines 1199-1205 Link Here
1199
    public static void printUsage(PrintStream out) {
1212
    public static void printUsage(PrintStream out) {
1200
        out.println(
1213
        out.println(
1201
              "\nUSAGE\nfop [options] [-fo|-xml] infile [-xsl file] "
1214
              "\nUSAGE\nfop [options] [-fo|-xml] infile [-xsl file] "
1202
                    + "[-awt|-pdf|-mif|-rtf|-tiff|-png|-pcl|-ps|-txt|-at [mime]|-print] <outfile>\n"
1215
                    + "[-awt|-pdf|-mif|-odt|-rtf|-tiff|-png|-pcl|-ps|-txt|-at [mime]|-print] <outfile>\n"
1203
            + " [OPTIONS]  \n"
1216
            + " [OPTIONS]  \n"
1204
            + "  -version          print FOP version and exit\n"
1217
            + "  -version          print FOP version and exit\n"
1205
            + "  -d                debug mode   \n"
1218
            + "  -d                debug mode   \n"
Lines 1258-1263 Link Here
1258
            + "  -pdfa1b outfile   input will be rendered as PDF/A-1b compliant PDF\n"
1271
            + "  -pdfa1b outfile   input will be rendered as PDF/A-1b compliant PDF\n"
1259
            + "                    (outfile req'd, same as \"-pdf outfile -pdfprofile PDF/A-1b\")\n"
1272
            + "                    (outfile req'd, same as \"-pdf outfile -pdfprofile PDF/A-1b\")\n"
1260
            + "  -awt              input will be displayed on screen \n"
1273
            + "  -awt              input will be displayed on screen \n"
1274
            + "  -odt outfile      input will be rendered as ODT (outfile req'd)\n"
1261
            + "  -rtf outfile      input will be rendered as RTF (outfile req'd)\n"
1275
            + "  -rtf outfile      input will be rendered as RTF (outfile req'd)\n"
1262
            + "  -pcl outfile      input will be rendered as PCL (outfile req'd) \n"
1276
            + "  -pcl outfile      input will be rendered as PCL (outfile req'd) \n"
1263
            + "  -ps outfile       input will be rendered as PostScript (outfile req'd) \n"
1277
            + "  -ps outfile       input will be rendered as PostScript (outfile req'd) \n"
Lines 1293-1298 Link Here
1293
            + "  fop -xml foo.xml -xsl foo.xsl -foout foo.fo\n"
1307
            + "  fop -xml foo.xml -xsl foo.xsl -foout foo.fo\n"
1294
            + "  fop -xml - -xsl foo.xsl -pdf -\n"
1308
            + "  fop -xml - -xsl foo.xsl -pdf -\n"
1295
            + "  fop foo.fo -mif foo.mif\n"
1309
            + "  fop foo.fo -mif foo.mif\n"
1310
            + "  fop foo.fo -odt foo.odt\n"
1296
            + "  fop foo.fo -rtf foo.rtf\n"
1311
            + "  fop foo.fo -rtf foo.rtf\n"
1297
            + "  fop foo.fo -print\n"
1312
            + "  fop foo.fo -print\n"
1298
            + "  fop foo.fo -awt\n");
1313
            + "  fop foo.fo -awt\n");
(-)src/java/org/apache/fop/apps/MimeConstants.java (+2 lines)
Lines 34-37 Link Here
34
    String MIME_FOP_IF          = "application/X-fop-intermediate-format";
34
    String MIME_FOP_IF          = "application/X-fop-intermediate-format";
35
    /** Bitmap images */
35
    /** Bitmap images */
36
    String MIME_BITMAP          = "image/x-bitmap";
36
    String MIME_BITMAP          = "image/x-bitmap";
37
    /** Apache FOP's ODT format */
38
    String MIME_ODT             = "application/vnd.oasis.opendocument.text";
37
}
39
}
(-)src/java/META-INF/services/org.apache.fop.fo.FOEventHandler (-1 / +2 lines)
Line 1 Link Here
1
org.apache.fop.render.rtf.RTFFOEventHandlerMaker
1
org.apache.fop.render.rtf.RTFFOEventHandlerMaker
2
org.apache.fop.render.odf.ODTFOEventHandlerMaker
(-)test/odf/odt/fo_inline/with_basiclink.fo (+104 lines)
Line 0 Link Here
1
<?xml version="1.0" encoding="utf-8"?>
2
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
3
	<fo:layout-master-set>
4
		<fo:simple-page-master master-name="simple"
5
			page-height="29.7cm" page-width="21cm" margin-top="1cm"
6
			margin-bottom="2cm" margin-left="2.5cm" margin-right="2.5cm">
7
			<fo:region-body margin-top="3cm" />
8
			<fo:region-before extent="3cm" />
9
			<fo:region-after extent="1.5cm" />
10
		</fo:simple-page-master>
11
	</fo:layout-master-set>
12
	<fo:page-sequence master-reference="simple">
13
		<fo:flow flow-name="xsl-region-body">
14
			<fo:block margin-left="0" text-align="left">
15
				<fo:block font-family="Arial, Helvetica, Symbol, sans-serif"
16
					color="#000000" keep-with-next="always" font-size="16pt"
17
					font-weight="bold" space-before="18pt" space-after="3pt"
18
					padding-after="3pt" border-bottom-width=".1mm" border-bottom-style="solid"
19
					border-bottom-color="black" text-align="center">Titre 3 : IF - Imposition
20
					forfaitaire sur les pylônes</fo:block>
21
			</fo:block>
22
			<fo:block font-family="Arial, Helvetica, Symbol, sans-serif"
23
				font-size="10pt" white-space-collapse="true" text-align="justify">
24
				<fo:block role="tableofcontent-196-PGP-6" />
25
				<fo:block font-size="9pt">
26
					<fo:leader />
27
				</fo:block>
28
				<fo:block font-family="Arial, Helvetica, sans-serif;"
29
					font-size="100%" white-space-collapse="true" text-align="justify"
30
					space-before="3pt" space-after="6pt" font-weight="normal" color="black"
31
					margin-left="1cm">
32
					<fo:inline font-weight="bold">1. Agrément de l’exploitant de la
33
						résidence hôtelière à vocation sociale et délai de
34
						mise en location</fo:inline>
35
				</fo:block>
36
				<fo:block font-family="Arial, Helvetica, sans-serif;"
37
					font-size="100%" white-space-collapse="true" text-align="justify"
38
					space-before="3pt" space-after="6pt" font-weight="normal" color="black"
39
					margin-left="1cm">
40
					<fo:inline font-weight="bold">
41
						2. Changement de l’exploitant de la résidence à l’initiative du
42
						propriétaire
43
						(
44
						<fo:basic-link external-destination="http://google.com"
45
							color="blue">
46
							CCH,
47
							<fo:inline font-style="italic">article R</fo:inline>
48
							. 631-13, I
49
						</fo:basic-link>
50
					</fo:inline>
51
				</fo:block>
52
				<fo:block font-family="Arial, Helvetica, sans-serif;"
53
					font-size="100%" white-space-collapse="true" text-align="justify"
54
					space-before="3pt" space-after="6pt" font-weight="normal" color="black"
55
					margin-left="1cm">
56
					<fo:inline font-weight="bold">
57
						3. Abandon de l’exploitation à l’initiative de l’exploitant de la
58
						résidence
59
						(
60
						<fo:basic-link external-destination="http://google.com"
61
							color="blue">CCH, article R. 631-13, III</fo:basic-link>
62
						)
63
					</fo:inline>
64
				</fo:block>
65
				<fo:block font-family="Arial, Helvetica, sans-serif;"
66
					font-size="100%" white-space-collapse="true" text-align="justify"
67
					space-before="3pt" space-after="6pt" font-weight="normal" color="black"
68
					margin-left="1cm">
69
					<fo:inline font-weight="bold">
70
						4. Retrait de l’agrément de l’exploitant de la résidence (CCH,
71
						articles
72
						<fo:basic-link external-destination="http://google.com"
73
							color="blue">
74
							R.
75
							<fo:inline font-style="italic"> 63</fo:inline>
76
							1-17
77
						</fo:basic-link>
78
						et
79
						<fo:basic-link external-destination="http://google.com"
80
							color="blue">R. 451-7</fo:basic-link>
81
						)
82
					</fo:inline>
83
				</fo:block>
84
				<fo:block font-family="Arial, Helvetica, Symbol, sans-serif"
85
					font-size="11pt" white-space-collapse="true" text-align="justify"
86
					space-before="3pt" space-after="6pt">1 Dans ce cas, le propriétaire de la
87
					résidence prend les dispositions nécessaires pour assurer le
88
					respect
89
					de ses engagements (prix de nuitée maximal et pourcentage
90
					des
91
					logements réservés aux personnes en difficulté, notamment) ainsi
92
					que la continuité de l’exploitation de la résidence au bénéfice des
93
					occupants de celle-ci.</fo:block>
94
				<fo:block font-family="Arial, Helvetica, sans-serif;"
95
					font-size="100%" white-space-collapse="true" text-align="justify"
96
					space-before="3pt" space-after="6pt" font-weight="normal" color="black"
97
					margin-left="1cm">
98
					<fo:inline font-weight="bold">5. Défaillance de l’exploitant</fo:inline>
99
				</fo:block>
100
			</fo:block>
101
		</fo:flow>
102
	</fo:page-sequence>
103
</fo:root>
104
(-)test/odf/odt/fo_inline/color_font_size_style_weight.fo (+24 lines)
Line 0 Link Here
1
<?xml version="1.0" encoding="utf-8"?>
2
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
3
	<fo:layout-master-set>
4
		<fo:simple-page-master master-name="simple"
5
			page-height="29.7cm" page-width="21cm" margin-top="1cm"
6
			margin-bottom="2cm" margin-left="2.5cm" margin-right="2.5cm">
7
			<fo:region-body margin-top="3cm" />
8
			<fo:region-before extent="3cm" />
9
			<fo:region-after extent="1.5cm" />
10
		</fo:simple-page-master>
11
	</fo:layout-master-set>
12
	<fo:page-sequence master-reference="simple">
13
		<fo:flow flow-name="xsl-region-body">
14
			<fo:block text-align="justify">
15
				<fo:block font-size="15pt" color="red">
16
					Joad <fo:inline font-weight="bold">rolled</fo:inline> the coat <fo:inline color="blue" font-size="20pt">up more</fo:inline> tightly. "An old turtle," he said. "Picked
17
					him up on the
18
					road. An old bulldozer. <fo:inline font-style="italic">Thought I'd </fo:inline>take 'im to my little brother. Kids
19
					like turtles."
20
				</fo:block>
21
			</fo:block>
22
		</fo:flow>
23
	</fo:page-sequence>
24
</fo:root>
(-)test/odf/odt/basic/text.fo (+28 lines)
Line 0 Link Here
1
<?xml version="1.0" encoding="utf-8"?>
2
3
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
4
5
  <fo:layout-master-set>
6
    <fo:simple-page-master master-name="simple"
7
                  page-height="29.7cm"
8
                  page-width="21cm"
9
                  margin-top="1cm"
10
                  margin-bottom="2cm"
11
                  margin-left="2.5cm"
12
                  margin-right="2.5cm">
13
      <fo:region-body margin-top="3cm"/>
14
      <fo:region-before extent="3cm"/>
15
      <fo:region-after extent="1.5cm"/>
16
    </fo:simple-page-master>
17
  </fo:layout-master-set>
18
19
  <fo:page-sequence master-reference="simple">
20
    <fo:flow flow-name="xsl-region-body">
21
      <fo:block font-size="12pt"
22
                font-family="sans-serif"
23
                line-height="15pt"
24
                space-after.optimum="3pt"
25
                text-align="justify">This is simple text.</fo:block>
26
    </fo:flow>
27
  </fo:page-sequence>
28
</fo:root>
(-)test/odf/odt/fo_block/font_size.fo (+164 lines)
Line 0 Link Here
1
<?xml version="1.0" encoding="utf-8"?>
2
3
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
4
5
	<fo:layout-master-set>
6
		<fo:simple-page-master master-name="simple"
7
			page-height="29.7cm" page-width="21cm" margin-top="1cm"
8
			margin-bottom="2cm" margin-left="2.5cm" margin-right="2.5cm">
9
			<fo:region-body margin-top="3cm" />
10
			<fo:region-before extent="3cm" />
11
			<fo:region-after extent="1.5cm" />
12
		</fo:simple-page-master>
13
	</fo:layout-master-set>
14
15
	<fo:page-sequence master-reference="simple">
16
		<fo:flow flow-name="xsl-region-body">
17
			<fo:block>
18
				<fo:block font-size="13pt">
19
					Lokomotywa
20
				</fo:block>
21
				<fo:block font-size="4pt">
22
					Stoi na stacji lokomotywa,
23
					<fo:block />
24
					Ciężka, ogromna i pot z niej spływa -
25
					<fo:block />
26
					Tłusta oliwa.
27
					<fo:block />
28
					Stoi i sapie, dyszy i dmucha,
29
					<fo:block />
30
					Żar z rozgrzanego jej brzucha bucha:
31
					<fo:block />
32
					Buch - jak gorąco!
33
					<fo:block />
34
					Uch - jak gorąco!
35
					<fo:block />
36
					Puff - jak gorąco!
37
					<fo:block />
38
					Uff - jak gorąco!
39
					<fo:block />
40
					Już ledwo sapie, już ledwo zipie,
41
					<fo:block />
42
					A jeszcze palacz węgiel w nią sypie.
43
					<fo:block />
44
					Wagony do niej podoczepiali
45
					<fo:block />
46
					Wielkie i ciężkie, z żelaza, stali,
47
					<fo:block />
48
					I pełno ludzi w każdym wagonie,
49
					<fo:block />
50
					A w jednym krowy, a w drugim konie,
51
					<fo:block />
52
					A w trzecim siedzą same grubasy,
53
					<fo:block />
54
					Siedzą i jedzą tłuste kiełbasy.
55
					<fo:block />
56
					A czwarty wagon pełen bananów,
57
					<fo:block />
58
					A w piątym stoi sześć fortepianów,
59
					<fo:block />
60
					W szóstym armata, o! jaka wielka!
61
					<fo:block />
62
					Pod każdym kołem żelazna belka!
63
					<fo:block />
64
					W siódmym dębowe stoły i szafy,
65
					<fo:block />
66
					W ósmym słoń, niedźwiedź i dwie żyrafy,
67
					<fo:block />
68
					W dziewiątym - same tuczone świnie,
69
					<fo:block />
70
					W dziesiątym - kufry, paki i skrzynie,
71
					<fo:block />
72
					A tych wagonów jest ze czterdzieści,
73
					<fo:block />
74
					Sam nie wiem, co się w nich jeszcze mieści.
75
				</fo:block>
76
				<fo:block font-size="6pt">
77
					Lecz choćby przyszło tysiąc atletów
78
					<fo:block />
79
					I każdy zjadłby tysiąc kotletów,
80
					<fo:block />
81
					I każdy nie wiem jak się natężał,
82
					<fo:block />
83
					To nie udźwigną - taki to ciężar!
84
				</fo:block>
85
				<fo:block font-size="15pt">
86
					Nagle - gwizd!
87
					<fo:block />
88
					Nagle - świst!
89
					<fo:block />
90
					Para - buch!
91
					<fo:block />
92
					Koła - w ruch!
93
				</fo:block>
94
				<fo:block font-size="8pt">
95
					Najpierw
96
					<fo:block />
97
					powoli
98
					<fo:block />
99
					jak żółw
100
					<fo:block />
101
					ociężale
102
					<fo:block />
103
					Ruszyła
104
					<fo:block />
105
					maszyna
106
					<fo:block />
107
					po szynach
108
					<fo:block />
109
					ospale.
110
					<fo:block />
111
					Szarpnęła wagony i ciągnie z mozołem,
112
					<fo:block />
113
					I kręci się, kręci się koło za kołem,
114
					<fo:block />
115
					I biegu przyspiesza, i gna coraz prędzej,
116
					<fo:block />
117
					I dudni, i stuka, łomoce i pędzi.
118
				</fo:block>
119
				<fo:block font-size="11pt">
120
					A dokąd? A dokąd? A dokąd? Na wprost!
121
					<fo:block />
122
					Po torze, po torze, po torze, przez most,
123
					<fo:block />
124
					Przez góry, przez tunel, przez pola, przez las
125
					<fo:block />
126
					I spieszy się, spieszy, by zdążyć na czas,
127
					<fo:block />
128
					Do taktu turkoce i puka, i stuka to:
129
					<fo:block />
130
					Tak to to, tak to to, tak to to, tak to to,
131
					<fo:block />
132
					Gładko tak, lekko tak toczy się w dal,
133
					<fo:block />
134
					Jak gdyby to była piłeczka, nie stal,
135
					<fo:block />
136
					Nie ciężka maszyna zziajana, zdyszana,
137
					<fo:block />
138
					Lecz raszka, igraszka, zabawka blaszana.
139
				</fo:block>
140
				<fo:block font-size="20pt">
141
					A skądże to, jakże to, czemu tak gna?
142
					<fo:block />
143
					A co to to, co to to, kto to tak pcha?
144
					<fo:block />
145
					Że pędzi, że wali, że bucha, buch-buch?
146
					<fo:block />
147
					To para gorąca wprawiła to w ruch,
148
					<fo:block />
149
					To para, co z kotła rurami do tłoków,
150
					<fo:block />
151
					A tłoki kołami ruszają z dwóch boków
152
					<fo:block />
153
					I gnają, i pchają, i pociąg się toczy,
154
					<fo:block />
155
					Bo para te tłoki wciąż tłoczy i tłoczy,,
156
					<fo:block />
157
					I koła turkocą, i puka, i stuka to:
158
					<fo:block />
159
					Tak to to, tak to to, tak to to, tak to to!...
160
				</fo:block>
161
			</fo:block>
162
		</fo:flow>
163
	</fo:page-sequence>
164
</fo:root>
(-)test/odf/odt/fo_block/color.fo (+253 lines)
Line 0 Link Here
1
<?xml version="1.0" encoding="utf-8"?>
2
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
3
	<fo:layout-master-set>
4
		<fo:simple-page-master master-name="simple"
5
			page-height="29.7cm" page-width="21cm" margin-top="1cm"
6
			margin-bottom="2cm" margin-left="2.5cm" margin-right="2.5cm">
7
			<fo:region-body margin-top="3cm" />
8
			<fo:region-before extent="3cm" />
9
			<fo:region-after extent="1.5cm" />
10
		</fo:simple-page-master>
11
	</fo:layout-master-set>
12
	<fo:page-sequence master-reference="simple">
13
		<fo:flow flow-name="xsl-region-body">
14
			<fo:block font-family="Arial" font-size="13pt">
15
				<fo:block font-size="20pt" color="black" >
16
					Julian Tuwim - Rzepka
17
				</fo:block>
18
				<fo:block color="#00ff00">
19
					Zasadził dziadek rzepkę w ogrodzie,
20
					<fo:block />
21
					Chodził te rzepkę oglądać co dzień.
22
					<fo:block />
23
					Wyrosła rzepka jędrna i krzepka,
24
					<fo:block />
25
					Schrupać by rzepkę z kawałkiem chlebaka!
26
					<fo:block />
27
					Więc ciągnie rzepkę dziadek niebożę,
28
					<fo:block />
29
					Ciągnie i ciągnie, wyciągnąć nie może!
30
				</fo:block>
31
				<fo:block color="red">
32
					Zawołał dziadek na pomoc babcię:
33
					<fo:block />
34
					"Ja złapię rzepkę, ty za mnie złap się!"
35
					<fo:block />
36
					I biedny dziadek z babcią niebogą
37
					<fo:block />
38
					Ciągną i ciągną, wyciągnąć nie mogą!
39
					<fo:block />
40
					Babcia za dziadka,
41
					<fo:block />
42
					Dziadek za rzepkę,
43
					<fo:block />
44
					Oj, przydałby się ktoś na przyczepkę!
45
				</fo:block>
46
				<fo:block color="#445533">
47
					Przyleciał wnuczek, babci się złapał,
48
					<fo:block />
49
					Poci się, stęka, aż się zasapał!
50
					<fo:block />
51
					Wnuczek za babcię,
52
					<fo:block />
53
					Babcia za dziadka,
54
					<fo:block />
55
					Dziadek za rzepkę,
56
					<fo:block />
57
					Oj, przydałby się ktoś na przyczepkę!
58
					<fo:block />
59
					Pocą się, sapią, stękają srogo,
60
					<fo:block />
61
					Ciągną i ciągną, wyciągnąć nie mogą!
62
				</fo:block>
63
				<fo:block color="orange">
64
					Zawołał wnuczek szczeniaczka Mruczka,
65
					<fo:block />
66
					Przyleciał Mruczek i ciągnie wnuczka!
67
					<fo:block />
68
					Mruczek za wnuczka,
69
					<fo:block />
70
					Wnuczek za babcię,
71
					<fo:block />
72
					Babcia za dziadka,
73
					<fo:block />
74
					Dziadek za rzepkę,
75
					<fo:block />
76
					Oj, przydałby się ktoś na przyczepkę!
77
					<fo:block />
78
					Pocą się, sapią, stękają srogo,
79
					<fo:block />
80
					Ciągną i ciągną, wyciągnąć nie mogą!
81
				</fo:block>
82
				<fo:block color="#abcdef">
83
					Na kurkę czyhał kotek w ukryciu,
84
					<fo:block />
85
					Zaszczekał Mruczek: "Pomóż nam, Kiciu!"
86
					<fo:block />
87
					Kicia za Mruczka,
88
					<fo:block />
89
					Mruczek za wnuczka,
90
					<fo:block />
91
					Wnuczek za babcię,
92
					<fo:block />
93
					Babcia za dziadka,
94
					<fo:block />
95
					Dziadek za rzepkę,
96
					<fo:block />
97
					Oj, przydałby się ktoś na przyczepkę!
98
					<fo:block />
99
					Pocą się, sapią, stękają srogo,
100
					<fo:block />
101
					Ciągną i ciągną, wyciągnąć nie mogą!
102
				</fo:block>
103
				<fo:block color="#654321">
104
					Więc woła Kicia kurkę z podwórka,
105
					<fo:block />
106
					Wnet przyleciała usłużna kurka.
107
					<fo:block />
108
					Kurka za Kicię,
109
					<fo:block />
110
					Kicia za Mruczka,
111
					<fo:block />
112
					Mruczek za wnuczka,
113
					<fo:block />
114
					Wnuczek za babcię,
115
					<fo:block />
116
					Babcia za dziadka,
117
					<fo:block />
118
					Dziadek za rzepkę,
119
					<fo:block />
120
					Oj, przydałby się ktoś na przyczepkę!
121
					<fo:block />
122
					Pocą się, sapią, stękają srogo,
123
					<fo:block />
124
					Ciągną i ciągną, wyciągnąć nie mogą!
125
				</fo:block>
126
				<fo:block color="#123456">
127
					Szła sobie gąska ścieżynką wąską,
128
					<fo:block />
129
					Krzyknęła kurka: "ChodĽ no tu gąsko!"
130
					<fo:block />
131
					Gąska za kurkę,
132
					<fo:block />
133
					Kurka za Kicię,
134
					<fo:block />
135
					Kicia za Mruczka,
136
					<fo:block />
137
					Mruczek za wnuczka,
138
					<fo:block />
139
					Wnuczek za babcię,
140
					<fo:block />
141
					Babcia za dziadka,
142
					<fo:block />
143
					Dziadek za rzepkę,
144
					<fo:block />
145
					Oj, przydałby się ktoś na przyczepkę!
146
					<fo:block />
147
					Pocą się, sapią, stękają srogo,
148
					<fo:block />
149
					Ciągną i ciągną, wyciągnąć nie mogą!
150
				</fo:block>
151
				<fo:block color="#334411">
152
					Leciał wysoko bocian-długonos,
153
					<fo:block />
154
					"Fruńże tu, boćku, do nas na pomoc!"
155
					<fo:block />
156
					Bociek za gąskę,
157
					<fo:block />
158
					Gąska za kurkę,
159
					<fo:block />
160
					Kurka za Kicię,
161
					<fo:block />
162
					Kicia za Mruczka,
163
					<fo:block />
164
					Mruczek za wnuczka,
165
					<fo:block />
166
					Wnuczek za babcię,
167
					<fo:block />
168
					Babcia za dziadka,
169
					<fo:block />
170
					Dziadek za rzepkę,
171
					<fo:block />
172
					Oj, przydałby się ktoś na przyczepkę!
173
					<fo:block />
174
					Pocą się, sapią, stękają srogo,
175
					<fo:block />
176
					Ciągną i ciągną, wyciągnąć nie mogą!
177
				</fo:block>
178
				<fo:block color="#aabbcc">
179
					Skakała drogą zielona żabka,
180
					<fo:block />
181
					Złapała boćka - rzadka to gradka!
182
					<fo:block />
183
					Żabka za boćka,
184
					<fo:block />
185
					Bociek za gąskę,
186
					<fo:block />
187
					Gąska za kurkę,
188
					<fo:block />
189
					Kurka za Kicię,
190
					<fo:block />
191
					Kicia za Mruczka,
192
					<fo:block />
193
					Mruczek za wnuczka,
194
					<fo:block />
195
					Wnuczek za babcię,
196
					<fo:block />
197
					Babcia za dziadka,
198
					<fo:block />
199
					Dziadek za rzepkę,
200
					<fo:block />
201
					A na przyczepkę
202
					<fo:block />
203
					Kawka za żabkę
204
					<fo:block />
205
					Bo na tę rzepkę
206
					<fo:block />
207
					Też miała chrapkę.
208
				</fo:block>
209
				<fo:block color="yellow">
210
					Tak się zawzięli,
211
					<fo:block />
212
					Tak się nadęli,
213
					<fo:block />
214
					Ze nagle rzepkę
215
					<fo:block />
216
					Trrrach!! - wyciągnęli!
217
					<fo:block />
218
					Aż wstyd powiedzieć,
219
					<fo:block />
220
					Co było dalej!
221
					<fo:block />
222
					Wszyscy na siebie
223
					<fo:block />
224
					Poupadali:
225
					<fo:block />
226
					Rzepka na dziadka,
227
					<fo:block />
228
					Dziadek na babcię,
229
					<fo:block />
230
					Babcia na wnuczka,
231
					<fo:block />
232
					Wnuczek na Mruczka,
233
					<fo:block />
234
					Mruczek na Kicię,
235
					<fo:block />
236
					Kicia na kurkę,
237
					<fo:block />
238
					Kurka na gąskę,
239
					<fo:block />
240
					Gąska na boćka,
241
					<fo:block />
242
					Bociek na żabkę,
243
					<fo:block />
244
					Żabka na kawkę
245
					<fo:block />
246
					I na ostatku
247
					<fo:block />
248
					Kawka na trawkę.
249
				</fo:block>
250
			</fo:block>
251
		</fo:flow>
252
	</fo:page-sequence>
253
</fo:root>
(-)test/odf/odt/fo_block/font_family.fo (+169 lines)
Line 0 Link Here
1
<?xml version="1.0" encoding="utf-8"?>
2
3
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
4
5
	<fo:layout-master-set>
6
		<fo:simple-page-master master-name="simple"
7
			page-height="29.7cm" page-width="21cm" margin-top="1cm"
8
			margin-bottom="2cm" margin-left="2.5cm" margin-right="2.5cm">
9
			<fo:region-body margin-top="3cm" />
10
			<fo:region-before extent="3cm" />
11
			<fo:region-after extent="1.5cm" />
12
		</fo:simple-page-master>
13
	</fo:layout-master-set>
14
15
	<fo:page-sequence master-reference="simple">
16
		<fo:flow flow-name="xsl-region-body">
17
			<fo:block font-family="Arial, Helvetica, Symbol, sans-serif"
18
				font-size="11pt">
19
				<fo:block font-family="Arial, Helvetica, Symbol, sans-serif">
20
					Lokomotywa
21
				</fo:block>
22
				<fo:block font-family="Helvetica, Symbol, sans-serif"
23
					font-size="11pt">
24
					Stoi na stacji lokomotywa,
25
					<fo:block />
26
					Ciężka, ogromna i pot z niej spływa -
27
					<fo:block />
28
					Tłusta oliwa.
29
					<fo:block />
30
					Stoi i sapie, dyszy i dmucha,
31
					<fo:block />
32
					Żar z rozgrzanego jej brzucha bucha:
33
					<fo:block />
34
					Buch - jak gorąco!
35
					<fo:block />
36
					Uch - jak gorąco!
37
					<fo:block />
38
					Puff - jak gorąco!
39
					<fo:block />
40
					Uff - jak gorąco!
41
					<fo:block />
42
					Już ledwo sapie, już ledwo zipie,
43
					<fo:block />
44
					A jeszcze palacz węgiel w nią sypie.
45
					<fo:block />
46
					Wagony do niej podoczepiali
47
					<fo:block />
48
					Wielkie i ciężkie, z żelaza, stali,
49
					<fo:block />
50
					I pełno ludzi w każdym wagonie,
51
					<fo:block />
52
					A w jednym krowy, a w drugim konie,
53
					<fo:block />
54
					A w trzecim siedzą same grubasy,
55
					<fo:block />
56
					Siedzą i jedzą tłuste kiełbasy.
57
					<fo:block />
58
					A czwarty wagon pełen bananów,
59
					<fo:block />
60
					A w piątym stoi sześć fortepianów,
61
					<fo:block />
62
					W szóstym armata, o! jaka wielka!
63
					<fo:block />
64
					Pod każdym kołem żelazna belka!
65
					<fo:block />
66
					W siódmym dębowe stoły i szafy,
67
					<fo:block />
68
					W ósmym słoń, niedźwiedź i dwie żyrafy,
69
					<fo:block />
70
					W dziewiątym - same tuczone świnie,
71
					<fo:block />
72
					W dziesiątym - kufry, paki i skrzynie,
73
					<fo:block />
74
					A tych wagonów jest ze czterdzieści,
75
					<fo:block />
76
					Sam nie wiem, co się w nich jeszcze mieści.
77
				</fo:block>
78
				<fo:block font-family="sans-serif" font-size="11pt">
79
					Lecz choćby przyszło tysiąc atletów
80
					<fo:block />
81
					I każdy zjadłby tysiąc kotletów,
82
					<fo:block />
83
					I każdy nie wiem jak się natężał,
84
					<fo:block />
85
					To nie udźwigną - taki to ciężar!
86
				</fo:block>
87
				<fo:block font-family="Arial, Helvetica, Symbol, sans-serif"
88
					font-size="11pt">
89
					Nagle - gwizd!
90
					<fo:block />
91
					Nagle - świst!
92
					<fo:block />
93
					Para - buch!
94
					<fo:block />
95
					Koła - w ruch!
96
				</fo:block>
97
				<fo:block font-family="Times new Roman" font-size="11pt">
98
					Najpierw
99
					<fo:block />
100
					powoli
101
					<fo:block />
102
					jak żółw
103
					<fo:block />
104
					ociężale
105
					<fo:block />
106
					Ruszyła
107
					<fo:block />
108
					maszyna
109
					<fo:block />
110
					po szynach
111
					<fo:block />
112
					ospale.
113
					<fo:block />
114
					Szarpnęła wagony i ciągnie z mozołem,
115
					<fo:block />
116
					I kręci się, kręci się koło za kołem,
117
					<fo:block />
118
					I biegu przyspiesza, i gna coraz prędzej,
119
					<fo:block />
120
					I dudni, i stuka, łomoce i pędzi.
121
				</fo:block>
122
				<fo:block font-family="Arial, Helvetica, Symbol, sans-serif"
123
					font-size="11pt">
124
					A dokąd? A dokąd? A dokąd? Na wprost!
125
					<fo:block />
126
					Po torze, po torze, po torze, przez most,
127
					<fo:block />
128
					Przez góry, przez tunel, przez pola, przez las
129
					<fo:block />
130
					I spieszy się, spieszy, by zdążyć na czas,
131
					<fo:block />
132
					Do taktu turkoce i puka, i stuka to:
133
					<fo:block />
134
					Tak to to, tak to to, tak to to, tak to to,
135
					<fo:block />
136
					Gładko tak, lekko tak toczy się w dal,
137
					<fo:block />
138
					Jak gdyby to była piłeczka, nie stal,
139
					<fo:block />
140
					Nie ciężka maszyna zziajana, zdyszana,
141
					<fo:block />
142
					Lecz raszka, igraszka, zabawka blaszana.
143
				</fo:block>
144
				<fo:block font-family="Arial, Helvetica, Symbol, sans-serif"
145
					font-size="11pt">
146
					A skądże to, jakże to, czemu tak gna?
147
					<fo:block />
148
					A co to to, co to to, kto to tak pcha?
149
					<fo:block />
150
					Że pędzi, że wali, że bucha, buch-buch?
151
					<fo:block />
152
					To para gorąca wprawiła to w ruch,
153
					<fo:block />
154
					To para, co z kotła rurami do tłoków,
155
					<fo:block />
156
					A tłoki kołami ruszają z dwóch boków
157
					<fo:block />
158
					I gnają, i pchają, i pociąg się toczy,
159
					<fo:block />
160
					Bo para te tłoki wciąż tłoczy i tłoczy,,
161
					<fo:block />
162
					I koła turkocą, i puka, i stuka to:
163
					<fo:block />
164
					Tak to to, tak to to, tak to to, tak to to!...
165
				</fo:block>
166
			</fo:block>
167
		</fo:flow>
168
	</fo:page-sequence>
169
</fo:root>
(-)test/odf/odt/fo_block/text_align.fo (+77 lines)
Line 0 Link Here
1
<?xml version="1.0" encoding="utf-8"?>
2
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
3
	<fo:layout-master-set>
4
		<fo:simple-page-master master-name="simple"
5
			page-height="29.7cm" page-width="21cm" margin-top="1cm"
6
			margin-bottom="2cm" margin-left="2.5cm" margin-right="2.5cm">
7
			<fo:region-body margin-top="3cm" />
8
			<fo:region-before extent="3cm" />
9
			<fo:region-after extent="1.5cm" />
10
		</fo:simple-page-master>
11
	</fo:layout-master-set>
12
	<fo:page-sequence master-reference="simple">
13
		<fo:flow flow-name="xsl-region-body">
14
			<fo:block font-size="13pt">
15
				<fo:block text-align="justify">
16
					Joad rolled the coat up more tightly. "An old turtle," he said. "Picked
17
					him up on the
18
					road. An old bulldozer. Thought I'd take 'im to my little brother. Kids
19
					like turtles."
20
				</fo:block>
21
				<fo:block text-align="left">
22
					The preacher nodded his head slowly. "Every kid got a turtle some time
23
					or other.
24
					Nobody can't keep a turtle though. They work at it and work at it, and at
25
					last one day
26
					they get out and away they go—off somewheres. It's like me. I wouldn't
27
					take the good
28
					ol' gospel that was just layin' there to my hand. I got to be pickin'
29
					at it an' workin' at it
30
					until I got it all tore down. Here I got the sperit sometimes an'
31
					nothin' to preach about. I
32
					got the call to lead people, an' no place to lead 'em."
33
				</fo:block>
34
				<fo:block text-align="right">
35
					"Lead 'em around and around," said Joad. "Sling 'em in the irrigation
36
					ditch. Tell 'em
37
					they'll burn in hell if they don't think like you. What the hell you want
38
					to lead 'em
39
					someplace for? Jus' lead 'em."
40
				</fo:block>
41
				<fo:block text-align="center">
42
					The straight trunk shade had stretched out along the ground. Joad
43
					moved gratefully
44
					into it and squatted on his hams and made a new smooth place on which
45
					to draw his
46
					thoughts with a stick. A thick-furred yellow shepherd dog came trotting
47
					down the road,
48
					head low, tongue lolling and dripping. Its tail hung limply curled, and
49
					it panted loudly.
50
					Joad whistled at it, but it only dropped its head an inch and trotted
51
					fast toward some
52
					definite destination. "Goin' someplace," Joad explained, a little piqued.
53
					"Goin' for
54
					home maybe."
55
				</fo:block>
56
				<fo:block>
57
					The preacher could not be thrown from his subject. "Goin' someplace,"
58
					he repeated.
59
					"That's right, he's goin' someplace. Me—I don't know where I'm goin'. Tell
60
					you what—
61
					I used ta get the people jumpin' an' talkin' in tongues and
62
					glory-shoutin' till they just
63
					fell down an' passed out. An' some I'd baptize to bring 'em to. An'
64
					then—you know
65
					what I'd do? I'd take one of them girls out in the grass, an' I'd lay
66
					with her. Done it
67
					ever' time. Then I'd feel bad, an' I'd pray an' pray, but it didn't do
68
					no good. Come the
69
					next time, them an' me was full of the sperit, I'd do it again. I
70
					figgered there just wasn't
71
					no hope for me, an' I was a damned ol' hypocrite. But I didn't mean
72
					to be."
73
				</fo:block>
74
			</fo:block>
75
		</fo:flow>
76
	</fo:page-sequence>
77
</fo:root>
(-)test/odf/odt/fo_block/space_before_after.fo (+64 lines)
Line 0 Link Here
1
<?xml version="1.0" encoding="utf-8"?>
2
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
3
	<fo:layout-master-set>
4
		<fo:simple-page-master master-name="simple"
5
			page-height="29.7cm" page-width="21cm" margin-top="1cm"
6
			margin-bottom="2cm" margin-left="2.5cm" margin-right="2.5cm">
7
			<fo:region-body margin-top="3cm" />
8
			<fo:region-before extent="3cm" />
9
			<fo:region-after extent="1.5cm" />
10
		</fo:simple-page-master>
11
	</fo:layout-master-set>
12
	<fo:page-sequence master-reference="simple">
13
		<fo:flow flow-name="xsl-region-body">
14
			<fo:block font-size="13pt" text-align="justify">
15
				<fo:block space-before="10pt" space-after="6pt">
16
					Joad had moved
17
					into the imperfect shade of the molting leaves before
18
					the man heard
19
					him coming, stopped his song, and turned his head. It was a long
20
					head,
21
					bony; tight of
22
					skin, and set on a neck as stringy and muscular
23
					as a celery stalk. His
24
					eyeballs were
25
					heavy and protruding; the lids
26
					stretched to cover them, and the lids
27
					were raw and red.
28
					His cheeks
29
					were brown and shiny and hairless and his mouth
30
					full—humorous or
31
					sensual. The nose, beaked and hard, stretched the skin so tightly
32
					that the
33
					bridge showed
34
					white. There was no perspiration on the face,
35
					not even on the tall pale
36
					forehead. It was
37
					an abnormally high
38
					forehead, lined with delicate blue veins at the
39
					temples. Fully half
40
					of the face was above the eyes. His stiff gray hair was mussed back
41
					from his brow as
42
					though he had combed it back with his fingers. For
43
					clothes he wore
44
					overalls and a blue
45
					shirt. A denim coat with brass
46
					buttons and a spotted brown hat creased
47
					like a pork pie
48
					lay on the
49
					ground beside him. Canvas sneakers, gray with dust, lay
50
					near by
51
					where they
52
					had fallen when they were kicked off.
53
				</fo:block>
54
				<fo:block space-before="1pt" space-after="1pt">
55
					The man looked long at Joad. The light seemed to go far into his brown
56
					eyes, and it
57
					picked out little golden specks deep in the irises. The strained bundle
58
					of neck muscles
59
					stood out.
60
				</fo:block>
61
			</fo:block>
62
		</fo:flow>
63
	</fo:page-sequence>
64
</fo:root>
(-)test/odf/odt/fo_block/font_style.fo (+30 lines)
Line 0 Link Here
1
<?xml version="1.0" encoding="utf-8"?>
2
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
3
	<fo:layout-master-set>
4
		<fo:simple-page-master master-name="simple"
5
			page-height="29.7cm" page-width="21cm" margin-top="1cm"
6
			margin-bottom="2cm" margin-left="2.5cm" margin-right="2.5cm">
7
			<fo:region-body margin-top="3cm" />
8
			<fo:region-before extent="3cm" />
9
			<fo:region-after extent="1.5cm" />
10
		</fo:simple-page-master>
11
	</fo:layout-master-set>
12
	<fo:page-sequence master-reference="simple">
13
		<fo:flow flow-name="xsl-region-body">
14
			<fo:block>
15
				<fo:block>
16
					O KOCIE
17
				</fo:block>
18
				<fo:block font-style="italic">
19
					Słyszał kto kiedy jako ciągą kota? 
20
					<fo:block/>
21
					Nie zawżdy szuka wody ta robota, 
22
					<fo:block/>
23
					Ciągnie go drugi nadobnie na suszy, 
24
					<fo:block/>
25
					Sukniej nie zmacza, ale wżdy mdło duszy.
26
				</fo:block>
27
			</fo:block>
28
		</fo:flow>
29
	</fo:page-sequence>
30
</fo:root>
(-)test/odf/odt/fo_block/font_weight.fo (+33 lines)
Line 0 Link Here
1
<?xml version="1.0" encoding="utf-8"?>
2
3
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
4
5
	<fo:layout-master-set>
6
		<fo:simple-page-master master-name="simple"
7
			page-height="29.7cm" page-width="21cm" margin-top="1cm"
8
			margin-bottom="2cm" margin-left="2.5cm" margin-right="2.5cm">
9
			<fo:region-body margin-top="3cm" />
10
			<fo:region-before extent="3cm" />
11
			<fo:region-after extent="1.5cm" />
12
		</fo:simple-page-master>
13
	</fo:layout-master-set>
14
15
	<fo:page-sequence master-reference="simple">
16
		<fo:flow flow-name="xsl-region-body">
17
			<fo:block>
18
				<fo:block font-weight="bold">
19
					DO PANIEJ
20
				</fo:block>
21
				<fo:block>
22
					Co usty mówisz byś w sercu myśliła,
23
					<fo:block/>
24
					Barzo byś mię tym, Pani, zniewoliła. 
25
					<fo:block/>
26
					Ale kiedy mię swym miłym mianujesz, 
27
					<fo:block/>
28
					Podobno dawnym zwyczajom folgujesz.
29
				</fo:block>
30
			</fo:block>
31
		</fo:flow>
32
	</fo:page-sequence>
33
</fo:root>
(-)test/odf/odt/fo_external_graphic/simple.fo (+27 lines)
Line 0 Link Here
1
<?xml version="1.0" encoding="utf-8"?>
2
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
3
	<fo:layout-master-set>
4
		<fo:simple-page-master master-name="simple"
5
			page-height="29.7cm" page-width="21cm" margin-top="1cm"
6
			margin-bottom="2cm" margin-left="2.5cm" margin-right="2.5cm">
7
			<fo:region-body margin-top="3cm" />
8
			<fo:region-before extent="3cm" />
9
			<fo:region-after extent="1.5cm" />
10
		</fo:simple-page-master>
11
	</fo:layout-master-set>
12
	<fo:page-sequence master-reference="simple">
13
		<fo:flow flow-name="xsl-region-body">
14
			<fo:block text-align="justify">
15
				<fo:block font-size="15pt">
16
					Joad rolled the coat up more tightly. "An old turtle," he said. "Picked
17
					him up on the
18
					road. An old bulldozer. Thought I'd take 'im to my little brother. Kids
19
					like turtles."
20
				</fo:block>
21
				<fo:block>
22
					<fo:external-graphic src="./test/odf/odt/fo_external_graphic/img.jpg" />
23
				</fo:block>
24
			</fo:block>
25
		</fo:flow>
26
	</fo:page-sequence>
27
</fo:root>
(-)test/odf/odt/fo_table/simple.fo (+128 lines)
Line 0 Link Here
1
<?xml version="1.0" encoding="utf-8"?>
2
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
3
	<fo:layout-master-set>
4
		<fo:simple-page-master master-name="simple"
5
			page-height="29.7cm" page-width="21cm" margin-top="1cm"
6
			margin-bottom="2cm" margin-left="2.5cm" margin-right="2.5cm">
7
			<fo:region-body margin-top="3cm" />
8
			<fo:region-before extent="3cm" />
9
			<fo:region-after extent="1.5cm" />
10
		</fo:simple-page-master>
11
	</fo:layout-master-set>
12
	<fo:page-sequence master-reference="simple">
13
		<fo:flow flow-name="xsl-region-body">
14
			<fo:block text-align="justify">
15
				<fo:block font-size="15pt">
16
					Joad rolled the coat up more tightly.
17
					"An old turtle," he said. "Picked
18
					him up on the
19
					road. An old
20
					bulldozer. Thought I'd take 'im to my little brother. Kids
21
					like
22
					turtles."
23
				</fo:block>
24
				<fo:block>
25
					<fo:table>
26
						<fo:table-body>
27
							<fo:table-row>
28
								<fo:table-cell border-style="solid" border-width=".1mm"
29
									padding="1mm">
30
									<fo:block>
31
										<fo:block font-family="Arial, Helvetica, Symbol, sans-serif"
32
											font-size="11pt" space-before="3pt" space-after="0cm">aa</fo:block>
33
									</fo:block>
34
								</fo:table-cell>
35
								<fo:table-cell border-style="solid" border-width=".1mm"
36
									padding="1mm">
37
									<fo:block>
38
										<fo:block font-family="Arial, Helvetica, Symbol, sans-serif"
39
											font-size="11pt" space-before="3pt" space-after="0cm">bb</fo:block>
40
									</fo:block>
41
								</fo:table-cell>
42
								<fo:table-cell border-style="solid" border-width=".1mm"
43
									padding="1mm">
44
									<fo:block>
45
										<fo:block font-family="Arial, Helvetica, Symbol, sans-serif"
46
											font-size="11pt" space-before="3pt" space-after="0cm">cc</fo:block>
47
									</fo:block>
48
								</fo:table-cell>
49
								<fo:table-cell border-style="solid" border-width=".1mm"
50
									padding="1mm">
51
									<fo:block>
52
										<fo:block font-family="Arial, Helvetica, Symbol, sans-serif"
53
											font-size="11pt" space-before="3pt" space-after="0cm">dd</fo:block>
54
									</fo:block>
55
								</fo:table-cell>
56
							</fo:table-row>
57
							<fo:table-row>
58
								<fo:table-cell border-style="solid" border-width=".1mm"
59
									padding="1mm">
60
									<fo:block>
61
										<fo:block font-family="Arial, Helvetica, Symbol, sans-serif"
62
											font-size="11pt" white-space-collapse="true" text-align="justify"
63
											space-before="3pt" space-after="0cm">ff</fo:block>
64
									</fo:block>
65
								</fo:table-cell>
66
								<fo:table-cell border-style="solid" border-width=".1mm"
67
									padding="1mm">
68
									<fo:block>
69
										<fo:block font-family="Arial, Helvetica, Symbol, sans-serif"
70
											font-size="11pt" space-before="3pt" space-after="0cm">gg</fo:block>
71
									</fo:block>
72
								</fo:table-cell>
73
								<fo:table-cell border-style="solid" border-width=".1mm"
74
									padding="1mm">
75
									<fo:block>
76
										<fo:block font-family="Arial, Helvetica, Symbol, sans-serif"
77
											font-size="11pt" space-before="3pt" space-after="0cm">hh</fo:block>
78
									</fo:block>
79
								</fo:table-cell>
80
								<fo:table-cell border-style="solid" border-width=".1mm"
81
									padding="1mm">
82
									<fo:block>
83
										<fo:block font-family="Arial, Helvetica, Symbol, sans-serif"
84
											font-size="11pt" space-before="3pt" space-after="0cm">ii</fo:block>
85
									</fo:block>
86
								</fo:table-cell>
87
							</fo:table-row>
88
							<fo:table-row>
89
								<fo:table-cell border-style="solid" border-width=".1mm"
90
									padding="1mm">
91
									<fo:block>
92
										<fo:block font-family="Arial, Helvetica, Symbol, sans-serif"
93
											font-size="11pt" space-before="3pt" space-after="0cm">jj</fo:block>
94
									</fo:block>
95
								</fo:table-cell>
96
								<fo:table-cell border-style="solid" border-width=".1mm"
97
									padding="1mm" number-rows-spanned="2">
98
									<fo:block>
99
										<fo:block font-family="Arial, Helvetica, Symbol, sans-serif"
100
											font-size="11pt" space-before="3pt" space-after="0cm">kk</fo:block>
101
									</fo:block>
102
								</fo:table-cell>
103
								<fo:table-cell border-style="solid" border-width=".1mm"
104
									padding="1mm" number-columns-spanned="2">
105
									<fo:block />
106
								</fo:table-cell>
107
							</fo:table-row>
108
							<fo:table-row>
109
								<fo:table-cell border-style="solid" border-width=".1mm"
110
									padding="1mm">
111
									<fo:block />
112
								</fo:table-cell>
113
								<fo:table-cell border-style="solid" border-width=".1mm"
114
									padding="1mm">
115
									<fo:block />
116
								</fo:table-cell>
117
								<fo:table-cell border-style="solid" border-width=".1mm"
118
									padding="1mm">
119
									<fo:block />
120
								</fo:table-cell>
121
							</fo:table-row>
122
						</fo:table-body>
123
					</fo:table>
124
				</fo:block>
125
			</fo:block>
126
		</fo:flow>
127
	</fo:page-sequence>
128
</fo:root>
(-)test/odf/odt/fo_list_block/simple.fo (+53 lines)
Line 0 Link Here
1
<?xml version="1.0" encoding="utf-8"?>
2
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
3
	<fo:layout-master-set>
4
		<fo:simple-page-master master-name="simple"
5
			page-height="29.7cm" page-width="21cm" margin-top="1cm"
6
			margin-bottom="2cm" margin-left="2.5cm" margin-right="2.5cm">
7
			<fo:region-body margin-top="3cm" />
8
			<fo:region-before extent="3cm" />
9
			<fo:region-after extent="1.5cm" />
10
		</fo:simple-page-master>
11
	</fo:layout-master-set>
12
	<fo:page-sequence master-reference="simple">
13
		<fo:flow flow-name="xsl-region-body">
14
			<fo:block text-align="justify">
15
				<fo:block font-size="15pt">
16
					Joad rolled the coat up more tightly.
17
					"An old turtle," he said. "Picked
18
					him up on the
19
					road. An old
20
					bulldozer. Thought I'd take 'im to my little brother. Kids
21
					like
22
					turtles."
23
				</fo:block>
24
				<fo:list-block>
25
					<fo:list-item>
26
						<fo:list-item-label>
27
							<fo:block>•</fo:block>
28
						</fo:list-item-label>
29
						<fo:list-item-body>
30
							<fo:block>item1</fo:block>
31
						</fo:list-item-body>
32
					</fo:list-item>
33
					<fo:list-item>
34
						<fo:list-item-label>
35
							<fo:block>•</fo:block>
36
						</fo:list-item-label>
37
						<fo:list-item-body>
38
							<fo:block>item2</fo:block>
39
						</fo:list-item-body>
40
					</fo:list-item>
41
					<fo:list-item>
42
						<fo:list-item-label>
43
							<fo:block>•</fo:block>
44
						</fo:list-item-label>
45
						<fo:list-item-body>
46
							<fo:block>item3</fo:block>
47
						</fo:list-item-body>
48
					</fo:list-item>
49
				</fo:list-block>
50
			</fo:block>
51
		</fo:flow>
52
	</fo:page-sequence>
53
</fo:root>

Return to bug 53400