From 1af3b165c9377702ca62a64112bc089a6f575c30 Mon Sep 17 00:00:00 2001 From: "Roberto C. Sanchez" Date: Tue, 21 Oct 2014 22:48:19 -0400 Subject: Imported Upstream version 2.0~beta2 --- bibletime/backend/Makefile.am | 44 -- bibletime/backend/Makefile.in | 794 -------------------- bibletime/backend/bt_gbfhtml.cpp | 303 -------- bibletime/backend/bt_gbfhtml.h | 60 -- bibletime/backend/bt_osishtml.cpp | 621 ---------------- bibletime/backend/bt_osishtml.h | 66 -- bibletime/backend/bt_plainhtml.cpp | 92 --- bibletime/backend/bt_plainhtml.h | 41 -- bibletime/backend/bt_thmlhtml.cpp | 395 ---------- bibletime/backend/bt_thmlhtml.h | 56 -- bibletime/backend/bt_thmlplain.cpp | 221 ------ bibletime/backend/bt_thmlplain.h | 40 - bibletime/backend/btstringmgr.cpp | 145 ---- bibletime/backend/btstringmgr.h | 57 -- bibletime/backend/cbookdisplay.cpp | 144 ---- bibletime/backend/cbookdisplay.h | 45 -- bibletime/backend/cchapterdisplay.cpp | 67 -- bibletime/backend/cchapterdisplay.h | 39 - bibletime/backend/cdisplayrendering.cpp | 163 ----- bibletime/backend/cdisplayrendering.h | 40 - bibletime/backend/cdisplaytemplatemgr.cpp | 191 ----- bibletime/backend/cdisplaytemplatemgr.h | 100 --- bibletime/backend/centrydisplay.cpp | 66 -- bibletime/backend/centrydisplay.h | 53 -- bibletime/backend/chtmlexportrendering.cpp | 236 ------ bibletime/backend/chtmlexportrendering.h | 60 -- bibletime/backend/clanguagemgr.cpp | 499 ------------- bibletime/backend/clanguagemgr.h | 172 ----- bibletime/backend/cplaintextexportrendering.cpp | 58 -- bibletime/backend/cplaintextexportrendering.h | 42 -- bibletime/backend/creferencemanager.cpp | 434 ----------- bibletime/backend/creferencemanager.h | 112 --- bibletime/backend/cswordbackend.cpp | 692 ------------------ bibletime/backend/cswordbackend.h | 266 ------- bibletime/backend/cswordbiblemoduleinfo.cpp | 262 ------- bibletime/backend/cswordbiblemoduleinfo.h | 132 ---- bibletime/backend/cswordbookmoduleinfo.cpp | 75 -- bibletime/backend/cswordbookmoduleinfo.h | 67 -- bibletime/backend/cswordcommentarymoduleinfo.cpp | 36 - bibletime/backend/cswordcommentarymoduleinfo.h | 45 -- bibletime/backend/cswordkey.cpp | 193 ----- bibletime/backend/cswordkey.h | 121 --- bibletime/backend/cswordldkey.cpp | 130 ---- bibletime/backend/cswordldkey.h | 110 --- bibletime/backend/cswordlexiconmoduleinfo.cpp | 183 ----- bibletime/backend/cswordlexiconmoduleinfo.h | 73 -- bibletime/backend/cswordmoduleinfo.cpp | 888 ----------------------- bibletime/backend/cswordmoduleinfo.h | 373 ---------- bibletime/backend/cswordmodulesearch.cpp | 120 --- bibletime/backend/cswordmodulesearch.h | 99 --- bibletime/backend/cswordtreekey.cpp | 99 --- bibletime/backend/cswordtreekey.h | 74 -- bibletime/backend/cswordversekey.cpp | 306 -------- bibletime/backend/cswordversekey.h | 122 ---- bibletime/backend/ctextrendering.cpp | 278 ------- bibletime/backend/ctextrendering.h | 147 ---- bibletime/backend/osismorphsegmentation.cpp | 92 --- bibletime/backend/osismorphsegmentation.h | 48 -- 58 files changed, 10487 deletions(-) delete mode 100644 bibletime/backend/Makefile.am delete mode 100644 bibletime/backend/Makefile.in delete mode 100644 bibletime/backend/bt_gbfhtml.cpp delete mode 100644 bibletime/backend/bt_gbfhtml.h delete mode 100644 bibletime/backend/bt_osishtml.cpp delete mode 100644 bibletime/backend/bt_osishtml.h delete mode 100644 bibletime/backend/bt_plainhtml.cpp delete mode 100644 bibletime/backend/bt_plainhtml.h delete mode 100644 bibletime/backend/bt_thmlhtml.cpp delete mode 100644 bibletime/backend/bt_thmlhtml.h delete mode 100644 bibletime/backend/bt_thmlplain.cpp delete mode 100644 bibletime/backend/bt_thmlplain.h delete mode 100644 bibletime/backend/btstringmgr.cpp delete mode 100644 bibletime/backend/btstringmgr.h delete mode 100644 bibletime/backend/cbookdisplay.cpp delete mode 100644 bibletime/backend/cbookdisplay.h delete mode 100644 bibletime/backend/cchapterdisplay.cpp delete mode 100644 bibletime/backend/cchapterdisplay.h delete mode 100644 bibletime/backend/cdisplayrendering.cpp delete mode 100644 bibletime/backend/cdisplayrendering.h delete mode 100644 bibletime/backend/cdisplaytemplatemgr.cpp delete mode 100644 bibletime/backend/cdisplaytemplatemgr.h delete mode 100644 bibletime/backend/centrydisplay.cpp delete mode 100644 bibletime/backend/centrydisplay.h delete mode 100644 bibletime/backend/chtmlexportrendering.cpp delete mode 100644 bibletime/backend/chtmlexportrendering.h delete mode 100644 bibletime/backend/clanguagemgr.cpp delete mode 100644 bibletime/backend/clanguagemgr.h delete mode 100644 bibletime/backend/cplaintextexportrendering.cpp delete mode 100644 bibletime/backend/cplaintextexportrendering.h delete mode 100644 bibletime/backend/creferencemanager.cpp delete mode 100644 bibletime/backend/creferencemanager.h delete mode 100644 bibletime/backend/cswordbackend.cpp delete mode 100644 bibletime/backend/cswordbackend.h delete mode 100644 bibletime/backend/cswordbiblemoduleinfo.cpp delete mode 100644 bibletime/backend/cswordbiblemoduleinfo.h delete mode 100644 bibletime/backend/cswordbookmoduleinfo.cpp delete mode 100644 bibletime/backend/cswordbookmoduleinfo.h delete mode 100644 bibletime/backend/cswordcommentarymoduleinfo.cpp delete mode 100644 bibletime/backend/cswordcommentarymoduleinfo.h delete mode 100644 bibletime/backend/cswordkey.cpp delete mode 100644 bibletime/backend/cswordkey.h delete mode 100644 bibletime/backend/cswordldkey.cpp delete mode 100644 bibletime/backend/cswordldkey.h delete mode 100644 bibletime/backend/cswordlexiconmoduleinfo.cpp delete mode 100644 bibletime/backend/cswordlexiconmoduleinfo.h delete mode 100644 bibletime/backend/cswordmoduleinfo.cpp delete mode 100644 bibletime/backend/cswordmoduleinfo.h delete mode 100644 bibletime/backend/cswordmodulesearch.cpp delete mode 100644 bibletime/backend/cswordmodulesearch.h delete mode 100644 bibletime/backend/cswordtreekey.cpp delete mode 100644 bibletime/backend/cswordtreekey.h delete mode 100644 bibletime/backend/cswordversekey.cpp delete mode 100644 bibletime/backend/cswordversekey.h delete mode 100644 bibletime/backend/ctextrendering.cpp delete mode 100644 bibletime/backend/ctextrendering.h delete mode 100644 bibletime/backend/osismorphsegmentation.cpp delete mode 100644 bibletime/backend/osismorphsegmentation.h (limited to 'bibletime/backend') diff --git a/bibletime/backend/Makefile.am b/bibletime/backend/Makefile.am deleted file mode 100644 index 85624f7..0000000 --- a/bibletime/backend/Makefile.am +++ /dev/null @@ -1,44 +0,0 @@ -libbackend_a_METASOURCES = AUTO -noinst_LIBRARIES = libbackend.a - -INCLUDES = $(all_includes) - -libbackend_a_SOURCES = bt_gbfhtml.cpp bt_osishtml.cpp bt_plainhtml.cpp \ - bt_thmlhtml.cpp bt_thmlplain.cpp btstringmgr.cpp cbookdisplay.cpp \ - cchapterdisplay.cpp cdisplayrendering.cpp cdisplaytemplatemgr.cpp centrydisplay.cpp \ - chtmlexportrendering.cpp clanguagemgr.cpp cplaintextexportrendering.cpp \ - creferencemanager.cpp cswordbackend.cpp cswordbiblemoduleinfo.cpp cswordbookmoduleinfo.cpp \ - cswordcommentarymoduleinfo.cpp cswordkey.cpp cswordldkey.cpp cswordlexiconmoduleinfo.cpp \ - cswordmoduleinfo.cpp cswordmodulesearch.cpp cswordtreekey.cpp cswordversekey.cpp \ - ctextrendering.cpp osismorphsegmentation.cpp - -all_headers = cswordbiblemoduleinfo.h \ -cswordcommentarymoduleinfo.h \ -cswordlexiconmoduleinfo.h \ -cswordkey.h \ -cswordversekey.h \ -cswordldkey.h \ -cswordbackend.h \ -cswordmoduleinfo.h \ -cswordmodulesearch.h \ -creferencemanager.h \ -cswordbookmoduleinfo.h \ -cswordtreekey.h \ -bt_thmlhtml.h \ -bt_osishtml.h \ -bt_gbfhtml.h \ -bt_plainhtml.h \ -bt_thmlplain.h \ -centrydisplay.h \ -clanguagemgr.h \ -cdisplaytemplatemgr.h \ -ctextrendering.h \ -btstringmgr.h \ -cbookdisplay.h \ -cchapterdisplay.h \ -chtmlexportrendering.h \ -cplaintextexportrendering.h \ -cdisplayrendering.h \ -osismorphsegmentation.h - -EXTRA_DIST = $(libbackend_a_SOURCES) $(all_headers) diff --git a/bibletime/backend/Makefile.in b/bibletime/backend/Makefile.in deleted file mode 100644 index 3187253..0000000 --- a/bibletime/backend/Makefile.in +++ /dev/null @@ -1,794 +0,0 @@ -# Makefile.in generated by automake 1.10.1 from Makefile.am. -# KDE tags expanded automatically by am_edit - $Revision: 1.31 $ -# @configure_input@ - -# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - -VPATH = @srcdir@ -pkgdatadir = $(datadir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -target_triplet = @target@ -subdir = bibletime/backend -DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ - $(top_srcdir)/configure.in -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -mkinstalldirs = $(SHELL) $(top_srcdir)/admin/mkinstalldirs -CONFIG_HEADER = $(top_builddir)/config.h -CONFIG_CLEAN_FILES = -LIBRARIES = $(noinst_LIBRARIES) -ARFLAGS = cru -libbackend_a_AR = $(AR) $(ARFLAGS) -libbackend_a_LIBADD = -am_libbackend_a_OBJECTS = bt_gbfhtml.$(OBJEXT) bt_osishtml.$(OBJEXT) \ - bt_plainhtml.$(OBJEXT) bt_thmlhtml.$(OBJEXT) \ - bt_thmlplain.$(OBJEXT) btstringmgr.$(OBJEXT) \ - cbookdisplay.$(OBJEXT) cchapterdisplay.$(OBJEXT) \ - cdisplayrendering.$(OBJEXT) cdisplaytemplatemgr.$(OBJEXT) \ - centrydisplay.$(OBJEXT) chtmlexportrendering.$(OBJEXT) \ - clanguagemgr.$(OBJEXT) cplaintextexportrendering.$(OBJEXT) \ - creferencemanager.$(OBJEXT) cswordbackend.$(OBJEXT) \ - cswordbiblemoduleinfo.$(OBJEXT) cswordbookmoduleinfo.$(OBJEXT) \ - cswordcommentarymoduleinfo.$(OBJEXT) cswordkey.$(OBJEXT) \ - cswordldkey.$(OBJEXT) cswordlexiconmoduleinfo.$(OBJEXT) \ - cswordmoduleinfo.$(OBJEXT) cswordmodulesearch.$(OBJEXT) \ - cswordtreekey.$(OBJEXT) cswordversekey.$(OBJEXT) \ - ctextrendering.$(OBJEXT) osismorphsegmentation.$(OBJEXT) -#>- libbackend_a_OBJECTS = $(am_libbackend_a_OBJECTS) -#>+ 17 -libbackend_a_final_OBJECTS = libbackend_a.all_cpp.o -libbackend_a_nofinal_OBJECTS = bt_gbfhtml.$(OBJEXT) bt_osishtml.$(OBJEXT) \ - bt_plainhtml.$(OBJEXT) bt_thmlhtml.$(OBJEXT) \ - bt_thmlplain.$(OBJEXT) btstringmgr.$(OBJEXT) \ - cbookdisplay.$(OBJEXT) cchapterdisplay.$(OBJEXT) \ - cdisplayrendering.$(OBJEXT) cdisplaytemplatemgr.$(OBJEXT) \ - centrydisplay.$(OBJEXT) chtmlexportrendering.$(OBJEXT) \ - clanguagemgr.$(OBJEXT) cplaintextexportrendering.$(OBJEXT) \ - creferencemanager.$(OBJEXT) cswordbackend.$(OBJEXT) \ - cswordbiblemoduleinfo.$(OBJEXT) cswordbookmoduleinfo.$(OBJEXT) \ - cswordcommentarymoduleinfo.$(OBJEXT) cswordkey.$(OBJEXT) \ - cswordldkey.$(OBJEXT) cswordlexiconmoduleinfo.$(OBJEXT) \ - cswordmoduleinfo.$(OBJEXT) cswordmodulesearch.$(OBJEXT) \ - cswordtreekey.$(OBJEXT) cswordversekey.$(OBJEXT) \ - ctextrendering.$(OBJEXT) osismorphsegmentation.$(OBJEXT) -@KDE_USE_FINAL_FALSE@libbackend_a_OBJECTS = $(libbackend_a_nofinal_OBJECTS) -@KDE_USE_FINAL_TRUE@libbackend_a_OBJECTS = $(libbackend_a_final_OBJECTS) -DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -depcomp = $(SHELL) $(top_srcdir)/admin/depcomp -am__depfiles_maybe = depfiles -#>- CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ -#>- $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -#>+ 2 -CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ - $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) $(KDE_CXXFLAGS) -#>- LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ -#>- --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ -#>- $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -#>+ 3 -LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ - --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ - $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) $(KDE_CXXFLAGS) -CXXLD = $(CXX) -#>- CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ -#>- --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \ -#>- $(LDFLAGS) -o $@ -#>+ 3 -CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ - --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(KDE_CXXFLAGS) $(AM_LDFLAGS) \ - $(LDFLAGS) -o $@ -SOURCES = $(libbackend_a_SOURCES) -DIST_SOURCES = $(libbackend_a_SOURCES) -ETAGS = etags -CTAGS = ctags -#>- DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -#>+ 1 -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) $(KDE_DIST) -ACLOCAL = @ACLOCAL@ -AMTAR = @AMTAR@ -AR = @AR@ -ARTSCCONFIG = @ARTSCCONFIG@ -AUTOCONF = @AUTOCONF@ -AUTODIRS = @AUTODIRS@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -BT_LDFLAGS = @BT_LDFLAGS@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CLUCENE_INCLUDES = @CLUCENE_INCLUDES@ -CLUCENE_LIBRARY_PATH = @CLUCENE_LIBRARY_PATH@ -CONF_FILES = @CONF_FILES@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DCOPIDL = @DCOPIDL@ -DCOPIDL2CPP = @DCOPIDL2CPP@ -DCOPIDLNG = @DCOPIDLNG@ -DCOP_DEPENDENCIES = @DCOP_DEPENDENCIES@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -DISTRIBUTION = @DISTRIBUTION@ -DISTRIBUTION_VERSION = @DISTRIBUTION_VERSION@ -ECHO = @ECHO@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -ENABLE_PERMISSIVE_FLAG = @ENABLE_PERMISSIVE_FLAG@ -EXEEXT = @EXEEXT@ -F77 = @F77@ -FFLAGS = @FFLAGS@ -FRAMEWORK_COREAUDIO = @FRAMEWORK_COREAUDIO@ -GMSGFMT = @GMSGFMT@ -GREP = @GREP@ -HAVE_GCC_VISIBILITY = @HAVE_GCC_VISIBILITY@ -HOWTODIR = @HOWTODIR@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -KCFG_DEPENDENCIES = @KCFG_DEPENDENCIES@ -KCONFIG_COMPILER = @KCONFIG_COMPILER@ -KDECONFIG = @KDECONFIG@ -KDE_EXTRA_RPATH = @KDE_EXTRA_RPATH@ -KDE_INCLUDES = @KDE_INCLUDES@ -KDE_LDFLAGS = @KDE_LDFLAGS@ -KDE_MT_LDFLAGS = @KDE_MT_LDFLAGS@ -KDE_MT_LIBS = @KDE_MT_LIBS@ -KDE_NO_UNDEFINED = @KDE_NO_UNDEFINED@ -KDE_PLUGIN = @KDE_PLUGIN@ -KDE_RPATH = @KDE_RPATH@ -KDE_USE_CLOSURE_FALSE = @KDE_USE_CLOSURE_FALSE@ -KDE_USE_CLOSURE_TRUE = @KDE_USE_CLOSURE_TRUE@ -KDE_USE_FINAL_FALSE = @KDE_USE_FINAL_FALSE@ -KDE_USE_FINAL_TRUE = @KDE_USE_FINAL_TRUE@ -KDE_USE_NMCHECK_FALSE = @KDE_USE_NMCHECK_FALSE@ -KDE_USE_NMCHECK_TRUE = @KDE_USE_NMCHECK_TRUE@ -KDE_XSL_STYLESHEET = @KDE_XSL_STYLESHEET@ -LDFLAGS = @LDFLAGS@ -LDFLAGS_AS_NEEDED = @LDFLAGS_AS_NEEDED@ -LDFLAGS_NEW_DTAGS = @LDFLAGS_NEW_DTAGS@ -LIBCOMPAT = @LIBCOMPAT@ -LIBCRYPT = @LIBCRYPT@ -LIBDL = @LIBDL@ -LIBJPEG = @LIBJPEG@ -LIBOBJS = @LIBOBJS@ -LIBPNG = @LIBPNG@ -LIBPTHREAD = @LIBPTHREAD@ -LIBRESOLV = @LIBRESOLV@ -LIBS = @LIBS@ -LIBSM = @LIBSM@ -LIBSOCKET = @LIBSOCKET@ -LIBTOOL = @LIBTOOL@ -LIBUCB = @LIBUCB@ -LIBUTIL = @LIBUTIL@ -LIBZ = @LIBZ@ -LIB_CLUCENE = @LIB_CLUCENE@ -LIB_KAB = @LIB_KAB@ -LIB_KABC = @LIB_KABC@ -LIB_KDECORE = @LIB_KDECORE@ -LIB_KDEPIM = @LIB_KDEPIM@ -LIB_KDEPRINT = @LIB_KDEPRINT@ -LIB_KDEUI = @LIB_KDEUI@ -LIB_KDNSSD = @LIB_KDNSSD@ -LIB_KFILE = @LIB_KFILE@ -LIB_KFM = @LIB_KFM@ -LIB_KHTML = @LIB_KHTML@ -LIB_KIMPROXY = @LIB_KIMPROXY@ -LIB_KIO = @LIB_KIO@ -LIB_KJS = @LIB_KJS@ -LIB_KNEWSTUFF = @LIB_KNEWSTUFF@ -LIB_KPARTS = @LIB_KPARTS@ -LIB_KSPELL = @LIB_KSPELL@ -LIB_KSYCOCA = @LIB_KSYCOCA@ -LIB_KUTILS = @LIB_KUTILS@ -LIB_POLL = @LIB_POLL@ -LIB_QPE = @LIB_QPE@ -LIB_QT = @LIB_QT@ -LIB_SMB = @LIB_SMB@ -LIB_SWORD = @LIB_SWORD@ -LIB_X11 = @LIB_X11@ -LIB_XEXT = @LIB_XEXT@ -LIB_XRENDER = @LIB_XRENDER@ -LN_S = @LN_S@ -LTLIBOBJS = @LTLIBOBJS@ -MAINT = @MAINT@ -MAKEINFO = @MAKEINFO@ -MAKEKDEWIDGETS = @MAKEKDEWIDGETS@ -MCOPIDL = @MCOPIDL@ -MEINPROC = @MEINPROC@ -MKDIR_P = @MKDIR_P@ -MOC = @MOC@ -MSGFMT = @MSGFMT@ -NOOPT_CFLAGS = @NOOPT_CFLAGS@ -NOOPT_CXXFLAGS = @NOOPT_CXXFLAGS@ -OBJEXT = @OBJEXT@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PERL = @PERL@ -QTE_NORTTI = @QTE_NORTTI@ -QT_INCLUDES = @QT_INCLUDES@ -QT_LDFLAGS = @QT_LDFLAGS@ -RANLIB = @RANLIB@ -RPM_GROUP = @RPM_GROUP@ -RPM_PREFIX = @RPM_PREFIX@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -SWORD_INCLUDES = @SWORD_INCLUDES@ -SWORD_LIBRARY_PATH = @SWORD_LIBRARY_PATH@ -TOPSUBDIRS = @TOPSUBDIRS@ -UIC = @UIC@ -UIC_TR = @UIC_TR@ -USER_INCLUDES = @USER_INCLUDES@ -USER_LDFLAGS = @USER_LDFLAGS@ -USE_EXCEPTIONS = @USE_EXCEPTIONS@ -USE_RTTI = @USE_RTTI@ -USE_THREADS = @USE_THREADS@ -VERSION = @VERSION@ -WOVERLOADED_VIRTUAL = @WOVERLOADED_VIRTUAL@ -XGETTEXT = @XGETTEXT@ -XMKMF = @XMKMF@ -XMLLINT = @XMLLINT@ -X_EXTRA_LIBS = @X_EXTRA_LIBS@ -X_INCLUDES = @X_INCLUDES@ -X_LDFLAGS = @X_LDFLAGS@ -X_PRE_LIBS = @X_PRE_LIBS@ -X_RPATH = @X_RPATH@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -ac_ct_F77 = @ac_ct_F77@ -all_includes = @all_includes@ -all_libraries = @all_libraries@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -kde_appsdir = @kde_appsdir@ -kde_bindir = @kde_bindir@ -kde_confdir = @kde_confdir@ -kde_datadir = @kde_datadir@ -kde_htmldir = @kde_htmldir@ -kde_icondir = @kde_icondir@ -kde_includes = @kde_includes@ -kde_kcfgdir = @kde_kcfgdir@ -kde_libraries = @kde_libraries@ -kde_libs_htmldir = @kde_libs_htmldir@ -kde_libs_prefix = @kde_libs_prefix@ -kde_locale = @kde_locale@ -kde_mimedir = @kde_mimedir@ -kde_moduledir = @kde_moduledir@ -kde_qtver = @kde_qtver@ -kde_servicesdir = @kde_servicesdir@ -kde_servicetypesdir = @kde_servicetypesdir@ -kde_sounddir = @kde_sounddir@ -kde_styledir = @kde_styledir@ -kde_templatesdir = @kde_templatesdir@ -kde_wallpaperdir = @kde_wallpaperdir@ -kde_widgetdir = @kde_widgetdir@ -kdeinitdir = @kdeinitdir@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -qt_includes = @qt_includes@ -qt_libraries = @qt_libraries@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -sysconfdir = @sysconfdir@ -target = @target@ -target_alias = @target_alias@ -target_cpu = @target_cpu@ -target_os = @target_os@ -target_vendor = @target_vendor@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -x_includes = @x_includes@ -x_libraries = @x_libraries@ -xdg_appsdir = @xdg_appsdir@ -xdg_directorydir = @xdg_directorydir@ -xdg_menudir = @xdg_menudir@ -#>- libbackend_a_METASOURCES = AUTO -noinst_LIBRARIES = libbackend.a -INCLUDES = $(all_includes) -libbackend_a_SOURCES = bt_gbfhtml.cpp bt_osishtml.cpp bt_plainhtml.cpp \ - bt_thmlhtml.cpp bt_thmlplain.cpp btstringmgr.cpp cbookdisplay.cpp \ - cchapterdisplay.cpp cdisplayrendering.cpp cdisplaytemplatemgr.cpp centrydisplay.cpp \ - chtmlexportrendering.cpp clanguagemgr.cpp cplaintextexportrendering.cpp \ - creferencemanager.cpp cswordbackend.cpp cswordbiblemoduleinfo.cpp cswordbookmoduleinfo.cpp \ - cswordcommentarymoduleinfo.cpp cswordkey.cpp cswordldkey.cpp cswordlexiconmoduleinfo.cpp \ - cswordmoduleinfo.cpp cswordmodulesearch.cpp cswordtreekey.cpp cswordversekey.cpp \ - ctextrendering.cpp osismorphsegmentation.cpp - -all_headers = cswordbiblemoduleinfo.h \ -cswordcommentarymoduleinfo.h \ -cswordlexiconmoduleinfo.h \ -cswordkey.h \ -cswordversekey.h \ -cswordldkey.h \ -cswordbackend.h \ -cswordmoduleinfo.h \ -cswordmodulesearch.h \ -creferencemanager.h \ -cswordbookmoduleinfo.h \ -cswordtreekey.h \ -bt_thmlhtml.h \ -bt_osishtml.h \ -bt_gbfhtml.h \ -bt_plainhtml.h \ -bt_thmlplain.h \ -centrydisplay.h \ -clanguagemgr.h \ -cdisplaytemplatemgr.h \ -ctextrendering.h \ -btstringmgr.h \ -cbookdisplay.h \ -cchapterdisplay.h \ -chtmlexportrendering.h \ -cplaintextexportrendering.h \ -cdisplayrendering.h \ -osismorphsegmentation.h - -EXTRA_DIST = $(libbackend_a_SOURCES) $(all_headers) -#>- all: all-am -#>+ 1 -all: docs-am all-am - -.SUFFIXES: -.SUFFIXES: .cpp .lo .o .obj -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) -#>- @for dep in $?; do \ -#>- case '$(am__configure_deps)' in \ -#>- *$$dep*) \ -#>- cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ -#>- && exit 0; \ -#>- exit 1;; \ -#>- esac; \ -#>- done; \ -#>- echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu bibletime/backend/Makefile'; \ -#>- cd $(top_srcdir) && \ -#>- $(AUTOMAKE) --gnu bibletime/backend/Makefile -#>+ 12 - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ - && exit 0; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu bibletime/backend/Makefile'; \ - cd $(top_srcdir) && \ - $(AUTOMAKE) --gnu bibletime/backend/Makefile - cd $(top_srcdir) && perl admin/am_edit bibletime/backend/Makefile.in -.PRECIOUS: Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -clean-noinstLIBRARIES: - -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) -libbackend.a: $(libbackend_a_OBJECTS) $(libbackend_a_DEPENDENCIES) - -rm -f libbackend.a - $(libbackend_a_AR) libbackend.a $(libbackend_a_OBJECTS) $(libbackend_a_LIBADD) - $(RANLIB) libbackend.a - -mostlyclean-compile: - -rm -f *.$(OBJEXT) - -distclean-compile: - -rm -f *.tab.c - -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bt_gbfhtml.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bt_osishtml.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bt_plainhtml.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bt_thmlhtml.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bt_thmlplain.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/btstringmgr.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cbookdisplay.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cchapterdisplay.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cdisplayrendering.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cdisplaytemplatemgr.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/centrydisplay.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chtmlexportrendering.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/clanguagemgr.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cplaintextexportrendering.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/creferencemanager.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cswordbackend.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cswordbiblemoduleinfo.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cswordbookmoduleinfo.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cswordcommentarymoduleinfo.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cswordkey.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cswordldkey.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cswordlexiconmoduleinfo.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cswordmoduleinfo.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cswordmodulesearch.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cswordtreekey.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cswordversekey.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ctextrendering.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/osismorphsegmentation.Po@am__quote@ - -.cpp.o: -@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< - -.cpp.obj: -@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` -@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` - -.cpp.lo: -@am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs - -ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - mkid -fID $$unique -tags: TAGS - -TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - tags=; \ - here=`pwd`; \ - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$tags $$unique; \ - fi -ctags: CTAGS -CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - tags=; \ - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - test -z "$(CTAGS_ARGS)$$tags$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$tags $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && cd $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) $$here - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ - fi; \ - cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ - else \ - test -f $(distdir)/$$file \ - || cp -p $$d/$$file $(distdir)/$$file \ - || exit 1; \ - fi; \ - done -check-am: all-am -check: check-am -all-am: Makefile $(LIBRARIES) -installdirs: -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - `test -z '$(STRIP)' || \ - echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -#>- clean: clean-am -#>+ 1 -clean: kde-rpo-clean clean-am - -#>- clean-am: clean-generic clean-libtool clean-noinstLIBRARIES \ -#>- mostlyclean-am -#>+ 2 -clean-am: clean-bcheck clean-final clean-generic clean-libtool clean-noinstLIBRARIES \ - mostlyclean-am - -distclean: distclean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -distclean-am: clean-am distclean-compile distclean-generic \ - distclean-tags - -dvi: dvi-am - -dvi-am: - -html: html-am - -info: info-am - -info-am: - -install-data-am: - -install-dvi: install-dvi-am - -install-exec-am: - -install-html: install-html-am - -install-info: install-info-am - -install-man: - -install-pdf: install-pdf-am - -install-ps: install-ps-am - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-compile mostlyclean-generic \ - mostlyclean-libtool - -pdf: pdf-am - -pdf-am: - -ps: ps-am - -ps-am: - -uninstall-am: - -.MAKE: install-am install-strip - -.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ - clean-libtool clean-noinstLIBRARIES ctags distclean \ - distclean-compile distclean-generic distclean-libtool \ - distclean-tags distdir dvi dvi-am html html-am info info-am \ - install install-am install-data install-data-am install-dvi \ - install-dvi-am install-exec install-exec-am install-html \ - install-html-am install-info install-info-am install-man \ - install-pdf install-pdf-am install-ps install-ps-am \ - install-strip installcheck installcheck-am installdirs \ - maintainer-clean maintainer-clean-generic mostlyclean \ - mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ - pdf pdf-am ps ps-am tags uninstall uninstall-am - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: - -#>+ 2 -KDE_DIST=cswordcommentarymoduleinfo.h clanguagemgr.h cswordmodulesearch.h bt_plainhtml.h ctextrendering.h cswordkey.h bt_gbfhtml.h cswordbiblemoduleinfo.h cswordbookmoduleinfo.h cswordversekey.h cswordtreekey.h bt_thmlhtml.h btstringmgr.h cswordlexiconmoduleinfo.h cplaintextexportrendering.h centrydisplay.h Makefile.in cdisplayrendering.h chtmlexportrendering.h cbookdisplay.h cswordldkey.h cdisplaytemplatemgr.h cchapterdisplay.h cswordmoduleinfo.h bt_osishtml.h bt_thmlplain.h cswordbackend.h osismorphsegmentation.h creferencemanager.h Makefile.am - -#>+ 2 -docs-am: - -#>+ 15 -force-reedit: - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ - && exit 0; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu bibletime/backend/Makefile'; \ - cd $(top_srcdir) && \ - $(AUTOMAKE) --gnu bibletime/backend/Makefile - cd $(top_srcdir) && perl admin/am_edit bibletime/backend/Makefile.in - - -#>+ 21 -clean-bcheck: - rm -f *.bchecktest.cc *.bchecktest.cc.class a.out - -bcheck: bcheck-am - -bcheck-am: - @for i in ; do \ - if test $(srcdir)/$$i -nt $$i.bchecktest.cc; then \ - echo "int main() {return 0;}" > $$i.bchecktest.cc ; \ - echo "#include \"$$i\"" >> $$i.bchecktest.cc ; \ - echo "$$i"; \ - if ! $(CXXCOMPILE) --dump-class-hierarchy -c $$i.bchecktest.cc; then \ - rm -f $$i.bchecktest.cc; exit 1; \ - fi ; \ - echo "" >> $$i.bchecktest.cc.class; \ - perl $(top_srcdir)/admin/bcheck.pl $$i.bchecktest.cc.class || { rm -f $$i.bchecktest.cc; exit 1; }; \ - rm -f a.out; \ - fi ; \ - done - - -#>+ 11 -libbackend_a.all_cpp.cpp: $(srcdir)/Makefile.in $(srcdir)/bt_gbfhtml.cpp $(srcdir)/bt_osishtml.cpp $(srcdir)/bt_plainhtml.cpp $(srcdir)/bt_thmlhtml.cpp $(srcdir)/bt_thmlplain.cpp $(srcdir)/btstringmgr.cpp $(srcdir)/cbookdisplay.cpp $(srcdir)/cchapterdisplay.cpp $(srcdir)/cdisplayrendering.cpp $(srcdir)/cdisplaytemplatemgr.cpp $(srcdir)/centrydisplay.cpp $(srcdir)/chtmlexportrendering.cpp $(srcdir)/clanguagemgr.cpp $(srcdir)/cplaintextexportrendering.cpp $(srcdir)/creferencemanager.cpp $(srcdir)/cswordbackend.cpp $(srcdir)/cswordbiblemoduleinfo.cpp $(srcdir)/cswordbookmoduleinfo.cpp $(srcdir)/cswordcommentarymoduleinfo.cpp $(srcdir)/cswordkey.cpp $(srcdir)/cswordldkey.cpp $(srcdir)/cswordlexiconmoduleinfo.cpp $(srcdir)/cswordmoduleinfo.cpp $(srcdir)/cswordmodulesearch.cpp $(srcdir)/cswordtreekey.cpp $(srcdir)/cswordversekey.cpp $(srcdir)/ctextrendering.cpp $(srcdir)/osismorphsegmentation.cpp - @echo 'creating libbackend_a.all_cpp.cpp ...'; \ - rm -f libbackend_a.all_cpp.files libbackend_a.all_cpp.final; \ - echo "#define KDE_USE_FINAL 1" >> libbackend_a.all_cpp.final; \ - for file in bt_gbfhtml.cpp bt_osishtml.cpp bt_plainhtml.cpp bt_thmlhtml.cpp bt_thmlplain.cpp btstringmgr.cpp cbookdisplay.cpp cchapterdisplay.cpp cdisplayrendering.cpp cdisplaytemplatemgr.cpp centrydisplay.cpp chtmlexportrendering.cpp clanguagemgr.cpp cplaintextexportrendering.cpp creferencemanager.cpp cswordbackend.cpp cswordbiblemoduleinfo.cpp cswordbookmoduleinfo.cpp cswordcommentarymoduleinfo.cpp cswordkey.cpp cswordldkey.cpp cswordlexiconmoduleinfo.cpp cswordmoduleinfo.cpp cswordmodulesearch.cpp cswordtreekey.cpp cswordversekey.cpp ctextrendering.cpp osismorphsegmentation.cpp ; do \ - echo "#include \"$$file\"" >> libbackend_a.all_cpp.files; \ - test ! -f $(srcdir)/$$file || egrep '^#pragma +implementation' $(srcdir)/$$file >> libbackend_a.all_cpp.final; \ - done; \ - cat libbackend_a.all_cpp.final libbackend_a.all_cpp.files > libbackend_a.all_cpp.cpp; \ - rm -f libbackend_a.all_cpp.final libbackend_a.all_cpp.files - -#>+ 3 -clean-final: - -rm -f libbackend_a.all_cpp.cpp - -#>+ 3 -final: - $(MAKE) libbackend_a_OBJECTS="$(libbackend_a_final_OBJECTS)" all-am - -#>+ 3 -final-install: - $(MAKE) libbackend_a_OBJECTS="$(libbackend_a_final_OBJECTS)" install-am - -#>+ 3 -no-final: - $(MAKE) libbackend_a_OBJECTS="$(libbackend_a_nofinal_OBJECTS)" all-am - -#>+ 3 -no-final-install: - $(MAKE) libbackend_a_OBJECTS="$(libbackend_a_nofinal_OBJECTS)" install-am - -#>+ 3 -cvs-clean: - $(MAKE) admindir=$(top_srcdir)/admin -f $(top_srcdir)/admin/Makefile.common cvs-clean - -#>+ 3 -kde-rpo-clean: - -rm -f *.rpo - -#>+ 3 -nmcheck: -nmcheck-am: nmcheck diff --git a/bibletime/backend/bt_gbfhtml.cpp b/bibletime/backend/bt_gbfhtml.cpp deleted file mode 100644 index 33d31a9..0000000 --- a/bibletime/backend/bt_gbfhtml.cpp +++ /dev/null @@ -1,303 +0,0 @@ -/********* -* -* This file is part of BibleTime's source code, http://www.bibletime.info/. -* -* Copyright 1999-2006 by the BibleTime developers. -* The BibleTime source code is licensed under the GNU General Public License version 2.0. -* -**********/ - - - -//BibleTime includes -#include "cswordmoduleinfo.h" -#include "cswordbackend.h" -#include "util/cpointers.h" - -#include "bt_gbfhtml.h" - -//sytsme includes -#include -#include - -//Sword includes -#include - -//Qt includes -#include -#include - -using namespace Filters; - -BT_GBFHTML::BT_GBFHTML() : sword::GBFHTML() { - - setEscapeStringCaseSensitive(true); - setPassThruUnknownEscapeString(true); //the HTML widget will render the HTML escape codes - - removeTokenSubstitute("Rf"); - // addTokenSubstitute("RB", ""); //start of a footnote with embedded text - - addTokenSubstitute("FI", ""); // italics begin - addTokenSubstitute("Fi", ""); - - addTokenSubstitute("FB", ""); // bold begin - addTokenSubstitute("Fb", ""); - - addTokenSubstitute("FR", ""); - addTokenSubstitute("Fr", ""); - - addTokenSubstitute("FU", ""); // underline begin - addTokenSubstitute("Fu", ""); - - addTokenSubstitute("FO", ""); // Old Testament quote begin - addTokenSubstitute("Fo", ""); - - - addTokenSubstitute("FS", ""); // Superscript begin// Subscript begin - addTokenSubstitute("Fs", ""); - - addTokenSubstitute("FV", ""); // Subscript begin - addTokenSubstitute("Fv", ""); - - addTokenSubstitute("TT", "
"); - addTokenSubstitute("Tt", "
"); - - addTokenSubstitute("TS", "
"); - addTokenSubstitute("Ts", "
"); - - //addTokenSubstitute("PP", ""); // poetry begin - //addTokenSubstitute("Pp", ""); - - - addTokenSubstitute("Fn", ""); // font end - addTokenSubstitute("CL", "
"); // new line - addTokenSubstitute("CM", "
"); // paragraph is a non showing comment that can be changed in the front end to

if desired - - addTokenSubstitute("CG", ">"); // literal greater-than sign - addTokenSubstitute("CT", "<"); // literal less-than sign - - addTokenSubstitute("JR", ""); // right align begin - addTokenSubstitute("JC", ""); // center align begin - addTokenSubstitute("JL", ""); // align end -} - -/** No descriptions */ -char BT_GBFHTML::processText(sword::SWBuf& buf, const sword::SWKey * key, const sword::SWModule * module) { - GBFHTML::processText(buf, key, module); - - if (!module->isProcessEntryAttributes()) { - return 1; //no processing should be done, may happen in a search - } - - CSwordModuleInfo* m = CPointers::backend()->findModuleByName( module->Name() ); - - if (m && !(m->has(CSwordModuleInfo::lemmas) || m->has(CSwordModuleInfo::morphTags) || m->has(CSwordModuleInfo::strongNumbers))) { //only parse if the module has strongs or lemmas - return 1; //WARNING: Return alread here - } - - //Am Anfang schuf Gott Himmel und Erde. - //A simple word means: No entry for this word "word" - QString result; - - QString t = QString::fromUtf8(buf.c_str()); - - QRegExp tag("([.,;:]?]*>\\s*)+"); - - QStringList list; - - int lastMatchEnd = 0; - - int pos = tag.search(t,0); - - if (pos == -1) { //no strong or morph code found in this text - return 1; //WARNING: Return already here - } - - //split the text into parts which end with the GBF tag marker for strongs/lemmas - while (pos != -1) { - list.append(t.mid(lastMatchEnd, pos+tag.matchedLength()-lastMatchEnd)); - - lastMatchEnd = pos + tag.matchedLength(); - pos = tag.search(t, pos + tag.matchedLength()); - } - - //append the trailing text to the list. - if (!t.right(t.length() - lastMatchEnd).isEmpty()) { - list.append(t.right(t.length() - lastMatchEnd)); - } - - //list is now a list of words with 1-n Strongs at the end, which belong to this word. - - //now create the necessary HTML in list entries and concat them to the result - tag = QRegExp("]*)>"); - tag.setMinimal(true); - - for (QStringList::iterator it = list.begin(); it != list.end(); ++it) { - QString e = (*it); //current entry to process - //qWarning(e.latin1()); - - //check if there is a word to which the strongs info belongs to. - //If yes, wrap that word with the strongs info - //If not, leave out the strongs info, because it can't be tight to a text - //Comparing the first char with < is not enough, because the tokenReplace is done already - //so there might be html tags already. - const bool textPresent = (e.stripWhiteSpace().remove(QRegExp("[.,;:]")).left(2) != ""); - pos += 7; - - //skip blanks, commas, dots and stuff at the beginning, it doesn't belong to the morph code - QString rep(""); - - hasMorphAttr = isMorph; - hasLemmaAttr = !isMorph; - - int startPos = 0; - QChar c = e[startPos]; - - while ((startPos < pos) && (c.isSpace() || c.isPunct())) { - ++startPos; - - c = e[startPos]; - } - - e.insert( startPos, rep ); - tagAttributeStart = startPos + 6; //to point to the start of the attributes - pos += rep.length(); - } - else { //add the attribute to the existing tag - e.remove(pos, tag.matchedLength()); - - if (tagAttributeStart == -1) { - continue; //nothing valid found - } - - if ((!isMorph && hasLemmaAttr) || (isMorph && hasMorphAttr)) { //we append another attribute value, e.g. 3000 gets 3000|5000 - //search the existing attribute start - QRegExp attrRegExp( isMorph ? "morph=\".+(?=\")" : "lemma=\".+(?=\")" ); - attrRegExp.setMinimal(true); - const int foundPos = e.find(attrRegExp, tagAttributeStart); - - if (foundPos != -1) { - e.insert(foundPos + attrRegExp.matchedLength(), QString("|").append(value)); - pos += value.length() + 1; - - hasLemmaAttr = !isMorph; - hasMorphAttr = isMorph; - } - } - else { //attribute was not yet inserted - QString attr; - attr.setLatin1(isMorph ? "morph" : "lemma").append("=\"").append(value).append("\" "); - - e.insert(tagAttributeStart, attr); - pos += attr.length(); - - hasMorphAttr = isMorph; - hasLemmaAttr = !isMorph; - } - - //tagAttributeStart remains the same - } - - insertedTag = true; - pos = tag.search(e, pos); - } - - result += e; - } - - if (list.count()) { - buf = (const char*)result.utf8(); - } - - return 1; -} - -bool BT_GBFHTML::handleToken(sword::SWBuf &buf, const char *token, sword::BasicFilterUserData *userData) { - if (!substituteToken(buf, token)) { //more than a simple replace - const unsigned int tokenLength = strlen(token); - unsigned long i; - sword::SWBuf value; - - BT_UserData* myUserData = dynamic_cast(userData); - sword::SWModule* myModule = const_cast(myUserData->module); //hack to be able to call stuff like Lang() - - if ( !strncmp(token, "WG", 2) - || !strncmp(token, "WH", 2) - || !strncmp(token, "WT", 2) ) { - buf.append('<'); - buf.append(token); - buf.append('>'); - } - else if (!strncmp(token, "RB", 2)) { - myUserData->hasFootnotePreTag = true; - buf.append(""); - } - else if (!strncmp(token, "RF", 2)) { - //we use several append calls because appendFormatted slows down filtering, which should be fast - - if (myUserData->hasFootnotePreTag) { - // qWarning("inserted footnotepre end"); - buf.append(""); - myUserData->hasFootnotePreTag = false; - } - - buf.append(" Name()); - buf.append('/'); - buf.append(myUserData->key->getShortText()); - buf.append('/'); - buf.append( QString::number(myUserData->swordFootnote++).latin1() ); - buf.append("\">* "); - - userData->suspendTextPassThru = true; - } - else if (!strncmp(token, "Rf", 2)) { //end of footnote - userData->suspendTextPassThru = false; - } - else if (!strncmp(token, "FN", 2)) { //the end tag is inserted in addTokenSubsitute - buf.append(""); - } - else if (!strncmp(token, "CA", 2)) { // ASCII value - buf.append( (char)atoi(&token[2]) ); - } - else { - return GBFHTML::handleToken(buf, token, userData); - } - } - - return true; -} diff --git a/bibletime/backend/bt_gbfhtml.h b/bibletime/backend/bt_gbfhtml.h deleted file mode 100644 index 4132047..0000000 --- a/bibletime/backend/bt_gbfhtml.h +++ /dev/null @@ -1,60 +0,0 @@ -/********* -* -* This file is part of BibleTime's source code, http://www.bibletime.info/. -* -* Copyright 1999-2006 by the BibleTime developers. -* The BibleTime source code is licensed under the GNU General Public License version 2.0. -* -**********/ - - - -/* $Header: /cvsroot/bibletime/bibletime/bibletime/backend/bt_gbfhtml.h,v 1.25 2007/06/29 22:47:14 joachim Exp $ */ -/* $Revision: 1.25 $ */ - -#ifndef BT_GBFHTML_H -#define BT_GBFHTML_H - -//Backend - -//Sword includes -#include -#include -#include -#include - -namespace Filters { - - /** GBF to HTML filter, - * This filter converts GBF Text into HTML - */ - -class BT_GBFHTML : public sword::GBFHTML/*, protected CFilterTool */ - { - -protected: - -class BT_UserData : public sword::GBFHTML::MyUserData { - -public: -BT_UserData(const sword::SWModule *module, const sword::SWKey *key) : sword::GBFHTML::MyUserData(module, key) { - swordFootnote = 1; - hasFootnotePreTag = false; - } - - short unsigned int swordFootnote; - }; - - virtual sword::BasicFilterUserData *createUserData(const sword::SWModule* module, const sword::SWKey* key) { - return new BT_UserData(module, key); - } - -public: - BT_GBFHTML(); - virtual bool handleToken(sword::SWBuf &buf, const char *token, sword::BasicFilterUserData *userData); - virtual char processText(sword::SWBuf& buf, const sword::SWKey*, const sword::SWModule * = 0); - }; - -} - -#endif diff --git a/bibletime/backend/bt_osishtml.cpp b/bibletime/backend/bt_osishtml.cpp deleted file mode 100644 index efe8f3f..0000000 --- a/bibletime/backend/bt_osishtml.cpp +++ /dev/null @@ -1,621 +0,0 @@ -/********* -* -* This file is part of BibleTime's source code, http://www.bibletime.info/. -* -* Copyright 1999-2006 by the BibleTime developers. -* The BibleTime source code is licensed under the GNU General Public License version 2.0. -* -**********/ - - - -//BibleTime includes -#include -#include "bt_osishtml.h" -#include "versekey.h" - -#include "clanguagemgr.h" -#include "creferencemanager.h" -#include "cswordmoduleinfo.h" -#include "frontend/cbtconfig.h" -#include "util/cpointers.h" - -#include - -//Sword includes -#include -#include -#include - -//KDE includes -#include - -//Qt includes -#include - -using sword::SWBuf; -using sword::XMLTag; - -using namespace Filters; - -BT_OSISHTML::BT_OSISHTML() : sword::OSISHTMLHREF() { - setPassThruUnknownEscapeString(true); //the HTML widget will render the HTML escape codes - - addTokenSubstitute("inscription", ""); - addTokenSubstitute("/inscription",""); - - addTokenSubstitute("mentioned", ""); - addTokenSubstitute("/mentioned", ""); - -// addTokenSubstitute("divineName", ""); -// addTokenSubstitute("/divineName", ""); - - //TODO Move that down to the real tag handling, segs without the type morph would generate incorrect markup, as the end span is always inserted -// addTokenSubstitute("seg type=\"morph\"", ""); -// addTokenSubstitute("/seg", ""); - - // OSIS tables - addTokenSubstitute("table", ""); - addTokenSubstitute("/table", "
"); - addTokenSubstitute("row", ""); - addTokenSubstitute("/row", ""); - addTokenSubstitute("cell", ""); - addTokenSubstitute("/cell", ""); - -} - -bool BT_OSISHTML::handleToken(sword::SWBuf &buf, const char *token, sword::BasicFilterUserData *userData) { - // manually process if it wasn't a simple substitution - - if (!substituteToken(buf, token)) { - BT_UserData* myUserData = dynamic_cast(userData); - sword::SWModule* myModule = const_cast(myUserData->module); //hack - - XMLTag tag(token); - // qWarning("found %s", token); - const bool osisQToTick = ((!userData->module->getConfigEntry("OSISqToTick")) || (strcmp(userData->module->getConfigEntry("OSISqToTick"), "false"))); - - if (!tag.getName()) { - return false; - } - - //

tag - if (!strcmp(tag.getName(), "div")) { - //handle intro - - if ((!tag.isEmpty()) && (!tag.isEndTag())) { //start tag - SWBuf type( tag.getAttribute("type") ); - - if (type == "introduction") { - buf.append("
"); - } - else if (type == "chapter") { - buf.append("
"); //don't open a div here, that would lead to a broken XML structure - } - else { - buf.append("
"); - } - } - else if (tag.isEndTag()) { //end tag - buf.append("
"); - } - } - else if (!strcmp(tag.getName(), "w")) { - if ((!tag.isEmpty()) && (!tag.isEndTag())) { //start tag - const char *attrib; - const char *val; - - XMLTag outTag("span"); - SWBuf attrValue; - - if ((attrib = tag.getAttribute("xlit"))) { - val = strchr(attrib, ':'); - val = (val) ? (val + 1) : attrib; - outTag.setAttribute("xlit", val); - } - - if ((attrib = tag.getAttribute("gloss"))) { - val = strchr(attrib, ':'); - val = (val) ? (val + 1) : attrib; - outTag.setAttribute("gloss", val); - } - - if ((attrib = tag.getAttribute("lemma"))) { - char splitChar = '|'; - const int countSplit1 = tag.getAttributePartCount("lemma", '|'); - const int countSplit2 = tag.getAttributePartCount("lemma", ' '); //TODO: not allowed, remove soon - int count = 0; - - if (countSplit1 > countSplit2) { //| split char - splitChar = '|'; //TODO: not allowed, remove soon - count = countSplit1; - } - else { - splitChar = ' '; - count = countSplit2; - } - - int i = (count > 1) ? 0 : -1; // -1 for whole value cuz it's faster, but does the same thing as 0 - attrValue = ""; - - do { - if (attrValue.length()) { - attrValue.append( '|' ); - } - - attrib = tag.getAttribute("lemma", i, splitChar); - - if (i < 0) { // to handle our -1 condition - i = 0; - } - - val = strchr(attrib, ':'); - val = (val) ? (val + 1) : attrib; - - attrValue.append(val); - } - while (++i < count); - - if (attrValue.length()) { - outTag.setAttribute("lemma", attrValue.c_str()); - } - } - - if ((attrib = tag.getAttribute("morph"))) { - char splitChar = '|'; - const int countSplit1 = tag.getAttributePartCount("morph", '|'); - const int countSplit2 = tag.getAttributePartCount("morph", ' '); //TODO: not allowed, remove soon - int count = 0; - - if (countSplit1 > countSplit2) { //| split char - splitChar = '|'; - count = countSplit1; - } - else { - splitChar = ' '; - count = countSplit2; - } - - int i = (count > 1) ? 0 : -1; // -1 for whole value cuz it's faster, but does the same thing as 0 - - attrValue = ""; - - do { - if (attrValue.length()) { - attrValue.append('|'); - } - - attrib = tag.getAttribute("morph", i, splitChar); - - if (i < 0) { - i = 0; // to handle our -1 condition - } - - val = strchr(attrib, ':'); - - if (val) { //the prefix gives the modulename - //check the prefix - if (!strncmp("robinson:", attrib, 9)) { //robinson - attrValue.append( "Robinson:" ); //work is not the same as Sword's module name - attrValue.append( val+1 ); - } - //strongs is handled by BibleTime - /*else if (!strncmp("strongs", attrib, val-atrrib)) { - attrValue.append( !strncmp(attrib, "x-", 2) ? attrib+2 : attrib ); - }*/ - else { - attrValue.append( !strncmp(attrib, "x-", 2) ? attrib+2 : attrib ); - } - } - else { //no prefix given - const bool skipFirst = ((val[0] == 'T') && ((val[1] == 'H') || (val[1] == 'H'))); - attrValue.append( skipFirst ? val+1 : val ); - } - } - while (++i < count); - - if (attrValue.length()) { - outTag.setAttribute("morph", attrValue.c_str()); - } - } - - if ((attrib = tag.getAttribute("POS"))) { - val = strchr(attrib, ':'); - val = (val) ? (val + 1) : attrib; - outTag.setAttribute("pos", val); - } - - buf.append( outTag.toString() ); - } - else if (tag.isEndTag()) { // end or empty tag - buf.append(""); - } - } - - // tag - else if (!strcmp(tag.getName(), "note")) { - if (!tag.isEndTag()) { //start tag - const SWBuf type( tag.getAttribute("type") ); - - if (type == "crossReference") { //note containing cross references - myUserData->inCrossrefNote = true; - myUserData->noteType = BT_UserData::CrossReference; - myUserData->swordFootnote++; // cross refs count as notes, too - - /* //get the refList value of the right entry attribute - AttributeList notes = myModule->getEntryAttributes()["Footnote"]; - bool foundNote = false; - - SWBuf id( tag.getAttribute("osisID") ); - SWBuf refList; - - for (AttributeList::iterator list_it = notes.begin(); (list_it != notes.end()) && !foundNote; ++list_it ) { - for (AttributeValue::iterator val_it = list_it->second.begin(); (val_it != list_it->second.end()) && !foundNote; ++val_it ) { - if ((val_it->first == "osisID") && (val_it->second == id)) { - foundNote = true; //this break the loop - refList = list_it->second["refList"]; - } - } - } - - if (refList.length()) { - buf.append(" "); - - myUserData->noteType = BT_UserData::CrossReference; - } - else { - myUserData->noteType = BT_UserData::Unknown; - }*/ - - buf.append(""); - } - - /* else if (type == "explanation") { - } - */ - else if ((type == "strongsMarkup") || (type == "x-strongsMarkup")) { - /** - * leave strong's markup notes out, in the future we'll probably have - * different option filters to turn different note types on or off - */ - - myUserData->suspendTextPassThru = true; - myUserData->noteType = BT_UserData::StrongsMarkup; - } - else if (type == "alternative") { - // qWarning("found alternative"); - // buf.append(" "); - myUserData->noteType = BT_UserData::Alternative; - myUserData->suspendTextPassThru = true; - myUserData->swordFootnote++; // count as notes, too - } - else { - // qWarning("found note in %s", myUserData->key->getShortText()); - buf.append(" Name()); - buf.append('/'); - buf.append(myUserData->key->getShortText()); - buf.append('/'); - buf.append( QString::number(myUserData->swordFootnote++).latin1() ); //inefficient - - const SWBuf n = tag.getAttribute("n"); - - buf.append("\">"); - buf.append( (n.length() > 0) ? n.c_str() : "*" ); - buf.append(" "); - - myUserData->noteType = BT_UserData::Footnote; - myUserData->suspendTextPassThru = true; - } - } - else { //if (tag.isEndTag()) { - Q_ASSERT(myUserData->noteType != BT_UserData::Unknown); - - if (myUserData->noteType == BT_UserData::CrossReference) { - buf.append(" "); -// myUserData->suspendTextPassThru = false; - myUserData->inCrossrefNote = false; - } - else if (myUserData->noteType == BT_UserData::Alternative) { - buf.append(" lastTextNode); - buf.append("\" title=\""); - buf.append((const char*)i18n("Alternative text").utf8()); - buf.append("\" />"); - } - - myUserData->noteType = BT_UserData::Unknown; - myUserData->suspendTextPassThru = false; - } - } - // The

paragraph tag is handled by OSISHTMLHref - else if (!strcmp(tag.getName(), "reference")) { // tag - - if (!tag.isEndTag() && !tag.isEmpty()) { - QString ref( tag.getAttribute("osisRef") ); - QString hrefRef( ref ); - Q_ASSERT(!ref.isEmpty()); - - if (!ref.isEmpty()) { - //find out the mod, using the current module makes sense if it's a bible or commentary because the refs link into a bible by default. - //If the osisRef is something like "ModuleID:key comes here" then the - // modulename is given, so we'll use that one - - CSwordModuleInfo* mod = CPointers::backend()->findSwordModuleByPointer(myModule); - Q_ASSERT(mod); - if (!mod || (mod->type() != CSwordModuleInfo::Bible - && mod->type() != CSwordModuleInfo::Commentary)) { - - mod = CBTConfig::get( CBTConfig::standardBible ); - } - - Q_ASSERT(mod); - - //if the osisRef like "GerLut:key" contains a module, use that - int pos = ref.find(":"); - - if ((pos >= 0) && ref.at(pos-1).isLetter() && ref.at(pos+1).isLetter()) { - QString newModuleName = ref.left(pos); - hrefRef = ref.mid(pos+1); - - if (CPointers::backend()->findModuleByName(newModuleName)) { - mod = CPointers::backend()->findModuleByName(newModuleName); - } - } - - CReferenceManager::ParseOptions options; - options.refBase = QString::fromUtf8(myUserData->key->getText()); - options.refDestinationModule = QString(mod->name()); - options.sourceLanguage = QString(myModule->Lang()); - options.destinationLanguage = QString("en"); - - buf.append("name(), - CReferenceManager::parseVerseReference(hrefRef, options), - CReferenceManager::typeFromModule(mod->type()) - ).utf8() - ); - buf.append("\" crossrefs=\""); - buf.append((const char*)CReferenceManager::parseVerseReference(ref, options).utf8()); //ref must contain the osisRef module marker if there was any - buf.append("\">"); - } - } - else if (tag.isEndTag()) { - buf.append(""); - } - else { // empty reference marker - // -- what should we do? nothing for now. - } - } - - // is handled by OSISHTMLHref - // - else if (!strcmp(tag.getName(), "title")) { - if (!tag.isEndTag() && !tag.isEmpty()) { - buf.append("<div class=\"sectiontitle\">"); - } - else if (tag.isEndTag()) { - buf.append("</div>"); - } - else { // empty title marker - // what to do? is this even valid? - buf.append("<br/>"); - } - } - - // <hi> highlighted text - else if (!strcmp(tag.getName(), "hi")) { - const SWBuf type = tag.getAttribute("type"); - - if ((!tag.isEndTag()) && (!tag.isEmpty())) { - if (type == "bold") { - buf.append("<span class=\"bold\">"); - } - else if (type == "illuminated") { - buf.append("<span class=\"illuminated\">"); - } - else if (type == "italic") { - buf.append("<span class=\"italic\">"); - } - else if (type == "line-through") { - buf.append("<span class=\"line-through\">"); - } - else if (type == "normal") { - buf.append("<span class=\"normal\">"); - } - else if (type == "small-caps") { - buf.append("<span class=\"small-caps\">"); - } - else if (type == "underline") { - buf.append("<span class=\"underline\">"); - } - else { - buf.append("<span>"); //don't break markup, </span> is inserted later - } - } - else if (tag.isEndTag()) { //all hi replacements are html spans - buf.append("</span>"); - } - } - - //name - else if (!strcmp(tag.getName(), "name")) { - const SWBuf type = tag.getAttribute("type"); - - if ((!tag.isEndTag()) && (!tag.isEmpty())) { - if (type == "geographic") { - buf.append("<span class=\"name\"><span class=\"geographic\">"); - } - else if (type == "holiday") { - buf.append("<span class=\"name\"><span class=\"holiday\">"); - } - else if (type == "nonhuman") { - buf.append("<span class=\"name\"><span class=\"nonhuman\">"); - } - else if (type == "person") { - buf.append("<span class=\"name\"><span class=\"person\">"); - } - else if (type == "ritual") { - buf.append("<span class=\"name\"><span class=\"ritual\">"); - } - else { - buf.append("<span class=\"name\"><span>"); - } - } - else if (tag.isEndTag()) { //all hi replacements are html spans - buf.append("</span></span> "); - } - } - else if (!strcmp(tag.getName(), "transChange")) { - SWBuf type( tag.getAttribute("type") ); - - if ( !type.length() ) { - type = tag.getAttribute("changeType"); - } - - if ((!tag.isEndTag()) && (!tag.isEmpty())) { - if (type == "added") { - buf.append("<span class=\"transchange\" title=\""); - buf.append((const char*)i18n("Added text").utf8()); - buf.append("\"><span class=\"added\">"); - } - else if (type == "amplified") { - buf.append("<span class=\"transchange\"><span class=\"amplified\">"); - } - else if (type == "changed") { - buf.append("<span class=\"transchange\"><span class=\"changed\">"); - } - else if (type == "deleted") { - buf.append("<span class=\"transchange\"><span class=\"deleted\">"); - } - else if (type == "moved") { - buf.append("<span class=\"transchange\"><span class=\"moved\">"); - } - else if (type == "tenseChange") { - buf.append("<span class=\"transchange\"><span class=\"tenseChange\">"); - } - else { - buf.append("<span class=\"transchange\"><span>"); - } - } - else if (tag.isEndTag()) { //all hi replacements are html spans - buf.append("</span></span>"); - } - } - else if (!strcmp(tag.getName(), "p")) { - if (tag.isEmpty()) { - buf.append("<p/>"); - } - } - - // <q> quote - else if (!strcmp(tag.getName(), "q")) { - SWBuf type = tag.getAttribute("type"); - SWBuf who = tag.getAttribute("who"); - const char *lev = tag.getAttribute("level"); - int level = (lev) ? atoi(lev) : 1; - - if ((!tag.isEndTag()) && (!tag.isEmpty())) { - myUserData->quote.who = who; - - if(osisQToTick) //alternate " and ' - buf.append((level % 2) ? '\"' : '\''); - - if (who == "Jesus") { - buf.append("<span class=\"jesuswords\">"); - } - } - else if (tag.isEndTag()) { - if (myUserData->quote.who == "Jesus") { - buf.append("</span>"); - } - - if (osisQToTick) { //alternate " and ' - buf.append((level % 2) ? '\"' : '\''); - } - - myUserData->quote.who = ""; - } - } - - // abbr tag - else if (!strcmp(tag.getName(), "abbr")) { - if (!tag.isEndTag() && !tag.isEmpty()) { - const SWBuf expansion = tag.getAttribute("expansion"); - - buf.append("<span class=\"abbreviation\" expansion=\""); - buf.append(expansion); - buf.append("\">"); - } - else if (tag.isEndTag()) { - buf.append("</span>"); - } - } - - // <milestone> tag - else if (!strcmp(tag.getName(), "milestone")) { - const SWBuf type = tag.getAttribute("type"); - - if ((type == "screen") || (type == "line")) {//line break - buf.append("<br/>"); - userData->supressAdjacentWhitespace = true; - } - else if (type == "x-p") { //e.g. occurs in the KJV2006 module - //buf.append("<br/>"); - const SWBuf marker = tag.getAttribute("marker"); - if (marker.length() > 0) { - buf.append(marker); - } - } - } - //seg tag - else if (!strcmp(tag.getName(), "seg")) { - if (!tag.isEndTag() && !tag.isEmpty()) { - - const SWBuf type = tag.getAttribute("type"); - - if (type == "morph") {//line break - //This code is for WLC and MORPH (WHI) - XMLTag outTag("span"); - outTag.setAttribute("class", "morphSegmentation"); - const char* attrValue; - //Transfer the values to the span - //Problem: the data is in hebrew/aramaic, how to encode in HTML/BibleTime? - if ((attrValue = tag.getAttribute("lemma"))) outTag.setAttribute("lemma", attrValue); - if ((attrValue = tag.getAttribute("morph"))) outTag.setAttribute("morph", attrValue); - if ((attrValue = tag.getAttribute("homonym"))) outTag.setAttribute("homonym", attrValue); - - buf.append(outTag.toString()); - //buf.append("<span class=\"morphSegmentation\">"); - } - else{ - buf.append("<span>"); - } - } - else { // seg end tag - buf.append("</span>"); - } - //qWarning(QString("handled <seg> token. result: %1").arg(buf.c_str()).latin1()); - } - - //divine name, don't use simple tag replacing because it may have attributes - else if (!strcmp(tag.getName(), "divineName")) { - if (!tag.isEndTag()) { - buf.append("<span class=\"name\"><span class=\"divine\">"); - } - else { //all hi replacements are html spans - buf.append("</span></span>"); - } - } - - else { //all tokens handled by OSISHTMLHref will run through the filter now - return sword::OSISHTMLHREF::handleToken(buf, token, userData); - } - } - - return false; -} diff --git a/bibletime/backend/bt_osishtml.h b/bibletime/backend/bt_osishtml.h deleted file mode 100644 index 22e5b81..0000000 --- a/bibletime/backend/bt_osishtml.h +++ /dev/null @@ -1,66 +0,0 @@ -/********* -* -* This file is part of BibleTime's source code, http://www.bibletime.info/. -* -* Copyright 1999-2006 by the BibleTime developers. -* The BibleTime source code is licensed under the GNU General Public License version 2.0. -* -**********/ - - - -#ifndef BT_OSISHTML_H -#define BT_OSISHTML_H - -//Sword includes -#include <osishtmlhref.h> - -namespace Filters { - - /** BibleTime's OSIS to HTMl filter. - * This filter works on OSIS tags and outputs HTML in the structure supported by BibleTime. - */ - -class BT_OSISHTML : public sword::OSISHTMLHREF { - -protected: - -class BT_UserData : public sword::OSISHTMLHREF::MyUserData { - -public: -BT_UserData(const sword::SWModule *module, const sword::SWKey *key) : sword::OSISHTMLHREF::MyUserData(module, key) { - noteType = Unknown; - swordFootnote = 1; - inCrossrefNote = false; - } - - unsigned short int swordFootnote; - bool inCrossrefNote; - - enum NoteType { - Unknown, - Alternative, - CrossReference, - Footnote, - StrongsMarkup - } noteType; - - struct { - sword::SWBuf who; - } - - quote; - }; - - virtual sword::BasicFilterUserData *createUserData(const sword::SWModule* module, const sword::SWKey* key) { - return new BT_UserData(module, key); - } - -public: - BT_OSISHTML(); - virtual bool handleToken(sword::SWBuf &buf, const char *token, sword::BasicFilterUserData *userData); - }; - -} //end of Filters namespace - -#endif diff --git a/bibletime/backend/bt_plainhtml.cpp b/bibletime/backend/bt_plainhtml.cpp deleted file mode 100644 index 703362a..0000000 --- a/bibletime/backend/bt_plainhtml.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/********* -* -* This file is part of BibleTime's source code, http://www.bibletime.info/. -* -* Copyright 1999-2006 by the BibleTime developers. -* The BibleTime source code is licensed under the GNU General Public License version 2.0. -* -**********/ - - - -//BibleTime includes -#include "cswordmoduleinfo.h" -#include "cswordbackend.h" -#include "util/cpointers.h" - -#include "bt_plainhtml.h" - -//system includes -#include <stdlib.h> -#include <stdio.h> - -//Sword includes -#include <utilxml.h> - -//Qt includes -#include <qregexp.h> -#include <qstring.h> - -using namespace Filters; - -BT_PLAINHTML::BT_PLAINHTML() : sword::SWFilter() { -} - -/** No descriptions */ -char BT_PLAINHTML::processText(sword::SWBuf& text, const sword::SWKey * key, const sword::SWModule * module) { - int count = 0; - - SWBuf orig = text; - const char *from = orig.c_str(); - for (text = ""; *from; from++) - { - if ((*from == '\n') && (from[1] == '\n')) // two newlinea are a paragraph - { - text += "<P>"; - from++; - continue; - } - //This is a special case: Newlines in the plaintext editor are stored as <br />, not as \n - //we need to let them through - else if ((*from == '<') && (from[1] == 'b') && (from[2] == 'r') && (from[3] == ' ') && (from[4] == '/') && (from[5] == '>')){ - text += "<br />"; - from += 5; - continue; - } - else if ((*from == '\n')){ // only one new line - text += "<BR>"; - continue; - } - else if (*from == '<') { - text += "<"; - continue; - } - else if (*from == '>') { - text += ">"; - continue; - } - else if (*from == '&'){ - text += "&"; - continue; - } - else if (*from == '{') { //footnote start - text += "<FONT COLOR=\"#80000\"><SMALL> ("; - continue; - } - else if (*from == '}') //footnote end - { - text += ") </SMALL></FONT>"; - continue; - } - else if ((*from == ' ') && (count > 5000)) - { - text += "<WBR>"; - count = 0; - continue; - } - - text += *from; - count++; - } - return 0; -} diff --git a/bibletime/backend/bt_plainhtml.h b/bibletime/backend/bt_plainhtml.h deleted file mode 100644 index fec3a48..0000000 --- a/bibletime/backend/bt_plainhtml.h +++ /dev/null @@ -1,41 +0,0 @@ -/********* -* -* This file is part of BibleTime's source code, http://www.bibletime.info/. -* -* Copyright 1999-2006 by the BibleTime developers. -* The BibleTime source code is licensed under the GNU General Public License version 2.0. -* -**********/ - - - -/* $Header: /cvsroot/bibletime/bibletime/bibletime/backend/bt_plainhtml.h,v 1.3 2007/06/29 22:47:14 joachim Exp $ */ -/* $Revision: 1.3 $ */ - -#ifndef BT_PLAINHTML_H -#define BT_PLAINHTML_H - -//Sword includes -#include <swkey.h> -#include <swmodule.h> -#include <swfilter.h> -//#include <plainhtml.h> - -namespace Filters { - - /** Plain to HTML filter, - * This filter converts Plain Text into HTML - */ - -class BT_PLAINHTML : public sword::SWFilter{ - -protected: - -public: - BT_PLAINHTML(); - virtual char processText(sword::SWBuf& buf, const sword::SWKey*, const sword::SWModule * = 0); - }; - -} - -#endif diff --git a/bibletime/backend/bt_thmlhtml.cpp b/bibletime/backend/bt_thmlhtml.cpp deleted file mode 100644 index 7a00bd4..0000000 --- a/bibletime/backend/bt_thmlhtml.cpp +++ /dev/null @@ -1,395 +0,0 @@ -/********* -* -* This file is part of BibleTime's source code, http://www.bibletime.info/. -* -* Copyright 1999-2006 by the BibleTime developers. -* The BibleTime source code is licensed under the GNU General Public License version 2.0. -* -**********/ - - - - -//BibleTime includes -#include "backend/bt_thmlhtml.h" -#include "backend/clanguagemgr.h" -#include "backend/cswordmoduleinfo.h" -#include "backend/creferencemanager.h" - -#include "frontend/cbtconfig.h" - -#include "util/cpointers.h" -#include "util/scoped_resource.h" - -#include <iostream> - -//Sword includes -#include <swmodule.h> -#include <utilxml.h> -#include "versekey.h" - -//Qt includes -#include <qstring.h> -#include <qregexp.h> - -//System includes -#include <stdlib.h> - -using namespace Filters; - -BT_ThMLHTML::BT_ThMLHTML() { - setEscapeStringCaseSensitive(true); - setPassThruUnknownEscapeString(true); //the HTML widget will render the HTML escape codes - - setTokenStart("<"); - setTokenEnd(">"); - setTokenCaseSensitive(true); - - addTokenSubstitute("/foreign", "</span>"); - - removeTokenSubstitute("note"); - removeTokenSubstitute("/note"); -} - -char BT_ThMLHTML::processText(sword::SWBuf& buf, const sword::SWKey* key, const sword::SWModule* module) { - ThMLHTML::processText(buf, key, module); - - CSwordModuleInfo* m = CPointers::backend()->findModuleByName( module->Name() ); - - if (m && !(m->has(CSwordModuleInfo::lemmas) || m->has(CSwordModuleInfo::strongNumbers))) { //only parse if the module has strongs or lemmas - return 1; - } - - QString result; - - QString t = QString::fromUtf8(buf.c_str()); - QRegExp tag("([.,;]?<sync[^>]+(type|value)=\"([^\"]+)\"[^>]+(type|value)=\"([^\"]+)\"([^<]*)>)+"); - - QStringList list; - int lastMatchEnd = 0; - int pos = tag.search(t,0); - - if (pos == -1) { //no strong or morph code found in this text - return 1; //WARNING: Return alread here - } - - while (pos != -1) { - list.append(t.mid(lastMatchEnd, pos+tag.matchedLength()-lastMatchEnd)); - - lastMatchEnd = pos+tag.matchedLength(); - pos = tag.search(t,pos+tag.matchedLength()); - } - - if (!t.right(t.length() - lastMatchEnd).isEmpty()) { - list.append(t.right(t.length() - lastMatchEnd)); - } - - tag = QRegExp("<sync[^>]+(type|value|class)=\"([^\"]+)\"[^>]+(type|value|class)=\"([^\"]+)\"[^>]+((type|value|class)=\"([^\"]+)\")*([^<]*)>"); - - for (QStringList::iterator it = list.begin(); it != list.end(); ++it) { - QString e( *it ); - - const bool textPresent = (e.stripWhiteSpace().remove(QRegExp("[.,;:]")).left(1) != "<"); - - if (!textPresent) { - continue; - } - - - bool hasLemmaAttr = false; - bool hasMorphAttr = false; - - int pos = tag.search(e, 0); - bool insertedTag = false; - QString value; - QString valueClass; - - while (pos != -1) { - bool isMorph = false; - bool isStrongs = false; - value = QString::null; - valueClass = QString::null; - - // check 3 attribute/value pairs - - for (int i = 1; i < 6; i += 2) { - if (i > 4) - i++; - - if (tag.cap(i) == "type") { - isMorph = (tag.cap(i+1) == "morph"); - isStrongs = (tag.cap(i+1) == "Strongs"); - } - else if (tag.cap(i) == "value") { - value = tag.cap(i+1); - } - else if (tag.cap(i) == "class") { - valueClass = tag.cap(i+1); - } - } - - // prepend the class qualifier to the value - if (!valueClass.isEmpty()) { - value = valueClass + ":" + value; - // value.append(":").append(value); - } - - if (value.isEmpty()) { - break; - } - - //insert the span - if (!insertedTag) { - e.replace(pos, tag.matchedLength(), "</span>"); - pos += 7; - - QString rep; - rep.setLatin1("<span lemma=\"").append(value).append("\">"); - int startPos = 0; - QChar c = e[startPos]; - - while ((startPos < pos) && (c.isSpace() || c.isPunct())) { - ++startPos; - c = e[startPos]; - } - - hasLemmaAttr = isStrongs; - hasMorphAttr = isMorph; - - e.insert( startPos, rep ); - pos += rep.length(); - } - else { //add the attribute to the existing tag - e.remove(pos, tag.matchedLength()); - - if ((!isMorph && hasLemmaAttr) || (isMorph && hasMorphAttr)) { //we append another attribute value, e.g. 3000 gets 3000|5000 - //search the existing attribute start - QRegExp attrRegExp( isMorph ? "morph=\".+(?=\")" : "lemma=\".+(?=\")" ); - attrRegExp.setMinimal(true); - const int foundAttrPos = e.find(attrRegExp, pos); - - if (foundAttrPos != -1) { - e.insert(foundAttrPos + attrRegExp.matchedLength(), QString("|").append(value)); - pos += value.length() + 1; - - hasLemmaAttr = !isMorph; - hasMorphAttr = isMorph; - } - } - else { //attribute was not yet inserted - const int attrPos = e.find(QRegExp("morph=|lemma="), 0); - - if (attrPos >= 0) { - QString attr; - attr.append(isMorph ? "morph" : "lemma").append("=\"").append(value).append("\" "); - e.insert(attrPos, attr); - - hasMorphAttr = isMorph; - hasLemmaAttr = !isMorph; - - pos += attr.length(); - } - } - } - - insertedTag = true; - pos = tag.search(e, pos); - } - - result.append( e ); - } - - if (list.count()) { - buf = (const char*)result.utf8(); - } - - return 1; -} - - -bool BT_ThMLHTML::handleToken(sword::SWBuf &buf, const char *token, sword::BasicFilterUserData *userData) { - if (!substituteToken(buf, token) && !substituteEscapeString(buf, token)) { - sword::XMLTag tag(token); - BT_UserData* myUserData = dynamic_cast<BT_UserData*>(userData); - sword::SWModule* myModule = const_cast<sword::SWModule*>(myUserData->module); //hack to be able to call stuff like Lang() - - if ( tag.getName() && !strcasecmp(tag.getName(), "foreign") ) { // a text part in another language, we have to set the right font - - if (tag.getAttribute("lang")) { - const char* abbrev = tag.getAttribute("lang"); - //const CLanguageMgr::Language* const language = CPointers::languageMgr()->languageForAbbrev( QString::fromLatin1(abbrev) ); - - buf.append("<span class=\"foreign\" lang=\""); - buf.append(abbrev); - buf.append("\">"); - } - } - else if (tag.getName() && !strcasecmp(tag.getName(), "sync")) { //lemmas, morph codes or strongs - - if (tag.getAttribute("type") && (!strcasecmp(tag.getAttribute("type"), "morph") || !strcasecmp(tag.getAttribute("type"), "Strongs") || !strcasecmp(tag.getAttribute("type"), "lemma"))) { // Morph or Strong - buf.append('<'); - buf.append(token); - buf.append('>'); - } - } - else if (tag.getName() && !strcasecmp(tag.getName(), "note")) { // <note> tag - - if (!tag.isEndTag() && !tag.isEmpty()) { - //appending is faster than appendFormatted - buf.append(" <span class=\"footnote\" note=\""); - buf.append(myModule->Name()); - buf.append('/'); - buf.append(myUserData->key->getShortText()); - buf.append('/'); - buf.append( QString::number(myUserData->swordFootnote++).latin1() ); - buf.append("\">*</span> "); - - myUserData->suspendTextPassThru = true; - myUserData->inFootnoteTag = true; - } - else if (tag.isEndTag() && !tag.isEmpty()) { //end tag - //buf += ")</span>"; - myUserData->suspendTextPassThru = false; - myUserData->inFootnoteTag = false; - } - } - else if (tag.getName() && !strcasecmp(tag.getName(), "scripRef")) { // a scripRef - //scrip refs which are embeded in footnotes may not be displayed! - - if (!myUserData->inFootnoteTag) { - if (tag.isEndTag()) { - if (myUserData->inscriptRef) { // like "<scripRef passage="John 3:16">See John 3:16</scripRef>" - buf.append("</a></span>"); - - myUserData->inscriptRef = false; - myUserData->suspendTextPassThru = false; - } - else { // like "<scripRef>John 3:16</scripRef>" - - CSwordModuleInfo* mod = CBTConfig::get(CBTConfig::standardBible); - Q_ASSERT(mod); - if (mod) { - CReferenceManager::ParseOptions options; - options.refBase = QString::fromUtf8(myUserData->key->getText()); //current module key - options.refDestinationModule = QString(mod->name()); - options.sourceLanguage = QString(myModule->Lang()); - options.destinationLanguage = QString("en"); - - //it's ok to split the reference, because to descriptive text is given - bool insertSemicolon = false; - buf.append("<span class=\"crossreference\">"); - QStringList refs = QStringList::split(";", QString::fromUtf8(myUserData->lastTextNode.c_str())); - QString oldRef; //the previous reference to use as a base for the next refs - for (QStringList::iterator it(refs.begin()); it != refs.end(); ++it) { - - if (! oldRef.isEmpty() ){ - options.refBase = oldRef; //use the last ref as a base, e.g. Rom 1,2-3, when the next ref is only 3:3-10 - } - const QString completeRef( CReferenceManager::parseVerseReference((*it), options) ); - - oldRef = completeRef; //use the parsed result as the base for the next ref. - - if (insertSemicolon) { //prepend a ref divider if we're after the first one - buf.append("; "); - } - - buf.append("<a href=\""); - buf.append( - CReferenceManager::encodeHyperlink( - mod->name(), - completeRef, - CReferenceManager::typeFromModule(mod->type()) - ).utf8() - ); - - buf.append("\" crossrefs=\""); - buf.append((const char*)completeRef.utf8()); - buf.append("\">"); - - buf.append((const char*)(*it).utf8()); - - buf.append("</a>"); - - insertSemicolon = true; - } - buf.append("</span>"); //crossref end - } - - myUserData->suspendTextPassThru = false; - } - } - else if (tag.getAttribute("passage") ) { //the passage was given as a parameter value - myUserData->inscriptRef = true; - myUserData->suspendTextPassThru = false; - - const char* ref = tag.getAttribute("passage"); - Q_ASSERT(ref); - - CSwordModuleInfo* mod = CBTConfig::get(CBTConfig::standardBible); - Q_ASSERT(mod); - - CReferenceManager::ParseOptions options; - options.refBase = QString::fromUtf8(myUserData->key->getText()); - options.refDestinationModule = QString(mod->name()); - options.sourceLanguage = myModule->Lang(); - options.destinationLanguage = QString("en"); - - const QString completeRef = CReferenceManager::parseVerseReference(QString::fromUtf8(ref), options); - - if (mod) { - buf.append("<span class=\"crossreference\">"); - buf.append("<a href=\""); - buf.append( - CReferenceManager::encodeHyperlink( - mod->name(), - completeRef, - CReferenceManager::typeFromModule(mod->type()) - ).utf8() - ); - buf.append("\" crossrefs=\""); - buf.append((const char*)completeRef.utf8()); - buf.append("\">"); - } - else { - buf.append("<span><a>"); - } - } - else if ( !tag.getAttribute("passage") ) { // we're starting a scripRef like "<scripRef>John 3:16</scripRef>" - myUserData->inscriptRef = false; - - // let's stop text from going to output, the text get's added in the -tag handler - myUserData->suspendTextPassThru = true; - } - } - } - else if (tag.getName() && !strcasecmp(tag.getName(), "div")) { - if (tag.isEndTag()) { - buf.append("</div>"); - } - else if ( tag.getAttribute("class") && !strcasecmp(tag.getAttribute("class"),"sechead") ) { - buf.append("<div class=\"sectiontitle\">"); - } - else if (tag.getAttribute("class") && !strcasecmp(tag.getAttribute("class"), "title")) { - buf.append("<div class=\"booktitle\">"); - } - } - else if (tag.getName() && !strcasecmp(tag.getName(), "img") && tag.getAttribute("src")) { - const char* value = tag.getAttribute("src"); - - if (value[0] == '/') { - value++; //strip the first / - } - - buf.append("<img src=\"file:"); - buf.append(myUserData->module->getConfigEntry("AbsoluteDataPath")); - buf.append('/'); - buf.append(value); - buf.append("\" />"); - } - else { // let unknown token pass thru - return sword::ThMLHTML::handleToken(buf, token, userData); - } - } - - return true; -} diff --git a/bibletime/backend/bt_thmlhtml.h b/bibletime/backend/bt_thmlhtml.h deleted file mode 100644 index e5ac614..0000000 --- a/bibletime/backend/bt_thmlhtml.h +++ /dev/null @@ -1,56 +0,0 @@ -/********* -* -* This file is part of BibleTime's source code, http://www.bibletime.info/. -* -* Copyright 1999-2006 by the BibleTime developers. -* The BibleTime source code is licensed under the GNU General Public License version 2.0. -* -**********/ - - - -#ifndef BT_THMLHTML_H -#define BT_THMLHTML_H - -#include <swbuf.h> -#include <thmlhtml.h> - -using sword::SWBuf; - -namespace Filters { - - /** ThML to HTML filter. - * This filter converts ThML text to HTML text - */ - -class BT_ThMLHTML : public sword::ThMLHTML { - -protected: - -class BT_UserData : public sword::ThMLHTML::MyUserData { - -public: -BT_UserData(const sword::SWModule *module, const sword::SWKey *key) : sword::ThMLHTML::MyUserData(module, key) { - inscriptRef = false; - swordFootnote = 1; - inFootnoteTag = false; - } - - bool inscriptRef; - bool inFootnoteTag; - unsigned short int swordFootnote; - }; - - virtual sword::BasicFilterUserData *createUserData(const sword::SWModule* module, const sword::SWKey* key) { - return new BT_UserData(module, key); - } - -public: - BT_ThMLHTML (); - virtual bool handleToken(sword::SWBuf &buf, const char *token, sword::BasicFilterUserData *userData); - virtual char processText(sword::SWBuf& buf, const sword::SWKey*, const sword::SWModule * = 0); - }; - -} - -#endif diff --git a/bibletime/backend/bt_thmlplain.cpp b/bibletime/backend/bt_thmlplain.cpp deleted file mode 100644 index 8c4d72d..0000000 --- a/bibletime/backend/bt_thmlplain.cpp +++ /dev/null @@ -1,221 +0,0 @@ -/****************************************************************************** - * - * thmlplain - SWFilter descendant to strip out all ThML tags or convert to - * ASCII rendered symbols. - */ - -#include "bt_thmlplain.h" - -#include <stdlib.h> -#include <swbuf.h> - -using namespace sword; - -namespace Filters { - -BT_ThMLPlain::BT_ThMLPlain() { -} - -char BT_ThMLPlain::processText(SWBuf &text, const SWKey *key, const SWModule *module) -{ - char token[2048]; - int tokpos = 0; - bool intoken = false; - bool ampersand = false; - - const char *from; - SWBuf orig = text; - from = orig.c_str(); - for (text = ""; *from; from++) - { - if (*from == 10 || *from == 13) - from++; - if (*from == '<') { - intoken = true; - tokpos = 0; - token[0] = 0; - token[1] = 0; - token[2] = 0; - ampersand = false; - continue; - } - else if (*from == '&') { - intoken = true; - tokpos = 0; - token[0] = 0; - token[1] = 0; - token[2] = 0; - ampersand = true; - continue; - } - if (*from == ';' && ampersand) { - intoken = false; - ampersand = false; - - if (!strncmp("nbsp", token, 4)) text += " "; - else if (!strncmp("quot", token, 4)) text += "\""; - else if (!strncmp("amp", token, 3)) text += "&"; - else if (!strncmp("lt", token, 2)) text += "<"; - else if (!strncmp("gt", token, 2)) text += ">"; - else if (!strncmp("brvbar", token, 6)) text += "¦"; - else if (!strncmp("sect", token, 4)) text += "§"; - else if (!strncmp("copy", token, 4)) text += "©"; - else if (!strncmp("laquo", token, 5)) text += "«"; - else if (!strncmp("reg", token, 3)) text += "®"; - else if (!strncmp("acute", token, 5)) text += "´"; - else if (!strncmp("para", token, 4)) text += "¶"; - else if (!strncmp("raquo", token, 5)) text += "»"; - - else if (!strncmp("Aacute", token, 6)) text += "Á"; - else if (!strncmp("Agrave", token, 6)) text += "À"; - else if (!strncmp("Acirc", token, 5)) text += "Â"; - else if (!strncmp("Auml", token, 4)) text += "Ä"; - else if (!strncmp("Atilde", token, 6)) text += "Ã"; - else if (!strncmp("Aring", token, 5)) text += "Å"; - else if (!strncmp("aacute", token, 6)) text += "á"; - else if (!strncmp("agrave", token, 6)) text += "à"; - else if (!strncmp("acirc", token, 5)) text += "â"; - else if (!strncmp("auml", token, 4)) text += "ä"; - else if (!strncmp("atilde", token, 6)) text += "ã"; - else if (!strncmp("aring", token, 5)) text += "å"; - else if (!strncmp("Eacute", token, 6)) text += "É"; - else if (!strncmp("Egrave", token, 6)) text += "È"; - else if (!strncmp("Ecirc", token, 5)) text += "Ê"; - else if (!strncmp("Euml", token, 4)) text += "Ë"; - else if (!strncmp("eacute", token, 6)) text += "é"; - else if (!strncmp("egrave", token, 6)) text += "è"; - else if (!strncmp("ecirc", token, 5)) text += "ê"; - else if (!strncmp("euml", token, 4)) text += "ë"; - else if (!strncmp("Iacute", token, 6)) text += "Í"; - else if (!strncmp("Igrave", token, 6)) text += "Ì"; - else if (!strncmp("Icirc", token, 5)) text += "Î"; - else if (!strncmp("Iuml", token, 4)) text += "Ï"; - else if (!strncmp("iacute", token, 6)) text += "í"; - else if (!strncmp("igrave", token, 6)) text += "ì"; - else if (!strncmp("icirc", token, 5)) text += "î"; - else if (!strncmp("iuml", token, 4)) text += "ï"; - else if (!strncmp("Oacute", token, 6)) text += "Ó"; - else if (!strncmp("Ograve", token, 6)) text += "Ò"; - else if (!strncmp("Ocirc", token, 5)) text += "Ô"; - else if (!strncmp("Ouml", token, 4)) text += "Ö"; - else if (!strncmp("Otilde", token, 6)) text += "Õ"; - else if (!strncmp("oacute", token, 6)) text += "ó"; - else if (!strncmp("ograve", token, 6)) text += "ò"; - else if (!strncmp("ocirc", token, 5)) text += "ô"; - else if (!strncmp("ouml", token, 4)) text += "ö"; - else if (!strncmp("otilde", token, 6)) text += "õ"; - else if (!strncmp("Uacute", token, 6)) text += "Ú"; - else if (!strncmp("Ugrave", token, 6)) text += "Ù"; - else if (!strncmp("Ucirc", token, 5)) text += "Û"; - else if (!strncmp("Uuml", token, 4)) text += "Ü"; - else if (!strncmp("uacute", token, 6)) text += "ú"; - else if (!strncmp("ugrave", token, 6)) text += "ù"; - else if (!strncmp("ucirc", token, 5)) text += "û"; - else if (!strncmp("uuml", token, 4)) text += "ü"; - else if (!strncmp("Yacute", token, 6)) text += "Ý"; - else if (!strncmp("yacute", token, 6)) text += "ý"; - else if (!strncmp("yuml", token, 4)) text += "ÿ"; - - else if (!strncmp("deg", token, 3)) text += "°"; - else if (!strncmp("plusmn", token, 6)) text += "±"; - else if (!strncmp("sup2", token, 4)) text += "²"; - else if (!strncmp("sup3", token, 4)) text += "³"; - else if (!strncmp("sup1", token, 4)) text += "¹"; - else if (!strncmp("nbsp", token, 4)) text += "º"; - else if (!strncmp("pound", token, 5)) text += "£"; - else if (!strncmp("cent", token, 4)) text += "¢"; - else if (!strncmp("frac14", token, 6)) text += "¼"; - else if (!strncmp("frac12", token, 6)) text += "½"; - else if (!strncmp("frac34", token, 6)) text += "¾"; - else if (!strncmp("iquest", token, 6)) text += "¿"; - else if (!strncmp("iexcl", token, 5)) text += "¡"; - else if (!strncmp("ETH", token, 3)) text += "Ð"; - else if (!strncmp("eth", token, 3)) text += "ð"; - else if (!strncmp("THORN", token, 5)) text += "Þ"; - else if (!strncmp("thorn", token, 5)) text += "þ"; - else if (!strncmp("AElig", token, 5)) text += "Æ"; - else if (!strncmp("aelig", token, 5)) text += "æ"; - else if (!strncmp("Oslash", token, 6)) text += "Ø"; - else if (!strncmp("curren", token, 6)) text += "¤"; - else if (!strncmp("Ccedil", token, 6)) text += "Ç"; - else if (!strncmp("ccedil", token, 6)) text += "ç"; - else if (!strncmp("szlig", token, 5)) text += "ß"; - else if (!strncmp("Ntilde", token, 6)) text += "Ñ"; - else if (!strncmp("ntilde", token, 6)) text += "ñ"; - else if (!strncmp("yen", token, 3)) text += "¥"; - else if (!strncmp("not", token, 3)) text += "¬"; - else if (!strncmp("ordf", token, 4)) text += "ª"; - else if (!strncmp("uml", token, 3)) text += "¨"; - else if (!strncmp("shy", token, 3)) text += "­"; - else if (!strncmp("macr", token, 4)) text += "¯"; - else if (!strncmp("micro", token, 5)) text += "µ"; - else if (!strncmp("middot", token, 6)) text +="·"; - else if (!strncmp("cedil", token, 5)) text += "¸"; - else if (!strncmp("ordm", token, 4)) text += "º"; - else if (!strncmp("times", token, 5)) text += "×"; - else if (!strncmp("divide", token, 6)) text +="÷"; - else if (!strncmp("oslash", token, 6)) text +="ø"; - continue; - - } - else if (*from == '>' && !ampersand) { - intoken = false; - // process desired tokens - if (!strncmp(token, "sync type=\"Strongs\" value=\"", 27)) { - text += ' '; - text += '<'; - for (unsigned int i = 27; token[i] != '\"'; i++) - text += token[i]; - text += '>'; - continue; - } - if (!strncmp(token, "sync type=\"morph\" value=\"", 25)) { - text += ' '; - text += '('; - for (unsigned int i = 25; token[i] != '\"'; i++) - text += token[i]; - text += ')'; - continue; - } - if (!strncmp("note", token, 4)) { - text += ' '; - text += '('; - } - else if (!strncmp("br", token, 2)) - text += '\n'; - else if (!strncmp("/p", token, 2)) - text += '\n'; - else if (!strncmp("/note", token, 5)) { - text += ')'; - text += ' '; - } - continue; - } - if (intoken) { - if (tokpos < 2045) - token[tokpos++] = *from; - token[tokpos+2] = 0; - } - else text += *from; - } - - orig = text; - from = orig.c_str(); - for (text = ""; *from; from++) { //loop to remove extra spaces - if ((strchr(" \t\n\r", *from))) { - while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { - from++; - } - text += " "; - } - else { - text += *from; - } - } - text += (char)0; - - return 0; -} - - -} diff --git a/bibletime/backend/bt_thmlplain.h b/bibletime/backend/bt_thmlplain.h deleted file mode 100644 index b510d33..0000000 --- a/bibletime/backend/bt_thmlplain.h +++ /dev/null @@ -1,40 +0,0 @@ -/****************************************************************************** - * - * $Id: bt_thmlplain.h,v 1.1 2007/03/14 21:32:47 joachim Exp $ - * - * Copyright 1998 CrossWire Bible Society (http://www.crosswire.org) - * CrossWire Bible Society - * P. O. Box 2528 - * Tempe, AZ 85280-2528 - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation version 2. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - */ - -#ifndef BT_THMLPLAIN_H -#define BT_THMLPLAIN_H - -#include <swfilter.h> - -using namespace sword; - -namespace Filters { - -/** this filter converts ThML text to plain text - */ -class BT_ThMLPlain : public SWFilter { -protected: - virtual char processText(SWBuf &text, const SWKey *key = 0, const SWModule *module = 0); -public: - BT_ThMLPlain(); -}; - -} -#endif diff --git a/bibletime/backend/btstringmgr.cpp b/bibletime/backend/btstringmgr.cpp deleted file mode 100644 index 83c29c8..0000000 --- a/bibletime/backend/btstringmgr.cpp +++ /dev/null @@ -1,145 +0,0 @@ -// -// C++ Implementation: btstringmgr -// -// Description: -// -// -// Author: The BibleTime team <info@bibletime.info>, (C) 2004 -// -// Copyright: See COPYING file that comes with this distribution -// -// - -#include "btstringmgr.h" - -//System includes -#include <ctype.h> - -char* BTStringMgr::upperUTF8(char* text, unsigned int maxlen) const { - const int max = (maxlen>0) ? maxlen : strlen(text); - - if (isUtf8(text)) { - strncpy(text, (const char*)QString::fromUtf8(text).upper().utf8(), max); - - return text; - } - else { - char* ret = text; - - while (*text) { - *text = toupper(*text); - text++; - } - - return ret; - } - - return text; -} - -char* BTStringMgr::upperLatin1(char* text, unsigned int max) const { - char* ret = text; - - while (*text) { - *text = toupper(*text); - text++; - } - - return ret; -} - -bool BTStringMgr::supportsUnicode() const { - return true; -} - -const bool BTStringMgr::isUtf8(const char *buf) const { - int i, n; - register unsigned char c; - bool gotone = false; - - #define F 0 /* character never appears in text */ - #define T 1 /* character appears in plain ASCII text */ - #define I 2 /* character appears in ISO-8859 text */ - #define X 3 /* character appears in non-ISO extended ASCII (Mac, IBM PC) */ - - static const unsigned char text_chars[256] = { - /* BEL BS HT LF FF CR */ - F, F, F, F, F, F, F, T, T, T, T, F, T, T, F, F, /* 0x0X */ - /* ESC */ - F, F, F, F, F, F, F, F, F, F, F, T, F, F, F, F, /* 0x1X */ - T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, /* 0x2X */ - T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, /* 0x3X */ - T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, /* 0x4X */ - T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, /* 0x5X */ - T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, /* 0x6X */ - T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, F, /* 0x7X */ - /* NEL */ - X, X, X, X, X, T, X, X, X, X, X, X, X, X, X, X, /* 0x8X */ - X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, /* 0x9X */ - I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, /* 0xaX */ - I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, /* 0xbX */ - I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, /* 0xcX */ - I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, /* 0xdX */ - I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, /* 0xeX */ - I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I /* 0xfX */ - }; - - /* *ulen = 0; */ - - for (i = 0; (c = buf[i]); i++) { - if ((c & 0x80) == 0) { /* 0xxxxxxx is plain ASCII */ - /* - * Even if the whole file is valid UTF-8 sequences, - * still reject it if it uses weird control characters. - */ - - if (text_chars[c] != T) - return false; - - } - else if ((c & 0x40) == 0) { /* 10xxxxxx never 1st byte */ - return false; - } - else { /* 11xxxxxx begins UTF-8 */ - int following; - - if ((c & 0x20) == 0) { /* 110xxxxx */ - following = 1; - } - else if ((c & 0x10) == 0) { /* 1110xxxx */ - following = 2; - } - else if ((c & 0x08) == 0) { /* 11110xxx */ - following = 3; - } - else if ((c & 0x04) == 0) { /* 111110xx */ - following = 4; - } - else if ((c & 0x02) == 0) { /* 1111110x */ - following = 5; - } - else - return false; - - for (n = 0; n < following; n++) { - i++; - - if (!(c = buf[i])) - goto done; - - if ((c & 0x80) == 0 || (c & 0x40)) - return false; - } - - gotone = true; - } - } - -done: - return gotone; /* don't claim it's UTF-8 if it's all 7-bit */ -} - -#undef F -#undef T -#undef I -#undef X diff --git a/bibletime/backend/btstringmgr.h b/bibletime/backend/btstringmgr.h deleted file mode 100644 index de5349d..0000000 --- a/bibletime/backend/btstringmgr.h +++ /dev/null @@ -1,57 +0,0 @@ -/********* -* -* This file is part of BibleTime's source code, http://www.bibletime.info/. -* -* Copyright 1999-2006 by the BibleTime developers. -* The BibleTime source code is licensed under the GNU General Public License version 2.0. -* -**********/ - - - -#ifndef BTSTRINGMGR_H -#define BTSTRINGMGR_H - -//Sword includes -#include <stringmgr.h> - -//Qt includes -#include <qstring.h> - -using namespace sword; - -/** Unicode string manager implementation. - * This is the StringManager implementation which works with QString. - * @author The BibleTime developers - */ - -class BTStringMgr : public StringMgr { - -public: - /** Converts the param to an upper case Utf8 string - * @param The text encoded in utf8 which should be turned into an upper case string - */ - virtual char *upperUTF8(char *text, unsigned int max = 0) const; - - /** Converts the param to an uppercase latin1 string - * @param The text encoded in latin1 which should be turned into an upper case string - */ - virtual char *upperLatin1(char *text, unsigned int max = 0) const; - -protected: - /** Enable Unicode support. - * Reimplementation to show unicode support. - */ - virtual bool supportsUnicode() const; - - /** CODE TAKEN FROM KDELIBS 3.2, which is licensed under the LGPL 2. - * - * This code was taken from KStringHandler, which is part of the KDE libraries. - * - * This function checks whether a string is utf8 or not. - * It was taken from kdelibs so we do not depend on KDE 3.2. - */ - const bool isUtf8(const char *buf) const; -}; - -#endif diff --git a/bibletime/backend/cbookdisplay.cpp b/bibletime/backend/cbookdisplay.cpp deleted file mode 100644 index 276c604..0000000 --- a/bibletime/backend/cbookdisplay.cpp +++ /dev/null @@ -1,144 +0,0 @@ -// -// C++ Implementation: cbookdisplay -// -// Description: -// -// -// Author: The BibleTime team <info@bibletime.info>, (C) 2004-2007 -// -// Copyright: See COPYING file that comes with this distribution -// -// - -//Backend -#include "cbookdisplay.h" -#include "cdisplayrendering.h" -#include "cswordbookmoduleinfo.h" -#include "cswordtreekey.h" - -//Util -#include "util/scoped_resource.h" - -namespace Rendering { - - - /** Returns the rendered text using the modules in the list and using the key parameter. The displayoptions and filter options are used, too. */ - const QString CBookDisplay::text( const ListCSwordModuleInfo& modules, const QString& keyName, const CSwordBackend::DisplayOptions displayOptions, const CSwordBackend::FilterOptions filterOptions ) { - CSwordBookModuleInfo* book = dynamic_cast<CSwordBookModuleInfo*>(modules.first()); - Q_ASSERT(book); - - CSwordBackend::DisplayOptions dOpts = displayOptions; - dOpts.lineBreaks = true; //books should render with blocks, not with inlined sections - - CDisplayRendering render(dOpts, filterOptions); - CDisplayRendering::KeyTree tree; - CDisplayRendering::KeyTreeItem::Settings itemSettings; - - // the number of levels which should be display together, 1 means display no entries together - int displayLevel = book->config( CSwordModuleInfo::DisplayLevel ).toInt(); - - util::scoped_ptr<CSwordTreeKey> key ( - dynamic_cast<CSwordTreeKey*>( CSwordKey::createInstance(book) ) - ); - key->key(keyName); //set the key to position we'd like to get - - const unsigned long offset = key->getOffset(); - - // standard of DisplayLevel, display nothing together - // if the current key is the root entry don't display anything together! - - if ((displayLevel <= 1) || (key->key().isEmpty() || (key->key() == "/") )) { - tree.append( new CDisplayRendering::KeyTreeItem( key->key(), modules, itemSettings ) ); - - const QString renderedText = render.renderKeyTree(tree); - key->setOffset( offset ); - return renderedText; - }; - - /** - * Check whether displaying displayLevel levels together is possible. - * For this count the childs and parents - * of the required position - */ - - int possibleLevels = 1; //we start with the default value of displayLevel, which means no entries together - - while( key->parent() && (key->key() != "/") && !key->key().isEmpty() ) {//add parents - ++possibleLevels; - }; - - // key->key(keyName); //set the key to the start position - - key->setOffset( offset ); - - while( key->firstChild( )) { //add childs - ++possibleLevels; - }; - - if (possibleLevels < displayLevel) { //too few levels available! - //display current level, we could also decide to display the available levels together - tree.append( new CDisplayRendering::KeyTreeItem( key->key(), modules, itemSettings ) ); - - const QString renderedText = render.renderKeyTree(tree); - key->setOffset( offset ); - return renderedText; - }; - - if ((displayLevel > 2) && (displayLevel == possibleLevels)) { //fix not to diplay the whole module - --displayLevel; - } - - // at this point we're sure that we can display the required levels toogether - // at the moment we're at the lowest level, so we only have to go up! - for (int currentLevel = 1; currentLevel < displayLevel; ++currentLevel) { //we start again with 1 == standard of displayLevel - - if ( !key->parent() ) { //something went wrong although we checked before! Be safe and return entry's text - tree.append( new CDisplayRendering::KeyTreeItem( key->key(), modules, itemSettings ) ); - - const QString renderedText = render.renderKeyTree(tree); - key->setOffset( offset ); - return renderedText; - }; - }; - - // no we can display all sub levels together! We checked before that this is possible! - itemSettings.highlight = (key->key() == keyName); - - tree.append( new CDisplayRendering::KeyTreeItem( key->key(), modules, itemSettings ) ); - - //const bool hasToplevelText = !key->strippedText().isEmpty(); - key->firstChild(); //go to the first sibling on the same level - - setupRenderTree(key.get(), &tree, keyName); - - const QString renderedText = render.renderKeyTree(tree); - - key->setOffset( offset ); //restore key - - return renderedText; - } - - void CBookDisplay::setupRenderTree(CSwordTreeKey * swordTree, CTextRendering::KeyTree * renderTree, const QString& highlightKey) { -// const QString key = swordTree->getFullName(); - const QString key = swordTree->key(); - const unsigned long offset = swordTree->getOffset(); - - CTextRendering::KeyTreeItem::Settings settings; - settings.highlight = (key == highlightKey); - - CTextRendering::KeyTreeItem* item = new CTextRendering::KeyTreeItem(key, swordTree->module(0), settings ); - renderTree->append( item ); - - if (swordTree->hasChildren()) { //print tree for the child items - swordTree->firstChild(); - setupRenderTree(swordTree, item->childList(), highlightKey); - swordTree->setOffset( offset ); //go back where we came from - } - - if (swordTree->nextSibling()) { //print tree for next entry on the same depth - setupRenderTree(swordTree, renderTree, highlightKey); - swordTree->setOffset( offset ); //return to the value we had at the beginning of this block! - } - } - -}; diff --git a/bibletime/backend/cbookdisplay.h b/bibletime/backend/cbookdisplay.h deleted file mode 100644 index 56fc2f2..0000000 --- a/bibletime/backend/cbookdisplay.h +++ /dev/null @@ -1,45 +0,0 @@ -// -// C++ Interface: cbookdisplay -// -// Description: -// -// -// Author: The BibleTime team <info@bibletime.info>, (C) 2004 -// -// Copyright: See COPYING file that comes with this distribution -// -// -#ifndef RENDERINGCBOOKDISPLAY_H -#define RENDERINGCBOOKDISPLAY_H - -#include "centrydisplay.h" - -class CSwordTreeKey; - -namespace Rendering { - - class CTextRendering::KeyTree; - - /** - * A CEntryDisplay implementation which works on tree-based GenBook modules - * of Sword. - * @short CEntryDisplay implementation for GenBook modules, - * @author The BibleTime team - */ - -class CBookDisplay : public CEntryDisplay { -public: // Public methods - virtual ~CBookDisplay() {} - - /** - * Returns the rendered text using the modules in the list and using the key parameter. - * The displayoptions and filter options are used, too. - */ - virtual const QString text( const ListCSwordModuleInfo& modules, const QString& key, const CSwordBackend::DisplayOptions displayOptions, const CSwordBackend::FilterOptions filterOptions); - -protected: - void setupRenderTree(CSwordTreeKey* swordTree, CTextRendering::KeyTree* renderTree, const QString& highlightKey); - }; -}; - -#endif diff --git a/bibletime/backend/cchapterdisplay.cpp b/bibletime/backend/cchapterdisplay.cpp deleted file mode 100644 index 02668e4..0000000 --- a/bibletime/backend/cchapterdisplay.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// -// C++ Implementation: cchapterdisplay -// -// Description: -// -// -// Author: The BibleTime team <info@bibletime.info>, (C) 2004 -// -// Copyright: See COPYING file that comes with this distribution -// -// - -//Backend -#include "cchapterdisplay.h" -#include "cdisplayrendering.h" -#include "cswordversekey.h" -#include "cswordbiblemoduleinfo.h" - - -namespace Rendering { - - const QString CChapterDisplay::text( const ListCSwordModuleInfo& modules, const QString& keyName, const CSwordBackend::DisplayOptions displayOptions, const CSwordBackend::FilterOptions filterOptions ) { - Q_ASSERT( modules.count() >= 1 ); - Q_ASSERT( !keyName.isEmpty() ); - - CSwordModuleInfo* module = modules.first(); - - if (modules.count() == 1) module->module()->setSkipConsecutiveLinks( true ); //skip empty, linked verses - - CTextRendering::KeyTreeItem::Settings settings; - settings.keyRenderingFace = - displayOptions.verseNumbers - ? CTextRendering::KeyTreeItem::Settings::SimpleKey - : CTextRendering::KeyTreeItem::Settings::NoKey; - - QString startKey = keyName; - QString endKey = startKey; - - //check whether there's an intro we have to include - Q_ASSERT((module->type() == CSwordModuleInfo::Bible)); - - if (module->type() == CSwordModuleInfo::Bible) { - ((VerseKey*)(module->module()->getKey()))->Headings(1); //HACK: enable headings for VerseKeys - - CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(module); - Q_ASSERT(bible); - - CSwordVerseKey k1(module); - k1.Headings(1); - k1.key(keyName); - - if (k1.Chapter() == 1) k1.Chapter(0); //Chapter 1, start with 0:0, otherwise X:0 - - k1.Verse(0); - - startKey = k1.key(); - - if (k1.Chapter() == 0) k1.Chapter(1); - k1.Verse(bible->verseCount(k1.book(), k1.Chapter())); - endKey = k1.key(); - } - - CDisplayRendering render(displayOptions, filterOptions); - return render.renderKeyRange( startKey, endKey, modules, keyName, settings ); - } - -}; diff --git a/bibletime/backend/cchapterdisplay.h b/bibletime/backend/cchapterdisplay.h deleted file mode 100644 index 891b16b..0000000 --- a/bibletime/backend/cchapterdisplay.h +++ /dev/null @@ -1,39 +0,0 @@ -// -// C++ Interface: cchapterdisplay -// -// Description: -// -// -// Author: The BibleTime team <info@bibletime.info>, (C) 2004 -// -// Copyright: See COPYING file that comes with this distribution -// -// -#ifndef RENDERINGCCHAPTERDISPLAY_H -#define RENDERINGCCHAPTERDISPLAY_H - -#include "centrydisplay.h" - -namespace Rendering { - -/** Chapter rendering. -* A CEntryDisplay implementation mde for Bibles to display whole chapters -* at once. -* @author The BibleTime team -*/ - -class CChapterDisplay : public CEntryDisplay { - -public: // Public methods - virtual ~CChapterDisplay() {} - - /** - * Returns the rendered text using the modules in the list and using the key parameter. - * The displayoptions and filter options are used, too. - */ - virtual const QString text( const ListCSwordModuleInfo& modules, const QString& key, const CSwordBackend::DisplayOptions displayOptions, const CSwordBackend::FilterOptions filterOptions); -}; - -}; - -#endif diff --git a/bibletime/backend/cdisplayrendering.cpp b/bibletime/backend/cdisplayrendering.cpp deleted file mode 100644 index 6b13114..0000000 --- a/bibletime/backend/cdisplayrendering.cpp +++ /dev/null @@ -1,163 +0,0 @@ -// -// C++ Implementation: cdisplayrendering -// -// Description: -// -// -// Author: The BibleTime team <info@bibletime.info>, (C) 2004 -// -// Copyright: See COPYING file that comes with this distribution -// -// - -//Backend includes -#include "cdisplayrendering.h" - -#include "cdisplaytemplatemgr.h" -#include "creferencemanager.h" -#include "cswordkey.h" -#include "cswordversekey.h" - -//Qt includes -#include <qstring.h> -#include <qregexp.h> - -namespace Rendering { - - CDisplayRendering::CDisplayRendering(CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions) -: CHTMLExportRendering(CHTMLExportRendering::Settings(true), displayOptions, filterOptions) {} - - const QString CDisplayRendering::entryLink( const KeyTreeItem& item, CSwordModuleInfo* module ) { - QString linkText; - - const bool isBible = module && (module->type() == CSwordModuleInfo::Bible); - CSwordVerseKey vk(module); //only valid for bible modules, i.e. isBible == true - vk.Headings(true); - - if (isBible) { - vk = item.key(); - } - - if (isBible && (vk.Verse() == 0)) { - return QString::null; //Warning: return already here - } - - switch (item.settings().keyRenderingFace) { - - case KeyTreeItem::Settings::NoKey: { - linkText = QString::null; - break; //no key is valid for all modules - } - - case KeyTreeItem::Settings::CompleteShort: { - if (isBible) { - linkText = QString::fromUtf8(vk.getShortText()); - break; - } - - //fall through for non-Bible modules - } - - case KeyTreeItem::Settings::CompleteLong: { - if (isBible) { - linkText = vk.key(); - break; - } - - //fall through for non-Bible modules - } - - case KeyTreeItem::Settings::SimpleKey: { - if (isBible) { - linkText = QString::number(vk.Verse()); - break; - } - - //fall through for non-Bible modules - } - - default: { //default behaviour to return the passed key - linkText = item.key(); - break; - } - } - - if (linkText.isEmpty()) { - return QString("<a name=\"").append(keyToHTMLAnchor(item.key())).append("\" />"); - } - else { - return QString("<a name=\"").append(keyToHTMLAnchor(item.key())).append("\" ") - .append("href=\"") - .append(CReferenceManager::encodeHyperlink( - module->name(), item.key(), CReferenceManager::typeFromModule(module->type())) - ) - .append("\">").append(linkText).append("</a>\n"); - } - - return QString::null; - } - - const QString CDisplayRendering::keyToHTMLAnchor(const QString& key) { - QString ret = key; - ret = ret.stripWhiteSpace().remove(QRegExp("[^A-Za-z0-9]+")); - ret = ret.remove(QRegExp("^\\d+|")); - - return ret; - } - - const QString CDisplayRendering::finishText( const QString& oldText, KeyTree& tree ) { - ListCSwordModuleInfo modules = tree.collectModules(); - - - //marking words is very slow, we have to find a better solution - - /* - //mark all words by spans - - QString text = oldText; - - QRegExp re("(\\b)(?=\\w)"); //word begin marker - int pos = text.find(re, 0); - - while (pos != -1) { //word begin found - //qWarning("found word at %i in %i", pos, text.length()); - int endPos = pos + 1; - if (!CToolClass::inHTMLTag(pos+1, text)) { //the re has a positive look ahead which matches one char before the word start - //qWarning("matched %s", text.mid(pos+1, 4).latin1()); - - //find end of word and put a marker around it - endPos = text.find(QRegExp("\\b|[,.:]"), pos+1); - if ((endPos != -1) && !CToolClass::inHTMLTag(endPos, text) && (endPos - pos >= 3)) { //reuire wordslonger than 3 chars - text.insert(endPos, "</span>"); - text.insert(pos, "<span class=\"word\">"); - - endPos += 26; - } - } - pos = text.find(re, endPos); - } - */ - const CLanguageMgr::Language* const lang = - (modules.count() >= 1) - ? modules.first()->language() - : CPointers::languageMgr()->defaultLanguage(); - - CDisplayTemplateMgr* tMgr = CPointers::displayTemplateManager(); - - Q_ASSERT(modules.count() >= 1); - - CDisplayTemplateMgr::Settings settings; - settings.modules = modules; - settings.langAbbrev = ((modules.count() == 1) && lang->isValid()) - ? lang->abbrev() - : QString::null; - settings.pageDirection = (modules.count() == 1) - ? ((modules.first()->textDirection() == CSwordModuleInfo::LeftToRight) ? "ltr" : "rtl") - : QString::null; - - return tMgr->fillTemplate(CBTConfig::get - (CBTConfig::displayStyle), oldText, settings); - - - } -} diff --git a/bibletime/backend/cdisplayrendering.h b/bibletime/backend/cdisplayrendering.h deleted file mode 100644 index b835ac6..0000000 --- a/bibletime/backend/cdisplayrendering.h +++ /dev/null @@ -1,40 +0,0 @@ -// -// C++ Interface: cdisplayrendering -// -// Description: -// -// -// Author: The BibleTime team <info@bibletime.info>, (C) 2004 -// -// Copyright: See COPYING file that comes with this distribution -// -// -#ifndef RENDERINGCDISPLAYRENDERING_H -#define RENDERINGCDISPLAYRENDERING_H - -#include "chtmlexportrendering.h" - -namespace Rendering { - -/** HTML rendering for the text display widgets. - * @short Rendering for the html display widget. - * @author The BibleTime team - */ - -class CDisplayRendering : public CHTMLExportRendering { -public: - static const QString keyToHTMLAnchor(const QString& key); - - CDisplayRendering( - CSwordBackend::DisplayOptions displayOptions = CBTConfig::getDisplayOptionDefaults(), - CSwordBackend::FilterOptions filterOptions = CBTConfig::getFilterOptionDefaults() - ); - -protected: - virtual const QString entryLink( const KeyTreeItem& item, CSwordModuleInfo* const module ); - virtual const QString finishText( const QString&, KeyTree& tree ); -}; - -} - -#endif diff --git a/bibletime/backend/cdisplaytemplatemgr.cpp b/bibletime/backend/cdisplaytemplatemgr.cpp deleted file mode 100644 index a0f5222..0000000 --- a/bibletime/backend/cdisplaytemplatemgr.cpp +++ /dev/null @@ -1,191 +0,0 @@ -// -// C++ Implementation: cdisplaytemplatemgr -// -// Description: -// -// -// Author: The BibleTime team <info@bibletime.info>, (C) 2004 -// -// Copyright: See COPYING file that comes with this distribution -// -// - -//BibleTime includes -#include "cdisplaytemplatemgr.h" -#include "cswordmoduleinfo.h" -#include "clanguagemgr.h" - -#include "frontend/cbtconfig.h" - -#include "util/cpointers.h" - -#include "config.h" - -//Qt includes -#include <qstringlist.h> -#include <qfile.h> -#include <qfileinfo.h> - -//KDE includes -#include <klocale.h> -#include <kstandarddirs.h> - -#include <iostream> - -CDisplayTemplateMgr::CDisplayTemplateMgr() { - init(); - loadUserTemplates(); -} - -CDisplayTemplateMgr::~CDisplayTemplateMgr() {} - - -/*! - \fn CDisplayTemplateMgr::fillTemplate( const QString& name, const QString& title, const QString& content ) - */ -const QString CDisplayTemplateMgr::fillTemplate( const QString& name, const QString& content, Settings& settings ) { - const QString templateName = m_templateMap.contains(name) ? name : defaultTemplate(); - - QString displayTypeString; - - if (!settings.pageCSS_ID.isEmpty()) { - displayTypeString = settings.pageCSS_ID; - } - else { - if (settings.modules.count()) { - switch (settings.modules.first()->type()) { - - case CSwordModuleInfo::Bible: - displayTypeString = "bible"; - break; - - case CSwordModuleInfo::GenericBook: - displayTypeString = "book"; - break; - - case CSwordModuleInfo::Commentary: - - case CSwordModuleInfo::Lexicon: - - default: - displayTypeString = "singleentry"; - break; - }; - } - else { //use bible as default type if no modules are set - displayTypeString = "bible"; - }; - } - - QString newContent = content; - const int moduleCount = settings.modules.count(); - - if (moduleCount >= 2) { - //create header for the modules - QString header; - - ListCSwordModuleInfo::iterator end_it = settings.modules.end(); - - for (ListCSwordModuleInfo::iterator it(settings.modules.begin()); it != end_it; ++it) { - header.append("<th style=\"width:") - .append(QString::number(int( 100.0 / (float)moduleCount ))) - .append("%;\">") - .append((*it)->name()) - .append("</th>"); - } - - newContent.setLatin1("<table><tr>") - .append(header) - .append("</tr>") - .append(content) - .append("</table>"); - } - - QString langCSS; - CLanguageMgr::LangMap langMap = CPointers::languageMgr()->availableLanguages(); - - for ( CLanguageMgr::LangMapIterator it( langMap ); it.current(); ++it ) { - const CLanguageMgr::Language* lang = it.current(); - - - //if (lang->isValid() && CBTConfig::get(lang).first) { - if (!lang->abbrev().isEmpty() && CBTConfig::get(lang).first) { - const QFont f = CBTConfig::get(lang).second; - - //don't use important, because it would reset the title formatting, etc. to the setup font - QString css("{ "); - css.append("font-family:").append(f.family())/*.append(" !important")*/; - css.append("; font-size:").append(QString::number(f.pointSize())).append("pt /*!important*/"); - css.append("; font-weight:").append(f.bold() ? "bold" : "normal /*!important*/"); - css.append("; font-style:").append(f.italic() ? "italic" : "normal /*!important*/"); - css.append("; }\n"); - - langCSS += - QString("\n*[lang=%1] %2") - .arg(lang->abbrev()) - .arg(css); - } - } - - //at first append the font standard settings for all languages without configured font - CLanguageMgr::LangMapIterator it( langMap ); - - const CLanguageMgr::Language* lang = it.current(); - - if (lang && !lang->abbrev().isEmpty()/*&& lang->isValid()*/) { - const QFont standardFont = CBTConfig::getDefault(lang); //we just need a dummy lang param - langCSS.prepend( - QString("\n#content {font-family:%1; font-size:%2pt; font-weight:%3; font-style: %4;}\n") - .arg(standardFont.family()) - .arg(standardFont.pointSize()) - .arg(standardFont.bold() ? "bold" : "normal") - .arg(standardFont.italic() ? "italic" : "normal") - ); - } - -// qWarning("Outputing unformated text"); - const QString t = QString(m_templateMap[ templateName ]) //don't change the map's content directly, use a copy - .replace("#TITLE#", settings.title) - .replace("#LANG_ABBREV#", settings.langAbbrev.isEmpty() ? QString("en") : settings.langAbbrev) - .replace("#DISPLAYTYPE#", displayTypeString) - .replace("#LANG_CSS#", langCSS) - .replace("#PAGE_DIRECTION#", settings.pageDirection) - .replace("#CONTENT#", newContent); - //printf("%s\n\n", t.latin1()); - - return t; -/* QString(m_templateMap[ templateName ]) //don't change the map's content directly, use a copy - .replace("#TITLE#", settings.title) - .replace("#LANG_ABBREV#", settings.langAbbrev.isEmpty() ? QString("en") : settings.langAbbrev) - .replace("#DISPLAYTYPE#", displayTypeString) - .replace("#LANG_CSS#", langCSS) - .replace("#PAGE_DIRECTION#", settings.pageDirection) - .replace("#CONTENT#", newContent);*/ -} - - -/*! - \fn CDisplayTemplateMgr::loadUserTemplates - */ -void CDisplayTemplateMgr::loadUserTemplates() { - qDebug("Loading user templates"); - QStringList files = KGlobal::dirs()->findAllResources("BT_DisplayTemplates"); - - for ( QStringList::iterator it( files.begin() ); it != files.end(); ++it) { - qDebug("Found user template %s", (*it).latin1()); - - QFile f( *it ); - Q_ASSERT( f.exists() ); - - if (f.open( IO_ReadOnly )) { - QString fileContent = QTextStream( &f ).read(); - - if (!fileContent.isEmpty()) { - m_templateMap[ QFileInfo(*it).fileName() + QString(" ") + i18n("(user template)")] = fileContent; - } - } - } -} - -//Include the HTML templates which were put into a cpp file by a Perl script -#include "../display-templates/template-init.cpp" diff --git a/bibletime/backend/cdisplaytemplatemgr.h b/bibletime/backend/cdisplaytemplatemgr.h deleted file mode 100644 index 764fb69..0000000 --- a/bibletime/backend/cdisplaytemplatemgr.h +++ /dev/null @@ -1,100 +0,0 @@ -// -// C++ Interface: cdisplaytemplatemgr -// -// Description: -// -// -// Author: The BibleTime team <info@bibletime.info>, (C) 2004 -// -// Copyright: See COPYING file that comes with this distribution -// -// -#ifndef CDISPLAYTEMPLATEMGR_H -#define CDISPLAYTEMPLATEMGR_H - -//BibleTime include -#include "cswordmoduleinfo.h" - -//Qt includes -#include <qmap.h> -#include <qstring.h> -#include <qstringlist.h> - -//KDE includes -#include <klocale.h> - -/** - * Manages the display templates used in the filters and display classes. - * @author The BibleTime team -*/ - -class CDisplayTemplateMgr { - -public: - /** Settings which are used to fill the content into the template. - */ - - struct Settings { - /** Constructor. Constructs the new settings object. The default values are empty. - */ - Settings() { - title = QString::null; - langAbbrev = QString::null; - pageCSS_ID = QString::null; - pageDirection = QString("ltr"); - }; - - ListCSwordModuleInfo modules; /**< the list of modules */ - QString title; /**< the title which is used for the new processed HTML page */ - QString langAbbrev; /**< the language for the HTML page. */ - QString pageDirection; /**< the language for the HTML page. */ - QString pageCSS_ID; /**< the CSS ID which is used in the content part of the page */ - }; - - /** Available templates. - * @return The list of templates, which are available. - */ - inline const QStringList availableTemplates(); - /** Fill template. Fill rendered content into the template given by the name. - * @param name The name of the template - * @param content The content which should be filled into the template - * @param settings The settings which are used to process the templating process - * @return The full HTML template HTML code including the CSS data. - */ - const QString fillTemplate( const QString& name, const QString& content, Settings& settings); - /** Default template. - * @return The i18n'ed name of the default template - */ - inline static const QString defaultTemplate(); - -protected: - - friend class CPointers; - /** Display template manager constructor. Protected to just allow CPointers to create objects. - */ - CDisplayTemplateMgr(); - /** Destructor. - */ - ~CDisplayTemplateMgr(); - - void loadUserTemplates(); - -private: - void init(); - QMap<QString, QString> m_templateMap; -}; - -inline const QString CDisplayTemplateMgr::defaultTemplate() { - return i18n("Default"); -} - -/** - * CDisplayTemplateMgr::availableTemplates() - */ -inline const QStringList CDisplayTemplateMgr::availableTemplates() { - return m_templateMap.keys(); -} - - - -#endif diff --git a/bibletime/backend/centrydisplay.cpp b/bibletime/backend/centrydisplay.cpp deleted file mode 100644 index 8fdcace..0000000 --- a/bibletime/backend/centrydisplay.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/********* -* -* This file is part of BibleTime's source code, http://www.bibletime.info/. -* -* Copyright 1999-2006 by the BibleTime developers. -* The BibleTime source code is licensed under the GNU General Public License version 2.0. -* -**********/ - - - -//BibleTime includes -#include "centrydisplay.h" - -#include "cswordkey.h" -#include "cswordversekey.h" -#include "cswordbookmoduleinfo.h" -#include "creferencemanager.h" -#include "cdisplaytemplatemgr.h" -#include "cdisplayrendering.h" - -#include "frontend/cbtconfig.h" - -#include "util/scoped_resource.h" - -//Qt includes -#include <qapplication.h> -#include <qregexp.h> - -using namespace Rendering; - -/** Returns the rendered text using the modules in the list and using the key parameter. - * The displayoptions and filter options are used, too. - */ -const QString CEntryDisplay::text( const ListCSwordModuleInfo& modules, const QString& keyName, const CSwordBackend::DisplayOptions displayOptions, const CSwordBackend::FilterOptions filterOptions ) { - CDisplayRendering render(displayOptions, filterOptions); - - //no highlighted key and no extra key link in the text - CTextRendering::KeyTreeItem::Settings normal_settings(false, CTextRendering::KeyTreeItem::Settings::CompleteShort); - CSwordModuleInfo* module = modules.first(); - QString result; - - //in Bibles and Commentaries we need to check if 0:0 and X:0 contain something - if (module->type() == CSwordModuleInfo::Bible || module->type() == CSwordModuleInfo::Commentary) { - ((VerseKey*)(module->module()->getKey()))->Headings(1); //HACK: enable headings for VerseKeys - - CSwordVerseKey k1(module); - k1.Headings(1); - k1.key(keyName); - - // don't print the key - CTextRendering::KeyTreeItem::Settings preverse_settings(false, CTextRendering::KeyTreeItem::Settings::NoKey); - - if (k1.Verse() == 1){ //X:1, prepend X:0 - if (k1.Chapter() == 1){ //1:1, also prepend 0:0 before that - k1.Chapter(0); - k1.Verse(0); - if ( k1.rawText().length() > 0 ) result.append( render.renderSingleKey(k1.key(), modules, preverse_settings ) ); - k1.Chapter(1); - } - k1.Verse(0); - if ( k1.rawText().length() > 0 ) result.append( render.renderSingleKey(k1.key(), modules, preverse_settings ) ); - } - } - return result.append( render.renderSingleKey(keyName, modules, normal_settings) ); -} diff --git a/bibletime/backend/centrydisplay.h b/bibletime/backend/centrydisplay.h deleted file mode 100644 index 141ed1d..0000000 --- a/bibletime/backend/centrydisplay.h +++ /dev/null @@ -1,53 +0,0 @@ -/********* -* -* This file is part of BibleTime's source code, http://www.bibletime.info/. -* -* Copyright 1999-2006 by the BibleTime developers. -* The BibleTime source code is licensed under the GNU General Public License version 2.0. -* -**********/ - - - -#ifndef CENTRYDISPLAY_H -#define CENTRYDISPLAY_H - -//BibleTime includes -#include "ctextrendering.h" -#include "cswordmoduleinfo.h" -#include "cswordbackend.h" - -#include "util/cpointers.h" - -//Sword includes -#include <swdisp.h> - -//Qt includes -#include <qstring.h> - -class CSwordModuleInfo; - -namespace Rendering { - -/** -* The reimplementation of SWDisplay to fit our needs. -* @short Display implementation -* @author The BibleTime team -*/ - -class CEntryDisplay : public sword::SWDisplay, public CPointers { - -public: - virtual ~CEntryDisplay() {} - - /** - * Returns the rendered text using the modules in the list and using the key parameter. - * The displayoptions and filter options are used, too. - */ - virtual const QString text( const ListCSwordModuleInfo& modules, const QString& key, const CSwordBackend::DisplayOptions displayOptions, const CSwordBackend::FilterOptions filterOptions); -}; - - -} - -#endif diff --git a/bibletime/backend/chtmlexportrendering.cpp b/bibletime/backend/chtmlexportrendering.cpp deleted file mode 100644 index a32d57c..0000000 --- a/bibletime/backend/chtmlexportrendering.cpp +++ /dev/null @@ -1,236 +0,0 @@ -// -// C++ Implementation: chtmlexportrendering -// -// Description: -// -// -// Author: The BibleTime team <info@bibletime.info>, (C) 2004 -// -// Copyright: See COPYING file that comes with this distribution -// -// - -//Backend -#include "chtmlexportrendering.h" - -#include "cdisplaytemplatemgr.h" -#include "clanguagemgr.h" -#include "cswordkey.h" -#include "cswordversekey.h" -#include "cswordmoduleinfo.h" - -//Util -#include "util/cpointers.h" -#include "util/scoped_resource.h" - -//KDE includes -#include <klocale.h> - -namespace Rendering { - - CHTMLExportRendering::CHTMLExportRendering(const CHTMLExportRendering::Settings& settings, CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions) -: m_displayOptions(displayOptions), - m_filterOptions(filterOptions), - m_settings(settings) {} - - CHTMLExportRendering::~CHTMLExportRendering() {} - - const QString CHTMLExportRendering::renderEntry( const KeyTreeItem& i, CSwordKey* k) { - // qDebug("CHTMLExportRendering::renderEntry"); - - if (i.hasAlternativeContent()) { - QString ret; - ret.setLatin1(i.settings().highlight ? "<div class=\"currententry\">" : "<div class=\"entry\">"); - ret.append(i.getAlternativeContent()); - - // Q_ASSERT(i.hasChildItems()); - - if (i.hasChildItems()) { - KeyTree const * tree = i.childList(); - - const ListCSwordModuleInfo& modules( tree->collectModules() ); - - if (modules.count() == 1) { //insert the direction into the sorrounding div - ret.insert( 5, QString("dir=\"%1\" ").arg((modules.first()->textDirection() == CSwordModuleInfo::LeftToRight) ? "ltr" : "rtl" )); - } - - for ( KeyTreeItem* c = tree->first(); c; c = tree->next() ) { - ret.append( renderEntry( *c ) ); - } - } - - ret.append("</div>"); - return ret; //WARNING: Return already here! - } - - - const ListCSwordModuleInfo& modules( i.modules() ); - - Q_ASSERT(modules.count() >= 1); - - util::scoped_ptr<CSwordKey> scoped_key( !k ? CSwordKey::createInstance(modules.first()) : 0 ); - - CSwordKey* key = k ? k : scoped_key; - - Q_ASSERT(key); - - CSwordVerseKey* myVK = dynamic_cast<CSwordVerseKey*>(key); - - if ( myVK ) { - myVK->Headings(1); - } - - QString renderedText( (modules.count() > 1) ? "<tr>" : "" ); - - if (modules.count() == 0) { - return QString(""); //no module present for rendering - } - - // Only insert the table stuff if we are displaying parallel. - // Otherwise, strip out he table stuff -> the whole chapter will be rendered in one cell! - - //declarations out of the loop for optimization - QString entry; - - QString keyText; - - bool isRTL; - - //taken out of the loop for optimization - QString preverseHeading; - - QString langAttr; - - ListCSwordModuleInfo::const_iterator end_modItr = modules.end(); - - for (ListCSwordModuleInfo::const_iterator mod_Itr(modules.begin()); mod_Itr != end_modItr; ++mod_Itr) { - key->module(*mod_Itr); - key->key( i.key() ); - - keyText = key->key(); - isRTL = ((*mod_Itr)->textDirection() == CSwordModuleInfo::RightToLeft); - entry = QString::null; - - if ((*mod_Itr)->language()->isValid()) { - langAttr.setLatin1("xml:lang=\"") - .append((*mod_Itr)->language()->abbrev()) - .append("\" lang=\"") - .append((*mod_Itr)->language()->abbrev()) - .append("\""); - } - else { - langAttr.setLatin1("xml:lang=\"") - .append((*mod_Itr)->module()->Lang()) - .append("\" lang=\"") - .append((*mod_Itr)->module()->Lang()) - .append("\""); - } - - const QString key_renderedText = key->renderedText(); - - // qWarning(key_renderedText.latin1()); - - if (m_filterOptions.headings) { - AttributeValue::const_iterator it = - (*mod_Itr)->module()->getEntryAttributes()["Heading"]["Preverse"].begin(); - const AttributeValue::const_iterator end = - (*mod_Itr)->module()->getEntryAttributes()["Heading"]["Preverse"].end(); - - for (; it != end; ++it) { - preverseHeading = QString::fromUtf8(it->second.c_str()); - - //TODO: Take care of the heading type! - - if (!preverseHeading.isEmpty()) { - entry.append("<div ") - .append(langAttr) - .append(" class=\"sectiontitle\">") - .append(preverseHeading) - .append("</div>"); - } - } - } - - entry.append(m_displayOptions.lineBreaks ? "<div " : "<span "); - - if (modules.count() == 1) { //insert only the class if we're not in a td - entry.append( i.settings().highlight ? "class=\"currententry\" " : "class=\"entry\" " ); - } - - entry.append(langAttr).append(isRTL ? " dir=\"rtl\"" : " dir=\"ltr\"").append(">"); - - //keys should normally be left-to-right, but this doesn't apply in all cases - entry.append("<span class=\"entryname\" dir=\"ltr\">").append(entryLink(i, *mod_Itr)).append("</span>"); - - if (m_settings.addText) { - //entry.append( QString::fromLatin1("<span %1>%2</span>").arg(langAttr).arg(key_renderedText) ); - entry.append( key_renderedText ); - } - - if (i.hasChildItems()) { - KeyTree const * tree = i.childList(); - - for (KeyTreeItem* c = tree->first(); c; c = tree->next()) { - entry.append( renderEntry(*c) ); - } - } - - entry.append(m_displayOptions.lineBreaks ? "</div>\n" : "</span>\n"); - - if (modules.count() == 1) { - renderedText.append( entry ); - } - else { - renderedText.append("<td class=\"") - .append(i.settings().highlight ? "currententry" : "entry") - .append("\" ") - .append(langAttr) - .append(" dir=\"") - .append(isRTL ? "rtl" : "ltr") - .append("\">") - .append(entry) - .append("</td>\n"); - } - } - - if (modules.count() > 1) { - renderedText.append("</tr>\n"); - } - - // qDebug("CHTMLExportRendering: %s", renderedText.latin1()); - return renderedText; - } - - void CHTMLExportRendering::initRendering() { - CPointers::backend()->setDisplayOptions( m_displayOptions ); - CPointers::backend()->setFilterOptions( m_filterOptions ); - } - - const QString CHTMLExportRendering::finishText( const QString& text, KeyTree& tree ) { - ListCSwordModuleInfo modules = tree.collectModules(); - - const CLanguageMgr::Language* const lang = modules.first()->language(); - - CDisplayTemplateMgr* tMgr = CPointers::displayTemplateManager(); - CDisplayTemplateMgr::Settings settings; - settings.modules = modules; - settings.langAbbrev = ((modules.count() == 1) && lang->isValid()) - ? lang->abbrev() - : "unknown"; - settings.pageDirection = (modules.count() == 1) - ? ((modules.first()->textDirection() == CSwordModuleInfo::LeftToRight) ? "ltr" : "rtl") - : QString::null; - - return tMgr->fillTemplate(i18n("Export"), text, settings); - } - - /*! - \fn CHTMLExportRendering::entryLink( KeyTreeItem& item ) - */ - const QString CHTMLExportRendering::entryLink( const KeyTreeItem& item, CSwordModuleInfo* ) { - return item.key(); - } - -} - -; //end of namespace "Rendering" diff --git a/bibletime/backend/chtmlexportrendering.h b/bibletime/backend/chtmlexportrendering.h deleted file mode 100644 index 0526df9..0000000 --- a/bibletime/backend/chtmlexportrendering.h +++ /dev/null @@ -1,60 +0,0 @@ -// -// C++ Interface: chtmlexportrendering -// -// Description: -// -// -// Author: The BibleTime team <info@bibletime.info>, (C) 2004 -// -// Copyright: See COPYING file that comes with this distribution -// -// -#ifndef RENDERINGCHTMLEXPORTRENDERING_H -#define RENDERINGCHTMLEXPORTRENDERING_H - -#include "cswordbackend.h" -#include "ctextrendering.h" - -#include "frontend/cbtconfig.h" - -namespace Rendering { - - /** - * This CTextRenerding implementation - * creates HTML specially made for export as HTML files. - * @short HTML rendering for export. - * @author The BibleTime team - */ - -class CHTMLExportRendering : public CTextRendering { - -public: - struct Settings { - Settings(const bool text = true) { - addText = text; - }; - - bool addText; - }; - - CHTMLExportRendering( - const Settings& settings, - CSwordBackend::DisplayOptions displayOptions = CBTConfig::getDisplayOptionDefaults(), - CSwordBackend::FilterOptions filterOptions = CBTConfig::getFilterOptionDefaults() - ); - virtual ~CHTMLExportRendering(); - -protected: - virtual const QString renderEntry( const KeyTreeItem&, CSwordKey* = 0 ); - virtual const QString finishText( const QString&, KeyTree& tree ); - virtual const QString entryLink( const KeyTreeItem& item, CSwordModuleInfo* module ); - virtual void initRendering(); - - CSwordBackend::DisplayOptions m_displayOptions; - CSwordBackend::FilterOptions m_filterOptions; - Settings m_settings; -}; - -} - -#endif diff --git a/bibletime/backend/clanguagemgr.cpp b/bibletime/backend/clanguagemgr.cpp deleted file mode 100644 index ef05b3e..0000000 --- a/bibletime/backend/clanguagemgr.cpp +++ /dev/null @@ -1,499 +0,0 @@ -/********* -* -* This file is part of BibleTime's source code, http://www.bibletime.info/. -* -* Copyright 1999-2006 by the BibleTime developers. -* The BibleTime source code is licensed under the GNU General Public License version 2.0. -* -**********/ - - - -#include "clanguagemgr.h" - -#include "cswordmoduleinfo.h" -#include "cswordbackend.h" - -#include "util/cpointers.h" - - -//Qt includes -#include <qptrlist.h> - -//KDE includes -#include <klocale.h> - -//initialize static language list -CLanguageMgr::LanguageList CLanguageMgr::m_langList; -CLanguageMgr::LanguageList CLanguageMgr::m_cleanupLangPtrs; - -CLanguageMgr::Language::Language() : m_altAbbrevs(0) { - m_abbrev = QString::null; - m_englishName = QString::null; - m_translatedName = QString::null; -}; - -CLanguageMgr::Language::Language(const Language& l) { - m_abbrev = l.m_abbrev; - m_englishName = l.m_englishName; - m_translatedName = l.m_translatedName; - - if (l.m_altAbbrevs) { //copy alternative abbrevs in a new list - m_altAbbrevs = new QStringList(*l.m_altAbbrevs); - //*m_altAbbrevs = *l.m_altAbbrevs; - } - else { - m_altAbbrevs = 0; - } -} - -CLanguageMgr::Language::Language( const QString& abbrev, const QString& name, const QString& translatedName, const QStringList& altAbbrevs ) : m_altAbbrevs(0) { - m_abbrev = abbrev; - m_englishName = name; - m_translatedName = translatedName; - - if (altAbbrevs.count() > 0) { - m_altAbbrevs = new QStringList(); - *m_altAbbrevs = altAbbrevs; - } -}; - -CLanguageMgr::Language::~Language() { - delete m_altAbbrevs; -}; - - -/****************************************************/ -/******************** CLanguageMgr ******************/ -/****************************************************/ -CLanguageMgr::CLanguageMgr() : m_langMap(0) { - m_availableModulesCache.moduleCount = 0; - - init(); -} - -CLanguageMgr::~CLanguageMgr() { - m_cleanupLangPtrs.setAutoDelete(true); - m_cleanupLangPtrs.clear(); - - m_langList.setAutoDelete(true); - m_langList.clear(); -} - -const CLanguageMgr::LangMap& CLanguageMgr::availableLanguages() { - ListCSwordModuleInfo mods = CPointers::backend()->moduleList(); - - if ( m_availableModulesCache.moduleCount != mods.count() ) { //we have to refill the cached map - m_availableModulesCache.availableLanguages.clear(); - m_availableModulesCache.moduleCount = mods.count(); - - //collect the languages abbrevs of all modules - QStrList abbrevs; - char *abbrev; - - ListCSwordModuleInfo::iterator end_it = mods.end(); - - for (ListCSwordModuleInfo::iterator it(mods.begin()); it != end_it; ++it) { - // for (CSwordModuleInfo* m = mods.first(); m; m = mods.next()) { - abbrev = (*it)->module()->Lang(); - - if (abbrev && !abbrevs.contains(abbrev)) { - abbrevs.append( abbrev ); - } - }; - - //now create a map of available langs - for ( abbrev = abbrevs.first(); abbrev; abbrev = abbrevs.next() ) { - const Language* const lang = languageForAbbrev(abbrev); - - if (lang->isValid()) { - m_availableModulesCache.availableLanguages.insert( abbrev, lang ); - } - else { //invalid lang used by a modules, create a new language using the abbrev - Language* newLang = new Language(abbrev, abbrev, abbrev); - m_cleanupLangPtrs.append(newLang); - - m_availableModulesCache.availableLanguages.insert( abbrev, newLang ); - } - }; - } - - return m_availableModulesCache.availableLanguages; -}; - -const CLanguageMgr::Language* const CLanguageMgr::languageForAbbrev( const QString& abbrev ) const { - Language* lang = m_langMap.find(abbrev); - - if (lang) { - return lang; - } - - //try to search in the alternative abbrevs - //const LangMapIterator end = m_langMap.constEnd(); - for ( LangMapIterator it( m_langMap ); it.current(); ++it ) { - if (it.current()->alternativeAbbrevs() && it.current()->alternativeAbbrevs()->contains(abbrev)) { - return it.current(); - } - } - - // Invalid lang used by a modules, create a new language using the abbrev - Language* newLang = new Language(abbrev, abbrev, abbrev); //return a language which holds the valid abbrev - m_cleanupLangPtrs.append(newLang); - - return newLang; -}; - -const CLanguageMgr::Language* const CLanguageMgr::languageForName( const QString& name ) const { - for ( LangMapIterator it( m_langMap ); it.current(); ++it ) { - if (it.current()->name() == name) { - return it.current(); - } - } - - return &m_defaultLanguage;//invalid language -}; - -const CLanguageMgr::Language* const CLanguageMgr::languageForTranslatedName( const QString& name ) const { - for ( LangMapIterator it( m_langMap ); it.current(); ++it ) { - if (it.current()->translatedName() == name) { - return it.current(); - } - } - - return &m_defaultLanguage; //invalid language -}; - -void CLanguageMgr::init() { - //if we've already inserted all items we do not proceed - - if (m_langMap.count() > 0) { - return; - } - - /* - * Chris explained in an eMail how language codes are build: - - Preference order for locale codes are: - - ISO 639-1 - ISO 639-2 - Ethnologue (http://www.ethnologue.org/) - - We intend to always follow OSIS locale conventions, which state that - Ethnologue codes will be encoded in the format x-E-??? where ??? - represents the 3-letter Ethnologue code in capital letters (though - capitalization really doesn't matter here). - - Some older modules maintain a former format for Ethnolgoue codes of - xx-???, including the AleWiesler module. - - --Chris - - */ - - // m_langList.append( new Language("aa" , "Afar" , i18n("Afar")) ); - // m_langList.append( new Language("ab" , "Abkhazian" , i18n("Abkhazian")) ); - // m_langList.append( new Language("ae" , "Avestan" , i18n("Avestan")) ); - m_langList.append( new Language("af" , "Afrikaans" , i18n("Afrikaans")) ); - - // m_langList.append( new Language("am" , "Amharic" , i18n("Amharic")) ); - m_langList.append( new Language("ang", "English, Old (ca.450-1100)", i18n("English, Old (ca.450-1100)")) ); - - m_langList.append( new Language("ar" , "Arabic" , i18n("Arabic")) ); - - // m_langList.append( new Language("as" , "Assamese" , i18n("Assamese")) ); - m_langList.append( new Language("az" , "Azerbaijani" , i18n("Azerbaijani")) ); - - // m_langList.append( new Language("ba" , "Bashkir" , i18n("Bashkir")) ); - m_langList.append( new Language("be" , "Belarusian" , i18n("Belarusian")) ); - - m_langList.append( new Language("bg" , "Bulgarian" , i18n("Bulgarian")) ); - - // m_langList.append( new Language("bh" , "Bihari" , i18n("Bihari")) ); - // m_langList.append( new Language("bi" , "Bislama" , i18n("Bislama")) ); - // m_langList.append( new Language("bn" , "Bengali" , i18n("Bengali")) ); - // m_langList.append( new Language("bo" , "Tibetan" , i18n("Tibetan")) ); - m_langList.append( new Language("br" , "Breton" , i18n("Breton")) ); - - m_langList.append( new Language("bs" , "Bosnian" , i18n("Bosnian")) ); - - m_langList.append( new Language("ca" , "Catalan" , i18n("Catalan")) ); - - // m_langList.append( new Language("ce" , "Chechen" , i18n("Chechen")) ); - m_langList.append( new Language("ceb" , "Cebuano" , i18n("Cebuano")) ); - - m_langList.append( new Language("ch" , "Chamorro" , i18n("Chamorro")) ); - - // m_langList.append( new Language("co" , "Corsican" , i18n("Corsican")) ); - m_langList.append( new Language("cop" , "Coptic" , i18n("Coptic")) ); - - m_langList.append( new Language("cs" , "Czech" , i18n("Czech")) ); - - m_langList.append( new Language("cu" , "Church Slavic" , i18n("Church Slavic")) ); - - // m_langList.append( new Language("cv" , "Chuvash" , i18n("Chuvash")) ); - m_langList.append( new Language("cy" , "Welsh" , i18n("Welsh")) ); - - m_langList.append( new Language("da" , "Danish" , i18n("Danish")) ); - - m_langList.append( new Language("de" , "German" , i18n("German")) ); - - // m_langList.append( new Language("dz" , "Dzongkha" , i18n("Dzongkha")) ); - - m_langList.append( new Language("el" , "Greek, Modern (1453-)" , i18n("Greek, Modern (1453-)"), makeStringList("gre;ell")) ); - - m_langList.append( new Language("en" , "English" , i18n("English")) ); - - m_langList.append( new Language("en_US","American English" , i18n("American English")) ); - - m_langList.append( new Language("enm" , "English, Middle (1100-1500)", i18n("English, Middle (1100-1500)")) ); - - m_langList.append( new Language("eo" , "Esperanto" , i18n("Esperanto")) ); - - m_langList.append( new Language("es" , "Spanish" , i18n("Spanish")) ); - - m_langList.append( new Language("et" , "Estonian" , i18n("Estonian")) ); - - m_langList.append( new Language("eu" , "Basque" , i18n("Basque")) ); - - // m_langList.append( new Language("fa" , "Persian" , i18n("Persian")) ); - m_langList.append( new Language("fi" , "Finnish" , i18n("Finnish")) ); - - // m_langList.append( new Language("fj" , "Fijian" , i18n("Fijian")) ); - // m_langList.append( new Language("fo" , "Faroese" , i18n("Faroese")) ); - m_langList.append( new Language("fr" , "French" , i18n("French")) ); - - m_langList.append( new Language("fy" , "Frisian" , i18n("Frisian")) ); - - m_langList.append( new Language("ga" , "Irish" , i18n("Irish")) ); - - m_langList.append( new Language("gd" , "Gaelic (Scots)", i18n("Gaelic (Scots)")) ); - - // m_langList.append( new Language("gl" , "Gallegan" , i18n("Gallegan")) ); - // m_langList.append( new Language("gn" , "Guarani" , i18n("Guarani")) ); - // m_langList.append( new Language("gn" , "Gujarati" , i18n("Gujarati")) ); - m_langList.append( new Language("got" , "Gothic" , i18n("Gothic")) ); - - m_langList.append( new Language("gv" , "Manx" , i18n("Manx")) ); - - m_langList.append( new Language("grc" , "Greek, Ancient (to 1453)" , i18n("Greek, Ancient (to 1453)")) ); - - m_langList.append( new Language("he" , "Hebrew" , i18n("Hebrew")) ); - - m_langList.append( new Language("hau" , "Hausa" , i18n("Hausa")) ); - - m_langList.append( new Language("haw" , "Hawaiian" , i18n("Hawaiian")) ); - - // m_langList.append( new Language("hi" , "Hindi" , i18n("Hindi")) ); - // m_langList.append( new Language("ho" , "Hiri Motu" , i18n("Hiri Motu")) ); - m_langList.append( new Language("hr" , "Croatian" , i18n("Croatian")) ); - - m_langList.append( new Language("hu" , "Hungarian" , i18n("Hungarian")) ); - - m_langList.append( new Language("hy" , "Armenian" , i18n("Armenian")) ); - - // m_langList.append( new Language("hz" , "Herero" , i18n("Herero")) ); - - // m_langList.append( new Language("ia" , "Interlingua" , i18n("Interlingua")) ); - m_langList.append( new Language("id" , "Indonesian" , i18n("Indonesian")) ); - - // m_langList.append( new Language("ie" , "Interlingue" , i18n("Interlingue")) ); - // m_langList.append( new Language("ik" , "Inupiaq" , i18n("Inupiaq")) ); - m_langList.append( new Language("is" , "Icelandic" , i18n("Icelandic")) ); - - m_langList.append( new Language("it" , "Italian" , i18n("Italian")) ); - - // m_langList.append( new Language("iu" , "Inuktitut" , i18n("Inuktitut")) ); - - m_langList.append( new Language("ja" , "Japanese" , i18n("Japanese")) ); - - m_langList.append( new Language("ka" , "Georgian" , i18n("Georgian")) ); - - // m_langList.append( new Language("x-E-KAB" , "Kabyle" , i18n("Kabyle")) ); - // m_langList.append( new Language("ki" , "Kikuyu" , i18n("Kikuyu")) ); - // m_langList.append( new Language("kj" , "Kuanyama" , i18n("Kuanyama")) ); - // m_langList.append( new Language("kk" , "Kazakh" , i18n("Kazakh")) ); - // m_langList.append( new Language("kl" , "Kalaallisut" , i18n("Kalaallisut")) ); - // m_langList.append( new Language("km" , "Khmer" , i18n("Khmer")) ); - // m_langList.append( new Language("kn" , "Kannada" , i18n("Kannada")) ); - m_langList.append( new Language("ko" , "Korean" , i18n("Korean")) ); - - // m_langList.append( new Language("ks" , "Kashmiri" , i18n("Kashmiri")) ); - m_langList.append( new Language("ku" , "Kurdish" , i18n("Kurdish")) ); - - // m_langList.append( new Language("kv" , "Komi" , i18n("Komi")) ); - // m_langList.append( new Language("kw" , "Cornish" , i18n("Cornish")) ); - m_langList.append( new Language("ky" , "Kirghiz" , i18n("Kirghiz")) ); - - m_langList.append( new Language("la" , "Latin" , i18n("Latin")) ); - - // m_langList.append( new Language("lb" , "Letzeburgesch" , i18n("Letzeburgesch")) ); - // m_langList.append( new Language("ln" , "Lingala" , i18n("Lingala")) ); - // m_langList.append( new Language("lo" , "Lao" , i18n("Lao")) ); - m_langList.append( new Language("lt" , "Lithuanian" , i18n("Lithuanian")) ); - - m_langList.append( new Language("lv" , "Latvian" , i18n("Latvian")) ); - - // m_langList.append( new Language("mg" , "Malagasy" , i18n("Malagasy")) ); - // m_langList.append( new Language("mh" , "Marshall" , i18n("Marshall")) ); - m_langList.append( new Language("mi" , "Maori" , i18n("Maori")) ); - - m_langList.append( new Language("mk" , "Macedonian" , i18n("Macedonian")) ); - - // m_langList.append( new Language("ml" , "Malayalam" , i18n("Malayalam")) ); - // m_langList.append( new Language("mn" , "Mongolian" , i18n("Mongolian")) ); - // m_langList.append( new Language("mo" , "Moldavian" , i18n("Moldavian")) ); - m_langList.append( new Language("mos" , "More" , i18n("More")) ); - - // m_langList.append( new Language("mr" , "Marathi" , i18n("Marathi")) ); - m_langList.append( new Language("ms" , "Malay" , i18n("Malay")) ); - - m_langList.append( new Language("mt" , "Maltese" , i18n("Maltese")) ); - - // m_langList.append( new Language("my" , "Burmese" , i18n("Burmese")) ); - - // m_langList.append( new Language("na" , "Nauru" , i18n("Nauru")) ); - // m_langList.append( new Language("nb" , "Norwegian Bokmål" , i18n("Norwegian Bokmål")) ); - // m_langList.append( new Language("nd" , "Ndebele, North" , i18n("Ndebele, North")) ); - m_langList.append( new Language("nds" , "Low German; Low Saxon" , i18n("Low German; Low Saxon")) ); - - // m_langList.append( new Language("ne" , "Nepali" , i18n("Nepali")) ); - // m_langList.append( new Language("ng" , "Ndonga" , i18n("Ndonga")) ); - m_langList.append( new Language("nl" , "Dutch" , i18n("Dutch")) ); - - // m_langList.append( new Language("nn" , "Norwegian Nynorsk" , i18n("Norwegian Nynorsk")) ); - m_langList.append( new Language("no" , "Norwegian" , i18n("Norwegian")) ); - - // m_langList.append( new Language("nr" , "Ndebele, South" , i18n("Ndebele, South")) ); - // m_langList.append( new Language("nv" , "Navajo" , i18n("Navajo")) ); - // m_langList.append( new Language("ny" , "Chichewa; Nyanja" , i18n("Chichewa; Nyanja")) ); - - // m_langList.append( new Language("oc" , "Occitan (post 1500); Provençal" , i18n("Occitan (post 1500); Provençal")) ); - // m_langList.append( new Language("om" , "Oromo" , i18n("Oromo")) ); - // m_langList.append( new Language("or" , "Oriya" , i18n("Oriya")) ); - // m_langList.append( new Language("os" , "Ossetian; Ossetic" , i18n("Ossetian; Ossetic")) ); - - // m_langList.append( new Language("pa" , "Panjabi" , i18n("Panjabi")) ); - m_langList.append( new Language("pap" , "Papiamento" , i18n("Papiamento")) ); - - // m_langList.append( new Language("pi" , "Pali" , i18n("Pali")) ); - m_langList.append( new Language("pl" , "Polish" , i18n("Polish")) ); - - // m_langList.append( new Language("ps" , "Pushto" , i18n("Pushto")) ); - m_langList.append( new Language("pt" , "Portuguese" , i18n("Portuguese")) ); - - m_langList.append( new Language("pt_BR" , "Brasilian Portuguese" , i18n("Brasilian Portuguese")) );//added by ourself - - // m_langList.append( new Language("qu" , "Quechua" , i18n("Quechua")) ); - - // m_langList.append( new Language("rm" , "Raeto-Romance" , i18n("Raeto-Romance")) ); - // m_langList.append( new Language("rn" , "Rundi" , i18n("Rundi")) ); - - m_langList.append( new Language("ro" , "Romanian" , i18n("Romanian")) ); - - m_langList.append( new Language("ru" , "Russian" , i18n("Russian")) ); - - // m_langList.append( new Language("rw" , "Kinyarwanda" , i18n("Kinyarwanda")) ); - - // m_langList.append( new Language("sa" , "Sanskrit" , i18n("Sanskrit")) ); - // m_langList.append( new Language("sc" , "Sardinian" , i18n("Sardinian")) ); - m_langList.append( new Language("sco" , "Scots" , i18n("Scots")) ); - - // m_langList.append( new Language("sd" , "Sindhi" , i18n("Sindhi")) ); - // m_langList.append( new Language("se" , "Northern Sami" , i18n("Northern Sami")) ); - // m_langList.append( new Language("sg" , "Sango" , i18n("Sango")) ); - // m_langList.append( new Language("si" , "Sinhalese" , i18n("Sinhalese")) ); - m_langList.append( new Language("sk" , "Slovak" , i18n("Slovak")) ); - - m_langList.append( new Language("sl" , "Slovenian" , i18n("Slovenian")) ); - - // m_langList.append( new Language("sm" , "Samoan" , i18n("Samoan")) ); - // m_langList.append( new Language("sn" , "Shona" , i18n("Shona")) ); - m_langList.append( new Language("so" , "Somali" , i18n("Somali")) ); - - m_langList.append( new Language("sq" , "Albanian" , i18n("Albanian")) ); - - // m_langList.append( new Language("sr" , "Serbian" , i18n("Serbian")) ); - // m_langList.append( new Language("ss" , "Swati" , i18n("Swati")) ); - // m_langList.append( new Language("st" , "Sotho, Southern" , i18n("Sotho, Southern")) ); - // m_langList.append( new Language("su" , "Sundanese" , i18n("Sundanese")) ); - m_langList.append( new Language("sv" , "Swedish" , i18n("Swedish")) ); - - m_langList.append( new Language("sw" , "Swahili" , i18n("Swahili")) ); - - m_langList.append( new Language("syr" , "Syriac" , i18n("Syriac")) ); - - m_langList.append( new Language("ta" , "Tamil" , i18n("Tamil")) ); - - // m_langList.append( new Language("te" , "Telugu" , i18n("Telugu")) ); - // m_langList.append( new Language("tg" , "Tajik" , i18n("Tajik")) ); - m_langList.append( new Language("th" , "Thai" , i18n("Thai")) ); - - // m_langList.append( new Language("tk" , "Turkmen" , i18n("Turkmen")) ); - m_langList.append( new Language("tl" , "Tagalog" , i18n("Tagalog")) ); - - m_langList.append( new Language("tn" , "Tswana" , i18n("Tswana")) ); - - m_langList.append( new Language("tr" , "Turkish" , i18n("Turkish")) ); - - // m_langList.append( new Language("ts" , "Tsonga" , i18n("Tsonga")) ); - // m_langList.append( new Language("tt" , "Tatar" , i18n("Tatar")) ); - // m_langList.append( new Language("tw" , "Twi" , i18n("Twi")) ); - m_langList.append( new Language("ty" , "Tahitian" , i18n("Tahitian")) ); - - // - // m_langList.append( new Language("ug" , "Uighur" , i18n("Uighur")) ); - m_langList.append( new Language("uk" , "Ukrainian" , i18n("Ukrainian")) ); - - // m_langList.append( new Language("ur" , "Urdu" , i18n("Urdu")) ); - // m_langList.append( new Language("uz" , "Uzbek" , i18n("Uzbek")) ); - - m_langList.append( new Language("vi" , "Vietnamese" , i18n("Vietnamese")) ); - - // m_langList.append( new Language("vo" , "Volapük" , i18n("Volapük")) ); - // - // m_langList.append( new Language("wo" , "Wolof" , i18n("Wolof")) ); - - m_langList.append( new Language("xh" , "Xhosa" , i18n("Xhosa")) ); - - m_langList.append( new Language("x-E-BAR" , "Bavarian" , i18n("Bavarian")) ); - - m_langList.append( new Language("x-E-DJE" , "Zarma" , i18n("Zarma")) ); - - m_langList.append( new Language("x-E-GSW" , "Alemannisch" , i18n("Alemannisch")) ); - - m_langList.append( new Language("x-E-HAT" , "Haitian Creole French" , i18n("Haitian Creole French")) ); - - m_langList.append( new Language("x-E-ITZ" , QString::fromUtf8("Itzá") , i18n("Itzá")) ); - - m_langList.append( new Language("x-E-JIV" , "Shuar" , i18n("Shuar")) ); - - m_langList.append( new Language("x-E-KEK" , QString::fromUtf8("Kekchí") , i18n("Kekchí")) ); - - m_langList.append( new Language("x-E-KAB" , "Kabyle" , i18n("Kabyle")) ); - - m_langList.append( new Language("x-E-LMO" , "Lombard" , i18n("Lombard")) ); - - m_langList.append( new Language("x-E-MKJ" , "Macedonian" , i18n("Macedonian")) ); - - m_langList.append( new Language("x-E-PDG" , "Tok Pisin" , i18n("Tok Pisin")) ); - - m_langList.append( new Language("x-E-PPK" , "Uma" , i18n("Uma")) ); - - m_langList.append( new Language("x-E-RMY" , "Romani, Vlax" , i18n("Romani, Vlax")) ); - - m_langList.append( new Language("x-E-SAJ" , "Sango" , i18n("Sango")) ); - - m_langList.append( new Language("x-E-SRN" , "Sranan" , i18n("Sranan")) ); - - // m_langList.append( new Language("yi" , "Yiddish" , i18n("Yiddish")) ); - // - // m_langList.append( new Language("za" , "Zhuang" , i18n("Zhuang")) ); - m_langList.append( new Language("zh" , "Chinese" , i18n("Chinese")) ); - - m_langList.append( new Language("zu" , "Zulu" , i18n("Zulu")) ); - - for ( Language* lang = m_langList.first(); lang; lang = m_langList.next() ) { - m_langMap.insert( lang->abbrev(), lang); - }; -}; diff --git a/bibletime/backend/clanguagemgr.h b/bibletime/backend/clanguagemgr.h deleted file mode 100644 index 2acc4c7..0000000 --- a/bibletime/backend/clanguagemgr.h +++ /dev/null @@ -1,172 +0,0 @@ -/********* -* -* This file is part of BibleTime's source code, http://www.bibletime.info/. -* -* Copyright 1999-2006 by the BibleTime developers. -* The BibleTime source code is licensed under the GNU General Public License version 2.0. -* -**********/ - - - -#ifndef CLANGUAGEMGR_H -#define CLANGUAGEMGR_H - -//Qt includes -#include <qstring.h> -#include <qstringlist.h> -#include <qvaluelist.h> -#include <qmap.h> -#include <qdict.h> - -/** Manages the anguages of BibleTime and provides functions to work with them. - * @author The BibleTime team - */ - -class CLanguageMgr { - -public: - /** Language container. - * This class (Language) contains the information about the chosen language. - */ - class Language { - public: - /** Default constructor of a language object. - * Uses the abbreviation parameter to lookup the - * language name and to be able to return the name, flag etc. - * Possible values for abbrev are de, en, fr, it etc. - */ - Language(); - /** Copy constructor. - */ - Language(const Language&); - /** Constructor which takes all necessary data. - */ - Language(const QString& abbrev, const QString& englishName, const QString& translatedName, const QStringList& altAbbrevs = QStringList()); - /** Destructor. - */ - ~Language(); - /** Returns the abbreviation. - * @return The abbreviation of the chosen language. - */ - inline const QString& abbrev() const; - /** Returns the translated name. - * @return The translated name of the language. - */ - inline const QString& translatedName() const; - //always define inlines in the header file, or make them not inline. - /** The english name of the language. - * @return The english name of the chosen language. - */ - inline const QString& name() const { - return m_englishName; - } - - /** The alternative abbreviations which are avalable for this language. - * @return A pointer to the list of alternate abbreviations - */ - inline const QStringList* const alternativeAbbrevs() const { - return m_altAbbrevs; - }; - - /** - * Returns true if this language object is valid, i.e. has an abbrev and name. - * @return True if the data is valid for this language. - */ - inline const bool isValid() const; - - private: - QString m_abbrev; - QString m_englishName; - QString m_translatedName; - QStringList* m_altAbbrevs; - }; - - typedef QPtrList<CLanguageMgr::Language> LanguageList; - - typedef QDict<Language> LangMap; - typedef QDictIterator<Language> LangMapIterator; - - /** Constructor. - */ - CLanguageMgr(); - /** Destructor - */ - virtual ~CLanguageMgr(); - /** - * Returns the standard languages available as standard. Does nothing for Sword. - * @return A QDict<Language> map which contains all known languages - */ - inline const CLanguageMgr::LangMap* const languages() const; - /** - * Returns the languages which are available. The languages cover all available modules, but nothing more. - * @return A map of all languages with modules available for them - */ - const CLanguageMgr::LangMap& availableLanguages(); - /** Language for abbreviation. - * @param abbrev The language abbreviation - * @return Pointer to a language for the given string abbreviation. - */ - const CLanguageMgr::Language* const languageForAbbrev( const QString& abbrev ) const; - /** Language for english name. - * @param abbrev The english language name. - * @return Pointer to a language for the given name - */ - const CLanguageMgr::Language* const languageForName( const QString& language ) const; - /** Language for translated language name. - * @param abbrev The translated language name - * @return Pointer to a language for the given translated language name - */ - const CLanguageMgr::Language* const languageForTranslatedName( const QString& language ) const; - /** Default language so we don't return NULL pointers. - * @return Pointer to the default language - */ - inline const CLanguageMgr::Language* const defaultLanguage() const; - -private: - void init(); - inline const QStringList makeStringList(const QString& abbrevs) { - return QStringList::split( ";", abbrevs, false ); - } - - mutable LangMap m_langMap; - Language m_defaultLanguage; - - //typedef QPtrList<CLanguageMgr::Language> LanguageList; - static LanguageList m_langList; - static LanguageList m_cleanupLangPtrs; - - struct ModuleCache { - unsigned int moduleCount; - LangMap availableLanguages; - } - m_availableModulesCache; -}; - - -/** Returns true if this language object is valid, i.e. has an abbrev and name. */ -inline const bool CLanguageMgr::Language::isValid() const { - return (!abbrev().isEmpty() && !name().isEmpty()); -} - -inline const QString& CLanguageMgr::Language::abbrev() const { - if (m_altAbbrevs && m_abbrev.isEmpty() && m_altAbbrevs->count()) { //no standard abbrev but alternative ones - return m_altAbbrevs->first(); - } - - return m_abbrev; -} - -inline const QString& CLanguageMgr::Language::translatedName() const { - return m_translatedName; -} - -inline const CLanguageMgr::LangMap* const CLanguageMgr::languages() const { - return &m_langMap; -} - -inline const CLanguageMgr::Language* const CLanguageMgr::defaultLanguage() const { - return &m_defaultLanguage; -} - -#endif diff --git a/bibletime/backend/cplaintextexportrendering.cpp b/bibletime/backend/cplaintextexportrendering.cpp deleted file mode 100644 index 37d0fa0..0000000 --- a/bibletime/backend/cplaintextexportrendering.cpp +++ /dev/null @@ -1,58 +0,0 @@ -// -// C++ Implementation: cplaintextexportrendering -// -// Description: -// -// -// Author: The BibleTime team <info@bibletime.info>, (C) 2004 -// -// Copyright: See COPYING file that comes with this distribution -// -// - -//Backend includes -#include "cplaintextexportrendering.h" -#include "cswordkey.h" - -//Util -#include "util/scoped_resource.h" - - - -namespace Rendering { - - CPlainTextExportRendering::CPlainTextExportRendering(const CPlainTextExportRendering::Settings& settings, CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions) -: CHTMLExportRendering(settings, displayOptions, filterOptions) {} - - CPlainTextExportRendering::~CPlainTextExportRendering() {} - - const QString CPlainTextExportRendering::renderEntry( const KeyTreeItem& i, CSwordKey* ) { - if (!m_settings.addText) { - return QString(i.key()).append("\n"); - } - - ListCSwordModuleInfo modules = i.modules(); - util::scoped_ptr<CSwordKey> key( CSwordKey::createInstance(modules.first()) ); - QString renderedText = QString(i.key()).append(":\n"); - - QString entry; - // for (CSwordModuleInfo* m = modules.first(); m; m = modules.next()) { - ListCSwordModuleInfo::iterator end_it = modules.end(); - - for (ListCSwordModuleInfo::iterator it(modules.begin()); it != end_it; ++it) { - key->module(*it); - key->key( i.key() ); - - //ToDo: Check this code - entry.append(key->strippedText()).append("\n"); - renderedText.append( entry ); - } - - return renderedText; - } - - const QString CPlainTextExportRendering::finishText( const QString& oldText, KeyTree& ) { - return oldText; - } - -}; diff --git a/bibletime/backend/cplaintextexportrendering.h b/bibletime/backend/cplaintextexportrendering.h deleted file mode 100644 index 95a1cae..0000000 --- a/bibletime/backend/cplaintextexportrendering.h +++ /dev/null @@ -1,42 +0,0 @@ -// -// C++ Interface: cplaintextexportrendering -// -// Description: -// -// -// Author: The BibleTime team <info@bibletime.info>, (C) 2004 -// -// Copyright: See COPYING file that comes with this distribution -// -// -#ifndef RENDERINGCPLAINTEXTEXPORTRENDERING_H -#define RENDERINGCPLAINTEXTEXPORTRENDERING_H - -#include "chtmlexportrendering.h" - -namespace Rendering { - - /** - * This implementation can be used to export content as plain text. - * @short Text rendering as plain text. - * @author The BibleTime team - */ - -class CPlainTextExportRendering : public CHTMLExportRendering { - -public: - CPlainTextExportRendering( - const Settings& settings, - CSwordBackend::DisplayOptions displayOptions = CBTConfig::getDisplayOptionDefaults(), - CSwordBackend::FilterOptions filterOptions = CBTConfig::getFilterOptionDefaults() - ); - virtual ~CPlainTextExportRendering(); - -protected: - virtual const QString renderEntry( const KeyTreeItem&, CSwordKey* = 0 ); - virtual const QString finishText( const QString&, KeyTree& tree ); - }; - -}; - -#endif diff --git a/bibletime/backend/creferencemanager.cpp b/bibletime/backend/creferencemanager.cpp deleted file mode 100644 index 7b41e7f..0000000 --- a/bibletime/backend/creferencemanager.cpp +++ /dev/null @@ -1,434 +0,0 @@ -/********* -* -* This file is part of BibleTime's source code, http://www.bibletime.info/. -* -* Copyright 1999-2006 by the BibleTime developers. -* The BibleTime source code is licensed under the GNU General Public License version 2.0. -* -**********/ - - - -#include "creferencemanager.h" -#include "cswordversekey.h" - -#include "../frontend/cbtconfig.h" - -//QT includes -#include <qregexp.h> - -//stl includes -#include <algorithm> // STL algorithms class library - -/** Returns a hyperlink used to be imbedded in the display windows. At the moment the format is sword://module/key */ -const QString CReferenceManager::encodeHyperlink( const QString moduleName, const QString key, const CReferenceManager::Type type) { - QString ret = QString::null; - - switch (type) { - - case Bible: - ret.setLatin1("sword://Bible/"); - break; - - case Commentary: - ret.setLatin1("sword://Commentary/"); - break; - - case Lexicon: - ret.setLatin1("sword://Lexicon/"); - break; - - case GenericBook: - ret.setLatin1("sword://Book/"); - break; - - case MorphHebrew: - ret.setLatin1("morph://Hebrew/"); - break; - - case MorphGreek: - ret.setLatin1("morph://Greek/"); - break; - - case StrongsHebrew: - ret.setLatin1("strongs://Hebrew/"); - break; - - case StrongsGreek: - ret.setLatin1("strongs://Greek/"); - break; - - default: - break; - } - - if (!moduleName.isEmpty()) { - ret.append( moduleName ).append('/'); - } - else { //if module is empty use fallback module - ret.append( preferredModule(type) ).append('/'); - } - - if (type == GenericBook) { - const QString s = (!key.isEmpty() ? key : QString::null); - QString newKey = QString::null; - //replace all / of the key (e.g. of a CSwordTreeKey) with - // the escape sequence \/ so we know it's a link internal divider (e.g. of CSwordTreeKey)! - - QChar c; - - for(unsigned int i = 0; i < s.length(); ++i) { - c = s.at(i); - - if (c == '/') { - newKey.append("\\/"); - } - else { - newKey.append(c); - } - } - - ret.append( newKey ); - } - else { //slashes do not appear in verses and dictionary entries - - switch (type) { - - case Bible: //bibles or commentary keys need parsing - - case Commentary: { -/* CSwordModuleInfo* mod = CPointers::backend()->findModuleByName(moduleName); - - ParseOptions options; - options.refDestinationModule = mod->name(); - options.refBase = - options.sourceLanguage = mod->module()->Lang(); - options.destinationLanguage = "en"; - - ret.append( parseVerseReference(key, options) ); //we add the english key, so drag and drop will work in all cases*/ - ret.append(key); - break; - } - - default: - ret.append( key ); //use the standard key, no parsing required - break; - } - } - - return ret; -} - -/** Decodes the given hyperlink to module and key. */ -const bool CReferenceManager::decodeHyperlink( const QString& hyperlink, QString& module, QString& key, CReferenceManager::Type& type ) { - /** - * We have to decide between three types of URLS: sword://Type/Module/Key, morph://Testament/key and strongs://Testament/Key - */ - module = QString::null; - key = QString::null; - - type = Unknown; //not yet known - QString ref = hyperlink; - //remove the trailing slash - - if (ref.right(1)=="/" && ref.right(2) != "\\/") //trailing slash, but not escaped - ref = ref.left(ref.length()-1); - - //find out which type we have by looking at the beginning (protocoll section of URL) - if (ref.left(8).lower() == "sword://") { //Bible, Commentary or Lexicon - ref = ref.mid(8); - - if (ref.left(5).lower() == "bible") { //a bible hyperlink - type = CReferenceManager::Bible; - ref = ref.mid(6); //inclusive trailing slash - } - else if (ref.left(10).lower() == "commentary") { // a Commentary hyperlink - type = CReferenceManager::Commentary; - ref = ref.mid(11); //inclusive trailing slash - } - else if (ref.left(7).lower() == "lexicon") { // a Lexicon hyperlink - type = CReferenceManager::Lexicon; - ref = ref.mid(8); //inclusive trailing slash - } - else if (ref.left(4).lower() == "book") { // a Book hyperlink - type = CReferenceManager::GenericBook; - ref = ref.mid(5); //inclusive trailing slash - } - - // string up to next slash is the modulename - if (ref.at(0) != '/' ) { //we have a module given - - while (true) { - const int pos = ref.find("/"); - - if ((pos>0) && ref.at(pos-1) != '\\') { //found a slash which is not escaped - module = ref.mid(0,pos); - ref = ref.mid(pos+1); - break; - } - else if (pos == -1) { - break; - } - } - - // the rest is the key - key = ref; - } - else { - key = ref.mid(1); - } - - //the key may be an osis key like "NASBLex:Moses", which sets the module, too - // const int modPos = key.find(":"); - // if (modPos != -1 && key.at(modPos-1).isLetter() && key.at(modPos+1).isLetter()) { - // module = key.left(modPos); - // key = key.mid(modPos+1); - // - // qWarning("found the module name %s with key %s", module.latin1(), key.latin1()); - // } - - //replace \/ escapes with / - key.replace(QRegExp("\\\\/"), "/"); - } - else if (ref.left(8).lower() == "morph://" || ref.left(10).lower() == "strongs://") { //strongs or morph URL have the same format - enum PreType {IsMorph, IsStrongs}; - PreType preType = IsMorph; - - if (ref.left(8).lower() == "morph://") { //morph code hyperlink - ref = ref.mid(8); - preType = IsMorph; - } - else if (ref.left(10).lower() == "strongs://") { - ref = ref.mid(10); - preType = IsStrongs; - } - - //part up to next slash is the language - const int pos = ref.find("/"); - - if (pos>0) { //found - const QString language = ref.mid(0,pos); - - if (language.lower() == "hebrew") { - switch (preType) { - - case IsMorph: - type = CReferenceManager::MorphHebrew; - break; - - case IsStrongs: - type = CReferenceManager::StrongsHebrew; - break; - } - } - else if (language.lower() == "greek") { - switch (preType) { - - case IsMorph: - type = CReferenceManager::MorphGreek; - break; - - case IsStrongs: - type = CReferenceManager::StrongsGreek; - break; - } - } - - ref = ref.mid(pos+1); - key = ref; //the remaining part is the key - - module = preferredModule(type); - } - } - - if (key.isEmpty() && module.isEmpty()) - return false; - - return true; -} - -const QString CReferenceManager::encodeReference(const QString &module, const QString &reference) { - //return QString("(%1)%2").arg(module).arg(reference); - return QString("(").append(module).append(")").append(reference); -} - -void CReferenceManager::decodeReference(QString &dragreference, QString &module, QString &reference) { - const int pos = dragreference.find(")"); - const QString fallbackModule = dragreference.mid( 1, pos - 1); - dragreference = dragreference.mid(pos+1); - - module = fallbackModule; - reference = dragreference; -} - -/** Returns true if the parameter is a hyperlink. */ -const bool CReferenceManager::isHyperlink( const QString& hyperlink ) { - return ( hyperlink.left(8) == "sword://") - || (hyperlink.left(10) == "strongs://") - || (hyperlink.left(8) == "morph://"); -} - -/** Returns the preferred module name for the given type. */ -const QString CReferenceManager::preferredModule( const CReferenceManager::Type type ) { - QString moduleName = QString::null; - CSwordModuleInfo* module = 0; - - switch (type) { - - case CReferenceManager::Bible: - - module = CBTConfig::get - ( CBTConfig::standardBible ); - - break; - - case CReferenceManager::Commentary: - module = CBTConfig::get - ( CBTConfig::standardCommentary ); - - break; - - case CReferenceManager::Lexicon: - module = CBTConfig::get - ( CBTConfig::standardLexicon ); - - break; - - case CReferenceManager::StrongsHebrew: - module = CBTConfig::get - ( CBTConfig::standardHebrewStrongsLexicon ); - - break; - - case CReferenceManager::StrongsGreek: - module = CBTConfig::get - ( CBTConfig::standardGreekStrongsLexicon ); - - break; - - case CReferenceManager::MorphHebrew: - module = CBTConfig::get - ( CBTConfig::standardHebrewMorphLexicon ); - - break; - - case CReferenceManager::MorphGreek: - module = CBTConfig::get - ( CBTConfig::standardGreekMorphLexicon ); - - break; - - default: - module = 0; - - break; - } - - return module ? module->name() : QString::null; -} - -/** No descriptions */ -CReferenceManager::Type CReferenceManager::typeFromModule( const CSwordModuleInfo::ModuleType type) { - switch (type) { - - case CSwordModuleInfo::Bible: - return CReferenceManager::Bible; - - case CSwordModuleInfo::Commentary: - return CReferenceManager::Commentary; - - case CSwordModuleInfo::Lexicon: - return CReferenceManager::Lexicon; - - case CSwordModuleInfo::GenericBook: - return CReferenceManager::GenericBook; - - default: - return CReferenceManager::Unknown; - } -} - -/** Parses the given verse references using the given language and the module.*/ -const QString CReferenceManager::parseVerseReference( const QString& ref, const CReferenceManager::ParseOptions& options) { - - CSwordModuleInfo* const mod = CPointers::backend()->findModuleByName(options.refDestinationModule); - Q_ASSERT(mod); - - if (!mod) { - //parsing of non-verse based references is not supported - return ref; - } - - if ((mod->type() != CSwordModuleInfo::Bible) && (mod->type() != CSwordModuleInfo::Commentary)) { - qDebug("CReferenceManager: Only verse based modules are supported as ref destination module"); - return QString::null; - } - - QString sourceLanguage = options.sourceLanguage; - QString destinationLanguage = options.destinationLanguage; - - StringList locales = sword::LocaleMgr::getSystemLocaleMgr()->getAvailableLocales(); - if (/*options.sourceLanguage == "en" ||*/ std::find(locales.begin(), locales.end(), sourceLanguage) == locales.end()) { //sourceLanguage not available - sourceLanguage = "en_US"; - } - - if (/*options.destinationLanguage == "en" ||*/ std::find(locales.begin(), locales.end(), sourceLanguage) == locales.end()) { //destination not available - destinationLanguage = "en_US"; - } - - - QString ret; - QStringList refList = QStringList::split(";", ref); - - CSwordVerseKey baseKey(0); - baseKey.setLocale( sourceLanguage.latin1() ); - baseKey.key( options.refBase ); //probably in the sourceLanguage - baseKey.setLocale( "en_US" ); //english works in all environments as base - -// CSwordVerseKey dummy(0); - //HACK: We have to workaround a Sword bug, we have to set the default locale to the same as the sourceLanguage ! - const QString oldLocaleName = CPointers::backend()->booknameLanguage(); - CPointers::backend()->booknameLanguage(sourceLanguage); - - VerseKey dummy; - dummy.setLocale( sourceLanguage.latin1() ); - Q_ASSERT( !strcmp(dummy.getLocale(), sourceLanguage.latin1()) ); - -// qDebug("Parsing '%s' in '%s' using '%s' as base, source lang '%s', dest lang '%s'", ref.latin1(), options.refDestinationModule.latin1(), baseKey.key().latin1(), sourceLanguage.latin1(), destinationLanguage.latin1()); - - for (QStringList::iterator it = refList.begin(); it != refList.end(); it++) { - //The listkey may contain more than one item, because a ref lik "Gen 1:3,5" is parsed into two single refs - ListKey lk = dummy.ParseVerseList((const char*)(*it).utf8(), (const char*)baseKey.key().utf8(), true); - Q_ASSERT(!dummy.Error()); - - Q_ASSERT(lk.Count()); - if (!lk.Count()) { - ret.append( *it ); //don't change the original - continue; - } - - for (int i = 0; i < lk.Count(); ++i) { - if (dynamic_cast<VerseKey*>(lk.getElement(i))) { // a range - VerseKey* k = dynamic_cast<VerseKey*>(lk.getElement(i)); - Q_ASSERT(k); - k->setLocale( destinationLanguage.latin1() ); - - ret.append( QString::fromUtf8(k->getRangeText()) ).append("; "); - } - else { // a single ref - VerseKey vk; - vk.setLocale( sourceLanguage.latin1() ); - vk = lk.getElement(i)->getText(); - vk.setLocale( destinationLanguage.latin1() ); - - ret.append( QString::fromUtf8(vk.getText()) ).append("; "); - } - } - - } - - CPointers::backend()->booknameLanguage(oldLocaleName); -// qDebug(" %s", ret.latin1()); - - return ret; -} diff --git a/bibletime/backend/creferencemanager.h b/bibletime/backend/creferencemanager.h deleted file mode 100644 index 343e3ef..0000000 --- a/bibletime/backend/creferencemanager.h +++ /dev/null @@ -1,112 +0,0 @@ -/********* -* -* This file is part of BibleTime's source code, http://www.bibletime.info/. -* -* Copyright 1999-2006 by the BibleTime developers. -* The BibleTime source code is licensed under the GNU General Public License version 2.0. -* -**********/ - - - -#ifndef CREFERENCEMANAGER_H -#define CREFERENCEMANAGER_H - -//Qt includes -#include <qstring.h> - -#include "cswordmoduleinfo.h" - -/** Contains static functions to work with referneces used for Drag & Drop and for hyperlinks used in our - * rendered HTML code. - * @author The BibleTime team - */ - -class CReferenceManager { - -public: - enum Type { - Bible, /**< Bibles */ - Commentary, /**< Commentary */ - Lexicon, /**< Lexicon */ - GenericBook, /**< Generic Book */ - MorphHebrew, /**< Module for hebrew morphology*/ - MorphGreek, /**< Module for greek morphology */ - StrongsHebrew, /**< Module for hebrew strongs */ - StrongsGreek, /**< Module for greek strongs */ - Unknown /**< Unknown */ - }; - - /** Turn a hyperlink into module, key and type. - * Decodes the given hyperlink into module, key and type. - * @param hyperlink The hyperlink to decode - * @param module The string which will contain the module name after decoding - * @param key The string which will contain the key after decoding - * @param type The type param will contain the reference type after decoding - */ - static const bool decodeHyperlink( const QString& hyperlink, QString& module, QString& key, Type& type); - /** - * Returns a hyperlink used to be imbedded in the display windows. - * At the moment the format is sword://module/key - * @param module The module which is used to encode the hyperlink - * @param key The key which is used to encode the hyperlink - * @param type The type which is used to encode the hyperlink - * @return The encoded hyperlink - */ - static const QString encodeHyperlink( const QString module, const QString key, const Type type); - /** - * Puts a module Name and a Reference together in the 'draggable' form - * (module)reference - * @param module The name of the module - * @param reference The key reference as text - * @return The encoded reference using module and reference - * @author Martin Gruner - */ - static const QString encodeReference(const QString &module, const QString &reference); - /** - * decodes a 'draggable' reference into a modulename and a reference - * @author Martin Gruner - */ - static void decodeReference(QString &dragreference, QString &module, QString &reference); - /** - * Returns true if the parameter is a hyperlink. - * @param hyperlink The string which is tested - * @return True if the passed string is a hyperlink - */ - static const bool isHyperlink( const QString& hyperlink ); - /** - * Returns the preferred module name for the given type. - * @param type The type which is used to find the module - * @return The default module name for the passed type - */ - static const QString preferredModule( const Type type ); - /** - * Returns the type of the passed module type - * @param type The CSwordModuleInfo module typpe - * @return The ReferenceManager type - */ - static CReferenceManager::Type typeFromModule( const CSwordModuleInfo::ModuleType type ); - - - struct ParseOptions { - QString refDestinationModule; - QString refBase; /* only valid for verse based destination modules*/ - QString sourceLanguage; /* only valid for verse based destination modules*/ - QString destinationLanguage; /* only valid for verse based destination modules*/ - - ParseOptions() { - destinationLanguage = "en"; - }; - }; - - /** Parses the given verse references using the given language and the module. - * @param moduleName The name of the module to use. Required for the language checking before parsing the key. - * @param ref The verse reference. - * @param lang The language of the verse reference - * @param newLang The language of the reference, which will be returned. For example: If BibleTime using an english environment parses a spanish ref (lang=es) the returned ref should be in english (newLang=en), because his english standard module only understands en. - */ - static const QString parseVerseReference( const QString& ref, const ParseOptions& options); -}; - -#endif - diff --git a/bibletime/backend/cswordbackend.cpp b/bibletime/backend/cswordbackend.cpp deleted file mode 100644 index f46b444..0000000 --- a/bibletime/backend/cswordbackend.cpp +++ /dev/null @@ -1,692 +0,0 @@ -/********* -* -* This file is part of BibleTime's source code, http://www.bibletime.info/. -* -* Copyright 1999-2006 by the BibleTime developers. -* The BibleTime source code is licensed under the GNU General Public License version 2.0. -* -**********/ - - - -//BibleTime includes -#include "cswordbackend.h" -#include "centrydisplay.h" -#include "cbookdisplay.h" -#include "cchapterdisplay.h" -#include "cswordbiblemoduleinfo.h" -#include "cswordcommentarymoduleinfo.h" -#include "cswordlexiconmoduleinfo.h" -#include "cswordbookmoduleinfo.h" - -#include "bt_thmlhtml.h" -#include "bt_thmlplain.h" -#include "bt_osishtml.h" -#include "bt_gbfhtml.h" -#include "bt_plainhtml.h" -#include "osismorphsegmentation.h" - -#include "frontend/cbtconfig.h" - -#include <dirent.h> -#include <unistd.h> -#include <ctype.h> - -//Qt includes -#include <qdir.h> -#include <qfileinfo.h> - -//KDE includes -#include <klocale.h> -#include <kstringhandler.h> - -//Sword includes -#include <swdisp.h> -#include <swfiltermgr.h> -#include <encfiltmgr.h> -#include <rtfhtml.h> -#include <filemgr.h> -#include <utilstr.h> -#include <swfilter.h> - -using std::string; - -using namespace Filters; - -using namespace Rendering; - -CSwordBackend::CSwordBackend() -: sword::SWMgr(0, 0, false, new sword::EncodingFilterMgr( sword::ENC_UTF8 ), true) { - m_displays.entry = 0; - m_displays.chapter = 0; - m_displays.book = 0; - - m_filters.gbf = 0; - m_filters.thml = 0; - m_filters.osis = 0; - m_filters.plain = 0; - - filterInit(); -} - -CSwordBackend::CSwordBackend(const QString& path, const bool augmentHome) -: sword::SWMgr(!path.isEmpty() ? (const char*)path.local8Bit() : 0, false, new sword::EncodingFilterMgr( sword::ENC_UTF8 ), false, augmentHome) // don't allow module renaming, because we load from a path -{ - qDebug("CSwordBackend::CSwordBackend for %s, using %s", path.latin1(), configPath); - m_displays.entry = 0; - m_displays.chapter = 0; - m_displays.book = 0; - - m_filters.gbf = 0; - m_filters.thml = 0; - m_filters.osis = 0; - m_filters.plain = 0; - - filterInit(); -} - -CSwordBackend::~CSwordBackend() { - shutdownModules(); - - delete m_filters.gbf; - delete m_filters.plain; - delete m_filters.thml; - delete m_filters.osis; - - delete m_displays.book; - delete m_displays.chapter; - delete m_displays.entry; -} - -/** Initializes the Sword modules. */ -const CSwordBackend::LoadError CSwordBackend::initModules() { - // qWarning("globalSwordConfigPath is %s", globalConfPath); - LoadError ret = NoError; - - shutdownModules(); //remove previous modules - m_moduleList.clear(); - - sword::ModMap::iterator end = Modules.end(); - ret = LoadError( Load() ); - - for (sword::ModMap::iterator it = Modules.begin(); it != end; it++) { - sword::SWModule* const curMod = (*it).second; - CSwordModuleInfo* newModule = 0; - - if (!strcmp(curMod->Type(), "Biblical Texts")) { - newModule = new CSwordBibleModuleInfo(curMod, this); - newModule->module()->Disp( - m_displays.chapter - ? m_displays.chapter - : (m_displays.chapter = new CChapterDisplay) - ); - } - else if (!strcmp(curMod->Type(), "Commentaries")) { - newModule = new CSwordCommentaryModuleInfo(curMod, this); - newModule->module()->Disp( - m_displays.entry - ? m_displays.entry - : (m_displays.entry = new CEntryDisplay) - ); - } - else if (!strcmp(curMod->Type(), "Lexicons / Dictionaries")) { - newModule = new CSwordLexiconModuleInfo(curMod, this); - newModule->module()->Disp( - m_displays.entry - ? m_displays.entry - : (m_displays.entry = new CEntryDisplay) - ); - } - else if (!strcmp(curMod->Type(), "Generic Books")) { - newModule = new CSwordBookModuleInfo(curMod, this); - newModule->module()->Disp( - m_displays.book - ? m_displays.book - : (m_displays.book = new CBookDisplay) - ); - } - - if (newModule) { - //append the new modules to our list, but only if it's supported - //the constructor of CSwordModuleInfo prints a waring on stdout - if (!newModule->hasVersion() || (newModule->minimumSwordVersion() <= sword::SWVersion::currentVersion)) { - m_moduleList.append( newModule ); - } - } - } - - ListCSwordModuleInfo::iterator end_it = m_moduleList.end(); - - for (ListCSwordModuleInfo::iterator it = m_moduleList.begin() ; it != end_it; ++it) { - // for (m_moduleList.first(); m_moduleList.current(); m_moduleList.next()) { - m_moduleDescriptionMap.insert( (*it)->config(CSwordModuleInfo::Description), (*it)->name() ); - } - - //unlock modules if keys are present - // ListCSwordModuleInfo::iterator end_it = m_moduleList.end(); - for (ListCSwordModuleInfo::iterator it = m_moduleList.begin() ; it != end_it; ++it) { - // for (m_moduleList.first(); m_moduleList.current(); m_moduleList.next()) { - - if ( (*it)->isEncrypted() ) { - const QString unlockKey = CBTConfig::getModuleEncryptionKey( (*it)->name() ).latin1(); - - if (!unlockKey.isNull()) { - setCipherKey( (*it)->name().latin1(), unlockKey.latin1() ); - } - } - } - - return ret; -} - -void CSwordBackend::AddRenderFilters(sword::SWModule *module, sword::ConfigEntMap §ion) { - sword::SWBuf moduleDriver; - sword::SWBuf sourceformat; - sword::ConfigEntMap::iterator entry; - bool noDriver = true; - - sourceformat = ((entry = section.find("SourceType")) != section.end()) ? (*entry).second : (sword::SWBuf) ""; - moduleDriver = ((entry = section.find("ModDrv")) != section.end()) ? (*entry).second : (sword::SWBuf) ""; - - if (sourceformat == "GBF") { - if (!m_filters.gbf) { - m_filters.gbf = new BT_GBFHTML(); - } - module->AddRenderFilter(m_filters.gbf); - noDriver = false; - } - else if (sourceformat == "PLAIN") { - if (!m_filters.plain) { - m_filters.plain = new BT_PLAINHTML(); - } - module->AddRenderFilter(m_filters.plain); - noDriver = false; - } - else if (sourceformat == "ThML") { - if (!m_filters.thml) { - m_filters.thml = new BT_ThMLHTML(); - } - module->AddRenderFilter(m_filters.thml); - noDriver = false; - } - else if (sourceformat == "OSIS") { - if (!m_filters.osis) { - m_filters.osis = new BT_OSISHTML(); - } - - module->AddRenderFilter(m_filters.osis); - noDriver = false; - } - - if (noDriver) { //no driver found - if ( (moduleDriver == "RawCom") || (moduleDriver == "RawLD") ) { - if (!m_filters.plain) { - m_filters.plain = new BT_PLAINHTML(); - } - module->AddRenderFilter(m_filters.plain); - noDriver = false; - } - } -} - -/** This function deinitializes the modules and deletes them. */ -const bool CSwordBackend::shutdownModules() { - ListCSwordModuleInfo::iterator it = m_moduleList.begin(); - ListCSwordModuleInfo::iterator end = m_moduleList.end(); - - while (it != end) { - CSwordModuleInfo* current = (*it); - it = m_moduleList.remove(it); - - delete current; - } - - Q_ASSERT(m_moduleList.count() == 0); - - //BT mods are deleted now, delete Sword mods, too. - DeleteMods(); - - return true; -} - -/** Returns true if the given option is enabled. */ -const bool CSwordBackend::isOptionEnabled( const CSwordModuleInfo::FilterTypes type) { - return (getGlobalOption( optionName(type).latin1() ) == "On"); -} - -/** Sets the given options enabled or disabled depending on the second parameter. */ -void CSwordBackend::setOption( const CSwordModuleInfo::FilterTypes type, const int state ) { - sword::SWBuf value; - - switch (type) { - - case CSwordModuleInfo::textualVariants: - - if (state == 0) { - value = "Primary Reading"; - } - else if (state == 1) { - value = "Secondary Reading"; - } - else { - value = "All Readings"; - } - - break; - - default: - value = state ? "On": "Off"; - break; - }; - - if (value.length()) - setGlobalOption(optionName(type).latin1(), value.c_str()); -} - -void CSwordBackend::setFilterOptions( const CSwordBackend::FilterOptions options) { - setOption( CSwordModuleInfo::footnotes, options.footnotes ); - setOption( CSwordModuleInfo::strongNumbers, options.strongNumbers ); - setOption( CSwordModuleInfo::headings, options.headings ); - setOption( CSwordModuleInfo::morphTags, options.morphTags ); - setOption( CSwordModuleInfo::lemmas, options.lemmas ); - setOption( CSwordModuleInfo::hebrewPoints, options.hebrewPoints ); - setOption( CSwordModuleInfo::hebrewCantillation, options.hebrewCantillation ); - setOption( CSwordModuleInfo::greekAccents, options.greekAccents ); - setOption( CSwordModuleInfo::redLetterWords, options.redLetterWords ); - setOption( CSwordModuleInfo::textualVariants, options.textualVariants ); - setOption( CSwordModuleInfo::morphSegmentation, options.morphSegmentation ); - // setOption( CSwordModuleInfo::transliteration, options.transliteration ); - setOption( CSwordModuleInfo::scriptureReferences, options.scriptureReferences); -} - -void CSwordBackend::setDisplayOptions( const CSwordBackend::DisplayOptions ) { - /* if (m_displays.entry) { - m_displays.entry->setDisplayOptions(options); - } - if (m_displays.chapter) { - m_displays.chapter->setDisplayOptions(options); - } - if (m_displays.book) { - m_displays.book->setDisplayOptions(options); - } - */ -} - -/** This function searches for a module with the specified description */ -CSwordModuleInfo* const CSwordBackend::findModuleByDescription(const QString& description) { - CSwordModuleInfo* ret = 0; - ListCSwordModuleInfo::iterator end_it = m_moduleList.end(); - - for (ListCSwordModuleInfo::iterator it = m_moduleList.begin() ; it != end_it; ++it) { - if ( (*it)->config(CSwordModuleInfo::Description) == description ) { - ret = *it; - break; - } - } - - return ret; -} - -/** This function searches for a module with the specified description */ -const QString CSwordBackend::findModuleNameByDescription(const QString& description) { - if (m_moduleDescriptionMap.contains(description)) { - return m_moduleDescriptionMap[description]; - } - - return QString::null; -} - -/** This function searches for a module with the specified name */ -CSwordModuleInfo* const CSwordBackend::findModuleByName(const QString& name) { - CSwordModuleInfo* ret = 0; - - ListCSwordModuleInfo::iterator end_it = m_moduleList.end(); - - for (ListCSwordModuleInfo::iterator it = m_moduleList.begin() ; it != end_it; ++it) { - if ( (*it)->name() == name ) { - ret = *it; - break; - } - } - - return ret; -} - -CSwordModuleInfo* const CSwordBackend::findSwordModuleByPointer(const sword::SWModule* const swmodule) { - CSwordModuleInfo* ret = 0; - ListCSwordModuleInfo::iterator end_it = m_moduleList.end(); - - for (ListCSwordModuleInfo::iterator it = m_moduleList.begin() ; it != end_it; ++it) { - if ( (*it)->module() == swmodule ) { - ret = *it; - break; - } - } - - return ret; -} - -CSwordModuleInfo* const CSwordBackend::findModuleByPointer(const CSwordModuleInfo* const module) { - CSwordModuleInfo* ret = 0; - - ListCSwordModuleInfo::iterator end_it = m_moduleList.end(); - - for (ListCSwordModuleInfo::iterator it = m_moduleList.begin() ; it != end_it; ++it) { - if ( (*it) == module ) { - ret = *it; - break; - } - } - - return ret; -} - -/** Returns our local config object to store the cipher keys etc. locally for each user. The values of the config are merged with the global config. */ -const bool CSwordBackend::moduleConfig(const QString& module, sword::SWConfig& moduleConfig) { - sword::SectionMap::iterator section; - DIR *dir = opendir(configPath); - - struct dirent *ent; - - bool foundConfig = false; - QString modFile; - - if (dir) { // find and update .conf file - rewinddir(dir); - - while ((ent = readdir(dir)) && !foundConfig) { - if ((strcmp(ent->d_name, ".")) && (strcmp(ent->d_name, ".."))) { - modFile.setLatin1(configPath); - modFile.append("/"); - modFile.append( QString::fromLocal8Bit(ent->d_name) ); - - moduleConfig = sword::SWConfig( (const char*)modFile.local8Bit() ); - section = moduleConfig.Sections.find( (const char*)module.local8Bit() ); - foundConfig = ( section != moduleConfig.Sections.end() ); - } - } - - closedir(dir); - } - else { //try to read mods.conf - moduleConfig = sword::SWConfig("");//global config - section = config->Sections.find( (const char*)module.local8Bit() ); - foundConfig = ( section != config->Sections.end() ); - - sword::ConfigEntMap::iterator entry; - - if (foundConfig) { //copy module section - - for (entry = (*section).second.begin(); entry != (*section).second.end(); entry++) { - moduleConfig.Sections[(*section).first].insert(sword::ConfigEntMap::value_type((*entry).first, (*entry).second)); - } - } - } - - if (!foundConfig && configType != 2) { //search in $HOME/.sword/ - QString myPath(getenv("HOME")); - myPath.append("/.sword/mods.d"); - dir = opendir(myPath.latin1()); - - if (dir) { - rewinddir(dir); - - while ((ent = readdir(dir)) && !foundConfig) { - if ((strcmp(ent->d_name, ".")) && (strcmp(ent->d_name, ".."))) { - modFile = myPath; - modFile.append('/'); - modFile.append(ent->d_name); - moduleConfig = sword::SWConfig( (const char*)modFile.local8Bit() ); - section = moduleConfig.Sections.find( (const char*)module.local8Bit() ); - foundConfig = ( section != moduleConfig.Sections.end() ); - } - } - - closedir(dir); - } - } - - return foundConfig; -} - -/** Returns the text used for the option given as parameter. */ -const QString CSwordBackend::optionName( const CSwordModuleInfo::FilterTypes option ) { - switch (option) { - - case CSwordModuleInfo::footnotes: - return QString("Footnotes"); - - case CSwordModuleInfo::strongNumbers: - return QString("Strong's Numbers"); - - case CSwordModuleInfo::headings: - return QString("Headings"); - - case CSwordModuleInfo::morphTags: - return QString("Morphological Tags"); - - case CSwordModuleInfo::lemmas: - return QString("Lemmas"); - - case CSwordModuleInfo::hebrewPoints: - return QString("Hebrew Vowel Points"); - - case CSwordModuleInfo::hebrewCantillation: - return QString("Hebrew Cantillation"); - - case CSwordModuleInfo::greekAccents: - return QString("Greek Accents"); - - case CSwordModuleInfo::redLetterWords: - return QString("Words of Christ in Red"); - - case CSwordModuleInfo::textualVariants: - return QString("Textual Variants"); - - case CSwordModuleInfo::scriptureReferences: - return QString("Cross-references"); - - case CSwordModuleInfo::morphSegmentation: - return QString("Morph Segmentation"); - // case CSwordModuleInfo::transliteration: - // return QString("Transliteration"); - } - - return QString::null; -} - -/** Returns the translated name of the option given as parameter. */ -const QString CSwordBackend::translatedOptionName(const CSwordModuleInfo::FilterTypes option) { - switch (option) { - - case CSwordModuleInfo::footnotes: - return i18n("Footnotes"); - - case CSwordModuleInfo::strongNumbers: - return i18n("Strong's numbers"); - - case CSwordModuleInfo::headings: - return i18n("Headings"); - - case CSwordModuleInfo::morphTags: - return i18n("Morphological tags"); - - case CSwordModuleInfo::lemmas: - return i18n("Lemmas"); - - case CSwordModuleInfo::hebrewPoints: - return i18n("Hebrew vowel points"); - - case CSwordModuleInfo::hebrewCantillation: - return i18n("Hebrew cantillation marks"); - - case CSwordModuleInfo::greekAccents: - return i18n("Greek accents"); - - case CSwordModuleInfo::redLetterWords: - return i18n("Red letter words"); - - case CSwordModuleInfo::textualVariants: - return i18n("Textual variants"); - - case CSwordModuleInfo::scriptureReferences: - return i18n("Scripture cross-references"); - - case CSwordModuleInfo::morphSegmentation: - return i18n("Morph segmentation"); - // case CSwordModuleInfo::transliteration: - // return i18n("Transliteration between scripts"); - } - - return QString::null; -} - - -const QString CSwordBackend::configOptionName( const CSwordModuleInfo::FilterTypes option ) { - switch (option) { - - case CSwordModuleInfo::footnotes: - return QString("Footnotes"); - - case CSwordModuleInfo::strongNumbers: - return QString("Strongs"); - - case CSwordModuleInfo::headings: - return QString("Headings"); - - case CSwordModuleInfo::morphTags: - return QString("Morph"); - - case CSwordModuleInfo::lemmas: - return QString("Lemma"); - - case CSwordModuleInfo::hebrewPoints: - return QString("HebrewPoints"); - - case CSwordModuleInfo::hebrewCantillation: - return QString("Cantillation"); - - case CSwordModuleInfo::greekAccents: - return QString("GreekAccents"); - - case CSwordModuleInfo::redLetterWords: - return QString("RedLetterWords"); - - case CSwordModuleInfo::textualVariants: - return QString("Variants"); - - case CSwordModuleInfo::scriptureReferences: - return QString("Scripref"); - - case CSwordModuleInfo::morphSegmentation: - return QString("MorphSegmentation"); - - default: - return QString::null; - } - - return QString::null; -} - -const QString CSwordBackend::booknameLanguage( const QString& language ) { - if (!language.isEmpty()) { - sword::LocaleMgr::getSystemLocaleMgr()->setDefaultLocaleName( language.latin1() ); - - //refresh the locale of all Bible and commentary modules! - const ListCSwordModuleInfo::iterator end_it = m_moduleList.end(); - - //use what sword returns, language may be different - QString newLocaleName( sword::LocaleMgr::getSystemLocaleMgr()->getDefaultLocaleName() ); - - for (ListCSwordModuleInfo::iterator it = m_moduleList.begin(); it != end_it; ++it) { - if ( ((*it)->type() == CSwordModuleInfo::Bible) || ((*it)->type() == CSwordModuleInfo::Commentary) ) { - //Create a new key, it will get the default bookname language - ((sword::VerseKey*)((*it)->module()->getKey()))->setLocale( newLocaleName.latin1() ); - } - } - - } - - return QString( sword::LocaleMgr::getSystemLocaleMgr()->getDefaultLocaleName() ); -} - - -/** Reload all Sword modules. */ -void CSwordBackend::reloadModules() { - shutdownModules(); - - //delete Sword's config to make Sword reload it! - - if (myconfig) { // force reload on config object because we may have changed the paths - delete myconfig; - config = myconfig = 0; - loadConfigDir(configPath); - } - else if (config) { - config->Load(); - } - - initModules(); -} - -const QStringList CSwordBackend::swordDirList() { - QStringList ret; - const QString home = QString(getenv("HOME")); - - //return a list of used Sword dirs. Useful for the installer - QString configPath = QString("%1/.sword/sword.conf").arg(home); - - if (!QFile(configPath).exists()) { - configPath = globalConfPath; //e.g. /etc/sword.conf, /usr/local/etc/sword.conf - - - } - - - QStringList configs = QStringList::split(":", configPath); - - /*ToDo: Use the const iterator as soon as we switch to Qt > 3.1 - for (QStringList::const_iterator it = configs.constBegin(); it != configs.constEnd(); ++it) {*/ - - for (QStringList::const_iterator it = configs.begin(); it != configs.end(); ++it) { - if (!QFileInfo(*it).exists()) { - continue; - } - - //get all DataPath and AugmentPath entries from the config file and add them to the list - sword::SWConfig conf( (*it).latin1() ); - - ret << conf["Install"]["DataPath"].c_str(); - - sword::ConfigEntMap group = conf["Install"]; - - sword::ConfigEntMap::iterator start = group.equal_range("AugmentPath").first; - - sword::ConfigEntMap::iterator end = group.equal_range("AugmentPath").second; - - for (sword::ConfigEntMap::const_iterator it = start; it != end; ++it) { - ret << it->second.c_str(); //added augment path - } - } - - if (!home.isEmpty()) { - ret << home + "/.sword/"; - } - - return ret; -} - -void CSwordBackend::filterInit() { - // qWarning("## INIT"); - - SWOptionFilter* tmpFilter = new OSISMorphSegmentation(); - optionFilters.insert(OptionFilterMap::value_type("OSISMorphSegmentation", tmpFilter)); - cleanupFilters.push_back(tmpFilter); - - //HACK: replace Sword's ThML strip filter with our own version - //remove this hack as soon as Sword is fixed - cleanupFilters.remove(thmlplain); - delete thmlplain; - thmlplain = new BT_ThMLPlain(); - cleanupFilters.push_back(thmlplain); -} diff --git a/bibletime/backend/cswordbackend.h b/bibletime/backend/cswordbackend.h deleted file mode 100644 index 90d7031..0000000 --- a/bibletime/backend/cswordbackend.h +++ /dev/null @@ -1,266 +0,0 @@ -/********* -* -* This file is part of BibleTime's source code, http://www.bibletime.info/. -* -* Copyright 1999-2006 by the BibleTime developers. -* The BibleTime source code is licensed under the GNU General Public License version 2.0. -* -**********/ - - - -#ifndef CSWORDBACKEND_H -#define CSWORDBACKEND_H - -//BibleTime includes -#include "cswordmoduleinfo.h" -//#include "centrydisplay.h" - -//Qt includes -#include <qptrlist.h> -#include <qmap.h> -#include <qstring.h> -#include <qstringlist.h> - -//Sword includes -#include <swmgr.h> -#include <swbuf.h> -#include <swmodule.h> -#include <swversion.h> -#include <localemgr.h> -#include <utilstr.h> - -using namespace sword; - -namespace Rendering { - - class CEntryDisplay; - - class CChapterDisplay; - - class CBookDisplay; -} - -/** The backend layer main class. - * This is the implementation of CBackend for Sword. It's additionally derived from SWMgr - * to provide functions of Sword. - * - * @short The backend implementation of Sword - * @author The BibleTime team - * @version $Id: cswordbackend.h,v 1.58 2007/03/14 21:32:47 joachim Exp $ - */ - -class CSwordBackend : public sword::SWMgr { - -public: - /** Filter options. Filter options to - * control the text display of modules. Uses int and not bool because not all - * options have just two toggle values. - */ - - struct FilterOptions { - int footnotes; /**< 0 for disabled, 1 for enabled */ - int strongNumbers; /**< 0 for disabled, 1 for enabled */ - int headings; /**< 0 for disabled, 1 for enabled */ - int morphTags; /**< 0 for disabled, 1 for enabled */ - int lemmas; /**< 0 for disabled, 1 for enabled */ - int hebrewPoints; /**< 0 for disabled, 1 for enabled */ - int hebrewCantillation; /**< 0 for disabled, 1 for enabled */ - int greekAccents; /**< 0 for disabled, 1 for enabled */ - int textualVariants; /**< Number n to enabled the n-th variant */ - int redLetterWords; /**< 0 for disabled, 1 for enabled */ - int scriptureReferences; /**< 0 for disabled, 1 for enabled */ - int morphSegmentation; /**< 0 for disabled, 1 for enabled */ - }; - - /** Control the display of a text. - */ - - struct DisplayOptions { - int lineBreaks; - int verseNumbers; - }; - - /** The error codes which may be returned by the @ref Load() call. - */ - enum LoadError { // the values exist to cast from the char return of SWMgr::Load - NoSwordConfig = -1, - NoError = 0, - NoModules = 1 - }; - /** - * The constructor of the Sword backend. - * It creates the SWModule objects using SWMgr's methods, it adds the necessary - * filters for the module format. - */ - CSwordBackend(); - /** - * The constructor of the Sword backend. - * @param path The path which is used to load modules - * @param augmentHome True if the $HOME/.sword/ modules should be augmented with the other modules - */ - CSwordBackend( const QString& path, const bool augmentHome = true ); - - /** - * The destrctor of this backend. This function shuts the modules down using @ref shutdownModules. - */ - virtual ~CSwordBackend(); - - /** - * This function returns the list of available modules managed by this backend. - * You have to call initModules() first; - * - * @return The list of modules managed by this backend - */ - inline virtual ListCSwordModuleInfo& moduleList(); - /** - * Initializes the Sword modules. - * - * @return True if the initializiation was succesful, otherwise return false. - */ - virtual const CSwordBackend::LoadError initModules(); - /** - * This function deinitializes the modules and deletes them. - * - * @return True if it was succesful, otherwise return false - */ - virtual const bool shutdownModules(); - /** - * Sets the given options enabled or disabled depending on the second parameter. - * - * @param type This is the type this function should set enabled or disabled - * @param enable If this is true the option will be enabled, otherwise it will be disabled. - */ - void setOption( const CSwordModuleInfo::FilterTypes type, const int state ); - void setFilterOptions( const CSwordBackend::FilterOptions options ); - void setDisplayOptions( const CSwordBackend::DisplayOptions options ); - /** - * Returns true if the given option is enabled. - * - * @return Returns true if the options given as aparameter is switched on at this time, otherwise return false. - */ - virtual const bool isOptionEnabled( const CSwordModuleInfo::FilterTypes type); - /** - * Sets the language for the international booknames of Sword. - * @param langName The abbreviation string which should be used for the Sword backend - */ - const QString booknameLanguage( const QString& langName = QString::null ); - /** - * This function searches for a module with the specified description - * @param description The description of the desired module - * @return pointer to the desired module; null if no module has the specified description - */ - virtual CSwordModuleInfo* const findModuleByDescription(const QString& description); - /** - * This function searches for a module with the specified description - * @param description The description of the desired module - * @return pointer to the desired module; null if no module has the specified description - */ - const QString findModuleNameByDescription(const QString& description); - /** - * This function searches for a module with the specified name - * @param name The name of the desired module - * @return Pointer to the desired module; null if no module has the specified name - */ - CSwordModuleInfo* const findModuleByName(const QString& name); - /** - * This function searches for a module with the specified sword module as module() object! - * @param swmodule to a Sword module - * @return pointer to the desired module; null if no module has the specified name - */ - CSwordModuleInfo* const findSwordModuleByPointer(const sword::SWModule* const swmodule); - /** - * This function searches for a module which is the same as the passed module. - * @param module The module which should be used for searching the new one. May be child of a different backend. - * @return Pointer to the desired module; null if no module has the specified name - */ - CSwordModuleInfo* const findModuleByPointer(const CSwordModuleInfo* const module); - /** - * @return Our global config object which contains the configs of all modules merged together. - */ - inline sword::SWConfig* const getConfig() const; - /** - * Tries to find the config object for the module. The second paramter will be the found config. - * @return True if the config was found, false if not. If false is returned the moduleConfig object is in undefined/unknwon state. - */ - const bool moduleConfig(const QString& module, sword::SWConfig& moduleConfig ); - /** - * Returns the text used for the option given as parameter. - * @param The paramter enum - * @return The name of the option given by the parameter - */ - static const QString optionName( const CSwordModuleInfo::FilterTypes option ); - /** - * Returns the text used for the option given as parameter. - */ - static const QString configOptionName( const CSwordModuleInfo::FilterTypes option ); - /** - * Returns the translated name of the option given as parameter. - * @param The translated option name - */ - static const QString translatedOptionName(const CSwordModuleInfo::FilterTypes option ); - /** - * Returns the version of the Sword library. - * @return The version used by this backend - */ - inline virtual const sword::SWVersion Version(); - /** - * Reload all Sword modules. - */ - void reloadModules(); - /** Sword prefix list. - * @return A list of all known Sword prefix dirs - */ - const QStringList swordDirList(); - -protected: - /** - * Adds a render filter to the module. - * @param module Add a render filter to this module! - */ - virtual void AddRenderFilters(sword::SWModule *module, sword::ConfigEntMap §ion); - /** - * Initializes the filters provided by BibleTime. - */ - virtual void filterInit(); - -private: - // Filters - - struct Filters { - sword::SWFilter *gbf; - sword::SWFilter *plain; - sword::SWFilter *thml; - sword::SWFilter *osis; - } - - m_filters; - - struct Displays { - Rendering::CChapterDisplay* chapter; - Rendering::CEntryDisplay* entry; - Rendering::CBookDisplay* book; - } - - m_displays; - - ListCSwordModuleInfo m_moduleList; - QMap<QString, QString> m_moduleDescriptionMap; -}; - -/**Returns The list of modules managed by this backend*/ -inline ListCSwordModuleInfo& CSwordBackend::moduleList() { - return m_moduleList; -} - -/** Returns our local config object to store the cipher keys etc. locally for each user. The values of the config are merged with the global config. */ -inline sword::SWConfig* const CSwordBackend::getConfig() const { - return config; -} - -/** Returns the version of the Sword library. */ -inline const sword::SWVersion CSwordBackend::Version() { - return sword::SWVersion::currentVersion; -} - -#endif diff --git a/bibletime/backend/cswordbiblemoduleinfo.cpp b/bibletime/backend/cswordbiblemoduleinfo.cpp deleted file mode 100644 index d4a35e8..0000000 --- a/bibletime/backend/cswordbiblemoduleinfo.cpp +++ /dev/null @@ -1,262 +0,0 @@ -/********* -* -* This file is part of BibleTime's source code, http://www.bibletime.info/. -* -* Copyright 1999-2006 by the BibleTime developers. -* The BibleTime source code is licensed under the GNU General Public License version 2.0. -* -**********/ - - - -//BibleTime includes -#include "cswordbiblemoduleinfo.h" -#include "cswordbackend.h" -#include "cswordversekey.h" - -// #include "util/cpointers.h" - -//Qt includes -#include <qfile.h> - -//Sword includes -#include <versekey.h> - -static sword::VerseKey staticKey; - -CSwordBibleModuleInfo::CSwordBibleModuleInfo( sword::SWModule* module, CSwordBackend* const usedBackend ) -: CSwordModuleInfo(module, usedBackend), -m_lowerBound(0), -m_upperBound(0), -m_bookList(0), -m_cachedLocale("unknown"), -m_hasOT(-1), -m_hasNT(-1) {} - -CSwordBibleModuleInfo::CSwordBibleModuleInfo( const CSwordBibleModuleInfo& m ) : -CSwordModuleInfo(m), -m_lowerBound(0), -m_upperBound(0), -m_bookList(0) { - if (m.m_bookList) { - m_bookList = new QStringList(); - *m_bookList = *m.m_bookList; - } - - m_hasOT = m.m_hasOT; - m_hasNT = m.m_hasNT; - m_cachedLocale = m.m_cachedLocale; -} - -CSwordModuleInfo* CSwordBibleModuleInfo::clone() { - return new CSwordBibleModuleInfo(*this); -} - -CSwordBibleModuleInfo::~CSwordBibleModuleInfo() { - delete m_bookList; -} - -void CSwordBibleModuleInfo::initBounds() { - if (m_hasOT == -1) { - m_hasOT = hasTestament(OldTestament); - } - - if (m_hasNT == -1) { - m_hasNT = hasTestament(NewTestament); - } - - if (m_hasOT) { - m_lowerBound.key("Genesis 1:1"); - } - else { - m_lowerBound.key("Matthew 1:1"); - } - - if (!m_hasNT) { - m_upperBound.key("Malachi 4:6"); - } - else { - m_upperBound.key("Revelation of John 22:21"); - } -} - - -/** Returns the books available in this module */ -QStringList* const CSwordBibleModuleInfo::books() { - if (m_cachedLocale != backend()->booknameLanguage()) { //if the locale has changed - delete m_bookList; - m_bookList = 0; - } - - if (!m_bookList) { - m_bookList = new QStringList(); - - initBounds(); - int min = 0; - int max = 1; - - //find out if we have ot and nt, only ot or only nt - - if (m_hasOT>0 && m_hasNT>0) { //both - min = 0; - max = 1; - } - else if (m_hasOT>0 && !m_hasNT) { //only OT - min = 0; - max = 0; - } - else if (!m_hasOT && m_hasNT>0) { //only NT - min = 1; - max = 1; - } - else if (!m_hasOT && !m_hasNT) { //somethings wrong here! - no OT and no NT - qWarning("CSwordBibleModuleInfo (%s) no OT and not NT! Check your config!", module()->Name()); - min = 0; - max = -1; - } - - staticKey.setLocale(sword::LocaleMgr::getSystemLocaleMgr()->getDefaultLocaleName()); - - for (int i = min; i <= max; ++i) { - for ( int j = 0; j < staticKey.BMAX[i]; ++j) { - // if (backend()->useICU()) - // m_bookList->append( QString::fromUtf8(staticKey.books[i][j].name) ); - // else - // m_bookList->append( QString::fromLocal8Bit(staticKey.books[i][j].name) ); - m_bookList->append( QString::fromUtf8(staticKey.books[i][j].name) ); - } - } - - m_cachedLocale = backend()->booknameLanguage(); - } - - return m_bookList; -} - -/** Returns the number of chapters for the given book. */ -const unsigned int CSwordBibleModuleInfo::chapterCount(const unsigned int book) { - int result = 0; - - if ( (book >= 1) && book <= (unsigned int)staticKey.BMAX[0] && hasTestament(OldTestament)) { //Is the book in the old testament? - result = (staticKey.books[0][book-1].chapmax); - } - else if ((book >= 1) && (book - staticKey.BMAX[0]) <= (unsigned int)staticKey.BMAX[1] && hasTestament(NewTestament) ) { //is the book in the new testament? - result = (staticKey.books[1][book-1-staticKey.BMAX[0]].chapmax); - } - - return result; -} - -const unsigned int CSwordBibleModuleInfo::chapterCount(const QString& book) { - return chapterCount( bookNumber(book) ); -} - -/** Returns the number of verses for the given chapter. */ - -const unsigned int CSwordBibleModuleInfo::verseCount( const unsigned int book, const unsigned int chapter ) { - unsigned int result = 0; - - if (book>=1 && (book <= (unsigned int)staticKey.BMAX[0]) && hasTestament(OldTestament) ) { //Is the book in the old testament? - - if (chapter <= chapterCount(book) ) //does the chapter exist? - result = (staticKey.books[0][book-1].versemax[chapter-1]); - } - else if (book>=1 && (book - staticKey.BMAX[0]) <= (unsigned int)staticKey.BMAX[1] && hasTestament(NewTestament)) { //is the book in the new testament? - - if (chapter <= chapterCount(book) ) //does the chapter exist? - result = staticKey.books[1][book-1-staticKey.BMAX[0]].versemax[chapter-1]; - } - - return result; -} - -const unsigned int CSwordBibleModuleInfo::verseCount( const QString& book, const unsigned int chapter ) { - return verseCount( bookNumber(book), chapter ); -} - -const unsigned int CSwordBibleModuleInfo::bookNumber(const QString &book) { - unsigned int bookNumber = 0; - bool found = false; - staticKey.setLocale(sword::LocaleMgr::getSystemLocaleMgr()->getDefaultLocaleName()); - int min = 0; - int max = 1; - - //find out if we have ot and nt, only ot or only nt - initBounds(); - - if ((m_hasOT>0 && m_hasNT>0) || (m_hasOT == m_hasNT == -1)) { - min = 0; - max = 1; - bookNumber = 0; - } - else if (m_hasOT>0 && !m_hasNT) { - min = 0; - max = 0; - bookNumber = 0; - } - else if (!m_hasOT && m_hasNT>0) { - min = 1; - max = 1; - bookNumber = staticKey.BMAX[0]; - } - else if (!m_hasOT && !m_hasNT) { - min = 0; - max = -1; //no loop - bookNumber = 0; - } - - for (int i = min; i <= max && !found; ++i) { - for ( int j = 0; j < staticKey.BMAX[i] && !found; ++j) { - ++bookNumber; - // if (book == QString::fromLocal8Bit( staticKey.books[i][j].name) ) - - if (book == QString::fromUtf8( staticKey.books[i][j].name) ) - found = true; - } - } - - return bookNumber; -} - -/** Returns true if his module has the text of desired type of testament */ -const bool CSwordBibleModuleInfo::hasTestament( CSwordBibleModuleInfo::Testament type ) { - if (m_hasOT == -1 || m_hasNT == -1) { - const bool oldStatus = module()->getSkipConsecutiveLinks(); - module()->setSkipConsecutiveLinks(true); - - *module() = sword::TOP; //position to first entry - sword::VerseKey key( module()->KeyText() ); - - if (key.Testament() == 1) { // OT && NT - m_hasOT = 1; - } - else if (key.Testament() == 2) { //no OT - m_hasOT = 0; - } - - *module() = sword::BOTTOM; - key = module()->KeyText(); - - if (key.Testament() == 1) { // only OT, no NT - m_hasNT = 0; - } - else if (key.Testament() == 2) { //has NT - m_hasNT = 1; - } - - module()->setSkipConsecutiveLinks(oldStatus); - } - - switch (type) { - - case OldTestament: - return m_hasOT>0; - - case NewTestament: - return m_hasNT>0; - - default: - return false; - } -} - diff --git a/bibletime/backend/cswordbiblemoduleinfo.h b/bibletime/backend/cswordbiblemoduleinfo.h deleted file mode 100644 index 1cd3784..0000000 --- a/bibletime/backend/cswordbiblemoduleinfo.h +++ /dev/null @@ -1,132 +0,0 @@ -/********* -* -* This file is part of BibleTime's source code, http://www.bibletime.info/. -* -* Copyright 1999-2006 by the BibleTime developers. -* The BibleTime source code is licensed under the GNU General Public License version 2.0. -* -**********/ - - - -#ifndef CSWORDBIBLEMODULEINFO_H -#define CSWORDBIBLEMODULEINFO_H - -//own includes -#include "cswordmoduleinfo.h" -#include "cswordversekey.h" - -//Qt includes -#include <qstringlist.h> - -//Sword includes - - -/** - * This is the CModuleInfo imlementation for Bible modules managed by Sword. - * - * @short Implementation for Sword Bibles - * @author The BibleTime team - * @version $Id: cswordbiblemoduleinfo.h,v 1.18 2006/02/25 11:38:15 joachim Exp $ - */ - -class CSwordBibleModuleInfo : public CSwordModuleInfo { - -public: - enum Testament { - OldTestament = 1, - NewTestament = 2 - }; - - /** - * The constructor of this class - */ - CSwordBibleModuleInfo( sword::SWModule* module, CSwordBackend* const = CPointers::backend() ); - /** The copy constructor for this Bible module. - */ - CSwordBibleModuleInfo( const CSwordBibleModuleInfo& m ); - /** - * The destructor of this class - */ - ~CSwordBibleModuleInfo(); - /** - * Returns the number of avalable verses for the given chapter and book. - * - * @param book The number book we should use - * @param chapter The chapter we should use - * @return The number of verses for the given book and chapter - */ - virtual const unsigned int verseCount( const unsigned int book, const unsigned int chapter ); - /** - * Returns the number of avalable verses for the given chapter and book. - * - * @param book The name of the book we use - * @param chapter The number of the chapter we use - * @return The number of verses for the given book and chapter - */ - virtual const unsigned int verseCount( const QString& book, const unsigned int chapter ); - /** Information about the chapters in a book. - * @return The number of available chapters of the given book. - * @return The number of chapters for the given book - */ - virtual const unsigned int chapterCount( const unsigned int book ); - /** Information about the chapters in a book. - * @return The number of available chapters of the given book. - */ - virtual const unsigned int chapterCount( const QString& book ); - /** Return all book of this module. - * @return A QStringList containing the books which are available in this module. - */ - virtual QStringList* const books(); - /** - * Reimplementation, Returns the type - */ - virtual const CSwordModuleInfo::ModuleType type() const; - /** - * @return the book number, values starting with 1; 0 if not found - */ - const unsigned int bookNumber(const QString &book); - /** - * Returns true if his module has the text of desired type of testament - */ - const bool hasTestament( CSwordBibleModuleInfo::Testament ); - /** Reimplementation to clone this object. */ - virtual CSwordModuleInfo* clone(); - /** - * Returns the key which represents the lower bound of this module. - */ - inline const CSwordVerseKey& lowerBound(); - /** - * Returns the key which represents the upper bound of this module. - */ - inline const CSwordVerseKey& upperBound(); - -private: - void initBounds(); - - CSwordVerseKey m_lowerBound; - CSwordVerseKey m_upperBound; - - QStringList* m_bookList; //This booklist is cached - QString m_cachedLocale; - short int m_hasOT; - short int m_hasNT; -}; - -inline const CSwordModuleInfo::ModuleType CSwordBibleModuleInfo::type() const { - return CSwordModuleInfo::Bible; -} - -/** Returns the key which represents the lower bound of this module. */ -inline const CSwordVerseKey& CSwordBibleModuleInfo::lowerBound() { - initBounds(); - return m_lowerBound; -} - -/** Returns the key which represents the lower bound of this module. */ -inline const CSwordVerseKey& CSwordBibleModuleInfo::upperBound() { - initBounds(); - return m_upperBound; -} - -#endif diff --git a/bibletime/backend/cswordbookmoduleinfo.cpp b/bibletime/backend/cswordbookmoduleinfo.cpp deleted file mode 100644 index 17cfb28..0000000 --- a/bibletime/backend/cswordbookmoduleinfo.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/********* -* -* This file is part of BibleTime's source code, http://www.bibletime.info/. -* -* Copyright 1999-2006 by the BibleTime developers. -* The BibleTime source code is licensed under the GNU General Public License version 2.0. -* -**********/ - - - -//BibleTime includes -#include "cswordbookmoduleinfo.h" -#include "cswordtreekey.h" - -//Sword includes -#include <treekeyidx.h> -#include <treekey.h> - -#include <iostream> -#include <string> -using std::cout; -using std::endl; - -CSwordBookModuleInfo::CSwordBookModuleInfo( sword::SWModule* module, CSwordBackend* const usedBackend ) -: CSwordModuleInfo(module, usedBackend), -m_depth(-1) {} - -CSwordBookModuleInfo::CSwordBookModuleInfo( const CSwordBookModuleInfo& module ) -: CSwordModuleInfo(module) { - m_depth = module.m_depth; -} - -CSwordBookModuleInfo::~CSwordBookModuleInfo() {} - -const int CSwordBookModuleInfo::depth() { - if (m_depth == -1) { - sword::TreeKeyIdx* key = tree(); - - if (key) { - key->root(); - computeDepth(key, 0); - } - } - - return m_depth; -} - -void CSwordBookModuleInfo::computeDepth(sword::TreeKeyIdx* key, int level ) { - std::string savedKey; - // savedKey = key->getFullName(); //sword 1.5.8 - savedKey = key->getText(); - - if (level > m_depth) { - m_depth = level; - } - - if (key->hasChildren()) { - key->firstChild(); - computeDepth(key, level+1); - - key->setText( savedKey.c_str() );//return to the initial value - } - - if (key->nextSibling()) { - computeDepth(key, level); - } -} - -/** Returns a treekey filled with the structure of this module */ -sword::TreeKeyIdx* const CSwordBookModuleInfo::tree() const { - sword::TreeKeyIdx* treeKey = dynamic_cast<sword::TreeKeyIdx*>((sword::SWKey*)*(module())); - Q_ASSERT(treeKey); - return treeKey; -} diff --git a/bibletime/backend/cswordbookmoduleinfo.h b/bibletime/backend/cswordbookmoduleinfo.h deleted file mode 100644 index 28e9d75..0000000 --- a/bibletime/backend/cswordbookmoduleinfo.h +++ /dev/null @@ -1,67 +0,0 @@ -/********* -* -* This file is part of BibleTime's source code, http://www.bibletime.info/. -* -* Copyright 1999-2006 by the BibleTime developers. -* The BibleTime source code is licensed under the GNU General Public License version 2.0. -* -**********/ - - - -#ifndef CSWORDGENBOOKMODULEINFO_H -#define CSWORDGENBOOKMODULEINFO_H - -//BibleTime includes -#include "cswordmoduleinfo.h" - -//Sword includes -#include <treekeyidx.h> - -/** Class for generic book support - * @author The BibleTime team - */ - -class CSwordBookModuleInfo : public CSwordModuleInfo { - -public: - /** Constructor. - * @param module The module which belongs to this object - * @param backend The parent backend for this book module. - */ - CSwordBookModuleInfo( sword::SWModule* module, CSwordBackend* const backend = CPointers::backend() ); - /** Copy constructor. - * Copy constructor to copy the passed parameter. - * @param module The module which should be copied. - */ - CSwordBookModuleInfo( const CSwordBookModuleInfo& module ); - /** Destructor. - */ - ~CSwordBookModuleInfo(); - /** - * Returns the type of the module. - */ - virtual const CSwordModuleInfo::ModuleType type() const; - /** - * Returns the maximal depth of sections and subsections. - */ - const int depth(); - /** - * @return A treekey filled with the structure of this module. Don't delete the returned key because it's casted from the module object. - */ - sword::TreeKeyIdx* const tree() const; - -private: - /** - * A recursive helper function to help computng the module depth! - */ - void computeDepth(sword::TreeKeyIdx* key, int level = 0 ); - int m_depth; -}; - -inline const CSwordBookModuleInfo::ModuleType CSwordBookModuleInfo::type() const { - return CSwordModuleInfo::GenericBook; -} - - -#endif diff --git a/bibletime/backend/cswordcommentarymoduleinfo.cpp b/bibletime/backend/cswordcommentarymoduleinfo.cpp deleted file mode 100644 index 187ac65..0000000 --- a/bibletime/backend/cswordcommentarymoduleinfo.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/********* -* -* This file is part of BibleTime's source code, http://www.bibletime.info/. -* -* Copyright 1999-2006 by the BibleTime developers. -* The BibleTime source code is licensed under the GNU General Public License version 2.0. -* -**********/ - - - -#include "cswordcommentarymoduleinfo.h" - -#include <string> - -CSwordCommentaryModuleInfo::CSwordCommentaryModuleInfo( sword::SWModule* module, CSwordBackend* const usedBackend) -: CSwordBibleModuleInfo(module, usedBackend) {} - -CSwordCommentaryModuleInfo::~CSwordCommentaryModuleInfo() {} - -/** No descriptions */ -CSwordModuleInfo* CSwordCommentaryModuleInfo::clone() { - return new CSwordCommentaryModuleInfo(*this); -} - -/** Returns true if this module may be written by the write display windows. */ -const bool CSwordCommentaryModuleInfo::isWritable() const { - // qWarning(module()->getConfigEntry("ModDrv")); - //a module is only writable if it's a RawFiles module with writable returning true - - if ( (std::string(module()->getConfigEntry("ModDrv")) == std::string("RawFiles")) && module()->isWritable()) { - return true; - }; - - return false; -} diff --git a/bibletime/backend/cswordcommentarymoduleinfo.h b/bibletime/backend/cswordcommentarymoduleinfo.h deleted file mode 100644 index c387ede..0000000 --- a/bibletime/backend/cswordcommentarymoduleinfo.h +++ /dev/null @@ -1,45 +0,0 @@ -/********* -* -* This file is part of BibleTime's source code, http://www.bibletime.info/. -* -* Copyright 1999-2006 by the BibleTime developers. -* The BibleTime source code is licensed under the GNU General Public License version 2.0. -* -**********/ - - - -#ifndef CSWORDCOMMENTARYMODULEINFO_H -#define CSWORDCOMMENTARYMODULEINFO_H - -//own includes -#include "cswordbiblemoduleinfo.h" - -/** Commentary module implementation. - * This CSwordModule implementation provides access to Sword's commentary modules. - * @author The BibleTime team - * @version $Id: cswordcommentarymoduleinfo.h,v 1.13 2006/02/25 11:38:15 joachim Exp $ - */ - -class CSwordCommentaryModuleInfo : public CSwordBibleModuleInfo { - -public: - CSwordCommentaryModuleInfo( sword::SWModule* module, CSwordBackend* const = CPointers::backend() ); - ~CSwordCommentaryModuleInfo(); - /** Reimplementation to return the commentary type. - */ - virtual const CSwordModuleInfo::ModuleType type() const; - /** Reimplementation to clone the current object. - */ - virtual CSwordModuleInfo* clone(); - /** - * Returns true if this module may be written by the write display windows. - */ - virtual const bool isWritable() const; -}; - -inline const CSwordModuleInfo::ModuleType CSwordCommentaryModuleInfo::type() const { - return CSwordModuleInfo::Commentary; -} - -#endif diff --git a/bibletime/backend/cswordkey.cpp b/bibletime/backend/cswordkey.cpp deleted file mode 100644 index a939162..0000000 --- a/bibletime/backend/cswordkey.cpp +++ /dev/null @@ -1,193 +0,0 @@ -/********* -* -* This file is part of BibleTime's source code, http://www.bibletime.info/. -* -* Copyright 1999-2006 by the BibleTime developers. -* The BibleTime source code is licensed under the GNU General Public License version 2.0. -* -**********/ - - - - -//own includes -#include "cswordkey.h" -#include "cswordmoduleinfo.h" - -#include "cswordversekey.h" -#include "cswordldkey.h" -#include "cswordtreekey.h" - -#include "util/ctoolclass.h" - -//Sword includes -#include <swmodule.h> -#include <swkey.h> -#include <versekey.h> -#include <treekey.h> -#include <treekeyidx.h> - -//Qt includes -#include <qregexp.h> -#include <qstring.h> -#include <qtextcodec.h> - -CSwordKey::CSwordKey(CSwordModuleInfo* const module) : m_module(module) {} - -CSwordKey::CSwordKey(const CSwordKey& k) { - m_module = k.m_module; -} - -const QString CSwordKey::rawText() { - if (!m_module) { - return QString::null; - } - - if (dynamic_cast<sword::SWKey*>(this)) { - char * buffer = new char[strlen(rawKey()) + 1]; - strcpy(buffer, rawKey()); - m_module->module()->getKey()->setText( buffer ); - delete buffer; - } - - if (key().isNull()) { - return QString::null; - } - -// qWarning("rawText: %s", m_module->module()->getRawEntry()); - return QString::fromUtf8( m_module->module()->getRawEntry() ); -} - -const QString CSwordKey::renderedText( const CSwordKey::TextRenderType mode ) { - Q_ASSERT(m_module); - if (!m_module) { - return QString::null; - } - - using namespace sword; - SWKey* const k = dynamic_cast<SWKey*>(this); - - if (k) { - char * buffer = new char[strlen(rawKey()) + 1]; - strcpy(buffer, rawKey()); - VerseKey* vk_mod = dynamic_cast<VerseKey*>(m_module->module()->getKey()); - - if (vk_mod) { - vk_mod->Headings(1); - } - - m_module->module()->getKey()->setText( buffer ); - - if (m_module->type() == CSwordModuleInfo::Lexicon) { - m_module->snap(); - /* In lexicons make sure that our key (e.g. 123) was successfully set to the module, - i.e. the module key contains this key (e.g. 0123 contains 123) */ - - if ( strcasecmp(m_module->module()->getKey()->getText(), buffer) - && !strstr(m_module->module()->getKey()->getText(), buffer) - ) { - qDebug("return an empty key for %s", m_module->module()->getKey()->getText()); - return QString::null; - } - } - delete buffer; - } - - Q_ASSERT(!key().isNull()); - if (!key().isNull()) { //we have valid text - QString text = QString::fromUtf8( m_module->module()->RenderText() ); - - // This is yucky, but if we want strong lexicon refs we have to do it here. - if (m_module->type() == CSwordModuleInfo::Lexicon) { - QString t(text); - QRegExp rx("(GREEK|HEBREW) for 0*([1-9]\\d*)"); // ignore 0's before number - int pos = 0; - while( (pos = rx.search(t, pos)) != -1 ) { - QString language = rx.cap(1); - QString langcode = QString(language.at(0)); // "G" or "H" - QString number = rx.cap(2); - QString paddednumber = number.rightJustify(5, '0'); // Form 00123 - - text.replace( - QRegExp( QString( - "(>[^<>]+)" // Avoid replacing inside tags - "\\b(0*%1)\\b").arg(number) ), // And span around 0's - QString("\\1<span lemma=\"%1%2\"><a href=\"strongs://%3/%4\">\\2</a></span>") - .arg(langcode, paddednumber, language, paddednumber) - ); - pos += rx.matchedLength(); - } - } - - if (mode == HTMLEscaped) { - //we have to encode all UTF-8 in HTML escapes - // go though every character and write down the escaped HTML unicode entity - // form is &#<decimal unicode value here>; - QString ret; - QChar c; - const unsigned int length = text.length(); - - for (unsigned int i = 0; i < length; ++i) { - c = text.at(i); - - if (c.latin1()) { //normal latin1 character - ret.append(c); - } - else {//unicode character, needs to be escaped - ret.append("&#") - .append(c.unicode()) - .append(";"); - } - } - - return ret; - } - else { - return text; - } - } - - return QString::null; -} - -const QString CSwordKey::strippedText() { - if (!m_module) { - return QString::null; - } - - if (/*sword::SWKey* k =*/ dynamic_cast<sword::SWKey*>(this)) { - // m_module->module()->SetKey(k); - //m_module->module()->getKey()->setText( (const char*)key().utf8() ); - char * buffer = new char[strlen(rawKey()) + 1]; - strcpy(buffer, rawKey()); - m_module->module()->getKey()->setText(buffer); - delete buffer; - } - - return QString::fromUtf8( m_module->module()->StripText() ); -} - - -/** This will create a proper key object from a given module */ -CSwordKey* CSwordKey::createInstance( CSwordModuleInfo* const module ) { - if (!module) { - return 0; - } - - switch( module->type() ) { - - case CSwordModuleInfo::Bible://fall through - - case CSwordModuleInfo::Commentary: - return new CSwordVerseKey( (sword::VerseKey *) ( (sword::SWKey *)(*module->module()) ), module ); - - case CSwordModuleInfo::Lexicon: - return new CSwordLDKey( (sword::SWKey *)(*module->module()), module); - - case CSwordModuleInfo::GenericBook: - return new CSwordTreeKey( (sword::TreeKeyIdx*)((sword::SWKey *)(*module->module())), module ); - - default: - return 0; - } -} diff --git a/bibletime/backend/cswordkey.h b/bibletime/backend/cswordkey.h deleted file mode 100644 index 2b549f8..0000000 --- a/bibletime/backend/cswordkey.h +++ /dev/null @@ -1,121 +0,0 @@ -/********* -* -* This file is part of BibleTime's source code, http://www.bibletime.info/. -* -* Copyright 1999-2006 by the BibleTime developers. -* The BibleTime source code is licensed under the GNU General Public License version 2.0. -* -**********/ - - - -#ifndef CSWORDKEY_H -#define CSWORDKEY_H - -//Own includes - - -//Qt includes -#include <qstring.h> -//forward declarations - -class CSwordModuleInfo; - -/** Base class for all keys. - * The base class for all Sword based keys. - * @author The BibleTime team - * @version $Id: cswordkey.h,v 1.28 2007/10/26 18:26:23 jerickson314 Exp $ - */ - -class CSwordKey { - -protected: - /** Constructor. May not be called because this class contains pure virtual methods. - * @param module The module which belongs to this key, may be NULL - */ - CSwordKey(CSwordModuleInfo* const module = 0); //protected constructor, because CSwordKey shouldn't be used (it's an abstract base class). - /** Copy constructor. - */ - CSwordKey(const CSwordKey&); //copy constructor - -public: - enum TextRenderType { - Normal = 0, - HTMLEscaped - }; - /** Destructor. - * Public, not protected like the constructor, because CSwordKey pointers may be deleted by all others. - */ - virtual ~CSwordKey() {} - - ; - - //pure virtual functions - /** Returns the current key. - * @return The current key which belongs to the current object. - */ - virtual const QString key() const = 0; - /** Sets the current key. Sets the key using a utf8 enabled QString. - * @param key The key which should be used to set the current one - */ - virtual const bool key(const QString& key) = 0; - /** Set the key using a utf8-decoded c-string - * @param key The key which should be used to set the current one - */ - virtual const bool key(const char* key) = 0; - /** Clone this object. Clone this current object and return it. - * @return A clone of the current object. - */ - virtual CSwordKey* copy() const = 0; - - //implemented functions - /** Set/get the module. Set and get the module which belongs to this key. - * @return The module which belongs to this key. - */ - inline virtual CSwordModuleInfo* const module(CSwordModuleInfo* const newModule = 0); - /** Returns the raw, unchanged text. Returns the text without any filter modifications, - * just in the way it comes out of the module. - */ - virtual const QString rawText(); - /** Returns the rendered text. Returns the text of the current key after passign it through the - * modules filters. - */ - virtual const QString renderedText( const CSwordKey::TextRenderType mode = CSwordKey::Normal ); - /** Stripped down text. Returns the text after removing all markup tags from it. - */ - virtual const QString strippedText(); - /** - * This returns a new object of the right CSwordKey* implementation - * (e.g. CSwordVerseKey or CSwordLDKey) - * The type is determined by the type of the module. - * @see CSwordModuleInfo, CSwordBibleModuleInfo, CSwordCommentaryModuleInfo, CSwordLexiconModukleInfo - */ - static CSwordKey* createInstance(CSwordModuleInfo * const module); - /** - * The assignment operator for more easy use of the key classes. - */ - inline virtual CSwordKey& operator = ( const QString& ); - -protected: - /** Returns the current key in raw format, for Sword. - * @return The current key which belongs to the current object. - */ - virtual const char* rawKey() const = 0; - CSwordModuleInfo* m_module; //module pointer used by all keys -}; - - -/** The assignment operator for more easy use of the key classes. */ -inline CSwordKey& CSwordKey::operator = ( const QString& newKey ) { - key(newKey); - return *this; -} - -inline CSwordModuleInfo* const CSwordKey::module(CSwordModuleInfo* const newModule) { - if (newModule) { - m_module = newModule; - } - return m_module; -} - -#endif diff --git a/bibletime/backend/cswordldkey.cpp b/bibletime/backend/cswordldkey.cpp deleted file mode 100644 index 0f189e9..0000000 --- a/bibletime/backend/cswordldkey.cpp +++ /dev/null @@ -1,130 +0,0 @@ -/********* -* -* This file is part of BibleTime's source code, http://www.bibletime.info/. -* -* Copyright 1999-2007 by the BibleTime developers. -* The BibleTime source code is licensed under the GNU General Public License version 2.0. -* -**********/ - - - -//BibleTime includes -#include "cswordldkey.h" -#include "cswordlexiconmoduleinfo.h" - -//Qt includes -#include <qtextcodec.h> - -//Sword includes -#include <swmodule.h> -#include <swld.h> -#include <utilstr.h> - - -CSwordLDKey::CSwordLDKey( CSwordModuleInfo* module ) { - if ((m_module = dynamic_cast<CSwordLexiconModuleInfo*>(module))) { - // *(m_module->module()) = TOP; - } - - SWKey::operator = (" "); -} - -/** No descriptions */ -CSwordLDKey::CSwordLDKey( const CSwordLDKey &k ) : CSwordKey(k), SWKey((const char*)k) {} - -/** No descriptions */ -CSwordLDKey::CSwordLDKey( const SWKey *k, CSwordModuleInfo* module) : CSwordKey(module), SWKey(*k) {} - -/** Clones this object by copying the members. */ -CSwordLDKey* CSwordLDKey::copy() const { - return new CSwordLDKey(*this); -} - -/** Sets the module of this key. */ -CSwordModuleInfo* const CSwordLDKey::module(CSwordModuleInfo* const newModule) { - if (newModule && newModule->type() == CSwordModuleInfo::Lexicon) { - const QString oldKey = key(); - m_module = newModule; - key(oldKey); - } - - return m_module; -} - -/** Sets the key of this instance */ -const QString CSwordLDKey::key() const { - - if (!m_module || m_module->isUnicode()) { - return QString::fromUtf8((const char*)*this); - } else { - QTextCodec *codec = QTextCodec::codecForName("CP1252"); - return codec->toUnicode((const char*)*this); - } -} - -const char * CSwordLDKey::rawKey() const { - return (const char*)*this; -} - -const bool CSwordLDKey::key( const QString& newKey ) { - - Q_ASSERT(m_module); - - if (!m_module || m_module->isUnicode()) { - return key((const char*)newKey.utf8()); - } else { - QTextCodec *codec = QTextCodec::codecForName("CP1252"); - return key((const char*)codec->fromUnicode(newKey)); - } -} - - -/** Sets the key of this instance */ -const bool CSwordLDKey::key( const char* newKey ) { - Q_ASSERT(newKey); - - if (newKey) { - SWKey::operator = (newKey); //set the key - - m_module->module()->SetKey(this); - // m_module->module()->getKey()->setText( (const char*)key().utf8() ); - m_module->snap(); - // SWKey::operator = (m_module->module()->KeyText()); - } - - return !Error(); -} - -/** Uses the parameter to returns the next entry afer this key. */ -CSwordLDKey* CSwordLDKey::NextEntry() { - m_module->module()->SetKey(this); //use this key as base for the next one! - - m_module->module()->setSkipConsecutiveLinks(true); - ( *( m_module->module() ) )++; - m_module->module()->setSkipConsecutiveLinks(false); - - key(m_module->module()->KeyText()); - SWKey::operator = (m_module->module()->KeyText()); - - return this; -} - -/** Uses the parameter to returns the next entry afer this key. */ -CSwordLDKey* CSwordLDKey::PreviousEntry() { - m_module->module()->SetKey(this); //use this key as base for the next one! - - m_module->module()->setSkipConsecutiveLinks(true); - ( *( m_module->module() ) )--; - m_module->module()->setSkipConsecutiveLinks(false); - - SWKey::operator = (m_module->module()->KeyText()); - - return this; -} - -/** Assignment operator for more ease of use of this class. */ -CSwordLDKey& CSwordLDKey::operator = (const QString& keyname ) { - key(keyname); - return *this; -} diff --git a/bibletime/backend/cswordldkey.h b/bibletime/backend/cswordldkey.h deleted file mode 100644 index bd6b6ce..0000000 --- a/bibletime/backend/cswordldkey.h +++ /dev/null @@ -1,110 +0,0 @@ -/********* -* -* This file is part of BibleTime's source code, http://www.bibletime.info/. -* -* Copyright 1999-2006 by the BibleTime developers. -* The BibleTime source code is licensed under the GNU General Public License version 2.0. -* -**********/ - - - -#ifndef CSWORDLDKEY_H -#define CSWORDLDKEY_H - - -//own includes -#include "cswordkey.h" -#include "cswordmoduleinfo.h" - -//Qt includes -#include <qstring.h> - -//Sword includes -#include <swkey.h> - -/** - * This class is the implementation of CSwordKey used for dictionaries and lexicons. - * - * CSwordLDKey is the implementation of CKey for Lexicons and dictionaries. - * It provides a simple interface to set the current key, - * to get the text for the key and functions to get the next and previous items - * of the used module in comparision to the current key.<BR> - * Here's an example how to use this class:<BR> - * @code - * CSwordLexiconModuleInfo* m_module = backend()->findModuleByName("ISBE"); - * CSwordLDKey ldKey(m_module); - * ldKey.key("Adam"); - * ldKey.nextEntry(); - * qDebug( QString("The current key is: %1").arg(ldKey.key())); - * @endcode - * - * Please not, that the result will be invalid if use the operator const char* - * on the adress of the object, use something like this - * - * @code - * CSwordLDKey* key = new CSwordLDKey( lexicon_module ); - * const QString keyname = key->getKey(); - * @endcode - * - * @author The BibleTime team - * @version $Id: cswordldkey.h,v 1.25 2007/10/26 18:26:23 jerickson314 Exp $ - */ - -class CSwordLDKey : public CSwordKey, public sword::SWKey { - -public: - /** - * Constructor of CSwordLDKey - */ - CSwordLDKey( CSwordModuleInfo* module ); - /** - * Copy constructor for this key class. - */ - CSwordLDKey( const CSwordLDKey &k ); - /** - * Copy constructor for this key class. - */ - CSwordLDKey( const sword::SWKey *k, CSwordModuleInfo* module); - /** - * Clones this object by copying the members. - */ - virtual CSwordLDKey* copy() const; - /** - * Uses the parameter to returns the next entry afer this key. - */ - CSwordLDKey* NextEntry( void ); - /** - * Uses the parameter to returns the previous entry afer this key. - */ - CSwordLDKey* PreviousEntry( void ); - /** - * Sets the module of this key. - */ - virtual CSwordModuleInfo* const module( CSwordModuleInfo* const module = 0 ); - /** - * Returns the current key as a QString - */ - virtual const QString key() const; - /** - * Set the current key - */ - virtual const bool key( const QString& newKey ); - /** - * Returns the current key as a QString - */ - virtual const bool key( const char* ); - /** - * Assignment operator for more ease of use of this class. - */ - virtual CSwordLDKey& operator = (const QString& keyname ); -protected: - /** - * The raw key for direct use with Sword. - */ - virtual const char * rawKey() const; -}; - - -#endif - diff --git a/bibletime/backend/cswordlexiconmoduleinfo.cpp b/bibletime/backend/cswordlexiconmoduleinfo.cpp deleted file mode 100644 index 26da0e7..0000000 --- a/bibletime/backend/cswordlexiconmoduleinfo.cpp +++ /dev/null @@ -1,183 +0,0 @@ -/********* -* -* This file is part of BibleTime's source code, http://www.bibletime.info/. -* -* Copyright 1999-2006 by the BibleTime developers. -* The BibleTime source code is licensed under the GNU General Public License version 2.0. -* -**********/ - - - -//BibleTime includes -#include "cswordlexiconmoduleinfo.h" -//#include "frontend/cbtconfig.h" - -//Qt includes -#include <qfile.h> -#include <qdatastream.h> -#include <qtextcodec.h> - -//Sword includes -#include <swmodule.h> - -#include <kglobal.h> -#include <kstandarddirs.h> - -//STL includes -#include <algorithm> - -//Change it once the format changed to make all -//systems rebuild their caches -#define CACHE_FORMAT "2" - -CSwordLexiconModuleInfo::CSwordLexiconModuleInfo( sword::SWModule* module, CSwordBackend* const backend ) : CSwordModuleInfo(module, backend) { - m_entryList = 0; -} - -CSwordLexiconModuleInfo::CSwordLexiconModuleInfo( const CSwordLexiconModuleInfo& m ) : CSwordModuleInfo(m) { - delete m_entryList; - m_entryList = 0; - - if (m.m_entryList) { - m_entryList = new QStringList(); - *m_entryList = *m.m_entryList;//copy list items - } -} - -CSwordLexiconModuleInfo::~CSwordLexiconModuleInfo() { - delete m_entryList; - m_entryList = 0; -} - -/** Returns the entries of the module. */ -QStringList* const CSwordLexiconModuleInfo::entries() { - if (!module()) { - return 0; - } - - sword::SWModule* my_module = module(); - bool is_unicode = isUnicode(); - - if (!m_entryList) { - m_entryList = new QStringList(); - bool read = false; - - //Check for buggy modules! They will not be loaded any more. - - if ( name() == QString("ZhEnglish")) { - qWarning("Module ZhEnglish is buggy and will not be loaded."); - return m_entryList; - } - - QString dir( KGlobal::dirs()->saveLocation("data", "bibletime/cache/") ); - QFile f1( - QString(dir) - .append("/") - .append(name()) - ); - - if ( f1.open( IO_ReadOnly ) ) { - QDataStream s( &f1 ); - QString mod_ver, prog_ver; - s >> mod_ver; - s >> prog_ver; - - if ((mod_ver == config(ModuleVersion)) && (prog_ver == CACHE_FORMAT)) { - s >> *m_entryList; - read = true; - } - - f1.close(); - // qWarning("read entries %d",m_entryList->count()); - } - - // Q_ASSERT(read); - // Q_ASSERT(m_entryList->count()); - if (!read || !m_entryList->count()) { - my_module->setSkipConsecutiveLinks(true); - (*my_module) = sword::TOP; - snap(); //snap to top entry - - // qWarning("Reading in module" ); - int i = 0; - - do { - if ( is_unicode ) { - m_entryList->append(QString::fromUtf8(my_module->KeyText())); - // qWarning("Entry: %s", my_module->KeyText() ); - } - else { //for latin1 modules use fromLatin1 because of speed - // m_entryList->append(QString::fromLatin1(my_module->KeyText())); - - QTextCodec *codec = QTextCodec::codecForName("CP1252"); - m_entryList->append(codec->toUnicode(my_module->KeyText())); - } - - (*my_module)++; - i++; - } - while ( !my_module->Error() ); - - // qWarning("Reading finished. Module has %d entries.", i ); - - (*my_module) = sword::TOP; //back to the first entry - - my_module->setSkipConsecutiveLinks(false); - - if (m_entryList->count()) { - m_entryList->first().simplifyWhiteSpace(); - - if (m_entryList->first().stripWhiteSpace().isEmpty()) { - - m_entryList->remove - ( m_entryList->begin() ); - } - - //now sort the list, this is necesssary because Sword doesn't do Unicode ordering - - // qWarning("sorting"); - // QStringList::iterator start(m_entryList->begin()); - // QStringList::iterator end(m_entryList->end()); - // std::sort( start, end, myLocaleAwareCompare() ); //stl sort - // m_entryList->sort(); //make sure the module is sorted by utf-8 - } - - qWarning("Writing cache file."); - - if (m_entryList->count()) { - //create cache - QString dir = KGlobal::dirs()->saveLocation("data", "bibletime/cache/"); - //QFile f2( QString::fromLatin1("%1/%2").arg(dir).arg( name() ) ); - QFile f2( QString(dir).append("/").append(name()) ); - - - if (f2.open( IO_WriteOnly )) { - QDataStream s( &f2 ); - s << config(CSwordModuleInfo::ModuleVersion); //store module version - s << QString(CACHE_FORMAT); //store BT version -- format may change - s << *m_entryList; - f2.close(); - } - } - - // // qWarning("Writing finished." ); - } - } - - return m_entryList; -} - -/** Jumps to the closest entry in the module. */ -const bool CSwordLexiconModuleInfo::snap() { - if(module()->getRawEntry()) { // Snap to the current entry - return true; - } - - return false; -} - -/** No descriptions */ -CSwordModuleInfo* CSwordLexiconModuleInfo::clone() { - return new CSwordLexiconModuleInfo(*this); -} diff --git a/bibletime/backend/cswordlexiconmoduleinfo.h b/bibletime/backend/cswordlexiconmoduleinfo.h deleted file mode 100644 index 8b8e8fe..0000000 --- a/bibletime/backend/cswordlexiconmoduleinfo.h +++ /dev/null @@ -1,73 +0,0 @@ -/********* -* -* This file is part of BibleTime's source code, http://www.bibletime.info/. -* -* Copyright 1999-2006 by the BibleTime developers. -* The BibleTime source code is licensed under the GNU General Public License version 2.0. -* -**********/ - - - -#ifndef CSWORDLEXICONMODULEINFO_H -#define CSWORDLEXICONMODULEINFO_H - -//own includes -#include "cswordmoduleinfo.h" - -//Qt includes -#include <qstringlist.h> - -/** - * The implementation of CModuleInfo for the Sword lexiccons and citionaries. - * @author The BibleTime team - * @version $Id: cswordlexiconmoduleinfo.h,v 1.12 2006/02/25 11:38:15 joachim Exp $ - */ - -class CSwordLexiconModuleInfo : public CSwordModuleInfo { - -public: - /** - * The standard constructor fot this object. - * A default constructor doesn't exist. Use this one. - */ - CSwordLexiconModuleInfo( sword::SWModule* module, CSwordBackend* const = CPointers::backend() ); - /** - * The copy constructor - */ - CSwordLexiconModuleInfo( const CSwordLexiconModuleInfo& m ); - /** Reimplementation to return a valid clone. - */ - virtual CSwordModuleInfo* clone(); - /** Destructor. - */ - virtual ~CSwordLexiconModuleInfo(); - /** - * Returns the entries of the module. - * This function returns the entries of the modules represented by this object. - * If this function is called for the first time the list is load from disk and stored in a list which cahes it. - * If the function is called again, the cached list is returned so we have a major speed improvement. - * @return The list of lexicon entries - */ - QStringList* const entries(); - /** - * Reimplementation, to return the right type for this lexicon. - */ - virtual const CSwordModuleInfo::ModuleType type() const; - /** - * Jumps to the closest entry in the module. - */ - const bool snap(); - -private: - /** - * This is the list which caches the entres of the module. - */ - QStringList* m_entryList; -}; - -inline const CSwordModuleInfo::ModuleType CSwordLexiconModuleInfo::type() const { - return CSwordModuleInfo::Lexicon; -} - -#endif diff --git a/bibletime/backend/cswordmoduleinfo.cpp b/bibletime/backend/cswordmoduleinfo.cpp deleted file mode 100644 index cb37426..0000000 --- a/bibletime/backend/cswordmoduleinfo.cpp +++ /dev/null @@ -1,888 +0,0 @@ -/********* -* -* This file is part of BibleTime's source code, http://www.bibletime.info/. -* -* Copyright 1999-2006 by the BibleTime developers. -* The BibleTime source code is licensed under the GNU General Public License version 2.0. -* -**********/ - -//BibleTime includes -#include "cswordmoduleinfo.h" -#include "cswordbackend.h" -#include "cswordmodulesearch.h" -#include "cswordkey.h" -#include "centrydisplay.h" -#include "clanguagemgr.h" - -#include "util/scoped_resource.h" -#include "util/directoryutil.h" -#include "util/cpointers.h" -#include "frontend/cbtconfig.h" - -#include <sys/types.h> -#include <unistd.h> -#include <stddef.h> -#include <dirent.h> -#include <regex.h> - -//Qt includes -#include <qregexp.h> -#include <qdir.h> -#include <qvariant.h> -#include <qfileinfo.h> - -//KDE includes -#include <klocale.h> -#include <kglobal.h> -#include <kstandarddirs.h> -#include <kconfig.h> - -//Sword includes -#include <swbuf.h> -#include <swkey.h> -#include <listkey.h> -#include <versekey.h> -#include <swconfig.h> -#include <rtfhtml.h> - -//Lucence includes -#include <CLucene.h> -#include <CLucene/util/Reader.h> -#include <CLucene/util/Misc.h> -#include <CLucene/util/dirent.h> - -//Increment this, if the index format changes -//Then indices on the user's systems will be rebuilt -const unsigned int INDEX_VERSION = 6; - -//Maximum index entry size, 1MiB for now -//Lucene default is too small -const unsigned long BT_MAX_LUCENE_FIELD_LENGTH = 1024*1024; - -CSwordModuleInfo::CSwordModuleInfo(sword::SWModule * module, CSwordBackend * const usedBackend) { - m_module = module; - Q_ASSERT(module); - - m_searchResult.ClearList(); - m_backend = usedBackend ? usedBackend : CPointers::backend(); - m_dataCache.name = module ? QString(module->Name()) : QString::null; - m_dataCache.isUnicode = module ? module->isUnicode() : false; - m_dataCache.category = UnknownCategory; - m_dataCache.language = 0; - m_dataCache.hasVersion = !QString((*m_backend->getConfig())[module->Name()]["Version"]).isEmpty(); - - if (backend()) { - if (hasVersion() && (minimumSwordVersion() > sword::SWVersion::currentVersion)) { - qWarning("The module \"%s\" requires a newer Sword library. Please update to \"Sword %s\".", - name().latin1(), (const char *)minimumSwordVersion()); - } - } -} - -CSwordModuleInfo::CSwordModuleInfo(const CSwordModuleInfo & m) { - m_module = m.m_module; - m_backend = m.m_backend; - m_dataCache = m.m_dataCache; - m_searchResult = m.m_searchResult; -} - -/** No descriptions */ -CSwordModuleInfo *CSwordModuleInfo::clone() { - return new CSwordModuleInfo(*this); -} - -CSwordModuleInfo::~CSwordModuleInfo() { - m_searchResult.ClearList(); - m_module = 0; //the Sword module object is deleted by the backend -} - -/** Sets the unlock key of the modules and writes the key into the cofig file.*/ -const bool CSwordModuleInfo::unlock(const QString & unlockKey) { - if (!isEncrypted()) { - return false; - } - - CBTConfig::setModuleEncryptionKey(name(), unlockKey); - backend()->setCipherKey(m_module->Name(), unlockKey.latin1()); - //TODO: write to Sword config as well - - return true; -} - -/** This function returns true if this module is locked, otherwise return false. */ -const bool CSwordModuleInfo::isLocked() { - //still works, but the cipherkey is stored in CBTConfig. - //Works because it is set in sword on program startup. - - if (isEncrypted()) { - if (unlockKeyIsValid()) { - return false; - } - return true; - } - return false; -} - -/** This functions returns true if this module is encrypted (locked or unlocked). */ -const bool CSwordModuleInfo::isEncrypted() const { - /** - * If we have the CipherKey entry the module - * is encrypted but not necessarily locked - */ - - //This code is still right, though we do no longer write to the module config files any more - sword::ConfigEntMap config = backend()->getConfig()->Sections.find(name().latin1())->second; - sword::ConfigEntMap::iterator it = config.find("CipherKey"); - - if (it != config.end()) { - return true; - } - - return false; -} - -/** This function makes an estimate if a module was properly unlocked. - * It returns true if the first entry of the module (parsed as Latin1 - * byte sequence) is not empty and contains only printable characters. - * If that is the case, we can safely assume that a) the module was properly - * unlocked and b) no buffer overflows will occur, which can happen when - * Sword filters process garbage text which was not properly decrypted. -*/ -const bool CSwordModuleInfo::unlockKeyIsValid() { - - (*m_module) = sword::TOP; - - // This needs to use ::fromLatin1 because if the text is still locked, - // a lot of garbage will show up. It will also work with properly decrypted - // Unicode text, because all non-ASCII Unicode chars consist of bytes >127 - // and therefore contain no control (nonprintable) characters, which are all <127. - QString test = isUnicode() - ? QString::fromUtf8(m_module->getRawEntryBuf().c_str()) - : QString::fromLatin1( m_module->getRawEntryBuf().c_str() ); - - if (test.isEmpty()) { - qWarning("Unlock key of module %s is NOT valid", name().latin1()); - return false; - } - - for (unsigned int i = 0; i <= test.length(); i++) { - if ( !test[i].isPrint() && !test[i].isNull() ) { - qWarning("Unlock key of module %s is NOT valid", name().latin1()); - return false; - } - } - - qDebug("Unlock key of module %s is valid", name().latin1()); - return true; -} - -const QString CSwordModuleInfo::getGlobalBaseIndexLocation() { - return KGlobal::dirs()->saveLocation("data", "bibletime/indices"); -} - -const QString CSwordModuleInfo::getModuleBaseIndexLocation() const { - return getGlobalBaseIndexLocation() + QString("/") + name().ascii(); -} - -const QString CSwordModuleInfo::getModuleStandardIndexLocation() const { //this for now returns the location of the main index - return getModuleBaseIndexLocation() + QString("/standard"); -} - -const bool CSwordModuleInfo::hasIndex() { //this will return true only - //if the index exists and has correct version information for both index and module - - QDir d; - if (!d.exists( getModuleStandardIndexLocation() )) { - return false; - } - - //first check if the index version and module version are ok - util::scoped_ptr<KConfig> indexconfig( - new KConfig( getModuleBaseIndexLocation() + QString("/bibletime-index.conf") ) - ); - - if (hasVersion()) { - if (indexconfig->readEntry("module-version") != QString(config(CSwordModuleInfo::ModuleVersion)) ) { - return false; - } - } - if (indexconfig->readEntry("index-version") != QString::number( INDEX_VERSION )) { - qDebug("%s: INDEX_VERSION is not compatible with this version of BibleTime.", name().latin1()); - return false; - } - - //then check if the index is there - return lucene::index::IndexReader::indexExists(getModuleStandardIndexLocation().ascii()); -} - - -void CSwordModuleInfo::buildIndex() { - wchar_t wcharBuffer[BT_MAX_LUCENE_FIELD_LENGTH + 1]; - - //we don't want the linked entries indexed again - module()->setSkipConsecutiveLinks(true); - - //Without this we don't get strongs, lemmas, etc - backend()->setFilterOptions ( CBTConfig::getFilterOptionDefaults() ); - //make sure we reset all important filter options which influcence the plain filters. - backend()->setOption( CSwordModuleInfo::strongNumbers, false ); - backend()->setOption( CSwordModuleInfo::morphTags, false ); - backend()->setOption( CSwordModuleInfo::morphSegmentation, false ); - backend()->setOption( CSwordModuleInfo::footnotes, false ); - backend()->setOption( CSwordModuleInfo::headings, false ); - backend()->setOption( CSwordModuleInfo::scriptureReferences, false ); - backend()->setOption( CSwordModuleInfo::redLetterWords, false ); - - // do not use any stop words - const TCHAR* stop_words[] = { - NULL - }; - lucene::analysis::standard::StandardAnalyzer an( stop_words ); - QString index = getModuleStandardIndexLocation(); - - QDir dir; - dir.mkdir( getGlobalBaseIndexLocation(), true ); - dir.mkdir( getModuleBaseIndexLocation(), true ); - dir.mkdir( getModuleStandardIndexLocation(), true ); - - - if (lucene::index::IndexReader::indexExists(index.ascii())) { - if (lucene::index::IndexReader::isLocked(index.ascii()) ) { - lucene::index::IndexReader::unlock(index.ascii()); - } - } - - util::scoped_ptr<lucene::index::IndexWriter> writer( new lucene::index::IndexWriter(index.ascii(), &an, true) ); //always create a new index - writer->setMaxFieldLength(BT_MAX_LUCENE_FIELD_LENGTH); - writer->setUseCompoundFile(true); //merge segments into a single file - writer->setMinMergeDocs(1000); - - *m_module = sword::TOP; - unsigned long verseLowIndex = m_module->Index(); - *m_module = sword::BOTTOM; - unsigned long verseHighIndex = m_module->Index(); - - //verseLowIndex is not 0 in all cases (i.e. NT-only modules) - unsigned long verseIndex = verseLowIndex + 1; - - - const bool isVerseModule = (type() == CSwordModuleInfo::Bible) || (type() == CSwordModuleInfo::Commentary); - - m_indexingProgress.setValue( QVariant((int)0) ); - m_indexingProgress.activate(); - - SWKey* key = m_module->getKey(); - //VerseKey for bibles - VerseKey* vk = dynamic_cast<VerseKey*>(key); - - if (vk) { - // we have to be sure to insert the english key into the index, otherwise we'd be in trouble if the language changes - vk->setLocale("en_US"); - //If we have a verse based module, we want to include the pre-chapter etc. headings in the search - vk->Headings(1); - } - - //holds UTF-8 data and is faster than QString - QCString textBuffer; - - // we start with the first module entry, key is automatically updated - // because key is a pointer to the modules key - for (*m_module = sword::TOP; !(key->Error()); (*key)++) { - - //If it is a sword-heading, store in buffer and index later in Verse X:1 - if (vk) { - if (vk->Verse() == 0) { - //qWarning("key is %s", key->getText()); - //qWarning("text is %s", m_module->StripText()); - textBuffer.append( m_module->StripText() ); - continue; - } - } - - util::scoped_ptr<lucene::document::Document> doc(new lucene::document::Document()); - - //index the key - lucene_utf8towcs(wcharBuffer, key->getText(), BT_MAX_LUCENE_FIELD_LENGTH); - doc->add(*lucene::document::Field::UnIndexed(_T("key"), wcharBuffer)); - - // index the main text - //at this point we have to make sure we disabled the strongs and the other options - //so the plain filters won't include the numbers somehow. - lucene_utf8towcs(wcharBuffer, (const char*) textBuffer.append(m_module->StripText()), BT_MAX_LUCENE_FIELD_LENGTH); - doc->add(*lucene::document::Field::UnStored(_T("content"), wcharBuffer)); - textBuffer.resize(0); //clean up - - // index attributes - AttributeList::iterator attListI; - AttributeValue::iterator attValueI; - // Footnotes - for (attListI = m_module->getEntryAttributes()["Footnote"].begin(); - attListI != m_module->getEntryAttributes()["Footnote"].end(); - attListI++) { - lucene_utf8towcs(wcharBuffer, attListI->second["body"], BT_MAX_LUCENE_FIELD_LENGTH); - doc->add(*lucene::document::Field::UnStored(_T("footnote"), wcharBuffer)); - } // for attListI - - // Headings - for (attValueI = m_module->getEntryAttributes()["Heading"]["Preverse"].begin(); - attValueI != m_module->getEntryAttributes()["Heading"]["Preverse"].end(); - attValueI++) { - lucene_utf8towcs(wcharBuffer, attValueI->second, BT_MAX_LUCENE_FIELD_LENGTH); - doc->add(*lucene::document::Field::UnStored(_T("heading"), wcharBuffer)); - } // for attValueI - - // Strongs/Morphs - for (attListI = m_module->getEntryAttributes()["Word"].begin(); - attListI != m_module->getEntryAttributes()["Word"].end(); - attListI++) { - // for each attribute - if (attListI->second["LemmaClass"] == "strong") { - lucene_utf8towcs(wcharBuffer, attListI->second["Lemma"], BT_MAX_LUCENE_FIELD_LENGTH); - doc->add(*lucene::document::Field::UnStored(_T("strong"), wcharBuffer)); - //qWarning("Adding strong %s", attListI->second["Lemma"].c_str()); - } - if (attListI->second.find("Morph") != attListI->second.end()) { - lucene_utf8towcs(wcharBuffer, attListI->second["Morph"], BT_MAX_LUCENE_FIELD_LENGTH); - doc->add(*lucene::document::Field::UnStored(_T("morph"), wcharBuffer)); - } - } // for attListI - - writer->addDocument(doc); - verseIndex = m_module->Index(); - - if (verseIndex % 200 == 0) { - if (verseHighIndex == verseLowIndex) { //prevent division by zero - m_indexingProgress.setValue( QVariant(0) ); - } else { - m_indexingProgress.setValue( QVariant((int)((100*(verseIndex-verseLowIndex))/(verseHighIndex-verseLowIndex))) ); - } - m_indexingProgress.activate(); - } - } - - writer->optimize(); - writer->close(); - - QString configFilename = getModuleStandardIndexLocation() + QString("/../bibletime-index.conf"); - util::scoped_ptr<KConfig> indexconfig( new KConfig( configFilename ) ); - if (hasVersion()) { - indexconfig->writeEntry("module-version", config(CSwordModuleInfo::ModuleVersion) ); - } - indexconfig->writeEntry("index-version", INDEX_VERSION); -} - -void CSwordModuleInfo::deleteIndexForModule( QString name ) { - util::filesystem::DirectoryUtil::removeRecursive( getGlobalBaseIndexLocation() + "/" + name ); -} - -unsigned long CSwordModuleInfo::indexSize() const { - return util::filesystem::DirectoryUtil::getDirSizeRecursive( getModuleBaseIndexLocation() ); -} - - -const bool CSwordModuleInfo::searchIndexed(const QString& searchedText, sword::ListKey& scope) { - char utfBuffer[BT_MAX_LUCENE_FIELD_LENGTH + 1]; - wchar_t wcharBuffer[BT_MAX_LUCENE_FIELD_LENGTH + 1]; - - // work around Swords thread insafety for Bibles and Commentaries - util::scoped_ptr < CSwordKey > key(CSwordKey::createInstance(this)); - sword::SWKey* s = dynamic_cast < sword::SWKey * >(key.get()); - QPtrList<VerseKey> list; - list.setAutoDelete( true ); // the list owns the objects - - const bool isVerseModule = (type() == CSwordModuleInfo::Bible) || (type() == CSwordModuleInfo::Commentary); - - if (s) { - m_module->SetKey(*s); - } - - m_searchResult.ClearList(); - - try { - // do not use any stop words - const TCHAR* stop_words[] = { - NULL - }; - lucene::analysis::standard::StandardAnalyzer analyzer( stop_words ); - lucene::search::IndexSearcher searcher(getModuleStandardIndexLocation().ascii()); - lucene_utf8towcs(wcharBuffer, searchedText.utf8(), BT_MAX_LUCENE_FIELD_LENGTH); - util::scoped_ptr<lucene::search::Query> q( lucene::queryParser::QueryParser::parse(wcharBuffer, _T("content"), &analyzer) ); - - util::scoped_ptr<lucene::search::Hits> h( searcher.search(q, lucene::search::Sort::INDEXORDER) ); - - const bool useScope = (scope.Count() > 0); -// const bool isVerseModule = (type() == CSwordModuleInfo::Bible) || (type() == CSwordModuleInfo::Commentary); - - lucene::document::Document* doc = 0; - util::scoped_ptr<SWKey> swKey( module()->CreateKey() ); - - - for (int i = 0; i < h->length(); ++i) { - doc = &h->doc(i); - lucene_wcstoutf8(utfBuffer, doc->get(_T("key")), BT_MAX_LUCENE_FIELD_LENGTH); - - swKey->setText(utfBuffer); - - // limit results based on scope - //if (searchOptions & CSwordModuleSearch::useScope && scope.Count() > 0){ - if (useScope) { - for (int j = 0; j < scope.Count(); j++) { - VerseKey* vkey = dynamic_cast<VerseKey*>(scope.getElement(j)); - if (vkey->LowerBound().compare(*swKey) <= 0 && vkey->UpperBound().compare(*swKey) >= 0) { - m_searchResult.add(*swKey); - } - } - } else { // no scope, give me all buffers - m_searchResult.add(*swKey); - } - } - } catch (...) { - qWarning("CLucene exception"); - return false; - } - - list.clear(); - - return (m_searchResult.Count() > 0); -} - -void CSwordModuleInfo::connectIndexingFinished(QObject* receiver, const char* slot) { - m_indexingFinished.connect(receiver, slot); -} - -void CSwordModuleInfo::connectIndexingProgress(QObject* receiver, const char* slot) { - m_indexingProgress.connect(receiver, slot); -} - -void CSwordModuleInfo::disconnectIndexingSignals(QObject* receiver) { - m_indexingProgress.disconnect(receiver); - m_indexingFinished.disconnect(receiver); -} - -/** Returns the last search result for this module. */ -sword::ListKey & CSwordModuleInfo::searchResult(const sword::ListKey * newResult) { - if (newResult) { - m_searchResult.copyFrom(*newResult); - } - - return m_searchResult; -} - -/** Clears the last search result. */ -void CSwordModuleInfo::clearSearchResult() { - m_searchResult.ClearList(); -} - -/** Returns the required Sword version for this module. Returns -1 if no special Sword version is required. */ -const sword::SWVersion CSwordModuleInfo::minimumSwordVersion() { - return sword::SWVersion(config(CSwordModuleInfo::MinimumSwordVersion).latin1()); -} - -const QString CSwordModuleInfo::config(const CSwordModuleInfo::ConfigEntry entry) const { - switch (entry) { - - case AboutInformation: { - return getFormattedConfigEntry("About"); - } - - case CipherKey: { - if (CBTConfig::getModuleEncryptionKey(name()).isNull()) { //fall back! - return QString(m_module->getConfigEntry("CipherKey")); - } else { - return CBTConfig::getModuleEncryptionKey(name()); - }; - } - - case AbsoluteDataPath: { - QString path( getSimpleConfigEntry("AbsoluteDataPath") ); - path.replace(QRegExp("/./"), "/"); // make /abs/path/./modules/ looking better - //make sure we have a trailing slash! - - if (path.right(1) != "/") { - path.append('/'); - } - - return path; - } - - case DataPath: { //make sure we remove the dataFile part if it's a Lexicon - QString path(getSimpleConfigEntry("DataPath")); - - if ((type() == CSwordModuleInfo::GenericBook) || (type() == CSwordModuleInfo::Lexicon)) { - int pos = path.findRev("/"); //last slash in the string - - if (pos != -1) { - path = path.left(pos + 1); //include the slash - } - } - - return path; - } - - case Description: - return getFormattedConfigEntry("Description"); - - case ModuleVersion: { - QString version(getSimpleConfigEntry("Version")); - - if (version.isEmpty()) { - version = "1.0"; - } - - return version; - } - - case MinimumSwordVersion: { - const QString minimumVersion(getSimpleConfigEntry("MinimumVersion")); - return !minimumVersion.isEmpty()? minimumVersion : QString("0.0"); - } - - case TextDir: { - const QString dir(getSimpleConfigEntry("Direction")); - return !dir.isEmpty()? dir : QString("LtoR"); - } - - case DisplayLevel: { - const QString level(getSimpleConfigEntry("DisplayLevel")); - return !level.isEmpty()? level : QString("1"); - } - - case GlossaryFrom: { - if (!category() == Glossary) { - return QString::null; - }; - - const QString lang(getSimpleConfigEntry("GlossaryFrom")); - - return !lang.isEmpty()? lang : QString::null; - } - - case GlossaryTo: { - if (!category() == Glossary) { - return QString::null; - }; - - const QString lang(getSimpleConfigEntry("GlossaryTo")); - - return !lang.isEmpty()? lang : QString::null; - } - - case Markup: { - const QString markup(getSimpleConfigEntry("SourceType")); - return !markup.isEmpty()? markup : QString("Unknown"); - } - - case DistributionLicense: - return getSimpleConfigEntry("DistributionLicense"); - - case DistributionSource: - return getSimpleConfigEntry("DistributionSource"); - - case DistributionNotes: - return getSimpleConfigEntry("DistributionNotes"); - - case TextSource: - return getSimpleConfigEntry("TextSource"); - - case CopyrightNotes: - return getSimpleConfigEntry("CopyrightNotes"); - - case CopyrightHolder: - return getSimpleConfigEntry("CopyrightHolder"); - - case CopyrightDate: - return getSimpleConfigEntry("CopyrightDate"); - - case CopyrightContactName: - return getSimpleConfigEntry("CopyrightContactName"); - - case CopyrightContactAddress: - return getSimpleConfigEntry("CopyrightContactAddress"); - - case CopyrightContactEmail: - return getSimpleConfigEntry("CopyrightContactEmail"); - - default: - return QString::null; - } -} - -/** Returns true if the module supports the feature given as parameter. */ -const bool CSwordModuleInfo::has(const CSwordModuleInfo::Feature feature) const { - switch (feature) { - - // case StrongsNumbers: - // return m_module->getConfig().has("Feature", "StrongsNumber"); - - case GreekDef: - return m_module->getConfig().has("Feature", "GreekDef"); - - case HebrewDef: - return m_module->getConfig().has("Feature", "HebrewDef"); - - case GreekParse: - return m_module->getConfig().has("Feature", "GreekParse"); - - case HebrewParse: - return m_module->getConfig().has("Feature", "HebrewParse"); - } - - return false; -} - -const bool CSwordModuleInfo::has(const CSwordModuleInfo::FilterTypes option) const { - //BAD workaround to see if the filter is GBF, OSIS or ThML! - const QString name = backend()->configOptionName(option); - - if (m_module->getConfig().has("GlobalOptionFilter", QString("OSIS").append(name).latin1())) { - return true; - } - - if (m_module->getConfig().has("GlobalOptionFilter", QString("GBF").append(name).latin1())) { - return true; - } - - if (m_module->getConfig().has("GlobalOptionFilter", QString("ThML").append(name).latin1())) { - return true; - } - - if (m_module->getConfig().has("GlobalOptionFilter", QString("UTF8").append(name).latin1())) { - return true; - } - - if (m_module->getConfig().has("GlobalOptionFilter", name.latin1())) { - return true; - } - - return false; -} - -/** Returns the text direction of the module's text., */ -const CSwordModuleInfo::TextDirection CSwordModuleInfo::textDirection() { - if (config(TextDir) == "RtoL") { - return CSwordModuleInfo::RightToLeft; - } else { - return CSwordModuleInfo::LeftToRight; - } -} - -/** Writes the new text at the given position into the module. This does only work for writable modules. */ -void CSwordModuleInfo::write(CSwordKey * key, const QString & newText) { - module()->KeyText((const char *)key->key().utf8()); - - //don't store a pointer to the const char* value somewhere because QCString doesn't keep the value of it - module()->setEntry(isUnicode()? (const char *)newText.utf8() : (const char *)newText.local8Bit()); -} - -/** Deletes the current entry and removes it from the module. */ -const bool CSwordModuleInfo::deleteEntry(CSwordKey * const key) { - module()->KeyText(isUnicode()? (const char *)key->key().utf8() : (const char *)key->key().local8Bit()); - - if (module()) { - module()->deleteEntry(); - return true; - }; - - return false; -} - -/** Returns the category of this module. See CSwordModuleInfo::Category for possible values. */ -const CSwordModuleInfo::Category CSwordModuleInfo::category() const { - if (m_dataCache.category == CSwordModuleInfo::UnknownCategory) { - const QString cat(m_module->getConfigEntry("Category")); - - if (cat == "Cults / Unorthodox / Questionable Material") { - m_dataCache.category = Cult; - } else if (cat == "Daily Devotional" || m_module->getConfig().has("Feature", "DailyDevotion")) { - m_dataCache.category = DailyDevotional; - } else if (cat == "Glossaries" || m_module->getConfig().has("Feature", "Glossary")) { //alow both - m_dataCache.category = Glossary; - }; - } - - return m_dataCache.category; -} - -/** Returns the display object for this module. */ -Rendering::CEntryDisplay * const CSwordModuleInfo::getDisplay() const { - return dynamic_cast < Rendering::CEntryDisplay * >(m_module->Disp()); -} - -QString CSwordModuleInfo::aboutText() const { - QString text; - text += "<font size=\"-1\"><table>"; - - text += QString("<tr><td><b>%1</b></td><td>%2</td><tr>") - .arg(i18n("Version")) - .arg(hasVersion()? config(CSwordModuleInfo::ModuleVersion) : i18n("unknown")); - - text += QString("<tr><td><b>%1</b></td><td>%2</td></tr>") - .arg(i18n("Markup")) - .arg(!QString(m_module->getConfigEntry("SourceType")).isEmpty()? m_module-> - getConfigEntry("SourceType") : i18n("unknown")); - - text += QString("<tr><td><b>%1</b></td><td>%2</td></tr>") - .arg(i18n("Location")) - .arg(config(CSwordModuleInfo::AbsoluteDataPath)); - - text += QString("<tr><td><b>%1</b></td><td>%2</td></tr>") - .arg(i18n("Language")) - .arg(language()->translatedName()); - - if (m_module->getConfigEntry("Category")) - text += QString("<tr><td><b>%1</b></td><td>%2</td></tr>") - .arg(i18n("Category")) - .arg(m_module->getConfigEntry("Category")); - - if (m_module->getConfigEntry("LCSH")) - text += QString("<tr><td><b>%1</b></td><td>%2</td></tr>") - .arg(i18n("LCSH")) - .arg(m_module->getConfigEntry("LCSH")); - - text += QString("<tr><td><b>%1</b></td><td>%2</td></tr>") - .arg(i18n("Writable")) - .arg(isWritable()? i18n("yes") : i18n("no")); - - if (isEncrypted()) - text += QString("<tr><td><b>%1</b></td><td>%2</td></tr>") - .arg(i18n("Unlock key")) - .arg(config(CSwordModuleInfo::CipherKey)); - - QString options; - - unsigned int opts; - - for (opts = CSwordModuleInfo::filterTypesMIN; opts <= CSwordModuleInfo::filterTypesMAX; ++opts) { - if (has(static_cast < CSwordModuleInfo::FilterTypes > (opts))) { - if (!options.isEmpty()) { - options += QString::fromLatin1(", "); - } - - options += CSwordBackend::translatedOptionName(static_cast < CSwordModuleInfo::FilterTypes > (opts)); - } - } - - if (!options.isEmpty()) { - text += QString("<tr><td><b>%1</b></td><td>%2</td></tr>") - .arg(i18n("Features")) - .arg(options); - } - - text += "</table><hr>"; - - if (category() == Cult) //clearly say the module contains cult/questionable materials - text += QString("<br/><b>%1</b><br/><br/>") - .arg(i18n("Take care, this work contains cult / questionable material!")); - - text += QString("<b>%1:</b><br><font size=\"-1\">%2</font>") - .arg(i18n("About")) - .arg(config(AboutInformation)); - - typedef QValueList<CSwordModuleInfo::ConfigEntry> ListConfigEntry; - - ListConfigEntry entries; - - entries.append(DistributionLicense); - - entries.append(DistributionSource); - - entries.append(DistributionNotes); - - entries.append(TextSource); - - entries.append(CopyrightNotes); - - entries.append(CopyrightHolder); - - entries.append(CopyrightDate); - - entries.append(CopyrightContactName); - - entries.append(CopyrightContactAddress); - - entries.append(CopyrightContactEmail); - - typedef QMap<CSwordModuleInfo::ConfigEntry, QString> MapConfigEntry; - - MapConfigEntry entryMap; - - entryMap[DistributionLicense] = i18n("Distribution license"); - - entryMap[DistributionSource] = i18n("Distribution source"); - - entryMap[DistributionNotes] = i18n("Distribution notes"); - - entryMap[TextSource] = i18n("Text source"); - - entryMap[CopyrightNotes] = i18n("Copyright notes"); - - entryMap[CopyrightHolder] = i18n("Copyright holder"); - - entryMap[CopyrightDate] = i18n("Copyright date"); - - entryMap[CopyrightContactName] = i18n("Copyright contact name"); - - entryMap[CopyrightContactAddress] = i18n("Copyright contact address"); - - entryMap[CopyrightContactEmail] = i18n("Copyright contact email"); - - text += ("<hr><table>"); - - for (ListConfigEntry::iterator it(entries.begin()); it != entries.end(); ++it) { - QString t( config(*it) ); - - if (!t.isEmpty()) { - text += QString("<tr><td><b>%1</b></td><td>%2</td></tr>") - .arg(entryMap[*it]) - .arg(config(*it)); - } - - } - - - text += "</table></font>"; - - return text; -} - -/** Returns the language of the module. */ -const CLanguageMgr::Language * const CSwordModuleInfo::language() const { - if (!m_dataCache.language) { - if (module()) { - if (category() == Glossary) { - //special handling for glossaries, we use the "from language" as language for the module - m_dataCache.language = (CPointers::languageMgr())->languageForAbbrev(config(GlossaryFrom)); - } else { - m_dataCache.language = (CPointers::languageMgr())->languageForAbbrev(module()->Lang()); - } - } else { - m_dataCache.language = (CPointers::languageMgr())->defaultLanguage(); //default language - } - } - - return m_dataCache.language; -} - - -/*! - \fn CSwordModuleInfo::getSimpleConfigEntry(char* name) - */ -QString CSwordModuleInfo::getSimpleConfigEntry(const QString& name) const { - QString ret = isUnicode() - ? QString::fromUtf8(m_module->getConfigEntry(name.latin1())) - : QString::fromLatin1(m_module->getConfigEntry(name.latin1())); - - return ret.isEmpty() ? QString::null : ret; -} - -QString CSwordModuleInfo::getFormattedConfigEntry(const QString& name) const { - SWBuf RTF_Buffer(m_module->getConfigEntry(name.latin1())); - sword::RTFHTML RTF_Filter; - RTF_Filter.processText(RTF_Buffer, 0, 0); - QString ret = isUnicode() - ? QString::fromUtf8(RTF_Buffer.c_str()) - : QString::fromLatin1(RTF_Buffer.c_str()); - - return ret.isEmpty() ? QString::null : ret; -} diff --git a/bibletime/backend/cswordmoduleinfo.h b/bibletime/backend/cswordmoduleinfo.h deleted file mode 100644 index 40112ec..0000000 --- a/bibletime/backend/cswordmoduleinfo.h +++ /dev/null @@ -1,373 +0,0 @@ -/********* -* -* This file is part of BibleTime's source code, http://www.bibletime.info/. -* -* Copyright 1999-2006 by the BibleTime developers. -* The BibleTime source code is licensed under the GNU General Public License version 2.0. -* -**********/ - - - -#ifndef CSWORDMODULEINFO_H -#define CSWORDMODULEINFO_H - -//BibleTime includes -#include "clanguagemgr.h" - -//Qt includes -#include <qstring.h> -#include <qvaluelist.h> -#include <qsignal.h> - -//Sword includes -#include <listkey.h> -#include <swsearchable.h> -#include <swmodule.h> -#include <swversion.h> -#include <swdisp.h> - - -class CSwordBackend; - -class CSwordKey; - -namespace Rendering { - - class CEntryDisplay; -} - -/** - * Base class for Sword modules. - * This is the base class for all Sword modules. Every class handling a special Sword module type - * does inherit from this class. - * - * @author The BibleTime team - * @version $Id: cswordmoduleinfo.h,v 1.83 2007/02/04 23:12:32 joachim Exp $ - */ - -class CSwordModuleInfo { - -public: - /** - * These are the options which could be supported by modules and by this backend. - * It's used in @ref CSwordBackend::isOptionEnabled and @ref CSwordBackend::setOption. - */ - enum FilterTypes { - footnotes, /**< Footnotes embedded in the module's text */ - strongNumbers, /**< strong numbers, usually in the text for the info display */ - headings, /**< additional section headings */ - morphTags, /**< morphology */ - lemmas, /**< lemma tags */ - hebrewPoints,/**< Hebrew vowel points */ - hebrewCantillation, /**<Hewbrew caantillation points */ - greekAccents, /**< Greek accents may be switched on and off */ - scriptureReferences, /**< scripture references may be switched on and off, just makes sense in Bibles */ - redLetterWords, /**< Jesus words in red, color is template specific */ - textualVariants, /**< variants */ - morphSegmentation, /**< morph word segmentation, supported by OSIS */ - filterTypesMIN = footnotes, /**< first entry of this enum */ - filterTypesMAX = morphSegmentation /**< last item in this enum */ - // transliteration /* The following are handled in a special way */ - }; - /** The text direction of a module */ - enum TextDirection { /* The text direction of the modules's text */ - LeftToRight, /**< Left to right text direction, the default setting */ - RightToLeft /**< Right to left text directin, e.g. for hebrew */ - }; - /** The module type. - */ - enum ModuleType { - Bible, /**< Bible module */ - Commentary, /**< Commentary module */ - Lexicon, /**< Lexicon module */ - GenericBook, /**< Generic book module */ - Unknown /**< Fall back type for unknown modules */ - }; - /** - * This enum is used to give - * back an error code after unlocking the module - * BibleTime stores the unlock key not in the module's config file but in BibleTime's - * configuration file. - */ - enum UnlockErrorCode { - noError, /**< No error occured, everything worked ok. The key was written to the BibleTime config */ - wrongUnlockKey, /**< The wrong key was used. Module is not unlocked */ - notLocked, /**< The module was not locked so it can't be unlocked */ - noPermission /**< The key was not written to config because we have no permissions */ - }; - enum ConfigEntry { - AboutInformation, /**< The about information of a module which is stored in the config file*/ - AbsoluteDataPath, /**< The absolute data path stored in the config object */ - CipherKey, /**< The cipher key which was used to unlock the module. Not necessarily set.*/ - DataPath, /**< The relative path. See AbsoluteDataPath*/ - Description, /**< The module description stored in the config file */ - ModuleVersion, /**< The module's version.*/ - MinimumSwordVersion, /**< The required Sword Version of this module. Otherwise some things may not work (compression etc.).*/ - TextDir, /**< The text direction */ - DisplayLevel, /**< Mostly used for books. Gives the level which should contain the connected entries.*/ - GlossaryFrom, /**< lamguage from which the Glosaary tramslates */ - GlossaryTo, /**< lamguages to which the glossary maps to */ - DistributionLicense, - DistributionSource, - DistributionNotes, - TextSource, - CopyrightNotes, - CopyrightHolder, - CopyrightDate, - CopyrightContactName, - CopyrightContactAddress, - CopyrightContactEmail, - Markup /**< The markup of this module */ - }; - enum Feature { - //StrongsNumbers, /**< Use for Bibles which have embedded strong numbers */ - GreekDef, - HebrewDef, - GreekParse, - HebrewParse, - featureMin = GreekDef, - featureMax = HebrewParse - }; - enum Category { - UnknownCategory = 0, /**< The category wasn't set or has an unknwon value */ - Cult, /**< The module is a cult / sect / questionable module */ - DailyDevotional, - Glossary - }; - - /** - * Returns the base directory for search indices - */ - static const QString getGlobalBaseIndexLocation(); - /** - * Removes search index for this module, even if the module is not there any more - */ - static void deleteIndexForModule( QString name ); - - - /** - * Returns the config entry which is pecified by the parameter. - */ - const QString config( const CSwordModuleInfo::ConfigEntry entry ) const; - - CSwordModuleInfo( sword::SWModule* module, CSwordBackend* const = 0 ); - /** Copy constructor to copy the passed parameter. - * @param m The module to be copied - */ - CSwordModuleInfo( const CSwordModuleInfo& m ); - /** Reimplementation to return a valid clone. - */ - virtual CSwordModuleInfo* clone(); - /** Destructor. - */ - virtual ~CSwordModuleInfo(); - - /** - * Returns the module object so all objects can access the original Sword module. - */ - inline sword::SWModule* const module() const; - /** - * Sets the unlock key of the modules and writes the key into the cofig file. - * @return True if the unlock process was succesful, if the key was wrong, or if the config file was write protected return false. - */ - const bool unlock( const QString& unlockKey ); - /** - * Returns the display object for this module. Normally every module should have a Display object. - * Please don't use module()->Display() because this function does return the Sword display and does - * render the text, too. - * This function performs some casts to return the correct display. If it returns 0 there's no valid - * display object. - */ - Rendering::CEntryDisplay* const getDisplay() const; - /** - * This function does return true if the data files of the module are encrypted by the module author - * (the on who made the module) no matter if it's locked or not. - * @return True if this module is encryped - */ - const bool isEncrypted() const; - /** - * This function returns true if this module is locked (encrypted + correct cipher key), - * otherwise return false. - * @return True if this module is locked, i.e. encrypted but without a key set - */ - const bool isLocked(); - - const bool unlockKeyIsValid(); - - /** The module version. - * @return true if this module has a version number and false if it doesn't have one. - */ - inline const bool hasVersion() const; - - /** - * Returns true if the module's index has been built. - */ - virtual const bool hasIndex(); - /** - * Returns the path to this module's index base dir - */ - virtual const QString getModuleBaseIndexLocation() const; - /** - * Returns the path to this module's standard index - */ - virtual const QString getModuleStandardIndexLocation() const; - /** - * Builds a search index for this module - */ - virtual void buildIndex(); - /** - * Returns index size - */ - virtual unsigned long indexSize() const; - - void connectIndexingFinished(QObject* receiver, const char* slot); - void connectIndexingProgress(QObject* receiver, const char* slot); - void disconnectIndexingSignals(QObject* receiver); - - /** - * Returns true if something was found, otherwise return false. - * This function uses CLucene to perform and index based search. It also - * overwrites the variable containing the last search result. - */ - virtual const bool searchIndexed(const QString& searchedText, sword::ListKey& scope); - /** - * Returns the last search result for this module. - * The last result is cleared by @ref search - */ - virtual sword::ListKey& searchResult( const sword::ListKey* newResult = 0 ); - /** - * Clears the last search result. - * This does immediately clean the last search result, - * no matter if search is in progress or not. - */ - void clearSearchResult(); - /** - * Returns the type of the module. - */ - virtual const CSwordModuleInfo::ModuleType type() const; - /** - * Returns the required Sword version for this module. - * Returns -1 if no special Sword version is required. - */ - const sword::SWVersion minimumSwordVersion(); - /** - * Returns the name of the module. - * @return The name of this module. - */ - inline const QString name() const; - /** - * Snaps to the closest entry in the module if the current key is - * not present in the data files. - */ - virtual const bool snap() { - return false; - }; - - const bool has( const CSwordModuleInfo::Feature ) const; - const bool has( const CSwordModuleInfo::FilterTypes ) const; - /** - * Returns the text direction of the module's text., - */ - virtual const CSwordModuleInfo::TextDirection textDirection(); - /** - * Writes the new text at the given position into the module. This does only work for writabe modules. - */ - virtual void write( CSwordKey* key, const QString& newText ); - /** - * Deletes the current entry and removes it from the module. - */ - const bool deleteEntry( CSwordKey* const key ); - /** - * Returns the language of the module. - */ - const CLanguageMgr::Language* const language() const; - /** - * Returns true if this module may be written by the write display windows. - */ - inline virtual const bool isWritable() const; - /** - * Returns the category of this module. See CSwordModuleInfo::Category for possible values. - */ - const CSwordModuleInfo::Category category() const; - /** - * The about text which belongs to this module. - */ - QString aboutText() const; - /** - * Returns true if this module is Unicode encoded. False if the charset is iso8859-1. - * Protected because it should not be used outside of the CSword*ModuleInfo classes. - */ - inline const bool isUnicode() const { - return m_dataCache.isUnicode; - } - -protected: - friend class CSwordBackend; - - inline CSwordBackend* backend() const { - return m_backend; - } - - inline void backend( CSwordBackend* newBackend ) { - if (newBackend) { - m_backend = newBackend; - } - } - - QString getSimpleConfigEntry(const QString& name) const; - QString getFormattedConfigEntry(const QString& name) const; - -private: - sword::SWModule* m_module; - sword::ListKey m_searchResult; - - mutable struct DataCache { - DataCache() { - language = 0; - } - - QString name; - bool isUnicode; - CSwordModuleInfo::Category category; - const CLanguageMgr::Language* language; - bool hasVersion; - } - - m_dataCache; - - CSwordBackend* m_backend; - - QSignal m_indexingFinished; - QSignal m_indexingProgress; -}; - -// typedef QPtrList<CSwordModuleInfo> ListCSwordModuleInfo; -typedef QValueList<CSwordModuleInfo*> ListCSwordModuleInfo; - -inline const CSwordModuleInfo::ModuleType CSwordModuleInfo::type() const { - return CSwordModuleInfo::Unknown; -} - -inline sword::SWModule* const CSwordModuleInfo::module() const { - return m_module; -} - -inline const bool CSwordModuleInfo::hasVersion() const { - return m_dataCache.hasVersion; -} - - -/** Returns the name of the module. */ -inline const QString CSwordModuleInfo::name() const { - return m_dataCache.name; -} - -/** Returns true if this module may be written by the write display windows. */ -inline const bool CSwordModuleInfo::isWritable() const { - return false; -} - -#include "util/cpointers.h" - -#endif diff --git a/bibletime/backend/cswordmodulesearch.cpp b/bibletime/backend/cswordmodulesearch.cpp deleted file mode 100644 index 3d00fd7..0000000 --- a/bibletime/backend/cswordmodulesearch.cpp +++ /dev/null @@ -1,120 +0,0 @@ -/********* -* -* This file is part of BibleTime's source code, http://www.bibletime.info/. -* -* Copyright 1999-2006 by the BibleTime developers. -* The BibleTime source code is licensed under the GNU General Public License version 2.0. -* -**********/ - - - -//BibleTime includes -#include "cswordmodulesearch.h" -#include "cswordmoduleinfo.h" -#include "cswordbackend.h" -#include "../frontend/cbtconfig.h" - -//Sword includes -#include <swmodule.h> -#include <swkey.h> -#include <listkey.h> - - -CSwordModuleSearch* CSwordModuleSearch::searcher = 0; - -CSwordModuleSearch::CSwordModuleSearch() : -m_searchedText(QString::null), -m_searchOptions(0), -m_foundItems(false){ - searcher = this; -} - -CSwordModuleSearch::~CSwordModuleSearch() { - searcher = 0; -} - -/** This function sets the modules which should be searched. */ -void CSwordModuleSearch::setModules( const ListCSwordModuleInfo& list ) { - m_moduleList = list; -} - -/** Starts the search for the search text. */ -const bool CSwordModuleSearch::startSearch() { - backend()->setFilterOptions ( CBTConfig::getFilterOptionDefaults() ); - m_foundItems = false; - - bool foundItems = false; - - // for (m_moduleList.first(); m_moduleList.current() && !m_terminateSearch; m_moduleList.next()) { - ListCSwordModuleInfo::iterator end_it = m_moduleList.end(); - - for (ListCSwordModuleInfo::iterator it = m_moduleList.begin(); it != end_it; ++it) { - if ( (*it)->searchIndexed(m_searchedText/*, m_searchOptions*/, m_searchScope) ) { - foundItems = true; - } - } - - m_foundItems = foundItems; - - m_finishedSig.activate(); - return true; -} - -/** Sets the text which should be search in the modules. */ -void CSwordModuleSearch::setSearchedText( const QString& text ) { - m_searchedText = text; -} - -/** Sets the search scope. */ -void CSwordModuleSearch::setSearchScope( const sword::ListKey& scope ) { - m_searchScope.copyFrom( scope ); - - if (!strlen(scope.getRangeText())) { //we can't search with an empty search scope, would crash - //reset the scope - resetSearchScope(); - - //disable searching with a scope! - // if (m_searchOptions | useScope) { - // qWarning("using the scope!"); - //set back the scope flag - // } - } -} - -/** Sets the search scope back. */ -void CSwordModuleSearch::resetSearchScope() { - m_searchScope.ClearList(); -} - -/** Returns true if in the last search the searcher found items, if no items were found return false. */ -const bool CSwordModuleSearch::foundItems() const { - return m_foundItems; -} - -/** Returns a copy of the used search scope. */ -const sword::ListKey& CSwordModuleSearch::searchScope() const { - return m_searchScope; -} - -void CSwordModuleSearch::connectFinished( QObject *receiver, const char *member ) { - m_finishedSig.connect(receiver, member); -} - -/** Should be called when the search finished. */ -void CSwordModuleSearch::searchFinished() { - m_finishedSig.activate(); -} - -const bool CSwordModuleSearch::modulesHaveIndices( const ListCSwordModuleInfo& modules ) -{ - bool hasIndices = true; - ListCSwordModuleInfo::const_iterator end_it = modules.end(); - for( ListCSwordModuleInfo::const_iterator it = modules.begin(); it != end_it; ++it) { - if (!(*it)->hasIndex()) { - hasIndices = false; - break; - } - } - return hasIndices; -} diff --git a/bibletime/backend/cswordmodulesearch.h b/bibletime/backend/cswordmodulesearch.h deleted file mode 100644 index 8c65d1c..0000000 --- a/bibletime/backend/cswordmodulesearch.h +++ /dev/null @@ -1,99 +0,0 @@ -/********* -* -* This file is part of BibleTime's source code, http://www.bibletime.info/. -* -* Copyright 1999-2006 by the BibleTime developers. -* The BibleTime source code is licensed under the GNU General Public License version 2.0. -* -**********/ - - - -#ifndef CSWORDMODULESEARCH_H -#define CSWORDMODULESEARCH_H - -//BibleTime - backend -#include "cswordmoduleinfo.h" - -//BibleTime - utils -#include "util/cpointers.h" - -//Qt includes -#include <qptrlist.h> -#include <qstring.h> -#include <qsignal.h> - -//System includes -#include <pthread.h> - -//Sword includes -#include <listkey.h> - -/** - * CSwordModuleSearch manages the search on Sword modules. It manages the thread(s) - * and manages the different modules. - * - * @author The BibleTime team - * @version $Id: cswordmodulesearch.h,v 1.34 2006/08/08 19:32:48 joachim Exp $ - */ - -class CSwordModuleSearch: public CPointers { - -public: - CSwordModuleSearch(); - /** - * The destructor of this class. It cleans uop memory before it's deleted. - */ - virtual ~CSwordModuleSearch(); - /** - * Sets the text which should be search in the modules. - */ - void setSearchedText( const QString& ); - /** - * Starts the search for the search text. - */ - const bool startSearch(); - /** - * This function sets the modules which should be searched. - */ - void setModules( const ListCSwordModuleInfo& ); - /** - * Sets the search scope. - */ - void setSearchScope( const sword::ListKey& scope ); - /** - * Sets the seaech scope back. - */ - void resetSearchScope(); - /** - * @return "true" if in the last search the searcher found items, if no items were found return "false" - */ - const bool foundItems() const; - /** - * Returns a copy of the used search scope. - */ - const sword::ListKey& searchScope() const; - - void connectFinished( QObject * receiver, const char * member ); - void searchFinished(); - - /** - * Returns true if all of the specified modules have indices already built. - */ - const bool modulesHaveIndices( const ListCSwordModuleInfo& ); - -protected: - QString m_searchedText; - sword::ListKey m_searchScope; - ListCSwordModuleInfo m_moduleList; - - int m_searchOptions; - - bool m_foundItems; - -private: - QSignal m_finishedSig; - static CSwordModuleSearch* searcher; -}; - -#endif diff --git a/bibletime/backend/cswordtreekey.cpp b/bibletime/backend/cswordtreekey.cpp deleted file mode 100644 index 0b17996..0000000 --- a/bibletime/backend/cswordtreekey.cpp +++ /dev/null @@ -1,99 +0,0 @@ -/********* -* -* This file is part of BibleTime's source code, http://www.bibletime.info/. -* -* Copyright 1999-2007 by the BibleTime developers. -* The BibleTime source code is licensed under the GNU General Public License version 2.0. -* -**********/ - - - -#include "cswordtreekey.h" -#include "cswordbookmoduleinfo.h" - -#include <qtextcodec.h> - -CSwordTreeKey::CSwordTreeKey( const CSwordTreeKey& k ) : CSwordKey(k), TreeKeyIdx(k) {} - -CSwordTreeKey::CSwordTreeKey( const TreeKeyIdx *k, CSwordModuleInfo* module ) : CSwordKey(module), TreeKeyIdx(*k) {} - -CSwordTreeKey* CSwordTreeKey::copy() const { - return new CSwordTreeKey(*this); -} - -const QString CSwordTreeKey::getLocalNameUnicode() const -{ - Q_ASSERT(m_module); - CSwordTreeKey* nonconst_this = const_cast<CSwordTreeKey*>(this); - if (!m_module || m_module->isUnicode()) { - return QString::fromUtf8(nonconst_this->getLocalName()); - } else { - QTextCodec *codec = QTextCodec::codecForName("CP1252"); - return codec->toUnicode(nonconst_this->getLocalName()); - } -} - -/** Returns the key of this instance */ -const QString CSwordTreeKey::key() const { - Q_ASSERT(m_module); - if (!m_module || m_module->isUnicode()) { - return QString::fromUtf8(getText()); - } else { - QTextCodec *codec = QTextCodec::codecForName("CP1252"); - return codec->toUnicode(getText()); - } -} - -/** Returns the raw key for use by Sword */ -const char* CSwordTreeKey::rawKey() const { - return getText(); -} - -const bool CSwordTreeKey::key( const QString& newKey ) { - Q_ASSERT(m_module); - if (!m_module || m_module->isUnicode()) { - return key((const char*)newKey.utf8()); - } else { - QTextCodec *codec = QTextCodec::codecForName("CP1252"); - return key((const char*)codec->fromUnicode(newKey)); - } -} - -const bool CSwordTreeKey::key( const char* newKey ) { - Q_ASSERT(newKey); - - if (newKey) { - TreeKeyIdx::operator = (newKey); - } - else { - root(); - } - - return !Error(); -} - -CSwordModuleInfo* const CSwordTreeKey::module( CSwordModuleInfo* const newModule ) { - if (newModule && (newModule != m_module) && (newModule->type() == CSwordModuleInfo::GenericBook) ) { - m_module = newModule; - - const QString oldKey = key(); - - CSwordBookModuleInfo* newBook = dynamic_cast<CSwordBookModuleInfo*>(newModule); - copyFrom( *(newBook->tree()) ); - - key(oldKey); //try to restore our old key - - //set the key to the root node - root(); - firstChild(); - } - - return m_module; -} - -/** Assignment operator. */ -CSwordTreeKey& CSwordTreeKey::operator = (const QString& keyname ) { - key(keyname); - return *this; - } diff --git a/bibletime/backend/cswordtreekey.h b/bibletime/backend/cswordtreekey.h deleted file mode 100644 index 7ba563d..0000000 --- a/bibletime/backend/cswordtreekey.h +++ /dev/null @@ -1,74 +0,0 @@ -/********* -* -* This file is part of BibleTime's source code, http://www.bibletime.info/. -* -* Copyright 1999-2007 by the BibleTime developers. -* The BibleTime source code is licensed under the GNU General Public License version 2.0. -* -**********/ - - - -#ifndef CSWORDTREEKEYIDX_H -#define CSWORDTREEKEYIDX_H - -//BibleTime includes -#include "cswordkey.h" - -//Sword includes -#include <treekeyidx.h> - -class CSwordModuleInfo; - -/** BibleTime's implementation of Sword's TreeKeyIdx class. - * @short CSwordKey implementation for Sword's TreeKey - * @author The BibleTime team - */ - -class CSwordTreeKey : public CSwordKey, public sword::TreeKeyIdx { - -public: - /** Constructor of this CSwordKey implementation. - * @param k The Sword tree key which belongs to this key - * @param module The module which belongs to this key - */ - CSwordTreeKey( const sword::TreeKeyIdx *k, CSwordModuleInfo* module ); - /** Copy constructor. - */ - CSwordTreeKey( const CSwordTreeKey& k ); - /** The module which belongs to this key. - * @return The module. - */ - virtual CSwordModuleInfo* const module( CSwordModuleInfo* const newModule ); - /** Copy method. - * @return A new copy of this object. - */ - virtual CSwordTreeKey* copy() const; - /** - * Returns the last part of the current key as unicode decoded QString. - * Use this instead of TreeKeyIdx::getLocalName() to avoid encoding problems. - */ - virtual const QString getLocalNameUnicode() const; - /** - * Returns the current key - */ - virtual const QString key() const; - /** - * Set the key. If the parameter is empty or null, the key will be set to "/" - */ - virtual const bool key( const QString& key ); - /** - * Set/get the key. If the parameter is not set (means equal to QString::null) - * the used key is returned. Otherwise the key is set and the new on ei returned. - */ - virtual const bool key( const char* key ); - /** - * Assignment operator. - */ - virtual CSwordTreeKey& operator = (const QString& keyname ); -protected: - /**Get the unencoded key for use by Sword.*/ - virtual const char * rawKey() const; -}; - -#endif diff --git a/bibletime/backend/cswordversekey.cpp b/bibletime/backend/cswordversekey.cpp deleted file mode 100644 index 3ab92d1..0000000 --- a/bibletime/backend/cswordversekey.cpp +++ /dev/null @@ -1,306 +0,0 @@ -/********* -* -* This file is part of BibleTime's source code, http://www.bibletime.info/. -* -* Copyright 1999-2006 by the BibleTime developers. -* The BibleTime source code is licensed under the GNU General Public License version 2.0. -* -**********/ - - - -//BibleTime includes -#include "cswordversekey.h" -#include "cswordbiblemoduleinfo.h" -#include "cswordcommentarymoduleinfo.h" - -//Qt includes -#include <qstringlist.h> - -//Sword includes -#include <swmodule.h> -#include <localemgr.h> - -CSwordVerseKey::CSwordVerseKey( CSwordModuleInfo* const module ) : CSwordKey(module) { - if ( CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(module) ) { - key( bible->lowerBound().key() ); - } -} - -CSwordVerseKey::CSwordVerseKey( const CSwordVerseKey& k ) : CSwordKey(k), VerseKey(k) {} - -CSwordVerseKey::CSwordVerseKey( const VerseKey* const k, CSwordModuleInfo* const module ) : CSwordKey(module), VerseKey(*k) {} - -/** Clones this object. */ -CSwordKey* CSwordVerseKey::copy() const { - return new CSwordVerseKey(*this); -} - -/** Sets the module for this key */ -CSwordModuleInfo* const CSwordVerseKey::module( CSwordModuleInfo* const newModule ) { - if (newModule && ((newModule->type() == CSwordModuleInfo::Bible) || (newModule->type() == CSwordModuleInfo::Commentary) ) ) { - m_module = newModule; - - //check if the module contains the key we present - CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(newModule); - - if (_compare(bible->lowerBound()) < 0) { - key( bible->lowerBound() ); - } - - if (_compare(bible->upperBound()) > 0) { - key( bible->upperBound() ); - } - } - - return dynamic_cast<CSwordBibleModuleInfo*>(m_module); -} - -/** Returns the current book as Text, not as integer. */ -const QString CSwordVerseKey::book( const QString& newBook ) { - int min = 0; - int max = 1; - - if (CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(module())) { - const bool hasOT = bible->hasTestament(CSwordBibleModuleInfo::OldTestament); - const bool hasNT = bible->hasTestament(CSwordBibleModuleInfo::NewTestament); - - if (hasOT && hasNT) { - min = 0; - max = 1; - } - else if (hasOT && !hasNT) { - min = 0; - max = 0; - } - else if (!hasOT && hasNT) { - min = 1; - max = 1; - } - else if (!hasOT && !hasNT) { - min = 0; - max = -1; //no loop - } - } - - if (!newBook.isEmpty()) { - bool finished = false; - - for (int testament = min; testament <= max && !finished; ++testament) { - for (int book = 0; book < BMAX[testament] && !finished; ++book) { - if ( !strcmp((const char*)newBook.utf8(), books[testament][book].name ) ) { - Testament(testament+1); - Book(book+1); - finished = true; - } - } - } - } - - if ( (Testament() >= min+1) && (Testament() <= max+1) && (Book() <= BMAX[min]) ) { - return QString::fromUtf8( books[Testament()-1][Book()-1].name ); - } - - //return QString::fromUtf8( books[min][0].name ); //return the first book, i.e. Genesis - return QString::null; -} - -/** Sets the key we use to the parameter. */ -const QString CSwordVerseKey::key() const { - return QString::fromUtf8(getText()); -} - -const char * CSwordVerseKey::rawKey() const { - return getText(); -} - -const bool CSwordVerseKey::key( const QString& newKey ) { - return key( (const char*)newKey.utf8() ); -} - -const bool CSwordVerseKey::key( const char* newKey ) { - if (newKey && (strlen(newKey)>0) ) { - VerseKey::operator = (newKey); - } - else if (newKey && !strlen(newKey)) { - CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(module()); - - if ( bible ) { - VerseKey::operator = ((const char*)bible->lowerBound().key().utf8()); - } - } - - return !Error(); -} - -const bool CSwordVerseKey::next( const JumpType type ) { - Error(); //clear Error status - bool ret = true; - - switch (type) { - - case UseBook: { - const int currentTestament = Testament(); - const int currentBook = Book(); - - if ((currentTestament == 2) && (currentBook >= BMAX[currentTestament-1])) { //Revelation, i.e. end of navigation - return false; - } - else if ((currentTestament == 1) && (currentBook >= BMAX[currentTestament-1])) { //Malachi, switch to the NT - Testament(currentTestament+1); - Book(1); - } - else { - Book(Book()+1); - } - break; - } - - case UseChapter: { - Chapter(Chapter()+1); - break; - } - - case UseVerse: { - if (m_module && m_module->module()) { - const bool oldStatus = m_module->module()->getSkipConsecutiveLinks(); - m_module->module()->setSkipConsecutiveLinks(true); - - //disable headings for next verse - const bool useHeaders = (Verse() == 0); - const bool oldHeadingsStatus = ((VerseKey*)(m_module->module()->getKey()))->Headings( useHeaders ); - //don't use setKey(), that would create a new key without Headings set - m_module->module()->getKey()->setText( (const char*)key().utf8() ); - - (*(m_module->module()) )++; - - ((VerseKey*)(m_module->module()->getKey()))->Headings(oldHeadingsStatus); - m_module->module()->setSkipConsecutiveLinks(oldStatus); - - if (!m_module->module()->Error()) { - key( QString::fromUtf8(m_module->module()->KeyText()) ); - } - else { - // Verse(Verse()+1); - //don't change the key, restore the module's position - m_module->module()->getKey()->setText( (const char*)key().utf8() ); - ret = false; - break; - } - - } - else { - Verse(Verse()+1); - } - - break; - } - - default: - return false; - } - - if ( CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(module()) ) { - if (_compare(bible->lowerBound()) < 0 ) { - key( bible->lowerBound() ); - ret = false; - } - - if (_compare(bible->upperBound()) > 0 ) { - key( bible->upperBound() ); - ret = false; - } - - return ret; - } - else if (Error()) { //we have no module, so take care of VerseKey::Error() - return false; - } - - return ret; -} - -const bool CSwordVerseKey::previous( const JumpType type ) { - bool ret = true; - - switch (type) { - - case UseBook: { - if ( (Book() == 1) && (Testament() == 1) ) { //Genesis - return false; - } - else if ( (Book() == 1) && (Testament() == 2) ){ //Matthew - Testament(1); - Book(BMAX[0]); - } - else{ - Book( Book()-1 ); - } - - break; - } - - case UseChapter: { - Chapter(Chapter()-1); - break; - } - - case UseVerse: { - if (m_module && m_module->module()) { - const bool useHeaders = (Verse() == 0); - const bool oldHeadingsStatus = ((VerseKey*)(m_module->module()->getKey()))->Headings( useHeaders ); - - m_module->module()->getKey()->setText( (const char*)key().utf8() ); - - const bool oldStatus = m_module->module()->getSkipConsecutiveLinks(); - m_module->module()->setSkipConsecutiveLinks(true); - ( *( m_module->module() ) )--; - - ((VerseKey*)(m_module->module()->getKey()))->Headings( oldHeadingsStatus ); - m_module->module()->setSkipConsecutiveLinks(oldStatus); - - if (!m_module->module()->Error()) { - key( QString::fromUtf8(m_module->module()->KeyText()) );//don't use fromUtf8 - } - else { - ret = false; - // Verse(Verse()-1); - m_module->module()->getKey()->setText( (const char*)key().utf8() ); //restore module's key - } - } - else { - Verse(Verse()-1); - } - - break; - } - - default: - return false; - } - - if ( CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(module()) ) { - if (_compare(bible->lowerBound()) < 0 ) { - key( bible->lowerBound() ); - ret = false; - } - - if (_compare(bible->upperBound()) > 0 ) { - key( bible->upperBound() ); - ret = false; - } - - return ret; - } - else if (Error()) { - return false; - } - - return ret; -} - -/** Assignment operator for more ease of use. */ -CSwordVerseKey& CSwordVerseKey::operator = (const QString& keyname) { - key(keyname); - return *this; -} diff --git a/bibletime/backend/cswordversekey.h b/bibletime/backend/cswordversekey.h deleted file mode 100644 index 79c9fe3..0000000 --- a/bibletime/backend/cswordversekey.h +++ /dev/null @@ -1,122 +0,0 @@ -/********* -* -* This file is part of BibleTime's source code, http://www.bibletime.info/. -* -* Copyright 1999-2006 by the BibleTime developers. -* The BibleTime source code is licensed under the GNU General Public License version 2.0. -* -**********/ - - - -#ifndef CSWORDVERSEKEY_H -#define CSWORDVERSEKEY_H - -//own includes -#include "cswordkey.h" -#include "cswordmoduleinfo.h" - -//Qt includes -#include <qstring.h> - -//Sword includes -#include <versekey.h> - -/** - * The CSwordKey implementation for verse based modules (Bibles and Commentaries) - * - * This class is the implementation of CKey for verse based modules like - * Bibles and commentaries. - * This class provides the special functions to work with the verse based modules. - * - * Useful functions are - * @see NextBook() - * @see PreviousBook() - * @see NextChapter() - * @see PreviousChapter() - * @see NextVerse() - * @see PreviousVerse(). - * - * Call the constructor only with a valid verse based modules, otherwise this key will be invalid - * and the application will probably crash. - * - * @version $Id: cswordversekey.h,v 1.27 2007/10/26 18:26:23 jerickson314 Exp $ - * @short CSwordKey implementation for Sword's VerseKey. - * @author The BibleTime team - */ - -class CSwordVerseKey : public CSwordKey, public sword::VerseKey { - -public: - enum JumpType { - UseBook, - UseChapter, - UseVerse - }; - - /** - * Constructor of this class. - * - * This function will construct a versekey with the current module position - * and it will setup the m_module members. - * - */ - CSwordVerseKey( CSwordModuleInfo* const module ); - /** - * Copy constructor. - */ - CSwordVerseKey( const CSwordVerseKey& k ); - /** - * VerseKey based constructor. - */ - CSwordVerseKey( const sword::VerseKey* const k, CSwordModuleInfo* const module ); - /** - * Clones this object. - */ - virtual CSwordKey* copy() const; - /** - * Set/get the key. If the parameter is not set (means equal to QString::null) - * the used key is returned. Otherwise the key is set and the new on ei returned. - */ - virtual const QString key() const; - /** - * Set the current key. - */ - virtual const bool key( const QString& ); - /** - * Set/get the key. If the parameter is not set (means equal to QString::null) - * the used key is returned. Otherwise the key is set and the new on ei returned. - */ - virtual const bool key( const char* key ); - - /** - * Jumps to the next entry of the given type - */ - const bool next( const JumpType type ); - /** - * Jumps to the previous entry of the given type - */ - const bool previous ( const JumpType type ); - /** - * This functions returns the current book as localised text, not as book numer. - * - * Use "char Book()" to retrieve the book number of the current book. - * @return The name of the current book - */ - const QString book(const QString& newBook = QString::null); - /** - * Sets the module for this key - */ - virtual CSwordModuleInfo* const module( CSwordModuleInfo* const newModule = 0 ); - /** - * Assignment operator for more ease of use. - */ - virtual CSwordVerseKey& operator = (const QString& keyname); -protected: - /** - * Returns the raw key for use with Sword. - */ - virtual const char * rawKey() const; -}; - -#endif diff --git a/bibletime/backend/ctextrendering.cpp b/bibletime/backend/ctextrendering.cpp deleted file mode 100644 index f3f5a9c..0000000 --- a/bibletime/backend/ctextrendering.cpp +++ /dev/null @@ -1,278 +0,0 @@ -// -// C++ Implementation: ctextrendering -// -// Description: -// -// -// Author: The BibleTime team <info@bibletime.info>, (C) 2004 -// -// Copyright: See COPYING file that comes with this distribution -// -// -#include "ctextrendering.h" - -//BibleTime includes -#include "backend/cswordkey.h" -#include "backend/cswordversekey.h" -#include "backend/cswordmoduleinfo.h" -#include "backend/cdisplaytemplatemgr.h" -#include "backend/creferencemanager.h" - -#include "util/scoped_resource.h" -#include "util/ctoolclass.h" - -//Sword includes -#include <swkey.h> - -//Qt includes -#include <qregexp.h> - -//KDE includes -#include <klocale.h> -#include <kurl.h> - -using namespace Rendering; - -CTextRendering::KeyTreeItem::KeyTreeItem(const QString& key, CSwordModuleInfo const * mod, const Settings settings ) -: m_settings( settings ), -m_moduleList(), -m_key( key ), -m_childList( 0 ), -m_stopKey( QString::null ), -m_alternativeContent( QString::null ) { - m_moduleList.append( const_cast<CSwordModuleInfo*>(mod) ); //BAD CODE -} - -CTextRendering::KeyTreeItem::KeyTreeItem(const QString& content, const Settings settings ) -: m_settings( settings ), -m_moduleList(), -m_key( QString::null ), -m_childList( 0 ), -m_stopKey( QString::null ), -m_alternativeContent( content ) {} - -CTextRendering::KeyTreeItem::KeyTreeItem(const QString& key, const ListCSwordModuleInfo& mods, const Settings settings ) -: m_settings( settings ), -m_moduleList( mods ), -m_key( key ), -m_childList( 0 ), -m_stopKey( QString::null ), -m_alternativeContent( QString::null ) {} - -CTextRendering::KeyTreeItem::KeyTreeItem() -: m_settings(), -m_moduleList(), -m_key(QString::null), -m_childList(0), -m_stopKey(QString::null), -m_alternativeContent(QString::null) {} - -CTextRendering::KeyTreeItem::KeyTreeItem(const KeyTreeItem& i) -: m_settings( i.m_settings ), -m_moduleList( i.m_moduleList ), -m_key( i.m_key ), -m_childList( 0 ), -m_stopKey( i.m_stopKey ), -m_alternativeContent( i.m_alternativeContent ) { - if (i.hasChildItems()) { - m_childList = new KeyTree(); - *m_childList = *(i.childList()); //deep copy - } - -} - -CTextRendering::KeyTreeItem::~KeyTreeItem() { - delete m_childList; - m_childList = 0; -} - -CTextRendering::KeyTreeItem::KeyTreeItem(const QString& startKey, const QString& stopKey, CSwordModuleInfo* module, const Settings settings) -: m_settings( settings ), -m_moduleList(), -m_key( startKey ), -m_childList( 0 ), -m_stopKey( stopKey ), -m_alternativeContent( QString::null ) { - Q_ASSERT(module); - m_moduleList.append(module); - - //use the start and stop key to ceate our child items - - if (module->type() == CSwordModuleInfo::Bible) { - CSwordVerseKey start(module); - start = startKey; - - CSwordVerseKey stop(module); - stop = stopKey; - - if (!m_key.isEmpty() && !m_stopKey.isEmpty()) { //we have a range of keys - bool ok = true; - - while (ok && ((start < stop) || (start == stop)) ) { //range - childList()->append( - new KeyTreeItem(start.key(), module, KeyTreeItem::Settings(false, settings.keyRenderingFace)) - ); - - - ok = start.next(CSwordVerseKey::UseVerse); - } - } - else if (m_key.isEmpty()) { - childList()->append( new KeyTreeItem(startKey, module, KeyTreeItem::Settings(false, settings.keyRenderingFace)) ); - } - } - else if ((module->type() == CSwordModuleInfo::Lexicon) || (module->type() == CSwordModuleInfo::Commentary) ) { - childList()->append( new KeyTreeItem(startKey, module, KeyTreeItem::Settings(false, KeyTreeItem::Settings::NoKey)) ); - } - else if (module->type() == CSwordModuleInfo::GenericBook) { - childList()->append( new KeyTreeItem(startKey, module, KeyTreeItem::Settings(false, KeyTreeItem::Settings::NoKey)) ); - } - - //make it into "<simple|range> (modulename)" - - if (startKey == stopKey) { - m_alternativeContent = startKey; - } - else { - sword::VerseKey vk(startKey.utf8(), stopKey.utf8()); - - if (vk.LowerBound().Book() != vk.UpperBound().Book()) { - m_alternativeContent = QString::fromUtf8(vk.getRangeText()); - } - else if (vk.LowerBound().Chapter() != vk.UpperBound().Chapter()) { - m_alternativeContent = QString("%1 - %2:%3") - .arg(QString::fromUtf8(vk.LowerBound().getText())) - .arg(vk.UpperBound().Chapter()) - .arg(vk.UpperBound().Verse()); - } - else { //only verses differ (same book, same chapter) - m_alternativeContent = QString("%1 - %2") - .arg(QString::fromUtf8(vk.LowerBound().getText())) - .arg(vk.UpperBound().Verse()); - } - } - - m_alternativeContent.append(" (").append(module->name()).append(")"); - m_alternativeContent.prepend("<div class=\"rangeheading\" dir=\"ltr\">").append("</div>"); //insert the right tags -} - -const QString& CTextRendering::KeyTreeItem::getAlternativeContent() const { - return m_alternativeContent; -} - -ListCSwordModuleInfo CTextRendering::KeyTree::collectModules() const { - //collect all modules which are available and used by child items - ListCSwordModuleInfo modules; - - for (KeyTreeItem* c = first(); c; c = next()) { - Q_ASSERT(c); - - ListCSwordModuleInfo childMods = c->modules(); - - /*ToDo: Use the const iterators as soon as we use Qt > 3.1 - const ListCSwordModuleInfo::const_iterator c_end = childMods.end(); - for (ListCSwordModuleInfo::const_iterator c_it = childMods.constBegin(); c_it != c_end; ++c_it) { - if (!modules.contains(*c_it)) { - modules.append(*c_it); - } - }*/ - - // for (CSwordModuleInfo* m = childMods.first(); m; m = childMods.next()) { - ListCSwordModuleInfo::iterator end_it = childMods.end(); - - for (ListCSwordModuleInfo::iterator it(childMods.begin()); it != end_it; ++it) { - if (!modules.contains(*it)) { - modules.append(*it); - } - } - - } - - return modules; -} - -const QString CTextRendering::renderKeyTree( KeyTree& tree ) { - initRendering(); - - ListCSwordModuleInfo modules = tree.collectModules(); - QString t; - - //optimization for entries with the same key - util::scoped_ptr<CSwordKey> key( - (modules.count() == 1) ? CSwordKey::createInstance(modules.first()) : 0 - ); - - for (KeyTreeItem* c = tree.first(); c; c = tree.next()) { - if (modules.count() == 1) { //this optimizes the rendering, only one key created for all items - key->key( c->key() ); - t.append( renderEntry( *c, key) ); - } - else { - t.append( renderEntry( *c ) ); - } - } - - return finishText(t, tree); -} - -const QString CTextRendering::renderKeyRange( const QString& start, const QString& stop, const ListCSwordModuleInfo& modules, const QString& highlightKey, const KeyTreeItem::Settings& keySettings ) { - - CSwordModuleInfo* module = modules.first(); - //qWarning( "renderKeyRange start %s stop %s \n", start.latin1(), stop.latin1() ); - - util::scoped_ptr<CSwordKey> lowerBound( CSwordKey::createInstance(module) ); - lowerBound->key(start); - - util::scoped_ptr<CSwordKey> upperBound( CSwordKey::createInstance(module) ); - upperBound->key(stop); - - sword::SWKey* sw_start = dynamic_cast<sword::SWKey*>(lowerBound.get()); - sword::SWKey* sw_stop = dynamic_cast<sword::SWKey*>(upperBound.get()); - - Q_ASSERT((*sw_start == *sw_stop) || (*sw_start < *sw_stop)); - - if (*sw_start == *sw_stop) { //same key, render single key - return renderSingleKey(lowerBound->key(), modules); - } - else if (*sw_start < *sw_stop) { // Render range - KeyTree tree; - KeyTreeItem::Settings settings = keySettings; - - CSwordVerseKey* vk_start = dynamic_cast<CSwordVerseKey*>(lowerBound.get()); - Q_ASSERT(vk_start); - - CSwordVerseKey* vk_stop = dynamic_cast<CSwordVerseKey*>(upperBound.get()); - Q_ASSERT(vk_stop); - - bool ok = true; - while (ok && ((*vk_start < *vk_stop) || (*vk_start == *vk_stop))) { - //make sure the key given by highlightKey gets marked as current key - settings.highlight = (!highlightKey.isEmpty() ? (vk_start->key() == highlightKey) : false); - - /*TODO: We need to take care of linked verses if we render one or (esp) more modules - If the verses 2,3,4,5 are linked to 1, it should be displayed as one entry with the caption 1-5 */ - - if (vk_start->Chapter() == 0){ //range was 0:0-1:x, render 0:0 first and jump to 1:0 - vk_start->Verse(0); - tree.append( new KeyTreeItem(vk_start->key(), modules, settings) ); - vk_start->Chapter(1); - vk_start->Verse(0); - } - tree.append( new KeyTreeItem(vk_start->key(), modules, settings) ); - ok = vk_start->next(CSwordVerseKey::UseVerse); - } - - return renderKeyTree(tree); - } - - return QString::null; -} - -const QString CTextRendering::renderSingleKey( const QString& key, const ListCSwordModuleInfo& moduleList, const KeyTreeItem::Settings& settings ) { - KeyTree tree; - tree.append( new KeyTreeItem(key, moduleList, settings) ); - - return renderKeyTree(tree); -} - - diff --git a/bibletime/backend/ctextrendering.h b/bibletime/backend/ctextrendering.h deleted file mode 100644 index d034959..0000000 --- a/bibletime/backend/ctextrendering.h +++ /dev/null @@ -1,147 +0,0 @@ -// -// C++ Interface: ctextrendering -// -// Description: -// -// -// Author: The BibleTime team <info@bibletime.info>, (C) 2004 -// -// Copyright: See COPYING file that comes with this distribution -// -// - -#ifndef CTEXTRENDERING_H -#define CTEXTRENDERING_H - -//BT includes -#include "backend/cswordmoduleinfo.h" - -#include "util/autoptrvector.h" - -//QT includes -#include <qstring.h> - -// class CSwordModuleInfo; - -class CSwordKey; - -/** - * CTextRendering is BibleTime's place where the actual rendering takes place. - * It provides several methods to convert an abstract tree of items - * into a string of html. - * - * See the implementations @ref CHTMLExportRendering and especially @ref CDisplayRendering. - * @short Text rendering based on trees - * @author The BibleTime team -*/ - -namespace Rendering { - - class CTextRendering { - -public: - - class KeyTreeItem; - - class KeyTree; - typedef util::AutoPtrVector<KeyTreeItem> KeyTreeItemList; - - class KeyTreeItem { - public: - - struct Settings { - enum KeyRenderingFace { - NoKey, //< means no key shown at all - SimpleKey, //< means only versenumber or only lexicon entry name - CompleteShort, //< means key like "Gen 1:1" - CompleteLong //< means "Genesis 1:1" - }; - - Settings(const bool highlight = false, KeyRenderingFace keyRendering = SimpleKey) : highlight(highlight), keyRenderingFace(keyRendering) {} - - bool highlight; - KeyRenderingFace keyRenderingFace; - }; - - KeyTreeItem(const QString& key, CSwordModuleInfo const * module, const Settings settings); - KeyTreeItem(const QString& key, const ListCSwordModuleInfo& modules, const Settings settings); - KeyTreeItem(const QString& startKey, const QString& stopKey, CSwordModuleInfo* module, const Settings settings); - KeyTreeItem(const QString& content, const Settings settings); - KeyTreeItem(const KeyTreeItem& i); - - virtual ~KeyTreeItem(); - - const QString& getAlternativeContent() const; - inline void setAlternativeContent(const QString& newContent) { - m_alternativeContent = newContent; - }; - - inline const bool hasAlternativeContent() const { - return !m_alternativeContent.isNull(); - }; - - inline const ListCSwordModuleInfo& modules() const { - return m_moduleList; - }; - - inline const QString& key() const { - return m_key; - }; - - inline const Settings& settings() const { - return m_settings; - }; - - inline KeyTree* const childList() const; - inline const bool hasChildItems() const; - - protected: - KeyTreeItem(); - - Settings m_settings; - ListCSwordModuleInfo m_moduleList; - QString m_key; - mutable KeyTree* m_childList; - - QString m_stopKey; - QString m_alternativeContent; - }; - - class KeyTree : public KeyTreeItemList { - public: - ListCSwordModuleInfo collectModules() const; - }; - - virtual ~CTextRendering() {} - - const QString renderKeyTree( KeyTree& ); - - const QString renderKeyRange( const QString& start, const QString& stop, const ListCSwordModuleInfo& modules, const QString& hightlightKey = QString::null, const KeyTreeItem::Settings& settings = KeyTreeItem::Settings() ); - - const QString renderSingleKey( const QString& key, const ListCSwordModuleInfo&, const KeyTreeItem::Settings& settings = KeyTreeItem::Settings() ); - -protected: - virtual const QString renderEntry( const KeyTreeItem&, CSwordKey* = 0 ) = 0; - virtual const QString finishText( const QString&, KeyTree& tree ) = 0; - virtual void initRendering() = 0; -}; - -inline CTextRendering::KeyTree* const CTextRendering::KeyTreeItem::childList() const { - if (!m_childList) { - m_childList = new KeyTree(); - } - - return m_childList; -} - -inline const bool CTextRendering::KeyTreeItem::hasChildItems() const { - if (!m_childList) { - return false; - } - - return !m_childList->isEmpty(); -} - -} - -#endif diff --git a/bibletime/backend/osismorphsegmentation.cpp b/bibletime/backend/osismorphsegmentation.cpp deleted file mode 100644 index 7aeb63c..0000000 --- a/bibletime/backend/osismorphsegmentation.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/****************************************************************************** - * - * osisfootnotes - SWFilter descendant to hide or show footnotes - * in an OSIS module. - */ - - -#include "osismorphsegmentation.h" - -#include <stdlib.h> -#include <swmodule.h> -#include <swbuf.h> -#include <versekey.h> -#include <utilxml.h> -#include <utilstr.h> - - - -namespace Filters { -const char OSISMorphSegmentation::oName[] = "Morph segmentation"; -const char OSISMorphSegmentation::oTip[] = "Toggles morph segmentation On and Off if they exist"; - -const SWBuf OSISMorphSegmentation::choices[3] = {"Off", "On", ""}; - -const StringList OSISMorphSegmentation::oValues(&choices[0], &choices[2]); - -OSISMorphSegmentation::OSISMorphSegmentation() : sword::SWOptionFilter(oName, oTip, &oValues) { - setOptionValue("Off"); - } - - - OSISMorphSegmentation::~OSISMorphSegmentation() {} - - - char OSISMorphSegmentation::processText(SWBuf &text, const SWKey */*key*/, const SWModule */*module*/) { - SWBuf token; - bool intoken = false; - bool hide = false; - - SWBuf orig( text ); - const char *from = orig.c_str(); - - XMLTag tag; - - for (text = ""; *from; ++from) { - if (*from == '<') { - intoken = true; - token = ""; - continue; - } - - if (*from == '>') { // process tokens - intoken = false; - - if (!strncmp(token.c_str(), "seg ", 4) || !strncmp(token.c_str(), "/seg", 4)) { - tag = token; - - if (!tag.isEndTag() && tag.getAttribute("type") && !strcmp("morph", tag.getAttribute("type"))) { //<seg type="morph"> start tag - hide = (option == 0); //only hide if option is Off - } - - if (hide) { //hides start and end tags as long as hide is set - - if (tag.isEndTag()) { //</seg> - hide = false; - } - - continue; //leave out the current token - } - } //end of seg tag handling - - text.append('<'); - text.append(token); - text.append('>'); - - // hide = false; //not right, because there may be child tags in seg. Only /seg may disable the seg hiding. - - continue; - } //end of intoken part - - if (intoken) { //copy token - token.append(*from); - } - else { //copy text which is not inside of a tag - text.append(*from); - } - } - - return 0; - } - -} diff --git a/bibletime/backend/osismorphsegmentation.h b/bibletime/backend/osismorphsegmentation.h deleted file mode 100644 index bc4ea0f..0000000 --- a/bibletime/backend/osismorphsegmentation.h +++ /dev/null @@ -1,48 +0,0 @@ -/****************************************************************************** - * - * $Id: osismorphsegmentation.h,v 1.4 2006/08/08 19:32:48 joachim Exp $ - * - * Copyright 1998 CrossWire Bible Society (http://www.crosswire.org) - * CrossWire Bible Society - * P. O. Box 2528 - * Tempe, AZ 85280-2528 - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation version 2. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - */ - -#ifndef OSISMORPHSEGMENTATION_H -#define OSISMORPHSEGMENTATION_H - -#include <swoptfilter.h> - -using namespace sword; - -namespace Filters { - -/** This Filter shows/hides headings in a OSIS text. - * @author Martin Gruner - */ -class OSISMorphSegmentation : public SWOptionFilter { - static const char oName[]; - static const char oTip[]; - static const SWBuf choices[3]; - static const StringList oValues; - -public: - OSISMorphSegmentation(); - virtual ~OSISMorphSegmentation(); - - virtual char processText(SWBuf &text, const SWKey *key = 0, const SWModule *module = 0); -}; - -} - -#endif -- cgit v1.2.3