From e5c9394c0bf941fa10be0b591bd1f351c3fb9878 Mon Sep 17 00:00:00 2001 From: "Elen.Subbotina" Date: Sat, 1 Mar 2014 08:55:21 +0000 Subject: [PATCH] git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@54724 954022d7-b5bf-4e40-9824-e11837661b57 --- ASCOfficeOdfFile/cpodf.vcproj | 4 ++ .../src/odf/datatypes/style_ref.cpp | 20 +++++++++ .../src/odf/datatypes/style_ref.h | 11 ++--- ASCOfficeOdfFileW/source/OdfFormat.vcproj | 8 ++++ .../OdfFormat/ods_conversion_context.cpp | 2 +- .../source/OdfFormat/ods_table_context.cpp | 4 +- .../source/OdfFormat/ods_table_context.h | 2 +- .../source/OdfFormat/ods_table_state.cpp | 13 ++++++ .../source/OdfFormat/ods_table_state.h | 8 ++-- .../source/OdfFormat/office_body.cpp | 10 ++++- .../source/OdfFormat/office_spreadsheet.cpp | 13 +++++- ASCOfficeOdfFileW/source/OdfFormat/table.cpp | 43 +++++++++++++------ ASCOfficeOdfFileW/source/OdfFormat/table.h | 3 +- .../source/Oox2OdfConverter/Converter.cpp | 4 +- .../source/Oox2OdfConverter/Converter.h | 5 +++ 15 files changed, 117 insertions(+), 33 deletions(-) create mode 100644 ASCOfficeOdfFile/src/odf/datatypes/style_ref.cpp diff --git a/ASCOfficeOdfFile/cpodf.vcproj b/ASCOfficeOdfFile/cpodf.vcproj index 14a8519506..a7458cf3db 100644 --- a/ASCOfficeOdfFile/cpodf.vcproj +++ b/ASCOfficeOdfFile/cpodf.vcproj @@ -828,6 +828,10 @@ RelativePath=".\src\odf\datatypes\smil_transitiontype.h" > + + diff --git a/ASCOfficeOdfFile/src/odf/datatypes/style_ref.cpp b/ASCOfficeOdfFile/src/odf/datatypes/style_ref.cpp new file mode 100644 index 0000000000..fd20689a79 --- /dev/null +++ b/ASCOfficeOdfFile/src/odf/datatypes/style_ref.cpp @@ -0,0 +1,20 @@ +#include "precompiled_cpodf.h" +#include "style_ref.h" + +#include +#include +#include +#include + +namespace cpdoccore { +namespace odf { + + +std::wostream & operator << (std::wostream & _Wostream, const style_ref & _styleRef) +{ + _Wostream << _styleRef.style_name(); + return _Wostream; +} + +} +} \ No newline at end of file diff --git a/ASCOfficeOdfFile/src/odf/datatypes/style_ref.h b/ASCOfficeOdfFile/src/odf/datatypes/style_ref.h index 3f641404bb..f6d598574a 100644 --- a/ASCOfficeOdfFile/src/odf/datatypes/style_ref.h +++ b/ASCOfficeOdfFile/src/odf/datatypes/style_ref.h @@ -11,11 +11,11 @@ class style_ref public: style_ref() { - } ; + } style_ref(const ::std::wstring & StyleName) : style_name_(StyleName) { - } ; + } bool empty() const { @@ -37,15 +37,10 @@ private: ::std::wstring style_name_; }; +std::wostream & operator << (std::wostream & _Wostream, const style_ref & _styleReft); typedef ::std::vector style_ref_array; -template Ostream & operator << (Ostream & _Ostream, const style_ref & _styleRef) -{ - _Ostream << _styleRef.style_name(); - return _Ostream; -} - inline std::wistream & operator >> (std::wistream & _Istream, style_ref & _styleRef) { _Istream >> _styleRef.style_name(); diff --git a/ASCOfficeOdfFileW/source/OdfFormat.vcproj b/ASCOfficeOdfFileW/source/OdfFormat.vcproj index d47ebfe20d..9353145cab 100644 --- a/ASCOfficeOdfFileW/source/OdfFormat.vcproj +++ b/ASCOfficeOdfFileW/source/OdfFormat.vcproj @@ -582,6 +582,10 @@ RelativePath="..\..\ASCOfficeOdfFile\src\odf\datatypes\smil_transitiontype.h" > + + @@ -971,6 +975,10 @@ RelativePath=".\ReadMe.txt" > + + diff --git a/ASCOfficeOdfFileW/source/OdfFormat/ods_conversion_context.cpp b/ASCOfficeOdfFileW/source/OdfFormat/ods_conversion_context.cpp index a252f2eea1..a0484de0bd 100644 --- a/ASCOfficeOdfFileW/source/OdfFormat/ods_conversion_context.cpp +++ b/ASCOfficeOdfFileW/source/OdfFormat/ods_conversion_context.cpp @@ -26,7 +26,7 @@ void ods_conversion_context::start_sheet(std::wstring & name) { create_element(L"table", L"table",current_spreadsheet_->getContent(),this); - ods_table_context_.start_table(current_spreadsheet_->getContent().back()); + ods_table_context_.start_table(current_spreadsheet_->getContent().back(),name); } diff --git a/ASCOfficeOdfFileW/source/OdfFormat/ods_table_context.cpp b/ASCOfficeOdfFileW/source/OdfFormat/ods_table_context.cpp index b1c6d75473..7d4344a3ae 100644 --- a/ASCOfficeOdfFileW/source/OdfFormat/ods_table_context.cpp +++ b/ASCOfficeOdfFileW/source/OdfFormat/ods_table_context.cpp @@ -25,13 +25,15 @@ const ods_table_state & ods_table_context::state() const return table_state_list_.back(); } -void ods_table_context::start_table(office_element_ptr & elm) +void ods_table_context::start_table(office_element_ptr & elm, std::wstring & name) { table_state_list_.push_back( ods_table_state(context_, elm) ); + state().set_name(name); } void ods_table_context::end_table() { + state().convert(); } } } \ No newline at end of file diff --git a/ASCOfficeOdfFileW/source/OdfFormat/ods_table_context.h b/ASCOfficeOdfFileW/source/OdfFormat/ods_table_context.h index ed9e60651d..b9ac8b4c0c 100644 --- a/ASCOfficeOdfFileW/source/OdfFormat/ods_table_context.h +++ b/ASCOfficeOdfFileW/source/OdfFormat/ods_table_context.h @@ -20,7 +20,7 @@ public: ods_table_context(ods_conversion_context & Context/*, ods_text_context & textCotnext*/); public: - void start_table(office_element_ptr & elm); + void start_table(office_element_ptr & elm,std::wstring & name); void end_table(); //std::wstring get_current_table_name() const; diff --git a/ASCOfficeOdfFileW/source/OdfFormat/ods_table_state.cpp b/ASCOfficeOdfFileW/source/OdfFormat/ods_table_state.cpp index baafbb15c2..bab5baedcd 100644 --- a/ASCOfficeOdfFileW/source/OdfFormat/ods_table_state.cpp +++ b/ASCOfficeOdfFileW/source/OdfFormat/ods_table_state.cpp @@ -15,6 +15,19 @@ ods_table_state::ods_table_state(ods_conversion_context & Context, office_elemen } +void ods_table_state::set_name(std::wstring name) +{ + tableName_ = name; + office_element_->table_table_attlist_.table_name_ = name; +} + +void ods_table_state::convert() +{ + if (office_element_ == NULL)return; + + //последние штрихи??? проверки .. согласования + +} } } diff --git a/ASCOfficeOdfFileW/source/OdfFormat/ods_table_state.h b/ASCOfficeOdfFileW/source/OdfFormat/ods_table_state.h index 95824fbde7..b7ee2f48d9 100644 --- a/ASCOfficeOdfFileW/source/OdfFormat/ods_table_state.h +++ b/ASCOfficeOdfFileW/source/OdfFormat/ods_table_state.h @@ -22,8 +22,9 @@ class table_table; class ods_table_state { public: - ods_table_state(ods_conversion_context & Context, office_element_ptr & elm); + ods_table_state(ods_conversion_context & Context, office_element_ptr & elm); + void set_name(std::wstring); // std::wstring current_style() const { return table_style_; } // void start_column(unsigned int repeated, const std::wstring & defaultCellStyleName); // void start_row(const std::wstring & StyleName, const std::wstring & defaultCellStyleName); @@ -67,7 +68,7 @@ public: // void serialize_hyperlinks(std::wostream & _Wostream); // void dump_rels_hyperlinks(rels & Rels); - //std::wstring get_current_table_name() const { return tableName_; } + std::wstring get_current_table_name() const { return tableName_; } //struct _group_row //{ @@ -76,13 +77,14 @@ public: // int level; // bool collapsed; //}group_row_; + void convert(); private: ods_conversion_context & context_; table_table* office_element_; //std::wstring table_style_; - // std::wstring tableName_; + std::wstring tableName_; // std::wstring table_row_style_; // std::vector column_default_cell_style_name_; // std::wstring row_default_cell_style_name_; diff --git a/ASCOfficeOdfFileW/source/OdfFormat/office_body.cpp b/ASCOfficeOdfFileW/source/OdfFormat/office_body.cpp index 5ec87b676e..af8e4fe8c0 100644 --- a/ASCOfficeOdfFileW/source/OdfFormat/office_body.cpp +++ b/ASCOfficeOdfFileW/source/OdfFormat/office_body.cpp @@ -7,6 +7,8 @@ #include #include +#include + namespace cpdoccore { namespace odf { @@ -39,7 +41,13 @@ void office_body::add_child_element( office_element_ptr & child_element) void office_body::serialize(std::wostream & _Wostream) { - + CP_XML_WRITER(_Wostream) + { + CP_XML_NODE(L"office::body") + { + content_->serialize(CP_XML_STREAM()); + } + } } diff --git a/ASCOfficeOdfFileW/source/OdfFormat/office_spreadsheet.cpp b/ASCOfficeOdfFileW/source/OdfFormat/office_spreadsheet.cpp index 104ad5597f..59069fcf00 100644 --- a/ASCOfficeOdfFileW/source/OdfFormat/office_spreadsheet.cpp +++ b/ASCOfficeOdfFileW/source/OdfFormat/office_spreadsheet.cpp @@ -10,6 +10,8 @@ #include "office_elements.h" #include "office_elements_create.h" +#include + namespace cpdoccore { namespace odf { @@ -34,7 +36,16 @@ void office_spreadsheet::add_child_element(office_element_ptr & child_element) } void office_spreadsheet::serialize(std::wostream & _Wostream) { - + CP_XML_WRITER(_Wostream) + { + CP_XML_NODE(L"office:spreadsheet") + { + BOOST_FOREACH(office_element_ptr & elm, content_) + { + elm->serialize(CP_XML_STREAM()); + } + } + } } } diff --git a/ASCOfficeOdfFileW/source/OdfFormat/table.cpp b/ASCOfficeOdfFileW/source/OdfFormat/table.cpp index 6632b181cb..3f17188fd2 100644 --- a/ASCOfficeOdfFileW/source/OdfFormat/table.cpp +++ b/ASCOfficeOdfFileW/source/OdfFormat/table.cpp @@ -6,10 +6,11 @@ #include #include -//#include "serialize_elements.h" #include -//#include "odf_conversion_context.h" +#include + +#include "serialize_common_attlists.h" namespace cpdoccore { namespace odf { @@ -117,17 +118,6 @@ void table_table::add_attributes( const xml::attributes_wc_ptr & Attributes ) table_table_attlist_.add_attributes(Attributes); } - -//void table_table::add_child_element(office_element_ptr & child_element) -//{ -// //get_type -> -// content_.push_back(child_element); -//} -// -//void table_table::serialize(std::wostream & _Wostream) -//{ -// -//} void table_table::add_child_element(const ::std::wstring & Ns, const ::std::wstring & Name) { if (L"table" == Ns && L"table-source" == Name) @@ -158,6 +148,33 @@ void table_table::add_child_element(const ::std::wstring & Ns, const ::std::wstr } +void table_table::serialize(std::wostream & _Wostream) +{ + std::wstring ns_name_ =std::wstring(ns) + std::wstring(L":") + std::wstring(name); + CP_XML_WRITER(_Wostream) + { + CP_XML_NODE(ns_name_) + { + CP_XML_ATTR_OPT( L"table:name", table_table_attlist_.table_name_); + CP_XML_ATTR_OPT( L"table:style-name", table_table_attlist_.table_style_name_); + CP_XML_ATTR_OPT( L"table:template-name", table_table_attlist_.table_template_name_); + + if (table_table_attlist_.table_protected_) + CP_XML_ATTR_OPT( L"table:protection-key", table_table_attlist_.table_protection_key_); + + if (table_table_attlist_.table_print_) + CP_XML_ATTR_OPT( L"table:print-ranges", table_table_attlist_.table_print_ranges_); + + + if (table_shapes_)table_shapes_->serialize(CP_XML_STREAM()); + if (table_shapes_)table_shapes_->serialize(CP_XML_STREAM()); + + table_columns_and_groups_.serialize(CP_XML_STREAM()); + table_rows_and_groups_.serialize(CP_XML_STREAM()); + } + } +} + ////////////////////////////////////////////////////////////////////////////////////////////////// void table_table_column_attlist::add_attributes( const xml::attributes_wc_ptr & Attributes ) { diff --git a/ASCOfficeOdfFileW/source/OdfFormat/table.h b/ASCOfficeOdfFileW/source/OdfFormat/table.h index 50f86a5d8b..a27581a5eb 100644 --- a/ASCOfficeOdfFileW/source/OdfFormat/table.h +++ b/ASCOfficeOdfFileW/source/OdfFormat/table.h @@ -8,7 +8,6 @@ #include "office_elements.h" #include "office_elements_create.h" -#include "style_ref.h" #include "tablevisibility.h" #include "common_attlists.h" @@ -652,7 +651,7 @@ public: virtual void add_child_element(const ::std::wstring & Ns, const ::std::wstring & Name); virtual void add_child_element( office_element_ptr & child_element){} - virtual void serialize(std::wostream & _Wostream){} + virtual void serialize(std::wostream & _Wostream); private: virtual void add_attributes( const xml::attributes_wc_ptr & Attributes ); diff --git a/ASCOfficeOdfFileW/source/Oox2OdfConverter/Converter.cpp b/ASCOfficeOdfFileW/source/Oox2OdfConverter/Converter.cpp index f6f05dd3d5..cd6153810f 100644 --- a/ASCOfficeOdfFileW/source/Oox2OdfConverter/Converter.cpp +++ b/ASCOfficeOdfFileW/source/Oox2OdfConverter/Converter.cpp @@ -91,14 +91,14 @@ namespace Oox2Odf if(pSheet->m_oRid.IsInit()) { - CString sSheetRId = pSheet->m_oName.get2(); + CString sSheetRId = pSheet->m_oRid.get2().ToString(); CAtlMap::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 = L"";/*pSheet->m_oName.get2()*/ + std::wstring name = string2std_string(pSheet->m_oName.get2()); ods_conversion_context_.start_sheet(name); //CAtlMap::CPair* pair = aWorksheets.Lookup(pSheet->m_oRid->GetValue()); //if(NULL != pair) diff --git a/ASCOfficeOdfFileW/source/Oox2OdfConverter/Converter.h b/ASCOfficeOdfFileW/source/Oox2OdfConverter/Converter.h index 58857a04bf..56c9847143 100644 --- a/ASCOfficeOdfFileW/source/Oox2OdfConverter/Converter.h +++ b/ASCOfficeOdfFileW/source/Oox2OdfConverter/Converter.h @@ -2,6 +2,11 @@ #include +static std::wstring string2std_string(CString val) +{ + return std::wstring(val.GetBuffer()); +} + namespace Oox2Odf { class Impl;