Commit 105a23d5 authored by Oleg Korshul's avatar Oleg Korshul

DocxRenderer (not worked)

parent ef76c800
This diff is collapsed.
This diff is collapsed.
QT -= core gui
VERSION = 1.0.0.4
TARGET = DocxRenderer
TEMPLATE = lib
CONFIG += shared
CONFIG += plugin
CONFIG += core_static_link_libstd
CORE_ROOT_DIR = $$PWD/..
PWD_ROOT_DIR = $$PWD
include(../Common/base.pri)
DEFINES += DOCXRENDERER_USE_DYNAMIC_LIBRARY
CONFIG += build_all_zlib build_zlib_as_sources
include(../OfficeUtils/OfficeUtils.pri)
CONFIG += build_cximage_zlib_disable
include(../DesktopEditor/Qt_build/graphics/project/graphics.pri)
include(../DesktopEditor/xml/build/qt/libxml2.pri)
#UnicodeConverter
LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -lUnicodeConverter
core_windows {
LIBS += -lgdi32 \
-ladvapi32 \
-luser32 \
-lshell32
}
HEADERS += \
src/resources/resources.h
HEADERS += \
src/logic/Common.h \
src/logic/Document.h \
src/logic/ElementImage.h \
src/logic/ElementParagraph.h \
src/logic/ElementShape.h \
src/logic/FontManager.h \
src/logic/FontManagerBase.h \
src/logic/Page.h
HEADERS += \
DocxRenderer.h
SOURCES += \
DocxRenderer.cpp
This diff is collapsed.
This diff is collapsed.
#pragma once
#include "Common.h"
namespace NSDocxRenderer
{
static _bstr_t g_bstr_image_1 = L"<w:r><w:pict><v:shape id=\"\" type=\"\" style=\"position:absolute;";
static _bstr_t g_bstr_image_2 = L"z-index:-1;mso-position-horizontal-relative:page;mso-position-vertical-relative:page\" filled=\"f\">";
static _bstr_t g_bstr_image_3 = L"</v:shape></w:pict></w:r>";
static CString g_string_image_position = _T("margin-left:%.2lfmm;margin-top:%.2lfmm;width:%.2lfmm;height:%.2lfmm;");
static CString g_string_image_position_rotate = _T("margin-left:%.2lfmm;margin-top:%.2lfmm;width:%.2lfmm;height:%.2lfmm;rotation:%d;");
static CString g_string_image_rid = _T("<v:imagedata r:id=\"rId%d\" o:title=\"\"/>");
class CImage : public CBaseItem
{
public:
CString m_strPath;
LONG m_lID;
double m_dLeft;
double m_dTop;
double m_dWidth;
double m_dHeight;
double m_dRotate;
public:
CImage()
{
m_eType = etImage;
m_strPath = _T("");
m_lID = -1;
}
CImage(const CImage& oSrc)
{
*this = oSrc;
}
CImage(const CImageInfo& oInfo, const CString& strDstMedia)
{
m_eType = etImage;
m_strPath = strDstMedia;
m_lID = oInfo.m_lID;
}
CImage& operator=(const CImage& oSrc)
{
m_eType = etImage;
m_strPath = oSrc.m_strPath;
m_lID = oSrc.m_lID;
m_dLeft = oSrc.m_dLeft;
m_dTop = oSrc.m_dTop;
m_dWidth = oSrc.m_dWidth;
m_dHeight = oSrc.m_dHeight;
m_dRotate = oSrc.m_dRotate;
return *this;
}
virtual void ToXml(NSDocxRenderer::CStringWriter& oWriter)
{
oWriter.WriteString(g_bstr_image_1);
if (0.0 == m_dRotate)
{
CString strPosition = _T("");
strPosition.Format(g_string_image_position, m_dLeft, m_dTop, m_dWidth, m_dHeight);
oWriter.WriteString(strPosition);
}
else
{
CString strPosition = _T("");
strPosition.Format(g_string_image_position_rotate, m_dLeft, m_dTop, m_dWidth, m_dHeight, (int)m_dRotate);
oWriter.WriteString(strPosition);
}
oWriter.WriteString(g_bstr_image_2);
CString strRid = _T("");
strRid.Format(g_string_image_rid, 10 + m_lID);
oWriter.WriteString(strRid);
oWriter.WriteString(g_bstr_image_3);
}
};
}
\ No newline at end of file
This diff is collapsed.
#pragma once
#include "Common.h"
namespace NSDocxRenderer
{
static _bstr_t g_vml_bstr_ClosePath = L"x";
static _bstr_t g_vml_bstr_EndPath = L"e";
static _bstr_t g_vml_bstr_NoFill = L"nf";
static _bstr_t g_vml_bstr_NoStroke = L"ns";
static CString g_vml_string_MoveTo = _T("m%d,%d");
static CString g_vml_string_LineTo = _T("l%d,%d");
static CString g_vml_string_CurveTo = _T("c%d,%d %d,%d %d,%d");
static _bstr_t g_bstr_shape1 = L"<w:r><w:pict><v:shape id=\"\" o:spid=\"\" style=\"position:absolute;";
static _bstr_t g_bstr_shape2 = L"z-index:-1;mso-position-horizontal-relative:page;mso-position-vertical-relative:page;\"";
static CString g_string_shape_position = _T("margin-left:%.2lfmm;margin-top:%.2lfmm;width:%.2lfmm;height:%.2lfmm;");
static CString g_string_shape_geometry = _T(" coordsize=\"%d,%d\" path=\"%s\" fillcolor=\"#%06x\" strokecolor=\"#%06x\" strokeweight=\"%.2lfmm\">");
static CString g_string_tx_rid = _T("<v:imagedata r:id=\"rId%d\" o:title=\"\"/>");
static CString g_string_fill_opacity = _T("<v:fill opacity=\"%.2lf\"/>");
static CString g_string_stroke_opacity = _T("<v:stroke opacity=\"%.2lf\"/>");
static _bstr_t g_bstr_shape3 = L"<w10:wrap anchorx=\"page\" anchory=\"page\"/></v:shape></w:pict></w:r>";
class CVectorGraphics
{
public:
double* m_pData;
size_t m_lSize;
double* m_pDataCur;
size_t m_lSizeCur;
public:
double m_dLeft;
double m_dTop;
double m_dRight;
double m_dBottom;
public:
CVectorGraphics()
{
m_pData = NULL;
m_lSize = 0;
m_pDataCur = m_pData;
m_lSizeCur = m_lSize;
End();
}
~CVectorGraphics()
{
RELEASEMEM(m_pData);
}
AVSINLINE void AddSize(size_t nSize)
{
if (NULL == m_pData)
{
m_lSize = max(nSize, 500);
m_pData = (double*)malloc(m_lSize * sizeof(double));
m_lSizeCur = 0;
m_pDataCur = m_pData;
return;
}
if ((m_lSizeCur + nSize) > m_lSize)
{
while ((m_lSizeCur + nSize) > m_lSize)
{
m_lSize *= 2;
}
double* pRealloc = (double*)realloc(m_pData, m_lSize * sizeof(double));
if (NULL != pRealloc)
{
//
m_pData = pRealloc;
m_pDataCur = m_pData + m_lSizeCur;
}
else
{
double* pMalloc = (double*)malloc(m_lSize * sizeof(double));
memcpy(pMalloc, m_pData, m_lSizeCur * sizeof(double));
free(m_pData);
m_pData = pMalloc;
m_pDataCur = m_pData + m_lSizeCur;
}
}
}
public:
AVSINLINE void MoveTo(const double& x1, const double& y1)
{
AddSize(3);
*m_pDataCur = 0; ++m_pDataCur;
*m_pDataCur = x1; ++m_pDataCur;
*m_pDataCur = y1; ++m_pDataCur;
m_lSizeCur += 3;
CheckPoint(x1, y1);
}
AVSINLINE void LineTo(const double& x1, const double& y1)
{
AddSize(3);
*m_pDataCur = 1; ++m_pDataCur;
*m_pDataCur = x1; ++m_pDataCur;
*m_pDataCur = y1; ++m_pDataCur;
m_lSizeCur += 3;
CheckPoint(x1, y1);
}
AVSINLINE void CurveTo(const double& x1, const double& y1, const double& x2, const double& y2, const double& x3, const double& y3)
{
AddSize(7);
*m_pDataCur = 2; ++m_pDataCur;
*m_pDataCur = x1; ++m_pDataCur;
*m_pDataCur = y1; ++m_pDataCur;
*m_pDataCur = x2; ++m_pDataCur;
*m_pDataCur = y2; ++m_pDataCur;
*m_pDataCur = x3; ++m_pDataCur;
*m_pDataCur = y3; ++m_pDataCur;
m_lSizeCur += 7;
CheckPoint(x1, y1);
CheckPoint(x2, y2);
CheckPoint(x3, y3);
}
AVSINLINE void Close()
{
AddSize(1);
*m_pDataCur = 3; ++m_pDataCur;
m_lSizeCur += 1;
}
AVSINLINE size_t GetCurSize()
{
return m_lSizeCur;
}
AVSINLINE void Clear()
{
RELEASEMEM(m_pData);
m_pData = NULL;
m_lSize = 0;
m_pDataCur = m_pData;
m_lSizeCur = 0;
}
AVSINLINE void ClearNoAttack()
{
m_pDataCur = m_pData;
m_lSizeCur = 0;
}
AVSINLINE void End()
{
ClearNoAttack();
m_dLeft = 0xFFFFFF;
m_dTop = 0xFFFFFF;
m_dRight = -0xFFFFFF;
m_dBottom = -0xFFFFFF;
}
AVSINLINE void CheckPoint(const double& x, const double& y)
{
if (m_dLeft > x)
m_dLeft = x;
if (m_dRight < x)
m_dRight = x;
if (m_dTop > y)
m_dTop = y;
if (m_dBottom < y)
m_dBottom = y;
}
};
class CShape : public CBaseItem
{
public:
CString m_strPath;
NSStructures::CBrush m_oBrush;
NSStructures::CPen m_oPen;
double m_dLeft;
double m_dTop;
double m_dWidth;
double m_dHeight;
bool m_bIsFill;
bool m_bIsStroke;
LONG m_lCoordSizeX;
LONG m_lCoordSizeY;
LONG m_lTxId;
public:
CShape()
{
m_dLeft = 0;
m_dTop = 0;
m_dWidth = 0;
m_dHeight = 0;
m_bIsFill = false;
m_bIsStroke = false;
m_lCoordSizeX = 100000;
m_lCoordSizeY = 100000;
m_lTxId = -1;
}
CShape(const CShape& oSrc)
{
*this = oSrc;
}
CShape& operator=(const CShape& oSrc)
{
m_eType = etShape;
m_strPath = oSrc.m_strPath;
m_oBrush = oSrc.m_oBrush;
m_oPen = oSrc.m_oPen;
m_dLeft = oSrc.m_dLeft;
m_dTop = oSrc.m_dTop;
m_dWidth = oSrc.m_dWidth;
m_dHeight = oSrc.m_dHeight;
m_bIsFill = oSrc.m_bIsFill;
m_bIsStroke = oSrc.m_bIsStroke;
m_lTxId = oSrc.m_lTxId;
return *this;
}
void CreateFromVectorData(CVectorGraphics* pVector, NSDocxRenderer::CStringWriter& oWriter, const LONG& lCoordSize, LONG lType)
{
m_dLeft = pVector->m_dLeft;
m_dTop = pVector->m_dTop;
m_dWidth = pVector->m_dRight - m_dLeft;
m_dHeight = pVector->m_dBottom - m_dTop;
m_lCoordSizeX = lCoordSize;
m_lCoordSizeY = lCoordSize;
size_t nCount = pVector->GetCurSize();
double* pData = pVector->m_pData;
while (nCount > 0)
{
double dType = *pData++;
if (0 == dType)
{
LONG lX = (LONG)((*pData - m_dLeft) * lCoordSize / m_dWidth);
++pData;
LONG lY = (LONG)((*pData - m_dTop) * lCoordSize / m_dHeight);
++pData;
CString strPath = _T("");
strPath.Format(g_vml_string_MoveTo, lX, lY);
oWriter.WriteString(strPath);
nCount -= 3;
}
else if (1 == dType)
{
LONG lX = (LONG)((*pData - m_dLeft) * lCoordSize / m_dWidth);
++pData;
LONG lY = (LONG)((*pData - m_dTop) * lCoordSize / m_dHeight);
++pData;
CString strPath = _T("");
strPath.Format(g_vml_string_LineTo, lX, lY);
oWriter.WriteString(strPath);
nCount -= 3;
}
else if (2 == dType)
{
LONG lX1 = (LONG)((*pData - m_dLeft) * lCoordSize / m_dWidth);
++pData;
LONG lY1 = (LONG)((*pData - m_dTop) * lCoordSize / m_dHeight);
++pData;
LONG lX2 = (LONG)((*pData - m_dLeft) * lCoordSize / m_dWidth);
++pData;
LONG lY2 = (LONG)((*pData - m_dTop) * lCoordSize / m_dHeight);
++pData;
LONG lX3 = (LONG)((*pData - m_dLeft) * lCoordSize / m_dWidth);
++pData;
LONG lY3 = (LONG)((*pData - m_dTop) * lCoordSize / m_dHeight);
++pData;
CString strPath = _T("");
strPath.Format(g_vml_string_CurveTo, lX1, lY1, lX2, lY2, lX3, lY3);
oWriter.WriteString(strPath);
nCount -= 7;
}
else
{
oWriter.WriteString(g_vml_bstr_ClosePath);
--nCount;
}
}
if (0x00 == (lType & 0x01))
oWriter.WriteString(g_vml_bstr_NoStroke);
if (0x00 == (lType >> 8))
oWriter.WriteString(g_vml_bstr_NoFill);
oWriter.WriteString(g_vml_bstr_EndPath);
m_strPath = oWriter.GetData();
oWriter.ClearNoAttack();
}
virtual void ToXml(NSDocxRenderer::CStringWriter& oWriter)
{
oWriter.WriteString(g_bstr_shape1);
CString strPosition = _T("");
strPosition.Format(g_string_shape_position, m_dLeft, m_dTop, m_dWidth, m_dHeight);
oWriter.WriteString(strPosition);
oWriter.WriteString(strPosition);
oWriter.WriteString(g_bstr_shape2);
CString strStyle = _T("");
strStyle.Format(g_string_shape_geometry, m_lCoordSizeX, m_lCoordSizeY, m_strPath, ConvertColor(m_oBrush.Color1), ConvertColor(m_oPen.Color), m_oPen.Size);
oWriter.WriteString(strStyle);
if (c_BrushTypeTexture == m_oBrush.Type)
{
CString strImage = _T("");
strImage.Format(g_string_tx_rid, 10 + m_lTxId);
oWriter.WriteString(strImage);
if (0xFF != m_oBrush.TextureAlpha)
{
CString strFillOpacity = _T("");
strFillOpacity.Format(g_string_fill_opacity, (double)m_oBrush.TextureAlpha / 255.0);
oWriter.WriteString(strFillOpacity);
}
}
else
{
if (0xFF != m_oBrush.Alpha1)
{
CString strFillOpacity = _T("");
strFillOpacity.Format(g_string_fill_opacity, (double)m_oBrush.Alpha1 / 255.0);
oWriter.WriteString(strFillOpacity);
}
if (0xFF != m_oPen.Alpha)
{
CString strPenOpacity = _T("");
strPenOpacity.Format(g_string_stroke_opacity, (double)m_oPen.Alpha / 255.0);
oWriter.WriteString(strPenOpacity);
}
}
oWriter.WriteString(g_bstr_shape3);
}
};
}
\ No newline at end of file
#pragma once
#include "Common.h"
#include "FontManagerBase.h"
namespace NSDocxRenderer
{
using namespace NSFontManager;
const double c_dDpiX = 72.0;
const double c_dDpiY = 72.0;
enum TextAssociationType
{
TextAssociationTypeDefault = 0,
TextAssociationTypeLine = 1,
TextAssociationTypeNoFrames = 2,
TextAssociationTypeBlock = 3
};
class CFontTableEntry
{
public:
CString m_strFamilyName;
CString m_strPANOSE;
LONG m_lStyle;
CAtlArray<DWORD> m_arSignature;
bool m_bIsFixedWidth;
public:
CFontTableEntry() : m_arSignature()
{
m_strFamilyName = _T("");
m_strPANOSE = _T("");
m_lStyle = 0;
m_bIsFixedWidth = false;
}
~CFontTableEntry()
{
}
CFontTableEntry(const CFontTableEntry& oSrc)
{
*this = oSrc;
}
CFontTableEntry& operator =(const CFontTableEntry& oSrc)
{
m_strFamilyName = oSrc.m_strFamilyName;
m_strPANOSE = oSrc.m_strPANOSE;
m_lStyle = oSrc.m_lStyle;
m_arSignature.Copy(oSrc.m_arSignature);
m_bIsFixedWidth = oSrc.m_bIsFixedWidth;
return *this;
}
};
class CFontTable
{
public:
CAtlMap<CString, CFontTableEntry> m_mapTable;
public:
CFontTable() : m_mapTable()
{
}
};
class CFontManager : public CFontManagerBase
{
public:
NSStructures::CFont* m_pFont;
NSDocxRenderer::CMatrix* m_pTransform;
double m_dSpaceWidthMM;
public:
CFontTable m_oFontTable;
public:
CFontManager() : m_pFont(NULL), CFontManagerBase()
{
m_pTransform = NULL;
m_dSpaceWidthMM = 0;
}
virtual ~CFontManager()
{
}
public:
AVSINLINE void Init()
{
m_oFontTable.m_mapTable.RemoveAll();
}
AVSINLINE void AddFontToMap()
{
CAtlMap<CString, CFontTableEntry>::CPair* pPair = m_oFontTable.m_mapTable.Lookup(m_oFont.m_strFamilyName);
if (NULL == pPair)
{
CFontTableEntry oEntry;
oEntry.m_strFamilyName = m_oFont.m_strFamilyName;
oEntry.m_strPANOSE = m_oFont.m_strPANOSE;
oEntry.m_lStyle = m_oFont.m_lStyle;
oEntry.m_bIsFixedWidth = m_oFont.m_bIsFixedWidth;
oEntry.m_arSignature.Copy(m_oFont.m_arSignature);
m_oFontTable.m_mapTable.SetAt(m_oFont.m_strFamilyName, oEntry);
}
}
public:
virtual void LoadFont(long lFaceIndex = 0, bool bNeedAddToMap = true)
{
if (NULL == m_pManager)
return;
double dSize = m_pFont->Size;
double dSizeFont = dSize * ((m_pTransform->m_agg_mtx.sx + m_pTransform->m_agg_mtx.sy) / 2);
double dPix = m_pFont->CharSpace / c_dPixToMM;
m_pFont->Size = dSizeFont;
if (m_pFont->IsEqual2(&m_oFont.m_oFont))
{
m_pFont->Size = dSize;
m_pManager->SetCharSpacing(dPix);
m_pManager->SetStringGID(m_oFont.m_oFont.StringGID);
return;
}
m_oFont.m_oFont = *m_pFont;
m_pFont->Size = dSize;
bool bIsPath = false;
if (_T("") == m_pFont->Path)
{
CFontManagerBase::LoadFontByName(m_oFont.m_oFont.Name, m_oFont.m_oFont.Size, m_oFont.m_oFont.GetStyle(), c_dDpiX, c_dDpiY);
}
else
{
CFontManagerBase::LoadFontByFile(m_oFont.m_oFont.Path, m_oFont.m_oFont.Size, c_dDpiX, c_dDpiY, lFaceIndex);
m_pFont->SetStyle(m_oFont.m_lStyle);
m_oFont.m_oFont.SetStyle(m_oFont.m_lStyle);
bIsPath = true;
}
long lGid = 0;
m_pManager->GetStringGID(&lGid);
m_pManager->SetStringGID(FALSE);
m_pManager->LoadString(L" ", 0, 0);
float _x = 0;
float _y = 0;
float _w = 0;
float _h = 0;
m_pManager->MeasureString2(&_x, &_y, &_w, &_h);
m_dSpaceWidthMM = (double)_w * c_dPixToMM;
if (0 >= m_dSpaceWidthMM)
{
m_dSpaceWidthMM = 1.0;
}
m_pManager->SetStringGID(lGid);
LoadFontMetrics();
LoadFontParams(bIsPath);
if (bNeedAddToMap)
AddFontToMap();
}
AVSINLINE void MeasureString(const CString& strText, double x, double y, double& dBoxX, double& dBoxY, double& dBoxWidth, double& dBoxHeight, MeasureType measureType)
{
BSTR bsText = strText.AllocSysString();
MeasureString(bsText, x, y, dBoxX, dBoxY, dBoxWidth, dBoxHeight, measureType);
SysFreeString(bsText);
}
AVSINLINE void MeasureStringUNICODE(const CString& strText, double x, double y, double& dBoxX, double& dBoxY, double& dBoxWidth, double& dBoxHeight, MeasureType measureType)
{
m_pManager->SetStringGID(FALSE);
MeasureString(strText, x, y, dBoxX, dBoxY, dBoxWidth, dBoxHeight, measureType);
m_pManager->SetStringGID(TRUE);
}
AVSINLINE void MeasureStringUNICODE(BSTR strText, double x, double y, double& dBoxX, double& dBoxY, double& dBoxWidth, double& dBoxHeight, MeasureType measureType)
{
m_pManager->SetStringGID(FALSE);
MeasureString(strText, x, y, dBoxX, dBoxY, dBoxWidth, dBoxHeight, measureType);
m_pManager->SetStringGID(TRUE);
}
void MeasureString(BSTR bsText, double x, double y, double& dBoxX, double& dBoxY, double& dBoxWidth, double& dBoxHeight, MeasureType measureType)
{
LoadFont();
dBoxX = 0;
dBoxY = 0;
dBoxWidth = 0;
dBoxHeight = 0;
if (NULL == m_pManager)
return;
m_pManager->LoadString(bsText, (float)x, (float)y);
float fx = 0;
float fy = 0;
float fwidth = 0;
float fheight = 0;
if (MeasureTypeGlyph == measureType)
{
m_pManager->MeasureString(&fx, &fy, &fwidth, &fheight);
}
else if (MeasureTypePosition == measureType)
{
m_pManager->MeasureString2(&fx, &fy, &fwidth, &fheight);
}
dBoxX = (double)fx;
dBoxY = (double)fy;
dBoxWidth = (double)fwidth;
dBoxHeight = (double)fheight;
//
dBoxX *= c_dPixToMM;
dBoxY *= c_dPixToMM;
dBoxWidth *= c_dPixToMM;
dBoxHeight *= c_dPixToMM;
}
__forceinline double GetBaseLineOffset()
{
LoadFont();
double d1 = 3 * (m_oFont.m_dLineSpacing - m_oFont.m_dDescent) - m_oFont.m_dAscent;
d1 /= 2.0;
d1 *= (m_oFont.m_oFont.Size / m_oFont.m_dEmHeight);
return d1;
}
__forceinline double GetFontHeight()
{
return c_dPtToMM * (m_oFont.m_dLineSpacing * m_oFont.m_oFont.Size ) / m_oFont.m_dEmHeight;
}
__forceinline void SetStringGid(const LONG& lGid)
{
if (NULL != m_pManager)
m_pManager->SetStringGID(lGid);
}
__forceinline void GenerateFontName2(CString& strText)
{
bool bIsNeedAddToMap = CFontManagerBase::GenerateFontName(strText);
if (bIsNeedAddToMap)
{
CAtlMap<CString, CFontTableEntry>::CPair* pPair = m_oFontTable.m_mapTable.Lookup(m_strCurrentPickFont);
if (NULL == pPair)
{
CFontTableEntry oEntry;
oEntry.m_strFamilyName = m_strCurrentPickFont;
oEntry.m_strPANOSE = m_oFont.m_strPANOSE;
oEntry.m_lStyle = m_oFont.m_lStyle;
oEntry.m_bIsFixedWidth = m_oFont.m_bIsFixedWidth;
oEntry.m_arSignature.Copy(m_oFont.m_arSignature);
m_oFontTable.m_mapTable.SetAt(m_oFont.m_oFont.Path, oEntry);
}
}
}
};
class CFontManagerLight
{
private:
CString m_strFontName;
LONG m_lFontStyle;
double m_dSize;
double m_dSpaceWidth;
AVSGraphics::IASCFontManager* m_pManager;
public:
CFontManagerLight()
{
m_strFontName = _T("");
m_lFontStyle = 0;
m_dSize = 0;
m_dSpaceWidth = 0;
m_pManager = NULL;
CoCreateInstance(AVSGraphics::CLSID_CASCFontManager, NULL, CLSCTX_ALL, AVSGraphics::IID_IASCFontManager, (void**)&m_pManager);
m_pManager->Initialize(L"");
m_pManager->SetDefaultFont(L"Arial");
}
~CFontManagerLight()
{
RELEASEINTERFACE(m_pManager);
}
AVSINLINE double GetSpaceWidth()
{
return m_dSpaceWidth;
}
public:
AVSINLINE void LoadFont(CString& strFontName, LONG& lStyle, double& dSize, const BOOL& bIsGID)
{
if ((strFontName == m_strFontName) && (lStyle == m_lFontStyle) && (dSize == m_dSize))
{
m_pManager->SetStringGID(bIsGID);
return;
}
m_strFontName = strFontName;
m_lFontStyle = lStyle;
m_dSize = dSize;
BSTR bsName = m_strFontName.AllocSysString();
m_pManager->LoadFontByName(bsName, (float)m_dSize, m_lFontStyle, c_dDpiX, c_dDpiY);
SysFreeString(bsName);
CString strSpace = _T(" ");
m_dSpaceWidth = MeasureStringWidth(strSpace);
m_pManager->SetStringGID(bIsGID);
}
AVSINLINE double MeasureStringWidth(CString& sText)
{
BSTR bsText = sText.AllocSysString();
m_pManager->LoadString(bsText, (float)0, (float)0);
SysFreeString(bsText);
float fx = 0;
float fy = 0;
float fwidth = 0;
float fheight = 0;
m_pManager->MeasureString2(&fx, &fy, &fwidth, &fheight);
return fwidth * c_dPixToMM;
}
};
}
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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