Commit 2f958852 authored by Elen.Subbotina's avatar Elen.Subbotina Committed by Alexander Trofimov

(1.2.0.60): ASCOfficeOdfFileW


git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@56513 954022d7-b5bf-4e40-9824-e11837661b57
parent eec4d53d
......@@ -998,6 +998,14 @@
RelativePath=".\OdfFormat\table.h"
>
</File>
<File
RelativePath=".\OdfFormat\table_database_ranges.cpp"
>
</File>
<File
RelativePath=".\OdfFormat\table_database_ranges.h"
>
</File>
<File
RelativePath=".\OdfFormat\table_named_expressions.cpp"
>
......
......@@ -35,7 +35,7 @@ public:
virtual ~odf_conversion_context();
virtual void start_document() = 0 ;
void end_document();
virtual void end_document();
package::odf_document * output_document_;
......
......@@ -38,8 +38,8 @@ public:
void end_drawing();
void start_group(std::wstring name, int id);
void set_group_size( double width_pt, double height_pt);
void set_group_position(double x_pt, double y_pt);
void set_group_size_koef( double cx, double cy);
void set_group_position_delta(double x_pt, double y_pt);
void set_group_flip_H(bool bVal);
void set_group_flip_V(bool bVal);
......
......@@ -49,13 +49,22 @@ void ods_conversion_context::start_document()
root_spreadsheet_ = dynamic_cast<office_spreadsheet*>(get_current_object_element().get());
}
void ods_conversion_context::start_defined_expressions()
void ods_conversion_context::end_document()
{
create_element(L"table", L"named-expressions",root_spreadsheet_->getContent(),this);
table_context_.start_defined_expressions(root_spreadsheet_->getContent().back());
if (table_context_.table_database_ranges_.root)
root_spreadsheet_->add_child_element(table_context_.table_database_ranges_.root);
if (table_context_.table_defined_expressions_.root)
root_spreadsheet_->add_child_element(table_context_.table_defined_expressions_.root);
odf_conversion_context::end_document();
}
void ods_conversion_context::start_autofilter(std::wstring ref)
{
table_context_.start_autofilter(ref);
}
void ods_conversion_context::start_conditional_formats()
{
current_table().start_conditional_formats();
......
......@@ -28,6 +28,7 @@ public:
ods_conversion_context(package::odf_document * outputDocument);
virtual void start_document();
virtual void end_document();
void start_sheet();
void set_sheet_dimension(std::wstring & ref);
......@@ -73,10 +74,11 @@ public:
double convert_symbol_width(double val);
void start_defined_expressions();
void add_defined_range(std::wstring & name,std::wstring & cell_range, int sheet_id, bool printable = false);
void add_defined_expression(std::wstring & name,std::wstring & value, int sheet_id, bool printable = false);
void end_defined_expressions(){}
void add_defined_range(std::wstring & name,std::wstring & cell_range, int sheet_id, bool printable = false);
void add_defined_expression(std::wstring & name,std::wstring & value, int sheet_id, bool printable = false);
void start_autofilter(std::wstring ref);
void end_autofilter(){}
void start_conditional_formats();
......
......@@ -22,7 +22,29 @@ ods_table_state & ods_table_context::state()
{
return table_state_list_.back();
}
void ods_table_context::start_autofilter(std::wstring ref)
{
if (!table_database_ranges_.root) create_element(L"table", L"database-ranges",table_database_ranges_.root,&context_);
office_element_ptr elm;
create_element(L"table", L"database-range",elm,&context_);
table_database_range * d_range = dynamic_cast<table_database_range*>(elm.get());
if (!d_range)return;
static formulasconvert::oox2odf_converter formulas_converter;
std::wstring odf_range = formulas_converter.convert_named_ref(ref);
boost::algorithm::replace_all(odf_range, L"[", L"");
boost::algorithm::replace_all(odf_range, L"]", L"");
d_range->table_target_range_address_ = odf_range;
d_range->table_display_filter_buttons_= true;
table_database_ranges_.root->add_child_element(elm);
table_database_ranges_.elements.push_back(elm);
}
void ods_table_context::start_defined_expressions(office_element_ptr & root_elm)
{
table_defined_expressions_.root = root_elm;
......@@ -51,7 +73,7 @@ void ods_table_context::add_defined_range(std::wstring & name,std::wstring & cel
if (odf_base_cell.length() > 0)
named_range->table_base_cell_address_ = odf_base_cell;
table_defined_expressions_.defined.push_back(elm);
table_defined_expressions_.elements.push_back(elm);
if (sheet_id >=0)
{
......@@ -67,7 +89,11 @@ void ods_table_context::add_defined_range(std::wstring & name,std::wstring & cel
}
}
else
{
if (!table_defined_expressions_.root)create_element(L"table", L"named-expressions",table_defined_expressions_.root,&context_);
table_defined_expressions_.root->add_child_element(elm);
}
}
void ods_table_context::add_defined_expression(std::wstring & name,std::wstring & value, int sheet_id, bool printable)
......@@ -109,13 +135,16 @@ void ods_table_context::add_defined_expression(std::wstring & name,std::wstring
}
}
else
{
if (!table_defined_expressions_.root)create_element(L"table", L"named-expressions",table_defined_expressions_.root,&context_);
table_defined_expressions_.root->add_child_element(elm);
}
if (odf_base_cell.length() > 0)
named_expression->table_base_cell_address_ = odf_base_cell;
table_defined_expressions_.defined.push_back(elm);
table_defined_expressions_.elements.push_back(elm);
}
void ods_table_context::start_table(office_element_ptr & elm)
......
......@@ -15,12 +15,13 @@ class ods_text_context;
class office_element;
typedef shared_ptr<office_element>::Type office_element_ptr;
struct table_defined_expressions_state
struct table_additional_elements_state
{
office_element_ptr root;
std::vector<office_element_ptr> defined;
std::vector<office_element_ptr> elements;
};
/// \class ods_table_context
class ods_table_context
{
......@@ -40,12 +41,19 @@ public:
void add_defined_range(std::wstring & name,std::wstring & cell_range, int sheet_id, bool printable = false);
void add_defined_expression(std::wstring & name,std::wstring & value, int sheet_id, bool printable = false);
void start_autofilter(std::wstring ref);
private:
ods_conversion_context & context_;
std::list<ods_table_state> table_state_list_;
table_defined_expressions_state table_defined_expressions_;
table_additional_elements_state table_defined_expressions_;
table_additional_elements_state table_database_ranges_;
friend class ods_conversion_context;
};
......
......@@ -108,7 +108,7 @@ ods_table_state::ods_table_state(ods_conversion_context & Context, office_elemen
dimension_row = 1024;
defaut_row_height_ = 9;//
defaut_row_height_ = 9;
defaut_column_width_ = 28.34467120181406 * 1.674;//
}
......
......@@ -257,6 +257,7 @@ private:
office_element_ptr office_table_;
style* office_table_style_;//??? ìîæåò õðàíèòü êàê office_element_ptr ???
office_element_ptr table_defined_expressions_;
std::wstring row_default_cell_style_name_;
......
......@@ -141,6 +141,8 @@ enum ElementType
typeTableNamedExpressions,
typeTableNamedExpression,
typeTableNamedRange,
typeTableDatabaseRanges,
typeTableDatabaseRange,
typeTableTable,
typeTableTableColumn,
typeTableTableColumns,
......
......@@ -13,6 +13,7 @@
#include "common_attlists.h"
#include "tablemode.h"
#include "table_named_expressions.h"
#include "table_database_ranges.h"
namespace cpdoccore {
namespace odf {
......
#include "precompiled_cpodf.h"
#include "table_database_ranges.h"
#include <boost/make_shared.hpp>
#include <cpdoccore/xml/xmlchar.h>
#include <cpdoccore/xml/attributes.h>
#include <cpdoccore/xml/simple_xml_writer.h>
namespace cpdoccore {
namespace odf {
using xml::xml_char_wc;
// table:table-source
//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * table_database_ranges::ns = L"table";
const wchar_t * table_database_ranges::name = L"database-ranges";
void table_database_ranges::create_child_element(const ::std::wstring & Ns, const ::std::wstring & Name)
{
if CP_CHECK_NAME(L"table", L"database-range")
{
CP_CREATE_ELEMENT(database_ranges_);
}
else
{
}
}
void table_database_ranges::add_child_element(office_element_ptr & child_element)
{
ElementType type = child_element->get_type();
if (type == typeTableDatabaseRange)
{
database_ranges_.push_back(child_element);
}
else
{
}
}
void table_database_ranges::serialize(std::wostream & _Wostream)
{
CP_XML_WRITER(_Wostream)
{
CP_XML_NODE_SIMPLE()
{
BOOST_FOREACH(const office_element_ptr & elm, database_ranges_)
{
elm->serialize(CP_XML_STREAM());
}
}
}
}
// table:named-range
//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * table_database_range::ns = L"table";
const wchar_t * table_database_range::name = L"database-range";
void table_database_range::serialize(std::wostream & _Wostream)
{
CP_XML_WRITER(_Wostream)
{
CP_XML_NODE_SIMPLE()
{
CP_XML_ATTR_OPT(L"table:name", table_name_);
CP_XML_ATTR_OPT(L"table:target-range-address", table_target_range_address_);
CP_XML_ATTR_OPT(L"table:display-filter-buttons", table_display_filter_buttons_);
}
}
}
//
//// table:named-expression
////////////////////////////////////////////////////////////////////////////////////////////////////
//const wchar_t * table_database_range::ns = L"table";
//const wchar_t * table_database_range::name = L"named-expression";
//
//void table_database_range::serialize(std::wostream & _Wostream)
//{
// CP_XML_WRITER(_Wostream)
// {
// CP_XML_NODE_SIMPLE()
// {
// CP_XML_ATTR_OPT(L"table:name", table_name_);
// CP_XML_ATTR_OPT(L"table:expression", table_expression_);
// CP_XML_ATTR_OPT(L"table:base-cell-address", table_base_cell_address_);
// }
// }
//}
}
}
#pragma once
#include <iosfwd>
#include <cpdoccore/CPOptional.h>
#include <cpdoccore/xml/xmlelement.h>
#include <cpdoccore/xml/nodetype.h>
#include "office_elements.h"
#include "office_elements_create.h"
#include "style_ref.h"
#include "bool.h"
namespace cpdoccore {
namespace odf {
/// \brief table:named-expressions
class table_database_ranges : public office_element_impl<table_database_ranges>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeTableDatabaseRanges;
CPDOCCORE_DEFINE_VISITABLE();
virtual void create_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);
office_element_ptr_array database_ranges_;
};
CP_REGISTER_OFFICE_ELEMENT2(table_database_ranges);
/// \brief table:named-range
class table_database_range: public office_element_impl<table_database_range>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeTableDatabaseRange;
CPDOCCORE_DEFINE_VISITABLE();
virtual void create_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);
_CP_OPT(std::wstring) table_name_;
_CP_OPT(std::wstring) table_target_range_address_;
_CP_OPT(Bool) table_display_filter_buttons_;
};
CP_REGISTER_OFFICE_ELEMENT2(table_database_range);
///// \brief table:named-expression
//class table_named_expression : public office_element_impl<table_named_expression>
//{
//public:
// static const wchar_t * ns;
// static const wchar_t * name;
// static const xml::NodeType xml_type = xml::typeElement;
// static const ElementType type = typeTableNamedExpression;
//
// CPDOCCORE_DEFINE_VISITABLE();
//
// virtual void create_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);
//
// _CP_OPT(std::wstring) table_name_;
// _CP_OPT(std::wstring) table_expression_;
// _CP_OPT(std::wstring) table_base_cell_address_;
//
//};
//
//CP_REGISTER_OFFICE_ELEMENT2(table_named_expression);
}
}
......@@ -124,14 +124,14 @@ void OoxConverter::convert(OOX::Drawing::CGroupShapeProperties * oox_group_spP
double x =oox_group_spPr->m_oXfrm->m_oOff->m_oX.GetValue()/ oox_group_spPr->m_oXfrm->m_oChOff->m_oX.GetValue();
double y =oox_group_spPr->m_oXfrm->m_oOff->m_oY.GetValue()/ oox_group_spPr->m_oXfrm->m_oChOff->m_oY.GetValue();
//odf_context()->drawing_context()->set_group_position_delata(x, y);
odf_context()->drawing_context()->set_group_position_delta(x, y);
}
if (oox_group_spPr->m_oXfrm->m_oExt.IsInit() && oox_group_spPr->m_oXfrm->m_oChExt.IsInit())
{
double x =oox_group_spPr->m_oXfrm->m_oExt->m_oCx.GetValue()/ oox_group_spPr->m_oXfrm->m_oChExt->m_oCx.GetValue();
double y =oox_group_spPr->m_oXfrm->m_oExt->m_oCy.GetValue()/ oox_group_spPr->m_oXfrm->m_oChExt->m_oCy.GetValue();
double x =oox_group_spPr->m_oXfrm->m_oExt->m_oCx.ToPoints()/ oox_group_spPr->m_oXfrm->m_oChExt->m_oCx.ToPoints();
double y =oox_group_spPr->m_oXfrm->m_oExt->m_oCy.ToPoints()/ oox_group_spPr->m_oXfrm->m_oChExt->m_oCy.ToPoints();
//odf_context()->drawing_context()->set_group_size_koeff(x, y);
if (x != 0 && y != 0) odf_context()->drawing_context()->set_group_size_koef(x, y);
}
//???
//if (oox_group_spPr->m_oXfrm->m_oFlipH.GetValue() == SimpleTypes::onoffTrue)
......
......@@ -142,12 +142,10 @@ void XlsxConverter::convert_sheets()
}
if (Workbook->m_oDefinedNames.IsInit())
{
ods_context->start_defined_expressions();
for (int i = 0; i < Workbook->m_oDefinedNames->m_arrItems.GetSize(); i++)
{
convert(Workbook->m_oDefinedNames->m_arrItems[i]);
}
ods_context->end_defined_expressions();
}
}
void XlsxConverter::convert(OOX::Spreadsheet::CDefinedName *oox_defined)
......@@ -235,6 +233,8 @@ void XlsxConverter::convert(OOX::Spreadsheet::CWorksheet *oox_sheet)
convert(pDrawing);
}
}
////
//convert(oox_sheet->m_oSortState.GetPointer());
//
convert(oox_sheet->m_oAutofilter.GetPointer());
......@@ -709,8 +709,8 @@ void XlsxConverter::convert(OOX::Spreadsheet::CSheetFormatPr *oox_sheet_format_p
if (oox_sheet_format_pr->m_oDefaultColWidth.IsInit())
{
width = oox_sheet_format_pr->m_oDefaultColWidth->GetValue();
width = ods_context->convert_symbol_width(width);
}
width = ods_context->convert_symbol_width(width);
ods_context->current_table().defaut_column_width_ = width;//pt
column_properties->style_table_column_properties_attlist_.style_column_width_ = odf::length(odf::length(width,odf::length::pt).get_value_unit(odf::length::cm),odf::length::cm);
}
......@@ -1751,9 +1751,42 @@ void XlsxConverter::convert(OOX::Spreadsheet::CFormulaCF *oox_cond_formula)
if (!oox_cond_formula)return;
ods_context->current_table().set_conditional_formula(string2std_string(oox_cond_formula->m_sText));
}
void XlsxConverter::convert(OOX::Spreadsheet::CFilterColumn *oox_filter_column)
{
//nullable<SimpleTypes::CUnsignedDecimalNumber<> > m_oColId;
//nullable<SimpleTypes::COnOff<> > m_oHiddenButton;
//nullable<SimpleTypes::COnOff<> > m_oShowButton;
//nullable<CColorFilter > m_oColorFilter;
//nullable<CDynamicFilter > m_oDynamicFilter;
//nullable<CCustomFilters > m_oCustomFilters;
//nullable<CFilters > m_oFilters;
//nullable<CTop10 > m_oTop10;
}
void XlsxConverter::convert(OOX::Spreadsheet::CAutofilter *oox_filter)
{
if (!oox_filter)return;
std::wstring ref, sort_ref;
bool sort = false, caseSensitive = false;
if (oox_filter->m_oRef.IsInit())
ref = string2std_string(oox_filter->m_oRef->GetValue());
if (oox_filter->m_oSortState.IsInit())
{
sort = true;
if (oox_filter->m_oSortState->m_oRef.IsInit())
sort_ref = string2std_string(oox_filter->m_oSortState->m_oRef->GetValue());
if (oox_filter->m_oSortState->m_oCaseSensitive.IsInit() && oox_filter->m_oSortState->m_oCaseSensitive->GetValue()==1)
caseSensitive = true;
}
ods_context->start_autofilter(ref);//target
{
for (long i=0; i < oox_filter->m_arrItems.GetSize(); i++)//set items todooo
{
}
}
ods_context->end_autofilter();
}
} // namespace Docx2Odt
\ No newline at end of file
......@@ -54,6 +54,7 @@ namespace OOX
class CFormulaCF;
class CConditionalFormatValueObject;
class CAutofilter;
class CFilterColumn;
}
}
......@@ -165,6 +166,7 @@ namespace Oox2Odf
void convert(OOX::Spreadsheet::CConditionalFormatting *oox_cond_fmt);
void convert(OOX::Spreadsheet::CConditionalFormattingRule *oox_cond_rule);
void convert(OOX::Spreadsheet::CAutofilter *oox_filter);
void convert(OOX::Spreadsheet::CFilterColumn *oox_filter_column);
void convert(OOX::Spreadsheet::CDataBar *oox_cond_databar);
void convert(OOX::Spreadsheet::CColorScale *oox_cond_colorscale);
void convert(OOX::Spreadsheet::CIconSet *oox_cond_iconset);
......
......@@ -2,6 +2,6 @@
//1
//2
//0
//59
#define INTVER 1,2,0,59
#define STRVER "1,2,0,59\0"
//60
#define INTVER 1,2,0,60
#define STRVER "1,2,0,60\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