I've finally gotten around to updating my earlier patch to provide KWallet 
support. See attached.
The encryption support adds an optional dependency on QCA2 - if that isn't 
found at compile time, you should get the old behaviour.

KWallet passwords should be interoperable with KWord.

I'm reasonably happy with this now, although there are a couple of issues I 
still want to resolve:
* I can't find an appropriate parent widget for some of the GUI operations 
that I need to do - it seems the TextDocumentConvertor doesn't expose one.
* There is an intermittent problem where okular sometimes won't load an 
encrypted document as the first document after start.

Naturally, the second problem is driving me insane. Only happens on one 
document that I have - okular looks like it is just hung loading. Works if I 
reload the same document. Works if I load something else first.

Feedback appreciated.

Brad

Index: manifest.cpp
===================================================================
--- manifest.cpp	(revision 0)
+++ manifest.cpp	(revision 0)
@@ -0,0 +1,408 @@
+/***************************************************************************
+ *   Copyright (C) 2007 by Brad Hards <[EMAIL PROTECTED]>                *
+ *                                                                         *
+ *   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.                                   *
+ ***************************************************************************/
+
+#include "manifest.h"
+#include "debug.h"
+
+#include <QBuffer>
+#include <QXmlStreamReader>
+
+#include <KFilterDev>
+#include <KLocale>
+#include <KMessageBox>
+#include <KPasswordDialog>
+#include <KWallet/Wallet>
+
+using namespace OOO;
+
+//---------------------------------------------------------------------
+
+ManifestEntry::ManifestEntry( const QString &fileName ) :
+  m_fileName( fileName )
+{
+}
+
+void ManifestEntry::setMimeType( const QString &mimeType )
+{
+  m_mimeType = mimeType;
+}
+
+void ManifestEntry::setSize( const QString &size )
+{
+  m_size = size;
+}
+
+const QString ManifestEntry::fileName()
+{
+  return m_fileName;
+}
+
+const QString ManifestEntry::mimeType()
+{
+  return m_mimeType;
+}
+
+const QString ManifestEntry::size()
+{
+  return m_size;
+}
+
+void ManifestEntry::setChecksumType( const QString &checksumType )
+{
+  m_checksumType = checksumType;
+}
+
+const QString ManifestEntry::checksumType()
+{
+  return m_checksumType;
+}
+
+void ManifestEntry::setChecksum( const QString &checksum )
+{
+  m_checksum = QByteArray::fromBase64( checksum.toAscii() );
+}
+
+const QByteArray ManifestEntry::checksum()
+{
+  return m_checksum;
+}
+
+void ManifestEntry::setAlgorithm( const QString &algorithm )
+{
+  m_algorithm = algorithm;
+}
+
+const QString ManifestEntry::algorithm()
+{
+  return m_algorithm;
+}
+
+void ManifestEntry::setInitialisationVector( const QString &initialisationVector )
+{
+  m_initialisationVector = QByteArray::fromBase64( initialisationVector.toAscii() );
+}
+
+const QByteArray ManifestEntry::initialisationVector()
+{
+  return m_initialisationVector;
+}
+
+void ManifestEntry::setKeyDerivationName( const QString &keyDerivationName )
+{
+  m_keyDerivationName = keyDerivationName;
+}
+
+const QString ManifestEntry::keyDerivationName()
+{
+  return m_keyDerivationName;
+}
+
+void ManifestEntry::setIterationCount( const QString &iterationCount )
+{
+  m_iterationCount = iterationCount.toInt();
+}
+
+int ManifestEntry::iterationCount()
+{
+  return m_iterationCount;
+}
+
+void ManifestEntry::setSalt( const QString &salt )
+{
+  m_salt = QByteArray::fromBase64( salt.toAscii() );
+}
+
+const QByteArray ManifestEntry::salt()
+{
+  return m_salt;
+}
+
+//---------------------------------------------------------------------
+
+Manifest::Manifest( const QString &odfFileName, const QByteArray &manifestData )
+  : m_odfFileName( odfFileName ), m_haveGoodPassword( false ), m_userCancelled( false )
+{
+  // I don't know why the parser barfs on this.
+  QByteArray manifestCopy = manifestData;
+  manifestCopy.replace(QByteArray("DOCTYPE manifest:manifest"), QByteArray("DOCTYPE manifest"));
+
+  QXmlStreamReader xml( manifestCopy );
+
+  ManifestEntry *currentEntry = 0;
+  while ( ! xml.atEnd() ) {
+    xml.readNext();
+    if ( (xml.tokenType() == QXmlStreamReader::NoToken) ||
+	 (xml.tokenType() == QXmlStreamReader::Invalid) ||
+	 (xml.tokenType() == QXmlStreamReader::StartDocument) ||
+	 (xml.tokenType() == QXmlStreamReader::EndDocument) ||
+	 (xml.tokenType() == QXmlStreamReader::DTD) || 
+	 (xml.tokenType() == QXmlStreamReader::Characters) ) {
+      continue;
+    }
+    if (xml.tokenType() == QXmlStreamReader::StartElement) {
+      if ( xml.name().toString() == "manifest" ) {
+	continue;
+      } else if ( xml.name().toString() == "file-entry" ) {
+	QXmlStreamAttributes attributes = xml.attributes();
+	if (currentEntry != 0) {
+	  kWarning(OooDebug) << "Got new StartElement for new file-entry, but haven't finished the last one yet!";
+	  kWarning(OooDebug) << "processing" << currentEntry->fileName() << ", got" << attributes.value("manifest:full-path").toString();
+	}
+	currentEntry = new ManifestEntry( attributes.value("manifest:full-path").toString() );
+	currentEntry->setMimeType( attributes.value("manifest:media-type").toString() );
+	currentEntry->setSize( attributes.value("manifest:size").toString() );
+      } else if ( xml.name().toString() == "encryption-data" ) {
+	QXmlStreamAttributes encryptionAttributes = xml.attributes();
+	currentEntry->setChecksumType( encryptionAttributes.value("manifest:checksum-type").toString() );
+	currentEntry->setChecksum( encryptionAttributes.value("manifest:checksum").toString() );
+      } else if ( xml.name().toString() == "algorithm" ) {
+	QXmlStreamAttributes algorithmAttributes = xml.attributes();
+	currentEntry->setAlgorithm( algorithmAttributes.value("manifest:algorithm-name").toString() );
+	currentEntry->setInitialisationVector( algorithmAttributes.value("manifest:initialisation-vector").toString() );
+      } else if ( xml.name().toString() == "key-derivation" ) {
+	QXmlStreamAttributes kdfAttributes = xml.attributes();
+	currentEntry->setKeyDerivationName( kdfAttributes.value("manifest:key-derivation-name").toString() );
+	currentEntry->setIterationCount( kdfAttributes.value("manifest:iteration-count").toString() );
+	currentEntry->setSalt( kdfAttributes.value("manifest:salt").toString() );
+      } else {
+	// handle other StartDocument types here 
+	kWarning(OooDebug) << "Unexpected start document type: " << xml.name().toString();
+      }
+    } else if ( xml.tokenType() == QXmlStreamReader::EndElement ) {
+      if ( xml.name().toString() == "manifest" ) {
+	continue;
+      } else if ( xml.name().toString() == "file-entry") {
+	// we're finished processing that file entry
+	if ( mEntries.contains( currentEntry->fileName() ) ) {
+	  kWarning(OooDebug) << "Can't insert entry because of duplicate name:" << currentEntry->fileName();
+	  delete currentEntry;
+	} else {
+	  mEntries.insert( currentEntry->fileName(), currentEntry);
+	  currentEntry = 0;
+	}
+      }
+    }      
+  }
+  if (xml.hasError()) {
+    kWarning(OooDebug) << "error: " << xml.errorString() << xml.lineNumber() << xml.columnNumber();
+  }
+}
+
+Manifest::~Manifest()
+{
+  savePasswordToWallet();
+
+  qDeleteAll( mEntries );
+}
+
+ManifestEntry* Manifest::entryByName( const QString &filename )
+{
+  return mEntries.value( filename, 0 );
+}
+
+bool Manifest::testIfEncrypted( const QString &filename )
+{
+  ManifestEntry *entry = entryByName( filename );
+
+  if (entry) {
+    return ( entry->salt().length() > 0 );
+  }
+
+  return false;
+}
+
+void Manifest::getPasswordFromUser()
+{
+  // TODO: This should have a proper parent
+  KPasswordDialog dlg( 0, KPasswordDialog::KPasswordDialogFlags() );
+  dlg.setCaption( i18n( "Document Password" ) );
+  dlg.setPrompt( i18n( "Please insert the password to read the document:" ) );
+  if( ! dlg.exec() ) {
+    // user cancel
+    m_userCancelled = true;
+  } else {
+    m_password = dlg.password();
+  }
+}
+
+void Manifest::getPasswordFromWallet()
+{
+  if ( KWallet::Wallet::folderDoesNotExist( KWallet::Wallet::LocalWallet(), KWallet::Wallet::PasswordFolder() ) ) {
+    return;
+  }
+
+  if ( m_odfFileName.isEmpty() ) {
+    return;
+  }
+  // This naming is consistent with how KOffice does it.
+  QString entryKey = m_odfFileName + "/opendocument";
+
+  if ( KWallet::Wallet::keyDoesNotExist( KWallet::Wallet::LocalWallet(), KWallet::Wallet::PasswordFolder(), entryKey ) ) {
+    return;
+  }
+
+  // TODO: this should have a proper parent. I can't see a way to get one though...
+  KWallet::Wallet *wallet = KWallet::Wallet::openWallet( KWallet::Wallet::LocalWallet(), 0 );
+  if ( ! wallet ) {
+    return;
+  }
+
+  if ( ! wallet->setFolder( KWallet::Wallet::PasswordFolder() ) ) {
+    delete wallet;
+    return;
+  }
+
+  wallet->readPassword( entryKey, m_password );
+  delete wallet;
+}
+
+void Manifest::savePasswordToWallet()
+{
+  if ( ! m_haveGoodPassword ) {
+    return;
+  }
+
+  if ( m_odfFileName.isEmpty() ) {
+    return;
+  }
+
+  // TODO: this should have a proper parent. I can't see a way to get one though...
+  KWallet::Wallet *wallet = KWallet::Wallet::openWallet( KWallet::Wallet::LocalWallet(), 0 );
+  if ( ! wallet ) {
+    return;
+  }
+
+  if ( ! wallet->hasFolder( KWallet::Wallet::PasswordFolder() ) ) {
+    wallet->createFolder( KWallet::Wallet::PasswordFolder() );
+  }
+
+  if ( ! wallet->setFolder( KWallet::Wallet::PasswordFolder() ) ) {
+    delete wallet;
+    return;
+  }
+
+  // This naming is consistent with how KOffice does it.
+  QString entryKey = m_odfFileName + "/opendocument";
+
+  if ( wallet->hasEntry( entryKey ) ) {
+    wallet->removeEntry( entryKey );
+  }
+
+  wallet->writePassword( entryKey, m_password );
+
+  delete wallet;
+}
+
+void Manifest::checkPassword( ManifestEntry *entry, const QByteArray &fileData, QByteArray *decryptedData )
+{
+  QCA::SymmetricKey key = QCA::PBKDF2( "sha1" ).makeKey( QCA::Hash( "sha1" ).hash( m_password.toLocal8Bit() ),
+							 QCA::InitializationVector( entry->salt() ),
+							 16, //128 bit key
+							 entry->iterationCount() );
+
+  QCA::Cipher decoder( "blowfish", QCA::Cipher::CFB, QCA::Cipher::DefaultPadding,
+		       QCA::Decode, key, QCA::InitializationVector( entry->initialisationVector() ) );
+  *decryptedData = decoder.update( QCA::MemoryRegion(fileData) ).toByteArray();
+  *decryptedData += decoder.final().toByteArray();
+
+  QByteArray csum;
+  if ( entry->checksumType() == "SHA1/1K" ) {
+    csum = QCA::Hash( "sha1").hash( decryptedData->left(1024) ).toByteArray();
+  } else if ( entry->checksumType() == "SHA1" ) {
+    csum = QCA::Hash( "sha1").hash( *decryptedData ).toByteArray();
+  } else {
+    kDebug(OooDebug) << "unknown checksum type: " << entry->checksumType();
+    // we can only assume it will be OK.
+    m_haveGoodPassword = true;
+    return;
+  }
+
+  if ( entry->checksum() == csum ) {
+    m_haveGoodPassword = true;
+  } else {
+    m_haveGoodPassword = false;
+  }
+}
+
+const QByteArray Manifest::decryptFile( const QString &filename, const QByteArray &fileData )
+{
+#ifdef QCA2
+  ManifestEntry *entry = entryByName( filename );
+
+  if ( ! QCA::isSupported( "sha1" ) ) {
+    KMessageBox::error( 0, i18n("This document is encrypted, and crypto support is compiled in, but a hashing plugin could not be located") );
+    // in the hope that it wasn't really encrypted...
+    return QByteArray( fileData );
+  }
+
+  if ( ! QCA::isSupported( "pbkdf2(sha1)") )  {
+    KMessageBox::error( 0, i18n("This document is encrypted, and crypto support is compiled in, but a key derivation plugin could not be located") );
+    // in the hope that it wasn't really encrypted...
+    return QByteArray( fileData );
+  }
+
+  if ( ! QCA::isSupported( "blowfish-cfb") )  {
+    KMessageBox::error( 0, i18n("This document is encrypted, and crypto support is compiled in, but a cipher plugin could not be located") );
+    // in the hope that it wasn't really encrypted...
+    return QByteArray( fileData );
+  }
+
+  if (m_userCancelled) {
+    return QByteArray();
+  }
+
+
+  QByteArray decryptedData;
+  if (! m_haveGoodPassword ) {
+    getPasswordFromWallet();
+    checkPassword( entry, fileData, &decryptedData );
+  }
+
+  do {
+    if (! m_haveGoodPassword ) {
+      getPasswordFromUser();
+    }
+
+    if (m_userCancelled) {
+      return QByteArray();
+    }
+
+    checkPassword( entry, fileData, &decryptedData );
+    if ( !m_haveGoodPassword ) {
+      QMessageBox::information( 0,  i18n("Incorrect password"), i18n("The password is not correct.") );
+    } else {
+      // kDebug(OooDebug) << "Have good password";
+    }
+
+  } while ( ( ! m_haveGoodPassword ) && ( ! m_userCancelled ) );
+
+  if ( m_haveGoodPassword ) {
+    QIODevice *decompresserDevice = KFilterDev::device( new QBuffer( &decryptedData, 0 ), "application/x-gzip", true );
+    if( !decompresserDevice ) {
+      kDebug(OooDebug) << "Couldn't create decompressor";
+      // hopefully it isn't compressed then!
+      return QByteArray( fileData );
+    }
+
+    static_cast<KFilterDev*>( decompresserDevice )->setSkipHeaders( );
+
+    decompresserDevice->open( QIODevice::ReadOnly );
+
+    return decompresserDevice->readAll();
+
+  } else {
+    return QByteArray( fileData );
+  }    
+#else
+  // TODO: This should have a proper parent
+  KMessageBox::error( 0, i18n("This document is encrypted, but Okular was compiled without crypto support. This document will probably not open.") );
+  // this is equivalent to what happened before all this Manifest stuff :-)
+  return QByteArray( fileData );
+#endif
+}
Index: manifest.h
===================================================================
--- manifest.h	(revision 0)
+++ manifest.h	(revision 0)
@@ -0,0 +1,263 @@
+/***************************************************************************
+ *   Copyright (C) 2007 by Brad Hards <[EMAIL PROTECTED]>                *
+ *                                                                         *
+ *   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.                                   *
+ ***************************************************************************/
+
+#ifndef OOO_MANIFEST_H
+#define OOO_MANIFEST_H
+
+#include <QtCore/QByteArray>
+#include <QtCore/QMap>
+#include <QtCore/QString>
+
+#ifdef QCA2
+#include <QtCrypto>
+#endif
+
+namespace OOO {
+
+/**
+   OOO document manifest entry
+
+   This class holds the manifest information for a single file-entry element.
+   An example of the XML that could be passed in is shown below, although
+   not all manifest entries will have encryption-data.
+\code
+<manifest:file-entry manifest:media-type="image/jpeg" manifest:full-path="Pictures/100000000000032000000258912EB1C3.jpg" manifest:size="66704">
+  <manifest:encryption-data>
+    <manifest:algorithm manifest:algorithm-name="Blowfish CFB" manifest:initialisation-vector="T+miu403484="/>
+    <manifest:key-derivation manifest:key-derivation-name="PBKDF2" manifest:iteration-count="1024" manifest:salt="aNYdmqv4cObAJSJjm4RzqA=="/>
+  </manifest:encryption-data>
+</manifest:file-entry>
+\endcode
+*/
+class ManifestEntry
+{
+  public:
+    /**
+       Create a new manifest entry
+    */
+    ManifestEntry( const QString &fileName );
+
+    /**
+       Set the mimetype of the file.
+    */
+    void setMimeType( const QString &mimeType );
+
+    /**
+       Get the file name
+    */
+    const QString fileName();
+
+    /**
+       Set the file size.
+
+       This is only required for files with encryption
+    */
+    void setSize( const QString &size );
+
+    /**
+       Get the mime type
+    */
+    const QString mimeType();
+
+    /**
+       Get the file size
+
+       This is only meaningful for files with encryption
+    */
+    const QString size();
+
+    /**
+       Set the checksum type.
+
+       This is only required for files with encryption
+    */
+    void setChecksumType( const QString &checksumType );
+
+    /**
+       Set the checksum.
+
+       \param checksum the checksum in base64 encoding.
+
+       This is only required for files with encryption
+    */
+    void setChecksum( const QString &checksum );
+
+    /**
+       Get the checksum type
+
+       This is only meaningful for files with encryption
+    */
+    const QString checksumType();
+
+    /**
+       Get the checksum
+
+       This is only meaningful for files with encryption
+    */
+    const QByteArray checksum();
+
+    /**
+       Set the algorithm name
+
+       This is only required for files with encryption
+    */
+    void setAlgorithm( const QString &algorithm );
+
+    /**
+       Get the algorithm name
+
+       This is only meaningful for files with encryption
+    */
+    const QString algorithm();
+
+    /**
+       Set the initialisation vector for the cipher algorithm
+
+       \param initialisationVector the IV in base64 encoding.
+
+       This is only required for files with encryption
+    */
+    void setInitialisationVector( const QString &initialisationVector );
+
+    /**
+       Get the initialisation vector for the cipher algorithm
+
+       This is only meaningful for files with encryption
+    */
+    const QByteArray initialisationVector();
+
+    /**
+       Set the name of the key derivation function
+
+       This is only required for files with encryption
+    */
+    void setKeyDerivationName( const QString &keyDerivationName );
+
+    /**
+       Get the name of the key derivation function
+
+       This is only meaningful for files with encryption
+    */
+    const QString keyDerivationName();
+
+    /**
+       Set the iteration count for the key derivation function
+
+       This is only required for files with encryption
+    */
+    void setIterationCount( const QString &iterationCount );
+
+    /**
+       Get the iteration count for the key derivation function
+
+       This is only meaningful for files with encryption
+    */
+    int iterationCount();
+
+    /**
+       Set the salt for the key derivation function
+
+       \param salt the salt in base64 encoding.
+
+       This is only required for files with encryption
+    */
+    void setSalt( const QString &salt );
+
+    /**
+       Get the salt for the key derivation function
+
+       This is only meaningful for files with encryption
+    */
+    const QByteArray salt();
+
+ private:
+   const QString m_fileName;
+   QString m_mimeType;
+   QString m_size;
+   QString m_checksumType;
+   QByteArray m_checksum;
+   QString m_algorithm;
+   QByteArray m_initialisationVector;
+   QString m_keyDerivationName;
+   int m_iterationCount;
+   QByteArray m_salt;
+};
+
+
+/**
+   OOO document manifest
+
+   The document manifest is described in the OASIS Open Office Specification
+   (Version 1.1) section 17.7. This class represents the same data.
+*/
+class Manifest
+{
+  public:
+    /**
+       Create a new manifest.
+
+       \param odfFileName the name of the parent ODF file
+       \param manifestData the data from the manifest file, as a byte array
+       of the XML format data.
+    */
+    Manifest( const QString &odfFileName, const QByteArray &manifestData );
+
+    ~Manifest();
+
+    /**
+       Check if the manifest indicates that a file is encrypted
+    */
+    bool testIfEncrypted( const QString &filename );
+
+    /**
+       Decrypt data associated with a specific file
+    */
+    const QByteArray decryptFile( const QString &filename, const QByteArray &fileData );
+
+  private:
+    /**
+       Retrieve the manifest data for a particular file
+    */
+    ManifestEntry* entryByName( const QString &filename );
+
+    /**
+       Try to get the password for this file from the wallet
+    */
+    void getPasswordFromWallet();
+
+    /**
+       Save the password for this file to the wallet
+    */
+    void savePasswordToWallet();
+
+    /**
+       Verify whether the password we have is the right one.
+
+       This verifies the provided checksum
+    */
+    void checkPassword( ManifestEntry *entry, const QByteArray &fileData, QByteArray *decryptedData );
+
+    /**
+       Ask the user for a password
+    */
+    void getPasswordFromUser();
+
+#ifdef QCA2
+    QCA::Initializer m_init;
+#endif
+    const QString m_odfFileName;
+    QMap<QString, ManifestEntry*> mEntries;
+    bool m_haveGoodPassword;
+    bool m_userCancelled;
+    QString m_password;
+};
+
+}
+
+#endif
Index: document.cpp
===================================================================
--- document.cpp	(revision 774008)
+++ document.cpp	(working copy)
@@ -15,7 +15,7 @@
 using namespace OOO;
 
 Document::Document( const QString &fileName )
-  : mFileName( fileName )
+  : mFileName( fileName ), mManifest( 0 )
 {
 }
 
@@ -37,13 +37,33 @@
   }
 
   const QStringList entries = directory->entries();
+  if ( !entries.contains( "META-INF" ) ) {
+    setError( i18n( "Invalid document structure (META-INF directory is missing)" ) );
+    return false;
+  }
+  const KArchiveDirectory *metaInfDirectory = static_cast<const KArchiveDirectory*>( directory->entry( "META-INF" ) );
+  if ( !(metaInfDirectory->entries().contains( "manifest.xml" ) ) ) {
+    setError( i18n( "Invalid document structure (META-INF/manifest.xml is missing)" ) );
+    return false;
+  }
+
+  const KArchiveFile *file = static_cast<const KArchiveFile*>( metaInfDirectory->entry( "manifest.xml" ) );
+  mManifest = new Manifest( mFileName, file->data() );
+
+  // we should really get the file names from the manifest, but for now, we only care
+  // if the manifest says the files are encrypted.
+  
   if ( !entries.contains( "content.xml" ) ) {
     setError( i18n( "Invalid document structure (content.xml is missing)" ) );
     return false;
   }
 
-  const KArchiveFile *file = static_cast<const KArchiveFile*>( directory->entry( "content.xml" ) );
-  mContent = file->data();
+  file = static_cast<const KArchiveFile*>( directory->entry( "content.xml" ) );
+  if ( mManifest->testIfEncrypted( "content.xml" )  ) {
+    mContent = mManifest->decryptFile( "content.xml", file->data() );
+  } else {
+    mContent = file->data();
+  }
 
   if ( !entries.contains( "styles.xml" ) ) {
     setError( i18n( "Invalid document structure (styles.xml is missing)" ) );
@@ -51,7 +71,11 @@
   }
 
   file = static_cast<const KArchiveFile*>( directory->entry( "styles.xml" ) );
-  mStyles = file->data();
+  if ( mManifest->testIfEncrypted( "styles.xml" )  ) {
+    mStyles = mManifest->decryptFile( "styles.xml", file->data() );
+  } else {
+    mStyles = file->data();
+  }
 
   if ( !entries.contains( "meta.xml" ) ) {
     setError( i18n( "Invalid document structure (meta.xml is missing)" ) );
@@ -59,7 +83,11 @@
   }
 
   file = static_cast<const KArchiveFile*>( directory->entry( "meta.xml" ) );
-  mMeta = file->data();
+  if ( mManifest->testIfEncrypted( "meta.xml" )  ) {
+    mMeta = mManifest->decryptFile( "meta.xml", file->data() );
+  } else {
+    mMeta = file->data();
+  }
 
   if ( entries.contains( "Pictures" ) ) {
     const KArchiveDirectory *imagesDirectory = static_cast<const KArchiveDirectory*>( directory->entry( "Pictures" ) );
@@ -67,7 +95,12 @@
     const QStringList imagesEntries = imagesDirectory->entries();
     for ( int i = 0; i < imagesEntries.count(); ++i ) {
       file = static_cast<const KArchiveFile*>( imagesDirectory->entry( imagesEntries[ i ] ) );
-      mImages.insert( QString( "Pictures/%1" ).arg( imagesEntries[ i ] ), file->data() );
+      QString fullPath = QString( "Pictures/%1" ).arg( imagesEntries[ i ] );
+      if ( mManifest->testIfEncrypted( fullPath ) ) {
+	mImages.insert( fullPath, mManifest->decryptFile( fullPath, file->data() ) );
+      } else {
+	mImages.insert( fullPath, file->data() );
+      }
     }
   }
 
@@ -76,6 +109,11 @@
   return true;
 }
 
+Document::~Document()
+{
+  delete mManifest;
+}
+
 QString Document::lastErrorString() const
 {
   return mErrorString;
Index: document.h
===================================================================
--- document.h	(revision 774008)
+++ document.h	(working copy)
@@ -14,12 +14,15 @@
 #include <QtCore/QMap>
 #include <QtCore/QString>
 
+#include "manifest.h"
+
 namespace OOO {
 
 class Document
 {
   public:
     Document( const QString &fileName );
+    ~Document();
 
     bool open();
 
@@ -38,6 +41,7 @@
     QByteArray mMeta;
     QByteArray mStyles;
     QMap<QString, QByteArray> mImages;
+    Manifest *mManifest;
     QString mErrorString;
 };
 
Index: debug.h
===================================================================
--- debug.h	(revision 0)
+++ debug.h	(revision 0)
@@ -0,0 +1,16 @@
+/***************************************************************************
+ *   Copyright (C) 2007 by Brad Hards <[EMAIL PROTECTED]>                *
+ *                                                                         *
+ *   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.                                   *
+ ***************************************************************************/
+
+#ifndef OOO_DEBUG_H
+#define OOO_DEBUG_H
+
+#include <KDebug>
+const int OooDebug = 4715;
+
+#endif
Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt	(revision 774008)
+++ CMakeLists.txt	(working copy)
@@ -3,7 +3,13 @@
    ${CMAKE_CURRENT_SOURCE_DIR}/../..
 )
 
+macro_optional_find_package(QCA2)
 
+if ( QCA2_FOUND )
+   include_directories( ${QCA2_INCLUDE_DIR} )
+   add_definitions( -DQCA2 )
+endif( QCA2_FOUND )
+
 ########### next target ###############
 
 set(okularGenerator_ooo_PART_SRCS
@@ -11,6 +17,7 @@
   document.cpp
   formatproperty.cpp
   generator_ooo.cpp
+  manifest.cpp
   styleinformation.cpp
   styleparser.cpp
 )
@@ -18,7 +25,11 @@
 
 kde4_add_plugin(okularGenerator_ooo ${okularGenerator_ooo_PART_SRCS})
 
-target_link_libraries(okularGenerator_ooo   ${POPPLER_LIBRARY} okularcore ${KDE4_KIO_LIBS} ${MATH_LIB} )
+if (QCA2_FOUND)
+  target_link_libraries(okularGenerator_ooo   ${POPPLER_LIBRARY} okularcore ${KDE4_KIO_LIBS} ${MATH_LIB} ${QCA2_LIBRARIES})
+else (QCA2_FOUND)
+  target_link_libraries(okularGenerator_ooo   ${POPPLER_LIBRARY} okularcore ${KDE4_KIO_LIBS} ${MATH_LIB})
+endif (QCA2_FOUND)
 
 install(TARGETS okularGenerator_ooo DESTINATION ${PLUGIN_INSTALL_DIR})
 
_______________________________________________
Okular-devel mailing list
Okular-devel@kde.org
https://mail.kde.org/mailman/listinfo/okular-devel

Reply via email to