You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ki...@apache.org on 2019/09/24 23:20:20 UTC

svn commit: r1867500 - in /poi/site/src/documentation: content/xdocs/encryption.xml resources/stylesheets/snipplets2document.xsl sitemap.xmap skinconf.xml

Author: kiwiwings
Date: Tue Sep 24 23:20:20 2019
New Revision: 1867500

URL: http://svn.apache.org/viewvc?rev=1867500&view=rev
Log:
CSS/XSLT formattings for code blocks with line numbers

Modified:
    poi/site/src/documentation/content/xdocs/encryption.xml
    poi/site/src/documentation/resources/stylesheets/snipplets2document.xsl
    poi/site/src/documentation/sitemap.xmap
    poi/site/src/documentation/skinconf.xml

Modified: poi/site/src/documentation/content/xdocs/encryption.xml
URL: http://svn.apache.org/viewvc/poi/site/src/documentation/content/xdocs/encryption.xml?rev=1867500&r1=1867499&r2=1867500&view=diff
==============================================================================
--- poi/site/src/documentation/content/xdocs/encryption.xml (original)
+++ poi/site/src/documentation/content/xdocs/encryption.xml Tue Sep 24 23:20:20 2019
@@ -135,36 +135,40 @@
         Biff8EncryptionKey</a>.<a href="apidocs/dev/org/apache/poi/hssf/record/crypto/Biff8EncryptionKey.html#setCurrentUserPassword(java.lang.String)">setCurrentUserPassword</a>(String password)
         to specify the password.</p>
 
-        <source>
-// XOR/RC4 decryption for xls
-Biff8EncryptionKey.setCurrentUserPassword("pass");
-POIFSFileSystem fs = new POIFSFileSystem(new File("file.xls"), true);
-HSSFWorkbook hwb = new HSSFWorkbook(fs.getRoot(), true);
-Biff8EncryptionKey.setCurrentUserPassword(null);
-        </source>
+        <section>
+            <title>XOR/RC4 decryption for xls</title>
+            <source>
+                Biff8EncryptionKey.setCurrentUserPassword("pass");
+                POIFSFileSystem fs = new POIFSFileSystem(new File("file.xls"), true);
+                HSSFWorkbook hwb = new HSSFWorkbook(fs.getRoot(), true);
+                Biff8EncryptionKey.setCurrentUserPassword(null);
+            </source>
+        </section>
 
-        <source>
-// RC4 CryptoApi support ppt - decryption
-Biff8EncryptionKey.setCurrentUserPassword("pass");
-POIFSFileSystem fs = new POIFSFileSystem(new File("file.ppt"), true);
-HSLFSlideShow hss = new HSLFSlideShow(fs);
-...
-// Option 1: remove password
-Biff8EncryptionKey.setCurrentUserPassword(null);
-OutputStream os = new FileOutputStream("decrypted.ppt");
-hss.write(os);
-os.close();
-...
-// Option 2: change encryption settings (experimental)
-// need to cache data (i.e. read all data) before changing the key size
-PictureData picsExpected[] = hss.getPictures();
-hss.getDocumentSummaryInformation();
-EncryptionInfo ei = hss.getDocumentEncryptionAtom().getEncryptionInfo();
-((CryptoAPIEncryptionHeader)ei.getHeader()).setKeySize(0x78);
-OutputStream os = new FileOutputStream("file_120bit.ppt");
-hss.write(os);
-os.close();
-        </source>
+        <section>
+            <title>RC4 CryptoApi support ppt - decryption</title>
+            <source>
+                Biff8EncryptionKey.setCurrentUserPassword("pass");
+                POIFSFileSystem fs = new POIFSFileSystem(new File("file.ppt"), true);
+                HSLFSlideShow hss = new HSLFSlideShow(fs);
+                ...
+                // Option 1: remove password
+                Biff8EncryptionKey.setCurrentUserPassword(null);
+                OutputStream os = new FileOutputStream("decrypted.ppt");
+                hss.write(os);
+                os.close();
+                ...
+                // Option 2: change encryption settings (experimental)
+                // need to cache data (i.e. read all data) before changing the key size
+                PictureData picsExpected[] = hss.getPictures();
+                hss.getDocumentSummaryInformation();
+                EncryptionInfo ei = hss.getDocumentEncryptionAtom().getEncryptionInfo();
+                ((CryptoAPIEncryptionHeader)ei.getHeader()).setKeySize(0x78);
+                OutputStream os = new FileOutputStream("file_120bit.ppt");
+                hss.write(os);
+                os.close();
+            </source>
+        </section>
     </section>
 
     <section><title>XML-based formats - Decryption</title>

Modified: poi/site/src/documentation/resources/stylesheets/snipplets2document.xsl
URL: http://svn.apache.org/viewvc/poi/site/src/documentation/resources/stylesheets/snipplets2document.xsl?rev=1867500&r1=1867499&r2=1867500&view=diff
==============================================================================
--- poi/site/src/documentation/resources/stylesheets/snipplets2document.xsl (original)
+++ poi/site/src/documentation/resources/stylesheets/snipplets2document.xsl Tue Sep 24 23:20:20 2019
@@ -18,7 +18,11 @@
    ====================================================================
 -->
 
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
+                xmlns:ext="http://exslt.org/common"
+                xmlns:math="http://exslt.org/math"
+                exclude-result-prefixes="ext math"
+>
 
     <xsl:template match="p[@id='helpwanted']">
         <div style="width: 80%;" type="helpwanted" project="poi" description="the Apache POI Project">
@@ -37,4 +41,35 @@
             <xsl:apply-templates/>
         </xsl:copy>
     </xsl:template>
+
+    <xsl:variable name="ASCII">!"#$%&amp;'()*+,-./0123456789:;=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~</xsl:variable>
+    <xsl:variable name="DOTS">............................................................................................</xsl:variable>
+
+    <xsl:template match="source">
+
+        <xsl:variable name="codelines">
+            <xsl:apply-templates mode="source"/>
+        </xsl:variable>
+
+        <xsl:variable name="indent" select="string-length(substring-before(translate(text(),$ASCII,$DOTS),'.'))"/>
+
+        <div class="code">
+            <xsl:for-each select="ext:node-set($codelines)/*">
+                <div class="codeline"><span class="lineno"></span><span class="codebody"><xsl:value-of select="substring(.,$indent)"/></span></div>
+            </xsl:for-each>
+        </div>
+    </xsl:template>
+
+    <xsl:template match="text()" name="split" mode="source">
+        <xsl:param name="pText" select="."/>
+        <xsl:if test="string-length($pText) >0">
+            <line>
+                <xsl:value-of select="substring-before(concat($pText, '&#10;'), '&#10;')"/>
+            </line>
+
+            <xsl:call-template name="split">
+                <xsl:with-param name="pText" select="substring-after($pText, '&#10;')"/>
+            </xsl:call-template>
+        </xsl:if>
+    </xsl:template>
 </xsl:stylesheet>

Modified: poi/site/src/documentation/sitemap.xmap
URL: http://svn.apache.org/viewvc/poi/site/src/documentation/sitemap.xmap?rev=1867500&r1=1867499&r2=1867500&view=diff
==============================================================================
--- poi/site/src/documentation/sitemap.xmap (original)
+++ poi/site/src/documentation/sitemap.xmap Tue Sep 24 23:20:20 2019
@@ -39,23 +39,9 @@
                 <map:serialize type="xml"/>
             </map:match>
 
-            <!-- todo: find a better pattern which doesn't fail on locationmap.xml -->
-            <map:match pattern="**/*.xml">
-                <map:generate src="{properties:content.xdocs}{1}/{2}.xml"/>
-                <map:act type="sourcetype" src="{properties:content.xdocs}{1}/{2}.xml">
-                    <map:select type="parameter">
-                        <map:parameter name="parameter-selector-test" value="{sourcetype}"/>
-                        <map:when test="document-v20">
-                            <map:transform src="{properties:resources.stylesheets}/snipplets2document.xsl"/>
-                        </map:when>
-                    </map:select>
-                </map:act>
-                <map:serialize type="xml"/>
-            </map:match>
-
-            <map:match pattern="index.xml">
-                <map:generate src="{properties:content.xdocs}index.xml"/>
-                <map:act type="sourcetype" src="{properties:content.xdocs}index.xml">
+            <map:match type="regexp" pattern="(.*/.*|encryption|index|download|legal|news|related-projects|text-extraction)\.xml">
+                <map:generate src="{properties:content.xdocs}{1}.xml"/>
+                <map:act type="sourcetype" src="{properties:content.xdocs}{1}.xml">
                     <map:select type="parameter">
                         <map:parameter name="parameter-selector-test" value="{sourcetype}"/>
                         <map:when test="document-v20">

Modified: poi/site/src/documentation/skinconf.xml
URL: http://svn.apache.org/viewvc/poi/site/src/documentation/skinconf.xml?rev=1867500&r1=1867499&r2=1867500&view=diff
==============================================================================
--- poi/site/src/documentation/skinconf.xml (original)
+++ poi/site/src/documentation/skinconf.xml Tue Sep 24 23:20:20 2019
@@ -201,6 +201,84 @@ which will be used to configure the chos
         .feature-yes { background-color: #9f9 }
         .feature-na { background-color: #ddf }
         .feature-no { background-color: #f99 }
+
+        li.pro, li.con {
+            list-style: none;
+            padding-left: 0.7em;
+            text-indent: -0.3em;
+        }
+
+        li.pro::before, li.con::before {
+            content: "\00a0";
+            font-weight: bold;
+            display: inline-block;
+            width: 1em;
+            margin-left: -1em;
+            margin-right: 0.3em;
+            background-repeat: no-repeat;
+            background-position: center;
+        }
+
+        li.pro::before {
+            background-image: url("data:image/svg+xml;utf8,&lt;svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'>&lt;path fill='green' d='M16.59 7.58L10 14.17l-3.59-3.58L5 12l5 5 8-8zM12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z'/>&lt;/svg>");
+        }
+
+
+        li.con::before {
+            background-image: url("data:image/svg+xml;utf8,&lt;svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'>&lt;path fill='red' d='M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm3.59-13L12 10.59 8.41 7 7 8.41 10.59 12 7 15.59 8.41 17 12 13.41 15.59 17 17 15.59 13.41 12 17 8.41z'>&lt;/path>&lt;/svg>");
+        }
+
+        /* Bare bones style for the desired effect */
+        div.code {
+            display: table;
+            white-space: pre-wrap;
+            border: solid 1px black;
+            font-family: monospace;
+        }
+
+        div.code::before {
+            counter-reset: linenum;
+        }
+
+        div.codeline {
+            display: table-row;
+            counter-increment: linenum;
+        }
+
+        span.lineno {
+            display: table-cell;
+            user-select: none;
+            -moz-user-select: none;
+            -webkit-user-select: none;
+            width: 4em;
+            background: #f0f0f0;
+            padding: 3px;
+            padding-top: 0px;
+            border-right: solid 1px silver;
+            border-top: solid 1px silver;
+        }
+
+        span.lineno::before {
+            content: counter(linenum) ".";
+            text-align: right;
+            display: block;
+            font-size: 90%;
+            color: #999;
+        }
+
+        span.codebody {
+            display: table-cell;
+            padding: 3px 5em 3px 1em;
+            background: white;
+        }
+
+        div.code div.codeline:nth-child(odd) .codebody {
+            background: #f0f8ff;
+        }
+
+        dd {
+            margin-bottom: 1em;
+        }
     </extra-css>
     <colors>
         <!-- These values are used for the generated CSS files.



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