Files
core/ASCOfficeXlsFile2/source/Serializer/XMLSerializer.cpp
Elen.Subbotina 29c989e784 чтение xls файлов
git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@58816 954022d7-b5bf-4e40-9824-e11837661b57
2016-05-20 23:19:50 +03:00

35 lines
830 B
C++

#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