From: Michal H. <ms...@gm...> - 2012-01-31 10:41:13
|
Hi, this is another one that needs a bit of clarification. I am not familiar with state updaters enough to see what this actually fixes/enhances. Any further description would be appreciated. --- >From 5ec13261832a2244872ed8bedf847b1697ff138c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eva=20Pe=C5=A1kov=C3=A1?= <car...@gm...> Date: Tue, 31 Jan 2012 11:26:14 +0100 Subject: [PATCH] kernel: Update operator position during printTextUpdate if it is provided as a parameter. [mis...@ho...: make the parameter optional] TODO: What does this fix? --- src/kernel/stateupdater.cc | 19 ++++++++++++++----- src/kernel/stateupdater.h | 2 +- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/kernel/stateupdater.cc b/src/kernel/stateupdater.cc index 656b434..0d1c3de 100644 --- a/src/kernel/stateupdater.cc +++ b/src/kernel/stateupdater.cc @@ -442,12 +442,15 @@ namespace { // This can happen in really damaged pdfs if (state->getFont()) { TextSimpleOperator *txtOp = dynamic_cast<TextSimpleOperator*>(op.get()); + txtOp->clearPositions(); assert(txtOp); // TODO - can we use const GfxFont *? txtOp->setFontData((GfxFont *)state->getFont()); + txtOp->setTransformationMatrix(state->getCTM()); + txtOp->concatTransformationMatrix(state->getTextMat()); std::string rawStr; txtOp->getRawText(rawStr); - StateUpdater::printTextUpdate (state, rawStr, rc); + StateUpdater::printTextUpdate (state, rawStr, rc,txtOp); } // return changed state @@ -508,12 +511,13 @@ namespace { TextSimpleOperator *txtOp = dynamic_cast<TextSimpleOperator*>(op.get()); + txtOp->clearPositions(); assert(txtOp); // TODO can we use const GfxFont *? txtOp->setFontData((GfxFont *)state->getFont()); std::string rawStr; txtOp->getRawText(rawStr); - StateUpdater::printTextUpdate (state, rawStr, rc); + StateUpdater::printTextUpdate (state, rawStr, rc,txtOp); // Set edge of rectangle from actual position on output devices //state->transform(state->getCurX (), state->getCurY(), & rc->xright, & rc->yright); @@ -572,9 +576,10 @@ namespace { break; case pString: - StateUpdater::printTextUpdate (state, getStringFromIProperty (item), & h_rc); + { + StateUpdater::printTextUpdate (state, getStringFromIProperty (item), & h_rc,txtOp); break; - + } default: assert (!"opTJUpdate: Bad object type."); throw ElementBadTypeException ("opTJUpdate: Bad object type."); @@ -758,7 +763,7 @@ namespace { // Actual state (position) updaters // GfxState* -StateUpdater::printTextUpdate (GfxState* state, const std::string& txt, BBox* rc) +StateUpdater::printTextUpdate (GfxState* state, const std::string& txt, BBox* rc, PdfOperator* oper) { const GfxFont *font; int wMode; @@ -950,6 +955,10 @@ StateUpdater::printTextUpdate (GfxState* state, const std::string& txt, BBox* rc originY *= state->getFontSize(); state->textTransformDelta(originX, originY, &tOriginX, &tOriginY); state->shift(tdx, tdy); + if ( oper ) { + TextSimpleOperator *txtOp = dynamic_cast<TextSimpleOperator*>(oper); + txtOp->savePosition(tdx,tdy); + } p += n; len -= n; } diff --git a/src/kernel/stateupdater.h b/src/kernel/stateupdater.h index 6f2235a..a711e48 100644 --- a/src/kernel/stateupdater.h +++ b/src/kernel/stateupdater.h @@ -211,7 +211,7 @@ public: // Helper functions // public: - static GfxState* printTextUpdate (GfxState* state, const std::string& txt, BBox* rc); + static GfxState* printTextUpdate (GfxState* state, const std::string& txt, BBox* rc, PdfOperator* op=NULL); }; -- 1.7.8.3 -- Michal Hocko |