Add tde-ebook-reader package

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
pull/1/head
Michele Calgaro 5 months ago
parent 17b259df9c
commit cd87a41ab9
Signed by: MicheleC
GPG Key ID: 2A75B7CA8ADED5CF

@ -12,6 +12,7 @@
include( TDEVersion ) include( TDEVersion )
cmake_minimum_required( VERSION ${TDE_CMAKE_MINIMUM_VERSION} ) cmake_minimum_required( VERSION ${TDE_CMAKE_MINIMUM_VERSION} )
tde_set_project_version( ) tde_set_project_version( )
set( PACKAGE_VERSION 0.99.4 )
#### general package setup #### general package setup
@ -69,7 +70,7 @@ set( CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--no-undefined"
##### directories ##### directories
add_subdirectory( zlibrary ) add_subdirectory( zlibrary )
#add_subdirectory( tde-ebook-reader ) add_subdirectory( reader )
##### write configure files ##### write configure files

@ -56,6 +56,13 @@ if( NOT FRIBIDI_FOUND )
endif( ) endif( )
##### check for sqlite3
pkg_search_module( SQLITE sqlite3 )
if( NOT SQLITE_FOUND )
tde_message_fatal( "sqlite3 is required, but not found on your system" )
endif( )
##### check for unibreak ##### check for unibreak
pkg_search_module( UNIBREAK libunibreak ) pkg_search_module( UNIBREAK libunibreak )
if( NOT UNIBREAK_FOUND ) if( NOT UNIBREAK_FOUND )

@ -1,4 +1,4 @@
#define VERSION "@VERSION@" #define VERSION "@PACKAGE_VERSION@"
// Defined if you have fvisibility and fvisibility-inlines-hidden support. // Defined if you have fvisibility and fvisibility-inlines-hidden support.
#cmakedefine __KDE_HAVE_GCC_VISIBILITY 1 #cmakedefine __KDE_HAVE_GCC_VISIBILITY 1

4
debian/control vendored

@ -4,8 +4,8 @@ Priority: optional
Maintainer: TDE Debian Team <team-debian@trinitydesktop.org> Maintainer: TDE Debian Team <team-debian@trinitydesktop.org>
XSBC-Original-Maintainer: Debian QA Group <packages@qa.debian.org> XSBC-Original-Maintainer: Debian QA Group <packages@qa.debian.org>
Build-Depends: cdbs, debhelper (>= 10~), quilt, tde-cmake, ninja-build, libtqtinterface-dev, Build-Depends: cdbs, debhelper (>= 10~), quilt, tde-cmake, ninja-build, libtqtinterface-dev,
libbz2-dev, libcurl4-gnutls-dev, libexpat1-dev, libfribidi-dev, libbz2-dev, libexpat1-dev, libfribidi-dev,
libjpeg-dev, libsqlite3-dev, libunibreak-dev, libz-dev, pkgconf libsqlite3-dev, libunibreak-dev, libz-dev, pkgconf
Standards-Version: 4.7.0 Standards-Version: 4.7.0
Package: tde-ebook-reader Package: tde-ebook-reader

@ -1 +1,2 @@
#usr/lib /opt/trinity/bin
/opt/trinity/share

@ -0,0 +1,3 @@
add_subdirectory( data )
add_subdirectory( desktop )
add_subdirectory( src )

@ -0,0 +1,49 @@
##### default files
file( GLOB _default_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/default/*.xml )
install(
FILES ${_default_files}
DESTINATION ${DATA_INSTALL_DIR}/tde-ebook-reader/default
)
##### format files
file( GLOB _formats_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/formats/fb2/* )
install(
FILES ${_formats_files}
DESTINATION ${DATA_INSTALL_DIR}/tde-ebook-reader/formats/fb2
)
file( GLOB _formats_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/formats/html/* )
install(
FILES ${_formats_files}
DESTINATION ${DATA_INSTALL_DIR}/tde-ebook-reader/formats/html
)
##### help files
file( GLOB _help_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/help/*.fb2 )
install(
FILES ${_help_files}
DESTINATION ${DATA_INSTALL_DIR}/tde-ebook-reader/help
)
##### icons files
file( GLOB_RECURSE _icon_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/icons/*)
install(
FILES ${_icon_files}
DESTINATION ${DATA_INSTALL_DIR}/tde-ebook-reader/icons
)
##### resource files
file( GLOB _xml_resource_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/resources/*.xml )
install(
FILES ${_xml_resource_files}
DESTINATION ${DATA_INSTALL_DIR}/tde-ebook-reader/resources
)

@ -1,39 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<menubar>
<item id="bookInfo"/>
<item id="toc"/>
<submenu id="library">
<item id="showLibrary"/>
<item id="previousBook"/>
<item id="showRecent"/>
<item id="addBook"/>
<item id="showHelp"/>
</submenu>
<submenu id="navigate">
<item id="gotoHome"/>
<item id="gotoPageNumber"/>
<item id="gotoSectionStart"/>
<item id="gotoSectionEnd"/>
<item id="nextTOCSection"/>
<item id="previousTOCSection"/>
<item id="undo"/>
<item id="redo"/>
</submenu>
<submenu id="selection">
<item id="copyToClipboard"/>
<item id="openInDictionary"/>
<item id="clearSelection"/>
</submenu>
<submenu id="search">
<item id="search"/>
<item id="findPrevious"/>
<item id="findNext"/>
</submenu>
<submenu id="view">
<item id="rotate"/>
<item id="toggleFullscreen"/>
<item id="toggleIndicator"/>
</submenu>
<item id="preferences"/>
<item id="quit"/>
</menubar>

@ -1,25 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<toolbar>
<button id="showReading"/>
<separator/>
<button id="showLibrary"/>
<button id="showRecent"/>
<button id="addBook"/>
<separator/>
<button id="gotoHome"/>
<button id="undo"/>
<button id="redo"/>
<separator/>
<button id="toc"/>
<separator/>
<button id="search"/>
<button id="findPrevious"/>
<button id="findNext"/>
<separator/>
<button id="bookInfo"/>
<button id="preferences"/>
<separator/>
<button id="rotate"/>
<separator/>
<button id="showHelp"/>
</toolbar>

@ -1,23 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<toolbar>
<button id="showReading"/>
<separator/>
<button id="showLibrary"/>
<button id="showRecent"/>
<button id="addBook"/>
<separator/>
<button id="gotoHome"/>
<button id="undo"/>
<button id="redo"/>
<separator/>
<button id="toc"/>
<separator/>
<button id="search"/>
<button id="findPrevious"/>
<button id="findNext"/>
<separator/>
<button id="bookInfo"/>
<button id="preferences"/>
<separator/>
<button id="rotate"/>
</toolbar>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 612 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 108 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 177 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

@ -1 +0,0 @@
22x22-transparent-png

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 205 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 193 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 269 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 205 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 205 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 205 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 205 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 205 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 205 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 205 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 205 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 193 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 205 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 227 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 523 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 680 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 523 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 523 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 523 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 523 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 523 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 654 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 523 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 523 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 836 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 523 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 695 B

@ -1 +0,0 @@
22x22-transparent-png

Before

Width:  |  Height:  |  Size: 744 B

After

Width:  |  Height:  |  Size: 744 B

Before

Width:  |  Height:  |  Size: 1015 B

After

Width:  |  Height:  |  Size: 1015 B

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Before

Width:  |  Height:  |  Size: 744 B

After

Width:  |  Height:  |  Size: 744 B

Before

Width:  |  Height:  |  Size: 744 B

After

Width:  |  Height:  |  Size: 744 B

Before

Width:  |  Height:  |  Size: 744 B

After

Width:  |  Height:  |  Size: 744 B

Before

Width:  |  Height:  |  Size: 744 B

After

Width:  |  Height:  |  Size: 744 B

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Before

Width:  |  Height:  |  Size: 744 B

After

Width:  |  Height:  |  Size: 744 B

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 241 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 247 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 371 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 376 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 303 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 235 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 166 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 219 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 495 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 256 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 171 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 134 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 175 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 171 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 274 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 275 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 533 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 525 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 338 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 270 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 202 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 218 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 613 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 275 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 196 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 147 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 207 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 196 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

@ -1 +0,0 @@
32x32-transparent-png

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

@ -0,0 +1,6 @@
INSTALL(
FILES tde-ebook-reader.1
DESTINATION ${MAN_INSTALL_DIR}/man1
)
tde_create_translated_desktop( tde-ebook-reader.desktop )

@ -0,0 +1,19 @@
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_BINARY_DIR}
${CMAKE_SOURCE_DIR}/zlibrary/core/include
${CMAKE_SOURCE_DIR}/zlibrary/text/include
${CMAKE_BINARY_DIR}/zlibrary/core/include
${CMAKE_BINARY_DIR}/zlibrary/text/include
)
##### libzlcore-tqt (shared)
file( GLOB_RECURSE _src_cpp_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
tde_add_executable( tde-ebook-reader AUTOMOC
SOURCES ${_src_cpp_files}
LINK zlcore-tqt-shared zltext-tqt-shared ${SQLITE_LIBRARIES}
DESTINATION ${BIN_INSTALL_DIR}
)

@ -1,111 +0,0 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.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 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.
*/
#include <ZLInputStream.h>
#include "DocBookBookReader.h"
#include "../../bookmodel/BookModel.h"
#include "../../model/Paragraph.h"
DocBookBookReader::DocBookBookReader(BookModel &model) : BookReader(model) {
setMainTextModel();
myReadText = false;
}
void DocBookBookReader::characterDataHandler(const char *text, std::size_t len) {
addDataToBuffer(text, len);
}
void DocBookBookReader::startElementHandler(int tag, const char **) {
switch (tag) {
case _SECT1:
myReadText = true;
pushKind(REGULAR);
beginContentsParagraph();
break;
case _PARA:
if (myReadText) {
beginParagraph();
}
break;
case _TITLE:
enterTitle();
pushKind(SECTION_TITLE);
if (myReadText) {
beginParagraph();
}
break;
case _EMPHASIS:
addControl(EMPHASIS, true);
break;
case _CITETITLE:
addControl(CITE, true);
break;
case _ULINK:
case _EMAIL:
addControl(CODE, true);
break;
case _BLOCKQUOTE:
pushKind(STRONG);
break;
default:
break;
}
}
void DocBookBookReader::endElementHandler(int tag) {
switch (tag) {
case _SECT1:
myReadText = false;
popKind();
endContentsParagraph();
insertEndOfSectionParagraph();
break;
case _PARA:
endParagraph();
break;
case _TITLE:
endParagraph();
popKind();
endContentsParagraph();
exitTitle();
break;
case _EMPHASIS:
addControl(EMPHASIS, false);
break;
case _CITETITLE:
addControl(CITE, false);
break;
case _ULINK:
case _EMAIL:
addControl(CODE, false);
break;
case _BLOCKQUOTE:
popKind();
break;
default:
break;
}
}
void DocBookBookReader::readBook(shared_ptr<ZLInputStream> stream) {
readDocument(stream);
}

@ -1,45 +0,0 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.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 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.
*/
#ifndef __DOCBOOKBOOKREADER_H__
#define __DOCBOOKBOOKREADER_H__
#include "DocBookReader.h"
#include "../../bookmodel/BookReader.h"
class BookModel;
class DocBookBookReader : public BookReader, public DocBookReader {
public:
DocBookBookReader(BookModel &model);
~DocBookBookReader();
void readBook(shared_ptr<ZLInputStream> stream);
void startElementHandler(int tag, const char **attributes);
void endElementHandler(int tag);
void characterDataHandler(const char *text, std::size_t len);
private:
bool myReadText;
};
inline DocBookBookReader::~DocBookBookReader() {}
#endif /* __DOCBOOKBOOKREADER_H__ */

@ -1,137 +0,0 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.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 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.
*/
#include <ZLInputStream.h>
#include <ZLUnicodeUtil.h>
#include "DocBookDescriptionReader.h"
#include "../../library/Book.h"
#include "../../library/Author.h"
DocBookDescriptionReader::DocBookDescriptionReader(Book &book) : myBook(book) {
myReadTitle = false;
myReadAuthor = false;
for (int i = 0; i < 3; ++i) {
myReadAuthorName[i] = false;
}
myBook.setLanguage("en");
myDepth = 0;
}
void DocBookDescriptionReader::characterDataHandler(const char *text, std::size_t len) {
if (myReadTitle) {
myBook.setTitle(myBook.title() + std::string(text, len));
} else {
for (int i = 0; i < 3; ++i) {
if (myReadAuthorName[i]) {
myAuthorNames[i].append(text, len);
break;
}
}
}
}
void DocBookDescriptionReader::startElementHandler(int tag, const char **) {
++myDepth;
switch (tag) {
case _SECT1:
myReturnCode = true;
myDoBreak = true;
break;
case _TITLE:
if (myDepth == 2) {
myReadTitle = true;
}
break;
case _AUTHOR:
if (myDepth == 3) {
myReadAuthor = true;
}
break;
case _FIRSTNAME:
if (myReadAuthor) {
myReadAuthorName[0] = true;
}
break;
case _OTHERNAME:
if (myReadAuthor) {
myReadAuthorName[1] = true;
}
break;
case _SURNAME:
if (myReadAuthor) {
myReadAuthorName[2] = true;
}
break;
default:
break;
}
}
void DocBookDescriptionReader::endElementHandler(int tag) {
--myDepth;
switch (tag) {
case _TITLE:
myReadTitle = false;
break;
case _AUTHOR: {
ZLUnicodeUtil::utf8Trim(myAuthorNames[0]);
ZLUnicodeUtil::utf8Trim(myAuthorNames[1]);
ZLUnicodeUtil::utf8Trim(myAuthorNames[2]);
std::string fullName = myAuthorNames[0];
if (!fullName.empty() && !myAuthorNames[1].empty()) {
fullName += ' ';
}
fullName += myAuthorNames[1];
if (!fullName.empty() && !myAuthorNames[2].empty()) {
fullName += ' ';
}
fullName += myAuthorNames[2];
shared_ptr<Author> author = Author::create(fullName, myAuthorNames[2]);
if (!author.isNull()) {
myBook.authors().add( author );
}
}
myAuthorNames[0].erase();
myAuthorNames[1].erase();
myAuthorNames[2].erase();
myReadAuthor = false;
break;
case _FIRSTNAME:
myReadAuthorName[0] = false;
break;
case _OTHERNAME:
myReadAuthorName[1] = false;
break;
case _SURNAME:
myReadAuthorName[2] = false;
break;
default:
break;
}
}
bool DocBookDescriptionReader::readMetaInfo(shared_ptr<ZLInputStream> stream) {
bool code = readDocument(stream);
if (myBook.authors().empty()) {
myBook.authors().push_back( new Author() );
}
return code;
}

@ -1,56 +0,0 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.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 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.
*/
#ifndef __DOCBOOKDESCRIPTIONREADER_H__
#define __DOCBOOKDESCRIPTIONREADER_H__
#include <string>
#include "DocBookReader.h"
class Book;
class DocBookDescriptionReader : public DocBookReader {
public:
DocBookDescriptionReader(Book &book);
~DocBookDescriptionReader();
bool readMetaInfo(shared_ptr<ZLInputStream> stream);
void startElementHandler(int tag, const char **attributes);
void endElementHandler(int tag);
void characterDataHandler(const char *text, std::size_t len);
private:
Book &myBook;
bool myReturnCode;
bool myReadTitle;
bool myReadAuthor;
bool myReadAuthorName[3];
std::string myAuthorNames[3];
int myDepth;
};
inline DocBookDescriptionReader::~DocBookDescriptionReader() {}
#endif /* __DOCBOOKDESCRIPTIONREADER_H__ */

@ -1,43 +0,0 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.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 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.
*/
#include <ZLFile.h>
#include <ZLInputStream.h>
#include "DocBookPlugin.h"
#include "DocBookDescriptionReader.h"
#include "DocBookBookReader.h"
#include "../../library/Book.h"
bool DocBookPlugin::acceptsFile(const std::string &extension) const {
return extension == "xml";
}
bool DocBookPlugin::readMetaInfo(Book &book) const {
return DocBookDescriptionReader(book).readMetaInfo(ZLFile(path).inputStream());
}
bool DocBookPlugin::readLanguageAndEncoding(Book &book) const {
(void)book;
return true;
}
bool DocBookPlugin::readModel(BookModel &model) const {
return DocBookBookReader(model).readDocument(ZLFile(book.fileName()).inputStream());
}

@ -1,41 +0,0 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.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 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.
*/
#ifndef __DOCBOOKPLUGIN_H__
#define __DOCBOOKPLUGIN_H__
#include "../FormatPlugin.h"
class DocBookPlugin : public FormatPlugin {
public:
DocBookPlugin();
~DocBookPlugin();
bool providesMetaInfo() const;
bool acceptsFile(const std::string &extension) const;
bool readMetaInfo(Book &book) const;
bool readLanguageAndEncoding(Book &book) const;
bool readModel(BookModel &model) const;
};
inline DocBookPlugin::DocBookPlugin() {}
inline DocBookPlugin::~DocBookPlugin() {}
inline bool DocBookPlugin::providesMetaInfo() const { return true; }
#endif /* __DOCBOOKPLUGIN_H__ */

@ -1,71 +0,0 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.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 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.
*/
#include <ZLStringUtil.h>
#include <ZLFile.h>
#include <ZLDir.h>
#include "DocBookReader.h"
static const DocBookReader::Tag TAGS[] = {
{"article", DocBookReader::_ARTICLE},
{"title", DocBookReader::_TITLE},
{"articleinfo", DocBookReader::_ARTICLEINFO},
{"author", DocBookReader::_AUTHOR},
{"firstname", DocBookReader::_FIRSTNAME},
{"othername", DocBookReader::_OTHERNAME},
{"surname", DocBookReader::_SURNAME},
{"affiliation", DocBookReader::_AFFILIATION},
{"orgname", DocBookReader::_ORGNAME},
{"ulink", DocBookReader::_ULINK},
{"address", DocBookReader::_ADDRESS},
{"email", DocBookReader::_EMAIL},
{"pubdate", DocBookReader::_PUBDATE},
{"releaseinfo", DocBookReader::_RELEASEINFO},
{"copyright", DocBookReader::_COPYRIGHT},
{"year", DocBookReader::_YEAR},
{"holder", DocBookReader::_HOLDER},
{"legalnotice", DocBookReader::_LEGALNOTICE},
{"para", DocBookReader::_PARA},
{"revhistory", DocBookReader::_REVHISTORY},
{"revision", DocBookReader::_REVISION},
{"revnumber", DocBookReader::_REVNUMBER},
{"date", DocBookReader::_DATE},
{"authorinitials", DocBookReader::_AUTHORINITIALS},
{"revremark", DocBookReader::_REVREMARK},
{"abstract", DocBookReader::_ABSTRACT},
{"sect1", DocBookReader::_SECT1},
{"emphasis", DocBookReader::_EMPHASIS},
{"blockquote", DocBookReader::_BLOCKQUOTE},
{"citetitle", DocBookReader::_CITETITLE},
{"link", DocBookReader::_LINK},
{"foreignphrase", DocBookReader::_FOREIGNPHRASE},
{"part", DocBookReader::_PART},
{"preface", DocBookReader::_PREFACE},
{"chapter", DocBookReader::_CHAPTER},
{0, DocBookReader::_UNKNOWN}
};
const DocBookReader::Tag *DocBookReader::tags() const {
return TAGS;
}
const std::vector<std::string> &DocBookReader::externalDTDs() const {
return EntityFilesCollector::Instance().externalDTDs("docbook");
}

@ -1,95 +0,0 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.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 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.
*/
#ifndef __DOCBOOKREADER_H__
#define __DOCBOOKREADER_H__
#include <ZLXMLReader.h>
class DocBookReader : public ZLXMLReader {
public:
static std::string DTDDirectory;
public:
struct Tag {
const char *tagName;
int tagCode;
};
public:
//protected:
enum TagCode {
_ARTICLE,
_TITLE,
_ARTICLEINFO,
_AUTHOR,
_FIRSTNAME,
_OTHERNAME,
_SURNAME,
_AFFILIATION,
_ORGNAME,
_ULINK,
_ADDRESS,
_EMAIL,
_PUBDATE,
_RELEASEINFO,
_COPYRIGHT,
_YEAR,
_HOLDER,
_LEGALNOTICE,
_PARA,
_REVHISTORY,
_REVISION,
_REVNUMBER,
_DATE,
_AUTHORINITIALS,
_REVREMARK,
_ABSTRACT,
_SECT1,
_EMPHASIS,
_BLOCKQUOTE,
_CITETITLE,
_LINK,
_FOREIGNPHRASE,
_FIRSTTERM,
_FILENAME,
_ITEMIZEDLIST,
_LISTITEM,
_PART,
_PREFACE,
_CHAPTER,
_UNKNOWN
};
protected:
DocBookReader();
public:
~DocBookReader();
const Tag *tags() const;
protected:
const std::vector<std::string> &externalDTDs() const;
};
inline DocBookReader::DocBookReader() {}
inline DocBookReader::~DocBookReader() {}
#endif /* __DOCBOOKREADER_H__ */

@ -1,42 +0,0 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.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 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.
*/
#include <ZLInputStream.h>
#include "DummyBookReader.h"
#include "../../bookmodel/BookModel.h"
DummyBookReader::DummyBookReader(BookModel &model) : myModelReader(model) {
}
/*
void DummyBookReader::characterDataHandler(const char *text, std::size_t len) {
}
void DummyBookReader::startElementHandler(int tag, const char **xmlattributes) {
}
void DummyBookReader::endElementHandler(int tag) {
}
*/
bool DummyBookReader::readBook(shared_ptr<ZLInputStream> stream) {
//return readDocument(stream);
return true;
}

@ -1,44 +0,0 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.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 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.
*/
#ifndef __DUMMYBOOKREADER_H__
#define __DUMMYBOOKREADER_H__
#include "../../bookmodel/BookReader.h"
class DummyBookReader {
public:
DummyBookReader(BookModel &model);
~DummyBookReader();
bool readBook(shared_ptr<ZLInputStream> stream);
/*
void startElementHandler(int tag, const char **attributes);
void endElementHandler(int tag);
void characterDataHandler(const char *text, std::size_t len);
*/
private:
BookReader myModelReader;
};
inline DummyBookReader::~DummyBookReader() {}
#endif /* __DUMMYBOOKREADER_H__ */

@ -1,40 +0,0 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.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 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.
*/
#include <ZLInputStream.h>
#include "DummyMetaInfoReader.h"
DummyMetaInfoReader::DummyMetaInfoReader(Book &book) : myBook(book) {
}
/*
void DummyMetaInfoReader::characterDataHandler(const char *text, std::size_t len) {
}
void DummyMetaInfoReader::startElementHandler(int tag, const char **) {
}
void DummyMetaInfoReader::endElementHandler(int tag) {
}
*/
bool DummyMetaInfoReader::readMetaInfo(shared_ptr<ZLInputStream> stream) {
return false;
}

@ -1,46 +0,0 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.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 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.
*/
#ifndef __DUMMYMETAINFOREADER_H__
#define __DUMMYMETAINFOREADER_H__
#include <string>
class Book;
class DummyMetaInfoReader {
public:
DummyMetaInfoReader(Book &book);
~DummyMetaInfoReader();
bool readMetaInfo(shared_ptr<ZLInputStream> stream);
/*
void startElementHandler(int tag, const char **attributes);
void endElementHandler(int tag);
void characterDataHandler(const char *text, std::size_t len);
*/
private:
Book &myBook;
};
inline DummyMetaInfoReader::~DummyMetaInfoReader() {}
#endif /* __DUMMYMETAINFOREADER_H__ */

@ -1,57 +0,0 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.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 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.
*/
#include <ZLFile.h>
#include <ZLInputStream.h>
#include "DummyPlugin.h"
#include "DummyMetaInfoReader.h"
#include "DummyBookReader.h"
#include "../../library/Book.h"
DummyPlugin::DummyPlugin() {
}
DummyPlugin::~DummyPlugin() {
}
bool DummyPlugin::providesMetaInfo() const {
return true;
}
bool DummyPlugin::acceptsFile(const ZLFile &file) const {
return file.extension() == "dummy";
}
bool DummyPlugin::readMetaInfo(Book &book) const {
return DummyMetaInfoReader(book).readMetaInfo(ZLFile(path).inputStream());
}
bool DummyPlugin::readLanguageAndEncoding(Book &book) const {
(void)book;
return true;
}
bool DummyPlugin::readModel(BookModel &model) const {
return DummyBookReader(model).readBook(ZLFile(book.fileName()).inputStream());
}
shared_ptr<const ZLImage> DummyPlugin::coverImage(const ZLFile &file) const {
return DummyCoverReader(file).readCover();
}

@ -1,38 +0,0 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.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 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.
*/
#ifndef __DUMMYPLUGIN_H__
#define __DUMMYPLUGIN_H__
#include "../FormatPlugin.h"
class DummyPlugin : public FormatPlugin {
public:
DummyPlugin();
~DummyPlugin();
bool providesMetaInfo() const;
bool acceptsFile(const ZLFile &file) const;
bool readMetaInfo(Book &book) const;
bool readLanguageAndEncoding(Book &book) const;
bool readModel(BookModel &model) const;
shared_ptr<const ZLImage> coverImage(const ZLFile &file) const;
};
#endif /* __DUMMYPLUGIN_H__ */

@ -1,12 +0,0 @@
#!/bin/sh
if [ $# != 3 ]; then
echo "usage: $0 <short_format_name> <camel_cased_format_name> <upper_cased_format_name>";
exit 0;
fi;
if mkdir ../$1; then
for file in Dummy*.h Dummy*.cpp; do
sed "s/Dummy/$2/g" $file | sed "s/DUMMY/$3/g" > ../$1/`echo $file | sed "s/Dummy/$2/"`;
done
fi;

@ -1,261 +0,0 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.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 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.
*/
#include <cstdlib>
#include <iostream>
#include <ZLStringUtil.h>
#include <ZLInputStream.h>
#include "PdfBookReader.h"
#include "PdfObject.h"
#include "../../bookmodel/BookModel.h"
static void readLine(ZLInputStream &stream, std::string &buffer) {
buffer.clear();
char ch;
while (1) {
if (stream.read(&ch, 1) != 1) {
return;
}
if ((ch == 10) || (ch == 13)) {
if (!buffer.empty()) {
return;
}
} else {
buffer += ch;
}
}
}
PdfBookReader::PdfBookReader(BookModel &model) : myModelReader(model) {
}
PdfBookReader::~PdfBookReader() {
}
shared_ptr<PdfObject> PdfBookReader::readObjectFromLocation(ZLInputStream &stream, const std::pair<int,int> &address) {
std::map<std::pair<int,int>,int>::const_iterator jt = myObjectLocationMap.find(address);
if (jt == myObjectLocationMap.end()) {
return 0;
}
stream.seek(jt->second, true);
char ch = 0;
PdfObject::readToken(stream, myBuffer, ch);
if (address.first != atoi(myBuffer.c_str())) {
return 0;
}
PdfObject::readToken(stream, myBuffer, ch);
if (address.second != atoi(myBuffer.c_str())) {
return 0;
}
PdfObject::readToken(stream, myBuffer, ch);
if (myBuffer != "obj") {
return 0;
}
return PdfObject::readObject(stream, ch);
}
shared_ptr<PdfObject> PdfBookReader::resolveReference(shared_ptr<PdfObject> ref, ZLInputStream &stream) {
if (ref.isNull() || (ref->type() != PdfObject::REFERENCE)) {
return ref;
}
const PdfObjectReference &reference = (const PdfObjectReference&)*ref;
const std::pair<int,int> address(reference.number(), reference.generation());
std::map<std::pair<int,int>,shared_ptr<PdfObject> >::const_iterator it = myObjectMap.find(address);
if (it != myObjectMap.end()) {
return it->second;
}
std::map<std::pair<int,int>,int>::const_iterator jt = myObjectLocationMap.find(address);
shared_ptr<PdfObject> object = readObjectFromLocation(stream, address);
myObjectMap.insert(std::make_pair(address, object));
return object;
}
static void stripBuffer(std::string &buffer) {
int index = buffer.find('%');
if (index >= 0) {
buffer.erase(index);
}
ZLStringUtil::stripWhiteSpaces(buffer);
}
bool PdfBookReader::readReferenceTable(ZLInputStream &stream, int xrefOffset) {
while (true) {
stream.seek(xrefOffset, true);
readLine(stream, myBuffer);
stripBuffer(myBuffer);
if (myBuffer != "xref") {
return false;
}
while (true) {
readLine(stream, myBuffer);
stripBuffer(myBuffer);
if (myBuffer == "trailer") {
break;
}
const int index = myBuffer.find(' ');
const int start = atoi(myBuffer.c_str());
const int len = atoi(myBuffer.c_str() + index + 1);
for (int i = 0; i < len; ++i) {
readLine(stream, myBuffer);
stripBuffer(myBuffer);
if (myBuffer.length() != 18) {
return false;
}
const int objectOffset = atoi(myBuffer.c_str());
const int objectGeneration = atoi(myBuffer.c_str() + 11);
const bool objectInUse = myBuffer[17] == 'n';
if (objectInUse) {
myObjectLocationMap[std::make_pair(start + i, objectGeneration)] = objectOffset;
}
}
}
char ch = 0;
shared_ptr<PdfObject> trailer = PdfObject::readObject(stream, ch);
if (trailer.isNull() || (trailer->type() != PdfObject::DICTIONARY)) {
return false;
}
if (myTrailer.isNull()) {
myTrailer = trailer;
}
PdfDictionaryObject &trailerDictionary = (PdfDictionaryObject&)*trailer;
shared_ptr<PdfObject> previous = trailerDictionary["Prev"];
if (previous.isNull()) {
return true;
}
if (previous->type() != PdfObject::INTEGER_NUMBER) {
return false;
}
xrefOffset = ((PdfIntegerObject&)*previous).value();
}
}
bool PdfBookReader::readBook(shared_ptr<ZLInputStream> stream) {
if (stream.isNull() || !stream->open()) {
return false;
}
readLine(*stream, myBuffer);
if (!ZLStringUtil::stringStartsWith(myBuffer, "%PDF-")) {
return false;
}
std::string version = myBuffer.substr(5);
std::cerr << "version = " << version << "\n";
std::size_t eofOffset = stream->sizeOfOpened();
if (eofOffset < 100) {
return false;
}
stream->seek(eofOffset - 100, true);
bool readXrefOffset = false;
std::size_t xrefOffset = (std::size_t)-1;
while (true) {
readLine(*stream, myBuffer);
if (myBuffer.empty()) {
break;
}
stripBuffer(myBuffer);
if (readXrefOffset) {
if (!myBuffer.empty()) {
xrefOffset = atoi(myBuffer.c_str());
break;
}
} else if (myBuffer == "startxref") {
readXrefOffset = true;
}
}
if (!readReferenceTable(*stream, xrefOffset)) {
return false;
}
PdfDictionaryObject &trailerDictionary = (PdfDictionaryObject&)*myTrailer;
shared_ptr<PdfObject> root = resolveReference(trailerDictionary["Root"], *stream);
if (root.isNull() || (root->type() != PdfObject::DICTIONARY)) {
return false;
}
PdfDictionaryObject &rootDictionary = (PdfDictionaryObject&)*root;
if (rootDictionary["Type"] != PdfNameObject::nameObject("Catalog")) {
return false;
}
shared_ptr<PdfObject> pageRootNode = resolveReference(rootDictionary["Pages"], *stream);
if (pageRootNode.isNull() || (pageRootNode->type() != PdfObject::DICTIONARY)) {
return false;
}
PdfDictionaryObject &pageRootNodeDictionary = (PdfDictionaryObject&)*pageRootNode;
if (pageRootNodeDictionary["Type"] != PdfNameObject::nameObject("Pages")) {
return false;
}
/*
shared_ptr<PdfObject> count = pageRootNodeDictionary["Count"];
if (!count.isNull() && (count->type() == PdfObject::INTEGER_NUMBER)) {
std::cerr << "count = " << ((PdfIntegerObject&)*count).value() << "\n";
}
*/
shared_ptr<PdfObject> pages = pageRootNodeDictionary["Kids"];
if (pages.isNull() || (pages->type() != PdfObject::ARRAY)) {
return false;
}
const PdfArrayObject& pagesArray = (const PdfArrayObject&)*pages;
const std::size_t pageNumber = pagesArray.size();
for (std::size_t i = 0; i < pageNumber; ++i) {
processPage(pagesArray[i], *stream);
}
return true;
}
void PdfBookReader::processContents(shared_ptr<PdfObject> contentsObject, ZLInputStream &stream) {
contentsObject = resolveReference(contentsObject, stream);
}
void PdfBookReader::processPage(shared_ptr<PdfObject> pageObject, ZLInputStream &stream) {
pageObject = resolveReference(pageObject, stream);
if (pageObject.isNull() || pageObject->type() != PdfObject::DICTIONARY) {
return;
}
const PdfDictionaryObject &pageDictionary = (const PdfDictionaryObject&)*pageObject;
shared_ptr<PdfObject> contents = pageDictionary["Contents"];
if (contents.isNull()) {
return;
}
switch (contents->type()) {
default:
break;
case PdfObject::REFERENCE:
processContents(contents, stream);
break;
case PdfObject::ARRAY:
{
const PdfArrayObject &array = (const PdfArrayObject&)*contents;
const std::size_t len = array.size();
for (std::size_t i = 0; i < len; ++i) {
processContents(array[i], stream);
}
break;
}
}
}

@ -1,52 +0,0 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.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 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.
*/
#ifndef __PdfBOOKREADER_H__
#define __PdfBOOKREADER_H__
#include <map>
#include "../../bookmodel/BookReader.h"
class PdfObject;
class PdfObjectReference;
class PdfBookReader {
public:
PdfBookReader(BookModel &model);
~PdfBookReader();
bool readBook(shared_ptr<ZLInputStream> stream);
private:
bool readReferenceTable(ZLInputStream &stream, int offset);
shared_ptr<PdfObject> resolveReference(shared_ptr<PdfObject> reference, ZLInputStream &stream);
shared_ptr<PdfObject> readObjectFromLocation(ZLInputStream &stream, const std::pair<int,int> &address);
void processPage(shared_ptr<PdfObject> pageObject, ZLInputStream &stream);
void processContents(shared_ptr<PdfObject> contentsObject, ZLInputStream &stream);
private:
BookReader myModelReader;
std::string myBuffer;
std::map<std::pair<int,int>,int> myObjectLocationMap;
std::map<std::pair<int,int>,shared_ptr<PdfObject> > myObjectMap;
shared_ptr<PdfObject> myTrailer;
};
#endif /* __PdfBOOKREADER_H__ */

@ -1,29 +0,0 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.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 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.
*/
#include <ZLInputStream.h>
#include "PdfDescriptionReader.h"
PdfDescriptionReader::PdfDescriptionReader(Book &book) : myBook(book) {
}
bool PdfDescriptionReader::readMetaInfo(shared_ptr<ZLInputStream> stream) {
return true;
}

@ -1,40 +0,0 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.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 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.
*/
#ifndef __PDFDESCRIPTIONREADER_H__
#define __PDFDESCRIPTIONREADER_H__
#include <string>
class Book;
class PdfDescriptionReader {
public:
PdfDescriptionReader(Book &book);
~PdfDescriptionReader();
bool readMetaInfo(shared_ptr<ZLInputStream> stream);
private:
Book &myBook;
};
inline PdfDescriptionReader::~PdfDescriptionReader() {}
#endif /* __PDFDESCRIPTIONREADER_H__ */

@ -1,450 +0,0 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.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 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.
*/
#include <iostream>
#include <ZLInputStream.h>
#include <ZLZDecompressor.h>
#include "PdfObject.h"
PdfObject::~PdfObject() {
}
shared_ptr<PdfObject> PdfIntegerObject::integerObject(int value) {
if ((value < 0) || (value >= 256)) {
return new PdfIntegerObject(value);
} else {
static shared_ptr<PdfObject>* table = new shared_ptr<PdfObject>[256];
if (table[value].isNull()) {
table[value] = new PdfIntegerObject(value);
}
return table[value];
}
}
PdfIntegerObject::PdfIntegerObject(int value) : myValue(value) {
std::cerr << "PdfIntegerObject " << value << "\n";
}
int PdfIntegerObject::value() const {
return myValue;
}
PdfObject::Type PdfIntegerObject::type() const {
return INTEGER_NUMBER;
}
shared_ptr<PdfObject> PdfBooleanObject::TRUE() {
static shared_ptr<PdfObject> value = new PdfBooleanObject(true);
return value;
}
shared_ptr<PdfObject> PdfBooleanObject::FALSE() {
static shared_ptr<PdfObject> value = new PdfBooleanObject(false);
return value;
}
PdfBooleanObject::PdfBooleanObject(bool value) : myValue(value) {
std::cerr << "PdfBooleanObject " << value << "\n";
}
bool PdfBooleanObject::value() const {
return myValue;
}
PdfObject::Type PdfBooleanObject::type() const {
return BOOLEAN;
}
PdfStringObject::PdfStringObject(const std::string &value) : myValue(value) {
std::cerr << "PdfStringObject " << value << "\n";
}
PdfObject::Type PdfStringObject::type() const {
return STRING;
}
std::map<std::string,shared_ptr<PdfObject> > PdfNameObject::ourObjectMap;
shared_ptr<PdfObject> PdfNameObject::nameObject(const std::string &id) {
// TODO: process escaped characters
std::map<std::string,shared_ptr<PdfObject> >::const_iterator it = ourObjectMap.find(id);
if (it != ourObjectMap.end()) {
return it->second;
}
std::cerr << "PdfNameObject " << id << "\n";
shared_ptr<PdfObject> object = new PdfNameObject();
ourObjectMap.insert(std::make_pair(id, object));
return object;
}
PdfNameObject::PdfNameObject() {
}
PdfObject::Type PdfNameObject::type() const {
return NAME;
}
PdfDictionaryObject::PdfDictionaryObject() {
}
void PdfDictionaryObject::setObject(shared_ptr<PdfObject> id, shared_ptr<PdfObject> object) {
myMap[id] = object;
}
shared_ptr<PdfObject> PdfDictionaryObject::operator[](shared_ptr<PdfObject> id) const {
std::map<shared_ptr<PdfObject>,shared_ptr<PdfObject> >::const_iterator it = myMap.find(id);
return (it != myMap.end()) ? it->second : 0;
}
shared_ptr<PdfObject> PdfDictionaryObject::operator[](const std::string &id) const {
return operator[](PdfNameObject::nameObject(id));
}
PdfObject::Type PdfDictionaryObject::type() const {
return DICTIONARY;
}
PdfArrayObject::PdfArrayObject() {
}
void PdfArrayObject::addObject(shared_ptr<PdfObject> object) {
myVector.push_back(object);
}
shared_ptr<PdfObject> PdfArrayObject::popLast() {
if (!myVector.empty()) {
shared_ptr<PdfObject> last = myVector.back();
myVector.pop_back();
return last;
}
return 0;
}
int PdfArrayObject::size() const {
return myVector.size();
}
shared_ptr<PdfObject> PdfArrayObject::operator[](int index) const {
return myVector[index];
}
PdfObject::Type PdfArrayObject::type() const {
return ARRAY;
}
PdfObjectReference::PdfObjectReference(int number, int generation) : myNumber(number), myGeneration(generation) {
}
int PdfObjectReference::number() const {
return myNumber;
}
int PdfObjectReference::generation() const {
return myGeneration;
}
PdfObject::Type PdfObjectReference::type() const {
return REFERENCE;
}
PdfStreamObject::PdfStreamObject(const PdfDictionaryObject &dictionary, ZLInputStream &dataStream) {
char ch;
skipWhiteSpaces(dataStream, ch);
shared_ptr<PdfObject> length = dictionary["Length"];
if (!length.isNull() && (length->type() == INTEGER_NUMBER)) {
int value = ((PdfIntegerObject&)*length).value();
if (value > 0) {
shared_ptr<PdfObject> filter = dictionary["Filter"];
if (filter == PdfNameObject::nameObject("FlateDecode")) {
dataStream.seek(1, false);
ZLZDecompressor decompressor(value - 2);
char buffer[2048];
while (true) {
std::size_t size = decompressor.decompress(dataStream, buffer, 2048);
if (size == 0) {
break;
}
myData.append(buffer, size);
}
std::cerr << myData << "\n";
} else {
myData.append(value, '\0');
myData[0] = ch;
dataStream.read((char*)myData.data() + 1, value - 1);
}
}
}
/*
shared_ptr<PdfObject> filter = dictionary["Filter"];
if (!filter.isNull()) {
switch (filter->type()) {
default:
break;
case NAME:
myFilters.push_back(
(filter == PdfNameObject::nameObject("FlateDecode")) ?
FLATE : UNKNOWN
);
break;
case ARRAY:
{
// TODO: process filters array
}
}
}
*/
}
PdfObject::Type PdfStreamObject::type() const {
return STREAM;
}
enum PdfCharacterType {
PDF_CHAR_REGULAR,
PDF_CHAR_WHITESPACE,
PDF_CHAR_DELIMITER
};
static PdfCharacterType *PdfCharacterTypeTable = 0;
void PdfObject::skipWhiteSpaces(ZLInputStream &stream, char &ch) {
if (PdfCharacterTypeTable == 0) {
PdfCharacterTypeTable = new PdfCharacterType[256];
for (int i = 0; i < 256; ++i) {
PdfCharacterTypeTable[i] = PDF_CHAR_REGULAR;
}
PdfCharacterTypeTable[0] = PDF_CHAR_WHITESPACE;
PdfCharacterTypeTable[9] = PDF_CHAR_WHITESPACE;
PdfCharacterTypeTable[10] = PDF_CHAR_WHITESPACE;
PdfCharacterTypeTable[12] = PDF_CHAR_WHITESPACE;
PdfCharacterTypeTable[13] = PDF_CHAR_WHITESPACE;
PdfCharacterTypeTable[32] = PDF_CHAR_WHITESPACE;
PdfCharacterTypeTable['('] = PDF_CHAR_DELIMITER;
PdfCharacterTypeTable[')'] = PDF_CHAR_DELIMITER;
PdfCharacterTypeTable['<'] = PDF_CHAR_DELIMITER;
PdfCharacterTypeTable['>'] = PDF_CHAR_DELIMITER;
PdfCharacterTypeTable['['] = PDF_CHAR_DELIMITER;
PdfCharacterTypeTable[']'] = PDF_CHAR_DELIMITER;
PdfCharacterTypeTable['{'] = PDF_CHAR_DELIMITER;
PdfCharacterTypeTable['}'] = PDF_CHAR_DELIMITER;
PdfCharacterTypeTable['/'] = PDF_CHAR_DELIMITER;
PdfCharacterTypeTable['%'] = PDF_CHAR_DELIMITER;
}
while ((PdfCharacterTypeTable[(unsigned char)ch] == PDF_CHAR_WHITESPACE) &&
(stream.read(&ch, 1) == 1)) {
}
}
void PdfObject::readToken(ZLInputStream &stream, std::string &buffer, char &ch) {
buffer.clear();
skipWhiteSpaces(stream, ch);
while (PdfCharacterTypeTable[(unsigned char)ch] == PDF_CHAR_REGULAR) {
buffer += ch;
if (stream.read(&ch, 1) != 1) {
break;
}
}
}
shared_ptr<PdfObject> PdfObject::readObject(ZLInputStream &stream, char &ch) {
skipWhiteSpaces(stream, ch);
PdfObject::Type type = PdfObject::NIL;
bool hexString = false;
switch (ch) {
case '(':
hexString = false;
type = PdfObject::STRING;
break;
case '<':
stream.read(&ch, 1);
hexString = true;
type = (ch == '<') ? PdfObject::DICTIONARY : PdfObject::STRING;
break;
case '>': // end of dictionary
stream.read(&ch, 1);
if (ch == '>') {
stream.read(&ch, 1);
}
return 0;
case '/':
type = PdfObject::NAME;
break;
case '[':
type = PdfObject::ARRAY;
break;
case ']': // end of array
stream.read(&ch, 1);
return 0;
case '+':
case '-':
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
type = PdfObject::INTEGER_NUMBER;
break;
case 't':
case 'f':
type = PdfObject::BOOLEAN;
break;
}
switch (type) {
case PdfObject::DICTIONARY:
{
ch = 0;
shared_ptr<PdfObject> name;
shared_ptr<PdfObject> value;
shared_ptr<PdfObject> next;
PdfDictionaryObject *dictionary = new PdfDictionaryObject();
while (true) {
next = readObject(stream, ch);
if (next.isNull()) {
break;
}
PdfObject::Type oType = next->type();
if (oType == PdfObject::NAME) {
name = next;
value = readObject(stream, ch);
if (value.isNull()) {
break;
}
dictionary->setObject(name, value);
} else if (oType == PdfObject::INTEGER_NUMBER) {
if (value.isNull() || (value->type() != PdfObject::INTEGER_NUMBER)) {
break;
}
skipWhiteSpaces(stream, ch);
if (ch != 'R') {
break;
}
const int number = ((PdfIntegerObject&)*value).value();
const int generation = ((PdfIntegerObject&)*next).value();
dictionary->setObject(name, new PdfObjectReference(number, generation));
value = 0;
ch = 0;
} else {
break;
}
}
std::string token;
readToken(stream, token, ch);
if (token == "stream") {
shared_ptr<PdfObject> d = dictionary;
return new PdfStreamObject(*dictionary, stream);
} else {
return dictionary;
}
}
case PdfObject::NAME:
{
std::string name;
stream.read(&ch, 1);
readToken(stream, name, ch);
return PdfNameObject::nameObject(name);
}
case PdfObject::BOOLEAN:
{
std::string name;
readToken(stream, name, ch);
return (name == "true") ? PdfBooleanObject::TRUE() : PdfBooleanObject::FALSE();
}
case PdfObject::INTEGER_NUMBER:
{
std::string str;
if ((ch == '+') || (ch == '-')) {
str += ch;
stream.read(&ch, 1);
}
while ((ch >= '0') && (ch <= '9')) {
str += ch;
stream.read(&ch, 1);
}
return PdfIntegerObject::integerObject(atoi(str.c_str()));
}
case PdfObject::STRING:
{
std::string value;
if (hexString) {
char num[3];
num[2] = '\0';
while (ch != '>') {
num[0] = ch;
stream.read(num + 1, 1);
value += (char)strtol(num, 0, 16);
stream.read(&ch, 1);
}
ch = 0;
} else {
// TODO: implement
}
return new PdfStringObject(value);
}
case PdfObject::ARRAY:
{
PdfArrayObject *array = new PdfArrayObject();
ch = 0;
while (true) {
skipWhiteSpaces(stream, ch);
if (ch == 'R') {
const int size = array->size();
if ((size >= 2) &&
((*array)[size - 1]->type() == PdfObject::INTEGER_NUMBER) &&
((*array)[size - 2]->type() == PdfObject::INTEGER_NUMBER)) {
const int generation = ((PdfIntegerObject&)*array->popLast()).value();
const int number = ((PdfIntegerObject&)*array->popLast()).value();
array->addObject(new PdfObjectReference(number, generation));
ch = 0;
}
}
shared_ptr<PdfObject> object = readObject(stream, ch);
if (object.isNull()) {
break;
}
array->addObject(object);
}
std::cerr << "PdfArrayObject " << array->size() << "\n";
return array;
}
default:
break;
}
std::string buffer;
stream.read(&ch, 1);
while (PdfCharacterTypeTable[(unsigned char)ch] == PDF_CHAR_REGULAR) {
buffer += ch;
stream.read(&ch, 1);
}
std::cerr << "buffer = " << buffer << "\n";
return 0;
}

@ -1,201 +0,0 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.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 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.
*/
#ifndef __PDFOBJECT_H__
#define __PDFOBJECT_H__
#include <string>
#include <vector>
#include <map>
#include <shared_ptr.h>
class ZLInputStream;
class PdfObject {
public:
static shared_ptr<PdfObject> readObject(ZLInputStream &stream, char &ch);
static void readToken(ZLInputStream &stream, std::string &buffer, char &ch);
protected:
static void skipWhiteSpaces(ZLInputStream &stream, char &ch);
public:
enum Type {
BOOLEAN,
INTEGER_NUMBER,
REAL_NUMBER,
STRING,
NAME,
ARRAY,
DICTIONARY,
STREAM,
NIL,
REFERENCE
};
virtual ~PdfObject();
virtual Type type() const = 0;
};
class PdfBooleanObject : public PdfObject {
public:
static shared_ptr<PdfObject> TRUE();
static shared_ptr<PdfObject> FALSE();
private:
PdfBooleanObject(bool value);
public:
bool value() const;
private:
Type type() const;
private:
const bool myValue;
};
class PdfIntegerObject : public PdfObject {
public:
static shared_ptr<PdfObject> integerObject(int value);
private:
PdfIntegerObject(int value);
public:
int value() const;
private:
Type type() const;
private:
const int myValue;
};
class PdfStringObject : public PdfObject {
private:
PdfStringObject(const std::string &value);
private:
Type type() const;
private:
std::string myValue;
friend shared_ptr<PdfObject> PdfObject::readObject(ZLInputStream &stream, char &ch);
};
class PdfNameObject : public PdfObject {
public:
static shared_ptr<PdfObject> nameObject(const std::string &id);
private:
static std::map<std::string,shared_ptr<PdfObject> > ourObjectMap;
private:
PdfNameObject();
private:
Type type() const;
};
class PdfDictionaryObject : public PdfObject {
private:
PdfDictionaryObject();
void setObject(shared_ptr<PdfObject> id, shared_ptr<PdfObject> object);
public:
shared_ptr<PdfObject> operator [] (shared_ptr<PdfObject> id) const;
shared_ptr<PdfObject> operator [] (const std::string &id) const;
private:
Type type() const;
private:
std::map<shared_ptr<PdfObject>,shared_ptr<PdfObject> > myMap;
friend shared_ptr<PdfObject> PdfObject::readObject(ZLInputStream &stream, char &ch);
};
class PdfStreamObject : public PdfObject {
private:
PdfStreamObject(const PdfDictionaryObject &dictionary, ZLInputStream &dataStream);
private:
Type type() const;
private:
std::string myData;
/*
enum EncodingType {
UNKNOWN,
FLATE,
};
std::vector<EncodingType> myFilters;
*/
friend shared_ptr<PdfObject> PdfObject::readObject(ZLInputStream &stream, char &ch);
};
class PdfArrayObject : public PdfObject {
private:
PdfArrayObject();
void addObject(shared_ptr<PdfObject> object);
shared_ptr<PdfObject> popLast();
public:
int size() const;
shared_ptr<PdfObject> operator [] (int index) const;
private:
Type type() const;
private:
std::vector<shared_ptr<PdfObject> > myVector;
friend shared_ptr<PdfObject> PdfObject::readObject(ZLInputStream &stream, char &ch);
};
class PdfObjectReference : public PdfObject {
public:
PdfObjectReference(int number, int generation);
int number() const;
int generation() const;
private:
Type type() const;
private:
const int myNumber;
const int myGeneration;
};
#endif /* __PDFOBJECT_H__ */

@ -1,42 +0,0 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.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 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.
*/
#include <ZLFile.h>
#include <ZLInputStream.h>
#include "PdfPlugin.h"
#include "PdfDescriptionReader.h"
#include "PdfBookReader.h"
#include "../../library/Book.h"
bool PdfPlugin::acceptsFile(const ZLFile &file) const {
return file.extension() == "pdf";
}
bool PdfPlugin::readMetaInfo(Book &book) const {
return PdfDescriptionReader(book).readMetaInfo(ZLFile(path).inputStream());
}
bool PdfPlugin::readLanguageAndEncoding(Book &book) const {
return true;
}
bool PdfPlugin::readModel(BookModel &model) const {
return PdfBookReader(model).readBook(ZLFile(book.fileName()).inputStream());
}

@ -1,41 +0,0 @@
/*
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.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 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.
*/
#ifndef __PdfPLUGIN_H__
#define __PdfPLUGIN_H__
#include "../FormatPlugin.h"
class PdfPlugin : public FormatPlugin {
public:
PdfPlugin();
~PdfPlugin();
bool providesMetaInfo() const;
bool acceptsFile(const ZLFile &file) const;
bool readMetaInfo(Book &book) const;
bool readLanguageAndEncoding(Book &book) const;
bool readModel(BookModel &model) const;
};
inline PdfPlugin::PdfPlugin() {}
inline PdfPlugin::~PdfPlugin() {}
inline bool PdfPlugin::providesMetaInfo() const { return true; }
#endif /* __PdfPLUGIN_H__ */

@ -1,55 +0,0 @@
/*
* Copyright (C) 2008-2012 Geometer Plus <contact@geometerplus.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 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.
*/
#include <algorithm>
#include "StringStream.h"
StringStream::StringStream(const std::string &data) : myData(data), myOffset(0) {
}
bool StringStream::open() {
myOffset = 0;
return true;
}
std::size_t StringStream::read(char *buffer, std::size_t maxSize) {
std::size_t size = std::min(maxSize, myData.length() - myOffset);
memcpy(buffer, myData.data() + myOffset, size);
myOffset += size;
return size;
}
void StringStream::close() {
}
void StringStream::seek(int offset, bool absoluteOffset) {
if (!absoluteOffset) {
offset += myOffset;
}
myOffset = std::min((std::size_t)std::max(0, offset), myData.length());
}
std::size_t StringStream::offset() const {
return myOffset;
}
std::size_t StringStream::sizeOfOpened() {
return myData.length();
}

@ -1,44 +0,0 @@
/*
* Copyright (C) 2008-2012 Geometer Plus <contact@geometerplus.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 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.
*/
#ifndef __STRINGSTREAM_H__
#define __STRINGSTREAM_H__
#include <ZLInputStream.h>
class StringStream : public ZLInputStream {
public:
StringStream(const std::string &data);
public:
bool open();
std::size_t read(char *buffer, std::size_t maxSize);
void close();
void seek(int offset, bool absoluteOffset);
std::size_t offset() const;
std::size_t sizeOfOpened();
private:
const std::string &myData;
std::size_t myOffset;
};
#endif /* __STRINGSTREAM_H__ */

@ -17,6 +17,8 @@
* 02110-1301, USA. * 02110-1301, USA.
*/ */
#include "config.h"
#include "../options/FBCategoryKey.h" #include "../options/FBCategoryKey.h"
#include "Migration.h" #include "Migration.h"

@ -32,7 +32,7 @@
#include "StyleOptionsPage.h" #include "StyleOptionsPage.h"
#include "../../reader/Reader.h" #include "../../reader/Reader.h"
#include "../../reader/FBView.h" #include "../../reader/View.h"
#include "../../options/FBOptions.h" #include "../../options/FBOptions.h"

@ -26,7 +26,7 @@
#include "ReadingOptionsDialog.h" #include "ReadingOptionsDialog.h"
#include "../../reader/Reader.h" #include "../../reader/Reader.h"
#include "../../reader/FBView.h" #include "../../reader/View.h"
#include "../../reader/BookTextView.h" #include "../../reader/BookTextView.h"
class StateOptionEntry : public ZLToggleBooleanOptionEntry { class StateOptionEntry : public ZLToggleBooleanOptionEntry {

@ -26,7 +26,7 @@
#include "ReadingOptionsDialog.h" #include "ReadingOptionsDialog.h"
#include "../../reader/Reader.h" #include "../../reader/Reader.h"
#include "../../reader/FBView.h" #include "../../reader/View.h"
class RotationTypeEntry : public ZLComboOptionEntry { class RotationTypeEntry : public ZLComboOptionEntry {

@ -26,7 +26,7 @@
#include <ZLOptions.h> #include <ZLOptions.h>
#include "FBView.h" #include "View.h"
class Book; class Book;

@ -20,7 +20,7 @@
#ifndef __CONTENTSVIEW_H__ #ifndef __CONTENTSVIEW_H__
#define __CONTENTSVIEW_H__ #define __CONTENTSVIEW_H__
#include "FBView.h" #include "View.h"
class ContentsView : public FBView { class ContentsView : public FBView {

@ -20,7 +20,7 @@
#ifndef __FOOTNOTEVIEW_H__ #ifndef __FOOTNOTEVIEW_H__
#define __FOOTNOTEVIEW_H__ #define __FOOTNOTEVIEW_H__
#include "FBView.h" #include "View.h"
class FootnoteView : public FBView { class FootnoteView : public FBView {

@ -17,6 +17,8 @@
* 02110-1301, USA. * 02110-1301, USA.
*/ */
#include "config.h"
#include <queue> #include <queue>
#include <ZLibrary.h> #include <ZLibrary.h>

@ -25,7 +25,7 @@
#include <ZLTextView.h> #include <ZLTextView.h>
#include "Reader.h" #include "Reader.h"
#include "FBView.h" #include "View.h"
#include "ReaderActions.h" #include "ReaderActions.h"
#include "../options/FBCategoryKey.h" #include "../options/FBCategoryKey.h"

@ -22,7 +22,7 @@
#include <ZLTextStyle.h> #include <ZLTextStyle.h>
#include "FBView.h" #include "View.h"
#include "TimeUpdater.h" #include "TimeUpdater.h"
TimeUpdater::TimeUpdater() : myTime(-1) { TimeUpdater::TimeUpdater() : myTime(-1) {

@ -24,7 +24,7 @@
#include <ZLTimeManager.h> #include <ZLTimeManager.h>
#include <ZLTextSelectionModel.h> #include <ZLTextSelectionModel.h>
#include "FBView.h" #include "View.h"
#include "Reader.h" #include "Reader.h"
#include "ReaderActions.h" #include "ReaderActions.h"
#include "../options/FBOptions.h" #include "../options/FBOptions.h"

@ -20,6 +20,8 @@
#ifndef __ZLZDECOMPRESSOR_H__ #ifndef __ZLZDECOMPRESSOR_H__
#define __ZLZDECOMPRESSOR_H__ #define __ZLZDECOMPRESSOR_H__
#include "core_export.h"
#include <zlib.h> #include <zlib.h>
#include <string> #include <string>

Loading…
Cancel
Save