mirror of
https://invent.kde.org/graphics/okular
synced 2024-08-25 10:55:37 +00:00
- Do not reattach the dcop client
- Keep the original url on the document so we can open relative file names - Add Enrico and my copyright svn path=/trunk/kdegraphics/kpdf/; revision=386244
This commit is contained in:
parent
519892521f
commit
bc1806e218
|
@ -43,6 +43,10 @@ class KPDFDocumentPrivate
|
|||
// find descriptors, mapped by ID (we handle multiple searches)
|
||||
QMap< int, RunningSearch * > searches;
|
||||
|
||||
// needed because for remote documents docFileName is a local file and
|
||||
// we want the remote url when the document refers to relativeNames
|
||||
KURL url;
|
||||
|
||||
// cached stuff
|
||||
QString docFileName;
|
||||
QString xmlFileName;
|
||||
|
@ -50,6 +54,7 @@ class KPDFDocumentPrivate
|
|||
// viewport stuff
|
||||
QValueList< DocumentViewport > viewportHistory;
|
||||
QValueList< DocumentViewport >::iterator viewportIterator;
|
||||
DocumentViewport nextDocumentViewport; // see KPDFLink::Goto for an explanation
|
||||
|
||||
// observers / requests / allocator stuff
|
||||
QMap< int, DocumentObserver * > observers;
|
||||
|
@ -113,7 +118,7 @@ KPDFDocument::~KPDFDocument()
|
|||
}
|
||||
|
||||
|
||||
bool KPDFDocument::openDocument( const QString & docFile )
|
||||
bool KPDFDocument::openDocument( const QString & docFile, const KURL & url )
|
||||
{
|
||||
// docFile is always local so we can use QFile on it
|
||||
QFile fileReadTest( docFile );
|
||||
|
@ -123,6 +128,7 @@ bool KPDFDocument::openDocument( const QString & docFile )
|
|||
return false;
|
||||
}
|
||||
// determine the related "xml document-info" filename
|
||||
d->url = url;
|
||||
d->docFileName = docFile;
|
||||
QString fn = docFile.contains('/') ? docFile.section('/', -1, -1) : docFile;
|
||||
fn = "kpdf/" + QString::number(fileReadTest.size()) + "." + fn + ".xml";
|
||||
|
@ -183,6 +189,12 @@ bool KPDFDocument::openDocument( const QString & docFile )
|
|||
}
|
||||
d->memCheckTimer->start( 2000 );
|
||||
|
||||
if (d->nextDocumentViewport.pageNumber != -1)
|
||||
{
|
||||
setViewport(d->nextDocumentViewport);
|
||||
d->nextDocumentViewport = DocumentViewport();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -803,7 +815,15 @@ void KPDFDocument::processLink( const KPDFLink * link )
|
|||
{
|
||||
case KPDFLink::Goto: {
|
||||
const KPDFLinkGoto * go = static_cast< const KPDFLinkGoto * >( link );
|
||||
DocumentViewport destVp = go->destViewport();
|
||||
d->nextDocumentViewport = go->destViewport();
|
||||
|
||||
// Explanation of why d->nextDocumentViewport is needed
|
||||
// all openRelativeFile does is launch a signal telling we
|
||||
// want to open another URL, the problem is that when the file is
|
||||
// non local, the loading is done assynchronously so you can't
|
||||
// do a setViewport after the if as it was because you are doing the setViewport
|
||||
// on the old file and when the new arrives there is no setViewport for it and
|
||||
// it does not show anything
|
||||
|
||||
// first open filename if link is pointing outside this document
|
||||
if ( go->isExternal() && !openRelativeFile( go->fileName() ) )
|
||||
|
@ -812,8 +832,6 @@ void KPDFDocument::processLink( const KPDFLink * link )
|
|||
return;
|
||||
}
|
||||
|
||||
// note: if external file is opened, 'link' doesn't exist anymore!
|
||||
setViewport( destVp );
|
||||
} break;
|
||||
|
||||
case KPDFLink::Execute: {
|
||||
|
@ -1197,12 +1215,10 @@ void KPDFDocument::loadDocumentInfo()
|
|||
|
||||
QString KPDFDocument::giveAbsolutePath( const QString & fileName )
|
||||
{
|
||||
if ( d->docFileName.isEmpty() )
|
||||
if ( !d->url.isValid() )
|
||||
return QString::null;
|
||||
|
||||
// convert the pdf fileName to absolute using current pdf path
|
||||
QFileInfo currentInfo( d->docFileName );
|
||||
return currentInfo.dir().absFilePath( fileName );
|
||||
|
||||
return d->url.upURL().url() + fileName;
|
||||
}
|
||||
|
||||
bool KPDFDocument::openRelativeFile( const QString & fileName )
|
||||
|
@ -1213,8 +1229,8 @@ bool KPDFDocument::openRelativeFile( const QString & fileName )
|
|||
|
||||
kdDebug() << "openDocument: '" << absFileName << "'" << endl;
|
||||
|
||||
// open the absolute filename
|
||||
return openDocument( absFileName );
|
||||
emit openURL( absFileName );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ class DocumentSynopsis;
|
|||
class Generator;
|
||||
class PixmapRequest;
|
||||
class KPrinter;
|
||||
class KURL;
|
||||
|
||||
/**
|
||||
* @short The Document. Heart of everything. Actions take place here.
|
||||
|
@ -51,7 +52,7 @@ class KPDFDocument : public QObject
|
|||
~KPDFDocument();
|
||||
|
||||
// document handling
|
||||
bool openDocument( const QString & docFile );
|
||||
bool openDocument( const QString & docFile, const KURL & url );
|
||||
void closeDocument();
|
||||
|
||||
// misc methods
|
||||
|
@ -96,6 +97,7 @@ class KPDFDocument : public QObject
|
|||
signals:
|
||||
void linkFind();
|
||||
void linkGoToPage();
|
||||
void openURL(const KURL &url);
|
||||
|
||||
private:
|
||||
void sendGeneratorRequest();
|
||||
|
|
8
part.cpp
8
part.cpp
|
@ -101,6 +101,7 @@ Part::Part(QWidget *parentWidget, const char *widgetName,
|
|||
m_document = new KPDFDocument();
|
||||
connect( m_document, SIGNAL( linkFind() ), this, SLOT( slotFind() ) );
|
||||
connect( m_document, SIGNAL( linkGoToPage() ), this, SLOT( slotGoToPage() ) );
|
||||
connect( m_document, SIGNAL( openURL(const KURL &) ), this, SLOT( openURL(const KURL &) ) );
|
||||
|
||||
// widgets: ^searchbar (toolbar containing label and SearchWidget)
|
||||
// m_searchToolBar = new KToolBar( parentWidget, "searchBar" );
|
||||
|
@ -252,7 +253,10 @@ Part::Part(QWidget *parentWidget, const char *widgetName,
|
|||
// [SPEECH] check for KTTSD presence and usability
|
||||
Settings::setUseKTTSD( true );
|
||||
DCOPClient * client = DCOPClient::mainClient();
|
||||
client->attach();
|
||||
// Albert says is this ever necessary?
|
||||
// we already attached on Part constructor
|
||||
if ( !client->isAttached() )
|
||||
client->attach();
|
||||
if ( !client->isApplicationRegistered("kttsd") )
|
||||
if ( KApplication::startServiceByName( "KTTSD" ) )
|
||||
Settings::setUseKTTSD( false );
|
||||
|
@ -316,7 +320,7 @@ KAboutData* Part::createAboutData()
|
|||
|
||||
bool Part::openFile()
|
||||
{
|
||||
bool ok = m_document->openDocument( m_file );
|
||||
bool ok = m_document->openDocument( m_file, url() );
|
||||
|
||||
// update one-time actions
|
||||
m_find->setEnabled( ok );
|
||||
|
|
|
@ -37,7 +37,7 @@ int main(int argc, char** argv)
|
|||
version,
|
||||
description,
|
||||
KAboutData::License_GPL,
|
||||
"(C) 2002 Wilco Greven, Christophe Devriese");
|
||||
"(C) 2002 Wilco Greven, Christophe Devriese\n(C) 2004-2005 Albert Astals Cid, Enrico Ros");
|
||||
|
||||
about.addAuthor("Wilco Greven", 0, "greven@kde.org");
|
||||
about.addAuthor("Christophe Devriese", 0, "oelewapperke@oelewapperke.org");
|
||||
|
|
|
@ -1039,6 +1039,8 @@ void PageView::contentsMouseReleaseEvent( QMouseEvent * e )
|
|||
{
|
||||
// [2] speech selection using KTTSD
|
||||
DCOPClient * client = DCOPClient::mainClient();
|
||||
// Albert says is this ever necessary?
|
||||
// we already attached on Part constructor
|
||||
if ( !client->isAttached() )
|
||||
client->attach();
|
||||
// serialize the text to speech (selectedText) and the
|
||||
|
|
Loading…
Reference in a new issue