mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-03-31 10:21:37 +08:00
Compare commits
337 Commits
v99.99.99.
...
fix/bug-68
| Author | SHA1 | Date | |
|---|---|---|---|
| fcd7818675 | |||
| 6d707ebae2 | |||
| 41dc23ce53 | |||
| a817cd54d5 | |||
| f5ddf8c6ce | |||
| 29355d337b | |||
| 8c6a26895b | |||
| 0154543b01 | |||
| 3e2dee5719 | |||
| c25f8cc204 | |||
| d3aae6dfcb | |||
| 03463ee0e4 | |||
| 32cfb4f71b | |||
| 243cc43771 | |||
| a90422c3a7 | |||
| 16e7528cff | |||
| 8be104e3c1 | |||
| fbcb387f51 | |||
| 4754569381 | |||
| 44948c850e | |||
| 3163177b89 | |||
| 66513e895f | |||
| 8bcf2ee154 | |||
| 7d9e756f3f | |||
| b2d28a7185 | |||
| 1a62f01cf7 | |||
| b518d5642f | |||
| e9dcafed07 | |||
| 9bd79e2752 | |||
| 77f363f737 | |||
| 3a866d2f55 | |||
| 0d148f0efa | |||
| c741cc4bba | |||
| c58203cdc1 | |||
| e56f807826 | |||
| ef3a93cb13 | |||
| fa55bd4c95 | |||
| 62a4de7a1d | |||
| a85d77b493 | |||
| 57b2cc5436 | |||
| 5894736c2a | |||
| fa407297c7 | |||
| 3d77b1d8c6 | |||
| fc2aca59aa | |||
| e2021faa33 | |||
| 9a4dd96072 | |||
| 3e9afa1d15 | |||
| 1c9e394549 | |||
| f8a901e2d0 | |||
| 59cd16f300 | |||
| b063c4af35 | |||
| 9f50c9d660 | |||
| e16972f410 | |||
| 77855a12e9 | |||
| cc8c771f61 | |||
| 31e5d626ca | |||
| 5067d33c84 | |||
| 6b3173e65f | |||
| 65fc2852ec | |||
| 0385087f98 | |||
| 366b122c51 | |||
| f7110040b1 | |||
| adc9445231 | |||
| a49951f392 | |||
| 3963f1fcef | |||
| 41e0b5fe83 | |||
| 5caf111308 | |||
| 7e7265827d | |||
| 65829b6e96 | |||
| e10aa90618 | |||
| 5210ffbd50 | |||
| 9b45589937 | |||
| 9c9ac53475 | |||
| d70c26f5ce | |||
| 6070cd54e2 | |||
| 5fd6709d04 | |||
| 0424b92b04 | |||
| 923f39fada | |||
| 6b6118ffcc | |||
| 84de7e98be | |||
| 906aace0df | |||
| 3fbb430b7f | |||
| c2de8a822a | |||
| 490180dbba | |||
| d928151fdb | |||
| c63a8adbb3 | |||
| a7e647d58a | |||
| b7062837c8 | |||
| f7a46174ad | |||
| 992bc0095f | |||
| bf67498f3e | |||
| c4676f1b28 | |||
| b4c9184a0d | |||
| 748b5d061b | |||
| ea15b54837 | |||
| 9d19af8749 | |||
| 05cef3635c | |||
| 1b03e3e71f | |||
| d15d681659 | |||
| 58189602cc | |||
| 6fd19e7618 | |||
| dbfdfcb202 | |||
| 801b5e604e | |||
| cb34481460 | |||
| a1ff4a8de2 | |||
| d82f9a4d7a | |||
| 6d9d709183 | |||
| 3f317a6d1f | |||
| c2c085f57d | |||
| 5719444c94 | |||
| 2c5d36d618 | |||
| 36d8b8afe9 | |||
| 0f6cd18603 | |||
| 32c22eee70 | |||
| cea739dc2c | |||
| 4a769c1faa | |||
| a77f612973 | |||
| 198e878eb5 | |||
| 0942bc78ab | |||
| ca53d3d035 | |||
| a4f271d7b0 | |||
| c99b304ec2 | |||
| 1b032f3d74 | |||
| db57d253d9 | |||
| b48909edaa | |||
| 1bfb055a50 | |||
| 149d3a2030 | |||
| 8bad09ea5a | |||
| 91656095fa | |||
| 9e89e48c07 | |||
| fe89b146d7 | |||
| 1c5bd6cbab | |||
| 8ba7535fc8 | |||
| 038fa50194 | |||
| c94a294317 | |||
| d220685cff | |||
| edae000326 | |||
| 2cbc83b389 | |||
| d05afa3106 | |||
| de56349019 | |||
| 821f9cacd0 | |||
| 4f38f17bd1 | |||
| 9f4a145b48 | |||
| eaa0bbf047 | |||
| e78391c68b | |||
| 109a5fe2b4 | |||
| a908c42910 | |||
| 36b7400e0e | |||
| a19bf4bedd | |||
| 8318535aae | |||
| 21f5e09237 | |||
| de9c51a2db | |||
| f42079a55f | |||
| 5e0b5b6e34 | |||
| 9b87eba66b | |||
| 09f2db26e0 | |||
| aa038179cc | |||
| c09d5197b7 | |||
| c6f616d42e | |||
| dcc208257e | |||
| cc369ffbcb | |||
| 93018caf09 | |||
| d80d6c4168 | |||
| 5360487954 | |||
| cd73ab58b1 | |||
| 1119fd4307 | |||
| 0769a5ed3b | |||
| 82ad23840f | |||
| 5cb971d600 | |||
| c66cb32dde | |||
| ab62a3ebcf | |||
| 04d3e94dcc | |||
| 1c4462e2e9 | |||
| 91dc5b8582 | |||
| e9cf55f8db | |||
| 43fc84e6ef | |||
| 5a8bd3f8ce | |||
| 84dda72a13 | |||
| 5819c36cee | |||
| b5b9d948b9 | |||
| 72ac94412d | |||
| 4125e698d6 | |||
| 7c2a95202c | |||
| c3527ad8d4 | |||
| 9fe692b048 | |||
| df66cbbca9 | |||
| d877278d8d | |||
| 41a4edb223 | |||
| 0979902167 | |||
| 20618403b6 | |||
| 131efd2eaa | |||
| 8871c785dd | |||
| 8bbdb30419 | |||
| 15370bcbce | |||
| 48c9a001dd | |||
| 6cb7e763d3 | |||
| 0d55fddd02 | |||
| 4dd15a8e80 | |||
| bd7914e7c7 | |||
| c7fa85602d | |||
| 809effa5df | |||
| 2f42eb6c42 | |||
| f5f3d2572e | |||
| 95476fc998 | |||
| c503044fc9 | |||
| 4bef318bd6 | |||
| 6546ae3fd9 | |||
| ac300f57a6 | |||
| c7a4edec03 | |||
| aaeb745ad3 | |||
| 0a85051119 | |||
| 85c60f172c | |||
| 7a9c57038e | |||
| 888f67dab2 | |||
| 87a9b92fea | |||
| 185be63b27 | |||
| 7cd7b03b89 | |||
| 3fe4c2ac21 | |||
| 776569ca81 | |||
| 7b264e940d | |||
| 160e99ab90 | |||
| 6988009971 | |||
| 66bed0e286 | |||
| 36aae7a6ab | |||
| 3f42678932 | |||
| 4bd0a53c9e | |||
| e9162eb230 | |||
| 44684c462e | |||
| 81be9c1c1f | |||
| 21451d83e4 | |||
| 21ec043636 | |||
| 83e6e5971c | |||
| aeb78a561e | |||
| 75c0dde6d2 | |||
| 2cb34822cd | |||
| e5c7a043be | |||
| b8cdfa9b36 | |||
| 7893197071 | |||
| f2bda6c81a | |||
| 3d2cb819d5 | |||
| b0b99dec3e | |||
| ddb544ce34 | |||
| f441ec5c35 | |||
| d7a8c30461 | |||
| e8bb81b88e | |||
| 99252cc950 | |||
| fee4394d3f | |||
| 744d90e655 | |||
| 5692732901 | |||
| 1aaec18152 | |||
| 266425e817 | |||
| 5b8549db9d | |||
| 8f0a4ebfc9 | |||
| 34f36cefc3 | |||
| 7ceefa54cb | |||
| e4188148ba | |||
| a92bf23081 | |||
| 1d9230b731 | |||
| d2b5299b99 | |||
| 29c8e185ca | |||
| 723e4713fd | |||
| 7e235780fc | |||
| cfbed19648 | |||
| 0e09d4ab7a | |||
| eb37cabb4e | |||
| 4b611b304b | |||
| c5e6fb69c8 | |||
| eebe3f321a | |||
| 925c40aa80 | |||
| b6741a504f | |||
| fedf33e2c2 | |||
| aed320e57a | |||
| caa34c540a | |||
| 44d76014bf | |||
| 7252d29579 | |||
| d620a53cd0 | |||
| df0528c69f | |||
| 49da36637d | |||
| 4e7ccd2506 | |||
| 2a5d7a78a3 | |||
| 52de014e14 | |||
| adea12d9f7 | |||
| 3a8601c354 | |||
| 86c994d0a0 | |||
| ba1597a8d5 | |||
| 84ecffa75e | |||
| 7a3815bc5f | |||
| 4d23382c92 | |||
| 8791f446b7 | |||
| e1c1ff3eb4 | |||
| 1830a1103a | |||
| 4957b61033 | |||
| 462556599f | |||
| 0796745158 | |||
| 6e6ffbf604 | |||
| c1f29d5317 | |||
| 4d4a67b15a | |||
| 258890352a | |||
| 62dbbc6d0d | |||
| 4085f58b09 | |||
| f28dc0a36a | |||
| 49a40fa841 | |||
| f9662752f7 | |||
| 7eb0892ab9 | |||
| edcd907749 | |||
| e1b13913ac | |||
| 9f3ab7cc29 | |||
| 229b263a9f | |||
| 028157d2ef | |||
| af4e0243d2 | |||
| 4de7ba4e52 | |||
| 70be48fec3 | |||
| c60ff31fd4 | |||
| 826d3fc678 | |||
| ec0ed4d2f0 | |||
| fff7f4e63f | |||
| 68c9d3cfa5 | |||
| 7e8e4586ca | |||
| bbb9165a99 | |||
| 17fe60ecdc | |||
| 9352721ec4 | |||
| e2df5a8ab0 | |||
| 8a86347eb6 | |||
| d6675bb981 | |||
| eba03f9833 | |||
| e7a462fb60 | |||
| aeb657ef25 | |||
| a9b225782d | |||
| b46df522e9 | |||
| c2eb402ebf | |||
| dabedf6121 | |||
| 4db56e4536 | |||
| 99224aecb9 | |||
| dd02c9594b | |||
| 894f88e475 | |||
| ba46a97bde | |||
| cabecb0116 |
@ -4,6 +4,7 @@ CORE_BOOST_LIBS = $$PWD/build/$$CORE_BUILDS_PLATFORM_PREFIX/lib
|
||||
core_ios:CONFIG += disable_enum_constexpr_conversion
|
||||
core_android:CONFIG += disable_enum_constexpr_conversion
|
||||
core_mac:CONFIG += disable_enum_constexpr_conversion
|
||||
core_linux_clang:CONFIG += disable_enum_constexpr_conversion
|
||||
|
||||
core_android {
|
||||
INCLUDEPATH += $$PWD/build/android/include
|
||||
|
||||
@ -49,6 +49,8 @@ namespace NSCSS
|
||||
if (!oElement.m_sId.empty())
|
||||
m_sId += L'+' + oElement.m_sId;
|
||||
|
||||
m_arParentsStyles.insert(oElement.m_arParentsStyles.begin(), oElement.m_arParentsStyles.end());
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -69,6 +71,8 @@ namespace NSCSS
|
||||
m_oDisplay = oElement.m_oDisplay;
|
||||
m_oTransform = oElement.m_oTransform;
|
||||
|
||||
m_arParentsStyles = oElement.m_arParentsStyles;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -109,7 +113,8 @@ namespace NSCSS
|
||||
bool CCompiledStyle::Empty() const
|
||||
{
|
||||
return m_oBackground.Empty() && m_oBorder.Empty() && m_oFont.Empty() &&
|
||||
m_oMargin.Empty() && m_oPadding.Empty() && m_oText.Empty() && m_oDisplay.Empty();
|
||||
m_oMargin.Empty() && m_oPadding.Empty() && m_oText.Empty() &&
|
||||
m_oDisplay.Empty() && m_oTransform.Empty();
|
||||
}
|
||||
|
||||
void CCompiledStyle::AddPropSel(const std::wstring& sProperty, const std::wstring& sValue, const unsigned int unLevel, const bool& bHardMode)
|
||||
@ -314,6 +319,7 @@ namespace NSCSS
|
||||
}
|
||||
//BORDER TOP
|
||||
CASE(L"border-top"):
|
||||
CASE(L"mso-border-top-alt"):
|
||||
{
|
||||
m_oBorder.SetTopSide(pPropertie.second, unLevel, bHardMode);
|
||||
break;
|
||||
@ -335,6 +341,7 @@ namespace NSCSS
|
||||
}
|
||||
//BORDER RIGHT
|
||||
CASE(L"border-right"):
|
||||
CASE(L"mso-border-right-alt"):
|
||||
{
|
||||
m_oBorder.SetRightSide(pPropertie.second, unLevel, bHardMode);
|
||||
break;
|
||||
@ -356,6 +363,7 @@ namespace NSCSS
|
||||
}
|
||||
//BORDER bottom
|
||||
CASE(L"border-bottom"):
|
||||
CASE(L"mso-border-bottom-alt"):
|
||||
{
|
||||
m_oBorder.SetBottomSide(pPropertie.second, unLevel, bHardMode);
|
||||
break;
|
||||
@ -377,6 +385,7 @@ namespace NSCSS
|
||||
}
|
||||
//BORDER LEFT
|
||||
CASE(L"border-left"):
|
||||
CASE(L"mso-border-left-alt"):
|
||||
{
|
||||
m_oBorder.SetLeftSide(pPropertie.second, unLevel, bHardMode);
|
||||
break;
|
||||
@ -521,7 +530,7 @@ namespace NSCSS
|
||||
{
|
||||
return m_sId;
|
||||
}
|
||||
|
||||
|
||||
bool CCompiledStyle::HaveThisParent(const std::wstring &wsParentName) const
|
||||
{
|
||||
return m_arParentsStyles.end() != m_arParentsStyles.find(wsParentName);
|
||||
|
||||
@ -1,9 +1,6 @@
|
||||
#ifndef CCOMPILEDSTYLE_H
|
||||
#define CCOMPILEDSTYLE_H
|
||||
|
||||
#include "CssCalculator_global.h"
|
||||
#include "ConstValues.h"
|
||||
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
@ -13,14 +13,9 @@ namespace NSCSS
|
||||
delete m_pInternal;
|
||||
}
|
||||
|
||||
CCompiledStyle CCssCalculator::GetCompiledStyle(const std::vector<CNode> &arSelectors) const
|
||||
bool CCssCalculator::CalculateCompiledStyle(std::vector<CNode>& arSelectors) const
|
||||
{
|
||||
return m_pInternal->GetCompiledStyle(arSelectors);
|
||||
}
|
||||
|
||||
bool CCssCalculator::GetCompiledStyle(CCompiledStyle &oStyle, const std::vector<CNode> &arSelectors) const
|
||||
{
|
||||
return m_pInternal->GetCompiledStyle(oStyle, arSelectors);
|
||||
return m_pInternal->CalculateCompiledStyle(arSelectors);
|
||||
}
|
||||
|
||||
std::wstring CCssCalculator::CalculateStyleId(const CNode& oNode)
|
||||
|
||||
@ -2,10 +2,8 @@
|
||||
#define CCSSCALCULATOR_H
|
||||
|
||||
#include "CssCalculator_global.h"
|
||||
#include "CCompiledStyle.h"
|
||||
#include "ConstValues.h"
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include "StyleProperties.h"
|
||||
#include "CNode.h"
|
||||
#include <vector>
|
||||
|
||||
namespace NSCSS
|
||||
@ -19,8 +17,7 @@ namespace NSCSS
|
||||
CCssCalculator();
|
||||
~CCssCalculator();
|
||||
|
||||
CCompiledStyle GetCompiledStyle(const std::vector<CNode> &arSelectors) const;
|
||||
bool GetCompiledStyle(CCompiledStyle& oStyle, const std::vector<CNode> &arSelectors) const;
|
||||
bool CalculateCompiledStyle(std::vector<CNode>& arSelectors) const;
|
||||
|
||||
std::wstring CalculateStyleId(const CNode& oNode);
|
||||
bool CalculatePageStyle(NSProperties::CPage& oPageData, const std::vector<CNode> &arSelectors);
|
||||
|
||||
@ -2,8 +2,6 @@
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <fstream>
|
||||
#include <cmath>
|
||||
#include <algorithm>
|
||||
#include <numeric>
|
||||
|
||||
@ -488,6 +486,80 @@ namespace NSCSS
|
||||
{}
|
||||
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
bool CCssCalculator_Private::CalculateCompiledStyle(std::vector<CNode>& arSelectors)
|
||||
{
|
||||
if (arSelectors.empty())
|
||||
return false;
|
||||
|
||||
const std::map<std::vector<CNode>, CCompiledStyle>::iterator oItem = m_mUsedStyles.find(arSelectors);
|
||||
|
||||
if (oItem != m_mUsedStyles.end())
|
||||
{
|
||||
arSelectors.back().SetCompiledStyle(new CCompiledStyle(oItem->second));
|
||||
return true;
|
||||
}
|
||||
|
||||
arSelectors.back().m_pCompiledStyle->SetDpi(m_nDpi);
|
||||
unsigned int unStart = 0;
|
||||
|
||||
std::vector<CNode>::const_reverse_iterator itFound = std::find_if(arSelectors.crbegin(), arSelectors.crend(), [](const CNode& oNode){ return !oNode.m_pCompiledStyle->Empty(); });
|
||||
|
||||
if (itFound != arSelectors.crend())
|
||||
unStart = itFound.base() - arSelectors.cbegin();
|
||||
|
||||
std::vector<std::wstring> arNodes = CalculateAllNodes(arSelectors, unStart);
|
||||
std::vector<std::wstring> arPrevNodes;
|
||||
bool bInTable = false;
|
||||
|
||||
for (size_t i = 0; i < unStart; ++i)
|
||||
{
|
||||
if (!bInTable)
|
||||
bInTable = IsTableElement(arSelectors[i].m_wsName);
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
for (size_t i = unStart; i < arSelectors.size(); ++i)
|
||||
{
|
||||
if (0 != i)
|
||||
*arSelectors[i].m_pCompiledStyle += *arSelectors[i - 1].m_pCompiledStyle;
|
||||
|
||||
arSelectors[i].m_pCompiledStyle->AddParent(arSelectors[i].m_wsName);
|
||||
|
||||
if (!bInTable)
|
||||
bInTable = IsTableElement(arSelectors[i].m_wsName);
|
||||
|
||||
if (bInTable)
|
||||
{
|
||||
arSelectors[i].m_pCompiledStyle->m_oBackground.Clear();
|
||||
arSelectors[i].m_pCompiledStyle->m_oBorder.Clear();
|
||||
}
|
||||
|
||||
arSelectors[i].m_pCompiledStyle->AddStyle(arSelectors[i].m_mAttributes, i + 1);
|
||||
|
||||
for (const CElement* oElement : FindElements(arNodes, arPrevNodes))
|
||||
arSelectors[i].m_pCompiledStyle->AddStyle(oElement->GetStyle(), i + 1);
|
||||
|
||||
if (!arSelectors[i].m_wsStyle.empty())
|
||||
arSelectors[i].m_pCompiledStyle->AddStyle(arSelectors[i].m_wsStyle, i + 1, true);
|
||||
|
||||
// Скидываем некоторые внешние стили, которые внутри таблицы переопределяются
|
||||
if (bInTable && i < arSelectors.size() - 1)
|
||||
{
|
||||
arSelectors[i].m_pCompiledStyle->m_oFont.GetLineHeight().Clear();
|
||||
arSelectors[i].m_pCompiledStyle->m_oPadding.Clear();
|
||||
arSelectors[i].m_pCompiledStyle->m_oMargin.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
arSelectors.back().m_pCompiledStyle->SetID(CalculateStyleId(arSelectors.back()));
|
||||
|
||||
if (!arSelectors.back().m_pCompiledStyle->Empty())
|
||||
m_mUsedStyles[arSelectors] = *arSelectors.back().m_pCompiledStyle;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CCssCalculator_Private::SetPageData(NSProperties::CPage &oPage, const std::map<std::wstring, std::wstring> &mData, unsigned int unLevel, bool bHardMode)
|
||||
{
|
||||
//TODO:: пересмотреть данный метод
|
||||
@ -505,11 +577,11 @@ namespace NSCSS
|
||||
}
|
||||
#endif
|
||||
|
||||
std::vector<std::wstring> CCssCalculator_Private::CalculateAllNodes(const std::vector<CNode> &arSelectors)
|
||||
std::vector<std::wstring> CCssCalculator_Private::CalculateAllNodes(const std::vector<CNode> &arSelectors, unsigned int unStart)
|
||||
{
|
||||
std::vector<std::wstring> arNodes;
|
||||
|
||||
for (std::vector<CNode>::const_reverse_iterator oNode = arSelectors.rbegin(); oNode != arSelectors.rend(); ++oNode)
|
||||
for (std::vector<CNode>::const_reverse_iterator oNode = arSelectors.rbegin(); oNode != arSelectors.rend() - unStart; ++oNode)
|
||||
{
|
||||
if (!oNode->m_wsName.empty())
|
||||
arNodes.push_back(oNode->m_wsName);
|
||||
@ -631,79 +703,6 @@ namespace NSCSS
|
||||
}
|
||||
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
CCompiledStyle CCssCalculator_Private::GetCompiledStyle(const std::vector<CNode>& arSelectors)
|
||||
{
|
||||
if (arSelectors.empty())
|
||||
return CCompiledStyle();
|
||||
|
||||
CCompiledStyle oStyle;
|
||||
|
||||
GetCompiledStyle(oStyle, arSelectors);
|
||||
|
||||
return oStyle;
|
||||
}
|
||||
|
||||
bool CCssCalculator_Private::GetCompiledStyle(CCompiledStyle &oStyle, const std::vector<CNode> &arSelectors)
|
||||
{
|
||||
if (arSelectors.empty())
|
||||
return false;
|
||||
|
||||
const std::map<std::vector<CNode>, CCompiledStyle>::iterator oItem = m_mUsedStyles.find(arSelectors);
|
||||
|
||||
if (oItem != m_mUsedStyles.end())
|
||||
{
|
||||
oStyle = oItem->second;
|
||||
return true;
|
||||
}
|
||||
|
||||
oStyle.SetDpi(m_nDpi);
|
||||
|
||||
std::vector<std::wstring> arNodes = CalculateAllNodes(arSelectors);
|
||||
std::vector<std::wstring> arPrevNodes;
|
||||
bool bInTable = false;
|
||||
|
||||
for (size_t i = 0; i < arSelectors.size(); ++i)
|
||||
{
|
||||
oStyle.AddParent(arSelectors[i].m_wsName);
|
||||
|
||||
if (!bInTable)
|
||||
bInTable = IsTableElement(arSelectors[i].m_wsName);
|
||||
|
||||
if (bInTable)
|
||||
{
|
||||
oStyle.m_oBackground.Clear();
|
||||
oStyle.m_oBorder.Clear();
|
||||
}
|
||||
|
||||
CCompiledStyle oTempStyle;
|
||||
|
||||
oTempStyle.AddStyle(arSelectors[i].m_mAttributes, i + 1);
|
||||
|
||||
for (const CElement* oElement : FindElements(arNodes, arPrevNodes))
|
||||
oTempStyle.AddStyle(oElement->GetStyle(), i + 1);
|
||||
|
||||
if (!arSelectors[i].m_wsStyle.empty())
|
||||
oTempStyle.AddStyle(arSelectors[i].m_wsStyle, i + 1, true);
|
||||
|
||||
oStyle += oTempStyle;
|
||||
|
||||
// Скидываем некоторые внешние стили, которые внутри таблицы переопределяются
|
||||
if (bInTable && i < arSelectors.size() - 1)
|
||||
{
|
||||
oStyle.m_oFont.GetLineHeight().Clear();
|
||||
oStyle.m_oPadding.Clear();
|
||||
oStyle.m_oMargin.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
oStyle.SetID(CalculateStyleId(arSelectors.back()));
|
||||
|
||||
if (!oStyle.Empty())
|
||||
m_mUsedStyles[arSelectors] = oStyle;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
std::wstring CCssCalculator_Private::CalculateStyleId(const CNode& oNode)
|
||||
{
|
||||
return oNode.m_wsName + ((!oNode.m_wsClass.empty()) ? L'.' + oNode.m_wsClass : L"") + ((oNode.m_wsId.empty()) ? L"" : L'#' + oNode.m_wsId) + L'-' + std::to_wstring(++m_nCountNodes);
|
||||
@ -910,4 +909,11 @@ inline static std::wstring StringifyValue(const KatanaValue* oValue)
|
||||
return str;
|
||||
}
|
||||
|
||||
inline static bool IsTableElement(const std::wstring& wsNameTag)
|
||||
{
|
||||
return L"td" == wsNameTag || L"tr" == wsNameTag || L"table" == wsNameTag ||
|
||||
L"tbody" == wsNameTag || L"thead" == wsNameTag || L"tfoot" == wsNameTag ||
|
||||
L"th" == wsNameTag;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -102,8 +102,7 @@ namespace NSCSS
|
||||
~CCssCalculator_Private();
|
||||
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
CCompiledStyle GetCompiledStyle(const std::vector<CNode> &arSelectors);
|
||||
bool GetCompiledStyle(CCompiledStyle& oStyle, const std::vector<CNode> &arSelectors);
|
||||
bool CalculateCompiledStyle(std::vector<CNode>& arSelectors);
|
||||
|
||||
std::wstring CalculateStyleId(const CNode& oNode);
|
||||
bool CalculatePageStyle(NSProperties::CPage& oPageData, const std::vector<CNode> &arSelectors);
|
||||
@ -111,7 +110,7 @@ namespace NSCSS
|
||||
void ClearPageData();
|
||||
#endif
|
||||
|
||||
std::vector<std::wstring> CalculateAllNodes(const std::vector<CNode>& arSelectors);
|
||||
std::vector<std::wstring> CalculateAllNodes(const std::vector<CNode>& arSelectors, unsigned int unStart = 0);
|
||||
std::vector<const CElement*> FindElements(std::vector<std::wstring>& arNodes, std::vector<std::wstring>& arNextNodes);
|
||||
|
||||
void AddStyles(const std::string& sStyle);
|
||||
|
||||
@ -1,19 +1,58 @@
|
||||
#include "CNode.h"
|
||||
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
#include "CCompiledStyle.h"
|
||||
#endif
|
||||
|
||||
namespace NSCSS
|
||||
{
|
||||
CNode::CNode()
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
: m_pCompiledStyle(new CCompiledStyle())
|
||||
#endif
|
||||
{}
|
||||
|
||||
CNode::CNode(const CNode& oNode)
|
||||
: m_wsName(oNode.m_wsName), m_wsClass(oNode.m_wsClass), m_wsId(oNode.m_wsId),
|
||||
m_wsStyle(oNode.m_wsStyle), m_mAttributes(oNode.m_mAttributes)
|
||||
{
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
m_pCompiledStyle = new CCompiledStyle();
|
||||
*m_pCompiledStyle = *oNode.m_pCompiledStyle;
|
||||
#endif
|
||||
}
|
||||
|
||||
CNode::CNode(const std::wstring& wsName, const std::wstring& wsClass, const std::wstring& wsId)
|
||||
: m_wsName(wsName), m_wsClass(wsClass), m_wsId(wsId)
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
, m_pCompiledStyle(new CCompiledStyle())
|
||||
#endif
|
||||
{}
|
||||
|
||||
CNode::~CNode()
|
||||
{
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
if (nullptr != m_pCompiledStyle)
|
||||
delete m_pCompiledStyle;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool CNode::Empty() const
|
||||
{
|
||||
return m_wsName.empty() && m_wsClass.empty() && m_wsId.empty() && m_wsStyle.empty();
|
||||
}
|
||||
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
void CNode::SetCompiledStyle(CCompiledStyle* pCompiledStyle)
|
||||
{
|
||||
if (nullptr != m_pCompiledStyle)
|
||||
delete m_pCompiledStyle;
|
||||
|
||||
m_pCompiledStyle = new CCompiledStyle();
|
||||
*m_pCompiledStyle = *pCompiledStyle;
|
||||
}
|
||||
#endif
|
||||
|
||||
void CNode::Clear()
|
||||
{
|
||||
m_wsName .clear();
|
||||
|
||||
@ -7,6 +7,9 @@
|
||||
|
||||
namespace NSCSS
|
||||
{
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
class CCompiledStyle;
|
||||
#endif
|
||||
class CNode
|
||||
{
|
||||
public:
|
||||
@ -16,12 +19,21 @@ namespace NSCSS
|
||||
std::wstring m_wsStyle; // Стиль тэга
|
||||
std::map<std::wstring, std::wstring> m_mAttributes; // Остальные аттрибуты тэга
|
||||
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
CCompiledStyle *m_pCompiledStyle;
|
||||
#endif
|
||||
public:
|
||||
CNode();
|
||||
CNode(const CNode& oNode);
|
||||
CNode(const std::wstring& wsName, const std::wstring& wsClass, const std::wstring& wsId);
|
||||
~CNode();
|
||||
|
||||
bool Empty() const;
|
||||
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
void SetCompiledStyle(CCompiledStyle* pCompiledStyle);
|
||||
#endif
|
||||
|
||||
void Clear();
|
||||
|
||||
std::vector<std::wstring> GetData() const;
|
||||
|
||||
@ -1328,7 +1328,6 @@ namespace NSCSS
|
||||
|
||||
// DISPLAY
|
||||
CDisplay::CDisplay()
|
||||
: m_oDisplay(L"inline", 0)
|
||||
{}
|
||||
|
||||
void CDisplay::Equation(CDisplay &oFirstDisplay, CDisplay &oSecondDisplay)
|
||||
|
||||
@ -22,10 +22,10 @@ namespace NSCSS
|
||||
: m_oStyle(oStyle), m_bIsPStyle(bIsPStyle)
|
||||
{}
|
||||
|
||||
bool CheckArrays(const std::vector<std::wstring>& arInitial, const std::set<std::wstring>& arFirst, const std::set<std::wstring>& arSecond)
|
||||
bool CheckArrays(const std::vector<std::wstring>& arInitial, const std::set<std::wstring>& arFirst, const std::set<std::wstring>& arSecond)
|
||||
{
|
||||
std::unordered_set<std::wstring> arInitialSet(arInitial.begin(), arInitial.end());
|
||||
|
||||
|
||||
std::vector<std::wstring> arCommonElements1;
|
||||
std::vector<std::wstring> arCommonElements2;
|
||||
|
||||
@ -470,9 +470,6 @@ namespace NSCSS
|
||||
|
||||
int nSpace{0};
|
||||
|
||||
if (NULL != pPadding && !pPadding->Empty() && !pPadding->Zero())
|
||||
nSpace = pPadding->ToInt(NSCSS::Point);
|
||||
|
||||
return L"w:val=\"" + wsStyle + L"\" w:sz=\"" + std::to_wstring(nWidth) + + L"\" w:space=\"" + std::to_wstring(nSpace) + L"\" w:color=\"" + wsColor + L"\"";
|
||||
}
|
||||
|
||||
@ -559,7 +556,7 @@ namespace NSCSS
|
||||
|
||||
if (oXmlElement.Empty())
|
||||
return false;
|
||||
|
||||
|
||||
m_sStyle += oXmlElement.GetPStyle(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -68,10 +68,10 @@ static std::wstring htmlToXhtml(std::string& sFileContent, bool bNeedConvert)
|
||||
{
|
||||
if (bNeedConvert)
|
||||
{ // Определение кодировки
|
||||
std::string sEncoding = NSStringFinder::FindPropety(sFileContent, "charset", {"="}, {";", "\\n", "\\r", " ", "\""}).m_sValue;
|
||||
std::string sEncoding = NSStringFinder::FindProperty(sFileContent, "charset", {"="}, {";", "\\n", "\\r", " ", "\""}).m_sValue;
|
||||
|
||||
if (sEncoding.empty())
|
||||
sEncoding = NSStringFinder::FindPropety(sFileContent, "encoding", {"="}, {";", "\\n", "\\r", " "}).m_sValue;
|
||||
sEncoding = NSStringFinder::FindProperty(sFileContent, "encoding", {"="}, {";", "\\n", "\\r", " "}).m_sValue;
|
||||
|
||||
if (!sEncoding.empty() && !NSStringFinder::Equals("utf-8", sEncoding))
|
||||
{
|
||||
@ -210,7 +210,7 @@ static void ReadMht(const std::string& sMhtContent, std::map<std::string, std::s
|
||||
NSStringFinder::TFoundedData<char> oData;
|
||||
|
||||
// Content-Type
|
||||
oData = NSStringFinder::FindPropety(sMhtContent, "content-type", {":"}, {";", "\\n", "\\r"});
|
||||
oData = NSStringFinder::FindProperty(sMhtContent, "content-type", {":"}, {";", "\\n", "\\r"});
|
||||
const std::string sContentType{oData.m_sValue};
|
||||
|
||||
if (sContentType.empty())
|
||||
@ -226,18 +226,18 @@ static void ReadMht(const std::string& sMhtContent, std::map<std::string, std::s
|
||||
unCharsetBegin = oData.m_unEndPosition;
|
||||
|
||||
// name
|
||||
// std::string sName = NSStringFinder::FindPropety(sMhtContent, "name", {"="}, {";", "\\n", "\\r"}, 0, unLastPosition);
|
||||
// std::string sName = NSStringFinder::FindProperty(sMhtContent, "name", {"="}, {";", "\\n", "\\r"}, 0, unLastPosition);
|
||||
// unContentPosition = std::max(unContentPosition, unLastPosition);
|
||||
|
||||
// Content-Location
|
||||
oData = NSStringFinder::FindPropety(sMhtContent, "content-location", {":"}, {";", "\\n", "\\r"});
|
||||
oData = NSStringFinder::FindProperty(sMhtContent, "content-location", {":"}, {";", "\\n", "\\r"});
|
||||
std::string sContentLocation{oData.m_sValue};
|
||||
|
||||
if (!oData.Empty())
|
||||
unContentPosition = std::max(unContentPosition, oData.m_unEndPosition);
|
||||
|
||||
// Content-ID
|
||||
oData = NSStringFinder::FindPropety(sMhtContent, "content-id", {":"}, {";", "\\n", "\\r"});
|
||||
oData = NSStringFinder::FindProperty(sMhtContent, "content-id", {":"}, {";", "\\n", "\\r"});
|
||||
std::string sContentID{oData.m_sValue};
|
||||
|
||||
if (!oData.Empty())
|
||||
@ -251,7 +251,7 @@ static void ReadMht(const std::string& sMhtContent, std::map<std::string, std::s
|
||||
sContentLocation = "cid:" + sContentID;
|
||||
|
||||
// Content-Transfer-Encoding
|
||||
oData = NSStringFinder::FindPropety(sMhtContent, "content-transfer-encoding", {":"}, {";", "\\n", "\\r"});
|
||||
oData = NSStringFinder::FindProperty(sMhtContent, "content-transfer-encoding", {":"}, {";", "\\n", "\\r"});
|
||||
const std::string sContentEncoding{oData.m_sValue};
|
||||
|
||||
if (!oData.Empty())
|
||||
@ -265,7 +265,7 @@ static void ReadMht(const std::string& sMhtContent, std::map<std::string, std::s
|
||||
|
||||
if (std::string::npos != unCharsetEnd && unCharsetBegin < unCharsetEnd)
|
||||
{
|
||||
sCharset = NSStringFinder::FindPropety(sMhtContent.substr(unCharsetBegin, unCharsetEnd - unCharsetBegin), "charset", {"="}, {";", "\\n", "\\r"}).m_sValue;
|
||||
sCharset = NSStringFinder::FindProperty(sMhtContent.substr(unCharsetBegin, unCharsetEnd - unCharsetBegin), "charset", {"="}, {";", "\\n", "\\r"}).m_sValue;
|
||||
NSStringFinder::CutInside<std::string>(sCharset, "\"");
|
||||
}
|
||||
|
||||
@ -337,7 +337,7 @@ static std::string mhtTohtml(const std::string& sFileContent)
|
||||
NSStringUtils::CStringBuilderA oRes;
|
||||
|
||||
// Поиск boundary
|
||||
NSStringFinder::TFoundedData<char> oData{NSStringFinder::FindPropety(sFileContent, "boundary", {"="}, {"\\r", "\\n", "\""})};
|
||||
NSStringFinder::TFoundedData<char> oData{NSStringFinder::FindProperty(sFileContent, "boundary", {"="}, {"\\r", "\\n", "\""})};
|
||||
|
||||
size_t nFound{oData.m_unEndPosition};
|
||||
std::string sBoundary{oData.m_sValue};
|
||||
@ -436,17 +436,17 @@ static void substitute_xml_entities_into_text(std::string& text)
|
||||
}
|
||||
|
||||
// After running through Gumbo, the values of type "" are replaced with the corresponding code '0x01'
|
||||
// Since the attribute value does not use control characters (value <= 0x1F),
|
||||
// Since the attribute value does not use control characters (value <= 0x09),
|
||||
// then just delete them, otherwise XmlUtils::CXmlLiteReader crashes on them.
|
||||
// bug#73486
|
||||
static void remove_control_symbols(std::string& text)
|
||||
{
|
||||
std::string::iterator itFound = std::find_if(text.begin(), text.end(), [](char chValue){ return chValue <= 0x1F; });
|
||||
std::string::iterator itFound = std::find_if(text.begin(), text.end(), [](unsigned char chValue){ return chValue <= 0x09; });
|
||||
|
||||
while (itFound != text.end())
|
||||
{
|
||||
itFound = text.erase(itFound);
|
||||
itFound = std::find_if(itFound, text.end(), [](char chValue){ return chValue <= 0x1F; });
|
||||
itFound = std::find_if(itFound, text.end(), [](unsigned char chValue){ return chValue <= 0x09; });
|
||||
}
|
||||
}
|
||||
|
||||
@ -489,6 +489,7 @@ static void build_doctype(GumboNode* node, NSStringUtils::CStringBuilderA& oBuil
|
||||
oBuilder.WriteString("<!DOCTYPE ");
|
||||
oBuilder.WriteString(node->v.document.name);
|
||||
std::string pi(node->v.document.public_identifier);
|
||||
remove_control_symbols(pi);
|
||||
if ((node->v.document.public_identifier != NULL) && !pi.empty())
|
||||
{
|
||||
oBuilder.WriteString(" PUBLIC \"");
|
||||
@ -509,6 +510,10 @@ static void build_attributes(const GumboVector* attribs, NSStringUtils::CStringB
|
||||
GumboAttribute* at = static_cast<GumboAttribute*>(attribs->data[i]);
|
||||
std::string sVal(at->value);
|
||||
std::string sName(at->name);
|
||||
|
||||
remove_control_symbols(sVal);
|
||||
remove_control_symbols(sName);
|
||||
|
||||
atts.WriteString(" ");
|
||||
|
||||
bool bCheck = false;
|
||||
@ -569,6 +574,7 @@ static void prettyprint_contents(GumboNode* node, NSStringUtils::CStringBuilderA
|
||||
if (child->type == GUMBO_NODE_TEXT)
|
||||
{
|
||||
std::string val(child->v.text.text);
|
||||
remove_control_symbols(val);
|
||||
substitute_xml_entities_into_text(val);
|
||||
|
||||
// Избавление от FF
|
||||
@ -608,6 +614,7 @@ static void prettyprint(GumboNode* node, NSStringUtils::CStringBuilderA& oBuilde
|
||||
}
|
||||
|
||||
std::string tagname = get_tag_name(node);
|
||||
remove_control_symbols(tagname);
|
||||
|
||||
if (NodeIsUnprocessed(tagname))
|
||||
return;
|
||||
|
||||
43
Common/3dParty/hunspell/autogen/generate.py
Normal file
43
Common/3dParty/hunspell/autogen/generate.py
Normal file
@ -0,0 +1,43 @@
|
||||
import os
|
||||
import glob
|
||||
import json
|
||||
import subprocess
|
||||
|
||||
curDirectory = os.path.dirname(os.path.realpath(__file__))
|
||||
dictionatiesDirectory = curDirectory + "/../../../../../dictionaries"
|
||||
|
||||
all_dictionaties = {}
|
||||
for dir in glob.glob(dictionatiesDirectory + "/*"):
|
||||
if not os.path.isdir(dir):
|
||||
continue
|
||||
dictionaryName = os.path.basename(dir)
|
||||
configFile = dictionatiesDirectory + "/" + dictionaryName + "/" + dictionaryName + ".json"
|
||||
if not os.path.isfile(configFile):
|
||||
continue
|
||||
isHyphen = False
|
||||
hyphenFile = dictionatiesDirectory + "/" + dictionaryName + "/hyph_" + dictionaryName + ".dic"
|
||||
if os.path.isfile(hyphenFile):
|
||||
isHyphen = True
|
||||
with open(configFile, 'r', encoding='utf-8') as file:
|
||||
data = json.loads(file.read())
|
||||
for lang in data["codes"]:
|
||||
all_dictionaties[str(lang)] = {
|
||||
"name": dictionaryName,
|
||||
"hyphen": isHyphen
|
||||
}
|
||||
|
||||
content = ""
|
||||
content += "#define DictionaryRec_count " + str(len(all_dictionaties)) + "\n"
|
||||
content += "typedef struct {\n"
|
||||
content += " const char* m_name;\n"
|
||||
content += " int m_lang;\n"
|
||||
content += "} DictionaryRec;\n\n"
|
||||
content += "static const DictionaryRec Dictionaries[DictionaryRec_count] = {\n"
|
||||
|
||||
for lang in all_dictionaties:
|
||||
info = all_dictionaties[lang]
|
||||
content += " { \"" + info["name"] + "\", " + str(lang) + " },\n"
|
||||
content += "};\n"
|
||||
|
||||
with open("./records.h", 'w', encoding='utf-8') as f:
|
||||
f.write(content)
|
||||
73
Common/3dParty/hunspell/autogen/records.h
Normal file
73
Common/3dParty/hunspell/autogen/records.h
Normal file
@ -0,0 +1,73 @@
|
||||
#define DictionaryRec_count 65
|
||||
typedef struct {
|
||||
const char* m_name;
|
||||
int m_lang;
|
||||
} DictionaryRec;
|
||||
|
||||
static const DictionaryRec Dictionaries[DictionaryRec_count] = {
|
||||
{ "ar", 1025 },
|
||||
{ "ar", 2049 },
|
||||
{ "ar", 3073 },
|
||||
{ "ar", 4097 },
|
||||
{ "ar", 5121 },
|
||||
{ "ar", 6145 },
|
||||
{ "ar", 7169 },
|
||||
{ "ar", 8193 },
|
||||
{ "ar", 9217 },
|
||||
{ "ar", 10241 },
|
||||
{ "ar", 11265 },
|
||||
{ "ar", 12289 },
|
||||
{ "ar", 13313 },
|
||||
{ "ar", 14337 },
|
||||
{ "ar", 15361 },
|
||||
{ "ar", 16385 },
|
||||
{ "az_Latn_AZ", 1068 },
|
||||
{ "bg_BG", 1026 },
|
||||
{ "ca_ES", 1027 },
|
||||
{ "ca_ES_valencia", 2051 },
|
||||
{ "cs_CZ", 1029 },
|
||||
{ "da_DK", 1030 },
|
||||
{ "de_AT", 3079 },
|
||||
{ "de_CH", 2055 },
|
||||
{ "de_DE", 1031 },
|
||||
{ "el_GR", 1032 },
|
||||
{ "en_AU", 3081 },
|
||||
{ "en_CA", 4105 },
|
||||
{ "en_GB", 2057 },
|
||||
{ "en_US", 1033 },
|
||||
{ "en_ZA", 7177 },
|
||||
{ "es_ES", 3082 },
|
||||
{ "eu_ES", 1069 },
|
||||
{ "fr_FR", 1036 },
|
||||
{ "gl_ES", 1110 },
|
||||
{ "hr_HR", 1050 },
|
||||
{ "hu_HU", 1038 },
|
||||
{ "id_ID", 1057 },
|
||||
{ "it_IT", 1040 },
|
||||
{ "kk_KZ", 1087 },
|
||||
{ "ko_KR", 1042 },
|
||||
{ "lb_LU", 1134 },
|
||||
{ "lt_LT", 1063 },
|
||||
{ "lv_LV", 1062 },
|
||||
{ "mn_MN", 1104 },
|
||||
{ "nb_NO", 1044 },
|
||||
{ "nl_NL", 1043 },
|
||||
{ "nl_NL", 2067 },
|
||||
{ "nn_NO", 2068 },
|
||||
{ "oc_FR", 1154 },
|
||||
{ "pl_PL", 1045 },
|
||||
{ "pt_BR", 1046 },
|
||||
{ "pt_PT", 2070 },
|
||||
{ "ro_RO", 1048 },
|
||||
{ "ru_RU", 1049 },
|
||||
{ "sk_SK", 1051 },
|
||||
{ "sl_SI", 1060 },
|
||||
{ "sr_Cyrl_RS", 10266 },
|
||||
{ "sr_Latn_RS", 9242 },
|
||||
{ "sv_SE", 1053 },
|
||||
{ "tr_TR", 1055 },
|
||||
{ "uk_UA", 1058 },
|
||||
{ "uz_Cyrl_UZ", 2115 },
|
||||
{ "uz_Latn_UZ", 1091 },
|
||||
{ "vi_VN", 1066 },
|
||||
};
|
||||
4
Common/3dParty/md/.gitignore
vendored
Normal file
4
Common/3dParty/md/.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
# Ignore everything in this directory
|
||||
md4c
|
||||
# Except this file
|
||||
!.gitignore
|
||||
13
Common/3dParty/md/fetch.py
Normal file
13
Common/3dParty/md/fetch.py
Normal file
@ -0,0 +1,13 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
sys.path.append('../../../../build_tools/scripts')
|
||||
import config
|
||||
import base
|
||||
import os
|
||||
|
||||
base_directory = os.getcwd()
|
||||
|
||||
if not base.is_dir("md4c"):
|
||||
base.cmd("git", ["clone", "https://github.com/mity/md4c.git"])
|
||||
base.cmd_in_dir("md4c", "git", ["checkout", "481fbfbdf72daab2912380d62bb5f2187d438408"])
|
||||
102
Common/3dParty/md/md2html.cpp
Normal file
102
Common/3dParty/md/md2html.cpp
Normal file
@ -0,0 +1,102 @@
|
||||
#include "md2html.h"
|
||||
|
||||
#include "md4c/src/md4c-html.h"
|
||||
#include "../../../DesktopEditor/common/File.h"
|
||||
|
||||
namespace Md
|
||||
{
|
||||
void ToHtml(const MD_CHAR* pValue, MD_SIZE uSize, void* pData)
|
||||
{
|
||||
if (NULL != pData)
|
||||
(*(std::string*)pData).append(pValue, uSize);
|
||||
}
|
||||
|
||||
std::string ConvertMdStringToHtml(const std::string& sMdString)
|
||||
{
|
||||
std::string sData;
|
||||
md_html(sMdString.c_str(), sMdString.length(), ToHtml, &sData, 0, 0);
|
||||
return sData;
|
||||
}
|
||||
|
||||
void ToHtmlFile(const MD_CHAR* pValue, MD_SIZE uSize, void* pData)
|
||||
{
|
||||
if (NULL != pData)
|
||||
((NSFile::CFileBinary*)pData)->WriteFile(pValue, uSize);
|
||||
}
|
||||
|
||||
void WriteBaseHtmlStyles(NSFile::CFileBinary& oFile)
|
||||
{
|
||||
oFile.WriteStringUTF8(L"<style>");
|
||||
|
||||
// Main styles
|
||||
oFile.WriteStringUTF8(L"* { font-family: Arial; }");
|
||||
oFile.WriteStringUTF8(L"p { margin: 0 0 10px; display: block; }");
|
||||
oFile.WriteStringUTF8(L"a { color: #0553c1; text-decoration: underline; } a:visited { color: #954f72; text-decoration: underline; }");
|
||||
oFile.WriteStringUTF8(L"ul { margin-top: 0; margin-bottom: 10px; }");
|
||||
oFile.WriteStringUTF8(L"img { vertical-align: middle; }");
|
||||
|
||||
// Styles for tables
|
||||
oFile.WriteStringUTF8(L"table { margin-bottom: 20px; width: 100%; max-width: 100%; border-spacing:0; border-collapse: collapse; border-color: gray;}");
|
||||
oFile.WriteStringUTF8(L"thead { display: table-header-group; vertical-align: middle; }");
|
||||
oFile.WriteStringUTF8(L"tr { display: table-row; }");
|
||||
oFile.WriteStringUTF8(L"th { text-align: left; display: table-cell; font-weight: bold; }");
|
||||
|
||||
oFile.WriteStringUTF8(L"table thead tr th { vertical-align: bottom; border-bottom: 2px solid #ddd; }");
|
||||
oFile.WriteStringUTF8(L"table thead tr th, table tbody tr th, table thead tr td, table tbody tr td { padding 8px; line-height: 1.4; vertical-align: top; border-top: 1px solid #ddd; }");
|
||||
oFile.WriteStringUTF8(L"table > caption + thead > tr > th, table > colgroup + thead > tr > th, table > thead > tr > th, table > caption + thead > tr > td, table > colgroup + thead > tr > td, table > thead > tr > td { border-top: 0; }");
|
||||
|
||||
// Styles for blockquote
|
||||
oFile.WriteStringUTF8(L"blockquote { border-left: 3px solid #e9e9e9; margin: 1.5em 0; padding: 0.5em 10px 0.5em 24px; font-size: 1.25rem; display: block; margin-top: 8pt; font-style: italic; color: #404040; }");
|
||||
|
||||
// Styles for code
|
||||
oFile.WriteStringUTF8(L"code { padding: 2px 4px; font-size: 90%; color: #c7254e; background-color: #f9f2f4; border-radius: 4px; }");
|
||||
oFile.WriteStringUTF8(L"pre code { padding: 0px; white-space: pre-wrap; background-color: transparent; border-radius: 0; color: inherit; }");
|
||||
oFile.WriteStringUTF8(L"pre { display: block; padding: 9.5px; margin: 0 0 10px; line-height: 1.4; word-break: break-all; word-wrap: break-word; background-color: #f5f5f5; border: 1px solid #ccc; border-radius: 4px; font-size: 1em; }");
|
||||
oFile.WriteStringUTF8(L"code, pre { font-family: Menlo, Monaco, Consolas, \"Courier New\", monospace; }");
|
||||
|
||||
|
||||
// Styles for headings
|
||||
oFile.WriteStringUTF8(L"h1 { font-size: 20pt; color: #0f4761; margin-top: 18pt; margin-bottom: 4pt; }");
|
||||
oFile.WriteStringUTF8(L"h2 { font-size: 16pt; color: #0f4761; margin-top: 8pt; margin-bottom: 4pt; }");
|
||||
oFile.WriteStringUTF8(L"h3 { font-size: 14pt; color: #0f4761; margin-top: 8pt; margin-bottom: 4pt; }");
|
||||
oFile.WriteStringUTF8(L"h4 { font-style: italic; color: #0f4761; margin-top: 4pt; margin-bottom: 2pt; }");
|
||||
oFile.WriteStringUTF8(L"h5 { color: #0f4761; margin-top: 4pt; margin-bottom: 2pt; }");
|
||||
oFile.WriteStringUTF8(L"h6 { font-style: italic; color: #595959; margin-top: 2pt; margin-bottom: 0; }");
|
||||
|
||||
oFile.WriteStringUTF8(L"</style>");
|
||||
}
|
||||
|
||||
bool ConvertMdFileToHtml(const std::wstring& wsPathToMdFile, const std::wstring& wsPathToHtmlFile)
|
||||
{
|
||||
std::string sMdData;
|
||||
|
||||
if (!NSFile::CFileBinary::ReadAllTextUtf8A(wsPathToMdFile, sMdData))
|
||||
return false;
|
||||
|
||||
NSFile::CFileBinary oFile;
|
||||
|
||||
if (!oFile.CreateFile(wsPathToHtmlFile))
|
||||
return false;
|
||||
|
||||
oFile.WriteStringUTF8(L"<html><body>");
|
||||
|
||||
oFile.WriteStringUTF8(L"<head>");
|
||||
WriteBaseHtmlStyles(oFile);
|
||||
oFile.WriteStringUTF8(L"</head>");
|
||||
|
||||
bool bResult = true;
|
||||
|
||||
if (0 != md_html(sMdData.c_str(), sMdData.length(), ToHtmlFile, &oFile, MD_DIALECT_GITHUB, 0))
|
||||
bResult = false;
|
||||
|
||||
oFile.WriteStringUTF8(L"</body></html>");
|
||||
|
||||
oFile.CloseFile();
|
||||
|
||||
if (!bResult)
|
||||
NSFile::CFileBinary::Remove(wsPathToHtmlFile);
|
||||
|
||||
return bResult;
|
||||
}
|
||||
}
|
||||
|
||||
19
Common/3dParty/md/md2html.h
Normal file
19
Common/3dParty/md/md2html.h
Normal file
@ -0,0 +1,19 @@
|
||||
#ifndef MD2HTML_H
|
||||
#define MD2HTML_H
|
||||
|
||||
#include <string>
|
||||
|
||||
#ifndef MDCONVERTER_DECL_EXPORT
|
||||
#define MDCONVERTER_DECL_EXPORT
|
||||
#else
|
||||
#include "../../../DesktopEditor/common/base_export.h"
|
||||
#define MDCONVERTER_DECL_EXPORT Q_DECL_EXPORT
|
||||
#endif
|
||||
|
||||
namespace Md
|
||||
{
|
||||
std::string MDCONVERTER_DECL_EXPORT ConvertMdStringToHtml(const std::string& sMdString);
|
||||
bool MDCONVERTER_DECL_EXPORT ConvertMdFileToHtml(const std::wstring& wsPathToMdFile, const std::wstring& wsPathToHtmlFile);
|
||||
}
|
||||
|
||||
#endif // MD2HTML_H
|
||||
11
Common/3dParty/md/md2html.pri
Normal file
11
Common/3dParty/md/md2html.pri
Normal file
@ -0,0 +1,11 @@
|
||||
DEFINES += MD4C_USE_UTF8
|
||||
|
||||
HEADERS += $$PWD/md4c/src/md4c.h \
|
||||
$$PWD/md4c/src/md4c-html.h \
|
||||
$$PWD/md4c/src/entity.h \
|
||||
$$PWD/md2html.h \
|
||||
|
||||
SOURCES += $$PWD/md4c/src/md4c.c \
|
||||
$$PWD/md4c/src/md4c-html.c \
|
||||
$$PWD/md4c/src/entity.c \
|
||||
$$PWD/md2html.cpp
|
||||
16
Common/3dParty/md/test/TestMd.pro
Normal file
16
Common/3dParty/md/test/TestMd.pro
Normal file
@ -0,0 +1,16 @@
|
||||
QT -= core
|
||||
QT -= gui
|
||||
|
||||
TARGET = test
|
||||
TEMPLATE = app
|
||||
|
||||
CONFIG += console
|
||||
CONFIG -= app_bundle
|
||||
|
||||
CORE_ROOT_DIR = $$PWD/../../../../
|
||||
|
||||
SOURCES += main.cpp
|
||||
|
||||
include($$CORE_ROOT_DIR/Common/3dParty/md/md2html.pri)
|
||||
|
||||
DESTDIR = $$PWD/build/$$CORE_BUILDS_PLATFORM_PREFIX
|
||||
1
Common/3dParty/md/test/files/file-1.md
Normal file
1
Common/3dParty/md/test/files/file-1.md
Normal file
@ -0,0 +1 @@
|
||||
* foo **bar [link](http://example.com) baz**
|
||||
10
Common/3dParty/md/test/main.cpp
Normal file
10
Common/3dParty/md/test/main.cpp
Normal file
@ -0,0 +1,10 @@
|
||||
#include <iostream>
|
||||
|
||||
#include "../md2html.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
std::cout << (ConvertMdFileToHtml(L"YOUR_PATH", L"YOUR_PATH") ? "Good" : "Bad") << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -109,4 +109,5 @@ public:
|
||||
bool isMobiFormatFile(unsigned char* pBuffer, int dwBytes);
|
||||
bool isFB2FormatFile(unsigned char* pBuffer, int dwBytes);
|
||||
bool isXpsFile(const std::wstring& fileName);
|
||||
bool isOFDFile(const std::wstring& fileName);
|
||||
};
|
||||
|
||||
@ -797,6 +797,13 @@ bool COfficeFileFormatChecker::isOfficeFile(const std::wstring &_fileName)
|
||||
bufferDetect = NULL;
|
||||
return true;
|
||||
}
|
||||
else if (isOFDFile(fileName))
|
||||
{
|
||||
if (bufferDetect)
|
||||
delete[] bufferDetect;
|
||||
bufferDetect = NULL;
|
||||
return true;
|
||||
}
|
||||
else if (isMacFormatFile(fileName))
|
||||
{
|
||||
if (bufferDetect)
|
||||
@ -930,6 +937,8 @@ bool COfficeFileFormatChecker::isOfficeFile(const std::wstring &_fileName)
|
||||
}
|
||||
else if (0 == sExt.compare(L".mht") || 0 == sExt.compare(L".mhtml"))
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_MHT;
|
||||
else if (0 == sExt.compare(L".md"))
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_MD;
|
||||
else if (0 == sExt.compare(L".csv") || 0 == sExt.compare(L".xls") || 0 == sExt.compare(L".xlsx") || 0 == sExt.compare(L".xlsb"))
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_CSV;
|
||||
else if (0 == sExt.compare(L".html") || 0 == sExt.compare(L".htm"))
|
||||
@ -938,7 +947,7 @@ bool COfficeFileFormatChecker::isOfficeFile(const std::wstring &_fileName)
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_CANVAS_PDF;
|
||||
else if (0 == sExt.compare(L".doct")) // случай архива с html viewer
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_TEAMLAB_DOCY;
|
||||
else if (0 == sExt.compare(L".txt") || 0 == sExt.compare(L".xml") || 0 == sExt.compare(L".rtf") || 0 == sExt.compare(L".doc") || 0 == sExt.compare(L".docx") || 0 == sExt.compare(L".md"))
|
||||
else if (0 == sExt.compare(L".txt") || 0 == sExt.compare(L".xml") || 0 == sExt.compare(L".rtf") || 0 == sExt.compare(L".doc") || 0 == sExt.compare(L".docx"))
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_TXT;
|
||||
else if (0 == sExt.compare(L".pages"))
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_PAGES;
|
||||
@ -1658,6 +1667,14 @@ std::wstring COfficeFileFormatChecker::GetExtensionByType(int type)
|
||||
return L".fodt";
|
||||
case AVS_OFFICESTUDIO_FILE_DOCUMENT_OTT:
|
||||
return L".ott";
|
||||
case AVS_OFFICESTUDIO_FILE_DOCUMENT_PAGES:
|
||||
return L".pages";
|
||||
case AVS_OFFICESTUDIO_FILE_DOCUMENT_HWP:
|
||||
return L".hwp";
|
||||
case AVS_OFFICESTUDIO_FILE_DOCUMENT_HWPX:
|
||||
return L".hwpx";
|
||||
case AVS_OFFICESTUDIO_FILE_DOCUMENT_MD:
|
||||
return L".md";
|
||||
|
||||
case AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTX:
|
||||
return L".pptx";
|
||||
@ -1681,6 +1698,8 @@ std::wstring COfficeFileFormatChecker::GetExtensionByType(int type)
|
||||
return L".otp";
|
||||
case AVS_OFFICESTUDIO_FILE_PRESENTATION_ODG:
|
||||
return L".odg";
|
||||
case AVS_OFFICESTUDIO_FILE_PRESENTATION_KEY:
|
||||
return L".key";
|
||||
|
||||
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX:
|
||||
return L".xlsx";
|
||||
@ -1702,6 +1721,8 @@ std::wstring COfficeFileFormatChecker::GetExtensionByType(int type)
|
||||
return L".fods";
|
||||
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_OTS:
|
||||
return L".ots";
|
||||
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_NUMBERS:
|
||||
return L".numbers";
|
||||
|
||||
case AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDF:
|
||||
case AVS_OFFICESTUDIO_FILE_DOCUMENT_OFORM_PDF:
|
||||
@ -1712,6 +1733,8 @@ std::wstring COfficeFileFormatChecker::GetExtensionByType(int type)
|
||||
return L".djvu";
|
||||
case AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_XPS:
|
||||
return L".xps";
|
||||
case AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_OFD:
|
||||
return L".ofd";
|
||||
case AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_SVG:
|
||||
return L".svg";
|
||||
case AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_HTMLR:
|
||||
@ -1829,6 +1852,14 @@ int COfficeFileFormatChecker::GetFormatByExtension(const std::wstring &sExt)
|
||||
return AVS_OFFICESTUDIO_FILE_DOCUMENT_ODT_FLAT;
|
||||
if (L".ott" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_DOCUMENT_OTT;
|
||||
if (L".pages" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_DOCUMENT_PAGES;
|
||||
if (L".hwp" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_DOCUMENT_HWP;
|
||||
if (L".hwpx" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_DOCUMENT_HWPX;
|
||||
if (L".md" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_DOCUMENT_MD;
|
||||
|
||||
if (L".pptx" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTX;
|
||||
@ -1852,6 +1883,8 @@ int COfficeFileFormatChecker::GetFormatByExtension(const std::wstring &sExt)
|
||||
return AVS_OFFICESTUDIO_FILE_PRESENTATION_OTP;
|
||||
if (L".odg" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_PRESENTATION_ODG;
|
||||
if (L".key" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_PRESENTATION_KEY;
|
||||
|
||||
if (L".xlsx" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX;
|
||||
@ -1879,6 +1912,8 @@ int COfficeFileFormatChecker::GetFormatByExtension(const std::wstring &sExt)
|
||||
return AVS_OFFICESTUDIO_FILE_SPREADSHEET_OTS;
|
||||
if (L".ods" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_SPREADSHEET_ODS;
|
||||
if (L".numbers" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_SPREADSHEET_NUMBERS;
|
||||
|
||||
if (L".ooxml" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_OTHER_OOXML;
|
||||
@ -1891,6 +1926,8 @@ int COfficeFileFormatChecker::GetFormatByExtension(const std::wstring &sExt)
|
||||
return AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_DJVU;
|
||||
if (L".xps" == ext || L".oxps" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_XPS;
|
||||
if (L"ofd" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_OFD;
|
||||
|
||||
if (L".jpg" == ext || L".jpeg" == ext || L".jpe" == ext || L".jfif" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_IMAGE_JPG;
|
||||
@ -2029,3 +2066,26 @@ bool COfficeFileFormatChecker::isXpsFile(const std::wstring &fileName)
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool COfficeFileFormatChecker::isOFDFile(const std::wstring& fileName)
|
||||
{
|
||||
COfficeUtils OfficeUtils(NULL);
|
||||
|
||||
ULONG nBufferSize = 0;
|
||||
BYTE *pBuffer = NULL;
|
||||
|
||||
HRESULT hresult = OfficeUtils.LoadFileFromArchive(fileName, L"OFD.xml", &pBuffer, nBufferSize);
|
||||
if (hresult == S_OK && pBuffer != NULL)
|
||||
{
|
||||
if (19 <= nBufferSize && NULL != strstr((char *)pBuffer, "ofd:OFD"))
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_OFD;
|
||||
|
||||
delete[] pBuffer;
|
||||
pBuffer = NULL;
|
||||
|
||||
if (nFileType != AVS_OFFICESTUDIO_FILE_UNKNOWN)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -58,7 +58,8 @@
|
||||
#define AVS_OFFICESTUDIO_FILE_DOCUMENT_OFORM_PDF AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x0017
|
||||
#define AVS_OFFICESTUDIO_FILE_DOCUMENT_PAGES AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x0018
|
||||
#define AVS_OFFICESTUDIO_FILE_DOCUMENT_HWP AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x0019
|
||||
#define AVS_OFFICESTUDIO_FILE_DOCUMENT_HWPX AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x0020
|
||||
#define AVS_OFFICESTUDIO_FILE_DOCUMENT_HWPX AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x001a
|
||||
#define AVS_OFFICESTUDIO_FILE_DOCUMENT_MD AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x001b
|
||||
|
||||
#define AVS_OFFICESTUDIO_FILE_DOCUMENT_XML AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x0030
|
||||
|
||||
@ -103,6 +104,7 @@
|
||||
#define AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_HTMLRMenu AVS_OFFICESTUDIO_FILE_CROSSPLATFORM + 0x0007
|
||||
#define AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_HTMLRCanvas AVS_OFFICESTUDIO_FILE_CROSSPLATFORM + 0x0008
|
||||
#define AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDFA AVS_OFFICESTUDIO_FILE_CROSSPLATFORM + 0x0009
|
||||
#define AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_OFD AVS_OFFICESTUDIO_FILE_CROSSPLATFORM + 0x000a
|
||||
|
||||
#define AVS_OFFICESTUDIO_FILE_IMAGE 0x0400
|
||||
#define AVS_OFFICESTUDIO_FILE_IMAGE_JPG AVS_OFFICESTUDIO_FILE_IMAGE + 0x0001
|
||||
@ -153,4 +155,4 @@
|
||||
#define AVS_OFFICESTUDIO_FILE_DRAW_VSTX AVS_OFFICESTUDIO_FILE_DRAW + 0x0003
|
||||
#define AVS_OFFICESTUDIO_FILE_DRAW_VSDM AVS_OFFICESTUDIO_FILE_DRAW + 0x0004
|
||||
#define AVS_OFFICESTUDIO_FILE_DRAW_VSSM AVS_OFFICESTUDIO_FILE_DRAW + 0x0005
|
||||
#define AVS_OFFICESTUDIO_FILE_DRAW_VSTM AVS_OFFICESTUDIO_FILE_DRAW + 0x0006
|
||||
#define AVS_OFFICESTUDIO_FILE_DRAW_VSTM AVS_OFFICESTUDIO_FILE_DRAW + 0x0006
|
||||
|
||||
@ -109,6 +109,31 @@ win32:!contains(QMAKE_TARGET.arch, x86_64): {
|
||||
CONFIG += core_win_32
|
||||
}
|
||||
|
||||
linux-clang-libc++ {
|
||||
CONFIG += core_linux
|
||||
CONFIG += core_linux_64
|
||||
CONFIG += core_linux_clang
|
||||
message("linux-64-clang-libc++")
|
||||
}
|
||||
linux-clang-libc++-32 {
|
||||
CONFIG += core_linux
|
||||
CONFIG += core_linux_32
|
||||
CONFIG += core_linux_clang
|
||||
message("linux-32-clang-libc++")
|
||||
}
|
||||
linux-clang {
|
||||
CONFIG += core_linux
|
||||
CONFIG += core_linux_64
|
||||
CONFIG += core_linux_clang
|
||||
message("linux-64-clang")
|
||||
}
|
||||
linux-clang-32 {
|
||||
CONFIG += core_linux
|
||||
CONFIG += core_linux_32
|
||||
CONFIG += core_linux_clang
|
||||
message("linux-32-clang")
|
||||
}
|
||||
|
||||
linux-g++ {
|
||||
CONFIG += core_linux
|
||||
linux-g++:contains(QMAKE_HOST.arch, x86_64): {
|
||||
@ -196,6 +221,10 @@ core_mac {
|
||||
}
|
||||
}
|
||||
|
||||
core_linux_clang {
|
||||
QMAKE_CFLAGS += -Wno-implicit-function-declaration
|
||||
}
|
||||
|
||||
# PREFIXES
|
||||
core_windows {
|
||||
CONFIG -= debug_and_release debug_and_release_target
|
||||
@ -416,6 +445,12 @@ message($$CORE_BUILDS_PLATFORM_PREFIX/$$CORE_BUILDS_CONFIGURATION_PREFIX)
|
||||
# COMPILER
|
||||
CONFIG += c++11
|
||||
|
||||
#CONFIG += enable_cpp_17
|
||||
enable_cpp_17 {
|
||||
CONFIG += c++1z
|
||||
DEFINES += _LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION
|
||||
}
|
||||
|
||||
!core_windows {
|
||||
QMAKE_CXXFLAGS += -Wno-register
|
||||
QMAKE_CFLAGS += -Wno-register
|
||||
@ -423,7 +458,11 @@ CONFIG += c++11
|
||||
|
||||
core_linux {
|
||||
core_static_link_libstd {
|
||||
QMAKE_LFLAGS += -static-libstdc++ -static-libgcc
|
||||
!core_linux_clang {
|
||||
QMAKE_LFLAGS += -static-libstdc++ -static-libgcc
|
||||
} else {
|
||||
# TODO: add libc++abi?
|
||||
}
|
||||
message(core_static_link_libstd)
|
||||
}
|
||||
plugin {
|
||||
|
||||
@ -416,6 +416,16 @@ namespace agg
|
||||
{
|
||||
return self_type(rgba::from_wavelength(wl, gamma));
|
||||
}
|
||||
|
||||
bool operator==(const self_type& other)
|
||||
{
|
||||
return a == other.a && r == other.r && g == other.g && b == other.b;
|
||||
}
|
||||
|
||||
bool operator!=(const self_type& other)
|
||||
{
|
||||
return !operator==(other);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -1465,7 +1465,29 @@ namespace agg
|
||||
}
|
||||
};
|
||||
|
||||
template<class ColorT, class Order> struct comp_op_rgba_draw_on_black
|
||||
{
|
||||
typedef ColorT color_type;
|
||||
typedef Order order_type;
|
||||
typedef typename color_type::value_type value_type;
|
||||
typedef typename color_type::calc_type calc_type;
|
||||
enum base_scale_e
|
||||
{
|
||||
base_shift = color_type::base_shift,
|
||||
base_mask = color_type::base_mask
|
||||
};
|
||||
|
||||
static AGG_INLINE void blend_pix(value_type* p,
|
||||
unsigned sr, unsigned sg, unsigned sb,
|
||||
unsigned sa, unsigned cover)
|
||||
{
|
||||
|
||||
if (0x00 != p[Order::R] || 0x00 != p[Order::G] || 0x00 != p[Order::B])
|
||||
return;
|
||||
|
||||
comp_op_rgba_src_over <ColorT,Order>::blend_pix(p, sr, sg, sb, sa, cover);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -1515,6 +1537,9 @@ namespace agg
|
||||
comp_op_rgba_contrast <ColorT,Order>::blend_pix,
|
||||
comp_op_rgba_invert <ColorT,Order>::blend_pix,
|
||||
comp_op_rgba_invert_rgb <ColorT,Order>::blend_pix,
|
||||
|
||||
//Custom function
|
||||
comp_op_rgba_draw_on_black<ColorT,Order>::blend_pix,
|
||||
0
|
||||
};
|
||||
|
||||
@ -1551,6 +1576,9 @@ namespace agg
|
||||
comp_op_invert, //----comp_op_invert
|
||||
comp_op_invert_rgb, //----comp_op_invert_rgb
|
||||
|
||||
//Custom modes
|
||||
comp_op_draw_on_black, //----comp_op_draw_on_black
|
||||
|
||||
end_of_comp_op_e
|
||||
};
|
||||
|
||||
|
||||
@ -1000,7 +1000,17 @@ namespace agg
|
||||
{
|
||||
if (i < RES && j < RES)
|
||||
{
|
||||
precalc[i][j] = c;
|
||||
if (m_oGradientInfo.luminocity)
|
||||
{
|
||||
ColorT fillC;
|
||||
fillC.r = m_oGradientInfo.shading.fill_color.r * c.r / 255 + 255 - c.r;
|
||||
fillC.g = m_oGradientInfo.shading.fill_color.g * c.g / 255 + 255 - c.g;
|
||||
fillC.b = m_oGradientInfo.shading.fill_color.b * c.b / 255 + 255 - c.b;
|
||||
fillC.a = 255;
|
||||
precalc[i][j] = fillC;
|
||||
}
|
||||
else
|
||||
precalc[i][j] = c;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1629,6 +1629,10 @@ namespace NSFile
|
||||
{
|
||||
wsTemp = L"";
|
||||
}
|
||||
#if defined(_WIN32) || defined (_WIN64)
|
||||
if (wsTempDir)
|
||||
free(wsTempDir);
|
||||
#endif
|
||||
wsTemp += L"x";
|
||||
int nTime = (int)time(NULL);
|
||||
for (int nIndex = 0; nIndex < 1000; ++nIndex)
|
||||
|
||||
@ -319,7 +319,14 @@ namespace NSStringUtils
|
||||
{
|
||||
WriteEncodeXmlString(sString.c_str(), (int)sString.length());
|
||||
}
|
||||
|
||||
void CStringBuilder::WriteEncodeXmlString(const std::string& sString)
|
||||
{
|
||||
WriteEncodeXmlString(std::wstring(sString.begin(), sString.end()));
|
||||
}
|
||||
void CStringBuilder::WriteUtf8EncodeXmlString(const std::string& sString)
|
||||
{
|
||||
WriteEncodeXmlString(NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)sString.c_str(), sString.size()));
|
||||
}
|
||||
void CStringBuilder::WriteEncodeXmlString(const wchar_t* pString, int nCount)
|
||||
{
|
||||
if (sizeof(wchar_t) == 2)
|
||||
|
||||
@ -110,6 +110,9 @@ namespace NSStringUtils
|
||||
void WriteEncodeXmlString(const std::wstring& sString);
|
||||
void WriteEncodeXmlString(const wchar_t* pString, int nCount = -1);
|
||||
|
||||
void WriteEncodeXmlString(const std::string& sString);
|
||||
void WriteUtf8EncodeXmlString(const std::string& sString);
|
||||
|
||||
void WriteEncodeXmlStringHHHH(const std::wstring& sString);
|
||||
void WriteEncodeXmlStringHHHH(const wchar_t* pString, int nCount = -1);
|
||||
|
||||
|
||||
@ -38,6 +38,7 @@
|
||||
#define CXIMAGE_SUPPORT_PNM 1
|
||||
#define CXIMAGE_SUPPORT_RAS 1
|
||||
#define CXIMAGE_SUPPORT_PIC 1
|
||||
#define CXIMAGE_SUPPORT_HEIF 1
|
||||
|
||||
#define CXIMAGE_SUPPORT_JBG 0 // GPL'd see ../jbig/copying.txt & ../jbig/patents.htm
|
||||
|
||||
|
||||
@ -133,13 +133,17 @@ CXIMAGE_FORMAT_PSD = 20,
|
||||
#if CXIMAGE_SUPPORT_PIC
|
||||
CXIMAGE_FORMAR_PIC = 25,
|
||||
#endif
|
||||
#if CXIMAGE_SUPPORT_HEIF
|
||||
CXIMAGE_FORMAT_HEIF = 26,
|
||||
#endif
|
||||
CMAX_IMAGE_FORMATS = CXIMAGE_SUPPORT_BMP + CXIMAGE_SUPPORT_GIF + CXIMAGE_SUPPORT_JPG +
|
||||
CXIMAGE_SUPPORT_PNG + CXIMAGE_SUPPORT_MNG + CXIMAGE_SUPPORT_ICO +
|
||||
CXIMAGE_SUPPORT_TIF + CXIMAGE_SUPPORT_TGA + CXIMAGE_SUPPORT_PCX +
|
||||
CXIMAGE_SUPPORT_WBMP+ CXIMAGE_SUPPORT_WMF + CXIMAGE_SUPPORT_PIC +
|
||||
CXIMAGE_SUPPORT_JBG + CXIMAGE_SUPPORT_JP2 + CXIMAGE_SUPPORT_JPC +
|
||||
CXIMAGE_SUPPORT_PGX + CXIMAGE_SUPPORT_PNM + CXIMAGE_SUPPORT_RAS +
|
||||
CXIMAGE_SUPPORT_SKA + CXIMAGE_SUPPORT_RAW + CXIMAGE_SUPPORT_PSD + 1
|
||||
CXIMAGE_SUPPORT_SKA + CXIMAGE_SUPPORT_RAW + CXIMAGE_SUPPORT_PSD +
|
||||
CXIMAGE_SUPPORT_HEIF + 1
|
||||
};
|
||||
|
||||
#if CXIMAGE_SUPPORT_EXIF
|
||||
|
||||
@ -23,14 +23,14 @@
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma warning (disable : 4550)
|
||||
|
||||
#pragma warning (disable : 4550)
|
||||
|
||||
/*
|
||||
* TIFF Library
|
||||
*
|
||||
* Read and return a packed RGBA image.
|
||||
*/
|
||||
*/
|
||||
#include "tiffiop.h"
|
||||
#include <stdio.h>
|
||||
|
||||
@ -828,11 +828,12 @@ gtStripContig(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h)
|
||||
nrowsub = nrow;
|
||||
if ((nrowsub%subsamplingver)!=0)
|
||||
nrowsub+=subsamplingver-nrowsub%subsamplingver;
|
||||
|
||||
if (TIFFReadEncodedStrip(tif,
|
||||
TIFFComputeStrip(tif,row+img->row_offset, 0),
|
||||
buf,
|
||||
((row + img->row_offset)%rowsperstrip + nrowsub) * scanline) < 0
|
||||
&& img->stoponerr)
|
||||
((row + img->row_offset)%rowsperstrip + nrowsub) * scanline) < 0
|
||||
&& img->stoponerr)
|
||||
{
|
||||
ret = 0;
|
||||
break;
|
||||
|
||||
@ -383,6 +383,20 @@ class CDocBuilderValue:
|
||||
def __setitem__(self, key, value):
|
||||
self.Set(key, value)
|
||||
|
||||
def __getattr__(self, name):
|
||||
def method(*args):
|
||||
return self.Call(name, *args)
|
||||
return method
|
||||
|
||||
def __len__(self):
|
||||
return self.GetLength()
|
||||
|
||||
def __iter__(self):
|
||||
if not self.IsArray():
|
||||
raise TypeError("Object is not iterable")
|
||||
for i in range(self.GetLength()):
|
||||
yield self.Get(i)
|
||||
|
||||
@staticmethod
|
||||
def CreateUndefined():
|
||||
return CDocBuilderValue(OBJECT_HANDLE(_lib.CDocBuilderValue_CreateUndefined()))
|
||||
@ -423,6 +437,36 @@ class CDocBuilderValue:
|
||||
return CDocBuilderValue(OBJECT_HANDLE(_lib.CDocBuilderValue_Call6(self._internal, ctypes.c_wchar_p(name), values[0]._internal, values[1]._internal, values[2]._internal, values[3]._internal, values[4]._internal, values[5]._internal)))
|
||||
else:
|
||||
raise TypeError("Call() expects at most 6 arguments")
|
||||
|
||||
def append(self, value):
|
||||
if not self.IsArray():
|
||||
raise TypeError("Object is not an array")
|
||||
length = self.GetLength()
|
||||
self.Set(length, value)
|
||||
return self
|
||||
|
||||
def extend(self, iterable):
|
||||
if not self.IsArray():
|
||||
raise TypeError("Object is not an array")
|
||||
length = self.GetLength()
|
||||
for i, value in enumerate(iterable, start=length):
|
||||
self.Set(i, value)
|
||||
return self
|
||||
|
||||
def insert(self, i, x):
|
||||
if not self.IsArray():
|
||||
raise TypeError("Object is not an array")
|
||||
length = self.GetLength()
|
||||
if i < 0:
|
||||
if abs(i) > length:
|
||||
raise IndexError("list index out of range")
|
||||
i = max(0, length + i)
|
||||
if i >= length:
|
||||
raise IndexError("list index out of range")
|
||||
for idx in range(length, i, -1):
|
||||
self.Set(idx, self.Get(idx - 1))
|
||||
self.Set(i, x)
|
||||
|
||||
|
||||
class CDocBuilder:
|
||||
_initialized = False
|
||||
@ -435,7 +479,7 @@ class CDocBuilder:
|
||||
# using self._lib instead of global _lib because it might be already garbage collected during this function call
|
||||
self._lib.CDocBuilder_Destroy(self._internal)
|
||||
|
||||
def OpenFile(self, path, params):
|
||||
def OpenFile(self, path, params=""):
|
||||
return _lib.CDocBuilder_OpenFile(self._internal, ctypes.c_wchar_p(path), ctypes.c_wchar_p(params))
|
||||
|
||||
def CreateFile(self, type):
|
||||
|
||||
@ -13,16 +13,16 @@ scope = context.CreateScope()
|
||||
globalObj = context.GetGlobal()
|
||||
|
||||
api = globalObj['Api']
|
||||
document = api.Call('GetDocument')
|
||||
paragraph1 = api.Call('CreateParagraph')
|
||||
paragraph1.Call('SetSpacingAfter', 1000, False)
|
||||
paragraph1.Call('AddText', 'Hello from Python!')
|
||||
document = api.GetDocument()
|
||||
paragraph1 = api.CreateParagraph()
|
||||
paragraph1.SetSpacingAfter(1000, False)
|
||||
paragraph1.AddText('Hello from Python!')
|
||||
|
||||
paragraph2 = api.Call('CreateParagraph')
|
||||
paragraph2.Call('AddText', 'Goodbye!')
|
||||
paragraph2 = api.CreateParagraph()
|
||||
paragraph2.AddText('Goodbye!')
|
||||
|
||||
content = [paragraph1, paragraph2]
|
||||
document.Call('InsertContent', content)
|
||||
document.InsertContent(content)
|
||||
|
||||
dstPath = os.getcwd() + '/result.docx'
|
||||
builder.SaveFile(docbuilder.FileTypes.Document.DOCX, dstPath)
|
||||
|
||||
@ -0,0 +1,29 @@
|
||||
import os
|
||||
import sys
|
||||
sys.path.append('path_to_docbuilder')
|
||||
import docbuilder
|
||||
|
||||
builder = docbuilder.CDocBuilder()
|
||||
|
||||
builder.CreateFile(docbuilder.FileTypes.Document.DOCX)
|
||||
|
||||
context = builder.GetContext()
|
||||
scope = context.CreateScope()
|
||||
|
||||
globalObj = context.GetGlobal()
|
||||
|
||||
api = globalObj['Api']
|
||||
document = api.Call('GetDocument')
|
||||
paragraph1 = api.Call('CreateParagraph')
|
||||
paragraph1.Call('SetSpacingAfter', 1000, False)
|
||||
paragraph1.Call('AddText', 'Hello from Python!')
|
||||
|
||||
paragraph2 = api.Call('CreateParagraph')
|
||||
paragraph2.Call('AddText', 'Goodbye!')
|
||||
|
||||
content = [paragraph1, paragraph2]
|
||||
document.Call('InsertContent', content)
|
||||
|
||||
dstPath = os.getcwd() + '/result.docx'
|
||||
builder.SaveFile(docbuilder.FileTypes.Document.DOCX, dstPath)
|
||||
builder.CloseFile()
|
||||
@ -82,7 +82,7 @@ CV8RealTimeWorker::~CV8RealTimeWorker()
|
||||
m_context->Dispose();
|
||||
}
|
||||
|
||||
bool CV8RealTimeWorker::ExecuteCommand(const std::wstring& command, NSDoctRenderer::CDocBuilderValue* retValue, const bool& isEnterContext)
|
||||
bool CV8RealTimeWorker::ExecuteCommand(const std::wstring& command, NSDoctRenderer::CDocBuilderValue* retValue, const bool& isEnterContextSrc)
|
||||
{
|
||||
LOGGER_SPEED_START();
|
||||
|
||||
@ -92,6 +92,10 @@ bool CV8RealTimeWorker::ExecuteCommand(const std::wstring& command, NSDoctRender
|
||||
std::string commandA = U_TO_UTF8(command);
|
||||
//commandA = "Api." + commandA;
|
||||
|
||||
bool isEnterContext = isEnterContextSrc;
|
||||
if (!isEnterContext && !m_context->IsEntered())
|
||||
isEnterContext = true;
|
||||
|
||||
if (isEnterContext)
|
||||
m_context->Enter();
|
||||
|
||||
|
||||
@ -171,7 +171,6 @@ public:
|
||||
|
||||
return m_pFile ? true : false;
|
||||
}
|
||||
|
||||
bool OpenFile(BYTE* data, LONG size, const std::wstring& sPassword)
|
||||
{
|
||||
CloseFile();
|
||||
@ -284,6 +283,24 @@ public:
|
||||
return NULL;
|
||||
return m_pFile->ConvertToPixels(nPageIndex, nRasterW, nRasterH, true, m_pFontManager, nBackgroundColor, (nBackgroundColor == 0xFFFFFF) ? false : true);
|
||||
}
|
||||
BYTE* SplitPages(int* arrPageIndex, int nLength, BYTE* data, LONG size)
|
||||
{
|
||||
if (m_nType == 0)
|
||||
return ((CPdfFile*)m_pFile)->SplitPages(arrPageIndex, nLength, data, size);
|
||||
return NULL;
|
||||
}
|
||||
bool MergePages(BYTE* data, LONG size, int nMaxID, const std::string& sPrefixForm)
|
||||
{
|
||||
if (m_nType == 0)
|
||||
return ((CPdfFile*)m_pFile)->MergePages(data, size, nMaxID, sPrefixForm);
|
||||
return false;
|
||||
}
|
||||
bool UnmergePages()
|
||||
{
|
||||
if (m_nType == 0)
|
||||
return ((CPdfFile*)m_pFile)->UnmergePages();
|
||||
return false;
|
||||
}
|
||||
|
||||
BYTE* GetGlyphs(int nPageIndex)
|
||||
{
|
||||
|
||||
@ -166,6 +166,48 @@ JSSmart<CJSValue> CDrawingFileEmbed::FreeWasmData(JSSmart<CJSValue> typedArray)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CDrawingFileEmbed::SplitPages(JSSmart<CJSValue> arrPageIndexes, JSSmart<CJSValue> data)
|
||||
{
|
||||
JSSmart<CJSArray> arrPages = arrPageIndexes->toArray();
|
||||
CJSDataBuffer changes;
|
||||
if (data->isTypedArray())
|
||||
changes = data->toTypedArray()->getData();
|
||||
|
||||
int nCountPages = arrPages->getCount();
|
||||
int* pPages = NULL;
|
||||
if (0 < nCountPages)
|
||||
pPages = new int[nCountPages];
|
||||
|
||||
for (int i = 0; i < nCountPages; i++)
|
||||
pPages[i] = arrPages->get(i)->toInt32();
|
||||
|
||||
JSSmart<CJSValue> res = WasmMemoryToJS(m_pFile->SplitPages(pPages, nCountPages, changes.Data, (LONG)changes.Len));
|
||||
if (pPages)
|
||||
delete [] pPages;
|
||||
return res;
|
||||
}
|
||||
JSSmart<CJSValue> CDrawingFileEmbed::MergePages(JSSmart<CJSValue> data, JSSmart<CJSValue> nMaxID, JSSmart<CJSValue> sPrefixForm)
|
||||
{
|
||||
bool result = false;
|
||||
if (m_pFile)
|
||||
{
|
||||
JSSmart<CJSTypedArray> dataPtr = data->toTypedArray();
|
||||
int maxID = nMaxID->toInt32();
|
||||
std::string prefix = sPrefixForm->toStringA();
|
||||
CJSDataBuffer buffer = dataPtr->getData();
|
||||
result = m_pFile->MergePages(buffer.Data, (LONG)buffer.Len, maxID, prefix);
|
||||
if (buffer.IsExternalize)
|
||||
buffer.Free();
|
||||
}
|
||||
return CJSContext::createBool(result);
|
||||
}
|
||||
JSSmart<CJSValue> CDrawingFileEmbed::UnmergePages()
|
||||
{
|
||||
if (m_pFile)
|
||||
return CJSContext::createBool(m_pFile->UnmergePages());
|
||||
return CJSContext::createBool(false);
|
||||
}
|
||||
|
||||
bool EmbedDrawingFile(JSSmart<NSJSBase::CJSContext>& context, IOfficeDrawingFile* pFile)
|
||||
{
|
||||
CJSContext::Embed<CDrawingFileEmbed>(false);
|
||||
|
||||
@ -51,6 +51,10 @@ public:
|
||||
|
||||
JSSmart<CJSValue> FreeWasmData(JSSmart<CJSValue> typedArray);
|
||||
|
||||
JSSmart<CJSValue> SplitPages(JSSmart<CJSValue> arrPageIndexes, JSSmart<CJSValue> data);
|
||||
JSSmart<CJSValue> MergePages(JSSmart<CJSValue> data, JSSmart<CJSValue> nMaxID, JSSmart<CJSValue> sPrefixForm);
|
||||
JSSmart<CJSValue> UnmergePages();
|
||||
|
||||
DECLARE_EMBED_METHODS
|
||||
};
|
||||
|
||||
|
||||
@ -27,6 +27,9 @@
|
||||
-(JSValue*) ScanPage : (JSValue*)nPageIndex : (JSValue*)mode;
|
||||
-(JSValue*) GetImageBase64 : (JSValue*)rId;
|
||||
-(JSValue*) FreeWasmData : (JSValue*)typedArray;
|
||||
-(JSValue*) SplitPages : (JSValue*)arrPageIndexes : (JSValue*)data;
|
||||
-(JSValue*) MergePages : (JSValue*)data : (JSValue*)nMaxID : (JSValue*)sPrefixForm;
|
||||
-(JSValue*) UnmergePages;
|
||||
@end
|
||||
|
||||
@interface CJSCDrawingFileEmbed : NSObject<IJSCDrawingFileEmbed, JSEmbedObjectProtocol>
|
||||
@ -61,6 +64,9 @@ FUNCTION_WRAPPER_JS_0(IsNeedCMap, IsNeedCMap)
|
||||
FUNCTION_WRAPPER_JS_2(ScanPage, ScanPage)
|
||||
FUNCTION_WRAPPER_JS_1(GetImageBase64, GetImageBase64)
|
||||
FUNCTION_WRAPPER_JS_1(FreeWasmData, FreeWasmData)
|
||||
FUNCTION_WRAPPER_JS_2(SplitPages, SplitPages)
|
||||
FUNCTION_WRAPPER_JS_3(MergePages, MergePages)
|
||||
FUNCTION_WRAPPER_JS_0(UnmergePages, UnmergePages)
|
||||
@end
|
||||
|
||||
class CDrawingFileEmbedAdapter : public CJSEmbedObjectAdapterJSC
|
||||
|
||||
@ -30,6 +30,9 @@ namespace NSDrawingFileEmbed
|
||||
FUNCTION_WRAPPER_V8_2(_ScanPage, ScanPage)
|
||||
FUNCTION_WRAPPER_V8_1(_GetImageBase64, GetImageBase64)
|
||||
FUNCTION_WRAPPER_V8_1(_FreeWasmData, FreeWasmData)
|
||||
FUNCTION_WRAPPER_V8_2(_SplitPages, SplitPages)
|
||||
FUNCTION_WRAPPER_V8_3(_MergePages, MergePages)
|
||||
FUNCTION_WRAPPER_V8_0(_UnmergePages, UnmergePages)
|
||||
|
||||
v8::Handle<v8::ObjectTemplate> CreateTemplate(v8::Isolate* isolate)
|
||||
{
|
||||
@ -59,6 +62,9 @@ namespace NSDrawingFileEmbed
|
||||
NSV8Objects::Template_Set(result, "ScanPage", _ScanPage);
|
||||
NSV8Objects::Template_Set(result, "GetImageBase64", _GetImageBase64);
|
||||
NSV8Objects::Template_Set(result, "FreeWasmData", _FreeWasmData);
|
||||
NSV8Objects::Template_Set(result, "SplitPages", _SplitPages);
|
||||
NSV8Objects::Template_Set(result, "MergePages", _MergePages);
|
||||
NSV8Objects::Template_Set(result, "UnmergePages", _UnmergePages);
|
||||
|
||||
return handle_scope.Escape(result);
|
||||
}
|
||||
|
||||
@ -483,6 +483,12 @@ namespace NSJSBase
|
||||
*/
|
||||
void Exit();
|
||||
|
||||
/**
|
||||
* Сheck if context is current.
|
||||
* This method is not safe.
|
||||
*/
|
||||
bool IsEntered();
|
||||
|
||||
/**
|
||||
* Embeds specified class in JS contexts.
|
||||
* @tparam T Embedded class name.
|
||||
|
||||
@ -439,6 +439,11 @@ namespace NSJSBase
|
||||
{
|
||||
}
|
||||
|
||||
bool CJSContext::IsEntered()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
class CJSLocalScopePrivate
|
||||
{
|
||||
public:
|
||||
|
||||
@ -255,6 +255,8 @@ namespace NSJSBase
|
||||
m_internal->m_context = v8::Local<v8::Context>::New(isolate, m_internal->m_contextPersistent);
|
||||
if (!m_internal->m_context.IsEmpty())
|
||||
m_internal->m_context->Enter();
|
||||
|
||||
m_internal->m_entered = true;
|
||||
}
|
||||
|
||||
void CJSContext::Exit()
|
||||
@ -271,6 +273,13 @@ namespace NSJSBase
|
||||
else
|
||||
m_internal->m_context = m_internal->m_isolate->GetCurrentContext();
|
||||
m_internal->m_isolate->Exit();
|
||||
|
||||
m_internal->m_entered = false;
|
||||
}
|
||||
|
||||
bool CJSContext::IsEntered()
|
||||
{
|
||||
return m_internal->m_entered;
|
||||
}
|
||||
|
||||
CJSValue* CJSContext::createUndefined()
|
||||
|
||||
@ -857,12 +857,14 @@ namespace NSJSBase
|
||||
v8::Local<v8::Context> m_context;
|
||||
|
||||
v8::StartupData m_startup_data;
|
||||
bool m_entered;
|
||||
|
||||
public:
|
||||
CJSContextPrivate() : m_isolate(NULL)
|
||||
{
|
||||
m_startup_data.data = NULL;
|
||||
m_startup_data.raw_size = 0;
|
||||
m_entered = false;
|
||||
}
|
||||
|
||||
void InsertToGlobal(const std::string& name, v8::FunctionCallback creator)
|
||||
|
||||
@ -1020,22 +1020,39 @@ void CBooleanOperations::TracePaths()
|
||||
{
|
||||
size_t length = Segments1.size();
|
||||
Result.StartFigure();
|
||||
bool first_start = true;
|
||||
for (size_t i = 0; i < length + Segments2.size(); i++)
|
||||
{
|
||||
Segment s = i >= length ? Segments2[i - length] : Segments1[i];
|
||||
bool valid = s.IsValid(Op),
|
||||
start = true;
|
||||
start = true;
|
||||
PointD start_point;
|
||||
while (valid)
|
||||
{
|
||||
if (!start || (Op == Intersection && s.Inters && !GetNextSegment(s).Inters))
|
||||
SetVisited(s);
|
||||
|
||||
if (start)
|
||||
if (first_start)
|
||||
{
|
||||
Result.MoveTo(s.P.X, s.P.Y);
|
||||
start_point = s.P;
|
||||
}
|
||||
else if (start)
|
||||
{
|
||||
double x, y;
|
||||
Result.GetLastPoint(x, y);
|
||||
if (isZero(start_point.X - x) && isZero(start_point.Y - y))
|
||||
{
|
||||
Result.MoveTo(s.P.X, s.P.Y);
|
||||
start_point = s.P;
|
||||
}
|
||||
else
|
||||
Result.LineTo(s.P.X, s.P.Y);
|
||||
}
|
||||
else if (s.IsCurve)
|
||||
Result.CurveTo(s.HI.X + s.P.X, s.HI.Y + s.P.Y,
|
||||
s.HO.X + s.P.X, s.HO.Y + s.P.Y,
|
||||
s.P.X, s.P.Y);
|
||||
s.HO.X + s.P.X, s.HO.Y + s.P.Y,
|
||||
s.P.X, s.P.Y);
|
||||
else
|
||||
Result.LineTo(s.P.X, s.P.Y);
|
||||
|
||||
@ -1065,6 +1082,9 @@ void CBooleanOperations::TracePaths()
|
||||
|
||||
if (start)
|
||||
start = false;
|
||||
|
||||
if (first_start)
|
||||
first_start = false;
|
||||
}
|
||||
|
||||
if (!start && AllOverlap()) break;
|
||||
@ -1645,12 +1665,14 @@ int CBooleanOperations::CheckInters(const PointD& point, const Segment& segment,
|
||||
std::vector<double> roots = curve.GetCurveLineIntersection(segment.P.X,segment.P.Y, point.X - segment.P.X, point.Y - segment.P.Y);
|
||||
Curve line(segment, Segment(point));
|
||||
|
||||
int count = 0;
|
||||
for (const auto& r : roots)
|
||||
if (line.GetTimeOf(curve.GetPoint(r)) != -1)
|
||||
count++;
|
||||
return roots.size() % 2;
|
||||
|
||||
return count;
|
||||
// int count = 0;
|
||||
// for (const auto& r : roots)
|
||||
// if (line.GetTimeOf(curve.GetPoint(r)) != -1)
|
||||
// count++;
|
||||
|
||||
// return count;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -863,20 +863,22 @@ namespace Aggplus
|
||||
|
||||
double CGraphicsPath::GetArea(unsigned idx, bool isCurve) const noexcept
|
||||
{
|
||||
float area;
|
||||
double area;
|
||||
if (isCurve)
|
||||
{
|
||||
std::vector<PointD> points = GetPoints(idx, 4);
|
||||
area = 3 * ((points[3].Y - points[0].Y) * (points[1].X + points[2].X)
|
||||
- (points[3].X - points[0].X) * (points[1].Y * points[2].Y)
|
||||
+ points[1].Y * (points[0].X - points[2].X)
|
||||
- points[1].X * (points[0].Y - points[2].Y)
|
||||
+ points[3].Y * (points[2].X + points[0].X / 3)
|
||||
- points[3].X * (points[2].Y - points[0].Y / 3)) / 20;
|
||||
area = (points[3].Y - points[0].Y) * (points[1].X + points[2].X)
|
||||
- (points[3].X - points[0].X) * (points[1].Y + points[2].Y)
|
||||
+ points[1].Y * (points[0].X - points[2].X)
|
||||
- points[1].X * (points[0].Y - points[2].Y)
|
||||
+ points[3].Y * (points[2].X + points[0].X / 3.0)
|
||||
- points[3].X * (points[2].Y + points[0].Y / 3.0);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::vector<PointD> points = GetPoints(idx, 2);
|
||||
area = 4.0 * (points[1].Y * points[0].X - points[1].X * points[0].Y) / 3.0;
|
||||
}
|
||||
|
||||
std::vector<PointD> points = GetPoints(idx, 2);
|
||||
area = (points[1].Y * points[0].X - points[1].X * points[0].Y) / 20;
|
||||
|
||||
return area;
|
||||
}
|
||||
|
||||
@ -214,6 +214,7 @@ int CAnnotFieldInfo::GetFlag() const { return m_nFlag; }
|
||||
int CAnnotFieldInfo::GetID() const { return m_nID; }
|
||||
int CAnnotFieldInfo::GetAnnotFlag() const { return m_nAnnotFlag; }
|
||||
int CAnnotFieldInfo::GetPage() const { return m_nPage; }
|
||||
int CAnnotFieldInfo::GetCopyAP() const { return m_nCopyAP; }
|
||||
void CAnnotFieldInfo::GetBE(BYTE& nS, double& dI) { nS = m_pBE.first; dI = m_pBE.second; }
|
||||
BYTE* CAnnotFieldInfo::GetRender(LONG& nLen)
|
||||
{
|
||||
@ -359,6 +360,8 @@ bool CAnnotFieldInfo::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMeta
|
||||
}
|
||||
if (nFlags & (1 << 7))
|
||||
m_wsOUserID = pReader->ReadString();
|
||||
if (nFlags & (1 << 8))
|
||||
m_nCopyAP = pReader->ReadInt();
|
||||
|
||||
if (IsMarkup())
|
||||
{
|
||||
@ -985,7 +988,7 @@ void CAnnotFieldInfo::CWidgetAnnotPr::CTextWidgetPr::Read(NSOnlineOfficeBinToPdf
|
||||
m_wsV = pReader->ReadString();
|
||||
if (nFlags & (1 << 10))
|
||||
m_nMaxLen = pReader->ReadInt();
|
||||
if (nWidgetFlag & (1 << 25))
|
||||
if (nFlags & (1 << 11))
|
||||
m_wsRV = pReader->ReadString();
|
||||
if (nFlags & (1 << 12))
|
||||
m_wsAPV = pReader->ReadString();
|
||||
@ -1064,15 +1067,21 @@ CWidgetsInfo::~CWidgetsInfo()
|
||||
for (int i = 0; i < m_arrParents.size(); ++i)
|
||||
RELEASEOBJECT(m_arrParents[i]);
|
||||
}
|
||||
const std::vector<int>& CWidgetsInfo::GetCO() { return m_arrCO; }
|
||||
const std::vector< std::pair<int, int> >& CWidgetsInfo::GetCO() { return m_arrCO; }
|
||||
const std::vector<std::wstring>& CWidgetsInfo::GetButtonImg() { return m_arrButtonImg; }
|
||||
const std::vector<CWidgetsInfo::CParent*>& CWidgetsInfo::GetParents() { return m_arrParents; }
|
||||
void CWidgetsInfo::ChangeCO(int i, int nNum, int nGen)
|
||||
{
|
||||
if (i < 0 || i > m_arrCO.size() - 1)
|
||||
return;
|
||||
m_arrCO[i] = std::make_pair(nNum, nGen);
|
||||
}
|
||||
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());
|
||||
m_arrCO.push_back(std::make_pair(pReader->ReadInt(), -1));
|
||||
|
||||
n = pReader->ReadInt();
|
||||
m_arrParents.reserve(n);
|
||||
@ -1104,6 +1113,36 @@ bool CWidgetsInfo::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMetafil
|
||||
for (int i = 0; i < n; ++i)
|
||||
pParent->arrV.push_back(pReader->ReadString());
|
||||
}
|
||||
if (nFlags & (1 << 6))
|
||||
{
|
||||
int n = pReader->ReadInt();
|
||||
pParent->arrOpt.reserve(n);
|
||||
for (int i = 0; i < n; ++i)
|
||||
{
|
||||
std::wstring s1 = pReader->ReadString();
|
||||
std::wstring s2 = pReader->ReadString();
|
||||
pParent->arrOpt.push_back(std::make_pair(s1, s2));
|
||||
}
|
||||
}
|
||||
if (nFlags & (1 << 7))
|
||||
pParent->nFieldFlag = pReader->ReadInt();
|
||||
if (nFlags & (1 << 8))
|
||||
{
|
||||
// Action
|
||||
int nAction = pReader->ReadInt();
|
||||
for (int i = 0; i < nAction; ++i)
|
||||
{
|
||||
std::wstring wsType = pReader->ReadString();
|
||||
CAnnotFieldInfo::CWidgetAnnotPr::CActionWidget* pA = ReadAction(pReader);
|
||||
if (pA)
|
||||
{
|
||||
pA->wsType = wsType;
|
||||
pParent->arrAction.push_back(pA);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (nFlags & (1 << 9))
|
||||
pParent->nMaxLen = pReader->ReadInt();
|
||||
m_arrParents.push_back(pParent);
|
||||
}
|
||||
|
||||
|
||||
@ -465,6 +465,7 @@ public:
|
||||
int GetID() const;
|
||||
int GetAnnotFlag() const;
|
||||
int GetPage() const;
|
||||
int GetCopyAP() const;
|
||||
void GetBE(BYTE& nS, double& dI);
|
||||
BYTE* GetRender(LONG& nLen);
|
||||
const std::wstring& GetNM();
|
||||
@ -522,6 +523,7 @@ private:
|
||||
int m_nID;
|
||||
int m_nAnnotFlag;
|
||||
int m_nPage;
|
||||
int m_nCopyAP;
|
||||
std::wstring m_wsNM;
|
||||
std::wstring m_wsLM;
|
||||
std::wstring m_wsOUserID;
|
||||
@ -567,25 +569,31 @@ public:
|
||||
{
|
||||
int nID;
|
||||
int nFlags;
|
||||
int nMaxLen;
|
||||
int nParentID;
|
||||
int nFieldFlag;
|
||||
std::wstring sName;
|
||||
std::wstring sV;
|
||||
std::wstring sDV;
|
||||
std::vector<int> arrI;
|
||||
std::vector<std::wstring> arrV;
|
||||
std::vector<CAnnotFieldInfo::CWidgetAnnotPr::CActionWidget*> arrAction;
|
||||
std::vector< std::pair<std::wstring, std::wstring> > arrOpt;
|
||||
};
|
||||
|
||||
CWidgetsInfo();
|
||||
virtual ~CWidgetsInfo();
|
||||
|
||||
const std::vector<int>& GetCO();
|
||||
const std::vector< std::pair<int, int> >& GetCO();
|
||||
const std::vector<std::wstring>& GetButtonImg();
|
||||
const std::vector<CParent*>& GetParents();
|
||||
|
||||
void ChangeCO(int i, int nNum, int nGen);
|
||||
|
||||
bool Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMetafileToRenderter* pCorrector);
|
||||
|
||||
private:
|
||||
std::vector<int> m_arrCO;
|
||||
std::vector< std::pair<int, int> > m_arrCO;
|
||||
std::vector<std::wstring> m_arrButtonImg;
|
||||
std::vector<CParent*> m_arrParents;
|
||||
};
|
||||
|
||||
@ -7,7 +7,7 @@ import os
|
||||
|
||||
base.configure_common_apps()
|
||||
|
||||
base.cmd_in_dir("./../../../../../core/Common/js", "make.py", ["./../../DesktopEditor/graphics/pro/js/drawingfile.json"])
|
||||
base.cmd_in_dir("./../../../../../core/Common/js", sys.executable, ["make.py", "./../../DesktopEditor/graphics/pro/js/drawingfile.json"])
|
||||
|
||||
src_dir = "./deploy/"
|
||||
dst_dir = "./../../../../../sdkjs/pdf/src/engine/"
|
||||
|
||||
@ -51,6 +51,9 @@
|
||||
"_IsNeedCMap",
|
||||
"_SetCMapData",
|
||||
"_ScanPage",
|
||||
"_SplitPages",
|
||||
"_MergePages",
|
||||
"_UnmergePages",
|
||||
"_GetImageBase64",
|
||||
"_GetImageBase64Len",
|
||||
"_GetImageBase64Ptr",
|
||||
@ -67,6 +70,7 @@
|
||||
"../../../../PdfFile/lib/goo", "../../../../PdfFile/lib/fofi", "../../../../PdfFile/lib/splash", "../../../../PdfFile/lib",
|
||||
"../../../raster/Jp2/openjpeg", "../../../raster/Jp2/openjpeg/openjpeg-2.4.0/src/lib/openjp2",
|
||||
"../../../../Common/3dParty/openssl/openssl/include",
|
||||
"../../../../Common/3dParty/openssl/build/linux_64/include",
|
||||
"../../../../DocxRenderer"
|
||||
],
|
||||
"define": [
|
||||
@ -86,7 +90,7 @@
|
||||
"NO_CONSOLE_IO", "USE_EXTERNAL_JPEG2000", "USE_JPIP", "OPJ_STATIC", "FONT_ENGINE_DISABLE_FILESYSTEM",
|
||||
"IMAGE_CHECKER_DISABLE_XML",
|
||||
"USE_OPENSSL_HASH",
|
||||
"DISABLE_FULL_DOCUMENT_CREATION", "DISABLE_FILESYSTEM"
|
||||
"DISABLE_FULL_DOCUMENT_CREATION", "DISABLE_FILESYSTEM", "CRYPTOPP_DISABLE_ASM", "DISABLE_TYPE_MISMATCH"
|
||||
],
|
||||
"compile_files_array": [
|
||||
{
|
||||
@ -135,7 +139,7 @@
|
||||
},
|
||||
{
|
||||
"folder": "./wasm/src/",
|
||||
"files": ["lib/wasm_jmp.cpp", "drawingfile.cpp", "metafile.cpp", "pdfwriter.cpp", "HTMLRendererText.cpp"]
|
||||
"files": ["lib/wasm_jmp.cpp", "drawingfile.cpp", "metafile.cpp", "HTMLRendererText.cpp"]
|
||||
},
|
||||
{
|
||||
"folder": "freetype-2.10.4/src/",
|
||||
@ -143,7 +147,7 @@
|
||||
},
|
||||
{
|
||||
"folder": "../../",
|
||||
"files": ["GraphicsRenderer.cpp", "pro/pro_Graphics.cpp", "pro/pro_Fonts.cpp", "pro/pro_Image.cpp", "Graphics.cpp", "Brush.cpp", "BaseThread.cpp", "GraphicsPath.cpp", "BooleanOperations.cpp", "Image.cpp", "Matrix.cpp", "Clip.cpp", "TemporaryCS.cpp", "AlphaMask.cpp", "GraphicsLayer.cpp", "commands/DocInfo.cpp", "commands/AnnotField.cpp", "commands/FormField.cpp"]
|
||||
"files": ["GraphicsRenderer.cpp", "pro/pro_Graphics.cpp", "pro/pro_Fonts.cpp", "pro/pro_Image.cpp", "Graphics.cpp", "Brush.cpp", "BaseThread.cpp", "GraphicsPath.cpp", "BooleanOperations.cpp", "Image.cpp", "Matrix.cpp", "Clip.cpp", "TemporaryCS.cpp", "AlphaMask.cpp", "GraphicsLayer.cpp", "commands/DocInfo.cpp", "commands/AnnotField.cpp", "commands/FormField.cpp", "MetafileToRenderer.cpp", "MetafileToRendererReader.cpp"]
|
||||
},
|
||||
{
|
||||
"folder": "../../../fontengine/",
|
||||
@ -155,12 +159,16 @@
|
||||
},
|
||||
{
|
||||
"folder": "../../../common/",
|
||||
"files": ["File.cpp", "Directory.cpp", "ByteBuilder.cpp", "Base64.cpp", "StringExt.cpp", "Path.cpp"]
|
||||
"files": ["File.cpp", "Directory.cpp", "ByteBuilder.cpp", "Base64.cpp", "StringExt.cpp", "Path.cpp", "SystemUtils.cpp"]
|
||||
},
|
||||
{
|
||||
"folder": "../../../../Common/3dParty/icu/icu/source/common/",
|
||||
"files": ["ucnv.c", "ustr_wcs.cpp", "ucnv_err.c", "ucnv_bld.cpp", "ustrtrns.cpp", "ucnv_cb.c", "udata.cpp", "ucnv_io.cpp", "uhash.c", "udatamem.c", "cmemory.c", "ustring.cpp", "umutex.cpp", "putil.cpp", "ustr_cnv.cpp", "ucnvmbcs.cpp", "ucnvlat1.c", "ucnv_u16.c", "ucnv_u8.c", "ucnv_u32.c", "ucnv_u7.c", "ucln_cmn.cpp", "ucnv2022.cpp", "ucnv_lmb.c", "ucnvhz.c", "ucnvscsu.c", "ucnvisci.c", "ucnvbocu.cpp", "ucnv_ct.c", "ucnv_cnv.c", "stringpiece.cpp", "charstr.cpp", "umapfile.c", "ucmndata.c", "ucnv_ext.cpp", "uobject.cpp", "umath.c", "ubidi_props.c", "uchar.c", "uinvchar.c", "usprep.cpp", "unistr.cpp", "uniset_props.cpp", "loadednormalizer2impl.cpp", "filterednormalizer2.cpp", "utrie2.cpp", "normalizer2.cpp", "normalizer2impl.cpp", "utrie.cpp", "ucase.cpp", "uniset.cpp", "ruleiter.cpp", "parsepos.cpp", "util.cpp", "uprops.cpp", "uvector.cpp", "unames.cpp", "propname.cpp", "utrie2_builder.cpp", "unifunct.cpp", "bmpset.cpp", "unisetspan.cpp", "unifilt.cpp", "patternprops.cpp", "utf_impl.c", "ustrcase.cpp", "cstring.c", "bytestrie.cpp"]
|
||||
},
|
||||
{
|
||||
"folder": "../../../../Common/3dParty/cryptopp/",
|
||||
"files": ["cryptlib.cpp", "cpu.cpp", "integer.cpp", "3way.cpp", "adler32.cpp", "algebra.cpp", "algparam.cpp", "allocate.cpp", "arc4.cpp", "aria.cpp", "aria_simd.cpp", "ariatab.cpp", "asn.cpp", "authenc.cpp", "base32.cpp", "base64.cpp", "basecode.cpp", "bfinit.cpp", "blake2.cpp", "blake2s_simd.cpp", "blake2b_simd.cpp", "blowfish.cpp", "blumshub.cpp", "camellia.cpp", "cast.cpp", "casts.cpp", "cbcmac.cpp", "ccm.cpp", "chacha.cpp", "chacha_simd.cpp", "chacha_avx.cpp", "chachapoly.cpp", "cham.cpp", "cham_simd.cpp", "channels.cpp", "cmac.cpp", "crc.cpp", "crc_simd.cpp", "darn.cpp", "default.cpp", "des.cpp", "dessp.cpp", "dh.cpp", "dh2.cpp", "dll.cpp", "donna_32.cpp", "donna_64.cpp", "donna_sse.cpp", "dsa.cpp", "eax.cpp", "ec2n.cpp", "ecp.cpp", "eccrypto.cpp", "eprecomp.cpp", "elgamal.cpp", "emsa2.cpp", "eprecomp.cpp", "esign.cpp", "files.cpp", "filters.cpp", "fips140.cpp", "gcm.cpp", "gcm_simd.cpp", "gf256.cpp", "gf2_32.cpp", "gf2n.cpp", "gf2n_simd.cpp", "gfpcrypt.cpp", "gost.cpp", "gzip.cpp", "hc128.cpp", "hc256.cpp", "hex.cpp", "hight.cpp", "hmac.cpp", "hrtimer.cpp", "ida.cpp", "idea.cpp", "iterhash.cpp", "kalyna.cpp", "md5.cpp", "randpool.cpp", "osrng.cpp", "rijndael.cpp", "modes.cpp", "misc.cpp", "rdtables.cpp", "sha.cpp", "mqueue.cpp", "queue.cpp"]
|
||||
},
|
||||
{
|
||||
"folder": "../../../../OfficeUtils/src/",
|
||||
"files": ["OfficeUtils.cpp", "ZipBuffer.cpp", "ZipUtilsCP.cpp", "zlib_addon.c"]
|
||||
@ -179,7 +187,23 @@
|
||||
},
|
||||
{
|
||||
"folder": "../../../../PdfFile/",
|
||||
"files": ["SrcReader/Adaptors.cpp", "SrcReader/GfxClip.cpp", "SrcReader/RendererOutputDev.cpp", "SrcReader/JPXStream2.cpp", "SrcReader/PdfAnnot.cpp", "Resources/BaseFonts.cpp", "Resources/CMapMemory/cmap_memory.cpp", "lib/fofi/FofiBase.cc", "lib/fofi/FofiEncodings.cc", "lib/fofi/FofiIdentifier.cc", "lib/fofi/FofiTrueType.cc", "lib/fofi/FofiType1.cc", "lib/fofi/FofiType1C.cc", "lib/goo/FixedPoint.cc", "lib/goo/gfile.cc", "lib/goo/GHash.cc", "lib/goo/GList.cc", "lib/goo/gmem.cc", "lib/goo/gmempp.cc", "lib/goo/GString.cc", "lib/goo/parseargs.c", "lib/goo/Trace.cc", "lib/splash/Splash.cc", "lib/splash/SplashBitmap.cc", "lib/splash/SplashClip.cc", "lib/splash/SplashFont.cc", "lib/splash/SplashFontEngine.cc", "lib/splash/SplashFontFile.cc", "lib/splash/SplashFontFileID.cc", "lib/splash/SplashFTFont.cc", "lib/splash/SplashFTFontEngine.cc", "lib/splash/SplashFTFontFile.cc", "lib/splash/SplashPath.cc", "lib/splash/SplashPattern.cc", "lib/splash/SplashScreen.cc", "lib/splash/SplashState.cc", "lib/splash/SplashXPath.cc", "lib/splash/SplashXPathScanner.cc", "lib/xpdf/AcroForm.cc", "lib/xpdf/Annot.cc", "lib/xpdf/Array.cc", "lib/xpdf/BuiltinFont.cc", "lib/xpdf/BuiltinFontTables.cc", "lib/xpdf/Catalog.cc", "lib/xpdf/CharCodeToUnicode.cc", "lib/xpdf/CMap.cc", "lib/xpdf/Decrypt.cc", "lib/xpdf/Dict.cc", "lib/xpdf/DisplayState.cc", "lib/xpdf/Error.cc", "lib/xpdf/FontEncodingTables.cc", "lib/xpdf/Function.cc", "lib/xpdf/Gfx.cc", "lib/xpdf/GfxFont.cc", "lib/xpdf/GfxState.cc", "lib/xpdf/GlobalParams.cc", "lib/xpdf/ImageOutputDev.cc", "lib/xpdf/JArithmeticDecoder.cc", "lib/xpdf/JBIG2Stream.cc", "lib/xpdf/JPXStream.cc", "lib/xpdf/Lexer.cc", "lib/xpdf/Link.cc", "lib/xpdf/NameToCharCode.cc", "lib/xpdf/Object.cc", "lib/xpdf/OptionalContent.cc", "lib/xpdf/Outline.cc", "lib/xpdf/OutputDev.cc", "lib/xpdf/Page.cc", "lib/xpdf/Parser.cc", "lib/xpdf/PDF417Barcode.cc", "lib/xpdf/PDFCore.cc", "lib/xpdf/PDFDoc.cc", "lib/xpdf/PDFDocEncoding.cc", "lib/xpdf/PreScanOutputDev.cc", "lib/xpdf/PSOutputDev.cc", "lib/xpdf/PSTokenizer.cc", "lib/xpdf/SecurityHandler.cc", "lib/xpdf/ShadingImage.cc", "lib/xpdf/SplashOutputDev.cc", "lib/xpdf/Stream.cc", "lib/xpdf/TextOutputDev.cc", "lib/xpdf/TextString.cc", "lib/xpdf/TileCache.cc", "lib/xpdf/TileCompositor.cc", "lib/xpdf/TileMap.cc", "lib/xpdf/UnicodeMap.cc", "lib/xpdf/UnicodeRemapping.cc", "lib/xpdf/UnicodeTypeTable.cc", "lib/xpdf/UTF8.cc", "lib/xpdf/WebFont.cc", "lib/xpdf/XFAScanner.cc", "lib/xpdf/XRef.cc", "lib/xpdf/Zoox.cc", "PdfFile.cpp", "PdfReader.cpp"]
|
||||
"files": ["PdfFile.cpp", "PdfReader.cpp", "PdfWriter.cpp", "PdfEditor.cpp", "OnlineOfficeBinToPdf.cpp"]
|
||||
},
|
||||
{
|
||||
"folder": "../../../../PdfFile/SrcReader/",
|
||||
"files": ["Adaptors.cpp", "GfxClip.cpp", "RendererOutputDev.cpp", "JPXStream2.cpp", "PdfAnnot.cpp"]
|
||||
},
|
||||
{
|
||||
"folder": "../../../../PdfFile/SrcWriter/",
|
||||
"files": ["AcroForm.cpp", "Annotation.cpp", "Catalog.cpp", "Destination.cpp", "Document.cpp", "Encrypt.cpp", "EncryptDictionary.cpp", "Field.cpp", "Font.cpp", "Font14.cpp", "FontCidTT.cpp", "FontTT.cpp", "FontTTWriter.cpp", "GState.cpp", "Image.cpp", "Info.cpp", "Metadata.cpp", "Objects.cpp", "Outline.cpp", "Pages.cpp", "Pattern.cpp", "ResourcesDictionary.cpp", "Shading.cpp", "States.cpp", "Streams.cpp", "Utils.cpp"]
|
||||
},
|
||||
{
|
||||
"folder": "../../../../PdfFile/Resources/",
|
||||
"files": ["BaseFonts.cpp", "CMapMemory/cmap_memory.cpp"]
|
||||
},
|
||||
{
|
||||
"folder": "../../../../PdfFile/lib/",
|
||||
"files": ["fofi/FoFiBase.cc", "fofi/FoFiEncodings.cc", "fofi/FoFiIdentifier.cc", "fofi/FoFiTrueType.cc", "fofi/FoFiType1.cc", "fofi/FoFiType1C.cc", "goo/FixedPoint.cc", "goo/gfile.cc", "goo/GHash.cc", "goo/GList.cc", "goo/gmem.cc", "goo/gmempp.cc", "goo/GString.cc", "goo/parseargs.c", "goo/Trace.cc", "splash/Splash.cc", "splash/SplashBitmap.cc", "splash/SplashClip.cc", "splash/SplashFont.cc", "splash/SplashFontEngine.cc", "splash/SplashFontFile.cc", "splash/SplashFontFileID.cc", "splash/SplashFTFont.cc", "splash/SplashFTFontEngine.cc", "splash/SplashFTFontFile.cc", "splash/SplashPath.cc", "splash/SplashPattern.cc", "splash/SplashScreen.cc", "splash/SplashState.cc", "splash/SplashXPath.cc", "splash/SplashXPathScanner.cc", "xpdf/AcroForm.cc", "xpdf/Annot.cc", "xpdf/Array.cc", "xpdf/BuiltinFont.cc", "xpdf/BuiltinFontTables.cc", "xpdf/Catalog.cc", "xpdf/CharCodeToUnicode.cc", "xpdf/CMap.cc", "xpdf/Decrypt.cc", "xpdf/Dict.cc", "xpdf/DisplayState.cc", "xpdf/Error.cc", "xpdf/FontEncodingTables.cc", "xpdf/Function.cc", "xpdf/Gfx.cc", "xpdf/GfxFont.cc", "xpdf/GfxState.cc", "xpdf/GlobalParams.cc", "xpdf/ImageOutputDev.cc", "xpdf/JArithmeticDecoder.cc", "xpdf/JBIG2Stream.cc", "xpdf/JPXStream.cc", "xpdf/Lexer.cc", "xpdf/Link.cc", "xpdf/NameToCharCode.cc", "xpdf/Object.cc", "xpdf/OptionalContent.cc", "xpdf/Outline.cc", "xpdf/OutputDev.cc", "xpdf/Page.cc", "xpdf/Parser.cc", "xpdf/PDF417Barcode.cc", "xpdf/PDFCore.cc", "xpdf/PDFDoc.cc", "xpdf/PDFDocEncoding.cc", "xpdf/PreScanOutputDev.cc", "xpdf/PSOutputDev.cc", "xpdf/PSTokenizer.cc", "xpdf/SecurityHandler.cc", "xpdf/ShadingImage.cc", "xpdf/SplashOutputDev.cc", "xpdf/Stream.cc", "xpdf/TextOutputDev.cc", "xpdf/TextString.cc", "xpdf/TileCache.cc", "xpdf/TileCompositor.cc", "xpdf/TileMap.cc", "xpdf/UnicodeMap.cc", "xpdf/UnicodeRemapping.cc", "xpdf/UnicodeTypeTable.cc", "xpdf/UTF8.cc", "xpdf/WebFont.cc", "xpdf/XFAScanner.cc", "xpdf/XRef.cc", "xpdf/Zoox.cc"]
|
||||
},
|
||||
{
|
||||
"folder": "../../../raster/Jp2/openjpeg/openjpeg-2.4.0/src/lib/openjp2/",
|
||||
|
||||
@ -619,10 +619,7 @@ INCLUDEPATH += \
|
||||
$$PDF_ROOT_DIR/lib/splash \
|
||||
$$PDF_ROOT_DIR/lib
|
||||
|
||||
HEADERS += \
|
||||
$$PDF_ROOT_DIR/lib/aconf.h \
|
||||
$$$files($$PDF_ROOT_DIR/lib/*.h)
|
||||
|
||||
HEADERS += $$files($$PDF_ROOT_DIR/lib/*.h, true)
|
||||
SOURCES += $$files($$PDF_ROOT_DIR/lib/*.c, true)
|
||||
SOURCES += $$files($$PDF_ROOT_DIR/lib/*.cc, true)
|
||||
|
||||
@ -644,9 +641,7 @@ SOURCES += \
|
||||
$$PDF_ROOT_DIR/SrcReader/GfxClip.cpp \
|
||||
$$PDF_ROOT_DIR/SrcReader/PdfAnnot.cpp \
|
||||
$$PDF_ROOT_DIR/Resources/BaseFonts.cpp \
|
||||
$$PDF_ROOT_DIR/Resources/CMapMemory/cmap_memory.cpp \
|
||||
$$PDF_ROOT_DIR/PdfReader.cpp \
|
||||
$$PDF_ROOT_DIR/PdfFile.cpp
|
||||
$$PDF_ROOT_DIR/Resources/CMapMemory/cmap_memory.cpp
|
||||
|
||||
HEADERS +=\
|
||||
$$PDF_ROOT_DIR/Resources/Fontd050000l.h \
|
||||
@ -670,9 +665,87 @@ HEADERS +=\
|
||||
$$PDF_ROOT_DIR/SrcReader/MemoryUtils.h \
|
||||
$$PDF_ROOT_DIR/SrcReader/GfxClip.h \
|
||||
$$PDF_ROOT_DIR/SrcReader/FontsWasm.h \
|
||||
$$PDF_ROOT_DIR/SrcReader/PdfAnnot.h \
|
||||
$$PDF_ROOT_DIR/SrcReader/PdfAnnot.h
|
||||
|
||||
DEFINES += CRYPTOPP_DISABLE_ASM
|
||||
LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -lCryptoPPLib
|
||||
|
||||
# PdfWriter
|
||||
HEADERS += \
|
||||
$$PDF_ROOT_DIR/SrcWriter/AcroForm.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Annotation.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Catalog.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Consts.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Destination.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Document.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Encodings.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Encrypt.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/EncryptDictionary.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Field.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Font.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Font14.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/FontCidTT.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/FontTT.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/FontTTWriter.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/GState.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Image.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Info.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Objects.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Outline.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Pages.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Pattern.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/ResourcesDictionary.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Shading.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Streams.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Types.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Utils.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Metadata.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/ICCProfile.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/States.h
|
||||
|
||||
SOURCES += \
|
||||
$$PDF_ROOT_DIR/SrcWriter/AcroForm.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Annotation.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Catalog.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Destination.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Document.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Encrypt.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/EncryptDictionary.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Field.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Font.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Font14.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/FontCidTT.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/FontTT.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/FontTTWriter.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/GState.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Image.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Info.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Objects.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Outline.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Pages.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Pattern.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/ResourcesDictionary.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Shading.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Streams.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Utils.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Metadata.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/States.cpp
|
||||
|
||||
# PdfFile
|
||||
|
||||
HEADERS += \
|
||||
$$PDF_ROOT_DIR/PdfFile.h \
|
||||
$$PDF_ROOT_DIR/PdfWriter.h \
|
||||
$$PDF_ROOT_DIR/PdfReader.h \
|
||||
$$PDF_ROOT_DIR/PdfFile.h
|
||||
$$PDF_ROOT_DIR/PdfEditor.h \
|
||||
$$PDF_ROOT_DIR/OnlineOfficeBinToPdf.h
|
||||
|
||||
SOURCES += \
|
||||
$$PDF_ROOT_DIR/PdfFile.cpp \
|
||||
$$PDF_ROOT_DIR/PdfWriter.cpp \
|
||||
$$PDF_ROOT_DIR/PdfReader.cpp \
|
||||
$$PDF_ROOT_DIR/PdfEditor.cpp \
|
||||
$$PDF_ROOT_DIR/OnlineOfficeBinToPdf.cpp
|
||||
|
||||
# DocxRenderer
|
||||
DOCX_RENDERER_ROOT_DIR = $$CORE_ROOT_DIR/DocxRenderer
|
||||
@ -729,7 +802,6 @@ HEADERS += \
|
||||
../wasm/src/Text.h
|
||||
|
||||
SOURCES += \
|
||||
../wasm/src/pdfwriter.cpp \
|
||||
../wasm/src/HTMLRendererText.cpp \
|
||||
../wasm/src/drawingfile.cpp \
|
||||
../wasm/src/drawingfile_test.cpp
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -42,6 +42,19 @@ CNativePointer.prototype.free = function()
|
||||
g_native_drawing_file["FreeWasmData"](this.ptr);
|
||||
this.ptr = null;
|
||||
};
|
||||
CNativePointer.prototype.getMemory = function(isCopy)
|
||||
{
|
||||
if (!this.ptr)
|
||||
return null;
|
||||
|
||||
if (!isCopy)
|
||||
return this.ptr;
|
||||
|
||||
let copyArray = new Uint8Array(this.ptr.length);
|
||||
copyArray.set(this.ptr);
|
||||
|
||||
return copyArray;
|
||||
};
|
||||
CNativePointer.prototype.getReader = function()
|
||||
{
|
||||
if (!this.ptr)
|
||||
@ -94,6 +107,34 @@ CFile.prototype._getError = function()
|
||||
return g_native_drawing_file["GetErrorCode"]();
|
||||
};
|
||||
|
||||
CFile.prototype._SplitPages = function(pages, changes)
|
||||
{
|
||||
let dataChanges = null;
|
||||
if (changes)
|
||||
dataChanges = (undefined !== changes.byteLength) ? new Uint8Array(changes) : changes;
|
||||
g_module_pointer.ptr = g_native_drawing_file["SplitPages"](pages, dataChanges);
|
||||
return g_module_pointer;
|
||||
};
|
||||
|
||||
CFile.prototype._MergePages = function(buffer, maxID, prefixForm)
|
||||
{
|
||||
if (!buffer)
|
||||
return false;
|
||||
|
||||
if (!maxID)
|
||||
maxID = 0;
|
||||
if (!prefixForm)
|
||||
prefixForm = "";
|
||||
|
||||
let data = (undefined !== buffer.byteLength) ? new Uint8Array(buffer) : buffer;
|
||||
return g_native_drawing_file["MergePages"](data, maxID, prefixForm);
|
||||
};
|
||||
|
||||
CFile.prototype._UndoMergePages = function()
|
||||
{
|
||||
return g_native_drawing_file["UnmergePages"]();
|
||||
};
|
||||
|
||||
// FONTS
|
||||
CFile.prototype._isNeedCMap = function()
|
||||
{
|
||||
|
||||
@ -39,7 +39,7 @@ CWasmPointer.prototype.free = function()
|
||||
Module["_free"](this.ptr);
|
||||
this.ptr = 0;
|
||||
};
|
||||
CWasmPointer.prototype.getReader = function()
|
||||
CWasmPointer.prototype.getMemory = function(isCopy)
|
||||
{
|
||||
if (!this.ptr)
|
||||
return null;
|
||||
@ -59,8 +59,23 @@ CWasmPointer.prototype.getReader = function()
|
||||
}
|
||||
|
||||
len -= 4;
|
||||
let buffer = new Uint8Array(Module["HEAP8"].buffer, this.ptr + 4, len);
|
||||
return new CBinaryReader(buffer, 0, len);
|
||||
|
||||
let noCopyArray = new Uint8Array(Module["HEAP8"].buffer, this.ptr + 4, len);
|
||||
if (!isCopy)
|
||||
return noCopyArray;
|
||||
|
||||
let copyArray = new Uint8Array(len);
|
||||
copyArray.set(noCopyArray);
|
||||
|
||||
return copyArray;
|
||||
};
|
||||
CWasmPointer.prototype.getReader = function()
|
||||
{
|
||||
let noCopyArray = this.getMemory(false);
|
||||
if (!noCopyArray)
|
||||
return null;
|
||||
|
||||
return new CBinaryReader(noCopyArray, 0, noCopyArray.length);
|
||||
};
|
||||
|
||||
var g_module_pointer = new CWasmPointer();
|
||||
@ -86,8 +101,9 @@ CFile.prototype._openFile = function(buffer, password)
|
||||
{
|
||||
let data = new Uint8Array(buffer);
|
||||
this.stream_size = data.length;
|
||||
this.stream = Module["_malloc"](this.stream_size);
|
||||
Module["HEAP8"].set(data, this.stream);
|
||||
let stream = Module["_malloc"](this.stream_size);
|
||||
Module["HEAP8"].set(data, stream);
|
||||
this.stream.push(stream);
|
||||
}
|
||||
|
||||
let passwordPtr = 0;
|
||||
@ -98,7 +114,7 @@ CFile.prototype._openFile = function(buffer, password)
|
||||
Module["HEAP8"].set(passwordBuf, passwordPtr);
|
||||
}
|
||||
|
||||
this.nativeFile = Module["_Open"](this.stream, this.stream_size, passwordPtr);
|
||||
this.nativeFile = Module["_Open"](this.stream[0], this.stream_size, passwordPtr);
|
||||
|
||||
if (passwordPtr)
|
||||
Module["_free"](passwordPtr);
|
||||
@ -112,7 +128,7 @@ CFile.prototype._closeFile = function()
|
||||
|
||||
CFile.prototype._getType = function()
|
||||
{
|
||||
return Module["_GetType"](this.stream, this.stream_size);
|
||||
return Module["_GetType"](this.stream[0], this.stream_size);
|
||||
};
|
||||
|
||||
CFile.prototype._getError = function()
|
||||
@ -120,6 +136,72 @@ CFile.prototype._getError = function()
|
||||
return Module["_GetErrorCode"](this.nativeFile);
|
||||
};
|
||||
|
||||
CFile.prototype._SplitPages = function(memoryBuffer, arrayBufferChanges)
|
||||
{
|
||||
let changesPtr = 0;
|
||||
let changesLen = 0;
|
||||
if (arrayBufferChanges)
|
||||
{
|
||||
let changes = new Uint8Array(arrayBufferChanges);
|
||||
changesLen = changes.length;
|
||||
changesPtr = Module["_malloc"](changesLen);
|
||||
Module["HEAP8"].set(changes, changesPtr);
|
||||
}
|
||||
|
||||
let pointer = Module["_malloc"](memoryBuffer.length * 4);
|
||||
Module["HEAP32"].set(memoryBuffer, pointer >> 2);
|
||||
let ptr = Module["_SplitPages"](this.nativeFile, pointer, memoryBuffer.length, changesPtr, changesLen);
|
||||
Module["_free"](pointer);
|
||||
if (changesPtr)
|
||||
Module["_free"](changesPtr);
|
||||
|
||||
g_module_pointer.ptr = ptr;
|
||||
return g_module_pointer;
|
||||
};
|
||||
|
||||
CFile.prototype._MergePages = function(buffer, maxID, prefixForm)
|
||||
{
|
||||
if (!buffer)
|
||||
return false;
|
||||
|
||||
let data = (undefined !== buffer.byteLength) ? new Uint8Array(buffer) : buffer;
|
||||
let stream2 = Module["_malloc"](data.length);
|
||||
Module["HEAP8"].set(data, stream2);
|
||||
|
||||
if (!maxID)
|
||||
maxID = 0;
|
||||
|
||||
let prefixPtr = 0;
|
||||
if (prefixForm)
|
||||
{
|
||||
let prefixBuf = prefixForm.toUtf8();
|
||||
prefixPtr = Module["_malloc"](prefixBuf.length);
|
||||
Module["HEAP8"].set(prefixBuf, prefixPtr);
|
||||
}
|
||||
|
||||
let bRes = Module["_MergePages"](this.nativeFile, stream2, data.length, maxID, prefixPtr);
|
||||
if (bRes == 1)
|
||||
this.stream.push(stream2);
|
||||
else
|
||||
Module["_free"](stream2);
|
||||
|
||||
if (prefixPtr)
|
||||
Module["_free"](prefixPtr);
|
||||
|
||||
return bRes == 1;
|
||||
};
|
||||
|
||||
CFile.prototype._UndoMergePages = function()
|
||||
{
|
||||
let bRes = Module["_UnmergePages"](this.nativeFile);
|
||||
if (bRes == 1)
|
||||
{
|
||||
let str = this.stream.pop();
|
||||
Module["_free"](str);
|
||||
}
|
||||
return bRes == 1;
|
||||
};
|
||||
|
||||
// FONTS
|
||||
CFile.prototype._isNeedCMap = function()
|
||||
{
|
||||
|
||||
@ -42,6 +42,12 @@ CBinaryReader.prototype.readByte = function()
|
||||
this.pos += 1;
|
||||
return val;
|
||||
};
|
||||
CBinaryReader.prototype.readShort = function()
|
||||
{
|
||||
let val = this.data[this.pos] | this.data[this.pos + 1] << 8;
|
||||
this.pos += 2;
|
||||
return val;
|
||||
};
|
||||
CBinaryReader.prototype.readInt = function()
|
||||
{
|
||||
let val = this.data[this.pos] | this.data[this.pos + 1] << 8 | this.data[this.pos + 2] << 16 | this.data[this.pos + 3] << 24;
|
||||
@ -56,6 +62,10 @@ CBinaryReader.prototype.readDouble2 = function()
|
||||
{
|
||||
return this.readInt() / 10000;
|
||||
};
|
||||
CBinaryReader.prototype.readDouble3 = function()
|
||||
{
|
||||
return this.readInt() / 100000;
|
||||
};
|
||||
CBinaryReader.prototype.readString = function()
|
||||
{
|
||||
let len = this.readInt();
|
||||
@ -63,9 +73,20 @@ CBinaryReader.prototype.readString = function()
|
||||
this.pos += len;
|
||||
return val;
|
||||
};
|
||||
CBinaryReader.prototype.readString2 = function()
|
||||
{
|
||||
let len = this.readShort();
|
||||
let val = "";
|
||||
for (let i = 0; i < len; ++i)
|
||||
{
|
||||
let c = this.readShort();
|
||||
val += String.fromCharCode(c);
|
||||
}
|
||||
return val;
|
||||
};
|
||||
CBinaryReader.prototype.readData = function()
|
||||
{
|
||||
let len = this.readInt();
|
||||
let len = this.readInt() - 4;
|
||||
let val = this.data.slice(this.pos, this.pos + len);
|
||||
this.pos += len;
|
||||
return val;
|
||||
|
||||
@ -125,7 +125,7 @@ WASM_EXPORT BYTE* GetGlyphs(CDrawingFile* pFile, int nPageIndex)
|
||||
{
|
||||
return pFile->GetGlyphs(nPageIndex);
|
||||
}
|
||||
WASM_EXPORT BYTE* GetLinks (CDrawingFile* pFile, int nPageIndex)
|
||||
WASM_EXPORT BYTE* GetLinks(CDrawingFile* pFile, int nPageIndex)
|
||||
{
|
||||
return pFile->GetLinks(nPageIndex);
|
||||
}
|
||||
@ -177,6 +177,18 @@ WASM_EXPORT BYTE* ScanPage(CDrawingFile* pFile, int nPageIndex, int mode)
|
||||
{
|
||||
return pFile->ScanPage(nPageIndex, mode);
|
||||
}
|
||||
WASM_EXPORT BYTE* SplitPages(CDrawingFile* pFile, int* arrPageIndex, int nLength, BYTE* data, LONG size)
|
||||
{
|
||||
return pFile->SplitPages(arrPageIndex, nLength, data, size);
|
||||
}
|
||||
WASM_EXPORT int MergePages(CDrawingFile* pFile, BYTE* data, LONG size, int nMaxID, const char* sPrefixForm)
|
||||
{
|
||||
return pFile->MergePages(data, size, nMaxID, sPrefixForm) ? 1 : 0;
|
||||
}
|
||||
WASM_EXPORT int UnmergePages(CDrawingFile* pFile)
|
||||
{
|
||||
return pFile->UnmergePages() ? 1 : 0;
|
||||
}
|
||||
|
||||
WASM_EXPORT void* GetImageBase64(CDrawingFile* pFile, int rId)
|
||||
{
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -40,6 +40,7 @@ enum OfficeDrawingFileType
|
||||
odftPDF = 0,
|
||||
odftXPS = 1,
|
||||
odftDJVU = 2,
|
||||
odftOFD = 3,
|
||||
odftUndefined = 255
|
||||
};
|
||||
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
LIB_GRAPHICS_PRI_PATH=$$PWD/../..
|
||||
LIB_3DPARTY_PRI_PATH=$$LIB_GRAPHICS_PRI_PATH/../Common/3dParty/heif/lib/Debug
|
||||
!core_debug:LIB_3DPARTY_PRI_PATH=$$LIB_GRAPHICS_PRI_PATH/../Common/3dParty/heif/lib/Release
|
||||
|
||||
DEFINES -= UNICODE
|
||||
DEFINES -= _UNICODE
|
||||
@ -12,11 +14,24 @@ DEFINES += \
|
||||
MNG_SUPPORT_WRITE \
|
||||
MNG_ACCESS_CHUNKS \
|
||||
MNG_STORE_CHUNKS\
|
||||
MNG_ERROR_TELLTALE
|
||||
MNG_ERROR_TELLTALE\
|
||||
LIBHEIF_STATIC_BUILD
|
||||
|
||||
core_linux {
|
||||
DEFINES += HAVE_UNISTD_H HAVE_FCNTL_H
|
||||
QMAKE_CXXFLAGS += -Wno-narrowing
|
||||
LIBS += -L$$LIB_3DPARTY_PRI_PATH \
|
||||
-lheif \
|
||||
-lde265 \
|
||||
-lx265
|
||||
}
|
||||
|
||||
core_linux_clang {
|
||||
QMAKE_CFLAGS += -Wno-incompatible-function-pointer-types
|
||||
LIBS += -L$$LIB_3DPARTY_PRI_PATH \
|
||||
-lheif \
|
||||
-lde265 \
|
||||
-lx265
|
||||
}
|
||||
|
||||
core_mac {
|
||||
@ -26,6 +41,10 @@ core_mac {
|
||||
core_windows {
|
||||
DEFINES += JAS_WIN_MSVC_BUILD NOMINMAX
|
||||
LIBS += -lUser32
|
||||
LIBS += -L$$LIB_3DPARTY_PRI_PATH \
|
||||
-lheif \
|
||||
-llibde265 \
|
||||
-lx265-static
|
||||
}
|
||||
|
||||
core_android {
|
||||
@ -35,7 +54,8 @@ core_android {
|
||||
INCLUDEPATH += \
|
||||
$$LIB_GRAPHICS_PRI_PATH/cximage/jasper/include \
|
||||
$$LIB_GRAPHICS_PRI_PATH/cximage/jpeg \
|
||||
$$LIB_GRAPHICS_PRI_PATH/cximage/png
|
||||
$$LIB_GRAPHICS_PRI_PATH/cximage/png \
|
||||
$$LIB_GRAPHICS_PRI_PATH/../Common/3dParty/heif/libheif/libheif/api \
|
||||
|
||||
HEADERS += \
|
||||
$$PWD/../../graphics/Image.h \
|
||||
@ -281,6 +301,9 @@ SOURCES += \
|
||||
$$LIB_GRAPHICS_PRI_PATH/raster/PICT/PICFile.cpp \
|
||||
$$LIB_GRAPHICS_PRI_PATH/raster/PICT/pic.cpp
|
||||
|
||||
SOURCES += \
|
||||
$$LIB_GRAPHICS_PRI_PATH/raster/heif/heif.cpp
|
||||
|
||||
SOURCES += \
|
||||
$$LIB_GRAPHICS_PRI_PATH/cximage/jasper/base/jas_cm.c \
|
||||
$$LIB_GRAPHICS_PRI_PATH/cximage/jasper/base/jas_debug.c \
|
||||
|
||||
@ -371,6 +371,7 @@ namespace NSStructures
|
||||
*
|
||||
* Наверное напишу адаптор который переводит порядок точек из 6 типа в общий.
|
||||
*/
|
||||
agg::rgba8 fill_color;
|
||||
std::vector<std::vector<Point>> patch;
|
||||
std::vector<std::vector<agg::rgba8>> patch_colors; // 2 на 2 цвета по углам
|
||||
std::vector<std::vector<float>> patch_parameters; // 2 на 2 параметра
|
||||
@ -388,8 +389,8 @@ namespace NSStructures
|
||||
xsize(1.0f), ysize(1.0f),
|
||||
linstretch(1.0f), linoffset(0.0f),
|
||||
continue_shading_f(false),
|
||||
continue_shading_b(false)
|
||||
|
||||
continue_shading_b(false),
|
||||
luminocity(false)
|
||||
{
|
||||
}
|
||||
void setAngleDegrees(float deg)
|
||||
@ -404,6 +405,57 @@ namespace NSStructures
|
||||
{
|
||||
discrete_step = 1.0f / n;
|
||||
}
|
||||
bool checkLuminosity() const
|
||||
{
|
||||
if (shading.patch_colors.empty())
|
||||
return false;
|
||||
|
||||
for (const auto& ar : shading.patch_colors)
|
||||
for (const auto& c : ar)
|
||||
if (c.r != c.g || c.g != c.b)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
bool colorEqual(const agg::rgba8& c1, const agg::rgba8& c2) const
|
||||
{
|
||||
return c1.r == c2.r &&
|
||||
c1.g == c2.g &&
|
||||
c1.b == c2.b &&
|
||||
c1.a == c2.a;
|
||||
}
|
||||
bool isOneColor() const
|
||||
{
|
||||
switch (shading.shading_type)
|
||||
{
|
||||
case ShadingInfo::FunctionOnly:
|
||||
case ShadingInfo::Parametric:
|
||||
return false;
|
||||
case ShadingInfo::TriangleInterpolation:
|
||||
return colorEqual(shading.triangle_colors[0], shading.triangle_colors[1]) &&
|
||||
colorEqual(shading.triangle_colors[1], shading.triangle_colors[2]);
|
||||
case ShadingInfo::CurveInterpolation:
|
||||
case ShadingInfo::TensorCurveInterpolation:
|
||||
return colorEqual(shading.patch_colors[0][0], shading.patch_colors[0][1]) &&
|
||||
colorEqual(shading.patch_colors[0][1], shading.patch_colors[1][0]) &&
|
||||
colorEqual(shading.patch_colors[1][0], shading.patch_colors[1][1]);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
agg::rgba8 getFillColor() const
|
||||
{
|
||||
if (!shading.triangle_colors.empty())
|
||||
return shading.triangle_colors[0];
|
||||
if (!shading.patch_colors.empty())
|
||||
return shading.patch_colors[0][0];
|
||||
return agg::rgba8(0, 0, 0);
|
||||
}
|
||||
void setFillColor(const agg::rgba8& color)
|
||||
{
|
||||
shading.fill_color = color;
|
||||
luminocity = true;
|
||||
}
|
||||
void transform(const Aggplus::CMatrix& matrix)
|
||||
{
|
||||
// shading transform
|
||||
@ -502,6 +554,7 @@ namespace NSStructures
|
||||
float linstretch; // stretch linear gradient, can be negative (eq angle = 180) can not be zero
|
||||
float linoffset; // offset relative to image size
|
||||
float continue_shading_b, continue_shading_f;
|
||||
bool luminocity;
|
||||
ShadingInfo shading;
|
||||
};
|
||||
|
||||
@ -643,6 +696,7 @@ namespace NSStructures
|
||||
const std::vector<std::vector<float>> &curve_parametrs,
|
||||
const std::vector<std::vector<agg::rgba8>> &curve_colors,
|
||||
bool parametric,
|
||||
bool luminosity = false,
|
||||
float t0 = 0.0f, float t1 = 1.0f)
|
||||
{
|
||||
GradientInfo ginfo;
|
||||
@ -651,6 +705,7 @@ namespace NSStructures
|
||||
|
||||
ginfo.shading.f_type = ShadingInfo::UseNew;
|
||||
ginfo.shading.function = ColorFunction<agg::rgba8>(256, t0, t1);
|
||||
ginfo.luminocity = luminosity;
|
||||
ginfo.continue_shading_f = false;
|
||||
ginfo.continue_shading_b = false;
|
||||
|
||||
|
||||
9
DesktopEditor/graphics/tests/testHeic/main.cpp
Normal file
9
DesktopEditor/graphics/tests/testHeic/main.cpp
Normal file
@ -0,0 +1,9 @@
|
||||
#include "../../pro/Graphics.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
Aggplus::CImage img(L"C:\\Users\\KProkhorov\\Work\\core\\DesktopEditor\\graphics\\tests\\testHeic\\image1.heic");
|
||||
img.SaveFile(L"C:\\Users\\KProkhorov\\Work\\core\\DesktopEditor\\graphics\\tests\\testHeic\\image1.bmp", 1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
23
DesktopEditor/graphics/tests/testHeic/testHeic.pro
Normal file
23
DesktopEditor/graphics/tests/testHeic/testHeic.pro
Normal file
@ -0,0 +1,23 @@
|
||||
QT -= core
|
||||
|
||||
QT -= gui
|
||||
|
||||
TARGET = test
|
||||
CONFIG += console
|
||||
TEMPLATE = app
|
||||
|
||||
CORE_ROOT_DIR = $$PWD/../../../..
|
||||
PWD_ROOT_DIR = $$PWD
|
||||
include($$CORE_ROOT_DIR/Common/base.pri)
|
||||
include($$CORE_ROOT_DIR/Common/3dParty/icu/icu.pri)
|
||||
|
||||
ADD_DEPENDENCY(kernel, graphics, UnicodeConverter)
|
||||
|
||||
GRAPHICS_AGG_PATH = $$PWD/../../../agg-2.4
|
||||
|
||||
INCLUDEPATH += \
|
||||
$$GRAPHICS_AGG_PATH/include
|
||||
|
||||
SOURCES += main.cpp
|
||||
|
||||
DESTDIR = $$PWD_ROOT_DIR/build/$$CORE_BUILDS_PLATFORM_PREFIX/$$CORE_BUILDS_CONFIGURATION_PREFIX
|
||||
@ -44,6 +44,10 @@
|
||||
#include "PICT/PICFile.h"
|
||||
#endif
|
||||
|
||||
#if CXIMAGE_SUPPORT_HEIF
|
||||
#include "heif/heif.h"
|
||||
#endif
|
||||
|
||||
#include <cmath>
|
||||
#define BGRA_FRAME_CXIMAGE_MAX_MEMORY 67108864 // 256Mb (*4 channel)
|
||||
|
||||
@ -444,11 +448,18 @@ bool CBgraFrame::OpenFile(const std::wstring& strFileName, unsigned int nFileTyp
|
||||
#endif
|
||||
|
||||
#if CXIMAGE_SUPPORT_PIC
|
||||
if (CXIMAGE_FORMAR_PIC == m_nFileType)
|
||||
{
|
||||
PICT::CPictFile PIC;
|
||||
return PIC.Open(this, strFileName, !m_bIsRGBA);
|
||||
}
|
||||
if (CXIMAGE_FORMAR_PIC == m_nFileType)
|
||||
{
|
||||
PICT::CPictFile PIC;
|
||||
return PIC.Open(this, strFileName, !m_bIsRGBA);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if CXIMAGE_SUPPORT_HEIF
|
||||
if (CXIMAGE_FORMAT_HEIF == m_nFileType)
|
||||
{
|
||||
return NSHeif::CHeifFile::Open(this, strFileName);
|
||||
}
|
||||
#endif
|
||||
|
||||
NSFile::CFileBinary oFile;
|
||||
@ -534,6 +545,13 @@ bool CBgraFrame::Decode(BYTE* pBuffer, int nSize, unsigned int nFileType)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if CXIMAGE_SUPPORT_HEIF
|
||||
if (CXIMAGE_FORMAT_HEIF == m_nFileType)
|
||||
{
|
||||
return NSHeif::CHeifFile::Open(this, pBuffer, nSize);
|
||||
}
|
||||
#endif
|
||||
|
||||
CxImage img;
|
||||
|
||||
if (!img.Decode(pBuffer, nSize, m_nFileType))
|
||||
@ -562,28 +580,32 @@ bool CBgraFrame::SaveFile(const std::wstring& strFileName, unsigned int nFileTyp
|
||||
|
||||
return res;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#if CXIMAGE_SUPPORT_HEIF
|
||||
if (CXIMAGE_FORMAT_HEIF == nFileType)
|
||||
{
|
||||
NSFile::CFileBinary oFile;
|
||||
if (!oFile.CreateFileW(strFileName))
|
||||
return false;
|
||||
|
||||
CxImage img;
|
||||
|
||||
if (!img.CreateFromArray(m_pData, m_lWidth, m_lHeight, lBitsPerPixel * 8, lStride, (m_lStride >= 0) ? true : false, !m_bIsRGBA))
|
||||
return false;
|
||||
|
||||
if (m_pPalette)
|
||||
{
|
||||
img.SetPalette((RGBQUAD*)m_pPalette, m_lPaletteColors);
|
||||
}
|
||||
|
||||
if (!img.Encode(oFile.GetFileNative(), nFileType))
|
||||
return false;
|
||||
|
||||
oFile.CloseFile();
|
||||
return NSHeif::CHeifFile::Save(m_pData, m_lWidth, m_lHeight, m_lStride, strFileName);
|
||||
}
|
||||
#endif
|
||||
|
||||
NSFile::CFileBinary oFile;
|
||||
if (!oFile.CreateFileW(strFileName))
|
||||
return false;
|
||||
|
||||
CxImage img;
|
||||
|
||||
if (!img.CreateFromArray(m_pData, m_lWidth, m_lHeight, lBitsPerPixel * 8, lStride, (m_lStride >= 0) ? true : false, !m_bIsRGBA))
|
||||
return false;
|
||||
|
||||
if (m_pPalette)
|
||||
{
|
||||
img.SetPalette((RGBQUAD*)m_pPalette, m_lPaletteColors);
|
||||
}
|
||||
|
||||
if (!img.Encode(oFile.GetFileNative(), nFileType))
|
||||
return false;
|
||||
|
||||
oFile.CloseFile();
|
||||
return true;
|
||||
}
|
||||
bool CBgraFrame::Encode(BYTE*& pBuffer, int& nSize, unsigned int nFileType)
|
||||
|
||||
@ -32,6 +32,7 @@
|
||||
#include "ImageFileFormatChecker.h"
|
||||
#include "../common/File.h"
|
||||
#include "../cximage/CxImage/ximacfg.h"
|
||||
#include "heif/heif.h"
|
||||
|
||||
#ifndef IMAGE_CHECKER_DISABLE_XML
|
||||
#include "../xml/include/xmlutils.h"
|
||||
@ -58,7 +59,7 @@ CImageFileFormatChecker::CImageFileFormatChecker()
|
||||
{
|
||||
eFileType = _CXIMAGE_FORMAT_UNKNOWN;
|
||||
}
|
||||
CImageFileFormatChecker::CImageFileFormatChecker(std::wstring sFileName)
|
||||
CImageFileFormatChecker::CImageFileFormatChecker(const std::wstring& sFileName)
|
||||
{
|
||||
eFileType = _CXIMAGE_FORMAT_UNKNOWN;
|
||||
isImageFile(sFileName);
|
||||
@ -432,8 +433,13 @@ bool CImageFileFormatChecker::isPicFile(BYTE *pBuffer, DWORD dwBytes)
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CImageFileFormatChecker::isHeifFile(BYTE* pBuffer, DWORD dwBytes)
|
||||
{
|
||||
return NSHeif::CHeifFile::isHeif(pBuffer, dwBytes);
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
bool CImageFileFormatChecker::isImageFile(std::wstring& fileName)
|
||||
bool CImageFileFormatChecker::isImageFile(const std::wstring& fileName)
|
||||
{
|
||||
eFileType = _CXIMAGE_FORMAT_UNKNOWN;
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@ -554,6 +560,10 @@ bool CImageFileFormatChecker::isImageFile(std::wstring& fileName)
|
||||
{
|
||||
eFileType = _CXIMAGE_FORMAT_PIC;
|
||||
}
|
||||
else if (isHeifFile(fileName))
|
||||
{
|
||||
eFileType = _CXIMAGE_FORMAT_HEIF;
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
delete [] buffer;
|
||||
|
||||
@ -669,11 +679,15 @@ bool CImageFileFormatChecker::isImageFile(BYTE* buffer, DWORD sizeRead)
|
||||
{
|
||||
eFileType = _CXIMAGE_FORMAT_PIC;
|
||||
}
|
||||
if (isHeifFile(buffer, sizeRead))
|
||||
{
|
||||
eFileType = _CXIMAGE_FORMAT_HEIF;
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
if (eFileType) return true;
|
||||
return false;
|
||||
}
|
||||
bool CImageFileFormatChecker::isSvmFile(std::wstring & fileName)
|
||||
bool CImageFileFormatChecker::isSvmFile(const std::wstring & fileName)
|
||||
{
|
||||
eFileType = _CXIMAGE_FORMAT_UNKNOWN;
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -703,7 +717,7 @@ bool CImageFileFormatChecker::isSvmFile(std::wstring & fileName)
|
||||
if (eFileType)return true;
|
||||
else return false;
|
||||
}
|
||||
bool CImageFileFormatChecker::isPngFile(std::wstring & fileName)
|
||||
bool CImageFileFormatChecker::isPngFile(const std::wstring & fileName)
|
||||
{
|
||||
eFileType = _CXIMAGE_FORMAT_UNKNOWN;
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -735,7 +749,7 @@ bool CImageFileFormatChecker::isPngFile(std::wstring & fileName)
|
||||
|
||||
}
|
||||
|
||||
bool CImageFileFormatChecker::isRawFile(std::wstring& fileName)
|
||||
bool CImageFileFormatChecker::isRawFile(const std::wstring& fileName)
|
||||
{
|
||||
// TODO:
|
||||
return false;
|
||||
@ -745,7 +759,7 @@ bool CImageFileFormatChecker::isRawFile(BYTE* pBuffer, DWORD dwBytes)
|
||||
// TODO:
|
||||
return false;
|
||||
}
|
||||
bool CImageFileFormatChecker::isSvgFile(std::wstring& fileName)
|
||||
bool CImageFileFormatChecker::isSvgFile(const std::wstring& fileName)
|
||||
{
|
||||
#ifndef IMAGE_CHECKER_DISABLE_XML
|
||||
XmlUtils::CXmlLiteReader oReader;
|
||||
@ -786,6 +800,10 @@ bool CImageFileFormatChecker::isSvgFile(std::wstring& fileName)
|
||||
return bFind;
|
||||
#endif
|
||||
}
|
||||
bool CImageFileFormatChecker::isHeifFile(const std::wstring& fileName)
|
||||
{
|
||||
return NSHeif::CHeifFile::isHeif(fileName);
|
||||
}
|
||||
|
||||
std::wstring CImageFileFormatChecker::DetectFormatByData(BYTE *Data, int DataSize)
|
||||
{
|
||||
|
||||
@ -63,6 +63,7 @@ enum __ENUM_CXIMAGE_FORMATS
|
||||
_CXIMAGE_FORMAT_SVM = 23,
|
||||
_CXIMAGE_FORMAT_SVG = 24,
|
||||
_CXIMAGE_FORMAT_PIC = 25,
|
||||
_CXIMAGE_FORMAT_HEIF = 26,
|
||||
};
|
||||
|
||||
class GRAPHICS_DECL CImageFileFormatChecker
|
||||
@ -71,17 +72,18 @@ public:
|
||||
__ENUM_CXIMAGE_FORMATS eFileType;
|
||||
|
||||
CImageFileFormatChecker();
|
||||
CImageFileFormatChecker(std::wstring sFileName);
|
||||
CImageFileFormatChecker(const std::wstring& sFileName);
|
||||
CImageFileFormatChecker(BYTE* pBuffer, DWORD dwBytes);
|
||||
|
||||
bool isImageFileInZip(std::wstring& fileName);
|
||||
bool isImageFileInZip(const std::wstring& fileName);
|
||||
|
||||
bool isImageFile(std::wstring& fileName);
|
||||
bool isPngFile(std::wstring& fileName);
|
||||
bool isSvmFile(std::wstring& fileName);
|
||||
bool isImageFile(const std::wstring& fileName);
|
||||
bool isPngFile(const std::wstring& fileName);
|
||||
bool isSvmFile(const std::wstring& fileName);
|
||||
|
||||
bool isRawFile(std::wstring& fileName);
|
||||
bool isSvgFile(std::wstring& fileName);
|
||||
bool isRawFile(const std::wstring& fileName);
|
||||
bool isSvgFile(const std::wstring& fileName);
|
||||
bool isHeifFile(const std::wstring& fileName);
|
||||
|
||||
bool isImageFile(BYTE* pBuffer,DWORD dwBytes);
|
||||
bool isBmpFile(BYTE* pBuffer,DWORD dwBytes);
|
||||
@ -111,6 +113,7 @@ public:
|
||||
bool isSvgFile(BYTE* pBuffer,DWORD dwBytes);
|
||||
bool isRawFile(BYTE* pBuffer,DWORD dwBytes);
|
||||
bool isPicFile(BYTE* pBuffer,DWORD dwBytes);
|
||||
bool isHeifFile(BYTE* pBuffer, DWORD dwBytes);
|
||||
|
||||
std::wstring DetectFormatByData(BYTE *Data, int DataSize);
|
||||
|
||||
|
||||
@ -50,7 +50,7 @@ namespace MetaFile
|
||||
virtual void End() = 0;
|
||||
|
||||
// pBuffer - BGRA картинка размерами ulWidth, ulHeight, которую надо нарисовать в заданном ректе
|
||||
virtual void DrawBitmap(double dX, double dY, double dW, double dH, BYTE* pBuffer, unsigned int unWidth, unsigned int unHeight) = 0;
|
||||
virtual void DrawBitmap(double dX, double dY, double dW, double dH, BYTE* pBuffer, unsigned int unWidth, unsigned int unHeight, unsigned int nBlendMode) = 0;
|
||||
|
||||
virtual void DrawString(std::wstring& wsText, unsigned int unCharsCount, double dX, double dY, double* pDx,
|
||||
int iGraphicsMode = 1, double dXScale = 1, double dYScale = 1) = 0;
|
||||
|
||||
@ -236,7 +236,7 @@ namespace MetaFile
|
||||
m_bUpdatedClip = false;
|
||||
}
|
||||
|
||||
void DrawBitmap(double dX, double dY, double dW, double dH, BYTE* pBuffer, unsigned int unWidth, unsigned int unHeight)
|
||||
void DrawBitmap(double dX, double dY, double dW, double dH, BYTE* pBuffer, unsigned int unWidth, unsigned int unHeight, unsigned int unBlendMode)
|
||||
{
|
||||
if (!pBuffer || 0 == unWidth || 0 == unHeight)
|
||||
return;
|
||||
@ -284,7 +284,11 @@ namespace MetaFile
|
||||
m_pRenderer->SetTransform(dKx * dM11, dKx * dM12, dKy * dM21, dKy * dM22, dShiftKoefX * dM11 + dShiftKoefY * dM21 + dMx, dShiftKoefX * dM12 + dShiftKoefY * dM22 + dMy);
|
||||
}
|
||||
|
||||
m_pRenderer->BeginCommand(c_nLayerType);
|
||||
m_pRenderer->put_BlendMode(unBlendMode);
|
||||
m_pRenderer->DrawImage(&oImage, dImageX, dImageY, dImageW, dImageH);
|
||||
m_pRenderer->EndCommand(c_nLayerType);
|
||||
m_pRenderer->put_BlendMode(BLEND_MODE_DEFAULT);
|
||||
}
|
||||
void DrawDriverString(const std::wstring& wsString, const std::vector<TPointD>& arPoints)
|
||||
{
|
||||
|
||||
@ -34,6 +34,7 @@
|
||||
|
||||
#include <string>
|
||||
#include <cfloat>
|
||||
#include <cmath>
|
||||
#include "../../../common/StringExt.h"
|
||||
|
||||
#ifndef BYTE
|
||||
@ -347,6 +348,12 @@ typedef unsigned char BYTE;
|
||||
#define HS_OUTLINEDDIAMOND 51
|
||||
#define HS_SOLIDDIAMOND 52
|
||||
|
||||
//Blend mode's
|
||||
#define BLEND_MODE_SRC_OVER 3
|
||||
#define BLEND_MODE_XOR 11
|
||||
#define BLEND_MODE_DRAW_ON_BLACK 28
|
||||
#define BLEND_MODE_DEFAULT BLEND_MODE_SRC_OVER
|
||||
|
||||
namespace MetaFile
|
||||
{
|
||||
#define DEFAULT_FONT_SIZE 14
|
||||
|
||||
@ -93,7 +93,7 @@ namespace MetaFile
|
||||
|
||||
return false;
|
||||
}
|
||||
bool ReadImageInfoHeader(BYTE* pHeaderBuffer, unsigned int ulHeaderBufferLen, BYTE* pImageBuffer, unsigned int ulImageBufferLen, BYTE** ppDstBuffer, unsigned int* pulWidth, unsigned int* pulHeight)
|
||||
bool ReadImageInfoHeader(BYTE* pHeaderBuffer, unsigned int ulHeaderBufferLen, BYTE* pImageBuffer, unsigned int ulImageBufferLen, BYTE** ppDstBuffer, unsigned int* pulWidth, unsigned int* pulHeight, unsigned int& unColorUsed)
|
||||
{
|
||||
CDataStream oHeaderStream;
|
||||
oHeaderStream.SetStream(pHeaderBuffer, ulHeaderBufferLen);
|
||||
@ -108,7 +108,6 @@ namespace MetaFile
|
||||
unsigned int unImageSize;
|
||||
unsigned int unXPelsPerMeter;
|
||||
unsigned int unYPelsPerMeter;
|
||||
unsigned int unColorUsed;
|
||||
unsigned int unColorImportant;
|
||||
|
||||
oHeaderStream >> nWidth;
|
||||
@ -817,7 +816,7 @@ namespace MetaFile
|
||||
|
||||
return false;
|
||||
}
|
||||
void ReadImage(BYTE* pHeaderBuffer, unsigned int ulHeaderBufferLen, BYTE* pImageBuffer, unsigned int ulImageBufferLen, BYTE** ppDstBuffer, unsigned int* pulWidth, unsigned int* pulHeight)
|
||||
void ReadImage(BYTE* pHeaderBuffer, unsigned int ulHeaderBufferLen, BYTE* pImageBuffer, unsigned int ulImageBufferLen, BYTE** ppDstBuffer, unsigned int* pulWidth, unsigned int* pulHeight, unsigned int& unColorUsed)
|
||||
{
|
||||
if (ulHeaderBufferLen <= 0 || NULL == pHeaderBuffer || NULL == pImageBuffer || ulImageBufferLen < 0)
|
||||
return;
|
||||
@ -834,9 +833,9 @@ namespace MetaFile
|
||||
else if (0x0000000C == ulHeaderSize) // BitmapCoreHeader
|
||||
ReadImageCoreHeader(pHeaderBuffer + 4, ulHeaderBufferLen - 4, pImageBuffer, ulImageBufferLen, ppDstBuffer, pulWidth, pulHeight);
|
||||
else // BitmapInfoHeader
|
||||
ReadImageInfoHeader(pHeaderBuffer + 4, ulHeaderBufferLen - 4, pImageBuffer, ulImageBufferLen, ppDstBuffer, pulWidth, pulHeight);
|
||||
ReadImageInfoHeader(pHeaderBuffer + 4, ulHeaderBufferLen - 4, pImageBuffer, ulImageBufferLen, ppDstBuffer, pulWidth, pulHeight, unColorUsed);
|
||||
}
|
||||
void ReadImage(BYTE* pImageBuffer, unsigned int unBufferLen, unsigned int unColorUsage, BYTE** ppDstBuffer, unsigned int* punWidth, unsigned int* punHeight)
|
||||
void ReadImage(BYTE* pImageBuffer, unsigned int unBufferLen, unsigned int unColorUsage, BYTE** ppDstBuffer, unsigned int* punWidth, unsigned int* punHeight, unsigned int& unColorUsed)
|
||||
{
|
||||
if (unBufferLen <= 0 || NULL == pImageBuffer)
|
||||
return;
|
||||
@ -866,7 +865,7 @@ namespace MetaFile
|
||||
unsigned int unImageSize;
|
||||
unsigned int unXPelsPerMeter;
|
||||
unsigned int unYPelsPerMeter;
|
||||
unsigned int unColorUsed;
|
||||
// unsigned int unColorUsed;
|
||||
unsigned int unColorImportant;
|
||||
|
||||
oHeaderStream >> nWidth;
|
||||
@ -897,7 +896,7 @@ namespace MetaFile
|
||||
}
|
||||
|
||||
unHeaderSize += 4 * unColorUsed; // RGBQuad
|
||||
ReadImageInfoHeader(pImageBuffer + 4, unHeaderSize - 4, pImageBuffer + unHeaderSize, unBufferLen - unHeaderSize, ppDstBuffer, punWidth, punHeight);
|
||||
ReadImageInfoHeader(pImageBuffer + 4, unHeaderSize - 4, pImageBuffer + unHeaderSize, unBufferLen - unHeaderSize, ppDstBuffer, punWidth, punHeight, unColorUsed);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -982,21 +981,6 @@ namespace MetaFile
|
||||
for (unsigned int unIndex = 3; unIndex < unWidth * 4 * unHeight; unIndex += 4)
|
||||
pBgra[unIndex] = 0xff;
|
||||
}
|
||||
else if (0x00660046 == unRasterOperation) //SRCINVERT
|
||||
{
|
||||
BYTE* pCur = pBgra;
|
||||
|
||||
for (unsigned int unY = 0; unY < unHeight; unY++)
|
||||
{
|
||||
for (unsigned int unX = 0; unX < unWidth; unX++)
|
||||
{
|
||||
unsigned int unIndex = (unY * unWidth + unX) * 4;
|
||||
|
||||
if (0x00 == pCur[unIndex + 0] && 0x00 == pCur[unIndex + 1] && 0x00 == pCur[unIndex + 2])
|
||||
pCur[unIndex + 3] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::wstring GetTempFilename(const std::wstring& sFolder)
|
||||
|
||||
@ -1174,8 +1174,8 @@ namespace MetaFile
|
||||
BYTE *pEnd;
|
||||
};
|
||||
|
||||
void ReadImage(BYTE* pHeaderBuffer, unsigned int ulHeaderBufferLen, BYTE* pImageBuffer, unsigned int ulImageBufferLen, BYTE** ppDstBuffer, unsigned int* pulWidth, unsigned int* pulHeight);
|
||||
void ReadImage(BYTE* pImageBuffer, unsigned int unBufferLen, unsigned int unColorUsage, BYTE** ppDstBuffer, unsigned int* punWidth, unsigned int* punHeight);
|
||||
void ReadImage(BYTE* pHeaderBuffer, unsigned int ulHeaderBufferLen, BYTE* pImageBuffer, unsigned int ulImageBufferLen, BYTE** ppDstBuffer, unsigned int* pulWidth, unsigned int* pulHeight, unsigned int& unColorUsed);
|
||||
void ReadImage(BYTE* pImageBuffer, unsigned int unBufferLen, unsigned int unColorUsage, BYTE** ppDstBuffer, unsigned int* punWidth, unsigned int* punHeight, unsigned int& unColorUsed);
|
||||
double GetEllipseAngle(int nL, int nT, int nR, int nB, int nX, int nY);
|
||||
void ProcessRasterOperation(unsigned int unRasterOperation, BYTE** ppBgra, unsigned int unWidth, unsigned int unHeight);
|
||||
std::wstring GetTempFilename(const std::wstring& sFolder = L"");
|
||||
|
||||
@ -215,7 +215,7 @@ namespace MetaFile
|
||||
void Begin() override {};
|
||||
void End() override {};
|
||||
|
||||
void DrawBitmap(double dX, double dY, double dW, double dH, BYTE* pBuffer, unsigned int unWidth, unsigned int unHeight) override {};
|
||||
void DrawBitmap(double dX, double dY, double dW, double dH, BYTE* pBuffer, unsigned int unWidth, unsigned int unHeight, unsigned int unBlendMode) override {};
|
||||
|
||||
void DrawString(std::wstring& wsText, unsigned int unCharsCount, double dX, double dY, double* pDx,
|
||||
int iGraphicsMode = 1, double dXScale = 1, double dYScale = 1) override {};
|
||||
|
||||
@ -73,10 +73,10 @@ namespace MetaFile
|
||||
pInterpretator->End();
|
||||
}
|
||||
|
||||
void CEmfInterpretatorArray::DrawBitmap(double dX, double dY, double dW, double dH, BYTE *pBuffer, unsigned int unWidth, unsigned int unHeight)
|
||||
void CEmfInterpretatorArray::DrawBitmap(double dX, double dY, double dW, double dH, BYTE *pBuffer, unsigned int unWidth, unsigned int unHeight, unsigned int unBlendMode)
|
||||
{
|
||||
for (CEmfInterpretatorBase* pInterpretator : m_arInterpretators)
|
||||
pInterpretator->DrawBitmap(dX, dY, dW, dH, pBuffer, unWidth, unHeight);
|
||||
pInterpretator->DrawBitmap(dX, dY, dW, dH, pBuffer, unWidth, unHeight, unBlendMode);
|
||||
}
|
||||
|
||||
void CEmfInterpretatorArray::DrawString(std::wstring &wsText, unsigned int unCharsCount, double dX, double dY, double *pDx,
|
||||
|
||||
@ -33,7 +33,7 @@ namespace MetaFile
|
||||
void Begin() override;
|
||||
void End() override;
|
||||
|
||||
void DrawBitmap(double dX, double dY, double dW, double dH, BYTE* pBuffer, unsigned int unWidth, unsigned int unHeight) override;
|
||||
void DrawBitmap(double dX, double dY, double dW, double dH, BYTE* pBuffer, unsigned int unWidth, unsigned int unHeight, unsigned int unBlendMode) override;
|
||||
|
||||
void DrawString(std::wstring& wsText, unsigned int unCharsCount, double dX, double dY, double* pDx,
|
||||
int iGraphicsMode = 1, double dXScale = 1, double dYScale = 1) override;
|
||||
|
||||
@ -34,10 +34,10 @@ namespace MetaFile
|
||||
m_pMetaFileRenderer->End();
|
||||
}
|
||||
|
||||
void CEmfInterpretatorRender::DrawBitmap(double dX, double dY, double dW, double dH, BYTE *pBuffer, unsigned int unWidth, unsigned int unHeight)
|
||||
void CEmfInterpretatorRender::DrawBitmap(double dX, double dY, double dW, double dH, BYTE *pBuffer, unsigned int unWidth, unsigned int unHeight, unsigned int unBlendMode)
|
||||
{
|
||||
if (NULL != m_pMetaFileRenderer)
|
||||
m_pMetaFileRenderer->DrawBitmap(dX, dY, dW, dH, pBuffer, unWidth, unHeight);
|
||||
m_pMetaFileRenderer->DrawBitmap(dX, dY, dW, dH, pBuffer, unWidth, unHeight, unBlendMode);
|
||||
}
|
||||
|
||||
void CEmfInterpretatorRender::DrawString(std::wstring &wsText, unsigned int unCharsCount, double dX, double dY, double *pDx,
|
||||
|
||||
@ -19,7 +19,7 @@ namespace MetaFile
|
||||
void Begin() override;
|
||||
void End() override;
|
||||
|
||||
void DrawBitmap(double dX, double dY, double dW, double dH, BYTE* pBuffer, unsigned int unWidth, unsigned int unHeight) override;
|
||||
void DrawBitmap(double dX, double dY, double dW, double dH, BYTE* pBuffer, unsigned int unWidth, unsigned int unHeight, unsigned int unBlendMode) override;
|
||||
|
||||
void DrawString(std::wstring& wsText, unsigned int unCharsCount, double dX, double dY, double* pDx,
|
||||
int iGraphicsMode = 1, double dXScale = 1, double dYScale = 1) override;
|
||||
|
||||
@ -1477,9 +1477,9 @@ namespace MetaFile
|
||||
m_bUpdatedClip = false;
|
||||
}
|
||||
|
||||
void CEmfInterpretatorSvg::DrawBitmap(double dX, double dY, double dW, double dH, BYTE *pBuffer, unsigned int unWidth, unsigned int unHeight)
|
||||
void CEmfInterpretatorSvg::DrawBitmap(double dX, double dY, double dW, double dH, BYTE *pBuffer, unsigned int unWidth, unsigned int unHeight, unsigned int unBlendMode)
|
||||
{
|
||||
CInterpretatorSvgBase::DrawBitmap(dX, dY, dW, dH, pBuffer, unWidth, unHeight);
|
||||
CInterpretatorSvgBase::DrawBitmap(dX, dY, dW, dH, pBuffer, unWidth, unHeight, unBlendMode);
|
||||
}
|
||||
|
||||
void CEmfInterpretatorSvg::ResetClip()
|
||||
|
||||
@ -195,7 +195,7 @@ namespace MetaFile
|
||||
private:
|
||||
TSvgConditional m_oSecondConditional;
|
||||
public:
|
||||
void DrawBitmap(double dX, double dY, double dW, double dH, BYTE* pBuffer, unsigned int unWidth, unsigned int unHeight) override;
|
||||
void DrawBitmap(double dX, double dY, double dW, double dH, BYTE* pBuffer, unsigned int unWidth, unsigned int unHeight, unsigned int unBlendMode) override;
|
||||
|
||||
//Следующие методы ничего не делают
|
||||
void Begin() override {};
|
||||
|
||||
@ -213,7 +213,7 @@ namespace MetaFile
|
||||
void End() override;
|
||||
//Следующие методы ничего не делают
|
||||
|
||||
void DrawBitmap(double dX, double dY, double dW, double dH, BYTE* pBuffer, unsigned int unWidth, unsigned int unHeight) override {};
|
||||
void DrawBitmap(double dX, double dY, double dW, double dH, BYTE* pBuffer, unsigned int unWidth, unsigned int unHeight, unsigned int unBlendMode) override {};
|
||||
|
||||
void DrawString(std::wstring& wsText, unsigned int unCharsCount, double dX, double dY, double* pDx,
|
||||
int iGraphicsMode = 1, double dXScale = 1, double dYScale = 1) override {};
|
||||
|
||||
@ -449,8 +449,9 @@ namespace MetaFile
|
||||
|
||||
unsigned int ulBitsSizeSkip = 0 == ulBitsSize ? 0 : ((int)(((double)ulBitsSize - 0.5) / 4) + 1) * 4;
|
||||
m_oStream.Skip(ulBitsSizeSkip);
|
||||
unsigned int unColorUsed;
|
||||
|
||||
MetaFile::ReadImage(pHeaderBuffer, ulHeaderSize, pBitsBuffer, ulBitsSize, ppBgraBuffer, pulWidth, pulHeight);
|
||||
MetaFile::ReadImage(pHeaderBuffer, ulHeaderSize, pBitsBuffer, ulBitsSize, ppBgraBuffer, pulWidth, pulHeight, unColorUsed);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -64,7 +64,7 @@ namespace MetaFile
|
||||
|
||||
DrawImage(oTEmfAlphaBlend.nXDest, oTEmfAlphaBlend.nYDest,
|
||||
oTEmfAlphaBlend.nCxDest, oTEmfAlphaBlend.nCyDest,
|
||||
pBgraBuffer, unWidth, unHeight);
|
||||
pBgraBuffer, unWidth, unHeight, BLEND_MODE_DEFAULT);
|
||||
}
|
||||
}
|
||||
|
||||
@ -84,9 +84,10 @@ namespace MetaFile
|
||||
if (m_pInterpretator)
|
||||
{
|
||||
ProcessRasterOperation(oTEmfStretchDIBITS.unBitBltRasterOperation, &pBgraBuffer, ulWidth, ulHeight);
|
||||
|
||||
DrawImage(oTEmfStretchDIBITS.nXDest, oTEmfStretchDIBITS.nYDest,
|
||||
oTEmfStretchDIBITS.nCxDest, oTEmfStretchDIBITS.nCyDest,
|
||||
pBgraBuffer, ulWidth, ulHeight);
|
||||
pBgraBuffer, ulWidth, ulHeight, BLEND_MODE_DEFAULT);
|
||||
}
|
||||
}
|
||||
|
||||
@ -108,7 +109,7 @@ namespace MetaFile
|
||||
{
|
||||
DrawImage(oTEmfBitBlt.nXDest, oTEmfBitBlt.nYDest,
|
||||
oTEmfBitBlt.nCxDest, oTEmfBitBlt.nCyDest,
|
||||
pBgraBuffer, ulWidth, ulHeight);
|
||||
pBgraBuffer, ulWidth, ulHeight, BLEND_MODE_DEFAULT);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -158,7 +159,7 @@ namespace MetaFile
|
||||
if (pBgraBuffer)
|
||||
DrawImage(oTEmfBitBlt.nXDest, oTEmfBitBlt.nYDest,
|
||||
oTEmfBitBlt.nCxDest, oTEmfBitBlt.nCyDest,
|
||||
pBgraBuffer, ulWidth, ulHeight);
|
||||
pBgraBuffer, ulWidth, ulHeight, BLEND_MODE_DEFAULT);
|
||||
}
|
||||
|
||||
if (pBgraBuffer)
|
||||
@ -177,7 +178,7 @@ namespace MetaFile
|
||||
DrawImage(oTEmfSetDiBitsToDevice.oBounds.Left, oTEmfSetDiBitsToDevice.oBounds.Top,
|
||||
oTEmfSetDiBitsToDevice.oBounds.Right - oTEmfSetDiBitsToDevice.oBounds.Left,
|
||||
oTEmfSetDiBitsToDevice.oBounds.Bottom - oTEmfSetDiBitsToDevice.oBounds.Top,
|
||||
pBgraBuffer, ulWidth, ulHeight);
|
||||
pBgraBuffer, ulWidth, ulHeight, BLEND_MODE_DEFAULT);
|
||||
}
|
||||
|
||||
if (pBgraBuffer)
|
||||
@ -197,9 +198,15 @@ namespace MetaFile
|
||||
if (m_pInterpretator)
|
||||
{
|
||||
ProcessRasterOperation(oTEmfStretchBLT.unBitBltRasterOperation, &pBgraBuffer, ulWidth, ulHeight);
|
||||
|
||||
unsigned int unBlendMode{BLEND_MODE_DEFAULT};
|
||||
|
||||
if (0x00660046 == oTEmfStretchBLT.unBitBltRasterOperation)
|
||||
unBlendMode = 0;
|
||||
|
||||
DrawImage(oTEmfStretchBLT.nXDest, oTEmfStretchBLT.nYDest,
|
||||
oTEmfStretchBLT.nCxDest, oTEmfStretchBLT.nCyDest,
|
||||
pBgraBuffer, ulWidth, ulHeight);
|
||||
pBgraBuffer, ulWidth, ulHeight, unBlendMode);
|
||||
}
|
||||
}
|
||||
|
||||
@ -225,14 +232,14 @@ namespace MetaFile
|
||||
}
|
||||
}
|
||||
|
||||
void CEmfParserBase::DrawImage(int nX, int nY, int nW, int nH, BYTE *pImageBuffer, unsigned int unImageW, unsigned int unImageH)
|
||||
void CEmfParserBase::DrawImage(int nX, int nY, int nW, int nH, BYTE *pImageBuffer, unsigned int unImageW, unsigned int unImageH, unsigned int unBlendMode)
|
||||
{
|
||||
if (NULL != m_pInterpretator)
|
||||
{
|
||||
double dX, dY, dR, dB;
|
||||
TranslatePoint(nX, nY, dX, dY);
|
||||
TranslatePoint(nX + nW, nY + nH, dR, dB);
|
||||
m_pInterpretator->DrawBitmap(dX, dY, dR - dX, dB - dY, pImageBuffer, unImageW, unImageH);
|
||||
m_pInterpretator->DrawBitmap(dX, dY, dR - dX, dB - dY, pImageBuffer, unImageW, unImageH, unBlendMode);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1601,7 +1608,7 @@ namespace MetaFile
|
||||
pBgraBuffer[2] = oColor.r;
|
||||
pBgraBuffer[3] = 0xff;
|
||||
|
||||
DrawImage(oPoint.X, oPoint.Y, 1, 1, pBgraBuffer, 1, 1);
|
||||
DrawImage(oPoint.X, oPoint.Y, 1, 1, pBgraBuffer, 1, 1, BLEND_MODE_DEFAULT);
|
||||
}
|
||||
|
||||
void CEmfParserBase::HANDLE_EMR_SMALLTEXTOUT(TEmfSmallTextout &oText)
|
||||
|
||||
@ -128,7 +128,7 @@ namespace MetaFile
|
||||
void ImageProcessing(const TEmfSetDiBitsToDevice&oTEmfSetDiBitsToDevice);
|
||||
void ImageProcessing(const TEmfStretchBLT &oTEmfStretchBLT);
|
||||
void ImageProcessing(const TEmfDibPatternBrush &oTEmfDibPatternBrush, unsigned int ulBrushIndex);
|
||||
void DrawImage(int nX, int nY, int nW, int nH, BYTE *pImageBuffer, unsigned int unImageW, unsigned int unImageH);
|
||||
void DrawImage(int nX, int nY, int nW, int nH, BYTE *pImageBuffer, unsigned int unImageW, unsigned int unImageH, unsigned int unBlendMode);
|
||||
//----------------------
|
||||
|
||||
void TranslatePoint(TPointL &oPoint, double &dX, double &dY) const;
|
||||
|
||||
@ -1601,15 +1601,8 @@ namespace MetaFile
|
||||
|
||||
pGrRenderer->SetFontManager(GetFontManager());
|
||||
|
||||
double dScale = ((CEmfInterpretatorRender*)m_pInterpretator)->GetRenderer()->GetWidth() * 96. / 25.4 / dParentWidth;
|
||||
|
||||
const double dMaxWidth = std::max(MAX_PICTURE_SIZE, dParentWidth);
|
||||
const double dMaxHeight = std::max(MAX_PICTURE_SIZE, dParentHeight);
|
||||
|
||||
dScale *= std::min(dMaxWidth / dFileWidth, dMaxHeight / dFileHeight);
|
||||
|
||||
const int nWidth = dFileWidth * dScale;
|
||||
const int nHeight = dFileHeight * dScale;
|
||||
const int nWidth = static_cast<int>(dFileWidth);
|
||||
const int nHeight = static_cast<int>(dFileHeight);
|
||||
|
||||
BYTE* pBgraData = new(std::nothrow) BYTE[nWidth * nHeight * 4];
|
||||
|
||||
@ -1649,17 +1642,17 @@ namespace MetaFile
|
||||
|
||||
TRectL oClipRect;
|
||||
|
||||
oClipRect.Left = std::floor((oSrcRect.dX - oFileBounds.Left) * dScale);
|
||||
oClipRect.Top = std::floor((oSrcRect.dY - oFileBounds.Top) * dScale);
|
||||
oClipRect.Right = std::floor((oSrcRect.dX + oSrcRect.dWidth - oFileBounds.Left) * dScale);
|
||||
oClipRect.Bottom = std::floor((oSrcRect.dY + oSrcRect.dHeight - oFileBounds.Top) * dScale);
|
||||
oClipRect.Left = std::floor(oSrcRect.dX - oFileBounds.Left);
|
||||
oClipRect.Top = std::floor(oSrcRect.dY - oFileBounds.Top);
|
||||
oClipRect.Right = std::floor(oSrcRect.dX + oSrcRect.dWidth - oFileBounds.Left);
|
||||
oClipRect.Bottom = std::floor(oSrcRect.dY + oSrcRect.dHeight - oFileBounds.Top);
|
||||
|
||||
unsigned int nW = (unsigned int)nWidth;
|
||||
unsigned int nH = (unsigned int)nHeight;
|
||||
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, BLEND_MODE_DEFAULT);
|
||||
|
||||
RELEASEINTERFACE(pGrRenderer);
|
||||
RELEASEARRAYOBJECTS(pNewBuffer);
|
||||
@ -1738,7 +1731,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, BLEND_MODE_DEFAULT);
|
||||
|
||||
if (!bExternalBuffer)
|
||||
RELEASEARRAYOBJECTS(pBytes);
|
||||
|
||||
@ -324,8 +324,9 @@ namespace MetaFile
|
||||
|
||||
unsigned int ulBitsSizeSkip = 0 == ulBitsSize ? 0 : ((int)(((double)ulBitsSize - 0.5) / 4) + 1) * 4;
|
||||
m_oStream.Skip(ulBitsSizeSkip);
|
||||
unsigned int unColorUsed;
|
||||
|
||||
MetaFile::ReadImage(pHeaderBuffer, ulHeaderSize, pBitsBuffer, ulBitsSize, ppBgraBuffer, pulWidth, pulHeight);
|
||||
MetaFile::ReadImage(pHeaderBuffer, ulHeaderSize, pBitsBuffer, ulBitsSize, ppBgraBuffer, pulWidth, pulHeight, unColorUsed);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -1261,7 +1262,7 @@ namespace MetaFile
|
||||
pBgraBuffer[2] = oColor.r;
|
||||
pBgraBuffer[3] = 0xff;
|
||||
|
||||
DrawImage(oPoint.X, oPoint.Y, 1, 1, pBgraBuffer, 1, 1);
|
||||
DrawImage(oPoint.X, oPoint.Y, 1, 1, pBgraBuffer, 1, 1, BLEND_MODE_DEFAULT);
|
||||
}
|
||||
void CEmfxParser::Read_EMR_SMALLTEXTOUT()
|
||||
{
|
||||
|
||||
@ -941,7 +941,8 @@ bool CSvmFile::ReadImage(unsigned short ushColorUsage, BYTE** ppBgraBuffer, unsi
|
||||
return false;
|
||||
|
||||
BYTE* pBuffer = m_oStream.GetCurPtr();
|
||||
MetaFile::ReadImage(pBuffer, unRemainBytes, ushColorUsage, ppBgraBuffer, pulWidth, pulHeight);
|
||||
unsigned int unColorUsed;
|
||||
MetaFile::ReadImage(pBuffer, unRemainBytes, ushColorUsage, ppBgraBuffer, pulWidth, pulHeight, unColorUsed);
|
||||
return true;
|
||||
}
|
||||
void CSvmFile::Read_META_POP()
|
||||
@ -994,7 +995,7 @@ void CSvmFile::Read_META_BMP()
|
||||
{
|
||||
if ( m_pOutput)
|
||||
{
|
||||
m_pOutput->DrawBitmap( m_oCurrnetOffset.x, m_oCurrnetOffset.y, bitmap_info.nWidth, bitmap_info.nHeight, pBgraBuffer, bitmap_info.nWidth, bitmap_info.nHeight);
|
||||
m_pOutput->DrawBitmap( m_oCurrnetOffset.x, m_oCurrnetOffset.y, bitmap_info.nWidth, bitmap_info.nHeight, pBgraBuffer, bitmap_info.nWidth, bitmap_info.nHeight, BLEND_MODE_DEFAULT);
|
||||
}
|
||||
|
||||
delete []pBgraBuffer;
|
||||
@ -1049,6 +1050,8 @@ void CSvmFile::Read_META_BMP(TSvmBitmap & bitmap_info, BYTE** ppDstBuffer, unsig
|
||||
else
|
||||
nColors = 0;
|
||||
|
||||
unsigned int unColorUsed;
|
||||
|
||||
if( ZCOMPRESS == bitmap_info.nCompression )
|
||||
{
|
||||
COfficeUtils OfficeUtils(NULL);
|
||||
@ -1069,7 +1072,7 @@ void CSvmFile::Read_META_BMP(TSvmBitmap & bitmap_info, BYTE** ppDstBuffer, unsig
|
||||
}
|
||||
m_oStream.Skip(srcSize);
|
||||
|
||||
MetaFile::ReadImage((BYTE*)&bitmap_info, bitmap_info.nSize, destBuf, destSize, ppDstBuffer, pulWidth, pulHeight);
|
||||
MetaFile::ReadImage((BYTE*)&bitmap_info, bitmap_info.nSize, destBuf, destSize, ppDstBuffer, pulWidth, pulHeight, unColorUsed);
|
||||
delete []destBuf;
|
||||
}
|
||||
else if (nHeaderSize >= bitmap_info.nSize)
|
||||
@ -1079,7 +1082,7 @@ void CSvmFile::Read_META_BMP(TSvmBitmap & bitmap_info, BYTE** ppDstBuffer, unsig
|
||||
|
||||
m_oStream.ReadBytes(Header + bitmap_info.nSize, nHeaderSize - bitmap_info.nSize);
|
||||
|
||||
MetaFile::ReadImage(Header , nHeaderSize, m_oStream.GetCurPtr(), bitmap_info.nSizeImage, ppDstBuffer, pulWidth, pulHeight);
|
||||
MetaFile::ReadImage(Header , nHeaderSize, m_oStream.GetCurPtr(), bitmap_info.nSizeImage, ppDstBuffer, pulWidth, pulHeight, unColorUsed);
|
||||
m_oStream.Skip(bitmap_info.nSizeImage);
|
||||
delete[] Header;
|
||||
}
|
||||
|
||||
@ -304,7 +304,8 @@ class CSvmFile : virtual public IMetaFileBase
|
||||
BYTE* pBitsBuffer = m_oStream.GetCurPtr();
|
||||
m_oStream.Skip(ulBitsSize);
|
||||
|
||||
MetaFile::ReadImage(pHeaderBuffer, ulHeaderSize, pBitsBuffer, ulBitsSize, ppBgraBuffer, pulWidth, pulHeight);
|
||||
unsigned int unColorUsed;
|
||||
MetaFile::ReadImage(pHeaderBuffer, ulHeaderSize, pBitsBuffer, ulBitsSize, ppBgraBuffer, pulWidth, pulHeight, unColorUsed);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -321,7 +322,7 @@ class CSvmFile : virtual public IMetaFileBase
|
||||
for (int nIndex = 3, nSize = 4 * unImageW * unImageH; nIndex < nSize; nIndex += 4)
|
||||
pImageBuffer[nIndex] = 255;
|
||||
|
||||
m_pOutput->DrawBitmap(dX, dY, dR - dX, dB - dY, pImageBuffer, unImageW, unImageH);
|
||||
m_pOutput->DrawBitmap(dX, dY, dR - dX, dB - dY, pImageBuffer, unImageW, unImageH, BLEND_MODE_DEFAULT);
|
||||
}
|
||||
}
|
||||
void DrawImage(int nX, int nY, int nW, int nH, unsigned int unColorUsage)
|
||||
@ -338,7 +339,7 @@ class CSvmFile : virtual public IMetaFileBase
|
||||
TranslatePoint(nX, nY, dX, dY);
|
||||
TranslatePoint(nX + nW, nY + nH, dX1, dY1);
|
||||
|
||||
m_pOutput->DrawBitmap(dX, dY, fabs(dX1 - dX), fabs(dY1 - dY), pBgra, unWidth, unHeight);
|
||||
m_pOutput->DrawBitmap(dX, dY, fabs(dX1 - dX), fabs(dY1 - dY), pBgra, unWidth, unHeight, BLEND_MODE_DEFAULT);
|
||||
}
|
||||
|
||||
if (pBgra)
|
||||
|
||||
@ -451,7 +451,7 @@ namespace MetaFile
|
||||
m_pXmlWriter->WriteNodeEnd(L"g");
|
||||
}
|
||||
|
||||
void CInterpretatorSvgBase::DrawBitmap(double dX, double dY, double dW, double dH, BYTE *pBuffer, unsigned int unWidth, unsigned int unHeight)
|
||||
void CInterpretatorSvgBase::DrawBitmap(double dX, double dY, double dW, double dH, BYTE *pBuffer, unsigned int unWidth, unsigned int unHeight, unsigned int unBlendMode)
|
||||
{
|
||||
if (NULL == pBuffer || Equals(0., dW) || Equals(0., dH) || 0 == unWidth || 0 == unHeight)
|
||||
return;
|
||||
|
||||
@ -108,7 +108,7 @@ namespace MetaFile
|
||||
void WriteNodeEnd(const std::wstring& wsNodeName);
|
||||
void WriteText(const std::wstring& wsText, const TPointD& oCoord, const TRectL& oBounds = TRectL(), const TPointD& oScale = TPointD(1, 1), const std::vector<double>& arDx = {});
|
||||
|
||||
void DrawBitmap(double dX, double dY, double dW, double dH, BYTE* pBuffer, unsigned int unWidth, unsigned int unHeight) override;
|
||||
void DrawBitmap(double dX, double dY, double dW, double dH, BYTE* pBuffer, unsigned int unWidth, unsigned int unHeight, unsigned int unBlendMode) override;
|
||||
|
||||
void ResetClip() override;
|
||||
void IntersectClip(const TRectD& oClip) override;
|
||||
|
||||
@ -22,10 +22,10 @@ namespace MetaFile
|
||||
m_pMetaFileRenderer->End();
|
||||
}
|
||||
|
||||
void CWmfInterpretatorRender::DrawBitmap(double dX, double dY, double dW, double dH, BYTE *pBuffer, unsigned int unWidth, unsigned int unHeight)
|
||||
void CWmfInterpretatorRender::DrawBitmap(double dX, double dY, double dW, double dH, BYTE *pBuffer, unsigned int unWidth, unsigned int unHeight, unsigned int unBlendMode)
|
||||
{
|
||||
if (NULL != m_pMetaFileRenderer)
|
||||
m_pMetaFileRenderer->DrawBitmap(dX, dY, dW, dH, pBuffer, unWidth, unHeight);
|
||||
m_pMetaFileRenderer->DrawBitmap(dX, dY, dW, dH, pBuffer, unWidth, unHeight, unBlendMode);
|
||||
}
|
||||
|
||||
void CWmfInterpretatorRender::DrawString(std::wstring &wsText, unsigned int unCharsCount, double dX, double dY, double *pDx,
|
||||
|
||||
@ -16,7 +16,7 @@ namespace MetaFile
|
||||
void Begin() override;
|
||||
void End() override;
|
||||
|
||||
void DrawBitmap(double dX, double dY, double dW, double dH, BYTE* pBuffer, unsigned int unWidth, unsigned int unHeight) override;
|
||||
void DrawBitmap(double dX, double dY, double dW, double dH, BYTE* pBuffer, unsigned int unWidth, unsigned int unHeight, unsigned int unBlendMode) override;
|
||||
|
||||
void DrawString(std::wstring& wsText, unsigned int unCharsCount, double dX, double dY, double* pDx,
|
||||
int iGraphicsMode = 1, double dXScale = 1, double dYScale = 1) override;
|
||||
|
||||
@ -470,9 +470,9 @@ namespace MetaFile
|
||||
m_bUpdatedClip = false;
|
||||
}
|
||||
|
||||
void CWmfInterpretatorSvg::DrawBitmap(double dX, double dY, double dW, double dH, BYTE *pBuffer, unsigned int unWidth, unsigned int unHeight)
|
||||
void CWmfInterpretatorSvg::DrawBitmap(double dX, double dY, double dW, double dH, BYTE *pBuffer, unsigned int unWidth, unsigned int unHeight, unsigned int unBlendMode)
|
||||
{
|
||||
CInterpretatorSvgBase::DrawBitmap(dX, dY, dW, dH, pBuffer, unWidth, unHeight);
|
||||
CInterpretatorSvgBase::DrawBitmap(dX, dY, dW, dH, pBuffer, unWidth, unHeight, unBlendMode);
|
||||
}
|
||||
|
||||
void CWmfInterpretatorSvg::ResetClip()
|
||||
|
||||
@ -102,7 +102,7 @@ namespace MetaFile
|
||||
void HANDLE_META_UNKNOWN(CDataStream& oDataStream) override {};
|
||||
|
||||
public:
|
||||
void DrawBitmap(double dX, double dY, double dW, double dH, BYTE* pBuffer, unsigned int unWidth, unsigned int unHeight) override;
|
||||
void DrawBitmap(double dX, double dY, double dW, double dH, BYTE* pBuffer, unsigned int unWidth, unsigned int unHeight, unsigned int unBlendMode) override;
|
||||
|
||||
//Следующие методы ничего не делают
|
||||
void Begin() override {};
|
||||
|
||||
@ -666,14 +666,14 @@ namespace MetaFile
|
||||
}
|
||||
}
|
||||
|
||||
bool CWmfParserBase::ReadImage(unsigned short ushColorUsage, BYTE **ppBgraBuffer, unsigned int *pulWidth, unsigned int *pulHeight)
|
||||
bool CWmfParserBase::ReadImage(unsigned short ushColorUsage, BYTE **ppBgraBuffer, unsigned int *pulWidth, unsigned int *pulHeight, unsigned int& unColorUsed)
|
||||
{
|
||||
unsigned int unRemainBytes = GetRecordRemainingBytesCount();
|
||||
if (unRemainBytes <= 0)
|
||||
return false;
|
||||
|
||||
BYTE* pBuffer = m_oStream.GetCurPtr();
|
||||
MetaFile::ReadImage(pBuffer, unRemainBytes, ushColorUsage, ppBgraBuffer, pulWidth, pulHeight);
|
||||
MetaFile::ReadImage(pBuffer, unRemainBytes, ushColorUsage, ppBgraBuffer, pulWidth, pulHeight, unColorUsed);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -682,12 +682,17 @@ namespace MetaFile
|
||||
if (NULL != m_pInterpretator)
|
||||
{
|
||||
BYTE* pBgra = NULL;
|
||||
unsigned int unWidth, unHeight;
|
||||
unsigned int unWidth, unHeight, unColorUsed;
|
||||
|
||||
if (ReadImage(unColorUsage, &pBgra, &unWidth, &unHeight))
|
||||
if (ReadImage(unColorUsage, &pBgra, &unWidth, &unHeight, unColorUsed))
|
||||
{
|
||||
ProcessRasterOperation(unRasterOperation, &pBgra, unWidth, unHeight);
|
||||
|
||||
unsigned int unBlendMode{BLEND_MODE_DEFAULT};
|
||||
|
||||
if (2 == unColorUsed && 0x00660046 == unRasterOperation)
|
||||
unBlendMode = BLEND_MODE_DRAW_ON_BLACK;
|
||||
|
||||
double dX, dY, dX1, dY1;
|
||||
TranslatePoint(oDestRect.Left, oDestRect.Top, dX, dY);
|
||||
TranslatePoint(oDestRect.Right, oDestRect.Bottom, dX1, dY1);
|
||||
@ -703,14 +708,14 @@ namespace MetaFile
|
||||
|
||||
if (NULL != pNewBuffer)
|
||||
{
|
||||
m_pInterpretator->DrawBitmap(dX, dY, dX1 - dX, dY1 - dY, pNewBuffer, std::abs(oClip.Right - oClip.Left), std::abs(oClip.Bottom - oClip.Top));
|
||||
m_pInterpretator->DrawBitmap(dX, dY, dX1 - dX, dY1 - dY, pNewBuffer, std::abs(oClip.Right - oClip.Left), std::abs(oClip.Bottom - oClip.Top), unBlendMode);
|
||||
delete[] pNewBuffer;
|
||||
}
|
||||
else
|
||||
m_pInterpretator->DrawBitmap(dX, dY, dX1 - dX, dY1 - dY, pBgra, unWidth, unHeight);
|
||||
m_pInterpretator->DrawBitmap(dX, dY, dX1 - dX, dY1 - dY, pBgra, unWidth, unHeight, unBlendMode);
|
||||
}
|
||||
else
|
||||
m_pInterpretator->DrawBitmap(dX, dY, dX1 - dX, dY1 - dY, pBgra, unWidth, unHeight);
|
||||
m_pInterpretator->DrawBitmap(dX, dY, dX1 - dX, dY1 - dY, pBgra, unWidth, unHeight, unBlendMode);
|
||||
}
|
||||
|
||||
if (pBgra)
|
||||
@ -1220,7 +1225,7 @@ namespace MetaFile
|
||||
if (NULL != m_pInterpretator)
|
||||
{
|
||||
m_pInterpretator->HANDLE_META_SETPIXEL(oColor, shY, shX);
|
||||
m_pInterpretator->DrawBitmap(shX, shY, 1, 1, pBgraBuffer, 1, 1);
|
||||
m_pInterpretator->DrawBitmap(shX, shY, 1, 1, pBgraBuffer, 1, 1, BLEND_MODE_DEFAULT);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1310,8 +1315,8 @@ namespace MetaFile
|
||||
m_pInterpretator->HANDLE_META_DIBCREATEPATTERNBRUSH(ushStyle, ushColorUsage, *pBrush, m_oStream);
|
||||
|
||||
BYTE* pBgra = NULL;
|
||||
unsigned int unWidth = 0, unHeight = 0;
|
||||
if (ReadImage(ushColorUsage, &pBgra, &unWidth, &unHeight))
|
||||
unsigned int unWidth = 0, unHeight = 0, unColorUsed = 0;
|
||||
if (ReadImage(ushColorUsage, &pBgra, &unWidth, &unHeight, unColorUsed))
|
||||
{
|
||||
pBrush->SetDibPattern(pBgra, unWidth, unHeight);
|
||||
}
|
||||
|
||||
@ -197,7 +197,7 @@ namespace MetaFile
|
||||
|
||||
void RegisterPoint(short shX, short shY);
|
||||
|
||||
bool ReadImage(unsigned short ushColorUsage, BYTE** ppBgraBuffer, unsigned int* pulWidth, unsigned int* pulHeight);
|
||||
bool ReadImage(unsigned short ushColorUsage, BYTE** ppBgraBuffer, unsigned int* pulWidth, unsigned int* pulHeight, unsigned int& unColorUsed);
|
||||
void DrawImage(const TRectL& oDestRect, const TRectL& oSrcRect, unsigned int unColorUsage, unsigned int unRasterOperation);
|
||||
|
||||
static BYTE* ClipBuffer(BYTE* pBuffer, unsigned int unWidth, unsigned int unHeight, TRectL& oNewRect);
|
||||
|
||||
152
DesktopEditor/raster/heif/heif.cpp
Normal file
152
DesktopEditor/raster/heif/heif.cpp
Normal file
@ -0,0 +1,152 @@
|
||||
#include "heif.h"
|
||||
#include "../../common/File.h"
|
||||
|
||||
#include <functional>
|
||||
|
||||
#define CONCAT_IMPL(x, y) x##y
|
||||
#define CONCAT(x, y) CONCAT_IMPL(x, y)
|
||||
#define defer(code) Defer CONCAT(_defer_, __COUNTER__)([&](){code;})
|
||||
|
||||
class Defer {
|
||||
std::function<void()> func;
|
||||
public:
|
||||
explicit Defer(std::function<void()> func) : func(func) {}
|
||||
~Defer() { func(); }
|
||||
};
|
||||
|
||||
namespace NSHeif {
|
||||
bool CHeifFile::isHeif(const std::wstring& fileName)
|
||||
{
|
||||
heif_context* ctx = heif_context_alloc();
|
||||
defer(heif_context_free(ctx););
|
||||
return !IsError(heif_context_read_from_file(ctx, m_oConverter.fromUnicode(fileName, "UTF-8").c_str(), nullptr));
|
||||
}
|
||||
|
||||
bool CHeifFile::isHeif(BYTE* buffer, DWORD size)
|
||||
{
|
||||
heif_context* ctx = heif_context_alloc();
|
||||
defer(heif_context_free(ctx););
|
||||
return !IsError(heif_context_read_from_memory_without_copy(ctx, buffer, size, nullptr));
|
||||
}
|
||||
|
||||
bool CHeifFile::Open(CBgraFrame *frame, const std::wstring& fileName)
|
||||
{
|
||||
heif_context* ctx = heif_context_alloc();
|
||||
defer(heif_context_free(ctx););
|
||||
if (IsError(heif_context_read_from_file(ctx, m_oConverter.fromUnicode(fileName, "UTF-8").c_str(), nullptr)))
|
||||
return false;
|
||||
return Decode(ctx, frame);
|
||||
}
|
||||
|
||||
bool CHeifFile::Open(CBgraFrame *frame, BYTE* buffer, DWORD size)
|
||||
{
|
||||
heif_context* ctx = heif_context_alloc();
|
||||
defer(heif_context_free(ctx););
|
||||
if (IsError(heif_context_read_from_memory_without_copy(ctx, buffer, size, nullptr)))
|
||||
return false;
|
||||
return Decode(ctx, frame);
|
||||
}
|
||||
|
||||
bool CHeifFile::Save(const BYTE* source, int width, int height, int sourceStride, const std::wstring& dstPath)
|
||||
{
|
||||
if (!source)
|
||||
return false;
|
||||
|
||||
heif_image* img;
|
||||
defer(heif_image_release(img););
|
||||
|
||||
if (IsError(heif_image_create(width, height, heif_colorspace_RGB, heif_chroma_interleaved_RGB, &img)))
|
||||
return false;
|
||||
|
||||
if (IsError(heif_image_add_plane(img, heif_channel_interleaved, width, height, 24)))
|
||||
return false;
|
||||
|
||||
int stride;
|
||||
BYTE* data = heif_image_get_plane(img, heif_channel_interleaved, &stride);
|
||||
|
||||
if (!data || stride == 0)
|
||||
return false;
|
||||
|
||||
for (size_t i = 0; i < height; ++i)
|
||||
{
|
||||
const BYTE* row = source + (height - i - 1) * (sourceStride < 0 ? -sourceStride : sourceStride);
|
||||
for (size_t j = 0; j < width; ++j)
|
||||
{
|
||||
data[(i * width + j) * 3 + 0] = row[(width - j - 1) * 4 + 2];
|
||||
data[(i * width + j) * 3 + 1] = row[(width - j - 1) * 4 + 1];
|
||||
data[(i * width + j) * 3 + 2] = row[(width - j - 1) * 4 + 0];
|
||||
}
|
||||
}
|
||||
|
||||
heif_context* ctx = heif_context_alloc();
|
||||
defer(heif_context_free(ctx););
|
||||
|
||||
heif_encoder* encoder;
|
||||
defer(heif_encoder_release(encoder););
|
||||
|
||||
if (IsError(heif_context_get_encoder_for_format(ctx, heif_compression_HEVC, &encoder)))
|
||||
return false;
|
||||
|
||||
if (IsError(heif_context_encode_image(ctx, img, encoder, nullptr, nullptr)))
|
||||
return false;
|
||||
|
||||
if (IsError(heif_context_write_to_file(ctx, m_oConverter.fromUnicode(dstPath, "UTF-8").c_str())))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool CHeifFile::IsError(heif_error err)
|
||||
{
|
||||
return err.code != heif_error_Ok;
|
||||
}
|
||||
|
||||
inline bool CHeifFile::Decode(heif_context* ctx, CBgraFrame* frame)
|
||||
{
|
||||
heif_image_handle* handle;
|
||||
defer(heif_image_handle_release(handle););
|
||||
|
||||
if (IsError(heif_context_get_primary_image_handle(ctx, &handle)))
|
||||
return false;
|
||||
|
||||
heif_image* img;
|
||||
defer(heif_image_release(img););
|
||||
|
||||
if (IsError(heif_decode_image(handle, &img, heif_colorspace_RGB, heif_chroma_444, nullptr)))
|
||||
return false;
|
||||
|
||||
int width = heif_image_get_primary_width(img);
|
||||
int height = heif_image_get_primary_height(img);
|
||||
|
||||
int stride_R, stride_G, stride_B;
|
||||
const BYTE* source_R = heif_image_get_plane_readonly(img, heif_channel_R, &stride_R);
|
||||
const BYTE* source_G = heif_image_get_plane_readonly(img, heif_channel_G, &stride_G);
|
||||
const BYTE* source_B = heif_image_get_plane_readonly(img, heif_channel_B, &stride_B);
|
||||
|
||||
if (stride_R == 0 || !source_R)
|
||||
return false;
|
||||
|
||||
BYTE* data = new BYTE[4 * width * height];
|
||||
|
||||
frame->put_Width(width);
|
||||
frame->put_Height(height);
|
||||
frame->put_Stride(4 * width);
|
||||
frame->put_Data(data);
|
||||
|
||||
for (size_t i = 0; i < height; ++i)
|
||||
{
|
||||
const BYTE* row_R = source_R + i * stride_R;
|
||||
const BYTE* row_G = source_G + i * stride_G;
|
||||
const BYTE* row_B = source_B + i * stride_B;
|
||||
for (size_t j = 0; j < width; ++j)
|
||||
{
|
||||
data[(i * width + j) * 4 + 0] = row_B[j];
|
||||
data[(i * width + j) * 4 + 1] = row_G[j];
|
||||
data[(i * width + j) * 4 + 2] = row_R[j];
|
||||
data[(i * width + j) * 4 + 3] = 255;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
22
DesktopEditor/raster/heif/heif.h
Normal file
22
DesktopEditor/raster/heif/heif.h
Normal file
@ -0,0 +1,22 @@
|
||||
#include "../BgraFrame.h"
|
||||
#include "../../Common/3dParty/heif/libheif/libheif/api/libheif/heif.h"
|
||||
#include "../../UnicodeConverter/UnicodeConverter.h"
|
||||
|
||||
namespace NSHeif {
|
||||
class GRAPHICS_DECL CHeifFile {
|
||||
private:
|
||||
CHeifFile() = delete;
|
||||
public:
|
||||
static bool isHeif(const std::wstring& fileName);
|
||||
static bool isHeif(BYTE* buffer, DWORD size);
|
||||
|
||||
static bool Open(CBgraFrame* frame, const std::wstring& fileName);
|
||||
static bool Open(CBgraFrame* frame, BYTE* buffer, DWORD size);
|
||||
static bool Save(const BYTE* source, int width, int height, int sourceStride, const std::wstring& dstPath);
|
||||
|
||||
private:
|
||||
static inline bool IsError(heif_error err);
|
||||
static inline bool Decode(heif_context* ctx, CBgraFrame* frame);
|
||||
static inline NSUnicodeConverter::CUnicodeConverter m_oConverter{};
|
||||
};
|
||||
}
|
||||
@ -85,6 +85,7 @@ namespace XmlUtils
|
||||
bool FromString (const wchar_t* sXml);
|
||||
bool FromString (const std::wstring& sXml);
|
||||
bool FromStringA(const std::string& sXml);
|
||||
bool FromStringA(const char* sXml, int size);
|
||||
|
||||
bool MoveToStart();
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user