poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ser...@apache.org
Subject svn commit: r1189180 - /poi/trunk/src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToHtmlConverter.java
Date Wed, 26 Oct 2011 13:02:34 GMT
Author: sergey
Date: Wed Oct 26 13:02:34 2011
New Revision: 1189180

URL: http://svn.apache.org/viewvc?rev=1189180&view=rev
Log:
ability to customize Excel-to-HTML CSS prefixes

Modified:
    poi/trunk/src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToHtmlConverter.java

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToHtmlConverter.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToHtmlConverter.java?rev=1189180&r1=1189179&r2=1189180&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToHtmlConverter.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToHtmlConverter.java Wed
Oct 26 13:02:34 2011
@@ -125,6 +125,14 @@ public class ExcelToHtmlConverter extend
 
     private String cssClassContainerDiv = null;
 
+    private String cssClassPrefixCell = "c";
+
+    private String cssClassPrefixDiv = "d";
+
+    private String cssClassPrefixRow = "r";
+
+    private String cssClassPrefixTable = "t";
+
     private final String cssClassTable;
 
     private Map<Short, String> excelStyleToClass = new LinkedHashMap<Short, String>();
@@ -136,7 +144,9 @@ public class ExcelToHtmlConverter extend
     public ExcelToHtmlConverter( Document doc )
     {
         htmlDocumentFacade = new HtmlDocumentFacade( doc );
-        cssClassTable = htmlDocumentFacade.getOrCreateCssClass( "t", "border-collapse:collapse;border-spacing:0;"
);
+        cssClassTable = htmlDocumentFacade.getOrCreateCssClass(
+                cssClassPrefixTable,
+                "border-collapse:collapse;border-spacing:0;" );
     }
 
     protected String buildStyle( HSSFWorkbook workbook, HSSFCellStyle cellStyle )
@@ -233,6 +243,26 @@ public class ExcelToHtmlConverter extend
         }
     }
 
+    public String getCssClassPrefixCell()
+    {
+        return cssClassPrefixCell;
+    }
+
+    public String getCssClassPrefixDiv()
+    {
+        return cssClassPrefixDiv;
+    }
+
+    public String getCssClassPrefixRow()
+    {
+        return cssClassPrefixRow;
+    }
+
+    public String getCssClassPrefixTable()
+    {
+        return cssClassPrefixTable;
+    }
+
     public Document getDocument()
     {
         return htmlDocumentFacade.getDocument();
@@ -248,7 +278,8 @@ public class ExcelToHtmlConverter extend
             return knownClass;
 
         String cssStyle = buildStyle( workbook, cellStyle );
-        String cssClass = htmlDocumentFacade.getOrCreateCssClass( "c", cssStyle );
+        String cssClass = htmlDocumentFacade.getOrCreateCssClass(
+                cssClassPrefixCell, cssStyle );
         excelStyleToClass.put( cellStyleKey, cssClass );
         return cssClass;
     }
@@ -399,7 +430,7 @@ public class ExcelToHtmlConverter extend
             innerDivStyle.append( "pt;white-space:nowrap;" );
             ExcelToHtmlUtils.appendAlign( innerDivStyle,
                     cellStyle.getAlignment() );
-            htmlDocumentFacade.addStyleClass( outerDiv, "d",
+            htmlDocumentFacade.addStyleClass( outerDiv, cssClassPrefixDiv,
                     innerDivStyle.toString() );
 
             innerDiv.appendChild( text );
@@ -633,8 +664,9 @@ public class ExcelToHtmlConverter extend
                 continue;
 
             Element tableRowElement = htmlDocumentFacade.createTableRow();
-            htmlDocumentFacade.addStyleClass( tableRowElement, "r", "height:"
-                    + ( row.getHeight() / 20f ) + "pt;" );
+            htmlDocumentFacade.addStyleClass( tableRowElement,
+                    cssClassPrefixRow, "height:" + ( row.getHeight() / 20f )
+                            + "pt;" );
 
             int maxRowColumnNumber = processRow( mergedRanges, row,
                     tableRowElement );
@@ -691,9 +723,10 @@ public class ExcelToHtmlConverter extend
         {
             // prepare CSS classes for later usage
             this.cssClassContainerCell = htmlDocumentFacade
-                    .getOrCreateCssClass( "c", "padding:0;margin:0;align:left;vertical-align:top;"
);
+                    .getOrCreateCssClass( cssClassPrefixCell,
+                            "padding:0;margin:0;align:left;vertical-align:top;" );
             this.cssClassContainerDiv = htmlDocumentFacade.getOrCreateCssClass(
-                    "d", "position:relative;" );
+                    cssClassPrefixDiv, "position:relative;" );
         }
 
         for ( int s = 0; s < workbook.getNumberOfSheets(); s++ )
@@ -705,6 +738,26 @@ public class ExcelToHtmlConverter extend
         htmlDocumentFacade.updateStylesheet();
     }
 
+    public void setCssClassPrefixCell( String cssClassPrefixCell )
+    {
+        this.cssClassPrefixCell = cssClassPrefixCell;
+    }
+
+    public void setCssClassPrefixDiv( String cssClassPrefixDiv )
+    {
+        this.cssClassPrefixDiv = cssClassPrefixDiv;
+    }
+
+    public void setCssClassPrefixRow( String cssClassPrefixRow )
+    {
+        this.cssClassPrefixRow = cssClassPrefixRow;
+    }
+
+    public void setCssClassPrefixTable( String cssClassPrefixTable )
+    {
+        this.cssClassPrefixTable = cssClassPrefixTable;
+    }
+
     /**
      * Allows converter to wrap content into two additional DIVs with tricky
      * styles, so it will wrap across empty cells (like in Excel).



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message