mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-05 10:49:24 +02:00
I don't remember all the changes of this commit :)
config is splitted to interface and xml-based implementation added (dummy) sqllite-based config implementation added full-featured text scrolling several time-optimizations added TODO file git-svn-id: https://only.mawhrin.net/repos/FBReaderJ/trunk@424 6a642e6f-84f6-412e-ac94-c4a38d5a04b0
This commit is contained in:
parent
0827bdf9d0
commit
08e5233f68
129 changed files with 2926 additions and 1507 deletions
67
TODO
Normal file
67
TODO
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
ZLTextView:
|
||||||
|
пометки (для найденных строк и т.п.)
|
||||||
|
выделение текста мышкой
|
||||||
|
прокрутка текста мышкой
|
||||||
|
переход по ссылкам
|
||||||
|
внутренним
|
||||||
|
внешним (вызов браузера)
|
||||||
|
переносы
|
||||||
|
position indicator
|
||||||
|
|
||||||
|
рисунки:
|
||||||
|
обработка palm'овых рисунков
|
||||||
|
избавиться от многократных вычислений (ZLImageData + WeakReference)
|
||||||
|
|
||||||
|
форматы:
|
||||||
|
fb2 (сделать чтение описания книги)
|
||||||
|
chm
|
||||||
|
html
|
||||||
|
oeb
|
||||||
|
epub
|
||||||
|
openreader
|
||||||
|
ztxt
|
||||||
|
palmdoc
|
||||||
|
plucker
|
||||||
|
rtf
|
||||||
|
tcr
|
||||||
|
txt
|
||||||
|
|
||||||
|
файловая система:
|
||||||
|
архивы
|
||||||
|
zip
|
||||||
|
grip
|
||||||
|
tar
|
||||||
|
bz2
|
||||||
|
|
||||||
|
диалоги:
|
||||||
|
Selection
|
||||||
|
открытие книги
|
||||||
|
Option
|
||||||
|
настройки
|
||||||
|
book info
|
||||||
|
MessageBox
|
||||||
|
WaitMessage
|
||||||
|
запуск программы (?)
|
||||||
|
загрузка книги
|
||||||
|
загрузка списка библиотеки
|
||||||
|
сохранение конфига
|
||||||
|
другие
|
||||||
|
диалог поиска
|
||||||
|
|
||||||
|
книги:
|
||||||
|
BookDescription
|
||||||
|
Collection
|
||||||
|
|
||||||
|
представления:
|
||||||
|
CollectionView
|
||||||
|
RecentBooksView
|
||||||
|
FootnoteView
|
||||||
|
|
||||||
|
конфиг:
|
||||||
|
нормальная запись в десктопном варианте (без длинной-длинной строки)
|
||||||
|
сохранение раз в 30 секунд
|
||||||
|
реализация на базе sqlite (для андроида)
|
||||||
|
|
||||||
|
другое:
|
||||||
|
поиск
|
||||||
|
написать другой how-to-start (без иконок)
|
14
build.xml
14
build.xml
|
@ -2,6 +2,7 @@
|
||||||
<project basedir = "." default = "buildJar" name = "fbreader">
|
<project basedir = "." default = "buildJar" name = "fbreader">
|
||||||
<property name = "src.dir" value = "src"/>
|
<property name = "src.dir" value = "src"/>
|
||||||
<property name = "bin.dir" value = "bin"/>
|
<property name = "bin.dir" value = "bin"/>
|
||||||
|
<property name = "cache.dir" value = "depcache"/>
|
||||||
<property name = "icons.dir" value = "icons"/>
|
<property name = "icons.dir" value = "icons"/>
|
||||||
<property name = "data.dir" value = "data"/>
|
<property name = "data.dir" value = "data"/>
|
||||||
<property name = "test.dir" value= "test"/>
|
<property name = "test.dir" value= "test"/>
|
||||||
|
@ -13,9 +14,17 @@
|
||||||
<mkdir dir = "${bin.dir}" />
|
<mkdir dir = "${bin.dir}" />
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<target name = "compile" depends = "prepare">
|
<target name = "depend" depends = "prepare">
|
||||||
|
<depend srcdir = "${src.dir}" destdir = "${bin.dir}" cache = "${cache.dir}" closure = "yes">
|
||||||
|
<exclude name = "org/zlibrary/ui/android/**"/>
|
||||||
|
<exclude name = "org/zlibrary/core/xml/sax/**"/>
|
||||||
|
</depend>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name = "compile" depends = "depend">
|
||||||
<javac srcdir = "${src.dir}" destdir = "${bin.dir}">
|
<javac srcdir = "${src.dir}" destdir = "${bin.dir}">
|
||||||
<exclude name = "org/zlibrary/ui/android/**"/>
|
<exclude name = "org/zlibrary/ui/android/**"/>
|
||||||
|
<exclude name = "org/zlibrary/core/xml/sax/**"/>
|
||||||
</javac>
|
</javac>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
|
@ -49,6 +58,7 @@
|
||||||
|
|
||||||
<target name = "clean">
|
<target name = "clean">
|
||||||
<delete dir = "${bin.dir}"/>
|
<delete dir = "${bin.dir}"/>
|
||||||
|
<delete dir = "${cache.dir}"/>
|
||||||
<delete file = "${main.jar}"/>
|
<delete file = "${main.jar}"/>
|
||||||
<delete file = "${sources.zip}"/>
|
<delete file = "${sources.zip}"/>
|
||||||
<delete dir = "platform/android/res/raw"/>
|
<delete dir = "platform/android/res/raw"/>
|
||||||
|
@ -63,7 +73,7 @@
|
||||||
<arg value = "${src.dir}" />
|
<arg value = "${src.dir}" />
|
||||||
<arg value = "${data.dir}" />
|
<arg value = "${data.dir}" />
|
||||||
<arg value = "${icons.dir}" />
|
<arg value = "${icons.dir}" />
|
||||||
<arg value = "${manifest.mf}" />
|
<arg value = "${manifest.file}" />
|
||||||
<arg value = "build.xml" />
|
<arg value = "build.xml" />
|
||||||
<arg value = "platform" />
|
<arg value = "platform" />
|
||||||
<arg value = "-x" />
|
<arg value = "-x" />
|
||||||
|
|
135
data/help/MiniHelp.it.fb2
Normal file
135
data/help/MiniHelp.it.fb2
Normal file
|
@ -0,0 +1,135 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<FictionBook xmlns="http://www.gribuser.ru/xml/fictionbook/2.0" xmlns:l="http://www.w3.org/1999/xlink"><description><title-info><author><last-name>FBReader</last-name></author> <book-title>Informazioni su FBReader</book-title> <lang>it</lang></title-info></description>
|
||||||
|
<body>
|
||||||
|
<title><p>Informazioni su FBReader</p></title>
|
||||||
|
<p>FBReader è un lettore di e-book per PDA/UMPC/computer Linux/Windows. FBReader supporta diversi formati di e-book: <code>fb2</code>, <code>html</code>, <code>chm</code>, <code>rtf</code>, <code>plucker</code>, etc. E' anche supportata la lettura diretta da archivi <code>zip</code>, <code>tar</code>, <code>gzip</code> e <code>bzip2</code>.</p>
|
||||||
|
<p>FBReader è distribuito nei termini is della licenza <a l:href="http://www.gnu.org/licenses/gpl.html">GNU GPL</a>.</p>
|
||||||
|
<empty-line/>
|
||||||
|
<subtitle><p>Come Iniziare</p></subtitle>
|
||||||
|
<p>FBReader cerca i libri <code>fb2</code>, <code>oeb</code> e <code>OpenReader</code> nelle cartelle elencate nell'opzione <code>Percorso Libri</code>. Prima di tutto occorre impostare questo percorso. Apri la finestra Opzioni (basta fare clic su <image l:href="#settings.png" voffset="-6"/> nella barra degli strumenti) and cambiare il valore dell'opzione <code>Percorso Libri</code> nella scheda <code>Generale</code>. Questa opzione contiene l'elenco delle cartelle contenenti file <code>*.fb2</code>, <code>*.oebzip</code>, <code>*.orb</code> o archivi. Le cartelle dell'elenco sono separate da due punti.</p>
|
||||||
|
<p>Apri <code>biblioteca</code> (fare clic su <image l:href="#books.png" voffset="-6"/>), seleziona un libro dall'elenco e leggi.</p>
|
||||||
|
<p>Per leggere un file in un altro formato, devi aggiungerlo alla biblioteca. Apri la <code>finestra aggiungi alla biblioteca</code> (<image l:href="#addbook.png"/>), seleziona un file e modifica le informazioni sul file. La prossima volta puoi aprire questo file usando la <code>biblioteca</code> (<image l:href="#books.png" voffset="-6"/>).</p>
|
||||||
|
<empty-line/>
|
||||||
|
<subtitle><p>Siti correlati</p></subtitle>
|
||||||
|
<p>Ulteriori informazioni su questo programma possono essere trovate alla <a l:href="http://www.fbreader.org">homepage di FBReader</a>.</p>
|
||||||
|
<p>Se vuoi essere informato sull'uscita di nuove versioni, per favore iscriviti al <a l:href="http://freshmeat.net/projects/fbreader">progetto FBReader su freshmeat</a>.</p>
|
||||||
|
<p>Se hai domande o suggerimenti, per favore usa il <a l:href="http://groups.google.com/group/fbreader">gruppo di FBReader su google gruppi</a>.</p>
|
||||||
|
</body>
|
||||||
|
<binary content-type="image/png" id="settings.png">
|
||||||
|
iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABHNCSVQICAgI
|
||||||
|
fAhkiAAACAhJREFUWIXtlmtQVOcZx//nuvddgWXBZUEuahWQmzqI8UKsouJE
|
||||||
|
Y2qt7Uynrdrxi1OVYEF0UqcpsGJ1tNZkSIyZZDptwrRaDUaIhqGdxppO0iji
|
||||||
|
hQUVuS3swsIuLHvupx/CZlYFsZMP/dJn5pn3fc95n+f/e573nTMH+L/9j42Y
|
||||||
|
bkNNTdVymqXfB0gdCNyXBeHDYFB46/Dhw9zzilQff6dIA/WLkpKdvv8K4MiR
|
||||||
|
IyaVkAJpqbORl7sQ/kAArbdbOO+g180FhYKDBw8OTCd+5MS7+xVVqaEoqlsQ
|
||||||
|
pOWHSnc+inxPPiu4rKxslCapld09j8b9gYDiSHBg7Zr12qzM7CSDSXf+WbF1
|
||||||
|
dXXU0VPvnWV1ml8tLihAYkqKnWGof1eeeDvruQEAoLS0/O+cKK365MplUlVV
|
||||||
|
XpIkZC3Ipgx6w4Lqo68XTlr1kXdMDwfGm0xm89acvEUGVqNBgsNB2R2OaFIl
|
||||||
|
b9bW1jJTAlRVVcU8+axif8XnAPyiKPYCAM/zSE1NM7C0Zsuk1Drqq/j4+Pys
|
||||||
|
3BwDRVMAAFmR4fV6ggRB/HjXrl3ipABOZ+VaklYHT5068f3I59XHqnMBWGia
|
||||||
|
DtI0DZIkYTQaCZqmUybTJ1TEzJmdohEEAaLAQxJ5tN9t4wRebCjfu/0PkXsf
|
||||||
|
A2A0zNmc7FxIivTH2to3XgaAmprKHEJSLs1Jm/uawWBI0Wg00Gq14DhOBeB+
|
||||||
|
UtzprLXIijxDkkQIfAiyKGDQ41F9Q94RgpN/9uR++jEAhhlKdCTZk2el0H+9
|
||||||
|
eO68s6YSCoDMBQtOrVhWWKGqqlaSJNA0jd7eHkkUxccKOFxbqyc4tnn+vDRR
|
||||||
|
lSXG7/MhFBpHX5+HIBRlU1nZztGnuhW5OH6ipjJ9fmZZbs5CiiQfvx6yLCMY
|
||||||
|
DEJRFDAMA17g0dBQzwmSuG1/SfmFw7W1em2IacrKmJNntpiYllbXeCAwdhcq
|
||||||
|
PoWKa+Ul2y9MelyRi8rKyjijWe/a8spWM8uykGUZJEmCIAhIkgSKouDz+dDa
|
||||||
|
2gqbzQZbnA0NDfUcL8obFSb2YF7mvIKoKCN741b7+PCw/82yvdtLJxONNCpy
|
||||||
|
0dTUFCxat8btcrWtcyQ4aKvVCoZhwDAMZFmGPzACRVYgiiII4mv29IwM2vVw
|
||||||
|
4EdZ6d9xxNmi2dY7HSHv4Mjb5fu2l0wn/lQHwnb0qHMTzdJnjAajLsZqJYPB
|
||||||
|
oOLxDNCiKGo2FL+kCrxIAICqqmh1dcMaEw37zFi03Ong+93eM+X7dux+HvEp
|
||||||
|
AYCvv2QPHtxLVykijlSIMYbR35Tl0ByKYT9bW7TeIPAiceteJywWCxId8bjT
|
||||||
|
9hDuni6BV4ZmH3r1UPe3BpjMktZXpceasSMjgdq9YuE8NsZiwKwkO9o6HoEh
|
||||||
|
CSTZZyjXrn82ND7GZ1RUVHifJ+e0n+KwpW6o3q5lmX+9sm7FnpAmlfrd+Q4Y
|
||||||
|
LdHouN8NKDLS5yYhISGRzM7KjdYZNV86nU7L8+Slpt8CpGyo2siy7Nkfbi7U
|
||||||
|
Fy5MJrV6Azk8yuODxpvITTUjP2cuaJoGz/NwOBJJWZIN/tHhzUvyC95tbm4W
|
||||||
|
n5V7WoDk4qp8mqIubi5epg/yKv5xy41O9zDsNgsGPH5ZHnfLS3LnUAABiqLA
|
||||||
|
cRySk1NIf8AfJYr82vz8gvebm5vlqfI/8whmra9eRZHUlfWr8/UKQcHrG4P7
|
||||||
|
fgu6736O8WAQoyE+6A2K+y43fswpqgJFUUCSJAKBAF4oWE7H2mw5MdYZ9XV1
|
||||||
|
dVMWOiVAWnHVLoalPtpcvMyk1emIPo8fw333EAqOIMGRiI5Or8Dzwo3zpw+e
|
||||||
|
VkTp5YbGS7wsSwAAgiAQDAZRuGIVazZbVg54+/6kquqkF/4pgLkv/daassFZ
|
||||||
|
rzPoj/1gU6FeISmIAo+xARf8wz7Y7QkYGiWF7r6BdoTUjQBQWlreqKjKlsuN
|
||||||
|
lwRe4EEQBGRZBs/zWP3dIlar0W48/cbJN6cFSC6u+oUE8aHdbluzbfOLBgUE
|
||||||
|
HDFa9Dy4De/gIOLj4zE0RgmdPQMucHjhwdVyfzj21b2/rIeCbZ9cucxzHAea
|
||||||
|
pr+BWPXiGg1FMz89+ftjB54E+KYtKcXOFayG+Shzfpo5KyMFM/QUZkZpce7j
|
||||||
|
ZnR29SAu1gqBskht7b0u8FgaKR5px08e3UaoxHurV69lWYZFIBDA4OAgHA4H
|
||||||
|
Gq9c5kReth84cGD4qQ6oUFfF2WJMq5fOQ0aSGWkzTTjXeB2dj3pgNppA6qy4
|
||||||
|
19E3KhBS0VTiAFCyZ/8HJE3tvHq1UQhxIfj9fng8HgQCAURFRckkqSya4giU
|
||||||
|
Ti1Dhkw6Gl39AZy58AU6H3aAZjSITUhFa1t3iB/zbu2pP+TDE/8REd2kAWj2
|
||||||
|
7N73Z57jS5qbPxWioqOQnp4Og9GAkZFhMhQS2yKDKAAsAL0qjHk5rePnoDTa
|
||||||
|
UU5C14M2CLyApJS56Hb7BZ+3/2JPk/MvALQANBNx5IQoC0A/4QYAhqtXm1x5
|
||||||
|
eTked797+YCnX3C57knDwyOHXv/1b65P6BIAFAKAZSKp1rboJytNM+fXLl2c
|
||||||
|
qeUD/QCjh0IZ8OVXt8f7/vnW93hf5yAALsLlCZciimEBMOG51WolsrOzo9vb
|
||||||
|
23u7uroCAAQA4sTIEwBMYQAAGtviHUUGW9pRs9kgkxRDDfv85FjPjdcGWz78
|
||||||
|
WzhowrmIuRwhTE/AhKtUASgRoOEcQrgDRASxDgBjTMyKNiYsWQiS1Ad7W26M
|
||||||
|
PrrmiahWiOiAOJE88h6QE2PY1QiI8PyxgMkuU3iMfK9ikgTf1v4DrpeFJVeZ
|
||||||
|
L6EAAAAASUVORK5CYII=
|
||||||
|
====
|
||||||
|
</binary>
|
||||||
|
<binary content-type="image/png" id="books.png">
|
||||||
|
iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/
|
||||||
|
AP+gvaeTAAAACXBIWXMAAA9rAAAPawHzS2yFAAAAB3RJTUUH1wIFECMDtXeg
|
||||||
|
zgAABUNJREFUWMPVVmtsU2UYfr5zabt2W3e6nXYr3aVjY2zDbtxHwGG4GI3B
|
||||||
|
amJi9A8STfSX0fhT/Gc0Uf/AfxMkMcSoQMVIgAUwoKJmsBUBGSuMyVjXrlvv
|
||||||
|
PT23zx+udB0bO7olxDc5Oed833vyPO/zXr4DGDTR528Sff6qedbNC6zXiD7/
|
||||||
|
gXnWiejzv114ZwyCr7ay0iUHN7V7LrjJbDkO4NU563aeKCcFU+p534ZNZPae
|
||||||
|
yWz5TBBd+wvvnAFwbxmbP7O22ebSNPMhwda7I5uTbjAMa0/y1j2dW55Zf+n0
|
||||||
|
0ROz/G08Ub7vWMFsqK4SEYmyP2/cuu08ADqZr9pUv27HzlR0NGqIgOjzr7Aw
|
||||||
|
+b5ub5nHXmkDAKtDsL9FKcWfYcC76mnkVE6f5W/hiHqsrRbbVrgEAECDp7YH
|
||||||
|
QM+diAKPuxdZ3VaCwT0C3Glm5DO+JkuzYC8v2bsZpqho3Y1EjgGRJsiMP88S
|
||||||
|
7atWp76rwV1T4j86qYDWbYVE7AClixMQfX7BRORTa+r59hqhomRvKKyhvGUX
|
||||||
|
EhIHKRlBdvg0MTOUUyl/eGWNusfrEUtyPhZToIibIbMOUJ0+hMXNA17BE+WH
|
||||||
|
Tg/X7aqxl+yFJlSUNe9AUjYjn45BGjmL9a2VCN5JfypYFdPKerHEPzytICes
|
||||||
|
h2pyQdf0eZVm5oCXcUT9rt1NeuqcpZ11J6KAb9yOlGJFPhNH9nYf1nrLcHdS
|
||||||
|
h92imVY1iiCkGHwkoSJV0QXN6oG2AHgJAdHnN3FE/batlj7lqXU8lEPG8yQy
|
||||||
|
eiXkXBLp4T50N5pwbwrQ8km0NdWUgMdSKqYtHaAVXqiq9sguY4oP+qEWUX+2
|
||||||
|
0V2NuTnUXT3IEQFyLo3kUB+6GhhIGo9YPIN2rwiGKQqZyGgYUz1ghVYoirro
|
||||||
|
jCkq4GneBktp5OG4Cs21GaTcA1nKIj7UB5+HorLcClWjcHdsRSiiQ5sprkhC
|
||||||
|
xX29HozZjrysGpqwD4pwVVsbnljzIvpOBkDT98GUCajyboacikNTZEzfPIs1
|
||||||
|
dQqqKostubO3BwzXi3PnL0DKZWCvb0STUIfQjUGjE75IgBCCHl8zdbveIGOx
|
||||||
|
LKaSWYSjCSSnJzEx3IcOZxbVVaUtSQCs9rphr3wO45NphKcyiKcl/Bub04YE
|
||||||
|
PMdQCwcQXQdAoKkqcfIxiI7KEs9UTp/1FaGFIizcjBJY+DAi/1wmiwW8eyPG
|
||||||
|
YgooAJ0CoQkFcvlKzB0rszvhPyowD0OGxb69r+C3/iAGBwZAwcDV1YZsNg1Q
|
||||||
|
LNkWJQAC8ByDLes60dTYiHAsg/FYGplsBsthzFI+po+bAB4/Afr/SwHHsVDk
|
||||||
|
nLw8ClAAIIZ5cCwDLR7KT4yG9i0PAUIoIcbGDssyQPovZeTa7y9Hg4EzSyZA
|
||||||
|
AJ0AuqE8MwSsNK6Frv6yNxoMBJZcAzMTj1KDviZlkg4PXHwzOnj8yBKLkBTk
|
||||||
|
pkaJltE4vXXlx3ciA8c+X3IXkJmDp1iEC4tACGAlKdy6fG7/xJWjB5ehDQlA
|
||||||
|
jEYO2NgcbvWf/Xi8/5uPlnYWFCKfB3whNnJmCsO3rx1U5Pz7hgcRpXTesqK6
|
||||||
|
TnN59WFwqpPRe+OMNudfX5WzdPxu6HBeyr4bDQYWVYwtPOg2D08t9p3VDoHk
|
||||||
|
JAXpnIJsJoXr/Rc/Gbx6Q6xx1zt4nicZSUE8kcDVX88d+WPwypeRhLTd4XQj
|
||||||
|
rwGjI7eVyxdOfa0q8uvRYEA1qu4Dc3a9sLuls/tDp6tubVaSrg8F+z8Y+enw
|
||||||
|
CdHnLzeZLe81tLS/xDCMPjJ07Qs5Lx2IBgOa6PN3EkJeY1jOpqnKaQABI5EX
|
||||||
|
7G/d4Snob6JgdQAAAABJRU5ErkJggg==
|
||||||
|
====
|
||||||
|
</binary>
|
||||||
|
<binary content-type="image/png" id="addbook.png">
|
||||||
|
iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/
|
||||||
|
AP+gvaeTAAAACXBIWXMAAA+XAAAPlwEpEhtWAAAAB3RJTUUH1wIFEDYsKRN7
|
||||||
|
gwAABC5JREFUWMO1V11IW2cYfr6Tk5MTE40ajkm0xVbbatkaFUY7xoadbWGF
|
||||||
|
UZlMZOxijIErbHRXg93uYtdju2yvynq1tWyR4XBjjMFaxsQiapuqtNRqJelJ
|
||||||
|
NMbEnJyf791FjtmqVZMYHzgf5IHzvs/3fu/3nDcOlAkl3H/FE+ikjfjs0y38
|
||||||
|
K55A55GN+OxiOfGEMpN/Uu/MfC0LWmgLf9IfbBkF0FHuhsQykn/QVJP7NnxM
|
||||||
|
EVZW09eavW/05XUjZsJ1CErbYLC9R0nGbuFABCjh/nf9cu5auL1RkJxOBJv8
|
||||||
|
SrDJf0UzOOZSjfAcOQ1N11AJhBKSX2xw5W50HWtwSpKzyOsmYW7VB++R16Dl
|
||||||
|
LVQKYY/kvT4p90N3e71LdklF3rAIs0kP6tpeR24fyXcVoIT7T9c6tUh3e53H
|
||||||
|
7XYVeYsTHqgy6tp7kdU49gthh+SnPKI22t3m9Xlq3EWecyAad8J3/E1kqpD8
|
||||||
|
hQKUcP9xtyM/1n3U46/11hR5IiAaF+A7cQ7rOUK1IGwn+M/hVjnkq/M8x88s
|
||||||
|
6vCdOI90DlXFNgFNh9qCMa0BeYOKZx5d5nAFXobBZFQb23wgGApg8J2PcCsy
|
||||||
|
irS6BCbXo7nnFOJP5nbehZiFt/U7dLXe/7jmU+mCTY+NDOvXKzKiw4F6Ghq4
|
||||||
|
xJaTGcSTGcSSWex26kzQ0XEyi/Ndn58h0Jl0dhXf3/4mAeB6hdeQgTFGAmME
|
||||||
|
xggMxPYIJIkyLGcWCXoAr9tXeQ8QbZXy37o3mB2DV8+KSwIVl4JfkFWyarHi
|
||||||
|
jIyDgQBGYIKxmdpeLQAQL12V3FvfHBnWc/sS4A2NorXzT7js2Mxe6r0dILsK
|
||||||
|
gsAQaGy5TKDLm5UhEFLpJACd7SqgFI87Fx6C4lfAwQuhiYPAkTGTBVGSgYuv
|
||||||
|
DoGDg2DBIhMCEzF25yaA7H6PgLBuPMPTtTuwyLD3xsHJAocFTiYsMsFhwiID
|
||||||
|
nAoia0UFGk+X0AO0twCDNITkTlhkwIIJToUnqS8gZSbQLL9kizJh2aJedMMq
|
||||||
|
qgA3vfjt9u/Fa0cEiA5CsIWjtVMBAGhZA+N3x1cAxOwSEQFEfLuEsntgQz2L
|
||||||
|
DfVs8bfsciAT+0MNvP+Lsnn/LTLBLboxMqx/VoEPlP6plV0i1hYmli3X+ECh
|
||||||
|
E6yigAM3IpckYn1pMhFbmL9wtPfeQyJedEC+LwElFECSRORiM2vLj6JvqVOR
|
||||||
|
+wDItEwIphu11IJ8GRNy2T0gOUXoidns4vz02+pUZMKmtdXV1M3xvyeZ7U0M
|
||||||
|
wHTVrdgpOpBX57SF6N0BdSry1//sNQVgsFpD6Y5FsNYeG49m/nlPnYr8emAT
|
||||||
|
kWGY4Px5DYLAkNc2rIf3Jj5UpyI/VXMkc2wl8mKjvpLjfc0thwVdN5HVLSw9
|
||||||
|
ntPnp8e/eDb549Vqz4Rsh/8FfY1NoS/9gVBPKpmIqstPvqr2zjfxL9Ru5qeZ
|
||||||
|
IAUkAAAAAElFTkSuQmCC
|
||||||
|
====
|
||||||
|
</binary>
|
||||||
|
</FictionBook>
|
|
@ -67,11 +67,12 @@
|
||||||
<node name="keyDelay" value="Delay Between Accepted Key Pressings"/>
|
<node name="keyDelay" value="Delay Between Accepted Key Pressings"/>
|
||||||
</node>
|
</node>
|
||||||
<node name="Language" value="Language">
|
<node name="Language" value="Language">
|
||||||
<node name="autoDetect" value="Detect Language and Encoding Automatically"/>
|
<node name="autoDetect" value="Automatically Detect Language and Encoding"/>
|
||||||
<node name="defaultLanguage" value="Default Language"/>
|
<node name="defaultLanguage" value="Default Language"/>
|
||||||
<node name="defaultEncodingSet" value="Default Encoding Set"/>
|
<node name="defaultEncodingSet" value="Default Encoding Set"/>
|
||||||
<node name="defaultEncoding" value="Default Encoding"/>
|
<node name="defaultEncoding" value="Default Encoding"/>
|
||||||
<node name="chineseBreakAtAnyPosition" value="In Chinese Break Line at Any Position"/>
|
<node name="useWindows1252Hack" value="Use windows-1252 instead of iso-8859-1"/>
|
||||||
|
<node name="chineseBreakAtAnyPosition" value="For Chinese Break Line at Any Position"/>
|
||||||
</node>
|
</node>
|
||||||
<node name="Indicator" value="Indicator">
|
<node name="Indicator" value="Indicator">
|
||||||
<node name="show" value="Show Position Indicator"/>
|
<node name="show" value="Show Position Indicator"/>
|
||||||
|
@ -102,6 +103,9 @@
|
||||||
<node name="linesToScroll" value="Lines to Scroll"/>
|
<node name="linesToScroll" value="Lines to Scroll"/>
|
||||||
<node name="percentToScroll" value="Percent to Scroll"/>
|
<node name="percentToScroll" value="Percent to Scroll"/>
|
||||||
</node>
|
</node>
|
||||||
|
<node name="Selection" value="Selection">
|
||||||
|
<node name="enableSelection" value="Enable Text Selection"/>
|
||||||
|
</node>
|
||||||
<node name="Margins" value="Margins">
|
<node name="Margins" value="Margins">
|
||||||
<node name="left" value="Left Margin"/>
|
<node name="left" value="Left Margin"/>
|
||||||
<node name="right" value="Right Margin"/>
|
<node name="right" value="Right Margin"/>
|
||||||
|
@ -216,6 +220,11 @@
|
||||||
<node name="choice" value="Use Browser"/>
|
<node name="choice" value="Use Browser"/>
|
||||||
<node name="command" value="Command to Execute"/>
|
<node name="command" value="Command to Execute"/>
|
||||||
</node>
|
</node>
|
||||||
|
<node name="Maemo" value="Maemo">
|
||||||
|
<node name="keyActionOnRelease" value="Key Action on Release, Not on Press"/>
|
||||||
|
<node name="minStylusPressure" value="Minimal Stylus Pressure"/>
|
||||||
|
<node name="maxStylusPressure" value="Maximal Stylus Pressure"/>
|
||||||
|
</node>
|
||||||
</node>
|
</node>
|
||||||
</node>
|
</node>
|
||||||
<node name="InfoDialog">
|
<node name="InfoDialog">
|
||||||
|
|
|
@ -71,6 +71,7 @@
|
||||||
<node name="defaultLanguage" value="Oletuskieli"/>
|
<node name="defaultLanguage" value="Oletuskieli"/>
|
||||||
<node name="defaultEncodingSet" value="Oletusmerkistöalue"/>
|
<node name="defaultEncodingSet" value="Oletusmerkistöalue"/>
|
||||||
<node name="defaultEncoding" value="Oletusmerkistö"/>
|
<node name="defaultEncoding" value="Oletusmerkistö"/>
|
||||||
|
<node name="useWindows1252Hack" value="Use windows-1252 instead of iso-8859-1" toBeTranslated="true"/>
|
||||||
<node name="chineseBreakAtAnyPosition" value="Katkaise Kiinaksi oleva teksti mistä tahansa kohdasta"/>
|
<node name="chineseBreakAtAnyPosition" value="Katkaise Kiinaksi oleva teksti mistä tahansa kohdasta"/>
|
||||||
</node>
|
</node>
|
||||||
<node name="Indicator" value="Ilmaisin">
|
<node name="Indicator" value="Ilmaisin">
|
||||||
|
@ -102,6 +103,9 @@
|
||||||
<node name="linesToScroll" value="Rivien määrä"/>
|
<node name="linesToScroll" value="Rivien määrä"/>
|
||||||
<node name="percentToScroll" value="Vieritysprosentti"/>
|
<node name="percentToScroll" value="Vieritysprosentti"/>
|
||||||
</node>
|
</node>
|
||||||
|
<node name="Selection" value="Valinta">
|
||||||
|
<node name="enableSelection" value="Enable Text Selection" toBeTranslated="true"/>
|
||||||
|
</node>
|
||||||
<node name="Margins" value="Reunus">
|
<node name="Margins" value="Reunus">
|
||||||
<node name="left" value="Vasenreunus"/>
|
<node name="left" value="Vasenreunus"/>
|
||||||
<node name="right" value="Oikeareunus"/>
|
<node name="right" value="Oikeareunus"/>
|
||||||
|
@ -216,6 +220,11 @@
|
||||||
<node name="choice" value="Käytä selainta"/>
|
<node name="choice" value="Käytä selainta"/>
|
||||||
<node name="command" value="Suorituskomento"/>
|
<node name="command" value="Suorituskomento"/>
|
||||||
</node>
|
</node>
|
||||||
|
<node name="Maemo" value="Maemo">
|
||||||
|
<node name="keyActionOnRelease" value="Key Action on Release, Not on Press" toBeTranslated="true"/>
|
||||||
|
<node name="minStylusPressure" value="Minimal Stylus Pressure" toBeTranslated="true"/>
|
||||||
|
<node name="maxStylusPressure" value="Maximal Stylus Pressure" toBeTranslated="true"/>
|
||||||
|
</node>
|
||||||
</node>
|
</node>
|
||||||
</node>
|
</node>
|
||||||
<node name="InfoDialog">
|
<node name="InfoDialog">
|
||||||
|
|
|
@ -68,11 +68,12 @@
|
||||||
<node name="keyDelay" value="Délai entre appui sur les touches"/>
|
<node name="keyDelay" value="Délai entre appui sur les touches"/>
|
||||||
</node>
|
</node>
|
||||||
<node name="Language" value="Langue">
|
<node name="Language" value="Langue">
|
||||||
<node name="autoDetect" value="Detect Language and Encoding Automatically" toBeTranslated="true"/>
|
<node name="autoDetect" value="Detecter la langue et l'encodage automatiquement"/>
|
||||||
<node name="defaultLanguage" value="Langue par défaut "/>
|
<node name="defaultLanguage" value="Langue par défaut "/>
|
||||||
<node name="defaultEncodingSet" value="Ensemble d'encodages par défaut"/>
|
<node name="defaultEncodingSet" value="Ensemble d'encodages par défaut"/>
|
||||||
<node name="defaultEncoding" value="Encodage par défaut"/>
|
<node name="defaultEncoding" value="Encodage par défaut"/>
|
||||||
<node name="chineseBreakAtAnyPosition" value="In Chinese Break Line at Any Position" toBeTranslated="true"/>
|
<node name="useWindows1252Hack" value="Use windows-1252 instead of iso-8859-1" toBeTranslated="true"/>
|
||||||
|
<node name="chineseBreakAtAnyPosition" value="En chinois, passer à la ligne n'importe où"/>
|
||||||
</node>
|
</node>
|
||||||
<node name="Indicator" value="Indicateur">
|
<node name="Indicator" value="Indicateur">
|
||||||
<node name="show" value="Montrer l'indicateur de position"/>
|
<node name="show" value="Montrer l'indicateur de position"/>
|
||||||
|
@ -103,6 +104,9 @@
|
||||||
<node name="linesToScroll" value="Lignes à défiler"/>
|
<node name="linesToScroll" value="Lignes à défiler"/>
|
||||||
<node name="percentToScroll" value="Pourcentage à défiler"/>
|
<node name="percentToScroll" value="Pourcentage à défiler"/>
|
||||||
</node>
|
</node>
|
||||||
|
<node name="Selection" value="Sélection">
|
||||||
|
<node name="enableSelection" value="Enable Text Selection" toBeTranslated="true"/>
|
||||||
|
</node>
|
||||||
<node name="Margins" value="Marges">
|
<node name="Margins" value="Marges">
|
||||||
<node name="left" value="Marge gauche"/>
|
<node name="left" value="Marge gauche"/>
|
||||||
<node name="right" value="Marge droite"/>
|
<node name="right" value="Marge droite"/>
|
||||||
|
@ -217,6 +221,11 @@
|
||||||
<node name="choice" value="Utiliser le navigateur"/>
|
<node name="choice" value="Utiliser le navigateur"/>
|
||||||
<node name="command" value="Commande à exécuter"/>
|
<node name="command" value="Commande à exécuter"/>
|
||||||
</node>
|
</node>
|
||||||
|
<node name="Maemo" value="Maemo">
|
||||||
|
<node name="keyActionOnRelease" value="Key Action on Release, Not on Press" toBeTranslated="true"/>
|
||||||
|
<node name="minStylusPressure" value="Minimal Stylus Pressure" toBeTranslated="true"/>
|
||||||
|
<node name="maxStylusPressure" value="Maximal Stylus Pressure" toBeTranslated="true"/>
|
||||||
|
</node>
|
||||||
</node>
|
</node>
|
||||||
</node>
|
</node>
|
||||||
<node name="InfoDialog">
|
<node name="InfoDialog">
|
||||||
|
@ -227,7 +236,7 @@
|
||||||
<node name="title" value="Titre"/>
|
<node name="title" value="Titre"/>
|
||||||
<node name="authorDisplayName" value="Auteur (nom affiché)"/>
|
<node name="authorDisplayName" value="Auteur (nom affiché)"/>
|
||||||
<node name="authorSortKey" value="Auteur (clef de tri)"/>
|
<node name="authorSortKey" value="Auteur (clef de tri)"/>
|
||||||
<node name="language" value="Language" toBeTranslated="true"/>
|
<node name="language" value="Langue"/>
|
||||||
<node name="encodingSet" value="Ensemble d'encodages"/>
|
<node name="encodingSet" value="Ensemble d'encodages"/>
|
||||||
<node name="encoding" value="Encodage"/>
|
<node name="encoding" value="Encodage"/>
|
||||||
</node>
|
</node>
|
||||||
|
@ -274,7 +283,7 @@
|
||||||
</node>
|
</node>
|
||||||
<node name="waitMessage">
|
<node name="waitMessage">
|
||||||
<node name="loadingBook" value="Chargement du livre. Veuillez patienter..."/>
|
<node name="loadingBook" value="Chargement du livre. Veuillez patienter..."/>
|
||||||
<node name="loadingBookList" value="Chargement de la liste des livres. Veuillez patitenter..."/>
|
<node name="loadingBookList" value="Chargement de la liste des livres. Veuillez patienter..."/>
|
||||||
</node>
|
</node>
|
||||||
</node>
|
</node>
|
||||||
<node name="style">
|
<node name="style">
|
||||||
|
|
337
data/resources/application/it.xml
Normal file
337
data/resources/application/it.xml
Normal file
|
@ -0,0 +1,337 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<resources>
|
||||||
|
<node name="menu">
|
||||||
|
<node name="bookInfo" value="Informazioni Libro..."/>
|
||||||
|
<node name="toc" value="Indice"/>
|
||||||
|
<node name="library" value="Biblioteca">
|
||||||
|
<node name="open" value="Apri"/>
|
||||||
|
<node name="previous" value="Libro Precedente"/>
|
||||||
|
<node name="recent" value="Recenti"/>
|
||||||
|
<node name="addBook" value="Aggiungi Libro..."/>
|
||||||
|
<node name="about" value="Informazioni su FBReader"/>
|
||||||
|
</node>
|
||||||
|
<node name="navigate" value="Navigazione">
|
||||||
|
<node name="gotoStartOfDocument" value="Vai all'Inizio del Documento"/>
|
||||||
|
<node name="gotoStartOfSection" value="Vai all'Inizio di Sezione"/>
|
||||||
|
<node name="gotoEndOfSection" value="Vai alla Fine di Sezione"/>
|
||||||
|
<node name="gotoNextTOCItem" value="Vai al Successivo Elemento dell'Indice"/>
|
||||||
|
<node name="gotoPreviousTOCItem" value="Vai al Precedente Elemento dell'Indice"/>
|
||||||
|
<node name="goBack" value="Vai Indietro"/>
|
||||||
|
<node name="goForward" value="Vai Avanti"/>
|
||||||
|
</node>
|
||||||
|
<node name="selection" value="Selezione">
|
||||||
|
<node name="clipboard" value="Copia negli Appunti"/>
|
||||||
|
<node name="dictionary" value="Apri in Dizionario"/>
|
||||||
|
<node name="clear" value="Deseleziona"/>
|
||||||
|
</node>
|
||||||
|
<node name="search" value="Trova">
|
||||||
|
<node name="find" value="Trova Testo..."/>
|
||||||
|
<node name="next" value="Trova Successivo"/>
|
||||||
|
<node name="previous" value="Trova Precedente"/>
|
||||||
|
</node>
|
||||||
|
<node name="view" value="Visualizzazione">
|
||||||
|
<node name="rotate" value="Ruota Schermo"/>
|
||||||
|
<node name="fullScreen" value="A Tutto Schermo"/>
|
||||||
|
<node name="toggleIndicator" value="Alterna Indicatore"/>
|
||||||
|
</node>
|
||||||
|
<node name="settings" value="Preferenze..."/>
|
||||||
|
<node name="close" value="Chiudi"/>
|
||||||
|
</node>
|
||||||
|
<node name="toolbar">
|
||||||
|
<node name="books" value="Mostra Albero Biblioteca"/>
|
||||||
|
<node name="history" value="Mostra Elenco Libri Recenti"/>
|
||||||
|
<node name="addbook" value="Aggiungi File alla Biblioteca"/>
|
||||||
|
<node name="home" value="Vai all'Inizio del Testo"/>
|
||||||
|
<node name="leftarrow" value="Vai Indietro"/>
|
||||||
|
<node name="rightarrow" value="Vai Avanti"/>
|
||||||
|
<node name="contents" value="Indice"/>
|
||||||
|
<node name="find" value="Trova Testo"/>
|
||||||
|
<node name="findnext" value="Trova Successivo"/>
|
||||||
|
<node name="findprev" value="Trova Precedente"/>
|
||||||
|
<node name="bookinfo" value="Mostra Finestra Informazioni Libro"/>
|
||||||
|
<node name="settings" value="Mostra Finestra Preferenze"/>
|
||||||
|
<node name="rotatescreen" value="Ruota Testo"/>
|
||||||
|
<node name="help" value="Informazioni su FBReader"/>
|
||||||
|
</node>
|
||||||
|
<node name="dialog">
|
||||||
|
<node name="button">
|
||||||
|
<node name="go" value="&Vai!"/>
|
||||||
|
</node>
|
||||||
|
<node name="OptionsDialog">
|
||||||
|
<node name="title" value="FBReader - Opzioni"/>
|
||||||
|
<node name="tab">
|
||||||
|
<node name="General" value="Generale">
|
||||||
|
<node name="bookPath" value="Percorso Libri"/>
|
||||||
|
<node name="lookInSubdirectories" value="Cerca Libri in Sottocartelle"/>
|
||||||
|
<node name="recentListSize" value="Lunghezza Elenco Libri Recenti"/>
|
||||||
|
<node name="keyDelay" value="Ritardo Tra Pressione Tasti Accettati"/>
|
||||||
|
</node>
|
||||||
|
<node name="Language" value="Lingua">
|
||||||
|
<node name="autoDetect" value="Riconosci Lingua e Codifica Automaticamente"/>
|
||||||
|
<node name="defaultLanguage" value="Lingua Predefinita"/>
|
||||||
|
<node name="defaultEncodingSet" value="Insieme Predefinito di Codifica"/>
|
||||||
|
<node name="defaultEncoding" value="Codifica Predefinita"/>
|
||||||
|
<node name="useWindows1252Hack" value="Use windows-1252 instead of iso-8859-1" toBeTranslated="true"/>
|
||||||
|
<node name="chineseBreakAtAnyPosition" value="In Cinese Interrompi Riga in Qualsiasi Posizione"/>
|
||||||
|
</node>
|
||||||
|
<node name="Indicator" value="Indicatore">
|
||||||
|
<node name="show" value="Mostra Indicatore di Posizione"/>
|
||||||
|
<node name="height" value="Altezza Indicatore"/>
|
||||||
|
<node name="offset" value="Distanza dal Testo"/>
|
||||||
|
<node name="pageNumber" value="Mostra Posizione come Numero"/>
|
||||||
|
<node name="time" value="Mostra Orario"/>
|
||||||
|
<node name="fontSize" value="Dimensioni Carattere"/>
|
||||||
|
<node name="tocMarks" value="Mostra Segni Indice"/>
|
||||||
|
<node name="navigation" value="Abilita Navigazione"/>
|
||||||
|
</node>
|
||||||
|
<node name="Scrolling" value="Scorrimento">
|
||||||
|
<node name="optionsFor" value="Opzioni per">
|
||||||
|
<node name="large" value="Scorrimenti Grandi"/>
|
||||||
|
<node name="small" value="Scorrimenti Piccoli"/>
|
||||||
|
<node name="mouse" value="Scorrimenti con Mouse"/>
|
||||||
|
<node name="finger" value="Scorrimenti con Tocco Dito"/>
|
||||||
|
</node>
|
||||||
|
<node name="delay" value="Ritardo tra Scorrimenti, msec"/>
|
||||||
|
<node name="mode" value="Modalità Scorrimento">
|
||||||
|
<node name="noOverlapping" value="Non Sovrapporre"/>
|
||||||
|
<node name="keepLines" value="Mantieni Righe"/>
|
||||||
|
<node name="scrollLines" value="Scorri Righe"/>
|
||||||
|
<node name="scrollPercentage" value="Scorri Percentuale"/>
|
||||||
|
<node name="disable" value="Disabilita"/>
|
||||||
|
</node>
|
||||||
|
<node name="linesToKeep" value="Righe da Mantenere"/>
|
||||||
|
<node name="linesToScroll" value="Righe da Scorrere"/>
|
||||||
|
<node name="percentToScroll" value="Percentuale da Scorrere"/>
|
||||||
|
</node>
|
||||||
|
<node name="Selection" value="Selezione">
|
||||||
|
<node name="enableSelection" value="Enable Text Selection" toBeTranslated="true"/>
|
||||||
|
</node>
|
||||||
|
<node name="Margins" value="Margini">
|
||||||
|
<node name="left" value="Margine Sinistro"/>
|
||||||
|
<node name="right" value="Margine Destro"/>
|
||||||
|
<node name="top" value="Margine Superiore"/>
|
||||||
|
<node name="bottom" value="Margine Inferiore"/>
|
||||||
|
</node>
|
||||||
|
<node name="Format" value="Formato">
|
||||||
|
<node name="optionsFor" value="Opzioni per"/>
|
||||||
|
<node name="lineSpacing" value="Spaziatura Righe">
|
||||||
|
<node name="unchanged" value="<invariata>"/>
|
||||||
|
</node>
|
||||||
|
<node name="firstLineIndent" value="Rientro Prima Riga"/>
|
||||||
|
<node name="alignment" value="Allineamento">
|
||||||
|
<node name="left" value="Sinistra"/>
|
||||||
|
<node name="right" value="Destra"/>
|
||||||
|
<node name="center" value="Centrato"/>
|
||||||
|
<node name="justify" value="Giustificato"/>
|
||||||
|
<node name="unchanged" value="<invariato>"/>
|
||||||
|
</node>
|
||||||
|
<node name="spaceBefore" value="Spazio Prima"/>
|
||||||
|
<node name="spaceAfter" value="Spazio Dopo"/>
|
||||||
|
<node name="leftIndent" value="Rientro a Sinistra"/>
|
||||||
|
<node name="rightIndent" value="Rientro a Destra"/>
|
||||||
|
</node>
|
||||||
|
<node name="Styles" value="Stili">
|
||||||
|
<node name="optionsFor" value="Options for"/>
|
||||||
|
<node name="fontFamily" value="Famiglia Caratteri">
|
||||||
|
<node name="unchanged" value="<invariata>"/>
|
||||||
|
</node>
|
||||||
|
<node name="fontSize" value="Dimensioni"/>
|
||||||
|
<node name="fontSizeDifference" value="Differenza di Dimensioni"/>
|
||||||
|
<node name="bold" value="Grassetto"/>
|
||||||
|
<node name="italic" value="Corsivo"/>
|
||||||
|
<node name="allowHyphenations" value="Permetti Sillabazione"/>
|
||||||
|
<node name="autoHyphenations" value="Sillabazione Automatica"/>
|
||||||
|
</node>
|
||||||
|
<node name="Rotation" value="Rotazione">
|
||||||
|
<node name="direction" value="Tipo di Rotazione">
|
||||||
|
<node name="disabled" value="Disabilitata"/>
|
||||||
|
<node name="clockwise" value="Oraria 90 Gradi"/>
|
||||||
|
<node name="counterclockwise" value="Antioraria 90 Gradi"/>
|
||||||
|
<node name="180" value="180 Gradi"/>
|
||||||
|
<node name="cycle" value="Cicla Tra Tutte le 4 Direzioni"/>
|
||||||
|
</node>
|
||||||
|
</node>
|
||||||
|
<node name="Colors" value="Colori">
|
||||||
|
<node name="colorFor" value="Colore di">
|
||||||
|
<node name="background" value="Sfondo"/>
|
||||||
|
<node name="selectionBackground" value="Sfondo della Selezione"/>
|
||||||
|
<node name="text" value="Testo Normale"/>
|
||||||
|
<node name="internalLink" value="Testo Collegamento Interno"/>
|
||||||
|
<node name="externalLink" value="Testo Collegamento Esterno"/>
|
||||||
|
<node name="highlighted" value="Testo Evidenziato"/>
|
||||||
|
<node name="treeLines" value="Linee Albero"/>
|
||||||
|
<node name="indicator" value="Indicatore Posizione"/>
|
||||||
|
</node>
|
||||||
|
</node>
|
||||||
|
<node name="Keys" value="Tasti">
|
||||||
|
<node name="grabSystemKeys" value="Intercetta Tasti di Sistema"/>
|
||||||
|
<node name="separate" value="Funzione Tasti Dipendente dall'Orientamento"/>
|
||||||
|
<node name="orientation" value="Orientamento"/>
|
||||||
|
<node name="action">
|
||||||
|
<node name="none" value="Nessuno"/>
|
||||||
|
<node name="showLibrary" value="Mostra Biblioteca"/>
|
||||||
|
<node name="showRecent" value="Mostra Libri Recenti"/>
|
||||||
|
<node name="previousBook" value="Apri Libro Precedente"/>
|
||||||
|
<node name="toc" value="Mostra Indice"/>
|
||||||
|
<node name="gotoHome" value="Vai alla Pagina Principale"/>
|
||||||
|
<node name="gotoSectionStart" value="Vai all'Inizio di Sezione"/>
|
||||||
|
<node name="gotoSectionEnd" value="Vai alla Fine di Seziona"/>
|
||||||
|
<node name="nextTOCSection" value="Vai alla Sezione Successiva dell'Indice"/>
|
||||||
|
<node name="previousTOCSection" value="Vai alla Sezione Precedente dell'Indice"/>
|
||||||
|
<node name="largeScrollForward" value="Scorrimento Grande in Avanti"/>
|
||||||
|
<node name="largeScrollBackward" value="Scorrimento Grande Indietro"/>
|
||||||
|
<node name="smallScrollForward" value="Scorrimento Piccolo in Avanti"/>
|
||||||
|
<node name="smallScrollBackward" value="Scorrimento Piccolo Indietro"/>
|
||||||
|
<node name="undo" value="Annulla"/>
|
||||||
|
<node name="redo" value="Ripristina"/>
|
||||||
|
<node name="copyToClipboard" value="Copia Testo Selezionato negli Appunti"/>
|
||||||
|
<node name="openInDictionary" value="Apri Testo Selezionato in Dizionario"/>
|
||||||
|
<node name="clearSelection" value="Deseleziona"/>
|
||||||
|
<node name="search" value="Trova"/>
|
||||||
|
<node name="findPrevious" value="Trova Precedente"/>
|
||||||
|
<node name="findNext" value="Trova Successivo"/>
|
||||||
|
<node name="increaseFont" value="Ingrandisci Carattere"/>
|
||||||
|
<node name="decreaseFont" value="Riduci Carattere"/>
|
||||||
|
<node name="toggleIndicator" value="Alterna Indicatore di Posizione"/>
|
||||||
|
<node name="toggleFullscreen" value="Alterna Modalità Schermo Intero"/>
|
||||||
|
<node name="onFullscreen" value="Passa a Modalità Schermo Intero"/>
|
||||||
|
<node name="rotate" value="Ruota Schermo"/>
|
||||||
|
<node name="preferences" value="Mostra Finestra Opzioni"/>
|
||||||
|
<node name="bookInfo" value="Mostra Finestra Informazioni Libro"/>
|
||||||
|
<node name="addBook" value="Aggiungi Libro"/>
|
||||||
|
<node name="cancel" value="Annulla"/>
|
||||||
|
<node name="quit" value="Esci"/>
|
||||||
|
</node>
|
||||||
|
<node name="quitOnCancel" value="Esci dall'Applicazione su Annullamento"/>
|
||||||
|
</node>
|
||||||
|
<node name="Config" value="Configurazione">
|
||||||
|
<node name="autoSave" value="Salva Stato Automaticamente"/>
|
||||||
|
<node name="timeout" value="Intervallo tra Salvataggi, sec"/>
|
||||||
|
</node>
|
||||||
|
<node name="Dictionary" value="Dizionario">
|
||||||
|
<node name="enableIntegration" value="Abilita Integrazione con %s"/>
|
||||||
|
<node name="defaultText" value="Abilita Integrazione con Dizionario"/>
|
||||||
|
<node name="choice" value="Integra con"/>
|
||||||
|
<node name="singleClickOpen" value="Apri con Clic Singolo"/>
|
||||||
|
</node>
|
||||||
|
<node name="Web" value="Web">
|
||||||
|
<node name="enableIntegration" value="Apri Collegamenti Esterni in %s"/>
|
||||||
|
<node name="defaultText" value="Apri Collegamenti Esterni in Browser"/>
|
||||||
|
<node name="choice" value="Usa Browser"/>
|
||||||
|
<node name="command" value="Comando da Eseguire"/>
|
||||||
|
</node>
|
||||||
|
<node name="Maemo" value="Maemo">
|
||||||
|
<node name="keyActionOnRelease" value="Key Action on Release, Not on Press" toBeTranslated="true"/>
|
||||||
|
<node name="minStylusPressure" value="Minimal Stylus Pressure" toBeTranslated="true"/>
|
||||||
|
<node name="maxStylusPressure" value="Maximal Stylus Pressure" toBeTranslated="true"/>
|
||||||
|
</node>
|
||||||
|
</node>
|
||||||
|
</node>
|
||||||
|
<node name="InfoDialog">
|
||||||
|
<node name="title" value="FBReader - Informazioni Libro"/>
|
||||||
|
<node name="tab">
|
||||||
|
<node name="Common" value="Comuni">
|
||||||
|
<node name="file" value="File"/>
|
||||||
|
<node name="title" value="Titolo"/>
|
||||||
|
<node name="authorDisplayName" value="Autore (Nome Mostrato)"/>
|
||||||
|
<node name="authorSortKey" value="Autore (Ordinamento)"/>
|
||||||
|
<node name="language" value="Lingua"/>
|
||||||
|
<node name="encodingSet" value="Insieme di Codifica"/>
|
||||||
|
<node name="encoding" value="Codifica"/>
|
||||||
|
</node>
|
||||||
|
<node name="Series" value="Serie">
|
||||||
|
<node name="seriesTitle" value="Titolo della Serie"/>
|
||||||
|
<node name="bookNumber" value="Libro Numero"/>
|
||||||
|
</node>
|
||||||
|
<node name="Text" value="Testo">
|
||||||
|
<node name="breakType" value="Interrompi Paragrafo a"/>
|
||||||
|
<node name="ignoreIndent" value="Ignora Rientri Inferiori a"/>
|
||||||
|
<node name="buildTOC" value="Crea Indice"/>
|
||||||
|
<node name="emptyLines" value="Righe Vuote Prima di Nuova Sezione"/>
|
||||||
|
</node>
|
||||||
|
<node name="<PRE>" value="<PRE>">
|
||||||
|
<node name="breakType" value="Interrompi Paragrafo a"/>
|
||||||
|
<node name="ignoreIndent" value="Ignora Rientri Inferiori a"/>
|
||||||
|
<node name="buildTOC" value="Crea Indice"/>
|
||||||
|
<node name="emptyLines" value="Righe Vuote Prima di Nuova Sezione"/>
|
||||||
|
</node>
|
||||||
|
</node>
|
||||||
|
</node>
|
||||||
|
<node name="addFileDialog">
|
||||||
|
<node name="title" value="FBReader - Aggiungi Libro alla Biblioteca"/>
|
||||||
|
</node>
|
||||||
|
<node name="textSearchDialog">
|
||||||
|
<node name="title" value="Trova Testo"/>
|
||||||
|
<node name="text" value=""/>
|
||||||
|
<node name="ignoreCase" value="&Ignora maiuscole/minuscole"/>
|
||||||
|
<node name="wholeText" value="In &tutto il testo"/>
|
||||||
|
<node name="backward" value="&All'indietro"/>
|
||||||
|
<node name="currentSection" value="&Solo questa sezione"/>
|
||||||
|
</node>
|
||||||
|
<node name="removeBookBox">
|
||||||
|
<node name="title" value="Elimina Libro"/>
|
||||||
|
<node name="message" value="Elimina Libro "%s" dalla Biblioteca?"/>
|
||||||
|
</node>
|
||||||
|
<node name="openBookErrorBox">
|
||||||
|
<node name="title" value="Errore"/>
|
||||||
|
<node name="message" value="Impossibile aprire: %s"/>
|
||||||
|
</node>
|
||||||
|
<node name="noHelpBox">
|
||||||
|
<node name="title" value="Errore"/>
|
||||||
|
<node name="message" value="Spiacente, file della Guida non trovato"/>
|
||||||
|
</node>
|
||||||
|
<node name="waitMessage">
|
||||||
|
<node name="loadingBook" value="Caricamento libro. Attendere, prego..."/>
|
||||||
|
<node name="loadingBookList" value="Caricamento elenco libri. Attendere, prego..."/>
|
||||||
|
</node>
|
||||||
|
</node>
|
||||||
|
<node name="style">
|
||||||
|
<node name="Base" value="Base"/>
|
||||||
|
<node name="Regular Paragraph" value="Paragrafo Normale"/>
|
||||||
|
<node name="Title" value="Titolo"/>
|
||||||
|
<node name="Section Title" value="Title di Sezione"/>
|
||||||
|
<node name="Poem Title" value="Titolo di Poesia"/>
|
||||||
|
<node name="Subtitle" value="Sottotitolo"/>
|
||||||
|
<node name="Annotation" value="Annozione"/>
|
||||||
|
<node name="Epigraph" value="Epigrafe"/>
|
||||||
|
<node name="Stanza" value="Strofa"/>
|
||||||
|
<node name="Verse" value="Verso"/>
|
||||||
|
<node name="Preformatted text" value="Testo preformattato"/>
|
||||||
|
<node name="Image" value="Immagine"/>
|
||||||
|
<node name="Cite" value="Citazione"/>
|
||||||
|
<node name="Author" value="Autore"/>
|
||||||
|
<node name="Date" value="Data"/>
|
||||||
|
<node name="Internal Hyperlink" value="Collegamento Interno"/>
|
||||||
|
<node name="Footnote" value="Nota"/>
|
||||||
|
<node name="Emphasis" value="Enfasi"/>
|
||||||
|
<node name="Strong" value="Rafforzato"/>
|
||||||
|
<node name="Subscript" value="Pedice"/>
|
||||||
|
<node name="Superscript" value="Apice"/>
|
||||||
|
<node name="Code" value="Codice"/>
|
||||||
|
<node name="StrikeThrough" value="Barrato"/>
|
||||||
|
<node name="Contents Table" value="Tabella di Contenuti"/>
|
||||||
|
<node name="Author in Library" value="Autore in Biblioteca"/>
|
||||||
|
<node name="Book in Library" value="Libro in Biblioteca"/>
|
||||||
|
<node name="Recent Book List" value="Elenco Libri Recenti"/>
|
||||||
|
<node name="Italic" value="Corsivo"/>
|
||||||
|
<node name="Bold" value="Grassetto"/>
|
||||||
|
<node name="Definition" value="Definizione"/>
|
||||||
|
<node name="Definition Description" value="Descrizione di Definizione"/>
|
||||||
|
<node name="Header 1" value="Intestazione 1"/>
|
||||||
|
<node name="Header 2" value="Intestazione 2"/>
|
||||||
|
<node name="Header 3" value="Intestazione 3"/>
|
||||||
|
<node name="Header 4" value="Intestazione 4"/>
|
||||||
|
<node name="Header 5" value="Intestazione 5"/>
|
||||||
|
<node name="Header 6" value="Intestazione 6"/>
|
||||||
|
<node name="External Hyperlink" value="Collegamento Esterno"/>
|
||||||
|
</node>
|
||||||
|
<node name="external">
|
||||||
|
<node name="browser" value="Browser"/>
|
||||||
|
<node name="defaultBrowser" value="Browser Predefinito"/>
|
||||||
|
</node>
|
||||||
|
<node name="mobipocketPlugin">
|
||||||
|
<node name="unknown" value="Errore Sconosciuto"/>
|
||||||
|
<node name="unsupportedCompressionMethod" value="Metodo di Compressione non Supportato"/>
|
||||||
|
<node name="encriptedFile" value="File Protetto da DRM"/>
|
||||||
|
</node>
|
||||||
|
</resources>
|
|
@ -71,6 +71,7 @@
|
||||||
<node name="defaultLanguage" value="Язык по умолчанию"/>
|
<node name="defaultLanguage" value="Язык по умолчанию"/>
|
||||||
<node name="defaultEncodingSet" value="Набор кодировок по умолчанию"/>
|
<node name="defaultEncodingSet" value="Набор кодировок по умолчанию"/>
|
||||||
<node name="defaultEncoding" value="Кодировка по умолчанию"/>
|
<node name="defaultEncoding" value="Кодировка по умолчанию"/>
|
||||||
|
<node name="useWindows1252Hack" value="Use windows-1252 instead of iso-8859-1" toBeTranslated="true"/>
|
||||||
<node name="chineseBreakAtAnyPosition" value="В китайском языке разрыв строки в любом месте"/>
|
<node name="chineseBreakAtAnyPosition" value="В китайском языке разрыв строки в любом месте"/>
|
||||||
</node>
|
</node>
|
||||||
<node name="Indicator" value="Индикатор">
|
<node name="Indicator" value="Индикатор">
|
||||||
|
@ -102,6 +103,9 @@
|
||||||
<node name="linesToScroll" value="Сколько строк сдвигать"/>
|
<node name="linesToScroll" value="Сколько строк сдвигать"/>
|
||||||
<node name="percentToScroll" value="Сколько процентов сдвигать"/>
|
<node name="percentToScroll" value="Сколько процентов сдвигать"/>
|
||||||
</node>
|
</node>
|
||||||
|
<node name="Selection" value="Пометка">
|
||||||
|
<node name="enableSelection" value="Разрешить помечать текст"/>
|
||||||
|
</node>
|
||||||
<node name="Margins" value="Отступы">
|
<node name="Margins" value="Отступы">
|
||||||
<node name="left" value="Отступ слева"/>
|
<node name="left" value="Отступ слева"/>
|
||||||
<node name="right" value="Отступ справа"/>
|
<node name="right" value="Отступ справа"/>
|
||||||
|
@ -216,6 +220,11 @@
|
||||||
<node name="choice" value="Браузер"/>
|
<node name="choice" value="Браузер"/>
|
||||||
<node name="command" value="Выполнять команду"/>
|
<node name="command" value="Выполнять команду"/>
|
||||||
</node>
|
</node>
|
||||||
|
<node name="Maemo" value="Maemo">
|
||||||
|
<node name="keyActionOnRelease" value="Key Action on Release, Not on Press" toBeTranslated="true"/>
|
||||||
|
<node name="minStylusPressure" value="Минимальное давление стилуса"/>
|
||||||
|
<node name="maxStylusPressure" value="Максимальное давление стилуса"/>
|
||||||
|
</node>
|
||||||
</node>
|
</node>
|
||||||
</node>
|
</node>
|
||||||
<node name="InfoDialog">
|
<node name="InfoDialog">
|
||||||
|
|
|
@ -66,12 +66,13 @@
|
||||||
<node name="recentListSize" value="Розмір списку прочитаних книг"/>
|
<node name="recentListSize" value="Розмір списку прочитаних книг"/>
|
||||||
<node name="keyDelay" value="Затримка між натисканням на клавіші"/>
|
<node name="keyDelay" value="Затримка між натисканням на клавіші"/>
|
||||||
</node>
|
</node>
|
||||||
<node name="Language" value="Language" toBeTranslated="true">
|
<node name="Language" value="Мова">
|
||||||
<node name="autoDetect" value="Detect Language and Encoding Automatically" toBeTranslated="true"/>
|
<node name="autoDetect" value="Визначити мову та кодувати автоматично"/>
|
||||||
<node name="defaultLanguage" value="Типова мова"/>
|
<node name="defaultLanguage" value="Типова мова"/>
|
||||||
<node name="defaultEncodingSet" value="Default Encoding Set" toBeTranslated="true"/>
|
<node name="defaultEncodingSet" value="Набiр символiв"/>
|
||||||
<node name="defaultEncoding" value="Типовий набiр символiв"/>
|
<node name="defaultEncoding" value="Типовий набiр символiв"/>
|
||||||
<node name="chineseBreakAtAnyPosition" value="In Chinese Break Line at Any Position" toBeTranslated="true"/>
|
<node name="useWindows1252Hack" value="Use windows-1252 instead of iso-8859-1" toBeTranslated="true"/>
|
||||||
|
<node name="chineseBreakAtAnyPosition" value="В китайскому розбивати строку у будь якому мiсцi"/>
|
||||||
</node>
|
</node>
|
||||||
<node name="Indicator" value="Індикатор">
|
<node name="Indicator" value="Індикатор">
|
||||||
<node name="show" value="Показувати індикатор"/>
|
<node name="show" value="Показувати індикатор"/>
|
||||||
|
@ -102,6 +103,9 @@
|
||||||
<node name="linesToScroll" value="Скільки рядків зсувати"/>
|
<node name="linesToScroll" value="Скільки рядків зсувати"/>
|
||||||
<node name="percentToScroll" value="Скільки відсотків зсувати"/>
|
<node name="percentToScroll" value="Скільки відсотків зсувати"/>
|
||||||
</node>
|
</node>
|
||||||
|
<node name="Selection" value="Помітка">
|
||||||
|
<node name="enableSelection" value="Enable Text Selection" toBeTranslated="true"/>
|
||||||
|
</node>
|
||||||
<node name="Margins" value="Відступи">
|
<node name="Margins" value="Відступи">
|
||||||
<node name="left" value="Відступ зліва"/>
|
<node name="left" value="Відступ зліва"/>
|
||||||
<node name="right" value="Відступ зправа"/>
|
<node name="right" value="Відступ зправа"/>
|
||||||
|
@ -216,6 +220,11 @@
|
||||||
<node name="choice" value="Переглядач"/>
|
<node name="choice" value="Переглядач"/>
|
||||||
<node name="command" value="Виконати команду"/>
|
<node name="command" value="Виконати команду"/>
|
||||||
</node>
|
</node>
|
||||||
|
<node name="Maemo" value="Maemo">
|
||||||
|
<node name="keyActionOnRelease" value="Key Action on Release, Not on Press" toBeTranslated="true"/>
|
||||||
|
<node name="minStylusPressure" value="Minimal Stylus Pressure" toBeTranslated="true"/>
|
||||||
|
<node name="maxStylusPressure" value="Maximal Stylus Pressure" toBeTranslated="true"/>
|
||||||
|
</node>
|
||||||
</node>
|
</node>
|
||||||
</node>
|
</node>
|
||||||
<node name="InfoDialog">
|
<node name="InfoDialog">
|
||||||
|
@ -226,7 +235,7 @@
|
||||||
<node name="title" value="Назва"/>
|
<node name="title" value="Назва"/>
|
||||||
<node name="authorDisplayName" value="Ім'я автора"/>
|
<node name="authorDisplayName" value="Ім'я автора"/>
|
||||||
<node name="authorSortKey" value="Ім'я для сортування"/>
|
<node name="authorSortKey" value="Ім'я для сортування"/>
|
||||||
<node name="language" value="Language" toBeTranslated="true"/>
|
<node name="language" value="Мова"/>
|
||||||
<node name="encodingSet" value="Набір кодувань"/>
|
<node name="encodingSet" value="Набір кодувань"/>
|
||||||
<node name="encoding" value="Кодування"/>
|
<node name="encoding" value="Кодування"/>
|
||||||
</node>
|
</node>
|
||||||
|
|
|
@ -34,15 +34,17 @@
|
||||||
<node name="language">
|
<node name="language">
|
||||||
<node name="cs" value="Czech"/>
|
<node name="cs" value="Czech"/>
|
||||||
<node name="de" value="German"/>
|
<node name="de" value="German"/>
|
||||||
<node name="de-traditional" value="German (traditional orphography)"/>
|
<node name="de-traditional" value="German (traditional orthography)"/>
|
||||||
<node name="en" value="English"/>
|
<node name="en" value="English"/>
|
||||||
<node name="eo" value="Esperanto"/>
|
<node name="eo" value="Esperanto"/>
|
||||||
<node name="es" value="Spanish"/>
|
<node name="es" value="Spanish"/>
|
||||||
<node name="fi" value="Finnish"/>
|
<node name="fi" value="Finnish"/>
|
||||||
<node name="fr" value="French"/>
|
<node name="fr" value="French"/>
|
||||||
<node name="it" value="Italian"/>
|
<node name="it" value="Italian"/>
|
||||||
|
<node name="no" value="Norwegian"/>
|
||||||
<node name="pt" value="Portuguese"/>
|
<node name="pt" value="Portuguese"/>
|
||||||
<node name="ru" value="Russian"/>
|
<node name="ru" value="Russian"/>
|
||||||
|
<node name="sv" value="Swedish"/>
|
||||||
<node name="uk" value="Ukrainian"/>
|
<node name="uk" value="Ukrainian"/>
|
||||||
<node name="zh" value="Chinese"/>
|
<node name="zh" value="Chinese"/>
|
||||||
<node name="other" value="Other"/>
|
<node name="other" value="Other"/>
|
||||||
|
|
|
@ -41,8 +41,10 @@
|
||||||
<node name="fi" value="Suomi"/>
|
<node name="fi" value="Suomi"/>
|
||||||
<node name="fr" value="Ranska"/>
|
<node name="fr" value="Ranska"/>
|
||||||
<node name="it" value="Italia"/>
|
<node name="it" value="Italia"/>
|
||||||
|
<node name="no" value="Norja"/>
|
||||||
<node name="pt" value="Portugali"/>
|
<node name="pt" value="Portugali"/>
|
||||||
<node name="ru" value="Venäjä"/>
|
<node name="ru" value="Venäjä"/>
|
||||||
|
<node name="sv" value="Ruotsi"/>
|
||||||
<node name="uk" value="Ukraina"/>
|
<node name="uk" value="Ukraina"/>
|
||||||
<node name="zh" value="Kiina"/>
|
<node name="zh" value="Kiina"/>
|
||||||
<node name="other" value="Muu"/>
|
<node name="other" value="Muu"/>
|
||||||
|
|
|
@ -34,17 +34,19 @@
|
||||||
</node>
|
</node>
|
||||||
<node name="language">
|
<node name="language">
|
||||||
<node name="cs" value="Tchèque"/>
|
<node name="cs" value="Tchèque"/>
|
||||||
<node name="de" value="German" toBeTranslated="true"/>
|
<node name="de" value="Allemand"/>
|
||||||
<node name="de-traditional" value="German (traditional orphography)" toBeTranslated="true"/>
|
<node name="de-traditional" value="Allemand (l'orthographie traditionelle)"/>
|
||||||
<node name="en" value="English" toBeTranslated="true"/>
|
<node name="en" value="Anglais"/>
|
||||||
<node name="eo" value="Esperanto" toBeTranslated="true"/>
|
<node name="eo" value="Espéranto"/>
|
||||||
<node name="es" value="Spanish" toBeTranslated="true"/>
|
<node name="es" value="Espagnol"/>
|
||||||
<node name="fi" value="Finnish" toBeTranslated="true"/>
|
<node name="fi" value="Finnois"/>
|
||||||
<node name="fr" value="French" toBeTranslated="true"/>
|
<node name="fr" value="Français"/>
|
||||||
<node name="it" value="Italian" toBeTranslated="true"/>
|
<node name="it" value="Italien"/>
|
||||||
<node name="pt" value="Portuguese" toBeTranslated="true"/>
|
<node name="no" value="Norvégien"/>
|
||||||
|
<node name="pt" value="Portugais"/>
|
||||||
<node name="ru" value="Russe"/>
|
<node name="ru" value="Russe"/>
|
||||||
<node name="uk" value="Ukrainian" toBeTranslated="true"/>
|
<node name="sv" value="Suédois"/>
|
||||||
|
<node name="uk" value="Ukrainien"/>
|
||||||
<node name="zh" value="Chinois"/>
|
<node name="zh" value="Chinois"/>
|
||||||
<node name="other" value="Autre"/>
|
<node name="other" value="Autre"/>
|
||||||
</node>
|
</node>
|
||||||
|
|
60
data/resources/zlibrary/it.xml
Normal file
60
data/resources/zlibrary/it.xml
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<resources>
|
||||||
|
<node name="dialog">
|
||||||
|
<node name="button">
|
||||||
|
<node name="ok" value="&Ok"/>
|
||||||
|
<node name="cancel" value="&Annulla"/>
|
||||||
|
<node name="yes" value="&Sì"/>
|
||||||
|
<node name="no" value="&No"/>
|
||||||
|
<node name="apply" value="&Applica"/>
|
||||||
|
</node>
|
||||||
|
<node name="waitMessage">
|
||||||
|
<node name="savingConfig" value="Salvataggio configurazione..."/>
|
||||||
|
</node>
|
||||||
|
</node>
|
||||||
|
<node name="color">
|
||||||
|
<node name="red" value="Rosso"/>
|
||||||
|
<node name="green" value="Verde"/>
|
||||||
|
<node name="blue" value="Blu"/>
|
||||||
|
<node name="black" value="Nero"/>
|
||||||
|
<node name="white" value="Bianco"/>
|
||||||
|
<node name="maroon" value="Marrone"/>
|
||||||
|
<node name="olive" value="Oliva"/>
|
||||||
|
<node name="navy" value="Blu scuro"/>
|
||||||
|
<node name="purple" value="Viola"/>
|
||||||
|
<node name="teal" value="Verde-azzurro"/>
|
||||||
|
<node name="silver" value="Argento"/>
|
||||||
|
<node name="gray" value="Grigio"/>
|
||||||
|
<node name="lime" value="Verde-giallo"/>
|
||||||
|
<node name="yellow" value="Giallo"/>
|
||||||
|
<node name="magenta" value="Magenta"/>
|
||||||
|
<node name="cyan" value="Ciano"/>
|
||||||
|
<node name="custom..." value="Personalizzato..."/>
|
||||||
|
</node>
|
||||||
|
<node name="language">
|
||||||
|
<node name="cs" value="Ceco"/>
|
||||||
|
<node name="de" value="Tedesco"/>
|
||||||
|
<node name="de-traditional" value="Tedesco (ortografia tradizionale)"/>
|
||||||
|
<node name="en" value="Inglese"/>
|
||||||
|
<node name="eo" value="Esperanto"/>
|
||||||
|
<node name="es" value="Spagnolo"/>
|
||||||
|
<node name="fi" value="Finlandese"/>
|
||||||
|
<node name="fr" value="Francese"/>
|
||||||
|
<node name="it" value="Italiano"/>
|
||||||
|
<node name="no" value="Norvegese"/>
|
||||||
|
<node name="pt" value="Portoghese"/>
|
||||||
|
<node name="ru" value="Russo"/>
|
||||||
|
<node name="sv" value="Svedese"/>
|
||||||
|
<node name="uk" value="Ucraino"/>
|
||||||
|
<node name="zh" value="Cinese"/>
|
||||||
|
<node name="other" value="Altra"/>
|
||||||
|
</node>
|
||||||
|
<node name="boolean3">
|
||||||
|
<node name="on" value="on"/>
|
||||||
|
<node name="off" value="off"/>
|
||||||
|
<node name="unchanged" value="invariato"/>
|
||||||
|
</node>
|
||||||
|
<node name="keyOptionView">
|
||||||
|
<node name="actionFor" value="Azione del Tasto"/>
|
||||||
|
</node>
|
||||||
|
</resources>
|
|
@ -41,8 +41,10 @@
|
||||||
<node name="fi" value="финский"/>
|
<node name="fi" value="финский"/>
|
||||||
<node name="fr" value="французский"/>
|
<node name="fr" value="французский"/>
|
||||||
<node name="it" value="итальянский"/>
|
<node name="it" value="итальянский"/>
|
||||||
|
<node name="no" value="норвежский"/>
|
||||||
<node name="pt" value="португальский"/>
|
<node name="pt" value="португальский"/>
|
||||||
<node name="ru" value="русский"/>
|
<node name="ru" value="русский"/>
|
||||||
|
<node name="sv" value="шведский"/>
|
||||||
<node name="uk" value="украинский"/>
|
<node name="uk" value="украинский"/>
|
||||||
<node name="zh" value="китайский"/>
|
<node name="zh" value="китайский"/>
|
||||||
<node name="other" value="другой"/>
|
<node name="other" value="другой"/>
|
||||||
|
|
|
@ -32,18 +32,20 @@
|
||||||
<node name="custom..." value="Налаштувати..."/>
|
<node name="custom..." value="Налаштувати..."/>
|
||||||
</node>
|
</node>
|
||||||
<node name="language">
|
<node name="language">
|
||||||
<node name="cs" value="Чешська"/>
|
<node name="cs" value="Чеська"/>
|
||||||
<node name="de" value="German" toBeTranslated="true"/>
|
<node name="de" value="Німецька"/>
|
||||||
<node name="de-traditional" value="German (traditional orphography)" toBeTranslated="true"/>
|
<node name="de-traditional" value="Німецька (традiцiйна орфографiя)"/>
|
||||||
<node name="en" value="English" toBeTranslated="true"/>
|
<node name="en" value="Англійська"/>
|
||||||
<node name="eo" value="Esperanto" toBeTranslated="true"/>
|
<node name="eo" value="Есперанто"/>
|
||||||
<node name="es" value="Spanish" toBeTranslated="true"/>
|
<node name="es" value="Іспанська"/>
|
||||||
<node name="fi" value="Finnish" toBeTranslated="true"/>
|
<node name="fi" value="Фінська"/>
|
||||||
<node name="fr" value="French" toBeTranslated="true"/>
|
<node name="fr" value="Французька"/>
|
||||||
<node name="it" value="Italian" toBeTranslated="true"/>
|
<node name="it" value="Італійська"/>
|
||||||
<node name="pt" value="Portuguese" toBeTranslated="true"/>
|
<node name="no" value="Норвезька"/>
|
||||||
|
<node name="pt" value="Португальська"/>
|
||||||
<node name="ru" value="Російська"/>
|
<node name="ru" value="Російська"/>
|
||||||
<node name="uk" value="Ukrainian" toBeTranslated="true"/>
|
<node name="sv" value="Шведська"/>
|
||||||
|
<node name="uk" value="Українська"/>
|
||||||
<node name="zh" value="Китайська"/>
|
<node name="zh" value="Китайська"/>
|
||||||
<node name="other" value="Інша"/>
|
<node name="other" value="Інша"/>
|
||||||
</node>
|
</node>
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
<!-- The intermediates directory -->
|
<!-- The intermediates directory -->
|
||||||
<!-- Eclipse uses "bin" for its own output, so we do the same. -->
|
<!-- Eclipse uses "bin" for its own output, so we do the same. -->
|
||||||
<property name="outdir" value="../../bin" />
|
<property name="outdir" value="../../bin" />
|
||||||
|
<property name="cachedir" value="../../depcache" />
|
||||||
|
|
||||||
<!-- No user servicable parts below. -->
|
<!-- No user servicable parts below. -->
|
||||||
|
|
||||||
|
@ -82,12 +83,19 @@
|
||||||
</apply>
|
</apply>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
|
<target name="depend" depends="dirs, resource-src, aidl">
|
||||||
|
<depend srcdir="${srcdir}" destdir="${outdir-classes}" cache="${cachedir}" closure="yes">
|
||||||
|
<exclude name="org/zlibrary/core/xml/sax/**"/>
|
||||||
|
<exclude name="org/zlibrary/core/xmlconfig/**"/>
|
||||||
|
<exclude name="org/zlibrary/ui/swing/**"/>
|
||||||
|
</depend>
|
||||||
|
</target>
|
||||||
|
|
||||||
<!-- Compile this project's .java files into .class files. -->
|
<!-- Compile this project's .java files into .class files. -->
|
||||||
<target name="compile" depends="dirs, resource-src, aidl">
|
<target name="compile" depends="depend">
|
||||||
<javac target="1.5" debug="true" extdirs=""
|
<javac target="1.5" debug="true" extdirs="" srcdir="${srcdir}" destdir="${outdir-classes}" bootclasspath="${android-jar}">
|
||||||
srcdir="${srcdir}"
|
<exclude name = "org/zlibrary/core/xml/sax/**"/>
|
||||||
destdir="${outdir-classes}"
|
<exclude name="org/zlibrary/core/xmlconfig/**"/>
|
||||||
bootclasspath="${android-jar}">
|
|
||||||
<exclude name = "org/zlibrary/ui/swing/**"/>
|
<exclude name = "org/zlibrary/ui/swing/**"/>
|
||||||
</javac>
|
</javac>
|
||||||
</target>
|
</target>
|
||||||
|
|
|
@ -2,16 +2,14 @@
|
||||||
<keymap>
|
<keymap>
|
||||||
<binding key="<L>" action="1"/>
|
<binding key="<L>" action="1"/>
|
||||||
<binding key="<O>" action="2"/>
|
<binding key="<O>" action="2"/>
|
||||||
<binding key="<PadLeft>" action="3"/>
|
<binding key="<PadLeft>" action="12"/>
|
||||||
<binding key="<PadRight>" action="4"/>
|
<binding key="<PadRight>" action="11"/>
|
||||||
<binding key="<C>" action="5"/>
|
<binding key="<C>" action="5"/>
|
||||||
<binding key="<F>" action="6"/>
|
<binding key="<F>" action="6"/>
|
||||||
<binding key="<P>" action="7"/>
|
<binding key="<P>" action="7"/>
|
||||||
<binding key="<N>" action="8"/>
|
<binding key="<N>" action="8"/>
|
||||||
<binding key="<PageDown>" action="9"/>
|
<binding key="<PadDown>" action="9"/>
|
||||||
<binding key="<PageUp>" action="10"/>
|
<binding key="<PadUp>" action="10"/>
|
||||||
<binding key="<PadDown>" action="11"/>
|
|
||||||
<binding key="<PadUp>" action="12"/>
|
|
||||||
<binding key="<Ctrl>+<Home>" action="15"/>
|
<binding key="<Ctrl>+<Home>" action="15"/>
|
||||||
<binding key="<Home>" action="16"/>
|
<binding key="<Home>" action="16"/>
|
||||||
<binding key="<End>" action="17"/>
|
<binding key="<End>" action="17"/>
|
||||||
|
|
38
platform/android/data/default/menubar.xml
Normal file
38
platform/android/data/default/menubar.xml
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<menubar>
|
||||||
|
<item action="25" key="bookInfo"/>
|
||||||
|
<item action="5" key="toc"/>
|
||||||
|
<submenu key="library">
|
||||||
|
<item action="1" key="open"/>
|
||||||
|
<item action="7" key="previous"/>
|
||||||
|
<item action="28" key="recent"/>
|
||||||
|
<item action="24" key="addBook"/>
|
||||||
|
<item action="26" key="about"/>
|
||||||
|
</submenu>
|
||||||
|
<submenu key="navigate">
|
||||||
|
<item action="15" key="gotoStartOfDocument"/>
|
||||||
|
<item action="16" key="gotoStartOfSection"/>
|
||||||
|
<item action="17" key="gotoEndOfSection"/>
|
||||||
|
<item action="33" key="gotoNextTOCItem"/>
|
||||||
|
<item action="34" key="gotoPreviousTOCItem"/>
|
||||||
|
<item action="3" key="goBack"/>
|
||||||
|
<item action="4" key="goForward"/>
|
||||||
|
</submenu>
|
||||||
|
<submenu key="selection">
|
||||||
|
<item action="35" key="clipboard"/>
|
||||||
|
<item action="37" key="dictionary"/>
|
||||||
|
<item action="36" key="clear"/>
|
||||||
|
</submenu>
|
||||||
|
<submenu key="search">
|
||||||
|
<item action="6" key="find"/>
|
||||||
|
<item action="7" key="next"/>
|
||||||
|
<item action="8" key="previous"/>
|
||||||
|
</submenu>
|
||||||
|
<submenu key="view">
|
||||||
|
<item action="27" key="rotate"/>
|
||||||
|
<item action="22" key="fullScreen"/>
|
||||||
|
<item action="21" key="toggleIndicator"/>
|
||||||
|
</submenu>
|
||||||
|
<item action="2" key="settings"/>
|
||||||
|
<item action="29" key="close"/>
|
||||||
|
</menubar>
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<DefaultStyles>
|
<DefaultStyles>
|
||||||
<base family="DroidSerif" fontSize="12"/>
|
<base family="DroidSerif" fontSize="14"/>
|
||||||
<style id="0" name="Regular Paragraph" firstLineIndentDelta="20" allowHyphenations="true"/>
|
<style id="0" name="Regular Paragraph" firstLineIndentDelta="20" allowHyphenations="true"/>
|
||||||
<style id="1" name="Title" fontSizeDelta="10" bold="true" spaceBefore="2" spaceAfter="7" alignment="center" allowHyphenations="false"/>
|
<style id="1" name="Title" fontSizeDelta="10" bold="true" spaceBefore="2" spaceAfter="7" alignment="center" allowHyphenations="false"/>
|
||||||
<style id="3" name="Poem Title" fontSizeDelta="2" bold="true" spaceBefore="6" spaceAfter="6" leftIndent="40" allowHyphenations="false"/>
|
<style id="3" name="Poem Title" fontSizeDelta="2" bold="true" spaceBefore="6" spaceAfter="6" leftIndent="40" allowHyphenations="false"/>
|
||||||
|
|
23
platform/swing/data/default/toolbar.xml
Normal file
23
platform/swing/data/default/toolbar.xml
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<toolbar>
|
||||||
|
<button action="1" key="books"/>
|
||||||
|
<button action="28" key="history"/>
|
||||||
|
<button action="24" key="addbook"/>
|
||||||
|
<separator/>
|
||||||
|
<button action="15" key="home"/>
|
||||||
|
<button action="3" key="leftarrow"/>
|
||||||
|
<button action="4" key="rightarrow"/>
|
||||||
|
<separator/>
|
||||||
|
<button action="5" key="contents"/>
|
||||||
|
<separator/>
|
||||||
|
<button action="6" key="find"/>
|
||||||
|
<button action="7" key="findnext"/>
|
||||||
|
<button action="8" key="findprev"/>
|
||||||
|
<separator/>
|
||||||
|
<button action="25" key="bookinfo"/>
|
||||||
|
<button action="2" key="settings"/>
|
||||||
|
<separator/>
|
||||||
|
<button action="27" key="rotatescreen"/>
|
||||||
|
<separator/>
|
||||||
|
<button action="26" key="help"/>
|
||||||
|
</toolbar>
|
|
@ -1,22 +1,27 @@
|
||||||
package org.fbreader.bookmodel;
|
package org.fbreader.bookmodel;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.HashMap;
|
||||||
import java.util.TreeMap;
|
|
||||||
import java.util.Collections;
|
|
||||||
|
|
||||||
import org.zlibrary.core.image.ZLImage;
|
import org.zlibrary.core.image.ZLImage;
|
||||||
|
import org.zlibrary.core.image.ZLImageMap;
|
||||||
import org.zlibrary.text.model.ZLTextModel;
|
import org.zlibrary.text.model.ZLTextModel;
|
||||||
import org.zlibrary.text.model.ZLTextParagraph;
|
import org.zlibrary.text.model.ZLTextParagraph;
|
||||||
import org.zlibrary.text.model.ZLTextPlainModel;
|
import org.zlibrary.text.model.ZLTextPlainModel;
|
||||||
import org.zlibrary.text.model.impl.ZLModelFactory;
|
import org.zlibrary.text.model.impl.ZLModelFactory;
|
||||||
|
|
||||||
public class BookModel {
|
public final class BookModel {
|
||||||
private final ZLModelFactory myModelFactory = new ZLModelFactory();
|
private final ZLModelFactory myModelFactory = new ZLModelFactory();
|
||||||
private final ZLTextPlainModel myBookTextModel = myModelFactory.createPlainModel();
|
private final ZLTextPlainModel myBookTextModel = myModelFactory.createPlainModel(65536);
|
||||||
private final ContentsModel myContentsModel = new ContentsModel();
|
private final ContentsModel myContentsModel = new ContentsModel();
|
||||||
private final TreeMap<String,ZLTextPlainModel> myFootnotes = new TreeMap<String,ZLTextPlainModel>();
|
private final HashMap<String,ZLTextPlainModel> myFootnotes = new HashMap<String,ZLTextPlainModel>();
|
||||||
private final TreeMap<String,Label> myInternalHyperlinks = new TreeMap<String,Label>();
|
private final HashMap<String,Label> myInternalHyperlinks = new HashMap<String,Label>();
|
||||||
private final TreeMap<String,ZLImage> myImageMap = new TreeMap<String,ZLImage>();
|
|
||||||
|
private class ImageMap extends HashMap<String,ZLImage> implements ZLImageMap {
|
||||||
|
public ZLImage getImage(String id) {
|
||||||
|
return get(id);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
private final ImageMap myImageMap = new ImageMap();
|
||||||
|
|
||||||
private final String myFileName;
|
private final String myFileName;
|
||||||
|
|
||||||
|
@ -47,14 +52,12 @@ public class BookModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ZLTextPlainModel getFootnoteModel(String id) {
|
public ZLTextPlainModel getFootnoteModel(String id) {
|
||||||
if (!myFootnotes.containsKey(id)) {
|
ZLTextPlainModel model = myFootnotes.get(id);
|
||||||
myFootnotes.put(id, myModelFactory.createPlainModel());
|
if (model == null) {
|
||||||
|
model = myModelFactory.createPlainModel(4096);
|
||||||
|
myFootnotes.put(id, model);
|
||||||
}
|
}
|
||||||
return myFootnotes.get(id);
|
return model;
|
||||||
}
|
|
||||||
|
|
||||||
public Map<String, ZLTextPlainModel> getFootnotes() {
|
|
||||||
return Collections.unmodifiableMap(myFootnotes);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void addHyperlinkLabel(String label, ZLTextModel model, int paragraphNumber) {
|
void addHyperlinkLabel(String label, ZLTextModel model, int paragraphNumber) {
|
||||||
|
@ -70,7 +73,7 @@ public class BookModel {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String,ZLImage> getImageMap() {
|
public ZLImageMap getImageMap() {
|
||||||
return myImageMap;
|
return myImageMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,8 +17,8 @@ public final class BookReader {
|
||||||
private final ZLTextBuffer myBuffer = new ZLTextBuffer();
|
private final ZLTextBuffer myBuffer = new ZLTextBuffer();
|
||||||
private final ZLTextBuffer myContentsBuffer = new ZLTextBuffer();
|
private final ZLTextBuffer myContentsBuffer = new ZLTextBuffer();
|
||||||
|
|
||||||
private byte[] myKindStack = new byte[10];
|
private byte[] myKindStack = new byte[20];
|
||||||
private int myKindStackSize = 0;
|
private int myKindStackSize;
|
||||||
|
|
||||||
private byte myHyperlinkKind;
|
private byte myHyperlinkKind;
|
||||||
private String myHyperlinkReference = "";
|
private String myHyperlinkReference = "";
|
||||||
|
@ -37,9 +37,10 @@ public final class BookReader {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void flushTextBufferToParagraph() {
|
private void flushTextBufferToParagraph() {
|
||||||
if (!myBuffer.isEmpty()) {
|
final ZLTextBuffer buffer = myBuffer;
|
||||||
myCurrentTextModel.addText(myBuffer);
|
if (!buffer.isEmpty()) {
|
||||||
myBuffer.clear();
|
myCurrentTextModel.addText(buffer);
|
||||||
|
buffer.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,30 +55,32 @@ public final class BookReader {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void pushKind(byte kind) {
|
public void pushKind(byte kind) {
|
||||||
if (myKindStackSize == myKindStack.length) {
|
byte[] stack = myKindStack;
|
||||||
byte[] newStack = new byte[myKindStackSize + 10];
|
if (stack.length == myKindStackSize) {
|
||||||
System.arraycopy(myKindStack, 0, newStack, 0, myKindStackSize);
|
stack = new byte[myKindStackSize * 2];
|
||||||
|
System.arraycopy(myKindStack, 0, stack, 0, myKindStackSize);
|
||||||
|
myKindStack = stack;
|
||||||
}
|
}
|
||||||
myKindStack[myKindStackSize++] = kind;
|
stack[myKindStackSize++] = kind;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean popKind() {
|
public void popKind() {
|
||||||
if (myKindStackSize > 0) {
|
if (myKindStackSize != 0) {
|
||||||
--myKindStackSize;
|
--myKindStackSize;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void beginParagraph(byte kind) {
|
public void beginParagraph(byte kind) {
|
||||||
if (myCurrentTextModel != null) {
|
final ZLTextPlainModel textModel = myCurrentTextModel;
|
||||||
myCurrentTextModel.createParagraph(kind);
|
if (textModel != null) {
|
||||||
|
textModel.createParagraph(kind);
|
||||||
|
final byte[] stack = myKindStack;
|
||||||
final int size = myKindStackSize;
|
final int size = myKindStackSize;
|
||||||
for (int i = 0; i < size; ++i) {
|
for (int i = 0; i < size; ++i) {
|
||||||
myCurrentTextModel.addControl(myKindStack[i], true);
|
textModel.addControl(stack[i], true);
|
||||||
}
|
}
|
||||||
if (myHyperlinkReference.length() != 0) {
|
if (myHyperlinkReference.length() != 0) {
|
||||||
myCurrentTextModel.addHyperlinkControl(myHyperlinkKind, myHyperlinkReference);
|
textModel.addHyperlinkControl(myHyperlinkKind, myHyperlinkReference);
|
||||||
}
|
}
|
||||||
myTextParagraphExists = true;
|
myTextParagraphExists = true;
|
||||||
}
|
}
|
||||||
|
@ -91,10 +94,11 @@ public final class BookReader {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void insertEndParagraph(byte kind) {
|
private void insertEndParagraph(byte kind) {
|
||||||
if ((myCurrentTextModel != null) && mySectionContainsRegularContents) {
|
final ZLTextPlainModel textModel = myCurrentTextModel;
|
||||||
int size = myCurrentTextModel.getParagraphsNumber();
|
if ((textModel != null) && mySectionContainsRegularContents) {
|
||||||
if ((size > 0) && (myCurrentTextModel.getParagraph(size-1).getKind() != kind)) {
|
int size = textModel.getParagraphsNumber();
|
||||||
myCurrentTextModel.createParagraph(kind);
|
if ((size > 0) && (textModel.getParagraph(size-1).getKind() != kind)) {
|
||||||
|
textModel.createParagraph(kind);
|
||||||
mySectionContainsRegularContents = false;
|
mySectionContainsRegularContents = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -164,12 +168,13 @@ public final class BookReader {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addHyperlinkLabel(String label) {
|
public void addHyperlinkLabel(String label) {
|
||||||
if (myCurrentTextModel != null) {
|
final ZLTextPlainModel textModel = myCurrentTextModel;
|
||||||
int paragraphNumber = myCurrentTextModel.getParagraphsNumber();
|
if (textModel != null) {
|
||||||
|
int paragraphNumber = textModel.getParagraphsNumber();
|
||||||
if (myTextParagraphExists) {
|
if (myTextParagraphExists) {
|
||||||
--paragraphNumber;
|
--paragraphNumber;
|
||||||
}
|
}
|
||||||
myBookModel.addHyperlinkLabel(label, myCurrentTextModel, paragraphNumber);
|
myBookModel.addHyperlinkLabel(label, textModel, paragraphNumber);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,20 +189,21 @@ public final class BookReader {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void beginContentsParagraph(int referenceNumber) {
|
public void beginContentsParagraph(int referenceNumber) {
|
||||||
|
final ZLTextPlainModel textModel = myCurrentTextModel;
|
||||||
final ArrayList<ZLTextTreeParagraph> tocStack = myTOCStack;
|
final ArrayList<ZLTextTreeParagraph> tocStack = myTOCStack;
|
||||||
if (myCurrentTextModel == myBookModel.getBookTextModel()) {
|
if (textModel == myBookModel.getBookTextModel()) {
|
||||||
ContentsModel contentsModel = myBookModel.getContentsModel();
|
ContentsModel contentsModel = myBookModel.getContentsModel();
|
||||||
if (referenceNumber == -1) {
|
if (referenceNumber == -1) {
|
||||||
referenceNumber = myCurrentTextModel.getParagraphsNumber();
|
referenceNumber = textModel.getParagraphsNumber();
|
||||||
}
|
}
|
||||||
int size = tocStack.size();
|
int size = tocStack.size();
|
||||||
ZLTextTreeParagraph peek = (size == 0) ? null : tocStack.get(size - 1);
|
ZLTextTreeParagraph peek = (size == 0) ? null : tocStack.get(size - 1);
|
||||||
if (!myContentsBuffer.isEmpty()) {
|
final ZLTextBuffer contentsBuffer = myContentsBuffer;
|
||||||
contentsModel.addText(myContentsBuffer);
|
if (!contentsBuffer.isEmpty()) {
|
||||||
myContentsBuffer.clear();
|
contentsModel.addText(contentsBuffer);
|
||||||
|
contentsBuffer.clear();
|
||||||
myLastTOCParagraphIsEmpty = false;
|
myLastTOCParagraphIsEmpty = false;
|
||||||
}
|
} else if (myLastTOCParagraphIsEmpty) {
|
||||||
if (myLastTOCParagraphIsEmpty) {
|
|
||||||
contentsModel.addText(PERIOD);
|
contentsModel.addText(PERIOD);
|
||||||
}
|
}
|
||||||
ZLTextTreeParagraph para = contentsModel.createParagraph(peek);
|
ZLTextTreeParagraph para = contentsModel.createParagraph(peek);
|
||||||
|
@ -210,18 +216,19 @@ public final class BookReader {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void endContentsParagraph() {
|
public void endContentsParagraph() {
|
||||||
if (!myTOCStack.isEmpty()) {
|
final ArrayList<ZLTextTreeParagraph> tocStack = myTOCStack;
|
||||||
|
if (!tocStack.isEmpty()) {
|
||||||
ContentsModel contentsModel = myBookModel.getContentsModel();
|
ContentsModel contentsModel = myBookModel.getContentsModel();
|
||||||
if (!myContentsBuffer.isEmpty()) {
|
final ZLTextBuffer contentsBuffer = myContentsBuffer;
|
||||||
contentsModel.addText(myContentsBuffer);
|
if (!contentsBuffer.isEmpty()) {
|
||||||
myContentsBuffer.clear();
|
contentsModel.addText(contentsBuffer);
|
||||||
|
contentsBuffer.clear();
|
||||||
myLastTOCParagraphIsEmpty = false;
|
myLastTOCParagraphIsEmpty = false;
|
||||||
}
|
} else if (myLastTOCParagraphIsEmpty) {
|
||||||
if (myLastTOCParagraphIsEmpty) {
|
|
||||||
contentsModel.addText(PERIOD);
|
contentsModel.addText(PERIOD);
|
||||||
myLastTOCParagraphIsEmpty = false;
|
myLastTOCParagraphIsEmpty = false;
|
||||||
}
|
}
|
||||||
myTOCStack.remove(myTOCStack.size() - 1);
|
tocStack.remove(tocStack.size() - 1);
|
||||||
}
|
}
|
||||||
myContentsParagraphExists = false;
|
myContentsParagraphExists = false;
|
||||||
}
|
}
|
||||||
|
@ -248,16 +255,17 @@ public final class BookReader {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addImageReference(String ref, short offset) {
|
public void addImageReference(String ref, short offset) {
|
||||||
if (myCurrentTextModel != null) {
|
final ZLTextPlainModel textModel = myCurrentTextModel;
|
||||||
|
if (textModel != null) {
|
||||||
mySectionContainsRegularContents = true;
|
mySectionContainsRegularContents = true;
|
||||||
if (myTextParagraphExists) {
|
if (myTextParagraphExists) {
|
||||||
flushTextBufferToParagraph();
|
flushTextBufferToParagraph();
|
||||||
myCurrentTextModel.addImage(ref, myBookModel.getImageMap(), offset);
|
textModel.addImage(ref, myBookModel.getImageMap(), offset);
|
||||||
} else {
|
} else {
|
||||||
beginParagraph(ZLTextParagraph.Kind.TEXT_PARAGRAPH);
|
beginParagraph(ZLTextParagraph.Kind.TEXT_PARAGRAPH);
|
||||||
myCurrentTextModel.addControl(FBTextKind.IMAGE, true);
|
textModel.addControl(FBTextKind.IMAGE, true);
|
||||||
myCurrentTextModel.addImage(ref, myBookModel.getImageMap(), offset);
|
textModel.addImage(ref, myBookModel.getImageMap(), offset);
|
||||||
myCurrentTextModel.addControl(FBTextKind.IMAGE, false);
|
textModel.addControl(FBTextKind.IMAGE, false);
|
||||||
endParagraph();
|
endParagraph();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -267,5 +275,4 @@ public final class BookReader {
|
||||||
public void addImage(String id, ZLImage image) {
|
public void addImage(String id, ZLImage image) {
|
||||||
myBookModel.addImage(id, image);
|
myBookModel.addImage(id, image);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,21 +3,49 @@ package org.fbreader.fbreader;
|
||||||
import org.zlibrary.core.options.*;
|
import org.zlibrary.core.options.*;
|
||||||
import org.zlibrary.core.view.ZLPaintContext;
|
import org.zlibrary.core.view.ZLPaintContext;
|
||||||
import org.zlibrary.text.model.ZLTextModel;
|
import org.zlibrary.text.model.ZLTextModel;
|
||||||
|
import org.zlibrary.text.view.impl.ZLTextWordCursor;
|
||||||
|
import org.zlibrary.text.view.impl.ZLTextParagraphCursor;
|
||||||
|
|
||||||
class BookTextView extends FBView {
|
class BookTextView extends FBView {
|
||||||
private ZLIntegerOption myParagraphPositionOption;
|
private ZLIntegerOption myParagraphNumberOption;
|
||||||
|
private ZLIntegerOption myWordNumberOption;
|
||||||
|
private ZLIntegerOption myCharNumberOption;
|
||||||
BookTextView(FBReader fbreader, ZLPaintContext context) {
|
BookTextView(FBReader fbreader, ZLPaintContext context) {
|
||||||
super(fbreader, context);
|
super(fbreader, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setModel(ZLTextModel model, String fileName) {
|
public void setModel(ZLTextModel model, String fileName) {
|
||||||
super.setModel(model);
|
super.setModel(model);
|
||||||
myParagraphPositionOption = new ZLIntegerOption(ZLOption.STATE_CATEGORY, fileName, "Paragraph", 0);
|
myParagraphNumberOption = new ZLIntegerOption(ZLOption.STATE_CATEGORY, fileName, "Paragraph", 0);
|
||||||
gotoParagraph(myParagraphPositionOption.getValue());
|
myWordNumberOption = new ZLIntegerOption(ZLOption.STATE_CATEGORY, fileName, "Word", 0);
|
||||||
|
myCharNumberOption = new ZLIntegerOption(ZLOption.STATE_CATEGORY, fileName, "Char", 0);
|
||||||
|
gotoPosition(myParagraphNumberOption.getValue(), myWordNumberOption.getValue(), myCharNumberOption.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void gotoParagraph(int index) {
|
protected void preparePaintInfo() {
|
||||||
super.gotoParagraph(index);
|
super.preparePaintInfo();
|
||||||
myParagraphPositionOption.setValue(index);
|
final ZLTextWordCursor cursor = getStartCursor();
|
||||||
|
if (!cursor.isNull()) {
|
||||||
|
myParagraphNumberOption.setValue(cursor.getParagraphCursor().getIndex());
|
||||||
|
myWordNumberOption.setValue(cursor.getWordNumber());
|
||||||
|
myCharNumberOption.setValue(cursor.getCharNumber());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void scrollToHome() {
|
||||||
|
final ZLTextWordCursor cursor = getStartCursor();
|
||||||
|
if (!cursor.isNull() && cursor.isStartOfParagraph() && cursor.getParagraphCursor().getIndex() == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//gotoParagraph(0, false);
|
||||||
|
gotoPosition(0, 0, 0);
|
||||||
|
getApplication().refreshWindow();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean onStylusPress(int x, int y) {
|
||||||
|
if (super.onStylusPress(x, y)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ class ChangeFontSizeAction extends FBAction {
|
||||||
ZLIntegerRangeOption option =
|
ZLIntegerRangeOption option =
|
||||||
ZLTextStyleCollection.getInstance().getBaseStyle().FontSizeOption;
|
ZLTextStyleCollection.getInstance().getBaseStyle().FontSizeOption;
|
||||||
option.setValue(option.getValue() + myDelta);
|
option.setValue(option.getValue() + myDelta);
|
||||||
//fbreader().clearTextCaches();
|
fbreader().clearTextCaches();
|
||||||
fbreader().refreshWindow();
|
fbreader().refreshWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ class ContentsView extends FBView {
|
||||||
final int reference = contentsModel.getReference(paragraph);
|
final int reference = contentsModel.getReference(paragraph);
|
||||||
|
|
||||||
FBReader fbreader = (FBReader)getApplication();
|
FBReader fbreader = (FBReader)getApplication();
|
||||||
fbreader.getBookTextView().gotoParagraph(reference);
|
fbreader.getBookTextView().gotoPosition(reference, 0, 0);
|
||||||
fbreader.setMode(FBReader.ViewMode.BOOK_TEXT);
|
fbreader.setMode(FBReader.ViewMode.BOOK_TEXT);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -26,6 +26,15 @@ public final class FBReader extends ZLApplication {
|
||||||
int RECENT_BOOKS = 1 << 5;
|
int RECENT_BOOKS = 1 << 5;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public final ScrollingOptions LargeScrollingOptions =
|
||||||
|
new ScrollingOptions("LargeScrolling", 250, ZLTextView.ScrollingMode.NO_OVERLAPPING);
|
||||||
|
public final ScrollingOptions SmallScrollingOptions =
|
||||||
|
new ScrollingOptions("SmallScrolling", 50, ZLTextView.ScrollingMode.SCROLL_LINES);
|
||||||
|
public final ScrollingOptions MouseScrollingOptions =
|
||||||
|
new ScrollingOptions("MouseScrolling", 0, ZLTextView.ScrollingMode.SCROLL_LINES);
|
||||||
|
public final ScrollingOptions FingerTapScrollingOptions =
|
||||||
|
new ScrollingOptions("FingerTapScrolling", 0, ZLTextView.ScrollingMode.NO_OVERLAPPING);
|
||||||
|
|
||||||
final static String HELP_FILE_NAME = "data/help/MiniHelp.ru.fb2";
|
final static String HELP_FILE_NAME = "data/help/MiniHelp.ru.fb2";
|
||||||
private final ZLStringOption myBookNameOption =
|
private final ZLStringOption myBookNameOption =
|
||||||
//new ZLStringOption(ZLOption.STATE_CATEGORY, "State", "Book", HELP_FILE_NAME);
|
//new ZLStringOption(ZLOption.STATE_CATEGORY, "State", "Book", HELP_FILE_NAME);
|
||||||
|
@ -71,14 +80,14 @@ public final class FBReader extends ZLApplication {
|
||||||
addAction(ActionCode.SCROLL_TO_HOME, new ScrollToHomeAction(this));
|
addAction(ActionCode.SCROLL_TO_HOME, new ScrollToHomeAction(this));
|
||||||
addAction(ActionCode.SCROLL_TO_START_OF_TEXT, new DummyAction(this));
|
addAction(ActionCode.SCROLL_TO_START_OF_TEXT, new DummyAction(this));
|
||||||
addAction(ActionCode.SCROLL_TO_END_OF_TEXT, new DummyAction(this));
|
addAction(ActionCode.SCROLL_TO_END_OF_TEXT, new DummyAction(this));
|
||||||
addAction(ActionCode.LARGE_SCROLL_FORWARD, new DummyAction(this));
|
addAction(ActionCode.LARGE_SCROLL_FORWARD, new ScrollingAction(this, LargeScrollingOptions, true));
|
||||||
addAction(ActionCode.LARGE_SCROLL_BACKWARD, new DummyAction(this));
|
addAction(ActionCode.LARGE_SCROLL_BACKWARD, new ScrollingAction(this, LargeScrollingOptions, false));
|
||||||
addAction(ActionCode.SMALL_SCROLL_FORWARD, new ScrollAction(this, 1));
|
addAction(ActionCode.SMALL_SCROLL_FORWARD, new ScrollingAction(this, SmallScrollingOptions, true));
|
||||||
addAction(ActionCode.SMALL_SCROLL_BACKWARD, new ScrollAction(this, -1));
|
addAction(ActionCode.SMALL_SCROLL_BACKWARD, new ScrollingAction(this, SmallScrollingOptions, false));
|
||||||
addAction(ActionCode.MOUSE_SCROLL_FORWARD, new DummyAction(this));
|
addAction(ActionCode.MOUSE_SCROLL_FORWARD, new ScrollingAction(this, MouseScrollingOptions, true));
|
||||||
addAction(ActionCode.MOUSE_SCROLL_BACKWARD, new DummyAction(this));
|
addAction(ActionCode.MOUSE_SCROLL_BACKWARD, new ScrollingAction(this, MouseScrollingOptions, false));
|
||||||
addAction(ActionCode.FINGER_TAP_SCROLL_FORWARD, new DummyAction(this));
|
addAction(ActionCode.FINGER_TAP_SCROLL_FORWARD, new ScrollingAction(this, FingerTapScrollingOptions, true));
|
||||||
addAction(ActionCode.FINGER_TAP_SCROLL_BACKWARD, new DummyAction(this));
|
addAction(ActionCode.FINGER_TAP_SCROLL_BACKWARD, new ScrollingAction(this, FingerTapScrollingOptions, false));
|
||||||
addAction(ActionCode.CANCEL, new CancelAction(this));
|
addAction(ActionCode.CANCEL, new CancelAction(this));
|
||||||
addAction(ActionCode.SHOW_HIDE_POSITION_INDICATOR, new DummyAction(this));
|
addAction(ActionCode.SHOW_HIDE_POSITION_INDICATOR, new DummyAction(this));
|
||||||
addAction(ActionCode.OPEN_PREVIOUS_BOOK, new DummyAction(this));
|
addAction(ActionCode.OPEN_PREVIOUS_BOOK, new DummyAction(this));
|
||||||
|
@ -89,67 +98,6 @@ public final class FBReader extends ZLApplication {
|
||||||
addAction(ActionCode.OPEN_SELECTED_TEXT_IN_DICTIONARY, new DummyAction(this));
|
addAction(ActionCode.OPEN_SELECTED_TEXT_IN_DICTIONARY, new DummyAction(this));
|
||||||
addAction(ActionCode.CLEAR_SELECTION, new DummyAction(this));
|
addAction(ActionCode.CLEAR_SELECTION, new DummyAction(this));
|
||||||
|
|
||||||
addToolbarButton(ActionCode.SHOW_COLLECTION, "books");
|
|
||||||
addToolbarButton(ActionCode.SHOW_LAST_BOOKS, "history");
|
|
||||||
addToolbarButton(ActionCode.ADD_BOOK, "addbook");
|
|
||||||
getToolbar().addSeparator();
|
|
||||||
addToolbarButton(ActionCode.SCROLL_TO_HOME, "home");
|
|
||||||
addToolbarButton(ActionCode.UNDO, "leftarrow");
|
|
||||||
addToolbarButton(ActionCode.REDO, "rightarrow");
|
|
||||||
getToolbar().addSeparator();
|
|
||||||
addToolbarButton(ActionCode.SHOW_CONTENTS, "contents");
|
|
||||||
getToolbar().addSeparator();
|
|
||||||
addToolbarButton(ActionCode.SEARCH, "find");
|
|
||||||
addToolbarButton(ActionCode.FIND_NEXT, "findnext");
|
|
||||||
addToolbarButton(ActionCode.FIND_PREVIOUS, "findprev");
|
|
||||||
getToolbar().addSeparator();
|
|
||||||
addToolbarButton(ActionCode.SHOW_BOOK_INFO, "bookinfo");
|
|
||||||
addToolbarButton(ActionCode.SHOW_OPTIONS, "settings");
|
|
||||||
getToolbar().addSeparator();
|
|
||||||
addToolbarButton(ActionCode.ROTATE_SCREEN, "rotatescreen");
|
|
||||||
//if (ShowHelpIconOption.value()) {
|
|
||||||
getToolbar().addSeparator();
|
|
||||||
addToolbarButton(ActionCode.SHOW_HELP, "help");
|
|
||||||
//}
|
|
||||||
|
|
||||||
getMenubar().addItem(ActionCode.SHOW_BOOK_INFO, "bookInfo");
|
|
||||||
getMenubar().addItem(ActionCode.SHOW_CONTENTS, "toc");
|
|
||||||
|
|
||||||
Menu librarySubmenu = getMenubar().addSubmenu("library");
|
|
||||||
librarySubmenu.addItem(ActionCode.SHOW_COLLECTION, "open");
|
|
||||||
librarySubmenu.addItem(ActionCode.OPEN_PREVIOUS_BOOK, "previous");
|
|
||||||
librarySubmenu.addItem(ActionCode.SHOW_LAST_BOOKS, "recent");
|
|
||||||
librarySubmenu.addItem(ActionCode.ADD_BOOK, "addBook");
|
|
||||||
librarySubmenu.addItem(ActionCode.SHOW_HELP, "about");
|
|
||||||
|
|
||||||
Menu navigationSubmenu = getMenubar().addSubmenu("navigate");
|
|
||||||
navigationSubmenu.addItem(ActionCode.SCROLL_TO_HOME, "gotoStartOfDocument");
|
|
||||||
navigationSubmenu.addItem(ActionCode.SCROLL_TO_START_OF_TEXT, "gotoStartOfSection");
|
|
||||||
navigationSubmenu.addItem(ActionCode.SCROLL_TO_END_OF_TEXT, "gotoEndOfSection");
|
|
||||||
navigationSubmenu.addItem(ActionCode.GOTO_NEXT_TOC_SECTION, "gotoNextTOCItem");
|
|
||||||
navigationSubmenu.addItem(ActionCode.GOTO_PREVIOUS_TOC_SECTION, "gotoPreviousTOCItem");
|
|
||||||
navigationSubmenu.addItem(ActionCode.UNDO, "goBack");
|
|
||||||
navigationSubmenu.addItem(ActionCode.REDO, "goForward");
|
|
||||||
|
|
||||||
Menu selectionSubmenu = getMenubar().addSubmenu("selection");
|
|
||||||
selectionSubmenu.addItem(ActionCode.COPY_SELECTED_TEXT_TO_CLIPBOARD, "clipboard");
|
|
||||||
selectionSubmenu.addItem(ActionCode.OPEN_SELECTED_TEXT_IN_DICTIONARY, "dictionary");
|
|
||||||
selectionSubmenu.addItem(ActionCode.CLEAR_SELECTION, "clear");
|
|
||||||
|
|
||||||
Menu findSubmenu = getMenubar().addSubmenu("search");
|
|
||||||
findSubmenu.addItem(ActionCode.SEARCH, "find");
|
|
||||||
findSubmenu.addItem(ActionCode.FIND_NEXT, "next");
|
|
||||||
findSubmenu.addItem(ActionCode.FIND_PREVIOUS, "previous");
|
|
||||||
|
|
||||||
Menu viewSubmenu = getMenubar().addSubmenu("view");
|
|
||||||
// MSS: these three actions can have a checkbox next to them
|
|
||||||
viewSubmenu.addItem(ActionCode.ROTATE_SCREEN, "rotate");
|
|
||||||
viewSubmenu.addItem(ActionCode.TOGGLE_FULLSCREEN, "fullScreen");
|
|
||||||
viewSubmenu.addItem(ActionCode.SHOW_HIDE_POSITION_INDICATOR, "toggleIndicator");
|
|
||||||
|
|
||||||
getMenubar().addItem(ActionCode.SHOW_OPTIONS, "settings");
|
|
||||||
getMenubar().addItem(ActionCode.QUIT, "close");
|
|
||||||
|
|
||||||
myBookTextView = new BookTextView(this, getContext());
|
myBookTextView = new BookTextView(this, getContext());
|
||||||
myContentsView = new ContentsView(this, getContext());
|
myContentsView = new ContentsView(this, getContext());
|
||||||
|
|
||||||
|
@ -181,10 +129,6 @@ public final class FBReader extends ZLApplication {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final void addToolbarButton(int code, String name) {
|
|
||||||
getToolbar().addButton(code, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ZLKeyBindings keyBindings() {
|
public ZLKeyBindings keyBindings() {
|
||||||
return myBindings0;
|
return myBindings0;
|
||||||
}
|
}
|
||||||
|
@ -239,4 +183,9 @@ public final class FBReader extends ZLApplication {
|
||||||
BookTextView getBookTextView() {
|
BookTextView getBookTextView() {
|
||||||
return myBookTextView;
|
return myBookTextView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void clearTextCaches() {
|
||||||
|
myBookTextView.clearCaches();
|
||||||
|
myContentsView.clearCaches();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
package org.fbreader.fbreader;
|
|
||||||
|
|
||||||
import org.zlibrary.text.view.ZLTextView;
|
|
||||||
|
|
||||||
class ScrollAction extends FBAction {
|
|
||||||
private final int myNumberOfParagraphs;
|
|
||||||
|
|
||||||
ScrollAction(FBReader fbreader, int numberOfParagraphs) {
|
|
||||||
super(fbreader);
|
|
||||||
myNumberOfParagraphs = numberOfParagraphs;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void run() {
|
|
||||||
fbreader().getTextView().scroll(myNumberOfParagraphs);
|
|
||||||
fbreader().refreshWindow();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -10,11 +10,10 @@ class ScrollToHomeAction extends FBAction {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isEnabled() {
|
public boolean isEnabled() {
|
||||||
return false;
|
return isVisible();
|
||||||
//return isVisible();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
//
|
fbreader().getBookTextView().scrollToHome();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
38
src/org/fbreader/fbreader/ScrollingAction.java
Normal file
38
src/org/fbreader/fbreader/ScrollingAction.java
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
package org.fbreader.fbreader;
|
||||||
|
|
||||||
|
import org.zlibrary.text.view.ZLTextView;
|
||||||
|
|
||||||
|
class ScrollingAction extends FBAction {
|
||||||
|
private final ScrollingOptions myOptions;
|
||||||
|
private final boolean myForward;
|
||||||
|
|
||||||
|
ScrollingAction(FBReader fbreader, ScrollingOptions options, boolean forward) {
|
||||||
|
super(fbreader);
|
||||||
|
myOptions = options;
|
||||||
|
myForward = forward;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEnabled() {
|
||||||
|
// TODO: implement
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void run() {
|
||||||
|
// TODO: use delay option
|
||||||
|
int mode = myOptions.ModeOption.getValue();
|
||||||
|
int value = 0;
|
||||||
|
switch (mode) {
|
||||||
|
case ZLTextView.ScrollingMode.KEEP_LINES:
|
||||||
|
value = myOptions.LinesToKeepOption.getValue();
|
||||||
|
break;
|
||||||
|
case ZLTextView.ScrollingMode.SCROLL_LINES:
|
||||||
|
value = myOptions.LinesToScrollOption.getValue();
|
||||||
|
break;
|
||||||
|
case ZLTextView.ScrollingMode.SCROLL_PERCENTAGE:
|
||||||
|
value = myOptions.PercentToScrollOption.getValue();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
fbreader().getTextView().scrollPage(myForward, mode, value);
|
||||||
|
fbreader().refreshWindow();
|
||||||
|
}
|
||||||
|
}
|
20
src/org/fbreader/fbreader/ScrollingOptions.java
Normal file
20
src/org/fbreader/fbreader/ScrollingOptions.java
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
package org.fbreader.fbreader;
|
||||||
|
|
||||||
|
import org.zlibrary.core.options.*;
|
||||||
|
|
||||||
|
public final class ScrollingOptions {
|
||||||
|
public final ZLIntegerRangeOption DelayOption;
|
||||||
|
public final ZLIntegerOption ModeOption;
|
||||||
|
public final ZLIntegerRangeOption LinesToKeepOption;
|
||||||
|
public final ZLIntegerRangeOption LinesToScrollOption;
|
||||||
|
public final ZLIntegerRangeOption PercentToScrollOption;
|
||||||
|
|
||||||
|
public ScrollingOptions(String group, int delay, int mode) {
|
||||||
|
final String category = ZLOption.CONFIG_CATEGORY;
|
||||||
|
DelayOption = new ZLIntegerRangeOption(category, group, "ScrollingDelay", 0, 5000, delay);
|
||||||
|
ModeOption = new ZLIntegerOption(category, group, "Mode", mode);
|
||||||
|
LinesToKeepOption = new ZLIntegerRangeOption(category, group, "LinesToKeep", 1, 100, 1);
|
||||||
|
LinesToScrollOption = new ZLIntegerRangeOption(category, group, "LinesToScroll", 1, 100, 1);
|
||||||
|
PercentToScrollOption = new ZLIntegerRangeOption(category, group, "PercentToScrollOption", 1, 100, 50);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,8 +1,5 @@
|
||||||
package org.fbreader.formats.fb2;
|
package org.fbreader.formats.fb2;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
import org.fbreader.bookmodel.BookModel;
|
import org.fbreader.bookmodel.BookModel;
|
||||||
import org.fbreader.bookmodel.BookReader;
|
import org.fbreader.bookmodel.BookReader;
|
||||||
import org.fbreader.bookmodel.FBTextKind;
|
import org.fbreader.bookmodel.FBTextKind;
|
||||||
|
@ -30,15 +27,7 @@ public class FB2Reader extends ZLXMLReader {
|
||||||
private int myParagraphsBeforeBodyNumber = Integer.MAX_VALUE;
|
private int myParagraphsBeforeBodyNumber = Integer.MAX_VALUE;
|
||||||
|
|
||||||
private final char[] SPACE = { ' ' };
|
private final char[] SPACE = { ' ' };
|
||||||
|
private String myHrefAttribute = ":href";
|
||||||
private static String reference(Map<String, String> attributes) {
|
|
||||||
for (String s : attributes.keySet()) {
|
|
||||||
if (s.endsWith(":href")) {
|
|
||||||
return attributes.get(s);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// private BookModel myBookModel = new BookModel();
|
// private BookModel myBookModel = new BookModel();
|
||||||
|
|
||||||
|
@ -65,40 +54,41 @@ public class FB2Reader extends ZLXMLReader {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void endElementHandler(String tagName) {
|
public void endElementHandler(String tagName) {
|
||||||
|
final BookReader modelReader = myModelReader;
|
||||||
switch (FB2Tag.getTagByName(tagName)) {
|
switch (FB2Tag.getTagByName(tagName)) {
|
||||||
case FB2Tag.P:
|
case FB2Tag.P:
|
||||||
myModelReader.endParagraph();
|
modelReader.endParagraph();
|
||||||
break;
|
break;
|
||||||
case FB2Tag.SUB:
|
case FB2Tag.SUB:
|
||||||
myModelReader.addControl(FBTextKind.SUB, false);
|
modelReader.addControl(FBTextKind.SUB, false);
|
||||||
break;
|
break;
|
||||||
case FB2Tag.SUP:
|
case FB2Tag.SUP:
|
||||||
myModelReader.addControl(FBTextKind.SUP, false);
|
modelReader.addControl(FBTextKind.SUP, false);
|
||||||
break;
|
break;
|
||||||
case FB2Tag.CODE:
|
case FB2Tag.CODE:
|
||||||
myModelReader.addControl(FBTextKind.CODE, false);
|
modelReader.addControl(FBTextKind.CODE, false);
|
||||||
break;
|
break;
|
||||||
case FB2Tag.EMPHASIS:
|
case FB2Tag.EMPHASIS:
|
||||||
myModelReader.addControl(FBTextKind.EMPHASIS, false);
|
modelReader.addControl(FBTextKind.EMPHASIS, false);
|
||||||
break;
|
break;
|
||||||
case FB2Tag.STRONG:
|
case FB2Tag.STRONG:
|
||||||
myModelReader.addControl(FBTextKind.STRONG, false);
|
modelReader.addControl(FBTextKind.STRONG, false);
|
||||||
break;
|
break;
|
||||||
case FB2Tag.STRIKETHROUGH:
|
case FB2Tag.STRIKETHROUGH:
|
||||||
myModelReader.addControl(FBTextKind.STRIKETHROUGH, false);
|
modelReader.addControl(FBTextKind.STRIKETHROUGH, false);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FB2Tag.V:
|
case FB2Tag.V:
|
||||||
case FB2Tag.SUBTITLE:
|
case FB2Tag.SUBTITLE:
|
||||||
case FB2Tag.TEXT_AUTHOR:
|
case FB2Tag.TEXT_AUTHOR:
|
||||||
case FB2Tag.DATE:
|
case FB2Tag.DATE:
|
||||||
myModelReader.popKind();
|
modelReader.popKind();
|
||||||
myModelReader.endParagraph();
|
modelReader.endParagraph();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FB2Tag.CITE:
|
case FB2Tag.CITE:
|
||||||
case FB2Tag.EPIGRAPH:
|
case FB2Tag.EPIGRAPH:
|
||||||
myModelReader.popKind();
|
modelReader.popKind();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FB2Tag.POEM:
|
case FB2Tag.POEM:
|
||||||
|
@ -106,58 +96,58 @@ public class FB2Reader extends ZLXMLReader {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FB2Tag.STANZA:
|
case FB2Tag.STANZA:
|
||||||
myModelReader.beginParagraph(ZLTextParagraph.Kind.AFTER_SKIP_PARAGRAPH);
|
modelReader.beginParagraph(ZLTextParagraph.Kind.AFTER_SKIP_PARAGRAPH);
|
||||||
myModelReader.endParagraph();
|
modelReader.endParagraph();
|
||||||
myModelReader.popKind();
|
modelReader.popKind();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FB2Tag.SECTION:
|
case FB2Tag.SECTION:
|
||||||
if (myReadMainText) {
|
if (myReadMainText) {
|
||||||
myModelReader.endContentsParagraph();
|
modelReader.endContentsParagraph();
|
||||||
--mySectionDepth;
|
--mySectionDepth;
|
||||||
mySectionStarted = false;
|
mySectionStarted = false;
|
||||||
} else {
|
} else {
|
||||||
myModelReader.unsetCurrentTextModel();
|
modelReader.unsetCurrentTextModel();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FB2Tag.ANNOTATION:
|
case FB2Tag.ANNOTATION:
|
||||||
myModelReader.popKind();
|
modelReader.popKind();
|
||||||
if (myBodyCounter == 0) {
|
if (myBodyCounter == 0) {
|
||||||
myModelReader.insertEndOfSectionParagraph();
|
modelReader.insertEndOfSectionParagraph();
|
||||||
myModelReader.unsetCurrentTextModel();
|
modelReader.unsetCurrentTextModel();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FB2Tag.TITLE:
|
case FB2Tag.TITLE:
|
||||||
myModelReader.popKind();
|
modelReader.popKind();
|
||||||
myModelReader.exitTitle();
|
modelReader.exitTitle();
|
||||||
myInsideTitle = false;
|
myInsideTitle = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FB2Tag.BODY:
|
case FB2Tag.BODY:
|
||||||
myModelReader.popKind();
|
modelReader.popKind();
|
||||||
myReadMainText = false;
|
myReadMainText = false;
|
||||||
myModelReader.unsetCurrentTextModel();
|
modelReader.unsetCurrentTextModel();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FB2Tag.A:
|
case FB2Tag.A:
|
||||||
myModelReader.addControl(myHyperlinkType, false);
|
modelReader.addControl(myHyperlinkType, false);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FB2Tag.COVERPAGE:
|
case FB2Tag.COVERPAGE:
|
||||||
if (myBodyCounter == 0) {
|
if (myBodyCounter == 0) {
|
||||||
myInsideCoverpage = false;
|
myInsideCoverpage = false;
|
||||||
myModelReader.insertEndOfSectionParagraph();
|
modelReader.insertEndOfSectionParagraph();
|
||||||
myModelReader.unsetCurrentTextModel();
|
modelReader.unsetCurrentTextModel();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FB2Tag.BINARY:
|
case FB2Tag.BINARY:
|
||||||
if (myCurrentImage != null) {
|
if (myCurrentImage != null) {
|
||||||
myCurrentImage.trimToSize();
|
myCurrentImage.trimToSize();
|
||||||
}
|
|
||||||
myCurrentImage = null;
|
myCurrentImage = null;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -165,72 +155,88 @@ public class FB2Reader extends ZLXMLReader {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startElementHandler(String tagName, Map<String, String> attributes) {
|
public void startElementHandler(String tagName, StringMap attributes) {
|
||||||
String id = attributes.get("id");
|
final BookReader modelReader = myModelReader;
|
||||||
|
String id = attributes.getValue("id");
|
||||||
if (id != null) {
|
if (id != null) {
|
||||||
if (!myReadMainText) {
|
if (!myReadMainText) {
|
||||||
myModelReader.setFootnoteTextModel(id);
|
modelReader.setFootnoteTextModel(id);
|
||||||
}
|
}
|
||||||
myModelReader.addHyperlinkLabel(id);
|
modelReader.addHyperlinkLabel(id);
|
||||||
}
|
}
|
||||||
switch (FB2Tag.getTagByName(tagName)) {
|
switch (FB2Tag.getTagByName(tagName)) {
|
||||||
|
case FB2Tag.FICTIONBOOK:
|
||||||
|
{
|
||||||
|
final int attibutesNumber = attributes.getSize();
|
||||||
|
for (int i = 0; i < attibutesNumber; ++i) {
|
||||||
|
final String key = attributes.getKey(i);
|
||||||
|
if (key.startsWith("xmlns:")) {
|
||||||
|
final String value = attributes.getValue(key);
|
||||||
|
if (value.endsWith("/xlink")) {
|
||||||
|
myHrefAttribute = (key.substring(6) + ":href").intern();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
case FB2Tag.P:
|
case FB2Tag.P:
|
||||||
if (mySectionStarted) {
|
if (mySectionStarted) {
|
||||||
mySectionStarted = false;
|
mySectionStarted = false;
|
||||||
} else if (myInsideTitle) {
|
} else if (myInsideTitle) {
|
||||||
myModelReader.addContentsData(SPACE);
|
modelReader.addContentsData(SPACE);
|
||||||
}
|
}
|
||||||
myModelReader.beginParagraph(ZLTextParagraph.Kind.TEXT_PARAGRAPH);
|
modelReader.beginParagraph(ZLTextParagraph.Kind.TEXT_PARAGRAPH);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FB2Tag.SUB:
|
case FB2Tag.SUB:
|
||||||
myModelReader.addControl(FBTextKind.SUB, true);
|
modelReader.addControl(FBTextKind.SUB, true);
|
||||||
break;
|
break;
|
||||||
case FB2Tag.SUP:
|
case FB2Tag.SUP:
|
||||||
myModelReader.addControl(FBTextKind.SUP, true);
|
modelReader.addControl(FBTextKind.SUP, true);
|
||||||
break;
|
break;
|
||||||
case FB2Tag.CODE:
|
case FB2Tag.CODE:
|
||||||
myModelReader.addControl(FBTextKind.CODE, true);
|
modelReader.addControl(FBTextKind.CODE, true);
|
||||||
break;
|
break;
|
||||||
case FB2Tag.EMPHASIS:
|
case FB2Tag.EMPHASIS:
|
||||||
myModelReader.addControl(FBTextKind.EMPHASIS, true);
|
modelReader.addControl(FBTextKind.EMPHASIS, true);
|
||||||
break;
|
break;
|
||||||
case FB2Tag.STRONG:
|
case FB2Tag.STRONG:
|
||||||
myModelReader.addControl(FBTextKind.STRONG, true);
|
modelReader.addControl(FBTextKind.STRONG, true);
|
||||||
break;
|
break;
|
||||||
case FB2Tag.STRIKETHROUGH:
|
case FB2Tag.STRIKETHROUGH:
|
||||||
myModelReader.addControl(FBTextKind.STRIKETHROUGH, true);
|
modelReader.addControl(FBTextKind.STRIKETHROUGH, true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FB2Tag.V:
|
case FB2Tag.V:
|
||||||
myModelReader.pushKind(FBTextKind.VERSE);
|
modelReader.pushKind(FBTextKind.VERSE);
|
||||||
myModelReader.beginParagraph(ZLTextParagraph.Kind.TEXT_PARAGRAPH);
|
modelReader.beginParagraph(ZLTextParagraph.Kind.TEXT_PARAGRAPH);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FB2Tag.TEXT_AUTHOR:
|
case FB2Tag.TEXT_AUTHOR:
|
||||||
myModelReader.pushKind(FBTextKind.AUTHOR);
|
modelReader.pushKind(FBTextKind.AUTHOR);
|
||||||
myModelReader.beginParagraph(ZLTextParagraph.Kind.TEXT_PARAGRAPH);
|
modelReader.beginParagraph(ZLTextParagraph.Kind.TEXT_PARAGRAPH);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FB2Tag.SUBTITLE:
|
case FB2Tag.SUBTITLE:
|
||||||
myModelReader.pushKind(FBTextKind.SUBTITLE);
|
modelReader.pushKind(FBTextKind.SUBTITLE);
|
||||||
myModelReader.beginParagraph(ZLTextParagraph.Kind.TEXT_PARAGRAPH);
|
modelReader.beginParagraph(ZLTextParagraph.Kind.TEXT_PARAGRAPH);
|
||||||
break;
|
break;
|
||||||
case FB2Tag.DATE:
|
case FB2Tag.DATE:
|
||||||
myModelReader.pushKind(FBTextKind.DATE);
|
modelReader.pushKind(FBTextKind.DATE);
|
||||||
myModelReader.beginParagraph(ZLTextParagraph.Kind.TEXT_PARAGRAPH);
|
modelReader.beginParagraph(ZLTextParagraph.Kind.TEXT_PARAGRAPH);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FB2Tag.EMPTY_LINE:
|
case FB2Tag.EMPTY_LINE:
|
||||||
myModelReader.beginParagraph(ZLTextParagraph.Kind.EMPTY_LINE_PARAGRAPH);
|
modelReader.beginParagraph(ZLTextParagraph.Kind.EMPTY_LINE_PARAGRAPH);
|
||||||
myModelReader.endParagraph();
|
modelReader.endParagraph();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FB2Tag.CITE:
|
case FB2Tag.CITE:
|
||||||
myModelReader.pushKind(FBTextKind.CITE);
|
modelReader.pushKind(FBTextKind.CITE);
|
||||||
break;
|
break;
|
||||||
case FB2Tag.EPIGRAPH:
|
case FB2Tag.EPIGRAPH:
|
||||||
myModelReader.pushKind(FBTextKind.EPIGRAPH);
|
modelReader.pushKind(FBTextKind.EPIGRAPH);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FB2Tag.POEM:
|
case FB2Tag.POEM:
|
||||||
|
@ -238,52 +244,52 @@ public class FB2Reader extends ZLXMLReader {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FB2Tag.STANZA:
|
case FB2Tag.STANZA:
|
||||||
myModelReader.pushKind(FBTextKind.STANZA);
|
modelReader.pushKind(FBTextKind.STANZA);
|
||||||
myModelReader.beginParagraph(ZLTextParagraph.Kind.BEFORE_SKIP_PARAGRAPH);
|
modelReader.beginParagraph(ZLTextParagraph.Kind.BEFORE_SKIP_PARAGRAPH);
|
||||||
myModelReader.endParagraph();
|
modelReader.endParagraph();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FB2Tag.SECTION:
|
case FB2Tag.SECTION:
|
||||||
if (myReadMainText) {
|
if (myReadMainText) {
|
||||||
myModelReader.insertEndOfSectionParagraph();
|
modelReader.insertEndOfSectionParagraph();
|
||||||
++mySectionDepth;
|
++mySectionDepth;
|
||||||
myModelReader.beginContentsParagraph();
|
modelReader.beginContentsParagraph();
|
||||||
mySectionStarted = true;
|
mySectionStarted = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FB2Tag.ANNOTATION:
|
case FB2Tag.ANNOTATION:
|
||||||
if (myBodyCounter == 0) {
|
if (myBodyCounter == 0) {
|
||||||
myModelReader.setMainTextModel();
|
modelReader.setMainTextModel();
|
||||||
}
|
}
|
||||||
myModelReader.pushKind(FBTextKind.ANNOTATION);
|
modelReader.pushKind(FBTextKind.ANNOTATION);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FB2Tag.TITLE:
|
case FB2Tag.TITLE:
|
||||||
if (myInsidePoem) {
|
if (myInsidePoem) {
|
||||||
myModelReader.pushKind(FBTextKind.POEM_TITLE);
|
modelReader.pushKind(FBTextKind.POEM_TITLE);
|
||||||
} else if (mySectionDepth == 0) {
|
} else if (mySectionDepth == 0) {
|
||||||
myModelReader.insertEndOfSectionParagraph();
|
modelReader.insertEndOfSectionParagraph();
|
||||||
myModelReader.pushKind(FBTextKind.TITLE);
|
modelReader.pushKind(FBTextKind.TITLE);
|
||||||
} else {
|
} else {
|
||||||
myModelReader.pushKind(FBTextKind.SECTION_TITLE);
|
modelReader.pushKind(FBTextKind.SECTION_TITLE);
|
||||||
myInsideTitle = true;
|
myInsideTitle = true;
|
||||||
myModelReader.enterTitle();
|
modelReader.enterTitle();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FB2Tag.BODY:
|
case FB2Tag.BODY:
|
||||||
++myBodyCounter;
|
++myBodyCounter;
|
||||||
myParagraphsBeforeBodyNumber = myModelReader.getModel().getBookTextModel().getParagraphsNumber();
|
myParagraphsBeforeBodyNumber = modelReader.getModel().getBookTextModel().getParagraphsNumber();
|
||||||
if ((myBodyCounter == 1) || (attributes.get("name") == null)) {
|
if ((myBodyCounter == 1) || (attributes.getValue("name") == null)) {
|
||||||
myModelReader.setMainTextModel();
|
modelReader.setMainTextModel();
|
||||||
myReadMainText = true;
|
myReadMainText = true;
|
||||||
}
|
}
|
||||||
myModelReader.pushKind(FBTextKind.REGULAR);
|
modelReader.pushKind(FBTextKind.REGULAR);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FB2Tag.A:
|
case FB2Tag.A:
|
||||||
String ref = reference(attributes);
|
String ref = attributes.getValue(myHrefAttribute);
|
||||||
if ((ref != null) && (ref.length() != 0)) {
|
if ((ref != null) && (ref.length() != 0)) {
|
||||||
if (ref.charAt(0) == '#') {
|
if (ref.charAt(0) == '#') {
|
||||||
myHyperlinkType = FBTextKind.FOOTNOTE;
|
myHyperlinkType = FBTextKind.FOOTNOTE;
|
||||||
|
@ -291,24 +297,24 @@ public class FB2Reader extends ZLXMLReader {
|
||||||
} else {
|
} else {
|
||||||
myHyperlinkType = FBTextKind.EXTERNAL_HYPERLINK;
|
myHyperlinkType = FBTextKind.EXTERNAL_HYPERLINK;
|
||||||
}
|
}
|
||||||
myModelReader.addHyperlinkControl(myHyperlinkType, ref);
|
modelReader.addHyperlinkControl(myHyperlinkType, ref);
|
||||||
} else {
|
} else {
|
||||||
myHyperlinkType = FBTextKind.FOOTNOTE;
|
myHyperlinkType = FBTextKind.FOOTNOTE;
|
||||||
myModelReader.addControl(myHyperlinkType, true);
|
modelReader.addControl(myHyperlinkType, true);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FB2Tag.COVERPAGE:
|
case FB2Tag.COVERPAGE:
|
||||||
if (myBodyCounter == 0) {
|
if (myBodyCounter == 0) {
|
||||||
myInsideCoverpage = true;
|
myInsideCoverpage = true;
|
||||||
myModelReader.setMainTextModel();
|
modelReader.setMainTextModel();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FB2Tag.IMAGE:
|
case FB2Tag.IMAGE:
|
||||||
String imgRef = reference(attributes);
|
String imgRef = attributes.getValue(myHrefAttribute);
|
||||||
if ((imgRef != null) && (imgRef.length() != 0) && (imgRef.charAt(0) == '#')) {
|
if ((imgRef != null) && (imgRef.length() != 0) && (imgRef.charAt(0) == '#')) {
|
||||||
String vOffset = attributes.get("voffset");
|
String vOffset = attributes.getValue("voffset");
|
||||||
short offset = 0;
|
short offset = 0;
|
||||||
try {
|
try {
|
||||||
offset = Short.parseShort(vOffset);
|
offset = Short.parseShort(vOffset);
|
||||||
|
@ -316,8 +322,8 @@ public class FB2Reader extends ZLXMLReader {
|
||||||
}
|
}
|
||||||
imgRef = imgRef.substring(1);
|
imgRef = imgRef.substring(1);
|
||||||
if (!imgRef.equals(myCoverImageReference) ||
|
if (!imgRef.equals(myCoverImageReference) ||
|
||||||
myParagraphsBeforeBodyNumber != myModelReader.getModel().getBookTextModel().getParagraphsNumber()) {
|
myParagraphsBeforeBodyNumber != modelReader.getModel().getBookTextModel().getParagraphsNumber()) {
|
||||||
myModelReader.addImageReference(imgRef, offset);
|
modelReader.addImageReference(imgRef, offset);
|
||||||
}
|
}
|
||||||
if (myInsideCoverpage) {
|
if (myInsideCoverpage) {
|
||||||
myCoverImageReference = imgRef;
|
myCoverImageReference = imgRef;
|
||||||
|
@ -326,11 +332,11 @@ public class FB2Reader extends ZLXMLReader {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FB2Tag.BINARY:
|
case FB2Tag.BINARY:
|
||||||
String contentType = attributes.get("content-type");
|
String contentType = attributes.getValue("content-type");
|
||||||
String imgId = attributes.get("id");
|
String imgId = attributes.getValue("id");
|
||||||
if ((contentType != null) && (id != null)) {
|
if ((contentType != null) && (id != null)) {
|
||||||
myCurrentImage = new Base64EncodedImage(contentType);
|
myCurrentImage = new Base64EncodedImage(contentType);
|
||||||
myModelReader.addImage(imgId, myCurrentImage);
|
modelReader.addImage(imgId, myCurrentImage);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@ final class FB2Tag {
|
||||||
public static final byte BODY = 22;
|
public static final byte BODY = 22;
|
||||||
public static final byte IMAGE = 23;
|
public static final byte IMAGE = 23;
|
||||||
public static final byte BINARY = 24;
|
public static final byte BINARY = 24;
|
||||||
|
public static final byte FICTIONBOOK = 25;
|
||||||
|
|
||||||
private static final HashMap<String,Byte> ourTagByName = new HashMap<String,Byte>();
|
private static final HashMap<String,Byte> ourTagByName = new HashMap<String,Byte>();
|
||||||
|
|
||||||
|
@ -57,6 +58,7 @@ final class FB2Tag {
|
||||||
ourTagByName.put("BODY", BODY);
|
ourTagByName.put("BODY", BODY);
|
||||||
ourTagByName.put("IMAGE", IMAGE);
|
ourTagByName.put("IMAGE", IMAGE);
|
||||||
ourTagByName.put("BINARY", BINARY);
|
ourTagByName.put("BINARY", BINARY);
|
||||||
|
ourTagByName.put("FICTIONBOOK", FICTIONBOOK);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte getTagByName(String name) {
|
public static byte getTagByName(String name) {
|
||||||
|
|
|
@ -3,6 +3,7 @@ package org.zlibrary.core.application;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import org.zlibrary.core.library.ZLibrary;
|
import org.zlibrary.core.library.ZLibrary;
|
||||||
|
import org.zlibrary.core.xml.ZLXMLReader;
|
||||||
import org.zlibrary.core.options.*;
|
import org.zlibrary.core.options.*;
|
||||||
import org.zlibrary.core.resources.*;
|
import org.zlibrary.core.resources.*;
|
||||||
import org.zlibrary.core.view.*;
|
import org.zlibrary.core.view.*;
|
||||||
|
@ -59,19 +60,16 @@ public abstract class ZLApplication {
|
||||||
|
|
||||||
//myPresentWindowHandler = new PresentWindowHandler(this);
|
//myPresentWindowHandler = new PresentWindowHandler(this);
|
||||||
//ZLCommunicationManager.instance().registerHandler("present", myPresentWindowHandler);
|
//ZLCommunicationManager.instance().registerHandler("present", myPresentWindowHandler);
|
||||||
|
|
||||||
|
new ToolbarCreator().read("data/default/toolbar.xml");
|
||||||
|
new MenubarCreator().read("data/default/menubar.xml");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final Toolbar getToolbar() {
|
final Toolbar getToolbar() {
|
||||||
if (myToolbar == null) {
|
|
||||||
myToolbar = new Toolbar();
|
|
||||||
}
|
|
||||||
return myToolbar;
|
return myToolbar;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final Menubar getMenubar() {
|
final Menubar getMenubar() {
|
||||||
if (myMenubar == null) {
|
|
||||||
myMenubar = new Menubar();
|
|
||||||
}
|
|
||||||
return myMenubar;
|
return myMenubar;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,7 +180,7 @@ public abstract class ZLApplication {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final ZLAction getAction(Integer actionId) {
|
private final ZLAction getAction(int actionId) {
|
||||||
if ((actionId >= 0) && (actionId < 256)) {
|
if ((actionId >= 0) && (actionId < 256)) {
|
||||||
return myActionMap[actionId];
|
return myActionMap[actionId];
|
||||||
}
|
}
|
||||||
|
@ -346,8 +344,12 @@ public abstract class ZLApplication {
|
||||||
myItems.add(new SeparatorItem());
|
myItems.add(new SeparatorItem());
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Item> items() {
|
int size() {
|
||||||
return Collections.unmodifiableList(myItems);
|
return myItems.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
Item getItem(int index) {
|
||||||
|
return myItems.get(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface Item {
|
public interface Item {
|
||||||
|
@ -425,7 +427,7 @@ public abstract class ZLApplication {
|
||||||
|
|
||||||
public final class ButtonGroup {
|
public final class ButtonGroup {
|
||||||
public final int UnselectAllButtonsActionId;
|
public final int UnselectAllButtonsActionId;
|
||||||
public final HashSet<ButtonItem> Items = new HashSet<ButtonItem>();
|
public final ArrayList<ButtonItem> Items = new ArrayList<ButtonItem>();
|
||||||
public ButtonItem PressedItem;
|
public ButtonItem PressedItem;
|
||||||
|
|
||||||
ButtonGroup(int unselectAllButtonsActionId) {
|
ButtonGroup(int unselectAllButtonsActionId) {
|
||||||
|
@ -440,7 +442,7 @@ public abstract class ZLApplication {
|
||||||
}
|
}
|
||||||
|
|
||||||
//Menu
|
//Menu
|
||||||
static public class Menu {
|
static class Menu {
|
||||||
public interface Item {
|
public interface Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -455,22 +457,26 @@ public abstract class ZLApplication {
|
||||||
return myResource;
|
return myResource;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addItem(int actionId, String key) {
|
void addItem(int actionId, String key) {
|
||||||
myItems.add(new Menubar.PlainItem(myResource.getResource(key).getValue(), actionId));
|
myItems.add(new Menubar.PlainItem(myResource.getResource(key).getValue(), actionId));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addSeparator() {
|
void addSeparator() {
|
||||||
myItems.add(new Menubar.Separator());
|
myItems.add(new Menubar.Separator());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Menu addSubmenu(String key) {
|
Menubar.Submenu addSubmenu(String key) {
|
||||||
Menubar.Submenu submenu = new Menubar.Submenu(myResource.getResource(key));
|
Menubar.Submenu submenu = new Menubar.Submenu(myResource.getResource(key));
|
||||||
myItems.add(submenu);
|
myItems.add(submenu);
|
||||||
return submenu;
|
return submenu;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Item> items() {
|
int size() {
|
||||||
return Collections.unmodifiableList(myItems);
|
return myItems.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
Item getItem(int index) {
|
||||||
|
return myItems.get(index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -514,8 +520,16 @@ public abstract class ZLApplication {
|
||||||
|
|
||||||
//MenuVisitor
|
//MenuVisitor
|
||||||
static public abstract class MenuVisitor {
|
static public abstract class MenuVisitor {
|
||||||
public final void processMenu(Menu menu) {
|
public final void processMenu(ZLApplication application) {
|
||||||
for (Menu.Item item : menu.items()) {
|
if (application.myMenubar != null) {
|
||||||
|
processMenu(application.myMenubar);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private final void processMenu(Menu menu) {
|
||||||
|
final int size = menu.size();
|
||||||
|
for (int i = 0; i < size; ++i) {
|
||||||
|
final Menu.Item item = menu.getItem(i);
|
||||||
if (item instanceof Menubar.PlainItem) {
|
if (item instanceof Menubar.PlainItem) {
|
||||||
processItem((Menubar.PlainItem)item);
|
processItem((Menubar.PlainItem)item);
|
||||||
} else if (item instanceof Menubar.Submenu) {
|
} else if (item instanceof Menubar.Submenu) {
|
||||||
|
@ -544,4 +558,68 @@ public abstract class ZLApplication {
|
||||||
//public String lastCaller();
|
//public String lastCaller();
|
||||||
//public void resetLastCaller();
|
//public void resetLastCaller();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class ToolbarCreator extends ZLXMLReader {
|
||||||
|
private static final String BUTTON = "button";
|
||||||
|
private static final String SEPARATOR = "separator";
|
||||||
|
|
||||||
|
public void startElementHandler(String tag, StringMap attributes) {
|
||||||
|
if (myToolbar == null) {
|
||||||
|
myToolbar = new Toolbar();
|
||||||
|
}
|
||||||
|
if (BUTTON == tag) {
|
||||||
|
String action = attributes.getValue("action");
|
||||||
|
String key = attributes.getValue("key");
|
||||||
|
if ((action != null) && (key != null)) {
|
||||||
|
try {
|
||||||
|
int actionId = Integer.parseInt(action);
|
||||||
|
myToolbar.addButton(actionId, key);
|
||||||
|
} catch (NumberFormatException exception) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (SEPARATOR == tag) {
|
||||||
|
myToolbar.addSeparator();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class MenubarCreator extends ZLXMLReader {
|
||||||
|
private static final String ITEM = "item";
|
||||||
|
private static final String SUBMENU = "submenu";
|
||||||
|
|
||||||
|
private final ArrayList<Menubar.Submenu> mySubmenuStack = new ArrayList<Menubar.Submenu>();
|
||||||
|
|
||||||
|
public void startElementHandler(String tag, StringMap attributes) {
|
||||||
|
if (myMenubar == null) {
|
||||||
|
myMenubar = new Menubar();
|
||||||
|
}
|
||||||
|
final ArrayList<Menubar.Submenu> stack = mySubmenuStack;
|
||||||
|
Menu menu = stack.isEmpty() ? myMenubar : stack.get(stack.size() - 1);
|
||||||
|
if (ITEM == tag) {
|
||||||
|
String action = attributes.getValue("action");
|
||||||
|
String key = attributes.getValue("key");
|
||||||
|
if ((action != null) && (key != null)) {
|
||||||
|
try {
|
||||||
|
int actionId = Integer.parseInt(action);
|
||||||
|
menu.addItem(actionId, key);
|
||||||
|
} catch (NumberFormatException exception) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (SUBMENU == tag) {
|
||||||
|
String key = attributes.getValue("key");
|
||||||
|
if (key != null) {
|
||||||
|
stack.add(menu.addSubmenu(key));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void endElementHandler(String tag) {
|
||||||
|
if (SUBMENU == tag) {
|
||||||
|
final ArrayList<Menubar.Submenu> stack = mySubmenuStack;
|
||||||
|
if (!stack.isEmpty()) {
|
||||||
|
stack.remove(stack.size() - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package org.zlibrary.core.application;
|
package org.zlibrary.core.application;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.ArrayList;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.zlibrary.core.view.ZLViewWidget;
|
import org.zlibrary.core.view.ZLViewWidget;
|
||||||
|
|
||||||
|
@ -22,9 +21,12 @@ abstract public class ZLApplicationWindow {
|
||||||
protected void init() {
|
protected void init() {
|
||||||
myApplication.setViewWidget(createViewWidget());
|
myApplication.setViewWidget(createViewWidget());
|
||||||
|
|
||||||
List<ZLApplication.Toolbar.Item> toolbarItems = myApplication.getToolbar().items();
|
final ZLApplication.Toolbar toolbar = myApplication.getToolbar();
|
||||||
for (ZLApplication.Toolbar.Item item: toolbarItems) {
|
if (toolbar != null) {
|
||||||
addToolbarItem(item);
|
final int size = toolbar.size();
|
||||||
|
for (int i = 0; i < size; ++i) {
|
||||||
|
addToolbarItem(toolbar.getItem(i));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
initMenu();
|
initMenu();
|
||||||
|
@ -45,9 +47,10 @@ abstract public class ZLApplicationWindow {
|
||||||
} else {
|
} else {
|
||||||
button.press();
|
button.press();
|
||||||
ZLApplication.Toolbar.ButtonGroup group = button.getButtonGroup();
|
ZLApplication.Toolbar.ButtonGroup group = button.getButtonGroup();
|
||||||
Set<ZLApplication.Toolbar.ButtonItem> items = group.Items;
|
final ArrayList<ZLApplication.Toolbar.ButtonItem> items = group.Items;
|
||||||
for (ZLApplication.Toolbar.ButtonItem bitem: items) {
|
final int size = items.size();
|
||||||
setToggleButtonState(bitem);
|
for (int i = 0; i < size; ++i) {
|
||||||
|
setToggleButtonState(items.get(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
myToggleButtonLock = false;
|
myToggleButtonLock = false;
|
||||||
|
@ -66,10 +69,13 @@ abstract public class ZLApplicationWindow {
|
||||||
abstract public void addToolbarItem(ZLApplication.Toolbar.Item item);
|
abstract public void addToolbarItem(ZLApplication.Toolbar.Item item);
|
||||||
|
|
||||||
protected void refresh() {
|
protected void refresh() {
|
||||||
List<ZLApplication.Toolbar.Item> items = getApplication().getToolbar().items();
|
final ZLApplication.Toolbar toolbar = myApplication.getToolbar();
|
||||||
|
if (toolbar != null) {
|
||||||
boolean enableToolbarSpace = false;
|
boolean enableToolbarSpace = false;
|
||||||
ZLApplication.Toolbar.Item lastSeparator = null;
|
ZLApplication.Toolbar.Item lastSeparator = null;
|
||||||
for (ZLApplication.Toolbar.Item item : items) {
|
final int size = toolbar.size();
|
||||||
|
for (int i = 0; i < size; ++i) {
|
||||||
|
final ZLApplication.Toolbar.Item item = toolbar.getItem(i);
|
||||||
if (item instanceof ZLApplication.Toolbar.OptionEntryItem) {
|
if (item instanceof ZLApplication.Toolbar.OptionEntryItem) {
|
||||||
/*case OPTION_ENTRY:
|
/*case OPTION_ENTRY:
|
||||||
{
|
{
|
||||||
|
@ -122,6 +128,7 @@ abstract public class ZLApplicationWindow {
|
||||||
setToolbarItemState(lastSeparator, false, true);
|
setToolbarItemState(lastSeparator, false, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// TODO: change to pure virtual
|
// TODO: change to pure virtual
|
||||||
//virtual void present() {}
|
//virtual void present() {}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
package org.zlibrary.core.application;
|
package org.zlibrary.core.application;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.HashMap;
|
||||||
import java.util.TreeMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.zlibrary.core.options.ZLIntegerOption;
|
import org.zlibrary.core.options.ZLIntegerOption;
|
||||||
|
@ -16,12 +14,12 @@ public final class ZLKeyBindings {
|
||||||
private static final String BINDED_ACTION = "Action";
|
private static final String BINDED_ACTION = "Action";
|
||||||
|
|
||||||
private final String myName;
|
private final String myName;
|
||||||
private final TreeMap<String,Integer> myBindingsMap = new TreeMap<String, Integer>();
|
private final HashMap<String,Integer> myBindingsMap = new HashMap<String,Integer>();
|
||||||
private boolean myIsChanged;
|
private boolean myIsChanged;
|
||||||
|
|
||||||
public ZLKeyBindings(String name) {
|
public ZLKeyBindings(String name) {
|
||||||
myName = name;
|
myName = name;
|
||||||
loadDefaultBindings();
|
new ZLKeyBindingsReader(myBindingsMap).readBindings();
|
||||||
loadCustomBindings();
|
loadCustomBindings();
|
||||||
myIsChanged = false;
|
myIsChanged = false;
|
||||||
}
|
}
|
||||||
|
@ -40,14 +38,6 @@ public final class ZLKeyBindings {
|
||||||
return myBindingsMap.keySet();
|
return myBindingsMap.keySet();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadDefaultBindings() {
|
|
||||||
TreeMap<String,Integer> keymap = new TreeMap<String,Integer>();
|
|
||||||
new ZLKeyBindingsReader(keymap).readBindings();
|
|
||||||
for (Map.Entry<String,Integer> entry: keymap.entrySet()) {
|
|
||||||
bindKey(entry.getKey(), entry.getValue());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void loadCustomBindings() {
|
private void loadCustomBindings() {
|
||||||
final int size =
|
final int size =
|
||||||
new ZLIntegerRangeOption(ZLOption.CONFIG_CATEGORY, myName, BINDINGS_NUMBER, 0, 256, 0).getValue();
|
new ZLIntegerRangeOption(ZLOption.CONFIG_CATEGORY, myName, BINDINGS_NUMBER, 0, 256, 0).getValue();
|
||||||
|
@ -73,7 +63,7 @@ public final class ZLKeyBindings {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
TreeMap<String,Integer> keymap = new TreeMap<String,Integer>();
|
final HashMap<String,Integer> keymap = new HashMap<String,Integer>();
|
||||||
new ZLKeyBindingsReader(keymap).readBindings();
|
new ZLKeyBindingsReader(keymap).readBindings();
|
||||||
|
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
|
@ -81,14 +71,14 @@ public final class ZLKeyBindings {
|
||||||
new ZLStringOption(ZLOption.CONFIG_CATEGORY, myName, "", "");
|
new ZLStringOption(ZLOption.CONFIG_CATEGORY, myName, "", "");
|
||||||
final ZLIntegerOption actionOption =
|
final ZLIntegerOption actionOption =
|
||||||
new ZLIntegerOption(ZLOption.CONFIG_CATEGORY, myName, "", -1);
|
new ZLIntegerOption(ZLOption.CONFIG_CATEGORY, myName, "", -1);
|
||||||
for (Map.Entry<String,Integer> entry : myBindingsMap.entrySet()) {
|
for (String key : myBindingsMap.keySet()) {
|
||||||
Integer original = keymap.get(entry.getKey());
|
Integer originalValue = keymap.get(key);
|
||||||
int defaultAction = original;
|
Integer value = myBindingsMap.get(key);
|
||||||
if (defaultAction != entry.getValue()) {
|
if (!originalValue.equals(value)) {
|
||||||
keyOption.changeName(BINDED_KEY + counter);
|
keyOption.changeName(BINDED_KEY + counter);
|
||||||
actionOption.changeName(BINDED_ACTION + counter);
|
actionOption.changeName(BINDED_ACTION + counter);
|
||||||
keyOption.setValue(entry.getKey());
|
keyOption.setValue(key);
|
||||||
actionOption.setValue(entry.getValue());
|
actionOption.setValue(value);
|
||||||
++counter;
|
++counter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,29 +1,31 @@
|
||||||
package org.zlibrary.core.application;
|
package org.zlibrary.core.application;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.HashMap;
|
||||||
import java.util.TreeMap;
|
|
||||||
|
|
||||||
import org.zlibrary.core.xml.ZLXMLReader;
|
import org.zlibrary.core.xml.ZLXMLReader;
|
||||||
|
|
||||||
class ZLKeyBindingsReader extends ZLXMLReader {
|
class ZLKeyBindingsReader extends ZLXMLReader {
|
||||||
private TreeMap<String,Integer> myKeymap;
|
private HashMap<String,Integer> myKeymap;
|
||||||
private final static String myKeymapFileName = "data/default/keymap.xml";
|
|
||||||
|
|
||||||
public ZLKeyBindingsReader(TreeMap<String,Integer> keymap) {
|
public ZLKeyBindingsReader(HashMap<String,Integer> keymap) {
|
||||||
myKeymap = keymap;
|
myKeymap = keymap;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startElementHandler(String tag, Map<String,String> attributes) {
|
public void startElementHandler(String tag, StringMap attributes) {
|
||||||
if ("binding".equals(tag)) {
|
if ("binding".equals(tag)) {
|
||||||
String key = attributes.get("key");
|
String key = attributes.getValue("key");
|
||||||
String action = attributes.get("action");
|
String action = attributes.getValue("action");
|
||||||
if ((key != null) && (action != null)) {
|
if ((key != null) && (action != null)) {
|
||||||
myKeymap.put(key, Integer.parseInt(action));
|
try {
|
||||||
|
int actionId = Integer.parseInt(action);
|
||||||
|
myKeymap.put(key, actionId);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void readBindings() {
|
public void readBindings() {
|
||||||
read(myKeymapFileName);
|
read("data/default/keymap.xml");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
8
src/org/zlibrary/core/config/ZLConfig.java
Normal file
8
src/org/zlibrary/core/config/ZLConfig.java
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
package org.zlibrary.core.config;
|
||||||
|
|
||||||
|
public interface ZLConfig {
|
||||||
|
void removeGroup(String name);
|
||||||
|
String getValue(String group, String name, String defaultValue);
|
||||||
|
void setValue(String group, String name, String value, String category);
|
||||||
|
void unsetValue(String group, String name);
|
||||||
|
}
|
37
src/org/zlibrary/core/config/ZLConfigManager.java
Normal file
37
src/org/zlibrary/core/config/ZLConfigManager.java
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
package org.zlibrary.core.config;
|
||||||
|
|
||||||
|
public abstract class ZLConfigManager {
|
||||||
|
private static ZLConfigManager ourInstance;
|
||||||
|
private static ZLConfig ourConfig;
|
||||||
|
|
||||||
|
// TODO: remove this method
|
||||||
|
public static ZLConfigManager getInstance() {
|
||||||
|
return ourInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ZLConfig getConfig() {
|
||||||
|
return ourConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static void setConfig(ZLConfig config) {
|
||||||
|
ourConfig = config;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void release() {
|
||||||
|
if (ourInstance != null) {
|
||||||
|
ourInstance.shutdown();
|
||||||
|
ourInstance = null;
|
||||||
|
ourConfig = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract void shutdown();
|
||||||
|
|
||||||
|
// TODO: remove these methods
|
||||||
|
public abstract void saveAll();
|
||||||
|
public abstract void saveDelta();
|
||||||
|
|
||||||
|
protected ZLConfigManager() {
|
||||||
|
ourInstance = this;
|
||||||
|
}
|
||||||
|
}
|
5
src/org/zlibrary/core/image/ZLImageMap.java
Normal file
5
src/org/zlibrary/core/image/ZLImageMap.java
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
package org.zlibrary.core.image;
|
||||||
|
|
||||||
|
public interface ZLImageMap {
|
||||||
|
ZLImage getImage(String id);
|
||||||
|
}
|
|
@ -2,15 +2,14 @@ package org.zlibrary.core.library;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.HashMap;
|
||||||
import java.util.TreeMap;
|
|
||||||
|
|
||||||
import org.zlibrary.core.application.ZLApplication;
|
import org.zlibrary.core.application.ZLApplication;
|
||||||
import org.zlibrary.core.xml.ZLXMLReader;
|
import org.zlibrary.core.xml.ZLXMLReader;
|
||||||
import org.zlibrary.core.view.ZLPaintContext;
|
import org.zlibrary.core.view.ZLPaintContext;
|
||||||
|
|
||||||
public abstract class ZLibrary {
|
public abstract class ZLibrary {
|
||||||
private final TreeMap<String,String> myProperties = new TreeMap<String,String>();
|
private final HashMap<String,String> myProperties = new HashMap<String,String>();
|
||||||
|
|
||||||
public static ZLibrary getInstance() {
|
public static ZLibrary getInstance() {
|
||||||
return ourImplementation;
|
return ourImplementation;
|
||||||
|
@ -42,9 +41,9 @@ public abstract class ZLibrary {
|
||||||
|
|
||||||
protected final void loadProperties() {
|
protected final void loadProperties() {
|
||||||
new ZLXMLReader() {
|
new ZLXMLReader() {
|
||||||
public void startElementHandler(String tag, Map<String, String> attributes) {
|
public void startElementHandler(String tag, StringMap attributes) {
|
||||||
if (tag.equals("property")) {
|
if (tag.equals("property")) {
|
||||||
myProperties.put(attributes.get("name"), attributes.get("value"));
|
myProperties.put(attributes.getValue("name"), attributes.getValue("value"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.read("data/application.xml");
|
}.read("data/application.xml");
|
||||||
|
|
|
@ -21,8 +21,7 @@ public final class ZLDoubleOption extends ZLOption {
|
||||||
String value = getConfigValue(null);
|
String value = getConfigValue(null);
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
try {
|
try {
|
||||||
Double doubleValue = Double.parseDouble(value);
|
myValue = Double.parseDouble(value);
|
||||||
myValue = doubleValue;
|
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
// System.err.println(e);
|
// System.err.println(e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,8 +27,7 @@ public final class ZLIntegerOption extends ZLOption {
|
||||||
String value = getConfigValue(null);
|
String value = getConfigValue(null);
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
try {
|
try {
|
||||||
Integer intValue = Integer.parseInt(value);
|
myValue = Integer.parseInt(value);
|
||||||
myValue = intValue;
|
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
// System.err.println(e);
|
// System.err.println(e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,8 +35,13 @@ public final class ZLIntegerRangeOption extends ZLOption {
|
||||||
String value = getConfigValue(null);
|
String value = getConfigValue(null);
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
try {
|
try {
|
||||||
Integer intValue = Integer.parseInt(value);
|
int intValue = Integer.parseInt(value);
|
||||||
myValue = Math.max(myMinValue, Math.min(myMaxValue, intValue));
|
if (intValue < myMinValue) {
|
||||||
|
intValue = myMinValue;
|
||||||
|
} else if (intValue > myMaxValue) {
|
||||||
|
intValue = myMaxValue;
|
||||||
|
}
|
||||||
|
myValue = intValue;
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
// System.err.println(e);
|
// System.err.println(e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
package org.zlibrary.core.options;
|
package org.zlibrary.core.options;
|
||||||
|
|
||||||
import org.zlibrary.core.options.config.ZLConfig;
|
import org.zlibrary.core.config.ZLConfig;
|
||||||
import org.zlibrary.core.options.config.ZLConfigInstance;
|
import org.zlibrary.core.config.ZLConfigManager;
|
||||||
|
|
||||||
public abstract class ZLOption {
|
public abstract class ZLOption {
|
||||||
public static final String LOOK_AND_FEEL_CATEGORY = "ui";
|
public static final String LOOK_AND_FEEL_CATEGORY = "ui";
|
||||||
public static final String CONFIG_CATEGORY = "options";
|
public static final String CONFIG_CATEGORY = "options";
|
||||||
public static final String STATE_CATEGORY = "state";
|
public static final String STATE_CATEGORY = "state";
|
||||||
|
|
||||||
private final ZLConfig myConfig = ZLConfigInstance.getInstance();
|
|
||||||
private final String myCategory;
|
private final String myCategory;
|
||||||
private final String myGroup;
|
private final String myGroup;
|
||||||
private String myOptionName;
|
private String myOptionName;
|
||||||
|
@ -66,14 +65,22 @@ public abstract class ZLOption {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final String getConfigValue(String defaultValue) {
|
protected final String getConfigValue(String defaultValue) {
|
||||||
return myConfig.getValue(myGroup, myOptionName, defaultValue);
|
ZLConfig config = ZLConfigManager.getConfig();
|
||||||
|
return (config != null) ?
|
||||||
|
config.getValue(myGroup, myOptionName, defaultValue) : defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final void setConfigValue(String value) {
|
protected final void setConfigValue(String value) {
|
||||||
myConfig.setValue(myGroup, myOptionName, value, myCategory);
|
ZLConfig config = ZLConfigManager.getConfig();
|
||||||
|
if (config != null) {
|
||||||
|
config.setValue(myGroup, myOptionName, value, myCategory);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final void unsetConfigValue() {
|
protected final void unsetConfigValue() {
|
||||||
myConfig.unsetValue(myGroup, myOptionName);
|
ZLConfig config = ZLConfigManager.getConfig();
|
||||||
|
if (config != null) {
|
||||||
|
config.unsetValue(myGroup, myOptionName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
package org.zlibrary.core.options.config;
|
|
||||||
|
|
||||||
public interface ZLConfig {
|
|
||||||
public void removeGroup(String name);
|
|
||||||
|
|
||||||
public String getValue(String group, String name, String defaultValue);
|
|
||||||
|
|
||||||
public void setValue(String group, String name, String value, String category);
|
|
||||||
|
|
||||||
public void unsetValue(String group, String name);
|
|
||||||
}
|
|
|
@ -1,9 +0,0 @@
|
||||||
package org.zlibrary.core.options.config;
|
|
||||||
|
|
||||||
public final class ZLConfigInstance {
|
|
||||||
private static final ZLConfigImpl myConfig = new ZLConfigImpl();
|
|
||||||
|
|
||||||
public static ZLConfig getInstance() {
|
|
||||||
return myConfig;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,7 +0,0 @@
|
||||||
package org.zlibrary.core.options.config;
|
|
||||||
|
|
||||||
public final class ZLConfigReaderFactory {
|
|
||||||
public static ZLReader createConfigReader(String path) {
|
|
||||||
return new ZLConfigReader(path);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,7 +0,0 @@
|
||||||
package org.zlibrary.core.options.config;
|
|
||||||
|
|
||||||
public final class ZLConfigWriterFactory {
|
|
||||||
public static ZLWriter createConfigWriter(String path) {
|
|
||||||
return new ZLConfigWriter(path);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,11 +1,11 @@
|
||||||
package org.zlibrary.core.resources;
|
package org.zlibrary.core.resources;
|
||||||
|
|
||||||
final class ZLMissingResource extends ZLResource {
|
final class ZLMissingResource extends ZLResource {
|
||||||
static final String ourValue = "????????";
|
static final String Value = "????????";
|
||||||
private static ZLMissingResource ourInstance;
|
static final ZLMissingResource Instance = new ZLMissingResource();
|
||||||
|
|
||||||
private ZLMissingResource() {
|
private ZLMissingResource() {
|
||||||
super(ourValue);
|
super(Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ZLResource getResource(String key) {
|
public ZLResource getResource(String key) {
|
||||||
|
@ -17,13 +17,6 @@ final class ZLMissingResource extends ZLResource {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getValue() {
|
public String getValue() {
|
||||||
return ourValue;
|
return Value;
|
||||||
}
|
|
||||||
|
|
||||||
public static ZLMissingResource instance() {
|
|
||||||
if (ourInstance == null) {
|
|
||||||
ourInstance = new ZLMissingResource();
|
|
||||||
}
|
|
||||||
return ourInstance;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,22 +1,18 @@
|
||||||
package org.zlibrary.core.resources;
|
package org.zlibrary.core.resources;
|
||||||
|
|
||||||
abstract public class ZLResource {
|
abstract public class ZLResource {
|
||||||
private String myName;
|
public final String Name;
|
||||||
|
|
||||||
public static ZLResource resource(String key) {
|
public static ZLResource resource(String key) {
|
||||||
ZLTreeResource.buildTree();
|
ZLTreeResource.buildTree();
|
||||||
if (ZLTreeResource.ourRoot == null) {
|
if (ZLTreeResource.ourRoot == null) {
|
||||||
return ZLMissingResource.instance();
|
return ZLMissingResource.Instance;
|
||||||
}
|
}
|
||||||
return ZLTreeResource.ourRoot.getResource(key);
|
return ZLTreeResource.ourRoot.getResource(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ZLResource(String name) {
|
protected ZLResource(String name) {
|
||||||
myName = name;
|
Name = name;
|
||||||
}
|
|
||||||
|
|
||||||
public final String getName() {
|
|
||||||
return myName;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract public boolean hasValue();
|
abstract public boolean hasValue();
|
||||||
|
|
|
@ -8,11 +8,11 @@ final class ZLTreeResource extends ZLResource {
|
||||||
|
|
||||||
private boolean myHasValue;
|
private boolean myHasValue;
|
||||||
private String myValue;
|
private String myValue;
|
||||||
private TreeMap<String,ZLTreeResource> myChildren;
|
private HashMap<String,ZLTreeResource> myChildren;
|
||||||
|
|
||||||
public static void buildTree() {
|
public static void buildTree() {
|
||||||
if (ourRoot == null) {
|
if (ourRoot == null) {
|
||||||
ourRoot = new ZLTreeResource("");
|
ourRoot = new ZLTreeResource("", null);
|
||||||
loadData("en");
|
loadData("en");
|
||||||
Locale locale = Locale.getDefault();
|
Locale locale = Locale.getDefault();
|
||||||
String language = locale.getLanguage();
|
String language = locale.getLanguage();
|
||||||
|
@ -29,19 +29,13 @@ final class ZLTreeResource extends ZLResource {
|
||||||
reader.readDocument(ourRoot, "data/resources/application/" + fileName);
|
reader.readDocument(ourRoot, "data/resources/application/" + fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ZLTreeResource(String name) {
|
|
||||||
super(name);
|
|
||||||
myHasValue = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private ZLTreeResource(String name, String value) {
|
private ZLTreeResource(String name, String value) {
|
||||||
super(name);
|
super(name);
|
||||||
myHasValue = true;
|
setValue(value);
|
||||||
myValue = value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setValue(String value) {
|
private void setValue(String value) {
|
||||||
myHasValue = true;
|
myHasValue = value != null;
|
||||||
myValue = value;
|
myValue = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,61 +44,62 @@ final class ZLTreeResource extends ZLResource {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getValue() {
|
public String getValue() {
|
||||||
return myHasValue ? myValue : ZLMissingResource.ourValue;
|
return myHasValue ? myValue : ZLMissingResource.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ZLResource getResource(String key) {
|
public ZLResource getResource(String key) {
|
||||||
if (myChildren != null) {
|
final HashMap<String,ZLTreeResource> children = myChildren;
|
||||||
ZLResource child = myChildren.get(key);
|
if (children != null) {
|
||||||
|
ZLResource child = children.get(key);
|
||||||
if (child != null) {
|
if (child != null) {
|
||||||
return child;
|
return child;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ZLMissingResource.instance();
|
return ZLMissingResource.Instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ResourceTreeReader extends ZLXMLReader {
|
private static class ResourceTreeReader extends ZLXMLReader {
|
||||||
private static final String NODE = "node";
|
private static final String NODE = "node";
|
||||||
private final ArrayList<ZLTreeResource> myStack = new ArrayList<ZLTreeResource>();
|
private final ArrayList<ZLTreeResource> myStack = new ArrayList<ZLTreeResource>();
|
||||||
|
|
||||||
public void readDocument(ZLTreeResource root, String string) {
|
public void readDocument(ZLTreeResource root, String fileName) {
|
||||||
myStack.clear();
|
myStack.clear();
|
||||||
myStack.add(root);
|
myStack.add(root);
|
||||||
read(string);
|
read(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void endElementHandler(String tag) {
|
public void endElementHandler(String tag) {
|
||||||
if (!myStack.isEmpty() && (NODE.equals(tag))) {
|
final ArrayList<ZLTreeResource> stack = myStack;
|
||||||
myStack.remove(myStack.size() - 1);
|
if (!stack.isEmpty() && (NODE.equals(tag))) {
|
||||||
|
stack.remove(stack.size() - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startElementHandler(String tag, Map<String, String> attributes) {
|
public void startElementHandler(String tag, StringMap attributes) {
|
||||||
if (!myStack.isEmpty() && (NODE.equals(tag))) {
|
final ArrayList<ZLTreeResource> stack = myStack;
|
||||||
String name = attributes.get("name");
|
if (!stack.isEmpty() && (NODE.equals(tag))) {
|
||||||
|
String name = attributes.getValue("name");
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
String value = attributes.get("value");
|
String value = attributes.getValue("value");
|
||||||
ZLTreeResource peek = myStack.get(myStack.size() - 1);
|
ZLTreeResource peek = stack.get(stack.size() - 1);
|
||||||
ZLTreeResource node;
|
ZLTreeResource node;
|
||||||
if (peek.myChildren == null) {
|
HashMap<String,ZLTreeResource> children = peek.myChildren;
|
||||||
|
if (children == null) {
|
||||||
node = null;
|
node = null;
|
||||||
peek.myChildren = new TreeMap<String,ZLTreeResource>();
|
children = new HashMap<String,ZLTreeResource>();
|
||||||
|
peek.myChildren = children;
|
||||||
} else {
|
} else {
|
||||||
node = peek.myChildren.get(name);
|
node = children.get(name);
|
||||||
}
|
}
|
||||||
if (node == null) {
|
if (node == null) {
|
||||||
if (value != null) {
|
|
||||||
node = new ZLTreeResource(name, value);
|
node = new ZLTreeResource(name, value);
|
||||||
} else {
|
children.put(name, node);
|
||||||
node = new ZLTreeResource(name);
|
|
||||||
}
|
|
||||||
peek.myChildren.put(name, node);
|
|
||||||
} else {
|
} else {
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
node.setValue(value);
|
node.setValue(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
myStack.add(node);
|
stack.add(node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package org.zlibrary.core.util;
|
package org.zlibrary.core.util;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
public final class ZLIntArray {
|
public final class ZLIntArray {
|
||||||
private int[] myData;
|
private int[] myData;
|
||||||
private int mySize;
|
private int mySize;
|
||||||
|
|
|
@ -9,7 +9,7 @@ abstract public class ZLPaintContext {
|
||||||
private int myX = 0;
|
private int myX = 0;
|
||||||
private int myY = 0;
|
private int myY = 0;
|
||||||
|
|
||||||
private final ArrayList<String> myFamilies = new ArrayList<String>();
|
//private final ArrayList<String> myFamilies = new ArrayList<String>();
|
||||||
|
|
||||||
public interface LineStyle {
|
public interface LineStyle {
|
||||||
int SOLID_LINE = 0;
|
int SOLID_LINE = 0;
|
||||||
|
|
|
@ -1,11 +1,16 @@
|
||||||
package org.zlibrary.core.xml;
|
package org.zlibrary.core.xml;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.zlibrary.core.library.ZLibrary;
|
import org.zlibrary.core.library.ZLibrary;
|
||||||
|
|
||||||
public abstract class ZLXMLReader {
|
public abstract class ZLXMLReader {
|
||||||
|
public interface StringMap {
|
||||||
|
int getSize();
|
||||||
|
String getKey(int index);
|
||||||
|
String getValue(String key);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean read(String fileName) {
|
public boolean read(String fileName) {
|
||||||
InputStream stream = ZLibrary.getInstance().getResourceInputStream(fileName);
|
InputStream stream = ZLibrary.getInstance().getResourceInputStream(fileName);
|
||||||
if (stream == null) {
|
if (stream == null) {
|
||||||
|
@ -18,7 +23,7 @@ public abstract class ZLXMLReader {
|
||||||
return (stream != null) ? ZLXMLProcessorFactory.getInstance().createXMLProcessor().read(this, stream) : false;
|
return (stream != null) ? ZLXMLProcessorFactory.getInstance().createXMLProcessor().read(this, stream) : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startElementHandler(String tag, Map<String, String> attributes) {
|
public void startElementHandler(String tag, StringMap attributes) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void endElementHandler(String tag) {
|
public void endElementHandler(String tag) {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package org.zlibrary.core.xml.own;
|
package org.zlibrary.core.xml.own;
|
||||||
|
|
||||||
import java.util.TreeMap;
|
import java.util.HashMap;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
|
||||||
import org.zlibrary.core.xml.ZLXMLReader;
|
import org.zlibrary.core.xml.ZLXMLReader;
|
||||||
|
@ -23,71 +23,99 @@ final class ZLOwnXMLParser {
|
||||||
private static final int ATTRIBUTE_VALUE = 14;
|
private static final int ATTRIBUTE_VALUE = 14;
|
||||||
private static final int ENTITY_REF = 15;
|
private static final int ENTITY_REF = 15;
|
||||||
|
|
||||||
private static final class ComparableString implements Comparable<ComparableString> {
|
private static final class StringContainer {
|
||||||
private CharSequence mySequence;
|
private char[] myData;
|
||||||
|
private int myLength;
|
||||||
|
|
||||||
ComparableString(CharSequence sequence) {
|
StringContainer(int len) {
|
||||||
mySequence = sequence;
|
myData = new char[len];
|
||||||
}
|
}
|
||||||
|
|
||||||
ComparableString() {
|
StringContainer() {
|
||||||
|
this(20);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setSequence(CharSequence sequence) {
|
StringContainer(StringContainer container) {
|
||||||
mySequence = sequence;
|
final int len = container.myLength;
|
||||||
|
final char[] data = new char[len];
|
||||||
|
myData = data;
|
||||||
|
myLength = len;
|
||||||
|
System.arraycopy(container.myData, 0, data, 0, len);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void append(char[] buffer, int offset, int count) {
|
||||||
|
final int len = myLength;
|
||||||
|
char[] data = myData;
|
||||||
|
final int newLength = len + count;
|
||||||
|
if (data.length < newLength) {
|
||||||
|
char[] data0 = new char[newLength];
|
||||||
|
if (len > 0) {
|
||||||
|
System.arraycopy(data, 0, data0, 0, len);
|
||||||
|
}
|
||||||
|
data = data0;
|
||||||
|
myData = data;
|
||||||
|
}
|
||||||
|
System.arraycopy(buffer, offset, data, len, count);
|
||||||
|
myLength = newLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clear() {
|
||||||
|
myLength = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
final StringContainer container = (StringContainer)o;
|
||||||
|
final int len = myLength;
|
||||||
|
if (len != container.myLength) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
final char[] data0 = myData;
|
||||||
|
final char[] data1 = container.myData;
|
||||||
|
for (int i = 0; i < len; ++i) {
|
||||||
|
if (data0[i] != data1[i]) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int hashCode() {
|
||||||
|
final int len = myLength;
|
||||||
|
final char[] data = myData;
|
||||||
|
int code = len * 31;
|
||||||
|
if (len > 1) {
|
||||||
|
code += data[0];
|
||||||
|
code *= 31;
|
||||||
|
code += data[1];
|
||||||
|
if (len > 2) {
|
||||||
|
code *= 31;
|
||||||
|
code += data[2];
|
||||||
|
}
|
||||||
|
} else if (len > 0) {
|
||||||
|
code += data[0];
|
||||||
|
}
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return mySequence.toString();
|
return new String(myData, 0, myLength).intern();
|
||||||
}
|
|
||||||
|
|
||||||
public int compareTo(ComparableString string) {
|
|
||||||
CharSequence s = mySequence;
|
|
||||||
CharSequence s1 = string.mySequence;
|
|
||||||
int len = s.length();
|
|
||||||
int len1 = s1.length();
|
|
||||||
if (len != len1) {
|
|
||||||
return len - len1;
|
|
||||||
}
|
|
||||||
for (int i = 0; i < len; ++i) {
|
|
||||||
int c = s.charAt(i);
|
|
||||||
int c1 = s1.charAt(i);
|
|
||||||
if (c != c1) {
|
|
||||||
return c - c1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isWhitespace(char ch) {
|
private static String convertToString(HashMap<StringContainer,String> strings, StringContainer contatiner) {
|
||||||
return (ch == ' ') || (ch <= 0x000D);
|
String s = strings.get(contatiner);
|
||||||
}
|
|
||||||
|
|
||||||
private static final TreeMap<ComparableString,String> ourStrings = new TreeMap<ComparableString,String>();
|
|
||||||
private static final ComparableString ourPattern = new ComparableString();
|
|
||||||
|
|
||||||
private static String convertToString(StringBuilder builder) {
|
|
||||||
final TreeMap<ComparableString,String> strings = ourStrings;
|
|
||||||
final ComparableString pattern = ourPattern;
|
|
||||||
pattern.setSequence(builder);
|
|
||||||
String s = strings.get(pattern);
|
|
||||||
if (s == null) {
|
if (s == null) {
|
||||||
s = builder.toString().intern();
|
s = contatiner.toString();
|
||||||
strings.put(new ComparableString(s), s);
|
strings.put(new StringContainer(contatiner), s);
|
||||||
}
|
}
|
||||||
builder.delete(0, builder.length());
|
contatiner.clear();
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void appendToName(StringBuilder name, char[] buffer, int startOffset, int endOffset) {
|
|
||||||
name.append(buffer, startOffset, endOffset - startOffset);
|
|
||||||
}
|
|
||||||
|
|
||||||
private final InputStreamReader myStreamReader;
|
private final InputStreamReader myStreamReader;
|
||||||
private final ZLXMLReader myXMLReader;
|
private final ZLXMLReader myXMLReader;
|
||||||
|
|
||||||
private final char[] myBuffer = new char[4096];
|
private final char[] myBuffer = new char[8192];
|
||||||
|
|
||||||
public ZLOwnXMLParser(ZLXMLReader xmlReader, InputStream stream) throws IOException {
|
public ZLOwnXMLParser(ZLXMLReader xmlReader, InputStream stream) throws IOException {
|
||||||
myXMLReader = xmlReader;
|
myXMLReader = xmlReader;
|
||||||
|
@ -118,8 +146,55 @@ final class ZLOwnXMLParser {
|
||||||
myStreamReader = new InputStreamReader(stream, encoding);
|
myStreamReader = new InputStreamReader(stream, encoding);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final class StringMap implements ZLXMLReader.StringMap {
|
||||||
|
private int mySize;
|
||||||
|
private String[] myKeys = new String[10];
|
||||||
|
private String[] myValues = new String[10];
|
||||||
|
|
||||||
|
public int getSize() {
|
||||||
|
return mySize;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getKey(int index) {
|
||||||
|
return myKeys[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValue(String key) {
|
||||||
|
final int size = mySize;
|
||||||
|
if (size > 0) {
|
||||||
|
key = key.intern();
|
||||||
|
final String[] keys = myKeys;
|
||||||
|
for (int i = 0; i < size; ++i) {
|
||||||
|
if (key == keys[i]) {
|
||||||
|
return myValues[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clear() {
|
||||||
|
mySize = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void put(String key, String value) {
|
||||||
|
final int size = mySize++;
|
||||||
|
String[] keys = myKeys;
|
||||||
|
if (keys.length == size) {
|
||||||
|
keys = new String[2 * size];
|
||||||
|
System.arraycopy(myKeys, 0, keys, 0, size);
|
||||||
|
myKeys = keys;
|
||||||
|
final String[] values = new String[2 * size];
|
||||||
|
System.arraycopy(myValues, 0, values, 0, size);
|
||||||
|
myValues = values;
|
||||||
|
}
|
||||||
|
keys[size] = key;
|
||||||
|
myValues[size] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void doIt() throws IOException {
|
public void doIt() throws IOException {
|
||||||
final TreeMap<String,char[]> entityMap = new TreeMap<String,char[]>();
|
final HashMap<String,char[]> entityMap = new HashMap<String,char[]>();
|
||||||
entityMap.put("amp", new char[] { '&' });
|
entityMap.put("amp", new char[] { '&' });
|
||||||
entityMap.put("apos", new char[] { '\'' });
|
entityMap.put("apos", new char[] { '\'' });
|
||||||
entityMap.put("gt", new char[] { '>' });
|
entityMap.put("gt", new char[] { '>' });
|
||||||
|
@ -129,18 +204,18 @@ final class ZLOwnXMLParser {
|
||||||
final InputStreamReader streamReader = myStreamReader;
|
final InputStreamReader streamReader = myStreamReader;
|
||||||
final ZLXMLReader xmlReader = myXMLReader;
|
final ZLXMLReader xmlReader = myXMLReader;
|
||||||
final char[] buffer = myBuffer;
|
final char[] buffer = myBuffer;
|
||||||
final StringBuilder tagName = new StringBuilder();
|
final StringContainer tagName = new StringContainer();
|
||||||
final StringBuilder attributeName = new StringBuilder();
|
final StringContainer attributeName = new StringContainer();
|
||||||
final StringBuilder attributeValue = new StringBuilder();
|
final StringContainer attributeValue = new StringContainer();
|
||||||
final StringBuilder entityName = new StringBuilder();
|
final StringContainer entityName = new StringContainer();
|
||||||
final TreeMap<String,String> attributes = new TreeMap<String,String>();
|
final HashMap<StringContainer,String> strings = new HashMap<StringContainer,String>();
|
||||||
|
final StringMap attributes = new StringMap();
|
||||||
|
|
||||||
int state = START_DOCUMENT;
|
int state = START_DOCUMENT;
|
||||||
int savedState = START_DOCUMENT;
|
int savedState = START_DOCUMENT;
|
||||||
while (true) {
|
while (true) {
|
||||||
int count = streamReader.read(buffer);
|
int count = streamReader.read(buffer);
|
||||||
if (count <= 0) {
|
if (count <= 0) {
|
||||||
ourStrings.clear();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int startPosition = 0;
|
int startPosition = 0;
|
||||||
|
@ -182,66 +257,100 @@ final class ZLOwnXMLParser {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case START_TAG:
|
case START_TAG:
|
||||||
|
startTagLabel:
|
||||||
while (true) {
|
while (true) {
|
||||||
if (isWhitespace(c)) {
|
switch (c) {
|
||||||
|
case 0x0008:
|
||||||
|
case 0x0009:
|
||||||
|
case 0x000A:
|
||||||
|
case 0x000B:
|
||||||
|
case 0x000C:
|
||||||
|
case 0x000D:
|
||||||
|
case ' ':
|
||||||
state = WS_AFTER_START_TAG_NAME;
|
state = WS_AFTER_START_TAG_NAME;
|
||||||
appendToName(tagName, buffer, startPosition, i);
|
tagName.append(buffer, startPosition, i - startPosition);
|
||||||
break;
|
break startTagLabel;
|
||||||
} else if (c == '>') {
|
case '>':
|
||||||
appendToName(tagName, buffer, startPosition, i);
|
|
||||||
processStartTag(xmlReader, tagName, attributes);
|
|
||||||
state = TEXT;
|
state = TEXT;
|
||||||
|
tagName.append(buffer, startPosition, i - startPosition);
|
||||||
|
processStartTag(xmlReader, convertToString(strings, tagName), attributes);
|
||||||
startPosition = i + 1;
|
startPosition = i + 1;
|
||||||
break;
|
break startTagLabel;
|
||||||
} else if (c == '/') {
|
case '/':
|
||||||
state = SLASH;
|
state = SLASH;
|
||||||
appendToName(tagName, buffer, startPosition, i);
|
tagName.append(buffer, startPosition, i - startPosition);
|
||||||
processFullTag(xmlReader, tagName, attributes);
|
processFullTag(xmlReader, convertToString(strings, tagName), attributes);
|
||||||
break;
|
break startTagLabel;
|
||||||
} else if (c == '&') {
|
case '&':
|
||||||
savedState = START_TAG;
|
savedState = START_TAG;
|
||||||
state = ENTITY_REF;
|
state = ENTITY_REF;
|
||||||
startPosition = i + 1;
|
startPosition = i + 1;
|
||||||
break;
|
break startTagLabel;
|
||||||
} else if (++i == count) {
|
default:
|
||||||
appendToName(tagName, buffer, startPosition, i);
|
if (++i == count) {
|
||||||
|
tagName.append(buffer, startPosition, i - startPosition);
|
||||||
|
break startTagLabel;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
c = buffer[i];
|
c = buffer[i];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case WS_AFTER_START_TAG_NAME:
|
case WS_AFTER_START_TAG_NAME:
|
||||||
if (c == '>') {
|
switch (c) {
|
||||||
processStartTag(xmlReader, tagName, attributes);
|
case '>':
|
||||||
|
processStartTag(xmlReader, convertToString(strings, tagName), attributes);
|
||||||
state = TEXT;
|
state = TEXT;
|
||||||
startPosition = i + 1;
|
startPosition = i + 1;
|
||||||
} else if (c == '/') {
|
break;
|
||||||
|
case '/':
|
||||||
state = SLASH;
|
state = SLASH;
|
||||||
processFullTag(xmlReader, tagName, attributes);
|
processFullTag(xmlReader, convertToString(strings, tagName), attributes);
|
||||||
} else if (!isWhitespace(c)) {
|
break;
|
||||||
|
case 0x0008:
|
||||||
|
case 0x0009:
|
||||||
|
case 0x000A:
|
||||||
|
case 0x000B:
|
||||||
|
case 0x000C:
|
||||||
|
case 0x000D:
|
||||||
|
case ' ':
|
||||||
|
break;
|
||||||
|
default:
|
||||||
state = ATTRIBUTE_NAME;
|
state = ATTRIBUTE_NAME;
|
||||||
startPosition = i;
|
startPosition = i;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ATTRIBUTE_NAME:
|
case ATTRIBUTE_NAME:
|
||||||
|
attributeNameLabel:
|
||||||
while (true) {
|
while (true) {
|
||||||
if (c == '=') {
|
switch (c) {
|
||||||
|
case '=':
|
||||||
state = WAIT_ATTRIBUTE_VALUE;
|
state = WAIT_ATTRIBUTE_VALUE;
|
||||||
break;
|
break attributeNameLabel;
|
||||||
} else if (c == '&') {
|
case '&':
|
||||||
savedState = ATTRIBUTE_NAME;
|
savedState = ATTRIBUTE_NAME;
|
||||||
state = ENTITY_REF;
|
state = ENTITY_REF;
|
||||||
startPosition = i + 1;
|
startPosition = i + 1;
|
||||||
break;
|
break attributeNameLabel;
|
||||||
} else if (isWhitespace(c)) {
|
case 0x0008:
|
||||||
|
case 0x0009:
|
||||||
|
case 0x000A:
|
||||||
|
case 0x000B:
|
||||||
|
case 0x000C:
|
||||||
|
case 0x000D:
|
||||||
|
case ' ':
|
||||||
state = WAIT_EQUALS;
|
state = WAIT_EQUALS;
|
||||||
break;
|
break attributeNameLabel;
|
||||||
} else if (++i == count) {
|
default:
|
||||||
|
if (++i == count) {
|
||||||
|
break attributeNameLabel;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
c = buffer[i];
|
c = buffer[i];
|
||||||
}
|
}
|
||||||
appendToName(attributeName, buffer, startPosition, i);
|
attributeName.append(buffer, startPosition, i - startPosition);
|
||||||
break;
|
break;
|
||||||
case WAIT_EQUALS:
|
case WAIT_EQUALS:
|
||||||
if (c == '=') {
|
if (c == '=') {
|
||||||
|
@ -258,10 +367,10 @@ final class ZLOwnXMLParser {
|
||||||
while ((c != '"') && (c != '&') && (++i < count)) {
|
while ((c != '"') && (c != '&') && (++i < count)) {
|
||||||
c = buffer[i];
|
c = buffer[i];
|
||||||
}
|
}
|
||||||
appendToName(attributeValue, buffer, startPosition, i);
|
attributeValue.append(buffer, startPosition, i - startPosition);
|
||||||
if (c == '"') {
|
if (c == '"') {
|
||||||
state = WS_AFTER_START_TAG_NAME;
|
state = WS_AFTER_START_TAG_NAME;
|
||||||
attributes.put(convertToString(attributeName), convertToString(attributeValue));
|
attributes.put(convertToString(strings, attributeName), convertToString(strings, attributeValue));
|
||||||
} else if (c == '&') {
|
} else if (c == '&') {
|
||||||
savedState = ATTRIBUTE_VALUE;
|
savedState = ATTRIBUTE_VALUE;
|
||||||
state = ENTITY_REF;
|
state = ENTITY_REF;
|
||||||
|
@ -272,11 +381,11 @@ final class ZLOwnXMLParser {
|
||||||
while ((c != ';') && (++i < count)) {
|
while ((c != ';') && (++i < count)) {
|
||||||
c = buffer[i];
|
c = buffer[i];
|
||||||
}
|
}
|
||||||
appendToName(entityName, buffer, startPosition, i);
|
entityName.append(buffer, startPosition, i - startPosition);
|
||||||
if (c == ';') {
|
if (c == ';') {
|
||||||
state = savedState;
|
state = savedState;
|
||||||
startPosition = i + 1;
|
startPosition = i + 1;
|
||||||
final String name = convertToString(entityName);
|
final String name = convertToString(strings, entityName);
|
||||||
char[] value = entityMap.get(name);
|
char[] value = entityMap.get(name);
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
if ((name.length() > 0) && (name.charAt(0) == '#')) {
|
if ((name.length() > 0) && (name.charAt(0) == '#')) {
|
||||||
|
@ -296,14 +405,14 @@ final class ZLOwnXMLParser {
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case ATTRIBUTE_VALUE:
|
case ATTRIBUTE_VALUE:
|
||||||
appendToName(attributeValue, value, 0, value.length);
|
attributeValue.append(value, 0, value.length);
|
||||||
break;
|
break;
|
||||||
case ATTRIBUTE_NAME:
|
case ATTRIBUTE_NAME:
|
||||||
appendToName(attributeName, value, 0, value.length);
|
attributeName.append(value, 0, value.length);
|
||||||
break;
|
break;
|
||||||
case START_TAG:
|
case START_TAG:
|
||||||
case END_TAG:
|
case END_TAG:
|
||||||
appendToName(tagName, value, 0, value.length);
|
tagName.append(value, 0, value.length);
|
||||||
break;
|
break;
|
||||||
case TEXT:
|
case TEXT:
|
||||||
xmlReader.characterDataHandler(value, 0, value.length);
|
xmlReader.characterDataHandler(value, 0, value.length);
|
||||||
|
@ -319,24 +428,35 @@ final class ZLOwnXMLParser {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case END_TAG:
|
case END_TAG:
|
||||||
|
endTagLabel:
|
||||||
while (true) {
|
while (true) {
|
||||||
if (c == '>') {
|
switch (c) {
|
||||||
appendToName(tagName, buffer, startPosition, i);
|
case '>':
|
||||||
processEndTag(xmlReader, tagName);
|
tagName.append(buffer, startPosition, i - startPosition);
|
||||||
|
processEndTag(xmlReader, convertToString(strings, tagName));
|
||||||
state = TEXT;
|
state = TEXT;
|
||||||
startPosition = i + 1;
|
startPosition = i + 1;
|
||||||
break;
|
break endTagLabel;
|
||||||
} else if (c == '&') {
|
case '&':
|
||||||
savedState = END_TAG;
|
savedState = END_TAG;
|
||||||
state = ENTITY_REF;
|
state = ENTITY_REF;
|
||||||
startPosition = i + 1;
|
startPosition = i + 1;
|
||||||
break;
|
break endTagLabel;
|
||||||
} else if (isWhitespace(c)) {
|
case 0x0008:
|
||||||
appendToName(tagName, buffer, startPosition, i);
|
case 0x0009:
|
||||||
|
case 0x000A:
|
||||||
|
case 0x000B:
|
||||||
|
case 0x000C:
|
||||||
|
case 0x000D:
|
||||||
|
case ' ':
|
||||||
|
tagName.append(buffer, startPosition, i - startPosition);
|
||||||
state = WS_AFTER_END_TAG_NAME;
|
state = WS_AFTER_END_TAG_NAME;
|
||||||
break;
|
break endTagLabel;
|
||||||
} else if (++i == count) {
|
default:
|
||||||
appendToName(tagName, buffer, startPosition, i);
|
if (++i == count) {
|
||||||
|
tagName.append(buffer, startPosition, i - startPosition);
|
||||||
|
break endTagLabel;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
c = buffer[i];
|
c = buffer[i];
|
||||||
|
@ -345,7 +465,7 @@ final class ZLOwnXMLParser {
|
||||||
case WS_AFTER_END_TAG_NAME:
|
case WS_AFTER_END_TAG_NAME:
|
||||||
if (c == '>') {
|
if (c == '>') {
|
||||||
state = TEXT;
|
state = TEXT;
|
||||||
processEndTag(xmlReader, tagName);
|
processEndTag(xmlReader, convertToString(strings, tagName));
|
||||||
startPosition = i + 1;
|
startPosition = i + 1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -373,19 +493,18 @@ final class ZLOwnXMLParser {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void processFullTag(ZLXMLReader xmlReader, StringBuilder tagName, TreeMap<String,String> attributes) {
|
private static void processFullTag(ZLXMLReader xmlReader, String tagName, StringMap attributes) {
|
||||||
final String s = convertToString(tagName);
|
xmlReader.startElementHandler(tagName, attributes);
|
||||||
xmlReader.startElementHandler(s, attributes);
|
xmlReader.endElementHandler(tagName);
|
||||||
xmlReader.endElementHandler(s);
|
|
||||||
attributes.clear();
|
attributes.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void processStartTag(ZLXMLReader xmlReader, StringBuilder tagName, TreeMap<String,String> attributes) {
|
private static void processStartTag(ZLXMLReader xmlReader, String tagName, StringMap attributes) {
|
||||||
xmlReader.startElementHandler(convertToString(tagName), attributes);
|
xmlReader.startElementHandler(tagName, attributes);
|
||||||
attributes.clear();
|
attributes.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void processEndTag(ZLXMLReader xmlReader, StringBuilder tagName) {
|
private static void processEndTag(ZLXMLReader xmlReader, String tagName) {
|
||||||
xmlReader.endElementHandler(convertToString(tagName));
|
xmlReader.endElementHandler(tagName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package org.zlibrary.core.xml.sax;
|
package org.zlibrary.core.xml.sax;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.HashMap;
|
||||||
import java.util.TreeMap;
|
|
||||||
|
|
||||||
import org.xml.sax.Attributes;
|
import org.xml.sax.Attributes;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
@ -10,39 +9,58 @@ import org.zlibrary.core.xml.ZLXMLReader;
|
||||||
|
|
||||||
class SAXHandler extends DefaultHandler {
|
class SAXHandler extends DefaultHandler {
|
||||||
private ZLXMLReader myXMLReader;
|
private ZLXMLReader myXMLReader;
|
||||||
private final TreeMap<String, String> myAttributes = new TreeMap<String, String>();
|
private static final class StringMap extends HashMap<String,String> implements ZLXMLReader.StringMap {
|
||||||
|
public int getSize() {
|
||||||
|
return size();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getKey(int index) {
|
||||||
|
int i = 0;
|
||||||
|
for (String s : keySet()) {
|
||||||
|
if (i++ == index) {
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValue(String key) {
|
||||||
|
return get(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private final StringMap myAttributes = new StringMap();
|
||||||
|
|
||||||
SAXHandler(ZLXMLReader reader) {
|
SAXHandler(ZLXMLReader reader) {
|
||||||
myXMLReader = reader;
|
myXMLReader = reader;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void endElement(String uri, String localName, String qName) throws SAXException {
|
public void endElement(String uri, String localName, String qName) throws SAXException {
|
||||||
myXMLReader.endElementHandler(qName);
|
myXMLReader.endElementHandler(qName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
|
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
|
||||||
myAttributes.clear();
|
StringMap attributesMap = myAttributes;
|
||||||
|
attributesMap.clear();
|
||||||
int length = attributes.getLength();
|
int length = attributes.getLength();
|
||||||
for (int i = 0; i < length; i++) {
|
for (int i = 0; i < length; i++) {
|
||||||
myAttributes.put(attributes.getQName(i), attributes.getValue(i));
|
attributesMap.put(attributes.getQName(i), attributes.getValue(i));
|
||||||
}
|
}
|
||||||
myXMLReader.startElementHandler(qName, myAttributes);
|
myXMLReader.startElementHandler(qName, attributesMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void characters(char[] ch, int start, int length) throws SAXException {
|
public void characters(char[] ch, int start, int length) throws SAXException {
|
||||||
myXMLReader.characterDataHandler(ch, start, length);
|
myXMLReader.characterDataHandler(ch, start, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void endDocument() throws SAXException {
|
public void endDocument() throws SAXException {
|
||||||
myXMLReader.endDocumentHandler();
|
myXMLReader.endDocumentHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void startDocument() throws SAXException {
|
public void startDocument() throws SAXException {
|
||||||
myXMLReader.startDocumentHandler();
|
myXMLReader.startDocumentHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getValue(String key) {
|
||||||
|
return myAttributes.get(key);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
package org.zlibrary.core.options.config;
|
package org.zlibrary.core.xmlconfig;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
import org.zlibrary.core.config.ZLConfig;
|
||||||
|
|
||||||
final class ZLConfigImpl implements ZLConfig {
|
final class ZLConfigImpl implements ZLConfig {
|
||||||
|
|
||||||
// public abstract boolean isAutoSavingSupported() const = 0;
|
// public abstract boolean isAutoSavingSupported() const = 0;
|
|
@ -1,12 +1,11 @@
|
||||||
package org.zlibrary.core.options.config;
|
package org.zlibrary.core.xmlconfig;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.zlibrary.core.xml.ZLXMLReader;
|
import org.zlibrary.core.xml.ZLXMLReader;
|
||||||
|
|
||||||
/*package*/ final class ZLConfigReader implements ZLReader {
|
final class ZLConfigReader implements ZLReader {
|
||||||
|
|
||||||
private class ConfigReader extends ZLXMLReader {
|
private class ConfigReader extends ZLXMLReader {
|
||||||
private int myDepth = 0;
|
private int myDepth = 0;
|
||||||
|
|
||||||
|
@ -16,7 +15,7 @@ import org.zlibrary.core.xml.ZLXMLReader;
|
||||||
myDepth = 0;
|
myDepth = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startElementHandler(String tag, Map<String, String> attributes) {
|
public void startElementHandler(String tag, StringMap attributes) {
|
||||||
switch (myDepth) {
|
switch (myDepth) {
|
||||||
case 0:
|
case 0:
|
||||||
if (!tag.equals("config")) {
|
if (!tag.equals("config")) {
|
||||||
|
@ -25,14 +24,14 @@ import org.zlibrary.core.xml.ZLXMLReader;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
if (tag.equals("group")) {
|
if (tag.equals("group")) {
|
||||||
myCurrentGroup = attributes.get("name");
|
myCurrentGroup = attributes.getValue("name");
|
||||||
} else {
|
} else {
|
||||||
printError(tag);
|
printError(tag);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
if (tag.equals("option")) {
|
if (tag.equals("option")) {
|
||||||
myConfig.setValueDirectly(myCurrentGroup, attributes.get("name"), attributes.get("value"), myCategory);
|
myConfig.setValueDirectly(myCurrentGroup, attributes.getValue("name"), attributes.getValue("value"), myCategory);
|
||||||
} else {
|
} else {
|
||||||
printError(tag);
|
printError(tag);
|
||||||
}
|
}
|
||||||
|
@ -64,7 +63,7 @@ import org.zlibrary.core.xml.ZLXMLReader;
|
||||||
myFile = "delta.xml";
|
myFile = "delta.xml";
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startElementHandler(String tag, Map<String, String> attributes) {
|
public void startElementHandler(String tag, StringMap attributes) {
|
||||||
switch (myDepth) {
|
switch (myDepth) {
|
||||||
case 0:
|
case 0:
|
||||||
if (!tag.equals("config")) {
|
if (!tag.equals("config")) {
|
||||||
|
@ -73,7 +72,7 @@ import org.zlibrary.core.xml.ZLXMLReader;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
if (tag.equals("group")) {
|
if (tag.equals("group")) {
|
||||||
myCurrentGroup = attributes.get("name");
|
myCurrentGroup = attributes.getValue("name");
|
||||||
myCurrentGroupIsEmpty = true;
|
myCurrentGroupIsEmpty = true;
|
||||||
} else {
|
} else {
|
||||||
printError(tag);
|
printError(tag);
|
||||||
|
@ -82,15 +81,13 @@ import org.zlibrary.core.xml.ZLXMLReader;
|
||||||
case 2:
|
case 2:
|
||||||
if (tag.equals("option")) {
|
if (tag.equals("option")) {
|
||||||
myCurrentGroupIsEmpty = false;
|
myCurrentGroupIsEmpty = false;
|
||||||
if ((attributes.get("value") != null)
|
String value = attributes.getValue("value");
|
||||||
&& (attributes.get("category") != null)) {
|
String category = attributes.getValue("category");
|
||||||
myConfig.setValue(myCurrentGroup,
|
String name = attributes.getValue("name");
|
||||||
attributes.get("name"),
|
if ((value != null) && (category != null)) {
|
||||||
attributes.get("value"),
|
myConfig.setValue(myCurrentGroup, name, value, category);
|
||||||
attributes.get("category"));
|
|
||||||
} else {
|
} else {
|
||||||
myConfig.unsetValue(myCurrentGroup,
|
myConfig.unsetValue(myCurrentGroup, name);
|
||||||
attributes.get("name"));
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
printError(tag);
|
printError(tag);
|
||||||
|
@ -127,8 +124,8 @@ import org.zlibrary.core.xml.ZLXMLReader;
|
||||||
|
|
||||||
private String myFile = "";
|
private String myFile = "";
|
||||||
|
|
||||||
protected ZLConfigReader(String path) {
|
protected ZLConfigReader(ZLConfigImpl config, String path) {
|
||||||
myConfig = (ZLConfigImpl)ZLConfigInstance.getInstance();
|
myConfig = config;
|
||||||
myDestinationDirectory = new File(path);
|
myDestinationDirectory = new File(path);
|
||||||
myDeltaFilePath = myDestinationDirectory + "/delta.xml";
|
myDeltaFilePath = myDestinationDirectory + "/delta.xml";
|
||||||
if (myDestinationDirectory.exists()) {
|
if (myDestinationDirectory.exists()) {
|
|
@ -1,13 +1,14 @@
|
||||||
package org.zlibrary.core.options.config;
|
package org.zlibrary.core.xmlconfig;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
final class ZLConfigWriter implements ZLWriter {
|
final class ZLConfigWriter implements ZLWriter {
|
||||||
private final ZLConfigImpl myConfig = (ZLConfigImpl)ZLConfigInstance.getInstance();
|
private final ZLConfigImpl myConfig;
|
||||||
private final File myDestinationDirectory;
|
private final File myDestinationDirectory;
|
||||||
|
|
||||||
protected ZLConfigWriter(String path) {
|
protected ZLConfigWriter(ZLConfigImpl config, String path) {
|
||||||
|
myConfig = config;
|
||||||
File file = new File(path);
|
File file = new File(path);
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
file.mkdir();
|
file.mkdir();
|
|
@ -1,4 +1,4 @@
|
||||||
package org.zlibrary.core.options.config;
|
package org.zlibrary.core.xmlconfig;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package org.zlibrary.core.options.config;
|
package org.zlibrary.core.xmlconfig;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package org.zlibrary.core.options.config;
|
package org.zlibrary.core.xmlconfig;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.TreeMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
final class ZLGroup {
|
final class ZLGroup {
|
||||||
private final TreeMap<String,ZLOptionInfo> myData = new TreeMap<String,ZLOptionInfo>();
|
private final HashMap<String,ZLOptionInfo> myData = new HashMap<String,ZLOptionInfo>();
|
||||||
|
|
||||||
Set<String> optionNames() {
|
Set<String> optionNames() {
|
||||||
return myData.keySet();
|
return myData.keySet();
|
|
@ -1,4 +1,4 @@
|
||||||
package org.zlibrary.core.options.config;
|
package org.zlibrary.core.xmlconfig;
|
||||||
|
|
||||||
final class ZLOptionID {
|
final class ZLOptionID {
|
||||||
private String myGroup = "";
|
private String myGroup = "";
|
|
@ -1,4 +1,4 @@
|
||||||
package org.zlibrary.core.options.config;
|
package org.zlibrary.core.xmlconfig;
|
||||||
|
|
||||||
final class ZLOptionInfo {
|
final class ZLOptionInfo {
|
||||||
private String myValue;
|
private String myValue;
|
|
@ -1,4 +1,4 @@
|
||||||
package org.zlibrary.core.options.config;
|
package org.zlibrary.core.xmlconfig;
|
||||||
|
|
||||||
public interface ZLReader {
|
public interface ZLReader {
|
||||||
public void read();
|
public void read();
|
|
@ -1,7 +1,7 @@
|
||||||
package org.zlibrary.core.options.config;
|
package org.zlibrary.core.xmlconfig;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.TreeMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* класс Конфиг. это своеобразная структура опций. основное поле myData содержит
|
* класс Конфиг. это своеобразная структура опций. основное поле myData содержит
|
||||||
|
@ -11,7 +11,7 @@ import java.util.TreeMap;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
final class ZLSimpleConfig {
|
final class ZLSimpleConfig {
|
||||||
private final TreeMap<String,ZLGroup> myData = new TreeMap<String,ZLGroup>();
|
private final HashMap<String,ZLGroup> myData = new HashMap<String,ZLGroup>();
|
||||||
|
|
||||||
void clear() {
|
void clear() {
|
||||||
myData.clear();
|
myData.clear();
|
|
@ -1,4 +1,4 @@
|
||||||
package org.zlibrary.core.options.config;
|
package org.zlibrary.core.xmlconfig;
|
||||||
|
|
||||||
public interface ZLWriter {
|
public interface ZLWriter {
|
||||||
public void write();
|
public void write();
|
37
src/org/zlibrary/core/xmlconfig/ZLXMLConfigManager.java
Normal file
37
src/org/zlibrary/core/xmlconfig/ZLXMLConfigManager.java
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
package org.zlibrary.core.xmlconfig;
|
||||||
|
|
||||||
|
import org.zlibrary.core.config.*;
|
||||||
|
|
||||||
|
public class ZLXMLConfigManager extends ZLConfigManager {
|
||||||
|
private String myDirectoryPath;
|
||||||
|
|
||||||
|
// TODO: remove this constructor
|
||||||
|
public ZLXMLConfigManager(String inputPath, String outputPath) {
|
||||||
|
myDirectoryPath = outputPath;
|
||||||
|
ZLConfigImpl config = new ZLConfigImpl();
|
||||||
|
if (inputPath != null) {
|
||||||
|
new ZLConfigReader(config, inputPath).read();
|
||||||
|
}
|
||||||
|
setConfig(config);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ZLXMLConfigManager(String directoryPath) {
|
||||||
|
this(directoryPath, directoryPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void shutdown() {
|
||||||
|
saveAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void saveAll() {
|
||||||
|
if (myDirectoryPath != null) {
|
||||||
|
new ZLConfigWriter((ZLConfigImpl)getConfig(), myDirectoryPath).write();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void saveDelta() {
|
||||||
|
if (myDirectoryPath != null) {
|
||||||
|
new ZLConfigWriter((ZLConfigImpl)getConfig(), myDirectoryPath).writeDelta();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,9 +1,7 @@
|
||||||
package org.zlibrary.text.model;
|
package org.zlibrary.text.model;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.zlibrary.core.util.ZLTextBuffer;
|
import org.zlibrary.core.util.ZLTextBuffer;
|
||||||
import org.zlibrary.core.image.ZLImage;
|
import org.zlibrary.core.image.ZLImageMap;
|
||||||
|
|
||||||
import org.zlibrary.text.model.impl.ZLTextForcedControlEntry;
|
import org.zlibrary.text.model.impl.ZLTextForcedControlEntry;
|
||||||
|
|
||||||
|
@ -16,10 +14,8 @@ public interface ZLTextModel {
|
||||||
void addText(char[] text, int offset, int length);
|
void addText(char[] text, int offset, int length);
|
||||||
void addText(ZLTextBuffer buffer);
|
void addText(ZLTextBuffer buffer);
|
||||||
|
|
||||||
void addControl(ZLTextForcedControlEntry entry);
|
//void addControl(ZLTextForcedControlEntry entry);
|
||||||
void addHyperlinkControl(byte textKind, String label);
|
void addHyperlinkControl(byte textKind, String label);
|
||||||
void addImage(String id, Map<String,ZLImage> imageMap, short vOffset);
|
void addImage(String id, ZLImageMap imageMap, short vOffset);
|
||||||
void addFixedHSpace(short length);
|
//void addFixedHSpace(short length);
|
||||||
|
|
||||||
String dump();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package org.zlibrary.text.model;
|
package org.zlibrary.text.model;
|
||||||
|
|
||||||
|
import org.zlibrary.text.model.impl.ZLImageEntry;
|
||||||
|
|
||||||
public interface ZLTextParagraph {
|
public interface ZLTextParagraph {
|
||||||
interface Entry {
|
interface Entry {
|
||||||
byte TEXT = 1;
|
byte TEXT = 1;
|
||||||
|
@ -19,8 +21,10 @@ public interface ZLTextParagraph {
|
||||||
byte getControlKind();
|
byte getControlKind();
|
||||||
boolean getControlIsStart();
|
boolean getControlIsStart();
|
||||||
|
|
||||||
|
ZLImageEntry getImageEntry();
|
||||||
|
|
||||||
boolean hasNext();
|
boolean hasNext();
|
||||||
Entry next();
|
void next();
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntryIterator iterator();
|
public EntryIterator iterator();
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package org.zlibrary.text.model;
|
package org.zlibrary.text.model;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public interface ZLTextTreeParagraph extends ZLTextParagraph {
|
public interface ZLTextTreeParagraph extends ZLTextParagraph {
|
||||||
boolean isOpen();
|
boolean isOpen();
|
||||||
void open(boolean o);
|
void open(boolean o);
|
||||||
|
@ -12,7 +10,6 @@ public interface ZLTextTreeParagraph extends ZLTextParagraph {
|
||||||
ZLTextTreeParagraph getParent();
|
ZLTextTreeParagraph getParent();
|
||||||
|
|
||||||
boolean hasChildren();
|
boolean hasChildren();
|
||||||
List<ZLTextTreeParagraph> children();
|
|
||||||
boolean isLastChild();
|
boolean isLastChild();
|
||||||
int getFullSize();
|
int getFullSize();
|
||||||
|
|
||||||
|
|
|
@ -1,22 +1,21 @@
|
||||||
package org.zlibrary.text.model.impl;
|
package org.zlibrary.text.model.impl;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.zlibrary.core.image.ZLImage;
|
import org.zlibrary.core.image.ZLImage;
|
||||||
|
import org.zlibrary.core.image.ZLImageMap;
|
||||||
import org.zlibrary.text.model.ZLTextParagraph;
|
import org.zlibrary.text.model.ZLTextParagraph;
|
||||||
|
|
||||||
public class ZLImageEntry implements ZLTextParagraph.Entry {
|
public final class ZLImageEntry {
|
||||||
|
private final ZLImageMap myImageMap;
|
||||||
private final String myId;
|
private final String myId;
|
||||||
private final Map<String,ZLImage> myImageMap;
|
|
||||||
public final short VOffset;
|
public final short VOffset;
|
||||||
|
|
||||||
ZLImageEntry(String id, Map<String,ZLImage> imageMap, short vOffset) {
|
ZLImageEntry(ZLImageMap imageMap, String id, short vOffset) {
|
||||||
myId = id;
|
|
||||||
myImageMap = imageMap;
|
myImageMap = imageMap;
|
||||||
|
myId = id;
|
||||||
VOffset = vOffset;
|
VOffset = vOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ZLImage getImage() {
|
public ZLImage getImage() {
|
||||||
return myImageMap.get(myId);
|
return myImageMap.getImage(myId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package org.zlibrary.text.model.impl;
|
package org.zlibrary.text.model.impl;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import org.zlibrary.text.model.ZLTextModel;
|
import org.zlibrary.text.model.ZLTextModel;
|
||||||
import org.zlibrary.text.model.ZLTextParagraph;
|
import org.zlibrary.text.model.ZLTextParagraph;
|
||||||
import org.zlibrary.text.model.ZLTextPlainModel;
|
import org.zlibrary.text.model.ZLTextPlainModel;
|
||||||
|
@ -11,8 +9,8 @@ import org.zlibrary.text.model.ZLTextTreeParagraph;
|
||||||
|
|
||||||
public class ZLModelFactory {
|
public class ZLModelFactory {
|
||||||
//models
|
//models
|
||||||
public ZLTextPlainModel createPlainModel() {
|
public ZLTextPlainModel createPlainModel(int dataBlockSize) {
|
||||||
return new ZLTextPlainModelImpl();
|
return new ZLTextPlainModelImpl(dataBlockSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ZLTextTreeModel createZLTextTreeModel() {
|
public ZLTextTreeModel createZLTextTreeModel() {
|
||||||
|
@ -21,19 +19,19 @@ public class ZLModelFactory {
|
||||||
|
|
||||||
//paragraphs
|
//paragraphs
|
||||||
public ZLTextParagraph createParagraph() {
|
public ZLTextParagraph createParagraph() {
|
||||||
return new ZLTextParagraphImpl(new ZLTextPlainModelImpl());
|
return new ZLTextParagraphImpl(new ZLTextPlainModelImpl(4096));
|
||||||
}
|
}
|
||||||
|
|
||||||
public ZLTextParagraph createSpecialParagragraph(byte kind) {
|
public ZLTextParagraph createSpecialParagragraph(byte kind) {
|
||||||
return new ZLTextSpecialParagraphImpl(kind, new ZLTextPlainModelImpl());
|
return new ZLTextSpecialParagraphImpl(kind, new ZLTextPlainModelImpl(4096));
|
||||||
}
|
}
|
||||||
|
|
||||||
public ZLTextTreeParagraph createTreeParagraph(ZLTextTreeParagraph parent) {
|
public ZLTextTreeParagraph createTreeParagraph(ZLTextTreeParagraph parent) {
|
||||||
return new ZLTextTreeParagraphImpl(parent, new ZLTextPlainModelImpl());
|
return new ZLTextTreeParagraphImpl(parent, new ZLTextPlainModelImpl(4096));
|
||||||
}
|
}
|
||||||
|
|
||||||
public ZLTextTreeParagraph createTreeParagraph() {
|
public ZLTextTreeParagraph createTreeParagraph() {
|
||||||
return new ZLTextTreeParagraphImpl(null, new ZLTextPlainModelImpl());
|
return new ZLTextTreeParagraphImpl(null, new ZLTextPlainModelImpl(4096));
|
||||||
}
|
}
|
||||||
|
|
||||||
//entries
|
//entries
|
||||||
|
|
|
@ -2,20 +2,20 @@ package org.zlibrary.text.model.impl;
|
||||||
|
|
||||||
import org.zlibrary.core.util.ZLIntArray;
|
import org.zlibrary.core.util.ZLIntArray;
|
||||||
import org.zlibrary.core.util.ZLTextBuffer;
|
import org.zlibrary.core.util.ZLTextBuffer;
|
||||||
import org.zlibrary.core.image.ZLImage;
|
import org.zlibrary.core.image.ZLImageMap;
|
||||||
import org.zlibrary.text.model.ZLTextModel;
|
import org.zlibrary.text.model.ZLTextModel;
|
||||||
import org.zlibrary.text.model.ZLTextParagraph;
|
import org.zlibrary.text.model.ZLTextParagraph;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
abstract class ZLTextModelImpl implements ZLTextModel {
|
abstract class ZLTextModelImpl implements ZLTextModel {
|
||||||
private final ArrayList<ZLTextParagraph.Entry> myEntries = new ArrayList<ZLTextParagraph.Entry>();
|
private final ArrayList<ZLImageEntry> myEntries = new ArrayList<ZLImageEntry>();
|
||||||
private ZLIntArray myStartEntryIndices = new ZLIntArray(1024);
|
private final ZLIntArray myStartEntryIndices = new ZLIntArray(1024);
|
||||||
private ZLIntArray myStartEntryOffsets = new ZLIntArray(1024);
|
private final ZLIntArray myStartEntryOffsets = new ZLIntArray(1024);
|
||||||
|
|
||||||
private static final int DATA_BLOCK_SIZE = 65536;
|
|
||||||
private int myBlockOffset = 0;
|
|
||||||
private final ArrayList<char[]> myData = new ArrayList<char[]>(1024);
|
private final ArrayList<char[]> myData = new ArrayList<char[]>(1024);
|
||||||
|
private final int myDataBlockSize;
|
||||||
|
private int myBlockOffset = 0;
|
||||||
|
|
||||||
final class EntryIteratorImpl implements ZLTextParagraph.EntryIterator {
|
final class EntryIteratorImpl implements ZLTextParagraph.EntryIterator {
|
||||||
private int myCounter;
|
private int myCounter;
|
||||||
|
@ -33,6 +33,8 @@ abstract class ZLTextModelImpl implements ZLTextModel {
|
||||||
private boolean myControlIsStart;
|
private boolean myControlIsStart;
|
||||||
private boolean myControlIsHyperlink;
|
private boolean myControlIsHyperlink;
|
||||||
|
|
||||||
|
private ZLImageEntry myImageEntry;
|
||||||
|
|
||||||
EntryIteratorImpl(int index, int length) {
|
EntryIteratorImpl(int index, int length) {
|
||||||
myLength = length;
|
myLength = length;
|
||||||
myDataIndex = myStartEntryIndices.get(index);
|
myDataIndex = myStartEntryIndices.get(index);
|
||||||
|
@ -63,73 +65,79 @@ abstract class ZLTextModelImpl implements ZLTextModel {
|
||||||
return myControlIsHyperlink;
|
return myControlIsHyperlink;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ZLImageEntry getImageEntry() {
|
||||||
|
return myImageEntry;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean hasNext() {
|
public boolean hasNext() {
|
||||||
return myCounter < myLength;
|
return myCounter < myLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ZLTextParagraph.Entry next() {
|
public void next() {
|
||||||
ZLTextParagraph.Entry entry = null;
|
int dataOffset = myDataOffset;
|
||||||
if (myDataOffset == DATA_BLOCK_SIZE) {
|
if (dataOffset == myDataBlockSize) {
|
||||||
++myDataIndex;
|
++myDataIndex;
|
||||||
myDataOffset = 0;
|
dataOffset = 0;
|
||||||
}
|
}
|
||||||
char[] data = myData.get(myDataIndex);
|
char[] data = myData.get(myDataIndex);
|
||||||
myType = (byte)data[myDataOffset];
|
byte type = (byte)data[dataOffset];
|
||||||
if (myType == 0) {
|
if (type == 0) {
|
||||||
data = myData.get(++myDataIndex);
|
data = myData.get(++myDataIndex);
|
||||||
myDataOffset = 0;
|
dataOffset = 0;
|
||||||
myType = (byte)data[0];
|
type = (byte)data[0];
|
||||||
}
|
}
|
||||||
++myDataOffset;
|
myType = type;
|
||||||
switch (myType) {
|
++dataOffset;
|
||||||
|
switch (type) {
|
||||||
case ZLTextParagraph.Entry.TEXT:
|
case ZLTextParagraph.Entry.TEXT:
|
||||||
myTextLength =
|
myTextLength =
|
||||||
((int)data[myDataOffset++] << 16) +
|
((int)data[dataOffset++] << 16) +
|
||||||
(int)data[myDataOffset++];
|
(int)data[dataOffset++];
|
||||||
myTextData = data;
|
myTextData = data;
|
||||||
myTextOffset = myDataOffset;
|
myTextOffset = dataOffset;
|
||||||
myDataOffset += myTextLength;
|
dataOffset += myTextLength;
|
||||||
break;
|
break;
|
||||||
case ZLTextParagraph.Entry.CONTROL:
|
case ZLTextParagraph.Entry.CONTROL:
|
||||||
{
|
{
|
||||||
short kind = (short)data[myDataOffset++];
|
short kind = (short)data[dataOffset++];
|
||||||
myControlKind = (byte)kind;
|
myControlKind = (byte)kind;
|
||||||
myControlIsStart = (kind & 0x0100) == 0x0100;
|
myControlIsStart = (kind & 0x0100) == 0x0100;
|
||||||
if ((kind & 0x0200) == 0x0200) {
|
if ((kind & 0x0200) == 0x0200) {
|
||||||
myControlIsHyperlink = true;
|
myControlIsHyperlink = true;
|
||||||
short labelLength = (short)data[myDataOffset++];
|
short labelLength = (short)data[dataOffset++];
|
||||||
myDataOffset += labelLength;
|
dataOffset += labelLength;
|
||||||
} else {
|
} else {
|
||||||
myControlIsHyperlink = false;
|
myControlIsHyperlink = false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ZLTextParagraph.Entry.IMAGE:
|
case ZLTextParagraph.Entry.IMAGE:
|
||||||
{
|
myImageEntry = myEntries.get((int)data[dataOffset++]);
|
||||||
int address = ((int)data[myDataOffset++] << 16) + (int)data[myDataOffset++];
|
|
||||||
entry = myEntries.get(address);
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case ZLTextParagraph.Entry.FIXED_HSPACE:
|
case ZLTextParagraph.Entry.FIXED_HSPACE:
|
||||||
case ZLTextParagraph.Entry.FORCED_CONTROL:
|
case ZLTextParagraph.Entry.FORCED_CONTROL:
|
||||||
//entry = myEntries.get((int)code);
|
//entry = myEntries.get((int)code);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
++myCounter;
|
++myCounter;
|
||||||
return entry;
|
myDataOffset = dataOffset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ZLTextModelImpl(int dataBlockSize) {
|
||||||
|
myDataBlockSize = dataBlockSize;
|
||||||
|
}
|
||||||
|
|
||||||
abstract void increaseLastParagraphSize();
|
abstract void increaseLastParagraphSize();
|
||||||
|
|
||||||
void onParagraphCreation() {
|
void createParagraph() {
|
||||||
myStartEntryIndices.add(myData.isEmpty() ? 0 : (myData.size() - 1));
|
myStartEntryIndices.add(myData.isEmpty() ? 0 : (myData.size() - 1));
|
||||||
myStartEntryOffsets.add(myBlockOffset);
|
myStartEntryOffsets.add(myBlockOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final char[] getDataBlock(int minimumLength) {
|
private final char[] getDataBlock(int minimumLength) {
|
||||||
final ArrayList<char[]> data = myData;
|
final ArrayList<char[]> data = myData;
|
||||||
int blockSize = (minimumLength <= DATA_BLOCK_SIZE) ? DATA_BLOCK_SIZE : minimumLength;
|
int blockSize = (minimumLength <= myDataBlockSize) ? myDataBlockSize : minimumLength;
|
||||||
if (!data.isEmpty()) {
|
if (!data.isEmpty()) {
|
||||||
char[] block = data.get(data.size() - 1);
|
char[] block = data.get(data.size() - 1);
|
||||||
if (minimumLength <= block.length - myBlockOffset) {
|
if (minimumLength <= block.length - myBlockOffset) {
|
||||||
|
@ -172,6 +180,7 @@ abstract class ZLTextModelImpl implements ZLTextModel {
|
||||||
myBlockOffset = blockOffset + length;
|
myBlockOffset = blockOffset + length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
public final void addControl(ZLTextForcedControlEntry entry) {
|
public final void addControl(ZLTextForcedControlEntry entry) {
|
||||||
final char[] block = getDataBlock(3);
|
final char[] block = getDataBlock(3);
|
||||||
increaseLastParagraphSize();
|
increaseLastParagraphSize();
|
||||||
|
@ -181,6 +190,7 @@ abstract class ZLTextModelImpl implements ZLTextModel {
|
||||||
block[myBlockOffset++] = (char)entryAddress;
|
block[myBlockOffset++] = (char)entryAddress;
|
||||||
myEntries.add(entry);
|
myEntries.add(entry);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
public final void addHyperlinkControl(byte textKind, String label) {
|
public final void addHyperlinkControl(byte textKind, String label) {
|
||||||
final short labelLength = (short)label.length();
|
final short labelLength = (short)label.length();
|
||||||
|
@ -195,16 +205,16 @@ abstract class ZLTextModelImpl implements ZLTextModel {
|
||||||
//myEntries.add(new ZLTextHyperlinkControlEntry(textKind, label));
|
//myEntries.add(new ZLTextHyperlinkControlEntry(textKind, label));
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void addImage(String id, Map<String,ZLImage> imageMap, short vOffset) {
|
public final void addImage(String id, ZLImageMap imageMap, short vOffset) {
|
||||||
final char[] block = getDataBlock(3);
|
final char[] block = getDataBlock(2);
|
||||||
increaseLastParagraphSize();
|
increaseLastParagraphSize();
|
||||||
block[myBlockOffset++] = (char)ZLTextParagraph.Entry.IMAGE;
|
block[myBlockOffset++] = (char)ZLTextParagraph.Entry.IMAGE;
|
||||||
final int entryAddress = myEntries.size();
|
final int entryAddress = myEntries.size();
|
||||||
block[myBlockOffset++] = (char)(entryAddress >> 16);
|
|
||||||
block[myBlockOffset++] = (char)entryAddress;
|
block[myBlockOffset++] = (char)entryAddress;
|
||||||
myEntries.add(new ZLImageEntry(id, imageMap, vOffset));
|
myEntries.add(new ZLImageEntry(imageMap, id, vOffset));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
public final void addFixedHSpace(short length) {
|
public final void addFixedHSpace(short length) {
|
||||||
final char[] block = getDataBlock(3);
|
final char[] block = getDataBlock(3);
|
||||||
increaseLastParagraphSize();
|
increaseLastParagraphSize();
|
||||||
|
@ -214,31 +224,5 @@ abstract class ZLTextModelImpl implements ZLTextModel {
|
||||||
block[myBlockOffset++] = (char)entryAddress;
|
block[myBlockOffset++] = (char)entryAddress;
|
||||||
myEntries.add(new ZLTextFixedHSpaceEntry(length));
|
myEntries.add(new ZLTextFixedHSpaceEntry(length));
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
public String dump() {
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
final int len = getParagraphsNumber();
|
|
||||||
for (int i = 0; i < len; ++i) {
|
|
||||||
ZLTextParagraph paragraph = getParagraph(i);
|
|
||||||
sb.append("[PARAGRAPH]\n");
|
|
||||||
for (ZLTextParagraph.EntryIterator it = paragraph.iterator(); it.hasNext(); ) {
|
|
||||||
it.next();
|
|
||||||
switch (it.getType()) {
|
|
||||||
case ZLTextParagraph.Entry.TEXT:
|
|
||||||
sb.append("[TEXT]");
|
|
||||||
sb.append(it.getTextData(), it.getTextOffset(), it.getTextLength());
|
|
||||||
sb.append("[/TEXT]");
|
|
||||||
break;
|
|
||||||
case ZLTextParagraph.Entry.CONTROL:
|
|
||||||
if (it.getControlIsStart())
|
|
||||||
sb.append("[CONTROL "+it.getControlKind()+"]");
|
|
||||||
else
|
|
||||||
sb.append("[/CONTROL "+it.getControlKind()+"]");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sb.append("[/PARAGRAPH]\n");
|
|
||||||
}
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,11 @@ import org.zlibrary.text.model.ZLTextParagraph;
|
||||||
import org.zlibrary.text.model.ZLTextPlainModel;
|
import org.zlibrary.text.model.ZLTextPlainModel;
|
||||||
|
|
||||||
final class ZLTextPlainModelImpl extends ZLTextModelImpl implements ZLTextPlainModel {
|
final class ZLTextPlainModelImpl extends ZLTextModelImpl implements ZLTextPlainModel {
|
||||||
private ZLIntArray myParagraphInfos = new ZLIntArray(1024);
|
private final ZLIntArray myParagraphInfos = new ZLIntArray(1024);
|
||||||
|
|
||||||
|
ZLTextPlainModelImpl(int dataBlockSize) {
|
||||||
|
super(dataBlockSize);
|
||||||
|
}
|
||||||
|
|
||||||
public final int getParagraphsNumber() {
|
public final int getParagraphsNumber() {
|
||||||
return myParagraphInfos.size();
|
return myParagraphInfos.size();
|
||||||
|
@ -25,7 +29,7 @@ final class ZLTextPlainModelImpl extends ZLTextModelImpl implements ZLTextPlainM
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createParagraph(byte kind) {
|
public void createParagraph(byte kind) {
|
||||||
onParagraphCreation();
|
createParagraph();
|
||||||
myParagraphInfos.add(kind << 24);
|
myParagraphInfos.add(kind << 24);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
package org.zlibrary.text.model.impl;
|
package org.zlibrary.text.model.impl;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
class ZLTextSpecialParagraphImpl extends ZLTextParagraphImpl {
|
class ZLTextSpecialParagraphImpl extends ZLTextParagraphImpl {
|
||||||
private byte myKind;
|
private final byte myKind;
|
||||||
|
|
||||||
ZLTextSpecialParagraphImpl(byte kind, ZLTextModelImpl model) {
|
ZLTextSpecialParagraphImpl(byte kind, ZLTextModelImpl model) {
|
||||||
super(model);
|
super(model);
|
||||||
|
|
|
@ -6,10 +6,12 @@ import org.zlibrary.text.model.ZLTextTreeModel;
|
||||||
import org.zlibrary.text.model.ZLTextTreeParagraph;
|
import org.zlibrary.text.model.ZLTextTreeParagraph;
|
||||||
|
|
||||||
public class ZLTextTreeModelImpl extends ZLTextModelImpl implements ZLTextTreeModel {
|
public class ZLTextTreeModelImpl extends ZLTextModelImpl implements ZLTextTreeModel {
|
||||||
private final ArrayList<ZLTextTreeParagraph> myParagraphs = new ArrayList<ZLTextTreeParagraph>();
|
private final ArrayList<ZLTextTreeParagraphImpl> myParagraphs =
|
||||||
|
new ArrayList<ZLTextTreeParagraphImpl>();
|
||||||
private final ZLTextTreeParagraphImpl myRoot;
|
private final ZLTextTreeParagraphImpl myRoot;
|
||||||
|
|
||||||
public ZLTextTreeModelImpl() {
|
public ZLTextTreeModelImpl() {
|
||||||
|
super(4096);
|
||||||
myRoot = new ZLTextTreeParagraphImpl(null, this);
|
myRoot = new ZLTextTreeParagraphImpl(null, this);
|
||||||
myRoot.open(true);
|
myRoot.open(true);
|
||||||
}
|
}
|
||||||
|
@ -23,15 +25,16 @@ public class ZLTextTreeModelImpl extends ZLTextModelImpl implements ZLTextTreeMo
|
||||||
}
|
}
|
||||||
|
|
||||||
void increaseLastParagraphSize() {
|
void increaseLastParagraphSize() {
|
||||||
((ZLTextTreeParagraphImpl)myParagraphs.get(myParagraphs.size() - 1)).addEntry();
|
final ArrayList<ZLTextTreeParagraphImpl> paragraphs = myParagraphs;
|
||||||
|
paragraphs.get(paragraphs.size() - 1).addEntry();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ZLTextTreeParagraph createParagraph(ZLTextTreeParagraph parent) {
|
public ZLTextTreeParagraph createParagraph(ZLTextTreeParagraph parent) {
|
||||||
onParagraphCreation();
|
createParagraph();
|
||||||
if (parent == null) {
|
if (parent == null) {
|
||||||
parent = myRoot;
|
parent = myRoot;
|
||||||
}
|
}
|
||||||
ZLTextTreeParagraph tp = new ZLTextTreeParagraphImpl(parent, this);
|
ZLTextTreeParagraphImpl tp = new ZLTextTreeParagraphImpl(parent, this);
|
||||||
myParagraphs.add(tp);
|
myParagraphs.add(tp);
|
||||||
return tp;
|
return tp;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
package org.zlibrary.text.model.impl;
|
package org.zlibrary.text.model.impl;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
|
||||||
|
|
||||||
import org.zlibrary.text.model.ZLTextTreeParagraph;
|
import org.zlibrary.text.model.ZLTextTreeParagraph;
|
||||||
|
|
||||||
|
@ -54,12 +52,6 @@ final class ZLTextTreeParagraphImpl extends ZLTextParagraphImpl implements ZLTex
|
||||||
return (myChildren != null) && !myChildren.isEmpty();
|
return (myChildren != null) && !myChildren.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ZLTextTreeParagraph> children() {
|
|
||||||
return (myChildren != null) ?
|
|
||||||
Collections.unmodifiableList(myChildren) :
|
|
||||||
Collections.<ZLTextTreeParagraph>emptyList();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isLastChild() {
|
public boolean isLastChild() {
|
||||||
if (myParent == null) {
|
if (myParent == null) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -8,15 +8,16 @@ public interface ZLTextStyle {
|
||||||
|
|
||||||
ZLColor getColor();
|
ZLColor getColor();
|
||||||
|
|
||||||
boolean bold();
|
boolean isBold();
|
||||||
boolean italic();
|
boolean isItalic();
|
||||||
int leftIndent();
|
int getLeftIndent();
|
||||||
int rightIndent();
|
int getRightIndent();
|
||||||
int firstLineIndentDelta();
|
int getFirstLineIndentDelta();
|
||||||
double lineSpace();
|
double getLineSpace();
|
||||||
int verticalShift();
|
int getVerticalShift();
|
||||||
int spaceBefore();
|
int getSpaceBefore();
|
||||||
int spaceAfter();
|
int getSpaceAfter();
|
||||||
boolean isDecorated();
|
byte getAlignment();
|
||||||
byte alignment();
|
|
||||||
|
ZLTextStyle getBase();
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,13 @@ import org.zlibrary.core.application.ZLApplication;
|
||||||
import org.zlibrary.text.model.ZLTextModel;
|
import org.zlibrary.text.model.ZLTextModel;
|
||||||
|
|
||||||
public abstract class ZLTextView extends ZLView {
|
public abstract class ZLTextView extends ZLView {
|
||||||
|
public interface ScrollingMode {
|
||||||
|
int NO_OVERLAPPING = 0;
|
||||||
|
int KEEP_LINES = 1;
|
||||||
|
int SCROLL_LINES = 2;
|
||||||
|
int SCROLL_PERCENTAGE = 3;
|
||||||
|
};
|
||||||
|
|
||||||
public ZLTextView(ZLApplication application, ZLPaintContext context) {
|
public ZLTextView(ZLApplication application, ZLPaintContext context) {
|
||||||
super(application, context);
|
super(application, context);
|
||||||
}
|
}
|
||||||
|
@ -15,11 +22,9 @@ public abstract class ZLTextView extends ZLView {
|
||||||
public abstract void paint();
|
public abstract void paint();
|
||||||
public abstract String caption();
|
public abstract String caption();
|
||||||
|
|
||||||
// TO BE DELETED;
|
public abstract void scrollPage(boolean forward, int scrollingMode, int value);
|
||||||
// this is temporary method for dummy scrolling
|
|
||||||
public abstract void scroll(int numberOfParagraphs);
|
|
||||||
|
|
||||||
public abstract void gotoParagraph(int index);
|
//public abstract void gotoParagraph(int index);
|
||||||
|
|
||||||
public abstract int getLeftMargin();
|
public abstract int getLeftMargin();
|
||||||
public abstract int getRightMargin();
|
public abstract int getRightMargin();
|
||||||
|
|
|
@ -4,11 +4,11 @@ import org.zlibrary.text.view.*;
|
||||||
|
|
||||||
final class ZLTextLineInfo {
|
final class ZLTextLineInfo {
|
||||||
static final class TreeNodeInfo {
|
static final class TreeNodeInfo {
|
||||||
public final boolean IsLeaf;
|
final boolean IsLeaf;
|
||||||
public final boolean IsOpen;
|
final boolean IsOpen;
|
||||||
public final boolean IsFirstLine;
|
final boolean IsFirstLine;
|
||||||
public final int ParagraphNumber;
|
final int ParagraphNumber;
|
||||||
public final boolean[] VerticalLinesStack;
|
final boolean[] VerticalLinesStack;
|
||||||
|
|
||||||
TreeNodeInfo(boolean isLeaf, boolean isOpen, boolean isFirstLine, int paragraphNumber, boolean[] stack) {
|
TreeNodeInfo(boolean isLeaf, boolean isOpen, boolean isFirstLine, int paragraphNumber, boolean[] stack) {
|
||||||
IsLeaf = isLeaf;
|
IsLeaf = isLeaf;
|
||||||
|
@ -20,29 +20,52 @@ final class ZLTextLineInfo {
|
||||||
};
|
};
|
||||||
TreeNodeInfo NodeInfo;
|
TreeNodeInfo NodeInfo;
|
||||||
|
|
||||||
public ZLTextWordCursor Start;
|
final ZLTextParagraphCursor ParagraphCursor;
|
||||||
public ZLTextWordCursor RealStart;
|
final int ParagraphCursorLength;
|
||||||
public ZLTextWordCursor End;
|
|
||||||
public boolean IsVisible;
|
final int StartWordNumber;
|
||||||
public int LeftIndent;
|
final int StartCharNumber;
|
||||||
public int Width;
|
int RealStartWordNumber;
|
||||||
public int Height;
|
int RealStartCharNumber;
|
||||||
public int Descent;
|
int EndWordNumber;
|
||||||
public int VSpaceAfter;
|
int EndCharNumber;
|
||||||
public ZLTextStyle StartStyle;
|
|
||||||
public int SpaceCounter;
|
boolean IsVisible;
|
||||||
|
int LeftIndent;
|
||||||
|
int Width;
|
||||||
|
int Height;
|
||||||
|
int Descent;
|
||||||
|
int VSpaceAfter;
|
||||||
|
int SpaceCounter;
|
||||||
|
ZLTextStyle StartStyle;
|
||||||
|
|
||||||
|
ZLTextLineInfo(ZLTextParagraphCursor paragraphCursor, int wordNumber, int charNumber, ZLTextStyle style) {
|
||||||
|
ParagraphCursor = paragraphCursor;
|
||||||
|
ParagraphCursorLength = paragraphCursor.getParagraphLength();
|
||||||
|
|
||||||
|
StartWordNumber = wordNumber;
|
||||||
|
StartCharNumber = charNumber;
|
||||||
|
RealStartWordNumber = wordNumber;
|
||||||
|
RealStartCharNumber = charNumber;
|
||||||
|
EndWordNumber = wordNumber;
|
||||||
|
EndCharNumber = charNumber;
|
||||||
|
|
||||||
public ZLTextLineInfo(ZLTextWordCursor word, ZLTextStyle style) {
|
|
||||||
Start = new ZLTextWordCursor(word);
|
|
||||||
RealStart = new ZLTextWordCursor(word);
|
|
||||||
End = new ZLTextWordCursor(word);
|
|
||||||
IsVisible = false;
|
|
||||||
LeftIndent = 0;
|
|
||||||
Width = 0;
|
|
||||||
Height = 0;
|
|
||||||
Descent = 0;
|
|
||||||
VSpaceAfter = 0;
|
|
||||||
StartStyle = style;
|
StartStyle = style;
|
||||||
SpaceCounter = 0;
|
}
|
||||||
|
|
||||||
|
boolean isEndOfParagraph() {
|
||||||
|
return EndWordNumber == ParagraphCursorLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
ZLTextLineInfo info = (ZLTextLineInfo)o;
|
||||||
|
return
|
||||||
|
(ParagraphCursor == info.ParagraphCursor) &&
|
||||||
|
(StartWordNumber == info.StartWordNumber) &&
|
||||||
|
(StartCharNumber == info.StartCharNumber);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int hashCode() {
|
||||||
|
return ParagraphCursor.hashCode() + StartWordNumber + 239 * StartCharNumber;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
9
src/org/zlibrary/text/view/impl/ZLTextLineInfoCache.java
Normal file
9
src/org/zlibrary/text/view/impl/ZLTextLineInfoCache.java
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
package org.zlibrary.text.view.impl;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
final class ZLTextLineInfoCache extends HashMap<ZLTextLineInfo,ZLTextLineInfo> {
|
||||||
|
public void put(ZLTextLineInfo info) {
|
||||||
|
super.put(info, info);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
package org.zlibrary.text.view.impl;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
final class ZLTextLineInfoVector extends ArrayList<ZLTextLineInfo> {
|
||||||
|
}
|
|
@ -7,7 +7,7 @@ import org.zlibrary.core.image.ZLImage;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
abstract class ZLTextParagraphCursor {
|
public abstract class ZLTextParagraphCursor {
|
||||||
private static abstract class Processor {
|
private static abstract class Processor {
|
||||||
protected ZLTextParagraph myParagraph;
|
protected ZLTextParagraph myParagraph;
|
||||||
protected ArrayList<ZLTextElement> myElements;
|
protected ArrayList<ZLTextElement> myElements;
|
||||||
|
@ -19,25 +19,18 @@ abstract class ZLTextParagraphCursor {
|
||||||
//myOffset = 0;
|
//myOffset = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*Why do we need ZLTextParagraph.Entry interface?*/
|
|
||||||
|
|
||||||
void fill() {
|
void fill() {
|
||||||
//for (ZLTextParagraph.Entry entry : myParagraph) {
|
|
||||||
for (ZLTextParagraph.EntryIterator it = myParagraph.iterator(); it.hasNext(); ) {
|
for (ZLTextParagraph.EntryIterator it = myParagraph.iterator(); it.hasNext(); ) {
|
||||||
ZLTextParagraph.Entry entry = it.next();
|
it.next();
|
||||||
switch (it.getType()) {
|
switch (it.getType()) {
|
||||||
case ZLTextParagraph.Entry.TEXT:
|
case ZLTextParagraph.Entry.TEXT:
|
||||||
//processTextEntry((ZLTextEntry)entry);
|
|
||||||
processTextEntry(it.getTextData(), it.getTextOffset(), it.getTextLength());
|
processTextEntry(it.getTextData(), it.getTextOffset(), it.getTextLength());
|
||||||
break;
|
break;
|
||||||
case ZLTextParagraph.Entry.CONTROL:
|
case ZLTextParagraph.Entry.CONTROL:
|
||||||
// System.out.println("Tag = " + ((ZLTextControlEntry) entry).getKind());
|
|
||||||
//myElements.add(new ZLTextControlElement((ZLTextControlEntry)entry));
|
|
||||||
myElements.add(ZLTextControlElement.get(it.getControlKind(), it.getControlIsStart()));
|
myElements.add(ZLTextControlElement.get(it.getControlKind(), it.getControlIsStart()));
|
||||||
break;
|
break;
|
||||||
case ZLTextParagraph.Entry.IMAGE:
|
case ZLTextParagraph.Entry.IMAGE:
|
||||||
ZLImageEntry imageEntry = (ZLImageEntry)entry;
|
ZLImage image = it.getImageEntry().getImage();
|
||||||
ZLImage image = imageEntry.getImage();
|
|
||||||
if (image != null) {
|
if (image != null) {
|
||||||
myElements.add(new ZLTextImageElement(image));
|
myElements.add(new ZLTextImageElement(image));
|
||||||
}
|
}
|
||||||
|
@ -108,12 +101,15 @@ abstract class ZLTextParagraphCursor {
|
||||||
}
|
}
|
||||||
|
|
||||||
static ZLTextParagraphCursor cursor(ZLTextModel model, int index) {
|
static ZLTextParagraphCursor cursor(ZLTextModel model, int index) {
|
||||||
ZLTextParagraphCursor result;
|
ZLTextParagraphCursor result = ZLTextParagraphCursorCache.get(model, index);
|
||||||
|
if (result == null) {
|
||||||
if (model instanceof ZLTextTreeModel) {
|
if (model instanceof ZLTextTreeModel) {
|
||||||
result = new ZLTextTreeParagraphCursor((ZLTextTreeModel)model, index);
|
result = new ZLTextTreeParagraphCursor((ZLTextTreeModel)model, index);
|
||||||
} else {
|
} else {
|
||||||
result = new ZLTextPlainParagraphCursor(model, index);
|
result = new ZLTextPlainParagraphCursor(model, index);
|
||||||
}
|
}
|
||||||
|
ZLTextParagraphCursorCache.put(model, index, result);
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,12 +131,6 @@ abstract class ZLTextParagraphCursor {
|
||||||
myElements.clear();
|
myElements.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*Something strange here*/
|
|
||||||
|
|
||||||
boolean isNull() {
|
|
||||||
return myModel == null;
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean isFirst() {
|
boolean isFirst() {
|
||||||
return myIndex == 0;
|
return myIndex == 0;
|
||||||
}
|
}
|
||||||
|
@ -151,11 +141,11 @@ abstract class ZLTextParagraphCursor {
|
||||||
return (myModel.getParagraph(myIndex).getKind() == ZLTextParagraph.Kind.END_OF_SECTION_PARAGRAPH);
|
return (myModel.getParagraph(myIndex).getKind() == ZLTextParagraph.Kind.END_OF_SECTION_PARAGRAPH);
|
||||||
}
|
}
|
||||||
|
|
||||||
int getParagraphLength() {
|
final int getParagraphLength() {
|
||||||
return myElements.size();
|
return myElements.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
int getIndex() {
|
public final int getIndex() {
|
||||||
return myIndex;
|
return myIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,5 +160,3 @@ abstract class ZLTextParagraphCursor {
|
||||||
return myModel.getParagraph(myIndex);
|
return myModel.getParagraph(myIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
package org.zlibrary.text.view.impl;
|
||||||
|
|
||||||
|
import java.lang.ref.WeakReference;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import org.zlibrary.text.model.ZLTextModel;
|
||||||
|
|
||||||
|
class ZLTextParagraphCursorCache {
|
||||||
|
private final static class Key {
|
||||||
|
private final ZLTextModel myModel;
|
||||||
|
private final int myIndex;
|
||||||
|
|
||||||
|
public Key(ZLTextModel model, int index) {
|
||||||
|
myModel = model;
|
||||||
|
myIndex = index;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
Key k = (Key)o;
|
||||||
|
return (myModel == k.myModel) && (myIndex == k.myIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int hashCode() {
|
||||||
|
return myModel.hashCode() + myIndex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final HashMap<Key,WeakReference<ZLTextParagraphCursor>> ourMap =
|
||||||
|
new HashMap<Key,WeakReference<ZLTextParagraphCursor>>();
|
||||||
|
|
||||||
|
public static void put(ZLTextModel model, int index, ZLTextParagraphCursor cursor) {
|
||||||
|
ourMap.put(new Key(model, index), new WeakReference<ZLTextParagraphCursor>(cursor));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ZLTextParagraphCursor get(ZLTextModel model, int index) {
|
||||||
|
WeakReference<ZLTextParagraphCursor> ref = ourMap.get(new Key(model, index));
|
||||||
|
return (ref != null) ? ref.get() : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void clear() {
|
||||||
|
ourMap.clear();
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,6 +5,7 @@ import org.zlibrary.text.model.ZLTextModel;
|
||||||
class ZLTextPlainParagraphCursor extends ZLTextParagraphCursor {
|
class ZLTextPlainParagraphCursor extends ZLTextParagraphCursor {
|
||||||
ZLTextPlainParagraphCursor(ZLTextModel model, int index) {
|
ZLTextPlainParagraphCursor(ZLTextModel model, int index) {
|
||||||
super(model, index);
|
super(model, index);
|
||||||
|
//System.err.println("ZLTextPlainParagraphCursor " + index);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isLast() {
|
public boolean isLast() {
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package org.zlibrary.text.view.impl;
|
package org.zlibrary.text.view.impl;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.zlibrary.text.model.*;
|
import org.zlibrary.text.model.*;
|
||||||
|
|
||||||
final class ZLTextTreeParagraphCursor extends ZLTextParagraphCursor {
|
final class ZLTextTreeParagraphCursor extends ZLTextParagraphCursor {
|
||||||
|
|
|
@ -6,6 +6,7 @@ import org.zlibrary.core.application.ZLApplication;
|
||||||
import org.zlibrary.core.view.ZLView;
|
import org.zlibrary.core.view.ZLView;
|
||||||
import org.zlibrary.core.view.ZLPaintContext;
|
import org.zlibrary.core.view.ZLPaintContext;
|
||||||
import org.zlibrary.core.options.*;
|
import org.zlibrary.core.options.*;
|
||||||
|
import org.zlibrary.core.util.ZLIntArray;
|
||||||
|
|
||||||
import org.zlibrary.text.model.*;
|
import org.zlibrary.text.model.*;
|
||||||
|
|
||||||
|
@ -15,16 +16,37 @@ import org.zlibrary.text.view.style.*;
|
||||||
public abstract class ZLTextViewImpl extends ZLTextView {
|
public abstract class ZLTextViewImpl extends ZLTextView {
|
||||||
private ZLTextModel myModel;
|
private ZLTextModel myModel;
|
||||||
|
|
||||||
|
private interface SizeUnit {
|
||||||
|
int PIXEL_UNIT = 0;
|
||||||
|
int LINE_UNIT = 1;
|
||||||
|
};
|
||||||
|
private interface PaintState {
|
||||||
|
int NOTHING_TO_PAINT = 0;
|
||||||
|
int READY = 1;
|
||||||
|
int START_IS_KNOWN = 2;
|
||||||
|
int END_IS_KNOWN = 3;
|
||||||
|
int TO_SCROLL_FORWARD = 4;
|
||||||
|
int TO_SCROLL_BACKWARD = 5;
|
||||||
|
};
|
||||||
|
private int myPaintState = PaintState.NOTHING_TO_PAINT;
|
||||||
|
private int myScrollingMode;
|
||||||
|
private int myOverlappingValue;
|
||||||
|
|
||||||
|
private int myOldWidth;
|
||||||
|
private int myOldHeight;
|
||||||
|
|
||||||
|
private final ZLTextWordCursor myStartCursor = new ZLTextWordCursor();
|
||||||
|
private final ZLTextWordCursor myEndCursor = new ZLTextWordCursor();
|
||||||
|
|
||||||
|
private final ZLTextLineInfoVector myLineInfos = new ZLTextLineInfoVector();
|
||||||
|
private final ZLTextLineInfoCache myLineInfoCache = new ZLTextLineInfoCache();
|
||||||
|
|
||||||
private ZLTextStyle myTextStyle;
|
private ZLTextStyle myTextStyle;
|
||||||
private int myWordHeight = -1;
|
private int myWordHeight = -1;
|
||||||
|
|
||||||
private final ArrayList<ZLTextLineInfo> myLineInfos = new ArrayList<ZLTextLineInfo>();
|
|
||||||
private final ArrayList<ZLTextElementArea> myTextElementMap = new ArrayList<ZLTextElementArea>();
|
private final ArrayList<ZLTextElementArea> myTextElementMap = new ArrayList<ZLTextElementArea>();
|
||||||
private final ArrayList<ZLTextTreeNodeArea> myTreeNodeMap = new ArrayList<ZLTextTreeNodeArea>();
|
private final ArrayList<ZLTextTreeNodeArea> myTreeNodeMap = new ArrayList<ZLTextTreeNodeArea>();
|
||||||
|
|
||||||
// TO BE DELETED
|
|
||||||
private int myStartParagraphNumber;
|
|
||||||
|
|
||||||
public ZLTextViewImpl(ZLApplication application, ZLPaintContext context) {
|
public ZLTextViewImpl(ZLApplication application, ZLPaintContext context) {
|
||||||
super(application, context);
|
super(application, context);
|
||||||
resetTextStyle();
|
resetTextStyle();
|
||||||
|
@ -32,17 +54,26 @@ public abstract class ZLTextViewImpl extends ZLTextView {
|
||||||
|
|
||||||
public void setModel(ZLTextModel model) {
|
public void setModel(ZLTextModel model) {
|
||||||
myModel = model;
|
myModel = model;
|
||||||
|
if (myModel.getParagraphsNumber() > 0) {
|
||||||
|
myStartCursor.setCursor(ZLTextParagraphCursor.cursor(myModel, 0));
|
||||||
|
myEndCursor.reset();
|
||||||
|
myPaintState = PaintState.START_IS_KNOWN;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
protected ZLTextModel getModel() {
|
protected ZLTextModel getModel() {
|
||||||
return myModel;
|
return myModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected ZLTextWordCursor getStartCursor() {
|
||||||
|
return myStartCursor;
|
||||||
|
}
|
||||||
|
|
||||||
private void setTextStyle(ZLTextStyle style) {
|
private void setTextStyle(ZLTextStyle style) {
|
||||||
if (myTextStyle != style) {
|
if (myTextStyle != style) {
|
||||||
myTextStyle = style;
|
myTextStyle = style;
|
||||||
myWordHeight = -1;
|
myWordHeight = -1;
|
||||||
}
|
}
|
||||||
getContext().setFont(myTextStyle.getFontFamily(), myTextStyle.getFontSize(), myTextStyle.bold(), myTextStyle.italic());
|
getContext().setFont(style.getFontFamily(), style.getFontSize(), style.isBold(), style.isItalic());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void resetTextStyle() {
|
private void resetTextStyle() {
|
||||||
|
@ -50,24 +81,23 @@ public abstract class ZLTextViewImpl extends ZLTextView {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void applyControl(ZLTextControlElement control) {
|
private void applyControl(ZLTextControlElement control) {
|
||||||
|
final ZLTextStyle textStyle = myTextStyle;
|
||||||
if (control.IsStart) {
|
if (control.IsStart) {
|
||||||
// System.out.println("Apply Start " + control.Kind);
|
// System.out.println("Apply Start " + control.Kind);
|
||||||
ZLTextStyleDecoration decoration = ZLTextStyleCollection.getInstance().getDecoration(control.Kind);
|
ZLTextStyleDecoration decoration = ZLTextStyleCollection.getInstance().getDecoration(control.Kind);
|
||||||
setTextStyle(decoration.createDecoratedStyle(myTextStyle));
|
setTextStyle(decoration.createDecoratedStyle(textStyle));
|
||||||
// if (decoration instanceof ZLTextFullStyleDecoration) {
|
// if (decoration instanceof ZLTextFullStyleDecoration) {
|
||||||
// System.out.println("FontSize = " + myTextStyle.getFontSize());
|
// System.out.println("FontSize = " + textStyle.getFontSize());
|
||||||
// }
|
// }
|
||||||
} else {
|
} else {
|
||||||
// System.out.println("Apply End " + control.Kind);
|
// System.out.println("Apply End " + control.Kind);
|
||||||
if (myTextStyle.isDecorated()) {
|
setTextStyle(textStyle.getBase());
|
||||||
setTextStyle(((ZLTextDecoratedStyle) myTextStyle).getBase());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void applyControls(ZLTextWordCursor begin, ZLTextWordCursor end) {
|
private void applyControls(ZLTextParagraphCursor cursor, int index, int end) {
|
||||||
for (ZLTextWordCursor cursor = begin; !cursor.equalWordNumber(end); cursor.nextWord()) {
|
for (; index != end; ++index) {
|
||||||
final ZLTextElement element = cursor.getElement();
|
final ZLTextElement element = cursor.getElement(index);
|
||||||
if (element instanceof ZLTextControlElement) {
|
if (element instanceof ZLTextControlElement) {
|
||||||
applyControl((ZLTextControlElement)element);
|
applyControl((ZLTextControlElement)element);
|
||||||
}
|
}
|
||||||
|
@ -80,20 +110,24 @@ public abstract class ZLTextViewImpl extends ZLTextView {
|
||||||
} else if (element instanceof ZLTextImageElement) {
|
} else if (element instanceof ZLTextImageElement) {
|
||||||
return getContext().imageWidth(((ZLTextImageElement)element).getImage());
|
return getContext().imageWidth(((ZLTextImageElement)element).getImage());
|
||||||
} else if (element == ZLTextElement.IndentElement) {
|
} else if (element == ZLTextElement.IndentElement) {
|
||||||
return myTextStyle.firstLineIndentDelta();
|
return myTextStyle.getFirstLineIndentDelta();
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getElementHeight(ZLTextElement element) {
|
private int getElementHeight(ZLTextElement element) {
|
||||||
if (element instanceof ZLTextWord) {
|
if (element instanceof ZLTextWord) {
|
||||||
if (myWordHeight == -1) {
|
int wordHeight = myWordHeight;
|
||||||
myWordHeight = (int) (getContext().getStringHeight() * myTextStyle.lineSpace()) + myTextStyle.verticalShift();
|
if (wordHeight == -1) {
|
||||||
|
final ZLTextStyle textStyle = myTextStyle;
|
||||||
|
wordHeight = (int)(getContext().getStringHeight() * textStyle.getLineSpace()) + textStyle.getVerticalShift();
|
||||||
|
myWordHeight = wordHeight;
|
||||||
}
|
}
|
||||||
return myWordHeight;
|
return wordHeight;
|
||||||
} else if (element instanceof ZLTextImageElement) {
|
} else if (element instanceof ZLTextImageElement) {
|
||||||
return getContext().imageHeight(((ZLTextImageElement) element).getImage()) +
|
final ZLPaintContext context = getContext();
|
||||||
Math.max((int)(getContext().getStringHeight() * (myTextStyle.lineSpace() - 1)), 3);
|
return context.imageHeight(((ZLTextImageElement)element).getImage()) +
|
||||||
|
Math.max((int)(context.getStringHeight() * (myTextStyle.getLineSpace() - 1)), 3);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -121,80 +155,40 @@ public abstract class ZLTextViewImpl extends ZLTextView {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void paint() {
|
public void paint() {
|
||||||
final ZLPaintContext context = getContext();
|
preparePaintInfo();
|
||||||
context.clear(ZLTextStyleCollection.getInstance().getBaseStyle().BackgroundColorOption.getValue());
|
|
||||||
myTextElementMap.clear();
|
myTextElementMap.clear();
|
||||||
myTreeNodeMap.clear();
|
myTreeNodeMap.clear();
|
||||||
|
|
||||||
|
final ZLPaintContext context = getContext();
|
||||||
|
context.clear(ZLTextStyleCollection.getInstance().getBaseStyle().BackgroundColorOption.getValue());
|
||||||
|
|
||||||
if ((myModel == null) || (myModel.getParagraphsNumber() == 0)) {
|
if ((myModel == null) || (myModel.getParagraphsNumber() == 0)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int paragraphs = myModel.getParagraphsNumber();
|
final ZLTextLineInfoVector lineInfos = myLineInfos;
|
||||||
if (paragraphs > 0) {
|
final int lineInfosSize = lineInfos.size();
|
||||||
int pn = myStartParagraphNumber;
|
final ZLIntArray labels = new ZLIntArray(lineInfosSize + 1);
|
||||||
pn = Math.max(0, Math.min(pn, paragraphs - 2));
|
|
||||||
myStartParagraphNumber = pn;
|
|
||||||
ZLTextParagraphCursor firstParagraph = ZLTextParagraphCursor.cursor(myModel, pn);
|
|
||||||
ZLTextWordCursor start = new ZLTextWordCursor();
|
|
||||||
start.setCursor(firstParagraph);
|
|
||||||
buildInfos(start);
|
|
||||||
}
|
|
||||||
|
|
||||||
ArrayList<Integer> labels = new ArrayList<Integer>(myLineInfos.size() + 1);
|
|
||||||
labels.add(0);
|
labels.add(0);
|
||||||
context.moveYTo(getTopMargin());
|
context.moveYTo(getTopMargin());
|
||||||
for (ZLTextLineInfo info : myLineInfos) {
|
for (int i = 0; i < lineInfosSize; ++i) {
|
||||||
prepareTextLine(info);
|
prepareTextLine(lineInfos.get(i));
|
||||||
labels.add(myTextElementMap.size());
|
labels.add(myTextElementMap.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
context.moveYTo(getTopMargin());
|
context.moveYTo(getTopMargin());
|
||||||
int index = 0;
|
for (int i = 0; i < lineInfosSize; ++i) {
|
||||||
for (ZLTextLineInfo info : myLineInfos) {
|
drawTextLine(context, lineInfos.get(i), labels.get(i), labels.get(i + 1));
|
||||||
drawTextLine(info, labels.get(index), labels.get(index + 1));
|
|
||||||
index++;
|
|
||||||
//System.out.println("Line " + index + " Y = " + context.getY());
|
//System.out.println("Line " + index + " Y = " + context.getY());
|
||||||
}
|
}
|
||||||
|
|
||||||
// for (ZLTextElementArea area : myTextElementMap) {
|
// for (ZLTextElementArea area : myTextElementMap) {
|
||||||
// System.out.println(area.XStart + " " + area.XEnd + " " + area.YStart + " " + area.YEnd);
|
// System.out.println(area.XStart + " " + area.XEnd + " " + area.YStart + " " + area.YEnd);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
/* int h = 0;
|
|
||||||
for (ZLTextLineInfo info : myLineInfos) {
|
|
||||||
int w = 0;
|
|
||||||
int spaces = 0;
|
|
||||||
boolean wordOccurred = false;
|
|
||||||
ZLTextWordCursor cursor;
|
|
||||||
for (cursor = info.getStart(); !cursor.equalWordNumber(info.End); cursor.nextWord()) {
|
|
||||||
ZLTextElement element = cursor.getElement();
|
|
||||||
if (element == ZLTextElement.HSpace) {
|
|
||||||
if (wordOccurred) {
|
|
||||||
w += context.getSpaceWidth();
|
|
||||||
spaces++;
|
|
||||||
wordOccurred = false;
|
|
||||||
}
|
|
||||||
} else if (element instanceof ZLTextWord) {
|
|
||||||
System.out.println("Word");
|
|
||||||
wordOccurred = true;
|
|
||||||
ZLTextWord word = (ZLTextWord)element;
|
|
||||||
context.drawString(w, h + info.Height, word.Data, word.Offset, word.Length);
|
|
||||||
w += word.getWidth(context);
|
|
||||||
} else if (element instanceof ZLTextControlElement) {
|
|
||||||
applyControl((ZLTextControlElement) element);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (cursor.isEndOfParagraph()) {
|
|
||||||
resetTextStyle();
|
|
||||||
}
|
|
||||||
System.out.println("Line over");
|
|
||||||
h += info.Height + info.Descent;
|
|
||||||
} */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void drawTreeLines(ZLTextLineInfo.TreeNodeInfo info, int height, int vSpaceAfter) {
|
private void drawTreeLines(ZLPaintContext context, ZLTextLineInfo.TreeNodeInfo info, int height, int vSpaceAfter) {
|
||||||
final ZLPaintContext context = getContext();
|
|
||||||
context.setColor(ZLTextStyleCollection.getInstance().getBaseStyle().TreeLinesColorOption.getValue());
|
context.setColor(ZLTextStyleCollection.getInstance().getBaseStyle().TreeLinesColorOption.getValue());
|
||||||
|
|
||||||
int x = context.getX();
|
int x = context.getX();
|
||||||
|
@ -252,24 +246,23 @@ public abstract class ZLTextViewImpl extends ZLTextView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void drawTextLine(ZLTextLineInfo info, final int from, final int to) {
|
private void drawTextLine(final ZLPaintContext context, final ZLTextLineInfo info, final int from, final int to) {
|
||||||
final ZLPaintContext context = getContext();
|
final ZLTextParagraphCursor paragraph = info.ParagraphCursor;
|
||||||
final ZLTextParagraphCursor paragraph = info.RealStart.getParagraphCursor();
|
|
||||||
|
|
||||||
context.moveY(info.Height);
|
context.moveY(info.Height);
|
||||||
int maxY = getTopMargin() + getTextAreaHeight();
|
int maxY = getTextAreaHeight() + getTopMargin();
|
||||||
if (context.getY() > maxY) {
|
if (context.getY() > maxY) {
|
||||||
context.moveYTo(maxY);
|
context.moveYTo(maxY);
|
||||||
}
|
}
|
||||||
context.moveXTo(getLeftMargin());
|
context.moveXTo(getLeftMargin());
|
||||||
if (info.NodeInfo != null) {
|
if (info.NodeInfo != null) {
|
||||||
drawTreeLines(info.NodeInfo, info.Height, info.Descent + info.VSpaceAfter);
|
drawTreeLines(context, info.NodeInfo, info.Height, info.Descent + info.VSpaceAfter);
|
||||||
}
|
}
|
||||||
|
|
||||||
int index = from;
|
int index = from;
|
||||||
final int endWordNumber = info.End.getWordNumber();
|
final int endWordNumber = info.EndWordNumber;
|
||||||
int charNumber = info.RealStart.getCharNumber();
|
int charNumber = info.RealStartCharNumber;
|
||||||
for (int wordNumber = info.RealStart.getWordNumber(); wordNumber != endWordNumber; ++wordNumber, charNumber = 0) {
|
for (int wordNumber = info.RealStartWordNumber; wordNumber != endWordNumber; ++wordNumber, charNumber = 0) {
|
||||||
final ZLTextElement element = paragraph.getElement(wordNumber);
|
final ZLTextElement element = paragraph.getElement(wordNumber);
|
||||||
if ((element instanceof ZLTextWord) || (element instanceof ZLTextImageElement)) {
|
if ((element instanceof ZLTextWord) || (element instanceof ZLTextImageElement)) {
|
||||||
//System.out.println("Word = " + ((ZLTextWord) element).getWord());
|
//System.out.println("Word = " + ((ZLTextWord) element).getWord());
|
||||||
|
@ -278,7 +271,7 @@ public abstract class ZLTextViewImpl extends ZLTextView {
|
||||||
setTextStyle(area.Style);
|
setTextStyle(area.Style);
|
||||||
}
|
}
|
||||||
final int x = area.XStart;
|
final int x = area.XStart;
|
||||||
final int y = area.YEnd - getElementDescent(element) - myTextStyle.verticalShift();
|
final int y = area.YEnd - getElementDescent(element) - myTextStyle.getVerticalShift();
|
||||||
context.moveXTo(x);
|
context.moveXTo(x);
|
||||||
if (element instanceof ZLTextWord) {
|
if (element instanceof ZLTextWord) {
|
||||||
//System.out.println("Draw " + x + " " + y + " " + area.YEnd);
|
//System.out.println("Draw " + x + " " + y + " " + area.YEnd);
|
||||||
|
@ -293,10 +286,10 @@ public abstract class ZLTextViewImpl extends ZLTextView {
|
||||||
if (area.ChangeStyle) {
|
if (area.ChangeStyle) {
|
||||||
setTextStyle(area.Style);
|
setTextStyle(area.Style);
|
||||||
}
|
}
|
||||||
int len = info.End.getCharNumber();
|
int len = info.EndCharNumber;
|
||||||
final ZLTextWord word = (ZLTextWord)info.End.getElement();
|
final ZLTextWord word = (ZLTextWord)paragraph.getElement(info.EndWordNumber);
|
||||||
final int x = area.XStart;
|
final int x = area.XStart;
|
||||||
final int y = area.YEnd - getElementDescent(word) - myTextStyle.verticalShift();
|
final int y = area.YEnd - getElementDescent(word) - myTextStyle.getVerticalShift();
|
||||||
drawWord(x, y, word, 0, len, area.AddHyphenationSign);
|
drawWord(x, y, word, 0, len, area.AddHyphenationSign);
|
||||||
}
|
}
|
||||||
context.moveY(info.Descent + info.VSpaceAfter);
|
context.moveY(info.Descent + info.VSpaceAfter);
|
||||||
|
@ -312,57 +305,58 @@ public abstract class ZLTextViewImpl extends ZLTextView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ZLTextWordCursor buildInfos(ZLTextWordCursor start) {
|
private void buildInfos(final ZLTextWordCursor start, final ZLTextWordCursor result) {
|
||||||
myLineInfos.clear();
|
result.setCursor(start);
|
||||||
final ZLTextWordCursor cursor = new ZLTextWordCursor(start);
|
final ZLPaintContext context = getContext();
|
||||||
int textAreaHeight = getTextAreaHeight();
|
int textAreaHeight = getTextAreaHeight();
|
||||||
|
myLineInfos.clear();
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
final ZLTextWordCursor paragraphEnd = new ZLTextWordCursor();
|
|
||||||
final ZLTextWordCursor paragraphStart = new ZLTextWordCursor();
|
|
||||||
do {
|
do {
|
||||||
paragraphEnd.setCursor(cursor);
|
|
||||||
paragraphEnd.moveToParagraphEnd();
|
|
||||||
paragraphStart.setCursor(cursor);
|
|
||||||
paragraphStart.moveToParagraphStart();
|
|
||||||
|
|
||||||
resetTextStyle();
|
resetTextStyle();
|
||||||
applyControls(paragraphStart, cursor);
|
final ZLTextParagraphCursor paragraphCursor = result.getParagraphCursor();
|
||||||
ZLTextLineInfo info = new ZLTextLineInfo(cursor, myTextStyle);
|
final int wordNumber = result.getWordNumber();
|
||||||
while (!info.End.isEndOfParagraph()) {
|
applyControls(paragraphCursor, 0, wordNumber);
|
||||||
info = processTextLine(info.End, paragraphEnd);
|
ZLTextLineInfo info = new ZLTextLineInfo(paragraphCursor, wordNumber, result.getCharNumber(), myTextStyle);
|
||||||
|
final int endIndex = info.ParagraphCursorLength;
|
||||||
|
while (info.EndWordNumber != endIndex) {
|
||||||
|
info = processTextLine(context, paragraphCursor, info.EndWordNumber, info.EndCharNumber, endIndex);
|
||||||
textAreaHeight -= info.Height + info.Descent;
|
textAreaHeight -= info.Height + info.Descent;
|
||||||
if ((textAreaHeight < 0) && (counter > 0)) {
|
if ((textAreaHeight < 0) && (counter > 0)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
textAreaHeight -= info.VSpaceAfter;
|
textAreaHeight -= info.VSpaceAfter;
|
||||||
cursor.setCursor(info.End);
|
result.moveTo(info.EndWordNumber, info.EndCharNumber);
|
||||||
myLineInfos.add(info);
|
myLineInfos.add(info);
|
||||||
if (textAreaHeight < 0) {
|
if (textAreaHeight < 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
counter++;
|
counter++;
|
||||||
}
|
}
|
||||||
} while (cursor.isEndOfParagraph() && cursor.nextParagraph() && !cursor.getParagraphCursor().isEndOfSection() && (textAreaHeight >= 0));
|
} while (result.isEndOfParagraph() && result.nextParagraph() && !result.getParagraphCursor().isEndOfSection() && (textAreaHeight >= 0));
|
||||||
resetTextStyle();
|
resetTextStyle();
|
||||||
// System.out.println("----------------------INFOS BUILT--------------------------------");
|
// System.out.println("----------------------INFOS BUILT--------------------------------");
|
||||||
return cursor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ZLTextLineInfo processTextLine(ZLTextWordCursor start, ZLTextWordCursor end) {
|
private ZLTextLineInfo processTextLine(final ZLPaintContext context, final ZLTextParagraphCursor paragraphCursor, final int startIndex, final int startCharNumber, final int endIndex) {
|
||||||
final ZLPaintContext context = getContext();
|
final ZLTextLineInfo info = new ZLTextLineInfo(paragraphCursor, startIndex, startCharNumber, myTextStyle);
|
||||||
final ZLTextLineInfo info = new ZLTextLineInfo(start, myTextStyle);
|
final ZLTextLineInfo cachedInfo = myLineInfoCache.get(info);
|
||||||
|
if (cachedInfo != null) {
|
||||||
|
//System.err.println("cached!!!!");
|
||||||
|
return cachedInfo;
|
||||||
|
}
|
||||||
|
|
||||||
ZLTextWordCursor current = new ZLTextWordCursor(start);
|
int currentWordIndex = startIndex;
|
||||||
ZLTextParagraphCursor paragraphCursor = current.getParagraphCursor();
|
int currentCharNumber = startCharNumber;
|
||||||
final boolean isFirstLine = current.isStartOfParagraph();
|
final boolean isFirstLine = (startIndex == 0) && (startCharNumber == 0);
|
||||||
|
|
||||||
if (paragraphCursor.getParagraph().getKind() == ZLTextParagraph.Kind.TREE_PARAGRAPH) {
|
final ZLTextParagraph para = paragraphCursor.getParagraph();
|
||||||
final ZLTextTreeParagraph treeParagraph =
|
if (para.getKind() == ZLTextParagraph.Kind.TREE_PARAGRAPH) {
|
||||||
(ZLTextTreeParagraph)paragraphCursor.getParagraph();
|
final ZLTextTreeParagraph treeParagraph = (ZLTextTreeParagraph)para;
|
||||||
boolean[] stack = new boolean[treeParagraph.getDepth() - 1];
|
final int stackLength = treeParagraph.getDepth() - 1;
|
||||||
if (stack.length > 0) {
|
final boolean[] stack = new boolean[stackLength];
|
||||||
|
if (stackLength > 0) {
|
||||||
ZLTextTreeParagraph ctp = treeParagraph;
|
ZLTextTreeParagraph ctp = treeParagraph;
|
||||||
for (int index = 0; index < stack.length; ++index) {
|
for (int index = 0; index < stackLength; ++index) {
|
||||||
stack[index] = !ctp.isLastChild();
|
stack[index] = !ctp.isLastChild();
|
||||||
ctp = ctp.getParent();
|
ctp = ctp.getParent();
|
||||||
}
|
}
|
||||||
|
@ -377,26 +371,28 @@ public abstract class ZLTextViewImpl extends ZLTextView {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isFirstLine) {
|
if (isFirstLine) {
|
||||||
ZLTextElement element = paragraphCursor.getElement(current.getWordNumber());
|
ZLTextElement element = paragraphCursor.getElement(currentWordIndex);
|
||||||
while (element instanceof ZLTextControlElement) {
|
while (element instanceof ZLTextControlElement) {
|
||||||
if (element instanceof ZLTextControlElement) {
|
if (element instanceof ZLTextControlElement) {
|
||||||
applyControl((ZLTextControlElement) element);
|
applyControl((ZLTextControlElement) element);
|
||||||
}
|
}
|
||||||
current.nextWord();
|
++currentWordIndex;
|
||||||
if (current.equalWordNumber(end)) {
|
currentCharNumber = 0;
|
||||||
|
if (currentWordIndex == endIndex) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
element = paragraphCursor.getElement(current.getWordNumber());
|
element = paragraphCursor.getElement(currentWordIndex);
|
||||||
}
|
}
|
||||||
info.StartStyle = myTextStyle;
|
info.StartStyle = myTextStyle;
|
||||||
info.RealStart.setCursor(current);
|
info.RealStartWordNumber = currentWordIndex;
|
||||||
|
info.RealStartCharNumber = currentCharNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
ZLTextStyle storedStyle = myTextStyle;
|
ZLTextStyle storedStyle = myTextStyle;
|
||||||
|
|
||||||
info.LeftIndent = myTextStyle.leftIndent();
|
info.LeftIndent = myTextStyle.getLeftIndent();
|
||||||
if (isFirstLine) {
|
if (isFirstLine) {
|
||||||
info.LeftIndent += myTextStyle.firstLineIndentDelta();
|
info.LeftIndent += myTextStyle.getFirstLineIndentDelta();
|
||||||
}
|
}
|
||||||
if (info.NodeInfo != null) {
|
if (info.NodeInfo != null) {
|
||||||
info.LeftIndent +=
|
info.LeftIndent +=
|
||||||
|
@ -406,16 +402,16 @@ public abstract class ZLTextViewImpl extends ZLTextView {
|
||||||
|
|
||||||
info.Width = info.LeftIndent;
|
info.Width = info.LeftIndent;
|
||||||
|
|
||||||
final ZLTextWordCursor realStart = info.RealStart;
|
if (info.RealStartWordNumber == endIndex) {
|
||||||
if (realStart.equalWordNumber(end)) {
|
info.EndWordNumber = info.RealStartWordNumber;
|
||||||
info.End.setCursor(realStart);
|
info.EndCharNumber = info.RealStartCharNumber;
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
int newWidth = info.Width;
|
int newWidth = info.Width;
|
||||||
int newHeight = info.Height;
|
int newHeight = info.Height;
|
||||||
int newDescent = info.Descent;
|
int newDescent = info.Descent;
|
||||||
int maxWidth = context.getWidth() - getLeftMargin() - getRightMargin() - myTextStyle.rightIndent();
|
int maxWidth = context.getWidth() - getLeftMargin() - getRightMargin() - myTextStyle.getRightIndent();
|
||||||
boolean wordOccurred = false;
|
boolean wordOccurred = false;
|
||||||
boolean isVisible = false;
|
boolean isVisible = false;
|
||||||
int lastSpaceWidth = 0;
|
int lastSpaceWidth = 0;
|
||||||
|
@ -423,8 +419,8 @@ public abstract class ZLTextViewImpl extends ZLTextView {
|
||||||
boolean removeLastSpace = false;
|
boolean removeLastSpace = false;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
ZLTextElement element = paragraphCursor.getElement(current.getWordNumber());
|
ZLTextElement element = paragraphCursor.getElement(currentWordIndex);
|
||||||
newWidth += getElementWidth(element, current.getCharNumber());
|
newWidth += getElementWidth(element, currentCharNumber);
|
||||||
newHeight = Math.max(newHeight, getElementHeight(element));
|
newHeight = Math.max(newHeight, getElementHeight(element));
|
||||||
newDescent = Math.max(newDescent, getElementDescent(element));
|
newDescent = Math.max(newDescent, getElementDescent(element));
|
||||||
if (element == ZLTextElement.HSpace) {
|
if (element == ZLTextElement.HSpace) {
|
||||||
|
@ -444,14 +440,15 @@ public abstract class ZLTextViewImpl extends ZLTextView {
|
||||||
wordOccurred = true;
|
wordOccurred = true;
|
||||||
isVisible = true;
|
isVisible = true;
|
||||||
}
|
}
|
||||||
if ((newWidth > maxWidth) && !info.End.equalWordNumber(start)) {
|
if ((newWidth > maxWidth) && (info.EndWordNumber != startIndex)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ZLTextElement previousElement = element;
|
ZLTextElement previousElement = element;
|
||||||
current.nextWord();
|
++currentWordIndex;
|
||||||
boolean allowBreak = current.equalWordNumber(end);
|
currentCharNumber = 0;
|
||||||
|
boolean allowBreak = currentWordIndex == endIndex;
|
||||||
if (!allowBreak) {
|
if (!allowBreak) {
|
||||||
element = current.getElement();
|
element = paragraphCursor.getElement(currentWordIndex);
|
||||||
allowBreak = (((!(element instanceof ZLTextWord)) || (previousElement instanceof ZLTextWord)) &&
|
allowBreak = (((!(element instanceof ZLTextWord)) || (previousElement instanceof ZLTextWord)) &&
|
||||||
!(element instanceof ZLTextImageElement) && !(element instanceof ZLTextControlElement));
|
!(element instanceof ZLTextImageElement) && !(element instanceof ZLTextControlElement));
|
||||||
}
|
}
|
||||||
|
@ -460,12 +457,13 @@ public abstract class ZLTextViewImpl extends ZLTextView {
|
||||||
info.Width = newWidth;
|
info.Width = newWidth;
|
||||||
info.Height = Math.max(info.Height, newHeight);
|
info.Height = Math.max(info.Height, newHeight);
|
||||||
info.Descent = Math.max(info.Descent, newDescent);
|
info.Descent = Math.max(info.Descent, newDescent);
|
||||||
info.End.setCursor(current);
|
info.EndWordNumber = currentWordIndex;
|
||||||
storedStyle = myTextStyle;
|
info.EndCharNumber = currentCharNumber;
|
||||||
info.SpaceCounter = internalSpaceCounter;
|
info.SpaceCounter = internalSpaceCounter;
|
||||||
removeLastSpace = !wordOccurred && (info.SpaceCounter > 0);
|
storedStyle = myTextStyle;
|
||||||
|
removeLastSpace = !wordOccurred && (internalSpaceCounter > 0);
|
||||||
}
|
}
|
||||||
} while (!current.equalWordNumber(end));
|
} while (currentWordIndex != endIndex);
|
||||||
|
|
||||||
/* if (!current.equalWordNumber(end)) {
|
/* if (!current.equalWordNumber(end)) {
|
||||||
ZLTextElement element = paragraphCursor.getElement(current.getWordNumber());
|
ZLTextElement element = paragraphCursor.getElement(current.getWordNumber());
|
||||||
|
@ -476,7 +474,7 @@ public abstract class ZLTextViewImpl extends ZLTextView {
|
||||||
info.Width = newWidth;
|
info.Width = newWidth;
|
||||||
info.Height = Math.max(info.Height, newHeight);
|
info.Height = Math.max(info.Height, newHeight);
|
||||||
info.Descent = Math.max(info.Descent, newDescent);
|
info.Descent = Math.max(info.Descent, newDescent);
|
||||||
info.End.setCursor(current);
|
info.setEnd(current);
|
||||||
info.SpaceCounter = internalSpaceCounter;
|
info.SpaceCounter = internalSpaceCounter;
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
@ -488,46 +486,50 @@ public abstract class ZLTextViewImpl extends ZLTextView {
|
||||||
setTextStyle(storedStyle);
|
setTextStyle(storedStyle);
|
||||||
|
|
||||||
if (isFirstLine) {
|
if (isFirstLine) {
|
||||||
info.Height += info.StartStyle.spaceBefore();
|
info.Height += info.StartStyle.getSpaceBefore();
|
||||||
}
|
}
|
||||||
if (info.End.isEndOfParagraph()) {
|
if (info.isEndOfParagraph()) {
|
||||||
info.VSpaceAfter = myTextStyle.spaceAfter();
|
info.VSpaceAfter = myTextStyle.getSpaceAfter();
|
||||||
}
|
}
|
||||||
|
|
||||||
//System.out.println();
|
//System.out.println();
|
||||||
//System.out.println("Info widht = " + info.Width);
|
//System.out.println("Info widht = " + info.Width);
|
||||||
|
|
||||||
// System.out.println(info.End.getElement());
|
// System.out.println(info.End.getElement());
|
||||||
|
if ((info.EndWordNumber != endIndex) || (endIndex == info.ParagraphCursorLength)) {
|
||||||
|
myLineInfoCache.put(info);
|
||||||
|
}
|
||||||
|
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void prepareTextLine(ZLTextLineInfo info) {
|
private void prepareTextLine(ZLTextLineInfo info) {
|
||||||
final ZLPaintContext context = getContext();
|
final ZLPaintContext context = getContext();
|
||||||
|
final ZLTextParagraphCursor paragraphCursor = info.ParagraphCursor;
|
||||||
|
|
||||||
setTextStyle(info.StartStyle);
|
setTextStyle(info.StartStyle);
|
||||||
final int y = Math.min(context.getY() + info.Height, getTopMargin() + getTextAreaHeight());
|
final int y = Math.min(context.getY() + info.Height, getTextAreaHeight() + getTopMargin());
|
||||||
int spaceCounter = info.SpaceCounter;
|
int spaceCounter = info.SpaceCounter;
|
||||||
int fullCorrection = 0;
|
int fullCorrection = 0;
|
||||||
final boolean endOfParagraph = info.End.isEndOfParagraph();
|
final boolean endOfParagraph = info.isEndOfParagraph();
|
||||||
boolean wordOccurred = false;
|
boolean wordOccurred = false;
|
||||||
boolean changeStyle = true;
|
boolean changeStyle = true;
|
||||||
|
|
||||||
context.moveXTo(getLeftMargin() + info.LeftIndent);
|
context.moveXTo(getLeftMargin() + info.LeftIndent);
|
||||||
//System.out.println(context.getWidth() + " " + info.Width);
|
//System.out.println(context.getWidth() + " " + info.Width);
|
||||||
final int maxWidth = context.getWidth() - getLeftMargin() - getRightMargin();
|
final int maxWidth = context.getWidth() - getLeftMargin() - getRightMargin();
|
||||||
switch (myTextStyle.alignment()) {
|
switch (myTextStyle.getAlignment()) {
|
||||||
case ZLTextAlignmentType.ALIGN_RIGHT: {
|
case ZLTextAlignmentType.ALIGN_RIGHT: {
|
||||||
context.moveX(maxWidth - myTextStyle.rightIndent() - info.Width);
|
context.moveX(maxWidth - myTextStyle.getRightIndent() - info.Width);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ZLTextAlignmentType.ALIGN_CENTER: {
|
case ZLTextAlignmentType.ALIGN_CENTER: {
|
||||||
context.moveX((maxWidth - myTextStyle.rightIndent() - info.Width) / 2);
|
context.moveX((maxWidth - myTextStyle.getRightIndent() - info.Width) / 2);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ZLTextAlignmentType.ALIGN_JUSTIFY: {
|
case ZLTextAlignmentType.ALIGN_JUSTIFY: {
|
||||||
if (!endOfParagraph && !(info.End.getElement() == ZLTextElement.AfterParagraph)) {
|
if (!endOfParagraph && (paragraphCursor.getElement(info.EndWordNumber) != ZLTextElement.AfterParagraph)) {
|
||||||
fullCorrection = maxWidth - myTextStyle.rightIndent() - info.Width;
|
fullCorrection = maxWidth - myTextStyle.getRightIndent() - info.Width;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -537,12 +539,12 @@ public abstract class ZLTextViewImpl extends ZLTextView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final ZLTextParagraphCursor paragraph = info.RealStart.getParagraphCursor();
|
final ZLTextParagraphCursor paragraph = info.ParagraphCursor;
|
||||||
int paragraphNumber = paragraph.getIndex();
|
int paragraphNumber = paragraph.getIndex();
|
||||||
// System.out.println();
|
// System.out.println();
|
||||||
final int endWordNumber = info.End.getWordNumber();
|
final int endWordNumber = info.EndWordNumber;
|
||||||
int charNumber = info.RealStart.getCharNumber();
|
int charNumber = info.RealStartCharNumber;
|
||||||
for (int wordNumber = info.RealStart.getWordNumber(); wordNumber != endWordNumber; ++wordNumber, charNumber = 0) {
|
for (int wordNumber = info.RealStartWordNumber; wordNumber != endWordNumber; ++wordNumber, charNumber = 0) {
|
||||||
final ZLTextElement element = paragraph.getElement(wordNumber);
|
final ZLTextElement element = paragraph.getElement(wordNumber);
|
||||||
final int x = context.getX();
|
final int x = context.getX();
|
||||||
final int width = getElementWidth(element, charNumber);
|
final int width = getElementWidth(element, charNumber);
|
||||||
|
@ -576,15 +578,327 @@ public abstract class ZLTextViewImpl extends ZLTextView {
|
||||||
return "SampleView";
|
return "SampleView";
|
||||||
}
|
}
|
||||||
|
|
||||||
// TO BE DELETED
|
public void scrollPage(boolean forward, int scrollingMode, int value) {
|
||||||
public void scroll(int numberOfParagraphs) {
|
preparePaintInfo();
|
||||||
gotoParagraph(myStartParagraphNumber + numberOfParagraphs);
|
if (myPaintState == PaintState.READY) {
|
||||||
|
myPaintState = forward ? PaintState.TO_SCROLL_FORWARD : PaintState.TO_SCROLL_BACKWARD;
|
||||||
|
myScrollingMode = scrollingMode;
|
||||||
|
myOverlappingValue = value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void gotoPosition(int paragraphNumber, int wordNumber, int charNumber) {
|
||||||
|
// TODO: implement
|
||||||
|
int paragraphs = myModel.getParagraphsNumber();
|
||||||
|
int pn = Math.max(0, Math.min(paragraphNumber, paragraphs - 2));
|
||||||
|
myStartCursor.setCursor(ZLTextParagraphCursor.cursor(myModel, pn));
|
||||||
|
myStartCursor.moveTo(wordNumber, charNumber);
|
||||||
|
myEndCursor.reset();
|
||||||
|
myPaintState = PaintState.START_IS_KNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
public void gotoParagraph(int index) {
|
public void gotoParagraph(int index) {
|
||||||
// TODO: implement
|
// TODO: implement
|
||||||
myStartParagraphNumber = index;
|
myStartParagraphNumber = index;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
private int getViewWidth() {
|
||||||
|
return Math.max(getContext().getWidth() - getLeftMargin() - getRightMargin(), 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void preparePaintInfo() {
|
||||||
|
int newWidth = getViewWidth();
|
||||||
|
int newHeight = getTextAreaHeight();
|
||||||
|
if ((newWidth != myOldWidth) || (newHeight != myOldHeight)) {
|
||||||
|
myOldWidth = newWidth;
|
||||||
|
myOldHeight = newHeight;
|
||||||
|
rebuildPaintInfo(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((myPaintState == PaintState.NOTHING_TO_PAINT) || (myPaintState == PaintState.READY)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final ZLTextLineInfoVector infos = myLineInfos;
|
||||||
|
final int infosSize = infos.size();
|
||||||
|
final ZLTextLineInfoCache cache = myLineInfoCache;
|
||||||
|
for (int i = 0; i < infosSize; ++i) {
|
||||||
|
cache.put(infos.get(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (myPaintState) {
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
case PaintState.TO_SCROLL_FORWARD:
|
||||||
|
if (!myEndCursor.getParagraphCursor().isLast() || !myEndCursor.isEndOfParagraph()) {
|
||||||
|
final ZLTextWordCursor startCursor = new ZLTextWordCursor();
|
||||||
|
switch (myScrollingMode) {
|
||||||
|
case ScrollingMode.NO_OVERLAPPING:
|
||||||
|
break;
|
||||||
|
case ScrollingMode.KEEP_LINES:
|
||||||
|
findLineFromEnd(startCursor, myOverlappingValue);
|
||||||
|
break;
|
||||||
|
case ScrollingMode.SCROLL_LINES:
|
||||||
|
findLineFromStart(startCursor, myOverlappingValue);
|
||||||
|
if (startCursor.isEndOfParagraph()) {
|
||||||
|
startCursor.nextParagraph();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ScrollingMode.SCROLL_PERCENTAGE:
|
||||||
|
findPercentFromStart(startCursor, myOverlappingValue);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!startCursor.isNull() && startCursor.equalsToCursor(myStartCursor)) {
|
||||||
|
findLineFromStart(startCursor, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!startCursor.isNull()) {
|
||||||
|
final ZLTextWordCursor endCursor = new ZLTextWordCursor();
|
||||||
|
buildInfos(startCursor, endCursor);
|
||||||
|
if (!pageIsEmpty() && ((myScrollingMode != ScrollingMode.KEEP_LINES) || (!endCursor.equalsToCursor(myEndCursor)))) {
|
||||||
|
myStartCursor.setCursor(startCursor);
|
||||||
|
myEndCursor.setCursor(endCursor);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
myStartCursor.setCursor(myEndCursor);
|
||||||
|
buildInfos(myStartCursor, myEndCursor);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case PaintState.TO_SCROLL_BACKWARD:
|
||||||
|
if (!myStartCursor.getParagraphCursor().isFirst() || !myStartCursor.isStartOfParagraph()) {
|
||||||
|
switch (myScrollingMode) {
|
||||||
|
case ScrollingMode.NO_OVERLAPPING:
|
||||||
|
myStartCursor.setCursor(findStart(myStartCursor, SizeUnit.PIXEL_UNIT, getTextAreaHeight()));
|
||||||
|
break;
|
||||||
|
case ScrollingMode.KEEP_LINES:
|
||||||
|
{
|
||||||
|
ZLTextWordCursor endCursor = new ZLTextWordCursor();
|
||||||
|
findLineFromStart(endCursor, myOverlappingValue);
|
||||||
|
if (!endCursor.isNull() && endCursor.equalsToCursor(myEndCursor)) {
|
||||||
|
findLineFromEnd(endCursor, 1);
|
||||||
|
}
|
||||||
|
if (!endCursor.isNull()) {
|
||||||
|
ZLTextWordCursor startCursor = findStart(endCursor, SizeUnit.PIXEL_UNIT, getTextAreaHeight());
|
||||||
|
if (startCursor.equalsToCursor(myStartCursor)) {
|
||||||
|
myStartCursor.setCursor(findStart(myStartCursor, SizeUnit.PIXEL_UNIT, getTextAreaHeight()));
|
||||||
|
} else {
|
||||||
|
myStartCursor.setCursor(startCursor);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
myStartCursor.setCursor(findStart(myStartCursor, SizeUnit.PIXEL_UNIT, getTextAreaHeight()));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case ScrollingMode.SCROLL_LINES:
|
||||||
|
myStartCursor.setCursor(findStart(myStartCursor, SizeUnit.LINE_UNIT, myOverlappingValue));
|
||||||
|
break;
|
||||||
|
case ScrollingMode.SCROLL_PERCENTAGE:
|
||||||
|
myStartCursor.setCursor(findStart(myStartCursor, SizeUnit.PIXEL_UNIT, getTextAreaHeight() * myOverlappingValue / 100));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
buildInfos(myStartCursor, myEndCursor);
|
||||||
|
if (pageIsEmpty()) {
|
||||||
|
myStartCursor.setCursor(findStart(myStartCursor, SizeUnit.LINE_UNIT, 1));
|
||||||
|
buildInfos(myStartCursor, myEndCursor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case PaintState.START_IS_KNOWN:
|
||||||
|
buildInfos(myStartCursor, myEndCursor);
|
||||||
|
break;
|
||||||
|
case PaintState.END_IS_KNOWN:
|
||||||
|
myStartCursor.setCursor(findStart(myEndCursor, SizeUnit.PIXEL_UNIT, getTextAreaHeight()));
|
||||||
|
buildInfos(myStartCursor, myEndCursor);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
myPaintState = PaintState.READY;
|
||||||
|
myLineInfoCache.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean pageIsEmpty() {
|
||||||
|
final ZLTextLineInfoVector infos = myLineInfos;
|
||||||
|
final int infosSize = infos.size();
|
||||||
|
for (int i = 0; i < infosSize; ++i) {
|
||||||
|
if (infos.get(i).IsVisible) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void findLineFromStart(ZLTextWordCursor cursor, int overlappingValue) {
|
||||||
|
if (myLineInfos.isEmpty() || (overlappingValue == 0)) {
|
||||||
|
cursor.reset();
|
||||||
|
} else {
|
||||||
|
final ZLTextLineInfoVector infos = myLineInfos;
|
||||||
|
final int size = infos.size();
|
||||||
|
ZLTextLineInfo info = null;
|
||||||
|
for (int i = 0; i < size; ++i) {
|
||||||
|
info = infos.get(i);
|
||||||
|
if (info.IsVisible) {
|
||||||
|
--overlappingValue;
|
||||||
|
if (overlappingValue == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cursor.setCursor(info.ParagraphCursor);
|
||||||
|
cursor.moveTo(info.EndWordNumber, info.EndCharNumber);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void findLineFromEnd(ZLTextWordCursor cursor, int overlappingValue) {
|
||||||
|
if (myLineInfos.isEmpty() || (overlappingValue == 0)) {
|
||||||
|
cursor.reset();
|
||||||
|
} else {
|
||||||
|
final ZLTextLineInfoVector infos = myLineInfos;
|
||||||
|
final int size = infos.size();
|
||||||
|
ZLTextLineInfo info = null;
|
||||||
|
for (int i = size; i >= 0; --i) {
|
||||||
|
info = infos.get(i);
|
||||||
|
if (info.IsVisible) {
|
||||||
|
--overlappingValue;
|
||||||
|
if (overlappingValue == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cursor.setCursor(info.ParagraphCursor);
|
||||||
|
cursor.moveTo(info.StartWordNumber, info.StartCharNumber);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void findPercentFromStart(ZLTextWordCursor cursor, int percent) {
|
||||||
|
if (myLineInfos.isEmpty()) {
|
||||||
|
cursor.reset();
|
||||||
|
} else {
|
||||||
|
int height = getTextAreaHeight() * percent / 100;
|
||||||
|
boolean visibleLineOccured = false;
|
||||||
|
final ZLTextLineInfoVector infos = myLineInfos;
|
||||||
|
final int size = infos.size();
|
||||||
|
ZLTextLineInfo info = null;
|
||||||
|
for (int i = 0; i < size; ++i) {
|
||||||
|
info = infos.get(i);
|
||||||
|
if (info.IsVisible) {
|
||||||
|
visibleLineOccured = true;
|
||||||
|
}
|
||||||
|
height -= info.Height + info.Descent + info.VSpaceAfter;
|
||||||
|
if (visibleLineOccured && (height <= 0)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cursor.setCursor(info.ParagraphCursor);
|
||||||
|
cursor.moveTo(info.EndWordNumber, info.EndCharNumber);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clearCaches() {
|
||||||
|
rebuildPaintInfo(true);
|
||||||
|
ZLTextParagraphCursorCache.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void rebuildPaintInfo(boolean strong) {
|
||||||
|
if (myPaintState == PaintState.NOTHING_TO_PAINT) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
myLineInfos.clear();
|
||||||
|
if (!myStartCursor.isNull()) {
|
||||||
|
if (strong) {
|
||||||
|
myStartCursor.rebuild();
|
||||||
|
myLineInfoCache.clear();
|
||||||
|
}
|
||||||
|
myEndCursor.reset();
|
||||||
|
myPaintState = PaintState.START_IS_KNOWN;
|
||||||
|
} else if (!myEndCursor.isNull()) {
|
||||||
|
if (strong) {
|
||||||
|
myEndCursor.rebuild();
|
||||||
|
myLineInfoCache.clear();
|
||||||
|
}
|
||||||
|
myStartCursor.reset();
|
||||||
|
myPaintState = PaintState.END_IS_KNOWN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private int infoSize(ZLTextLineInfo info, int unit) {
|
||||||
|
return (unit == SizeUnit.PIXEL_UNIT) ? (info.Height + info.Descent + info.VSpaceAfter) : (info.IsVisible ? 1 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private int paragraphSize(ZLTextWordCursor cursor, boolean beforeCurrentPosition, int unit) {
|
||||||
|
final ZLPaintContext context = getContext();
|
||||||
|
final ZLTextParagraphCursor paragraphCursor = cursor.getParagraphCursor();
|
||||||
|
final int endWordNumber =
|
||||||
|
beforeCurrentPosition ? cursor.getWordNumber() : paragraphCursor.getParagraphLength();
|
||||||
|
|
||||||
|
resetTextStyle();
|
||||||
|
|
||||||
|
int size = 0;
|
||||||
|
|
||||||
|
int wordNumber = 0;
|
||||||
|
int charNumber = 0;
|
||||||
|
while (wordNumber != endWordNumber) {
|
||||||
|
ZLTextLineInfo info = processTextLine(context, paragraphCursor, wordNumber, charNumber, endWordNumber);
|
||||||
|
wordNumber = info.EndWordNumber;
|
||||||
|
charNumber = info.EndCharNumber;
|
||||||
|
size += infoSize(info, unit);
|
||||||
|
}
|
||||||
|
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void skip(ZLTextWordCursor cursor, int unit, int size) {
|
||||||
|
final ZLPaintContext context = getContext();
|
||||||
|
final ZLTextParagraphCursor paragraphCursor = cursor.getParagraphCursor();
|
||||||
|
final int endWordNumber = paragraphCursor.getParagraphLength();
|
||||||
|
|
||||||
|
resetTextStyle();
|
||||||
|
applyControls(paragraphCursor, 0, cursor.getWordNumber());
|
||||||
|
|
||||||
|
while (!cursor.isEndOfParagraph() && (size > 0)) {
|
||||||
|
ZLTextLineInfo info = processTextLine(context, paragraphCursor, cursor.getWordNumber(), cursor.getCharNumber(), endWordNumber);
|
||||||
|
cursor.moveTo(info.EndWordNumber, info.EndCharNumber);
|
||||||
|
size -= infoSize(info, unit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private ZLTextWordCursor findStart(ZLTextWordCursor end, int unit, int size) {
|
||||||
|
final ZLTextWordCursor start = new ZLTextWordCursor(end);
|
||||||
|
size -= paragraphSize(start, true, unit);
|
||||||
|
boolean positionChanged = !start.isStartOfParagraph();
|
||||||
|
start.moveToParagraphStart();
|
||||||
|
while (size > 0) {
|
||||||
|
if (positionChanged && start.getParagraphCursor().isEndOfSection()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (!start.previousParagraph()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (!start.getParagraphCursor().isEndOfSection()) {
|
||||||
|
positionChanged = true;
|
||||||
|
}
|
||||||
|
size -= paragraphSize(start, false, unit);
|
||||||
|
}
|
||||||
|
skip(start, unit, -size);
|
||||||
|
|
||||||
|
if (unit == SizeUnit.PIXEL_UNIT) {
|
||||||
|
boolean sameStart = start.equalsToCursor(end);
|
||||||
|
if (!sameStart && start.isEndOfParagraph() && end.isStartOfParagraph()) {
|
||||||
|
ZLTextWordCursor startCopy = start;
|
||||||
|
startCopy.nextParagraph();
|
||||||
|
sameStart = startCopy.equalsToCursor(end);
|
||||||
|
}
|
||||||
|
if (sameStart) {
|
||||||
|
start.setCursor(findStart(end, SizeUnit.LINE_UNIT, 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return start;
|
||||||
|
}
|
||||||
|
|
||||||
protected int paragraphIndexByCoordinate(int y) {
|
protected int paragraphIndexByCoordinate(int y) {
|
||||||
ZLTextElementArea area = ZLTextRectangularArea.binarySearch(myTextElementMap, y);
|
ZLTextElementArea area = ZLTextRectangularArea.binarySearch(myTextElementMap, y);
|
||||||
|
@ -598,24 +912,26 @@ public abstract class ZLTextViewImpl extends ZLTextView {
|
||||||
final int index = nodeArea.ParagraphNumber;
|
final int index = nodeArea.ParagraphNumber;
|
||||||
final ZLTextTreeParagraph paragraph = ((ZLTextTreeModel)myModel).getParagraph(index);
|
final ZLTextTreeParagraph paragraph = ((ZLTextTreeModel)myModel).getParagraph(index);
|
||||||
paragraph.open(!paragraph.isOpen());
|
paragraph.open(!paragraph.isOpen());
|
||||||
/*
|
|
||||||
rebuildPaintInfo(true);
|
rebuildPaintInfo(true);
|
||||||
preparePaintInfo();
|
preparePaintInfo();
|
||||||
if (paragraph->isOpen()) {
|
if (paragraph.isOpen()) {
|
||||||
int nextParagraphNumber = paragraphNumber + paragraph->fullSize();
|
int nextParagraphNumber = index + paragraph.getFullSize();
|
||||||
int lastParagraphNumber = endCursor().paragraphCursor().index();
|
int lastParagraphNumber = myEndCursor.getParagraphCursor().getIndex();
|
||||||
if (endCursor().isEndOfParagraph()) {
|
if (myEndCursor.isEndOfParagraph()) {
|
||||||
++lastParagraphNumber;
|
++lastParagraphNumber;
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
if (lastParagraphNumber < nextParagraphNumber) {
|
if (lastParagraphNumber < nextParagraphNumber) {
|
||||||
gotoParagraph(nextParagraphNumber, true);
|
gotoParagraph(nextParagraphNumber, true);
|
||||||
preparePaintInfo();
|
preparePaintInfo();
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
int firstParagraphNumber = startCursor().paragraphCursor().index();
|
int firstParagraphNumber = myStartCursor.getParagraphCursor().getIndex();
|
||||||
if (startCursor().isStartOfParagraph()) {
|
if (myStartCursor.isStartOfParagraph()) {
|
||||||
--firstParagraphNumber;
|
--firstParagraphNumber;
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
if (firstParagraphNumber >= paragraphNumber) {
|
if (firstParagraphNumber >= paragraphNumber) {
|
||||||
gotoParagraph(paragraphNumber);
|
gotoParagraph(paragraphNumber);
|
||||||
preparePaintInfo();
|
preparePaintInfo();
|
||||||
|
|
|
@ -22,10 +22,4 @@ final class ZLTextWord extends ZLTextElement {
|
||||||
}
|
}
|
||||||
return width;
|
return width;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
String getWord() {
|
|
||||||
return Data.substring(Offset, Offset + Length);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ package org.zlibrary.text.view.impl;
|
||||||
|
|
||||||
//import java.util.*;
|
//import java.util.*;
|
||||||
|
|
||||||
final class ZLTextWordCursor {
|
public final class ZLTextWordCursor {
|
||||||
private ZLTextParagraphCursor myParagraphCursor;
|
private ZLTextParagraphCursor myParagraphCursor;
|
||||||
private int myWordNumber;
|
private int myWordNumber;
|
||||||
private int myCharNumber;
|
private int myCharNumber;
|
||||||
|
@ -15,9 +15,7 @@ final class ZLTextWordCursor {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ZLTextWordCursor(ZLTextWordCursor cursor) {
|
public ZLTextWordCursor(ZLTextWordCursor cursor) {
|
||||||
myParagraphCursor = cursor.myParagraphCursor;
|
setCursor(cursor);
|
||||||
myWordNumber = cursor.myWordNumber;
|
|
||||||
myCharNumber = cursor.myCharNumber;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCursor(ZLTextWordCursor cursor) {
|
public void setCursor(ZLTextWordCursor cursor) {
|
||||||
|
@ -26,23 +24,22 @@ final class ZLTextWordCursor {
|
||||||
myCharNumber = cursor.myCharNumber;
|
myCharNumber = cursor.myCharNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ZLTextWordCursor(ZLTextParagraphCursor paragraphCursor) {
|
||||||
|
setCursor(paragraphCursor);
|
||||||
|
}
|
||||||
|
|
||||||
public void setCursor(ZLTextParagraphCursor paragraphCursor) {
|
public void setCursor(ZLTextParagraphCursor paragraphCursor) {
|
||||||
|
myParagraphCursor = paragraphCursor;
|
||||||
myWordNumber = 0;
|
myWordNumber = 0;
|
||||||
myCharNumber = 0;
|
myCharNumber = 0;
|
||||||
myParagraphCursor = paragraphCursor;
|
|
||||||
moveToParagraphStart();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isNull() {
|
public boolean isNull() {
|
||||||
return myParagraphCursor.isNull();
|
return myParagraphCursor == null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean equalWordNumber(ZLTextWordCursor cursor) {
|
public boolean equalsToCursor(ZLTextWordCursor cursor) {
|
||||||
return myWordNumber == cursor.myWordNumber;
|
return (myWordNumber == cursor.myWordNumber) && (myCharNumber == cursor.myCharNumber) && (myParagraphCursor.getIndex() == cursor.myParagraphCursor.getIndex());
|
||||||
}
|
|
||||||
|
|
||||||
public boolean sameElementAs(ZLTextWordCursor cursor) {
|
|
||||||
return (myWordNumber == cursor.myWordNumber && myParagraphCursor.getIndex() == cursor.myParagraphCursor.getIndex());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isStartOfParagraph() {
|
public boolean isStartOfParagraph() {
|
||||||
|
@ -97,6 +94,7 @@ final class ZLTextWordCursor {
|
||||||
if (!myParagraphCursor.isFirst()) {
|
if (!myParagraphCursor.isFirst()) {
|
||||||
myParagraphCursor = myParagraphCursor.previous();
|
myParagraphCursor = myParagraphCursor.previous();
|
||||||
moveToParagraphStart();
|
moveToParagraphStart();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -159,6 +157,12 @@ final class ZLTextWordCursor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void reset() {
|
||||||
|
myParagraphCursor = null;
|
||||||
|
myWordNumber = 0;
|
||||||
|
myCharNumber = 0;
|
||||||
|
}
|
||||||
|
|
||||||
public void rebuild() {
|
public void rebuild() {
|
||||||
if (!isNull()) {
|
if (!isNull()) {
|
||||||
myParagraphCursor.clear();
|
myParagraphCursor.clear();
|
||||||
|
|
|
@ -27,28 +27,24 @@ public class ZLTextBaseStyle implements ZLTextStyle {
|
||||||
public final ZLColorOption TreeLinesColorOption =
|
public final ZLColorOption TreeLinesColorOption =
|
||||||
new ZLColorOption(CATEGORY, COLORS, "TreeLines", new ZLColor(127, 127, 127));
|
new ZLColorOption(CATEGORY, COLORS, "TreeLines", new ZLColor(127, 127, 127));
|
||||||
|
|
||||||
public ZLBooleanOption AutoHyphenationOption;
|
public final ZLBooleanOption AutoHyphenationOption =
|
||||||
|
new ZLBooleanOption(CATEGORY, OPTIONS, "AutoHyphenation", true);
|
||||||
|
|
||||||
|
public final ZLBooleanOption BoldOption =
|
||||||
|
new ZLBooleanOption(CATEGORY, GROUP, "Base:bold", false);
|
||||||
|
public final ZLBooleanOption ItalicOption =
|
||||||
|
new ZLBooleanOption(CATEGORY, GROUP, "Base:italic", false);
|
||||||
|
public final ZLIntegerOption AlignmentOption =
|
||||||
|
new ZLIntegerOption(CATEGORY, GROUP, "Base:alignment", ZLTextAlignmentType.ALIGN_JUSTIFY);
|
||||||
|
public final ZLDoubleOption LineSpaceOption =
|
||||||
|
new ZLDoubleOption(CATEGORY, GROUP, "Base:lineSpacing", 1.2);
|
||||||
|
|
||||||
public final ZLStringOption FontFamilyOption;
|
public final ZLStringOption FontFamilyOption;
|
||||||
public final ZLIntegerRangeOption FontSizeOption;
|
public final ZLIntegerRangeOption FontSizeOption;
|
||||||
public ZLBooleanOption BoldOption;
|
|
||||||
public ZLBooleanOption ItalicOption;
|
|
||||||
public final ZLIntegerOption AlignmentOption;
|
|
||||||
public final ZLDoubleOption LineSpaceOption;
|
|
||||||
|
|
||||||
public ZLTextBaseStyle(String fontFamily, int fontSize) {
|
public ZLTextBaseStyle(String fontFamily, int fontSize) {
|
||||||
//TODO
|
FontFamilyOption = new ZLStringOption(CATEGORY, GROUP, "Base:fontFamily", fontFamily);
|
||||||
/*
|
FontSizeOption = new ZLIntegerRangeOption(CATEGORY, GROUP, "Base:fontSize", 0, 72, fontSize);
|
||||||
AutoHyphenationOption = new ZLBooleanOption(ZLOption.LOOK_AND_FEEL_CATEGORY, OPTIONS, "AutoHyphenation", true);
|
|
||||||
|
|
||||||
BoldOption = new ZLBooleanOption(ZLOption.LOOK_AND_FEEL_CATEGORY, GROUP, "Base:bold", false);
|
|
||||||
ItalicOption = new ZLBooleanOption(ZLOption.LOOK_AND_FEEL_CATEGORY, GROUP, "Base:italic", false);
|
|
||||||
*/
|
|
||||||
final String category = ZLOption.LOOK_AND_FEEL_CATEGORY;
|
|
||||||
AlignmentOption = new ZLIntegerOption(category, GROUP, "Base:alignment", ZLTextAlignmentType.ALIGN_JUSTIFY);
|
|
||||||
LineSpaceOption = new ZLDoubleOption(category, GROUP, "Base:lineSpacing", 1.2);
|
|
||||||
FontFamilyOption = new ZLStringOption(category, GROUP, "Base:fontFamily", fontFamily);
|
|
||||||
FontSizeOption = new ZLIntegerRangeOption(category, GROUP, "Base:fontSize", 0, 72, fontSize);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFontFamily() {
|
public String getFontFamily() {
|
||||||
|
@ -63,47 +59,47 @@ public class ZLTextBaseStyle implements ZLTextStyle {
|
||||||
return RegularTextColorOption.getValue();
|
return RegularTextColorOption.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean bold() {
|
public boolean isBold() {
|
||||||
return false;
|
return BoldOption.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean italic() {
|
public boolean isItalic() {
|
||||||
return false;
|
return ItalicOption.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int leftIndent() {
|
public int getLeftIndent() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int rightIndent() {
|
public int getRightIndent() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int firstLineIndentDelta() {
|
public int getFirstLineIndentDelta() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double lineSpace() {
|
public double getLineSpace() {
|
||||||
return LineSpaceOption.getValue();
|
return LineSpaceOption.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int verticalShift() {
|
public int getVerticalShift() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int spaceBefore() {
|
public int getSpaceBefore() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int spaceAfter() {
|
public int getSpaceAfter() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDecorated() {
|
public byte getAlignment() {
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte alignment() {
|
|
||||||
return (byte)AlignmentOption.getValue();
|
return (byte)AlignmentOption.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ZLTextStyle getBase() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,10 +11,6 @@ public class ZLTextDecoratedStyle {
|
||||||
myBase = base;
|
myBase = base;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDecorated() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ZLTextStyle getBase() {
|
public ZLTextStyle getBase() {
|
||||||
return myBase;
|
return myBase;
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,59 +35,59 @@ public class ZLTextFullDecoratedStyle extends ZLTextDecoratedStyle implements ZL
|
||||||
return getBase().getFontSize() + myDecoration.FontSizeDeltaOption.getValue();
|
return getBase().getFontSize() + myDecoration.FontSizeDeltaOption.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean bold() {
|
public boolean isBold() {
|
||||||
switch (myDecoration.BoldOption.getValue()) {
|
switch (myDecoration.BoldOption.getValue()) {
|
||||||
case ZLBoolean3.B3_TRUE:
|
case ZLBoolean3.B3_TRUE:
|
||||||
return true;
|
return true;
|
||||||
case ZLBoolean3.B3_FALSE:
|
case ZLBoolean3.B3_FALSE:
|
||||||
return false;
|
return false;
|
||||||
default:
|
default:
|
||||||
return getBase().bold();
|
return getBase().isBold();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean italic() {
|
public boolean isItalic() {
|
||||||
switch (myDecoration.ItalicOption.getValue()) {
|
switch (myDecoration.ItalicOption.getValue()) {
|
||||||
case ZLBoolean3.B3_TRUE:
|
case ZLBoolean3.B3_TRUE:
|
||||||
return true;
|
return true;
|
||||||
case ZLBoolean3.B3_FALSE:
|
case ZLBoolean3.B3_FALSE:
|
||||||
return false;
|
return false;
|
||||||
default:
|
default:
|
||||||
return getBase().italic();
|
return getBase().isItalic();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int leftIndent() {
|
public int getLeftIndent() {
|
||||||
return getBase().leftIndent() + myDecoration.LeftIndentOption.getValue();
|
return getBase().getLeftIndent() + myDecoration.LeftIndentOption.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int rightIndent() {
|
public int getRightIndent() {
|
||||||
return getBase().rightIndent() + myDecoration.RightIndentOption.getValue();
|
return getBase().getRightIndent() + myDecoration.RightIndentOption.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int firstLineIndentDelta() {
|
public int getFirstLineIndentDelta() {
|
||||||
return (alignment() == ZLTextAlignmentType.ALIGN_CENTER) ? 0 : getBase().firstLineIndentDelta() + myDecoration.FirstLineIndentDeltaOption.getValue();
|
return (getAlignment() == ZLTextAlignmentType.ALIGN_CENTER) ? 0 : getBase().getFirstLineIndentDelta() + myDecoration.FirstLineIndentDeltaOption.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
public double lineSpace() {
|
public double getLineSpace() {
|
||||||
double value = myDecoration.LineSpaceOption.getValue();
|
double value = myDecoration.LineSpaceOption.getValue();
|
||||||
return (value != 0.0) ? value : getBase().lineSpace();
|
return (value != 0.0) ? value : getBase().getLineSpace();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int verticalShift() {
|
public int getVerticalShift() {
|
||||||
return getBase().verticalShift() + myDecoration.VerticalShiftOption.getValue();
|
return getBase().getVerticalShift() + myDecoration.VerticalShiftOption.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int spaceBefore() {
|
public int getSpaceBefore() {
|
||||||
return 0;
|
return myDecoration.SpaceBeforeOption.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int spaceAfter() {
|
public int getSpaceAfter() {
|
||||||
return 0;
|
return myDecoration.SpaceAfterOption.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte alignment() {
|
public byte getAlignment() {
|
||||||
byte value = (byte)myDecoration.AlignmentOption.getValue();
|
byte value = (byte)myDecoration.AlignmentOption.getValue();
|
||||||
return (value == ZLTextAlignmentType.ALIGN_UNDEFINED) ? getBase().alignment() : value;
|
return (value == ZLTextAlignmentType.ALIGN_UNDEFINED) ? getBase().getAlignment() : value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,57 +36,57 @@ class ZLTextPartialDecoratedStyle extends ZLTextDecoratedStyle implements ZLText
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean bold() {
|
public boolean isBold() {
|
||||||
switch (myDecoration.BoldOption.getValue()) {
|
switch (myDecoration.BoldOption.getValue()) {
|
||||||
case ZLBoolean3.B3_TRUE:
|
case ZLBoolean3.B3_TRUE:
|
||||||
return true;
|
return true;
|
||||||
case ZLBoolean3.B3_FALSE:
|
case ZLBoolean3.B3_FALSE:
|
||||||
return false;
|
return false;
|
||||||
default:
|
default:
|
||||||
return getBase().bold();
|
return getBase().isBold();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean italic() {
|
public boolean isItalic() {
|
||||||
switch (myDecoration.ItalicOption.getValue()) {
|
switch (myDecoration.ItalicOption.getValue()) {
|
||||||
case ZLBoolean3.B3_TRUE:
|
case ZLBoolean3.B3_TRUE:
|
||||||
return true;
|
return true;
|
||||||
case ZLBoolean3.B3_FALSE:
|
case ZLBoolean3.B3_FALSE:
|
||||||
return false;
|
return false;
|
||||||
default:
|
default:
|
||||||
return getBase().italic();
|
return getBase().isItalic();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int leftIndent() {
|
public int getLeftIndent() {
|
||||||
return getBase().leftIndent();
|
return getBase().getLeftIndent();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int rightIndent() {
|
public int getRightIndent() {
|
||||||
return getBase().rightIndent();
|
return getBase().getRightIndent();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int firstLineIndentDelta() {
|
public int getFirstLineIndentDelta() {
|
||||||
return getBase().firstLineIndentDelta();
|
return getBase().getFirstLineIndentDelta();
|
||||||
}
|
}
|
||||||
|
|
||||||
public double lineSpace() {
|
public double getLineSpace() {
|
||||||
return getBase().lineSpace();
|
return getBase().getLineSpace();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int verticalShift() {
|
public int getVerticalShift() {
|
||||||
return getBase().verticalShift() + myDecoration.VerticalShiftOption.getValue();
|
return getBase().getVerticalShift() + myDecoration.VerticalShiftOption.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int spaceBefore() {
|
public int getSpaceBefore() {
|
||||||
return 0;
|
return getBase().getSpaceBefore();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int spaceAfter() {
|
public int getSpaceAfter() {
|
||||||
return 0;
|
return getBase().getSpaceAfter();
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte alignment() {
|
public byte getAlignment() {
|
||||||
return getBase().alignment();
|
return getBase().getAlignment();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package org.zlibrary.text.view.style;
|
package org.zlibrary.text.view.style;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.zlibrary.core.util.ZLBoolean3;
|
import org.zlibrary.core.util.ZLBoolean3;
|
||||||
import org.zlibrary.core.xml.ZLXMLReader;
|
import org.zlibrary.core.xml.ZLXMLReader;
|
||||||
import org.zlibrary.text.model.ZLTextAlignmentType;
|
import org.zlibrary.text.model.ZLTextAlignmentType;
|
||||||
|
@ -51,9 +49,9 @@ public class ZLTextStyleCollection {
|
||||||
private static class TextStyleReader extends ZLXMLReader {
|
private static class TextStyleReader extends ZLXMLReader {
|
||||||
private ZLTextStyleCollection myCollection;
|
private ZLTextStyleCollection myCollection;
|
||||||
|
|
||||||
private static int intValue(Map<String,String> attributes, String name) {
|
private static int intValue(StringMap attributes, String name) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
String value = attributes.get(name);
|
String value = attributes.getValue(name);
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
try {
|
try {
|
||||||
i = Integer.parseInt(value);
|
i = Integer.parseInt(value);
|
||||||
|
@ -64,9 +62,9 @@ public class ZLTextStyleCollection {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static double doubleValue(Map<String,String> attributes, String name) {
|
private static double doubleValue(StringMap attributes, String name) {
|
||||||
double d = 0;
|
double d = 0;
|
||||||
String value = attributes.get(name);
|
String value = attributes.getValue(name);
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
try {
|
try {
|
||||||
d = Double.parseDouble(value);
|
d = Double.parseDouble(value);
|
||||||
|
@ -77,27 +75,27 @@ public class ZLTextStyleCollection {
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean booleanValue(Map<String,String> attributes, String name) {
|
private static boolean booleanValue(StringMap attributes, String name) {
|
||||||
return "true".equals(attributes.get(name));
|
return "true".equals(attributes.getValue(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int b3Value(Map<String,String> attributes, String name) {
|
private static int b3Value(StringMap attributes, String name) {
|
||||||
return ZLBoolean3.getByString(attributes.get(name));
|
return ZLBoolean3.getByString(attributes.getValue(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
public TextStyleReader(ZLTextStyleCollection collection) {
|
public TextStyleReader(ZLTextStyleCollection collection) {
|
||||||
myCollection = collection;
|
myCollection = collection;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startElementHandler(String tag, Map<String,String> attributes) {
|
public void startElementHandler(String tag, StringMap attributes) {
|
||||||
final String BASE = "base";
|
final String BASE = "base";
|
||||||
final String STYLE = "style";
|
final String STYLE = "style";
|
||||||
|
|
||||||
if (BASE.equals(tag)) {
|
if (BASE.equals(tag)) {
|
||||||
myCollection.myBaseStyle = new ZLTextBaseStyle(attributes.get("family"), intValue(attributes, "fontSize"));
|
myCollection.myBaseStyle = new ZLTextBaseStyle(attributes.getValue("family"), intValue(attributes, "fontSize"));
|
||||||
} else if (STYLE.equals(tag)) {
|
} else if (STYLE.equals(tag)) {
|
||||||
String idString = attributes.get("id");
|
String idString = attributes.getValue("id");
|
||||||
String name = attributes.get("name");
|
String name = attributes.getValue("name");
|
||||||
if ((idString != null) && (name != null)) {
|
if ((idString != null) && (name != null)) {
|
||||||
byte id = Byte.parseByte(idString);
|
byte id = Byte.parseByte(idString);
|
||||||
ZLTextStyleDecoration decoration;
|
ZLTextStyleDecoration decoration;
|
||||||
|
@ -108,7 +106,7 @@ public class ZLTextStyleCollection {
|
||||||
int verticalShift = intValue(attributes, "vShift");
|
int verticalShift = intValue(attributes, "vShift");
|
||||||
int allowHyphenations = b3Value(attributes, "allowHyphenations");
|
int allowHyphenations = b3Value(attributes, "allowHyphenations");
|
||||||
byte hyperlinkStyle = HyperlinkStyle.NONE;
|
byte hyperlinkStyle = HyperlinkStyle.NONE;
|
||||||
String hyperlink = attributes.get("hyperlink");
|
String hyperlink = attributes.getValue("hyperlink");
|
||||||
if (hyperlink != null) {
|
if (hyperlink != null) {
|
||||||
if ("internal".equals(hyperlink)) {
|
if ("internal".equals(hyperlink)) {
|
||||||
hyperlinkStyle = HyperlinkStyle.INTERNAL;
|
hyperlinkStyle = HyperlinkStyle.INTERNAL;
|
||||||
|
@ -128,7 +126,7 @@ public class ZLTextStyleCollection {
|
||||||
int firstLineIndentDelta = intValue(attributes, "firstLineIndentDelta");
|
int firstLineIndentDelta = intValue(attributes, "firstLineIndentDelta");
|
||||||
|
|
||||||
byte alignment = ZLTextAlignmentType.ALIGN_UNDEFINED;
|
byte alignment = ZLTextAlignmentType.ALIGN_UNDEFINED;
|
||||||
String alignmentString = attributes.get("alignment");
|
String alignmentString = attributes.getValue("alignment");
|
||||||
if (alignmentString != null) {
|
if (alignmentString != null) {
|
||||||
if (alignmentString.equals("left")) {
|
if (alignmentString.equals("left")) {
|
||||||
alignment = ZLTextAlignmentType.ALIGN_LEFT;
|
alignment = ZLTextAlignmentType.ALIGN_LEFT;
|
||||||
|
@ -146,7 +144,7 @@ public class ZLTextStyleCollection {
|
||||||
}
|
}
|
||||||
decoration.setHyperlinkStyle(hyperlinkStyle);
|
decoration.setHyperlinkStyle(hyperlinkStyle);
|
||||||
|
|
||||||
String fontFamily = attributes.get("family");
|
String fontFamily = attributes.getValue("family");
|
||||||
if (fontFamily != null) {
|
if (fontFamily != null) {
|
||||||
decoration.FontFamilyOption.setValue(fontFamily);
|
decoration.FontFamilyOption.setValue(fontFamily);
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ public final class ZLAndroidApplicationWindow extends ZLApplicationWindow {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void buildMenu(Menu menu) {
|
public void buildMenu(Menu menu) {
|
||||||
new MenuBuilder(menu).processMenu(getApplication().getMenubar());
|
new MenuBuilder(menu).processMenu(getApplication());
|
||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,10 @@ import org.zlibrary.core.application.ZLApplication;
|
||||||
import org.zlibrary.ui.android.util.ZLAndroidKeyUtil;
|
import org.zlibrary.ui.android.util.ZLAndroidKeyUtil;
|
||||||
|
|
||||||
public class ZLAndroidActivity extends Activity {
|
public class ZLAndroidActivity extends Activity {
|
||||||
|
public static long StartTime;
|
||||||
|
|
||||||
public void onCreate(Bundle icicle) {
|
public void onCreate(Bundle icicle) {
|
||||||
|
StartTime = System.currentTimeMillis();
|
||||||
super.onCreate(icicle);
|
super.onCreate(icicle);
|
||||||
new ZLAndroidLibrary().run(this);
|
new ZLAndroidLibrary().run(this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,10 +7,9 @@ import android.content.Resources;
|
||||||
import org.zlibrary.core.library.ZLibrary;
|
import org.zlibrary.core.library.ZLibrary;
|
||||||
import org.zlibrary.core.application.ZLApplication;
|
import org.zlibrary.core.application.ZLApplication;
|
||||||
|
|
||||||
|
//import org.zlibrary.core.xml.sax.ZLSaxXMLProcessorFactory;
|
||||||
import org.zlibrary.core.xml.own.ZLOwnXMLProcessorFactory;
|
import org.zlibrary.core.xml.own.ZLOwnXMLProcessorFactory;
|
||||||
import org.zlibrary.core.xml.sax.ZLSaxXMLProcessorFactory;
|
import org.zlibrary.ui.android.sqliteconfig.ZLSQLiteConfigManager;
|
||||||
//import org.zlibrary.options.config.reader.ZLConfigReaderFactory;
|
|
||||||
//import org.zlibrary.options.config.writer.ZLConfigWriterFactory;
|
|
||||||
|
|
||||||
import org.zlibrary.ui.android.view.ZLAndroidPaintContext;
|
import org.zlibrary.ui.android.view.ZLAndroidPaintContext;
|
||||||
import org.zlibrary.ui.android.view.ZLAndroidWidget;
|
import org.zlibrary.ui.android.view.ZLAndroidWidget;
|
||||||
|
@ -49,14 +48,8 @@ public final class ZLAndroidLibrary extends ZLibrary {
|
||||||
return myActivity.getResources().openRawResource(resourceId);
|
return myActivity.getResources().openRawResource(resourceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
private static String configDirectory() {
|
|
||||||
return System.getProperty("user.home") + "/." + getInstance().getApplicationName();
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
public static void shutdown() {
|
public static void shutdown() {
|
||||||
//ZLConfigWriterFactory.createConfigWriter(configDirectory()).write();
|
ZLSQLiteConfigManager.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void finish() {
|
public void finish() {
|
||||||
|
@ -69,12 +62,12 @@ public final class ZLAndroidLibrary extends ZLibrary {
|
||||||
void run(ZLAndroidActivity activity) {
|
void run(ZLAndroidActivity activity) {
|
||||||
myActivity = activity;
|
myActivity = activity;
|
||||||
|
|
||||||
new ZLOwnXMLProcessorFactory();
|
|
||||||
//new ZLSaxXMLProcessorFactory();
|
//new ZLSaxXMLProcessorFactory();
|
||||||
|
new ZLOwnXMLProcessorFactory();
|
||||||
|
new ZLSQLiteConfigManager();
|
||||||
loadProperties();
|
loadProperties();
|
||||||
|
|
||||||
myActivity.setContentView(R.layout.main);
|
activity.setContentView(R.layout.main);
|
||||||
//ZLConfigReaderFactory.createConfigReader(configDirectory()).read();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ZLApplication application = (ZLApplication)getApplicationClass().newInstance();
|
ZLApplication application = (ZLApplication)getApplicationClass().newInstance();
|
||||||
|
|
22
src/org/zlibrary/ui/android/sqliteconfig/ZLSQLiteConfig.java
Normal file
22
src/org/zlibrary/ui/android/sqliteconfig/ZLSQLiteConfig.java
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
package org.zlibrary.ui.android.sqliteconfig;
|
||||||
|
|
||||||
|
import org.zlibrary.core.config.ZLConfig;
|
||||||
|
|
||||||
|
class ZLSQLiteConfig implements ZLConfig {
|
||||||
|
public void removeGroup(String name) {
|
||||||
|
// TODO: implement
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValue(String group, String name, String defaultValue) {
|
||||||
|
// TODO: implement
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValue(String group, String name, String value, String category) {
|
||||||
|
// TODO: implement
|
||||||
|
}
|
||||||
|
|
||||||
|
public void unsetValue(String group, String name) {
|
||||||
|
// TODO: implement
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
package org.zlibrary.ui.android.sqliteconfig;
|
||||||
|
|
||||||
|
import org.zlibrary.core.config.ZLConfig;
|
||||||
|
import org.zlibrary.core.config.ZLConfigManager;
|
||||||
|
|
||||||
|
public class ZLSQLiteConfigManager extends ZLConfigManager {
|
||||||
|
public ZLSQLiteConfigManager() {
|
||||||
|
setConfig(new ZLSQLiteConfig());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void shutdown() {
|
||||||
|
saveAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void saveAll() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void saveDelta() {
|
||||||
|
}
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue