mirror of
https://invent.kde.org/graphics/okular
synced 2024-08-27 03:30:20 +00:00
resync with spectre
svn path=/trunk/KDE/kdegraphics/okular/; revision=741933
This commit is contained in:
parent
d3f4460d38
commit
2153ec5edd
|
@ -1712,6 +1712,7 @@ static char * readline (fd, lineP, positionP, line_lenP)
|
|||
{
|
||||
unsigned int nbytes=0;
|
||||
int skipped=0;
|
||||
int nesting_level=0;
|
||||
char *line;
|
||||
|
||||
BEGINMESSAGE(readline)
|
||||
|
@ -1770,10 +1771,18 @@ static char * readline (fd, lineP, positionP, line_lenP)
|
|||
#endif
|
||||
if (!IS_COMMENT("Begin")) {} /* Do nothing */
|
||||
else if IS_BEGIN("Document:") { /* Skip the EPS without handling its content */
|
||||
while (line && !IS_END("Document")) {
|
||||
line = ps_io_fgetchars(fd,-1);
|
||||
if (line) *line_lenP += FD_LINE_LEN;
|
||||
}
|
||||
nesting_level=1;
|
||||
line = ps_io_fgetchars(fd,-1);
|
||||
if (line) *line_lenP += FD_LINE_LEN;
|
||||
while (line) {
|
||||
if (IS_COMMENT("Begin") && IS_BEGIN("Document:"))
|
||||
nesting_level++;
|
||||
else if (IS_COMMENT("End") && IS_END("Document"))
|
||||
nesting_level--;
|
||||
if (nesting_level == 0) break;
|
||||
line = ps_io_fgetchars(fd,-1);
|
||||
if (line) *line_lenP += FD_LINE_LEN;
|
||||
}
|
||||
}
|
||||
else if IS_BEGIN("Feature:") SKIP_UNTIL_1("EndFeature")
|
||||
#ifdef USE_ACROREAD_WORKAROUND
|
||||
|
|
|
@ -171,7 +171,7 @@ spectre_device_render (SpectreDevice *device,
|
|||
{
|
||||
SpectreGS *gs;
|
||||
char **args;
|
||||
int n_args = 10;
|
||||
int n_args = 12;
|
||||
int arg = 0;
|
||||
int success;
|
||||
char *text_alpha, *graph_alpha;
|
||||
|
@ -226,10 +226,12 @@ spectre_device_render (SpectreDevice *device,
|
|||
n_args++;
|
||||
|
||||
args = calloc (sizeof (char *), n_args);
|
||||
args[arg++] = "libspectre"; /* This value doesn't really matter */
|
||||
args[arg++] = "-dMaxBitmap=10000000";
|
||||
args[arg++] = "-dDELAYSAFER";
|
||||
args[arg++] = "-dNOPAUSE";
|
||||
args[arg++] = "-dNOPAGEPROMPT";
|
||||
args[arg++] = "-sDEVICE=display";
|
||||
args[arg++] = text_alpha =_spectre_strdup_printf("-dTextAlphaBits=%d",
|
||||
rc->text_alpha_bits);
|
||||
args[arg++] = graph_alpha = _spectre_strdup_printf("-dGraphicsAlphaBits=%d",
|
||||
|
|
|
@ -234,6 +234,33 @@ spectre_document_get_page (SpectreDocument *document,
|
|||
return page;
|
||||
}
|
||||
|
||||
SpectrePage *
|
||||
spectre_document_get_page_by_label (SpectreDocument *document,
|
||||
const char *label)
|
||||
{
|
||||
unsigned int i;
|
||||
int page_index = -1;
|
||||
|
||||
if (!label) {
|
||||
document->status = SPECTRE_STATUS_INVALID_PAGE;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (i = 0; i < document->doc->numpages; i++) {
|
||||
if (strcmp (document->doc->pages[i].label, label) == 0) {
|
||||
page_index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (page_index == -1) {
|
||||
document->status = SPECTRE_STATUS_INVALID_PAGE;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return spectre_document_get_page (document, page_index);
|
||||
}
|
||||
|
||||
void
|
||||
spectre_document_save (SpectreDocument *document,
|
||||
const char *filename)
|
||||
|
|
|
@ -118,6 +118,15 @@ unsigned int spectre_document_get_language_level (SpectreDocument *documen
|
|||
*/
|
||||
SpectrePage *spectre_document_get_page (SpectreDocument *document,
|
||||
unsigned int page_index);
|
||||
|
||||
/*! Returns a page of the document referenced by label. This function can fail
|
||||
@param document the document whose page will be returned
|
||||
@param label the label of the page to get.
|
||||
@see spectre_document_status
|
||||
*/
|
||||
SpectrePage *spectre_document_get_page_by_label (SpectreDocument *document,
|
||||
const char *label);
|
||||
|
||||
/*! Save document as filename. This function can fail
|
||||
@param document the document that will be saved
|
||||
@param filename the path where document will be saved
|
||||
|
|
|
@ -194,14 +194,31 @@ spectre_gs_send_page (SpectreGS *gs,
|
|||
struct document *doc,
|
||||
unsigned int page_index)
|
||||
{
|
||||
int urx, ury, llx, lly;
|
||||
int doc_llx = 0, doc_lly = 0;
|
||||
int page_llx = 0, page_lly = 0;
|
||||
|
||||
if ((doc->boundingbox[URX] > doc->boundingbox[LLX]) &&
|
||||
(doc->boundingbox[URY] > doc->boundingbox[LLY])) {
|
||||
doc_llx = doc->boundingbox[LLX];
|
||||
doc_lly = doc->boundingbox[LLY];
|
||||
}
|
||||
|
||||
if (doc->numpages > 0 &&
|
||||
(doc->pages[page_index].boundingbox[URX] >
|
||||
doc->pages[page_index].boundingbox[LLX]) &&
|
||||
(doc->pages[page_index].boundingbox[URY] >
|
||||
doc->pages[page_index].boundingbox[LLY])) {
|
||||
/* Do not translate twice */
|
||||
if (doc->pages[page_index].boundingbox[LLX] != doc_llx &&
|
||||
doc->pages[page_index].boundingbox[LLY] != doc_lly) {
|
||||
page_llx = doc->pages[page_index].boundingbox[LLX];
|
||||
page_lly = doc->pages[page_index].boundingbox[LLY];
|
||||
}
|
||||
}
|
||||
|
||||
psgetpagebox (doc, page_index,
|
||||
&urx, &ury, &llx, &lly);
|
||||
|
||||
if (!spectre_gs_process (gs,
|
||||
doc->filename,
|
||||
llx, lly,
|
||||
doc_llx, doc_lly,
|
||||
doc->beginprolog,
|
||||
doc->endprolog))
|
||||
return FALSE;
|
||||
|
@ -216,7 +233,7 @@ spectre_gs_send_page (SpectreGS *gs,
|
|||
if (doc->numpages > 0) {
|
||||
if (!spectre_gs_process (gs,
|
||||
doc->filename,
|
||||
llx, lly,
|
||||
page_llx, page_lly,
|
||||
doc->pages[page_index].begin,
|
||||
doc->pages[page_index].end))
|
||||
return FALSE;
|
||||
|
|
|
@ -77,6 +77,12 @@ spectre_page_get_index (SpectrePage *page)
|
|||
return page->index;
|
||||
}
|
||||
|
||||
const char *
|
||||
spectre_page_get_label (SpectrePage *page)
|
||||
{
|
||||
return page->doc->numpages > 0 ? page->doc->pages[page->index].label : NULL;
|
||||
}
|
||||
|
||||
SpectreOrientation
|
||||
spectre_page_get_orientation (SpectrePage *page)
|
||||
{
|
||||
|
|
|
@ -55,6 +55,11 @@ void spectre_page_free (SpectrePage *page);
|
|||
*/
|
||||
unsigned int spectre_page_get_index (SpectrePage *page);
|
||||
|
||||
/*! Returns the label of the page inside the document.
|
||||
@param page The page whose label will be returned
|
||||
*/
|
||||
const char *spectre_page_get_label (SpectrePage *page);
|
||||
|
||||
/*! Returns the orientation of the page
|
||||
@param page The page whose orientation will be returned
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue