コード例 #1
0
void CPDF_StreamContentParser::Handle_CurveTo_123() {
  if (m_Options.m_bTextOnly) {
    return;
  }
  AddPathPoint(GetNumber(5), GetNumber(4), FXPT_BEZIERTO);
  AddPathPoint(GetNumber(3), GetNumber(2), FXPT_BEZIERTO);
  AddPathPoint(GetNumber(1), GetNumber(0), FXPT_BEZIERTO);
}
コード例 #2
0
void CPDF_StreamContentParser::AddPathRect(FX_FLOAT x,
                                           FX_FLOAT y,
                                           FX_FLOAT w,
                                           FX_FLOAT h) {
  AddPathPoint(x, y, FXPT_MOVETO);
  AddPathPoint(x + w, y, FXPT_LINETO);
  AddPathPoint(x + w, y + h, FXPT_LINETO);
  AddPathPoint(x, y + h, FXPT_LINETO);
  AddPathPoint(x, y, FXPT_LINETO | FXPT_CLOSEFIGURE);
}
コード例 #3
0
void CPDF_StreamContentParser::Handle_CloseEOFillStrokePath() {
  if (m_Options.m_bTextOnly) {
    return;
  }
  AddPathPoint(m_PathStartX, m_PathStartY, FXPT_LINETO | FXPT_CLOSEFIGURE);
  AddPathObject(FXFILL_ALTERNATE, TRUE);
}
コード例 #4
0
void CPDF_StreamContentParser::Handle_LineTo() {
  if (m_ParamCount != 2)
    return;

  if (m_Options.m_bTextOnly) {
    return;
  }
  AddPathPoint(GetNumber(1), GetNumber(0), FXPT_LINETO);
}
コード例 #5
0
void CPDF_StreamContentParser::Handle_MoveTo() {
  if (m_ParamCount != 2)
    return;

  if (m_Options.m_bTextOnly) {
    m_pSyntax->SkipPathObject();
    return;
  }
  AddPathPoint(GetNumber(1), GetNumber(0), FXPT_MOVETO);
  ParsePathObject();
}
コード例 #6
0
void CPDF_StreamContentParser::Handle_ClosePath() {
  if (m_Options.m_bTextOnly) {
    return;
  }
  if (m_PathPointCount == 0) {
    return;
  }
  if (m_PathStartX != m_PathCurrentX || m_PathStartY != m_PathCurrentY) {
    AddPathPoint(m_PathStartX, m_PathStartY, FXPT_LINETO | FXPT_CLOSEFIGURE);
  } else if (m_pPathPoints[m_PathPointCount - 1].m_Flag != FXPT_MOVETO) {
    m_pPathPoints[m_PathPointCount - 1].m_Flag |= FXPT_CLOSEFIGURE;
  }
}
コード例 #7
0
void CPDF_StreamContentParser::ParsePathObject()
{
    FX_FLOAT params[6] = {0};
    int nParams = 0;
    int last_pos = m_pSyntax->GetPos();
    while (1) {
        CPDF_StreamParser::SyntaxType type = m_pSyntax->ParseNextElement();
        FX_BOOL bProcessed = TRUE;
        switch (type) {
            case CPDF_StreamParser::EndOfData:
                return;
            case CPDF_StreamParser::Keyword: {
                    int len = m_pSyntax->GetWordSize();
                    if (len == 1) {
                        switch (m_pSyntax->GetWordBuf()[0]) {
                            case 'm':
                                AddPathPoint(params[0], params[1], FXPT_MOVETO);
                                nParams = 0;
                                break;
                            case 'l':
                                AddPathPoint(params[0], params[1], FXPT_LINETO);
                                nParams = 0;
                                break;
                            case 'c':
                                AddPathPoint(params[0], params[1], FXPT_BEZIERTO);
                                AddPathPoint(params[2], params[3], FXPT_BEZIERTO);
                                AddPathPoint(params[4], params[5], FXPT_BEZIERTO);
                                nParams = 0;
                                break;
                            case 'v':
                                AddPathPoint(m_PathCurrentX, m_PathCurrentY, FXPT_BEZIERTO);
                                AddPathPoint(params[0], params[1], FXPT_BEZIERTO);
                                AddPathPoint(params[2], params[3], FXPT_BEZIERTO);
                                nParams = 0;
                                break;
                            case 'y':
                                AddPathPoint(params[0], params[1], FXPT_BEZIERTO);
                                AddPathPoint(params[2], params[3], FXPT_BEZIERTO);
                                AddPathPoint(params[2], params[3], FXPT_BEZIERTO);
                                nParams = 0;
                                break;
                            case 'h':
                                Handle_ClosePath();
                                nParams = 0;
                                break;
                            default:
                                bProcessed = FALSE;
                                break;
                        }
                    } else if (len == 2) {
                        if (m_pSyntax->GetWordBuf()[0] == 'r' && m_pSyntax->GetWordBuf()[1] == 'e') {
                            AddPathRect(params[0], params[1], params[2], params[3]);
                            nParams = 0;
                        } else {
                            bProcessed = FALSE;
                        }
                    } else {
                        bProcessed = FALSE;
                    }
                    if (bProcessed) {
                        last_pos = m_pSyntax->GetPos();
                    }
                    break;
                }
            case CPDF_StreamParser::Number: {
                    if (nParams == 6) {
                        break;
                    }
                    FX_BOOL bInteger;
                    int value;
                    FX_atonum(CFX_ByteStringC(m_pSyntax->GetWordBuf(), m_pSyntax->GetWordSize()), bInteger, &value);
                    params[nParams++] = bInteger ? (FX_FLOAT)value : *(FX_FLOAT*)&value;
                    break;
                }
            default:
                bProcessed = FALSE;
        }
        if (!bProcessed) {
            m_pSyntax->SetPos(last_pos);
            return;
        }
    }
}