mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-04-07 13:55:33 +08:00
Fix bug 72045
This commit is contained in:
@ -1988,6 +1988,8 @@ HRESULT CPdfWriter::AddAnnotField(NSFonts::IApplicationFonts* pAppFonts, CAnnotF
|
|||||||
|
|
||||||
pTextMarkupAnnot->SetSubtype(pPr->GetSubtype());
|
pTextMarkupAnnot->SetSubtype(pPr->GetSubtype());
|
||||||
pTextMarkupAnnot->SetQuadPoints(pPr->GetQuadPoints());
|
pTextMarkupAnnot->SetQuadPoints(pPr->GetQuadPoints());
|
||||||
|
|
||||||
|
pTextMarkupAnnot->SetAP(pPr->GetQuadPoints());
|
||||||
}
|
}
|
||||||
else if (oInfo.IsSquareCircle())
|
else if (oInfo.IsSquareCircle())
|
||||||
{
|
{
|
||||||
|
|||||||
@ -317,27 +317,8 @@ namespace PdfWriter
|
|||||||
return;
|
return;
|
||||||
CAnnotAppearanceObject* pNormal = m_pAppearance->GetNormal();
|
CAnnotAppearanceObject* pNormal = m_pAppearance->GetNormal();
|
||||||
|
|
||||||
CArrayObject* pArray = new CArrayObject();
|
pNormal->AddBBox(GetRect().fLeft, GetRect().fBottom, GetRect().fRight, GetRect().fTop);
|
||||||
if (!pArray)
|
pNormal->AddMatrix(1, 0, 0, 1, -GetRect().fLeft, -GetRect().fBottom);
|
||||||
return;
|
|
||||||
pNormal->Add("BBox", pArray);
|
|
||||||
|
|
||||||
pArray->Add(GetRect().fLeft);
|
|
||||||
pArray->Add(GetRect().fBottom);
|
|
||||||
pArray->Add(GetRect().fRight);
|
|
||||||
pArray->Add(GetRect().fTop);
|
|
||||||
|
|
||||||
pArray = new CArrayObject();
|
|
||||||
if (!pArray)
|
|
||||||
return;
|
|
||||||
|
|
||||||
pNormal->Add("Matrix", pArray);
|
|
||||||
pArray->Add(1);
|
|
||||||
pArray->Add(0);
|
|
||||||
pArray->Add(0);
|
|
||||||
pArray->Add(1);
|
|
||||||
pArray->Add(-GetRect().fLeft);
|
|
||||||
pArray->Add(-GetRect().fBottom);
|
|
||||||
}
|
}
|
||||||
//----------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------
|
||||||
// CMarkupAnnotation
|
// CMarkupAnnotation
|
||||||
@ -1030,27 +1011,8 @@ namespace PdfWriter
|
|||||||
CAnnotAppearanceObject* pNormal = pAppearance->GetNormal();
|
CAnnotAppearanceObject* pNormal = pAppearance->GetNormal();
|
||||||
CStream* pStream = pNormal->GetStream();
|
CStream* pStream = pNormal->GetStream();
|
||||||
|
|
||||||
CArrayObject* pArray = new CArrayObject();
|
pNormal->AddBBox(GetRect().fLeft, GetRect().fBottom, GetRect().fRight, GetRect().fTop);
|
||||||
if (!pArray)
|
pNormal->AddMatrix(1, 0, 0, 1, -GetRect().fLeft, -GetRect().fBottom);
|
||||||
return;
|
|
||||||
pNormal->Add("BBox", pArray);
|
|
||||||
|
|
||||||
pArray->Add(GetRect().fLeft);
|
|
||||||
pArray->Add(GetRect().fBottom);
|
|
||||||
pArray->Add(GetRect().fRight);
|
|
||||||
pArray->Add(GetRect().fTop);
|
|
||||||
|
|
||||||
pArray = new CArrayObject();
|
|
||||||
if (!pArray)
|
|
||||||
return;
|
|
||||||
|
|
||||||
pNormal->Add("Matrix", pArray);
|
|
||||||
pArray->Add(1);
|
|
||||||
pArray->Add(0);
|
|
||||||
pArray->Add(0);
|
|
||||||
pArray->Add(1);
|
|
||||||
pArray->Add(-GetRect().fLeft);
|
|
||||||
pArray->Add(-GetRect().fBottom);
|
|
||||||
|
|
||||||
if (GetBorderType() == EBorderType::Dashed)
|
if (GetBorderType() == EBorderType::Dashed)
|
||||||
pStream->WriteStr(GetBorderDash().c_str());
|
pStream->WriteStr(GetBorderDash().c_str());
|
||||||
@ -1226,6 +1188,121 @@ namespace PdfWriter
|
|||||||
for (int i = 0; i < arrQuadPoints.size(); ++i)
|
for (int i = 0; i < arrQuadPoints.size(); ++i)
|
||||||
pArray->Add(i % 2 == 0 ? (arrQuadPoints[i] + m_dPageX) : (m_dPageH - arrQuadPoints[i]));
|
pArray->Add(i % 2 == 0 ? (arrQuadPoints[i] + m_dPageX) : (m_dPageH - arrQuadPoints[i]));
|
||||||
}
|
}
|
||||||
|
void CTextMarkupAnnotation::SetAP(const std::vector<double>& arrQuadPoints)
|
||||||
|
{
|
||||||
|
CAnnotAppearance* pAP = new CAnnotAppearance(m_pXref, this);
|
||||||
|
Add("AP", pAP);
|
||||||
|
CAnnotAppearanceObject* pN = pAP->GetNormal();
|
||||||
|
CStream* pStream = pN->GetStream();
|
||||||
|
|
||||||
|
pN->AddBBox(GetRect().fLeft, GetRect().fBottom, GetRect().fRight, GetRect().fTop);
|
||||||
|
pN->AddMatrix(1, 0, 0, 1, -GetRect().fLeft, -GetRect().fBottom);
|
||||||
|
|
||||||
|
switch (m_nSubtype)
|
||||||
|
{
|
||||||
|
case AnnotHighLight:
|
||||||
|
{
|
||||||
|
CExtGrState* pExtGrState = m_pDocument->GetExtGState(-1, -1, blendmode_Multiply);
|
||||||
|
const char* sExtGrStateName = m_pDocument->GetFieldsResources()->GetExtGrStateName(pExtGrState);
|
||||||
|
if (sExtGrStateName)
|
||||||
|
{
|
||||||
|
pStream->WriteEscapeName(sExtGrStateName);
|
||||||
|
pStream->WriteStr(" gs\012");
|
||||||
|
}
|
||||||
|
std::string sColor = GetColor(dynamic_cast<CArrayObject*>(Get("C")), false);
|
||||||
|
pStream->WriteStr(sColor.c_str());
|
||||||
|
pStream->WriteChar('\012');
|
||||||
|
pStream->WriteStr("1 w\012");
|
||||||
|
|
||||||
|
for (int i = 0; i < arrQuadPoints.size(); i += 8)
|
||||||
|
{
|
||||||
|
pStream->WriteReal(arrQuadPoints[i] + m_dPageX);
|
||||||
|
pStream->WriteChar(' ');
|
||||||
|
pStream->WriteReal(m_dPageH - arrQuadPoints[i + 1]);
|
||||||
|
pStream->WriteStr(" m\012");
|
||||||
|
|
||||||
|
pStream->WriteReal(arrQuadPoints[i + 2] + m_dPageX);
|
||||||
|
pStream->WriteChar(' ');
|
||||||
|
pStream->WriteReal(m_dPageH - arrQuadPoints[i + 3]);
|
||||||
|
pStream->WriteStr(" l\012");
|
||||||
|
|
||||||
|
pStream->WriteReal(arrQuadPoints[i + 6] + m_dPageX);
|
||||||
|
pStream->WriteChar(' ');
|
||||||
|
pStream->WriteReal(m_dPageH - arrQuadPoints[i + 7]);
|
||||||
|
pStream->WriteStr(" l\012");
|
||||||
|
|
||||||
|
pStream->WriteReal(arrQuadPoints[i + 4] + m_dPageX);
|
||||||
|
pStream->WriteChar(' ');
|
||||||
|
pStream->WriteReal(m_dPageH - arrQuadPoints[i + 5]);
|
||||||
|
pStream->WriteStr(" l\012f\012");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case AnnotSquiggly:
|
||||||
|
case AnnotUnderline:
|
||||||
|
{
|
||||||
|
std::string sColor = GetColor(dynamic_cast<CArrayObject*>(Get("C")), true);
|
||||||
|
pStream->WriteStr(sColor.c_str());
|
||||||
|
pStream->WriteChar('\012');
|
||||||
|
|
||||||
|
for (int i = 0; i < arrQuadPoints.size(); i += 8)
|
||||||
|
{
|
||||||
|
double dX = arrQuadPoints[i + 2] - arrQuadPoints[i];
|
||||||
|
double dY = arrQuadPoints[i + 3] - arrQuadPoints[i + 1];
|
||||||
|
double dAngle = atan2(dY, dX);
|
||||||
|
double dHeight = sqrt(pow(arrQuadPoints[i] - arrQuadPoints[i + 4], 2) + pow(arrQuadPoints[i + 1] - arrQuadPoints[i + 5], 2));
|
||||||
|
double dLineWidth = std::max(0.5, dHeight * 0.075);
|
||||||
|
double dIndentX = sin(dAngle) * dLineWidth * 1.9;
|
||||||
|
double dIndentY = cos(dAngle) * dLineWidth * 1.9;
|
||||||
|
|
||||||
|
pStream->WriteReal(dLineWidth);
|
||||||
|
pStream->WriteStr(" w\012");
|
||||||
|
|
||||||
|
pStream->WriteReal(arrQuadPoints[i + 4] + m_dPageX + dIndentX);
|
||||||
|
pStream->WriteChar(' ');
|
||||||
|
pStream->WriteReal(m_dPageH - arrQuadPoints[i + 5] + dIndentY);
|
||||||
|
pStream->WriteStr(" m\012");
|
||||||
|
|
||||||
|
pStream->WriteReal(arrQuadPoints[i + 6] + m_dPageX + dIndentX);
|
||||||
|
pStream->WriteChar(' ');
|
||||||
|
pStream->WriteReal(m_dPageH - arrQuadPoints[i + 7] + dIndentY);
|
||||||
|
pStream->WriteStr(" l\012S\012");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case AnnotStrikeOut:
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
std::string sColor = GetColor(dynamic_cast<CArrayObject*>(Get("C")), true);
|
||||||
|
pStream->WriteStr(sColor.c_str());
|
||||||
|
pStream->WriteChar('\012');
|
||||||
|
|
||||||
|
for (int i = 0; i < arrQuadPoints.size(); i += 8)
|
||||||
|
{
|
||||||
|
double dX1 = arrQuadPoints[i] + (arrQuadPoints[i + 4] - arrQuadPoints[i]) / 2.0;
|
||||||
|
double dY1 = arrQuadPoints[i + 1] + (arrQuadPoints[i + 5] - arrQuadPoints[i + 1]) / 2.0;
|
||||||
|
double dX2 = arrQuadPoints[i + 2] + (arrQuadPoints[i + 6] - arrQuadPoints[i + 2]) / 2.0;
|
||||||
|
double dY2 = arrQuadPoints[i + 3] + (arrQuadPoints[i + 7] - arrQuadPoints[i + 3]) / 2.0;
|
||||||
|
double dHeight = sqrt(pow(arrQuadPoints[i] - arrQuadPoints[i + 4], 2) + pow(arrQuadPoints[i + 1] - arrQuadPoints[i + 5], 2));
|
||||||
|
double dLineWidth = std::max(0.5, dHeight * 0.075);
|
||||||
|
|
||||||
|
pStream->WriteReal(dLineWidth);
|
||||||
|
pStream->WriteStr(" w\012");
|
||||||
|
|
||||||
|
pStream->WriteReal(dX1 + m_dPageX);
|
||||||
|
pStream->WriteChar(' ');
|
||||||
|
pStream->WriteReal(m_dPageH - dY1);
|
||||||
|
pStream->WriteStr(" m\012");
|
||||||
|
|
||||||
|
pStream->WriteReal(dX2 + m_dPageX);
|
||||||
|
pStream->WriteChar(' ');
|
||||||
|
pStream->WriteReal(m_dPageH - dY2);
|
||||||
|
pStream->WriteStr(" l\012S\012");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
//----------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------
|
||||||
// CSquareCircleAnnotation
|
// CSquareCircleAnnotation
|
||||||
//----------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------
|
||||||
@ -1659,16 +1736,7 @@ namespace PdfWriter
|
|||||||
if (!m_pAppearance)
|
if (!m_pAppearance)
|
||||||
return;
|
return;
|
||||||
CAnnotAppearanceObject* pNormal = m_pAppearance->GetNormal();
|
CAnnotAppearanceObject* pNormal = m_pAppearance->GetNormal();
|
||||||
|
pNormal->AddBBox(0, 0, GetWidth(), GetHeight());
|
||||||
CArrayObject* pArray = new CArrayObject();
|
|
||||||
if (!pArray)
|
|
||||||
return;
|
|
||||||
pNormal->Add("BBox", pArray);
|
|
||||||
|
|
||||||
pArray->Add(0);
|
|
||||||
pArray->Add(0);
|
|
||||||
pArray->Add(GetWidth());
|
|
||||||
pArray->Add(GetHeight());
|
|
||||||
}
|
}
|
||||||
void CWidgetAnnotation::SetEmptyAP()
|
void CWidgetAnnotation::SetEmptyAP()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -320,6 +320,8 @@ namespace PdfWriter
|
|||||||
|
|
||||||
void SetSubtype(BYTE nSubtype);
|
void SetSubtype(BYTE nSubtype);
|
||||||
void SetQuadPoints(const std::vector<double>& arrQuadPoints);
|
void SetQuadPoints(const std::vector<double>& arrQuadPoints);
|
||||||
|
|
||||||
|
void SetAP(const std::vector<double>& arrQuadPoints);
|
||||||
};
|
};
|
||||||
class CSquareCircleAnnotation : public CMarkupAnnotation
|
class CSquareCircleAnnotation : public CMarkupAnnotation
|
||||||
{
|
{
|
||||||
|
|||||||
@ -2623,6 +2623,17 @@ namespace PdfWriter
|
|||||||
pArray->Add(dW);
|
pArray->Add(dW);
|
||||||
pArray->Add(dH);
|
pArray->Add(dH);
|
||||||
}
|
}
|
||||||
|
void CAnnotAppearanceObject::AddMatrix(double sx, double shy, double shx, double sy, double tx, double ty)
|
||||||
|
{
|
||||||
|
CArrayObject* pArray = new CArrayObject();
|
||||||
|
Add("Matrix", pArray);
|
||||||
|
pArray->Add(sx);
|
||||||
|
pArray->Add(shy);
|
||||||
|
pArray->Add(shx);
|
||||||
|
pArray->Add(sy);
|
||||||
|
pArray->Add(tx);
|
||||||
|
pArray->Add(ty);
|
||||||
|
}
|
||||||
void CAnnotAppearanceObject::DrawTextCommentN(const std::string& sColor)
|
void CAnnotAppearanceObject::DrawTextCommentN(const std::string& sColor)
|
||||||
{
|
{
|
||||||
CExtGrState* pExtGrState = m_pAnnot->GetDocument()->GetExtGState(0.6, 0.6);
|
CExtGrState* pExtGrState = m_pAnnot->GetDocument()->GetExtGState(0.6, 0.6);
|
||||||
|
|||||||
@ -391,6 +391,7 @@ namespace PdfWriter
|
|||||||
void DrawTextLine(const double &dX, const double &dY, const std::wstring& wsText);
|
void DrawTextLine(const double &dX, const double &dY, const std::wstring& wsText);
|
||||||
void EndDrawText();
|
void EndDrawText();
|
||||||
void AddBBox(double dX, double dY, double dW, double dH);
|
void AddBBox(double dX, double dY, double dW, double dH);
|
||||||
|
void AddMatrix(double sx, double shy, double shx, double sy, double tx, double ty);
|
||||||
|
|
||||||
void StartDraw(const double& dWidth, const double& dHeight);
|
void StartDraw(const double& dWidth, const double& dHeight);
|
||||||
void StartText(CFontDict* pFont, const double& dFontSize);
|
void StartText(CFontDict* pFont, const double& dFontSize);
|
||||||
|
|||||||
@ -326,7 +326,7 @@ TEST_F(CPdfFileTest, ConvertToRaster)
|
|||||||
LoadFromFile();
|
LoadFromFile();
|
||||||
|
|
||||||
double dPageDpiX, dPageDpiY, dWidth, dHeight;
|
double dPageDpiX, dPageDpiY, dWidth, dHeight;
|
||||||
int i = 3;
|
int i = 0;
|
||||||
//for (i = 0; i < pdfFile->GetPagesCount(); i++)
|
//for (i = 0; i < pdfFile->GetPagesCount(); i++)
|
||||||
{
|
{
|
||||||
pdfFile->GetPageInfo(i, &dWidth, &dHeight, &dPageDpiX, &dPageDpiY);
|
pdfFile->GetPageInfo(i, &dWidth, &dHeight, &dPageDpiX, &dPageDpiY);
|
||||||
|
|||||||
Reference in New Issue
Block a user