public ExcelToHtmlConverter( Document doc )
{
htmlDocumentFacade = new HtmlDocumentFacade( doc );
- cssClassTable = htmlDocumentFacade.getOrCreateCssClass( "table", "t",
- "border-collapse:collapse;border-spacing:0;" );
+ cssClassTable = htmlDocumentFacade.getOrCreateCssClass( "t", "border-collapse:collapse;border-spacing:0;" );
}
protected String buildStyle( HSSFWorkbook workbook, HSSFCellStyle cellStyle )
return knownClass;
String cssStyle = buildStyle( workbook, cellStyle );
- String cssClass = htmlDocumentFacade.getOrCreateCssClass( "td", "c",
- cssStyle );
+ String cssClass = htmlDocumentFacade.getOrCreateCssClass( "c", cssStyle );
excelStyleToClass.put( cellStyleKey, cssClass );
return cssClass;
}
{
// prepare CSS classes for later usage
this.cssClassContainerCell = htmlDocumentFacade
- .getOrCreateCssClass( "td", "c",
- "padding:0;margin:0;align:left;vertical-align:top;" );
+ .getOrCreateCssClass( "c", "padding:0;margin:0;align:left;vertical-align:top;" );
this.cssClassContainerDiv = htmlDocumentFacade.getOrCreateCssClass(
- "div", "d", "position:relative;" );
+ "d", "position:relative;" );
}
for ( int s = 0; s < workbook.getNumberOfSheets(); s++ )
String style )
{
String exising = element.getAttribute( "class" );
- String addition = getOrCreateCssClass( element.getTagName(),
- classNamePrefix, style );
+ String addition = getOrCreateCssClass( classNamePrefix, style );
String newClassValue = WordToHtmlUtils.isEmpty( exising ) ? addition
: ( exising + " " + addition );
element.setAttribute( "class", newClassValue );
return head;
}
- public String getOrCreateCssClass( String tagName, String classNamePrefix,
- String style )
+ public String getOrCreateCssClass( String classNamePrefix, String style )
{
- if ( !stylesheet.containsKey( tagName ) )
- stylesheet.put( tagName, new LinkedHashMap<String, String>( 1 ) );
+ if ( !stylesheet.containsKey( classNamePrefix ) )
+ stylesheet.put( classNamePrefix, new LinkedHashMap<String, String>(
+ 1 ) );
- Map<String, String> styleToClassName = stylesheet.get( tagName );
+ Map<String, String> styleToClassName = stylesheet.get( classNamePrefix );
String knownClass = styleToClassName.get( style );
if ( knownClass != null )
return knownClass;
public void updateStylesheet()
{
StringBuilder stringBuilder = new StringBuilder();
- for ( Map.Entry<String, Map<String, String>> byTag : stylesheet
- .entrySet() )
+ for ( Map<String, String> byPrefix : stylesheet.values() )
{
- String tagName = byTag.getKey();
- for ( Map.Entry<String, String> byStyle : byTag.getValue()
- .entrySet() )
+ for ( Map.Entry<String, String> byStyle : byPrefix.entrySet() )
{
String style = byStyle.getKey();
String className = byStyle.getValue();
- stringBuilder.append( tagName + "." + className + "{" + style
- + "}\n" );
+ stringBuilder.append( "." + className + "{" + style + "}\n" );
}
}
stylesheetElement.setTextContent( stringBuilder.toString() );
{
final String textIndex = String.valueOf( noteIndex + 1 );
final String textIndexClass = htmlDocumentFacade.getOrCreateCssClass(
- "a", "a", "vertical-align:super;font-size:smaller;" );
+ "a", "vertical-align:super;font-size:smaller;" );
final String forwardNoteLink = type + "note_" + textIndex;
final String backwardNoteLink = type + "note_back_" + textIndex;
if ( tableRowStyle.length() > 0 )
tableRowElement.setAttribute( "class", htmlDocumentFacade
- .getOrCreateCssClass( "tr", "r",
- tableRowStyle.toString() ) );
+ .getOrCreateCssClass( "r", tableRowStyle.toString() ) );
if ( tableRow.isTableHeader() )
{
.setAttribute(
"class",
htmlDocumentFacade.getOrCreateCssClass(
- tableElement.getTagName(), "t",
- "table-layout:fixed;border-collapse:collapse;border-spacing:0;" ) );
+ "t", "table-layout:fixed;border-collapse:collapse;border-spacing:0;" ) );
if ( tableHeader.hasChildNodes() )
{
tableElement.appendChild( tableHeader );