Compare commits

..

41 Commits

Author SHA1 Message Date
2261de2884 Fix build without UNICODE
(cherry picked from commit 4503678e2c)
2020-05-26 12:33:36 +03:00
7bc4ab9655 Use boost 1.72 2020-05-26 12:32:02 +03:00
5e6d2f12d5 x2t - bin reader - fix error 2020-05-25 19:35:52 +03:00
fb7d20c7e0 Merge pull request #257 from ONLYOFFICE/feature/fixFor554
Feature/fix for554
2020-05-25 16:22:34 +00:00
ba518d7c85 . 2020-05-25 18:26:26 +03:00
a045f57430 . 2020-05-25 18:24:18 +03:00
b10274c65d x2t - fix users files; fix bug #45439 2020-05-25 17:21:05 +03:00
c1e4a2ce33 v5.5.3 2020-05-22 11:21:42 +03:00
ee091e7ca9 [x2t] Fix writing corrupted docx
any docx file with chart in group shape
2020-05-06 10:30:07 +03:00
3d814e7b40 Merge pull request #253 from ONLYOFFICE/hotfix/v5.5.2 2020-04-27 18:37:39 +03:00
bb65549dc1 RtfFormat - fix bug #45195 (#250) 2020-04-17 15:56:01 +03:00
5294089fd0 [builder] Stop work with local resources in web mode (#249) 2020-04-16 17:37:14 +03:00
3ec24e5e39 RtfFormat - fix bug #45166 2020-04-16 16:32:25 +03:00
dc44dc5e84 RtfFormat - fix bug #45150 2020-04-16 16:32:25 +03:00
cf76de8811 . 2020-04-16 16:32:25 +03:00
86421d8235 DocxFormat - fix bug #44709 2020-04-16 16:32:25 +03:00
5e77e96e5f [x2t] Fix bug 45171 (#248) 2020-04-16 15:52:16 +03:00
973b89609d v5.5.1r2 2020-04-15 13:04:24 +03:00
a0c0171d12 Set small fontscache size by allfontsgen working... (#244) 2020-04-11 12:12:50 +03:00
d5c5c4b8cf v5.5.1 2020-04-09 12:40:22 +03:00
60904a6df0 Fix windows xp support for non-console apps (#240) 2020-04-06 12:08:03 +03:00
72315d1229 Add sort to application fonts list (#239) 2020-04-06 10:51:12 +03:00
abb5fd1ec1 x2t - fix bug #44957 (#238) 2020-04-02 13:16:09 +03:00
fd6beb0044 return error from abnormal zip (#237) 2020-04-02 11:46:00 +03:00
1b6eff5cb7 Fix writing sdk version when linking binary files (macos) (#236) 2020-04-01 10:38:33 +03:00
4fc6511b37 . (#235) 2020-03-31 19:00:41 +03:00
52ff8af2be Feature/year (#234)
* Correct year detect on windows

* Remove qmake message
2020-03-31 15:15:17 +03:00
d29475b6fb Update base.pri (#233) 2020-03-30 17:45:42 +03:00
32e7193212 [x2t] Fix bug 44934 (#232) 2020-03-28 19:39:47 +03:00
23fc146eca Fix wget/curl parameters injection 2020-03-24 13:38:10 +03:00
7fd9e52bc3 Merge pull request #230 from ONLYOFFICE/feature/fix_bug_v5.5.1
fix bug in zip
2020-03-19 18:22:53 +03:00
dd13f9f24c fix bug in zip 2020-03-19 18:21:00 +03:00
0fe3c3ece5 Merge pull request #228 from ONLYOFFICE/feature/fix_bug_v5.5.1
XlsxFormat - fix bug #44840
2020-03-19 12:56:48 +03:00
5d148a6d0d Set htmlfileinternal path to doctrenderer.config 2020-03-18 18:28:56 +03:00
d7af2cb41d Remove path to HtmlFileInternal from x2t xml params 2020-03-18 18:09:52 +03:00
ed5bfb7b27 Add gitignore file 2020-03-18 16:33:25 +03:00
b81e988da5 XlsxFormat - fix bug #44840 2020-03-18 15:15:26 +03:00
a7c868d3d1 Remove unused files 2020-03-18 09:55:30 +03:00
bb022c49bd Fix xp build 2020-03-16 17:54:21 +03:00
31e8a1cbdd Fix previous commit 2020-03-16 17:27:31 +03:00
a19074993d Fix xp artifacts 2020-03-16 17:23:27 +03:00
62 changed files with 1530 additions and 4544 deletions

View File

@ -100,6 +100,7 @@ public:
bSectionType = false;
bPageNumStart = false;
bRtlGutter = false;
bGutter = false;
}
std::wstring Write()
{
@ -730,10 +731,12 @@ public:
{
pCStringWriter->WriteString(L"<w:sz w:val=\"" + std::to_wstring(FontSize) + L"\"/>");
}
if(bFontSizeCs)
{
if(bFontSizeCs)
{
if(false == bFontSize)
pCStringWriter->WriteString(L"<w:sz w:val=\"" + std::to_wstring(FontSizeCs) + L"\"/>");
pCStringWriter->WriteString(L"<w:szCs w:val=\"" + std::to_wstring(FontSizeCs) + L"\"/>");
}
}
if(bHighLight)
{
docRGB& H = HighLight;

View File

@ -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"
>

View File

@ -350,9 +350,10 @@ namespace PPTX
{
nvGraphicFramePr.toXmlWriter(pWriter);
if (xfrm.IsInit() && pWriter->m_lDocType != XMLWRITER_DOC_TYPE_DOCX)
if (xfrm.IsInit() && (pWriter->m_lDocType != XMLWRITER_DOC_TYPE_DOCX || pWriter->m_lGroupIndex >= 0))
{
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX && pWriter->m_lGroupIndex >= 0) xfrm->m_ns = L"xdr";
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX && pWriter->m_lGroupIndex >= 0) xfrm->m_ns = L"wpg";
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_GRAPHICS) xfrm->m_ns = L"a";
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_CHART_DRAWING) xfrm->m_ns = L"cdr";

View File

@ -2918,7 +2918,15 @@ bool RtfParagraphPropDestination::ExecuteCommand(RtfDocument& oDocument, RtfRead
// pNewChar->m_eType = RtfCharSpecial::rsc_chatn;
// m_oCurParagraph->AddItem( pNewChar );
//}
else if ( "chftn" == sCommand )
else if ( "chpgn" == sCommand ) //todooo - other special
{//header & footer
RtfCharSpecialPtr pNewChar ( new RtfCharSpecial() );
pNewChar->m_oProperty = oReader.m_oState->m_oCharProp;
pNewChar->m_eType = RtfCharSpecial::rsc_chpgn;
m_oCurParagraph->AddItem( pNewChar );
}
else if ( "chftn" == sCommand )
{
if ( 1 == oReader.m_nFootnote )
{

View File

@ -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;

View File

@ -270,6 +270,7 @@ public:
m_byteShade = oColor.m_byteShade;
m_byteTint = oColor.m_byteTint;
m_bAuto = oColor.m_bAuto;
return (*this);
}

View File

@ -2,13 +2,16 @@ INCLUDEPATH += $$PWD/build/$$CORE_BUILDS_PLATFORM_PREFIX/include
CORE_BOOST_LIBS = $$PWD/build/$$CORE_BUILDS_PLATFORM_PREFIX/lib
core_windows {
BOOST_POSTFIX = vc140
core_debug:BOOST_POSTFIX=$$BOOST_POSTFIX-mt-gd-1_58
core_release:BOOST_POSTFIX=$$BOOST_POSTFIX-mt-1_58
core_win_64:BOOST_POSTFIX = -vc140-mt-x64-1_72
core_win_32:BOOST_POSTFIX = -vc140-mt-x32-1_72
core_debug {
core_win_64:BOOST_POSTFIX = -vc140-mt-gd-x64-1_72
core_win_32:BOOST_POSTFIX = -vc140-mt-gd-x32-1_72
}
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
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 {
core_boost_libs:LIBS += -L$$CORE_BOOST_LIBS -lboost_system -lboost_filesystem
core_boost_regex:LIBS += -L$$CORE_BOOST_LIBS -lboost_regex

View File

@ -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%

View File

@ -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

View File

@ -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%/"
)

View File

@ -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
View File

@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

View File

@ -1 +0,0 @@
echo "build: OK!"

View File

@ -1,3 +0,0 @@
#!/bin/bash
echo "build: OK!"

View File

@ -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]
}

View File

@ -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

View File

@ -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

View File

@ -1 +0,0 @@
echo "build: OK!"

View File

@ -1,3 +0,0 @@
#!/bin/bash
echo "build: OK!"

View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -0,0 +1,486 @@
/*
* (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 "./common_openssl.h"
#include <openssl/sha.h>
#include <openssl/rsa.h>
#include <openssl/bio.h>
#include <openssl/pem.h>
#include <openssl/err.h>
#include <openssl/aes.h>
namespace NSOpenSSL
{
unsigned char* openssl_alloc(unsigned int len)
{
return (unsigned char*)malloc(len);
}
void openssl_free(unsigned char* data)
{
free(data);
}
// hash
unsigned int GetHashSize(const int& alg)
{
switch (alg)
{
case OPENSSL_HASH_ALG_SHA1:
return 20;
case OPENSSL_HASH_ALG_SHA224:
return 28;
case OPENSSL_HASH_ALG_SHA256:
return 32;
case OPENSSL_HASH_ALG_SHA384:
return 48;
case OPENSSL_HASH_ALG_SHA512:
return 64;
default:
break;
}
return 0;
}
unsigned char* GetHash(const unsigned char* data, const unsigned int& size, const int& alg, unsigned int& len)
{
len = GetHashSize(alg);
if (0 == len)
return NULL;
unsigned char* res = openssl_alloc(len);
switch (alg)
{
case OPENSSL_HASH_ALG_SHA1:
SHA1(data, (size_t)size, res);
break;
case OPENSSL_HASH_ALG_SHA224:
SHA224(data, (size_t)size, res);
break;
case OPENSSL_HASH_ALG_SHA256:
SHA256(data, (size_t)size, res);
break;
case OPENSSL_HASH_ALG_SHA384:
SHA384(data, (size_t)size, res);
break;
case OPENSSL_HASH_ALG_SHA512:
SHA512(data, (size_t)size, res);
break;
default:
break;
}
return res;
}
// rsa
bool RSA_GenerateKeys(unsigned char*& publicKey, unsigned char*& privateKey)
{
publicKey = NULL;
privateKey = NULL;
RSA* rsa = RSA_new();
BIGNUM *exponent = BN_new();
BN_set_word(exponent, RSA_F4);
int result = RSA_generate_multi_prime_key(rsa, 2048, 2, exponent, NULL);
if (0 == result)
return false;
if (true)
{
BIO* bio = BIO_new(BIO_s_mem());
if (PEM_write_bio_RSAPrivateKey(bio, rsa, NULL, NULL, 0, NULL, NULL))
{
int key_length = BIO_pending(bio);
privateKey = openssl_alloc(key_length + 1);
if (key_length != BIO_read(bio, privateKey, key_length))
{
openssl_free(privateKey);
privateKey = NULL;
}
else
{
privateKey[key_length] = '\0';
}
}
BIO_free_all(bio);
}
if (true)
{
BIO* bio = BIO_new(BIO_s_mem());
if (PEM_write_bio_RSA_PUBKEY(bio, rsa))
{
int key_length = BIO_pending(bio);
publicKey = openssl_alloc(key_length + 1);
if (key_length != BIO_read(bio, publicKey, key_length))
{
openssl_free(publicKey);
publicKey = NULL;
}
else
{
publicKey[key_length] = '\0';
}
}
BIO_free_all(bio);
}
BN_free(exponent);
RSA_free(rsa);
return (NULL != publicKey && NULL != privateKey) ? true : false;
}
//#define USE_DEPRECATED
bool RSA_EncryptPublic(const unsigned char* publicKey, const unsigned char* data, const unsigned int& size, unsigned char*& data_crypt, unsigned int& data_crypt_len)
{
BIO* bio = BIO_new_mem_buf(publicKey, (int)strlen((char*)publicKey));
#ifdef USE_DEPRECATED
RSA* rsa = RSA_new();
RSA* resrsa = PEM_read_bio_RSA_PUBKEY(bio, &rsa, 0, NULL);
unsigned int key_size = (unsigned int)RSA_size(rsa);
data_crypt = openssl_alloc(key_size);
int res = RSA_public_encrypt((int)size, data, data_crypt, rsa, RSA_NO_PADDING);
data_crypt_len = key_size;
BIO_free(bio);
RSA_free(rsa);
return (-1 != res) ? true : false;
#else
EVP_PKEY* publicKeyEngine = NULL;
PEM_read_bio_PUBKEY(bio, &publicKeyEngine, 0, NULL);
EVP_PKEY_CTX *ctx = EVP_PKEY_CTX_new(publicKeyEngine, NULL);
EVP_PKEY_encrypt_init(ctx);
EVP_PKEY_CTX_set_rsa_padding(ctx, RSA_PKCS1_OAEP_PADDING);
size_t out_len = 0;
EVP_PKEY_encrypt(ctx, NULL, &out_len, data, (size_t)size);
data_crypt = openssl_alloc((unsigned int)out_len);
EVP_PKEY_encrypt(ctx, data_crypt, &out_len, data, (size_t)size);
data_crypt_len = (unsigned int)out_len;
EVP_PKEY_CTX_free(ctx);
EVP_PKEY_free(publicKeyEngine);
BIO_free(bio);
return (out_len > 0) ? true : false;
#endif
}
bool RSA_DecryptPrivate(const unsigned char* privateKey, const unsigned char* data, const unsigned int& size, unsigned char*& data_decrypt, unsigned int& data_decrypt_len)
{
BIO* bio = BIO_new_mem_buf(privateKey, (int)strlen((char*)privateKey));
#ifdef USE_DEPRECATED
RSA* rsa = RSA_new();
PEM_read_bio_RSAPrivateKey(bio, &rsa, 0, NULL);
unsigned int key_size = (unsigned int)RSA_size(rsa);
data_decrypt = openssl_alloc(key_size);
int res = RSA_private_decrypt((int)size, data, data_decrypt, rsa, RSA_NO_PADDING);
data_decrypt_len = key_size;
BIO_free(bio);
RSA_free(rsa);
return (-1 != res) ? true : false;
#else
EVP_PKEY* privateKeyEngine = NULL;
PEM_read_bio_PrivateKey(bio, &privateKeyEngine, 0, NULL);
EVP_PKEY_CTX *ctx = EVP_PKEY_CTX_new(privateKeyEngine, NULL);
EVP_PKEY_decrypt_init(ctx);
EVP_PKEY_CTX_set_rsa_padding(ctx, RSA_PKCS1_OAEP_PADDING);
size_t out_len = 0;
EVP_PKEY_decrypt(ctx, NULL, &out_len, data, (size_t)size);
data_decrypt = openssl_alloc((unsigned int)out_len);
EVP_PKEY_decrypt(ctx, data_decrypt, &out_len, data, (size_t)size);
data_decrypt_len = (unsigned int)out_len;
EVP_PKEY_CTX_free(ctx);
EVP_PKEY_free(privateKeyEngine);
BIO_free(bio);
return (out_len > 0) ? true : false;
#endif
}
bool RSA_EncryptPublic_desktop(const unsigned char* publicKey, const std::string& input, std::string& out)
{
unsigned char* out_ptr = NULL;
unsigned int out_ptr_len = 0;
if (!RSA_EncryptPublic(publicKey, (unsigned char*)input.c_str(), (unsigned int)input.length(), out_ptr, out_ptr_len))
return false;
out = Serialize(out_ptr, out_ptr_len, OPENSSL_SERIALIZE_TYPE_BASE64);
openssl_free(out_ptr);
return true;
}
bool RSA_DecryptPrivate_desktop(const unsigned char* privateKey, const std::string& input, std::string& out)
{
unsigned char* input_ptr = NULL;
int input_ptr_len = 0;
bool bBase64 = NSFile::CBase64Converter::Decode(input.c_str(), (int)input.length(), input_ptr, input_ptr_len);
if (!bBase64)
return false;
unsigned char* out_ptr = NULL;
unsigned int out_ptr_len = 0;
if (!RSA_DecryptPrivate(privateKey, input_ptr, (unsigned int)input_ptr_len, out_ptr, out_ptr_len))
{
openssl_free(input_ptr);
return false;
}
//out = Serialize(out_ptr, out_ptr_len, OPENSSL_SERIALIZE_TYPE_ASCII);
out = std::string((char*)out_ptr, out_ptr_len);
openssl_free(input_ptr);
openssl_free(out_ptr);
return true;
}
// pbkdf2
const EVP_MD* Get_EVP_MD(int nAlg)
{
switch (nAlg)
{
case OPENSSL_HASH_ALG_SHA1:
{
return EVP_sha1();
}
case OPENSSL_HASH_ALG_SHA224:
{
return EVP_sha224();
}
case OPENSSL_HASH_ALG_SHA256:
{
return EVP_sha256();
}
case OPENSSL_HASH_ALG_SHA384:
{
return EVP_sha384();
}
case OPENSSL_HASH_ALG_SHA512:
{
return EVP_sha512();
}
default:
break;
}
return EVP_sha1();
}
unsigned char* PBKDF2(const char* pass, int passlen, const unsigned char* salt, int saltlen, int hash_alg, int key_len)
{
unsigned char* out = openssl_alloc(key_len);
if (0 == PKCS5_PBKDF2_HMAC(pass, passlen, salt, saltlen, 1000, Get_EVP_MD(hash_alg), key_len, out))
{
openssl_free(out);
out = NULL;
}
return out;
}
unsigned char* PBKDF2_desktop(const std::string& pass, const std::string& salt)
{
unsigned char* key_iv = NULL;
if (salt.empty())
{
unsigned int pass_salt_len = 0;
unsigned char* pass_salt = NSOpenSSL::GetHash((unsigned char*)pass.c_str(), (unsigned int)pass.length(), OPENSSL_HASH_ALG_SHA512, pass_salt_len);
key_iv = PBKDF2(pass.c_str(), (int)pass.length(), pass_salt, pass_salt_len, OPENSSL_HASH_ALG_SHA256, 32 + 16);
openssl_free(pass_salt);
}
else
{
key_iv = PBKDF2(pass.c_str(), (int)pass.length(), (const unsigned char*)salt.c_str(), (unsigned int)salt.length(), OPENSSL_HASH_ALG_SHA256, 32 + 16);
}
return key_iv;
}
// aes
int AES_GetKeySize(int type)
{
switch (type)
{
case OPENSSL_AES_256_CBC:
return 32;
}
return 32;
}
int AES_GetIvSize(int type)
{
switch (type)
{
case OPENSSL_AES_256_CBC:
return 16;
}
return 16;
}
const EVP_CIPHER* _get_cipher_aes(int type)
{
switch (type)
{
case OPENSSL_AES_256_CBC:
return EVP_aes_256_cbc();
}
return NULL;
}
bool AES_Encrypt(int type, const unsigned char* key, const unsigned char* iv, const unsigned char* data, const unsigned int& size, unsigned char*& data_crypt, unsigned int& data_crypt_len)
{
EVP_CIPHER_CTX* ctx = EVP_CIPHER_CTX_new();
EVP_CIPHER_CTX_init(ctx);
EVP_EncryptInit_ex(ctx, _get_cipher_aes(type), NULL, key, iv);
EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_IVLEN, 16, NULL);
int out_len1 = (int)size + AES_BLOCK_SIZE;
int out_len2 = 0;
data_crypt = openssl_alloc(out_len1);
EVP_EncryptUpdate(ctx, data_crypt, &out_len1, data, (int)size);
EVP_EncryptFinal_ex(ctx, data_crypt + out_len1, &out_len2);
data_crypt_len = out_len1 + out_len2;
EVP_CIPHER_CTX_free(ctx);
EVP_cleanup();
return true;
}
bool AES_Decrypt(int type, const unsigned char* key, const unsigned char* iv, const unsigned char* data, const unsigned int& size, unsigned char*& data_decrypt, unsigned int& data_decrypt_len)
{
EVP_CIPHER_CTX* ctx = EVP_CIPHER_CTX_new();
EVP_CIPHER_CTX_init(ctx);
EVP_DecryptInit_ex(ctx, _get_cipher_aes(type), NULL, key, iv);
EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_IVLEN, 16, NULL);
int out_len1 = (int)size;
int out_len2 = 0;
data_decrypt = openssl_alloc(out_len1);
EVP_DecryptUpdate(ctx, data_decrypt, &out_len1, data, (int)size);
EVP_DecryptFinal_ex(ctx, data_decrypt + out_len1, &out_len2);
data_decrypt_len = out_len1 + out_len2;
EVP_CIPHER_CTX_free(ctx);
EVP_cleanup();
return true;
}
bool AES_Encrypt_desktop(const std::string& pass, const std::string& input, std::string& output, const std::string& salt)
{
unsigned char* key_iv = PBKDF2_desktop(pass, salt);
bool bRes = AES_Encrypt_desktop(key_iv, input, output);
openssl_free(key_iv);
return bRes;
}
bool AES_Decrypt_desktop(const std::string& pass, const std::string& input, std::string& output, const std::string& salt)
{
unsigned char* key_iv = PBKDF2_desktop(pass, salt);
bool bRes = AES_Decrypt_desktop(key_iv, input, output);
openssl_free(key_iv);
return bRes;
}
bool AES_Encrypt_desktop(const unsigned char* key_iv, const std::string& input, std::string& output)
{
unsigned char* data_crypt = NULL;
unsigned int data_crypt_len = 0;
bool bRes = AES_Encrypt(OPENSSL_AES_256_CBC, key_iv, key_iv + 32, (unsigned char*)input.c_str(), (unsigned int)input.length(), data_crypt, data_crypt_len);
if (!bRes)
return false;
output = Serialize(data_crypt, data_crypt_len, OPENSSL_SERIALIZE_TYPE_BASE64);
openssl_free(data_crypt);
return true;
}
bool AES_Decrypt_desktop(const unsigned char* key_iv, const std::string& input, std::string& output)
{
unsigned char* input_ptr = NULL;
int input_ptr_len = 0;
bool bBase64 = NSFile::CBase64Converter::Decode(input.c_str(), (int)input.length(), input_ptr, input_ptr_len);
if (!bBase64)
return false;
unsigned char* data_decrypt = NULL;
unsigned int data_decrypt_len = 0;
bool bRes = AES_Decrypt(OPENSSL_AES_256_CBC, key_iv, key_iv + 32, input_ptr, input_ptr_len, data_decrypt, data_decrypt_len);
if (!bRes)
{
RELEASEARRAYOBJECTS(input_ptr);
return false;
}
//output = Serialize(out_ptr, out_ptr_len, OPENSSL_SERIALIZE_TYPE_ASCII);
output = std::string((char*)data_decrypt, data_decrypt_len);
RELEASEARRAYOBJECTS(input_ptr);
openssl_free(data_decrypt);
return true;
}
// serialize
std::string Serialize(const unsigned char* data, const unsigned int& size, const int& alg)
{
switch (alg)
{
case OPENSSL_SERIALIZE_TYPE_ASCII:
{
return std::string((char*)data, size);
}
case OPENSSL_SERIALIZE_TYPE_HEX:
{
std::string res;
res.reserve(2 * size + 1);
char tmp[16] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
for (unsigned int i = 0; i < size; ++i)
{
res.append(1, tmp[data[i] >> 4]);
res.append(1, tmp[data[i] & 0x0F]);
}
return res;
}
case OPENSSL_SERIALIZE_TYPE_BASE64:
{
char* pDataDst = NULL;
int nDataDst = 0;
NSFile::CBase64Converter::Encode((BYTE*)data, (int)size, pDataDst, nDataDst, NSBase64::B64_BASE64_FLAG_NOCRLF);
std::string sBase64((char*)pDataDst, nDataDst);
RELEASEARRAYOBJECTS(pDataDst);
return sBase64;
}
default:
break;
}
return "";
}
}

View File

@ -0,0 +1,94 @@
/*
* (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
*
*/
#ifndef COMMON_OPENSSL_H
#define COMMON_OPENSSL_H
#define OPENSSL_HASH_ALG_SHA1 0
#define OPENSSL_HASH_ALG_INVALID 1
#define OPENSSL_HASH_ALG_SHA256 2
#define OPENSSL_HASH_ALG_SHA224 3
#define OPENSSL_HASH_ALG_SHA384 4
#define OPENSSL_HASH_ALG_SHA512 5
#define OPENSSL_SERIALIZE_TYPE_BASE64 0
#define OPENSSL_SERIALIZE_TYPE_HEX 1
#define OPENSSL_SERIALIZE_TYPE_ASCII 2
#define OPENSSL_AES_256_CBC 0
#include "../../../../DesktopEditor/common/File.h"
#ifdef COMMON_OPENSSL_BUILDING
#define OPENSSL_DECL Q_DECL_EXPORT
#else
#define OPENSSL_DECL Q_DECL_IMPORT
#endif
namespace NSOpenSSL
{
// alloc
OPENSSL_DECL unsigned char* openssl_alloc(unsigned int len);
OPENSSL_DECL void openssl_free(unsigned char* data);
// hash
OPENSSL_DECL unsigned int GetHashSize(const int& alg);
OPENSSL_DECL unsigned char* GetHash(const unsigned char* data, const unsigned int& size, const int& alg, unsigned int& len);
// rsa
OPENSSL_DECL bool RSA_GenerateKeys(unsigned char*& publicKey, unsigned char*& privateKey);
OPENSSL_DECL bool RSA_EncryptPublic(const unsigned char* publicKey, const unsigned char* data, const unsigned int& size, unsigned char*& data_crypt, unsigned int& data_crypt_len);
OPENSSL_DECL bool RSA_DecryptPrivate(const unsigned char* privateKey, const unsigned char* data, const unsigned int& size, unsigned char*& data_decrypt, unsigned int& data_decrypt_len);
OPENSSL_DECL bool RSA_EncryptPublic_desktop(const unsigned char* publicKey, const std::string& input, std::string& out);
OPENSSL_DECL bool RSA_DecryptPrivate_desktop(const unsigned char* privateKey, const std::string& input, std::string& out);
// pbkdf2
OPENSSL_DECL unsigned char* PBKDF2(const char* pass, int passlen, const unsigned char* salt, int saltlen, int hash_alg, int key_len);
OPENSSL_DECL unsigned char* PBKDF2_desktop(const std::string& pass, const std::string& salt = "");
// aes
OPENSSL_DECL int AES_GetKeySize(int type);
OPENSSL_DECL int AES_GetIvSize(int type);
OPENSSL_DECL bool AES_Encrypt(int type, const unsigned char* key, const unsigned char* iv, const unsigned char* data, const unsigned int& size, unsigned char*& data_crypt, unsigned int& data_crypt_len);
OPENSSL_DECL bool AES_Decrypt(int type, const unsigned char* key, const unsigned char* iv, const unsigned char* data, const unsigned int& size, unsigned char*& data_crypt, unsigned int& data_crypt_len);
OPENSSL_DECL bool AES_Encrypt_desktop(const std::string& pass, const std::string& input, std::string& output, const std::string& salt = "");
OPENSSL_DECL bool AES_Decrypt_desktop(const std::string& pass, const std::string& input, std::string& output, const std::string& salt = "");
OPENSSL_DECL bool AES_Encrypt_desktop(const unsigned char* key_iv, const std::string& input, std::string& output);
OPENSSL_DECL bool AES_Decrypt_desktop(const unsigned char* key_iv, const std::string& input, std::string& output);
// serialize
OPENSSL_DECL std::string Serialize(const unsigned char* data, const unsigned int& size, const int& alg);
}
#endif // COMMON_OPENSSL_H

View File

@ -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

View File

@ -1,18 +1,11 @@
core_linux {
INCLUDEPATH += $$PWD/build/$$CORE_BUILDS_PLATFORM_PREFIX/include
INCLUDEPATH += $$PWD/openssl/include
core_windows:LIBS += -L$$PWD/build/$$CORE_BUILDS_PLATFORM_PREFIX/lib -llibcrypto -llibssl
!core_windows:LIBS += -L$$PWD/build/$$CORE_BUILDS_PLATFORM_PREFIX/lib -lcrypto -lssl
QMAKE_LFLAGS += -fvisibility=hidden
LIBS += $$PWD/openssl/libssl.a
LIBS += $$PWD/openssl/libcrypto.a
}
core_mac {
INCLUDEPATH += $$PWD/openssl/include
LIBS += $$PWD/openssl/libssl.a
LIBS += $$PWD/openssl/libcrypto.a
open_ssl_common {
DEFINES += COMMON_OPENSSL_BUILDING
HEADERS += $$PWD/common/common_openssl.h
SOURCES += $$PWD/common/common_openssl.cpp
}

View File

@ -0,0 +1,94 @@
/*
* (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 "./../common/common_openssl.h"
int main(int argc, char *argv[])
{
argc;
argv;
if (true)
{
std::string sTestHashString = "knoejnrgijwenrgiojwnergjiwnerigjnwerojgnweorigjn";
unsigned int data_len = 0;
unsigned char* data = NSOpenSSL::GetHash((unsigned char*)sTestHashString.c_str(), (unsigned int)sTestHashString.length(), OPENSSL_HASH_ALG_SHA256, data_len);
std::string sResult = NSOpenSSL::Serialize(data, data_len, OPENSSL_SERIALIZE_TYPE_HEX);
NSOpenSSL::openssl_free(data);
}
if (true)
{
unsigned char* publicKey = NULL;
unsigned char* privateKey = NULL;
bool bRes = NSOpenSSL::RSA_GenerateKeys(publicKey, privateKey);
bRes;
std::string sPublic((char*)publicKey);
std::string sPrivate((char*)privateKey);
NSOpenSSL::openssl_free(publicKey);
NSOpenSSL::openssl_free(privateKey);
std::string sMessage = "Hello world";
unsigned char* message_crypt = NULL;
unsigned int message_crypt_len = 0;
bool bEncrypt = NSOpenSSL::RSA_EncryptPublic((unsigned char*)sPublic.c_str(), (unsigned char*)sMessage.c_str(), (unsigned int)sMessage.length(), message_crypt, message_crypt_len);
bEncrypt;
unsigned char* message_decrypt = NULL;
unsigned int message_decrypt_len = 0;
bool bDecrypt = NSOpenSSL::RSA_DecryptPrivate((unsigned char*)sPrivate.c_str(), message_crypt, message_crypt_len, message_decrypt, message_decrypt_len);
bDecrypt;
std::string sMessageOut((char*)message_decrypt, message_decrypt_len);
NSOpenSSL::openssl_free(message_crypt);
NSOpenSSL::openssl_free(message_decrypt);
}
if (true)
{
std::string password = "{PASSWORD}";
std::string message = "{MESSAGE}";
std::string message_crypted = "";
std::string message_decrypted = "";
NSOpenSSL::AES_Encrypt_desktop(password, message, message_crypted);
NSOpenSSL::AES_Decrypt_desktop(password, message_crypted, message_decrypted);
message;
}
return 0;
}

View File

@ -0,0 +1,28 @@
QT -= core
QT -= gui
TARGET = test
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
CORE_ROOT_DIR = $$PWD/../../../../../core
PWD_ROOT_DIR = $$PWD
include($$CORE_ROOT_DIR/Common/base.pri)
############### destination path ###############
DESTDIR = $$PWD_ROOT_DIR/build/$$CORE_BUILDS_PLATFORM_PREFIX
################################################
INCLUDEPATH += $$PWD_ROOT_DIR/../build/$$CORE_BUILDS_PLATFORM_PREFIX/include
LIBS += -L$$PWD_ROOT_DIR/../build/$$CORE_BUILDS_PLATFORM_PREFIX/lib -llibcrypto
core_windows:LIBS += -lws2_32 -lAdvapi32 -lCrypt32 -lUser32
ADD_DEPENDENCY(kernel)
HEADERS += $$PWD_ROOT_DIR/../common/common_openssl.h
SOURCES += $$PWD_ROOT_DIR/../common/common_openssl.cpp
SOURCES += main.cpp

View File

@ -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%

View File

@ -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

View File

@ -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
)

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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 )

View File

@ -231,13 +231,11 @@ namespace XmlUtils
double d = 0;
#if defined (_WIN32) || defined (_WIN64)
swscanf_s(string.c_str(), L"%lf", &d);
#elif defined(_IOS) || defined(__ANDROID__)
swscanf(string.c_str(), L"%lf", &d);
swscanf_s(string.c_str(), L"%lf", &d);
#else
_stscanf(string.c_str(), L"%lf", &d);
swscanf(string.c_str(), L"%lf", &d);
#endif
return d;
return d;
}
AVSINLINE static float GetFloat (const std::wstring& string)
{
@ -245,13 +243,11 @@ namespace XmlUtils
float f = 0;
#if defined (_WIN32) || defined (_WIN64)
swscanf_s(string.c_str(), L"%f", &f);
#elif defined(_IOS) || defined(__ANDROID__)
swscanf(string.c_str(), L"%f", &f);
swscanf_s(string.c_str(), L"%f", &f);
#else
_stscanf(string.c_str(), L"%f", &f);
swscanf(string.c_str(), L"%f", &f);
#endif
return f;
return f;
}
AVSINLINE static std::wstring BoolToString (const bool & value)
{

View File

@ -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() ) )

View File

@ -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";

View File

@ -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
@ -145,8 +150,8 @@ core_windows {
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_CONSOLE = /SUBSYSTEM:WINDOWS,5.02
core_win_32:QMAKE_LFLAGS_CONSOLE = /SUBSYSTEM:WINDOWS,5.01
core_win_64:QMAKE_LFLAGS_WINDOWS = /SUBSYSTEM:WINDOWS,5.02
core_win_32:QMAKE_LFLAGS_WINDOWS = /SUBSYSTEM:WINDOWS,5.01
}
}
}
@ -286,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

View File

@ -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";

View File

@ -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"

View File

@ -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);

View File

@ -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);
}

View File

@ -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)
}

View File

@ -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;

View File

@ -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()

View File

@ -19,14 +19,6 @@ include($$CORE_ROOT_DIR/Common/base.pri)
ADD_DEPENDENCY(kernel)
DEFINES -= UNICODE
core_linux {
CONFIG += signature_openssl
}
core_mac {
CONFIG += signature_openssl
}
HEADERS += \
include/XmlCertificate.h \
include/OOXMLSigner.h \
@ -51,10 +43,12 @@ HEADERS += \
LIBS += -lcrypt32
LIBS += -lcryptui
LIBS += -lAdvapi32
LIBS += -lws2_32
LIBS += -lUser32
}
signature_openssl {
!core_windows {
HEADERS += \
src/XmlSigner_openssl.h
@ -64,8 +58,5 @@ SOURCES += \
}
signature_openssl {
CONFIG += open_ssl_common
include(../../../Common/3dParty/openssl/openssl.pri)
}

View File

@ -616,7 +616,7 @@ public:
void RemoveSignature(const std::string& sGuid)
{
int nCountSignatures = m_arSignatures.size();
int nCountSignatures = (int)m_arSignatures.size();
if (0 == nCountSignatures)
return;

View File

@ -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);
}

View File

@ -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_

View File

@ -3,6 +3,7 @@
#include "tchar.h"
#include "../source/ECMACryptFile.h"
#include "../../Common/OfficeFileFormatChecker.h"
#include "../../DesktopEditor/common/File.h"
#if defined(_WIN64)
#pragma comment(lib, "../../build/bin/icu/win_64/icuuc.lib")
@ -25,7 +26,7 @@ int _tmain(int argc, _TCHAR* argv[])
ECMACryptFile crypt_file;
bool result = false, bDataIntegrity = false;
std::wstring srcFileName = L"D:\\test\\_crypted\\test-111.docx";
std::wstring srcFileName = L"D:\\test\\_bad_86\\crypt_file_test.docx";
std::wstring dstFileName = srcFileName + L"-mycrypt.docx";
std::wstring dstFileName2 = dstFileName + L".oox";
@ -39,8 +40,17 @@ int _tmain(int argc, _TCHAR* argv[])
//std::wstring dstFileName1 = srcFileName1 + L".oox";
//result = crypt_file.DecryptOfficeFile(srcFileName1, dstFileName1, password, bDataIntegrity);
result = crypt_file.EncryptOfficeFile(srcFileName, dstFileName, password, L"123456789");
result = crypt_file.DecryptOfficeFile(dstFileName, dstFileName2, password, bDataIntegrity);
//result = crypt_file.EncryptOfficeFile(srcFileName, dstFileName, password, L"123456789");
//result = crypt_file.DecryptOfficeFile(dstFileName, dstFileName2, password, bDataIntegrity);
std::wstring addit_name = L"11111111111111111111111111111";
std::string addit_info = crypt_file.ReadAdditional(srcFileName, addit_name);
std::wstring temp = NSFile::CFileBinary::CreateTempFileWithUniqueName(L"", L"asd");
addit_info += std::string(temp.begin(), temp.end());
crypt_file.WriteAdditional(srcFileName, addit_name, addit_info);
return 0;
}

View File

@ -0,0 +1,314 @@
/*
* (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 "./../source/ECMACryptFile.h"
#include "./../../DesktopEditor/common/File.h"
#include "./../../Common/3dParty/openssl/common/common_openssl.h"
#include <iostream>
// examples:
// ooxml_crypt --file=D:/cryptor/1.docx --password=111
// ooxml_crypt --file=D:/cryptor/1.docx --add={user-id-1}\ndata1
// ooxml_crypt --file=D:/cryptor/1.docx --remove={user-id-1}
// ooxml_crypt --file=D:/cryptor/1.docx --remove={user-id-1}\ndata1
// ooxml_crypt --file=D:/cryptor/1.docx --add={user-id-1}\ndata11
// ooxml_crypt --file=D:/cryptor/1.docx --info=
void string_replace(std::wstring& text, const std::wstring& replaceFrom, const std::wstring& replaceTo)
{
size_t posn = 0;
while (std::wstring::npos != (posn = text.find(replaceFrom, posn)))
{
text.replace(posn, replaceFrom.length(), replaceTo);
posn += replaceTo.length();
}
}
void string_replaceA(std::string& text, const std::string& replaceFrom, const std::string& replaceTo)
{
size_t posn = 0;
while (std::string::npos != (posn = text.find(replaceFrom, posn)))
{
text.replace(posn, replaceFrom.length(), replaceTo);
posn += replaceTo.length();
}
}
#ifdef WIN32
int wmain(int argc, wchar_t** argv)
#else
int main(int argc, char** argv)
#endif
{
if (argc <= 0)
return 0;
std::wstring file_path;
std::wstring password;
bool is_print_info = false;
bool is_decrypt = false;
std::string user;
std::wstring user_key_file;
std::vector<std::string> add_records;
std::vector<std::string> remove_records;
for (int i = 0; i < argc; ++i)
{
#ifdef WIN32
std::wstring param(argv[i]);
#else
std::string paramA(argv[i]);
std::wstring param = UTF8_TO_U(paramA);
#endif
std::wstring::size_type len = param.length();
if (2 > len)
continue;
const wchar_t* param_str = param.c_str();
if (param_str[0] != '-' || param_str[1] != '-')
continue;
std::wstring::size_type pos = param.find('=');
if (std::wstring::npos == pos)
continue;
std::wstring key = param.substr(2, pos - 2);
std::wstring value = param.substr(pos + 1);
if (key == L"file")
{
file_path = value;
}
else if (key == L"add")
{
if (!value.empty())
{
if (value.c_str()[value.length() - 1] == '\n')
value = value.substr(0, value.length() - 1);
string_replace(value, L";;;", L"\n");
add_records.push_back(U_TO_UTF8(value));
}
}
else if (key == L"remove")
{
if (!value.empty())
{
if (value.c_str()[value.length() - 1] == '\n')
value = value.substr(0, value.length() - 1);
string_replace(value, L";;;", L"\n");
remove_records.push_back(U_TO_UTF8(value));
}
}
else if (key == L"password")
{
password = value;
}
else if (key == L"info")
{
is_print_info = true;
}
else if (key == L"decrypt")
{
is_decrypt = true;
}
else if (key == L"user")
{
user = U_TO_UTF8(value);
}
else if (key == L"key")
{
user_key_file = value;
}
}
if (file_path.empty() || !NSFile::CFileBinary::Exists(file_path))
{
std::cout << "error: file not exist" << std::endl;
return 1;
}
if (!password.empty())
{
// encrypt file
ECMACryptFile file;
bool result = file.EncryptOfficeFile(file_path, file_path, password);
if (!result)
{
std::cout << "error: file is not encrypted" << std::endl;
return 0;
}
return 2;
}
ECMACryptFile file;
std::string docinfo = file.ReadAdditional(file_path, L"DocumentID");
if (is_print_info)
{
std::cout << docinfo << std::endl;
return 0;
}
const char* doc_info_str = docinfo.c_str();
const char* doc_info_str_end = doc_info_str + docinfo.length();
if (is_decrypt)
{
std::string encrypted_password = "";
// находим нужную запись
while (doc_info_str < doc_info_str_end)
{
const char* rec_start = doc_info_str;
// 1) ищем старт записи
while (doc_info_str < doc_info_str_end && *doc_info_str != '\n')
++doc_info_str;
if (user == std::string(rec_start, doc_info_str - rec_start))
{
rec_start = doc_info_str;
while (doc_info_str < doc_info_str_end && *doc_info_str != '\n')
++doc_info_str;
encrypted_password = std::string(rec_start, doc_info_str - rec_start);
}
// идем в конец записи
while (doc_info_str < doc_info_str_end)
{
if (*doc_info_str++ == '\n')
{
if (*doc_info_str == '\n')
{
++doc_info_str;
break;
}
}
}
}
std::string private_key_content;
NSFile::CFileBinary::ReadAllTextUtf8A(user_key_file, private_key_content);
std::string passwordA;
NSOpenSSL::RSA_DecryptPrivate_desktop((unsigned char*)private_key_content.c_str(), encrypted_password, passwordA);
std::wstring password = UTF8_TO_U(passwordA);
// encrypt file
ECMACryptFile file;
bool bDataIntegrity;
bool result = file.DecryptOfficeFile(file_path, file_path, password, bDataIntegrity);
if (!result)
{
std::cout << "error: file is not decrypted" << std::endl;
return 0;
}
return 2;
}
std::string sResult = "";
sResult.reserve(1000);
while (doc_info_str < doc_info_str_end)
{
const char* rec_start = doc_info_str;
// 1) ищем старт записи
while (doc_info_str < doc_info_str_end && *doc_info_str != '\n')
++doc_info_str;
std::string::size_type len_first = doc_info_str - rec_start;
// 2) ищем конец записи
while (doc_info_str < doc_info_str_end)
{
if (*doc_info_str++ == '\n')
{
if (*doc_info_str == '\n')
{
++doc_info_str;
break;
}
}
}
bool isAdd = true;
std::string sRec = std::string(rec_start, (doc_info_str - rec_start - 2));
// 3) проверяем запись на удаление
for (std::vector<std::string>::iterator iter = remove_records.begin(); iter != remove_records.end(); iter++)
{
if (*iter == std::string(rec_start, len_first))
{
isAdd = false;
}
else if (*iter == sRec)
{
isAdd = false;
}
}
// 4) проверяем запись на удаление
for (std::vector<std::string>::iterator iter = add_records.begin(); iter != add_records.end(); iter++)
{
if (*iter == sRec)
{
isAdd = false;
}
}
if (isAdd)
{
sResult += sRec;
sResult += "\n\n";
}
}
for (std::vector<std::string>::iterator iter = add_records.begin(); iter != add_records.end(); iter++)
{
sResult += *iter;
sResult += "\n\n";
}
bool result = file.WriteAdditional(file_path, L"DocumentID", sResult);
if (!result)
{
std::cout << "error: docinfo not writed" << std::endl;
return 3;
}
return 0;
}

View File

@ -0,0 +1,56 @@
TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt
TARGET = ooxml_crypt
CORE_ROOT_DIR = $$PWD/../..
PWD_ROOT_DIR = $$PWD
CONFIG += core_static_link_libstd
include($$CORE_ROOT_DIR/Common/base.pri)
include($$CORE_ROOT_DIR/Common/3dParty/boost/boost.pri)
LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -lCryptoPPLib
ADD_DEPENDENCY(kernel)
CONFIG += open_ssl_common
include($$CORE_ROOT_DIR/Common/3dParty/openssl/openssl.pri)
DEFINES += CRYPTOPP_DISABLE_ASM
DESTDIR = $$CORE_BUILDS_BINARY_PATH
HEADERS += \
$$PWD/../source/ECMACryptFile.h \
$$PWD/../source/CryptTransform.h \
$$PWD/../source/simple_xml_writer.h
SOURCES += \
$$PWD/../source/ECMACryptFile.cpp \
$$PWD/../source/CryptTransform.cpp
SOURCES += \
$$CORE_ROOT_DIR/Common/OfficeFileFormatChecker2.cpp \
$$CORE_ROOT_DIR/Common/3dParty/pole/pole.cpp \
$$CORE_ROOT_DIR/Common/DocxFormat/Source/Base/unicode_util.cpp
SOURCES += \
$$PWD/main.cpp
core_windows {
DEFINES -= UNICODE
DEFINES -= _DEBUG
LIBS += -lAdvapi32
LIBS += -lShell32
LIBS += -lGdi32
LIBS += -lUser32
LIBS += -lcrypt32
LIBS += -lcryptui
LIBS += -lws2_32
}
core_linux {
LIBS += -lz -pthread
QMAKE_LFLAGS += -Wl,--rpath=./
}

View File

@ -976,3 +976,56 @@ bool ECMACryptFile::DecryptOfficeFile(const std::wstring &file_name_inp, const s
return result;
}
std::string ECMACryptFile::ReadAdditional(const std::wstring &file_name, const std::wstring &addit_name)
{
POLE::Storage *pStorage = new POLE::Storage(file_name.c_str());
if (!pStorage->open(false, false))
{
delete pStorage;
return "";
}
std::string result;
POLE::Stream *pStream = new POLE::Stream(pStorage, addit_name);
if ((pStream) && (pStream->size() > 0))
{
_UINT64 lengthData, size = pStream->size();
char* data = new char[size];
lengthData = pStream->read((unsigned char*)data, size);
result = std::string(data, lengthData);
delete []data;
delete pStream;
}
delete pStorage;
return result;
}
bool ECMACryptFile::WriteAdditional(const std::wstring &file_name, const std::wstring &addit_name, const std::string &addit_info)
{
POLE::Storage *pStorage = new POLE::Storage(file_name.c_str());
if (!pStorage)return false;
if (!pStorage->open(true, false))
{
delete pStorage;
return false;
}
POLE::Stream *pStream = new POLE::Stream(pStorage, addit_name, true, addit_info.size());
pStream->write((unsigned char*)addit_info.c_str(), addit_info.size());
pStream->setSize(addit_info.size());
pStream->flush();
delete pStream;
pStorage->close();
delete pStorage;
return true;
}

View File

@ -40,6 +40,9 @@ public:
bool DecryptOfficeFile(const std::wstring &file_name_inp, const std::wstring &file_name_out, const std::wstring &password, bool & bDataIntegrity);
bool EncryptOfficeFile(const std::wstring &file_name_inp, const std::wstring &file_name_out, const std::wstring &password, const std::wstring &documentID = L"");
std::string ReadAdditional(const std::wstring &file_name, const std::wstring &addit_name);
bool WriteAdditional(const std::wstring &file_name, const std::wstring &addit_name, const std::string &addit_info);
struct _refComponent
{
int type;
@ -50,5 +53,5 @@ public:
std::vector<_refComponent> refComponents;
std::wstring dataSpaceName;
};
std::vector<_mapEntry> mapEntries;
std::vector<_mapEntry> mapEntries;
};

View File

@ -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 );

View File

@ -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);
}
}
}

View File

@ -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

View File

@ -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);

View File

@ -329,10 +329,13 @@ namespace CSVReader
}
else
{
const auto oEncodindId = std::find_if (NSUnicodeConverter::Encodings, NSUnicodeConverter::Encodings + UNICODE_CONVERTER_ENCODINGS_COUNT - 1, [nCodePage] (const NSUnicodeConverter::EncodindId& ei) { return ei.WindowsCodePage == nCodePage; });
#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);
sFileDataW = oUnicodeConverter.toUnicode((const char*)pInputBuffer, nInputBufferSize, oEncodindId.Name);
}
//------------------------------------------------------------------------------------------------------------------------------
@ -340,10 +343,13 @@ namespace CSVReader
if (nSize < 1 && nInputBufferSize > 0)
{//для синхронности вывода превью и нормального результата
const auto oEncodindId = std::find_if (NSUnicodeConverter::Encodings, NSUnicodeConverter::Encodings + UNICODE_CONVERTER_ENCODINGS_COUNT - 1, [nCodePage] (const NSUnicodeConverter::EncodindId& ei) { return ei.WindowsCodePage == nCodePage; });
#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);
sFileDataW = oUnicodeConverter.toUnicode((const char*)pInputBuffer, nInputBufferSize, oEncodindId.Name);
nSize = sFileDataW.length();
//return AVS_FILEUTILS_ERROR_CONVERT_ICU;