mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-04-07 13:55:33 +08:00
Fix bug #72353
This commit is contained in:
@ -33,6 +33,7 @@
|
||||
#define _METAFILE_COMMON_METAFILEOBJECTS_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace MetaFile
|
||||
{
|
||||
@ -70,6 +71,8 @@ namespace MetaFile
|
||||
virtual void GetBounds(double& left, double& top, double& width, double& height) const = 0;
|
||||
virtual void GetCenterPoint(double& dX, double& dY) const = 0;
|
||||
|
||||
virtual std::vector<std::pair<unsigned int, double>> GetGradientColors() const = 0;
|
||||
|
||||
virtual void GetDibPattern(unsigned char** pBuffer, unsigned int &unWidth, unsigned int &unHeight) const = 0;
|
||||
};
|
||||
|
||||
|
||||
@ -1109,12 +1109,18 @@ namespace MetaFile
|
||||
|
||||
m_pRenderer->put_BrushLinearAngle(pBrush->GetStyleEx());
|
||||
|
||||
long Colors[2];
|
||||
Colors[0] = pBrush->GetColor() + (pBrush->GetAlpha() << 24);
|
||||
Colors[1] = pBrush->GetColor2() + (pBrush->GetAlpha2() << 24);
|
||||
double Position[2] = {0, 1};
|
||||
std::vector<std::pair<unsigned int, double>> arColors{pBrush->GetGradientColors()};
|
||||
|
||||
m_pRenderer->put_BrushGradientColors(Colors,Position,2);
|
||||
std::vector<long> arLColors(arColors.size());
|
||||
std::vector<double> arDPositions(arColors.size());
|
||||
|
||||
for (unsigned int unIndex = 0; unIndex < arColors.size(); ++unIndex)
|
||||
{
|
||||
arLColors[unIndex] = arColors[unIndex].first;
|
||||
arDPositions[unIndex] = arColors[unIndex].second;
|
||||
}
|
||||
|
||||
m_pRenderer->put_BrushGradientColors(arLColors.data(), arDPositions.data(), arColors.size());
|
||||
|
||||
}
|
||||
else if ( BS_RADIALGRADIENT == unBrushStyle ||
|
||||
|
||||
@ -155,6 +155,15 @@ namespace MetaFile
|
||||
unHeight = unDibHeigth;
|
||||
}
|
||||
|
||||
std::vector<std::pair<unsigned int, double> > CEmfLogBrushEx::GetGradientColors() const
|
||||
{
|
||||
std::vector<std::pair<unsigned, double>> arColors(2);
|
||||
|
||||
arColors[0] = std::make_pair(GetColor() + (GetAlpha() << 24), 0.);
|
||||
arColors[1] = std::make_pair(GetColor2() + (GetAlpha2() << 24), 0.);
|
||||
|
||||
return arColors;
|
||||
}
|
||||
|
||||
CEmfLogFont::CEmfLogFont(bool bFixedLength)
|
||||
: m_bFixedLength(bFixedLength)
|
||||
|
||||
@ -77,6 +77,8 @@ namespace MetaFile
|
||||
void GetBounds(double& left, double& top, double& width, double& height) const override;
|
||||
void GetCenterPoint(double& dX, double& dY) const override;
|
||||
void GetDibPattern(unsigned char** pBuffer, unsigned int &unWidth, unsigned int &unHeight) const override;
|
||||
|
||||
std::vector<std::pair<unsigned, double>> GetGradientColors() const override;
|
||||
public:
|
||||
unsigned int unBrushStyle;
|
||||
TRGBA oColor;
|
||||
|
||||
@ -655,20 +655,15 @@ namespace MetaFile
|
||||
|
||||
m_oStream >> unPositionCount;
|
||||
|
||||
std::vector<double> arBlendPositions(unPositionCount);
|
||||
|
||||
for (unsigned int unIndex = 0; unIndex < unPositionCount; ++unIndex)
|
||||
m_oStream >> arBlendPositions[unIndex];
|
||||
|
||||
std::vector<TEmfPlusARGB> arBlendColors(unPositionCount);
|
||||
|
||||
for (unsigned int unIndex = 0; unIndex < unPositionCount; ++unIndex)
|
||||
m_oStream >> arBlendColors[unIndex];
|
||||
|
||||
if (1 < unPositionCount)
|
||||
if (unPositionCount > 1)
|
||||
{
|
||||
pEmfPlusBrush->oColorBack = arBlendColors[0];
|
||||
pEmfPlusBrush->oColor = arBlendColors.back();
|
||||
pEmfPlusBrush->arGradientColors.resize(unPositionCount);
|
||||
|
||||
for (unsigned int unIndex = 0; unIndex < unPositionCount; ++unIndex)
|
||||
m_oStream >> pEmfPlusBrush->arGradientColors[unIndex].second;
|
||||
|
||||
for (unsigned int unIndex = 0; unIndex < unPositionCount; ++unIndex)
|
||||
m_oStream >> pEmfPlusBrush->arGradientColors[unIndex].first;
|
||||
}
|
||||
}
|
||||
|
||||
@ -679,13 +674,40 @@ namespace MetaFile
|
||||
//TODO: реализовать
|
||||
pEmfPlusBrush->unStyle = BS_LINEARGRADIENT;
|
||||
|
||||
m_oStream.Skip(8); // BrushDataFlags, WrapMode
|
||||
int nBrushDataFlags;
|
||||
m_oStream >> nBrushDataFlags;
|
||||
|
||||
m_oStream.Skip(4); // WrapMode
|
||||
|
||||
// m_oStream >> pEmfPlusBrush->RectF;
|
||||
m_oStream.Skip(16);
|
||||
m_oStream >> pEmfPlusBrush->oColor;
|
||||
m_oStream >> pEmfPlusBrush->oColorBack;
|
||||
|
||||
m_oStream.Skip(8); // Reserved1, Reserved2
|
||||
|
||||
if (BrushDataTransform & nBrushDataFlags)
|
||||
{
|
||||
m_oStream.Skip(24);
|
||||
}
|
||||
|
||||
if (BrushDataPresetColors & nBrushDataFlags)
|
||||
{
|
||||
int nPositionCount;
|
||||
m_oStream >> nPositionCount;
|
||||
|
||||
if (nPositionCount > 1)
|
||||
{
|
||||
pEmfPlusBrush->arGradientColors.resize(nPositionCount);
|
||||
|
||||
for (unsigned int unIndex = 0; unIndex < nPositionCount; ++unIndex)
|
||||
m_oStream >> pEmfPlusBrush->arGradientColors[unIndex].second;
|
||||
|
||||
for (unsigned int unIndex = 0; unIndex < nPositionCount; ++unIndex)
|
||||
m_oStream >> pEmfPlusBrush->arGradientColors[unIndex].first;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
||||
@ -79,6 +79,29 @@ namespace MetaFile
|
||||
height = oRectF.dHeight;
|
||||
}
|
||||
|
||||
std::vector<std::pair<unsigned int, double> > CEmfPlusBrush::GetGradientColors() const
|
||||
{
|
||||
if (arGradientColors.empty())
|
||||
{
|
||||
std::vector<std::pair<unsigned int, double>> arColors(2);
|
||||
|
||||
arColors[0] = std::make_pair(GetColor() + (GetAlpha() << 24), 0.);
|
||||
arColors[1] = std::make_pair(GetColor2() + (GetAlpha2() << 24), 0.);
|
||||
|
||||
return arColors;
|
||||
}
|
||||
|
||||
std::vector<std::pair<unsigned int, double>> arColors(arGradientColors.size());
|
||||
|
||||
for (unsigned int unIndex = 0; unIndex < arGradientColors.size(); ++unIndex)
|
||||
{
|
||||
arColors[unIndex].first = METAFILE_RGBA(arGradientColors[unIndex].first.chRed, arGradientColors[unIndex].first.chGreen, arGradientColors[unIndex].first.chBlue, arGradientColors[unIndex].first.chAlpha);
|
||||
arColors[unIndex].second = arGradientColors[unIndex].second;
|
||||
}
|
||||
|
||||
return arColors;
|
||||
}
|
||||
|
||||
CEmfPlusPen::CEmfPlusPen()
|
||||
: unStyle(PS_SOLID | PS_GEOMETRIC | PS_STARTCAP_FLAT | PS_ENDCAP_FLAT | PS_JOIN_MITER), dWidth(1), oColor(0, 0, 0),
|
||||
pBrush(NULL), dMiterLimit(0), dDashOffset(0),
|
||||
|
||||
@ -189,6 +189,7 @@ namespace MetaFile
|
||||
void GetCenterPoint(double& dX, double& dY) const override;
|
||||
void GetBounds(double& left, double& top, double& width, double& height) const override;
|
||||
|
||||
std::vector<std::pair<unsigned int, double>> GetGradientColors() const override;
|
||||
public:
|
||||
TEmfPlusARGB oColor;
|
||||
TEmfPlusARGB oColorBack;
|
||||
@ -198,6 +199,8 @@ namespace MetaFile
|
||||
TEmfPlusPointF oCenterPoint;
|
||||
unsigned int unAngle;
|
||||
std::wstring wsDibPatternPath;
|
||||
|
||||
std::vector<std::pair<TEmfPlusARGB, double>> arGradientColors;
|
||||
};
|
||||
|
||||
class CEmfPlusPen: public CEmfPlusObject, public IPen
|
||||
|
||||
@ -358,6 +358,16 @@ void CSvmBrush::GetBounds(double& left, double& top, double& width, double& heig
|
||||
void CSvmBrush::GetDibPattern(unsigned char **pBuffer, unsigned int &unWidth, unsigned int &unHeight) const
|
||||
{}
|
||||
|
||||
std::vector<std::pair<unsigned int, double> > CSvmBrush::GetGradientColors() const
|
||||
{
|
||||
std::vector<std::pair<unsigned int, double>> arColors(2);
|
||||
|
||||
arColors[0] = std::make_pair(GetColor() + (GetAlpha() << 24), 0.);
|
||||
arColors[1] = std::make_pair(GetColor2() + (GetAlpha2() << 24), 0.);
|
||||
|
||||
return arColors;
|
||||
}
|
||||
|
||||
int CSvmPen::GetColor() const
|
||||
{
|
||||
return METAFILE_RGBA(Color.r, Color.g, Color.b, 0);
|
||||
|
||||
@ -300,6 +300,7 @@ public:
|
||||
void GetBounds(double& left, double& top, double& width, double& height) const override;
|
||||
void GetDibPattern(unsigned char** pBuffer, unsigned int &unWidth, unsigned int &unHeight) const override;
|
||||
|
||||
std::vector<std::pair<unsigned int, double>> GetGradientColors() const override;
|
||||
public:
|
||||
unsigned short BrushStyleEx; //angle, or ....
|
||||
unsigned short BrushStyle;
|
||||
|
||||
@ -1276,16 +1276,19 @@ namespace MetaFile
|
||||
|
||||
std::wstring wsStyleId;
|
||||
|
||||
if (BS_LINEARGRADIENT == pBrush->GetStyle() ||
|
||||
BS_RECTGRADIENT == pBrush->GetStyle() ||
|
||||
BS_PATHGRADIENT == pBrush->GetStyle())
|
||||
if (BS_LINEARGRADIENT == pBrush->GetStyle() ||
|
||||
BS_RECTGRADIENT == pBrush->GetStyle() ||
|
||||
BS_PATHGRADIENT == pBrush->GetStyle())
|
||||
{
|
||||
wsStyleId = L"LINEARGRADIENT_" + ConvertToWString(++m_unNumberDefs, 0);
|
||||
|
||||
m_wsDefs += L"<linearGradient id=\"" + wsStyleId + L"\">" +
|
||||
L"<stop offset=\"0%\" stop-color=\"" + CalculateColor(pBrush->GetColor(), pBrush->GetAlpha()) + L"\"/>" +
|
||||
L"<stop offset=\"100%\" stop-color=\"" + CalculateColor(pBrush->GetColor2(), pBrush->GetAlpha2()) + L"\"/>" +
|
||||
L"</linearGradient>";
|
||||
m_wsDefs += L"<linearGradient id=\"" + wsStyleId + L"\">";
|
||||
|
||||
for (const std::pair<unsigned int, double> parColorData : pBrush->GetGradientColors())
|
||||
m_wsDefs += L"<stop offset=\"" + ConvertToWString(parColorData.second, 2) +
|
||||
L"\" stop-color=\"" + CalculateColor(parColorData.first) + L"\"/>";
|
||||
|
||||
m_wsDefs += L"</linearGradient>";
|
||||
|
||||
return wsStyleId;
|
||||
}
|
||||
@ -2065,4 +2068,12 @@ namespace MetaFile
|
||||
|
||||
return L"rgba(" + std::to_wstring(uchRed) + L", " + std::to_wstring(uchGreen) + L", " + std::to_wstring(uchBlue) + L", " + ConvertToWString((double)uchAlpha / 255., 3) + L')';
|
||||
}
|
||||
|
||||
std::wstring CalculateColor(unsigned int unColor)
|
||||
{
|
||||
BYTE chAlpha = unColor >> 24;
|
||||
|
||||
return CalculateColor(unColor, chAlpha);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -158,6 +158,7 @@ namespace MetaFile
|
||||
friend class CWmfInterpretatorSvg;
|
||||
};
|
||||
|
||||
std::wstring CalculateColor(unsigned int unColor);
|
||||
std::wstring CalculateColor(unsigned int unColor, BYTE uchAlpha);
|
||||
std::wstring CalculateColor(BYTE uchRed, BYTE uchGreen, BYTE uchBlue, BYTE uchAlpha);
|
||||
}
|
||||
|
||||
@ -162,6 +162,16 @@ namespace MetaFile
|
||||
unHeight = unDibHeigth;
|
||||
}
|
||||
|
||||
std::vector<std::pair<unsigned int, double> > CWmfBrush::GetGradientColors() const
|
||||
{
|
||||
std::vector<std::pair<unsigned int, double>> arColors(2);
|
||||
|
||||
arColors[0] = std::make_pair(GetColor() + (GetAlpha() << 24), 0.);
|
||||
arColors[1] = std::make_pair(GetColor2() + (GetAlpha2() << 24), 0.);
|
||||
|
||||
return arColors;
|
||||
}
|
||||
|
||||
CWmfFont::CWmfFont()
|
||||
: shHeight(DEFAULT_FONT_SIZE), shWidth(0), shEscapement(0), shOrientation(0), shWeight(400),
|
||||
uchItalic(0x00), uchUnderline(0x00), uchStrikeOut(0x00), uchCharSet(0x01), uchOutPrecision(0x00),
|
||||
|
||||
@ -82,6 +82,8 @@ namespace MetaFile
|
||||
void GetBounds(double& left, double& top, double& width, double& height) const override;
|
||||
void GetCenterPoint(double& dX, double& dY) const override;
|
||||
void GetDibPattern(unsigned char** pBuffer, unsigned int &unWidth, unsigned int &unHeight) const override;
|
||||
|
||||
std::vector<std::pair<unsigned int, double>> GetGradientColors() const override;
|
||||
public:
|
||||
|
||||
unsigned short ushBrushStyle;
|
||||
|
||||
Reference in New Issue
Block a user