Commit 6fc4c6a2 authored by ElenaSubbotina's avatar ElenaSubbotina

OdfFormatWriter - fix chart data

parent 4e58b2ce
......@@ -128,7 +128,15 @@ public:
{
styles_context_ = NULL;
current_series_count_= 0;
local_table_enabled_ = true;// false; - пока тока КЭШ .. demo.docx
if (odf_context->type == SpreadsheetDocument)
{
local_table_enabled_ = false;
}
else
{
local_table_enabled_ = true;
}
}
......@@ -1441,8 +1449,6 @@ void odf_chart_context::set_cash(std::wstring format, std::vector<std::wstring>
void odf_chart_context::set_local_table (bool Val)
{
if (Val == false) return;
impl_->local_table_enabled_ = Val;
}
......
......@@ -55,10 +55,10 @@ namespace odf_writer {
//////////////////////////////////////////////////////////////////////////////////////////////////
odf_conversion_context::odf_conversion_context(package::odf_document * outputDocument) : chart_context_ (this), page_layout_context_(this)
odf_conversion_context::odf_conversion_context(_office_type_document type_, package::odf_document * outputDocument)
: type (type_), chart_context_ (this), page_layout_context_(this)
{
output_document_ = outputDocument;
current_object_ =0;
applicationFonts_ = new CApplicationFonts();
......
......@@ -52,7 +52,12 @@ class office_element;
typedef shared_ptr<office_element>::Type office_element_ptr;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
enum _office_type_document
{
TextDocument,
SpreadsheetDocument,
PresentationDocument
};
class odf_conversion_context : boost::noncopyable
{
struct _object
......@@ -70,7 +75,9 @@ class odf_conversion_context : boost::noncopyable
};
public:
odf_conversion_context(package::odf_document * outputDocument);
const _office_type_document type;
odf_conversion_context(_office_type_document type, package::odf_document * outputDocument);
virtual ~odf_conversion_context();
void set_fonts_directory(std::wstring pathFonts);
......
......@@ -74,7 +74,8 @@ void calculate_size_font_symbols(_font_metrix & metrix, CApplicationFonts *appFo
}
}
ods_conversion_context::ods_conversion_context(package::odf_document * outputDocument)
: odf_conversion_context(outputDocument), table_context_(*this), current_text_context_(NULL)
: odf_conversion_context (SpreadsheetDocument, outputDocument),
table_context_(*this), current_text_context_(NULL)
{
font_metrix_ = _font_metrix();
}
......
......@@ -60,7 +60,7 @@ int ods_table_state::current_table_row_ = 0;
int ods_table_state::tmp_column_ =0;
int ods_table_state::tmp_row_ =0;
namespace utils//////////////////////////////////////////// ОБўАя хрень .. вытащить что ли в utils ???
namespace utils//////////////////////////////////////////// ОБЩАЯ хрень .. вытащить что ли в utils ???
{
std::wstring convert_date(const std::wstring & oox_date)
......@@ -74,7 +74,7 @@ std::wstring convert_date(const std::wstring & oox_date)
{
return oox_date;
}
//todoooo ПЕРЕПИСАTЬ !!!!
//todoooo ПЕРЕПИСАТЬ !!!!
//boost::gregorian::date date_ = boost::gregorian::date(1900, 1, 1) + boost::gregorian::date_duration(iDate-2);
......@@ -103,7 +103,7 @@ std::wstring convert_time(const std::wstring & oox_time)
int hours=0, minutes=0;
double sec=0;
//todooo ПЕРЕПИСАTЬ !!!
//todooo ПЕРЕПИСАТЬ !!!
//boost::posix_time::time_duration day(24, 0, 0);
//
//double millisec = day.total_milliseconds() * dTime;
......
......@@ -72,7 +72,8 @@ double calculate_size_font_symbols(std::wstring str_test, std::wstring font_name
}
}
odt_conversion_context::odt_conversion_context(package::odf_document * outputDocument)
: odf_conversion_context(outputDocument),comment_context_(this), main_text_context_(NULL),table_context_(this)
: odf_conversion_context (TextDocument, outputDocument),
comment_context_(this), main_text_context_(NULL),table_context_(this)
{
current_field_.enabled = false;
current_field_.started = false;
......
......@@ -29,7 +29,6 @@
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "XlsxConverter.h"
#include "../utils.h"
......@@ -149,7 +148,6 @@ void XlsxConverter::convertDocument()
convert_sheets();
//удалим уже ненужный документ xlsx
if (UpdateProgress(800000))return;
delete xlsx_document; xlsx_document = NULL;
......@@ -222,7 +220,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CDefinedName *oox_defined)
bool printable = false;
if (name == L"_xlnm.Print_Area")printable = true;
if (false)//если простой - range, составной - выражение
if (false)//���� ������� - range, ��������� - ���������
ods_context->add_defined_range (name, string2std_string(oox_defined->m_oRef.get2()), sheet_id, printable);
else
ods_context->add_defined_expression (name, string2std_string(oox_defined->m_oRef.get2()), sheet_id, printable);
......@@ -240,22 +238,22 @@ void XlsxConverter::convert(OOX::Spreadsheet::CWorksheet *oox_sheet)
convert(oox_sheet->m_oSheetFormatPr.GetPointer());
convert(oox_sheet->m_oSheetPr.GetPointer());
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Предобработка
//гиперлинки
//�������������
//����������
for (unsigned int hyp = 0; oox_sheet->m_oHyperlinks.IsInit() && hyp < oox_sheet->m_oHyperlinks->m_arrItems.size(); hyp++)
{
convert(oox_sheet->m_oHyperlinks->m_arrItems[hyp],oox_sheet);
}
//комментарии
//�����������
std::map<CString, OOX::Spreadsheet::CCommentItem*>::iterator pos = oox_sheet->m_mapComments.begin();
while ( oox_sheet->m_mapComments.end() != pos )
{
convert(pos->second);
pos++;
}
//todooo для оптимизации - перенести мержи в начало
//todooo ��� ����������� - ��������� ����� � ������
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//колонки
//�������
ods_context->start_columns();
for (unsigned int col = 0 ; oox_sheet->m_oCols.IsInit() && col < oox_sheet->m_oCols->m_arrItems.size(); col++)
{
......@@ -263,7 +261,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CWorksheet *oox_sheet)
}
ods_context->end_columns();
//строки
//������
if (oox_sheet->m_oSheetData.IsInit() )
{
ods_context->start_rows();
......@@ -279,7 +277,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CWorksheet *oox_sheet)
oox_sheet->m_oSheetData.reset();
}
//мержи
//�����
for (unsigned int mrg = 0 ; oox_sheet->m_oMergeCells.IsInit() && mrg < oox_sheet->m_oMergeCells->m_arrItems.size(); mrg++)
{
if (oox_sheet->m_oMergeCells->m_arrItems[mrg]->m_oRef.IsInit())
......@@ -295,13 +293,13 @@ void XlsxConverter::convert(OOX::Spreadsheet::CWorksheet *oox_sheet)
convert(pDrawing);
}
}
////сортировки
////����������
//convert(oox_sheet->m_oSortState.GetPointer());
//автофильтры
//�����������
convert(oox_sheet->m_oAutofilter.GetPointer());
//условное форматирование
//�������� ��������������
if (oox_sheet->m_arrConditionalFormatting.size() >0)
{
ods_context->start_conditional_formats();
......@@ -311,7 +309,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CWorksheet *oox_sheet)
}
ods_context->end_conditional_formats();
}
//выносные части таблицы
//�������� ����� �������
if (oox_sheet->m_oTableParts.IsInit())
{
for (unsigned int i=0 ; i < oox_sheet->m_oTableParts->m_arrItems.size(); i++)
......@@ -660,7 +658,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CRPr *oox_run_pr)
text_properties->content().style_text_position_ = odf_types::text_position(+33.); break;
case SimpleTypes::verticalalignrunSubscript:
//text_properties->content().style_text_position_ = odf_types::text_position(odf_types::text_position::Sub); break;
text_properties->content().style_text_position_ = odf_types::text_position(-33.); break;//по умолчанию 58% - хуже выглядит
text_properties->content().style_text_position_ = odf_types::text_position(-33.); break;//�� ��������� 58% - ���� ��������
}
}
if (oox_run_pr->m_oScheme.IsInit() && oox_run_pr->m_oScheme->m_oFontScheme.IsInit())
......@@ -783,7 +781,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CCol *oox_column)
}
else
{
//нужно добавить дефолтный стиль для ячеек ДАННОГО листа
//����� �������� ��������� ����� ��� ����� ������� �����
//???
style_cell_name= ods_context->styles_context()->find_odf_style_name_default(odf_types::style_family::TableCell);
}
......@@ -919,7 +917,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CSheetViews *oox_sheet_views)
if (oox_sheet_views->m_arrItems[i]->m_oSelection->m_oSqref.IsInit())
{
//D6:D9 I9:I12 M16:M21 C20:I24
//в OpenOffice этого нету
//� OpenOffice ����� ����
}
}
if (oox_sheet_views->m_arrItems[i]->m_oPane.IsInit())
......@@ -1006,7 +1004,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CSheetFormatPr *oox_sheet_format_p
//nullable<SimpleTypes::COnOff<>> m_oThickTop;
//nullable<SimpleTypes::COnOff<>> m_oZeroHeight;
//Cell default////////////////////////////
////пока не красиво :( и главное НЕПРАВИЛЬНО c чегой то раз первый - то и делтный ???? - НЕФИГА - хз чё делать :(
////���� �� ������� :( � ������� ����������� c ����� �� ��� ������ - �� � ������� ???? - ������ - �� �� ������ :(
//odf_writer::odf_style_state_ptr default_cell_style;
//ods_context->styles_context()->find_odf_style_state(0,odf_types::style_family::TableCell, default_cell_style, true);
//if (default_cell_style) ods_context->styles_context()->add_default(default_cell_style);
......@@ -1018,8 +1016,8 @@ void XlsxConverter::convert(OOX::Spreadsheet::CSheetFormatPr *oox_sheet_format_p
///Column///////////////////////////////////////////////////////////////////////////////////////
ods_context->styles_context()->create_style(L"",odf_types::style_family::TableColumn, true, false, -1);
{
double width = 8.1; // из приложния MS Office 2010
//в xlsx необязательно задавать ширину (колонок) - дефолтное по приложению. в oo - обязательно
double width = 8.1; // �� ��������� MS Office 2010
//� xlsx ������������� �������� ������ (�������) - ��������� �� ����������. � oo - �����������
odf_writer::style* style = dynamic_cast<odf_writer::style*>(ods_context->styles_context()->last_state()->get_office_element().get());
if (style)
{
......@@ -1054,7 +1052,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CSheetFormatPr *oox_sheet_format_p
ods_context->current_table().defaut_row_height_ = height;//pt
row_properties->style_table_row_properties_attlist_.style_row_height_ = odf_types::length(odf_types::length(height,odf_types::length::pt).get_value_unit(odf_types::length::cm),odf_types::length::cm);
}
row_properties->style_table_row_properties_attlist_.style_use_optimal_row_height_ = true; //???? не знаю cтоит ли
row_properties->style_table_row_properties_attlist_.style_use_optimal_row_height_ = true; //???? �� ���� c���� ��
row_properties->style_table_row_properties_attlist_.common_break_attlist_.fo_break_before_ = odf_types::fo_break(odf_types::fo_break::Auto);
}
}
......@@ -1072,16 +1070,16 @@ void XlsxConverter::convert_styles()
OOX::Spreadsheet::CStyles * xlsx_styles = xlsx_document->GetStyles();
if (!xlsx_styles)return;
//todooo ?? стоит ли обращать на параметр Count ??
////////////форматы данных
//todooo ?? ����� �� �������� �� �������� Count ??
////////////������� ������
for (unsigned int i = 0; xlsx_styles->m_oNumFmts.IsInit() && i < xlsx_styles->m_oNumFmts->m_arrItems.size(); i++)
{
convert(xlsx_styles->m_oNumFmts->m_arrItems[i]);
}
/////////////стили ячеек
/////////////����� �����
for (unsigned int i = 0; xlsx_styles->m_oCellStyleXfs.IsInit() && i < xlsx_styles->m_oCellStyleXfs->m_arrItems.size(); i++)
{
//automatical, root - noname - они тока для named
//automatical, root - noname - ��� ���� ��� named
convert(xlsx_styles->m_oCellStyleXfs->m_arrItems[i] , i, true, true);
}
for (unsigned int i = 0; xlsx_styles->m_oCellStyles.IsInit() && i < xlsx_styles->m_oCellStyles->m_arrItems.size(); i++)//styles.xml
......@@ -1090,14 +1088,14 @@ void XlsxConverter::convert_styles()
convert(xlsx_styles->m_oCellStyles->m_arrItems[i]);
}
//кастомные стили ячеек
//��������� ����� �����
for (unsigned int i = 0; xlsx_styles->m_oCellXfs.IsInit() && i < xlsx_styles->m_oCellXfs->m_arrItems.size(); i++)
{
//automatical, non root
convert(xlsx_styles->m_oCellXfs->m_arrItems[i], i, true, false);
}
////////////стили условного форматирования
////////////����� ��������� ��������������
for (unsigned int i=0; xlsx_styles->m_oDxfs.IsInit() && i < xlsx_styles->m_oDxfs->m_arrItems.size(); i++)
{
convert(xlsx_styles->m_oDxfs->m_arrItems[i], i);
......@@ -1178,7 +1176,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CFont * font, odf_writer::style_te
text_properties->content().style_text_position_ = odf_types::text_position(+33.); break;
case SimpleTypes::verticalalignrunSubscript:
//text_properties->content().style_text_position_ = odf_types::text_position(odf_types::text_position::Sub); break;
text_properties->content().style_text_position_ = odf_types::text_position(-33.); break;//по умолчанию 58% - хуже выглядит
text_properties->content().style_text_position_ = odf_types::text_position(-33.); break;//�� ��������� 58% - ���� ��������
}
}
if (font->m_oScheme.IsInit() && font->m_oScheme->m_oFontScheme.IsInit())
......@@ -1201,7 +1199,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CFont * font, odf_writer::style_te
void XlsxConverter::convert(double oox_size, _CP_OPT(odf_types::length) & odf_size)
{
//нужно сделать преобразования типов oox_size
//����� ������� �������������� ����� oox_size
//???
odf_size = odf_types::length(oox_size, odf_types::length::pt);
}
......@@ -1287,7 +1285,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CAligment *aligment, odf_writer::s
cell_properties->style_table_cell_properties_attlist_.common_rotation_angle_attlist_.style_rotation_angle_ = rot;
cell_properties->style_table_cell_properties_attlist_.style_rotation_align_= odf_types::rotation_align(odf_types::rotation_align::Bottom);
}
else if (rot == 0xff)//вертикальный текст
else if (rot == 0xff)//������������ �����
cell_properties->style_table_cell_properties_attlist_.style_direction_ = odf_types::direction(odf_types::direction::Ttb);
}
......@@ -1430,7 +1428,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CBorderProp *borderProp, std::wstr
odf_border_prop = border_style + border_color;
}
void XlsxConverter::convert(OOX::Spreadsheet::CColor *color, _CP_OPT(odf_types::color) & odf_color)//стоит ли сюда тащить odf_writer type???
void XlsxConverter::convert(OOX::Spreadsheet::CColor *color, _CP_OPT(odf_types::color) & odf_color)//����� �� ���� ������ odf_writer type???
{
if (!color)return;
......@@ -1546,8 +1544,8 @@ void XlsxConverter::convert(OOX::Spreadsheet::CCellStyle * cell_style)
//if (parent_id >=0)
// ods_context->styles_context()->last_state()->set_parent_style_name(ods_context->styles_context()->find_odf_style_name(parent_id, odf_types::style_family::TableCell,true, true));
//фишечка либры и оо - они НЕ ЧИTАЮT автоматические стили для стилей
//придется копировать свойства все .. они автоматические стили удалить (не сохранять в файл)
//������� ����� � �� - ��� �� ������ �������������� ����� ��� ������
//�������� ���������� �������� ��� .. ��� �������������� ����� ������� (�� ��������� � ����)
odf_writer::odf_style_state_ptr parent_style_state;
if (ods_context->styles_context()->find_odf_style_state(parent_id, odf_types::style_family::TableCell,parent_style_state, true, true) && parent_style_state)
......@@ -1646,7 +1644,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CXfs * xfc_style, int oox_id, bool
odf_writer::odf_style_state_ptr parent_style_state;
if (ods_context->styles_context()->find_odf_style_state(id_parent, odf_types::style_family::TableCell,parent_style_state, true, false)
&& parent_style_state) // сначала в поименованных
&& parent_style_state) // ������� � �������������
{
ods_context->styles_context()->last_state()->set_parent_style_name(parent_style_state->get_name());
......@@ -1698,7 +1696,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CCellAnchor *oox_anchor)
if (oox_anchor->m_oExt.IsInit())
{
}
//собственно
//����������
if (oox_anchor->m_oPicture.IsInit())
{
convert(oox_anchor->m_oPicture.GetPointer());
......@@ -1835,12 +1833,12 @@ void XlsxConverter::convert(OOX::Spreadsheet::CShape* oox_shape)
if (oox_shape->m_oNvSpPr.IsInit())
{
OoxConverter::convert(oox_shape->m_oNvSpPr->m_oCNvPr.GetPointer()); //имя, описалово, номер ...
convert(oox_shape->m_oNvSpPr->m_oCNvSpPr.GetPointer()); //заблокированности ... todooo
OoxConverter::convert(oox_shape->m_oNvSpPr->m_oCNvPr.GetPointer()); //���, ���������, ����� ...
convert(oox_shape->m_oNvSpPr->m_oCNvSpPr.GetPointer()); //����������������� ... todooo
}
if (oox_shape->m_oShapeStyle.IsInit())
{
//доп эффекты
//��� �������
}
if (oox_shape->m_oTxBody.IsInit())
......@@ -1886,7 +1884,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CGraphicFrame* oox_graphic_frame)
{
if (oox_graphic_frame->m_oChartGraphic->m_oGraphicData->m_oChart.IsInit() && oox_graphic_frame->m_oChartGraphic->m_oGraphicData->m_oChart->m_oRId.IsInit())
{
//диаграмма
//���������
CString sId = oox_graphic_frame->m_oChartGraphic->m_oGraphicData->m_oChart->m_oRId->GetValue();
smart_ptr<OOX::File> oFile = xlsx_current_drawing->Find(sId);
......@@ -1909,7 +1907,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CGraphicFrame* oox_graphic_frame)
}
}
}
//могут быть и другие типы объектов
//����� ���� � ������ ���� ��������
}
}
ods_context->drawing_context()->end_object();
......@@ -1943,7 +1941,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CConnShape* oox_shape)
{
OoxConverter::convert(oox_shape->m_oSpPr.GetPointer(), oox_shape->m_oShapeStyle.GetPointer());
//частенько приплывает из стиля заполенение объекта .. а он то одномерный :)
//��������� ���������� �� ����� ����������� ������� .. � �� �� ���������� :)
odf_context()->drawing_context()->start_area_properties();
odf_context()->drawing_context()->set_no_fill();
odf_context()->drawing_context()->end_area_properties();
......@@ -1969,7 +1967,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CConnShape* oox_shape)
void XlsxConverter::convert(OOX::Spreadsheet::CPic* oox_picture)
{
if (!oox_picture)return;
if (!oox_picture->m_oBlipFill.IsInit()) return; // невeрная структура оох
if (!oox_picture->m_oBlipFill.IsInit()) return; // ���e���� ��������� ���
ods_context->drawing_context()->start_drawing();
......
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