Bug 36004 - [PATCH] Block content in inline content
Summary: [PATCH] Block content in inline content
Status: CLOSED FIXED
Alias: None
Product: Fop - Now in Jira
Classification: Unclassified
Component: page-master/layout (show other bugs)
Version: trunk
Hardware: Other other
: P2 normal
Target Milestone: ---
Assignee: fop-dev
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-08-03 22:12 UTC by Simon Pepping
Modified: 2012-04-01 07:09 UTC (History)
0 users



Attachments
My work on block content in inline content (87.08 KB, patch)
2005-08-03 22:14 UTC, Simon Pepping
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Simon Pepping 2005-08-03 22:12:08 UTC
This patch contains the current state of my work on block content in inline content.
Comment 1 Simon Pepping 2005-08-03 22:14:03 UTC
Created attachment 15868 [details]
My work on block content in inline content
Comment 2 Simon Pepping 2005-08-03 22:33:47 UTC
Implementation notes
====================

KnuthSequence now has a variable and a method declaring whether it
contains a sequence of inline or block Knuth elements.

getNextKnuthElements() of InlineLevelLMs construct and return a list
of KnuthSequences. During the construction, if the last sequence is an
inline sequence, it is kept open for addition of further returned
inline Knuth elements (lastSequence != null). While it is open, newly
received inline sequences are added to it. It is closed when a
received inline sequence is ended by a negative infinite penalty,
which signals a forced line break, or when a forced line break is read
(TextLM).

Those InlineLevelLMs that can have BlockLevelLM children, turn the
list of Knuth elements that they receive from their BlockLevelLM
children into a block sequence, after having wrapped their
positions. Before they add this sequence to their return list, they
close the open inline sequence. They create a separate sequence for
each block level child LM.

LineLM, collectInlineKnuthElements: inline Knuth sequences are turned
into paragraphs. The positions of the elements of block sequences are
wrapped. knuthParagraphs is a list of Paragraphs and block
KnuthSequences.

Represent each block sequence (one line area) by a LineBreakPosition,
with iParIndex as the index of the block sequence in
knuthParagraphs. The LBP must be placed as
lineLayoutsList[0].possibilitiesList[0].breakPositions[0], in
agreement with the placement of LBPs of inline sequences. The type of
the block sequence leads to different processing in addAreas: an
iterator over the block sequence, the child area being placed in a
single line area (and the block areas must be children of a single
inline area, which is a descendant of the child area of the line
area).

State diagram of InlineLM:
Possible states:
 I: lastSequence != 0 && lastSequence.isInlineSequence()
 B: lastSequence != 0 && !lastSequence.isInlineSequence()
 0: lastSequence == 0
Start state = 0
InlineLevelLMs return a list of Knuth sequences, mixed inline and
 block; each returned sequence is a separate event
BlockLevelLMs return a list of Knuth elements
Possible events:
 ILM(i): InlineLevelLM returns inline sequence
 ILM(ic): InlineLevelLM returns closed inline sequence
 ILM(b): InlineLevelLM returns block sequence
 BLM(s): BlockLevelLM, curLM == lastLM
 BLM(o): BlockLevelLM, curLM != lastLM
 BLM:	 BlockLevelLM = BLM(s) or BLM(o)
Symbols:
 [ I: open new lastInlineSequence and add to return list,
	  add returned inline sequence
 [ L: open new lastBlockSequence and add to return list,
	  add returned list
 + I: add inline sequence to existing lastInlineSequence
 + L: add list to existing lastBlockSequence
 ]: close sequence
 B: add block sequence to return list
Transitions:
0 - ILM(i): [ I,      state becomes I
  - ILM(ic): [ I ],   state remains 0
  - ILM(b): B,		  state remains 0
  - BLM:	[ L,	  state becomes B
I - ILM(i): + I,	  state remains I
  - ILM(ic): + I ],   state becomes 0
  - ILM(b): ] B,	  state becomes 0
  - BLM:	] [ L,	  state becomes B
B - ILM(i): ] [ I,	  state becomes I
  - ILM(ic): ] [ I ], state becomes 0
  - ILM(b): ] B,	  state becomes 0
  - BLM(s):	+ L,	  state remains B
  - BLM(o): ] [ L,	  state remains B

The routine may end in states 0 or I. Technically it can also end in
state B, but the parent LM will never consider a returned block
sequence as open; therefore ending in state B is effectively ending in
state 0.

An inline sequence must be closed by an explicit negative infinite
penalty, so that the parent LM can see that it is closed. A block
sequence is implicitly closed. Only its creator can add elements to
it.

State diagram of InlineLevelLMs with InlineLevelM children:
Possible states:
 I: lastSequence != 0
 0: lastSequence == 0
Start state = 0
InlineLevelLMs return a list of Knuth sequences, mixed inline and
 block; each returned sequence is a separate event
Possible events:
 ILM(i): InlineLevelLM returns inline sequence
 ILM(ic): InlineLevelLM returns closed inline sequence
 ILM(b): InlineLevelLM returns block sequence
Symbols:
 [ I: open new lastInlineSequence and add to return list,
	  add returned inline sequence
 + I: add inline sequence to existing lastInlineSequence
 ]: close sequence
 B: add block sequence to return list
Transitions:
0 - ILM(i): [ I,      state becomes I
  - ILM(ic): [ I ],   state remains 0
  - ILM(b): B,		  state remains 0
I - ILM(i): + I,	  state remains I
  - ILM(ic): + I ],   state becomes 0
  - ILM(b): ] B,	  state becomes 0

For block sequences we do this whole process (adding a
LineBreakPosition to a layout possibility) in
LineLM.createBlockLineBreak. We add one layout possibility, with 1
line and 0 demerits. Then we create one linebreak position for the
sequence. The parameters for the linebreak position are as follows:

LineBreakPosition lbp = new LineBreakPosition
 (this,
  knuthParagraphs.indexOf(seq),
  seq.size() - 1,
  lineShrink,
  lineStretch,
  0, // difference 
  0, // ipd adjustment
  0, // adjust (= bpd adjustment?)
  0, // start indent
  lineHeight,
  0, // line width
  0, // baseline
  0, // topshift
  0); // bottomshift

As a bonus for using the same complicated data structure also for
block sequences, in postProcessLineBreaks, inline and blocksequences
are treated alike. The only difference is in fetching the footnote
list, which needs to be copied from the contained KnuthBlockBoxes.

Adding areas: InlineLM is supposed to return an InlineArea, but
InlineAreas cannot contain a block area. Created a new type,
InlineBlockParent.

AbstractRenderer.RenderInlineArea must recognize InlineBlockParent.

Each renderer must have a method RenderInlineBlockParent. Implemented
for AbstractRenderer, XMLRenderer.
Comment 3 Simon Pepping 2005-08-04 22:31:52 UTC
Moved to the branch 'inlineblock' for further development
Comment 4 Jeremias Maerki 2005-08-08 16:36:33 UTC
Simon, thanks for your work on inlines and for setting up the branch. As you 
will have seen, I've hacked around a little bit in the branch and I think 
we're ready to merge the branch back into trunk. All necessary tests pass. 
Would you please review? My KnuthElement/KnuthSequence mixture might be 
subject to discussion but it allowed not adjusting some of the LMs and creates 
fewer objects that way. WDYT?
Comment 5 Simon Pepping 2006-10-09 07:47:58 UTC
This feature has been implemented without directly using this patch report.
Comment 6 Glenn Adams 2012-04-01 07:09:24 UTC
batch transition pre-FOP1.0 resolved+fixed bugs to closed+fixed