Merge remote-tracking branch 'origin/feature/docxrenderer' into feature/docxrenderer2

This commit is contained in:
Oleg Korshul
2021-09-28 14:15:45 +03:00
28 changed files with 1863 additions and 3294 deletions

View File

@ -61,6 +61,9 @@ SOURCES += ./../DesktopEditor/common/StringBuilder.cpp
HEADERS += ./../DesktopEditor/common/StringExt.h
SOURCES += ./../DesktopEditor/common/StringExt.cpp
HEADERS += ./../DesktopEditor/common/StringUTF32.h
SOURCES += ./../DesktopEditor/common/StringUTF32.cpp
# BYTE BUILDER
HEADERS += ./../DesktopEditor/common/ByteBuilder.h
SOURCES += ./../DesktopEditor/common/ByteBuilder.cpp

View File

@ -829,6 +829,14 @@ namespace NSStringUtils
WriteHexByteNoSafe((value >> 8) & 0xFF);
WriteHexByteNoSafe(value & 0xFF);
}
void CStringBuilder::WriteHexInt4(const unsigned int& value)
{
AddSize(8);
WriteHexByteNoSafe((value >> 24) & 0xFF);
WriteHexByteNoSafe((value >> 16) & 0xFF);
WriteHexByteNoSafe((value >> 8) & 0xFF);
WriteHexByteNoSafe(value & 0xFF);
}
void CStringBuilder::WriteHexColor3(const unsigned char& r, const unsigned char& g, const unsigned char& b)
{
AddSize(7);

View File

@ -145,6 +145,7 @@ namespace NSStringUtils
void WriteHexByteNoSafe(const unsigned char& value);
void WriteHexByte(const unsigned char& value);
void WriteHexInt3(const unsigned int& value);
void WriteHexInt4(const unsigned int& value);
void WriteHexColor3(const unsigned char& r, const unsigned char& g, const unsigned char& b);
void WriteHexColor3(const unsigned int& value);

View File

@ -0,0 +1,154 @@
/*
* (c) Copyright Ascensio System SIA 2010-2019
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha
* street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "StringUTF32.h"
using namespace std;
using namespace NSStringUtils;
CStringUTF32::CStringUTF32() {}
CStringUTF32::CStringUTF32(const CStringUTF32 &other): m_vec(other.m_vec) {}
CStringUTF32::CStringUTF32(const wchar_t *other) { *this = other; }
CStringUTF32::CStringUTF32(const wstring &other) { *this = other; }
CStringUTF32::CStringUTF32(const vector<uint32_t> &other): m_vec(other) {}
CStringUTF32::CStringUTF32(const uint32_t* data, const size_t& len)
{
m_vec.reserve(len);
for (size_t i = 0; i < len; ++i)
this->m_vec.push_back(data[i]);
}
CStringUTF32::~CStringUTF32() {}
bool CStringUTF32::empty() const
{
return this->m_vec.empty();
}
size_t CStringUTF32::length() const
{
return this->m_vec.size();
}
wstring CStringUTF32::ToStdWString() const
{
if (0 == length())
return L"";
return NSStringExt::CConverter::GetUnicodeFromUTF32(&this->m_vec[0], static_cast<long>(this->length()));
}
bool CStringUTF32::operator == (const CStringUTF32 &right) const
{
return this->m_vec == right.m_vec;
}
bool CStringUTF32::operator != (const CStringUTF32 &right) const
{
return !(this->m_vec == right.m_vec);
}
uint32_t& CStringUTF32::operator [] (size_t index)
{
return this->m_vec[index];
}
CStringUTF32& CStringUTF32::operator = (const CStringUTF32 &right)
{
this->m_vec = right.m_vec;
return *this;
}
CStringUTF32& CStringUTF32::operator = (const wchar_t *right)
{
if (!right)
{
m_vec.clear();
return *this;
}
return (*this = std::wstring(right));
}
CStringUTF32& CStringUTF32::operator = (const wstring &right)
{
if (right.empty())
{
m_vec.clear();
return *this;
}
unsigned int utf32_len = 0;
unsigned int* utf32 = NSStringExt::CConverter::GetUtf32FromUnicode(right, utf32_len);
this->m_vec.clear();
this->m_vec.reserve(utf32_len);
for (size_t i = 0; i < utf32_len; ++i)
this->m_vec.push_back(utf32[i]);
delete [] utf32;
return *this;
}
CStringUTF32& CStringUTF32::operator = (const std::vector<uint32_t> &right)
{
this->m_vec = right;
return *this;
}
CStringUTF32 CStringUTF32::operator + (const CStringUTF32 &right) const
{
CStringUTF32 result;
result.m_vec.reserve(this->length() + right.length());
result.m_vec.insert(result.m_vec.end(), m_vec.begin(), m_vec.end());
result.m_vec.insert(result.m_vec.end(), right.m_vec.begin(), right.m_vec.end());
return result;
}
CStringUTF32& CStringUTF32::operator += (const CStringUTF32 &right)
{
m_vec.insert(m_vec.end(), right.m_vec.begin(), right.m_vec.end());
return *this;
}
CStringUTF32& CStringUTF32::operator += (const uint32_t& symbol)
{
m_vec.push_back(symbol);
return *this;
}
CStringUTF32 CStringUTF32::substr(size_t start, size_t count) const
{
CStringUTF32 result;
result.m_vec.reserve(count);
result.m_vec.insert(result.m_vec.end(), m_vec.begin() + start, m_vec.begin() + start + count);
return result;
}

View File

@ -0,0 +1,76 @@
#ifndef STRINGUTF32_HPP
#define STRINGUTF32_HPP
/*
* (c) Copyright Ascensio System SIA 2010-2019
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha
* street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include <string>
#include <vector>
#include <stdint.h>
#include "StringExt.h"
namespace NSStringUtils
{
class KERNEL_DECL CStringUTF32
{
std::vector<uint32_t> m_vec;
public:
CStringUTF32();
CStringUTF32(const CStringUTF32 &other);
CStringUTF32(const wchar_t *other);
CStringUTF32(const std::wstring &other);
CStringUTF32(const std::vector<uint32_t> &other);
CStringUTF32(const uint32_t* data, const size_t& count);
virtual ~CStringUTF32();
bool empty() const;
size_t length() const;
std::wstring ToStdWString() const;
bool operator == (const CStringUTF32 &right) const;
bool operator != (const CStringUTF32 &right) const;
uint32_t &operator [] (size_t index);
CStringUTF32 &operator = (const CStringUTF32 &right);
CStringUTF32 &operator = (const wchar_t *right);
CStringUTF32 &operator = (const std::wstring &right);
CStringUTF32 &operator = (const std::vector<uint32_t> &right);
CStringUTF32 operator + (const CStringUTF32 &right) const;
CStringUTF32 &operator += (const CStringUTF32 &right);
CStringUTF32 &operator += (const uint32_t& symbol);
CStringUTF32 substr(size_t start, size_t count) const;
};
}
#endif // STRINGUTF32_HPP

View File

@ -34,6 +34,15 @@
#include <string>
class IRenderer;
enum OfficeDrawingFileType
{
odftPDF = 0,
odftXPS = 1,
odftDJVU = 2,
odftUndefined = 255
};
class IOfficeDrawingFile
{
public:
@ -44,6 +53,8 @@ public:
virtual void Close() = 0;
virtual OfficeDrawingFileType GetType() = 0;
virtual std::wstring GetTempDirectory() = 0;
virtual void SetTempDirectory(const std::wstring& directory) = 0;

View File

@ -56,6 +56,11 @@ void CDjVuFile::Close()
m_pImplementation->Close();
}
OfficeDrawingFileType CDjVuFile::GetType()
{
return odftDJVU;
}
std::wstring CDjVuFile::GetTempDirectory()
{
return m_pImplementation ? m_pImplementation->GetTempDirectory() : L"";

View File

@ -59,6 +59,8 @@ public:
virtual void Close();
virtual OfficeDrawingFileType GetType();
virtual std::wstring GetTempDirectory();
virtual void SetTempDirectory(const std::wstring& directory);

View File

@ -30,22 +30,19 @@
*
*/
#include "DocxRenderer.h"
#include "src/logic/Document.h"
#include "../OfficeUtils/src/OfficeUtils.h"
class CDocxRenderer_Private
{
public:
NSDocxRenderer::CDocument m_oDocument;
CApplicationFonts* m_pApplicationFonts;
std::wstring m_strDstFilePath;
std::wstring m_strTempFileDir;
std::wstring m_strTempFileName;
std::wstring m_sTempDirectory;
public:
CDocxRenderer_Private(CApplicationFonts* pFonts)
CDocxRenderer_Private(NSFonts::IApplicationFonts* pFonts, IRenderer* pRenderer) : m_oDocument(pRenderer, pFonts)
{
m_pApplicationFonts = pFonts;
}
~CDocxRenderer_Private()
{
@ -53,9 +50,9 @@ public:
}
};
CDocxRenderer::CDocxRenderer(CApplicationFonts* pAppFonts)
CDocxRenderer::CDocxRenderer(NSFonts::IApplicationFonts* pAppFonts)
{
m_pInternal = new CDocxRenderer_Private(pAppFonts);
m_pInternal = new CDocxRenderer_Private(pAppFonts, this);
}
CDocxRenderer::~CDocxRenderer()
@ -63,439 +60,489 @@ CDocxRenderer::~CDocxRenderer()
RELEASEOBJECT(m_pInternal);
}
void CDocxRenderer::CreateFile(const std::wstring& wsPath)
HRESULT CDocxRenderer::CreateNewFile(const std::wstring& wsPath)
{
m_pInternal->m_oDocument.m_strDstFilePath = wsPath;
m_pInternal->m_oDocument.m_strTempDirectory = NSDirectory::CreateDirectoryWithUniqueName(m_pInternal->m_sTempDirectory.empty() ?
NSDirectory::CreateDirectoryWithUniqueName(NSDirectory::GetTempPath()) :
NSDirectory::CreateDirectoryWithUniqueName(m_pInternal->m_sTempDirectory));
m_pInternal->m_oDocument.CreateDocument();
return S_OK;
}
void CDocxRenderer::Close()
HRESULT CDocxRenderer::Close()
{
m_pInternal->m_oDocument.Close();
COfficeUtils oCOfficeUtils(NULL);
HRESULT hr = oCOfficeUtils.CompressFileOrDirectory(m_pInternal->m_oDocument.m_strTempDirectory, m_pInternal->m_oDocument.m_strDstFilePath, true);
NSDirectory::DeleteDirectory(m_pInternal->m_oDocument.m_strTempDirectory);
m_pInternal->m_oDocument.m_strTempDirectory = L"";
return S_OK;
}
void CDocxRenderer::SetTextAssociationType(const NSDocxRenderer::TextAssociationType& eType)
HRESULT CDocxRenderer::SetTextAssociationType(const NSDocxRenderer::TextAssociationType& eType)
{
m_pInternal->m_oDocument.m_oCurrentPage.m_eTextAssociationType = eType;
return S_OK;
}
void CDocxRenderer::SetTempFolder(const std::wstring& wsPath)
int CDocxRenderer::Convert(IOfficeDrawingFile* pFile, const std::wstring& sDstFile)
{
CreateNewFile(sDstFile);
if (odftPDF == pFile->GetType())
m_pInternal->m_oDocument.m_bIsNeedPDFTextAnalyzer = true;
int nPagesCount = pFile->GetPagesCount();
for (int i = 0; i < nPagesCount; ++i)
{
NewPage();
BeginCommand(c_nPageType);
m_pInternal->m_oDocument.m_bIsDisablePageCommand = true;
double dPageDpiX, dPageDpiY;
double dWidth, dHeight;
pFile->GetPageInfo(i, &dWidth, &dHeight, &dPageDpiX, &dPageDpiY);
dWidth *= 25.4 / dPageDpiX;
dHeight *= 25.4 / dPageDpiY;
put_Width(dWidth);
put_Height(dHeight);
pFile->DrawPageOnRenderer(this, i, NULL);
m_pInternal->m_oDocument.m_bIsDisablePageCommand = false;
EndCommand(c_nPageType);
}
HRESULT hr = Close();
return (hr == S_OK) ? 0 : 1;
}
HRESULT CDocxRenderer::SetTempFolder(const std::wstring& wsPath)
{
m_pInternal->m_sTempDirectory = wsPath;
return S_OK;
}
//----------------------------------------------------------------------------------------
// Тип рендерера
//----------------------------------------------------------------------------------------
virtual HRESULT CDocxRenderer::get_Type(LONG* lType)
HRESULT CDocxRenderer::get_Type(LONG* lType)
{
*lType = c_nDocxWriter;
return S_OK;
}
//----------------------------------------------------------------------------------------
// Функции для работы со страницей
//----------------------------------------------------------------------------------------
virtual HRESULT CDocxRenderer::NewPage()
HRESULT CDocxRenderer::NewPage()
{
return S_OK;
return m_pInternal->m_oDocument.NewPage();
}
virtual HRESULT CDocxRenderer::get_Height(double* dHeight)
HRESULT CDocxRenderer::get_Height(double* dHeight)
{
return S_OK;
return m_pInternal->m_oDocument.get_Height(dHeight);
}
virtual HRESULT CDocxRenderer::put_Height(const double& dHeight)
HRESULT CDocxRenderer::put_Height(const double& dHeight)
{
return S_OK;
return m_pInternal->m_oDocument.put_Height(dHeight);
}
virtual HRESULT CDocxRenderer::get_Width(double* dWidth)
HRESULT CDocxRenderer::get_Width(double* dWidth)
{
return S_OK;
return m_pInternal->m_oDocument.get_Width(dWidth);
}
virtual HRESULT CDocxRenderer::put_Width(const double& dWidth)
HRESULT CDocxRenderer::put_Width(const double& dWidth)
{
return S_OK;
return m_pInternal->m_oDocument.put_Width(dWidth);
}
virtual HRESULT CDocxRenderer::get_DpiX(double* dDpiX)
HRESULT CDocxRenderer::get_DpiX(double* dDpiX)
{
return S_OK;
return m_pInternal->m_oDocument.get_DpiX(dDpiX);
}
virtual HRESULT CDocxRenderer::get_DpiY(double* dDpiY)
HRESULT CDocxRenderer::get_DpiY(double* dDpiY)
{
return S_OK;
return m_pInternal->m_oDocument.get_DpiY(dDpiY);
}
//----------------------------------------------------------------------------------------
// Функции для работы с Pen
//----------------------------------------------------------------------------------------
virtual HRESULT CDocxRenderer::get_PenColor(LONG* lColor)
HRESULT CDocxRenderer::get_PenColor(LONG* lColor)
{
return S_OK;
return m_pInternal->m_oDocument.get_PenColor(lColor);
}
virtual HRESULT CDocxRenderer::put_PenColor(const LONG& lColor)
HRESULT CDocxRenderer::put_PenColor(const LONG& lColor)
{
return S_OK;
return m_pInternal->m_oDocument.put_PenColor(lColor);
}
virtual HRESULT CDocxRenderer::get_PenAlpha(LONG* lAlpha)
HRESULT CDocxRenderer::get_PenAlpha(LONG* lAlpha)
{
return S_OK;
return m_pInternal->m_oDocument.get_PenAlpha(lAlpha);
}
virtual HRESULT CDocxRenderer::put_PenAlpha(const LONG& lAlpha)
HRESULT CDocxRenderer::put_PenAlpha(const LONG& lAlpha)
{
return S_OK;
return m_pInternal->m_oDocument.put_PenAlpha(lAlpha);
}
virtual HRESULT CDocxRenderer::get_PenSize(double* dSize)
HRESULT CDocxRenderer::get_PenSize(double* dSize)
{
return S_OK;
return m_pInternal->m_oDocument.get_PenSize(dSize);
}
virtual HRESULT CDocxRenderer::put_PenSize(const double& dSize)
HRESULT CDocxRenderer::put_PenSize(const double& dSize)
{
return S_OK;
return m_pInternal->m_oDocument.put_PenSize(dSize);
}
virtual HRESULT CDocxRenderer::get_PenDashStyle(BYTE* nDashStyle)
HRESULT CDocxRenderer::get_PenDashStyle(BYTE* nDashStyle)
{
return S_OK;
return m_pInternal->m_oDocument.get_PenDashStyle(nDashStyle);
}
virtual HRESULT CDocxRenderer::put_PenDashStyle(const BYTE& nDashStyle)
HRESULT CDocxRenderer::put_PenDashStyle(const BYTE& nDashStyle)
{
return S_OK;
return m_pInternal->m_oDocument.put_PenDashStyle(nDashStyle);
}
virtual HRESULT CDocxRenderer::get_PenLineStartCap(BYTE* nCapStyle)
HRESULT CDocxRenderer::get_PenLineStartCap(BYTE* nCapStyle)
{
return S_OK;
return m_pInternal->m_oDocument.get_PenLineStartCap(nCapStyle);
}
virtual HRESULT CDocxRenderer::put_PenLineStartCap(const BYTE& nCapStyle)
HRESULT CDocxRenderer::put_PenLineStartCap(const BYTE& nCapStyle)
{
return S_OK;
return m_pInternal->m_oDocument.put_PenLineStartCap(nCapStyle);
}
virtual HRESULT CDocxRenderer::get_PenLineEndCap(BYTE* nCapStyle)
HRESULT CDocxRenderer::get_PenLineEndCap(BYTE* nCapStyle)
{
return S_OK;
return m_pInternal->m_oDocument.get_PenLineEndCap(nCapStyle);
}
virtual HRESULT CDocxRenderer::put_PenLineEndCap(const BYTE& nCapStyle)
HRESULT CDocxRenderer::put_PenLineEndCap(const BYTE& nCapStyle)
{
return S_OK;
return m_pInternal->m_oDocument.put_PenLineEndCap(nCapStyle);
}
virtual HRESULT CDocxRenderer::get_PenLineJoin(BYTE* nJoinStyle)
HRESULT CDocxRenderer::get_PenLineJoin(BYTE* nJoinStyle)
{
return S_OK;
return m_pInternal->m_oDocument.get_PenLineJoin(nJoinStyle);
}
virtual HRESULT CDocxRenderer::put_PenLineJoin(const BYTE& nJoinStyle)
HRESULT CDocxRenderer::put_PenLineJoin(const BYTE& nJoinStyle)
{
return S_OK;
return m_pInternal->m_oDocument.put_PenLineJoin(nJoinStyle);
}
virtual HRESULT CDocxRenderer::get_PenDashOffset(double* dOffset)
HRESULT CDocxRenderer::get_PenDashOffset(double* dOffset)
{
return S_OK;
return m_pInternal->m_oDocument.get_PenDashOffset(dOffset);
}
virtual HRESULT CDocxRenderer::put_PenDashOffset(const double& dOffset)
HRESULT CDocxRenderer::put_PenDashOffset(const double& dOffset)
{
return S_OK;
return m_pInternal->m_oDocument.put_PenDashOffset(dOffset);
}
virtual HRESULT CDocxRenderer::get_PenAlign(LONG* lAlign)
HRESULT CDocxRenderer::get_PenAlign(LONG* lAlign)
{
return S_OK;
return m_pInternal->m_oDocument.get_PenAlign(lAlign);
}
virtual HRESULT CDocxRenderer::put_PenAlign(const LONG& lAlign)
HRESULT CDocxRenderer::put_PenAlign(const LONG& lAlign)
{
return S_OK;
return m_pInternal->m_oDocument.put_PenAlign(lAlign);
}
virtual HRESULT CDocxRenderer::get_PenMiterLimit(double* dMiter)
HRESULT CDocxRenderer::get_PenMiterLimit(double* dMiter)
{
return S_OK;
return m_pInternal->m_oDocument.get_PenMiterLimit(dMiter);
}
virtual HRESULT CDocxRenderer::put_PenMiterLimit(const double& dMiter)
HRESULT CDocxRenderer::put_PenMiterLimit(const double& dMiter)
{
return S_OK;
return m_pInternal->m_oDocument.put_PenMiterLimit(dMiter);
}
virtual HRESULT CDocxRenderer::PenDashPattern(double* pPattern, LONG lCount)
HRESULT CDocxRenderer::PenDashPattern(double* pPattern, LONG lCount)
{
return S_OK;
return m_pInternal->m_oDocument.PenDashPattern(pPattern, lCount);
}
//----------------------------------------------------------------------------------------
// Функции для работы с Brush
//----------------------------------------------------------------------------------------
virtual HRESULT CDocxRenderer::get_BrushType(LONG* lType)
HRESULT CDocxRenderer::get_BrushType(LONG* lType)
{
return m_pInternal->m_oDocument.get_BrushType(lType);
}
HRESULT CDocxRenderer::put_BrushType(const LONG& lType)
{
return m_pInternal->m_oDocument.put_BrushType(lType);
}
HRESULT CDocxRenderer::get_BrushColor1(LONG* lColor)
{
return m_pInternal->m_oDocument.get_BrushColor1(lColor);
}
HRESULT CDocxRenderer::put_BrushColor1(const LONG& lColor)
{
return m_pInternal->m_oDocument.put_BrushColor1(lColor);
}
HRESULT CDocxRenderer::get_BrushAlpha1(LONG* lAlpha)
{
return m_pInternal->m_oDocument.get_BrushAlpha1(lAlpha);
}
HRESULT CDocxRenderer::put_BrushAlpha1(const LONG& lAlpha)
{
return m_pInternal->m_oDocument.put_BrushAlpha1(lAlpha);
}
HRESULT CDocxRenderer::get_BrushColor2(LONG* lColor)
{
return m_pInternal->m_oDocument.get_BrushColor2(lColor);
}
HRESULT CDocxRenderer::put_BrushColor2(const LONG& lColor)
{
return m_pInternal->m_oDocument.put_BrushColor2(lColor);
}
HRESULT CDocxRenderer::get_BrushAlpha2(LONG* lAlpha)
{
return m_pInternal->m_oDocument.get_BrushAlpha2(lAlpha);
}
HRESULT CDocxRenderer::put_BrushAlpha2(const LONG& lAlpha)
{
return m_pInternal->m_oDocument.put_BrushAlpha2(lAlpha);
}
HRESULT CDocxRenderer::get_BrushTexturePath(std::wstring* wsPath)
{
return m_pInternal->m_oDocument.get_BrushTexturePath(wsPath);
}
HRESULT CDocxRenderer::put_BrushTexturePath(const std::wstring& wsPath)
{
return m_pInternal->m_oDocument.put_BrushTexturePath(wsPath);
}
HRESULT CDocxRenderer::get_BrushTextureMode(LONG* lMode)
{
return m_pInternal->m_oDocument.get_BrushTextureMode(lMode);
}
HRESULT CDocxRenderer::put_BrushTextureMode(const LONG& lMode)
{
return m_pInternal->m_oDocument.put_BrushTextureMode(lMode);
}
HRESULT CDocxRenderer::get_BrushTextureAlpha(LONG* lAlpha)
{
return m_pInternal->m_oDocument.get_BrushTextureAlpha(lAlpha);
}
HRESULT CDocxRenderer::put_BrushTextureAlpha(const LONG& lAlpha)
{
return m_pInternal->m_oDocument.put_BrushTextureAlpha(lAlpha);
}
HRESULT CDocxRenderer::get_BrushLinearAngle(double* dAngle)
{
return m_pInternal->m_oDocument.get_BrushLinearAngle(dAngle);
}
HRESULT CDocxRenderer::put_BrushLinearAngle(const double& dAngle)
{
return m_pInternal->m_oDocument.put_BrushLinearAngle(dAngle);
}
HRESULT CDocxRenderer::BrushRect(const INT& nVal, const double& dLeft, const double& dTop, const double& dWidth, const double& dHeight)
{
return m_pInternal->m_oDocument.BrushRect(nVal, dLeft, dTop, dWidth, dHeight);
}
HRESULT CDocxRenderer::BrushBounds(const double& dLeft, const double& dTop, const double& dWidth, const double& dHeight)
{
// TODO:
return S_OK;
}
virtual HRESULT CDocxRenderer::put_BrushType(const LONG& lType)
{
return S_OK;
}
virtual HRESULT CDocxRenderer::get_BrushColor1(LONG* lColor)
{
return S_OK;
}
virtual HRESULT CDocxRenderer::put_BrushColor1(const LONG& lColor)
{
return S_OK;
}
virtual HRESULT CDocxRenderer::get_BrushAlpha1(LONG* lAlpha)
{
return S_OK;
}
virtual HRESULT CDocxRenderer::put_BrushAlpha1(const LONG& lAlpha)
{
return S_OK;
}
virtual HRESULT CDocxRenderer::get_BrushColor2(LONG* lColor)
{
return S_OK;
}
virtual HRESULT CDocxRenderer::put_BrushColor2(const LONG& lColor)
{
return S_OK;
}
virtual HRESULT CDocxRenderer::get_BrushAlpha2(LONG* lAlpha)
{
return S_OK;
}
virtual HRESULT CDocxRenderer::put_BrushAlpha2(const LONG& lAlpha)
{
return S_OK;
}
virtual HRESULT CDocxRenderer::get_BrushTexturePath(std::wstring* wsPath)
{
return S_OK;
}
virtual HRESULT CDocxRenderer::put_BrushTexturePath(const std::wstring& wsPath)
{
return S_OK;
}
virtual HRESULT CDocxRenderer::get_BrushTextureMode(LONG* lMode)
{
return S_OK;
}
virtual HRESULT CDocxRenderer::put_BrushTextureMode(const LONG& lMode)
{
return S_OK;
}
virtual HRESULT CDocxRenderer::get_BrushTextureAlpha(LONG* lAlpha)
{
return S_OK;
}
virtual HRESULT CDocxRenderer::put_BrushTextureAlpha(const LONG& lAlpha)
{
return S_OK;
}
virtual HRESULT CDocxRenderer::get_BrushLinearAngle(double* dAngle)
{
return S_OK;
}
virtual HRESULT CDocxRenderer::put_BrushLinearAngle(const double& dAngle)
{
return S_OK;
}
virtual HRESULT CDocxRenderer::BrushRect(const INT& nVal, const double& dLeft, const double& dTop, const double& dWidth, const double& dHeight)
{
return S_OK;
}
virtual HRESULT CDocxRenderer::BrushBounds(const double& dLeft, const double& dTop, const double& dWidth, const double& dHeight)
{
return S_OK;
}
virtual HRESULT CDocxRenderer::put_BrushGradientColors(LONG* pColors, double* pPositions, LONG lCount)
HRESULT CDocxRenderer::put_BrushGradientColors(LONG* pColors, double* pPositions, LONG lCount)
{
// TODO:
return S_OK;
}
//----------------------------------------------------------------------------------------
// Функции для работы со шрифтами
//----------------------------------------------------------------------------------------
virtual HRESULT CDocxRenderer::get_FontName(std::wstring* wsName)
HRESULT CDocxRenderer::get_FontName(std::wstring* wsName)
{
return S_OK;
return m_pInternal->m_oDocument.get_FontName(wsName);
}
virtual HRESULT CDocxRenderer::put_FontName(const std::wstring& wsName)
HRESULT CDocxRenderer::put_FontName(const std::wstring& wsName)
{
return S_OK;
return m_pInternal->m_oDocument.put_FontName(wsName);
}
virtual HRESULT CDocxRenderer::get_FontPath(std::wstring* wsPath)
HRESULT CDocxRenderer::get_FontPath(std::wstring* wsPath)
{
return S_OK;
return m_pInternal->m_oDocument.get_FontPath(wsPath);
}
virtual HRESULT CDocxRenderer::put_FontPath(const std::wstring& wsPath)
HRESULT CDocxRenderer::put_FontPath(const std::wstring& wsPath)
{
return S_OK;
return m_pInternal->m_oDocument.put_FontPath(wsPath);
}
virtual HRESULT CDocxRenderer::get_FontSize(double* dSize)
HRESULT CDocxRenderer::get_FontSize(double* dSize)
{
return S_OK;
return m_pInternal->m_oDocument.get_FontSize(dSize);
}
virtual HRESULT CDocxRenderer::put_FontSize(const double& dSize)
HRESULT CDocxRenderer::put_FontSize(const double& dSize)
{
return S_OK;
return m_pInternal->m_oDocument.put_FontSize(dSize);
}
virtual HRESULT CDocxRenderer::get_FontStyle(LONG* lStyle)
HRESULT CDocxRenderer::get_FontStyle(LONG* lStyle)
{
return S_OK;
return m_pInternal->m_oDocument.get_FontStyle(lStyle);
}
virtual HRESULT CDocxRenderer::put_FontStyle(const LONG& lStyle)
HRESULT CDocxRenderer::put_FontStyle(const LONG& lStyle)
{
return S_OK;
return m_pInternal->m_oDocument.put_FontStyle(lStyle);
}
virtual HRESULT CDocxRenderer::get_FontStringGID(INT* bGid)
HRESULT CDocxRenderer::get_FontStringGID(INT* bGid)
{
return S_OK;
return m_pInternal->m_oDocument.get_FontStringGID(bGid);
}
virtual HRESULT CDocxRenderer::put_FontStringGID(const INT& bGid)
HRESULT CDocxRenderer::put_FontStringGID(const INT& bGid)
{
return S_OK;
return m_pInternal->m_oDocument.put_FontStringGID(bGid);
}
virtual HRESULT CDocxRenderer::get_FontCharSpace(double* dSpace)
HRESULT CDocxRenderer::get_FontCharSpace(double* dSpace)
{
return S_OK;
return m_pInternal->m_oDocument.get_FontCharSpace(dSpace);
}
virtual HRESULT CDocxRenderer::put_FontCharSpace(const double& dSpace)
HRESULT CDocxRenderer::put_FontCharSpace(const double& dSpace)
{
return S_OK;
return m_pInternal->m_oDocument.put_FontCharSpace(dSpace);
}
virtual HRESULT CDocxRenderer::get_FontFaceIndex(int* lFaceIndex)
HRESULT CDocxRenderer::get_FontFaceIndex(int* lFaceIndex)
{
return S_OK;
return m_pInternal->m_oDocument.get_FontFaceIndex(lFaceIndex);
}
virtual HRESULT CDocxRenderer::put_FontFaceIndex(const int& lFaceIndex)
HRESULT CDocxRenderer::put_FontFaceIndex(const int& lFaceIndex)
{
return S_OK;
return m_pInternal->m_oDocument.put_FontFaceIndex(lFaceIndex);
}
//----------------------------------------------------------------------------------------
// Функции для вывода текста
//----------------------------------------------------------------------------------------
virtual HRESULT CDocxRenderer::CommandDrawTextCHAR (const LONG& lUnicode, const double& dX, const double& dY, const double& dW, const double& dH)
HRESULT CDocxRenderer::CommandDrawTextCHAR(const LONG& lUnicode, const double& dX, const double& dY, const double& dW, const double& dH)
{
return S_OK;
return m_pInternal->m_oDocument.CommandDrawTextCHAR((int)lUnicode, dX, dY, dW, dH);
}
virtual HRESULT CDocxRenderer::CommandDrawTextExCHAR(const LONG& lUnicode, const LONG& lGid, const double& dX, const double& dY, const double& dW, const double& dH)
HRESULT CDocxRenderer::CommandDrawTextExCHAR(const LONG& lUnicode, const LONG& lGid, const double& dX, const double& dY, const double& dW, const double& dH)
{
return S_OK;
return m_pInternal->m_oDocument.CommandDrawTextExCHAR((int)lUnicode, (int)lGid, dX, dY, dW, dH);
}
virtual HRESULT CDocxRenderer::CommandDrawText (const std::wstring& wsUnicodeText, const double& dX, const double& dY, const double& dW, const double& dH)
HRESULT CDocxRenderer::CommandDrawText(const std::wstring& wsUnicodeText, const double& dX, const double& dY, const double& dW, const double& dH)
{
return S_OK;
return m_pInternal->m_oDocument.CommandDrawText(wsUnicodeText, dX, dY, dW, dH);
}
virtual HRESULT CDocxRenderer::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 CDocxRenderer::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)
{
return S_OK;
return m_pInternal->m_oDocument.CommandDrawTextEx(wsUnicodeText, pGids, nGidsCount, dX, dY, dW, dH);
}
//----------------------------------------------------------------------------------------
// Маркеры команд
//----------------------------------------------------------------------------------------
virtual HRESULT CDocxRenderer::BeginCommand(const DWORD& lType)
HRESULT CDocxRenderer::BeginCommand(const DWORD& lType)
{
return S_OK;
return m_pInternal->m_oDocument.BeginCommand(lType);
}
virtual HRESULT CDocxRenderer::EndCommand(const DWORD& lType)
HRESULT CDocxRenderer::EndCommand(const DWORD& lType)
{
return S_OK;
return m_pInternal->m_oDocument.EndCommand(lType);
}
//----------------------------------------------------------------------------------------
// Функции для работы с патом
//----------------------------------------------------------------------------------------
virtual HRESULT CDocxRenderer::PathCommandMoveTo(const double& dX, const double& dY)
HRESULT CDocxRenderer::PathCommandMoveTo(const double& dX, const double& dY)
{
return S_OK;
return m_pInternal->m_oDocument.PathCommandMoveTo(dX, dY);
}
virtual HRESULT CDocxRenderer::PathCommandLineTo(const double& dX, const double& dY)
HRESULT CDocxRenderer::PathCommandLineTo(const double& dX, const double& dY)
{
return S_OK;
return m_pInternal->m_oDocument.PathCommandLineTo(dX, dY);
}
virtual HRESULT CDocxRenderer::PathCommandLinesTo(double* pPoints, const int& nCount)
HRESULT CDocxRenderer::PathCommandLinesTo(double* pPoints, const int& nCount)
{
return S_OK;
return m_pInternal->m_oDocument.PathCommandLinesTo(pPoints, nCount);
}
virtual HRESULT CDocxRenderer::PathCommandCurveTo(const double& dX1, const double& dY1, const double& dX2, const double& dY2, const double& dXe, const double& dYe)
HRESULT CDocxRenderer::PathCommandCurveTo(const double& dX1, const double& dY1, const double& dX2, const double& dY2, const double& dXe, const double& dYe)
{
return S_OK;
return m_pInternal->m_oDocument.PathCommandCurveTo(dX1, dY1, dX2, dY2, dXe, dYe);
}
virtual HRESULT CDocxRenderer::PathCommandCurvesTo(double* pPoints, const int& nCount)
HRESULT CDocxRenderer::PathCommandCurvesTo(double* pPoints, const int& nCount)
{
return S_OK;
return m_pInternal->m_oDocument.PathCommandCurvesTo(pPoints, nCount);
}
virtual HRESULT CDocxRenderer::PathCommandArcTo(const double& dX, const double& dY, const double& dW, const double& dH, const double& dStartAngle, const double& dSweepAngle)
HRESULT CDocxRenderer::PathCommandArcTo(const double& dX, const double& dY, const double& dW, const double& dH, const double& dStartAngle, const double& dSweepAngle)
{
return S_OK;
return m_pInternal->m_oDocument.PathCommandArcTo(dX, dY, dW, dH, dStartAngle, dSweepAngle);
}
virtual HRESULT CDocxRenderer::PathCommandClose()
HRESULT CDocxRenderer::PathCommandClose()
{
return S_OK;
return m_pInternal->m_oDocument.PathCommandClose();
}
virtual HRESULT CDocxRenderer::PathCommandEnd()
HRESULT CDocxRenderer::PathCommandEnd()
{
return S_OK;
return m_pInternal->m_oDocument.PathCommandEnd();
}
virtual HRESULT CDocxRenderer::DrawPath(const LONG& lType)
HRESULT CDocxRenderer::DrawPath(const LONG& lType)
{
return S_OK;
return m_pInternal->m_oDocument.DrawPath(lType);
}
virtual HRESULT CDocxRenderer::PathCommandStart()
HRESULT CDocxRenderer::PathCommandStart()
{
return S_OK;
return m_pInternal->m_oDocument.PathCommandStart();
}
virtual HRESULT CDocxRenderer::PathCommandGetCurrentPoint(double* dX, double* dY)
HRESULT CDocxRenderer::PathCommandGetCurrentPoint(double* dX, double* dY)
{
return S_OK;
return m_pInternal->m_oDocument.PathCommandGetCurrentPoint(dX, dY);
}
virtual HRESULT CDocxRenderer::PathCommandTextCHAR (const LONG& lUnicode, const double& dX, const double& dY, const double& dW, const double& dH)
HRESULT CDocxRenderer::PathCommandTextCHAR(const LONG& lUnicode, const double& dX, const double& dY, const double& dW, const double& dH)
{
return S_OK;
return m_pInternal->m_oDocument.PathCommandTextCHAR((int)lUnicode, dX, dY, dW, dH);
}
virtual HRESULT CDocxRenderer::PathCommandTextExCHAR(const LONG& lUnicode, const LONG& lGid, const double& dX, const double& dY, const double& dW, const double& dH)
HRESULT CDocxRenderer::PathCommandTextExCHAR(const LONG& lUnicode, const LONG& lGid, const double& dX, const double& dY, const double& dW, const double& dH)
{
return S_OK;
return m_pInternal->m_oDocument.PathCommandTextExCHAR((int)lUnicode, (int)lGid, dX, dY, dW, dH);
}
virtual HRESULT CDocxRenderer::PathCommandText (const std::wstring& wsUnicodeText, const double& dX, const double& dY, const double& dW, const double& dH)
HRESULT CDocxRenderer::PathCommandText(const std::wstring& wsUnicodeText, const double& dX, const double& dY, const double& dW, const double& dH)
{
return S_OK;
return m_pInternal->m_oDocument.PathCommandText(wsUnicodeText, dX, dY, dW, dH);
}
virtual HRESULT CDocxRenderer::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)
HRESULT CDocxRenderer::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)
{
return S_OK;
return m_pInternal->m_oDocument.PathCommandTextEx(wsUnicodeText, pGids, nGidsCount, dX, dY, dW, dH);
}
//----------------------------------------------------------------------------------------
// Функции для вывода изображений
//----------------------------------------------------------------------------------------
virtual HRESULT CDocxRenderer::DrawImage(IGrObject* pImage, const double& dX, const double& dY, const double& dW, const double& dH)
HRESULT CDocxRenderer::DrawImage(IGrObject* pImage, const double& dX, const double& dY, const double& dW, const double& dH)
{
return S_OK;
return m_pInternal->m_oDocument.DrawImage(pImage, dX, dY, dW, dH);
}
virtual HRESULT CDocxRenderer::DrawImageFromFile(const std::wstring& wsImagePath, const double& dX, const double& dY, const double& dW, const double& dH, const BYTE& nAlpha = 255)
HRESULT CDocxRenderer::DrawImageFromFile(const std::wstring& wsImagePath, const double& dX, const double& dY, const double& dW, const double& dH, const BYTE& nAlpha)
{
return S_OK;
return m_pInternal->m_oDocument.DrawImageFromFile(wsImagePath,dX, dY, dW, dH);
}
//----------------------------------------------------------------------------------------
// Функции для выставления преобразования
//----------------------------------------------------------------------------------------
virtual HRESULT CDocxRenderer::SetTransform(const double& dM11, const double& dM12, const double& dM21, const double& dM22, const double& dX, const double& dY)
HRESULT CDocxRenderer::SetTransform(const double& dM11, const double& dM12, const double& dM21, const double& dM22, const double& dX, const double& dY)
{
return S_OK;
return m_pInternal->m_oDocument.SetTransform(dM11, dM12, dM21, dM22, dX, dY);
}
virtual HRESULT CDocxRenderer::GetTransform(double* dM11, double* dM12, double* dM21, double* dM22, double* dX, double* dY)
HRESULT CDocxRenderer::GetTransform(double* dM11, double* dM12, double* dM21, double* dM22, double* dX, double* dY)
{
return S_OK;
return m_pInternal->m_oDocument.GetTransform(dM11, dM12, dM21, dM22, dX, dY);
}
virtual HRESULT CDocxRenderer::ResetTransform()
HRESULT CDocxRenderer::ResetTransform()
{
return S_OK;
return m_pInternal->m_oDocument.ResetTransform();
}
//----------------------------------------------------------------------------------------
// Тип клипа
//----------------------------------------------------------------------------------------
virtual HRESULT CDocxRenderer::get_ClipMode(LONG* lMode)
HRESULT CDocxRenderer::get_ClipMode(LONG* lMode)
{
return S_OK;
return m_pInternal->m_oDocument.get_ClipMode(lMode);
}
virtual HRESULT CDocxRenderer::put_ClipMode(const LONG& lMode)
HRESULT CDocxRenderer::put_ClipMode(const LONG& lMode)
{
return S_OK;
return m_pInternal->m_oDocument.put_ClipMode(lMode);
}
//----------------------------------------------------------------------------------------
// Дополнительные функции
//----------------------------------------------------------------------------------------
virtual HRESULT CDocxRenderer::CommandLong(const LONG& lType, const LONG& lCommand)
HRESULT CDocxRenderer::CommandLong(const LONG& lType, const LONG& lCommand)
{
return S_OK;
}
virtual HRESULT CDocxRenderer::CommandDouble(const LONG& lType, const double& dCommand)
HRESULT CDocxRenderer::CommandDouble(const LONG& lType, const double& dCommand)
{
return S_OK;
}
virtual HRESULT CDocxRenderer::CommandString(const LONG& lType, const std::wstring& sCommand)
HRESULT CDocxRenderer::CommandString(const LONG& lType, const std::wstring& sCommand)
{
return S_OK;
}

View File

@ -29,10 +29,12 @@
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#ifndef _PDF_WRITER_PDFRENDERER_H
#define _PDF_WRITER_PDFRENDERER_H
#ifndef _DOCX_RENDERER_H
#define _DOCX_RENDERER_H
#include "../DesktopEditor/graphics/IRenderer.h"
#include "../DesktopEditor/common/officedrawingfile.h"
#include "../DesktopEditor/graphics/pro/Fonts.h"
#include <string>
#include <vector>
#include <algorithm>
@ -44,9 +46,6 @@
#define DOCXRENDERER_DECL_EXPORT Q_DECL_EXPORT
#endif
class CFontManager;
class CApplicationFonts;
namespace NSDocxRenderer
{
enum TextAssociationType
@ -58,18 +57,17 @@ namespace NSDocxRenderer
};
}
class CDocxRenderer_Private;
class DOCXRENDERER_DECL_EXPORT CDocxRenderer : public IRenderer
{
public:
CDocxRenderer(CApplicationFonts* pAppFonts);
CDocxRenderer(NSFonts::IApplicationFonts* pAppFonts);
~CDocxRenderer();
void CreateFile(const std::wstring& wsPath);
void Close();
HRESULT CreateNewFile(const std::wstring& wsPath);
HRESULT Close();
void SetTextAssociationType(const NSDocxRenderer::TextAssociationType& eType);
void SetTempFolder(const std::wstring& wsPath);
HRESULT SetTempFolder(const std::wstring& wsPath);
//----------------------------------------------------------------------------------------
// Тип рендерера
//----------------------------------------------------------------------------------------
@ -202,8 +200,12 @@ public:
virtual HRESULT CommandDouble(const LONG& lType, const double& dCommand);
virtual HRESULT CommandString(const LONG& lType, const std::wstring& sCommand);
// методы, которыми будет пользоваться конвертер
HRESULT SetTextAssociationType(const NSDocxRenderer::TextAssociationType& eType);
int Convert(IOfficeDrawingFile* pFile, const std::wstring& sDstFile);
private:
CDocxRenderer_Private* m_pInternal;
};
#endif // _PDF_WRITER_PDFRENDERER_H
#endif // _DOCX_RENDERER_H

View File

@ -15,15 +15,7 @@ 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
ADD_DEPENDENCY(UnicodeConverter, kernel, graphics)
core_windows {
@ -34,20 +26,20 @@ LIBS += -lgdi32 \
}
HEADERS += \
src/resources/resources.h
HEADERS += \
src/resources/resources.h \
\
src/logic/Common.h \
src/logic/Page.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 += \
src/resources/resources.cpp \
\
DocxRenderer.cpp

View File

@ -2,13 +2,16 @@
#define DOCX_RENDERER_COMMON_H
#include "../DesktopEditor/common/StringBuilder.h"
#include "../DesktopEditor/common/StringUTF32.h"
#include "../DesktopEditor/common/CalculatorCRC32.h"
#include "../DesktopEditor/graphics/Matrix.h"
#include "../DesktopEditor/graphics/structures.h"
#include "../DesktopEditor/graphics/TemporaryCS.h"
#include "../DesktopEditor/raster/BgraFrame.h"
#include "../DesktopEditor/common/Directory.h"
#include "../DesktopEditor/xml/include/xmlutils.h"
#include "../DesktopEditor/graphics/pro/Graphics.h"
#include <algorithm>
#include <map>
namespace NSDocxRenderer
@ -34,6 +37,7 @@ namespace NSDocxRenderer
{
m_eType = etShape;
}
virtual ~CBaseItem() {}
virtual void ToXml(NSStringUtils::CStringBuilder& oWriter) = 0;
};
@ -91,7 +95,7 @@ namespace NSDocxRenderer
}
public:
CImageInfo WriteImage(CBgraFrame* pImage, double& x, double& y, double& width, double& height)
CImageInfo WriteImage(Aggplus::CImage* pImage, double& x, double& y, double& width, double& height)
{
if (height < 0)
{
@ -102,7 +106,7 @@ namespace NSDocxRenderer
return GenerateImageID(pImage);
}
CImageInfo WriteImage(std::wstring& strFile, double& x, double& y, double& width, double& height)
CImageInfo WriteImage(const std::wstring& strFile, double& x, double& y, double& width, double& height)
{
return GenerateImageID(strFile);
}
@ -112,19 +116,19 @@ namespace NSDocxRenderer
{
NSFile::CFileBinary::Copy(strFileSrc, strFileDst);
}
void SaveImage(std::wstring& strFileSrc, CImageInfo& oInfo)
void SaveImage(const std::wstring& strFileSrc, CImageInfo& oInfo)
{
CBgraFrame oFrame;
if (oFrame.OpenFile(strFileSrc))
Aggplus::CImage oFrame(strFileSrc);
if (NULL != oFrame.GetData())
return SaveImage(&oFrame, oInfo);
}
void SaveImage(CBgraFrame* pImage, CImageInfo& oInfo)
void SaveImage(Aggplus::CImage* pImage, CImageInfo& oInfo)
{
if (NULL == pImage)
return;
int w = pImage->get_Width();
int h = pImage->get_Height();
int w = pImage->GetWidth();
int h = pImage->GetHeight();
oInfo.m_eType = GetImageType(pImage);
@ -158,10 +162,10 @@ namespace NSDocxRenderer
}
}
CImageInfo GenerateImageID(CBgraFrame* pImage)
CImageInfo GenerateImageID(Aggplus::CImage* pImage)
{
BYTE* pData = pImage->get_Data();
int nSize = pImage->get_Stride() * pImage->get_Height();
BYTE* pData = pImage->GetData();
int nSize = pImage->GetStride() * pImage->GetHeight();
if (nSize < 0)
nSize = -nSize;
@ -169,40 +173,40 @@ namespace NSDocxRenderer
std::map<DWORD, CImageInfo>::iterator find = m_mapImageData.find(dwSum);
if (find != m_mapImageData.end())
return *find;
return find->second;
++m_lNextIDImage;
CImageInfo oInfo;
oInfo.m_lID = m_lNextIDImage;
oInfo.m_nId = m_lNextIDImage;
SaveImage(pImage, oInfo);
m_mapImageData.insert(std::pair<std::DWORD, CImageInfo>(dwSum, oInfo);
m_mapImageData.insert(std::pair<DWORD, CImageInfo>(dwSum, oInfo));
return oInfo;
}
CImageInfo GenerateImageID(std::wstring& strFileName)
CImageInfo GenerateImageID(const std::wstring& strFileName)
{
std::map<std::wstring, CImageInfo>::iterator find = m_mapImagesFile.find(strFileName);
if (find != m_mapImagesFile.end())
return *find;
return find->second;
++m_lNextIDImage;
CImageInfo oInfo;
oInfo.m_lID = m_lNextIDImage;
oInfo.m_nId = m_lNextIDImage;
SaveImage(strFileName, oInfo);
m_mapImagesFile.insert(std::pair<std::wstring, CImageInfo>(strFileName, oInfo);
m_mapImagesFile.insert(std::pair<std::wstring, CImageInfo>(strFileName, oInfo));
return oInfo;
}
CImageInfo::ImageType GetImageType(CBgraFrame* pFrame)
CImageInfo::ImageType GetImageType(Aggplus::CImage* pFrame)
{
int w = pFrame->get_Width();
int h = pFrame->get_Height();
BYTE* pBuffer = pFrame->get_Data();
int w = pFrame->GetWidth();
int h = pFrame->GetHeight();
BYTE* pBuffer = pFrame->GetData();
BYTE* pBufferMem = pBuffer + 3;
LONG lCountPix = lWidth * lHeight;
LONG lCountPix = w * h;
for (LONG i = 0; i < lCountPix; ++i, pBufferMem += 4)
{
@ -212,15 +216,15 @@ namespace NSDocxRenderer
return CImageInfo::itJPG;
}
void FlipY(CBgraFrame* pImage)
void FlipY(Aggplus::CImage* pImage)
{
if (NULL == pImage)
return;
int w = pImage->get_Width();
int h = pImage->get_Height();
BYTE* pBuffer = pImage->get_Data();
int stride = pImage->get_Stride();
int w = pImage->GetWidth();
int h = pImage->GetHeight();
BYTE* pBuffer = pImage->GetData();
int stride = pImage->GetStride();
if (stride < 0)
stride = -stride;
@ -269,7 +273,7 @@ namespace NSDocxRenderer
for (LONG lIndexV = 0; lIndexV < h; ++lIndexV)
{
DWORD* pMem1 = pBufferDWORD;
DWORD* pMem2 = pBufferDWORD + lWidth - 1;
DWORD* pMem2 = pBufferDWORD + w - 1;
LONG lI = 0;
while (lI < lW2)

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,5 @@
#pragma once
#include "Common.h"
#include "FontManager.h"
namespace NSDocxRenderer
@ -11,7 +10,7 @@ namespace NSDocxRenderer
template<typename T>
void SortElements(std::vector<T*>& oArray)
{
int nSize = (int)oArray.GetCount();
int nSize = (int)oArray.size();
// handle 0, 1 and 2 elements
if (nSize <= 1)
@ -86,49 +85,25 @@ namespace NSDocxRenderer
}
}
static _bstr_t g_bstr_text_run_Start = L"<w:r><w:rPr>";
static _bstr_t g_bstr_text_run_PropEnd = L"</w:rPr>";
static _bstr_t g_bstr_text_run_End = L"</w:r>";
static _bstr_t g_bstr_text_run_text1 = L"<w:t xml:space=\"preserve\">";
static _bstr_t g_bstr_text_run_text2 = L"</w:t>";
static _bstr_t g_bstr_text_bold_true = L"<w:b w:val=\"true\"/>";
static _bstr_t g_bstr_text_italic_true = L"<w:i w:val=\"true\"/>";
static CString g_string_text_font_size = _T("<w:sz w:val=\"%d\"/><w:szCs w:val=\"%d\"/>");
static CString g_string_text_font_name = _T("<w:rFonts w:ascii=\"%s\" w:hAnsi=\"%s\" w:cs=\"%s\"/>");
static CString g_string_text_color = _T("<w:color w:val=\"%06x\"/>");
static CString g_string_text_paragraph_noframes = _T("<w:pPr><w:spacing w:before=\"%d\" w:line=\"%d\" w:lineRule=\"exact\"/><w:ind w:left=\"%d\"/></w:pPr>");
static _bstr_t g_bstr_text_par_start = L"<w:p>";
static _bstr_t g_bstr_text_par_end = L"</w:p>";
static CString g_string_spacing_character = _T("<w:spacing w:val=\"%d\"/>");
static CString g_string_spacing_character2 = _T("<w:spacing w:val=\"%.3lfpt\"/>");
static CString g_string_par_props_mode2 = _T("<w:pPr><w:framePr w:hAnchor=\"page\" w:vAnchor=\"page\" w:x=\"%d\" w:y=\"%d\"/></w:pPr>");
inline void DeleteSpaces(CString& strText)
inline void DeleteSpaces(NSStringUtils::CStringUTF32& oText)
{
int nLen = strText.GetLength();
int nStart = 0;
size_t nLen = oText.length();
size_t nStart = 0;
while ((nStart < nLen) && (TCHAR(' ') == strText[nStart]))
while ((nStart < nLen) && (' ' == oText[nStart]))
++nStart;
if (nStart == nLen)
{
strText = _T("");
oText = L"";
return;
}
int nEnd = nLen - 1;
while ((nEnd > nStart) && (TCHAR(' ') == strText[nEnd]))
size_t nEnd = nLen - 1;
while ((nEnd > nStart) && (' ' == oText[nEnd]))
--nEnd;
strText = strText.Mid(nStart, nEnd - nStart + 1);
oText = oText.substr(nStart, nEnd - nStart + 1);
}
class CContText
@ -137,11 +112,11 @@ namespace NSDocxRenderer
NSStructures::CFont m_oFont;
NSStructures::CBrush m_oBrush;
CString m_strPickFontName;
std::wstring m_strPickFontName;
LONG m_lPickFontStyle;
CString m_strText;
CString m_strGidText;
NSStringUtils::CStringUTF32 m_oText;
NSStringUtils::CStringUTF32 m_oGidText;
double m_dX;
double m_dY;
@ -159,10 +134,7 @@ namespace NSDocxRenderer
public:
CContText()
{
m_strText = _T("");
m_strGidText = _T("");
m_strPickFontName = _T("");
m_strPickFontName = L"";
m_lPickFontStyle = 0;
m_dX = 0;
@ -182,7 +154,7 @@ namespace NSDocxRenderer
{
}
AVSINLINE void Clear()
inline void Clear()
{
}
@ -195,8 +167,8 @@ namespace NSDocxRenderer
m_oFont = oSrc.m_oFont;
m_oBrush = oSrc.m_oBrush;
m_strText = oSrc.m_strText;
m_strGidText = oSrc.m_strGidText;
m_oText = oSrc.m_oText;
m_oGidText = oSrc.m_oGidText;
m_strPickFontName = oSrc.m_strPickFontName;
m_lPickFontStyle = oSrc.m_lPickFontStyle;
@ -217,159 +189,157 @@ namespace NSDocxRenderer
return *this;
}
AVSINLINE bool IsBigger(const CContText* oSrc)
inline bool IsBigger(const CContText* oSrc)
{
return (m_dX > oSrc->m_dX) ? true : false;
}
AVSINLINE bool IsBiggerOrEqual(const CContText* oSrc)
inline bool IsBiggerOrEqual(const CContText* oSrc)
{
return (m_dX >= oSrc->m_dX) ? true : false;
}
AVSINLINE void Write(NSDocxRenderer::CStringWriter& oWriter, CFontManagerLight* pManagerLight, bool bIsAddSpace = false)
inline void Write(NSStringUtils::CStringBuilder& oWriter, CFontManagerLight* pManagerLight, bool bIsAddSpace = false)
{
oWriter.WriteString(g_bstr_text_run_Start);
oWriter.WriteString(L"<w:r><w:rPr>");
if (m_dWidth != m_dWidthWithoutSpaces)
{
DeleteSpaces(m_strText);
DeleteSpaces(m_oText);
m_dWidth = m_dWidthWithoutSpaces;
}
if (_T("") == m_strPickFontName)
if (m_strPickFontName.empty())
{
if (m_oFont.Bold)
oWriter.WriteString(g_bstr_text_bold_true);
oWriter.WriteString(L"<w:b w:val=\"true\"/>");
if (m_oFont.Italic)
oWriter.WriteString(g_bstr_text_italic_true);
oWriter.WriteString(L"<w:i w:val=\"true\"/>");
if (bIsAddSpace)
{
m_dWidth += m_dSpaceWidthMM;
m_strText += _T(" ");
m_oText += L" ";
}
}
else
{
if (0x01 == (0x01 & m_lPickFontStyle))
oWriter.WriteString(g_bstr_text_bold_true);
oWriter.WriteString(L"<w:b w:val=\"true\"/>");
if (0x02 == (0x02 & m_lPickFontStyle))
oWriter.WriteString(g_bstr_text_italic_true);
oWriter.WriteString(L"<w:i w:val=\"true\"/>");
if (bIsAddSpace)
{
m_dWidth += pManagerLight->GetSpaceWidth();
m_strText += _T(" ");
m_oText += L" ";
}
// нужно перемерять...
double ___dSize = (double)((LONG)(m_oFont.Size * 2)) / 2;
pManagerLight->LoadFont(m_strPickFontName, m_lPickFontStyle, ___dSize, FALSE);
double dWidth = pManagerLight->MeasureStringWidth(m_strText);
double dWidth = pManagerLight->MeasureStringWidth(m_oText.ToStdWString());
if (fabs(dWidth - m_dWidth) > 2)
{
double dSpacing = (m_dWidth - dWidth) / (m_strText.GetLength() + 1);
double dSpacing = (m_dWidth - dWidth) / (m_oText.length() + 1);
dSpacing *= c_dMMToDx;
CString strSpacing = _T("");
strSpacing.Format(g_string_spacing_character, (LONG)dSpacing);
oWriter.WriteString(strSpacing);
oWriter.WriteString(L"<w:spacing w:val=\"");
oWriter.AddInt((int)dSpacing);
oWriter.WriteString(L"\"/>");
}
}
CString strSize = _T("");
LONG lSize = (LONG)(2 * m_oFont.Size);
strSize.Format(g_string_text_font_size, lSize, lSize);
oWriter.WriteString(strSize);
int lSize = (int)(2 * m_oFont.Size);
oWriter.WriteString(L"<w:sz w:val=\"");
oWriter.AddInt(lSize);
oWriter.WriteString(L"\"/><w:szCs w:val=\"");
oWriter.AddInt(lSize);
oWriter.WriteString(L"\"/>");
CString strName = _T("");
std::wstring& strFontName = m_strPickFontName.empty() ? m_oFont.Name : m_strPickFontName;
oWriter.WriteString(L"<w:rFonts w:ascii=\"");
oWriter.WriteEncodeXmlString(strFontName);
oWriter.WriteString(L"\" w:hAnsi=\"");
oWriter.WriteEncodeXmlString(strFontName);
oWriter.WriteString(L"\" w:cs=\"");
oWriter.WriteEncodeXmlString(strFontName);
oWriter.WriteString(L"\"/>");
if (_T("") == m_strPickFontName)
strName.Format(g_string_text_font_name, m_oFont.Name, m_oFont.Name, m_oFont.Name);
else
strName.Format(g_string_text_font_name, m_strPickFontName, m_strPickFontName, m_strPickFontName);
oWriter.WriteString(L"<w:color w:val=\"");
oWriter.WriteHexInt3(ConvertColor(m_oBrush.Color1));
oWriter.WriteString(L"\"/>");
oWriter.WriteString(strName);
oWriter.WriteString(L"</w:rPr>");
CString strColor = _T("");
strColor.Format(g_string_text_color, ConvertColor(m_oBrush.Color1));
oWriter.WriteString(strColor);
oWriter.WriteString(L"<w:t xml:space=\"preserve\">");
oWriter.WriteEncodeXmlString(m_oText.ToStdWString());
oWriter.WriteString(L"</w:t>");
oWriter.WriteString(g_bstr_text_run_PropEnd);
oWriter.WriteString(g_bstr_text_run_text1);
CString strText = m_strText;
CorrectString(strText);
oWriter.WriteString(strText);
oWriter.WriteString(g_bstr_text_run_text2);
oWriter.WriteString(g_bstr_text_run_End);
oWriter.WriteString(L"</w:r>");
}
AVSINLINE void WriteTo(double dSpacingMM, NSDocxRenderer::CStringWriter& oWriter, CFontManagerLight* pManagerLight)
void WriteTo(double dSpacingMM, NSStringUtils::CStringBuilder& oWriter, CFontManagerLight* pManagerLight)
{
oWriter.WriteString(g_bstr_text_run_Start);
oWriter.WriteString(L"<w:r><w:rPr>");
double dSpaceMMSize = m_dSpaceWidthMM;
if (_T("") == m_strPickFontName)
if (m_strPickFontName.empty())
{
if (m_oFont.Bold)
oWriter.WriteString(g_bstr_text_bold_true);
oWriter.WriteString(L"<w:b w:val=\"true\"/>");
if (m_oFont.Italic)
oWriter.WriteString(g_bstr_text_italic_true);
oWriter.WriteString(L"<w:i w:val=\"true\"/>");
}
else
{
if (0x01 == (0x01 & m_lPickFontStyle))
oWriter.WriteString(g_bstr_text_bold_true);
oWriter.WriteString(L"<w:b w:val=\"true\"/>");
if (0x02 == (0x02 & m_lPickFontStyle))
oWriter.WriteString(g_bstr_text_italic_true);
oWriter.WriteString(L"<w:i w:val=\"true\"/>");
dSpaceMMSize = pManagerLight->GetSpaceWidth();
}
CString strSize = _T("");
LONG lSize = (LONG)(2 * m_oFont.Size);
strSize.Format(g_string_text_font_size, lSize, lSize);
oWriter.WriteString(strSize);
int lSize = (int)(2 * m_oFont.Size);
oWriter.WriteString(L"<w:sz w:val=\"");
oWriter.AddInt(lSize);
oWriter.WriteString(L"\"/><w:szCs w:val=\"");
oWriter.AddInt(lSize);
oWriter.WriteString(L"\"/>");
CString strName = _T("");
std::wstring& strFontName = m_strPickFontName.empty() ? m_oFont.Name : m_strPickFontName;
oWriter.WriteString(L"<w:rFonts w:ascii=\"");
oWriter.WriteEncodeXmlString(strFontName);
oWriter.WriteString(L"\" w:hAnsi=\"");
oWriter.WriteEncodeXmlString(strFontName);
oWriter.WriteString(L"\" w:cs=\"");
oWriter.WriteEncodeXmlString(strFontName);
oWriter.WriteString(L"\"/>");
if (_T("") == m_strPickFontName)
strName.Format(g_string_text_font_name, m_oFont.Name, m_oFont.Name, m_oFont.Name);
else
strName.Format(g_string_text_font_name, m_strPickFontName, m_strPickFontName, m_strPickFontName);
oWriter.WriteString(strName);
CString strColor = _T("");
strColor.Format(g_string_text_color, ConvertColor(m_oBrush.Color1));
oWriter.WriteString(strColor);
oWriter.WriteString(L"<w:color w:val=\"");
oWriter.WriteHexInt3(ConvertColor(m_oBrush.Color1));
oWriter.WriteString(L"\"/>");
LONG lSpacing = (LONG)((dSpacingMM - dSpaceMMSize) * c_dMMToDx);
CString strSpacing = _T("");
strSpacing.Format(g_string_spacing_character, lSpacing);
oWriter.WriteString(strSpacing);
oWriter.WriteString(L"<w:spacing w:val=\"");
oWriter.AddInt((int)lSpacing);
oWriter.WriteString(L"\"/>");
oWriter.WriteString(g_bstr_text_run_PropEnd);
oWriter.WriteString(L"</w:rPr>");
oWriter.WriteString(g_bstr_text_run_text1);
oWriter.WriteString(L"<w:t xml:space=\"preserve\">");
oWriter.WriteString(L" ");
oWriter.WriteString(L"</w:t>");
CString strText = _T(" ");
oWriter.WriteString(strText);
oWriter.WriteString(g_bstr_text_run_text2);
oWriter.WriteString(g_bstr_text_run_End);
oWriter.WriteString(L"</w:r>");
}
};
class CTextLine
{
public:
CAtlArray<CContText*> m_arConts;
std::vector<CContText*> m_arConts;
double m_dBaselinePos;
double m_dBaselineOffset;
@ -389,15 +359,14 @@ namespace NSDocxRenderer
m_dWidth = 0;
m_dHeight = 0;
}
AVSINLINE void Clear()
void Clear()
{
size_t nCount = m_arConts.GetCount();
for (size_t i = 0; i < nCount; ++i)
{
CContText* pText = m_arConts[i];
RELEASEOBJECT(pText);
}
m_arConts.RemoveAll();
for (std::vector<CContText*>::iterator iter = m_arConts.begin(); iter != m_arConts.end(); iter++)
{
CContText* pText = *iter;
RELEASEOBJECT(pText);
}
m_arConts.clear();
}
~CTextLine()
@ -412,10 +381,9 @@ namespace NSDocxRenderer
CTextLine& operator=(const CTextLine& oSrc)
{
Clear();
size_t nCount = oSrc.m_arConts.GetCount();
for (size_t i = 0; i < nCount; ++i)
for (std::vector<CContText*>::const_iterator iter = oSrc.m_arConts.begin(); iter != oSrc.m_arConts.end(); iter++)
{
m_arConts.Add(new CContText(*oSrc.m_arConts[i]));
m_arConts.push_back(new CContText(*(*iter)));
}
m_dBaselinePos = oSrc.m_dBaselinePos;
@ -425,9 +393,9 @@ namespace NSDocxRenderer
m_dHeight = oSrc.m_dHeight;
}
AVSINLINE void AddCont(CContText* pCont, double dBaselineOffset)
inline void AddCont(CContText* pCont, double dBaselineOffset)
{
if (0 == m_arConts.GetCount())
if (0 == m_arConts.size())
m_dBaselineOffset = dBaselineOffset;
if ( ( pCont->m_dX > 0 ) && ( ( m_dX == 0 ) || ( pCont->m_dX < m_dX ) ) )
@ -436,19 +404,19 @@ namespace NSDocxRenderer
if (m_dHeight < pCont->m_dHeight)
m_dHeight = pCont->m_dHeight;
m_arConts.Add(pCont);
m_arConts.push_back(pCont);
}
AVSINLINE bool IsBigger(const CTextLine* oSrc)
inline bool IsBigger(const CTextLine* oSrc)
{
return (m_dBaselinePos > oSrc->m_dBaselinePos) ? true : false;
}
AVSINLINE bool IsBiggerOrEqual(const CTextLine* oSrc)
inline bool IsBiggerOrEqual(const CTextLine* oSrc)
{
return (m_dBaselinePos >= oSrc->m_dBaselinePos) ? true : false;
}
AVSINLINE void SortConts()
inline void SortConts()
{
// сортировка непрерывных слов по m_dX
SortElements(m_arConts);
@ -456,7 +424,7 @@ namespace NSDocxRenderer
void Merge(CTextLine* pTextLine)
{
size_t nCount = pTextLine->m_arConts.GetCount();
size_t nCount = pTextLine->m_arConts.size();
if (0 != nCount)
{
if (pTextLine->m_dX < m_dX)
@ -477,14 +445,14 @@ namespace NSDocxRenderer
for (size_t i = 0; i < nCount; ++i)
{
pTextLine->m_arConts[i]->m_dPosition = dSubPosition;
m_arConts.Add(pTextLine->m_arConts[i]);
m_arConts.push_back(pTextLine->m_arConts[i]);
}
}
}
void ToXml(NSDocxRenderer::CStringWriter& oWriter, CFontManagerLight* pManagerLight)
void ToXml(NSStringUtils::CStringBuilder& oWriter, CFontManagerLight* pManagerLight)
{
size_t nCountConts = m_arConts.GetCount();
size_t nCountConts = m_arConts.size();
if (0 == nCountConts)
return;
@ -543,7 +511,7 @@ namespace NSDocxRenderer
double m_dSpaceBefore;
TextAssociationType m_eTextAssociationType;
CAtlArray<CTextLine*> m_arLines;
std::vector<CTextLine*> m_arLines;
public:
CParagraph(const TextAssociationType& eType) : m_arLines()
@ -571,15 +539,15 @@ namespace NSDocxRenderer
Clear();
}
AVSINLINE void Clear()
void Clear()
{
size_t nCount = m_arLines.GetCount();
size_t nCount = m_arLines.size();
for (size_t i = 0; i < nCount; ++i)
{
CTextLine* pText = m_arLines[i];
RELEASEOBJECT(pText);
}
m_arLines.RemoveAll();
m_arLines.clear();
m_pManagerLight = NULL;
}
@ -600,10 +568,10 @@ namespace NSDocxRenderer
m_eTextAssociationType = oSrc.m_eTextAssociationType;
Clear();
size_t nCount = oSrc.m_arLines.GetCount();
size_t nCount = oSrc.m_arLines.size();
for (size_t i = 0; i < nCount; ++i)
{
m_arLines.Add(new CTextLine(*oSrc.m_arLines[i]));
m_arLines.push_back(new CTextLine(*oSrc.m_arLines[i]));
}
m_pManagerLight = oSrc.m_pManagerLight;
@ -611,50 +579,46 @@ namespace NSDocxRenderer
return *this;
}
virtual void ToXml(NSDocxRenderer::CStringWriter& oWriter)
virtual void ToXml(NSStringUtils::CStringBuilder& oWriter)
{
oWriter.WriteString(g_bstr_text_par_start);
oWriter.WriteString(L"<w:p>");
switch (m_eTextAssociationType)
{
case TextAssociationTypeDefault:
case TextAssociationTypeLine:
{
LONG lX = (LONG)(m_dLeft * c_dMMToDx);
LONG lY = (LONG)(m_dTop * c_dMMToDx);
CString strTextProps = _T("");
strTextProps.Format(g_string_par_props_mode2, lX, lY);
oWriter.WriteString(strTextProps);
oWriter.WriteString(L"<w:pPr><w:framePr w:hAnchor=\"page\" w:vAnchor=\"page\" w:x=\"");
oWriter.AddInt((int)(m_dLeft * c_dMMToDx));
oWriter.WriteString(L"\" w:y=\"");
oWriter.AddInt((int)(m_dTop * c_dMMToDx));
oWriter.WriteString(L"\"/></w:pPr>");
break;
}
case TextAssociationTypeBlock:
{
LONG lX = (LONG)(m_dLeft * c_dMMToDx);
LONG lY = (LONG)(m_dTop * c_dMMToDx);
CString strTextProps = _T("");
strTextProps.Format(g_string_par_props_mode2, lX, lY);
oWriter.WriteString(strTextProps);
break;
oWriter.WriteString(L"<w:pPr><w:framePr w:hAnchor=\"page\" w:vAnchor=\"page\" w:x=\"");
oWriter.AddInt((int)(m_dLeft * c_dMMToDx));
oWriter.WriteString(L"\" w:y=\"");
oWriter.AddInt((int)(m_dTop * c_dMMToDx));
oWriter.WriteString(L"\"/></w:pPr>");
}
case TextAssociationTypeNoFrames:
{
LONG lSpaceBefore = (LONG)(m_dSpaceBefore * c_dMMToDx);
LONG lHeight = (LONG)(m_dHeight * c_dMMToDx);
LONG lLeft = (LONG)(m_dLeft * c_dMMToDx);
CString strParProperties = _T("");
strParProperties.Format(g_string_text_paragraph_noframes, lSpaceBefore, lHeight, lLeft);
oWriter.WriteString(strParProperties);
oWriter.WriteString(L"<w:pPr><w:spacing w:before=\"");
oWriter.AddInt((int)(m_dSpaceBefore * c_dMMToDx));
oWriter.WriteString(L"\" w:line=\"");
oWriter.AddInt((int)(m_dHeight * c_dMMToDx));
oWriter.WriteString(L"\" w:lineRule=\"exact\"/><w:ind w:left=\"");
oWriter.AddInt((int)(m_dLeft * c_dMMToDx));
oWriter.WriteString(L"\"/></w:pPr>");
break;
}
default:
break;
}
size_t nCount = m_arLines.GetCount();
size_t nCount = m_arLines.size();
for (size_t i = 0; i < nCount; ++i)
{
CTextLine* pTextLine = m_arLines[i];
@ -662,7 +626,7 @@ namespace NSDocxRenderer
pTextLine->ToXml(oWriter, m_pManagerLight);
}
oWriter.WriteString(g_bstr_text_par_end);
oWriter.WriteString(L"</w:p>");
}
};
}

View File

@ -40,7 +40,7 @@ namespace NSDocxRenderer
{
if (NULL == m_pData)
{
m_lSize = max(nSize, 500);
m_lSize = std::max(nSize, (size_t)500);
m_pData = (double*)malloc(m_lSize * sizeof(double));
m_lSizeCur = 0;
@ -347,16 +347,16 @@ namespace NSDocxRenderer
oWriter.AddInt((int)m_lCoordSizeY);
oWriter.WriteString(L"\" path=\"");
oWriter.WriteString(m_strPath);
oWriter.WriteString(L"\" fillcolor=\"");
oWriter.WriteString(L"\" fillcolor=\"#");
oWriter.WriteHexInt3((int)ConvertColor(m_oBrush.Color1));
oWriter.WriteString(L"\" strokecolor=\"");
oWriter.WriteString(L"\" strokecolor=\"#");
oWriter.WriteHexInt3((int)ConvertColor(m_oPen.Color));
oWriter.WriteString(L"\" strokeweight=\"");
oWriter.AddDouble(m_oPen.Size, 2);
oWriter.WriteString(L"mm\">");
static CString g_string_fill_opacity = _T("<v:fill opacity=\"%.2lf\"/>");
static CString g_string_stroke_opacity = _T("<v:stroke opacity=\"%.2lf\"/>");
std::wstring g_string_fill_opacity = L"<v:fill opacity=\"%.2lf\"/>";
std::wstring g_string_stroke_opacity = L"<v:stroke opacity=\"%.2lf\"/>";
if (c_BrushTypeTexture == m_oBrush.Type)
{

View File

@ -1,6 +1,7 @@
#pragma once
#include "Common.h"
#include "FontManagerBase.h"
#include "../../DocxRenderer.h"
namespace NSDocxRenderer
{
@ -9,28 +10,20 @@ namespace NSDocxRenderer
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;
std::wstring m_strFamilyName;
std::wstring m_strPANOSE;
LONG m_lStyle;
std::vector<UINT> m_arSignature;
bool m_bIsFixedWidth;
public:
CFontTableEntry() : m_arSignature()
{
m_strFamilyName = _T("");
m_strPANOSE = _T("");
m_strFamilyName = L"";
m_strPANOSE = L"";
m_lStyle = 0;
m_bIsFixedWidth = false;
}
@ -46,7 +39,7 @@ namespace NSDocxRenderer
m_strFamilyName = oSrc.m_strFamilyName;
m_strPANOSE = oSrc.m_strPANOSE;
m_lStyle = oSrc.m_lStyle;
m_arSignature.Copy(oSrc.m_arSignature);
m_arSignature = oSrc.m_arSignature;
m_bIsFixedWidth = oSrc.m_bIsFixedWidth;
return *this;
@ -56,7 +49,7 @@ namespace NSDocxRenderer
class CFontTable
{
public:
CAtlMap<CString, CFontTableEntry> m_mapTable;
std::map<std::wstring, CFontTableEntry> m_mapTable;
public:
CFontTable() : m_mapTable()
@ -67,18 +60,17 @@ namespace NSDocxRenderer
class CFontManager : public CFontManagerBase
{
public:
NSStructures::CFont* m_pFont;
NSDocxRenderer::CMatrix* m_pTransform;
double m_dSpaceWidthMM;
NSStructures::CFont* m_pFont;
Aggplus::CMatrix* m_pTransform;
double m_dSpaceWidthMM;
public:
CFontTable m_oFontTable;
CFontTable m_oFontTable;
public:
CFontManager() : m_pFont(NULL), CFontManagerBase()
CFontManager(NSFonts::IApplicationFonts* pFonts) : m_pFont(NULL), CFontManagerBase(pFonts)
{
m_pTransform = NULL;
m_dSpaceWidthMM = 0;
}
virtual ~CFontManager()
@ -86,24 +78,23 @@ namespace NSDocxRenderer
}
public:
AVSINLINE void Init()
void Init()
{
m_oFontTable.m_mapTable.RemoveAll();
m_oFontTable.m_mapTable.clear();
}
AVSINLINE void AddFontToMap()
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);
if (m_oFontTable.m_mapTable.end() != m_oFontTable.m_mapTable.find(m_oFont.m_strFamilyName))
{
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 = m_oFont.m_arSignature;
m_oFontTable.m_mapTable.SetAt(m_oFont.m_strFamilyName, oEntry);
}
m_oFontTable.m_mapTable.insert(std::pair<std::wstring, CFontTableEntry>(m_oFont.m_strFamilyName, oEntry));
}
}
public:
@ -113,13 +104,13 @@ namespace NSDocxRenderer
return;
double dSize = m_pFont->Size;
double dSizeFont = dSize * ((m_pTransform->m_agg_mtx.sx + m_pTransform->m_agg_mtx.sy) / 2);
double dSizeFont = dSize * ((m_pTransform->sx() + m_pTransform->sy()) / 2);
double dPix = m_pFont->CharSpace / c_dPixToMM;
m_pFont->Size = dSizeFont;
if (m_pFont->IsEqual2(&m_oFont.m_oFont))
if (m_pFont->IsEqual(&m_oFont.m_oFont))
{
m_pFont->Size = dSize;
m_pManager->SetCharSpacing(dPix);
@ -132,7 +123,7 @@ namespace NSDocxRenderer
bool bIsPath = false;
if (_T("") == m_pFont->Path)
if (m_pFont->Path.empty())
{
CFontManagerBase::LoadFontByName(m_oFont.m_oFont.Name, m_oFont.m_oFont.Size, m_oFont.m_oFont.GetStyle(), c_dDpiX, c_dDpiY);
}
@ -146,52 +137,25 @@ namespace NSDocxRenderer
bIsPath = true;
}
long lGid = 0;
m_pManager->GetStringGID(&lGid);
int bIsGID = m_pManager->GetStringGID();
m_pManager->SetStringGID(FALSE);
m_pManager->LoadString(L" ", 0, 0);
float _x = 0;
float _y = 0;
float _w = 0;
float _h = 0;
m_pManager->LoadString2(L" ", 0, 0);
TBBox bbox = m_pManager->MeasureString2();
m_pManager->MeasureString2(&_x, &_y, &_w, &_h);
m_dSpaceWidthMM = (double)_w * c_dPixToMM;
m_dSpaceWidthMM = (double)(bbox.fMaxX - bbox.fMinX) * c_dPixToMM;
if (0 >= m_dSpaceWidthMM)
{
m_dSpaceWidthMM = 1.0;
}
m_pManager->SetStringGID(lGid);
LoadFontMetrics();
LoadFontParams(bIsPath);
m_pManager->SetStringGID(bIsGID);
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)
void MeasureString(std::wstring sText, double x, double y, double& dBoxX, double& dBoxY, double& dBoxWidth, double& dBoxHeight, MeasureType measureType)
{
LoadFont();
@ -203,26 +167,22 @@ namespace NSDocxRenderer
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;
m_pManager->LoadString1(sText, (float)x, (float)y);
TBBox bbox;
if (MeasureTypeGlyph == measureType)
{
m_pManager->MeasureString(&fx, &fy, &fwidth, &fheight);
bbox = m_pManager->MeasureString();
}
else if (MeasureTypePosition == measureType)
{
m_pManager->MeasureString2(&fx, &fy, &fwidth, &fheight);
bbox = m_pManager->MeasureString2();
}
dBoxX = (double)fx;
dBoxY = (double)fy;
dBoxWidth = (double)fwidth;
dBoxHeight = (double)fheight;
dBoxX = (double)bbox.fMinX;
dBoxY = (double)bbox.fMinY;
dBoxWidth = (double)(bbox.fMaxX - bbox.fMinX);
dBoxHeight = (double)(bbox.fMaxY - bbox.fMinY);
// переводим в миллиметры
dBoxX *= c_dPixToMM;
@ -230,9 +190,43 @@ namespace NSDocxRenderer
dBoxWidth *= c_dPixToMM;
dBoxHeight *= c_dPixToMM;
}
void MeasureStringGids(unsigned int* pGids, unsigned int count, double x, double y, double& dBoxX, double& dBoxY, double& dBoxWidth, double& dBoxHeight, MeasureType measureType)
{
LoadFont();
dBoxX = 0;
dBoxY = 0;
dBoxWidth = 0;
dBoxHeight = 0;
__forceinline double GetBaseLineOffset()
if (NULL == m_pManager)
return;
m_pManager->LoadString1(pGids, count, (float)x, (float)y);
TBBox bbox;
if (MeasureTypeGlyph == measureType)
{
bbox = m_pManager->MeasureString();
}
else if (MeasureTypePosition == measureType)
{
bbox = m_pManager->MeasureString2();
}
dBoxX = (double)bbox.fMinX;
dBoxY = (double)bbox.fMinY;
dBoxWidth = (double)(bbox.fMaxX - bbox.fMinX);
dBoxHeight = (double)(bbox.fMaxY - bbox.fMinY);
// переводим в миллиметры
dBoxX *= c_dPixToMM;
dBoxY *= c_dPixToMM;
dBoxWidth *= c_dPixToMM;
dBoxHeight *= c_dPixToMM;
}
inline double GetBaseLineOffset()
{
LoadFont();
@ -243,35 +237,34 @@ namespace NSDocxRenderer
return d1;
}
__forceinline double GetFontHeight()
inline double GetFontHeight()
{
return c_dPtToMM * (m_oFont.m_dLineSpacing * m_oFont.m_oFont.Size ) / m_oFont.m_dEmHeight;
}
__forceinline void SetStringGid(const LONG& lGid)
inline void SetStringGid(const LONG& lGid)
{
if (NULL != m_pManager)
m_pManager->SetStringGID(lGid);
}
__forceinline void GenerateFontName2(CString& strText)
inline void GenerateFontName2(NSStringUtils::CStringUTF32& oText)
{
bool bIsNeedAddToMap = CFontManagerBase::GenerateFontName(strText);
bool bIsNeedAddToMap = CFontManagerBase::GenerateFontName(oText);
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);
if (m_oFontTable.m_mapTable.end() != m_oFontTable.m_mapTable.find(m_strCurrentPickFont))
{
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 = m_oFont.m_arSignature;
m_oFontTable.m_mapTable.SetAt(m_oFont.m_oFont.Path, oEntry);
}
m_oFontTable.m_mapTable.insert(std::pair<std::wstring, CFontTableEntry>(m_oFont.m_strFamilyName, oEntry));
}
}
}
};
@ -279,40 +272,36 @@ namespace NSDocxRenderer
class CFontManagerLight
{
private:
CString m_strFontName;
std::wstring m_strFontName;
LONG m_lFontStyle;
double m_dSize;
double m_dSpaceWidth;
AVSGraphics::IASCFontManager* m_pManager;
NSFonts::IFontManager* m_pManager;
public:
CFontManagerLight()
CFontManagerLight(NSFonts::IApplicationFonts* pFonts)
{
m_strFontName = _T("");
m_strFontName = L"";
m_lFontStyle = 0;
m_dSize = 0;
m_dSpaceWidth = 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");
m_pManager = pFonts->GenerateFontManager();
}
~CFontManagerLight()
{
RELEASEINTERFACE(m_pManager);
}
AVSINLINE double GetSpaceWidth()
inline double GetSpaceWidth()
{
return m_dSpaceWidth;
}
public:
AVSINLINE void LoadFont(CString& strFontName, LONG& lStyle, double& dSize, const BOOL& bIsGID)
void LoadFont(std::wstring& strFontName, LONG& lStyle, double& dSize, const BOOL& bIsGID)
{
if ((strFontName == m_strFontName) && (lStyle == m_lFontStyle) && (dSize == m_dSize))
{
@ -324,31 +313,19 @@ namespace NSDocxRenderer
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->LoadFontByName(strFontName, (float)m_dSize, m_lFontStyle, c_dDpiX, c_dDpiY);
m_dSpaceWidth = MeasureStringWidth(L" ");
m_pManager->SetStringGID(bIsGID);
}
AVSINLINE double MeasureStringWidth(CString& sText)
double MeasureStringWidth(const std::wstring& sText)
{
BSTR bsText = sText.AllocSysString();
m_pManager->LoadString(bsText, (float)0, (float)0);
SysFreeString(bsText);
m_pManager->LoadString2(sText, (float)0, (float)0);
TBBox bbox = m_pManager->MeasureString2();
float fx = 0;
float fy = 0;
float fwidth = 0;
float fheight = 0;
m_pManager->MeasureString2(&fx, &fy, &fwidth, &fheight);
return fwidth * c_dPixToMM;
return (bbox.fMaxX - bbox.fMinX) * c_dPixToMM;
}
};
}
}

File diff suppressed because it is too large Load Diff

View File

@ -8,19 +8,14 @@ namespace NSDocxRenderer
const double STANDART_STRING_HEIGHT_MM = 4.2333333333333334;
const double THE_SAME_STRING_Y_PRECISION_MM = 0.01;
static _bstr_t g_bstr_sectStart = L"<w:p><w:pPr><w:sectPr>";
static _bstr_t g_bstr_lastSect = L"<w:type w:val=\"continuous\"/>";
static _bstr_t g_bstr_sectEnd = L"<w:pgMar w:top=\"0\" w:right=\"0\" w:bottom=\"0\" w:left=\"0\"/></w:sectPr><w:spacing w:line=\"1\" w:lineRule=\"exact\"/></w:pPr></w:p>";
static CString g_string_sectSizeVer = _T("<w:pgSz w:w=\"%d\" w:h=\"%d\" w:orient=\"portrait\"/>");
static CString g_string_sectSizeHor = _T("<w:pgSz w:w=\"%d\" w:h=\"%d\" w:orient=\"landscape\"/>");
inline bool IsSpaceUtf32(NSStringUtils::CStringUTF32& oText)
{
if (1 != oText.length())
return false;
return (' ' == oText[0]) ? true : false;
}
static _bstr_t g_bstr_drawingParStart = L"<w:p><w:pPr><w:spacing w:line=\"1\" w:lineRule=\"exact\"/></w:pPr>";
static _bstr_t g_bstr_ParEnd = L"</w:p>";
static CString g_bstr_lastsection1 = L"<w:sectPr>";
static CString g_bstr_lastsection2 = L"<w:pgMar w:top=\"0\" w:right=\"0\" w:bottom=\"0\" w:left=\"0\" w:header=\"0\" w:footer=\"0\" w:gutter=\"0\"/></w:sectPr>";
AVSINLINE bool IsUnicodeSymbol( WCHAR symbol )
inline bool IsUnicodeSymbol( int symbol )
{
bool result = false;
@ -43,8 +38,8 @@ namespace NSDocxRenderer
NSStructures::CShadow* m_pShadow;
NSStructures::CEdgeText* m_pEdgeText;
NSDocxRenderer::CMatrix* m_pTransform;
AVSGraphics::IASCGraphicSimpleComverter* m_pSimpleGraphicsConverter;
Aggplus::CMatrix* m_pTransform;
Aggplus::CGraphicsPathSimpleConverter* m_pSimpleGraphicsConverter;
CVectorGraphics m_oVector;
@ -53,10 +48,10 @@ namespace NSDocxRenderer
LONG m_lCurrentCommand;
CAtlArray<CBaseItem*> m_arGraphicItems;
CAtlArray<CParagraph*> m_arParagraphs;
std::vector<CBaseItem*> m_arGraphicItems;
std::vector<CParagraph*> m_arParagraphs;
CAtlArray<CTextLine*> m_arTextLine;
std::vector<CTextLine*> m_arTextLine;
CTextLine* m_pCurrentLine;
CFontManager m_oManager;
@ -64,12 +59,12 @@ namespace NSDocxRenderer
TextAssociationType m_eTextAssociationType;
NSDocxRenderer::CStringWriter m_oWriterVML;
NSStringUtils::CStringBuilder m_oWriterVML;
bool m_bIsDeleteTextClipPage;
public:
CPage() : m_oManager(), m_oManagerLight()
CPage(NSFonts::IApplicationFonts* pFonts) : m_oManager(pFonts), m_oManagerLight(pFonts)
{
m_pFont = NULL;
m_pBrush = NULL;
@ -90,8 +85,8 @@ namespace NSDocxRenderer
}
public:
AVSINLINE void Init(NSStructures::CFont* pFont, NSStructures::CPen* pPen, NSStructures::CBrush* pBrush,
NSStructures::CShadow* pShadow, NSStructures::CEdgeText* pEdge, NSDocxRenderer::CMatrix* pMatrix, AVSGraphics::IASCGraphicSimpleComverter* pSimple)
void Init(NSStructures::CFont* pFont, NSStructures::CPen* pPen, NSStructures::CBrush* pBrush,
NSStructures::CShadow* pShadow, NSStructures::CEdgeText* pEdge, Aggplus::CMatrix* pMatrix, Aggplus::CGraphicsPathSimpleConverter* pSimple)
{
m_pFont = pFont;
m_pPen = pPen;
@ -107,36 +102,36 @@ namespace NSDocxRenderer
m_pCurrentLine = NULL;
m_oWriterVML.AddSize(1000, 1000);
m_oWriterVML.AddSize(1000);
}
AVSINLINE void Clear()
void Clear()
{
size_t nCount = 0;
nCount = m_arTextLine.GetCount();
nCount = m_arTextLine.size();
for (size_t i = 0; i < nCount; ++i)
{
CTextLine* pTemp = m_arTextLine[i];
RELEASEOBJECT(pTemp);
}
m_arTextLine.RemoveAll();
m_arTextLine.clear();
nCount = m_arGraphicItems.GetCount();
nCount = m_arGraphicItems.size();
for (size_t i = 0; i < nCount; ++i)
{
CBaseItem* pTemp = m_arGraphicItems[i];
RELEASEOBJECT(pTemp);
}
m_arGraphicItems.RemoveAll();
m_arGraphicItems.clear();
nCount = m_arParagraphs.GetCount();
nCount = m_arParagraphs.size();
for (size_t i = 0; i < nCount; ++i)
{
CParagraph* pTemp = m_arParagraphs[i];
RELEASEOBJECT(pTemp);
}
m_arParagraphs.RemoveAll();
m_arParagraphs.clear();
m_pCurrentLine = NULL;
@ -148,7 +143,7 @@ namespace NSDocxRenderer
Clear();
}
AVSINLINE void SetCurrentLineByBaseline(const double& dBaseLinePos)
void SetCurrentLineByBaseline(const double& dBaseLinePos)
{
if ((NULL == m_pCurrentLine) || (TextAssociationTypeDefault == m_eTextAssociationType))
{
@ -156,14 +151,14 @@ namespace NSDocxRenderer
m_pCurrentLine = new CTextLine();
m_pCurrentLine->m_dBaselinePos = dBaseLinePos;
m_arTextLine.Add(m_pCurrentLine);
m_arTextLine.push_back(m_pCurrentLine);
return;
}
if (fabs(m_pCurrentLine->m_dBaselinePos - dBaseLinePos) <= THE_SAME_STRING_Y_PRECISION_MM)
{
return;
}
size_t nCount = m_arTextLine.GetCount();
size_t nCount = m_arTextLine.size();
for (size_t i = 0; i < nCount; ++i)
{
if (fabs(m_arTextLine[i]->m_dBaselinePos - dBaseLinePos) <= THE_SAME_STRING_Y_PRECISION_MM)
@ -176,14 +171,14 @@ namespace NSDocxRenderer
// лини¤ не нашлась - не беда - создадим новую
m_pCurrentLine = new CTextLine();
m_pCurrentLine->m_dBaselinePos = dBaseLinePos;
m_arTextLine.Add(m_pCurrentLine);
m_arTextLine.push_back(m_pCurrentLine);
return;
}
// image commands
AVSINLINE void WriteImage(CImageInfo& oInfo, double& fX, double& fY, double& fWidth, double& fHeight)
void WriteImage(CImageInfo& oInfo, double& fX, double& fY, double& fWidth, double& fHeight)
{
CImage* pImage = new CImage(oInfo, _T(""));
CImage* pImage = new CImage(oInfo, L"");
double dRotation = m_pTransform->z_Rotation();
@ -228,7 +223,7 @@ namespace NSDocxRenderer
double x2 = fX + fWidth;
double y2 = fY + fHeight;
NSDocxRenderer::CMatrix oTemp = *m_pTransform;
Aggplus::CMatrix oTemp = *m_pTransform;
double dCx = (x1 + x2) / 2;
double dCy = (y1 + y2) / 2;
@ -263,22 +258,22 @@ namespace NSDocxRenderer
pImage->m_dRotate = dRotation;
}
m_arGraphicItems.Add(pImage);
m_arGraphicItems.push_back(pImage);
}
// path commands
AVSINLINE void MoveTo(double& dX, double& dY)
void MoveTo(double& dX, double& dY)
{
m_pTransform->TransformPoint(dX, dY);
m_oVector.MoveTo(dX, dY);
}
AVSINLINE void LineTo(double& dX, double& dY)
void LineTo(double& dX, double& dY)
{
m_pTransform->TransformPoint(dX, dY);
m_oVector.LineTo(dX, dY);
}
AVSINLINE void CurveTo(double& x1, double& y1, double& x2, double& y2, double& x3, double& y3)
void CurveTo(double& x1, double& y1, double& x2, double& y2, double& x3, double& y3)
{
m_pTransform->TransformPoint(x1, y1);
m_pTransform->TransformPoint(x2, y2);
@ -286,19 +281,19 @@ namespace NSDocxRenderer
m_oVector.CurveTo(x1, y1, x2, y2, x3, y3);
}
AVSINLINE void Start()
void Start()
{
}
AVSINLINE void End()
void End()
{
m_oVector.End();
m_oWriterVML.ClearNoAttack();
}
AVSINLINE void Close()
void Close()
{
m_oVector.Close();
}
AVSINLINE void DrawPath(LONG lType, LONG lTxId)
void DrawPath(LONG lType, LONG lTxId)
{
if ((m_oVector.m_dLeft <= m_oVector.m_dRight) && (m_oVector.m_dTop <= m_oVector.m_dBottom))
{
@ -310,7 +305,7 @@ namespace NSDocxRenderer
pShape->m_oBrush = *m_pBrush;
// нормализуем толщину линии
double dScaleTransform = (m_pTransform->m_agg_mtx.sx + m_pTransform->m_agg_mtx.sy) / 2.0;
double dScaleTransform = (m_pTransform->sx() + m_pTransform->sy()) / 2.0;
pShape->m_oPen.Size *= dScaleTransform;
if ((lType & 0x01) == 0x00)
@ -326,11 +321,11 @@ namespace NSDocxRenderer
}
pShape->CreateFromVectorData(&m_oVector, m_oWriterVML, 100000, lType);
m_arGraphicItems.Add(pShape);
m_arGraphicItems.push_back(pShape);
}
}
AVSINLINE void WriteText(BSTR bsText, BSTR bsGid, double fX, double fY, double fWidth, double fHeight, double fBaseLineOffset, bool bIsPDFAnalyzer)
void WriteText(unsigned int* pUnicodes, unsigned int* pGids, unsigned int nCount, double fX, double fY, double fWidth, double fHeight, double fBaseLineOffset, bool bIsPDFAnalyzer)
{
double dTextX = fX;
double dTextY = fY;
@ -343,34 +338,25 @@ namespace NSDocxRenderer
double dTextW = dTextR - dTextX;
double dTextH = dTextB - dTextY;
CString strText = _T("");
NSStringUtils::CStringUTF32 oText((uint32_t*)pUnicodes, nCount);
if ((bsText != NULL) && (bsGid != NULL))
if ((pUnicodes != NULL) && (pGids != NULL))
{
UINT lLen = SysStringLen(bsText);
for (unsigned int i = 0; i < lLen; ++i)
for (unsigned int i = 0; i < nCount; ++i)
{
if ( IsUnicodeSymbol( bsText[i] ) )
if ( !IsUnicodeSymbol( pUnicodes[i] ) )
{
strText += bsText[i];
}
else
{
strText += _T(" ");
}
oText[i] = ' ';
}
}
}
else
{
strText = (CString)bsText;
}
bool bIsPath = ((NULL == bsGid) && !bIsPDFAnalyzer) ? false : true;
bool bIsPath = ((NULL == pGids) && !bIsPDFAnalyzer) ? false : true;
m_oManager.LoadFont(0, !bIsPath);
if (bIsPath)
m_oManager.GenerateFontName2(strText);
m_oManager.GenerateFontName2(oText);
if ((0 == dTextW) || (dTextW > 5 * m_oManager.m_dSpaceWidthMM))
{
@ -379,16 +365,16 @@ namespace NSDocxRenderer
double _w = 0;
double _h = 0;
if (NULL != bsGid)
if (NULL != pGids)
{
m_oManager.SetStringGid(1);
m_oManager.MeasureString(bsGid, dTextX, dTextY, _x, _y, _w, _h, CFontManager::MeasureTypePosition);
m_oManager.MeasureStringGids(pGids, nCount, dTextX, dTextY, _x, _y, _w, _h, CFontManager::MeasureTypePosition);
}
else
{
// такого быть не должно (только из xps)
m_oManager.SetStringGid(0);
m_oManager.MeasureString(bsText, dTextX, dTextY, _x, _y, _w, _h, CFontManager::MeasureTypePosition);
m_oManager.MeasureStringGids(pUnicodes, nCount, dTextX, dTextY, _x, _y, _w, _h, CFontManager::MeasureTypePosition);
}
dTextW = _w;
@ -401,7 +387,7 @@ namespace NSDocxRenderer
SetCurrentLineByBaseline(dBaseLinePos);
CContText* pLastCont = NULL;
size_t nCountConts = m_pCurrentLine->m_arConts.GetCount();
size_t nCountConts = m_pCurrentLine->m_arConts.size();
if (nCountConts != 0)
pLastCont = m_pCurrentLine->m_arConts[nCountConts - 1];
@ -416,7 +402,7 @@ namespace NSDocxRenderer
pCont->m_dWidth = dTextW;
pCont->m_dHeight = dTextH;
if (_T(" ") == strText)
if (IsSpaceUtf32(oText))
{
pCont->m_dWidthWithoutSpaces = 0;
pCont->m_dLeftWithoutSpaces = dTextX + dTextW;
@ -427,7 +413,7 @@ namespace NSDocxRenderer
pCont->m_dLeftWithoutSpaces = dTextX;
}
pCont->m_strText = strText;
pCont->m_oText = oText;
pCont->m_oFont = m_oManager.m_oFont.m_oFont;
pCont->m_oBrush = *m_pBrush;
@ -461,10 +447,10 @@ namespace NSDocxRenderer
if (fabs(dRight - dTextX) < 0.5)
{
// продолжаем слово
pLastCont->m_strText += strText;
pLastCont->m_oText += oText;
pLastCont->m_dWidth = (dTextX + dTextW - pLastCont->m_dX);
if (_T(" ") != strText)
if (!IsSpaceUtf32(oText))
{
if (0 == pLastCont->m_dWidthWithoutSpaces)
pLastCont->m_dLeftWithoutSpaces = dTextX;
@ -481,10 +467,11 @@ namespace NSDocxRenderer
else if ((dRight < dTextX) && ((dTextX - dRight) < m_oManager.m_dSpaceWidthMM))
{
// продолжаем слово с пробелом
pLastCont->m_strText += (_T(" ") + strText);
pLastCont->m_oText += uint32_t(' ');
pLastCont->m_oText += oText;
pLastCont->m_dWidth = (dTextX + dTextW - pLastCont->m_dX);
if (_T(" ") != strText)
if (!IsSpaceUtf32(oText))
{
if (0 == pLastCont->m_dWidthWithoutSpaces)
pLastCont->m_dLeftWithoutSpaces = dTextX;
@ -510,7 +497,7 @@ namespace NSDocxRenderer
pCont->m_dWidth = dTextW;
pCont->m_dHeight = dTextH;
if (_T(" ") == strText)
if (IsSpaceUtf32(oText))
{
pCont->m_dWidthWithoutSpaces = 0;
pCont->m_dLeftWithoutSpaces = dTextX + dTextW;
@ -521,7 +508,7 @@ namespace NSDocxRenderer
pCont->m_dLeftWithoutSpaces = dTextX;
}
pCont->m_strText = strText;
pCont->m_oText = oText;
pCont->m_oFont = m_oManager.m_oFont.m_oFont;
pCont->m_oBrush = *m_pBrush;
@ -542,7 +529,7 @@ namespace NSDocxRenderer
if (m_bIsDeleteTextClipPage)
{
// удалим все линии, которые выход¤т за границы страницы
size_t nCount = m_arTextLine.GetCount();
size_t nCount = m_arTextLine.size();
for (size_t i = 0; i < nCount; ++i)
{
CTextLine* pTextLine = m_arTextLine[i];
@ -552,7 +539,7 @@ namespace NSDocxRenderer
if (_top >= m_dHeight || _bottom <= 0)
{
m_arTextLine.RemoveAt(i);
m_arTextLine.erase(m_arTextLine.begin() + i);
--i;
--nCount;
}
@ -564,7 +551,7 @@ namespace NSDocxRenderer
case TextAssociationTypeDefault:
case TextAssociationTypeLine:
{
size_t nCount = m_arTextLine.GetCount();
size_t nCount = m_arTextLine.size();
for (size_t i = 0; i < nCount; ++i)
{
CTextLine* pTextLine = m_arTextLine[i];
@ -576,18 +563,18 @@ namespace NSDocxRenderer
pParagraph->m_dLeft = pTextLine->m_dX;
pParagraph->m_dTop = pTextLine->m_dBaselinePos - pTextLine->m_dHeight + pTextLine->m_dBaselineOffset;
pParagraph->m_arLines.Add(pTextLine);
pParagraph->m_arLines.push_back(pTextLine);
m_arParagraphs.Add(pParagraph);
m_arParagraphs.push_back(pParagraph);
}
// удалим все линии
m_arTextLine.RemoveAll();
m_arTextLine.clear();
break;
}
case TextAssociationTypeBlock:
{
size_t nCount = m_arTextLine.GetCount();
size_t nCount = m_arTextLine.size();
if (0 == nCount)
break;
@ -601,9 +588,9 @@ namespace NSDocxRenderer
pParagraph->m_dLeft = pFirstLine->m_dX;
pParagraph->m_dTop = pFirstLine->m_dBaselinePos - pFirstLine->m_dHeight + pFirstLine->m_dBaselineOffset;
pParagraph->m_arLines.Add(pFirstLine);
pParagraph->m_arLines.push_back(pFirstLine);
m_arParagraphs.Add(pParagraph);
m_arParagraphs.push_back(pParagraph);
for (size_t i = 1; i < nCount; ++i)
{
@ -627,12 +614,12 @@ namespace NSDocxRenderer
pFirstLine = pTextLine;
pParagraph->m_arLines.Add(pTextLine);
m_arParagraphs.Add(pParagraph);
pParagraph->m_arLines.push_back(pTextLine);
m_arParagraphs.push_back(pParagraph);
}
// удалим все линии
m_arTextLine.RemoveAll();
m_arTextLine.clear();
break;
}
case TextAssociationTypeNoFrames:
@ -641,7 +628,7 @@ namespace NSDocxRenderer
Merge(STANDART_STRING_HEIGHT_MM / 3);
double previousStringOffset = 0;
size_t nCount = m_arTextLine.GetCount();
size_t nCount = m_arTextLine.size();
for (size_t i = 0; i < nCount; ++i)
{
CTextLine* pTextLine = m_arTextLine[i];
@ -654,7 +641,7 @@ namespace NSDocxRenderer
double dBeforeSpacing = (pTextLine->m_dBaselinePos - previousStringOffset - pTextLine->m_dHeight + pTextLine->m_dBaselineOffset);
pParagraph->m_dSpaceBefore = max(dBeforeSpacing, 0);
pParagraph->m_dSpaceBefore = std::max(dBeforeSpacing, 0.0);
double dHeight = 1;
if (pTextLine->m_dHeight != 0)
@ -669,11 +656,11 @@ namespace NSDocxRenderer
previousStringOffset = pTextLine->m_dBaselinePos + pTextLine->m_dBaselineOffset;
pParagraph->m_arLines.Add(pTextLine);
m_arParagraphs.Add(pParagraph);
pParagraph->m_arLines.push_back(pTextLine);
m_arParagraphs.push_back(pParagraph);
}
m_arTextLine.RemoveAll();
m_arTextLine.clear();
break;
}
}
@ -681,7 +668,7 @@ namespace NSDocxRenderer
void Merge(double dAffinity)
{
size_t nCount = m_arTextLine.GetCount();
size_t nCount = m_arTextLine.size();
if (1 < nCount)
{
CTextLine* pPrev = m_arTextLine[0];
@ -693,10 +680,10 @@ namespace NSDocxRenderer
{
pPrev->Merge(pNext);
pNext->m_arConts.RemoveAll();
pNext->m_arConts.clear();
RELEASEOBJECT(pNext);
m_arTextLine.RemoveAt(i);
m_arTextLine.erase(m_arTextLine.begin() + i);
--i;
--nCount;
continue;
@ -706,57 +693,52 @@ namespace NSDocxRenderer
}
}
void Write(NSDocxRenderer::CStringWriter& oWriter)
void Write(NSStringUtils::CStringBuilder& oWriter)
{
// drawings
size_t nCountDrawings = m_arGraphicItems.GetCount();
size_t nCountDrawings = m_arGraphicItems.size();
if (0 != nCountDrawings)
{
oWriter.WriteString(g_bstr_drawingParStart);
oWriter.WriteString(L"<w:p><w:pPr><w:spacing w:line=\"1\" w:lineRule=\"exact\"/></w:pPr>");
for (size_t i = 0; i < nCountDrawings; ++i)
{
m_arGraphicItems[i]->ToXml(oWriter);
}
oWriter.WriteString(g_bstr_ParEnd);
oWriter.WriteString(L"</w:p>");
}
size_t nCountParagraphs = m_arParagraphs.GetCount();
size_t nCountParagraphs = m_arParagraphs.size();
for (size_t i = 0; i < nCountParagraphs; ++i)
{
m_arParagraphs[i]->ToXml(oWriter);
}
}
AVSINLINE void WriteSectionToFile(bool bLastPage, NSDocxRenderer::CStringWriter& oWriter)
void WriteSectionToFile(bool bLastPage, NSStringUtils::CStringBuilder& oWriter)
{
// section
LONG lWidthDx = (LONG)(m_dWidth * c_dMMToDx);
LONG lHeightDx = (LONG)(m_dHeight * c_dMMToDx);
int lWidthDx = (int)(m_dWidth * c_dMMToDx);
int lHeightDx = (int)(m_dHeight * c_dMMToDx);
if (!bLastPage)
oWriter.WriteString(g_bstr_sectStart);
oWriter.WriteString(L"<w:p><w:pPr><w:sectPr>");
else
oWriter.WriteString(g_bstr_lastsection1);
if (lWidthDx >= lHeightDx)
{
CString strSize = _T("");
strSize.Format(g_string_sectSizeHor, lWidthDx, lHeightDx);
oWriter.WriteString(strSize);
}
else
{
CString strSize = _T("");
strSize.Format(g_string_sectSizeVer, lWidthDx, lHeightDx);
oWriter.WriteString(strSize);
}
oWriter.WriteString(L"<w:sectPr>");
oWriter.WriteString(L"<w:pgSz w:w=\"");
oWriter.AddInt((int)(m_dWidth * c_dMMToDx));
oWriter.WriteString(L"\" w:h=\"");
oWriter.AddInt((int)(m_dHeight * c_dMMToDx));
oWriter.WriteString(L"\" w:orient=\"");
(lWidthDx >= lHeightDx) ? oWriter.WriteString(L"landscape") : oWriter.WriteString(L"portrait");
oWriter.WriteString(L"\"/>");
if (!bLastPage)
oWriter.WriteString(g_bstr_sectEnd);
oWriter.WriteString(L"<w:pgMar w:top=\"0\" w:right=\"0\" w:bottom=\"0\" w:left=\"0\"/></w:sectPr><w:spacing w:line=\"1\" w:lineRule=\"exact\"/></w:pPr></w:p>");
else
oWriter.WriteString(g_bstr_lastsection2);
oWriter.WriteString(L"<w:pgMar w:top=\"0\" w:right=\"0\" w:bottom=\"0\" w:left=\"0\" w:header=\"0\" w:footer=\"0\" w:gutter=\"0\"/></w:sectPr>");
}
};
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,851 +0,0 @@
// AVSDocxRenderer.cpp : Implementation of CAVSDocxRenderer
#include "stdafx.h"
#include "ASCDocxRenderer.h"
// CAVSDocxRenderer
STDMETHODIMP CAVSDocxRenderer::get_Type(LONG* lType)
{
return S_OK;
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::NewPage()
{
return m_oDocument.NewPage();
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::get_Height(double* dHeight)
{
return m_oDocument.get_Height(dHeight);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::put_Height(double dHeight)
{
return m_oDocument.put_Height(dHeight);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::get_Width(double* dWidth)
{
return m_oDocument.get_Width(dWidth);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::put_Width(double dWidth)
{
return m_oDocument.put_Width(dWidth);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::get_DpiX(double* dDpiX)
{
return m_oDocument.get_DpiX(dDpiX);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::get_DpiY(double* dDpiY)
{
return m_oDocument.get_DpiY(dDpiY);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::SetPen(BSTR bsXML)
{
return m_oDocument.SetPen(bsXML);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::get_PenColor(LONG* lColor)
{
return m_oDocument.get_PenColor(lColor);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::put_PenColor(LONG lColor)
{
return m_oDocument.put_PenColor(lColor);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::get_PenAlpha(LONG* lAlpha)
{
return m_oDocument.get_PenAlpha(lAlpha);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::put_PenAlpha(LONG lAlpha)
{
return m_oDocument.put_PenAlpha(lAlpha);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::get_PenSize(double* dSize)
{
return m_oDocument.get_PenSize(dSize);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::put_PenSize(double dSize)
{
return m_oDocument.put_PenSize(dSize);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::get_PenDashStyle(BYTE* val)
{
return m_oDocument.get_PenDashStyle(val);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::put_PenDashStyle(BYTE val)
{
return m_oDocument.put_PenDashStyle(val);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::get_PenLineStartCap(BYTE* val)
{
return m_oDocument.get_PenLineStartCap(val);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::put_PenLineStartCap(BYTE val)
{
return m_oDocument.put_PenLineStartCap(val);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::get_PenLineEndCap(BYTE* val)
{
return m_oDocument.get_PenLineEndCap(val);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::put_PenLineEndCap(BYTE val)
{
return m_oDocument.put_PenLineEndCap(val);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::get_PenLineJoin(BYTE* val)
{
return m_oDocument.get_PenLineJoin(val);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::put_PenLineJoin(BYTE val)
{
return m_oDocument.put_PenLineJoin(val);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::get_PenDashOffset(double* val)
{
return m_oDocument.get_PenDashOffset(val);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::put_PenDashOffset(double val)
{
return m_oDocument.put_PenDashOffset(val);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::get_PenAlign(LONG* val)
{
return m_oDocument.get_PenAlign(val);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::put_PenAlign(LONG val)
{
return m_oDocument.put_PenAlign(val);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::get_PenMiterLimit(double* val)
{
return m_oDocument.get_PenMiterLimit(val);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::put_PenMiterLimit(double val)
{
return m_oDocument.put_PenMiterLimit(val);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::PenDashPattern(SAFEARRAY* pPattern)
{
return m_oDocument.PenDashPattern(pPattern);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::SetBrush(BSTR bsXML)
{
return m_oDocument.SetBrush(bsXML);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::get_BrushType(LONG* lType)
{
return m_oDocument.get_BrushType(lType);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::put_BrushType(LONG lType)
{
return m_oDocument.put_BrushType(lType);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::get_BrushColor1(LONG* lColor)
{
return m_oDocument.get_BrushColor1(lColor);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::put_BrushColor1(LONG lColor)
{
return m_oDocument.put_BrushColor1(lColor);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::get_BrushAlpha1(LONG* lAlpha)
{
return m_oDocument.get_BrushAlpha1(lAlpha);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::put_BrushAlpha1(LONG lAlpha)
{
return m_oDocument.put_BrushAlpha1(lAlpha);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::get_BrushColor2(LONG* lColor)
{
return m_oDocument.get_BrushColor2(lColor);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::put_BrushColor2(LONG lColor)
{
return m_oDocument.put_BrushColor2(lColor);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::get_BrushAlpha2(LONG* lAlpha)
{
return m_oDocument.get_BrushAlpha2(lAlpha);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::put_BrushAlpha2(LONG lAlpha)
{
return m_oDocument.put_BrushAlpha2(lAlpha);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::get_BrushTexturePath(BSTR* bsPath)
{
return m_oDocument.get_BrushTexturePath(bsPath);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::put_BrushTexturePath(BSTR bsPath)
{
return m_oDocument.put_BrushTexturePath(bsPath);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::get_BrushTextureMode(LONG* lMode)
{
return m_oDocument.get_BrushTextureMode(lMode);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::put_BrushTextureMode(LONG lMode)
{
return m_oDocument.put_BrushTextureMode(lMode);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::get_BrushTextureAlpha(LONG* lTxAlpha)
{
return m_oDocument.get_BrushTextureAlpha(lTxAlpha);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::put_BrushTextureAlpha(LONG lTxAlpha)
{
return m_oDocument.put_BrushTextureAlpha(lTxAlpha);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::get_BrushLinearAngle(double* dAngle)
{
return m_oDocument.get_BrushLinearAngle(dAngle);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::put_BrushLinearAngle(double dAngle)
{
return m_oDocument.put_BrushLinearAngle(dAngle);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::BrushRect(BOOL val, double left, double top, double width, double height)
{
return m_oDocument.BrushRect(val, left, top, width, height);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::SetFont(BSTR bsXML)
{
return m_oDocument.SetFont(bsXML);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::get_FontName(BSTR* bsName)
{
return m_oDocument.get_FontName(bsName);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::put_FontName(BSTR bsName)
{
return m_oDocument.put_FontName(bsName);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::get_FontPath(BSTR* bsName)
{
return m_oDocument.get_FontPath(bsName);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::put_FontPath(BSTR bsName)
{
return m_oDocument.put_FontPath(bsName);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::get_FontSize(double* dSize)
{
return m_oDocument.get_FontSize(dSize);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::put_FontSize(double dSize)
{
return m_oDocument.put_FontSize(dSize);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::get_FontStyle(LONG* lStyle)
{
return m_oDocument.get_FontStyle(lStyle);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::put_FontStyle(LONG lStyle)
{
return m_oDocument.put_FontStyle(lStyle);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::get_FontStringGID(BOOL* bGID)
{
return m_oDocument.get_FontStringGID(bGID);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::put_FontStringGID(BOOL bGID)
{
return m_oDocument.put_FontStringGID(bGID);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::get_FontCharSpace(double* dSpace)
{
return m_oDocument.get_FontCharSpace(dSpace);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::put_FontCharSpace(double dSpace)
{
return m_oDocument.put_FontCharSpace(dSpace);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::SetShadow(BSTR bsXML)
{
return m_oDocument.SetShadow(bsXML);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::get_ShadowDistanceX(double* val)
{
return m_oDocument.get_ShadowDistanceX(val);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::put_ShadowDistanceX(double val)
{
return m_oDocument.put_ShadowDistanceX(val);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::get_ShadowDistanceY(double* val)
{
return m_oDocument.get_ShadowDistanceY(val);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::put_ShadowDistanceY(double val)
{
return m_oDocument.put_ShadowDistanceY(val);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::get_ShadowBlurSize(double* val)
{
return m_oDocument.get_ShadowBlurSize(val);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::put_ShadowBlurSize(double val)
{
return m_oDocument.put_ShadowBlurSize(val);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::get_ShadowColor(LONG* val)
{
return m_oDocument.get_ShadowColor(val);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::put_ShadowColor(LONG val)
{
return m_oDocument.put_ShadowColor(val);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::get_ShadowAlpha(LONG* val)
{
return m_oDocument.get_ShadowAlpha(val);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::put_ShadowAlpha(LONG val)
{
return m_oDocument.put_ShadowAlpha(val);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::get_ShadowVisible(BOOL* val)
{
return m_oDocument.get_ShadowVisible(val);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::put_ShadowVisible(BOOL val)
{
return m_oDocument.put_ShadowVisible(val);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::SetEdgeText(BSTR bsXML)
{
return m_oDocument.SetEdgeText(bsXML);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::get_EdgeVisible(LONG* val)
{
return m_oDocument.get_EdgeVisible(val);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::put_EdgeVisible(LONG val)
{
return m_oDocument.put_EdgeVisible(val);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::get_EdgeColor(LONG* val)
{
return m_oDocument.get_EdgeColor(val);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::put_EdgeColor(LONG val)
{
return m_oDocument.put_EdgeColor(val);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::get_EdgeAlpha(LONG* val)
{
return m_oDocument.get_EdgeAlpha(val);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::put_EdgeAlpha(LONG val)
{
return m_oDocument.put_EdgeAlpha(val);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::get_EdgeDist(double* val)
{
return m_oDocument.get_EdgeDist(val);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::put_EdgeDist(double val)
{
return m_oDocument.put_EdgeDist(val);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::CommandDrawText(BSTR bsText, double fX, double fY, double fWidth, double fHeight, double fBaseLineOffset)
{
return m_oDocument.CommandDrawText(bsText, fX, fY, fWidth, fHeight, fBaseLineOffset);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::CommandDrawTextEx(BSTR bsUnicodeText, BSTR bsGidText, BSTR bsSourceCodeText, double fX, double fY, double fWidth, double fHeight, double fBaseLineOffset, DWORD lFlags)
{
return m_oDocument.CommandDrawTextEx(bsUnicodeText, bsGidText, bsSourceCodeText, fX, fY, fWidth, fHeight, fBaseLineOffset, lFlags);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::BeginCommand(DWORD lType)
{
return m_oDocument.BeginCommand(lType);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::EndCommand(DWORD lType)
{
return m_oDocument.EndCommand(lType);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::PathCommandMoveTo(double fX, double fY)
{
return m_oDocument.PathCommandMoveTo(fX, fY);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::PathCommandLineTo(double fX, double fY)
{
return m_oDocument.PathCommandLineTo(fX, fY);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::PathCommandLinesTo(SAFEARRAY* pPoints)
{
return m_oDocument.PathCommandLinesTo(pPoints);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::PathCommandCurveTo(double fX1, double fY1, double fX2, double fY2, double fX3, double fY3)
{
return m_oDocument.PathCommandCurveTo(fX1, fY1, fX2, fY2, fX3, fY3);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::PathCommandCurvesTo(SAFEARRAY* pPoints)
{
return m_oDocument.PathCommandCurvesTo(pPoints);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::PathCommandArcTo(double fX, double fY, double fWidth, double fHeight, double fStartAngle, double fSweepAngle)
{
return m_oDocument.PathCommandArcTo(fX, fY, fWidth, fHeight, fStartAngle, fSweepAngle);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::PathCommandClose()
{
return m_oDocument.PathCommandClose();
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::PathCommandEnd()
{
return m_oDocument.PathCommandEnd();
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::DrawPath(long nType)
{
return m_oDocument.DrawPath(nType);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::PathCommandStart()
{
return m_oDocument.PathCommandStart();
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::PathCommandGetCurrentPoint(double* fX, double* fY)
{
return m_oDocument.PathCommandGetCurrentPoint( fX, fY );
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::GetCommandParams(double* dAngle, double* dLeft, double* dTop, double* dWidth, double* dHeight, DWORD* lFlags)
{
return m_oDocument.GetCommandParams( dAngle, dLeft, dTop, dWidth, dHeight, lFlags );
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::SetCommandParams(double dAngle, double dLeft, double dTop, double dWidth, double dHeight, DWORD lFlags)
{
return m_oDocument.SetCommandParams( dAngle, dLeft, dTop, dWidth, dHeight, lFlags );
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::DrawImage(IUnknown* pInterface, double fX, double fY, double fWidth, double fHeight)
{
return m_oDocument.DrawImage( pInterface, fX, fY, fWidth, fHeight);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::DrawImageFromFile(BSTR bstrVal, double fX, double fY, double fWidth, double fHeight)
{
return m_oDocument.DrawImageFromFile( bstrVal, fX, fY, fWidth, fHeight);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::SetAdditionalParam(BSTR ParamName, VARIANT ParamValue)
{
CString sParamName = ParamName;
if ( _T("SourceRendererType") == sParamName && VT_I4 == ParamValue.vt )
{
m_oDocument.m_bIsNeedPDFTextAnalyzer = ( ParamValue.lVal == c_nPDFWriter ? true : false );
}
return S_OK;
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::GetAdditionalParam(BSTR ParamName, VARIANT* ParamValue)
{
return S_OK;
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::SetTransform(double dA, double dB, double dC, double dD, double dE, double dF)
{
return m_oDocument.SetTransform( dA, dB, dC, dD, dE, dF );
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::GetTransform(double *pdA, double *pdB, double *pdC, double *pdD, double *pdE, double *pdF)
{
return m_oDocument.GetTransform( pdA, pdB, pdC, pdD, pdE, pdF );
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::ResetTransform(void)
{
return m_oDocument.ResetTransform();
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::get_ClipMode(LONG* plMode)
{
return m_oDocument.get_ClipMode(plMode);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::put_ClipMode(LONG lMode)
{
return m_oDocument.put_ClipMode(lMode);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::PathCommandText(BSTR bsText, double fX, double fY, double fWidth, double fHeight, double fBaseLineOffset)
{
return m_oDocument.PathCommandText(bsText, fX, fY, fWidth, fHeight, fBaseLineOffset);
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::PathCommandTextEx(BSTR bsUnicodeText, BSTR bsGidText, BSTR bsSourceCodeText, double fX, double fY, double fWidth, double fHeight, double fBaseLineOffset, DWORD lFlags)
{
return m_oDocument.PathCommandTextEx( bsUnicodeText, bsGidText, bsSourceCodeText, fX, fY, fWidth, fHeight, fBaseLineOffset, lFlags );
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::Initialize(BSTR bsXMLOptions)
{
BaseInitialize(bsXMLOptions);
IUnknown* punkRenderer = NULL;
this->QueryInterface(IID_IUnknown, (void**)&punkRenderer);
m_oDocument.CreateDocument(punkRenderer, m_strTempFileDir);
RELEASEINTERFACE(punkRenderer);
return S_OK;
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::Save()
{
m_oDocument.Close();
return S_OK;
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::CreateOfficeFile(BSTR bsXMLOptions)
{
BaseInitialize(bsXMLOptions);
IUnknown* punkRenderer = NULL;
this->QueryInterface(IID_IUnknown, (void**)&punkRenderer);
m_oDocument.CreateDocument(punkRenderer, m_strTempFileDir);
RELEASEINTERFACE(punkRenderer);
return S_OK;
}
/*========================================================================================================*/
STDMETHODIMP CAVSDocxRenderer::CloseFile()
{
m_oDocument.Close();
return S_OK;
}
/*========================================================================================================*/

View File

@ -1,239 +0,0 @@
// AVSDocxRenderer.h : Declaration of the CAVSDocxRenderer
#pragma once
#include "stdafx.h"
#include "resource.h" // main symbols
#include "Logic/Document.h"
#if defined(_WIN32_WCE) && !defined(_CE_DCOM) && !defined(_CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA)
#error "Single-threaded COM objects are not properly supported on Windows CE platform, such as the Windows Mobile platforms that do not include full DCOM support. Define _CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA to force ATL to support creating single-thread COM object's and allow use of it's single-threaded COM object implementations. The threading model in your rgs file was set to 'Free' as that is the only threading model supported in non DCOM Windows CE platforms."
#endif
// IAVSDocxRenderer
[object, uuid("5BEC40F1-CA4F-4275-BCC8-D4ABF47D896D"), dual, pointer_default(unique)]
__interface IAVSDocxRenderer : IASCRenderer
{
[id(11001)] HRESULT Initialize([in]BSTR bsXMLOptions);
[id(11002)] HRESULT Save();
};
[object, uuid("84411C25-B8A1-4f16-A37A-9C142FBE8D26"), dual, pointer_default(unique)]
__interface IAVSDocxRenderer2 : IDispatch
{
[id(12001)] HRESULT CreateOfficeFile([in]BSTR bstrFileName);
[id(12002)] HRESULT CloseFile();
};
// CAVSDocxRenderer
[coclass, default(IAVSDocxRenderer), threading(apartment), vi_progid("AVSOfficeDocxRenderer.AVSDocxRenderer"), progid("AVSOfficeDocxRenderer.AVSDocxRenderer.1"), version(1.0), uuid("77B37E21-16F0-4BCC-8901-DFD89B962174")]
class ATL_NO_VTABLE CAVSDocxRenderer :
public IAVSDocxRenderer,
public IAVSDocxRenderer2
{
public:
CAVSDocxRenderer()
{
}
DECLARE_PROTECT_FINAL_CONSTRUCT()
HRESULT FinalConstruct()
{
m_strDstFilePath = _T("");
m_strTempFileDir = _T("");
m_strTempFileName = _T("");
InitializeCriticalSection(&m_oCS);
return S_OK;
}
void FinalRelease()
{
CloseFile();
DeleteCriticalSection(&m_oCS);
}
public:
// IASCRenderer Methods
// тип рендерера-----------------------------------------------------------------------------
STDMETHOD(get_Type)(LONG* lType);
//-------- Функции для работы со страницей --------------------------------------------------
STDMETHOD(NewPage)();
STDMETHOD(get_Height)(double* dHeight);
STDMETHOD(put_Height)(double dHeight);
STDMETHOD(get_Width)(double* dWidth);
STDMETHOD(put_Width)(double dWidth);
STDMETHOD(get_DpiX)(double* dDpiX);
STDMETHOD(get_DpiY)(double* dDpiY);
//-------- Функции для задания настроек текста ----------------------------------------------
STDMETHOD(SetPen)(BSTR bsXML);
STDMETHOD(get_PenColor)(LONG* lColor);
STDMETHOD(put_PenColor)(LONG lColor);
STDMETHOD(get_PenAlpha)(LONG* lAlpha);
STDMETHOD(put_PenAlpha)(LONG lAlpha);
STDMETHOD(get_PenSize)(double* dSize);
STDMETHOD(put_PenSize)(double dSize);
STDMETHOD(get_PenDashStyle)(BYTE* val);
STDMETHOD(put_PenDashStyle)(BYTE val);
STDMETHOD(get_PenLineStartCap)(BYTE* val);
STDMETHOD(put_PenLineStartCap)(BYTE val);
STDMETHOD(get_PenLineEndCap)(BYTE* val);
STDMETHOD(put_PenLineEndCap)(BYTE val);
STDMETHOD(get_PenLineJoin)(BYTE* val);
STDMETHOD(put_PenLineJoin)(BYTE val);
STDMETHOD(get_PenDashOffset)(double* val);
STDMETHOD(put_PenDashOffset)(double val);
STDMETHOD(get_PenAlign)(LONG* val);
STDMETHOD(put_PenAlign)(LONG val);
STDMETHOD(get_PenMiterLimit)(double* val);
STDMETHOD(put_PenMiterLimit)(double val);
STDMETHOD(PenDashPattern)(SAFEARRAY* pPattern);
STDMETHOD(SetBrush)(BSTR bsXML);
STDMETHOD(get_BrushType)(LONG* lType);
STDMETHOD(put_BrushType)(LONG lType);
STDMETHOD(get_BrushColor1)(LONG* lColor);
STDMETHOD(put_BrushColor1)(LONG lColor);
STDMETHOD(get_BrushAlpha1)(LONG* lAlpha);
STDMETHOD(put_BrushAlpha1)(LONG lAlpha);
STDMETHOD(get_BrushColor2)(LONG* lColor);
STDMETHOD(put_BrushColor2)(LONG lColor);
STDMETHOD(get_BrushAlpha2)(LONG* lAlpha);
STDMETHOD(put_BrushAlpha2)(LONG lAlpha);
STDMETHOD(get_BrushTexturePath)(BSTR* bsPath);
STDMETHOD(put_BrushTexturePath)(BSTR bsPath);
STDMETHOD(get_BrushTextureMode)(LONG* lMode);
STDMETHOD(put_BrushTextureMode)(LONG lMode);
STDMETHOD(get_BrushTextureAlpha)(LONG* lTxAlpha);
STDMETHOD(put_BrushTextureAlpha)(LONG lTxAlpha);
STDMETHOD(get_BrushLinearAngle)(double* dAngle);
STDMETHOD(put_BrushLinearAngle)(double dAngle);
STDMETHOD(BrushRect)(BOOL val, double left, double top, double width, double height);
STDMETHOD(SetFont)(BSTR bsXML);
STDMETHOD(get_FontName)(BSTR* bsName);
STDMETHOD(put_FontName)(BSTR bsName);
STDMETHOD(get_FontPath)(BSTR* bsName);
STDMETHOD(put_FontPath)(BSTR bsName);
STDMETHOD(get_FontSize)(double* dSize);
STDMETHOD(put_FontSize)(double dSize);
STDMETHOD(get_FontStyle)(LONG* lStyle);
STDMETHOD(put_FontStyle)(LONG lStyle);
STDMETHOD(get_FontStringGID)(BOOL* bGID);
STDMETHOD(put_FontStringGID)(BOOL bGID);
STDMETHOD(get_FontCharSpace)(double* dSpace);
STDMETHOD(put_FontCharSpace)(double dSpace);
STDMETHOD(SetShadow)(BSTR bsXML);
STDMETHOD(get_ShadowDistanceX)(double* val);
STDMETHOD(put_ShadowDistanceX)(double val);
STDMETHOD(get_ShadowDistanceY)(double* val);
STDMETHOD(put_ShadowDistanceY)(double val);
STDMETHOD(get_ShadowBlurSize)(double* val);
STDMETHOD(put_ShadowBlurSize)(double val);
STDMETHOD(get_ShadowColor)(LONG* val);
STDMETHOD(put_ShadowColor)(LONG val);
STDMETHOD(get_ShadowAlpha)(LONG* val);
STDMETHOD(put_ShadowAlpha)(LONG val);
STDMETHOD(get_ShadowVisible)(BOOL* val);
STDMETHOD(put_ShadowVisible)(BOOL val);
STDMETHOD(SetEdgeText)(BSTR bsXML);
STDMETHOD(get_EdgeVisible)(LONG* val);
STDMETHOD(put_EdgeVisible)(LONG val);
STDMETHOD(get_EdgeColor)(LONG* val);
STDMETHOD(put_EdgeColor)(LONG val);
STDMETHOD(get_EdgeAlpha)(LONG* val);
STDMETHOD(put_EdgeAlpha)(LONG val);
STDMETHOD(get_EdgeDist)(double* val);
STDMETHOD(put_EdgeDist)(double val);
//-------- Функции для вывода текста --------------------------------------------------------
STDMETHOD(CommandDrawText)(BSTR bsText, double fX, double fY, double fWidth, double fHeight, double fBaseLineOffset);
STDMETHOD(CommandDrawTextEx)(BSTR bsUnicodeText, BSTR bsGidText, BSTR bsSourceCodeText, double fX, double fY, double fWidth, double fHeight, double fBaseLineOffset, DWORD lFlags);
//-------- Маркеры для команд ---------------------------------------------------------------
STDMETHOD(BeginCommand)(DWORD lType);
STDMETHOD(EndCommand)(DWORD lType);
//-------- Функции для работы с Graphics Path -----------------------------------------------
STDMETHOD(PathCommandMoveTo)(double fX, double fY);
STDMETHOD(PathCommandLineTo)(double fX, double fY);
STDMETHOD(PathCommandLinesTo)(SAFEARRAY* pPoints);
STDMETHOD(PathCommandCurveTo)(double fX1, double fY1, double fX2, double fY2, double fX3, double fY3);
STDMETHOD(PathCommandCurvesTo)(SAFEARRAY* pPoints);
STDMETHOD(PathCommandArcTo)(double fX, double fY, double fWidth, double fHeight, double fStartAngle, double fSweepAngle);
STDMETHOD(PathCommandClose)();
STDMETHOD(PathCommandEnd)();
STDMETHOD(DrawPath)(long nType);
STDMETHOD(PathCommandStart)();
STDMETHOD(PathCommandGetCurrentPoint)(double* fX, double* fY);
STDMETHOD(PathCommandText)(BSTR bsText, double fX, double fY, double fWidth, double fHeight, double fBaseLineOffset);
STDMETHOD(PathCommandTextEx)(BSTR bsUnicodeText, BSTR bsGidText, BSTR bsSourceCodeText, double fX, double fY, double fWidth, double fHeight, double fBaseLineOffset, DWORD lFlags);
STDMETHOD(GetCommandParams)(double* dAngle, double* dLeft, double* dTop, double* dWidth, double* dHeight, DWORD* lFlags);
STDMETHOD(SetCommandParams)(double dAngle, double dLeft, double dTop, double dWidth, double dHeight, DWORD lFlags);
//-------- Функции для вывода изображений --------------------------------------------------
STDMETHOD(DrawImage)(IUnknown* pInterface, double fX, double fY, double fWidth, double fHeight);
STDMETHOD(DrawImageFromFile)(BSTR bstrVal, double fX, double fY, double fWidth, double fHeight);
//------------------------------------------------------------------------------------------
STDMETHOD(SetAdditionalParam)(BSTR ParamName, VARIANT ParamValue);
STDMETHOD(GetAdditionalParam)(BSTR ParamName, VARIANT* ParamValue);
STDMETHOD(SetTransform)(double dA, double dB, double dC, double dD, double dE, double dF);
STDMETHOD(GetTransform)(double *pdA, double *pdB, double *pdC, double *pdD, double *pdE, double *pdF);
STDMETHOD(ResetTransform)(void);
STDMETHOD(get_ClipMode)(LONG* plMode);
STDMETHOD(put_ClipMode)(LONG lMode);
public:
//IAVSDocxRenderer Methods
STDMETHOD(Initialize)(BSTR bsXMLOptions);
STDMETHOD(Save)();
public:
//IAVSDocxRenderer2 Methods
STDMETHOD(CreateOfficeFile)(BSTR bsFileName);
STDMETHOD(CloseFile)();
private:
AVSGraphics::IASCFontManager* m_pFontManager;
NSDocxRenderer::CDocument m_oDocument;
CRITICAL_SECTION m_oCS;
CString m_strDstFilePath;
CString m_strTempFileDir;
CString m_strTempFileName;
void BaseInitialize(BSTR bsXMLOptions)
{
m_oDocument.m_oCurrentPage.m_eTextAssociationType = NSDocxRenderer::TextAssociationTypeNoFrames;
XmlUtils::CXmlReader oXmlReader;
if( TRUE == oXmlReader.OpenFromXmlString( bsXMLOptions ) )
{
if( TRUE == oXmlReader.ReadRootNode( _T( "DocxRenderer" ) ) )
{
m_strTempFileDir = oXmlReader.ReadNodeAttributeOrValue( _T( "destinationpath" ) );
CString textFormatting = oXmlReader.ReadNodeAttributeOrValue( _T( "textformatting" ) );
if ( !textFormatting.IsEmpty() )
{
m_oDocument.m_oCurrentPage.m_eTextAssociationType = (NSDocxRenderer::TextAssociationType)XmlUtils::GetInteger(textFormatting);
}
}
}
}
};

111
DocxRenderer/test/main.cpp Normal file
View File

@ -0,0 +1,111 @@
/*
* (c) Copyright Ascensio System SIA 2010-2019
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha
* street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "../../DesktopEditor/common/Directory.h"
#include "../../DesktopEditor/graphics/pro/Fonts.h"
#include "../../DesktopEditor/graphics/pro/Graphics.h"
#include "../../DesktopEditor/fontengine/ApplicationFontsWorker.h"
#include "../../PdfReader/PdfReader.h"
#include "../../DjVuFile/DjVu.h"
#include "../../XpsFile/XpsFile.h"
#include "../DocxRenderer.h"
#include "../../Common/OfficeFileFormatChecker.h"
int main(int argc, char *argv[])
{
CApplicationFontsWorker oWorker;
oWorker.m_sDirectory = NSFile::GetProcessDirectory() + L"/fonts_cache";
oWorker.m_bIsNeedThumbnails = false;
if (!NSDirectory::Exists(oWorker.m_sDirectory))
NSDirectory::CreateDirectory(oWorker.m_sDirectory);
NSFonts::IApplicationFonts* pFonts = oWorker.Check();
std::wstring sTempDir = NSFile::GetProcessDirectory() + L"/temp";
std::wstring sTempDirOut = NSFile::GetProcessDirectory() + L"/temp/output";
if (!NSDirectory::Exists(sTempDir))
NSDirectory::CreateDirectory(sTempDir);
if (!NSDirectory::Exists(sTempDirOut))
NSDirectory::CreateDirectory(sTempDirOut);
std::wstring sSourceFile = L"PATH_TO_TEST_FILE";
std::wstring sDestFile = NSFile::GetProcessDirectory() + L"/output.docx";
IOfficeDrawingFile* pReader = NULL;
COfficeFileFormatChecker oChecker;
if (oChecker.isOfficeFile(sSourceFile))
{
switch (oChecker.nFileType)
{
case AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDF:
pReader = new PdfReader::CPdfReader(pFonts);
break;
case AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_XPS:
pReader = new CXpsFile(pFonts);
break;
case AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_DJVU:
pReader = new CDjVuFile(pFonts);
break;
default:
break;
}
}
if (!pReader)
{
pFonts->Release();
return 0;
}
pReader->SetTempDirectory(sTempDir);
pReader->LoadFromFile(sSourceFile);
CDocxRenderer oDocxRenderer(pFonts);
// проверить все режимы
NSDocxRenderer::TextAssociationType taType = NSDocxRenderer::TextAssociationTypeNoFrames;
//taType = NSDocxRenderer::TextAssociationTypeLine;
//taType = NSDocxRenderer::TextAssociationTypeBlock;
//taType = NSDocxRenderer::TextAssociationTypeNoFrames;
oDocxRenderer.SetTextAssociationType(taType);
oDocxRenderer.SetTempFolder(sTempDirOut);
oDocxRenderer.Convert(pReader, sDestFile);
delete pReader;
pFonts->Release();
return 0;
}

View File

@ -0,0 +1,30 @@
CONFIG -= qt
QT -= core gui
TARGET = test
CONFIG += console
CONFIG -= app_bundle
CONFIG += c++11
TEMPLATE = app
CORE_ROOT_DIR = $$PWD/../..
PWD_ROOT_DIR = $$PWD
include($$CORE_ROOT_DIR/Common/base.pri)
ADD_DEPENDENCY(UnicodeConverter, kernel, graphics, PdfReader, DjVuFile, XpsFile, PdfWriter, DocxRenderer)
core_linux:include($$PWD/../../Common/3dParty/icu/icu.pri)
core_windows:LIBS += -lgdi32 -ladvapi32 -luser32 -lshell32
core_linux:LIBS += -lz
SOURCES += main.cpp
# for officefilechecker
SOURCES += \
$$CORE_ROOT_DIR/Common/OfficeFileFormatChecker2.cpp \
$$CORE_ROOT_DIR/Common/3dParty/pole/pole.cpp \
$$CORE_ROOT_DIR/Common/DocxFormat/Source/Base/unicode_util.cpp
DESTDIR = $$PWD_ROOT_DIR/build

View File

@ -163,6 +163,10 @@ namespace PdfReader
{
RELEASEOBJECT((m_pInternal->m_pPDFDocument));
}
OfficeDrawingFileType CPdfReader::GetType()
{
return odftPDF;
}
int CPdfReader::GetError()
{
if (!m_pInternal->m_pPDFDocument)

View File

@ -72,6 +72,8 @@ namespace PdfReader
virtual void Close();
virtual OfficeDrawingFileType GetType();
virtual std::wstring GetTempDirectory();
virtual void SetTempDirectory(const std::wstring& directory);

View File

@ -130,6 +130,10 @@ void CXpsFile::Close()
m_pInternal->m_pDocument = NULL;
}
}
OfficeDrawingFileType CXpsFile::GetType()
{
return odftXPS;
}
int CXpsFile::GetPagesCount()
{
if (!m_pInternal->m_pDocument)

View File

@ -54,6 +54,8 @@ public:
virtual void Close();
virtual OfficeDrawingFileType GetType();
virtual std::wstring GetTempDirectory();
virtual void SetTempDirectory(const std::wstring& directory);