Commit 0b29b076 authored by Pino Toscano's avatar Pino Toscano
Browse files

Some work on the chm generator:

- correctly find the chm library
- make the chm generator and the kio-msits compile and link
- some qt3/kde3 support less

svn path=/branches/work/kde4/playground/graphics/cmake/; revision=523938
parent c2566649
......@@ -17,11 +17,16 @@ FIND_PATH(CHM_INCLUDE_DIR chm_lib.h
${GNUWIN32_DIR}/include
)
#check_library_exists(chm ??? "" CHM_LIBRARY)
find_library(CHM_LIBRARY NAMES chm
PATHS
/usr/lib
/usr/local/lib
${GNUWIN32_DIR}/lib
)
if(CHM_INCLUDE_DIR)
if(CHM_INCLUDE_DIR AND CHM_LIBRARY)
set(CHM_FOUND TRUE)
endif(CHM_INCLUDE_DIR)
endif(CHM_INCLUDE_DIR AND CHM_LIBRARY)
if (CHM_FOUND)
if (NOT CHM_FIND_QUIETLY)
......
......@@ -3,12 +3,24 @@ kde4_header()
add_subdirectory( lib )
add_subdirectory( kio-msits )
include_directories( ${KDE4_INCLUDE_DIR} ${QT_INCLUDES} )
include_directories( ${KDE4_INCLUDE_DIR} ${QT_INCLUDES} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR}/okular ${CMAKE_BINARY_DIR}/okular ${CHM_INCLUDE_DIR} ${CMAKE_SOURCE_DIR}/okular/generators/chm/lib )
########### next target ###############
set(okularGenerator_chmlib_PART_SRCS generator_t.cpp )
set(chmlib_SRCS
${CMAKE_SOURCE_DIR}/okular/generators/chm/lib/iconstorage.cpp
${CMAKE_SOURCE_DIR}/okular/generators/chm/lib/kchmtextencoding.cpp
${CMAKE_SOURCE_DIR}/okular/generators/chm/lib/kchmtreeviewitem.cpp
${CMAKE_SOURCE_DIR}/okular/generators/chm/lib/kchmurl.cpp
${CMAKE_SOURCE_DIR}/okular/generators/chm/lib/xchmfile.cpp
)
set(okularGenerator_chmlib_SRCS
${CMAKE_SOURCE_DIR}/okular/generators/chm/generator_t.cpp
)
set(okularGenerator_chmlib_PART_SRCS ${chmlib_SRCS} ${okularGenerator_chmlib_SRCS} )
kde4_automoc(${okularGenerator_chmlib_PART_SRCS})
......@@ -16,7 +28,7 @@ kde4_add_plugin(okularGenerator_chmlib WITH_PREFIX ${okularGenerator_chmlib_PART
kde4_install_libtool_file( ${PLUGIN_INSTALL_DIR} okularGenerator_chmlib )
target_link_libraries(okularGenerator_chmlib ${KDE4_KDECORE_LIBS} oKularcore oKularconf chmfile ${KDE4_KDEPRINT_LIBS} ${KDE4_KDEUI_LIBS} ${KDE4_KHTML_LIBS} chm )
target_link_libraries(okularGenerator_chmlib ${KDE4_KDECORE_LIBS} oKularcore ${CHM_LIBRARY} ${KDE4_KDEPRINT_LIBS} ${KDE4_KDEUI_LIBS} ${KDE4_KHTML_LIBS} )
install_targets(${LIB_INSTALL_DIR}/kde4 okularGenerator_chmlib )
......
......@@ -9,7 +9,7 @@
#include "generator_t.h"
#include "lib/xchmfile.h"
#include "conf/settings.h"
#include "settings.h"
#include "core/page.h"
#include "core/link.h"
#include "core/observer.h" //for PAGEVIEW_ID
......@@ -47,7 +47,7 @@ bool TGenerator::loadDocument( const QString & fileName, QVector< KPDFPage * > &
p.setPageSize(static_cast< QPrinter::PageSize >( KGlobal::locale()->pageSize() ));
p.setFullPage(true);
kdDebug () << "UrlPage count " << m_file->m_UrlPage.count() << endl;
kDebug () << "UrlPage count " << m_file->m_UrlPage.count() << endl;
pagesVector.resize(m_file->m_UrlPage.count());
if (!m_syncGen)
......@@ -63,7 +63,7 @@ bool TGenerator::loadDocument( const QString & fileName, QVector< KPDFPage * > &
int i= it.data() - 1;
pagesVector[ i ] = new KPDFPage (i, m_syncGen->view()->contentsWidth(),
m_syncGen->view()->contentsHeight(),0);
kdDebug() << "W/H: " << m_syncGen->view()->contentsWidth() << "/" << m_syncGen->view()->contentsHeight() << endl;
kDebug() << "W/H: " << m_syncGen->view()->contentsWidth() << "/" << m_syncGen->view()->contentsHeight() << endl;
}
return true;
}
......@@ -72,7 +72,7 @@ void TGenerator::preparePageForSyncOperation( int zoom , const QString & url)
{
KUrl pAddress= "ms-its:" + m_fileName + "::" + url;
m_state=0;
kdDebug() << "Url: " << pAddress << endl;
kDebug() << "Url: " << pAddress << endl;
m_syncGen->setZoomFactor(zoom);
m_doneFlagSet=false;
m_syncGen->openURL(pAddress);
......@@ -82,14 +82,14 @@ void TGenerator::preparePageForSyncOperation( int zoom , const QString & url)
void TGenerator::slotCompleted()
{
kdDebug() << "completed() " << m_state << endl;
kDebug() << "completed() " << m_state << endl;
if (m_state==0)
{
m_doneFlagSet=true;
}
else if (m_state==1)
{
// kdDebug() << "completed(1) " << m_request->id << endl;
// kDebug() << "completed(1) " << m_request->id << endl;
QPixmap* pix=new QPixmap (m_request->width,m_request->height);
pix->fill();
QPainter p (pix);
......@@ -128,7 +128,7 @@ bool TGenerator::canGeneratePixmap ( bool /*async*/ )
{
/* if (async)
{
kdDebug() << "async is locked " << asyncLock.locked() << endl;
kDebug() << "async is locked " << asyncLock.locked() << endl;
return !asyncLock.locked();
}*/
return !syncLock.locked();
......@@ -139,7 +139,7 @@ void TGenerator::generatePixmap( PixmapRequest * request )
QString a="S";
if (request->async) a="As";
kdDebug() << a << "ync PixmapRequest of " << request->width << "x"
kDebug() << a << "ync PixmapRequest of " << request->width << "x"
<< request->height << " size, pageNo " << request->pageNumber
<< ", priority: " << request->priority << " id: " << request->id
<< endl;
......@@ -151,7 +151,7 @@ void TGenerator::generatePixmap( PixmapRequest * request )
) * 100;
KUrl pAddress= "ms-its:" + m_fileName + "::" + url;
kdDebug() << "Page asked is: " << pAddress << " zoom is " << zoom << endl;
kDebug() << "Page asked is: " << pAddress << " zoom is " << zoom << endl;
m_syncGen->setZoomFactor(zoom);
m_syncGen->view()->resize(request->width,request->height);
m_request=request;
......@@ -179,9 +179,9 @@ void TGenerator::recursiveExploreNodes(DOM::Node node,KPDFTextPage *tp)
{
nodeNormRect=new NormalizedRect (r,vWidth,vHeight);
tp->append(nodeText,nodeNormRect,nodeNormRect->bottom,0,(nodeText=="\n"));
kdDebug() << "Norm Rect is [" << nodeNormRect->left << "x" << nodeNormRect->top
kDebug() << "Norm Rect is [" << nodeNormRect->left << "x" << nodeNormRect->top
<< "] [" << nodeNormRect->right << "x" << nodeNormRect->bottom << "]" << endl;
kdDebug() << "Node Dom text(" << nodeText.length() << "): " << nodeText << endl;
kDebug() << "Node Dom text(" << nodeText.length() << "): " << nodeText << endl;
}
else
{
......@@ -193,28 +193,28 @@ void TGenerator::recursiveExploreNodes(DOM::Node node,KPDFTextPage *tp)
{
// if (nodeType[i+1]
node.getCursor(i+1,x_next,y_next,height_next);
kdDebug() << "DL/L/R " << r.left() << "/" << x << "/" << x_next << endl;
kDebug() << "DL/L/R " << r.left() << "/" << x << "/" << x_next << endl;
nodeNormRect=new NormalizedRect (QRect(x,y,x_next-x-1,height),vWidth,vHeight);
}
else if ( i <nodeTextLength -1 )
// i is between zero and the last element
{
node.getCursor(i+1,x_next,y_next,height_next);
kdDebug() << "L/R" << x << "/" << x_next << endl;
kDebug() << "L/R" << x << "/" << x_next << endl;
nodeNormRect=new NormalizedRect (QRect(x,y,x_next-x-1,height),vWidth,vHeight);
}
else
// the last element use right rect boundary
{
node.getCursor(i-1,x_next,y_next,height_next);
kdDebug() << "L/R" << x_next << "/" << r.right() << endl;
kDebug() << "L/R" << x_next << "/" << r.right() << endl;
nodeNormRect=new NormalizedRect (QRect(x,y,r.right()-x-1,height),vWidth,vHeight);
}
tp->append(QString(nodeText[i]),nodeNormRect,nodeNormRect->bottom,0,(nodeText[i]=='\n'));
kdDebug () << "Working with offset : " << i << endl;
kdDebug() << "Norm Rect is [" << nodeNormRect->left << "x" << nodeNormRect->top
kDebug () << "Working with offset : " << i << endl;
kDebug() << "Norm Rect is [" << nodeNormRect->left << "x" << nodeNormRect->top
<< "] [" << nodeNormRect->right << "x" << nodeNormRect->bottom << "]" << endl;
kdDebug() << "Node Dom text(1): " << nodeText[i] << endl;
kDebug() << "Node Dom text(1): " << nodeText[i] << endl;
}
}
#else
......@@ -243,7 +243,7 @@ void TGenerator::additionalRequestData()
// only generate object info when generating a full page not a thumbnail
if ( genObjectRects )
{
kdDebug() << "Generating ObjRects - start" << endl;
kDebug() << "Generating ObjRects - start" << endl;
QLinkedList< ObjectRect * > objRects;
int xScale=m_request->width;
int yScale=m_request->height;
......@@ -262,7 +262,7 @@ void TGenerator::additionalRequestData()
QString url = n.attributes().getNamedItem("href").nodeValue().string();
DocumentViewport viewport(getMetaData( url, QString::number(page->number() - 1) ));
r=n.getRect();
kdDebug() << "Adding rect: " << url << " " << r << endl;
kDebug() << "Adding rect: " << url << " " << r << endl;
// there is no way for us to support javascript properly
if (url.startsWith("JavaScript:"))
continue;
......@@ -306,7 +306,7 @@ void TGenerator::additionalRequestData()
if ( genTextPage )
{
kdDebug() << "Generating text page - start" << endl;
kDebug() << "Generating text page - start" << endl;
KPDFTextPage *tp=new KPDFTextPage();
recursiveExploreNodes(domDoc,tp);
page->setSearchPage (tp);
......@@ -406,7 +406,7 @@ bool TGenerator::handleEvent (QEvent * /*event*/ )
/*
void PixmapThreader::run()
{
kdDebug() << "starting thread\n";
kDebug() << "starting thread\n";
m_pix = m_gen->renderPixmap(m_req);
QCustomEvent * readyEvent = new QCustomEvent( CHM_DATAREADY_ID );
readyEvent->setData(m_req);
......@@ -419,7 +419,7 @@ void TGenerator::customEvent( QCustomEvent * e )
{
PixmapRequest* request=(PixmapRequest*) e->data();
asyncLock.unlock();
kdDebug() << "got pixmap\n";
kDebug() << "got pixmap\n";
request->page->setPixmap( request->id, px->takePixmap() );
signalRequestDone( request );
}
......
kde4_header()
include_directories( ${KDE4_INCLUDE_DIR} ${QT_INCLUDES} )
include_directories( ${KDE4_INCLUDE_DIR} ${QT_INCLUDES} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR}/okular ${CHM_INCLUDE_DIR} )
########### next target ###############
......@@ -13,7 +13,7 @@ kde4_add_plugin(kio_msits ${kio_msits_PART_SRCS})
kde4_install_libtool_file( ${PLUGIN_INSTALL_DIR} kio_msits )
target_link_libraries(kio_msits ${KDE4_KDECORE_LIBS} ${KDE4_KIO_LIBS} chm )
target_link_libraries(kio_msits ${KDE4_KDECORE_LIBS} ${KDE4_KIO_LIBS} ${CHM_LIBRARY} )
install_targets(${LIB_INSTALL_DIR}/kde4 kio_msits )
......
......@@ -37,20 +37,20 @@ extern "C"
{
int kdemain( int argc, char **argv )
{
kdDebug() << "*** kio_msits Init" << endl;
kDebug() << "*** kio_msits Init" << endl;
KInstance instance( "kio_msits" );
if ( argc != 4 )
{
kdDebug() << "Usage: kio_msits protocol domain-socket1 domain-socket2" << endl;
kDebug() << "Usage: kio_msits protocol domain-socket1 domain-socket2" << endl;
exit (-1);
}
ProtocolMSITS slave ( argv[2], argv[3] );
slave.dispatchLoop();
kdDebug() << "*** kio_msits Done" << endl;
kDebug() << "*** kio_msits Done" << endl;
return 0;
}
}
......@@ -82,12 +82,12 @@ void ProtocolMSITS::get( const KUrl& url )
QString fileName;
chmUnitInfo ui;
kdDebug() << "kio_msits::get() " << url.path() << endl;
kDebug() << "kio_msits::get() " << url.path() << endl;
if ( !parseLoadAndLookup ( url, fileName ) )
return; // error() has been called by parseLoadAndLookup
kdDebug() << "kio_msits::get: parseLoadAndLookup returned " << fileName << endl;
kDebug() << "kio_msits::get: parseLoadAndLookup returned " << fileName << endl;
if ( isDirectory (fileName) )
{
......@@ -97,7 +97,7 @@ void ProtocolMSITS::get( const KUrl& url )
if ( !ResolveObject ( fileName, &ui) )
{
kdDebug() << "kio_msits::get: could not resolve filename " << fileName << endl;
kDebug() << "kio_msits::get: could not resolve filename " << fileName << endl;
error( KIO::ERR_DOES_NOT_EXIST, url.prettyURL() );
return;
}
......@@ -106,14 +106,14 @@ void ProtocolMSITS::get( const KUrl& url )
if ( RetrieveObject (&ui, (unsigned char*) buf.data(), 0, ui.length) == 0 )
{
kdDebug() << "kio_msits::get: could not retrieve filename " << fileName << endl;
kDebug() << "kio_msits::get: could not retrieve filename " << fileName << endl;
error( KIO::ERR_NO_CONTENT, url.prettyURL() );
return;
}
totalSize( ui.length );
KMimeMagicResult * result = KMimeMagic::self()->findBufferFileType( buf, fileName );
kdDebug() << "Emitting mimetype " << result->mimeType() << endl;
kDebug() << "Emitting mimetype " << result->mimeType() << endl;
mimeType( result->mimeType() );
data( buf );
......@@ -125,7 +125,7 @@ void ProtocolMSITS::get( const KUrl& url )
bool ProtocolMSITS::parseLoadAndLookup ( const KUrl& url, QString& abspath )
{
kdDebug() << "ProtocolMSITS::parseLoadAndLookup (const KUrl&) " << url.path() << endl;
kDebug() << "ProtocolMSITS::parseLoadAndLookup (const KUrl&) " << url.path() << endl;
int pos = url.path().find ("::");
......@@ -138,7 +138,7 @@ bool ProtocolMSITS::parseLoadAndLookup ( const KUrl& url, QString& abspath )
QString filename = url.path().left (pos);
abspath = url.path().mid (pos + 2); // skip ::
kdDebug() << "ProtocolMSITS::parseLoadAndLookup: filename " << filename << ", path " << abspath << endl;
kDebug() << "ProtocolMSITS::parseLoadAndLookup: filename " << filename << ", path " << abspath << endl;
if ( filename.isEmpty() )
{
......@@ -150,7 +150,7 @@ bool ProtocolMSITS::parseLoadAndLookup ( const KUrl& url, QString& abspath )
if ( m_chmFile && filename == m_openedFile )
return true;
kdDebug() << "Opening a new CHM file " << filename << endl;
kDebug() << "Opening a new CHM file " << filename << endl;
// First try to open a temporary file
chmFile * tmpchm;
......@@ -168,7 +168,7 @@ bool ProtocolMSITS::parseLoadAndLookup ( const KUrl& url, QString& abspath )
m_chmFile = tmpchm;
m_openedFile = filename;
kdDebug() << "A CHM file " << filename << " has beed opened successfully" << endl;
kDebug() << "A CHM file " << filename << " has beed opened successfully" << endl;
return true;
}
......@@ -211,7 +211,7 @@ void ProtocolMSITS::stat (const KUrl & url)
QString fileName;
chmUnitInfo ui;
kdDebug() << "kio_msits::stat (const KUrl& url) " << url.path() << endl;
kDebug() << "kio_msits::stat (const KUrl& url) " << url.path() << endl;
if ( !parseLoadAndLookup ( url, fileName ) )
return; // error() has been called by parseLoadAndLookup
......@@ -222,7 +222,7 @@ void ProtocolMSITS::stat (const KUrl & url)
return;
}
kdDebug() << "kio_msits::stat: adding an entry for " << fileName << endl;
kDebug() << "kio_msits::stat: adding an entry for " << fileName << endl;
UDSEntry entry;
if ( isDirectory ( fileName ) )
......@@ -248,7 +248,7 @@ void ProtocolMSITS::listDir (const KUrl & url)
{
QString filepath;
kdDebug() << "kio_msits::listDir (const KUrl& url) " << url.path() << endl;
kDebug() << "kio_msits::listDir (const KUrl& url) " << url.path() << endl;
if ( !parseLoadAndLookup ( url, filepath ) )
return; // error() has been called by parseLoadAndLookup
......@@ -261,7 +261,7 @@ void ProtocolMSITS::listDir (const KUrl & url)
return;
}
kdDebug() << "kio_msits::listDir: enumerating directory " << filepath << endl;
kDebug() << "kio_msits::listDir: enumerating directory " << filepath << endl;
QVector<QString> listing;
......
......@@ -11,7 +11,7 @@ namespace KCHMUrl
if ( uriregex.search ( url ) != -1 )
{
QString proto = uriregex.cap ( 1 ).lower();
QString proto = uriregex.cap ( 1 ).toLower();
// Filter the URLs which need to be opened by a browser
if ( proto == "http"
......
......@@ -378,9 +378,9 @@ bool CHMFile::ParseHhcAndFillTree (const QString& file, QDomDocument *tree, bool
QString tagword, tag = src.mid (pos, i - pos);
if ( word_end )
tagword = src.mid (pos, word_end - pos).lower();
tagword = src.mid (pos, word_end - pos).toLower();
else
tagword = tag.lower();
tagword = tag.toLower();
// qDebug ("tag: '%s', tagword: '%s'\n", tag.ascii(), tagword.ascii());
......@@ -459,7 +459,7 @@ bool CHMFile::ParseHhcAndFillTree (const QString& file, QDomDocument *tree, bool
// offset+5 skips 'name='
offset = findStringInQuotes (tag, offset + name_pattern.length(), pname, TRUE, FALSE);
pname = pname.lower();
pname = pname.toLower();
if ( (offset = tag.find (value_pattern, offset, FALSE)) == -1 )
qFatal ("CHMFile::ParseAndFillTopicsTree: bad <param> tag '%s': no value=\n", tag.ascii());
......@@ -565,9 +565,9 @@ bool CHMFile::ParseHhcAndFillTree (const QString& file, K3ListView *tree, bool a
QString tagword, tag = src.mid (pos, i - pos);
if ( word_end )
tagword = src.mid (pos, word_end - pos).lower();
tagword = src.mid (pos, word_end - pos).toLower();
else
tagword = tag.lower();
tagword = tag.toLower();
//qDebug ("tag: '%s', tagword: '%s'\n", tag.ascii(), tagword.ascii());
......@@ -635,7 +635,7 @@ bool CHMFile::ParseHhcAndFillTree (const QString& file, K3ListView *tree, bool a
// offset+5 skips 'name='
offset = findStringInQuotes (tag, offset + name_pattern.length(), pname, TRUE, FALSE);
pname = pname.lower();
pname = pname.toLower();
if ( (offset = tag.find (value_pattern, offset, FALSE)) == -1 )
qFatal ("CHMFile::ParseAndFillTopicsTree: bad <param> tag '%s': no value=\n", tag.ascii());
......@@ -1327,7 +1327,7 @@ Q3CString CHMFile::convertSearchWord( const QString & src )
};
if ( !m_textCodec )
return (Q3CString) src.lower().toLocal8Bit();
return (Q3CString) src.toLower().toLocal8Bit();
Q3CString dest = m_textCodec->fromUnicode (src);
......@@ -1343,7 +1343,7 @@ Q3CString CHMFile::convertSearchWord( const QString & src )
}
}
return dest.lower();
return dest.toLower();
}
......@@ -1484,9 +1484,9 @@ bool CHMFile::ParseChmIndexFile ( const QString& file, bool asIndex, KCHMParsedI
QString tagword, tag = src.mid (pos, i - pos);
if ( word_end )
tagword = src.mid (pos, word_end - pos).lower();
tagword = src.mid (pos, word_end - pos).toLower();
else
tagword = tag.lower();
tagword = tag.toLower();
//qDebug ("tag: '%s', tagword: '%s'\n", tag.ascii(), tagword.ascii());
......@@ -1549,7 +1549,7 @@ bool CHMFile::ParseChmIndexFile ( const QString& file, bool asIndex, KCHMParsedI
// offset+5 skips 'name='
offset = findStringInQuotes (tag, offset + name_pattern.length(), pname, TRUE, FALSE);
pname = pname.lower();
pname = pname.toLower();
if ( (offset = tag.find (value_pattern, offset, FALSE)) == -1 )
qFatal ("CHMFile::ParseAndFillTopicsTree: bad <param> tag '%s': no value=\n", tag.ascii());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment