ability to change CSS building procedure

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1189618 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Sergey Vladimirov 2011-10-27 06:07:12 +00:00
parent c235706423
commit b31307ad4f

View File

@ -93,6 +93,28 @@ public class HtmlDocumentFacade
element.setAttribute( "class", newClassValue ); element.setAttribute( "class", newClassValue );
} }
protected String buildStylesheet(
final Map<String, Map<String, String>> prefixToMapOfStyles )
{
StringBuilder stringBuilder = new StringBuilder();
for ( Map<String, String> byPrefix : prefixToMapOfStyles.values() )
{
for ( Map.Entry<String, String> byStyle : byPrefix.entrySet() )
{
String style = byStyle.getKey();
String className = byStyle.getValue();
stringBuilder.append( "." );
stringBuilder.append( className );
stringBuilder.append( "{" );
stringBuilder.append( style );
stringBuilder.append( "}\n" );
}
}
final String stylesheetText = stringBuilder.toString();
return stylesheetText;
}
public Element createBlock() public Element createBlock()
{ {
return document.createElement( "div" ); return document.createElement( "div" );
@ -255,17 +277,6 @@ public class HtmlDocumentFacade
public void updateStylesheet() public void updateStylesheet()
{ {
StringBuilder stringBuilder = new StringBuilder(); stylesheetElement.setTextContent( buildStylesheet( stylesheet ) );
for ( Map<String, String> byPrefix : stylesheet.values() )
{
for ( Map.Entry<String, String> byStyle : byPrefix.entrySet() )
{
String style = byStyle.getKey();
String className = byStyle.getValue();
stringBuilder.append( "." + className + "{" + style + "}\n" );
}
}
stylesheetElement.setTextContent( stringBuilder.toString() );
} }
} }