Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
John Zhang
Okular
Commits
92c653cf
Commit
92c653cf
authored
Dec 28, 2004
by
Enrico Ros
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Leak fix encrypted document opening.
svn path=/branches/kpdf_experiments/kdegraphics/kpdf/; revision=373695
parent
2fb64506
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
44 deletions
+29
-44
kpdf/TODO
kpdf/TODO
+1
-0
kpdf/generator_pdf.cpp
kpdf/generator_pdf.cpp
+21
-43
kpdf/generator_pdf.h
kpdf/generator_pdf.h
+7
-1
No files found.
kpdf/TODO
View file @
92c653cf
...
...
@@ -81,6 +81,7 @@ More items (first items will enter 'In progress list' first):
-> investigate 'Splash' lack of smoothness at low resolutions (see lines in thumbnails)
-> add search on the toc widget (a prune on type lineedit like in thumbnails widget)
-> goto 'logical' page (usually differs from pdf's page) (req. by Luca Burrelli)
-> use wallet for storing passwords of encrypted files
Done (newest feature comes firts):
-> FIX: Memory manager (free cache if needed, avoid disk swap and oom)
...
...
kpdf/generator_pdf.cpp
View file @
92c653cf
...
...
@@ -62,58 +62,36 @@ PDFGenerator::~PDFGenerator()
bool
PDFGenerator
::
loadDocument
(
const
QString
&
fileName
,
QValueVector
<
KPDFPage
*>
&
pagesVector
)
{
// create PDFDoc for the given file
GString
*
filename
=
new
GString
(
QFile
::
encodeName
(
fileName
)
);
delete
pdfdoc
;
pdfdoc
=
new
PDFDoc
(
filename
,
0
,
0
);
pdfdoc
=
new
PDFDoc
(
new
GString
(
QFile
::
encodeName
(
fileName
)
),
0
,
0
);
// if the file didn't open correctly it might be encrypted, so ask for a pass
if
(
!
pdfdoc
->
isOk
()
)
bool
firstTry
=
true
;
while
(
!
pdfdoc
->
isOk
()
&&
pdfdoc
->
getErrorCode
()
==
errEncrypted
)
{
if
(
pdfdoc
->
getErrorCode
()
==
errEncrypted
)
{
bool
first
,
correct
;
QString
prompt
;
QCString
pwd
;
QString
prompt
;
if
(
firstTry
)
prompt
=
i18n
(
"Please insert the password to read the document:"
);
else
prompt
=
i18n
(
"Incorrect password. Try again:"
);
firstTry
=
false
;
first
=
true
;
correct
=
false
;
while
(
!
correct
)
{
if
(
first
)
{
prompt
=
i18n
(
"Please insert the password to read the document:"
);
first
=
false
;
}
else
prompt
=
i18n
(
"Incorrect password. Try again:"
);
if
(
KPasswordDialog
::
getPassword
(
pwd
,
prompt
)
==
KPasswordDialog
::
Accepted
)
{
GString
*
pwd2
;
pwd2
=
new
GString
(
pwd
.
data
()
);
pdfdoc
=
new
PDFDoc
(
filename
,
pwd2
,
pwd2
);
delete
pwd2
;
correct
=
pdfdoc
->
isOk
();
if
(
!
correct
&&
pdfdoc
->
getErrorCode
()
!=
errEncrypted
)
{
delete
pdfdoc
;
pdfdoc
=
0
;
return
false
;
}
}
else
{
delete
pdfdoc
;
pdfdoc
=
0
;
return
false
;
}
}
}
QCString
pwd
;
if
(
KPasswordDialog
::
getPassword
(
pwd
,
prompt
)
!=
KPasswordDialog
::
Accepted
)
break
;
else
{
GString
*
pwd2
=
new
GString
(
pwd
.
data
()
);
delete
pdfdoc
;
pdfdoc
=
0
;
return
false
;
pdfdoc
=
new
PDFDoc
(
new
GString
(
QFile
::
encodeName
(
fileName
)
),
pwd2
,
pwd2
)
;
delete
pwd2
;
}
}
if
(
!
pdfdoc
->
isOk
()
)
{
delete
pdfdoc
;
pdfdoc
=
0
;
return
false
;
}
// initialize output device for rendering current pdf
kpdfOutputDev
->
startDoc
(
pdfdoc
->
getXRef
()
);
...
...
kpdf/generator_pdf.h
View file @
92c653cf
...
...
@@ -22,6 +22,7 @@
class
PDFDoc
;
class
GList
;
class
KPDFOutputDev
;
class
PDFGeneratorThread
;
/**
* @short A generator that builds contents from a PDF document.
...
...
@@ -68,13 +69,18 @@ class PDFGenerator : public Generator
// private function for creating the document synopsis hieracy
void
addSynopsisChildren
(
QDomNode
*
parent
,
GList
*
items
);
//
private classes
//
xpdf dependant stuff
QMutex
docLock
;
PDFDoc
*
pdfdoc
;
KPDFOutputDev
*
kpdfOutputDev
;
QColor
paperColor
;
// asyncronous generation related things
PDFGeneratorThread
*
generatorThread
;
PixmapRequest
*
requestOnThread
;
QValueList
<
PixmapRequest
*
>
requestsQueue
;
// misc variables for document info and synopsis caching
bool
docInfoDirty
;
DocumentInfo
docInfo
;
bool
docSynopsisDirty
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment