./PaxHeaders.8614/kchmviewer-7.5 0000644 0000000 0000000 00000000132 12622005721 013265 x ustar 00 30 mtime=1447562193.244733042
30 atime=1447562193.004736308
30 ctime=1447562193.244733042
kchmviewer-7.5/ 0000755 0001750 0000144 00000000000 12622005721 013536 5 ustar 00tim users 0000000 0000000 kchmviewer-7.5/PaxHeaders.8614/CMakeLists.txt 0000644 0000000 0000000 00000000124 12322425122 015744 x ustar 00 27 mtime=1397369426.255372
27 atime=1447562193.020736
30 ctime=1447562193.027735995
kchmviewer-7.5/CMakeLists.txt 0000644 0001750 0000144 00000001512 12322425122 016273 0 ustar 00tim users 0000000 0000000 # Project name
PROJECT( kchmviewer )
# Init cmake
#SET( CMAKE_VERBOSE_MAKEFILE ON )
set( CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/")
# Necessary packages
FIND_PACKAGE( KDE4 REQUIRED )
FIND_PACKAGE( Libchm REQUIRED)
# libzip
FIND_PATH(LIBZIP_INCLUDE_DIR zip.h)
FIND_LIBRARY(LIBZIP_LIBRARY NAMES zip)
IF (LIBZIP_INCLUDE_DIR AND LIBZIP_LIBRARY)
MESSAGE(STATUS "Found libzip: ${LIBZIP_LIBRARY}")
ELSE ()
MESSAGE(FATAL_ERROR "Could not find libzip. Please install libzip and libzip-devel packages")
ENDIF ()
# Set compilation params
INCLUDE_DIRECTORIES( ${KDE4_INCLUDES}
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/lib/libebook )
ADD_DEFINITIONS( ${KDE4_DEFINITIONS} )
ADD_DEFINITIONS( -DUSE_KDE )
# Run in those subdirectories
ADD_SUBDIRECTORY( lib/libebook )
ADD_SUBDIRECTORY( src )
ADD_SUBDIRECTORY( po )
ADD_SUBDIRECTORY( packages )
kchmviewer-7.5/PaxHeaders.8614/templates 0000644 0000000 0000000 00000000132 12622005721 015126 x ustar 00 30 mtime=1447562193.237733137
30 atime=1447562193.236733151
30 ctime=1447562193.237733137
kchmviewer-7.5/templates/ 0000755 0001750 0000144 00000000000 12622005721 015534 5 ustar 00tim users 0000000 0000000 kchmviewer-7.5/templates/PaxHeaders.8614/cpp 0000644 0000000 0000000 00000000071 10340772766 015731 x ustar 00 27 atime=1447562193.237733
30 ctime=1447562193.237733137
kchmviewer-7.5/templates/cpp 0000644 0001750 0000144 00000003005 10340772766 016256 0 ustar 00tim users 0000000 0000000 /***************************************************************************
* Copyright (C) 2004-2005 by Georgy Yunaev, gyunaev@ulduzsoft.com *
* Please do not use email address above for bug reports; see *
* the README file *
* *
* 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; either version 2 of the License, or *
* (at your option) any later version. *
* *
* 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. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
kchmviewer-7.5/templates/PaxHeaders.8614/h 0000644 0000000 0000000 00000000071 10340772766 015376 x ustar 00 27 atime=1447562193.237733
30 ctime=1447562193.237733137
kchmviewer-7.5/templates/h 0000644 0001750 0000144 00000003005 10340772766 015723 0 ustar 00tim users 0000000 0000000 /***************************************************************************
* Copyright (C) 2004-2005 by Georgy Yunaev, gyunaev@ulduzsoft.com *
* Please do not use email address above for bug reports; see *
* the README file *
* *
* 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; either version 2 of the License, or *
* (at your option) any later version. *
* *
* 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. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
kchmviewer-7.5/PaxHeaders.8614/COPYING 0000644 0000000 0000000 00000000124 11270677072 014255 x ustar 00 27 mtime=1256422970.829794
27 atime=1447562193.027735
30 ctime=1447562193.030735954
kchmviewer-7.5/COPYING 0000644 0001750 0000144 00000104513 11270677072 014611 0 ustar 00tim users 0000000 0000000 GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc.
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
Copyright (C)
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, either version 3 of the License, or
(at your option) any later version.
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.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
Copyright (C)
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
.
kchmviewer-7.5/PaxHeaders.8614/build-win32-mingw.sh 0000644 0000000 0000000 00000000124 12616333137 016730 x ustar 00 27 mtime=1446622815.937622
27 atime=1447562193.032735
30 ctime=1447562193.036735873
kchmviewer-7.5/build-win32-mingw.sh 0000755 0001750 0000144 00000001314 12616333137 017262 0 ustar 00tim users 0000000 0000000 #!/bin/sh
# Path to (cross-platform) mingw compiler
MINGWPATH=/usr/toolchains/windows-x86-complete
# We cannot build statically because Webkit is not statically linkable
#QMAKE=$MINGWPATH/x86_64-w64-mingw32.static/qt4-shared/bin/qmake
QMAKE=$MINGWPATH/i686-w64-mingw32.static/qt4-shared/bin/qmake
#QMAKE=$MINGWPATH/qt4-static/bin/qmake
BUILDDIR="build.win32"
##################################
if [ -d "$BUILDDIR" ]; then
rm -rf "$BUILDDIR"
fi
svn export . "$BUILDDIR/" || exit 1
cd "$BUILDDIR"
# Compile it
export PATH=$MINGWPATH/bin:$PATH
$QMAKE -r "CONFIG -= release_and_debug" "CONFIG += release" && make -j4 || exit 1
if [ "x$1" == "x-nsis" ]; then
(cd nsis && sh create_installer.sh) || exit 1
fi
kchmviewer-7.5/PaxHeaders.8614/kchmviewer.pro 0000644 0000000 0000000 00000000124 12425306307 016101 x ustar 00 27 mtime=1414892743.080698
27 atime=1447562193.037735
30 ctime=1447562193.037735859
kchmviewer-7.5/kchmviewer.pro 0000644 0001750 0000144 00000000111 12425306307 016422 0 ustar 00tim users 0000000 0000000 SUBDIRS += lib src
TEMPLATE = subdirs
CONFIG += debug
src.depends = lib
kchmviewer-7.5/PaxHeaders.8614/DBUS-bindings 0000644 0000000 0000000 00000000123 11115111274 015455 x ustar 00 27 mtime=1228182204.558559
27 atime=1447562193.030735
29 ctime=1447562193.03173594
kchmviewer-7.5/DBUS-bindings 0000644 0001750 0000144 00000001413 11115111274 016005 0 ustar 00tim users 0000000 0000000 kchmviewer supports the following DBUS bindings:
Interface path: net.kchmviewer.application
Bingings:
// Loads a CHM file filename , and opens the URL url. Use URL "/" to open default homepage
void loadHelpFile( String filename, String url );
// Opens a specific url inside the loaded CHM file
void openPage( String url );
// Tries to find word in index, opening the index window and scrolling it there
void guiFindInIndex( String word );
// Executes a search in GUI. query contains the complete search query.
void guiSearchQuery( String query );
// Executes a search; GUI is not involved and user sees nothing.
// query contains the complete search query.
// Returns a list of URLs, or empty array if nothing os
StringList searchQuery( String query );
kchmviewer-7.5/PaxHeaders.8614/ChangeLog 0000644 0000000 0000000 00000000124 12622005704 014761 x ustar 00 27 mtime=1447562180.413702
27 atime=1447562193.030735
30 ctime=1447562193.030735954
kchmviewer-7.5/ChangeLog 0000644 0001750 0000144 00000056676 12622005704 015335 0 ustar 00tim users 0000000 0000000 2015-11-14 tim
- Version 7.5 released (r458);
- Added more useful information into About window;
- Fixed EPUB default encoding to be UTF-8;
- Changed the TOC/Index/Search default click to be single-click, not system-specific.
- On Windows we do not store the window size if it is minimized or maximized; using default size instead.
2015-11-02 tim
- Version 7.4 released (r450)
- Zoom level is now inherited in newly opened windows
- Fixed the empty or stale tab names while using the back/forward navigation buttons and new tab options
- Added -v and --version command-line options
- Added an option (Settings/Browser/Always use single click) to use a single-click to open tree items in the contents/index tabs despite the selected OS activator such as KDE double-click. Off by default.
- Fixed TOC parsing on some CHM files which had TOC names without associated URLs.
- Disabled encoding selection menu for epubs
2015-02-22 tim
- Version 7.3 released (r440)
- Fixed Windows-specific issues, Windows build works again
- Added X11-specific way to bring the window to front when requested;
- Added search highlighting suggested by Jomart
- Various KDE build fixes
- Added an option to disable automatic auto-expansion of Table of Contents entries
- Fixed the new version check which was triggered on older versions
- Fixed Qt5 build, it works fine now
- Fixed settings storage on Qt4/Qt5
2014-12-23 tim
- Version 7.2 released
- Ported to Qt5 (but still builds and works with Qt4)
- Added support for 3rd party integration
- Fixed some minor issues
2014-10-12 tim
- Version 7.1 released
- Added support for creating kchmviewer as a portable app
- Fixed a crash when indexing (in search) certain malformed HTML files
- Fixed parsing CHM files whose filenames contained URL-encoded characters
2014-03-26 tim
- Version 6.1 released
- Keyboard usability improved thanks to the Giuseppe "Cowo" Corbelli.
- The focus is now moved to the content page once the link is clicked, so the keyboard navigation is available immediately. You can switch the focus back by pressing Ctrl+(1-4).
- Added extended keyboard shortcuts for FindNext and FindPrevious; F3 still works.
- Navigation tab window activation (Contents, Search, Index, Bookmarks) now automatically focus the proper element.
- The items in the navigation page now reacts on onItemActivated, and hence act on key and follow the DE policy (such as respecting KDE single click).
- Upon successful search, the focus moves to the results list.
- Titles are now space-trimmed.
- Fixed binary TOC parser check which led to crashes for some CHM files.
- Fixed incorrect settings file storage name when the CHM file contains multiple dots.
- Fixed the Ctrl+click and Shift+click when the release event was intercepted by other applications (i.e. GoldenDict)
- 'Esc' closes the search dialog and restores focus in the content window.
2011-12-18 tim
- Version 6.0 released
- Removed outdated and buggy QTextBrowser support.
- Removed unneeded KHTMLPart support. Only QWebKit is now supported.
- Fixed zoom and "select all".
- Fixed storing scrollbar position.
- Added browser options to control JavaScript, Java and HTML5 features, which now apply to Webkit
- Fixed crash on start when the number of recent files was set to zero
- Added support for opening the specific page on startup using the --url switch
- Fixed scrolling at the same page when links are clicked
- Fixed the "Locate in content tree" which was broken for QWebKit
- For CHM entries with an URL but no name use the URL as name
- Updated copyrights
2011-01-14 tim
- Version 5.3 released.
- Fixed spelling error (thx Razvan Visan)
- Changed encodings order for Chinese and Japanese languages (thanks Kai-Chieh Ku)
- Added Ukrainian localization (thanks Olexander Yatsenko)
- Added Brazilian localization (thanks Márcio Moraes)
- Fixed some grammatical errors (thanks Robin 'cheese' Lee)
- Fixed webkit engine for buggy CHMs which do not have all content, as well as
cases when external references cannot be loaded. Thanks to Kai-Chieh Ku
- Added Mac support (thanks Serge Weinstock)
2010-04-26 tim
- 5.2 RELEASE
- Fixed missing images on CHM files under Windows XP SP3;
- Fixed viewing CHM files which embed links to other CHM files;
2010-04-23 tim
- Fixed window icon (thanks Aaron Lewis)
- Fixed typos in README and FAQ (thanks Martin 'Cheese' Lee)
- Fixed errors while building index because 'keyword' was ignored (thanks ivg)
- Switched to use new cross-compiler from http://mingw-cross-env.nongnu.org/ to create Windows builds
2009-12-17 tim
- 5.1 RELEASE
- Trying to use non-normalized URL first to fix CHMs which use them in TOC/Index
2009-12-16 tim
- Fixed application settings storage.
- Fixed bookmark edit button.
- Version changed to 5.1
2009-12-14 tim
- 5.0 RELEASE
- Version changed to 5.0
- Binary index parser commented out as it seems to be buggy.
- Toolbar mode is now configurable through settings.
- Now the application can start without opening a CHM file. Startup mode is selected in settings.
- Added check if a new version is available.
- Added new icons from DryIcons
2009-12-13 tim
- Major code refactoring, with renamed files and classes, to make it easier to maintain
the code in future.
- Changed all license headers to GPLv3-compliant.
- Recent files feature now uses a separate class.
- The navigator tab is now a Dock widget, so can be moved and floated.
- Content tab is now always loaded, and the page is correctly located.
2009-24-10 tim
- Version changed to 4.2
- Fixed font size change on KHTMLPart (thanks to Jure Repinc)
- Fixed Windows file opener being unable to open the file with non-English characters.
- Fixed "Open in new tab" for QTextBrowser opening an empty page.
- Middle button in QTextBrowser and WebKit now opens the link in new tab in background.
- Middle button now closes opened tabs in the tab bar.
2009-19-07 tim
- Version changed to 4.1
- Updated Dutch translation (thanks to Sander Pientka)
- Updated Turkish translation (thanks to Ozan Caglayan)
- Default toolbar button order changed to standard -/+
- Automatic encoding detection for KHTMLPart/WebKit is now disabled by default.
- Fixed incorrest index string encoding for non-English strings.
- Fixed text size auto-increase each time the file is loaded for WebKit browser.
- Fixed Windows mingw build issues.
- Fixed Windows command line parser being unable to open the file with non-English characters.
- License changed from GPLv2 to GPLv3.
2008-12-01 tim
- Version changed to 4.0 (release);
- Released version 4.0.
2008-11-30 tim
- Integrate Fedora .desktop fixes (thx Patrice Dumas)
- Implemented binary TOC and index tables (thx Razvan Cojocaru , the author of xchm). Speed up loading files more than twice!
- Now showing 'waiting' cursor while loading chm table of contents or index.
- Fixed QTextBrowser by providing workaround for "empty" books.
- More compatibility fixes with KDE 4.1
- Added Swedish translation (thx Daniel Nylander)
- Fixed handling files with file:// prefix.
- Added D-BUS support for Qt and KDE builds, the application could now be controlled remotely from other applications or scripts.
- Restored KDE translations.
2008-06-18 tim
- Version changed to 4.0b4;
- Added WebKit support (requires QtWebKit module). WebKit browser is default for a system where QtWebKit is present;
- Added support for Right-To-Left application and text layouts;
- Added support for disabling automatic encoding detection for browsers which could detect it themselves (KHTMLPart and Webkit);
2008-06-06 tim
- Version changed to 4.0b3;
- Added KDE4 support;
- Fixed several compatibility issues with qt-4.4.0;
- Added keyboard shortcuts to move to the next and previous entries in TOC: Ctrl+Right arrow
and Ctrl+Left arrow;
- Added manifest for the Windows version (thanks Cristian Adam);
- Windows version should not rely on mingw DLL anymore;
- Toolbars are now named;
- Fixed parallel build (thanks Patrice Dumas);
2008-02-10 tim
- Version changed to 4.0b2 (this is Qt4-only release);
- Added a command-line option to search through table of contents (--stoc);
- Added Italian translation (thanks to Emilio Scalise);
- Fixed crash on incorrectly compressed CHM file (thanks Albert Astals Cid);
- Fixed kio-msits so it now works with KDE4 (thanks Albert Astals Cid);
- Fixed FSF mailing address everywhere (thanks Albert Astals Cid);
- Fixed handling of improperly formatted CHM files like Audigy help;
- Added heuristics to support for improperly formatted CHMs which have toc and index,
but do not specify so in the project file;
- Fixed handling of CHM files which have local links in form of MS-ITS: urls;
- Search engine has been integrated into libchmfile;
- Search indexes are now stored in a single file, which should make it easier to make
search available through the indexing application;
2007-08-26 tim
- Application ported to Qt4.
- Recent files reworked.
- Search on page is now done via toolbar (like FireFox), activated by Ctrl-F and /.
- After switching tabs (either with mouse or Alt+ the focus is moved to the browser widget,
so you don't have to click on it to navigate using keyboard.
- Enchanced browser context menu.
2007-06-16 tim
- Fixed locale and .desktop installation directory for Gentoo (thanks Peter Volkov)
- Increased the speed of search engine indexing (thanks Kai Londenberg)
- Fixed the problem when kchmviewer is called from a browser with URL like file://.
- Fixed the unability to run the program when the last opened file does not exist anymore,
and the LoadLatestFileOnStartup is set to 1.
- Fixed CHMs with Unicode index/topic filenames inside CHM file (thanks hephooey).
- Fixed showing book images in QTextBrowser when file path contains urlencoded symbols.
- Fixed 64bit platforms compilation if system chmlib is not present.
- Version 3.1 (Qt3) released.
2007-03-14 tim
- Version 3.0 released
- Added a lot of decoded entities.
- Fixed incorrect saving of the settings file which result of this file not being loaded.
- Added FAQ.
- Added command-line options to search in index and in search window.
2007-03-09 tim
- Added improved custom search engine.
- Added DCOP support for KDE version.
2007-03-08 tim
- KDE version now shows KDE about dialog
- Fixed 'copy' in KDE browser
- Version changed to 3.0
- Removed duplicated application title in KDE.
- Gentoo installation issues fixed.
- KDE version sometime didn't kill the process after quit; thanks Norberto Bensa for fix.
- Fixed popup menu popping in a wrong place when using QTextBrowser if the scrollbar
position is not at the top of the document.
- KHTMLPart options sometime were not disabled while QTextBrowser was choosen.
2007-03-01 tim
- The design changed; created the chm files processing library, and moved it outside the source
to improve and simplify Okular integration.
- Changed URL2Topic search, the result - startup and opening times increased up to 20 times
for large chm files!
- Index multiple URL entry also opens now faster.
- Added support for new autotools.
2006-12-01 tim
- Version changed to 2.7.
- You can now switch between tabs using Alt+, thanks Bobi Jam.
- Kchmviewer should now work correctly on non-x86 platforms, including the codepage
autodetection.
- Added a warning when the browser or browser settings are changed that the application
restart is required for changes to take effect.
- Fixed the i18n compilation problem in kchmviewwindow.cpp.
- If the TOC directory entry did not have an associated page, it was not possible to select it.
- TOC directory entries now could be opened/closed with double-click on the entry name/icon,
not just +/- icons. Credits to Ludo for the ideas.
- No more duplicate entries in previous file history.
- The window title is now truncated if too long.
- Tab close icon now positioned correctly.
- Now current window size and splitter position is also stored on exit - separately
for each chm file.
- Window selection with multiple tabs now works.
- Czech translation added, thanks Hynek Fabian.
- Dutch translation updated, thanks Rinse de Vries.
2006-04-05 tim
- Version changed to 2.6
- Fixed gcc 4.x compilation.
- Added shortcut help in context menus.
- Right-click menu is now available in Contents, Search, Index and Favorites windows.
- Fixed navigation buttons 'What's this' messages.
- Fixed compilation on Zaurus and Debian.
2006-04-05 tim
- Application icon should now be correctly installed.
- Fixed handling of mailto: urls.
- 'Locate in content' button now opens a Contents tab, if hidden.
- Version 2.5 release.
2006-04-02 tim
- A tooltip is now shows the full text in all the tree and list views if truncated on screen.
- Fixed content tree parser, now the content table should be parsed correctly.
- Fixed crash after the encoding is changed, if any tree item is clicked.
- Added a bookmark menu. Ctrl-B is a shortcut to add a bookmark.
2006-04-01 tim
- Added tab browsing. Use right-click and 'Open in new tab'.
- Added right-click content menu to open pages in a new tab.
- Control-click on link or table of contents opens a page in a new tab in background.
- Shift-click on link or table of contents opens a page in a new tab in foreground.
2006-03-31 tim
- 'Setup' menu renamed to 'Settings'
- Fixed various navigation errors when 'Locate' button didn't locate the appropriate topic.
- Fixed forward navigation, and saved scroll position.
- Added tab browsing.
2006-02-07 tim
- Navigation history rewritten, now it stores text position too.
- Version changed to 2.1.
2006-02-06 tim
- Added 'Extract CHM content' menu item to extract the whole CHM file into a directory.
2006-02-02 tim
- Added i18n calls for complete internationalization. pot file created.
- Switched to a new, correct automake file structure.
- Fixed autotest.
- Version changed to 2.0.
2006-02-01 tim
- Now kchmviewer uses system libchm if found, and no --with-builtin-chmlib configure switch defined.
- Made configure more compatible with newest autoconf and Debian - thanks to Jose Luis Tallon.
- Added an application icon - thanks to Jose Luis Tallon.
- Fixed index parser for PHP manual - thanks to Dmitry Bakshaev.
- In full screen mode the menu bar and status bar are now hidden.
2006-01-30 tim
- Added 'locate in content window' button to open currently opened topic in the content window.
- Fixed compilation with gcc 4.1 - thanks to Jan Jitse Venselaar.
- The algorithm to detect the valid root offset in contents page is changed. Now there should be less
"CHMFile::ParseAndFillTopicsTree: child entry 1 with no root entry!" errors.
- Pages with images only are now shown correctly.
2005-12-30 tim
- Fixed kqrunprocess.h compilation bug on some platforms.
2005-11-27 tim
- Version 1.3 RELEASE
2005-11-25 tim
- Fixed error message when CHM file cannot be opened.
- Added Fullscreen mode (shortcut F11), and option to show/hide contents window (F9).
2005-11-22 tim
- Added possibility to view HTML source in external viewer/editor
2005-11-21 tim
- File names containing non-English characters now open correctly.
- Changed copyright notices.
2005-11-21 tim
- Fixed browser page update for QTextBrowser when current encoding changes.
- Changed encoding selectore. Now it compiles on x86_64.
- version 1.2 RELEASE
2005-11-20 tim
- Added 'next page' and 'prev page' buttons.
- Added extra charset encodings for Japanese, Chinese, Russian and Ukrainian languages.
- Added UTF-8 and UTF-16 encodings to country 'Unicode' :)
- Added special KOI8 encoding to Russian and Ukrainian languages. 'Special' means that
TOC is in CP1251 encoding, while content is in KOI8 encoding. There were some CHM files
with such weird encoding, so it is kinda hack.
- Fixed language selection bug - application crashed when you select the last language in any submenu.
- 'Set encoding' menu renamed to 'Set Language'.
- Added a new 'Set codepage' menu, which allows experienced people to send needed text code page directly.
- Added Ctrl-F shortcut to move cursor focus onto the search input combo box.
- Fixed navigation in some CHM files, which have spaces in filenames.
2005-10-30 tim
- fixed security bug - chmlib-0.35 updated to 0.37
- version 1.1 RELEASE released.
2005-09-27 tim
- fixed bug with incorrect embedded image shown - thanks to XinWei Hu.
- fixed bug with non-working decrease font size - thanks to anonymous Sourceforge user.
- copy in KDE version worked through Ctrl-C or 'copy' in content menu.
2005-07-28 tim
- Version 1.0 RELEASE released.
- Fixed -h option for Qt version.
- Fixed search messagebox on '?' button.
- Added F3 shortcut for 'next search in page' action.
2005-06-30 tim
- version 0.92 RELEASE CANDIDATE 2 released.
- fixed Slackware 10 compilation (one more time)
2005-06-25 tim
- more namespace cleanups and bugfixes.
- context and search windows are not shown if the opened file doesn't have it.
- removed 'search in results' checkbox.
- the last used directory is also stored.
2005-06-21 tim
- fixed 'View HTML source' bug.
- fixed "Select All/Copy" popup menu bugs.
- fixed bug with duplicated WhatsIs icon on every toolbar.
- added several keyboard shortcuts for menu commands.
- added extra shortcuts: Ctrl+1 opens the contents page, Ctrl+2 opens Index page,
Ctrl+3 opens the Search page, and Ctrl+4 opens the Bookmarks page.
- added command-line options to search in pages, in index and in bookmarks.
2005-06-20 Luca 'Ziabice' Gambetta
- fix for AMD64 platform (confirmed to work)
2005-06-18 tim
- version 0.91 RELEASE CANDIDATE 1 released.
2005-06-18 tim
- all configuration settings are now used.
- history is saved, loaded and cleaned up correctly.
- chm data (size/time) is now stored inside the history file, not in file name.
2005-06-17 tim
- some of configuration settings are now used.
- new browser is now running on Qt version when external URL is opening.
2005-06-16 tim
- added the configuration dialog, configuration settings are now saved and loaded.
2005-06-12 tim
- fixed compilation on Slackware 10.
- fixed internal links following for QTextBrowser.
2005-06-11 Gregorio Guidi
- fixed possible problem - linking static chmlib against non-static executable.
- added --without-kde option.
2005-06-07 tim
- preparing to release version 0.9beta.
- version 0.9beta released.
2005-06-07 tim
- added a full-featured search engine with complex query support.
2005-06-02 tim
- added copy/selectall functionality to KHTML browser, including a popup menu.
- fixed storing scrollbar position for KHTML browser.
- fixed window refresh on encoding change, encoding change now works for KHTML browser.
- zoom in/out buttons also work for KHTML browser.
2005-06-01 tim
- clicking on links (in-book navigation) now works for KHTML browser.
- full links (ms-its:) in chm files are now supported.
2005-05-10 tim
- switched to KPopupMenu for KDE.
- fixed search/print for KHTMLPart.
- fixed status bar in KDE window.
- added QWhatsThis for every toolbar icon.
- fixed command-line parsing for KDE app, remove external GetOpt class.
- fixed build outside the work directory.
2005-05-04 tim
- KDE integration continues. Now we support printing from KHTML.
- KIO-slave now works.
- switched to KTabWidget for KDE.
- fixed search/print for QTextBrowser.
2005-05-03 tim
- Reimplemented browser history in a more convinient way.
- KDE integration continues. Now we support KHTML.
- Added a KIO-slave to handle CHMs.
- Now it is possible to open files with non-latin filenames.
- Added support for CHM urls containing anchors.
- It is possible to use QTextBrowser even for a KDE application.
2005-04-27 tim
- KDE integration started. Now we support KApplication, KMainWindow and KFileDialog.
2005-04-24 tim
- version 0.2 released.
2005-04-24 tim
- added index fields identation according to .hhk file.
- index entries with multiple links are now supported. A dialog is opened when such a link is clicked.
- index "see also" links are now supported.
- added red color for index entries with multiple links, and grey color for "see also" links.
- chmlib interface redesigned for a great code cleanup and a little speedup.
- fixed bug when search history and bookmark list grow up every start.
- fixed garbage at the end of some HTML pages.
- fixed bug when search results do not open in page.
- fixed compilation on earlier Qt version (remove qvector.h dependency).
- fixed compilation on glibc without off_t.
2005-04-23 tim
- TOC parser rewritten, got about 30% speedup on TOC parsing. Note that TOC parser becomes stricter; please report any warnings.
- Fixed chinese encoding TOC bugs, chinese files are now also shown correctly.
- Added ” entity to the entities list.
2005-04-19 tim
- added support for built-in images, including custom images for folders;
- re-merged toolbar images into the executable as PNGs (uses less space);
- switched to autoconf/automake from qmake to simplify building and distribution, and to simplify KDEing;
2005-04-05 tim
- version 0.1alpha released
- fixed slowdown on big files;
2005-04-05 tim
- images merged into the main executable
kchmviewer-7.5/PaxHeaders.8614/build-release.sh 0000644 0000000 0000000 00000000124 12616333137 016267 x ustar 00 27 mtime=1446622815.937622
27 atime=1447562193.032735
30 ctime=1447562193.032735926
kchmviewer-7.5/build-release.sh 0000755 0001750 0000144 00000006122 12616333137 016623 0 ustar 00tim users 0000000 0000000 #!/bin/sh
# Export the source code
BUILD_RPM64=1
BUILD_RPM32=1
BUILD_WINDOWS=1
PACKAGE=kchmviewer
BINARYFILE="bin/kchmviewer"
FILE_VERSION="src/version.h"
RPM_OUTDIR="/home/tim/rpmbuild/RPMS"
# Get current version
VERSION_MAJOR=`sed -n 's/^\#define\s\+APP_VERSION_MAJOR\s\+\([0-9a-z]\+\)/\1/p' $FILE_VERSION`
VERSION_MINOR=`sed -n 's/^\#define\s\+APP_VERSION_MINOR\s\+\"\?\([0-9a-z]\+\)\"\?/\1/p' $FILE_VERSION`
CURRENTVER="$VERSION_MAJOR.$VERSION_MINOR"
BUILDDIR="$PACKAGE-$CURRENTVER"
RELEASEDIR="release-$CURRENTVER"
if [ -d "$BUILDDIR" ]; then
rm -rf "$BUILDDIR"
fi
if [ -d "$RELEASEDIR" ]; then
rm -rf "$RELEASEDIR"
fi
mkdir "$RELEASEDIR" || exit 1
# Source package
svn export . "$BUILDDIR/" || exit 1
tar zcf "$RELEASEDIR/$PACKAGE-$CURRENTVER.tar.gz" $BUILDDIR || exit 1
# win32
sh build-win32-mingw.sh -nsis || exit 1
mv build.win32/nsis/InstallKchmviewer*.exe $RELEASEDIR
rm -rf "build.win32"
# Linux RPMs
for target in qt5-32 qt5-64 qt4-32 qt4-64; do
echo "Building for $target"
rm -rf "$BUILDDIR"
svn export . "$BUILDDIR/" || exit 1
# Get the Qt version
case $target in
qt4-*)
QMAKE=qmake
QTLIBS="QtDBus QtXml QtGui QtCore QtNetwork QtWebKit"
RPMSUFFIX="qt4"
;;
qt5-*)
QMAKE=qmake-qt5
QTLIBS="Qt5WebKitWidgets Qt5PrintSupport Qt5WebKit Qt5Widgets Qt5Xml Qt5DBus Qt5Network Qt5Gui Qt5Core GL"
RPMSUFFIX="qt5"
;;
*)
echo "Invalid target"
exit 1
esac
# Get the arch
case $target in
*-32)
QMAKESPEC="linux-g++-32"
RPMARCH="i586"
LINKLIBS="pthread chm zip $QTLIBS"
;;
*-64)
QMAKESPEC="linux-g++-64"
RPMARCH="x86_64"
;;
*)
echo "Invalid arch"
exit 1
esac
# Hack the libs
if [ -n "$LINKLIBS" ]; then
pushd $BUILDDIR
# Link the libraries so the linker finds the 32-bit libs instead of 64-bit ones
for lib in $LINKLIBS; do
libpath=`find /lib /usr/lib/ -maxdepth 1 -name lib$lib.so | sort -r | head -n1`
if [ -z "$libpath" ]; then
libpath=`find /lib /usr/lib/ -maxdepth 1 -name lib$lib.so\.[0-9] | sort -r | head -n1`
if [ -z "$libpath" ]; then
echo "No library $lib found"
exit
fi
fi
ln -s $libpath "src/lib$lib.so"
done
popd
fi
# Build it
(cd "$BUILDDIR" && $QMAKE -r -spec $QMAKESPEC "CONGIF+=release" && make -j4) || exit 1
# Making the RPM root
rm -rf "$BUILDDIR/buildroot"
mkdir -p "$BUILDDIR/buildroot/usr/bin"
mkdir -p "$BUILDDIR/buildroot/usr/share/applications"
mkdir -p "$BUILDDIR/buildroot/usr/share/pixmaps"
cp packages/*.desktop "$BUILDDIR/buildroot/usr/share/applications"
cp packages/*.png "$BUILDDIR/buildroot/usr/share/pixmaps"
strip --strip-all "$BUILDDIR/bin/kchmviewer" -o "$BUILDDIR/buildroot/usr/bin/kchmviewer" || exit 1
# Prepare a spec file
sed "s/^Version: [0-9.]\\+/Version: $CURRENTVER/" packages/rpm.spec > $BUILDDIR/rpm.spec
# Build an RPM
rpmbuild -bb --target=$RPMARCH --buildroot `pwd`"/$BUILDDIR/buildroot/" $BUILDDIR/rpm.spec || exit 1
mv $RPM_OUTDIR/$RPMARCH/kchmviewer-$CURRENTVER-1.$RPMARCH.rpm "$RELEASEDIR/kchmviewer-$CURRENTVER-1.${RPMARCH}-${RPMSUFFIX}.rpm" || exit 1
rm -rf "$BUILDDIR"
done
echo "Done! Version $CURRENTVER released!"
kchmviewer-7.5/PaxHeaders.8614/lib 0000644 0000000 0000000 00000000131 12622005721 013675 x ustar 00 30 mtime=1447562193.073735369
29 atime=1447562193.04573575
30 ctime=1447562193.073735369
kchmviewer-7.5/lib/ 0000755 0001750 0000144 00000000000 12622005721 014304 5 ustar 00tim users 0000000 0000000 kchmviewer-7.5/lib/PaxHeaders.8614/lib.pro 0000644 0000000 0000000 00000000124 12316713333 015251 x ustar 00 27 mtime=1396414171.836935
27 atime=1447562193.070735
30 ctime=1447562193.071735396
kchmviewer-7.5/lib/lib.pro 0000644 0001750 0000144 00000000066 12316713333 015603 0 ustar 00tim users 0000000 0000000 SUBDIRS += libebook
TEMPLATE = subdirs
CONFIG += xml
kchmviewer-7.5/lib/PaxHeaders.8614/libebook 0000644 0000000 0000000 00000000130 12622005721 015462 x ustar 00 29 mtime=1447562193.09273511
30 atime=1447562193.071735396
29 ctime=1447562193.09273511
kchmviewer-7.5/lib/libebook/ 0000755 0001750 0000144 00000000000 12622005721 016072 5 ustar 00tim users 0000000 0000000 kchmviewer-7.5/lib/libebook/PaxHeaders.8614/helperxmlhandler_epubtoc.cpp 0000644 0000000 0000000 00000000123 12325413144 023326 x ustar 00 27 mtime=1398150756.763307
27 atime=1447562193.092735
29 ctime=1447562193.09273511
kchmviewer-7.5/lib/libebook/helperxmlhandler_epubtoc.cpp 0000644 0001750 0000144 00000005146 12325413144 023665 0 ustar 00tim users 0000000 0000000 /*
* Kchmviewer - a CHM and EPUB file viewer with broad language support
* Copyright (C) 2004-2014 George Yunaev, gyunaev@ulduzsoft.com
*
* 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, either version 3 of the License, or
* (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#include
#include "helperxmlhandler_epubtoc.h"
HelperXmlHandler_EpubTOC::HelperXmlHandler_EpubTOC(EBook_EPUB *epub)
{
m_epub = epub;
m_inNavMap = false;
m_inText = false;
m_indent = 0;
}
bool HelperXmlHandler_EpubTOC::startElement(const QString &, const QString &localName, const QString &, const QXmlAttributes &atts)
{
// qDebug() << "startElement " << " " << localName;
// for ( int i = 0; i < atts.count(); i++ )
// qDebug() << " " << atts.localName(i) << " " << atts.value(i);
if ( localName == "navMap" )
{
m_inNavMap = true;
return true;
}
if ( !m_inNavMap )
return true;
if ( localName == "navPoint" )
m_indent++;
if ( localName == "text" )
m_inText = true;
if ( localName == "content" )
{
int idx = atts.index( "src" );
if ( idx == -1 )
return false;
m_lastId = atts.value( idx );
checkNewTocEntry();
}
return true;
}
bool HelperXmlHandler_EpubTOC::characters(const QString &ch)
{
// qDebug() << "characters" << " " << ch;
if ( m_inText )
m_lastTitle = ch;
checkNewTocEntry();
return true;
}
bool HelperXmlHandler_EpubTOC::endElement(const QString& , const QString &localName, const QString &)
{
// qDebug() << "endElement" << " " << qName;
if ( localName == "navMap" )
{
m_inNavMap = false;
return true;
}
if ( localName == "navPoint" )
m_indent--;
if ( localName == "text" )
m_inText = false;
return true;
}
void HelperXmlHandler_EpubTOC::checkNewTocEntry()
{
if ( !m_lastId.isEmpty() && !m_lastTitle.isEmpty() )
{
EBookTocEntry entry;
entry.name = m_lastTitle;
entry.url = m_epub->pathToUrl( m_lastId );
entry.iconid = EBookTocEntry::IMAGE_AUTO;
entry.indent = m_indent - 1;
entries.push_back( entry );
//qDebug() << "TOC entry: " << m_lastId << " :" << m_lastTitle << " :" << m_indent - 1;
m_lastId.clear();
m_lastTitle.clear();
}
}
kchmviewer-7.5/lib/libebook/PaxHeaders.8614/ebook_search.h 0000644 0000000 0000000 00000000123 12321077735 020350 x ustar 00 27 mtime=1396998109.567818
27 atime=1447562193.081735
29 ctime=1447562193.08173526
kchmviewer-7.5/lib/libebook/ebook_search.h 0000644 0001750 0000144 00000006426 12321077735 020711 0 ustar 00tim users 0000000 0000000 /*
* Kchmviewer - a CHM and EPUB file viewer with broad language support
* Copyright (C) 2004-2014 George Yunaev, gyunaev@ulduzsoft.com
*
* 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, either version 3 of the License, or
* (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#ifndef EBookSearch_H
#define EBookSearch_H
#include
#include "helper_search_index.h"
class EBook;
class EBookSearch : public QObject
{
Q_OBJECT
public:
EBookSearch();
~EBookSearch();
//! Loads the search index from the data stream \param stream.
//! The index should be previously saved with generateIndex().
bool loadIndex( QDataStream& stream );
//! Generates the search index from the opened CHM file \param chmFile,
//! and saves it to the data stream \param stream which should be writeable.
//!
//! To show the progress, this procedure emits a progressStep() signal periodically
//! with the value showing current progress in percentage (i.e. from 0 to 100)
//! After signal emission, the following event processing function will be called:
//! qApp->processEvents( QEventLoop::ExcludeUserInputEvents )
//! to make sure the dialogs (if any) are properly updated.
//!
//! If \param progressDls is not null, it will be used to display progress.
//! Returns true if the index has been generated and saved, or false if internal
//! error occurs, or (most likely) the cancelIndexGeneration() slot has been called.
bool generateIndex( EBook * ebook, QDataStream& stream );
//! Executes the search query. The \param query is a string like "C++ language" class,
//! \param results is a pointer to QStringList, and \param limit limits the number of
//! results in case the query is too generic (like \a "a" ).
//! The \param chmFile is used to get the current encoding information.
//! The return value is false only if the index is not generated, or if a closing quote character
//! is missing. Call hasIndex() to clarify. If search returns no results, the return value is
//! true, but the \param results list will be empty.
//!
//! Note that the function does not clear \param results before adding search results, so if you are
//! not merging search results, make sure it's empty.
bool searchQuery ( const QString& query, QList< QUrl > * results, EBook * chmFile, unsigned int limit = 100 );
//! Returns true if a valid search index is present, and therefore search could be executed
bool hasIndex() const;
signals:
void progressStep( int value, const QString& stepName );
public slots:
void cancelIndexGeneration();
private slots:
void updateProgress( int value, const QString& stepName );
void processEvents();
private:
QStringList m_keywordDocuments;
QtAs::Index * m_Index;
};
#endif
kchmviewer-7.5/lib/libebook/PaxHeaders.8614/CMakeLists.txt 0000644 0000000 0000000 00000000124 12322425122 020300 x ustar 00 27 mtime=1397369426.255372
27 atime=1447562193.074735
30 ctime=1447562193.078735301
kchmviewer-7.5/lib/libebook/CMakeLists.txt 0000644 0001750 0000144 00000000547 12322425122 020636 0 ustar 00tim users 0000000 0000000 # Project files
SET( libebookSources
ebook_chm.cpp
ebook_epub.cpp
ebook.cpp
ebook_chm_encoding.cpp
ebook_search.cpp
helper_entitydecoder.cpp
helper_search_index.cpp
helperxmlhandler_epubcontainer.cpp
helperxmlhandler_epubcontent.cpp
helperxmlhandler_epubtoc.cpp
)
KDE4_ADD_LIBRARY( ebook STATIC ${libebookSources} )
kchmviewer-7.5/lib/libebook/PaxHeaders.8614/bitfiddle.h 0000644 0000000 0000000 00000000124 11270704705 017647 x ustar 00 27 mtime=1256425925.210996
27 atime=1447562193.079735
30 ctime=1447562193.079735287
kchmviewer-7.5/lib/libebook/bitfiddle.h 0000644 0001750 0000144 00000006427 11270704705 020210 0 ustar 00tim users 0000000 0000000 /*
Copyright (C) 2003 Razvan Cojocaru
Most of the code in this file is a modified version of code from
Pabs' GPL chmdeco project, credits and thanks go to him.
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; either version 2 of the License, or
(at your option) any later version.
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.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
inline unsigned short UINT16ARRAY( const void * x )
{
unsigned char * p = (unsigned char *) x;
return p[0] | (p[1] << 8);
}
inline unsigned int UINT32ARRAY( const void * x )
{
unsigned char * p = (unsigned char *) x;
return p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24);
}
inline int INT32ARRAY( const void * x )
{
char * p = (char *) x;
return p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24);
}
inline unsigned int get_int32_le( void *addr)
{
unsigned char *p = (unsigned char*) addr;
return (unsigned int) ( p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24) );
}
inline quint64 be_encint(unsigned char* buffer, size_t& length)
{
quint64 result = 0;
int shift=0;
length = 0;
do {
result |= ((*buffer) & 0x7f) << shift;
shift += 7;
++length;
} while (*(buffer++) & 0x80);
return result;
}
/*
Finds the first unset bit in memory. Returns the number of set bits found.
Returns -1 if the buffer runs out before we find an unset bit.
*/
inline int ffus(unsigned char* byte, int* bit, size_t& length)
{
int bits = 0;
length = 0;
while(*byte & (1 << *bit)){
if(*bit)
--(*bit);
else {
++byte;
++length;
*bit = 7;
}
++bits;
}
if(*bit)
--(*bit);
else {
++length;
*bit = 7;
}
return bits;
}
inline quint64 sr_int(unsigned char* byte, int* bit,
unsigned char s, unsigned char r, size_t& length)
{
quint64 ret;
unsigned char mask;
int n, n_bits, num_bits, base, count;
length = 0;
size_t fflen;
if(!bit || *bit > 7 || s != 2)
return ~(quint64)0;
ret = 0;
count = ffus(byte, bit, fflen);
length += fflen;
byte += length;
n_bits = n = r + (count ? count-1 : 0) ;
while(n > 0) {
num_bits = n > *bit ? *bit : n-1;
base = n > *bit ? 0 : *bit - (n-1);
switch(num_bits){
case 0:
mask = 1;
break;
case 1:
mask = 3;
break;
case 2:
mask = 7;
break;
case 3:
mask = 0xf;
break;
case 4:
mask = 0x1f;
break;
case 5:
mask = 0x3f;
break;
case 6:
mask = 0x7f;
break;
case 7:
mask = 0xff;
break;
default:
mask = 0xff;
break;
}
mask <<= base;
ret = (ret << (num_bits+1)) |
(quint64)((*byte & mask) >> base);
if( n > *bit ){
++byte;
++length;
n -= *bit+1;
*bit = 7;
} else {
*bit -= n;
n = 0;
}
}
if(count)
ret |= (quint64)1 << n_bits;
return ret;
}
kchmviewer-7.5/lib/libebook/PaxHeaders.8614/ebook_chm_encoding.h 0000644 0000000 0000000 00000000124 12321077735 021521 x ustar 00 27 mtime=1396998109.567818
27 atime=1447562193.080735
30 ctime=1447562193.080735274
kchmviewer-7.5/lib/libebook/ebook_chm_encoding.h 0000644 0001750 0000144 00000001757 12321077735 022063 0 ustar 00tim users 0000000 0000000 /*
* Kchmviewer - a CHM and EPUB file viewer with broad language support
* Copyright (C) 2004-2014 George Yunaev, gyunaev@ulduzsoft.com
*
* 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, either version 3 of the License, or
* (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#ifndef EBOOK_CHM_ENCODING_H
#define EBOOK_CHM_ENCODING_H
#include
class Ebook_CHM_Encoding
{
public:
static QString guessByLCID( unsigned short lcid );
};
#endif // EBOOK_CHM_ENCODING_H
kchmviewer-7.5/lib/libebook/PaxHeaders.8614/libebook.pro 0000644 0000000 0000000 00000000123 12616333137 020061 x ustar 00 27 mtime=1446622815.937622
27 atime=1447562193.092735
29 ctime=1447562193.09273511
kchmviewer-7.5/lib/libebook/libebook.pro 0000644 0001750 0000144 00000001272 12616333137 020414 0 ustar 00tim users 0000000 0000000 HEADERS += bitfiddle.h \
ebook_chm.h \
ebook_epub.h \
ebook.h \
ebook_chm_encoding.h \
ebook_search.h \
helper_entitydecoder.h \
helper_search_index.h \
helperxmlhandler_epubcontainer.h \
helperxmlhandler_epubcontent.h \
helperxmlhandler_epubtoc.h
SOURCES += \
ebook_chm.cpp \
ebook_epub.cpp \
ebook.cpp \
ebook_chm_encoding.cpp \
ebook_search.cpp \
helper_entitydecoder.cpp \
helper_search_index.cpp \
helperxmlhandler_epubcontainer.cpp \
helperxmlhandler_epubcontent.cpp \
helperxmlhandler_epubtoc.cpp
TARGET = ebook
CONFIG += warn_on \
qt \
staticlib
TEMPLATE = lib
INCLUDEPATH += ../../src
QT += widgets
kchmviewer-7.5/lib/libebook/PaxHeaders.8614/ebook.cpp 0000644 0000000 0000000 00000000124 12321077735 017357 x ustar 00 27 mtime=1396998109.567818
27 atime=1447562193.079735
30 ctime=1447562193.079735287
kchmviewer-7.5/lib/libebook/ebook.cpp 0000644 0001750 0000144 00000002341 12321077735 017707 0 ustar 00tim users 0000000 0000000 /*
* Kchmviewer - a CHM and EPUB file viewer with broad language support
* Copyright (C) 2004-2014 George Yunaev, gyunaev@ulduzsoft.com
*
* 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, either version 3 of the License, or
* (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#include "ebook.h"
#include "ebook_chm.h"
#include "ebook_epub.h"
const char * const INTERNAL_URL_SCHEME = "kchm";
EBook::EBook()
{
}
EBook::~EBook()
{
}
EBook * EBook::loadFile( const QString &archiveName )
{
EBook_CHM * cbook = new EBook_CHM();
if ( cbook->load( archiveName ) )
return cbook;
delete cbook;
EBook_EPUB * ebook = new EBook_EPUB();
if ( ebook->load( archiveName ) )
return ebook;
delete ebook;
return 0;
}
kchmviewer-7.5/lib/libebook/PaxHeaders.8614/ebook_url.h 0000644 0000000 0000000 00000000124 12317212375 017702 x ustar 00 27 mtime=1396511997.347081
27 atime=1447562193.081735
30 ctime=1447562193.090735139
kchmviewer-7.5/lib/libebook/ebook_url.h 0000644 0001750 0000144 00000000255 12317212375 020234 0 ustar 00tim users 0000000 0000000 #ifndef EBOOK_URL_H
#define EBOOK_URL_H
#include
class EbookURL : public QUrl
{
public:
EbookURL();
EbookURL( const QString & url );
};
#endif // EBOOK_URL_H
kchmviewer-7.5/lib/libebook/PaxHeaders.8614/ebook_search.cpp 0000644 0000000 0000000 00000000123 12616333137 020701 x ustar 00 27 mtime=1446622815.937622
27 atime=1447562193.081735
29 ctime=1447562193.08173526
kchmviewer-7.5/lib/libebook/ebook_search.cpp 0000644 0001750 0000144 00000012407 12616333137 021236 0 ustar 00tim users 0000000 0000000 /*
* Kchmviewer - a CHM and EPUB file viewer with broad language support
* Copyright (C) 2004-2014 George Yunaev, gyunaev@ulduzsoft.com
*
* 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, either version 3 of the License, or
* (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#include
#include "ebook.h"
#include "ebook_search.h"
// Helper class to simplity state management and data keeping
class SearchDataKeeper
{
public:
SearchDataKeeper() { m_inPhrase = false; }
void beginPhrase()
{
phrase_terms.clear();
m_inPhrase = true;
}
void endPhrase()
{
m_inPhrase = false;
phrasewords += phrase_terms;
phrases.push_back( phrase_terms.join(" ") );
}
bool isInPhrase() const { return m_inPhrase; }
void addTerm( const QString& term )
{
if ( !term.isEmpty() )
{
terms.push_back( term );
if ( m_inPhrase )
phrase_terms.push_back( term );
}
}
// Should contain all the search terms present in query, includind those from phrases. One element - one term .
QStringList terms;
// Should contain phrases present in query without quotes. One element - one phrase.
QStringList phrases;
// Should contain all the terms present in all the phrases (but not outside).
QStringList phrasewords;
private:
bool m_inPhrase;
QStringList phrase_terms;
};
EBookSearch::EBookSearch()
{
m_Index = 0;
}
EBookSearch::~ EBookSearch()
{
delete m_Index;
}
bool EBookSearch::loadIndex( QDataStream & stream )
{
delete m_Index;
m_Index = new QtAs::Index();
return m_Index->readDict( stream );
}
bool EBookSearch::generateIndex( EBook * ebookFile, QDataStream & stream )
{
QList< QUrl > documents;
QList< QUrl > alldocuments;
emit progressStep( 0, "Generating the list of documents" );
processEvents();
// Enumerate the documents
if ( !ebookFile->enumerateFiles( alldocuments ) )
return false;
if ( m_Index )
delete m_Index;
m_Index = new QtAs::Index();
connect( m_Index, SIGNAL( indexingProgress( int, const QString& ) ), this, SLOT( updateProgress( int, const QString& ) ) );
// Process the list of files in CHM archive and keep only HTML document files from there
for ( int i = 0; i < alldocuments.size(); i++ )
{
QString docpath = alldocuments[i].path();
if ( docpath.endsWith( ".html", Qt::CaseInsensitive )
|| docpath.endsWith( ".htm", Qt::CaseInsensitive )
|| docpath.endsWith( ".xhtml", Qt::CaseInsensitive ) )
documents.push_back( alldocuments[i] );
}
if ( !m_Index->makeIndex( documents, ebookFile ) )
{
delete m_Index;
m_Index = 0;
return false;
}
m_Index->writeDict( stream );
m_keywordDocuments.clear();
return true;
}
void EBookSearch::cancelIndexGeneration()
{
m_Index->setLastWinClosed();
}
void EBookSearch::updateProgress(int value, const QString & stepName)
{
emit progressStep( value, stepName );
}
void EBookSearch::processEvents()
{
// Do it up to ten times; some events generate other events
for ( int i = 0; i < 10; i++ )
qApp->processEvents( QEventLoop::ExcludeUserInputEvents );
}
bool EBookSearch::searchQuery(const QString & query, QList< QUrl > * results, EBook *ebookFile, unsigned int limit)
{
// We should have index
if ( !m_Index )
return false;
// Characters which split the words. We need to make them separate tokens
QString splitChars = m_Index->getCharsSplit();
// Characters which are part of the word. We should keep them apart.
QString partOfWordChars = m_Index->getCharsPartOfWord();
// Variables to store current state
SearchDataKeeper keeper;
QString term;
for ( int i = 0; i < query.length(); i++ )
{
QChar ch = query[i].toLower();
// a quote either begins or ends the phrase
if ( ch == '"' )
{
keeper.addTerm( term );
if ( keeper.isInPhrase() )
keeper.endPhrase();
else
keeper.beginPhrase();
continue;
}
// If new char does not stop the word, add ot and continue
if ( ch.isLetterOrNumber() || partOfWordChars.indexOf( ch ) != -1 )
{
term.append( ch );
continue;
}
// If it is a split char, add this term and split char as separate term
if ( splitChars.indexOf( ch ) != -1 )
{
// Add existing term if present
keeper.addTerm( term );
// Change the term variable, so it will be added when we exit this block
term = ch;
}
// Just add the word; it is most likely a space or terminated by tokenizer.
keeper.addTerm( term );
term = QString::null;
}
keeper.addTerm( term );
if ( keeper.isInPhrase() )
return false;
QList< QUrl > foundDocs = m_Index->query( keeper.terms, keeper.phrases, keeper.phrasewords, ebookFile );
for ( QList< QUrl >::iterator it = foundDocs.begin(); it != foundDocs.end() && limit > 0; ++it, limit-- )
results->push_back( *it );
return true;
}
bool EBookSearch::hasIndex() const
{
return m_Index != 0;
}
kchmviewer-7.5/lib/libebook/PaxHeaders.8614/ebook_epub.cpp 0000644 0000000 0000000 00000000123 12622003403 020352 x ustar 00 27 mtime=1447560963.701728
27 atime=1447562193.080735
29 ctime=1447562193.08173526
kchmviewer-7.5/lib/libebook/ebook_epub.cpp 0000644 0001750 0000144 00000017034 12622003403 020710 0 ustar 00tim users 0000000 0000000 /*
* Kchmviewer - a CHM and EPUB file viewer with broad language support
* Copyright (C) 2004-2014 George Yunaev, gyunaev@ulduzsoft.com
*
* 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, either version 3 of the License, or
* (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#include
#include
#include "ebook_epub.h"
#include "helperxmlhandler_epubcontainer.h"
#include "helperxmlhandler_epubcontent.h"
#include "helperxmlhandler_epubtoc.h"
static const char * URL_SCHEME_EPUB = "epub";
EBook_EPUB::EBook_EPUB()
{
m_zipFile = 0;
}
EBook_EPUB::~EBook_EPUB()
{
close();
}
bool EBook_EPUB::load(const QString &archiveName)
{
close();
// We use QFile and zip_fdopen instead of zip_open because latter does not support Unicode file names
m_epubFile.setFileName( archiveName );
if ( !m_epubFile.open( QIODevice::ReadOnly ) )
{
qWarning("Could not open file %s: %s", qPrintable(archiveName), qPrintable( m_epubFile.errorString()));
return false;
}
// Open the ZIP archive: http://www.nih.at/libzip/zip_fdopen.html
int errcode;
m_zipFile = zip_fdopen( m_epubFile.handle(), 0, &errcode );
if ( !m_zipFile )
{
qWarning("Could not open file %s: error %d", qPrintable(archiveName), errcode);
return false;
}
// Parse the book descriptor file
if ( !parseBookinfo() )
return false;
return true;
}
void EBook_EPUB::close()
{
if ( m_zipFile )
{
zip_close( m_zipFile );
m_zipFile = 0;
}
if ( m_epubFile.isOpen() )
m_epubFile.close();
}
bool EBook_EPUB::getFileContentAsString(QString &str, const QUrl &url) const
{
return getFileAsString( str, urlToPath( url ) );
}
bool EBook_EPUB::getFileContentAsBinary(QByteArray &data, const QUrl &url) const
{
return getFileAsBinary( data, urlToPath( url ) );
}
bool EBook_EPUB::enumerateFiles(QList &files)
{
files = m_ebookManifest;
return true;
}
QString EBook_EPUB::title() const
{
return m_title;
}
QUrl EBook_EPUB::homeUrl() const
{
return m_tocEntries[0].url;
}
bool EBook_EPUB::hasFeature(EBook::Feature code) const
{
switch ( code )
{
case FEATURE_TOC:
return true;
case FEATURE_INDEX:
return false;
case FEATURE_ENCODING:
return false;
}
return false;
}
bool EBook_EPUB::getTableOfContents( QList &toc ) const
{
toc = m_tocEntries;
return true;
}
bool EBook_EPUB::getIndex(QList &) const
{
return false;
}
QString EBook_EPUB::getTopicByUrl(const QUrl& url)
{
if ( m_urlTitleMap.contains( url ) )
return m_urlTitleMap[ url ];
return "";
}
QString EBook_EPUB::currentEncoding() const
{
return "UTF-8";
}
bool EBook_EPUB::setCurrentEncoding(const char *)
{
abort();
}
bool EBook_EPUB::isSupportedUrl(const QUrl &url)
{
return url.scheme() == URL_SCHEME_EPUB;
}
bool EBook_EPUB::parseXML(const QString &uri, QXmlDefaultHandler * parser)
{
QByteArray container;
if ( !getFileAsBinary( container, uri ) )
{
qDebug("Failed to retrieve XML file %s", qPrintable( uri ) );
return false;
}
// Use it as XML source
QXmlInputSource source;
source.setData( container );
// Init the reader
QXmlSimpleReader reader;
reader.setContentHandler( parser );
reader.setErrorHandler( parser );
return reader.parse( source );
}
bool EBook_EPUB::parseBookinfo()
{
// Parse the container.xml to find the content descriptor
HelperXmlHandler_EpubContainer container_parser;
if ( !parseXML( "META-INF/container.xml", &container_parser )
|| container_parser.contentPath.isEmpty() )
return false;
// Parse the content.opf
HelperXmlHandler_EpubContent content_parser;
if ( !parseXML( container_parser.contentPath, &content_parser ) )
return false;
// At least title and the TOC must be present
if ( !content_parser.metadata.contains("title") || content_parser.tocname.isEmpty() )
return false;
// All the files, including TOC, are relative to the container_parser.contentPath
m_documentRoot.clear();
int sep = container_parser.contentPath.lastIndexOf( '/' );
if ( sep != -1 )
m_documentRoot = container_parser.contentPath.left( sep + 1 ); // Keep the trailing slash
// Parse the TOC
HelperXmlHandler_EpubTOC toc_parser( this );
if ( !parseXML( content_parser.tocname, &toc_parser ) )
return false;
// Get the data
m_title = content_parser.metadata[ "title" ];
// Copy the manifest information and fill up the other maps
Q_FOREACH( EBookTocEntry e, toc_parser.entries )
{
// Add into url-title map
m_urlTitleMap[ e.url ] = e.name;
m_tocEntries.push_back( e );
}
// Move the manifest entries into the list
Q_FOREACH( QString f, content_parser.manifest.values() )
m_ebookManifest.push_back( pathToUrl( f ) );
return true;
}
QUrl EBook_EPUB::pathToUrl(const QString &link) const
{
QUrl url;
url.setScheme( URL_SCHEME_EPUB );
url.setHost( URL_SCHEME_EPUB );
// Does the link contain the fragment as well?
int off = link.indexOf( '#' );
QString path;
if ( off != -1 )
{
path = link.left( off );
url.setFragment( link.mid( off + 1 ) );
}
else
path = link;
if ( !path.startsWith( '/' ) )
path.prepend( '/' );
url.setPath( QUrl::fromPercentEncoding( path.toUtf8() ) );
return url;
}
QString EBook_EPUB::urlToPath(const QUrl &link) const
{
if ( link.scheme() == URL_SCHEME_EPUB )
return link.path();
return "";
}
bool EBook_EPUB::getFileAsString(QString &str, const QString &path) const
{
QByteArray data;
if ( !getFileAsBinary( data, path ) )
return false;
// I have never seen yet an UTF16 epub
if ( data.startsWith("" );
int utf16 = data.indexOf("UTF-16");
if ( utf16 > 0 && utf16 < endxmltag )
{
QMessageBox::critical( 0,
("Unsupported encoding"),
("The encoding of this ebook is not supported yet. Please send it to gyunaev@ulduzsoft.com for support to be added") );
return false;
}
}
str = QString::fromUtf8( data );
return true;
}
bool EBook_EPUB::getFileAsBinary(QByteArray &data, const QString &path) const
{
// Retrieve the file size
struct zip_stat fileinfo;
QString completeUrl;
if ( !path.isEmpty() && path[0] == '/' )
completeUrl = m_documentRoot + path.mid( 1 );
else
completeUrl = m_documentRoot + path;
//qDebug("URL requested: %s (%s)", qPrintable(path), qPrintable(completeUrl));
// http://www.nih.at/libzip/zip_stat.html
if ( zip_stat( m_zipFile, completeUrl.toUtf8().constData(), 0, &fileinfo) != 0 )
{
qDebug("File %s is not found in the archive", qPrintable(completeUrl));
return false;
}
// Make sure the size field is valid
if ( (fileinfo.valid & ZIP_STAT_SIZE) == 0 || (fileinfo.valid & ZIP_STAT_INDEX) == 0 )
return false;
// Open the file
struct zip_file * file = zip_fopen_index( m_zipFile, fileinfo.index, 0 );
if ( !file )
return false;
// Allocate the memory and read the file
data.resize( fileinfo.size );
// Could it return a positive number but not fileinfo.size???
int ret = zip_fread( file, data.data(), fileinfo.size );
if ( ret != (int) fileinfo.size )
{
zip_fclose( file );
return false;
}
zip_fclose( file );
return true;
}
kchmviewer-7.5/lib/libebook/PaxHeaders.8614/helper_search_index.cpp 0000644 0000000 0000000 00000000123 12446223156 022250 x ustar 00 26 mtime=1419322990.47456
27 atime=1447562193.090735
30 ctime=1447562193.090735139
kchmviewer-7.5/lib/libebook/helper_search_index.cpp 0000644 0001750 0000144 00000027645 12446223156 022617 0 ustar 00tim users 0000000 0000000 /*
* Kchmviewer - a CHM and EPUB file viewer with broad language support
* Copyright (C) 2004-2014 George Yunaev, gyunaev@ulduzsoft.com
*
* 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, either version 3 of the License, or
* (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#include
#include
#include "ebook.h"
#include "ebook_search.h"
#include "helper_search_index.h"
static const int DICT_VERSION = 4;
namespace QtAs {
// Those characters are splitters (i.e. split the word), but added themselves into dictionary too.
// This makes the dictionary MUCH larger, but ensure that for the piece of "window->print" both
// search for "print" and "->print" will find it.
static const char SPLIT_CHARACTERS[] = "!()*&^%#@[]{}':;,.?/|/?<>\\-+=~`";
// Those characters are parts of word - for example, '_' is here, and search for _debug will find only _debug.
static const char WORD_CHARACTERS[] = "$_";
struct Term
{
Term() : frequency(-1) {}
Term( const QString &t, int f, QVector l ) : term( t ), frequency( f ), documents( l ) {}
QString term;
int frequency;
QVectordocuments;
bool operator<( const Term &i2 ) const { return frequency < i2.frequency; }
};
QDataStream &operator>>( QDataStream &s, Document &l )
{
s >> l.docNumber;
s >> l.frequency;
return s;
}
QDataStream &operator<<( QDataStream &s, const Document &l )
{
s << (short)l.docNumber;
s << (short)l.frequency;
return s;
}
Index::Index()
: QObject( 0 )
{
lastWindowClosed = false;
connect( qApp, SIGNAL( lastWindowClosed() ), this, SLOT( setLastWinClosed() ) );
}
void Index::setLastWinClosed()
{
lastWindowClosed = true;
}
bool Index::makeIndex(const QList< QUrl >& docs, EBook *chmFile )
{
if ( docs.isEmpty() )
return false;
docList = docs;
if ( chmFile->hasFeature( EBook::FEATURE_ENCODING ) )
entityDecoder.changeEncoding( QTextCodec::codecForName( chmFile->currentEncoding().toUtf8() ) );
QList< QUrl >::ConstIterator it = docList.begin();
int steps = docList.count() / 100;
if ( !steps )
steps++;
int prog = 0;
for ( int i = 0; it != docList.end(); ++it, ++i )
{
if ( lastWindowClosed )
return false;
QUrl filename = *it;
QStringList terms;
if ( parseDocumentToStringlist( chmFile, filename, terms ) )
{
for ( QStringList::ConstIterator tit = terms.begin(); tit != terms.end(); ++tit )
insertInDict( *tit, i );
}
if ( i%steps == 0 )
{
prog++;
prog = qMin( prog, 99 );
emit indexingProgress( prog, tr("Processing document %1") .arg( (*it).path() ) );
}
}
emit indexingProgress( 100, tr("Processing completed") );
return true;
}
void Index::insertInDict( const QString &str, int docNum )
{
Entry *e = 0;
if ( dict.count() )
e = dict[ str ];
if ( e )
{
if ( e->documents.last().docNumber != docNum )
e->documents.append( Document(docNum, 1 ) );
else
e->documents.last().frequency++;
}
else
{
dict.insert( str, new Entry( docNum ) );
}
}
bool Index::parseDocumentToStringlist(EBook *chmFile, const QUrl& filename, QStringList& tokenlist )
{
QString parsedbuf, parseentity, text;
if ( !chmFile->getFileContentAsString( text, filename )
|| text.isEmpty() )
{
qWarning( "Search index generator: could not retrieve the document content for %s", qPrintable( filename.toString() ) );
return false;
}
m_charssplit = SPLIT_CHARACTERS;
m_charsword = WORD_CHARACTERS;
tokenlist.clear();
// State machine states
enum state_t
{
STATE_OUTSIDE_TAGS, // outside HTML tags; parse text
STATE_IN_HTML_TAG, // inside HTML tags; wait for end tag
STATE_IN_QUOTES, // inside HTML tags and inside quotes; wait for end quote (in var QuoteChar)
STATE_IN_HTML_ENTITY // inside HTML entity; parse the entity
};
state_t state = STATE_OUTSIDE_TAGS;
QChar QuoteChar; // used in STATE_IN_QUOTES
for ( int j = 0; j < text.length(); j++ )
{
QChar ch = text[j];
if ( (j % 20000) == 0 )
qApp->processEvents( QEventLoop::ExcludeUserInputEvents );
if ( state == STATE_IN_HTML_TAG )
{
// We are inside HTML tag.
// Ignore everything until we see '>' (end of HTML tag) or quote char (quote start)
if ( ch == '"' || ch == '\'' )
{
state = STATE_IN_QUOTES;
QuoteChar = ch;
}
else if ( ch == '>' )
state = STATE_OUTSIDE_TAGS;
continue;
}
else if ( state == STATE_IN_QUOTES )
{
// We are inside quoted text inside HTML tag.
// Ignore everything until we see the quote character again
if ( ch == QuoteChar )
state = STATE_IN_HTML_TAG;
continue;
}
else if ( state == STATE_IN_HTML_ENTITY )
{
// We are inside encoded HTML entity (like ).
// Collect to parsedbuf everything until we see ;
if ( ch.isLetterOrNumber() )
{
// get next character of this entity
parseentity.append( ch );
continue;
}
// The entity ended
state = STATE_OUTSIDE_TAGS;
// Some shitty HTML does not terminate entities correctly. Screw it.
if ( ch != ';' && ch != '<' )
{
if ( parseentity.isEmpty() )
{
// straight '&' symbol. Add and continue.
parsedbuf += "&";
}
else
qWarning( "Index::parseDocument: incorrectly terminated HTML entity '&%s%c', ignoring", qPrintable( parseentity ), ch.toLatin1() );
j--; // parse this character again, but in different state
continue;
}
// Don't we have a space?
if ( parseentity.toLower() != "nbsp" )
{
QString entity = entityDecoder.decode( parseentity );
if ( entity.isNull() )
{
// decodeEntity() already printed error message
//qWarning( "Index::parseDocument: failed to decode entity &%s;", parsedbuf.ascii() );
continue;
}
parsedbuf += entity;
continue;
}
else
ch = ' '; // We got a space, so treat it like it, and not add it to parsebuf
}
//
// Now process STATE_OUTSIDE_TAGS
//
// Check for start of HTML tag, and switch to STATE_IN_HTML_TAG if it is
if ( ch == '<' )
{
state = STATE_IN_HTML_TAG;
goto tokenize_buf;
}
// Check for start of HTML entity
if ( ch == '&' )
{
state = STATE_IN_HTML_ENTITY;
parseentity = QString::null;
continue;
}
// Replace quote by ' - quotes are used in search window to set the phrase
if ( ch == '"' )
ch = '\'';
// Ok, we have a valid character outside HTML tags, and probably some in buffer already.
// If it is char or letter, add it and continue
if ( ch.isLetterOrNumber() || m_charsword.indexOf( ch ) != -1 )
{
parsedbuf.append( ch );
continue;
}
// If it is a split char, add the word to the dictionary, and then add the char itself.
if ( m_charssplit.indexOf( ch ) != -1 )
{
if ( !parsedbuf.isEmpty() )
tokenlist.push_back( parsedbuf.toLower() );
tokenlist.push_back( ch.toLower() );
parsedbuf = QString::null;
continue;
}
tokenize_buf:
// Just add the word; it is most likely a space or terminated by tokenizer.
if ( !parsedbuf.isEmpty() )
{
tokenlist.push_back( parsedbuf.toLower() );
parsedbuf = QString::null;
}
}
// Add the last word if still here - for broken htmls.
if ( !parsedbuf.isEmpty() )
tokenlist.push_back( parsedbuf.toLower() );
return true;
}
void Index::writeDict( QDataStream& stream )
{
stream << DICT_VERSION;
stream << m_charssplit;
stream << m_charsword;
// Document list
stream << docList;
// Dictionary
for( QHash::ConstIterator it = dict.begin(); it != dict.end(); ++it )
{
stream << it.key();
stream << (int) it.value()->documents.count();
stream << it.value()->documents;
}
}
bool Index::readDict( QDataStream& stream )
{
dict.clear();
docList.clear();
QString key;
int version, numOfDocs;
stream >> version;
if ( version < 2 )
return false;
stream >> m_charssplit;
stream >> m_charsword;
// Read the document list
stream >> docList;
while ( !stream.atEnd() )
{
stream >> key;
stream >> numOfDocs;
QVector docs( numOfDocs );
stream >> docs;
dict.insert( key, new Entry( docs ) );
}
return dict.size() > 0;
}
QList< QUrl > Index::query(const QStringList &terms, const QStringList &termSeq, const QStringList &seqWords, EBook *chmFile )
{
QList termList;
QStringList::ConstIterator it = terms.begin();
for ( it = terms.begin(); it != terms.end(); ++it )
{
Entry *e = 0;
if ( dict[ *it ] )
{
e = dict[ *it ];
termList.append( Term( *it, e->documents.count(), e->documents ) );
}
else
{
return QList< QUrl >();
}
}
if ( !termList.count() )
return QList< QUrl >();
qSort( termList );
QVector minDocs = termList.takeFirst().documents;
for(QList::Iterator it = termList.begin(); it != termList.end(); ++it) {
Term *t = &(*it);
QVector docs = t->documents;
for(QVector::Iterator minDoc_it = minDocs.begin(); minDoc_it != minDocs.end(); ) {
bool found = false;
for (QVector::ConstIterator doc_it = docs.constBegin(); doc_it != docs.constEnd(); ++doc_it ) {
if ( (*minDoc_it).docNumber == (*doc_it).docNumber ) {
(*minDoc_it).frequency += (*doc_it).frequency;
found = true;
break;
}
}
if ( !found )
minDoc_it = minDocs.erase( minDoc_it );
else
++minDoc_it;
}
}
QList< QUrl > results;
qSort( minDocs );
if ( termSeq.isEmpty() ) {
for(QVector::Iterator it = minDocs.begin(); it != minDocs.end(); ++it)
results << docList.at((int)(*it).docNumber);
return results;
}
QUrl fileName;
for(QVector::Iterator it = minDocs.begin(); it != minDocs.end(); ++it) {
fileName = docList[ (int)(*it).docNumber ];
if ( searchForPhrases( termSeq, seqWords, fileName, chmFile ) )
results << fileName;
}
return results;
}
bool Index::searchForPhrases( const QStringList &phrases, const QStringList &words, const QUrl &filename, EBook * chmFile )
{
QStringList parsed_document;
if ( !parseDocumentToStringlist( chmFile, filename, parsed_document ) )
return false;
miniDict.clear();
// Initialize the dictionary with the words in phrase(s)
for ( QStringList::ConstIterator cIt = words.begin(); cIt != words.end(); ++cIt )
miniDict.insert( *cIt, new PosEntry( 0 ) );
// Fill the dictionary with the words from the document
unsigned int word_offset = 3;
for ( QStringList::ConstIterator it = parsed_document.begin(); it != parsed_document.end(); it++, word_offset++ )
{
PosEntry * entry = miniDict[ *it ];
if ( entry )
entry->positions.append( word_offset );
}
// Dump it
/*
QDictIterator it( miniDict );
for( ; it.current(); ++it )
{
QString text( it.currentKey() );
QValueList pos = miniDict[text]->positions;
for ( unsigned int i = 1; i < pos.size(); i++ )
text += " " + QString::number( pos[i] );
qDebug( "%s", text.ascii());
}
*/
QList first_word_positions;
for ( QStringList::ConstIterator phrase_it = phrases.begin(); phrase_it != phrases.end(); phrase_it++ )
{
QStringList phrasewords = phrase_it->split( ' ' );
first_word_positions = miniDict[ phrasewords[0] ]->positions;
for ( int j = 1; j < phrasewords.count(); ++j )
{
QList next_word_it = miniDict[ phrasewords[j] ]->positions;
QList::iterator dict_it = first_word_positions.begin();
while ( dict_it != first_word_positions.end() )
{
if ( next_word_it.indexOf( *dict_it + 1 ) != -1 )
{
(*dict_it)++;
++dict_it;
}
else
dict_it = first_word_positions.erase( dict_it );
}
}
}
if ( first_word_positions.count() )
return true;
return false;
}
};
kchmviewer-7.5/lib/libebook/PaxHeaders.8614/helperxmlhandler_epubcontent.cpp 0000644 0000000 0000000 00000000124 12321077735 024224 x ustar 00 27 mtime=1396998109.567818
27 atime=1447562193.091735
30 ctime=1447562193.091735125
kchmviewer-7.5/lib/libebook/helperxmlhandler_epubcontent.cpp 0000644 0001750 0000144 00000005633 12321077735 024563 0 ustar 00tim users 0000000 0000000 /*
* Kchmviewer - a CHM and EPUB file viewer with broad language support
* Copyright (C) 2004-2014 George Yunaev, gyunaev@ulduzsoft.com
*
* 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, either version 3 of the License, or
* (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#include "helperxmlhandler_epubcontent.h"
HelperXmlHandler_EpubContent::HelperXmlHandler_EpubContent()
{
m_state = STATE_NONE;
}
bool HelperXmlHandler_EpubContent::startElement(const QString &, const QString &localName, const QString &, const QXmlAttributes &atts)
{
// tag contains the medatada which goes into m_metadata
if ( localName == "metadata" )
m_state = STATE_IN_METADATA;
else if ( localName == "manifest" )
m_state = STATE_IN_MANIFEST;
else if ( localName == "spine" )
m_state = STATE_IN_SPINE;
// Now handle the states
else if ( m_state == STATE_IN_METADATA ) // we don't need to store the first 'metadata' here
m_tagname = localName;
else if ( m_state == STATE_IN_MANIFEST && localName == "item" )
{
int idx_id = atts.index( "id" );
int idx_href = atts.index( "href" );
int idx_mtype = atts.index( "media-type" );
if ( idx_id == -1 || idx_href == -1 || idx_mtype == -1 )
return false;
manifest[ atts.value( idx_id ) ] = atts.value( idx_href );
if ( atts.value( idx_mtype ) == "application/x-dtbncx+xml" )
tocname = atts.value( idx_href );
//qDebug() << "MANIFEST: " << atts.value( idx_id ) << "->" << atts.value( idx_href );
}
else if ( m_state == STATE_IN_SPINE && localName == "itemref" )
{
int idx = atts.index( "idref" );
if ( idx == -1 )
return false;
spine.push_back( atts.value( idx ) );
//qDebug() << "SPINE: " << atts.value( idx );
}
return true;
}
bool HelperXmlHandler_EpubContent::characters(const QString &ch)
{
if ( m_state == STATE_IN_METADATA && !m_tagname.isEmpty() && !ch.trimmed().isEmpty() )
{
// Some metadata may be duplicated; we concantenate them with |
if ( metadata.contains( m_tagname ) )
{
metadata[ m_tagname ].append( "|" );
metadata[ m_tagname ].append( ch.trimmed() );
}
else
metadata[ m_tagname ] = ch.trimmed();
//qDebug() << "METATAG: " << m_tagname << " " << metadata[ m_tagname ];
}
return true;
}
bool HelperXmlHandler_EpubContent::endElement(const QString &, const QString &, const QString &qName)
{
if ( qName == "manifest" || qName == "metadata" || qName == "spine" )
m_state = STATE_NONE;
return true;
}
kchmviewer-7.5/lib/libebook/PaxHeaders.8614/helper_search_index.h 0000644 0000000 0000000 00000000124 12321077735 021720 x ustar 00 27 mtime=1396998109.567818
27 atime=1447562193.090735
30 ctime=1447562193.091735125
kchmviewer-7.5/lib/libebook/helper_search_index.h 0000644 0001750 0000144 00000007045 12321077735 022256 0 ustar 00tim users 0000000 0000000 /*
* Kchmviewer - a CHM and EPUB file viewer with broad language support
* Copyright (C) 2004-2014 George Yunaev, gyunaev@ulduzsoft.com
*
* 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, either version 3 of the License, or
* (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#ifndef EBOOK_SEARCH_INDEX_H
#define EBOOK_SEARCH_INDEX_H
#include
#include
#include
#include
#include
#include "helper_entitydecoder.h"
class EBook;
// This code is based on some pretty old version of Qt Assistant
namespace QtAs
{
struct Document
{
Document( int d, int f ) : docNumber( d ), frequency( f ) {}
Document() : docNumber( -1 ), frequency( 0 ) {}
bool operator==( const Document &doc ) const
{
return docNumber == doc.docNumber;
}
bool operator<( const Document &doc ) const
{
return frequency > doc.frequency;
}
bool operator<=( const Document &doc ) const
{
return frequency >= doc.frequency;
}
bool operator>( const Document &doc ) const
{
return frequency < doc.frequency;
}
qint16 docNumber;
qint16 frequency;
};
QDataStream &operator>>( QDataStream &s, Document &l );
QDataStream &operator<<( QDataStream &s, const Document &l );
class Index : public QObject
{
Q_OBJECT
public:
Index();
void writeDict( QDataStream& stream );
bool readDict( QDataStream& stream );
bool makeIndex(const QList &docs, EBook * chmFile );
QList query( const QStringList&, const QStringList&, const QStringList&, EBook * chmFile );
QString getCharsSplit() const { return m_charssplit; }
QString getCharsPartOfWord() const { return m_charsword; }
signals:
void indexingProgress( int, const QString& );
public slots:
void setLastWinClosed();
private:
struct Entry
{
Entry( int d ) { documents.append( Document( d, 1 ) ); }
Entry( QVector l ) : documents( l ) {}
QVector documents;
};
struct PosEntry
{
PosEntry( int p ) { positions.append( p ); }
QList positions;
};
bool parseDocumentToStringlist( EBook * chmFile, const QUrl& filename, QStringList& tokenlist );
void insertInDict( const QString&, int );
QStringList getWildcardTerms( const QString& );
QStringList split( const QString& );
QList setupDummyTerm( const QStringList& );
bool searchForPhrases(const QStringList &phrases, const QStringList &words, const QUrl &filename, EBook * chmFile );
QList< QUrl > docList;
QHash dict;
QHashminiDict;
bool lastWindowClosed;
HelperEntityDecoder entityDecoder;
// Those characters are splitters (i.e. split the word), but added themselves into dictionary too.
// This makes the dictionary MUCH larger, but ensure that for the piece of "window->print" both
// search for "print" and "->print" will find it.
QString m_charssplit;
// Those characters are parts of word - for example, '_' is here, and search for _debug will find only _debug.
QString m_charsword;
};
};
#endif // EBOOK_SEARCH_INDEX_H
kchmviewer-7.5/lib/libebook/PaxHeaders.8614/ebook.h 0000644 0000000 0000000 00000000124 12622003403 017005 x ustar 00 27 mtime=1447560963.701728
27 atime=1447562193.079735
30 ctime=1447562193.079735287
kchmviewer-7.5/lib/libebook/ebook.h 0000644 0001750 0000144 00000017414 12622003403 017344 0 ustar 00tim users 0000000 0000000 /*
* Kchmviewer - a CHM and EPUB file viewer with broad language support
* Copyright (C) 2004-2014 George Yunaev, gyunaev@ulduzsoft.com
*
* 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, either version 3 of the License, or
* (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#ifndef INCLUDE_EBOOK_H
#define INCLUDE_EBOOK_H
#include
#include
#include
//! Stores a single table of content entry
class EBookTocEntry
{
public:
//! Content TOC icon indexes for CHM books (epub books contain no icons)
enum Icon
{
IMAGE_NONE = -1,
IMAGE_AUTO = -2,
MAX_BUILTIN_ICONS = 42
};
//! Entry name
QString name;
//! Entry URL.
QUrl url;
//! Associated image number. Used for TOC only; indexes does not have the image.
//! If IMAGE_NONE, no icon is associated. Otherwise use getBookIconPixmap() to get associated pixmap icon.
Icon iconid;
//! Indentation level for this entry.
int indent;
};
//! Stores a single index entry
class EBookIndexEntry
{
public:
//! Entry name
QString name;
//! Entry URLs. The index entry could have several URLs
QList urls;
//! Whether this is a 'see also' index type, and its value
QString seealso;
//! Indentation level for this entry.
int indent;
};
//! Universal ebook files processor supporting both CHM and EPUB. Abstract.
class EBook
{
public:
enum Feature
{
FEATURE_TOC, // has table of contents
FEATURE_INDEX, // has index
FEATURE_ENCODING // Could be encoded with different encodings
};
//! Default constructor and destructor.
EBook();
virtual ~EBook();
/*!
* \brief Attempts to load chm or epub file.
* \param archiveName filename.
* \return EBook object on success, NULL on failure.
*
* Loads a CHM or epub file. For CHM files it could internally load more than one file,
* if files linked to this one are present locally (like MSDN).
* \ingroup init
*/
static EBook * loadFile( const QString& archiveName );
/*!
* \brief Closes all the files, and frees the appropriate data.
* \ingroup init
*/
virtual void close() = 0;
/*!
* \brief Gets the title name of the opened ebook.
* \return The name of the opened document, or an empty string if no ebook has been loaded.
* \ingroup information
*/
virtual QString title() const = 0;
/*!
* \brief Gets the default URL of the e-book which should be opened when the book it first open
*
* \return The home page name, with a '/' added in front and relative to
* the root of the archive filesystem. If no book has been opened, returns "/".
* \ingroup information
*/
virtual QUrl homeUrl() const = 0;
/*!
* \brief Checks whether the specific feature is present in this file.
* \return true if it is available; false otherwise.
* \ingroup information
*/
virtual bool hasFeature( Feature code ) const = 0;
/*!
* \brief Parses and fills up the Table of Contents (TOC)
* \param topics A pointer to the container which will store the parsed results.
* Will be cleaned before parsing.
* \return true if the tree is present and parsed successfully, false otherwise.
* The parser is built to be error-prone, however it still can abort with qFatal()
* by really buggy files; please report a bug if the file is opened ok under Windows.
* \ingroup fileparsing
*/
virtual bool getTableOfContents( QList< EBookTocEntry >& toc ) const = 0;
/*!
* \brief Parses the index table
* \param indexes A pointer to the container which will store the parsed results.
* Will be cleaned before parsing.
* \return true if the tree is present and parsed successfully, false otherwise.
* The parser is built to be error-prone, however it still can abort with qFatal()
* by really buggy chm file; so far it never happened on indexes.
* \ingroup fileparsing
*/
virtual bool getIndex( QList< EBookIndexEntry >& index ) const = 0;
/*!
* \brief Retrieves the content associated with the url from the current ebook as QString.
* \param str A string where the retreived content should be stored.
* \param url An URL in chm file to retreive content from. Must be absolute.
* \return true if the content is successfully received; false otherwise. Note content may be an empty string.
*
* This function retreives the file content (mostly for HTML pages) from the ebook. Because the content
* in chm file might not be stored in Unicode, it will be recoded according to current encoding.
* Do not use for binary data.
*
* \sa setCurrentEncoding() currentEncoding() getFileContentAsBinary()
* \ingroup dataretrieve
*/
virtual bool getFileContentAsString( QString& str, const QUrl& url ) const = 0;
/*!
* \brief Retrieves the content from url in current chm file to QByteArray.
* \param data A data array where the retreived content should be stored.
* \param url An URL in chm file to retreive content from. Must be absolute.
* \return true if the content is successfully received; false otherwise.
*
* This function retreives the file content from the chm archive opened by load()
* function. The content is not encoded.
*
* \sa getFileContentAsString()
* \ingroup dataretrieve
*/
virtual bool getFileContentAsBinary( QByteArray& data, const QUrl& url ) const = 0;
/*!
* \brief Obtains the list of all the files (URLs) in current ebook archive. This is used in search
* and to dump the e-book content.
* \param files An array to store list of URLs present in chm archive.
* \return true if the enumeration succeed; false otherwise (I could hardly imagine a reason).
*
* \ingroup dataretrieve
*/
virtual bool enumerateFiles( QList& files ) = 0;
/*!
* \brief Gets the Title of the page referenced by url.
* \param url An URL in ebook file to get title from. Must be absolute.
* \return The title, or QString::null if the URL cannot be found or not a HTML page.
*
* \ingroup dataretrieve
*/
virtual QString getTopicByUrl ( const QUrl& url ) = 0;
/*!
* \brief Gets the current ebook encoding (set or autodetected) as qtcodec name. Must be implemented,
* even if the book doesn't support change of encoding (then it should return a default encoding)
* \return The current encoding.
*
* \ingroup encoding
*/
virtual QString currentEncoding() const = 0;
/*!
* \brief Sets the ebook encoding to use for TOC and content
* \param encoding An encoding to use.
*
* \ingroup encoding
*/
virtual bool setCurrentEncoding ( const char * encoding ) = 0;
/*!
* \brief Checks if this kind of URL is supported by the ebook format (i.e. could be passed to ebook functions)
* \param url The url to check
*/
virtual bool isSupportedUrl( const QUrl& url ) = 0;
// Converts the string to the ebook-specific URL format
virtual QUrl pathToUrl( const QString & link ) const = 0;
// Extracts the path component from the URL
virtual QString urlToPath( const QUrl& link ) const = 0;
protected:
// Loads the file; returns true if loaded, false otherwise
virtual bool load( const QString& archiveName ) = 0;
};
#endif // INCLUDE_LIBCHMFILE_H
kchmviewer-7.5/lib/libebook/PaxHeaders.8614/helper_entitydecoder.h 0000644 0000000 0000000 00000000124 12321077735 022126 x ustar 00 27 mtime=1396998109.567818
27 atime=1447562193.090735
30 ctime=1447562193.090735139
kchmviewer-7.5/lib/libebook/helper_entitydecoder.h 0000644 0001750 0000144 00000002716 12321077735 022464 0 ustar 00tim users 0000000 0000000 /*
* Kchmviewer - a CHM and EPUB file viewer with broad language support
* Copyright (C) 2004-2014 George Yunaev, gyunaev@ulduzsoft.com
*
* 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, either version 3 of the License, or
* (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#ifndef HELPER_ENTITYDECODER_H
#define HELPER_ENTITYDECODER_H
#include
#include
//
// This helper class decodes the Unicode HTML entities into the Unicode characters
//
class HelperEntityDecoder
{
public:
// Initialization with the specific decoder
HelperEntityDecoder( QTextCodec * encoder = 0 );
// Used when the encoding changes
void changeEncoding( QTextCodec * encoder = 0 );
// The decoder function
QString decode( const QString& entity ) const;
private:
// Map to decode HTML entitles like ´ based on current encoding, initialized upon the first use
QMap m_entityDecodeMap;
};
#endif // HELPER_ENTITYDECODER_H
kchmviewer-7.5/lib/libebook/PaxHeaders.8614/helperxmlhandler_epubcontainer.cpp 0000644 0000000 0000000 00000000124 12321077735 024534 x ustar 00 27 mtime=1396998109.567818
27 atime=1447562193.091735
30 ctime=1447562193.091735125
kchmviewer-7.5/lib/libebook/helperxmlhandler_epubcontainer.cpp 0000644 0001750 0000144 00000002174 12321077735 025070 0 ustar 00tim users 0000000 0000000 /*
* Kchmviewer - a CHM and EPUB file viewer with broad language support
* Copyright (C) 2004-2014 George Yunaev, gyunaev@ulduzsoft.com
*
* 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, either version 3 of the License, or
* (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#include "helperxmlhandler_epubcontainer.h"
bool HelperXmlHandler_EpubContainer::startElement(const QString &, const QString &, const QString &qName, const QXmlAttributes &atts)
{
if ( qName == "rootfile" )
{
int idx = atts.index( "full-path" );
if ( idx == -1 )
return false;
contentPath = atts.value( idx );
}
return true;
}
kchmviewer-7.5/lib/libebook/PaxHeaders.8614/helperxmlhandler_epubcontent.h 0000644 0000000 0000000 00000000124 12425306251 023662 x ustar 00 27 mtime=1414892713.024955
27 atime=1447562193.091735
30 ctime=1447562193.091735125
kchmviewer-7.5/lib/libebook/helperxmlhandler_epubcontent.h 0000644 0001750 0000144 00000003373 12425306251 024220 0 ustar 00tim users 0000000 0000000 /*
* Kchmviewer - a CHM and EPUB file viewer with broad language support
* Copyright (C) 2004-2014 George Yunaev, gyunaev@ulduzsoft.com
*
* 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, either version 3 of the License, or
* (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#ifndef HELPERXMLHANDLER_EPUBCONTENT_H
#define HELPERXMLHANDLER_EPUBCONTENT_H
#include
#include
#include
class HelperXmlHandler_EpubContent : public QXmlDefaultHandler
{
public:
HelperXmlHandler_EpubContent();
// Keep the tag-associated metadata
QMap< QString, QString > metadata;
// Manifest storage, id -> href
QMap< QString, QString > manifest;
// Spline storage
QList< QString > spine;
// TOC (NCX) filename
QString tocname;
private:
enum State
{
STATE_NONE,
STATE_IN_METADATA,
STATE_IN_MANIFEST,
STATE_IN_SPINE
};
bool startElement ( const QString & namespaceURI, const QString & localName, const QString & qName, const QXmlAttributes & atts );
bool characters(const QString &ch);
bool endElement(const QString &namespaceURI, const QString &localName, const QString &qName);
// Tracking
State m_state;
QString m_tagname;
};
#endif // HELPERXMLHANDLER_EPUBCONTENT_H
kchmviewer-7.5/lib/libebook/PaxHeaders.8614/helperxmlhandler_epubcontainer.h 0000644 0000000 0000000 00000000124 12321077735 024201 x ustar 00 27 mtime=1396998109.567818
27 atime=1447562193.091735
30 ctime=1447562193.091735125
kchmviewer-7.5/lib/libebook/helperxmlhandler_epubcontainer.h 0000644 0001750 0000144 00000002342 12321077735 024532 0 ustar 00tim users 0000000 0000000 /*
* Kchmviewer - a CHM and EPUB file viewer with broad language support
* Copyright (C) 2004-2014 George Yunaev, gyunaev@ulduzsoft.com
*
* 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, either version 3 of the License, or
* (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#ifndef HELPERXMLHANDLER_EPUBCONTAINER_H
#define HELPERXMLHANDLER_EPUBCONTAINER_H
#include
class HelperXmlHandler_EpubContainer : public QXmlDefaultHandler
{
public:
// Overridden members
bool startElement ( const QString & namespaceURI, const QString & localName, const QString & qName, const QXmlAttributes & atts );
// The content path
QString contentPath;
};
#endif // HELPERXMLHANDLER_EPUBCONTAINER_H
kchmviewer-7.5/lib/libebook/PaxHeaders.8614/helperxmlhandler_epubtoc.h 0000644 0000000 0000000 00000000123 12321077735 023003 x ustar 00 27 mtime=1396998109.567818
27 atime=1447562193.092735
29 ctime=1447562193.09273511
kchmviewer-7.5/lib/libebook/helperxmlhandler_epubtoc.h 0000644 0001750 0000144 00000003074 12321077735 023340 0 ustar 00tim users 0000000 0000000 /*
* Kchmviewer - a CHM and EPUB file viewer with broad language support
* Copyright (C) 2004-2014 George Yunaev, gyunaev@ulduzsoft.com
*
* 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, either version 3 of the License, or
* (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#ifndef HELPERXMLHANDLER_EPUBTOC_H
#define HELPERXMLHANDLER_EPUBTOC_H
#include
#include "ebook_epub.h"
class HelperXmlHandler_EpubTOC : public QXmlDefaultHandler
{
public:
HelperXmlHandler_EpubTOC( EBook_EPUB * epub );
QList< EBookTocEntry > entries;
private:
// Overridden members
bool startElement ( const QString & namespaceURI, const QString & localName, const QString & qName, const QXmlAttributes & atts );
bool characters(const QString &ch);
bool endElement(const QString &namespaceURI, const QString &localName, const QString &qName);
void checkNewTocEntry();
bool m_inNavMap;
bool m_inText;
unsigned int m_indent;
QString m_lastId;
QString m_lastTitle;
EBook_EPUB * m_epub;
};
#endif // HELPERXMLHANDLER_EPUBTOC_H
kchmviewer-7.5/lib/libebook/PaxHeaders.8614/helper_entitydecoder.cpp 0000644 0000000 0000000 00000000123 12446223156 022456 x ustar 00 26 mtime=1419322990.47456
27 atime=1447562193.090735
30 ctime=1447562193.090735139
kchmviewer-7.5/lib/libebook/helper_entitydecoder.cpp 0000644 0001750 0000144 00000031673 12446223156 023021 0 ustar 00tim users 0000000 0000000 /*
* Kchmviewer - a CHM and EPUB file viewer with broad language support
* Copyright (C) 2004-2014 George Yunaev, gyunaev@ulduzsoft.com
*
* 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, either version 3 of the License, or
* (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#include
#include "helper_entitydecoder.h"
HelperEntityDecoder::HelperEntityDecoder(QTextCodec *encoder)
{
changeEncoding( encoder );
}
static inline QString encodeWithCodec( QTextCodec *encoder, const QByteArray& str )
{
return (encoder ? encoder->toUnicode( str.constData () ) : str);
}
void HelperEntityDecoder::changeEncoding(QTextCodec *encoder)
{
// Set up m_entityDecodeMap characters according to current textCodec
m_entityDecodeMap.clear();
m_entityDecodeMap["AElig"] = encodeWithCodec( encoder, "\306"); // capital AE diphthong (ligature)
m_entityDecodeMap["Aacute"] = encodeWithCodec( encoder, "\301"); // capital A, acute accent
m_entityDecodeMap["Acirc"] = encodeWithCodec( encoder, "\302"); // capital A, circumflex accent
m_entityDecodeMap["Agrave"] = encodeWithCodec( encoder, "\300"); // capital A, grave accent
m_entityDecodeMap["Aring"] = encodeWithCodec( encoder, "\305"); // capital A, ring
m_entityDecodeMap["Atilde"] = encodeWithCodec( encoder, "\303"); // capital A, tilde
m_entityDecodeMap["Auml"] = encodeWithCodec( encoder, "\304"); // capital A, dieresis or umlaut mark
m_entityDecodeMap["Ccedil"] = encodeWithCodec( encoder, "\307"); // capital C, cedilla
m_entityDecodeMap["Dstrok"] = encodeWithCodec( encoder, "\320"); // whatever
m_entityDecodeMap["ETH"] = encodeWithCodec( encoder, "\320"); // capital Eth, Icelandic
m_entityDecodeMap["Eacute"] = encodeWithCodec( encoder, "\311"); // capital E, acute accent
m_entityDecodeMap["Ecirc"] = encodeWithCodec( encoder, "\312"); // capital E, circumflex accent
m_entityDecodeMap["Egrave"] = encodeWithCodec( encoder, "\310"); // capital E, grave accent
m_entityDecodeMap["Euml"] = encodeWithCodec( encoder, "\313"); // capital E, dieresis or umlaut mark
m_entityDecodeMap["Iacute"] = encodeWithCodec( encoder, "\315"); // capital I, acute accent
m_entityDecodeMap["Icirc"] = encodeWithCodec( encoder, "\316"); // capital I, circumflex accent
m_entityDecodeMap["Igrave"] = encodeWithCodec( encoder, "\314"); // capital I, grave accent
m_entityDecodeMap["Iuml"] = encodeWithCodec( encoder, "\317"); // capital I, dieresis or umlaut mark
m_entityDecodeMap["Ntilde"] = encodeWithCodec( encoder, "\321"); // capital N, tilde
m_entityDecodeMap["Oacute"] = encodeWithCodec( encoder, "\323"); // capital O, acute accent
m_entityDecodeMap["Ocirc"] = encodeWithCodec( encoder, "\324"); // capital O, circumflex accent
m_entityDecodeMap["Ograve"] = encodeWithCodec( encoder, "\322"); // capital O, grave accent
m_entityDecodeMap["Oslash"] = encodeWithCodec( encoder, "\330"); // capital O, slash
m_entityDecodeMap["Otilde"] = encodeWithCodec( encoder, "\325"); // capital O, tilde
m_entityDecodeMap["Ouml"] = encodeWithCodec( encoder, "\326"); // capital O, dieresis or umlaut mark
m_entityDecodeMap["THORN"] = encodeWithCodec( encoder, "\336"); // capital THORN, Icelandic
m_entityDecodeMap["Uacute"] = encodeWithCodec( encoder, "\332"); // capital U, acute accent
m_entityDecodeMap["Ucirc"] = encodeWithCodec( encoder, "\333"); // capital U, circumflex accent
m_entityDecodeMap["Ugrave"] = encodeWithCodec( encoder, "\331"); // capital U, grave accent
m_entityDecodeMap["Uuml"] = encodeWithCodec( encoder, "\334"); // capital U, dieresis or umlaut mark
m_entityDecodeMap["Yacute"] = encodeWithCodec( encoder, "\335"); // capital Y, acute accent
m_entityDecodeMap["OElig"] = encodeWithCodec( encoder, "\338"); // capital Y, acute accent
m_entityDecodeMap["oelig"] = encodeWithCodec( encoder, "\339"); // capital Y, acute accent
m_entityDecodeMap["aacute"] = encodeWithCodec( encoder, "\341"); // small a, acute accent
m_entityDecodeMap["acirc"] = encodeWithCodec( encoder, "\342"); // small a, circumflex accent
m_entityDecodeMap["aelig"] = encodeWithCodec( encoder, "\346"); // small ae diphthong (ligature)
m_entityDecodeMap["agrave"] = encodeWithCodec( encoder, "\340"); // small a, grave accent
m_entityDecodeMap["aring"] = encodeWithCodec( encoder, "\345"); // small a, ring
m_entityDecodeMap["atilde"] = encodeWithCodec( encoder, "\343"); // small a, tilde
m_entityDecodeMap["auml"] = encodeWithCodec( encoder, "\344"); // small a, dieresis or umlaut mark
m_entityDecodeMap["ccedil"] = encodeWithCodec( encoder, "\347"); // small c, cedilla
m_entityDecodeMap["eacute"] = encodeWithCodec( encoder, "\351"); // small e, acute accent
m_entityDecodeMap["ecirc"] = encodeWithCodec( encoder, "\352"); // small e, circumflex accent
m_entityDecodeMap["Scaron"] = encodeWithCodec( encoder, "\352"); // small e, circumflex accent
m_entityDecodeMap["egrave"] = encodeWithCodec( encoder, "\350"); // small e, grave accent
m_entityDecodeMap["eth"] = encodeWithCodec( encoder, "\360"); // small eth, Icelandic
m_entityDecodeMap["euml"] = encodeWithCodec( encoder, "\353"); // small e, dieresis or umlaut mark
m_entityDecodeMap["iacute"] = encodeWithCodec( encoder, "\355"); // small i, acute accent
m_entityDecodeMap["icirc"] = encodeWithCodec( encoder, "\356"); // small i, circumflex accent
m_entityDecodeMap["igrave"] = encodeWithCodec( encoder, "\354"); // small i, grave accent
m_entityDecodeMap["iuml"] = encodeWithCodec( encoder, "\357"); // small i, dieresis or umlaut mark
m_entityDecodeMap["ntilde"] = encodeWithCodec( encoder, "\361"); // small n, tilde
m_entityDecodeMap["oacute"] = encodeWithCodec( encoder, "\363"); // small o, acute accent
m_entityDecodeMap["ocirc"] = encodeWithCodec( encoder, "\364"); // small o, circumflex accent
m_entityDecodeMap["ograve"] = encodeWithCodec( encoder, "\362"); // small o, grave accent
m_entityDecodeMap["oslash"] = encodeWithCodec( encoder, "\370"); // small o, slash
m_entityDecodeMap["otilde"] = encodeWithCodec( encoder, "\365"); // small o, tilde
m_entityDecodeMap["ouml"] = encodeWithCodec( encoder, "\366"); // small o, dieresis or umlaut mark
m_entityDecodeMap["szlig"] = encodeWithCodec( encoder, "\337"); // small sharp s, German (sz ligature)
m_entityDecodeMap["thorn"] = encodeWithCodec( encoder, "\376"); // small thorn, Icelandic
m_entityDecodeMap["uacute"] = encodeWithCodec( encoder, "\372"); // small u, acute accent
m_entityDecodeMap["ucirc"] = encodeWithCodec( encoder, "\373"); // small u, circumflex accent
m_entityDecodeMap["ugrave"] = encodeWithCodec( encoder, "\371"); // small u, grave accent
m_entityDecodeMap["uuml"] = encodeWithCodec( encoder, "\374"); // small u, dieresis or umlaut mark
m_entityDecodeMap["yacute"] = encodeWithCodec( encoder, "\375"); // small y, acute accent
m_entityDecodeMap["yuml"] = encodeWithCodec( encoder, "\377"); // small y, dieresis or umlaut mark
m_entityDecodeMap["iexcl"] = encodeWithCodec( encoder, "\241");
m_entityDecodeMap["cent"] = encodeWithCodec( encoder, "\242");
m_entityDecodeMap["pound"] = encodeWithCodec( encoder, "\243");
m_entityDecodeMap["curren"] = encodeWithCodec( encoder, "\244");
m_entityDecodeMap["yen"] = encodeWithCodec( encoder, "\245");
m_entityDecodeMap["brvbar"] = encodeWithCodec( encoder, "\246");
m_entityDecodeMap["sect"] = encodeWithCodec( encoder, "\247");
m_entityDecodeMap["uml"] = encodeWithCodec( encoder, "\250");
m_entityDecodeMap["ordf"] = encodeWithCodec( encoder, "\252");
m_entityDecodeMap["laquo"] = encodeWithCodec( encoder, "\253");
m_entityDecodeMap["not"] = encodeWithCodec( encoder, "\254");
m_entityDecodeMap["shy"] = encodeWithCodec( encoder, "\255");
m_entityDecodeMap["macr"] = encodeWithCodec( encoder, "\257");
m_entityDecodeMap["deg"] = encodeWithCodec( encoder, "\260");
m_entityDecodeMap["plusmn"] = encodeWithCodec( encoder, "\261");
m_entityDecodeMap["sup1"] = encodeWithCodec( encoder, "\271");
m_entityDecodeMap["sup2"] = encodeWithCodec( encoder, "\262");
m_entityDecodeMap["sup3"] = encodeWithCodec( encoder, "\263");
m_entityDecodeMap["acute"] = encodeWithCodec( encoder, "\264");
m_entityDecodeMap["micro"] = encodeWithCodec( encoder, "\265");
m_entityDecodeMap["para"] = encodeWithCodec( encoder, "\266");
m_entityDecodeMap["middot"] = encodeWithCodec( encoder, "\267");
m_entityDecodeMap["cedil"] = encodeWithCodec( encoder, "\270");
m_entityDecodeMap["ordm"] = encodeWithCodec( encoder, "\272");
m_entityDecodeMap["raquo"] = encodeWithCodec( encoder, "\273");
m_entityDecodeMap["frac14"] = encodeWithCodec( encoder, "\274");
m_entityDecodeMap["frac12"] = encodeWithCodec( encoder, "\275");
m_entityDecodeMap["frac34"] = encodeWithCodec( encoder, "\276");
m_entityDecodeMap["iquest"] = encodeWithCodec( encoder, "\277");
m_entityDecodeMap["times"] = encodeWithCodec( encoder, "\327");
m_entityDecodeMap["divide"] = encodeWithCodec( encoder, "\367");
m_entityDecodeMap["copy"] = encodeWithCodec( encoder, "\251"); // copyright sign
m_entityDecodeMap["reg"] = encodeWithCodec( encoder, "\256"); // registered sign
m_entityDecodeMap["nbsp"] = encodeWithCodec( encoder, "\240"); // non breaking space
m_entityDecodeMap["fnof"] = QChar((unsigned short) 402);
m_entityDecodeMap["Delta"] = QChar((unsigned short) 916);
m_entityDecodeMap["Pi"] = QChar((unsigned short) 928);
m_entityDecodeMap["Sigma"] = QChar((unsigned short) 931);
m_entityDecodeMap["beta"] = QChar((unsigned short) 946);
m_entityDecodeMap["gamma"] = QChar((unsigned short) 947);
m_entityDecodeMap["delta"] = QChar((unsigned short) 948);
m_entityDecodeMap["eta"] = QChar((unsigned short) 951);
m_entityDecodeMap["theta"] = QChar((unsigned short) 952);
m_entityDecodeMap["lambda"] = QChar((unsigned short) 955);
m_entityDecodeMap["mu"] = QChar((unsigned short) 956);
m_entityDecodeMap["nu"] = QChar((unsigned short) 957);
m_entityDecodeMap["pi"] = QChar((unsigned short) 960);
m_entityDecodeMap["rho"] = QChar((unsigned short) 961);
m_entityDecodeMap["lsquo"] = QChar((unsigned short) 8216);
m_entityDecodeMap["rsquo"] = QChar((unsigned short) 8217);
m_entityDecodeMap["rdquo"] = QChar((unsigned short) 8221);
m_entityDecodeMap["bdquo"] = QChar((unsigned short) 8222);
m_entityDecodeMap["trade"] = QChar((unsigned short) 8482);
m_entityDecodeMap["ldquo"] = QChar((unsigned short) 8220);
m_entityDecodeMap["ndash"] = QChar((unsigned short) 8211);
m_entityDecodeMap["mdash"] = QChar((unsigned short) 8212);
m_entityDecodeMap["bull"] = QChar((unsigned short) 8226);
m_entityDecodeMap["hellip"] = QChar((unsigned short) 8230);
m_entityDecodeMap["emsp"] = QChar((unsigned short) 8195);
m_entityDecodeMap["rarr"] = QChar((unsigned short) 8594);
m_entityDecodeMap["rArr"] = QChar((unsigned short) 8658);
m_entityDecodeMap["crarr"] = QChar((unsigned short) 8629);
m_entityDecodeMap["le"] = QChar((unsigned short) 8804);
m_entityDecodeMap["ge"] = QChar((unsigned short) 8805);
m_entityDecodeMap["lte"] = QChar((unsigned short) 8804); // wrong, but used somewhere
m_entityDecodeMap["gte"] = QChar((unsigned short) 8805); // wrong, but used somewhere
m_entityDecodeMap["dagger"] = QChar((unsigned short) 8224);
m_entityDecodeMap["Dagger"] = QChar((unsigned short) 8225);
m_entityDecodeMap["euro"] = QChar((unsigned short) 8364);
m_entityDecodeMap["asymp"] = QChar((unsigned short) 8776);
m_entityDecodeMap["isin"] = QChar((unsigned short) 8712);
m_entityDecodeMap["notin"] = QChar((unsigned short) 8713);
m_entityDecodeMap["prod"] = QChar((unsigned short) 8719);
m_entityDecodeMap["ne"] = QChar((unsigned short) 8800);
m_entityDecodeMap["amp"] = "&"; // ampersand
m_entityDecodeMap["gt"] = ">"; // greater than
m_entityDecodeMap["lt"] = "<"; // less than
m_entityDecodeMap["quot"] = "\""; // double quote
m_entityDecodeMap["apos"] = "'"; // single quote
m_entityDecodeMap["frasl"] = "/";
m_entityDecodeMap["minus"] = "-";
m_entityDecodeMap["oplus"] = "+";
m_entityDecodeMap["Prime"] = "\"";
}
QString HelperEntityDecoder::decode( const QString &entity ) const
{
// If entity is an ASCII code like 〽 - just decode it
if ( entity.isEmpty() )
{
return "";
}
else if ( entity[0] == '#' )
{
bool valid;
unsigned int ascode = entity.mid(1).toUInt( &valid );
if ( !valid )
{
qWarning ( "HelperEntityDecoder::decode: could not decode HTML entity '%s'", qPrintable( entity ) );
return QString::null;
}
return (QString) (QChar( ascode ));
}
else
{
QMap::const_iterator it = m_entityDecodeMap.find( entity );
if ( it == m_entityDecodeMap.end() )
{
qWarning ("HelperEntityDecoder::decode: could not decode HTML entity '%s'", qPrintable( entity ));
return "";
}
return *it;
}
}
kchmviewer-7.5/lib/libebook/PaxHeaders.8614/ebook_chm.h 0000644 0000000 0000000 00000000124 12616333137 017651 x ustar 00 27 mtime=1446622815.937622
27 atime=1447562193.080735
30 ctime=1447562193.080735274
kchmviewer-7.5/lib/libebook/ebook_chm.h 0000644 0001750 0000144 00000026352 12616333137 020211 0 ustar 00tim users 0000000 0000000 /*
* Kchmviewer - a CHM and EPUB file viewer with broad language support
* Copyright (C) 2004-2014 George Yunaev, gyunaev@ulduzsoft.com
*
* 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, either version 3 of the License, or
* (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#ifndef EBOOK_CHM_H
#define EBOOK_CHM_H
#include
#include
// Enable Unicode use in libchm
#if defined (WIN32)
#define PPC_BSTR
#endif
#include
#include "ebook.h"
#include "helper_entitydecoder.h"
class EBook_CHM : public EBook
{
public:
EBook_CHM();
~EBook_CHM();
/*!
* \brief Attempts to load chm file.
* \param archiveName filename.
* \return EBook object on success, NULL on failure.
*
* Loads a CHM file. For CHM files it could internally load more than one file,
* if files linked to this one are present locally (like MSDN).
* \ingroup init
*/
bool load( const QString& archiveName );
/*!
* \brief Closes all the files, and frees the appropriate data.
* \ingroup init
*/
virtual void close();
/*!
* \brief Gets the title name of the opened ebook.
* \return The name of the opened document, or an empty string if no ebook has been loaded.
* \ingroup information
*/
virtual QString title() const;
/*!
* \brief Gets the default URL of the e-book which should be opened when the book it first open
*
* \return The home page name, with a '/' added in front and relative to
* the root of the archive filesystem. If no book has been opened, returns "/".
* \ingroup information
*/
virtual QUrl homeUrl() const;
/*!
* \brief Checks whether the specific feature is present in this file.
* \return true if it is available; false otherwise.
* \ingroup information
*/
virtual bool hasFeature( Feature code ) const;
/*!
* \brief Parses and fills up the Table of Contents (TOC)
* \param topics A pointer to the container which will store the parsed results.
* Will be cleaned before parsing.
* \return true if the tree is present and parsed successfully, false otherwise.
* The parser is built to be error-prone, however it still can abort with qFatal()
* by really buggy files; please report a bug if the file is opened ok under Windows.
* \ingroup fileparsing
*/
virtual bool getTableOfContents( QList< EBookTocEntry >& toc ) const;
/*!
* \brief Parses the index table
* \param indexes A pointer to the container which will store the parsed results.
* Will be cleaned before parsing.
* \return true if the tree is present and parsed successfully, false otherwise.
* The parser is built to be error-prone, however it still can abort with qFatal()
* by really buggy chm file; so far it never happened on indexes.
* \ingroup fileparsing
*/
virtual bool getIndex( QList< EBookIndexEntry >& index ) const;
/*!
* \brief Retrieves the content associated with the url from the current ebook as QString.
* \param str A string where the retreived content should be stored.
* \param url An URL in chm file to retreive content from. Must be absolute.
* \return true if the content is successfully received; false otherwise. Note content may be an empty string.
*
* This function retreives the file content (mostly for HTML pages) from the ebook. Because the content
* in chm file might not be stored in Unicode, it will be recoded according to current encoding.
* Do not use for binary data.
*
* \sa setCurrentEncoding() currentEncoding() getFileContentAsBinary()
* \ingroup dataretrieve
*/
virtual bool getFileContentAsString( QString& str, const QUrl& url ) const;
/*!
* \brief Retrieves the content from url in current chm file to QByteArray.
* \param data A data array where the retreived content should be stored.
* \param url An URL in chm file to retreive content from. Must be absolute.
* \return true if the content is successfully received; false otherwise.
*
* This function retreives the file content from the chm archive opened by load()
* function. The content is not encoded.
*
* \sa getFileContentAsString()
* \ingroup dataretrieve
*/
virtual bool getFileContentAsBinary( QByteArray& data, const QUrl& url ) const;
/*!
* \brief Retrieves the content size.
* \param url An URL in ebook file to retreive content from. Must be absolute.
* \return the size; -1 in case of error.
*
* \ingroup dataretrieve
*/
virtual int getContentSize( const QString& url );
/*!
* \brief Obtains the list of all the files (URLs) in current ebook archive. This is used in search
* and to dump the e-book content.
* \param files An array to store list of URLs (file names) present in chm archive.
* \return true if the enumeration succeed; false otherwise (I could hardly imagine a reason).
*
* \ingroup dataretrieve
*/
virtual bool enumerateFiles( QList& files );
/*!
* \brief Gets the Title of the page referenced by url.
* \param url An URL in ebook file to get title from. Must be absolute.
* \return The title, or QString::null if the URL cannot be found or not a HTML page.
*
* \ingroup dataretrieve
*/
virtual QString getTopicByUrl ( const QUrl& url );
/*!
* \brief Gets the current ebook encoding (set or autodetected) as qtcodec
* \return The current encoding.
*
* \ingroup encoding
*/
virtual QString currentEncoding() const;
/*!
* \brief Sets the ebook encoding to use for TOC and content
* \param encoding An encoding to use.
*
* \ingroup encoding
*/
virtual bool setCurrentEncoding ( const char * encoding );
/*!
* \brief Checks if this kind of URL is supported by the ebook format (i.e. could be passed to ebook functions)
* \param url The url to check
*/
virtual bool isSupportedUrl( const QUrl& url );
// Converts the string to the ebook-specific URL format
QUrl pathToUrl( const QString & link ) const;
// Extracts the path component from the URL
QString urlToPath( const QUrl& link ) const;
private:
// Used in local parser
class ParsedEntry
{
public:
ParsedEntry();
QString name;
QList urls;
int iconid;
int indent;
QString seealso;
};
//! Looks up fileName in the archive.
bool hasFile( const QString& fileName ) const;
//! Looks up fileName in the archive.
bool ResolveObject( const QString& fileName, chmUnitInfo *ui ) const;
//! Retrieves an uncompressed chunk of a file in the .chm.
size_t RetrieveObject( const chmUnitInfo *ui, unsigned char *buffer, LONGUINT64 fileOffset, LONGINT64 bufferSize) const;
//! Encode the string with the currently selected text codec, if possible. Or return as-is, if not.
inline QString encodeWithCurrentCodec( const QByteArray& str) const
{
return (m_textCodec ? m_textCodec->toUnicode( str.constData () ) : str);
}
//! Encode the string with the currently selected text codec, if possible. Or return as-is, if not.
inline QString encodeWithCurrentCodec (const char * str) const
{
return (m_textCodec ? m_textCodec->toUnicode( str ) : (QString) str);
}
//! Encode the string from internal files with the currently selected text codec, if possible.
//! Or return as-is, if not.
inline QString encodeInternalWithCurrentCodec (const QString& str) const
{
return (m_textCodecForSpecialFiles ? m_textCodecForSpecialFiles->toUnicode( qPrintable(str) ) : str);
}
//! Encode the string from internal files with the currently selected text codec, if possible.
//! Or return as-is, if not.
inline QString encodeInternalWithCurrentCodec (const char * str) const
{
return (m_textCodecForSpecialFiles ? m_textCodecForSpecialFiles->toUnicode (str) : (QString) str);
}
//! Helper. Translates from Win32 encodings to generic wxWidgets ones.
const char * GetFontEncFromCharSet (const QString& font) const;
//! Parse the HHC or HHS file, and fill the context (asIndex is false) or index (asIndex is true) array.
bool parseFileAndFillArray (const QString& file, QList< ParsedEntry >& data, bool asIndex ) const;
bool getBinaryContent( QByteArray &data, const QString &url ) const;
bool getTextContent( QString& str, const QString& url, bool internal_encoding = false ) const;
/*!
* Parse binary TOC
*/
bool parseBinaryTOC(QList &data ) const;
//! btree string parser
QString getBtreeString( const QByteArray& btidx, unsigned long * offset, unsigned short * spaceLeft ) const;
/*!
* Recursively parse and fill binary TOC
*/
bool RecurseLoadBTOC(const QByteArray& tocidx,
const QByteArray& topics,
const QByteArray& urltbl,
const QByteArray& urlstr,
const QByteArray& strings,
int offset,
QList &data,
int level ) const;
/*!
* Helper procedure in TOC parsing, decodes the string between the quotes (first or last) with decoding HTML
* entities like í
*/
int findStringInQuotes (const QString& tag, int offset, QString& value, bool firstquote, bool decodeentities ) const;
bool getInfoFromWindows();
bool getInfoFromSystem();
bool changeFileEncoding(const QString &qtencoding);
bool guessTextEncoding();
void fillTopicsUrlMap();
bool hasOption(const QString &name) const;
// Members
//! Pointer to the chmlib structure
chmFile * m_chmFile;
//! Opened file name
QString m_filename;
//! Home url, got from CHM file
QByteArray m_home;
//! Context tree filename. Got from CHM file
QByteArray m_topicsFile;
//! Index filename. Got from CHM file
QByteArray m_indexFile;
//! Chm Title. Got from CHM file
QByteArray m_title;
// Localization stuff
//! LCID from CHM file, used in encoding detection
short m_detectedLCID;
//! font charset from CHM file, used in encoding detection
QString m_font;
//! Chosen text codec
QTextCodec * m_textCodec;
QTextCodec * m_textCodecForSpecialFiles;
//! Current encoding
QString m_currentEncoding;
//! TRUE if /#TOPICS, /#STRINGS, /#URLTBL and /#URLSTR are resolved, and the members below are valid
bool m_lookupTablesValid;
//! pointer to /#TOPICS
chmUnitInfo m_chmTOPICS;
//! pointer to /#STRINGS
chmUnitInfo m_chmSTRINGS;
//! pointer to /#URLTBL
chmUnitInfo m_chmURLTBL;
//! pointer to /#URLSTR
chmUnitInfo m_chmURLSTR;
//! Indicates whether TOC, either binary or text, is available.
bool m_tocAvailable;
//! Indicates whether index, either binary or text, is available.
bool m_indexAvailable;
//! Map url->topic
QMap< QUrl, QString > m_url2topics;
//! KCHMViewer debug options from environment
QString m_envOptions;
//! HTML entity decoder
HelperEntityDecoder m_htmlEntityDecoder;
};
#endif // EBOOK_CHM_H
kchmviewer-7.5/lib/libebook/PaxHeaders.8614/ebook_epub.h 0000644 0000000 0000000 00000000123 12321077735 020036 x ustar 00 27 mtime=1396998109.567818
27 atime=1447562193.081735
29 ctime=1447562193.08173526
kchmviewer-7.5/lib/libebook/ebook_epub.h 0000644 0001750 0000144 00000015573 12321077735 020402 0 ustar 00tim users 0000000 0000000 /*
* Kchmviewer - a CHM and EPUB file viewer with broad language support
* Copyright (C) 2004-2014 George Yunaev, gyunaev@ulduzsoft.com
*
* 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, either version 3 of the License, or
* (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#ifndef EBOOK_EPUB_H
#define EBOOK_EPUB_H
#include
#include
#include
#include
#include "ebook.h"
#include "zip.h"
class QXmlDefaultHandler;
class EBook_EPUB : public EBook
{
public:
EBook_EPUB();
virtual ~EBook_EPUB();
/*!
* \brief Attempts to load epub file.
* \param archiveName filename.
* \return EBook object on success, NULL on failure.
*
* Loads a epub file.
* \ingroup init
*/
bool load( const QString& archiveName );
/*!
* \brief Closes all the files, and frees the appropriate data.
* \ingroup init
*/
virtual void close();
/*!
* \brief Gets the title name of the opened ebook.
* \return The name of the opened document, or an empty string if no ebook has been loaded.
* \ingroup information
*/
virtual QString title() const;
/*!
* \brief Gets the default URL of the e-book which should be opened when the book it first open
*
* \return The home page name, with a '/' added in front and relative to
* the root of the archive filesystem. If no book has been opened, returns "/".
* \ingroup information
*/
virtual QUrl homeUrl() const;
/*!
* \brief Checks whether the specific feature is present in this file.
* \return true if it is available; false otherwise.
* \ingroup information
*/
virtual bool hasFeature( Feature code ) const;
/*!
* \brief Parses and fills up the Table of Contents (TOC)
* \param topics A pointer to the container which will store the parsed results.
* Will be cleaned before parsing.
* \return true if the tree is present and parsed successfully, false otherwise.
* The parser is built to be error-prone, however it still can abort with qFatal()
* by really buggy files; please report a bug if the file is opened ok under Windows.
* \ingroup fileparsing
*/
virtual bool getTableOfContents( QList< EBookTocEntry >& toc ) const;
/*!
* \brief Parses the index table
* \param indexes A pointer to the container which will store the parsed results.
* Will be cleaned before parsing.
* \return true if the tree is present and parsed successfully, false otherwise.
* The parser is built to be error-prone, however it still can abort with qFatal()
* by really buggy chm file; so far it never happened on indexes.
* \ingroup fileparsing
*/
virtual bool getIndex( QList< EBookIndexEntry >& index ) const;
/*!
* \brief Retrieves the content associated with the url from the current ebook as QString.
* \param str A string where the retreived content should be stored.
* \param url An URL in chm file to retreive content from. Must be absolute.
* \return true if the content is successfully received; false otherwise. Note content may be an empty string.
*
* This function retreives the file content (mostly for HTML pages) from the ebook. Because the content
* in chm file might not be stored in Unicode, it will be recoded according to current encoding.
* Do not use for binary data.
*
* \sa setCurrentEncoding() currentEncoding() getFileContentAsBinary()
* \ingroup dataretrieve
*/
virtual bool getFileContentAsString( QString& str, const QUrl& url ) const;
/*!
* \brief Retrieves the content from url in current chm file to QByteArray.
* \param data A data array where the retreived content should be stored.
* \param url An URL in chm file to retreive content from. Must be absolute.
* \return true if the content is successfully received; false otherwise.
*
* This function retreives the file content from the chm archive opened by load()
* function. The content is not encoded.
*
* \sa getFileContentAsString()
* \ingroup dataretrieve
*/
virtual bool getFileContentAsBinary( QByteArray& data, const QUrl& url ) const;
/*!
* \brief Obtains the list of all the files (URLs) in current ebook archive. This is used in search
* and to dump the e-book content.
* \param files An array to store list of URLs (file names) present in chm archive.
* \return true if the enumeration succeed; false otherwise (I could hardly imagine a reason).
*
* \ingroup dataretrieve
*/
virtual bool enumerateFiles( QList& files );
/*!
* \brief Gets the Title of the page referenced by url.
* \param url An URL in ebook file to get title from. Must be absolute.
* \return The title, or QString::null if the URL cannot be found or not a HTML page.
*
* \ingroup dataretrieve
*/
virtual QString getTopicByUrl ( const QUrl& url );
/*!
* \brief Gets the current ebook encoding (set or autodetected) as qtcodec
* \return The current encoding.
*
* \ingroup encoding
*/
virtual QString currentEncoding() const;
/*!
* \brief Sets the ebook encoding to use for TOC and content
* \param encoding An encoding to use.
*
* \ingroup encoding
*/
virtual bool setCurrentEncoding ( const char * encoding );
/*!
* \brief Checks if this kind of URL is supported by the ebook format (i.e. could be passed to ebook functions)
* \param url The url to check
*/
virtual bool isSupportedUrl( const QUrl& url );
// Converts the string to the ebook-specific URL format
QUrl pathToUrl( const QString & link ) const;
// Extracts the path component from the URL
QString urlToPath( const QUrl& link ) const;
private:
// Parses the XML file using a specified parser
bool parseXML( const QString& uri, QXmlDefaultHandler * reader );
// Parses the book description file. Fills up the ebook info
bool parseBookinfo();
// Get file content from path
bool getFileAsString( QString& str, const QString& path ) const;
bool getFileAsBinary( QByteArray& data, const QString& path ) const;
// ZIP archive fd and structs
QFile m_epubFile;
struct zip * m_zipFile;
// Ebook info
QString m_title;
QString m_documentRoot;
// List of files in the ebook
QList m_ebookManifest;
// Table of contents
QList< EBookTocEntry > m_tocEntries;
// Map of URL-Title
QMap< QUrl, QString> m_urlTitleMap;
};
#endif // EBOOK_EPUB_H
kchmviewer-7.5/lib/libebook/PaxHeaders.8614/ebook_chm_encoding.cpp 0000644 0000000 0000000 00000000124 12321077735 022054 x ustar 00 27 mtime=1396998109.567818
27 atime=1447562193.080735
30 ctime=1447562193.080735274
kchmviewer-7.5/lib/libebook/ebook_chm_encoding.cpp 0000644 0001750 0000144 00000010764 12321077735 022414 0 ustar 00tim users 0000000 0000000 /*
* Kchmviewer - a CHM and EPUB file viewer with broad language support
* Copyright (C) 2004-2014 George Yunaev, gyunaev@ulduzsoft.com
*
* 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, either version 3 of the License, or
* (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#include "ebook_chm_encoding.h"
typedef struct
{
const char * qtcodec;
const short * lcids;
} EbookChmTextEncodingEntry;
// Do not try to embed those in the text_encoding_table, it does not work - at least with gcc.
static short lcid_arabic[] =
{
0x1401, 0x3C01, 0x0C01, 0x0801, 0x2C01, 0x3401, 0x3001, 0x1001,
0x1801, 0x2001, 0x4001, 0x0401, 0x2801, 0x1C01, 0x3801, 0x2401,
0x0429, 0x0420,
0,
};
static short lcid_baltic[] =
{
0x0425, 0x0426, 0x0427, 0
};
static short lcid_centralEuropean[] =
{
0x041C, 0x041A, 0x0405, 0x040E, 0x0415, 0x0418, 0x081A, 0x041B, 0x0424, 0
};
static short lcid_ChineseSimplifiedGB18030[] =
{
0x0804, 0
};
static short lcid_ChineseSimplifiedGBK[] =
{
0x0804, 0
};
static short lcid_ChineseSimplifiedGB2313[] =
{
0x1004, 0
};
static short lcid_ChineseTraditionalBig5[] =
{
0x0404, 0x1404, 0
};
static short lcid_ChineseTraditionalBigHKSCS[] =
{
0x0C04, 0
};
static short lcid_CyrillicCP1251[] =
{
0x082C, 0x0423, 0x0402, 0x042F, 0x0419, 0x0C1A, 0x0444, 0x0422, 0x0843, 0
};
static short lcid_CyrillicKOI8R[] =
{
0x7001, // artifical LCID
0
};
static short lcid_Greek[] =
{
0x0408, 0
};
static short lcid_Hebrew[] =
{
0x040D, 0
};
static short lcid_Japanese_eucJP[] =
{
0x0411, 0
};
static short lcid_Japanese_JIS7[] =
{
0x0411, 0
};
static short lcid_Japanese_ShiftJIS[] =
{
0x0411, 0
};
static short lcid_Korean_eucKR[] =
{
0x0412, 0
};
static short lcid_TamilTSCII[] =
{
0x0449, 0
};
static short lcid_ThaiTIS[] =
{
0x041E, 0
};
static short lcid_UkrainianKOI[] =
{
0x7006, 0
};
static short lcid_Turkish[] =
{
0x042C, 0x041F, 0x0443, 0
};
static short lcid_Vietnamese[] =
{
0x042A, 0
};
static short lcid_UnicodeUTF8[] =
{
0x7004, // artifical LCID
0
};
static short lcid_UnicodeUTF16[] =
{
0x7005, // artifical LCID
0
};
static short lcid_Western[] =
{
0x0436, 0x042D, 0x0403, 0x0406, 0x0813, 0x0413, 0x0C09, 0x2809,
0x1009, 0x2409, 0x1809, 0x2009, 0x1409, 0x3409, 0x1C09, 0x2C09,
0x0809, 0x0409, 0x0438, 0x040B, 0x080C, 0x0C0C, 0x040C, 0x140C,
0x100C, 0x0C07, 0x0407, 0x1407, 0x1007, 0x0807, 0x040F, 0x0421,
0x0410, 0x0810, 0x083E, 0x043E, 0x0414, 0x0814, 0x0416, 0x0816,
0x0432, 0x2C0A, 0x400A, 0x340A, 0x240A, 0x140A, 0x1C0A, 0x300A,
0x440A, 0x100A, 0x480A, 0x080A, 0x4C0A, 0x180A, 0x3C0A, 0x280A,
0x500A, 0x0C0A, 0x380A, 0x200A, 0x0441, 0x081D, 0x041D, 0x0434,
0x0435, 0x042B, 0x042C, 0x0439, 0x043A, 0x044E, 0x044F, 0x081A,
0x0443,
0
};
static const EbookChmTextEncodingEntry text_encoding_table [] =
{
{
"CP1256",
lcid_arabic
},
{
"CP1257",
lcid_baltic
},
{
"CP1250",
lcid_centralEuropean
},
{
"GB18030",
lcid_ChineseSimplifiedGB18030
},
{
"GBK",
lcid_ChineseSimplifiedGBK
},
{
"GB2313",
lcid_ChineseSimplifiedGB2313
},
{
"Big5",
lcid_ChineseTraditionalBig5
},
{
"Big5-HKSCS",
lcid_ChineseTraditionalBigHKSCS
},
{
"CP1251",
lcid_CyrillicCP1251
},
{
"KOI8-R",
lcid_CyrillicKOI8R
},
{
"CP1253",
lcid_Greek
},
{
"CP1255",
lcid_Hebrew
},
{
"Shift-JIS",
lcid_Japanese_ShiftJIS
},
{
"eucJP",
lcid_Japanese_eucJP
},
{
"JIS7",
lcid_Japanese_JIS7
},
{
"eucKR",
lcid_Korean_eucKR
},
{
"TSCII",
lcid_TamilTSCII
},
{
"TIS-620",
lcid_ThaiTIS
},
{
"KOI8-U",
lcid_UkrainianKOI
},
{
"CP1254",
lcid_Turkish
},
{
"CP1258",
lcid_Vietnamese
},
{
"UTF-8",
lcid_UnicodeUTF8
},
{
"UTF-16",
lcid_UnicodeUTF16
},
{
"CP1252",
lcid_Western
},
{ 0, 0 }
};
QString Ebook_CHM_Encoding::guessByLCID(unsigned short lcid)
{
for ( const EbookChmTextEncodingEntry * t = text_encoding_table; t->qtcodec; ++t )
{
for ( const short * lcids = t->lcids; *lcids; lcids++ )
if ( *lcids == lcid )
return t->qtcodec;
}
return "UTF-8";
}
kchmviewer-7.5/lib/libebook/PaxHeaders.8614/ebook_chm.cpp 0000644 0000000 0000000 00000000124 12616333137 020204 x ustar 00 27 mtime=1446622815.937622
27 atime=1447562193.079735
30 ctime=1447562193.080735274
kchmviewer-7.5/lib/libebook/ebook_chm.cpp 0000644 0001750 0000144 00000065446 12616333137 020553 0 ustar 00tim users 0000000 0000000 /*
* Kchmviewer - a CHM and EPUB file viewer with broad language support
* Copyright (C) 2004-2014 George Yunaev, gyunaev@ulduzsoft.com
*
* 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, either version 3 of the License, or
* (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#include
#include
#include
#include "ebook_chm.h"
#include "ebook_chm_encoding.h"
#include "helper_entitydecoder.h"
#include "bitfiddle.h"
// Big-enough buffer size for use with various routines.
#define BUF_SIZE 4096
#define COMMON_BUF_LEN 1025
#define TOPICS_ENTRY_LEN 16
#define URLTBL_ENTRY_LEN 12
//#define DEBUGPARSER(A) qDebug A
#define DEBUGPARSER(A)
static const char * URL_SCHEME_CHM = "ms-its";
EBook_CHM::EBook_CHM()
{
m_envOptions = getenv("KCHMVIEWEROPTS");
m_chmFile = NULL;
m_filename = m_font = QString::null;
m_textCodec = 0;
m_textCodecForSpecialFiles = 0;
m_detectedLCID = 0;
m_currentEncoding = "UTF-8";
m_htmlEntityDecoder = 0;
}
EBook_CHM::~EBook_CHM()
{
close();
}
void EBook_CHM::close()
{
if ( m_chmFile == NULL )
return;
chm_close( m_chmFile );
m_chmFile = NULL;
m_filename = m_font = QString::null;
m_home.clear();
m_topicsFile.clear();
m_indexFile.clear();
m_textCodec = 0;
m_textCodecForSpecialFiles = 0;
m_detectedLCID = 0;
m_currentEncoding = "UTF-8";
}
QString EBook_CHM::title() const
{
return encodeWithCurrentCodec( m_title );
}
QUrl EBook_CHM::homeUrl() const
{
return pathToUrl( m_home );
}
bool EBook_CHM::hasFeature(EBook::Feature code) const
{
switch ( code )
{
case FEATURE_TOC:
return m_tocAvailable;
case FEATURE_INDEX:
return m_indexAvailable;
case FEATURE_ENCODING:
return true;
}
return false;
}
bool EBook_CHM::getTableOfContents( QList &toc ) const
{
if ( parseBinaryTOC( toc ) )
return true;
// Parse the plain text TOC
QList< ParsedEntry > parsed;
if ( !parseFileAndFillArray( m_topicsFile, parsed, false ) )
return false;
// Find out the root offset, and reduce the indent level to it
// so the toc starts from zero offset.
int root_offset = -1;
// Fill up the real toc
toc.reserve( parsed.size() );
Q_FOREACH( const ParsedEntry& e, parsed )
{
if ( root_offset == -1 )
root_offset = e.indent;
EBookTocEntry entry;
entry.iconid = (EBookTocEntry::Icon) e.iconid;
entry.indent = e.indent - root_offset;
entry.name = e.name;
if ( !e.urls.empty() )
entry.url = e.urls[0];
toc.append( entry );
}
return true;
}
bool EBook_CHM::getIndex(QList &index) const
{
// Parse the plain text index
QList< ParsedEntry > parsed;
if ( !parseFileAndFillArray( m_indexFile, parsed, true ) )
return false;
// Find out the root offset, and reduce the indent level to it
// so the index starts from zero offset.
int root_offset = -1;
// Fill up the real index
index.reserve( parsed.size() );
Q_FOREACH( const ParsedEntry& e, parsed )
{
if ( e.urls.empty() )
continue;
if ( root_offset == -1 )
root_offset = e.indent;
EBookIndexEntry entry;
entry.name = e.name;
entry.urls = e.urls;
entry.indent = e.indent - root_offset;
entry.seealso = e.seealso;
index.append( entry );
}
return true;
}
bool EBook_CHM::getFileContentAsString( QString &str, const QUrl &url ) const
{
return getTextContent( str, urlToPath( url ) );
}
bool EBook_CHM::getFileContentAsBinary( QByteArray &data, const QUrl &url ) const
{
return getBinaryContent( data, urlToPath(url) );
}
bool EBook_CHM::getBinaryContent( QByteArray &data, const QString &url ) const
{
chmUnitInfo ui;
if( !ResolveObject( url, &ui ) )
return false;
data.resize( ui.length );
if ( RetrieveObject( &ui, (unsigned char*) data.data(), 0, ui.length ) )
return true;
return false;
}
bool EBook_CHM::getTextContent( QString& str, const QString& url, bool internal_encoding ) const
{
QByteArray buf;
if ( getBinaryContent( buf, url ) )
{
unsigned int length = buf.size();
if ( length > 0 )
{
buf.resize( length + 1 );
buf [length] = '\0';
str = internal_encoding ? (QString)( buf.constData() ) : encodeWithCurrentCodec( buf.constData() );
return true;
}
}
return false;
}
int EBook_CHM::getContentSize(const QString &url)
{
chmUnitInfo ui;
if( !ResolveObject( url, &ui ) )
return -1;
return ui.length;
}
bool EBook_CHM::load(const QString &archiveName)
{
QString filename;
// If the file has a file:// prefix, remove it
if ( archiveName.startsWith( "file://" ) )
filename = archiveName.mid( 7 ); // strip it
else
filename = archiveName;
if( m_chmFile )
close();
#if defined (WIN32)
// chmlib on Win32 uses BSTR, so we need to alloc/free a string
BSTR bstrfilename = SysAllocStringLen( 0, filename.length() );
filename.toWCharArray( bstrfilename );
m_chmFile = chm_open( bstrfilename );
SysFreeString( bstrfilename );
#else
m_chmFile = chm_open( QFile::encodeName(filename) );
#endif
if ( m_chmFile == NULL )
return false;
m_filename = filename;
// Reset encoding
m_textCodec = 0;
m_textCodecForSpecialFiles = 0;
m_currentEncoding = "UTF-8";
// Get information from /#WINDOWS and /#SYSTEM files (encoding, title, context file and so)
// and guess the encoding
getInfoFromWindows();
getInfoFromSystem();
guessTextEncoding();
// Check whether the search tables are present
if ( ResolveObject("/#TOPICS", &m_chmTOPICS)
&& ResolveObject("/#STRINGS", &m_chmSTRINGS)
&& ResolveObject("/#URLTBL", &m_chmURLTBL)
&& ResolveObject("/#URLSTR", &m_chmURLSTR) )
{
m_lookupTablesValid = true;
fillTopicsUrlMap();
}
else
m_lookupTablesValid = false;
// Some CHM files have toc and index files, but do not set the name properly.
// Some heuristics here.
if ( m_topicsFile.isEmpty() && hasFile( "/toc.hhc" ) )
m_topicsFile = "/toc.hhc";
if ( m_indexFile.isEmpty() && hasFile( "/index.hhk" ) )
m_indexFile = "/index.hhk";
if ( !m_topicsFile.isEmpty() || ( m_lookupTablesValid && hasFile( "/#TOCIDX" ) ) )
m_tocAvailable = true;
else
m_tocAvailable = false;
if ( !m_indexFile.isEmpty() || ( m_lookupTablesValid && hasFile( "/$WWKeywordLinks/BTree" ) ) )
m_indexAvailable = true;
else
m_indexAvailable = false;
return true;
}
int EBook_CHM::findStringInQuotes (const QString& tag, int offset, QString& value, bool firstquote, bool decodeentities) const
{
int qbegin = tag.indexOf ('"', offset);
if ( qbegin == -1 )
qFatal ("EBook_CHMImpl::findStringInQuotes: cannot find first quote in tag: '%s'", qPrintable( tag ));
int qend = firstquote ? tag.indexOf ('"', qbegin + 1) : tag.lastIndexOf ('"');
if ( qend == -1 || qend <= qbegin )
qFatal ("EBook_CHMImpl::findStringInQuotes: cannot find last quote in tag: '%s'", qPrintable( tag ));
// If we do not need to decode HTML entities, just return.
if ( decodeentities )
{
QString htmlentity = QString::null;
bool fill_entity = false;
value.reserve (qend - qbegin); // to avoid multiple memory allocations
for ( int i = qbegin + 1; i < qend; i++ )
{
if ( !fill_entity )
{
if ( tag[i] == '&' ) // HTML entity starts
fill_entity = true;
else
value.append (tag[i]);
}
else
{
if ( tag[i] == ';' ) // HTML entity ends
{
// If entity is an ASCII code, just decode it
QString decode = m_htmlEntityDecoder.decode( htmlentity );
if ( decode.isNull() )
break;
value.append ( decode );
htmlentity = QString::null;
fill_entity = false;
}
else
htmlentity.append (tag[i]);
}
}
}
else
value = tag.mid (qbegin + 1, qend - qbegin - 1);
return qend + 1;
}
bool EBook_CHM::parseFileAndFillArray( const QString& file, QList< ParsedEntry >& data, bool asIndex ) const
{
QString src;
const int MAX_NEST_DEPTH = 256;
if ( !getTextContent( src, file ) || src.isEmpty() )
return false;
/*
// Save the index for debugging purposes
QFile outfile( "parsed.htm" );
if ( outfile.open( QIODevice::WriteOnly ) )
{
QTextStream textstream( &outfile );
textstream << src;
outfile.close();
}
*/
EBookTocEntry::Icon defaultimagenum = EBookTocEntry::IMAGE_AUTO;
int pos = 0, indent = 0, root_indent_offset = 0;
bool in_object = false, root_indent_offset_set = false;
ParsedEntry entry;
entry.iconid = defaultimagenum;
// Split the HHC file by HTML tags
int stringlen = src.length();
while ( pos < stringlen && (pos = src.indexOf ('<', pos)) != -1 )
{
int i, word_end = 0;
for ( i = ++pos; i < stringlen; i++ )
{
// If a " or ' is found, skip to the next one.
if ( (src[i] == '"' || src[i] == '\'') )
{
// find where quote ends, either by another quote, or by '>' symbol (some people don't know HTML)
int nextpos = src.indexOf (src[i], i+1);
if ( nextpos == -1 && (nextpos = src.indexOf ('>', i+1)) == -1 )
{
qWarning ("EBook_CHMImpl::ParseHhcAndFillTree: corrupted TOC: %s", qPrintable( src.mid(i) ));
return false;
}
i = nextpos;
}
else if ( src[i] == '>' )
break;
else if ( !src[i].isLetterOrNumber() && src[i] != '/' && !word_end )
word_end = i;
}
QString tagword, tag = src.mid (pos, i - pos);
if ( word_end )
tagword = src.mid (pos, word_end - pos).toLower();
else
tagword = tag.toLower();
DEBUGPARSER(("tag: '%s', tagword: '%s'\n", qPrintable( tag ), qPrintable( tagword ) ));
//