Commit 717aa6b2 authored by Ilya.Kirillov's avatar Ilya.Kirillov Committed by Alexander Trofimov

Реализованы команды отрисовки текста патами в рендерере.

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@63576 954022d7-b5bf-4e40-9824-e11837661b57
parent 45ea3e56
......@@ -1158,23 +1158,68 @@ HRESULT CPdfRenderer::PathCommandGetCurrentPoint(double* dX, double* dY)
}
HRESULT CPdfRenderer::PathCommandTextCHAR(const LONG& lUnicode, const double& dX, const double& dY, const double& dW, const double& dH)
{
m_oPath.AddText(m_oFont, lUnicode, MM_2_PT(dX), MM_2_PT(m_dPageHeight - dY), MM_2_PT(dW), MM_2_PT(dH));
return S_OK;
unsigned int unUnicode = lUnicode;
bool bRes = PathCommandDrawText(&unUnicode, 1, dX, dY, NULL);
return bRes ? S_OK : S_FALSE;
}
HRESULT CPdfRenderer::PathCommandText(const std::wstring& wsText, const double& dX, const double& dY, const double& dW, const double& dH)
HRESULT CPdfRenderer::PathCommandText(const std::wstring& wsUnicodeText, const double& dX, const double& dY, const double& dW, const double& dH)
{
m_oPath.AddText(m_oFont, wsText, MM_2_PT(dX), MM_2_PT(m_dPageHeight - dY), MM_2_PT(dW), MM_2_PT(dH));
unsigned int unLen;
unsigned int* pUnicodes = WStringToUtf32(wsUnicodeText, unLen);
if (!pUnicodes)
return S_FALSE;
PathCommandDrawText(pUnicodes, unLen, dX, dY, NULL);
delete[] pUnicodes;
return S_OK;
}
HRESULT CPdfRenderer::PathCommandTextExCHAR(const LONG& lUnicode, const LONG& lGid, const double& dX, const double& dY, const double& dW, const double& dH)
{
m_oPath.AddText(m_oFont, lUnicode, lGid, MM_2_PT(dX), MM_2_PT(m_dPageHeight - dY), MM_2_PT(dW), MM_2_PT(dH));
return S_OK;
unsigned int unUnicode = lUnicode;
unsigned int unGid = lGid;
bool bRes = PathCommandDrawText(&unUnicode, 1, dX, dY, &unGid);
return bRes ? S_OK : S_FALSE;
}
HRESULT CPdfRenderer::PathCommandTextEx(const std::wstring& wsUnicodeText, const unsigned int* pGids, const unsigned int unGidsCount, const double& dX, const double& dY, const double& dW, const double& dH)
{
m_oPath.AddText(m_oFont, wsUnicodeText, pGids, unGidsCount, MM_2_PT(dX), MM_2_PT(m_dPageHeight - dY), MM_2_PT(dW), MM_2_PT(dH));
return S_OK;
if (!IsPageValid() || (!wsUnicodeText.size() && (!pGids || !unGidsCount)))
return S_FALSE;
unsigned int unLen = 0;
unsigned int* pUnicodes = NULL;
if (pGids && unGidsCount)
{
unLen = unGidsCount;
if (wsUnicodeText.size())
{
unsigned int unUnicodeLen;
pUnicodes = WStringToUtf32(wsUnicodeText, unUnicodeLen);
if (!pUnicodes || unUnicodeLen != unLen)
RELEASEARRAYOBJECTS(pUnicodes);
}
if (!pUnicodes)
{
pUnicodes = new unsigned int[unLen];
if (!pUnicodes)
return S_FALSE;
for (unsigned int unIndex = 0; unIndex < unLen; unIndex++)
pUnicodes[unIndex] = pGids[unIndex];
}
}
else
{
pUnicodes = WStringToUtf32(wsUnicodeText, unLen);
if (!pUnicodes)
return S_FALSE;
}
bool bRes = PathCommandDrawText(pUnicodes, unLen, dX, dY, pGids);
RELEASEARRAYOBJECTS(pUnicodes);
return bRes ? S_OK : S_FALSE;
}
//----------------------------------------------------------------------------------------
//
......@@ -1317,7 +1362,6 @@ HRESULT CPdfRenderer::DrawImageWith1bppMask(IGrObject* pImage, Pix* pMaskBuffer,
m_pPage->GrRestore();
return S_OK;
}
//----------------------------------------------------------------------------------------
//
//----------------------------------------------------------------------------------------
......@@ -1410,6 +1454,18 @@ bool CPdfRenderer::DrawText(unsigned int* pUnicodes, unsigned int unLen, const d
return true;
}
bool CPdfRenderer::PathCommandDrawText(unsigned int* pUnicodes, unsigned int unLen, const double& dX, const double& dY, const unsigned int* pGids)
{
if (m_bNeedUpdateTextFont)
UpdateFont();
if (!m_pFont)
return false;
unsigned char* pCodes = m_pFont->EncodeString(pUnicodes, unLen, pGids);
m_oPath.AddText(m_pFont, pCodes, unLen * 2, MM_2_PT(dX), MM_2_PT(m_dPageHeight - dY), m_oFont.GetSize(), MM_2_PT(m_oFont.GetCharSpace()));
return true;
}
void CPdfRenderer::UpdateFont()
{
m_bNeedUpdateTextFont = false;
......@@ -1803,37 +1859,19 @@ void CPdfRenderer::CPath::CPathClose::Draw(PdfWriter::CPage* pPage)
void CPdfRenderer::CPath::CPathClose::UpdateBounds(double& dL, double& dT, double& dR, double& dB)
{
}
void CPdfRenderer::CPath::CPathTextChar::Draw(PdfWriter::CPage* pPage)
{
// TODO:
}
void CPdfRenderer::CPath::CPathTextChar::UpdateBounds(double& dL, double& dT, double& dR, double& dB)
{
// TODO:
}
void CPdfRenderer::CPath::CPathText::Draw(PdfWriter::CPage* pPage)
{
// TODO:
// TODO: , ,
pPage->BeginText();
pPage->SetFontAndSize(font, fontSize);
pPage->SetCharSpace(charSpace);
pPage->SetTextRenderingMode(textrenderingmode_Stroke);
pPage->DrawText(x, y, codes, codesCount);
pPage->EndText();
}
void CPdfRenderer::CPath::CPathText::UpdateBounds(double& dL, double& dT, double& dR, double& dB)
{
// TODO:
}
void CPdfRenderer::CPath::CPathTextExChar::Draw(PdfWriter::CPage* pPage)
{
// TODO:
}
void CPdfRenderer::CPath::CPathTextExChar::UpdateBounds(double& dL, double& dT, double& dR, double& dB)
{
// TODO:
}
void CPdfRenderer::CPath::CPathTextEx::Draw(PdfWriter::CPage* pPage)
{
// TODO:
}
void CPdfRenderer::CPath::CPathTextEx::UpdateBounds(double& dL, double& dT, double& dR, double& dB)
{
// TODO:
UpdateMaxMinPoints(dL, dT, dR, dB, x, y);
}
void CPdfRenderer::CBrushState::Reset()
{
......
......@@ -16,6 +16,7 @@ namespace PdfWriter
class CImageDict;
class CShading;
class CExtGrState;
class CFontDict;
}
namespace Aggplus
......@@ -189,6 +190,7 @@ private:
PdfWriter::CImageDict* LoadImage(Aggplus::CImage* pImage, const BYTE& nAlpha);
bool DrawImage(Aggplus::CImage* pImage, const double& dX, const double& dY, const double& dW, const double& dH, const BYTE& nAlpha);
bool DrawText(unsigned int* pUnicodes, unsigned int unLen, const double& dX, const double& dY, const unsigned int* pGids = NULL);
bool PathCommandDrawText(unsigned int* pUnicodes, unsigned int unLen, const double& dX, const double& dY, const unsigned int* pGids = NULL);
void UpdateFont();
void UpdateTransform();
void UpdatePen();
......@@ -1186,142 +1188,22 @@ private:
return rendererpathcommand_Close;
}
};
class CPathTextChar : public CPathCommandBase
{
public:
CPathTextChar(const CFontState& oFont, const LONG& lUnicode, const double& dX, const double& dY, const double& dW, const double& dH)
{
font = oFont;
unicode = lUnicode;
x = dX;
y = dY;
w = dW;
h = dH;
}
void GetLastPoint(double& dX, double& dY)
{
dX = x;
dY = y;
}
void Draw(PdfWriter::CPage* pPage);
void UpdateBounds(double& dL, double& dT, double& dR, double& dB);
EPathCommandType GetType()
{
return rendererpathcommand_TextChar;
}
public:
CFontState font;
LONG unicode;
double x;
double y;
double w;
double h;
};
class CPathText : public CPathCommandBase
{
public:
CPathText(const CFontState& oFont, const std::wstring& wsText, const double& dX, const double& dY, const double& dW, const double& dH)
CPathText(PdfWriter::CFontDict* pFont, unsigned char* pCodes, const unsigned int& unCodesCount, const double& dX, const double& dY, const double& dSize, const double& dCharSpace)
{
font = oFont;
text = wsText;
font = pFont;
codes = pCodes;
codesCount = unCodesCount;
x = dX;
y = dY;
w = dW;
h = dH;
fontSize = dSize;
charSpace = dCharSpace;
}
void GetLastPoint(double& dX, double& dY)
~CPathText()
{
dX = x;
dY = y;
}
void Draw(PdfWriter::CPage* pPage);
void UpdateBounds(double& dL, double& dT, double& dR, double& dB);
EPathCommandType GetType()
{
return rendererpathcommand_Text;
}
public:
CFontState font;
std::wstring text;
double x;
double y;
double w;
double h;
};
class CPathTextExChar : public CPathCommandBase
{
public:
CPathTextExChar(const CFontState& oFont, const LONG& lUnicode, const LONG& lGid, const double& dX, const double& dY, const double& dW, const double& dH)
{
font = oFont;
unicode = lUnicode;
gid = lGid;
x = dX;
y = dY;
w = dW;
h = dH;
}
void GetLastPoint(double& dX, double& dY)
{
dX = x;
dY = y;
}
void Draw(PdfWriter::CPage* pPage);
void UpdateBounds(double& dL, double& dT, double& dR, double& dB);
EPathCommandType GetType()
{
return rendererpathcommand_TextExChar;
}
public:
CFontState font;
LONG unicode;
LONG gid;
double x;
double y;
double w;
double h;
};
class CPathTextEx : public CPathCommandBase
{
public:
CPathTextEx(const CFontState& oFont, const std::wstring& wsUnicodeText, const unsigned int* pGids, const unsigned int unGidsCount, const double& dX, const double& dY, const double& dW, const double& dH)
{
font = oFont;
unicodeText = wsUnicodeText;
x = dX;
y = dY;
w = dW;
h = dH;
if (pGids && unGidsCount)
{
gids = new unsigned int[unGidsCount];
if (gids)
{
memcpy(gids, pGids, unGidsCount * sizeof(unsigned int));
gidsCount = unGidsCount;
}
else
{
gids = NULL;
gidsCount = 0;
}
}
else
{
gidsCount = 0;
gids = NULL;
}
}
~CPathTextEx()
{
RELEASEARRAYOBJECTS(gids);
RELEASEARRAYOBJECTS(codes);
}
void GetLastPoint(double& dX, double& dY)
{
......@@ -1332,19 +1214,18 @@ private:
void UpdateBounds(double& dL, double& dT, double& dR, double& dB);
EPathCommandType GetType()
{
return rendererpathcommand_TextEx;
return rendererpathcommand_Text;
}
public:
CFontState font;
std::wstring unicodeText;
unsigned int*gids;
unsigned int gidsCount;
PdfWriter::CFontDict* font;
unsigned char* codes;
unsigned int codesCount;
double x;
double y;
double w;
double h;
double fontSize;
double charSpace;
};
public:
......@@ -1384,21 +1265,9 @@ private:
return Add(new CPathArcTo(dX, dY, dW, dH, dStart, dSweep));
}
bool AddText(const CFontState& oFont, const LONG& lUnicode, const double& dX, const double& dY, const double& dW, const double& dH)
{
return Add(new CPathTextChar(oFont, lUnicode, dX, dY, dW, dH));
}
bool AddText(const CFontState& oFont, const std::wstring& wsText, const double& dX, const double& dY, const double& dW, const double& dH)
{
return Add(new CPathText(oFont, wsText, dX, dY, dW, dH));
}
bool AddText(const CFontState& oFont, const LONG& lUnicode, const LONG& lGid, const double& dX, const double& dY, const double& dW, const double& dH)
{
return Add(new CPathTextExChar(oFont, lUnicode, lGid, dX, dY, dW, dH));
}
bool AddText(const CFontState& oFont, const std::wstring& wsUnicodeText, const unsigned int* pGids, const unsigned int unGidsCount, const double& dX, const double& dY, const double& dW, const double& dH)
bool AddText(PdfWriter::CFontDict* pFont, unsigned char* pCodes, const unsigned int& unLen, const double& dX, const double& dY, const double& dSize, const double& dCharSpace)
{
return Add(new CPathTextEx(oFont, wsUnicodeText, pGids, unGidsCount, dX, dY, dW, dH));
return Add(new CPathText(pFont, pCodes, unLen, dX, dY, dSize, dCharSpace));
}
bool Close()
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment