init repo

This commit is contained in:
nikolay ivanov
2014-07-05 18:22:49 +00:00
commit a8be6b9e72
17348 changed files with 9229832 additions and 0 deletions

View File

@@ -0,0 +1,59 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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
*
*/
#pragma once
class AVSOfficeCriticalSection
{
private:
CRITICAL_SECTION CriticalSection;
public:
AVSOfficeCriticalSection()
{
InitializeCriticalSection( &(this->CriticalSection) );
}
~AVSOfficeCriticalSection()
{
DeleteCriticalSection( &(this->CriticalSection) );
}
void Enter()
{
EnterCriticalSection( &(this->CriticalSection) );
}
void Leave()
{
LeaveCriticalSection( &(this->CriticalSection) );
}
};

View File

@@ -0,0 +1,49 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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 "stdafx.h"
#include "resource.h"
[ module(dll, uuid = "{92F87FA9-D3C2-4820-82F6-DEAEC0A3539D}",
name = "ASCOfficeUtils",
helpstring = "ASCOfficeUtils 1.0 Type Library",
resource_name = "IDR_ASCOFFICEUTILS") ]
class CAVSOfficeUtilsModule
{
public:
};
#include "OfficeUtils.h"
#include "OfficeOCR.h"

View File

@@ -0,0 +1,103 @@
//Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#include "version.h"
#define COMPONENT_NAME "OfficeUtils"
#include "../../Common/FileInfo.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "winres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
LANGUAGE 9, 1
#pragma code_page(1251)
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"#include ""winres.h""\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
#ifndef _MAC
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION INTVER
PRODUCTVERSION INTVER
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904B0"
BEGIN
VALUE "CompanyName", COMPANY_NAME
VALUE "FileDescription", FILE_DESCRIPTION_ACTIVEX
VALUE "FileVersion", STRVER
VALUE "LegalCopyright", LEGAL_COPYRIGHT
VALUE "InternalName", COMPONENT_FILE_NAME_DLL
VALUE "OriginalFilename", COMPONENT_FILE_NAME_DLL
VALUE "ProductName", FILE_DESCRIPTION_ACTIVEX
VALUE "ProductVersion", STRVER
VALUE "OLESelfRegister", ""
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x0409, 0x04B0
END
END
#endif // !_MAC
/////////////////////////////////////////////////////////////////////////////
//
// String Table
//
STRINGTABLE
BEGIN
IDS_PROJNAME "ASCOfficeUtils"
END
IDR_ASCOFFICEUTILS REGISTRY "ASCOfficeUtils.rgs"
////////////////////////////////////////////////////////////////////////////
#endif
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View File

@@ -0,0 +1,11 @@
HKCR
{
NoRemove AppID
{
'%APPID%' = s 'ASCOfficeUtils'
'ASCOfficeUtils.DLL'
{
val AppID = s '%APPID%'
}
}
}

View File

@@ -0,0 +1,688 @@
<?xml version="1.0" encoding="windows-1251"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9,00"
Name="ASCOfficeUtils"
ProjectGUID="{6215E3BF-2D42-40FB-B951-B8C448A596D2}"
RootNamespace="ASCOfficeUtils"
Keyword="AtlProj"
TargetFrameworkVersion="131072"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="Debug"
IntermediateDirectory="Debug"
ConfigurationType="2"
UseOfATL="1"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="_DEBUG"
MkTypLibCompatible="false"
TargetEnvironment="1"
GenerateStublessProxies="true"
TypeLibraryName="$(IntDir)/ASCOfficeUtils.tlb"
HeaderFileName="ASCOfficeUtils.h"
DLLDataFileName=""
InterfaceIdentifierFileName="ASCOfficeUtils_i.c"
ProxyFileName="ASCOfficeUtils_p.c"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="&quot;..\ZLIB\zlib-1.2.3\contrib\minizip&quot;;&quot;..\ZLIB\zlib-1.2.3&quot;;&quot;..\GOCR\headers&quot;;&quot;..\GOCR\include&quot;;&quot;..\PNM\headers&quot;"
PreprocessorDefinitions="WIN32;_WINDOWS;_DEBUG;_USRDLL;_ATL_ATTRIBUTES;ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="2"
WarningLevel="3"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1033"
AdditionalIncludeDirectories="$(IntDir)"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
IgnoreImportLibrary="true"
OutputFile="$(OutDir)/ASCOfficeUtils.dll"
LinkIncremental="2"
AdditionalLibraryDirectories="..\ZLIB\zlib123dll\static32"
IgnoreDefaultLibraryNames="LIBC.LIB"
MergedIDLBaseFileName="_ASCOfficeUtils.idl"
GenerateDebugInformation="true"
SubSystem="2"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
ImportLibrary="$(OutDir)/ASCOfficeUtils.lib"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
Description="Performing registration"
CommandLine="regsvr32 /s /c &quot;$(TargetPath)&quot;"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="Release"
IntermediateDirectory="Release"
ConfigurationType="2"
UseOfATL="1"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
CommandLine="..\..\..\..\Redist\VersionControl.exe $(ProjectDir)version.h"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="false"
TargetEnvironment="1"
GenerateStublessProxies="true"
TypeLibraryName="$(IntDir)/ASCOfficeUtils.tlb"
HeaderFileName="ASCOfficeUtils.h"
DLLDataFileName=""
InterfaceIdentifierFileName="ASCOfficeUtils_i.c"
ProxyFileName="ASCOfficeUtils_p.c"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="&quot;..\ZLIB\zlib-1.2.3\contrib\minizip&quot;;&quot;..\ZLIB\zlib-1.2.3&quot;;&quot;..\GOCR\headers&quot;;&quot;..\GOCR\include&quot;;&quot;..\PNM\headers&quot;"
PreprocessorDefinitions="WIN32;_WINDOWS;NDEBUG;_USRDLL;_ATL_ATTRIBUTES;ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE"
RuntimeLibrary="2"
UsePrecompiledHeader="2"
WarningLevel="3"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"
AdditionalIncludeDirectories="$(IntDir)"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
RegisterOutput="true"
IgnoreImportLibrary="true"
OutputFile="..\$(ProjectName).dll"
LinkIncremental="1"
AdditionalLibraryDirectories="..\ZLIB\zlib123dll\static32"
IgnoreDefaultLibraryNames="LIBC.LIB"
MergedIDLBaseFileName="_ASCOfficeUtils.idl"
GenerateDebugInformation="true"
ProgramDatabaseFile="$(OutDir)/$(TargetName).pdb"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
ImportLibrary="$(OutDir)/ASCOfficeUtils.lib"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
Description="Performing registration"
CommandLine="regsvr32 /s /c &quot;$(TargetPath)&quot;"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath=".\ASCOfficeUtils.cpp"
>
</File>
<File
RelativePath=".\CallbackHelpers.cpp"
>
</File>
<File
RelativePath=".\OfficeOCR.cpp"
>
</File>
<File
RelativePath=".\OfficeUtils.cpp"
>
</File>
<File
RelativePath=".\stdafx.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
/>
</FileConfiguration>
</File>
<File
RelativePath=".\UniversalString.cpp"
>
</File>
<File
RelativePath=".\ZipUtils.cpp"
>
</File>
<Filter
Name="zlib"
>
<File
RelativePath="..\ZLIB\zlib-1.2.3\adler32.c"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ZLIB\zlib-1.2.3\compress.c"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ZLIB\zlib-1.2.3\crc32.c"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ZLIB\zlib-1.2.3\deflate.c"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ZLIB\zlib-1.2.3\contrib\masmx86\gvmat32c.c"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ZLIB\zlib-1.2.3\gzio.c"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ZLIB\zlib-1.2.3\infback.c"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ZLIB\zlib-1.2.3\contrib\masmx64\inffas8664.c"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ZLIB\zlib-1.2.3\inffast.c"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ZLIB\zlib-1.2.3\inflate.c"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ZLIB\zlib-1.2.3\inftrees.c"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ZLIB\zlib-1.2.3\contrib\minizip\ioapi.c"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ZLIB\zlib-1.2.3\trees.c"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ZLIB\zlib-1.2.3\uncompr.c"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ZLIB\zlib-1.2.3\contrib\minizip\unzip.c"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ZLIB\zlib-1.2.3\contrib\minizip\zip.c"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\ZLIB\zlib-1.2.3\zutil.c"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
</Filter>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath=".\ASCOfficeCriticalSection.h"
>
</File>
<File
RelativePath=".\CallbackHelpers.h"
>
</File>
<File
RelativePath=".\CSLocker.h"
>
</File>
<File
RelativePath=".\OfficeOCR.h"
>
</File>
<File
RelativePath=".\OfficeUtils.h"
>
</File>
<File
RelativePath=".\Resource.h"
>
</File>
<File
RelativePath=".\stdafx.h"
>
</File>
<File
RelativePath=".\UniversalString.h"
>
</File>
<File
RelativePath=".\version.h"
>
</File>
<File
RelativePath=".\ZipUtils.h"
>
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
<File
RelativePath=".\ASCOfficeUtils.rc"
>
</File>
<File
RelativePath=".\ASCOfficeUtils.rgs"
>
</File>
</Filter>
<Filter
Name="Interfaces"
>
<File
RelativePath=".\IOfficeOCR.h"
>
</File>
</Filter>
<File
RelativePath=".\ReadMe.txt"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,52 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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
*
*/
#pragma once
#include "ASCOfficeCriticalSection.h"
class CSLocker
{
public:
CSLocker(AVSOfficeCriticalSection &critical_section) : cs(critical_section)
{
cs.Enter();
}
~CSLocker(void)
{
cs.Leave();
}
private:
AVSOfficeCriticalSection &cs;
};

View File

@@ -0,0 +1,64 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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 "StdAfx.h"
#include "CallbackHelpers.h"
#include "OfficeUtils.h"
ExtractedFileCallback::ExtractedFileCallback(IExtractedFileEvent* data_receiver) : invokable_object(data_receiver)
{
}
void ExtractedFileCallback::Invoke(_bstr_t file_name, SAFEARRAY** arr)
{
if(invokable_object)
{
invokable_object->ExtractedFile(file_name, arr);
}
}
RequestFileCallback::RequestFileCallback(IRequestFileEvent* data_receiver) : invokable_object(data_receiver)
{
}
bool RequestFileCallback::Invoke(BSTR* file_name, SAFEARRAY** arr)
{
if(invokable_object)
{
VARIANT_BOOL is_data_attached;
invokable_object->RequestFile(file_name, arr, &is_data_attached);
return VARIANT_TRUE == is_data_attached;
}
}

View File

@@ -0,0 +1,59 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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
*
*/
#pragma once
__interface IExtractedFileEvent;
class ExtractedFileCallback
{
public:
ExtractedFileCallback(IExtractedFileEvent* data_receiver);
void Invoke(_bstr_t file_name, SAFEARRAY** arr);
private:
IExtractedFileEvent* invokable_object;
};
__interface IRequestFileEvent;
class RequestFileCallback
{
public:
RequestFileCallback(IRequestFileEvent* data_receiver);
bool Invoke(BSTR* file_name, SAFEARRAY** arr);
private:
IRequestFileEvent* invokable_object;
};

View File

@@ -0,0 +1,62 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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
*
*/
#pragma once
[ object, uuid("804C1FF6-7020-477E-AD9F-980E9201C237"), dual, pointer_default(unique) ]
__interface IOfficeOCR : IDispatch
{
[id(1)] HRESULT Recognize([in] IUnknown *Image, [out, retval] BSTR* Text);
[id(2), propput]HRESULT OutputFormat([in] LONG Type);
[id(2), propget]HRESULT OutputFormat([ out, retval ] LONG *Type);
[id(3), propput]HRESULT GrayLevel([in] LONG Type);
[id(3), propget]HRESULT GrayLevel([ out, retval ] LONG *Type);
[id(4), propput]HRESULT DustSize([in] LONG Type);
[id(4), propget]HRESULT DustSize([ out, retval ] LONG *Type);
[id(5), propput]HRESULT SpaceWidthDots([in] LONG Type);
[id(5), propget]HRESULT SpaceWidthDots([ out, retval ] LONG *Type);
[id(6), propput]HRESULT Certainty([in] LONG Type);
[id(6), propget]HRESULT Certainty([ out, retval ] LONG *Type);
[id(100000)] HRESULT SetAdditionalParam([in] BSTR ParamName, [in] VARIANT ParamValue);
[id(100001)] HRESULT GetAdditionalParam([in] BSTR ParamName, [out, retval] VARIANT* ParamValue);
};

View File

@@ -0,0 +1,212 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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 "stdafx.h"
#include "../../Common/ASCUtils.h"
#include "../../Common/MediaFormatDefine.h"
#include "OfficeOCR.h"
#include "ImageToPNM.h"
#include "gocr.h"
COfficeOCR::COfficeOCR ()
: CAVSATLError ( __uuidof ( COfficeOCR ), __uuidof ( IOfficeOCR ) )
{
m_lOutputFormatType = OUTPUT_FORMAT_TYPE_XML;
m_lGrayLevel = 0;
m_lDustSize = -1;
m_lSpaceWidthDots = 0;
m_lCertainty = 95;
}
HRESULT COfficeOCR::FinalConstruct()
{
return S_OK;
}
void COfficeOCR::FinalRelease()
{
}
STDMETHODIMP COfficeOCR::Recognize ( IUnknown *Image, BSTR* Text )
{
#ifdef BUILD_CONFIG_FULL_VERSION
if ( NULL == Text )
return CAVSATLError::Error ( MEMORY );
*Text = NULL;
if ( NULL == Image )
return CAVSATLError::Error ( FILEFORMAT );
MediaCore::IAVSUncompressedVideoFrame *pUncompressedVideoFrame = NULL; Image->QueryInterface ( &pUncompressedVideoFrame );
if ( NULL == pUncompressedVideoFrame )
return CAVSATLError::Error ( FILEFORMAT );
LPBYTE pBuffer = NULL; pUncompressedVideoFrame->get_Buffer ( &pBuffer );
LONG lWidth = 0; pUncompressedVideoFrame->get_Width ( &lWidth );
LONG lHeight = 0; pUncompressedVideoFrame->get_Height ( &lHeight );
LONG lColorSpace = 0; pUncompressedVideoFrame->get_ColorSpace ( &lColorSpace );
LONG lBitCount = 0;
if ( ( CSP_BGRA & CSP_COLOR_MASK ) == lColorSpace || ( ( CSP_BGRA | CSP_VFLIP ) & CSP_COLOR_MASK ) == lColorSpace ||
( CSP_ABGR & CSP_COLOR_MASK ) == lColorSpace || ( ( CSP_ABGR | CSP_VFLIP ) & CSP_COLOR_MASK ) == lColorSpace ||
( CSP_RGBA & CSP_COLOR_MASK ) == lColorSpace || ( ( CSP_RGBA | CSP_VFLIP ) & CSP_COLOR_MASK ) == lColorSpace ||
( CSP_ARGB & CSP_COLOR_MASK ) == lColorSpace || ( ( CSP_ARGB | CSP_VFLIP ) & CSP_COLOR_MASK ) == lColorSpace )
lBitCount = 32;
else if ( ( CSP_BGR & CSP_COLOR_MASK ) == lColorSpace || ( ( CSP_BGR | CSP_VFLIP ) & CSP_COLOR_MASK ) == lColorSpace )
lBitCount = 24;
else if ( ( CSP_RGB555 & CSP_COLOR_MASK ) == lColorSpace || ( ( CSP_RGB555 | CSP_VFLIP ) & CSP_COLOR_MASK ) == lColorSpace ||
( CSP_RGB565 & CSP_COLOR_MASK ) == lColorSpace || ( ( CSP_RGB565 | CSP_VFLIP ) & CSP_COLOR_MASK ) == lColorSpace )
lBitCount = 16;
else
lBitCount = 32;
long lCount = 0;
CHAR *pPBMImage = convertToPNM ( pBuffer, lWidth, lHeight, lBitCount, true, true, lCount );
CStringA sOutputFormat = "";
switch ( m_lOutputFormatType )
{
case OUTPUT_FORMAT_TYPE_XML :
sOutputFormat = "XML";
break;
case OUTPUT_FORMAT_TYPE_TEXT :
sOutputFormat = "UTF8";
break;
}
CHAR *pText = PNMToText (pPBMImage, lCount, sOutputFormat.GetBuffer(), m_lGrayLevel, m_lDustSize, m_lSpaceWidthDots, m_lCertainty);
free ( pPBMImage );
RELEASEINTERFACE ( pUncompressedVideoFrame );
CString sText ( pText );
free ( pText );
CString sResult = _T("");
if ( OUTPUT_FORMAT_TYPE_XML == m_lOutputFormatType )
{
sResult += _T("<?xml version=\"1.0\" encoding=\"utf-8\" ?>");
sResult += _T ("<Text>");
}
sResult += sText;
if ( OUTPUT_FORMAT_TYPE_XML == m_lOutputFormatType )
sResult += _T ("</Text>");
*Text = sResult.AllocSysString();
#endif
return S_OK;
}
STDMETHODIMP COfficeOCR::put_OutputFormat ( LONG Type )
{
if ( 0 <= Type && 2 >Type )
m_lOutputFormatType = Type;
return S_OK;
}
STDMETHODIMP COfficeOCR::get_OutputFormat ( LONG *Type )
{
*Type = m_lOutputFormatType;
return S_OK;
}
STDMETHODIMP COfficeOCR::put_GrayLevel ( LONG Type )
{
m_lGrayLevel = Type;
if ( 0 > m_lGrayLevel )
m_lGrayLevel = 0;
if ( 255 < m_lGrayLevel )
m_lGrayLevel = 255;
return S_OK;
}
STDMETHODIMP COfficeOCR::get_GrayLevel ( LONG *Type )
{
*Type = m_lDustSize;
return S_OK;
}
STDMETHODIMP COfficeOCR::put_DustSize ( LONG Type )
{
m_lDustSize = Type;
return S_OK;
}
STDMETHODIMP COfficeOCR::get_DustSize ( LONG *Type )
{
*Type = m_lGrayLevel;
return S_OK;
}
STDMETHODIMP COfficeOCR::put_SpaceWidthDots ( LONG Type )
{
m_lSpaceWidthDots = Type;
if ( 0 > m_lSpaceWidthDots )
m_lSpaceWidthDots = 0;
return S_OK;
}
STDMETHODIMP COfficeOCR::get_SpaceWidthDots ( LONG *Type )
{
*Type = m_lSpaceWidthDots;
return S_OK;
}
STDMETHODIMP COfficeOCR::put_Certainty ( LONG Type )
{
m_lCertainty = Type;
if ( 0 > m_lCertainty )
m_lSpaceWidthDots = 0;
if ( 100 < m_lCertainty )
m_lCertainty = 100;
return S_OK;
}
STDMETHODIMP COfficeOCR::get_Certainty ( LONG *Type )
{
*Type = m_lCertainty;
return S_OK;
}
STDMETHODIMP COfficeOCR::SetAdditionalParam ( BSTR ParamName, VARIANT ParamValue )
{
return S_OK;
}
STDMETHODIMP COfficeOCR::GetAdditionalParam ( BSTR ParamName, VARIANT *ParamValue )
{
return S_OK;
}

View File

@@ -0,0 +1,81 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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
*
*/
#pragma once
#include "resource.h"
#include "IOfficeOCR.h"
#include "../../Common/ASCATLError.h"
#define OUTPUT_FORMAT_TYPE_XML 0
#define OUTPUT_FORMAT_TYPE_TEXT 1
[ coclass, uuid("5E4BC6BB-26B4-4237-894E-2C872842A8EE"), threading(apartment), vi_progid("AVSOfficeUtils.OfficeOCR"), progid("AVSOfficeUtils.OfficeOCR.1"), version(1.0), support_error_info(IOfficeOCR) ]
class ATL_NO_VTABLE COfficeOCR : public IOfficeOCR, public CAVSATLError
{
public :
COfficeOCR();
DECLARE_PROTECT_FINAL_CONSTRUCT()
HRESULT FinalConstruct();
void FinalRelease();
public :
STDMETHOD ( Recognize )( IUnknown *Image, BSTR* Text );
STDMETHOD ( put_OutputFormat )( LONG Type );
STDMETHOD ( get_OutputFormat )( LONG *Type );
STDMETHOD ( put_GrayLevel )( LONG Type );
STDMETHOD ( get_GrayLevel )( LONG *Type );
STDMETHOD ( put_DustSize )( LONG Type );
STDMETHOD ( get_DustSize )( LONG *Type );
STDMETHOD ( put_SpaceWidthDots )( LONG Type );
STDMETHOD ( get_SpaceWidthDots )( LONG *Type );
STDMETHOD ( put_Certainty )( LONG Type );
STDMETHOD ( get_Certainty )( LONG *Type );
STDMETHOD ( SetAdditionalParam )( BSTR ParamName, VARIANT ParamValue );
STDMETHOD ( GetAdditionalParam )( BSTR ParamName, VARIANT *ParamValue );
private :
LONG m_lOutputFormatType;
LONG m_lGrayLevel;
LONG m_lDustSize;
LONG m_lSpaceWidthDots;
LONG m_lCertainty;
};

View File

@@ -0,0 +1,196 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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 "stdafx.h"
#include "OfficeUtils.h"
STDMETHODIMP COfficeUtils::ExtractToDirectory(BSTR zipFile, BSTR unzipDir, BSTR password, SHORT extract_without_path)
{
ProgressCallback progress;
progress.OnProgress = OnProgressFunc;
progress.caller = this;
if( ZLibZipUtils::UnzipToDir( zipFile, unzipDir, &progress, password, ( extract_without_path > 0 ) ? (true) : (false) ) == 0 )
{
return S_OK;
}
else
{
return S_FALSE;
}
}
STDMETHODIMP COfficeUtils::CompressFileOrDirectory(BSTR name, BSTR outputFile, SHORT level)
{
WIN32_FIND_DATA ffd;
HANDLE hFind = INVALID_HANDLE_VALUE;
HRESULT result = S_FALSE;
hFind = FindFirstFile( name, &ffd );
if ( hFind == INVALID_HANDLE_VALUE )
{
return result;
}
if ( ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )
{
ProgressCallback progress;
progress.OnProgress = OnProgressFunc;
progress.caller = this;
if ( ZLibZipUtils::ZipDir( name, outputFile, &progress, level ) == 0 )
{
result = S_OK;
}
else
{
result = S_FALSE;
}
}
else
{
if ( ZLibZipUtils::ZipFile( name, outputFile, level ) == 0 )
{
result = S_OK;
}
else
{
result = S_FALSE;
}
}
FindClose( hFind );
return result;
}
STDMETHODIMP COfficeUtils::Uncompress(BYTE* destBuf, ULONG* destSize, BYTE* sourceBuf, ULONG sourceSize)
{
if ( ZLibZipUtils::UncompressBytes( destBuf, destSize, sourceBuf, sourceSize ) == Z_OK )
{
return S_OK;
}
else
{
return S_FALSE;
}
}
STDMETHODIMP COfficeUtils::Compress(BYTE* destBuf, ULONG* destSize, BYTE* sourceBuf, ULONG sourceSize, SHORT level)
{
if ( ZLibZipUtils::CompressBytes( destBuf, destSize, sourceBuf, sourceSize, level ) == Z_OK )
{
return S_OK;
}
else
{
return S_FALSE;
}
}
STDMETHODIMP COfficeUtils::IsArchive(BSTR filename)
{
if( ZLibZipUtils::IsArchive(filename) )
{
return S_OK;
}
else
{
return S_FALSE;
}
}
STDMETHODIMP COfficeUtils::IsFileExistInArchive(BSTR zipFile, BSTR filePath)
{
if( ZLibZipUtils::IsFileExistInArchive( zipFile, filePath) )
{
return S_OK;
}
else
{
return S_FALSE;
}
}
STDMETHODIMP COfficeUtils::LoadFileFromArchive(BSTR zipFile, BSTR filePath, BYTE** fileInBytes)
{
if( ZLibZipUtils::LoadFileFromArchive( zipFile, filePath, fileInBytes))
{
return S_OK;
}
else
{
return S_FALSE;
}
}
STDMETHODIMP COfficeUtils::ExtractFilesToMemory(BSTR zipFile, IExtractedFileEvent* data_receiver, VARIANT_BOOL* result)
{
*result = ZLibZipUtils::ExtractFiles(_bstr_t(zipFile), ExtractedFileCallback (data_receiver)) ? VARIANT_TRUE : VARIANT_FALSE;
return S_OK;
}
STDMETHODIMP COfficeUtils::CompressFilesFromMemory(BSTR zipFile, IRequestFileEvent* data_source, SHORT compression_level, VARIANT_BOOL* result)
{
*result = ZLibZipUtils::CompressFiles(_bstr_t(zipFile), RequestFileCallback (data_source), compression_level) ? VARIANT_TRUE : VARIANT_FALSE;
return S_OK;
}
void COfficeUtils::OnProgressFunc( LPVOID lpParam, long nID, long nPercent, short* Cancel )
{
COfficeUtils* pOfficeUtils = reinterpret_cast<COfficeUtils*>( lpParam );
if ( pOfficeUtils != NULL )
{
pOfficeUtils->OnProgress( nID, nPercent, Cancel );
}
}

View File

@@ -0,0 +1,163 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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
*
*/
#pragma once
#include "resource.h"
#include "ZipUtils.h"
#if defined(_WIN32_WCE) && !defined(_CE_DCOM) && !defined(_CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA)
#error "Single-threaded COM objects are not properly supported on Windows CE platform, such as the Windows Mobile platforms that do not include full DCOM support. Define _CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA to force ATL to support creating single-thread COM object's and allow use of it's single-threaded COM object implementations. The threading model in your rgs file was set to 'Free' as that is the only threading model supported in non DCOM Windows CE platforms."
#endif
[
object,
uuid("D1E2A35D-AD68-4E0E-9FF2-859155151328"),
dual, helpstring("IOfficeUtils Interface"),
pointer_default(unique)
]
__interface IOfficeUtils : IDispatch
{
[id(1), helpstring("method ExtractToDirectory")] HRESULT ExtractToDirectory([in] BSTR zipFile, [in] BSTR unzipDir, [in] BSTR password, [in] SHORT extract_without_path);
[id(2), helpstring("method CompressFileOrDirectory")] HRESULT CompressFileOrDirectory([in] BSTR name, [in] BSTR outputFile, [in] SHORT level);
[id(3), helpstring("method Uncompress")] HRESULT Uncompress([out] BYTE* destBuf, [in,out] ULONG* destSize, [in] BYTE* sourceBuf, [in] ULONG sourceSize);
[id(4), helpstring("method Compress")] HRESULT Compress([out] BYTE* destBuf, [in,out] ULONG* destSize, [in] BYTE* sourceBuf, [in] ULONG sourceSize, [in] SHORT level);
};
[
object,
uuid("6BA9C2ED-263A-456d-882F-646DA4CE1FEA"),
dual, helpstring("IExtractedFileEvent Interface"),
pointer_default(unique)
]
__interface IExtractedFileEvent : IDispatch
{
[id(9), helpstring("method ExtractedFile")] HRESULT ExtractedFile([in] BSTR file_name, [in, satype("unsigned char")] SAFEARRAY** arr);
};
[
object,
uuid("6013A180-406F-48fc-94BD-B0AC8B72CC0E"),
dual, helpstring("IRequestFileEvent Interface"),
pointer_default(unique)
]
__interface IRequestFileEvent : IDispatch
{
[id(11), helpstring("method RequestFile")] HRESULT RequestFile([out] BSTR* file_name, [out, satype("unsigned char")] SAFEARRAY** arr, [out, retval] VARIANT_BOOL* is_data_attached);
};
[
object,
uuid("F9C00AE2-7B59-4210-B348-5E34B8F495D7"),
dual, helpstring("IOfficeUtils2 Interface"),
pointer_default(unique)
]
__interface IOfficeUtils2 : IOfficeUtils
{
[id(5), helpstring("method IsArchive")] HRESULT IsArchive([in] BSTR filename);
[id(6), helpstring("method IsFileExistInArchive")] HRESULT IsFileExistInArchive([in] BSTR zipFile, [in] BSTR filePath);
[id(7), helpstring("method LoadFileFromArchive")] HRESULT LoadFileFromArchive([in] BSTR zipFile, [in] BSTR filePath, [out] BYTE** fileInBytes);
[id(8), helpstring("method ExtractFilesToMemory")] HRESULT ExtractFilesToMemory([in] BSTR zipFile, [in] IExtractedFileEvent* data_receiver, [out, retval] VARIANT_BOOL* result);
[id(10), helpstring("method CompressFilesFromMemory")] HRESULT CompressFilesFromMemory([in] BSTR zipFile, [in] IRequestFileEvent* data_source, [in] SHORT compression_level, [out, retval] VARIANT_BOOL* result);
};
[
dispinterface,
uuid("FB7DE28F-2E10-4dc8-813E-943701B9FB81"),
helpstring("_IAVSOfficeUtilsEvents Interface")
]
__interface _IAVSOfficeUtilsEvents
{
[id(1), helpstring("method OnProgress")] HRESULT OnProgress([in] LONG nID, [in] LONG nPercent, [in, out, ref] SHORT* Cancel);
};
[
coclass,
default(IOfficeUtils, _IAVSOfficeUtilsEvents),
threading(apartment),
event_source(com),
vi_progid("AVSOfficeUtils.OfficeUtils"),
progid("AVSOfficeUtils.OfficeUtils.1"),
version(1.0),
uuid("27AC89C1-0995-46FA-90A5-01EE850A09AC"),
helpstring("OfficeUtils Class")
]
class ATL_NO_VTABLE COfficeUtils :
public IOfficeUtils2
{
public:
COfficeUtils()
{
}
__event __interface _IAVSOfficeUtilsEvents;
DECLARE_PROTECT_FINAL_CONSTRUCT()
HRESULT FinalConstruct()
{
return S_OK;
}
void FinalRelease()
{
}
public:
STDMETHOD(ExtractToDirectory)(BSTR zipFile, BSTR unzipDir, BSTR password, SHORT extract_without_path);
STDMETHOD(CompressFileOrDirectory)(BSTR name, BSTR outputFile, SHORT level);
STDMETHOD(Uncompress)(BYTE* destBuf, ULONG* destSize, BYTE* sourceBuf, ULONG sourceSize);
STDMETHOD(Compress)(BYTE* destBuf, ULONG* destSize, BYTE* sourceBuf, ULONG sourceSize, SHORT level);
STDMETHOD(IsArchive)(BSTR filename);
STDMETHOD(IsFileExistInArchive)(BSTR zipFile, BSTR filePath);
STDMETHOD(LoadFileFromArchive)(BSTR zipFile, BSTR filePath, BYTE** fileInBytes);
STDMETHOD(ExtractFilesToMemory)(BSTR zipFile, IExtractedFileEvent* data_receiver, VARIANT_BOOL* result);
STDMETHOD(CompressFilesFromMemory)(BSTR zipFile, IRequestFileEvent* data_source, SHORT compression_level, VARIANT_BOOL* result);
protected:
static void OnProgressFunc( LPVOID lpParam, long nID, long nPercent, short* Cancel );
};

View File

@@ -0,0 +1,68 @@
========================================================================
ACTIVE TEMPLATE LIBRARY : AVSOfficeUtils Project Overview
========================================================================
AppWizard has created this AVSOfficeUtils project for you to use as the starting point for
writing your Dynamic Link Library (DLL).
This project is implemented with Visual C++ attributes.
This file contains a summary of what you will find in each of the files that
make up your project.
AVSOfficeUtils.vcproj
This is the main project file for VC++ projects generated using an Application Wizard.
It contains information about the version of Visual C++ that generated the file, and
information about the platforms, configurations, and project features selected with the
Application Wizard.
_AVSOfficeUtils.idl
This file will be generated by the compiler when the project is built. It will contain the IDL
definitions of the type library, the interfaces and co-classes defined in your project.
This file will be processed by the MIDL compiler to generate:
C++ interface definitions and GUID declarations (_AVSOfficeUtils.h)
GUID definitions (_AVSOfficeUtils_i.c)
A type library (_AVSOfficeUtils.tlb)
Marshaling code (_AVSOfficeUtils_p.c and dlldata.c)
AVSOfficeUtils.cpp
This file contains the object map and the implementation of your DLL's exports.
AVSOfficeUtils.rc
This is a listing of all of the Microsoft Windows resources that the
program uses.
AVSOfficeUtils.def
This module-definition file provides the linker with information about the exports
required by your DLL. It contains exports for:
DllGetClassObject
DllCanUnloadNow
GetProxyDllInfo
DllRegisterServer
DllUnregisterServer
/////////////////////////////////////////////////////////////////////////////
Other standard files:
StdAfx.h, StdAfx.cpp
These files are used to build a precompiled header (PCH) file
named AVSOfficeUtils.pch and a precompiled types file named StdAfx.obj.
Resource.h
This is the standard header file that defines resource IDs.
/////////////////////////////////////////////////////////////////////////////
Proxy/stub DLL project and module definition file:
AVSOfficeUtilsps.vcproj
This file is the project file for building a proxy/stub DLL if necessary.
The IDL file in the main project must contain at least one interface and you must
first compile the IDL file before building the proxy/stub DLL. This process generates
dlldata.c, AVSOfficeUtils_i.c and AVSOfficeUtils_p.c which are required
to build the proxy/stub DLL.
AVSOfficeUtilsps.def
This module definition file provides the linker with information about the exports
required by the proxy/stub.
/////////////////////////////////////////////////////////////////////////////

View File

@@ -0,0 +1,18 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by AVSOfficeUtils.rc
//
#define IDS_PROJNAME 100
#define IDR_ASCOFFICEUTILS 101
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 201
#define _APS_NEXT_COMMAND_VALUE 32768
#define _APS_NEXT_CONTROL_VALUE 201
#define _APS_NEXT_SYMED_VALUE 102
#endif
#endif

View File

@@ -0,0 +1,222 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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 "stdafx.h"
#include "UniversalString.h"
void UniversalString::ClearUniversalString()
{
this->length = 0;
this->charSize = 0;
this->wcharSize = 0;
if ( this->str != NULL )
{
delete [](this->str);
this->str = NULL;
}
if ( this->wstr != NULL )
{
delete [](this->wstr);
this->wstr = NULL;
}
}
UniversalString::UniversalString():
str(NULL), wstr(NULL), length(0), charSize(1), wcharSize(1)
{
this->str = new char[this->charSize];
this->str[0] = '\0';
this->wstr = new wchar_t[this->wcharSize];
this->wstr[0] = '\0';
}
UniversalString::UniversalString( const UniversalString& _ustr ):
str(NULL), wstr(NULL), length(_ustr.length), charSize(_ustr.charSize), wcharSize(_ustr.wcharSize)
{
if ( ( this->charSize > 0 ) && ( this->wcharSize > 0 ) )
{
this->str = new char[this->charSize];
this->wstr = new wchar_t[this->wcharSize];
if ( ( this->str != NULL ) && ( this->wstr != NULL ) )
{
memset( this->str, 0, ( sizeof(char) * this->charSize ) );
memset( this->wstr, 0, ( sizeof(wchar_t) * this->wcharSize ) );
memcpy( this->str, _ustr.str, ( sizeof(char) * this->charSize ) );
memcpy( this->wstr, _ustr.wstr, ( sizeof(wchar_t) * this->wcharSize ) );
}
}
}
UniversalString::UniversalString( const char* _str, unsigned int CodePage ):
str(NULL), wstr(NULL), length(0), charSize(0), wcharSize(0)
{
if ( _str != NULL )
{
this->length = (unsigned int)strlen( _str );
this->charSize = ( this->length + 1 );
this->str = new char[this->charSize];
if ( this->str != NULL )
{
memset( this->str, 0, ( sizeof(char) * this->charSize ) );
memcpy( this->str, _str, ( sizeof(char) * this->charSize ) );
this->wcharSize = MultiByteToWideChar( CodePage, 0, this->str, -1, NULL, 0 );
this->wstr = new wchar_t[this->wcharSize];
if ( this->wstr != NULL )
{
memset( this->wstr, 0, ( sizeof(wchar_t) * this->wcharSize ) );
MultiByteToWideChar( CodePage, 0, this->str, -1, this->wstr, this->wcharSize );
}
}
}
}
UniversalString::UniversalString( const wchar_t* _wstr, unsigned int CodePage ):
str(NULL), wstr(NULL), length(0), charSize(0), wcharSize(0)
{
if ( _wstr != NULL )
{
this->length = (unsigned int)wcslen( _wstr );
this->wcharSize = ( this->length + 1 );
this->wstr = new wchar_t[this->wcharSize];
if ( this->wstr != NULL )
{
memset( this->wstr, 0, ( sizeof(wchar_t) * this->wcharSize ) );
memcpy( this->wstr, _wstr, ( sizeof(wchar_t) * this->wcharSize ) );
this->charSize = WideCharToMultiByte( CodePage, 0, this->wstr, -1, NULL, 0, NULL, NULL );
this->str = new char[this->charSize];
if ( this->str != NULL )
{
memset( this->str, 0, ( sizeof(char) * this->charSize ) );
WideCharToMultiByte( CodePage, 0, this->wstr, -1, this->str, this->charSize, NULL, NULL );
}
}
}
}
UniversalString::~UniversalString()
{
this->ClearUniversalString();
}
UniversalString::operator char* ()
{
return this->str;
}
UniversalString::operator wchar_t* ()
{
return this->wstr;
}
bool UniversalString::operator == ( const UniversalString& _ustr )
{
if ( ( this->length == _ustr.length ) && ( this->charSize == _ustr.charSize ) && ( this->wcharSize == _ustr.wcharSize ) &&
( strncmp( this->str, _ustr.str, _ustr.charSize ) == 0 ) && ( wcsncmp( this->wstr, _ustr.wstr, _ustr.wcharSize ) == 0 ) )
{
return true;
}
else
{
return false;
}
}
bool UniversalString::operator != ( const UniversalString& _ustr )
{
return !(this->operator == ( _ustr ));
}
UniversalString& UniversalString::operator = ( const UniversalString& _ustr )
{
if ( this != &_ustr )
{
this->ClearUniversalString();
this->length = _ustr.length;
this->charSize = _ustr.charSize;
this->wcharSize = _ustr.wcharSize;
if ( ( this->charSize > 0 ) && ( this->wcharSize > 0 ) )
{
this->str = new char[this->charSize];
this->wstr = new wchar_t[this->wcharSize];
if ( ( this->str != NULL ) && ( this->wstr != NULL ) )
{
memset( this->str, 0, ( sizeof(char) * this->charSize ) );
memset( this->wstr, 0, ( sizeof(wchar_t) * this->wcharSize ) );
memcpy( this->str, _ustr.str, ( sizeof(char) * this->charSize ) );
memcpy( this->wstr, _ustr.wstr, ( sizeof(wchar_t) * this->wcharSize ) );
}
}
}
return *this;
}
unsigned int UniversalString::GetLength() const
{
return this->length;
}

View File

@@ -0,0 +1,60 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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
*
*/
#pragma once
#include <string.h>
#include <stdlib.h>
class UniversalString
{
private:
char *str;
wchar_t *wstr;
unsigned int length;
unsigned int charSize;
unsigned int wcharSize;
void ClearUniversalString();
public:
UniversalString();
UniversalString( const UniversalString& _ustr );
UniversalString( const char* _str, unsigned int CodePage = CP_ACP);
UniversalString( const wchar_t* _wstr, unsigned int CodePage = CP_ACP);
~UniversalString();
operator char* ();
operator wchar_t* ();
bool operator == ( const UniversalString& _ustr );
bool operator != ( const UniversalString& _ustr );
UniversalString& operator = ( const UniversalString& _ustr );
unsigned int GetLength() const;
};

View File

@@ -0,0 +1,996 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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 "stdafx.h"
#include "ZipUtils.h"
#include <memory>
#include "atlsafe.h"
#define WRITEBUFFERSIZE 8192
#define READBUFFERSIZE 8192
namespace ZLibZipUtils
{
AVSOfficeCriticalSection criticalSection;
static void change_file_date( const char *filename, uLong dosdate, tm_unz tmu_date );
static int mymkdir( const char* dirname );
static int makedir( const char *newdir );
static int do_extract_currentfile( unzFile uf, const int* popt_extract_without_path, int* popt_overwrite, const char* password );
static int do_extract( unzFile uf, int opt_extract_without_path, int opt_overwrite, const char* password, const ProgressCallback* progress );
static bool is_file_in_archive(unzFile uf, const wchar_t *filename);
static bool current_file_is_find(unzFile uf, const wchar_t *filename);
static bool get_file_in_archive(unzFile uf, const wchar_t *filePathInZip, BYTE** fileInBytes );
static bool get_file(unzFile uf, BYTE** fileInBytes );
static unsigned int get_files_count( const WCHAR* dirname );
static void change_file_date( const char *filename, uLong dosdate, tm_unz tmu_date )
{
HANDLE hFile;
FILETIME ftm,ftLocal,ftCreate,ftLastAcc,ftLastWrite;
hFile = CreateFileA(filename,GENERIC_READ | GENERIC_WRITE,
0,NULL,OPEN_EXISTING,0,NULL);
GetFileTime(hFile,&ftCreate,&ftLastAcc,&ftLastWrite);
DosDateTimeToFileTime((WORD)(dosdate>>16),(WORD)dosdate,&ftLocal);
LocalFileTimeToFileTime(&ftLocal,&ftm);
SetFileTime(hFile,&ftm,&ftLastAcc,&ftm);
CloseHandle(hFile);
}
static int mymkdir( const char* dirname )
{
int ret=0;
ret = _mkdir(dirname);
return ret;
}
static int makedir( const char *newdir )
{
char *buffer ;
char *p;
int len = (int)strlen(newdir);
if (len <= 0)
return 0;
buffer = (char*)malloc(len+1);
strcpy_s(buffer, (len+1), newdir);
if (buffer[len-1] == '/') {
buffer[len-1] = '\0';
}
if (mymkdir(buffer) == 0)
{
free(buffer);
return 1;
}
p = buffer+1;
while (1)
{
char hold;
while(*p && *p != '\\' && *p != '/')
p++;
hold = *p;
*p = 0;
if ((mymkdir(buffer) == -1) && (errno == ENOENT))
{
free(buffer);
return 0;
}
if (hold == 0)
break;
*p++ = hold;
}
free(buffer);
return 1;
}
static int do_extract_currentfile( unzFile uf, const int* popt_extract_without_path, int* popt_overwrite, const char* password )
{
char filename_inzip[256];
char* filename_withoutpath;
char* p;
int err=UNZ_OK;
FILE *fout=NULL;
void* buf;
uInt size_buf;
unz_file_info file_info;
uLong ratio=0;
err = unzGetCurrentFileInfo(uf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0);
#ifdef CODEPAGE_ISSUE_FIX
{
UniversalString us( filename_inzip, CP_OEMCP );
us = UniversalString( (wchar_t*)us );
memset( filename_inzip, 0, ( 256 * sizeof(char) ) );
strcpy_s( filename_inzip, 256, (char*)us );
}
#endif
if (err!=UNZ_OK)
{
return err;
}
size_buf = WRITEBUFFERSIZE;
buf = (void*)malloc(size_buf);
if (buf==NULL)
{
return UNZ_INTERNALERROR;
}
p = filename_withoutpath = filename_inzip;
while ((*p) != '\0')
{
if (((*p)=='/') || ((*p)=='\\'))
filename_withoutpath = p+1;
p++;
}
if ((*filename_withoutpath)=='\0')
{
if ((*popt_extract_without_path)==0)
{
mymkdir(filename_inzip);
}
}
else
{
const char* write_filename;
int skip=0;
if ((*popt_extract_without_path)==0)
write_filename = filename_inzip;
else
write_filename = filename_withoutpath;
err = unzOpenCurrentFilePassword(uf,password);
if (((*popt_overwrite)==0) && (err==UNZ_OK))
{
char rep=0;
FILE* ftestexist = NULL;
fopen_s(&ftestexist, write_filename, "rb");
if (ftestexist!=NULL)
{
fclose(ftestexist);
}
if (rep == 'N')
skip = 1;
if (rep == 'A')
*popt_overwrite=1;
}
if ((skip==0) && (err==UNZ_OK))
{
fopen_s(&fout, write_filename, "wb");
if ((fout==NULL) && ((*popt_extract_without_path)==0) &&
(filename_withoutpath!=(char*)filename_inzip))
{
char c=*(filename_withoutpath-1);
*(filename_withoutpath-1)='\0';
makedir(write_filename);
*(filename_withoutpath-1)=c;
fopen_s(&fout, write_filename, "wb");
}
}
if (fout!=NULL)
{
do
{
err = unzReadCurrentFile(uf, buf, size_buf);
if (err<0)
{
break;
}
if (err>0)
if (fwrite(buf,err,1,fout)!=1)
{
err=UNZ_ERRNO;
break;
}
}
while (err>0);
if (fout)
fclose(fout);
if (err==0)
change_file_date(write_filename,file_info.dosDate,
file_info.tmu_date);
}
if (err==UNZ_OK)
{
err = unzCloseCurrentFile (uf);
}
else
unzCloseCurrentFile(uf);
}
free(buf);
return err;
}
static int do_extract( unzFile uf, int opt_extract_without_path, int opt_overwrite, const char* password, const ProgressCallback* progress )
{
uLong i;
unz_global_info gi;
int err;
FILE* fout=NULL;
err = unzGetGlobalInfo (uf,&gi);
for (i=0;i<gi.number_entry;i++)
{
if (do_extract_currentfile(uf,&opt_extract_without_path,
&opt_overwrite,
password) != UNZ_OK)
break;
if ( progress != NULL )
{
short cancel = 0;
long progressValue = ( 1000000 / gi.number_entry * i );
progress->OnProgress( progress->caller, UTILS_ONPROGRESSEVENT_ID, progressValue, &cancel );
if ( cancel != 0 )
{
return err;
}
}
if ((i+1)<gi.number_entry)
{
err = unzGoToNextFile(uf);
if (err!=UNZ_OK)
{
break;
}
}
}
if ( progress != NULL )
{
short cancel = 0;
long progressValue = 1000000;
progress->OnProgress( progress->caller, UTILS_ONPROGRESSEVENT_ID, progressValue, &cancel );
}
return 0;
}
static bool is_file_in_archive(unzFile uf, const wchar_t *filename)
{
uLong i;
unz_global_info gi;
int err;
err = unzGetGlobalInfo (uf,&gi);
for (i = 0; i < gi.number_entry; i++)
{
if (current_file_is_find(uf, filename) == true)
return true;
if ((i + 1) < gi.number_entry)
{
err = unzGoToNextFile(uf);
if (err != UNZ_OK)
break;
}
}
return false;
}
static bool current_file_is_find(unzFile uf, const wchar_t *filename)
{
char filename_inzip[256];
int err = UNZ_OK;
unz_file_info file_info;
err = unzGetCurrentFileInfo(uf, &file_info, filename_inzip, sizeof(filename_inzip), NULL, 0, NULL, 0);
UniversalString us( filename_inzip, CP_OEMCP );
us = UniversalString( (wchar_t*)us );
UniversalString findFile( filename, CP_OEMCP );
if (us == findFile)
return true;
return false;
}
static const _bstr_t get_filename_from_unzfile(unzFile unzip_file_handle)
{
static char filename_OEM[MAX_PATH];
static wchar_t filename_ANSI[MAX_PATH];
if (UNZ_OK == unzGetCurrentFileInfo(unzip_file_handle, NULL, filename_OEM, sizeof(filename_OEM), NULL, 0, NULL, 0))
{
OemToChar(filename_OEM, filename_ANSI);
return _bstr_t(filename_ANSI);
}
return _bstr_t(L"");
}
static bool get_file_in_archive(unzFile uf, const wchar_t *filePathInZip, BYTE** fileInBytes)
{
unz_global_info gi;
int err;
err = unzGetGlobalInfo (uf,&gi);
for (uLong i = 0; i < gi.number_entry; i++)
{
if (current_file_is_find(uf, filePathInZip) == true)
{
get_file(uf, fileInBytes);
return true;
}
if ((i + 1) < gi.number_entry)
{
err = unzGoToNextFile(uf);
if (err != UNZ_OK)
break;
}
}
return false;
}
static bool get_file(unzFile uf, BYTE** fileInBytes)
{
int err = UNZ_OK;
uInt size_buf = WRITEBUFFERSIZE;
bool flag = false;
void* buf;
buf = (void*)malloc(size_buf);
err = unzOpenCurrentFilePassword(uf, NULL);
err = unzReadCurrentFile(uf, buf, size_buf);
if (err > 0)
{
*fileInBytes = (BYTE*)::HeapAlloc(GetProcessHeap(), NULL, err);
memcpy(*fileInBytes, static_cast<BYTE*>(buf), err);
flag = true;
}
if (err == UNZ_OK)
err = unzCloseCurrentFile (uf);
else
unzCloseCurrentFile(uf);
free(buf);
return flag;
}
static bool get_file(unzFile unzip_file_handle, SAFEARRAY* arr, uInt array_size)
{
if(UNZ_OK == unzOpenCurrentFile(unzip_file_handle))
{
int data_read_size = unzReadCurrentFile(unzip_file_handle, arr->pvData, array_size);
unzCloseCurrentFile(unzip_file_handle);
return data_read_size == array_size ? true : false;
}
return false;
}
int ZipDir( const WCHAR* dir, const WCHAR* outputFile, const ProgressCallback* progress, int compressionLevel )
{
criticalSection.Enter();
int err = -1;
if ( ( dir != NULL ) && ( outputFile != NULL ) )
{
WIN32_FIND_DATA ffd;
HANDLE hFind = INVALID_HANDLE_VALUE;
BOOL bNextFile = FALSE;
deque<wstring> StringDeque;
deque<wstring> zipDeque;
StringDeque.push_back( wstring( dir ) );
wstring zipDir;
wstring file;
wstring zipFileName;
wstring szText;
wstring szCurText;
zipFile zf = zipOpen( UniversalString( outputFile ), APPEND_STATUS_CREATE );
zip_fileinfo zi;
zi.tmz_date.tm_sec = zi.tmz_date.tm_min = zi.tmz_date.tm_hour =
zi.tmz_date.tm_mday = zi.tmz_date.tm_mon = zi.tmz_date.tm_year = 0;
zi.dosDate = 0;
zi.internal_fa = 0;
zi.external_fa = 0;
SYSTEMTIME currTime;
GetLocalTime( &currTime );
zi.tmz_date.tm_sec = currTime.wSecond;
zi.tmz_date.tm_min = currTime.wMinute;
zi.tmz_date.tm_hour = currTime.wHour;
zi.tmz_date.tm_mday = currTime.wDay;
zi.tmz_date.tm_mon = currTime.wMonth;
zi.tmz_date.tm_year = currTime.wYear;
unsigned int filesCount = get_files_count( dir );
unsigned int currentFileIndex = 0;
while ( ( !StringDeque.empty() ) || ( bNextFile ) )
{
if ( ( !bNextFile ) && ( !StringDeque.empty() ) )
{
szText = StringDeque.front() + wstring( _T( "\\" ) );
szCurText = szText + wstring( _T( "*" ) );
if ( hFind != INVALID_HANDLE_VALUE )
{
FindClose( hFind );
zipDir = zipDeque.front() + wstring( _T( "/" ) );
zipDeque.pop_front();
}
StringDeque.pop_front();
hFind = FindFirstFile( szCurText.c_str(), &ffd );
}
if ( ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )
{
if ( ( wcscmp( ffd.cFileName, _T( "." ) ) != 0 ) && ( wcscmp( ffd.cFileName, _T( ".." ) ) != 0 ) )
{
StringDeque.push_back( szText + wstring( ffd.cFileName ) );
zipDeque.push_back( zipDir + wstring( ffd.cFileName ) );
}
}
else
{
file = szText + wstring( ffd.cFileName );
zipFileName = zipDir + wstring( ffd.cFileName );
string xstr;
ifstream xfile( file.c_str(), ios::binary );
xfile.seekg( 0, ios_base::end );
xstr.resize( xfile.tellg() );
xfile.seekg( 0, ios_base::beg );
xfile.read( const_cast<char*>( xstr.data() ), (streamsize)xstr.size() );
err = zipOpenNewFileInZip( zf, UniversalString( zipFileName.c_str(), CP_OEMCP ), &zi, NULL, 0, NULL, 0, NULL, Z_DEFLATED, compressionLevel );
err = zipWriteInFileInZip( zf, xstr.data(), (unsigned int)xstr.size() );
err = zipCloseFileInZip( zf );
xfile.close();
if ( progress != NULL )
{
short cancel = 0;
long progressValue = ( 1000000 / filesCount * currentFileIndex );
progress->OnProgress( progress->caller, UTILS_ONPROGRESSEVENT_ID, progressValue, &cancel );
if ( cancel != 0 )
{
FindClose( hFind );
err = zipClose( zf, NULL );
return err;
}
}
currentFileIndex++;
}
bNextFile = FindNextFile( hFind, &ffd );
}
FindClose( hFind );
err = zipClose( zf, NULL );
if ( progress != NULL )
{
short cancel = 0;
long progressValue = 1000000;
progress->OnProgress( progress->caller, UTILS_ONPROGRESSEVENT_ID, progressValue, &cancel );
}
}
criticalSection.Leave();
return err;
}
int ZipFile( const WCHAR* inputFile, const WCHAR* outputFile, int compressionLevel )
{
criticalSection.Enter();
int err = -1;
if ( ( inputFile != NULL ) && ( outputFile != NULL ) )
{
string istr;
ifstream ifile( inputFile, std::ios::binary );
ifile.seekg( 0, ios_base::end );
istr.resize( ifile.tellg() );
ifile.seekg( 0, ios_base::beg );
ifile.read( const_cast<char*>( istr.data() ), (streamsize)istr.size() );
ifile.close();
zipFile zf = zipOpen( UniversalString( outputFile ), APPEND_STATUS_CREATE );
zip_fileinfo zi;
zi.tmz_date.tm_sec = zi.tmz_date.tm_min = zi.tmz_date.tm_hour =
zi.tmz_date.tm_mday = zi.tmz_date.tm_mon = zi.tmz_date.tm_year = 0;
zi.dosDate = 0;
zi.internal_fa = 0;
zi.external_fa = 0;
SYSTEMTIME currTime;
GetLocalTime( &currTime );
zi.tmz_date.tm_sec = currTime.wSecond;
zi.tmz_date.tm_min = currTime.wMinute;
zi.tmz_date.tm_hour = currTime.wHour;
zi.tmz_date.tm_mday = currTime.wDay;
zi.tmz_date.tm_mon = currTime.wMonth;
zi.tmz_date.tm_year = currTime.wYear;
wstring inputFileName( inputFile );
wstring::size_type pos = 0;
static const wstring::size_type npos = -1;
pos = inputFileName.find_last_of( _T( '\\' ) );
wstring zipFileName;
if ( pos != npos )
{
zipFileName = wstring( ( inputFileName.begin() + pos + 1 ), inputFileName.end() );
}
else
{
zipFileName = wstring( inputFileName.begin(), inputFileName.end() );
}
err = zipOpenNewFileInZip( zf, UniversalString( zipFileName.c_str(), CP_OEMCP ), &zi, NULL, 0, NULL, 0, NULL, Z_DEFLATED, compressionLevel );
err = zipWriteInFileInZip( zf, istr.data(), (unsigned int)istr.size() );
err = zipCloseFileInZip( zf );
err = zipClose( zf, NULL );
}
criticalSection.Leave();
return false;
}
bool ClearDirectory( const WCHAR* dir, bool delDir )
{
criticalSection.Enter();
bool result = false;
if ( dir != NULL )
{
unsigned int size = (unsigned int)wcslen( dir );
WCHAR* _dir = new WCHAR[size + 2];
wcsncpy_s( _dir, size + 2, dir, size );
_dir[size++] = L'\0';
_dir[size] = L'\0';
SHFILEOPSTRUCT lpFileOp;
lpFileOp.hwnd = NULL;
lpFileOp.wFunc = FO_DELETE;
lpFileOp.pFrom = _dir;
lpFileOp.pTo = NULL;
lpFileOp.fFlags = FOF_NOERRORUI | FOF_NOCONFIRMATION | FOF_SILENT;
lpFileOp.fAnyOperationsAborted = FALSE;
lpFileOp.hNameMappings = NULL;
lpFileOp.lpszProgressTitle = NULL;
int err = SHFileOperation( &lpFileOp );
if ( !delDir )
{
CreateDirectory( dir, NULL );
}
if ( _dir != NULL )
{
delete []_dir;
_dir = NULL;
}
result = true;
}
else
{
result = false;
}
criticalSection.Leave();
return result;
}
int UnzipToDir( const WCHAR* zipFile, const WCHAR* unzipDir, const ProgressCallback* progress, const WCHAR* password, bool opt_extract_without_path, bool clearOutputDirectory )
{
criticalSection.Enter();
unzFile uf = NULL;
int err = -1;
if ( ( zipFile != NULL ) && ( unzipDir != NULL ) )
{
uf = unzOpen (zipFile);
}
if ( uf != NULL )
{
if ( clearOutputDirectory )
{
ClearDirectory( unzipDir );
}
char* buffer = NULL;
buffer = _getcwd( NULL, 0 );
err = _wchdir (unzipDir);
if ( err == 0 )
{
err = do_extract( uf, opt_extract_without_path, 1, UniversalString( password ), progress );
}
if ( err == UNZ_OK )
{
err = unzClose( uf );
}
if ( buffer != NULL )
{
err = _chdir( UniversalString( buffer ) );
free( buffer );
buffer = NULL;
}
}
criticalSection.Leave();
return err;
}
int UncompressBytes( BYTE* destBuf, ULONG* destSize, const BYTE* sourceBuf, ULONG sourceSize )
{
criticalSection.Enter();
int err = -1;
err = uncompress( destBuf, destSize, sourceBuf, sourceSize );
criticalSection.Leave();
return err;
}
int CompressBytes( BYTE* destBuf, ULONG* destSize, const BYTE* sourceBuf, ULONG sourceSize, SHORT level )
{
criticalSection.Enter();
int err = -1;
err = compress2( destBuf, destSize, sourceBuf, sourceSize, level );
criticalSection.Leave();
return err;
}
bool IsArchive(const WCHAR* filename)
{
criticalSection.Enter();
unzFile uf = NULL;
bool isZIP = false;
if (( filename != NULL ))
uf = unzOpen( UniversalString( filename ) );
if ( uf != NULL )
{
isZIP = true;
unzClose( uf );
}
criticalSection.Leave();
return isZIP;
}
bool IsFileExistInArchive(const WCHAR* zipFile, const WCHAR* filePathInZip)
{
criticalSection.Enter();
unzFile uf = NULL;
bool isIn = false;
if ( ( zipFile != NULL ) && ( filePathInZip != NULL ) )
uf = unzOpen( UniversalString( zipFile ) );
if ( uf != NULL )
{
isIn = is_file_in_archive( uf, filePathInZip );
unzClose( uf );
}
criticalSection.Leave();
return isIn;
}
bool LoadFileFromArchive(const WCHAR* zipFile, const WCHAR* filePathInZip, BYTE** fileInBytes)
{
criticalSection.Enter();
unzFile uf = NULL;
bool isIn = false;
if ( ( zipFile != NULL ) && ( filePathInZip != NULL ) )
uf = unzOpen( UniversalString( zipFile ) );
if ( uf != NULL )
{
isIn = get_file_in_archive( uf, filePathInZip, fileInBytes);
unzClose( uf );
}
criticalSection.Leave();
return isIn;
}
bool ExtractFiles(const _bstr_t zip_file_path, ExtractedFileCallback& callback)
{
CSLocker locker(criticalSection);
unzFile unzip_file_handle = unzOpen(static_cast<wchar_t*>(zip_file_path));
if ( unzip_file_handle != NULL )
{
do
{
unz_file_info file_info;
unzGetCurrentFileInfo(unzip_file_handle, &file_info, NULL, 0, NULL, 0, NULL, 0);
CComSafeArray<BYTE> arr(file_info.uncompressed_size);
if(file_info.uncompressed_size == 0 || get_file(unzip_file_handle, arr.m_psa, file_info.uncompressed_size))
{
callback.Invoke(get_filename_from_unzfile(unzip_file_handle), arr.GetSafeArrayPtr());
}
} while (UNZ_OK == unzGoToNextFile(unzip_file_handle));
unzClose( unzip_file_handle );
return true;
}
return false;
}
bool CompressFiles(_bstr_t zip_file_path, RequestFileCallback& callback, int compression_level)
{
CSLocker locker(criticalSection);
zipFile zip_file_handle = zipOpen(zip_file_path, APPEND_STATUS_CREATE);
if(NULL != zip_file_handle)
{
zip_fileinfo zi = {0};
SYSTEMTIME currTime;
GetLocalTime( &currTime );
zi.tmz_date.tm_sec = currTime.wSecond;
zi.tmz_date.tm_min = currTime.wMinute;
zi.tmz_date.tm_hour = currTime.wHour;
zi.tmz_date.tm_mday = currTime.wDay;
zi.tmz_date.tm_mon = currTime.wMonth;
zi.tmz_date.tm_year = currTime.wYear;
SAFEARRAY* arr;
BSTR in_zip_filename;
while(callback.Invoke(&in_zip_filename, &arr))
{
_bstr_t in_zip_filename_wrapper(in_zip_filename, false);
CComSafeArray<BYTE> arr_wrapper;
arr_wrapper.Attach(arr);
static char in_zip_filename_OEM[MAX_PATH];
CharToOemW(static_cast<wchar_t*>(in_zip_filename_wrapper), in_zip_filename_OEM);
if (ZIP_OK != zipOpenNewFileInZip( zip_file_handle, in_zip_filename_OEM, &zi, NULL, 0, NULL, 0, NULL, Z_DEFLATED, compression_level ) ||
ZIP_OK != zipWriteInFileInZip(zip_file_handle, arr_wrapper.m_psa->pvData, arr_wrapper.GetCount()) ||
ZIP_OK != zipCloseFileInZip(zip_file_handle))
{
zipClose(zip_file_handle, NULL);
return false;
}
}
zipClose(zip_file_handle, NULL);
return true;
}
return false;
}
static unsigned int get_files_count( const WCHAR* dirname )
{
unsigned int filescount = 0;
if ( dirname != NULL )
{
WIN32_FIND_DATA ffd;
HANDLE hFind = INVALID_HANDLE_VALUE;
BOOL bNextFile = FALSE;
deque<wstring> StringDeque;
StringDeque.push_back( dirname );
wstring file;
wstring szText;
wstring szCurText;
while ( ( !StringDeque.empty() ) || ( bNextFile ) )
{
if ( ( !bNextFile ) && ( !StringDeque.empty() ) )
{
szText = StringDeque.front() + wstring( _T( "\\" ) );
szCurText = szText + wstring( _T( "*" ) );
if ( hFind != INVALID_HANDLE_VALUE )
{
FindClose( hFind );
}
StringDeque.pop_front();
hFind = FindFirstFile( szCurText.c_str(), &ffd );
}
if ( ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )
{
if ( ( wcscmp( ffd.cFileName, _T( "." ) ) != 0 ) && ( wcscmp( ffd.cFileName, _T( ".." ) ) != 0 ) )
{
StringDeque.push_back( szText + wstring( ffd.cFileName ) );
}
}
else
{
filescount++;
}
bNextFile = FindNextFile( hFind, &ffd );
}
FindClose( hFind );
}
return filescount;
}
}

View File

@@ -0,0 +1,69 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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
*
*/
#pragma once
#include "UniversalString.h"
#include <string>
#include <deque>
#include <fstream>
#include <vector>
#include <list>
#include <direct.h>
#include "CallbackHelpers.h"
using namespace std;
#define ZLIB_WINAPI
#define CODEPAGE_ISSUE_FIX
#include "unzip.h"
#include "zip.h"
namespace ZLibZipUtils
{
int ZipDir( const WCHAR* dir, const WCHAR* outputFile, const ProgressCallback* progress, int compressionLevel = -1 );
int ZipFile( const WCHAR* inputFile, const WCHAR* outputFile, int compressionLevel = -1 );
bool ClearDirectory( const WCHAR* dir, bool delDir = false );
int UnzipToDir( const WCHAR* zipFile, const WCHAR* unzipDir, const ProgressCallback* progress, const WCHAR* password = NULL, bool opt_extract_without_path = false, bool clearOutputDirectory = false );
int UncompressBytes( BYTE* destBuf, ULONG* destSize, const BYTE* sourceBuf, ULONG sourceSize );
int CompressBytes( BYTE* destBuf, ULONG* destSize, const BYTE* sourceBuf, ULONG sourceSize, SHORT level );
bool IsArchive(const WCHAR* filename);
bool IsFileExistInArchive(const WCHAR* zipFile, const WCHAR* filePathInZip);
bool LoadFileFromArchive(const WCHAR* zipFile, const WCHAR* filePathInZip, BYTE** fileInBytes);
bool ExtractFiles(const _bstr_t zip_file_path, ExtractedFileCallback& callback);
bool CompressFiles(_bstr_t zip_file_path, RequestFileCallback& callback, int compression_level);
}

View File

@@ -0,0 +1,5 @@
// stdafx.cpp : source file that includes just the standard includes
// AVSOfficeUtils.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"

View File

@@ -0,0 +1,77 @@
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently,
// but are changed infrequently
#pragma once
#ifndef STRICT
#define STRICT
#endif
// Modify the following defines if you have to target a platform prior to the ones specified below.
// Refer to MSDN for the latest info on corresponding values for different platforms.
#ifndef WINVER // Allow use of features specific to Windows 95 and Windows NT 4 or later.
#define WINVER 0x0400 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later.
#endif
#ifndef _WIN32_WINNT // Allow use of features specific to Windows NT 4 or later.
#define _WIN32_WINNT 0x0400 // Change this to the appropriate value to target Windows 2000 or later.
#endif
#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later.
#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later.
#endif
#ifndef _WIN32_IE // Allow use of features specific to IE 4.0 or later.
#define _WIN32_IE 0x0400 // Change this to the appropriate value to target IE 5.0 or later.
#endif
#define _ATL_APARTMENT_THREADED
#define _ATL_NO_AUTOMATIC_NAMESPACE
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit
// turns off ATL's hiding of some common and often safely ignored warning messages
#define _ATL_ALL_WARNINGS
#include <atlbase.h>
#include <atlcom.h>
#include <atlwin.h>
#include <atltypes.h>
#include <atlctl.h>
#include <atlhost.h>
#include "CSLocker.h"
using namespace ATL;
#include "../../Common/Config.h"
#ifdef BUILD_CONFIG_FULL_VERSION
#import "../../Redist/ASCMediaCore3.dll" named_guids raw_interfaces_only rename_namespace("MediaCore"), exclude("tagRECT")
#else
#import "../../Redist/OfficeCore.dll" named_guids raw_interfaces_only rename_namespace("OfficeCore")
#endif
#ifdef _DEBUG
#pragma comment(lib, "..\\GOCR\\Debug\\GOCR.lib")
#pragma comment(lib, "..\\PNM\\Debug\\PNM.lib")
#else
#ifdef BUILD_CONFIG_FULL_VERSION
#pragma comment(lib, "..\\GOCR\\Release\\GOCR.lib")
#pragma comment(lib, "..\\PNM\\Release\\PNM.lib")
#else
#pragma comment(lib, "..\\GOCR\\ReleaseOpenSource\\GOCR.lib")
#pragma comment(lib, "..\\PNM\\ReleaseOpenSource\\PNM.lib")
#endif
#endif
static const long UTILS_ONPROGRESSEVENT_ID = 0;
typedef void (*OnProgressCallback)( LPVOID lpParam, long nID, long nPercent, short* Cancel );
struct ProgressCallback
{
OnProgressCallback OnProgress;
LPVOID caller;
};

View File

@@ -0,0 +1,7 @@
#pragma once
//1
//0
//0
//18
#define INTVER 1,0,0,18
#define STRVER "1,0,0,18\0"