Commit aad5ef64 authored by Elen.Subbotina's avatar Elen.Subbotina Committed by Alexander Trofimov
parent 1c0bf853
......@@ -395,8 +395,6 @@ ASCOfficeXlsFile2/ASCOfficeXlsFileTest svnc_tsvn_003alogminsize=5
ASCOfficeXlsFile2/ASCOfficeXlsFileTest/Guideline.docx svn_mime_002dtype=application%2Foctet-stream
ASCOfficeXlsFile2/linux svnc_tsvn_003alogminsize=5
ASCOfficeXlsFile2/source svnc_tsvn_003alogminsize=5
ASCOfficeXlsFile2/source/Converter svnc_tsvn_003alogminsize=5
ASCOfficeXlsFile2/source/Serializer svnc_tsvn_003alogminsize=5
ASCOfficeXlsFile2/source/XlsFormat svnc_tsvn_003alogminsize=5
ASCOfficeXlsFile2/source/XlsFormat/Auxiliary svnc_tsvn_003alogminsize=5
ASCOfficeXlsFile2/source/XlsFormat/Auxiliary/nullable svnc_tsvn_003alogminsize=5
......@@ -6,7 +6,7 @@
#include <iostream>
#include <string>
#import "../../../Redist/ASCOfficeXlsFile2.dll" rename_namespace("ASCOfficeXlsFile"), raw_interfaces_only
#import "../debug/ASCOfficeXlsFile2.dll" rename_namespace("ASCOfficeXlsFile"), raw_interfaces_only
#define HR_RET(HR) if FAILED(hr = (HR)) { _ASSERTE(false); return -1; }
......
......@@ -11,6 +11,9 @@
<Platform
Name="Win32"
/>
<Platform
Name="x64"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
......@@ -167,6 +170,160 @@
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Debug|x64"
OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="2"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="kernel32.lib $(NoInherit)"
LinkIncremental="2"
GenerateDebugInformation="true"
SubSystem="1"
TargetMachine="17"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|x64"
OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
RuntimeLibrary="2"
UsePrecompiledHeader="2"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="kernel32.lib $(NoInherit)"
LinkIncremental="1"
GenerateDebugInformation="true"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="17"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
......@@ -199,6 +356,22 @@
UsePrecompiledHeader="1"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|x64"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|x64"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
/>
</FileConfiguration>
</File>
</Filter>
<Filter
......
#include "stdafx.h"
#include "Converter.h"
#include <Document/Document.h>
const bool Converter::convert(Document& doc, MSXML2::IXMLDOMDocumentPtr xslt)
{
return VARIANT_TRUE == doc.getDoc()->loadXML(doc.getDoc()->transformNode(xslt));
}
#pragma once
class Document;
class Converter
{
public:
virtual const bool convertToX(Document& doc) = 0;
virtual const bool convertFromX(Document& doc) = 0;
protected:
const bool convert(Document& doc, MSXML2::IXMLDOMDocumentPtr xslt);
};
#include "stdafx.h"
#include "XLSConverter.h"
#include <Document/Document.h>
#include <fstream>
#include <iostream> // endl
#include "boost/filesystem.hpp"
namespace XLS
{;
XLSConverter::XLSConverter()
{
}
const bool XLSConverter::convertFromX(Document& doc)
{
MSXML2::IXMLDOMDocument3Ptr xslt_from_X(_T("Msxml2.FreeThreadedDOMDocument.6.0"));
xslt_from_X->Putasync(VARIANT_TRUE);
xslt_from_X->setProperty(L"SelectionNamespaces", L"xmlns:xsl='http://www.w3.org/1999/XSL/Transform'");
std::vector<std::wstring> resources;
wchar_t file_path[MAX_PATH];
GetModuleFileNameW(ATL::_AtlBaseModule.GetModuleInstance(), file_path, MAX_PATH);
std::wstring dll_file_name = boost::filesystem::wpath(file_path).filename();
resources.push_back(L"res://" + dll_file_name + L"/XSL/#2012"); // x2xls.xsl
resources.push_back(L"res://" + dll_file_name + L"/XSL/#2013"); // x2xls_Globals.xsl
resources.push_back(L"res://" + dll_file_name + L"/XSL/#2014"); // propertiesTree.xsl
resources.push_back(L"res://" + dll_file_name + L"/XSL/#2015"); // x2xls_Worksheet.xsl
if(!XMLSTUFF::loadXSLTFromResources(xslt_from_X, resources))
{
return false;
}
Log::event("XLSX to XLS XSLT table loaded from resources successfully");
#ifdef _DEBUG
// DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG
//xslt_from_X->save(L"../InFiles/convert.xsl");
// DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG
#endif
if(!convert(doc, xslt_from_X))
{
return false;
}
Log::event("The internal XLSX XML converted to XLS XML successfully");
return true;
}
const bool XLSConverter::convertToX(Document& doc)
{
MSXML2::IXMLDOMDocument3Ptr xslt_to_X(_T("Msxml2.FreeThreadedDOMDocument.6.0"));
xslt_to_X->setProperty(L"SelectionNamespaces", L"xmlns:xsl='http://www.w3.org/1999/XSL/Transform'");
xslt_to_X->Putasync(VARIANT_TRUE);
std::vector<std::wstring> resources;
wchar_t file_path[MAX_PATH];
GetModuleFileNameW(ATL::_AtlBaseModule.GetModuleInstance(), file_path, MAX_PATH);
std::wstring dll_file_name = boost::filesystem::wpath(file_path).filename();
resources.push_back(L"res://" + dll_file_name + L"/XSL/#2001"); // xls2x.xsl
resources.push_back(L"res://" + dll_file_name + L"/XSL/#2003"); // xls2x_rels.xsl
resources.push_back(L"res://" + dll_file_name + L"/XSL/#2005"); // xls2x_wb.xsl
resources.push_back(L"res://" + dll_file_name + L"/XSL/#2006"); // xls2x_ws.xsl
resources.push_back(L"res://" + dll_file_name + L"/XSL/#2008"); // xls2x_styles.xsl
resources.push_back(L"res://" + dll_file_name + L"/XSL/#2009"); // xls2x_sst.xsl
resources.push_back(L"res://" + dll_file_name + L"/XSL/#2011"); // xls2x_comments.xsl
resources.push_back(L"res://" + dll_file_name + L"/XSL/#2014"); // propertiesTree.xsl
resources.push_back(L"res://" + dll_file_name + L"/XSL/#2018"); // xls2x_drawing.xsl
resources.push_back(L"res://" + dll_file_name + L"/XSL/#2019"); // xls2x_chart.xsl
resources.push_back(L"res://" + dll_file_name + L"/XSL/#2020"); // xls2x_cs.xsl
if(!XMLSTUFF::loadXSLTFromResources(xslt_to_X, resources))
{
return false;
}
Log::event("XLS to XLSX XSLT table loaded from resources successfully");
#ifdef _DEBUG
// DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG
//xslt_to_X->save(L"../InFiles/convert.xsl");
boost::filesystem::path curr_path = boost::filesystem::current_path();
xslt_to_X->save(L"d://test//convert.xsl");
// Log::event("../InFiles/convert.xsl saved successfully");
// DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG
DWORD time_before = GetTickCount();
#endif
if(!convert(doc, xslt_to_X))
{
return false;
}
#ifdef _DEBUG
DWORD ticks_spent = GetTickCount() - time_before;
std::cout << "XSLT conversion took " << ticks_spent / 1000 << " seconds (" << ticks_spent << " ms)" << std::endl;
#endif
Log::event("The internal XLS XML converted to XLSX XML successfully");
return true;
}
} // namespace XLS
#pragma once
#include <Converter/Converter.h>
namespace XLS
{;
class XLSConverter : public Converter
{
public:
XLSConverter();
virtual const bool convertToX(Document& doc);
virtual const bool convertFromX(Document& doc);
};
} // namespace XLS
#include "stdafx.h"
#include "XLSXConverter.h"
namespace XLSX
{;
const bool XLSXConverter::convertToX(Document& doc)
{
return true; // Already the necessary format
}
const bool XLSXConverter::convertFromX(Document& doc)
{
return true; // Already the necessary format
}
} // namespace XLS
#pragma once
#include <Converter/Converter.h>
namespace XLSX
{;
class XLSXConverter : public Converter
{
public:
virtual const bool convertToX(Document& doc);
virtual const bool convertFromX(Document& doc);
};
} // namespace XLSX
#pragma once
#include <Document/Document.h>
//namespace XLS
//{;
class Document;
class Serializer
{
public:
virtual const bool read(Document& doc, const _bstr_t& from) = 0;
virtual const bool write(const Document& doc, const _bstr_t& to) = 0;
};
//} // namespace XLS
#include "stdafx.h"
#include "XLSSerializer.h"
#include <XLS_bin/CFStream.h>
#include <XLS_bin/CompoundFile.h>
#include <XLS_bin/CFStreamCacheReader.h>
#include <XLS_bin/CFStreamCacheWriter.h>
#include <XLS_logic/GlobalWorkbookInfo.h>
#include <XLS_logic/WorkbookStreamObject.h>
#include <XLS_logic/BinProcessor.h>
#include <Exception/CompoundFileFormatError.h>
#include "XLS_logic/SummaryInformationStream/SummaryInformation.h"
#include "Auxiliary/HelpersTagsGenerator.h"
namespace XLS
{;
const bool XLSSerializer::read(Document& doc, const _bstr_t& from)
{
CompoundFile cfile(from, CompoundFile::cf_ReadMode);
/*
CFStreamPtr summary(cfile.getSummaryInformationStream());
size_t summary_size = static_cast<size_t>(summary->getStreamSize());
char* summary_raw = new char[summary_size];
summary->read(summary_raw, summary_size);
std::ofstream file1("SummaryInformation.bin", std::ios_base::binary);
file1.write(summary_raw, summary_size);
file1.flush();
return true;
*/
/*
CFStreamPtr summary(cfile.getDocumentSummaryInformationStream());
size_t summary_size = static_cast<size_t>(summary->getStreamSize());
char* summary_raw = new char[summary_size];
summary->read(summary_raw, summary_size);
std::ofstream file1("DocumentSummaryInformation.bin", std::ios_base::binary);
file1.write(summary_raw, summary_size);
file1.flush();
return true;
*/
CFStreamPtr summary;
CFStreamPtr doc_summary;
try
{
summary = cfile.getSummaryInformationStream();
}
catch (EXCEPT::RT::CompoundFileFormatError&)
{
}
try
{
doc_summary = cfile.getDocumentSummaryInformationStream();
}
catch (EXCEPT::RT::CompoundFileFormatError&)
{
}
WORD workbook_code_page = WorkbookStreamObject::DefaultCodePage;
if(summary)
{
OLEPS::SummaryInformation summary_info(summary);
workbook_code_page = summary_info.GetCodePage();
}
else if(doc_summary)
{
OLEPS::SummaryInformation doc_summary_info(doc_summary);
workbook_code_page = doc_summary_info.GetCodePage();
}
if(1200/* UTF-16 */ == workbook_code_page || 0/*error*/ == workbook_code_page)
{
workbook_code_page = WorkbookStreamObject::DefaultCodePage;
}
GlobalWorkbookInfoPtr global_info(new GlobalWorkbookInfo(workbook_code_page));
CFStreamCacheReader stream_reader(cfile.getWorkbookStream(), global_info);
BinReaderProcessor proc(stream_reader, doc.getRoot(), true);
return proc.mandatory(WorkbookStreamObject(workbook_code_page)) &&
AUX::HelpersTagsGenerator(doc.getRoot()).GenHelpers();
}
const bool XLSSerializer::write(const Document& doc, const _bstr_t& to)
{
CompoundFile cfile(to, CompoundFile::cf_WriteMode);
/*
{
char* summary_raw2 = new char[200];
std::ifstream file2("SummaryInformation.bin", std::ios_base::binary);
file2.read(summary_raw2, 200);
CFStreamPtr summary2(cfile.createSummaryInformationStream());
summary2->write(summary_raw2, 200);
cfile.closeSummaryInformationStream();
}
{
char* summary_raw = new char[116];
std::ifstream file1("DocumentSummaryInformation.bin", std::ios_base::binary);
file1.read(summary_raw, 116);
CFStreamPtr summary(cfile.createDocumentSummaryInformationStream());
summary->write(summary_raw, 116);
cfile.closeDocumentSummaryInformationStream();
}
*/
GlobalWorkbookInfoPtr global_info(new GlobalWorkbookInfo(WorkbookStreamObject::DefaultCodePage));
CFStreamCacheWriter stream_writer(cfile.createWorkbookStream(), global_info);
BinWriterProcessor proc(stream_writer, doc.getRoot(), true);
return proc.mandatory(WorkbookStreamObject());
}
} // namespace XLS
#pragma once
#include "Serializer.h"
namespace XLS
{;
class XLSSerializer : public Serializer
{
public:
virtual const bool read(Document& doc, const _bstr_t& from);
virtual const bool write(const Document& doc, const _bstr_t& to);
};
} // namespace XLS
#include "stdafx.h"
#include "XLSXSerializer.h"
#include <fstream>
#include <iostream> // endl
#include <direct.h>
#include "boost/filesystem.hpp"
namespace XLSX
{;
const bool loadDir(const Document& doc, MSXML2::IXMLDOMElementPtr cur_dir, const boost::filesystem::wpath path);
const bool storeDir(const Document& doc, MSXML2::IXMLDOMElementPtr cur_dir, const _bstr_t& path_for_dir);
const bool XLSXSerializer::read(Document& doc, const _bstr_t& from)
{
if(!boost::filesystem::exists(static_cast<wchar_t*>(from)) || !boost::filesystem::is_directory(static_cast<wchar_t*>(from)))
{
return false;
}
doc.newXMLDoc(L"root");
MSXML2::IXMLDOMElementPtr cur_dir = doc.getRoot();
bool res = loadDir(doc, cur_dir, static_cast<wchar_t*>(from));
if(res)
{
Log::event("\"" + std::string(static_cast<char*>(from)) + "\" loaded successfully");
return true;
}
return false;
}
const bool loadDir(const Document& doc, MSXML2::IXMLDOMElementPtr cur_dir, const boost::filesystem::wpath path)
{
for(boost::filesystem::wdirectory_iterator it(path), itEnd; it != itEnd; ++it)
{
if(boost::filesystem::is_directory(it->status()))
{
MSXML2::IXMLDOMElementPtr dir_tag = cur_dir->GetownerDocument()->createElement(L"dir");
dir_tag->setAttribute(L"name", it->filename().c_str());
cur_dir->appendChild(dir_tag);
if(!loadDir(doc, dir_tag, path / it->filename()))
{
return false;
}
continue;
}
if(boost::filesystem::is_regular_file(it->status()))
{
if(L".xml" == it->path().extension() || L".rels" == it->path().extension())
{
MSXML2::IXMLDOMElementPtr file_tag = cur_dir->GetownerDocument()->createElement(L"file");
file_tag->setAttribute(L"name", it->filename().c_str());
cur_dir->appendChild(file_tag);
MSXML2::IXMLDOMDocument3Ptr file_xml(_T("Msxml2.DOMDocument.6.0"));
VARIANT_BOOL res = file_xml->load(static_cast<std::wstring>(it->string()).c_str());
if(VARIANT_TRUE != res)
{
Log::warning("\"" + std::string(static_cast<char*>(_bstr_t(it->string().c_str()))) + "\" file is not a valid XML file.");
continue;
}
MSXML2::IXMLDOMNodePtr ins_elem = file_xml->removeChild(file_xml->GetdocumentElement());
file_tag->appendChild(ins_elem);
// Log::info("\"" + std::string(static_cast<char*>(_bstr_t(it->string().c_str()))) + "\" file has been read.");
}
if(L".bin" == it->path().extension())
{
MSXML2::IXMLDOMElementPtr file_tag = cur_dir->GetownerDocument()->createElement(L"file");
file_tag->setAttribute(L"name", it->filename().c_str());
cur_dir->appendChild(file_tag);
size_t file_size = static_cast<size_t>(boost::filesystem::file_size(it->path()));
boost::shared_array<char> buffer(new char[file_size]);
std::ifstream bin_file(static_cast<wchar_t*>(_bstr_t(it->string().c_str())), std::ios_base::binary | std::ios_base::in);
bin_file.read(buffer.get(), file_size);
file_tag->setAttribute(L"format", L"bin");
size_t bin_data_id = doc.appendBinaryData(file_tag, buffer, file_size);
MSXML2::IXMLDOMElementPtr bin_data_id_tag = cur_dir->GetownerDocument()->createElement(L"bin_data_id");
bin_data_id_tag->setAttribute(L"id", STR::int2str(bin_data_id).c_str());
file_tag->appendChild(bin_data_id_tag);
// Log::info("\"" + std::string(static_cast<char*>(_bstr_t(it->string().c_str()))) + "\" file has been read.");
}
}
}
return true;
}
const bool XLSXSerializer::write(const Document& doc, const _bstr_t& folder_path)
{
////////////////////////////
//
// http://www.rsdn.ru/forum/Message.aspx?mid=70479
//
// solved with <xsl:output method="xml" encoding="utf-16" indent="yes"/>
/*
Log::info("Saving to \"" + static_cast<char*>(to) + "\"");
_bstr_t xml = doc.getDoc()->Getxml();
CString strXml((char*)xml);
strXml.Replace(_T("><"), _T(">\n<"));
xml = strXml;
HRESULT res;
res = doc.getDoc()->loadXML(xml);
*/
/////////////////
std::wstring folder_path_w = static_cast<wchar_t*>(folder_path);
size_t pos1 = folder_path_w.find_last_of(L"\\/");
pos1 = std::string::npos == pos1 ? 0 : pos1;
std::wstring folder_name = folder_path_w.substr(pos1 + 1, folder_path_w.size() - pos1 - 1);
std::wstring folder_parent_path = folder_path_w.substr(0, pos1);
MSXML2::IXMLDOMElementPtr cur_dir = doc.getRoot();
cur_dir->setAttribute(L"name", folder_name.c_str());
if(storeDir(doc, cur_dir, folder_parent_path.c_str()))
{
//SetCurrentDirectoryA((dir_for_root + "/" + root_name).c_str());
//system(("7z a -r -tzip ../" + root_name + ".xlsx ./*.*").c_str());
return true;
}
return false;
}
const bool storeDir(const Document& doc, MSXML2::IXMLDOMElementPtr cur_dir, const _bstr_t& path_for_dir)
{
if(!cur_dir)
{
return false;
}
const _bstr_t node_type = cur_dir->GetnodeName();
const _bstr_t node_name = _bstr_t(cur_dir->getAttribute(L"name"));
if(_bstr_t(L"xlsx:dir") == node_type || _bstr_t(L"xlsx:root") == node_type)
{
const _bstr_t dir_name = path_for_dir + "/" + node_name;
_wmkdir(static_cast<wchar_t*>(dir_name));
MSXML2::IXMLDOMNodeListPtr children = cur_dir->GetchildNodes();
MSXML2::IXMLDOMNodePtr item;
while((item = children->nextNode()))
{
storeDir(doc, item, dir_name);
}
}
if(_bstr_t(L"xlsx:file") == node_type)
{
const _variant_t file_format = cur_dir->getAttribute(L"format");
if(VT_NULL != file_format.vt && _bstr_t(file_format) == _bstr_t(L"bin"))
{
const _bstr_t bin_data_id_str = _bstr_t(cur_dir->getAttribute(L"bin_data_id"));
if(!!bin_data_id_str)
{
int bin_data_id = atoi(static_cast<char*>(bin_data_id_str));
std::ofstream bin_file(static_cast<wchar_t*>(path_for_dir + "/" + node_name), std::ios_base::binary | std::ios_base::out);
const std::pair<char*, size_t> bin_data = doc.getBinaryData(bin_data_id);
bin_file.write(bin_data.first, bin_data.second);
}
}
else
{
MSXML2::IXMLDOMDocument3Ptr xml_doc(_T("Msxml2.DOMDocument.6.0"));
xml_doc->loadXML(L"<?xml version=\"1.0\" standalone=\"yes\" ?> <root/>");
xml_doc->PutRefdocumentElement(MSXML2::IXMLDOMElementPtr(cur_dir->removeChild(cur_dir->GetfirstChild())));
xml_doc->save(path_for_dir + "/" + node_name);
}
}
return true;
}
} // namespace XLSX
#pragma once
#include "Serializer.h"
namespace XLSX
{;
class XLSXSerializer : public Serializer
{
public:
virtual const bool read(Document& doc, const _bstr_t& from);
virtual const bool write(const Document& doc, const _bstr_t& folder_path);
};
} // namespace XLSX
#include "stdafx.h"
#include "XMLSerializer.h"
namespace XLS
{;
const bool XMLSerializer::read(Document& doc, const _bstr_t& from)
{
return S_OK == doc.getDoc()->load(from);
}
const bool XMLSerializer::write(const Document& doc, const _bstr_t& to)
{
// Log::info("XMLSerializer::write started \\n transformation.");
_bstr_t xml = doc.getDoc()->Getxml();
std::wstring wstr(static_cast<wchar_t*>(xml));
boost::algorithm::replace_all(wstr, L"><", L">\n<");
MSXML2::IXMLDOMDocument3Ptr full_indented_doc(_T("Msxml2.DOMDocument.6.0"));
try
{
full_indented_doc->loadXML(wstr.c_str());
}
catch (_com_error& e)
{
doc.getDoc()->save(to);
throw e;
}
// Log::info("XMLSerializer::write finished \\n transformation.");
return S_OK == full_indented_doc->save(to);
}
} // namespace XLS
#pragma once
#include "Serializer.h"
namespace XLS
{;
class XMLSerializer : public Serializer
{
public:
virtual const bool read(Document& doc, const _bstr_t& from);
virtual const bool write(const Document& doc, const _bstr_t& to);
};
} // namespace XLS
#include "precompiled_xls.h"
#include "Logger.h"
#include <iostream>
Logger::Logger(const std::string& log_file)
: m_log(log_file.c_str())
......
......@@ -83,7 +83,7 @@ BiffStructurePtr CellRangeRef::clone()
//}
//
//
//void CellRangeRef::setXMLAttributes(MSXML2::IXMLDOMElementPtr xml_tag)
//void CellRangeRef::(MSXML2::IXMLDOMElementPtr xml_tag)
//{
// xml_tag->setAttribute(L"name", toString().c_str());
// xml_tag->setAttribute(L"top_left_cell", getTopLeftCell().toString().c_str());
......
......@@ -13,7 +13,7 @@
//#include <ostream>
#include <boost/shared_ptr.hpp>
#include <boost/bind.hpp>
//#include <boost/bind.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/shared_array.hpp>
......
#include "stdafx.h"
#include "ConvertXls2Xlsx.h"
......
......@@ -11,6 +11,9 @@
<Platform
Name="Win32"
/>
<Platform
Name="x64"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
......@@ -137,6 +140,130 @@
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Debug|x64"
OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|x64"
OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
......@@ -147,7 +274,7 @@
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath="..\ConvertXls2Xlsx.cpp"
RelativePath="..\XlsXlsxConverter\ConvertXls2Xlsx.cpp"
>
</File>
</Filter>
......@@ -156,6 +283,10 @@
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath="..\XlsXlsxConverter\ConvertXls2Xlsx.h"
>
</File>
</Filter>
</Files>
<Globals>
......
......@@ -3,12 +3,17 @@ 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
{77DDC8D7-5B12-4FF2-9629-26AEBCA8436D} = {77DDC8D7-5B12-4FF2-9629-26AEBCA8436D}
{CBEDD0D1-10A8-45C1-AF81-8492F40964CA} = {CBEDD0D1-10A8-45C1-AF81-8492F40964CA}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "XlsFormat", "source\XlsFormat.vcproj", "{77DDC8D7-5B12-4FF2-9629-26AEBCA8436D}"
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "XlsFormat", "..\source\win32\XlsFormat.vcproj", "{77DDC8D7-5B12-4FF2-9629-26AEBCA8436D}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "XlsXlsxConverter", "..\source\win32\XlsXlsxConverter.vcproj", "{CBEDD0D1-10A8-45C1-AF81-8492F40964CA}"
ProjectSection(ProjectDependencies) = postProject
{77DDC8D7-5B12-4FF2-9629-26AEBCA8436D} = {77DDC8D7-5B12-4FF2-9629-26AEBCA8436D}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ASCOfficeXlsFileTest", "ASCOfficeXlsFileTest\ASCOfficeXlsFileTest.vcproj", "{C2882DDD-07E6-4314-AD4B-48F43F38D722}"
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ASCOfficeXlsFileTest", "..\ASCOfficeXlsFileTest\ASCOfficeXlsFileTest.vcproj", "{C2882DDD-07E6-4314-AD4B-48F43F38D722}"
ProjectSection(ProjectDependencies) = postProject
{4260FEDF-E1DA-447F-991B-62F17DF5533E} = {4260FEDF-E1DA-447F-991B-62F17DF5533E}
EndProjectSection
......@@ -16,21 +21,43 @@ EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Release|Win32 = Release|Win32
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{4260FEDF-E1DA-447F-991B-62F17DF5533E}.Debug|Win32.ActiveCfg = Debug|Win32
{4260FEDF-E1DA-447F-991B-62F17DF5533E}.Debug|Win32.Build.0 = Debug|Win32
{4260FEDF-E1DA-447F-991B-62F17DF5533E}.Debug|x64.ActiveCfg = Debug|x64
{4260FEDF-E1DA-447F-991B-62F17DF5533E}.Debug|x64.Build.0 = Debug|x64
{4260FEDF-E1DA-447F-991B-62F17DF5533E}.Release|Win32.ActiveCfg = Release|Win32
{4260FEDF-E1DA-447F-991B-62F17DF5533E}.Release|Win32.Build.0 = Release|Win32
{4260FEDF-E1DA-447F-991B-62F17DF5533E}.Release|x64.ActiveCfg = Release|x64
{4260FEDF-E1DA-447F-991B-62F17DF5533E}.Release|x64.Build.0 = Release|x64
{77DDC8D7-5B12-4FF2-9629-26AEBCA8436D}.Debug|Win32.ActiveCfg = Debug|Win32
{77DDC8D7-5B12-4FF2-9629-26AEBCA8436D}.Debug|Win32.Build.0 = Debug|Win32
{77DDC8D7-5B12-4FF2-9629-26AEBCA8436D}.Debug|x64.ActiveCfg = Debug|x64
{77DDC8D7-5B12-4FF2-9629-26AEBCA8436D}.Debug|x64.Build.0 = Debug|x64
{77DDC8D7-5B12-4FF2-9629-26AEBCA8436D}.Release|Win32.ActiveCfg = Release|Win32
{77DDC8D7-5B12-4FF2-9629-26AEBCA8436D}.Release|Win32.Build.0 = Release|Win32
{77DDC8D7-5B12-4FF2-9629-26AEBCA8436D}.Release|x64.ActiveCfg = Release|x64
{77DDC8D7-5B12-4FF2-9629-26AEBCA8436D}.Release|x64.Build.0 = Release|x64
{CBEDD0D1-10A8-45C1-AF81-8492F40964CA}.Debug|Win32.ActiveCfg = Debug|Win32
{CBEDD0D1-10A8-45C1-AF81-8492F40964CA}.Debug|Win32.Build.0 = Debug|Win32
{CBEDD0D1-10A8-45C1-AF81-8492F40964CA}.Debug|x64.ActiveCfg = Debug|x64
{CBEDD0D1-10A8-45C1-AF81-8492F40964CA}.Debug|x64.Build.0 = Debug|x64
{CBEDD0D1-10A8-45C1-AF81-8492F40964CA}.Release|Win32.ActiveCfg = Release|Win32
{CBEDD0D1-10A8-45C1-AF81-8492F40964CA}.Release|Win32.Build.0 = Release|Win32
{CBEDD0D1-10A8-45C1-AF81-8492F40964CA}.Release|x64.ActiveCfg = Release|x64
{CBEDD0D1-10A8-45C1-AF81-8492F40964CA}.Release|x64.Build.0 = Release|x64
{C2882DDD-07E6-4314-AD4B-48F43F38D722}.Debug|Win32.ActiveCfg = Debug|Win32
{C2882DDD-07E6-4314-AD4B-48F43F38D722}.Debug|Win32.Build.0 = Debug|Win32
{C2882DDD-07E6-4314-AD4B-48F43F38D722}.Debug|x64.ActiveCfg = Debug|x64
{C2882DDD-07E6-4314-AD4B-48F43F38D722}.Debug|x64.Build.0 = Debug|x64
{C2882DDD-07E6-4314-AD4B-48F43F38D722}.Release|Win32.ActiveCfg = Release|Win32
{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
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......
......@@ -4,12 +4,16 @@
Version="8,00"
Name="ASCOfficeXlsFile2"
ProjectGUID="{4260FEDF-E1DA-447F-991B-62F17DF5533E}"
RootNamespace="ASCOfficeXlsFile2"
Keyword="AtlProj"
>
<Platforms>
<Platform
Name="Win32"
/>
<Platform
Name="x64"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
......@@ -201,6 +205,191 @@
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Debug|x64"
OutputDirectory="$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="2"
UseOfATL="2"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="_DEBUG"
MkTypLibCompatible="false"
TargetEnvironment="3"
GenerateStublessProxies="true"
TypeLibraryName="$(IntDir)/ASCOfficeXlsFile2.tlb"
HeaderFileName="ASCOfficeXlsFile2.h"
DLLDataFileName=""
InterfaceIdentifierFileName="ASCOfficeXlsFile2_i.c"
ProxyFileName="ASCOfficeXlsFile2_p.c"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="XlsFormat; source/XlsFormat"
PreprocessorDefinitions="WIN32;_WINDOWS;_DEBUG;_USRDLL;_ATL_ATTRIBUTES;STANDALONE_USE=1"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="2"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1033"
AdditionalIncludeDirectories="$(IntDir)"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
RegisterOutput="true"
IgnoreImportLibrary="true"
LinkIncremental="2"
MergedIDLBaseFileName="_ASCOfficeXlsFile2.idl"
GenerateDebugInformation="true"
SubSystem="2"
TargetMachine="17"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|x64"
OutputDirectory="$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="2"
UseOfATL="2"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="false"
TargetEnvironment="3"
GenerateStublessProxies="true"
TypeLibraryName="$(IntDir)/ASCOfficeXlsFile2.tlb"
HeaderFileName="ASCOfficeXlsFile2.h"
DLLDataFileName=""
InterfaceIdentifierFileName="ASCOfficeXlsFile2_i.c"
ProxyFileName="ASCOfficeXlsFile2_p.c"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
PreprocessorDefinitions="WIN32;_WINDOWS;NDEBUG;_USRDLL;_ATL_ATTRIBUTES;STANDALONE_USE=0"
RuntimeLibrary="2"
UsePrecompiledHeader="2"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"
AdditionalIncludeDirectories="$(IntDir)"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
RegisterOutput="true"
IgnoreImportLibrary="true"
LinkIncremental="1"
MergedIDLBaseFileName="_ASCOfficeXlsFile2.idl"
GenerateDebugInformation="true"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="17"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
......@@ -214,10 +403,6 @@
RelativePath=".\ASCOfficeXlsFile2.cpp"
>
</File>
<File
RelativePath=".\source\ConvertXls2Xlsx.cpp"
>
</File>
<File
RelativePath=".\OfficeXlsFile.cpp"
>
......@@ -241,6 +426,22 @@
UsePrecompiledHeader="1"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|x64"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|x64"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
/>
</FileConfiguration>
</File>
</Filter>
<Filter
......
......@@ -16,7 +16,7 @@
#include <boost/lexical_cast.hpp>
#include "../Common/boost_filesystem_version.h"
#include "source/ConvertXls2Xlsx.h"
#include "../source/XlsXlsxConverter/ConvertXls2Xlsx.h"
#include "../Common/XmlUtils.h"
#include "../Common/ASCATLError.h"
......
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