You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by je...@apache.org on 2005/06/21 15:10:36 UTC

cvs commit: xml-fop/test/layoutengine/testcases normal-breaking5.xml

jeremias    2005/06/21 06:10:36

  Modified:    test/layoutengine disabled-testcases.txt
  Added:       test/layoutengine/testcases normal-breaking5.xml
  Log:
  In page breaking, content that doesn't fit, should move to the next page even if that means creating empty pages.
  
  Revision  Changes    Path
  1.30      +1 -0      xml-fop/test/layoutengine/disabled-testcases.txt
  
  Index: disabled-testcases.txt
  ===================================================================
  RCS file: /home/cvs/xml-fop/test/layoutengine/disabled-testcases.txt,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- disabled-testcases.txt	21 Jun 2005 12:04:12 -0000	1.29
  +++ disabled-testcases.txt	21 Jun 2005 13:10:36 -0000	1.30
  @@ -7,6 +7,7 @@
   keep-with-previous5.xml
   multi-column1.xml
   normal-breaking4.xml
  +normal-breaking5.xml
   table-border-collapse1.xml
   table-border-collapse2.xml
   table-fixed2.xml
  
  
  
  1.1                  xml-fop/test/layoutengine/testcases/normal-breaking5.xml
  
  Index: normal-breaking5.xml
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <!--
    Copyright 2005 The Apache Software Foundation
  
    Licensed 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: normal-breaking5.xml,v 1.1 2005/06/21 13:10:36 jeremias Exp $ -->
  <testcase>
    <info>
      <p>
        This test checks normal breaking. It checks whether elements that don't fit on a 
        page are sent over to the next if that one has more room (indirectly checks 
        changing available BPD, too).
      </p>
    </info>
    <fo>
      <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" widows="0" orphans="0">
        <fo:layout-master-set>
          <fo:simple-page-master master-name="short" page-height="30pt" page-width="120pt">
            <fo:region-body/>
          </fo:simple-page-master>
          <fo:simple-page-master master-name="long" page-height="100pt" page-width="120pt">
            <fo:region-body/>
          </fo:simple-page-master>
          <fo:page-sequence-master master-name="master">
            <fo:single-page-master-reference master-reference="long"/>
            <fo:single-page-master-reference master-reference="short"/>
            <fo:single-page-master-reference master-reference="long"/>
          </fo:page-sequence-master>
        </fo:layout-master-set>
        <fo:page-sequence master-reference="master">
          <fo:flow flow-name="xsl-region-body">
            <fo:block background-color="orange" keep-together="always">Apache FOP is a great tool to create PDF documents with.</fo:block>
            <fo:block background-color="orange" keep-together="always">Apache FOP is a great tool to create PDF documents with.</fo:block>
            <fo:block background-color="orange" keep-together="always">Apache FOP is a great tool to create PDF documents with.</fo:block>
            <fo:block background-color="orange" keep-together="always">Apache FOP is a great tool to create PDF documents with.</fo:block>
            <fo:block background-color="yellow">last line in new block</fo:block>
          </fo:flow>
        </fo:page-sequence>
      </fo:root>
    </fo>
    <checks>
      <eval expected="4" xpath="count(//pageViewport)"/>
      
      <eval expected="6" xpath="sum(//pageViewport[@nr=1]/page/regionViewport/regionBody/mainReference/span/flow/block/@bpda) div 14400"/>
      <!-- the second page should be empty since the third block doesn't fit into that page with only 30pt BPD -->
      <eval expected="0" xpath="sum(//pageViewport[@nr=2]/page/regionViewport/regionBody/mainReference/span/flow/block/@bpda) div 14400"/>"/>
      <eval expected="6" xpath="sum(//pageViewport[@nr=3]/page/regionViewport/regionBody/mainReference/span/flow/block/@bpda) div 14400"/>"/>
      <eval expected="1" xpath="sum(//pageViewport[@nr=4]/page/regionViewport/regionBody/mainReference/span/flow/block/@bpda) div 14400"/>"/>
    </checks>
  </testcase>
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org


Re: cvs commit: xml-fop/test/layoutengine/testcases normal-breaking5.xml

Posted by Jeremias Maerki <de...@greenmail.ch>.
Luca,

your pointers were 100% on target! It took a few other things around
that but the issue seems to be fixed now.

If you look at the code, you can see that this functionality could
theoretically also be useful for line-breaking. Especially when we have
side floats some day this could be very useful to avoid text to overflow
into the side-flow. Even today, there are some constellations where this
behaviour would make sense. But I think we'd need some additional code
to handle every situation properly. For the moment, I've disabled the
"part overflow recovery" (for lack of a better description) for line
breaking.

I've also disabled it for side region layout and block-containers since
we want the overflow in these areas. Parts n > 0 will just be dropped
anyway.

Thanks for your help.

On 22.06.2005 14:42:42 Luca Furini wrote:
> Jeremias Maerki wrote:
> 
> > Before I waste a lot of time trying to figure out how I should fix that,
> > I thought I'd just drop in a test case. Luca, for you it's probably very
> > easy to say at which point I should hook in to create pages with empty
> > content so the non-fitting content is simply pushed to the next page. In
> > the end, that "pushing-loop" need an upper limit (like 50 iterations or
> > so) after which it throws a layout exception complaining about too
> > little room to place content (This check used to be in FlowLM [1]). I'm
> > somewhat stuck in PageBreakingAlgorithm.removeNode(). Intuitively, I'd
> > say I'd have to create a new KnuthNode that somehow results in an empty
> > page or something like that.
> 
> At the moment, the test fails because the algorithm stops and restarts 
> from lastTooLong (a page break involving content overflow), so I think 
> that the right point could be BreakingAlgorithm.findBreakingPoints() 
> at line #368.
> 
> Instead of using lastTooLong, a node representing an empty page should be 
> created and lastForced should be made equal to that new node.
> 
> I did not try if this works, but here is my idea to do that:
> 
> - lastTooLong would create a page whose content overflows, so the last
>    "good" break poing is lastTooLong.previous
> - create a new node whose .position is lastTooLong.previous.position,
>    .line is lastTooLong.previous.line + 1, .previous is
>    lastTooLong.previous (the other values could be 0, I think)
> - this could be the node representing an empty page, from which the
>    algorithm can restart
> 
> > BTW, Luca, I haven't forgotten your post about keep-with-previous in
> > tables. Thank you for that one. ATM I'm swimming in another lake trying
> > to remain on top. :-)
> 
> I know that kind of situation ... :-)
> 
> Regards
>      Luca



Jeremias Maerki


Re: cvs commit: xml-fop/test/layoutengine/testcases normal-breaking5.xml

Posted by Jeremias Maerki <de...@greenmail.ch>.
Before I waste a lot of time trying to figure out how I should fix that,
I thought I'd just drop in a test case. Luca, for you it's probably very
easy to say at which point I should hook in to create pages with empty
content so the non-fitting content is simply pushed to the next page. In
the end, that "pushing-loop" need an upper limit (like 50 iterations or
so) after which it throws a layout exception complaining about too
little room to place content (This check used to be in FlowLM [1]). I'm
somewhat stuck in PageBreakingAlgorithm.removeNode(). Intuitively, I'd
say I'd have to create a new KnuthNode that somehow results in an empty
page or something like that.

BTW, Luca, I haven't forgotten your post about keep-with-previous in
tables. Thank you for that one. ATM I'm swimming in another lake trying
to remain on top. :-)

[1] http://cvs.apache.org/viewcvs.cgi/xml-fop/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java?r1=1.9&r2=1.10&diff_format=h

On 21.06.2005 15:10:36 jeremias wrote:
> jeremias    2005/06/21 06:10:36
> 
>   Modified:    test/layoutengine disabled-testcases.txt
>   Added:       test/layoutengine/testcases normal-breaking5.xml
>   Log:
>   In page breaking, content that doesn't fit, should move to the next page even if that means creating empty pages.

<snip/>

>   <testcase>
>     <info>
>       <p>
>         This test checks normal breaking. It checks whether elements that don't fit on a 
>         page are sent over to the next if that one has more room (indirectly checks 
>         changing available BPD, too).
>       </p>
>     </info>
>     <fo>
>       <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" widows="0" orphans="0">
>         <fo:layout-master-set>
>           <fo:simple-page-master master-name="short" page-height="30pt" page-width="120pt">
>             <fo:region-body/>
>           </fo:simple-page-master>
>           <fo:simple-page-master master-name="long" page-height="100pt" page-width="120pt">
>             <fo:region-body/>
>           </fo:simple-page-master>
>           <fo:page-sequence-master master-name="master">
>             <fo:single-page-master-reference master-reference="long"/>
>             <fo:single-page-master-reference master-reference="short"/>
>             <fo:single-page-master-reference master-reference="long"/>
>           </fo:page-sequence-master>
>         </fo:layout-master-set>
>         <fo:page-sequence master-reference="master">
>           <fo:flow flow-name="xsl-region-body">
>             <fo:block background-color="orange" keep-together="always">Apache FOP is a great tool to create PDF documents with.</fo:block>
>             <fo:block background-color="orange" keep-together="always">Apache FOP is a great tool to create PDF documents with.</fo:block>
>             <fo:block background-color="orange" keep-together="always">Apache FOP is a great tool to create PDF documents with.</fo:block>
>             <fo:block background-color="orange" keep-together="always">Apache FOP is a great tool to create PDF documents with.</fo:block>
>             <fo:block background-color="yellow">last line in new block</fo:block>
>           </fo:flow>
>         </fo:page-sequence>
>       </fo:root>
>     </fo>
>     <checks>
>       <eval expected="4" xpath="count(//pageViewport)"/>
>       
>       <eval expected="6" xpath="sum(//pageViewport[@nr=1]/page/regionViewport/regionBody/mainReference/span/flow/block/@bpda) div 14400"/>
>       <!-- the second page should be empty since the third block doesn't fit into that page with only 30pt BPD -->
>       <eval expected="0" xpath="sum(//pageViewport[@nr=2]/page/regionViewport/regionBody/mainReference/span/flow/block/@bpda) div 14400"/>"/>
>       <eval expected="6" xpath="sum(//pageViewport[@nr=3]/page/regionViewport/regionBody/mainReference/span/flow/block/@bpda) div 14400"/>"/>
>       <eval expected="1" xpath="sum(//pageViewport[@nr=4]/page/regionViewport/regionBody/mainReference/span/flow/block/@bpda) div 14400"/>"/>
>     </checks>
>   </testcase>

Jeremias Maerki