Rotate form

This commit is contained in:
Svetlana Kulikova
2025-05-23 17:04:56 +03:00
parent 59cd16f300
commit f8a901e2d0
7 changed files with 135 additions and 42 deletions

View File

@ -1025,7 +1025,7 @@ int main(int argc, char* argv[])
// SPLIT & MERGE // SPLIT & MERGE
BYTE* pSplitPages = NULL; BYTE* pSplitPages = NULL;
BYTE* pFileMerge = NULL; BYTE* pFileMerge = NULL;
if (true) if (false)
{ {
int nBufferLen = NULL; int nBufferLen = NULL;
BYTE* pBuffer = NULL; BYTE* pBuffer = NULL;

View File

@ -2261,6 +2261,7 @@ HRESULT CPdfWriter::AddAnnotField(NSFonts::IApplicationFonts* pAppFonts, CAnnotF
pWidgetAnnot->SetFlag(pPr->GetFlag()); pWidgetAnnot->SetFlag(pPr->GetFlag());
int nFlags = pPr->GetFlags(); int nFlags = pPr->GetFlags();
int nR = 0;
if (nFlags & (1 << 0)) if (nFlags & (1 << 0))
pWidgetAnnot->SetTU(pPr->GetTU()); pWidgetAnnot->SetTU(pPr->GetTU());
if (nFlags & (1 << 1)) if (nFlags & (1 << 1))
@ -2270,7 +2271,10 @@ HRESULT CPdfWriter::AddAnnotField(NSFonts::IApplicationFonts* pAppFonts, CAnnotF
if (nFlags & (1 << 5)) if (nFlags & (1 << 5))
pWidgetAnnot->SetBC(pPr->GetBC()); pWidgetAnnot->SetBC(pPr->GetBC());
if (nFlags & (1 << 6)) if (nFlags & (1 << 6))
pWidgetAnnot->SetR(pPr->GetR()); {
nR = pPr->GetR();
pWidgetAnnot->SetR(nR);
}
if (nFlags & (1 << 7)) if (nFlags & (1 << 7))
pWidgetAnnot->SetBG(pPr->GetBG()); pWidgetAnnot->SetBG(pPr->GetBG());
if (nFlags & (1 << 8)) if (nFlags & (1 << 8))
@ -2373,6 +2377,7 @@ HRESULT CPdfWriter::AddAnnotField(NSFonts::IApplicationFonts* pAppFonts, CAnnotF
if (!pButtonWidget->Get("DA")) if (!pButtonWidget->Get("DA"))
{ {
PdfWriter::CFontDict* pFont = pFontTT; PdfWriter::CFontDict* pFont = pFontTT;
dFontSize = oInfo.GetWidgetAnnotPr()->GetFontSize();
if (!wsFontName.empty()) if (!wsFontName.empty())
{ {
put_FontName(wsFontName); put_FontName(wsFontName);
@ -2400,7 +2405,7 @@ HRESULT CPdfWriter::AddAnnotField(NSFonts::IApplicationFonts* pAppFonts, CAnnotF
// ВНЕШНИЙ ВИД // ВНЕШНИЙ ВИД
if (!pButtonWidget->Get("AP")) if (!pButtonWidget->Get("AP"))
pButtonWidget->SetAP(); pButtonWidget->SetAP(nR);
if (nFlags & (1 << 9)) if (nFlags & (1 << 9))
{ {
@ -2442,13 +2447,25 @@ HRESULT CPdfWriter::AddAnnotField(NSFonts::IApplicationFonts* pAppFonts, CAnnotF
LONG nLen = 0; LONG nLen = 0;
BYTE* pRender = pPr->GetRender(nLen); BYTE* pRender = pPr->GetRender(nLen);
DrawWidgetAP(pAnnot, pRender, nLen); DrawWidgetAP(pAnnot, pRender, nLen, nR);
PdfWriter::CFontDict* pFont = NULL; PdfWriter::CFontDict* pFont = NULL;
if (m_pFont14) if (m_pFont14)
pFont = m_pFont14; pFont = m_pFont14;
else if (m_pFont) else if (m_pFont)
pFont = m_pDocument->CreateTrueTypeFont(m_pFont); pFont = m_pDocument->CreateTrueTypeFont(m_pFont);
else
{
dFontSize = oInfo.GetWidgetAnnotPr()->GetFontSize();
put_FontName(wsFontName);
put_FontStyle(nStyle);
put_FontSize(dFontSize);
if (m_bNeedUpdateTextFont)
UpdateFont();
if (m_pFont)
pFont = m_pDocument->CreateTrueTypeFont(m_pFont);
}
if (pFont) if (pFont)
pWidgetAnnot->SetDA(pFont, oInfo.GetWidgetAnnotPr()->GetFontSize(), dFontSize, oInfo.GetWidgetAnnotPr()->GetTC()); pWidgetAnnot->SetDA(pFont, oInfo.GetWidgetAnnotPr()->GetFontSize(), dFontSize, oInfo.GetWidgetAnnotPr()->GetTC());
} }
@ -2497,13 +2514,25 @@ HRESULT CPdfWriter::AddAnnotField(NSFonts::IApplicationFonts* pAppFonts, CAnnotF
LONG nLen = 0; LONG nLen = 0;
BYTE* pRender = pPr->GetRender(nLen); BYTE* pRender = pPr->GetRender(nLen);
DrawWidgetAP(pAnnot, pRender, nLen); DrawWidgetAP(pAnnot, pRender, nLen, nR);
PdfWriter::CFontDict* pFont = NULL; PdfWriter::CFontDict* pFont = NULL;
if (m_pFont14) if (m_pFont14)
pFont = m_pFont14; pFont = m_pFont14;
else if (m_pFont) else if (m_pFont)
pFont = m_pDocument->CreateTrueTypeFont(m_pFont); pFont = m_pDocument->CreateTrueTypeFont(m_pFont);
else
{
dFontSize = oInfo.GetWidgetAnnotPr()->GetFontSize();
put_FontName(wsFontName);
put_FontStyle(nStyle);
put_FontSize(dFontSize);
if (m_bNeedUpdateTextFont)
UpdateFont();
if (m_pFont)
pFont = m_pDocument->CreateTrueTypeFont(m_pFont);
}
if (pFont) if (pFont)
pWidgetAnnot->SetDA(pFont, oInfo.GetWidgetAnnotPr()->GetFontSize(), dFontSize, oInfo.GetWidgetAnnotPr()->GetTC()); pWidgetAnnot->SetDA(pFont, oInfo.GetWidgetAnnotPr()->GetFontSize(), dFontSize, oInfo.GetWidgetAnnotPr()->GetTC());
} }
@ -3895,7 +3924,7 @@ PdfWriter::CAnnotAppearanceObject* CPdfWriter::DrawAP(PdfWriter::CAnnotation* pA
m_pDocument->SetCurPage(pFakePage); m_pDocument->SetCurPage(pFakePage);
m_pPage->StartTransform(1, 0, 0, 1, -pAnnot->GetPageX(), 0); m_pPage->StartTransform(1, 0, 0, 1, -pAnnot->GetPageX(), 0);
PdfWriter::CAnnotAppearanceObject* pAP = pAnnot->StartAP(); PdfWriter::CAnnotAppearanceObject* pAP = pAnnot->StartAP(0);
pFakePage->SetStream(pAP->GetStream()); pFakePage->SetStream(pAP->GetStream());
pFakePage->Add("Resources", pAP->Get("Resources")); pFakePage->Add("Resources", pAP->Get("Resources"));
@ -3912,7 +3941,7 @@ PdfWriter::CAnnotAppearanceObject* CPdfWriter::DrawAP(PdfWriter::CAnnotation* pA
return pAP; return pAP;
} }
void CPdfWriter::DrawWidgetAP(PdfWriter::CAnnotation* pA, BYTE* pRender, LONG nLenRender) void CPdfWriter::DrawWidgetAP(PdfWriter::CAnnotation* pA, BYTE* pRender, LONG nLenRender, int nRotate)
{ {
if (!pA || !pRender) if (!pA || !pRender)
return; return;
@ -3923,9 +3952,17 @@ void CPdfWriter::DrawWidgetAP(PdfWriter::CAnnotation* pA, BYTE* pRender, LONG nL
PdfWriter::CPage* pFakePage = new PdfWriter::CPage(m_pDocument); PdfWriter::CPage* pFakePage = new PdfWriter::CPage(m_pDocument);
m_pPage = pFakePage; m_pPage = pFakePage;
m_pDocument->SetCurPage(pFakePage); m_pDocument->SetCurPage(pFakePage);
m_oTransform.Set(1, 0, 0, 1, PT_2_MM(-pAnnot->GetPageX() - pAnnot->GetRect().fLeft), PT_2_MM(pAnnot->GetRect().fBottom)); if (nRotate == 0 || nRotate == 180)
m_oTransform.Set(1, 0, 0, 1, PT_2_MM(-pAnnot->GetPageX() - pAnnot->GetRect().fLeft), PT_2_MM(pAnnot->GetRect().fBottom));
else if (nRotate == 90 || nRotate == 270)
{
double dW = pAnnot->GetWidth();
double dH = pAnnot->GetHeight();
double dDiff = dW / 2.0 - dH / 2.0;
m_oTransform.Set(1, 0, 0, 1, PT_2_MM(-pAnnot->GetPageX() - pAnnot->GetRect().fLeft), PT_2_MM(pAnnot->GetRect().fBottom - dDiff));
}
PdfWriter::CAnnotAppearanceObject* pAP = pAnnot->StartAP(); PdfWriter::CAnnotAppearanceObject* pAP = pAnnot->StartAP(nRotate);
pFakePage->SetStream(pAP->GetStream()); pFakePage->SetStream(pAP->GetStream());
pFakePage->Add("Resources", pAP->Get("Resources")); pFakePage->Add("Resources", pAP->Get("Resources"));
@ -3941,8 +3978,6 @@ void CPdfWriter::DrawWidgetAP(PdfWriter::CAnnotation* pA, BYTE* pRender, LONG nL
pAP->EndDraw(); pAP->EndDraw();
pFakePage->EndMarkedContent(); pFakePage->EndMarkedContent();
pAnnot->APFromFakePage();
m_pPage = pCurPage; m_pPage = pCurPage;
m_pDocument->SetCurPage(pCurPage); m_pDocument->SetCurPage(pCurPage);
RELEASEOBJECT(pFakePage); RELEASEOBJECT(pFakePage);
@ -4011,7 +4046,7 @@ void CPdfWriter::DrawTextWidget(NSFonts::IApplicationFonts* pAppFonts, PdfWriter
m_oLinesManager.CalculateLines(dFontSize, dWidth - dShiftBorder * 4); m_oLinesManager.CalculateLines(dFontSize, dWidth - dShiftBorder * 4);
pTextWidget->StartAP(); pTextWidget->StartAP(0);
unsigned int unLinesCount = m_oLinesManager.GetLinesCount(); unsigned int unLinesCount = m_oLinesManager.GetLinesCount();
double dLineShiftY = dHeight - dShiftBorder * 2 - dLineHeight; double dLineShiftY = dHeight - dShiftBorder * 2 - dLineHeight;
@ -4223,7 +4258,7 @@ void CPdfWriter::DrawChoiceWidget(NSFonts::IApplicationFonts* pAppFonts, PdfWrit
double dKoef = dFontSize / pFontTT->m_dUnitsPerEm; double dKoef = dFontSize / pFontTT->m_dUnitsPerEm;
double dLineHeight = pFontTT->m_dHeight * dKoef; double dLineHeight = pFontTT->m_dHeight * dKoef;
pChoiceWidget->SetListBoxHeight(dLineHeight); pChoiceWidget->SetListBoxHeight(dLineHeight);
pChoiceWidget->StartAP(); pChoiceWidget->StartAP(0);
// double dKoef = dFontSize / pFontTT->m_dUnitsPerEm; // double dKoef = dFontSize / pFontTT->m_dUnitsPerEm;
// double dDescent = std::abs(pFontTT->m_dDescent * dFontSize / pFontTT->m_dUnitsPerEm); // double dDescent = std::abs(pFontTT->m_dDescent * dFontSize / pFontTT->m_dUnitsPerEm);

View File

@ -250,7 +250,7 @@ private:
unsigned char* EncodeGID(const unsigned int& unGID, const unsigned int* pUnicodes, const unsigned int& unUnicodesCount); unsigned char* EncodeGID(const unsigned int& unGID, const unsigned int* pUnicodes, const unsigned int& unUnicodesCount);
std::wstring GetDownloadFile(const std::wstring& sUrl, const std::wstring& wsTempDirectory); std::wstring GetDownloadFile(const std::wstring& sUrl, const std::wstring& wsTempDirectory);
PdfWriter::CAnnotAppearanceObject* DrawAP(PdfWriter::CAnnotation* pAnnot, BYTE* pRender, LONG nLenRender); PdfWriter::CAnnotAppearanceObject* DrawAP(PdfWriter::CAnnotation* pAnnot, BYTE* pRender, LONG nLenRender);
void DrawWidgetAP(PdfWriter::CAnnotation* pAnnot, BYTE* pRender, LONG nLenRender); void DrawWidgetAP(PdfWriter::CAnnotation* pAnnot, BYTE* pRender, LONG nLenRender, int nRotate = 0);
void DrawTextWidget (NSFonts::IApplicationFonts* pAppFonts, PdfWriter::CTextWidget* pTextWidget, const std::wstring& wsValue); void DrawTextWidget (NSFonts::IApplicationFonts* pAppFonts, PdfWriter::CTextWidget* pTextWidget, const std::wstring& wsValue);
void DrawChoiceWidget(NSFonts::IApplicationFonts* pAppFonts, PdfWriter::CChoiceWidget* pChoiceWidget, const std::vector<std::wstring>& arrValue); void DrawChoiceWidget(NSFonts::IApplicationFonts* pAppFonts, PdfWriter::CChoiceWidget* pChoiceWidget, const std::vector<std::wstring>& arrValue);
void DrawButtonWidget(NSFonts::IApplicationFonts* pAppFonts, PdfWriter::CPushButtonWidget* pButtonWidget, BYTE nAP, PdfWriter::CXObject* pForm); void DrawButtonWidget(NSFonts::IApplicationFonts* pAppFonts, PdfWriter::CPushButtonWidget* pButtonWidget, BYTE nAP, PdfWriter::CXObject* pForm);

View File

@ -325,7 +325,7 @@ namespace PdfWriter
} }
return sRes; return sRes;
} }
CAnnotAppearanceObject* CAnnotation::StartAP() CAnnotAppearanceObject* CAnnotation::StartAP(int nRotate)
{ {
m_pAppearance = new CAnnotAppearance(m_pXref, this); m_pAppearance = new CAnnotAppearance(m_pXref, this);
if (!m_pAppearance) if (!m_pAppearance)
@ -1482,13 +1482,6 @@ namespace PdfWriter
CObjectBase* pObj = m_pMK->Get("BC"); CObjectBase* pObj = m_pMK->Get("BC");
return pObj && pObj->GetType() == object_type_ARRAY; return pObj && pObj->GetType() == object_type_ARRAY;
} }
void CWidgetAnnotation::APFromFakePage()
{
if (!m_pAppearance)
return;
CAnnotAppearanceObject* pNormal = m_pAppearance->GetNormal();
pNormal->AddBBox(0, 0, GetWidth(), GetHeight());
}
void CWidgetAnnotation::SetEmptyAP() void CWidgetAnnotation::SetEmptyAP()
{ {
if (!m_pAppearance) if (!m_pAppearance)
@ -1510,12 +1503,39 @@ namespace PdfWriter
CAnnotAppearanceObject* pNormal = m_pAppearance->GetNormal(); CAnnotAppearanceObject* pNormal = m_pAppearance->GetNormal();
pNormal->DrawSimpleText(wsValue, pCodes, unCount, m_pFont, m_dFontSize, dX, dY, 0, 0, 0, NULL, fabs(m_oRect.fRight - m_oRect.fLeft), fabs(m_oRect.fBottom - m_oRect.fTop), ppFonts, pShifts); pNormal->DrawSimpleText(wsValue, pCodes, unCount, m_pFont, m_dFontSize, dX, dY, 0, 0, 0, NULL, fabs(m_oRect.fRight - m_oRect.fLeft), fabs(m_oRect.fBottom - m_oRect.fTop), ppFonts, pShifts);
} }
CAnnotAppearanceObject* CWidgetAnnotation::StartAP() CAnnotAppearanceObject* CWidgetAnnotation::StartAP(int nRotate)
{ {
CAnnotAppearanceObject* pNormal = CAnnotation::StartAP(); CAnnotAppearanceObject* pNormal = CAnnotation::StartAP(nRotate);
m_pResources = dynamic_cast<CResourcesDict*>(pNormal->Get("Resources")); m_pResources = dynamic_cast<CResourcesDict*>(pNormal->Get("Resources"));
pNormal->StartDrawText(m_pFont, m_dFontSize, 0, 0, 0, NULL, fabs(m_oRect.fRight - m_oRect.fLeft), fabs(m_oRect.fBottom - m_oRect.fTop)); double dW = fabs(m_oRect.fRight - m_oRect.fLeft);
double dH = fabs(m_oRect.fBottom - m_oRect.fTop);
if (nRotate == 0 || nRotate == 180)
pNormal->StartDrawText(m_pFont, m_dFontSize, 0, 0, 0, NULL, dW, dH);
else
pNormal->StartDrawText(m_pFont, m_dFontSize, 0, 0, 0, NULL, dH, dW);
pNormal->EndText(); pNormal->EndText();
if (nRotate == 0)
{
pNormal->AddBBox(0, 0, dW, dH);
pNormal->AddMatrix(1, 0, 0, 1, 0, 0);
}
if (nRotate == 90)
{
pNormal->AddBBox(0, 0, dH, dW);
pNormal->AddMatrix(0, 1, -1, 0, dW, 0);
}
else if (nRotate == 180)
{
pNormal->AddBBox(0, 0, dW, dH);
pNormal->AddMatrix(-1, 0, 0, -1, dW, dH);
}
else if (nRotate == 270)
{
pNormal->AddBBox(0, 0, dH, dW);
pNormal->AddMatrix(0, -1, 1, 0, 0, dH);
}
return pNormal; return pNormal;
} }
void CWidgetAnnotation::AddLineToAP(const double& dX, const double& dY, unsigned short* pCodes, const unsigned int& unCodesCount, CFontCidTrueType** ppFonts, const double* pShifts) void CWidgetAnnotation::AddLineToAP(const double& dX, const double& dY, unsigned short* pCodes, const unsigned int& unCodesCount, CFontCidTrueType** ppFonts, const double* pShifts)
@ -1916,7 +1936,7 @@ namespace PdfWriter
{ {
return m_sAP_N_Yes.empty(); return m_sAP_N_Yes.empty();
} }
void CCheckBoxWidget::SetAP() void CCheckBoxWidget::SetAP(int nRotate)
{ {
if (!m_pAP) if (!m_pAP)
{ {
@ -1926,17 +1946,52 @@ namespace PdfWriter
if (m_nStyle == ECheckBoxStyle::Circle && m_nSubtype == WidgetRadiobutton) if (m_nStyle == ECheckBoxStyle::Circle && m_nSubtype == WidgetRadiobutton)
{ {
m_pAP->GetYesN()->DrawCheckBoxCircle(true, true); m_pAP->GetYesN()->DrawCheckBoxCircle(nRotate, true, true);
m_pAP->GetOffN()->DrawCheckBoxCircle(false, true); m_pAP->GetOffN()->DrawCheckBoxCircle(nRotate, false, true);
m_pAP->GetYesD()->DrawCheckBoxCircle(true, false); m_pAP->GetYesD()->DrawCheckBoxCircle(nRotate, true, false);
m_pAP->GetOffD()->DrawCheckBoxCircle(false, false); m_pAP->GetOffD()->DrawCheckBoxCircle(nRotate, false, false);
} }
else else
{ {
m_pAP->GetYesN()->DrawCheckBoxSquare(true, true); m_pAP->GetYesN()->DrawCheckBoxSquare(nRotate, true, true);
m_pAP->GetOffN()->DrawCheckBoxSquare(false, true); m_pAP->GetOffN()->DrawCheckBoxSquare(nRotate, false, true);
m_pAP->GetYesD()->DrawCheckBoxSquare(true, false); m_pAP->GetYesD()->DrawCheckBoxSquare(nRotate, true, false);
m_pAP->GetOffD()->DrawCheckBoxSquare(false, false); m_pAP->GetOffD()->DrawCheckBoxSquare(nRotate, false, false);
}
if (nRotate != 0)
{
double dW = fabs(m_oRect.fRight - m_oRect.fLeft);
double dH = fabs(m_oRect.fBottom - m_oRect.fTop);
if (nRotate == 90 || nRotate == 270)
{
m_pAP->GetYesN()->AddBBox(0, 0, dH, dW);
m_pAP->GetOffN()->AddBBox(0, 0, dH, dW);
m_pAP->GetYesD()->AddBBox(0, 0, dH, dW);
m_pAP->GetOffD()->AddBBox(0, 0, dH, dW);
}
if (nRotate == 90)
{
m_pAP->GetYesN()->AddMatrix(0, 1, -1, 0, dW, 0);
m_pAP->GetOffN()->AddMatrix(0, 1, -1, 0, dW, 0);
m_pAP->GetYesD()->AddMatrix(0, 1, -1, 0, dW, 0);
m_pAP->GetOffD()->AddMatrix(0, 1, -1, 0, dW, 0);
}
if (nRotate == 180)
{
m_pAP->GetYesN()->AddMatrix(-1, 0, 0, -1, dW, dH);
m_pAP->GetOffN()->AddMatrix(-1, 0, 0, -1, dW, dH);
m_pAP->GetYesD()->AddMatrix(-1, 0, 0, -1, dW, dH);
m_pAP->GetOffD()->AddMatrix(-1, 0, 0, -1, dW, dH);
}
if (nRotate == 270)
{
m_pAP->GetYesN()->AddMatrix(0, -1, 1, 0, 0, dH);
m_pAP->GetOffN()->AddMatrix(0, -1, 1, 0, 0, dH);
m_pAP->GetYesD()->AddMatrix(0, -1, 1, 0, 0, dH);
m_pAP->GetOffD()->AddMatrix(0, -1, 1, 0, 0, dH);
}
} }
} }
std::string CCheckBoxWidget::Yes() std::string CCheckBoxWidget::Yes()

View File

@ -193,7 +193,7 @@ namespace PdfWriter
void SetC(const std::vector<double>& arrC); void SetC(const std::vector<double>& arrC);
void APFromFakePage(); void APFromFakePage();
virtual CAnnotAppearanceObject* StartAP(); virtual CAnnotAppearanceObject* StartAP(int nRotate);
TRect& GetRect() { return m_oRect; } TRect& GetRect() { return m_oRect; }
void SetXref(CXref* pXref) { m_pXref = pXref; } void SetXref(CXref* pXref) { m_pXref = pXref; }
virtual void SetDocument(CDocument* pDocument); virtual void SetDocument(CDocument* pDocument);
@ -479,10 +479,9 @@ namespace PdfWriter
bool HaveBC(); bool HaveBC();
BYTE GetQ() { return m_nQ; } BYTE GetQ() { return m_nQ; }
void APFromFakePage();
void SetEmptyAP(); void SetEmptyAP();
void SetAP(const std::wstring& wsValue, unsigned short* pCodes, unsigned int unCount, double dX, double dY, CFontCidTrueType** ppFonts, double* pShifts); void SetAP(const std::wstring& wsValue, unsigned short* pCodes, unsigned int unCount, double dX, double dY, CFontCidTrueType** ppFonts, double* pShifts);
virtual CAnnotAppearanceObject* StartAP() override; virtual CAnnotAppearanceObject* StartAP(int nRotate) override;
void AddLineToAP(const double& dX, const double& dY, unsigned short* pCodes, const unsigned int& unCodesCount, CFontCidTrueType** ppFonts = NULL, const double* pShifts = NULL); void AddLineToAP(const double& dX, const double& dY, unsigned short* pCodes, const unsigned int& unCodesCount, CFontCidTrueType** ppFonts = NULL, const double* pShifts = NULL);
void EndAP(); void EndAP();
}; };
@ -546,7 +545,7 @@ namespace PdfWriter
bool NeedAP_N_Yes(); bool NeedAP_N_Yes();
void RenameAP_N_Yes(const std::wstring& wsAP_N_Yes); void RenameAP_N_Yes(const std::wstring& wsAP_N_Yes);
virtual void SetFlag (const int& nFlag); virtual void SetFlag (const int& nFlag);
void SetAP(); void SetAP(int nRotate);
void SwitchAP(const std::string& sV, int nI = -1); void SwitchAP(const std::string& sV, int nI = -1);
std::string GetTC(bool bCAPS); std::string GetTC(bool bCAPS);

View File

@ -3163,7 +3163,7 @@ namespace PdfWriter
CLineAnnotation* pAnnot = (CLineAnnotation*)m_pAnnot; CLineAnnotation* pAnnot = (CLineAnnotation*)m_pAnnot;
DrawLineArrow(m_pStream, dBorderSize, pAnnot->dL[0], pAnnot->dL[1], pAnnot->dL[2], pAnnot->dL[3], pAnnot->m_nLE1, pAnnot->m_nLE2, dLL, dLLE, dLLO); DrawLineArrow(m_pStream, dBorderSize, pAnnot->dL[0], pAnnot->dL[1], pAnnot->dL[2], pAnnot->dL[3], pAnnot->m_nLE1, pAnnot->m_nLE2, dLL, dLLE, dLLO);
} }
void CAnnotAppearanceObject::DrawCheckBoxCircle(bool bSet, bool bN) void CAnnotAppearanceObject::DrawCheckBoxCircle(int nRotate, bool bSet, bool bN)
{ {
CCheckBoxWidget* pAnnot = dynamic_cast<CCheckBoxWidget*>(m_pAnnot); CCheckBoxWidget* pAnnot = dynamic_cast<CCheckBoxWidget*>(m_pAnnot);
if (!pAnnot) if (!pAnnot)
@ -3178,6 +3178,8 @@ namespace PdfWriter
} }
double dW = m_pAnnot->GetRect().fRight - m_pAnnot->GetRect().fLeft; double dW = m_pAnnot->GetRect().fRight - m_pAnnot->GetRect().fLeft;
double dH = std::abs(m_pAnnot->GetRect().fBottom - m_pAnnot->GetRect().fTop); double dH = std::abs(m_pAnnot->GetRect().fBottom - m_pAnnot->GetRect().fTop);
if (nRotate == 90 || nRotate == 270)
std::swap(dW, dH);
double dCX = dW / 2.0, dCY = dH / 2.0; double dCX = dW / 2.0, dCY = dH / 2.0;
double dR = std::min(dW, dH) / 2.0; double dR = std::min(dW, dH) / 2.0;
@ -3274,7 +3276,7 @@ namespace PdfWriter
StreamWriteCircle(m_pStream, 0, 0, dR / 2.0 - dShift); StreamWriteCircle(m_pStream, 0, 0, dR / 2.0 - dShift);
m_pStream->WriteStr("f\012Q\012"); m_pStream->WriteStr("f\012Q\012");
} }
void CAnnotAppearanceObject::DrawCheckBoxSquare(bool bSet, bool bN) void CAnnotAppearanceObject::DrawCheckBoxSquare(int nRotate, bool bSet, bool bN)
{ {
CCheckBoxWidget* pAnnot = dynamic_cast<CCheckBoxWidget*>(m_pAnnot); CCheckBoxWidget* pAnnot = dynamic_cast<CCheckBoxWidget*>(m_pAnnot);
if (!pAnnot) if (!pAnnot)
@ -3289,6 +3291,8 @@ namespace PdfWriter
} }
double dW = m_pAnnot->GetRect().fRight - m_pAnnot->GetRect().fLeft; double dW = m_pAnnot->GetRect().fRight - m_pAnnot->GetRect().fLeft;
double dH = std::abs(m_pAnnot->GetRect().fBottom - m_pAnnot->GetRect().fTop); double dH = std::abs(m_pAnnot->GetRect().fBottom - m_pAnnot->GetRect().fTop);
if (nRotate == 90 || nRotate == 270)
std::swap(dW, dH);
// Задний фон // Задний фон
m_pStream->WriteStr("q\012"); m_pStream->WriteStr("q\012");

View File

@ -420,8 +420,8 @@ namespace PdfWriter
void DrawLine(); void DrawLine();
void DrawCheckBoxCircle(bool bSet, bool bN); void DrawCheckBoxCircle(int nRotate, bool bSet, bool bN);
void DrawCheckBoxSquare(bool bSet, bool bN); void DrawCheckBoxSquare(int nRotate, bool bSet, bool bN);
CStream* GetStream() const { return m_pStream; } CStream* GetStream() const { return m_pStream; }
CFontDict* GetFont() { return m_pFont; } CFontDict* GetFont() { return m_pFont; }