mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-02-10 18:05:41 +08:00
Fix Dash Pattern for drawingfile
This commit is contained in:
@ -49,10 +49,8 @@ CAnnotFieldInfo::CAnnotFieldInfo() : IAdvancedCommand(AdvancedCommandType::Annot
|
||||
m_pBE.first = 0;
|
||||
m_pBE.second = 0.0;
|
||||
|
||||
m_oBorder.nType = 0;
|
||||
m_oBorder.dWidth = 0.0;
|
||||
m_oBorder.dDashesAlternating = 0.0;
|
||||
m_oBorder.dGaps = 0.0;
|
||||
m_oBorder.nType = 0;
|
||||
m_oBorder.dWidth = 0.0;
|
||||
|
||||
m_pMarkupPr = NULL;
|
||||
m_pTextPr = NULL;
|
||||
@ -215,12 +213,11 @@ void CAnnotFieldInfo::GetBounds(double& dX1, double& dY1, double& dX2, double& d
|
||||
dX2 = m_dX2;
|
||||
dY2 = m_dY2;
|
||||
}
|
||||
void CAnnotFieldInfo::GetBorder(BYTE& nType, double& dWidth, double& dDashesAlternating, double& dGaps)
|
||||
void CAnnotFieldInfo::GetBorder(BYTE& nType, double& dWidth, std::vector<double>& arrDash)
|
||||
{
|
||||
nType = m_oBorder.nType;
|
||||
dWidth = m_oBorder.dWidth;
|
||||
dDashesAlternating = m_oBorder.dDashesAlternating;
|
||||
dGaps = m_oBorder.dGaps;
|
||||
arrDash = m_oBorder.arrDash;
|
||||
}
|
||||
|
||||
// Common
|
||||
@ -460,13 +457,9 @@ bool CAnnotFieldInfo::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMeta
|
||||
{
|
||||
m_oBorder.nType = pReader->ReadByte();
|
||||
m_oBorder.dWidth = pReader->ReadDouble();
|
||||
m_oBorder.dDashesAlternating = 0.0;
|
||||
m_oBorder.dGaps = 0.0;
|
||||
if (m_oBorder.nType == 2)
|
||||
{
|
||||
m_oBorder.dDashesAlternating = pReader->ReadDouble();
|
||||
m_oBorder.dGaps = pReader->ReadDouble();
|
||||
}
|
||||
int n = pReader->ReadInt();
|
||||
for (int i = 0; i < n; ++i)
|
||||
m_oBorder.arrDash.push_back(pReader->ReadDouble());
|
||||
}
|
||||
if (nFlags & (1 << 5))
|
||||
m_wsLM = pReader->ReadString();
|
||||
|
||||
@ -380,8 +380,7 @@ private:
|
||||
{
|
||||
BYTE nType;
|
||||
double dWidth;
|
||||
double dDashesAlternating;
|
||||
double dGaps;
|
||||
std::vector<double> arrDash;
|
||||
};
|
||||
|
||||
public:
|
||||
@ -392,7 +391,7 @@ public:
|
||||
bool IsValid() const;
|
||||
|
||||
void GetBounds(double& dX1, double& dY1, double& dX2, double& dY2) const;
|
||||
void GetBorder(BYTE& nType, double& dWidth, double& dDashesAlternating, double& dGaps);
|
||||
void GetBorder(BYTE& nType, double& dWidth, std::vector<double>& arrDash);
|
||||
int GetFlag() const { return m_nFlag; }
|
||||
int GetID() const { return m_nID; }
|
||||
int GetAnnotFlag() const { return m_nAnnotFlag; }
|
||||
|
||||
@ -563,9 +563,10 @@
|
||||
// Border Dash Pattern
|
||||
if (rec["border"] == 2)
|
||||
{
|
||||
let n = reader.readInt();
|
||||
rec["dashed"] = [];
|
||||
rec["dashed"].push(reader.readDouble());
|
||||
rec["dashed"].push(reader.readDouble());
|
||||
for (let i = 0; i < n; ++i)
|
||||
rec["dashed"].push(reader.readDouble());
|
||||
}
|
||||
}
|
||||
// Date of last change - M
|
||||
|
||||
@ -242,13 +242,17 @@ void ReadAnnot(BYTE* pWidgets, int& i)
|
||||
|
||||
if (nBorderType == 2)
|
||||
{
|
||||
nPathLength = READ_INT(pWidgets + i);
|
||||
int nDash = READ_INT(pWidgets + i);
|
||||
i += 4;
|
||||
std::cout << "Dash Pattern " << (double)nPathLength / 100.0 << " ";
|
||||
std::cout << "Dash Pattern";
|
||||
|
||||
nPathLength = READ_INT(pWidgets + i);
|
||||
i += 4;
|
||||
std::cout << (double)nPathLength / 100.0 << ", ";
|
||||
for (int j = 0; j < nDash; ++j)
|
||||
{
|
||||
nPathLength = READ_INT(pWidgets + i);
|
||||
i += 4;
|
||||
std::cout << " " << (double)nPathLength / 100.0;
|
||||
}
|
||||
std::cout << ", ";
|
||||
}
|
||||
}
|
||||
if (nFlags & (1 << 5))
|
||||
|
||||
@ -1056,7 +1056,7 @@ HRESULT CPdfWriter::AddHyperlink(const double& dX, const double& dY, const doubl
|
||||
NSUnicodeConverter::CUnicodeConverter conv;
|
||||
PdfWriter::CAnnotation* pAnnot = m_pDocument->CreateUriLinkAnnot(PdfWriter::TRect(MM_2_PT(dX), m_pPage->GetHeight() - MM_2_PT(dY), MM_2_PT(dX + dW), m_pPage->GetHeight() - MM_2_PT(dY + dH)), conv.SASLprepToUtf8(wsUrl).c_str());
|
||||
m_pPage->AddAnnotation(pAnnot);
|
||||
pAnnot->SetBorder(0, 0);
|
||||
pAnnot->SetBorder(0, 0, {});
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CPdfWriter::AddLink(const double& dX, const double& dY, const double& dW, const double& dH, const double& dDestX, const double& dDestY, const int& nPage)
|
||||
@ -1805,9 +1805,10 @@ HRESULT CPdfWriter::AddAnnotField(NSFonts::IApplicationFonts* pAppFonts, CAnnotF
|
||||
if (nFlags & (1 << 4))
|
||||
{
|
||||
BYTE nType;
|
||||
double dWidth, d1, d2;
|
||||
oInfo.GetBorder(nType, dWidth, d1, d2);
|
||||
pAnnot->SetBorder(nType, dWidth, d1, d2);
|
||||
double dWidth;
|
||||
std::vector<double> arrDash;
|
||||
oInfo.GetBorder(nType, dWidth, arrDash);
|
||||
pAnnot->SetBorder(nType, dWidth, arrDash);
|
||||
}
|
||||
if (nFlags & (1 << 5))
|
||||
pAnnot->SetLM(oInfo.GetLM());
|
||||
@ -2063,6 +2064,73 @@ HRESULT CPdfWriter::AddAnnotField(NSFonts::IApplicationFonts* pAppFonts, CAnnotF
|
||||
|
||||
switch (pAction->nActionType)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
PdfWriter::CActionGoTo* ppA = (PdfWriter::CActionGoTo*)pA;
|
||||
PdfWriter::CPage* pPageD = m_pDocument->GetPage(pAction->nInt1);
|
||||
PdfWriter::CDestination* pDest = m_pDocument->CreateDestination(pAction->nInt1);
|
||||
ppA->SetDestination(pDest);
|
||||
|
||||
switch (pAction->nKind)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
pDest->SetXYZ(pAction->dD[0], pAction->dD[1], pAction->dD[2]);
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
pDest->SetFit();
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
pDest->SetFitH(pAction->dD[1]);
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
pDest->SetFitV(pAction->dD[0]);
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
pDest->SetFitR(pAction->dD[0], pAction->dD[1], pAction->dD[2], pAction->dD[3]);
|
||||
break;
|
||||
}
|
||||
case 5:
|
||||
{
|
||||
pDest->SetFitB();
|
||||
break;
|
||||
}
|
||||
case 6:
|
||||
{
|
||||
pDest->SetFitBH(pAction->dD[1]);
|
||||
break;
|
||||
}
|
||||
case 7:
|
||||
{
|
||||
pDest->SetFitBV(pAction->dD[0]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
case 6:
|
||||
{
|
||||
PdfWriter::CActionURI* ppA = (PdfWriter::CActionURI*)pA;
|
||||
ppA->SetURI(pAction->wsStr1);
|
||||
}
|
||||
case 9:
|
||||
{
|
||||
PdfWriter::CActionHide* ppA = (PdfWriter::CActionHide*)pA;
|
||||
ppA->SetH(pAction->nKind);
|
||||
ppA->SetT(pAction->arrStr);
|
||||
}
|
||||
case 10:
|
||||
{
|
||||
PdfWriter::CActionNamed* ppA = (PdfWriter::CActionNamed*)pA;
|
||||
ppA->SetN(pAction->wsStr1);
|
||||
}
|
||||
case 12:
|
||||
{
|
||||
PdfWriter::CActionResetForm* ppA = (PdfWriter::CActionResetForm*)pA;
|
||||
@ -2824,7 +2892,7 @@ void CPdfWriter::AddLink(PdfWriter::CPage* pPage, const double& dX, const double
|
||||
PdfWriter::CAnnotation* pAnnot = m_pDocument->CreateLinkAnnot(PdfWriter::TRect(MM_2_PT(dX), pPage->GetHeight() - MM_2_PT(dY), MM_2_PT(dX + dW), pPage->GetHeight() - MM_2_PT(dY + dH)), pDestination);
|
||||
if (pAnnot && pPage)
|
||||
pPage->AddAnnotation(pAnnot);
|
||||
pAnnot->SetBorder(0, 0);
|
||||
pAnnot->SetBorder(0, 0, {});
|
||||
}
|
||||
bool CPdfWriter::IsValid()
|
||||
{
|
||||
|
||||
@ -1922,10 +1922,13 @@ CAnnot::CBorderType* CAnnot::getBorder(Object* oBorder, bool bBSorBorder)
|
||||
oV.free();
|
||||
if (oBorder->dictLookup("D", &oV)->isArray())
|
||||
{
|
||||
Object oObj2;
|
||||
ARR_GET_NUM(oV, 0, pBorderType->dDashesAlternating);
|
||||
pBorderType->dGaps = pBorderType->dDashesAlternating;
|
||||
ARR_GET_NUM(oV, 1, pBorderType->dGaps);
|
||||
for (int j = 0; j < oV.arrayGetLength(); ++j)
|
||||
{
|
||||
Object oObj2;
|
||||
if (oV.arrayGet(j, &oObj2)->isNum())
|
||||
pBorderType->arrDash.push_back(oObj2.getNum());
|
||||
oObj2.free();
|
||||
}
|
||||
}
|
||||
oV.free();
|
||||
}
|
||||
@ -1940,8 +1943,13 @@ CAnnot::CBorderType* CAnnot::getBorder(Object* oBorder, bool bBSorBorder)
|
||||
if (oBorder->arrayGetLength() > 3 && oBorder->arrayGet(3, &oObj)->isArray() && oObj.arrayGetLength() > 1)
|
||||
{
|
||||
pBorderType->nType = annotBorderDashed;
|
||||
ARR_GET_NUM(oObj, 0, pBorderType->dDashesAlternating);
|
||||
ARR_GET_NUM(oObj, 1, pBorderType->dGaps);
|
||||
for (int j = 0; j < oObj.arrayGetLength(); ++j)
|
||||
{
|
||||
Object oObj2;
|
||||
if (oObj.arrayGet(j, &oObj2)->isNum())
|
||||
pBorderType->arrDash.push_back(oObj2.getNum());
|
||||
oObj2.free();
|
||||
}
|
||||
}
|
||||
oObj.free();
|
||||
}
|
||||
@ -2316,8 +2324,9 @@ void CAnnot::CBorderType::ToWASM(NSWasm::CData& oRes)
|
||||
oRes.AddDouble(dWidth);
|
||||
if (nType == annotBorderDashed)
|
||||
{
|
||||
oRes.AddDouble(dDashesAlternating);
|
||||
oRes.AddDouble(dGaps);
|
||||
oRes.AddInt(arrDash.size());
|
||||
for (int i = 0; i < arrDash.size(); ++i)
|
||||
oRes.AddDouble(arrDash[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -178,16 +178,13 @@ private:
|
||||
{
|
||||
nType = 0;
|
||||
dWidth = 1;
|
||||
dDashesAlternating = 3;
|
||||
dGaps = 3;
|
||||
}
|
||||
|
||||
void ToWASM(NSWasm::CData& oRes);
|
||||
|
||||
BYTE nType;
|
||||
double dWidth;
|
||||
double dDashesAlternating;
|
||||
double dGaps;
|
||||
std::vector<double> arrDash;
|
||||
};
|
||||
CBorderType* getBorder(Object* oBorder, bool bBSorBorder);
|
||||
|
||||
|
||||
@ -70,6 +70,60 @@ namespace PdfWriter
|
||||
"Check", "Checkmark", "Circle", "Comment", "Cross", "CrossHairs", "Help", "Insert", "Key", "NewParagraph", "Note", "Paragraph", "RightArrow", "RightPointer", "Star", "UpArrow", "UpLeftArrow"
|
||||
};
|
||||
|
||||
void AddToVectorD(CDictObject* pObj, const std::string& sName, const std::vector<double>& arrV)
|
||||
{
|
||||
CArrayObject* pArray = new CArrayObject();
|
||||
if (!pArray)
|
||||
return;
|
||||
|
||||
pObj->Add(sName, pArray);
|
||||
|
||||
for (const double& dV : arrV)
|
||||
pArray->Add(dV);
|
||||
}
|
||||
std::string AddLE(const BYTE& nLE)
|
||||
{
|
||||
std::string sValue;
|
||||
switch (nLE)
|
||||
{
|
||||
case 0:
|
||||
{ sValue = "Square"; break; }
|
||||
case 1:
|
||||
{ sValue = "Circle"; break; }
|
||||
case 2:
|
||||
{ sValue = "Diamond"; break; }
|
||||
case 3:
|
||||
{ sValue = "OpenArrow"; break; }
|
||||
case 4:
|
||||
{ sValue = "ClosedArrow"; break; }
|
||||
case 5:
|
||||
{ sValue = "None"; break; }
|
||||
case 6:
|
||||
{ sValue = "Butt"; break; }
|
||||
case 7:
|
||||
{ sValue = "ROpenArrow"; break; }
|
||||
case 8:
|
||||
{ sValue = "RClosedArrow"; break; }
|
||||
case 9:
|
||||
{ sValue = "Slash"; break; }
|
||||
}
|
||||
|
||||
return sValue;
|
||||
}
|
||||
void AddRD(CDictObject* pObj, const double& dRD1, const double& dRD2, const double& dRD3, const double& dRD4)
|
||||
{
|
||||
CArrayObject* pArray = new CArrayObject();
|
||||
if (!pArray)
|
||||
return;
|
||||
|
||||
pObj->Add("RD", pArray);
|
||||
|
||||
pArray->Add(dRD1);
|
||||
pArray->Add(dRD2);
|
||||
pArray->Add(dRD3);
|
||||
pArray->Add(dRD4);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
// CAnnotation
|
||||
//----------------------------------------------------------------------------------------
|
||||
@ -109,7 +163,7 @@ namespace PdfWriter
|
||||
pArray->Add(oRect.fTop);
|
||||
}
|
||||
}
|
||||
void CAnnotation::SetBorder(BYTE nType, double dWidth, double dDashesAlternating, double dGaps)
|
||||
void CAnnotation::SetBorder(BYTE nType, double dWidth, const std::vector<double>& arrDash)
|
||||
{
|
||||
if (dWidth <= 0)
|
||||
return;
|
||||
@ -125,15 +179,7 @@ namespace PdfWriter
|
||||
|
||||
EBorderSubtype eSubtype = EBorderSubtype(nType);
|
||||
if (border_subtype_Dashed == eSubtype)
|
||||
{
|
||||
CArrayObject* pDash = new CArrayObject();
|
||||
if (pDash)
|
||||
{
|
||||
pBorderStyleDict->Add("D", pDash);
|
||||
pDash->Add(dDashesAlternating);
|
||||
pDash->Add(dGaps);
|
||||
}
|
||||
}
|
||||
AddToVectorD(this, "D", arrDash);
|
||||
|
||||
switch (eSubtype)
|
||||
{
|
||||
@ -192,17 +238,6 @@ namespace PdfWriter
|
||||
std::string sValue = U_TO_UTF8(wsLM);
|
||||
Add("M", new CStringObject(sValue.c_str()));
|
||||
}
|
||||
void AddToVectorD(CDictObject* pObj, const std::string& sName, const std::vector<double>& arrV)
|
||||
{
|
||||
CArrayObject* pArray = new CArrayObject();
|
||||
if (!pArray)
|
||||
return;
|
||||
|
||||
pObj->Add(sName, pArray);
|
||||
|
||||
for (const double& dV : arrV)
|
||||
pArray->Add(dV);
|
||||
}
|
||||
void CAnnotation::SetC(const std::vector<double>& arrC)
|
||||
{
|
||||
AddToVectorD(this, "C", arrC);
|
||||
@ -481,35 +516,6 @@ namespace PdfWriter
|
||||
{
|
||||
Add("LLO", dLLO);
|
||||
}
|
||||
std::string AddLE(const BYTE& nLE)
|
||||
{
|
||||
std::string sValue;
|
||||
switch (nLE)
|
||||
{
|
||||
case 0:
|
||||
{ sValue = "Square"; break; }
|
||||
case 1:
|
||||
{ sValue = "Circle"; break; }
|
||||
case 2:
|
||||
{ sValue = "Diamond"; break; }
|
||||
case 3:
|
||||
{ sValue = "OpenArrow"; break; }
|
||||
case 4:
|
||||
{ sValue = "ClosedArrow"; break; }
|
||||
case 5:
|
||||
{ sValue = "None"; break; }
|
||||
case 6:
|
||||
{ sValue = "Butt"; break; }
|
||||
case 7:
|
||||
{ sValue = "ROpenArrow"; break; }
|
||||
case 8:
|
||||
{ sValue = "RClosedArrow"; break; }
|
||||
case 9:
|
||||
{ sValue = "Slash"; break; }
|
||||
}
|
||||
|
||||
return sValue;
|
||||
}
|
||||
void CLineAnnotation::SetLE(const BYTE& nLE1, const BYTE& nLE2)
|
||||
{
|
||||
CArrayObject* pArray = new CArrayObject();
|
||||
@ -597,19 +603,6 @@ namespace PdfWriter
|
||||
std::string sValue = U_TO_UTF8(wsDS);
|
||||
Add("DS", new CStringObject(sValue.c_str()));
|
||||
}
|
||||
void AddRD(CDictObject* pObj, const double& dRD1, const double& dRD2, const double& dRD3, const double& dRD4)
|
||||
{
|
||||
CArrayObject* pArray = new CArrayObject();
|
||||
if (!pArray)
|
||||
return;
|
||||
|
||||
pObj->Add("RD", pArray);
|
||||
|
||||
pArray->Add(dRD1);
|
||||
pArray->Add(dRD2);
|
||||
pArray->Add(dRD3);
|
||||
pArray->Add(dRD4);
|
||||
}
|
||||
void CFreeTextAnnotation::SetRD(const double& dRD1, const double& dRD2, const double& dRD3, const double& dRD4)
|
||||
{
|
||||
AddRD(this, dRD1, dRD2, dRD3, dRD4);
|
||||
|
||||
@ -175,7 +175,7 @@ namespace PdfWriter
|
||||
}
|
||||
|
||||
void SetRect(const TRect& oRect);
|
||||
void SetBorder(BYTE nType, double dWidth, double dDashesAlternating = 0.0, double dGaps = 0.0);
|
||||
void SetBorder(BYTE nType, double dWidth, const std::vector<double>& arrDash);
|
||||
void SetAnnotFlag(const int& nAnnotFlag);
|
||||
void SetPage(CPage* pPage);
|
||||
void SetBE(BYTE nType, const double& dBE);
|
||||
|
||||
Reference in New Issue
Block a user