From f2adea4fab7c486f1479d751362e1d1722600a85 Mon Sep 17 00:00:00 2001 From: Hib Eris Date: Tue, 1 Nov 2011 14:15:09 +0100 Subject: [PATCH] [qt4] Use PDFDoc(wchar_t *, ...) on Windows Bug 35378 --- qt4/src/poppler-document.cc | 4 ++-- qt4/src/poppler-private.h | 16 ++++++++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/qt4/src/poppler-document.cc b/qt4/src/poppler-document.cc index 04c56c6..75864f3 100644 --- a/qt4/src/poppler-document.cc +++ b/qt4/src/poppler-document.cc @@ -50,7 +50,7 @@ namespace Poppler { Document *Document::load(const QString &filePath, const QByteArray &ownerPassword, const QByteArray &userPassword) { - DocumentData *doc = new DocumentData(new GooString(QFile::encodeName(filePath)), + DocumentData *doc = new DocumentData(filePath, new GooString(ownerPassword.data()), new GooString(userPassword.data())); return DocumentData::checkDocument(doc); @@ -128,7 +128,7 @@ namespace Poppler { } else { - doc2 = new DocumentData(new GooString(m_doc->doc->getFileName()), + doc2 = new DocumentData(m_doc->m_filePath, new GooString(ownerPassword.data()), new GooString(userPassword.data())); } diff --git a/qt4/src/poppler-private.h b/qt4/src/poppler-private.h index 6d2b315..9c49d77 100644 --- a/qt4/src/poppler-private.h +++ b/qt4/src/poppler-private.h @@ -75,10 +75,21 @@ namespace Poppler { class DocumentData { public: - DocumentData(GooString *filePath, GooString *ownerPassword, GooString *userPassword) + DocumentData(const QString &filePath, GooString *ownerPassword, GooString *userPassword) { init(); - doc = new PDFDoc(filePath, ownerPassword, userPassword); + m_filePath = filePath; + +#if defined(_WIN32) + wchar_t *fileName = new WCHAR[filePath.length()]; + int length = filePath.toWCharArray(fileName); + doc = new PDFDoc(fileName, length, ownerPassword, userPassword); + delete fileName; +#else + GooString *fileName = new GooString(QFile::encodeName(filePath)); + doc = new PDFDoc(fileName, ownerPassword, userPassword); +#endif + delete ownerPassword; delete userPassword; } @@ -173,6 +184,7 @@ namespace Poppler { static Document *checkDocument(DocumentData *doc); PDFDoc *doc; + QString m_filePath; QByteArray fileContents; bool locked; FontIterator *m_fontInfoIterator; -- 1.7.4.1