mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-04-07 13:55:33 +08:00
Compare commits
229 Commits
v8.3.0.83
...
feature/gr
| Author | SHA1 | Date | |
|---|---|---|---|
| 1fc7ebed19 | |||
| dbf89fcaa3 | |||
| 44c26bc020 | |||
| a3a1c5fc3e | |||
| e3968cec5b | |||
| 20ba78cd7c | |||
| 7043515089 | |||
| 68f070d073 | |||
| b2c6667823 | |||
| 0e563c8461 | |||
| ee47ced36b | |||
| efe6f4408b | |||
| b918f81c2b | |||
| 204bc33610 | |||
| db9fb871a1 | |||
| ccad697cd8 | |||
| dd60367d01 | |||
| 54bbbbc3d7 | |||
| 9b901f7834 | |||
| 4f59af17b8 | |||
| b9258429f6 | |||
| e8f2c55ad4 | |||
| 46f6ba4d0a | |||
| 09b55bd1f1 | |||
| 176053e8d8 | |||
| 01365f938c | |||
| d168e4594f | |||
| cad36a73be | |||
| 27d2e40da7 | |||
| 14b09ce582 | |||
| aeeab690b1 | |||
| 016a0a971b | |||
| afe55a456f | |||
| a430ba92ad | |||
| efc1149235 | |||
| 567cc14bc7 | |||
| 0fc7f2a8b3 | |||
| b14fa1c2a1 | |||
| 2c27cfc720 | |||
| 1d31e5836b | |||
| 6adf65d3a8 | |||
| 093e1348fa | |||
| b78157487a | |||
| 77b30109f0 | |||
| efd047be74 | |||
| 61abfdb272 | |||
| f5088f43d8 | |||
| 6b3c395220 | |||
| 67cb29652d | |||
| d0cb082b33 | |||
| 2eff67efc3 | |||
| 84416ef5b6 | |||
| 447ade207f | |||
| ddd7628bbe | |||
| 1f86b0265a | |||
| e484db496b | |||
| 5bc1c8d860 | |||
| dbdf4bd120 | |||
| a93db0e012 | |||
| f145378002 | |||
| 4e800f6952 | |||
| 8098fec345 | |||
| 7bfcea0fff | |||
| 4b4845c558 | |||
| b26e3e2fee | |||
| 388951670c | |||
| 7d3488abc9 | |||
| fea3910254 | |||
| 2d58b08f0f | |||
| 612142f0ae | |||
| 2a0c84513b | |||
| b7d3464609 | |||
| beb8574dfd | |||
| c22cc89ef0 | |||
| 58255093bf | |||
| 50846677d5 | |||
| 3b450306f1 | |||
| c67ec5f632 | |||
| 62450ee1fb | |||
| ad301b6f50 | |||
| d251682639 | |||
| 896427db83 | |||
| e03f02103b | |||
| 27c7920def | |||
| a1b0421ec1 | |||
| b7972ea391 | |||
| 17840c5ed7 | |||
| ff4726e6ec | |||
| 4e9cd74367 | |||
| b8737d2474 | |||
| 2f4b7442c7 | |||
| d97d2668d2 | |||
| 45da53e9ae | |||
| 618a7ea09e | |||
| a33743cff2 | |||
| a83e19cbdf | |||
| 8a991ae24a | |||
| 6caca87b64 | |||
| 9ab884ae24 | |||
| e493d976e3 | |||
| d75e7342cf | |||
| ddd750be9c | |||
| 79a4434583 | |||
| 44ff2aff3c | |||
| 2f4b3e41b3 | |||
| fe208f5243 | |||
| e41c1d9703 | |||
| 1cb56e532c | |||
| 5c5f98a6e3 | |||
| f9dd82ad47 | |||
| 084c8f4b94 | |||
| bf15325a9e | |||
| 1b50b3a53a | |||
| 70b40c46d2 | |||
| 23798f3c96 | |||
| d91c6ff830 | |||
| b75a577793 | |||
| 1e8d22080d | |||
| 90bcd47fb7 | |||
| c1adf0b30c | |||
| b65ed1ccb4 | |||
| 8e4bbb5e27 | |||
| 81a4d9ccd0 | |||
| a97014c173 | |||
| b3951d083a | |||
| 7d78b37540 | |||
| ff162d451e | |||
| 5dc6402006 | |||
| fae17d9bfc | |||
| 931f4edae4 | |||
| 3609cf1237 | |||
| cc8fa641aa | |||
| 3b9a865d77 | |||
| f3b0a992bd | |||
| 74f3e7f279 | |||
| d195aa4a79 | |||
| 4a384edf08 | |||
| 30f96cbc6c | |||
| 007362d8be | |||
| f4aac048ea | |||
| f815fec8ed | |||
| 4ec217226d | |||
| 3cef41e876 | |||
| 20bff1d6fe | |||
| 8da1a109de | |||
| 7e4fe558f4 | |||
| 6913cae8f3 | |||
| d3d9c8df94 | |||
| 01b582c4b9 | |||
| 87dcea55b1 | |||
| c2dc112949 | |||
| c85713d82a | |||
| 6d970d0706 | |||
| cf047defac | |||
| aa72db079f | |||
| 483ead4243 | |||
| ddd92777b4 | |||
| 07ab24638e | |||
| ffe44155e2 | |||
| 7c2093a4c7 | |||
| 4f6fa2a15c | |||
| 9c70225a9e | |||
| b42e3ad01f | |||
| 3a40dc1f8b | |||
| 6952bedbc3 | |||
| bf299e82bb | |||
| 915790e26e | |||
| e18a26a252 | |||
| 73ccefd720 | |||
| 11385b946d | |||
| 7598e882b8 | |||
| 51cc45d178 | |||
| 9dc3d3ed82 | |||
| 6fe92e1725 | |||
| e512ceedec | |||
| d05a40389e | |||
| ea0494e8c2 | |||
| 127680c988 | |||
| cdbd9bdba3 | |||
| 1910151224 | |||
| cd27981734 | |||
| 9509d5e730 | |||
| 219733c437 | |||
| ad4fee9581 | |||
| 2af29de849 | |||
| 0c847ce1d8 | |||
| f1905b524b | |||
| f742a0ef10 | |||
| 3547ad9c57 | |||
| 0d2248352b | |||
| 012a724069 | |||
| 2e50a2ede4 | |||
| 78d7d40c0a | |||
| dac47c3214 | |||
| be3a84dcf7 | |||
| 22a2079c5f | |||
| fe2bac216f | |||
| d89e94bb8e | |||
| a95aba3ff4 | |||
| a1ebcaea23 | |||
| ab10854dde | |||
| 3f25120e04 | |||
| 44d0a0ca23 | |||
| ec645c0202 | |||
| 63134aa586 | |||
| 8489127f71 | |||
| e024463770 | |||
| 25fa85c218 | |||
| 6e20c656e7 | |||
| a158529c70 | |||
| 87b5ae8f75 | |||
| 1c163421c7 | |||
| d5e7ccac2d | |||
| 925f3614c7 | |||
| 6b21323e8c | |||
| d21d0caa68 | |||
| 63bf1797c0 | |||
| f8ba0c59a6 | |||
| 0553db3a69 | |||
| a7ef6ea3be | |||
| d72b9b47ed | |||
| 7e7186f068 | |||
| 2d61e8bbd2 | |||
| c4c350f1aa | |||
| 2f382d21dc | |||
| a968a3a035 | |||
| deb875337d | |||
| 1b0791364b | |||
| d939aa7247 |
@ -316,7 +316,7 @@ namespace NSCSS
|
||||
|
||||
std::wstring wsTextAlign{oStyle.m_oText.GetAlign().ToWString()};
|
||||
|
||||
if (wsTextAlign.empty() && bInTable)
|
||||
if (wsTextAlign.empty())
|
||||
wsTextAlign = oStyle.m_oDisplay.GetHAlign().ToWString();
|
||||
|
||||
oXmlElement.AddPropertiesInP(PProperties::P_Jc, wsTextAlign);
|
||||
|
||||
@ -68,6 +68,7 @@ public:
|
||||
bool isOOXFormatFile(const std::wstring& fileName, bool unpacked = false);
|
||||
bool isOpenOfficeFormatFile(const std::wstring& fileName, std::wstring& documentID);
|
||||
bool isOnlyOfficeFormatFile(const std::wstring& fileName);
|
||||
bool isMacFormatFile(const std::wstring& fileName);
|
||||
|
||||
bool isDocFormatFile(const std::wstring& fileName);
|
||||
bool isXlsFormatFile(const std::wstring& fileName);
|
||||
@ -80,6 +81,7 @@ public:
|
||||
bool isMS_MITCRYPTOFormatFile(POLE::Storage* storage, std::wstring& documentID);
|
||||
bool isVbaProjectFile(POLE::Storage* storage);
|
||||
bool isMS_OFFCRYPTOFormatFile(const std::wstring& fileName, std::wstring& documentID);
|
||||
bool isHwpFile(POLE::Storage* storage);
|
||||
|
||||
bool iXmlFile(const std::wstring& fileName);
|
||||
|
||||
|
||||
@ -451,6 +451,20 @@ bool COfficeFileFormatChecker::isVbaProjectFile(POLE::Storage *storage)
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool COfficeFileFormatChecker::isHwpFile(POLE::Storage* storage)
|
||||
{
|
||||
if (storage == NULL)
|
||||
return false;
|
||||
|
||||
unsigned char buffer[10];
|
||||
|
||||
POLE::Stream stream(storage, L"BodyText/Section0");
|
||||
if (stream.read(buffer, 10) < 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool COfficeFileFormatChecker::isXlsFormatFile(POLE::Storage *storage)
|
||||
{
|
||||
if (storage == NULL)
|
||||
@ -721,6 +735,11 @@ bool COfficeFileFormatChecker::isOfficeFile(const std::wstring &_fileName)
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_OTHER_MS_VBAPROJECT;
|
||||
return true;
|
||||
}
|
||||
else if (isHwpFile(&storage))
|
||||
{
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_HWP;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
NSFile::CFileBinary file;
|
||||
if (!file.OpenFile(fileName))
|
||||
@ -767,6 +786,13 @@ bool COfficeFileFormatChecker::isOfficeFile(const std::wstring &_fileName)
|
||||
bufferDetect = NULL;
|
||||
return true;
|
||||
}
|
||||
else if (isMacFormatFile(fileName))
|
||||
{
|
||||
if (bufferDetect)
|
||||
delete[] bufferDetect;
|
||||
bufferDetect = NULL;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
@ -1133,6 +1159,58 @@ bool COfficeFileFormatChecker::isOnlyOfficeFormatFile(const std::wstring &fileNa
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool COfficeFileFormatChecker::isMacFormatFile(const std::wstring& fileName)
|
||||
{
|
||||
COfficeUtils OfficeUtils(NULL);
|
||||
|
||||
ULONG nBufferSize = 0;
|
||||
BYTE* pBuffer = NULL;
|
||||
|
||||
HRESULT hresult = OfficeUtils.LoadFileFromArchive(fileName, L"Index/Document.iwa", &pBuffer, nBufferSize);
|
||||
if (hresult == S_OK && pBuffer != NULL)
|
||||
{
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_PAGES;
|
||||
|
||||
delete[] pBuffer;
|
||||
pBuffer = NULL;
|
||||
|
||||
hresult = OfficeUtils.LoadFileFromArchive(fileName, L"Index/Slide.iwa", &pBuffer, nBufferSize);
|
||||
if (hresult == S_OK && pBuffer != NULL)
|
||||
{
|
||||
delete[] pBuffer;
|
||||
pBuffer = NULL;
|
||||
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_PRESENTATION_KEY;
|
||||
return true;
|
||||
}
|
||||
hresult = OfficeUtils.LoadFileFromArchive(fileName, L"Index/Tables/DataList.iwa", &pBuffer, nBufferSize);
|
||||
if (hresult == S_OK && pBuffer != NULL)
|
||||
{
|
||||
delete[] pBuffer;
|
||||
pBuffer = NULL;
|
||||
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_NUMBERS;
|
||||
return true;
|
||||
}
|
||||
std::wstring::size_type nExtPos = fileName.rfind(L'.');
|
||||
std::wstring sExt = L"unknown";
|
||||
|
||||
if (nExtPos != std::wstring::npos)
|
||||
sExt = fileName.substr(nExtPos);
|
||||
|
||||
std::transform(sExt.begin(), sExt.end(), sExt.begin(), tolower);
|
||||
|
||||
if (0 == sExt.compare(L".pages"))
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_PAGES;
|
||||
else if (0 == sExt.compare(L".numbers"))
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_NUMBERS;
|
||||
else if (0 == sExt.compare(L".key"))
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_PRESENTATION_KEY;
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool COfficeFileFormatChecker::isOpenOfficeFormatFile(const std::wstring &fileName, std::wstring &documentID)
|
||||
{
|
||||
documentID.clear();
|
||||
|
||||
60
DesktopEditor/doctrenderer/addon/docbuilder_addon.h
Normal file
60
DesktopEditor/doctrenderer/addon/docbuilder_addon.h
Normal file
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2023
|
||||
*
|
||||
* 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-6 Ernesta Birznieka-Upish
|
||||
* 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
|
||||
*
|
||||
*/
|
||||
#ifndef DOC_BUILDER_ADDON_PRIVATE
|
||||
#define DOC_BUILDER_ADDON_PRIVATE
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace NSDoctRenderer
|
||||
{
|
||||
class CDocBuilderAddon
|
||||
{
|
||||
private:
|
||||
std::wstring m_sWorkDirectory;
|
||||
public:
|
||||
CDocBuilderAddon(const std::wstring& sWorkDir)
|
||||
{
|
||||
m_sWorkDirectory = sWorkDir;
|
||||
}
|
||||
public:
|
||||
std::wstring GetX2tSaveAddon()
|
||||
{
|
||||
return L"";
|
||||
}
|
||||
int GetX2tPreSaveError()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif // DOC_BUILDER_ADDON_PRIVATE
|
||||
@ -191,7 +191,7 @@ namespace NSDoctRenderer
|
||||
m_strSdkPath = oNode.ReadNodeText(L"sdkjs");
|
||||
if (!m_strSdkPath.empty())
|
||||
{
|
||||
if (!NSDirectory::Exists(m_strSdkPath))
|
||||
if (0 == m_strSdkPath.find(L"./") || !NSDirectory::Exists(m_strSdkPath))
|
||||
m_strSdkPath = sConfigDir + m_strSdkPath;
|
||||
}
|
||||
|
||||
|
||||
@ -47,14 +47,6 @@ namespace NSDoctRenderer
|
||||
RELEASEOBJECT(m_pInternal);
|
||||
}
|
||||
|
||||
int CDocBuilder::OpenFile(const wchar_t* path, const wchar_t* params)
|
||||
{
|
||||
m_pInternal->m_nFileType = -1;
|
||||
if (!NSDirectory::Exists(m_pInternal->m_sTmpFolder))
|
||||
NSDirectory::CreateDirectory(m_pInternal->m_sTmpFolder);
|
||||
|
||||
return m_pInternal->OpenFile(path, params);
|
||||
}
|
||||
int CDocBuilder::SaveFile(const int& type, const wchar_t* path, const wchar_t* params)
|
||||
{
|
||||
return m_pInternal->SaveFile(type, path, params);
|
||||
|
||||
@ -526,6 +526,7 @@ namespace NSDoctRenderer
|
||||
CDocBuilder_Private* m_pInternal;
|
||||
|
||||
friend class CBuilderDocumentEmbed;
|
||||
friend class CBuilderEmbed;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@ -82,7 +82,7 @@ CV8RealTimeWorker::~CV8RealTimeWorker()
|
||||
m_context->Dispose();
|
||||
}
|
||||
|
||||
bool CV8RealTimeWorker::ExecuteCommand(const std::wstring& command, NSDoctRenderer::CDocBuilderValue* retValue)
|
||||
bool CV8RealTimeWorker::ExecuteCommand(const std::wstring& command, NSDoctRenderer::CDocBuilderValue* retValue, const bool& isEnterContext)
|
||||
{
|
||||
LOGGER_SPEED_START();
|
||||
|
||||
@ -92,14 +92,20 @@ bool CV8RealTimeWorker::ExecuteCommand(const std::wstring& command, NSDoctRender
|
||||
std::string commandA = U_TO_UTF8(command);
|
||||
//commandA = "Api." + commandA;
|
||||
|
||||
CJSContextScope scope(m_context);
|
||||
if (isEnterContext)
|
||||
m_context->Enter();
|
||||
|
||||
JSSmart<CJSTryCatch> try_catch = m_context->GetExceptions();
|
||||
|
||||
LOGGER_SPEED_LAP("compile_command");
|
||||
|
||||
JSSmart<CJSValue> retNativeVal = m_context->runScript(commandA, try_catch);
|
||||
if(try_catch->Check())
|
||||
{
|
||||
if (isEnterContext)
|
||||
m_context->Exit();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (retValue)
|
||||
{
|
||||
@ -110,6 +116,9 @@ bool CV8RealTimeWorker::ExecuteCommand(const std::wstring& command, NSDoctRender
|
||||
|
||||
LOGGER_SPEED_LAP("run_command");
|
||||
|
||||
if (isEnterContext)
|
||||
m_context->Exit();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -240,6 +249,14 @@ bool CV8RealTimeWorker::InitVariables()
|
||||
if (try_catch->Check())
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_sJSCodeStart.empty())
|
||||
{
|
||||
m_context->runScript(m_sJSCodeStart, try_catch);
|
||||
if (try_catch->Check())
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -336,7 +353,17 @@ bool CV8RealTimeWorker::OpenFile(const std::wstring& sBasePath, const std::wstri
|
||||
return !bIsBreak;
|
||||
}
|
||||
|
||||
bool CV8RealTimeWorker::SaveFileWithChanges(int type, const std::wstring& _path, const std::wstring& sJsonParams)
|
||||
bool CV8RealTimeWorker::NewSimpleJSInstance()
|
||||
{
|
||||
return InitVariables();
|
||||
}
|
||||
|
||||
bool CV8RealTimeWorker::IsSimpleJSInstance()
|
||||
{
|
||||
return (-1 == m_nFileType);
|
||||
}
|
||||
|
||||
bool CV8RealTimeWorker::SaveFileWithChanges(int type, const std::wstring& _path, const std::wstring& sJsonParams, const bool& isEnterContext)
|
||||
{
|
||||
NSDoctRenderer::DoctRendererFormat::FormatFile _formatDst = NSDoctRenderer::DoctRendererFormat::DOCT;
|
||||
if (type & AVS_OFFICESTUDIO_FILE_PRESENTATION)
|
||||
@ -362,7 +389,9 @@ bool CV8RealTimeWorker::SaveFileWithChanges(int type, const std::wstring& _path,
|
||||
}
|
||||
}
|
||||
|
||||
CJSContextScope scope(m_context);
|
||||
if (isEnterContext)
|
||||
m_context->Enter();
|
||||
|
||||
JSSmart<CJSTryCatch> try_catch = m_context->GetExceptions();
|
||||
|
||||
NSNativeControl::CNativeControl* pNative = NULL;
|
||||
@ -391,7 +420,7 @@ bool CV8RealTimeWorker::SaveFileWithChanges(int type, const std::wstring& _path,
|
||||
bIsSilentMode = true;
|
||||
|
||||
if (bIsSilentMode)
|
||||
this->ExecuteCommand(L"Api.asc_SetSilentMode(false);");
|
||||
this->ExecuteCommand(L"Api.asc_SetSilentMode(false);", NULL, isEnterContext);
|
||||
|
||||
std::wstring strError;
|
||||
bool bIsError = Doct_renderer_SaveFile_ForBuilder(_formatDst,
|
||||
@ -403,7 +432,10 @@ bool CV8RealTimeWorker::SaveFileWithChanges(int type, const std::wstring& _path,
|
||||
sJsonParams);
|
||||
|
||||
if (bIsSilentMode)
|
||||
this->ExecuteCommand(L"Api.asc_SetSilentMode(true);");
|
||||
this->ExecuteCommand(L"Api.asc_SetSilentMode(true);", NULL, isEnterContext);
|
||||
|
||||
if (isEnterContext)
|
||||
m_context->Exit();
|
||||
|
||||
return bIsError;
|
||||
}
|
||||
@ -1231,8 +1263,29 @@ namespace NSDoctRenderer
|
||||
nCount = nIndex;
|
||||
}
|
||||
|
||||
int CDocBuilder::OpenFile(const wchar_t* path, const wchar_t* params)
|
||||
{
|
||||
if (m_pInternal->m_nFileType != -1 && m_pInternal->m_bIsOpenedFromSimpleJS)
|
||||
{
|
||||
m_pInternal->m_bIsOpenedFromSimpleJS = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
m_pInternal->m_nFileType = -1;
|
||||
if (!NSDirectory::Exists(m_pInternal->m_sTmpFolder))
|
||||
NSDirectory::CreateDirectory(m_pInternal->m_sTmpFolder);
|
||||
|
||||
return m_pInternal->OpenFile(path, params);
|
||||
}
|
||||
|
||||
bool CDocBuilder::CreateFile(const int& type)
|
||||
{
|
||||
if (m_pInternal->m_nFileType != -1 && m_pInternal->m_bIsOpenedFromSimpleJS)
|
||||
{
|
||||
m_pInternal->m_bIsOpenedFromSimpleJS = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
m_pInternal->m_nFileType = -1;
|
||||
if (!NSDirectory::Exists(m_pInternal->m_sTmpFolder))
|
||||
NSDirectory::CreateDirectory(m_pInternal->m_sTmpFolder);
|
||||
@ -1391,7 +1444,7 @@ namespace NSDoctRenderer
|
||||
if (!sJsCommands.empty())
|
||||
{
|
||||
std::wstring sUnicodeCommand = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)sJsCommands.c_str(), (LONG)sJsCommands.length());
|
||||
bIsNoError = this->ExecuteCommand(sUnicodeCommand.c_str());
|
||||
bIsNoError = this->m_pInternal->ExecuteCommand(sUnicodeCommand.c_str(), NULL, bIsBuilderJSCloseFile);
|
||||
sJsCommands = "";
|
||||
if (!bIsNoError)
|
||||
return false;
|
||||
@ -1413,6 +1466,10 @@ namespace NSDoctRenderer
|
||||
if (0 == _builder_params[nCheckParam].find(L"jsValue(") && _builder_params[nCheckParam].length() > 9)
|
||||
{
|
||||
std::wstring sParam = _builder_params[nCheckParam].substr(8, _builder_params[nCheckParam].length() - 9);
|
||||
|
||||
if (NULL == m_pInternal->m_pWorker)
|
||||
m_pInternal->CheckWorker();
|
||||
|
||||
_builder_params[nCheckParam] = m_pInternal->m_pWorker->GetJSVariable(sParam);
|
||||
}
|
||||
}
|
||||
@ -1478,7 +1535,7 @@ namespace NSDoctRenderer
|
||||
{
|
||||
// Такого быть не должно!!! Так как результат никуда не сохранится. пустое действие.
|
||||
std::wstring sUnicodeCommand = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)sJsCommands.c_str(), (LONG)sJsCommands.length());
|
||||
bool bIsNoError = this->ExecuteCommand(sUnicodeCommand.c_str());
|
||||
bool bIsNoError = this->m_pInternal->ExecuteCommand(sUnicodeCommand.c_str(), NULL, true);
|
||||
sJsCommands = "";
|
||||
if (!bIsNoError)
|
||||
return false;
|
||||
|
||||
@ -63,6 +63,8 @@
|
||||
|
||||
#include "../common/ProcessEnv.h"
|
||||
|
||||
#include "docbuilder_addon.h"
|
||||
|
||||
#ifdef CreateFile
|
||||
#undef CreateFile
|
||||
#endif
|
||||
@ -422,6 +424,7 @@ public:
|
||||
int m_nFileType;
|
||||
std::string m_sUtf8ArgumentJSON;
|
||||
std::string m_sGlobalVariable;
|
||||
std::string m_sJSCodeStart;
|
||||
|
||||
CJSContextData m_oContextData;
|
||||
|
||||
@ -434,14 +437,17 @@ public:
|
||||
|
||||
static void _LOGGING_ERROR_(const std::wstring& strType, const std::wstring& strError);
|
||||
|
||||
bool ExecuteCommand(const std::wstring& command, NSDoctRenderer::CDocBuilderValue* retValue = NULL);
|
||||
bool ExecuteCommand(const std::wstring& command, NSDoctRenderer::CDocBuilderValue* retValue = NULL, const bool& isEnterContext = true);
|
||||
|
||||
std::string GetGlobalVariable();
|
||||
std::wstring GetJSVariable(std::wstring sParam);
|
||||
|
||||
bool OpenFile(const std::wstring& sBasePath, const std::wstring& path, const NSDoctRenderer::DoctRendererEditorType& editorType, NSDoctRenderer::CDoctRendererConfig* config, CV8Params* pParams = NULL);
|
||||
bool SaveFileWithChanges(int type, const std::wstring& _path, const std::wstring& sJsonParams = L"");
|
||||
bool SaveFileWithChanges(int type, const std::wstring& _path, const std::wstring& sJsonParams = L"", const bool& isEnterContext = true);
|
||||
bool InitVariables();
|
||||
|
||||
bool NewSimpleJSInstance();
|
||||
bool IsSimpleJSInstance();
|
||||
};
|
||||
|
||||
namespace NSDoctRenderer
|
||||
@ -455,7 +461,8 @@ namespace NSDoctRenderer
|
||||
std::wstring m_sTmpFolder;
|
||||
std::wstring m_sFileDir;
|
||||
int m_nFileType;
|
||||
bool m_bJavascriptBeforeEditor;
|
||||
|
||||
std::wstring m_sCommandsBeforeContextCreated;
|
||||
|
||||
std::wstring m_sX2tPath;
|
||||
|
||||
@ -474,11 +481,13 @@ namespace NSDoctRenderer
|
||||
|
||||
NSDoctRenderer::CDocBuilder* m_pParent;
|
||||
|
||||
bool m_bIsOpenedFromSimpleJS;
|
||||
|
||||
static std::wstring m_sExternalDirectory;
|
||||
public:
|
||||
CDocBuilder_Private() : CDoctRendererConfig(), m_sTmpFolder(NSFile::CFileBinary::GetTempPath()), m_nFileType(-1),
|
||||
m_pWorker(NULL), m_pAdditionalData(NULL), m_bIsInit(false), m_bIsServerSafeVersion(false),
|
||||
m_sGlobalVariable(""), m_bIsGlobalVariableUse(false), m_pParent(NULL), m_bJavascriptBeforeEditor(false)
|
||||
m_sGlobalVariable(""), m_bIsGlobalVariableUse(false), m_pParent(NULL), m_sCommandsBeforeContextCreated(L""), m_bIsOpenedFromSimpleJS(false)
|
||||
{
|
||||
}
|
||||
|
||||
@ -637,10 +646,14 @@ namespace NSDoctRenderer
|
||||
{
|
||||
NSDirectory::CreateDirectory(m_sFileDir + L"/media");
|
||||
NSDirectory::CreateDirectory(m_sFileDir + L"/changes");
|
||||
}
|
||||
|
||||
if (m_bJavascriptBeforeEditor)
|
||||
CheckWorkerAfterOpen();
|
||||
if (m_pWorker && m_pWorker->IsSimpleJSInstance() && !m_bIsOpenedFromSimpleJS)
|
||||
{
|
||||
RELEASEOBJECT(m_pWorker);
|
||||
CheckWorker();
|
||||
}
|
||||
return bRet;
|
||||
}
|
||||
|
||||
return bRet;
|
||||
#else
|
||||
@ -931,8 +944,11 @@ namespace NSDoctRenderer
|
||||
|
||||
if (0 == nReturnCode)
|
||||
{
|
||||
if (m_bJavascriptBeforeEditor)
|
||||
CheckWorkerAfterOpen();
|
||||
if (m_pWorker && m_pWorker->IsSimpleJSInstance() && !m_bIsOpenedFromSimpleJS)
|
||||
{
|
||||
RELEASEOBJECT(m_pWorker);
|
||||
CheckWorker();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -981,10 +997,16 @@ namespace NSDoctRenderer
|
||||
return _path;
|
||||
}
|
||||
|
||||
int SaveFile(const int& type, const std::wstring& path, const wchar_t* params = NULL)
|
||||
int SaveFile(const int& type, const std::wstring& path, const wchar_t* params = NULL, const bool& isEnterContext = true)
|
||||
{
|
||||
Init();
|
||||
|
||||
CDocBuilderAddon oSaveAddon(m_sX2tPath);
|
||||
|
||||
int nPreSaveError = oSaveAddon.GetX2tPreSaveError();
|
||||
if (0 != nPreSaveError)
|
||||
return nPreSaveError;
|
||||
|
||||
if (-1 == m_nFileType)
|
||||
{
|
||||
CV8RealTimeWorker::_LOGGING_ERROR_(L"error (save)", L"file not opened!");
|
||||
@ -1023,7 +1045,7 @@ namespace NSDoctRenderer
|
||||
}
|
||||
}
|
||||
|
||||
this->m_pWorker->SaveFileWithChanges(type, m_sFileDir + L"/Editor2.bin", sJsonParams);
|
||||
this->m_pWorker->SaveFileWithChanges(type, m_sFileDir + L"/Editor2.bin", sJsonParams, isEnterContext);
|
||||
sFileBin = L"/Editor2.bin";
|
||||
}
|
||||
|
||||
@ -1068,6 +1090,8 @@ namespace NSDoctRenderer
|
||||
if (!sOptions.empty())
|
||||
oBuilder.WriteString(UTF8_TO_U(sOptions));
|
||||
|
||||
oBuilder.WriteString(oSaveAddon.GetX2tSaveAddon());
|
||||
|
||||
oBuilder.WriteString(L"</TaskQueueDataConvert>");
|
||||
|
||||
std::wstring sXmlConvert = oBuilder.GetData();
|
||||
@ -1220,62 +1244,75 @@ namespace NSDoctRenderer
|
||||
{
|
||||
if (NULL == m_pWorker)
|
||||
{
|
||||
m_pWorker = new CV8RealTimeWorker(m_pParent, GetEditorType(), this);
|
||||
NSDoctRenderer::DoctRendererEditorType editorType = GetEditorType();
|
||||
m_pWorker = new CV8RealTimeWorker(m_pParent, editorType, this);
|
||||
m_pWorker->m_sUtf8ArgumentJSON = m_oParams.m_sArgumentJSON;
|
||||
m_pWorker->m_sGlobalVariable = m_sGlobalVariable;
|
||||
m_pWorker->m_sJSCodeStart = U_TO_UTF8(m_sCommandsBeforeContextCreated);
|
||||
|
||||
return CheckWorkerAfterOpen();
|
||||
m_pWorker->m_nFileType = m_nFileType;
|
||||
|
||||
if (-1 != m_nFileType)
|
||||
m_sCommandsBeforeContextCreated = L"";
|
||||
else
|
||||
{
|
||||
m_pWorker->NewSimpleJSInstance();
|
||||
return true;
|
||||
}
|
||||
|
||||
CV8Params oParams;
|
||||
oParams.IsServerSaveVersion = m_bIsServerSafeVersion;
|
||||
oParams.DocumentDirectory = m_sFileDir;
|
||||
|
||||
return m_pWorker->OpenFile(m_sX2tPath, m_sFileDir, editorType, this, &oParams);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CheckWorkerAfterOpen()
|
||||
{
|
||||
if (!m_pWorker)
|
||||
return false;
|
||||
|
||||
m_pWorker->m_nFileType = m_nFileType;
|
||||
if (-1 == m_nFileType)
|
||||
{
|
||||
m_bJavascriptBeforeEditor = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
m_bJavascriptBeforeEditor = false;
|
||||
|
||||
CV8Params oParams;
|
||||
oParams.IsServerSaveVersion = m_bIsServerSafeVersion;
|
||||
oParams.DocumentDirectory = m_sFileDir;
|
||||
|
||||
return m_pWorker->OpenFile(m_sX2tPath, m_sFileDir, GetEditorType(), this, &oParams);
|
||||
}
|
||||
|
||||
int SaveFile(const std::wstring& ext, const std::wstring& path, const wchar_t* params = NULL)
|
||||
{
|
||||
int nType = GetFormatByTexExtention(ext);
|
||||
return SaveFile(nType, path, params);
|
||||
}
|
||||
|
||||
bool ExecuteCommand(const std::wstring& command, CDocBuilderValue* retValue = NULL)
|
||||
bool ExecuteCommand(const std::wstring& command, CDocBuilderValue* retValue = NULL, const bool& forceExecute = false)
|
||||
{
|
||||
if (command.length() < 7 && !retValue) // minimum command (!!!)
|
||||
return true;
|
||||
|
||||
if (m_nFileType == -1 && !forceExecute)
|
||||
{
|
||||
m_sCommandsBeforeContextCreated += command;
|
||||
return true;
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
bool bRes = CheckWorker();
|
||||
if (CheckWorker())
|
||||
{
|
||||
bool bIsOpenedFromSimpleJSOld = m_bIsOpenedFromSimpleJS;
|
||||
bool bResult = m_pWorker->ExecuteCommand(command, retValue);
|
||||
if (!bResult && !bIsOpenedFromSimpleJSOld && m_bIsOpenedFromSimpleJS)
|
||||
{
|
||||
RELEASEOBJECT(m_pWorker);
|
||||
CheckWorker();
|
||||
return m_pWorker->ExecuteCommand(command, retValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
return bResult;
|
||||
}
|
||||
}
|
||||
|
||||
if (!bRes && m_pWorker && m_bJavascriptBeforeEditor)
|
||||
m_pWorker->InitVariables();
|
||||
|
||||
return m_pWorker->ExecuteCommand(command, retValue);
|
||||
return false;
|
||||
}
|
||||
|
||||
CDocBuilderContext GetContext(bool enterContext)
|
||||
{
|
||||
CDocBuilderContext ctx;
|
||||
|
||||
CheckWorker();
|
||||
if (!CheckWorker())
|
||||
return ctx;
|
||||
|
||||
ctx.m_internal->m_context = m_pWorker->m_context;
|
||||
ctx.m_internal->m_context_data = &m_pWorker->m_oContextData;
|
||||
|
||||
130
DesktopEditor/doctrenderer/doctrenderer.pri
Normal file
130
DesktopEditor/doctrenderer/doctrenderer.pri
Normal file
@ -0,0 +1,130 @@
|
||||
QT -= core
|
||||
QT -= gui
|
||||
|
||||
VERSION = 1.0.0.3
|
||||
TARGET = doctrenderer
|
||||
TEMPLATE = lib
|
||||
|
||||
CONFIG += shared
|
||||
CONFIG += plugin
|
||||
|
||||
CORE_ROOT_DIR = $$PWD/../..
|
||||
PWD_ROOT_DIR = $$PWD
|
||||
|
||||
PWD_CUR = $$PWD
|
||||
include($$PWD_CUR/../../Common/base.pri)
|
||||
|
||||
DEFINES += DOCTRENDERER_USE_DYNAMIC_LIBRARY_BUILDING
|
||||
DEFINES += JSBASE_USE_DYNAMIC_LIBRARY_BUILDING
|
||||
ADD_DEPENDENCY(graphics, kernel, UnicodeConverter, kernel_network)
|
||||
|
||||
#CONFIG += build_xp
|
||||
#CONFIG += v8_version_60
|
||||
core_android:DEFINES += DISABLE_MEMORY_LIMITATION
|
||||
|
||||
HEADERS += \
|
||||
$$PWD_CUR/config.h \
|
||||
$$PWD_CUR/editors.h \
|
||||
$$PWD_CUR/doctrenderer.h \
|
||||
$$PWD_CUR/docbuilder.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD_CUR/editors.cpp \
|
||||
$$PWD_CUR/nativecontrol.cpp \
|
||||
$$PWD_CUR/doctrenderer.cpp \
|
||||
$$PWD_CUR/docbuilder.cpp \
|
||||
$$PWD_CUR/docbuilder_p.cpp \
|
||||
$$PWD_CUR/graphics.cpp \
|
||||
$$PWD_CUR/hash.cpp
|
||||
|
||||
SOURCES += \
|
||||
$$PWD_CUR/../../Common/OfficeFileFormatChecker2.cpp \
|
||||
$$PWD_CUR/../../Common/3dParty/pole/pole.cpp \
|
||||
$$PWD_CUR/../../OOXML/Base/unicode_util.cpp
|
||||
|
||||
HEADERS += \
|
||||
$$PWD_CUR/docbuilder_p.h \
|
||||
$$PWD_CUR/nativecontrol.h \
|
||||
$$PWD_CUR/graphics.h \
|
||||
$$PWD_CUR/hash.h \
|
||||
$$PWD_CUR/server.h
|
||||
|
||||
HEADERS += \
|
||||
$$PWD_CUR/embed/PointerEmbed.h \
|
||||
$$PWD_CUR/embed/ZipEmbed.h \
|
||||
$$PWD_CUR/embed/GraphicsEmbed.h \
|
||||
$$PWD_CUR/embed/MemoryStreamEmbed.h \
|
||||
$$PWD_CUR/embed/NativeControlEmbed.h \
|
||||
$$PWD_CUR/embed/NativeBuilderEmbed.h \
|
||||
$$PWD_CUR/embed/NativeBuilderDocumentEmbed.h \
|
||||
$$PWD_CUR/embed/TextMeasurerEmbed.h \
|
||||
$$PWD_CUR/embed/HashEmbed.h \
|
||||
$$PWD_CUR/embed/Default.h \
|
||||
$$PWD_CUR/js_internal/js_base.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD_CUR/embed/PointerEmbed.cpp \
|
||||
$$PWD_CUR/embed/ZipEmbed.cpp \
|
||||
$$PWD_CUR/embed/GraphicsEmbed.cpp \
|
||||
$$PWD_CUR/embed/MemoryStreamEmbed.cpp \
|
||||
$$PWD_CUR/embed/NativeControlEmbed.cpp \
|
||||
$$PWD_CUR/embed/NativeBuilderEmbed.cpp \
|
||||
$$PWD_CUR/embed/NativeBuilderDocumentEmbed.cpp \
|
||||
$$PWD_CUR/embed/TextMeasurerEmbed.cpp \
|
||||
$$PWD_CUR/embed/HashEmbed.cpp \
|
||||
$$PWD_CUR/embed/Default.cpp
|
||||
|
||||
# Serialize objects to JS
|
||||
HEADERS += \
|
||||
$$PWD_CUR/json/json.h \
|
||||
$$PWD_CUR/json/json_p.h \
|
||||
$$PWD_CUR/json/json_values.h \
|
||||
$$PWD_CUR/json/serialization.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD_CUR/json/json.cpp \
|
||||
$$PWD_CUR/json/json_values.cpp
|
||||
|
||||
include($$PWD_CUR/js_internal/js_base.pri)
|
||||
|
||||
!use_javascript_core {
|
||||
build_xp:DESTDIR=$$DESTDIR/xp
|
||||
}
|
||||
|
||||
use_javascript_core {
|
||||
OBJECTIVE_SOURCES += $$PWD_CUR/../common/Mac/NSString+StringUtils.mm
|
||||
}
|
||||
|
||||
# files for embedded classes
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER($$PWD_CUR/embed/GraphicsEmbed.h)
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER($$PWD_CUR/embed/HashEmbed.h)
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER($$PWD_CUR/embed/MemoryStreamEmbed.h)
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER($$PWD_CUR/embed/NativeBuilderEmbed.h)
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER($$PWD_CUR/embed/NativeBuilderDocumentEmbed.h)
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER($$PWD_CUR/embed/NativeControlEmbed.h)
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER($$PWD_CUR/embed/PointerEmbed.h)
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER($$PWD_CUR/embed/TextMeasurerEmbed.h)
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER($$PWD_CUR/embed/ZipEmbed.h)
|
||||
|
||||
include($$PWD_CUR/../graphics/pro/textshaper.pri)
|
||||
include($$PWD_CUR/../../Common/3dParty/openssl/openssl.pri)
|
||||
|
||||
# downloader
|
||||
DEFINES += BUIDLER_OPEN_DOWNLOAD_ENABLED
|
||||
DEFINES += BUIDLER_OPEN_BASE64_ENABLED
|
||||
|
||||
CONFIG += drawingfile_support
|
||||
drawingfile_support {
|
||||
DEFINES += WASM_SERIALIZER_USE_ALLOCATOR
|
||||
ADD_DEPENDENCY(PdfFile, XpsFile, DjVuFile, DocxRenderer)
|
||||
|
||||
HEADERS += \
|
||||
$$PWD_CUR/drawingfile.h \
|
||||
$$PWD_CUR/embed/DrawingFileEmbed.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD_CUR/../graphics/pro/js/wasm/src/HTMLRendererText.cpp \
|
||||
$$PWD_CUR/embed/DrawingFileEmbed.cpp
|
||||
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER($$PWD_CUR/embed/DrawingFileEmbed.h)
|
||||
}
|
||||
@ -1,128 +1,3 @@
|
||||
QT -= core
|
||||
QT -= gui
|
||||
INCLUDEPATH += $$PWD/addon
|
||||
|
||||
VERSION = 1.0.0.3
|
||||
TARGET = doctrenderer
|
||||
TEMPLATE = lib
|
||||
|
||||
CONFIG += shared
|
||||
CONFIG += plugin
|
||||
|
||||
CORE_ROOT_DIR = $$PWD/../..
|
||||
PWD_ROOT_DIR = $$PWD
|
||||
include(../../Common/base.pri)
|
||||
|
||||
DEFINES += DOCTRENDERER_USE_DYNAMIC_LIBRARY_BUILDING
|
||||
DEFINES += JSBASE_USE_DYNAMIC_LIBRARY_BUILDING
|
||||
ADD_DEPENDENCY(graphics, kernel, UnicodeConverter, kernel_network)
|
||||
|
||||
#CONFIG += build_xp
|
||||
#CONFIG += v8_version_60
|
||||
core_android:DEFINES += DISABLE_MEMORY_LIMITATION
|
||||
|
||||
HEADERS += \
|
||||
config.h \
|
||||
editors.h \
|
||||
doctrenderer.h \
|
||||
docbuilder.h
|
||||
|
||||
SOURCES += \
|
||||
editors.cpp \
|
||||
nativecontrol.cpp \
|
||||
doctrenderer.cpp \
|
||||
docbuilder.cpp \
|
||||
docbuilder_p.cpp \
|
||||
graphics.cpp \
|
||||
hash.cpp
|
||||
|
||||
SOURCES += \
|
||||
../../Common/OfficeFileFormatChecker2.cpp \
|
||||
../../Common/3dParty/pole/pole.cpp \
|
||||
../../OOXML/Base/unicode_util.cpp
|
||||
|
||||
HEADERS += \
|
||||
docbuilder_p.h \
|
||||
nativecontrol.h \
|
||||
graphics.h \
|
||||
hash.h \
|
||||
server.h
|
||||
|
||||
HEADERS += \
|
||||
embed/PointerEmbed.h \
|
||||
embed/ZipEmbed.h \
|
||||
embed/GraphicsEmbed.h \
|
||||
embed/MemoryStreamEmbed.h \
|
||||
embed/NativeControlEmbed.h \
|
||||
embed/NativeBuilderEmbed.h \
|
||||
embed/NativeBuilderDocumentEmbed.h \
|
||||
embed/TextMeasurerEmbed.h \
|
||||
embed/HashEmbed.h \
|
||||
embed/Default.h \
|
||||
js_internal/js_base.h
|
||||
|
||||
SOURCES += \
|
||||
embed/PointerEmbed.cpp \
|
||||
embed/ZipEmbed.cpp \
|
||||
embed/GraphicsEmbed.cpp \
|
||||
embed/MemoryStreamEmbed.cpp \
|
||||
embed/NativeControlEmbed.cpp \
|
||||
embed/NativeBuilderEmbed.cpp \
|
||||
embed/NativeBuilderDocumentEmbed.cpp \
|
||||
embed/TextMeasurerEmbed.cpp \
|
||||
embed/HashEmbed.cpp \
|
||||
embed/Default.cpp
|
||||
|
||||
# Serialize objects to JS
|
||||
HEADERS += \
|
||||
json/json.h \
|
||||
json/json_p.h \
|
||||
json/json_values.h \
|
||||
json/serialization.h
|
||||
|
||||
SOURCES += \
|
||||
json/json.cpp \
|
||||
json/json_values.cpp
|
||||
|
||||
include($$PWD/js_internal/js_base.pri)
|
||||
|
||||
!use_javascript_core {
|
||||
build_xp:DESTDIR=$$DESTDIR/xp
|
||||
}
|
||||
|
||||
use_javascript_core {
|
||||
OBJECTIVE_SOURCES += ../common/Mac/NSString+StringUtils.mm
|
||||
}
|
||||
|
||||
# files for embedded classes
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER(embed/GraphicsEmbed.h)
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER(embed/HashEmbed.h)
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER(embed/MemoryStreamEmbed.h)
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER(embed/NativeBuilderEmbed.h)
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER(embed/NativeBuilderDocumentEmbed.h)
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER(embed/NativeControlEmbed.h)
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER(embed/PointerEmbed.h)
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER(embed/TextMeasurerEmbed.h)
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER(embed/ZipEmbed.h)
|
||||
|
||||
include(../graphics/pro/textshaper.pri)
|
||||
include(../../Common/3dParty/openssl/openssl.pri)
|
||||
|
||||
# downloader
|
||||
DEFINES += BUIDLER_OPEN_DOWNLOAD_ENABLED
|
||||
DEFINES += BUIDLER_OPEN_BASE64_ENABLED
|
||||
|
||||
CONFIG += drawingfile_support
|
||||
drawingfile_support {
|
||||
DEFINES += WASM_SERIALIZER_USE_ALLOCATOR
|
||||
ADD_DEPENDENCY(PdfFile, XpsFile, DjVuFile, DocxRenderer)
|
||||
|
||||
HEADERS += \
|
||||
drawingfile.h \
|
||||
embed/DrawingFileEmbed.h
|
||||
|
||||
SOURCES += \
|
||||
../graphics/pro/js/wasm/src/HTMLRendererText.cpp \
|
||||
embed/DrawingFileEmbed.cpp
|
||||
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER(embed/DrawingFileEmbed.h)
|
||||
}
|
||||
include(doctrenderer.pri)
|
||||
|
||||
@ -125,10 +125,6 @@ namespace NSDoctRenderer
|
||||
AppendScript(builder, config->m_strSdkPath + L"/pdf/src/engine/drawingfile_native.js");
|
||||
AppendScript(builder, config->m_strSdkPath + L"/pdf/src/annotations/stamps.json", "window[\"native_pdf_stamps\"]=", ";");
|
||||
sCachePath = config->m_strSdkPath + L"/pdf/sdk-all";
|
||||
|
||||
std::string ss = builder->GetData();
|
||||
NSFile::CFileBinary::SaveToFile(L"D:\\222.js", UTF8_TO_U(ss));
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
||||
@ -160,16 +160,30 @@ void CGraphicsEmbed::SetAppImage(CGraphicsAppImage* appImage)
|
||||
|
||||
JSSmart<CJSValue> CGraphicsEmbed::create(JSSmart<CJSValue> Native, JSSmart<CJSValue> width_px, JSSmart<CJSValue> height_px, JSSmart<CJSValue> width_mm, JSSmart<CJSValue> height_mm)
|
||||
{
|
||||
NSNativeControl::CNativeControl* pControl = NULL;
|
||||
if (!Native->isNull())
|
||||
{
|
||||
pControl = (NSNativeControl::CNativeControl*)Native->toObject()->getNative()->getObject();
|
||||
JSSmart<CJSObject> pNativeObject = Native->toObject();
|
||||
CJSEmbedObject* pNativeEmbedObject = pNativeObject->getNative();
|
||||
|
||||
if (m_pInternal->m_pAppImage)
|
||||
delete m_pInternal->m_pAppImage;
|
||||
m_pInternal->m_pAppImage = new CGraphicsAppImage();
|
||||
m_pInternal->m_pAppImage->SetFontsDirectory(pControl->m_strFontsDirectory);
|
||||
m_pInternal->m_pAppImage->SetImagesDirectory(pControl->m_strImagesDirectory);
|
||||
|
||||
if (pNativeEmbedObject)
|
||||
{
|
||||
NSNativeControl::CNativeControl* pControl = (NSNativeControl::CNativeControl*)pNativeEmbedObject->getObject();
|
||||
m_pInternal->m_pAppImage->SetFontsDirectory(pControl->m_strFontsDirectory);
|
||||
m_pInternal->m_pAppImage->SetImagesDirectory(pControl->m_strImagesDirectory);
|
||||
}
|
||||
else
|
||||
{
|
||||
JSSmart<CJSValue> checkResources = pNativeObject->get("isResourcesObject");
|
||||
if (checkResources->isBool() && true == checkResources->toBool())
|
||||
{
|
||||
m_pInternal->m_pAppImage->SetFontsDirectory(pNativeObject->get("fontsDirectory")->toStringW());
|
||||
m_pInternal->m_pAppImage->SetImagesDirectory(pNativeObject->get("imagesDirectory")->toStringW());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_pInternal->init(width_px->toDouble(), height_px->toDouble(), width_mm->toDouble(), height_mm->toDouble());
|
||||
|
||||
@ -8,7 +8,22 @@ JSSmart<CJSValue> CBuilderEmbed::OpenFile(JSSmart<CJSValue> sPath, JSSmart<CJSVa
|
||||
{
|
||||
std::wstring Path = sPath->toStringW();
|
||||
std::wstring Params = sParams->toStringW();
|
||||
|
||||
// Since we now use snapshots, and we can't always determine which editor is needed
|
||||
// (since the code may be BEFORE opening the file). And if the opening came from
|
||||
// builderJS.OpenFile - in this case we skip reopening.
|
||||
NSDoctRenderer::CDocBuilder_Private* pPrivate = GetPrivate();
|
||||
if (pPrivate->m_pWorker->IsSimpleJSInstance())
|
||||
pPrivate->m_bIsOpenedFromSimpleJS = true;
|
||||
|
||||
int ret = m_pBuilder->OpenFile(Path.c_str(), Params.c_str());
|
||||
|
||||
if (pPrivate->m_pWorker->IsSimpleJSInstance())
|
||||
{
|
||||
JSSmart<CJSContext> current = CJSContext::GetCurrent();
|
||||
current->runScript("throw 0;");
|
||||
}
|
||||
|
||||
return CJSContext::createInt(ret);
|
||||
}
|
||||
|
||||
@ -20,7 +35,21 @@ JSSmart<CJSValue> CBuilderEmbed::CreateFile(JSSmart<CJSValue> type)
|
||||
else
|
||||
nFormat = type->toInt32();
|
||||
|
||||
// Since we now use snapshots, and we can't always determine which editor is needed
|
||||
// (since the code may be BEFORE opening the file). And if the opening came from
|
||||
// builderJS.OpenFile - in this case we skip reopening.
|
||||
NSDoctRenderer::CDocBuilder_Private* pPrivate = GetPrivate();
|
||||
if (pPrivate->m_pWorker->IsSimpleJSInstance())
|
||||
pPrivate->m_bIsOpenedFromSimpleJS = true;
|
||||
|
||||
bool ret = m_pBuilder->CreateFile(nFormat);
|
||||
|
||||
if (pPrivate->m_pWorker->IsSimpleJSInstance())
|
||||
{
|
||||
JSSmart<CJSContext> current = CJSContext::GetCurrent();
|
||||
current->runScript("throw 0;");
|
||||
}
|
||||
|
||||
return CJSContext::createBool(ret);
|
||||
}
|
||||
|
||||
@ -41,7 +70,7 @@ JSSmart<CJSValue> CBuilderEmbed::SaveFile(JSSmart<CJSValue> type, JSSmart<CJSVal
|
||||
|
||||
std::wstring sPath = path->toStringW();
|
||||
std::wstring sParams = params->toStringW();
|
||||
int ret = m_pBuilder->SaveFile(nFormat, sPath.c_str(), sParams.empty() ? NULL : sParams.c_str());
|
||||
int ret = GetPrivate()->SaveFile(nFormat, sPath.c_str(), sParams.empty() ? NULL : sParams.c_str(), false);
|
||||
return CJSContext::createInt(ret);
|
||||
}
|
||||
|
||||
|
||||
@ -50,6 +50,7 @@ public:
|
||||
~CBuilderEmbed() { if(m_pBuilder) RELEASEOBJECT(m_pBuilder); }
|
||||
|
||||
virtual void* getObject() { return (void*)m_pBuilder; }
|
||||
NSDoctRenderer::CDocBuilder_Private* GetPrivate() { return m_pBuilder->GetPrivate(); }
|
||||
|
||||
public:
|
||||
JSSmart<CJSValue> OpenFile(JSSmart<CJSValue> sPath, JSSmart<CJSValue> sParams);
|
||||
|
||||
@ -374,7 +374,7 @@ namespace NSJSBase
|
||||
|
||||
JSSmart<CJSContext> CJSContext::GetCurrent()
|
||||
{
|
||||
CJSContext* ret = new CJSContext();
|
||||
CJSContext* ret = new CJSContext(false);
|
||||
ret->m_internal->context = NSJSBase::CJSContextPrivate::GetCurrentContext();
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -351,11 +351,17 @@ CFontManager::~CFontManager()
|
||||
RELEASEINTERFACE(m_pFont);
|
||||
RELEASEOBJECT(m_pOwnerCache);
|
||||
}
|
||||
|
||||
void CFontManager::SetOwnerCache(NSFonts::IFontsCache* pCache)
|
||||
{
|
||||
m_pOwnerCache = (CFontsCache*)pCache;
|
||||
}
|
||||
|
||||
void CFontManager::ClearOwnerCache()
|
||||
{
|
||||
m_pOwnerCache->Clear();
|
||||
}
|
||||
|
||||
NSFonts::IFontsCache* CFontManager::GetCache() { return m_pOwnerCache; }
|
||||
NSFonts::IApplicationFonts* CFontManager::GetApplication() { return m_pApplication; }
|
||||
NSFonts::IFontFile* CFontManager::GetFile() { return m_pFont; }
|
||||
|
||||
@ -132,6 +132,7 @@ public:
|
||||
|
||||
virtual void Initialize();
|
||||
virtual void SetOwnerCache(NSFonts::IFontsCache* pCache);
|
||||
virtual void ClearOwnerCache();
|
||||
|
||||
virtual NSFonts::IFontsCache* GetCache();
|
||||
virtual NSFonts::IApplicationFonts* GetApplication();
|
||||
|
||||
@ -100,6 +100,7 @@
|
||||
"FT_CONFIG_OPTION_SYSTEM_ZLIB",
|
||||
"GRAPHICS_NO_USE_DYNAMIC_LIBRARY",
|
||||
"HYPHEN_ENGINE_DISABLE_FILESYSTEM",
|
||||
"METAFILE_DISABLE_FILESYSTEM",
|
||||
|
||||
"HAVE_UNISTD_H", "HAVE_FCNTL_H", "_ARM_ALIGN_",
|
||||
"METAFILE_SUPPORT_WMF_EMF",
|
||||
@ -259,10 +260,13 @@
|
||||
"folder": "../../../OfficeUtils/js",
|
||||
"files": ["../src/ZipBuffer.cpp", "wasm/src/base.cpp", "../src/zlib_addon.c"]
|
||||
},
|
||||
|
||||
{
|
||||
"folder": "../../",
|
||||
"files": ["graphics/Image.cpp", "raster/BgraFrame.cpp", "raster/ImageFileFormatChecker.cpp"]
|
||||
"files": ["graphics/Image.cpp", "raster/BgraFrame.cpp", "raster/ImageFileFormatChecker.cpp", "graphics/Matrix.cpp"]
|
||||
},
|
||||
{
|
||||
"folder": "../../agg-2.4/src/",
|
||||
"files": ["agg_trans_affine.cpp"]
|
||||
},
|
||||
{
|
||||
"folder": "../../raster/",
|
||||
|
||||
@ -33,479 +33,647 @@
|
||||
|
||||
namespace Aggplus
|
||||
{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CBrush::CBrush(BrushType bType) : m_bType(bType)
|
||||
CBrush::CBrush()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CBrush::CBrush(const BrushType& type)
|
||||
: m_bType(type)
|
||||
{
|
||||
}
|
||||
|
||||
CBrush::~CBrush()
|
||||
{
|
||||
}
|
||||
|
||||
BrushType CBrush::GetType() const
|
||||
{
|
||||
return m_bType;
|
||||
BrushType CBrush::GetType() const
|
||||
{
|
||||
return m_bType;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CBrushSolid::CBrushSolid(CColor dwColor) : CBrush(BrushTypeSolidColor), m_dwColor(dwColor)
|
||||
CBrushSolid::CBrushSolid() : CBrush()
|
||||
{
|
||||
}
|
||||
CBrushSolid::~CBrushSolid()
|
||||
|
||||
CBrushSolid::CBrushSolid(CColor color)
|
||||
: CBrush(),
|
||||
m_dwColor(color)
|
||||
{
|
||||
}
|
||||
CBrush* CBrushSolid::Clone() const
|
||||
{
|
||||
return new CBrushSolid(m_dwColor);
|
||||
|
||||
CBrushSolid::CBrushSolid(const CBrushSolid& other) : CBrush()
|
||||
{
|
||||
*this = other;
|
||||
}
|
||||
|
||||
void CBrushSolid::GetColor(CColor* color) const { *color = m_dwColor; }
|
||||
void CBrushSolid::SetColor(const CColor &color) { m_dwColor = color; }
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CBrushHatch::CBrushHatch() : CBrush(BrushTypeHatchFill)
|
||||
CBrushSolid::~CBrushSolid()
|
||||
{
|
||||
}
|
||||
CBrushHatch::~CBrushHatch()
|
||||
|
||||
void CBrushSolid::GetColor(CColor* color) const
|
||||
{
|
||||
*color = m_dwColor;
|
||||
}
|
||||
|
||||
void CBrushSolid::SetColor(const CColor &color)
|
||||
{
|
||||
m_dwColor = color;
|
||||
}
|
||||
|
||||
CBrushSolid& CBrushSolid::operator=(const CBrushSolid& other)
|
||||
{
|
||||
if (this == &other)
|
||||
return *this;
|
||||
|
||||
m_dwColor = other.m_dwColor;
|
||||
return *this;
|
||||
}
|
||||
|
||||
CBrushHatch::CBrushHatch()
|
||||
: CBrush(BrushTypeHatchFill)
|
||||
{
|
||||
}
|
||||
CBrush* CBrushHatch::Clone() const
|
||||
{
|
||||
CBrushHatch* clone = new CBrushHatch();
|
||||
clone->m_name = m_name;
|
||||
clone->m_dwColor1 = m_dwColor1;
|
||||
clone->m_dwColor2 = m_dwColor2;
|
||||
return clone;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CBrushLinearGradient::CBrushLinearGradient( const PointF& p1, const PointF& p2, const CColor& c1, const CColor& c2 )
|
||||
CBrushHatch::CBrushHatch(const CBrushHatch& other)
|
||||
: CBrush(BrushTypeHatchFill)
|
||||
{
|
||||
*this = other;
|
||||
}
|
||||
|
||||
CBrushHatch::CBrushHatch(CBrushHatch&& other) noexcept
|
||||
: CBrush(BrushTypeHatchFill)
|
||||
{
|
||||
*this = std::move(other);
|
||||
}
|
||||
|
||||
CBrushHatch::~CBrushHatch()
|
||||
{
|
||||
}
|
||||
|
||||
void CBrushHatch::SetName(const std::wstring& name)
|
||||
{
|
||||
m_wsName = name;
|
||||
}
|
||||
|
||||
std::wstring CBrushHatch::GetName() const
|
||||
{
|
||||
return m_wsName;
|
||||
}
|
||||
|
||||
void CBrushHatch::SetColor1(const CColor& color)
|
||||
{
|
||||
m_dwColor1 = color;
|
||||
}
|
||||
|
||||
CColor CBrushHatch::GetColor1() const
|
||||
{
|
||||
return m_dwColor1;
|
||||
}
|
||||
|
||||
void CBrushHatch::SetColor2(const CColor& color)
|
||||
{
|
||||
m_dwColor2 = color;
|
||||
}
|
||||
|
||||
CColor CBrushHatch::GetColor2() const
|
||||
{
|
||||
return m_dwColor2;
|
||||
}
|
||||
|
||||
void CBrushHatch::SetBounds(const CDoubleRect& rect)
|
||||
{
|
||||
m_oBounds = rect;
|
||||
}
|
||||
|
||||
CDoubleRect& CBrushHatch::GetBounds()
|
||||
{
|
||||
return m_oBounds;
|
||||
}
|
||||
|
||||
CBrushHatch& CBrushHatch::operator=(const CBrushHatch& other)
|
||||
{
|
||||
if (this == &other)
|
||||
return *this;
|
||||
|
||||
m_wsName = other.m_wsName;
|
||||
m_dwColor1 = other.m_dwColor1;
|
||||
m_dwColor2 = other.m_dwColor2;
|
||||
return *this;
|
||||
}
|
||||
|
||||
CBrushHatch& CBrushHatch::operator=(CBrushHatch&& other) noexcept
|
||||
{
|
||||
if (this == &other)
|
||||
return *this;
|
||||
|
||||
m_wsName = std::move(other.m_wsName);
|
||||
m_dwColor1 = other.m_dwColor1;
|
||||
m_dwColor2 = other.m_dwColor2;
|
||||
return *this;
|
||||
}
|
||||
|
||||
CBrushLinearGradient::CBrushLinearGradient()
|
||||
: CBrush(BrushTypeLinearGradient)
|
||||
{
|
||||
m_points[0] = p1;
|
||||
m_points[1] = p2;
|
||||
|
||||
m_colors[0] = c1;
|
||||
m_colors[1] = c2;
|
||||
|
||||
m_angle = 0;
|
||||
m_wrap = Aggplus::WrapModeTile;
|
||||
|
||||
m_bAngleScalable = FALSE;
|
||||
m_bRectable = FALSE;
|
||||
m_bRelativeCoords = FALSE;
|
||||
}
|
||||
|
||||
CBrushLinearGradient::CBrushLinearGradient( const Point& p1, const Point& p2, const CColor& c1, const CColor& c2 )
|
||||
CBrushLinearGradient::CBrushLinearGradient(const PointF& p1, const PointF& p2, const CColor& c1, const CColor& c2)
|
||||
: CBrush(BrushTypeLinearGradient)
|
||||
{
|
||||
m_points[0].X = (float)p1.X;
|
||||
m_points[0].Y = (float)p1.Y;
|
||||
m_points[1].X = (float)p2.X;
|
||||
m_points[1].Y = (float)p2.Y;
|
||||
m_arPoints[0] = p1;
|
||||
m_arPoints[1] = p2;
|
||||
|
||||
m_colors[0] = c1;
|
||||
m_colors[1] = c2;
|
||||
|
||||
m_angle = 0;
|
||||
|
||||
m_wrap = Aggplus::WrapModeTile;
|
||||
|
||||
m_bAngleScalable = FALSE;
|
||||
m_bRectable = FALSE;
|
||||
m_bRelativeCoords = FALSE;
|
||||
m_arColors[0] = c1;
|
||||
m_arColors[1] = c2;
|
||||
}
|
||||
|
||||
CBrushLinearGradient::CBrushLinearGradient( const RectF& rect, const CColor& c1, const CColor& c2, float angle, INT isAngleScalable )
|
||||
CBrushLinearGradient::CBrushLinearGradient(const Point& p1, const Point& p2, const CColor& c1, const CColor& c2)
|
||||
: CBrush(BrushTypeLinearGradient)
|
||||
{
|
||||
m_points[0].X = rect.GetLeft();
|
||||
m_points[0].Y = rect.GetTop();
|
||||
m_points[1].X = rect.GetRight();
|
||||
m_points[1].Y = rect.GetBottom();
|
||||
m_arPoints[0].X = static_cast<float>(p1.X);
|
||||
m_arPoints[0].Y = static_cast<float>(p1.Y);
|
||||
m_arPoints[1].X = static_cast<float>(p2.X);
|
||||
m_arPoints[1].Y = static_cast<float>(p2.Y);
|
||||
|
||||
m_colors[0] = c1;
|
||||
m_colors[1] = c2;
|
||||
m_arColors[0] = c1;
|
||||
m_arColors[1] = c2;
|
||||
}
|
||||
|
||||
m_angle = angle;
|
||||
|
||||
m_wrap = Aggplus::WrapModeTile;
|
||||
CBrushLinearGradient::CBrushLinearGradient(const RectF& rect, const CColor& c1, const CColor& c2, float angle, bool isAngleScalable)
|
||||
: CBrush(BrushTypeLinearGradient)
|
||||
{
|
||||
m_arPoints[0].X = rect.GetLeft();
|
||||
m_arPoints[0].Y = rect.GetTop();
|
||||
m_arPoints[1].X = rect.GetRight();
|
||||
m_arPoints[1].Y = rect.GetBottom();
|
||||
|
||||
m_arColors[0] = c1;
|
||||
m_arColors[1] = c2;
|
||||
|
||||
m_fAngle = angle;
|
||||
|
||||
m_bAngleScalable = isAngleScalable;
|
||||
m_bRectable = TRUE;
|
||||
m_bRelativeCoords = FALSE;
|
||||
m_bRectable = true;
|
||||
}
|
||||
|
||||
CBrushLinearGradient::CBrushLinearGradient( const Rect& rect, const CColor& c1, const CColor& c2, float angle, INT isAngleScalable )
|
||||
CBrushLinearGradient::CBrushLinearGradient(const Rect& rect, const CColor& c1, const CColor& c2, float angle, bool isAngleScalable)
|
||||
: CBrush(BrushTypeLinearGradient)
|
||||
{
|
||||
m_points[0].X = (float)rect.GetLeft();
|
||||
m_points[0].Y = (float)rect.GetTop();
|
||||
m_points[1].X = (float)rect.GetRight();
|
||||
m_points[1].Y = (float)rect.GetBottom();
|
||||
m_arPoints[0].X = static_cast<float>(rect.GetLeft());
|
||||
m_arPoints[0].Y = static_cast<float>(rect.GetTop());
|
||||
m_arPoints[1].X = static_cast<float>(rect.GetRight());
|
||||
m_arPoints[1].Y = static_cast<float>(rect.GetBottom());
|
||||
|
||||
m_colors[0] = c1;
|
||||
m_colors[1] = c2;
|
||||
m_arColors[0] = c1;
|
||||
m_arColors[1] = c2;
|
||||
|
||||
m_angle = angle;
|
||||
|
||||
m_wrap = Aggplus::WrapModeTile;
|
||||
m_fAngle = angle;
|
||||
|
||||
m_bAngleScalable = isAngleScalable;
|
||||
m_bRectable = TRUE;
|
||||
m_bRelativeCoords = FALSE;
|
||||
m_bRectable = true;
|
||||
}
|
||||
|
||||
CBrushLinearGradient::CBrushLinearGradient( const RectF& rect, const CColor& c1, const CColor& c2, Aggplus::LinearGradientMode mode )
|
||||
CBrushLinearGradient::CBrushLinearGradient(const RectF& rect, const CColor& c1, const CColor& c2, Aggplus::LinearGradientMode mode)
|
||||
: CBrush(BrushTypeLinearGradient)
|
||||
{
|
||||
m_points[0].X = rect.GetLeft();
|
||||
m_points[0].Y = rect.GetTop();
|
||||
m_points[1].X = rect.GetRight();
|
||||
m_points[1].Y = rect.GetBottom();
|
||||
m_arPoints[0].X = rect.GetLeft();
|
||||
m_arPoints[0].Y = rect.GetTop();
|
||||
m_arPoints[1].X = rect.GetRight();
|
||||
m_arPoints[1].Y = rect.GetBottom();
|
||||
|
||||
switch( mode )
|
||||
{
|
||||
case LinearGradientModeHorizontal:
|
||||
m_angle = 0;
|
||||
m_fAngle = 0;
|
||||
break;
|
||||
|
||||
case LinearGradientModeVertical:
|
||||
m_angle = 90;
|
||||
m_fAngle = 90;
|
||||
break;
|
||||
|
||||
case LinearGradientModeForwardDiagonal:
|
||||
m_angle = 45;
|
||||
m_fAngle = 45;
|
||||
break;
|
||||
|
||||
default:
|
||||
m_angle = 315;
|
||||
m_fAngle = 315;
|
||||
}
|
||||
|
||||
m_colors[0] = c1;
|
||||
m_colors[1] = c2;
|
||||
m_arColors[0] = c1;
|
||||
m_arColors[1] = c2;
|
||||
|
||||
m_wrap = Aggplus::WrapModeTile;
|
||||
|
||||
m_bAngleScalable = TRUE;
|
||||
m_bRectable = TRUE;
|
||||
m_bRelativeCoords = FALSE;
|
||||
m_bAngleScalable = true;
|
||||
m_bRectable = true;
|
||||
}
|
||||
|
||||
CBrushLinearGradient::CBrushLinearGradient( const Rect& rect, const CColor& c1, const CColor& c2, Aggplus::LinearGradientMode mode )
|
||||
CBrushLinearGradient::CBrushLinearGradient(const Rect& rect, const CColor& c1, const CColor& c2, Aggplus::LinearGradientMode mode)
|
||||
: CBrush(BrushTypeLinearGradient)
|
||||
{
|
||||
m_points[0].X = (REAL)rect.GetLeft();
|
||||
m_points[0].Y = (REAL)rect.GetTop();
|
||||
m_points[1].X = (REAL)rect.GetRight();
|
||||
m_points[1].Y = (REAL)rect.GetBottom();
|
||||
m_arPoints[0].X = static_cast<float>(rect.GetLeft());
|
||||
m_arPoints[0].Y = static_cast<float>(rect.GetTop());
|
||||
m_arPoints[1].X = static_cast<float>(rect.GetRight());
|
||||
m_arPoints[1].Y = static_cast<float>(rect.GetBottom());
|
||||
|
||||
switch( mode )
|
||||
{
|
||||
case LinearGradientModeHorizontal:
|
||||
m_angle = 0;
|
||||
m_fAngle = 0;
|
||||
break;
|
||||
|
||||
case LinearGradientModeVertical:
|
||||
m_angle = 90;
|
||||
m_fAngle = 90;
|
||||
break;
|
||||
|
||||
case LinearGradientModeForwardDiagonal:
|
||||
m_angle = 45;
|
||||
m_fAngle = 45;
|
||||
break;
|
||||
|
||||
default:
|
||||
m_angle = 315;
|
||||
m_fAngle = 315;
|
||||
}
|
||||
|
||||
m_colors[0] = c1;
|
||||
m_colors[1] = c2;
|
||||
m_arColors[0] = c1;
|
||||
m_arColors[1] = c2;
|
||||
|
||||
m_wrap = Aggplus::WrapModeTile;
|
||||
|
||||
m_bAngleScalable = TRUE;
|
||||
m_bRectable = TRUE;
|
||||
m_bRelativeCoords = FALSE;
|
||||
m_bAngleScalable = true;
|
||||
m_bRectable = true;
|
||||
}
|
||||
|
||||
|
||||
CBrushLinearGradient::CBrushLinearGradient( const CBrushLinearGradient& out )
|
||||
: CBrush(out.m_bType)
|
||||
CBrushLinearGradient::CBrushLinearGradient(const CBrushLinearGradient& other)
|
||||
: CBrush(other.m_bType)
|
||||
{
|
||||
m_colors[0] = out.m_colors[0];
|
||||
m_colors[1] = out.m_colors[1];
|
||||
m_points[0] = out.m_points[0];
|
||||
m_points[1] = out.m_points[1];
|
||||
|
||||
m_subcolors = out.m_subcolors;
|
||||
|
||||
m_matrix = out.m_matrix;
|
||||
m_angle = out.m_angle;
|
||||
|
||||
m_wrap = out.m_wrap;
|
||||
m_bAngleScalable = out.m_bAngleScalable;
|
||||
m_bRectable = out.m_bRectable;
|
||||
m_bRelativeCoords = out.m_bRelativeCoords;
|
||||
*this = other;
|
||||
}
|
||||
|
||||
Status CBrushLinearGradient::GetLinearColors( CColor* colors ) const
|
||||
CBrushLinearGradient::CBrushLinearGradient(CBrushLinearGradient&& other) noexcept
|
||||
{
|
||||
if( !colors )
|
||||
*this = std::move(other);
|
||||
}
|
||||
|
||||
CBrushLinearGradient::~CBrushLinearGradient()
|
||||
{
|
||||
}
|
||||
|
||||
Status CBrushLinearGradient::GetLinearColors(CColor* colors) const
|
||||
{
|
||||
if(!colors)
|
||||
return InvalidParameter;
|
||||
|
||||
colors[0] = m_colors[0];
|
||||
colors[1] = m_colors[1];
|
||||
colors[0] = m_arColors[0];
|
||||
colors[1] = m_arColors[1];
|
||||
|
||||
return Ok;
|
||||
}
|
||||
|
||||
Status CBrushLinearGradient::GetRectangle( Rect *rect ) const
|
||||
Status CBrushLinearGradient::GetRectangle(Rect *rect) const
|
||||
{
|
||||
if( !rect )
|
||||
if(!rect)
|
||||
return InvalidParameter;
|
||||
|
||||
rect->X = (int)( m_points[0].X );
|
||||
rect->Y = (int)( m_points[0].Y );
|
||||
rect->Width = (int)( m_points[1].X ) - rect->X;
|
||||
rect->Height = (int)( m_points[1].Y ) - rect->Y;
|
||||
rect->X = static_cast<int>((m_arPoints[0].X));
|
||||
rect->Y = static_cast<int>((m_arPoints[0].Y));
|
||||
rect->Width = static_cast<int>((m_arPoints[1].X) - rect->X);
|
||||
rect->Height = static_cast<int>((m_arPoints[1].Y) - rect->Y);
|
||||
return Ok;
|
||||
}
|
||||
|
||||
Status CBrushLinearGradient::GetRectangle(RectF *rect) const
|
||||
{
|
||||
if(!rect)
|
||||
return InvalidParameter;
|
||||
|
||||
rect->X = m_arPoints[0].X;
|
||||
rect->Y = m_arPoints[0].Y;
|
||||
rect->Width = m_arPoints[1].X - rect->X;
|
||||
rect->Height = m_arPoints[1].Y - rect->Y;
|
||||
|
||||
return Ok;
|
||||
}
|
||||
|
||||
Status CBrushLinearGradient::GetRectangle( RectF *rect ) const
|
||||
Status CBrushLinearGradient::GetTransform(CMatrix* matrix) const
|
||||
{
|
||||
if( !rect )
|
||||
if(!matrix)
|
||||
return InvalidParameter;
|
||||
|
||||
rect->X = m_points[0].X;
|
||||
rect->Y = m_points[0].Y;
|
||||
rect->Width = m_points[1].X - rect->X;
|
||||
rect->Height = m_points[1].Y - rect->Y;
|
||||
*matrix = m_Matrix;
|
||||
|
||||
return Ok;
|
||||
}
|
||||
|
||||
Status CBrushLinearGradient::GetTransform( CMatrix* matrix ) const
|
||||
Status CBrushLinearGradient::MultiplyTransform(const CMatrix *matrix, MatrixOrder order)
|
||||
{
|
||||
if( !matrix )
|
||||
return InvalidParameter;
|
||||
|
||||
*matrix = m_matrix;
|
||||
|
||||
return Ok;
|
||||
}
|
||||
|
||||
Status CBrushLinearGradient::MultiplyTransform( const CMatrix *matrix, MatrixOrder order)
|
||||
{
|
||||
if( !matrix )
|
||||
return InvalidParameter;
|
||||
|
||||
m_matrix.Multiply( matrix, order );
|
||||
m_Matrix.Multiply(matrix, order);
|
||||
|
||||
return Ok;
|
||||
}
|
||||
|
||||
Status CBrushLinearGradient::ResetTransform()
|
||||
{
|
||||
m_matrix.Reset();
|
||||
m_Matrix.Reset();
|
||||
|
||||
return Ok;
|
||||
}
|
||||
|
||||
Status CBrushLinearGradient::RotateTransform( REAL angle, MatrixOrder order )
|
||||
Status CBrushLinearGradient::RotateTransform(float angle, MatrixOrder order)
|
||||
{
|
||||
m_matrix.Rotate( angle, order );
|
||||
m_Matrix.Rotate(angle, order);
|
||||
|
||||
return Ok;
|
||||
}
|
||||
|
||||
Status CBrushLinearGradient::ScaleTransform( REAL sx, REAL sy, MatrixOrder order )
|
||||
Status CBrushLinearGradient::ScaleTransform(float sx, float sy, MatrixOrder order)
|
||||
{
|
||||
m_matrix.Scale( sx, sy, order );
|
||||
m_Matrix.Scale(sx, sy, order);
|
||||
|
||||
return Ok;
|
||||
}
|
||||
|
||||
void CBrushLinearGradient::SetWrapMode( WrapMode mode )
|
||||
void CBrushLinearGradient::SetWrapMode(WrapMode mode)
|
||||
{
|
||||
m_wrap = mode;
|
||||
m_eWrap = mode;
|
||||
}
|
||||
|
||||
WrapMode CBrushLinearGradient::GetWrapMode() const
|
||||
{
|
||||
return m_wrap;
|
||||
return m_eWrap;
|
||||
}
|
||||
|
||||
CBrush* CBrushLinearGradient::Clone() const
|
||||
Status CBrushLinearGradient::SetInterpolationColors(const CColor *presetColors, const float *blendPositions, int count)
|
||||
{
|
||||
return new CBrushLinearGradient( *this );
|
||||
}
|
||||
m_arSubColors.clear();
|
||||
|
||||
Status CBrushLinearGradient::SetInterpolationColors( const CColor *presetColors, const REAL *blendPositions, INT count )
|
||||
{
|
||||
m_subcolors.clear();
|
||||
|
||||
if( count > 0 && presetColors && blendPositions )
|
||||
if(count > 0 && presetColors && blendPositions)
|
||||
{
|
||||
m_subcolors.resize( count );
|
||||
m_arSubColors.resize(count);
|
||||
|
||||
for( int i = 0; i < count; i++ )
|
||||
for(int i = 0; i < count; i++)
|
||||
{
|
||||
m_subcolors[i].color = presetColors[i];
|
||||
m_subcolors[i].position = blendPositions[i];
|
||||
m_arSubColors[i].color = presetColors[i];
|
||||
m_arSubColors[i].position = blendPositions[i];
|
||||
}
|
||||
}
|
||||
|
||||
return Ok;
|
||||
}
|
||||
|
||||
Status CBrushLinearGradient::GetInterpolationColors( CColor *presetColors, REAL *blendPositions, INT count ) const
|
||||
Status CBrushLinearGradient::GetInterpolationColors(CColor *presetColors, float *blendPositions, int count) const
|
||||
{
|
||||
if( count > 0 && count <= (INT)m_subcolors.size() && presetColors && blendPositions )
|
||||
if( count > 0 && count <= (int)m_arSubColors.size() && presetColors && blendPositions )
|
||||
{
|
||||
for( int i = 0; i < count; i++ )
|
||||
{
|
||||
presetColors[i] = m_subcolors[i].color;
|
||||
blendPositions[i] = m_subcolors[i].position;
|
||||
presetColors[i] = m_arSubColors[i].color;
|
||||
blendPositions[i] = m_arSubColors[i].position;
|
||||
}
|
||||
}
|
||||
|
||||
return Ok;
|
||||
}
|
||||
|
||||
INT CBrushLinearGradient::GetInterpolationColorsCount() const
|
||||
int CBrushLinearGradient::GetInterpolationColorsCount() const
|
||||
{
|
||||
return (INT)m_subcolors.size();
|
||||
return static_cast<int>(m_arSubColors.size());
|
||||
}
|
||||
|
||||
// additional methods
|
||||
void CBrushLinearGradient::GetSubColor( int nIndex, CColor* pColor, float* pPosition ) const
|
||||
void CBrushLinearGradient::GetSubColor(int index, CColor* color, float* position) const
|
||||
{
|
||||
*pColor = m_subcolors[nIndex].color;
|
||||
*pPosition = m_subcolors[nIndex].position;
|
||||
*color = m_arSubColors[index].color;
|
||||
*position = m_arSubColors[index].position;
|
||||
}
|
||||
|
||||
void CBrushLinearGradient::SetRelativeCoords( INT bRelative )
|
||||
|
||||
void CBrushLinearGradient::SetRelativeCoords(bool relative)
|
||||
{
|
||||
m_bRelativeCoords = bRelative;
|
||||
m_bRelativeCoords = relative;
|
||||
}
|
||||
INT CBrushLinearGradient::IsRelativeCoords() const
|
||||
|
||||
bool CBrushLinearGradient::IsRelativeCoords() const
|
||||
{
|
||||
return m_bRelativeCoords;
|
||||
}
|
||||
|
||||
INT CBrushLinearGradient::IsAngleScalable() const
|
||||
bool CBrushLinearGradient::IsAngleScalable() const
|
||||
{
|
||||
return m_bAngleScalable;
|
||||
}
|
||||
INT CBrushLinearGradient::IsRectable() const
|
||||
|
||||
bool CBrushLinearGradient::IsRectable() const
|
||||
{
|
||||
return m_bRectable;
|
||||
}
|
||||
|
||||
float CBrushLinearGradient::GetAngle() const
|
||||
{
|
||||
return m_angle;
|
||||
return m_fAngle;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CBrushTexture::CBrushTexture() : CBrush(BrushTypeTextureFill)
|
||||
void CBrushLinearGradient::SetBounds(const CDoubleRect& rect)
|
||||
{
|
||||
m_pImage = NULL;
|
||||
m_bReleaseImage = FALSE;
|
||||
Alpha = 255;
|
||||
m_bUseBounds = false;
|
||||
m_oBounds = rect;
|
||||
}
|
||||
|
||||
CBrushTexture::CBrushTexture(const std::wstring& strName, WrapMode wrapMode) : CBrush(BrushTypeTextureFill), m_wrapMode(wrapMode)
|
||||
CDoubleRect& CBrushLinearGradient::GetBounds()
|
||||
{
|
||||
m_pImage = new CImage(strName);
|
||||
m_bReleaseImage = TRUE;
|
||||
Alpha = 255;
|
||||
m_bUseBounds = false;
|
||||
return m_oBounds;
|
||||
}
|
||||
|
||||
CBrushTexture::CBrushTexture(CImage *pImage, WrapMode wrapMode) : CBrush(BrushTypeTextureFill), m_wrapMode(wrapMode)
|
||||
CBrushLinearGradient& CBrushLinearGradient::operator=(const CBrushLinearGradient& other)
|
||||
{
|
||||
m_pImage = pImage;
|
||||
m_bReleaseImage = FALSE;
|
||||
Alpha = 255;
|
||||
m_bUseBounds = false;
|
||||
if (this == &other)
|
||||
return *this;
|
||||
|
||||
m_arColors[0] = other.m_arColors[0];
|
||||
m_arColors[1] = other.m_arColors[1];
|
||||
m_arPoints[0] = other.m_arPoints[0];
|
||||
m_arPoints[1] = other.m_arPoints[1];
|
||||
|
||||
m_arSubColors = other.m_arSubColors;
|
||||
|
||||
m_Matrix = other.m_Matrix;
|
||||
m_fAngle = other.m_fAngle;
|
||||
|
||||
m_eWrap = other.m_eWrap;
|
||||
|
||||
m_bAngleScalable = other.m_bAngleScalable;
|
||||
m_bRectable = other.m_bRectable;
|
||||
m_bRelativeCoords = other.m_bRelativeCoords;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
CBrushTexture::~CBrushTexture()
|
||||
|
||||
CBrushLinearGradient& CBrushLinearGradient::operator=(CBrushLinearGradient&& other) noexcept
|
||||
{
|
||||
if (this == &other)
|
||||
return *this;
|
||||
|
||||
m_arColors[0] = other.m_arColors[0];
|
||||
m_arColors[1] = other.m_arColors[1];
|
||||
m_arPoints[0] = other.m_arPoints[0];
|
||||
m_arPoints[1] = other.m_arPoints[1];
|
||||
|
||||
m_arSubColors = other.m_arSubColors;
|
||||
|
||||
m_Matrix = std::move(other.m_Matrix);
|
||||
|
||||
m_eWrap = other.m_eWrap;
|
||||
|
||||
m_bAngleScalable = other.m_bAngleScalable;
|
||||
m_bRectable = other.m_bRectable;
|
||||
m_bRelativeCoords = other.m_bRelativeCoords;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
CBrushTexture::CBrushTexture()
|
||||
: CBrush(BrushTypeTextureFill)
|
||||
{
|
||||
}
|
||||
|
||||
CBrushTexture::CBrushTexture(const std::wstring& name, WrapMode mode)
|
||||
: CBrush(BrushTypeTextureFill),
|
||||
m_eWrapMode(mode)
|
||||
{
|
||||
m_pImage = new CImage(name);
|
||||
m_bReleaseImage = true;
|
||||
}
|
||||
|
||||
CBrushTexture::CBrushTexture(CImage *image, WrapMode mode)
|
||||
: CBrush(BrushTypeTextureFill),
|
||||
m_eWrapMode(mode)
|
||||
{
|
||||
m_pImage = image;
|
||||
}
|
||||
|
||||
CBrushTexture::CBrushTexture(const CBrushTexture& other)
|
||||
{
|
||||
*this = other;
|
||||
}
|
||||
|
||||
CBrushTexture::CBrushTexture(CBrushTexture&& other)
|
||||
{
|
||||
*this = std::move(other);
|
||||
}
|
||||
|
||||
CBrushTexture::~CBrushTexture()
|
||||
{
|
||||
if (m_bReleaseImage)
|
||||
{
|
||||
RELEASEOBJECT(m_pImage);
|
||||
}
|
||||
}
|
||||
|
||||
CBrush* CBrushTexture::Clone() const
|
||||
|
||||
void CBrushTexture::TranslateTransform(double x, double y, MatrixOrder order)
|
||||
{
|
||||
CBrushTexture *pRet = new CBrushTexture(m_pImage, m_wrapMode);
|
||||
if( pRet )
|
||||
{
|
||||
pRet->m_mtx = m_mtx;
|
||||
}
|
||||
|
||||
return pRet;
|
||||
m_Matrix.Translate(x, y, order);
|
||||
}
|
||||
|
||||
void CBrushTexture::TranslateTransform(double dX, double dY, MatrixOrder order)
|
||||
{
|
||||
m_mtx.Translate(dX, dY, order);
|
||||
}
|
||||
void CBrushTexture::ScaleTransform(double dX, double dY, MatrixOrder order)
|
||||
{
|
||||
m_mtx.Scale(dX, dY, order);
|
||||
}
|
||||
void CBrushTexture::RotateTransform(double angle, MatrixOrder order)
|
||||
{
|
||||
m_mtx.Rotate(angle, order);
|
||||
}
|
||||
void CBrushTexture::GetTransform(CMatrix* matrix) const
|
||||
{
|
||||
*matrix = m_mtx;
|
||||
}
|
||||
void CBrushTexture::SetTransform(const CMatrix* matrix)
|
||||
{
|
||||
m_mtx = *matrix;
|
||||
void CBrushTexture::ScaleTransform(double x, double y, MatrixOrder order)
|
||||
{
|
||||
m_Matrix.Scale(x, y, order);
|
||||
}
|
||||
|
||||
void CBrushTexture::SetWrapMode(WrapMode wMode)
|
||||
{
|
||||
m_wrapMode = wMode;
|
||||
void CBrushTexture::RotateTransform(double angle, MatrixOrder order)
|
||||
{
|
||||
m_Matrix.Rotate(angle, order);
|
||||
}
|
||||
WrapMode CBrushTexture::GetWrapMode() const
|
||||
{
|
||||
return(m_wrapMode);
|
||||
|
||||
void CBrushTexture::GetTransform(CMatrix* matrix) const
|
||||
{
|
||||
*matrix = m_Matrix;
|
||||
}
|
||||
|
||||
void CBrushTexture::SetTransform(const CMatrix* matrix)
|
||||
{
|
||||
m_Matrix = *matrix;
|
||||
}
|
||||
|
||||
void CBrushTexture::SetWrapMode(WrapMode mode)
|
||||
{
|
||||
m_eWrapMode = mode;
|
||||
}
|
||||
|
||||
WrapMode CBrushTexture::GetWrapMode() const
|
||||
{
|
||||
return m_eWrapMode;
|
||||
}
|
||||
|
||||
void CBrushTexture::SetBounds(const CDoubleRect& rect)
|
||||
{
|
||||
m_bUseBounds = true;
|
||||
m_oBounds = rect;
|
||||
}
|
||||
|
||||
CDoubleRect& CBrushTexture::GetBounds()
|
||||
{
|
||||
return m_oBounds;
|
||||
}
|
||||
|
||||
void CBrushTexture::SetReleaseImage(bool isReleaseImage)
|
||||
{
|
||||
m_bReleaseImage = isReleaseImage;
|
||||
}
|
||||
|
||||
bool CBrushTexture::IsReleaseImage() const
|
||||
{
|
||||
return m_bReleaseImage;
|
||||
}
|
||||
|
||||
void CBrushTexture::SetAlpha(BYTE alpha)
|
||||
{
|
||||
m_Alpha = alpha;
|
||||
}
|
||||
|
||||
BYTE CBrushTexture::GetAlpha() const
|
||||
{
|
||||
return m_Alpha;
|
||||
}
|
||||
|
||||
void* CBrushTexture::GetData()
|
||||
{
|
||||
return m_pImage->m_pImgData;
|
||||
}
|
||||
|
||||
void* CBrushTexture::PatternFinalize()
|
||||
{
|
||||
{
|
||||
if (m_pImage->m_nStride < 0)
|
||||
return m_pImage->m_pImgData - ((m_pImage->m_dwHeight - 1) * m_pImage->m_nStride);
|
||||
return m_pImage->m_pImgData;
|
||||
}
|
||||
|
||||
DWORD CBrushTexture::PatternGetWidth()
|
||||
{
|
||||
{
|
||||
return m_pImage->m_dwWidth;
|
||||
}
|
||||
|
||||
DWORD CBrushTexture::PatternGetHeight()
|
||||
{
|
||||
{
|
||||
return m_pImage->m_dwHeight;
|
||||
}
|
||||
|
||||
int CBrushTexture::PatternGetStride()
|
||||
{
|
||||
{
|
||||
return m_pImage->m_nStride;
|
||||
}
|
||||
|
||||
CBrushTexture& CBrushTexture::operator=(const CBrushTexture& other)
|
||||
{
|
||||
if (this == &other)
|
||||
return *this;
|
||||
|
||||
m_pImage = new CImage(*other.m_pImage);
|
||||
|
||||
m_Matrix = other.m_Matrix;
|
||||
|
||||
m_eWrapMode = other.m_eWrapMode;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
CBrushTexture& CBrushTexture::operator=(CBrushTexture&& other)
|
||||
{
|
||||
if (this == &other)
|
||||
return *this;
|
||||
|
||||
m_pImage = std::move(other.m_pImage);
|
||||
|
||||
m_Matrix = std::move(other.m_Matrix);
|
||||
|
||||
m_eWrapMode = other.m_eWrapMode;
|
||||
|
||||
return *this;
|
||||
}
|
||||
}
|
||||
|
||||
@ -43,170 +43,256 @@
|
||||
|
||||
namespace Aggplus
|
||||
{
|
||||
class CBrush
|
||||
{
|
||||
friend class CGraphics;
|
||||
|
||||
protected:
|
||||
|
||||
CBrush(BrushType bType);
|
||||
|
||||
public:
|
||||
virtual ~CBrush();
|
||||
|
||||
virtual CBrush* Clone() const = 0;
|
||||
BrushType GetType() const;
|
||||
|
||||
public:
|
||||
BrushType m_bType;
|
||||
};
|
||||
|
||||
class CBrushSolid : public CBrush
|
||||
{
|
||||
public:
|
||||
CBrushSolid(CColor dwColor);
|
||||
virtual ~CBrushSolid();
|
||||
virtual CBrush *Clone() const;
|
||||
|
||||
void GetColor(CColor* color) const;
|
||||
void SetColor(const CColor &color);
|
||||
|
||||
protected:
|
||||
CColor m_dwColor;
|
||||
};
|
||||
|
||||
class CBrushHatch : public CBrush
|
||||
{
|
||||
public:
|
||||
CBrushHatch();
|
||||
virtual ~CBrushHatch();
|
||||
virtual CBrush *Clone() const;
|
||||
|
||||
inline CDoubleRect& GetBounds() { return Bounds; }
|
||||
|
||||
|
||||
public:
|
||||
std::wstring m_name;
|
||||
CColor m_dwColor1;
|
||||
CColor m_dwColor2;
|
||||
|
||||
CDoubleRect Bounds;
|
||||
};
|
||||
|
||||
|
||||
class CBrushLinearGradient : public CBrush
|
||||
{
|
||||
friend class CGraphics;
|
||||
|
||||
public:
|
||||
CBrushLinearGradient( const PointF& p1, const PointF& p2, const CColor& c1, const CColor& c2 );
|
||||
CBrushLinearGradient( const Point& p1, const Point& p2, const CColor& c1, const CColor& c2 );
|
||||
CBrushLinearGradient( const RectF& rect, const CColor& c1, const CColor& c2, float angle, INT isAngleScalable );
|
||||
CBrushLinearGradient( const Rect& rect, const CColor& c1, const CColor& c2, float angle, INT isAngleScalable );
|
||||
CBrushLinearGradient( const RectF& rect, const CColor& c1, const CColor& c2, Aggplus::LinearGradientMode mode );
|
||||
CBrushLinearGradient( const Rect& rect, const CColor& c1, const CColor& c2, Aggplus::LinearGradientMode mode );
|
||||
CBrushLinearGradient( const CBrushLinearGradient& out );
|
||||
|
||||
Status GetLinearColors( CColor* colors ) const;
|
||||
Status GetRectangle( Rect *rect ) const;
|
||||
Status GetRectangle( RectF *rect ) const;
|
||||
|
||||
Status GetTransform( CMatrix* matrix ) const;
|
||||
Status MultiplyTransform( const CMatrix *matrix, MatrixOrder order = MatrixOrderPrepend);
|
||||
Status ResetTransform();
|
||||
Status RotateTransform( REAL angle, MatrixOrder order = MatrixOrderPrepend );
|
||||
Status ScaleTransform( REAL sx, REAL sy, MatrixOrder order = MatrixOrderPrepend );
|
||||
|
||||
void SetWrapMode( WrapMode mode );
|
||||
WrapMode GetWrapMode() const;
|
||||
|
||||
virtual CBrush *Clone() const;
|
||||
|
||||
Status SetInterpolationColors( const CColor *presetColors, const REAL *blendPositions, INT count );
|
||||
Status GetInterpolationColors( CColor *presetColors, REAL *blendPositions, INT count ) const;
|
||||
INT GetInterpolationColorsCount() const;
|
||||
|
||||
// additional methods
|
||||
void GetSubColor( int nIndex, CColor* pColor, float* pPosition ) const;
|
||||
|
||||
void SetRelativeCoords( INT bRelative );
|
||||
INT IsRelativeCoords() const;
|
||||
INT IsAngleScalable() const;
|
||||
INT IsRectable() const;
|
||||
float GetAngle() const;
|
||||
inline void SetBounds(const CDoubleRect& oRect) { Bounds = oRect; }
|
||||
inline CDoubleRect& GetBounds() { return Bounds; }
|
||||
|
||||
// info about gradient
|
||||
NSStructures::GradientInfo m_oGradientInfo; // used in 60xx grad types
|
||||
protected:
|
||||
CColor m_colors[2];
|
||||
PointF m_points[2];
|
||||
|
||||
struct TSubColor
|
||||
/**
|
||||
* @abstract CBrush
|
||||
*
|
||||
* Base class for brushes (by default a solid brush
|
||||
* is created).
|
||||
*/
|
||||
class CBrush
|
||||
{
|
||||
CColor color;
|
||||
float position;
|
||||
friend class CGraphics;
|
||||
|
||||
protected:
|
||||
CBrush();
|
||||
CBrush(const BrushType& type);
|
||||
|
||||
public:
|
||||
virtual ~CBrush();
|
||||
|
||||
BrushType GetType() const;
|
||||
|
||||
public:
|
||||
BrushType m_bType = BrushTypeSolidColor;
|
||||
};
|
||||
|
||||
std::vector<TSubColor> m_subcolors;
|
||||
|
||||
CMatrix m_matrix;
|
||||
float m_angle; // угол поворота в градусах базовой линии p1 -> p2
|
||||
/**
|
||||
* @class CBrushSolid
|
||||
*
|
||||
* A single-color brush used to draw text, graphic paths,
|
||||
* and fills with a single color.
|
||||
*/
|
||||
class CBrushSolid : public CBrush
|
||||
{
|
||||
public:
|
||||
CBrushSolid();
|
||||
CBrushSolid(CColor color);
|
||||
virtual ~CBrushSolid();
|
||||
CBrushSolid(const CBrushSolid& other);
|
||||
|
||||
CDoubleRect Bounds;
|
||||
void GetColor(CColor* color) const;
|
||||
void SetColor(const CColor &color);
|
||||
|
||||
Aggplus::WrapMode m_wrap;
|
||||
CBrushSolid& operator=(const CBrushSolid& other);
|
||||
protected:
|
||||
CColor m_dwColor{};
|
||||
};
|
||||
|
||||
INT m_bAngleScalable; // масштабировать угол поворота относительно заданных точек b = arctan( width / height * tan(angle) );
|
||||
INT m_bRectable; // в качестве направляющей используется диагональ прямоугольника
|
||||
INT m_bRelativeCoords; // координаты точек считаются относительно рисуемого примитива
|
||||
};
|
||||
/**
|
||||
* @class CBrushHatch
|
||||
*
|
||||
* A two-color brush used to fill graphic paths using
|
||||
* one of the hatch patterns
|
||||
*/
|
||||
class CBrushHatch : public CBrush
|
||||
{
|
||||
public:
|
||||
CBrushHatch();
|
||||
CBrushHatch(const CBrushHatch& other);
|
||||
CBrushHatch(CBrushHatch&& other) noexcept;
|
||||
virtual ~CBrushHatch();
|
||||
|
||||
class CBrushTexture : public CBrush
|
||||
{
|
||||
friend class CGraphics;
|
||||
|
||||
protected:
|
||||
CBrushTexture();
|
||||
void SetName(const std::wstring& name);
|
||||
std::wstring GetName() const;
|
||||
|
||||
public:
|
||||
CBrushTexture(const std::wstring& strName, WrapMode wrapMode = WrapModeTile);
|
||||
CBrushTexture(CImage *pImage, WrapMode wrapMode = WrapModeTile);
|
||||
virtual ~CBrushTexture();
|
||||
virtual CBrush* Clone() const;
|
||||
void SetColor1(const CColor& color);
|
||||
CColor GetColor1() const;
|
||||
void SetColor2(const CColor& color);
|
||||
CColor GetColor2() const;
|
||||
|
||||
void TranslateTransform(double dX, double dY, MatrixOrder order = MatrixOrderPrepend);
|
||||
void ScaleTransform(double dX, double dY, MatrixOrder order = MatrixOrderPrepend);
|
||||
void RotateTransform(double angle, MatrixOrder order = MatrixOrderPrepend);
|
||||
void GetTransform(CMatrix* matrix) const;
|
||||
void SetTransform(const CMatrix* matrix);
|
||||
void SetBounds(const CDoubleRect& rect);
|
||||
CDoubleRect& GetBounds();
|
||||
|
||||
void SetWrapMode(WrapMode wMode);
|
||||
WrapMode GetWrapMode() const;
|
||||
|
||||
public:
|
||||
CBrushHatch& operator=(const CBrushHatch& other);
|
||||
CBrushHatch& operator=(CBrushHatch&& other) noexcept;
|
||||
protected:
|
||||
/**
|
||||
* @brief m_wsName - hatch brush pattern name
|
||||
* (as default - cross)
|
||||
*
|
||||
* See all patterns in agg_span_hatch.h, array -
|
||||
* c_resource_hatches_names.
|
||||
*/
|
||||
std::wstring m_wsName;
|
||||
CColor m_dwColor1{};
|
||||
CColor m_dwColor2{};
|
||||
|
||||
void* GetData();
|
||||
void* PatternFinalize();
|
||||
DWORD PatternGetWidth();
|
||||
DWORD PatternGetHeight();
|
||||
int PatternGetStride();
|
||||
|
||||
public:
|
||||
CImage* m_pImage;
|
||||
INT m_bReleaseImage;
|
||||
|
||||
WrapMode m_wrapMode;
|
||||
CMatrix m_mtx;
|
||||
CDoubleRect m_oBounds{};
|
||||
};
|
||||
|
||||
CColor m_colors[2];
|
||||
/**
|
||||
* @class CBrushLinearGradient
|
||||
*
|
||||
* brush for drawing gradients, stores information about the gradient.
|
||||
* According to the pdf documentation, it stores the start and end point
|
||||
* and color, as well as the linear interpolation of the colors.
|
||||
*/
|
||||
class CBrushLinearGradient : public CBrush
|
||||
{
|
||||
friend class CGraphics;
|
||||
|
||||
bool m_bUseBounds;
|
||||
CDoubleRect m_oBounds;
|
||||
public:
|
||||
CBrushLinearGradient();
|
||||
CBrushLinearGradient(const PointF& p1, const PointF& p2, const CColor& c1, const CColor& c2);
|
||||
CBrushLinearGradient(const Point& p1, const Point& p2, const CColor& c1, const CColor& c2);
|
||||
CBrushLinearGradient(const RectF& rect, const CColor& c1, const CColor& c2, float angle, bool isAngleScalable);
|
||||
CBrushLinearGradient(const Rect& rect, const CColor& c1, const CColor& c2, float angle, bool isAngleScalable);
|
||||
CBrushLinearGradient(const RectF& rect, const CColor& c1, const CColor& c2, Aggplus::LinearGradientMode mode);
|
||||
CBrushLinearGradient(const Rect& rect, const CColor& c1, const CColor& c2, Aggplus::LinearGradientMode mode);
|
||||
CBrushLinearGradient(const CBrushLinearGradient& other);
|
||||
CBrushLinearGradient(CBrushLinearGradient&& other) noexcept;
|
||||
virtual ~CBrushLinearGradient();
|
||||
|
||||
BYTE Alpha;
|
||||
};
|
||||
Status GetLinearColors(CColor* colors) const;
|
||||
Status GetRectangle(Rect *rect) const;
|
||||
Status GetRectangle(RectF *rect) const;
|
||||
|
||||
Status GetTransform(CMatrix* matrix) const;
|
||||
Status MultiplyTransform(const CMatrix *matrix, MatrixOrder order = MatrixOrderPrepend);
|
||||
Status ResetTransform();
|
||||
Status RotateTransform(float angle, MatrixOrder order = MatrixOrderPrepend );
|
||||
Status ScaleTransform(float sx, float sy, MatrixOrder order = MatrixOrderPrepend );
|
||||
|
||||
void SetWrapMode(WrapMode mode);
|
||||
WrapMode GetWrapMode() const;
|
||||
|
||||
Status SetInterpolationColors(const CColor *presetColors, const float *blendPositions, int count);
|
||||
Status GetInterpolationColors(CColor *presetColors, float *blendPositions, int count) const;
|
||||
int GetInterpolationColorsCount() const;
|
||||
|
||||
void GetSubColor(int index, CColor* color, float* position) const;
|
||||
|
||||
void SetRelativeCoords(bool relative);
|
||||
bool IsRelativeCoords() const;
|
||||
bool IsAngleScalable() const;
|
||||
bool IsRectable() const;
|
||||
float GetAngle() const;
|
||||
|
||||
void SetBounds(const CDoubleRect& rect);
|
||||
CDoubleRect& GetBounds();
|
||||
|
||||
CBrushLinearGradient& operator=(const CBrushLinearGradient& other);
|
||||
CBrushLinearGradient& operator=(CBrushLinearGradient&& other) noexcept;
|
||||
|
||||
NSStructures::GradientInfo m_oGradientInfo{};
|
||||
protected:
|
||||
CColor m_arColors[2];
|
||||
PointF m_arPoints[2];
|
||||
|
||||
struct TSubColor
|
||||
{
|
||||
CColor color{};
|
||||
float position = 0;
|
||||
};
|
||||
|
||||
std::vector<TSubColor> m_arSubColors;
|
||||
|
||||
CMatrix m_Matrix{};
|
||||
|
||||
/**
|
||||
* @brief m_angle - rotation angle of line p1 - p2 (measured in degrees)
|
||||
*/
|
||||
float m_fAngle = 0;
|
||||
|
||||
CDoubleRect m_oBounds{};
|
||||
|
||||
/**
|
||||
* @brief m_eWrapMode - Used to determine the rotation of the image tiles
|
||||
* (by default, we do not change the position).
|
||||
*/
|
||||
WrapMode m_eWrap = Aggplus::WrapModeTile;
|
||||
|
||||
/**
|
||||
* @brief m_bAngleScalable - whether to scale the rotation angle relative
|
||||
* to the given points
|
||||
*
|
||||
* calculated like this b = arctan(width / height * tan(angle));
|
||||
*/
|
||||
bool m_bAngleScalable = false;
|
||||
|
||||
/**
|
||||
* @brief m_bRectable - is the diagonal of a rectangle a guide
|
||||
*/
|
||||
bool m_bRectable = false;
|
||||
|
||||
/**
|
||||
* @brief m_bRelativeCoords - are the coordinates of the points calculated
|
||||
* relative to the resulting primitive
|
||||
*/
|
||||
bool m_bRelativeCoords = false;
|
||||
};
|
||||
|
||||
/**
|
||||
* @class CBrushTexture
|
||||
*
|
||||
* A texture brush that is used to draw images on the renderer.
|
||||
*/
|
||||
class CBrushTexture : public CBrush
|
||||
{
|
||||
friend class CGraphics;
|
||||
|
||||
public:
|
||||
CBrushTexture();
|
||||
CBrushTexture(const std::wstring& name, WrapMode mode = WrapModeTile);
|
||||
CBrushTexture(CImage *image, WrapMode mode = WrapModeTile);
|
||||
CBrushTexture(const CBrushTexture& other);
|
||||
CBrushTexture(CBrushTexture&& other);
|
||||
virtual ~CBrushTexture();
|
||||
|
||||
void TranslateTransform(double x, double y, MatrixOrder order = MatrixOrderPrepend);
|
||||
void ScaleTransform(double x, double y, MatrixOrder order = MatrixOrderPrepend);
|
||||
void RotateTransform(double angle, MatrixOrder order = MatrixOrderPrepend);
|
||||
void GetTransform(CMatrix* matrix) const;
|
||||
void SetTransform(const CMatrix* matrix);
|
||||
|
||||
void SetWrapMode(WrapMode mode);
|
||||
WrapMode GetWrapMode() const;
|
||||
|
||||
void SetBounds(const CDoubleRect& rect);
|
||||
CDoubleRect& GetBounds();
|
||||
|
||||
void SetReleaseImage(bool isReleaseImage);
|
||||
bool IsReleaseImage() const;
|
||||
|
||||
void SetAlpha(BYTE alpha);
|
||||
BYTE GetAlpha() const;
|
||||
|
||||
void* GetData();
|
||||
void* PatternFinalize();
|
||||
DWORD PatternGetWidth();
|
||||
DWORD PatternGetHeight();
|
||||
int PatternGetStride();
|
||||
|
||||
CBrushTexture& operator=(const CBrushTexture& other);
|
||||
CBrushTexture& operator=(CBrushTexture&& other);
|
||||
|
||||
protected:
|
||||
CImage* m_pImage{nullptr};
|
||||
bool m_bReleaseImage = false;
|
||||
|
||||
/**
|
||||
* @brief m_eWrapMode - Used to determine the rotation of the image tiles
|
||||
* (by default, we do not change the position).
|
||||
*/
|
||||
WrapMode m_eWrapMode = WrapModeTile;
|
||||
|
||||
CMatrix m_Matrix{};
|
||||
|
||||
bool m_bUseBounds = false;
|
||||
CDoubleRect m_oBounds{};
|
||||
|
||||
BYTE m_Alpha = 255;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // _BUILD_BRUSH_H_
|
||||
|
||||
@ -832,7 +832,8 @@ namespace Aggplus
|
||||
b = ptxBrush->m_oBounds.bottom;
|
||||
}
|
||||
|
||||
CMatrix brushMatrix(ptxBrush->m_mtx);
|
||||
CMatrix brushMatrix;
|
||||
ptxBrush->GetTransform(&brushMatrix);
|
||||
if (ptxBrush->GetWrapMode() == Aggplus::WrapModeClamp)
|
||||
{
|
||||
double dScaleX = (r - x) / dwPatternWidth;
|
||||
@ -1652,11 +1653,11 @@ namespace Aggplus
|
||||
m_rasterizer.gamma(1.0);
|
||||
}
|
||||
#else
|
||||
agg::rgba8 c1 = agg::rgba8(pBrush->m_dwColor1.GetR(), pBrush->m_dwColor1.GetG(), pBrush->m_dwColor1.GetB(), pBrush->m_dwColor1.GetA());
|
||||
agg::rgba8 c2 = agg::rgba8(pBrush->m_dwColor2.GetR(), pBrush->m_dwColor2.GetG(), pBrush->m_dwColor2.GetB(), pBrush->m_dwColor2.GetA());
|
||||
agg::rgba8 c1 = agg::rgba8(pBrush->GetColor1().GetR(), pBrush->GetColor1().GetG(), pBrush->GetColor1().GetB(), pBrush->GetColor1().GetA());
|
||||
agg::rgba8 c2 = agg::rgba8(pBrush->GetColor2().GetR(), pBrush->GetColor2().GetG(), pBrush->GetColor2().GetB(), pBrush->GetColor2().GetA());
|
||||
|
||||
BYTE* pPattern = new BYTE[HATCH_TX_SIZE * HATCH_TX_SIZE * 4];
|
||||
agg::GetHatchPattern(pBrush->m_name, (agg::rgba8*)pPattern, c1, c2);
|
||||
agg::GetHatchPattern(pBrush->GetName(), (agg::rgba8*)pPattern, c1, c2);
|
||||
|
||||
agg::trans_affine mtx_Work(m_oTransform.m_internal->m_agg_mtx);
|
||||
if (m_dDpiTile > 1)
|
||||
@ -2049,22 +2050,22 @@ namespace Aggplus
|
||||
|
||||
if(pImgBuff && dwImgWidth && dwImgHeight)
|
||||
{
|
||||
Aggplus::WrapMode wrapmode = ptxBrush->m_wrapMode;
|
||||
Aggplus::CMatrix matrix = ptxBrush->m_mtx;
|
||||
Aggplus::WrapMode wrapmode = ptxBrush->m_eWrapMode;
|
||||
Aggplus::CMatrix matrix = ptxBrush->m_Matrix;
|
||||
|
||||
if(wrapmode == WrapModeClamp)
|
||||
{
|
||||
DoFillPathTextureClampSz2( matrix, pImgBuff, dwImgWidth, dwImgHeight, nImgStride, ptxBrush->Alpha);
|
||||
DoFillPathTextureClampSz2( matrix, pImgBuff, dwImgWidth, dwImgHeight, nImgStride, ptxBrush->m_Alpha);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!m_bSwapRGB)
|
||||
{
|
||||
DoFillPathTextureClampSz3<agg::pixfmt_bgra32>(matrix, pImgBuff, dwImgWidth, dwImgHeight, nImgStride, wrapmode, ptxBrush->Alpha);
|
||||
DoFillPathTextureClampSz3<agg::pixfmt_bgra32>(matrix, pImgBuff, dwImgWidth, dwImgHeight, nImgStride, wrapmode, ptxBrush->m_Alpha);
|
||||
}
|
||||
else
|
||||
{
|
||||
DoFillPathTextureClampSz3<agg::pixfmt_rgba32>(matrix, pImgBuff, dwImgWidth, dwImgHeight, nImgStride, wrapmode, ptxBrush->Alpha);
|
||||
DoFillPathTextureClampSz3<agg::pixfmt_rgba32>(matrix, pImgBuff, dwImgWidth, dwImgHeight, nImgStride, wrapmode, ptxBrush->m_Alpha);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -48,7 +48,7 @@ namespace Aggplus
|
||||
|
||||
CGraphicsPath::CGraphicsPath(CGraphicsPath&& other) noexcept
|
||||
{
|
||||
*this = other;
|
||||
*this = std::move(other);
|
||||
}
|
||||
|
||||
CGraphicsPath::CGraphicsPath(const std::vector<CGraphicsPath>& paths) noexcept : CGraphicsPath()
|
||||
|
||||
@ -94,7 +94,7 @@ Aggplus::CBrush* CGraphicsRenderer::CreateBrush(NSStructures::CBrush* pBrush)
|
||||
Aggplus::CColor o1((BYTE)(pBrush->Alpha1 * m_dGlobalAlpha), pBrush->Color1, bIsSwappedRGB);
|
||||
Aggplus::CColor o2((BYTE)(pBrush->Alpha2 * m_dGlobalAlpha), pBrush->Color2, bIsSwappedRGB);
|
||||
|
||||
Aggplus::CBrushLinearGradient* pNew = new Aggplus::CBrushLinearGradient( Aggplus::RectF(0.0f, 0.0f, 1.0f, 1.0f), o1, o2, (float)pBrush->LinearAngle, TRUE );
|
||||
Aggplus::CBrushLinearGradient* pNew = new Aggplus::CBrushLinearGradient(Aggplus::RectF(0.0f, 0.0f, 1.0f, 1.0f), o1, o2, (float)pBrush->LinearAngle, true);
|
||||
if( pNew )
|
||||
{
|
||||
pNew->SetRelativeCoords( TRUE );
|
||||
@ -180,11 +180,11 @@ Aggplus::CBrush* CGraphicsRenderer::CreateBrush(NSStructures::CBrush* pBrush)
|
||||
Aggplus::CColor o2((BYTE)(pBrush->Alpha2 * m_dGlobalAlpha), pBrush->Color2, bIsSwappedRGB);
|
||||
|
||||
Aggplus::CBrushHatch* pNew = new Aggplus::CBrushHatch();
|
||||
pNew->m_dwColor1 = o1;
|
||||
pNew->m_dwColor2 = o2;
|
||||
pNew->m_name = pBrush->TexturePath;
|
||||
pNew->SetColor1(o1);
|
||||
pNew->SetColor2(o2);
|
||||
pNew->SetName(pBrush->TexturePath);
|
||||
|
||||
pNew->Bounds = pBrush->Bounds;
|
||||
pNew->SetBounds(pBrush->Bounds);
|
||||
|
||||
return pNew;
|
||||
}
|
||||
@ -996,7 +996,7 @@ HRESULT CGraphicsRenderer::DrawPath(const LONG& nType)
|
||||
pImage->Create(oFrame.get_Data(), oFrame.get_Width(), oFrame.get_Height(), oFrame.get_Stride());
|
||||
oFrame.ClearNoAttack();
|
||||
pTextureBrush = new Aggplus::CBrushTexture(pImage, oMode);
|
||||
pTextureBrush->m_bReleaseImage = TRUE;
|
||||
pTextureBrush->SetReleaseImage(true);
|
||||
}
|
||||
else
|
||||
RELEASEARRAYOBJECTS(pImageData);
|
||||
@ -1018,15 +1018,14 @@ HRESULT CGraphicsRenderer::DrawPath(const LONG& nType)
|
||||
{
|
||||
pTextureBrush->SetTransform(&m_oBrush.Transform);
|
||||
|
||||
pTextureBrush->Alpha = (BYTE)m_oBrush.TextureAlpha;
|
||||
pTextureBrush->SetAlpha(static_cast<BYTE>(m_oBrush.TextureAlpha));
|
||||
|
||||
if (m_oBrush.Rectable == 1)
|
||||
{
|
||||
pTextureBrush->m_bUseBounds = true;
|
||||
pTextureBrush->m_oBounds.left = m_oBrush.Rect.X;
|
||||
pTextureBrush->m_oBounds.top = m_oBrush.Rect.Y;
|
||||
pTextureBrush->m_oBounds.right = pTextureBrush->m_oBounds.left + m_oBrush.Rect.Width;
|
||||
pTextureBrush->m_oBounds.bottom = pTextureBrush->m_oBounds.top + m_oBrush.Rect.Height;
|
||||
pTextureBrush->SetBounds({m_oBrush.Rect.X,
|
||||
m_oBrush.Rect.Y,
|
||||
m_oBrush.Rect.X + m_oBrush.Rect.Width,
|
||||
m_oBrush.Rect.Y + m_oBrush.Rect.Height});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -51,6 +51,16 @@ namespace Aggplus
|
||||
Create(filename);
|
||||
}
|
||||
|
||||
CImage::CImage(const CImage& other)
|
||||
{
|
||||
*this = other;
|
||||
}
|
||||
|
||||
CImage::CImage(CImage&& other)
|
||||
{
|
||||
*this = std::move(other);
|
||||
}
|
||||
|
||||
CImage::~CImage()
|
||||
{
|
||||
Destroy();
|
||||
@ -136,6 +146,46 @@ namespace Aggplus
|
||||
m_bExternalBuffer = false;
|
||||
}
|
||||
|
||||
CImage& CImage::operator=(const CImage& other)
|
||||
{
|
||||
if (this == &other)
|
||||
return *this;
|
||||
|
||||
m_Status = other.m_Status;
|
||||
|
||||
m_dwHeight = other.m_dwHeight;
|
||||
m_dwWidth = other.m_dwWidth;
|
||||
m_nStride = other.m_nStride;
|
||||
|
||||
m_bExternalBuffer = other.m_bExternalBuffer;
|
||||
|
||||
size_t size_of_data = m_dwHeight * m_nStride > 0 ? m_nStride : -m_nStride;
|
||||
m_pImgData = new BYTE[size_of_data];
|
||||
|
||||
memcpy(m_pImgData, other.m_pImgData, size_of_data);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
CImage& CImage::operator=(CImage&& other)
|
||||
{
|
||||
if (this == &other)
|
||||
return *this;
|
||||
|
||||
m_Status = other.m_Status;
|
||||
|
||||
m_dwHeight = other.m_dwHeight;
|
||||
m_dwWidth = other.m_dwWidth;
|
||||
m_nStride = other.m_nStride;
|
||||
|
||||
m_bExternalBuffer = other.m_bExternalBuffer;
|
||||
|
||||
m_pImgData = other.m_pImgData;
|
||||
other.m_pImgData = nullptr;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
DWORD CImage::GetWidth() const { return(m_dwWidth); }
|
||||
DWORD CImage::GetHeight() const { return(m_dwHeight); }
|
||||
long CImage::GetStride() const { return(m_nStride); }
|
||||
@ -146,10 +196,10 @@ namespace Aggplus
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
CBitmap::CBitmap(LONG width, LONG height, PixelFormat format) : CImage()
|
||||
{
|
||||
if(width <= 0 || height <= 0)
|
||||
{
|
||||
m_Status=InvalidParameter;
|
||||
return;
|
||||
if(width <= 0 || height <= 0)
|
||||
{
|
||||
m_Status=InvalidParameter;
|
||||
return;
|
||||
}
|
||||
|
||||
LONG lSize = 4 * width * height;
|
||||
@ -168,15 +218,15 @@ namespace Aggplus
|
||||
CBitmap::CBitmap(LONG width, LONG height, LONG stride, PixelFormat format, BYTE* scan0) : CImage()
|
||||
{
|
||||
//Warning! This is not Gdiplus behavior; it returns Ok!
|
||||
if(width <= 0 || height <= 0 || stride == 0)
|
||||
{
|
||||
m_Status = InvalidParameter;
|
||||
return;
|
||||
if(width <= 0 || height <= 0 || stride == 0)
|
||||
{
|
||||
m_Status = InvalidParameter;
|
||||
return;
|
||||
}
|
||||
|
||||
m_bExternalBuffer = true;
|
||||
|
||||
if (stride > 0)
|
||||
if (stride > 0)
|
||||
{
|
||||
m_pImgData = scan0;
|
||||
}
|
||||
@ -184,7 +234,7 @@ namespace Aggplus
|
||||
{
|
||||
m_pImgData = scan0 + (height - 1) * (-stride);
|
||||
}
|
||||
|
||||
|
||||
m_dwWidth = width;
|
||||
m_dwHeight = height;
|
||||
m_nStride = stride;
|
||||
|
||||
@ -49,6 +49,8 @@ public:
|
||||
public:
|
||||
CImage();
|
||||
CImage(const std::wstring& filename);
|
||||
CImage(const CImage& other);
|
||||
CImage(CImage&& other);
|
||||
virtual ~CImage();
|
||||
|
||||
DWORD GetWidth() const;
|
||||
@ -64,6 +66,9 @@ public:
|
||||
bool SaveFile(const std::wstring& strFileName, UINT nFileType);
|
||||
void Destroy();
|
||||
|
||||
CImage& operator=(const CImage& other);
|
||||
CImage& operator=(CImage&& other);
|
||||
|
||||
protected:
|
||||
Status m_Status;
|
||||
|
||||
|
||||
@ -30,127 +30,133 @@
|
||||
*
|
||||
*/
|
||||
#include "Matrix_private.h"
|
||||
#include <utility>
|
||||
|
||||
namespace Aggplus
|
||||
{
|
||||
CMatrix::CMatrix(double m11, double m12, double m21, double m22, double dx, double dy)
|
||||
CMatrix::CMatrix(double m11, double m12, double m21, double m22, double dx, double dy)
|
||||
{
|
||||
m_internal = new CMatrix_private();
|
||||
m_internal->m_agg_mtx.sx = m11;
|
||||
m_internal->m_agg_mtx.shy = m12;
|
||||
m_internal->m_agg_mtx.shx = m21;
|
||||
m_internal->m_agg_mtx.sy = m22;
|
||||
m_internal->m_agg_mtx.tx = dx;
|
||||
m_internal->m_agg_mtx.ty = dy;
|
||||
m_internal = new CMatrix_private();
|
||||
m_internal->m_agg_mtx.sx = m11;
|
||||
m_internal->m_agg_mtx.shy = m12;
|
||||
m_internal->m_agg_mtx.shx = m21;
|
||||
m_internal->m_agg_mtx.sy = m22;
|
||||
m_internal->m_agg_mtx.tx = dx;
|
||||
m_internal->m_agg_mtx.ty = dy;
|
||||
}
|
||||
|
||||
CMatrix::CMatrix(const CMatrix& oSrc)
|
||||
{
|
||||
m_internal = new CMatrix_private();
|
||||
m_internal->m_agg_mtx = oSrc.m_internal->m_agg_mtx;
|
||||
}
|
||||
|
||||
CMatrix::CMatrix()
|
||||
CMatrix::CMatrix()
|
||||
{
|
||||
m_internal = new CMatrix_private();
|
||||
m_internal = new CMatrix_private();
|
||||
}
|
||||
|
||||
|
||||
CMatrix::CMatrix(const CMatrix& other)
|
||||
{
|
||||
*this = other;
|
||||
}
|
||||
|
||||
CMatrix::CMatrix(CMatrix&& other)
|
||||
{
|
||||
*this = std::move(other);
|
||||
}
|
||||
|
||||
CMatrix::~CMatrix()
|
||||
{
|
||||
RELEASEOBJECT(m_internal);
|
||||
RELEASEOBJECT(m_internal);
|
||||
}
|
||||
|
||||
|
||||
void CMatrix::Translate(double offsetX, double offsetY, MatrixOrder order)
|
||||
{
|
||||
if (order == MatrixOrderPrepend)
|
||||
{
|
||||
m_internal->m_agg_mtx.premultiply(agg::trans_affine_translation(offsetX, offsetY));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_internal->m_agg_mtx.multiply(agg::trans_affine_translation(offsetX, offsetY));
|
||||
}
|
||||
if (order == MatrixOrderPrepend)
|
||||
m_internal->m_agg_mtx.premultiply(agg::trans_affine_translation(offsetX, offsetY));
|
||||
else
|
||||
m_internal->m_agg_mtx.multiply(agg::trans_affine_translation(offsetX, offsetY));
|
||||
}
|
||||
|
||||
void CMatrix::Scale(double scaleX, double scaleY, MatrixOrder order)
|
||||
{
|
||||
if (order == MatrixOrderPrepend)
|
||||
{
|
||||
m_internal->m_agg_mtx.premultiply(agg::trans_affine_scaling(scaleX, scaleY));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_internal->m_agg_mtx.multiply(agg::trans_affine_scaling(scaleX, scaleY));
|
||||
}
|
||||
{
|
||||
if (order == MatrixOrderPrepend)
|
||||
m_internal->m_agg_mtx.premultiply(agg::trans_affine_scaling(scaleX, scaleY));
|
||||
else
|
||||
m_internal->m_agg_mtx.multiply(agg::trans_affine_scaling(scaleX, scaleY));
|
||||
}
|
||||
|
||||
void CMatrix::Shear(double shearX, double shearY, MatrixOrder order)
|
||||
{
|
||||
if (order == MatrixOrderPrepend)
|
||||
{
|
||||
m_internal->m_agg_mtx.premultiply(agg::trans_affine_skewing(shearX, shearY));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_internal->m_agg_mtx.multiply(agg::trans_affine_skewing(shearX, shearY));
|
||||
}
|
||||
if (order == MatrixOrderPrepend)
|
||||
m_internal->m_agg_mtx.premultiply(agg::trans_affine_skewing(shearX, shearY));
|
||||
else
|
||||
m_internal->m_agg_mtx.multiply(agg::trans_affine_skewing(shearX, shearY));
|
||||
}
|
||||
|
||||
double CMatrix::Determinant() const
|
||||
{
|
||||
return m_internal->m_agg_mtx.determinant();
|
||||
}
|
||||
|
||||
void CMatrix::TransformVectors(PointF* pts, int count) const
|
||||
{
|
||||
// Store matrix to an array [6] of double
|
||||
double M[6]; m_internal->m_agg_mtx.store_to(M);
|
||||
double M[6];
|
||||
m_internal->m_agg_mtx.store_to(M);
|
||||
|
||||
for (int i = 0; i < count; ++i)
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
double x = pts[i].X;
|
||||
double y = pts[i].Y;
|
||||
m_internal->m_agg_mtx.transform(&x, &y);
|
||||
pts[i].X = (float)(x-M[4]);
|
||||
pts[i].Y = (float)(y-M[5]);
|
||||
double x = pts[i].X;
|
||||
double y = pts[i].Y;
|
||||
m_internal->m_agg_mtx.transform(&x, &y);
|
||||
pts[i].X = static_cast<float>(x-M[4]);
|
||||
pts[i].Y = static_cast<float>(y-M[5]);
|
||||
}
|
||||
}
|
||||
|
||||
void CMatrix::TransformPoints(PointF* pts, int count) const
|
||||
{
|
||||
for (int i = 0; i < count; ++i)
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
double x = pts[i].X;
|
||||
double y = pts[i].Y;
|
||||
m_internal->m_agg_mtx.transform(&x, &y);
|
||||
pts[i].X = (float)x;
|
||||
pts[i].Y = (float)y;
|
||||
m_internal->m_agg_mtx.transform(&x, &y);
|
||||
pts[i].X = static_cast<float>(x);
|
||||
pts[i].Y = static_cast<float>(y);
|
||||
}
|
||||
}
|
||||
|
||||
void CMatrix::TransformPoint(double& x, double& y) const
|
||||
{
|
||||
m_internal->m_agg_mtx.transform(&x, &y);
|
||||
m_internal->m_agg_mtx.transform(&x, &y);
|
||||
}
|
||||
|
||||
void CMatrix::TransformPoints(PointF* dst, const PointF* src, int count) const
|
||||
{
|
||||
agg::trans_affine& m = m_internal->m_agg_mtx;
|
||||
for(int i = 0; i < count; ++i)
|
||||
{
|
||||
double x = src[i].X * m.sx + src[i].Y * m.shx + m.tx;
|
||||
double y = src[i].Y * m.sy + src[i].X * m.shy + m.ty;
|
||||
|
||||
dst[i].X = static_cast<float>(x);
|
||||
dst[i].Y = static_cast<float>(y);
|
||||
}
|
||||
}
|
||||
|
||||
void CMatrix::Rotate(double angle, MatrixOrder order)
|
||||
{
|
||||
if (order == MatrixOrderPrepend)
|
||||
{
|
||||
m_internal->m_agg_mtx.premultiply(agg::trans_affine_rotation(agg::deg2rad(angle)));
|
||||
}
|
||||
if (order == MatrixOrderPrepend)
|
||||
m_internal->m_agg_mtx.premultiply(agg::trans_affine_rotation(agg::deg2rad(angle)));
|
||||
else
|
||||
{
|
||||
m_internal->m_agg_mtx.multiply(agg::trans_affine_rotation(agg::deg2rad(angle)));
|
||||
}
|
||||
m_internal->m_agg_mtx.multiply(agg::trans_affine_rotation(agg::deg2rad(angle)));
|
||||
}
|
||||
|
||||
void CMatrix::RotateAt(double angle, const PointF ¢er, MatrixOrder order)
|
||||
{
|
||||
Translate(-center.X, -center.Y, order);
|
||||
if(order == MatrixOrderPrepend)
|
||||
{
|
||||
m_internal->m_agg_mtx.premultiply(agg::trans_affine_rotation(agg::deg2rad(angle)));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_internal->m_agg_mtx.multiply(agg::trans_affine_rotation(agg::deg2rad(angle)));
|
||||
}
|
||||
|
||||
if(order == MatrixOrderPrepend)
|
||||
m_internal->m_agg_mtx.premultiply(agg::trans_affine_rotation(agg::deg2rad(angle)));
|
||||
else
|
||||
m_internal->m_agg_mtx.multiply(agg::trans_affine_rotation(agg::deg2rad(angle)));
|
||||
|
||||
Translate(center.X, center.Y, order);
|
||||
return;
|
||||
}
|
||||
@ -158,168 +164,169 @@ namespace Aggplus
|
||||
void CMatrix::RotateAt(double angle, double x, double y, MatrixOrder order)
|
||||
{
|
||||
Translate(-x, -y, order);
|
||||
if (order == MatrixOrderPrepend)
|
||||
{
|
||||
m_internal->m_agg_mtx.premultiply(agg::trans_affine_rotation(agg::deg2rad(angle)));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_internal->m_agg_mtx.multiply(agg::trans_affine_rotation(agg::deg2rad(angle)));
|
||||
}
|
||||
|
||||
if (order == MatrixOrderPrepend)
|
||||
m_internal->m_agg_mtx.premultiply(agg::trans_affine_rotation(agg::deg2rad(angle)));
|
||||
else
|
||||
m_internal->m_agg_mtx.multiply(agg::trans_affine_rotation(agg::deg2rad(angle)));
|
||||
|
||||
Translate(x, y, order);
|
||||
}
|
||||
|
||||
void CMatrix::Multiply(const CMatrix* matrix, MatrixOrder order)
|
||||
{
|
||||
if (order == MatrixOrderPrepend)
|
||||
{
|
||||
m_internal->m_agg_mtx.premultiply(matrix->m_internal->m_agg_mtx);
|
||||
}
|
||||
if (order == MatrixOrderPrepend)
|
||||
m_internal->m_agg_mtx.premultiply(matrix->m_internal->m_agg_mtx);
|
||||
else
|
||||
{
|
||||
m_internal->m_agg_mtx.multiply(matrix->m_internal->m_agg_mtx);
|
||||
}
|
||||
m_internal->m_agg_mtx.multiply(matrix->m_internal->m_agg_mtx);
|
||||
}
|
||||
|
||||
double CMatrix::OffsetX() const
|
||||
{
|
||||
return m_internal->m_agg_mtx.tx;
|
||||
return m_internal->m_agg_mtx.tx;
|
||||
}
|
||||
|
||||
double CMatrix::OffsetY() const
|
||||
{
|
||||
return m_internal->m_agg_mtx.ty;
|
||||
return m_internal->m_agg_mtx.ty;
|
||||
}
|
||||
|
||||
double CMatrix::sx() const
|
||||
{
|
||||
return m_internal->m_agg_mtx.sx;
|
||||
}
|
||||
double CMatrix::sy() const
|
||||
{
|
||||
return m_internal->m_agg_mtx.sy;
|
||||
}
|
||||
double CMatrix::shx() const
|
||||
{
|
||||
return m_internal->m_agg_mtx.shx;
|
||||
}
|
||||
double CMatrix::shy() const
|
||||
{
|
||||
return m_internal->m_agg_mtx.shy;
|
||||
}
|
||||
double CMatrix::tx() const
|
||||
{
|
||||
return m_internal->m_agg_mtx.tx;
|
||||
}
|
||||
double CMatrix::ty() const
|
||||
{
|
||||
return m_internal->m_agg_mtx.ty;
|
||||
}
|
||||
double CMatrix::rotation()
|
||||
{
|
||||
return m_internal->m_agg_mtx.rotation();
|
||||
}
|
||||
|
||||
|
||||
void CMatrix::SetElements(const double& sx, const double& shy, const double& shx, const double& sy, const double& tx, const double& ty)
|
||||
{
|
||||
m_internal->m_agg_mtx.sx = sx;
|
||||
m_internal->m_agg_mtx.shy = shy;
|
||||
m_internal->m_agg_mtx.shx = shx;
|
||||
m_internal->m_agg_mtx.sy = sy;
|
||||
m_internal->m_agg_mtx.tx = tx;
|
||||
m_internal->m_agg_mtx.ty = ty;
|
||||
}
|
||||
|
||||
Status CMatrix::GetElements(REAL* m) const
|
||||
double CMatrix::sx() const
|
||||
{
|
||||
double M[6]; m_internal->m_agg_mtx.store_to(M);
|
||||
m[0]=(REAL)M[0];
|
||||
m[1]=(REAL)M[1];
|
||||
m[2]=(REAL)M[2];
|
||||
m[3]=(REAL)M[3];
|
||||
m[4]=(REAL)M[4];
|
||||
m[5]=(REAL)M[5];
|
||||
return m_internal->m_agg_mtx.sx;
|
||||
}
|
||||
|
||||
double CMatrix::sy() const
|
||||
{
|
||||
return m_internal->m_agg_mtx.sy;
|
||||
}
|
||||
|
||||
double CMatrix::shx() const
|
||||
{
|
||||
return m_internal->m_agg_mtx.shx;
|
||||
}
|
||||
|
||||
double CMatrix::shy() const
|
||||
{
|
||||
return m_internal->m_agg_mtx.shy;
|
||||
}
|
||||
|
||||
double CMatrix::tx() const
|
||||
{
|
||||
return m_internal->m_agg_mtx.tx;
|
||||
}
|
||||
|
||||
double CMatrix::ty() const
|
||||
{
|
||||
return m_internal->m_agg_mtx.ty;
|
||||
}
|
||||
|
||||
double CMatrix::rotation()
|
||||
{
|
||||
return m_internal->m_agg_mtx.rotation();
|
||||
}
|
||||
|
||||
void CMatrix::SetElements(const double& sx, const double& shy, const double& shx,
|
||||
const double& sy, const double& tx, const double& ty)
|
||||
{
|
||||
m_internal->m_agg_mtx.sx = sx;
|
||||
m_internal->m_agg_mtx.shy = shy;
|
||||
m_internal->m_agg_mtx.shx = shx;
|
||||
m_internal->m_agg_mtx.sy = sy;
|
||||
m_internal->m_agg_mtx.tx = tx;
|
||||
m_internal->m_agg_mtx.ty = ty;
|
||||
}
|
||||
|
||||
Status CMatrix::GetElements(float* m) const
|
||||
{
|
||||
double M[6];
|
||||
m_internal->m_agg_mtx.store_to(M);
|
||||
|
||||
m[0] = static_cast<float>(M[0]);
|
||||
m[1] = static_cast<float>(M[1]);
|
||||
m[2] = static_cast<float>(M[2]);
|
||||
m[3] = static_cast<float>(M[3]);
|
||||
m[4] = static_cast<float>(M[4]);
|
||||
m[5] = static_cast<float>(M[5]);
|
||||
|
||||
return Ok;
|
||||
}
|
||||
|
||||
Status CMatrix::GetElements(double* m) const
|
||||
{
|
||||
m_internal->m_agg_mtx.store_to(m);
|
||||
m_internal->m_agg_mtx.store_to(m);
|
||||
return Ok;
|
||||
}
|
||||
|
||||
void CMatrix::Reset()
|
||||
{
|
||||
m_internal->m_agg_mtx.reset();
|
||||
m_internal->m_agg_mtx.reset();
|
||||
}
|
||||
|
||||
double CMatrix::Determinant() const
|
||||
bool CMatrix::IsIdentity(const double& eps) const
|
||||
{
|
||||
return m_internal->m_agg_mtx.determinant();
|
||||
}
|
||||
return m_internal->m_agg_mtx.is_identity(eps);
|
||||
}
|
||||
|
||||
const CMatrix& CMatrix::operator=(const CMatrix& Src)
|
||||
bool CMatrix::IsIdentity2(const double& eps) const
|
||||
{
|
||||
m_internal->m_agg_mtx = Src.m_internal->m_agg_mtx;
|
||||
return *this;
|
||||
agg::trans_affine& m = m_internal->m_agg_mtx;
|
||||
return agg::is_equal_eps(m.sx, 1.0, eps) &&
|
||||
agg::is_equal_eps(m.shy, 0.0, eps) &&
|
||||
agg::is_equal_eps(m.shx, 0.0, eps) &&
|
||||
agg::is_equal_eps(m.sy, 1.0, eps);
|
||||
}
|
||||
|
||||
bool CMatrix::IsEqual(const CMatrix* mm1, const CMatrix* mm2, const double& eps, bool bIsOnlyMain)
|
||||
{
|
||||
agg::trans_affine& m1 = mm1->m_internal->m_agg_mtx;
|
||||
agg::trans_affine& m2 = mm2->m_internal->m_agg_mtx;
|
||||
|
||||
bool bMain = fabs(m1.sx - m2.sx) < eps &&
|
||||
fabs(m1.sy - m2.sy) < eps &&
|
||||
fabs(m1.shx - m2.shx) < eps &&
|
||||
fabs(m1.shy - m2.shy) < eps;
|
||||
|
||||
if (!bMain || bIsOnlyMain)
|
||||
return bMain;
|
||||
|
||||
return fabs(m1.tx - m2.tx) < eps && fabs(m1.ty - m2.ty) < eps;
|
||||
}
|
||||
|
||||
Status CMatrix::Invert()
|
||||
{
|
||||
double d = m_internal->m_agg_mtx.determinant();
|
||||
if (0.0001 >= fabs(d))
|
||||
double d = m_internal->m_agg_mtx.determinant();
|
||||
if (0.0001 >= fabs(d))
|
||||
return InvalidParameter;
|
||||
|
||||
m_internal->m_agg_mtx.invert();
|
||||
m_internal->m_agg_mtx.invert();
|
||||
return Ok;
|
||||
}
|
||||
|
||||
//Temp
|
||||
//Used in X_BrushLinearGradient constructor
|
||||
double CMatrix::z_Rotation() const
|
||||
{
|
||||
return agg::rad2deg(m_internal->m_agg_mtx.rotation());
|
||||
}
|
||||
|
||||
void CMatrix::TransformPoints( PointF* dst, const PointF* src, int count ) const
|
||||
double CMatrix::z_Rotation() const
|
||||
{
|
||||
agg::trans_affine& m = m_internal->m_agg_mtx;
|
||||
for(int i = 0; i < count; ++i)
|
||||
{
|
||||
double x = src[i].X * m.sx + src[i].Y * m.shx + m.tx;
|
||||
double y = src[i].Y * m.sy + src[i].X * m.shy + m.ty;
|
||||
|
||||
dst[i].X = (float)x;
|
||||
dst[i].Y = (float)y;
|
||||
}
|
||||
return agg::rad2deg(m_internal->m_agg_mtx.rotation());
|
||||
}
|
||||
|
||||
bool CMatrix::IsIdentity(const double& eps) const
|
||||
const CMatrix& CMatrix::operator=(const CMatrix& other)
|
||||
{
|
||||
return m_internal->m_agg_mtx.is_identity(eps);
|
||||
if (this == &other)
|
||||
return *this;
|
||||
|
||||
m_internal = new CMatrix_private();
|
||||
m_internal->m_agg_mtx = other.m_internal->m_agg_mtx;
|
||||
return *this;
|
||||
}
|
||||
bool CMatrix::IsIdentity2(const double& eps) const
|
||||
|
||||
CMatrix& CMatrix::operator=(CMatrix&& other)
|
||||
{
|
||||
agg::trans_affine& m = m_internal->m_agg_mtx;
|
||||
return agg::is_equal_eps(m.sx, 1.0, eps) &&
|
||||
agg::is_equal_eps(m.shy, 0.0, eps) &&
|
||||
agg::is_equal_eps(m.shx, 0.0, eps) &&
|
||||
agg::is_equal_eps(m.sy, 1.0, eps);
|
||||
if (this == &other)
|
||||
return *this;
|
||||
|
||||
m_internal = other.m_internal;
|
||||
other.m_internal = nullptr;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool CMatrix::IsEqual(const CMatrix* mm1, const CMatrix* mm2, const double& eps, bool bIsOnlyMain)
|
||||
{
|
||||
agg::trans_affine& m1 = mm1->m_internal->m_agg_mtx;
|
||||
agg::trans_affine& m2 = mm2->m_internal->m_agg_mtx;
|
||||
|
||||
bool bMain = fabs(m1.sx - m2.sx) < eps &&
|
||||
fabs(m1.sy - m2.sy) < eps &&
|
||||
fabs(m1.shx - m2.shx) < eps &&
|
||||
fabs(m1.shy - m2.shy) < eps;
|
||||
|
||||
if (!bMain || bIsOnlyMain)
|
||||
return bMain;
|
||||
|
||||
return fabs(m1.tx - m2.tx) < eps && fabs(m1.ty - m2.ty) < eps;
|
||||
}
|
||||
}
|
||||
|
||||
@ -37,62 +37,62 @@
|
||||
|
||||
namespace Aggplus
|
||||
{
|
||||
class CMatrix_private;
|
||||
class GRAPHICS_DECL CMatrix
|
||||
{
|
||||
public:
|
||||
CMatrix(double m11, double m12, double m21, double m22, double dx, double dy);
|
||||
CMatrix();
|
||||
CMatrix(const CMatrix& oSrc);
|
||||
class CMatrix_private;
|
||||
class GRAPHICS_DECL CMatrix
|
||||
{
|
||||
public:
|
||||
CMatrix();
|
||||
CMatrix(double m11, double m12, double m21, double m22, double dx, double dy);
|
||||
CMatrix(const CMatrix& other);
|
||||
CMatrix(CMatrix&& other);
|
||||
~CMatrix();
|
||||
|
||||
~CMatrix();
|
||||
void Translate(double offsetX, double offsetY, MatrixOrder order = MatrixOrderPrepend);
|
||||
void Scale(double scaleX, double scaleY, MatrixOrder order = MatrixOrderPrepend);
|
||||
void Shear(double shearX, double shearY, MatrixOrder order = MatrixOrderPrepend);
|
||||
double Determinant() const;
|
||||
|
||||
void Translate(double offsetX, double offsetY, MatrixOrder order = MatrixOrderPrepend);
|
||||
void Scale(double scaleX, double scaleY, MatrixOrder order = MatrixOrderPrepend);
|
||||
void Shear(double shearX, double shearY, MatrixOrder order = MatrixOrderPrepend);
|
||||
double Determinant() const;
|
||||
void TransformVectors(PointF* pts, int count) const;
|
||||
void TransformPoints(PointF* pts, int count) const;
|
||||
void TransformPoint(double& x, double& y) const;
|
||||
void TransformPoints(PointF* dst, const PointF* src, int count) const;
|
||||
|
||||
void TransformVectors(PointF* pts, int count) const;
|
||||
void TransformPoints(PointF* pts, int count) const;
|
||||
void TransformPoint(double& x, double& y) const;
|
||||
void TransformPoints(PointF* dst, const PointF* src, int count) const;
|
||||
void Rotate(double angle, MatrixOrder order = MatrixOrderPrepend);
|
||||
void RotateAt(double angle, const PointF ¢er, MatrixOrder order = MatrixOrderPrepend);
|
||||
void RotateAt(double angle, double x, double y, MatrixOrder order = MatrixOrderPrepend);
|
||||
|
||||
void Rotate(double angle, MatrixOrder order = MatrixOrderPrepend);
|
||||
void RotateAt(double angle, const PointF ¢er, MatrixOrder order = MatrixOrderPrepend);
|
||||
void RotateAt(double angle, double x, double y, MatrixOrder order = MatrixOrderPrepend);
|
||||
void Multiply(const CMatrix* matrix, MatrixOrder order = MatrixOrderPrepend);
|
||||
|
||||
void Multiply(const CMatrix* matrix, MatrixOrder order = MatrixOrderPrepend);
|
||||
double OffsetX() const;
|
||||
double OffsetY() const;
|
||||
|
||||
double OffsetX() const;
|
||||
double OffsetY() const;
|
||||
double sx() const;
|
||||
double sy() const;
|
||||
double shx() const;
|
||||
double shy() const;
|
||||
double tx() const;
|
||||
double ty() const;
|
||||
double rotation();
|
||||
|
||||
double sx() const;
|
||||
double sy() const;
|
||||
double shx() const;
|
||||
double shy() const;
|
||||
double tx() const;
|
||||
double ty() const;
|
||||
double rotation();
|
||||
void SetElements(const double& sx, const double& shy, const double& shx, const double& sy, const double& tx = 0, const double& ty = 0);
|
||||
void SetElements(const double& sx, const double& shy, const double& shx, const double& sy, const double& tx = 0, const double& ty = 0);
|
||||
Status GetElements(float* m) const;
|
||||
Status GetElements(double* m) const;
|
||||
|
||||
Status GetElements(float* m) const;
|
||||
Status GetElements(double* m) const;
|
||||
void Reset();
|
||||
bool IsIdentity(const double& eps = 0.00001) const;
|
||||
bool IsIdentity2(const double& eps = 0.00001) const;
|
||||
|
||||
void Reset();
|
||||
bool IsIdentity(const double& eps = 0.00001) const;
|
||||
bool IsIdentity2(const double& eps = 0.00001) const;
|
||||
static bool IsEqual(const CMatrix* m1, const CMatrix* m2, const double& eps = 0.001, bool bIsOnlyMain = false);
|
||||
|
||||
static bool IsEqual(const CMatrix* m1, const CMatrix* m2, const double& eps = 0.001, bool bIsOnlyMain = false);
|
||||
Status Invert();
|
||||
|
||||
const CMatrix& operator=(const CMatrix& Src);
|
||||
double z_Rotation() const;
|
||||
|
||||
Status Invert();
|
||||
const CMatrix& operator=(const CMatrix& other);
|
||||
CMatrix& operator=(CMatrix&& other);
|
||||
|
||||
double z_Rotation() const;
|
||||
|
||||
public:
|
||||
CMatrix_private* m_internal;
|
||||
};
|
||||
public:
|
||||
CMatrix_private* m_internal;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // _BUILD_MATRIX_H_
|
||||
|
||||
@ -153,13 +153,6 @@ IMetafileToRenderter::IMetafileToRenderter(IRenderer* pRenderer)
|
||||
}
|
||||
IMetafileToRenderter::~IMetafileToRenderter()
|
||||
{
|
||||
for (std::vector<std::wstring>::iterator i = m_arTempFiles.begin(); i != m_arTempFiles.end(); i++)
|
||||
{
|
||||
std::wstring sPath = *i;
|
||||
if (NSFile::CFileBinary::Exists(sPath))
|
||||
NSFile::CFileBinary::Remove(sPath);
|
||||
}
|
||||
|
||||
if (m_pPicker)
|
||||
{
|
||||
CMetafileFontPicker* pPicker = (CMetafileFontPicker*)m_pPicker;
|
||||
@ -234,8 +227,6 @@ std::wstring IMetafileToRenderter::GetImagePath(const std::wstring& sPath)
|
||||
oFrame.put_Data(NULL);
|
||||
sImagePath = sTempFile;
|
||||
}
|
||||
|
||||
m_arTempFiles.push_back(sTempFile);
|
||||
}
|
||||
|
||||
RELEASEARRAYOBJECTS(pImageBuffer);
|
||||
|
||||
@ -49,7 +49,6 @@ public:
|
||||
|
||||
protected:
|
||||
std::wstring m_sTempDir;
|
||||
std::vector<std::wstring> m_arTempFiles;
|
||||
|
||||
std::wstring m_sThemesDir;
|
||||
std::wstring m_sMediaDir;
|
||||
|
||||
@ -48,7 +48,7 @@
|
||||
|
||||
CAnnotFieldInfo::CAnnotFieldInfo() : IAdvancedCommand(AdvancedCommandType::Annotaion)
|
||||
{
|
||||
m_nType = -1;
|
||||
m_nType = EAnnotType::Unknown;
|
||||
|
||||
m_nFlag = 0;
|
||||
m_nID = 0;
|
||||
@ -94,118 +94,108 @@ CAnnotFieldInfo::~CAnnotFieldInfo()
|
||||
RELEASEOBJECT(m_pWidgetPr);
|
||||
}
|
||||
|
||||
void CAnnotFieldInfo::CreateMarkup()
|
||||
{
|
||||
RELEASEOBJECT(m_pMarkupPr);
|
||||
m_pMarkupPr = new CAnnotFieldInfo::CMarkupAnnotPr();
|
||||
}
|
||||
void CAnnotFieldInfo::SetType(int nType)
|
||||
{
|
||||
m_nType = nType;
|
||||
switch (nType)
|
||||
m_nType = static_cast<EAnnotType>(nType);
|
||||
switch (m_nType)
|
||||
{
|
||||
case 0:
|
||||
case EAnnotType::Text:
|
||||
{
|
||||
RELEASEOBJECT(m_pMarkupPr);
|
||||
m_pMarkupPr = new CAnnotFieldInfo::CMarkupAnnotPr();
|
||||
|
||||
CreateMarkup();
|
||||
RELEASEOBJECT(m_pTextPr);
|
||||
m_pTextPr = new CAnnotFieldInfo::CTextAnnotPr();
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
case EAnnotType::FreeText:
|
||||
{
|
||||
RELEASEOBJECT(m_pMarkupPr);
|
||||
m_pMarkupPr = new CAnnotFieldInfo::CMarkupAnnotPr();
|
||||
|
||||
CreateMarkup();
|
||||
RELEASEOBJECT(m_pFreeTextPr);
|
||||
m_pFreeTextPr = new CAnnotFieldInfo::CFreeTextAnnotPr();
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
case EAnnotType::Line:
|
||||
{
|
||||
RELEASEOBJECT(m_pMarkupPr);
|
||||
m_pMarkupPr = new CAnnotFieldInfo::CMarkupAnnotPr();
|
||||
|
||||
CreateMarkup();
|
||||
RELEASEOBJECT(m_pLinePr);
|
||||
m_pLinePr = new CAnnotFieldInfo::CLineAnnotPr();
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
case 5:
|
||||
case EAnnotType::Square:
|
||||
case EAnnotType::Circle:
|
||||
{
|
||||
RELEASEOBJECT(m_pMarkupPr);
|
||||
m_pMarkupPr = new CAnnotFieldInfo::CMarkupAnnotPr();
|
||||
|
||||
CreateMarkup();
|
||||
RELEASEOBJECT(m_pSquareCirclePr);
|
||||
m_pSquareCirclePr = new CAnnotFieldInfo::CSquareCircleAnnotPr();
|
||||
break;
|
||||
}
|
||||
case 6:
|
||||
case 7:
|
||||
case EAnnotType::PolygonLine:
|
||||
case EAnnotType::PolyLine:
|
||||
{
|
||||
RELEASEOBJECT(m_pMarkupPr);
|
||||
m_pMarkupPr = new CAnnotFieldInfo::CMarkupAnnotPr();
|
||||
|
||||
CreateMarkup();
|
||||
RELEASEOBJECT(m_pPolygonLinePr);
|
||||
m_pPolygonLinePr = new CAnnotFieldInfo::CPolygonLineAnnotPr();
|
||||
break;
|
||||
}
|
||||
case 8:
|
||||
case 9:
|
||||
case 10:
|
||||
case 11:
|
||||
case EAnnotType::Highlight:
|
||||
case EAnnotType::Underline:
|
||||
case EAnnotType::Squiggly:
|
||||
case EAnnotType::Strikeout:
|
||||
{
|
||||
RELEASEOBJECT(m_pMarkupPr);
|
||||
m_pMarkupPr = new CAnnotFieldInfo::CMarkupAnnotPr();
|
||||
|
||||
CreateMarkup();
|
||||
RELEASEOBJECT(m_pTextMarkupPr);
|
||||
m_pTextMarkupPr = new CAnnotFieldInfo::CTextMarkupAnnotPr();
|
||||
break;
|
||||
}
|
||||
case 12:
|
||||
case EAnnotType::Stamp:
|
||||
{
|
||||
RELEASEOBJECT(m_pMarkupPr);
|
||||
m_pMarkupPr = new CAnnotFieldInfo::CMarkupAnnotPr();
|
||||
|
||||
CreateMarkup();
|
||||
RELEASEOBJECT(m_pStampPr);
|
||||
m_pStampPr = new CAnnotFieldInfo::CStampAnnotPr();
|
||||
break;
|
||||
}
|
||||
case 13:
|
||||
case EAnnotType::Caret:
|
||||
{
|
||||
RELEASEOBJECT(m_pMarkupPr);
|
||||
m_pMarkupPr = new CAnnotFieldInfo::CMarkupAnnotPr();
|
||||
|
||||
CreateMarkup();
|
||||
RELEASEOBJECT(m_pCaretPr);
|
||||
m_pCaretPr = new CAnnotFieldInfo::CCaretAnnotPr();
|
||||
break;
|
||||
}
|
||||
case 14:
|
||||
case EAnnotType::Ink:
|
||||
{
|
||||
RELEASEOBJECT(m_pMarkupPr);
|
||||
m_pMarkupPr = new CAnnotFieldInfo::CMarkupAnnotPr();
|
||||
|
||||
CreateMarkup();
|
||||
RELEASEOBJECT(m_pInkPr);
|
||||
m_pInkPr = new CAnnotFieldInfo::CInkAnnotPr();
|
||||
break;
|
||||
}
|
||||
case 15:
|
||||
case EAnnotType::Popup:
|
||||
{
|
||||
RELEASEOBJECT(m_pPopupPr);
|
||||
m_pPopupPr = new CAnnotFieldInfo::CPopupAnnotPr();
|
||||
break;
|
||||
}
|
||||
case 26:
|
||||
case 27:
|
||||
case 28:
|
||||
case 29:
|
||||
case 30:
|
||||
case 31:
|
||||
case 32:
|
||||
case 33:
|
||||
case EAnnotType::Widget:
|
||||
case EAnnotType::WidgetPushButton:
|
||||
case EAnnotType::WidgetRadioButton:
|
||||
case EAnnotType::WidgetCheckBox:
|
||||
case EAnnotType::WidgetText:
|
||||
case EAnnotType::WidgetCombobox:
|
||||
case EAnnotType::WidgetListbox:
|
||||
case EAnnotType::WidgetSignature:
|
||||
{
|
||||
RELEASEOBJECT(m_pWidgetPr);
|
||||
m_pWidgetPr = new CAnnotFieldInfo::CWidgetAnnotPr(nType);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
CAnnotFieldInfo::EAnnotType CAnnotFieldInfo::GetType() { return m_nType; }
|
||||
|
||||
void CAnnotFieldInfo::GetBounds(double& dX1, double& dY1, double& dX2, double& dY2)
|
||||
{
|
||||
@ -343,6 +333,7 @@ bool CAnnotFieldInfo::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMeta
|
||||
if (nFlags & (1 << 3))
|
||||
{
|
||||
int n = pReader->ReadInt();
|
||||
m_arrC.reserve(n);
|
||||
for (int i = 0; i < n; ++i)
|
||||
m_arrC.push_back(pReader->ReadDouble());
|
||||
}
|
||||
@ -353,6 +344,7 @@ bool CAnnotFieldInfo::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMeta
|
||||
if (m_oBorder.nType == 2)
|
||||
{
|
||||
int n = pReader->ReadInt();
|
||||
m_oBorder.arrDash.reserve(n);
|
||||
for (int i = 0; i < n; ++i)
|
||||
m_oBorder.arrDash.push_back(pReader->ReadDouble());
|
||||
}
|
||||
@ -428,6 +420,7 @@ void CAnnotFieldInfo::CMarkupAnnotPr::Read(NSOnlineOfficeBinToPdf::CBufferReader
|
||||
if (nFlags & (1 << 3))
|
||||
{
|
||||
int nFont = pReader->ReadInt();
|
||||
m_arrRC.reserve(nFont);
|
||||
for (int i = 0; i < nFont; ++i)
|
||||
{
|
||||
CFontData* pFont = new CFontData();
|
||||
@ -480,6 +473,7 @@ void CAnnotFieldInfo::CInkAnnotPr::Read(NSOnlineOfficeBinToPdf::CBufferReader* p
|
||||
{
|
||||
std::vector<double> arrLine;
|
||||
int m = pReader->ReadInt();
|
||||
arrLine.reserve(m);
|
||||
for (int j = 0; j < m; ++j)
|
||||
arrLine.push_back(pReader->ReadDouble());
|
||||
if (!arrLine.empty())
|
||||
@ -512,6 +506,7 @@ void CAnnotFieldInfo::CLineAnnotPr::Read(NSOnlineOfficeBinToPdf::CBufferReader*
|
||||
if (nFlags & (1 << 16))
|
||||
{
|
||||
int n = pReader->ReadInt();
|
||||
m_arrIC.reserve(n);
|
||||
for (int i = 0; i < n; ++i)
|
||||
m_arrIC.push_back(pReader->ReadDouble());
|
||||
}
|
||||
@ -539,6 +534,7 @@ void CAnnotFieldInfo::CTextMarkupAnnotPr::Read(NSOnlineOfficeBinToPdf::CBufferRe
|
||||
{
|
||||
m_nSubtype = nType;
|
||||
int n = pReader->ReadInt();
|
||||
m_arrQuadPoints.reserve(n);
|
||||
for (int i = 0; i < n; ++i)
|
||||
m_arrQuadPoints.push_back(pReader->ReadDouble());
|
||||
}
|
||||
@ -559,6 +555,7 @@ void CAnnotFieldInfo::CSquareCircleAnnotPr::Read(NSOnlineOfficeBinToPdf::CBuffer
|
||||
if (nFlags & (1 << 16))
|
||||
{
|
||||
int n = pReader->ReadInt();
|
||||
m_arrIC.reserve(n);
|
||||
for (int i = 0; i < n; ++i)
|
||||
m_arrIC.push_back(pReader->ReadDouble());
|
||||
}
|
||||
@ -572,6 +569,7 @@ const std::vector<double>& CAnnotFieldInfo::CPolygonLineAnnotPr::GetVertices() {
|
||||
void CAnnotFieldInfo::CPolygonLineAnnotPr::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, BYTE nType, int nFlags)
|
||||
{
|
||||
int n = pReader->ReadInt();
|
||||
m_arrVertices.reserve(n);
|
||||
for (int i = 0; i < n; ++i)
|
||||
m_arrVertices.push_back(pReader->ReadDouble());
|
||||
|
||||
@ -584,6 +582,7 @@ void CAnnotFieldInfo::CPolygonLineAnnotPr::Read(NSOnlineOfficeBinToPdf::CBufferR
|
||||
if (nFlags & (1 << 16))
|
||||
{
|
||||
int n = pReader->ReadInt();
|
||||
m_arrIC.reserve(n);
|
||||
for (int i = 0; i < n; ++i)
|
||||
m_arrIC.push_back(pReader->ReadDouble());
|
||||
}
|
||||
@ -613,6 +612,7 @@ void CAnnotFieldInfo::CFreeTextAnnotPr::Read(NSOnlineOfficeBinToPdf::CBufferRead
|
||||
if (nFlags & (1 << 16))
|
||||
{
|
||||
int n = pReader->ReadInt();
|
||||
m_arrCL.reserve(n);
|
||||
for (int i = 0; i < n; ++i)
|
||||
m_arrCL.push_back(pReader->ReadDouble());
|
||||
}
|
||||
@ -625,6 +625,7 @@ void CAnnotFieldInfo::CFreeTextAnnotPr::Read(NSOnlineOfficeBinToPdf::CBufferRead
|
||||
if (nFlags & (1 << 21))
|
||||
{
|
||||
int n = pReader->ReadInt();
|
||||
m_arrIC.reserve(n);
|
||||
for (int i = 0; i < n; ++i)
|
||||
m_arrIC.push_back(pReader->ReadDouble());
|
||||
}
|
||||
@ -814,6 +815,7 @@ CAnnotFieldInfo::CWidgetAnnotPr::CActionWidget* ReadAction(NSOnlineOfficeBinToPd
|
||||
{
|
||||
pRes->nKind = pReader->ReadByte();
|
||||
int n = pReader->ReadInt();
|
||||
pRes->arrStr.reserve(n);
|
||||
for (int i = 0; i < n; ++i)
|
||||
pRes->arrStr.push_back(pReader->ReadString());
|
||||
break;
|
||||
@ -822,6 +824,7 @@ CAnnotFieldInfo::CWidgetAnnotPr::CActionWidget* ReadAction(NSOnlineOfficeBinToPd
|
||||
{
|
||||
pRes->nInt1 = pReader->ReadInt();
|
||||
int n = pReader->ReadInt();
|
||||
pRes->arrStr.reserve(n);
|
||||
for (int i = 0; i < n; ++i)
|
||||
pRes->arrStr.push_back(pReader->ReadString());
|
||||
break;
|
||||
@ -841,6 +844,7 @@ void CAnnotFieldInfo::CWidgetAnnotPr::Read(NSOnlineOfficeBinToPdf::CBufferReader
|
||||
m_nFontStyle = pReader->ReadInt();
|
||||
|
||||
int n = pReader->ReadInt();
|
||||
m_arrTC.reserve(n);
|
||||
for (int i = 0; i < n; ++i)
|
||||
m_arrTC.push_back(pReader->ReadDouble());
|
||||
|
||||
@ -863,6 +867,7 @@ void CAnnotFieldInfo::CWidgetAnnotPr::Read(NSOnlineOfficeBinToPdf::CBufferReader
|
||||
if (nFlags & (1 << 5))
|
||||
{
|
||||
int n = pReader->ReadInt();
|
||||
m_arrBC.reserve(n);
|
||||
for (int i = 0; i < n; ++i)
|
||||
m_arrBC.push_back(pReader->ReadDouble());
|
||||
}
|
||||
@ -871,6 +876,7 @@ void CAnnotFieldInfo::CWidgetAnnotPr::Read(NSOnlineOfficeBinToPdf::CBufferReader
|
||||
if (nFlags & (1 << 7))
|
||||
{
|
||||
int n = pReader->ReadInt();
|
||||
m_arrBG.reserve(n);
|
||||
for (int i = 0; i < n; ++i)
|
||||
m_arrBG.push_back(pReader->ReadDouble());
|
||||
}
|
||||
@ -1006,6 +1012,7 @@ void CAnnotFieldInfo::CWidgetAnnotPr::CChoiceWidgetPr::Read(NSOnlineOfficeBinToP
|
||||
if (nFlags & (1 << 10))
|
||||
{
|
||||
int n = pReader->ReadInt();
|
||||
m_arrOpt.reserve(n);
|
||||
for (int i = 0; i < n; ++i)
|
||||
{
|
||||
std::wstring s1 = pReader->ReadString();
|
||||
@ -1020,12 +1027,14 @@ void CAnnotFieldInfo::CWidgetAnnotPr::CChoiceWidgetPr::Read(NSOnlineOfficeBinToP
|
||||
if (nFlags & (1 << 13))
|
||||
{
|
||||
int n = pReader->ReadInt();
|
||||
m_arrV.reserve(n);
|
||||
for (int i = 0; i < n; ++i)
|
||||
m_arrV.push_back(pReader->ReadString());
|
||||
}
|
||||
if (nFlags & (1 << 14))
|
||||
{
|
||||
int n = pReader->ReadInt();
|
||||
m_arrI.reserve(n);
|
||||
for (int i = 0; i < n; ++i)
|
||||
m_arrI.push_back(pReader->ReadInt());
|
||||
}
|
||||
@ -1058,10 +1067,12 @@ const std::vector<CWidgetsInfo::CParent*>& CWidgetsInfo::GetParents() { return m
|
||||
bool CWidgetsInfo::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMetafileToRenderter* pCorrector)
|
||||
{
|
||||
int n = pReader->ReadInt();
|
||||
m_arrCO.reserve(n);
|
||||
for (int i = 0; i < n; ++i)
|
||||
m_arrCO.push_back(pReader->ReadInt());
|
||||
|
||||
n = pReader->ReadInt();
|
||||
m_arrParents.reserve(n);
|
||||
for (int i = 0; i < n; ++i)
|
||||
{
|
||||
CParent* pParent = new CParent();
|
||||
@ -1077,6 +1088,7 @@ bool CWidgetsInfo::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMetafil
|
||||
if (nFlags & (1 << 3))
|
||||
{
|
||||
int n = pReader->ReadInt();
|
||||
pParent->arrI.reserve(n);
|
||||
for (int i = 0; i < n; ++i)
|
||||
pParent->arrI.push_back(pReader->ReadInt());
|
||||
}
|
||||
@ -1085,6 +1097,7 @@ bool CWidgetsInfo::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMetafil
|
||||
if (nFlags & (1 << 5))
|
||||
{
|
||||
int n = pReader->ReadInt();
|
||||
pParent->arrV.reserve(n);
|
||||
for (int i = 0; i < n; ++i)
|
||||
pParent->arrV.push_back(pReader->ReadString());
|
||||
}
|
||||
@ -1092,6 +1105,7 @@ bool CWidgetsInfo::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMetafil
|
||||
}
|
||||
|
||||
n = pReader->ReadInt();
|
||||
m_arrButtonImg.reserve(n);
|
||||
for (int i = 0; i < n; ++i)
|
||||
{
|
||||
std::string sImagePath = pReader->ReadStringA();
|
||||
|
||||
@ -39,6 +39,36 @@ class IMetafileToRenderter;
|
||||
class GRAPHICS_DECL CAnnotFieldInfo : public IAdvancedCommand
|
||||
{
|
||||
public:
|
||||
enum EAnnotType
|
||||
{
|
||||
Unknown = -1,
|
||||
Text = 0,
|
||||
Link = 1,
|
||||
FreeText = 2,
|
||||
Line = 3,
|
||||
Square = 4,
|
||||
Circle = 5,
|
||||
PolygonLine = 6,
|
||||
PolyLine = 7,
|
||||
Highlight = 8,
|
||||
Underline = 9,
|
||||
Squiggly = 10,
|
||||
Strikeout = 11,
|
||||
Stamp = 12,
|
||||
Caret = 13,
|
||||
Ink = 14,
|
||||
Popup = 15,
|
||||
FileAttachment = 16,
|
||||
Widget = 26,
|
||||
WidgetPushButton = 27,
|
||||
WidgetRadioButton = 28,
|
||||
WidgetCheckBox = 29,
|
||||
WidgetText = 30,
|
||||
WidgetCombobox = 31,
|
||||
WidgetListbox = 32,
|
||||
WidgetSignature = 33
|
||||
};
|
||||
|
||||
class GRAPHICS_DECL CWidgetAnnotPr
|
||||
{
|
||||
public:
|
||||
@ -423,7 +453,9 @@ public:
|
||||
CAnnotFieldInfo();
|
||||
virtual ~CAnnotFieldInfo();
|
||||
|
||||
void CreateMarkup();
|
||||
void SetType(int nType);
|
||||
EAnnotType GetType();
|
||||
|
||||
void GetBounds(double& dX1, double& dY1, double& dX2, double& dY2);
|
||||
void GetBorder(BYTE& nType, double& dWidth, std::vector<double>& arrDash);
|
||||
@ -479,7 +511,7 @@ private:
|
||||
std::vector<double> arrDash;
|
||||
};
|
||||
|
||||
int m_nType;
|
||||
EAnnotType m_nType;
|
||||
double m_dX1;
|
||||
double m_dY1;
|
||||
double m_dX2;
|
||||
|
||||
@ -701,6 +701,7 @@ namespace NSFonts
|
||||
virtual void Initialize() = 0;
|
||||
virtual void SetOwnerCache(IFontsCache* pCache) = 0;
|
||||
virtual void CreateOwnerCache(const int& nCacheSize = -1);
|
||||
virtual void ClearOwnerCache() = 0;
|
||||
|
||||
virtual void AfterLoad() = 0;
|
||||
|
||||
|
||||
@ -110,11 +110,20 @@ namespace NSImages
|
||||
#ifndef GRAPHICS_DISABLE_METAFILE
|
||||
namespace MetaFile
|
||||
{
|
||||
const int c_lMetaWmf = 0x01;
|
||||
const int c_lMetaEmf = 0x02;
|
||||
const int c_lMetaSvg = 0x04;
|
||||
const int c_lMetaSvm = 0x05;
|
||||
/**
|
||||
* @brief Meta file extension constants
|
||||
*/
|
||||
const long c_lMetaWmf = 0x0001;
|
||||
const long c_lMetaEmf = 0x0002;
|
||||
const long c_lMetaSvg = 0x0004;
|
||||
const long c_lMetaSvm = 0x0005;
|
||||
|
||||
/**
|
||||
* @interface IMetaFile
|
||||
*
|
||||
* The interface provides various options for loading a metafile and saving it
|
||||
* in another format.
|
||||
*/
|
||||
class GRAPHICS_DECL IMetaFile : public NSBase::CBaseRefCounter
|
||||
{
|
||||
public:
|
||||
@ -124,23 +133,20 @@ namespace MetaFile
|
||||
virtual bool LoadFromFile(const wchar_t* wsFilePath) = 0;
|
||||
virtual bool LoadFromBuffer(BYTE* pBuffer, unsigned int unSize) = 0;
|
||||
virtual bool LoadFromString(const std::wstring& data) = 0;
|
||||
virtual bool DrawOnRenderer(IRenderer* pRenderer, double dX, double dY, double dWidth, double dHeight) = 0;
|
||||
virtual bool DrawOnRenderer(IRenderer* pRenderer, double dX, double dY,
|
||||
double dWidth, double dHeight, const wchar_t* wsXmlFilePath = NULL) = 0;
|
||||
virtual void Close() = 0;
|
||||
virtual void GetBounds(double* pdX, double* pdY, double* pdW, double* pdH) = 0;
|
||||
virtual int GetType() = 0;
|
||||
virtual void ConvertToRaster(const wchar_t* wsOutFilePath, unsigned int unFileType, int nWidth, int nHeight = -1) = 0;
|
||||
virtual void ConvertToRaster(const wchar_t* wsOutFilePath, unsigned int unFileType, int nWidth, int nHeight = -1, const wchar_t* wsXmlOutFile = NULL) = 0;
|
||||
virtual NSFonts::IFontManager* get_FontManager() = 0;
|
||||
|
||||
virtual std::wstring ConvertToSvg(unsigned int unWidth = 0, unsigned int unHeight = 0) = 0;
|
||||
virtual void SetTempDirectory(const std::wstring& dir) = 0;
|
||||
|
||||
//Для тестов
|
||||
#ifdef METAFILE_SUPPORT_WMF_EMF
|
||||
virtual void ConvertToXml(const wchar_t *wsFilePath) = 0;
|
||||
virtual void ConvertToXmlAndRaster(const wchar_t *wsXmlFilePath, const wchar_t* wsOutFilePath, unsigned int unFileType, int nWidth, int nHeight = -1) = 0;
|
||||
virtual bool LoadFromXmlFile(const wchar_t* wsFilePath) = 0;
|
||||
virtual void ConvertToXml(const wchar_t *wsFilePath) = 0;
|
||||
virtual void ConvertToEmf(const wchar_t *wsFilePath) = 0;
|
||||
#endif
|
||||
};
|
||||
|
||||
GRAPHICS_DECL IMetaFile* Create(NSFonts::IApplicationFonts *pAppFonts);
|
||||
|
||||
@ -682,6 +682,7 @@ HEADERS += \
|
||||
$$DOCX_RENDERER_ROOT_DIR/src/logic/elements/DropCap.h \
|
||||
$$DOCX_RENDERER_ROOT_DIR/src/logic/elements/Paragraph.h \
|
||||
$$DOCX_RENDERER_ROOT_DIR/src/logic/elements/Shape.h \
|
||||
$$DOCX_RENDERER_ROOT_DIR/src/logic/elements/Table.h \
|
||||
$$DOCX_RENDERER_ROOT_DIR/src/logic/elements/TextLine.h \
|
||||
$$DOCX_RENDERER_ROOT_DIR/src/logic/managers/ExternalImageStorage.h \
|
||||
$$DOCX_RENDERER_ROOT_DIR/src/logic/managers/FontStyleManager.h \
|
||||
@ -706,6 +707,7 @@ SOURCES += \
|
||||
$$DOCX_RENDERER_ROOT_DIR/src/logic/elements/ContText.cpp \
|
||||
$$DOCX_RENDERER_ROOT_DIR/src/logic/elements/Paragraph.cpp \
|
||||
$$DOCX_RENDERER_ROOT_DIR/src/logic/elements/Shape.cpp \
|
||||
$$DOCX_RENDERER_ROOT_DIR/src/logic/elements/Table.cpp \
|
||||
$$DOCX_RENDERER_ROOT_DIR/src/logic/elements/TextLine.cpp \
|
||||
$$DOCX_RENDERER_ROOT_DIR/src/logic/managers/FontManager.cpp \
|
||||
$$DOCX_RENDERER_ROOT_DIR/src/logic/managers/FontStyleManager.cpp \
|
||||
|
||||
@ -1,11 +0,0 @@
|
||||
#include <codecvt>
|
||||
|
||||
#include "../../pro/Graphics.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
Aggplus::CImage Cimg(std::wstring_convert<std::codecvt_utf8<wchar_t>>().from_bytes(argv[1]));
|
||||
Cimg.SaveFile(std::wstring_convert<std::codecvt_utf8<wchar_t>>().from_bytes(argv[2]), 1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
11
DesktopEditor/graphics/tests/hatchBrush/main.cpp
Normal file
11
DesktopEditor/graphics/tests/hatchBrush/main.cpp
Normal file
@ -0,0 +1,11 @@
|
||||
#include "mainwindow.h"
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
MainWindow w;
|
||||
w.show();
|
||||
return a.exec();
|
||||
}
|
||||
182
DesktopEditor/graphics/tests/hatchBrush/mainwindow.cpp
Normal file
182
DesktopEditor/graphics/tests/hatchBrush/mainwindow.cpp
Normal file
@ -0,0 +1,182 @@
|
||||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
|
||||
#include <QImage>
|
||||
#include <QPixmap>
|
||||
#include <QSpinBox>
|
||||
#include <QComboBox>
|
||||
#include <QStringList>
|
||||
|
||||
#include "../../pro/Graphics.h"
|
||||
|
||||
static constexpr double rectangle[4] = {
|
||||
10.0, 10.0, 80.0, 80.0,
|
||||
};
|
||||
|
||||
static const QStringList patterns = {
|
||||
"cross",
|
||||
"dashDnDiag",
|
||||
"dashHorz",
|
||||
"dashUpDiag",
|
||||
"dashVert",
|
||||
"diagBrick",
|
||||
"diagCross",
|
||||
"divot",
|
||||
"dkDnDiag",
|
||||
"dkHorz",
|
||||
"dkUpDiag",
|
||||
"dkVert",
|
||||
"dnDiag",
|
||||
"dotDmnd",
|
||||
"dotGrid",
|
||||
"horz",
|
||||
"horzBrick",
|
||||
"lgCheck",
|
||||
"lgConfetti",
|
||||
"lgGrid",
|
||||
"ltDnDiag",
|
||||
"ltHorz",
|
||||
"ltUpDiag",
|
||||
"ltVert",
|
||||
"narHorz",
|
||||
"narVert",
|
||||
"openDmnd",
|
||||
"pct10",
|
||||
"pct20",
|
||||
"pct25",
|
||||
"pct30",
|
||||
"pct40",
|
||||
"pct5",
|
||||
"pct50",
|
||||
"pct60",
|
||||
"pct70",
|
||||
"pct75",
|
||||
"pct80",
|
||||
"pct90",
|
||||
"plaid",
|
||||
"shingle",
|
||||
"smCheck",
|
||||
"smConfetti",
|
||||
"smGrid",
|
||||
"solidDmnd",
|
||||
"sphere",
|
||||
"trellis",
|
||||
"upDiag",
|
||||
"vert",
|
||||
"wave",
|
||||
"wdDnDiag",
|
||||
"wdUpDiag",
|
||||
"weave",
|
||||
"zigZag"
|
||||
};
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent)
|
||||
: QMainWindow(parent)
|
||||
, ui(new Ui::MainWindow)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->pushButton->SetColor(Qt::red);
|
||||
ui->pushButton_2->SetColor(Qt::blue);
|
||||
|
||||
ui->comboBox->addItems(patterns);
|
||||
|
||||
connect(ui->pushButton, &CColorButton::ColorChanged, this, &MainWindow::Draw);
|
||||
connect(ui->pushButton_2, &CColorButton::ColorChanged, this, &MainWindow::Draw);
|
||||
connect(ui->spinBox, &QSpinBox::valueChanged, this, &MainWindow::Draw);
|
||||
connect(ui->spinBox_2, &QSpinBox::valueChanged, this, &MainWindow::Draw);
|
||||
connect(ui->comboBox, &QComboBox::currentTextChanged, this, &MainWindow::Draw);
|
||||
connect(ui->radioButton, &QRadioButton::clicked, this, &MainWindow::Draw);
|
||||
connect(ui->radioButton_2, &QRadioButton::clicked, this, &MainWindow::Draw);
|
||||
|
||||
m_oPathRectangle.StartFigure();
|
||||
m_oPathRectangle.MoveTo(rectangle[0], rectangle[1]);
|
||||
m_oPathRectangle.LineTo(rectangle[0] + rectangle[2], rectangle[1]);
|
||||
m_oPathRectangle.LineTo(rectangle[0] + rectangle[2], rectangle[1] + rectangle[3]);
|
||||
m_oPathRectangle.LineTo(rectangle[0], rectangle[1] + rectangle[3]);
|
||||
m_oPathRectangle.LineTo(rectangle[0], rectangle[1]);
|
||||
m_oPathRectangle.CloseFigure();
|
||||
|
||||
m_oPathEllisps.StartFigure();
|
||||
m_oPathEllisps.AddEllipse(rectangle[0], rectangle[1], rectangle[2], rectangle[3]);
|
||||
m_oPathEllisps.CloseFigure();
|
||||
|
||||
Draw();
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void MainWindow::Draw()
|
||||
{
|
||||
NSGraphics::IGraphicsRenderer *renderer = NSGraphics::Create();
|
||||
|
||||
int width = ui->label->width(),
|
||||
height = ui->label->height();
|
||||
|
||||
BYTE* data = new BYTE[4 * width * height];
|
||||
|
||||
CBgraFrame frame;
|
||||
frame.put_Data(data);
|
||||
frame.put_Width(width);
|
||||
frame.put_Height(height);
|
||||
frame.put_Stride(4 * width);
|
||||
|
||||
renderer->put_Width(100);
|
||||
renderer->put_Height(100);
|
||||
|
||||
renderer->CreateFromBgraFrame(&frame);
|
||||
renderer->SetSwapRGB(false);
|
||||
|
||||
renderer->put_BrushType(c_BrushTypeHatch1);
|
||||
renderer->put_BrushTexturePath(ui->comboBox->currentText().toStdWString());
|
||||
renderer->put_BrushColor1(ui->pushButton->GetColor().rgb());
|
||||
renderer->put_BrushAlpha1(ui->spinBox->value());
|
||||
renderer->put_BrushColor2(ui->pushButton_2->GetColor().rgb());
|
||||
renderer->put_BrushAlpha2(ui->spinBox->value());
|
||||
|
||||
std::vector<Aggplus::PointD> points;
|
||||
unsigned length;
|
||||
bool is_rectangle = ui->radioButton->isChecked();
|
||||
if (is_rectangle)
|
||||
{
|
||||
length = m_oPathRectangle.GetPointCount();
|
||||
points = m_oPathRectangle.GetPoints(0, length);
|
||||
}
|
||||
else
|
||||
{
|
||||
length = m_oPathEllisps.GetPointCount();
|
||||
points = m_oPathEllisps.GetPoints(0, length);
|
||||
}
|
||||
|
||||
renderer->BeginCommand(c_nPathType);
|
||||
renderer->PathCommandStart();
|
||||
|
||||
for (unsigned i = 0; i < length; i++)
|
||||
{
|
||||
if (is_rectangle ? m_oPathRectangle.IsCurvePoint(i) : m_oPathEllisps.IsCurvePoint(i))
|
||||
{
|
||||
renderer->PathCommandCurveTo(points[i].X, points[i].Y,
|
||||
points[i + 1].X, points[i + 1].Y,
|
||||
points[i + 2].X, points[i + 2].Y);
|
||||
i += 2;
|
||||
}
|
||||
else if (is_rectangle ? m_oPathRectangle.IsMovePoint(i) : m_oPathEllisps.IsMovePoint(i))
|
||||
renderer->PathCommandMoveTo(points[i].X, points[i].Y);
|
||||
else if (is_rectangle ? m_oPathRectangle.IsLinePoint(i) : m_oPathEllisps.IsLinePoint(i))
|
||||
renderer->PathCommandLineTo(points[i].X, points[i].Y);
|
||||
}
|
||||
|
||||
renderer->PathCommandClose();
|
||||
renderer->Fill();
|
||||
renderer->EndCommand(c_nPathType);
|
||||
renderer->PathCommandEnd();
|
||||
|
||||
auto img = QImage(data, width, height, QImage::Format_RGBA8888, [](void *data){
|
||||
delete[] (BYTE*)data;
|
||||
});
|
||||
ui->label->setPixmap(QPixmap::fromImage(img));
|
||||
|
||||
RELEASEOBJECT(renderer);
|
||||
}
|
||||
81
DesktopEditor/graphics/tests/hatchBrush/mainwindow.h
Normal file
81
DesktopEditor/graphics/tests/hatchBrush/mainwindow.h
Normal file
@ -0,0 +1,81 @@
|
||||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QPushButton>
|
||||
#include <QColor>
|
||||
#include <QColorDialog>
|
||||
#include <QPalette>
|
||||
|
||||
#include "../../GraphicsPath.h"
|
||||
|
||||
class CColorButton final : public QPushButton
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CColorButton(QWidget *parent = nullptr) : QPushButton(parent)
|
||||
{
|
||||
connect(this, &QPushButton::clicked, this, &CColorButton::onClicked);
|
||||
}
|
||||
|
||||
~CColorButton() {}
|
||||
|
||||
QColor GetColor() const
|
||||
{
|
||||
return m_oColor;
|
||||
}
|
||||
|
||||
void SetColor(const QColor& color)
|
||||
{
|
||||
if (color == m_oColor)
|
||||
return;
|
||||
|
||||
m_oColor = color;
|
||||
setStyleSheet("QPushButton { background-color : " + m_oColor.name()
|
||||
+ "; border: 1px solid black; padding 10px;}");
|
||||
|
||||
emit ColorChanged();
|
||||
}
|
||||
|
||||
signals:
|
||||
void ColorChanged();
|
||||
|
||||
public slots:
|
||||
void onClicked()
|
||||
{
|
||||
QColorDialog color_dialog;
|
||||
auto color = color_dialog.getColor();
|
||||
|
||||
if (color.isValid())
|
||||
SetColor(color);
|
||||
}
|
||||
|
||||
private:
|
||||
QColor m_oColor;
|
||||
};
|
||||
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
}
|
||||
QT_END_NAMESPACE
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MainWindow(QWidget *parent = nullptr);
|
||||
~MainWindow();
|
||||
|
||||
public slots:
|
||||
void Draw();
|
||||
|
||||
private:
|
||||
Aggplus::CGraphicsPath m_oPathRectangle;
|
||||
Aggplus::CGraphicsPath m_oPathEllisps;
|
||||
|
||||
Ui::MainWindow *ui;
|
||||
};
|
||||
#endif // MAINWINDOW_H
|
||||
253
DesktopEditor/graphics/tests/hatchBrush/mainwindow.ui
Normal file
253
DesktopEditor/graphics/tests/hatchBrush/mainwindow.ui
Normal file
@ -0,0 +1,253 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>368</width>
|
||||
<height>538</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>190</y>
|
||||
<width>300</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>10</y>
|
||||
<width>321</width>
|
||||
<height>151</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Hatch brush parametrs</string>
|
||||
</property>
|
||||
<widget class="CColorButton" name="pushButton">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>40</y>
|
||||
<width>31</width>
|
||||
<height>24</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="CColorButton" name="pushButton_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>110</x>
|
||||
<y>40</y>
|
||||
<width>31</width>
|
||||
<height>24</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>20</y>
|
||||
<width>61</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>First color:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>110</x>
|
||||
<y>20</y>
|
||||
<width>81</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Second color:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>110</x>
|
||||
<y>70</y>
|
||||
<width>81</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Second alpha:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QSpinBox" name="spinBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>90</y>
|
||||
<width>42</width>
|
||||
<height>25</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>255</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>255</number>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QSpinBox" name="spinBox_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>110</x>
|
||||
<y>90</y>
|
||||
<width>42</width>
|
||||
<height>25</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>255</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>255</number>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>200</x>
|
||||
<y>20</y>
|
||||
<width>81</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Type:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="comboBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>200</x>
|
||||
<y>40</y>
|
||||
<width>110</width>
|
||||
<height>24</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>200</x>
|
||||
<y>70</y>
|
||||
<width>110</width>
|
||||
<height>70</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Path:</string>
|
||||
</property>
|
||||
<widget class="QRadioButton" name="radioButton">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>20</y>
|
||||
<width>91</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Rectangle</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QRadioButton" name="radioButton_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>40</y>
|
||||
<width>91</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Circle</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>70</y>
|
||||
<width>61</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>First alpha:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>160</y>
|
||||
<width>61</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Output:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>368</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>CColorButton</class>
|
||||
<extends>QPushButton</extends>
|
||||
<header>mainwindow.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
20
DesktopEditor/graphics/tests/hatchBrush/test.pro
Normal file
20
DesktopEditor/graphics/tests/hatchBrush/test.pro
Normal file
@ -0,0 +1,20 @@
|
||||
QT += core gui widgets
|
||||
|
||||
QMAKE_CXXFLAGS += /permissive-
|
||||
|
||||
SOURCES += \
|
||||
main.cpp \
|
||||
mainwindow.cpp
|
||||
|
||||
HEADERS += \
|
||||
mainwindow.h
|
||||
|
||||
FORMS += \
|
||||
mainwindow.ui
|
||||
|
||||
PWD_ROOT_DIR = $$PWD
|
||||
CORE_ROOT_DIR = $$PWD/../../../../../core
|
||||
include($$CORE_ROOT_DIR/Common/base.pri)
|
||||
|
||||
ADD_DEPENDENCY(kernel, graphics, UnicodeConverter)
|
||||
include($$CORE_ROOT_DIR/Common/3dParty/icu/icu.pri)
|
||||
11
DesktopEditor/graphics/tests/images/main.cpp
Normal file
11
DesktopEditor/graphics/tests/images/main.cpp
Normal file
@ -0,0 +1,11 @@
|
||||
#include "mainwindow.h"
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
MainWindow w;
|
||||
w.show();
|
||||
return a.exec();
|
||||
}
|
||||
62
DesktopEditor/graphics/tests/images/mainwindow.cpp
Normal file
62
DesktopEditor/graphics/tests/images/mainwindow.cpp
Normal file
@ -0,0 +1,62 @@
|
||||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
|
||||
#include <QFileDialog>
|
||||
#include <QLabel>
|
||||
#include <QSizePolicy>
|
||||
#include <QDir>
|
||||
|
||||
#include "../../../../UnicodeConverter/UnicodeConverter.h"
|
||||
#include "../../pro/Graphics.h"
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent)
|
||||
: QMainWindow(parent)
|
||||
, ui(new Ui::MainWindow)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->label->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
ui->label->setFixedWidth(310);
|
||||
ui->comboBox->addItems(m_arExtensions);
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void MainWindow::on_pushButton_clicked()
|
||||
{
|
||||
m_arFileNames = QFileDialog::getOpenFileNames(this,
|
||||
"Select one or more images",
|
||||
"",
|
||||
"*.bmp *.gif *.jpg *.png *.ico "
|
||||
"*.tif *.tga *.pcx *.wbmp *.jp2 "
|
||||
"*.jpc *.pgx *.pnm *.ras *.jbg "
|
||||
"*.mng *.ska *.raw *.psd *.pic");
|
||||
|
||||
if (!m_arFileNames.empty())
|
||||
ui->label->setText("File:" + m_arFileNames[0]);
|
||||
}
|
||||
|
||||
void MainWindow::on_pushButton_2_clicked()
|
||||
{
|
||||
auto save_dir = QFileDialog::getExistingDirectory(this,
|
||||
"Open Directory",
|
||||
"",
|
||||
QFileDialog::ShowDirsOnly |
|
||||
QFileDialog::DontResolveSymlinks);
|
||||
|
||||
auto ext = ui->comboBox->currentText();
|
||||
|
||||
NSUnicodeConverter::CUnicodeConverter converter;
|
||||
for (const auto& f : m_arFileNames)
|
||||
{
|
||||
ui->label->setText("File:" + f);
|
||||
Aggplus::CImage img(converter.toUnicode(f.toStdString(), 1));
|
||||
img.SaveFile(converter.toUnicode(QDir(save_dir).filePath("res." + ext).toStdString(), 1),
|
||||
m_mapExtensionCodes.value(ext));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
75
DesktopEditor/graphics/tests/images/mainwindow.h
Normal file
75
DesktopEditor/graphics/tests/images/mainwindow.h
Normal file
@ -0,0 +1,75 @@
|
||||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QMap>
|
||||
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
}
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MainWindow(QWidget *parent = nullptr);
|
||||
~MainWindow();
|
||||
|
||||
private slots:
|
||||
void on_pushButton_clicked();
|
||||
|
||||
void on_pushButton_2_clicked();
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
|
||||
QStringList m_arFileNames;
|
||||
|
||||
QStringList m_arExtensions = {
|
||||
"bmp",
|
||||
"gif",
|
||||
"jpg",
|
||||
"png",
|
||||
"ico",
|
||||
"tif",
|
||||
"tga",
|
||||
"pcx",
|
||||
"wbmp",
|
||||
"jp2",
|
||||
"jpc",
|
||||
"pgx",
|
||||
"pnm",
|
||||
"ras",
|
||||
"mng",
|
||||
"ska",
|
||||
"raw",
|
||||
"psd",
|
||||
"pic",
|
||||
};
|
||||
QMap<QString, int> m_mapExtensionCodes = {
|
||||
{"bmp", 1},
|
||||
{"gif", 2},
|
||||
{"jpg", 3},
|
||||
{"png", 4},
|
||||
{"ico", 5},
|
||||
{"tif", 6},
|
||||
{"tga", 7},
|
||||
{"pcx", 8},
|
||||
{"wbmp", 9},
|
||||
{"jp2", 11},
|
||||
{"jpc", 12},
|
||||
{"pgx", 13},
|
||||
{"pnm", 14},
|
||||
{"ras", 15},
|
||||
{"mng", 17},
|
||||
{"ska", 18},
|
||||
{"raw", 19},
|
||||
{"psd", 20},
|
||||
{"pic", 25},
|
||||
};
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
||||
84
DesktopEditor/graphics/tests/images/mainwindow.ui
Normal file
84
DesktopEditor/graphics/tests/images/mainwindow.ui
Normal file
@ -0,0 +1,84 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>385</width>
|
||||
<height>196</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>40</x>
|
||||
<y>20</y>
|
||||
<width>121</width>
|
||||
<height>24</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Choose img file</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>40</x>
|
||||
<y>50</y>
|
||||
<width>310</width>
|
||||
<height>91</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>File:</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>270</x>
|
||||
<y>20</y>
|
||||
<width>80</width>
|
||||
<height>24</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Convert</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="comboBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>180</x>
|
||||
<y>20</y>
|
||||
<width>72</width>
|
||||
<height>24</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>385</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@ -1,13 +1,8 @@
|
||||
#CONFIG += c++11 cmdline
|
||||
CONFIG += c++11
|
||||
|
||||
#SOURCES += \
|
||||
QT -= core
|
||||
QMAKE_CXXFLAGS += /permissive-
|
||||
|
||||
QT -= gui
|
||||
|
||||
TARGET = test
|
||||
CONFIG += console
|
||||
TEMPLATE = app
|
||||
QT += core gui widgets
|
||||
|
||||
CORE_ROOT_DIR = $$PWD/../../../..
|
||||
PWD_ROOT_DIR = $$PWD
|
||||
@ -21,6 +16,13 @@ GRAPHICS_AGG_PATH = $$PWD/../../../agg-2.4
|
||||
INCLUDEPATH += \
|
||||
$$GRAPHICS_AGG_PATH/include
|
||||
|
||||
SOURCES += main.cpp
|
||||
SOURCES += main.cpp \
|
||||
mainwindow.cpp
|
||||
|
||||
DESTDIR = $$PWD_ROOT_DIR/build/$$CORE_BUILDS_PLATFORM_PREFIX/$$CORE_BUILDS_CONFIGURATION_PREFIX
|
||||
|
||||
FORMS += \
|
||||
mainwindow.ui
|
||||
|
||||
HEADERS += \
|
||||
mainwindow.h
|
||||
11
DesktopEditor/graphics/tests/metaFiles/main.cpp
Normal file
11
DesktopEditor/graphics/tests/metaFiles/main.cpp
Normal file
@ -0,0 +1,11 @@
|
||||
#include "mainwindow.h"
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
MainWindow w;
|
||||
w.show();
|
||||
return a.exec();
|
||||
}
|
||||
76
DesktopEditor/graphics/tests/metaFiles/mainwindow.cpp
Normal file
76
DesktopEditor/graphics/tests/metaFiles/mainwindow.cpp
Normal file
@ -0,0 +1,76 @@
|
||||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
|
||||
#include <QFileDialog>
|
||||
#include <QLabel>
|
||||
#include <QSizePolicy>
|
||||
#include <QDir>
|
||||
|
||||
#include "../../../../UnicodeConverter/UnicodeConverter.h"
|
||||
#include "../../pro/Graphics.h"
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent)
|
||||
: QMainWindow(parent)
|
||||
, ui(new Ui::MainWindow)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->label->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
ui->label->setFixedWidth(160);
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void MainWindow::on_pushButton_clicked()
|
||||
{
|
||||
m_arFileNames = QFileDialog::getOpenFileNames(this,
|
||||
"Select one or more metafiles to convert",
|
||||
"",
|
||||
"*.emf *.wmf *.svm *.svg");
|
||||
if (!m_arFileNames.empty())
|
||||
ui->label->setText("File:" + m_arFileNames[0]);
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::on_pushButton_2_clicked()
|
||||
{
|
||||
auto save_dir = QFileDialog::getExistingDirectory(this,
|
||||
"Open Directory",
|
||||
"",
|
||||
QFileDialog::ShowDirsOnly |
|
||||
QFileDialog::DontResolveSymlinks);
|
||||
|
||||
NSUnicodeConverter::CUnicodeConverter converter;
|
||||
for (const auto& f : m_arFileNames)
|
||||
{
|
||||
ui->label->setText("File:" + f);
|
||||
NSFonts::IApplicationFonts* app_fonts = NSFonts::NSApplication::Create();
|
||||
app_fonts->Initialize();
|
||||
MetaFile::IMetaFile* meta_file = MetaFile::Create(app_fonts);
|
||||
if (!meta_file->LoadFromFile(converter.toUnicode(f.toStdString(), 1).c_str()))
|
||||
return;
|
||||
|
||||
double x, y, w, h;
|
||||
meta_file->GetBounds(&x, &y, &w, &h);
|
||||
|
||||
if (ui->radioButton->isChecked())
|
||||
meta_file->ConvertToRaster(converter.toUnicode(QDir(save_dir).filePath("res.bmp").toStdString(), 1).c_str(), 1,
|
||||
static_cast<int>(w) + 1, static_cast<int>(h) + 1);
|
||||
else if (ui->radioButton_2->isChecked())
|
||||
meta_file->ConvertToXml(converter.toUnicode(QDir(save_dir).filePath("res.xml").toStdString(), 1).c_str());
|
||||
else if (ui->radioButton_3->isChecked())
|
||||
meta_file->ConvertToRaster(converter.toUnicode(QDir(save_dir).filePath("res.bmp").toStdString(), 1).c_str(), 1,
|
||||
static_cast<int>(w) + 1, static_cast<int>(h) + 1,
|
||||
converter.toUnicode(QDir(save_dir).filePath("res.xml").toStdString(), 1).c_str());
|
||||
else if (ui->radioButton_4->isChecked())
|
||||
meta_file->ConvertToSvg(static_cast<int>(w) + 1, static_cast<int>(h) + 1);
|
||||
else if (ui->radioButton_5->isChecked())
|
||||
meta_file->ConvertToEmf(converter.toUnicode(QDir(save_dir).filePath("res.emf").toStdString(), 1).c_str());
|
||||
|
||||
RELEASEOBJECT(app_fonts);
|
||||
RELEASEOBJECT(meta_file);
|
||||
}
|
||||
}
|
||||
|
||||
32
DesktopEditor/graphics/tests/metaFiles/mainwindow.h
Normal file
32
DesktopEditor/graphics/tests/metaFiles/mainwindow.h
Normal file
@ -0,0 +1,32 @@
|
||||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
}
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MainWindow(QWidget *parent = nullptr);
|
||||
~MainWindow();
|
||||
|
||||
private slots:
|
||||
void on_pushButton_clicked();
|
||||
|
||||
void on_pushButton_2_clicked();
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
|
||||
QStringList m_arFileNames;
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
||||
161
DesktopEditor/graphics/tests/metaFiles/mainwindow.ui
Normal file
161
DesktopEditor/graphics/tests/metaFiles/mainwindow.ui
Normal file
@ -0,0 +1,161 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>540</width>
|
||||
<height>211</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>50</x>
|
||||
<y>60</y>
|
||||
<width>161</width>
|
||||
<height>24</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Choose Metafile</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>250</x>
|
||||
<y>0</y>
|
||||
<width>151</width>
|
||||
<height>131</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Choose to convert</string>
|
||||
</property>
|
||||
<widget class="QRadioButton" name="radioButton">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>30</y>
|
||||
<width>91</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Raster(.bmp)</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QRadioButton" name="radioButton_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>50</y>
|
||||
<width>91</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Xml</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QRadioButton" name="radioButton_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>70</y>
|
||||
<width>131</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Raster(.bmp) + Xml</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QRadioButton" name="radioButton_4">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>90</y>
|
||||
<width>91</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Svg</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QRadioButton" name="radioButton_5">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>110</y>
|
||||
<width>91</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Emf</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>450</x>
|
||||
<y>60</y>
|
||||
<width>80</width>
|
||||
<height>24</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Convert</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>60</x>
|
||||
<y>90</y>
|
||||
<width>151</width>
|
||||
<height>71</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>File: </string>
|
||||
</property>
|
||||
<property name="scaledContents">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="openExternalLinks">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>540</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
23
DesktopEditor/graphics/tests/metaFiles/test.pro
Normal file
23
DesktopEditor/graphics/tests/metaFiles/test.pro
Normal file
@ -0,0 +1,23 @@
|
||||
CONFIG += c++11
|
||||
|
||||
QMAKE_CXXFLAGS += /permissive-
|
||||
|
||||
QT += core gui widgets
|
||||
|
||||
SOURCES += \
|
||||
main.cpp\
|
||||
mainwindow.cpp
|
||||
|
||||
FORMS += \
|
||||
mainwindow.ui
|
||||
|
||||
HEADERS += \
|
||||
mainwindow.h
|
||||
|
||||
PWD_ROOT_DIR = $$PWD
|
||||
CORE_ROOT_DIR = $$PWD/../../../../../core
|
||||
include($$CORE_ROOT_DIR/Common/base.pri)
|
||||
|
||||
ADD_DEPENDENCY(kernel, graphics, UnicodeConverter)
|
||||
include($$CORE_ROOT_DIR/Common/3dParty/icu/icu.pri)
|
||||
|
||||
11
DesktopEditor/graphics/tests/text/main.cpp
Normal file
11
DesktopEditor/graphics/tests/text/main.cpp
Normal file
@ -0,0 +1,11 @@
|
||||
#include "mainwindow.h"
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
MainWindow w;
|
||||
w.show();
|
||||
return a.exec();
|
||||
}
|
||||
97
DesktopEditor/graphics/tests/text/mainwindow.cpp
Normal file
97
DesktopEditor/graphics/tests/text/mainwindow.cpp
Normal file
@ -0,0 +1,97 @@
|
||||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
|
||||
#include <iterator>
|
||||
|
||||
#include <QImage>
|
||||
#include <QPixmap>
|
||||
#include <QString>
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent)
|
||||
: QMainWindow(parent)
|
||||
, ui(new Ui::MainWindow)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->pushButton->SetColor(Qt::black);
|
||||
|
||||
m_oAppFonts = NSFonts::NSApplication::Create();
|
||||
m_oAppFonts->Initialize();
|
||||
|
||||
m_oFontManager = m_oAppFonts->GenerateFontManager();
|
||||
NSFonts::IFontsCache* fonts_cache = NSFonts::NSFontCache::Create();
|
||||
fonts_cache->SetStreams(m_oAppFonts->GetStreams());
|
||||
m_oFontManager->SetOwnerCache(fonts_cache);
|
||||
|
||||
for (auto it = m_oAppFonts->GetList()->GetFonts()->cbegin(); it != m_oAppFonts->GetList()->GetFonts()->cend(); it++)
|
||||
ui->comboBox->addItem(QString::fromWCharArray((*it)->m_wsFontName.c_str()));
|
||||
|
||||
connect(ui->textEdit, &QTextEdit::textChanged, this, &MainWindow::Draw);
|
||||
connect(ui->spinBox, &QSpinBox::valueChanged, this, &MainWindow::Draw);
|
||||
connect(ui->comboBox, &QComboBox::currentTextChanged, this, &MainWindow::Draw);
|
||||
connect(ui->checkBox, &QCheckBox::stateChanged, this, &MainWindow::Draw);
|
||||
connect(ui->checkBox_2, &QCheckBox::stateChanged, this, &MainWindow::Draw);
|
||||
connect(ui->pushButton, &CColorButton::ColorChanged, this, &MainWindow::Draw);
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
RELEASEOBJECT(m_oAppFonts);
|
||||
RELEASEOBJECT(m_oFontManager);
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::Draw()
|
||||
{
|
||||
NSGraphics::IGraphicsRenderer* renderer = NSGraphics::Create();
|
||||
renderer->SetFontManager(m_oFontManager);
|
||||
|
||||
int width = ui->label->width(),
|
||||
height = ui->label->height();
|
||||
|
||||
BYTE* data = new BYTE[4 * width * height];
|
||||
|
||||
CBgraFrame frame;
|
||||
frame.put_Data(data);
|
||||
frame.put_Width(width);
|
||||
frame.put_Height(height);
|
||||
frame.put_Stride(4 * width);
|
||||
|
||||
renderer->put_Width(100);
|
||||
renderer->put_Height(100);
|
||||
|
||||
renderer->CreateFromBgraFrame(&frame);
|
||||
renderer->SetSwapRGB(false);
|
||||
|
||||
renderer->put_FontName(ui->comboBox->currentText().toStdWString());
|
||||
renderer->put_FontSize(ui->spinBox->value());
|
||||
|
||||
long font_style = 0;
|
||||
if (ui->checkBox->isChecked())
|
||||
font_style |= 0x01;
|
||||
if (ui->checkBox_2->isChecked())
|
||||
font_style |= 0x02;
|
||||
renderer->put_FontStyle(font_style);
|
||||
|
||||
renderer->put_BrushColor1(ui->pushButton->GetColor().rgb());
|
||||
|
||||
auto lines = ui->textEdit->toPlainText().split('\n');
|
||||
double x = 1.0;
|
||||
double y = (ui->spinBox->value() * 25.4 / 96.0) + 3.0;
|
||||
double scale_y = y;
|
||||
|
||||
renderer->BeginCommand(c_nTextGraphicType);
|
||||
for (auto it = lines.cbegin(); it != lines.cend(); it++)
|
||||
{
|
||||
renderer->CommandDrawText((*it).toStdWString(), x, y, 0.0, 0.0);
|
||||
y += scale_y;
|
||||
}
|
||||
renderer->EndCommand(c_nTextGraphicType);
|
||||
|
||||
QImage img = QImage(data, width, height, QImage::Format_RGBA8888, [](void *data){
|
||||
delete[] (BYTE*)data;
|
||||
});
|
||||
ui->label->setPixmap(QPixmap::fromImage(img));
|
||||
|
||||
RELEASEOBJECT(renderer);
|
||||
}
|
||||
80
DesktopEditor/graphics/tests/text/mainwindow.h
Normal file
80
DesktopEditor/graphics/tests/text/mainwindow.h
Normal file
@ -0,0 +1,80 @@
|
||||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include "../../pro/Graphics.h"
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QPushButton>
|
||||
#include <QColor>
|
||||
#include <QColorDialog>
|
||||
#include <QPalette>
|
||||
|
||||
class CColorButton final : public QPushButton
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CColorButton(QWidget *parent = nullptr) : QPushButton(parent)
|
||||
{
|
||||
connect(this, &QPushButton::clicked, this, &CColorButton::onClicked);
|
||||
}
|
||||
|
||||
~CColorButton() {}
|
||||
|
||||
QColor GetColor() const
|
||||
{
|
||||
return m_oColor;
|
||||
}
|
||||
|
||||
void SetColor(const QColor& color)
|
||||
{
|
||||
if (color == m_oColor)
|
||||
return;
|
||||
|
||||
m_oColor = color;
|
||||
setStyleSheet("QPushButton { background-color : " + m_oColor.name()
|
||||
+ "; border: 1px solid black; padding 10px;}");
|
||||
|
||||
emit ColorChanged();
|
||||
}
|
||||
|
||||
signals:
|
||||
void ColorChanged();
|
||||
|
||||
public slots:
|
||||
void onClicked()
|
||||
{
|
||||
QColorDialog color_dialog;
|
||||
auto color = color_dialog.getColor();
|
||||
|
||||
if (color.isValid())
|
||||
SetColor(color);
|
||||
}
|
||||
|
||||
private:
|
||||
QColor m_oColor;
|
||||
};
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
}
|
||||
QT_END_NAMESPACE
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MainWindow(QWidget *parent = nullptr);
|
||||
~MainWindow();
|
||||
|
||||
public slots:
|
||||
void Draw();
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
|
||||
NSFonts::IApplicationFonts* m_oAppFonts;
|
||||
NSFonts::IFontManager* m_oFontManager;
|
||||
};
|
||||
#endif // MAINWINDOW_H
|
||||
214
DesktopEditor/graphics/tests/text/mainwindow.ui
Normal file
214
DesktopEditor/graphics/tests/text/mainwindow.ui
Normal file
@ -0,0 +1,214 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>471</width>
|
||||
<height>390</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>130</y>
|
||||
<width>450</width>
|
||||
<height>200</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QTextEdit" name="textEdit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>20</y>
|
||||
<width>180</width>
|
||||
<height>70</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>Hello</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>0</y>
|
||||
<width>61</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Text input:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>200</x>
|
||||
<y>0</y>
|
||||
<width>261</width>
|
||||
<height>91</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Brush</string>
|
||||
</property>
|
||||
<widget class="QSpinBox" name="spinBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>140</x>
|
||||
<y>40</y>
|
||||
<width>42</width>
|
||||
<height>25</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>30</number>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>140</x>
|
||||
<y>20</y>
|
||||
<width>49</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Font size:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="checkBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>70</y>
|
||||
<width>51</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Bold</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="checkBox_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>60</x>
|
||||
<y>70</y>
|
||||
<width>51</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Italic</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>200</x>
|
||||
<y>20</y>
|
||||
<width>41</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Color:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="CColorButton" name="pushButton">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>200</x>
|
||||
<y>40</y>
|
||||
<width>31</width>
|
||||
<height>24</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="autoFillBackground">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>20</y>
|
||||
<width>31</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Font:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="comboBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>40</y>
|
||||
<width>121</width>
|
||||
<height>24</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="duplicatesEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>100</y>
|
||||
<width>71</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Text output:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>471</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>CColorButton</class>
|
||||
<extends>QPushButton</extends>
|
||||
<header>mainwindow.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
20
DesktopEditor/graphics/tests/text/test.pro
Normal file
20
DesktopEditor/graphics/tests/text/test.pro
Normal file
@ -0,0 +1,20 @@
|
||||
QT += core gui widgets
|
||||
|
||||
QMAKE_CXXFLAGS += /permissive-
|
||||
|
||||
SOURCES += \
|
||||
main.cpp \
|
||||
mainwindow.cpp
|
||||
|
||||
HEADERS += \
|
||||
mainwindow.h
|
||||
|
||||
FORMS += \
|
||||
mainwindow.ui
|
||||
|
||||
PWD_ROOT_DIR = $$PWD
|
||||
CORE_ROOT_DIR = $$PWD/../../../../../core
|
||||
include($$CORE_ROOT_DIR/Common/base.pri)
|
||||
|
||||
ADD_DEPENDENCY(kernel, graphics, UnicodeConverter)
|
||||
include($$CORE_ROOT_DIR/Common/3dParty/icu/icu.pri)
|
||||
@ -100,8 +100,6 @@ namespace MetaFile
|
||||
m_bStartedPath = false;
|
||||
m_bUpdatedClip = true;
|
||||
|
||||
m_pRenderer->CommandLong(c_nPenWidth0As1px, 1);
|
||||
|
||||
//int alpha = 0xff;
|
||||
//m_pRenderer->put_BrushAlpha1(alpha);
|
||||
//m_pRenderer->put_BrushType(c_BrushTypeSolid);
|
||||
@ -1218,7 +1216,41 @@ namespace MetaFile
|
||||
else if (PS_JOIN_MITER == ulPenJoin)
|
||||
nJoinStyle = Aggplus::LineJoinMiter;
|
||||
|
||||
const double dWidth = pPen->GetWidth() * m_dScaleX;
|
||||
double dWidth = pPen->GetWidth();
|
||||
|
||||
// Повторение кода из Graphics для вычисления минимальной ширины пера
|
||||
double dM11, dM12, dM21, dM22, dDx, dDy;
|
||||
m_pRenderer->GetTransform(&dM11, &dM12, &dM21, &dM22, &dDx, &dDy);
|
||||
|
||||
Aggplus::CMatrix oMatrix;
|
||||
|
||||
oMatrix.SetElements(dM11, dM12, dM21, dM22, dDx, dDy);
|
||||
oMatrix.Scale(1. / m_dScaleX, 1. / m_dScaleY);
|
||||
|
||||
// Вычисление минимально возможной ширины пера
|
||||
// # Код явялется дублированным из Graphics
|
||||
const double dSqrtDet = sqrt(abs(oMatrix.Determinant()));
|
||||
const double dWidthMinSize = (dSqrtDet != 0) ? (1.0 / dSqrtDet) : dWidth;
|
||||
|
||||
if (0 == pPen->GetWidth())
|
||||
{
|
||||
double dX = 0.72, dY = 0.72;
|
||||
|
||||
oMatrix.Invert();
|
||||
oMatrix.TransformPoint(dX, dY);
|
||||
dX -= oMatrix.OffsetX();
|
||||
dY -= oMatrix.OffsetY();
|
||||
dWidth = std::min(abs(dX), abs(dY));
|
||||
}
|
||||
//------------------------
|
||||
else
|
||||
{
|
||||
dWidth *= m_dScaleX;
|
||||
|
||||
if (dWidth < dWidthMinSize)
|
||||
dWidth = dWidthMinSize;
|
||||
}
|
||||
|
||||
const double dMiterLimit = (0 != pPen->GetMiterLimit()) ? pPen->GetMiterLimit() : m_pFile->GetMiterLimit() * m_dScaleX;
|
||||
|
||||
BYTE nDashStyle = Aggplus::DashStyleSolid;
|
||||
@ -1228,79 +1260,83 @@ namespace MetaFile
|
||||
|
||||
pPen->GetDashData(pDataDash, unSizeDash);
|
||||
|
||||
if (NULL != pDataDash && 0 != unSizeDash)
|
||||
if ((NULL != pDataDash && 0 != unSizeDash) || PS_SOLID != ulPenStyle)
|
||||
{
|
||||
m_pRenderer->put_PenDashOffset(pPen->GetDashOffset());
|
||||
// Дублированный код из Graphics
|
||||
// Без этого используется оригинальный код в Graphics, который отрисовывает уже неверно
|
||||
double dDashWidth{dWidth};
|
||||
|
||||
double dM11, dTemp;
|
||||
m_pRenderer->GetTransform(&dM11, &dTemp, &dTemp, &dTemp, &dTemp, &dTemp);
|
||||
double dDpi;
|
||||
m_pRenderer->get_DpiX(&dDpi);
|
||||
const double dNewWidth{dWidth * dM11 * dDpi / 25.4};
|
||||
|
||||
std::vector<double> arDashes(unSizeDash);
|
||||
|
||||
for (unsigned int unIndex = 0; unIndex < unSizeDash; ++unIndex)
|
||||
arDashes[unIndex] = pDataDash[unIndex] * dNewWidth;
|
||||
|
||||
m_pRenderer->PenDashPattern(arDashes.data(), unSizeDash);
|
||||
|
||||
nDashStyle = Aggplus::DashStyleCustom;
|
||||
}
|
||||
else if (PS_SOLID != ulPenStyle)
|
||||
{
|
||||
std::vector<double> arDashPattern;
|
||||
|
||||
double dM11, dTemp;
|
||||
m_pRenderer->GetTransform(&dM11, &dTemp, &dTemp, &dTemp, &dTemp, &dTemp);
|
||||
double dDpi;
|
||||
m_pRenderer->get_DpiX(&dDpi);
|
||||
const double dNewWidth{dWidth * dM11 * dDpi / 25.4};
|
||||
|
||||
switch (ulPenStyle)
|
||||
if (!Equals(dWidthMinSize, dWidth))
|
||||
{
|
||||
case PS_DASH:
|
||||
{
|
||||
arDashPattern.push_back(9 * dNewWidth);
|
||||
arDashPattern.push_back(3 * dNewWidth);
|
||||
double dDet = oMatrix.Determinant();
|
||||
|
||||
break;
|
||||
}
|
||||
case PS_DOT:
|
||||
{
|
||||
arDashPattern.push_back(3 * dNewWidth);
|
||||
arDashPattern.push_back(3 * dNewWidth);
|
||||
|
||||
break;
|
||||
}
|
||||
case PS_DASHDOT:
|
||||
{
|
||||
arDashPattern.push_back(9 * dNewWidth);
|
||||
arDashPattern.push_back(3 * dNewWidth);
|
||||
arDashPattern.push_back(3 * dNewWidth);
|
||||
arDashPattern.push_back(3 * dNewWidth);
|
||||
|
||||
break;
|
||||
}
|
||||
case PS_DASHDOTDOT:
|
||||
{
|
||||
arDashPattern.push_back(9 * dNewWidth);
|
||||
arDashPattern.push_back(3 * dNewWidth);
|
||||
arDashPattern.push_back(3 * dNewWidth);
|
||||
arDashPattern.push_back(3 * dNewWidth);
|
||||
arDashPattern.push_back(3 * dNewWidth);
|
||||
arDashPattern.push_back(3 * dNewWidth);
|
||||
|
||||
break;
|
||||
}
|
||||
if (fabs(dDet) < 0.0001)
|
||||
dDashWidth *= dSqrtDet;
|
||||
}
|
||||
// -----------------------------
|
||||
|
||||
if (!arDashPattern.empty())
|
||||
if (NULL != pDataDash && 0 != unSizeDash)
|
||||
{
|
||||
m_pRenderer->PenDashPattern(arDashPattern.data(), arDashPattern.size());
|
||||
m_pRenderer->put_PenDashOffset(pPen->GetDashOffset());
|
||||
|
||||
std::vector<double> arDashes(unSizeDash);
|
||||
|
||||
for (unsigned int unIndex = 0; unIndex < unSizeDash; ++unIndex)
|
||||
arDashes[unIndex] = pDataDash[unIndex] * dDashWidth;
|
||||
|
||||
m_pRenderer->PenDashPattern(arDashes.data(), unSizeDash);
|
||||
|
||||
nDashStyle = Aggplus::DashStyleCustom;
|
||||
nStartCapStyle = nEndCapStyle = Aggplus::LineCapFlat;
|
||||
nJoinStyle = Aggplus::LineJoinMiter;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::vector<double> arDashPattern;
|
||||
|
||||
switch (ulPenStyle)
|
||||
{
|
||||
case PS_DASH:
|
||||
{
|
||||
arDashPattern.push_back(9 * dDashWidth);
|
||||
arDashPattern.push_back(3 * dDashWidth);
|
||||
|
||||
break;
|
||||
}
|
||||
case PS_DOT:
|
||||
{
|
||||
arDashPattern.push_back(3 * dDashWidth);
|
||||
arDashPattern.push_back(3 * dDashWidth);
|
||||
|
||||
break;
|
||||
}
|
||||
case PS_DASHDOT:
|
||||
{
|
||||
arDashPattern.push_back(9 * dDashWidth);
|
||||
arDashPattern.push_back(6 * dDashWidth);
|
||||
arDashPattern.push_back(3 * dDashWidth);
|
||||
arDashPattern.push_back(6 * dDashWidth);
|
||||
|
||||
break;
|
||||
}
|
||||
case PS_DASHDOTDOT:
|
||||
{
|
||||
arDashPattern.push_back(9 * dDashWidth);
|
||||
arDashPattern.push_back(6 * dDashWidth);
|
||||
arDashPattern.push_back(3 * dDashWidth);
|
||||
arDashPattern.push_back(6 * dDashWidth);
|
||||
arDashPattern.push_back(3 * dDashWidth);
|
||||
arDashPattern.push_back(6 * dDashWidth);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!arDashPattern.empty())
|
||||
{
|
||||
m_pRenderer->PenDashPattern(arDashPattern.data(), arDashPattern.size());
|
||||
nDashStyle = Aggplus::DashStyleCustom;
|
||||
nStartCapStyle = nEndCapStyle = Aggplus::LineCapFlat;
|
||||
nJoinStyle = Aggplus::LineJoinMiter;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -44,7 +44,8 @@ namespace MetaFile
|
||||
: r(_r), g(_g), b(_b), a(_a)
|
||||
{}
|
||||
|
||||
TRGBA::TRGBA(int nValue) : r((nValue >> 0) & 0xFF), g((nValue >> 8) & 0xFF), b((nValue >> 16) & 0xFF), a((nValue >> 24) & 0xFF)
|
||||
TRGBA::TRGBA(int nValue)
|
||||
: r((nValue >> 0) & 0xFF), g((nValue >> 8) & 0xFF), b((nValue >> 16) & 0xFF), a((nValue >> 24) & 0xFF)
|
||||
{}
|
||||
|
||||
void TRGBA::Set(unsigned char _r, unsigned char _g, unsigned char _b, unsigned char _a)
|
||||
@ -94,7 +95,18 @@ namespace MetaFile
|
||||
return a;
|
||||
}
|
||||
|
||||
TXForm::TXForm() : M11(1), M12(0), M21(0), M22(1), Dx(0), Dy(0)
|
||||
TRGBA& TRGBA::operator=(const TRGBA& oRGBA)
|
||||
{
|
||||
r = oRGBA.r;
|
||||
g = oRGBA.g;
|
||||
b = oRGBA.b;
|
||||
a = oRGBA.a;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
TXForm::TXForm()
|
||||
: M11(1), M12(0), M21(0), M22(1), Dx(0), Dy(0)
|
||||
{}
|
||||
|
||||
TXForm::TXForm(const TXForm &oXForm)
|
||||
|
||||
@ -558,6 +558,8 @@ namespace MetaFile
|
||||
unsigned char GetGreen() const;
|
||||
unsigned char GetBlue() const;
|
||||
unsigned char GetAlpha() const;
|
||||
|
||||
TRGBA& operator=(const TRGBA& oRGBA);
|
||||
};
|
||||
|
||||
struct TXForm
|
||||
|
||||
@ -147,6 +147,10 @@ namespace MetaFile
|
||||
if (BI_JPEG != unCompression || BI_PNG != unCompression)
|
||||
return false;
|
||||
|
||||
#ifdef METAFILE_DISABLE_FILESYSTEM
|
||||
return false;
|
||||
#endif
|
||||
|
||||
std::wstring wsTempFileName = GetTempFilename();
|
||||
if (wsTempFileName.empty())
|
||||
return false;
|
||||
@ -233,7 +237,9 @@ namespace MetaFile
|
||||
}
|
||||
for (int nAddIndex = 0; nAddIndex < nAdditBytes; nAddIndex++)
|
||||
{
|
||||
int nByte = *pBuffer; pBuffer++; lBufLen--;
|
||||
// int nByte = *pBuffer;
|
||||
++pBuffer;
|
||||
--lBufLen;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -267,7 +273,9 @@ namespace MetaFile
|
||||
}
|
||||
for (int nAddIndex = 0; nAddIndex < nAdditBytes; nAddIndex++)
|
||||
{
|
||||
int nByte = *pBuffer; pBuffer++; lBufLen--;
|
||||
// int nByte = *pBuffer;
|
||||
++pBuffer;
|
||||
--lBufLen;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -486,7 +494,12 @@ namespace MetaFile
|
||||
}
|
||||
|
||||
if (lBufLen < (nWidth + nAdd) * abs(nHeight))
|
||||
{
|
||||
if (pUncompressedBuffer)
|
||||
delete[] pUncompressedBuffer;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
pBgraBuffer = new BYTE[nWidth * abs(nHeight) * 4 * sizeof(BYTE)];
|
||||
if (NULL == pBgraBuffer)
|
||||
@ -639,7 +652,7 @@ namespace MetaFile
|
||||
*pulWidth = ulWidth;
|
||||
*pulHeight = ulHeight;
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
else if (BI_BITCOUNT_5 == ushBitCount)
|
||||
{
|
||||
@ -986,29 +999,6 @@ namespace MetaFile
|
||||
}
|
||||
}
|
||||
|
||||
std::wstring ascii_to_unicode(const char *src)
|
||||
{
|
||||
size_t nSize = mbstowcs(0, src, 0);
|
||||
wchar_t* pBuffer = new wchar_t[nSize];
|
||||
nSize = mbstowcs(pBuffer, src, nSize);
|
||||
std::wstring sRes;
|
||||
if (nSize != (size_t)-1)
|
||||
sRes = std::wstring(pBuffer, nSize);
|
||||
delete[] pBuffer;
|
||||
return sRes;
|
||||
}
|
||||
std::string unicode_to_ascii(const wchar_t *src)
|
||||
{
|
||||
size_t nSize = wcstombs(0, src, 0);
|
||||
char* pBuffer = new char[nSize];
|
||||
nSize = wcstombs(pBuffer, src, nSize);
|
||||
std::string sRes;
|
||||
if (nSize != (size_t)-1)
|
||||
sRes = std::string(pBuffer, nSize);
|
||||
delete[] pBuffer;
|
||||
return sRes;
|
||||
}
|
||||
|
||||
std::wstring GetTempFilename(const std::wstring& sFolder)
|
||||
{
|
||||
std::wstring sTmpFile = NSFile::CFileBinary::CreateTempFileWithUniqueName(sFolder.empty() ? NSFile::CFileBinary::GetTempPath() : sFolder, L"wmf");
|
||||
|
||||
@ -30,7 +30,6 @@
|
||||
*
|
||||
*/
|
||||
#include "../../../raster/ImageFileFormatChecker.h"
|
||||
#include "../../../graphics/Image.h"
|
||||
|
||||
#include "../Common/MetaFileUtils.h"
|
||||
|
||||
|
||||
@ -593,6 +593,8 @@ namespace MetaFile
|
||||
|
||||
if (!BanEMFProcesses())
|
||||
HANDLE_EMR_CREATEBRUSHINDIRECT(ulBrushIndex, pBrush);
|
||||
else
|
||||
delete pBrush;
|
||||
}
|
||||
|
||||
void CEmfParser::Read_EMR_SETTEXTCOLOR()
|
||||
@ -630,6 +632,8 @@ namespace MetaFile
|
||||
|
||||
if (!BanEMFProcesses())
|
||||
HANDLE_EMR_EXTCREATEFONTINDIRECTW(ulIndex, pFont);
|
||||
else
|
||||
delete pFont;
|
||||
}
|
||||
|
||||
void CEmfParser::Read_EMR_SETTEXTALIGN()
|
||||
@ -722,6 +726,8 @@ namespace MetaFile
|
||||
|
||||
if (!BanEMFProcesses())
|
||||
HANDLE_EMR_EXTCREATEPEN(ulPenIndex, pPen, arUnused);
|
||||
else
|
||||
delete pPen;
|
||||
}
|
||||
|
||||
void CEmfParser::Read_EMR_CREATEPEN()
|
||||
@ -744,6 +750,8 @@ namespace MetaFile
|
||||
|
||||
if (!BanEMFProcesses())
|
||||
HANDLE_EMR_CREATEPEN(ulPenIndex, widthX, pPen);
|
||||
else
|
||||
delete pPen;
|
||||
}
|
||||
|
||||
void CEmfParser::Read_EMR_SETPOLYFILLMODE()
|
||||
@ -1011,6 +1019,8 @@ namespace MetaFile
|
||||
|
||||
if (!BanEMFProcesses())
|
||||
HANDLE_EMR_CREATEPALETTE(ulPaletteIndex, pPalette);
|
||||
else
|
||||
delete pPalette;
|
||||
}
|
||||
|
||||
void CEmfParser::Read_EMR_SELECTPALETTE()
|
||||
|
||||
@ -763,7 +763,7 @@ namespace MetaFile
|
||||
if (InterpretatorType::Svg == oInterpretatorType)
|
||||
{
|
||||
CEmfInterpretatorSvg *pEmfInterpretatorSvg = new CEmfInterpretatorSvg(this, dWidth, dHeight);
|
||||
pEmfInterpretatorSvg->SetShapeRendering(EShapeRendering::CrispEdges);
|
||||
pEmfInterpretatorSvg->SetShapeRendering(EShapeRendering::OptimizeSpeed);
|
||||
m_pInterpretator = pEmfInterpretatorSvg;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,10 +1,6 @@
|
||||
#ifndef CEMFPARSERBASE_H
|
||||
#define CEMFPARSERBASE_H
|
||||
|
||||
//#include "../EmfTypes.h"
|
||||
//#include "../EmfObjects.h"
|
||||
//#include "../../Common/MetaFileUtils.h"
|
||||
|
||||
#include "../EmfPlayer.h"
|
||||
|
||||
#include "../../Common/MetaFile.h"
|
||||
|
||||
@ -67,15 +67,11 @@
|
||||
#define EMFPLUS_TRANSLATEWORLDTRANSFORM 0x402D
|
||||
|
||||
#include <map>
|
||||
#include <iostream>
|
||||
|
||||
#include "CEmfParser.h"
|
||||
#include "../../Wmf/WmfFile.h"
|
||||
#include "../../Wmf/WmfInterpretator/CWmfInterpretatorSvg.h"
|
||||
|
||||
#include "../EmfInterpretator/CEmfInterpretator.h"
|
||||
#include "../EmfInterpretator/CEmfInterpretatorSvg.h"
|
||||
#include "../EmfInterpretator/CEmfInterpretatorArray.h"
|
||||
#include "../EmfInterpretator/CEmfInterpretatorRender.h"
|
||||
|
||||
#ifdef METAFILE_SUPPORT_WMF_EMF_XML
|
||||
@ -664,6 +660,9 @@ namespace MetaFile
|
||||
|
||||
for (unsigned int unIndex = 0; unIndex < unPositionCount; ++unIndex)
|
||||
m_oStream >> pEmfPlusBrush->arGradientColors[unIndex].first;
|
||||
|
||||
pEmfPlusBrush->oColor = pEmfPlusBrush->arGradientColors.back() .first;
|
||||
pEmfPlusBrush->oColorBack = pEmfPlusBrush->arGradientColors.front().first;
|
||||
}
|
||||
}
|
||||
|
||||
@ -772,7 +771,7 @@ namespace MetaFile
|
||||
|
||||
switch (nEndCap)
|
||||
{
|
||||
case 0: pEmfPlusPen->unStyle |= PS_ENDCAP_MASK & PS_ENDCAP_FLAT; break;
|
||||
case 0: pEmfPlusPen->unStyle |= PS_ENDCAP_MASK & PS_ENDCAP_FLAT; break;
|
||||
case 1: pEmfPlusPen->unStyle |= PS_ENDCAP_MASK & PS_ENDCAP_SQUARE; break;
|
||||
case 2: pEmfPlusPen->unStyle |= PS_ENDCAP_MASK & PS_ENDCAP_ROUND; break;
|
||||
}
|
||||
@ -785,7 +784,7 @@ namespace MetaFile
|
||||
|
||||
switch (nJoin)
|
||||
{
|
||||
case 0: pEmfPlusPen->unStyle |= PS_JOIN_MASK & PS_JOIN_MITER; break;
|
||||
case 0: pEmfPlusPen->unStyle |= PS_JOIN_MASK & PS_JOIN_MITER; break;
|
||||
case 1: pEmfPlusPen->unStyle |= PS_JOIN_MASK & PS_JOIN_BEVEL; break;
|
||||
case 2: pEmfPlusPen->unStyle |= PS_JOIN_MASK & PS_ENDCAP_ROUND; break;
|
||||
}
|
||||
@ -871,7 +870,7 @@ namespace MetaFile
|
||||
m_oStream >> *pLineCapData;
|
||||
|
||||
if (CustomLineCapDataFillPath == pLineCapData->unCustomLineCapDataFlags ||
|
||||
CustomLineCapDataLinePath == pLineCapData->unCustomLineCapDataFlags)
|
||||
CustomLineCapDataLinePath == pLineCapData->unCustomLineCapDataFlags)
|
||||
{
|
||||
m_oStream.Skip(4); // FillPathLength or LinePathLength
|
||||
pLineCapData->pPath = ReadPath();
|
||||
@ -1343,7 +1342,7 @@ namespace MetaFile
|
||||
if (oImageAttributes.eWrapMode == WrapModeClamp)
|
||||
{
|
||||
if (oRectangle.dX < 0 || oRectangle.dX < 0 ||
|
||||
oRectangle.dX >= oRectangle.dWidth || oRectangle.dY >= oRectangle.dHeight)
|
||||
oRectangle.dX >= oRectangle.dWidth || oRectangle.dY >= oRectangle.dHeight)
|
||||
return oImageAttributes.oClampColor;
|
||||
|
||||
}
|
||||
@ -1541,14 +1540,10 @@ namespace MetaFile
|
||||
case MetafileDataTypeEmf:
|
||||
case MetafileDataTypeEmfPlusOnly:
|
||||
case MetafileDataTypeEmfPlusDual:
|
||||
{
|
||||
return DrawMetafile<CEmfParser>(pBuffer, unSizeBuffer, oSrcRect, arPoints);
|
||||
}
|
||||
case MetafileDataTypeWmf:
|
||||
case MetafileDataTypeWmfPlaceable:
|
||||
{
|
||||
return DrawMetafile<CWmfParser>(pBuffer, unSizeBuffer, oSrcRect, arPoints);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1661,7 +1656,7 @@ namespace MetaFile
|
||||
BYTE* pNewBuffer = GetClipedImage(pPixels, nWidth, nHeight, oClipRect, nW, nH);
|
||||
|
||||
m_pInterpretator->DrawBitmap(arPoints[0].X, arPoints[0].Y, arPoints[1].X - arPoints[0].X - m_pDC->GetPixelWidth(), arPoints[2].Y - arPoints[0].Y - m_pDC->GetPixelHeight(),
|
||||
(NULL != pNewBuffer) ? pNewBuffer : pPixels, nW, nH);
|
||||
(NULL != pNewBuffer) ? pNewBuffer : pPixels, nW, nH);
|
||||
|
||||
RELEASEINTERFACE(pGrRenderer);
|
||||
RELEASEARRAYOBJECTS(pNewBuffer);
|
||||
@ -1740,7 +1735,7 @@ namespace MetaFile
|
||||
BYTE* pNewBuffer = GetClipedImage(pBytes, unWidth, unHeight, oClipRect, nW, nH);
|
||||
|
||||
m_pInterpretator->DrawBitmap(arPoints[0].X, arPoints[0].Y, arPoints[1].X - arPoints[0].X, arPoints[2].Y - arPoints[0].Y,
|
||||
(NULL != pNewBuffer) ? pNewBuffer : pBytes, nW, nH);
|
||||
(NULL != pNewBuffer) ? pNewBuffer : pBytes, nW, nH);
|
||||
|
||||
if (!bExternalBuffer)
|
||||
RELEASEARRAYOBJECTS(pBytes);
|
||||
@ -1803,17 +1798,15 @@ namespace MetaFile
|
||||
m_pDC->SetPen(pPen);
|
||||
|
||||
if (AD_COUNTERCLOCKWISE != m_pDC->GetArcDirection())
|
||||
{
|
||||
dSweepAngle = dSweepAngle - 360;
|
||||
}
|
||||
|
||||
TEmfPlusRectF oConvertedRect = GetConvertedRectangle(oRect);
|
||||
|
||||
MoveTo(oConvertedRect.dX, oConvertedRect.dY);
|
||||
ArcTo(oConvertedRect.dX, oConvertedRect.dY,
|
||||
oConvertedRect.dX + oConvertedRect.dWidth,
|
||||
oConvertedRect.dY + oConvertedRect.dHeight,
|
||||
dStartAngle, dSweepAngle);
|
||||
oConvertedRect.dX + oConvertedRect.dWidth,
|
||||
oConvertedRect.dY + oConvertedRect.dHeight,
|
||||
dStartAngle, dSweepAngle);
|
||||
DrawPath(true, false);
|
||||
|
||||
if (NULL != m_pInterpretator)
|
||||
@ -2290,13 +2283,13 @@ namespace MetaFile
|
||||
|
||||
if (NULL != m_pInterpretator)
|
||||
{
|
||||
CPathConverter oPathConverter;
|
||||
CPath oNewPath, oLineCapPath;
|
||||
|
||||
oPathConverter.GetUpdatedPath(oNewPath, oLineCapPath, *pPath, *pEmfPlusPen);
|
||||
|
||||
if (InterpretatorType::Render == m_pInterpretator->GetType())
|
||||
{
|
||||
CPathConverter oPathConverter;
|
||||
CPath oNewPath, oLineCapPath;
|
||||
|
||||
oPathConverter.GetUpdatedPath(oNewPath, oLineCapPath, *pPath, *pEmfPlusPen);
|
||||
|
||||
oNewPath.DrawOn(m_pInterpretator, true, false);
|
||||
oLineCapPath.DrawOn(m_pInterpretator, false, true);
|
||||
}
|
||||
@ -2833,7 +2826,7 @@ namespace MetaFile
|
||||
|
||||
void CEmfPlusParser::Read_EMFPLUS_FILLREGION(unsigned short unShFlags)
|
||||
{
|
||||
short shOgjectIndex = ExpressValue(unShFlags, 0, 7);
|
||||
// short shOgjectIndex = ExpressValue(unShFlags, 0, 7);
|
||||
unsigned int unBrushId;
|
||||
|
||||
m_oStream >> unBrushId;
|
||||
@ -2992,34 +2985,34 @@ namespace MetaFile
|
||||
|
||||
void CEmfPlusParser::Read_EMFPLUS_SETANTIALIASMODE(unsigned short unShFlags)
|
||||
{
|
||||
short shSmoothingMode = ExpressValue(unShFlags, 1, 7);
|
||||
// short shSmoothingMode = ExpressValue(unShFlags, 1, 7);
|
||||
|
||||
//TODO: реализовать
|
||||
}
|
||||
|
||||
void CEmfPlusParser::Read_EMFPLUS_SETCOMPOSITINGMODE(unsigned short unShFlags)
|
||||
{
|
||||
short shCompositingMode = ExpressValue(unShFlags, 0, 7);
|
||||
// short shCompositingMode = ExpressValue(unShFlags, 0, 7);
|
||||
|
||||
//TODO: реализовать
|
||||
}
|
||||
|
||||
void CEmfPlusParser::Read_EMFPLUS_SETCOMPOSITINGQUALITY(unsigned short unShFlags)
|
||||
{
|
||||
short shCompositingQuality = ExpressValue(unShFlags, 0, 7);
|
||||
// short shCompositingQuality = ExpressValue(unShFlags, 0, 7);
|
||||
|
||||
//TODO: реализовать
|
||||
}
|
||||
|
||||
void CEmfPlusParser::Read_EMFPLUS_SETINTERPOLATIONMODE(unsigned short unShFlags)
|
||||
{
|
||||
short shInterpolationMode = ExpressValue(unShFlags, 0, 7);
|
||||
// short shInterpolationMode = ExpressValue(unShFlags, 0, 7);
|
||||
//TODO: реализовать
|
||||
}
|
||||
|
||||
void CEmfPlusParser::Read_EMFPLUS_SETPIXELOFFSETMODE(unsigned short unShFlags)
|
||||
{
|
||||
short shPixelOffsetMode = ExpressValue(unShFlags, 0, 7);
|
||||
// short shPixelOffsetMode = ExpressValue(unShFlags, 0, 7);
|
||||
|
||||
//TODO: реализовать
|
||||
}
|
||||
@ -3036,20 +3029,20 @@ namespace MetaFile
|
||||
|
||||
void CEmfPlusParser::Read_EMFPLUS_SETTEXTCONTRAST(unsigned short unShFlags)
|
||||
{
|
||||
short shTextContrast = ExpressValue(unShFlags, 0, 11);
|
||||
// short shTextContrast = ExpressValue(unShFlags, 0, 11);
|
||||
|
||||
//TODO: реализовать
|
||||
}
|
||||
|
||||
void CEmfPlusParser::Read_EMRPLUS_SETTEXTRENDERINGHINT(unsigned short unShFlags)
|
||||
{
|
||||
short shTextRenderingHint = ExpressValue(unShFlags, 0, 7);
|
||||
// short shTextRenderingHint = ExpressValue(unShFlags, 0, 7);
|
||||
//TODO: реализовать
|
||||
}
|
||||
|
||||
void CEmfPlusParser::Read_EMFPLUS_BEGINCONTAINER(unsigned short unShFlags)
|
||||
{
|
||||
short shPageUnit = ExpressValue(unShFlags, 8, 15);
|
||||
// short shPageUnit = ExpressValue(unShFlags, 8, 15);
|
||||
TEmfPlusRectF oDestRect, oSrcRect;
|
||||
unsigned int unStackIndex;
|
||||
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
#ifndef CEMFPLUSPARSER_H
|
||||
#define CEMFPLUSPARSER_H
|
||||
|
||||
//#include "../../Common/MetaFileUtils.h"
|
||||
//#include "../../Common/MetaFile.h"
|
||||
#include "../EmfPlusObjects.h"
|
||||
#include "CEmfParserBase.h"
|
||||
#include "../EmfPlusTypes.h"
|
||||
|
||||
@ -106,6 +106,16 @@ namespace MetaFile
|
||||
chRed = oARGB.chRed;
|
||||
chAlpha = oARGB.chAlpha;
|
||||
}
|
||||
|
||||
TEmfPlusARGB& operator=(const TEmfPlusARGB& oARGB)
|
||||
{
|
||||
chBlue = oARGB.chBlue;
|
||||
chGreen = oARGB.chGreen;
|
||||
chRed = oARGB.chRed;
|
||||
chAlpha = oARGB.chAlpha;
|
||||
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
struct TGUID
|
||||
|
||||
@ -47,11 +47,18 @@ namespace MetaFile
|
||||
return new CMetaFile(pAppFonts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief CMetaFile Constructor
|
||||
* @param pAppFonts
|
||||
*
|
||||
* Create a font manager accordingly Applications Fonts for the
|
||||
* appropriate metafile.
|
||||
*/
|
||||
CMetaFile::CMetaFile(NSFonts::IApplicationFonts *pAppFonts) : MetaFile::IMetaFile(pAppFonts)
|
||||
{
|
||||
m_pFontManager = NULL;
|
||||
m_pAppFonts = pAppFonts;
|
||||
// Создаем менеджер шрифтов с собственным кэшем
|
||||
|
||||
if (pAppFonts)
|
||||
{
|
||||
m_pFontManager = pAppFonts->GenerateFontManager();
|
||||
@ -60,28 +67,35 @@ namespace MetaFile
|
||||
m_pFontManager->SetOwnerCache(pMeasurerCache);
|
||||
}
|
||||
|
||||
#ifdef METAFILE_SUPPORT_WMF_EMF
|
||||
m_oWmfFile.SetFontManager(m_pFontManager);
|
||||
m_oEmfFile.SetFontManager(m_pFontManager);
|
||||
#endif
|
||||
|
||||
#ifdef METAFILE_SUPPORT_SVM
|
||||
m_oSvmFile.SetFontManager(m_pFontManager);
|
||||
#endif
|
||||
m_lType = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief CMetaFile::get_FontManager
|
||||
* @return Pointer of current Font Manager
|
||||
*/
|
||||
NSFonts::IFontManager* CMetaFile::get_FontManager()
|
||||
{
|
||||
return m_pFontManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief CMetaFile Destructor
|
||||
*
|
||||
* Close metafile and release memory, allocated for Font Manager
|
||||
*/
|
||||
CMetaFile::~CMetaFile()
|
||||
{
|
||||
Close();
|
||||
RELEASEINTERFACE(m_pFontManager);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief CMetaFile::ConvertToSvg
|
||||
* @param unWidth - width of picture from metafile (0 - default)
|
||||
* @param unHeight - height of picture from metafile (0 - default)
|
||||
* @return string containing svg content
|
||||
*/
|
||||
std::wstring CMetaFile::ConvertToSvg(unsigned int unWidth, unsigned int unHeight)
|
||||
{
|
||||
|
||||
@ -102,7 +116,16 @@ namespace MetaFile
|
||||
return L"";
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Methods for conversation in test examples
|
||||
*/
|
||||
#ifdef METAFILE_SUPPORT_WMF_EMF
|
||||
/**
|
||||
* @brief CMetaFile::ConvertToXml
|
||||
* @param wsFilePath - path to the file being saving (must be .xml)
|
||||
*
|
||||
* Convert and save metafile data to .xml
|
||||
*/
|
||||
void CMetaFile::ConvertToXml(const wchar_t *wsFilePath)
|
||||
{
|
||||
if (NULL == wsFilePath)
|
||||
@ -112,129 +135,17 @@ namespace MetaFile
|
||||
m_oEmfFile.PlayMetaFile();
|
||||
}
|
||||
|
||||
void CMetaFile::ConvertToXmlAndRaster(const wchar_t *wsXmlFilePath, const wchar_t *wsOutFilePath, unsigned int unFileType, int nWidth, int nHeight)
|
||||
{
|
||||
if (NULL == wsXmlFilePath || NULL == wsOutFilePath)
|
||||
return;
|
||||
|
||||
m_oEmfFile.SetOutputDevice(NULL, wsXmlFilePath);
|
||||
|
||||
NSGraphics::IGraphicsRenderer* pGrRenderer = NSGraphics::Create();
|
||||
|
||||
NSFonts::IFontManager* pFontManager = m_pAppFonts->GenerateFontManager();
|
||||
NSFonts::IFontsCache* pFontCache = NSFonts::NSFontCache::Create();
|
||||
pFontCache->SetStreams(m_pAppFonts->GetStreams());
|
||||
pFontManager->SetOwnerCache(pFontCache);
|
||||
|
||||
pGrRenderer->SetFontManager(pFontManager);
|
||||
|
||||
if (-1 == nHeight)
|
||||
{
|
||||
double dX, dY, dW, dH;
|
||||
GetBounds(&dX, &dY, &dW, &dH);
|
||||
|
||||
if (dW < 0)
|
||||
dW = -dW;
|
||||
if (dH < 0)
|
||||
dH = -dH;
|
||||
|
||||
if (nWidth < 0) nWidth = (int)(dW * 96 / 25.4);
|
||||
nHeight = (int)((double)nWidth * dH / dW);
|
||||
}
|
||||
|
||||
double dWidth = 25.4 * nWidth / 96;
|
||||
double dHeight = 25.4 * nHeight / 96;
|
||||
|
||||
BYTE* pBgraData = new(std::nothrow) BYTE[nWidth * nHeight * 4];
|
||||
if (!pBgraData)
|
||||
return;
|
||||
|
||||
unsigned int alfa = 0xffffff;
|
||||
//дефолтный тон должен быть прозрачным, а не белым
|
||||
//memset(pBgraData, 0xff, nWidth * nHeight * 4);
|
||||
for (int i = 0; i < nWidth * nHeight; i++)
|
||||
{
|
||||
((unsigned int*)pBgraData)[i] = alfa;
|
||||
}
|
||||
CBgraFrame oFrame;
|
||||
oFrame.put_Data(pBgraData);
|
||||
oFrame.put_Width(nWidth);
|
||||
oFrame.put_Height(nHeight);
|
||||
oFrame.put_Stride(-4 * nWidth);
|
||||
|
||||
pGrRenderer->CreateFromBgraFrame(&oFrame);
|
||||
pGrRenderer->SetSwapRGB(false);
|
||||
pGrRenderer->put_Width(dWidth);
|
||||
pGrRenderer->put_Height(dHeight);
|
||||
|
||||
DrawOnRenderer(wsXmlFilePath, pGrRenderer, 0, 0, dWidth, dHeight);
|
||||
|
||||
oFrame.SaveFile(wsOutFilePath, unFileType);
|
||||
|
||||
RELEASEINTERFACE(pFontManager);
|
||||
RELEASEINTERFACE(pGrRenderer);
|
||||
}
|
||||
|
||||
bool CMetaFile::DrawOnRenderer(const wchar_t *wsXmlFilePath, IRenderer *pRenderer, double dX, double dY, double dWidth, double dHeight)
|
||||
{
|
||||
if (NULL == wsXmlFilePath || NULL == pRenderer)
|
||||
return false;
|
||||
|
||||
pRenderer->BeginCommand(c_nImageType);
|
||||
|
||||
switch (m_lType)
|
||||
{
|
||||
#ifdef METAFILE_SUPPORT_WMF_EMF
|
||||
case c_lMetaWmf:
|
||||
{
|
||||
CMetaFileRenderer oWmfOut(m_oWmfFile.GetWmfParser(), pRenderer, dX, dY, dWidth, dHeight);
|
||||
m_oWmfFile.SetOutputDevice((IOutputDevice*)&oWmfOut);
|
||||
m_oWmfFile.PlayMetaFile();
|
||||
break;
|
||||
}
|
||||
case c_lMetaEmf:
|
||||
{
|
||||
CMetaFileRenderer oEmfOut(m_oEmfFile.GetEmfParser(), pRenderer, dX, dY, dWidth, dHeight);
|
||||
m_oEmfFile.SetOutputDevice((IOutputDevice*)&oEmfOut, wsXmlFilePath);
|
||||
m_oEmfFile.PlayMetaFile();
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
#ifdef METAFILE_SUPPORT_SVM
|
||||
case c_lMetaSvm:
|
||||
{
|
||||
CMetaFileRenderer oSvmOut(&m_oSvmFile, pRenderer, dX, dY, dWidth, dHeight);
|
||||
m_oSvmFile.SetOutputDevice((IOutputDevice*)&oSvmOut);
|
||||
m_oSvmFile.PlayMetaFile();
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
#ifdef METAFILE_SUPPORT_SVG
|
||||
case c_lMetaSvg:
|
||||
{
|
||||
m_oSvgFile.Draw(pRenderer, dX, dY, dWidth, dHeight);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
pRenderer->EndCommand(c_nImageType);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief CMetaFile::LoadFromXmlFile
|
||||
* @param wsFilePath - path to the source file (must be .xml)
|
||||
* @return if correct reading - return true, elde - false
|
||||
*
|
||||
* Load meta file content from source .xml file.
|
||||
* Remake Font Manager for metafile
|
||||
*/
|
||||
bool CMetaFile::LoadFromXmlFile(const wchar_t *wsFilePath)
|
||||
{
|
||||
RELEASEINTERFACE(m_pFontManager);
|
||||
|
||||
if (m_pAppFonts)
|
||||
{
|
||||
m_pFontManager = m_pAppFonts->GenerateFontManager();
|
||||
NSFonts::IFontsCache* pMeasurerCache = NSFonts::NSFontCache::Create();
|
||||
pMeasurerCache->SetStreams(m_pAppFonts->GetStreams());
|
||||
m_pFontManager->SetOwnerCache(pMeasurerCache);
|
||||
}
|
||||
m_pFontManager->ClearOwnerCache();
|
||||
|
||||
m_oWmfFile.SetFontManager(m_pFontManager);
|
||||
m_oEmfFile.SetFontManager(m_pFontManager);
|
||||
@ -264,6 +175,10 @@ namespace MetaFile
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief CMetaFile::ConvertToEmf
|
||||
* @param wsFilePath - path to the file being saving (must be .emf)
|
||||
*/
|
||||
void CMetaFile::ConvertToEmf(const wchar_t *wsFilePath)
|
||||
{
|
||||
if (m_lType != c_lMetaEmf || m_oEmfFile.GetEmfParser()->GetType() != EmfParserType::EmfxParser)
|
||||
@ -276,21 +191,18 @@ namespace MetaFile
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief CMetaFile::LoadFromFile
|
||||
* @param wsFilePath - path to source file
|
||||
* @return if correct reading - return true, elde - false
|
||||
*
|
||||
* Load from source file
|
||||
* Remake Font Manager for metafile, for each picture
|
||||
* Check file extansion (wmf, emf, svm, svg)
|
||||
*/
|
||||
bool CMetaFile::LoadFromFile(const wchar_t *wsFilePath)
|
||||
{
|
||||
// TODO: Сейчас при загрузке каждой новой картинки мы пересоздаем
|
||||
// FontManager, потому что сейчас в нем кэш без ограничения.
|
||||
//------------------------------------------------------
|
||||
|
||||
RELEASEINTERFACE(m_pFontManager);
|
||||
|
||||
if (m_pAppFonts)
|
||||
{
|
||||
m_pFontManager = m_pAppFonts->GenerateFontManager();
|
||||
NSFonts::IFontsCache* pMeasurerCache = NSFonts::NSFontCache::Create();
|
||||
pMeasurerCache->SetStreams(m_pAppFonts->GetStreams());
|
||||
m_pFontManager->SetOwnerCache(pMeasurerCache);
|
||||
}
|
||||
m_pFontManager->ClearOwnerCache();
|
||||
|
||||
#ifdef METAFILE_SUPPORT_WMF_EMF
|
||||
m_oWmfFile.SetFontManager(m_pFontManager);
|
||||
@ -305,10 +217,7 @@ namespace MetaFile
|
||||
m_oSvgFile.SetFontManager(m_pFontManager);
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------
|
||||
|
||||
#ifdef METAFILE_SUPPORT_WMF_EMF
|
||||
// Сначала пытаемся открыть файл как Wmf
|
||||
if (m_oWmfFile.OpenFromWmfFile(wsFilePath) == true)
|
||||
{
|
||||
m_oWmfFile.Scan();
|
||||
@ -320,7 +229,7 @@ namespace MetaFile
|
||||
}
|
||||
m_oWmfFile.Close();
|
||||
}
|
||||
// Это не Wmf
|
||||
|
||||
if (m_oEmfFile.OpenFromEmfFile(wsFilePath) == true)
|
||||
{
|
||||
m_oEmfFile.Scan();
|
||||
@ -333,7 +242,7 @@ namespace MetaFile
|
||||
m_oEmfFile.Close();
|
||||
}
|
||||
#endif
|
||||
// Это не Emf
|
||||
|
||||
#ifdef METAFILE_SUPPORT_SVM
|
||||
if (m_oSvmFile.OpenFromFile(wsFilePath) == true)
|
||||
{
|
||||
@ -348,37 +257,47 @@ namespace MetaFile
|
||||
m_oSvmFile.Close();
|
||||
}
|
||||
#endif
|
||||
// Это не svm
|
||||
|
||||
#ifdef METAFILE_SUPPORT_SVG
|
||||
if (m_oSvgFile.OpenFromFile(wsFilePath) == true)
|
||||
{
|
||||
m_lType = c_lMetaSvg;
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief CMetaFile::LoadFromBuffer
|
||||
* @param pBuffer - pointer of buffer whith metacontent
|
||||
* for example, the buffer obtained after reading the file
|
||||
* @code
|
||||
* NSFile::CFileBinary file;
|
||||
* file.OpenFile(L"file_name");
|
||||
* DWORD file_size = file.GetFileSize();
|
||||
* BYTE* data = new BYTE[file_size];
|
||||
* file.ReadFile(data, file_size);
|
||||
* @endcode
|
||||
* @param unSize - buffer size (size of file or readed size)
|
||||
* @code
|
||||
* DWORD readed_size;
|
||||
* file.ReadFile(data, file_size, readed_size);
|
||||
* @endcode
|
||||
* @return if correct format load for extansion - return true,
|
||||
* else - false
|
||||
*
|
||||
* Load metafile content from buffer
|
||||
* Remake Font Manager for metafile, for each picture
|
||||
* Check type of content in buffer, appropriate extension (wmf, emf, svm, svg)
|
||||
*/
|
||||
bool CMetaFile::LoadFromBuffer(BYTE *pBuffer, unsigned int unSize)
|
||||
{
|
||||
if (NULL == pBuffer || 0 == unSize)
|
||||
return false;
|
||||
|
||||
// TODO: Сейчас при загрузке каждой новой картинки мы пересоздаем
|
||||
// FontManager, потому что сейчас в нем кэш без ограничения.
|
||||
//------------------------------------------------------
|
||||
|
||||
RELEASEINTERFACE(m_pFontManager);
|
||||
|
||||
if (m_pAppFonts)
|
||||
{
|
||||
m_pFontManager = m_pAppFonts->GenerateFontManager();
|
||||
NSFonts::IFontsCache* pMeasurerCache = NSFonts::NSFontCache::Create();
|
||||
pMeasurerCache->SetStreams(m_pAppFonts->GetStreams());
|
||||
m_pFontManager->SetOwnerCache(pMeasurerCache);
|
||||
}
|
||||
m_pFontManager->ClearOwnerCache();
|
||||
|
||||
#ifdef METAFILE_SUPPORT_WMF_EMF
|
||||
m_oWmfFile.SetFontManager(m_pFontManager);
|
||||
@ -393,10 +312,7 @@ namespace MetaFile
|
||||
m_oSvgFile.SetFontManager(m_pFontManager);
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------
|
||||
|
||||
#ifdef METAFILE_SUPPORT_WMF_EMF
|
||||
// Сначала пытаемся открыть файл как Wmf
|
||||
if (m_oWmfFile.ReadFromBuffer(pBuffer, unSize) == true)
|
||||
{
|
||||
m_oWmfFile.Scan();
|
||||
@ -408,7 +324,7 @@ namespace MetaFile
|
||||
}
|
||||
m_oWmfFile.Close();
|
||||
}
|
||||
// Это не Wmf
|
||||
|
||||
if (m_oEmfFile.ReadFromBuffer(pBuffer, unSize) == true)
|
||||
{
|
||||
m_oEmfFile.Scan();
|
||||
@ -421,7 +337,7 @@ namespace MetaFile
|
||||
m_oEmfFile.Close();
|
||||
}
|
||||
#endif
|
||||
// Это не Emf
|
||||
|
||||
#ifdef METAFILE_SUPPORT_SVM
|
||||
if (m_oSvmFile.ReadFromBuffer(pBuffer, unSize) == true)
|
||||
{
|
||||
@ -436,7 +352,7 @@ namespace MetaFile
|
||||
m_oSvmFile.Close();
|
||||
}
|
||||
#endif
|
||||
// Это не svm
|
||||
|
||||
#ifdef METAFILE_SUPPORT_SVG
|
||||
if (m_oSvgFile.ReadFromBuffer(pBuffer, unSize) == true)
|
||||
{
|
||||
@ -448,19 +364,18 @@ namespace MetaFile
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief CMetaFile::LoadFromString
|
||||
* @param data - source string, containing svg metadata (.svg extension type)
|
||||
* @return if correct read svg content - return true, else - false
|
||||
*
|
||||
* Load .svg content from wide string
|
||||
* Remake Font Manager for metafile, for each picture
|
||||
*/
|
||||
bool CMetaFile::LoadFromString(const std::wstring& data)
|
||||
{
|
||||
m_pFontManager->ClearOwnerCache();
|
||||
#ifdef METAFILE_SUPPORT_SVG
|
||||
RELEASEINTERFACE(m_pFontManager);
|
||||
|
||||
if (m_pAppFonts)
|
||||
{
|
||||
m_pFontManager = m_pAppFonts->GenerateFontManager();
|
||||
NSFonts::IFontsCache* pMeasurerCache = NSFonts::NSFontCache::Create();
|
||||
pMeasurerCache->SetStreams(m_pAppFonts->GetStreams());
|
||||
m_pFontManager->SetOwnerCache(pMeasurerCache);
|
||||
}
|
||||
|
||||
m_oSvgFile.SetFontManager(m_pFontManager);
|
||||
|
||||
if (m_oSvgFile.ReadFromWString(data) == true)
|
||||
@ -472,6 +387,10 @@ namespace MetaFile
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief CMetaFile::SetTempDirectory
|
||||
* @param dir - path to working directory
|
||||
*/
|
||||
void CMetaFile::SetTempDirectory(const std::wstring& dir)
|
||||
{
|
||||
#ifdef METAFILE_SUPPORT_SVG
|
||||
@ -479,7 +398,23 @@ namespace MetaFile
|
||||
#endif
|
||||
}
|
||||
|
||||
bool CMetaFile::DrawOnRenderer(IRenderer* pRenderer, double dX, double dY, double dWidth, double dHeight)
|
||||
/**
|
||||
* @brief CMetaFile::DrawOnRenderer
|
||||
* @param pRenderer - class instance of CGraphicsRenderer, which will render
|
||||
* meta content
|
||||
* @param dX - start coordinate for X axis
|
||||
* @param dY - start coordinate for Y axis
|
||||
* @param dWidth - width of picture from metafile
|
||||
* @param dHeight - height of picture from metafile
|
||||
* @param wsXmlFilePath - path to the file being saveing as xml commands from
|
||||
* metafile (default - nullptr)
|
||||
* @return if none render - return false, else - true
|
||||
*
|
||||
* Check type of metacontent
|
||||
* Draw the meta file picture on renderer
|
||||
*/
|
||||
bool CMetaFile::DrawOnRenderer(IRenderer* pRenderer, double dX, double dY,
|
||||
double dWidth, double dHeight, const wchar_t* wsXmlFilePath)
|
||||
{
|
||||
if (NULL == pRenderer)
|
||||
return false;
|
||||
@ -499,7 +434,10 @@ namespace MetaFile
|
||||
case c_lMetaEmf:
|
||||
{
|
||||
CMetaFileRenderer oEmfOut(m_oEmfFile.GetEmfParser(), pRenderer, dX, dY, dWidth, dHeight);
|
||||
m_oEmfFile.SetOutputDevice((IOutputDevice*)&oEmfOut);
|
||||
if (wsXmlFilePath)
|
||||
m_oEmfFile.SetOutputDevice((IOutputDevice*)&oEmfOut, wsXmlFilePath);
|
||||
else
|
||||
m_oEmfFile.SetOutputDevice((IOutputDevice*)&oEmfOut);
|
||||
m_oEmfFile.PlayMetaFile();
|
||||
break;
|
||||
}
|
||||
@ -528,6 +466,11 @@ namespace MetaFile
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief CMetaFile::Close
|
||||
*
|
||||
* Close each type file (type = 0)
|
||||
*/
|
||||
void CMetaFile::Close()
|
||||
{
|
||||
#ifdef METAFILE_SUPPORT_WMF_EMF
|
||||
@ -542,11 +485,27 @@ namespace MetaFile
|
||||
m_lType = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief CMetaFile::GetType
|
||||
* @return type of metafile
|
||||
* @enum
|
||||
* c_lMetaWmf = 0x01;
|
||||
* c_lMetaEmf = 0x02;
|
||||
* c_lMetaSvg = 0x04;
|
||||
* c_lMetaSvm = 0x05;
|
||||
*/
|
||||
int CMetaFile::GetType()
|
||||
{
|
||||
return m_lType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief CMetaFile::GetBounds
|
||||
* @param pdX - pointer to saving X coordinate of bounds
|
||||
* @param pdY - pointer to saving Y coordinate of bounds
|
||||
* @param pdW - pointer to saving Width of bounds
|
||||
* @param pdH - pointer to saving height of bounds
|
||||
*/
|
||||
void CMetaFile::GetBounds(double* pdX, double* pdY, double* pdW, double* pdH)
|
||||
{
|
||||
switch (m_lType)
|
||||
@ -609,8 +568,31 @@ namespace MetaFile
|
||||
if (*pdH < 0) *pdH = -*pdH;
|
||||
}
|
||||
|
||||
void CMetaFile::ConvertToRaster(const wchar_t* wsOutFilePath, unsigned int unFileType, int nWidth, int nHeight)
|
||||
/**
|
||||
* @brief CMetaFile::ConvertToRaster
|
||||
* @param wsOutFilePath - path to the file being saving (must be raster graphics
|
||||
* like .bmp, .png, etc.)
|
||||
* @param unFileType - type of raster file, see ENUM_CXIMAGE_FORMATS
|
||||
* for example .bmp = 1, .png = 4
|
||||
* @param unWidth - width of picture from metafile
|
||||
* @param unHeight - height of picture from metafile (default -1)
|
||||
* @param wsXmlOutFile(optional) - path to the file being saving metafile
|
||||
* commands to .xml (default nullptr)
|
||||
*
|
||||
* Create Graphics Renderer and Font Manager
|
||||
* Draw metafile content on created renderer and save in raster graphics file
|
||||
*/
|
||||
void CMetaFile::ConvertToRaster(const wchar_t* wsOutFilePath, unsigned int unFileType, int nWidth, int nHeight, const wchar_t* wsXmlOutFile)
|
||||
{
|
||||
if (nWidth == 0 || nHeight == 0)
|
||||
return;
|
||||
|
||||
if (NULL == wsOutFilePath)
|
||||
return;
|
||||
|
||||
if (wsXmlOutFile != NULL)
|
||||
m_oEmfFile.SetOutputDevice(NULL, wsXmlOutFile);
|
||||
|
||||
NSGraphics::IGraphicsRenderer* pGrRenderer = NSGraphics::Create();
|
||||
|
||||
NSFonts::IFontManager* pFontManager = m_pAppFonts->GenerateFontManager();
|
||||
@ -634,8 +616,8 @@ namespace MetaFile
|
||||
nHeight = (int)((double)nWidth * dH / dW);
|
||||
}
|
||||
|
||||
double dWidth = 25.4 * nWidth / 96;
|
||||
double dHeight = 25.4 * nHeight / 96;
|
||||
double dWidth = 25.4 * nWidth / 96; // Get the width and height from pixels to mm
|
||||
double dHeight = 25.4 * nHeight / 96; // 96 - standart DPI for inch
|
||||
|
||||
BYTE* pBgraData = (BYTE*)malloc(nWidth * nHeight * 4);
|
||||
if (!pBgraData)
|
||||
@ -655,12 +637,11 @@ namespace MetaFile
|
||||
return;
|
||||
|
||||
unsigned int alfa = 0xffffff;
|
||||
//дефолтный тон должен быть прозрачным, а не белым
|
||||
//memset(pBgraData, 0xff, nWidth * nHeight * 4);
|
||||
for (int i = 0; i < nWidth * nHeight; i++)
|
||||
{
|
||||
((unsigned int*)pBgraData)[i] = alfa;
|
||||
((unsigned int*)pBgraData)[i] = alfa; // Set default tone (must be transparent and not white)
|
||||
}
|
||||
|
||||
CBgraFrame oFrame;
|
||||
oFrame.put_Data(pBgraData);
|
||||
oFrame.put_Width(nWidth);
|
||||
@ -672,10 +653,11 @@ namespace MetaFile
|
||||
pGrRenderer->put_Width(dWidth);
|
||||
pGrRenderer->put_Height(dHeight);
|
||||
|
||||
DrawOnRenderer(pGrRenderer, 0, 0, dWidth, dHeight);
|
||||
DrawOnRenderer(pGrRenderer, 0, 0, dWidth, dHeight, wsXmlOutFile);
|
||||
|
||||
oFrame.SaveFile(wsOutFilePath, unFileType);
|
||||
oFrame.put_Data(NULL);
|
||||
|
||||
RELEASEINTERFACE(pFontManager);
|
||||
RELEASEINTERFACE(pGrRenderer);
|
||||
|
||||
|
||||
@ -56,36 +56,39 @@ typedef CSVGTransformer CSvgFile;
|
||||
|
||||
namespace MetaFile
|
||||
{
|
||||
/**
|
||||
* @class CMetaFile
|
||||
*
|
||||
* The interface provides various options for loading a metafile and saving it
|
||||
* in another format.
|
||||
*/
|
||||
class CMetaFile : public IMetaFile
|
||||
{
|
||||
public:
|
||||
CMetaFile(NSFonts::IApplicationFonts *pAppFonts);
|
||||
virtual ~CMetaFile();
|
||||
void Close();
|
||||
|
||||
void SetTempDirectory(const std::wstring& dir);
|
||||
|
||||
bool LoadFromFile(const wchar_t* wsFilePath);
|
||||
bool LoadFromBuffer(BYTE* pBuffer, unsigned int unSize);
|
||||
bool LoadFromString(const std::wstring& data);
|
||||
bool DrawOnRenderer(IRenderer* pRenderer, double dX, double dY, double dWidth, double dHeight);
|
||||
void Close();
|
||||
void GetBounds(double* pdX, double* pdY, double* pdW, double* pdH);
|
||||
int GetType();
|
||||
void ConvertToRaster(const wchar_t* wsOutFilePath, unsigned int unFileType, int nWidth, int nHeight = -1);
|
||||
|
||||
void ConvertToRaster(const wchar_t* wsOutFilePath, unsigned int unFileType,
|
||||
int nWidth, int nHeight = -1, const wchar_t* wsXmlOutFile = NULL);
|
||||
std::wstring ConvertToSvg(unsigned int unWidth = 0, unsigned int unHeight = 0);
|
||||
bool DrawOnRenderer(IRenderer* pRenderer, double dX, double dY,
|
||||
double dWidth, double dHeight, const wchar_t* wsXmlFilePath = NULL);
|
||||
|
||||
int GetType();
|
||||
void GetBounds(double* pdX, double* pdY, double* pdW, double* pdH);
|
||||
NSFonts::IFontManager* get_FontManager();
|
||||
|
||||
//конвертация в Svg
|
||||
std::wstring ConvertToSvg(unsigned int unWidth = 0, unsigned int unHeight = 0);
|
||||
|
||||
void SetTempDirectory(const std::wstring& dir);
|
||||
|
||||
//Для тестов
|
||||
#ifdef METAFILE_SUPPORT_WMF_EMF
|
||||
// For tests
|
||||
void ConvertToXml(const wchar_t *wsFilePath);
|
||||
void ConvertToXmlAndRaster(const wchar_t *wsXmlFilePath, const wchar_t* wsOutFilePath, unsigned int unFileType, int nWidth, int nHeight = -1);
|
||||
bool LoadFromXmlFile(const wchar_t* wsFilePath);
|
||||
bool DrawOnRenderer(const wchar_t *wsXmlFilePath, IRenderer* pRenderer, double dX, double dY, double dWidth, double dHeight);
|
||||
void ConvertToEmf(const wchar_t* wsFilePath);
|
||||
#endif
|
||||
|
||||
|
||||
private:
|
||||
|
||||
@ -266,6 +266,7 @@ void CSvmFile::Read_META_LINE()
|
||||
{
|
||||
case LINE_SOLID: last_pen->PenStyle = PS_SOLID ; break;
|
||||
case LINE_DASH: last_pen->PenStyle = PS_DASH ; break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -323,6 +324,7 @@ void CSvmFile::Read_META_POLYLINE()
|
||||
{
|
||||
case LINE_SOLID: last_pen->PenStyle = PS_SOLID ; break;
|
||||
case LINE_DASH: last_pen->PenStyle = PS_DASH ; break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
if (last_pen->Width < 1)
|
||||
|
||||
@ -153,7 +153,13 @@ namespace MetaFile
|
||||
|
||||
const std::wstring wsText{ConvertToUnicode(pString, (long)shStringLength, (NULL != pFont) ? pFont->GetCharSet() : DEFAULT_CHARSET)};
|
||||
|
||||
TPointD oScale((m_pParser->IsWindowFlippedX()) ? -1 : 1, (m_pParser->IsWindowFlippedY()) ? -1 : 1);
|
||||
TPointD oScale(1, 1);
|
||||
|
||||
if (NULL != m_pParser)
|
||||
{
|
||||
oScale.X = m_pParser->IsWindowFlippedX() ? -1 : 1;
|
||||
oScale.Y = m_pParser->IsWindowFlippedY() ? -1 : 1;
|
||||
}
|
||||
|
||||
std::vector<double> arDx(0);
|
||||
|
||||
|
||||
@ -298,7 +298,7 @@ namespace MetaFile
|
||||
m_oStream >> oBitmap;
|
||||
|
||||
unsigned int unRecordSizeDWORD = m_unRecordSize >> 1;
|
||||
unsigned int unValue = (META_STRETCHBLT >> 8) + 3;
|
||||
// unsigned int unValue = (META_STRETCHBLT >> 8) + 3;
|
||||
|
||||
if (unRecordSizeDWORD == ((META_STRETCHBLT >> 8) + 3))
|
||||
{
|
||||
|
||||
@ -196,7 +196,7 @@ namespace MetaFile
|
||||
if (InterpretatorType::Svg == oInterpretatorType)
|
||||
{
|
||||
CWmfInterpretatorSvg *pWmfInterpretatorSvg = new CWmfInterpretatorSvg(this, unWidth, unHeight);
|
||||
pWmfInterpretatorSvg->SetShapeRendering(EShapeRendering::CrispEdges);
|
||||
pWmfInterpretatorSvg->SetShapeRendering(EShapeRendering::OptimizeSpeed);
|
||||
m_pInterpretator = pWmfInterpretatorSvg;
|
||||
}
|
||||
}
|
||||
@ -241,10 +241,10 @@ namespace MetaFile
|
||||
{
|
||||
const double dKoef = 96. / (double)m_oPlaceable.ushInch;
|
||||
|
||||
m_oDCRect.Left = std::round(m_oDCRect.Left * dKoef);
|
||||
m_oDCRect.Top = std::round(m_oDCRect.Top * dKoef);
|
||||
m_oDCRect.Right = std::round(m_oDCRect.Right * dKoef);
|
||||
m_oDCRect.Bottom = std::round(m_oDCRect.Bottom * dKoef);
|
||||
m_oDCRect.Left = static_cast<int>(std::round(m_oDCRect.Left * dKoef));
|
||||
m_oDCRect.Top = static_cast<int>(std::round(m_oDCRect.Top * dKoef));
|
||||
m_oDCRect.Right = static_cast<int>(std::round(m_oDCRect.Right * dKoef));
|
||||
m_oDCRect.Bottom = static_cast<int>(std::round(m_oDCRect.Bottom * dKoef));
|
||||
}
|
||||
|
||||
// Иногда m_oPlaceable.BoundingBox задается нулевой ширины и высоты
|
||||
@ -292,6 +292,16 @@ namespace MetaFile
|
||||
m_pDC->SetCurPos(shX, shY);
|
||||
}
|
||||
|
||||
void CWmfParserBase::MoveToD(double dX, double dY)
|
||||
{
|
||||
if (NULL != m_pInterpretator)
|
||||
m_pInterpretator->MoveTo(dX, dY);
|
||||
else
|
||||
RegisterPoint(static_cast<short>(dX), static_cast<short>(dY));
|
||||
|
||||
m_pDC->SetCurPos(static_cast<short>(dX), static_cast<short>(dY));
|
||||
}
|
||||
|
||||
void CWmfParserBase::LineTo(short shX, short shY)
|
||||
{
|
||||
if (NULL != m_pInterpretator)
|
||||
@ -396,7 +406,7 @@ namespace MetaFile
|
||||
NSFonts::IFontManager* pFontManager = GetFontManager();
|
||||
if (pFontManager)
|
||||
{
|
||||
int lLogicalFontHeight = pFont->GetHeight();
|
||||
int lLogicalFontHeight = static_cast<int>(pFont->GetHeight());
|
||||
if (lLogicalFontHeight < 0)
|
||||
lLogicalFontHeight = -lLogicalFontHeight;
|
||||
if (lLogicalFontHeight < 0.01)
|
||||
@ -444,8 +454,8 @@ namespace MetaFile
|
||||
{
|
||||
pFontManager->LoadString1(wsText, 0, 0);
|
||||
TBBox oBox = pFontManager->MeasureString2();
|
||||
fL = (float)(oBox.fMinX);
|
||||
fW = (float)(oBox.fMaxX - oBox.fMinX);
|
||||
fL = static_cast<float>(oBox.fMinX);
|
||||
fW = static_cast<float>(oBox.fMaxX - oBox.fMinX);
|
||||
}
|
||||
|
||||
pFontManager->LoadString1(wsText, 0, 0);
|
||||
@ -520,7 +530,7 @@ namespace MetaFile
|
||||
}
|
||||
else
|
||||
{
|
||||
int lLogicalFontHeight = pFont->GetHeight();
|
||||
int lLogicalFontHeight = static_cast<int>(pFont->GetHeight());
|
||||
if (lLogicalFontHeight < 0)
|
||||
lLogicalFontHeight = -lLogicalFontHeight;
|
||||
if (lLogicalFontHeight < 0.01)
|
||||
@ -548,7 +558,7 @@ namespace MetaFile
|
||||
fW = (float)(dFontHeight * wsText.length());
|
||||
}
|
||||
|
||||
fH = dFontHeight * 1.2;
|
||||
fH = (float)dFontHeight * 1.2f;
|
||||
|
||||
double dTheta = -((((double)pFont->GetEscapement()) / 10) * 3.14159265358979323846 / 180);
|
||||
double dCosTheta = (float)cos(dTheta);
|
||||
@ -724,17 +734,17 @@ namespace MetaFile
|
||||
oNewRect.Top < 0 || oNewRect.Bottom < 0)
|
||||
return NULL;
|
||||
|
||||
if (unHeight < (oNewRect.Bottom - oNewRect.Top))
|
||||
oNewRect.Bottom = oNewRect.Top + unWidth;
|
||||
if (unHeight < static_cast<unsigned int>(std::abs(oNewRect.Bottom - oNewRect.Top)))
|
||||
oNewRect.Bottom = oNewRect.Top + unHeight;
|
||||
|
||||
if (unWidth < (oNewRect.Right - oNewRect.Left))
|
||||
if (unWidth < static_cast<unsigned int>(std::abs(oNewRect.Right - oNewRect.Left)))
|
||||
oNewRect.Right = oNewRect.Left + unWidth;
|
||||
|
||||
if (unHeight == (oNewRect.Bottom - oNewRect.Top) &&
|
||||
unWidth == (oNewRect.Right - oNewRect.Left))
|
||||
return NULL;
|
||||
|
||||
int nBeginX, nBeginY, nEndX, nEndY;
|
||||
ULONG nBeginX, nBeginY, nEndX, nEndY;
|
||||
|
||||
nBeginX = (std::min)(oNewRect.Left, oNewRect.Right);
|
||||
nBeginY = (std::min)(oNewRect.Top, oNewRect.Bottom);
|
||||
@ -924,7 +934,7 @@ namespace MetaFile
|
||||
|
||||
double dSweepAngle = GetSweepAngle(dStartAngle, dEndAngle);
|
||||
|
||||
MoveTo(dX1, dY1);
|
||||
MoveToD(dX1, dY1);
|
||||
ArcTo(shLeft, shTop, shRight, shBottom, dStartAngle, dSweepAngle);
|
||||
DrawPath(true, false);
|
||||
}
|
||||
|
||||
@ -188,6 +188,7 @@ namespace MetaFile
|
||||
inline double GetSweepAngle(const double& dStartAngle, const double& dEndAngle) const;
|
||||
|
||||
void MoveTo(short shX, short shY);
|
||||
void MoveToD(double dX, double dY);
|
||||
void LineTo(short shX, short shY);
|
||||
void ArcTo(short shL, short shT, short shR, short shB, double dStart, double dSweep);
|
||||
void ClosePath();
|
||||
|
||||
@ -9,6 +9,15 @@ namespace NSDocxRenderer
|
||||
{
|
||||
UINT CShape::m_gRelativeHeight = c_iStandartRelativeHeight;
|
||||
|
||||
unsigned int ClampUIntSign(const double& value)
|
||||
{
|
||||
if (value < 0)
|
||||
return 0;
|
||||
if (value > 0x7FFFFFFF)
|
||||
return 0x7FFFFFFF;
|
||||
return (unsigned int)value;
|
||||
}
|
||||
|
||||
CShape::CShape()
|
||||
{
|
||||
m_nRelativeHeight = m_gRelativeHeight;
|
||||
@ -881,10 +890,10 @@ namespace NSDocxRenderer
|
||||
{
|
||||
double to_percentage = 100.0 * 1000.0 / m_oPen.Size;
|
||||
oWriter.WriteString(L"<a:ds d=\"");
|
||||
oWriter.AddUInt(dash_pattern[i] * to_percentage);
|
||||
oWriter.AddUInt(ClampUIntSign(dash_pattern[i] * to_percentage));
|
||||
oWriter.WriteString(L"\" ");
|
||||
oWriter.WriteString(L"sp=\"");
|
||||
oWriter.AddUInt(dash_pattern[i + 1] * to_percentage);
|
||||
oWriter.AddUInt(ClampUIntSign(dash_pattern[i + 1] * to_percentage));
|
||||
oWriter.WriteString(L"\" />");
|
||||
}
|
||||
oWriter.WriteString(L"</a:custDash>");
|
||||
|
||||
@ -2381,6 +2381,8 @@ private:
|
||||
if (oTS.bAddSpaces && m_oState.m_bInP && !m_oState.m_bInR && !iswspace(sText.front()) && !m_oState.m_bWasSpace && CTextSettings::Normal == oTS.eTextMode)
|
||||
WriteSpace(pXml);
|
||||
|
||||
OpenP(pXml);
|
||||
|
||||
NSStringUtils::CStringBuilder oPPr;
|
||||
|
||||
std::wstring sPStyle = wrP(&oPPr, arSelectors, oTS);
|
||||
|
||||
@ -12,6 +12,8 @@ PWD_ROOT_DIR = $$PWD
|
||||
|
||||
include($$CORE_ROOT_DIR/Common/base.pri)
|
||||
|
||||
LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -lCryptoPPLib
|
||||
|
||||
ADD_DEPENDENCY(kernel, UnicodeConverter, graphics)
|
||||
|
||||
DEFINES += HWPFILE_USE_DYNAMIC_LIBRARY
|
||||
@ -50,7 +52,6 @@ SOURCES += \
|
||||
HwpDoc/HwpFileHeader.cpp \
|
||||
HwpDoc/OLEdoc/CompoundFile.cpp \
|
||||
HwpDoc/OLEdoc/DirectoryEntry.cpp \
|
||||
HwpDoc/Paragraph/CCtrlField.cpp \
|
||||
HwpDoc/Paragraph/CapParagraph.cpp \
|
||||
HwpDoc/Paragraph/CellParagraph.cpp \
|
||||
HwpDoc/Paragraph/CharShape.cpp \
|
||||
@ -63,6 +64,7 @@ SOURCES += \
|
||||
HwpDoc/Paragraph/CtrlContainer.cpp \
|
||||
HwpDoc/Paragraph/CtrlEmpty.cpp \
|
||||
HwpDoc/Paragraph/CtrlEqEdit.cpp \
|
||||
HwpDoc/Paragraph/CtrlField.cpp \
|
||||
HwpDoc/Paragraph/CtrlForm.cpp \
|
||||
HwpDoc/Paragraph/CtrlGeneralShape.cpp \
|
||||
HwpDoc/Paragraph/CtrlHeadFoot.cpp \
|
||||
@ -135,7 +137,6 @@ HEADERS += \
|
||||
HwpDoc/OLEdoc/DirectoryEntry.h \
|
||||
HwpDoc/OLEdoc/Sector.h \
|
||||
HwpDoc/OLEdoc/SectorType.h \
|
||||
HwpDoc/Paragraph/CCtrlField.h \
|
||||
HwpDoc/Paragraph/CapParagraph.h \
|
||||
HwpDoc/Paragraph/CellParagraph.h \
|
||||
HwpDoc/Paragraph/CharShape.h \
|
||||
@ -149,6 +150,7 @@ HEADERS += \
|
||||
HwpDoc/Paragraph/CtrlContainer.h \
|
||||
HwpDoc/Paragraph/CtrlEmpty.h \
|
||||
HwpDoc/Paragraph/CtrlEqEdit.h \
|
||||
HwpDoc/Paragraph/CtrlField.h \
|
||||
HwpDoc/Paragraph/CtrlForm.h \
|
||||
HwpDoc/Paragraph/CtrlGeneralShape.h \
|
||||
HwpDoc/Paragraph/CtrlHeadFoot.h \
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
|
||||
namespace HWP
|
||||
{
|
||||
static std::vector<std::pair<THWPColor, std::wstring>> arHighlightColors
|
||||
static const std::vector<std::pair<THWPColor, std::wstring>> arHighlightColors
|
||||
{{{{0, 0, 0}, L"black"}, {{0, 0, 255}, L"blue"}, {{0, 255, 255}, L"cyan"},
|
||||
{{0, 255, 0}, L"green"}, {{255, 0, 255}, L"magenta"}, {{255, 0, 0}, L"red"},
|
||||
{{255, 255, 0}, L"yellow"}, {{255, 255, 255}, L"white"}, {{0, 0, 139}, L"darkBlue"},
|
||||
@ -74,7 +74,8 @@ EShapeObjectType GetShapeObjectType(const std::wstring& wsID)
|
||||
}
|
||||
|
||||
CConverter2OOXML::CConverter2OOXML()
|
||||
: m_pContext(nullptr), m_ushShapeCount(0), m_ushPageCount(1), m_ushTableCount(0), m_ushEquationCount(0)
|
||||
: m_pContext(nullptr), m_ushShapeCount(0), m_ushPageCount(1), m_ushTableCount(0),
|
||||
m_ushEquationCount(0), m_ushBookmarkCount(0)
|
||||
{}
|
||||
|
||||
CConverter2OOXML::~CConverter2OOXML()
|
||||
@ -331,13 +332,11 @@ void CConverter2OOXML::WriteCharacter(const CCtrlCharacter* pCharacter, short sh
|
||||
{
|
||||
case ECtrlCharType::PARAGRAPH_BREAK:
|
||||
{
|
||||
if (oState.m_bOpenedP)
|
||||
{
|
||||
oState.m_bOpenedP = false;
|
||||
oBuilder.WriteString(L"</w:p>");
|
||||
}
|
||||
else
|
||||
WriteText(L"", shParaShapeID, pCharacter->GetCharShapeId(), oBuilder, oState);
|
||||
if (!oState.m_bOpenedP)
|
||||
break;
|
||||
|
||||
oState.m_bOpenedP = false;
|
||||
oBuilder.WriteString(L"</w:p>");
|
||||
|
||||
break;
|
||||
}
|
||||
@ -352,9 +351,9 @@ void CConverter2OOXML::WriteCharacter(const CCtrlCharacter* pCharacter, short sh
|
||||
}
|
||||
}
|
||||
|
||||
void CConverter2OOXML::WriteShape(const CCtrlGeneralShape* pShape, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState)
|
||||
void CConverter2OOXML::WriteShape(const CCtrlGeneralShape* pShape, short shParaShapeID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState)
|
||||
{
|
||||
if (nullptr == pShape)
|
||||
if (nullptr == pShape || oState.m_bInTextBox)
|
||||
return;
|
||||
|
||||
switch (pShape->GetShapeType())
|
||||
@ -366,27 +365,27 @@ void CConverter2OOXML::WriteShape(const CCtrlGeneralShape* pShape, NSStringUtils
|
||||
case EShapeType::Polygon:
|
||||
case EShapeType::Curve:
|
||||
{
|
||||
WriteGeometryShape(pShape, oBuilder, oState);
|
||||
WriteGeometryShape(pShape, shParaShapeID, oBuilder, oState);
|
||||
break;
|
||||
}
|
||||
case EShapeType::Pic:
|
||||
{
|
||||
WritePicture((const CCtrlShapePic*)pShape, oBuilder, oState);
|
||||
WritePicture((const CCtrlShapePic*)pShape, shParaShapeID, oBuilder, oState);
|
||||
break;
|
||||
}
|
||||
case EShapeType::EqEdit:
|
||||
{
|
||||
WriteEqEditShape((const CCtrlEqEdit*)pShape, oBuilder, oState);
|
||||
WriteEqEditShape((const CCtrlEqEdit*)pShape, shParaShapeID, oBuilder, oState);
|
||||
break;
|
||||
}
|
||||
case EShapeType::Ole:
|
||||
{
|
||||
WriteOleShape((const CCtrlShapeOle*)pShape, oBuilder, oState);
|
||||
WriteOleShape((const CCtrlShapeOle*)pShape, shParaShapeID, oBuilder, oState);
|
||||
break;
|
||||
}
|
||||
case EShapeType::Video:
|
||||
{
|
||||
WriteVideo((const CCtrlShapeVideo*)pShape, oBuilder, oState);
|
||||
WriteVideo((const CCtrlShapeVideo*)pShape, shParaShapeID, oBuilder, oState);
|
||||
break;
|
||||
}
|
||||
case EShapeType::GeneralShape:
|
||||
@ -417,22 +416,32 @@ void CConverter2OOXML::WriteField(const CCtrlField* pShape, short shParaShapeID,
|
||||
{
|
||||
case EFieldType::Hyperlink:
|
||||
{
|
||||
HWP_STRING sCommand = pShape->GetCommand();
|
||||
HWP_STRING wsHref = pShape->GetStringParam(L"Path");
|
||||
|
||||
if (sCommand.empty())
|
||||
break;
|
||||
|
||||
sCommand = sCommand.substr(0, sCommand.find(L';'));
|
||||
|
||||
size_t unFound = sCommand.find(L'\\');
|
||||
|
||||
while (HWP_STRING::npos != unFound)
|
||||
if(wsHref.empty())
|
||||
{
|
||||
sCommand.erase(unFound, 1);
|
||||
unFound = sCommand.find(L'\\', unFound);
|
||||
HWP_STRING sCommand = pShape->GetStringParam(L"Command");
|
||||
|
||||
if (sCommand.empty())
|
||||
sCommand = pShape->GetCommand();
|
||||
|
||||
sCommand = sCommand.substr(0, sCommand.find(L';'));
|
||||
|
||||
size_t unFound = sCommand.find(L'\\');
|
||||
|
||||
while (HWP_STRING::npos != unFound)
|
||||
{
|
||||
sCommand.erase(unFound, 1);
|
||||
unFound = sCommand.find(L'\\', unFound);
|
||||
}
|
||||
|
||||
wsHref = sCommand;
|
||||
}
|
||||
|
||||
const HWP_STRING wsID = AddRelationship(L"hyperlink", sCommand);
|
||||
if (wsHref.empty())
|
||||
break;
|
||||
|
||||
const HWP_STRING wsID = AddRelationship(L"hyperlink", wsHref);
|
||||
|
||||
OpenParagraph(shParaShapeID, oBuilder, oState);
|
||||
oBuilder.WriteString(L"<w:hyperlink r:id=\"" + wsID + L"\">");
|
||||
@ -446,6 +455,26 @@ void CConverter2OOXML::WriteField(const CCtrlField* pShape, short shParaShapeID,
|
||||
oBuilder.WriteString(L"</w:hyperlink>");
|
||||
break;
|
||||
}
|
||||
case EFieldType::Bookmark:
|
||||
{
|
||||
oBuilder.WriteString(L"<w:bookmarkStart w:id=\"" + std::to_wstring(m_ushBookmarkCount) + L"\" w:name=\"");
|
||||
oBuilder.WriteEncodeXmlString(pShape->GetStringParam(L"bookmarkname"));
|
||||
oBuilder.WriteString(L"\"/>");
|
||||
|
||||
oState.m_arOpenedBookmarks.push(m_ushBookmarkCount++);
|
||||
oState.m_mOpenField.insert(std::make_pair(pShape->GetInstanceID(), pShape));
|
||||
|
||||
break;
|
||||
}
|
||||
case EFieldType::BookmarkClosing:
|
||||
{
|
||||
if (oState.m_arOpenedBookmarks.empty())
|
||||
break;
|
||||
|
||||
oBuilder.WriteString(L"<w:bookmarkEnd w:id=\"" + std::to_wstring(oState.m_arOpenedBookmarks.top()) + L"\"/>");
|
||||
oState.m_arOpenedBookmarks.pop();
|
||||
break;
|
||||
}
|
||||
//TODO:: как-будто хочется определить тип закрывающей field на этапе парса hwpx
|
||||
case EFieldType::Unknown:
|
||||
{
|
||||
@ -460,6 +489,15 @@ void CConverter2OOXML::WriteField(const CCtrlField* pShape, short shParaShapeID,
|
||||
oBuilder.WriteString(L"</w:hyperlink>");
|
||||
break;
|
||||
}
|
||||
case EFieldType::Bookmark:
|
||||
{
|
||||
if (oState.m_arOpenedBookmarks.empty())
|
||||
break;
|
||||
|
||||
oBuilder.WriteString(L"<w:bookmarkEnd w:id=\"" + std::to_wstring(oState.m_arOpenedBookmarks.top()) + L"\"/>");
|
||||
oState.m_arOpenedBookmarks.pop();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -485,23 +523,22 @@ void CConverter2OOXML::WriteParagraph(const CHWPPargraph* pParagraph, NSStringUt
|
||||
return;
|
||||
|
||||
CloseParagraph(oBuilder, oState);
|
||||
OpenParagraph(pParagraph->GetShapeID(), oBuilder, oState);
|
||||
|
||||
if (0 < pParagraph->GetBreakType())
|
||||
{
|
||||
if ((0x04 == (pParagraph->GetBreakType() & 0x04)) && (0 < oState.m_unParaIndex))
|
||||
{
|
||||
oBuilder.WriteString(L"<w:r><w:br w:type=\"page\"/></w:r>");
|
||||
oState.m_eBreakType = TConversionState::EBreakType::Page;
|
||||
// oBuilder.WriteString(L"<w:r><w:br w:type=\"page\"/></w:r>");
|
||||
++m_ushPageCount;
|
||||
}
|
||||
else if (0x08 == (pParagraph->GetBreakType() & 0x08))
|
||||
oBuilder.WriteString(L"<w:r><w:br w:type=\"column\"/></w:r>");
|
||||
oState.m_eBreakType = TConversionState::EBreakType::Column;
|
||||
// oBuilder.WriteString(L"<w:r><w:br w:type=\"column\"/></w:r>");
|
||||
}
|
||||
|
||||
++oState.m_unParaIndex;
|
||||
|
||||
std::vector<const CCtrlNote*> arNotes;
|
||||
|
||||
for (const CCtrl* pCtrl : pParagraph->GetCtrls())
|
||||
{
|
||||
switch (pCtrl->GetCtrlType())
|
||||
@ -519,7 +556,7 @@ void CConverter2OOXML::WriteParagraph(const CHWPPargraph* pParagraph, NSStringUt
|
||||
}
|
||||
case ECtrlObjectType::Shape:
|
||||
{
|
||||
WriteShape((const CCtrlGeneralShape*)pCtrl, oBuilder, oState);
|
||||
WriteShape((const CCtrlGeneralShape*)pCtrl, pParagraph->GetShapeID(), oBuilder, oState);
|
||||
break;
|
||||
}
|
||||
case ECtrlObjectType::Table:
|
||||
@ -529,7 +566,7 @@ void CConverter2OOXML::WriteParagraph(const CHWPPargraph* pParagraph, NSStringUt
|
||||
}
|
||||
case ECtrlObjectType::Note:
|
||||
{
|
||||
arNotes.push_back((const CCtrlNote*)pCtrl);
|
||||
WriteNote((const CCtrlNote*)pCtrl, pParagraph->GetShapeID(), oBuilder, oState);
|
||||
break;
|
||||
}
|
||||
case ECtrlObjectType::SectionDef:
|
||||
@ -544,7 +581,7 @@ void CConverter2OOXML::WriteParagraph(const CHWPPargraph* pParagraph, NSStringUt
|
||||
}
|
||||
case ECtrlObjectType::AutoNumber:
|
||||
{
|
||||
WriteAutoNumber((const CCtrlAutoNumber*)pCtrl, pParagraph->GetShapeID(), ((const CParaText*)pCtrl)->GetCharShapeID(), oBuilder, oState);
|
||||
WriteAutoNumber((const CCtrlAutoNumber*)pCtrl, pParagraph->GetShapeID(), oState.m_ushLastCharShapeId, oBuilder, oState);
|
||||
break;
|
||||
}
|
||||
case ECtrlObjectType::Field:
|
||||
@ -561,20 +598,6 @@ void CConverter2OOXML::WriteParagraph(const CHWPPargraph* pParagraph, NSStringUt
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (!arNotes.empty() && ECtrlObjectType::Note != pCtrl->GetCtrlType() && oState.m_bOpenedP)
|
||||
{
|
||||
for (const CCtrlNote* pNote: arNotes)
|
||||
WriteNote(pNote, pParagraph->GetShapeID(), oBuilder, oState);
|
||||
|
||||
arNotes.clear();
|
||||
}
|
||||
}
|
||||
|
||||
if (oState.m_bOpenedP && !arNotes.empty())
|
||||
{
|
||||
for (const CCtrlNote* pNote: arNotes)
|
||||
WriteNote(pNote, pParagraph->GetShapeID(), oBuilder, oState);
|
||||
}
|
||||
|
||||
CloseParagraph(oBuilder, oState);
|
||||
@ -604,6 +627,11 @@ void CConverter2OOXML::WriteParaShapeProperties(short shParaShapeID, NSStringUti
|
||||
|
||||
oBuilder.WriteString(L"<w:keepNext w:val=\"" + HWP_STRING((pParaShape->KeepWithNext()) ? L"true" : L"false") + L"\"/>");
|
||||
|
||||
const int nIndent = pParaShape->GetIndent();
|
||||
|
||||
if (0 != nIndent)
|
||||
oBuilder.WriteString(L"<w:ind w:firstLine=\"" + std::to_wstring(static_cast<int>(std::ceil(nIndent / 10.))) + L"\"/>");
|
||||
|
||||
switch(pParaShape->GetHorizantalAlign())
|
||||
{
|
||||
case EHorizontalAlign::JUSTIFY: oBuilder.WriteString(L"<w:jc w:val=\"both\"/>"); break;
|
||||
@ -667,7 +695,7 @@ void CConverter2OOXML::WriteParaShapeProperties(short shParaShapeID, NSStringUti
|
||||
|
||||
oBuilder.WriteString(L"<w:numPr>");
|
||||
|
||||
oBuilder.WriteString(L"<w:ilvl w:val=\"0\"/>");
|
||||
oBuilder.WriteString(L"<w:ilvl w:val=\"" + std::to_wstring((int)pParaShape->GetHeadingLevel()) + L"\"/>");
|
||||
oBuilder.WriteString(L"<w:numId w:val=\"" + std::to_wstring(nNumId) + L"\"/>");
|
||||
|
||||
oBuilder.WriteString(L"</w:numPr>");
|
||||
@ -685,6 +713,8 @@ void CConverter2OOXML::WriteTable(const CCtrlTable* pTable, short shParaShapeID,
|
||||
if (nullptr == pTable || pTable->Empty())
|
||||
return;
|
||||
|
||||
CloseParagraph(oBuilder, oState);
|
||||
|
||||
++m_ushTableCount;
|
||||
|
||||
oBuilder.WriteString(L"<w:tbl>");
|
||||
@ -825,8 +855,18 @@ void CConverter2OOXML::WriteCell(const CTblCell* pCell, NSStringUtils::CStringBu
|
||||
{
|
||||
for (const CHWPPargraph* pParagraph : pCell->GetParagraphs())
|
||||
{
|
||||
NSStringUtils::CStringBuilder oCellBuilder;
|
||||
TConversionState oCellState;
|
||||
WriteParagraph(pParagraph, oBuilder, oCellState);
|
||||
|
||||
WriteParagraph(pParagraph, oCellBuilder, oCellState);
|
||||
|
||||
if (0 == oCellBuilder.GetCurSize())
|
||||
{
|
||||
OpenParagraph(pParagraph->GetShapeID(), oBuilder, oCellState);
|
||||
CloseParagraph(oBuilder, oCellState);
|
||||
}
|
||||
else
|
||||
oBuilder.Write(oCellBuilder);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -850,15 +890,15 @@ void CConverter2OOXML::WriteCellProperties(short shBorderFillID, NSStringUtils::
|
||||
|
||||
oBuilder.WriteString(L"<w:tcBorders>");
|
||||
|
||||
WriteCellBorder(pBorderFill->GetTopBorder(), L"top", oBuilder);
|
||||
WriteCellBorder(pBorderFill->GetLeftBorder(), L"left", oBuilder);
|
||||
WriteCellBorder(pBorderFill->GetBottomBorder(), L"bottom", oBuilder);
|
||||
WriteCellBorder(pBorderFill->GetRightBorder(), L"right", oBuilder);
|
||||
WriteBorder(pBorderFill->GetTopBorder(), L"top", oBuilder);
|
||||
WriteBorder(pBorderFill->GetLeftBorder(), L"left", oBuilder);
|
||||
WriteBorder(pBorderFill->GetBottomBorder(), L"bottom", oBuilder);
|
||||
WriteBorder(pBorderFill->GetRightBorder(), L"right", oBuilder);
|
||||
|
||||
oBuilder.WriteString(L"</w:tcBorders>");
|
||||
}
|
||||
|
||||
void CConverter2OOXML::WriteCellBorder(const TBorder& oBorder, const HWP_STRING& sBorderName, NSStringUtils::CStringBuilder& oBuilder)
|
||||
void CConverter2OOXML::WriteBorder(const TBorder& oBorder, const HWP_STRING& sBorderName, NSStringUtils::CStringBuilder& oBuilder)
|
||||
{
|
||||
if (0x00 == oBorder.m_chWidth || sBorderName.empty())
|
||||
return;
|
||||
@ -904,7 +944,7 @@ VECTOR<TPoint> ArcToBezier(const TPoint& oStart, const TPoint& oEnd, const TPoin
|
||||
return {oStart, oControl1, oControl2, oEnd};
|
||||
}
|
||||
|
||||
void CConverter2OOXML::WriteGeometryShape(const CCtrlGeneralShape* pGeneralShape, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState)
|
||||
void CConverter2OOXML::WriteGeometryShape(const CCtrlGeneralShape* pGeneralShape, short shParaShapeID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState)
|
||||
{
|
||||
if (nullptr == pGeneralShape)
|
||||
return;
|
||||
@ -914,17 +954,18 @@ void CConverter2OOXML::WriteGeometryShape(const CCtrlGeneralShape* pGeneralShape
|
||||
if (EShapeObjectType::Unknown == eShapeType)
|
||||
return;
|
||||
|
||||
++m_ushShapeCount;
|
||||
|
||||
WriteCaption((const CCtrlCommon*)pGeneralShape, oBuilder, oState);
|
||||
|
||||
OpenParagraph(shParaShapeID, oBuilder, oState);
|
||||
|
||||
const int nWidth = Transform::HWPUINT2OOXML(pGeneralShape->GetWidth());
|
||||
const int nHeight = Transform::HWPUINT2OOXML(pGeneralShape->GetHeight());
|
||||
|
||||
const std::wstring wsWidth = std::to_wstring(nWidth);
|
||||
const std::wstring wsHeight = std::to_wstring(nHeight);
|
||||
|
||||
if (!oState.m_bOpenedP)
|
||||
oBuilder.WriteString(L"<w:p>");
|
||||
|
||||
oBuilder.WriteString(L"<w:r><w:rPr><w:noProof/></w:rPr>");
|
||||
oBuilder.WriteString(L"<mc:AlternateContent><mc:Choice Requires=\"wps\">");
|
||||
|
||||
@ -1053,6 +1094,7 @@ void CConverter2OOXML::WriteGeometryShape(const CCtrlGeneralShape* pGeneralShape
|
||||
oBuilder.WriteString(L"<wps:txbx><w:txbxContent>");
|
||||
|
||||
TConversionState oShapeState;
|
||||
oShapeState.m_bInTextBox = true;
|
||||
|
||||
for (unsigned int unParaIndex = 0; unParaIndex < nCountParagraphs; ++unParaIndex)
|
||||
WriteParagraph(pGeneralShape->GetParagraphs(unParaIndex), oBuilder, oShapeState);
|
||||
@ -1065,21 +1107,16 @@ void CConverter2OOXML::WriteGeometryShape(const CCtrlGeneralShape* pGeneralShape
|
||||
oBuilder.WriteString(L"</wps:wsp></a:graphicData></a:graphic>");
|
||||
CloseDrawingNode(pGeneralShape, oBuilder);
|
||||
oBuilder.WriteString(L"</mc:Choice></mc:AlternateContent></w:r>");
|
||||
|
||||
if (!oState.m_bOpenedP)
|
||||
oBuilder.WriteString(L"</w:p>");
|
||||
}
|
||||
|
||||
void CConverter2OOXML::WriteEqEditShape(const CCtrlEqEdit* pEqEditShape, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState)
|
||||
void CConverter2OOXML::WriteEqEditShape(const CCtrlEqEdit* pEqEditShape, short shParaShapeID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState)
|
||||
{
|
||||
//TODO:: добавить конвертацию eqn формулы в ooxml
|
||||
++m_ushEquationCount;
|
||||
|
||||
if (!oState.m_bOpenedP)
|
||||
{
|
||||
oBuilder.WriteString(L"<w:p>");
|
||||
oState.m_bOpenedP = true;
|
||||
}
|
||||
WriteCaption((const CCtrlCommon*)pEqEditShape, oBuilder, oState);
|
||||
|
||||
OpenParagraph(shParaShapeID, oBuilder, oState);
|
||||
|
||||
oBuilder.WriteString(L"<w:r>");
|
||||
|
||||
@ -1088,7 +1125,7 @@ void CConverter2OOXML::WriteEqEditShape(const CCtrlEqEdit* pEqEditShape, NSStrin
|
||||
oBuilder.WriteString(L"</w:t></w:r>");
|
||||
}
|
||||
|
||||
void CConverter2OOXML::WriteOleShape(const CCtrlShapeOle* pOleShape, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState)
|
||||
void CConverter2OOXML::WriteOleShape(const CCtrlShapeOle* pOleShape, short shParaShapeID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState)
|
||||
{
|
||||
//TODO:: добавить конвертацию hwp ole -> ooxml chart
|
||||
//TODO:: необходимо добавить поддержку формата "Hwp Document File Formats - Charts" (для случаев, когда нет ooxml представления)
|
||||
@ -1111,12 +1148,15 @@ void CConverter2OOXML::WriteOleShape(const CCtrlShapeOle* pOleShape, NSStringUti
|
||||
if (0 == unChartIndex)
|
||||
return;
|
||||
|
||||
++m_ushShapeCount;
|
||||
|
||||
WriteCaption((const CCtrlCommon*)pOleShape, oBuilder, oState);
|
||||
|
||||
const std::wstring wsWidth = std::to_wstring(Transform::HWPUINT2OOXML(pOleShape->GetWidth()));
|
||||
const std::wstring wsHeight = std::to_wstring(Transform::HWPUINT2OOXML(pOleShape->GetHeight()));
|
||||
const std::wstring wsRelID = AddRelationship(L"chart", L"charts/chart" + std::to_wstring(unChartIndex) + L".xml");
|
||||
|
||||
if (!oState.m_bOpenedP)
|
||||
oBuilder.WriteString(L"<w:p>");
|
||||
OpenParagraph(shParaShapeID, oBuilder, oState);
|
||||
|
||||
oBuilder.WriteString(L"<w:r><w:rPr><w:noProof/></w:rPr>");
|
||||
|
||||
@ -1129,9 +1169,6 @@ void CConverter2OOXML::WriteOleShape(const CCtrlShapeOle* pOleShape, NSStringUti
|
||||
CloseDrawingNode(pOleShape, oBuilder);
|
||||
oBuilder.WriteString(L"</w:r>");
|
||||
|
||||
if (!oState.m_bOpenedP)
|
||||
oBuilder.WriteString(L"</w:p>");
|
||||
|
||||
AddContentType(L"charts/chart" + std::to_wstring(unChartIndex) + L".xml", L"application/vnd.openxmlformats-officedocument.drawingml.chart+xml");
|
||||
AddContentType(L"charts/style" + std::to_wstring(unChartIndex) + L".xml", L"application/vnd.ms-office.chartstyle+xml");
|
||||
AddContentType(L"charts/colors" + std::to_wstring(unChartIndex) + L".xml", L"application/vnd.ms-office.chartcolorstyle+xml");
|
||||
@ -1168,17 +1205,6 @@ void CConverter2OOXML::WriteSectionSettings(TConversionState& oState)
|
||||
}
|
||||
}
|
||||
|
||||
if (nullptr != oState.m_pColumnDef && 1 < oState.m_pColumnDef->GetColCount())
|
||||
{
|
||||
//TODO:: Добавить поддержку остальный свойств
|
||||
m_oDocXml.WriteString(L"<w:cols w:num=\"" + std::to_wstring(oState.m_pColumnDef->GetColCount()) + L"\" w:space=\"454\" w:equalWidth=\"true\"");
|
||||
|
||||
if (ELineStyle2::NONE != oState.m_pColumnDef->GetColLineStyle())
|
||||
m_oDocXml.WriteString(L" w:sep=\"true\"");
|
||||
|
||||
m_oDocXml.WriteString(L"/>");
|
||||
}
|
||||
|
||||
const CPage *pPage = (nullptr != oState.m_pSectionDef) ? oState.m_pSectionDef->GetPage() : nullptr;
|
||||
|
||||
if (nullptr == pPage)
|
||||
@ -1195,12 +1221,24 @@ void CConverter2OOXML::WriteSectionSettings(TConversionState& oState)
|
||||
std::to_wstring(Transform::HWPUINT2Twips(pPage->GetMarginHeader())) + L"\" w:footer=\"" + std::to_wstring(Transform::HWPUINT2Twips(pPage->GetMarginFooter())) + L"\" w:gutter=\"" +
|
||||
std::to_wstring(Transform::HWPUINT2Twips(pPage->GetMarginGutter())) + L"\"/>");
|
||||
}
|
||||
m_oDocXml.WriteString(L"<w:cols w:space=\"708\"/>");
|
||||
m_oDocXml.WriteString(L"<w:docGrid w:linePitch=\"360\"/>");
|
||||
|
||||
if (nullptr != oState.m_pColumnDef && 1 < oState.m_pColumnDef->GetColCount())
|
||||
{
|
||||
//TODO:: Добавить поддержку остальный свойств
|
||||
m_oDocXml.WriteString(L"<w:cols w:num=\"" + std::to_wstring(oState.m_pColumnDef->GetColCount()) + L"\" w:space=\"454\"");
|
||||
|
||||
if (ELineStyle2::NONE != oState.m_pColumnDef->GetColLineStyle())
|
||||
m_oDocXml.WriteString(L" w:sep=\"true\"");
|
||||
|
||||
m_oDocXml.WriteString(L"/>");
|
||||
}
|
||||
else
|
||||
m_oDocXml.WriteString(L"<w:cols w:space=\"708\"/>");
|
||||
|
||||
m_oDocXml.WriteString(L"</w:sectPr>");
|
||||
}
|
||||
|
||||
void CConverter2OOXML::WritePicture(const CCtrlShapePic* pCtrlPic, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState)
|
||||
void CConverter2OOXML::WritePicture(const CCtrlShapePic* pCtrlPic, short shParaShapeId, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState)
|
||||
{
|
||||
if (nullptr == pCtrlPic)
|
||||
return;
|
||||
@ -1210,10 +1248,11 @@ void CConverter2OOXML::WritePicture(const CCtrlShapePic* pCtrlPic, NSStringUtils
|
||||
if (sPictureID.empty())
|
||||
return;
|
||||
|
||||
++m_ushShapeCount;
|
||||
|
||||
WriteCaption((const CCtrlCommon*)pCtrlPic, oBuilder, oState);
|
||||
|
||||
if (!oState.m_bOpenedP)
|
||||
oBuilder.WriteString(L"<w:p>");
|
||||
OpenParagraph(shParaShapeId, oBuilder, oState);
|
||||
|
||||
oBuilder.WriteString(L"<w:r><w:rPr><w:noProof/></w:rPr>");
|
||||
|
||||
@ -1231,12 +1270,9 @@ void CConverter2OOXML::WritePicture(const CCtrlShapePic* pCtrlPic, NSStringUtils
|
||||
oBuilder.WriteString(L"</pic:spPr></pic:pic></a:graphicData></a:graphic>");
|
||||
CloseDrawingNode(pCtrlPic, oBuilder);
|
||||
oBuilder.WriteString(L"</w:r>");
|
||||
|
||||
if (!oState.m_bOpenedP)
|
||||
oBuilder.WriteString(L"</w:p>");
|
||||
}
|
||||
|
||||
void CConverter2OOXML::WriteVideo(const CCtrlShapeVideo* pCtrlVideo, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState)
|
||||
void CConverter2OOXML::WriteVideo(const CCtrlShapeVideo* pCtrlVideo, short shParaShapeId, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState)
|
||||
{
|
||||
if (nullptr == pCtrlVideo || 1 != pCtrlVideo->GetVideoType())
|
||||
return;
|
||||
@ -1246,10 +1282,11 @@ void CConverter2OOXML::WriteVideo(const CCtrlShapeVideo* pCtrlVideo, NSStringUti
|
||||
if (sPictureID.empty())
|
||||
return;
|
||||
|
||||
++m_ushShapeCount;
|
||||
|
||||
WriteCaption((const CCtrlCommon*)pCtrlVideo, oBuilder, oState);
|
||||
|
||||
if (!oState.m_bOpenedP)
|
||||
oBuilder.WriteString(L"<w:p>");
|
||||
OpenParagraph(shParaShapeId, oBuilder, oState);
|
||||
|
||||
oBuilder.WriteString(L"<w:r><w:rPr><w:noProof/></w:rPr>");
|
||||
|
||||
@ -1279,9 +1316,6 @@ void CConverter2OOXML::WriteVideo(const CCtrlShapeVideo* pCtrlVideo, NSStringUti
|
||||
|
||||
CloseDrawingNode(pCtrlVideo, oBuilder);
|
||||
oBuilder.WriteString(L"</w:r>");
|
||||
|
||||
if (!oState.m_bOpenedP)
|
||||
oBuilder.WriteString(L"</w:p>");
|
||||
}
|
||||
|
||||
bool CConverter2OOXML::SaveSVGFile(const HWP_STRING& sSVG, HWP_STRING& sFileName)
|
||||
@ -1532,14 +1566,17 @@ void CConverter2OOXML::WriteRunnerStyle(short shCharShapeID, NSStringUtils::CStr
|
||||
if (!bStrike && pCharShape->StrikeOut())
|
||||
oBuilder.WriteString(L"<w:strike/>");
|
||||
|
||||
double dSpacing = ((double)pCharShape->GetHeight() / 100.) * ((double)pCharShape->GetSpacing(ELang::HANGUL) / 100) * 0.8 + 0.4;
|
||||
dSpacing *= 20; // pt to twips (20 = 1440 / 72)
|
||||
//TODO:: на данный момент вычисляется не правильно. Необходимо более точно разобраться
|
||||
// double dSpacing = ((double)pCharShape->GetHeight() / 100.) * ((double)pCharShape->GetSpacing(ELang::HANGUL) / 100) * 0.8 + 0.4;
|
||||
// dSpacing *= 20; // pt to twips (20 = 1440 / 72)
|
||||
|
||||
oBuilder.WriteString(L"<w:spacing w:val=\"" + std::to_wstring((int)std::round(dSpacing)) + L"\"/>");
|
||||
// oBuilder.WriteString(L"<w:spacing w:val=\"" + std::to_wstring((int)std::round(dSpacing)) + L"\"/>");
|
||||
|
||||
if (nullptr != oState.m_pHighlightColor)
|
||||
oBuilder.WriteString(L"<w:highlight w:val=\"" + ConvertIntRgbToStr(*oState.m_pHighlightColor) + L"\"/>");
|
||||
|
||||
WriteTextBorderStyle(pCharShape->GetBorderFillID(), oBuilder, oState);
|
||||
|
||||
oBuilder.WriteString(sExternStyles);
|
||||
|
||||
oBuilder.WriteString(L"</w:rPr>");
|
||||
@ -1559,13 +1596,26 @@ void CConverter2OOXML::WriteRunnerStyle(short shCharShapeID, NSStringUtils::CStr
|
||||
oState.m_eBreakType = TConversionState::EBreakType::None;
|
||||
}
|
||||
|
||||
void CConverter2OOXML::WriteTextBorderStyle(short shBorderFillId, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState)
|
||||
{
|
||||
const CHWPRecordBorderFill* pBorderFill = dynamic_cast<const CHWPRecordBorderFill*>(m_pContext->GetBorderFill(shBorderFillId));
|
||||
|
||||
if (nullptr == pBorderFill)
|
||||
return;
|
||||
|
||||
TBorder oBorder{pBorderFill->GetLeftBorder()};
|
||||
|
||||
if (ELineStyle2::NONE == oBorder.m_eStyle)
|
||||
return;
|
||||
|
||||
WriteBorder(pBorderFill->GetLeftBorder(), L"bdr", oBuilder);
|
||||
}
|
||||
|
||||
void CConverter2OOXML::OpenDrawingNode(const CCtrlCommon* pCtrlShape, NSStringUtils::CStringBuilder& oBuilder)
|
||||
{
|
||||
if (nullptr == pCtrlShape)
|
||||
return;
|
||||
|
||||
++m_ushShapeCount;
|
||||
|
||||
oBuilder.WriteString(L"<w:drawing>");
|
||||
|
||||
if (pCtrlShape->GetTreatAsChar())
|
||||
@ -1742,8 +1792,8 @@ void CConverter2OOXML::WriteText(const CParaText* pParaText, const std::vector<T
|
||||
{
|
||||
if (unTextPosition + nParaTextPosition == oRangeTag.m_nStartPos)
|
||||
{
|
||||
WriteText(wsText.substr(unStartText, unTextPosition - unStartText - 1), shParaShapeID, pParaText->GetCharShapeID(), oBuilder, oState);
|
||||
unStartText = unTextPosition - 1;
|
||||
WriteText(wsText.substr(unStartText, unTextPosition - unStartText), shParaShapeID, pParaText->GetCharShapeID(), oBuilder, oState);
|
||||
unStartText = unTextPosition;
|
||||
|
||||
switch (oRangeTag.m_chType)
|
||||
{
|
||||
@ -1758,8 +1808,8 @@ void CConverter2OOXML::WriteText(const CParaText* pParaText, const std::vector<T
|
||||
}
|
||||
else if (unTextPosition + nParaTextPosition == oRangeTag.m_nEndPos)
|
||||
{
|
||||
WriteText(wsText.substr(unStartText, unTextPosition - unStartText - 1), shParaShapeID, pParaText->GetCharShapeID(), oBuilder, oState);
|
||||
unStartText = unTextPosition - 1;
|
||||
WriteText(wsText.substr(unStartText, unTextPosition - unStartText), shParaShapeID, pParaText->GetCharShapeID(), oBuilder, oState);
|
||||
unStartText = unTextPosition;
|
||||
|
||||
switch (oRangeTag.m_chType)
|
||||
{
|
||||
@ -1830,7 +1880,22 @@ void CConverter2OOXML::WriteText(const HWP_STRING& wsText, short shParaShapeID,
|
||||
|
||||
WriteRunnerStyle(shCharShapeID, oBuilder, oState);
|
||||
|
||||
oBuilder.WriteString(L"<w:t>");
|
||||
oBuilder.WriteString(L"<w:t");
|
||||
|
||||
bool bNeedPreserve = (wsText.cend() != std::find_if(wsText.cbegin(), wsText.cend(), [](wchar_t wChar){ return iswspace(wChar); }));
|
||||
bool bNeedAddSpace = false;
|
||||
|
||||
if (oState.m_bIsNote && !iswspace(wsText[0]))
|
||||
bNeedAddSpace = true;
|
||||
|
||||
if (bNeedPreserve || bNeedAddSpace)
|
||||
oBuilder.WriteString(L" xml:space=\"preserve\">");
|
||||
else
|
||||
oBuilder.WriteString(L">");
|
||||
|
||||
if (bNeedAddSpace)
|
||||
oBuilder.WriteString(L" ");
|
||||
|
||||
oBuilder.WriteEncodeXmlString(wsText);
|
||||
oBuilder.WriteString(L"</w:t></w:r>");
|
||||
|
||||
@ -1985,12 +2050,29 @@ void CConverter2OOXML::WriteAutoNumber(const CCtrlAutoNumber* pAutoNumber,short
|
||||
switch (pAutoNumber->GetNumType())
|
||||
{
|
||||
case ENumType::PAGE:
|
||||
{
|
||||
OpenParagraph(shParaShapeID, oBuilder, oState);
|
||||
oBuilder.WriteString(L"<w:fldSimple w:instr=\"PAGE \\* ARABIC\"><w:r><w:t>1</w:t></w:r></w:fldSimple>");
|
||||
return;
|
||||
}
|
||||
case ENumType::TOTAL_PAGE:
|
||||
ushValue = m_ushPageCount; break;
|
||||
case ENumType::FOOTNOTE:
|
||||
ushValue = m_oFootnoteConverter.GetFootnoteCount(); break;
|
||||
{
|
||||
OpenParagraph(shParaShapeID, oBuilder, oState);
|
||||
oBuilder.WriteString(L"<w:r>");
|
||||
WriteRunnerStyle(shCharShapeID, oBuilder, oState, L"<w:vertAlign w:val=\"superscript\"/>");
|
||||
oBuilder.WriteString(L"<w:footnoteRef/></w:r>");
|
||||
return;
|
||||
}
|
||||
case ENumType::ENDNOTE:
|
||||
ushValue = m_oFootnoteConverter.GetEndnoteCount(); break;
|
||||
{
|
||||
OpenParagraph(shParaShapeID, oBuilder, oState);
|
||||
oBuilder.WriteString(L"<w:r>");
|
||||
WriteRunnerStyle(shCharShapeID, oBuilder, oState, L"<w:vertAlign w:val=\"superscript\"/>");
|
||||
oBuilder.WriteString(L"<w:endnoteRef/></w:r>");
|
||||
return;
|
||||
}
|
||||
case ENumType::FIGURE:
|
||||
{
|
||||
wsType = L"Figure";
|
||||
@ -2030,7 +2112,15 @@ HWP_STRING CConverter2OOXML::AddRelationship(const HWP_STRING& wsType, const HWP
|
||||
if (m_arRelationships.cend() != itFound)
|
||||
return itFound->m_wsID;
|
||||
|
||||
m_arRelationships.push_back({L"rId" + std::to_wstring(m_arRelationships.size() + 1), wsType, wsTarget});
|
||||
if (L"hyperlink" == wsType)
|
||||
{
|
||||
NSStringUtils::CStringBuilder oBuilder;
|
||||
oBuilder.WriteEncodeXmlString(wsTarget);
|
||||
|
||||
m_arRelationships.push_back({L"rId" + std::to_wstring(m_arRelationships.size() + 1), wsType, oBuilder.GetData()});
|
||||
}
|
||||
else
|
||||
m_arRelationships.push_back({L"rId" + std::to_wstring(m_arRelationships.size() + 1), wsType, wsTarget});
|
||||
|
||||
return m_arRelationships.back().m_wsID;
|
||||
}
|
||||
@ -2105,7 +2195,7 @@ HWP_STRING CConverter2OOXML::GetTempDirectory() const
|
||||
}
|
||||
|
||||
TConversionState::TConversionState()
|
||||
: m_bOpenedP(false), m_bOpenedR(false), m_ushLastCharShapeId(-1), m_ushSecdIndex(0), m_unParaIndex(0), m_pHighlightColor(nullptr),
|
||||
: m_bOpenedP(false), m_bOpenedR(false), m_bIsNote(false), m_bInTextBox(false), m_ushLastCharShapeId(-1), m_ushSecdIndex(0), m_unParaIndex(0), m_pHighlightColor(nullptr),
|
||||
m_pSectionDef(nullptr), m_pColumnDef(nullptr), m_eBreakType(EBreakType::None)
|
||||
{}
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
|
||||
#include "../../../DesktopEditor/common/StringBuilder.h"
|
||||
|
||||
#include "../Paragraph/CCtrlField.h"
|
||||
#include "../Paragraph/CtrlField.h"
|
||||
#include "../Paragraph/CtrlAutoNumber.h"
|
||||
#include "../Paragraph/CtrlSectionDef.h"
|
||||
#include "../Paragraph/CtrlShapeVideo.h"
|
||||
@ -37,6 +37,9 @@ struct TConversionState
|
||||
{
|
||||
bool m_bOpenedP;
|
||||
bool m_bOpenedR;
|
||||
bool m_bIsNote;
|
||||
|
||||
bool m_bInTextBox; // TODO:: используется, чтобы в wps:txbx не появилась новая фигура (посмотреть этот момент нужно подробнее)
|
||||
|
||||
unsigned short m_ushLastCharShapeId;
|
||||
|
||||
@ -46,6 +49,7 @@ struct TConversionState
|
||||
THWPColor *m_pHighlightColor;
|
||||
|
||||
VECTOR<const CCtrlHeadFoot*> m_arCtrlsHeadFoot; //only for hwpx
|
||||
std::stack<int> m_arOpenedBookmarks;
|
||||
|
||||
const CCtrlSectionDef* m_pSectionDef;
|
||||
const CCtrlColumnDef* m_pColumnDef;
|
||||
@ -106,6 +110,8 @@ class CConverter2OOXML
|
||||
unsigned short m_ushTableCount;
|
||||
unsigned short m_ushEquationCount;
|
||||
|
||||
unsigned short m_ushBookmarkCount;
|
||||
|
||||
void CreateEmptyFiles();
|
||||
void FillDefaultData();
|
||||
void Close();
|
||||
@ -118,20 +124,21 @@ class CConverter2OOXML
|
||||
void WriteTableProperties(const CCtrlTable* pTable, short shParaShapeID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState);
|
||||
void WriteCell(const CTblCell* pCell, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState, ECellCreator eCellCreator);
|
||||
void WriteCellProperties(short shBorderFillID, NSStringUtils::CStringBuilder& oBuilder);
|
||||
void WriteCellBorder(const TBorder& oBorder, const HWP_STRING& sBorderName, NSStringUtils::CStringBuilder& oBuilder);
|
||||
void WriteBorder(const TBorder& oBorder, const HWP_STRING& sBorderName, NSStringUtils::CStringBuilder& oBuilder);
|
||||
|
||||
void WriteGeometryShape(const CCtrlGeneralShape* pGeneralShape, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState);
|
||||
void WriteEqEditShape(const CCtrlEqEdit* pEqEditShape, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState);
|
||||
void WriteOleShape(const CCtrlShapeOle* pOleShape, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState);
|
||||
void WriteGeometryShape(const CCtrlGeneralShape* pGeneralShape, short shParaShapeID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState);
|
||||
void WriteEqEditShape(const CCtrlEqEdit* pEqEditShape, short shParaShapeID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState);
|
||||
void WriteOleShape(const CCtrlShapeOle* pOleShape, short shParaShapeID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState);
|
||||
|
||||
void WriteSectionSettings(TConversionState& oState);
|
||||
void WritePicture(const CCtrlShapePic* pCtrlPic, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState);
|
||||
void WriteVideo(const CCtrlShapeVideo* pCtrlVideo, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState);
|
||||
void WritePicture(const CCtrlShapePic* pCtrlPic, short shParaShapeID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState);
|
||||
void WriteVideo(const CCtrlShapeVideo* pCtrlVideo, short shParaShapeID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState);
|
||||
bool SaveSVGFile(const HWP_STRING& sSVG, HWP_STRING& sFileName);
|
||||
HWP_STRING SavePicture(const HWP_STRING& sBinItemId);
|
||||
|
||||
void WriteParaShapeProperties(short shParaShapeID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState);
|
||||
void WriteRunnerStyle(short shCharShapeID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState, const HWP_STRING& sExternStyles = L"");
|
||||
void WriteTextBorderStyle(short shBorderFillId, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState);
|
||||
|
||||
void OpenDrawingNode(const CCtrlCommon* pCtrlShape, NSStringUtils::CStringBuilder& oBuilder);
|
||||
void CloseDrawingNode(const CCtrlCommon* pCtrlShape, NSStringUtils::CStringBuilder& oBuilder);
|
||||
@ -152,7 +159,7 @@ class CConverter2OOXML
|
||||
|
||||
void WriteAutoNumber(const CCtrlAutoNumber* pAutoNumber, short shParaShapeID, short shCharShapeID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState);
|
||||
void WriteCharacter(const CCtrlCharacter* pCharacter, short shParaShapeID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState);
|
||||
void WriteShape(const CCtrlGeneralShape* pShape, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState);
|
||||
void WriteShape(const CCtrlGeneralShape* pShape, short shParaShapeID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState);
|
||||
|
||||
void WriteNote(const CCtrlNote* pNote, short shParaShapeID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState);
|
||||
|
||||
|
||||
@ -35,6 +35,7 @@ std::wstring CFootnoteConverter::CreateNote(const CCtrlNote* pNote, CConverter2O
|
||||
pXMLBuilder->WriteString(L"<w:" + wsPrefix + L"note w:id=\"" + wsIndex + L"\">");
|
||||
|
||||
TConversionState oState;
|
||||
oState.m_bIsNote = true;
|
||||
|
||||
for (const CHWPPargraph* pParagraph : pNote->GetParagraphs())
|
||||
oConverter.WriteParagraph(pParagraph, *pXMLBuilder, oState);
|
||||
|
||||
@ -27,12 +27,14 @@ int CNumberingConverter::CreateNumbering(const CHWPRecordNumbering* pNumbering,
|
||||
if (nullptr == pNumbering || eHeadingType == EHeadingType::NONE || EHeadingType::OUTLINE == eHeadingType)
|
||||
return 0;
|
||||
|
||||
std::vector<const CHWPRecordNumbering*>::const_iterator itFound = std::find(m_arUsedNumbering.cbegin(), m_arUsedNumbering.cend(), pNumbering);
|
||||
std::vector<std::pair<EHeadingType, const CHWPRecordNumbering*>>::const_iterator itFound = std::find_if(m_arUsedNumbering.cbegin(), m_arUsedNumbering.cend(),
|
||||
[pNumbering, eHeadingType](const std::pair<EHeadingType, const CHWPRecordNumbering*>& oValue)
|
||||
{ return eHeadingType == oValue.first && pNumbering == oValue.second;});
|
||||
|
||||
if (m_arUsedNumbering.cend() != itFound)
|
||||
return itFound - m_arUsedNumbering.cbegin() + 1;
|
||||
|
||||
m_arUsedNumbering.push_back(pNumbering);
|
||||
m_arUsedNumbering.push_back(std::make_pair(eHeadingType, pNumbering));
|
||||
|
||||
m_oNumberXml.WriteString(L"<w:abstractNum w:abstractNumId=\"" + std::to_wstring(m_arUsedNumbering.size()) + L"\">");
|
||||
|
||||
@ -51,7 +53,15 @@ int CNumberingConverter::CreateNumbering(const CHWPRecordNumbering* pNumbering,
|
||||
m_oNumberXml.WriteString(L"<w:suff w:val=\"space\"/>");
|
||||
|
||||
wsLvlText = pNumbering->GetNumFormat(shIndex);
|
||||
std::replace(wsLvlText.begin(), wsLvlText.end(), L'^', L'%');
|
||||
|
||||
if (wsLvlText.empty())
|
||||
{
|
||||
for (short shLvl = 0; shLvl <= shIndex; ++shLvl)
|
||||
wsLvlText += L'%' + std::to_wstring(shLvl + 1) + L'.';
|
||||
}
|
||||
else
|
||||
std::replace(wsLvlText.begin(), wsLvlText.end(), L'^', L'%');
|
||||
|
||||
m_oNumberXml.WriteString(L"<w:lvlText w:val=\"" + wsLvlText + L"\"/>");
|
||||
|
||||
m_oNumberXml.WriteString(L"<w:lvlJc w:val=\"");
|
||||
@ -73,9 +83,8 @@ int CNumberingConverter::CreateNumbering(const CHWPRecordNumbering* pNumbering,
|
||||
{
|
||||
m_oNumberXml.WriteString(L"<w:lvl w:ilvl=\"" + std::to_wstring(shIndex) + L"\">");
|
||||
|
||||
m_oNumberXml.WriteString(L"<w:start w:val=\"1\"/>");
|
||||
m_oNumberXml.WriteString(L"<w:numFmt w:val=\"" + wsNumFormat + L"\"/>");
|
||||
m_oNumberXml.WriteString(L"<w:suff w:val=\"space\"/>");
|
||||
m_oNumberXml.WriteString(L"<w:isLgl w:val=\"false\"/>");
|
||||
|
||||
m_oNumberXml.WriteString(L"<w:lvlJc w:val=\"");
|
||||
switch(pNumbering->GetAlign(shIndex))
|
||||
@ -174,7 +183,7 @@ bool CNumberingConverter::SaveToFile(const std::wstring& wsDirectory)
|
||||
else
|
||||
{
|
||||
for (unsigned short ushIndex = 1; ushIndex <= m_arUsedNumbering.size(); ++ushIndex)
|
||||
m_oNumberXml.WriteString(L"<w:num w:numId=\"" + std::to_wstring(ushIndex) + L"\"><w:abstractNumId w:val=\"" + std::to_wstring(ushIndex) + L"\"/></w:num>");
|
||||
oNumberingData.WriteString(L"<w:num w:numId=\"" + std::to_wstring(ushIndex) + L"\"><w:abstractNumId w:val=\"" + std::to_wstring(ushIndex) + L"\"/></w:num>");
|
||||
}
|
||||
|
||||
oNumberingData.WriteString(L"</w:numbering>");
|
||||
|
||||
@ -11,7 +11,7 @@ namespace HWP
|
||||
class CNumberingConverter
|
||||
{
|
||||
NSStringUtils::CStringBuilder m_oNumberXml;
|
||||
std::vector<const CHWPRecordNumbering*> m_arUsedNumbering;
|
||||
std::vector<std::pair<EHeadingType, const CHWPRecordNumbering*>> m_arUsedNumbering;
|
||||
public:
|
||||
CNumberingConverter();
|
||||
|
||||
|
||||
@ -123,8 +123,8 @@ void COleConverter::CreateChart(CHWPStream& oOleStream)
|
||||
NSStringUtils::CStringBuilder oRelsData;
|
||||
oRelsData.WriteString(L"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>");
|
||||
oRelsData.WriteString(L"<Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\">");
|
||||
oRelsData.WriteString(L"<Relationship Id=\"rId1\" Type=\"http://schemas.microsoft.com/office/2011/relationships/chartStyle\" Target=\"style1.xml\"/>");
|
||||
oRelsData.WriteString(L"<Relationship Id=\"rId2\" Type=\"http://schemas.microsoft.com/office/2011/relationships/chartColorStyle\" Target=\"colors1.xml\"/>");
|
||||
oRelsData.WriteString(L"<Relationship Id=\"rId1\" Type=\"http://schemas.microsoft.com/office/2011/relationships/chartStyle\" Target=\"style" + std::to_wstring(m_unCountCharts) + L".xml\"/>");
|
||||
oRelsData.WriteString(L"<Relationship Id=\"rId2\" Type=\"http://schemas.microsoft.com/office/2011/relationships/chartColorStyle\" Target=\"colors" + std::to_wstring(m_unCountCharts) + L".xml\"/>");
|
||||
oRelsData.WriteString(L"</Relationships>");
|
||||
|
||||
NSFile::CFileBinary oRelsFile;
|
||||
|
||||
@ -288,7 +288,7 @@ const CHWPRecord* CHWPDocInfo::GetCharShape(int nIndex) const
|
||||
|
||||
const CHWPRecord* CHWPDocInfo::GetNumbering(int nIndex) const
|
||||
{
|
||||
GET_RECORD(m_arNumberings, nIndex - 1);
|
||||
GET_RECORD(m_arNumberings, nIndex);
|
||||
}
|
||||
|
||||
const CHWPRecord* CHWPDocInfo::GetBullet(int nIndex) const
|
||||
@ -318,10 +318,33 @@ CHWPFile* CHWPDocInfo::GetParentHWP()
|
||||
|
||||
const CHWPRecord* CHWPDocInfo::GetBinData(const HWP_STRING& sID) const
|
||||
{
|
||||
if (m_mBinDatas.end() == m_mBinDatas.find(sID))
|
||||
return nullptr;
|
||||
switch (m_eHanType)
|
||||
{
|
||||
case EHanType::HWP:
|
||||
{
|
||||
short shID = std::stoi(sID) - 1;
|
||||
|
||||
return m_mBinDatas.at(sID);
|
||||
if (shID >= m_mBinDatas.size())
|
||||
return nullptr;
|
||||
|
||||
std::map<HWP_STRING, CHWPRecord*>::const_iterator itElement = m_mBinDatas.cbegin();
|
||||
|
||||
for (unsigned short ushIndex = 0; ushIndex < shID; ++ushIndex)
|
||||
++itElement;
|
||||
|
||||
return itElement->second;
|
||||
}
|
||||
case EHanType::HWPX:
|
||||
{
|
||||
if (m_mBinDatas.end() == m_mBinDatas.find(sID))
|
||||
return nullptr;
|
||||
|
||||
return m_mBinDatas.at(sID);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
EHanType CHWPDocInfo::GetHanType() const
|
||||
|
||||
@ -43,12 +43,6 @@ EState GetState(int nValue)
|
||||
CHWPRecordBinData::CHWPRecordBinData(CHWPDocInfo& oDocInfo, int nTagNum, int nLevel, int nSize, CHWPStream& oBuffer, int nOff, int nVersion)
|
||||
: CHWPRecord(nTagNum, nLevel, nSize)
|
||||
{
|
||||
if (EHanType::HWP == oDocInfo.GetHanType())
|
||||
{
|
||||
if (oDocInfo.GetParentHWP()->GetBinData().empty())
|
||||
oDocInfo.GetParentHWP()->SetBinData(oDocInfo.GetParentHWP()->GetOleFile()->GetChildEntries(L"BinData"));
|
||||
}
|
||||
|
||||
oBuffer.SavePosition();
|
||||
|
||||
short shTypeBits;
|
||||
|
||||
@ -372,4 +372,9 @@ int CHWPRecordCharShape::GetTextColor() const
|
||||
{
|
||||
return m_nTextColor;
|
||||
}
|
||||
|
||||
short CHWPRecordCharShape::GetBorderFillID() const
|
||||
{
|
||||
return m_shBorderFillIDRef;
|
||||
}
|
||||
}
|
||||
|
||||
@ -123,6 +123,8 @@ public:
|
||||
HWP_STRING GetFontName(ELang eLang) const;
|
||||
short GetSpacing(ELang eLang) const;
|
||||
int GetTextColor() const;
|
||||
|
||||
short GetBorderFillID() const;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
#include "HWPRecordCtrlData.h"
|
||||
#include "../Paragraph/CtrlField.h"
|
||||
|
||||
namespace HWP
|
||||
{
|
||||
@ -35,7 +36,53 @@ int CHWPRecordCtrlData::ParseCtrl(CCtrl& oCtrl, int nSize, CHWPStream& oBuffer,
|
||||
// TODO:: Вернуться к этому моменту
|
||||
// Само по себе содержание документа Hankom не позволяет понять, как его интерпретировать.
|
||||
|
||||
oBuffer.Skip(nSize);
|
||||
oBuffer.SavePosition();
|
||||
|
||||
if (ECtrlObjectType::Field == oCtrl.GetCtrlType())
|
||||
{
|
||||
short shSetID, shNumberItems;
|
||||
|
||||
oBuffer.ReadShort(shSetID);
|
||||
oBuffer.ReadShort(shNumberItems);
|
||||
|
||||
short shItemID, shItemType;
|
||||
for (unsigned short ushIndex = 0; ushIndex < shNumberItems; ++ushIndex)
|
||||
{
|
||||
oBuffer.ReadShort(shItemID);
|
||||
short shUnknownValue;
|
||||
oBuffer.ReadShort(shUnknownValue); // Unknown Data
|
||||
oBuffer.ReadShort(shItemType);
|
||||
|
||||
switch (GetParamItemType(shItemType))
|
||||
{
|
||||
case EParamItemType::PIT_NULL: oBuffer.Skip(4); break;
|
||||
case EParamItemType::PIT_BSTR:
|
||||
{
|
||||
HWP_STRING sValue;
|
||||
oBuffer.ReadString(sValue, EStringCharacter::UTF16);
|
||||
|
||||
if (EFieldType::Bookmark == ((CCtrlField&)oCtrl).GetType())
|
||||
((CCtrlField&)oCtrl).AddStringParam(L"bookmarkname", sValue);
|
||||
|
||||
break;
|
||||
}
|
||||
case EParamItemType::PIT_I1: oBuffer.Skip(1); break;
|
||||
case EParamItemType::PIT_I2: oBuffer.Skip(2); break;
|
||||
case EParamItemType::PIT_I4: oBuffer.Skip(4); break;
|
||||
case EParamItemType::PIT_I: oBuffer.Skip(4); break;
|
||||
case EParamItemType::PIT_UI1: oBuffer.Skip(1); break;
|
||||
case EParamItemType::PIT_UI2: oBuffer.Skip(2); break;
|
||||
case EParamItemType::PIT_UI4: oBuffer.Skip(4); break;
|
||||
case EParamItemType::PIT_UI: oBuffer.Skip(4); break;
|
||||
case EParamItemType::PIT_SET:
|
||||
case EParamItemType::PIT_ARRAY:
|
||||
case EParamItemType::PIT_BINDATA:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
oBuffer.Skip(nSize - oBuffer.GetDistanceToLastPos(true));
|
||||
return nSize;
|
||||
}
|
||||
}
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
#include "../Paragraph/CtrlSectionDef.h"
|
||||
#include "../Paragraph/CtrlTable.h"
|
||||
#include "../Paragraph/CtrlEmpty.h"
|
||||
#include "../Paragraph/CCtrlField.h"
|
||||
#include "../Paragraph/CtrlField.h"
|
||||
|
||||
namespace HWP
|
||||
{
|
||||
@ -78,7 +78,8 @@ CCtrl* CHWPRecordCtrlHeader::Parse(int nTagNum, int nLevel, int nSize, CHWPStrea
|
||||
pCtrl = new CCtrlPageNumPos(sCtrlID, nSize - oBuffer.GetDistanceToLastPos(), oBuffer, 0, nVersion);
|
||||
pCtrl->SetFullFilled();
|
||||
}
|
||||
else if (L"klh%" == sCtrlID)
|
||||
else if (L"klh%" == sCtrlID ||
|
||||
L"kmb%" == sCtrlID)
|
||||
{
|
||||
pCtrl = new CCtrlField(sCtrlID, nSize - oBuffer.GetDistanceToLastPos(), oBuffer, 0, nVersion);
|
||||
pCtrl->SetFullFilled();
|
||||
|
||||
@ -44,19 +44,6 @@ CHWPRecordIDMaping::CHWPRecordIDMaping(CHWPDocInfo& oDocInfo, int nTagNum, int n
|
||||
m_arIdMappingNum.push_back(nCount);
|
||||
|
||||
m_arCounts[nIndex] = nCount;
|
||||
|
||||
switch (GetIndex(nIndex))
|
||||
{
|
||||
case EIndex::BIN_DATA:
|
||||
{
|
||||
// TODO:: проверить
|
||||
if (nullptr != m_pParent && m_pParent->GetParentHWP()->GetBinData().empty())
|
||||
m_pParent->GetParentHWP()->SetBinData(m_pParent->GetParentHWP()->GetOleFile()->GetChildEntries(L"BinData"));
|
||||
|
||||
break;
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -218,4 +218,12 @@ int CHWPRecordNumbering::GetStartNumber(unsigned short ushIndex) const
|
||||
|
||||
return m_arNumbering[ushIndex].m_nStartNumber;
|
||||
}
|
||||
|
||||
int CHWPRecordNumbering::GetCharShape(unsigned short ushIndex) const
|
||||
{
|
||||
if (ushIndex >= 7)
|
||||
return 0;
|
||||
|
||||
return m_arNumbering[ushIndex].m_nCharShape;
|
||||
}
|
||||
}
|
||||
|
||||
@ -42,6 +42,7 @@ public:
|
||||
HWP_STRING GetNumFormat(unsigned short ushIndex) const;
|
||||
HWP_BYTE GetAlign(unsigned short ushIndex) const;
|
||||
int GetStartNumber(unsigned short ushIndex) const;
|
||||
int GetCharShape(unsigned short ushIndex) const;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -13,6 +13,14 @@ EHeadingType GetHeadingType(int nValue)
|
||||
}
|
||||
}
|
||||
|
||||
EHeadingType GetHeadingType(const HWP_STRING& sValue)
|
||||
{
|
||||
IF_STRING_IN_ENUM(OUTLINE, sValue, EHeadingType);
|
||||
ELSE_IF_STRING_IN_ENUM(NUMBER, sValue, EHeadingType);
|
||||
ELSE_IF_STRING_IN_ENUM(BULLET, sValue, EHeadingType);
|
||||
ELSE_STRING_IN_ENUM(NONE, EHeadingType);
|
||||
}
|
||||
|
||||
EHorizontalAlign GetHorizontalAlign(int nValue)
|
||||
{
|
||||
SWITCH(EHorizontalAlign, nValue)
|
||||
@ -26,6 +34,16 @@ EHorizontalAlign GetHorizontalAlign(int nValue)
|
||||
}
|
||||
}
|
||||
|
||||
EHorizontalAlign GetHorizontalAlign(const HWP_STRING& sValue)
|
||||
{
|
||||
IF_STRING_IN_ENUM(RIGHT, sValue, EHorizontalAlign);
|
||||
ELSE_IF_STRING_IN_ENUM(CENTER, sValue, EHorizontalAlign);
|
||||
ELSE_IF_STRING_IN_ENUM(DISTRIBUTE, sValue, EHorizontalAlign);
|
||||
ELSE_IF_STRING_IN_ENUM(DISTRIBUTE_SPACE, sValue, EHorizontalAlign);
|
||||
ELSE_IF_STRING_IN_ENUM(JUSTIFY, sValue, EHorizontalAlign);
|
||||
ELSE_STRING_IN_ENUM(LEFT, EHorizontalAlign);
|
||||
}
|
||||
|
||||
EVerticalAlign GetVerticalAlign(int nValue)
|
||||
{
|
||||
SWITCH(EVerticalAlign, nValue)
|
||||
@ -37,6 +55,14 @@ EVerticalAlign GetVerticalAlign(int nValue)
|
||||
}
|
||||
}
|
||||
|
||||
EVerticalAlign GetVerticalAlign(const HWP_STRING& sValue)
|
||||
{
|
||||
IF_STRING_IN_ENUM(CENTER, sValue, EVerticalAlign);
|
||||
ELSE_IF_STRING_IN_ENUM(BOTTOM, sValue, EVerticalAlign);
|
||||
ELSE_IF_STRING_IN_ENUM(BASELINE, sValue, EVerticalAlign);
|
||||
ELSE_STRING_IN_ENUM(TOP, EVerticalAlign);
|
||||
}
|
||||
|
||||
CHWPRecordParaShape::CHWPRecordParaShape(CHWPDocInfo& oDocInfo, int nTagNum, int nLevel, int nSize, CHWPStream& oBuffer, int nOff, int nVersion)
|
||||
: CHWPRecord(nTagNum, nLevel, nSize), m_pParent(&oDocInfo)
|
||||
{
|
||||
@ -125,12 +151,12 @@ void CHWPRecordParaShape::RecursiveParaShape(CXMLNode& oNode)
|
||||
{
|
||||
if (L"hh:align" == oNode.GetName())
|
||||
{
|
||||
m_eAlign = ::HWP::GetHorizontalAlign(oNode.GetAttributeInt(L"horizontal"));
|
||||
m_eVertAlign = ::HWP::GetVerticalAlign(oNode.GetAttributeInt(L"vertical"));
|
||||
m_eAlign = ::HWP::GetHorizontalAlign(oNode.GetAttribute(L"horizontal"));
|
||||
m_eVertAlign = ::HWP::GetVerticalAlign(oNode.GetAttribute(L"vertical"));
|
||||
}
|
||||
else if (L"hh:heading" == oNode.GetName())
|
||||
{
|
||||
m_eHeadingType = ::HWP::GetHeadingType(oNode.GetAttributeInt(L"type"));
|
||||
m_eHeadingType = ::HWP::GetHeadingType(oNode.GetAttribute(L"type"));
|
||||
m_shHeadingIdRef = oNode.GetAttributeInt(L"idRef");
|
||||
m_chHeadingLevel = (HWP_BYTE)oNode.GetAttributeInt(L"level");
|
||||
}
|
||||
@ -262,6 +288,11 @@ int CHWPRecordParaShape::GetMarginNext() const
|
||||
return m_nMarginNext;
|
||||
}
|
||||
|
||||
int CHWPRecordParaShape::GetIndent() const
|
||||
{
|
||||
return m_nIndent;
|
||||
}
|
||||
|
||||
bool CHWPRecordParaShape::KeepWithNext() const
|
||||
{
|
||||
return m_bKeepWithNext;
|
||||
|
||||
@ -90,6 +90,8 @@ public:
|
||||
int GetMarginPrev() const;
|
||||
int GetMarginNext() const;
|
||||
|
||||
int GetIndent() const;
|
||||
|
||||
bool KeepWithNext() const;
|
||||
};
|
||||
}
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
#include "../Paragraph/CtrlGeneralShape.h"
|
||||
#include "../Paragraph/CtrlTable.h"
|
||||
#include "../Paragraph/CtrlEqEdit.h"
|
||||
#include "../Paragraph/CCtrlField.h"
|
||||
#include "../Paragraph/CtrlField.h"
|
||||
|
||||
#include <regex>
|
||||
|
||||
@ -38,7 +38,7 @@ LIST<CCtrl*> CHWPRecordParaText::Parse(int nTagNum, int nLevel, int nSize, CHWPS
|
||||
}
|
||||
|
||||
//TODO:: перейти на обычный проход по символам
|
||||
std::wregex oRegex(L"([\\u0000-\\u001f]|.{2}[\\u0000-\u0017]{4})"); // [\\u0000\\u000a\\u000d\\u0018-\\u001f]|[\\u0001\\u0002-\\u0009\\u000b-\\u000c\\u000e-\\u0017].{6}[\\u0001\\u0002-\\u0009\\u000b-\\u000c\\u000e-\\u0017]
|
||||
std::wregex oRegex(L"([\\u0000-\\u001f]|.{2}[\\u0000-\\u0017]{4})"); // [\\u0000\\u000a\\u000d\\u0018-\\u001f]|[\\u0001\\u0002-\\u0009\\u000b-\\u000c\\u000e-\\u0017].{6}[\\u0001\\u0002-\\u0009\\u000b-\\u000c\\u000e-\\u0017]
|
||||
std::wsregex_iterator itCurrent(sText.begin(), sText.end(), oRegex);
|
||||
std::wsregex_iterator itEnd = std::wsregex_iterator();
|
||||
|
||||
@ -51,7 +51,7 @@ LIST<CCtrl*> CHWPRecordParaText::Parse(int nTagNum, int nLevel, int nSize, CHWPS
|
||||
|
||||
#define UPDATE_CURRENT_TEXT() \
|
||||
do { \
|
||||
if (!sCurrentText.empty()) \
|
||||
if (!sCurrentText.empty() && (unsigned int)sCurrentText[0] > 0x001f) \
|
||||
{ \
|
||||
arParas.push_back(new CParaText(L"____", sCurrentText, nPrevIndex + 1)); \
|
||||
sCurrentText.clear(); \
|
||||
@ -133,7 +133,7 @@ LIST<CCtrl*> CHWPRecordParaText::Parse(int nTagNum, int nLevel, int nSize, CHWPS
|
||||
|
||||
//TODO:: Проверить
|
||||
HWP_STRING sInfo = sText.substr(itCurrent->position(), 2);
|
||||
std::wregex wrReplaceRegex(L"[\\x00-\\x20]+$");
|
||||
std::wregex wrReplaceRegex(L"[\\u0000-\\u0017]+$");
|
||||
sInfo = std::regex_replace(sInfo, wrReplaceRegex, L"");
|
||||
|
||||
HWP_STRING sType;
|
||||
@ -144,7 +144,7 @@ LIST<CCtrl*> CHWPRecordParaText::Parse(int nTagNum, int nLevel, int nSize, CHWPS
|
||||
sType[2] = (sInfo[1] & 0xFF);
|
||||
sType[3] = ((sInfo[1] >> 8) & 0xFF);
|
||||
|
||||
if (0x00 == sType[3])
|
||||
if (0x17 >= sType[3])
|
||||
sType[3] = L' ';
|
||||
|
||||
//TODO:: более подробно разобраться в данном моменте
|
||||
@ -170,8 +170,10 @@ LIST<CCtrl*> CHWPRecordParaText::Parse(int nTagNum, int nLevel, int nSize, CHWPS
|
||||
arParas.push_back(new CCtrlTable(sType));
|
||||
else if (L"deqe" == sType)
|
||||
arParas.push_back(new CCtrlEqEdit(sType));
|
||||
else if (L"klh%" == sType ||
|
||||
L"klh " == sType)
|
||||
else if (L"klh%" == sType || // hyperlink start
|
||||
L"klh " == sType || // hyperlink end
|
||||
L"kmb%" == sType || // bookmark start
|
||||
L"kmb " == sType) // bookmark end
|
||||
arParas.push_back(new CCtrlField(sType));
|
||||
}
|
||||
|
||||
@ -183,7 +185,7 @@ LIST<CCtrl*> CHWPRecordParaText::Parse(int nTagNum, int nLevel, int nSize, CHWPS
|
||||
sCurrentText += sText.substr(nPrevIndex);
|
||||
|
||||
if (!sCurrentText.empty())
|
||||
arParas.push_back(new CParaText(L"____", sCurrentText, nPrevIndex));
|
||||
arParas.push_back(new CParaText(L"____", sCurrentText, nPrevIndex + 1));
|
||||
|
||||
oBuffer.Skip(nSize - oBuffer.GetDistanceToLastPos(true));
|
||||
return arParas;
|
||||
|
||||
@ -4,6 +4,12 @@
|
||||
#include "../OfficeUtils/src/OfficeUtils.h"
|
||||
#include "../DesktopEditor/common/Directory.h"
|
||||
|
||||
// For decrypt
|
||||
#include "../../Common/3dParty/cryptopp/modes.h"
|
||||
#include "../../Common/3dParty/cryptopp/aes.h"
|
||||
#include "../../Common/3dParty/cryptopp/filters.h"
|
||||
// ----------
|
||||
|
||||
#define DEFAULT_BUFFER_SIZE 8096
|
||||
|
||||
namespace HWP
|
||||
@ -67,7 +73,7 @@ bool CHWPFile::Open()
|
||||
if (!m_oFileHeader.Distributable() && !GetBodyText(m_nVersion))
|
||||
return false;
|
||||
|
||||
if (!m_oFileHeader.Distributable() && !GetViewText(m_nVersion))
|
||||
if (m_oFileHeader.Distributable() && !GetViewText(m_nVersion))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
@ -115,35 +121,7 @@ bool CHWPFile::GetComponent(const HWP_STRING& sEntryName, CHWPStream& oBuffer)
|
||||
{
|
||||
return m_oOleFile.GetComponent(sEntryName, oBuffer);
|
||||
}
|
||||
|
||||
//TODO:: написанно, что данные методы используются только для отображения в LibbreOffice
|
||||
// проверить и если нужны будут, то реализовать
|
||||
VECTOR<CDirectoryEntry*> CHWPFile::GetBinData()
|
||||
{
|
||||
return VECTOR<CDirectoryEntry*>();
|
||||
}
|
||||
|
||||
void CHWPFile::SetBinData(const std::vector<CDirectoryEntry*>& arBinData)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
VECTOR<CHWPPargraph*> CHWPFile::GetParas()
|
||||
{
|
||||
return VECTOR<CHWPPargraph*>();
|
||||
}
|
||||
|
||||
void CHWPFile::AddParas(const std::vector<CHWPPargraph*>& arParas)
|
||||
{
|
||||
|
||||
}
|
||||
//------------
|
||||
|
||||
void CHWPFile::SaveChildEntries(const HWP_STRING& sBasePath, const HWP_STRING& sStorageName, ECompressed eCompressed)
|
||||
{
|
||||
// TODO:: перенести
|
||||
}
|
||||
|
||||
CDirectoryEntry* CHWPFile::FindChildEntry(const HWP_STRING& sBasePath, const CDirectoryEntry& oBaseEntry, const HWP_STRING& sEntryName) const
|
||||
{
|
||||
for (CDirectoryEntry* pEntry : m_oOleFile.GetChildEntries(&oBaseEntry))
|
||||
@ -303,6 +281,24 @@ bool CHWPFile::Unzip(CHWPStream& oInput, CHWPStream& oBuffer)
|
||||
return DEFLATE_OK == nRes || DEFLATE_STREAM_END == nRes;
|
||||
}
|
||||
|
||||
// Так как на всех ОС необходимо одинаковое поведение,
|
||||
// то используем свой рандомайзер
|
||||
|
||||
class CRandomizer
|
||||
{
|
||||
uint32_t m_unSeed;
|
||||
public:
|
||||
CRandomizer(uint32_t unSeed)
|
||||
: m_unSeed(unSeed)
|
||||
{}
|
||||
|
||||
int rand()
|
||||
{
|
||||
m_unSeed = m_unSeed * 214013L + 2531011L;
|
||||
return (m_unSeed >> 16) & 0x7fff;
|
||||
}
|
||||
};
|
||||
|
||||
bool CHWPFile::Decrypt(CHWPStream& oInput, CHWPStream& oBuffer)
|
||||
{
|
||||
int nHeader;
|
||||
@ -320,8 +316,43 @@ bool CHWPFile::Decrypt(CHWPStream& oInput, CHWPStream& oBuffer)
|
||||
if (256 != nSize)
|
||||
return false;
|
||||
|
||||
//TODO:: реализовать
|
||||
return false;
|
||||
CHWPStream oDocData(256);
|
||||
oDocData.Copy(oInput, 256);
|
||||
oInput.Skip(256);
|
||||
|
||||
int nSeed;
|
||||
oDocData.ReadInt(nSeed);
|
||||
oDocData.Skip(-4);
|
||||
|
||||
CRandomizer oRandomizer(nSeed);
|
||||
|
||||
unsigned char chKey;
|
||||
|
||||
for (unsigned int unIndex = 0, unCount = 0; unIndex < 256; ++unIndex)
|
||||
{
|
||||
if (0 == unCount)
|
||||
{
|
||||
chKey = oRandomizer.rand() & 0xFF;
|
||||
unCount = (oRandomizer.rand() & 0xF) + 1;
|
||||
}
|
||||
if (unIndex >= 4)
|
||||
*(oDocData.GetCurPtr() + unIndex) = oDocData[unIndex] ^ chKey;
|
||||
|
||||
--unCount;
|
||||
}
|
||||
|
||||
int nHashOffset = (nSeed & 0x0f) + 4;
|
||||
|
||||
oBuffer.Expand(oInput.SizeToEnd());
|
||||
|
||||
using namespace CryptoPP;
|
||||
|
||||
ECB_Mode<AES>::Decryption oDecryptor;
|
||||
oDecryptor.SetKey((byte*)(oDocData.GetCurPtr() + nHashOffset), 16);
|
||||
|
||||
ArraySource((byte*)oInput.GetCurPtr(), oInput.SizeToEnd(), true, new StreamTransformationFilter(oDecryptor, new ArraySink( (byte*)oBuffer.GetCurPtr(), oBuffer.GetSize()), StreamTransformationFilter::NO_PADDING));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CHWPFile::GetBodyText(int nVersion)
|
||||
|
||||
@ -32,13 +32,8 @@ public:
|
||||
const CHWPDocInfo* GetDocInfo() const;
|
||||
bool GetDocInfo(int nVersion);
|
||||
bool GetComponent(const HWP_STRING& sEntryName, CHWPStream& oBuffer);
|
||||
VECTOR<CDirectoryEntry*> GetBinData();
|
||||
void SetBinData(const VECTOR<CDirectoryEntry*>& arBinData);
|
||||
VECTOR<CHWPPargraph*> GetParas();
|
||||
void AddParas(const VECTOR<CHWPPargraph*>& arParas);
|
||||
bool GetChildStream(const HWP_STRING& sEntryName, ECompressed eCompressed, CHWPStream& oBuffer);
|
||||
private:
|
||||
void SaveChildEntries(const HWP_STRING& sBasePath, const HWP_STRING& sStorageName, ECompressed eCompressed);
|
||||
CDirectoryEntry* FindChildEntry(const HWP_STRING& sBasePath, const CDirectoryEntry& oBaseEntry, const HWP_STRING& sEntryName) const;
|
||||
HWP_STRING SaveChildEntry(const HWP_STRING& sRootPath, const HWP_STRING& sEntryName, ECompressed eCompressed);
|
||||
|
||||
|
||||
@ -529,8 +529,6 @@ int CHWPSection::ParseCtrlRecurse(CCtrl* pCurrCtrl, int nRunLevel, CHWPStream& o
|
||||
ParseRecurse(pNewPara, nLevel, oBuffer, 0, nVersion);
|
||||
}
|
||||
else if (ECtrlObjectType::Shape == pCtrl->GetCtrlType())
|
||||
// else if (nullptr != dynamic_cast<CCtrlShapeRect*>(pCtrl) ||
|
||||
// nullptr != dynamic_cast<CCtrlGeneralShape*>(pCtrl))
|
||||
{
|
||||
CCtrlCommon* pCtrlCommon = (CCtrlCommon*)pCtrl;
|
||||
oBuffer.Skip(-6);
|
||||
@ -573,7 +571,6 @@ int CHWPSection::ParseCtrlRecurse(CCtrl* pCurrCtrl, int nRunLevel, CHWPStream& o
|
||||
case HWPTAG_SHAPE_COMPONENT_TEXTART:
|
||||
case HWPTAG_SHAPE_COMPONENT_UNKNOWN:
|
||||
{
|
||||
// if (nullptr != dynamic_cast<CCtrlGeneralShape*>(pCtrl))
|
||||
if (ECtrlObjectType::Shape == pCtrl->GetCtrlType())
|
||||
ParseCtrlRecurse((CCtrlGeneralShape*)pCtrl, nLevel, oBuffer, 0, nVersion);
|
||||
else
|
||||
@ -856,6 +853,8 @@ int CHWPSection::ParseCtrlRecurse(CCtrl* pCurrCtrl, int nRunLevel, CHWPStream& o
|
||||
}
|
||||
}
|
||||
|
||||
oBuffer.RemoveLastSavedPos();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -895,6 +894,7 @@ int CHWPSection::ParseContainerRecurse(CCtrlContainer* pContainer, int nRunLevel
|
||||
while (oBuffer.CanRead())
|
||||
{
|
||||
oBuffer.ReadInt(nHeader);
|
||||
oBuffer.Skip(-4);
|
||||
nTagNum = nHeader & 0x3FF; // 10 bits (0 - 9 bit)
|
||||
nLevel = (nHeader & 0xFFC00) >> 10; // 10 bits (10-19 bit)
|
||||
nSize = (nHeader & 0xFFF00000) >> 20; // 12 bits (20-31 bit)
|
||||
@ -979,7 +979,6 @@ int CHWPSection::ParseContainerRecurse(CCtrlContainer* pContainer, int nRunLevel
|
||||
{
|
||||
CCtrlGeneralShape* pCtrl = pContainer->GetLastShape();
|
||||
int nSubParaCount = CHWPRecordListHeader::GetCount(nTagNum, nLevel, nSize, oBuffer, 0, nVersion);
|
||||
oBuffer.Skip(6);
|
||||
|
||||
if (EShapeType::Rect == pCtrl->GetShapeType() || EShapeType::Polygon == pCtrl->GetShapeType())
|
||||
{
|
||||
|
||||
@ -36,6 +36,11 @@ void CHWPStream::Clear()
|
||||
m_arSavedPositions.pop();
|
||||
}
|
||||
|
||||
void CHWPStream::Copy(CHWPStream& oStream, unsigned long ulSize)
|
||||
{
|
||||
memcpy(m_pCur, oStream.GetCurPtr(), (std::min)(SizeToEnd(), (unsigned long)(std::min)(ulSize, oStream.SizeToEnd())));
|
||||
}
|
||||
|
||||
void CHWPStream::SetStream(HWP_BYTE* pBuffer, unsigned long ulSize, bool bExternalBuffer)
|
||||
{
|
||||
m_pBegin = pBuffer;
|
||||
|
||||
@ -28,6 +28,7 @@ public:
|
||||
~CHWPStream();
|
||||
|
||||
void Clear();
|
||||
void Copy(CHWPStream& oStream, unsigned long ulSize);
|
||||
|
||||
void SetStream(HWP_BYTE* pBuffer, unsigned long ulSize, bool bExternalBuffer = true);
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user