Commit 001efe9f authored by Elen.Subbotina's avatar Elen.Subbotina Committed by Alexander Trofimov

коррекция цветов под linux в Emf

исправление ошибки со шрифтами в Emf под linux

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@62276 954022d7-b5bf-4e40-9824-e11837661b57
parent 0ff4a777
......@@ -567,7 +567,12 @@ int CFontFile::SetCMapForCharCode2(long lUnicode)
FT_Int unGID;
int nCMapIndex = 0;
int nCacheIndex = m_arrCacheSizesIndexs[lUnicode];
int nCacheIndex = 0xFFFF;
if (lUnicode < FONT_CACHE_SIZES_INDEXES_SIZE) //linux !!!
{
nCacheIndex = m_arrCacheSizesIndexs[lUnicode];
}
if ( 0xFFFF == nCacheIndex )
{
return unGID = SetCMapForCharCode( lUnicode, &nCMapIndex );
......@@ -591,9 +596,12 @@ int CFontFile::SetCMapForCharCode2(long lUnicode)
return unGID;
}
void CFontFile::AddToSizesCache(const TFontCacheSizes& oSizes)
bool CFontFile::AddToSizesCache(const TFontCacheSizes& oSizes)
{
if (oSizes.ushUnicode >= FONT_CACHE_SIZES_INDEXES_SIZE) return false; //oSizes.ushUnicode = 4784212 !!! linux
m_arrCacheSizesIndexs[oSizes.ushUnicode] = m_oCacheSizes.Add( oSizes );
return true;
}
TFontCacheSizes CFontFile::GetChar(LONG lUnicode)
......@@ -613,7 +621,13 @@ TFontCacheSizes CFontFile::GetChar(LONG lUnicode)
}
LONG unGID = 0;
USHORT charSymbolObj = m_arrCacheSizesIndexs[ushUnicode];
USHORT charSymbolObj = 0xFFFF;
if (ushUnicode < FONT_CACHE_SIZES_INDEXES_SIZE) //вылетает под Linux
{
charSymbolObj = m_arrCacheSizesIndexs[ushUnicode];
}
if (0xFFFF == charSymbolObj)
{
int nCMapIndex = 0;
......@@ -743,7 +757,12 @@ INT CFontFile::GetString(CGlyphString& oString)
int ushUnicode = pCurGlyph->lUnicode;
int unGID = 0;
USHORT charSymbolObj = m_arrCacheSizesIndexs[ushUnicode];
USHORT charSymbolObj = 0xFFFF;
if (ushUnicode >= 0 && ushUnicode >= 0 && ushUnicode < FONT_CACHE_SIZES_INDEXES_SIZE) //вылетает под Linux
{
charSymbolObj = m_arrCacheSizesIndexs[ushUnicode];
}
if (0xFFFF == charSymbolObj)
{
int nCMapIndex = 0;
......@@ -839,8 +858,10 @@ INT CFontFile::GetString(CGlyphString& oString)
if (m_bNeedDoBold)
oSizes.fAdvanceX += 1;
AddToSizesCache( oSizes );
charSymbolObj = m_arrCacheSizesIndexs[oSizes.ushUnicode];
if ( AddToSizesCache( oSizes ) == true)
{
charSymbolObj = m_arrCacheSizesIndexs[oSizes.ushUnicode];
}
}
if (0xFFFF != charSymbolObj)
{
......@@ -949,7 +970,13 @@ INT CFontFile::GetString2(CGlyphString& oString)
int ushUnicode = pCurGlyph->lUnicode;
int unGID = 0;
USHORT charSymbolObj = m_arrCacheSizesIndexs[ushUnicode];
USHORT charSymbolObj = 0xFFFF;
if ( ushUnicode >= 0 && ushUnicode < FONT_CACHE_SIZES_INDEXES_SIZE) //linux !!!!
{
charSymbolObj = m_arrCacheSizesIndexs[ushUnicode];
}
if (0xFFFF == charSymbolObj || m_oCacheSizes[charSymbolObj].bBitmap == false)
{
int nCMapIndex = 0;
......@@ -1117,8 +1144,10 @@ INT CFontFile::GetString2(CGlyphString& oString)
oSizes.oBitmap.nHeight = pBitmap->nHeight;
oSizes.oBitmap.pData = pBitmap->pData;
AddToSizesCache( oSizes );
charSymbolObj = m_arrCacheSizesIndexs[oSizes.ushUnicode];
if ( AddToSizesCache( oSizes ) == true)
{
charSymbolObj = m_arrCacheSizesIndexs[oSizes.ushUnicode];
}
}
if (0xFFFF != charSymbolObj)
{
......@@ -1217,7 +1246,13 @@ INT CFontFile::GetString2C(CGlyphString& oString)
int ushUnicode = pCurGlyph->lUnicode;
int unGID = 0;
USHORT charSymbolObj = m_arrCacheSizesIndexs[ushUnicode];
USHORT charSymbolObj = 0xFFFF;
if (ushUnicode >= 0 && ushUnicode < FONT_CACHE_SIZES_INDEXES_SIZE) //вылетает под Linux
{
charSymbolObj = m_arrCacheSizesIndexs[ushUnicode];
}
if (0xFFFF == charSymbolObj || m_oCacheSizes[charSymbolObj].bBitmap == false)
{
int nCMapIndex = 0;
......@@ -1385,8 +1420,10 @@ INT CFontFile::GetString2C(CGlyphString& oString)
oSizes.oBitmap.nHeight = pBitmap->nHeight;
oSizes.oBitmap.pData = pBitmap->pData;
AddToSizesCache( oSizes );
charSymbolObj = m_arrCacheSizesIndexs[oSizes.ushUnicode];
if (AddToSizesCache( oSizes ) == true)
{
charSymbolObj = m_arrCacheSizesIndexs[oSizes.ushUnicode];
}
}
if (0xFFFF != charSymbolObj)
{
......
......@@ -203,7 +203,7 @@ public:
INT GetString2C(CGlyphString& oString);
TFontCacheSizes GetChar(LONG lUnicode);
void AddToSizesCache(const TFontCacheSizes& oSizes);
bool AddToSizesCache(const TFontCacheSizes& oSizes);
int SetCMapForCharCode(long lUnicode, int *pnCMapIndex);
int SetCMapForCharCode2(long lUnicode);
......@@ -245,4 +245,4 @@ static int GlyphPathLineTo(const FT_Vector *pPoint, void *pPath);
static int GlyphPathConicTo(const FT_Vector *pControlPoint, const FT_Vector *pEndPoint, void *pPath);
static int GlyphPathCubicTo(const FT_Vector *pFirstControlPoint, const FT_Vector *pSecondControlPoint, const FT_Vector *pEndPoint, void *pPath);
#endif // _BUILD_FONT_ENGINE_FONTFILE_H_
\ No newline at end of file
#endif // _BUILD_FONT_ENGINE_FONTFILE_H_
......@@ -188,9 +188,9 @@ namespace MetaFile
{
int nBit = (nByte & nBitIndex);
TRgbQuad* pColor = (nBit ? &oColor2 : &oColor1);
pBgraBuffer[nIndex + 0] = pColor->b;
pBgraBuffer[nIndex + 1] = pColor->g;
pBgraBuffer[nIndex + 2] = pColor->r;
pBgraBuffer[nIndex + 0] = pColor->b;
pBgraBuffer[nIndex + 1] = pColor->g;
pBgraBuffer[nIndex + 2] = pColor->r;
pBgraBuffer[nIndex + 3] = 255;
nIndex += 4;
}
......@@ -387,10 +387,10 @@ namespace MetaFile
BYTE nByte = *pBuffer; pBuffer++; lBufLen--;
pBgraBuffer[nIndex + 0] = oColorTable[nByte].b;
pBgraBuffer[nIndex + 0] = oColorTable[nByte].b;
pBgraBuffer[nIndex + 1] = oColorTable[nByte].g;
pBgraBuffer[nIndex + 2] = oColorTable[nByte].r;
pBgraBuffer[nIndex + 3] = 255;
pBgraBuffer[nIndex + 2] = oColorTable[nByte].r;
pBgraBuffer[nIndex + 3] = 255;
}
pBuffer += nAdd; lBufLen -= nAdd;
}
......@@ -645,9 +645,15 @@ namespace MetaFile
}
else
{
pBgraBuffer[nIndex + 0] = pBuffer[0]; pBuffer++; lBufLen--;
#ifdef __linux__
pBgraBuffer[nIndex + 2] = pBuffer[0]; pBuffer++; lBufLen--;
pBgraBuffer[nIndex + 1] = pBuffer[0]; pBuffer++; lBufLen--;
pBgraBuffer[nIndex + 2] = pBuffer[0]; pBuffer++; lBufLen--;
pBgraBuffer[nIndex + 0] = pBuffer[0]; pBuffer++; lBufLen--;
#else
pBgraBuffer[nIndex + 0] = pBuffer[0]; pBuffer++; lBufLen--;
pBgraBuffer[nIndex + 1] = pBuffer[0]; pBuffer++; lBufLen--;
pBgraBuffer[nIndex + 2] = pBuffer[0]; pBuffer++; lBufLen--;
#endif
pBgraBuffer[nIndex + 3] = 255; pBuffer++; lBufLen--; // ,
}
}
......@@ -684,9 +690,15 @@ namespace MetaFile
}
else
{
pBgraBuffer[nIndex + 0] = pBuffer[0]; pBuffer++; lBufLen--;
#ifdef __linux__
pBgraBuffer[nIndex + 2] = pBuffer[0]; pBuffer++; lBufLen--;
pBgraBuffer[nIndex + 1] = pBuffer[0]; pBuffer++; lBufLen--;
pBgraBuffer[nIndex + 2] = pBuffer[0]; pBuffer++; lBufLen--;
pBgraBuffer[nIndex + 0] = pBuffer[0]; pBuffer++; lBufLen--;
#else
pBgraBuffer[nIndex + 0] = pBuffer[0]; pBuffer++; lBufLen--;
pBgraBuffer[nIndex + 1] = pBuffer[0]; pBuffer++; lBufLen--;
pBgraBuffer[nIndex + 2] = pBuffer[0]; pBuffer++; lBufLen--;
#endif
pBgraBuffer[nIndex + 3] = 255; pBuffer++; lBufLen--; // ,
}
}
......
......@@ -19,9 +19,9 @@ typedef unsigned char BYTE;
namespace MetaFile
{
#define METAFILE_RGBA(r, g, b) ((DWORD)( ( (BYTE)(r) )| ( ( (BYTE)(g) ) << 8 ) | ( ( (BYTE)(b) ) << 16 ) | ( (BYTE)(0) << 24 ) ) )
#define METAFILE_RGBA(r, g, b) ((DWORD)( ( (BYTE)(r) )| ( ( (BYTE)(g) ) << 8 ) | ( ( (BYTE)(b) ) << 16 ) | ( (BYTE)(0) << 24 ) ) )
struct TRgbQuad
struct TRgbQuad
{
unsigned char r;
unsigned char g;
......@@ -209,10 +209,18 @@ namespace MetaFile
}
CDataStream& operator>>(TEmfColor& oColor)
{
*this >> oColor.r;
*this >> oColor.g;
*this >> oColor.b;
*this >> oColor.a;
#if __linux__
*this >> oColor.b;
*this >> oColor.g;
*this >> oColor.r;
*this >> oColor.a;
#else
*this >> oColor.r;
*this >> oColor.g;
*this >> oColor.b;
*this >> oColor.a;
#endif
return *this;
}
......@@ -441,10 +449,16 @@ namespace MetaFile
}
CDataStream& operator>>(TRgbQuad& oRGB)
{
*this >> oRGB.b;
#ifdef __linux__
*this >> oRGB.r;
*this >> oRGB.g;
*this >> oRGB.r;
Skip(1); // reserved
*this >> oRGB.b;
#else
*this >> oRGB.b;
*this >> oRGB.g;
*this >> oRGB.r;
#endif
Skip(1); // reserved
return *this;
}
......@@ -675,4 +689,4 @@ namespace MetaFile
void ReadImage(BYTE* pHeaderBuffer, unsigned int ulHeaderBufferLen, BYTE* pImageBuffer, unsigned int ulImageBufferLen, BYTE** ppDstBuffer, unsigned int* pulWidth, unsigned int* pulHeight);
};
#endif //_METAFILE_WMF_EMF_COMMON_H
\ No newline at end of file
#endif //_METAFILE_WMF_EMF_COMMON_H
......@@ -764,9 +764,9 @@ namespace MetaFile
{
//
pBgraBuffer = new BYTE[4];
pBgraBuffer[0] = pBrush->Color.b;
pBgraBuffer[0] = pBrush->Color.b;
pBgraBuffer[1] = pBrush->Color.g;
pBgraBuffer[2] = pBrush->Color.r;
pBgraBuffer[2] = pBrush->Color.r;
pBgraBuffer[3] = 30;
ulWidth = 1;
......@@ -1730,9 +1730,9 @@ namespace MetaFile
//
BYTE pBgraBuffer[4];
pBgraBuffer[0] = oColor.b;
pBgraBuffer[0] = oColor.b;
pBgraBuffer[1] = oColor.g;
pBgraBuffer[2] = oColor.r;
pBgraBuffer[2] = oColor.r;
pBgraBuffer[3] = 0xff;
if (m_pOutput)
......@@ -1809,4 +1809,4 @@ namespace MetaFile
};
}
#endif // _EMF_FILE_H
\ No newline at end of file
#endif // _EMF_FILE_H
......@@ -6,6 +6,11 @@
#if !defined(_WIN32) && !defined(_WIN64)
//from wingdi.h
#define PT_CLOSEFIGURE 0x01
#define PT_LINETO 0x02
#define PT_BEZIERTO 0x04
#define PT_MOVETO 0x06
#ifndef _MAC
#define ENHMETA_SIGNATURE 0x464D4520
#else
......
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