mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-04-07 13:55:33 +08:00
Compare commits
50 Commits
v5.5.0.112
...
v5.5.2.9
| Author | SHA1 | Date | |
|---|---|---|---|
| bb65549dc1 | |||
| 5294089fd0 | |||
| 3ec24e5e39 | |||
| dc44dc5e84 | |||
| cf76de8811 | |||
| 86421d8235 | |||
| 5e77e96e5f | |||
| 973b89609d | |||
| a0c0171d12 | |||
| d5c5c4b8cf | |||
| 60904a6df0 | |||
| 72315d1229 | |||
| abb5fd1ec1 | |||
| fd6beb0044 | |||
| 1b6eff5cb7 | |||
| 4fc6511b37 | |||
| 52ff8af2be | |||
| d29475b6fb | |||
| 32e7193212 | |||
| 23fc146eca | |||
| 7fd9e52bc3 | |||
| dd13f9f24c | |||
| 0fe3c3ece5 | |||
| 5d148a6d0d | |||
| d7af2cb41d | |||
| ed5bfb7b27 | |||
| b81e988da5 | |||
| a7c868d3d1 | |||
| bb022c49bd | |||
| 31e8a1cbdd | |||
| a19074993d | |||
| 0a1c718cc0 | |||
| fb5da5e4ff | |||
| 61a157a3c4 | |||
| a7ba4c471e | |||
| 8c18843b58 | |||
| 04d796d760 | |||
| 12c427b11e | |||
| 9415983797 | |||
| e82ea1bc5c | |||
| 49f4bdb933 | |||
| a577378a1e | |||
| 997bf0b887 | |||
| 51c1b7d21a | |||
| 4b0ce196e8 | |||
| b96189c213 | |||
| 987e6b6e76 | |||
| aefef93e21 | |||
| 2c04e9fb57 | |||
| 93108c244a |
2
.gitignore
vendored
2
.gitignore
vendored
@ -11,6 +11,8 @@ Common/3dParty/icu/win_32
|
||||
Common/3dParty/icu/linux_64
|
||||
Common/3dParty/icu/linux_32
|
||||
Common/3dParty/icu/mac_64
|
||||
Common/3dParty/icu/ios
|
||||
Common/3dParty/icu/mac-build
|
||||
Common/3dParty/cef/win_64
|
||||
Common/3dParty/cef/win_32
|
||||
Common/3dParty/cef/linux_64
|
||||
|
||||
@ -7622,7 +7622,9 @@ void BinaryCommentsTableWriter::WriteComment(CCommentWriteTemp& oComment)
|
||||
}
|
||||
else
|
||||
{
|
||||
nDurableId = XmlUtils::GenerateInt();
|
||||
//numbers greater than 0x7FFFFFFE cause MS Office errors(ST_LongHexNumber by spec)
|
||||
nDurableId = XmlUtils::GenerateInt() & 0x7FFFFFFF;
|
||||
nDurableId = (0x7FFFFFFF != nDurableId) ? nDurableId : nDurableId - 1;
|
||||
}
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSer_CommentsType::DurableId);
|
||||
m_oBcw.m_oStream.WriteULONG(nDurableId);
|
||||
|
||||
@ -1254,6 +1254,14 @@
|
||||
<File
|
||||
RelativePath="..\src\odf\chart_build_oox.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalOptions="/bigobj"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|x64"
|
||||
>
|
||||
@ -1302,6 +1310,14 @@
|
||||
<File
|
||||
RelativePath="..\src\odf\draw_frame_docx.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalOptions="/bigobj"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|x64"
|
||||
>
|
||||
@ -1314,6 +1330,14 @@
|
||||
<File
|
||||
RelativePath="..\src\odf\draw_frame_pptx.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalOptions="/bigobj"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|x64"
|
||||
>
|
||||
@ -1326,6 +1350,14 @@
|
||||
<File
|
||||
RelativePath="..\src\odf\draw_frame_xlsx.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalOptions="/bigobj"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|x64"
|
||||
>
|
||||
|
||||
@ -43,7 +43,12 @@ namespace PPTX
|
||||
{
|
||||
public:
|
||||
WritingElement_AdditionConstructors(TextFont)
|
||||
PPTX_LOGIC_BASE2(TextFont)
|
||||
TextFont()
|
||||
{
|
||||
m_eType = OOX::et_Unknown;
|
||||
}
|
||||
virtual ~TextFont() {}
|
||||
TextFont(const TextFont& oSrc) { *this = oSrc; }
|
||||
|
||||
virtual OOX::EElementType getType () const
|
||||
{
|
||||
|
||||
@ -338,5 +338,13 @@ namespace PPTX
|
||||
return 0; //return 0; - заменить на просмотр настроек по умолчанию
|
||||
}
|
||||
|
||||
void UniColor::SetRGBColor(const BYTE& R, const BYTE& G, const BYTE& B)
|
||||
{
|
||||
Logic::SrgbClr* rgbColor = new Logic::SrgbClr();
|
||||
rgbColor->SetRGB(R, G, B);
|
||||
|
||||
Color.reset(rgbColor);
|
||||
}
|
||||
|
||||
} // namespace Logic
|
||||
} // namespace PPTX
|
||||
|
||||
@ -75,6 +75,8 @@ namespace PPTX
|
||||
return Color->GetRGBColor(_oTheme,_oClrMap, ARGB);
|
||||
return 0;
|
||||
}
|
||||
void SetRGBColor(const BYTE& R, const BYTE& G, const BYTE& B);
|
||||
|
||||
virtual std::wstring toXML() const;
|
||||
|
||||
virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const
|
||||
|
||||
@ -79,6 +79,7 @@ namespace PPTX
|
||||
node1 = node.ReadNode(_T("a:folHlink"));
|
||||
lColor.GetColorFrom(node1); Scheme.insert(std::pair<std::wstring,Logic::UniColor>(_T("folHlink"), lColor));
|
||||
|
||||
FillWithDefaults();
|
||||
FillParentPointersForChilds();
|
||||
}
|
||||
|
||||
@ -233,7 +234,85 @@ namespace PPTX
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
void FillWithDefaults()
|
||||
{
|
||||
Logic::UniColor lColor;
|
||||
std::map<std::wstring, Logic::UniColor>::iterator it;
|
||||
it = Scheme.find(L"dk1");
|
||||
if (Scheme.end() == it || !it->second.is_init())
|
||||
{
|
||||
lColor.SetRGBColor(0,0,0);
|
||||
Scheme[L"dk1"] = lColor;
|
||||
}
|
||||
it = Scheme.find(L"lt1");
|
||||
if (Scheme.end() == it || !it->second.is_init())
|
||||
{
|
||||
lColor.SetRGBColor(255,255,255);
|
||||
Scheme[L"lt1"] = lColor;
|
||||
}
|
||||
it = Scheme.find(L"dk2");
|
||||
if (Scheme.end() == it || !it->second.is_init())
|
||||
{
|
||||
lColor.SetRGBColor(0x1F,0x49, 0x7D);
|
||||
Scheme[L"dk2"] = lColor;
|
||||
}
|
||||
it = Scheme.find(L"lt2");
|
||||
if (Scheme.end() == it || !it->second.is_init())
|
||||
{
|
||||
lColor.SetRGBColor(0xEE,0xEC,0xE1);
|
||||
Scheme[L"lt2"] = lColor;
|
||||
}
|
||||
it = Scheme.find(L"accent1");
|
||||
if (Scheme.end() == it || !it->second.is_init())
|
||||
{
|
||||
lColor.SetRGBColor(0x4F, 0x81, 0xBD);
|
||||
Scheme[L"accent1"] = lColor;
|
||||
}
|
||||
it = Scheme.find(L"accent2");
|
||||
if (Scheme.end() == it || !it->second.is_init())
|
||||
{
|
||||
lColor.SetRGBColor(0xC0,0x50,0x4D);
|
||||
Scheme[L"accent2"] = lColor;
|
||||
}
|
||||
it = Scheme.find(L"accent3");
|
||||
if (Scheme.end() == it || !it->second.is_init())
|
||||
{
|
||||
lColor.SetRGBColor(0x9B,0xBB,0x59);
|
||||
Scheme[L"accent3"] = lColor;
|
||||
}
|
||||
it = Scheme.find(L"accent4");
|
||||
if (Scheme.end() == it || !it->second.is_init())
|
||||
{
|
||||
lColor.SetRGBColor(0x80,0x64,0xA2);
|
||||
Scheme[L"accent4"] = lColor;
|
||||
}
|
||||
it = Scheme.find(L"accent5");
|
||||
if (Scheme.end() == it || !it->second.is_init())
|
||||
{
|
||||
lColor.SetRGBColor(0x4B,0xAC,0xC6);
|
||||
Scheme[L"accent5"] = lColor;
|
||||
}
|
||||
it = Scheme.find(L"accent6");
|
||||
if (Scheme.end() == it || !it->second.is_init())
|
||||
{
|
||||
lColor.SetRGBColor(0xF7,0x96,0x46);
|
||||
Scheme[L"accent6"] = lColor;
|
||||
}
|
||||
it = Scheme.find(L"hlink");
|
||||
if (Scheme.end() == it || !it->second.is_init())
|
||||
{
|
||||
lColor.SetRGBColor(0x00,0x00,0xFF);
|
||||
Scheme[L"hlink"] = lColor;
|
||||
}
|
||||
it = Scheme.find(L"folHlink");
|
||||
if (Scheme.end() == it || !it->second.is_init())
|
||||
{
|
||||
lColor.SetRGBColor(0x80, 0x00, 0x80);
|
||||
Scheme[L"folHlink"] = lColor;
|
||||
}
|
||||
|
||||
FillParentPointersForChilds();
|
||||
}
|
||||
protected:
|
||||
virtual void FillParentPointersForChilds()
|
||||
{
|
||||
|
||||
@ -35,6 +35,7 @@
|
||||
|
||||
#include "./../WrapperWritingElement.h"
|
||||
#include "./../Logic/UniFill.h"
|
||||
#include "./../Logic/Colors/SchemeClr.h"
|
||||
#include "./../Logic/Ln.h"
|
||||
#include "./../Logic/EffectStyle.h"
|
||||
|
||||
@ -84,6 +85,7 @@ namespace PPTX
|
||||
XmlUtils::CXmlNode oNode4 = node.ReadNode(_T("a:bgFillStyleLst"));
|
||||
XmlMacroLoadArray(oNode4, _T("*"), bgFillStyleLst, Logic::UniFill);
|
||||
|
||||
FillWithDefaults();
|
||||
FillParentPointersForChilds();
|
||||
}
|
||||
|
||||
@ -251,6 +253,113 @@ namespace PPTX
|
||||
pReader->Seek(_end_rec);
|
||||
}
|
||||
|
||||
void FillWithDefaults()
|
||||
{
|
||||
Logic::SolidFill* pSolidFill = NULL;
|
||||
Logic::SchemeClr* pSchemeClr = NULL;
|
||||
|
||||
// -------------- fill styles -------------------------
|
||||
if (fillStyleLst.size() < 3)
|
||||
{
|
||||
fillStyleLst.clear();
|
||||
|
||||
pSolidFill = new Logic::SolidFill();
|
||||
pSolidFill->m_namespace = L"a";
|
||||
pSchemeClr = new Logic::SchemeClr();
|
||||
pSchemeClr->val.set(L"phClr");
|
||||
pSolidFill->Color.Color.reset(pSchemeClr);
|
||||
fillStyleLst.push_back(Logic::UniFill());
|
||||
fillStyleLst.back().m_type = Logic::UniFill::solidFill;
|
||||
fillStyleLst.back().Fill.reset(pSolidFill);
|
||||
|
||||
pSolidFill = new Logic::SolidFill();
|
||||
pSolidFill->m_namespace = L"a";
|
||||
pSolidFill->Color.SetRGBColor(0,0,0);
|
||||
fillStyleLst.push_back(Logic::UniFill());
|
||||
fillStyleLst.back().m_type = Logic::UniFill::solidFill;
|
||||
fillStyleLst.back().Fill.reset(pSolidFill);
|
||||
|
||||
pSolidFill = new Logic::SolidFill();
|
||||
pSolidFill->m_namespace = L"a";
|
||||
pSolidFill->Color.SetRGBColor(0,0,0);
|
||||
fillStyleLst.push_back(Logic::UniFill());
|
||||
fillStyleLst.back().m_type = Logic::UniFill::solidFill;
|
||||
fillStyleLst.back().Fill.reset(pSolidFill);
|
||||
}
|
||||
|
||||
// -------------- back styles -------------------------
|
||||
if (bgFillStyleLst.size() < 3)
|
||||
{
|
||||
bgFillStyleLst.clear();
|
||||
|
||||
pSolidFill = new Logic::SolidFill();
|
||||
pSolidFill->m_namespace = L"a";
|
||||
pSchemeClr = new Logic::SchemeClr();
|
||||
pSchemeClr->val.set(L"phClr");
|
||||
pSolidFill->Color.Color.reset(pSchemeClr);
|
||||
bgFillStyleLst.push_back(Logic::UniFill());
|
||||
bgFillStyleLst.back().m_type = Logic::UniFill::solidFill;
|
||||
bgFillStyleLst.back().Fill.reset(pSolidFill);
|
||||
|
||||
pSolidFill = new Logic::SolidFill();
|
||||
pSolidFill->m_namespace = L"a";
|
||||
pSolidFill->Color.SetRGBColor(0,0,0);
|
||||
bgFillStyleLst.push_back(Logic::UniFill());
|
||||
bgFillStyleLst.back().m_type = Logic::UniFill::solidFill;
|
||||
bgFillStyleLst.back().Fill.reset(pSolidFill);
|
||||
|
||||
pSolidFill = new Logic::SolidFill();
|
||||
pSolidFill->m_namespace = L"a";
|
||||
pSolidFill->Color.SetRGBColor(0,0,0);
|
||||
bgFillStyleLst.push_back(Logic::UniFill());
|
||||
bgFillStyleLst.back().m_type = Logic::UniFill::solidFill;
|
||||
bgFillStyleLst.back().Fill.reset(pSolidFill);
|
||||
}
|
||||
|
||||
// -------------- line styles -------------------------
|
||||
if (lnStyleLst.size() < 3)
|
||||
{
|
||||
lnStyleLst.clear();
|
||||
|
||||
pSolidFill = new Logic::SolidFill();
|
||||
pSolidFill->m_namespace = L"a";
|
||||
pSchemeClr = new Logic::SchemeClr();
|
||||
pSchemeClr->val.set(L"phClr");
|
||||
pSchemeClr->Modifiers.push_back(Logic::ColorModifier());
|
||||
pSchemeClr->Modifiers.back().name = L"shade";
|
||||
pSchemeClr->Modifiers.back().val = 95000;
|
||||
pSchemeClr->Modifiers.push_back(Logic::ColorModifier());
|
||||
pSchemeClr->Modifiers.back().name = L"satMod";
|
||||
pSchemeClr->Modifiers.back().val = 105000;
|
||||
pSolidFill->Color.Color.reset(pSchemeClr);
|
||||
lnStyleLst.push_back(Logic::Ln());
|
||||
lnStyleLst.back().w = 9525;
|
||||
lnStyleLst.back().Fill.m_type = Logic::UniFill::solidFill;
|
||||
lnStyleLst.back().Fill.Fill.reset(pSolidFill);
|
||||
|
||||
pSolidFill = new Logic::SolidFill();
|
||||
pSolidFill->m_namespace = L"a";
|
||||
pSchemeClr = new Logic::SchemeClr();
|
||||
pSchemeClr->val.set(L"phClr");
|
||||
pSolidFill->Color.Color.reset(pSchemeClr);
|
||||
lnStyleLst.push_back(Logic::Ln());
|
||||
lnStyleLst.back().w = 25400;
|
||||
lnStyleLst.back().Fill.m_type = Logic::UniFill::solidFill;
|
||||
lnStyleLst.back().Fill.Fill.reset(pSolidFill);
|
||||
|
||||
pSolidFill = new Logic::SolidFill();
|
||||
pSolidFill->m_namespace = L"a";
|
||||
pSchemeClr = new Logic::SchemeClr();
|
||||
pSchemeClr->val.set(L"phClr");
|
||||
pSolidFill->Color.Color.reset(pSchemeClr);
|
||||
lnStyleLst.push_back(Logic::Ln());
|
||||
lnStyleLst.back().w = 38100;
|
||||
lnStyleLst.back().Fill.m_type = Logic::UniFill::solidFill;
|
||||
lnStyleLst.back().Fill.Fill.reset(pSolidFill);
|
||||
}
|
||||
|
||||
FillParentPointersForChilds();
|
||||
}
|
||||
public:
|
||||
std::wstring name;
|
||||
std::vector<Logic::UniFill> fillStyleLst;
|
||||
|
||||
@ -52,6 +52,7 @@ namespace PPTX
|
||||
majorFont = node.ReadNode(_T("a:majorFont"));
|
||||
minorFont = node.ReadNode(_T("a:minorFont"));
|
||||
|
||||
FillWithDefaults();
|
||||
FillParentPointersForChilds();
|
||||
}
|
||||
virtual std::wstring toXML() const
|
||||
@ -133,6 +134,20 @@ namespace PPTX
|
||||
|
||||
pReader->Seek(_end_rec);
|
||||
}
|
||||
void FillWithDefaults()
|
||||
{
|
||||
if (OOX::et_Unknown == majorFont.latin.m_eType)
|
||||
{
|
||||
majorFont.latin.m_name = _T("a:latin");
|
||||
majorFont.latin.typeface = L"Arial";
|
||||
}
|
||||
if (OOX::et_Unknown == minorFont.latin.m_eType)
|
||||
{
|
||||
minorFont.latin.m_name = _T("a:latin");
|
||||
minorFont.latin.typeface = L"Arial";
|
||||
}
|
||||
FillParentPointersForChilds();
|
||||
}
|
||||
|
||||
std::wstring name;
|
||||
Logic::FontCollection majorFont;
|
||||
|
||||
@ -261,13 +261,13 @@ std::wstring RtfFont::RenderToOOX(RenderParameter oRenderParameter)
|
||||
break;
|
||||
}
|
||||
sResult += L"<w:rFonts w:ascii=\"";
|
||||
sResult += sFontName;
|
||||
sResult += XmlUtils::EncodeXmlString( sFontName, true );
|
||||
sResult += L"\" w:eastAsia=\"";
|
||||
sResult += sFontName;
|
||||
sResult += XmlUtils::EncodeXmlString( sFontName, true );
|
||||
sResult += L"\" w:hAnsi=\"";
|
||||
sResult += sFontName;
|
||||
sResult += XmlUtils::EncodeXmlString( sFontName, true );
|
||||
sResult += L"\" w:cs=\"";
|
||||
sResult += sFontName;
|
||||
sResult += XmlUtils::EncodeXmlString( sFontName, true );
|
||||
sResult += L"\"";
|
||||
sResult += sHint;
|
||||
sResult += L"/>";
|
||||
@ -2948,8 +2948,14 @@ std::wstring RtfTableProperty::RenderToOOX(RenderParameter oRenderParameter)
|
||||
sDefCellMargins += L"<w:bottom w:w=\"" + std::to_wstring(m_nDefCellMarBottom) + L"\" w:type=\"dxa\"/>";
|
||||
if( PROP_DEF != m_nDefCellMarLeft && 3 == m_eDefCellMarLeftUnit )
|
||||
sDefCellMargins += L"<w:left w:w=\"" + std::to_wstring(m_nDefCellMarLeft) + L"\" w:type=\"dxa\"/>";
|
||||
else
|
||||
sDefCellMargins += L"<w:left w:w=\"0\" w:type=\"dxa\"/>";
|
||||
|
||||
if( PROP_DEF != m_nDefCellMarRight && 3 == m_eDefCellMarRightUnit )
|
||||
sDefCellMargins += L"<w:right w:w=\"" + std::to_wstring(m_nDefCellMarRight) + L"\" w:type=\"dxa\"/>";
|
||||
else
|
||||
sDefCellMargins += L"<w:right w:w=\"0\" w:type=\"dxa\"/>";
|
||||
|
||||
if( PROP_DEF != m_nDefCellMarTop && 3 == m_eDefCellMarTopUnit )
|
||||
sDefCellMargins += L"<w:top w:w=\"" + std::to_wstring(m_nDefCellMarTop) + L"\" w:type=\"dxa\"/>";
|
||||
|
||||
@ -3111,7 +3117,7 @@ std::wstring RtfRowProperty::RenderToOOX(RenderParameter oRenderParameter)
|
||||
{
|
||||
switch( m_eWidthEndInvCellUnit )
|
||||
{
|
||||
case mu_Percent: sResult += L"<w:wAfter w:type=\"pct\" w:w=\"" + std::to_wstring(m_nWidthEndInvCell) + L"%\"/>"; break;
|
||||
case mu_Percent: sResult += L"<w:wAfter w:type=\"pct\" w:w=\"" + std::to_wstring(m_nWidthEndInvCell) + L"\"/>"; break;
|
||||
case mu_Twips: sResult += L"<w:wAfter w:type=\"dxa\" w:w=\"" + std::to_wstring(m_nWidthEndInvCell) + L"\"/>"; break;
|
||||
default:
|
||||
break;
|
||||
|
||||
@ -270,6 +270,7 @@ public:
|
||||
m_byteShade = oColor.m_byteShade;
|
||||
m_byteTint = oColor.m_byteTint;
|
||||
|
||||
m_bAuto = oColor.m_bAuto;
|
||||
return (*this);
|
||||
}
|
||||
|
||||
|
||||
@ -1,50 +1,16 @@
|
||||
INCLUDEPATH += $$PWD/build/$$CORE_BUILDS_PLATFORM_PREFIX/include
|
||||
|
||||
MSVC = vc140
|
||||
|
||||
CORE_BOOST_LIBS = $$PWD/build/$$CORE_BUILDS_PLATFORM_PREFIX/lib
|
||||
|
||||
core_boost_libs {
|
||||
|
||||
core_windows {
|
||||
core_debug {
|
||||
LIBS += -L$$CORE_BOOST_LIBS -llibboost_system-$$MSVC-mt-gd-1_58 -llibboost_filesystem-$$MSVC-mt-gd-1_58
|
||||
}
|
||||
core_release {
|
||||
LIBS += -L$$CORE_BOOST_LIBS -llibboost_system-$$MSVC-mt-1_58 -llibboost_filesystem-$$MSVC-mt-1_58
|
||||
}
|
||||
BOOST_POSTFIX = vc140
|
||||
core_debug:BOOST_POSTFIX=$$BOOST_POSTFIX-mt-gd-1_58
|
||||
core_release:BOOST_POSTFIX=$$BOOST_POSTFIX-mt-1_58
|
||||
|
||||
core_boost_libs:LIBS += -L$$CORE_BOOST_LIBS -llibboost_system-$$BOOST_POSTFIX -llibboost_filesystem-$$BOOST_POSTFIX
|
||||
core_boost_regex:LIBS += -L$$CORE_BOOST_LIBS -llibboost_regex-$$BOOST_POSTFIX
|
||||
core_boost_date_time:LIBS += -L$$CORE_BOOST_LIBS -llibboost_date_time-$$BOOST_POSTFIX
|
||||
} else {
|
||||
LIBS += -L$$CORE_BOOST_LIBS -lboost_system -lboost_filesystem
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
core_boost_regex {
|
||||
|
||||
core_windows {
|
||||
core_debug {
|
||||
LIBS += -L$$CORE_BOOST_LIBS -llibboost_regex-$$MSVC-mt-gd-1_58
|
||||
}
|
||||
core_release {
|
||||
LIBS += -L$$CORE_BOOST_LIBS -llibboost_regex-$$MSVC-mt-1_58
|
||||
}
|
||||
} else {
|
||||
LIBS += -L$$CORE_BOOST_LIBS -lboost_regex
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
core_boost_date_time {
|
||||
|
||||
core_windows {
|
||||
core_debug {
|
||||
LIBS += -L$$CORE_BOOST_LIBS -llibboost_date_time-$$MSVC-mt-gd-1_58
|
||||
}
|
||||
core_release {
|
||||
LIBS += -L$$CORE_BOOST_LIBS -llibboost_date_time-$$MSVC-mt-1_58
|
||||
}
|
||||
} else {
|
||||
LIBS += -L$$CORE_BOOST_LIBS -lboost_date_time
|
||||
}
|
||||
|
||||
core_boost_libs:LIBS += -L$$CORE_BOOST_LIBS -lboost_system -lboost_filesystem
|
||||
core_boost_regex:LIBS += -L$$CORE_BOOST_LIBS -lboost_regex
|
||||
core_boost_date_time:LIBS += -L$$CORE_BOOST_LIBS -lboost_date_time
|
||||
}
|
||||
|
||||
@ -1,73 +0,0 @@
|
||||
SET SCRIPTPATH=%~dp0
|
||||
CD /D %~dp0
|
||||
|
||||
SET outputdir=%SCRIPTPATH%boost_1_58_0\build\%platform%
|
||||
echo "%outputdir%"
|
||||
|
||||
SET TOOLSET=msvc-14.0
|
||||
|
||||
CD "%SCRIPTPATH%\boost_1_58_0"
|
||||
call .\bootstrap.bat
|
||||
|
||||
if exist "stage" (
|
||||
RMDIR "stage" /S /Q
|
||||
)
|
||||
|
||||
md build
|
||||
|
||||
SET folder=build/win_32
|
||||
|
||||
if not exist "%folder%" (
|
||||
echo "x86..."
|
||||
|
||||
md %folder%
|
||||
md %folder%\static
|
||||
md %folder%\static_fpic
|
||||
md %folder%\shared
|
||||
|
||||
.\b2.exe --clean
|
||||
.\bjam.exe link=static --with-filesystem --with-system --with-date_time --with-regex --toolset=%TOOLSET% || goto :error
|
||||
XCOPY /Y stage\lib\* "%folder%\static\"
|
||||
|
||||
.\b2.exe --clean
|
||||
.\bjam.exe link=static cxxflags=-fPIC --with-filesystem --with-system --with-date_time --with-regex --toolset=%TOOLSET% || goto :error
|
||||
XCOPY /Y stage\lib\* "%folder%\static_fpic\"
|
||||
|
||||
.\b2.exe --clean
|
||||
.\bjam.exe link=shared --with-filesystem --with-system --with-date_time --with-regex --toolset=%TOOLSET% || goto :error
|
||||
XCOPY /Y stage\lib\* "%folder%\shared\"
|
||||
)
|
||||
|
||||
SET folder=build/win_64
|
||||
|
||||
|
||||
if not exist "%folder%" (
|
||||
echo "x64..."
|
||||
|
||||
if exist "stage" (
|
||||
RMDIR "stage" /S /Q
|
||||
)
|
||||
|
||||
md %folder%
|
||||
md %folder%\static
|
||||
md %folder%\static_fpic
|
||||
md %folder%\shared
|
||||
|
||||
.\b2.exe --clean
|
||||
.\bjam.exe link=static --with-filesystem --with-system --with-date_time --with-regex address-model=64 --toolset=%TOOLSET% || goto :error
|
||||
XCOPY /Y stage\lib\* "%folder%\static\"
|
||||
|
||||
.\b2.exe --clean
|
||||
.\bjam.exe link=static cxxflags=-fPIC --with-filesystem --with-system --with-date_time --with-regex address-model=64 --toolset=%TOOLSET% || goto :error
|
||||
XCOPY /Y stage\lib\* "%folder%\static_fpic\"
|
||||
|
||||
.\b2.exe --clean
|
||||
.\bjam.exe link=shared --with-filesystem --with-system --with-date_time --with-regex address-model=64 --toolset=%TOOLSET% || goto :error
|
||||
XCOPY /Y stage\lib\* "%folder%\shared\"
|
||||
)
|
||||
|
||||
exit /b 0
|
||||
|
||||
:error
|
||||
echo "Failed with error #%errorlevel%."
|
||||
exit /b %errorlevel%
|
||||
@ -1,61 +0,0 @@
|
||||
#!/bin/bash
|
||||
SCRIPTPATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||
|
||||
os=$(uname -s)
|
||||
platform=""
|
||||
|
||||
case "$os" in
|
||||
Linux*) platform="linux" ;;
|
||||
Darwin*) platform="mac" ;;
|
||||
*) exit ;;
|
||||
esac
|
||||
|
||||
architecture=$(uname -m)
|
||||
arch=""
|
||||
|
||||
case "$architecture" in
|
||||
x86_64*) arch="_64" ;;
|
||||
*) arch="_32" ;;
|
||||
esac
|
||||
|
||||
outputdir="$SCRIPTPATH/boost_1_58_0/build/$platform$arch"
|
||||
echo $outputdir
|
||||
|
||||
cd "$SCRIPTPATH/boost_1_58_0"
|
||||
|
||||
folder="build/$platform$arch"
|
||||
if [ ! -d $folder ]; then
|
||||
./bootstrap.sh --with-libraries=filesystem,system,date_time,regex
|
||||
|
||||
stage="stage"
|
||||
if [ -d $stage ]; then
|
||||
rm -R $stage
|
||||
fi
|
||||
|
||||
mkdir -p "$folder"
|
||||
mkdir -p "$folder/static"
|
||||
mkdir -p "$folder/static_fpic"
|
||||
mkdir -p "$folder/shared"
|
||||
|
||||
./b2 --clean
|
||||
./bjam link=static
|
||||
cp stage/lib/* "$folder/static/"
|
||||
|
||||
./b2 --clean
|
||||
./bjam link=static cxxflags=-fPIC
|
||||
cp stage/lib/* "$folder/static_fpic/"
|
||||
|
||||
./b2 --clean
|
||||
./bjam link=shared
|
||||
cp stage/lib/* "$folder/shared/"
|
||||
fi
|
||||
|
||||
if [[ "$OO_PLATFORM" == *"ios"* ]]
|
||||
then
|
||||
if [ ! -d "$SCRIPTPATH/boost_1_58_0/build/ios" ]; then
|
||||
cd "$SCRIPTPATH"
|
||||
./boost_ios.sh
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
@ -1,20 +0,0 @@
|
||||
SET SCRIPTPATH=%~dp0
|
||||
CD /D %~dp0
|
||||
|
||||
if exist "%SCRIPTPATH%boost_1_58_0.7z" (
|
||||
echo "boost already downloaded"
|
||||
) else (
|
||||
Powershell.exe Invoke-WebRequest -OutFile boost_1_58_0.7z https://downloads.sourceforge.net/project/boost/boost/1.58.0/boost_1_58_0.7z -UserAgent [Microsoft.PowerShell.Commands.PSUserAgent]::FireFox
|
||||
)
|
||||
|
||||
SET UNSIP_PROGRAMM="C:\Program Files\7-Zip\7z.exe"
|
||||
SET UNSIP_PROGRAMM2="C:\Program Files (x86)\7-Zip\7z.exe"
|
||||
if exist %UNSIP_PROGRAMM2% (
|
||||
SET UNSIP_PROGRAMM=%UNSIP_PROGRAMM2%
|
||||
)
|
||||
|
||||
if exist "%SCRIPTPATH%boost_1_58_0/" (
|
||||
echo "boost already extracted"
|
||||
) else (
|
||||
call %UNSIP_PROGRAMM% x "%SCRIPTPATH%/boost_1_58_0.7z" -o"%SCRIPTPATH%/"
|
||||
)
|
||||
@ -1,30 +0,0 @@
|
||||
#!/bin/bash
|
||||
SCRIPTPATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||
BOOST_URL=https://downloads.sourceforge.net/project/boost/boost/1.58.0/boost_1_58_0.7z
|
||||
|
||||
os=$(uname -s)
|
||||
platform=""
|
||||
|
||||
case "$os" in
|
||||
Linux*) platform="linux" ;;
|
||||
Darwin*) platform="mac" ;;
|
||||
*) exit ;;
|
||||
esac
|
||||
|
||||
if [[ -f "$SCRIPTPATH/boost_1_58_0.7z" ]]
|
||||
then
|
||||
echo "boost already downloaded"
|
||||
else
|
||||
wget $BOOST_URL || curl -O -L $BOOST_URL
|
||||
fi
|
||||
|
||||
if [ -d "$SCRIPTPATH/boost_1_58_0" ]; then
|
||||
echo "boost already extracted"
|
||||
else
|
||||
if [[ "$platform" == *"linux"* ]]
|
||||
then
|
||||
7z x -y "$SCRIPTPATH/boost_1_58_0.7z" -o"$SCRIPTPATH/"
|
||||
else
|
||||
7za x "$SCRIPTPATH/boost_1_58_0.7z" -o"$SCRIPTPATH/"
|
||||
fi
|
||||
fi
|
||||
4
Common/3dParty/cef/.gitignore
vendored
Normal file
4
Common/3dParty/cef/.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
# Ignore everything in this directory
|
||||
*
|
||||
# Except this file
|
||||
!.gitignore
|
||||
@ -1 +0,0 @@
|
||||
echo "build: OK!"
|
||||
@ -1,3 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "build: OK!"
|
||||
@ -1,62 +0,0 @@
|
||||
Add-Type -AssemblyName System.IO.Compression.FileSystem
|
||||
|
||||
# ----------------------------------------------------------------------------------------------
|
||||
# download a file
|
||||
# ----------------------------------------------------------------------------------------------
|
||||
function Download-File
|
||||
{
|
||||
param ([string]$url,[string]$file)
|
||||
|
||||
$downloadRequired = $true
|
||||
if (Test-Path $file)
|
||||
{
|
||||
$localModified = (Get-Item $file).CreationTime
|
||||
$webRequest = [System.Net.HttpWebRequest]::Create($url)
|
||||
$webRequest.Method = "HEAD"
|
||||
$webResponse = $webRequest.GetResponse()
|
||||
$remoteLastModified = ($webResponse.LastModified) -as [DateTime]
|
||||
$webResponse.Close()
|
||||
|
||||
if ($remoteLastModified -gt $localModified)
|
||||
{
|
||||
Write-Host "$file is out of date"
|
||||
}
|
||||
else
|
||||
{
|
||||
$downloadRequired = $false
|
||||
}
|
||||
}
|
||||
|
||||
if ($downloadRequired)
|
||||
{
|
||||
$clnt = new-object System.Net.WebClient
|
||||
Write-Host "Downloading from $url to $file"
|
||||
$clnt.DownloadFile($url, $file)
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Host "$file is up to date."
|
||||
}
|
||||
|
||||
return $downloadRequired
|
||||
}
|
||||
|
||||
# ----------------------------------------------------------------------------------------------
|
||||
# unzip a file
|
||||
# ----------------------------------------------------------------------------------------------
|
||||
function RemoveCef
|
||||
{
|
||||
param([string]$outpath)
|
||||
|
||||
if (Test-Path $outpath)
|
||||
{
|
||||
Write-Host "Remove folder $outpath"
|
||||
Remove-Item $outpath -Force -Recurse
|
||||
}
|
||||
}
|
||||
|
||||
$output = Download-File -url $args[0] -file $args[1]
|
||||
if ($output)
|
||||
{
|
||||
RemoveCef -outpath $args[2]
|
||||
}
|
||||
@ -1,58 +0,0 @@
|
||||
@echo off
|
||||
|
||||
SET SCRIPTPATH=%~dp0
|
||||
CD /D %~dp0
|
||||
|
||||
setlocal
|
||||
|
||||
SET UNSIP_PROGRAMM="%ProgramFiles%\7-Zip\7z.exe"
|
||||
SET UNSIP_PROGRAMM2="%ProgramFiles(x86)%\7-Zip\7z.exe"
|
||||
if exist %UNSIP_PROGRAMM2% (
|
||||
SET UNSIP_PROGRAMM=%UNSIP_PROGRAMM2%
|
||||
)
|
||||
|
||||
if defined BUILD_PLATFORM (
|
||||
if not "%BUILD_PLATFORM%"=="%BUILD_PLATFORM:xp=%" (
|
||||
SET "BUILD_PLATFORMS=win_64 win_32 winxp_64 winxp_32"
|
||||
GOTO :found
|
||||
)
|
||||
if not "%BUILD_PLATFORM%"=="%BUILD_PLATFORM:all=%" (
|
||||
SET "BUILD_PLATFORMS=win_64 win_32"
|
||||
GOTO :found
|
||||
)
|
||||
)
|
||||
|
||||
SET "BUILD_PLATFORMS=win_32"
|
||||
if defined ProgramFiles(x86) (
|
||||
SET "BUILD_PLATFORMS=win_64"
|
||||
GOTO :found
|
||||
)
|
||||
if defined TARGET (
|
||||
SET "BUILD_PLATFORMS=%TARGET%"
|
||||
GOTO :found
|
||||
)
|
||||
|
||||
echo "error"
|
||||
GOTO :end
|
||||
|
||||
:found
|
||||
for %%a in (%BUILD_PLATFORMS%) do (
|
||||
echo "platform: %%a"
|
||||
mkdir "%SCRIPTPATH%%%a"
|
||||
cd "%SCRIPTPATH%%%a"
|
||||
Powershell.exe -executionpolicy remotesigned -file %SCRIPTPATH%download.ps1 http://d2ettrnqo7v976.cloudfront.net/cef/3163/%%a/cef_binary.7z cef_binary.7z cef_binary
|
||||
|
||||
if exist "cef_binary" (
|
||||
echo "cef_binary.7z already extracted"
|
||||
) else (
|
||||
call %UNSIP_PROGRAMM% x "cef_binary.7z"
|
||||
mkdir build
|
||||
xcopy /Y /S cef_binary\Release\* build\
|
||||
xcopy /Y /S cef_binary\Resources\* build\
|
||||
)
|
||||
)
|
||||
|
||||
:end
|
||||
endlocal
|
||||
|
||||
@echo on
|
||||
@ -1,88 +0,0 @@
|
||||
#!/bin/bash
|
||||
SCRIPTPATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||
|
||||
os=$(uname -s)
|
||||
platform=""
|
||||
|
||||
case "$os" in
|
||||
Linux*) platform="linux" ;;
|
||||
Darwin*) platform="mac" ;;
|
||||
*) exit ;;
|
||||
esac
|
||||
|
||||
architecture=$(uname -m)
|
||||
arch=""
|
||||
|
||||
case "$architecture" in
|
||||
x86_64*) arch="_64" ;;
|
||||
*) arch="_32" ;;
|
||||
esac
|
||||
|
||||
if [[ -d "$SCRIPTPATH/$platform$arch" ]]
|
||||
then
|
||||
echo
|
||||
else
|
||||
mkdir "$SCRIPTPATH/$platform$arch"
|
||||
fi
|
||||
|
||||
cd "$SCRIPTPATH/$platform$arch"
|
||||
|
||||
if [ -d "build" ]
|
||||
then
|
||||
echo ""
|
||||
else
|
||||
mkdir "build"
|
||||
fi
|
||||
cef_binary=cef_binary
|
||||
cef_arch=$cef_binary.7z
|
||||
cef_version="3163"
|
||||
|
||||
if [[ "$platform" == *"linux"* ]]
|
||||
then
|
||||
cef_version="3202"
|
||||
cef_url=http://d2ettrnqo7v976.cloudfront.net/cef/$cef_version/$platform$arch/$cef_arch
|
||||
else
|
||||
cef_url=http://d2ettrnqo7v976.cloudfront.net/cef/$cef_version/$platform/$cef_arch
|
||||
fi
|
||||
|
||||
if [[ "$platform" == *"linux"* ]]
|
||||
then
|
||||
|
||||
if [[ -f $cef_arch ]]
|
||||
then
|
||||
cef_mod_time=$(date -d"$(curl -sI $cef_url | awk '/Last-Modified/ {print ($3, $4, $5, $6, $7, $8)}')" +"%s")
|
||||
local_mod_time=$(stat -c %Y $cef_arch)
|
||||
if [[ $cef_mod_time -eq $local_mod_time ]]
|
||||
then
|
||||
echo "cef_binary already downloaded"
|
||||
else
|
||||
wget $cef_url -O $cef_arch
|
||||
rm -fr $cef_binary/
|
||||
fi
|
||||
else
|
||||
wget $cef_url
|
||||
rm -fr $cef_binary/
|
||||
fi
|
||||
|
||||
if [ -d $cef_binary ]
|
||||
then
|
||||
echo "cef_binary already extracted"
|
||||
else
|
||||
7z x -y $cef_arch
|
||||
fi
|
||||
|
||||
cp -r -t build/ ./$cef_binary/Release/* ./$cef_binary/Resources/*
|
||||
chmod a+xr build/locales
|
||||
fi
|
||||
|
||||
if [[ "$platform" == *"mac"* ]]
|
||||
then
|
||||
if [ -d "build/Chromium Embedded Framework.framework" ]
|
||||
then
|
||||
echo "cef_binary already extracted"
|
||||
else
|
||||
wget $cef_url || curl -O $cef_url
|
||||
7za x $cef_arch
|
||||
mv "$cef_binary" "build/Chromium Embedded Framework.framework"
|
||||
fi
|
||||
fi
|
||||
@ -1 +0,0 @@
|
||||
echo "build: OK!"
|
||||
@ -1,3 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "build: OK!"
|
||||
@ -1,84 +0,0 @@
|
||||
@echo off
|
||||
|
||||
SET SCRIPTPATH=%~dp0
|
||||
CD /D %~dp0
|
||||
|
||||
setlocal
|
||||
|
||||
SET ICU_MAJOR_VER=58
|
||||
SET ICU_MINOR_VER=2
|
||||
|
||||
SET VC=%ProgramFiles%\Microsoft Visual Studio 14.0\VC
|
||||
SET VC64=%ProgramFiles(x86)%\Microsoft Visual Studio 14.0\VC
|
||||
if exist %VC64% (
|
||||
SET VC=%VC64%
|
||||
)
|
||||
|
||||
SET UNSIP_PROGRAMM="%ProgramFiles%\7-Zip\7z.exe"
|
||||
SET UNSIP_PROGRAMM2="%ProgramFiles(x86)%\7-Zip\7z.exe"
|
||||
if exist %UNSIP_PROGRAMM2% (
|
||||
SET UNSIP_PROGRAMM=%UNSIP_PROGRAMM2%
|
||||
)
|
||||
|
||||
if defined BUILD_PLATFORM (
|
||||
if not "%BUILD_PLATFORM%"=="%BUILD_PLATFORM:all=%" (
|
||||
SET "BUILD_PLATFORMS=win_64 win_32"
|
||||
GOTO :found
|
||||
)
|
||||
if not "%BUILD_PLATFORM%"=="%BUILD_PLATFORM:xp=%" (
|
||||
SET "BUILD_PLATFORMS=win_64 win_32"
|
||||
GOTO :found
|
||||
)
|
||||
)
|
||||
|
||||
SET "BUILD_PLATFORMS=win_32"
|
||||
if defined ProgramFiles(x86) (
|
||||
SET "BUILD_PLATFORMS=win_64"
|
||||
GOTO :found
|
||||
)
|
||||
if defined TARGET (
|
||||
SET "BUILD_PLATFORMS=%TARGET%"
|
||||
GOTO :found
|
||||
)
|
||||
|
||||
echo "error"
|
||||
GOTO :end
|
||||
|
||||
:found
|
||||
for %%a in (%BUILD_PLATFORMS%) do (
|
||||
cd "%SCRIPTPATH%"
|
||||
if not exist "%%a" (
|
||||
md "%%a"
|
||||
)
|
||||
if not exist "%%a\build" (
|
||||
md "%%a\build"
|
||||
)
|
||||
cd "%SCRIPTPATH%%%a"
|
||||
if exist "icu" (
|
||||
echo "icu already exported"
|
||||
) else (
|
||||
svn export https://github.com/unicode-org/icu/tags/release-%ICU_MAJOR_VER%-%ICU_MINOR_VER%/icu4c ./icu
|
||||
)
|
||||
|
||||
if "%%a" == "win_64" (
|
||||
call "%VC%\vcvarsall.bat" x64
|
||||
MSBuild.exe icu\source\allinone\allinone.sln /p:Configuration=Release /p:PlatformToolset=v140 /p:Platform="X64"
|
||||
XCOPY /Y "icu\bin64\icudt%ICU_MAJOR_VER%.dll" "build\"
|
||||
XCOPY /Y "icu\bin64\icuuc%ICU_MAJOR_VER%.dll" "build\"
|
||||
XCOPY /Y "icu\lib64\icudt.lib" "build\"
|
||||
XCOPY /Y "icu\lib64\icuuc.lib" "build\"
|
||||
) else (
|
||||
call "%VC%\vcvarsall.bat" x86
|
||||
MSBuild.exe icu\source\allinone\allinone.sln /p:Configuration=Release /p:PlatformToolset=v140 /p:Platform="Win32"
|
||||
XCOPY /Y "icu\bin\icudt%ICU_MAJOR_VER%.dll" "build\"
|
||||
XCOPY /Y "icu\bin\icuuc%ICU_MAJOR_VER%.dll" "build\"
|
||||
XCOPY /Y "icu\lib\icudt.lib" "build\"
|
||||
XCOPY /Y "icu\lib\icuuc.lib" "build\"
|
||||
)
|
||||
)
|
||||
cd "%SCRIPTPATH%"
|
||||
|
||||
:end
|
||||
endlocal
|
||||
|
||||
@echo on
|
||||
@ -1,91 +0,0 @@
|
||||
#!/bin/bash
|
||||
SCRIPTPATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||
|
||||
ICU_MAJOR_VER=58
|
||||
ICU_MINOR_VER=2
|
||||
|
||||
SHARED_LIB_VER=$ICU_MAJOR_VER.$ICU_MINOR_VER
|
||||
|
||||
os=$(uname -s)
|
||||
platform=""
|
||||
|
||||
case "$os" in
|
||||
Linux*)
|
||||
platform="linux"
|
||||
BUILD_PLATFORM=Linux
|
||||
SHARED_LIB_EXT=.so.$SHARED_LIB_VER
|
||||
SHARED_LIB_SHORT_EXT=.so.$ICU_MAJOR_VER
|
||||
;;
|
||||
Darwin*)
|
||||
platform="mac"
|
||||
BUILD_PLATFORM=MacOSX
|
||||
SHARED_LIB_EXT=.$SHARED_LIB_VER.dylib
|
||||
SHARED_LIB_SHORT_EXT=.$ICU_MAJOR_VER.dylib
|
||||
;;
|
||||
*) exit ;;
|
||||
esac
|
||||
|
||||
|
||||
architecture=$(uname -m)
|
||||
arch=""
|
||||
|
||||
case "$architecture" in
|
||||
x86_64*) arch="_64" ;;
|
||||
*) arch="_32" ;;
|
||||
esac
|
||||
|
||||
if [[ -d "$SCRIPTPATH/$platform$arch" ]]
|
||||
then
|
||||
echo
|
||||
else
|
||||
mkdir "$SCRIPTPATH/$platform$arch"
|
||||
fi
|
||||
|
||||
cd "$SCRIPTPATH/$platform$arch"
|
||||
|
||||
if [ -d "build" ]
|
||||
then
|
||||
echo ""
|
||||
else
|
||||
mkdir "build"
|
||||
fi
|
||||
|
||||
if [ -d "./icu" ]
|
||||
then
|
||||
echo "icu already exported"
|
||||
else
|
||||
svn export https://github.com/unicode-org/icu/tags/release-$ICU_MAJOR_VER-$ICU_MINOR_VER/icu4c ./icu
|
||||
fi
|
||||
|
||||
if [[ "$platform" == *"linux"* ]]
|
||||
then
|
||||
# Workaround for building icu older than 60.0
|
||||
# on systems without xlocale.h (removed from glibc since 2.26)
|
||||
# See https://sourceware.org/glibc/wiki/Release/2.26#Removal_of_.27xlocale.h.27
|
||||
# See https://bugs.archlinux.org/task/55246
|
||||
sed -i 's/xlocale/locale/' ./icu/source/i18n/digitlst.cpp
|
||||
fi
|
||||
|
||||
if [[ "$platform" == *"mac"* ]]
|
||||
then
|
||||
sed -i -e 's/cmd\, \"%s %s -o %s%s %s %s%s %s %s\"\,/cmd\, \"%s %s -o %s%s %s %s %s %s %s\"\,/' ./icu/source/tools/pkgdata/pkgdata.cpp
|
||||
fi
|
||||
|
||||
cd ./icu/source/
|
||||
|
||||
if [ ! -f "./Makefile" ]
|
||||
then
|
||||
./runConfigureICU $BUILD_PLATFORM
|
||||
fi
|
||||
|
||||
make
|
||||
|
||||
if [ ! -d "$SCRIPTPATH/$platform$arch/usr/local" ]
|
||||
then
|
||||
DESTDIR="$SCRIPTPATH/$platform$arch" make install
|
||||
fi
|
||||
|
||||
cd ../../
|
||||
|
||||
cp "./icu/source/lib/libicudata$SHARED_LIB_EXT" "build/libicudata$SHARED_LIB_SHORT_EXT"
|
||||
cp "./icu/source/lib/libicuuc$SHARED_LIB_EXT" "build/libicuuc$SHARED_LIB_SHORT_EXT"
|
||||
@ -23,3 +23,11 @@ core_mac {
|
||||
LIBS += $$PWD/$$CORE_BUILDS_PLATFORM_PREFIX/build/libicuuc.$${ICU_MAJOR_VER}.dylib
|
||||
LIBS += $$PWD/$$CORE_BUILDS_PLATFORM_PREFIX/build/libicudata.$${ICU_MAJOR_VER}.dylib
|
||||
}
|
||||
|
||||
core_ios {
|
||||
INCLUDEPATH += $$PWD/$$CORE_BUILDS_PLATFORM_PREFIX/build/include
|
||||
|
||||
LIBS += $$PWD/$$CORE_BUILDS_PLATFORM_PREFIX/build/libicudata.a
|
||||
LIBS += $$PWD/$$CORE_BUILDS_PLATFORM_PREFIX/build/libicui18n.a
|
||||
LIBS += $$PWD/$$CORE_BUILDS_PLATFORM_PREFIX/build/libicuuc.a
|
||||
}
|
||||
|
||||
272
Common/3dParty/icu/icu_ios.sh
Executable file
272
Common/3dParty/icu/icu_ios.sh
Executable file
@ -0,0 +1,272 @@
|
||||
#!/bin/bash
|
||||
|
||||
ICU_VERSION="58"
|
||||
|
||||
ICU_DIR="$PWD/icu"
|
||||
|
||||
ICU_SOURCE="${ICU_DIR}/source"
|
||||
|
||||
PREBUILD="$PWD/ios/icu_build"
|
||||
|
||||
CONFIG_PREFIX=" --enable-extras=yes \
|
||||
--enable-tools=yes \
|
||||
--enable-icuio=yes \
|
||||
--enable-strict=no \
|
||||
--enable-static \
|
||||
--enable-shared=no \
|
||||
--enable-tests=yes \
|
||||
--disable-renaming \
|
||||
--enable-samples=no \
|
||||
--enable-dyload=no \
|
||||
--with-data-packaging=static"
|
||||
|
||||
CFLAGS="-O3 -D__STDC_INT64__ -fno-exceptions -fno-short-wchar -fno-short-enums -fembed-bitcode"
|
||||
|
||||
CXXFLAGS="${CFLAGS} -std=c++11 -fembed-bitcode"
|
||||
|
||||
#will set value to 1
|
||||
defines_config_set_1=(
|
||||
"UCONFIG_NO_BREAK_ITERATION"
|
||||
"UCONFIG_NO_FORMATTING"
|
||||
"UCONFIG_NO_REGULAR_EXPRESSIONS"
|
||||
"CONFIG_NO_CONVERSION"
|
||||
"U_DISABLE_RENAMING"
|
||||
)
|
||||
|
||||
#will set value to 0
|
||||
defines_config_set_0=(
|
||||
"U_HAVE_NL_LANGINFO_CODESET"
|
||||
"UCONFIG_NO_TRANSLITERATION"
|
||||
"U_USING_ICU_NAMESPACE"
|
||||
)
|
||||
|
||||
#will set value to 1
|
||||
defines_utypes=(
|
||||
"U_CHARSET_IS_UTF8"
|
||||
)
|
||||
|
||||
function prebuild() {
|
||||
|
||||
svn export http://source.icu-project.org/repos/icu/tags/release-${ICU_VERSION}/icu4c/ ${ICU_DIR} --native-eol LF
|
||||
|
||||
echo "===== REMOVING data from bundle ====="
|
||||
|
||||
#Data bundle reduction
|
||||
{
|
||||
echo "GENRB_CLDR_VERSION = 32.0.1"
|
||||
echo "GENRB_SYNTHETIC_ALIAS = "
|
||||
echo "GENRB_ALIAS_SOURCE = \$(GENRB_SYNTHETIC_ALIAS) "
|
||||
echo "GENRB_SOURCE = "
|
||||
} >"${ICU_SOURCE}/data/locales/reslocal.mk"
|
||||
|
||||
{
|
||||
echo "LANG_CLDR_VERSION = 32.0.1"
|
||||
echo "LANG_SYNTHETIC_ALIAS = "
|
||||
echo "LANG_ALIAS_SOURCE = \$(LANG_SYNTHETIC_ALIAS) "
|
||||
echo "LANG_SOURCE = "
|
||||
} >"${ICU_SOURCE}/data/lang/reslocal.mk"
|
||||
|
||||
{
|
||||
echo "CURR_CLDR_VERSION = 32.0.1"
|
||||
echo "CURR_SYNTHETIC_ALIAS = "
|
||||
echo "CURR_ALIAS_SOURCE = \$(CURR_SYNTHETIC_ALIAS) "
|
||||
echo "CURR_SOURCE = "
|
||||
} >"${ICU_SOURCE}/data/curr/reslocal.mk"
|
||||
|
||||
{
|
||||
echo "REGION_CLDR_VERSION = 32.0.1"
|
||||
echo "REGION_SYNTHETIC_ALIAS = "
|
||||
echo "REGION_ALIAS_SOURCE = \$(REGION_SYNTHETIC_ALIAS) "
|
||||
echo "REGION_SOURCE = "
|
||||
} >"${ICU_SOURCE}/data/region/reslocal.mk"
|
||||
|
||||
{
|
||||
echo "UNIT_CLDR_VERSION = 32.0.1"
|
||||
echo "UNIT_SYNTHETIC_ALIAS = "
|
||||
echo "UNIT_ALIAS_SOURCE = \$(UNIT_SYNTHETIC_ALIAS) "
|
||||
echo "UNIT_SOURCE = "
|
||||
} >"${ICU_SOURCE}/data/unit/reslocal.mk"
|
||||
|
||||
{
|
||||
echo "ZONE_CLDR_VERSION = 32.0.1"
|
||||
echo "ZONE_SYNTHETIC_ALIAS = "
|
||||
echo "ZONE_ALIAS_SOURCE = \$(ZONE_SYNTHETIC_ALIAS) "
|
||||
echo "ZONE_SOURCE = "
|
||||
} >"${ICU_SOURCE}/data/zone/reslocal.mk"
|
||||
|
||||
#find "${ICU_SOURCES}/data/mappings/" -name '*.mk' ! -name 'ucmcore.mk' -type f -exec rm -f {} +
|
||||
|
||||
mv "${ICU_SOURCE}/data/mappings/ucmcore.mk" "${ICU_SOURCE}/data/mappings/ucmcore.not_used" 2>/dev/null
|
||||
mv "${ICU_SOURCE}/data/mappings/ucmfiles.mk" "${ICU_SOURCE}/data/mappings/ucmfiles.not_used" 2>/dev/null
|
||||
mv "${ICU_SOURCE}/data/mappings/ucmebcdic.mk" "${ICU_SOURCE}/data/mappings/ucmebcdic.not_used" 2>/dev/null
|
||||
mv "${ICU_SOURCE}/data/mappings/ucmlocal.mk" "${ICU_SOURCE}/data/mappings/ucmlocal.not_used" 2>/dev/null
|
||||
|
||||
echo "===== Modify icu/source/common/unicode/uconfig.h ====="
|
||||
|
||||
cp "${ICU_SOURCE}/common/unicode/uconfig" "${ICU_SOURCE}/common/unicode/uconfig.h" 2>/dev/null
|
||||
cp "${ICU_SOURCE}/common/unicode/uconfig.h" "${ICU_SOURCE}/common/unicode/uconfig" 2>/dev/null
|
||||
|
||||
for var in "${defines_config_set_1[@]}"; do
|
||||
sed "/define __UCONFIG_H__/a \\
|
||||
#ifndef ${var} \\
|
||||
#define ${var} 1 \\
|
||||
#endif \\
|
||||
" "${ICU_SOURCE}/common/unicode/uconfig.h" >"${ICU_SOURCE}/common/unicode/uconfig.tmp"
|
||||
|
||||
mv "${ICU_SOURCE}/common/unicode/uconfig.tmp" "${ICU_SOURCE}/common/unicode/uconfig.h"
|
||||
done
|
||||
|
||||
for var in "${defines_config_set_0[@]}"; do
|
||||
sed "/define __UCONFIG_H__/a \\
|
||||
#ifndef ${var} \\
|
||||
#define ${var} 0 \\
|
||||
#endif \\
|
||||
" "${ICU_SOURCE}/common/unicode/uconfig.h" >"${ICU_SOURCE}/common/unicode/uconfig.tmp"
|
||||
|
||||
mv "${ICU_SOURCE}/common/unicode/uconfig.tmp" "${ICU_SOURCE}/common/unicode/uconfig.h"
|
||||
done
|
||||
|
||||
echo "===== Modify icu/source/common/unicode/utypes.h ====="
|
||||
|
||||
cp "${ICU_SOURCE}/common/unicode/utypes" "${ICU_SOURCE}/common/unicode/utypes.h" 2>/dev/null
|
||||
cp "${ICU_SOURCE}/common/unicode/utypes.h" "${ICU_SOURCE}/common/unicode/utypes" 2>/dev/null
|
||||
|
||||
for var in "${defines_utypes[@]}"; do
|
||||
sed "/define UTYPES_H/a \\
|
||||
#ifndef ${var} \\
|
||||
#define ${var} 1 \\
|
||||
#endif \\
|
||||
" "${ICU_SOURCE}/common/unicode/utypes.h" >"${ICU_SOURCE}/common/unicode/utypes.tmp"
|
||||
|
||||
mv "${ICU_SOURCE}/common/unicode/utypes.tmp" "${ICU_SOURCE}/common/unicode/utypes.h"
|
||||
|
||||
done
|
||||
|
||||
echo "===== Patching icu/source/tools/pkgdata/pkgdata.cpp for iOS ====="
|
||||
|
||||
cp "${ICU_SOURCE}/tools/pkgdata/pkgdata" "${ICU_SOURCE}/tools/pkgdata/pkgdata.cpp" 2>/dev/null
|
||||
cp "${ICU_SOURCE}/tools/pkgdata/pkgdata.cpp" "${ICU_SOURCE}/tools/pkgdata/pkgdata" 2>/dev/null
|
||||
|
||||
sed "s/int result = system(cmd);/ \\
|
||||
#if defined(IOS_SYSTEM_FIX) \\
|
||||
pid_t pid; \\
|
||||
char * argv[2]; argv[0] = cmd; argv[1] = NULL; \\
|
||||
posix_spawn(\&pid, argv[0], NULL, NULL, argv, environ); \\
|
||||
waitpid(pid, NULL, 0); \\
|
||||
int result = 0; \\
|
||||
#else \\
|
||||
int result = system(cmd); \\
|
||||
#endif \\
|
||||
/g" "${ICU_SOURCE}/tools/pkgdata/pkgdata.cpp" >"${ICU_SOURCE}/tools/pkgdata/pkgdata.tmp"
|
||||
|
||||
sed "/#include <stdlib.h>/a \\
|
||||
#if defined(IOS_SYSTEM_FIX) \\
|
||||
#include <spawn.h> \\
|
||||
extern char **environ; \\
|
||||
#endif \\
|
||||
" "${ICU_SOURCE}/tools/pkgdata/pkgdata.tmp" >"${ICU_SOURCE}/tools/pkgdata/pkgdata.cpp"
|
||||
|
||||
#mv "${ICU_SOURCE}/tools/pkgdata/pkgdata.tmp" "${ICU_SOURCE}/tools/pkgdata/pkgdata.cpp"
|
||||
|
||||
echo "==============================="
|
||||
echo "===== Run build for MacOS ====="
|
||||
echo "==============================="
|
||||
|
||||
export PLATFORM_PREFIX="${PWD}/mac-build"
|
||||
|
||||
export CPPFLAGS=${CFLAGS}
|
||||
|
||||
mkdir -p ${PREBUILD}
|
||||
|
||||
cd ${PREBUILD}
|
||||
|
||||
sh ${ICU_SOURCE}/runConfigureICU MacOSX --prefix=${PLATFORM_PREFIX} ${CONFIG_PREFIX}
|
||||
|
||||
make clean
|
||||
make -j4
|
||||
make install
|
||||
|
||||
cd ..
|
||||
}
|
||||
|
||||
function build() {
|
||||
|
||||
unset CXX
|
||||
unset CC
|
||||
unset CFLAGS
|
||||
unset CXXFLAGS
|
||||
unset LDFLAGS
|
||||
|
||||
echo "preparing $1 toolchain"
|
||||
|
||||
export BUILD_DIR="${PWD}/build-${2}"
|
||||
|
||||
DEVELOPER="$(xcode-select --print-path)"
|
||||
SDKROOT="$(xcodebuild -version -sdk $4 | grep -E '^Path' | sed 's/Path: //')"
|
||||
ARCH=$2
|
||||
|
||||
ICU_FLAGS="-I$ICU_SOURCE/common/ -I$ICU_SOURCE/tools/tzcode/ "
|
||||
|
||||
export ADDITION_FLAG="-DIOS_SYSTEM_FIX"
|
||||
|
||||
export CXX="$DEVELOPER/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++"
|
||||
export CC="$DEVELOPER/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
|
||||
export CFLAGS="-fembed-bitcode -isysroot $SDKROOT -I$SDKROOT/usr/include/ -I./include/ -arch $ARCH -miphoneos-version-min=9.0 $ICU_FLAGS $CFLAGS ${ADDITION_FLAG}"
|
||||
export CXXFLAGS="${CXXFLAGS} -fembed-bitcode -stdlib=libc++ -isysroot $SDKROOT -I$SDKROOT/usr/include/ -I./include/ -arch $ARCH -miphoneos-version-min=9.0 $ICU_FLAGS ${ADDITION_FLAG}"
|
||||
export LDFLAGS="-fembed-bitcode -stdlib=libc++ -L$SDKROOT/usr/lib/ -isysroot $SDKROOT -Wl,-dead_strip -miphoneos-version-min=9.0 -lstdc++ ${ADDITION_FLAG}"
|
||||
|
||||
mkdir -p ${BUILD_DIR}
|
||||
cd ${BUILD_DIR}
|
||||
|
||||
sh ${ICU_SOURCE}/configure --host=$3 --with-library-suffix=${2} --with-cross-build=${PREBUILD} ${CONFIG_PREFIX}
|
||||
|
||||
make clean
|
||||
make -j4
|
||||
make install
|
||||
|
||||
cd ..
|
||||
}
|
||||
|
||||
prebuild
|
||||
|
||||
echo "------------------------------------------------------"
|
||||
echo " ICU build armv7 libraries"
|
||||
echo "------------------------------------------------------"
|
||||
|
||||
build "armv7" "armv7" "armv7-apple-darwin" "iphoneos"
|
||||
|
||||
echo "------------------------------------------------------"
|
||||
echo " ICU build arm64 libraries"
|
||||
echo "------------------------------------------------------"
|
||||
|
||||
build "arm64" "arm64" "aarch64-apple-darwin" "iphoneos"
|
||||
|
||||
echo "------------------------------------------------------"
|
||||
echo " ICU combining x86_64 libraries"
|
||||
echo "------------------------------------------------------"
|
||||
|
||||
build "x86_64" "x86_64" "x86_64-apple-darwin" "iphonesimulator"
|
||||
|
||||
cd ..
|
||||
|
||||
echo "------------------------------------------------------"
|
||||
echo " ICU combining x86_64, armv7 and arm64 libraries"
|
||||
echo "------------------------------------------------------"
|
||||
|
||||
function buildUniversal() {
|
||||
lipo -create -output "${PWD}/ios/build/$1.a" \
|
||||
"${PWD}/ios/build-x86_64/lib/$1x86_64.a" \
|
||||
"${PWD}/ios/build-arm64/lib/$1arm64.a" \
|
||||
"${PWD}/ios/build-armv7/lib/$1armv7.a"
|
||||
}
|
||||
|
||||
mkdir -p build
|
||||
mkdir -p ios/build
|
||||
mkdir -p ios/build/include
|
||||
mkdir -p ios/build/include/unicode
|
||||
|
||||
cp ${ICU_SOURCE}/common/unicode/*.h ios/build/include/unicode
|
||||
|
||||
buildUniversal "libicuuc"
|
||||
buildUniversal "libicui18n"
|
||||
buildUniversal "libicudata"
|
||||
@ -1,35 +0,0 @@
|
||||
#!/bin/bash
|
||||
SCRIPTPATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||
|
||||
cd "$SCRIPTPATH"/openssl
|
||||
|
||||
os=$(uname -s)
|
||||
platform=""
|
||||
|
||||
case "$os" in
|
||||
Linux*) platform="linux" ;;
|
||||
Darwin*) platform="darwin64-x86_64-cc" ;;
|
||||
*) exit ;;
|
||||
esac
|
||||
|
||||
platformLinux=""
|
||||
|
||||
architecture=$(uname -m)
|
||||
arch=""
|
||||
|
||||
if [[ "$platform" == "linux" ]]
|
||||
then
|
||||
case "$architecture" in
|
||||
x86_64*) arch="-64" ;;
|
||||
*) arch="-32" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
echo "$platform$arch"
|
||||
|
||||
if [ ! -f Makefile ]; then
|
||||
#perl ./Configure $platform$arch
|
||||
./config no-shared no-asm
|
||||
fi
|
||||
|
||||
make build_libs
|
||||
@ -1,8 +0,0 @@
|
||||
#!/bin/bash
|
||||
SCRIPTPATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||
|
||||
cd "$SCRIPTPATH"
|
||||
|
||||
if [ ! -d openssl ]; then
|
||||
git clone --depth=1 https://github.com/openssl/openssl.git
|
||||
fi
|
||||
@ -2,6 +2,7 @@ core_linux {
|
||||
|
||||
INCLUDEPATH += $$PWD/openssl/include
|
||||
|
||||
QMAKE_LFLAGS += -fvisibility=hidden
|
||||
LIBS += $$PWD/openssl/libssl.a
|
||||
LIBS += $$PWD/openssl/libcrypto.a
|
||||
|
||||
|
||||
@ -1,33 +0,0 @@
|
||||
SET SCRIPTPATH=%~dp0
|
||||
CD /D %~dp0
|
||||
|
||||
SET PATH=%SCRIPTPATH%depot_tools;%PATH%
|
||||
SET DEPOT_TOOLS_WIN_TOOLCHAIN=0
|
||||
SET GYP_MSVS_VERSION=2015
|
||||
|
||||
call powershell -File .\fix-static_crt.ps1
|
||||
cd v8
|
||||
|
||||
call gn gen out.gn/win_64/release --args="is_debug=false target_cpu=\"x64\" v8_target_cpu=\"x64\" v8_static_library=true is_component_build=false v8_use_snapshot=false is_clang=false"
|
||||
call ninja -C out.gn/win_64/release || goto :error
|
||||
|
||||
call gn gen out.gn/win_64/debug --args="is_debug=true target_cpu=\"x64\" v8_target_cpu=\"x64\" v8_static_library=true is_component_build=false v8_use_snapshot=false is_clang=false"
|
||||
call ninja -C out.gn/win_64/debug || goto :error
|
||||
|
||||
call gn gen out.gn/win_32/release --args="is_debug=false target_cpu=\"x86\" v8_target_cpu=\"x86\" v8_static_library=true is_component_build=false v8_use_snapshot=false is_clang=false"
|
||||
call ninja -C out.gn/win_32/release || goto :error
|
||||
|
||||
call gn gen out.gn/win_32/debug --args="is_debug=true target_cpu=\"x86\" v8_target_cpu=\"x86\" v8_static_library=true is_component_build=false v8_use_snapshot=false is_clang=false"
|
||||
call ninja -C out.gn/win_32/debug || goto :error
|
||||
|
||||
rem v8_use_snapshot=true v8_use_external_startup_data=true
|
||||
if not "%BUILD_PLATFORM%"=="%BUILD_PLATFORM:xp=%" (
|
||||
call %~dp0v8_xp\build.bat || goto :error
|
||||
cd %~dp0
|
||||
)
|
||||
|
||||
exit /b 0
|
||||
|
||||
:error
|
||||
echo "Failed with error #%errorlevel%."
|
||||
exit /b %errorlevel%
|
||||
@ -1,45 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
export PATH=`pwd`/depot_tools:"$PATH"
|
||||
|
||||
SCRIPTPATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||
|
||||
os=$(uname -s)
|
||||
platform=""
|
||||
|
||||
case "$os" in
|
||||
Linux*) platform="linux" ;;
|
||||
Darwin*) platform="mac" ;;
|
||||
*) exit ;;
|
||||
esac
|
||||
|
||||
architecture=$(uname -m)
|
||||
arch=""
|
||||
|
||||
case "$architecture" in
|
||||
x86_64*) arch="_64" ;;
|
||||
*) arch="_32" ;;
|
||||
esac
|
||||
|
||||
cd "$SCRIPTPATH/v8"
|
||||
|
||||
if [[ "$platform$arch" == "linux_64" ]]
|
||||
then
|
||||
gn gen out.gn/linux_64 --args='is_debug=false target_cpu="x64" v8_target_cpu="x64" v8_static_library=true is_component_build=false v8_use_snapshot=false is_clang=false use_sysroot=false'
|
||||
ninja -C out.gn/linux_64
|
||||
fi
|
||||
|
||||
if [[ "$platform$arch" == "linux_32" ]]
|
||||
then
|
||||
gn gen out.gn/linux_32 --args='is_debug=false target_cpu="x86" v8_target_cpu="x86" v8_static_library=true is_component_build=false v8_use_snapshot=false is_clang=false use_sysroot=false'
|
||||
ninja -C out.gn/linux_32
|
||||
fi
|
||||
|
||||
if [[ "$platform" == "mac" ]]
|
||||
then
|
||||
sed -i -e "s/if (mac_sdk_version != mac_sdk_min_build_override/if (false \&\& mac_sdk_version != mac_sdk_min_build_override/g" build/config/mac/mac_sdk.gni
|
||||
# for new macOS!!!
|
||||
#sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
|
||||
gn gen out.gn/mac_64 --args='is_debug=false target_cpu="x64" v8_static_library=true is_component_build=false v8_use_snapshot=false'
|
||||
ninja -C out.gn/mac_64
|
||||
fi
|
||||
@ -1,28 +0,0 @@
|
||||
SET SCRIPTPATH=%~dp0
|
||||
CD /D %~dp0
|
||||
|
||||
SET DEPOT_TOOLS_WIN_TOOLCHAIN=0
|
||||
SET GYP_MSVS_VERSION=2015
|
||||
|
||||
if exist "depot_tools" (
|
||||
echo "depot_tools already fetched"
|
||||
) else (
|
||||
call git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
|
||||
call powershell -File .\fix-depot_tools.ps1
|
||||
)
|
||||
|
||||
SET PATH=%SCRIPTPATH%depot_tools;%PATH%
|
||||
|
||||
call gclient
|
||||
|
||||
call ./depot_tools/fetch v8
|
||||
cd v8
|
||||
call git checkout -b 6.0 -t branch-heads/6.0
|
||||
cd ../
|
||||
|
||||
call gclient sync --no-history
|
||||
|
||||
if not "%BUILD_PLATFORM%"=="%BUILD_PLATFORM:xp=%" (
|
||||
call v8_xp\fetch.bat
|
||||
cd %~dp0
|
||||
)
|
||||
@ -1,49 +0,0 @@
|
||||
#!/bin/bash
|
||||
SCRIPTPATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||
|
||||
cd "$SCRIPTPATH"
|
||||
|
||||
if [ ! -d "depot_tools" ]
|
||||
then
|
||||
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
|
||||
fi
|
||||
|
||||
export PATH=`pwd`/depot_tools:"$PATH"
|
||||
gclient
|
||||
|
||||
#detect gcc version
|
||||
currentver="$(gcc -dumpversion)"
|
||||
requiredver="6.0.0"
|
||||
v8_version="6.0"
|
||||
|
||||
if [ "$(printf '%s\n' "$requiredver" "$currentver" | sort -V | head -n1)" = "$requiredver" ]
|
||||
then
|
||||
v8_version="7.0"
|
||||
fi
|
||||
|
||||
echo "v8 version: $v8_version"
|
||||
|
||||
if [ ! -d "./v8" ]
|
||||
then
|
||||
fetch v8
|
||||
cd v8
|
||||
git checkout -b $v8_version -t branch-heads/$v8_version
|
||||
else
|
||||
cd v8
|
||||
fi
|
||||
|
||||
gclient sync --no-history
|
||||
|
||||
os=$(uname -s)
|
||||
platform=""
|
||||
case "$os" in
|
||||
Linux*) platform="linux" ;;
|
||||
*) exit ;;
|
||||
esac
|
||||
|
||||
cd "$SCRIPTPATH"
|
||||
|
||||
if [[ "$platform" == "linux" ]]
|
||||
then
|
||||
./fetch_linux_correct.sh
|
||||
fi
|
||||
@ -1,40 +0,0 @@
|
||||
#!/bin/bash
|
||||
SCRIPTPATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||
|
||||
export PATH=`pwd`/depot_tools:"$PATH"
|
||||
|
||||
if [ -d "$SCRIPTPATH/v8/third_party/binutils/Linux_x64/Release" ]; then
|
||||
rm -rf "$SCRIPTPATH/v8/third_party/binutils/Linux_x64/Release"
|
||||
fi
|
||||
if [ -d "$SCRIPTPATH/v8/third_party/binutils/Linux_ia32/Release" ]; then
|
||||
rm -rf "$SCRIPTPATH/v8/third_party/binutils/Linux_ia32/Release"
|
||||
fi
|
||||
|
||||
cd "$SCRIPTPATH/v8"
|
||||
gclient sync --no-history
|
||||
|
||||
if [ -d "$SCRIPTPATH/v8/third_party/binutils/Linux_x64/Release/bin" ]; then
|
||||
cd "$SCRIPTPATH/v8/third_party/binutils/Linux_x64/Release/bin"
|
||||
for file in *
|
||||
do
|
||||
echo $file
|
||||
if [ $file != "ld.gold" ]
|
||||
then
|
||||
mv "$file" "old_${file}"
|
||||
ln -s /usr/bin/"$file" ./"$file"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
if [ -d "$SCRIPTPATH/v8/third_party/binutils/Linux_ia32/Release/bin" ]; then
|
||||
cd "$SCRIPTPATH/v8/third_party/binutils/Linux_ia32/Release/bin"
|
||||
for file in *
|
||||
do
|
||||
echo $file
|
||||
if [ $file != "ld.gold" ]
|
||||
then
|
||||
mv "$file" "old_${file}"
|
||||
ln -s /usr/bin/"$file" ./"$file"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
@ -1,4 +0,0 @@
|
||||
$gclient_path = "depot_tools\gclient.bat"
|
||||
$fetch_path = "depot_tools\fetch.bat"
|
||||
(Get-Content $gclient_path) | ForEach-Object { $_ -replace "^(`"%~dp0python`")", "call $&" } | Set-Content $gclient_path
|
||||
(Get-Content $fetch_path) | ForEach-Object { $_ -replace "^(%~dp0python)", "call $&" } | Set-Content $fetch_path
|
||||
@ -1,2 +0,0 @@
|
||||
$gn_path = "v8\build\config\win\BUILD.gn"
|
||||
(Get-Content $gn_path) | ForEach-Object { $_ -replace ":static_crt", ":dynamic_crt" } | Set-Content $gn_path
|
||||
@ -343,9 +343,7 @@ namespace OOX
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CTbl::fromXML(XmlUtils::CXmlLiteReader& oReader)
|
||||
void CTbl::fromXML(XmlUtils::CXmlLiteReader& oReader)
|
||||
{
|
||||
if ( oReader.IsEmptyNode() )
|
||||
return;
|
||||
@ -411,7 +409,13 @@ namespace OOX
|
||||
else if ( _T("w:sdt") == sName )
|
||||
pItem = new CSdt( oReader );
|
||||
else if ( _T("w:tblGrid") == sName )
|
||||
m_oTblGrid = oReader;
|
||||
{
|
||||
if (false == m_oTblGrid.IsInit())
|
||||
{
|
||||
m_oTblGrid = new CTblGrid();
|
||||
}
|
||||
m_oTblGrid->fromXML(oReader);
|
||||
}
|
||||
else if ( _T("w:tblPr") == sName )
|
||||
{
|
||||
pItem = m_oTableProperties = new CTableProperty( oReader );
|
||||
@ -657,7 +661,11 @@ namespace OOX
|
||||
}
|
||||
else if ( _T("w:trPr") == sName )
|
||||
{
|
||||
pItem = m_pTableRowProperties = new CTableRowProperties( oReader );
|
||||
if (!m_pTableRowProperties)
|
||||
{
|
||||
pItem = m_pTableRowProperties = new CTableRowProperties();
|
||||
}
|
||||
m_pTableRowProperties->fromXML(oReader);
|
||||
}
|
||||
|
||||
if ( pItem )
|
||||
@ -872,7 +880,12 @@ namespace OOX
|
||||
pItem = new CTbl( oReader );
|
||||
else if ( _T("w:tcPr") == sName )
|
||||
{
|
||||
pItem = m_pTableCellProperties = new CTableCellProperties( oReader );
|
||||
if (!m_pTableCellProperties)
|
||||
{
|
||||
pItem = m_pTableCellProperties = new CTableCellProperties();
|
||||
}
|
||||
|
||||
m_pTableCellProperties->fromXML(oReader);
|
||||
}
|
||||
|
||||
if ( pItem )
|
||||
@ -905,9 +918,8 @@ namespace OOX
|
||||
|
||||
return sResult;
|
||||
}
|
||||
void CTc::ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
|
||||
void CTc::ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
|
||||
{
|
||||
// Читаем атрибуты
|
||||
WritingElement_ReadAttributes_Start( oReader )
|
||||
WritingElement_ReadAttributes_ReadSingle( oReader, _T("w:id"), m_sId )
|
||||
WritingElement_ReadAttributes_End( oReader )
|
||||
|
||||
@ -438,15 +438,87 @@ namespace ComplexTypes
|
||||
m_oVertAnchor.Init();
|
||||
m_oVertAnchor->SetValue(SimpleTypes::vanchorMargin);
|
||||
}
|
||||
if(false == m_oTblpX.IsInit() && false == m_oTblpXSpec.IsInit())
|
||||
if(false == m_oTblpXSpec.IsInit())
|
||||
{
|
||||
m_oTblpXSpec.Init();
|
||||
m_oTblpXSpec->SetValue(SimpleTypes::xalignLeft);
|
||||
if(false == m_oTblpX.IsInit())
|
||||
{
|
||||
m_oTblpX.Init();
|
||||
m_oTblpX->FromTwips(0);
|
||||
}
|
||||
//Several values of sprmTDxaAbs have special meanings as specified by
|
||||
//[ECMA-376] Part 4, Section 2.18.114. These values are specified as
|
||||
//follows.
|
||||
switch(m_oTblpX->ToTwips())
|
||||
{
|
||||
case 0:
|
||||
m_oTblpX.reset(NULL);
|
||||
m_oTblpXSpec.Init();
|
||||
m_oTblpXSpec->SetValue(SimpleTypes::xalignLeft);
|
||||
break;
|
||||
case -4:
|
||||
m_oTblpX.reset(NULL);
|
||||
m_oTblpXSpec.Init();
|
||||
m_oTblpXSpec->SetValue(SimpleTypes::xalignCenter);
|
||||
break;
|
||||
case -8:
|
||||
m_oTblpX.reset(NULL);
|
||||
m_oTblpXSpec.Init();
|
||||
m_oTblpXSpec->SetValue(SimpleTypes::xalignRight);
|
||||
break;
|
||||
case -12:
|
||||
m_oTblpX.reset(NULL);
|
||||
m_oTblpXSpec.Init();
|
||||
m_oTblpXSpec->SetValue(SimpleTypes::xalignInside);
|
||||
break;
|
||||
case -16:
|
||||
m_oTblpX.reset(NULL);
|
||||
m_oTblpXSpec.Init();
|
||||
m_oTblpXSpec->SetValue(SimpleTypes::xalignOutside);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(false == m_oTblpY.IsInit() && false == m_oTblpYSpec.IsInit())
|
||||
if(false == m_oTblpYSpec.IsInit())
|
||||
{
|
||||
m_oTblpY.Init();
|
||||
m_oTblpY->FromTwips(0);
|
||||
if(false == m_oTblpY.IsInit())
|
||||
{
|
||||
m_oTblpY.Init();
|
||||
m_oTblpY->FromTwips(0);
|
||||
}
|
||||
//The meanings that are provided correspond to
|
||||
//values that are defined in [ECMA-376] Part 4, Section 2.18.115 ST_YAlign
|
||||
//(Vertical Alignment Location).
|
||||
switch(m_oTblpY->ToTwips())
|
||||
{
|
||||
case 0:
|
||||
m_oVertAnchor.Init();
|
||||
m_oVertAnchor->SetValue(SimpleTypes::vanchorText);
|
||||
break;
|
||||
case -4:
|
||||
m_oTblpY.reset(NULL);
|
||||
m_oTblpYSpec.Init();
|
||||
m_oTblpYSpec->SetValue(SimpleTypes::yalignTop);
|
||||
break;
|
||||
case -8:
|
||||
m_oTblpY.reset(NULL);
|
||||
m_oTblpYSpec.Init();
|
||||
m_oTblpYSpec->SetValue(SimpleTypes::yalignCenter);
|
||||
break;
|
||||
case -12:
|
||||
m_oTblpY.reset(NULL);
|
||||
m_oTblpYSpec.Init();
|
||||
m_oTblpYSpec->SetValue(SimpleTypes::yalignBottom);
|
||||
break;
|
||||
case -16:
|
||||
m_oTblpY.reset(NULL);
|
||||
m_oTblpYSpec.Init();
|
||||
m_oTblpYSpec->SetValue(SimpleTypes::yalignInside);
|
||||
break;
|
||||
case -20:
|
||||
m_oTblpY.reset(NULL);
|
||||
m_oTblpYSpec.Init();
|
||||
m_oTblpYSpec->SetValue(SimpleTypes::yalignOutside);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
virtual void FromXML(XmlUtils::CXmlNode& oNode)
|
||||
|
||||
@ -2267,6 +2267,8 @@ xmlns:xr16=\"http://schemas.microsoft.com/office/spreadsheetml/2017/revision16\"
|
||||
m_oReadPath = oPath;
|
||||
IFileContainer::Read( oRootPath, oPath );
|
||||
|
||||
return;// todooo option read
|
||||
|
||||
XmlUtils::CXmlLiteReader oReader;
|
||||
|
||||
if ( !oReader.FromFile( oPath.GetPath() ) )
|
||||
|
||||
@ -47,6 +47,18 @@
|
||||
#include <unistd.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
std::string wget_url_validate(const std::string& url)
|
||||
{
|
||||
std::string::size_type pos = 0;
|
||||
const char* url_ptr = url.c_str();
|
||||
while ('-' == *url_ptr++) // '\0' => break
|
||||
++pos;
|
||||
if (*url_ptr == '\0')
|
||||
return "";
|
||||
|
||||
return url.substr(pos);
|
||||
}
|
||||
|
||||
int download_external(const std::wstring& sUrl, const std::wstring& sOutput)
|
||||
{
|
||||
int nReturnCode = -1;
|
||||
@ -68,13 +80,14 @@ int download_external(const std::wstring& sUrl, const std::wstring& sOutput)
|
||||
|
||||
case 0: // child process
|
||||
{
|
||||
const char* nargs[6];
|
||||
const char* nargs[7];
|
||||
nargs[0] = "/usr/bin/curl";
|
||||
nargs[1] = sUrlA.c_str();
|
||||
nargs[2] = "--output";
|
||||
nargs[3] = sOutputA.c_str();
|
||||
nargs[4] = "--silent";
|
||||
nargs[5] = NULL;
|
||||
nargs[1] = "--url";
|
||||
nargs[2] = sUrlA.c_str();
|
||||
nargs[3] = "--output";
|
||||
nargs[4] = sOutputA.c_str();
|
||||
nargs[5] = "--silent";
|
||||
nargs[6] = NULL;
|
||||
|
||||
const char* nenv[3];
|
||||
nenv[0] = "LD_PRELOAD=";
|
||||
@ -97,6 +110,8 @@ int download_external(const std::wstring& sUrl, const std::wstring& sOutput)
|
||||
|
||||
if (0 != nReturnCode && NSFile::CFileBinary::Exists(L"/usr/bin/wget"))
|
||||
{
|
||||
std::string sUrlValidateA = wget_url_validate(sUrlA);
|
||||
|
||||
pid_t pid = fork(); // create child process
|
||||
int status;
|
||||
|
||||
@ -109,7 +124,7 @@ int download_external(const std::wstring& sUrl, const std::wstring& sOutput)
|
||||
{
|
||||
const char* nargs[6];
|
||||
nargs[0] = "/usr/bin/wget";
|
||||
nargs[1] = sUrlA.c_str();
|
||||
nargs[1] = sUrlValidateA.c_str();
|
||||
nargs[2] = "-O";
|
||||
nargs[3] = sOutputA.c_str();
|
||||
nargs[4] = "-q";
|
||||
|
||||
@ -17,7 +17,11 @@ isEmpty(PUBLISHER_NAME){
|
||||
}
|
||||
|
||||
win32 {
|
||||
CURRENT_YEAR = $$system("echo %Date:~6,4%")
|
||||
CURRENT_YEAR = $$system(wmic PATH Win32_LocalTime GET ^Year /FORMAT:VALUE | find \"=\")
|
||||
CURRENT_YEAR = $$replace(CURRENT_YEAR, "Year=", "")
|
||||
CURRENT_YEAR = $$replace(CURRENT_YEAR, "\r", "")
|
||||
CURRENT_YEAR = $$replace(CURRENT_YEAR, "\n", "")
|
||||
CURRENT_YEAR = $$replace(CURRENT_YEAR, "\t", "")
|
||||
}
|
||||
|
||||
!win32 {
|
||||
@ -131,6 +135,7 @@ core_linux {
|
||||
core_mac {
|
||||
DEFINES += LINUX _LINUX MAC _MAC
|
||||
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.11
|
||||
QMAKE_LFLAGS += -isysroot $$QMAKE_MAC_SDK_PATH
|
||||
}
|
||||
|
||||
# PREFIXES
|
||||
@ -141,8 +146,13 @@ core_windows {
|
||||
QMAKE_CXXFLAGS += /MP
|
||||
|
||||
equals(TEMPLATE, app) {
|
||||
core_win_64:QMAKE_LFLAGS_CONSOLE = /SUBSYSTEM:CONSOLE,5.02
|
||||
core_win_32:QMAKE_LFLAGS_CONSOLE = /SUBSYSTEM:CONSOLE,5.01
|
||||
console {
|
||||
core_win_64:QMAKE_LFLAGS_CONSOLE = /SUBSYSTEM:CONSOLE,5.02
|
||||
core_win_32:QMAKE_LFLAGS_CONSOLE = /SUBSYSTEM:CONSOLE,5.01
|
||||
} else {
|
||||
core_win_64:QMAKE_LFLAGS_WINDOWS = /SUBSYSTEM:WINDOWS,5.02
|
||||
core_win_32:QMAKE_LFLAGS_WINDOWS = /SUBSYSTEM:WINDOWS,5.01
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -281,6 +291,12 @@ OBJECTS_DIR = $$PWD_ROOT_DIR/core_build/$$CORE_BUILDS_PLATFORM_PREFIX/$$CORE_BUI
|
||||
MOC_DIR = $$PWD_ROOT_DIR/core_build/$$CORE_BUILDS_PLATFORM_PREFIX/$$CORE_BUILDS_CONFIGURATION_PREFIX/moc
|
||||
RCC_DIR = $$PWD_ROOT_DIR/core_build/$$CORE_BUILDS_PLATFORM_PREFIX/$$CORE_BUILDS_CONFIGURATION_PREFIX/rcc
|
||||
UI_DIR = $$PWD_ROOT_DIR/core_build/$$CORE_BUILDS_PLATFORM_PREFIX/$$CORE_BUILDS_CONFIGURATION_PREFIX/ui
|
||||
build_xp {
|
||||
OBJECTS_DIR = $$OBJECTS_DIR/xp
|
||||
MOC_DIR = $$MOC_DIR/xp
|
||||
RCC_DIR = $$RCC_DIR/xp
|
||||
UI_DIR = $$UI_DIR/xp
|
||||
}
|
||||
}
|
||||
|
||||
CORE_BUILDS_LIBRARIES_PATH = $$CORE_ROOT_DIR/build/lib/$$CORE_BUILDS_PLATFORM_PREFIX
|
||||
|
||||
@ -392,6 +392,7 @@ namespace NSCommon
|
||||
{
|
||||
NSFonts::IFontManager* pManager = applicationFonts->GenerateFontManager();
|
||||
NSFonts::IFontsCache* pCache = NSFonts::NSFontCache::Create();
|
||||
pCache->SetCacheSize(3);
|
||||
pCache->SetStreams(applicationFonts->GetStreams());
|
||||
pManager->SetOwnerCache(pCache);
|
||||
|
||||
@ -427,6 +428,9 @@ namespace NSCommon
|
||||
pRenderer->put_Width(lWidthPix * 25.4 / dDpi);
|
||||
pRenderer->put_Height(lHeightPix * 25.4 / dDpi);
|
||||
|
||||
bool isUseMapForStreams = false;
|
||||
std::map<std::wstring, bool> mapUsedFiles;
|
||||
|
||||
for (int index = 0; index < nCountFonts; ++index)
|
||||
{
|
||||
std::map<std::wstring, CFontInfoJS>::iterator pPair = mapFonts.find(arrFonts[index]);
|
||||
@ -476,6 +480,9 @@ namespace NSCommon
|
||||
|
||||
if (NULL != pInfoCur)
|
||||
{
|
||||
if (isUseMapForStreams)
|
||||
mapUsedFiles.insert(std::pair<std::wstring, bool>(pInfoCur->m_wsFontPath, true));
|
||||
|
||||
pManager->LoadFontFromFile(pInfoCur->m_wsFontPath, 0, 14, dDpi, dDpi);
|
||||
}
|
||||
pRenderer->put_FontPath(pInfoCur->m_wsFontPath);
|
||||
@ -503,6 +510,9 @@ namespace NSCommon
|
||||
|
||||
if (NULL != pInfoCur)
|
||||
{
|
||||
if (isUseMapForStreams)
|
||||
mapUsedFiles.insert(std::pair<std::wstring, bool>(pInfoCur->m_wsFontPath, true));
|
||||
|
||||
pManager->LoadFontFromFile(pInfoCur->m_wsFontPath, 0, 14, dDpi, dDpi);
|
||||
}
|
||||
pRenderer->put_FontPath(pInfoCur->m_wsFontPath);
|
||||
@ -514,6 +524,11 @@ namespace NSCommon
|
||||
pRenderer->put_FontSize(14);
|
||||
|
||||
pRenderer->CommandDrawText(pPair->second.m_sName, 5, 25.4 * (index * lH1_px + lH1_px) / dDpi - 2, 0, 0);
|
||||
|
||||
if (isUseMapForStreams)
|
||||
applicationFonts->GetStreams()->CheckStreams(mapUsedFiles);
|
||||
else
|
||||
applicationFonts->GetStreams()->Clear();
|
||||
}
|
||||
|
||||
std::wstring strThumbnailPath = strFolderThumbnails + L"/fonts_thumbnail";
|
||||
@ -1210,6 +1225,22 @@ std::wstring CorrectDir(const std::wstring& sDir)
|
||||
return sDir.substr(pos1, pos2 - pos1);
|
||||
}
|
||||
|
||||
std::wstring CorrectValue(const std::wstring& value)
|
||||
{
|
||||
if (value.empty())
|
||||
return L"";
|
||||
|
||||
const wchar_t* data = value.c_str();
|
||||
|
||||
std::wstring::size_type pos1 = (data[0] == '\"') ? 1 : 0;
|
||||
std::wstring::size_type pos2 = value.length();
|
||||
|
||||
if (data[pos2 - 1] == '\"')
|
||||
--pos2;
|
||||
|
||||
return value.substr(pos1, pos2 - pos1);
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
int wmain(int argc, wchar_t** argv)
|
||||
#else
|
||||
@ -1252,6 +1283,7 @@ int main(int argc, char** argv)
|
||||
|
||||
if (sKey == L"--use-system")
|
||||
{
|
||||
sValue = CorrectValue(sValue);
|
||||
if (sValue == L"1" || sValue == L"true")
|
||||
bIsUseSystemFonts = true;
|
||||
}
|
||||
@ -1283,7 +1315,7 @@ int main(int argc, char** argv)
|
||||
{
|
||||
if (srcPrev != src)
|
||||
{
|
||||
arFontsDirs.push_back(std::wstring(srcPrev, src - srcPrev));
|
||||
arFontsDirs.push_back(CorrectDir(std::wstring(srcPrev, src - srcPrev)));
|
||||
}
|
||||
src++;
|
||||
srcPrev = src;
|
||||
@ -1294,7 +1326,7 @@ int main(int argc, char** argv)
|
||||
|
||||
if (src > srcPrev)
|
||||
{
|
||||
arFontsDirs.push_back(std::wstring(srcPrev, src - srcPrev));
|
||||
arFontsDirs.push_back(CorrectDir(std::wstring(srcPrev, src - srcPrev)));
|
||||
}
|
||||
}
|
||||
else if (sKey == L"--output-web")
|
||||
|
||||
@ -791,4 +791,42 @@
|
||||
#define ASC_EVENT_TYPE_SPELLCHECK_MESSAGE 22004
|
||||
#define ASC_EVENT_TYPE_SPELLCHECK_TURN_ON 22005
|
||||
|
||||
#define ASC_MENU_EVENT_TYPE_DO_NONPRINTING_DISPLAY 22006
|
||||
|
||||
// Comments
|
||||
#define ASC_MENU_EVENT_TYPE_ADD_COMMENT 23001
|
||||
#define ASC_MENU_EVENT_TYPE_ADD_COMMENTS 23002
|
||||
#define ASC_MENU_EVENT_TYPE_REMOVE_COMMENT 23003
|
||||
#define ASC_MENU_EVENT_TYPE_CHANGE_COMMENTS 23004
|
||||
#define ASC_MENU_EVENT_TYPE_REMOVE_COMMENTS 23005
|
||||
#define ASC_MENU_EVENT_TYPE_CHANGE_COMMENT_DATA 23006
|
||||
#define ASC_MENU_EVENT_TYPE_LOCK_COMMENT 23007
|
||||
#define ASC_MENU_EVENT_TYPE_UNLOCK_COMMENT 23008
|
||||
#define ASC_MENU_EVENT_TYPE_SHOW_COMMENT 23009
|
||||
#define ASC_MENU_EVENT_TYPE_HIDE_COMMENT 23010
|
||||
#define ASC_MENU_EVENT_TYPE_UPDATE_COMMENT_POSITION 23011
|
||||
#define ASC_MENU_EVENT_TYPE_DOCUMENT_PLACE_CHANGED 23012
|
||||
#define ASC_MENU_EVENT_TYPE_DO_SELECT_COMMENT 23101
|
||||
#define ASC_MENU_EVENT_TYPE_DO_SHOW_COMMENT 23102
|
||||
#define ASC_MENU_EVENT_TYPE_DO_SELECT_COMMENTS 23103
|
||||
#define ASC_MENU_EVENT_TYPE_DO_DESELECT_COMMENTS 23104
|
||||
#define ASC_MENU_EVENT_TYPE_DO_ADD_COMMENT 23105
|
||||
#define ASC_MENU_EVENT_TYPE_DO_REMOVE_COMMENT 23106
|
||||
#define ASC_MENU_EVENT_TYPE_DO_REMOVE_ALL_COMMENTS 23107
|
||||
#define ASC_MENU_EVENT_TYPE_DO_CHANGE_COMMENT 23108
|
||||
|
||||
// Track reviews
|
||||
#define ASC_MENU_EVENT_TYPE_SHOW_REVISIONS_CHANGE 24001
|
||||
|
||||
#define ASC_MENU_EVENT_TYPE_DO_SET_TRACK_REVISIONS 24101
|
||||
#define ASC_MENU_EVENT_TYPE_DO_BEGIN_VIEWMODE_IN_REVIEW 24102
|
||||
#define ASC_MENU_EVENT_TYPE_DO_END_VIEWMODE_IN_REVIEW 24103
|
||||
#define ASC_MENU_EVENT_TYPE_DO_ACCEPT_ALL_CHANGES 24104
|
||||
#define ASC_MENU_EVENT_TYPE_DO_REJECT_ALL_CHANGES 24105
|
||||
#define ASC_MENU_EVENT_TYPE_DO_GET_PREV_REVISIONS_CHANGE 24106
|
||||
#define ASC_MENU_EVENT_TYPE_DO_GET_NEXT_REVISIONS_CHANGE 24107
|
||||
#define ASC_MENU_EVENT_TYPE_DO_ACCEPT_CHANGES 24108
|
||||
#define ASC_MENU_EVENT_TYPE_DO_REJECT_CHANGES 24109
|
||||
#define ASC_MENU_EVENT_TYPE_DO_FOLLOW_REVISION_MOVE 24110
|
||||
|
||||
#endif //_BUILD_EDITOR_DEFINES_CROSSPLATFORM_H_
|
||||
|
||||
@ -72,6 +72,21 @@ std::wstring CorrectDir(const std::wstring& sDir)
|
||||
|
||||
return sDir.substr(pos1, pos2 - pos1);
|
||||
}
|
||||
std::wstring CorrectValue(const std::wstring& value)
|
||||
{
|
||||
if (value.empty())
|
||||
return L"";
|
||||
|
||||
const wchar_t* data = value.c_str();
|
||||
|
||||
std::wstring::size_type pos1 = (data[0] == '\"') ? 1 : 0;
|
||||
std::wstring::size_type pos2 = value.length();
|
||||
|
||||
if (data[pos2 - 1] == '\"')
|
||||
--pos2;
|
||||
|
||||
return value.substr(pos1, pos2 - pos1);
|
||||
}
|
||||
void string_replace(std::wstring& text, const std::wstring& replaceFrom, const std::wstring& replaceTo)
|
||||
{
|
||||
size_t posn = 0;
|
||||
@ -308,6 +323,7 @@ int main(int argc, char** argv)
|
||||
}
|
||||
else if (sKey == L"--change-sdk")
|
||||
{
|
||||
sValue = CorrectValue(sValue);
|
||||
if (L"1" == sValue || L"true" == sValue)
|
||||
{
|
||||
bIsNeedCorrectSdkAll = true;
|
||||
@ -315,6 +331,7 @@ int main(int argc, char** argv)
|
||||
}
|
||||
else if (sKey == L"--allfonts")
|
||||
{
|
||||
sValue = CorrectValue(sValue);
|
||||
sAllFonts = sValue;
|
||||
}
|
||||
else if (sKey == L"--params")
|
||||
|
||||
@ -50,11 +50,13 @@
|
||||
#define FILE_SEPARATOR
|
||||
#define FILE_SEPARATOR_CHAR '\\'
|
||||
#define FILE_SEPARATOR_STR L"\\"
|
||||
#else
|
||||
#define FILE_SEPARATOR_STRA "\\"
|
||||
#else
|
||||
#define FILE_SEPARATOR
|
||||
#define FILE_SEPARATOR_CHAR '/'
|
||||
#define FILE_SEPARATOR_STR L"/"
|
||||
#endif
|
||||
#define FILE_SEPARATOR_STRA "/"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "../../Common/kernel_config.h"
|
||||
|
||||
@ -648,6 +648,8 @@ namespace NSDoctRenderer
|
||||
}
|
||||
void CDocBuilder::SetTmpFolder(const wchar_t* folder)
|
||||
{
|
||||
if (m_pInternal->m_bIsServerSafeVersion)
|
||||
return;
|
||||
m_pInternal->m_sTmpFolder = std::wstring(folder);
|
||||
}
|
||||
void CDocBuilder::CloseFile()
|
||||
@ -907,7 +909,10 @@ namespace NSDoctRenderer
|
||||
else if (sParam == "--cache-scripts")
|
||||
m_pInternal->m_bIsCacheScript = (std::wstring(value) == L"true");
|
||||
else if (sParam == "--save-use-only-names")
|
||||
{
|
||||
m_pInternal->m_bIsServerSafeVersion = true;
|
||||
m_pInternal->m_sFolderForSaveOnlyUseNames = std::wstring(value);
|
||||
}
|
||||
else if (sParam == "--all-fonts-path")
|
||||
{
|
||||
m_pInternal->m_strAllFonts = std::wstring(value);
|
||||
|
||||
@ -186,6 +186,7 @@ namespace NSDoctRenderer
|
||||
|
||||
bool m_bIsCacheScript;
|
||||
|
||||
bool m_bIsServerSafeVersion;
|
||||
std::wstring m_sFolderForSaveOnlyUseNames;
|
||||
|
||||
std::string m_sGlobalVariable;
|
||||
@ -214,6 +215,7 @@ namespace NSDoctRenderer
|
||||
m_bIsGlobalVariableUse = false;
|
||||
|
||||
m_bIsNotUseConfigAllFontsDir = false;
|
||||
m_bIsServerSafeVersion = false;
|
||||
}
|
||||
|
||||
void Init()
|
||||
@ -551,6 +553,10 @@ namespace NSDoctRenderer
|
||||
}
|
||||
#endif
|
||||
|
||||
// не открываем локальные файлы в серверной версии.
|
||||
if (m_bIsServerSafeVersion)
|
||||
return;
|
||||
|
||||
NSFile::CFileBinary::Copy(from, to);
|
||||
}
|
||||
|
||||
|
||||
@ -25,10 +25,6 @@ ADD_DEPENDENCY(graphics, kernel, UnicodeConverter)
|
||||
} else {
|
||||
DEFINES += V8_OS_XP
|
||||
DESTDIR=$$DESTDIR/xp
|
||||
OBJECTS_DIR = $$OBJECTS_DIR/xp
|
||||
MOC_DIR = $$MOC_DIR/xp
|
||||
RCC_DIR = $$RCC_DIR/xp
|
||||
UI_DIR = $$UI_DIR/xp
|
||||
include(../../Common/3dParty/v8/v8_xp/v8.pri)
|
||||
}
|
||||
|
||||
|
||||
@ -119,6 +119,8 @@ NSFonts::IApplicationFonts* CApplicationFontsWorker::Check()
|
||||
NSDirectory::GetFiles2(*i, strFontsW_Cur, true);
|
||||
}
|
||||
|
||||
std::sort(strFontsW_Cur.begin(), strFontsW_Cur.end());
|
||||
|
||||
bool bIsEqual = true;
|
||||
if (strFonts.size() != strFontsW_Cur.size())
|
||||
bIsEqual = false;
|
||||
|
||||
@ -104,7 +104,19 @@ NSFonts::IFontStream* CApplicationFontStreams::GetStream(const std::wstring &str
|
||||
}
|
||||
void CApplicationFontStreams::CheckStreams(std::map<std::wstring,bool> &mapFiles)
|
||||
{
|
||||
// TODO:
|
||||
std::map<std::wstring, CFontStream*>::iterator iter = m_mapStreams.begin();
|
||||
while (iter != m_mapStreams.end())
|
||||
{
|
||||
CFontStream* pFile = iter->second;
|
||||
|
||||
if (mapFiles.find(iter->first) != mapFiles.end())
|
||||
{
|
||||
iter = m_mapStreams.erase(iter);
|
||||
RELEASEINTERFACE(pFile);
|
||||
}
|
||||
else
|
||||
iter++;
|
||||
}
|
||||
}
|
||||
|
||||
void CApplicationFontStreams::Clear()
|
||||
|
||||
@ -55,11 +55,30 @@ class CHtmlFile_Private
|
||||
{
|
||||
public:
|
||||
bool m_bIsEpub;
|
||||
std::wstring m_sHtmlFileInternal;
|
||||
|
||||
public:
|
||||
CHtmlFile_Private()
|
||||
{
|
||||
m_bIsEpub = false;
|
||||
m_sHtmlFileInternal = L"";
|
||||
|
||||
std::wstring sProcessPath = NSFile::GetProcessDirectory();
|
||||
std::wstring sPathConfig = sProcessPath + L"/DoctRenderer.config";
|
||||
if (NSFile::CFileBinary::Exists(sPathConfig))
|
||||
{
|
||||
XmlUtils::CXmlNode oNode;
|
||||
if (oNode.FromXmlFile(sPathConfig))
|
||||
{
|
||||
std::wstring sPath = oNode.ReadValueString(L"htmlfileinternal");
|
||||
if (!sPath.empty())
|
||||
{
|
||||
if (0 == sPath.find(L"./"))
|
||||
sPath = sProcessPath + sPath.substr(1);
|
||||
m_sHtmlFileInternal = sPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@ -224,9 +243,9 @@ static void GetScriptsPath(NSStringUtils::CStringBuilder& oBuilder)
|
||||
}
|
||||
}
|
||||
|
||||
int CHtmlFile::Convert(const std::vector<std::wstring>& arFiles, const std::wstring& sDstfolder, const std::wstring& sPathInternal)
|
||||
int CHtmlFile::Convert(const std::vector<std::wstring>& arFiles, const std::wstring& sDstfolder)
|
||||
{
|
||||
std::wstring sInternal = sPathInternal;
|
||||
std::wstring sInternal = m_internal->m_sHtmlFileInternal;
|
||||
if (sInternal.empty())
|
||||
sInternal = NSFile::GetProcessDirectory() + L"/HtmlFileInternal/";
|
||||
|
||||
@ -635,7 +654,7 @@ static std::vector<std::wstring> ParseEpub(const std::wstring& sPackagePath, std
|
||||
return arHtmls;
|
||||
}
|
||||
|
||||
int CHtmlFile::ConvertEpub(const std::wstring& sFolder, std::wstring& sMetaInfo, const std::wstring& sDstfolder, const std::wstring& sPathInternal)
|
||||
int CHtmlFile::ConvertEpub(const std::wstring& sFolder, std::wstring& sMetaInfo, const std::wstring& sDstfolder)
|
||||
{
|
||||
std::wstring sFolderWithSlash = sFolder;
|
||||
NSStringExt::Replace(sFolderWithSlash, L"\\", L"/");
|
||||
@ -691,7 +710,7 @@ int CHtmlFile::ConvertEpub(const std::wstring& sFolder, std::wstring& sMetaInfo,
|
||||
return 1;
|
||||
|
||||
m_internal->m_bIsEpub = true;
|
||||
int nErr = this->Convert(arHtmls, sDstfolder, sPathInternal);
|
||||
int nErr = this->Convert(arHtmls, sDstfolder);
|
||||
m_internal->m_bIsEpub = false;
|
||||
return nErr;
|
||||
}
|
||||
@ -1399,7 +1418,7 @@ namespace NSMht
|
||||
};
|
||||
}
|
||||
|
||||
int CHtmlFile::ConvertMht(const std::wstring& sFile, const std::wstring& sDstfolder, const std::wstring& sPathInternal)
|
||||
int CHtmlFile::ConvertMht(const std::wstring& sFile, const std::wstring& sDstfolder)
|
||||
{
|
||||
NSMht::CMhtFile oFile;
|
||||
oFile.Parse(sFile);
|
||||
@ -1408,5 +1427,5 @@ int CHtmlFile::ConvertMht(const std::wstring& sFile, const std::wstring& sDstfol
|
||||
|
||||
std::vector<std::wstring> arFiles;
|
||||
arFiles.push_back(sFileMht);
|
||||
return this->Convert(arFiles, sDstfolder, sPathInternal);
|
||||
return this->Convert(arFiles, sDstfolder);
|
||||
}
|
||||
|
||||
@ -56,9 +56,9 @@ public:
|
||||
/// \param sPathInternal - path (subprocesspath = path + HtmlFileInternal.exe) ("" -> GetProcessDirectory()/HtmlFileInternal/HtmlFileInternal.exe)
|
||||
/// \return 1 error, 0 - success
|
||||
|
||||
int Convert(const std::vector<std::wstring>& arFiles, const std::wstring& sDstfolder, const std::wstring& sPathInternal = L"");
|
||||
int ConvertEpub(const std::wstring& sFolder, std::wstring& sMetaInfo, const std::wstring& sDstfolder, const std::wstring& sPathInternal = L"");
|
||||
int ConvertMht(const std::wstring& sFile, const std::wstring& sDstfolder, const std::wstring& sPathInternal = L"");
|
||||
int Convert(const std::vector<std::wstring>& arFiles, const std::wstring& sDstfolder);
|
||||
int ConvertEpub(const std::wstring& sFolder, std::wstring& sMetaInfo, const std::wstring& sDstfolder);
|
||||
int ConvertMht(const std::wstring& sFile, const std::wstring& sDstfolder);
|
||||
};
|
||||
|
||||
#endif // _HTMLFILE_HTMLFILE_H_
|
||||
|
||||
@ -207,6 +207,75 @@ namespace ZLibZipUtils
|
||||
|
||||
/*========================================================================================================*/
|
||||
|
||||
static std::string normalize_path(const std::string &path)
|
||||
{
|
||||
const char* pData = path.c_str();
|
||||
int nLen = (int) path.length();
|
||||
|
||||
char* pDataNorm = new char[nLen + 1];
|
||||
int* pSlashPoints = new int[nLen + 1];
|
||||
|
||||
int nStart = 0;
|
||||
int nCurrent = 0;
|
||||
int nCurrentSlash = -1;
|
||||
int nCurrentW = 0;
|
||||
bool bIsUp = false;
|
||||
|
||||
#if !defined(_WIN32) && !defined (_WIN64)
|
||||
if (pData[nCurrent] == FILE_SEPARATOR_CHAR)
|
||||
pDataNorm[nCurrentW++] = pData[nCurrent];
|
||||
#endif
|
||||
while (nCurrent < nLen)
|
||||
{
|
||||
if (pData[nCurrent] == FILE_SEPARATOR_CHAR)
|
||||
{
|
||||
if (nStart < nCurrent)
|
||||
{
|
||||
bIsUp = false;
|
||||
if ((nCurrent - nStart) == 2)
|
||||
{
|
||||
if (pData[nStart] == (char)'.' && pData[nStart + 1] == (char)'.')
|
||||
{
|
||||
if (nCurrentSlash > 0)
|
||||
{
|
||||
--nCurrentSlash;
|
||||
nCurrentW = pSlashPoints[nCurrentSlash];
|
||||
bIsUp = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!bIsUp)
|
||||
{
|
||||
pDataNorm[nCurrentW++] = (char) FILE_SEPARATOR_CHAR;
|
||||
++nCurrentSlash;
|
||||
pSlashPoints[nCurrentSlash] = nCurrentW;
|
||||
}
|
||||
}
|
||||
nStart = nCurrent + 1;
|
||||
++nCurrent;
|
||||
continue;
|
||||
}
|
||||
pDataNorm[nCurrentW++] = pData[nCurrent];
|
||||
++nCurrent;
|
||||
}
|
||||
|
||||
pDataNorm[nCurrentW] = (char)'\0';
|
||||
|
||||
std::string result = std::string(pDataNorm, nCurrentW);
|
||||
|
||||
delete []pDataNorm;
|
||||
|
||||
return result;
|
||||
}
|
||||
static void replace_all(std::string& subject, const std::string& search, const std::string& replace)
|
||||
{
|
||||
size_t pos = 0;
|
||||
while ((pos = subject.find(search, pos)) != std::string::npos)
|
||||
{
|
||||
subject.replace(pos, search.length(), replace);
|
||||
pos += replace.length();
|
||||
}
|
||||
}
|
||||
static int do_extract_currentfile( unzFile uf, const int* popt_extract_without_path, int* popt_overwrite, const char* password )
|
||||
{
|
||||
char filename_inzipA[256];
|
||||
@ -289,12 +358,39 @@ namespace ZLibZipUtils
|
||||
if ((fout==NULL) && ((*popt_extract_without_path)==0) &&
|
||||
(filename_withoutpath!=(wchar_t*)filename_inzip))
|
||||
{
|
||||
char* current_directory = getcwd(NULL, 0);
|
||||
if (current_directory)
|
||||
{
|
||||
std::string current_path(current_directory);
|
||||
free(current_directory);
|
||||
|
||||
current_path += FILE_SEPARATOR_STRA;
|
||||
|
||||
replace_all(current_path, "/", FILE_SEPARATOR_STRA);
|
||||
replace_all(current_path, "\\", FILE_SEPARATOR_STRA);
|
||||
|
||||
std::string filename_inzip(filename_inzipA);
|
||||
|
||||
replace_all(filename_inzip, "/", FILE_SEPARATOR_STRA);
|
||||
replace_all(filename_inzip, "\\", FILE_SEPARATOR_STRA);
|
||||
|
||||
std::string norm_path = normalize_path(current_path + filename_inzip);
|
||||
std::string norm_current_path = normalize_path(current_path);
|
||||
|
||||
if (std::string::npos == norm_path.find(norm_current_path))
|
||||
{
|
||||
return UNZ_INTERNALERROR;
|
||||
}
|
||||
}
|
||||
char c=*(filename_withoutpath-1);
|
||||
*(filename_withoutpath-1)='\0';
|
||||
makedir(write_filename);
|
||||
*(filename_withoutpath-1)=c;
|
||||
|
||||
if(oFile.CreateFileW(write_filename))
|
||||
{
|
||||
fout = oFile.GetFileNative();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -352,7 +448,10 @@ namespace ZLibZipUtils
|
||||
if (do_extract_currentfile(uf,&opt_extract_without_path,
|
||||
&opt_overwrite,
|
||||
password) != UNZ_OK)
|
||||
break;
|
||||
{
|
||||
err = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
if ( progress != NULL )
|
||||
{
|
||||
@ -385,7 +484,7 @@ namespace ZLibZipUtils
|
||||
(*progress)( UTILS_ONPROGRESSEVENT_ID, progressValue, &cancel );
|
||||
}
|
||||
|
||||
return 0;
|
||||
return err;
|
||||
}
|
||||
|
||||
/*========================================================================================================*/
|
||||
@ -541,23 +640,46 @@ int ZipDir( const WCHAR* dir, const WCHAR* outputFile, const OnProgressCallback*
|
||||
std::vector<std::wstring> aCurFiles = NSDirectory::GetFiles(szText);
|
||||
std::vector<std::wstring> aCurDirectories = NSDirectory::GetDirectories(szText);
|
||||
|
||||
if (sorted)
|
||||
{
|
||||
std::sort(aCurFiles.begin(), aCurFiles.end());
|
||||
std::sort(aCurDirectories.begin(), aCurDirectories.end());
|
||||
}
|
||||
for(size_t i = 0; i < aCurDirectories.size(); ++i)
|
||||
for(size_t i = 0; i < aCurDirectories.size(); ++i)
|
||||
{
|
||||
std::wstring sDirName = NSSystemPath::GetFileName(aCurDirectories[i]);
|
||||
StringDeque.push_back( aCurDirectories[i] );
|
||||
zipDeque.push_back( zipDir + sDirName );
|
||||
|
||||
if (sorted)
|
||||
{
|
||||
if (sDirName == L"ppt")
|
||||
{
|
||||
StringDeque.push_front(aCurDirectories[i] );
|
||||
zipDeque.push_front( zipDir + sDirName );
|
||||
}
|
||||
else if(sDirName == L"xl")
|
||||
{
|
||||
StringDeque.push_front( aCurDirectories[i] );
|
||||
zipDeque.push_front( zipDir + sDirName );
|
||||
}
|
||||
else if (sDirName == L"word")
|
||||
{
|
||||
StringDeque.push_front( aCurDirectories[i] );
|
||||
zipDeque.push_front( zipDir + sDirName );
|
||||
}
|
||||
else
|
||||
{
|
||||
StringDeque.push_back( aCurDirectories[i] );
|
||||
zipDeque.push_back( zipDir + sDirName );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
StringDeque.push_back( aCurDirectories[i] );
|
||||
zipDeque.push_back( zipDir + sDirName );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (size_t i = 0; i < aCurFiles.size(); ++i)
|
||||
{
|
||||
std::wstring cFileName = NSSystemPath::GetFileName(aCurFiles[i]);
|
||||
|
||||
if (std::wstring::npos != cFileName.find(L"mimetype")) // возможно и полное соответствие
|
||||
if (std::wstring::npos != cFileName.find(L"mimetype") ||
|
||||
std::wstring::npos != cFileName.find(L"[Content_Types]")) // возможно и полное соответствие
|
||||
{
|
||||
file = NSSystemPath::Combine(szText, cFileName);
|
||||
zipFileName = zipDir + cFileName;
|
||||
@ -745,9 +867,9 @@ int ZipDir( const WCHAR* dir, const WCHAR* outputFile, const OnProgressCallback*
|
||||
if ( buffer != NULL )
|
||||
{
|
||||
#if defined(_WIN32) || defined (_WIN64)
|
||||
err = _wchdir( buffer );
|
||||
int err1 = _wchdir( buffer );
|
||||
#else
|
||||
err = chdir( buffer );
|
||||
int err1 = chdir( buffer );
|
||||
#endif
|
||||
|
||||
free( buffer );
|
||||
|
||||
@ -432,7 +432,7 @@ class X2t private constructor() {
|
||||
|
||||
if (File(mInputParams.to).exists()) {
|
||||
if (mIsOverwrite) {
|
||||
FileUtils.deletePath(result.root!!)
|
||||
FileUtils.deletePath(result.to!!)
|
||||
} else {
|
||||
result.code = CONVERTER_CODE_EXIST
|
||||
return@let
|
||||
@ -555,6 +555,7 @@ class X2t private constructor() {
|
||||
this.to = cache1.to
|
||||
this.temp = cache1.temp
|
||||
this.theme = inputParams.theme
|
||||
this.password = inputParams.password
|
||||
}
|
||||
|
||||
var code = first.invoke(inputTemp)
|
||||
@ -565,6 +566,7 @@ class X2t private constructor() {
|
||||
this.to = inputParams.to
|
||||
this.temp = cache2.temp
|
||||
this.theme = "${cache2.root}/theme"
|
||||
this.password = inputParams.password
|
||||
}
|
||||
|
||||
if (!FileUtils.createPath(inputResult.theme!!)) {
|
||||
|
||||
@ -147,9 +147,7 @@ namespace NExtractTools
|
||||
if (OfficeFileFormatChecker.nFileType == AVS_OFFICESTUDIO_FILE_OTHER_MS_OFFCRYPTO)
|
||||
return mscrypt2oot_bin(sFrom, sTo, sTemp, params);
|
||||
else
|
||||
{
|
||||
//вместо docx другой формат!!
|
||||
}
|
||||
return AVS_FILEUTILS_ERROR_CONVERT;
|
||||
}
|
||||
else return AVS_FILEUTILS_ERROR_CONVERT;
|
||||
}
|
||||
@ -228,7 +226,7 @@ namespace NExtractTools
|
||||
}
|
||||
else
|
||||
{
|
||||
nRes = dir2zip(sResultDocxDir, sTo);
|
||||
nRes = dir2zip(sResultDocxDir, sTo, true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -559,7 +557,7 @@ namespace NExtractTools
|
||||
}
|
||||
else
|
||||
{
|
||||
//вместо xlsx другой формат!!
|
||||
return AVS_FILEUTILS_ERROR_CONVERT;
|
||||
}
|
||||
}
|
||||
else return AVS_FILEUTILS_ERROR_CONVERT;
|
||||
@ -648,7 +646,7 @@ namespace NExtractTools
|
||||
}
|
||||
else
|
||||
{
|
||||
nRes = dir2zip(sResultXlsxDir, sTo);
|
||||
nRes = dir2zip(sResultXlsxDir, sTo, true);
|
||||
}
|
||||
}
|
||||
return nRes;
|
||||
@ -938,7 +936,8 @@ namespace NExtractTools
|
||||
{
|
||||
if (OfficeFileFormatChecker.nFileType == AVS_OFFICESTUDIO_FILE_OTHER_MS_OFFCRYPTO)
|
||||
return mscrypt2oot_bin(sFrom, sTo, sTemp, params);
|
||||
//вместо pptx другой формат!!
|
||||
else
|
||||
return AVS_FILEUTILS_ERROR_CONVERT;
|
||||
}
|
||||
else return AVS_FILEUTILS_ERROR_CONVERT;
|
||||
}
|
||||
@ -1021,7 +1020,7 @@ namespace NExtractTools
|
||||
}
|
||||
else
|
||||
{
|
||||
nRes = dir2zip(sResultPptxDir, sTo);
|
||||
nRes = dir2zip(sResultPptxDir, sTo, true);
|
||||
}
|
||||
}
|
||||
return nRes;
|
||||
@ -1071,10 +1070,10 @@ namespace NExtractTools
|
||||
return pptt_bin2pptx(sTempPpttFileEditor, sTo, sTemp, bFromChanges, sThemeDir, params);
|
||||
}
|
||||
// zip dir
|
||||
_UINT32 dir2zip (const std::wstring &sFrom, const std::wstring &sTo)
|
||||
_UINT32 dir2zip (const std::wstring &sFrom, const std::wstring &sTo, bool bSorted, int method, short level)
|
||||
{
|
||||
COfficeUtils oCOfficeUtils(NULL);
|
||||
return (S_OK == oCOfficeUtils.CompressFileOrDirectory(sFrom, sTo)) ? 0 : AVS_FILEUTILS_ERROR_CONVERT;
|
||||
return (S_OK == oCOfficeUtils.CompressFileOrDirectory(sFrom, sTo, bSorted, method, level)) ? 0 : AVS_FILEUTILS_ERROR_CONVERT;
|
||||
}
|
||||
|
||||
// unzip dir
|
||||
@ -2759,8 +2758,7 @@ namespace NExtractTools
|
||||
arFiles.push_back(sFrom);
|
||||
|
||||
CHtmlFile oHtmlFile;
|
||||
std::wstring sPathInternal = NULL != params.m_sHtmlFileInternalPath ? *params.m_sHtmlFileInternalPath : L"";
|
||||
return 0 == oHtmlFile.Convert(arFiles, sTo, sPathInternal) ? 0 : AVS_FILEUTILS_ERROR_CONVERT;
|
||||
return 0 == oHtmlFile.Convert(arFiles, sTo) ? 0 : AVS_FILEUTILS_ERROR_CONVERT;
|
||||
}
|
||||
//html in container
|
||||
_UINT32 html_zip2doct_dir (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params)
|
||||
@ -2795,15 +2793,13 @@ namespace NExtractTools
|
||||
{
|
||||
}
|
||||
CHtmlFile oHtmlFile;
|
||||
std::wstring sPathInternal = NULL != params.m_sHtmlFileInternalPath ? *params.m_sHtmlFileInternalPath : L"";
|
||||
return 0 == oHtmlFile.Convert(arFiles, sTo, sPathInternal) ? 0 : AVS_FILEUTILS_ERROR_CONVERT;
|
||||
return 0 == oHtmlFile.Convert(arFiles, sTo) ? 0 : AVS_FILEUTILS_ERROR_CONVERT;
|
||||
}
|
||||
//mht
|
||||
_UINT32 mht2doct_dir (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params)
|
||||
{
|
||||
CHtmlFile oHtmlFile;
|
||||
std::wstring sPathInternal = NULL != params.m_sHtmlFileInternalPath ? *params.m_sHtmlFileInternalPath : L"";
|
||||
return 0 == oHtmlFile.ConvertMht(sFrom, sTo, sPathInternal) ? 0 : AVS_FILEUTILS_ERROR_CONVERT;
|
||||
return 0 == oHtmlFile.ConvertMht(sFrom, sTo) ? 0 : AVS_FILEUTILS_ERROR_CONVERT;
|
||||
}
|
||||
_UINT32 epub2doct_dir (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params)
|
||||
{
|
||||
@ -2814,8 +2810,7 @@ namespace NExtractTools
|
||||
{
|
||||
CHtmlFile oHtmlFile;
|
||||
std::wstring sMetaInfo;
|
||||
std::wstring sPathInternal = NULL != params.m_sHtmlFileInternalPath ? *params.m_sHtmlFileInternalPath : L"";
|
||||
nRes = 0 == oHtmlFile.ConvertEpub(sEpubDir, sMetaInfo, sTo, sPathInternal) ? 0 : AVS_FILEUTILS_ERROR_CONVERT;
|
||||
nRes = 0 == oHtmlFile.ConvertEpub(sEpubDir, sMetaInfo, sTo) ? 0 : AVS_FILEUTILS_ERROR_CONVERT;
|
||||
}
|
||||
return nRes;
|
||||
}
|
||||
@ -3174,7 +3169,7 @@ namespace NExtractTools
|
||||
}
|
||||
else
|
||||
{
|
||||
nRes = dir2zip(sFrom, sTo);
|
||||
nRes = dir2zip(sFrom, sTo, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3406,7 +3401,7 @@ namespace NExtractTools
|
||||
}
|
||||
else
|
||||
{
|
||||
nRes = dir2zip(sFrom, sTo);
|
||||
nRes = dir2zip(sFrom, sTo, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3653,7 +3648,7 @@ namespace NExtractTools
|
||||
}
|
||||
else
|
||||
{
|
||||
nRes = dir2zip(sFrom, sTo);
|
||||
nRes = dir2zip(sFrom, sTo, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -178,7 +178,7 @@ namespace NExtractTools
|
||||
_UINT32 html2docx (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params);
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
_UINT32 dir2zip (const std::wstring &sFrom, const std::wstring &sTo);
|
||||
_UINT32 dir2zip (const std::wstring &sFrom, const std::wstring &sTo, bool bSorted = false, int method = 8/*Z_DEFLATED*/, short level = -1);
|
||||
_UINT32 zip2dir (const std::wstring &sFrom, const std::wstring &sTo);
|
||||
|
||||
_UINT32 convertmailmerge (const InputParamsMailMerge& oMailMergeSend,const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, bool bPaid, const std::wstring &sThemeDir, InputParams& params);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -409,7 +409,6 @@ namespace NExtractTools
|
||||
InputParamsMailMerge* m_oMailMergeSend;
|
||||
InputParamsThumbnail* m_oThumbnail;
|
||||
std::wstring* m_sJsonParams;
|
||||
std::wstring* m_sHtmlFileInternalPath;
|
||||
std::wstring* m_sPassword;
|
||||
std::wstring* m_sSavePassword;
|
||||
std::wstring* m_sDocumentID;
|
||||
@ -440,7 +439,6 @@ namespace NExtractTools
|
||||
m_oMailMergeSend = NULL;
|
||||
m_oThumbnail = NULL;
|
||||
m_sJsonParams = NULL;
|
||||
m_sHtmlFileInternalPath = NULL;
|
||||
m_sPassword = NULL;
|
||||
m_sSavePassword = NULL;
|
||||
m_sDocumentID = NULL;
|
||||
@ -470,7 +468,6 @@ namespace NExtractTools
|
||||
RELEASEOBJECT(m_oMailMergeSend);
|
||||
RELEASEOBJECT(m_oThumbnail);
|
||||
RELEASEOBJECT(m_sJsonParams);
|
||||
RELEASEOBJECT(m_sHtmlFileInternalPath);
|
||||
RELEASEOBJECT(m_sPassword);
|
||||
RELEASEOBJECT(m_sSavePassword);
|
||||
RELEASEOBJECT(m_sDocumentID);
|
||||
@ -615,11 +612,6 @@ namespace NExtractTools
|
||||
RELEASEOBJECT(m_sJsonParams);
|
||||
m_sJsonParams = new std::wstring(sValue);
|
||||
}
|
||||
else if(_T("m_sHtmlFileInternalPath") == sName)
|
||||
{
|
||||
RELEASEOBJECT(m_sHtmlFileInternalPath);
|
||||
m_sHtmlFileInternalPath = new std::wstring(sValue);
|
||||
}
|
||||
else if(_T("m_sPassword") == sName)
|
||||
{
|
||||
RELEASEOBJECT(m_sPassword);
|
||||
|
||||
@ -1,478 +1,484 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2019
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
#include "CSVReader.h"
|
||||
|
||||
#include <map>
|
||||
#include <locale>
|
||||
|
||||
#include "../../DesktopEditor/common/File.h"
|
||||
#include "../../Common/DocxFormat/Source/Base/unicode_util.h"
|
||||
#include "../../Common/OfficeFileErrorDescription.h"
|
||||
#include "../../UnicodeConverter/UnicodeConverter.h"
|
||||
#include "../../UnicodeConverter/UnicodeConverter_Encodings.h"
|
||||
#include "../../Common/DocxFormat/Source/XlsxFormat/Workbook/Workbook.h"
|
||||
#include "../../Common/DocxFormat/Source/XlsxFormat/SharedStrings/SharedStrings.h"
|
||||
#include "../../Common/DocxFormat/Source/XlsxFormat/Styles/Styles.h"
|
||||
|
||||
namespace CSVReader
|
||||
{
|
||||
const std::wstring ansi_2_unicode(const unsigned char* data, DWORD data_size)
|
||||
{
|
||||
std::wstring result;
|
||||
|
||||
std::locale loc("");
|
||||
std::ctype<wchar_t> const &facet = std::use_facet<std::ctype<wchar_t> >(loc);
|
||||
|
||||
result.resize(data_size);
|
||||
|
||||
facet.widen((char*)data, (char*)data + data_size, &result[0]);
|
||||
return result;
|
||||
}
|
||||
const std::wstring utf8_2_unicode(const unsigned char* data, DWORD data_size)
|
||||
{
|
||||
if (sizeof(wchar_t) == 2)//utf8 -> utf16
|
||||
{
|
||||
unsigned int nLength = data_size;
|
||||
|
||||
UTF16 *pStrUtf16 = new UTF16 [nLength + 1];
|
||||
memset ((void *) pStrUtf16, 0, sizeof (UTF16) * (nLength + 1));
|
||||
|
||||
UTF8 *pStrUtf8 = (UTF8 *) data;
|
||||
|
||||
const UTF8 *pStrUtf8_Conv = pStrUtf8;
|
||||
UTF16 *pStrUtf16_Conv = pStrUtf16;
|
||||
|
||||
ConversionResult eUnicodeConversionResult = ConvertUTF8toUTF16 (&pStrUtf8_Conv, &pStrUtf8[nLength]
|
||||
, &pStrUtf16_Conv, &pStrUtf16 [nLength]
|
||||
, strictConversion);
|
||||
|
||||
if (conversionOK != eUnicodeConversionResult)
|
||||
{
|
||||
delete [] pStrUtf16;
|
||||
return std::wstring();
|
||||
}
|
||||
std::wstring utf16Str ((wchar_t *) pStrUtf16);
|
||||
|
||||
delete [] pStrUtf16;
|
||||
return utf16Str;
|
||||
}
|
||||
else //utf8 -> utf32
|
||||
{
|
||||
unsigned int nLength = data_size;
|
||||
|
||||
UTF32 *pStrUtf32 = new UTF32 [nLength + 1];
|
||||
memset ((void *) pStrUtf32, 0, sizeof (UTF32) * (nLength + 1));
|
||||
|
||||
UTF8 *pStrUtf8 = (UTF8 *) data;
|
||||
|
||||
const UTF8 *pStrUtf8_Conv = pStrUtf8;
|
||||
UTF32 *pStrUtf32_Conv = pStrUtf32;
|
||||
|
||||
ConversionResult eUnicodeConversionResult = ConvertUTF8toUTF32 (&pStrUtf8_Conv, &pStrUtf8[nLength]
|
||||
, &pStrUtf32_Conv, &pStrUtf32 [nLength]
|
||||
, strictConversion);
|
||||
|
||||
if (conversionOK != eUnicodeConversionResult)
|
||||
{
|
||||
delete [] pStrUtf32;
|
||||
return std::wstring();
|
||||
}
|
||||
std::wstring utf32Str ((wchar_t *) pStrUtf32);
|
||||
|
||||
delete [] pStrUtf32;
|
||||
return utf32Str;
|
||||
}
|
||||
}
|
||||
|
||||
const std::wstring utf16_2_unicode(const unsigned char* data, DWORD data_size)
|
||||
{
|
||||
if (sizeof(wchar_t) == 2)//utf16 -> utf16
|
||||
{
|
||||
return std::wstring((wchar_t*)data, data_size / 2);
|
||||
}
|
||||
else //utf16 -> utf32
|
||||
{
|
||||
unsigned int nLength = data_size / 2;
|
||||
|
||||
UTF32 *pStrUtf32 = new UTF32 [nLength + 1];
|
||||
memset ((void *) pStrUtf32, 0, sizeof (UTF32) * (nLength + 1));
|
||||
|
||||
UTF16 *pStrUtf16 = (UTF16 *) data;
|
||||
|
||||
const UTF16 *pStrUtf16_Conv = pStrUtf16;
|
||||
UTF32 *pStrUtf32_Conv = pStrUtf32;
|
||||
|
||||
ConversionResult eUnicodeConversionResult = ConvertUTF16toUTF32 (&pStrUtf16_Conv, &pStrUtf16[nLength]
|
||||
, &pStrUtf32_Conv, &pStrUtf32 [nLength]
|
||||
, strictConversion);
|
||||
|
||||
if (conversionOK != eUnicodeConversionResult)
|
||||
{
|
||||
delete [] pStrUtf32;
|
||||
return std::wstring();
|
||||
}
|
||||
std::wstring utf32Str ((wchar_t *) pStrUtf32);
|
||||
|
||||
delete [] pStrUtf32;
|
||||
return utf32Str;
|
||||
}
|
||||
}
|
||||
|
||||
const std::wstring utf32_2_unicode(const unsigned char* data, DWORD data_size)
|
||||
{
|
||||
if (sizeof(wchar_t) == 4)//utf32 -> utf32
|
||||
{
|
||||
return std::wstring((wchar_t*)data, data_size / 4);
|
||||
}
|
||||
else //utf32 -> utf16
|
||||
{
|
||||
unsigned int nLength = data_size / 4;
|
||||
|
||||
UTF16 *pStrUtf16 = new UTF16 [nLength + 1];
|
||||
memset ((void *) pStrUtf16, 0, sizeof (UTF16) * (nLength + 1));
|
||||
|
||||
UTF32 *pStrUtf32 = (UTF32 *) data;
|
||||
|
||||
const UTF32 *pStrUtf32_Conv = pStrUtf32;
|
||||
UTF16 *pStrUtf16_Conv = pStrUtf16;
|
||||
|
||||
ConversionResult eUnicodeConversionResult = ConvertUTF32toUTF16 (&pStrUtf32_Conv, &pStrUtf32[nLength]
|
||||
, &pStrUtf16_Conv, &pStrUtf16 [nLength]
|
||||
, strictConversion);
|
||||
|
||||
if (conversionOK != eUnicodeConversionResult)
|
||||
{
|
||||
delete [] pStrUtf16;
|
||||
return std::wstring();
|
||||
}
|
||||
std::wstring utf16Str ((wchar_t *) pStrUtf16);
|
||||
|
||||
delete [] pStrUtf16;
|
||||
return utf16Str;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
void AddCell(std::wstring &sText, INT nStartCell, std::stack<INT> &oDeleteChars, OOX::Spreadsheet::CRow &oRow, INT nRow, INT nCol, bool bIsWrap)
|
||||
{
|
||||
while(!oDeleteChars.empty())
|
||||
{
|
||||
INT nIndex = oDeleteChars.top() - nStartCell;
|
||||
sText.erase(nIndex, 1);
|
||||
oDeleteChars.pop();
|
||||
}
|
||||
// Пустую не пишем
|
||||
if (0 == sText.length())
|
||||
return;
|
||||
|
||||
OOX::Spreadsheet::CCell *pCell = new OOX::Spreadsheet::CCell();
|
||||
pCell->m_oType.Init();
|
||||
|
||||
WCHAR *pEndPtr;
|
||||
double dValue = wcstod(sText.c_str(), &pEndPtr);
|
||||
if (0 != *pEndPtr)
|
||||
{
|
||||
// Не число
|
||||
pCell->m_oType->SetValue(SimpleTypes::Spreadsheet::celltypeInlineStr);
|
||||
pCell->m_oRichText.Init();
|
||||
OOX::Spreadsheet::CText *pText = new OOX::Spreadsheet::CText();
|
||||
pText->m_sText = sText;
|
||||
pCell->m_oRichText->m_arrItems.push_back(pText);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Число
|
||||
pCell->m_oValue.Init();
|
||||
pCell->m_oValue->m_sText = sText;
|
||||
}
|
||||
|
||||
if (bIsWrap)
|
||||
{
|
||||
// WrapStyle
|
||||
pCell->m_oStyle.Init();
|
||||
pCell->m_oStyle->SetValue(1);
|
||||
}
|
||||
|
||||
pCell->setRowCol(nRow, nCol);
|
||||
oRow.m_arrItems.push_back(pCell);
|
||||
}
|
||||
_UINT32 ReadFromCsvToXlsx(const std::wstring &sFileName, OOX::Spreadsheet::CXlsx &oXlsx, UINT nCodePage, const std::wstring& sDelimiter)
|
||||
{
|
||||
NSFile::CFileBinary oFile;
|
||||
if (false == oFile.OpenFile(sFileName)) return AVS_FILEUTILS_ERROR_CONVERT;
|
||||
//-----------------------------------------------------------------------------------
|
||||
// Создадим Workbook
|
||||
oXlsx.CreateWorkbook();
|
||||
// Создадим стили
|
||||
oXlsx.CreateStyles();
|
||||
|
||||
// Добавим стили для wrap-а
|
||||
oXlsx.m_pStyles->m_oCellXfs.Init();
|
||||
oXlsx.m_pStyles->m_oCellXfs->m_oCount.Init();
|
||||
oXlsx.m_pStyles->m_oCellXfs->m_oCount->SetValue(2);
|
||||
|
||||
// Normall default
|
||||
OOX::Spreadsheet::CXfs* pXfs = NULL;
|
||||
pXfs = new OOX::Spreadsheet::CXfs();
|
||||
pXfs->m_oBorderId.Init();
|
||||
pXfs->m_oBorderId->SetValue(0);
|
||||
pXfs->m_oFillId.Init();
|
||||
pXfs->m_oFillId->SetValue(0);
|
||||
pXfs->m_oFontId.Init();
|
||||
pXfs->m_oFontId->SetValue(0);
|
||||
pXfs->m_oNumFmtId.Init();
|
||||
pXfs->m_oNumFmtId->SetValue(0);
|
||||
|
||||
oXlsx.m_pStyles->m_oCellXfs->m_arrItems.push_back(pXfs);
|
||||
|
||||
// Wrap style
|
||||
pXfs = new OOX::Spreadsheet::CXfs();
|
||||
pXfs->m_oBorderId.Init();
|
||||
pXfs->m_oBorderId->SetValue(0);
|
||||
pXfs->m_oFillId.Init();
|
||||
pXfs->m_oFillId->SetValue(0);
|
||||
pXfs->m_oFontId.Init();
|
||||
pXfs->m_oFontId->SetValue(0);
|
||||
pXfs->m_oNumFmtId.Init();
|
||||
pXfs->m_oNumFmtId->SetValue(0);
|
||||
|
||||
pXfs->m_oApplyAlignment.Init();
|
||||
pXfs->m_oApplyAlignment->SetValue(SimpleTypes::onoffTrue);
|
||||
pXfs->m_oAligment.Init();
|
||||
pXfs->m_oAligment->m_oWrapText.Init();
|
||||
pXfs->m_oAligment->m_oWrapText->SetValue(SimpleTypes::onoffTrue);
|
||||
|
||||
oXlsx.m_pStyles->m_oCellXfs->m_arrItems.push_back(pXfs);
|
||||
|
||||
std::wstring sSheetRId = L"rId1";
|
||||
OOX::Spreadsheet::CWorksheet* pWorksheet = new OOX::Spreadsheet::CWorksheet(NULL);
|
||||
pWorksheet->m_oSheetData.Init();
|
||||
|
||||
OOX::Spreadsheet::CSheet *pSheet = new OOX::Spreadsheet::CSheet();
|
||||
|
||||
pSheet->m_oName.Init();
|
||||
pSheet->m_oName->append(L"Sheet1");
|
||||
pSheet->m_oSheetId.Init();
|
||||
pSheet->m_oSheetId->SetValue(1);
|
||||
pSheet->m_oRid.Init();
|
||||
pSheet->m_oRid->SetValue(sSheetRId);
|
||||
|
||||
oXlsx.m_pWorkbook->m_oSheets.Init();
|
||||
oXlsx.m_pWorkbook->m_oSheets->m_arrItems.push_back(pSheet);
|
||||
|
||||
//-----------------------------------------------------------------------------------
|
||||
DWORD nFileSize = 0;
|
||||
BYTE* pFileData = new BYTE[oFile.GetFileSize()];
|
||||
|
||||
oFile.ReadFile(pFileData, oFile.GetFileSize(), nFileSize);
|
||||
oFile.CloseFile();
|
||||
//skip bom
|
||||
DWORD nInputBufferSize = nFileSize;
|
||||
BYTE* pInputBuffer = pFileData;
|
||||
if (nInputBufferSize >= 3 && 0xef == pInputBuffer[0] && 0xbb == pInputBuffer[1] && 0xbf == pInputBuffer[2])
|
||||
{
|
||||
nInputBufferSize -= 3;
|
||||
pInputBuffer += 3;
|
||||
}
|
||||
else if (nInputBufferSize >= 2 && ((0xfe == pInputBuffer[0] && 0xff == pInputBuffer[1]) || (0xff == pInputBuffer[0] && 0xfe == pInputBuffer[1])))
|
||||
{
|
||||
nInputBufferSize -= 2;
|
||||
pInputBuffer += 2;
|
||||
}
|
||||
|
||||
std::wstring sFileDataW;
|
||||
|
||||
if (nCodePage == 1000)
|
||||
{
|
||||
sFileDataW = ansi_2_unicode(pInputBuffer, nInputBufferSize);
|
||||
}
|
||||
else if (nCodePage == 46)//utf-8
|
||||
{
|
||||
sFileDataW = utf8_2_unicode(pInputBuffer, nInputBufferSize);
|
||||
}
|
||||
else if (nCodePage == 48)//utf-16
|
||||
{
|
||||
sFileDataW = utf16_2_unicode(pInputBuffer, nInputBufferSize);
|
||||
}
|
||||
else if (nCodePage == 50) // utf-32
|
||||
{
|
||||
sFileDataW = utf32_2_unicode(pInputBuffer, nInputBufferSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
const NSUnicodeConverter::EncodindId& oEncodindId = NSUnicodeConverter::Encodings[nCodePage];
|
||||
|
||||
NSUnicodeConverter::CUnicodeConverter oUnicodeConverter;
|
||||
sFileDataW = oUnicodeConverter.toUnicode((const char*)pInputBuffer, nInputBufferSize, oEncodindId.Name);
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
size_t nSize = sFileDataW.length();
|
||||
|
||||
if (nSize < 1 && nInputBufferSize > 0)
|
||||
{//для синхронности вывода превью и нормального результата
|
||||
const NSUnicodeConverter::EncodindId& oEncodindId = NSUnicodeConverter::Encodings[nCodePage];
|
||||
|
||||
NSUnicodeConverter::CUnicodeConverter oUnicodeConverter;
|
||||
sFileDataW = oUnicodeConverter.toUnicode((const char*)pInputBuffer, nInputBufferSize, oEncodindId.Name);
|
||||
|
||||
nSize = sFileDataW.length();
|
||||
//return AVS_FILEUTILS_ERROR_CONVERT_ICU;
|
||||
}
|
||||
const WCHAR *pTemp = sFileDataW.c_str();
|
||||
|
||||
WCHAR wcDelimiterLeading = L'\0';
|
||||
WCHAR wcDelimiterTrailing = L'\0';
|
||||
int nDelimiterSize = 0;
|
||||
|
||||
if (sDelimiter.length() > 0)
|
||||
{
|
||||
wcDelimiterLeading = sDelimiter[0];
|
||||
nDelimiterSize = 1;
|
||||
if (2 == sizeof(wchar_t) && 0xD800 <= wcDelimiterLeading && wcDelimiterLeading <= 0xDBFF && sDelimiter.length() > 1)
|
||||
{
|
||||
wcDelimiterTrailing = sDelimiter[1];
|
||||
nDelimiterSize = 2;
|
||||
}
|
||||
}
|
||||
|
||||
const WCHAR wcNewLineN = _T('\n');
|
||||
const WCHAR wcNewLineR = _T('\r');
|
||||
const WCHAR wcQuote = _T('"');
|
||||
const WCHAR wcTab = _T('\t');
|
||||
|
||||
bool bIsWrap = false;
|
||||
WCHAR wcCurrent;
|
||||
INT nStartCell = 0;
|
||||
std::stack<INT> oDeleteChars;
|
||||
|
||||
bool bInQuote = false;
|
||||
INT nIndexRow = 0;
|
||||
INT nIndexCol = 0;
|
||||
OOX::Spreadsheet::CRow *pRow = new OOX::Spreadsheet::CRow();
|
||||
pRow->m_oR.Init();
|
||||
pRow->m_oR->SetValue(nIndexRow + 1);
|
||||
|
||||
for (size_t nIndex = 0; nIndex < nSize; ++nIndex)
|
||||
{
|
||||
wcCurrent = pTemp[nIndex];
|
||||
if (wcDelimiterLeading == wcCurrent && (L'\0' == wcDelimiterTrailing || (nIndex + 1 < nSize && wcDelimiterTrailing == pTemp[nIndex + 1])))
|
||||
{
|
||||
if (bInQuote)
|
||||
continue;
|
||||
// New Cell
|
||||
std::wstring sCellText(pTemp + nStartCell, nIndex - nStartCell);
|
||||
AddCell(sCellText, nStartCell, oDeleteChars, *pRow, nIndexRow, nIndexCol++, bIsWrap);
|
||||
bIsWrap = false;
|
||||
|
||||
nStartCell = nIndex + nDelimiterSize;
|
||||
if (nStartCell == nSize)
|
||||
{
|
||||
pWorksheet->m_oSheetData->m_arrItems.push_back(pRow);
|
||||
pRow = NULL;
|
||||
}
|
||||
}
|
||||
else if (wcNewLineN == wcCurrent || wcNewLineR == wcCurrent)
|
||||
{
|
||||
if (bInQuote)
|
||||
{
|
||||
// Добавим Wrap
|
||||
bIsWrap = true;
|
||||
continue;
|
||||
}
|
||||
// New line
|
||||
if (nStartCell != nIndex)
|
||||
{
|
||||
std::wstring sCellText(pTemp + nStartCell, nIndex - nStartCell);
|
||||
AddCell(sCellText, nStartCell, oDeleteChars, *pRow, nIndexRow, nIndexCol++, bIsWrap);
|
||||
bIsWrap = false;
|
||||
}
|
||||
|
||||
if (wcNewLineR == wcCurrent && nIndex + 1 != nSize && wcNewLineN == pTemp[nIndex + 1])
|
||||
{
|
||||
// На комбинацию \r\n должен быть только 1 перенос
|
||||
++nIndex;
|
||||
}
|
||||
|
||||
nStartCell = nIndex + 1;
|
||||
|
||||
pWorksheet->m_oSheetData->m_arrItems.push_back(pRow);
|
||||
pRow = new OOX::Spreadsheet::CRow();
|
||||
pRow->m_oR.Init();
|
||||
pRow->m_oR->SetValue(++nIndexRow + 1);
|
||||
nIndexCol = 0;
|
||||
}
|
||||
else if (wcQuote == wcCurrent)
|
||||
{
|
||||
// Quote
|
||||
if (false == bInQuote && nStartCell == nIndex && nIndex + 1 != nSize)
|
||||
{
|
||||
// Начало новой ячейки (только если мы сразу после разделителя и не в конце файла)
|
||||
bInQuote = !bInQuote;
|
||||
nStartCell = nIndex + 1;
|
||||
}
|
||||
else if ( bInQuote )
|
||||
{
|
||||
// Нужно удалить кавычку ограничитель
|
||||
oDeleteChars.push(nIndex);
|
||||
|
||||
// Если следующий символ кавычка, то мы не закончили ограничитель строки (1997,Ford,E350,"Super, ""luxurious"" truck")
|
||||
if (nIndex + 1 != nSize && wcQuote == pTemp[nIndex + 1])
|
||||
++nIndex;
|
||||
else
|
||||
bInQuote = !bInQuote;
|
||||
}
|
||||
}
|
||||
else if (wcTab == wcCurrent)
|
||||
{
|
||||
// delete tab if not delimiter
|
||||
oDeleteChars.push(nIndex);
|
||||
}
|
||||
}
|
||||
|
||||
if (nStartCell != nSize)
|
||||
{
|
||||
// New line
|
||||
std::wstring sCellText(pTemp + nStartCell, nSize - nStartCell);
|
||||
AddCell(sCellText, nStartCell, oDeleteChars, *pRow, nIndexRow, nIndexCol++, bIsWrap);
|
||||
pWorksheet->m_oSheetData->m_arrItems.push_back(pRow);
|
||||
}
|
||||
else
|
||||
{
|
||||
RELEASEOBJECT(pRow);
|
||||
}
|
||||
oXlsx.m_arWorksheets.push_back(pWorksheet);
|
||||
oXlsx.m_mapWorksheets.insert(std::make_pair(sSheetRId, pWorksheet));
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2019
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
#include "CSVReader.h"
|
||||
|
||||
#include <map>
|
||||
#include <locale>
|
||||
|
||||
#include "../../DesktopEditor/common/File.h"
|
||||
#include "../../Common/DocxFormat/Source/Base/unicode_util.h"
|
||||
#include "../../Common/OfficeFileErrorDescription.h"
|
||||
#include "../../UnicodeConverter/UnicodeConverter.h"
|
||||
#include "../../UnicodeConverter/UnicodeConverter_Encodings.h"
|
||||
#include "../../Common/DocxFormat/Source/XlsxFormat/Workbook/Workbook.h"
|
||||
#include "../../Common/DocxFormat/Source/XlsxFormat/SharedStrings/SharedStrings.h"
|
||||
#include "../../Common/DocxFormat/Source/XlsxFormat/Styles/Styles.h"
|
||||
|
||||
namespace CSVReader
|
||||
{
|
||||
const std::wstring ansi_2_unicode(const unsigned char* data, DWORD data_size)
|
||||
{
|
||||
std::wstring result;
|
||||
|
||||
std::locale loc("");
|
||||
std::ctype<wchar_t> const &facet = std::use_facet<std::ctype<wchar_t> >(loc);
|
||||
|
||||
result.resize(data_size);
|
||||
|
||||
facet.widen((char*)data, (char*)data + data_size, &result[0]);
|
||||
return result;
|
||||
}
|
||||
const std::wstring utf8_2_unicode(const unsigned char* data, DWORD data_size)
|
||||
{
|
||||
if (sizeof(wchar_t) == 2)//utf8 -> utf16
|
||||
{
|
||||
unsigned int nLength = data_size;
|
||||
|
||||
UTF16 *pStrUtf16 = new UTF16 [nLength + 1];
|
||||
memset ((void *) pStrUtf16, 0, sizeof (UTF16) * (nLength + 1));
|
||||
|
||||
UTF8 *pStrUtf8 = (UTF8 *) data;
|
||||
|
||||
const UTF8 *pStrUtf8_Conv = pStrUtf8;
|
||||
UTF16 *pStrUtf16_Conv = pStrUtf16;
|
||||
|
||||
ConversionResult eUnicodeConversionResult = ConvertUTF8toUTF16 (&pStrUtf8_Conv, &pStrUtf8[nLength]
|
||||
, &pStrUtf16_Conv, &pStrUtf16 [nLength]
|
||||
, strictConversion);
|
||||
|
||||
if (conversionOK != eUnicodeConversionResult)
|
||||
{
|
||||
delete [] pStrUtf16;
|
||||
return std::wstring();
|
||||
}
|
||||
std::wstring utf16Str ((wchar_t *) pStrUtf16);
|
||||
|
||||
delete [] pStrUtf16;
|
||||
return utf16Str;
|
||||
}
|
||||
else //utf8 -> utf32
|
||||
{
|
||||
unsigned int nLength = data_size;
|
||||
|
||||
UTF32 *pStrUtf32 = new UTF32 [nLength + 1];
|
||||
memset ((void *) pStrUtf32, 0, sizeof (UTF32) * (nLength + 1));
|
||||
|
||||
UTF8 *pStrUtf8 = (UTF8 *) data;
|
||||
|
||||
const UTF8 *pStrUtf8_Conv = pStrUtf8;
|
||||
UTF32 *pStrUtf32_Conv = pStrUtf32;
|
||||
|
||||
ConversionResult eUnicodeConversionResult = ConvertUTF8toUTF32 (&pStrUtf8_Conv, &pStrUtf8[nLength]
|
||||
, &pStrUtf32_Conv, &pStrUtf32 [nLength]
|
||||
, strictConversion);
|
||||
|
||||
if (conversionOK != eUnicodeConversionResult)
|
||||
{
|
||||
delete [] pStrUtf32;
|
||||
return std::wstring();
|
||||
}
|
||||
std::wstring utf32Str ((wchar_t *) pStrUtf32);
|
||||
|
||||
delete [] pStrUtf32;
|
||||
return utf32Str;
|
||||
}
|
||||
}
|
||||
|
||||
const std::wstring utf16_2_unicode(const unsigned char* data, DWORD data_size)
|
||||
{
|
||||
if (sizeof(wchar_t) == 2)//utf16 -> utf16
|
||||
{
|
||||
return std::wstring((wchar_t*)data, data_size / 2);
|
||||
}
|
||||
else //utf16 -> utf32
|
||||
{
|
||||
unsigned int nLength = data_size / 2;
|
||||
|
||||
UTF32 *pStrUtf32 = new UTF32 [nLength + 1];
|
||||
memset ((void *) pStrUtf32, 0, sizeof (UTF32) * (nLength + 1));
|
||||
|
||||
UTF16 *pStrUtf16 = (UTF16 *) data;
|
||||
|
||||
const UTF16 *pStrUtf16_Conv = pStrUtf16;
|
||||
UTF32 *pStrUtf32_Conv = pStrUtf32;
|
||||
|
||||
ConversionResult eUnicodeConversionResult = ConvertUTF16toUTF32 (&pStrUtf16_Conv, &pStrUtf16[nLength]
|
||||
, &pStrUtf32_Conv, &pStrUtf32 [nLength]
|
||||
, strictConversion);
|
||||
|
||||
if (conversionOK != eUnicodeConversionResult)
|
||||
{
|
||||
delete [] pStrUtf32;
|
||||
return std::wstring();
|
||||
}
|
||||
std::wstring utf32Str ((wchar_t *) pStrUtf32);
|
||||
|
||||
delete [] pStrUtf32;
|
||||
return utf32Str;
|
||||
}
|
||||
}
|
||||
|
||||
const std::wstring utf32_2_unicode(const unsigned char* data, DWORD data_size)
|
||||
{
|
||||
if (sizeof(wchar_t) == 4)//utf32 -> utf32
|
||||
{
|
||||
return std::wstring((wchar_t*)data, data_size / 4);
|
||||
}
|
||||
else //utf32 -> utf16
|
||||
{
|
||||
unsigned int nLength = data_size / 4;
|
||||
|
||||
UTF16 *pStrUtf16 = new UTF16 [nLength + 1];
|
||||
memset ((void *) pStrUtf16, 0, sizeof (UTF16) * (nLength + 1));
|
||||
|
||||
UTF32 *pStrUtf32 = (UTF32 *) data;
|
||||
|
||||
const UTF32 *pStrUtf32_Conv = pStrUtf32;
|
||||
UTF16 *pStrUtf16_Conv = pStrUtf16;
|
||||
|
||||
ConversionResult eUnicodeConversionResult = ConvertUTF32toUTF16 (&pStrUtf32_Conv, &pStrUtf32[nLength]
|
||||
, &pStrUtf16_Conv, &pStrUtf16 [nLength]
|
||||
, strictConversion);
|
||||
|
||||
if (conversionOK != eUnicodeConversionResult)
|
||||
{
|
||||
delete [] pStrUtf16;
|
||||
return std::wstring();
|
||||
}
|
||||
std::wstring utf16Str ((wchar_t *) pStrUtf16);
|
||||
|
||||
delete [] pStrUtf16;
|
||||
return utf16Str;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
void AddCell(std::wstring &sText, INT nStartCell, std::stack<INT> &oDeleteChars, OOX::Spreadsheet::CRow &oRow, INT nRow, INT nCol, bool bIsWrap)
|
||||
{
|
||||
while(!oDeleteChars.empty())
|
||||
{
|
||||
INT nIndex = oDeleteChars.top() - nStartCell;
|
||||
sText.erase(nIndex, 1);
|
||||
oDeleteChars.pop();
|
||||
}
|
||||
// Пустую не пишем
|
||||
if (0 == sText.length())
|
||||
return;
|
||||
|
||||
OOX::Spreadsheet::CCell *pCell = new OOX::Spreadsheet::CCell();
|
||||
pCell->m_oType.Init();
|
||||
|
||||
WCHAR *pEndPtr;
|
||||
double dValue = wcstod(sText.c_str(), &pEndPtr);
|
||||
if (0 != *pEndPtr)
|
||||
{
|
||||
// Не число
|
||||
pCell->m_oType->SetValue(SimpleTypes::Spreadsheet::celltypeInlineStr);
|
||||
pCell->m_oRichText.Init();
|
||||
OOX::Spreadsheet::CText *pText = new OOX::Spreadsheet::CText();
|
||||
pText->m_sText = sText;
|
||||
pCell->m_oRichText->m_arrItems.push_back(pText);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Число
|
||||
pCell->m_oValue.Init();
|
||||
pCell->m_oValue->m_sText = sText;
|
||||
}
|
||||
|
||||
if (bIsWrap)
|
||||
{
|
||||
// WrapStyle
|
||||
pCell->m_oStyle.Init();
|
||||
pCell->m_oStyle->SetValue(1);
|
||||
}
|
||||
|
||||
pCell->setRowCol(nRow, nCol);
|
||||
oRow.m_arrItems.push_back(pCell);
|
||||
}
|
||||
_UINT32 ReadFromCsvToXlsx(const std::wstring &sFileName, OOX::Spreadsheet::CXlsx &oXlsx, UINT nCodePage, const std::wstring& sDelimiter)
|
||||
{
|
||||
NSFile::CFileBinary oFile;
|
||||
if (false == oFile.OpenFile(sFileName)) return AVS_FILEUTILS_ERROR_CONVERT;
|
||||
//-----------------------------------------------------------------------------------
|
||||
// Создадим Workbook
|
||||
oXlsx.CreateWorkbook();
|
||||
// Создадим стили
|
||||
oXlsx.CreateStyles();
|
||||
|
||||
// Добавим стили для wrap-а
|
||||
oXlsx.m_pStyles->m_oCellXfs.Init();
|
||||
oXlsx.m_pStyles->m_oCellXfs->m_oCount.Init();
|
||||
oXlsx.m_pStyles->m_oCellXfs->m_oCount->SetValue(2);
|
||||
|
||||
// Normall default
|
||||
OOX::Spreadsheet::CXfs* pXfs = NULL;
|
||||
pXfs = new OOX::Spreadsheet::CXfs();
|
||||
pXfs->m_oBorderId.Init();
|
||||
pXfs->m_oBorderId->SetValue(0);
|
||||
pXfs->m_oFillId.Init();
|
||||
pXfs->m_oFillId->SetValue(0);
|
||||
pXfs->m_oFontId.Init();
|
||||
pXfs->m_oFontId->SetValue(0);
|
||||
pXfs->m_oNumFmtId.Init();
|
||||
pXfs->m_oNumFmtId->SetValue(0);
|
||||
|
||||
oXlsx.m_pStyles->m_oCellXfs->m_arrItems.push_back(pXfs);
|
||||
|
||||
// Wrap style
|
||||
pXfs = new OOX::Spreadsheet::CXfs();
|
||||
pXfs->m_oBorderId.Init();
|
||||
pXfs->m_oBorderId->SetValue(0);
|
||||
pXfs->m_oFillId.Init();
|
||||
pXfs->m_oFillId->SetValue(0);
|
||||
pXfs->m_oFontId.Init();
|
||||
pXfs->m_oFontId->SetValue(0);
|
||||
pXfs->m_oNumFmtId.Init();
|
||||
pXfs->m_oNumFmtId->SetValue(0);
|
||||
|
||||
pXfs->m_oApplyAlignment.Init();
|
||||
pXfs->m_oApplyAlignment->SetValue(SimpleTypes::onoffTrue);
|
||||
pXfs->m_oAligment.Init();
|
||||
pXfs->m_oAligment->m_oWrapText.Init();
|
||||
pXfs->m_oAligment->m_oWrapText->SetValue(SimpleTypes::onoffTrue);
|
||||
|
||||
oXlsx.m_pStyles->m_oCellXfs->m_arrItems.push_back(pXfs);
|
||||
|
||||
std::wstring sSheetRId = L"rId1";
|
||||
OOX::Spreadsheet::CWorksheet* pWorksheet = new OOX::Spreadsheet::CWorksheet(NULL);
|
||||
pWorksheet->m_oSheetData.Init();
|
||||
|
||||
OOX::Spreadsheet::CSheet *pSheet = new OOX::Spreadsheet::CSheet();
|
||||
|
||||
pSheet->m_oName.Init();
|
||||
pSheet->m_oName->append(L"Sheet1");
|
||||
pSheet->m_oSheetId.Init();
|
||||
pSheet->m_oSheetId->SetValue(1);
|
||||
pSheet->m_oRid.Init();
|
||||
pSheet->m_oRid->SetValue(sSheetRId);
|
||||
|
||||
oXlsx.m_pWorkbook->m_oSheets.Init();
|
||||
oXlsx.m_pWorkbook->m_oSheets->m_arrItems.push_back(pSheet);
|
||||
|
||||
//-----------------------------------------------------------------------------------
|
||||
DWORD nFileSize = 0;
|
||||
BYTE* pFileData = new BYTE[oFile.GetFileSize()];
|
||||
|
||||
oFile.ReadFile(pFileData, oFile.GetFileSize(), nFileSize);
|
||||
oFile.CloseFile();
|
||||
//skip bom
|
||||
DWORD nInputBufferSize = nFileSize;
|
||||
BYTE* pInputBuffer = pFileData;
|
||||
if (nInputBufferSize >= 3 && 0xef == pInputBuffer[0] && 0xbb == pInputBuffer[1] && 0xbf == pInputBuffer[2])
|
||||
{
|
||||
nInputBufferSize -= 3;
|
||||
pInputBuffer += 3;
|
||||
}
|
||||
else if (nInputBufferSize >= 2 && ((0xfe == pInputBuffer[0] && 0xff == pInputBuffer[1]) || (0xff == pInputBuffer[0] && 0xfe == pInputBuffer[1])))
|
||||
{
|
||||
nInputBufferSize -= 2;
|
||||
pInputBuffer += 2;
|
||||
}
|
||||
|
||||
std::wstring sFileDataW;
|
||||
|
||||
if (nCodePage == 1000)
|
||||
{
|
||||
sFileDataW = ansi_2_unicode(pInputBuffer, nInputBufferSize);
|
||||
}
|
||||
else if (nCodePage == 46)//utf-8
|
||||
{
|
||||
sFileDataW = utf8_2_unicode(pInputBuffer, nInputBufferSize);
|
||||
}
|
||||
else if (nCodePage == 48)//utf-16
|
||||
{
|
||||
sFileDataW = utf16_2_unicode(pInputBuffer, nInputBufferSize);
|
||||
}
|
||||
else if (nCodePage == 50) // utf-32
|
||||
{
|
||||
sFileDataW = utf32_2_unicode(pInputBuffer, nInputBufferSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef __ANDROID__
|
||||
const auto oEncodindId = *std::find_if (NSUnicodeConverter::Encodings, NSUnicodeConverter::Encodings + UNICODE_CONVERTER_ENCODINGS_COUNT - 1, [nCodePage] (const NSUnicodeConverter::EncodindId& ei) { return ei.WindowsCodePage == nCodePage; });
|
||||
#else
|
||||
const NSUnicodeConverter::EncodindId& oEncodindId = NSUnicodeConverter::Encodings[nCodePage];
|
||||
#endif
|
||||
NSUnicodeConverter::CUnicodeConverter oUnicodeConverter;
|
||||
sFileDataW = oUnicodeConverter.toUnicode((const char*)pInputBuffer, nInputBufferSize, oEncodindId.Name);
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
size_t nSize = sFileDataW.length();
|
||||
|
||||
if (nSize < 1 && nInputBufferSize > 0)
|
||||
{//для синхронности вывода превью и нормального результата
|
||||
#ifdef __ANDROID__
|
||||
const auto oEncodindId = *std::find_if (NSUnicodeConverter::Encodings, NSUnicodeConverter::Encodings + UNICODE_CONVERTER_ENCODINGS_COUNT - 1, [nCodePage] (const NSUnicodeConverter::EncodindId& ei) { return ei.WindowsCodePage == nCodePage; });
|
||||
#else
|
||||
const NSUnicodeConverter::EncodindId& oEncodindId = NSUnicodeConverter::Encodings[nCodePage];
|
||||
#endif
|
||||
NSUnicodeConverter::CUnicodeConverter oUnicodeConverter;
|
||||
sFileDataW = oUnicodeConverter.toUnicode((const char*)pInputBuffer, nInputBufferSize, oEncodindId.Name);
|
||||
|
||||
nSize = sFileDataW.length();
|
||||
//return AVS_FILEUTILS_ERROR_CONVERT_ICU;
|
||||
}
|
||||
const WCHAR *pTemp = sFileDataW.c_str();
|
||||
|
||||
WCHAR wcDelimiterLeading = L'\0';
|
||||
WCHAR wcDelimiterTrailing = L'\0';
|
||||
int nDelimiterSize = 0;
|
||||
|
||||
if (sDelimiter.length() > 0)
|
||||
{
|
||||
wcDelimiterLeading = sDelimiter[0];
|
||||
nDelimiterSize = 1;
|
||||
if (2 == sizeof(wchar_t) && 0xD800 <= wcDelimiterLeading && wcDelimiterLeading <= 0xDBFF && sDelimiter.length() > 1)
|
||||
{
|
||||
wcDelimiterTrailing = sDelimiter[1];
|
||||
nDelimiterSize = 2;
|
||||
}
|
||||
}
|
||||
|
||||
const WCHAR wcNewLineN = _T('\n');
|
||||
const WCHAR wcNewLineR = _T('\r');
|
||||
const WCHAR wcQuote = _T('"');
|
||||
const WCHAR wcTab = _T('\t');
|
||||
|
||||
bool bIsWrap = false;
|
||||
WCHAR wcCurrent;
|
||||
INT nStartCell = 0;
|
||||
std::stack<INT> oDeleteChars;
|
||||
|
||||
bool bInQuote = false;
|
||||
INT nIndexRow = 0;
|
||||
INT nIndexCol = 0;
|
||||
OOX::Spreadsheet::CRow *pRow = new OOX::Spreadsheet::CRow();
|
||||
pRow->m_oR.Init();
|
||||
pRow->m_oR->SetValue(nIndexRow + 1);
|
||||
|
||||
for (size_t nIndex = 0; nIndex < nSize; ++nIndex)
|
||||
{
|
||||
wcCurrent = pTemp[nIndex];
|
||||
if (wcDelimiterLeading == wcCurrent && (L'\0' == wcDelimiterTrailing || (nIndex + 1 < nSize && wcDelimiterTrailing == pTemp[nIndex + 1])))
|
||||
{
|
||||
if (bInQuote)
|
||||
continue;
|
||||
// New Cell
|
||||
std::wstring sCellText(pTemp + nStartCell, nIndex - nStartCell);
|
||||
AddCell(sCellText, nStartCell, oDeleteChars, *pRow, nIndexRow, nIndexCol++, bIsWrap);
|
||||
bIsWrap = false;
|
||||
|
||||
nStartCell = nIndex + nDelimiterSize;
|
||||
if (nStartCell == nSize)
|
||||
{
|
||||
pWorksheet->m_oSheetData->m_arrItems.push_back(pRow);
|
||||
pRow = NULL;
|
||||
}
|
||||
}
|
||||
else if (wcNewLineN == wcCurrent || wcNewLineR == wcCurrent)
|
||||
{
|
||||
if (bInQuote)
|
||||
{
|
||||
// Добавим Wrap
|
||||
bIsWrap = true;
|
||||
continue;
|
||||
}
|
||||
// New line
|
||||
if (nStartCell != nIndex)
|
||||
{
|
||||
std::wstring sCellText(pTemp + nStartCell, nIndex - nStartCell);
|
||||
AddCell(sCellText, nStartCell, oDeleteChars, *pRow, nIndexRow, nIndexCol++, bIsWrap);
|
||||
bIsWrap = false;
|
||||
}
|
||||
|
||||
if (wcNewLineR == wcCurrent && nIndex + 1 != nSize && wcNewLineN == pTemp[nIndex + 1])
|
||||
{
|
||||
// На комбинацию \r\n должен быть только 1 перенос
|
||||
++nIndex;
|
||||
}
|
||||
|
||||
nStartCell = nIndex + 1;
|
||||
|
||||
pWorksheet->m_oSheetData->m_arrItems.push_back(pRow);
|
||||
pRow = new OOX::Spreadsheet::CRow();
|
||||
pRow->m_oR.Init();
|
||||
pRow->m_oR->SetValue(++nIndexRow + 1);
|
||||
nIndexCol = 0;
|
||||
}
|
||||
else if (wcQuote == wcCurrent)
|
||||
{
|
||||
// Quote
|
||||
if (false == bInQuote && nStartCell == nIndex && nIndex + 1 != nSize)
|
||||
{
|
||||
// Начало новой ячейки (только если мы сразу после разделителя и не в конце файла)
|
||||
bInQuote = !bInQuote;
|
||||
nStartCell = nIndex + 1;
|
||||
}
|
||||
else if ( bInQuote )
|
||||
{
|
||||
// Нужно удалить кавычку ограничитель
|
||||
oDeleteChars.push(nIndex);
|
||||
|
||||
// Если следующий символ кавычка, то мы не закончили ограничитель строки (1997,Ford,E350,"Super, ""luxurious"" truck")
|
||||
if (nIndex + 1 != nSize && wcQuote == pTemp[nIndex + 1])
|
||||
++nIndex;
|
||||
else
|
||||
bInQuote = !bInQuote;
|
||||
}
|
||||
}
|
||||
else if (wcTab == wcCurrent)
|
||||
{
|
||||
// delete tab if not delimiter
|
||||
oDeleteChars.push(nIndex);
|
||||
}
|
||||
}
|
||||
|
||||
if (nStartCell != nSize)
|
||||
{
|
||||
// New line
|
||||
std::wstring sCellText(pTemp + nStartCell, nSize - nStartCell);
|
||||
AddCell(sCellText, nStartCell, oDeleteChars, *pRow, nIndexRow, nIndexCol++, bIsWrap);
|
||||
pWorksheet->m_oSheetData->m_arrItems.push_back(pRow);
|
||||
}
|
||||
else
|
||||
{
|
||||
RELEASEOBJECT(pRow);
|
||||
}
|
||||
oXlsx.m_arWorksheets.push_back(pWorksheet);
|
||||
oXlsx.m_mapWorksheets.insert(std::make_pair(sSheetRId, pWorksheet));
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user