Commit b0525345 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@54795 954022d7-b5bf-4e40-9824-e11837661b57
parent b85da715
......@@ -140,8 +140,7 @@ HRESULT COfficeOdfFileW::SaveToFileImpl(const std::wstring & srcPath,
try
{
std::wstring type = L"spreadsheet";
Oox2Odf::Converter converter(srcTempPath,type);
Oox2Odf::Converter converter(srcTempPath);
converter.convert();
converter.write(dstTempPath);
......
......@@ -950,6 +950,22 @@
RelativePath=".\OdfFormat\header_footer.h"
>
</File>
<File
RelativePath=".\OdfFormat\odf_style_context.cpp"
>
</File>
<File
RelativePath=".\OdfFormat\odf_style_context.h"
>
</File>
<File
RelativePath=".\OdfFormat\odf_style_state.cpp"
>
</File>
<File
RelativePath=".\OdfFormat\odf_style_state.h"
>
</File>
<File
RelativePath=".\OdfFormat\style_map.cpp"
>
......@@ -982,6 +998,14 @@
RelativePath=".\OdfFormat\styles_list.h"
>
</File>
<File
RelativePath=".\OdfFormat\styles_lite_container.cpp"
>
</File>
<File
RelativePath=".\OdfFormat\styles_lite_container.h"
>
</File>
</Filter>
<Filter
Name="odf text"
......
......@@ -25,8 +25,6 @@ void style_header_footer_properties::add_child_element( const ::std::wstring &
}
}
void header_footer_content::add_child_element(const ::std::wstring & Ns, const ::std::wstring & Name, odf_conversion_context * Context)
{
CP_CREATE_ELEMENT_SIMPLE(content_);
......
......@@ -45,6 +45,8 @@ public:
CPDOCCORE_DEFINE_VISITABLE();
virtual void add_child_element(const ::std::wstring & Ns, const ::std::wstring & Name);
virtual void add_child_element(office_element_ptr & child)
{std::wstringstream str; str <<L"Non add child in "; str << ns; str << L":"; str <<name; _CP_LOG(error) << str.str();}
virtual void serialize(std::wostream & strm){}
style_header_footer_properties_attlist style_header_footer_properties_attlist_;
......@@ -68,6 +70,8 @@ class header_footer_content
{
public:
void add_child_element( const ::std::wstring & Ns, const ::std::wstring & Name, odf_conversion_context * Context);
virtual void add_child_element(office_element_ptr & child, odf_conversion_context * Context)
{}
office_element_ptr_array content_;
......
......@@ -13,7 +13,7 @@ namespace odf {
//////////////////////////////////////////////////////////////////////////////////////////////////
odf_conversion_context::odf_conversion_context(package::odf_document * outputDocument)
odf_conversion_context::odf_conversion_context(package::odf_document * outputDocument) : style_context_(*this)
{
output_document_ = outputDocument;
}
......@@ -36,8 +36,20 @@ office_element_ptr & odf_conversion_context::getCurrentElement()
}
}
//void odf_conversion_context::start_font_face()
//{
// create_element(L"office", L"font-face-decls", styles_, this,true);
//}
void odf_conversion_context::end_document()
{
///////////////////çàâåðøàþùàÿ îáðàáîòêà
process_styles();
//////////////////////////////////////////////////////////////////////
package::content_content_ptr content_root_ = package::content_content::create();
......@@ -47,8 +59,13 @@ void odf_conversion_context::end_document()
}
std::wstringstream styles_root_strm;
//odf_styles_.serialize(styles_root_strm);// ìàñòåð-ïåéäæû, çàäàííûå çàëèâêè (ãðàäèåíòû, áèòìàïû), äåôîëòíûå ñòèëè, êîëîíòèòóëû, ðàçìåòêè, çàìåòêè,...
//////////////////////////////////////////////////////////////////////////////////////////
BOOST_FOREACH(const office_element_ptr & elm, styles_)
{// ìàñòåð-ïåéäæû, çàäàííûå çàëèâêè (ãðàäèåíòû, áèòìàïû), äåôîëòíûå ñòèëè, êîëîíòèòóëû, ðàçìåòêè, çàìåòêè,...
elm->serialize(styles_root_strm);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
package::object_files *object_files = new package::object_files();
if (object_files)
{
......@@ -61,10 +78,6 @@ void odf_conversion_context::end_document()
std::vector<package::content_content_ptr> objects_; //styles â îáúåêòàõ ïî÷òè ïóñòûå .. - ññûëêè íà êàðòèíêè ... è òîëüêî
//ñîáñòâåííî ñòèëè çàïèñûâàþòñÿ â ñàì êîíòåíò
{
//...
}
output_document_->set_rels(rels_);
}
......@@ -73,6 +86,18 @@ void odf_conversion_context::add_rel(relationship const & r)
rels_.add(r);
}
void odf_conversion_context::process_styles()
{
create_element(L"office", L"office-styles", styles_, this,true);
style_context_.process_office(styles_.back());
create_element(L"office", L"automatic-styles", styles_, this,true);
style_context_.process_automatic(styles_.back());
create_element(L"office", L"master-styles", styles_, this,true);
style_context_.process_master(styles_.back());
}
}
......
#pragma once
#include "object_package.h"
#include "odf_style_context.h"
namespace cpdoccore {
namespace odf {
class office_element;
typedef shared_ptr<office_element>::Type office_element_ptr;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class odf_style_manager;
//class styles_container;
//class style_instance;
//typedef boost::shared_ptr<style_instance> style_instance_ptr;
//typedef boost::shared_ptr<styles_container> styles_container_ptr;
//class style_instance
//{
//public:
// style_instance(
// styles_container * Container,
// const std::wstring & Name,
// style_family::type Type,
// style_content * Content,
// bool IsAutomatic,
// bool IsDefault,
// const std::wstring & ParentStyleName,
// const std::wstring & NextStyleName,
// const std::wstring & DataStyleName
// );
//
//
// const std::wstring & name() const;
// style_family::type type() const;
// style_content * content() const;
// style_instance * parent() const;
// const std::wstring & parent_name() const;
// style_instance * next() const;
// const std::wstring & next_name() const;
// bool is_automatic() const;
// bool is_default() const;
// const styles_container * container() const { return container_; }
// const std::wstring & data_style_name() const;
//
//private:
// styles_container * container_;
// std::wstring name_;
// style_family::type style_type_;
// style_content * content_;
//
// bool is_automatic_;
// bool is_default_;
//
// std::wstring parent_name_;
// std::wstring next_name_;
// mutable style_instance * parent_;
// mutable style_instance * next_;
// std::wstring data_style_name_;
//};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//class styles_container
//{
//public:
// styles_container() : hyperlink_style_pos_(-1)
// {}
//
// typedef std::vector<style_instance_ptr> instances_array;
//
// void add_style(const std::wstring & Name,
// style_family::type Type,
// style_content * Content,
// bool IsAutomatic,
// bool IsDefault,
// const std::wstring & ParentStyleName,
// const std::wstring & NextStyleName,
// const std::wstring & DataStyleName);
//
// void add_master_page_name(const std::wstring & StyleName, const std::wstring & MasterPageName);
//
// style_instance * hyperlink_style();
// style_instance * style_by_name(const std::wstring & Name, style_family::type Type,bool object_in_styles) const;
// style_instance * style_default_by_type(style_family::type Type) const;
//
// const std::wstring master_page_name_by_name(const std::wstring & StyleName) const;
//
// instances_array & instances() { return instances_; }
//
// presentation_layouts_instance & presentation_layouts() { return presentation_layouts_; }
// presentation_masters_instance & presentation_masters() { return presentation_masters_; }
//
//private:
// //presentation_layouts_instance presentation_layouts_;
// //presentation_masters_instance presentation_masters_;
//
// instances_array instances_;
//
// typedef boost::unordered_map<std::wstring, int> map_wstring_int_t;
// map_wstring_int_t map_;
//
// typedef boost::unordered_map<std::wstring, std::wstring> map_wstring_wstring;
// map_wstring_wstring master_page_name_;
//
// typedef boost::unordered_map<style_family::type, int> map_style_family_int;
// map_style_family_int default_map_;
// int hyperlink_style_pos_;
//};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class odf_conversion_context : boost::noncopyable
{
......@@ -22,15 +122,44 @@ public:
office_element_ptr & getCurrentElement();
std::vector<office_element_ptr> content_;
std::vector<office_element_ptr> styles_;
void add_rel(relationship const & r);
package::odf_document * output_document_;
odf_style_context & styles_context(){return style_context_;}
private:
//odf_style_manager odf_styles_;
rels rels_;
void process_styles();
public:
odf_style_context style_context_;
//styles_container & styleContainer() { return major_style_container_; }
//page_layout_container & pageLayoutContainer() { return page_layout_container_; }
//fonts_container & fontContainer() { return fonts_container_; }
//list_style_container & listStyleContainer() { return list_style_container_; }
//notes_configuration & noteConfiguration() { return notes_configuration_; }
//styles_lite_container & numberStyles() { return number_style_container_; }
//styles_lite_container & drawStyles() { return draw_style_container_; }
//styles_lite_container & Templates() { return template_container_; }
private:
//styles_container major_style_container_;
//page_layout_container page_layout_container_;
//fonts_container fonts_container_;
//list_style_container list_style_container_;
//notes_configuration notes_configuration_;
//styles_lite_container number_style_container_;
//styles_lite_container draw_style_container_;
//styles_lite_container template_container_;
};
}
......
#include "precompiled_cpodf.h"
#include "odf_style_context.h"
//#include "ods_textcontext.h"
#include "ods_conversion_context.h"
#include "logging.h"
#include "styles.h"
#include <boost/foreach.hpp>
#include <iostream>
namespace cpdoccore {
namespace odf {
odf_style_context::odf_style_context(odf_conversion_context & Context/*, xlsx_text_context & textCotnext*/): context_(Context)
{
}
odf_style_state & odf_style_context::state()
{
return style_state_list_.back();
}
const odf_style_state & odf_style_context::state() const
{
return style_state_list_.back();
}
void odf_style_context::start_style(std::wstring name,const style_family family, bool automatic )
{
int id = style_state_list_.size();
office_element_ptr elm;
create_element(L"style", L"style", elm, &context_);
style_state_list_.push_back( odf_style_state(context_, elm, family) );
///////////////////////////////////////
state().set_name(name);
state().set_automatic(automatic);
state().style_oox_id_ = id;
}
void odf_style_context::process_automatic(office_element_ptr root )
{
for (std::list<odf_style_state>::iterator it = style_state_list_.begin(); it != style_state_list_.end(); it++)
{
if (it->automatic_== true && it->odf_style_)
root->add_child_element(it->odf_style_);
}
}
void odf_style_context::process_office(office_element_ptr root )
{
for (std::list<odf_style_state>::iterator it = style_state_list_.begin(); it != style_state_list_.end(); it++)
{
if (it->automatic_== false && it->master_ == false && it->odf_style_)
root->add_child_element(it->odf_style_);
}
}
void odf_style_context::process_master(office_element_ptr root )
{
for (std::list<odf_style_state>::iterator it = style_state_list_.begin(); it != style_state_list_.end(); it++)
{
if (it->master_ == true && it->odf_style_)
root->add_child_element(it->odf_style_);
}
}
//office_element_ptr & odf_style_context::find_by_id()
//{
// for (std::list<odf_style_state>::iterator it = style_state_list_.begin(); it != style_state_list_.end(); it++)
// {
// if (it->odf_style_)
// {
// if (it->odf_style_->style_family_ == family && it->style_oox_id_ == id)
// return it->get_office_element();
// }
// }
// return office_element_ptr();
//}
void odf_style_context::end_style()
{
state().convert();
}
}
}
\ No newline at end of file
#pragma once
#include <string>
#include "odf_style_state.h"
namespace cpdoccore {
namespace odf {
//class ods_conversion_context;
//class odt_conversion_context;
class odf_conversion_context;
class office_element;
typedef shared_ptr<office_element>::Type office_element_ptr;
/// \class ods_table_context
class odf_style_context
{
public:
odf_style_context(odf_conversion_context & Context/*, ods_text_context & textCotnext*/);
void start_style(std::wstring name, const style_family style_family, bool automatic = false);
void end_style();
//office_element_ptr & find_by_id(int id, const style_family family);
void process_automatic(office_element_ptr root );
void process_master(office_element_ptr root );
void process_office(office_element_ptr root );
//std::wstring get_current_table_name() const;
//void start_cell(const std::wstring & formula,
// size_t columnsSpanned,
// size_t rowsSpanned);
//void end_cell();
// std::wstring default_row_cell_style() const;
// std::wstring default_column_cell_style() const;
// void start_covered_cell();
// void end_covered_cell();
// void start_cell_content();
// int end_cell_content();
// void set_current_cell_style_id(unsigned int xfId);
// int get_current_cell_style_id();
// int current_column() const;
// int current_row() const;
//void set_table_row_group(int count, bool collapsed, int level);
// void start_row(const std::wstring & StyleName, const std::wstring & defaultCellStyleName);
// void non_empty_row();
// bool is_empty_row() const;
// void end_row();
// void start_column(unsigned int repeated, const std::wstring & defaultCellStyleName);
// size_t depth() const { return table_state_stack_.size(); }
// unsigned int columns_count();
// void serialize_merge_cells(std::wostream & _Wostream);
//void serialize_table_format(std::wostream & _Wostream);
//xlsx_table_metrics & get_table_metrics();
//
//xlsx_drawing_context & get_drawing_context();
// xlsx_comments_context & get_comments_context();
//
// void table_column_last_width(double w);
// double table_column_last_width() const;
odf_style_state & state();
const odf_style_state & state() const;
// void start_hyperlink();
//std::wstring end_hyperlink(std::wstring const & ref, std::wstring const & href, std::wstring const & display);
// void dump_rels_hyperlinks(rels & Rels);
// void serialize_hyperlinks(std::wostream & _Wostream);
private:
odf_conversion_context & context_;
std::list<odf_style_state> style_state_list_;// content_
};
}
}
#include "precompiled_cpodf.h"
#include "logging.h"
#include "odf_style_state.h"
#include "odf_conversion_context.h"
#include "styles.h"
namespace cpdoccore {
namespace odf {
odf_style_state::odf_style_state(odf_conversion_context & Context, office_element_ptr & elm, const style_family family ): context_(Context)
{
odf_style_ = elm;
automatic_= false;
style* style_ = dynamic_cast<style*>(elm.get());
if (!style_)return;
style_->style_family_ = family;
//set default
}
office_element_ptr & odf_style_state::get_office_element()
{
return odf_style_;
}
void odf_style_state::set_name(std::wstring name)
{
style* style_ = dynamic_cast<style*>(odf_style_.get());
if (!style_)return;
style_->style_name_ = name;
}
std::wstring & odf_style_state::get_name()
{
style* style_ = dynamic_cast<style*>(odf_style_.get());
if (!style_)return std::wstring();
return style_->style_name_;
}
void odf_style_state::set_automatic(bool val)
{
automatic_ = val;
}
void odf_style_state::convert()
{
if (odf_style_== NULL)return;
}
}
}
#pragma once
#include <string>
#include <vector>
//
//#include "ods_row_spanned.h"
//#include "ods_merge_cells.h"
//#include "ods_table_metrics.h"
//#include "ods_drawing_context.h"
//#include "ods_comments_context.h"
//#include "ods_hyperlinks.h"
#include "office_elements.h"
#include "office_elements_create.h"
#include "stylefamily.h"
namespace cpdoccore {
namespace odf {
class odf_conversion_context;
class odf_style_context;
//class style;
class odf_style_state
{
public:
odf_style_state(odf_conversion_context & Context, office_element_ptr & elm, const style_family style_family );
void set_name(std::wstring);
void set_automatic(bool val);
std::wstring & get_name();
void convert();
office_element_ptr & get_office_element();
private:
int style_oox_id_;
bool automatic_;
bool master_;
office_element_ptr odf_style_;//
// !!! - , ... ,
// ???
odf_conversion_context & context_;
friend class odf_style_context;
};
}
}
......@@ -17,11 +17,12 @@ ods_conversion_context::ods_conversion_context(package::odf_document * outputDoc
void ods_conversion_context::start_document()
{
create_element(L"office", L"spreadsheet",content_, this,true);
create_element(L"office", L"spreadsheet", content_, this,true);
current_spreadsheet_ = (office_spreadsheet*)dynamic_cast<office_spreadsheet*>(content_.back().get());
}
void ods_conversion_context::start_sheet(std::wstring & name)
{
create_element(L"table", L"table",current_spreadsheet_->getContent(),this);
......
......@@ -25,7 +25,7 @@ void ods_table_state::convert()
{
if (office_element_ == NULL)return;
// ??? ..
//ïîñëåäíèå øòðèõè???
}
......
......@@ -41,6 +41,8 @@ public:
odf_conversion_context * getContext() { return context_; }
const odf_conversion_context * getContext() const { return context_; }
virtual void add_child_element(office_element_ptr & child) = 0;
void set_root(bool root){is_root_ = root;}
////////////////////////
virtual ::std::wostream & text_to_stream(::std::wostream & _Wostream) const
......
......@@ -25,6 +25,8 @@ public:
CPDOCCORE_DEFINE_VISITABLE();
virtual void add_child_element( const ::std::wstring & Ns, const ::std::wstring & Name);
virtual void add_child_element(office_element_ptr & child)
{std::wstringstream str; str <<L"Non add child in "; str << ns; str << L":"; str <<name; _CP_LOG(error) << str.str();}
virtual void serialize(std::wostream & strm){}
std::wstring style_condition_;
......
......@@ -68,6 +68,8 @@ public:
CPDOCCORE_DEFINE_VISITABLE();
virtual void add_child_element(const ::std::wstring & Ns, const ::std::wstring & Name);
virtual void add_child_element(office_element_ptr & child)
{std::wstringstream str; str <<L"Non add child in "; str << ns; str << L":"; str <<name; _CP_LOG(error) << str.str();}
table_format_properties table_format_properties_;
......@@ -81,7 +83,6 @@ CP_REGISTER_OFFICE_ELEMENT2(style_table_properties);
class style_table_column_properties_attlist
{
public:
void add_attributes( const xml::attributes_wc_ptr & Attributes );
_CP_OPT(length) style_column_width_;
_CP_OPT(length) style_rel_column_width_;
......@@ -104,6 +105,8 @@ public:
CPDOCCORE_DEFINE_VISITABLE();
virtual void add_child_element( const ::std::wstring & Ns, const ::std::wstring & Name);
virtual void add_child_element(office_element_ptr & child)
{std::wstringstream str; str <<L"Non add child in "; str << ns; str << L":"; str <<name; _CP_LOG(error) << str.str();}
virtual void serialize(std::wostream & strm){}
style_table_column_properties_attlist style_table_column_properties_attlist_;
......@@ -116,7 +119,6 @@ CP_REGISTER_OFFICE_ELEMENT2(style_table_column_properties);
class style_table_row_properties_attlist
{
public:
void add_attributes( const xml::attributes_wc_ptr & Attributes );
_CP_OPT(length) style_row_height_;
_CP_OPT(length) style_min_row_height_;
......@@ -139,6 +141,8 @@ public:
CPDOCCORE_DEFINE_VISITABLE();
virtual void add_child_element(const ::std::wstring & Ns, const ::std::wstring & Name);
virtual void add_child_element(office_element_ptr & child)
{std::wstringstream str; str <<L"Non add child in "; str << ns; str << L":"; str <<name; _CP_LOG(error) << str.str();}
virtual void serialize(std::wostream & strm){}
......@@ -228,8 +232,6 @@ public:
class style_table_cell_properties_elements
{
public:
void add_attributes( const xml::attributes_wc_ptr & Attributes );
// 15.11.6
office_element_ptr style_background_image_;
......@@ -249,6 +251,8 @@ public:
CPDOCCORE_DEFINE_VISITABLE();
virtual void add_child_element( const ::std::wstring & Ns, const ::std::wstring & Name);
virtual void add_child_element(office_element_ptr & child)
{std::wstringstream str; str <<L"Non add child in "; str << ns; str << L":"; str <<name; _CP_LOG(error) << str.str();}
virtual void serialize(std::wostream & strm){}
......
This diff is collapsed.
......@@ -44,6 +44,8 @@ public:
office_element_ptr_array & get_content() { return text_list_style_content_; }
virtual void add_child_element( const std::wstring & Ns, const std::wstring & Name);
virtual void add_child_element(office_element_ptr & child)
{std::wstringstream str; str <<L"Non add child in "; str << ns; str << L":"; str <<name; _CP_LOG(error) << str.str();}
virtual void serialize(std::wostream & strm){}
text_list_style_attr text_list_style_attr_;
......@@ -96,6 +98,8 @@ public:
CPDOCCORE_DEFINE_VISITABLE();
virtual void add_child_element(const std::wstring & Ns, const std::wstring & Name);
virtual void add_child_element(office_element_ptr & child)
{std::wstringstream str; str <<L"Non add child in "; str << ns; str << L":"; str <<name; _CP_LOG(error) << str.str();}
virtual void serialize(std::wostream & strm){}
friend class text_list_level_style_number;
......@@ -133,6 +137,8 @@ public:
CPDOCCORE_DEFINE_VISITABLE();
virtual void add_child_element(const std::wstring & Ns, const std::wstring & Name);
virtual void add_child_element(office_element_ptr & child)
{std::wstringstream str; str <<L"Non add child in "; str << ns; str << L":"; str <<name; _CP_LOG(error) << str.str();}
virtual void serialize(std::wostream & strm){}
const _CP_OPT(length) & get_fo_text_indent() const { return fo_text_indent_; }
......@@ -164,6 +170,8 @@ public:
office_element_ptr style_list_level_properties_;
virtual void add_child_element( const std::wstring & Ns, const std::wstring & Name);
virtual void add_child_element(office_element_ptr & child)
{std::wstringstream str; str <<L"Non add child in "; str << ns; str << L":"; str <<name; _CP_LOG(error) << str.str();}
virtual void serialize(std::wostream & strm){}
text_list_level_style_attr text_list_level_style_attr_;
......@@ -204,6 +212,8 @@ public:
office_element_ptr style_list_level_properties_;
virtual void add_child_element( const std::wstring & Ns, const std::wstring & Name);
virtual void add_child_element(office_element_ptr & child)
{std::wstringstream str; str <<L"Non add child in "; str << ns; str << L":"; str <<name; _CP_LOG(error) << str.str();}
virtual void serialize(std::wostream & strm){}
text_list_level_style_attr text_list_level_style_attr_;
......
#include "precompiled_cpodf.h"
#include <vector>
#include <boost/unordered_map.hpp>
#include "styles_lite_container.h"
namespace cpdoccore {
namespace odf {
struct style_ref_lite_container
{
int style_oox;
office_element_ptr style;
};
struct styles_lite_container::Impl
{
typedef std::vector<style_ref_lite_container> array_t;
array_t array_;
typedef boost::unordered_map<int, size_t> map_t;
map_t map_;
};
styles_lite_container::styles_lite_container(): impl_(new styles_lite_container::Impl() )
{
}
styles_lite_container::~styles_lite_container()
{
}
void styles_lite_container::add(const int style_oox, office_element_ptr content)
{
style_ref_lite_container ref = {style_oox, content};
impl_->array_.push_back(ref);
impl_->map_[style_oox] = impl_->array_.size() - 1;
}
office_element_ptr styles_lite_container::find_by_style_oox(const int style_oox)
{
styles_lite_container::Impl::map_t::const_iterator i = impl_->map_.find(style_oox);
if (i != impl_->map_.end())
{
return impl_->array_[i->second].style;
}
else
{
return office_element_ptr();
}
}
}
}
\ No newline at end of file
#pragma once
#include <cpdoccore/CPSharedPtr.h>
#include <cpdoccore/CPScopedPtr.h>
namespace cpdoccore {
namespace odf {
class office_element;
typedef shared_ptr<office_element>::Type office_element_ptr;
class styles_lite_container
{
public:
styles_lite_container();
~styles_lite_container();
public:
void add(const int oox_style, office_element_ptr content);
office_element_ptr find_by_style_oox(const int style_oox);
private:
struct Impl;
_CP_SCOPED_PTR(Impl) impl_;
};
}
}
......@@ -20,9 +20,6 @@ namespace odf {
// table-table-attlist
class table_table_attlist
{
public:
void add_attributes( const xml::attributes_wc_ptr & Attributes );
public:
_CP_OPT(std::wstring) table_name_;
_CP_OPT(style_ref) table_style_name_;
......@@ -44,9 +41,6 @@ public:
// table-table-row-attlist
class table_table_row_attlist
{
public:
void add_attributes( const xml::attributes_wc_ptr & Attributes );
public:
unsigned int table_number_rows_repeated_; // default 1
_CP_OPT(style_ref) table_style_name_;
......@@ -58,9 +52,6 @@ public:
// table-table-cell-attlist
class table_table_cell_attlist
{
public:
void add_attributes( const xml::attributes_wc_ptr & Attributes );
public:
unsigned int table_number_columns_repeated_; // default 1
_CP_OPT(style_ref) table_style_name_;
......@@ -76,9 +67,6 @@ public:
// table-table-cell-attlist-extra
class table_table_cell_attlist_extra
{
public:
void add_attributes( const xml::attributes_wc_ptr & Attributes );
public:
unsigned int table_number_columns_spanned_; // default 1
unsigned int table_number_rows_spanned_; // default 1
......@@ -90,9 +78,6 @@ public:
// table-table-source-attlist
class table_table_source_attlist
{
public:
void add_attributes( const xml::attributes_wc_ptr & Attributes );
public:
table_mode table_mode_; // default CopyAll
_CP_OPT(std::wstring) table_table_name_;
......@@ -102,9 +87,6 @@ public:
// table-linked-source-attlist
class table_linked_source_attlist
{
public:
void add_attributes( const xml::attributes_wc_ptr & Attributes );
public:
common_xlink_attlist common_xlink_attlist_;
......@@ -135,10 +117,6 @@ public:
virtual void serialize(std::wostream & _Wostream){}
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
};
CP_REGISTER_OFFICE_ELEMENT2(table_table_source);
......@@ -168,8 +146,6 @@ public:
xml::NodeType xml_type;
ElementType type;
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes ) {}
CPDOCCORE_DEFINE_VISITABLE();
public:
......@@ -213,9 +189,6 @@ public:
// table-table-column-attlist
class table_table_column_attlist
{
public:
void add_attributes( const xml::attributes_wc_ptr & Attributes );
public:
unsigned int table_number_columns_repeated_; // default 1
_CP_OPT(style_ref) table_style_name_;
......@@ -242,9 +215,6 @@ public:
virtual void serialize(std::wostream & _Wostream){}
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
public:
table_table_column_attlist table_table_column_attlist_;
......@@ -269,10 +239,7 @@ public:
virtual void add_child_element( office_element_ptr & child_element){}
virtual void serialize(std::wostream & _Wostream){}
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
public:
office_element_ptr_array table_table_column_;
};
......@@ -297,10 +264,6 @@ public:
virtual void serialize(std::wostream & _Wostream){}
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
public:
office_element_ptr_array table_table_column_;
};
......@@ -310,10 +273,6 @@ CP_REGISTER_OFFICE_ELEMENT2(table_table_header_columns);
// table-table-column-group-attlist
class table_table_column_group_attlist
{
public:
void add_attributes( const xml::attributes_wc_ptr & Attributes );
private:
bool table_display_; // default true
};
......@@ -340,10 +299,6 @@ public:
{
}
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
public:
table_table_column_group_attlist table_table_column_group_attlist_;
table_columns_and_groups table_columns_and_groups_;
......@@ -369,10 +324,6 @@ public:
virtual void serialize(std::wostream & _Wostream){}
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
public:
table_table_row_attlist table_table_row_attlist_;
office_element_ptr_array content_; // table-table-cell, table-covered-table-cell
......@@ -416,11 +367,6 @@ public:
virtual void serialize(std::wostream & _Wostream){}
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
public:
table_table_cell_attlist table_table_cell_attlist_;
table_table_cell_attlist_extra table_table_cell_attlist_extra_;
table_table_cell_content table_table_cell_content_;
......@@ -449,10 +395,6 @@ public:
virtual void serialize(std::wostream & _Wostream){}
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
public:
bool empty_;
table_table_cell_attlist table_table_cell_attlist_;
table_table_cell_content table_table_cell_content_;
......@@ -483,10 +425,6 @@ public:
{
}
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
public:
office_element_ptr_array table_table_row_;
};
......@@ -511,10 +449,6 @@ public:
virtual void serialize(std::wostream & _Wostream){}
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
public:
office_element_ptr_array table_table_row_;
};
......@@ -531,7 +465,6 @@ public:
virtual void serialize(std::wostream & _Wostream){}
public:
office_element_ptr table_table_rows_;
office_element_ptr_array table_table_row_;
......@@ -547,8 +480,6 @@ public:
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeTableTableRowNoGroup;
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes ) {}
static _CP_PTR(table_rows_no_group) create();
CPDOCCORE_DEFINE_VISITABLE();
......@@ -561,7 +492,7 @@ public:
virtual void serialize(std::wostream & _Wostream){}
public:
table_rows table_rows_1_;
bool was_header_;
......@@ -584,7 +515,6 @@ public:
int get_count(){return content_.size();}// ..
public:
office_element_ptr_array content_;
//int type_;
//office_element_ptr table_table_row_group_;
......@@ -596,15 +526,11 @@ public:
class table_table_row_group_attlist
{
public:
void add_attributes( const xml::attributes_wc_ptr & Attributes );
bool table_display_; // default true
};
//
// \class table_table_row_group
// table-table-row-group
// table:table-row-group
class table_table_row_group : public office_element_impl<table_table_row_group>
{
......@@ -624,10 +550,6 @@ public:
virtual void serialize(std::wostream & _Wostream){}
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
public:
table_table_row_group_attlist table_table_row_group_attlist_;
table_rows_and_groups table_rows_and_groups_;
......@@ -653,10 +575,6 @@ public:
virtual void serialize(std::wostream & _Wostream);
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
public:
table_table_attlist table_table_attlist_;
office_element_ptr table_table_source_;//table-table-source
//office-dde-source
......@@ -688,10 +606,6 @@ public:
virtual void serialize(std::wostream & _Wostream){}
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
private:
office_element_ptr_array content_;
};
......
......@@ -40,7 +40,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=".\OdfFormat;.\Oox2OdfConverter;..\..\Common\DocxFormat\Source;..\..\Common\DocxFormat\Source\XML;..\..\ASCOfficeOdfFile\include;..\..\ASCOfficeOdfFile\3dparty\utf8cpp\include"
AdditionalIncludeDirectories="..\..\ASCOfficeOdfFile\src\odf\datatypes;.\OdfFormat;.\Oox2OdfConverter;..\..\Common\DocxFormat\Source;..\..\Common\DocxFormat\Source\XML;..\..\ASCOfficeOdfFile\include;..\..\ASCOfficeOdfFile\3dparty\utf8cpp\include"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_USE_XMLLITE_READER_;USE_LITE_READER"
MinimalRebuild="true"
BasicRuntimeChecks="3"
......@@ -103,7 +103,7 @@
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=".\OdfFormat;.\Oox2OdfConverter;..\..\Common\DocxFormat\Source;..\..\Common\DocxFormat\Source\XML;..\..\ASCOfficeOdfFile\include;..\..\ASCOfficeOdfFile\3dparty\utf8cpp\include"
AdditionalIncludeDirectories="..\..\ASCOfficeOdfFile\src\odf\datatypes;.\OdfFormat;.\Oox2OdfConverter;..\..\Common\DocxFormat\Source;..\..\Common\DocxFormat\Source\XML;..\..\ASCOfficeOdfFile\include;..\..\ASCOfficeOdfFile\3dparty\utf8cpp\include"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_USE_XMLLITE_READER_;USE_LITE_READER"
RuntimeLibrary="2"
UsePrecompiledHeader="2"
......@@ -152,6 +152,10 @@
RelativePath=".\Oox2OdfConverter\Converter.cpp"
>
</File>
<File
RelativePath=".\Oox2OdfConverter\DocxConverter.cpp"
>
</File>
<File
RelativePath=".\Oox2OdfConverter\stdafx.cpp"
>
......@@ -172,6 +176,10 @@
/>
</FileConfiguration>
</File>
<File
RelativePath=".\Oox2OdfConverter\XlsxConverter.cpp"
>
</File>
</Filter>
<Filter
Name="Header Files"
......@@ -182,10 +190,18 @@
RelativePath=".\Oox2OdfConverter\Converter.h"
>
</File>
<File
RelativePath=".\Oox2OdfConverter\DocxConverter.h"
>
</File>
<File
RelativePath=".\Oox2OdfConverter\stdafx.h"
>
</File>
<File
RelativePath=".\Oox2OdfConverter\XlsxConverter.h"
>
</File>
</Filter>
<Filter
Name="Resource Files"
......
#pragma once
#include "stdAfx.h"
#include "Converter.h"
#include <XlsxFormat\Xlsx.h>
#include <DocxFormat\Docx.h>
#include <boost/foreach.hpp>
#include "ods_conversion_context.h"
//#include "odt_conversion_context.h"
using namespace cpdoccore;
#include "XlsxConverter.h"
#include "DocxConverter.h"
namespace Oox2Odf
{
class Impl
{
friend class Converter;
public:
Impl(const std::wstring & path,const std::wstring & type) : output_document(type)
{
const OOX::CPath oox_path(CString(path.c_str()));
docx_document =0;
xlsx_document =0;
if (type == L"text")
{
docx_document = new OOX::CDocx(oox_path);
}
if (type == L"spreadsheet")
{
xlsx_document = new OOX::Spreadsheet::CXlsx(oox_path);
}
}
public:
void convert(/*Odt::IOdtEvent& Event*/);
void write(const std::wstring & path);
private:
OOX::CDocx *docx_document;
OOX::Spreadsheet::CXlsx *xlsx_document;
odf::package::odf_document output_document;
};
void Impl::write(const std::wstring & path)
{
output_document.write(path);
}
void Impl::convert()
{
odf::ods_conversion_context ods_conversion_context_(&output_document);
if (docx_document)
{
// , (Core, App)
// -
const OOX::CDocument* document = docx_document->GetDocument();
if (document)
Converter::Converter(const std::wstring & path)
{
//odf_context.convert(document); - odf
std::wstring type = L"spreadsheet";
}
}
else if (xlsx_document)
{
const OOX::Spreadsheet::CWorkbook *Workbook= xlsx_document->GetWorkbook();
CAtlMap<CString, OOX::Spreadsheet::CWorksheet*> &arrWorksheets = xlsx_document->GetWorksheets();
//convert(xlsx_document->GetWorkbook(),odf_conversion_context_);
if (Workbook)
{
ods_conversion_context_.start_document();
if(Workbook->m_oSheets.IsInit())
{
CSimpleArray<OOX::Spreadsheet::CSheet*>& aWs = Workbook->m_oSheets->m_arrItems;
for(int i = 0, length = aWs.GetSize(); i < length; ++i)
{
OOX::Spreadsheet::CSheet* pSheet = aWs[i];
if(pSheet->m_oRid.IsInit())
{
CString sSheetRId = pSheet->m_oRid.get2().ToString();
CAtlMap<CString, OOX::Spreadsheet::CWorksheet*>::CPair* pPair = arrWorksheets.Lookup(sSheetRId);
if (NULL != pPair)
{
OOX::Spreadsheet::CWorksheet *pWorksheet = pPair->m_value;
if (NULL != pWorksheet && pWorksheet->m_oSheetData.IsInit())
{
std::wstring name = string2std_string(pSheet->m_oName.get2());
ods_conversion_context_.start_sheet(name);
//CAtlMap<CString, OOX::Spreadsheet::CWorksheet*>::CPair* pair = aWorksheets.Lookup(pSheet->m_oRid->GetValue());
//if(NULL != pair)
//{
// nCurPos = m_oBcw.WriteItemStart(c_oSerWorksheetsTypes::Worksheet);
// WriteWorksheet(*pSheet, *pair->m_value);
// m_oBcw.WriteItemWithLengthEnd(nCurPos);
//}
ods_conversion_context_.end_sheet();
}
if (type == L"text") impl_ = new DocxConverter(path);
if (type == L"spreadsheet") impl_ = new XlsxConverter(path);
}
}
}
}
ods_conversion_context_.end_document();
}
}
}
///////////////
Converter::Converter(const std::wstring & path, const std::wstring & type)
{
impl_ = new Impl(path,type);
}
Converter::~Converter()
{
if (impl_ )delete impl_ ;
}
void Converter::convert(/*Odt::IOdtEvent& Event*/)
void Converter::convert()
{
if (!impl_)return;
impl_->convert(/*Event*/);
impl_->convert();
}
void Converter::write(const std::wstring & path) const
{
......
......@@ -9,12 +9,19 @@ static std::wstring string2std_string(CString val)
namespace Oox2Odf
{
class Impl;
class OoxConverter
{
public:
virtual void convert() = 0;
virtual void write(const std::wstring & path) = 0;
OoxConverter(){}
};
class Converter
{
public:
Converter(const std::wstring & path, const std::wstring & type);
Converter(const std::wstring & path);
virtual ~Converter();
public:
......@@ -22,9 +29,9 @@ namespace Oox2Odf
void write(const std::wstring & path) const;
Impl * get_impl() { return impl_; }
OoxConverter * get_ooxConverter() { return impl_; }
private:
Impl* impl_;
OoxConverter* impl_;
};
} // namespace Oox2Odf:Convert
#pragma once
#include "stdAfx.h"
#include "DocxConverter.h"
#include <DocxFormat\Docx.h>
#include <boost/foreach.hpp>
#include "odf_conversion_context.h"
//#include "odt_conversion_context.h"
using namespace cpdoccore;
namespace Oox2Odf
{
DocxConverter::DocxConverter(const std::wstring & path)
{
output_document = new odf::package::odf_document(L"text");
const OOX::CPath oox_path(CString(path.c_str()));
docx_document = new OOX::CDocx(oox_path);
}
void DocxConverter::write(const std::wstring & path)
{
if (!output_document)return;
output_document->write(path);
}
void DocxConverter::convert()
{
if (!docx_document)return;
const OOX::CDocument* document = docx_document->GetDocument();
if (!document)return;
//odf_context_ = new odf::odf_conversion_context(output_document);
}
}
\ No newline at end of file
#pragma once
#include "Converter.h"
namespace OOX
{
class CDocx;
}
namespace cpdoccore
{
namespace odf
{
namespace package
{
class odf_document;
}
class ods_conversion_context;
}
}
namespace Oox2Odf
{
class DocxConverter : public OoxConverter
{
public:
DocxConverter(const std::wstring & path);
virtual void convert();
virtual void write(const std::wstring & path);
private:
OOX::CDocx *docx_document;
cpdoccore::odf::package::odf_document *output_document;
///////////////////////////////
};
}
\ No newline at end of file
#pragma once
#include "stdAfx.h"
#include "XlsxConverter.h"
#include <boost/foreach.hpp>
#include "ods_conversion_context.h"
using namespace cpdoccore;
namespace Oox2Odf
{
XlsxConverter::XlsxConverter(const std::wstring & path)
{
const OOX::CPath oox_path(CString(path.c_str()));
xlsx_document = new OOX::Spreadsheet::CXlsx(oox_path);
output_document = new odf::package::odf_document(L"spreadsheet");
}
void XlsxConverter::write(const std::wstring & path)
{
if (!output_document)return;
output_document->write(path);
}
void XlsxConverter::convert()
{
if (!xlsx_document)return;
if (!output_document)return;
ods_context = new odf::ods_conversion_context(output_document);
if (!ods_context)return;
convert_styles();
ods_context->start_document();
convert_sheets();
ods_context->end_document();
}
void XlsxConverter::convert_sheets()
{
if (!ods_context) return;
const OOX::Spreadsheet::CWorkbook *Workbook= xlsx_document->GetWorkbook();
if (!Workbook) return;
CAtlMap<CString, OOX::Spreadsheet::CWorksheet*> &arrWorksheets = xlsx_document->GetWorksheets();
if(Workbook->m_oSheets.IsInit())
{
CSimpleArray<OOX::Spreadsheet::CSheet*>& aWs = Workbook->m_oSheets->m_arrItems;//
for(int i = 0, length = aWs.GetSize(); i < length; ++i)
{
OOX::Spreadsheet::CSheet* pSheet = aWs[i];
if(pSheet->m_oRid.IsInit())
{
CString sSheetRId = pSheet->m_oRid.get2().ToString();
CAtlMap<CString, OOX::Spreadsheet::CWorksheet*>::CPair* pPair = arrWorksheets.Lookup(sSheetRId);
if (NULL != pPair)
{
OOX::Spreadsheet::CWorksheet *pWorksheet = pPair->m_value;
if (NULL != pWorksheet && pWorksheet->m_oSheetData.IsInit())
{
std::wstring name = string2std_string(pSheet->m_oName.get2());
ods_context->start_sheet(name);
convert(pWorksheet);
ods_context->end_sheet();
}
}
}
}
}
}
void XlsxConverter::convert(OOX::Spreadsheet::CWorksheet *oox_sheet)
{
}
void XlsxConverter::convert_styles()
{
if (!ods_context) return;
OOX::Spreadsheet::CStyles * xlsx_styles = xlsx_document->GetStyles();
if (!xlsx_styles)return;
if (!xlsx_styles->m_oCellStyleXfs.IsInit())return;
for (long i=0;i< xlsx_styles->m_oCellXfs->m_oCount->GetValue(); i++)
{
ods_context->styles_context().start_style(L"" ,odf::style_family::TableCell,true); // - () - oox
//
// //find_fill_by_id (xlsx_styles->m_oCellXfs->m_arrItems[i]->m_oFillId); // graphic_properies
// //find_num_format_by_id (xlsx_styles->m_oCellXfs->m_arrItems[i]->m_oNumFmtId); //
// //find_text_by_id (xlsx_styles->m_oCellXfs->m_arrItems[i]->m_oFontId); // text_properties
//
ods_context->styles_context().end_style();
}
for (long i=0;i< xlsx_styles->m_oCellStyles->m_oCount->GetValue(); i++)//styles.xml
{
std::wstring style_name = string2std_string(xlsx_styles->m_oCellStyles->m_arrItems[i]->m_oName.get2());
ods_context->styles_context().start_style(style_name ,odf::style_family::TableCell);
int id_xfd = xlsx_styles->m_oCellStyles->m_arrItems[i]->m_oXfId->GetValue();
xlsx_styles->m_oCellXfs->m_arrItems[id_xfd];//
//odf::office_element_ptr & elm = ods_context->styles_context().find_by_id(, odf::style_family::TableCell);
//ods_context->styles_.back()->add_child(elm);
//ods_context->styles_context().start_style(xlsx_styles->m_oCellStyles->m_arrItems[i]->m_oName,odf::style_family::TableCell);
//generate style:style
//ods_context->styles_context().current_style().set_cell_style_id();
//// - , text_properies, ... - //style:table-cell-properties, style:paragraph-properties , ...
//ods_context->styles_context().current_style().set_hidden(xlsx_styles->m_oCellStyles->m_arrItems[i]->m_oHidden->ToBool())
//ods_context->styles_context().current_style().set_level(xlsx_styles->m_oCellStyles->m_arrItems[i]->m_oILevel->GetValue())
//
ods_context->styles_context().end_style();
}
}
} // namespace Docx2Odt
\ No newline at end of file
#pragma once
#include "Converter.h"
#include <boost/foreach.hpp>
#include <XlsxFormat\Xlsx.h>
namespace OOX
{
class CDocx;
}
namespace cpdoccore
{
namespace odf
{
namespace package
{
class odf_document;
}
class ods_conversion_context;
}
}
namespace Oox2Odf
{
class XlsxConverter : public OoxConverter
{
public:
XlsxConverter(const std::wstring & path);
virtual void convert();
virtual void write(const std::wstring & path);
private:
OOX::Spreadsheet::CXlsx *xlsx_document;
cpdoccore::odf::package::odf_document *output_document;
cpdoccore::odf::ods_conversion_context *ods_context;
void convert_sheets();
void convert_styles();
void convert(OOX::Spreadsheet::CWorksheet *oox_sheet);
};
}
\ No newline at end of file
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