Commit 10325828 authored by Oleg.Korshul's avatar Oleg.Korshul Committed by Alexander Trofimov

поправил интерфейс работы с текстом (gids)

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@63567 954022d7-b5bf-4e40-9824-e11837661b57
parent 1746479d
......@@ -273,6 +273,26 @@ INT CFontManager::LoadString2(const std::wstring &wsBuffer, const float &fX, con
return TRUE;
}
INT CFontManager::LoadString1(const unsigned int* pGids, const unsigned int& nGidsCount, const float &fX, const float &fY)
{
if (NULL == m_pFont)
return FALSE;
m_oString.SetString(pGids, nGidsCount, fX, fY);
m_pFont->GetString(m_oString);
return TRUE;
}
INT CFontManager::LoadString2(const unsigned int* pGids, const unsigned int& nGidsCount, const float &fX, const float &fY)
{
if (NULL == m_pFont)
return FALSE;
m_oString.SetString(pGids, nGidsCount, fX, fY);
m_pFont->GetString2(m_oString);
return TRUE;
}
INT CFontManager::LoadString3(const LONG& gid, const float &fX, const float &fY)
{
if (NULL == m_pFont)
......
......@@ -118,6 +118,8 @@ public:
INT LoadString1(const std::wstring& wsBuffer, const float& fX, const float& fY);
INT LoadString2(const std::wstring& wsBuffer, const float& fX, const float& fY);
INT LoadString1(const unsigned int* pGids, const unsigned int& nGidsCount, const float& fX, const float& fY);
INT LoadString2(const unsigned int* pGids, const unsigned int& nGidsCount, const float& fX, const float& fY);
INT LoadString3(const LONG& gid, const float& fX, const float& fY);
INT LoadString3C(const LONG& gid, const float& fX, const float& fY);
INT LoadString2C(const LONG& wsBuffer, const float& fX, const float& fY);
......
......@@ -129,6 +129,32 @@ CGlyphString::~CGlyphString()
delete []m_pGlyphsBuffer;
}
void CGlyphString::SetString(const unsigned int* pGids, const unsigned int& nGidsCount, float fX, float fY)
{
m_fX = fX + m_fTransX;
m_fY = fY + m_fTransY;
if ( m_pGlyphsBuffer )
delete []m_pGlyphsBuffer;
m_nGlyphIndex = 0;
m_nGlyphsCount = nGidsCount;
if ( m_nGlyphsCount > 0 )
{
m_pGlyphsBuffer = new TGlyph[m_nGlyphsCount];
for ( int nIndex = 0; nIndex < m_nGlyphsCount; ++nIndex )
{
m_pGlyphsBuffer[nIndex].lUnicode = (long)pGids[nIndex];
m_pGlyphsBuffer[nIndex].bBitmap = false;
}
}
else
{
m_pGlyphsBuffer = NULL;
}
}
void CGlyphString::SetString(const std::wstring& wsString, float fX, float fY)
{
......
......@@ -135,6 +135,7 @@ public:
CGlyphString(const std::wstring& wsString, float fX = 0, float fY = 0);
~CGlyphString();
void SetString(const std::wstring& wsString, float fX = 0, float fY = 0);
void SetString(const unsigned int* pGids, const unsigned int& nGidsCount, float fX = 0, float fY = 0);
void SetStringGID(const LONG& gid, float fX = 0, float fY = 0);
void Reset();
int GetLength();
......@@ -169,4 +170,4 @@ private:
int m_nGlyphIndex; // Номер текущего символа
};
#endif /* _BUILD_GLYPH_STRING_H */
\ No newline at end of file
#endif /* _BUILD_GLYPH_STRING_H */
......@@ -999,6 +999,51 @@ namespace Aggplus
return TRUE;
}
INT CGraphics::DrawString(const unsigned int* pGids, const unsigned int nGidsCount, CFontManager* pFont, CBrush* pBrush, double x, double y)
{
if (pBrush->GetType() != BrushTypeSolidColor)
return TRUE;
CMatrix oMatrix = m_oBaseTransform;
oMatrix.Multiply(&m_oTransform, MatrixOrderPrepend);
double mass[6];
oMatrix.GetElements(mass);
double _x = x;
double _y = y;
CMatrix oM1 = oMatrix;
oM1.Invert();
oM1.Multiply(&m_oFullTransform, MatrixOrderPrepend);
oM1.TransformPoint(_x, _y);
pFont->SetTextMatrix((float)mass[0], (float)mass[1], (float)mass[2], (float)mass[3], (float)mass[4], (float)mass[5]);
pFont->LoadString2(pGids, nGidsCount, (float)_x, (float)_y);
float fX = 0;
float fY = 0;
INT bRes = FALSE;
while (TRUE)
{
TGlyph* pGlyph = NULL;
float fX = 0, fY = 0;
bRes = pFont->GetNextChar2(pGlyph, fX, fY);
if (FALSE == bRes)
break;
if (NULL != pGlyph)
{
FillGlyph2((int)fX, (int)fY, pGlyph, pBrush);
}
}
return TRUE;
}
INT CGraphics::DrawStringC(const LONG& lText, CFontManager* pFont, CBrush* pBrush, double x, double y)
{
if (pBrush->GetType() != BrushTypeSolidColor)
......
......@@ -366,6 +366,7 @@ public:
// отрисовка текста
INT DrawString(const std::wstring& strText, CFontManager* pFont, CBrush* pBrush, double x, double y);
INT DrawString(const unsigned int* pGids, const unsigned int nGidsCount, CFontManager* pFont, CBrush* pBrush, double x, double y);
INT DrawStringC(const LONG& lText, CFontManager* pFont, CBrush* pBrush, double x, double y);
INT DrawStringPath(const std::wstring& strText, CFontManager* pFont, CBrush* pBrush, double x, double y);
INT DrawStringPathC(const LONG& lText, CFontManager* pFont, CBrush* pBrush, double x, double y);
......
......@@ -405,6 +405,15 @@ namespace Aggplus
pFont->LoadString1(strText, (float)x, (float)y);
return (TRUE == pFont->GetStringPath(this)) ? Ok : InvalidParameter;
}
Status CGraphicsPath::AddString(const unsigned int* pGids, const unsigned int nGidsCount, CFontManager* pFont, double x, double y)
{
if (NULL == pFont)
return InvalidParameter;
pFont->LoadString1(pGids, nGidsCount, (float)x, (float)y);
return (TRUE == pFont->GetStringPath(this)) ? Ok : InvalidParameter;
}
Status CGraphicsPath::AddStringC(const LONG& lText, CFontManager* pFont, double x, double y)
{
if (NULL == pFont)
......@@ -1168,4 +1177,4 @@ namespace Aggplus
return false;
}
}
\ No newline at end of file
}
......@@ -70,6 +70,7 @@ public:
virtual bool _CurveTo(double x1, double y1, double x2, double y2, double x3, double y3);
virtual bool _Close();
Status AddString(const std::wstring& strText, CFontManager* pFont, double x, double y);
Status AddString(const unsigned int* pGids, const unsigned int nGidsCount, CFontManager* pFont, double x, double y);
Status AddStringC(const LONG& lText, CFontManager* pFont, double x, double y);
void z_Stroke(const NSStructures::CPen* Pen);
void Widen(const NSStructures::CPen* Pen, const CMatrix* matrix, float flatness);
......@@ -151,4 +152,4 @@ protected:
};
}
#endif // _BUILD_GRAPHICSPATH_H_
\ No newline at end of file
#endif // _BUILD_GRAPHICSPATH_H_
......@@ -586,7 +586,7 @@ HRESULT CGraphicsRenderer::put_FontFaceIndex(const int& lFaceIndex)
}
//-------- Функции для вывода текста --------------------------------------------------------
HRESULT CGraphicsRenderer::CommandDrawTextCHAR(const LONG& c, const double& x, const double& y, const double& w, const double& h, const double& baselineOffset)
HRESULT CGraphicsRenderer::CommandDrawTextCHAR(const LONG& c, const double& x, const double& y, const double& w, const double& h)
{
if (c_nHyperlinkType == m_lCurrentCommandType)
return S_OK;
......@@ -595,13 +595,13 @@ HRESULT CGraphicsRenderer::CommandDrawTextCHAR(const LONG& c, const double& x, c
_SetFont();
Aggplus::CBrush* pBrush = CreateBrush(&m_oBrush);
m_pRenderer->DrawStringC(c, m_pFontManager, pBrush, x, y + baselineOffset);
m_pRenderer->DrawStringC(c, m_pFontManager, pBrush, x, y);
RELEASEOBJECT(pBrush);
return S_OK;
}
HRESULT CGraphicsRenderer::CommandDrawText(const std::wstring& bsText, const double& x, const double& y, const double& w, const double& h, const double& baselineOffset)
HRESULT CGraphicsRenderer::CommandDrawText(const std::wstring& bsText, const double& x, const double& y, const double& w, const double& h)
{
if (c_nHyperlinkType == m_lCurrentCommandType)
return S_OK;
......@@ -610,35 +610,46 @@ HRESULT CGraphicsRenderer::CommandDrawText(const std::wstring& bsText, const dou
_SetFont();
Aggplus::CBrush* pBrush = CreateBrush(&m_oBrush);
m_pRenderer->DrawString(bsText, m_pFontManager, pBrush, x, y + baselineOffset);
m_pRenderer->DrawString(bsText, m_pFontManager, pBrush, x, y);
RELEASEOBJECT(pBrush);
return S_OK;
}
HRESULT CGraphicsRenderer::CommandDrawTextExCHAR(const LONG& c, const LONG& gid, const double& x, const double& y, const double& w, const double& h, const double& baselineOffset, const DWORD& lFlags)
HRESULT CGraphicsRenderer::CommandDrawTextExCHAR(const LONG& c, const LONG& gid, const double& x, const double& y, const double& w, const double& h)
{
if (gid >= 0)
{
m_oFont.StringGID = TRUE;
return CommandDrawTextCHAR(gid, x, y, w, h, baselineOffset);
return CommandDrawTextCHAR(gid, x, y, w, h);
}
m_oFont.StringGID = FALSE;
return CommandDrawTextCHAR(c, x, y, w, h, baselineOffset);
return CommandDrawTextCHAR(c, x, y, w, h);
}
HRESULT CGraphicsRenderer::CommandDrawTextEx(const std::wstring& bsUnicodeText, const std::wstring& bsGidText, const double& x, const double& y, const double& w, const double& h, const double& baselineOffset, const DWORD& lFlags)
HRESULT CGraphicsRenderer::CommandDrawTextEx(const std::wstring& bsUnicodeText, const unsigned int* pGids, const unsigned int nGidsCount, const double& x, const double& y, const double& w, const double& h)
{
if (!bsGidText.empty())
if (NULL != pGids)
{
m_oFont.StringGID = TRUE;
return CommandDrawText(bsGidText, x, y, w, h, baselineOffset);
m_oFont.StringGID = TRUE;
if (c_nHyperlinkType == m_lCurrentCommandType)
return S_OK;
put_BrushType(c_BrushTypeSolid);
_SetFont();
Aggplus::CBrush* pBrush = CreateBrush(&m_oBrush);
m_pRenderer->DrawString(pGids, nGidsCount, m_pFontManager, pBrush, x, y);
RELEASEOBJECT(pBrush);
return S_OK;
}
m_oFont.StringGID = FALSE;
return CommandDrawText(bsUnicodeText, x, y, w, h, baselineOffset);
m_oFont.StringGID = FALSE;
return CommandDrawText(bsUnicodeText, x, y, w, h);
}
//-------- Маркеры для команд ---------------------------------------------------------------
......@@ -909,7 +920,7 @@ HRESULT CGraphicsRenderer::PathCommandGetCurrentPoint(double* x, double* y)
}
// textpath
HRESULT CGraphicsRenderer::PathCommandTextCHAR(const LONG& c, const double& x, const double& y, const double& w, const double& h, const double& baselineOffset)
HRESULT CGraphicsRenderer::PathCommandTextCHAR(const LONG& c, const double& x, const double& y, const double& w, const double& h)
{
if (!CheckValidate())
return S_FALSE;
......@@ -918,11 +929,11 @@ HRESULT CGraphicsRenderer::PathCommandTextCHAR(const LONG& c, const double& x, c
// так как пат рисуется в миллиметрах - надо перевести пункты в миллиметры
float fSize = (float)(0.3528 * m_oFont.Size);
m_pPath->AddStringC(c, m_pFontManager, x, y + baselineOffset);
m_pPath->AddStringC(c, m_pFontManager, x, y);
return S_OK;
}
HRESULT CGraphicsRenderer::PathCommandText(const std::wstring& bsText, const double& x, const double& y, const double& w, const double& h, const double& baselineOffset)
HRESULT CGraphicsRenderer::PathCommandText(const std::wstring& bsText, const double& x, const double& y, const double& w, const double& h)
{
if (!CheckValidate())
return S_FALSE;
......@@ -931,32 +942,41 @@ HRESULT CGraphicsRenderer::PathCommandText(const std::wstring& bsText, const dou
// так как пат рисуется в миллиметрах - надо перевести пункты в миллиметры
float fSize = (float)(0.3528 * m_oFont.Size);
m_pPath->AddString(bsText, m_pFontManager, x, y + baselineOffset);
m_pPath->AddString(bsText, m_pFontManager, x, y);
return S_OK;
}
HRESULT CGraphicsRenderer::PathCommandTextExCHAR(const LONG& c, const LONG& gid, const double& x, const double& y, const double& w, const double& h, const double& baselineOffset, const DWORD& lFlags)
HRESULT CGraphicsRenderer::PathCommandTextExCHAR(const LONG& c, const LONG& gid, const double& x, const double& y, const double& w, const double& h)
{
if (gid >= 0)
{
m_oFont.StringGID = TRUE;
return PathCommandTextCHAR(gid, x, y, w, h, baselineOffset);
return PathCommandTextCHAR(gid, x, y, w, h);
}
m_oFont.StringGID = FALSE;
return PathCommandTextCHAR(c, x, y, w, h, baselineOffset);
return PathCommandTextCHAR(c, x, y, w, h);
}
HRESULT CGraphicsRenderer::PathCommandTextEx(const std::wstring& bsUnicodeText, const std::wstring& bsGidText, const double& x, const double& y, const double& w, const double& h, const double& baselineOffset, const DWORD& lFlags)
HRESULT CGraphicsRenderer::PathCommandTextEx(const std::wstring& bsUnicodeText, const unsigned int* pGids, const unsigned int nGidsCount, const double& x, const double& y, const double& w, const double& h)
{
if (!bsGidText.empty())
if (NULL != pGids)
{
m_oFont.StringGID = TRUE;
return PathCommandText(bsGidText, x, y, w, h, baselineOffset);
if (!CheckValidate())
return S_FALSE;
_SetFont();
// так как пат рисуется в миллиметрах - надо перевести пункты в миллиметры
float fSize = (float)(0.3528 * m_oFont.Size);
m_pPath->AddString(pGids, nGidsCount, m_pFontManager, x, y);
return S_OK;
}
m_oFont.StringGID = FALSE;
return PathCommandText(bsUnicodeText, x, y, w, h, baselineOffset);
return PathCommandText(bsUnicodeText, x, y, w, h);
}
//-------- Функции для вывода изображений ---------------------------------------------------
......
......@@ -169,11 +169,11 @@ public:
virtual HRESULT put_FontFaceIndex(const int& lFaceIndex);
//-------- Функции для вывода текста --------------------------------------------------------
virtual HRESULT CommandDrawTextCHAR(const LONG& c, const double& x, const double& y, const double& w, const double& h, const double& baselineOffset);
virtual HRESULT CommandDrawText(const std::wstring& bsText, const double& x, const double& y, const double& w, const double& h, const double& baselineOffset);
virtual HRESULT CommandDrawTextExCHAR(const LONG& c, const LONG& gid, const double& x, const double& y, const double& w, const double& h, const double& baselineOffset, const DWORD& lFlags);
virtual HRESULT CommandDrawTextEx(const std::wstring& bsUnicodeText, const std::wstring& bsGidText, const double& x, const double& y, const double& w, const double& h, const double& baselineOffset, const DWORD& lFlags);
virtual HRESULT CommandDrawTextCHAR(const LONG& c, const double& x, const double& y, const double& w, const double& h);
virtual HRESULT CommandDrawText(const std::wstring& bsText, const double& x, const double& y, const double& w, const double& h);
virtual HRESULT CommandDrawTextExCHAR(const LONG& c, const LONG& gid, const double& x, const double& y, const double& w, const double& h);
virtual HRESULT CommandDrawTextEx(const std::wstring& bsUnicodeText, const unsigned int* pGids, const unsigned int nGidsCount, const double& x, const double& y, const double& w, const double& h);
//-------- Маркеры для команд ---------------------------------------------------------------
virtual HRESULT BeginCommand(const DWORD& lType);
......@@ -192,11 +192,11 @@ public:
virtual HRESULT PathCommandStart();
virtual HRESULT PathCommandGetCurrentPoint(double* x, double* y);
virtual HRESULT PathCommandTextCHAR(const LONG& c, const double& x, const double& y, const double& w, const double& h, const double& baselineOffset);
virtual HRESULT PathCommandText(const std::wstring& bsText, const double& x, const double& y, const double& w, const double& h, const double& baselineOffset);
virtual HRESULT PathCommandTextExCHAR(const LONG& c, const LONG& gid, const double& x, const double& y, const double& w, const double& h, const double& baselineOffset, const DWORD& lFlags);
virtual HRESULT PathCommandTextEx(const std::wstring& bsUnicodeText, const std::wstring& bsGidText, const double& x, const double& y, const double& w, const double& h, const double& baselineOffset, const DWORD& lFlags);
virtual HRESULT PathCommandTextCHAR(const LONG& c, const double& x, const double& y, const double& w, const double& h);
virtual HRESULT PathCommandText(const std::wstring& bsText, const double& x, const double& y, const double& w, const double& h);
virtual HRESULT PathCommandTextExCHAR(const LONG& c, const LONG& gid, const double& x, const double& y, const double& w, const double& h);
virtual HRESULT PathCommandTextEx(const std::wstring& sText, const unsigned int* pGids, const unsigned int nGidsCount, const double& x, const double& y, const double& w, const double& h);
//-------- Функции для вывода изображений ---------------------------------------------------
virtual HRESULT DrawImage(IGrObject* pImage, const double& x, const double& y, const double& w, const double& h);
......
......@@ -221,11 +221,11 @@ public:
virtual HRESULT put_FontFaceIndex(const int& lFaceIndex) = 0;
//-------- Функции для вывода текста --------------------------------------------------------
virtual HRESULT CommandDrawTextCHAR(const LONG& c, const double& x, const double& y, const double& w, const double& h) = 0;
virtual HRESULT CommandDrawText(const std::wstring& bsText, const double& x, const double& y, const double& w, const double& h) = 0;
virtual HRESULT CommandDrawTextExCHAR(const LONG& c, const LONG& gid, const double& x, const double& y, const double& w, const double& h) = 0;
virtual HRESULT CommandDrawTextEx(const std::wstring& bsUnicodeText, const unsigned int* pGids, const unsigned int nGidsCount, const double& x, const double& y, const double& w, const double& h) = 0;
virtual HRESULT CommandDrawTextCHAR(const LONG& c, const double& x, const double& y, const double& w, const double& h) = 0;
virtual HRESULT CommandDrawText(const std::wstring& bsText, const double& x, const double& y, const double& w, const double& h) = 0;
virtual HRESULT CommandDrawTextExCHAR(const LONG& c, const LONG& gid, const double& x, const double& y, const double& w, const double& h) = 0;
virtual HRESULT CommandDrawTextEx(const std::wstring& bsUnicodeText, const unsigned int* pGids, const unsigned int nGidsCount, const double& x, const double& y, const double& w, const double& h) = 0;
//-------- Маркеры для команд ---------------------------------------------------------------
virtual HRESULT BeginCommand(const DWORD& lType) = 0;
......@@ -244,11 +244,11 @@ public:
virtual HRESULT PathCommandStart() = 0;
virtual HRESULT PathCommandGetCurrentPoint(double* x, double* y) = 0;
virtual HRESULT PathCommandTextCHAR(const LONG& c, const double& x, const double& y, const double& w, const double& h) = 0;
virtual HRESULT PathCommandText(const std::wstring& bsText, const double& x, const double& y, const double& w, const double& h) = 0;
virtual HRESULT PathCommandTextExCHAR(const LONG& c, const LONG& gid, const double& x, const double& y, const double& w, const double& h) = 0;
virtual HRESULT PathCommandTextEx(const std::wstring& sText, const unsigned int* pGids, const unsigned int nGidsCount, const double& x, const double& y, const double& w, const double& h) = 0;
virtual HRESULT PathCommandTextCHAR(const LONG& c, const double& x, const double& y, const double& w, const double& h) = 0;
virtual HRESULT PathCommandText(const std::wstring& bsText, const double& x, const double& y, const double& w, const double& h) = 0;
virtual HRESULT PathCommandTextExCHAR(const LONG& c, const LONG& gid, const double& x, const double& y, const double& w, const double& h) = 0;
virtual HRESULT PathCommandTextEx(const std::wstring& sText, const unsigned int* pGids, const unsigned int nGidsCount, const double& x, const double& y, const double& w, const double& h) = 0;
//-------- Функции для вывода изображений ---------------------------------------------------
virtual HRESULT DrawImage(IGrObject* pImage, const double& x, const double& y, const double& w, const double& h) = 0;
......
......@@ -300,7 +300,7 @@ namespace MetaFile
if (NULL == pDx)
{
m_pRenderer->CommandDrawText(wsText, dX, dY, 0, 0, 0);
m_pRenderer->CommandDrawText(wsText, dX, dY, 0, 0);
}
else
{
......@@ -310,7 +310,7 @@ namespace MetaFile
{
std::wstring wsChar;
wsChar += wsText.at(unCharIndex);
m_pRenderer->CommandDrawText(wsChar, dX + dOffset, dY, 0, 0, 0);
m_pRenderer->CommandDrawText(wsChar, dX + dOffset, dY, 0, 0);
dOffset += (pDx[unCharIndex] * dKoefX);
}
}
......@@ -795,4 +795,4 @@ namespace MetaFile
bool m_bStartedPath;
};
}
#endif // _METAFILE_COMMON_METAFILERENDERER_H
\ No newline at end of file
#endif // _METAFILE_COMMON_METAFILERENDERER_H
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