mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-04-07 13:55:33 +08:00
Refactoring
This commit is contained in:
@ -46,11 +46,9 @@ public:
|
||||
|
||||
public:
|
||||
CDocxRenderer_Private(NSFonts::IApplicationFonts* pFonts, IRenderer* pRenderer) : m_oDocument(pRenderer, pFonts)
|
||||
{
|
||||
}
|
||||
{}
|
||||
~CDocxRenderer_Private()
|
||||
{
|
||||
}
|
||||
{}
|
||||
};
|
||||
|
||||
CDocxRenderer::CDocxRenderer(NSFonts::IApplicationFonts* pAppFonts)
|
||||
@ -122,7 +120,6 @@ std::vector<std::wstring> CDocxRenderer::ScanPage(IOfficeDrawingFile* pFile, siz
|
||||
{
|
||||
m_pInternal->m_oDocument.Clear();
|
||||
m_pInternal->m_oDocument.Init(false);
|
||||
|
||||
m_pInternal->m_oDocument.m_oCurrentPage.m_bUseDefaultFont = true;
|
||||
m_pInternal->m_oDocument.m_oCurrentPage.m_bWriteStyleRaw = true;
|
||||
m_pInternal->m_bIsSupportShapeCommands = false;
|
||||
@ -151,7 +148,6 @@ std::vector<std::wstring> CDocxRenderer::ScanPagePptx(IOfficeDrawingFile* pFile,
|
||||
{
|
||||
m_pInternal->m_oDocument.Clear();
|
||||
m_pInternal->m_oDocument.Init(false);
|
||||
|
||||
m_pInternal->m_oDocument.m_oCurrentPage.m_bUseDefaultFont = true;
|
||||
m_pInternal->m_oDocument.m_oCurrentPage.m_bWriteStyleRaw = true;
|
||||
m_pInternal->m_bIsSupportShapeCommands = true;
|
||||
@ -258,17 +254,13 @@ HRESULT CDocxRenderer::AdvancedCommand(IAdvancedCommand* command)
|
||||
return S_FALSE;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
// Тип рендерера
|
||||
//----------------------------------------------------------------------------------------
|
||||
|
||||
HRESULT CDocxRenderer::get_Type(LONG* lType)
|
||||
{
|
||||
*lType = c_nDocxWriter;
|
||||
return S_OK;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------
|
||||
// Функции для работы со страницей
|
||||
//----------------------------------------------------------------------------------------
|
||||
|
||||
HRESULT CDocxRenderer::NewPage()
|
||||
{
|
||||
return m_pInternal->m_oDocument.NewPage();
|
||||
@ -297,9 +289,7 @@ HRESULT CDocxRenderer::get_DpiY(double* dDpiY)
|
||||
{
|
||||
return m_pInternal->m_oDocument.get_DpiY(dDpiY);
|
||||
}
|
||||
//----------------------------------------------------------------------------------------
|
||||
// Функции для работы с Pen
|
||||
//----------------------------------------------------------------------------------------
|
||||
|
||||
HRESULT CDocxRenderer::get_PenColor(LONG* lColor)
|
||||
{
|
||||
return m_pInternal->m_oDocument.get_PenColor(lColor);
|
||||
@ -384,9 +374,7 @@ HRESULT CDocxRenderer::PenDashPattern(double* pPattern, LONG lCount)
|
||||
{
|
||||
return m_pInternal->m_oDocument.PenDashPattern(pPattern, lCount);
|
||||
}
|
||||
//----------------------------------------------------------------------------------------
|
||||
// Функции для работы с Brush
|
||||
//----------------------------------------------------------------------------------------
|
||||
|
||||
HRESULT CDocxRenderer::get_BrushType(LONG* lType)
|
||||
{
|
||||
return m_pInternal->m_oDocument.get_BrushType(lType);
|
||||
@ -473,18 +461,18 @@ HRESULT CDocxRenderer::put_BrushGradientColors(LONG* pColors, double* pPositions
|
||||
}
|
||||
HRESULT CDocxRenderer::get_BrushTextureImage(Aggplus::CImage** pImage)
|
||||
{
|
||||
*pImage = m_pInternal->m_oDocument.m_oBrush.Image;
|
||||
*pImage = m_pInternal->m_oDocument.m_oCurrentPage.m_oBrush.Image;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocxRenderer::put_BrushTextureImage(Aggplus::CImage* pImage)
|
||||
{
|
||||
RELEASEINTERFACE(m_pInternal->m_oDocument.m_oBrush.Image);
|
||||
RELEASEINTERFACE(m_pInternal->m_oDocument.m_oCurrentPage.m_oBrush.Image);
|
||||
|
||||
if (NULL == pImage)
|
||||
return S_FALSE;
|
||||
|
||||
m_pInternal->m_oDocument.m_oBrush.Image = pImage;
|
||||
m_pInternal->m_oDocument.m_oBrush.Image->AddRef();
|
||||
m_pInternal->m_oDocument.m_oCurrentPage.m_oBrush.Image = pImage;
|
||||
m_pInternal->m_oDocument.m_oCurrentPage.m_oBrush.Image->AddRef();
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
@ -500,9 +488,7 @@ void CDocxRenderer::put_BrushGradInfo(void* pGradInfo)
|
||||
{
|
||||
m_pInternal->m_oDocument.put_BrushGradInfo(pGradInfo);
|
||||
}
|
||||
//----------------------------------------------------------------------------------------
|
||||
// Функции для работы со шрифтами
|
||||
//----------------------------------------------------------------------------------------
|
||||
|
||||
HRESULT CDocxRenderer::get_FontName(std::wstring* wsName)
|
||||
{
|
||||
return m_pInternal->m_oDocument.get_FontName(wsName);
|
||||
@ -559,9 +545,7 @@ HRESULT CDocxRenderer::put_FontFaceIndex(const int& lFaceIndex)
|
||||
{
|
||||
return m_pInternal->m_oDocument.put_FontFaceIndex(lFaceIndex);
|
||||
}
|
||||
//----------------------------------------------------------------------------------------
|
||||
// Функции для вывода текста
|
||||
//----------------------------------------------------------------------------------------
|
||||
|
||||
HRESULT CDocxRenderer::CommandDrawTextCHAR(const LONG& lUnicode, const double& dX, const double& dY, const double& dW, const double& dH)
|
||||
{
|
||||
return m_pInternal->m_oDocument.CommandDrawTextCHAR((int)lUnicode, dX, dY, dW, dH);
|
||||
@ -578,9 +562,7 @@ HRESULT CDocxRenderer::CommandDrawTextEx(const std::wstring& wsUnicodeText, cons
|
||||
{
|
||||
return m_pInternal->m_oDocument.CommandDrawTextEx(wsUnicodeText, pGids, nGidsCount, dX, dY, dW, dH);
|
||||
}
|
||||
//----------------------------------------------------------------------------------------
|
||||
// Маркеры команд
|
||||
//----------------------------------------------------------------------------------------
|
||||
|
||||
HRESULT CDocxRenderer::BeginCommand(const DWORD& lType)
|
||||
{
|
||||
return m_pInternal->m_oDocument.BeginCommand(lType);
|
||||
@ -589,9 +571,7 @@ HRESULT CDocxRenderer::EndCommand(const DWORD& lType)
|
||||
{
|
||||
return m_pInternal->m_oDocument.EndCommand(lType);
|
||||
}
|
||||
//----------------------------------------------------------------------------------------
|
||||
// Функции для работы с патом
|
||||
//----------------------------------------------------------------------------------------
|
||||
|
||||
HRESULT CDocxRenderer::PathCommandMoveTo(const double& dX, const double& dY)
|
||||
{
|
||||
return m_pInternal->m_oDocument.PathCommandMoveTo(dX, dY);
|
||||
@ -652,9 +632,7 @@ HRESULT CDocxRenderer::PathCommandTextEx(const std::wstring& wsUnicodeText, cons
|
||||
{
|
||||
return m_pInternal->m_oDocument.PathCommandTextEx(wsUnicodeText, pGids, nGidsCount, dX, dY, dW, dH);
|
||||
}
|
||||
//----------------------------------------------------------------------------------------
|
||||
// Функции для вывода изображений
|
||||
//----------------------------------------------------------------------------------------
|
||||
|
||||
HRESULT CDocxRenderer::DrawImage(IGrObject* pImage, const double& dX, const double& dY, const double& dW, const double& dH)
|
||||
{
|
||||
return m_pInternal->m_oDocument.DrawImage(pImage, dX, dY, dW, dH);
|
||||
@ -663,9 +641,7 @@ HRESULT CDocxRenderer::DrawImageFromFile(const std::wstring& wsImagePath, const
|
||||
{
|
||||
return m_pInternal->m_oDocument.DrawImageFromFile(wsImagePath,dX, dY, dW, dH);
|
||||
}
|
||||
//----------------------------------------------------------------------------------------
|
||||
// Функции для выставления преобразования
|
||||
//----------------------------------------------------------------------------------------
|
||||
|
||||
HRESULT CDocxRenderer::SetTransform(const double& dM11, const double& dM12, const double& dM21, const double& dM22, const double& dX, const double& dY)
|
||||
{
|
||||
return m_pInternal->m_oDocument.SetTransform(dM11, dM12, dM21, dM22, dX, dY);
|
||||
@ -679,9 +655,6 @@ HRESULT CDocxRenderer::ResetTransform()
|
||||
return m_pInternal->m_oDocument.ResetTransform();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
// Тип клипа
|
||||
//----------------------------------------------------------------------------------------
|
||||
HRESULT CDocxRenderer::get_ClipMode(LONG* lMode)
|
||||
{
|
||||
return m_pInternal->m_oDocument.get_ClipMode(lMode);
|
||||
@ -691,22 +664,19 @@ HRESULT CDocxRenderer::put_ClipMode(const LONG& lMode)
|
||||
return m_pInternal->m_oDocument.put_ClipMode(lMode);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
// Дополнительные функции
|
||||
//----------------------------------------------------------------------------------------
|
||||
HRESULT CDocxRenderer::CommandLong(const LONG& lType, const LONG& lCommand)
|
||||
{
|
||||
if (c_nSupportPathTextAsText == lType)
|
||||
{
|
||||
NSStructures::CBrush* pBrush = &m_pInternal->m_oDocument.m_oBrush;
|
||||
NSStructures::CBrush* pBrush = &m_pInternal->m_oDocument.m_oCurrentPage.m_oBrush;
|
||||
if (c_BrushTypeSolid != pBrush->Type)
|
||||
return S_FALSE;
|
||||
|
||||
NSStructures::CPen* pPen = &m_pInternal->m_oDocument.m_oPen;
|
||||
NSStructures::CPen* pPen = &m_pInternal->m_oDocument.m_oCurrentPage.m_oPen;
|
||||
if (pBrush->Color1 != pPen->Color || pBrush->Alpha1 != pPen->Alpha)
|
||||
return S_FALSE;
|
||||
|
||||
Aggplus::CMatrix* pTransform = &m_pInternal->m_oDocument.m_oTransform;
|
||||
Aggplus::CMatrix* pTransform = &m_pInternal->m_oDocument.m_oCurrentPage.m_oTransform;
|
||||
if (std::abs(pTransform->z_Rotation()) > 1.0 || pTransform->sx() < 0 || pTransform->sy() < 0)
|
||||
return S_FALSE;
|
||||
|
||||
|
||||
@ -55,13 +55,9 @@ public:
|
||||
|
||||
HRESULT Compress();
|
||||
HRESULT SetTempFolder(const std::wstring& wsPath);
|
||||
//----------------------------------------------------------------------------------------
|
||||
// Тип рендерера
|
||||
//----------------------------------------------------------------------------------------
|
||||
|
||||
virtual HRESULT get_Type(LONG* lType);
|
||||
//----------------------------------------------------------------------------------------
|
||||
// Функции для работы со страницей
|
||||
//----------------------------------------------------------------------------------------
|
||||
|
||||
virtual HRESULT NewPage();
|
||||
virtual HRESULT get_Height(double* dHeight);
|
||||
virtual HRESULT put_Height(const double& dHeight);
|
||||
@ -69,9 +65,7 @@ public:
|
||||
virtual HRESULT put_Width(const double& dWidth);
|
||||
virtual HRESULT get_DpiX(double* dDpiX);
|
||||
virtual HRESULT get_DpiY(double* dDpiY);
|
||||
//----------------------------------------------------------------------------------------
|
||||
// Функции для работы с Pen
|
||||
//----------------------------------------------------------------------------------------
|
||||
|
||||
virtual HRESULT get_PenColor(LONG* lColor);
|
||||
virtual HRESULT put_PenColor(const LONG& lColor);
|
||||
virtual HRESULT get_PenAlpha(LONG* lAlpha);
|
||||
@ -93,9 +87,7 @@ public:
|
||||
virtual HRESULT get_PenMiterLimit(double* dMiter);
|
||||
virtual HRESULT put_PenMiterLimit(const double& dMiter);
|
||||
virtual HRESULT PenDashPattern(double* pPattern, LONG lCount);
|
||||
//----------------------------------------------------------------------------------------
|
||||
// Функции для работы с Brush
|
||||
//----------------------------------------------------------------------------------------
|
||||
|
||||
virtual HRESULT get_BrushType(LONG* lType);
|
||||
virtual HRESULT put_BrushType(const LONG& lType);
|
||||
virtual HRESULT get_BrushColor1(LONG* lColor);
|
||||
@ -114,17 +106,17 @@ public:
|
||||
virtual HRESULT put_BrushTextureAlpha(const LONG& lAlpha);
|
||||
virtual HRESULT get_BrushLinearAngle(double* dAngle);
|
||||
virtual HRESULT put_BrushLinearAngle(const double& dAngle);
|
||||
|
||||
virtual HRESULT BrushRect(const INT& nVal, const double& dLeft, const double& dTop, const double& dWidth, const double& dHeight);
|
||||
virtual HRESULT BrushBounds(const double& dLeft, const double& dTop, const double& dWidth, const double& dHeight);
|
||||
|
||||
virtual HRESULT put_BrushGradientColors(LONG* pColors, double* pPositions, LONG lCount);
|
||||
virtual HRESULT get_BrushTextureImage(Aggplus::CImage** pImage);
|
||||
virtual HRESULT put_BrushTextureImage(Aggplus::CImage* pImage);
|
||||
virtual HRESULT get_BrushTransform(Aggplus::CMatrix& oMatrix);
|
||||
virtual HRESULT put_BrushTransform(const Aggplus::CMatrix& oMatrix);
|
||||
virtual void put_BrushGradInfo(void* pGradInfo) override;
|
||||
//----------------------------------------------------------------------------------------
|
||||
// Функции для работы со шрифтами
|
||||
//----------------------------------------------------------------------------------------
|
||||
|
||||
virtual HRESULT get_FontName(std::wstring* wsName);
|
||||
virtual HRESULT put_FontName(const std::wstring& wsName);
|
||||
virtual HRESULT get_FontPath(std::wstring* wsPath);
|
||||
@ -139,21 +131,15 @@ public:
|
||||
virtual HRESULT put_FontCharSpace(const double& dSpace);
|
||||
virtual HRESULT get_FontFaceIndex(int* lFaceIndex);
|
||||
virtual HRESULT put_FontFaceIndex(const int& lFaceIndex);
|
||||
//----------------------------------------------------------------------------------------
|
||||
// Функции для вывода текста
|
||||
//----------------------------------------------------------------------------------------
|
||||
virtual HRESULT CommandDrawTextCHAR (const LONG& lUnicode, const double& dX, const double& dY, const double& dW, const double& dH);
|
||||
|
||||
virtual HRESULT CommandDrawTextCHAR(const LONG& lUnicode, const double& dX, const double& dY, const double& dW, const double& dH);
|
||||
virtual HRESULT CommandDrawTextExCHAR(const LONG& lUnicode, const LONG& lGid, const double& dX, const double& dY, const double& dW, const double& dH);
|
||||
virtual HRESULT CommandDrawText (const std::wstring& wsUnicodeText, const double& dX, const double& dY, const double& dW, const double& dH);
|
||||
virtual HRESULT CommandDrawTextEx (const std::wstring& wsUnicodeText, const unsigned int* pGids, const unsigned int nGidsCount, const double& dX, const double& dY, const double& dW, const double& dH);
|
||||
//----------------------------------------------------------------------------------------
|
||||
// Маркеры команд
|
||||
//----------------------------------------------------------------------------------------
|
||||
virtual HRESULT CommandDrawText(const std::wstring& wsUnicodeText, const double& dX, const double& dY, const double& dW, const double& dH);
|
||||
virtual HRESULT CommandDrawTextEx(const std::wstring& wsUnicodeText, const unsigned int* pGids, const unsigned int nGidsCount, const double& dX, const double& dY, const double& dW, const double& dH);
|
||||
|
||||
virtual HRESULT BeginCommand(const DWORD& lType);
|
||||
virtual HRESULT EndCommand(const DWORD& lType);
|
||||
//----------------------------------------------------------------------------------------
|
||||
// Функции для работы с патом
|
||||
//----------------------------------------------------------------------------------------
|
||||
|
||||
virtual HRESULT PathCommandMoveTo(const double& dX, const double& dY);
|
||||
virtual HRESULT PathCommandLineTo(const double& dX, const double& dY);
|
||||
virtual HRESULT PathCommandLinesTo(double* pPoints, const int& nCount);
|
||||
@ -165,29 +151,21 @@ public:
|
||||
virtual HRESULT DrawPath(const LONG& lType);
|
||||
virtual HRESULT PathCommandStart();
|
||||
virtual HRESULT PathCommandGetCurrentPoint(double* dX, double* dY);
|
||||
virtual HRESULT PathCommandTextCHAR (const LONG& lUnicode, const double& dX, const double& dY, const double& dW, const double& dH);
|
||||
virtual HRESULT PathCommandTextCHAR(const LONG& lUnicode, const double& dX, const double& dY, const double& dW, const double& dH);
|
||||
virtual HRESULT PathCommandTextExCHAR(const LONG& lUnicode, const LONG& lGid, const double& dX, const double& dY, const double& dW, const double& dH);
|
||||
virtual HRESULT PathCommandText (const std::wstring& wsUnicodeText, const double& dX, const double& dY, const double& dW, const double& dH);
|
||||
virtual HRESULT PathCommandTextEx (const std::wstring& wsUnicodeText, const unsigned int* pGids, const unsigned int nGidsCount, const double& dX, const double& dY, const double& dW, const double& dH);
|
||||
//----------------------------------------------------------------------------------------
|
||||
// Функции для вывода изображений
|
||||
//----------------------------------------------------------------------------------------
|
||||
virtual HRESULT PathCommandText(const std::wstring& wsUnicodeText, const double& dX, const double& dY, const double& dW, const double& dH);
|
||||
virtual HRESULT PathCommandTextEx (const std::wstring& wsUnicodeText, const unsigned int* pGids, const unsigned int nGidsCount, const double& dX, const double& dY, const double& dW, const double& dH);
|
||||
|
||||
virtual HRESULT DrawImage(IGrObject* pImage, const double& dX, const double& dY, const double& dW, const double& dH);
|
||||
virtual HRESULT DrawImageFromFile(const std::wstring& wsImagePath, const double& dX, const double& dY, const double& dW, const double& dH, const BYTE& nAlpha = 255);
|
||||
//----------------------------------------------------------------------------------------
|
||||
// Функции для выставления преобразования
|
||||
//----------------------------------------------------------------------------------------
|
||||
|
||||
virtual HRESULT SetTransform(const double& dM11, const double& dM12, const double& dM21, const double& dM22, const double& dX, const double& dY);
|
||||
virtual HRESULT GetTransform(double* dM11, double* dM12, double* dM21, double* dM22, double* dX, double* dY);
|
||||
virtual HRESULT ResetTransform();
|
||||
//----------------------------------------------------------------------------------------
|
||||
// Тип клипа
|
||||
//----------------------------------------------------------------------------------------
|
||||
|
||||
virtual HRESULT get_ClipMode(LONG* lMode);
|
||||
virtual HRESULT put_ClipMode(const LONG& lMode);
|
||||
//----------------------------------------------------------------------------------------
|
||||
// Дополнительные функции
|
||||
//----------------------------------------------------------------------------------------
|
||||
|
||||
virtual HRESULT CommandLong(const LONG& lType, const LONG& lCommand);
|
||||
virtual HRESULT CommandDouble(const LONG& lType, const double& dCommand);
|
||||
virtual HRESULT CommandString(const LONG& lType, const std::wstring& sCommand);
|
||||
|
||||
@ -12,7 +12,10 @@
|
||||
namespace NSDocxRenderer
|
||||
{
|
||||
CDocument::CDocument(IRenderer* pRenderer, NSFonts::IApplicationFonts* pFonts) :
|
||||
m_pAppFonts(pFonts), m_oCurrentPage(), m_oFontManager(pFonts), m_oFontSelector(pFonts)
|
||||
m_pAppFonts(pFonts),
|
||||
m_oFontManager(pFonts),
|
||||
m_oFontSelector(pFonts),
|
||||
m_oCurrentPage(pFonts, {&m_oImageManager, &m_oFontStyleManager, &m_oParagraphStyleManager, &m_oFontManager, &m_oFontSelector})
|
||||
{
|
||||
m_oSimpleGraphicsConverter.SetRenderer(pRenderer);
|
||||
}
|
||||
@ -24,23 +27,19 @@ namespace NSDocxRenderer
|
||||
delete val.second;
|
||||
|
||||
m_mapXmlString.clear();
|
||||
m_oFontSelector.ClearCache();
|
||||
m_lCurrentCommandType = 0;
|
||||
m_oImageManager.Clear();
|
||||
m_oFontStyleManager.Clear();
|
||||
}
|
||||
|
||||
CDocument::~CDocument() {
|
||||
CDocument::~CDocument()
|
||||
{
|
||||
Clear();
|
||||
RELEASEINTERFACE(m_pFontManager);
|
||||
RELEASEINTERFACE(m_pBaseFontManager);
|
||||
}
|
||||
|
||||
HRESULT CDocument::NewPage()
|
||||
{
|
||||
m_oPen.SetDefaultParams();
|
||||
m_oBrush.SetDefaultParams();
|
||||
m_oFont.SetDefaultParams();
|
||||
m_oShadow.SetDefaultParams();
|
||||
m_oEdge.SetDefaultParams();
|
||||
|
||||
m_oTransform.Reset();
|
||||
m_oCurrentPage.Clear();
|
||||
return S_OK;
|
||||
}
|
||||
@ -80,109 +79,109 @@ namespace NSDocxRenderer
|
||||
// pen --------------------------------------------------------------------------------------
|
||||
HRESULT CDocument::get_PenColor(LONG* lColor)
|
||||
{
|
||||
*lColor = m_oPen.Color;
|
||||
*lColor = m_oCurrentPage.m_oPen.Color;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::put_PenColor(LONG lColor)
|
||||
{
|
||||
m_oPen.Color = lColor;
|
||||
m_oCurrentPage.m_oPen.Color = lColor;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::get_PenAlpha(LONG* lAlpha)
|
||||
{
|
||||
*lAlpha = m_oPen.Alpha;
|
||||
*lAlpha = m_oCurrentPage.m_oPen.Alpha;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::put_PenAlpha(LONG lAlpha)
|
||||
{
|
||||
m_oPen.Alpha = CLAMP_ALPHA(lAlpha);
|
||||
m_oCurrentPage.m_oPen.Alpha = CLAMP_ALPHA(lAlpha);
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::get_PenSize(double* dSize)
|
||||
{
|
||||
*dSize = m_oPen.Size;
|
||||
*dSize = m_oCurrentPage.m_oPen.Size;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::put_PenSize(double dSize)
|
||||
{
|
||||
m_oPen.Size = dSize;
|
||||
m_oCurrentPage.m_oPen.Size = dSize;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::get_PenDashStyle(BYTE* val)
|
||||
{
|
||||
*val = m_oPen.DashStyle;
|
||||
*val = m_oCurrentPage.m_oPen.DashStyle;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::put_PenDashStyle(BYTE val)
|
||||
{
|
||||
m_oPen.DashStyle = val;
|
||||
m_oCurrentPage.m_oPen.DashStyle = val;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::get_PenLineStartCap(BYTE* val)
|
||||
{
|
||||
*val = m_oPen.LineStartCap;
|
||||
*val = m_oCurrentPage.m_oPen.LineStartCap;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::put_PenLineStartCap(BYTE val)
|
||||
{
|
||||
m_oPen.LineStartCap = val;
|
||||
m_oCurrentPage.m_oPen.LineStartCap = val;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::get_PenLineEndCap(BYTE* val)
|
||||
{
|
||||
*val = m_oPen.LineEndCap;
|
||||
*val = m_oCurrentPage.m_oPen.LineEndCap;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::put_PenLineEndCap(BYTE val)
|
||||
{
|
||||
m_oPen.LineEndCap = val;
|
||||
m_oCurrentPage.m_oPen.LineEndCap = val;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::get_PenLineJoin(BYTE* val)
|
||||
{
|
||||
*val = m_oPen.LineJoin;
|
||||
*val = m_oCurrentPage.m_oPen.LineJoin;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::put_PenLineJoin(BYTE val)
|
||||
{
|
||||
m_oPen.LineJoin = val;
|
||||
m_oCurrentPage.m_oPen.LineJoin = val;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::get_PenDashOffset(double* val)
|
||||
{
|
||||
*val = m_oPen.DashOffset;
|
||||
*val = m_oCurrentPage.m_oPen.DashOffset;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::put_PenDashOffset(double val)
|
||||
{
|
||||
m_oPen.DashOffset = val;
|
||||
m_oCurrentPage.m_oPen.DashOffset = val;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::get_PenAlign(LONG* val)
|
||||
{
|
||||
*val = m_oPen.Align;
|
||||
*val = m_oCurrentPage.m_oPen.Align;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::put_PenAlign(LONG val)
|
||||
{
|
||||
m_oPen.Align = val;
|
||||
m_oCurrentPage.m_oPen.Align = val;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::get_PenMiterLimit(double* val)
|
||||
{
|
||||
*val = m_oPen.MiterLimit;
|
||||
*val = m_oCurrentPage.m_oPen.MiterLimit;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::put_PenMiterLimit(double val)
|
||||
{
|
||||
m_oPen.MiterLimit = val;
|
||||
m_oCurrentPage.m_oPen.MiterLimit = val;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::PenDashPattern(double* pPattern, LONG lCount)
|
||||
{
|
||||
if (nullptr != pPattern)
|
||||
{
|
||||
m_oPen.SetDashPattern(pPattern, lCount);
|
||||
m_oCurrentPage.m_oPen.SetDashPattern(pPattern, lCount);
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
@ -190,304 +189,304 @@ namespace NSDocxRenderer
|
||||
// brush ------------------------------------------------------------------------------------
|
||||
HRESULT CDocument::get_BrushType(LONG* lType)
|
||||
{
|
||||
*lType = m_oBrush.Type;
|
||||
*lType = m_oCurrentPage.m_oBrush.Type;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::put_BrushType(LONG lType)
|
||||
{
|
||||
m_oBrush.Type = lType;
|
||||
m_oCurrentPage.m_oBrush.Type = lType;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::get_BrushColor1(LONG* lColor)
|
||||
{
|
||||
*lColor = m_oBrush.Color1;
|
||||
*lColor = m_oCurrentPage.m_oBrush.Color1;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::put_BrushColor1(LONG lColor)
|
||||
{
|
||||
m_oBrush.Color1 = lColor;
|
||||
m_oCurrentPage.m_oBrush.Color1 = lColor;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::get_BrushAlpha1(LONG* lAlpha)
|
||||
{
|
||||
*lAlpha = m_oBrush.Alpha1;
|
||||
*lAlpha = m_oCurrentPage.m_oBrush.Alpha1;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::put_BrushAlpha1(LONG lAlpha)
|
||||
{
|
||||
m_oBrush.Alpha1 = CLAMP_ALPHA(lAlpha);;
|
||||
m_oCurrentPage.m_oBrush.Alpha1 = CLAMP_ALPHA(lAlpha);;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::get_BrushColor2(LONG* lColor)
|
||||
{
|
||||
*lColor = m_oBrush.Color2;
|
||||
*lColor = m_oCurrentPage.m_oBrush.Color2;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::put_BrushColor2(LONG lColor)
|
||||
{
|
||||
m_oBrush.Color2 = lColor;
|
||||
m_oCurrentPage.m_oBrush.Color2 = lColor;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::get_BrushAlpha2(LONG* lAlpha)
|
||||
{
|
||||
*lAlpha = m_oBrush.Alpha2;
|
||||
*lAlpha = m_oCurrentPage.m_oBrush.Alpha2;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::put_BrushAlpha2(LONG lAlpha)
|
||||
{
|
||||
m_oBrush.Alpha2 = CLAMP_ALPHA(lAlpha);;
|
||||
m_oCurrentPage.m_oBrush.Alpha2 = CLAMP_ALPHA(lAlpha);;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::get_BrushTexturePath(std::wstring* sPath)
|
||||
{
|
||||
*sPath = m_oBrush.TexturePath;
|
||||
*sPath = m_oCurrentPage.m_oBrush.TexturePath;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::put_BrushTexturePath(const std::wstring& sPath)
|
||||
{
|
||||
m_oBrush.TexturePath = sPath;
|
||||
m_oCurrentPage.m_oBrush.TexturePath = sPath;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::get_BrushTextureMode(LONG* lMode)
|
||||
{
|
||||
*lMode = m_oBrush.TextureMode;
|
||||
*lMode = m_oCurrentPage.m_oBrush.TextureMode;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::put_BrushTextureMode(LONG lMode)
|
||||
{
|
||||
m_oBrush.TextureMode = lMode;
|
||||
m_oCurrentPage.m_oBrush.TextureMode = lMode;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::get_BrushTextureAlpha(LONG* lTxAlpha)
|
||||
{
|
||||
*lTxAlpha = m_oBrush.TextureAlpha;
|
||||
*lTxAlpha = m_oCurrentPage.m_oBrush.TextureAlpha;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::put_BrushTextureAlpha(LONG lTxAlpha)
|
||||
{
|
||||
m_oBrush.TextureAlpha = CLAMP_ALPHA(lTxAlpha);
|
||||
m_oCurrentPage.m_oBrush.TextureAlpha = CLAMP_ALPHA(lTxAlpha);
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::get_BrushLinearAngle(double* dAngle)
|
||||
{
|
||||
*dAngle = m_oBrush.LinearAngle;
|
||||
*dAngle = m_oCurrentPage.m_oBrush.LinearAngle;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::put_BrushLinearAngle(double dAngle)
|
||||
{
|
||||
m_oBrush.LinearAngle = dAngle;
|
||||
m_oCurrentPage.m_oBrush.LinearAngle = dAngle;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::BrushRect(bool val, double left, double top, double width, double height)
|
||||
{
|
||||
m_oBrush.Rectable = val ? 1 : 0;
|
||||
m_oBrush.Rect.X = (float)left;
|
||||
m_oBrush.Rect.Y = (float)top;
|
||||
m_oBrush.Rect.Width = (float)width;
|
||||
m_oBrush.Rect.Height = (float)height;
|
||||
m_oCurrentPage.m_oBrush.Rectable = val ? 1 : 0;
|
||||
m_oCurrentPage.m_oBrush.Rect.X = (float)left;
|
||||
m_oCurrentPage.m_oBrush.Rect.Y = (float)top;
|
||||
m_oCurrentPage.m_oBrush.Rect.Width = (float)width;
|
||||
m_oCurrentPage.m_oBrush.Rect.Height = (float)height;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::BrushBounds(const double& dLeft, const double& dTop, const double& dWidth, const double& dHeight)
|
||||
{
|
||||
m_oBrush.Bounds.left = dLeft;
|
||||
m_oBrush.Bounds.top = dTop;
|
||||
m_oBrush.Bounds.right = dLeft + dWidth;
|
||||
m_oBrush.Bounds.bottom = dTop + dHeight;
|
||||
m_oCurrentPage.m_oBrush.Bounds.left = dLeft;
|
||||
m_oCurrentPage.m_oBrush.Bounds.top = dTop;
|
||||
m_oCurrentPage.m_oBrush.Bounds.right = dLeft + dWidth;
|
||||
m_oCurrentPage.m_oBrush.Bounds.bottom = dTop + dHeight;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::put_BrushGradientColors(LONG* pColors, double* pPositions, LONG lCount)
|
||||
{
|
||||
m_oBrush.m_arrSubColors.clear();
|
||||
m_oCurrentPage.m_oBrush.m_arrSubColors.clear();
|
||||
for (LONG i = 0; i < lCount; ++i)
|
||||
{
|
||||
NSStructures::CBrush::TSubColor color;
|
||||
color.color = pColors[i];
|
||||
color.position = (long)(pPositions[i] * 65536);
|
||||
m_oBrush.m_arrSubColors.push_back(color);
|
||||
m_oCurrentPage.m_oBrush.m_arrSubColors.push_back(color);
|
||||
}
|
||||
m_oCurrentPage.m_bIsGradient = true;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::put_BrushGradInfo(void* pGradInfo)
|
||||
{
|
||||
m_oBrush.m_oGradientInfo = *((NSStructures::GradientInfo*)pGradInfo);
|
||||
m_oBrush.m_oGradientInfo.transform(m_oTransform);
|
||||
m_oCurrentPage.m_oBrush.m_oGradientInfo = *((NSStructures::GradientInfo*)pGradInfo);
|
||||
m_oCurrentPage.m_oBrush.m_oGradientInfo.transform(m_oCurrentPage.m_oTransform);
|
||||
m_oCurrentPage.m_bIsGradient = true;
|
||||
return S_OK;
|
||||
}
|
||||
// font -------------------------------------------------------------------------------------
|
||||
HRESULT CDocument::get_FontName(std::wstring* sName)
|
||||
{
|
||||
*sName = m_oFont.Name;
|
||||
*sName = m_oCurrentPage.m_oFont.Name;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::put_FontName(std::wstring sName)
|
||||
{
|
||||
m_oFont.Name = sName;
|
||||
m_oCurrentPage.m_oFont.Name = sName;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::get_FontPath(std::wstring* sPath)
|
||||
{
|
||||
*sPath = m_oFont.Path;
|
||||
*sPath = m_oCurrentPage.m_oFont.Path;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::put_FontPath(std::wstring sPath)
|
||||
{
|
||||
m_oFont.Path = sPath;
|
||||
m_oCurrentPage.m_oFont.Path = sPath;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::get_FontSize(double* dSize)
|
||||
{
|
||||
*dSize = m_oFont.Size;
|
||||
*dSize = m_oCurrentPage.m_oFont.Size;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::put_FontSize(double dSize)
|
||||
{
|
||||
m_oFont.Size = dSize;
|
||||
m_oCurrentPage.m_oFont.Size = dSize;
|
||||
m_oCurrentPage.m_bIsRecalcFontSize = true;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::get_FontStyle(LONG* lStyle)
|
||||
{
|
||||
*lStyle = m_oFont.GetStyle();
|
||||
*lStyle = m_oCurrentPage.m_oFont.GetStyle();
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::put_FontStyle(LONG lStyle)
|
||||
{
|
||||
m_oFont.SetStyle(lStyle);
|
||||
m_oCurrentPage.m_oFont.SetStyle(lStyle);
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::get_FontStringGID(INT* bGID)
|
||||
{
|
||||
*bGID = m_oFont.StringGID;
|
||||
*bGID = m_oCurrentPage.m_oFont.StringGID;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::put_FontStringGID(INT bGID)
|
||||
{
|
||||
m_oFont.StringGID = bGID;
|
||||
m_oCurrentPage.m_oFont.StringGID = bGID;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::get_FontCharSpace(double* dSpace)
|
||||
{
|
||||
*dSpace = m_oFont.CharSpace;
|
||||
*dSpace = m_oCurrentPage.m_oFont.CharSpace;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::put_FontCharSpace(double dSpace)
|
||||
{
|
||||
m_oFont.CharSpace = dSpace;
|
||||
m_oCurrentPage.m_oFont.CharSpace = dSpace;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::get_FontFaceIndex(int* lFaceIndex)
|
||||
{
|
||||
*lFaceIndex = m_oFont.FaceIndex;
|
||||
*lFaceIndex = m_oCurrentPage.m_oFont.FaceIndex;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::put_FontFaceIndex(const int& lFaceIndex)
|
||||
{
|
||||
m_oFont.FaceIndex = lFaceIndex;
|
||||
m_oCurrentPage.m_oFont.FaceIndex = lFaceIndex;
|
||||
return S_OK;
|
||||
}
|
||||
// shadow -----------------------------------------------------------------------------------
|
||||
HRESULT CDocument::get_ShadowDistanceX(double* val)
|
||||
{
|
||||
*val = m_oShadow.DistanceX;
|
||||
*val = m_oCurrentPage.m_oShadow.DistanceX;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::put_ShadowDistanceX(double val)
|
||||
{
|
||||
m_oShadow.DistanceX = val;
|
||||
m_oCurrentPage.m_oShadow.DistanceX = val;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::get_ShadowDistanceY(double* val)
|
||||
{
|
||||
*val = m_oShadow.DistanceY;
|
||||
*val = m_oCurrentPage.m_oShadow.DistanceY;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::put_ShadowDistanceY(double val)
|
||||
{
|
||||
m_oShadow.DistanceY = val;
|
||||
m_oCurrentPage.m_oShadow.DistanceY = val;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::get_ShadowBlurSize(double* val)
|
||||
{
|
||||
*val = m_oShadow.BlurSize;
|
||||
*val = m_oCurrentPage.m_oShadow.BlurSize;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::put_ShadowBlurSize(double val)
|
||||
{
|
||||
m_oShadow.BlurSize = val;
|
||||
m_oCurrentPage.m_oShadow.BlurSize = val;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::get_ShadowColor(LONG* val)
|
||||
{
|
||||
*val = m_oShadow.Color;
|
||||
*val = m_oCurrentPage.m_oShadow.Color;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::put_ShadowColor(LONG val)
|
||||
{
|
||||
m_oShadow.Color = val;
|
||||
m_oCurrentPage.m_oShadow.Color = val;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::get_ShadowAlpha(LONG* val)
|
||||
{
|
||||
*val = m_oShadow.Alpha;
|
||||
*val = m_oCurrentPage.m_oShadow.Alpha;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::put_ShadowAlpha(LONG val)
|
||||
{
|
||||
m_oShadow.Alpha = val;
|
||||
m_oCurrentPage.m_oShadow.Alpha = val;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::get_ShadowVisible(INT* val)
|
||||
{
|
||||
*val = m_oShadow.Visible;
|
||||
*val = m_oCurrentPage.m_oShadow.Visible;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::put_ShadowVisible(INT val)
|
||||
{
|
||||
m_oShadow.Visible = val;
|
||||
m_oCurrentPage.m_oShadow.Visible = val;
|
||||
return S_OK;
|
||||
}
|
||||
// edge -------------------------------------------------------------------------------------
|
||||
HRESULT CDocument::get_EdgeVisible(LONG* val)
|
||||
{
|
||||
*val = m_oEdge.Visible;
|
||||
*val = m_oCurrentPage.m_oEdgeText.Visible;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::put_EdgeVisible(LONG val)
|
||||
{
|
||||
m_oEdge.Visible = val;
|
||||
m_oCurrentPage.m_oEdgeText.Visible = val;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::get_EdgeColor(LONG* val)
|
||||
{
|
||||
*val = m_oEdge.Color;
|
||||
*val = m_oCurrentPage.m_oEdgeText.Color;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::put_EdgeColor(LONG val)
|
||||
{
|
||||
m_oEdge.Color = val;
|
||||
m_oCurrentPage.m_oEdgeText.Color = val;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::get_EdgeAlpha(LONG* val)
|
||||
{
|
||||
*val = m_oEdge.Alpha;
|
||||
*val = m_oCurrentPage.m_oEdgeText.Alpha;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::put_EdgeAlpha(LONG val)
|
||||
{
|
||||
m_oEdge.Alpha = val;
|
||||
m_oCurrentPage.m_oEdgeText.Alpha = val;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::get_EdgeDist(double* val)
|
||||
{
|
||||
*val = m_oEdge.Dist;
|
||||
*val = m_oCurrentPage.m_oEdgeText.Dist;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::put_EdgeDist(double val)
|
||||
{
|
||||
m_oEdge.Dist = val;
|
||||
m_oCurrentPage.m_oEdgeText.Dist = val;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@ -496,21 +495,21 @@ namespace NSDocxRenderer
|
||||
const double& dX, const double& dY, const double& dW,
|
||||
const double& dH, const double& dBaseLineOffset)
|
||||
{
|
||||
double dAngleMatrix = m_oTransform.z_Rotation();
|
||||
if (fabs(dAngleMatrix) > 1 || m_oTransform.sx() < 0 || m_oTransform.sy() < 0)
|
||||
double dAngleMatrix = m_oCurrentPage.m_oTransform.z_Rotation();
|
||||
if (fabs(dAngleMatrix) > 1 || m_oCurrentPage.m_oTransform.sx() < 0 || m_oCurrentPage.m_oTransform.sy() < 0)
|
||||
{
|
||||
//note У повернутых символов не приходят координаты.
|
||||
_SetFont();
|
||||
PathCommandEnd();
|
||||
BeginCommand(c_nPathType);
|
||||
m_oSimpleGraphicsConverter.PathCommandText2(pUnicodes, pGids, nCount, m_pFontManager, dX, dY, dW, dH);
|
||||
m_oSimpleGraphicsConverter.PathCommandText2(pUnicodes, pGids, nCount, m_pBaseFontManager, dX, dY, dW, dH);
|
||||
DrawPath(c_nWindingFillMode);
|
||||
EndCommand(c_nPathType);
|
||||
PathCommandEnd();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
m_oCurrentPage.CollectTextData((unsigned int*)pUnicodes, (unsigned int*)pGids, nCount, dX, dY, dW, dH, 0);
|
||||
m_oCurrentPage.AddText((unsigned int*)pUnicodes, (unsigned int*)pGids, nCount, dX, dY, dW, dH, 0);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@ -584,25 +583,17 @@ namespace NSDocxRenderer
|
||||
HRESULT CDocument::PathCommandMoveTo(double fX, double fY)
|
||||
{
|
||||
if (c_nSimpleGraphicType == m_lCurrentCommandType)
|
||||
{
|
||||
m_oCurrentPage.MoveTo(fX, fY);
|
||||
}
|
||||
m_oCurrentPage.PathMoveTo(fX, fY);
|
||||
else
|
||||
{
|
||||
m_oSimpleGraphicsConverter.PathCommandMoveTo(fX, fY);
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::PathCommandLineTo(double fX, double fY)
|
||||
{
|
||||
if (c_nSimpleGraphicType == m_lCurrentCommandType)
|
||||
{
|
||||
m_oCurrentPage.LineTo(fX, fY);
|
||||
}
|
||||
m_oCurrentPage.PathLineTo(fX, fY);
|
||||
else
|
||||
{
|
||||
m_oSimpleGraphicsConverter.PathCommandLineTo(fX, fY);
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::PathCommandLinesTo(double* pPoints, LONG lCount)
|
||||
@ -613,13 +604,9 @@ namespace NSDocxRenderer
|
||||
HRESULT CDocument::PathCommandCurveTo(double fX1, double fY1, double fX2, double fY2, double fX3, double fY3)
|
||||
{
|
||||
if (c_nSimpleGraphicType == m_lCurrentCommandType)
|
||||
{
|
||||
m_oCurrentPage.CurveTo(fX1, fY1, fX2, fY2, fX3, fY3);
|
||||
}
|
||||
m_oCurrentPage.PathCurveTo(fX1, fY1, fX2, fY2, fX3, fY3);
|
||||
else
|
||||
{
|
||||
m_oSimpleGraphicsConverter.PathCommandCurveTo(fX1, fY1, fX2, fY2, fX3, fY3);
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::PathCommandCurvesTo(double* pPoints, LONG lCount)
|
||||
@ -635,37 +622,29 @@ namespace NSDocxRenderer
|
||||
HRESULT CDocument::PathCommandClose()
|
||||
{
|
||||
if (c_nSimpleGraphicType == m_lCurrentCommandType)
|
||||
{
|
||||
m_oCurrentPage.PathClose();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_oSimpleGraphicsConverter.PathCommandClose();
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::PathCommandEnd()
|
||||
{
|
||||
if (c_nSimpleGraphicType == m_lCurrentCommandType)
|
||||
{
|
||||
m_oCurrentPage.PathEnd();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_oSimpleGraphicsConverter.PathCommandEnd();
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::DrawPath(long nType)
|
||||
{
|
||||
std::shared_ptr<CImageInfo> pInfo = nullptr;
|
||||
if ((nType > 0xFF) && (c_BrushTypeTexture == m_oBrush.Type))
|
||||
if ((nType > 0xFF) && (c_BrushTypeTexture == m_oCurrentPage.m_oBrush.Type))
|
||||
{
|
||||
double x = 0, y = 0, w = 0, h = 0;
|
||||
if (m_oBrush.Image)
|
||||
pInfo = m_oImageManager.WriteImage(m_oBrush.Image, x, y, w, h);
|
||||
if (m_oCurrentPage.m_oBrush.Image)
|
||||
pInfo = m_oImageManager.WriteImage(m_oCurrentPage.m_oBrush.Image, x, y, w, h);
|
||||
else
|
||||
pInfo = m_oImageManager.WriteImage(m_oBrush.TexturePath, x, y, w, h);
|
||||
pInfo = m_oImageManager.WriteImage(m_oCurrentPage.m_oBrush.TexturePath, x, y, w, h);
|
||||
}
|
||||
m_oCurrentPage.DrawPath(nType, pInfo);
|
||||
return S_OK;
|
||||
@ -673,13 +652,9 @@ namespace NSDocxRenderer
|
||||
HRESULT CDocument::PathCommandStart()
|
||||
{
|
||||
if (c_nSimpleGraphicType == m_lCurrentCommandType)
|
||||
{
|
||||
m_oCurrentPage.PathStart();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_oSimpleGraphicsConverter.PathCommandStart();
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::PathCommandGetCurrentPoint(double* fX, double* fY)
|
||||
@ -691,25 +666,25 @@ namespace NSDocxRenderer
|
||||
HRESULT CDocument::PathCommandTextCHAR(const int& lUnicode, const double& dX, const double& dY, const double& dW, const double& dH)
|
||||
{
|
||||
_SetFont();
|
||||
m_oSimpleGraphicsConverter.PathCommandText2(&lUnicode, nullptr, 1, m_pFontManager, dX, dY, dW, dH);
|
||||
m_oSimpleGraphicsConverter.PathCommandText2(&lUnicode, nullptr, 1, m_pBaseFontManager, dX, dY, dW, dH);
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::PathCommandTextExCHAR(const int& lUnicode, const int& lGid, const double& dX, const double& dY, const double& dW, const double& dH)
|
||||
{
|
||||
_SetFont();
|
||||
m_oSimpleGraphicsConverter.PathCommandText2(&lUnicode, &lGid, 1, m_pFontManager, dX, dY, dW, dH);
|
||||
m_oSimpleGraphicsConverter.PathCommandText2(&lUnicode, &lGid, 1, m_pBaseFontManager, dX, dY, dW, dH);
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::PathCommandText(const std::wstring& wsUnicodeText, const double& dX, const double& dY, const double& dW, const double& dH)
|
||||
{
|
||||
_SetFont();
|
||||
m_oSimpleGraphicsConverter.PathCommandText(wsUnicodeText, m_pFontManager, dX, dY, dW, dH, 0);
|
||||
m_oSimpleGraphicsConverter.PathCommandText(wsUnicodeText, m_pBaseFontManager, dX, dY, dW, dH, 0);
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::PathCommandTextEx(const std::wstring& wsUnicodeText, const unsigned int* pGids, const unsigned int nGidsCount, const double& dX, const double& dY, const double& dW, const double& dH)
|
||||
{
|
||||
_SetFont();
|
||||
m_oSimpleGraphicsConverter.PathCommandText2(wsUnicodeText, (const int*)pGids, nGidsCount, m_pFontManager, dX, dY, dW, dH);
|
||||
m_oSimpleGraphicsConverter.PathCommandText2(wsUnicodeText, (const int*)pGids, nGidsCount, m_pBaseFontManager, dX, dY, dW, dH);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@ -745,7 +720,7 @@ namespace NSDocxRenderer
|
||||
}
|
||||
HRESULT CDocument::ResetTransform(void)
|
||||
{
|
||||
m_oTransform.Reset();
|
||||
m_oCurrentPage.m_oTransform.Reset();
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocument::get_ClipMode(LONG* plMode)
|
||||
@ -761,7 +736,7 @@ namespace NSDocxRenderer
|
||||
|
||||
void CDocument::ApplyTransform(double d1, double d2, double d3, double d4, double d5, double d6)
|
||||
{
|
||||
m_oTransform.SetElements(d1, d2, d3, d4, d5, d6);
|
||||
m_oCurrentPage.m_oTransform.SetElements(d1, d2, d3, d4, d5, d6);
|
||||
}
|
||||
|
||||
void CDocument::ApplyTransform2(double dAngle, double dLeft, double dTop, double dWidth, double dHeight, DWORD lFlags)
|
||||
@ -788,73 +763,49 @@ namespace NSDocxRenderer
|
||||
oMatrix.Translate(dCentreX, dCentreY, Aggplus::MatrixOrderAppend);
|
||||
}
|
||||
|
||||
m_oTransform = oMatrix;
|
||||
m_oCurrentPage.m_oTransform = oMatrix;
|
||||
}
|
||||
|
||||
void CDocument::_SetFont()
|
||||
{
|
||||
if (nullptr == m_pFontManager)
|
||||
if (nullptr == m_pBaseFontManager)
|
||||
{
|
||||
m_pFontManager = m_pAppFonts->GenerateFontManager();
|
||||
m_pFontManager->CreateOwnerCache(8);
|
||||
m_pBaseFontManager = m_pAppFonts->GenerateFontManager();
|
||||
m_pBaseFontManager->CreateOwnerCache(8);
|
||||
}
|
||||
|
||||
double dPix = m_oFont.CharSpace * m_dDpiX / 25.4;
|
||||
|
||||
if (m_oInstalledFont.IsEqual(&m_oFont))
|
||||
double dPix = m_oCurrentPage.m_oFont.CharSpace * m_dDpiX / 25.4;
|
||||
if (m_oInstalledFont.IsEqual(&m_oCurrentPage.m_oFont))
|
||||
{
|
||||
if (1 < m_dWidth)
|
||||
{
|
||||
m_pFontManager->SetCharSpacing(dPix);
|
||||
m_pBaseFontManager->SetCharSpacing(dPix);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
m_pFontManager->SetStringGID(m_oFont.StringGID);
|
||||
m_pBaseFontManager->SetStringGID(m_oCurrentPage.m_oFont.StringGID);
|
||||
if (1 < m_dWidth)
|
||||
{
|
||||
m_pFontManager->SetCharSpacing(dPix);
|
||||
}
|
||||
m_pBaseFontManager->SetCharSpacing(dPix);
|
||||
|
||||
if (m_oFont.Path.empty())
|
||||
{
|
||||
m_pFontManager->LoadFontByName(m_oFont.Name, (float)m_oFont.Size, m_oFont.GetStyle(), m_dDpiX, m_dDpiY);
|
||||
}
|
||||
if (m_oCurrentPage.m_oFont.Path.empty())
|
||||
m_pBaseFontManager->LoadFontByName(m_oCurrentPage.m_oFont.Name, (float)m_oCurrentPage.m_oFont.Size, m_oCurrentPage.m_oFont.GetStyle(), m_dDpiX, m_dDpiY);
|
||||
else
|
||||
{
|
||||
m_pFontManager->LoadFontFromFile(m_oFont.Path, m_oFont.FaceIndex, (float)m_oFont.Size, m_dDpiX, m_dDpiY);
|
||||
}
|
||||
|
||||
m_oInstalledFont = m_oFont;
|
||||
m_pBaseFontManager->LoadFontFromFile(m_oCurrentPage.m_oFont.Path, m_oCurrentPage.m_oFont.FaceIndex, (float)m_oCurrentPage.m_oFont.Size, m_dDpiX, m_dDpiY);
|
||||
m_oInstalledFont = m_oCurrentPage.m_oFont;
|
||||
}
|
||||
|
||||
void CDocument::Init(const bool& bIsClearStreams)
|
||||
void CDocument::Init(bool bIsClearStreams)
|
||||
{
|
||||
Clear();
|
||||
|
||||
// Сбросим кэш шрифтов. По идее можно оставлять кэш для шрифтов "по имени",
|
||||
// но для шрифтов из темповых папок - нет. Темповая папка для Reader (PDF/XPS/DJVU)
|
||||
// может быть одной и той же. И создание там файлов функцией создания временных файлов
|
||||
// может вернуть один и тот же путь. И шрифт возьмется из старого файла.
|
||||
m_oFontSelector.ClearCache();
|
||||
m_oFontManager.ClearCache();
|
||||
if (m_pAppFonts && bIsClearStreams) m_pAppFonts->GetStreams()->Clear();
|
||||
|
||||
Clear();
|
||||
m_lCurrentCommandType = 0;
|
||||
|
||||
m_oCurrentPage.Init(&m_oFont,
|
||||
&m_oPen,
|
||||
&m_oBrush,
|
||||
&m_oShadow,
|
||||
&m_oEdge,
|
||||
&m_oTransform,
|
||||
&m_oSimpleGraphicsConverter,
|
||||
&m_oImageManager,
|
||||
&m_oFontStyleManager,
|
||||
&m_oFontManager,
|
||||
&m_oFontSelector,
|
||||
&m_oParagraphStyleManager);
|
||||
|
||||
m_oImageManager.Clear();
|
||||
m_oFontStyleManager.Clear();
|
||||
}
|
||||
|
||||
#ifndef DISABLE_FULL_DOCUMENT_CREATION
|
||||
|
||||
@ -12,42 +12,34 @@ namespace NSDocxRenderer
|
||||
class CDocument
|
||||
{
|
||||
public:
|
||||
NSFonts::IApplicationFonts* m_pAppFonts;
|
||||
|
||||
NSStructures::CPen m_oPen;
|
||||
NSStructures::CBrush m_oBrush;
|
||||
NSStructures::CFont m_oFont;
|
||||
NSStructures::CShadow m_oShadow;
|
||||
NSStructures::CEdgeText m_oEdge;
|
||||
|
||||
NSStructures::CFont m_oInstalledFont;
|
||||
Aggplus::CMatrix m_oTransform;
|
||||
|
||||
CImageManager m_oImageManager;
|
||||
CFontStyleManager m_oFontStyleManager;
|
||||
CParagraphStyleManager m_oParagraphStyleManager;
|
||||
CFontManager m_oFontManager;
|
||||
CFontSelector m_oFontSelector;
|
||||
|
||||
CPage m_oCurrentPage;
|
||||
LONG m_lCurrentCommandType {0};
|
||||
|
||||
double m_dWidth {0.0};
|
||||
double m_dHeight {0.0};
|
||||
double m_dDpiX {72.0};
|
||||
double m_dDpiY {72.0};
|
||||
|
||||
std::wstring m_strTempDirectory {L""};
|
||||
std::wstring m_strDstFilePath;
|
||||
|
||||
LONG m_lPageNum {0};
|
||||
LONG m_lNumberPages{0};
|
||||
|
||||
bool m_bIsDisablePageCommand {false}; // disable commands inside draw function
|
||||
|
||||
NSFonts::IFontManager* m_pFontManager {nullptr};
|
||||
Aggplus::CGraphicsPathSimpleConverter m_oSimpleGraphicsConverter;
|
||||
|
||||
NSFonts::IApplicationFonts* m_pAppFonts {nullptr};
|
||||
NSFonts::IFontManager* m_pBaseFontManager{nullptr};
|
||||
NSStructures::CFont m_oInstalledFont;
|
||||
|
||||
CImageManager m_oImageManager;
|
||||
CFontStyleManager m_oFontStyleManager;
|
||||
CParagraphStyleManager m_oParagraphStyleManager;
|
||||
CFontManager m_oFontManager;
|
||||
CFontSelector m_oFontSelector;
|
||||
|
||||
CPage m_oCurrentPage;
|
||||
LONG m_lCurrentCommandType {0};
|
||||
|
||||
double m_dWidth {0.0};
|
||||
double m_dHeight {0.0};
|
||||
double m_dDpiX {72.0};
|
||||
double m_dDpiY {72.0};
|
||||
|
||||
std::wstring m_strTempDirectory {L""};
|
||||
std::wstring m_strDstFilePath;
|
||||
|
||||
LONG m_lPageNum {0};
|
||||
LONG m_lNumberPages{0};
|
||||
|
||||
bool m_bIsDisablePageCommand {false}; // disable commands inside draw function
|
||||
|
||||
std::map<LONG, NSStringUtils::CStringBuilder*> m_mapXmlString;
|
||||
|
||||
public:
|
||||
@ -62,8 +54,7 @@ namespace NSDocxRenderer
|
||||
HRESULT put_Width(double dWidth);
|
||||
HRESULT get_DpiX(double* dDpiX);
|
||||
HRESULT get_DpiY(double* dDpiY);
|
||||
//-------- Функции для задания настроек текста ----------------------------------------------
|
||||
// pen --------------------------------------------------------------------------------------
|
||||
|
||||
HRESULT get_PenColor(LONG* lColor);
|
||||
HRESULT put_PenColor(LONG lColor);
|
||||
HRESULT get_PenAlpha(LONG* lAlpha);
|
||||
@ -85,7 +76,7 @@ namespace NSDocxRenderer
|
||||
HRESULT get_PenMiterLimit(double* val);
|
||||
HRESULT put_PenMiterLimit(double val);
|
||||
HRESULT PenDashPattern(double* pPattern, LONG lCount);
|
||||
// brush ------------------------------------------------------------------------------------
|
||||
|
||||
HRESULT get_BrushType(LONG* lType);
|
||||
HRESULT put_BrushType(LONG lType);
|
||||
HRESULT get_BrushColor1(LONG* lColor);
|
||||
@ -108,7 +99,7 @@ namespace NSDocxRenderer
|
||||
HRESULT BrushBounds(const double& dLeft, const double& dTop, const double& dWidth, const double& dHeight);
|
||||
HRESULT put_BrushGradientColors(LONG* pColors, double* pPositions, LONG lCount);
|
||||
HRESULT put_BrushGradInfo(void* pGradInfo);
|
||||
// font -------------------------------------------------------------------------------------
|
||||
|
||||
HRESULT get_FontName(std::wstring* sName);
|
||||
HRESULT put_FontName(std::wstring sName);
|
||||
HRESULT get_FontPath(std::wstring* sPath);
|
||||
@ -123,7 +114,7 @@ namespace NSDocxRenderer
|
||||
HRESULT put_FontCharSpace(double dSpace);
|
||||
HRESULT get_FontFaceIndex(int* lFaceIndex);
|
||||
HRESULT put_FontFaceIndex(const int& lFaceIndex);
|
||||
// shadow -----------------------------------------------------------------------------------
|
||||
|
||||
HRESULT get_ShadowDistanceX(double* val);
|
||||
HRESULT put_ShadowDistanceX(double val);
|
||||
HRESULT get_ShadowDistanceY(double* val);
|
||||
@ -136,7 +127,7 @@ namespace NSDocxRenderer
|
||||
HRESULT put_ShadowAlpha(LONG val);
|
||||
HRESULT get_ShadowVisible(INT* val);
|
||||
HRESULT put_ShadowVisible(INT val);
|
||||
// edge -------------------------------------------------------------------------------------
|
||||
|
||||
HRESULT get_EdgeVisible(LONG* val);
|
||||
HRESULT put_EdgeVisible(LONG val);
|
||||
HRESULT get_EdgeColor(LONG* val);
|
||||
@ -145,20 +136,16 @@ namespace NSDocxRenderer
|
||||
HRESULT put_EdgeAlpha(LONG val);
|
||||
HRESULT get_EdgeDist(double* val);
|
||||
HRESULT put_EdgeDist(double val);
|
||||
//-------- Функции для вывода текста --------------------------------------------------------
|
||||
HRESULT CommandDrawTextPrivate(const int* pUnicodes, const int* pGids, int nCount,
|
||||
const double& dX, const double& dY, const double& dW,
|
||||
const double& dH, const double& dBaseLineOffset = 0);
|
||||
|
||||
HRESULT CommandDrawTextPrivate(const int* pUnicodes, const int* pGids, int nCount, const double& dX, const double& dY, const double& dW, const double& dH, const double& dBaseLineOffset = 0);
|
||||
HRESULT CommandDrawTextCHAR(const int& lUnicode, const double& dX, const double& dY, const double& dW, const double& dH);
|
||||
HRESULT CommandDrawTextExCHAR(const int& lUnicode, const int& lGid, const double& dX, const double& dY, const double& dW, const double& dH);
|
||||
virtual HRESULT CommandDrawText(const std::wstring& wsUnicodeText, const double& dX, const double& dY, const double& dW, const double& dH);
|
||||
virtual HRESULT CommandDrawTextEx(const std::wstring& wsUnicodeText, const unsigned int* pGids,
|
||||
const unsigned int nGidsCount, const double& dX, const double& dY,
|
||||
const double& dW, const double& dH);
|
||||
//-------- Маркеры для команд ---------------------------------------------------------------
|
||||
virtual HRESULT CommandDrawTextEx(const std::wstring& wsUnicodeText, const unsigned int* pGids, const unsigned int nGidsCount, const double& dX, const double& dY, const double& dW, const double& dH);
|
||||
|
||||
HRESULT BeginCommand(DWORD lType);
|
||||
HRESULT EndCommand(DWORD lType);
|
||||
//-------- Функции для работы с Graphics Path -----------------------------------------------
|
||||
|
||||
HRESULT PathCommandMoveTo(double fX, double fY);
|
||||
HRESULT PathCommandLineTo(double fX, double fY);
|
||||
HRESULT PathCommandLinesTo(double* pPoints, LONG lCount);
|
||||
@ -178,10 +165,10 @@ namespace NSDocxRenderer
|
||||
|
||||
HRESULT GetCommandParams(double* dAngle, double* dLeft, double* dTop, double* dWidth, double* dHeight, DWORD* lFlags);
|
||||
HRESULT SetCommandParams(double dAngle, double dLeft, double dTop, double dWidth, double dHeight, DWORD lFlags);
|
||||
//-------- Функции для вывода изображений --------------------------------------------------
|
||||
|
||||
HRESULT DrawImage(IGrObject* pImage, double fX, double fY, double fWidth, double fHeight);
|
||||
HRESULT DrawImageFromFile(const std::wstring& sVal, double fX, double fY, double fWidth, double fHeight);
|
||||
//------------------------------------------------------------------------------------------
|
||||
|
||||
HRESULT SetTransform(double dA, double dB, double dC, double dD, double dE, double dF);
|
||||
HRESULT GetTransform(double *pdA, double *pdB, double *pdC, double *pdD, double *pdE, double *pdF);
|
||||
HRESULT ResetTransform(void);
|
||||
@ -194,7 +181,7 @@ namespace NSDocxRenderer
|
||||
void _SetFont();
|
||||
public:
|
||||
|
||||
void Init(const bool& bIsClearStreams = true);
|
||||
void Init(bool bIsClearStreams = true);
|
||||
void Clear();
|
||||
|
||||
#ifndef DISABLE_FULL_DOCUMENT_CREATION
|
||||
|
||||
@ -11,39 +11,10 @@
|
||||
|
||||
namespace NSDocxRenderer
|
||||
{
|
||||
CPage::CPage()
|
||||
CPage::CPage(NSFonts::IApplicationFonts* pAppFonts, const CManagers& oManagers) :
|
||||
m_oManagers(oManagers), m_oContBuilder(oManagers.pFontStyleManager, oManagers.pFontSelector)
|
||||
{
|
||||
}
|
||||
|
||||
void CPage::Init(
|
||||
NSStructures::CFont* pFont,
|
||||
NSStructures::CPen* pPen,
|
||||
NSStructures::CBrush* pBrush,
|
||||
NSStructures::CShadow* pShadow,
|
||||
NSStructures::CEdgeText* pEdge,
|
||||
Aggplus::CMatrix* pMatrix,
|
||||
Aggplus::CGraphicsPathSimpleConverter* pSimple,
|
||||
CImageManager* pImageManager,
|
||||
CFontStyleManager* pFontStyleManager,
|
||||
CFontManager *pFontManager,
|
||||
CFontSelector* pFontSelector,
|
||||
CParagraphStyleManager* pParagraphStyleManager)
|
||||
{
|
||||
m_pFont = pFont;
|
||||
m_pPen = pPen;
|
||||
m_pBrush = pBrush;
|
||||
m_pShadow = pShadow;
|
||||
m_pEdgeText = pEdge;
|
||||
|
||||
m_pTransform = pMatrix;
|
||||
m_pSimpleGraphicsConverter = pSimple;
|
||||
|
||||
m_pImageManager = pImageManager;
|
||||
m_pFontStyleManager = pFontStyleManager;
|
||||
m_pFontManager = pFontManager;
|
||||
m_pFontSelector = pFontSelector;
|
||||
m_pParagraphStyleManager = pParagraphStyleManager;
|
||||
|
||||
m_pAppFonts = pAppFonts;
|
||||
CShape::ResetRelativeHeight();
|
||||
}
|
||||
|
||||
@ -77,6 +48,13 @@ namespace NSDocxRenderer
|
||||
|
||||
void CPage::Clear()
|
||||
{
|
||||
m_oPen.SetDefaultParams();
|
||||
m_oBrush.SetDefaultParams();
|
||||
m_oFont.SetDefaultParams();
|
||||
m_oShadow.SetDefaultParams();
|
||||
m_oEdgeText.SetDefaultParams();
|
||||
m_oTransform.Reset();
|
||||
|
||||
m_arConts.clear();
|
||||
m_arTextLines.clear();
|
||||
m_arDiacriticalSymbols.clear();
|
||||
@ -103,13 +81,13 @@ namespace NSDocxRenderer
|
||||
// image commands
|
||||
void CPage::WriteImage(const std::shared_ptr<CImageInfo> pInfo, double& fX, double& fY, double& fWidth, double& fHeight)
|
||||
{
|
||||
double rotation = m_pTransform->z_Rotation();
|
||||
double rotation = m_oTransform.z_Rotation();
|
||||
|
||||
Point p1(fX, fY);
|
||||
Point p2(fX + fWidth, fY + fHeight);
|
||||
|
||||
m_pTransform->TransformPoint(p1.x, p1.y);
|
||||
m_pTransform->TransformPoint(p2.x, p2.y);
|
||||
m_oTransform.TransformPoint(p1.x, p1.y);
|
||||
m_oTransform.TransformPoint(p2.x, p2.y);
|
||||
|
||||
Point c((p1.x + p2.x) / 2, (p1.y + p2.y) / 2);
|
||||
Aggplus::CMatrix rotate_matrix;
|
||||
@ -138,25 +116,24 @@ namespace NSDocxRenderer
|
||||
}
|
||||
|
||||
// path commands
|
||||
void CPage::MoveTo(double& dX, double& dY)
|
||||
void CPage::PathMoveTo(double& dX, double& dY)
|
||||
{
|
||||
m_pTransform->TransformPoint(dX, dY);
|
||||
m_oTransform.TransformPoint(dX, dY);
|
||||
m_oCurrVectorGraphics.MoveTo(dX, dY);
|
||||
}
|
||||
|
||||
void CPage::LineTo(double& dX, double& dY)
|
||||
void CPage::PathLineTo(double& dX, double& dY)
|
||||
{
|
||||
m_pTransform->TransformPoint(dX, dY);
|
||||
m_oTransform.TransformPoint(dX, dY);
|
||||
m_oCurrVectorGraphics.LineTo(dX, dY);
|
||||
}
|
||||
|
||||
void CPage::CurveTo(double& x1, double& y1, double& x2, double& y2, double& x3, double& y3)
|
||||
void CPage::PathCurveTo(double& dX1, double& dY1, double& dX2, double& dY2, double& dX3, double& dY3)
|
||||
{
|
||||
m_pTransform->TransformPoint(x1, y1);
|
||||
m_pTransform->TransformPoint(x2, y2);
|
||||
m_pTransform->TransformPoint(x3, y3);
|
||||
|
||||
m_oCurrVectorGraphics.CurveTo(x1, y1, x2, y2, x3, y3);
|
||||
m_oTransform.TransformPoint(dX1, dY1);
|
||||
m_oTransform.TransformPoint(dX2, dY2);
|
||||
m_oTransform.TransformPoint(dX3, dY3);
|
||||
m_oCurrVectorGraphics.CurveTo(dX1, dY1, dX2, dY2, dX3, dY3);
|
||||
}
|
||||
|
||||
void CPage::PathStart()
|
||||
@ -183,12 +160,12 @@ namespace NSDocxRenderer
|
||||
if (m_oCurrVectorGraphics.IsEmpty())
|
||||
return;
|
||||
|
||||
double rotation = m_pTransform->z_Rotation();
|
||||
double rotation = m_oTransform.z_Rotation();
|
||||
double left = m_oCurrVectorGraphics.GetLeft();
|
||||
double right = m_oCurrVectorGraphics.GetRight();
|
||||
double top = m_oCurrVectorGraphics.GetTop();
|
||||
double bot = m_oCurrVectorGraphics.GetBottom();
|
||||
double transform_det = sqrt(fabs(m_pTransform->Determinant()));
|
||||
double transform_det = sqrt(fabs(m_oTransform.Determinant()));
|
||||
|
||||
// save default image vector before clip to calc blipFill
|
||||
auto image_vector = m_oCurrVectorGraphics;
|
||||
@ -197,13 +174,13 @@ namespace NSDocxRenderer
|
||||
if (lType & c_nStroke)
|
||||
{
|
||||
s->m_bIsNoStroke = false;
|
||||
s->m_oPen = *m_pPen;
|
||||
s->m_oPen = m_oPen;
|
||||
s->m_oPen.Size *= transform_det;
|
||||
}
|
||||
if (lType & c_nWindingFillMode || lType & c_nEvenOddFillMode)
|
||||
{
|
||||
s->m_bIsNoFill = false;
|
||||
s->m_oBrush = *m_pBrush;
|
||||
s->m_oBrush = m_oBrush;
|
||||
}
|
||||
};
|
||||
|
||||
@ -225,8 +202,8 @@ namespace NSDocxRenderer
|
||||
{
|
||||
if ((fabs(left - right) < 0.3) || (fabs(top - bot) < 0.3))
|
||||
{
|
||||
shape->m_oPen.Color = m_pBrush->Color1;
|
||||
shape->m_oPen.Alpha = m_pBrush->Alpha1;
|
||||
shape->m_oPen.Color = m_oBrush.Color1;
|
||||
shape->m_oPen.Alpha = m_oBrush.Alpha1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -281,7 +258,7 @@ namespace NSDocxRenderer
|
||||
transform_matrix.Translate(-shifted_vector.GetLeft(), -shifted_vector.GetTop());
|
||||
shifted_vector.Transform(transform_matrix);
|
||||
|
||||
NSStructures::CBrush shifted_brush = *m_pBrush;
|
||||
NSStructures::CBrush shifted_brush = m_oBrush;
|
||||
shifted_brush.Bounds.left = shifted_vector.GetLeft();
|
||||
shifted_brush.Bounds.right = shifted_vector.GetRight();
|
||||
shifted_brush.Bounds.bottom = shifted_vector.GetBottom();
|
||||
@ -294,7 +271,7 @@ namespace NSDocxRenderer
|
||||
g_renderer->put_Width(shape->m_dWidth);
|
||||
g_renderer->put_Height(shape->m_dHeight);
|
||||
g_renderer->RestoreBrush(shifted_brush);
|
||||
g_renderer->RestorePen(*m_pPen);
|
||||
g_renderer->RestorePen(m_oPen);
|
||||
g_renderer->BeginCommand(c_nPathType);
|
||||
shifted_vector.DrawOnRenderer(g_renderer);
|
||||
g_renderer->DrawPath(c_nWindingFillMode);
|
||||
@ -302,7 +279,7 @@ namespace NSDocxRenderer
|
||||
|
||||
Aggplus::CImage img;
|
||||
img.Create(data, width_pix, height_pix, stride, true);
|
||||
info = m_pImageManager->WriteImage(&img, shape->m_dTop, shape->m_dBaselinePos, shape->m_dWidth, shape->m_dHeight);
|
||||
info = m_oManagers.pImageManager->WriteImage(&img, shape->m_dTop, shape->m_dBaselinePos, shape->m_dWidth, shape->m_dHeight);
|
||||
rotation = 0;
|
||||
image_vector = shape->m_oVector;
|
||||
|
||||
@ -338,7 +315,7 @@ namespace NSDocxRenderer
|
||||
m_arShapes.push_back(shape);
|
||||
}
|
||||
|
||||
void CPage::CollectTextData(
|
||||
void CPage::AddText(
|
||||
const PUINT pUnicodes,
|
||||
const PUINT pGids,
|
||||
const UINT& nCount,
|
||||
@ -357,8 +334,8 @@ namespace NSDocxRenderer
|
||||
double dTextR = fX + fWidth;
|
||||
double dTextB = fY + fHeight;
|
||||
|
||||
m_pTransform->TransformPoint(dTextX, dTextY);
|
||||
m_pTransform->TransformPoint(dTextR, dTextB);
|
||||
m_oTransform.TransformPoint(dTextX, dTextY);
|
||||
m_oTransform.TransformPoint(dTextR, dTextB);
|
||||
|
||||
NSStringUtils::CStringUTF32 oText((uint32_t*)pUnicodes, nCount);
|
||||
|
||||
@ -370,10 +347,10 @@ namespace NSDocxRenderer
|
||||
// иногда приходит неверный? размер, нужно перемерить (XPS)
|
||||
if (m_bIsRecalcFontSize)
|
||||
{
|
||||
m_pFont->Size *= ((m_pTransform->sx() + m_pTransform->sy()) / 2);
|
||||
m_oFont.Size *= ((m_oTransform.sx() + m_oTransform.sy()) / 2);
|
||||
m_bIsRecalcFontSize = false;
|
||||
}
|
||||
m_pFontManager->LoadFontByFile(*m_pFont);
|
||||
m_oManagers.pFontManager->LoadFontByFile(m_oFont);
|
||||
|
||||
double _x = 0;
|
||||
double _y = 0;
|
||||
@ -382,151 +359,37 @@ namespace NSDocxRenderer
|
||||
|
||||
if (nullptr != pGids)
|
||||
{
|
||||
m_pFontManager->SetStringGid(1);
|
||||
m_pFontManager->MeasureStringGids(pGids, nCount, dTextX, dTextY, _x, _y, _w, _h, CFontManager::mtPosition);
|
||||
m_oManagers.pFontManager->SetStringGid(1);
|
||||
m_oManagers.pFontManager->MeasureStringGids(pGids, nCount, dTextX, dTextY, _x, _y, _w, _h, CFontManager::mtPosition);
|
||||
}
|
||||
else
|
||||
{
|
||||
// такого быть не должно (только из xps)
|
||||
m_pFontManager->SetStringGid(0);
|
||||
m_pFontManager->MeasureStringGids(pUnicodes, nCount, dTextX, dTextY, _x, _y, _w, _h, CFontManager::mtPosition);
|
||||
m_oManagers.pFontManager->SetStringGid(0);
|
||||
m_oManagers.pFontManager->MeasureStringGids(pUnicodes, nCount, dTextX, dTextY, _x, _y, _w, _h, CFontManager::mtPosition);
|
||||
}
|
||||
|
||||
auto oMetrics = m_pFontManager->GetFontMetrics();
|
||||
_h = m_pFontManager->GetFontHeight();
|
||||
_h = m_oManagers.pFontManager->GetFontHeight();
|
||||
|
||||
double baseline = dTextY + fBaseLineOffset;
|
||||
double top = baseline - _h;
|
||||
double height = baseline - top;
|
||||
double left = dTextX;
|
||||
double width = _w;
|
||||
double right = left + _w;
|
||||
|
||||
// if new text is close to current cont
|
||||
if (m_pCurrCont != nullptr &&
|
||||
fabs(m_pCurrCont->m_dBaselinePos - baseline) < c_dTHE_SAME_STRING_Y_PRECISION_MM &&
|
||||
m_oPrevFont.IsEqual2(m_pFont) &&
|
||||
m_oPrevBrush.IsEqual(m_pBrush))
|
||||
{
|
||||
|
||||
double avg_width = width / oText.length();
|
||||
for (size_t i = 0; i < oText.length(); ++i)
|
||||
if (oText.at(i) == c_SPACE_SYM)
|
||||
m_pCurrCont->m_pFontStyle->UpdateAvgSpaceWidth(avg_width);
|
||||
|
||||
double avg_space_width = m_pCurrCont->m_pFontStyle->GetAvgSpaceWidth();
|
||||
double space_width =
|
||||
avg_space_width != 0.0 ?
|
||||
avg_space_width * c_dAVERAGE_SPACE_WIDTH_COEF :
|
||||
m_pCurrCont->CalculateSpace() * c_dSPACE_WIDTH_COEF;
|
||||
|
||||
bool is_added = false;
|
||||
|
||||
// some_text+more_text
|
||||
if (fabs(m_pCurrCont->m_dRight - left) < space_width && right > m_pCurrCont->m_dRight)
|
||||
{
|
||||
double left_avg_width = (right - m_pCurrCont->m_dRight) / oText.length();
|
||||
std::vector<double> ar_widths;
|
||||
for (size_t i = 0; i < oText.length(); ++i)
|
||||
ar_widths.push_back(left_avg_width);
|
||||
|
||||
m_pCurrCont->AddTextBack(oText, ar_widths);
|
||||
is_added = true;
|
||||
|
||||
}
|
||||
// more_text+some_text
|
||||
else if (fabs(m_pCurrCont->m_dLeft - right) < space_width && left < m_pCurrCont->m_dLeft)
|
||||
{
|
||||
double right_avg_width = (m_pCurrCont->m_dLeft - left) / oText.length();
|
||||
std::vector<double> ar_widths;
|
||||
for (size_t i = 0; i < oText.length(); ++i)
|
||||
ar_widths.push_back(right_avg_width);
|
||||
|
||||
m_pCurrCont->AddTextFront(oText, ar_widths);
|
||||
is_added = true;
|
||||
}
|
||||
|
||||
if (is_added)
|
||||
{
|
||||
m_pCurrCont->m_dTop = std::min(m_pCurrCont->m_dTop, top);
|
||||
m_pCurrCont->m_dBaselinePos = std::max(m_pCurrCont->m_dBaselinePos, baseline);
|
||||
m_pCurrCont->m_dHeight = m_pCurrCont->m_dBaselinePos - m_pCurrCont->m_dTop;
|
||||
m_pCurrCont->m_dWidth = m_pCurrCont->m_dRight - m_pCurrCont->m_dLeft;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
auto pCont = std::make_shared<CContText>(m_pFontManager);
|
||||
auto oParams = m_pFontManager->GetFontSelectParams();
|
||||
|
||||
// use forced fold option
|
||||
const auto& oParams = m_oManagers.pFontManager->GetFontSelectParams();
|
||||
bool bForcedBold = oParams.bDefaultBold;
|
||||
if (m_lCurrentCommand == c_nStrokeTextType && m_pFont->Bold)
|
||||
if (m_lCurrentCommand == c_nStrokeTextType && m_oFont.Bold)
|
||||
bForcedBold = true;
|
||||
|
||||
m_pFontSelector->SelectFont(oParams, oMetrics, oText);
|
||||
|
||||
pCont->m_dBaselinePos = baseline;
|
||||
pCont->m_dTop = top;
|
||||
pCont->m_dHeight = height;
|
||||
pCont->m_dLeft = left;
|
||||
|
||||
// первичное получение стиля для текущего символа
|
||||
// при дальнейшем анализе может измениться
|
||||
pCont->m_pFontStyle = m_pFontStyleManager->GetOrAddFontStyle(
|
||||
*m_pBrush,
|
||||
m_pFontSelector->GetSelectedName(),
|
||||
m_pFont->Size,
|
||||
m_pFontSelector->IsSelectedItalic(),
|
||||
m_pFontSelector->IsSelectedBold() || bForcedBold);
|
||||
|
||||
// just in case if oText contains more than 1 symbol
|
||||
std::vector<double> ar_widths;
|
||||
double avg_width = abs(right - left) / oText.length();
|
||||
for (size_t i = 0; i < oText.length(); ++i)
|
||||
{
|
||||
if (oText.at(i) == c_SPACE_SYM) pCont->m_pFontStyle->UpdateAvgSpaceWidth(avg_width);
|
||||
ar_widths.push_back(avg_width);
|
||||
}
|
||||
|
||||
pCont->SetText(oText, ar_widths);
|
||||
pCont->m_bIsRtl = CContText::IsUnicodeRtl(oText[0]);
|
||||
|
||||
pCont->m_dWidth = width;
|
||||
pCont->m_dRight = right;
|
||||
|
||||
double font_size = m_pFont->Size;
|
||||
double em_height = oMetrics.dEmHeight;
|
||||
double ratio = font_size / em_height * c_dPtToMM;
|
||||
|
||||
pCont->m_dTopWithAscent = pCont->m_dBaselinePos - (oMetrics.dAscent * ratio) - oMetrics.dBaselineOffset;
|
||||
pCont->m_dBotWithDescent = pCont->m_dBaselinePos + (oMetrics.dDescent * ratio) - oMetrics.dBaselineOffset;
|
||||
pCont->m_dSpaceWidthMM = m_pFontManager->GetSpaceWidthMM();
|
||||
|
||||
if (m_bUseDefaultFont)
|
||||
{
|
||||
pCont->m_oSelectedFont.Path = m_pFont->Path;
|
||||
pCont->m_oSelectedFont.Size = m_pFont->Size;
|
||||
pCont->m_oSelectedFont.FaceIndex = m_pFont->FaceIndex;
|
||||
}
|
||||
else
|
||||
{
|
||||
pCont->m_oSelectedFont.Name = m_pFontSelector->GetSelectedName();
|
||||
pCont->m_oSelectedFont.Size = m_pFont->Size;
|
||||
pCont->m_oSelectedFont.Bold = m_pFontSelector->IsSelectedBold();
|
||||
pCont->m_oSelectedFont.Italic = m_pFontSelector->IsSelectedItalic();
|
||||
}
|
||||
pCont->m_bWriteStyleRaw = m_bWriteStyleRaw;
|
||||
m_pParagraphStyleManager->UpdateAvgFontSize(m_pFont->Size);
|
||||
m_arConts.push_back(pCont);
|
||||
|
||||
m_pCurrCont = pCont;
|
||||
m_oPrevFont = *m_pFont;
|
||||
m_oPrevBrush = *m_pBrush;
|
||||
m_oManagers.pParagraphStyleManager->UpdateAvgFontSize(m_oFont.Size);
|
||||
m_oContBuilder.AddUnicode(top, baseline, left, right, m_oFont, m_oBrush, m_oManagers.pFontManager, oText, bForcedBold, m_bUseDefaultFont, m_bWriteStyleRaw);
|
||||
}
|
||||
|
||||
void CPage::Analyze()
|
||||
{
|
||||
m_arConts = std::move(m_oContBuilder.GetConts());
|
||||
|
||||
// analyze shapes (get type of lines etc)
|
||||
AnalyzeShapes();
|
||||
|
||||
@ -788,7 +651,7 @@ namespace NSDocxRenderer
|
||||
|
||||
void CPage::AnalyzeDropCaps()
|
||||
{
|
||||
double avg_font_size = m_pParagraphStyleManager->GetAvgFontSize();
|
||||
double avg_font_size = m_oManagers.pParagraphStyleManager->GetAvgFontSize();
|
||||
|
||||
std::vector<std::pair<std::shared_ptr<CContText>&, std::shared_ptr<CTextLine>&>> possible_caps;
|
||||
std::vector<std::shared_ptr<CDropCap>> drop_caps;
|
||||
@ -862,9 +725,9 @@ namespace NSDocxRenderer
|
||||
NSStructures::CFont oFont;
|
||||
oFont.Name = drop_cap->wsFont;
|
||||
oFont.Size = static_cast<double>(drop_cap->nFontSize) / 2.0;
|
||||
m_pFontManager->LoadFontByName(oFont);
|
||||
m_oManagers.pFontManager->LoadFontByName(oFont);
|
||||
|
||||
auto h = m_pFontManager->GetFontHeight();
|
||||
auto h = m_oManagers.pFontManager->GetFontHeight();
|
||||
|
||||
shape->m_dTop = drop_cap->m_dTop;
|
||||
shape->m_dBaselinePos = drop_cap->m_dTop + h;
|
||||
@ -940,7 +803,7 @@ namespace NSDocxRenderer
|
||||
{
|
||||
CFontStyle font_style = *pCurrCont->m_pFontStyle;
|
||||
font_style.bBold = true;
|
||||
pCurrCont->m_pFontStyle = m_pFontStyleManager->GetOrAddFontStyle(font_style);
|
||||
pCurrCont->m_pFontStyle = m_oManagers.pFontStyleManager->GetOrAddFontStyle(font_style);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1037,7 +900,7 @@ namespace NSDocxRenderer
|
||||
auto oBrush = curr_cont->m_pFontStyle->oBrush;
|
||||
oBrush.Color1 = shape->m_oPen.Color;
|
||||
|
||||
curr_cont->m_pFontStyle = m_pFontStyleManager->GetOrAddFontStyle(
|
||||
curr_cont->m_pFontStyle = m_oManagers.pFontStyleManager->GetOrAddFontStyle(
|
||||
oBrush,
|
||||
curr_cont->m_pFontStyle->wsFontName,
|
||||
curr_cont->m_pFontStyle->dFontSize,
|
||||
@ -1629,7 +1492,7 @@ namespace NSDocxRenderer
|
||||
paragraph->m_dLineHeight = paragraph->m_dHeight / paragraph->m_arLines.size();
|
||||
paragraph->m_bIsNeedFirstLineIndent = false;
|
||||
paragraph->m_dFirstLine = 0;
|
||||
paragraph->m_wsStyleId = m_pParagraphStyleManager->GetDefaultParagraphStyleId(*paragraph);
|
||||
paragraph->m_wsStyleId = m_oManagers.pParagraphStyleManager->GetDefaultParagraphStyleId(*paragraph);
|
||||
|
||||
paragraph->MergeLines();
|
||||
|
||||
|
||||
@ -12,86 +12,74 @@ namespace NSDocxRenderer
|
||||
class CPage
|
||||
{
|
||||
public:
|
||||
struct CManagers
|
||||
{
|
||||
CManagers() = default;
|
||||
CManagers(const CManagers& other) = default;
|
||||
~CManagers() = default;
|
||||
|
||||
CImageManager* pImageManager;
|
||||
CFontStyleManager* pFontStyleManager;
|
||||
CParagraphStyleManager* pParagraphStyleManager;
|
||||
CFontManager* pFontManager;
|
||||
CFontSelector* pFontSelector;
|
||||
};
|
||||
|
||||
double m_dWidth {0.0};
|
||||
double m_dHeight {0.0};
|
||||
|
||||
LONG m_lCurrentCommand{0};
|
||||
LONG m_lClipMode{0};
|
||||
bool m_bIsGradient = false;
|
||||
|
||||
TextAssociationType m_eTextAssociationType {TextAssociationType::tatPlainParagraph};
|
||||
TextAssociationType m_eTextAssociationType{TextAssociationType::tatPlainParagraph};
|
||||
NSFonts::IApplicationFonts* m_pAppFonts{nullptr};
|
||||
|
||||
bool m_bUseDefaultFont{false};
|
||||
bool m_bWriteStyleRaw {false};
|
||||
NSStructures::CFont m_oFont;
|
||||
NSStructures::CPen m_oPen;
|
||||
NSStructures::CBrush m_oBrush;
|
||||
NSStructures::CShadow m_oShadow;
|
||||
NSStructures::CEdgeText m_oEdgeText;
|
||||
|
||||
NSStructures::CFont* m_pFont {nullptr};
|
||||
NSStructures::CPen* m_pPen {nullptr};
|
||||
NSStructures::CBrush* m_pBrush {nullptr};
|
||||
NSStructures::CShadow* m_pShadow {nullptr};
|
||||
NSStructures::CEdgeText* m_pEdgeText {nullptr};
|
||||
Aggplus::CMatrix m_oTransform;
|
||||
CManagers m_oManagers;
|
||||
|
||||
Aggplus::CMatrix* m_pTransform {nullptr};
|
||||
Aggplus::CGraphicsPathSimpleConverter* m_pSimpleGraphicsConverter{nullptr};
|
||||
CVectorGraphics m_oCurrVectorGraphics, m_oClipVectorGraphics;
|
||||
CContTextBuilder m_oContBuilder;
|
||||
|
||||
CImageManager* m_pImageManager {nullptr};
|
||||
CFontStyleManager* m_pFontStyleManager {nullptr};
|
||||
CParagraphStyleManager* m_pParagraphStyleManager{nullptr};
|
||||
CFontManager* m_pFontManager {nullptr};
|
||||
CFontSelector* m_pFontSelector {nullptr};
|
||||
|
||||
CVectorGraphics m_oCurrVectorGraphics;
|
||||
CVectorGraphics m_oClipVectorGraphics;
|
||||
|
||||
std::vector<std::shared_ptr<CContText>> m_arConts;
|
||||
std::vector<std::shared_ptr<CTextLine>> m_arTextLines;
|
||||
std::vector<std::shared_ptr<CContText>> m_arDiacriticalSymbols;
|
||||
std::vector<std::shared_ptr<CShape>> m_arShapes;
|
||||
std::vector<std::shared_ptr<CContText>> m_arConts;
|
||||
std::vector<std::shared_ptr<CTextLine>> m_arTextLines;
|
||||
std::vector<std::shared_ptr<CContText>> m_arDiacriticalSymbols;
|
||||
std::vector<std::shared_ptr<CShape>> m_arShapes;
|
||||
|
||||
std::vector<std::wstring> m_arCompleteObjectsXml;
|
||||
std::vector<std::shared_ptr<CBaseItem>> m_arOutputObjects;
|
||||
|
||||
bool m_bIsDeleteTextClipPage {true};
|
||||
bool m_bIsRecalcFontSize {true};
|
||||
bool m_bIsDeleteTextClipPage{true};
|
||||
bool m_bIsRecalcFontSize {true};
|
||||
bool m_bIsGradient {false};
|
||||
bool m_bUseDefaultFont {false};
|
||||
bool m_bWriteStyleRaw {false};
|
||||
|
||||
CPage();
|
||||
CPage(NSFonts::IApplicationFonts* pAppFonts, const CManagers& oManagers);
|
||||
~CPage();
|
||||
|
||||
void Init(
|
||||
NSStructures::CFont* pFont,
|
||||
NSStructures::CPen* pPen,
|
||||
NSStructures::CBrush* pBrush,
|
||||
NSStructures::CShadow* pShadow,
|
||||
NSStructures::CEdgeText* pEdge,
|
||||
Aggplus::CMatrix* pMatrix,
|
||||
Aggplus::CGraphicsPathSimpleConverter* pSimple,
|
||||
CImageManager* pImageManager,
|
||||
CFontStyleManager* pStyleManager,
|
||||
CFontManager *pFontManager,
|
||||
CFontSelector* pFontSelector,
|
||||
CParagraphStyleManager* pParagraphStyleManager);
|
||||
|
||||
void BeginCommand(DWORD lType);
|
||||
void EndCommand(DWORD lType);
|
||||
void Clear();
|
||||
|
||||
// удаляем то, что выходит за границы страницы
|
||||
void Clear();
|
||||
void DeleteTextClipPage();
|
||||
|
||||
// image commands
|
||||
void WriteImage(const std::shared_ptr<CImageInfo> pInfo, double& fX, double& fY, double& fWidth, double& fHeight);
|
||||
|
||||
// path commands
|
||||
void MoveTo(double& dX, double& dY);
|
||||
void LineTo(double& dX, double& dY);
|
||||
void CurveTo(double& x1, double& y1, double& x2, double& y2, double& x3, double& y3);
|
||||
void PathMoveTo(double& dX, double& dY);
|
||||
void PathLineTo(double& dX, double& dY);
|
||||
void PathCurveTo(double& dX1, double& dY1, double& dX2, double& dY2, double& dX3, double& dY3);
|
||||
void PathStart();
|
||||
void PathEnd();
|
||||
void PathClose();
|
||||
|
||||
//набивается содержимым вектор m_arShapes
|
||||
void DrawPath(LONG lType, const std::shared_ptr<CImageInfo> pInfo);
|
||||
|
||||
void CollectTextData(
|
||||
void AddText(
|
||||
const PUINT pUnicodes,
|
||||
const PUINT pGids,
|
||||
const UINT& nCount,
|
||||
@ -106,8 +94,6 @@ namespace NSDocxRenderer
|
||||
void ReorderShapesForPptx();
|
||||
|
||||
private:
|
||||
|
||||
// methods to build text lines
|
||||
void BuildDiacriticalSymbols();
|
||||
void BuildTextLines();
|
||||
void AnalyzeTextLines();
|
||||
@ -150,9 +136,6 @@ namespace NSDocxRenderer
|
||||
void ToXml(NSStringUtils::CStringBuilder& oWriter);
|
||||
void WriteSectionToFile(bool bLastPage, NSStringUtils::CStringBuilder& oWriter);
|
||||
|
||||
std::shared_ptr<CContText> m_pCurrCont {nullptr};
|
||||
NSStructures::CFont m_oPrevFont;
|
||||
NSStructures::CBrush m_oPrevBrush;
|
||||
size_t m_nShapeOrder = 0;
|
||||
};
|
||||
}
|
||||
|
||||
@ -850,4 +850,147 @@ namespace NSDocxRenderer
|
||||
{
|
||||
return m_dSpaceWidthMM;
|
||||
}
|
||||
|
||||
CContTextBuilder::CContTextBuilder(CFontStyleManager* pFontStyleManager, CFontSelector* pFontSelector) :
|
||||
m_pFontStyleManager(pFontStyleManager), m_pFontSelector(pFontSelector)
|
||||
{}
|
||||
|
||||
std::vector<CContTextBuilder::cont_ptr_t> CContTextBuilder::GetConts()
|
||||
{
|
||||
return std::move(m_arConts);
|
||||
}
|
||||
|
||||
void CContTextBuilder::AddUnicode(
|
||||
double dTop,
|
||||
double dBot,
|
||||
double dLeft,
|
||||
double dRight,
|
||||
const NSStructures::CFont& oFont,
|
||||
const NSStructures::CBrush& oBrush,
|
||||
CFontManager* pFontManager,
|
||||
const NSStringUtils::CStringUTF32& oText,
|
||||
bool bForcedBold,
|
||||
bool bUseDefaultFont,
|
||||
bool bWriteStyleRaw)
|
||||
{
|
||||
double dWidth = dRight - dLeft;
|
||||
double dHeight = dBot - dTop;
|
||||
|
||||
// if new text is close to current cont
|
||||
if (m_pCurrCont != nullptr &&
|
||||
fabs(m_pCurrCont->m_dBaselinePos - dBot) < c_dTHE_SAME_STRING_Y_PRECISION_MM &&
|
||||
m_oPrevFont.IsEqual2(&oFont) &&
|
||||
m_oPrevBrush.IsEqual(&oBrush))
|
||||
{
|
||||
|
||||
double avg_width = dWidth / oText.length();
|
||||
for (size_t i = 0; i < oText.length(); ++i)
|
||||
if (oText.at(i) == c_SPACE_SYM)
|
||||
m_pCurrCont->m_pFontStyle->UpdateAvgSpaceWidth(avg_width);
|
||||
|
||||
double avg_space_width = m_pCurrCont->m_pFontStyle->GetAvgSpaceWidth();
|
||||
double space_width =
|
||||
avg_space_width != 0.0 ?
|
||||
avg_space_width * c_dAVERAGE_SPACE_WIDTH_COEF :
|
||||
m_pCurrCont->CalculateSpace() * c_dSPACE_WIDTH_COEF;
|
||||
|
||||
bool is_added = false;
|
||||
|
||||
// some_text+more_text
|
||||
if (fabs(m_pCurrCont->m_dRight - dLeft) < space_width && dRight > m_pCurrCont->m_dRight)
|
||||
{
|
||||
double left_avg_width = (dRight - m_pCurrCont->m_dRight) / oText.length();
|
||||
std::vector<double> ar_widths;
|
||||
for (size_t i = 0; i < oText.length(); ++i)
|
||||
ar_widths.push_back(left_avg_width);
|
||||
|
||||
m_pCurrCont->AddTextBack(oText, ar_widths);
|
||||
is_added = true;
|
||||
|
||||
}
|
||||
// more_text+some_text
|
||||
else if (fabs(m_pCurrCont->m_dLeft - dRight) < space_width && dLeft < m_pCurrCont->m_dLeft)
|
||||
{
|
||||
double right_avg_width = (m_pCurrCont->m_dLeft - dLeft) / oText.length();
|
||||
std::vector<double> ar_widths;
|
||||
for (size_t i = 0; i < oText.length(); ++i)
|
||||
ar_widths.push_back(right_avg_width);
|
||||
|
||||
m_pCurrCont->AddTextFront(oText, ar_widths);
|
||||
is_added = true;
|
||||
}
|
||||
|
||||
if (is_added)
|
||||
{
|
||||
m_pCurrCont->m_dTop = std::min(m_pCurrCont->m_dTop, dTop);
|
||||
m_pCurrCont->m_dBaselinePos = std::max(m_pCurrCont->m_dBaselinePos, dBot);
|
||||
m_pCurrCont->m_dHeight = m_pCurrCont->m_dBaselinePos - m_pCurrCont->m_dTop;
|
||||
m_pCurrCont->m_dWidth = m_pCurrCont->m_dRight - m_pCurrCont->m_dLeft;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
auto pCont = std::make_shared<CContText>(pFontManager);
|
||||
const auto& oParams = pFontManager->GetFontSelectParams();
|
||||
const auto& oMetrics = pFontManager->GetFontMetrics();
|
||||
m_pFontSelector->SelectFont(oParams, oMetrics, oText);
|
||||
|
||||
pCont->m_dBaselinePos = dBot;
|
||||
pCont->m_dTop = dTop;
|
||||
pCont->m_dHeight = dHeight;
|
||||
pCont->m_dLeft = dLeft;
|
||||
|
||||
// первичное получение стиля для текущего символа
|
||||
// при дальнейшем анализе может измениться
|
||||
pCont->m_pFontStyle = m_pFontStyleManager->GetOrAddFontStyle(
|
||||
oBrush,
|
||||
m_pFontSelector->GetSelectedName(),
|
||||
oFont.Size,
|
||||
m_pFontSelector->IsSelectedItalic(),
|
||||
m_pFontSelector->IsSelectedBold() || bForcedBold);
|
||||
|
||||
// just in case if oText contains more than 1 symbol
|
||||
std::vector<double> ar_widths;
|
||||
double avg_width = abs(dRight - dLeft) / oText.length();
|
||||
for (size_t i = 0; i < oText.length(); ++i)
|
||||
{
|
||||
if (oText.at(i) == c_SPACE_SYM) pCont->m_pFontStyle->UpdateAvgSpaceWidth(avg_width);
|
||||
ar_widths.push_back(avg_width);
|
||||
}
|
||||
|
||||
pCont->SetText(oText, ar_widths);
|
||||
pCont->m_bIsRtl = CContText::IsUnicodeRtl(oText.at(0));
|
||||
|
||||
pCont->m_dWidth = dWidth;
|
||||
pCont->m_dRight = dRight;
|
||||
|
||||
double font_size = oFont.Size;
|
||||
double em_height = oMetrics.dEmHeight;
|
||||
double ratio = font_size / em_height * c_dPtToMM;
|
||||
|
||||
pCont->m_dTopWithAscent = pCont->m_dBaselinePos - (oMetrics.dAscent * ratio) - oMetrics.dBaselineOffset;
|
||||
pCont->m_dBotWithDescent = pCont->m_dBaselinePos + (oMetrics.dDescent * ratio) - oMetrics.dBaselineOffset;
|
||||
pCont->m_dSpaceWidthMM = pFontManager->GetSpaceWidthMM();
|
||||
|
||||
if (bUseDefaultFont)
|
||||
{
|
||||
pCont->m_oSelectedFont.Name = oFont.Name;
|
||||
pCont->m_oSelectedFont.Path = oFont.Path;
|
||||
pCont->m_oSelectedFont.Size = oFont.Size;
|
||||
pCont->m_oSelectedFont.FaceIndex = oFont.FaceIndex;
|
||||
}
|
||||
else
|
||||
{
|
||||
pCont->m_oSelectedFont.Name = m_pFontSelector->GetSelectedName();
|
||||
pCont->m_oSelectedFont.Size = oFont.Size;
|
||||
pCont->m_oSelectedFont.Bold = m_pFontSelector->IsSelectedBold();
|
||||
pCont->m_oSelectedFont.Italic = m_pFontSelector->IsSelectedItalic();
|
||||
}
|
||||
pCont->m_bWriteStyleRaw = bWriteStyleRaw;
|
||||
m_arConts.push_back(pCont);
|
||||
|
||||
m_pCurrCont = pCont;
|
||||
m_oPrevFont = oFont;
|
||||
m_oPrevBrush = oBrush;
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
|
||||
#include "BaseItem.h"
|
||||
#include "../managers/FontManager.h"
|
||||
#include "../managers//FontStyleManager.h"
|
||||
#include "../styles/FontStyle.h"
|
||||
#include "../../resources/Constants.h"
|
||||
#include "../../resources/LinesTable.h"
|
||||
@ -139,4 +140,39 @@ namespace NSDocxRenderer
|
||||
NSStringUtils::CStringUTF32 m_oText{};
|
||||
std::vector<double> m_arSymWidths{};
|
||||
};
|
||||
|
||||
class CContTextBuilder
|
||||
{
|
||||
protected:
|
||||
using cont_ptr_t = std::shared_ptr<CContText>;
|
||||
|
||||
public:
|
||||
CContTextBuilder() = delete;
|
||||
CContTextBuilder(CFontStyleManager* pFontStyleManager, CFontSelector* pFontSelector);
|
||||
~CContTextBuilder() = default;
|
||||
|
||||
// after call CContTextBuilder is empty.
|
||||
std::vector<cont_ptr_t> GetConts();
|
||||
void AddUnicode(
|
||||
double dTop,
|
||||
double dBot,
|
||||
double dLeft,
|
||||
double dRight,
|
||||
const NSStructures::CFont& oFont,
|
||||
const NSStructures::CBrush& oBrush,
|
||||
CFontManager* pFontManager,
|
||||
const NSStringUtils::CStringUTF32& oText,
|
||||
bool bForcedBold = false,
|
||||
bool bUseDefaultFont = false,
|
||||
bool bWriteStyleRaw = false);
|
||||
|
||||
private:
|
||||
std::vector<cont_ptr_t> m_arConts;
|
||||
cont_ptr_t m_pCurrCont {nullptr};
|
||||
NSStructures::CFont m_oPrevFont;
|
||||
NSStructures::CBrush m_oPrevBrush;
|
||||
|
||||
CFontStyleManager* m_pFontStyleManager {nullptr};
|
||||
CFontSelector* m_pFontSelector {nullptr};
|
||||
};
|
||||
}
|
||||
|
||||
@ -320,12 +320,12 @@ namespace NSDocxRenderer
|
||||
|
||||
void CFontSelector::SelectFont(const CFontSelectParams& oFontSelectParams,
|
||||
const CFontMetrics& oFontMetrics,
|
||||
NSStringUtils::CStringUTF32& oText)
|
||||
const NSStringUtils::CStringUTF32& oText)
|
||||
{
|
||||
BYTE lRangeNum = 0xFF;
|
||||
BYTE lRange = 0xFF;
|
||||
|
||||
m_oRanges.CheckRange(oText[0], lRange, lRangeNum);
|
||||
m_oRanges.CheckRange(oText.at(0), lRange, lRangeNum);
|
||||
|
||||
for(auto it = m_arParamsCache.begin(); it != m_arParamsCache.end(); it++)
|
||||
{
|
||||
|
||||
@ -81,7 +81,7 @@ namespace NSDocxRenderer
|
||||
|
||||
void SelectFont(const CFontSelectParams& oFontSelectParams,
|
||||
const CFontMetrics& oFontMetrics,
|
||||
NSStringUtils::CStringUTF32& oText);
|
||||
const NSStringUtils::CStringUTF32& oText);
|
||||
std::wstring GetSelectedName() const noexcept;
|
||||
bool IsSelectedBold() const noexcept;
|
||||
bool IsSelectedItalic() const noexcept;
|
||||
|
||||
Reference in New Issue
Block a user