Subversion Repositories Scribus

Compare Revisions

Ignore whitespace Rev 25119 → Rev 25118

/branches/Version15x/Scribus/scribus/plugins/import/pdf/slaoutput.cpp
16,10 → 16,8
#include <poppler/poppler-config.h>
#include <poppler/FileSpec.h>
#include <poppler/fofi/FoFiTrueType.h>
 
#include <QApplication>
#include <QFile>
 
#include "commonstrings.h"
#include "loadsaveplugin.h"
#include "sccolorengine.h"
293,6 → 291,8
m_Elements = Elements;
pushGroup();
m_importedColors = importedColors;
m_currColorStroke = "Black";
m_currColorFill = "Black";
tmpSel = new Selection(m_doc, false);
importerFlags = flags;
currentLayer = m_doc->activeLayer();
689,23 → 689,23
if (bgCol)
{
bgFound = true;
m_graphicStack.top().fillColor = getAnnotationColor(bgCol);
m_currColorFill = getAnnotationColor(bgCol);
}
else
m_graphicStack.top().fillColor = CommonStrings::None;
m_currColorFill = CommonStrings::None;
POPPLER_CONST AnnotColor *fgCol = achar->getBorderColor();
if (fgCol)
{
fgFound = true;
m_graphicStack.top().strokeColor = getAnnotationColor(fgCol);
m_currColorStroke = getAnnotationColor(fgCol);
}
else
{
fgCol = achar->getBackColor();
if (fgCol)
m_graphicStack.top().strokeColor = getAnnotationColor(fgCol);
m_currColorStroke = getAnnotationColor(fgCol);
else
m_graphicStack.top().strokeColor = CommonStrings::None;
m_currColorStroke = CommonStrings::None;
}
}
QString m_currColorText = "Black";
724,9 → 724,9
#endif
ano->draw(gfx, false);
if (!bgFound)
m_graphicStack.top().fillColor = annotOutDev->currColorFill;
m_currColorFill = annotOutDev->currColorFill;
if (!fgFound)
m_graphicStack.top().strokeColor = annotOutDev->currColorStroke;
m_currColorStroke = annotOutDev->currColorStroke;
m_currColorText = annotOutDev->currColorText;
fontSize = annotOutDev->fontSize;
fontName = UnicodeParsedString(annotOutDev->fontName);
734,8 → 734,7
delete gfx;
delete annotOutDev;
}
const auto& graphicState = m_graphicStack.top();
int z = m_doc->itemAdd(PageItem::TextFrame, PageItem::Rectangle, xCoor, yCoor, width, height, 0, graphicState.fillColor, CommonStrings::None);
int z = m_doc->itemAdd(PageItem::TextFrame, PageItem::Rectangle, xCoor, yCoor, width, height, 0, m_currColorFill, CommonStrings::None);
PageItem *ite = m_doc->Items->at(z);
int flg = annota->getFlags();
if (!(flg & 16))
767,7 → 766,7
else if (bsty == AnnotBorder::borderUnderlined)
bsty = 2;
ite->annotation().setBorderStyle(bsty);
ite->annotation().setBorderColor(graphicState.strokeColor);
ite->annotation().setBorderColor(m_currColorStroke);
ite->annotation().setBorderWidth(qRound(brd->getWidth()));
}
else
803,7 → 802,7
ite->annotation().setVis(3);
if (wtyp == Annotation::Button)
{
ite->setFillColor(graphicState.fillColor);
ite->setFillColor(m_currColorFill);
if (achar)
ite->itemText.insertChars(UnicodeParsedString(achar->getNormalCaption()));
else
1371,9 → 1370,10
m_radioMap.clear();
m_radioButtons.clear();
m_actPage = pageNum;
m_graphicStack.clear();
m_groupStack.clear();
pushGroup();
m_currentClipPath = QPainterPath();
m_clipPaths.clear();
}
 
void SlaOutputDev::endPage()
1409,7 → 1409,7
 
void SlaOutputDev::saveState(GfxState *state)
{
m_graphicStack.save();
m_clipPaths.push(m_currentClipPath);
pushGroup();
}
 
1431,7 → 1431,7
PageItem *ite = m_doc->groupObjectsSelection(tmpSel);
if (ite)
{
QPainterPath clippath = m_graphicStack.top().clipPath;
QPainterPath clippath = m_currentClipPath;
clippath.translate(m_doc->currentPage()->xOffset(), m_doc->currentPage()->yOffset());
clippath.translate(-ite->xPos(), -ite->yPos());
ite->PoLine.fromQPainterPath(clippath, true);
1479,8 → 1479,8
}
}
}
m_graphicStack.restore();
if (m_clipPaths.count() != 0)
m_currentClipPath = m_clipPaths.pop();
}
 
void SlaOutputDev::beginTransparencyGroup(GfxState *state, POPPLER_CONST_070 double *bbox, GfxColorSpace * /*blendingColorSpace*/, GBool isolated, GBool knockout, GBool forSoftMask)
1562,7 → 1562,7
ite->FrameType = 3;
if (checkClip())
{
QPainterPath clippath = m_graphicStack.top().clipPath;
QPainterPath clippath = m_currentClipPath;
clippath.translate(m_doc->currentPage()->xOffset(), m_doc->currentPage()->yOffset());
clippath.translate(-ite->xPos(), -ite->yPos());
ite->PoLine.fromQPainterPath(clippath, true);
1617,16 → 1617,14
 
void SlaOutputDev::updateFillColor(GfxState *state)
{
auto& graphicState = m_graphicStack.top();
graphicState.fillShade = 100;
graphicState.fillColor = getColor(state->getFillColorSpace(), state->getFillColor(), &graphicState.fillShade);
m_currFillShade = 100;
m_currColorFill = getColor(state->getFillColorSpace(), state->getFillColor(), &m_currFillShade);
}
 
void SlaOutputDev::updateStrokeColor(GfxState *state)
{
auto& graphicState = m_graphicStack.top();
graphicState.strokeShade = 100;
graphicState.strokeColor = getColor(state->getStrokeColorSpace(), state->getStrokeColor(), &graphicState.strokeShade);
m_currStrokeShade = 100;
m_currColorStroke = getColor(state->getStrokeColorSpace(), state->getStrokeColor(), &m_currStrokeShade);
}
 
void SlaOutputDev::clip(GfxState *state)
1661,29 → 1659,26
// this information.
QPainterPath pathN = out.toQPainterPath(false);
pathN.setFillRule(fillRule);
m_graphicStack.top().clipPath = intersection(pathN, m_graphicStack.top().clipPath);
m_currentClipPath = intersection(pathN, m_currentClipPath);
}
else
m_graphicStack.top().clipPath = out.toQPainterPath(false);
m_currentClipPath = out.toQPainterPath(false);
}
 
void SlaOutputDev::stroke(GfxState *state)
{
// qDebug() << "Stroke";
const double *ctm = state->getCTM();
const double *ctm;
ctm = state->getCTM();
double xCoor = m_doc->currentPage()->xOffset();
double yCoor = m_doc->currentPage()->yOffset();
QString output = convertPath(state->getPath());
getPenState(state);
 
auto& graphicState = m_graphicStack.top();
graphicState.strokeColor = getColor(state->getStrokeColorSpace(), state->getStrokeColor(), &graphicState.strokeShade);
QString output = convertPath(state->getPath());
if ((m_Elements->count() != 0) && (output == Coords)) // Path is the same as in last fill
{
PageItem* ite = m_Elements->last();
ite->setLineColor(graphicState.strokeColor);
ite->setLineShade(graphicState.strokeShade);
ite->setLineColor(m_currColorStroke);
ite->setLineShade(m_currStrokeShade);
ite->setLineEnd(m_lineEnd);
ite->setLineJoin(m_lineJoin);
ite->setLineWidth(state->getTransformedLineWidth());
1690,74 → 1685,76
ite->setDashes(DashValues);
ite->setDashOffset(DashOffset);
ite->setLineTransparency(1.0 - state->getStrokeOpacity());
return;
}
 
FPointArray out;
out.parseSVG(output);
m_ctm = QTransform(ctm[0], ctm[1], ctm[2], ctm[3], ctm[4], ctm[5]);
out.map(m_ctm);
FPoint wh = out.widthHeight();
if ((out.size() <= 3) || ((wh.x() <= 0.0) && (wh.y() <= 0.0)))
return;
 
int z;
if (pathIsClosed)
z = m_doc->itemAdd(PageItem::Polygon, PageItem::Unspecified, xCoor, yCoor, 10, 10, state->getTransformedLineWidth(), CommonStrings::None, graphicState.strokeColor);
else
z = m_doc->itemAdd(PageItem::PolyLine, PageItem::Unspecified, xCoor, yCoor, 10, 10, state->getTransformedLineWidth(), CommonStrings::None, graphicState.strokeColor);
PageItem* ite = m_doc->Items->at(z);
ite->PoLine = out.copy();
ite->ClipEdited = true;
ite->FrameType = 3;
ite->setWidthHeight(wh.x(), wh.y());
m_doc->adjustItemSize(ite);
if (m_Elements->count() != 0)
{
PageItem* lItem = m_Elements->last();
if ((lItem->lineColor() == CommonStrings::None) && (lItem->PoLine == ite->PoLine))
FPointArray out;
out.parseSVG(output);
m_ctm = QTransform(ctm[0], ctm[1], ctm[2], ctm[3], ctm[4], ctm[5]);
out.map(m_ctm);
FPoint wh = out.widthHeight();
if ((out.size() > 3) && ((wh.x() != 0.0) || (wh.y() != 0.0)))
{
lItem->setLineColor(graphicState.strokeColor);
lItem->setLineWidth(state->getTransformedLineWidth());
lItem->setLineShade(graphicState.strokeShade);
lItem->setLineTransparency(1.0 - state->getStrokeOpacity());
lItem->setLineBlendmode(getBlendMode(state));
lItem->setLineEnd(m_lineEnd);
lItem->setLineJoin(m_lineJoin);
lItem->setDashes(DashValues);
lItem->setDashOffset(DashOffset);
lItem->setTextFlowMode(PageItem::TextFlowDisabled);
m_doc->Items->removeAll(ite);
m_currColorStroke = getColor(state->getStrokeColorSpace(), state->getStrokeColor(), &m_currStrokeShade);
int z;
if (pathIsClosed)
z = m_doc->itemAdd(PageItem::Polygon, PageItem::Unspecified, xCoor, yCoor, 10, 10, state->getTransformedLineWidth(), CommonStrings::None, m_currColorStroke);
else
z = m_doc->itemAdd(PageItem::PolyLine, PageItem::Unspecified, xCoor, yCoor, 10, 10, state->getTransformedLineWidth(), CommonStrings::None, m_currColorStroke);
PageItem* ite = m_doc->Items->at(z);
ite->PoLine = out.copy();
ite->ClipEdited = true;
ite->FrameType = 3;
ite->setWidthHeight(wh.x(), wh.y());
m_doc->adjustItemSize(ite);
if (m_Elements->count() != 0)
{
PageItem* lItem = m_Elements->last();
if ((lItem->lineColor() == CommonStrings::None) && (lItem->PoLine == ite->PoLine))
{
lItem->setLineColor(m_currColorStroke);
lItem->setLineWidth(state->getTransformedLineWidth());
lItem->setLineShade(m_currStrokeShade);
lItem->setLineTransparency(1.0 - state->getStrokeOpacity());
lItem->setLineBlendmode(getBlendMode(state));
lItem->setLineEnd(m_lineEnd);
lItem->setLineJoin(m_lineJoin);
lItem->setDashes(DashValues);
lItem->setDashOffset(DashOffset);
lItem->setTextFlowMode(PageItem::TextFlowDisabled);
m_doc->Items->removeAll(ite);
}
else
{
ite->setLineShade(m_currStrokeShade);
ite->setLineTransparency(1.0 - state->getStrokeOpacity());
ite->setLineBlendmode(getBlendMode(state));
ite->setLineEnd(m_lineEnd);
ite->setLineJoin(m_lineJoin);
ite->setDashes(DashValues);
ite->setDashOffset(DashOffset);
ite->setTextFlowMode(PageItem::TextFlowDisabled);
m_Elements->append(ite);
if (m_groupStack.count() != 0)
m_groupStack.top().Items.append(ite);
}
}
else
{
ite->setLineShade(m_currStrokeShade);
ite->setLineTransparency(1.0 - state->getStrokeOpacity());
ite->setLineBlendmode(getBlendMode(state));
ite->setLineEnd(m_lineEnd);
ite->setLineJoin(m_lineJoin);
ite->setDashes(DashValues);
ite->setDashOffset(DashOffset);
ite->setTextFlowMode(PageItem::TextFlowDisabled);
m_Elements->append(ite);
if (m_groupStack.count() != 0)
m_groupStack.top().Items.append(ite);
}
}
else
{
ite->setLineShade(graphicState.strokeShade);
ite->setLineTransparency(1.0 - state->getStrokeOpacity());
ite->setLineBlendmode(getBlendMode(state));
ite->setLineEnd(m_lineEnd);
ite->setLineJoin(m_lineJoin);
ite->setDashes(DashValues);
ite->setDashOffset(DashOffset);
ite->setTextFlowMode(PageItem::TextFlowDisabled);
m_Elements->append(ite);
if (m_groupStack.count() != 0)
m_groupStack.top().Items.append(ite);
}
}
else
{
ite->setLineShade(graphicState.strokeShade);
ite->setLineTransparency(1.0 - state->getStrokeOpacity());
ite->setLineBlendmode(getBlendMode(state));
ite->setLineEnd(m_lineEnd);
ite->setLineJoin(m_lineJoin);
ite->setDashes(DashValues);
ite->setDashOffset(DashOffset);
ite->setTextFlowMode(PageItem::TextFlowDisabled);
m_Elements->append(ite);
if (m_groupStack.count() != 0)
m_groupStack.top().Items.append(ite);
}
}
 
void SlaOutputDev::fill(GfxState *state)
1784,12 → 1781,10
out.parseSVG(output);
out.map(m_ctm);
 
auto& graphicState = m_graphicStack.top();
 
// Clip the new path first and only add it if it is not empty.
QPainterPath path = out.toQPainterPath(false);
path.setFillRule(fillRule);
QPainterPath clippedPath = intersection(graphicState.clipPath, path);
QPainterPath clippedPath = intersection(m_currentClipPath, path);
 
// Undo the rotation of the clipping path as it is rotated together with the item.
double angle = m_ctm.map(QLineF(0, 0, 1, 0)).angle();
1801,17 → 1796,17
QRectF bbox = clippedPath.boundingRect();
if (!clippedPath.isEmpty() && !bbox.isNull())
{
graphicState.fillColor = getColor(state->getFillColorSpace(), state->getFillColor(), &graphicState.fillShade);
m_currColorFill = getColor(state->getFillColorSpace(), state->getFillColor(), &m_currFillShade);
int z;
if (pathIsClosed)
z = m_doc->itemAdd(PageItem::Polygon, PageItem::Unspecified, xCoor, yCoor, 10, 10, 0, graphicState.fillColor, CommonStrings::None);
z = m_doc->itemAdd(PageItem::Polygon, PageItem::Unspecified, xCoor, yCoor, 10, 10, 0, m_currColorFill, CommonStrings::None);
else
z = m_doc->itemAdd(PageItem::PolyLine, PageItem::Unspecified, xCoor, yCoor, 10, 10, 0, graphicState.fillColor, CommonStrings::None);
z = m_doc->itemAdd(PageItem::PolyLine, PageItem::Unspecified, xCoor, yCoor, 10, 10, 0, m_currColorFill, CommonStrings::None);
PageItem* ite = m_doc->Items->at(z);
ite->PoLine.fromQPainterPath(clippedPath, true);
ite->ClipEdited = true;
ite->FrameType = 3;
ite->setFillShade(graphicState.fillShade);
ite->setFillShade(m_currFillShade);
ite->setLineShade(100);
ite->setRotation(-angle);
// Only the new path has to be interpreted according to fillRule. QPainterPath
1891,7 → 1886,7
{
// Apply the clip path early to adjust the gradient vector to the
// smaller boundign box.
out = intersection(m_graphicStack.top().clipPath, out);
out = intersection(m_currentClipPath, out);
crect = out.boundingRect();
}
const double *ctm = state->getCTM();
1926,9 → 1921,7
output += QString("Z");
pathIsClosed = true;
Coords = output;
 
const auto& graphicState = m_graphicStack.top();
int z = m_doc->itemAdd(PageItem::Polygon, PageItem::Rectangle, xCoor + crect.x(), yCoor + crect.y(), bb.width(), bb.height(), 0, graphicState.fillColor, CommonStrings::None);
int z = m_doc->itemAdd(PageItem::Polygon, PageItem::Rectangle, xCoor + crect.x(), yCoor + crect.y(), bb.width(), bb.height(), 0, m_currColorFill, CommonStrings::None);
PageItem* ite = m_doc->Items->at(z);
if (checkClip())
{
1938,7 → 1931,7
ite->setRotation(-angle);
ite->ClipEdited = true;
ite->FrameType = 3;
ite->setFillShade(graphicState.fillShade);
ite->setFillShade(m_currFillShade);
ite->setLineShade(100);
ite->setFillTransparency(1.0 - state->getFillOpacity());
ite->setFillBlendmode(getBlendMode(state));
2013,7 → 2006,6
QString stopColor2 = getColor(color_space, &stop2, &shade);
FillGradient.addStop( ScColorEngine::getShadeColor(m_doc->PageColors[stopColor2], m_doc, shade), 1.0, 0.5, 1.0, stopColor2, shade );
}
 
double r0, x1, y1, r1;
shading->getCoords(&GrStartX, &GrStartY, &r0, &x1, &y1, &r1);
double xmin, ymin, xmax, ymax;
2048,13 → 2040,11
output += QString("Z");
pathIsClosed = true;
Coords = output;
 
const auto& graphicState = m_graphicStack.top();
int z = m_doc->itemAdd(PageItem::Polygon, PageItem::Rectangle, xCoor + crect.x(), yCoor + crect.y(), crect.width(), crect.height(), 0, graphicState.fillColor, CommonStrings::None);
int z = m_doc->itemAdd(PageItem::Polygon, PageItem::Rectangle, xCoor + crect.x(), yCoor + crect.y(), crect.width(), crect.height(), 0, m_currColorFill, CommonStrings::None);
PageItem* ite = m_doc->Items->at(z);
if (checkClip())
{
QPainterPath out = graphicState.clipPath;
QPainterPath out = m_currentClipPath;
out.translate(m_doc->currentPage()->xOffset(), m_doc->currentPage()->yOffset());
out.translate(-ite->xPos(), -ite->yPos());
ite->PoLine.fromQPainterPath(out, true);
2062,7 → 2052,7
}
ite->ClipEdited = true;
ite->FrameType = 3;
ite->setFillShade(graphicState.fillShade);
ite->setFillShade(m_currFillShade);
ite->setLineShade(100);
ite->setFillTransparency(1.0 - state->getFillOpacity());
ite->setFillBlendmode(getBlendMode(state));
2112,12 → 2102,11
Coords = output;
const double *ctm = state->getCTM();
m_ctm = QTransform(ctm[0], ctm[1], ctm[2], ctm[3], ctm[4], ctm[5]);
const auto& graphicState = m_graphicStack.top();
int z = m_doc->itemAdd(PageItem::Polygon, PageItem::Rectangle, xCoor + crect.x(), yCoor + crect.y(), crect.width(), crect.height(), 0, graphicState.fillColor, CommonStrings::None);
int z = m_doc->itemAdd(PageItem::Polygon, PageItem::Rectangle, xCoor + crect.x(), yCoor + crect.y(), crect.width(), crect.height(), 0, m_currColorFill, CommonStrings::None);
PageItem* ite = m_doc->Items->at(z);
ite->ClipEdited = true;
ite->FrameType = 3;
ite->setFillShade(graphicState.fillShade);
ite->setFillShade(m_currFillShade);
ite->setLineShade(100);
ite->setFillEvenOdd(false);
ite->setFillTransparency(1.0 - state->getFillOpacity());
2193,12 → 2182,11
Coords = output;
const double *ctm = state->getCTM();
m_ctm = QTransform(ctm[0], ctm[1], ctm[2], ctm[3], ctm[4], ctm[5]);
const auto& graphicState = m_graphicStack.top();
int z = m_doc->itemAdd(PageItem::Polygon, PageItem::Rectangle, xCoor + crect.x(), yCoor + crect.y(), crect.width(), crect.height(), 0, graphicState.fillColor, CommonStrings::None);
int z = m_doc->itemAdd(PageItem::Polygon, PageItem::Rectangle, xCoor + crect.x(), yCoor + crect.y(), crect.width(), crect.height(), 0, m_currColorFill, CommonStrings::None);
PageItem* ite = m_doc->Items->at(z);
ite->ClipEdited = true;
ite->FrameType = 3;
ite->setFillShade(graphicState.fillShade);
ite->setFillShade(m_currFillShade);
ite->setLineShade(100);
ite->setFillEvenOdd(false);
ite->setFillTransparency(1.0 - state->getFillOpacity());
2360,14 → 2348,14
gfx = new Gfx(pdfDoc, this, resDict, &box, nullptr);
inPattern++;
// Unset the clip path as it is unrelated to the pattern's coordinate space.
QPainterPath savedClip = m_graphicStack.top().clipPath;
m_graphicStack.top().clipPath = QPainterPath();
QPainterPath savedClip = m_currentClipPath;
m_currentClipPath = QPainterPath();
#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(21, 3, 0)
gfx->display(tPat->getContentStream());
#else
gfx->display(str);
#endif
m_graphicStack.top().clipPath = savedClip;
m_currentClipPath = savedClip;
inPattern--;
gElements = m_groupStack.pop();
m_doc->m_Selection->clear();
2422,9 → 2410,7
output += QString("Z");
pathIsClosed = true;
Coords = output;
 
const auto& graphicState = m_graphicStack.top();
int z = m_doc->itemAdd(PageItem::Polygon, PageItem::Rectangle, xCoor + crect.x(), yCoor + crect.y(), crect.width(), crect.height(), 0, graphicState.fillColor, CommonStrings::None);
int z = m_doc->itemAdd(PageItem::Polygon, PageItem::Rectangle, xCoor + crect.x(), yCoor + crect.y(), crect.width(), crect.height(), 0, m_currColorFill, CommonStrings::None);
ite = m_doc->Items->at(z);
 
m_ctm = QTransform(ctm[0], ctm[1], ctm[2], ctm[3], ctm[4], ctm[5]);
2432,7 → 2418,7
ite->setRotation(-angle);
if (checkClip())
{
QPainterPath outline = graphicState.clipPath;
QPainterPath outline = m_currentClipPath;
outline.translate(xCoor - ite->xPos(), yCoor - ite->yPos());
// Undo the rotation of the clipping path as it is rotated together with the item.
QTransform mm;
2443,7 → 2429,7
}
ite->ClipEdited = true;
ite->FrameType = 3;
ite->setFillShade(graphicState.fillShade);
ite->setFillShade(m_currFillShade);
ite->setLineShade(100);
ite->setFillTransparency(1.0 - state->getFillOpacity());
ite->setFillBlendmode(getBlendMode(state));
2516,8 → 2502,7
}
}
}
const auto& graphicState = m_graphicStack.top();
QColor backColor = ScColorEngine::getShadeColorProof(m_doc->PageColors[graphicState.fillColor], m_doc, graphicState.fillShade);
QColor backColor = ScColorEngine::getShadeColorProof(m_doc->PageColors[m_currColorFill], m_doc, m_currFillShade);
QImage res = QImage(width, height, QImage::Format_ARGB32);
res.fill(backColor.rgb());
unsigned char cc, cm, cy, ck;
2800,7 → 2785,7
QPainterPath outline;
outline.addRect(0, 0, 1, 1);
outline = m_ctm.map(outline);
outline = intersection(outline, m_graphicStack.top().clipPath);
outline = intersection(outline, m_currentClipPath);
 
if ((inPattern == 0) && (outline.isEmpty() || outline.boundingRect().isNull()))
return;
3465,9 → 3450,8
ite = m_doc->m_Selection->itemAt(0);
if (!f3e.colored)
{
const auto& graphicState = m_graphicStack.top();
m_doc->itemSelection_SetItemBrush(graphicState.fillColor);
m_doc->itemSelection_SetItemBrushShade(graphicState.fillShade);
m_doc->itemSelection_SetItemBrush(m_currColorFill);
m_doc->itemSelection_SetItemBrushShade(m_currFillShade);
m_doc->itemSelection_SetItemFillTransparency(1.0 - state->getFillOpacity());
m_doc->itemSelection_SetItemFillBlend(getBlendMode(state));
}
3501,7 → 3485,7
// qDebug() << "SlaOutputDev::endTextObject";
if (!m_clipTextPath.isEmpty())
{
m_graphicStack.top().clipPath = intersection(m_graphicStack.top().clipPath, m_clipTextPath);
m_currentClipPath = intersection(m_currentClipPath, m_clipTextPath);
m_clipTextPath = QPainterPath();
}
if (m_groupStack.count() != 0)
3950,10 → 3934,9
bool SlaOutputDev::checkClip()
{
bool ret = false;
const auto& graphicState = m_graphicStack.top();
if (!graphicState.clipPath.isEmpty())
if (!m_currentClipPath.isEmpty())
{
QRectF bbox = graphicState.clipPath.boundingRect();
QRectF bbox = m_currentClipPath.boundingRect();
if ((bbox.width() > 0) && (bbox.height() > 0))
ret = true;
}
3974,12 → 3957,10
if (textRenderingMode == 3)
return;
 
auto& graphicState = m_graphicStack.top();
 
// Fill text rendering modes. See above
if (textRenderingMode == 0 || textRenderingMode == 2 || textRenderingMode == 4 || textRenderingMode == 6)
{
graphicState.fillColor = getColor(state->getFillColorSpace(), state->getFillColor(), &graphicState.fillShade);
m_currColorFill = getColor(state->getFillColorSpace(), state->getFillColor(), &m_currFillShade);
if (textNode->isTextFrame())
{
textNode->setFillTransparency(1.0 - (state->getFillOpacity() > state->getStrokeOpacity() ? state->getFillOpacity() : state->getStrokeOpacity())); //fill colour sets the background colour for the frame not the fill colour fore the text
3987,12 → 3968,12
textNode->setFillColor(CommonStrings::None);
textNode->setLineColor(CommonStrings::None);
textNode->setLineWidth(0);//line width doesn't effect drawing text, it creates a bounding box state->getTransformedLineWidth());
textNode->setFillShade(graphicState.fillShade);
textNode->setFillShade(m_currFillShade);
}
else
{
textNode->setFillColor(graphicState.fillColor);
textNode->setFillShade(graphicState.fillShade);
textNode->setFillColor(m_currColorFill);
textNode->setFillShade(m_currFillShade);
textNode->setFillEvenOdd(false);
textNode->setFillTransparency(1.0 - state->getFillOpacity());
textNode->setFillBlendmode(getBlendMode(state));
4001,7 → 3982,7
// Stroke text rendering modes. See above
if (textRenderingMode == 1 || textRenderingMode == 2 || textRenderingMode == 5 || textRenderingMode == 6)
{
graphicState.strokeColor = getColor(state->getStrokeColorSpace(), state->getStrokeColor(), &graphicState.strokeShade);
m_currColorStroke = getColor(state->getStrokeColorSpace(), state->getStrokeColor(), &m_currStrokeShade);
if (textNode->isTextFrame())
{
//fill color sets the background color for the frame not the fill color fore the text
4011,16 → 3992,16
textNode->setLineColor(CommonStrings::None);
textNode->setLineWidth(0);//line width doesn't effect drawing text, it creates a bounding box state->getTransformedLineWidth());
textNode->setFillBlendmode(getBlendMode(state));
textNode->setFillShade(graphicState.fillShade);
textNode->setFillShade(m_currFillShade);
}
else
{
textNode->setLineColor(graphicState.strokeColor);
textNode->setLineColor(m_currColorStroke);
textNode->setLineWidth(0);//line width doesn't effect drawing text, it creates a bounding box state->getTransformedLineWidth());
textNode->setFillTransparency(1.0 - state->getFillOpacity() > state->getStrokeOpacity() ? state->getFillOpacity() : state->getStrokeOpacity());
textNode->setLineTransparency(1.0); // this sets the transparency of the textbox border and we don't want to see it
textNode->setLineBlendmode(getBlendMode(state));
textNode->setLineShade(graphicState.strokeShade);
textNode->setLineShade(m_currStrokeShade);
}
}
}
/branches/Version15x/Scribus/scribus/plugins/import/pdf/pdftextrecognition.cpp
536,7 → 536,7
textNode->setFillColor(CommonStrings::None);
textNode->setLineColor(CommonStrings::None);
textNode->setLineWidth(0.0);
textNode->setFillShade(m_graphicStack.top().fillShade);
textNode->setFillShade(m_currFillShade);
 
 
/* Oliver Stieber 2020-06-11 Set text matrix... This need to be done so that the global world view that we rite out glyphs to is transformed correctly by the context matrix for each glyph, possibly anyhow.
/branches/Version15x/Scribus/scribus/plugins/import/pdf/slaoutput.h
300,57 → 300,6
Qt::PenJoinStyle m_lineJoin { Qt::MiterJoin };
QList<PageItem*>* m_Elements;
 
class GraphicState
{
public:
QString fillColor { "Black" };
int fillShade { 100 };
QString strokeColor { "Black "};
int strokeShade { 100 };
 
// The currently visible area. If it is empty, everything is visible.
// QPainterPath has the drawback that it sometimes approximates Bezier curves
// by line segments for numerical stability. If available, a better class
// should be used. However, it is important that the used class knows which
// areas are covered and does not rely on external information about the fill
// rule to use.
QPainterPath clipPath;
};
 
class GraphicStack
{
public:
GraphicStack()
{
m_stack.push(GraphicState());
}
 
void clear()
{
m_stack.clear();
m_stack.push(GraphicState());
}
 
void save()
{
m_stack.push(m_stack.top());
}
 
void restore()
{
if (m_stack.count() > 0)
m_stack.pop();
if (m_stack.count() == 0)
m_stack.push(GraphicState());
}
 
GraphicState& top() { return m_stack.top(); }
const GraphicState& top() const { return m_stack.top(); }
 
private:
QStack<GraphicState> m_stack;
};
 
struct groupEntry
{
QList<PageItem*> Items;
363,7 → 312,10
};
 
QStack<groupEntry> m_groupStack;
GraphicStack m_graphicStack;
QString m_currColorFill;
QString m_currColorStroke;
int m_currFillShade { 100 };
int m_currStrokeShade { 100 };
 
private:
void getPenState(GfxState *state);
389,7 → 341,14
QVector<double> DashValues;
double DashOffset { 0.0 };
QString Coords;
 
// The currently visible area. If it is empty, everything is visible.
// QPainterPath has the drawback that it sometimes approximates Bezier curves
// by line segments for numerical stability. If available, a better class
// should be used. However, it is important that the used class knows which
// areas are covered and does not rely on external information about the fill
// rule to use.
QPainterPath m_currentClipPath;
QStack<QPainterPath> m_clipPaths;
// Collect the paths of character glyphs for clipping of a whole text group.
QPainterPath m_clipTextPath;