Commit 3471ee97 authored by Elen.Subbotina's avatar Elen.Subbotina Committed by Alexander Trofimov

git-svn-id:...

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@54638 954022d7-b5bf-4e40-9824-e11837661b57
parent a57ed797
......@@ -21,15 +21,18 @@
#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;
}
// - 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"";
}
STDMETHODIMP COfficeOdfFileW::LoadFromFile(BSTR sSrcFileName, BSTR sDstPath, BSTR sXMLOptions)
{
......@@ -90,7 +93,7 @@ STDMETHODIMP COfficeOdfFileW::SaveToFile(BSTR sDstFileName, BSTR sSrcPath, BSTR
boost::filesystem::create_directory(srcTempPath); //
#endif
hr = SaveToFileImpl(CString(sSrcPath), CString(srcTempPath.string().c_str()), CString(dstTempPath.string().c_str()), CString(sDstFileName));
hr = SaveToFileImpl(bstr2wstring(sSrcPath),srcTempPath.string(), dstTempPath.string(), bstr2wstring(sDstFileName));
}
catch(...)
......@@ -121,23 +124,24 @@ STDMETHODIMP COfficeOdfFileW::SaveToFile(BSTR sDstFileName, BSTR sSrcPath, BSTR
return hr;
}
HRESULT COfficeOdfFileW::SaveToFileImpl(const CString & srcPath,
const CString & srcTempPath,
const CString & dstTempPath,
const CString & dstFileName)
HRESULT COfficeOdfFileW::SaveToFileImpl(const std::wstring & srcPath,
const std::wstring & srcTempPath,
const std::wstring & dstTempPath,
const std::wstring & dstFileName)
{
HRESULT hr = E_FAIL;
// ( )
#if defined(STANDALONE_USE) && (STANDALONE_USE == 1)
if FAILED(hr = office_utils_->ExtractToDirectory(CComBSTR(srcPath), CComBSTR(srcTempPath), NULL, 0))
if FAILED(hr = office_utils_->ExtractToDirectory(CComBSTR(srcPath.c_str()), CComBSTR(srcTempPath.c_str()), NULL, 0))
return hr;
#endif
try
{
Oox2Odf::Converter converter(srcTempPath);
std::wstring type = L"spreadsheet";
Oox2Odf::Converter converter(srcTempPath,type);
converter.convert();
converter.write(dstTempPath);
......@@ -149,7 +153,7 @@ HRESULT COfficeOdfFileW::SaveToFileImpl(const CString & srcPath,
if FAILED(hr)
return hr;
if FAILED(hr = office_utils_->CompressFileOrDirectory(CComBSTR(dstTempPath), CComBSTR(dstFileName), (-1)))
if FAILED(hr = office_utils_->CompressFileOrDirectory(CComBSTR(dstTempPath.c_str()), CComBSTR(dstFileName.c_str()), (-1)))
return hr;
return S_OK;
......
......@@ -85,8 +85,8 @@ private:
bool initialized();
HRESULT SaveToFileImpl(const CString & srcPath, const CString & srcTempPath,
const CString & dstTempPath, const CString & dstFileName);
HRESULT SaveToFileImpl(const std::wstring & srcPath, const std::wstring & srcTempPath,
const std::wstring & dstTempPath, const std::wstring & dstFileName);
};
......@@ -40,7 +40,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\ASCOfficeOdfFile\include"
AdditionalIncludeDirectories="..\..\ASCOfficeOdfFile\include;..\..\ASCOfficeOdfFile\3dparty\utf8cpp\include"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
MinimalRebuild="true"
BasicRuntimeChecks="3"
......
......@@ -35,6 +35,11 @@ namespace odf
}
////////////
content_content_ptr content_content::create()
{
return boost::make_shared<content_content>();
}
///////////////
void manifect_file::add_rels(rels & r)
{
BOOST_FOREACH(relationship & item, r.relationships())
......@@ -252,6 +257,66 @@ namespace odf
if (settings_) settings_->write(RootPath);
}
void content_file::write(const std::wstring & RootPath)
{
std::wstringstream resStream;
CP_XML_WRITER(resStream)
{
CP_XML_NODE(L"office:document-content")
{
CP_XML_ATTR(L"xmlns:office",L"urn:oasis:names:tc:opendocument:xmlns:office:1.0" );
CP_XML_ATTR(L"xmlns:style", L"urn:oasis:names:tc:opendocument:xmlns:style:1.0" );
CP_XML_ATTR(L"xmlns:text", L"urn:oasis:names:tc:opendocument:xmlns:text:1.0" );
CP_XML_ATTR(L"xmlns:table", L"urn:oasis:names:tc:opendocument:xmlns:table:1.0" );
CP_XML_ATTR(L"xmlns:draw", L"urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" );
CP_XML_ATTR(L"xmlns:fo", L"urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" );
CP_XML_ATTR(L"xmlns:xlink", L"http://www.w3.org/1999/xlink" );
CP_XML_ATTR(L"xmlns:dc", L"http://purl.org/dc/elements/1.1/" );
CP_XML_ATTR(L"xmlns:meta", L"urn:oasis:names:tc:opendocument:xmlns:meta:1.0" );
CP_XML_ATTR(L"xmlns:number",L"urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" );
CP_XML_ATTR(L"xmlns:presentation", L"urn:oasis:names:tc:opendocument:xmlns:presentation:1.0" );
CP_XML_ATTR(L"xmlns:svg", L"urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0");
CP_XML_ATTR(L"xmlns:chart", L"urn:oasis:names:tc:opendocument:xmlns:chart:1.0" );
CP_XML_ATTR(L"xmlns:dr3d", L"urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" );
CP_XML_ATTR(L"xmlns:math", L"http://www.w3.org/1998/Math/MathML" );
CP_XML_ATTR(L"xmlns:form", L"urn:oasis:names:tc:opendocument:xmlns:form:1.0" );
CP_XML_ATTR(L"xmlns:script", L"urn:oasis:names:tc:opendocument:xmlns:script:1.0" );
CP_XML_ATTR(L"xmlns:ooo", L"http://openoffice.org/2004/office" );
CP_XML_ATTR(L"xmlns:ooow", L"http://openoffice.org/2004/writer" );
CP_XML_ATTR(L"xmlns:oooc", L"http://openoffice.org/2004/calc" );
CP_XML_ATTR(L"xmlns:dom", L"http://www.w3.org/2001/xml-events" );
CP_XML_ATTR(L"xmlns:xforms",L"http://www.w3.org/2002/xforms");
CP_XML_ATTR(L"xmlns:xsd", L"http://www.w3.org/2001/XMLSchema" );
CP_XML_ATTR(L"xmlns:xsi", L"http://www.w3.org/2001/XMLSchema-instance" );
CP_XML_ATTR(L"xmlns:rpt", L"http://openoffice.org/2005/report" );
CP_XML_ATTR(L"xmlns:of", L"urn:oasis:names:tc:opendocument:xmlns:of:1.2" );
CP_XML_ATTR(L"xmlns:xhtml", L"http://www.w3.org/1999/xhtml" );
CP_XML_ATTR(L"xmlns:grddl", L"http://www.w3.org/2003/g/data-view#" );
CP_XML_ATTR(L"xmlns:tableooo", L"http://openoffice.org/2009/table" );
CP_XML_ATTR(L"xmlns:drawooo", L"http://openoffice.org/2010/draw" );
CP_XML_ATTR(L"xmlns:calcext", L"urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" );
CP_XML_ATTR(L"xmlns:field", L"urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" );
CP_XML_ATTR(L"xmlns:formx", L"urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0" );
CP_XML_ATTR(L"xmlns:css3t", L"http://www.w3.org/TR/css3-text/" );
CP_XML_ATTR(L"office:version", L"1.2");
CP_XML_NODE(L"office:scripts");
CP_XML_NODE(L"office:font-face-decls");
CP_XML_NODE(L"office:automatic-styles");
CP_XML_NODE(L"office:boby")
{
if (content_)
{
CP_XML_STREAM() << content_->str();
}
}
}
}
simple_element elm(L"content.xml", resStream.str());
elm.write(RootPath);
}
}
}
......
......@@ -26,7 +26,7 @@ namespace odf
class content_content : noncopyable
{
public:
content_content();
content_content(){}
std::wostream & content() { return content_; }
std::wstring str() { return content_.str(); }
static _CP_PTR(content_content) create();
......@@ -35,8 +35,6 @@ namespace odf
std::wstringstream content_;
};
//class element;
class element
{
public:
......
......@@ -40,7 +40,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=".\OdfFormat;.\Oox2OdfConverter;..\..\Common\DocxFormat\Source;..\..\Common\DocxFormat\Source\XML"
AdditionalIncludeDirectories=".\OdfFormat;.\Oox2OdfConverter;..\..\Common\DocxFormat\Source;..\..\Common\DocxFormat\Source\XML;..\..\ASCOfficeOdfFile\include;..\..\ASCOfficeOdfFile\3dparty\utf8cpp\include"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_USE_XMLLITE_READER_"
MinimalRebuild="true"
BasicRuntimeChecks="3"
......@@ -103,7 +103,7 @@
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=".\OdfFormat;.\Oox2OdfConverter;..\..\Common\DocxFormat\Source;..\..\Common\DocxFormat\Source\XML"
AdditionalIncludeDirectories=".\OdfFormat;.\Oox2OdfConverter;..\..\Common\DocxFormat\Source;..\..\Common\DocxFormat\Source\XML;..\..\ASCOfficeOdfFile\include;..\..\ASCOfficeOdfFile\3dparty\utf8cpp\include"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_USE_XMLLITE_READER_"
RuntimeLibrary="2"
UsePrecompiledHeader="2"
......
......@@ -10,26 +10,26 @@
#include "odf_conversion_context.h"
using namespace cpdoccore;
namespace Oox2Odf
{
class Impl
{
friend class Converter;
public:
Impl(const CString & path)
Impl(const std::wstring & path,const std::wstring & type) : output_document(type)
{
const OOX::CPath oox_path(path);
m_input_docx =0;
m_input_xlsx =0;
int type = 1; //get type oox ????
const OOX::CPath oox_path(CString(path.c_str()));
docx_document =0;
xlsx_document =0;
if (type == 1)
if (type == L"text")
{
docx_document = new OOX::CDocx(oox_path);
}
if (type == 2)
if (type == L"spreadsheet")
{
xlsx_document = new OOX::Spreadsheet::CXlsx(oox_path);
}
......@@ -38,28 +38,24 @@ namespace Oox2Odf
public:
void convert(/*Odt::IOdtEvent& Event*/);
void write(const CString & path);
void write(const std::wstring & path);
private:
OOX::CDocx *docx_document;
OOX::Spreadsheet::CXlsx *xlsx_document;
package::odf_document outputDocument;
//Odf::Folder m_output; //odf_document
odf::package::odf_document output_document;
};
void Impl::write(const CString & path)
void Impl::write(const std::wstring & path)
{
outputDocument.write(path);
output_document.write(path);
}
void Impl::convert()
{
odf_conversion_context odf_conversion_context_(&outputDocument);
odf::odf_conversion_context odf_conversion_context_(&output_document);
if (docx_document)
{
......@@ -79,13 +75,13 @@ namespace Oox2Odf
if (document)
{
odf_conversion_context_.start_documet();
odf_conversion_context_.start_document();
document->m_oSheets;
//odf_context.convert(document); - odf
//...
odf_conversion_context_.end_documet();
odf_conversion_context_.end_document();
}
}
}
......@@ -93,9 +89,9 @@ namespace Oox2Odf
///////////////
Converter::Converter(const CString & path)
Converter::Converter(const std::wstring & path, const std::wstring & type)
{
impl_ = new Impl(path);
impl_ = new Impl(path,type);
}
Converter::~Converter()
{
......@@ -106,7 +102,7 @@ namespace Oox2Odf
if (!impl_)return;
impl_->convert(/*Event*/);
}
void Converter::write(const CString & path) const
void Converter::write(const std::wstring & path) const
{
return impl_->write(path);
}
......
......@@ -9,13 +9,13 @@ namespace Oox2Odf
{
public:
Converter(const CString & path);
Converter(const std::wstring & path, const std::wstring & type);
virtual ~Converter();
public:
void convert();
void write(const CString & path) const;
void write(const std::wstring & path) const;
Impl * get_impl() { return impl_; }
......
......@@ -2,6 +2,6 @@
//1
//0
//2
//5
#define INTVER 1,0,2,5
#define STRVER "1,0,2,5\0"
//23
#define INTVER 1,0,2,23
#define STRVER "1,0,2,23\0"
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