Re: cvs commit: xml-fop/src/java/org/apache/fop/layoutmgr LineLayoutManager.java

2004-10-25 Thread Jeremias Maerki
That's exactly why we need a good regression test facility. I apologize
for not being more thorough. I'll probably have time on Thursday to look
into it if noone beats me to it. 

I also thought about reusing the static areas but as soon as there are
things like the page number or another reference, things get complicated.
I don't think it's worth the trouble to write code that can detect if a
static area is invariable.

On 25.10.2004 17:47:09 Luca Furini wrote:
 Jeremias Maerki wrote:
 
  jeremias2004/10/10 04:21:29
 
Modified:src/java/org/apache/fop/layoutmgr LineLayoutManager.java
Log:
This is supposed to fix a problem that surfaced with Finn's latest
  change in PageSequence. There was an ArrayIndexOutOfBoundsException here in
  LineLayoutManager when a static region was layouted for the second page
  (instance is reused). It seems to me that iCurrParIndex could be made a
  method-local variable instead of an instance variable.
 
 It took me a while to notice that these changes cause another problem for
 blocks containing preserved linefeeds and whose lines are parted on
 different pages. For these blocks, the array named knuthParagraphs has
 more than one element (the block will generate more than one paragraph)
 and the method LineLM.addAreas() is called more than once, so it isn't
 always right to set iCurrParIndex to 0. I'm attaching a fo file showing
 this problem.
 
 So, iCurrParIndex must be set to 0 in addAreas only for LineLM descendant
 of a StaticContentLM.
 But maybe it isn't necessary to call addAreas more than once for static
 content: as the static content is repeated on each page, wouldn't it be
 better to store the static area sub-tree and re-use it?


Jeremias Maerki



cvs commit: xml-fop/src/java/org/apache/fop/layoutmgr LineLayoutManager.java TextLayoutManager.java

2004-04-02 Thread cbowditch
cbowditch2004/04/02 02:38:29

  Modified:src/java/org/apache/fop/layoutmgr LineLayoutManager.java
TextLayoutManager.java
  Log:
  Applied Luca Furini's patch from bugzilla entry 28130.
  Corrections to space adjustment for text justification
  
  Revision  ChangesPath
  1.17  +6 -3  xml-fop/src/java/org/apache/fop/layoutmgr/LineLayoutManager.java
  
  Index: LineLayoutManager.java
  ===
  RCS file: 
/home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/LineLayoutManager.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- LineLayoutManager.java21 Mar 2004 12:03:08 -  1.16
  +++ LineLayoutManager.java2 Apr 2004 10:38:29 -   1.17
  @@ -566,7 +566,7 @@
   realWidth = targetWith;
   } else {
   ipdAdjust = -1;
  -realWidth = actual.max;
  +realWidth = actual.min;
   }
   } else {
   if (targetWith - actual.opt  actual.max - actual.opt) {
  @@ -575,7 +575,7 @@
   realWidth = targetWith;
   } else {
   ipdAdjust = 1;
  -realWidth = actual.min;
  +realWidth = actual.max;
   }
   }
   
  @@ -586,7 +586,7 @@
   switch (textalign) {
   case TextAlign.JUSTIFY:
   if (realWidth != 0) {
  -dAdjust = (targetWith - realWidth) / realWidth;
  +dAdjust = (double)(targetWith - realWidth) / realWidth;
   }
   break;
   case TextAlign.START:
  @@ -601,6 +601,9 @@
   indent = targetWith - realWidth;
   break;
   }
  +//System.err.println( );
  +//System.err.println(LineLayoutManager difference to fill=  + 
(targetWith - realWidth));
  +//System.err.println(LineLayoutManager ipdAdjust=  + ipdAdjust +  
dAdjust=  + dAdjust);
   
   LineBreakPosition lbp;
   lbp = new LineBreakPosition(this,
  
  
  
  1.13  +12 -15xml-fop/src/java/org/apache/fop/layoutmgr/TextLayoutManager.java
  
  Index: TextLayoutManager.java
  ===
  RCS file: 
/home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/TextLayoutManager.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- TextLayoutManager.java17 Mar 2004 03:37:32 -  1.12
  +++ TextLayoutManager.java2 Apr 2004 10:38:29 -   1.13
  @@ -466,23 +466,19 @@
   return;
   }
   // Calculate total adjustment
  +int iRealWidth = ai.ipdArea.opt;
   int iAdjust = 0;
  +double dIPDAdjust = context.getIPDAdjust();
   double dSpaceAdjust = context.getSpaceAdjust();
  -if (dSpaceAdjust  0.0) {
  -// Stretch by factor
  -// System.err.println(Potential stretch =  +
  -//(ai.ipdArea.max - ai.ipdArea.opt));
  -iAdjust = (int)((double)(ai.ipdArea.max
  - - ai.ipdArea.opt) * dSpaceAdjust);
  -} else if (dSpaceAdjust  0.0) {
  -// Shrink by factor
  -// System.err.println(Potential shrink =  +
  -//(ai.ipdArea.opt - ai.ipdArea.min));
  -iAdjust = (int)((double)(ai.ipdArea.opt
  - - ai.ipdArea.min) * dSpaceAdjust);
  +if (dIPDAdjust  0.0) {
  +iRealWidth += (int)((double)(ai.ipdArea.max - ai.ipdArea.opt) * 
dIPDAdjust);
   }
  -//System.err.println(\nText adjustment factor =  + dSpaceAdjust +
  -//   total= + iAdjust + ; breakIndex =  + ai.iBreakIndex);
  +else {
  +iRealWidth += (int)((double)(ai.ipdArea.opt - ai.ipdArea.min) * 
dIPDAdjust);
  +}
  +iAdjust = (int)((double)(iRealWidth * dSpaceAdjust));
  +//System.err.println( );
  +//System.err.println(TextLayoutManager recreated difference to fill=  + 
iAdjust);
   
   // Make an area containing all characters between start and end.
   InlineArea word = null;
  @@ -498,12 +494,13 @@
   word = new Space();
   word.setWidth(ai.ipdArea.opt + iAdjust);
   } else  {
  -TextArea t = createTextArea(str, ai.ipdArea.opt + iAdjust, 
  +TextArea t = createTextArea(str, iRealWidth + iAdjust, 
   context.getBaseline());
   if (iWScount  0) {
   //getLogger().error(Adjustment per word-space=  +
   //   iAdjust / iWScount);
   t.setTSadjust(iAdjust / iWScount);
  +//System.err.println(TextLayoutManager word spaces=  + iWScount 
+  adjustment per word space=  + 

cvs commit: xml-fop/src/java/org/apache/fop/layoutmgr LineLayoutManager.java

2004-02-05 Thread bckfnn
bckfnn  2004/02/05 09:59:31

  Modified:src/java/org/apache/fop/layoutmgr LineLayoutManager.java
  Log:
  Support for text-indent.
  
  Revision  ChangesPath
  1.12  +7 -1  xml-fop/src/java/org/apache/fop/layoutmgr/LineLayoutManager.java
  
  Index: LineLayoutManager.java
  ===
  RCS file: 
/home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/LineLayoutManager.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- LineLayoutManager.java17 Jan 2004 19:29:46 -  1.11
  +++ LineLayoutManager.java5 Feb 2004 17:59:30 -   1.12
  @@ -178,6 +178,10 @@
   clearPrevIPD();
   int iPrevLineEnd = vecInlineBreaks.size();
   
  +// Adjust available line length by text-indent. 
  +if (iPrevLineEnd == 0  bTextAlignment == TextAlign.START) {
  +availIPD.subtract(new MinOptMax(iTextIndent));
  +}
   prevBP = null;
   
   while ((curLM = getChildLM()) != null) {
  @@ -618,7 +622,9 @@
   }
   break;
   case TextAlign.START:
  -//indent = 0;
  +if (prevLineEnd == 0) {
  +indent = iTextIndent;
  +}
   break;
   case TextAlign.CENTER:
   indent = (targetWith - realWidth) / 2;
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: xml-fop/src/java/org/apache/fop/layoutmgr LineLayoutManager.java

2003-12-27 Thread gmazza
gmazza  2003/12/27 13:03:34

  Modified:src/java/org/apache/fop/layoutmgr LineLayoutManager.java
  Log:
  Bug 25756 (Patch by Simon Pepping):  Remove line BPs where line consists
  only of suppressible content (whitespace).
  
  Revision  ChangesPath
  1.9   +36 -1 xml-fop/src/java/org/apache/fop/layoutmgr/LineLayoutManager.java
  
  Index: LineLayoutManager.java
  ===
  RCS file: 
/home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/LineLayoutManager.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- LineLayoutManager.java23 Dec 2003 20:41:58 -  1.8
  +++ LineLayoutManager.java27 Dec 2003 21:03:34 -  1.9
  @@ -325,7 +325,15 @@
   return null;
   }
   if (prevBP == null) {
  -prevBP = bp;
  +BreakPoss prevLineEnd = (iPrevLineEnd == 0)
  +? null
  +: (BreakPoss) vecInlineBreaks.get(iPrevLineEnd);
  +if (allAreSuppressible(prevLineEnd)) {
  +removeAllBP(prevLineEnd);
  +return null;
  +} else {
  +prevBP = bp;
  +}
   }
   
   // Choose the best break
  @@ -419,6 +427,33 @@
   if (!couldEndLine || bp == prev) break;
   }
   return couldEndLine;
  +}
  +
  +/** Test whether all breakposs in vecInlineBreaks
  +back to and excluding prev are suppressible */
  +private boolean allAreSuppressible(BreakPoss prev) {
  +ListIterator bpIter =
  +vecInlineBreaks.listIterator(vecInlineBreaks.size());
  +boolean allAreSuppressible = true;
  +BreakPoss bp;
  +while (bpIter.hasPrevious()
  +(bp = (BreakPoss) bpIter.previous()) != prev
  +(allAreSuppressible = bp.isSuppressible())) {
  +}
  +return allAreSuppressible;
  +}
  +
  +/** Remove all BPs from the end back to and excluding prev
  +from vecInlineBreaks*/
  +private void removeAllBP(BreakPoss prev) {
  +int iPrev;
  +if (prev == null) {
  +vecInlineBreaks.clear();
  +} else if ((iPrev = vecInlineBreaks.indexOf(prev)) != -1) {
  +for (int i = vecInlineBreaks.size(); iPrev  i; --i) {
  +vecInlineBreaks.remove(i);
  +}
  +}
   }
   
   private HyphContext getHyphenContext(BreakPoss prev,
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: xml-fop/src/java/org/apache/fop/layoutmgr LineLayoutManager.java

2003-12-23 Thread gmazza
gmazza  2003/12/23 12:41:58

  Modified:src/java/org/apache/fop/layoutmgr LineLayoutManager.java
  Log:
  Bug #25031 -- patch in calculation of line breakpoints, by Simon Pepping (spepping 
at leverkruid dot nl)
  
  Revision  ChangesPath
  1.8   +12 -1 xml-fop/src/java/org/apache/fop/layoutmgr/LineLayoutManager.java
  
  Index: LineLayoutManager.java
  ===
  RCS file: 
/home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/LineLayoutManager.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- LineLayoutManager.java15 Dec 2003 22:39:01 -  1.7
  +++ LineLayoutManager.java23 Dec 2003 20:41:58 -  1.8
  @@ -242,6 +242,10 @@
   // If we are already in a hyphenation loop, then stop.
   
   if (inlineLC.tryHyphenate()) {
  +if (prevBP == null) {
  +vecInlineBreaks.add(bp);
  +prevBP = bp;
  +}
   break;
   }
   // Otherwise, prepare to try hyphenation
  @@ -254,6 +258,10 @@
   inlineLC.setHyphContext(
 getHyphenContext((prevBP == null) ? prev : prevBP, bp));
   if (inlineLC.getHyphContext() == null) {
  +if (prevBP == null) {
  +vecInlineBreaks.add(bp);
  +prevBP = bp;
  +}
   break;
   }
   inlineLC.setFlags(LayoutContext.TRY_HYPHENATE,
  @@ -264,6 +272,10 @@
   /* If we are not in justified text, we can end the line at
* prevBP.
*/
  +if (prevBP == null) {
  +vecInlineBreaks.add(bp);
  +prevBP = bp;
  +}
   break;
   }
   } else {
  @@ -313,7 +325,6 @@
   return null;
   }
   if (prevBP == null) {
  -vecInlineBreaks.add(bp);
   prevBP = bp;
   }
   
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: xml-fop/src/java/org/apache/fop/layoutmgr LineLayoutManager.java

2003-12-15 Thread gmazza
gmazza  2003/12/15 14:39:01

  Modified:src/java/org/apache/fop/layoutmgr LineLayoutManager.java
  Log:
  Hyphenation/Quotation problem fixed (quoted strings not breaking properly.)
  Patch #25512 by Simon Pepping (spepping at leverkruid dot nl).
  
  Revision  ChangesPath
  1.7   +15 -1 xml-fop/src/java/org/apache/fop/layoutmgr/LineLayoutManager.java
  
  Index: LineLayoutManager.java
  ===
  RCS file: 
/home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/LineLayoutManager.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- LineLayoutManager.java1 Dec 2003 04:47:00 -   1.6
  +++ LineLayoutManager.java15 Dec 2003 22:39:01 -  1.7
  @@ -322,7 +322,7 @@
   prevBP = getBestBP(vecPossEnd);
   }
   // Backup child LM if necessary
  -if (bp != prevBP  !prevBP.couldEndLine()) {
  +if (bp != prevBP  !prevCouldEndLine(prevBP)) {
   reset();
   }
   
  @@ -394,6 +394,20 @@
   /** Line area is always considered to act as a fence. */
   protected boolean hasTrailingFence(boolean bNotLast) {
   return true;
  +}
  +
  +/** Test whether all breakposs in vecInlineBreaks
  +back to and including prev could end line */
  +private boolean prevCouldEndLine(BreakPoss prev) {
  +ListIterator bpIter =
  +vecInlineBreaks.listIterator(vecInlineBreaks.size());
  +boolean couldEndLine = true;
  +while (bpIter.hasPrevious()) {
  +BreakPoss bp = (BreakPoss) bpIter.previous();
  +couldEndLine = bp.couldEndLine();
  +if (!couldEndLine || bp == prev) break;
  +}
  +return couldEndLine;
   }
   
   private HyphContext getHyphenContext(BreakPoss prev,
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: xml-fop/src/java/org/apache/fop/layoutmgr LineLayoutManager.java

2003-11-30 Thread gmazza
gmazza  2003/11/30 20:47:00

  Modified:src/java/org/apache/fop/layoutmgr LineLayoutManager.java
  Log:
  Hyphenation improvements from Simon Pepping (Bugs #25031 and #25059) added.
  
  Revision  ChangesPath
  1.6   +20 -10xml-fop/src/java/org/apache/fop/layoutmgr/LineLayoutManager.java
  
  Index: LineLayoutManager.java
  ===
  RCS file: 
/home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/LineLayoutManager.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- LineLayoutManager.java16 Oct 2003 23:54:21 -  1.5
  +++ LineLayoutManager.java1 Dec 2003 04:47:00 -   1.6
  @@ -252,14 +252,14 @@
   }
   
   inlineLC.setHyphContext(
  -  getHyphenContext(prevBP, bp));
  +  getHyphenContext((prevBP == null) ? prev : prevBP, bp));
   if (inlineLC.getHyphContext() == null) {
   break;
   }
   inlineLC.setFlags(LayoutContext.TRY_HYPHENATE,
 true);
   // Reset to previous acceptable break
  -reset();
  +resetBP((prevBP == null) ? prev : prevBP);
   } else {
   /* If we are not in justified text, we can end the line at
* prevBP.
  @@ -313,6 +313,7 @@
   return null;
   }
   if (prevBP == null) {
  +vecInlineBreaks.add(bp);
   prevBP = bp;
   }
   
  @@ -335,11 +336,19 @@
   return makeLineBreak(iPrevLineEnd, availIPD, talign);
   }
   
  -private void reset() {
  -while (vecInlineBreaks.get(vecInlineBreaks.size() - 1) != prevBP) {
  -vecInlineBreaks.remove(vecInlineBreaks.size() - 1);
  +private void resetBP(BreakPoss resetBP) {
  +if (resetBP == null) {
  +reset((Position) null);
  +} else {
  +while (vecInlineBreaks.get(vecInlineBreaks.size() - 1) != resetBP) {
  +vecInlineBreaks.remove(vecInlineBreaks.size() - 1);
  +}
  +reset(resetBP.getPosition());
   }
  -reset(prevBP.getPosition());
  +}
  +
  +private void reset() {
  +resetBP(prevBP);
   }
   
   protected boolean couldEndLine(BreakPoss bp) {
  @@ -398,19 +407,20 @@
   vecInlineBreaks.listIterator(vecInlineBreaks.size());
   while (bpIter.hasPrevious()  bpIter.previous() != prev) {
   }
  -if (bpIter.next() != prev) {
  +if (prev != null  bpIter.next() != prev) {
   getLogger().error(findHyphenPoss: problem!);
   return null;
   }
   StringBuffer sbChars = new StringBuffer(30);
   while (bpIter.hasNext()) {
   BreakPoss bp = (BreakPoss) bpIter.next();
  -if (bp.getLayoutManager() == prev.getLayoutManager()) {
  +if (prev != null 
  +bp.getLayoutManager() == prev.getLayoutManager()) {
   bp.getLayoutManager().getWordChars(sbChars,
  -   prev.getPosition(), 
bp.getPosition());
  +prev.getPosition(), bp.getPosition());
   } else {
   bp.getLayoutManager().getWordChars(sbChars, null,
  -   bp.getPosition());
  +bp.getPosition());
   }
   prev = bp;
   }
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: xml-fop/src/java/org/apache/fop/layoutmgr LineLayoutManager.java

2003-10-16 Thread gmazza
gmazza  2003/10/16 16:54:21

  Modified:src/java/org/apache/fop/layoutmgr LineLayoutManager.java
  Log:
  Patch by Finn Bock applied
  (bug http://nagoya.apache.org/bugzilla/show_bug.cgi?id=23765:
  Words not fitting the current line were not appearing on the
  subsequent line when trailing spaces were included in
  the fo:block.)
  
  Revision  ChangesPath
  1.5   +1 -1  xml-fop/src/java/org/apache/fop/layoutmgr/LineLayoutManager.java
  
  Index: LineLayoutManager.java
  ===
  RCS file: 
/home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/LineLayoutManager.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- LineLayoutManager.java8 Sep 2003 17:00:54 -   1.4
  +++ LineLayoutManager.java16 Oct 2003 23:54:21 -  1.5
  @@ -321,7 +321,7 @@
   prevBP = getBestBP(vecPossEnd);
   }
   // Backup child LM if necessary
  -if (bp != prevBP  !bp.couldEndLine()) {
  +if (bp != prevBP  !prevBP.couldEndLine()) {
   reset();
   }
   
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]