Commit 7db254af authored by Elen.Subbotina's avatar Elen.Subbotina Committed by Alexander Trofimov

XlsFile2

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@63487 954022d7-b5bf-4e40-9824-e11837661b57
parent 9969eb77
......@@ -6,7 +6,7 @@
#include <iostream>
#include <string>
#import "../debug/ASCOfficeXlsFile2.dll" rename_namespace("ASCOfficeXlsFile"), raw_interfaces_only
#import "../win32/x64/Debug/ASCOfficeXlsFile2.dll" rename_namespace("ASCOfficeXlsFile"), raw_interfaces_only
#define HR_RET(HR) if FAILED(hr = (HR)) { _ASSERTE(false); return -1; }
......
......@@ -2,9 +2,9 @@
#include "CFRecordType.h"
#include "CFStream.h"
#include <Binary/BinSmartPointers.h>
#include <Logic/GlobalWorkbookInfo.h>
#include <Auxiliary/nullable/nullable.h>
#include "BinSmartPointers.h"
#include "../Logic/GlobalWorkbookInfo.h"
#include "../Auxiliary/nullable/nullable.h"
namespace XLS
......
......@@ -4,6 +4,8 @@
//#include <Exception/CompoundFileFormatError.h>
//#include <Exception/EndOfStreamReached.h>
#include <boost/bind.hpp>
#include <sstream>
namespace XLS
......
......@@ -2,8 +2,8 @@
#include "objidl.h"
#include <Binary/CFRecordType.h>
#include <Binary/BinSmartPointers.h>
#include "CFRecordType.h"
#include "BinSmartPointers.h"
namespace XLS
{;
......
......@@ -2,8 +2,8 @@
#include "CFRecordType.h"
#include "BinSmartPointers.h"
#include "../Logic/GlobalWorkbookInfo.h"
#include "../Logic/Biff_structures/ODRAW/OfficeArtRecordHeader.h"
#include <Logic/GlobalWorkbookInfo.h>
#include <Logic/Biff_structures/ODRAW/OfficeArtRecordHeader.h>
namespace XLS
{;
......
......@@ -5,7 +5,7 @@
#include <boost/shared_ptr.hpp>
#include "../../Auxiliary/BetterVariantT.h"
#include <Auxiliary/BetterVariantT.h>
//#include <Logic/Biff_structures/BitMarkedStructs.h>
class Document;
......
#pragma once
#include "Property.h"
#include "Binary/BinSmartPointers.h"
#include <Binary/BinSmartPointers.h>
namespace OLEPS
{;
......
#pragma once
#include "Property.h"
#include "Binary\BinSmartPointers.h"
#include <Binary/BinSmartPointers.h>
namespace OLEPS
{;
......
#pragma once
#include "Binary/BinSmartPointers.h"
#include <Binary/BinSmartPointers.h>
#include "PropertySet.h"
namespace OLEPS
......
#include "precompiled_xls.h"
#include "SummaryInformation.h"
#include "Binary\CFStream.h"
#include "Binary/CFStream.h"
namespace OLEPS
......
#pragma once
#include "Binary\BinSmartPointers.h"
#include "Structures\PropertySetStream.h"
#include <Binary/BinSmartPointers.h>
#include "Structures/PropertySetStream.h"
namespace OLEPS
{;
......
#include "ConvertXls2Xlsx.h"
#include "..\..\Common\OfficeFileErrorDescription.h"
#include "XlsFormat\Document\Document.h"
#include "XlsFormat\Binary\CompoundFile.h"
#include "XlsFormat\Binary\BinSmartPointers.h"
#include "XlsFormat\Binary\CFStreamCacheReader.h"
//#include "XlsFormat\Binary\CFStreamCacheWriter.h"
#include "XlsFormat\Logic\GlobalWorkbookInfo.h"
#include "XlsFormat\Logic\WorkbookStreamObject.h"
#include "XlsFormat\Logic\BinProcessor.h"
#include "XlsFormat\Logic\SummaryInformationStream\SummaryInformation.h"
//#include "XlsFormat\Auxiliary\HelpersTagsGenerator.h"
#include "XlsFormat\Logic\BaseObject.h"
#include "../../../Common/OfficeFileErrorDescription.h"
#include "../XlsFormat/Document/Document.h"
#include "../XlsFormat/Binary/CompoundFile.h"
#include "../XlsFormat/Binary/BinSmartPointers.h"
#include "../XlsFormat/Binary/CFStreamCacheReader.h"
//#include "../XlsFormat/Binary/CFStreamCacheWriter.h"
#include "../XlsFormat/Logic/GlobalWorkbookInfo.h"
#include "../XlsFormat/Logic/WorkbookStreamObject.h"
#include "../XlsFormat/Logic/BinProcessor.h"
#include "../XlsFormat/Logic/SummaryInformationStream/SummaryInformation.h"
//#include "../XlsFormat\Auxiliary\HelpersTagsGenerator.h"
#include "../XlsFormat/Logic/BaseObject.h"
HRESULT ConvertXls2Xlsx(const std::wstring & srcFile, const std::wstring & dstPath, const ProgressCallback* CallBack)
{
......
......@@ -43,7 +43,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\XlsFormat; ..\source\XlsFormat"
AdditionalIncludeDirectories="..\XlsFormat"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
MinimalRebuild="true"
BasicRuntimeChecks="3"
......@@ -106,7 +106,7 @@
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="..\XlsFormat; ..\source\XlsFormat"
AdditionalIncludeDirectories="..\XlsFormat"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
......@@ -168,7 +168,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\XlsFormat; ..\source\XlsFormat"
AdditionalIncludeDirectories="..\XlsFormat"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
MinimalRebuild="true"
BasicRuntimeChecks="3"
......@@ -232,7 +232,7 @@
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="..\XlsFormat; ..\source\XlsFormat"
AdditionalIncludeDirectories="..\XlsFormat"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
......
......@@ -43,6 +43,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\XlsFormat"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
MinimalRebuild="true"
BasicRuntimeChecks="3"
......@@ -105,6 +106,7 @@
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="..\XlsFormat"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
......@@ -166,6 +168,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\XlsFormat"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
MinimalRebuild="true"
BasicRuntimeChecks="3"
......@@ -229,6 +232,7 @@
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="..\XlsFormat"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
......@@ -277,6 +281,14 @@
RelativePath="..\XlsXlsxConverter\ConvertXls2Xlsx.cpp"
>
</File>
<File
RelativePath="..\..\..\Common\DocxFormat\Source\SystemUtility\FileSystem\Directory.cpp"
>
</File>
<File
RelativePath="..\..\..\Common\DocxFormat\Source\XML\stringcommon.cpp"
>
</File>
</Filter>
<Filter
Name="Header Files"
......
......@@ -3,6 +3,8 @@ Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ASCOfficeXlsFile2", "ASCOfficeXlsFile2.vcproj", "{4260FEDF-E1DA-447F-991B-62F17DF5533E}"
ProjectSection(ProjectDependencies) = postProject
{37CA072A-5BDE-498B-B3A7-5E404F5F9BF2} = {37CA072A-5BDE-498B-B3A7-5E404F5F9BF2}
{3F3CB5A1-BB01-49C1-9342-4A69E30F9EF6} = {3F3CB5A1-BB01-49C1-9342-4A69E30F9EF6}
{CBEDD0D1-10A8-45C1-AF81-8492F40964CA} = {CBEDD0D1-10A8-45C1-AF81-8492F40964CA}
EndProjectSection
EndProject
......@@ -18,6 +20,10 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ASCOfficeXlsFileTest", "..\
{4260FEDF-E1DA-447F-991B-62F17DF5533E} = {4260FEDF-E1DA-447F-991B-62F17DF5533E}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ASCOfficeUtilsLib", "..\..\ASCOfficeUtils\ASCOfficeUtilsLib\Win\ASCOfficeUtilsLib.vcproj", "{3F3CB5A1-BB01-49C1-9342-4A69E30F9EF6}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "graphics", "..\..\DesktopEditor\graphics\graphics_vs2005.vcproj", "{37CA072A-5BDE-498B-B3A7-5E404F5F9BF2}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
......@@ -58,6 +64,22 @@ Global
{C2882DDD-07E6-4314-AD4B-48F43F38D722}.Release|Win32.Build.0 = Release|Win32
{C2882DDD-07E6-4314-AD4B-48F43F38D722}.Release|x64.ActiveCfg = Release|x64
{C2882DDD-07E6-4314-AD4B-48F43F38D722}.Release|x64.Build.0 = Release|x64
{3F3CB5A1-BB01-49C1-9342-4A69E30F9EF6}.Debug|Win32.ActiveCfg = Debug|Win32
{3F3CB5A1-BB01-49C1-9342-4A69E30F9EF6}.Debug|Win32.Build.0 = Debug|Win32
{3F3CB5A1-BB01-49C1-9342-4A69E30F9EF6}.Debug|x64.ActiveCfg = Debug|x64
{3F3CB5A1-BB01-49C1-9342-4A69E30F9EF6}.Debug|x64.Build.0 = Debug|x64
{3F3CB5A1-BB01-49C1-9342-4A69E30F9EF6}.Release|Win32.ActiveCfg = Release|Win32
{3F3CB5A1-BB01-49C1-9342-4A69E30F9EF6}.Release|Win32.Build.0 = Release|Win32
{3F3CB5A1-BB01-49C1-9342-4A69E30F9EF6}.Release|x64.ActiveCfg = Release|x64
{3F3CB5A1-BB01-49C1-9342-4A69E30F9EF6}.Release|x64.Build.0 = Release|x64
{37CA072A-5BDE-498B-B3A7-5E404F5F9BF2}.Debug|Win32.ActiveCfg = Debug|Win32
{37CA072A-5BDE-498B-B3A7-5E404F5F9BF2}.Debug|Win32.Build.0 = Debug|Win32
{37CA072A-5BDE-498B-B3A7-5E404F5F9BF2}.Debug|x64.ActiveCfg = Debug|x64
{37CA072A-5BDE-498B-B3A7-5E404F5F9BF2}.Debug|x64.Build.0 = Debug|x64
{37CA072A-5BDE-498B-B3A7-5E404F5F9BF2}.Release|Win32.ActiveCfg = Release|Win32
{37CA072A-5BDE-498B-B3A7-5E404F5F9BF2}.Release|Win32.Build.0 = Release|Win32
{37CA072A-5BDE-498B-B3A7-5E404F5F9BF2}.Release|x64.ActiveCfg = Release|x64
{37CA072A-5BDE-498B-B3A7-5E404F5F9BF2}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......
......@@ -5,22 +5,18 @@
#include <string>
#include <iostream>
#include <boost/uuid/uuid.hpp>
#pragma warning(push)
#pragma warning(disable : 4244)
#include <boost/uuid/random_generator.hpp>
#pragma warning(pop)
#include <boost/algorithm/string/case_conv.hpp>
#include <boost/uuid/uuid_io.hpp>
#include <boost/lexical_cast.hpp>
#include "../Common/boost_filesystem_version.h"
#include "../../Common/DocxFormat/Source/Base/Base.h"
#include "../../Common/DocxFormat/Source/SystemUtility/FileSystem/Directory.h"
#include "../source/XlsXlsxConverter/ConvertXls2Xlsx.h"
#include "../Common/XmlUtils.h"
#include "../Common/ASCATLError.h"
#include "../../ASCOfficeUtils/ASCOfficeUtilsLib/OfficeUtils.h"
#include "../../Common/ASCATLError.h"
#include "OfficeXlsFile.h"
......@@ -30,32 +26,18 @@
#define STANDALONE_USE 0// : (1) (0)
#endif
// - uuid
boost::filesystem::wpath MakeTempDirectoryName(const std::wstring & Dst)
{
boost::uuids::random_generator gen;
boost::uuids::uuid u = gen();
boost::filesystem::wpath path = boost::filesystem::wpath(Dst) / boost::lexical_cast<std::wstring>(u);
return path;
}
std::wstring bstr2wstring(BSTR str)
{
return str ? std::wstring(&str[0], &str[::SysStringLen(str)]) : L"";
}
boost::filesystem::wpath MakeTempDirectoryName(BSTR Dst)
{
return MakeTempDirectoryName(bstr2wstring(Dst));
}
///------------------------------------------------------------------------------------
// COfficeXlsFile
COfficeXlsFile::COfficeXlsFile()
{
#if defined(STANDALONE_USE) && (STANDALONE_USE == 1)
office_utils_.CoCreateInstance(__uuidof(ASCOfficeUtils::COfficeUtils));
#endif
}
HRESULT COfficeXlsFile::SaveToFile(BSTR sDstFileName, BSTR sSrcPath, BSTR sXMLOptions)
......@@ -65,37 +47,30 @@ HRESULT COfficeXlsFile::SaveToFile(BSTR sDstFileName, BSTR sSrcPath, BSTR sXMLOp
HRESULT COfficeXlsFile::LoadFromFile(BSTR sSrcFileName, BSTR sDstPath, BSTR sXMLOptions)
{
HRESULT hr;
if (!initialized())
return E_FAIL;
HRESULT hr = AVS_ERROR_UNEXPECTED;
if (!sDstPath)
if (!sDstPath)
{
_ASSERTE(!!sDstPath);
return E_FAIL;
}
#if defined(STANDALONE_USE) && (STANDALONE_USE == 1)
boost::filesystem::wpath outputDir = boost::filesystem::wpath(bstr2wstring(sDstPath)).parent_path();
std::wstring outputDir = FileSystem::Directory::GetFolderPath(std::wstring(sDstPath));
#else
boost::filesystem::wpath outputDir = boost::filesystem::wpath(bstr2wstring(sDstPath));
std::wstring outputDir = sDstPath;
#endif
#if defined(STANDALONE_USE) && (STANDALONE_USE == 1)
boost::filesystem::wpath dstTempPath = MakeTempDirectoryName(BOOST_STRING_PATH(outputDir));
std::wstring dstTempPath = FileSystem::Directory::CreateDirectoryWithUniqueName(outputDir);
#else
boost::filesystem::wpath dstTempPath = outputDir.string();
std::wstring dstTempPath = outputDir;
#endif
try
{
#if defined(STANDALONE_USE) && (STANDALONE_USE == 1)
//
boost::filesystem::create_directory(dstTempPath);
#endif
hr = LoadFromFileImpl(bstr2wstring(sSrcFileName), BOOST_STRING_PATH(dstTempPath), bstr2wstring(sDstPath));
hr = LoadFromFileImpl(bstr2wstring(sSrcFileName), dstTempPath, bstr2wstring(sDstPath));
}
catch(...)
......@@ -109,7 +84,7 @@ HRESULT COfficeXlsFile::LoadFromFile(BSTR sSrcFileName, BSTR sDstPath, BSTR sXML
// ( )
try
{
boost::filesystem::remove_all(dstTempPath);
FileSystem::Directory::DeleteDirectory(dstTempPath);
}
catch(...)
{
......@@ -121,12 +96,10 @@ HRESULT COfficeXlsFile::LoadFromFile(BSTR sSrcFileName, BSTR sDstPath, BSTR sXML
HRESULT COfficeXlsFile::LoadFromFileImpl(const std::wstring & srcFileName,
const std::wstring & dstTempPath,
const std::wstring & dstPath)
HRESULT COfficeXlsFile::LoadFromFileImpl(const std::wstring & srcFileName, const std::wstring & dstTempPath, const std::wstring & dstPath)
{
HRESULT hr = AVS_ERROR_UNEXPECTED;
HRESULT hr = AVS_ERROR_UNEXPECTED;
ProgressCallback ffCallBack;
ffCallBack.OnProgress = OnProgressFunc;
......@@ -138,43 +111,28 @@ HRESULT COfficeXlsFile::LoadFromFileImpl(const std::wstring & srcFileName,
if (hr != S_OK) return hr;
#if defined(STANDALONE_USE) && (STANDALONE_USE == 1)
if FAILED(hr = office_utils_->CompressFileOrDirectory(ATL::CComBSTR(dstTempPath.c_str()), ATL::CComBSTR(dstPath.c_str()), (-1)))
COfficeUtils oCOfficeUtils(NULL);
if (S_OK != oCOfficeUtils.CompressFileOrDirectory(dstTempPath.c_str(), dstPath.c_str(), -1))
return hr;
#endif
return S_OK;
}
bool COfficeXlsFile::initialized()
{
#if defined(STANDALONE_USE) && (STANDALONE_USE == 1)
return (!!office_utils_);
#endif
return true;
}
void COfficeXlsFile::OnProgressFunc (LPVOID lpParam, long nID, long nPercent)
{
//g_oCriticalSection.Enter();
COfficeXlsFile* pXlsFile = reinterpret_cast<COfficeXlsFile*>(lpParam);
if (pXlsFile != NULL)
{
pXlsFile->OnProgress(nID, nPercent);
}
//g_oCriticalSection.Leave();
}
void COfficeXlsFile::OnProgressExFunc (LPVOID lpParam, long nID, long nPercent, short* pStop)
{
//g_oCriticalSection.Enter();
COfficeXlsFile* pXlsFile = reinterpret_cast<COfficeXlsFile*>(lpParam);
if (pXlsFile != NULL)
{
pXlsFile->OnProgressEx(nID, nPercent, pStop);
}
//g_oCriticalSection.Leave();
}
......@@ -3,17 +3,12 @@
#pragma once
#include "resource.h" // main symbols
#include "../Common/OfficeFileTemplate.h"
#if defined(STANDALONE_USE) && (STANDALONE_USE == 1)
#import "../Redist/ASCOfficeUtils.dll" rename_namespace("ASCOfficeUtils"), raw_interfaces_only
#endif
#include "../../Common/OfficeFileTemplate.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
// IOfficeXlsFile
[
object,
......@@ -75,15 +70,7 @@ public:
STDMETHOD(LoadFromFile) (BSTR sSrcFileName, BSTR sDstPath, BSTR sXMLOptions);
STDMETHOD(SaveToFile) (BSTR sDstFileName, BSTR sSrcPath, BSTR sXMLOptions);
#if defined(STANDALONE_USE) && (STANDALONE_USE == 1)
ATL::CComPtr< ASCOfficeUtils::IOfficeUtils > office_utils_;
#endif
bool initialized();
HRESULT LoadFromFileImpl(const std::wstring & srcFileName,
const std::wstring & dstTempPath,
const std::wstring & dstPath);
HRESULT LoadFromFileImpl(const std::wstring & srcFileName, const std::wstring & dstTempPath, const std::wstring & dstPath);
protected:
......
......@@ -33,20 +33,15 @@
#include <atlbase.h>
#include <atlcom.h>
#include <atlwin.h>
#include <atltypes.h>
#include <atlctl.h>
#include <atlhost.h>
using namespace ATL;
typedef void (*OnProgressCallback)( LPVOID lpParam, long nID, long nPercent );
typedef void (*OnProgressExCallback)( LPVOID lpParam, long nID, long nPercent, short* Cancel );
typedef void (*XlsOnProgressCallback)( LPVOID lpParam, long nID, long nPercent );
typedef void (*XlsOnProgressExCallback)( LPVOID lpParam, long nID, long nPercent, short* Cancel );
struct ProgressCallback
{
OnProgressCallback OnProgress;
OnProgressExCallback OnProgressEx;
XlsOnProgressCallback OnProgress;
XlsOnProgressExCallback OnProgressEx;
LPVOID caller;
};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment