Subversion Repositories Scribus

Compare Revisions

Ignore whitespace Rev 16765 → Rev 16766

/trunk/Scribus/scribus/plugins/import/pdf/slaoutput.cpp
1708,9 → 1708,156
}
}
 
GBool SlaOutputDev::beginType3Char(GfxState *state, double x, double y, double dx, double dy, CharCode code, Unicode *u, int uLen)
{
double *ctm;
ctm = state->getCTM();
QTransform orig_ctm = QTransform(ctm[0], ctm[1], ctm[2], ctm[3], ctm[4], ctm[5]);
GfxFont *gfxFont;
GfxFontType fontType;
if (!(gfxFont = state->getFont()))
return gTrue;
fontType = gfxFont->getType();
if (fontType != fontType3)
return gTrue;
Ref* fref = gfxFont->getID();
QString fRefID = QString("Font_%1_%2").arg(fref->num).arg(code);
if (m_Font_Pattern_Map.contains(fRefID))
{
QLineF cline = QLineF(0, 0, 1, 0);
QLineF tline = orig_ctm.map(cline);
double xCoor = m_doc->currentPage()->xOffset();
double yCoor = m_doc->currentPage()->yOffset();
ScPattern pat = m_doc->docPatterns[m_Font_Pattern_Map[fRefID]];
QTransform mm;
mm.translate(0, -pat.height * tline.length());
mm = orig_ctm * mm;
int shade = 100;
CurrColorFill = getColor(state->getFillColorSpace(), state->getFillColor(), &shade);
int z = m_doc->itemAdd(PageItem::Polygon, PageItem::Rectangle, xCoor + mm.dx(), yCoor + mm.dy(), pat.width * tline.length(), pat.height * tline.length(), 0, CurrColorFill, CommonStrings::None, true);
PageItem *b = m_doc->Items->at(z);
b->setWidth(pat.width * tline.length());
b->setHeight(pat.height * tline.length());
b->OldB2 = b->width();
b->OldH2 = b->height();
m_doc->RotMode(3);
m_doc->RotateItem(-tline.angle(), b);
m_doc->RotMode(0);
b->setFillShade(shade);
b->setFillEvenOdd(false);
b->setFillTransparency(1.0 - state->getFillOpacity());
b->setFillBlendmode(getBlendMode(state));
b->setLineEnd(PLineEnd);
b->setLineJoin(PLineJoin);
b->setTextFlowMode(PageItem::TextFlowDisabled);
b->setPatternMask(m_Font_Pattern_Map[fRefID]);
b->setMaskTransform(b->width() / pat.width * 100, b->height() / pat.height * 100, 0, 0, 0, 0, 0);
b->setMaskType(3);
m_Elements->append(b);
if (m_groupStack.count() != 0)
{
m_groupStack.top().Items.append(b);
}
return gTrue;
}
else
{
F3Entry f3e;
f3e.ctm = orig_ctm;
f3e.glyphRef = fRefID;
m_F3Stack.push(f3e);
ctm = state->getTextMat();
state->setCTM(ctm[0], ctm[1], ctm[2], ctm[3], 0, 0);
pushGroup();
return gFalse;
}
}
 
void SlaOutputDev::endType3Char(GfxState *state)
{
double *ctm;
ctm = state->getCTM();
groupEntry gElements = m_groupStack.pop();
tmpSel->clear();
if (gElements.Items.count() > 0)
{
for (int dre = 0; dre < gElements.Items.count(); ++dre)
{
tmpSel->addItem(gElements.Items.at(dre), true);
m_Elements->removeAll(gElements.Items.at(dre));
}
PageItem *ite = m_doc->groupObjectsSelection(tmpSel);
ite->setFillTransparency(1.0 - state->getFillOpacity());
ite->setFillBlendmode(getBlendMode(state));
m_doc->m_Selection->addItem(ite, true);
m_doc->itemSelection_FlipV();
m_doc->m_Selection->clear();
ScPattern pat = ScPattern();
pat.setDoc(m_doc);
m_doc->DoDrawing = true;
pat.pattern = ite->DrawObj_toImage(qMax(ite->width(), ite->height()));
pat.xoffset = 0;
pat.yoffset = 0;
m_doc->DoDrawing = false;
pat.width = ite->width();
pat.height = ite->height();
pat.items.append(ite);
m_doc->Items->removeAll(ite);
QString id = QString("Pattern_from_PDF_%1T").arg(m_doc->docPatterns.count() + 1);
m_doc->addPattern(id, pat);
tmpSel->clear();
if (m_F3Stack.count() > 0)
{
F3Entry f3e = m_F3Stack.pop();
m_Font_Pattern_Map.insert(f3e.glyphRef, id);
state->setCTM(f3e.ctm.m11(), f3e.ctm.m12(), f3e.ctm.m21(), f3e.ctm.m22(), f3e.ctm.dx(), f3e.ctm.dy());
QLineF cline = QLineF(0, 0, 1, 0);
QLineF tline = f3e.ctm.map(cline);
double xCoor = m_doc->currentPage()->xOffset();
double yCoor = m_doc->currentPage()->yOffset();
QTransform mm;
mm.translate(0, -pat.height * tline.length());
mm = f3e.ctm * mm;
int shade = 100;
CurrColorFill = getColor(state->getFillColorSpace(), state->getFillColor(), &shade);
int z = m_doc->itemAdd(PageItem::Polygon, PageItem::Rectangle, xCoor + mm.dx(), yCoor + mm.dy(), pat.width * tline.length(), pat.height * tline.length(), 0, CurrColorFill, CommonStrings::None, true);
PageItem *b = m_doc->Items->at(z);
b->setWidth(pat.width * tline.length());
b->setHeight(pat.height * tline.length());
b->OldB2 = b->width();
b->OldH2 = b->height();
m_doc->RotMode(3);
m_doc->RotateItem(-tline.angle(), b);
m_doc->RotMode(0);
b->setFillShade(shade);
b->setFillEvenOdd(false);
b->setFillTransparency(1.0 - state->getFillOpacity());
b->setFillBlendmode(getBlendMode(state));
b->setLineEnd(PLineEnd);
b->setLineJoin(PLineJoin);
b->setTextFlowMode(PageItem::TextFlowDisabled);
b->setPatternMask(id);
b->setMaskTransform(b->width() / pat.width * 100, b->height() / pat.height * 100, 0, 0, 0, 0, 0);
b->setMaskType(3);
m_Elements->append(b);
if (m_groupStack.count() != 0)
{
m_groupStack.top().Items.append(b);
}
}
}
}
 
void SlaOutputDev::type3D0(GfxState * /*state*/, double /*wx*/, double /*wy*/)
{
}
 
void SlaOutputDev::type3D1(GfxState *state, double wx, double wy, double llx, double lly, double urx, double ury)
{
}
 
void SlaOutputDev::beginTextObject(GfxState *state)
{
// qDebug() << "Begin Text Object";
pushGroup();
}
 
/trunk/Scribus/scribus/plugins/import/pdf/slaoutput.h
104,11 → 104,7
//----- path clipping
virtual void clip(GfxState *state);
virtual void eoClip(GfxState *state);
//----- text drawing
virtual void beginTextObject(GfxState *state);
virtual GBool deviceHasTextClip(GfxState *state) { return gFalse; }
virtual void endTextObject(GfxState *state);
virtual void drawChar(GfxState *state, double /*x*/, double /*y*/, double /*dx*/, double /*dy*/, double /*originX*/, double /*originY*/, CharCode /*code*/, int /*nBytes*/, Unicode * /*u*/, int /*uLen*/);
 
// If current colorspace is pattern,
// does this device support text in pattern colorspace?
158,6 → 154,14
 
// virtual void updateFillColor(GfxState *state);
virtual void updateFont(GfxState *state);
//----- text drawing
virtual void beginTextObject(GfxState *state);
virtual void endTextObject(GfxState *state);
virtual void drawChar(GfxState *state, double /*x*/, double /*y*/, double /*dx*/, double /*dy*/, double /*originX*/, double /*originY*/, CharCode /*code*/, int /*nBytes*/, Unicode * /*u*/, int /*uLen*/);
virtual GBool beginType3Char(GfxState * /*state*/, double /*x*/, double /*y*/, double /*dx*/, double /*dy*/, CharCode /*code*/, Unicode * /*u*/, int /*uLen*/);
virtual void endType3Char(GfxState * /*state*/);
virtual void type3D0(GfxState * /*state*/, double /*wx*/, double /*wy*/);
virtual void type3D1(GfxState * /*state*/, double /*wx*/, double /*wy*/, double /*llx*/, double /*lly*/, double /*urx*/, double /*ury*/);
 
private:
void getPenState(GfxState *state);
197,6 → 201,13
QList<PageItem*> *m_Elements;
QStringList *m_importedColors;
QTransform m_ctm;
struct F3Entry
{
QTransform ctm;
QString glyphRef;
};
QStack<F3Entry> m_F3Stack;
QMap<QString, QString> m_Font_Pattern_Map;
int grStackDepth;
int layerNum;
int currentLayer;