Commit a57ed797 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@54635 954022d7-b5bf-4e40-9824-e11837661b57
parent 7a5f3560
......@@ -105,7 +105,7 @@
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="..\..\ASCOfficeOdfFile\include"
AdditionalIncludeDirectories="..\..\ASCOfficeOdfFile\include;..\..\ASCOfficeOdfFile\3dparty\utf8cpp\include"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
......@@ -823,28 +823,64 @@
>
</File>
</Filter>
<Filter
Name="package"
>
<File
RelativePath=".\OdfFormat\mediaitems.cpp"
>
</File>
<File
RelativePath=".\OdfFormat\mediaitems.h"
>
</File>
<File
RelativePath=".\OdfFormat\mediaitems_utils.cpp"
>
</File>
<File
RelativePath=".\OdfFormat\mediaitems_utils.h"
>
</File>
<File
RelativePath=".\OdfFormat\object_package.cpp"
>
</File>
<File
RelativePath=".\OdfFormat\object_package.h"
>
</File>
<File
RelativePath=".\OdfFormat\odf_rels.cpp"
>
</File>
<File
RelativePath=".\OdfFormat\odf_rels.h"
>
</File>
</Filter>
<File
RelativePath=".\OdfFormat\office_elements.h"
RelativePath=".\OdfFormat\odf_conversion_context.cpp"
>
</File>
<File
RelativePath=".\OdfFormat\office_elements_create.cpp"
RelativePath=".\OdfFormat\odf_conversion_context.h"
>
</File>
<File
RelativePath=".\OdfFormat\office_elements_create.h"
RelativePath=".\OdfFormat\office_elements.h"
>
</File>
<File
RelativePath=".\ReadMe.txt"
RelativePath=".\OdfFormat\office_elements_create.cpp"
>
</File>
<File
RelativePath=".\OdfFormat\skipelement.cpp"
RelativePath=".\OdfFormat\office_elements_create.h"
>
</File>
<File
RelativePath=".\OdfFormat\skipelement.h"
RelativePath=".\ReadMe.txt"
>
</File>
</Files>
......
#include "precompiled_cpodf.h"
#include "mediaitems.h"
#include "odf_rels.h"
#include <regex.h>
#include <boost/filesystem.hpp>
#include <boost/foreach.hpp>
#include <boost/algorithm/string/case_conv.hpp>
#include <cpdoccore/xml/utils.h>
#include "mediaitems_utils.h"
#include <cpdoccore/common/boost_filesystem_version.h>
namespace cpdoccore {
namespace odf {
using boost::filesystem::wpath;
mediaitems::item::item( std::wstring const & _href,
Type _type,
std::wstring const & _outputName
)
: href(_href),
type(_type),
outputName(_outputName)
{
}
namespace fs = boost::filesystem;
void mediaitems::add_or_find(const std::wstring & href, Type type, std::wstring & ref)
{
std::wstring sub_path;//
std::wstring inputFileName;
int number=0;
if (type == typeImage)
{
sub_path = L"Pictures/";
number= count_image+1;
}
else
{
sub_path = L"Media/";
number= count_media+1;
}
inputFileName = utils::media::create_file_name(href, type, number);//guid???
std::wstring inputPath = BOOST_STRING_PATH(wpath(oox_packet_) / href);
std::wstring outputPath ;
std::wstring id;
BOOST_FOREACH(item const & elm, items_)
{
if (elm.href == inputPath)
{
outputPath = elm.outputName;
break;
}
}
if (outputPath .length() < 1)
{
outputPath = ( sub_path + inputFileName) ;
if ( type == typeImage)
{
fs::wpath file_name = fs::wpath(inputPath);
if (file_name.extension() == L".svm" || file_name.extension().empty())
{
outputPath = outputPath + L".png";
}
count_image++;
}
items_.push_back( item(inputPath, type, xml::utils::replace_text_to_xml(outputPath)) );
}
ref = outputPath;
}
void mediaitems::dump_rels(rels & Rels)
{
size_t i = 0;
BOOST_FOREACH(item & elm, items_)
{
Rels.add( relationship(
utils::media::get_rel_type(elm.type),
elm.outputName)
);
}
}
}
}
#pragma once
#include <vector>
#include <string>
namespace cpdoccore {
namespace odf {
class rels;
class mediaitems
{
public:
enum Type { typeUnknown = 0, typeImage, typeAudio, typeVideo};
//oleObject ???
mediaitems(const std::wstring & ooxPacket) : oox_packet_(ooxPacket)
{
count_image =0;
count_media =0;
}
struct item
{
item(
std::wstring const & _href,
Type _type,
std::wstring const & _outputName);
std::wstring href;
Type type;
std::wstring outputName;
};
typedef std::vector< item > items_array;
size_t count_image;
size_t count_media;
void add_or_find(const std::wstring & href, Type type, std::wstring & ref);
void dump_rels(rels & Rels);
items_array & items() { return items_; }
private:
items_array items_;
std::wstring oox_packet_;
};
}
}
#include "precompiled_cpodf.h"
#include "mediaitems_utils.h"
#include <boost/filesystem.hpp>
#include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp>
#include <cpdoccore/common/boost_filesystem_version.h>
namespace cpdoccore {
namespace odf{
namespace utils {
namespace media {
using boost::filesystem::wpath;
std::wstring get_rel_type(mediaitems::Type type)
{
switch (type)
{
case mediaitems::typeImage:
return L"";
default:
return L"";
}
}
std::wstring get_default_file_name(mediaitems::Type type)
{
switch (type)
{
case mediaitems::typeImage:
return L"image";
default:
return L"";
}
}
std::wstring create_file_name(const std::wstring & uri, mediaitems::Type type, size_t Num)
{
#ifdef BOOST_FILESYSTEM_LEGACY
return get_default_file_name(type) + boost::lexical_cast<std::wstring>(Num) + wpath(uri).extension();
#else
return get_default_file_name(type) + boost::lexical_cast<std::wstring>(Num) + wpath(uri).extension().string<std::wstring>();
#endif
}
}
}
}
}
#pragma once
#include <string>
#include "mediaitems.h"
namespace cpdoccore {
namespace odf {
namespace utils {
namespace media {
std::wstring create_file_name(const std::wstring & uri, mediaitems::Type type, size_t Num);
std::wstring get_rel_type(mediaitems::Type type);
}
}
}
}
#include "precompiled_cpodf.h"
#include <boost/foreach.hpp>
#include <boost/filesystem/fstream.hpp>
#include <utf8cpp/utf8.h>
#include <cpdoccore/common/boost_filesystem_version.h>
#include <cpdoccore/xml/simple_xml_writer.h>
#include "object_package.h"
#include "mediaitems.h"
namespace cpdoccore
{
namespace odf
{
namespace package
{
namespace fs = boost::filesystem;
simple_element::simple_element(const std::wstring & FileName, const std::wstring & Content) : file_name_(FileName)
{
utf8::utf16to8(Content.begin(), Content.end(), std::back_inserter(content_utf8_));
}
void simple_element::write(const std::wstring & RootPath)
{
fs::ofstream file( fs::wpath(RootPath) / file_name_, std::ios_base::out | std::ios_base::binary );
file << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
file << content_utf8_;
}
element_ptr simple_element::create(const std::wstring & FileName, const std::wstring & Content)
{
return boost::make_shared<simple_element>(FileName, Content);
}
////////////
void manifect_file::add_rels(rels & r)
{
BOOST_FOREACH(relationship & item, r.relationships())
{
rels_.add(item);
}
}
manifect_file::manifect_file(std::wstring t)
{
type_ = t;
}
mimetype_file::mimetype_file(std::wstring t)
{
type_ = t;
}
void mimetype_file::write(const std::wstring & RootPath)
{
std::wstringstream resStream;
resStream << L"application/vnd.oasis.opendocument.";
resStream << type_;
simple_element elm(L"mimetype", resStream.str());
elm.write(RootPath);
}
void manifect_file::write(const std::wstring & RootPath)
{
std::wstringstream resStream;
CP_XML_WRITER(resStream)
{
CP_XML_NODE(L"manifest:manifest")
{
CP_XML_ATTR(L"xmlns:manifest", L"urn:oasis:names:tc:opendocument:xmlns:manifest:1.0");
CP_XML_NODE(L"manifest:file-entry")
{
CP_XML_ATTR(L"manifest:full-path", L"/");
CP_XML_ATTR(L"manifest:media-type", std::wstring(L"application/vnd.oasis.opendocument.") + type_);
}
rels_.serialize(CP_XML_STREAM());//
CP_XML_NODE(L"manifest:file-entry")
{
CP_XML_ATTR(L"manifest:full-path", L"content.xml");
CP_XML_ATTR(L"manifest:media-type", L"text/xml");
}
CP_XML_NODE(L"manifest:file-entry")
{
CP_XML_ATTR(L"manifest:full-path", L"styles.xml");
CP_XML_ATTR(L"manifest:media-type", L"text/xml");
}
CP_XML_NODE(L"manifest:file-entry")
{
CP_XML_ATTR(L"manifest:full-path", L"meta.xml");
CP_XML_ATTR(L"manifest:media-type", L"text/xml");
}
}
}
fs::wpath path = fs::wpath(RootPath) / L"META-INF";
fs::create_directory(path);
simple_element elm(L"manifest.xml", resStream.str());
elm.write(path.string());
}
void meta_file::write(const std::wstring & RootPath)
{
std::wstringstream resStream;
CP_XML_WRITER(resStream)
{
CP_XML_NODE(L"office:document-meta")
{
CP_XML_ATTR(L"xmlns:office", L"urn:oasis:names:tc:opendocument:xmlns:office: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:ooo", L"http://openoffice.org/2004/office");
CP_XML_ATTR(L"xmlns:text", L"urn:oasis:names:tc:opendocument:xmlns:text:1.0");
CP_XML_ATTR(L"xmlns:grddl", L"http://www.w3.org/2003/g/data-view#");
CP_XML_ATTR(L"xmlns:presentation", L"urn:oasis:names:tc:opendocument:xmlns:presentation:1.0");
CP_XML_ATTR(L"xmlns:smil", L"urn:oasis:names:tc:opendocument:xmlns:smil-compatible:1.0");
CP_XML_ATTR(L"xmlns:anim", L"urn:oasis:names:tc:opendocument:xmlns:animation:1.0");
CP_XML_NODE(L"office:meta")
{
CP_XML_NODE(L"meta:generator");
CP_XML_NODE(L"meta:initial-creator");
CP_XML_NODE(L"meta:creation-date");
CP_XML_NODE(L"meta:editing-cycles");
CP_XML_NODE(L"meta:editing-duration");
CP_XML_NODE(L"dc:date");
CP_XML_NODE(L"dc:creator");
CP_XML_NODE(L"meta:document-statistic");
}
}
}
simple_element elm(L"meta.xml", resStream.str());
elm.write(RootPath);
}
///////////////////////////
media::media(mediaitems & _Mediaitems) : mediaitems_(_Mediaitems)
{
}
void media::write(const std::wstring & RootPath)
{
if (mediaitems_.count_media )return;
fs::wpath path = fs::wpath(RootPath) / L"media";
fs::create_directory(path);
BOOST_FOREACH( mediaitems::item & item, mediaitems_.items() )
{
if (item.type == mediaitems::typeAudio || item.type == mediaitems::typeVideo)
{
fs::wpath file_name = fs::wpath(item.href);
fs::wpath file_name_out = fs::wpath(RootPath) / item.outputName;
boost::filesystem::copy_file(item.href, file_name_out);
}
}
}
pictures::pictures(mediaitems & _Mediaitems) : mediaitems_(_Mediaitems)
{
}
void pictures::write(const std::wstring & RootPath)//folder by content.xml
{
if (mediaitems_.count_image )return;
fs::wpath path = fs::wpath(RootPath) / L"Pictures";
fs::create_directory(path);
BOOST_FOREACH( mediaitems::item & item, mediaitems_.items() )
{
if (item.type == mediaitems::typeImage )
{
fs::wpath file_name = fs::wpath(item.href);
fs::wpath file_name_out = fs::wpath(RootPath) / item.outputName;
boost::filesystem::copy_file(item.href, file_name_out);
}
}
}
void object_files::set_content(content_content_ptr & _Content)
{
content_.set_content(_Content);
meta_ = element_ptr(new meta_file());
}
void object_files::set_media(mediaitems & _Mediaitems)
{
media_ = element_ptr( new media(_Mediaitems) );
}
void object_files::set_pictures(mediaitems & _Mediaitems)
{
pictures_ = element_ptr( new pictures(_Mediaitems) );
}
void object_files::set_styles(element_ptr Element)
{
styles_ = Element;
}
void object_files::write(const std::wstring & RootPath)
{
content_.write(RootPath);
if (meta_) meta_->write(RootPath);
if (styles_) styles_->write(RootPath);
if (media_) media_->write(RootPath);
if (pictures_) pictures_->write(RootPath);
}
void odf_document::add_object(element_ptr _object,bool root)
{
if (root)base_ = _object;
else objects_.push_back(_object);
}
void odf_document::set_rels(rels & r)
{
(dynamic_cast<manifect_file*>(manifest_.get()))->add_rels(r);
}
odf_document::odf_document(std::wstring type)
{
manifest_ = element_ptr(new manifect_file(type));
mimetype_ = element_ptr(new mimetype_file(type));
}
void odf_document::write(const std::wstring & RootPath)
{
if (base_)base_->write(RootPath);
long count = 0;
BOOST_FOREACH(const element_ptr & item, objects_)
{
std::wstring name = L"Object " + boost::lexical_cast<std::wstring>(++count);
fs::wpath path = fs::wpath(RootPath) / name;
fs::create_directory(path);
item->write(path.string());
}
if (manifest_) manifest_->write(RootPath);
if (settings_) settings_->write(RootPath);
}
}
}
}
#include <vector>
#include <cpdoccore/CPSharedPtr.h>
#include <cpdoccore/CPNoncopyable.h>
#include "odf_rels.h"
namespace cpdoccore
{
namespace odf
{
class mediaitems;//picture & media
class rels;
namespace package
{
class element;
typedef shared_ptr<element>::Type element_ptr;
typedef std::vector<element_ptr> element_ptr_array;
class content_content;
typedef _CP_PTR(content_content) content_content_ptr;
class content_content : noncopyable
{
public:
content_content();
std::wostream & content() { return content_; }
std::wstring str() { return content_.str(); }
static _CP_PTR(content_content) create();
private:
std::wstringstream content_;
};
//class element;
class element
{
public:
virtual ~element() = 0;
//void set_main_document(element * _element) { element_ = _element; }
//document * get_main_document() { return element_; }
virtual void write(const std::wstring & RootPath) = 0;
private:
element * element_;
};
inline element::~element()
{}
class simple_element : public element
{
public:
simple_element(const std::wstring & FileName, const std::wstring & Content);
static element_ptr create(const std::wstring & FileName, const std::wstring & Content);
virtual void write(const std::wstring & RootPath);
private:
std::wstring file_name_;
std::string content_utf8_;
};
class meta_file : public element
{
public:
virtual void write(const std::wstring & RootPath);
};
class content_file : public element
{
public:
void set_content(content_content_ptr & c) {content_ = c;}
virtual void write(const std::wstring & RootPath);
content_content_ptr content_;
};
class styles_file : public element
{
public:
virtual void write(const std::wstring & RootPath);
};
class manifect_file : public element
{
public:
manifect_file(std::wstring type);
virtual void write(const std::wstring & RootPath);
void add_rels(rels & r);
private:
rels rels_;
std::wstring type_;
};
class mimetype_file : public element
{
public:
mimetype_file(std::wstring type);
virtual void write(const std::wstring & RootPath);
private:
std::wstring type_;
};
class media : public element
{
public:
media(mediaitems & _Mediaitems);
virtual void write(const std::wstring & RootPath);
private:
mediaitems & mediaitems_;
};
class pictures : public element
{
public:
pictures(mediaitems & _Mediaitems);
virtual void write(const std::wstring & RootPath);
private:
mediaitems & mediaitems_;
};
class object_files : public element
{
public:
object_files(){}
void set_content(content_content_ptr & _Content);
void set_media(mediaitems & _Mediaitems);
void set_pictures(mediaitems & _Mediaitems);
void set_styles(element_ptr Element);
virtual void write(const std::wstring & RootPath);
private:
content_file content_;
element_ptr styles_;
element_ptr meta_;
element_ptr media_;
element_ptr pictures_;
};
class odf_document : public element
{
public:
odf_document(std::wstring type);
void add_object(element_ptr _object,bool root=false);
void set_rels(rels & r);
virtual void write(const std::wstring & RootPath);
private:
element_ptr base_;
std::vector<element_ptr> objects_;
element_ptr mimetype_;
element_ptr settings_;
element_ptr manifest_;
};
};
}
}
\ No newline at end of file
#include "precompiled_cpodf.h"
#include "odf_conversion_context.h"
#include "odf_rels.h"
namespace cpdoccore {
namespace odf {
//////////////////////////////////////////////////////////////////////////////////////////////////
odf_conversion_context::odf_conversion_context(package::odf_document * outputDocument)
{
output_document_ = outputDocument;
}
odf_conversion_context::~odf_conversion_context()
{
}
void odf_conversion_context::start_document()
{
}
void odf_conversion_context::end_document()
{
package::content_content_ptr content_root_ = package::content_content::create();
std::wstringstream styles_root_strm;
//odf_styles_.serialize(styles_root_strm);// ìàñòåð-ïåéäæû, çàäàííûå çàëèâêè (ãðàäèåíòû, áèòìàïû), äåôîëòíûå ñòèëè, êîëîíòèòóëû, ðàçìåòêè, çàìåòêè,...
package::object_files *object_files = new package::object_files();
if (object_files)
{
object_files->set_content(content_root_);
object_files->set_styles(package::simple_element::create(L"styles.xml", styles_root_strm.str()));
output_document_->add_object(package::element_ptr(object_files ),true);
}
std::vector<package::content_content_ptr> objects_; //styles â îáúåêòàõ ïî÷òè ïóñòûå .. - ññûëêè íà êàðòèíêè ... è òîëüêî
//ñîáñòâåííî ñòèëè çàïèñûâàþòñÿ â ñàì êîíòåíò
{
//...
}
output_document_->set_rels(rels_);
}
void odf_conversion_context::add_rel(relationship const & r)
{
rels_.add(r);
}
}
}
#pragma once
#include "object_package.h"
namespace cpdoccore {
namespace odf {
//class office_element;
//class relationship;
//class rels;
class odf_style_manager;
class odf_conversion_context : boost::noncopyable
{
public:
odf_conversion_context(package::odf_document * outputDocument);
virtual ~odf_conversion_context();
void start_document();
void end_document();
void add_rel(relationship const & r);
package::odf_document * output_document_;
private:
//odf_style_manager odf_styles_;
rels rels_;
};
}
}
\ No newline at end of file
#include "precompiled_cpodf.h"
#include <boost/foreach.hpp>
#include "odf_rels.h"
#include <cpdoccore/xml/serialize.h>
#include <cpdoccore/xml/attributes.h>
#include <cpdoccore/xml/simple_xml_writer.h>
namespace cpdoccore {
namespace odf {
void relationship::serialize(std::wostream & _Wostream)
{
CP_XML_WRITER(_Wostream)
{
CP_XML_NODE(L"manifest:file-entry")
{
CP_XML_ATTR(L"media-type", type());
CP_XML_ATTR(L"manifest:full-path", target());
}
}
}
void rels::serialize(std::wostream & _Wostream)
{
BOOST_FOREACH(relationship & r, relationship_)
{
r.serialize(_Wostream);
}
}
void rels::add(relationship const & r)
{
relationships().push_back(r);
}
}
}
#pragma once
#include <string>
#include <iosfwd>
#include <cpdoccore/xml/xmlelement.h>
#include <cpdoccore/CPSharedPtr.h>
namespace cpdoccore {
namespace odf {
class relationship /*: public xml::element_impl<relationship>*/
{
public:
relationship() {}
relationship(const std::wstring & Type,const std::wstring & Target) : type_(Type), target_(Target)
{}
void serialize(::std::wostream & _Wostream);
const std::wstring & type() const { return type_; }
const std::wstring & target() const { return target_; }
private:
std::wstring type_;
std::wstring target_;
};
class rels;
typedef _CP_PTR(rels) rels_ptr;
/// \class rels
class rels
{
public:
rels() {}
void serialize(std::wostream & _Wostream);
std::vector<relationship> & relationships() { return relationship_; }
void add(relationship const & r);
bool empty() { return relationship_.empty(); }
private:
std::vector<relationship> relationship_;
};
}
}
......@@ -6,7 +6,6 @@
#include <boost/thread/mutex.hpp>
#include <boost/thread/shared_mutex.hpp>
#include "logging.h"
#include "skipelement.h"
namespace cpdoccore {
namespace odf {
......@@ -109,6 +108,50 @@ void not_applicable_element(const office_element * CurrentElm, const std::wstrin
not_applicable_element(ss.str(), Ns, Name);
}
bool create_element(const ::std::wstring & Ns,
const ::std::wstring & Name,
office_element_ptr & _Element,
document_context * Context,
bool isRoot)
{
if (office_element_ptr elm = office_element_creator::get()->create(Ns, Name, Context, isRoot))
{
if (_Element) //
{
std::wstringstream ss;
ss << L"[warning] : duplicate element (" << Ns << L":" << Name << L")\n";
_CP_LOG(error) << ss.str();
}
_Element = elm;
return true;
}
else
{
#ifdef _DEBUG
std::wstringstream ss;
ss << L"[warning] : create element failed (" << Ns << L":" << Name << L")\n";
_CP_LOG(error) << ss.str();
#endif
not_applicable_element(L"[!!!]", 0, Ns, Name);
}
return false;
}
bool create_element(const ::std::wstring & Ns,
const ::std::wstring & Name,
office_element_ptr_array & _Elements,
document_context * Context,
bool isRoot)
{
office_element_ptr elm;
if (create_element(Ns, Name, elm, Context, isRoot))
{
_Elements.push_back(elm);
return true;
}
return false;
}
}
......
......@@ -12,10 +12,6 @@ namespace boost {
class shared_mutex;
}
namespace xml
{
class sax;
}
namespace cpdoccore {
namespace odf {
......@@ -91,26 +87,18 @@ private:
template<class T> int RegisterElement<T>::class_registered_ = 0;
/// \brief SAX, shared_ptr
bool create_element_and_read(xml::sax * Reader,
const ::std::wstring & Ns,
/// \brief
bool create_element(const ::std::wstring & Ns,
const ::std::wstring & Name,
office_element_ptr & _Element,
document_context * Context,
bool isRoot = false);
/// \brief SAX, array
bool create_element_and_read(xml::sax * Reader,
const ::std::wstring & Ns,
bool create_element(const ::std::wstring & Ns,
const ::std::wstring & Name,
office_element_ptr_array & _Elements,
document_context * Context,
bool isRoot = false);
#define CP_CREATE_ELEMENT_SIMPLE(ELEMENT) create_element_and_read(Reader, Ns, Name, (ELEMENT), Context)
#define CP_CREATE_ELEMENT(ELEMENT) create_element_and_read(Reader, Ns, Name, (ELEMENT), getContext())
#define _CPDOCCORE_CREATE_ELEMENT_ROOT(ELEMENT) create_element_and_read(Reader, Ns, Name, (ELEMENT), getContext(), true)
bool isRoot);
#define CP_CHECK_NAME(NS, NAME) ((NS) == Ns && (NAME) == Name)
......
#include "precompiled_cpodf.h"
#include "skipelement.h"
#include "logging.h"
#include <cpdoccore/xml/attributes.h>
namespace cpdoccore {
namespace odf {
//_skip_element _skip_element::skip_element_;
const wchar_t * _skip_element::ns = L"";
const wchar_t * _skip_element::name = L"";
void _skip_element::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
Attributes->reset_check();
return;
}
void _skip_element::add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name)
{
std::wstringstream ss;
ss << L"[warning] : skip element " << Ns << L":" << Name << "\n";
_CP_LOG(error) << ss.str();
/* if (Reader)
skip_element_.read_sax(Reader); */
}
void _skip_element::add_text(const std::wstring & Text)
{
std::wstringstream ss;
ss << L"[warning] : skip element text\n";
//_CP_LOG(error) << ss.str();
}
}
}
#ifndef _CPDOCCORE_ODF_OFFCIE_SKIP_ELEMENT_
#define _CPDOCCORE_ODF_OFFCIE_SKIP_ELEMENT_
#include <cpdoccore/xml/xmlelement.h>
#include <cpdoccore/xml/nodetype.h>
#include "office_elements.h"
#include "office_elements_create.h"
namespace cpdoccore {
namespace odf {
/// \class _skip_element
class _skip_element : public office_element_impl<_skip_element>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = type_AbstractXml;
//CPDOCCORE_DEFINE_VISITABLE();
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name);
virtual void add_text(const std::wstring & Text);
public:
static _skip_element skip_element_;
};
}
}
#endif
......@@ -8,6 +8,8 @@
#include <boost/foreach.hpp>
#include "odf_conversion_context.h"
namespace Oox2Odf
{
class Impl
......@@ -25,12 +27,13 @@ namespace Oox2Odf
if (type == 1)
{
m_input_docx = new OOX::CDocx(oox_path);
docx_document = new OOX::CDocx(oox_path);
}
if (type == 2)
{
m_input_xlsx = new OOX::Spreadsheet::CXlsx(oox_path);
xlsx_document = new OOX::Spreadsheet::CXlsx(oox_path);
}
}
public:
......@@ -38,8 +41,11 @@ namespace Oox2Odf
void write(const CString & path);
private:
OOX::CDocx *m_input_docx;
OOX::Spreadsheet::CXlsx *m_input_xlsx;
OOX::CDocx *docx_document;
OOX::Spreadsheet::CXlsx *xlsx_document;
package::odf_document outputDocument;
//Odf::Folder m_output; //odf_document
......@@ -47,44 +53,40 @@ namespace Oox2Odf
void Impl::write(const CString & path)
{
//m_output.write(path);
outputDocument.write(path);
}
void Impl::convert()
{
bool cancelled = false;
int percent = 150000;
odf_conversion_context odf_conversion_context_(&outputDocument);
if (m_input_docx)
if (docx_document)
{
const OOX::CApp *app = m_input_docx->GetApp();
if (app)
{
percent += 250000;
if(cancelled)
return;
}
const OOX::CCore *core = m_input_docx->GetCore();
if (core)
{
percent += 250000;
if(cancelled)
return;
}
const OOX::CDocument* document = m_input_docx->GetDocument();
// , (Core, App)
// -
const OOX::CDocument* document = docx_document->GetDocument();
if (document)
{
//odf_context.convert(document);
//odf_context.convert(document); - odf
percent += 250000;
if(cancelled)
return;
}
}
else if (m_input_xlsx)
else if (xlsx_document)
{
const OOX::Spreadsheet::CWorkbook *document = xlsx_document->GetWorkbook();
if (document)
{
odf_conversion_context_.start_documet();
document->m_oSheets;
//odf_context.convert(document); - odf
//...
odf_conversion_context_.end_documet();
}
}
}
......
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