do not use block-inline property compactization in FO (result is a target to automate processing anyway)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1150596 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e8b148eaef
commit
c7f970420a
@ -22,7 +22,6 @@ import java.util.ArrayList;
|
|||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.Stack;
|
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
@ -57,28 +56,6 @@ import org.w3c.dom.Text;
|
|||||||
public class WordToFoConverter extends AbstractWordConverter
|
public class WordToFoConverter extends AbstractWordConverter
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
|
||||||
* Holds properties values, applied to current <tt>fo:block</tt> element.
|
|
||||||
* Those properties shall not be doubled in children <tt>fo:inline</tt>
|
|
||||||
* elements.
|
|
||||||
*/
|
|
||||||
private static class BlockProperies
|
|
||||||
{
|
|
||||||
final boolean pBold;
|
|
||||||
final String pFontName;
|
|
||||||
final int pFontSize;
|
|
||||||
final boolean pItalic;
|
|
||||||
|
|
||||||
public BlockProperies( String pFontName, int pFontSize, boolean pBold,
|
|
||||||
boolean pItalic )
|
|
||||||
{
|
|
||||||
this.pFontName = pFontName;
|
|
||||||
this.pFontSize = pFontSize;
|
|
||||||
this.pBold = pBold;
|
|
||||||
this.pItalic = pItalic;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final POILogger logger = POILogFactory
|
private static final POILogger logger = POILogFactory
|
||||||
.getLogger( WordToFoConverter.class );
|
.getLogger( WordToFoConverter.class );
|
||||||
|
|
||||||
@ -133,8 +110,6 @@ public class WordToFoConverter extends AbstractWordConverter
|
|||||||
return wordToFoConverter.getDocument();
|
return wordToFoConverter.getDocument();
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Stack<BlockProperies> blocksProperies = new Stack<BlockProperies>();
|
|
||||||
|
|
||||||
private List<Element> endnotes = new ArrayList<Element>( 0 );
|
private List<Element> endnotes = new ArrayList<Element>( 0 );
|
||||||
|
|
||||||
protected final FoDocumentFacade foDocumentFacade;
|
protected final FoDocumentFacade foDocumentFacade;
|
||||||
@ -228,29 +203,15 @@ public class WordToFoConverter extends AbstractWordConverter
|
|||||||
protected void outputCharacters( Element block, CharacterRun characterRun,
|
protected void outputCharacters( Element block, CharacterRun characterRun,
|
||||||
String text )
|
String text )
|
||||||
{
|
{
|
||||||
BlockProperies blockProperies = this.blocksProperies.peek();
|
|
||||||
Element inline = foDocumentFacade.createInline();
|
Element inline = foDocumentFacade.createInline();
|
||||||
|
|
||||||
Triplet triplet = getCharacterRunTriplet( characterRun );
|
Triplet triplet = getCharacterRunTriplet( characterRun );
|
||||||
|
|
||||||
if ( triplet.bold != blockProperies.pBold )
|
if ( WordToFoUtils.isNotEmpty( triplet.fontName ) )
|
||||||
{
|
|
||||||
WordToFoUtils.setBold( inline, triplet.bold );
|
|
||||||
}
|
|
||||||
if ( triplet.italic != blockProperies.pItalic )
|
|
||||||
{
|
|
||||||
WordToFoUtils.setItalic( inline, triplet.italic );
|
|
||||||
}
|
|
||||||
if ( WordToFoUtils.isNotEmpty( triplet.fontName )
|
|
||||||
&& !WordToFoUtils.equals( triplet.fontName,
|
|
||||||
blockProperies.pFontName ) )
|
|
||||||
{
|
|
||||||
WordToFoUtils.setFontFamily( inline, characterRun.getFontName() );
|
WordToFoUtils.setFontFamily( inline, characterRun.getFontName() );
|
||||||
}
|
WordToFoUtils.setBold( inline, triplet.bold );
|
||||||
if ( characterRun.getFontSize() / 2 != blockProperies.pFontSize )
|
WordToFoUtils.setItalic( inline, triplet.italic );
|
||||||
{
|
WordToFoUtils.setFontSize( inline, characterRun.getFontSize() / 2 );
|
||||||
WordToFoUtils.setFontSize( inline, characterRun.getFontSize() / 2 );
|
|
||||||
}
|
|
||||||
WordToFoUtils.setCharactersProperties( characterRun, inline );
|
WordToFoUtils.setCharactersProperties( characterRun, inline );
|
||||||
block.appendChild( inline );
|
block.appendChild( inline );
|
||||||
|
|
||||||
@ -323,16 +284,7 @@ public class WordToFoConverter extends AbstractWordConverter
|
|||||||
setId( backwardLink, forwardLinkName );
|
setId( backwardLink, forwardLinkName );
|
||||||
endnote.appendChild( backwardLink );
|
endnote.appendChild( backwardLink );
|
||||||
|
|
||||||
blocksProperies.push( new BlockProperies( "", -1, false, false ) );
|
processCharacters( doc, Integer.MIN_VALUE, endnoteTextRange, endnote );
|
||||||
try
|
|
||||||
{
|
|
||||||
processCharacters( doc, Integer.MIN_VALUE, endnoteTextRange,
|
|
||||||
endnote );
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
blocksProperies.pop();
|
|
||||||
}
|
|
||||||
|
|
||||||
WordToFoUtils.compactInlines( endnote );
|
WordToFoUtils.compactInlines( endnote );
|
||||||
this.endnotes.add( endnote );
|
this.endnotes.add( endnote );
|
||||||
@ -368,16 +320,8 @@ public class WordToFoConverter extends AbstractWordConverter
|
|||||||
footnoteBody.appendChild( footnoteBlock );
|
footnoteBody.appendChild( footnoteBlock );
|
||||||
footNote.appendChild( footnoteBody );
|
footNote.appendChild( footnoteBody );
|
||||||
|
|
||||||
blocksProperies.push( new BlockProperies( "", -1, false, false ) );
|
processCharacters( doc, Integer.MIN_VALUE, footnoteTextRange,
|
||||||
try
|
footnoteBlock );
|
||||||
{
|
|
||||||
processCharacters( doc, Integer.MIN_VALUE, footnoteTextRange,
|
|
||||||
footnoteBlock );
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
blocksProperies.pop();
|
|
||||||
}
|
|
||||||
|
|
||||||
WordToFoUtils.compactInlines( footnoteBlock );
|
WordToFoUtils.compactInlines( footnoteBlock );
|
||||||
}
|
}
|
||||||
@ -458,46 +402,26 @@ public class WordToFoConverter extends AbstractWordConverter
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean haveAnyText = false;
|
||||||
|
|
||||||
|
if ( WordToFoUtils.isNotEmpty( bulletText ) )
|
||||||
{
|
{
|
||||||
CharacterRun characterRun = paragraph.getCharacterRun( 0 );
|
Element inline = foDocumentFacade.createInline();
|
||||||
int pFontSize = characterRun.getFontSize() / 2;
|
block.appendChild( inline );
|
||||||
Triplet triplet = getCharacterRunTriplet( characterRun );
|
|
||||||
|
|
||||||
WordToFoUtils.setFontFamily( block, triplet.fontName );
|
Text textNode = foDocumentFacade.createText( bulletText );
|
||||||
WordToFoUtils.setFontSize( block, pFontSize );
|
inline.appendChild( textNode );
|
||||||
WordToFoUtils.setBold( block, triplet.bold );
|
|
||||||
WordToFoUtils.setItalic( block, triplet.italic );
|
|
||||||
|
|
||||||
blocksProperies.push( new BlockProperies( triplet.fontName,
|
haveAnyText |= bulletText.trim().length() != 0;
|
||||||
pFontSize, triplet.bold, triplet.italic ) );
|
|
||||||
}
|
}
|
||||||
try
|
|
||||||
|
haveAnyText = processCharacters( hwpfDocument, currentTableLevel,
|
||||||
|
paragraph, block );
|
||||||
|
|
||||||
|
if ( !haveAnyText )
|
||||||
{
|
{
|
||||||
boolean haveAnyText = false;
|
Element leader = foDocumentFacade.createLeader();
|
||||||
|
block.appendChild( leader );
|
||||||
if ( WordToFoUtils.isNotEmpty( bulletText ) )
|
|
||||||
{
|
|
||||||
Element inline = foDocumentFacade.createInline();
|
|
||||||
block.appendChild( inline );
|
|
||||||
|
|
||||||
Text textNode = foDocumentFacade.createText( bulletText );
|
|
||||||
inline.appendChild( textNode );
|
|
||||||
|
|
||||||
haveAnyText |= bulletText.trim().length() != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
haveAnyText = processCharacters( hwpfDocument, currentTableLevel,
|
|
||||||
paragraph, block );
|
|
||||||
|
|
||||||
if ( !haveAnyText )
|
|
||||||
{
|
|
||||||
Element leader = foDocumentFacade.createLeader();
|
|
||||||
block.appendChild( leader );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
blocksProperies.pop();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WordToFoUtils.compactInlines( block );
|
WordToFoUtils.compactInlines( block );
|
||||||
|
Loading…
Reference in New Issue
Block a user