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 @@ ...@@ -21,15 +21,18 @@
#endif #endif
// - uuid // - uuid
boost::filesystem::wpath MakeTempDirectoryName(const std::wstring& Dst) boost::filesystem::wpath MakeTempDirectoryName(const std::wstring& Dst)
{ {
boost::uuids::random_generator gen; boost::uuids::random_generator gen;
boost::uuids::uuid u = gen(); boost::uuids::uuid u = gen();
boost::filesystem::wpath path = boost::filesystem::wpath(Dst) / boost::lexical_cast<std::wstring>(u); boost::filesystem::wpath path = boost::filesystem::wpath(Dst) / boost::lexical_cast<std::wstring>(u);
return path; 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) STDMETHODIMP COfficeOdfFileW::LoadFromFile(BSTR sSrcFileName, BSTR sDstPath, BSTR sXMLOptions)
{ {
...@@ -90,7 +93,7 @@ STDMETHODIMP COfficeOdfFileW::SaveToFile(BSTR sDstFileName, BSTR sSrcPath, BSTR ...@@ -90,7 +93,7 @@ STDMETHODIMP COfficeOdfFileW::SaveToFile(BSTR sDstFileName, BSTR sSrcPath, BSTR
boost::filesystem::create_directory(srcTempPath); // boost::filesystem::create_directory(srcTempPath); //
#endif #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(...) catch(...)
...@@ -121,23 +124,24 @@ STDMETHODIMP COfficeOdfFileW::SaveToFile(BSTR sDstFileName, BSTR sSrcPath, BSTR ...@@ -121,23 +124,24 @@ STDMETHODIMP COfficeOdfFileW::SaveToFile(BSTR sDstFileName, BSTR sSrcPath, BSTR
return hr; return hr;
} }
HRESULT COfficeOdfFileW::SaveToFileImpl(const CString & srcPath, HRESULT COfficeOdfFileW::SaveToFileImpl(const std::wstring & srcPath,
const CString & srcTempPath, const std::wstring & srcTempPath,
const CString & dstTempPath, const std::wstring & dstTempPath,
const CString & dstFileName) const std::wstring & dstFileName)
{ {
HRESULT hr = E_FAIL; HRESULT hr = E_FAIL;
// ( ) // ( )
#if defined(STANDALONE_USE) && (STANDALONE_USE == 1) #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; return hr;
#endif #endif
try try
{ {
Oox2Odf::Converter converter(srcTempPath); std::wstring type = L"spreadsheet";
Oox2Odf::Converter converter(srcTempPath,type);
converter.convert(); converter.convert();
converter.write(dstTempPath); converter.write(dstTempPath);
...@@ -149,7 +153,7 @@ HRESULT COfficeOdfFileW::SaveToFileImpl(const CString & srcPath, ...@@ -149,7 +153,7 @@ HRESULT COfficeOdfFileW::SaveToFileImpl(const CString & srcPath,
if FAILED(hr) if FAILED(hr)
return 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 hr;
return S_OK; return S_OK;
......
...@@ -85,8 +85,8 @@ private: ...@@ -85,8 +85,8 @@ private:
bool initialized(); bool initialized();
HRESULT SaveToFileImpl(const CString & srcPath, const CString & srcTempPath, HRESULT SaveToFileImpl(const std::wstring & srcPath, const std::wstring & srcTempPath,
const CString & dstTempPath, const CString & dstFileName); const std::wstring & dstTempPath, const std::wstring & dstFileName);
}; };
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
<Tool <Tool
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
Optimization="0" Optimization="0"
AdditionalIncludeDirectories="..\..\ASCOfficeOdfFile\include" AdditionalIncludeDirectories="..\..\ASCOfficeOdfFile\include;..\..\ASCOfficeOdfFile\3dparty\utf8cpp\include"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB" PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
MinimalRebuild="true" MinimalRebuild="true"
BasicRuntimeChecks="3" BasicRuntimeChecks="3"
......
...@@ -35,6 +35,11 @@ namespace odf ...@@ -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) void manifect_file::add_rels(rels & r)
{ {
BOOST_FOREACH(relationship & item, r.relationships()) BOOST_FOREACH(relationship & item, r.relationships())
...@@ -252,6 +257,66 @@ namespace odf ...@@ -252,6 +257,66 @@ namespace odf
if (settings_) settings_->write(RootPath); 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 ...@@ -26,7 +26,7 @@ namespace odf
class content_content : noncopyable class content_content : noncopyable
{ {
public: public:
content_content(); content_content(){}
std::wostream & content() { return content_; } std::wostream & content() { return content_; }
std::wstring str() { return content_.str(); } std::wstring str() { return content_.str(); }
static _CP_PTR(content_content) create(); static _CP_PTR(content_content) create();
...@@ -35,8 +35,6 @@ namespace odf ...@@ -35,8 +35,6 @@ namespace odf
std::wstringstream content_; std::wstringstream content_;
}; };
//class element;
class element class element
{ {
public: public:
......
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
<Tool <Tool
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
Optimization="0" 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_" PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_USE_XMLLITE_READER_"
MinimalRebuild="true" MinimalRebuild="true"
BasicRuntimeChecks="3" BasicRuntimeChecks="3"
...@@ -103,7 +103,7 @@ ...@@ -103,7 +103,7 @@
/> />
<Tool <Tool
Name="VCCLCompilerTool" 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_" PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_USE_XMLLITE_READER_"
RuntimeLibrary="2" RuntimeLibrary="2"
UsePrecompiledHeader="2" UsePrecompiledHeader="2"
......
...@@ -10,26 +10,26 @@ ...@@ -10,26 +10,26 @@
#include "odf_conversion_context.h" #include "odf_conversion_context.h"
using namespace cpdoccore;
namespace Oox2Odf namespace Oox2Odf
{ {
class Impl class Impl
{ {
friend class Converter; friend class Converter;
public: public:
Impl(const CString & path) Impl(const std::wstring & path,const std::wstring & type) : output_document(type)
{ {
const OOX::CPath oox_path(path); const OOX::CPath oox_path(CString(path.c_str()));
m_input_docx =0;
m_input_xlsx =0;
int type = 1; //get type oox ???? docx_document =0;
xlsx_document =0;
if (type == 1) if (type == L"text")
{ {
docx_document = new OOX::CDocx(oox_path); docx_document = new OOX::CDocx(oox_path);
} }
if (type == 2) if (type == L"spreadsheet")
{ {
xlsx_document = new OOX::Spreadsheet::CXlsx(oox_path); xlsx_document = new OOX::Spreadsheet::CXlsx(oox_path);
} }
...@@ -38,28 +38,24 @@ namespace Oox2Odf ...@@ -38,28 +38,24 @@ namespace Oox2Odf
public: public:
void convert(/*Odt::IOdtEvent& Event*/); void convert(/*Odt::IOdtEvent& Event*/);
void write(const CString & path); void write(const std::wstring & path);
private: private:
OOX::CDocx *docx_document; OOX::CDocx *docx_document;
OOX::Spreadsheet::CXlsx *xlsx_document; OOX::Spreadsheet::CXlsx *xlsx_document;
package::odf_document outputDocument; odf::package::odf_document output_document;
//Odf::Folder m_output; //odf_document
}; };
void Impl::write(const CString & path) void Impl::write(const std::wstring & path)
{ {
outputDocument.write(path); output_document.write(path);
} }
void Impl::convert() void Impl::convert()
{ {
odf_conversion_context odf_conversion_context_(&outputDocument); odf::odf_conversion_context odf_conversion_context_(&output_document);
if (docx_document) if (docx_document)
{ {
...@@ -79,13 +75,13 @@ namespace Oox2Odf ...@@ -79,13 +75,13 @@ namespace Oox2Odf
if (document) if (document)
{ {
odf_conversion_context_.start_documet(); odf_conversion_context_.start_document();
document->m_oSheets; document->m_oSheets;
//odf_context.convert(document); - odf //odf_context.convert(document); - odf
//... //...
odf_conversion_context_.end_documet(); odf_conversion_context_.end_document();
} }
} }
} }
...@@ -93,9 +89,9 @@ namespace Oox2Odf ...@@ -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() Converter::~Converter()
{ {
...@@ -106,7 +102,7 @@ namespace Oox2Odf ...@@ -106,7 +102,7 @@ namespace Oox2Odf
if (!impl_)return; if (!impl_)return;
impl_->convert(/*Event*/); impl_->convert(/*Event*/);
} }
void Converter::write(const CString & path) const void Converter::write(const std::wstring & path) const
{ {
return impl_->write(path); return impl_->write(path);
} }
......
...@@ -9,13 +9,13 @@ namespace Oox2Odf ...@@ -9,13 +9,13 @@ namespace Oox2Odf
{ {
public: public:
Converter(const CString & path); Converter(const std::wstring & path, const std::wstring & type);
virtual ~Converter(); virtual ~Converter();
public: public:
void convert(); void convert();
void write(const CString & path) const; void write(const std::wstring & path) const;
Impl * get_impl() { return impl_; } Impl * get_impl() { return impl_; }
......
...@@ -2,6 +2,6 @@ ...@@ -2,6 +2,6 @@
//1 //1
//0 //0
//2 //2
//5 //23
#define INTVER 1,0,2,5 #define INTVER 1,0,2,23
#define STRVER "1,0,2,5\0" #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