mirror of
https://github.com/pdf2htmlEX/pdf2htmlEX.git
synced 2024-12-22 04:50:09 +00:00
initial copy of poppler-0.78.0 Cairo files
This commit is contained in:
parent
4c3038ad40
commit
89cfef32de
92
3rdparty/poppler/git/CairoOutputDev.cc
vendored
92
3rdparty/poppler/git/CairoOutputDev.cc
vendored
@ -87,12 +87,12 @@
|
|||||||
// CairoImage
|
// CairoImage
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
|
|
||||||
CairoImage::CairoImage (double x1, double y1, double x2, double y2) {
|
CairoImage::CairoImage (double x1A, double y1A, double x2A, double y2A) {
|
||||||
this->image = nullptr;
|
image = nullptr;
|
||||||
this->x1 = x1;
|
x1 = x1A;
|
||||||
this->y1 = y1;
|
y1 = y1A;
|
||||||
this->x2 = x2;
|
x2 = x2A;
|
||||||
this->y2 = y2;
|
y2 = y2A;
|
||||||
}
|
}
|
||||||
|
|
||||||
CairoImage::~CairoImage () {
|
CairoImage::~CairoImage () {
|
||||||
@ -100,10 +100,10 @@ CairoImage::~CairoImage () {
|
|||||||
cairo_surface_destroy (image);
|
cairo_surface_destroy (image);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CairoImage::setImage (cairo_surface_t *image) {
|
void CairoImage::setImage (cairo_surface_t *i) {
|
||||||
if (this->image)
|
if (image)
|
||||||
cairo_surface_destroy (this->image);
|
cairo_surface_destroy (image);
|
||||||
this->image = cairo_surface_reference (image);
|
image = cairo_surface_reference (i);
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
@ -161,7 +161,7 @@ CairoOutputDev::CairoOutputDev() {
|
|||||||
cairo_shape = nullptr;
|
cairo_shape = nullptr;
|
||||||
knockoutCount = 0;
|
knockoutCount = 0;
|
||||||
|
|
||||||
text = nullptr;
|
textPage = nullptr;
|
||||||
actualText = nullptr;
|
actualText = nullptr;
|
||||||
|
|
||||||
// the SA parameter supposedly defaults to false, but Acrobat
|
// the SA parameter supposedly defaults to false, but Acrobat
|
||||||
@ -187,53 +187,53 @@ CairoOutputDev::~CairoOutputDev() {
|
|||||||
cairo_pattern_destroy (mask);
|
cairo_pattern_destroy (mask);
|
||||||
if (shape)
|
if (shape)
|
||||||
cairo_pattern_destroy (shape);
|
cairo_pattern_destroy (shape);
|
||||||
if (text)
|
if (textPage)
|
||||||
text->decRefCnt();
|
textPage->decRefCnt();
|
||||||
if (actualText)
|
if (actualText)
|
||||||
delete actualText;
|
delete actualText;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CairoOutputDev::setCairo(cairo_t *cairo)
|
void CairoOutputDev::setCairo(cairo_t *c)
|
||||||
{
|
{
|
||||||
if (this->cairo != nullptr) {
|
if (cairo != nullptr) {
|
||||||
cairo_status_t status = cairo_status (this->cairo);
|
cairo_status_t status = cairo_status (cairo);
|
||||||
if (status) {
|
if (status) {
|
||||||
error(errInternal, -1, "cairo context error: {0:s}\n", cairo_status_to_string(status));
|
error(errInternal, -1, "cairo context error: {0:s}\n", cairo_status_to_string(status));
|
||||||
}
|
}
|
||||||
cairo_destroy (this->cairo);
|
cairo_destroy (cairo);
|
||||||
assert(!cairo_shape);
|
assert(!cairo_shape);
|
||||||
}
|
}
|
||||||
if (cairo != nullptr) {
|
if (c != nullptr) {
|
||||||
this->cairo = cairo_reference (cairo);
|
cairo = cairo_reference (c);
|
||||||
/* save the initial matrix so that we can use it for type3 fonts. */
|
/* save the initial matrix so that we can use it for type3 fonts. */
|
||||||
//XXX: is this sufficient? could we miss changes to the matrix somehow?
|
//XXX: is this sufficient? could we miss changes to the matrix somehow?
|
||||||
cairo_get_matrix(cairo, &orig_matrix);
|
cairo_get_matrix(cairo, &orig_matrix);
|
||||||
setContextAntialias(cairo, antialias);
|
setContextAntialias(cairo, antialias);
|
||||||
} else {
|
} else {
|
||||||
this->cairo = nullptr;
|
cairo = nullptr;
|
||||||
this->cairo_shape = nullptr;
|
cairo_shape = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CairoOutputDev::setTextPage(TextPage *text)
|
void CairoOutputDev::setTextPage(TextPage *text)
|
||||||
{
|
{
|
||||||
if (this->text)
|
if (textPage)
|
||||||
this->text->decRefCnt();
|
textPage->decRefCnt();
|
||||||
if (actualText)
|
if (actualText)
|
||||||
delete actualText;
|
delete actualText;
|
||||||
if (text) {
|
if (text) {
|
||||||
this->text = text;
|
textPage = text;
|
||||||
this->text->incRefCnt();
|
textPage->incRefCnt();
|
||||||
actualText = new ActualText(text);
|
actualText = new ActualText(text);
|
||||||
} else {
|
} else {
|
||||||
this->text = nullptr;
|
textPage = nullptr;
|
||||||
actualText = nullptr;
|
actualText = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CairoOutputDev::setAntialias(cairo_antialias_t antialias)
|
void CairoOutputDev::setAntialias(cairo_antialias_t a)
|
||||||
{
|
{
|
||||||
this->antialias = antialias;
|
antialias = a;
|
||||||
if (cairo)
|
if (cairo)
|
||||||
setContextAntialias (cairo, antialias);
|
setContextAntialias (cairo, antialias);
|
||||||
if (cairo_shape)
|
if (cairo_shape)
|
||||||
@ -276,17 +276,17 @@ void CairoOutputDev::startPage(int pageNum, GfxState *state, XRef *xrefA) {
|
|||||||
stroke_pattern = cairo_pattern_reference(fill_pattern);
|
stroke_pattern = cairo_pattern_reference(fill_pattern);
|
||||||
stroke_color.r = stroke_color.g = stroke_color.b = 0;
|
stroke_color.r = stroke_color.g = stroke_color.b = 0;
|
||||||
|
|
||||||
if (text)
|
if (textPage)
|
||||||
text->startPage(state);
|
textPage->startPage(state);
|
||||||
if (xrefA != nullptr) {
|
if (xrefA != nullptr) {
|
||||||
xref = xrefA;
|
xref = xrefA;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CairoOutputDev::endPage() {
|
void CairoOutputDev::endPage() {
|
||||||
if (text) {
|
if (textPage) {
|
||||||
text->endPage();
|
textPage->endPage();
|
||||||
text->coalesce(true, 0, false);
|
textPage->coalesce(true, 0, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -354,8 +354,8 @@ void CairoOutputDev::updateAll(GfxState *state) {
|
|||||||
updateStrokeOpacity(state);
|
updateStrokeOpacity(state);
|
||||||
updateBlendMode(state);
|
updateBlendMode(state);
|
||||||
needFontUpdate = true;
|
needFontUpdate = true;
|
||||||
if (text)
|
if (textPage)
|
||||||
text->updateFont(state);
|
textPage->updateFont(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CairoOutputDev::setDefaultCTM(const double *ctm) {
|
void CairoOutputDev::setDefaultCTM(const double *ctm) {
|
||||||
@ -659,8 +659,8 @@ void CairoOutputDev::updateFont(GfxState *state) {
|
|||||||
needFontUpdate = false;
|
needFontUpdate = false;
|
||||||
|
|
||||||
//FIXME: use cairo font engine?
|
//FIXME: use cairo font engine?
|
||||||
if (text)
|
if (textPage)
|
||||||
text->updateFont(state);
|
textPage->updateFont(state);
|
||||||
|
|
||||||
currentFont = fontEngine->getFont (state->getFont(), doc, printing, xref);
|
currentFont = fontEngine->getFont (state->getFont(), doc, printing, xref);
|
||||||
|
|
||||||
@ -751,11 +751,11 @@ void CairoOutputDev::alignStrokeCoords(GfxSubpath *subpath, int i, double *x, do
|
|||||||
|
|
||||||
#undef STROKE_COORD_TOLERANCE
|
#undef STROKE_COORD_TOLERANCE
|
||||||
|
|
||||||
void CairoOutputDev::doPath(cairo_t *cairo, GfxState *state, GfxPath *path) {
|
void CairoOutputDev::doPath(cairo_t *c, GfxState *state, GfxPath *path) {
|
||||||
GfxSubpath *subpath;
|
GfxSubpath *subpath;
|
||||||
int i, j;
|
int i, j;
|
||||||
double x, y;
|
double x, y;
|
||||||
cairo_new_path (cairo);
|
cairo_new_path (c);
|
||||||
for (i = 0; i < path->getNumSubpaths(); ++i) {
|
for (i = 0; i < path->getNumSubpaths(); ++i) {
|
||||||
subpath = path->getSubpath(i);
|
subpath = path->getSubpath(i);
|
||||||
if (subpath->getNumPoints() > 0) {
|
if (subpath->getNumPoints() > 0) {
|
||||||
@ -765,7 +765,7 @@ void CairoOutputDev::doPath(cairo_t *cairo, GfxState *state, GfxPath *path) {
|
|||||||
x = subpath->getX(0);
|
x = subpath->getX(0);
|
||||||
y = subpath->getY(0);
|
y = subpath->getY(0);
|
||||||
}
|
}
|
||||||
cairo_move_to (cairo, x, y);
|
cairo_move_to (c, x, y);
|
||||||
j = 1;
|
j = 1;
|
||||||
while (j < subpath->getNumPoints()) {
|
while (j < subpath->getNumPoints()) {
|
||||||
if (subpath->getCurve(j)) {
|
if (subpath->getCurve(j)) {
|
||||||
@ -775,7 +775,7 @@ void CairoOutputDev::doPath(cairo_t *cairo, GfxState *state, GfxPath *path) {
|
|||||||
x = subpath->getX(j+2);
|
x = subpath->getX(j+2);
|
||||||
y = subpath->getY(j+2);
|
y = subpath->getY(j+2);
|
||||||
}
|
}
|
||||||
cairo_curve_to( cairo,
|
cairo_curve_to( c,
|
||||||
subpath->getX(j), subpath->getY(j),
|
subpath->getX(j), subpath->getY(j),
|
||||||
subpath->getX(j+1), subpath->getY(j+1),
|
subpath->getX(j+1), subpath->getY(j+1),
|
||||||
x, y);
|
x, y);
|
||||||
@ -788,13 +788,13 @@ void CairoOutputDev::doPath(cairo_t *cairo, GfxState *state, GfxPath *path) {
|
|||||||
x = subpath->getX(j);
|
x = subpath->getX(j);
|
||||||
y = subpath->getY(j);
|
y = subpath->getY(j);
|
||||||
}
|
}
|
||||||
cairo_line_to (cairo, x, y);
|
cairo_line_to (c, x, y);
|
||||||
++j;
|
++j;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (subpath->isClosed()) {
|
if (subpath->isClosed()) {
|
||||||
LOG (printf ("close\n"));
|
LOG (printf ("close\n"));
|
||||||
cairo_close_path (cairo);
|
cairo_close_path (c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1423,7 +1423,7 @@ void CairoOutputDev::drawChar(GfxState *state, double x, double y,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!text)
|
if (!textPage)
|
||||||
return;
|
return;
|
||||||
actualText->addChar (state, x, y, dx, dy, code, nBytes, u, uLen);
|
actualText->addChar (state, x, y, dx, dy, code, nBytes, u, uLen);
|
||||||
}
|
}
|
||||||
@ -1580,13 +1580,13 @@ void CairoOutputDev::endTextObject(GfxState *state) {
|
|||||||
|
|
||||||
void CairoOutputDev::beginActualText(GfxState *state, const GooString *text)
|
void CairoOutputDev::beginActualText(GfxState *state, const GooString *text)
|
||||||
{
|
{
|
||||||
if (this->text)
|
if (textPage)
|
||||||
actualText->begin(state, text);
|
actualText->begin(state, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CairoOutputDev::endActualText(GfxState *state)
|
void CairoOutputDev::endActualText(GfxState *state)
|
||||||
{
|
{
|
||||||
if (text)
|
if (textPage)
|
||||||
actualText->end(state);
|
actualText->end(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
4
3rdparty/poppler/git/CairoOutputDev.h
vendored
4
3rdparty/poppler/git/CairoOutputDev.h
vendored
@ -23,7 +23,7 @@
|
|||||||
// Copyright (C) 2010-2013 Thomas Freitag <Thomas.Freitag@alfa.de>
|
// Copyright (C) 2010-2013 Thomas Freitag <Thomas.Freitag@alfa.de>
|
||||||
// Copyright (C) 2015 Suzuki Toshiya <mpsuzuki@hiroshima-u.ac.jp>
|
// Copyright (C) 2015 Suzuki Toshiya <mpsuzuki@hiroshima-u.ac.jp>
|
||||||
// Copyright (C) 2016 Jason Crain <jason@aquaticape.us>
|
// Copyright (C) 2016 Jason Crain <jason@aquaticape.us>
|
||||||
// Copyright (C) 2018 Albert Astals Cid <aacid@kde.org>
|
// Copyright (C) 2018, 2019 Albert Astals Cid <aacid@kde.org>
|
||||||
// Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, <info@kdab.com>. Work sponsored by the LiMux project of the city of Munich
|
// Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, <info@kdab.com>. Work sponsored by the LiMux project of the city of Munich
|
||||||
//
|
//
|
||||||
// To see a description of the changes please see the Changelog file that
|
// To see a description of the changes please see the Changelog file that
|
||||||
@ -347,7 +347,7 @@ protected:
|
|||||||
cairo_antialias_t antialias;
|
cairo_antialias_t antialias;
|
||||||
bool prescaleImages;
|
bool prescaleImages;
|
||||||
|
|
||||||
TextPage *text; // text for the current page
|
TextPage *textPage; // text for the current page
|
||||||
ActualText *actualText;
|
ActualText *actualText;
|
||||||
|
|
||||||
cairo_pattern_t *group;
|
cairo_pattern_t *group;
|
||||||
|
Loading…
Reference in New Issue
Block a user