Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/fix/v.7.3.3-chart-ex' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
ElenaSubbotina committed Feb 16, 2023
2 parents 1fbbabe + 1f3a104 commit a4fd9eb
Show file tree
Hide file tree
Showing 59 changed files with 10,071 additions and 16,595 deletions.
1 change: 1 addition & 0 deletions Common/base.pri
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ core_ios {
QMAKE_CFLAGS += -fembed-bitcode
QMAKE_CXXFLAGS += -fembed-bitcode
QMAKE_LFLAGS += -fembed-bitcode
QMAKE_CXXFLAGS += -fobjc-arc

bundle_xcframeworks {
xcframework_platform_ios_simulator {
Expand Down
4 changes: 4 additions & 0 deletions DesktopEditor/common/StringExt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,10 @@ namespace NSStringExt
{
m_internal = new CStringUnicodeIterator_private(string);
}
CStringUnicodeIterator::~CStringUnicodeIterator()
{
delete m_internal;
}

bool CStringUnicodeIterator::Check()
{
Expand Down
1 change: 1 addition & 0 deletions DesktopEditor/common/StringExt.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ namespace NSStringExt

public:
CStringUnicodeIterator(const std::wstring& string);
~CStringUnicodeIterator();
bool Check();
void Next();
unsigned int Value();
Expand Down
11 changes: 11 additions & 0 deletions DesktopEditor/raster/Metafile/Common/MetaFileUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1077,4 +1077,15 @@ namespace MetaFile
return owsStream.str();
}

std::wstring ConvertToWString(const std::vector<double>& arValues, int nAccuracy)
{
std::wstringstream owsStream;

for (double dValue : arValues)
owsStream << std::fixed << std::setprecision((-1 != nAccuracy) ? nAccuracy : GetMinAccuracy(dValue)) << dValue << L" ";

owsStream.seekp(-1, std::ios_base::end);

return owsStream.str();
}
}
2 changes: 2 additions & 0 deletions DesktopEditor/raster/Metafile/Common/MetaFileUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -1219,6 +1219,8 @@ namespace MetaFile
std::wstring GetTempFilename(const std::wstring& sFolder = L"");

std::wstring StringNormalization(std::wstring wsString);

std::wstring ConvertToWString(double dValue, int nAccuracy = -1);
std::wstring ConvertToWString(const std::vector<double>& arValues, int nAccuracy = -1);
};
#endif // _METAFILE_COMMON_METAFILEUTILS_H
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ namespace MetaFile

void CEmfInterpretatorSvg::HANDLE_EMR_RESTOREDC(const int &nIndexDC)
{
ResetClip();
CInterpretatorSvgBase::ResetClip();
}

void CEmfInterpretatorSvg::HANDLE_EMR_FILLPATH(const TEmfRectL &oBounds)
Expand Down Expand Up @@ -130,22 +130,22 @@ namespace MetaFile

void CEmfInterpretatorSvg::HANDLE_EMR_SELECTCLIPPATH(const unsigned int &unRegionMode)
{
ResetClip();
CInterpretatorSvgBase::ResetClip();
}

void CEmfInterpretatorSvg::HANDLE_EMR_EXCLUDECLIPRECT(const TEmfRectL &oClip)
{
ResetClip();
CInterpretatorSvgBase::ResetClip();
}

void CEmfInterpretatorSvg::HANDLE_EMR_EXTSELECTCLIPRGN(const unsigned int &unRgnDataSize, const unsigned int &unRegionMode, CDataStream &oDataStream)
{
ResetClip();
CInterpretatorSvgBase::ResetClip();
}

void CEmfInterpretatorSvg::HANDLE_EMR_INTERSECTCLIPRECT(const TEmfRectL &oClip)
{
ResetClip();
CInterpretatorSvgBase::ResetClip();
}

void CEmfInterpretatorSvg::HANDLE_EMR_ANGLEARC(const TEmfPointL &oCenter, const unsigned int &unRadius, const double &dStartAngle, const double &dSweepAngle)
Expand Down Expand Up @@ -365,14 +365,24 @@ namespace MetaFile
{
std::wstring wsText = NSStringExt::CConverter::GetUnicodeFromUTF16((unsigned short*)oTEmfExtTextoutA.aEmrText.OutputString, oTEmfExtTextoutA.aEmrText.Chars);

WriteText(wsText, TPointD(oTEmfExtTextoutA.aEmrText.Reference.x, oTEmfExtTextoutA.aEmrText.Reference.y), oTEmfExtTextoutA.Bounds, TPointD(oTEmfExtTextoutA.exScale, oTEmfExtTextoutA.eyScale));
std::vector<double> arDx(0);

if (NULL != oTEmfExtTextoutA.aEmrText.OutputDx)
arDx = std::vector<double>(oTEmfExtTextoutA.aEmrText.OutputDx, oTEmfExtTextoutA.aEmrText.OutputDx + oTEmfExtTextoutA.aEmrText.Chars);

WriteText(wsText, TPointD(oTEmfExtTextoutA.aEmrText.Reference.x, oTEmfExtTextoutA.aEmrText.Reference.y), oTEmfExtTextoutA.Bounds, TPointD(oTEmfExtTextoutA.exScale, oTEmfExtTextoutA.eyScale), arDx);
}

void CEmfInterpretatorSvg::HANDLE_EMR_EXTTEXTOUTW(const TEmfExtTextoutW &oTEmfExtTextoutW)
{
std::wstring wsText = NSStringExt::CConverter::GetUnicodeFromUTF16((unsigned short*)oTEmfExtTextoutW.wEmrText.OutputString, oTEmfExtTextoutW.wEmrText.Chars);

WriteText(wsText, TPointD(oTEmfExtTextoutW.wEmrText.Reference.x, oTEmfExtTextoutW.wEmrText.Reference.y), oTEmfExtTextoutW.Bounds, TPointD(oTEmfExtTextoutW.exScale, oTEmfExtTextoutW.eyScale));
std::vector<double> arDx(0);

if (NULL != oTEmfExtTextoutW.wEmrText.OutputDx)
arDx = std::vector<double>(oTEmfExtTextoutW.wEmrText.OutputDx, oTEmfExtTextoutW.wEmrText.OutputDx + oTEmfExtTextoutW.wEmrText.Chars);

WriteText(wsText, TPointD(oTEmfExtTextoutW.wEmrText.Reference.x, oTEmfExtTextoutW.wEmrText.Reference.y), oTEmfExtTextoutW.Bounds, TPointD(oTEmfExtTextoutW.exScale, oTEmfExtTextoutW.eyScale), arDx);
}

void CEmfInterpretatorSvg::HANDLE_EMR_LINETO(const TEmfPointL &oPoint)
Expand Down Expand Up @@ -1187,27 +1197,27 @@ namespace MetaFile

void CEmfInterpretatorSvg::HANDLE_EMFPLUS_OFFSETCLIP(double dX, double dY)
{
ResetClip();
CInterpretatorSvgBase::ResetClip();
}

void CEmfInterpretatorSvg::HANDLE_EMFPLUS_RESETCLIP()
{
ResetClip();
CInterpretatorSvgBase::ResetClip();
}

void CEmfInterpretatorSvg::HANDLE_EMFPLUS_SETCLIPPATH(short unShFlags, const CEmfPlusPath *pPath)
{
ResetClip();
CInterpretatorSvgBase::ResetClip();
}

void CEmfInterpretatorSvg::HANDLE_EMFPLUS_SETCLIPRECT(short shCM, const TEmfPlusRectF &oRect)
{
ResetClip();
CInterpretatorSvgBase::ResetClip();
}

void CEmfInterpretatorSvg::HANDLE_EMFPLUS_SETCLIPREGION(short shObjectIndex, short shCM, const CEmfPlusRegion *pRegion)
{
ResetClip();
CInterpretatorSvgBase::ResetClip();
}

void CEmfInterpretatorSvg::HANDLE_EMFPLUS_CLEAR(const TEmfPlusARGB &oARGB)
Expand Down Expand Up @@ -1698,32 +1708,17 @@ namespace MetaFile

void CEmfInterpretatorSvg::ResetClip()
{
m_wsLastClipId.clear();
CInterpretatorSvgBase::ResetClip();
}

void CEmfInterpretatorSvg::IntersectClip(const TRectD &oClip)
{
m_wsLastClipId = L"INTERSECTCLIP_" + ConvertToWString(++m_unNumberDefs, 0);

TXForm *pTransform = m_pParser->GetTransform();

m_wsDefs += L"<clipPath id=\"" + m_wsLastClipId + L"\">" +
L"<rect x=\"" + ConvertToWString(oClip.dLeft * pTransform->M11, 0) + L"\" y=\"" + ConvertToWString(oClip.dTop * pTransform->M22, 0) + L"\" width=\"" + ConvertToWString((oClip.dRight - oClip.dLeft) * pTransform->M11, 0) + L"\" height=\"" + ConvertToWString((oClip.dBottom - oClip.dTop) * pTransform->M22, 0) + L"\"/>" +
L"</clipPath>";
CInterpretatorSvgBase::IntersectClip(oClip);
}

void CEmfInterpretatorSvg::ExcludeClip(const TRectD &oClip, const TRectD &oBB)
{
m_wsLastClipId = L"EXCLUDECLIP_" + ConvertToWString(++m_unNumberDefs, 0);

TXForm *pTransform = m_pParser->GetTransform();

m_wsDefs += L"<clipPath id=\"" + m_wsLastClipId + L"\">" +
L"<path d=\"M" + ConvertToWString(oBB.dLeft * pTransform->M11) + L' ' + ConvertToWString(oBB.dTop * pTransform->M22) + L", L" + ConvertToWString(oBB.dRight * pTransform->M11) + L' ' + ConvertToWString(oBB.dTop * pTransform->M11) + L", " +
ConvertToWString(oBB.dRight * pTransform->M11) + L' ' + ConvertToWString(oBB.dBottom * pTransform->M22) + L", " + ConvertToWString(oBB.dLeft * pTransform->M11) + L' ' + ConvertToWString(oBB.dBottom * pTransform->M22) + L", M" +
ConvertToWString(oClip.dLeft * pTransform->M11) + L' ' + ConvertToWString(oClip.dTop * pTransform->M22) + L", L" + ConvertToWString(oClip.dRight * pTransform->M11) + L' ' + ConvertToWString(oClip.dTop * pTransform->M22) + L", " +
ConvertToWString(oClip.dRight * pTransform->M11) + L' ' + ConvertToWString(oClip.dBottom * pTransform->M22) + L", " + ConvertToWString(oClip.dLeft * pTransform->M11) + L' ' + ConvertToWString(oClip.dLeft * pTransform->M22) + L"\" clip-rule=\"evenodd\"/>" +
L"</clipPath>";
CInterpretatorSvgBase::ExcludeClip(oClip, oBB);
}

void CEmfInterpretatorSvg::PathClip(IPath *pPath, int nClipMode, TXForm *pTransform)
Expand All @@ -1746,26 +1741,6 @@ namespace MetaFile
m_wsDefs += L"<clipPath id=\"" + m_wsLastClipId + L"\"><path d=\"" + wsPath + L"\" clip-rule=\"evenodd\"/></clipPath>";
}

void CEmfInterpretatorSvg::AddClip(NodeAttributes &arAttributes)
{
if (NULL == m_pParser)
return;

if (m_wsLastClipId.empty())
UpdateClip();

if (!m_wsLastClipId.empty())
arAttributes.push_back({L"clip-path", L"url(#" + m_wsLastClipId + L')'});
}

void CEmfInterpretatorSvg::UpdateClip()
{
IClip* pClip = m_pParser->GetClip();

if (NULL != pClip)
pClip->ClipOnRenderer((CInterpretatorSvgBase*)this);
}

TRectD CEmfInterpretatorSvg::TranslateRect(const TEmfRectL &oRect) const
{
TRectD oNewRect(oRect.lLeft, oRect.lTop, oRect.lRight, oRect.lBottom);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ namespace MetaFile
void End() override {};

void DrawString(std::wstring& wsText, unsigned int unCharsCount, double dX, double dY, double* pDx,
int iGraphicsMode = 1, double dXScale = 1, double dYScale = 1) override {};
int iGraphicsMode = 1, double dXScale = 1, double dYScale = 1) override {};

void DrawDriverString(const std::wstring& wsString, const std::vector<TPointD>& arPoints) override {};

Expand All @@ -221,9 +221,6 @@ namespace MetaFile
void StartClipPath(unsigned int unMode, int nFillMode = -1) override {};
void EndClipPath(unsigned int unMode) override {};

void AddClip(NodeAttributes &arAttributes);
void UpdateClip();

void UpdateDC() override {};
void SetTransform(double& dM11, double& dM12, double& dM21, double& dM22, double& dX, double& dY) override {};
void GetTransform(double* pdM11, double* pdM12, double* pdM21, double* pdM22, double* pdX, double* pdY) override {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ namespace MetaFile
m_oXmlWriter.WriteNodeEnd(wsNodeName, false, false);
}

void CInterpretatorSvgBase::WriteText(const std::wstring& wsText, const TPointD& oCoord, const TRect& oBounds, const TPointD& oScale)
void CInterpretatorSvgBase::WriteText(const std::wstring &wsText, const TPointD &oCoord, const TRect &oBounds, const TPointD &oScale, const std::vector<double>& arDx)
{
if (NULL == m_pParser || NULL == m_pParser->GetFont())
return;
Expand Down Expand Up @@ -342,9 +342,25 @@ namespace MetaFile

size_t unPosLineBreak = wsText.find(L"\n");

std::wstring wsXCoord;

if (arDx.empty() || arDx.size() < wsText.length())
wsXCoord = ConvertToWString(dXCoord);
else
{
std::vector<double> arXCoords(wsText.length());

arXCoords[0] = dXCoord;

for (unsigned int unIndex = 1; unIndex < wsText.length(); ++unIndex)
arXCoords[unIndex] = arDx[unIndex - 1] + arXCoords[unIndex - 1];

wsXCoord = ConvertToWString(arXCoords);
}

if (std::wstring::npos == unPosLineBreak)
{
arNodeAttributes.push_back({L"x", ConvertToWString(dXCoord)});
arNodeAttributes.push_back({L"x", wsXCoord});
arNodeAttributes.push_back({L"y", ConvertToWString(dYCoord)});

WriteNode(L"text", arNodeAttributes, StringNormalization(wsText));
Expand All @@ -360,7 +376,7 @@ namespace MetaFile
{
std::wstring wsTemp = StringNormalization(wsText.substr(unStart, unPosLineBreak - unStart));

WriteNode(L"tspan", {{L"x", ConvertToWString(dXCoord)},
WriteNode(L"tspan", {{L"x", wsXCoord},
{L"y", ConvertToWString(dYNewCoord)}}, StringNormalization(wsText.substr(unStart, unPosLineBreak - unStart)));

dYNewCoord += dFontHeight * 1.6;
Expand All @@ -376,6 +392,36 @@ namespace MetaFile
m_oXmlWriter.WriteNodeEnd(L"g");
}

void CInterpretatorSvgBase::ResetClip()
{
m_wsLastClipId.clear();
}

void CInterpretatorSvgBase::IntersectClip(const TRectD &oClip)
{
m_wsLastClipId = L"INTERSECTCLIP_" + ConvertToWString(++m_unNumberDefs, 0);

TXForm *pTransform = m_pParser->GetTransform();

m_wsDefs += L"<clipPath id=\"" + m_wsLastClipId + L"\">" +
L"<rect x=\"" + ConvertToWString(oClip.dLeft * pTransform->M11, 0) + L"\" y=\"" + ConvertToWString(oClip.dTop * pTransform->M22, 0) + L"\" width=\"" + ConvertToWString((oClip.dRight - oClip.dLeft) * pTransform->M11, 0) + L"\" height=\"" + ConvertToWString((oClip.dBottom - oClip.dTop) * pTransform->M22, 0) + L"\"/>" +
L"</clipPath>";
}

void CInterpretatorSvgBase::ExcludeClip(const TRectD &oClip, const TRectD &oBB)
{
m_wsLastClipId = L"EXCLUDECLIP_" + ConvertToWString(++m_unNumberDefs, 0);

TXForm *pTransform = m_pParser->GetTransform();

m_wsDefs += L"<clipPath id=\"" + m_wsLastClipId + L"\">" +
L"<path d=\"M" + ConvertToWString(oBB.dLeft * pTransform->M11) + L' ' + ConvertToWString(oBB.dTop * pTransform->M22) + L", L" + ConvertToWString(oBB.dRight * pTransform->M11) + L' ' + ConvertToWString(oBB.dTop * pTransform->M11) + L", " +
ConvertToWString(oBB.dRight * pTransform->M11) + L' ' + ConvertToWString(oBB.dBottom * pTransform->M22) + L", " + ConvertToWString(oBB.dLeft * pTransform->M11) + L' ' + ConvertToWString(oBB.dBottom * pTransform->M22) + L", M" +
ConvertToWString(oClip.dLeft * pTransform->M11) + L' ' + ConvertToWString(oClip.dTop * pTransform->M22) + L", L" + ConvertToWString(oClip.dRight * pTransform->M11) + L' ' + ConvertToWString(oClip.dTop * pTransform->M22) + L", " +
ConvertToWString(oClip.dRight * pTransform->M11) + L' ' + ConvertToWString(oClip.dBottom * pTransform->M22) + L", " + ConvertToWString(oClip.dLeft * pTransform->M11) + L' ' + ConvertToWString(oClip.dLeft * pTransform->M22) + L"\" clip-rule=\"evenodd\"/>" +
L"</clipPath>";
}

void CInterpretatorSvgBase::AddStroke(NodeAttributes &arAttributes) const
{
if (NULL == m_pParser)
Expand Down Expand Up @@ -618,6 +664,22 @@ namespace MetaFile

void CInterpretatorSvgBase::AddClip(NodeAttributes &arAttributes)
{
if (NULL == m_pParser)
return;

if (m_wsLastClipId.empty())
UpdateClip();

if (!m_wsLastClipId.empty())
arAttributes.push_back({L"clip-path", L"url(#" + m_wsLastClipId + L')'});
}

void CInterpretatorSvgBase::UpdateClip()
{
IClip* pClip = m_pParser->GetClip();

if (NULL != pClip)
pClip->ClipOnRenderer((CInterpretatorSvgBase*)this);
}

void CInterpretatorSvgBase::AddNoneFill(NodeAttributes &arAttributes) const
Expand Down Expand Up @@ -1446,5 +1508,4 @@ namespace MetaFile
{
m_oStringBuilder.WriteNodeEnd(L"pattern");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,17 @@ namespace MetaFile
void WriteNode(const std::wstring& wsNodeName, const NodeAttributes& arAttributes, const std::wstring& wsValueNode = L"");
void WriteNodeBegin(const std::wstring& wsNodeName, const NodeAttributes& arAttributes);
void WriteNodeEnd(const std::wstring& wsNodeName);
void WriteText(const std::wstring& wsText, const TPointD& oCoord, const TRect& oBounds = TRect(), const TPointD& oScale = TPointD(1, 1));
void WriteText(const std::wstring& wsText, const TPointD& oCoord, const TRect& oBounds = TRect(), const TPointD& oScale = TPointD(1, 1), const std::vector<double>& arDx = {});

void ResetClip() override;
void IntersectClip(const TRectD& oClip) override;
void ExcludeClip(const TRectD& oClip, const TRectD& oBB) override;

void AddStroke(NodeAttributes &arAttributes) const;
void AddFill(NodeAttributes &arAttributes, double dWidth = 0, double dHeight = 0);
void AddTransform(NodeAttributes &arAttributes, TXForm* pTransform = NULL) const;
void AddClip(NodeAttributes &arAttributes);
void UpdateClip();

void AddNoneFill(NodeAttributes &arAttributes) const;

Expand Down
Loading

0 comments on commit a4fd9eb

Please sign in to comment.