Commit 076de8bb authored by ElenaSubbotina's avatar ElenaSubbotina

OdfFormatWriter - настройки табличек (активный лист, текущие ячейки, ...) + закрепленные области

parent bfbdc714
......@@ -47,21 +47,30 @@ void odf_conversion_context::set_fonts_directory(std::wstring pathFonts)
odf_style_context* odf_conversion_context::styles_context()
{
if (objects_.size() > 0)
if (!objects_.empty())
return objects_[current_object_].style_context.get();
else
return NULL;
}
odf_settings_context* odf_conversion_context::settings_context()
{
if (!objects_.empty())
return objects_[current_object_].settings_context.get();
else
return NULL;
}
odf_page_layout_context* odf_conversion_context::page_layout_context()
{
return &page_layout_context_;
}
odf_chart_context* odf_conversion_context::chart_context()
{
return &chart_context_;
}
odf_number_styles_context* odf_conversion_context::numbers_styles_context()
{
if (objects_.size() > 0 && objects_[current_object_].style_context)
......
......@@ -51,16 +51,17 @@ public:
CApplicationFonts *applicationFonts_;
virtual odf_drawing_context * drawing_context() = 0;
virtual odf_text_context * text_context() = 0;
virtual odf_drawing_context * drawing_context() = 0;
virtual odf_text_context * text_context() = 0;
virtual void start_text_context() = 0;
virtual void end_text_context() = 0;
virtual void start_text_context() = 0;
virtual void end_text_context() = 0;
virtual void start_image(const std::wstring & image_file_name) = 0;
virtual odf_style_context * styles_context();
odf_settings_context * settings_context();
odf_chart_context * chart_context();
odf_page_layout_context * page_layout_context();
......
......@@ -15,6 +15,8 @@ namespace odf_writer {
odf_settings_context::odf_settings_context()
{
current_view_ = -1;
current_table_ = -1;
}
void odf_settings_context::set_odf_context(odf_conversion_context * Context)
......@@ -23,6 +25,68 @@ void odf_settings_context::set_odf_context(odf_conversion_context * Context)
}
void odf_settings_context::start_view()
{
_view v;
views_.push_back(v);
current_view_ = views_.size() - 1;
}
void odf_settings_context::end_view()
{
current_view_ = -1;
}
void odf_settings_context::set_current_view(int id)
{
if (id < 0 || id >= views_.size()) return;
current_view_ = id;
}
void odf_settings_context::start_table(std::wstring name)
{
if (current_view_ < 0) return;
_table t;
t.name = name;
views_[current_view_].tables.push_back(t);
current_table_ = views_[current_view_].tables.size() - 1;
}
void odf_settings_context::end_table()
{
current_table_ = -1;
}
void odf_settings_context::add_property(std::wstring name, std::wstring type, std::wstring value)
{
if (current_view_ < 0) return;
if (name.empty() || type.empty()) return;
office_element_ptr prop;
create_element (L"config", L"config-item", prop, odf_context_);
settings_config_item *item = NULL;
item = dynamic_cast<settings_config_item*>(prop.get());
if (!item) return;
item->config_name_ = name;
item->config_type_ = type;
item->content_ = value;
if (current_table_ < 0)
{
views_[current_view_].content.push_back(prop);
}
else
{
views_[current_view_].tables.back().content.push_back(prop);
}
}
void odf_settings_context::process_office_settings(office_element_ptr root )
{
settings_config_item_set *item_set = NULL;
......@@ -30,7 +94,7 @@ void odf_settings_context::process_office_settings(office_element_ptr root )
settings_config_item_map_indexed *item_map_indexed = NULL;
settings_config_item_map_entry *item_map_entry = NULL;
if (!views_.content.empty() || !views_.tables.empty())
if (!views_.empty())
{
office_element_ptr ooo_view_elm;
{
......@@ -47,36 +111,41 @@ void odf_settings_context::process_office_settings(office_element_ptr root )
if (item_map_indexed) item_map_indexed->config_name_ = L"Views";
}
office_element_ptr views_entry_elm;
for (int v = 0 ; v < views_.size(); v++)
{
create_element (L"config", L"config-item-map-entry" , views_entry_elm, odf_context_);
views_elm->add_child_element(views_entry_elm);
}
for (int i = 0; i < views_.content.size(); i++)
{
views_entry_elm->add_child_element(views_.content[i]);
}
if (!views_.tables.empty())
{
office_element_ptr tables_elm;
create_element(L"config", L"config-item-map-named", tables_elm, odf_context_);
views_entry_elm->add_child_element(tables_elm);
item_map_named= dynamic_cast<settings_config_item_map_named*>(tables_elm.get());
if (item_map_named) item_map_indexed->config_name_ = L"Tables";
office_element_ptr views_entry_elm;
{
create_element (L"config", L"config-item-map-entry" , views_entry_elm, odf_context_);
views_elm->add_child_element(views_entry_elm);
}
for (std::map<std::wstring, std::vector<office_element_ptr>>::iterator it = views_.tables.begin(); it != views_.tables.end(); it++)
for (int i = 0; i < views_[v].content.size(); i++)
{
office_element_ptr table_elm;
create_element(L"config", L"config-item-map-entry", table_elm, odf_context_);
tables_elm->add_child_element(table_elm);
item_map_entry= dynamic_cast<settings_config_item_map_entry*>(table_elm.get());
if (item_map_entry) item_map_indexed->config_name_ = it->first;
views_entry_elm->add_child_element(views_[v].content[i]);
}
for (int j = 0; j < it->second.size(); j++)
if (!views_[v].tables.empty())
{
office_element_ptr tables_elm;
create_element(L"config", L"config-item-map-named", tables_elm, odf_context_);
views_entry_elm->add_child_element(tables_elm);
item_map_named= dynamic_cast<settings_config_item_map_named*>(tables_elm.get());
if (item_map_named) item_map_named->config_name_ = L"Tables";
for (int t = 0 ; t < views_[v].tables.size(); t++)
{
table_elm->add_child_element(it->second[j]);
office_element_ptr table_elm;
create_element(L"config", L"config-item-map-entry", table_elm, odf_context_);
tables_elm->add_child_element(table_elm);
item_map_entry= dynamic_cast<settings_config_item_map_entry*>(table_elm.get());
if (item_map_entry) item_map_entry->config_name_ = views_[v].tables[t].name;
for (int j = 0; j < views_[v].tables[t].content.size(); j++)
{
table_elm->add_child_element(views_[v].tables[t].content[j]);
}
}
}
}
......
......@@ -26,16 +26,34 @@ public:
void process_office_settings(office_element_ptr root );
void start_view ();
void end_view ();
void set_current_view(int id);
void start_table(std::wstring name);
void end_table ();
void add_property(std::wstring name, std::wstring type, std::wstring value);
private:
struct views
struct _table
{
std::wstring name;
std::vector<office_element_ptr> content;
};
struct _view
{
std::map<std::wstring, std::vector<office_element_ptr>> tables;
std::vector<office_element_ptr> content;
}views_;
std::vector<_table> tables;
std::vector<office_element_ptr> content;
};
std::vector<_view> views_;
std::vector<office_element_ptr> config_content_;
odf_conversion_context* odf_context_;
int current_table_;
int current_view_;
};
......
......@@ -101,10 +101,10 @@ void ods_conversion_context::start_sheet()
void ods_conversion_context::set_sheet_dimension(const std::wstring & ref)
{
std::vector<std::wstring> ref_cells;
boost::algorithm::split(ref_cells,ref, boost::algorithm::is_any_of(L":"), boost::algorithm::token_compress_on);
boost::algorithm::split(ref_cells, ref, boost::algorithm::is_any_of(L":"), boost::algorithm::token_compress_on);
int max_col = 0, max_row = 0;
for (long i=0; i<ref_cells.size(); i++)
for (long i = 0; i < ref_cells.size(); i++)
{
int col = -1, row = -1;
utils::parsing_ref (ref_cells[i], col, row);
......@@ -112,7 +112,7 @@ void ods_conversion_context::set_sheet_dimension(const std::wstring & ref)
if (col > max_col) max_col = col;
if (col > max_row) max_row = row;
}
current_table().set_table_dimension(max_col,max_row);
current_table().set_table_dimension(max_col, max_row);
}
void ods_conversion_context::end_sheet()
......@@ -488,12 +488,16 @@ double ods_conversion_context::convert_symbol_width(double val)
return pixels * 0.75; //* 9525. * 72.0 / (360000.0 * 2.54);
}
void ods_conversion_context::start_table_view(std::wstring table_name, int view_id)
void ods_conversion_context::start_table_view( int view_id )
{
settings_context()->set_current_view(view_id);
settings_context()->start_table(current_table().office_table_name_);
}
void ods_conversion_context::end_table_view()
{
settings_context()->end_table();
settings_context()->set_current_view(-1);
}
......
......@@ -83,7 +83,7 @@ public:
void start_conditional_formats();
void end_conditional_formats(){}
void start_table_view(std::wstring table_name, int view_id);
void start_table_view(int view_id);
void end_table_view();
private:
......
......@@ -112,10 +112,7 @@ void settings_config_item_map_indexed::serialize(std::wostream & _Wostream)
{
CP_XML_NODE_SIMPLE()
{
if (!config_name_.empty())
{
CP_XML_ATTR( L"config:name", config_name_);
}
CP_XML_ATTR_OPT( L"config:name", config_name_);
BOOST_FOREACH(const office_element_ptr & elm, content_)
{
......@@ -144,10 +141,8 @@ void settings_config_item_map_named::serialize(std::wostream & _Wostream)
{
CP_XML_NODE_SIMPLE()
{
if (!config_name_.empty())
{
CP_XML_ATTR( L"config:name", config_name_);
}
CP_XML_ATTR_OPT( L"config:name", config_name_);
BOOST_FOREACH(const office_element_ptr & elm, content_)
{
elm->serialize(CP_XML_STREAM());
......@@ -175,6 +170,8 @@ void settings_config_item_map_entry::serialize(std::wostream & _Wostream)
{
CP_XML_NODE_SIMPLE()
{
CP_XML_ATTR_OPT( L"config:name", config_name_);
BOOST_FOREACH(const office_element_ptr & elm, content_)
{
elm->serialize(CP_XML_STREAM());
......
......@@ -88,7 +88,7 @@ public:
virtual void serialize(std::wostream & _Wostream);
std::wstring config_name_;
_CP_OPT(std::wstring) config_name_;
office_element_ptr_array content_;
};
CP_REGISTER_OFFICE_ELEMENT2(settings_config_item_map_indexed);
......@@ -108,7 +108,7 @@ public:
virtual void serialize(std::wostream & _Wostream);
std::wstring config_name_;
_CP_OPT(std::wstring) config_name_;
office_element_ptr_array content_;
};
CP_REGISTER_OFFICE_ELEMENT2(settings_config_item_map_named);
......@@ -128,7 +128,8 @@ public:
virtual void serialize(std::wostream & _Wostream);
office_element_ptr_array content_;
_CP_OPT(std::wstring) config_name_;
office_element_ptr_array content_;
};
CP_REGISTER_OFFICE_ELEMENT2(settings_config_item_map_entry);
......
......@@ -61,6 +61,7 @@ namespace OOX
class CPageSetup;
class CPageMargins;
class CSi;
class CWorkbookView;
}
}
......@@ -140,7 +141,8 @@ namespace Oox2Odf
void convert(OOX::Spreadsheet::CSheetViews *oox_sheet_views);
void convert(OOX::Spreadsheet::CPageSetup *oox_page);
void convert(OOX::Spreadsheet::CPageMargins *oox_page);
void convert(OOX::Spreadsheet::CWorkbookView *oox_book_views);
void convert(OOX::Spreadsheet::CFont *font, odf_writer::style_text_properties *text_properties);
void convert(OOX::Spreadsheet::CBorder *border, odf_writer::style_table_cell_properties *cell_properties);
void convert(OOX::Spreadsheet::CFill *fill, odf_writer::style_table_cell_properties *cell_properties);
......@@ -156,16 +158,16 @@ namespace Oox2Odf
void convert(OOX::Spreadsheet::CNumFmt *numFmt);
void convert(OOX::Spreadsheet::CDxf *dxFmt, int oox_id);
void convert(OOX::Spreadsheet::CCellAnchor *oox_anchor);
void convert(OOX::Spreadsheet::CDrawing *oox_drawing);
void convert(OOX::Spreadsheet::CCellAnchor *oox_anchor);
void convert(OOX::Spreadsheet::CDrawing *oox_drawing);
void convert(OOX::Spreadsheet::CFromTo *oox_from_to, oox_table_position * pos);
void convert(OOX::Spreadsheet::CFromTo *oox_from_to, oox_table_position * pos);
void convert(OOX::Spreadsheet::CPic *oox_picture);
void convert(OOX::Spreadsheet::CShape *oox_shape);
void convert(OOX::Spreadsheet::CConnShape *oox_conn_shape);
void convert(OOX::Spreadsheet::CGraphicFrame *oox_graphic_frame);
void convert(OOX::Spreadsheet::CGroupShape *oox_group_shape);
void convert(OOX::Spreadsheet::CPic *oox_picture);
void convert(OOX::Spreadsheet::CShape *oox_shape);
void convert(OOX::Spreadsheet::CConnShape *oox_conn_shape);
void convert(OOX::Spreadsheet::CGraphicFrame *oox_graphic_frame);
void convert(OOX::Spreadsheet::CGroupShape *oox_group_shape);
void convert(OOX::Spreadsheet::CConditionalFormatting *oox_cond_fmt);
void convert(OOX::Spreadsheet::CConditionalFormattingRule *oox_cond_rule);
......
......@@ -409,7 +409,6 @@ namespace OOX
nullable<SimpleTypes::COnOff<>> m_oThickTop;
nullable<SimpleTypes::COnOff<>> m_oZeroHeight;
};
class CPane : public WritingElement
{
public:
......@@ -487,10 +486,84 @@ namespace OOX
nullable<SimpleTypes::CDouble> m_oYSplit;
};
class CSelection : public WritingElement
{
public:
WritingElementSpreadsheet_AdditionConstructors(CSelection)
CSelection()
{
}
virtual ~CSelection()
{
}
public:
virtual CString toXML() const
{
return _T("");
}
virtual void toXML(XmlUtils::CStringWriter& writer) const
{
writer.WriteString(_T("<selection"));
if (m_oActiveCell.IsInit())
{
CString sVal; sVal.Format(_T(" activeCell=\"%ls\""), m_oActiveCell.get());
writer.WriteString(sVal);
}
if (m_oActiveCellId.IsInit())
{
CString sVal; sVal.Format(_T(" activeCellId=\"%d\""), m_oActiveCellId.get());
writer.WriteString(sVal);
}
if (m_oSqref.IsInit())
{
CString sVal; sVal.Format(_T(" sqref=\"%ls\""), m_oSqref.get());
writer.WriteString(sVal);
}
if (m_oPane.IsInit())
{
CString sVal; sVal.Format(_T(" pane=\"%ls\""), m_oPane.get());
writer.WriteString(sVal);
}
writer.WriteString(_T("/>"));
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( !oReader.IsEmptyNode() )
oReader.ReadTillEnd();
}
virtual EElementType getType () const
{
return et_Selection;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
//
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("activeCell") , m_oActiveCell)
WritingElement_ReadAttributes_Read_if ( oReader, _T("activeCellId") , m_oActiveCellId)
WritingElement_ReadAttributes_Read_if ( oReader, _T("sqref") , m_oSqref)
WritingElement_ReadAttributes_Read_if ( oReader, _T("pane") , m_oPane)
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<CString> m_oActiveCell;
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oActiveCellId;
nullable<CString> m_oSqref;
nullable<CString> m_oPane; //bottomLeft, bottomRight, topLeft, topRight
};
//:
//<extLst>
//<pivotSelection>
//<selection>
class CSheetView : public WritingElement
{
public:
......@@ -609,6 +682,9 @@ namespace OOX
if (m_oPane.IsInit())
m_oPane->toXML(writer);
if (m_oSelection.IsInit())
m_oSelection->toXML(writer);
writer.WriteString(_T("</sheetView>"));
}
......@@ -626,7 +702,8 @@ namespace OOX
if (_T("pane") == sName)
m_oPane = oReader;
}
if (_T("selection") == sName)
m_oSelection = oReader; }
}
virtual EElementType getType () const
......@@ -666,6 +743,7 @@ namespace OOX
public:
nullable<CPane> m_oPane;
nullable<CSelection> m_oSelection;
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oColorId;
nullable<SimpleTypes::COnOff<>> m_oDefaultGridColor;
......
......@@ -304,6 +304,7 @@ namespace Spreadsheet
et_SheetPr,
et_Pane,
et_ExternalBook,
et_Selection,
et_PictureNonVisual,
et_NonVisualDrawingProperties,
......
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