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

Переделано на новый интерфейс IRenderer. Гиды теперь unsigned int, а не unsigned short.

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@63572 954022d7-b5bf-4e40-9824-e11837661b57
parent 66ec3df1
...@@ -599,7 +599,7 @@ namespace NSOnlineOfficeBinToPdf ...@@ -599,7 +599,7 @@ namespace NSOnlineOfficeBinToPdf
double m1 = ReadInt(current, curindex) / 100000.0; double m1 = ReadInt(current, curindex) / 100000.0;
double m2 = ReadInt(current, curindex) / 100000.0; double m2 = ReadInt(current, curindex) / 100000.0;
pPdf->CommandDrawText(wsTempString, m1, m2, 0, 0, 0); pPdf->CommandDrawText(wsTempString, m1, m2, 0, 0);
break; break;
} }
case ctBeginCommand: case ctBeginCommand:
......
...@@ -882,7 +882,7 @@ HRESULT CPdfRenderer::put_FontFaceIndex(const int& nFaceIndex) ...@@ -882,7 +882,7 @@ HRESULT CPdfRenderer::put_FontFaceIndex(const int& nFaceIndex)
//---------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------
// //
//---------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------
HRESULT CPdfRenderer::CommandDrawTextCHAR(const LONG& lUnicode, const double& dX, const double& dY, const double& dW, const double& dH, const double& dBaselineOffset) HRESULT CPdfRenderer::CommandDrawTextCHAR(const LONG& lUnicode, const double& dX, const double& dY, const double& dW, const double& dH)
{ {
if (!IsPageValid()) if (!IsPageValid())
return S_FALSE; return S_FALSE;
...@@ -891,7 +891,7 @@ HRESULT CPdfRenderer::CommandDrawTextCHAR(const LONG& lUnicode, const double& dX ...@@ -891,7 +891,7 @@ HRESULT CPdfRenderer::CommandDrawTextCHAR(const LONG& lUnicode, const double& dX
bool bRes = DrawText(&unUnicode, 1, dX, dY, NULL); 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)
{ {
if (!IsPageValid() || !wsUnicodeText.size()) if (!IsPageValid() || !wsUnicodeText.size())
return S_FALSE; return S_FALSE;
...@@ -944,29 +944,26 @@ HRESULT CPdfRenderer::CommandDrawText(const std::wstring& wsUnicodeText, const d ...@@ -944,29 +944,26 @@ HRESULT CPdfRenderer::CommandDrawText(const std::wstring& wsUnicodeText, const d
return bRes ? S_OK : S_FALSE; return bRes ? S_OK : S_FALSE;
} }
HRESULT CPdfRenderer::CommandDrawTextExCHAR(const LONG& lUnicode, const LONG& lGid, const double& dX, const double& dY, const double& dW, const double& dH, const double& dBaselineOffset, const DWORD& dwFlags) HRESULT CPdfRenderer::CommandDrawTextExCHAR(const LONG& lUnicode, const LONG& lGid, const double& dX, const double& dY, const double& dW, const double& dH)
{ {
if (!IsPageValid()) if (!IsPageValid())
return S_FALSE; return S_FALSE;
unsigned int unUnicode = lUnicode; unsigned int unUnicode = lUnicode;
unsigned short ushGid = lGid; unsigned int unGid = lGid;
bool bRes = DrawText(&unUnicode, 1, dX, dY, &ushGid); bool bRes = DrawText(&unUnicode, 1, dX, dY, &unGid);
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 unsigned int* pGids, const unsigned int unGidsCount, const double& dX, const double& dY, const double& dW, const double& dH)
{ {
if (!IsPageValid() || (!wsUnicodeText.size() && !wsGidText.size())) if (!IsPageValid() || (!wsUnicodeText.size() && (!pGids || !unGidsCount)))
return S_FALSE; return S_FALSE;
unsigned int unLen = 0; unsigned int unLen = 0;
unsigned int* pUnicodes = NULL; unsigned int* pUnicodes = NULL;
unsigned short* pGids = NULL; if (pGids && unGidsCount)
if (wsGidText.size())
{ {
unLen = wsGidText.size(); unLen = unGidsCount;
if (wsUnicodeText.size()) if (wsUnicodeText.size())
{ {
unsigned int unUnicodeLen; unsigned int unUnicodeLen;
...@@ -982,18 +979,8 @@ HRESULT CPdfRenderer::CommandDrawTextEx(const std::wstring& wsUnicodeText, const ...@@ -982,18 +979,8 @@ HRESULT CPdfRenderer::CommandDrawTextEx(const std::wstring& wsUnicodeText, const
return S_FALSE; return S_FALSE;
for (unsigned int unIndex = 0; unIndex < unLen; unIndex++) for (unsigned int unIndex = 0; unIndex < unLen; unIndex++)
pUnicodes[unIndex] = (unsigned int)wsGidText.at(unIndex); pUnicodes[unIndex] = pGids[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 else
{ {
...@@ -1003,9 +990,7 @@ HRESULT CPdfRenderer::CommandDrawTextEx(const std::wstring& wsUnicodeText, const ...@@ -1003,9 +990,7 @@ HRESULT CPdfRenderer::CommandDrawTextEx(const std::wstring& wsUnicodeText, const
} }
bool bRes = DrawText(pUnicodes, unLen, dX, dY, pGids); bool bRes = DrawText(pUnicodes, unLen, dX, dY, pGids);
RELEASEARRAYOBJECTS(pUnicodes); RELEASEARRAYOBJECTS(pUnicodes);
RELEASEARRAYOBJECTS(pGids);
return bRes ? S_OK : S_FALSE; return bRes ? S_OK : S_FALSE;
} }
...@@ -1171,24 +1156,24 @@ HRESULT CPdfRenderer::PathCommandGetCurrentPoint(double* dX, double* dY) ...@@ -1171,24 +1156,24 @@ HRESULT CPdfRenderer::PathCommandGetCurrentPoint(double* dX, double* dY)
*dY = PT_2_MM(*dY); *dY = PT_2_MM(*dY);
return S_OK; return S_OK;
} }
HRESULT CPdfRenderer::PathCommandTextCHAR(const LONG& lUnicode, const double& dX, const double& dY, const double& dW, const double& dH, const double& dBaselineOffset) 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), MM_2_PT(dBaselineOffset)); 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; return S_OK;
} }
HRESULT CPdfRenderer::PathCommandText(const std::wstring& wsText, const double& dX, const double& dY, const double& dW, const double& dH, const double& dBaselineOffset) HRESULT CPdfRenderer::PathCommandText(const std::wstring& wsText, 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), MM_2_PT(dBaselineOffset)); m_oPath.AddText(m_oFont, wsText, MM_2_PT(dX), MM_2_PT(m_dPageHeight - dY), MM_2_PT(dW), MM_2_PT(dH));
return S_OK; return S_OK;
} }
HRESULT CPdfRenderer::PathCommandTextExCHAR(const LONG& lUnicode, const LONG& lGid, const double& dX, const double& dY, const double& dW, const double& dH, const double& dBaselineOffset, const DWORD& dwFlags) 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), MM_2_PT(dBaselineOffset), dwFlags); 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; return S_OK;
} }
HRESULT CPdfRenderer::PathCommandTextEx(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::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, wsGidText, MM_2_PT(dX), MM_2_PT(m_dPageHeight - dY), MM_2_PT(dW), MM_2_PT(dH), MM_2_PT(dBaselineOffset), dwFlags); 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; return S_OK;
} }
//---------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------
...@@ -1275,11 +1260,11 @@ HRESULT CPdfRenderer::CommandString(const LONG& lType, const std::wstring& sComm ...@@ -1275,11 +1260,11 @@ HRESULT CPdfRenderer::CommandString(const LONG& lType, const std::wstring& sComm
//---------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------
// Pdf // Pdf
//---------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------
HRESULT CPdfRenderer::CommandDrawTextPdf(const std::wstring& bsUnicodeText, const std::wstring& bsGidText, const std::wstring& wsSrcCodeText, const double& dX, const double& dY, const double& dW, const double& dH, const double& dBaselineOffset, const DWORD& dwFlags) HRESULT CPdfRenderer::CommandDrawTextPdf(const std::wstring& bsUnicodeText, const unsigned int* pGids, const unsigned int unGidsCount, const std::wstring& bsSrcCodeText, const double& dX, const double& dY, const double& dW, const double& dH)
{ {
return S_OK; return S_OK;
} }
HRESULT CPdfRenderer::PathCommandTextPdf(const std::wstring& bsUnicodeText, const std::wstring& bsGidText, const std::wstring& bsSrcCodeText, const double& dX, const double& dY, const double& dW, const double& dH, const double& dBaselineOffset, const DWORD& dwFlags) HRESULT CPdfRenderer::PathCommandTextPdf(const std::wstring& bsUnicodeText, const unsigned int* pGids, const unsigned int unGidsCount, const std::wstring& bsSrcCodeText, const double& dX, const double& dY, const double& dW, const double& dH)
{ {
return S_OK; return S_OK;
} }
...@@ -1403,7 +1388,7 @@ bool CPdfRenderer::DrawImage(Aggplus::CImage* pImage, const double& dX, const do ...@@ -1403,7 +1388,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, unsigned short* pGids) bool CPdfRenderer::DrawText(unsigned int* pUnicodes, unsigned int unLen, const double& dX, const double& dY, const unsigned int* pGids)
{ {
if (m_bNeedUpdateTextFont) if (m_bNeedUpdateTextFont)
UpdateFont(); UpdateFont();
......
This diff is collapsed.
...@@ -17,7 +17,7 @@ namespace PdfWriter ...@@ -17,7 +17,7 @@ namespace PdfWriter
static const char* c_sToUnicodeInfo = "/CIDSystemInfo\n<< /Registry (Adobe)\n /Ordering (UCS)\n /Supplement 0\n >> def\n/CMapName /Adobe-Identity-UCS def\n/CMapType 2 def\n1 begincodespacerange\n<0000> <FFFF>\nendcodespacerange\n"; static const char* c_sToUnicodeInfo = "/CIDSystemInfo\n<< /Registry (Adobe)\n /Ordering (UCS)\n /Supplement 0\n >> def\n/CMapName /Adobe-Identity-UCS def\n/CMapType 2 def\n1 begincodespacerange\n<0000> <FFFF>\nendcodespacerange\n";
static const char* c_sToUnicodeFooter = "endcmap\nCMapName currentdict /CMap defineresource pop\nend\nend\n"; static const char* c_sToUnicodeFooter = "endcmap\nCMapName currentdict /CMap defineresource pop\nend\nend\n";
static unsigned short GetGID(FT_Face pFace, unsigned int unUnicode) static unsigned int GetGID(FT_Face pFace, unsigned int unUnicode)
{ {
int nCharIndex = 0; int nCharIndex = 0;
...@@ -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 short* pGids) unsigned char* CFontCidTrueType::EncodeString(unsigned int* pUnicodes, unsigned int unLen, const unsigned int* pGids)
{ {
if (!OpenFontFace()) if (!OpenFontFace())
return NULL; return NULL;
...@@ -224,25 +224,25 @@ namespace PdfWriter ...@@ -224,25 +224,25 @@ 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; unsigned int unGID;
if (!pGids) if (!pGids)
{ {
ushGID = GetGID(m_pFace, unUnicode); unGID = GetGID(m_pFace, unUnicode);
if (0 == ushGID && -1 != m_nSymbolicCmap) if (0 == unGID && -1 != m_nSymbolicCmap)
ushGID = GetGID(m_pFace, unUnicode + 0xF000); unGID = GetGID(m_pFace, unUnicode + 0xF000);
} }
else else
{ {
ushGID = pGids[unIndex]; unGID = pGids[unIndex];
} }
m_vCodeToGid.push_back(ushGID); m_vCodeToGid.push_back(unGID);
// //
m_mGlyphs.insert(std::pair<unsigned short, bool>(ushGID, true)); m_mGlyphs.insert(std::pair<unsigned int, bool>(unGID, true));
// (CompositeGlyf), (subglyfs) // (CompositeGlyf), (subglyfs)
if (0 == FT_Load_Glyph(m_pFace, ushGID, FT_LOAD_NO_SCALE | FT_LOAD_NO_RECURSE)) if (0 == FT_Load_Glyph(m_pFace, unGID, FT_LOAD_NO_SCALE | FT_LOAD_NO_RECURSE))
{ {
for (int nSubIndex = 0; nSubIndex < m_pFace->glyph->num_subglyphs; nSubIndex++) for (int nSubIndex = 0; nSubIndex < m_pFace->glyph->num_subglyphs; nSubIndex++)
{ {
......
...@@ -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 short* pGid = NULL); unsigned char* EncodeString(unsigned int* pUnicodes, unsigned int unLen, const unsigned int* pGids = NULL);
unsigned int GetWidth(unsigned short ushCode); unsigned int GetWidth(unsigned short ushCode);
EFontType GetFontType() EFontType GetFontType()
{ {
...@@ -58,7 +58,7 @@ namespace PdfWriter ...@@ -58,7 +58,7 @@ namespace PdfWriter
std::map<unsigned int, unsigned short> m_mUnicodeToCode; // -> std::map<unsigned int, unsigned short> m_mUnicodeToCode; // ->
std::vector<unsigned int> m_vUnicodes; // -> std::vector<unsigned int> m_vUnicodes; // ->
std::vector<unsigned short> m_vCodeToGid; std::vector<unsigned int> m_vCodeToGid;
std::vector<unsigned int> m_vWidths; std::vector<unsigned int> m_vWidths;
std::map<unsigned short, bool> m_mGlyphs; std::map<unsigned short, bool> m_mGlyphs;
......
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