float bottomMargin = section.getMarginBottom() / TWIPS_PER_INCH;
String style = "margin: " + topMargin + "in " + rightMargin + "in "
- + bottomMargin + "in " + leftMargin + "in; ";
+ + bottomMargin + "in " + leftMargin + "in;";
if ( section.getNumColumns() > 1 )
{
- style += "column-count: " + ( section.getNumColumns() ) + "; ";
+ style += "column-count: " + ( section.getNumColumns() ) + ";";
if ( section.isColumnsEvenlySpaced() )
{
float distance = section.getDistanceBetweenColumns()
/ TWIPS_PER_INCH;
- style += "column-gap: " + distance + "in; ";
+ style += "column-gap: " + distance + "in;";
}
else
{
- style += "column-gap: 0.25in; ";
+ style += "column-gap: 0.25in;";
}
}
return style;
public Document getDocument()
{
+ htmlDocumentFacade.updateStylesheet();
return htmlDocumentFacade.getDocument();
}
&& !WordToHtmlUtils.equals( triplet.fontName,
blockProperies.pFontName ) )
{
- style.append( "font-family: " + triplet.fontName + "; " );
+ style.append( "font-family:" + triplet.fontName + ";" );
}
if ( characterRun.getFontSize() / 2 != blockProperies.pFontSize )
{
- style.append( "font-size: " + characterRun.getFontSize() / 2 + "; " );
+ style.append( "font-size:" + characterRun.getFontSize() / 2 + "pt;" );
}
if ( triplet.bold )
{
- style.append( "font-weight: bold; " );
+ style.append( "font-weight:bold;" );
}
if ( triplet.italic )
{
- style.append( "font-style: italic; " );
+ style.append( "font-style:italic;" );
}
WordToHtmlUtils.addCharactersProperties( characterRun, style );
if ( style.length() != 0 )
- span.setAttribute( "style", style.toString() );
+ span.setAttribute( "class", htmlDocumentFacade.getOrCreateCssClass(
+ span.getTagName(), "s", style.toString() ) );
Text textNode = htmlDocumentFacade.createText( text );
span.appendChild( textNode );
float visibleHeight = Math.max( 0, imageHeight - cropTop
- cropBottom );
- root = htmlDocumentFacade.document.createElement( "div" );
- root.setAttribute( "style", "vertical-align:text-bottom;width:"
- + visibleWidth + "in;height:" + visibleHeight + "in;" );
+ root = htmlDocumentFacade.createBlock();
+ root.setAttribute( "class", htmlDocumentFacade.getOrCreateCssClass(
+ root.getTagName(), "d", "vertical-align:text-bottom;width:"
+ + visibleWidth + "in;height:" + visibleHeight
+ + "in;" ) );
// complex
- Element inner = htmlDocumentFacade.document.createElement( "div" );
- inner.setAttribute( "style", "position:relative;width:"
- + visibleWidth + "in;height:" + visibleHeight
- + "in;overflow:hidden;" );
+ Element inner = htmlDocumentFacade.createBlock();
+ inner.setAttribute( "class", htmlDocumentFacade
+ .getOrCreateCssClass( inner.getTagName(), "d",
+ "position:relative;width:" + visibleWidth
+ + "in;height:" + visibleHeight
+ + "in;overflow:hidden;" ) );
root.appendChild( inner );
Element image = htmlDocumentFacade.document.createElement( "img" );
image.setAttribute( "src", imageSourcePath );
- image.setAttribute( "style", "position:absolute;left:-" + cropLeft
- + ";top:-" + cropTop + ";width:" + imageWidth
- + "in;height:" + imageHeight + "in;" );
+ image.setAttribute( "class", htmlDocumentFacade
+ .getOrCreateCssClass( image.getTagName(), "i",
+ "position:absolute;left:-" + cropLeft + ";top:-"
+ + cropTop + ";width:" + imageWidth
+ + "in;height:" + imageHeight + "in;" ) );
inner.appendChild( image );
style.append( "overflow:hidden;" );
}
if ( style.length() > 0 )
- pElement.setAttribute( "style", style.toString() );
+ pElement.setAttribute(
+ "class",
+ htmlDocumentFacade.getOrCreateCssClass(
+ pElement.getTagName(), "p", style.toString() ) );
return;
}
protected void processSection( HWPFDocumentCore wordDocument,
Section section, int sectionCounter )
{
- Element div = htmlDocumentFacade.document.createElement( "div" );
- div.setAttribute( "style", getSectionStyle( section ) );
+ Element div = htmlDocumentFacade.createBlock();
+ div.setAttribute( "class", htmlDocumentFacade.getOrCreateCssClass(
+ div.getTagName(), "d", getSectionStyle( section ) ) );
htmlDocumentFacade.body.appendChild( div );
processSectionParagraphes( wordDocument, div, section,
protected void processSingleSection( HWPFDocumentCore wordDocument,
Section section )
{
- htmlDocumentFacade.body.setAttribute( "style",
- getSectionStyle( section ) );
+ htmlDocumentFacade.body
+ .setAttribute( "class", htmlDocumentFacade.getOrCreateCssClass(
+ "body", "b", getSectionStyle( section ) ) );
processSectionParagraphes( wordDocument, htmlDocumentFacade.body,
section, Integer.MIN_VALUE );
.createParagraph() );
}
if ( tableCellStyle.length() > 0 )
- tableCellElement.setAttribute( "style",
- tableCellStyle.toString() );
+ tableCellElement.setAttribute( "class", htmlDocumentFacade
+ .getOrCreateCssClass(
+ tableCellElement.getTagName(),
+ tableCellElement.getTagName(),
+ tableCellStyle.toString() ) );
tableRowElement.appendChild( tableCellElement );
}
if ( tableRowStyle.length() > 0 )
- tableRowElement
- .setAttribute( "style", tableRowStyle.toString() );
+ tableRowElement.setAttribute( "class", htmlDocumentFacade
+ .getOrCreateCssClass( "tr", "r",
+ tableRowStyle.toString() ) );
if ( tableRow.isTableHeader() )
{
{
public static void addBold( final boolean bold, StringBuilder style )
{
- style.append( "font-weight: " + ( bold ? "bold" : "normal" ) + ";" );
+ style.append( "font-weight:" + ( bold ? "bold" : "normal" ) + ";" );
}
public static void addBorder( BorderCode borderCode, String where,
if ( isEmpty( where ) )
{
- style.append( "border-style: " + getBorderType( borderCode ) + "; " );
- style.append( "border-color: " + getColor( borderCode.getColor() )
- + "; " );
- style.append( "border-width: " + getBorderWidth( borderCode )
- + "; " );
+ style.append( "border:" );
}
else
{
- style.append( "border-" + where + "-style: "
- + getBorderType( borderCode ) + "; " );
- style.append( "border-" + where + "-color: "
- + getColor( borderCode.getColor() ) + "; " );
- style.append( "border-" + where + "-width: "
- + getBorderWidth( borderCode ) + "; " );
+ style.append( "border-" );
+ style.append( where );
}
+
+ style.append( ":" );
+ style.append( getBorderWidth( borderCode ) );
+ style.append( ' ' );
+ style.append( getBorderType( borderCode ) );
+ style.append( ' ' );
+ style.append( getColor( borderCode.getColor() ) );
+ style.append( ';' );
}
public static void addCharactersProperties(
if ( characterRun.isCapitalized() )
{
- style.append( "text-transform: uppercase; " );
+ style.append( "text-transform:uppercase;" );
}
if ( characterRun.isHighlighted() )
{
- style.append( "background-color: "
- + getColor( characterRun.getHighlightedColor() ) + "; " );
+ style.append( "background-color:"
+ + getColor( characterRun.getHighlightedColor() ) + ";" );
}
if ( characterRun.isStrikeThrough() )
{
- style.append( "text-decoration: line-through; " );
+ style.append( "text-decoration:line-through;" );
}
if ( characterRun.isShadowed() )
{
- style.append( "text-shadow: " + characterRun.getFontSize() / 24
- + "pt; " );
+ style.append( "text-shadow:" + characterRun.getFontSize() / 24
+ + "pt;" );
}
if ( characterRun.isSmallCaps() )
{
- style.append( "font-variant: small-caps; " );
+ style.append( "font-variant:small-caps;" );
}
if ( characterRun.getSubSuperScriptIndex() == 1 )
{
- style.append( "baseline-shift: super; " );
- style.append( "font-size: smaller; " );
+ style.append( "baseline-shift:super;" );
+ style.append( "font-size:smaller;" );
}
if ( characterRun.getSubSuperScriptIndex() == 2 )
{
- style.append( "baseline-shift: sub; " );
- style.append( "font-size: smaller; " );
+ style.append( "baseline-shift:sub;" );
+ style.append( "font-size:smaller;" );
}
if ( characterRun.getUnderlineCode() > 0 )
{
- style.append( "text-decoration: underline; " );
+ style.append( "text-decoration:underline;" );
}
if ( characterRun.isVanished() )
{
- style.append( "visibility: hidden; " );
+ style.append( "visibility:hidden;" );
}
}
if ( isEmpty( fontFamily ) )
return;
- style.append( "font-family: " + fontFamily + "; " );
+ style.append( "font-family:" + fontFamily + ";" );
}
public static void addFontSize( final int fontSize, StringBuilder style )
{
- style.append( "font-size: " + fontSize + "pt; " );
+ style.append( "font-size:" + fontSize + "pt;" );
}
public static void addIndent( Paragraph paragraph, StringBuilder style )
if ( twipsValue == 0 )
return;
- style.append( cssName + ": " + ( twipsValue / TWIPS_PER_PT ) + "pt; " );
+ style.append( cssName + ":" + ( twipsValue / TWIPS_PER_PT ) + "pt;" );
}
public static void addJustification( Paragraph paragraph,
{
String justification = getJustification( paragraph.getJustification() );
if ( isNotEmpty( justification ) )
- style.append( "text-align: " + justification + "; " );
+ style.append( "text-align:" + justification + ";" );
}
public static void addParagraphProperties( Paragraph paragraph,
if ( paragraph.pageBreakBefore() )
{
- style.append( "break-before: page; " );
+ style.append( "break-before:page;" );
}
- style.append( "hyphenate: "
- + ( paragraph.isAutoHyphenated() ? "auto" : "none" ) + "; " );
+ style.append( "hyphenate:"
+ + ( paragraph.isAutoHyphenated() ? "auto" : "none" ) + ";" );
if ( paragraph.keepOnPage() )
{
- style.append( "keep-together.within-page: always; " );
+ style.append( "keep-together.within-page:always;" );
}
if ( paragraph.keepWithNext() )
{
- style.append( "keep-with-next.within-page: always; " );
+ style.append( "keep-with-next.within-page:always;" );
}
}
TableCell tableCell, boolean toppest, boolean bottomest,
boolean leftest, boolean rightest, StringBuilder style )
{
- style.append( "width: " + ( tableCell.getWidth() / TWIPS_PER_INCH )
- + "in; " );
- style.append( "padding-start: "
- + ( tableRow.getGapHalf() / TWIPS_PER_INCH ) + "in; " );
- style.append( "padding-end: "
- + ( tableRow.getGapHalf() / TWIPS_PER_INCH ) + "in; " );
+ style.append( "width:" + ( tableCell.getWidth() / TWIPS_PER_INCH )
+ + "in;" );
+ style.append( "padding-start:"
+ + ( tableRow.getGapHalf() / TWIPS_PER_INCH ) + "in;" );
+ style.append( "padding-end:"
+ + ( tableRow.getGapHalf() / TWIPS_PER_INCH ) + "in;" );
BorderCode top = tableCell.getBrcTop() != null
&& tableCell.getBrcTop().getBorderType() != 0 ? tableCell
{
if ( tableRow.getRowHeight() > 0 )
{
- style.append( "height: "
- + ( tableRow.getRowHeight() / TWIPS_PER_INCH ) + "in; " );
+ style.append( "height:"
+ + ( tableRow.getRowHeight() / TWIPS_PER_INCH ) + "in;" );
}
if ( !tableRow.cantSplit() )
{
- style.append( "keep-together: always; " );
+ style.append( "keep-together:always;" );
}
}