<?xml version="1.0" encoding="UTF-8"?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<!-- $Id$ -->
<testcase>
  <info>
    <p>
      This test checks backgrounds on table elements.
    </p>
  </info>
  <variables>
    <table>../resources/images/fop-logo-gray-8bit.png</table>
    <col>../resources/images/bgimg72dpi.jpg</col>
    <body>../resources/images/fop-logo-color-24bit.png</body>
    <row>../../examples/fo/graphics/asf-logo.png</row>
    <headFoot>../../examples/fo/graphics/asf-logo.png</headFoot>
    <header>../resources/images/box1.png</header>
  </variables>
  <fo>
    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
      <fo:layout-master-set>
        <fo:simple-page-master master-name="page" page-height="10in" page-width="5in" margin="0.5in">
          <fo:region-body/>
        </fo:simple-page-master>
      </fo:layout-master-set>

      <fo:page-sequence master-reference="page" font-size="8pt" line-height="10pt">
        <fo:flow flow-name="xsl-region-body">
          <fo:block space-after="10pt">Before the table.</fo:block>
          <fo:table width="100%" table-layout="fixed"
            border-collapse="separate" border-separation="4pt" padding="2pt"
            background-color="#F0F0F0" background-image="##table" background-repeat="no-repeat"
            background-position-horizontal="center" background-position-vertical="center"
            border="4pt solid black">
            <fo:table-column column-width="proportional-column-width(1)"
              background-color="yellow" background-image="##col" background-repeat="no-repeat"
              background-position-horizontal="center" background-position-vertical="center"/>
            <fo:table-column column-width="proportional-column-width(1)"
              background-image="##col" background-repeat="no-repeat"
              background-position-horizontal="center" background-position-vertical="center"/>
            <fo:table-header background-image="##headFoot" background-repeat="no-repeat"
              background-position-horizontal="center" background-position-vertical="center">
              <fo:table-cell border="2pt solid blue">
                <fo:block>Header 1.1</fo:block>
                <fo:block>Header 1.1</fo:block>
                <fo:block>Header 1.1</fo:block>
                <fo:block>Header 1.1</fo:block>
                <fo:block>Header 1.1</fo:block>
              </fo:table-cell>
              <fo:table-cell border="2pt solid blue" background-color="yellow"
                background-image="##header" background-repeat="no-repeat"
                background-position-horizontal="center" background-position-vertical="center">
                <fo:block>Header 1.2</fo:block>
                <fo:block>Header 1.2</fo:block>
                <fo:block>Header 1.2</fo:block>
                <fo:block>Header 1.2</fo:block>
                <fo:block>Header 1.2</fo:block>
              </fo:table-cell>
            </fo:table-header>
            <fo:table-footer background-image="##headFoot" background-repeat="no-repeat"
              background-position-horizontal="center" background-position-vertical="center">
              <fo:table-cell border="2pt solid blue">
                <fo:block>Footer 1.1</fo:block>
                <fo:block>Footer 1.1</fo:block>
              </fo:table-cell>
              <fo:table-cell border="2pt solid blue">
                <fo:block>Footer 1.2</fo:block>
                <fo:block>Footer 1.2</fo:block>
              </fo:table-cell>
            </fo:table-footer>
            <fo:table-body>
              <fo:table-row background-image="##row" background-repeat="no-repeat"
                background-position-horizontal="center" background-position-vertical="center">
                <fo:table-cell border="2pt solid red" number-rows-spanned="2">
                  <fo:block>Cell 1.1</fo:block>
                  <fo:block>Cell 1.1</fo:block>
                  <fo:block>Cell 1.1</fo:block>
                  <fo:block>Cell 1.1</fo:block>
                </fo:table-cell>
                <fo:table-cell color="orange">
                  <fo:block>Cell 1.2</fo:block>
                  <fo:block>Cell 1.2</fo:block>
                </fo:table-cell>
              </fo:table-row>
              <fo:table-row background-image="##row" background-repeat="no-repeat"
                background-position-horizontal="center" background-position-vertical="center">
                <fo:table-cell border="2pt solid red" color="orange">
                  <fo:block>Cell 2.2</fo:block>
                </fo:table-cell>
              </fo:table-row>
              <fo:table-row background-image="##row" background-repeat="no-repeat"
                background-position-horizontal="center" background-position-vertical="center">
                <fo:table-cell border="2pt solid red" number-columns-spanned="2">
                  <fo:block>Cell 3.1</fo:block>
                  <fo:block>Cell 3.1</fo:block>
                </fo:table-cell>
              </fo:table-row>
              <fo:table-row background-image="##row" background-repeat="no-repeat"
                background-position-horizontal="center" background-position-vertical="center">
                <fo:table-cell border="2pt solid red">
                  <fo:block>Cell 4.1</fo:block>
                  <fo:block>Cell 4.1</fo:block>
                </fo:table-cell>
                <fo:table-cell color="orange">
                  <fo:block>Cell 4.2</fo:block>
                </fo:table-cell>
              </fo:table-row>
            </fo:table-body>
            <fo:table-body background-image="##body" background-repeat="no-repeat"
              background-position-horizontal="center" background-position-vertical="center">
              <fo:table-row>
                <fo:table-cell border="2pt solid red" number-rows-spanned="2">
                  <fo:block>Cell 5.1</fo:block>
                  <fo:block>Cell 5.1</fo:block>
                  <fo:block>Cell 5.1</fo:block>
                  <fo:block>Cell 5.1</fo:block>
                  <fo:block>Cell 5.1 Line 5</fo:block>
                  <fo:block>Cell 5.1</fo:block>
                  <fo:block>Cell 5.1</fo:block>
                  <fo:block>Cell 5.1</fo:block>
                  <fo:block>Cell 5.1</fo:block>
                  <fo:block>Cell 5.1 Line 10</fo:block>
                  <fo:block>Cell 5.1</fo:block>
                </fo:table-cell>
                <fo:table-cell color="orange">
                  <fo:block>Cell 5.2</fo:block>
                  <fo:block>Cell 5.2</fo:block>
                  <fo:block>Cell 5.2</fo:block>
                  <fo:block>Cell 5.2</fo:block>
                </fo:table-cell>
              </fo:table-row>
              <fo:table-row>
                <fo:table-cell border="2pt solid red" color="orange">
                  <fo:block>Cell 6.2</fo:block>
                </fo:table-cell>
              </fo:table-row>
            </fo:table-body>
          </fo:table>
        </fo:flow>
      </fo:page-sequence>
    </fo:root>

  </fo>
  <checks>
    <!-- table background -->
    <eval expected="color=#f0f0f0,url=../resources/images/fop-logo-gray-8bit.png,repeat=no-repeat,horiz=53480,vertical=108960"
      xpath="//flow/block[2]/@background"/>

    <!-- column background, header 1.1 -->
    <eval expected="136000" xpath="//flow/block[2]/block[1]/@ipd"/>
    <eval expected="50000"  xpath="//flow/block[2]/block[1]/@bpd"/>
    <eval expected="4000"   xpath="//flow/block[2]/block[1]/@top-offset"/>
    <eval expected="4000"   xpath="//flow/block[2]/block[1]/@left-offset"/>
    <eval                   xpath="//flow/block[2]/block[1]/@background"
      expected="color=#ffff00,url=../resources/images/bgimg72dpi.jpg,repeat=no-repeat,horiz=-28000,vertical=54000"/>

    <!-- table-header background, header 1.1 -->
    <eval expected="136000" xpath="//flow/block[2]/block[2]/@ipd"/>
    <eval expected="50000"  xpath="//flow/block[2]/block[2]/@bpd"/>
    <eval expected="4000"   xpath="//flow/block[2]/block[2]/@top-offset"/>
    <eval expected="4000"   xpath="//flow/block[2]/block[2]/@left-offset"/>
    <eval                   xpath="//flow/block[2]/block[2]/@background"
      expected="url=../../examples/fo/graphics/asf-logo.png,repeat=no-repeat,horiz=76633,vertical=5877"/>


    <!-- column background, header 1.2 -->
    <eval expected="136000" xpath="//flow/block[2]/block[4]/@ipd"/>
    <eval expected="50000"  xpath="//flow/block[2]/block[4]/@bpd"/>
    <eval expected="4000"   xpath="//flow/block[2]/block[4]/@top-offset"/>
    <eval expected="148000" xpath="//flow/block[2]/block[4]/@left-offset"/>
    <eval                   xpath="//flow/block[2]/block[4]/@background"
      expected="url=../resources/images/bgimg72dpi.jpg,repeat=no-repeat,horiz=-28000,vertical=54000"/>

    <!-- table-header background, header 1.2 -->
    <eval expected="136000" xpath="//flow/block[2]/block[5]/@ipd"/>
    <eval expected="50000"  xpath="//flow/block[2]/block[5]/@bpd"/>
    <eval expected="4000"   xpath="//flow/block[2]/block[5]/@top-offset"/>
    <eval expected="148000" xpath="//flow/block[2]/block[5]/@left-offset"/>
    <eval                   xpath="//flow/block[2]/block[5]/@background"
      expected="url=../../examples/fo/graphics/asf-logo.png,repeat=no-repeat,horiz=-67367,vertical=5877"/>

    <!-- header 1.2 background -->
    <eval expected="136000" xpath="//flow/block[2]/block[6]/@ipd"/>
    <eval expected="50000"  xpath="//flow/block[2]/block[6]/@bpd"/>
    <eval expected="2000"   xpath="//flow/block[2]/block[6]/@top-offset"/>
    <eval expected="148000" xpath="//flow/block[2]/block[6]/@left-offset"/>
    <eval                   xpath="//flow/block[2]/block[6]/@background"
      expected="color=#ffff00,url=../resources/images/box1.png,repeat=no-repeat,horiz=47995,vertical=4995"/>


    <!-- column background, cell 1.2 -->
    <eval expected="140000" xpath="//flow/block[2]/block[7]/@ipd"/>
    <eval expected="20000"  xpath="//flow/block[2]/block[7]/@bpd"/>
    <eval expected="60000"  xpath="//flow/block[2]/block[7]/@top-offset"/>
    <eval expected="146000" xpath="//flow/block[2]/block[7]/@left-offset"/>
    <eval                   xpath="//flow/block[2]/block[7]/@background"
      expected="url=../resources/images/bgimg72dpi.jpg,repeat=no-repeat,horiz=-26000,vertical=-2000"/>

    <!-- table-row background, cell 1.2 -->
    <eval expected="140000" xpath="//flow/block[2]/block[8]/@ipd"/>
    <eval expected="20000"  xpath="//flow/block[2]/block[8]/@bpd"/>
    <eval expected="60000"  xpath="//flow/block[2]/block[8]/@top-offset"/>
    <eval expected="146000" xpath="//flow/block[2]/block[8]/@left-offset"/>
    <eval                   xpath="//flow/block[2]/block[8]/@background"
      expected="url=../../examples/fo/graphics/asf-logo.png,repeat=no-repeat,horiz=-65367,vertical=-9122"/>


    <!-- column background, cell 1.1 -->
    <eval expected="136000" xpath="//flow/block[2]/block[10]/@ipd"/>
    <eval expected="40000"  xpath="//flow/block[2]/block[10]/@bpd"/>
    <eval expected="62000"  xpath="//flow/block[2]/block[10]/@top-offset"/>
    <eval expected="4000"   xpath="//flow/block[2]/block[10]/@left-offset"/>
    <eval                   xpath="//flow/block[2]/block[10]/@background"
      expected="color=#ffff00,url=../resources/images/bgimg72dpi.jpg,repeat=no-repeat,horiz=-28000,vertical=-4000"/>

    <!-- table-row background, cell 1.1 -->
    <eval expected="136000" xpath="//flow/block[2]/block[11]/@ipd"/>
    <eval expected="40000"  xpath="//flow/block[2]/block[11]/@bpd"/>
    <eval expected="62000"  xpath="//flow/block[2]/block[11]/@top-offset"/>
    <eval expected="4000"   xpath="//flow/block[2]/block[11]/@left-offset"/>
    <eval                   xpath="//flow/block[2]/block[11]/@background"
      expected="url=../../examples/fo/graphics/asf-logo.png,repeat=no-repeat,horiz=76633,vertical=-11122"/>


    <!-- column background, cell 2.2 -->
    <eval expected="136000" xpath="//flow/block[2]/block[13]/@ipd"/>
    <eval expected="16000"  xpath="//flow/block[2]/block[13]/@bpd"/>
    <eval expected="86000"  xpath="//flow/block[2]/block[13]/@top-offset"/>
    <eval expected="148000" xpath="//flow/block[2]/block[13]/@left-offset"/>
    <eval                   xpath="//flow/block[2]/block[13]/@background"
      expected="url=../resources/images/bgimg72dpi.jpg,repeat=no-repeat,horiz=-28000,vertical=-28000"/>

    <!-- table-row background, cell 2.2 -->
    <eval expected="136000" xpath="//flow/block[2]/block[14]/@ipd"/>
    <eval expected="16000"  xpath="//flow/block[2]/block[14]/@bpd"/>
    <eval expected="86000"  xpath="//flow/block[2]/block[14]/@top-offset"/>
    <eval expected="148000" xpath="//flow/block[2]/block[14]/@left-offset"/>
    <eval                   xpath="//flow/block[2]/block[14]/@background"
      expected="url=../../examples/fo/graphics/asf-logo.png,repeat=no-repeat,horiz=-67367,vertical=-11122"/>


    <!-- column background, cell 3.1 -->
    <eval expected="280000" xpath="//flow/block[2]/block[16]/@ipd"/>
    <eval expected="20000"  xpath="//flow/block[2]/block[16]/@bpd"/>
    <eval expected="110000" xpath="//flow/block[2]/block[16]/@top-offset"/>
    <eval expected="4000"   xpath="//flow/block[2]/block[16]/@left-offset"/>
    <eval                   xpath="//flow/block[2]/block[16]/@background"
      expected="color=#ffff00,url=../resources/images/bgimg72dpi.jpg,repeat=no-repeat,horiz=-28000,vertical=-52000"/>

    <!-- table-row background, cell 3.1 -->
    <eval expected="280000" xpath="//flow/block[2]/block[17]/@ipd"/>
    <eval expected="20000"  xpath="//flow/block[2]/block[17]/@bpd"/>
    <eval expected="110000" xpath="//flow/block[2]/block[17]/@top-offset"/>
    <eval expected="4000"   xpath="//flow/block[2]/block[17]/@left-offset"/>
    <eval                   xpath="//flow/block[2]/block[17]/@background"
      expected="url=../../examples/fo/graphics/asf-logo.png,repeat=no-repeat,horiz=76633,vertical=-9122"/>


    <!-- column background, cell 4.1 -->
    <eval expected="136000" xpath="//flow/block[2]/block[19]/@ipd"/>
    <eval expected="20000"  xpath="//flow/block[2]/block[19]/@bpd"/>
    <eval expected="138000" xpath="//flow/block[2]/block[19]/@top-offset"/>
    <eval expected="4000"   xpath="//flow/block[2]/block[19]/@left-offset"/>
    <eval                   xpath="//flow/block[2]/block[19]/@background"
      expected="color=#ffff00,url=../resources/images/bgimg72dpi.jpg,repeat=no-repeat,horiz=-28000,vertical=-80000"/>

    <!-- table-row background, cell 4.1 -->
    <eval expected="136000" xpath="//flow/block[2]/block[20]/@ipd"/>
    <eval expected="20000"  xpath="//flow/block[2]/block[20]/@bpd"/>
    <eval expected="138000" xpath="//flow/block[2]/block[20]/@top-offset"/>
    <eval expected="4000"   xpath="//flow/block[2]/block[20]/@left-offset"/>
    <eval                   xpath="//flow/block[2]/block[20]/@background"
      expected="url=../../examples/fo/graphics/asf-logo.png,repeat=no-repeat,horiz=76633,vertical=-9122"/>


    <!-- column background, cell 4.2 -->
    <eval expected="140000" xpath="//flow/block[2]/block[22]/@ipd"/>
    <eval expected="24000"  xpath="//flow/block[2]/block[22]/@bpd"/>
    <eval expected="136000" xpath="//flow/block[2]/block[22]/@top-offset"/>
    <eval expected="146000" xpath="//flow/block[2]/block[22]/@left-offset"/>
    <eval                   xpath="//flow/block[2]/block[22]/@background"
      expected="url=../resources/images/bgimg72dpi.jpg,repeat=no-repeat,horiz=-26000,vertical=-78000"/>

    <!-- table-row background, cell 4.2 -->
    <eval expected="140000" xpath="//flow/block[2]/block[23]/@ipd"/>
    <eval expected="24000"  xpath="//flow/block[2]/block[23]/@bpd"/>
    <eval expected="136000" xpath="//flow/block[2]/block[23]/@top-offset"/>
    <eval expected="146000" xpath="//flow/block[2]/block[23]/@left-offset"/>
    <eval                   xpath="//flow/block[2]/block[23]/@background"
      expected="url=../../examples/fo/graphics/asf-logo.png,repeat=no-repeat,horiz=-65367,vertical=-7122"/>


    <!-- column background, cell 5.2 -->
    <eval expected="140000" xpath="//flow/block[2]/block[25]/@ipd"/>
    <eval expected="40000"  xpath="//flow/block[2]/block[25]/@bpd"/>
    <eval expected="164000" xpath="//flow/block[2]/block[25]/@top-offset"/>
    <eval expected="146000" xpath="//flow/block[2]/block[25]/@left-offset"/>
    <eval                   xpath="//flow/block[2]/block[25]/@background"
      expected="url=../resources/images/bgimg72dpi.jpg,repeat=no-repeat,horiz=-26000,vertical=-106000"/>

    <!-- table-body background, cell 5.2 -->
    <eval expected="140000" xpath="//flow/block[2]/block[26]/@ipd"/>
    <eval expected="40000"  xpath="//flow/block[2]/block[26]/@bpd"/>
    <eval expected="164000" xpath="//flow/block[2]/block[26]/@top-offset"/>
    <eval expected="146000" xpath="//flow/block[2]/block[26]/@left-offset"/>
    <eval                   xpath="//flow/block[2]/block[26]/@background"
      expected="url=../resources/images/fop-logo-color-24bit.png,repeat=no-repeat,horiz=-94513,vertical=9964"/>


    <!-- column background, cell 5.1 -->
    <eval expected="136000" xpath="//flow/block[2]/block[28]/@ipd"/>
    <eval expected="110000" xpath="//flow/block[2]/block[28]/@bpd"/>
    <eval expected="166000" xpath="//flow/block[2]/block[28]/@top-offset"/>
    <eval expected="4000"   xpath="//flow/block[2]/block[28]/@left-offset"/>
    <eval                   xpath="//flow/block[2]/block[28]/@background"
      expected="color=#ffff00,url=../resources/images/bgimg72dpi.jpg,repeat=no-repeat,horiz=-28000,vertical=-108000"/>

    <!-- table-body background, cell 5.1 -->
    <eval expected="136000" xpath="//flow/block[2]/block[29]/@ipd"/>
    <eval expected="110000" xpath="//flow/block[2]/block[29]/@bpd"/>
    <eval expected="166000" xpath="//flow/block[2]/block[29]/@top-offset"/>
    <eval expected="4000"   xpath="//flow/block[2]/block[29]/@left-offset"/>
    <eval                   xpath="//flow/block[2]/block[29]/@background"
      expected="url=../resources/images/fop-logo-color-24bit.png,repeat=no-repeat,horiz=47487,vertical=7964"/>


    <!-- column background, cell 6.2 -->
    <eval expected="136000" xpath="//flow/block[2]/block[31]/@ipd"/>
    <eval expected="66000"  xpath="//flow/block[2]/block[31]/@bpd"/>
    <eval expected="210000" xpath="//flow/block[2]/block[31]/@top-offset"/>
    <eval expected="148000" xpath="//flow/block[2]/block[31]/@left-offset"/>
    <eval                   xpath="//flow/block[2]/block[31]/@background"
      expected="url=../resources/images/bgimg72dpi.jpg,repeat=no-repeat,horiz=-28000,vertical=-152000"/>

    <!-- table-body background, cell 6.2 -->
    <eval expected="136000" xpath="//flow/block[2]/block[32]/@ipd"/>
    <eval expected="66000"  xpath="//flow/block[2]/block[32]/@bpd"/>
    <eval expected="210000" xpath="//flow/block[2]/block[32]/@top-offset"/>
    <eval expected="148000" xpath="//flow/block[2]/block[32]/@left-offset"/>
    <eval                   xpath="//flow/block[2]/block[32]/@background"
      expected="url=../resources/images/fop-logo-color-24bit.png,repeat=no-repeat,horiz=-96513,vertical=-36036"/>


    <!-- column background, footer 1.1 -->
    <eval expected="136000" xpath="//flow/block[2]/block[34]/@ipd"/>
    <eval expected="20000"  xpath="//flow/block[2]/block[34]/@bpd"/>
    <eval expected="284000" xpath="//flow/block[2]/block[34]/@top-offset"/>
    <eval expected="4000"   xpath="//flow/block[2]/block[34]/@left-offset"/>
    <eval                   xpath="//flow/block[2]/block[34]/@background"
      expected="color=#ffff00,url=../resources/images/bgimg72dpi.jpg,repeat=no-repeat,horiz=-28000,vertical=-226000"/>

    <!-- table-footer background, footer 1.1 -->
    <eval expected="136000" xpath="//flow/block[2]/block[35]/@ipd"/>
    <eval expected="20000"  xpath="//flow/block[2]/block[35]/@bpd"/>
    <eval expected="284000" xpath="//flow/block[2]/block[35]/@top-offset"/>
    <eval expected="4000"   xpath="//flow/block[2]/block[35]/@left-offset"/>
    <eval                   xpath="//flow/block[2]/block[35]/@background"
      expected="url=../../examples/fo/graphics/asf-logo.png,repeat=no-repeat,horiz=76633,vertical=-9122"/>


    <!-- column background, footer 1.2 -->
    <eval expected="136000" xpath="//flow/block[2]/block[37]/@ipd"/>
    <eval expected="20000"  xpath="//flow/block[2]/block[37]/@bpd"/>
    <eval expected="284000" xpath="//flow/block[2]/block[37]/@top-offset"/>
    <eval expected="148000" xpath="//flow/block[2]/block[37]/@left-offset"/>
    <eval                   xpath="//flow/block[2]/block[37]/@background"
      expected="url=../resources/images/bgimg72dpi.jpg,repeat=no-repeat,horiz=-28000,vertical=-226000"/>

    <!-- table-footer background, footer 1.2 -->
    <eval expected="136000" xpath="//flow/block[2]/block[38]/@ipd"/>
    <eval expected="20000"  xpath="//flow/block[2]/block[38]/@bpd"/>
    <eval expected="284000" xpath="//flow/block[2]/block[38]/@top-offset"/>
    <eval expected="148000" xpath="//flow/block[2]/block[38]/@left-offset"/>
    <eval                   xpath="//flow/block[2]/block[38]/@background"
      expected="url=../../examples/fo/graphics/asf-logo.png,repeat=no-repeat,horiz=-67367,vertical=-9122"/>

  </checks>
</testcase>
