Make kpdf aware of the /PageMode/FullScreen tag in PDF files, so it starts

in presentation mode when the flag is available.

svn path=/branches/kpdf_experiments/kdegraphics/kpdf/; revision=374668
This commit is contained in:
Tobias Koenig 2005-01-01 15:44:44 +00:00
parent 6a3c3d6c97
commit d67d3d16b0
8 changed files with 59 additions and 5 deletions

View file

@ -240,6 +240,10 @@ bool KPDFDocument::okToPrint() const
return generator ? generator->allowed( Generator::Print ) : false;
}
QString KPDFDocument::getMetaData( const QString &key ) const
{
return generator ? generator->getMetaData( key ) : QString();
}
void KPDFDocument::requestPixmaps( const QValueList< PixmapRequest * > & requests, bool async )
{

View file

@ -93,6 +93,7 @@ class KPDFDocument : public QObject // only for a private slot..
uint currentPage() const;
uint pages() const;
bool okToPrint() const;
QString getMetaData( const QString &key ) const;
// perform actions on document / pages
void requestPixmaps( const QValueList< PixmapRequest * > & requests, bool asyncronous );

View file

@ -65,6 +65,9 @@ class Generator : public QObject
// check configuration and return true if something changed
virtual bool reparseConfig() { return false; }
// Access meta data of the generator
virtual QString getMetaData( const QString &key ) const { return QString(); }
signals:
void contentsChanged( int id, int pageNumber );
};

View file

@ -374,6 +374,16 @@ bool PDFGenerator::reparseConfig()
return false;
}
QString PDFGenerator::getMetaData( const QString &key ) const
{
if ( key == "StartFullScreen" ) {
if ( pdfdoc->getCatalog()->getPageMode() == Catalog::FullScreen )
return "yes";
}
return QString();
}
KPDFLinkGoto::Viewport PDFGenerator::decodeLinkViewport( GString * namedDest, LinkDest * dest )
// note: this function is called when processing a page, when the MUTEX is already LOCKED
{

View file

@ -61,6 +61,8 @@ class PDFGenerator : public Generator
// [INHERITED] reparse configuration
bool reparseConfig();
QString getMetaData( const QString &key ) const;
// used by the KPDFOutputDev child
KPDFLinkGoto::Viewport decodeLinkViewport( class GString * namedDest, class LinkDest * dest );

View file

@ -253,12 +253,16 @@ KAboutData* Part::createAboutData()
bool Part::openFile()
{
bool ok = m_document->openDocument( m_file );
if ( ok && !m_watcher->contains(m_file)) m_watcher->addFile(m_file);
m_find->setEnabled( ok );
m_showProperties->setEnabled( ok );
bool ok = m_document->openDocument( m_file );
if ( ok && !m_watcher->contains(m_file)) m_watcher->addFile(m_file);
m_find->setEnabled( ok );
m_showProperties->setEnabled( ok );
m_showPresentation->setEnabled( ok );
return ok;
if ( ok && m_document->getMetaData( "StartFullScreen" ) == "yes" )
slotShowPresentation();
return ok;
}
bool Part::openURL(const KURL &url)

View file

@ -40,6 +40,7 @@ Catalog::Catalog(XRef *xrefA) {
pageRefs = NULL;
numPages = pagesSize = 0;
baseURI = NULL;
pageMode = UseNone;
xref->getCatalog(&catDict);
if (!catDict.isDict()) {
@ -105,6 +106,23 @@ Catalog::Catalog(XRef *xrefA) {
}
obj.free();
// read page mode
if (catDict.dictLookup("PageMode", &obj)->isName()) {
if (strcmp(obj.getName(), "UseNone") == 0)
pageMode = UseNone;
else if (strcmp(obj.getName(), "UseOutlines") == 0)
pageMode = UseOutlines;
else if (strcmp(obj.getName(), "UseThumbs") == 0)
pageMode = UseThumbs;
else if (strcmp(obj.getName(), "FullScreen") == 0)
pageMode = FullScreen;
else if (strcmp(obj.getName(), "UseOC") == 0)
pageMode = UseOC;
} else {
pageMode = UseNone;
}
obj.free();
// get the metadata stream
catDict.dictLookup("Metadata", &metadata);

View file

@ -29,6 +29,14 @@ class LinkDest;
class Catalog {
public:
enum PageMode {
UseNone,
UseOutlines,
UseThumbs,
FullScreen,
UseOC
};
// Constructor.
Catalog(XRef *xrefA);
@ -50,6 +58,9 @@ public:
// Return base URI, or NULL if none.
GString *getBaseURI() { return baseURI; }
// Returns the page mode.
PageMode getPageMode() { return pageMode; }
// Return the contents of the metadata stream, or NULL if there is
// no metadata.
GString *readMetadata();
@ -77,6 +88,7 @@ private:
Object dests; // named destination dictionary
Object nameTree; // name tree
GString *baseURI; // base URI for URI-type links
PageMode pageMode; // page mode
Object metadata; // metadata stream
Object structTreeRoot; // structure tree root dictionary
Object outline; // outline dictionary