[jsword-svn] r1607 - in trunk: bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop bibledesktop/src/main/resources/xsl/cswing common common/src/main/java/org/crosswire/common/xml jsword/src/main/java/org/crosswire/jsword/book jsword/src/main/java/org/crosswire/jsword/book/filter/thml
dmsmith at www.crosswire.org
dmsmith at www.crosswire.org
Sat Aug 4 10:13:25 MST 2007
Author: dmsmith
Date: 2007-08-04 10:13:24 -0700 (Sat, 04 Aug 2007)
New Revision: 1607
Modified:
trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/DesktopActions.java
trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/ViewSourcePane.java
trunk/bibledesktop/src/main/resources/xsl/cswing/simple.xsl
trunk/common/JSwordDictionary.txt
trunk/common/src/main/java/org/crosswire/common/xml/PrettySerializingContentHandler.java
trunk/common/src/main/java/org/crosswire/common/xml/SerializingContentHandler.java
trunk/common/src/main/java/org/crosswire/common/xml/XMLUtil.java
trunk/jsword/src/main/java/org/crosswire/jsword/book/BookData.java
trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/HTag.java
Log:
More right to left changes.
Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/DesktopActions.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/DesktopActions.java 2007-08-04 03:36:22 UTC (rev 1606)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/DesktopActions.java 2007-08-04 17:13:24 UTC (rev 1607)
@@ -45,7 +45,6 @@
import org.crosswire.common.util.OSType;
import org.crosswire.common.util.ReflectionUtil;
import org.crosswire.common.util.Reporter;
-import org.crosswire.jsword.book.Book;
import org.crosswire.jsword.passage.Key;
import org.crosswire.jsword.passage.NoSuchVerseException;
import org.crosswire.jsword.util.Project;
@@ -403,9 +402,7 @@
return;
}
- Book book = da.getFirstBook();
-
- ViewSourcePane viewer = new ViewSourcePane(book, key);
+ ViewSourcePane viewer = new ViewSourcePane(da.getBooks(), key);
viewer.showInFrame(getDesktop());
}
Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/ViewSourcePane.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/ViewSourcePane.java 2007-08-04 03:36:22 UTC (rev 1606)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/ViewSourcePane.java 2007-08-04 17:13:24 UTC (rev 1607)
@@ -76,7 +76,7 @@
*/
public class ViewSourcePane extends JPanel
{
- public ViewSourcePane(Book book, Key key)
+ public ViewSourcePane(Book[] books, Key key)
{
try
{
@@ -85,15 +85,27 @@
Iterator iter = key.iterator();
while (iter.hasNext())
{
- if (buf.length() > 0)
+ Key currentKey = (Key) iter.next();
+ String osisID = currentKey.getOsisID();
+ for (int i = 0; i < books.length; i++)
{
- buf.append('\n');
+ Book book = books[i];
+ if (buf.length() > 0)
+ {
+ buf.append('\n');
+ }
+ buf.append(book.getInitials());
+ buf.append(':');
+ buf.append(osisID);
+ buf.append(" - "); //$NON-NLS-1$
+ buf.append(book.getRawText(currentKey));
}
- buf.append(book.getRawText((Key) iter.next()));
}
- BookData bdata = new BookData(book, key);
+ // TODO(DMS): handle comparison
+ BookData bdata = new BookData(books, key, false);
+ Book book = bdata.getFirstBook();
BookMetaData bmd = book.getBookMetaData();
String fontSpec = GuiConvert.font2String(BookFont.instance().getFont(book));
Modified: trunk/bibledesktop/src/main/resources/xsl/cswing/simple.xsl
===================================================================
--- trunk/bibledesktop/src/main/resources/xsl/cswing/simple.xsl 2007-08-04 03:36:22 UTC (rev 1606)
+++ trunk/bibledesktop/src/main/resources/xsl/cswing/simple.xsl 2007-08-04 17:13:24 UTC (rev 1607)
@@ -113,6 +113,8 @@
<!-- Create a global key factory from which OSIS ids will be generated -->
<xsl:variable name="keyf" select="jsword:org.crosswire.jsword.passage.PassageKeyFactory.instance()"/>
+ <!-- Create a global number shaper that can transform 0-9 into other number systems. -->
+ <xsl:variable name="shaper" select="jsword:org.crosswire.common.icu.NumberShaper.new()"/>
<!--=======================================================================-->
<xsl:template match="/">
@@ -361,15 +363,15 @@
<!-- An osisID can be a space separated list of them -->
<xsl:variable name="firstOsisID" select="substring-before(concat(@osisID, ' '), ' ')"/>
<xsl:variable name="book" select="substring-before($firstOsisID, '.')"/>
- <xsl:variable name="chapter" select="substring-before(substring-after($firstOsisID, '.'), '.')"/>
+ <xsl:variable name="chapter" select="jsword:shape($shaper, substring-before(substring-after($firstOsisID, '.'), '.'))"/>
<!-- If n is present use it for the number -->
<xsl:variable name="verse">
<xsl:choose>
<xsl:when test="@n">
- <xsl:value-of select="@n"/>
+ <xsl:value-of select="jsword:shape($shaper, string(@n))"/>
</xsl:when>
<xsl:otherwise>
- <xsl:value-of select="substring-after(substring-after($firstOsisID, '.'), '.')"/>
+ <xsl:value-of select="jsword:shape($shaper, substring-after(substring-after($firstOsisID, '.'), '.'))"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
@@ -1252,9 +1254,26 @@
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
+ <xsl:variable name="cell-direction">
+ <xsl:if test="@xml:lang">
+ <xsl:call-template name="getDirection">
+ <xsl:with-param name="lang"><xsl:value-of select="@xml:lang"/></xsl:with-param>
+ </xsl:call-template>
+ </xsl:if>
+ </xsl:variable>
<xsl:element name="{$element-name}">
<xsl:attribute name="class">cell</xsl:attribute>
<xsl:attribute name="valign">top</xsl:attribute>
+ <xsl:if test="@xml:lang">
+ <xsl:attribute name="dir">
+ <xsl:value-of select="$cell-direction"/>
+ </xsl:attribute>
+ </xsl:if>
+ <xsl:if test="$cell-direction = 'rtl'">
+ <xsl:attribute name="align">
+ <xsl:value-of select="'right'"/>
+ </xsl:attribute>
+ </xsl:if>
<xsl:if test="@rows">
<xsl:attribute name="rowspan">
<xsl:value-of select="@rows"/>
@@ -1265,7 +1284,15 @@
<xsl:value-of select="@cols"/>
</xsl:attribute>
</xsl:if>
- <xsl:apply-templates/>
+ <!-- hack alert -->
+ <xsl:choose>
+ <xsl:when test="$cell-direction = 'rtl'">
+ <xsl:text>‫</xsl:text><xsl:apply-templates/><xsl:text>‬</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates/>
+ </xsl:otherwise>
+ </xsl:choose>
</xsl:element>
</xsl:template>
@@ -1427,5 +1454,22 @@
</xsl:otherwise>
</xsl:choose>
</xsl:template>
+
+ <!--
+ The direction is deduced from the xml:lang attribute and is assumed to be meaningful for those elements.
+ Note: there is a bug that prevents dir=rtl from working.
+ see: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4296022 and 4866977
+ -->
+ <xsl:template name="getDirection">
+ <xsl:param name="lang"/>
+ <xsl:choose>
+ <xsl:when test="$lang = 'he' or $lang = 'ar' or $lang = 'fa' or $lang = 'ur' or $lang = 'syr'">
+ <xsl:value-of select="'rtl'"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="'ltr'"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
</xsl:stylesheet>
Modified: trunk/common/JSwordDictionary.txt
===================================================================
--- trunk/common/JSwordDictionary.txt 2007-08-04 03:36:22 UTC (rev 1606)
+++ trunk/common/JSwordDictionary.txt 2007-08-04 17:13:24 UTC (rev 1607)
@@ -13,3 +13,8 @@
fallback
yahoo
com
+installable
+accessor
+interlinear
+serializer
+namespace
Modified: trunk/common/src/main/java/org/crosswire/common/xml/PrettySerializingContentHandler.java
===================================================================
--- trunk/common/src/main/java/org/crosswire/common/xml/PrettySerializingContentHandler.java 2007-08-04 03:36:22 UTC (rev 1606)
+++ trunk/common/src/main/java/org/crosswire/common/xml/PrettySerializingContentHandler.java 2007-08-04 17:13:24 UTC (rev 1607)
@@ -135,7 +135,7 @@
for (int i = 0; i < attrs.getLength(); i++)
{
write(' ');
- write(decorateAttributeName(attrs.getLocalName(i)));
+ write(decorateAttributeName(XMLUtil.getAttributeName(attrs, i)));
write("='"); //$NON-NLS-1$
write(decorateAttributeValue(XMLUtil.escape(attrs.getValue(i))));
write('\'');
Modified: trunk/common/src/main/java/org/crosswire/common/xml/SerializingContentHandler.java
===================================================================
--- trunk/common/src/main/java/org/crosswire/common/xml/SerializingContentHandler.java 2007-08-04 03:36:22 UTC (rev 1606)
+++ trunk/common/src/main/java/org/crosswire/common/xml/SerializingContentHandler.java 2007-08-04 17:13:24 UTC (rev 1607)
@@ -118,7 +118,7 @@
for (int i = 0; i < attrs.getLength(); i++)
{
buffer.append(' ');
- buffer.append(attrs.getLocalName(i));
+ buffer.append(XMLUtil.getAttributeName(attrs, i));
buffer.append("=\""); //$NON-NLS-1$
buffer.append(attrs.getValue(i));
buffer.append('\"');
Modified: trunk/common/src/main/java/org/crosswire/common/xml/XMLUtil.java
===================================================================
--- trunk/common/src/main/java/org/crosswire/common/xml/XMLUtil.java 2007-08-04 03:36:22 UTC (rev 1606)
+++ trunk/common/src/main/java/org/crosswire/common/xml/XMLUtil.java 2007-08-04 17:13:24 UTC (rev 1607)
@@ -87,6 +87,21 @@
}
/**
+ * Get the full name of the attribute, including the namespace if any.
+ * @param attrs the collection of attributes
+ * @param index the index of the desired attribute
+ * @return
+ */
+ public static String getAttributeName(Attributes attrs, int index)
+ {
+ String qName = attrs.getQName(index);
+ if (qName != null)
+ {
+ return qName;
+ }
+ return attrs.getLocalName(index);
+ }
+ /**
* Show the attributes of an element as debug
*/
public static void debugSAXAttributes(Attributes attrs)
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/BookData.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/BookData.java 2007-08-04 03:36:22 UTC (rev 1606)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/BookData.java 2007-08-04 17:13:24 UTC (rev 1607)
@@ -37,7 +37,7 @@
import org.jdom.Text;
/**
- * BookData is the assembler of the osis that is returned by the filters.
+ * BookData is the assembler of the OSIS that is returned by the filters.
* As such it puts that into an OSIS document. When several books are
* supplied, it gets the data from each and puts it into a parallel or
* interlinear view.
@@ -48,7 +48,7 @@
* @see gnu.lgpl.License for license details.
* The copyright to this program is held by it's authors.
* @author Joe Walker [joe at eireneh dot com]
- * @author DM Smith [dmsmith at yahoo dot com]
+ * @author DM Smith [dmsmith555 at yahoo dot com]
*/
public class BookData implements BookProvider
{
@@ -211,16 +211,12 @@
buf.append(book.getInitials());
cell.addContent(OSISUtil.factory().createText(buf.toString()));
- Language prevLang = (Language) book.getProperty(BookMetaData.KEY_XML_LANG);
- cell.setAttribute(OSISUtil.OSIS_ATTR_LANG, prevLang.getCode(), Namespace.XML_NAMESPACE);
row.addContent(cell);
cell = OSISUtil.factory().createHeaderCell();
}
}
cell.addContent(OSISUtil.factory().createText(book.getInitials()));
- Language lang = (Language) book.getProperty(BookMetaData.KEY_XML_LANG);
- cell.setAttribute(OSISUtil.OSIS_ATTR_LANG, lang.getCode(), Namespace.XML_NAMESPACE);
row.addContent(cell);
iters[i] = book.getOsisIterator(key, true);
@@ -240,7 +236,10 @@
for (int i = 0; i < iters.length; i++)
{
+ Book book = books[i];
cell = OSISUtil.factory().createCell();
+ Language lang = (Language) book.getProperty(BookMetaData.KEY_XML_LANG);
+ cell.setAttribute(OSISUtil.OSIS_ATTR_LANG, lang.getCode(), Namespace.XML_NAMESPACE);
row.addContent(cell);
if (iters[i].hasNext())
{
@@ -266,6 +265,8 @@
// Since we used that cell create another
cell = OSISUtil.factory().createCell();
+ lang = (Language) book.getProperty(BookMetaData.KEY_XML_LANG);
+ cell.setAttribute(OSISUtil.OSIS_ATTR_LANG, lang.getCode(), Namespace.XML_NAMESPACE);
row.addContent(cell);
}
lastText = thisText;
@@ -308,7 +309,7 @@
private boolean comparingBooks;
/**
- * The complete osis container for the element
+ * The complete OSIS container for the element
*/
private Element osis;
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/HTag.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/HTag.java 2007-08-04 03:36:22 UTC (rev 1606)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/HTag.java 2007-08-04 17:13:24 UTC (rev 1607)
@@ -30,7 +30,7 @@
*
* @see gnu.lgpl.License for license details.
* The copyright to this program is held by it's authors.
- * @author DM Smith [dmsmith at yahoo dot com]
+ * @author DM Smith [dmsmith555 at yahoo dot com]
*/
public class HTag extends AbstractTag
{
More information about the jsword-svn
mailing list