first commit

This commit is contained in:
MaddoScientisto 2026-03-14 20:04:39 +01:00
commit 4d332ef662
27586 changed files with 3281783 additions and 0 deletions

View file

@ -0,0 +1,5 @@
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.7.1
Created-By: 11.0-b15 (Sun Microsystems Inc.)
Main-Class: jxl.demo.Demo

View file

@ -0,0 +1,293 @@
# The default names (the English) for all function names in java
abs=ABS
absref=ABSREF
acos=ACOS
acosh=ACOSH
address=ADDRESS
and=AND
areas=AREAS
argument=ARGUMENT
asc=ASC
asin=ASIN
asinh=ASINH
atan=ATAN
atan2=ATAN2
atanh=ATANH
avedev=AVEDEV
average=AVERAGE
averagea=AVERAGEA
betadist=BETADIST
betainv=BETAINV
binomdist=BINOMDIST
call=CALL
caller=CALLER
ceiling=CEILING
cell=CELL
char=CHAR
chidist=CHIDIST
chiinv=CHIINV
chitest=CHITEST
choose=CHOOSE
clean=CLEAN
code=CODE
column=COLUMN
columns=COLUMNS
combin=COMBIN
concatenate=CONCATENATE
confidence=CONFIDENCE
correl=CORREL
cos=COS
cosh=COSH
count=COUNT
counta=COUNTA
countblank=COUNTBLANK
countif=COUNTIF
covar=COVAR
critbinom=CRITBINOM
date=DATE
datedif=DATEDIF
datestring=DATESTRING
datevalue=DATEVALUE
daverage=DAVERAGE
day=DAY
days360=DAYS360
db=DB
dbcs=DBCS
dcount=DCOUNT
dcounta=DCOUNTA
ddb=DDB
degrees=DEGREES
deref=DEREF
devsq=DEVSQ
dget=DGET
directory=DIRECTORY
dmax=DMAX
dmin=DMIN
documents=DOCUMENTS
dollar=DOLLAR
dproduct=DPRODUCT
dstdev=DSTDEV
dstdevp=DSTDEVP
dsum=DSUM
dvar=DVAR
dvarp=DVARP
echo=ECHO
error=ERROR
evaluate=EVALUATE
even=EVEN
exact=EXACT
exec=EXEC
execute=EXECUTE
exp=EXP
expondist=EXPONDIST
fact=FACT
fclose=FCLOSE
fdist=FDIST
files=FILES
find=FIND
findb=FINDB
finv=FINV
fisher=FISHER
fisherinv=FISHERINV
fixed=FIXED
floor=FLOOR
fopen=FOPEN
forecast=FORECAST
fpos=FPOS
fread=FREAD
freadln=FREADLN
frequency=FREQUENCY
fsize=FSIZE
ftest=FTEST
fv=FV
fwrite=FWRITE
fwriteln=FWRITELN
gammadist=GAMMADIST
gammainv=GAMMAINV
gammaln=GAMMALN
geomean=GEOMEAN
goto=GOTO
group=GROUP
growth=GROWTH
halt=HALT
harmean=HARMEAN
help=HELP
hlookup=HLOOKUP
hour=HOUR
hyperlink=HYPERLINK
hypgeomdist=HYPGEOMDIST
if=IF
index=INDEX
indirect=INDIRECT
info=INFO
initiate=INITIATE
input=INPUT
int=INT
intercept=INTERCEPT
ipmt=IPMT
irr=IRR
isblank=ISBLANK
iserr=ISERR
iserror=ISERROR
islogical=ISLOGICAL
isna=ISNA
isnontext=ISNONTEXT
isnumber=ISNUMBER
ispmt=ISPMT
isref=ISREF
istext=ISTEXT
kurt=KURT
large=LARGE
left=LEFT
leftb=LEFTB
len=LEN
lenb=LENB
linest=LINEST
links=LINKS
ln=LN
log=LOG
log10=LOG10
logest=LOGEST
loginv=LOGINV
lognormdist=LOGNORMDIST
lookup=LOOKUP
lower=LOWER
match=MATCH
max=MAX
maxa=MAXA
mdeterm=MDETERM
median=MEDIAN
mid=MID
midb=MIDB
min=MIN
mina=MINA
minute=MINUTE
minverse=MINVERSE
mirr=MIRR
mmult=MMULT
mod=MOD
mode=MODE
month=MONTH
n=N
na=NA
names=NAMES
negbinomdist=NEGBINOMDIST
normdist=NORMDIST
norminv=NORMINV
normsdist=NORMSDIST
normsinv=NORMSINV
not=NOT
note=NOTE
now=NOW
nper=NPER
npv=NPV
numberstring=NUMBERSTRING
odd=ODD
offset=OFFSET
or=OR
pause=PAUSE
pearson=PEARSON
percentile=PERCENTILE
percentrank=PERCENTRANK
permut=PERMUT
pi=PI
pmt=PMT
poisson=POISSON
poke=POKE
power=POWER
ppmt=PPMT
prob=PROB
product=PRODUCT
proper=PROPER
pv=PV
quartile=QUARTILE
radians=RADIANS
rand=RAND
rank=RANK
rate=RATE
reftext=REFTEXT
register=REGISTER
relref=RELREF
replace=REPLACE
replaceb=REPLACEB
rept=REPT
request=REQUEST
restart=RESTART
result=RESULT
resume=RESUME
right=RIGHT
rightb=RIGHTB
roman=ROMAN
round=ROUND
rounddown=ROUNDDOWN
roundup=ROUNDUP
row=ROW
rows=ROWS
rsq=RSQ
search=SEARCH
searchb=SEARCHB
second=SECOND
selection=SELECTION
series=SERIES
sign=SIGN
sin=SIN
sinh=SINH
skew=SKEW
sln=SLN
slope=SLOPE
small=SMALL
sqrt=SQRT
standardize=STANDARDIZE
stdev=STDEV
stdeva=STDDEVA
stdevp=STDEVP
stdevpa=STDDEVPA
step=STEP
steyx=STEYX
substitute=SUBSTITUTE
subtotal=SUBTOTAL
sum=SUM
sumif=SUMIF
sumproduct=SUMPRODUCT
sumsq=SUMSQ
sumx2my2=SUMX2MY2
sumx2py2=SUMX2PY2
sumxmy2=SUMXMY2
syd=SYD
t=T
tan=TAN
tanh=TANH
tdist=TDIST
terminate=TERMINATE
text=TEXT
textref=TEXTREF
time=TIME
timevalue=TIMEVALUE
tinv=TINV
today=TODAY
transpose=TRANSPOSE
trend=TREND
trim=TRIM
trimmean=TRIMMEAN
trunc=TRUNC
ttest=TTEST
type=TYPE
unregister=UNREGISTER
upper=UPPER
usdollar=USDOLLAR
value=VALUE
var=VAR
vara=VARA
varp=VARP
varpa=VARPA
vdb=VDB
vlookup=VLOOKUP
volatile=VOLATILE
weekday=WEEKDAY
weibull=WEIBULL
windows=WINDOWS
year=YEAR
ztest=ZTEST
false=FALSE
true=TRUE

View file

@ -0,0 +1,54 @@
# The default names in Danish
abs=ABS
acos=ARCCOS
acosh=ARCCOSH
address=ADRESSE
and=OG
areas=OMRÅDER
asin=ARCSIN
asinh=ARCSINH
atan=ARCTAN
atan2=ARCTAN2
atanh=ARCTANH
average=MIDDEL
averagea=AVERAGEA
betadist=BETAFORDELING
betainv=BETAINV
binomdist=BINOMIALFORDELING
ceiling=AFRUND.LOFT
cell=CELLE
char=TEGN
chidist=CHIFORDELING
chiinv=CHIINV
chitest=CHITEST
choose=VÆLG
clean=RENS
code=KODE
column=KOLONNE
columns=KOLONNER
concatenate=SAMMENKÆDNING
confidence=KONFIDENSINTERVAL
cos=COS
cosh=COSH
count=TÆL
countblank=ANTAL.BLANKE
countif=TÆL.HVIS
covar=KOVARIANS
critbinom=KRITBINOM
date=DATO
datevalue=DATOVÆRDI
day=DAG
days360=DAGE360
db=DB
degrees=GRADER
dmax=DMAKS
dmin=DMIN
documents=DOCUMENTS
false=FALSK
if=HVIS
not=IKKE
or=ELLER
sum=SUM
true=SAND
year=ÅR

View file

@ -0,0 +1,308 @@
# The function names in German
abs=ABS
absref=ABSPOS
acos=ARCCOS
acosh=ARCCOSHYP
address=ADRESSE
and=UND
app=TITLE ANW.TITEL
areas=BEREICHE
argument=ARGUMENT
asc=ASC
asin=ARCSIN
asinh=ARCSINHYP
atan=ARCTAN
atan2=ARCTAN2
atanh=ARCTANHYP
avedev=MITTELABW
average=MITTELWERT
betadist=BETAVERT
betainv=BETAINV
binomdist=BINOMVERT
call=AUFRUFEN
caller=URSPRUNG
ceiling=OBERGRENZE
cell=ZELLE
char=ZEICHEN
chidist=CHIVERT
chiinv=CHIINV
chitest=CHITEST
choose=WAHL
clean=SÄUBERN
code=CODE
column=SPALTE
columns=SPALTEN
combin=KOMBINATIONEN
concatenate=VERKETTEN
confidence=KONFIDENZ
correl=KORREL
cos=COS
cosh=COSHYP
count=ANZAHL
counta=ANZAHL2
countblank=ANZAHLLEEREZELLEN
countif=ZÄHLENWENN
covar=KOVAR
create=OBJECT OBJEKT.ERSTELLEN
critbinom=KRITBINOM
date=DATUM
datedif=DATEDIF
datestring=DATESTRING
datevalue=DATWERT
daverage=DBMITTELWERT
day=TAG
days360=TAGE360
db=GDA2
dbcs=DBCS
dcount=DBANZAHL
dcounta=DBANZAHL2
ddb=GDA
degrees=GRAD
deref=POSWERT
devsq=SUMQUADABW
dget=DBAUSZUG
dialog=BOX DIALOGFELD
directory=VERZEICHNIS
dmax=DBMAX
dmin=DBMIN
documents=DOKUMENTE
dollar=DM
dproduct=DBPRODUKT
dstdev=DBSTDABW
dstdevp=DBSTDABWN
dsum=DBSUMME
dvar=DBVARIANZ
dvarp=DBVARIANZEN
echo=ECHO
error=FEHLER
evaluate=AUSWERTEN
even=GERADE
exact=IDENTISCH
exec=AUSF
execute=AUSFÜHREN
exp=EXP
expondist=EXPONVERT
fact=FAKULTÄT
fclose=DSCHLIESSEN
fdist=FVERT
files=DATEIEN
find=FINDEN
findb=FINDENB
finv=FINV
fisher=FISHER
fisherinv=FISHERINV
fixed=FEST
floor=UNTERGRENZE
fopen=DÖFFNEN
forecast=SCHÄTZER
formula=CONVERT FORMEL.UMWANDELN
fpos=DPOS
fread=DLESEN
freadln=DLESEN.ZEILE
frequency=HÄUFIGKEIT
fsize=DGRÖSSE
ftest=FTEST
fv=ZW
fwrite=DSCHREIBEN
fwriteln=DSCHREIBEN.ZEILE
gammadist=GAMMAVERT
gammainv=GAMMAINV
gammaln=GAMMALN
geomean=GEOMITTEL
goto=GEHEZU
group=GRUPPIEREN
growth=VARIATION
halt=STOP
harmean=HARMITTEL
help=HILFE
hlookup=WVERWEIS
hour=STUNDE
hypgeomdist=HYPGEOMVERT
if=WENN
index=INDEX
indirect=INDIREKT
info=INFO
initiate=KANAL.ÖFFNEN
input=EINGABE
int=GANZZAHL
intercept=ACHSENABSCHNITT
ipmt=ZINSZ
irr=IKV
isblank=ISTLEER
iserr=ISTFEHL
iserror=ISTFEHLER
islogical=ISTLOG
isna=ISTNV
isnontext=ISTKTEXT
isnumber=ISTZAHL
ispmt=ISPMT
isref=ISTBEZUG
istext=ISTTEXT
kurt=KURT
large=KGRÖSSTE
left=LINKS
leftb=LINKSB
len=LÄNGE
lenb=LENB
linest=RGP
links=VERKNÜPFTE.DATEIEN
ln=LN
log=LOG
log10=LOG10
logest=RKP
loginv=LOGINV
lognormdist=LOGNORMVERT
lookup=VERWEIS
lower=KLEIN
match=VERGLEICH
max=MAX
mdeterm=MDET
median=MEDIAN
mid=TEIL
midb=TEILB
min=MIN
minute=MINUTE
minverse=MINV
mirr=QIKV
mmult=MMULT
mod=REST
mode=MODALWERT
month=MONAT
movie=COMMAND SEQUENZ.BEFEHL
n=N
na=NV
names=NAMEN
negbinomdist=NEGBINOMVERT
normdist=NORMVERT
norminv=NORMINV
normsdist=STANDNORMVERT
normsinv=STANDNORMINV
not=NICHT
note=NOTIZ
now=JETZT
nper=ZZR
npv=NBW
numberstring=NUMBERSTRING
odd=UNGERADE
offset=BEREICH.VERSCHIEBEN
open=DIALOG DATEI.ÖFFNEN
options=LISTS.GET OPTIONEN.LISTEN.ZUORDNEN
or=ODER
pause=PAUSE
pearson=PEARSON
percentile=QUANTIL
percentrank=QUANTILSRANG
permut=VARIATIONEN
pi=PI
pivot=ADD.DATA PIVOT.DATEN.HINZUFÜGEN
pmt=RMZ
poisson=POISSON
poke=SENDEN
power=POTENZ
ppmt=KAPZ
press=TOOL SYMBOL.DRÜCKEN
prob=WAHRSCHBEREICH
product=PRODUKT
proper=GROSS2
pv=BW
quartile=QUARTILE
radians=RADIANT
rand=ZUFALLSZAHL
rank=RANG
rate=ZINS
reftext=POSTEXT
register=REGISTER
register=ID REGISTER.KENNUMMER
relref=RELPOS
replace=ERSETZEN
replaceb=ERSETZENB
rept=WIEDERHOLEN
request=ABFRAGEN
reset=TOOLBAR SYMBOLLEISTE.ZURÜCKSETZEN
restart=NEUSTART
result=ERGEBNIS
resume=WEITER.AUSFÜHREN
right=RECHTS
rightb=RECHTSB
roman=RÖMISCH
round=RUNDEN
rounddown=ABRUNDEN
roundup=AUFRUNDEN
row=ZEILE
rows=ZEILEN
rsq=BESTIMMTHEITSMASS
save=DIALOG DATEI.SPEICHERN.UNTER
save=TOOLBAR SYMBOLLEISTE.SPEICHERN
scenario=GET SZENARIO.INFO
search=SUCHEN
searchb=SUCHENB
second=SEKUNDE
selection=AUSWAHL
series=DATENREIHE
set=NAME NAMEN.ZUWEISEN
set=VALUE WERT.FESTLEGEN
show=BAR MENÜLEISTE.ZEIGEN
sign=VORZEICHEN
sin=SIN
sinh=SINHYP
skew=SCHIEFE
sln=LIA
slope=STEIGUNG
small=KKLEINSTE
spelling=CHECK RECHTSCHREIBUNG.ÜBERPRÜFEN
sqrt=WURZEL
standardize=STANDARDISIERUNG
stdev=STABW
stdeva=STABWA
stdevp=STABWN
stdevpa=STABWNA
step=EINZELSCHRITT
steyx=STFEHLERYX
substitute=WECHSELN
subtotal=TEILERGEBNIS
sum=SUMME
sumif=SUMMEWENN
sumproduct=SUMMENPRODUKT
sumsq=QUADRATESUMME
sumx2my2=SUMMEX2MY2
sumx2py2=SUMMEX2PY2
sumxmy2=SUMMEXMY2
syd=DIA
t=T
tan=TAN
tanh=TANHYP
tdist=TVERT
terminate=KANAL.SCHLIESSEN
text=TEXT
text=BOX TEXTFELD
textref=TEXTPOS
time=ZEIT
timevalue=ZEITWERT
tinv=TINV
today=HEUTE
transpose=MTRANS
trend=TREND
trim=GLÄTTEN
trimmean=GESTUTZTMITTEL
trunc=KÜRZEN
ttest=TTEST
type=TYP
unregister=KREGISTER
upper=GROSS
usdollar=USDOLLAR
value=WERT
var=VARIANZ
vara=VARIANZA
varp=VARIANZEN
varpa=VARIANZENA
vdb=VDB
vlookup=SVERWEIS
volatile=IMMER.BERECHNEN
weekday=WOCHENTAG
weibull=WEIBULL
windows=FENSTER
year=JAHR
ztest=GTEST
false=FALSCH
true=WAHR

View file

@ -0,0 +1,293 @@
# The default names (the English) for all function names in java
abs=ABS
absref=ABSREF
acos=ACOS
acosh=ACOSH
address=ADDRESS
and=AND
areas=AREAS
argument=ARGUMENT
asc=ASC
asin=ASIN
asinh=ASINH
atan=ATAN
atan2=ATAN2
atanh=ATANH
avedev=AVEDEV
average=AVERAGE
averagea=AVERAGEA
betadist=BETADIST
betainv=BETAINV
binomdist=BINOMDIST
call=CALL
caller=CALLER
ceiling=CEILING
cell=CELL
char=CHAR
chidist=CHIDIST
chiinv=CHIINV
chitest=CHITEST
choose=CHOOSE
clean=CLEAN
code=CODE
column=COLUMN
columns=COLUMNS
combin=COMBIN
concatenate=CONCATENATE
confidence=CONFIDENCE
correl=CORREL
cos=COS
cosh=COSH
count=COUNT
counta=COUNTA
countblank=COUNTBLANK
countif=COUNTIF
covar=COVAR
critbinom=CRITBINOM
date=DATE
datedif=DATEDIF
datestring=DATESTRING
datevalue=DATEVALUE
daverage=DAVERAGE
day=DAY
days360=DAYS360
db=DB
dbcs=DBCS
dcount=DCOUNT
dcounta=DCOUNTA
ddb=DDB
degrees=DEGREES
deref=DEREF
devsq=DEVSQ
dget=DGET
directory=DIRECTORY
dmax=DMAX
dmin=DMIN
documents=DOCUMENTS
dollar=DOLLAR
dproduct=DPRODUCT
dstdev=DSTDEV
dstdevp=DSTDEVP
dsum=DSUM
dvar=DVAR
dvarp=DVARP
echo=ECHO
error=ERROR
evaluate=EVALUATE
even=EVEN
exact=EXACT
exec=EXEC
execute=EXECUTE
exp=EXP
expondist=EXPONDIST
fact=FACT
fclose=FCLOSE
fdist=FDIST
files=FILES
find=FIND
findb=FINDB
finv=FINV
fisher=FISHER
fisherinv=FISHERINV
fixed=FIXED
floor=FLOOR
fopen=FOPEN
forecast=FORECAST
fpos=FPOS
fread=FREAD
freadln=FREADLN
frequency=FREQUENCY
fsize=FSIZE
ftest=FTEST
fv=FV
fwrite=FWRITE
fwriteln=FWRITELN
gammadist=GAMMADIST
gammainv=GAMMAINV
gammaln=GAMMALN
geomean=GEOMEAN
goto=GOTO
group=GROUP
growth=GROWTH
halt=HALT
harmean=HARMEAN
help=HELP
hlookup=HLOOKUP
hour=HOUR
hyperlink=HYPERLINK
hypgeomdist=HYPGEOMDIST
if=IF
index=INDEX
indirect=INDIRECT
info=INFO
initiate=INITIATE
input=INPUT
int=INT
intercept=INTERCEPT
ipmt=IPMT
irr=IRR
isblank=ISBLANK
iserr=ISERR
iserror=ISERROR
islogical=ISLOGICAL
isna=ISNA
isnontext=ISNONTEXT
isnumber=ISNUMBER
ispmt=ISPMT
isref=ISREF
istext=ISTEXT
kurt=KURT
large=LARGE
left=LEFT
leftb=LEFTB
len=LEN
lenb=LENB
linest=LINEST
links=LINKS
ln=LN
log=LOG
log10=LOG10
logest=LOGEST
loginv=LOGINV
lognormdist=LOGNORMDIST
lookup=LOOKUP
lower=LOWER
match=MATCH
max=MAX
maxa=MAXA
mdeterm=MDETERM
median=MEDIAN
mid=MID
midb=MIDB
min=MIN
mina=MINA
minute=MINUTE
minverse=MINVERSE
mirr=MIRR
mmult=MMULT
mod=MOD
mode=MODE
month=MONTH
n=N
na=NA
names=NAMES
negbinomdist=NEGBINOMDIST
normdist=NORMDIST
norminv=NORMINV
normsdist=NORMSDIST
normsinv=NORMSINV
not=NOT
note=NOTE
now=NOW
nper=NPER
npv=NPV
numberstring=NUMBERSTRING
odd=ODD
offset=OFFSET
or=OR
pause=PAUSE
pearson=PEARSON
percentile=PERCENTILE
percentrank=PERCENTRANK
permut=PERMUT
pi=PI
pmt=PMT
poisson=POISSON
poke=POKE
power=POWER
ppmt=PPMT
prob=PROB
product=PRODUCT
proper=PROPER
pv=PV
quartile=QUARTILE
radians=RADIANS
rand=RAND
rank=RANK
rate=RATE
reftext=REFTEXT
register=REGISTER
relref=RELREF
replace=REPLACE
replaceb=REPLACEB
rept=REPT
request=REQUEST
restart=RESTART
result=RESULT
resume=RESUME
right=RIGHT
rightb=RIGHTB
roman=ROMAN
round=ROUND
rounddown=ROUNDDOWN
roundup=ROUNDUP
row=ROW
rows=ROWS
rsq=RSQ
search=SEARCH
searchb=SEARCHB
second=SECOND
selection=SELECTION
series=SERIES
sign=SIGN
sin=SIN
sinh=SINH
skew=SKEW
sln=SLN
slope=SLOPE
small=SMALL
sqrt=SQRT
standardize=STANDARDIZE
stdev=STDEV
stdeva=STDDEVA
stdevp=STDEVP
stdevpa=STDDEVPA
step=STEP
steyx=STEYX
substitute=SUBSTITUTE
subtotal=SUBTOTAL
sum=SUM
sumif=SUMIF
sumproduct=SUMPRODUCT
sumsq=SUMSQ
sumx2my2=SUMX2MY2
sumx2py2=SUMX2PY2
sumxmy2=SUMXMY2
syd=SYD
t=T
tan=TAN
tanh=TANH
tdist=TDIST
terminate=TERMINATE
text=TEXT
textref=TEXTREF
time=TIME
timevalue=TIMEVALUE
tinv=TINV
today=TODAY
transpose=TRANSPOSE
trend=TREND
trim=TRIM
trimmean=TRIMMEAN
trunc=TRUNC
ttest=TTEST
type=TYPE
unregister=UNREGISTER
upper=UPPER
usdollar=USDOLLAR
value=VALUE
var=VAR
vara=VARA
varp=VARP
varpa=VARPA
vdb=VDB
vlookup=VLOOKUP
volatile=VOLATILE
weekday=WEEKDAY
weibull=WEIBULL
windows=WINDOWS
year=YEAR
ztest=ZTEST
false=FALSE
true=TRUE

View file

@ -0,0 +1,325 @@
# The function names in Spanish
abs=ABS
absref=REFABS
acos=ACOS
acosh=ACOSH
address=DIRECCION
and=Y
areas=AREAS
argument=ARGUMENTO
asc=ASC
asin=ASENO
asinh=ASENOH
atan=ATAN
atan2=ATAN2
atanh=ATANH
avedev=DESVPROM
average=PROMEDIO
betadist=DISTR.BETA
betainv=DISTR.BETA.INV
binomdist=DISTR.BINOM
call=LLAMAR
caller=LLAMADOR
ceiling=MULTIPLO.SUPERIOR
cell=CELDA
char=CARACTER
chidist=DISTR.CHI
chiinv=PRUEBA.CHI.INV
chitest=PRUEBA.CHI
choose=ELEGIR
clean=LIMPIAR
code=CODIGO
column=COLUMNA
columns=COLUMNAS
combin=COMBINAT
concatenate=CONCATENAR
confidence=INTERVALO.CONFIANZA
correl=COEF.DE.CORREL
cos=COS
cosh=COSH
count=CONTAR
counta=CONTARA
countblank=CONTAR.BLANCO
countif=CONTAR.SI
covar=COVAR
create=OBJECT CREAR.OBJETO
critbinom=BINOM.CRIT
date=FECHA
datedif=SIFECHA
datestring=CADENA.FECHA
datevalue=FECHANUMERO
daverage=BDPROMEDIO
day=DIA
days360=DIAS360
db=DB
dbcs=DBCS
dcount=BDCONTAR
dcounta=BDCONTARA
ddb=DDB
degrees=GRADOS
deref=VALREF
devsq=DESVIA2
dget=BDEXTRAER
directory=DIRECTORIO
dmax=BDMAX
dmin=BDMIN
documents=DOCUMENTOS
dollar=MONEDA
dproduct=BDPRODUCTO
dstdev=BDDESVEST
dstdevp=BDDESVESTP
dsum=BDSUMA
dvar=BDVAR
dvarp=BDVARP
echo=ECHO
error=ERROR
evaluate=EVALUAR
even=REDONDEA.PAR
exact=IGUAL
exec=EJEC
execute=EJECUTA
exp=EXP
expondist=DISTR.EXP
fact=FACT
fclose=CERRARA
fdist=DISTR.F
files=ARCHIVOS
find=ENCONTRAR
findb=ENCONTRARB
finv=DISTR.F.INV
fisher=FISHER
fisherinv=PRUEBA.FISHER.INV
fixed=DECIMAL
floor=MULTIPLO.INFERIOR
fopen=ABRIRA
forecast=PRONOSTICO
formula=CONVERT FORMULA.CONVERTIR
fpos=POSICIONA
fread=LEERA
freadln=LEERALN
frequency=FRECUENCIA
fsize=TAMAÑOA
ftest=PRUEBA.F
fv=VF
fwrite=ESCRIBIRA
fwriteln=ESCRIBIRALN
gammadist=DISTR.GAMMA
gammainv=DISTR.GAMMA.INV
gammaln=GAMMA.LN
geomean=MEDIA.GEOM
get=BAR INDICAR.BARRA
get=CELL INDICAR.CELDA
get=CHART.ITEM INDICAR.ELEMENTO.GRAFICO
get=DEF INDICAR.DEF
get=DOCUMENT INDICAR.DOCUMENTO
get=FORMULA INDICAR.FORMULA
get=LINK.INFO INDICAR.INFO.VINCULO
get=MOVIE GET.MOVIE
get=NAME INDICAR.NOMBRE
get=NOTE INDICAR.NOTAS
get=OBJECT INDICAR.OBJETO
get=PIVOT.FIELD INDICAR.CAMPO.TABLA.DI
get=PIVOT.ITEM INDICAR.ELEMENTO.TABLA.DI
get=PIVOT.TABLE INDICAR.TABLA.DINAMICA
get=TOOL INDICAR.HERRAMIENTA
get=TOOLBAR INDICAR.BARRA.HERRAMIENTAS
get=WINDOW INDICAR.VENTANA
get=WORKBOOK INDICAR.LIBRO
get=WORKSPACE INDICAR.AREA.DE.TRABAJO
goto=IR.A
group=AGRUPAR
growth=CRECIMIENTO
halt=DETENER
harmean=MEDIA.ARMO
help=AYUDA
hlookup=BUSCARH
hour=HORA
hypgeomdist=DISTR.HIPERGEOM
if=SI
index=INDICE
indirect=INDIRECTO
info=INFO
initiate=INICIAR
input=INTRODUCIR
int=ENTERO
intercept=INTERSECCION
ipmt=PAGOINT
irr=TIR
isblank=ESBLANCO
iserr=ESERR
iserror=ESERROR
islogical=ESLOGICO
isna=ESNOD
isnontext=ESNOTEXTO
isnumber=ESNUMERO
ispmt=INT.PAGO.DIR
isref=ESREF
istext=ESTEXTO
kurt=CURTOSIS
large=K.ESIMO.MAYOR
left=IZQUIERDA
leftb=IZQUIERDAB
len=LARGO
lenb=LARGOB
linest=ESTIMACION.LINEAL
links=VINCULOS
ln=LN
log=LOG
log10=LOG10
logest=ESTIMACION.LOGARITMICA
loginv=DISTR.LOG.INV
lognormdist=DISTR.LOG.NORM
lookup=BUSCAR
lower=MINUSC
match=COINCIDIR
max=MAX
mdeterm=MDETERM
median=MEDIANA
mid=EXTRAE
midb=EXTRAE
min=MIN
minute=MINUTO
minverse=MINVERSA
mirr=TIRM
mmult=MMULT
mod=RESIDUO
mode=MODA
month=MES
movie=COMMAND MOVIE.COMMAND
n=N
na=NOD
names=NOMBRES
negbinomdist=NEGBINOMDIST
normdist=DISTR.NORM
norminv=DISTR.NORM.INV
normsdist=DISTR.NORM.ESTAND
normsinv=DISTR.NORM.ESTAND.INV
not=NO
note=NOTA
now=AHORA
nper=NPER
npv=VNA
numberstring=CADENA.NUMERO
odd=REDONDEA.IMPAR
offset=DESREF
open=DIALOG ABRIR.ARCHIVO
options=LISTS.GET OPCIONES.INDICAR.LISTAS
or=O
pause=PAUSA
pearson=PEARSON
percentile=PERCENTIL
percentrank=RANGO.PERCENTIL
permut=PERMUTACIONES
pi=PI
pivot=ADD.DATA TABLA.DI.ADICIONAR.DATOS
pmt=PAGO
poisson=POISSON
poke=TRANSFERIR
power=POTENCIA
ppmt=PAGOPRIN
press=TOOL PRESIONAR.HERRAMIENTA
prob=PROBABILIDAD
product=PRODUCTO
proper=NOMPROPIO
pv=VA
quartile=CUARTIL
radians=RADIANES
rand=ALEATORIO
rank=JERARQUIA
rate=TASA
reftext=REFTEXTO
register=REGISTRAR
register=ID ID.REGISTRO
relref=REFREL
rename=COMMAND CAMBIAR.NOMBRE.COMANDO
replace=REEMPLAZAR
replaceb=REEMPLAZARB
rept=REPETIR
request=SOLICITAR
reset=TOOLBAR RESTABLECER.BARRA
restart=REINICIAR
result=RESULTADO
resume=REANUDAR
right=DERECHA
rightb=DERECHAB
roman=NUMERO.ROMANO
round=REDONDEAR
rounddown=REDONDEAR.MENOS
roundup=REDONDEAR.MAS
row=FILA
rows=FILAS
rsq=COEFICIENTE.R2
save=DIALOG GUARDAR.ARCHIVO
save=TOOLBAR GUARDAR.BARRA.HERRAMIENTAS
scenario=GET ESCENARIO.INDICAR
search=HALLAR
searchb=HALLARB
second=SEGUNDO
selection=SELECCION
series=SERIES
set=NAME ESTABLECER.NOMBRE
set=VALUE ESTABLECER.VALOR
show=BAR MOSTRAR.BARRA
sign=SIGNO
sin=SENO
sinh=SENOH
skew=COEFICIENTE.ASIMETRIA
sln=SLN
slope=PENDIENTE
small=K.ESIMO.MENOR
sqrt=RAIZ
standardize=NORMALIZACION
stdev=DESVEST
stdeva=DESVESTA
stdevp=DESVESTP
stdevpa=DESVESTPA
step=PASO.A.PASO
steyx=ERROR.TIPICO.XY
substitute=SUSTITUIR
subtotal=SUBTOTALES
sum=SUMA
sumif=SUMAR.SI
sumproduct=SUMAPRODUCTO
sumsq=SUMA.CUADRADOS
sumx2my2=SUMAX2MENOSY2
sumx2py2=SUMAX2MASY2
sumxmy2=SUMAXMENOSY2
syd=SYD
t=T
tan=TAN
tanh=TANH
tdist=DISTR.T
terminate=TERMINAR
text=TEXTO
textref=TEXTOREF
time=NSHORA
timevalue=HORANUMERO
tinv=DISTR.T.INV
today=HOY
transpose=TRANSPONER
trend=TENDENCIA
trim=ESPACIOS
trimmean=MEDIA.ACOTADA
trunc=TRUNCAR
ttest=PRUEBA.T
type=TIPO
unregister=DESREGISTRAR
upper=MAYUSC
usdollar=USDOLLAR
value=VALOR
var=VAR
vara=VARA
varp=VARP
varpa=VARPA
vdb=DVS
vlookup=BUSCARV
volatile=VOLATIL
weekday=DIASEM
weibull=DIST.WEIBULL
window=TITLE VENTANA.TITULO
windows=VENTANAS
year=AÑO
ztest=PRUEBA.Z
false=FALSO
true=VERDADERO

View file

@ -0,0 +1,301 @@
# The function names in French
abs=ABS
absref=REFABS
acos=ACOS
acosh=ACOSH
address=ADRESSE
and=ET
areas=ZONES
argument=ARGUMENT
asc=ASC
asin=ASIN
asinh=ASINH
atan=ATAN
atan2=ATAN2
atanh=ATANH
avedev=ECART.MOYEN
average=MOYENNE
betadist=LOI.BETA
betainv=BETA.INVERSE
binomdist=LOI.BINOMIALE
call=FONCTION.APPELANTE
caller=CELLULE.APPELANTE
cancel=KEY TOUCHE.ARRET
ceiling=PLAFOND
cell=CELLULE
char=CAR
chidist=LOI.KHIDEUX
chiinv=KHIDEUX.INVERSE
chitest=TEST.KHIDEUX
choose=CHOISIR
clean=EPURAGE
code=CODE
column=COLONNE
columns=COLONNES
combin=COMBIN
concatenate=CONCATENER
confidence=INTERVALLE.CONFIANCE
correl=COEFFICIENT.CORRELATION
cos=COS
cosh=COSH
count=NB
counta=NBVAL
countblank=NB.VIDE
countif=NB.SI
covar=COVARIANCE
create=OBJECT CREER.OBJET
critbinom=CRITERE.LOI.BINOMIALE
custom=REPEAT REPETER.PERSONNALISE
date=DATE
datedif=DATEDIF
datestring=DATESTRING
datevalue=DATEVAL
daverage=BDMOYENNE
day=JOUR
days360=JOURS360
db=DB
dbcs=DBCS
dcount=BDNB
dcounta=BDNBVAL
ddb=DDB
degrees=DEGRES
deref=DEREF
devsq=SOMME.CARRES.ECARTS
dget=BDLIRE
directory=REPERTOIRE
dmax=BDMAX
dmin=BDMIN
documents=DOCUMENTS
dollar=FRANC
dproduct=BDPRODUIT
dstdev=BDECARTYPE
dstdevp=BDECARTYPEP
dsum=BDSOMME
dvar=BDVAR
dvarp=BDVARP
echo=ECRAN
error=ERREUR
evaluate=EVALUER
even=PAIR
exact=EXACT
exec=LANCER
execute=EXEC
exp=EXP
expondist=LOI.EXPONENTIELLE
fact=FACT
fclose=F.FERMER
fdist=LOI.F
files=FICHIERS
find=TROUVE
findb=FINDB
finv=INVERSE.LOI.F
fisher=FISHER
fisherinv=FISHER.INVERSE
fixed=CTXT
floor=PLANCHER
fopen=F.OUVRIR
forecast=PREVISION
formula=CONVERT CONVERSION.FORMULE
fpos=F.POSITION
fread=F.LIRE
freadln=F.LIRE.LIGNE
frequency=FREQUENCE
fsize=F.DIMENSION
ftest=TEST.F
fv=VC
fwrite=F.ECRIRE
fwriteln=F.ECRIRE.LIGNE
gammadist=LOI.GAMMA
gammainv=LOI.GAMMA.INVERSE
gammaln=LNGAMMA
geomean=MOYENNE.GEOMETRIQUE
goto=ATTEINDRE
group=GROUPER
growth=CROISSANCE
halt=ARRETER
harmean=MOYENNE.HARMONIQUE
help=AIDE
hlookup=RECHERCHEH
hour=HEURE
hypgeomdist=LOI.HYPERGEOMETRIQUE
if=SI
index=INDEX
indirect=INDIRECT
info=INFO
initiate=ACCEDER
input=ENTRER
int=ENT
intercept=ORDONNEE.ORIGINE
ipmt=INTPER
irr=TRI
isblank=ESTVIDE
iserr=ESTERR
iserror=ESTERREUR
islogical=ESTLOGIQUE
isna=ESTNA
isnontext=ESTNONTEXTE
isnumber=ESTNUM
ispmt=ISPMT
isref=ESTREF
istext=ESTTEXTE
kurt=KURTOSIS
large=GRANDE.VALEUR
last=ERROR DERNIERE.ERREUR
left=GAUCHE
leftb=LEFTB
len=NBCAR
lenb=LENB
linest=DROITEREG
links=LIAISONS
ln=LN
log=LOG
log10=LOG10
logest=LOGREG
loginv=LOI.LOGNORMALE.INVERSE
lognormdist=LOI.LOGNORMALE
lookup=RECHERCHE
lower=MINUSCULE
match=EQUIV
max=MAX
mdeterm=DETERMAT
median=MEDIANE
mid=STXT
midb=MIDB
min=MIN
minute=MINUTE
minverse=INVERSEMAT
mirr=TRIM
mmult=PRODUITMAT
mod=MOD
mode=MODE
month=MOIS
movie=COMMAND COMMANDE.ANIMATION
n=N
na=NA
names=NOMS
negbinomdist=LOI.BINOMIALE.NEG
normdist=LOI.NORMALE
norminv=LOI.NORMALE.INVERSE
normsdist=LOI.NORMALE.STANDARD
normsinv=LOI.NORMALE.STANDARD.INVERSE
not=NON
note=COMMENTAIRES
now=MAINTENANT
nper=NPM
npv=VAN
numberstring=NUMBERSTRING
odd=IMPAIR
offset=DECALER
open=DIALOG OUVRIR.DIALOGUE
options=LISTS.GET LIRE.LISTES.PERSONNELLES
or=OU
pause=PAUSE
pearson=PEARSON
percentile=CENTILE
percentrank=RANG.POURCENTAGE
permut=PERMUTATION
pi=PI
pmt=VPM
poisson=LOI.POISSON
poke=POINT
power=PUISSANCE
ppmt=PRINCPER
press=TOOL ENFONCER.OUTIL
prob=PROBABILITE
product=PRODUIT
proper=NOMPROPRE
pv=VA
quartile=QUARTILE
radians=RADIANS
rand=ALEA
rank=RANG
rate=TAUX
reftext=TEXTEREF
register=REGISTRE
register=ID REGISTRE.NUMERO
relref=REFREL
replace=REMPLACER
replaceb=REPLACEB
rept=REPT
request=REQUETE
reset=TOOLBAR RETABLIR.BARRE.OUTILS
restart=RECOMMENCER
result=RESULTAT
resume=REPRISE
right=DROITE
rightb=RIGHTB
roman=ROMAIN
round=ARRONDI
rounddown=ARRONDI.INF
roundup=ARRONDI.SUP
row=LIGNE
rows=LIGNES
rsq=COEFFICIENT.DETERMINATION
search=CHERCHE
searchb=SEARCHB
second=SECONDE
selection=SELECTION
series=SERIE
sign=SIGNE
sin=SIN
sinh=SINH
skew=COEFFICIENT.ASYMETRIE
sln=AMORLIN
slope=PENTE
small=PETITE.VALEUR
sqrt=RACINE
standardize=CENTREE.REDUITE
stdev=ECARTYPE
stdeva=ECARTYPEA
stdevp=ECARTYPEP
stdevpa=ECARTYPEPA
step=PAS.A.PAS
steyx=ERREUR.TYPE.XY
substitute=SUBSTITUE
subtotal=SOUS.TOTAL
sum=SOMME
sumif=SOMME.SI
sumproduct=SOMMEPROD
sumsq=SOMME.CARRES
sumx2my2=SOMME.X2MY2
sumx2py2=SOMME.X2PY2
sumxmy2=SOMME.XMY2
syd=SYD
t=T
tan=TAN
tanh=TANH
tdist=LOI.STUDENT
terminate=TERMINER
text=TEXTE
textref=REFTEXTE
time=TEMPS
timevalue=TEMPSVAL
tinv=LOI.STUDENT.INVERSE
today=AUJOURDHUI
transpose=TRANSPOSE
trend=TENDANCE
trim=SUPPRESPACE
trimmean=MOYENNE.REDUITE
trunc=TRONQUE
ttest=TEST.STUDENT
type=TYPE
unregister=SUPPRIMER.REGISTRE
upper=MAJUSCULE
usdollar=USDOLLAR
value=CNUM
var=VAR
vara=VARA
varp=VAR.P
varp=VAR.PA
vdb=VDB
vlookup=RECHERCHEV
volatile=VOLATILE
weekday=JOURSEM
weibull=LOI.WEIBULL
window=TITLE TITRE.FENETRE
windows=FENETRES
year=ANNEE
ztest=TEST.Z
false=FAUX
true=VRAI

View file

@ -0,0 +1,294 @@
# The default names in Dutch
abs=ABS
absref=ABSOLUTE.VERWIJZING
acos=BOOGCOS
acosh=BOOGCOSH
address=ADRES
and=EN
areas=BEREIKEN
argument=ARGUMENT
asc=ASC
asin=BOOGSIN
asinh=BOOGSINH
atan=BOOGTAN
atan2=BOOGTAN2
atanh=BOOGTANH
avedev=GEMIDDELDE.DEVIATIE
average=GEMIDDELDE
averagea=GEMIDDELDEA
betadist=BETA.VERD
betainv=BETA.INV
binomdist=BINOMIALE.VERD
call=ROEPEN
caller=ROEPER
ceiling=AFRONDEN.BOVEN
cell=CELL
char=TEKEN
chidist=CHI.KWADRAAT
chiinv=CHI.KWADRAAT.INV
chitest=CHI.TOETS
choose=KIEZEN
clean=WISSEN.CONTROL
code=CODE
column=KOLOM
columns=KOLOMMEN
combin=COMBINATIES
concatenate=TEKST.SAMENVOEGEN
confidence=BETROUWBAARHEID
correl=CORRELATIE
cos=COS
cosh=COSH
count=AANTAL
counta=AANTAL.ARG
countblank=AANTAL.LEGE.CELLEN
countif=AANTAL.ALS
covar=COVARIANTIE
critbinom=CRIT.BINOM
date=DATUM
datedif=DATUMVERSCHIL
datestring=DATUMNOTATIE
datevalue=DATUMWAARDE
daverage=DBGEMIDDELDE
day=DAG
days360=DAGEN360
db=DB
dbcs=DBCS
dcount=DBAANTAL
dcounta=DBAANTALC
ddb=DDB
degrees=GRADEN
deref=WAARDE.VERWIJZING
devsq=DEV.KWAD
dget=DBLEZEN
directory=DIRECTORY
dmax=DBMAX
dmin=DBMIN
documents=DOCUMENTEN
dollar=GULDEN
dproduct=DBPRODUCT
dstdev=DBSTDEV
dstdevp=DBSTDEVP
dsum=DBSOM
dvar=DBVAR
dvarp=DBVARP
echo=ECHO
error=TYPEFOUT
evaluate=EVALUEREN
even=EVEN
exact=GELIJK
exec=BESTAND.STARTEN
execute=BESTAND.UITVOEREN
exp=EXP
expondist=EXPON.VERD
fact=FACULTEIT
fclose=BSLUITEN
fdist=F.VERDELING
files=BESTANDEN
find=VIND.ALLES
findb=VIND.ALLES.B
finv=F.INVERSE
fisher=FISHER
fisherinv=FISHER.INV
fixed=VAST
floor=AFRONDEN.BENEDEN
fopen=BOPENEN
forecast=VOORSPELLEN
fpos=BPOS
fread=BLEZEN
freadln=REGEL.BLEZEN
frequency=INTERVAL
fsize=BGROOTTE
ftest=F.TOETS
fv=TW
fwrite=BSCHRIJVEN
fwriteln=REGEL.BSCHRIJVEN
gammadist=GAMMA.VERD
gammainv=GAMMA.INV
gammaln=GAMMA.LN
geomean=MEETK.GEM
goto=GA.NAAR
group=GROEPEREN
growth=GROEI
halt=STOPPEN
harmean=HARM.GEM
help=HULP
hlookup=HORIZ.ZOEKEN
hour=UUR
hyperlink=HYPERLINK
hypgeomdist=HYPERGEO.VERD
if=ALS
index=INDEX
indirect=INDIRECT
info=INFO
initiate=KANAAL.OPENEN
input=INVOER
int=INTEGER
intercept=
ipmt=BET
irr=IR
isblank=ISLEEG
iserr=ISFOUT2
iserror=ISFOUT
islogical=ISLOGISCH
isna=ISNB
isnontext=ISGEENTEKST
isnumber=ISGETAL
ispmt=ISBET
isref=ISVERWIJZING
istext=ISTEKST
kurt=KURTOSIS
large=GROOTSTE
left=LINKS
leftb=LINKSB
len=LENGTE
lenb=LENGTEB
linest=LIJNSCH
links=KOPPELINGEN
ln=LN
log=LOG
log10=LOG10
logest=LOGSCH
loginv=LOG.NORM.INV
lognormdist=LOG.NORM.VERD
lookup=ZOEKEN
lower=KLEINE.LETTERS
match=VERGELIJKEN
max=MAX
maxa=MAXA
mdeterm=DETERMINANTMAT
median=MEDIAAN
mid=DEEL
midb=DEELB
min=MIN
mina=MINA
minute=MINUUT
minverse=INVERSEMAT
mirr=GIR
mmult=PRODUCTMAT
mod=REST
mode=MODUS
month=MAAND
n=N
na=NB
names=NAMEN
negbinomdist=NEG.BINOM.VERD
networkdays=NETTO.WERKDAGEN
normdist=NORM.VERD
norminv=NORM.INV
normsdist=STAND.NORM.VERD
normsinv=STAND.NORM.INV
not=NIET
note=NOTITIE
now=NU
nper=NPER
npv=NHW
numberstring=GETALNOTATIE
odd=ONEVEN
offset=VERSCHUIVING
or=OF
pause=PAUZE
pearson=PEARSON
percentile=PERCENTIEL
percentrank=PERCENT.RANG
permut=PERMUTATIES
pi=PI
pmt=IBET
poisson=POISSON
poke=INZETTEN
power=MACHT
ppmt=PBET
prob=KANS
product=PRODUCT
proper=BEGINLETTERS
pv=HW
quartile=KWARTIEL
radians=RADIALEN
rand=ASELECT
rank=RANG
rate=RENTE
reftext=VERWIJZING.TEKST
register=REGISTER
relref=RELATIEVE.VERWIJZING
replace=VERVANGEN
replaceb=VERVANGENB
rept=HERHALING
request=VERZOEKEN
restart=OPNIEUW.STARTEN
result=RESULTAAT
resume=HERVATTEN
right=RECHTS
rightb=RECHTSB
roman=ROMEINS
round=AFRONDEN
rounddown=AFRONDEN.NAAR.BENEDEN
roundup=AFRONDEN.NAAR.BOVEN
row=RIJ
rows=RIJEN
rsq=R.KWADRAAT
search=VIND.SPEC
searchb=VIND.SPEC.B
second=SECONDE
selection=SELECTIE
series=REEKS
sign=POS.NEG
sin=SIN
sinh=SINH
skew=SCHEEFHEID
sln=LIN.AFSCHR
slope=RICHTING
small=KLEINSTE
sqrt=WORTEL
standardize=NORMALISEREN
stdev=STDEV
stdeva=STDEVA
stdevp=STDEVP
stdevpa=STDEVPA
step=STAP
steyx=STAND.FOUT.YX
substitute=SUBSTITUEREN
subtotal=SUBTOTAAL
sum=SOM
sumif=SOM.ALS
sumproduct=SOMPRODUCT
sumsq=KWADRATENSOM
sumx2my2=SOM.X2MINY2
sumx2py2=SOM.X2PLUSY2
sumxmy2=SOM.XMINY.2
syd=SYD
t=T
tan=TAN
tanh=TANH
tdist=T.VERD
terminate=KANAAL.SLUITEN
text=TEKST
textref=TEKST.VERWIJZING
time=TIJD
timevalue=TIJDWAARDE
tinv=T.INV
today=VANDAAG
transpose=TRANSPONEREN
trend=TREND
trim=SPATIES.WISSEN
trimmean=GETRIMD.GEM
trunc=GEHEEL
ttest=T.TOETS
type=TYPE
unregister=REGISTRATIE.OPHEFFEN
upper=HOOFDLETTERS
usdollar=USDOLLAR
value=WAARDE
var=VAR
vara=VARA
varp=VARP
varpa=VARPA
vdb=VDB
vlookup=VERT.ZOEKEN
volatile=ALTIJD.HERBEREKENEN
weekday=WEEKDAG
weibull=WEIBULL
windows=VENSTERS
year=JAAR
ztest=Z.TOETS
false=ONWAAR
true=WAAR

View file

@ -0,0 +1,5 @@
package jxl;
public interface BooleanCell extends Cell {
boolean getValue();
}

View file

@ -0,0 +1,3 @@
package jxl;
public interface BooleanFormulaCell extends BooleanCell, FormulaCell {}

View file

@ -0,0 +1,19 @@
package jxl;
import jxl.format.CellFormat;
public interface Cell {
int getRow();
int getColumn();
CellType getType();
boolean isHidden();
String getContents();
CellFormat getCellFormat();
CellFeatures getCellFeatures();
}

View file

@ -0,0 +1,23 @@
package jxl;
import jxl.biff.BaseCellFeatures;
public class CellFeatures extends BaseCellFeatures {
public CellFeatures() {}
protected CellFeatures(CellFeatures cf) {
super(cf);
}
public String getComment() {
return super.getComment();
}
public String getDataValidationList() {
return super.getDataValidationList();
}
public Range getSharedDataValidationRange() {
return super.getSharedDataValidationRange();
}
}

View file

@ -0,0 +1,3 @@
package jxl;
public interface CellFormat extends jxl.format.CellFormat {}

View file

@ -0,0 +1,70 @@
package jxl;
import jxl.biff.formula.ExternalSheet;
import jxl.write.WritableWorkbook;
public final class CellReferenceHelper {
public static void getCellReference(int column, int row, StringBuffer buf) {
jxl.biff.CellReferenceHelper.getCellReference(column, row, buf);
}
public static void getCellReference(int column, boolean colabs, int row, boolean rowabs, StringBuffer buf) {
jxl.biff.CellReferenceHelper.getCellReference(column, colabs, row, rowabs, buf);
}
public static String getCellReference(int column, int row) {
return jxl.biff.CellReferenceHelper.getCellReference(column, row);
}
public static int getColumn(String s) {
return jxl.biff.CellReferenceHelper.getColumn(s);
}
public static String getColumnReference(int c) {
return jxl.biff.CellReferenceHelper.getColumnReference(c);
}
public static int getRow(String s) {
return jxl.biff.CellReferenceHelper.getRow(s);
}
public static boolean isColumnRelative(String s) {
return jxl.biff.CellReferenceHelper.isColumnRelative(s);
}
public static boolean isRowRelative(String s) {
return jxl.biff.CellReferenceHelper.isRowRelative(s);
}
public static void getCellReference(int sheet, int column, int row, Workbook workbook, StringBuffer buf) {
jxl.biff.CellReferenceHelper.getCellReference(sheet, column, row, (ExternalSheet)workbook, buf);
}
public static void getCellReference(int sheet, int column, int row, WritableWorkbook workbook, StringBuffer buf) {
jxl.biff.CellReferenceHelper.getCellReference(sheet, column, row, (ExternalSheet)workbook, buf);
}
public static void getCellReference(int sheet, int column, boolean colabs, int row, boolean rowabs, Workbook workbook, StringBuffer buf) {
jxl.biff.CellReferenceHelper.getCellReference(sheet, column, colabs, row, rowabs, (ExternalSheet)workbook, buf);
}
public static String getCellReference(int sheet, int column, int row, Workbook workbook) {
return jxl.biff.CellReferenceHelper.getCellReference(sheet, column, row, (ExternalSheet)workbook);
}
public static String getCellReference(int sheet, int column, int row, WritableWorkbook workbook) {
return jxl.biff.CellReferenceHelper.getCellReference(sheet, column, row, (ExternalSheet)workbook);
}
public static String getSheet(String ref) {
return jxl.biff.CellReferenceHelper.getSheet(ref);
}
public static String getCellReference(Cell c) {
return getCellReference(c.getColumn(), c.getRow());
}
public static void getCellReference(Cell c, StringBuffer sb) {
getCellReference(c.getColumn(), c.getRow(), sb);
}
}

View file

@ -0,0 +1,35 @@
package jxl;
public final class CellType {
private String description;
private CellType(String desc) {
this.description = desc;
}
public String toString() {
return this.description;
}
public static final CellType EMPTY = new CellType("Empty");
public static final CellType LABEL = new CellType("Label");
public static final CellType NUMBER = new CellType("Number");
public static final CellType BOOLEAN = new CellType("Boolean");
public static final CellType ERROR = new CellType("Error");
public static final CellType NUMBER_FORMULA = new CellType("Numerical Formula");
public static final CellType DATE_FORMULA = new CellType("Date Formula");
public static final CellType STRING_FORMULA = new CellType("String Formula");
public static final CellType BOOLEAN_FORMULA = new CellType("Boolean Formula");
public static final CellType FORMULA_ERROR = new CellType("Formula Error");
public static final CellType DATE = new CellType("Date");
}

View file

@ -0,0 +1,79 @@
package jxl;
import jxl.format.CellFormat;
public final class CellView {
private int dimension;
private int size;
private boolean depUsed;
private boolean hidden;
private CellFormat format;
private boolean autosize;
public CellView() {
this.hidden = false;
this.depUsed = false;
this.dimension = 1;
this.size = 1;
this.autosize = false;
}
public CellView(CellView cv) {
this.hidden = cv.hidden;
this.depUsed = cv.depUsed;
this.dimension = cv.dimension;
this.size = cv.size;
this.autosize = cv.autosize;
}
public void setHidden(boolean h) {
this.hidden = h;
}
public boolean isHidden() {
return this.hidden;
}
public void setDimension(int d) {
this.dimension = d;
this.depUsed = true;
}
public void setSize(int d) {
this.size = d;
this.depUsed = false;
}
public int getDimension() {
return this.dimension;
}
public int getSize() {
return this.size;
}
public void setFormat(CellFormat cf) {
this.format = cf;
}
public CellFormat getFormat() {
return this.format;
}
public boolean depUsed() {
return this.depUsed;
}
public void setAutosize(boolean a) {
this.autosize = a;
}
public boolean isAutosize() {
return this.autosize;
}
}

View file

@ -0,0 +1,12 @@
package jxl;
import java.text.DateFormat;
import java.util.Date;
public interface DateCell extends Cell {
Date getDate();
boolean isTime();
DateFormat getDateFormat();
}

View file

@ -0,0 +1,3 @@
package jxl;
public interface DateFormulaCell extends DateCell, FormulaCell {}

View file

@ -0,0 +1,5 @@
package jxl;
public interface ErrorCell extends Cell {
int getErrorCode();
}

View file

@ -0,0 +1,3 @@
package jxl;
public interface ErrorFormulaCell extends ErrorCell, FormulaCell {}

View file

@ -0,0 +1,7 @@
package jxl;
import jxl.biff.formula.FormulaException;
public interface FormulaCell extends Cell {
String getFormula() throws FormulaException;
}

View file

@ -0,0 +1,137 @@
package jxl;
public final class HeaderFooter extends jxl.biff.HeaderFooter {
public static class Contents extends jxl.biff.HeaderFooter.Contents {
Contents() {}
Contents(String s) {
super(s);
}
Contents(Contents copy) {
super(copy);
}
public void append(String txt) {
super.append(txt);
}
public void toggleBold() {
super.toggleBold();
}
public void toggleUnderline() {
super.toggleUnderline();
}
public void toggleItalics() {
super.toggleItalics();
}
public void toggleStrikethrough() {
super.toggleStrikethrough();
}
public void toggleDoubleUnderline() {
super.toggleDoubleUnderline();
}
public void toggleSuperScript() {
super.toggleSuperScript();
}
public void toggleSubScript() {
super.toggleSubScript();
}
public void toggleOutline() {
super.toggleOutline();
}
public void toggleShadow() {
super.toggleShadow();
}
public void setFontName(String fontName) {
super.setFontName(fontName);
}
public boolean setFontSize(int size) {
return super.setFontSize(size);
}
public void appendPageNumber() {
super.appendPageNumber();
}
public void appendTotalPages() {
super.appendTotalPages();
}
public void appendDate() {
super.appendDate();
}
public void appendTime() {
super.appendTime();
}
public void appendWorkbookName() {
super.appendWorkbookName();
}
public void appendWorkSheetName() {
super.appendWorkSheetName();
}
public void clear() {
super.clear();
}
public boolean empty() {
return super.empty();
}
}
public HeaderFooter() {}
public HeaderFooter(HeaderFooter hf) {
super(hf);
}
public HeaderFooter(String s) {
super(s);
}
public String toString() {
return super.toString();
}
public Contents getRight() {
return (Contents)getRightText();
}
public Contents getCentre() {
return (Contents)getCentreText();
}
public Contents getLeft() {
return (Contents)getLeftText();
}
public void clear() {
super.clear();
}
protected jxl.biff.HeaderFooter.Contents createContents() {
return new Contents();
}
protected jxl.biff.HeaderFooter.Contents createContents(String s) {
return new Contents(s);
}
protected jxl.biff.HeaderFooter.Contents createContents(jxl.biff.HeaderFooter.Contents c) {
return new Contents((Contents)c);
}
}

View file

@ -0,0 +1,26 @@
package jxl;
import java.io.File;
import java.net.URL;
public interface Hyperlink {
int getRow();
int getColumn();
Range getRange();
boolean isFile();
boolean isURL();
boolean isLocation();
int getLastRow();
int getLastColumn();
URL getURL();
File getFile();
}

View file

@ -0,0 +1,30 @@
package jxl;
import java.io.File;
import jxl.common.LengthUnit;
public interface Image {
double getColumn();
double getRow();
double getWidth();
double getHeight();
File getImageFile();
byte[] getImageData();
double getWidth(LengthUnit paramLengthUnit);
double getHeight(LengthUnit paramLengthUnit);
int getImageWidth();
int getImageHeight();
double getHorizontalResolution(LengthUnit paramLengthUnit);
double getVerticalResolution(LengthUnit paramLengthUnit);
}

View file

@ -0,0 +1,7 @@
package jxl;
public class JXLException extends Exception {
protected JXLException(String message) {
super(message);
}
}

View file

@ -0,0 +1,5 @@
package jxl;
public interface LabelCell extends Cell {
String getString();
}

View file

@ -0,0 +1,9 @@
package jxl;
import java.text.NumberFormat;
public interface NumberCell extends Cell {
double getValue();
NumberFormat getNumberFormat();
}

View file

@ -0,0 +1,3 @@
package jxl;
public interface NumberFormulaCell extends NumberCell, FormulaCell {}

View file

@ -0,0 +1,11 @@
package jxl;
public interface Range {
Cell getTopLeft();
Cell getBottomRight();
int getFirstSheetIndex();
int getLastSheetIndex();
}

View file

@ -0,0 +1,56 @@
package jxl;
import java.util.regex.Pattern;
import jxl.format.CellFormat;
public interface Sheet {
Cell getCell(int paramInt1, int paramInt2);
Cell getCell(String paramString);
int getRows();
int getColumns();
Cell[] getRow(int paramInt);
Cell[] getColumn(int paramInt);
String getName();
boolean isHidden();
boolean isProtected();
Cell findCell(String paramString);
Cell findCell(String paramString, int paramInt1, int paramInt2, int paramInt3, int paramInt4, boolean paramBoolean);
Cell findCell(Pattern paramPattern, int paramInt1, int paramInt2, int paramInt3, int paramInt4, boolean paramBoolean);
LabelCell findLabelCell(String paramString);
Hyperlink[] getHyperlinks();
Range[] getMergedCells();
SheetSettings getSettings();
CellFormat getColumnFormat(int paramInt);
int getColumnWidth(int paramInt);
CellView getColumnView(int paramInt);
int getRowHeight(int paramInt);
CellView getRowView(int paramInt);
int getNumberOfImages();
Image getDrawing(int paramInt);
int[] getRowPageBreaks();
int[] getColumnPageBreaks();
}

View file

@ -0,0 +1,572 @@
package jxl;
import jxl.biff.SheetRangeImpl;
import jxl.common.Assert;
import jxl.format.PageOrder;
import jxl.format.PageOrientation;
import jxl.format.PaperSize;
public final class SheetSettings {
private PageOrientation orientation;
private PageOrder pageOrder;
private PaperSize paperSize;
private boolean sheetProtected;
private boolean hidden;
private boolean selected;
private HeaderFooter header;
private double headerMargin;
private HeaderFooter footer;
private double footerMargin;
private int scaleFactor;
private int zoomFactor;
private int pageStart;
private int fitWidth;
private int fitHeight;
private int horizontalPrintResolution;
private int verticalPrintResolution;
private double leftMargin;
private double rightMargin;
private double topMargin;
private double bottomMargin;
private boolean fitToPages;
private boolean showGridLines;
private boolean printGridLines;
private boolean printHeaders;
private boolean pageBreakPreviewMode;
private boolean displayZeroValues;
private String password;
private int passwordHash;
private int defaultColumnWidth;
private int defaultRowHeight;
private int horizontalFreeze;
private int verticalFreeze;
private boolean verticalCentre;
private boolean horizontalCentre;
private int copies;
private boolean automaticFormulaCalculation;
private boolean recalculateFormulasBeforeSave;
private int pageBreakPreviewMagnification;
private int normalMagnification;
private Range printArea;
private Range printTitlesRow;
private Range printTitlesCol;
private Sheet sheet;
private static final PageOrientation DEFAULT_ORIENTATION = PageOrientation.PORTRAIT;
private static final PageOrder DEFAULT_ORDER = PageOrder.RIGHT_THEN_DOWN;
private static final PaperSize DEFAULT_PAPER_SIZE = PaperSize.A4;
private static final double DEFAULT_HEADER_MARGIN = 0.5D;
private static final double DEFAULT_FOOTER_MARGIN = 0.5D;
private static final int DEFAULT_PRINT_RESOLUTION = 300;
private static final double DEFAULT_WIDTH_MARGIN = 0.75D;
private static final double DEFAULT_HEIGHT_MARGIN = 1.0D;
private static final int DEFAULT_DEFAULT_COLUMN_WIDTH = 8;
private static final int DEFAULT_ZOOM_FACTOR = 100;
private static final int DEFAULT_NORMAL_MAGNIFICATION = 100;
private static final int DEFAULT_PAGE_BREAK_PREVIEW_MAGNIFICATION = 60;
public static final int DEFAULT_DEFAULT_ROW_HEIGHT = 255;
public SheetSettings(Sheet s) {
this.sheet = s;
this.orientation = DEFAULT_ORIENTATION;
this.pageOrder = DEFAULT_ORDER;
this.paperSize = DEFAULT_PAPER_SIZE;
this.sheetProtected = false;
this.hidden = false;
this.selected = false;
this.headerMargin = 0.5D;
this.footerMargin = 0.5D;
this.horizontalPrintResolution = 300;
this.verticalPrintResolution = 300;
this.leftMargin = 0.75D;
this.rightMargin = 0.75D;
this.topMargin = 1.0D;
this.bottomMargin = 1.0D;
this.fitToPages = false;
this.showGridLines = true;
this.printGridLines = false;
this.printHeaders = false;
this.pageBreakPreviewMode = false;
this.displayZeroValues = true;
this.defaultColumnWidth = 8;
this.defaultRowHeight = 255;
this.zoomFactor = 100;
this.pageBreakPreviewMagnification = 60;
this.normalMagnification = 100;
this.horizontalFreeze = 0;
this.verticalFreeze = 0;
this.copies = 1;
this.header = new HeaderFooter();
this.footer = new HeaderFooter();
this.automaticFormulaCalculation = true;
this.recalculateFormulasBeforeSave = true;
}
public SheetSettings(SheetSettings copy, Sheet s) {
Assert.verify((copy != null));
this.sheet = s;
this.orientation = copy.orientation;
this.pageOrder = copy.pageOrder;
this.paperSize = copy.paperSize;
this.sheetProtected = copy.sheetProtected;
this.hidden = copy.hidden;
this.selected = false;
this.headerMargin = copy.headerMargin;
this.footerMargin = copy.footerMargin;
this.scaleFactor = copy.scaleFactor;
this.pageStart = copy.pageStart;
this.fitWidth = copy.fitWidth;
this.fitHeight = copy.fitHeight;
this.horizontalPrintResolution = copy.horizontalPrintResolution;
this.verticalPrintResolution = copy.verticalPrintResolution;
this.leftMargin = copy.leftMargin;
this.rightMargin = copy.rightMargin;
this.topMargin = copy.topMargin;
this.bottomMargin = copy.bottomMargin;
this.fitToPages = copy.fitToPages;
this.password = copy.password;
this.passwordHash = copy.passwordHash;
this.defaultColumnWidth = copy.defaultColumnWidth;
this.defaultRowHeight = copy.defaultRowHeight;
this.zoomFactor = copy.zoomFactor;
this.pageBreakPreviewMagnification = copy.pageBreakPreviewMagnification;
this.normalMagnification = copy.normalMagnification;
this.showGridLines = copy.showGridLines;
this.displayZeroValues = copy.displayZeroValues;
this.pageBreakPreviewMode = copy.pageBreakPreviewMode;
this.horizontalFreeze = copy.horizontalFreeze;
this.verticalFreeze = copy.verticalFreeze;
this.horizontalCentre = copy.horizontalCentre;
this.verticalCentre = copy.verticalCentre;
this.copies = copy.copies;
this.header = new HeaderFooter(copy.header);
this.footer = new HeaderFooter(copy.footer);
this.automaticFormulaCalculation = copy.automaticFormulaCalculation;
this.recalculateFormulasBeforeSave = copy.recalculateFormulasBeforeSave;
if (copy.printArea != null)
this.printArea = new SheetRangeImpl(this.sheet, copy.getPrintArea().getTopLeft().getColumn(), copy.getPrintArea().getTopLeft().getRow(), copy.getPrintArea().getBottomRight().getColumn(), copy.getPrintArea().getBottomRight().getRow());
if (copy.printTitlesRow != null)
this.printTitlesRow = new SheetRangeImpl(this.sheet, copy.getPrintTitlesRow().getTopLeft().getColumn(), copy.getPrintTitlesRow().getTopLeft().getRow(), copy.getPrintTitlesRow().getBottomRight().getColumn(), copy.getPrintTitlesRow().getBottomRight().getRow());
if (copy.printTitlesCol != null)
this.printTitlesCol = new SheetRangeImpl(this.sheet, copy.getPrintTitlesCol().getTopLeft().getColumn(), copy.getPrintTitlesCol().getTopLeft().getRow(), copy.getPrintTitlesCol().getBottomRight().getColumn(), copy.getPrintTitlesCol().getBottomRight().getRow());
}
public void setOrientation(PageOrientation po) {
this.orientation = po;
}
public PageOrientation getOrientation() {
return this.orientation;
}
public PageOrder getPageOrder() {
return this.pageOrder;
}
public void setPageOrder(PageOrder order) {
this.pageOrder = order;
}
public void setPaperSize(PaperSize ps) {
this.paperSize = ps;
}
public PaperSize getPaperSize() {
return this.paperSize;
}
public boolean isProtected() {
return this.sheetProtected;
}
public void setProtected(boolean p) {
this.sheetProtected = p;
}
public void setHeaderMargin(double d) {
this.headerMargin = d;
}
public double getHeaderMargin() {
return this.headerMargin;
}
public void setFooterMargin(double d) {
this.footerMargin = d;
}
public double getFooterMargin() {
return this.footerMargin;
}
public void setHidden(boolean h) {
this.hidden = h;
}
public boolean isHidden() {
return this.hidden;
}
public void setSelected() {
setSelected(true);
}
public void setSelected(boolean s) {
this.selected = s;
}
public boolean isSelected() {
return this.selected;
}
public void setScaleFactor(int sf) {
this.scaleFactor = sf;
this.fitToPages = false;
}
public int getScaleFactor() {
return this.scaleFactor;
}
public void setPageStart(int ps) {
this.pageStart = ps;
}
public int getPageStart() {
return this.pageStart;
}
public void setFitWidth(int fw) {
this.fitWidth = fw;
this.fitToPages = true;
}
public int getFitWidth() {
return this.fitWidth;
}
public void setFitHeight(int fh) {
this.fitHeight = fh;
this.fitToPages = true;
}
public int getFitHeight() {
return this.fitHeight;
}
public void setHorizontalPrintResolution(int hpw) {
this.horizontalPrintResolution = hpw;
}
public int getHorizontalPrintResolution() {
return this.horizontalPrintResolution;
}
public void setVerticalPrintResolution(int vpw) {
this.verticalPrintResolution = vpw;
}
public int getVerticalPrintResolution() {
return this.verticalPrintResolution;
}
public void setRightMargin(double m) {
this.rightMargin = m;
}
public double getRightMargin() {
return this.rightMargin;
}
public void setLeftMargin(double m) {
this.leftMargin = m;
}
public double getLeftMargin() {
return this.leftMargin;
}
public void setTopMargin(double m) {
this.topMargin = m;
}
public double getTopMargin() {
return this.topMargin;
}
public void setBottomMargin(double m) {
this.bottomMargin = m;
}
public double getBottomMargin() {
return this.bottomMargin;
}
public double getDefaultWidthMargin() {
return 0.75D;
}
public double getDefaultHeightMargin() {
return 1.0D;
}
public boolean getFitToPages() {
return this.fitToPages;
}
public void setFitToPages(boolean b) {
this.fitToPages = b;
}
public String getPassword() {
return this.password;
}
public void setPassword(String s) {
this.password = s;
}
public int getPasswordHash() {
return this.passwordHash;
}
public void setPasswordHash(int ph) {
this.passwordHash = ph;
}
public int getDefaultColumnWidth() {
return this.defaultColumnWidth;
}
public void setDefaultColumnWidth(int w) {
this.defaultColumnWidth = w;
}
public int getDefaultRowHeight() {
return this.defaultRowHeight;
}
public void setDefaultRowHeight(int h) {
this.defaultRowHeight = h;
}
public int getZoomFactor() {
return this.zoomFactor;
}
public void setZoomFactor(int zf) {
this.zoomFactor = zf;
}
public int getPageBreakPreviewMagnification() {
return this.pageBreakPreviewMagnification;
}
public void setPageBreakPreviewMagnification(int f) {
this.pageBreakPreviewMagnification = f;
}
public int getNormalMagnification() {
return this.normalMagnification;
}
public void setNormalMagnification(int f) {
this.normalMagnification = f;
}
public boolean getDisplayZeroValues() {
return this.displayZeroValues;
}
public void setDisplayZeroValues(boolean b) {
this.displayZeroValues = b;
}
public boolean getShowGridLines() {
return this.showGridLines;
}
public void setShowGridLines(boolean b) {
this.showGridLines = b;
}
public boolean getPageBreakPreviewMode() {
return this.pageBreakPreviewMode;
}
public void setPageBreakPreviewMode(boolean b) {
this.pageBreakPreviewMode = b;
}
public boolean getPrintGridLines() {
return this.printGridLines;
}
public void setPrintGridLines(boolean b) {
this.printGridLines = b;
}
public boolean getPrintHeaders() {
return this.printHeaders;
}
public void setPrintHeaders(boolean b) {
this.printHeaders = b;
}
public int getHorizontalFreeze() {
return this.horizontalFreeze;
}
public void setHorizontalFreeze(int row) {
this.horizontalFreeze = Math.max(row, 0);
}
public int getVerticalFreeze() {
return this.verticalFreeze;
}
public void setVerticalFreeze(int col) {
this.verticalFreeze = Math.max(col, 0);
}
public void setCopies(int c) {
this.copies = c;
}
public int getCopies() {
return this.copies;
}
public HeaderFooter getHeader() {
return this.header;
}
public void setHeader(HeaderFooter h) {
this.header = h;
}
public void setFooter(HeaderFooter f) {
this.footer = f;
}
public HeaderFooter getFooter() {
return this.footer;
}
public boolean isHorizontalCentre() {
return this.horizontalCentre;
}
public void setHorizontalCentre(boolean horizCentre) {
this.horizontalCentre = horizCentre;
}
public boolean isVerticalCentre() {
return this.verticalCentre;
}
public void setVerticalCentre(boolean vertCentre) {
this.verticalCentre = vertCentre;
}
public void setAutomaticFormulaCalculation(boolean auto) {
this.automaticFormulaCalculation = auto;
}
public boolean getAutomaticFormulaCalculation() {
return this.automaticFormulaCalculation;
}
public void setRecalculateFormulasBeforeSave(boolean recalc) {
this.recalculateFormulasBeforeSave = recalc;
}
public boolean getRecalculateFormulasBeforeSave() {
return this.recalculateFormulasBeforeSave;
}
public void setPrintArea(int firstCol, int firstRow, int lastCol, int lastRow) {
this.printArea = new SheetRangeImpl(this.sheet, firstCol, firstRow, lastCol, lastRow);
}
public Range getPrintArea() {
return this.printArea;
}
public void setPrintTitles(int firstRow, int lastRow, int firstCol, int lastCol) {
setPrintTitlesRow(firstRow, lastRow);
setPrintTitlesCol(firstCol, lastCol);
}
public void setPrintTitlesRow(int firstRow, int lastRow) {
this.printTitlesRow = new SheetRangeImpl(this.sheet, 0, firstRow, 255, lastRow);
}
public void setPrintTitlesCol(int firstCol, int lastCol) {
this.printTitlesCol = new SheetRangeImpl(this.sheet, firstCol, 0, lastCol, 65535);
}
public Range getPrintTitlesRow() {
return this.printTitlesRow;
}
public Range getPrintTitlesCol() {
return this.printTitlesCol;
}
}

View file

@ -0,0 +1,3 @@
package jxl;
public interface StringFormulaCell extends LabelCell, FormulaCell {}

View file

@ -0,0 +1,116 @@
package jxl;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import jxl.read.biff.BiffException;
import jxl.read.biff.PasswordException;
import jxl.read.biff.WorkbookParser;
import jxl.write.WritableWorkbook;
import jxl.write.biff.WritableWorkbookImpl;
public abstract class Workbook {
private static final String VERSION = "2.6.12";
public abstract Sheet[] getSheets();
public abstract String[] getSheetNames();
public abstract Sheet getSheet(int paramInt) throws IndexOutOfBoundsException;
public abstract Sheet getSheet(String paramString);
public static String getVersion() {
return "2.6.12";
}
public abstract int getNumberOfSheets();
public abstract Cell findCellByName(String paramString);
public abstract Cell getCell(String paramString);
public abstract Range[] findByName(String paramString);
public abstract String[] getRangeNames();
public abstract boolean isProtected();
protected abstract void parse() throws BiffException, PasswordException;
public abstract void close();
public static Workbook getWorkbook(File file) throws IOException, BiffException {
return getWorkbook(file, new WorkbookSettings());
}
public static Workbook getWorkbook(File file, WorkbookSettings ws) throws IOException, BiffException {
FileInputStream fis = new FileInputStream(file);
jxl.read.biff.File dataFile = null;
try {
dataFile = new jxl.read.biff.File(fis, ws);
} catch (IOException e) {
fis.close();
throw e;
} catch (BiffException e) {
fis.close();
throw e;
}
fis.close();
Workbook workbook = new WorkbookParser(dataFile, ws);
workbook.parse();
return workbook;
}
public static Workbook getWorkbook(InputStream is) throws IOException, BiffException {
return getWorkbook(is, new WorkbookSettings());
}
public static Workbook getWorkbook(InputStream is, WorkbookSettings ws) throws IOException, BiffException {
jxl.read.biff.File dataFile = new jxl.read.biff.File(is, ws);
Workbook workbook = new WorkbookParser(dataFile, ws);
workbook.parse();
return workbook;
}
public static WritableWorkbook createWorkbook(File file) throws IOException {
return createWorkbook(file, new WorkbookSettings());
}
public static WritableWorkbook createWorkbook(File file, WorkbookSettings ws) throws IOException {
FileOutputStream fos = new FileOutputStream(file);
WritableWorkbook w = new WritableWorkbookImpl(fos, true, ws);
return w;
}
public static WritableWorkbook createWorkbook(File file, Workbook in) throws IOException {
return createWorkbook(file, in, new WorkbookSettings());
}
public static WritableWorkbook createWorkbook(File file, Workbook in, WorkbookSettings ws) throws IOException {
FileOutputStream fos = new FileOutputStream(file);
WritableWorkbook w = new WritableWorkbookImpl(fos, in, true, ws);
return w;
}
public static WritableWorkbook createWorkbook(OutputStream os, Workbook in) throws IOException {
return createWorkbook(os, in, ((WorkbookParser)in).getSettings());
}
public static WritableWorkbook createWorkbook(OutputStream os, Workbook in, WorkbookSettings ws) throws IOException {
WritableWorkbook w = new WritableWorkbookImpl(os, in, false, ws);
return w;
}
public static WritableWorkbook createWorkbook(OutputStream os) throws IOException {
return createWorkbook(os, new WorkbookSettings());
}
public static WritableWorkbook createWorkbook(OutputStream os, WorkbookSettings ws) throws IOException {
WritableWorkbook w = new WritableWorkbookImpl(os, false, ws);
return w;
}
}

View file

@ -0,0 +1,337 @@
package jxl;
import java.io.File;
import java.util.HashMap;
import java.util.Locale;
import jxl.biff.CountryCode;
import jxl.biff.formula.FunctionNames;
import jxl.common.Logger;
public final class WorkbookSettings {
private static Logger logger = Logger.getLogger(WorkbookSettings.class);
private int initialFileSize;
private int arrayGrowSize;
private boolean drawingsDisabled;
private boolean namesDisabled;
private boolean formulaReferenceAdjustDisabled;
private boolean gcDisabled;
private boolean rationalizationDisabled;
private boolean mergedCellCheckingDisabled;
private boolean propertySetsDisabled;
private boolean cellValidationDisabled;
private boolean ignoreBlankCells;
private boolean autoFilterDisabled;
private boolean useTemporaryFileDuringWrite;
private File temporaryFileDuringWriteDirectory;
private Locale locale;
private FunctionNames functionNames;
private String encoding;
private int characterSet;
private String excelDisplayLanguage;
private String excelRegionalSettings;
private HashMap localeFunctionNames;
private boolean refreshAll;
private boolean template;
private boolean excel9file = false;
private boolean windowProtected;
private String writeAccess;
private int hideobj;
public static final int HIDEOBJ_HIDE_ALL = 2;
public static final int HIDEOBJ_SHOW_PLACEHOLDERS = 1;
public static final int HIDEOBJ_SHOW_ALL = 0;
private static final int DEFAULT_INITIAL_FILE_SIZE = 5242880;
private static final int DEFAULT_ARRAY_GROW_SIZE = 1048576;
public WorkbookSettings() {
this.initialFileSize = 5242880;
this.arrayGrowSize = 1048576;
this.localeFunctionNames = new HashMap();
this.excelDisplayLanguage = CountryCode.USA.getCode();
this.excelRegionalSettings = CountryCode.UK.getCode();
this.refreshAll = false;
this.template = false;
this.excel9file = false;
this.windowProtected = false;
this.hideobj = 0;
try {
boolean suppressWarnings = Boolean.getBoolean("jxl.nowarnings");
setSuppressWarnings(suppressWarnings);
this.drawingsDisabled = Boolean.getBoolean("jxl.nodrawings");
this.namesDisabled = Boolean.getBoolean("jxl.nonames");
this.gcDisabled = Boolean.getBoolean("jxl.nogc");
this.rationalizationDisabled = Boolean.getBoolean("jxl.norat");
this.mergedCellCheckingDisabled = Boolean.getBoolean("jxl.nomergedcellchecks");
this.formulaReferenceAdjustDisabled = Boolean.getBoolean("jxl.noformulaadjust");
this.propertySetsDisabled = Boolean.getBoolean("jxl.nopropertysets");
this.ignoreBlankCells = Boolean.getBoolean("jxl.ignoreblanks");
this.cellValidationDisabled = Boolean.getBoolean("jxl.nocellvalidation");
this.autoFilterDisabled = !Boolean.getBoolean("jxl.autofilter");
this.useTemporaryFileDuringWrite = Boolean.getBoolean("jxl.usetemporaryfileduringwrite");
String tempdir = System.getProperty("jxl.temporaryfileduringwritedirectory");
if (tempdir != null)
this.temporaryFileDuringWriteDirectory = new File(tempdir);
this.encoding = System.getProperty("file.encoding");
} catch (SecurityException e) {
logger.warn("Error accessing system properties.", e);
}
try {
if (System.getProperty("jxl.lang") == null || System.getProperty("jxl.country") == null) {
this.locale = Locale.getDefault();
} else {
this.locale = new Locale(System.getProperty("jxl.lang"), System.getProperty("jxl.country"));
}
if (System.getProperty("jxl.encoding") != null)
this.encoding = System.getProperty("jxl.encoding");
} catch (SecurityException e) {
logger.warn("Error accessing system properties.", e);
this.locale = Locale.getDefault();
}
}
public void setArrayGrowSize(int sz) {
this.arrayGrowSize = sz;
}
public int getArrayGrowSize() {
return this.arrayGrowSize;
}
public void setInitialFileSize(int sz) {
this.initialFileSize = sz;
}
public int getInitialFileSize() {
return this.initialFileSize;
}
public boolean getDrawingsDisabled() {
return this.drawingsDisabled;
}
public boolean getGCDisabled() {
return this.gcDisabled;
}
public boolean getNamesDisabled() {
return this.namesDisabled;
}
public void setNamesDisabled(boolean b) {
this.namesDisabled = b;
}
public void setDrawingsDisabled(boolean b) {
this.drawingsDisabled = b;
}
public void setRationalization(boolean r) {
this.rationalizationDisabled = !r;
}
public boolean getRationalizationDisabled() {
return this.rationalizationDisabled;
}
public boolean getMergedCellCheckingDisabled() {
return this.mergedCellCheckingDisabled;
}
public void setMergedCellChecking(boolean b) {
this.mergedCellCheckingDisabled = !b;
}
public void setPropertySets(boolean r) {
this.propertySetsDisabled = !r;
}
public boolean getPropertySetsDisabled() {
return this.propertySetsDisabled;
}
public void setSuppressWarnings(boolean w) {
logger.setSuppressWarnings(w);
}
public boolean getFormulaAdjust() {
return !this.formulaReferenceAdjustDisabled;
}
public void setFormulaAdjust(boolean b) {
this.formulaReferenceAdjustDisabled = !b;
}
public void setLocale(Locale l) {
this.locale = l;
}
public Locale getLocale() {
return this.locale;
}
public String getEncoding() {
return this.encoding;
}
public void setEncoding(String enc) {
this.encoding = enc;
}
public FunctionNames getFunctionNames() {
if (this.functionNames == null) {
this.functionNames = (FunctionNames)this.localeFunctionNames.get(this.locale);
if (this.functionNames == null) {
this.functionNames = new FunctionNames(this.locale);
this.localeFunctionNames.put(this.locale, this.functionNames);
}
}
return this.functionNames;
}
public int getCharacterSet() {
return this.characterSet;
}
public void setCharacterSet(int cs) {
this.characterSet = cs;
}
public void setGCDisabled(boolean disabled) {
this.gcDisabled = disabled;
}
public void setIgnoreBlanks(boolean ignoreBlanks) {
this.ignoreBlankCells = ignoreBlanks;
}
public boolean getIgnoreBlanks() {
return this.ignoreBlankCells;
}
public void setCellValidationDisabled(boolean cv) {
this.cellValidationDisabled = cv;
}
public boolean getCellValidationDisabled() {
return this.cellValidationDisabled;
}
public String getExcelDisplayLanguage() {
return this.excelDisplayLanguage;
}
public String getExcelRegionalSettings() {
return this.excelRegionalSettings;
}
public void setExcelDisplayLanguage(String code) {
this.excelDisplayLanguage = code;
}
public void setExcelRegionalSettings(String code) {
this.excelRegionalSettings = code;
}
public boolean getAutoFilterDisabled() {
return this.autoFilterDisabled;
}
public void setAutoFilterDisabled(boolean disabled) {
this.autoFilterDisabled = disabled;
}
public boolean getUseTemporaryFileDuringWrite() {
return this.useTemporaryFileDuringWrite;
}
public void setUseTemporaryFileDuringWrite(boolean temp) {
this.useTemporaryFileDuringWrite = temp;
}
public void setTemporaryFileDuringWriteDirectory(File dir) {
this.temporaryFileDuringWriteDirectory = dir;
}
public File getTemporaryFileDuringWriteDirectory() {
return this.temporaryFileDuringWriteDirectory;
}
public void setRefreshAll(boolean refreshAll) {
this.refreshAll = refreshAll;
}
public boolean getRefreshAll() {
return this.refreshAll;
}
public boolean getTemplate() {
return this.template;
}
public void setTemplate(boolean template) {
this.template = template;
}
public boolean getExcel9File() {
return this.excel9file;
}
public void setExcel9File(boolean excel9file) {
this.excel9file = excel9file;
}
public boolean getWindowProtected() {
return this.windowProtected;
}
public void setWindowProtected(boolean windowprotected) {
this.windowProtected = this.windowProtected;
}
public int getHideobj() {
return this.hideobj;
}
public void setHideobj(int hideobj) {
this.hideobj = hideobj;
}
public String getWriteAccess() {
return this.writeAccess;
}
public void setWriteAccess(String writeAccess) {
this.writeAccess = writeAccess;
}
}

View file

@ -0,0 +1,30 @@
package jxl.biff;
import java.io.IOException;
import jxl.write.biff.File;
public class AutoFilter {
private FilterModeRecord filterMode;
private AutoFilterInfoRecord autoFilterInfo;
private AutoFilterRecord autoFilter;
public AutoFilter(FilterModeRecord fmr, AutoFilterInfoRecord afir) {
this.filterMode = fmr;
this.autoFilterInfo = afir;
}
public void add(AutoFilterRecord af) {
this.autoFilter = af;
}
public void write(File outputFile) throws IOException {
if (this.filterMode != null)
outputFile.write(this.filterMode);
if (this.autoFilterInfo != null)
outputFile.write(this.autoFilterInfo);
if (this.autoFilter != null)
outputFile.write(this.autoFilter);
}
}

View file

@ -0,0 +1,18 @@
package jxl.biff;
import jxl.common.Logger;
import jxl.read.biff.Record;
public class AutoFilterInfoRecord extends WritableRecordData {
private static Logger logger = Logger.getLogger(AutoFilterInfoRecord.class);
public AutoFilterInfoRecord(Record t) {
super(t);
}
private byte[] data = getRecord().getData();
public byte[] getData() {
return this.data;
}
}

View file

@ -0,0 +1,18 @@
package jxl.biff;
import jxl.common.Logger;
import jxl.read.biff.Record;
public class AutoFilterRecord extends WritableRecordData {
private static Logger logger = Logger.getLogger(AutoFilterRecord.class);
public AutoFilterRecord(Record t) {
super(t);
}
private byte[] data = getRecord().getData();
public byte[] getData() {
return this.data;
}
}

View file

@ -0,0 +1,273 @@
package jxl.biff;
import java.util.Collection;
import jxl.Range;
import jxl.biff.drawing.ComboBox;
import jxl.biff.drawing.Comment;
import jxl.common.Assert;
import jxl.common.Logger;
import jxl.write.biff.CellValue;
public class BaseCellFeatures {
public static Logger logger = Logger.getLogger(BaseCellFeatures.class);
private String comment;
private double commentWidth;
private double commentHeight;
private Comment commentDrawing;
private ComboBox comboBox;
private DataValiditySettingsRecord validationSettings;
private DVParser dvParser;
private boolean dropDown;
private boolean dataValidation;
private CellValue writableCell;
private static final double defaultCommentWidth = 3.0D;
private static final double defaultCommentHeight = 4.0D;
protected static class ValidationCondition {
private DVParser.Condition condition;
private static ValidationCondition[] types = new ValidationCondition[0];
ValidationCondition(DVParser.Condition c) {
this.condition = c;
ValidationCondition[] oldtypes = types;
types = new ValidationCondition[oldtypes.length + 1];
System.arraycopy(oldtypes, 0, types, 0, oldtypes.length);
types[oldtypes.length] = this;
}
public DVParser.Condition getCondition() {
return this.condition;
}
}
public static final ValidationCondition BETWEEN = new ValidationCondition(DVParser.BETWEEN);
public static final ValidationCondition NOT_BETWEEN = new ValidationCondition(DVParser.NOT_BETWEEN);
public static final ValidationCondition EQUAL = new ValidationCondition(DVParser.EQUAL);
public static final ValidationCondition NOT_EQUAL = new ValidationCondition(DVParser.NOT_EQUAL);
public static final ValidationCondition GREATER_THAN = new ValidationCondition(DVParser.GREATER_THAN);
public static final ValidationCondition LESS_THAN = new ValidationCondition(DVParser.LESS_THAN);
public static final ValidationCondition GREATER_EQUAL = new ValidationCondition(DVParser.GREATER_EQUAL);
public static final ValidationCondition LESS_EQUAL = new ValidationCondition(DVParser.LESS_EQUAL);
protected BaseCellFeatures() {}
public BaseCellFeatures(BaseCellFeatures cf) {
this.comment = cf.comment;
this.commentWidth = cf.commentWidth;
this.commentHeight = cf.commentHeight;
this.dropDown = cf.dropDown;
this.dataValidation = cf.dataValidation;
this.validationSettings = cf.validationSettings;
if (cf.dvParser != null)
this.dvParser = new DVParser(cf.dvParser);
}
protected String getComment() {
return this.comment;
}
public double getCommentWidth() {
return this.commentWidth;
}
public double getCommentHeight() {
return this.commentHeight;
}
public final void setWritableCell(CellValue wc) {
this.writableCell = wc;
}
public void setReadComment(String s, double w, double h) {
this.comment = s;
this.commentWidth = w;
this.commentHeight = h;
}
public void setValidationSettings(DataValiditySettingsRecord dvsr) {
Assert.verify((dvsr != null));
this.validationSettings = dvsr;
this.dataValidation = true;
}
public void setComment(String s) {
setComment(s, 3.0D, 4.0D);
}
public void setComment(String s, double width, double height) {
this.comment = s;
this.commentWidth = width;
this.commentHeight = height;
if (this.commentDrawing != null) {
this.commentDrawing.setCommentText(s);
this.commentDrawing.setWidth(width);
this.commentDrawing.setWidth(height);
}
}
public void removeComment() {
this.comment = null;
if (this.commentDrawing != null) {
this.writableCell.removeComment(this.commentDrawing);
this.commentDrawing = null;
}
}
public void removeDataValidation() {
if (!this.dataValidation)
return;
DVParser dvp = getDVParser();
if (dvp.extendedCellsValidation()) {
logger.warn("Cannot remove data validation from " + jxl.CellReferenceHelper.getCellReference(this.writableCell) + " as it is part of the shared reference " + jxl.CellReferenceHelper.getCellReference(dvp.getFirstColumn(), dvp.getFirstRow()) + "-" + jxl.CellReferenceHelper.getCellReference(dvp.getLastColumn(), dvp.getLastRow()));
return;
}
this.writableCell.removeDataValidation();
clearValidationSettings();
}
public void removeSharedDataValidation() {
if (!this.dataValidation)
return;
this.writableCell.removeDataValidation();
clearValidationSettings();
}
public final void setCommentDrawing(Comment c) {
this.commentDrawing = c;
}
public final Comment getCommentDrawing() {
return this.commentDrawing;
}
public String getDataValidationList() {
if (this.validationSettings == null)
return null;
return this.validationSettings.getValidationFormula();
}
public void setDataValidationList(Collection c) {
if (this.dataValidation && getDVParser().extendedCellsValidation()) {
logger.warn("Cannot set data validation on " + jxl.CellReferenceHelper.getCellReference(this.writableCell) + " as it is part of a shared data validation");
return;
}
clearValidationSettings();
this.dvParser = new DVParser(c);
this.dropDown = true;
this.dataValidation = true;
}
public void setDataValidationRange(int col1, int r1, int col2, int r2) {
if (this.dataValidation && getDVParser().extendedCellsValidation()) {
logger.warn("Cannot set data validation on " + jxl.CellReferenceHelper.getCellReference(this.writableCell) + " as it is part of a shared data validation");
return;
}
clearValidationSettings();
this.dvParser = new DVParser(col1, r1, col2, r2);
this.dropDown = true;
this.dataValidation = true;
}
public void setDataValidationRange(String namedRange) {
if (this.dataValidation && getDVParser().extendedCellsValidation()) {
logger.warn("Cannot set data validation on " + jxl.CellReferenceHelper.getCellReference(this.writableCell) + " as it is part of a shared data validation");
return;
}
clearValidationSettings();
this.dvParser = new DVParser(namedRange);
this.dropDown = true;
this.dataValidation = true;
}
public void setNumberValidation(double val, ValidationCondition c) {
if (this.dataValidation && getDVParser().extendedCellsValidation()) {
logger.warn("Cannot set data validation on " + jxl.CellReferenceHelper.getCellReference(this.writableCell) + " as it is part of a shared data validation");
return;
}
clearValidationSettings();
this.dvParser = new DVParser(val, Double.NaN, c.getCondition());
this.dropDown = false;
this.dataValidation = true;
}
public void setNumberValidation(double val1, double val2, ValidationCondition c) {
if (this.dataValidation && getDVParser().extendedCellsValidation()) {
logger.warn("Cannot set data validation on " + jxl.CellReferenceHelper.getCellReference(this.writableCell) + " as it is part of a shared data validation");
return;
}
clearValidationSettings();
this.dvParser = new DVParser(val1, val2, c.getCondition());
this.dropDown = false;
this.dataValidation = true;
}
public boolean hasDataValidation() {
return this.dataValidation;
}
private void clearValidationSettings() {
this.validationSettings = null;
this.dvParser = null;
this.dropDown = false;
this.comboBox = null;
this.dataValidation = false;
}
public boolean hasDropDown() {
return this.dropDown;
}
public void setComboBox(ComboBox cb) {
this.comboBox = cb;
}
public DVParser getDVParser() {
if (this.dvParser != null)
return this.dvParser;
if (this.validationSettings != null) {
this.dvParser = new DVParser(this.validationSettings.getDVParser());
return this.dvParser;
}
return null;
}
public void shareDataValidation(BaseCellFeatures source) {
if (this.dataValidation) {
logger.warn("Attempting to share a data validation on cell " + jxl.CellReferenceHelper.getCellReference(this.writableCell) + " which already has a data validation");
return;
}
clearValidationSettings();
this.dvParser = source.getDVParser();
this.validationSettings = null;
this.dataValidation = true;
this.dropDown = source.dropDown;
this.comboBox = source.comboBox;
}
public Range getSharedDataValidationRange() {
if (!this.dataValidation)
return null;
DVParser dvp = getDVParser();
return new SheetRangeImpl(this.writableCell.getSheet(), dvp.getFirstColumn(), dvp.getFirstRow(), dvp.getLastColumn(), dvp.getLastRow());
}
}

View file

@ -0,0 +1,154 @@
package jxl.biff;
import jxl.common.Assert;
import jxl.common.Logger;
public abstract class BaseCompoundFile {
private static Logger logger = Logger.getLogger(BaseCompoundFile.class);
protected static final byte[] IDENTIFIER = new byte[] { -48, -49, 17, -32, -95, -79, 26, -31 };
protected static final int NUM_BIG_BLOCK_DEPOT_BLOCKS_POS = 44;
protected static final int SMALL_BLOCK_DEPOT_BLOCK_POS = 60;
protected static final int NUM_SMALL_BLOCK_DEPOT_BLOCKS_POS = 64;
protected static final int ROOT_START_BLOCK_POS = 48;
protected static final int BIG_BLOCK_SIZE = 512;
protected static final int SMALL_BLOCK_SIZE = 64;
protected static final int EXTENSION_BLOCK_POS = 68;
protected static final int NUM_EXTENSION_BLOCK_POS = 72;
protected static final int PROPERTY_STORAGE_BLOCK_SIZE = 128;
protected static final int BIG_BLOCK_DEPOT_BLOCKS_POS = 76;
protected static final int SMALL_BLOCK_THRESHOLD = 4096;
private static final int SIZE_OF_NAME_POS = 64;
private static final int TYPE_POS = 66;
private static final int COLOUR_POS = 67;
private static final int PREVIOUS_POS = 68;
private static final int NEXT_POS = 72;
private static final int CHILD_POS = 76;
private static final int START_BLOCK_POS = 116;
private static final int SIZE_POS = 120;
public static final String ROOT_ENTRY_NAME = "Root Entry";
public static final String WORKBOOK_NAME = "Workbook";
public static final String SUMMARY_INFORMATION_NAME = "\005SummaryInformation";
public static final String DOCUMENT_SUMMARY_INFORMATION_NAME = "\005DocumentSummaryInformation";
public static final String COMP_OBJ_NAME = "\001CompObj";
public static final String[] STANDARD_PROPERTY_SETS = new String[] { "Root Entry", "Workbook", "\005SummaryInformation", "\005DocumentSummaryInformation" };
public static final int NONE_PS_TYPE = 0;
public static final int DIRECTORY_PS_TYPE = 1;
public static final int FILE_PS_TYPE = 2;
public static final int ROOT_ENTRY_PS_TYPE = 5;
public class PropertyStorage {
public String name;
public int type;
public int colour;
public int startBlock;
public int size;
public int previous;
public int next;
public int child;
public byte[] data;
public PropertyStorage(byte[] d) {
this.data = d;
int nameSize = IntegerHelper.getInt(this.data[64], this.data[65]);
if (nameSize > 64) {
BaseCompoundFile.logger.warn("property set name exceeds max length - truncating");
nameSize = 64;
}
this.type = this.data[66];
this.colour = this.data[67];
this.startBlock = IntegerHelper.getInt(this.data[116], this.data[117], this.data[118], this.data[119]);
this.size = IntegerHelper.getInt(this.data[120], this.data[121], this.data[122], this.data[123]);
this.previous = IntegerHelper.getInt(this.data[68], this.data[69], this.data[70], this.data[71]);
this.next = IntegerHelper.getInt(this.data[72], this.data[73], this.data[74], this.data[75]);
this.child = IntegerHelper.getInt(this.data[76], this.data[77], this.data[78], this.data[79]);
int chars = 0;
if (nameSize > 2)
chars = (nameSize - 1) / 2;
StringBuffer n = new StringBuffer("");
for (int i = 0; i < chars; i++)
n.append((char)this.data[i * 2]);
this.name = n.toString();
}
public PropertyStorage(String name) {
this.data = new byte[128];
Assert.verify((name.length() < 32));
IntegerHelper.getTwoBytes((name.length() + 1) * 2, this.data, 64);
for (int i = 0; i < name.length(); i++)
this.data[i * 2] = (byte)name.charAt(i);
}
public void setType(int t) {
this.type = t;
this.data[66] = (byte)t;
}
public void setStartBlock(int sb) {
this.startBlock = sb;
IntegerHelper.getFourBytes(sb, this.data, 116);
}
public void setSize(int s) {
this.size = s;
IntegerHelper.getFourBytes(s, this.data, 120);
}
public void setPrevious(int prev) {
this.previous = prev;
IntegerHelper.getFourBytes(prev, this.data, 68);
}
public void setNext(int nxt) {
this.next = nxt;
IntegerHelper.getFourBytes(this.next, this.data, 72);
}
public void setChild(int dir) {
this.child = dir;
IntegerHelper.getFourBytes(this.child, this.data, 76);
}
public void setColour(int col) {
this.colour = (col == 0) ? 0 : 1;
this.data[67] = (byte)this.colour;
}
}
}

View file

@ -0,0 +1,82 @@
package jxl.biff;
import jxl.format.Format;
final class BuiltInFormat implements Format, DisplayFormat {
private String formatString;
private int formatIndex;
private BuiltInFormat(String s, int i) {
this.formatIndex = i;
this.formatString = s;
}
public String getFormatString() {
return this.formatString;
}
public int getFormatIndex() {
return this.formatIndex;
}
public boolean isInitialized() {
return true;
}
public void initialize(int pos) {}
public boolean isBuiltIn() {
return true;
}
public boolean equals(Object o) {
if (o == this)
return true;
if (!(o instanceof BuiltInFormat))
return false;
BuiltInFormat bif = (BuiltInFormat)o;
return (this.formatIndex == bif.formatIndex);
}
public static BuiltInFormat[] builtIns = new BuiltInFormat[50];
static {
builtIns[0] = new BuiltInFormat("", 0);
builtIns[1] = new BuiltInFormat("0", 1);
builtIns[2] = new BuiltInFormat("0.00", 2);
builtIns[3] = new BuiltInFormat("#,##0", 3);
builtIns[4] = new BuiltInFormat("#,##0.00", 4);
builtIns[5] = new BuiltInFormat("($#,##0_);($#,##0)", 5);
builtIns[6] = new BuiltInFormat("($#,##0_);[Red]($#,##0)", 6);
builtIns[7] = new BuiltInFormat("($#,##0_);[Red]($#,##0)", 7);
builtIns[8] = new BuiltInFormat("($#,##0.00_);[Red]($#,##0.00)", 8);
builtIns[9] = new BuiltInFormat("0%", 9);
builtIns[10] = new BuiltInFormat("0.00%", 10);
builtIns[11] = new BuiltInFormat("0.00E+00", 11);
builtIns[12] = new BuiltInFormat("# ?/?", 12);
builtIns[13] = new BuiltInFormat("# ??/??", 13);
builtIns[14] = new BuiltInFormat("dd/mm/yyyy", 14);
builtIns[15] = new BuiltInFormat("d-mmm-yy", 15);
builtIns[16] = new BuiltInFormat("d-mmm", 16);
builtIns[17] = new BuiltInFormat("mmm-yy", 17);
builtIns[18] = new BuiltInFormat("h:mm AM/PM", 18);
builtIns[19] = new BuiltInFormat("h:mm:ss AM/PM", 19);
builtIns[20] = new BuiltInFormat("h:mm", 20);
builtIns[21] = new BuiltInFormat("h:mm:ss", 21);
builtIns[22] = new BuiltInFormat("m/d/yy h:mm", 22);
builtIns[37] = new BuiltInFormat("(#,##0_);(#,##0)", 37);
builtIns[38] = new BuiltInFormat("(#,##0_);[Red](#,##0)", 38);
builtIns[39] = new BuiltInFormat("(#,##0.00_);(#,##0.00)", 39);
builtIns[40] = new BuiltInFormat("(#,##0.00_);[Red](#,##0.00)", 40);
builtIns[41] = new BuiltInFormat("_(*#,##0_);_(*(#,##0);_(*\"-\"_);(@_)", 41);
builtIns[42] = new BuiltInFormat("_($*#,##0_);_($*(#,##0);_($*\"-\"_);(@_)", 42);
builtIns[43] = new BuiltInFormat("_(* #,##0.00_);_(* (#,##0.00);_(* \"-\"??_);(@_)", 43);
builtIns[44] = new BuiltInFormat("_($* #,##0.00_);_($* (#,##0.00);_($* \"-\"??_);(@_)", 44);
builtIns[45] = new BuiltInFormat("mm:ss", 45);
builtIns[46] = new BuiltInFormat("[h]mm:ss", 46);
builtIns[47] = new BuiltInFormat("mm:ss.0", 47);
builtIns[48] = new BuiltInFormat("##0.0E+0", 48);
builtIns[49] = new BuiltInFormat("@", 49);
}
}

View file

@ -0,0 +1,63 @@
package jxl.biff;
public class BuiltInName {
private String name;
private int value;
private static BuiltInName[] builtInNames = new BuiltInName[0];
private BuiltInName(String n, int v) {
this.name = n;
this.value = v;
BuiltInName[] oldnames = builtInNames;
builtInNames = new BuiltInName[oldnames.length + 1];
System.arraycopy(oldnames, 0, builtInNames, 0, oldnames.length);
builtInNames[oldnames.length] = this;
}
public String getName() {
return this.name;
}
public int getValue() {
return this.value;
}
public static BuiltInName getBuiltInName(int val) {
BuiltInName ret = FILTER_DATABASE;
for (int i = 0; i < builtInNames.length; i++) {
if (builtInNames[i].getValue() == val)
ret = builtInNames[i];
}
return ret;
}
public static final BuiltInName CONSOLIDATE_AREA = new BuiltInName("Consolidate_Area", 0);
public static final BuiltInName AUTO_OPEN = new BuiltInName("Auto_Open", 1);
public static final BuiltInName AUTO_CLOSE = new BuiltInName("Auto_Open", 2);
public static final BuiltInName EXTRACT = new BuiltInName("Extract", 3);
public static final BuiltInName DATABASE = new BuiltInName("Database", 4);
public static final BuiltInName CRITERIA = new BuiltInName("Criteria", 5);
public static final BuiltInName PRINT_AREA = new BuiltInName("Print_Area", 6);
public static final BuiltInName PRINT_TITLES = new BuiltInName("Print_Titles", 7);
public static final BuiltInName RECORDER = new BuiltInName("Recorder", 8);
public static final BuiltInName DATA_FORM = new BuiltInName("Data_Form", 9);
public static final BuiltInName AUTO_ACTIVATE = new BuiltInName("Auto_Activate", 10);
public static final BuiltInName AUTO_DEACTIVATE = new BuiltInName("Auto_Deactivate", 11);
public static final BuiltInName SHEET_TITLE = new BuiltInName("Sheet_Title", 11);
public static final BuiltInName FILTER_DATABASE = new BuiltInName("_FilterDatabase", 13);
}

View file

@ -0,0 +1,22 @@
package jxl.biff;
class BuiltInStyle extends WritableRecordData {
private int xfIndex;
private int styleNumber;
public BuiltInStyle(int xfind, int sn) {
super(Type.STYLE);
this.xfIndex = xfind;
this.styleNumber = sn;
}
public byte[] getData() {
byte[] data = new byte[4];
IntegerHelper.getTwoBytes(this.xfIndex, data, 0);
data[1] = (byte)(data[1] | 0x80);
data[2] = (byte)this.styleNumber;
data[3] = -1;
return data;
}
}

View file

@ -0,0 +1,47 @@
package jxl.biff;
public class ByteArray {
private int growSize;
private byte[] bytes;
private int pos;
private static final int defaultGrowSize = 1024;
public ByteArray() {
this(1024);
}
public ByteArray(int gs) {
this.growSize = gs;
this.bytes = new byte[1024];
this.pos = 0;
}
public void add(byte b) {
checkSize(1);
this.bytes[this.pos] = b;
this.pos++;
}
public void add(byte[] b) {
checkSize(b.length);
System.arraycopy(b, 0, this.bytes, this.pos, b.length);
this.pos += b.length;
}
public byte[] getBytes() {
byte[] returnArray = new byte[this.pos];
System.arraycopy(this.bytes, 0, returnArray, 0, this.pos);
return returnArray;
}
private void checkSize(int sz) {
while (this.pos + sz >= this.bytes.length) {
byte[] newArray = new byte[this.bytes.length + this.growSize];
System.arraycopy(this.bytes, 0, newArray, 0, this.pos);
this.bytes = newArray;
}
}
}

View file

@ -0,0 +1,5 @@
package jxl.biff;
public interface ByteData {
byte[] getBytes();
}

View file

@ -0,0 +1,102 @@
package jxl.biff;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import jxl.Cell;
import jxl.CellType;
import jxl.LabelCell;
import jxl.Sheet;
public class CellFinder {
private Sheet sheet;
public CellFinder(Sheet s) {
this.sheet = s;
}
public Cell findCell(String contents, int firstCol, int firstRow, int lastCol, int lastRow, boolean reverse) {
Cell cell = null;
boolean found = false;
int numCols = lastCol - firstCol;
int numRows = lastRow - firstRow;
int row1 = reverse ? lastRow : firstRow;
int row2 = reverse ? firstRow : lastRow;
int col1 = reverse ? lastCol : firstCol;
int col2 = reverse ? firstCol : lastCol;
int inc = reverse ? -1 : 1;
for (int i = 0; i <= numCols && !found; i++) {
for (int j = 0; j <= numRows && !found; j++) {
int curCol = col1 + i * inc;
int curRow = row1 + j * inc;
if (curCol < this.sheet.getColumns() && curRow < this.sheet.getRows()) {
Cell c = this.sheet.getCell(curCol, curRow);
if (c.getType() != CellType.EMPTY)
if (c.getContents().equals(contents)) {
cell = c;
found = true;
}
}
}
}
return cell;
}
public Cell findCell(String contents) {
Cell cell = null;
boolean found = false;
for (int i = 0; i < this.sheet.getRows() && !found; i++) {
Cell[] row = this.sheet.getRow(i);
for (int j = 0; j < row.length && !found; j++) {
if (row[j].getContents().equals(contents)) {
cell = row[j];
found = true;
}
}
}
return cell;
}
public Cell findCell(Pattern pattern, int firstCol, int firstRow, int lastCol, int lastRow, boolean reverse) {
Cell cell = null;
boolean found = false;
int numCols = lastCol - firstCol;
int numRows = lastRow - firstRow;
int row1 = reverse ? lastRow : firstRow;
int row2 = reverse ? firstRow : lastRow;
int col1 = reverse ? lastCol : firstCol;
int col2 = reverse ? firstCol : lastCol;
int inc = reverse ? -1 : 1;
for (int i = 0; i <= numCols && !found; i++) {
for (int j = 0; j <= numRows && !found; j++) {
int curCol = col1 + i * inc;
int curRow = row1 + j * inc;
if (curCol < this.sheet.getColumns() && curRow < this.sheet.getRows()) {
Cell c = this.sheet.getCell(curCol, curRow);
if (c.getType() != CellType.EMPTY) {
Matcher m = pattern.matcher(c.getContents());
if (m.matches()) {
cell = c;
found = true;
}
}
}
}
}
return cell;
}
public LabelCell findLabelCell(String contents) {
LabelCell cell = null;
boolean found = false;
for (int i = 0; i < this.sheet.getRows() && !found; i++) {
Cell[] row = this.sheet.getRow(i);
for (int j = 0; j < row.length && !found; j++) {
if ((row[j].getType() == CellType.LABEL || row[j].getType() == CellType.STRING_FORMULA) && row[j].getContents().equals(contents)) {
cell = (LabelCell)row[j];
found = true;
}
}
}
return cell;
}
}

View file

@ -0,0 +1,131 @@
package jxl.biff;
import jxl.biff.formula.ExternalSheet;
import jxl.common.Logger;
public final class CellReferenceHelper {
private static Logger logger = Logger.getLogger(CellReferenceHelper.class);
private static final char fixedInd = '$';
private static final char sheetInd = '!';
public static void getCellReference(int column, int row, StringBuffer buf) {
getColumnReference(column, buf);
buf.append(Integer.toString(row + 1));
}
public static void getCellReference(int column, boolean colabs, int row, boolean rowabs, StringBuffer buf) {
if (colabs)
buf.append('$');
getColumnReference(column, buf);
if (rowabs)
buf.append('$');
buf.append(Integer.toString(row + 1));
}
public static String getColumnReference(int column) {
StringBuffer buf = new StringBuffer();
getColumnReference(column, buf);
return buf.toString();
}
public static void getColumnReference(int column, StringBuffer buf) {
int v = column / 26;
int r = column % 26;
StringBuffer tmp = new StringBuffer();
while (v != 0) {
char c = (char)(65 + r);
tmp.append(c);
r = v % 26 - 1;
v /= 26;
}
char col = (char)(65 + r);
tmp.append(col);
for (int i = tmp.length() - 1; i >= 0; i--)
buf.append(tmp.charAt(i));
}
public static void getCellReference(int sheet, int column, int row, ExternalSheet workbook, StringBuffer buf) {
String name = workbook.getExternalSheetName(sheet);
buf.append(StringHelper.replace(name, "'", "''"));
buf.append('!');
getCellReference(column, row, buf);
}
public static void getCellReference(int sheet, int column, boolean colabs, int row, boolean rowabs, ExternalSheet workbook, StringBuffer buf) {
String name = workbook.getExternalSheetName(sheet);
buf.append(name);
buf.append('!');
getCellReference(column, colabs, row, rowabs, buf);
}
public static String getCellReference(int sheet, int column, int row, ExternalSheet workbook) {
StringBuffer sb = new StringBuffer();
getCellReference(sheet, column, row, workbook, sb);
return sb.toString();
}
public static String getCellReference(int column, int row) {
StringBuffer buf = new StringBuffer();
getCellReference(column, row, buf);
return buf.toString();
}
public static int getColumn(String s) {
int colnum = 0;
int numindex = getNumberIndex(s);
String s2 = s.toUpperCase();
int startPos = s.lastIndexOf('!') + 1;
if (s.charAt(startPos) == '$')
startPos++;
int endPos = numindex;
if (s.charAt(numindex - 1) == '$')
endPos--;
for (int i = startPos; i < endPos; i++) {
if (i != startPos)
colnum = (colnum + 1) * 26;
colnum += s2.charAt(i) - 65;
}
return colnum;
}
public static int getRow(String s) {
try {
return Integer.parseInt(s.substring(getNumberIndex(s))) - 1;
} catch (NumberFormatException e) {
logger.warn(e, e);
return 65535;
}
}
private static int getNumberIndex(String s) {
boolean numberFound = false;
int pos = s.lastIndexOf('!') + 1;
char c = '\000';
while (!numberFound && pos < s.length()) {
c = s.charAt(pos);
if (c >= '0' && c <= '9') {
numberFound = true;
continue;
}
pos++;
}
return pos;
}
public static boolean isColumnRelative(String s) {
return (s.charAt(0) != '$');
}
public static boolean isRowRelative(String s) {
return (s.charAt(getNumberIndex(s) - 1) != '$');
}
public static String getSheet(String ref) {
int sheetPos = ref.lastIndexOf('!');
if (sheetPos == -1)
return "";
return ref.substring(0, sheetPos);
}
}

View file

@ -0,0 +1,42 @@
package jxl.biff;
import java.io.IOException;
import java.util.ArrayList;
import jxl.write.biff.File;
public class ConditionalFormat {
private ConditionalFormatRangeRecord range;
private ArrayList conditions;
public ConditionalFormat(ConditionalFormatRangeRecord cfrr) {
this.range = cfrr;
this.conditions = new ArrayList();
}
public void addCondition(ConditionalFormatRecord cond) {
this.conditions.add(cond);
}
public void insertColumn(int col) {
this.range.insertColumn(col);
}
public void removeColumn(int col) {
this.range.removeColumn(col);
}
public void removeRow(int row) {
this.range.removeRow(row);
}
public void insertRow(int row) {
this.range.insertRow(row);
}
public void write(File outputFile) throws IOException {
outputFile.write(this.range);
for (ConditionalFormatRecord cfr : (Iterable<ConditionalFormatRecord>)this.conditions)
outputFile.write(cfr);
}
}

View file

@ -0,0 +1,181 @@
package jxl.biff;
import jxl.common.Logger;
import jxl.read.biff.Record;
public class ConditionalFormatRangeRecord extends WritableRecordData {
private static Logger logger = Logger.getLogger(ConditionalFormatRangeRecord.class);
private Range enclosingRange;
private Range[] ranges;
private int numRanges;
private static class Range {
public int firstRow;
public int firstColumn;
public int lastRow;
public int lastColumn;
public boolean modified = false;
public void insertColumn(int col) {
if (col > this.lastColumn)
return;
if (col <= this.firstColumn) {
this.firstColumn++;
this.modified = true;
}
if (col <= this.lastColumn) {
this.lastColumn++;
this.modified = true;
}
}
public void removeColumn(int col) {
if (col > this.lastColumn)
return;
if (col < this.firstColumn) {
this.firstColumn--;
this.modified = true;
}
if (col <= this.lastColumn) {
this.lastColumn--;
this.modified = true;
}
}
public void removeRow(int row) {
if (row > this.lastRow)
return;
if (row < this.firstRow) {
this.firstRow--;
this.modified = true;
}
if (row <= this.lastRow) {
this.lastRow--;
this.modified = true;
}
}
public void insertRow(int row) {
if (row > this.lastRow)
return;
if (row <= this.firstRow) {
this.firstRow++;
this.modified = true;
}
if (row <= this.lastRow) {
this.lastRow++;
this.modified = true;
}
}
}
public ConditionalFormatRangeRecord(Record t) {
super(t);
}
private boolean initialized = false;
private boolean modified = false;
private byte[] data = getRecord().getData();
private void initialize() {
this.enclosingRange = new Range();
this.enclosingRange.firstRow = IntegerHelper.getInt(this.data[4], this.data[5]);
this.enclosingRange.lastRow = IntegerHelper.getInt(this.data[6], this.data[7]);
this.enclosingRange.firstColumn = IntegerHelper.getInt(this.data[8], this.data[9]);
this.enclosingRange.lastColumn = IntegerHelper.getInt(this.data[10], this.data[11]);
this.numRanges = IntegerHelper.getInt(this.data[12], this.data[13]);
this.ranges = new Range[this.numRanges];
int pos = 14;
for (int i = 0; i < this.numRanges; i++) {
this.ranges[i] = new Range();
(this.ranges[i]).firstRow = IntegerHelper.getInt(this.data[pos], this.data[pos + 1]);
(this.ranges[i]).lastRow = IntegerHelper.getInt(this.data[pos + 2], this.data[pos + 3]);
(this.ranges[i]).firstColumn = IntegerHelper.getInt(this.data[pos + 4], this.data[pos + 5]);
(this.ranges[i]).lastColumn = IntegerHelper.getInt(this.data[pos + 6], this.data[pos + 7]);
pos += 8;
}
this.initialized = true;
}
public void insertColumn(int col) {
if (!this.initialized)
initialize();
this.enclosingRange.insertColumn(col);
if (this.enclosingRange.modified)
this.modified = true;
for (int i = 0; i < this.ranges.length; i++) {
this.ranges[i].insertColumn(col);
if ((this.ranges[i]).modified)
this.modified = true;
}
}
public void removeColumn(int col) {
if (!this.initialized)
initialize();
this.enclosingRange.removeColumn(col);
if (this.enclosingRange.modified)
this.modified = true;
for (int i = 0; i < this.ranges.length; i++) {
this.ranges[i].removeColumn(col);
if ((this.ranges[i]).modified)
this.modified = true;
}
}
public void removeRow(int row) {
if (!this.initialized)
initialize();
this.enclosingRange.removeRow(row);
if (this.enclosingRange.modified)
this.modified = true;
for (int i = 0; i < this.ranges.length; i++) {
this.ranges[i].removeRow(row);
if ((this.ranges[i]).modified)
this.modified = true;
}
}
public void insertRow(int row) {
if (!this.initialized)
initialize();
this.enclosingRange.insertRow(row);
if (this.enclosingRange.modified)
this.modified = true;
for (int i = 0; i < this.ranges.length; i++) {
this.ranges[i].insertRow(row);
if ((this.ranges[i]).modified)
this.modified = true;
}
}
public byte[] getData() {
if (!this.modified)
return this.data;
byte[] d = new byte[14 + this.ranges.length * 8];
System.arraycopy(this.data, 0, d, 0, 4);
IntegerHelper.getTwoBytes(this.enclosingRange.firstRow, d, 4);
IntegerHelper.getTwoBytes(this.enclosingRange.lastRow, d, 6);
IntegerHelper.getTwoBytes(this.enclosingRange.firstColumn, d, 8);
IntegerHelper.getTwoBytes(this.enclosingRange.lastColumn, d, 10);
IntegerHelper.getTwoBytes(this.numRanges, d, 12);
int pos = 14;
for (int i = 0; i < this.ranges.length; i++) {
IntegerHelper.getTwoBytes((this.ranges[i]).firstRow, d, pos);
IntegerHelper.getTwoBytes((this.ranges[i]).lastRow, d, pos + 2);
IntegerHelper.getTwoBytes((this.ranges[i]).firstColumn, d, pos + 4);
IntegerHelper.getTwoBytes((this.ranges[i]).lastColumn, d, pos + 6);
pos += 8;
}
return d;
}
}

View file

@ -0,0 +1,18 @@
package jxl.biff;
import jxl.common.Logger;
import jxl.read.biff.Record;
public class ConditionalFormatRecord extends WritableRecordData {
private static Logger logger = Logger.getLogger(ConditionalFormatRecord.class);
public ConditionalFormatRecord(Record t) {
super(t);
}
private byte[] data = getRecord().getData();
public byte[] getData() {
return this.data;
}
}

View file

@ -0,0 +1,25 @@
package jxl.biff;
import jxl.read.biff.Record;
public class ContinueRecord extends WritableRecordData {
private byte[] data;
public ContinueRecord(Record t) {
super(t);
this.data = t.getData();
}
public ContinueRecord(byte[] d) {
super(Type.CONTINUE);
this.data = d;
}
public byte[] getData() {
return this.data;
}
public Record getRecord() {
return super.getRecord();
}
}

View file

@ -0,0 +1,92 @@
package jxl.biff;
import jxl.common.Logger;
public class CountryCode {
private static Logger logger = Logger.getLogger(CountryCode.class);
private int value;
private String code;
private String description;
private static CountryCode[] codes = new CountryCode[0];
private CountryCode(int v, String c, String d) {
this.value = v;
this.code = c;
this.description = d;
CountryCode[] newcodes = new CountryCode[codes.length + 1];
System.arraycopy(codes, 0, newcodes, 0, codes.length);
newcodes[codes.length] = this;
codes = newcodes;
}
private CountryCode(int v) {
this.value = v;
this.description = "Arbitrary";
this.code = "??";
}
public int getValue() {
return this.value;
}
public String getCode() {
return this.code;
}
public static CountryCode getCountryCode(String s) {
if (s == null || s.length() != 2) {
logger.warn("Please specify two character ISO 3166 country code");
return USA;
}
CountryCode code = UNKNOWN;
for (int i = 0; i < codes.length && code == UNKNOWN; i++) {
if ((codes[i]).code.equals(s))
code = codes[i];
}
return code;
}
public static CountryCode createArbitraryCode(int i) {
return new CountryCode(i);
}
public static final CountryCode USA = new CountryCode(1, "US", "USA");
public static final CountryCode CANADA = new CountryCode(2, "CA", "Canada");
public static final CountryCode GREECE = new CountryCode(30, "GR", "Greece");
public static final CountryCode NETHERLANDS = new CountryCode(31, "NE", "Netherlands");
public static final CountryCode BELGIUM = new CountryCode(32, "BE", "Belgium");
public static final CountryCode FRANCE = new CountryCode(33, "FR", "France");
public static final CountryCode SPAIN = new CountryCode(34, "ES", "Spain");
public static final CountryCode ITALY = new CountryCode(39, "IT", "Italy");
public static final CountryCode SWITZERLAND = new CountryCode(41, "CH", "Switzerland");
public static final CountryCode UK = new CountryCode(44, "UK", "United Kingdowm");
public static final CountryCode DENMARK = new CountryCode(45, "DK", "Denmark");
public static final CountryCode SWEDEN = new CountryCode(46, "SE", "Sweden");
public static final CountryCode NORWAY = new CountryCode(47, "NO", "Norway");
public static final CountryCode GERMANY = new CountryCode(49, "DE", "Germany");
public static final CountryCode PHILIPPINES = new CountryCode(63, "PH", "Philippines");
public static final CountryCode CHINA = new CountryCode(86, "CN", "China");
public static final CountryCode INDIA = new CountryCode(91, "IN", "India");
public static final CountryCode UNKNOWN = new CountryCode(65535, "??", "Unknown");
}

View file

@ -0,0 +1,613 @@
package jxl.biff;
import java.text.DecimalFormat;
import java.text.MessageFormat;
import java.util.Collection;
import java.util.Iterator;
import jxl.WorkbookSettings;
import jxl.biff.formula.ExternalSheet;
import jxl.biff.formula.FormulaException;
import jxl.biff.formula.FormulaParser;
import jxl.biff.formula.ParseContext;
import jxl.common.Assert;
import jxl.common.Logger;
public class DVParser {
private static Logger logger = Logger.getLogger(DVParser.class);
public static class DVType {
private int value;
private String desc;
private static DVType[] types = new DVType[0];
DVType(int v, String d) {
this.value = v;
this.desc = d;
DVType[] oldtypes = types;
types = new DVType[oldtypes.length + 1];
System.arraycopy(oldtypes, 0, types, 0, oldtypes.length);
types[oldtypes.length] = this;
}
static DVType getType(int v) {
DVType found = null;
for (int i = 0; i < types.length && found == null; i++) {
if ((types[i]).value == v)
found = types[i];
}
return found;
}
public int getValue() {
return this.value;
}
public String getDescription() {
return this.desc;
}
}
public static class ErrorStyle {
private int value;
private static ErrorStyle[] types = new ErrorStyle[0];
ErrorStyle(int v) {
this.value = v;
ErrorStyle[] oldtypes = types;
types = new ErrorStyle[oldtypes.length + 1];
System.arraycopy(oldtypes, 0, types, 0, oldtypes.length);
types[oldtypes.length] = this;
}
static ErrorStyle getErrorStyle(int v) {
ErrorStyle found = null;
for (int i = 0; i < types.length && found == null; i++) {
if ((types[i]).value == v)
found = types[i];
}
return found;
}
public int getValue() {
return this.value;
}
}
public static class Condition {
private int value;
private MessageFormat format;
private static Condition[] types = new Condition[0];
Condition(int v, String pattern) {
this.value = v;
this.format = new MessageFormat(pattern);
Condition[] oldtypes = types;
types = new Condition[oldtypes.length + 1];
System.arraycopy(oldtypes, 0, types, 0, oldtypes.length);
types[oldtypes.length] = this;
}
static Condition getCondition(int v) {
Condition found = null;
for (int i = 0; i < types.length && found == null; i++) {
if ((types[i]).value == v)
found = types[i];
}
return found;
}
public int getValue() {
return this.value;
}
public String getConditionString(String s1, String s2) {
return this.format.format(new String[] { s1, s2 });
}
}
public static final DVType ANY = new DVType(0, "any");
public static final DVType INTEGER = new DVType(1, "int");
public static final DVType DECIMAL = new DVType(2, "dec");
public static final DVType LIST = new DVType(3, "list");
public static final DVType DATE = new DVType(4, "date");
public static final DVType TIME = new DVType(5, "time");
public static final DVType TEXT_LENGTH = new DVType(6, "strlen");
public static final DVType FORMULA = new DVType(7, "form");
public static final ErrorStyle STOP = new ErrorStyle(0);
public static final ErrorStyle WARNING = new ErrorStyle(1);
public static final ErrorStyle INFO = new ErrorStyle(2);
public static final Condition BETWEEN = new Condition(0, "{0} <= x <= {1}");
public static final Condition NOT_BETWEEN = new Condition(1, "!({0} <= x <= {1}");
public static final Condition EQUAL = new Condition(2, "x == {0}");
public static final Condition NOT_EQUAL = new Condition(3, "x != {0}");
public static final Condition GREATER_THAN = new Condition(4, "x > {0}");
public static final Condition LESS_THAN = new Condition(5, "x < {0}");
public static final Condition GREATER_EQUAL = new Condition(6, "x >= {0}");
public static final Condition LESS_EQUAL = new Condition(7, "x <= {0}");
private static final int STRING_LIST_GIVEN_MASK = 128;
private static final int EMPTY_CELLS_ALLOWED_MASK = 256;
private static final int SUPPRESS_ARROW_MASK = 512;
private static final int SHOW_PROMPT_MASK = 262144;
private static final int SHOW_ERROR_MASK = 524288;
private static DecimalFormat DECIMAL_FORMAT = new DecimalFormat("#.#");
private static final int MAX_VALIDATION_LIST_LENGTH = 254;
private static final int MAX_ROWS = 65535;
private static final int MAX_COLUMNS = 255;
private DVType type;
private ErrorStyle errorStyle;
private Condition condition;
private boolean stringListGiven;
private boolean emptyCellsAllowed;
private boolean suppressArrow;
private boolean showPrompt;
private boolean showError;
private String promptTitle;
private String errorTitle;
private String promptText;
private String errorText;
private FormulaParser formula1;
private String formula1String;
private FormulaParser formula2;
private String formula2String;
private int column1;
private int row1;
private int column2;
private int row2;
private boolean extendedCellsValidation;
private boolean copied;
public DVParser(byte[] data, ExternalSheet es, WorkbookMethods nt, WorkbookSettings ws) {
Assert.verify((nt != null));
this.copied = false;
int options = IntegerHelper.getInt(data[0], data[1], data[2], data[3]);
int typeVal = options & 0xF;
this.type = DVType.getType(typeVal);
int errorStyleVal = (options & 0x70) >> 4;
this.errorStyle = ErrorStyle.getErrorStyle(errorStyleVal);
int conditionVal = (options & 0xF00000) >> 20;
this.condition = Condition.getCondition(conditionVal);
this.stringListGiven = ((options & 0x80) != 0);
this.emptyCellsAllowed = ((options & 0x100) != 0);
this.suppressArrow = ((options & 0x200) != 0);
this.showPrompt = ((options & 0x40000) != 0);
this.showError = ((options & 0x80000) != 0);
int pos = 4;
int length = IntegerHelper.getInt(data[pos], data[pos + 1]);
if (length > 0 && data[pos + 2] == 0) {
this.promptTitle = StringHelper.getString(data, length, pos + 3, ws);
pos += length + 3;
} else if (length > 0) {
this.promptTitle = StringHelper.getUnicodeString(data, length, pos + 3);
pos += length * 2 + 3;
} else {
pos += 3;
}
length = IntegerHelper.getInt(data[pos], data[pos + 1]);
if (length > 0 && data[pos + 2] == 0) {
this.errorTitle = StringHelper.getString(data, length, pos + 3, ws);
pos += length + 3;
} else if (length > 0) {
this.errorTitle = StringHelper.getUnicodeString(data, length, pos + 3);
pos += length * 2 + 3;
} else {
pos += 3;
}
length = IntegerHelper.getInt(data[pos], data[pos + 1]);
if (length > 0 && data[pos + 2] == 0) {
this.promptText = StringHelper.getString(data, length, pos + 3, ws);
pos += length + 3;
} else if (length > 0) {
this.promptText = StringHelper.getUnicodeString(data, length, pos + 3);
pos += length * 2 + 3;
} else {
pos += 3;
}
length = IntegerHelper.getInt(data[pos], data[pos + 1]);
if (length > 0 && data[pos + 2] == 0) {
this.errorText = StringHelper.getString(data, length, pos + 3, ws);
pos += length + 3;
} else if (length > 0) {
this.errorText = StringHelper.getUnicodeString(data, length, pos + 3);
pos += length * 2 + 3;
} else {
pos += 3;
}
int formula1Length = IntegerHelper.getInt(data[pos], data[pos + 1]);
pos += 4;
int formula1Pos = pos;
pos += formula1Length;
int formula2Length = IntegerHelper.getInt(data[pos], data[pos + 1]);
pos += 4;
int formula2Pos = pos;
pos += formula2Length;
pos += 2;
this.row1 = IntegerHelper.getInt(data[pos], data[pos + 1]);
pos += 2;
this.row2 = IntegerHelper.getInt(data[pos], data[pos + 1]);
pos += 2;
this.column1 = IntegerHelper.getInt(data[pos], data[pos + 1]);
pos += 2;
this.column2 = IntegerHelper.getInt(data[pos], data[pos + 1]);
pos += 2;
this.extendedCellsValidation = !(this.row1 == this.row2 && this.column1 == this.column2);
try {
EmptyCell tmprt = new EmptyCell(this.column1, this.row1);
if (formula1Length != 0) {
byte[] tokens = new byte[formula1Length];
System.arraycopy(data, formula1Pos, tokens, 0, formula1Length);
this.formula1 = new FormulaParser(tokens, tmprt, es, nt, ws, ParseContext.DATA_VALIDATION);
this.formula1.parse();
}
if (formula2Length != 0) {
byte[] tokens = new byte[formula2Length];
System.arraycopy(data, formula2Pos, tokens, 0, formula2Length);
this.formula2 = new FormulaParser(tokens, tmprt, es, nt, ws, ParseContext.DATA_VALIDATION);
this.formula2.parse();
}
} catch (FormulaException e) {
logger.warn(e.getMessage() + " for cells " + CellReferenceHelper.getCellReference(this.column1, this.row1) + "-" + CellReferenceHelper.getCellReference(this.column2, this.row2));
}
}
public DVParser(Collection strings) {
this.copied = false;
this.type = LIST;
this.errorStyle = STOP;
this.condition = BETWEEN;
this.extendedCellsValidation = false;
this.stringListGiven = true;
this.emptyCellsAllowed = true;
this.suppressArrow = false;
this.showPrompt = true;
this.showError = true;
this.promptTitle = "\000";
this.errorTitle = "\000";
this.promptText = "\000";
this.errorText = "\000";
if (strings.size() == 0)
logger.warn("no validation strings - ignoring");
Iterator i = strings.iterator();
StringBuffer formulaString = new StringBuffer();
formulaString.append(i.next().toString());
while (i.hasNext()) {
formulaString.append('\000');
formulaString.append(' ');
formulaString.append(i.next().toString());
}
if (formulaString.length() > 254) {
logger.warn("Validation list exceeds maximum number of characters - truncating");
formulaString.delete(254, formulaString.length());
}
formulaString.insert(0, '"');
formulaString.append('"');
this.formula1String = formulaString.toString();
}
public DVParser(String namedRange) {
if (namedRange.length() == 0) {
this.copied = false;
this.type = FORMULA;
this.errorStyle = STOP;
this.condition = EQUAL;
this.extendedCellsValidation = false;
this.stringListGiven = false;
this.emptyCellsAllowed = false;
this.suppressArrow = false;
this.showPrompt = true;
this.showError = true;
this.promptTitle = "\000";
this.errorTitle = "\000";
this.promptText = "\000";
this.errorText = "\000";
this.formula1String = "\"\"";
return;
}
this.copied = false;
this.type = LIST;
this.errorStyle = STOP;
this.condition = BETWEEN;
this.extendedCellsValidation = false;
this.stringListGiven = false;
this.emptyCellsAllowed = true;
this.suppressArrow = false;
this.showPrompt = true;
this.showError = true;
this.promptTitle = "\000";
this.errorTitle = "\000";
this.promptText = "\000";
this.errorText = "\000";
this.formula1String = namedRange;
}
public DVParser(int c1, int r1, int c2, int r2) {
this.copied = false;
this.type = LIST;
this.errorStyle = STOP;
this.condition = BETWEEN;
this.extendedCellsValidation = false;
this.stringListGiven = false;
this.emptyCellsAllowed = true;
this.suppressArrow = false;
this.showPrompt = true;
this.showError = true;
this.promptTitle = "\000";
this.errorTitle = "\000";
this.promptText = "\000";
this.errorText = "\000";
StringBuffer formulaString = new StringBuffer();
CellReferenceHelper.getCellReference(c1, r1, formulaString);
formulaString.append(':');
CellReferenceHelper.getCellReference(c2, r2, formulaString);
this.formula1String = formulaString.toString();
}
public DVParser(double val1, double val2, Condition c) {
this.copied = false;
this.type = DECIMAL;
this.errorStyle = STOP;
this.condition = c;
this.extendedCellsValidation = false;
this.stringListGiven = false;
this.emptyCellsAllowed = true;
this.suppressArrow = false;
this.showPrompt = true;
this.showError = true;
this.promptTitle = "\000";
this.errorTitle = "\000";
this.promptText = "\000";
this.errorText = "\000";
this.formula1String = DECIMAL_FORMAT.format(val1);
if (!Double.isNaN(val2))
this.formula2String = DECIMAL_FORMAT.format(val2);
}
public DVParser(DVParser copy) {
this.copied = true;
this.type = copy.type;
this.errorStyle = copy.errorStyle;
this.condition = copy.condition;
this.stringListGiven = copy.stringListGiven;
this.emptyCellsAllowed = copy.emptyCellsAllowed;
this.suppressArrow = copy.suppressArrow;
this.showPrompt = copy.showPrompt;
this.showError = copy.showError;
this.promptTitle = copy.promptTitle;
this.promptText = copy.promptText;
this.errorTitle = copy.errorTitle;
this.errorText = copy.errorText;
this.extendedCellsValidation = copy.extendedCellsValidation;
this.row1 = copy.row1;
this.row2 = copy.row2;
this.column1 = copy.column1;
this.column2 = copy.column2;
if (copy.formula1String != null) {
this.formula1String = copy.formula1String;
this.formula2String = copy.formula2String;
} else {
try {
this.formula1String = copy.formula1.getFormula();
this.formula2String = (copy.formula2 != null) ? copy.formula2.getFormula() : null;
} catch (FormulaException e) {
logger.warn("Cannot parse validation formula: " + e.getMessage());
}
}
}
public byte[] getData() {
byte[] f1Bytes = (this.formula1 != null) ? this.formula1.getBytes() : new byte[0];
byte[] f2Bytes = (this.formula2 != null) ? this.formula2.getBytes() : new byte[0];
int dataLength = 4 + this.promptTitle.length() * 2 + 3 + this.errorTitle.length() * 2 + 3 + this.promptText.length() * 2 + 3 + this.errorText.length() * 2 + 3 + f1Bytes.length + 2 + f2Bytes.length + 2 + 4 + 10;
byte[] data = new byte[dataLength];
int pos = 0;
int options = 0;
options |= this.type.getValue();
options |= this.errorStyle.getValue() << 4;
options |= this.condition.getValue() << 20;
if (this.stringListGiven)
options |= 0x80;
if (this.emptyCellsAllowed)
options |= 0x100;
if (this.suppressArrow)
options |= 0x200;
if (this.showPrompt)
options |= 0x40000;
if (this.showError)
options |= 0x80000;
IntegerHelper.getFourBytes(options, data, pos);
pos += 4;
IntegerHelper.getTwoBytes(this.promptTitle.length(), data, pos);
pos += 2;
data[pos] = 1;
pos++;
StringHelper.getUnicodeBytes(this.promptTitle, data, pos);
pos += this.promptTitle.length() * 2;
IntegerHelper.getTwoBytes(this.errorTitle.length(), data, pos);
pos += 2;
data[pos] = 1;
pos++;
StringHelper.getUnicodeBytes(this.errorTitle, data, pos);
pos += this.errorTitle.length() * 2;
IntegerHelper.getTwoBytes(this.promptText.length(), data, pos);
pos += 2;
data[pos] = 1;
pos++;
StringHelper.getUnicodeBytes(this.promptText, data, pos);
pos += this.promptText.length() * 2;
IntegerHelper.getTwoBytes(this.errorText.length(), data, pos);
pos += 2;
data[pos] = 1;
pos++;
StringHelper.getUnicodeBytes(this.errorText, data, pos);
pos += this.errorText.length() * 2;
IntegerHelper.getTwoBytes(f1Bytes.length, data, pos);
pos += 4;
System.arraycopy(f1Bytes, 0, data, pos, f1Bytes.length);
pos += f1Bytes.length;
IntegerHelper.getTwoBytes(f2Bytes.length, data, pos);
pos += 4;
System.arraycopy(f2Bytes, 0, data, pos, f2Bytes.length);
pos += f2Bytes.length;
IntegerHelper.getTwoBytes(1, data, pos);
pos += 2;
IntegerHelper.getTwoBytes(this.row1, data, pos);
pos += 2;
IntegerHelper.getTwoBytes(this.row2, data, pos);
pos += 2;
IntegerHelper.getTwoBytes(this.column1, data, pos);
pos += 2;
IntegerHelper.getTwoBytes(this.column2, data, pos);
pos += 2;
return data;
}
public void insertRow(int row) {
if (this.formula1 != null)
this.formula1.rowInserted(0, row, true);
if (this.formula2 != null)
this.formula2.rowInserted(0, row, true);
if (this.row1 >= row)
this.row1++;
if (this.row2 >= row && this.row2 != 65535)
this.row2++;
}
public void insertColumn(int col) {
if (this.formula1 != null)
this.formula1.columnInserted(0, col, true);
if (this.formula2 != null)
this.formula2.columnInserted(0, col, true);
if (this.column1 >= col)
this.column1++;
if (this.column2 >= col && this.column2 != 255)
this.column2++;
}
public void removeRow(int row) {
if (this.formula1 != null)
this.formula1.rowRemoved(0, row, true);
if (this.formula2 != null)
this.formula2.rowRemoved(0, row, true);
if (this.row1 > row)
this.row1--;
if (this.row2 >= row)
this.row2--;
}
public void removeColumn(int col) {
if (this.formula1 != null)
this.formula1.columnRemoved(0, col, true);
if (this.formula2 != null)
this.formula2.columnRemoved(0, col, true);
if (this.column1 > col)
this.column1--;
if (this.column2 >= col && this.column2 != 255)
this.column2--;
}
public int getFirstColumn() {
return this.column1;
}
public int getLastColumn() {
return this.column2;
}
public int getFirstRow() {
return this.row1;
}
public int getLastRow() {
return this.row2;
}
String getValidationFormula() throws FormulaException {
if (this.type == LIST)
return this.formula1.getFormula();
String s1 = this.formula1.getFormula();
String s2 = (this.formula2 != null) ? this.formula2.getFormula() : null;
return this.condition.getConditionString(s1, s2) + "; x " + this.type.getDescription();
}
public void setCell(int col, int row, ExternalSheet es, WorkbookMethods nt, WorkbookSettings ws) throws FormulaException {
if (this.extendedCellsValidation)
return;
this.row1 = row;
this.row2 = row;
this.column1 = col;
this.column2 = col;
this.formula1 = new FormulaParser(this.formula1String, es, nt, ws, ParseContext.DATA_VALIDATION);
this.formula1.parse();
if (this.formula2String != null) {
this.formula2 = new FormulaParser(this.formula2String, es, nt, ws, ParseContext.DATA_VALIDATION);
this.formula2.parse();
}
}
public void extendCellValidation(int cols, int rows) {
this.row2 = this.row1 + rows;
this.column2 = this.column1 + cols;
this.extendedCellsValidation = true;
}
public boolean extendedCellsValidation() {
return this.extendedCellsValidation;
}
public boolean copied() {
return this.copied;
}
}

View file

@ -0,0 +1,69 @@
package jxl.biff;
import jxl.common.Logger;
public class DValParser {
private static Logger logger = Logger.getLogger(DValParser.class);
private static int PROMPT_BOX_VISIBLE_MASK = 1;
private static int PROMPT_BOX_AT_CELL_MASK = 2;
private static int VALIDITY_DATA_CACHED_MASK = 4;
private boolean promptBoxVisible;
private boolean promptBoxAtCell;
private boolean validityDataCached;
private int numDVRecords;
private int objectId;
public DValParser(byte[] data) {
int options = IntegerHelper.getInt(data[0], data[1]);
this.promptBoxVisible = ((options & PROMPT_BOX_VISIBLE_MASK) != 0);
this.promptBoxAtCell = ((options & PROMPT_BOX_AT_CELL_MASK) != 0);
this.validityDataCached = ((options & VALIDITY_DATA_CACHED_MASK) != 0);
this.objectId = IntegerHelper.getInt(data[10], data[11], data[12], data[13]);
this.numDVRecords = IntegerHelper.getInt(data[14], data[15], data[16], data[17]);
}
public DValParser(int objid, int num) {
this.objectId = objid;
this.numDVRecords = num;
this.validityDataCached = true;
}
public byte[] getData() {
byte[] data = new byte[18];
int options = 0;
if (this.promptBoxVisible)
options |= PROMPT_BOX_VISIBLE_MASK;
if (this.promptBoxAtCell)
options |= PROMPT_BOX_AT_CELL_MASK;
if (this.validityDataCached)
options |= VALIDITY_DATA_CACHED_MASK;
IntegerHelper.getTwoBytes(options, data, 0);
IntegerHelper.getFourBytes(this.objectId, data, 10);
IntegerHelper.getFourBytes(this.numDVRecords, data, 14);
return data;
}
public void dvRemoved() {
this.numDVRecords--;
}
public int getNumberOfDVRecords() {
return this.numDVRecords;
}
public int getObjectId() {
return this.objectId;
}
public void dvAdded() {
this.numDVRecords++;
}
}

View file

@ -0,0 +1,167 @@
package jxl.biff;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import jxl.WorkbookSettings;
import jxl.biff.formula.ExternalSheet;
import jxl.common.Assert;
import jxl.common.Logger;
import jxl.write.biff.File;
public class DataValidation {
private static Logger logger = Logger.getLogger(DataValidation.class);
private DataValidityListRecord validityList;
private ArrayList validitySettings;
private WorkbookMethods workbook;
private ExternalSheet externalSheet;
private WorkbookSettings workbookSettings;
private int comboBoxObjectId;
private boolean copied;
public static final int DEFAULT_OBJECT_ID = -1;
private static final int MAX_NO_OF_VALIDITY_SETTINGS = 65533;
public DataValidation(DataValidityListRecord dvlr) {
this.validityList = dvlr;
this.validitySettings = new ArrayList(this.validityList.getNumberOfSettings());
this.copied = false;
}
public DataValidation(int objId, ExternalSheet es, WorkbookMethods wm, WorkbookSettings ws) {
this.workbook = wm;
this.externalSheet = es;
this.workbookSettings = ws;
this.validitySettings = new ArrayList();
this.comboBoxObjectId = objId;
this.copied = false;
}
public DataValidation(DataValidation dv, ExternalSheet es, WorkbookMethods wm, WorkbookSettings ws) {
this.workbook = wm;
this.externalSheet = es;
this.workbookSettings = ws;
this.copied = true;
this.validityList = new DataValidityListRecord(dv.getDataValidityList());
this.validitySettings = new ArrayList();
DataValiditySettingsRecord[] settings = dv.getDataValiditySettings();
for (int i = 0; i < settings.length; i++)
this.validitySettings.add(new DataValiditySettingsRecord(settings[i], this.externalSheet, this.workbook, this.workbookSettings));
}
public void add(DataValiditySettingsRecord dvsr) {
this.validitySettings.add(dvsr);
dvsr.setDataValidation(this);
if (this.copied) {
Assert.verify((this.validityList != null));
this.validityList.dvAdded();
}
}
public DataValidityListRecord getDataValidityList() {
return this.validityList;
}
public DataValiditySettingsRecord[] getDataValiditySettings() {
DataValiditySettingsRecord[] dvlr = new DataValiditySettingsRecord[0];
return (DataValiditySettingsRecord[])this.validitySettings.toArray(dvlr);
}
public void write(File outputFile) throws IOException {
if (this.validitySettings.size() > 65533) {
logger.warn("Maximum number of data validations exceeded - truncating...");
this.validitySettings = new ArrayList(this.validitySettings.subList(0, 65532));
Assert.verify((this.validitySettings.size() <= 65533));
}
if (this.validityList == null) {
DValParser dvp = new DValParser(this.comboBoxObjectId, this.validitySettings.size());
this.validityList = new DataValidityListRecord(dvp);
}
if (!this.validityList.hasDVRecords())
return;
outputFile.write(this.validityList);
for (DataValiditySettingsRecord dvsr : (Iterable<DataValiditySettingsRecord>)this.validitySettings)
outputFile.write(dvsr);
}
public void insertRow(int row) {
for (DataValiditySettingsRecord dv : (Iterable<DataValiditySettingsRecord>)this.validitySettings)
dv.insertRow(row);
}
public void removeRow(int row) {
for (Iterator<DataValiditySettingsRecord> i = this.validitySettings.iterator(); i.hasNext(); ) {
DataValiditySettingsRecord dv = i.next();
if (dv.getFirstRow() == row && dv.getLastRow() == row) {
i.remove();
this.validityList.dvRemoved();
continue;
}
dv.removeRow(row);
}
}
public void insertColumn(int col) {
for (DataValiditySettingsRecord dv : (Iterable<DataValiditySettingsRecord>)this.validitySettings)
dv.insertColumn(col);
}
public void removeColumn(int col) {
for (Iterator<DataValiditySettingsRecord> i = this.validitySettings.iterator(); i.hasNext(); ) {
DataValiditySettingsRecord dv = i.next();
if (dv.getFirstColumn() == col && dv.getLastColumn() == col) {
i.remove();
this.validityList.dvRemoved();
continue;
}
dv.removeColumn(col);
}
}
public void removeDataValidation(int col, int row) {
for (Iterator<DataValiditySettingsRecord> i = this.validitySettings.iterator(); i.hasNext(); ) {
DataValiditySettingsRecord dv = i.next();
if (dv.getFirstColumn() == col && dv.getLastColumn() == col && dv.getFirstRow() == row && dv.getLastRow() == row) {
i.remove();
this.validityList.dvRemoved();
break;
}
}
}
public void removeSharedDataValidation(int col1, int row1, int col2, int row2) {
for (Iterator<DataValiditySettingsRecord> i = this.validitySettings.iterator(); i.hasNext(); ) {
DataValiditySettingsRecord dv = i.next();
if (dv.getFirstColumn() == col1 && dv.getLastColumn() == col2 && dv.getFirstRow() == row1 && dv.getLastRow() == row2) {
i.remove();
this.validityList.dvRemoved();
break;
}
}
}
public DataValiditySettingsRecord getDataValiditySettings(int col, int row) {
boolean found = false;
DataValiditySettingsRecord foundRecord = null;
for (Iterator<DataValiditySettingsRecord> i = this.validitySettings.iterator(); i.hasNext() && !found; ) {
DataValiditySettingsRecord dvsr = i.next();
if (dvsr.getFirstColumn() == col && dvsr.getFirstRow() == row) {
found = true;
foundRecord = dvsr;
}
}
return foundRecord;
}
public int getComboBoxObjectId() {
return this.comboBoxObjectId;
}
}

View file

@ -0,0 +1,67 @@
package jxl.biff;
import jxl.common.Logger;
import jxl.read.biff.Record;
public class DataValidityListRecord extends WritableRecordData {
private static Logger logger = Logger.getLogger(DataValidityListRecord.class);
private int numSettings;
private int objectId;
private DValParser dvalParser;
private byte[] data;
public DataValidityListRecord(Record t) {
super(t);
this.data = getRecord().getData();
this.objectId = IntegerHelper.getInt(this.data[10], this.data[11], this.data[12], this.data[13]);
this.numSettings = IntegerHelper.getInt(this.data[14], this.data[15], this.data[16], this.data[17]);
}
public DataValidityListRecord(DValParser dval) {
super(Type.DVAL);
this.dvalParser = dval;
}
DataValidityListRecord(DataValidityListRecord dvlr) {
super(Type.DVAL);
this.data = dvlr.getData();
}
int getNumberOfSettings() {
return this.numSettings;
}
public byte[] getData() {
if (this.dvalParser == null)
return this.data;
return this.dvalParser.getData();
}
void dvRemoved() {
if (this.dvalParser == null)
this.dvalParser = new DValParser(this.data);
this.dvalParser.dvRemoved();
}
void dvAdded() {
if (this.dvalParser == null)
this.dvalParser = new DValParser(this.data);
this.dvalParser.dvAdded();
}
public boolean hasDVRecords() {
if (this.dvalParser == null)
return true;
return (this.dvalParser.getNumberOfDVRecords() > 0);
}
public int getObjectId() {
if (this.dvalParser == null)
return this.objectId;
return this.dvalParser.getObjectId();
}
}

View file

@ -0,0 +1,131 @@
package jxl.biff;
import jxl.WorkbookSettings;
import jxl.biff.formula.ExternalSheet;
import jxl.biff.formula.FormulaException;
import jxl.common.Assert;
import jxl.common.Logger;
import jxl.read.biff.Record;
public class DataValiditySettingsRecord extends WritableRecordData {
private static Logger logger = Logger.getLogger(DataValiditySettingsRecord.class);
private byte[] data;
private DVParser dvParser;
private WorkbookMethods workbook;
private ExternalSheet externalSheet;
private WorkbookSettings workbookSettings;
private DataValidation dataValidation;
public DataValiditySettingsRecord(Record t, ExternalSheet es, WorkbookMethods wm, WorkbookSettings ws) {
super(t);
this.data = t.getData();
this.externalSheet = es;
this.workbook = wm;
this.workbookSettings = ws;
}
DataValiditySettingsRecord(DataValiditySettingsRecord dvsr) {
super(Type.DV);
this.data = dvsr.getData();
}
DataValiditySettingsRecord(DataValiditySettingsRecord dvsr, ExternalSheet es, WorkbookMethods w, WorkbookSettings ws) {
super(Type.DV);
this.workbook = w;
this.externalSheet = es;
this.workbookSettings = ws;
Assert.verify((w != null));
Assert.verify((es != null));
this.data = new byte[dvsr.data.length];
System.arraycopy(dvsr.data, 0, this.data, 0, this.data.length);
}
public DataValiditySettingsRecord(DVParser dvp) {
super(Type.DV);
this.dvParser = dvp;
}
private void initialize() {
if (this.dvParser == null)
this.dvParser = new DVParser(this.data, this.externalSheet, this.workbook, this.workbookSettings);
}
public byte[] getData() {
if (this.dvParser == null)
return this.data;
return this.dvParser.getData();
}
public void insertRow(int row) {
if (this.dvParser == null)
initialize();
this.dvParser.insertRow(row);
}
public void removeRow(int row) {
if (this.dvParser == null)
initialize();
this.dvParser.removeRow(row);
}
public void insertColumn(int col) {
if (this.dvParser == null)
initialize();
this.dvParser.insertColumn(col);
}
public void removeColumn(int col) {
if (this.dvParser == null)
initialize();
this.dvParser.removeColumn(col);
}
public int getFirstColumn() {
if (this.dvParser == null)
initialize();
return this.dvParser.getFirstColumn();
}
public int getLastColumn() {
if (this.dvParser == null)
initialize();
return this.dvParser.getLastColumn();
}
public int getFirstRow() {
if (this.dvParser == null)
initialize();
return this.dvParser.getFirstRow();
}
public int getLastRow() {
if (this.dvParser == null)
initialize();
return this.dvParser.getLastRow();
}
void setDataValidation(DataValidation dv) {
this.dataValidation = dv;
}
DVParser getDVParser() {
return this.dvParser;
}
public String getValidationFormula() {
try {
if (this.dvParser == null)
initialize();
return this.dvParser.getValidationFormula();
} catch (FormulaException e) {
logger.warn("Cannot read drop down range " + e.getMessage());
return "";
}
}
}

View file

@ -0,0 +1,11 @@
package jxl.biff;
public interface DisplayFormat {
int getFormatIndex();
boolean isInitialized();
void initialize(int paramInt);
boolean isBuiltIn();
}

View file

@ -0,0 +1,26 @@
package jxl.biff;
public class DoubleHelper {
public static double getIEEEDouble(byte[] data, int pos) {
int num1 = IntegerHelper.getInt(data[pos], data[pos + 1], data[pos + 2], data[pos + 3]);
int num2 = IntegerHelper.getInt(data[pos + 4], data[pos + 5], data[pos + 6], data[pos + 7]);
boolean negative = ((num2 & Integer.MIN_VALUE) != 0);
long val = (long)(num2 & Integer.MAX_VALUE) * 4294967296L + ((num1 < 0) ? (4294967296L + (long)num1) : (long)num1);
double value = Double.longBitsToDouble(val);
if (negative)
value = -value;
return value;
}
public static void getIEEEBytes(double d, byte[] target, int pos) {
long val = Double.doubleToLongBits(d);
target[pos] = (byte)(int)(val & 0xFFL);
target[pos + 1] = (byte)(int)((val & 0xFF00L) >> 8L);
target[pos + 2] = (byte)(int)((val & 0xFF0000L) >> 16L);
target[pos + 3] = (byte)(int)((val & 0xFFFFFFFFFF000000L) >> 24L);
target[pos + 4] = (byte)(int)((val & 0xFF00000000L) >> 32L);
target[pos + 5] = (byte)(int)((val & 0xFF0000000000L) >> 40L);
target[pos + 6] = (byte)(int)((val & 0xFF000000000000L) >> 48L);
target[pos + 7] = (byte)(int)((val & 0xFF00000000000000L) >> 56L);
}
}

View file

@ -0,0 +1,74 @@
package jxl.biff;
import jxl.CellFeatures;
import jxl.CellType;
import jxl.format.Alignment;
import jxl.format.Border;
import jxl.format.BorderLineStyle;
import jxl.format.CellFormat;
import jxl.format.VerticalAlignment;
import jxl.write.WritableCell;
import jxl.write.WritableCellFeatures;
public class EmptyCell implements WritableCell {
private int row;
private int col;
public EmptyCell(int c, int r) {
this.row = r;
this.col = c;
}
public int getRow() {
return this.row;
}
public int getColumn() {
return this.col;
}
public CellType getType() {
return CellType.EMPTY;
}
public String getContents() {
return "";
}
public CellFormat getCellFormat() {
return null;
}
public void setHidden(boolean flag) {}
public void setLocked(boolean flag) {}
public void setAlignment(Alignment align) {}
public void setVerticalAlignment(VerticalAlignment valign) {}
public void setBorder(Border border, BorderLineStyle line) {}
public void setCellFormat(CellFormat cf) {}
public void setCellFormat(jxl.CellFormat cf) {}
public boolean isHidden() {
return false;
}
public WritableCell copyTo(int c, int r) {
return new EmptyCell(c, r);
}
public CellFeatures getCellFeatures() {
return null;
}
public WritableCellFeatures getWritableCellFeatures() {
return null;
}
public void setCellFeatures(WritableCellFeatures wcf) {}
}

View file

@ -0,0 +1,73 @@
package jxl.biff;
import jxl.WorkbookSettings;
import jxl.common.Logger;
public class EncodedURLHelper {
private static Logger logger = Logger.getLogger(EncodedURLHelper.class);
private static byte msDosDriveLetter = 1;
private static byte sameDrive = 2;
private static byte endOfSubdirectory = 3;
private static byte parentDirectory = 4;
private static byte unencodedUrl = 5;
public static byte[] getEncodedURL(String s, WorkbookSettings ws) {
if (s.startsWith("http:"))
return getURL(s, ws);
return getFile(s, ws);
}
private static byte[] getFile(String s, WorkbookSettings ws) {
ByteArray byteArray = new ByteArray();
int pos = 0;
if (s.charAt(1) == ':') {
byteArray.add(msDosDriveLetter);
byteArray.add((byte)s.charAt(0));
pos = 2;
} else if (s.charAt(pos) == '\\' || s.charAt(pos) == '/') {
byteArray.add(sameDrive);
}
while (s.charAt(pos) == '\\' || s.charAt(pos) == '/')
pos++;
while (pos < s.length()) {
int nextSepIndex1 = s.indexOf('/', pos);
int nextSepIndex2 = s.indexOf('\\', pos);
int nextSepIndex = 0;
String nextFileNameComponent = null;
if (nextSepIndex1 != -1 && nextSepIndex2 != -1) {
nextSepIndex = Math.min(nextSepIndex1, nextSepIndex2);
} else if (nextSepIndex1 == -1 || nextSepIndex2 == -1) {
nextSepIndex = Math.max(nextSepIndex1, nextSepIndex2);
}
if (nextSepIndex == -1) {
nextFileNameComponent = s.substring(pos);
pos = s.length();
} else {
nextFileNameComponent = s.substring(pos, nextSepIndex);
pos = nextSepIndex + 1;
}
if (!nextFileNameComponent.equals("."))
if (nextFileNameComponent.equals("..")) {
byteArray.add(parentDirectory);
} else {
byteArray.add(StringHelper.getBytes(nextFileNameComponent, ws));
}
if (pos < s.length())
byteArray.add(endOfSubdirectory);
}
return byteArray.getBytes();
}
private static byte[] getURL(String s, WorkbookSettings ws) {
ByteArray byteArray = new ByteArray();
byteArray.add(unencodedUrl);
byteArray.add((byte)s.length());
byteArray.add(StringHelper.getBytes(s, ws));
return byteArray.getBytes();
}
}

View file

@ -0,0 +1,18 @@
package jxl.biff;
import jxl.common.Logger;
import jxl.read.biff.Record;
public class FilterModeRecord extends WritableRecordData {
private static Logger logger = Logger.getLogger(FilterModeRecord.class);
public FilterModeRecord(Record t) {
super(t);
}
private byte[] data = getRecord().getData();
public byte[] getData() {
return this.data;
}
}

View file

@ -0,0 +1,234 @@
package jxl.biff;
import jxl.WorkbookSettings;
import jxl.common.Assert;
import jxl.common.Logger;
import jxl.format.Colour;
import jxl.format.Font;
import jxl.format.ScriptStyle;
import jxl.format.UnderlineStyle;
import jxl.read.biff.Record;
public class FontRecord extends WritableRecordData implements Font {
private static Logger logger = Logger.getLogger(FontRecord.class);
private int pointHeight;
private int colourIndex;
private int boldWeight;
private int scriptStyle;
private int underlineStyle;
private byte fontFamily;
private byte characterSet;
private boolean italic;
private boolean struckout;
private String name;
private boolean initialized;
private int fontIndex;
private static class Biff7 {
private Biff7() {}
}
public static final Biff7 biff7 = new Biff7();
private static final int EXCEL_UNITS_PER_POINT = 20;
protected FontRecord(String fn, int ps, int bold, boolean it, int us, int ci, int ss) {
super(Type.FONT);
this.boldWeight = bold;
this.underlineStyle = us;
this.name = fn;
this.pointHeight = ps;
this.italic = it;
this.scriptStyle = ss;
this.colourIndex = ci;
this.initialized = false;
this.struckout = false;
}
public FontRecord(Record t, WorkbookSettings ws) {
super(t);
byte[] data = getRecord().getData();
this.pointHeight = IntegerHelper.getInt(data[0], data[1]) / 20;
this.colourIndex = IntegerHelper.getInt(data[4], data[5]);
this.boldWeight = IntegerHelper.getInt(data[6], data[7]);
this.scriptStyle = IntegerHelper.getInt(data[8], data[9]);
this.underlineStyle = data[10];
this.fontFamily = data[11];
this.characterSet = data[12];
this.initialized = false;
if ((data[2] & 0x2) != 0)
this.italic = true;
if ((data[2] & 0x8) != 0)
this.struckout = true;
int numChars = data[14];
if (data[15] == 0) {
this.name = StringHelper.getString(data, numChars, 16, ws);
} else if (data[15] == 1) {
this.name = StringHelper.getUnicodeString(data, numChars, 16);
} else {
this.name = StringHelper.getString(data, numChars, 15, ws);
}
}
public FontRecord(Record t, WorkbookSettings ws, Biff7 dummy) {
super(t);
byte[] data = getRecord().getData();
this.pointHeight = IntegerHelper.getInt(data[0], data[1]) / 20;
this.colourIndex = IntegerHelper.getInt(data[4], data[5]);
this.boldWeight = IntegerHelper.getInt(data[6], data[7]);
this.scriptStyle = IntegerHelper.getInt(data[8], data[9]);
this.underlineStyle = data[10];
this.fontFamily = data[11];
this.initialized = false;
if ((data[2] & 0x2) != 0)
this.italic = true;
if ((data[2] & 0x8) != 0)
this.struckout = true;
int numChars = data[14];
this.name = StringHelper.getString(data, numChars, 15, ws);
}
protected FontRecord(Font f) {
super(Type.FONT);
Assert.verify((f != null));
this.pointHeight = f.getPointSize();
this.colourIndex = f.getColour().getValue();
this.boldWeight = f.getBoldWeight();
this.scriptStyle = f.getScriptStyle().getValue();
this.underlineStyle = f.getUnderlineStyle().getValue();
this.italic = f.isItalic();
this.name = f.getName();
this.struckout = f.isStruckout();
this.initialized = false;
}
public byte[] getData() {
byte[] data = new byte[16 + this.name.length() * 2];
IntegerHelper.getTwoBytes(this.pointHeight * 20, data, 0);
if (this.italic)
data[2] = (byte)(data[2] | 0x2);
if (this.struckout)
data[2] = (byte)(data[2] | 0x8);
IntegerHelper.getTwoBytes(this.colourIndex, data, 4);
IntegerHelper.getTwoBytes(this.boldWeight, data, 6);
IntegerHelper.getTwoBytes(this.scriptStyle, data, 8);
data[10] = (byte)this.underlineStyle;
data[11] = this.fontFamily;
data[12] = this.characterSet;
data[13] = 0;
data[14] = (byte)this.name.length();
data[15] = 1;
StringHelper.getUnicodeBytes(this.name, data, 16);
return data;
}
public final boolean isInitialized() {
return this.initialized;
}
public final void initialize(int pos) {
this.fontIndex = pos;
this.initialized = true;
}
public final void uninitialize() {
this.initialized = false;
}
public final int getFontIndex() {
return this.fontIndex;
}
protected void setFontPointSize(int ps) {
Assert.verify(!this.initialized);
this.pointHeight = ps;
}
public int getPointSize() {
return this.pointHeight;
}
protected void setFontBoldStyle(int bs) {
Assert.verify(!this.initialized);
this.boldWeight = bs;
}
public int getBoldWeight() {
return this.boldWeight;
}
protected void setFontItalic(boolean i) {
Assert.verify(!this.initialized);
this.italic = i;
}
public boolean isItalic() {
return this.italic;
}
protected void setFontUnderlineStyle(int us) {
Assert.verify(!this.initialized);
this.underlineStyle = us;
}
public UnderlineStyle getUnderlineStyle() {
return UnderlineStyle.getStyle(this.underlineStyle);
}
protected void setFontColour(int c) {
Assert.verify(!this.initialized);
this.colourIndex = c;
}
public Colour getColour() {
return Colour.getInternalColour(this.colourIndex);
}
protected void setFontScriptStyle(int ss) {
Assert.verify(!this.initialized);
this.scriptStyle = ss;
}
public ScriptStyle getScriptStyle() {
return ScriptStyle.getStyle(this.scriptStyle);
}
public String getName() {
return this.name;
}
public int hashCode() {
return this.name.hashCode();
}
public boolean equals(Object o) {
if (o == this)
return true;
if (!(o instanceof FontRecord))
return false;
FontRecord font = (FontRecord)o;
if (this.pointHeight == font.pointHeight && this.colourIndex == font.colourIndex && this.boldWeight == font.boldWeight && this.scriptStyle == font.scriptStyle && this.underlineStyle == font.underlineStyle && this.italic == font.italic && this.struckout == font.struckout && this.fontFamily == font.fontFamily && this.characterSet == font.characterSet && this.name.equals(font.name))
return true;
return false;
}
public boolean isStruckout() {
return this.struckout;
}
protected void setFontStruckout(boolean os) {
this.struckout = os;
}
}

View file

@ -0,0 +1,79 @@
package jxl.biff;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import jxl.common.Assert;
import jxl.write.biff.File;
public class Fonts {
private ArrayList fonts = new ArrayList();
private static final int numDefaultFonts = 4;
public void addFont(FontRecord f) {
if (!f.isInitialized()) {
int pos = this.fonts.size();
if (pos >= 4)
pos++;
f.initialize(pos);
this.fonts.add(f);
}
}
public FontRecord getFont(int index) {
if (index > 4)
index--;
return this.fonts.get(index);
}
public void write(File outputFile) throws IOException {
Iterator<FontRecord> i = this.fonts.iterator();
FontRecord font = null;
while (i.hasNext()) {
font = i.next();
outputFile.write(font);
}
}
IndexMapping rationalize() {
IndexMapping mapping = new IndexMapping(this.fonts.size() + 1);
ArrayList<FontRecord> newfonts = new ArrayList();
FontRecord fr = null;
int numremoved = 0;
for (int i = 0; i < 4; i++) {
fr = this.fonts.get(i);
newfonts.add(fr);
mapping.setMapping(fr.getFontIndex(), fr.getFontIndex());
}
Iterator<FontRecord> it = null;
FontRecord fr2 = null;
boolean duplicate = false;
for (int j = 4; j < this.fonts.size(); j++) {
fr = this.fonts.get(j);
duplicate = false;
it = newfonts.iterator();
while (it.hasNext() && !duplicate) {
fr2 = it.next();
if (fr.equals(fr2)) {
duplicate = true;
mapping.setMapping(fr.getFontIndex(), mapping.getNewIndex(fr2.getFontIndex()));
numremoved++;
}
}
if (!duplicate) {
newfonts.add(fr);
int newindex = fr.getFontIndex() - numremoved;
Assert.verify((newindex > 4));
mapping.setMapping(fr.getFontIndex(), newindex);
}
}
it = newfonts.iterator();
while (it.hasNext()) {
fr = it.next();
fr.initialize(mapping.getNewIndex(fr.getFontIndex()));
}
this.fonts = newfonts;
return mapping;
}
}

View file

@ -0,0 +1,304 @@
package jxl.biff;
import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import jxl.WorkbookSettings;
import jxl.common.Logger;
import jxl.format.Format;
import jxl.read.biff.Record;
public class FormatRecord extends WritableRecordData implements DisplayFormat, Format {
public static Logger logger = Logger.getLogger(FormatRecord.class);
private boolean initialized;
private byte[] data;
private int indexCode;
private String formatString;
private boolean date;
private boolean number;
private java.text.Format format;
private static String[] dateStrings = new String[] { "dd", "mm", "yy", "hh", "ss", "m/", "/d" };
private static class BiffType {
private BiffType() {}
}
public static final BiffType biff8 = new BiffType();
public static final BiffType biff7 = new BiffType();
FormatRecord(String fmt, int refno) {
super(Type.FORMAT);
this.formatString = fmt;
this.indexCode = refno;
this.initialized = true;
}
protected FormatRecord() {
super(Type.FORMAT);
this.initialized = false;
}
protected FormatRecord(FormatRecord fr) {
super(Type.FORMAT);
this.initialized = false;
this.formatString = fr.formatString;
this.date = fr.date;
this.number = fr.number;
}
public FormatRecord(Record t, WorkbookSettings ws, BiffType biffType) {
super(t);
byte[] data = getRecord().getData();
this.indexCode = IntegerHelper.getInt(data[0], data[1]);
this.initialized = true;
if (biffType == biff8) {
int numchars = IntegerHelper.getInt(data[2], data[3]);
if (data[4] == 0) {
this.formatString = StringHelper.getString(data, numchars, 5, ws);
} else {
this.formatString = StringHelper.getUnicodeString(data, numchars, 5);
}
} else {
int numchars = data[2];
byte[] chars = new byte[numchars];
System.arraycopy(data, 3, chars, 0, chars.length);
this.formatString = new String(chars);
}
this.date = false;
this.number = false;
for (int i = 0; i < dateStrings.length; i++) {
String dateString = dateStrings[i];
if (this.formatString.indexOf(dateString) != -1 || this.formatString.indexOf(dateString.toUpperCase()) != -1) {
this.date = true;
break;
}
}
if (!this.date)
if (this.formatString.indexOf('#') != -1 || this.formatString.indexOf('0') != -1)
this.number = true;
}
public byte[] getData() {
this.data = new byte[this.formatString.length() * 2 + 3 + 2];
IntegerHelper.getTwoBytes(this.indexCode, this.data, 0);
IntegerHelper.getTwoBytes(this.formatString.length(), this.data, 2);
this.data[4] = 1;
StringHelper.getUnicodeBytes(this.formatString, this.data, 5);
return this.data;
}
public int getFormatIndex() {
return this.indexCode;
}
public boolean isInitialized() {
return this.initialized;
}
public void initialize(int pos) {
this.indexCode = pos;
this.initialized = true;
}
protected final String replace(String input, String search, String replace) {
String fmtstr = input;
int pos = fmtstr.indexOf(search);
while (pos != -1) {
StringBuffer tmp = new StringBuffer(fmtstr.substring(0, pos));
tmp.append(replace);
tmp.append(fmtstr.substring(pos + search.length()));
fmtstr = tmp.toString();
pos = fmtstr.indexOf(search);
}
return fmtstr;
}
protected final void setFormatString(String s) {
this.formatString = s;
}
public final boolean isDate() {
return this.date;
}
public final boolean isNumber() {
return this.number;
}
public final NumberFormat getNumberFormat() {
if (this.format != null && this.format instanceof NumberFormat)
return (NumberFormat)this.format;
try {
String fs = this.formatString;
fs = replace(fs, "E+", "E");
fs = replace(fs, "_)", "");
fs = replace(fs, "_", "");
fs = replace(fs, "[Red]", "");
fs = replace(fs, "\\", "");
this.format = new DecimalFormat(fs);
} catch (IllegalArgumentException e) {
this.format = new DecimalFormat("#.###");
}
return (NumberFormat)this.format;
}
public final DateFormat getDateFormat() {
if (this.format != null && this.format instanceof DateFormat)
return (DateFormat)this.format;
String fmt = this.formatString;
int pos = fmt.indexOf("AM/PM");
while (pos != -1) {
StringBuffer stringBuffer = new StringBuffer(fmt.substring(0, pos));
stringBuffer.append('a');
stringBuffer.append(fmt.substring(pos + 5));
fmt = stringBuffer.toString();
pos = fmt.indexOf("AM/PM");
}
pos = fmt.indexOf("ss.0");
while (pos != -1) {
StringBuffer stringBuffer = new StringBuffer(fmt.substring(0, pos));
stringBuffer.append("ss.SSS");
pos += 4;
while (pos < fmt.length() && fmt.charAt(pos) == '0')
pos++;
stringBuffer.append(fmt.substring(pos));
fmt = stringBuffer.toString();
pos = fmt.indexOf("ss.0");
}
StringBuffer sb = new StringBuffer();
for (int i = 0; i < fmt.length(); i++) {
if (fmt.charAt(i) != '\\')
sb.append(fmt.charAt(i));
}
fmt = sb.toString();
if (fmt.charAt(0) == '[') {
int end = fmt.indexOf(']');
if (end != -1)
fmt = fmt.substring(end + 1);
}
fmt = replace(fmt, ";@", "");
char[] formatBytes = fmt.toCharArray();
for (int j = 0; j < formatBytes.length; j++) {
if (formatBytes[j] == 'm')
if (j > 0 && (formatBytes[j - 1] == 'm' || formatBytes[j - 1] == 'M')) {
formatBytes[j] = formatBytes[j - 1];
} else {
int minuteDist = Integer.MAX_VALUE;
for (j = j - 1; j > 0; j--) {
if (formatBytes[j] == 'h') {
minuteDist = j - j;
break;
}
}
for (j = j + 1; j < formatBytes.length; j++) {
if (formatBytes[j] == 'h') {
minuteDist = Math.min(minuteDist, j - j);
break;
}
}
for (j = j - 1; j > 0; j--) {
if (formatBytes[j] == 'H') {
minuteDist = j - j;
break;
}
}
for (j = j + 1; j < formatBytes.length; j++) {
if (formatBytes[j] == 'H') {
minuteDist = Math.min(minuteDist, j - j);
break;
}
}
for (j = j - 1; j > 0; j--) {
if (formatBytes[j] == 's') {
minuteDist = Math.min(minuteDist, j - j);
break;
}
}
for (j = j + 1; j < formatBytes.length; j++) {
if (formatBytes[j] == 's') {
minuteDist = Math.min(minuteDist, j - j);
break;
}
}
int monthDist = Integer.MAX_VALUE;
for (j = j - 1; j > 0; j--) {
if (formatBytes[j] == 'd') {
monthDist = j - j;
break;
}
}
for (j = j + 1; j < formatBytes.length; j++) {
if (formatBytes[j] == 'd') {
monthDist = Math.min(monthDist, j - j);
break;
}
}
for (j = j - 1; j > 0; j--) {
if (formatBytes[j] == 'y') {
monthDist = Math.min(monthDist, j - j);
break;
}
}
for (j = j + 1; j < formatBytes.length; j++) {
if (formatBytes[j] == 'y') {
monthDist = Math.min(monthDist, j - j);
break;
}
}
if (monthDist < minuteDist) {
formatBytes[j] = Character.toUpperCase(formatBytes[j]);
} else if (monthDist == minuteDist && monthDist != Integer.MAX_VALUE) {
char ind = formatBytes[j - monthDist];
if (ind == 'y' || ind == 'd')
formatBytes[j] = Character.toUpperCase(formatBytes[j]);
}
}
}
try {
this.format = new SimpleDateFormat(new String(formatBytes));
} catch (IllegalArgumentException e) {
this.format = new SimpleDateFormat("dd MM yyyy hh:mm:ss");
}
return (DateFormat)this.format;
}
public int getIndexCode() {
return this.indexCode;
}
public String getFormatString() {
return this.formatString;
}
public boolean isBuiltIn() {
return false;
}
public int hashCode() {
return this.formatString.hashCode();
}
public boolean equals(Object o) {
if (o == this)
return true;
if (!(o instanceof FormatRecord))
return false;
FormatRecord fr = (FormatRecord)o;
if (this.initialized && fr.initialized) {
if (this.date != fr.date || this.number != fr.number)
return false;
return this.formatString.equals(fr.formatString);
}
return this.formatString.equals(fr.formatString);
}
}

View file

@ -0,0 +1,252 @@
package jxl.biff;
import java.io.IOException;
import java.text.DateFormat;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import jxl.common.Assert;
import jxl.common.Logger;
import jxl.format.Colour;
import jxl.format.RGB;
import jxl.write.biff.File;
public class FormattingRecords {
private static Logger logger = Logger.getLogger(FormattingRecords.class);
private HashMap formats;
private ArrayList formatsList;
private ArrayList xfRecords;
private int nextCustomIndexNumber;
private Fonts fonts;
private PaletteRecord palette;
private static final int customFormatStartIndex = 164;
private static final int maxFormatRecordsIndex = 441;
private static final int minXFRecords = 21;
public FormattingRecords(Fonts f) {
this.xfRecords = new ArrayList(10);
this.formats = new HashMap(10);
this.formatsList = new ArrayList(10);
this.fonts = f;
this.nextCustomIndexNumber = 164;
}
public final void addStyle(XFRecord xf) throws NumFormatRecordsException {
if (!xf.isInitialized()) {
int pos = this.xfRecords.size();
xf.initialize(pos, this, this.fonts);
this.xfRecords.add(xf);
} else if (xf.getXFIndex() >= this.xfRecords.size()) {
this.xfRecords.add(xf);
}
}
public final void addFormat(DisplayFormat fr) throws NumFormatRecordsException {
if (fr.isInitialized() && fr.getFormatIndex() >= 441) {
logger.warn("Format index exceeds Excel maximum - assigning custom number");
fr.initialize(this.nextCustomIndexNumber);
this.nextCustomIndexNumber++;
}
if (!fr.isInitialized()) {
fr.initialize(this.nextCustomIndexNumber);
this.nextCustomIndexNumber++;
}
if (this.nextCustomIndexNumber > 441) {
this.nextCustomIndexNumber = 441;
throw new NumFormatRecordsException();
}
if (fr.getFormatIndex() >= this.nextCustomIndexNumber)
this.nextCustomIndexNumber = fr.getFormatIndex() + 1;
if (!fr.isBuiltIn()) {
this.formatsList.add(fr);
this.formats.put(new Integer(fr.getFormatIndex()), fr);
}
}
public final boolean isDate(int pos) {
XFRecord xfr = this.xfRecords.get(pos);
if (xfr.isDate())
return true;
FormatRecord fr = (FormatRecord)this.formats.get(new Integer(xfr.getFormatRecord()));
return (fr == null) ? false : fr.isDate();
}
public final DateFormat getDateFormat(int pos) {
XFRecord xfr = this.xfRecords.get(pos);
if (xfr.isDate())
return xfr.getDateFormat();
FormatRecord fr = (FormatRecord)this.formats.get(new Integer(xfr.getFormatRecord()));
if (fr == null)
return null;
return fr.isDate() ? fr.getDateFormat() : null;
}
public final NumberFormat getNumberFormat(int pos) {
XFRecord xfr = this.xfRecords.get(pos);
if (xfr.isNumber())
return xfr.getNumberFormat();
FormatRecord fr = (FormatRecord)this.formats.get(new Integer(xfr.getFormatRecord()));
if (fr == null)
return null;
return fr.isNumber() ? fr.getNumberFormat() : null;
}
FormatRecord getFormatRecord(int index) {
return (FormatRecord)this.formats.get(new Integer(index));
}
public void write(File outputFile) throws IOException {
Iterator<FormatRecord> i = this.formatsList.iterator();
FormatRecord fr = null;
while (i.hasNext()) {
fr = i.next();
outputFile.write(fr);
}
i = this.xfRecords.iterator();
XFRecord xfr = null;
while (i.hasNext()) {
xfr = (XFRecord)i.next();
outputFile.write(xfr);
}
BuiltInStyle style = new BuiltInStyle(16, 3);
outputFile.write(style);
style = new BuiltInStyle(17, 6);
outputFile.write(style);
style = new BuiltInStyle(18, 4);
outputFile.write(style);
style = new BuiltInStyle(19, 7);
outputFile.write(style);
style = new BuiltInStyle(0, 0);
outputFile.write(style);
style = new BuiltInStyle(20, 5);
outputFile.write(style);
}
protected final Fonts getFonts() {
return this.fonts;
}
public final XFRecord getXFRecord(int index) {
return this.xfRecords.get(index);
}
protected final int getNumberOfFormatRecords() {
return this.formatsList.size();
}
public IndexMapping rationalizeFonts() {
return this.fonts.rationalize();
}
public IndexMapping rationalize(IndexMapping fontMapping, IndexMapping formatMapping) {
xfr = null;
for (XFRecord xfr : (Iterable<XFRecord>)this.xfRecords) {
if (xfr.getFormatRecord() >= 164)
xfr.setFormatIndex(formatMapping.getNewIndex(xfr.getFormatRecord()));
xfr.setFontIndex(fontMapping.getNewIndex(xfr.getFontIndex()));
}
ArrayList<XFRecord> newrecords = new ArrayList(21);
IndexMapping mapping = new IndexMapping(this.xfRecords.size());
int numremoved = 0;
int numXFRecords = Math.min(21, this.xfRecords.size());
for (int j = 0; j < numXFRecords; j++) {
newrecords.add(this.xfRecords.get(j));
mapping.setMapping(j, j);
}
if (numXFRecords < 21) {
logger.warn("There are less than the expected minimum number of XF records");
return mapping;
}
for (int i = 21; i < this.xfRecords.size(); i++) {
XFRecord xf = this.xfRecords.get(i);
boolean duplicate = false;
Iterator<XFRecord> it = newrecords.iterator();
while (it.hasNext() && !duplicate) {
XFRecord xf2 = it.next();
if (xf2.equals(xf)) {
duplicate = true;
mapping.setMapping(i, mapping.getNewIndex(xf2.getXFIndex()));
numremoved++;
}
}
if (!duplicate) {
newrecords.add(xf);
mapping.setMapping(i, i - numremoved);
}
}
for (XFRecord xf : (Iterable<XFRecord>)this.xfRecords)
xf.rationalize(mapping);
this.xfRecords = newrecords;
return mapping;
}
public IndexMapping rationalizeDisplayFormats() {
ArrayList<DisplayFormat> newformats = new ArrayList();
int numremoved = 0;
IndexMapping mapping = new IndexMapping(this.nextCustomIndexNumber);
Iterator<DisplayFormat> i = this.formatsList.iterator();
DisplayFormat df = null;
DisplayFormat df2 = null;
boolean duplicate = false;
while (i.hasNext()) {
df = i.next();
Assert.verify(!df.isBuiltIn());
Iterator<DisplayFormat> i2 = newformats.iterator();
duplicate = false;
while (i2.hasNext() && !duplicate) {
df2 = i2.next();
if (df2.equals(df)) {
duplicate = true;
mapping.setMapping(df.getFormatIndex(), mapping.getNewIndex(df2.getFormatIndex()));
numremoved++;
}
}
if (!duplicate) {
newformats.add(df);
int indexnum = df.getFormatIndex() - numremoved;
if (indexnum > 441) {
logger.warn("Too many number formats - using default format.");
indexnum = 0;
}
mapping.setMapping(df.getFormatIndex(), df.getFormatIndex() - numremoved);
}
}
this.formatsList = newformats;
i = this.formatsList.iterator();
while (i.hasNext()) {
df = i.next();
df.initialize(mapping.getNewIndex(df.getFormatIndex()));
}
return mapping;
}
public PaletteRecord getPalette() {
return this.palette;
}
public void setPalette(PaletteRecord pr) {
this.palette = pr;
}
public void setColourRGB(Colour c, int r, int g, int b) {
if (this.palette == null)
this.palette = new PaletteRecord();
this.palette.setColourRGB(c, r, g, b);
}
public RGB getColourRGB(Colour c) {
if (this.palette == null)
return c.getDefaultRGB();
return this.palette.getColourRGB(c);
}
}

View file

@ -0,0 +1,8 @@
package jxl.biff;
import jxl.Cell;
import jxl.biff.formula.FormulaException;
public interface FormulaData extends Cell {
byte[] getFormulaData() throws FormulaException;
}

View file

@ -0,0 +1,283 @@
package jxl.biff;
import jxl.common.Logger;
public abstract class HeaderFooter {
private static Logger logger = Logger.getLogger(HeaderFooter.class);
private static final String BOLD_TOGGLE = "&B";
private static final String UNDERLINE_TOGGLE = "&U";
private static final String ITALICS_TOGGLE = "&I";
private static final String STRIKETHROUGH_TOGGLE = "&S";
private static final String DOUBLE_UNDERLINE_TOGGLE = "&E";
private static final String SUPERSCRIPT_TOGGLE = "&X";
private static final String SUBSCRIPT_TOGGLE = "&Y";
private static final String OUTLINE_TOGGLE = "&O";
private static final String SHADOW_TOGGLE = "&H";
private static final String LEFT_ALIGN = "&L";
private static final String CENTRE = "&C";
private static final String RIGHT_ALIGN = "&R";
private static final String PAGENUM = "&P";
private static final String TOTAL_PAGENUM = "&N";
private static final String DATE = "&D";
private static final String TIME = "&T";
private static final String WORKBOOK_NAME = "&F";
private static final String WORKSHEET_NAME = "&A";
private Contents left;
private Contents right;
private Contents centre;
protected static class Contents {
private StringBuffer contents;
protected Contents() {
this.contents = new StringBuffer();
}
protected Contents(String s) {
this.contents = new StringBuffer(s);
}
protected Contents(Contents copy) {
this.contents = new StringBuffer(copy.getContents());
}
protected String getContents() {
return (this.contents != null) ? this.contents.toString() : "";
}
private void appendInternal(String txt) {
if (this.contents == null)
this.contents = new StringBuffer();
this.contents.append(txt);
}
private void appendInternal(char ch) {
if (this.contents == null)
this.contents = new StringBuffer();
this.contents.append(ch);
}
protected void append(String txt) {
appendInternal(txt);
}
protected void toggleBold() {
appendInternal("&B");
}
protected void toggleUnderline() {
appendInternal("&U");
}
protected void toggleItalics() {
appendInternal("&I");
}
protected void toggleStrikethrough() {
appendInternal("&S");
}
protected void toggleDoubleUnderline() {
appendInternal("&E");
}
protected void toggleSuperScript() {
appendInternal("&X");
}
protected void toggleSubScript() {
appendInternal("&Y");
}
protected void toggleOutline() {
appendInternal("&O");
}
protected void toggleShadow() {
appendInternal("&H");
}
protected void setFontName(String fontName) {
appendInternal("&\"");
appendInternal(fontName);
appendInternal('"');
}
protected boolean setFontSize(int size) {
String fontSize;
if (size < 1 || size > 99)
return false;
if (size < 10) {
fontSize = "0" + size;
} else {
fontSize = Integer.toString(size);
}
appendInternal('&');
appendInternal(fontSize);
return true;
}
protected void appendPageNumber() {
appendInternal("&P");
}
protected void appendTotalPages() {
appendInternal("&N");
}
protected void appendDate() {
appendInternal("&D");
}
protected void appendTime() {
appendInternal("&T");
}
protected void appendWorkbookName() {
appendInternal("&F");
}
protected void appendWorkSheetName() {
appendInternal("&A");
}
protected void clear() {
this.contents = null;
}
protected boolean empty() {
if (this.contents == null || this.contents.length() == 0)
return true;
return false;
}
}
protected HeaderFooter() {
this.left = createContents();
this.right = createContents();
this.centre = createContents();
}
protected HeaderFooter(HeaderFooter hf) {
this.left = createContents(hf.left);
this.right = createContents(hf.right);
this.centre = createContents(hf.centre);
}
protected HeaderFooter(String s) {
if (s == null || s.length() == 0) {
this.left = createContents();
this.right = createContents();
this.centre = createContents();
return;
}
int leftPos = s.indexOf("&L");
int rightPos = s.indexOf("&R");
int centrePos = s.indexOf("&C");
if (leftPos == -1 && rightPos == -1 && centrePos == -1) {
this.centre = createContents(s);
} else {
if (leftPos != -1) {
int endLeftPos = s.length();
if (centrePos > leftPos) {
endLeftPos = centrePos;
if (rightPos > leftPos && endLeftPos > rightPos)
endLeftPos = rightPos;
} else if (rightPos > leftPos) {
endLeftPos = rightPos;
}
this.left = createContents(s.substring(leftPos + 2, endLeftPos));
}
if (rightPos != -1) {
int endRightPos = s.length();
if (centrePos > rightPos) {
endRightPos = centrePos;
if (leftPos > rightPos && endRightPos > leftPos)
endRightPos = leftPos;
} else if (leftPos > rightPos) {
endRightPos = leftPos;
}
this.right = createContents(s.substring(rightPos + 2, endRightPos));
}
if (centrePos != -1) {
int endCentrePos = s.length();
if (rightPos > centrePos) {
endCentrePos = rightPos;
if (leftPos > centrePos && endCentrePos > leftPos)
endCentrePos = leftPos;
} else if (leftPos > centrePos) {
endCentrePos = leftPos;
}
this.centre = createContents(s.substring(centrePos + 2, endCentrePos));
}
}
if (this.left == null)
this.left = createContents();
if (this.centre == null)
this.centre = createContents();
if (this.right == null)
this.right = createContents();
}
public String toString() {
StringBuffer hf = new StringBuffer();
if (!this.left.empty()) {
hf.append("&L");
hf.append(this.left.getContents());
}
if (!this.centre.empty()) {
hf.append("&C");
hf.append(this.centre.getContents());
}
if (!this.right.empty()) {
hf.append("&R");
hf.append(this.right.getContents());
}
return hf.toString();
}
protected Contents getRightText() {
return this.right;
}
protected Contents getCentreText() {
return this.centre;
}
protected Contents getLeftText() {
return this.left;
}
protected void clear() {
this.left.clear();
this.right.clear();
this.centre.clear();
}
protected abstract Contents createContents();
protected abstract Contents createContents(String paramString);
protected abstract Contents createContents(Contents paramContents);
}

View file

@ -0,0 +1,21 @@
package jxl.biff;
import jxl.common.Logger;
public final class IndexMapping {
private static Logger logger = Logger.getLogger(IndexMapping.class);
private int[] newIndices;
public IndexMapping(int size) {
this.newIndices = new int[size];
}
public void setMapping(int oldIndex, int newIndex) {
this.newIndices[oldIndex] = newIndex;
}
public int getNewIndex(int oldIndex) {
return this.newIndices[oldIndex];
}
}

View file

@ -0,0 +1,53 @@
package jxl.biff;
public final class IntegerHelper {
public static int getInt(byte b1, byte b2) {
int i1 = b1 & 0xFF;
int i2 = b2 & 0xFF;
int val = i2 << 8 | i1;
return val;
}
public static short getShort(byte b1, byte b2) {
short i1 = (short)(b1 & 0xFF);
short i2 = (short)(b2 & 0xFF);
short val = (short)(i2 << 8 | i1);
return val;
}
public static int getInt(byte b1, byte b2, byte b3, byte b4) {
int i1 = getInt(b1, b2);
int i2 = getInt(b3, b4);
int val = i2 << 16 | i1;
return val;
}
public static byte[] getTwoBytes(int i) {
byte[] bytes = new byte[2];
bytes[0] = (byte)(i & 0xFF);
bytes[1] = (byte)((i & 0xFF00) >> 8);
return bytes;
}
public static byte[] getFourBytes(int i) {
byte[] bytes = new byte[4];
int i1 = i & 0xFFFF;
int i2 = (i & 0xFFFF0000) >> 16;
getTwoBytes(i1, bytes, 0);
getTwoBytes(i2, bytes, 2);
return bytes;
}
public static void getTwoBytes(int i, byte[] target, int pos) {
target[pos] = (byte)(i & 0xFF);
target[pos + 1] = (byte)((i & 0xFF00) >> 8);
}
public static void getFourBytes(int i, byte[] target, int pos) {
byte[] bytes = getFourBytes(i);
target[pos] = bytes[0];
target[pos + 1] = bytes[1];
target[pos + 2] = bytes[2];
target[pos + 3] = bytes[3];
}
}

View file

@ -0,0 +1,9 @@
package jxl.biff;
import jxl.JXLException;
public class NameRangeException extends JXLException {
public NameRangeException() {
super("");
}
}

View file

@ -0,0 +1,7 @@
package jxl.biff;
public class NumFormatRecordsException extends Exception {
public NumFormatRecordsException() {
super("Internal error: max number of FORMAT records exceeded");
}
}

View file

@ -0,0 +1,96 @@
package jxl.biff;
import jxl.format.Colour;
import jxl.format.RGB;
import jxl.read.biff.Record;
public class PaletteRecord extends WritableRecordData {
private RGB[] rgbColours = new RGB[56];
private boolean dirty;
private boolean read;
private boolean initialized;
private static final int numColours = 56;
public PaletteRecord(Record t) {
super(t);
this.initialized = false;
this.dirty = false;
this.read = true;
}
public PaletteRecord() {
super(Type.PALETTE);
this.initialized = true;
this.dirty = false;
this.read = false;
Colour[] colours = Colour.getAllColours();
for (int i = 0; i < colours.length; i++) {
Colour c = colours[i];
setColourRGB(c, c.getDefaultRGB().getRed(), c.getDefaultRGB().getGreen(), c.getDefaultRGB().getBlue());
}
}
public byte[] getData() {
if (this.read && !this.dirty)
return getRecord().getData();
byte[] data = new byte[226];
int pos = 0;
IntegerHelper.getTwoBytes(56, data, pos);
for (int i = 0; i < 56; i++) {
pos = i * 4 + 2;
data[pos] = (byte)this.rgbColours[i].getRed();
data[pos + 1] = (byte)this.rgbColours[i].getGreen();
data[pos + 2] = (byte)this.rgbColours[i].getBlue();
}
return data;
}
private void initialize() {
byte[] data = getRecord().getData();
int numrecords = IntegerHelper.getInt(data[0], data[1]);
for (int i = 0; i < numrecords; i++) {
int pos = i * 4 + 2;
int red = IntegerHelper.getInt(data[pos], (byte)0);
int green = IntegerHelper.getInt(data[pos + 1], (byte)0);
int blue = IntegerHelper.getInt(data[pos + 2], (byte)0);
this.rgbColours[i] = new RGB(red, green, blue);
}
this.initialized = true;
}
public boolean isDirty() {
return this.dirty;
}
public void setColourRGB(Colour c, int r, int g, int b) {
int pos = c.getValue() - 8;
if (pos < 0 || pos >= 56)
return;
if (!this.initialized)
initialize();
r = setValueRange(r, 0, 255);
g = setValueRange(g, 0, 255);
b = setValueRange(b, 0, 255);
this.rgbColours[pos] = new RGB(r, g, b);
this.dirty = true;
}
public RGB getColourRGB(Colour c) {
int pos = c.getValue() - 8;
if (pos < 0 || pos >= 56)
return c.getDefaultRGB();
if (!this.initialized)
initialize();
return this.rgbColours[pos];
}
private int setValueRange(int val, int min, int max) {
val = Math.max(val, min);
val = Math.min(val, max);
return val;
}
}

View file

@ -0,0 +1,56 @@
package jxl.biff;
import jxl.Cell;
import jxl.Range;
import jxl.Sheet;
import jxl.common.Logger;
public class RangeImpl implements Range {
private static Logger logger = Logger.getLogger(RangeImpl.class);
private WorkbookMethods workbook;
private int sheet1;
private int column1;
private int row1;
private int sheet2;
private int column2;
private int row2;
public RangeImpl(WorkbookMethods w, int s1, int c1, int r1, int s2, int c2, int r2) {
this.workbook = w;
this.sheet1 = s1;
this.sheet2 = s2;
this.row1 = r1;
this.row2 = r2;
this.column1 = c1;
this.column2 = c2;
}
public Cell getTopLeft() {
Sheet s = this.workbook.getReadSheet(this.sheet1);
if (this.column1 < s.getColumns() && this.row1 < s.getRows())
return s.getCell(this.column1, this.row1);
return new EmptyCell(this.column1, this.row1);
}
public Cell getBottomRight() {
Sheet s = this.workbook.getReadSheet(this.sheet2);
if (this.column2 < s.getColumns() && this.row2 < s.getRows())
return s.getCell(this.column2, this.row2);
return new EmptyCell(this.column2, this.row2);
}
public int getFirstSheetIndex() {
return this.sheet1;
}
public int getLastSheetIndex() {
return this.sheet2;
}
}

View file

@ -0,0 +1,26 @@
package jxl.biff;
import jxl.read.biff.Record;
public abstract class RecordData {
private Record record;
private int code;
protected RecordData(Record r) {
this.record = r;
this.code = r.getCode();
}
protected RecordData(Type t) {
this.code = t.value;
}
protected Record getRecord() {
return this.record;
}
protected final int getCode() {
return this.code;
}
}

View file

@ -0,0 +1,118 @@
package jxl.biff;
import jxl.Cell;
import jxl.Range;
import jxl.Sheet;
public class SheetRangeImpl implements Range {
private Sheet sheet;
private int column1;
private int row1;
private int column2;
private int row2;
public SheetRangeImpl(Sheet s, int c1, int r1, int c2, int r2) {
this.sheet = s;
this.row1 = r1;
this.row2 = r2;
this.column1 = c1;
this.column2 = c2;
}
public SheetRangeImpl(SheetRangeImpl c, Sheet s) {
this.sheet = s;
this.row1 = c.row1;
this.row2 = c.row2;
this.column1 = c.column1;
this.column2 = c.column2;
}
public Cell getTopLeft() {
if (this.column1 >= this.sheet.getColumns() || this.row1 >= this.sheet.getRows())
return new EmptyCell(this.column1, this.row1);
return this.sheet.getCell(this.column1, this.row1);
}
public Cell getBottomRight() {
if (this.column2 >= this.sheet.getColumns() || this.row2 >= this.sheet.getRows())
return new EmptyCell(this.column2, this.row2);
return this.sheet.getCell(this.column2, this.row2);
}
public int getFirstSheetIndex() {
return -1;
}
public int getLastSheetIndex() {
return -1;
}
public boolean intersects(SheetRangeImpl range) {
if (range == this)
return true;
if (this.row2 < range.row1 || this.row1 > range.row2 || this.column2 < range.column1 || this.column1 > range.column2)
return false;
return true;
}
public String toString() {
StringBuffer sb = new StringBuffer();
CellReferenceHelper.getCellReference(this.column1, this.row1, sb);
sb.append('-');
CellReferenceHelper.getCellReference(this.column2, this.row2, sb);
return sb.toString();
}
public void insertRow(int r) {
if (r > this.row2)
return;
if (r <= this.row1)
this.row1++;
if (r <= this.row2)
this.row2++;
}
public void insertColumn(int c) {
if (c > this.column2)
return;
if (c <= this.column1)
this.column1++;
if (c <= this.column2)
this.column2++;
}
public void removeRow(int r) {
if (r > this.row2)
return;
if (r < this.row1)
this.row1--;
if (r < this.row2)
this.row2--;
}
public void removeColumn(int c) {
if (c > this.column2)
return;
if (c < this.column1)
this.column1--;
if (c < this.column2)
this.column2--;
}
public int hashCode() {
return 0xFFFF ^ this.row1 ^ this.row2 ^ this.column1 ^ this.column2;
}
public boolean equals(Object o) {
if (o == this)
return true;
if (!(o instanceof SheetRangeImpl))
return false;
SheetRangeImpl compare = (SheetRangeImpl)o;
return (this.column1 == compare.column1 && this.column2 == compare.column2 && this.row1 == compare.row1 && this.row2 == compare.row2);
}
}

View file

@ -0,0 +1,81 @@
package jxl.biff;
import java.io.UnsupportedEncodingException;
import jxl.WorkbookSettings;
import jxl.common.Logger;
public final class StringHelper {
private static Logger logger = Logger.getLogger(StringHelper.class);
public static String UNICODE_ENCODING = "UnicodeLittle";
public static byte[] getBytes(String s) {
return s.getBytes();
}
public static byte[] getBytes(String s, WorkbookSettings ws) {
try {
return s.getBytes(ws.getEncoding());
} catch (UnsupportedEncodingException e) {
return null;
}
}
public static byte[] getUnicodeBytes(String s) {
try {
byte[] b = s.getBytes(UNICODE_ENCODING);
if (b.length == s.length() * 2 + 2) {
byte[] b2 = new byte[b.length - 2];
System.arraycopy(b, 2, b2, 0, b2.length);
b = b2;
}
return b;
} catch (UnsupportedEncodingException e) {
return null;
}
}
public static void getBytes(String s, byte[] d, int pos) {
byte[] b = getBytes(s);
System.arraycopy(b, 0, d, pos, b.length);
}
public static void getUnicodeBytes(String s, byte[] d, int pos) {
byte[] b = getUnicodeBytes(s);
System.arraycopy(b, 0, d, pos, b.length);
}
public static String getString(byte[] d, int length, int pos, WorkbookSettings ws) {
if (length == 0)
return "";
try {
return new String(d, pos, length, ws.getEncoding());
} catch (UnsupportedEncodingException e) {
logger.warn(e.toString());
return "";
}
}
public static String getUnicodeString(byte[] d, int length, int pos) {
try {
byte[] b = new byte[length * 2];
System.arraycopy(d, pos, b, 0, length * 2);
return new String(b, UNICODE_ENCODING);
} catch (UnsupportedEncodingException e) {
return "";
}
}
public static final String replace(String input, String search, String replace) {
String fmtstr = input;
int pos = fmtstr.indexOf(search);
while (pos != -1) {
StringBuffer tmp = new StringBuffer(fmtstr.substring(0, pos));
tmp.append(replace);
tmp.append(fmtstr.substring(pos + search.length()));
fmtstr = tmp.toString();
pos = fmtstr.indexOf(search, pos + replace.length());
}
return fmtstr;
}
}

View file

@ -0,0 +1,292 @@
package jxl.biff;
public final class Type {
public final int value;
private static Type[] types = new Type[0];
private Type(int v) {
this.value = v;
Type[] newTypes = new Type[types.length + 1];
System.arraycopy(types, 0, newTypes, 0, types.length);
newTypes[types.length] = this;
types = newTypes;
}
private static class ArbitraryType {
private ArbitraryType() {}
}
private static ArbitraryType arbitrary = new ArbitraryType();
private Type(int v, ArbitraryType arb) {
this.value = v;
}
public int hashCode() {
return this.value;
}
public boolean equals(Object o) {
if (o == this)
return true;
if (!(o instanceof Type))
return false;
Type t = (Type)o;
return (this.value == t.value);
}
public static Type getType(int v) {
for (int i = 0; i < types.length; i++) {
if ((types[i]).value == v)
return types[i];
}
return UNKNOWN;
}
public static Type createType(int v) {
return new Type(v, arbitrary);
}
public static final Type BOF = new Type(2057);
public static final Type EOF = new Type(10);
public static final Type BOUNDSHEET = new Type(133);
public static final Type SUPBOOK = new Type(430);
public static final Type EXTERNSHEET = new Type(23);
public static final Type DIMENSION = new Type(512);
public static final Type BLANK = new Type(513);
public static final Type MULBLANK = new Type(190);
public static final Type ROW = new Type(520);
public static final Type NOTE = new Type(28);
public static final Type TXO = new Type(438);
public static final Type RK = new Type(126);
public static final Type RK2 = new Type(638);
public static final Type MULRK = new Type(189);
public static final Type INDEX = new Type(523);
public static final Type DBCELL = new Type(215);
public static final Type SST = new Type(252);
public static final Type COLINFO = new Type(125);
public static final Type EXTSST = new Type(255);
public static final Type CONTINUE = new Type(60);
public static final Type LABEL = new Type(516);
public static final Type RSTRING = new Type(214);
public static final Type LABELSST = new Type(253);
public static final Type NUMBER = new Type(515);
public static final Type NAME = new Type(24);
public static final Type TABID = new Type(317);
public static final Type ARRAY = new Type(545);
public static final Type STRING = new Type(519);
public static final Type FORMULA = new Type(1030);
public static final Type FORMULA2 = new Type(6);
public static final Type SHAREDFORMULA = new Type(1212);
public static final Type FORMAT = new Type(1054);
public static final Type XF = new Type(224);
public static final Type BOOLERR = new Type(517);
public static final Type INTERFACEHDR = new Type(225);
public static final Type SAVERECALC = new Type(95);
public static final Type INTERFACEEND = new Type(226);
public static final Type XCT = new Type(89);
public static final Type CRN = new Type(90);
public static final Type DEFCOLWIDTH = new Type(85);
public static final Type DEFAULTROWHEIGHT = new Type(549);
public static final Type WRITEACCESS = new Type(92);
public static final Type WSBOOL = new Type(129);
public static final Type CODEPAGE = new Type(66);
public static final Type DSF = new Type(353);
public static final Type FNGROUPCOUNT = new Type(156);
public static final Type FILTERMODE = new Type(155);
public static final Type AUTOFILTERINFO = new Type(157);
public static final Type AUTOFILTER = new Type(158);
public static final Type COUNTRY = new Type(140);
public static final Type PROTECT = new Type(18);
public static final Type SCENPROTECT = new Type(221);
public static final Type OBJPROTECT = new Type(99);
public static final Type PRINTHEADERS = new Type(42);
public static final Type HEADER = new Type(20);
public static final Type FOOTER = new Type(21);
public static final Type HCENTER = new Type(131);
public static final Type VCENTER = new Type(132);
public static final Type FILEPASS = new Type(47);
public static final Type SETUP = new Type(161);
public static final Type PRINTGRIDLINES = new Type(43);
public static final Type GRIDSET = new Type(130);
public static final Type GUTS = new Type(128);
public static final Type WINDOWPROTECT = new Type(25);
public static final Type PROT4REV = new Type(431);
public static final Type PROT4REVPASS = new Type(444);
public static final Type PASSWORD = new Type(19);
public static final Type REFRESHALL = new Type(439);
public static final Type WINDOW1 = new Type(61);
public static final Type WINDOW2 = new Type(574);
public static final Type BACKUP = new Type(64);
public static final Type HIDEOBJ = new Type(141);
public static final Type NINETEENFOUR = new Type(34);
public static final Type PRECISION = new Type(14);
public static final Type BOOKBOOL = new Type(218);
public static final Type FONT = new Type(49);
public static final Type MMS = new Type(193);
public static final Type CALCMODE = new Type(13);
public static final Type CALCCOUNT = new Type(12);
public static final Type REFMODE = new Type(15);
public static final Type TEMPLATE = new Type(96);
public static final Type OBJPROJ = new Type(211);
public static final Type DELTA = new Type(16);
public static final Type MERGEDCELLS = new Type(229);
public static final Type ITERATION = new Type(17);
public static final Type STYLE = new Type(659);
public static final Type USESELFS = new Type(352);
public static final Type VERTICALPAGEBREAKS = new Type(26);
public static final Type HORIZONTALPAGEBREAKS = new Type(27);
public static final Type SELECTION = new Type(29);
public static final Type HLINK = new Type(440);
public static final Type OBJ = new Type(93);
public static final Type MSODRAWING = new Type(236);
public static final Type MSODRAWINGGROUP = new Type(235);
public static final Type LEFTMARGIN = new Type(38);
public static final Type RIGHTMARGIN = new Type(39);
public static final Type TOPMARGIN = new Type(40);
public static final Type BOTTOMMARGIN = new Type(41);
public static final Type EXTERNNAME = new Type(35);
public static final Type PALETTE = new Type(146);
public static final Type PLS = new Type(77);
public static final Type SCL = new Type(160);
public static final Type PANE = new Type(65);
public static final Type WEIRD1 = new Type(239);
public static final Type SORT = new Type(144);
public static final Type CONDFMT = new Type(432);
public static final Type CF = new Type(433);
public static final Type DV = new Type(446);
public static final Type DVAL = new Type(434);
public static final Type BUTTONPROPERTYSET = new Type(442);
public static final Type EXCEL9FILE = new Type(448);
public static final Type FONTX = new Type(4134);
public static final Type IFMT = new Type(4174);
public static final Type FBI = new Type(4192);
public static final Type ALRUNS = new Type(4176);
public static final Type SERIES = new Type(4099);
public static final Type SERIESLIST = new Type(4118);
public static final Type SBASEREF = new Type(4168);
public static final Type UNKNOWN = new Type(65535);
public static final Type U1C0 = new Type(448);
public static final Type U1C1 = new Type(449);
}

View file

@ -0,0 +1,11 @@
package jxl.biff;
import jxl.Sheet;
public interface WorkbookMethods {
Sheet getReadSheet(int paramInt);
String getName(int paramInt) throws NameRangeException;
int getNameIndex(String paramString);
}

View file

@ -0,0 +1,66 @@
package jxl.biff;
import jxl.common.Logger;
import jxl.read.biff.Record;
public class WorkspaceInformationRecord extends WritableRecordData {
private static Logger logger = Logger.getLogger(WorkspaceInformationRecord.class);
private int wsoptions;
private boolean rowOutlines;
private boolean columnOutlines;
private boolean fitToPages;
private static final int FIT_TO_PAGES = 256;
private static final int SHOW_ROW_OUTLINE_SYMBOLS = 1024;
private static final int SHOW_COLUMN_OUTLINE_SYMBOLS = 2048;
private static final int DEFAULT_OPTIONS = 1217;
public WorkspaceInformationRecord(Record t) {
super(t);
byte[] data = getRecord().getData();
this.wsoptions = IntegerHelper.getInt(data[0], data[1]);
this.fitToPages = ((this.wsoptions | 0x100) != 0);
this.rowOutlines = ((this.wsoptions | 0x400) != 0);
this.columnOutlines = ((this.wsoptions | 0x800) != 0);
}
public WorkspaceInformationRecord() {
super(Type.WSBOOL);
this.wsoptions = 1217;
}
public boolean getFitToPages() {
return this.fitToPages;
}
public void setFitToPages(boolean b) {
this.fitToPages = b;
}
public void setRowOutlines(boolean ro) {
this.rowOutlines = true;
}
public void setColumnOutlines(boolean ro) {
this.rowOutlines = true;
}
public byte[] getData() {
byte[] data = new byte[2];
if (this.fitToPages)
this.wsoptions |= 0x100;
if (this.rowOutlines)
this.wsoptions |= 0x400;
if (this.columnOutlines)
this.wsoptions |= 0x800;
IntegerHelper.getTwoBytes(this.wsoptions, data, 0);
return data;
}
}

View file

@ -0,0 +1,52 @@
package jxl.biff;
import jxl.common.Logger;
import jxl.read.biff.Record;
public abstract class WritableRecordData extends RecordData implements ByteData {
private static Logger logger = Logger.getLogger(WritableRecordData.class);
protected static final int maxRecordLength = 8228;
protected WritableRecordData(Type t) {
super(t);
}
protected WritableRecordData(Record t) {
super(t);
}
public final byte[] getBytes() {
byte[] data = getData();
int dataLength = data.length;
if (data.length > 8224) {
dataLength = 8224;
data = handleContinueRecords(data);
}
byte[] bytes = new byte[data.length + 4];
System.arraycopy(data, 0, bytes, 4, data.length);
IntegerHelper.getTwoBytes(getCode(), bytes, 0);
IntegerHelper.getTwoBytes(dataLength, bytes, 2);
return bytes;
}
private byte[] handleContinueRecords(byte[] data) {
int continuedData = data.length - 8224;
int numContinueRecords = continuedData / 8224 + 1;
byte[] newdata = new byte[data.length + numContinueRecords * 4];
System.arraycopy(data, 0, newdata, 0, 8224);
int oldarraypos = 8224;
int newarraypos = 8224;
for (int i = 0; i < numContinueRecords; i++) {
int length = Math.min(data.length - oldarraypos, 8224);
IntegerHelper.getTwoBytes(Type.CONTINUE.value, newdata, newarraypos);
IntegerHelper.getTwoBytes(length, newdata, newarraypos + 2);
System.arraycopy(data, oldarraypos, newdata, newarraypos + 4, length);
oldarraypos += length;
newarraypos += length + 4;
}
return newdata;
}
protected abstract byte[] getData();
}

View file

@ -0,0 +1,13 @@
package jxl.biff;
import jxl.read.biff.Record;
public class XCTRecord extends WritableRecordData {
public XCTRecord(Record t) {
super(t);
}
public byte[] getData() {
return getRecord().getData();
}
}

View file

@ -0,0 +1,755 @@
package jxl.biff;
import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import jxl.WorkbookSettings;
import jxl.common.Assert;
import jxl.common.Logger;
import jxl.format.Alignment;
import jxl.format.Border;
import jxl.format.BorderLineStyle;
import jxl.format.CellFormat;
import jxl.format.Colour;
import jxl.format.Font;
import jxl.format.Format;
import jxl.format.Orientation;
import jxl.format.Pattern;
import jxl.format.VerticalAlignment;
import jxl.read.biff.Record;
public class XFRecord extends WritableRecordData implements CellFormat {
private static Logger logger = Logger.getLogger(XFRecord.class);
public int formatIndex;
private int parentFormat;
private XFType xfFormatType;
private boolean date;
private boolean number;
private DateFormat dateFormat;
private NumberFormat numberFormat;
private byte usedAttributes;
private int fontIndex;
private boolean locked;
private boolean hidden;
private Alignment align;
private VerticalAlignment valign;
private Orientation orientation;
private boolean wrap;
private int indentation;
private boolean shrinkToFit;
private BorderLineStyle leftBorder;
private BorderLineStyle rightBorder;
private BorderLineStyle topBorder;
private BorderLineStyle bottomBorder;
private Colour leftBorderColour;
private Colour rightBorderColour;
private Colour topBorderColour;
private Colour bottomBorderColour;
private Colour backgroundColour;
private Pattern pattern;
private int options;
private int xfIndex;
private FontRecord font;
private DisplayFormat format;
private boolean initialized;
private boolean read;
private Format excelFormat;
private boolean formatInfoInitialized;
private boolean copied;
private FormattingRecords formattingRecords;
private static final int USE_FONT = 4;
private static final int USE_FORMAT = 8;
private static final int USE_ALIGNMENT = 16;
private static final int USE_BORDER = 32;
private static final int USE_BACKGROUND = 64;
private static final int USE_PROTECTION = 128;
private static final int USE_DEFAULT_VALUE = 248;
private static final int[] dateFormats = new int[] {
14, 15, 16, 17, 18, 19, 20, 21, 22, 45,
46, 47 };
private static final DateFormat[] javaDateFormats = new DateFormat[] {
SimpleDateFormat.getDateInstance(3), SimpleDateFormat.getDateInstance(2), new SimpleDateFormat("d-MMM"), new SimpleDateFormat("MMM-yy"), new SimpleDateFormat("h:mm a"), new SimpleDateFormat("h:mm:ss a"), new SimpleDateFormat("H:mm"), new SimpleDateFormat("H:mm:ss"), new SimpleDateFormat("M/d/yy H:mm"), new SimpleDateFormat("mm:ss"),
new SimpleDateFormat("H:mm:ss"), new SimpleDateFormat("mm:ss.S") };
private static int[] numberFormats = new int[] {
1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
11, 37, 38, 39, 40, 41, 42, 43, 44, 48 };
private static NumberFormat[] javaNumberFormats = new NumberFormat[] {
new DecimalFormat("0"), new DecimalFormat("0.00"), new DecimalFormat("#,##0"), new DecimalFormat("#,##0.00"), new DecimalFormat("$#,##0;($#,##0)"), new DecimalFormat("$#,##0;($#,##0)"), new DecimalFormat("$#,##0.00;($#,##0.00)"), new DecimalFormat("$#,##0.00;($#,##0.00)"), new DecimalFormat("0%"), new DecimalFormat("0.00%"),
new DecimalFormat("0.00E00"), new DecimalFormat("#,##0;(#,##0)"), new DecimalFormat("#,##0;(#,##0)"), new DecimalFormat("#,##0.00;(#,##0.00)"), new DecimalFormat("#,##0.00;(#,##0.00)"), new DecimalFormat("#,##0;(#,##0)"), new DecimalFormat("$#,##0;($#,##0)"), new DecimalFormat("#,##0.00;(#,##0.00)"), new DecimalFormat("$#,##0.00;($#,##0.00)"), new DecimalFormat("##0.0E0") };
private static class BiffType {
private BiffType() {}
}
public static final BiffType biff8 = new BiffType();
public static final BiffType biff7 = new BiffType();
private BiffType biffType;
private static class XFType {
private XFType() {}
}
protected static final XFType cell = new XFType();
protected static final XFType style = new XFType();
public XFRecord(Record t, WorkbookSettings ws, BiffType bt) {
super(t);
this.biffType = bt;
byte[] data = getRecord().getData();
this.fontIndex = IntegerHelper.getInt(data[0], data[1]);
this.formatIndex = IntegerHelper.getInt(data[2], data[3]);
this.date = false;
this.number = false;
for (int j = 0; j < dateFormats.length && !this.date; j++) {
if (this.formatIndex == dateFormats[j]) {
this.date = true;
this.dateFormat = javaDateFormats[j];
}
}
for (int i = 0; i < numberFormats.length && !this.number; i++) {
if (this.formatIndex == numberFormats[i]) {
this.number = true;
DecimalFormat df = (DecimalFormat)javaNumberFormats[i].clone();
DecimalFormatSymbols symbols = new DecimalFormatSymbols(ws.getLocale());
df.setDecimalFormatSymbols(symbols);
this.numberFormat = df;
}
}
int cellAttributes = IntegerHelper.getInt(data[4], data[5]);
this.parentFormat = (cellAttributes & 0xFFF0) >> 4;
int formatType = cellAttributes & 0x4;
this.xfFormatType = (formatType == 0) ? cell : style;
this.locked = ((cellAttributes & 0x1) != 0);
this.hidden = ((cellAttributes & 0x2) != 0);
if (this.xfFormatType == cell && (this.parentFormat & 0xFFF) == 4095) {
this.parentFormat = 0;
logger.warn("Invalid parent format found - ignoring");
}
this.initialized = false;
this.read = true;
this.formatInfoInitialized = false;
this.copied = false;
}
public XFRecord(FontRecord fnt, DisplayFormat form) {
super(Type.XF);
this.initialized = false;
this.locked = true;
this.hidden = false;
this.align = Alignment.GENERAL;
this.valign = VerticalAlignment.BOTTOM;
this.orientation = Orientation.HORIZONTAL;
this.wrap = false;
this.leftBorder = BorderLineStyle.NONE;
this.rightBorder = BorderLineStyle.NONE;
this.topBorder = BorderLineStyle.NONE;
this.bottomBorder = BorderLineStyle.NONE;
this.leftBorderColour = Colour.AUTOMATIC;
this.rightBorderColour = Colour.AUTOMATIC;
this.topBorderColour = Colour.AUTOMATIC;
this.bottomBorderColour = Colour.AUTOMATIC;
this.pattern = Pattern.NONE;
this.backgroundColour = Colour.DEFAULT_BACKGROUND;
this.indentation = 0;
this.shrinkToFit = false;
this.usedAttributes = 124;
this.parentFormat = 0;
this.xfFormatType = null;
this.font = fnt;
this.format = form;
this.biffType = biff8;
this.read = false;
this.copied = false;
this.formatInfoInitialized = true;
Assert.verify((this.font != null));
Assert.verify((this.format != null));
}
protected XFRecord(XFRecord fmt) {
super(Type.XF);
this.initialized = false;
this.locked = fmt.locked;
this.hidden = fmt.hidden;
this.align = fmt.align;
this.valign = fmt.valign;
this.orientation = fmt.orientation;
this.wrap = fmt.wrap;
this.leftBorder = fmt.leftBorder;
this.rightBorder = fmt.rightBorder;
this.topBorder = fmt.topBorder;
this.bottomBorder = fmt.bottomBorder;
this.leftBorderColour = fmt.leftBorderColour;
this.rightBorderColour = fmt.rightBorderColour;
this.topBorderColour = fmt.topBorderColour;
this.bottomBorderColour = fmt.bottomBorderColour;
this.pattern = fmt.pattern;
this.xfFormatType = fmt.xfFormatType;
this.indentation = fmt.indentation;
this.shrinkToFit = fmt.shrinkToFit;
this.parentFormat = fmt.parentFormat;
this.backgroundColour = fmt.backgroundColour;
this.font = fmt.font;
this.format = fmt.format;
this.fontIndex = fmt.fontIndex;
this.formatIndex = fmt.formatIndex;
this.formatInfoInitialized = fmt.formatInfoInitialized;
this.biffType = biff8;
this.read = false;
this.copied = true;
}
protected XFRecord(CellFormat cellFormat) {
super(Type.XF);
Assert.verify((cellFormat != null));
Assert.verify(cellFormat instanceof XFRecord);
XFRecord fmt = (XFRecord)cellFormat;
if (!fmt.formatInfoInitialized)
fmt.initializeFormatInformation();
this.locked = fmt.locked;
this.hidden = fmt.hidden;
this.align = fmt.align;
this.valign = fmt.valign;
this.orientation = fmt.orientation;
this.wrap = fmt.wrap;
this.leftBorder = fmt.leftBorder;
this.rightBorder = fmt.rightBorder;
this.topBorder = fmt.topBorder;
this.bottomBorder = fmt.bottomBorder;
this.leftBorderColour = fmt.leftBorderColour;
this.rightBorderColour = fmt.rightBorderColour;
this.topBorderColour = fmt.topBorderColour;
this.bottomBorderColour = fmt.bottomBorderColour;
this.pattern = fmt.pattern;
this.xfFormatType = fmt.xfFormatType;
this.parentFormat = fmt.parentFormat;
this.indentation = fmt.indentation;
this.shrinkToFit = fmt.shrinkToFit;
this.backgroundColour = fmt.backgroundColour;
this.font = new FontRecord(fmt.getFont());
if (fmt.getFormat() == null) {
if (fmt.format.isBuiltIn()) {
this.format = fmt.format;
} else {
this.format = new FormatRecord((FormatRecord)fmt.format);
}
} else if (fmt.getFormat() instanceof BuiltInFormat) {
this.excelFormat = fmt.excelFormat;
this.format = (BuiltInFormat)fmt.excelFormat;
} else {
Assert.verify(fmt.formatInfoInitialized);
Assert.verify(fmt.excelFormat instanceof FormatRecord);
FormatRecord fr = new FormatRecord((FormatRecord)fmt.excelFormat);
this.excelFormat = fr;
this.format = fr;
}
this.biffType = biff8;
this.formatInfoInitialized = true;
this.read = false;
this.copied = false;
this.initialized = false;
}
public DateFormat getDateFormat() {
return this.dateFormat;
}
public NumberFormat getNumberFormat() {
return this.numberFormat;
}
public int getFormatRecord() {
return this.formatIndex;
}
public boolean isDate() {
return this.date;
}
public boolean isNumber() {
return this.number;
}
public byte[] getData() {
if (!this.formatInfoInitialized)
initializeFormatInformation();
byte[] data = new byte[20];
IntegerHelper.getTwoBytes(this.fontIndex, data, 0);
IntegerHelper.getTwoBytes(this.formatIndex, data, 2);
int cellAttributes = 0;
if (getLocked())
cellAttributes |= 0x1;
if (getHidden())
cellAttributes |= 0x2;
if (this.xfFormatType == style) {
cellAttributes |= 0x4;
this.parentFormat = 65535;
}
cellAttributes |= this.parentFormat << 4;
IntegerHelper.getTwoBytes(cellAttributes, data, 4);
int alignMask = this.align.getValue();
if (this.wrap)
alignMask |= 0x8;
alignMask |= this.valign.getValue() << 4;
alignMask |= this.orientation.getValue() << 8;
IntegerHelper.getTwoBytes(alignMask, data, 6);
data[9] = 16;
int borderMask = this.leftBorder.getValue();
borderMask |= this.rightBorder.getValue() << 4;
borderMask |= this.topBorder.getValue() << 8;
borderMask |= this.bottomBorder.getValue() << 12;
IntegerHelper.getTwoBytes(borderMask, data, 10);
if (borderMask != 0) {
byte lc = (byte)this.leftBorderColour.getValue();
byte rc = (byte)this.rightBorderColour.getValue();
byte tc = (byte)this.topBorderColour.getValue();
byte bc = (byte)this.bottomBorderColour.getValue();
int sideColourMask = lc & Byte.MAX_VALUE | (rc & Byte.MAX_VALUE) << 7;
int topColourMask = tc & Byte.MAX_VALUE | (bc & Byte.MAX_VALUE) << 7;
IntegerHelper.getTwoBytes(sideColourMask, data, 12);
IntegerHelper.getTwoBytes(topColourMask, data, 14);
}
int patternVal = this.pattern.getValue() << 10;
IntegerHelper.getTwoBytes(patternVal, data, 16);
int colourPaletteMask = this.backgroundColour.getValue();
colourPaletteMask |= 0x2000;
IntegerHelper.getTwoBytes(colourPaletteMask, data, 18);
this.options |= this.indentation & 0xF;
if (this.shrinkToFit) {
this.options |= 0x10;
} else {
this.options &= 0xEF;
}
data[8] = (byte)this.options;
if (this.biffType == biff8)
data[9] = this.usedAttributes;
return data;
}
protected final boolean getLocked() {
return this.locked;
}
protected final boolean getHidden() {
return this.hidden;
}
protected final void setXFLocked(boolean l) {
this.locked = l;
this.usedAttributes = (byte)(this.usedAttributes | 0x80);
}
protected final void setXFCellOptions(int opt) {
this.options |= opt;
}
protected void setXFAlignment(Alignment a) {
Assert.verify(!this.initialized);
this.align = a;
this.usedAttributes = (byte)(this.usedAttributes | 0x10);
}
protected void setXFIndentation(int i) {
Assert.verify(!this.initialized);
this.indentation = i;
this.usedAttributes = (byte)(this.usedAttributes | 0x10);
}
protected void setXFShrinkToFit(boolean s) {
Assert.verify(!this.initialized);
this.shrinkToFit = s;
this.usedAttributes = (byte)(this.usedAttributes | 0x10);
}
public Alignment getAlignment() {
if (!this.formatInfoInitialized)
initializeFormatInformation();
return this.align;
}
public int getIndentation() {
if (!this.formatInfoInitialized)
initializeFormatInformation();
return this.indentation;
}
public boolean isShrinkToFit() {
if (!this.formatInfoInitialized)
initializeFormatInformation();
return this.shrinkToFit;
}
public boolean isLocked() {
if (!this.formatInfoInitialized)
initializeFormatInformation();
return this.locked;
}
public VerticalAlignment getVerticalAlignment() {
if (!this.formatInfoInitialized)
initializeFormatInformation();
return this.valign;
}
public Orientation getOrientation() {
if (!this.formatInfoInitialized)
initializeFormatInformation();
return this.orientation;
}
protected void setXFBackground(Colour c, Pattern p) {
Assert.verify(!this.initialized);
this.backgroundColour = c;
this.pattern = p;
this.usedAttributes = (byte)(this.usedAttributes | 0x40);
}
public Colour getBackgroundColour() {
if (!this.formatInfoInitialized)
initializeFormatInformation();
return this.backgroundColour;
}
public Pattern getPattern() {
if (!this.formatInfoInitialized)
initializeFormatInformation();
return this.pattern;
}
protected void setXFVerticalAlignment(VerticalAlignment va) {
Assert.verify(!this.initialized);
this.valign = va;
this.usedAttributes = (byte)(this.usedAttributes | 0x10);
}
protected void setXFOrientation(Orientation o) {
Assert.verify(!this.initialized);
this.orientation = o;
this.usedAttributes = (byte)(this.usedAttributes | 0x10);
}
protected void setXFWrap(boolean w) {
Assert.verify(!this.initialized);
this.wrap = w;
this.usedAttributes = (byte)(this.usedAttributes | 0x10);
}
public boolean getWrap() {
if (!this.formatInfoInitialized)
initializeFormatInformation();
return this.wrap;
}
protected void setXFBorder(Border b, BorderLineStyle ls, Colour c) {
Assert.verify(!this.initialized);
if (c == Colour.BLACK || c == Colour.UNKNOWN)
c = Colour.PALETTE_BLACK;
if (b == Border.LEFT) {
this.leftBorder = ls;
this.leftBorderColour = c;
} else if (b == Border.RIGHT) {
this.rightBorder = ls;
this.rightBorderColour = c;
} else if (b == Border.TOP) {
this.topBorder = ls;
this.topBorderColour = c;
} else if (b == Border.BOTTOM) {
this.bottomBorder = ls;
this.bottomBorderColour = c;
}
this.usedAttributes = (byte)(this.usedAttributes | 0x20);
}
public BorderLineStyle getBorder(Border border) {
return getBorderLine(border);
}
public BorderLineStyle getBorderLine(Border border) {
if (border == Border.NONE || border == Border.ALL)
return BorderLineStyle.NONE;
if (!this.formatInfoInitialized)
initializeFormatInformation();
if (border == Border.LEFT)
return this.leftBorder;
if (border == Border.RIGHT)
return this.rightBorder;
if (border == Border.TOP)
return this.topBorder;
if (border == Border.BOTTOM)
return this.bottomBorder;
return BorderLineStyle.NONE;
}
public Colour getBorderColour(Border border) {
if (border == Border.NONE || border == Border.ALL)
return Colour.PALETTE_BLACK;
if (!this.formatInfoInitialized)
initializeFormatInformation();
if (border == Border.LEFT)
return this.leftBorderColour;
if (border == Border.RIGHT)
return this.rightBorderColour;
if (border == Border.TOP)
return this.topBorderColour;
if (border == Border.BOTTOM)
return this.bottomBorderColour;
return Colour.BLACK;
}
public final boolean hasBorders() {
if (!this.formatInfoInitialized)
initializeFormatInformation();
if (this.leftBorder == BorderLineStyle.NONE && this.rightBorder == BorderLineStyle.NONE && this.topBorder == BorderLineStyle.NONE && this.bottomBorder == BorderLineStyle.NONE)
return false;
return true;
}
public final void initialize(int pos, FormattingRecords fr, Fonts fonts) throws NumFormatRecordsException {
this.xfIndex = pos;
this.formattingRecords = fr;
if (this.read || this.copied) {
this.initialized = true;
return;
}
if (!this.font.isInitialized())
fonts.addFont(this.font);
if (!this.format.isInitialized())
fr.addFormat(this.format);
this.fontIndex = this.font.getFontIndex();
this.formatIndex = this.format.getFormatIndex();
this.initialized = true;
}
public final void uninitialize() {
if (this.initialized == true)
logger.warn("A default format has been initialized");
this.initialized = false;
}
final void setXFIndex(int xfi) {
this.xfIndex = xfi;
}
public final int getXFIndex() {
return this.xfIndex;
}
public final boolean isInitialized() {
return this.initialized;
}
public final boolean isRead() {
return this.read;
}
public Format getFormat() {
if (!this.formatInfoInitialized)
initializeFormatInformation();
return this.excelFormat;
}
public Font getFont() {
if (!this.formatInfoInitialized)
initializeFormatInformation();
return this.font;
}
private void initializeFormatInformation() {
if (this.formatIndex < BuiltInFormat.builtIns.length && BuiltInFormat.builtIns[this.formatIndex] != null) {
this.excelFormat = BuiltInFormat.builtIns[this.formatIndex];
} else {
this.excelFormat = this.formattingRecords.getFormatRecord(this.formatIndex);
}
this.font = this.formattingRecords.getFonts().getFont(this.fontIndex);
byte[] data = getRecord().getData();
int cellAttributes = IntegerHelper.getInt(data[4], data[5]);
this.parentFormat = (cellAttributes & 0xFFF0) >> 4;
int formatType = cellAttributes & 0x4;
this.xfFormatType = (formatType == 0) ? cell : style;
this.locked = ((cellAttributes & 0x1) != 0);
this.hidden = ((cellAttributes & 0x2) != 0);
if (this.xfFormatType == cell && (this.parentFormat & 0xFFF) == 4095) {
this.parentFormat = 0;
logger.warn("Invalid parent format found - ignoring");
}
int alignMask = IntegerHelper.getInt(data[6], data[7]);
if ((alignMask & 0x8) != 0)
this.wrap = true;
this.align = Alignment.getAlignment(alignMask & 0x7);
this.valign = VerticalAlignment.getAlignment(alignMask >> 4 & 0x7);
this.orientation = Orientation.getOrientation(alignMask >> 8 & 0xFF);
int attr = IntegerHelper.getInt(data[8], data[9]);
this.indentation = attr & 0xF;
this.shrinkToFit = ((attr & 0x10) != 0);
if (this.biffType == biff8)
this.usedAttributes = data[9];
int borderMask = IntegerHelper.getInt(data[10], data[11]);
this.leftBorder = BorderLineStyle.getStyle(borderMask & 0x7);
this.rightBorder = BorderLineStyle.getStyle(borderMask >> 4 & 0x7);
this.topBorder = BorderLineStyle.getStyle(borderMask >> 8 & 0x7);
this.bottomBorder = BorderLineStyle.getStyle(borderMask >> 12 & 0x7);
int borderColourMask = IntegerHelper.getInt(data[12], data[13]);
this.leftBorderColour = Colour.getInternalColour(borderColourMask & 0x7F);
this.rightBorderColour = Colour.getInternalColour((borderColourMask & 0x3F80) >> 7);
borderColourMask = IntegerHelper.getInt(data[14], data[15]);
this.topBorderColour = Colour.getInternalColour(borderColourMask & 0x7F);
this.bottomBorderColour = Colour.getInternalColour((borderColourMask & 0x3F80) >> 7);
if (this.biffType == biff8) {
int patternVal = IntegerHelper.getInt(data[16], data[17]);
patternVal &= 0xFC00;
patternVal >>= 10;
this.pattern = Pattern.getPattern(patternVal);
int colourPaletteMask = IntegerHelper.getInt(data[18], data[19]);
this.backgroundColour = Colour.getInternalColour(colourPaletteMask & 0x3F);
if (this.backgroundColour == Colour.UNKNOWN || this.backgroundColour == Colour.DEFAULT_BACKGROUND1)
this.backgroundColour = Colour.DEFAULT_BACKGROUND;
} else {
this.pattern = Pattern.NONE;
this.backgroundColour = Colour.DEFAULT_BACKGROUND;
}
this.formatInfoInitialized = true;
}
public int hashCode() {
if (!this.formatInfoInitialized)
initializeFormatInformation();
int hashValue = 17;
int oddPrimeNumber = 37;
hashValue = oddPrimeNumber * hashValue + (this.hidden ? 1 : 0);
hashValue = oddPrimeNumber * hashValue + (this.locked ? 1 : 0);
hashValue = oddPrimeNumber * hashValue + (this.wrap ? 1 : 0);
hashValue = oddPrimeNumber * hashValue + (this.shrinkToFit ? 1 : 0);
if (this.xfFormatType == cell) {
hashValue = oddPrimeNumber * hashValue + 1;
} else if (this.xfFormatType == style) {
hashValue = oddPrimeNumber * hashValue + 2;
}
hashValue = oddPrimeNumber * hashValue + this.align.getValue() + 1;
hashValue = oddPrimeNumber * hashValue + this.valign.getValue() + 1;
hashValue = oddPrimeNumber * hashValue + this.orientation.getValue();
hashValue ^= this.leftBorder.getDescription().hashCode();
hashValue ^= this.rightBorder.getDescription().hashCode();
hashValue ^= this.topBorder.getDescription().hashCode();
hashValue ^= this.bottomBorder.getDescription().hashCode();
hashValue = oddPrimeNumber * hashValue + this.leftBorderColour.getValue();
hashValue = oddPrimeNumber * hashValue + this.rightBorderColour.getValue();
hashValue = oddPrimeNumber * hashValue + this.topBorderColour.getValue();
hashValue = oddPrimeNumber * hashValue + this.bottomBorderColour.getValue();
hashValue = oddPrimeNumber * hashValue + this.backgroundColour.getValue();
hashValue = oddPrimeNumber * hashValue + this.pattern.getValue() + 1;
hashValue = oddPrimeNumber * hashValue + this.usedAttributes;
hashValue = oddPrimeNumber * hashValue + this.parentFormat;
hashValue = oddPrimeNumber * hashValue + this.fontIndex;
hashValue = oddPrimeNumber * hashValue + this.formatIndex;
hashValue = oddPrimeNumber * hashValue + this.indentation;
return hashValue;
}
public boolean equals(Object o) {
if (o == this)
return true;
if (!(o instanceof XFRecord))
return false;
XFRecord xfr = (XFRecord)o;
if (!this.formatInfoInitialized)
initializeFormatInformation();
if (!xfr.formatInfoInitialized)
xfr.initializeFormatInformation();
if (this.xfFormatType != xfr.xfFormatType || this.parentFormat != xfr.parentFormat || this.locked != xfr.locked || this.hidden != xfr.hidden || this.usedAttributes != xfr.usedAttributes)
return false;
if (this.align != xfr.align || this.valign != xfr.valign || this.orientation != xfr.orientation || this.wrap != xfr.wrap || this.shrinkToFit != xfr.shrinkToFit || this.indentation != xfr.indentation)
return false;
if (this.leftBorder != xfr.leftBorder || this.rightBorder != xfr.rightBorder || this.topBorder != xfr.topBorder || this.bottomBorder != xfr.bottomBorder)
return false;
if (this.leftBorderColour != xfr.leftBorderColour || this.rightBorderColour != xfr.rightBorderColour || this.topBorderColour != xfr.topBorderColour || this.bottomBorderColour != xfr.bottomBorderColour)
return false;
if (this.backgroundColour != xfr.backgroundColour || this.pattern != xfr.pattern)
return false;
if (this.initialized && xfr.initialized) {
if (this.fontIndex != xfr.fontIndex || this.formatIndex != xfr.formatIndex)
return false;
} else if (!this.font.equals(xfr.font) || !this.format.equals(xfr.format)) {
return false;
}
return true;
}
void setFormatIndex(int newindex) {
this.formatIndex = newindex;
}
public int getFontIndex() {
return this.fontIndex;
}
void setFontIndex(int newindex) {
this.fontIndex = newindex;
}
protected void setXFDetails(XFType t, int pf) {
this.xfFormatType = t;
this.parentFormat = pf;
}
void rationalize(IndexMapping xfMapping) {
this.xfIndex = xfMapping.getNewIndex(this.xfIndex);
if (this.xfFormatType == cell)
this.parentFormat = xfMapping.getNewIndex(this.parentFormat);
}
public void setFont(FontRecord f) {
this.font = f;
}
}

View file

@ -0,0 +1,33 @@
package jxl.biff.drawing;
import jxl.common.Logger;
class BStoreContainer extends EscherContainer {
private static Logger logger = Logger.getLogger(BStoreContainer.class);
private int numBlips;
public BStoreContainer(EscherRecordData erd) {
super(erd);
this.numBlips = getInstance();
}
public BStoreContainer() {
super(EscherRecordType.BSTORE_CONTAINER);
}
void setNumBlips(int count) {
this.numBlips = count;
setInstance(this.numBlips);
}
public int getNumBlips() {
return this.numBlips;
}
public BlipStoreEntry getDrawing(int i) {
EscherRecord[] children = getChildren();
BlipStoreEntry bse = (BlipStoreEntry)children[i];
return bse;
}
}

View file

@ -0,0 +1,84 @@
package jxl.biff.drawing;
import java.io.IOException;
import jxl.biff.IntegerHelper;
import jxl.common.Assert;
import jxl.common.Logger;
class BlipStoreEntry extends EscherAtom {
private static Logger logger = Logger.getLogger(BlipStoreEntry.class);
private BlipType type;
private byte[] data;
private int imageDataLength;
private int referenceCount;
private boolean write;
private static final int IMAGE_DATA_OFFSET = 61;
public BlipStoreEntry(EscherRecordData erd) {
super(erd);
this.type = BlipType.getType(getInstance());
this.write = false;
byte[] bytes = getBytes();
this.referenceCount = IntegerHelper.getInt(bytes[24], bytes[25], bytes[26], bytes[27]);
}
public BlipStoreEntry(Drawing d) throws IOException {
super(EscherRecordType.BSE);
this.type = BlipType.PNG;
setVersion(2);
setInstance(this.type.getValue());
byte[] imageData = d.getImageBytes();
this.imageDataLength = imageData.length;
this.data = new byte[this.imageDataLength + 61];
System.arraycopy(imageData, 0, this.data, 61, this.imageDataLength);
this.referenceCount = d.getReferenceCount();
this.write = true;
}
public BlipType getBlipType() {
return this.type;
}
public byte[] getData() {
if (this.write) {
this.data[0] = (byte)this.type.getValue();
this.data[1] = (byte)this.type.getValue();
IntegerHelper.getFourBytes(this.imageDataLength + 8 + 17, this.data, 20);
IntegerHelper.getFourBytes(this.referenceCount, this.data, 24);
IntegerHelper.getFourBytes(0, this.data, 28);
this.data[32] = 0;
this.data[33] = 0;
this.data[34] = 126;
this.data[35] = 1;
this.data[36] = 0;
this.data[37] = 110;
IntegerHelper.getTwoBytes(61470, this.data, 38);
IntegerHelper.getFourBytes(this.imageDataLength + 17, this.data, 40);
} else {
this.data = getBytes();
}
return setHeaderData(this.data);
}
void dereference() {
this.referenceCount--;
Assert.verify((this.referenceCount >= 0));
}
int getReferenceCount() {
return this.referenceCount;
}
byte[] getImageData() {
byte[] allData = getBytes();
byte[] imageData = new byte[allData.length - 61];
System.arraycopy(allData, 61, imageData, 0, imageData.length);
return imageData;
}
}

View file

@ -0,0 +1,57 @@
package jxl.biff.drawing;
final class BlipType {
private int value;
private String desc;
private static BlipType[] types = new BlipType[0];
private BlipType(int val, String d) {
this.value = val;
this.desc = d;
BlipType[] newtypes = new BlipType[types.length + 1];
System.arraycopy(types, 0, newtypes, 0, types.length);
newtypes[types.length] = this;
types = newtypes;
}
public String getDescription() {
return this.desc;
}
public int getValue() {
return this.value;
}
public static BlipType getType(int val) {
BlipType type = UNKNOWN;
for (int i = 0; i < types.length; i++) {
if ((types[i]).value == val) {
type = types[i];
break;
}
}
return type;
}
public static final BlipType ERROR = new BlipType(0, "Error");
public static final BlipType UNKNOWN = new BlipType(1, "Unknown");
public static final BlipType EMF = new BlipType(2, "EMF");
public static final BlipType WMF = new BlipType(3, "WMF");
public static final BlipType PICT = new BlipType(4, "PICT");
public static final BlipType JPEG = new BlipType(5, "JPEG");
public static final BlipType PNG = new BlipType(6, "PNG");
public static final BlipType DIB = new BlipType(7, "DIB");
public static final BlipType FIRST_CLIENT = new BlipType(32, "FIRST");
public static final BlipType LAST_CLIENT = new BlipType(255, "LAST");
}

View file

@ -0,0 +1,358 @@
package jxl.biff.drawing;
import java.io.IOException;
import jxl.WorkbookSettings;
import jxl.biff.ContinueRecord;
import jxl.biff.IntegerHelper;
import jxl.biff.StringHelper;
import jxl.common.Assert;
import jxl.common.Logger;
import jxl.write.biff.File;
public class Button implements DrawingGroupObject {
private static Logger logger = Logger.getLogger(Button.class);
private EscherContainer readSpContainer;
private EscherContainer spContainer;
private MsoDrawingRecord msoDrawingRecord;
private ObjRecord objRecord;
private boolean initialized = false;
private int objectId;
private int blipId;
private int shapeId;
private int column;
private int row;
private double width;
private double height;
private int referenceCount;
private EscherContainer escherData;
private Origin origin;
private DrawingGroup drawingGroup;
private DrawingData drawingData;
private ShapeType type;
private int drawingNumber;
private MsoDrawingRecord mso;
private TextObjectRecord txo;
private ContinueRecord text;
private ContinueRecord formatting;
private String commentText;
private WorkbookSettings workbookSettings;
public Button(MsoDrawingRecord msodr, ObjRecord obj, DrawingData dd, DrawingGroup dg, WorkbookSettings ws) {
this.drawingGroup = dg;
this.msoDrawingRecord = msodr;
this.drawingData = dd;
this.objRecord = obj;
this.initialized = false;
this.workbookSettings = ws;
this.origin = Origin.READ;
this.drawingData.addData(this.msoDrawingRecord.getData());
this.drawingNumber = this.drawingData.getNumDrawings() - 1;
this.drawingGroup.addDrawing(this);
Assert.verify((this.msoDrawingRecord != null && this.objRecord != null));
initialize();
}
public Button(DrawingGroupObject dgo, DrawingGroup dg, WorkbookSettings ws) {
Button d = (Button)dgo;
Assert.verify((d.origin == Origin.READ));
this.msoDrawingRecord = d.msoDrawingRecord;
this.objRecord = d.objRecord;
this.initialized = false;
this.origin = Origin.READ;
this.drawingData = d.drawingData;
this.drawingGroup = dg;
this.drawingNumber = d.drawingNumber;
this.drawingGroup.addDrawing(this);
this.mso = d.mso;
this.txo = d.txo;
this.text = d.text;
this.formatting = d.formatting;
this.workbookSettings = ws;
}
private void initialize() {
this.readSpContainer = this.drawingData.getSpContainer(this.drawingNumber);
Assert.verify((this.readSpContainer != null));
EscherRecord[] children = this.readSpContainer.getChildren();
Sp sp = (Sp)this.readSpContainer.getChildren()[0];
this.objectId = this.objRecord.getObjectId();
this.shapeId = sp.getShapeId();
this.type = ShapeType.getType(sp.getShapeType());
if (this.type == ShapeType.UNKNOWN)
logger.warn("Unknown shape type");
ClientAnchor clientAnchor = null;
for (int i = 0; i < children.length && clientAnchor == null; i++) {
if (children[i].getType() == EscherRecordType.CLIENT_ANCHOR)
clientAnchor = (ClientAnchor)children[i];
}
if (clientAnchor == null) {
logger.warn("Client anchor not found");
} else {
this.column = (int)clientAnchor.getX1() - 1;
this.row = (int)clientAnchor.getY1() + 1;
}
this.initialized = true;
}
public final void setObjectId(int objid, int bip, int sid) {
this.objectId = objid;
this.blipId = bip;
this.shapeId = sid;
if (this.origin == Origin.READ)
this.origin = Origin.READ_WRITE;
}
public final int getObjectId() {
if (!this.initialized)
initialize();
return this.objectId;
}
public final int getShapeId() {
if (!this.initialized)
initialize();
return this.shapeId;
}
public final int getBlipId() {
if (!this.initialized)
initialize();
return this.blipId;
}
public MsoDrawingRecord getMsoDrawingRecord() {
return this.msoDrawingRecord;
}
public EscherContainer getSpContainer() {
if (!this.initialized)
initialize();
if (this.origin == Origin.READ)
return getReadSpContainer();
Assert.verify(false);
return this.spContainer;
}
public void setDrawingGroup(DrawingGroup dg) {
this.drawingGroup = dg;
}
public DrawingGroup getDrawingGroup() {
return this.drawingGroup;
}
public Origin getOrigin() {
return this.origin;
}
public int getReferenceCount() {
return this.referenceCount;
}
public void setReferenceCount(int r) {
this.referenceCount = r;
}
public double getX() {
if (!this.initialized)
initialize();
return (double)this.column;
}
public void setX(double x) {
if (this.origin == Origin.READ) {
if (!this.initialized)
initialize();
this.origin = Origin.READ_WRITE;
}
this.column = (int)x;
}
public double getY() {
if (!this.initialized)
initialize();
return (double)this.row;
}
public void setY(double y) {
if (this.origin == Origin.READ) {
if (!this.initialized)
initialize();
this.origin = Origin.READ_WRITE;
}
this.row = (int)y;
}
public double getWidth() {
if (!this.initialized)
initialize();
return this.width;
}
public void setWidth(double w) {
if (this.origin == Origin.READ) {
if (!this.initialized)
initialize();
this.origin = Origin.READ_WRITE;
}
this.width = w;
}
public double getHeight() {
if (!this.initialized)
initialize();
return this.height;
}
public void setHeight(double h) {
if (this.origin == Origin.READ) {
if (!this.initialized)
initialize();
this.origin = Origin.READ_WRITE;
}
this.height = h;
}
private EscherContainer getReadSpContainer() {
if (!this.initialized)
initialize();
return this.readSpContainer;
}
public byte[] getImageData() {
Assert.verify((this.origin == Origin.READ || this.origin == Origin.READ_WRITE));
if (!this.initialized)
initialize();
return this.drawingGroup.getImageData(this.blipId);
}
public ShapeType getType() {
return this.type;
}
public void setTextObject(TextObjectRecord t) {
this.txo = t;
}
public void setText(ContinueRecord t) {
this.text = t;
}
public void setFormatting(ContinueRecord t) {
this.formatting = t;
}
public byte[] getImageBytes() {
Assert.verify(false);
return null;
}
public String getImageFilePath() {
Assert.verify(false);
return null;
}
public void addMso(MsoDrawingRecord d) {
this.mso = d;
this.drawingData.addRawData(this.mso.getData());
}
public void writeAdditionalRecords(File outputFile) throws IOException {
if (this.origin == Origin.READ) {
outputFile.write(this.objRecord);
if (this.mso != null)
outputFile.write(this.mso);
outputFile.write(this.txo);
outputFile.write(this.text);
if (this.formatting != null)
outputFile.write(this.formatting);
return;
}
Assert.verify(false);
ObjRecord objrec = new ObjRecord(this.objectId, ObjRecord.EXCELNOTE);
outputFile.write(objrec);
ClientTextBox textBox = new ClientTextBox();
MsoDrawingRecord msod = new MsoDrawingRecord(textBox.getData());
outputFile.write(msod);
TextObjectRecord tor = new TextObjectRecord(getText());
outputFile.write(tor);
byte[] textData = new byte[this.commentText.length() * 2 + 1];
textData[0] = 1;
StringHelper.getUnicodeBytes(this.commentText, textData, 1);
ContinueRecord textContinue = new ContinueRecord(textData);
outputFile.write(textContinue);
byte[] frData = new byte[16];
IntegerHelper.getTwoBytes(0, frData, 0);
IntegerHelper.getTwoBytes(0, frData, 2);
IntegerHelper.getTwoBytes(this.commentText.length(), frData, 8);
IntegerHelper.getTwoBytes(0, frData, 10);
ContinueRecord frContinue = new ContinueRecord(frData);
outputFile.write(frContinue);
}
public void writeTailRecords(File outputFile) {}
public int getRow() {
return 0;
}
public int getColumn() {
return 0;
}
public String getText() {
if (this.commentText == null) {
Assert.verify((this.text != null));
byte[] td = this.text.getData();
if (td[0] == 0) {
this.commentText = StringHelper.getString(td, td.length - 1, 1, this.workbookSettings);
} else {
this.commentText = StringHelper.getUnicodeString(td, (td.length - 1) / 2, 1);
}
}
return this.commentText;
}
public int hashCode() {
return this.commentText.hashCode();
}
public void setButtonText(String t) {
this.commentText = t;
if (this.origin == Origin.READ)
this.origin = Origin.READ_WRITE;
}
public boolean isFirst() {
return this.mso.isFirst();
}
public boolean isFormObject() {
return true;
}
}

View file

@ -0,0 +1,111 @@
package jxl.biff.drawing;
import jxl.WorkbookSettings;
import jxl.biff.ByteData;
import jxl.biff.IndexMapping;
import jxl.biff.IntegerHelper;
import jxl.biff.Type;
import jxl.common.Assert;
import jxl.common.Logger;
import jxl.read.biff.File;
public class Chart implements ByteData, EscherStream {
private static final Logger logger = Logger.getLogger(Chart.class);
private MsoDrawingRecord msoDrawingRecord;
private ObjRecord objRecord;
private int startpos;
private int endpos;
private File file;
private DrawingData drawingData;
private int drawingNumber;
private byte[] data;
private boolean initialized;
private WorkbookSettings workbookSettings;
public Chart(MsoDrawingRecord mso, ObjRecord obj, DrawingData dd, int sp, int ep, File f, WorkbookSettings ws) {
this.msoDrawingRecord = mso;
this.objRecord = obj;
this.startpos = sp;
this.endpos = ep;
this.file = f;
this.workbookSettings = ws;
if (this.msoDrawingRecord != null) {
this.drawingData = dd;
this.drawingData.addData(this.msoDrawingRecord.getRecord().getData());
this.drawingNumber = this.drawingData.getNumDrawings() - 1;
}
this.initialized = false;
Assert.verify(((mso != null && obj != null) || (mso == null && obj == null)));
}
public byte[] getBytes() {
if (!this.initialized)
initialize();
return this.data;
}
public byte[] getData() {
return this.msoDrawingRecord.getRecord().getData();
}
private void initialize() {
this.data = this.file.read(this.startpos, this.endpos - this.startpos);
this.initialized = true;
}
public void rationalize(IndexMapping xfMapping, IndexMapping fontMapping, IndexMapping formatMapping) {
if (!this.initialized)
initialize();
int pos = 0;
int code = 0;
int length = 0;
Type type = null;
while (pos < this.data.length) {
code = IntegerHelper.getInt(this.data[pos], this.data[pos + 1]);
length = IntegerHelper.getInt(this.data[pos + 2], this.data[pos + 3]);
type = Type.getType(code);
if (type == Type.FONTX) {
int fontind = IntegerHelper.getInt(this.data[pos + 4], this.data[pos + 5]);
IntegerHelper.getTwoBytes(fontMapping.getNewIndex(fontind), this.data, pos + 4);
} else if (type == Type.FBI) {
int fontind = IntegerHelper.getInt(this.data[pos + 12], this.data[pos + 13]);
IntegerHelper.getTwoBytes(fontMapping.getNewIndex(fontind), this.data, pos + 12);
} else if (type == Type.IFMT) {
int formind = IntegerHelper.getInt(this.data[pos + 4], this.data[pos + 5]);
IntegerHelper.getTwoBytes(formatMapping.getNewIndex(formind), this.data, pos + 4);
} else if (type == Type.ALRUNS) {
int numRuns = IntegerHelper.getInt(this.data[pos + 4], this.data[pos + 5]);
int fontPos = pos + 6;
for (int i = 0; i < numRuns; i++) {
int fontind = IntegerHelper.getInt(this.data[fontPos + 2], this.data[fontPos + 3]);
IntegerHelper.getTwoBytes(fontMapping.getNewIndex(fontind), this.data, fontPos + 2);
fontPos += 4;
}
}
pos += length + 4;
}
}
EscherContainer getSpContainer() {
EscherContainer spContainer = this.drawingData.getSpContainer(this.drawingNumber);
return spContainer;
}
MsoDrawingRecord getMsoDrawingRecord() {
return this.msoDrawingRecord;
}
ObjRecord getObjRecord() {
return this.objRecord;
}
}

View file

@ -0,0 +1,337 @@
package jxl.biff.drawing;
import java.io.IOException;
import jxl.WorkbookSettings;
import jxl.biff.ContinueRecord;
import jxl.common.Assert;
import jxl.common.Logger;
import jxl.write.biff.File;
public class CheckBox implements DrawingGroupObject {
private static Logger logger = Logger.getLogger(CheckBox.class);
private EscherContainer readSpContainer;
private EscherContainer spContainer;
private MsoDrawingRecord msoDrawingRecord;
private ObjRecord objRecord;
private boolean initialized = false;
private int objectId;
private int blipId;
private int shapeId;
private int column;
private int row;
private double width;
private double height;
private int referenceCount;
private EscherContainer escherData;
private Origin origin;
private DrawingGroup drawingGroup;
private DrawingData drawingData;
private ShapeType type;
private int drawingNumber;
private MsoDrawingRecord mso;
private TextObjectRecord txo;
private ContinueRecord text;
private ContinueRecord formatting;
private WorkbookSettings workbookSettings;
public CheckBox(MsoDrawingRecord mso, ObjRecord obj, DrawingData dd, DrawingGroup dg, WorkbookSettings ws) {
this.drawingGroup = dg;
this.msoDrawingRecord = mso;
this.drawingData = dd;
this.objRecord = obj;
this.initialized = false;
this.workbookSettings = ws;
this.origin = Origin.READ;
this.drawingData.addData(this.msoDrawingRecord.getData());
this.drawingNumber = this.drawingData.getNumDrawings() - 1;
this.drawingGroup.addDrawing(this);
Assert.verify((mso != null && obj != null));
initialize();
}
public CheckBox(DrawingGroupObject dgo, DrawingGroup dg, WorkbookSettings ws) {
CheckBox d = (CheckBox)dgo;
Assert.verify((d.origin == Origin.READ));
this.msoDrawingRecord = d.msoDrawingRecord;
this.objRecord = d.objRecord;
this.initialized = false;
this.origin = Origin.READ;
this.drawingData = d.drawingData;
this.drawingGroup = dg;
this.drawingNumber = d.drawingNumber;
this.drawingGroup.addDrawing(this);
this.mso = d.mso;
this.txo = d.txo;
this.text = d.text;
this.formatting = d.formatting;
this.workbookSettings = ws;
}
public CheckBox() {
this.initialized = true;
this.origin = Origin.WRITE;
this.referenceCount = 1;
this.type = ShapeType.HOST_CONTROL;
}
private void initialize() {
this.readSpContainer = this.drawingData.getSpContainer(this.drawingNumber);
Assert.verify((this.readSpContainer != null));
EscherRecord[] children = this.readSpContainer.getChildren();
Sp sp = (Sp)this.readSpContainer.getChildren()[0];
this.objectId = this.objRecord.getObjectId();
this.shapeId = sp.getShapeId();
this.type = ShapeType.getType(sp.getShapeType());
if (this.type == ShapeType.UNKNOWN)
logger.warn("Unknown shape type");
ClientAnchor clientAnchor = null;
for (int i = 0; i < children.length && clientAnchor == null; i++) {
if (children[i].getType() == EscherRecordType.CLIENT_ANCHOR)
clientAnchor = (ClientAnchor)children[i];
}
if (clientAnchor == null) {
logger.warn("Client anchor not found");
} else {
this.column = (int)clientAnchor.getX1();
this.row = (int)clientAnchor.getY1();
}
this.initialized = true;
}
public final void setObjectId(int objid, int bip, int sid) {
this.objectId = objid;
this.blipId = bip;
this.shapeId = sid;
if (this.origin == Origin.READ)
this.origin = Origin.READ_WRITE;
}
public final int getObjectId() {
if (!this.initialized)
initialize();
return this.objectId;
}
public final int getShapeId() {
if (!this.initialized)
initialize();
return this.shapeId;
}
public final int getBlipId() {
if (!this.initialized)
initialize();
return this.blipId;
}
public MsoDrawingRecord getMsoDrawingRecord() {
return this.msoDrawingRecord;
}
public EscherContainer getSpContainer() {
if (!this.initialized)
initialize();
if (this.origin == Origin.READ)
return getReadSpContainer();
SpContainer spc = new SpContainer();
Sp sp = new Sp(this.type, this.shapeId, 2560);
spc.add(sp);
Opt opt = new Opt();
opt.addProperty(127, false, false, 17039620);
opt.addProperty(191, false, false, 524296);
opt.addProperty(511, false, false, 524288);
opt.addProperty(959, false, false, 131072);
spc.add(opt);
ClientAnchor clientAnchor = new ClientAnchor((double)this.column, (double)this.row, (double)(this.column + 1), (double)(this.row + 1), 1);
spc.add(clientAnchor);
ClientData clientData = new ClientData();
spc.add(clientData);
return spc;
}
public void setDrawingGroup(DrawingGroup dg) {
this.drawingGroup = dg;
}
public DrawingGroup getDrawingGroup() {
return this.drawingGroup;
}
public Origin getOrigin() {
return this.origin;
}
public int getReferenceCount() {
return this.referenceCount;
}
public void setReferenceCount(int r) {
this.referenceCount = r;
}
public double getX() {
if (!this.initialized)
initialize();
return (double)this.column;
}
public void setX(double x) {
if (this.origin == Origin.READ) {
if (!this.initialized)
initialize();
this.origin = Origin.READ_WRITE;
}
this.column = (int)x;
}
public double getY() {
if (!this.initialized)
initialize();
return (double)this.row;
}
public void setY(double y) {
if (this.origin == Origin.READ) {
if (!this.initialized)
initialize();
this.origin = Origin.READ_WRITE;
}
this.row = (int)y;
}
public double getWidth() {
if (!this.initialized)
initialize();
return this.width;
}
public void setWidth(double w) {
if (this.origin == Origin.READ) {
if (!this.initialized)
initialize();
this.origin = Origin.READ_WRITE;
}
this.width = w;
}
public double getHeight() {
if (!this.initialized)
initialize();
return this.height;
}
public void setHeight(double h) {
if (this.origin == Origin.READ) {
if (!this.initialized)
initialize();
this.origin = Origin.READ_WRITE;
}
this.height = h;
}
private EscherContainer getReadSpContainer() {
if (!this.initialized)
initialize();
return this.readSpContainer;
}
public byte[] getImageData() {
Assert.verify((this.origin == Origin.READ || this.origin == Origin.READ_WRITE));
if (!this.initialized)
initialize();
return this.drawingGroup.getImageData(this.blipId);
}
public ShapeType getType() {
return this.type;
}
public byte[] getImageBytes() {
Assert.verify(false);
return null;
}
public String getImageFilePath() {
Assert.verify(false);
return null;
}
public void writeAdditionalRecords(File outputFile) throws IOException {
if (this.origin == Origin.READ) {
outputFile.write(this.objRecord);
if (this.mso != null)
outputFile.write(this.mso);
outputFile.write(this.txo);
outputFile.write(this.text);
if (this.formatting != null)
outputFile.write(this.formatting);
return;
}
ObjRecord objrec = new ObjRecord(this.objectId, ObjRecord.CHECKBOX);
outputFile.write(objrec);
logger.warn("Writing of additional records for checkboxes not implemented");
}
public void writeTailRecords(File outputFile) {}
public int getRow() {
return 0;
}
public int getColumn() {
return 0;
}
public int hashCode() {
return getClass().getName().hashCode();
}
public boolean isFirst() {
return this.msoDrawingRecord.isFirst();
}
public boolean isFormObject() {
return false;
}
public void setTextObject(TextObjectRecord t) {
this.txo = t;
}
public void setText(ContinueRecord t) {
this.text = t;
}
public void setFormatting(ContinueRecord t) {
this.formatting = t;
}
public void addMso(MsoDrawingRecord d) {
this.mso = d;
this.drawingData.addRawData(this.mso.getData());
}
}

View file

@ -0,0 +1,23 @@
package jxl.biff.drawing;
class Chunk {
private int pos;
private int length;
private ChunkType type;
private byte[] data;
public Chunk(int p, int l, ChunkType ct, byte[] d) {
this.pos = p;
this.length = l;
this.type = ct;
this.data = new byte[this.length];
System.arraycopy(d, this.pos, this.data, 0, this.length);
}
public byte[] getData() {
return this.data;
}
}

View file

@ -0,0 +1,45 @@
package jxl.biff.drawing;
import java.util.Arrays;
class ChunkType {
private byte[] id;
private String name;
private static ChunkType[] chunkTypes = new ChunkType[0];
private ChunkType(int d1, int d2, int d3, int d4, String n) {
this.id = new byte[] { (byte)d1, (byte)d2, (byte)d3, (byte)d4 };
this.name = n;
ChunkType[] ct = new ChunkType[chunkTypes.length + 1];
System.arraycopy(chunkTypes, 0, ct, 0, chunkTypes.length);
ct[chunkTypes.length] = this;
chunkTypes = ct;
}
public String getName() {
return this.name;
}
public static ChunkType getChunkType(byte d1, byte d2, byte d3, byte d4) {
byte[] cmp = { d1, d2, d3, d4 };
boolean found = false;
ChunkType chunk = UNKNOWN;
for (int i = 0; i < chunkTypes.length && !found; i++) {
if (Arrays.equals((chunkTypes[i]).id, cmp)) {
chunk = chunkTypes[i];
found = true;
}
}
return chunk;
}
public static ChunkType IHDR = new ChunkType(73, 72, 68, 82, "IHDR");
public static ChunkType IEND = new ChunkType(73, 69, 78, 68, "IEND");
public static ChunkType PHYS = new ChunkType(112, 72, 89, 115, "pHYs");
public static ChunkType UNKNOWN = new ChunkType(255, 255, 255, 255, "UNKNOWN");
}

View file

@ -0,0 +1,85 @@
package jxl.biff.drawing;
import jxl.biff.IntegerHelper;
import jxl.common.Logger;
class ClientAnchor extends EscherAtom {
private static final Logger logger = Logger.getLogger(ClientAnchor.class);
private byte[] data;
private int properties;
private double x1;
private double y1;
private double x2;
private double y2;
public ClientAnchor(EscherRecordData erd) {
super(erd);
byte[] bytes = getBytes();
this.properties = IntegerHelper.getInt(bytes[0], bytes[1]);
int x1Cell = IntegerHelper.getInt(bytes[2], bytes[3]);
int x1Fraction = IntegerHelper.getInt(bytes[4], bytes[5]);
this.x1 = (double)x1Cell + (double)x1Fraction / 1024.0D;
int y1Cell = IntegerHelper.getInt(bytes[6], bytes[7]);
int y1Fraction = IntegerHelper.getInt(bytes[8], bytes[9]);
this.y1 = (double)y1Cell + (double)y1Fraction / 256.0D;
int x2Cell = IntegerHelper.getInt(bytes[10], bytes[11]);
int x2Fraction = IntegerHelper.getInt(bytes[12], bytes[13]);
this.x2 = (double)x2Cell + (double)x2Fraction / 1024.0D;
int y2Cell = IntegerHelper.getInt(bytes[14], bytes[15]);
int y2Fraction = IntegerHelper.getInt(bytes[16], bytes[17]);
this.y2 = (double)y2Cell + (double)y2Fraction / 256.0D;
}
public ClientAnchor(double x1, double y1, double x2, double y2, int props) {
super(EscherRecordType.CLIENT_ANCHOR);
this.x1 = x1;
this.y1 = y1;
this.x2 = x2;
this.y2 = y2;
this.properties = props;
}
byte[] getData() {
this.data = new byte[18];
IntegerHelper.getTwoBytes(this.properties, this.data, 0);
IntegerHelper.getTwoBytes((int)this.x1, this.data, 2);
int x1fraction = (int)((this.x1 - (double)(int)this.x1) * 1024.0D);
IntegerHelper.getTwoBytes(x1fraction, this.data, 4);
IntegerHelper.getTwoBytes((int)this.y1, this.data, 6);
int y1fraction = (int)((this.y1 - (double)(int)this.y1) * 256.0D);
IntegerHelper.getTwoBytes(y1fraction, this.data, 8);
IntegerHelper.getTwoBytes((int)this.x2, this.data, 10);
int x2fraction = (int)((this.x2 - (double)(int)this.x2) * 1024.0D);
IntegerHelper.getTwoBytes(x2fraction, this.data, 12);
IntegerHelper.getTwoBytes((int)this.y2, this.data, 14);
int y2fraction = (int)((this.y2 - (double)(int)this.y2) * 256.0D);
IntegerHelper.getTwoBytes(y2fraction, this.data, 16);
return setHeaderData(this.data);
}
double getX1() {
return this.x1;
}
double getY1() {
return this.y1;
}
double getX2() {
return this.x2;
}
double getY2() {
return this.y2;
}
int getProperties() {
return this.properties;
}
}

View file

@ -0,0 +1,22 @@
package jxl.biff.drawing;
import jxl.common.Logger;
class ClientData extends EscherAtom {
private static Logger logger = Logger.getLogger(ClientData.class);
private byte[] data;
public ClientData(EscherRecordData erd) {
super(erd);
}
public ClientData() {
super(EscherRecordType.CLIENT_DATA);
}
byte[] getData() {
this.data = new byte[0];
return setHeaderData(this.data);
}
}

View file

@ -0,0 +1,22 @@
package jxl.biff.drawing;
import jxl.common.Logger;
class ClientTextBox extends EscherAtom {
private static Logger logger = Logger.getLogger(ClientTextBox.class);
private byte[] data;
public ClientTextBox(EscherRecordData erd) {
super(erd);
}
public ClientTextBox() {
super(EscherRecordType.CLIENT_TEXT_BOX);
}
byte[] getData() {
this.data = new byte[0];
return setHeaderData(this.data);
}
}

View file

@ -0,0 +1,300 @@
package jxl.biff.drawing;
import java.io.IOException;
import jxl.WorkbookSettings;
import jxl.common.Assert;
import jxl.common.Logger;
import jxl.write.biff.File;
public class ComboBox implements DrawingGroupObject {
private static Logger logger = Logger.getLogger(ComboBox.class);
private EscherContainer readSpContainer;
private EscherContainer spContainer;
private MsoDrawingRecord msoDrawingRecord;
private ObjRecord objRecord;
private boolean initialized = false;
private int objectId;
private int blipId;
private int shapeId;
private int column;
private int row;
private double width;
private double height;
private int referenceCount;
private EscherContainer escherData;
private Origin origin;
private DrawingGroup drawingGroup;
private DrawingData drawingData;
private ShapeType type;
private int drawingNumber;
private WorkbookSettings workbookSettings;
public ComboBox(MsoDrawingRecord mso, ObjRecord obj, DrawingData dd, DrawingGroup dg, WorkbookSettings ws) {
this.drawingGroup = dg;
this.msoDrawingRecord = mso;
this.drawingData = dd;
this.objRecord = obj;
this.initialized = false;
this.workbookSettings = ws;
this.origin = Origin.READ;
this.drawingData.addData(this.msoDrawingRecord.getData());
this.drawingNumber = this.drawingData.getNumDrawings() - 1;
this.drawingGroup.addDrawing(this);
Assert.verify((mso != null && obj != null));
initialize();
}
public ComboBox(DrawingGroupObject dgo, DrawingGroup dg, WorkbookSettings ws) {
ComboBox d = (ComboBox)dgo;
Assert.verify((d.origin == Origin.READ));
this.msoDrawingRecord = d.msoDrawingRecord;
this.objRecord = d.objRecord;
this.initialized = false;
this.origin = Origin.READ;
this.drawingData = d.drawingData;
this.drawingGroup = dg;
this.drawingNumber = d.drawingNumber;
this.drawingGroup.addDrawing(this);
this.workbookSettings = ws;
}
public ComboBox() {
this.initialized = true;
this.origin = Origin.WRITE;
this.referenceCount = 1;
this.type = ShapeType.HOST_CONTROL;
}
private void initialize() {
this.readSpContainer = this.drawingData.getSpContainer(this.drawingNumber);
Assert.verify((this.readSpContainer != null));
EscherRecord[] children = this.readSpContainer.getChildren();
Sp sp = (Sp)this.readSpContainer.getChildren()[0];
this.objectId = this.objRecord.getObjectId();
this.shapeId = sp.getShapeId();
this.type = ShapeType.getType(sp.getShapeType());
if (this.type == ShapeType.UNKNOWN)
logger.warn("Unknown shape type");
ClientAnchor clientAnchor = null;
for (int i = 0; i < children.length && clientAnchor == null; i++) {
if (children[i].getType() == EscherRecordType.CLIENT_ANCHOR)
clientAnchor = (ClientAnchor)children[i];
}
if (clientAnchor == null) {
logger.warn("Client anchor not found");
} else {
this.column = (int)clientAnchor.getX1();
this.row = (int)clientAnchor.getY1();
}
this.initialized = true;
}
public final void setObjectId(int objid, int bip, int sid) {
this.objectId = objid;
this.blipId = bip;
this.shapeId = sid;
if (this.origin == Origin.READ)
this.origin = Origin.READ_WRITE;
}
public final int getObjectId() {
if (!this.initialized)
initialize();
return this.objectId;
}
public final int getShapeId() {
if (!this.initialized)
initialize();
return this.shapeId;
}
public final int getBlipId() {
if (!this.initialized)
initialize();
return this.blipId;
}
public MsoDrawingRecord getMsoDrawingRecord() {
return this.msoDrawingRecord;
}
public EscherContainer getSpContainer() {
if (!this.initialized)
initialize();
if (this.origin == Origin.READ)
return getReadSpContainer();
SpContainer spc = new SpContainer();
Sp sp = new Sp(this.type, this.shapeId, 2560);
spc.add(sp);
Opt opt = new Opt();
opt.addProperty(127, false, false, 17039620);
opt.addProperty(191, false, false, 524296);
opt.addProperty(511, false, false, 524288);
opt.addProperty(959, false, false, 131072);
spc.add(opt);
ClientAnchor clientAnchor = new ClientAnchor((double)this.column, (double)this.row, (double)(this.column + 1), (double)(this.row + 1), 1);
spc.add(clientAnchor);
ClientData clientData = new ClientData();
spc.add(clientData);
return spc;
}
public void setDrawingGroup(DrawingGroup dg) {
this.drawingGroup = dg;
}
public DrawingGroup getDrawingGroup() {
return this.drawingGroup;
}
public Origin getOrigin() {
return this.origin;
}
public int getReferenceCount() {
return this.referenceCount;
}
public void setReferenceCount(int r) {
this.referenceCount = r;
}
public double getX() {
if (!this.initialized)
initialize();
return (double)this.column;
}
public void setX(double x) {
if (this.origin == Origin.READ) {
if (!this.initialized)
initialize();
this.origin = Origin.READ_WRITE;
}
this.column = (int)x;
}
public double getY() {
if (!this.initialized)
initialize();
return (double)this.row;
}
public void setY(double y) {
if (this.origin == Origin.READ) {
if (!this.initialized)
initialize();
this.origin = Origin.READ_WRITE;
}
this.row = (int)y;
}
public double getWidth() {
if (!this.initialized)
initialize();
return this.width;
}
public void setWidth(double w) {
if (this.origin == Origin.READ) {
if (!this.initialized)
initialize();
this.origin = Origin.READ_WRITE;
}
this.width = w;
}
public double getHeight() {
if (!this.initialized)
initialize();
return this.height;
}
public void setHeight(double h) {
if (this.origin == Origin.READ) {
if (!this.initialized)
initialize();
this.origin = Origin.READ_WRITE;
}
this.height = h;
}
private EscherContainer getReadSpContainer() {
if (!this.initialized)
initialize();
return this.readSpContainer;
}
public byte[] getImageData() {
Assert.verify((this.origin == Origin.READ || this.origin == Origin.READ_WRITE));
if (!this.initialized)
initialize();
return this.drawingGroup.getImageData(this.blipId);
}
public ShapeType getType() {
return this.type;
}
public byte[] getImageBytes() {
Assert.verify(false);
return null;
}
public String getImageFilePath() {
Assert.verify(false);
return null;
}
public void writeAdditionalRecords(File outputFile) throws IOException {
if (this.origin == Origin.READ) {
outputFile.write(this.objRecord);
return;
}
ObjRecord objrec = new ObjRecord(this.objectId, ObjRecord.COMBOBOX);
outputFile.write(objrec);
}
public void writeTailRecords(File outputFile) {}
public int getRow() {
return 0;
}
public int getColumn() {
return 0;
}
public int hashCode() {
return getClass().getName().hashCode();
}
public boolean isFirst() {
return this.msoDrawingRecord.isFirst();
}
public boolean isFormObject() {
return false;
}
}

View file

@ -0,0 +1,404 @@
package jxl.biff.drawing;
import java.io.IOException;
import jxl.WorkbookSettings;
import jxl.biff.ContinueRecord;
import jxl.biff.IntegerHelper;
import jxl.biff.StringHelper;
import jxl.common.Assert;
import jxl.common.Logger;
import jxl.write.biff.File;
public class Comment implements DrawingGroupObject {
private static Logger logger = Logger.getLogger(Comment.class);
private EscherContainer readSpContainer;
private EscherContainer spContainer;
private MsoDrawingRecord msoDrawingRecord;
private ObjRecord objRecord;
private boolean initialized = false;
private int objectId;
private int blipId;
private int shapeId;
private int column;
private int row;
private double width;
private double height;
private int referenceCount;
private EscherContainer escherData;
private Origin origin;
private DrawingGroup drawingGroup;
private DrawingData drawingData;
private ShapeType type;
private int drawingNumber;
private MsoDrawingRecord mso;
private TextObjectRecord txo;
private NoteRecord note;
private ContinueRecord text;
private ContinueRecord formatting;
private String commentText;
private WorkbookSettings workbookSettings;
public Comment(MsoDrawingRecord msorec, ObjRecord obj, DrawingData dd, DrawingGroup dg, WorkbookSettings ws) {
this.drawingGroup = dg;
this.msoDrawingRecord = msorec;
this.drawingData = dd;
this.objRecord = obj;
this.initialized = false;
this.workbookSettings = ws;
this.origin = Origin.READ;
this.drawingData.addData(this.msoDrawingRecord.getData());
this.drawingNumber = this.drawingData.getNumDrawings() - 1;
this.drawingGroup.addDrawing(this);
Assert.verify((this.msoDrawingRecord != null && this.objRecord != null));
if (!this.initialized)
initialize();
}
public Comment(DrawingGroupObject dgo, DrawingGroup dg, WorkbookSettings ws) {
Comment d = (Comment)dgo;
Assert.verify((d.origin == Origin.READ));
this.msoDrawingRecord = d.msoDrawingRecord;
this.objRecord = d.objRecord;
this.initialized = false;
this.origin = Origin.READ;
this.drawingData = d.drawingData;
this.drawingGroup = dg;
this.drawingNumber = d.drawingNumber;
this.drawingGroup.addDrawing(this);
this.mso = d.mso;
this.txo = d.txo;
this.text = d.text;
this.formatting = d.formatting;
this.note = d.note;
this.width = d.width;
this.height = d.height;
this.workbookSettings = ws;
}
public Comment(String txt, int c, int r) {
this.initialized = true;
this.origin = Origin.WRITE;
this.column = c;
this.row = r;
this.referenceCount = 1;
this.type = ShapeType.TEXT_BOX;
this.commentText = txt;
this.width = 3.0D;
this.height = 4.0D;
}
private void initialize() {
this.readSpContainer = this.drawingData.getSpContainer(this.drawingNumber);
Assert.verify((this.readSpContainer != null));
EscherRecord[] children = this.readSpContainer.getChildren();
Sp sp = (Sp)this.readSpContainer.getChildren()[0];
this.objectId = this.objRecord.getObjectId();
this.shapeId = sp.getShapeId();
this.type = ShapeType.getType(sp.getShapeType());
if (this.type == ShapeType.UNKNOWN)
logger.warn("Unknown shape type");
ClientAnchor clientAnchor = null;
for (int i = 0; i < children.length && clientAnchor == null; i++) {
if (children[i].getType() == EscherRecordType.CLIENT_ANCHOR)
clientAnchor = (ClientAnchor)children[i];
}
if (clientAnchor == null) {
logger.warn("client anchor not found");
} else {
this.column = (int)clientAnchor.getX1() - 1;
this.row = (int)clientAnchor.getY1() + 1;
this.width = clientAnchor.getX2() - clientAnchor.getX1();
this.height = clientAnchor.getY2() - clientAnchor.getY1();
}
this.initialized = true;
}
public final void setObjectId(int objid, int bip, int sid) {
this.objectId = objid;
this.blipId = bip;
this.shapeId = sid;
if (this.origin == Origin.READ)
this.origin = Origin.READ_WRITE;
}
public final int getObjectId() {
if (!this.initialized)
initialize();
return this.objectId;
}
public final int getShapeId() {
if (!this.initialized)
initialize();
return this.shapeId;
}
public final int getBlipId() {
if (!this.initialized)
initialize();
return this.blipId;
}
public MsoDrawingRecord getMsoDrawingRecord() {
return this.msoDrawingRecord;
}
public EscherContainer getSpContainer() {
if (!this.initialized)
initialize();
if (this.origin == Origin.READ)
return getReadSpContainer();
if (this.spContainer == null) {
this.spContainer = new SpContainer();
Sp sp = new Sp(this.type, this.shapeId, 2560);
this.spContainer.add(sp);
Opt opt = new Opt();
opt.addProperty(344, false, false, 0);
opt.addProperty(385, false, false, 134217808);
opt.addProperty(387, false, false, 134217808);
opt.addProperty(959, false, false, 131074);
this.spContainer.add(opt);
ClientAnchor clientAnchor = new ClientAnchor((double)this.column + 1.3D, Math.max(0.0D, (double)this.row - 0.6D), (double)this.column + 1.3D + this.width, (double)this.row + this.height, 1);
this.spContainer.add(clientAnchor);
ClientData clientData = new ClientData();
this.spContainer.add(clientData);
ClientTextBox clientTextBox = new ClientTextBox();
this.spContainer.add(clientTextBox);
}
return this.spContainer;
}
public void setDrawingGroup(DrawingGroup dg) {
this.drawingGroup = dg;
}
public DrawingGroup getDrawingGroup() {
return this.drawingGroup;
}
public Origin getOrigin() {
return this.origin;
}
public int getReferenceCount() {
return this.referenceCount;
}
public void setReferenceCount(int r) {
this.referenceCount = r;
}
public double getX() {
if (!this.initialized)
initialize();
return (double)this.column;
}
public void setX(double x) {
if (this.origin == Origin.READ) {
if (!this.initialized)
initialize();
this.origin = Origin.READ_WRITE;
}
this.column = (int)x;
}
public double getY() {
if (!this.initialized)
initialize();
return (double)this.row;
}
public void setY(double y) {
if (this.origin == Origin.READ) {
if (!this.initialized)
initialize();
this.origin = Origin.READ_WRITE;
}
this.row = (int)y;
}
public double getWidth() {
if (!this.initialized)
initialize();
return this.width;
}
public void setWidth(double w) {
if (this.origin == Origin.READ) {
if (!this.initialized)
initialize();
this.origin = Origin.READ_WRITE;
}
this.width = w;
}
public double getHeight() {
if (!this.initialized)
initialize();
return this.height;
}
public void setHeight(double h) {
if (this.origin == Origin.READ) {
if (!this.initialized)
initialize();
this.origin = Origin.READ_WRITE;
}
this.height = h;
}
private EscherContainer getReadSpContainer() {
if (!this.initialized)
initialize();
return this.readSpContainer;
}
public byte[] getImageData() {
Assert.verify((this.origin == Origin.READ || this.origin == Origin.READ_WRITE));
if (!this.initialized)
initialize();
return this.drawingGroup.getImageData(this.blipId);
}
public ShapeType getType() {
return this.type;
}
public void setTextObject(TextObjectRecord t) {
this.txo = t;
}
public void setNote(NoteRecord t) {
this.note = t;
}
public void setText(ContinueRecord t) {
this.text = t;
}
public void setFormatting(ContinueRecord t) {
this.formatting = t;
}
public byte[] getImageBytes() {
Assert.verify(false);
return null;
}
public String getImageFilePath() {
Assert.verify(false);
return null;
}
public void addMso(MsoDrawingRecord d) {
this.mso = d;
this.drawingData.addRawData(this.mso.getData());
}
public void writeAdditionalRecords(File outputFile) throws IOException {
if (this.origin == Origin.READ) {
outputFile.write(this.objRecord);
if (this.mso != null)
outputFile.write(this.mso);
outputFile.write(this.txo);
outputFile.write(this.text);
if (this.formatting != null)
outputFile.write(this.formatting);
return;
}
ObjRecord objrec = new ObjRecord(this.objectId, ObjRecord.EXCELNOTE);
outputFile.write(objrec);
ClientTextBox textBox = new ClientTextBox();
MsoDrawingRecord msod = new MsoDrawingRecord(textBox.getData());
outputFile.write(msod);
TextObjectRecord txorec = new TextObjectRecord(getText());
outputFile.write(txorec);
byte[] textData = new byte[this.commentText.length() * 2 + 1];
textData[0] = 1;
StringHelper.getUnicodeBytes(this.commentText, textData, 1);
ContinueRecord textContinue = new ContinueRecord(textData);
outputFile.write(textContinue);
byte[] frData = new byte[16];
IntegerHelper.getTwoBytes(0, frData, 0);
IntegerHelper.getTwoBytes(0, frData, 2);
IntegerHelper.getTwoBytes(this.commentText.length(), frData, 8);
IntegerHelper.getTwoBytes(0, frData, 10);
ContinueRecord frContinue = new ContinueRecord(frData);
outputFile.write(frContinue);
}
public void writeTailRecords(File outputFile) throws IOException {
if (this.origin == Origin.READ) {
outputFile.write(this.note);
return;
}
NoteRecord noteRecord = new NoteRecord(this.column, this.row, this.objectId);
outputFile.write(noteRecord);
}
public int getRow() {
return this.note.getRow();
}
public int getColumn() {
return this.note.getColumn();
}
public String getText() {
if (this.commentText == null) {
Assert.verify((this.text != null));
byte[] td = this.text.getData();
if (td[0] == 0) {
this.commentText = StringHelper.getString(td, td.length - 1, 1, this.workbookSettings);
} else {
this.commentText = StringHelper.getUnicodeString(td, (td.length - 1) / 2, 1);
}
}
return this.commentText;
}
public int hashCode() {
return this.commentText.hashCode();
}
public void setCommentText(String t) {
this.commentText = t;
if (this.origin == Origin.READ)
this.origin = Origin.READ_WRITE;
}
public boolean isFirst() {
return this.msoDrawingRecord.isFirst();
}
public boolean isFormObject() {
return true;
}
}

View file

@ -0,0 +1,44 @@
package jxl.biff.drawing;
import jxl.biff.IntegerHelper;
class Dg extends EscherAtom {
private byte[] data;
private int drawingId;
private int shapeCount;
private int seed;
public Dg(EscherRecordData erd) {
super(erd);
this.drawingId = getInstance();
byte[] bytes = getBytes();
this.shapeCount = IntegerHelper.getInt(bytes[0], bytes[1], bytes[2], bytes[3]);
this.seed = IntegerHelper.getInt(bytes[4], bytes[5], bytes[6], bytes[7]);
}
public Dg(int numDrawings) {
super(EscherRecordType.DG);
this.drawingId = 1;
this.shapeCount = numDrawings + 1;
this.seed = 1024 + this.shapeCount + 1;
setInstance(this.drawingId);
}
public int getDrawingId() {
return this.drawingId;
}
int getShapeCount() {
return this.shapeCount;
}
byte[] getData() {
this.data = new byte[8];
IntegerHelper.getFourBytes(this.shapeCount, this.data, 0);
IntegerHelper.getFourBytes(this.seed, this.data, 4);
return setHeaderData(this.data);
}
}

View file

@ -0,0 +1,7 @@
package jxl.biff.drawing;
class DgContainer extends EscherContainer {
public DgContainer() {
super(EscherRecordType.DG_CONTAINER);
}
}

View file

@ -0,0 +1,91 @@
package jxl.biff.drawing;
import java.util.ArrayList;
import jxl.biff.IntegerHelper;
import jxl.common.Logger;
class Dgg extends EscherAtom {
private static Logger logger = Logger.getLogger(Dgg.class);
private byte[] data;
private int numClusters;
private int maxShapeId;
private int shapesSaved;
private int drawingsSaved;
private ArrayList clusters;
static final class Cluster {
int drawingGroupId;
int shapeIdsUsed;
Cluster(int dgId, int sids) {
this.drawingGroupId = dgId;
this.shapeIdsUsed = sids;
}
}
public Dgg(EscherRecordData erd) {
super(erd);
this.clusters = new ArrayList();
byte[] bytes = getBytes();
this.maxShapeId = IntegerHelper.getInt(bytes[0], bytes[1], bytes[2], bytes[3]);
this.numClusters = IntegerHelper.getInt(bytes[4], bytes[5], bytes[6], bytes[7]);
this.shapesSaved = IntegerHelper.getInt(bytes[8], bytes[9], bytes[10], bytes[11]);
this.drawingsSaved = IntegerHelper.getInt(bytes[12], bytes[13], bytes[14], bytes[15]);
int pos = 16;
for (int i = 0; i < this.numClusters; i++) {
int dgId = IntegerHelper.getInt(bytes[pos], bytes[pos + 1]);
int sids = IntegerHelper.getInt(bytes[pos + 2], bytes[pos + 3]);
Cluster c = new Cluster(dgId, sids);
this.clusters.add(c);
pos += 4;
}
}
public Dgg(int numShapes, int numDrawings) {
super(EscherRecordType.DGG);
this.shapesSaved = numShapes;
this.drawingsSaved = numDrawings;
this.clusters = new ArrayList();
}
void addCluster(int dgid, int sids) {
Cluster c = new Cluster(dgid, sids);
this.clusters.add(c);
}
byte[] getData() {
this.numClusters = this.clusters.size();
this.data = new byte[16 + this.numClusters * 4];
IntegerHelper.getFourBytes(1024 + this.shapesSaved, this.data, 0);
IntegerHelper.getFourBytes(this.numClusters, this.data, 4);
IntegerHelper.getFourBytes(this.shapesSaved, this.data, 8);
IntegerHelper.getFourBytes(1, this.data, 12);
int pos = 16;
for (int i = 0; i < this.numClusters; i++) {
Cluster c = this.clusters.get(i);
IntegerHelper.getTwoBytes(c.drawingGroupId, this.data, pos);
IntegerHelper.getTwoBytes(c.shapeIdsUsed, this.data, pos + 2);
pos += 4;
}
return setHeaderData(this.data);
}
int getShapesSaved() {
return this.shapesSaved;
}
int getDrawingsSaved() {
return this.drawingsSaved;
}
Cluster getCluster(int i) {
return this.clusters.get(i);
}
}

View file

@ -0,0 +1,7 @@
package jxl.biff.drawing;
class DggContainer extends EscherContainer {
public DggContainer() {
super(EscherRecordType.DGG_CONTAINER);
}
}

View file

@ -0,0 +1,515 @@
package jxl.biff.drawing;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import jxl.CellView;
import jxl.Image;
import jxl.Sheet;
import jxl.common.Assert;
import jxl.common.LengthConverter;
import jxl.common.LengthUnit;
import jxl.common.Logger;
public class Drawing implements DrawingGroupObject, Image {
private static Logger logger = Logger.getLogger(Drawing.class);
private EscherContainer readSpContainer;
private MsoDrawingRecord msoDrawingRecord;
private ObjRecord objRecord;
private boolean initialized = false;
private File imageFile;
private byte[] imageData;
private int objectId;
private int blipId;
private double x;
private double y;
private double width;
private double height;
private int referenceCount;
private EscherContainer escherData;
private Origin origin;
private DrawingGroup drawingGroup;
private DrawingData drawingData;
private ShapeType type;
private int shapeId;
private int drawingNumber;
private Sheet sheet;
private PNGReader pngReader;
private ImageAnchorProperties imageAnchorProperties;
protected static class ImageAnchorProperties {
private int value;
private static ImageAnchorProperties[] o = new ImageAnchorProperties[0];
ImageAnchorProperties(int v) {
this.value = v;
ImageAnchorProperties[] oldArray = o;
o = new ImageAnchorProperties[oldArray.length + 1];
System.arraycopy(oldArray, 0, o, 0, oldArray.length);
o[oldArray.length] = this;
}
int getValue() {
return this.value;
}
static ImageAnchorProperties getImageAnchorProperties(int val) {
ImageAnchorProperties iap = Drawing.MOVE_AND_SIZE_WITH_CELLS;
int pos = 0;
while (pos < o.length) {
if (o[pos].getValue() == val) {
iap = o[pos];
break;
}
pos++;
}
return iap;
}
}
public static ImageAnchorProperties MOVE_AND_SIZE_WITH_CELLS = new ImageAnchorProperties(1);
public static ImageAnchorProperties MOVE_WITH_CELLS = new ImageAnchorProperties(2);
public static ImageAnchorProperties NO_MOVE_OR_SIZE_WITH_CELLS = new ImageAnchorProperties(3);
private static final double DEFAULT_FONT_SIZE = 10.0D;
public Drawing(MsoDrawingRecord mso, ObjRecord obj, DrawingData dd, DrawingGroup dg, Sheet s) {
this.drawingGroup = dg;
this.msoDrawingRecord = mso;
this.drawingData = dd;
this.objRecord = obj;
this.sheet = s;
this.initialized = false;
this.origin = Origin.READ;
this.drawingData.addData(this.msoDrawingRecord.getData());
this.drawingNumber = this.drawingData.getNumDrawings() - 1;
this.drawingGroup.addDrawing(this);
Assert.verify((mso != null && obj != null));
initialize();
}
protected Drawing(DrawingGroupObject dgo, DrawingGroup dg) {
Drawing d = (Drawing)dgo;
Assert.verify((d.origin == Origin.READ));
this.msoDrawingRecord = d.msoDrawingRecord;
this.objRecord = d.objRecord;
this.initialized = false;
this.origin = Origin.READ;
this.drawingData = d.drawingData;
this.drawingGroup = dg;
this.drawingNumber = d.drawingNumber;
this.drawingGroup.addDrawing(this);
}
public Drawing(double x, double y, double w, double h, File image) {
this.imageFile = image;
this.initialized = true;
this.origin = Origin.WRITE;
this.x = x;
this.y = y;
this.width = w;
this.height = h;
this.referenceCount = 1;
this.imageAnchorProperties = MOVE_WITH_CELLS;
this.type = ShapeType.PICTURE_FRAME;
}
public Drawing(double x, double y, double w, double h, byte[] image) {
this.imageData = image;
this.initialized = true;
this.origin = Origin.WRITE;
this.x = x;
this.y = y;
this.width = w;
this.height = h;
this.referenceCount = 1;
this.imageAnchorProperties = MOVE_WITH_CELLS;
this.type = ShapeType.PICTURE_FRAME;
}
private void initialize() {
this.readSpContainer = this.drawingData.getSpContainer(this.drawingNumber);
Assert.verify((this.readSpContainer != null));
EscherRecord[] children = this.readSpContainer.getChildren();
Sp sp = (Sp)this.readSpContainer.getChildren()[0];
this.shapeId = sp.getShapeId();
this.objectId = this.objRecord.getObjectId();
this.type = ShapeType.getType(sp.getShapeType());
if (this.type == ShapeType.UNKNOWN)
logger.warn("Unknown shape type");
Opt opt = (Opt)this.readSpContainer.getChildren()[1];
if (opt.getProperty(260) != null)
this.blipId = (opt.getProperty(260)).value;
if (opt.getProperty(261) != null) {
this.imageFile = new File((opt.getProperty(261)).stringValue);
} else if (this.type == ShapeType.PICTURE_FRAME) {
logger.warn("no filename property for drawing");
this.imageFile = new File(Integer.toString(this.blipId));
}
ClientAnchor clientAnchor = null;
for (int i = 0; i < children.length && clientAnchor == null; i++) {
if (children[i].getType() == EscherRecordType.CLIENT_ANCHOR)
clientAnchor = (ClientAnchor)children[i];
}
if (clientAnchor == null) {
logger.warn("client anchor not found");
} else {
this.x = clientAnchor.getX1();
this.y = clientAnchor.getY1();
this.width = clientAnchor.getX2() - this.x;
this.height = clientAnchor.getY2() - this.y;
this.imageAnchorProperties = ImageAnchorProperties.getImageAnchorProperties(clientAnchor.getProperties());
}
if (this.blipId == 0)
logger.warn("linked drawings are not supported");
this.initialized = true;
}
public File getImageFile() {
return this.imageFile;
}
public String getImageFilePath() {
if (this.imageFile == null)
return (this.blipId != 0) ? Integer.toString(this.blipId) : "__new__image__";
return this.imageFile.getPath();
}
public final void setObjectId(int objid, int bip, int sid) {
this.objectId = objid;
this.blipId = bip;
this.shapeId = sid;
if (this.origin == Origin.READ)
this.origin = Origin.READ_WRITE;
}
public final int getObjectId() {
if (!this.initialized)
initialize();
return this.objectId;
}
public int getShapeId() {
if (!this.initialized)
initialize();
return this.shapeId;
}
public final int getBlipId() {
if (!this.initialized)
initialize();
return this.blipId;
}
public MsoDrawingRecord getMsoDrawingRecord() {
return this.msoDrawingRecord;
}
public EscherContainer getSpContainer() {
if (!this.initialized)
initialize();
if (this.origin == Origin.READ)
return getReadSpContainer();
SpContainer spContainer = new SpContainer();
Sp sp = new Sp(this.type, this.shapeId, 2560);
spContainer.add(sp);
Opt opt = new Opt();
opt.addProperty(260, true, false, this.blipId);
if (this.type == ShapeType.PICTURE_FRAME) {
String filePath = (this.imageFile != null) ? this.imageFile.getPath() : "";
opt.addProperty(261, true, true, filePath.length() * 2, filePath);
opt.addProperty(447, false, false, 65536);
opt.addProperty(959, false, false, 524288);
spContainer.add(opt);
}
ClientAnchor clientAnchor = new ClientAnchor(this.x, this.y, this.x + this.width, this.y + this.height, this.imageAnchorProperties.getValue());
spContainer.add(clientAnchor);
ClientData clientData = new ClientData();
spContainer.add(clientData);
return spContainer;
}
public void setDrawingGroup(DrawingGroup dg) {
this.drawingGroup = dg;
}
public DrawingGroup getDrawingGroup() {
return this.drawingGroup;
}
public Origin getOrigin() {
return this.origin;
}
public int getReferenceCount() {
return this.referenceCount;
}
public void setReferenceCount(int r) {
this.referenceCount = r;
}
public double getX() {
if (!this.initialized)
initialize();
return this.x;
}
public void setX(double x) {
if (this.origin == Origin.READ) {
if (!this.initialized)
initialize();
this.origin = Origin.READ_WRITE;
}
this.x = x;
}
public double getY() {
if (!this.initialized)
initialize();
return this.y;
}
public void setY(double y) {
if (this.origin == Origin.READ) {
if (!this.initialized)
initialize();
this.origin = Origin.READ_WRITE;
}
this.y = y;
}
public double getWidth() {
if (!this.initialized)
initialize();
return this.width;
}
public void setWidth(double w) {
if (this.origin == Origin.READ) {
if (!this.initialized)
initialize();
this.origin = Origin.READ_WRITE;
}
this.width = w;
}
public double getHeight() {
if (!this.initialized)
initialize();
return this.height;
}
public void setHeight(double h) {
if (this.origin == Origin.READ) {
if (!this.initialized)
initialize();
this.origin = Origin.READ_WRITE;
}
this.height = h;
}
private EscherContainer getReadSpContainer() {
if (!this.initialized)
initialize();
return this.readSpContainer;
}
public byte[] getImageData() {
Assert.verify((this.origin == Origin.READ || this.origin == Origin.READ_WRITE));
if (!this.initialized)
initialize();
return this.drawingGroup.getImageData(this.blipId);
}
public byte[] getImageBytes() throws IOException {
if (this.origin == Origin.READ || this.origin == Origin.READ_WRITE)
return getImageData();
Assert.verify((this.origin == Origin.WRITE));
if (this.imageFile == null) {
Assert.verify((this.imageData != null));
return this.imageData;
}
byte[] data = new byte[(int)this.imageFile.length()];
FileInputStream fis = new FileInputStream(this.imageFile);
fis.read(data, 0, data.length);
fis.close();
return data;
}
public ShapeType getType() {
return this.type;
}
public void writeAdditionalRecords(jxl.write.biff.File outputFile) throws IOException {
if (this.origin == Origin.READ) {
outputFile.write(this.objRecord);
return;
}
ObjRecord objrec = new ObjRecord(this.objectId, ObjRecord.PICTURE);
outputFile.write(objrec);
}
public void writeTailRecords(jxl.write.biff.File outputFile) throws IOException {}
public double getColumn() {
return getX();
}
public double getRow() {
return getY();
}
public boolean isFirst() {
return this.msoDrawingRecord.isFirst();
}
public boolean isFormObject() {
return false;
}
public void removeRow(int r) {
if (this.y > (double)r)
setY((double)r);
}
private double getWidthInPoints() {
if (this.sheet == null) {
logger.warn("calculating image width: sheet is null");
return 0.0D;
}
int firstCol = (int)this.x;
int lastCol = (int)Math.ceil(this.x + this.width) - 1;
CellView cellView = this.sheet.getColumnView(firstCol);
int firstColWidth = cellView.getSize();
double firstColImageWidth = (1.0D - (this.x - (double)firstCol)) * (double)firstColWidth;
double pointSize = (cellView.getFormat() != null) ? (double)cellView.getFormat().getFont().getPointSize() : 10.0D;
double firstColWidthInPoints = firstColImageWidth * 0.59D * pointSize / 256.0D;
int lastColWidth = 0;
double lastColImageWidth = 0.0D;
double lastColWidthInPoints = 0.0D;
if (lastCol != firstCol) {
cellView = this.sheet.getColumnView(lastCol);
lastColWidth = cellView.getSize();
lastColImageWidth = (this.x + this.width - (double)lastCol) * (double)lastColWidth;
pointSize = (cellView.getFormat() != null) ? (double)cellView.getFormat().getFont().getPointSize() : 10.0D;
lastColWidthInPoints = lastColImageWidth * 0.59D * pointSize / 256.0D;
}
double width = 0.0D;
for (int i = 0; i < lastCol - firstCol - 1; i++) {
cellView = this.sheet.getColumnView(firstCol + 1 + i);
pointSize = (cellView.getFormat() != null) ? (double)cellView.getFormat().getFont().getPointSize() : 10.0D;
width += (double)cellView.getSize() * 0.59D * pointSize / 256.0D;
}
double widthInPoints = width + firstColWidthInPoints + lastColWidthInPoints;
return widthInPoints;
}
private double getHeightInPoints() {
if (this.sheet == null) {
logger.warn("calculating image height: sheet is null");
return 0.0D;
}
int firstRow = (int)this.y;
int lastRow = (int)Math.ceil(this.y + this.height) - 1;
int firstRowHeight = this.sheet.getRowView(firstRow).getSize();
double firstRowImageHeight = (1.0D - (this.y - (double)firstRow)) * (double)firstRowHeight;
int lastRowHeight = 0;
double lastRowImageHeight = 0.0D;
if (lastRow != firstRow) {
lastRowHeight = this.sheet.getRowView(lastRow).getSize();
lastRowImageHeight = (this.y + this.height - (double)lastRow) * (double)lastRowHeight;
}
double height = 0.0D;
for (int i = 0; i < lastRow - firstRow - 1; i++)
height += (double)this.sheet.getRowView(firstRow + 1 + i).getSize();
double heightInTwips = height + (double)firstRowHeight + (double)lastRowHeight;
double heightInPoints = heightInTwips / 20.0D;
return heightInPoints;
}
public double getWidth(LengthUnit unit) {
double widthInPoints = getWidthInPoints();
return widthInPoints * LengthConverter.getConversionFactor(LengthUnit.POINTS, unit);
}
public double getHeight(LengthUnit unit) {
double heightInPoints = getHeightInPoints();
return heightInPoints * LengthConverter.getConversionFactor(LengthUnit.POINTS, unit);
}
public int getImageWidth() {
return getPngReader().getWidth();
}
public int getImageHeight() {
return getPngReader().getHeight();
}
public double getHorizontalResolution(LengthUnit unit) {
int res = getPngReader().getHorizontalResolution();
return (double)res / LengthConverter.getConversionFactor(LengthUnit.METRES, unit);
}
public double getVerticalResolution(LengthUnit unit) {
int res = getPngReader().getVerticalResolution();
return (double)res / LengthConverter.getConversionFactor(LengthUnit.METRES, unit);
}
private PNGReader getPngReader() {
if (this.pngReader != null)
return this.pngReader;
byte[] imdata = null;
if (this.origin == Origin.READ || this.origin == Origin.READ_WRITE) {
imdata = getImageData();
} else {
try {
imdata = getImageBytes();
} catch (IOException e) {
logger.warn("Could not read image file");
imdata = new byte[0];
}
}
this.pngReader = new PNGReader(imdata);
this.pngReader.read();
return this.pngReader;
}
protected void setImageAnchor(ImageAnchorProperties iap) {
this.imageAnchorProperties = iap;
if (this.origin == Origin.READ)
this.origin = Origin.READ_WRITE;
}
protected ImageAnchorProperties getImageAnchor() {
if (!this.initialized)
initialize();
return this.imageAnchorProperties;
}
}

Some files were not shown because too many files have changed in this diff Show more