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

Сделана поодержка отрисовки символов через гиды.

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@63477 954022d7-b5bf-4e40-9824-e11837661b57
parent aad5ef64
...@@ -888,7 +888,7 @@ HRESULT CPdfRenderer::CommandDrawTextCHAR(const LONG& lUnicode, const double& dX ...@@ -888,7 +888,7 @@ HRESULT CPdfRenderer::CommandDrawTextCHAR(const LONG& lUnicode, const double& dX
return S_FALSE; return S_FALSE;
unsigned int unUnicode = lUnicode; unsigned int unUnicode = lUnicode;
bool bRes = DrawText(&unUnicode, 1, dX, dY); bool bRes = DrawText(&unUnicode, 1, dX, dY, NULL);
return bRes ? S_OK : S_FALSE; return bRes ? S_OK : S_FALSE;
} }
HRESULT CPdfRenderer::CommandDrawText(const std::wstring& wsUnicodeText, const double& dX, const double& dY, const double& dW, const double& dH, const double& dBaselineOffset) HRESULT CPdfRenderer::CommandDrawText(const std::wstring& wsUnicodeText, const double& dX, const double& dY, const double& dW, const double& dH, const double& dBaselineOffset)
...@@ -939,7 +939,7 @@ HRESULT CPdfRenderer::CommandDrawText(const std::wstring& wsUnicodeText, const d ...@@ -939,7 +939,7 @@ HRESULT CPdfRenderer::CommandDrawText(const std::wstring& wsUnicodeText, const d
return S_OK; return S_OK;
} }
bool bRes = DrawText(pUnicodes, unLen, dX, dY); bool bRes = DrawText(pUnicodes, unLen, dX, dY, NULL);
delete[] pUnicodes; delete[] pUnicodes;
return bRes ? S_OK : S_FALSE; return bRes ? S_OK : S_FALSE;
...@@ -950,21 +950,62 @@ HRESULT CPdfRenderer::CommandDrawTextExCHAR(const LONG& lUnicode, const LONG& lG ...@@ -950,21 +950,62 @@ HRESULT CPdfRenderer::CommandDrawTextExCHAR(const LONG& lUnicode, const LONG& lG
return S_FALSE; return S_FALSE;
unsigned int unUnicode = lUnicode; unsigned int unUnicode = lUnicode;
bool bRes = DrawText(&unUnicode, 1, dX, dY); unsigned short ushGid = lGid;
bool bRes = DrawText(&unUnicode, 1, dX, dY, &ushGid);
return bRes ? S_OK : S_FALSE; return bRes ? S_OK : S_FALSE;
} }
HRESULT CPdfRenderer::CommandDrawTextEx(const std::wstring& wsUnicodeText, const std::wstring& wsGidText, const double& dX, const double& dY, const double& dW, const double& dH, const double& dBaselineOffset, const DWORD& dwFlags) HRESULT CPdfRenderer::CommandDrawTextEx(const std::wstring& wsUnicodeText, const std::wstring& wsGidText, const double& dX, const double& dY, const double& dW, const double& dH, const double& dBaselineOffset, const DWORD& dwFlags)
{ {
if (!IsPageValid() || !wsUnicodeText.size()) if (!IsPageValid() || (!wsUnicodeText.size() && !wsGidText.size()))
return S_FALSE; return S_FALSE;
unsigned int unLen; unsigned int unLen = 0;
unsigned int* pUnicodes = WStringToUtf32(wsUnicodeText, unLen); unsigned int* pUnicodes = NULL;
unsigned short* pGids = NULL;
if (wsGidText.size())
{
unLen = wsGidText.size();
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) if (!pUnicodes)
return S_FALSE; return S_FALSE;
bool bRes = DrawText(pUnicodes, unLen, dX, dY); for (unsigned int unIndex = 0; unIndex < unLen; unIndex++)
delete[] pUnicodes; pUnicodes[unIndex] = (unsigned int)wsGidText.at(unIndex);
}
pGids = new unsigned short[unLen];
if (!pGids)
{
RELEASEARRAYOBJECTS(pUnicodes);
return S_FALSE;
}
for (unsigned int unIndex = 0; unIndex < unLen; unIndex++)
pGids[unIndex] = (unsigned int)wsGidText.at(unIndex);
}
else
{
pUnicodes = WStringToUtf32(wsUnicodeText, unLen);
if (!pUnicodes)
return S_FALSE;
}
bool bRes = DrawText(pUnicodes, unLen, dX, dY, pGids);
RELEASEARRAYOBJECTS(pUnicodes);
RELEASEARRAYOBJECTS(pGids);
return bRes ? S_OK : S_FALSE; return bRes ? S_OK : S_FALSE;
} }
...@@ -1362,7 +1403,7 @@ bool CPdfRenderer::DrawImage(Aggplus::CImage* pImage, const double& dX, const do ...@@ -1362,7 +1403,7 @@ bool CPdfRenderer::DrawImage(Aggplus::CImage* pImage, const double& dX, const do
return true; return true;
} }
bool CPdfRenderer::DrawText(unsigned int* pUnicodes, unsigned int unLen, const double& dX, const double& dY) bool CPdfRenderer::DrawText(unsigned int* pUnicodes, unsigned int unLen, const double& dX, const double& dY, unsigned short* pGids)
{ {
if (m_bNeedUpdateTextFont) if (m_bNeedUpdateTextFont)
UpdateFont(); UpdateFont();
...@@ -1370,7 +1411,7 @@ bool CPdfRenderer::DrawText(unsigned int* pUnicodes, unsigned int unLen, const d ...@@ -1370,7 +1411,7 @@ bool CPdfRenderer::DrawText(unsigned int* pUnicodes, unsigned int unLen, const d
if (!m_pFont) if (!m_pFont)
return false; return false;
unsigned char* pCodes = m_pFont->EncodeString(pUnicodes, unLen); unsigned char* pCodes = m_pFont->EncodeString(pUnicodes, unLen, pGids);
CTransform& t = m_oTransform; CTransform& t = m_oTransform;
m_oCommandManager.SetTransform(t.m11, -t.m12, -t.m21, t.m22, MM_2_PT(t.dx + t.m21 * m_dPageHeight), MM_2_PT(m_dPageHeight - m_dPageHeight * t.m22 - t.dy)); m_oCommandManager.SetTransform(t.m11, -t.m12, -t.m21, t.m22, MM_2_PT(t.dx + t.m21 * m_dPageHeight), MM_2_PT(m_dPageHeight - m_dPageHeight * t.m22 - t.dy));
......
...@@ -188,7 +188,7 @@ private: ...@@ -188,7 +188,7 @@ private:
void OnlineWordToPdfInternal(BYTE* dstArray, LONG lLen, const std::wstring& wsHtmlPlace, std::wstring& wsHypers, int& nCountPages, const std::wstring& wsTempLogo, LONG lReg); void OnlineWordToPdfInternal(BYTE* dstArray, LONG lLen, const std::wstring& wsHtmlPlace, std::wstring& wsHypers, int& nCountPages, const std::wstring& wsTempLogo, LONG lReg);
PdfWriter::CImageDict* LoadImage(Aggplus::CImage* pImage, const BYTE& nAlpha); 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 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); bool DrawText(unsigned int* pUnicodes, unsigned int unLen, const double& dX, const double& dY, unsigned short* pGids = NULL);
void UpdateFont(); void UpdateFont();
void UpdateTransform(); void UpdateTransform();
void UpdatePen(); void UpdatePen();
......
...@@ -176,7 +176,7 @@ namespace PdfWriter ...@@ -176,7 +176,7 @@ namespace PdfWriter
pCIDToGIDMapDict->SetFilter(STREAM_FILTER_FLATE_DECODE); pCIDToGIDMapDict->SetFilter(STREAM_FILTER_FLATE_DECODE);
m_pCidToGidMapStream = pCIDToGIDMapDict->GetStream(); m_pCidToGidMapStream = pCIDToGIDMapDict->GetStream();
} }
unsigned char* CFontCidTrueType::EncodeString(unsigned int* pUnicodes, unsigned int unLen) unsigned char* CFontCidTrueType::EncodeString(unsigned int* pUnicodes, unsigned int unLen, unsigned short* pGids)
{ {
if (!OpenFontFace()) if (!OpenFontFace())
return NULL; return NULL;
...@@ -190,13 +190,32 @@ namespace PdfWriter ...@@ -190,13 +190,32 @@ namespace PdfWriter
// . // .
for (unsigned int unIndex = 0; unIndex < unLen; unIndex++) for (unsigned int unIndex = 0; unIndex < unLen; unIndex++)
{ {
std::map<unsigned int, unsigned short>::const_iterator oIter = m_mUnicodeToCode.find(pUnicodes[unIndex]); bool bFind = false;
unsigned short ushCode; unsigned short ushCode;
if (pGids)
{
unsigned short ushGid = pGids[unIndex];
for (unsigned short ushCurCode = 0, ushCodesCount = m_vCodeToGid.size(); ushCurCode < ushCodesCount; ushCurCode++)
{
if (ushGid == m_vCodeToGid.at(ushCurCode))
{
ushCode = ushCurCode;
bFind = true;
break;
}
}
}
else
{
std::map<unsigned int, unsigned short>::const_iterator oIter = m_mUnicodeToCode.find(pUnicodes[unIndex]);
if (oIter != m_mUnicodeToCode.end()) if (oIter != m_mUnicodeToCode.end())
{ {
ushCode = oIter->second; ushCode = oIter->second;
bFind = true;
} }
else }
if (!bFind)
{ {
unsigned int unUnicode = pUnicodes[unIndex]; unsigned int unUnicode = pUnicodes[unIndex];
ushCode = m_ushCodesCount; ushCode = m_ushCodesCount;
...@@ -205,9 +224,17 @@ namespace PdfWriter ...@@ -205,9 +224,17 @@ namespace PdfWriter
m_mUnicodeToCode.insert(std::pair<unsigned int, unsigned short>(unUnicode, ushCode)); m_mUnicodeToCode.insert(std::pair<unsigned int, unsigned short>(unUnicode, ushCode));
m_vUnicodes.push_back(unUnicode); m_vUnicodes.push_back(unUnicode);
unsigned short ushGID = GetGID(m_pFace, unUnicode); unsigned short ushGID;
if (!pGids)
{
ushGID = GetGID(m_pFace, unUnicode);
if (0 == ushGID && -1 != m_nSymbolicCmap) if (0 == ushGID && -1 != m_nSymbolicCmap)
ushGID = GetGID(m_pFace, unUnicode + 0xF000); ushGID = GetGID(m_pFace, unUnicode + 0xF000);
}
else
{
ushGID = pGids[unIndex];
}
m_vCodeToGid.push_back(ushGID); m_vCodeToGid.push_back(ushGID);
......
...@@ -26,7 +26,7 @@ namespace PdfWriter ...@@ -26,7 +26,7 @@ namespace PdfWriter
CFontCidTrueType(CXref* pXref, CDocument* pDocument, const std::wstring& wsFontPath, unsigned int unIndex); CFontCidTrueType(CXref* pXref, CDocument* pDocument, const std::wstring& wsFontPath, unsigned int unIndex);
~CFontCidTrueType(); ~CFontCidTrueType();
unsigned char* EncodeString(unsigned int* pUnicodes, unsigned int unLen); unsigned char* EncodeString(unsigned int* pUnicodes, unsigned int unLen, unsigned short* pGid = NULL);
unsigned int GetWidth(unsigned short ushCode); unsigned int GetWidth(unsigned short ushCode);
EFontType GetFontType() EFontType GetFontType()
{ {
......
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