Commit f3c66cab authored by ElenaSubbotina's avatar ElenaSubbotina

OdfFormatWriter

parent 11e6fc3e
<?xml version="1.0" encoding="windows-1251"?> <?xml version="1.0" encoding="windows-1251"?>
<VisualStudioProject <VisualStudioProject
ProjectType="Visual C++" ProjectType="Visual C++"
Version="8,00" Version="8.00"
Name="OdfFileReaderTest" Name="OdfFileReaderTest"
ProjectGUID="{C2882DDD-07E6-4314-AD4B-48F43F38D722}" ProjectGUID="{C2882DDD-07E6-4314-AD4B-48F43F38D722}"
RootNamespace="ASCOfficeOdfFileTest" RootNamespace="ASCOfficeOdfFileTest"
......
...@@ -136,7 +136,8 @@ void xlsx_text_context::Impl::serialize_shared_strings(std::wostream & strm) ...@@ -136,7 +136,8 @@ void xlsx_text_context::Impl::serialize_shared_strings(std::wostream & strm)
xlsx_text_context::Impl::Impl(odf_reader::styles_container & styles): paragraphs_cout_(0),styles_(styles), xlsx_text_context::Impl::Impl(odf_reader::styles_container & styles): paragraphs_cout_(0),styles_(styles),
in_comment(false),in_draw(false),in_paragraph(false),in_span(false),in_cell_content(false) in_comment(false),in_draw(false),in_paragraph(false),in_span(false),in_cell_content(false)
{ {
text_properties_cell_ = NULL; local_styles_ptr_ = NULL;
text_properties_cell_ = NULL;
} }
void xlsx_text_context::Impl::add_text(const std::wstring & text) void xlsx_text_context::Impl::add_text(const std::wstring & text)
......
...@@ -403,9 +403,11 @@ int draw_enhanced_geometry::parsing(_CP_OPT(std::wstring) val) ...@@ -403,9 +403,11 @@ int draw_enhanced_geometry::parsing(_CP_OPT(std::wstring) val)
void draw_enhanced_geometry_attlist::serialize(CP_ATTR_NODE) void draw_enhanced_geometry_attlist::serialize(CP_ATTR_NODE)
{ {
CP_XML_ATTR_OPT(L"draw:type", draw_type_); CP_XML_ATTR_OPT(L"draw:type", draw_type_);
CP_XML_ATTR_OPT(L"draw:text-areas", draw_text_areas_); CP_XML_ATTR_OPT(L"drawooo:sub-view-size", draw_sub_view_size_);
CP_XML_ATTR_OPT(L"draw:text-areas", draw_text_areas_);
CP_XML_ATTR_OPT(L"draw:modifiers", draw_modifiers_); CP_XML_ATTR_OPT(L"draw:modifiers", draw_modifiers_);
CP_XML_ATTR_OPT(L"draw:enhanced-path", draw_enhanced_path_); CP_XML_ATTR_OPT(L"drawooo:enhanced-path", draw_enhanced_path_);
//CP_XML_ATTR_OPT(L"draw:enhanced-path", draw_enhanced_path_);
CP_XML_ATTR_OPT(L"draw:glue-points", draw_glue_points_); CP_XML_ATTR_OPT(L"draw:glue-points", draw_glue_points_);
CP_XML_ATTR_OPT(L"draw:mirror-vertical", draw_mirror_vertical_); CP_XML_ATTR_OPT(L"draw:mirror-vertical", draw_mirror_vertical_);
CP_XML_ATTR_OPT(L"draw:mirror-horizontal", draw_mirror_horizontal_); CP_XML_ATTR_OPT(L"draw:mirror-horizontal", draw_mirror_horizontal_);
......
...@@ -316,19 +316,21 @@ CP_REGISTER_OFFICE_ELEMENT2(draw_handle); ...@@ -316,19 +316,21 @@ CP_REGISTER_OFFICE_ELEMENT2(draw_handle);
class draw_enhanced_geometry_attlist class draw_enhanced_geometry_attlist
{ {
public: public:
_CP_OPT(std::wstring) draw_type_; _CP_OPT(std::wstring) draw_type_;
_CP_OPT(std::wstring) draw_modifiers_; _CP_OPT(std::wstring) draw_modifiers_;
_CP_OPT(std::wstring) draw_enhanced_path_; _CP_OPT(std::wstring) draw_enhanced_path_;
_CP_OPT(std::wstring) draw_text_areas_; _CP_OPT(std::wstring) draw_text_areas_;
_CP_OPT(std::wstring) draw_glue_points_; _CP_OPT(std::wstring) draw_glue_points_;
_CP_OPT(odf_types::Bool) draw_mirror_vertical_; _CP_OPT(std::wstring) draw_sub_view_size_;
_CP_OPT(odf_types::Bool) draw_mirror_horizontal_;
_CP_OPT(odf_types::Bool) draw_mirror_vertical_;
_CP_OPT(odf_types::Bool) draw_mirror_horizontal_;
_CP_OPT(odf_types::Bool) draw_text_path_; _CP_OPT(odf_types::Bool) draw_text_path_;
_CP_OPT(odf_types::Bool) draw_text_path_same_letter_heights_; _CP_OPT(odf_types::Bool) draw_text_path_same_letter_heights_;
_CP_OPT(std::wstring) draw_text_path_mode_; _CP_OPT(std::wstring) draw_text_path_mode_;
_CP_OPT(std::wstring) draw_text_path_scale_; _CP_OPT(std::wstring) draw_text_path_scale_;
void serialize(CP_ATTR_NODE); void serialize(CP_ATTR_NODE);
}; };
......
...@@ -190,9 +190,9 @@ struct odf_drawing_state ...@@ -190,9 +190,9 @@ struct odf_drawing_state
path_ = L""; path_ = L"";
view_box_ = L""; view_box_ = L"";
path_last_command_ = L""; path_last_command_ = L"";
modifiers_ = L"";
oox_shape_preset = -1; oox_shape_preset = -1;
oox_shape_.reset();
in_group = false; in_group = false;
text_box_tableframe = false; text_box_tableframe = false;
...@@ -221,11 +221,10 @@ struct odf_drawing_state ...@@ -221,11 +221,10 @@ struct odf_drawing_state
bool flipH; bool flipH;
bool flipV; bool flipV;
std::wstring path_; std::wstring path_;
std::wstring view_box_; std::wstring view_box_;
std::wstring path_last_command_; std::wstring path_last_command_;
std::wstring modifiers_; oox_shape_ptr oox_shape_;
/////////////////////// ///////////////////////
int oox_shape_preset; int oox_shape_preset;
bool in_group; bool in_group;
...@@ -713,7 +712,7 @@ void odf_drawing_context::Impl::create_draw_base(int type) ...@@ -713,7 +712,7 @@ void odf_drawing_context::Impl::create_draw_base(int type)
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int level = current_level_.size(); int level = current_level_.size();
if (current_level_.size()>0) if (current_level_.size() > 0)
current_level_.back()->add_child_element(draw_elm); current_level_.back()->add_child_element(draw_elm);
current_level_.push_back(draw_elm); current_level_.push_back(draw_elm);
...@@ -722,6 +721,9 @@ void odf_drawing_context::Impl::create_draw_base(int type) ...@@ -722,6 +721,9 @@ void odf_drawing_context::Impl::create_draw_base(int type)
current_drawing_state_.elements_.push_back(state); current_drawing_state_.elements_.push_back(state);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if (type == 7)
current_drawing_state_.oox_shape_ = oox_shape_ptr(new oox_shape());
} }
void odf_drawing_context::start_shape(int type) void odf_drawing_context::start_shape(int type)
...@@ -738,7 +740,7 @@ void odf_drawing_context::start_shape(int type) ...@@ -738,7 +740,7 @@ void odf_drawing_context::start_shape(int type)
} }
else if (type == 1001) else if (type == 1001)
{ {
impl_->create_draw_base(6);//пока кастом .. потом переделать на path, что правильнее impl_->create_draw_base(6); //path
} }
else if (type == 2000) else if (type == 2000)
{ {
...@@ -748,9 +750,9 @@ void odf_drawing_context::start_shape(int type) ...@@ -748,9 +750,9 @@ void odf_drawing_context::start_shape(int type)
{ {
start_image(L""); start_image(L"");
} }
else if (type > 2000 && type < 3000) else if (type > 2000 && type < 3000) //custom text path
{ {
impl_->create_draw_base(7); impl_->create_draw_base(7);
} }
} }
...@@ -812,7 +814,10 @@ void odf_drawing_context::end_shape() ...@@ -812,7 +814,10 @@ void odf_drawing_context::end_shape()
if (impl_->current_drawing_state_.oox_shape_preset == 3000) return end_image(); if (impl_->current_drawing_state_.oox_shape_preset == 3000) return end_image();
//вторичные, вычисляемые свойства шейпов //вторичные, вычисляемые свойства шейпов
bool line_always_present = false; if (isLineShape())
{
impl_->current_graphic_properties->common_draw_fill_attlist_.draw_fill_ = draw_fill::none;
}
draw_path* path = dynamic_cast<draw_path*>(impl_->current_drawing_state_.elements_[0].elm.get()); draw_path* path = dynamic_cast<draw_path*>(impl_->current_drawing_state_.elements_[0].elm.get());
if (path) if (path)
...@@ -821,10 +826,8 @@ void odf_drawing_context::end_shape() ...@@ -821,10 +826,8 @@ void odf_drawing_context::end_shape()
set_viewBox( impl_->current_drawing_state_.svg_width_->get_value_unit(length::cm) * 1000, set_viewBox( impl_->current_drawing_state_.svg_width_->get_value_unit(length::cm) * 1000,
impl_->current_drawing_state_.svg_height_->get_value_unit(length::cm) *1000); impl_->current_drawing_state_.svg_height_->get_value_unit(length::cm) *1000);
if (impl_->current_drawing_state_.path_.length()>1) path->draw_path_attlist_.svg_d_ = impl_->current_drawing_state_.path_; if (!impl_->current_drawing_state_.path_.empty()) path->draw_path_attlist_.svg_d_ = impl_->current_drawing_state_.path_;
if (impl_->current_drawing_state_.view_box_.length()>1) path->draw_path_attlist_.svg_viewbox_ = impl_->current_drawing_state_.view_box_; if (!impl_->current_drawing_state_.view_box_.empty()) path->draw_path_attlist_.svg_viewbox_ = impl_->current_drawing_state_.view_box_;
line_always_present = true;
} }
//////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////
draw_line* line = dynamic_cast<draw_line*>(impl_->current_level_.back().get()); draw_line* line = dynamic_cast<draw_line*>(impl_->current_level_.back().get());
...@@ -861,16 +864,14 @@ void odf_drawing_context::end_shape() ...@@ -861,16 +864,14 @@ void odf_drawing_context::end_shape()
line->draw_line_attlist_.svg_x1_ = line->draw_line_attlist_.svg_x2_; line->draw_line_attlist_.svg_x1_ = line->draw_line_attlist_.svg_x2_;
line->draw_line_attlist_.svg_x2_ = tmp; line->draw_line_attlist_.svg_x2_ = tmp;
} }
line_always_present = true;
} }
//////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////
draw_connector* connector = dynamic_cast<draw_connector*>(impl_->current_level_.back().get()); draw_connector* connector = dynamic_cast<draw_connector*>(impl_->current_level_.back().get());
if (connector) if (connector)
{ {
if (!connector->draw_connector_attlist_.draw_type_) connector->draw_connector_attlist_.draw_type_ = L"line"; if (!connector->draw_connector_attlist_.draw_type_)
line_always_present = true; connector->draw_connector_attlist_.draw_type_ = L"line";
} }
////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////
...@@ -888,11 +889,11 @@ void odf_drawing_context::end_shape() ...@@ -888,11 +889,11 @@ void odf_drawing_context::end_shape()
{ {
text_shape = true; text_shape = true;
} }
else //else
{ //{
sub_type = L"polyline"; // sub_type = L"polyline";
line_always_present = true; // line_always_present = true;
} //}
office_element_ptr enhanced_elm; office_element_ptr enhanced_elm;
create_element(L"draw", L"enhanced-geometry", enhanced_elm, impl_->odf_context_); create_element(L"draw", L"enhanced-geometry", enhanced_elm, impl_->odf_context_);
...@@ -906,52 +907,50 @@ void odf_drawing_context::end_shape() ...@@ -906,52 +907,50 @@ void odf_drawing_context::end_shape()
{ {
enhanced->draw_enhanced_geometry_attlist_.draw_text_path_same_letter_heights_ = false; enhanced->draw_enhanced_geometry_attlist_.draw_text_path_same_letter_heights_ = false;
enhanced->draw_enhanced_geometry_attlist_.draw_text_path_scale_ = L"path" ; enhanced->draw_enhanced_geometry_attlist_.draw_text_path_scale_ = L"path" ;
enhanced->draw_enhanced_geometry_attlist_.draw_text_path_mode_ = L"shape" ; enhanced->draw_enhanced_geometry_attlist_.draw_text_path_mode_ = L"shape" ;
enhanced->draw_enhanced_geometry_attlist_.draw_text_path_ = true; enhanced->draw_enhanced_geometry_attlist_.draw_text_path_ = true;
} }
if (impl_->current_drawing_state_.path_.length()>1) if (!impl_->current_drawing_state_.path_.empty())
{ {
enhanced->draw_enhanced_geometry_attlist_.draw_enhanced_path_ =impl_->current_drawing_state_.path_; enhanced->draw_enhanced_geometry_attlist_.draw_enhanced_path_ =impl_->current_drawing_state_.path_;
} }
if (impl_->current_drawing_state_.view_box_.length()>1) if (!impl_->current_drawing_state_.view_box_.empty())
{ {
enhanced->svg_viewbox_ = impl_->current_drawing_state_.view_box_; enhanced->svg_viewbox_ = impl_->current_drawing_state_.view_box_;
} }
if (sub_type.length()>1) if (!sub_type.empty())
{ {
enhanced->draw_enhanced_geometry_attlist_.draw_type_ = sub_type; enhanced->draw_enhanced_geometry_attlist_.draw_type_ = sub_type;
int res=0;
if ((res = sub_type.find(L"ooxml")) >= 0 && impl_->current_drawing_state_.modifiers_.length()>1)
{
enhanced->draw_enhanced_geometry_attlist_.draw_modifiers_ = impl_->current_drawing_state_.modifiers_;
}
} }
else else
{ {
oox_shape_ptr shape_define = oox_shape::create(impl_->current_drawing_state_.oox_shape_preset); oox_shape_ptr shape_define = oox_shape::create(impl_->current_drawing_state_.oox_shape_preset);
if (!shape_define) shape_define = impl_->current_drawing_state_.oox_shape_;
if (shape_define) if (shape_define)
{ {
enhanced->svg_viewbox_ = shape_define->view_box; enhanced->svg_viewbox_ = shape_define->view_box;
enhanced->draw_enhanced_geometry_attlist_.draw_type_ = shape_define->odf_type_name; enhanced->draw_enhanced_geometry_attlist_.draw_type_ = shape_define->odf_type_name;
enhanced->draw_enhanced_geometry_attlist_.draw_text_areas_ = shape_define->text_areas; enhanced->draw_enhanced_geometry_attlist_.draw_text_areas_ = shape_define->text_areas;
if (shape_define->glue_points)
{ enhanced->draw_enhanced_geometry_attlist_.draw_glue_points_ = shape_define->glue_points;
enhanced->draw_enhanced_geometry_attlist_.draw_glue_points_ = *shape_define->glue_points; enhanced->draw_enhanced_geometry_attlist_.draw_sub_view_size_ = shape_define->sub_view_size;
}
if (impl_->current_drawing_state_.modifiers_.length()>1) if (!impl_->current_drawing_state_.oox_shape_->modifiers.empty())
{ {
enhanced->draw_enhanced_geometry_attlist_.draw_modifiers_ = impl_->current_drawing_state_.modifiers_; enhanced->draw_enhanced_geometry_attlist_.draw_modifiers_ = impl_->current_drawing_state_.oox_shape_->modifiers;
} }
else // обязательно нужны дефолтовые else // обязательно нужны дефолтовые
enhanced->draw_enhanced_geometry_attlist_.draw_modifiers_ = shape_define->modifiers; enhanced->draw_enhanced_geometry_attlist_.draw_modifiers_ = shape_define->modifiers;
enhanced->draw_enhanced_geometry_attlist_.draw_enhanced_path_ = shape_define->enhanced_path; if (!shape_define->enhanced_path.empty())
enhanced->draw_enhanced_geometry_attlist_.draw_enhanced_path_ = shape_define->enhanced_path;
else
enhanced->draw_enhanced_geometry_attlist_.draw_enhanced_path_ = impl_->current_drawing_state_.path_;
for (size_t i = 0; i < shape_define->equations.size();i++) for (size_t i = 0; i < shape_define->equations.size(); i++)
{ {
office_element_ptr elm_eq; office_element_ptr elm_eq;
create_element(L"draw", L"equation", elm_eq, impl_->odf_context_); create_element(L"draw", L"equation", elm_eq, impl_->odf_context_);
...@@ -965,7 +964,7 @@ void odf_drawing_context::end_shape() ...@@ -965,7 +964,7 @@ void odf_drawing_context::end_shape()
end_element(); end_element();
} }
//----------------------------- //-----------------------------
for (size_t i = 0; i < shape_define->handles.size();i++) for (size_t i = 0; i < shape_define->handles.size(); i++)
{ {
office_element_ptr elm_h; office_element_ptr elm_h;
create_element(L"draw", L"handle", elm_h, impl_->odf_context_); create_element(L"draw", L"handle", elm_h, impl_->odf_context_);
...@@ -988,7 +987,38 @@ void odf_drawing_context::end_shape() ...@@ -988,7 +987,38 @@ void odf_drawing_context::end_shape()
} }
end_element(); end_element();
} }
void odf_drawing_context::corrected_line_fill()
bool odf_drawing_context::isLineShape()
{
if (impl_->current_level_.empty()) return false;
draw_line* line = dynamic_cast<draw_line*>(impl_->current_level_.back().get());
if (line) return true;
draw_connector* connector = dynamic_cast<draw_connector*>(impl_->current_level_.back().get());
if (connector) return true;
draw_path* path = dynamic_cast<draw_path*>(impl_->current_level_.back().get());
if (path) return true;
switch(impl_->current_drawing_state_.oox_shape_preset)
{
case 20: //SimpleTypes::shapetypeBentConnector2:
case 21: //SimpleTypes::shapetypeBentConnector3:
case 22: //SimpleTypes::shapetypeBentConnector4:
case 23: //SimpleTypes::shapetypeBentConnector5:
case 47: //SimpleTypes::shapetypeCurvedConnector2:
case 48: //SimpleTypes::shapetypeCurvedConnector3:
case 49: //SimpleTypes::shapetypeCurvedConnector4:
case 50: //SimpleTypes::shapetypeCurvedConnector5:
return true;
default:
return false;
}
return false;
}
void odf_drawing_context::corrected_line_fill() //for vml objects
{ {
if (!impl_->current_graphic_properties)return; if (!impl_->current_graphic_properties)return;
...@@ -1246,10 +1276,12 @@ void odf_drawing_context::set_path(std::wstring path_string) ...@@ -1246,10 +1276,12 @@ void odf_drawing_context::set_path(std::wstring path_string)
//boost::replace_all(path_string, L",,", L" 0 "); //boost::replace_all(path_string, L",,", L" 0 ");
//boost::replace_all(path_string, L" -", L"-"); //boost::replace_all(path_string, L" -", L"-");
//boost::replace_all(path_string, L",", L"0"); // нужен разбор //boost::replace_all(path_string, L",", L"0"); // нужен разбор
//impl_->current_drawing_state_.path_ = path_string; impl_->current_drawing_state_.path_ = path_string;
} }
void odf_drawing_context::add_path_element(std::wstring command, const std::wstring & strE) void odf_drawing_context::add_path_element(std::wstring command, std::wstring strE)
{ {
XmlUtils::replace_all(strE, L"gd", L"?f");
if (command != impl_->current_drawing_state_.path_last_command_) if (command != impl_->current_drawing_state_.path_last_command_)
{ {
impl_->current_drawing_state_.path_ += command; impl_->current_drawing_state_.path_ += command;
...@@ -1258,19 +1290,179 @@ void odf_drawing_context::add_path_element(std::wstring command, const std::wstr ...@@ -1258,19 +1290,179 @@ void odf_drawing_context::add_path_element(std::wstring command, const std::wstr
impl_->current_drawing_state_.path_last_command_ = command; impl_->current_drawing_state_.path_last_command_ = command;
} }
if (command != L"N")
impl_->current_drawing_state_.path_ += strE + L" "; impl_->current_drawing_state_.path_ += strE + L" ";
else
impl_->current_drawing_state_.path_ += strE; if (command == L"N")
impl_->current_drawing_state_.path_last_command_.clear();
} }
void odf_drawing_context::add_modifier(std::wstring modifier) void odf_drawing_context::add_modifier (std::wstring modifier)
{ {
if (!impl_->current_drawing_state_.oox_shape_) return;
boost::algorithm::to_lower(modifier); boost::algorithm::to_lower(modifier);
int res = modifier.find(L"val "); int res = modifier.find(L"val ");
if (res >=0) modifier = modifier.substr(4); if (res >=0) modifier = modifier.substr(4);
impl_->current_drawing_state_.modifiers_ += modifier + L" ";
impl_->current_drawing_state_.oox_shape_->modifiers += modifier + L" ";
}
int GetFormulaType2(const WCHAR& c1, const WCHAR& c2)
{
switch (c1)
{
case (WCHAR)'*': return 0;
case (WCHAR)'+': return ((WCHAR)'-' == c2) ? 1 : 2;
case (WCHAR)'?': return 3;
case (WCHAR)'a': return ((WCHAR)'b' == c2) ? 4 : 5;
case (WCHAR)'c': return ((WCHAR)'a' == c2) ? 6 : 7;
case (WCHAR)'m': return ((WCHAR)'a' == c2) ? 8 : (((WCHAR)'i' == c2) ? 16 : 9);
case (WCHAR)'p': return 10;
case (WCHAR)'s': return ((WCHAR)'a' == c2) ? 11 : (((WCHAR)'i' == c2) ? 12 : 13);
case (WCHAR)'t': return 14;
case (WCHAR)'v': return 15;
default:
break;
}
return 0;
}
void odf_drawing_context::set_textarea (std::wstring l, std::wstring t, std::wstring r, std::wstring b)
{
if (!impl_->current_drawing_state_.oox_shape_) return;
impl_->current_drawing_state_.oox_shape_->text_areas = l + L" " + t + L" " + r + L" " + b;
XmlUtils::replace_all(impl_->current_drawing_state_.oox_shape_->text_areas, L"gd", L"?f");
}
void odf_drawing_context::add_handle (std::wstring x, std::wstring y, std::wstring refX, std::wstring refY,
std::wstring minX, std::wstring maxX, std::wstring minY, std::wstring maxY)
{
if (!impl_->current_drawing_state_.oox_shape_) return;
oox_shape::_handle h;
XmlUtils::replace_all(x, L"gd", L"?f");
XmlUtils::replace_all(y, L"gd", L"?f");
h.position = x + L" " + y;
if (!maxX.empty()) h.x_maximum= maxX;
if (!minX.empty()) h.x_minimum= minX;
if (!maxY.empty()) h.y_maximum= maxY;
if (!minY.empty()) h.y_minimum= minY;
impl_->current_drawing_state_.oox_shape_->handles.push_back(h);
} }
void odf_drawing_context::set_viewBox(double W, double H)
void odf_drawing_context::add_formula (std::wstring name, std::wstring fmla)
{
if (!impl_->current_drawing_state_.oox_shape_) return;
size_t nStart = 0;
size_t nCurrent = 0;
const wchar_t* pData = fmla.c_str();
int nFound = 0, x = 0, y = 0;
std::wstring val[4];
while (nCurrent < fmla.length())
{
if (pData[nCurrent] == (WCHAR)' ')
{
if (nStart < nCurrent)
{
if (0 == nFound)
{
if ((nCurrent - nStart) > 1)
{
x = GetFormulaType2(pData[nStart], pData[nStart + 1]);
}
else
{
x = 0;
}
}
else
{
val[nFound-1] = std::wstring( pData + nStart, (ULONG)(nCurrent - nStart));
}
nStart = nCurrent + 1;
++nFound;
}
}
++nCurrent;
}
if (nStart < nCurrent)
{
if (0 == nFound)
{
if ((nCurrent - nStart) > 1)
{
y = GetFormulaType2(pData[nStart], pData[nStart + 1]);
}
else
{
y = 0;
}
}
else
{
val[nFound-1] = std::wstring( pData + nStart, (ULONG)(nCurrent - nStart));
}
}
std::wstring odf_fmla = L"";
switch(x)
{
case 0:
odf_fmla = val[0] + L"*" + val[1] + L"/" + val[2];
break;
case 1:
odf_fmla = val[0] + L"+" + val[1] + L"-" + val[2];
break;
case 2:
odf_fmla = val[0] + L"+" + val[1];
break;
case 3:
odf_fmla = L"if(";
for (int i = 0; i < nFound - 1; i++)
{
odf_fmla += val[i] + L",";
}
odf_fmla += val[nFound-1] + L")"; break;
case 4:
odf_fmla = L"abs(" + val[0] + L")";
break;
case 7:
odf_fmla = val[0] + L"*cos(pi*(" + val[1] + L")/10800000)";
break;
case 12:
odf_fmla = val[0] + L"*sin(pi*(" + val[1] + L")/10800000)";
break;
case 13:
odf_fmla = L"sqrt(" + val[0] + L")";
break;
case 15:
odf_fmla = val[0];
break;
default:
odf_fmla = fmla;
break;
}
XmlUtils::replace_all(odf_fmla, L"gd", L"?f");
XmlUtils::replace_all(odf_fmla, L"h", L"logheight");
XmlUtils::replace_all(odf_fmla, L"w", L"logwidth");
XmlUtils::replace_all(odf_fmla, L"adj", L"$");
XmlUtils::replace_all(name, L"gd", L"f");
impl_->current_drawing_state_.oox_shape_->add(name, odf_fmla);
}
void odf_drawing_context::set_viewBox (double W, double H)
{ {
if (W < 0.01) if (W < 0.01)
{ {
...@@ -1282,7 +1474,15 @@ void odf_drawing_context::set_viewBox(double W, double H) ...@@ -1282,7 +1474,15 @@ void odf_drawing_context::set_viewBox(double W, double H)
if (impl_->current_drawing_state_.svg_height_) if (impl_->current_drawing_state_.svg_height_)
H = impl_->current_drawing_state_.svg_height_->get_value_unit(length::emu); H = impl_->current_drawing_state_.svg_height_->get_value_unit(length::emu);
} }
impl_->current_drawing_state_.view_box_ = std::wstring(L"0 0 ") + boost::lexical_cast<std::wstring>((int)W) + L" " + boost::lexical_cast<std::wstring>((int)H); impl_->current_drawing_state_.view_box_ = std::wstring(L"0 0 ") + std::to_wstring((int)W) + L" " + std::to_wstring((int)H);
if (impl_->current_drawing_state_.oox_shape_)
{
if (impl_->current_drawing_state_.oox_shape_->sub_view_size)
impl_->current_drawing_state_.oox_shape_->sub_view_size = *impl_->current_drawing_state_.oox_shape_->sub_view_size + L" " + std::to_wstring((int)W) + L" " + std::to_wstring((int)H);
else
impl_->current_drawing_state_.oox_shape_->sub_view_size = std::to_wstring((int)W) + L" " + std::to_wstring((int)H);
}
} }
void odf_drawing_context::set_flip_H(bool bVal) void odf_drawing_context::set_flip_H(bool bVal)
{ {
......
...@@ -139,6 +139,7 @@ public: ...@@ -139,6 +139,7 @@ public:
void start_object(std::wstring name); void start_object(std::wstring name);
void end_object(); void end_object();
bool isLineShape();
void corrected_line_fill(); void corrected_line_fill();
office_element_ptr & get_root_element(); office_element_ptr & get_root_element();
...@@ -149,8 +150,12 @@ public: ...@@ -149,8 +150,12 @@ public:
bool is_exist_content(); bool is_exist_content();
////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////
void set_path (std::wstring path_string); void set_path (std::wstring path_string);
void add_path_element (std::wstring command, const std::wstring & elm); void add_path_element (std::wstring command, std::wstring elm);
void add_modifier (std::wstring modifier); void add_modifier (std::wstring modifier);
void add_formula (std::wstring name, std::wstring fmla);
void set_textarea (std::wstring l, std::wstring t, std::wstring r, std::wstring b);
void add_handle (std::wstring x, std::wstring y, std::wstring refX, std::wstring refY,
std::wstring minX, std::wstring maxX, std::wstring minY, std::wstring maxY);
void set_viewBox (double W, double H); void set_viewBox (double W, double H);
......
...@@ -238,11 +238,11 @@ void ods_conversion_context::end_row() ...@@ -238,11 +238,11 @@ void ods_conversion_context::end_row()
////////////////////// //////////////////////
void ods_conversion_context::start_comment(int col, int row, std::wstring & author) void ods_conversion_context::start_comment(int col, int row, std::wstring & author)
{ {
current_table().start_comment(col,row,author); current_table().start_comment(col, row, author);
start_text_context(); start_text_context();
//////////////// ////////////////
office_element_ptr paragr_elm; office_element_ptr paragr_elm;
create_element(L"text", L"p",paragr_elm,this); create_element(L"text", L"p", paragr_elm, this);
current_text_context_->start_paragraph(paragr_elm); current_text_context_->start_paragraph(paragr_elm);
} }
...@@ -309,7 +309,7 @@ void ods_conversion_context::add_merge_cells(const std::wstring & ref) ...@@ -309,7 +309,7 @@ void ods_conversion_context::add_merge_cells(const std::wstring & ref)
void ods_conversion_context::start_cell(std::wstring & ref, int xfd_style) void ods_conversion_context::start_cell(std::wstring & ref, int xfd_style)
{ {
int col=0, row=0; int col = 0, row = 0;
utils::parsing_ref ( ref, col,row); utils::parsing_ref ( ref, col,row);
if (col > current_table().current_column()+1) if (col > current_table().current_column()+1)
...@@ -389,11 +389,31 @@ void ods_conversion_context::start_rows() ...@@ -389,11 +389,31 @@ void ods_conversion_context::start_rows()
void ods_conversion_context::end_rows() void ods_conversion_context::end_rows()
{ {
//add default last row //add default last row
int repeat = (std::max)(current_table().dimension_row,64) - current_table().current_row(); int repeated = (std::max)(current_table().dimension_row, 64) - current_table().current_row();
if (repeat < 0) repeat = 1; if (repeated < 0) repeated = 1;
while(true)
{
//делим на 3 - до, с комметом, после;
int comment_idx = current_table().is_row_comment(current_table().current_row() + 1, repeated);
if (comment_idx < 0) break;
int rows = current_table().comments_[comment_idx].row - current_table().current_row() - 1;
start_row(current_table().current_row() + 1, rows, 0, true);
end_row();
start_row(current_table().current_row() + 1, 1, 0, true);
end_row();
repeated -= (1 + rows);
}
start_row(current_table().current_row()+1,repeat,0,true); if (repeated > 0)
end_row(); {
start_row(current_table().current_row() + 1, repeated, 0, true);
end_row();
}
} }
void ods_conversion_context::add_column(int start_column, int repeated, int level, bool _default) void ods_conversion_context::add_column(int start_column, int repeated, int level, bool _default)
......
...@@ -136,8 +136,8 @@ ods_table_state::ods_table_state(odf_conversion_context * Context, office_elemen ...@@ -136,8 +136,8 @@ ods_table_state::ods_table_state(odf_conversion_context * Context, office_elemen
{ {
office_table_ = elm; office_table_ = elm;
current_table_row_ =0; current_table_row_ = 0;
current_table_column_ =0; current_table_column_ = 0;
current_level_.push_back(office_table_); current_level_.push_back(office_table_);
...@@ -395,7 +395,7 @@ bool ods_table_state::is_cell_hyperlink() ...@@ -395,7 +395,7 @@ bool ods_table_state::is_cell_hyperlink()
bool ods_table_state::is_cell_comment() bool ods_table_state::is_cell_comment()
{ {
if (cells_size_ <1)return false; if (cells_size_ <1)return false;
return cells_.back().comment_idx >=0 ? true : false; return cells_.back().comment_idx >= 0 ? true : false;
} }
int ods_table_state::is_cell_hyperlink(int col, int row) int ods_table_state::is_cell_hyperlink(int col, int row)
...@@ -413,7 +413,18 @@ int ods_table_state::is_cell_comment(int col, int row, short repeate_col) ...@@ -413,7 +413,18 @@ int ods_table_state::is_cell_comment(int col, int row, short repeate_col)
{ {
for (size_t i = 0; i < comments_.size(); i++) for (size_t i = 0; i < comments_.size(); i++)
{ {
if ((comments_[i].col < col+repeate_col && comments_[i].col >= col) && comments_[i].row == row) if ((comments_[i].col < col + repeate_col && comments_[i].col >= col) && comments_[i].row == row)
{
return i;
}
}
return -1;
}
int ods_table_state::is_row_comment(int row, int repeate_row)
{
for (size_t i = 0; i < comments_.size(); i++)
{
if (comments_[i].row < row + repeate_row && comments_[i].row >= row)
{ {
return i; return i;
} }
...@@ -489,10 +500,10 @@ void ods_table_state::start_cell(office_element_ptr & elm, office_element_ptr & ...@@ -489,10 +500,10 @@ void ods_table_state::start_cell(office_element_ptr & elm, office_element_ptr &
state.empty = true; state.empty = true;
state.elm = elm; state.repeated = 1; state.style_name = style_name; state.style_elm = style_elm; state.elm = elm; state.repeated = 1; state.style_name = style_name; state.style_elm = style_elm;
state.row=current_table_row_; state.col =current_table_column_+1; state.row = current_table_row_; state.col =current_table_column_ + 1;
state.hyperlink_idx = is_cell_hyperlink(state.col, state.row); state.hyperlink_idx = is_cell_hyperlink(state.col, state.row);
state.comment_idx = is_cell_comment(state.col, state.row); state.comment_idx = is_cell_comment(state.col, state.row);
current_table_column_ += state.repeated; current_table_column_ += state.repeated;
cells_.push_back(state); cells_.push_back(state);
...@@ -1016,8 +1027,8 @@ void ods_table_state::end_cell() ...@@ -1016,8 +1027,8 @@ void ods_table_state::end_cell()
void ods_table_state::add_default_cell( short repeated) void ods_table_state::add_default_cell( short repeated)
{ {
int comment_idx = is_cell_comment(current_table_column_+1 , current_table_row_, repeated); int comment_idx = is_cell_comment(current_table_column_ + 1 , current_table_row_, repeated);
if (comment_idx >=0 && repeated >1) if (comment_idx >= 0 && repeated > 1)
{ {
//делим на 3 - до, с комметом, после; //делим на 3 - до, с комметом, после;
int c = current_table_column_; int c = current_table_column_;
......
...@@ -300,6 +300,7 @@ public: ...@@ -300,6 +300,7 @@ public:
int is_cell_hyperlink (int col, int row); int is_cell_hyperlink (int col, int row);
bool is_cell_comment (); bool is_cell_comment ();
int is_cell_comment (int col, int row, short repeate_col = 1); int is_cell_comment (int col, int row, short repeate_col = 1);
int is_row_comment (int row, int repeate_row = 1);
ods_hyperlink_state & current_hyperlink(); ods_hyperlink_state & current_hyperlink();
...@@ -316,7 +317,8 @@ public: ...@@ -316,7 +317,8 @@ public:
odf_drawing_context * drawing_context(){return &drawing_context_;} odf_drawing_context * drawing_context(){return &drawing_context_;}
std::wstring office_table_name_; std::wstring office_table_name_;
std::vector<ods_comment_state> comments_;
private: private:
odf_conversion_context * context_; odf_conversion_context * context_;
...@@ -342,9 +344,7 @@ private: ...@@ -342,9 +344,7 @@ private:
std::list<ods_cell_state> cells_; std::list<ods_cell_state> cells_;
long cells_size_; long cells_size_;
std::vector<ods_hyperlink_state> hyperlinks_; std::vector<ods_hyperlink_state> hyperlinks_;
std::vector<ods_comment_state> comments_;
std::vector<ods_shared_formula_state> shared_formulas_; std::vector<ods_shared_formula_state> shared_formulas_;
odf_drawing_context drawing_context_; odf_drawing_context drawing_context_;
......
...@@ -50,6 +50,12 @@ ...@@ -50,6 +50,12 @@
namespace cpdoccore namespace cpdoccore
{ {
oox_shape::oox_shape()
{
odf_type_name = L"ooxml-non-primitive";
view_box = L"0 0 0 0";
}
oox_shape_ptr oox_shape::create(int ooxPrstGeomType) oox_shape_ptr oox_shape::create(int ooxPrstGeomType)
{ {
switch (ooxPrstGeomType) switch (ooxPrstGeomType)
...@@ -127,7 +133,7 @@ oox_shape_ptr oox_shape::create(int ooxPrstGeomType) ...@@ -127,7 +133,7 @@ oox_shape_ptr oox_shape::create(int ooxPrstGeomType)
default: default:
if (ooxPrstGeomType > 2000) return boost::make_shared<oox_shape_textPlain>(); if (ooxPrstGeomType > 2000) return boost::make_shared<oox_shape_textPlain>();
else return boost::make_shared<oox_shape>(); else return oox_shape_ptr();
} }
} }
......
...@@ -48,6 +48,8 @@ namespace cpdoccore ...@@ -48,6 +48,8 @@ namespace cpdoccore
public: public:
static oox_shape_ptr create(int ooxPrstGeomType); static oox_shape_ptr create(int ooxPrstGeomType);
oox_shape();
struct _equation struct _equation
{ {
std::wstring name; std::wstring name;
...@@ -66,20 +68,20 @@ namespace cpdoccore ...@@ -66,20 +68,20 @@ namespace cpdoccore
void add(std::wstring name,std::wstring frmla) void add(std::wstring name,std::wstring frmla)
{ {
_equation q = {name,frmla}; _equation q = {name, frmla};
equations.push_back(q); equations.push_back(q);
} }
std::vector<_equation> equations; std::vector<_equation> equations;
std::vector<_handle> handles; std::vector<_handle> handles;
std::wstring enhanced_path; std::wstring enhanced_path;
std::wstring modifiers; std::wstring modifiers;
std::wstring text_areas; std::wstring text_areas;
std::wstring view_box; std::wstring view_box;
_CP_OPT(std::wstring) sub_view_size;
std::wstring odf_type_name; _CP_OPT(std::wstring) glue_points;
_CP_OPT(std::wstring) glue_points; std::wstring odf_type_name;
}; };
}; };
\ No newline at end of file
...@@ -372,7 +372,17 @@ void OoxConverter::convert(PPTX::Logic::CxnSp *oox_connect) ...@@ -372,7 +372,17 @@ void OoxConverter::convert(PPTX::Logic::CxnSp *oox_connect)
odf_context()->drawing_context()->start_drawing(); odf_context()->drawing_context()->start_drawing();
odf_context()->drawing_context()->start_shape(SimpleTypes::shapetypeLine); int type = SimpleTypes::shapetypeLine;
if ( oox_connect->spPr.Geometry.is<PPTX::Logic::PrstGeom>() )
{
const PPTX::Logic::PrstGeom& prstGeom = oox_connect->spPr.Geometry.as<PPTX::Logic::PrstGeom>();
SimpleTypes::CShapeType<> preset;
preset.FromString(prstGeom.prst.get());
type = preset.GetValue();
}
odf_context()->drawing_context()->start_shape(type);
convert(&oox_connect->spPr, oox_connect->style.GetPointer()); convert(&oox_connect->spPr, oox_connect->style.GetPointer());
convert(&oox_connect->nvCxnSpPr); convert(&oox_connect->nvCxnSpPr);
...@@ -462,7 +472,7 @@ void OoxConverter::convert(PPTX::Logic::SpPr *oox_spPr, PPTX::Logic::ShapeStyle* ...@@ -462,7 +472,7 @@ void OoxConverter::convert(PPTX::Logic::SpPr *oox_spPr, PPTX::Logic::ShapeStyle*
convert(prstGeom); convert(prstGeom);
convert(custGeom); convert(custGeom);
bool bLine = prstGeom ? (prstGeom->prst.get() == L"line") : false; bool bLine = odf_context()->drawing_context()->isLineShape();
if (!bLine) if (!bLine)
{ {
...@@ -526,19 +536,52 @@ void OoxConverter::convert(PPTX::Logic::PrstGeom *oox_geom) ...@@ -526,19 +536,52 @@ void OoxConverter::convert(PPTX::Logic::PrstGeom *oox_geom)
for (size_t i = 0; i < oox_geom->avLst.size(); i++) for (size_t i = 0; i < oox_geom->avLst.size(); i++)
{ {
if (oox_geom->avLst[i].fmla.IsInit()) odf_context()->drawing_context()->add_modifier(oox_geom->avLst[i].fmla.get_value_or(L"0"));
odf_context()->drawing_context()->add_modifier(oox_geom->avLst[i].fmla.get());
} }
} }
void OoxConverter::convert(PPTX::Logic::CustGeom *oox_cust_geom) void OoxConverter::convert(PPTX::Logic::CustGeom *oox_cust_geom)
{ {
if (!oox_cust_geom) return; if (!oox_cust_geom) return;
for (size_t i = 0; i < oox_cust_geom->gdLst.size(); i++)
{
odf_context()->drawing_context()->add_formula(oox_cust_geom->gdLst[i].name.get_value_or(L""), oox_cust_geom->gdLst[i].fmla.get_value_or(L""));
}
for (size_t i = 0; i < oox_cust_geom->pathLst.size(); i++) for (size_t i = 0; i < oox_cust_geom->pathLst.size(); i++)
{ {
convert(&oox_cust_geom->pathLst[i]); convert(&oox_cust_geom->pathLst[i]);
} }
for (size_t i = 0; i < oox_cust_geom->avLst.size(); i++)
{
odf_context()->drawing_context()->add_modifier(oox_cust_geom->avLst[i].fmla.get_value_or(L"0"));
}
for (size_t i = 0; i < oox_cust_geom->ahLst.size(); i++)
{
convert(oox_cust_geom->ahLst[i].ah.operator->());
}
if (oox_cust_geom->rect.IsInit())
{
odf_context()->drawing_context()->set_textarea (oox_cust_geom->rect->l.get_value_or(L"0"),
oox_cust_geom->rect->t.get_value_or(L"0"),
oox_cust_geom->rect->r.get_value_or(L"0"),
oox_cust_geom->rect->b.get_value_or(L"0"));
}
}
void OoxConverter::convert(PPTX::Logic::AhXY *oox_handle)
{
if (!oox_handle) return;
odf_context()->drawing_context()->add_handle(oox_handle->x, oox_handle->y,
oox_handle->gdRefX.get_value_or(L""), oox_handle->gdRefY.get_value_or(L""),
oox_handle->minX.get_value_or(L""), oox_handle->maxX.get_value_or(L""),
oox_handle->minX.get_value_or(L""), oox_handle->maxY.get_value_or(L""));
} }
void OoxConverter::convert(PPTX::Logic::AhPolar *oox_handle)
{
if (!oox_handle) return;
}
void OoxConverter::convert(PPTX::Logic::EffectLst *oox_effect_list) void OoxConverter::convert(PPTX::Logic::EffectLst *oox_effect_list)
{ {
if (!oox_effect_list) return; if (!oox_effect_list) return;
...@@ -616,44 +659,20 @@ void OoxConverter::convert(PPTX::Logic::PathBase *oox_path) ...@@ -616,44 +659,20 @@ void OoxConverter::convert(PPTX::Logic::PathBase *oox_path)
{ {
if (!oox_path) return; if (!oox_path) return;
PPTX::Logic::MoveTo* moveTo = dynamic_cast<PPTX::Logic::MoveTo*> (oox_path); PPTX::Logic::MoveTo* moveTo = dynamic_cast<PPTX::Logic::MoveTo*> (oox_path);
PPTX::Logic::LineTo* lineTo = dynamic_cast<PPTX::Logic::LineTo*> (oox_path); PPTX::Logic::LineTo* lineTo = dynamic_cast<PPTX::Logic::LineTo*> (oox_path);
PPTX::Logic::CubicBezTo* cubicBezTo = dynamic_cast<PPTX::Logic::CubicBezTo*> (oox_path); PPTX::Logic::CubicBezTo* cubicBezTo = dynamic_cast<PPTX::Logic::CubicBezTo*>(oox_path);
PPTX::Logic::Close* close = dynamic_cast<PPTX::Logic::Close*> (oox_path); PPTX::Logic::Close* close = dynamic_cast<PPTX::Logic::Close*> (oox_path);
PPTX::Logic::ArcTo* arcTo = dynamic_cast<PPTX::Logic::ArcTo*> (oox_path); PPTX::Logic::ArcTo* arcTo = dynamic_cast<PPTX::Logic::ArcTo*> (oox_path);
PPTX::Logic::QuadBezTo* quadBezTo = dynamic_cast<PPTX::Logic::QuadBezTo*> (oox_path); PPTX::Logic::QuadBezTo* quadBezTo = dynamic_cast<PPTX::Logic::QuadBezTo*> (oox_path);
if (moveTo) if (moveTo) convert(moveTo);
{ if (lineTo) convert(lineTo);
std::wstring path_elm = moveTo->x + L" " + moveTo->y; if (cubicBezTo) convert(cubicBezTo);
odf_context()->drawing_context()->add_path_element(std::wstring(L"M"), path_elm); if (quadBezTo) convert(quadBezTo);
} if (arcTo) convert(arcTo);
if (lineTo) if (close) convert(close);
{
std::wstring path_elm = lineTo->x + L" " + lineTo->y;
odf_context()->drawing_context()->add_path_element(std::wstring(L"L"), path_elm);
}
if (cubicBezTo)
{
std::wstring path_elm = cubicBezTo->x[0] + L" " + cubicBezTo->y[0] + L" " +
cubicBezTo->x[1] + L" " + cubicBezTo->y[1] + L" " +
cubicBezTo->x[2] + L" " + cubicBezTo->y[2];
odf_context()->drawing_context()->add_path_element(std::wstring(L"C"), path_elm);
}
if (quadBezTo)
{
std::wstring path_elm = quadBezTo->x[0] + L" " + quadBezTo->y[0] + L" " +
quadBezTo->x[1] + L" " + quadBezTo->y[1];
odf_context()->drawing_context()->add_path_element(std::wstring(L"S"), path_elm);
}
if (arcTo)
{
}
if (close)
{
std::wstring path_elm ;
odf_context()->drawing_context()->add_path_element(std::wstring(L"Z"), path_elm);
}
} }
...@@ -810,7 +829,7 @@ void OoxConverter::convert(PPTX::Logic::GradFill *oox_grad_fill, DWORD nARGB) ...@@ -810,7 +829,7 @@ void OoxConverter::convert(PPTX::Logic::GradFill *oox_grad_fill, DWORD nARGB)
} }
void OoxConverter::convert(PPTX::Logic::UniColor * color, std::wstring & hexString, _CP_OPT(double) & opacity, DWORD nARGB) void OoxConverter::convert(PPTX::Logic::UniColor * color, DWORD & nARGB)
{ {
if (!color) return; if (!color) return;
...@@ -818,6 +837,13 @@ void OoxConverter::convert(PPTX::Logic::UniColor * color, std::wstring & hexStri ...@@ -818,6 +837,13 @@ void OoxConverter::convert(PPTX::Logic::UniColor * color, std::wstring & hexStri
smart_ptr<PPTX::Theme> theme(oox_theme()); theme.AddRef(); smart_ptr<PPTX::Theme> theme(oox_theme()); theme.AddRef();
nARGB = color->GetRGBColor(theme, clrMap, nARGB); nARGB = color->GetRGBColor(theme, clrMap, nARGB);
}
void OoxConverter::convert(PPTX::Logic::UniColor * color, std::wstring & hexString, _CP_OPT(double) & opacity, DWORD nARGB)
{
if (!color) return;
convert(color, nARGB);
hexString = XmlUtils::IntToString(nARGB & 0x00FFFFFF, L"#%06X"); hexString = XmlUtils::IntToString(nARGB & 0x00FFFFFF, L"#%06X");
...@@ -896,7 +922,7 @@ void OoxConverter::convert(PPTX::Logic::Ln *oox_line_prop, DWORD ARGB, PPTX::Log ...@@ -896,7 +922,7 @@ void OoxConverter::convert(PPTX::Logic::Ln *oox_line_prop, DWORD ARGB, PPTX::Log
{ {
if (oox_line_prop->headEnd->len.IsInit() || oox_line_prop->headEnd->type.IsInit() || oox_line_prop->headEnd->w.IsInit()) if (oox_line_prop->headEnd->len.IsInit() || oox_line_prop->headEnd->type.IsInit() || oox_line_prop->headEnd->w.IsInit())
{ {
int type = 0, w=1, len =1;//medium arrow int type = 0, w = 1, len = 1;//medium arrow
if (oox_line_prop->headEnd->len.IsInit()) len = oox_line_prop->headEnd->len->GetBYTECode(); if (oox_line_prop->headEnd->len.IsInit()) len = oox_line_prop->headEnd->len->GetBYTECode();
if (oox_line_prop->headEnd->type.IsInit()) type = oox_line_prop->headEnd->type->GetBYTECode(); if (oox_line_prop->headEnd->type.IsInit()) type = oox_line_prop->headEnd->type->GetBYTECode();
if (oox_line_prop->headEnd->w.IsInit()) w = oox_line_prop->headEnd->w->GetBYTECode(); if (oox_line_prop->headEnd->w.IsInit()) w = oox_line_prop->headEnd->w->GetBYTECode();
...@@ -908,7 +934,7 @@ void OoxConverter::convert(PPTX::Logic::Ln *oox_line_prop, DWORD ARGB, PPTX::Log ...@@ -908,7 +934,7 @@ void OoxConverter::convert(PPTX::Logic::Ln *oox_line_prop, DWORD ARGB, PPTX::Log
{ {
if (oox_line_prop->tailEnd->len.IsInit() || oox_line_prop->tailEnd->type.IsInit() || oox_line_prop->tailEnd->w.IsInit()) if (oox_line_prop->tailEnd->len.IsInit() || oox_line_prop->tailEnd->type.IsInit() || oox_line_prop->tailEnd->w.IsInit())
{ {
int type =0, w=1, len =1;//medium arrow int type = 0, w = 1, len = 1;//medium arrow
if (oox_line_prop->tailEnd->len.IsInit()) len = oox_line_prop->tailEnd->len->GetBYTECode(); if (oox_line_prop->tailEnd->len.IsInit()) len = oox_line_prop->tailEnd->len->GetBYTECode();
if (oox_line_prop->tailEnd->type.IsInit()) type = oox_line_prop->tailEnd->type->GetBYTECode(); if (oox_line_prop->tailEnd->type.IsInit()) type = oox_line_prop->tailEnd->type->GetBYTECode();
if (oox_line_prop->tailEnd->w.IsInit()) w = oox_line_prop->tailEnd->w->GetBYTECode(); if (oox_line_prop->tailEnd->w.IsInit()) w = oox_line_prop->tailEnd->w->GetBYTECode();
...@@ -1487,10 +1513,9 @@ void OoxConverter::convert(PPTX::Logic::ArcTo *oox_geom_path) ...@@ -1487,10 +1513,9 @@ void OoxConverter::convert(PPTX::Logic::ArcTo *oox_geom_path)
{ {
if (!oox_geom_path) return; if (!oox_geom_path) return;
//std::wstring path_elm = std::to_wstring ((int)pt2emu(oox_geom_path->m_oPt.m_oX.GetValue())) + std::wstring path_elm = oox_geom_path->hR + L" " + oox_geom_path->wR + L" " + oox_geom_path->swAng + L" " + oox_geom_path->stAng;
// std::wstring(L" ")+ std::to_wstring ((int)pt2emu(oox_geom_path->m_oPt.m_oY.GetValue()));
// odf_context()->drawing_context()->add_path_element(std::wstring(L"G"), path_elm);
//odf_context()->drawing_context()->add_path_element(std::wstring(L"A"), path_elm);
} }
void OoxConverter::convert(PPTX::Logic::QuadBezTo *oox_geom_path) void OoxConverter::convert(PPTX::Logic::QuadBezTo *oox_geom_path)
{ {
...@@ -1521,14 +1546,19 @@ void OoxConverter::convert(PPTX::Logic::Close *oox_geom_path) ...@@ -1521,14 +1546,19 @@ void OoxConverter::convert(PPTX::Logic::Close *oox_geom_path)
void OoxConverter::convert(PPTX::Logic::StyleRef *style_ref, int type) void OoxConverter::convert(PPTX::Logic::StyleRef *style_ref, int type)
{ {
if (!style_ref) return; if (!style_ref) return;
DWORD nARGB = 0;
convert(&style_ref->Color, nARGB);
if (style_ref->idx.IsInit() == false) if (style_ref->idx.IsInit() == false)
{ {
std::wstring hexColor; std::wstring hexColor = XmlUtils::IntToString(nARGB & 0x00FFFFFF, L"#%06X");
_CP_OPT(double) opacity; _CP_OPT(double) opacity;
convert(&style_ref->Color, hexColor, opacity); if ((nARGB >> 24) != 0xff)
{
opacity = ((nARGB >> 24) /255.) * 100.;
}
if (type != 3) //?? todooo if (type != 3) //?? todooo
{ {
...@@ -1568,14 +1598,14 @@ void OoxConverter::convert(PPTX::Logic::StyleRef *style_ref, int type) ...@@ -1568,14 +1598,14 @@ void OoxConverter::convert(PPTX::Logic::StyleRef *style_ref, int type)
} }
} }
convert(fill, style_ref->Color.GetARGB()); convert(fill, nARGB);
} }
else if (type == 2) else if (type == 2)
{ {
index -= 1; index -= 1;
if ((index >= 0) || (index < theme->themeElements.fmtScheme.lnStyleLst.size())) if ((index >= 0) || (index < theme->themeElements.fmtScheme.lnStyleLst.size()))
{ {
convert(&theme->themeElements.fmtScheme.lnStyleLst[index], style_ref->Color.GetARGB()); convert(&theme->themeElements.fmtScheme.lnStyleLst[index], nARGB);
} }
} }
else if (type == 3) else if (type == 3)
......
...@@ -181,6 +181,14 @@ void OoxConverter::convert(OOX::WritingElement *oox_unknown) ...@@ -181,6 +181,14 @@ void OoxConverter::convert(OOX::WritingElement *oox_unknown)
{ {
convert(dynamic_cast<PPTX::Logic::CustGeom*>(oox_unknown)); convert(dynamic_cast<PPTX::Logic::CustGeom*>(oox_unknown));
}break; }break;
case OOX::et_a_ahXY:
{
convert(dynamic_cast<PPTX::Logic::AhXY*>(oox_unknown));
}break;
case OOX::et_a_ahPolar:
{
convert(dynamic_cast<PPTX::Logic::AhPolar*>(oox_unknown));
}break;
case OOX::et_a_lnTo: case OOX::et_a_lnTo:
{ {
convert(dynamic_cast<PPTX::Logic::LineTo*>(oox_unknown)); convert(dynamic_cast<PPTX::Logic::LineTo*>(oox_unknown));
......
...@@ -322,6 +322,8 @@ namespace PPTX ...@@ -322,6 +322,8 @@ namespace PPTX
class InnerShdw; class InnerShdw;
class OuterShdw; class OuterShdw;
class PrstShdw; class PrstShdw;
class AhXY;
class AhPolar;
} }
} }
...@@ -390,6 +392,7 @@ public: ...@@ -390,6 +392,7 @@ public:
void convert(PPTX::Logic::PathBase *oox_path); void convert(PPTX::Logic::PathBase *oox_path);
void convert(PPTX::Logic::BodyPr *oox_bodyPr); void convert(PPTX::Logic::BodyPr *oox_bodyPr);
void convert(PPTX::Logic::UniFill *oox_fill, DWORD ARGB = 0); void convert(PPTX::Logic::UniFill *oox_fill, DWORD ARGB = 0);
void convert(PPTX::Logic::UniColor *color, DWORD & nARGB);
void convert(PPTX::Logic::UniColor *color, std::wstring & hexString, _CP_OPT(double) & opacity, DWORD ARGB = 0); void convert(PPTX::Logic::UniColor *color, std::wstring & hexString, _CP_OPT(double) & opacity, DWORD ARGB = 0);
void convert(PPTX::Logic::NvSpPr *oox_nvSpPr); void convert(PPTX::Logic::NvSpPr *oox_nvSpPr);
void convert(PPTX::Logic::CNvPr *oox_cnvPr); void convert(PPTX::Logic::CNvPr *oox_cnvPr);
...@@ -417,6 +420,8 @@ public: ...@@ -417,6 +420,8 @@ public:
void convert(PPTX::Logic::QuadBezTo *oox_geom_path); void convert(PPTX::Logic::QuadBezTo *oox_geom_path);
void convert(PPTX::Logic::CubicBezTo *oox_geom_path); void convert(PPTX::Logic::CubicBezTo *oox_geom_path);
void convert(PPTX::Logic::Close *oox_geom_path); void convert(PPTX::Logic::Close *oox_geom_path);
void convert(PPTX::Logic::AhXY *oox_handle);
void convert(PPTX::Logic::AhPolar *oox_handle);
void convert(PPTX::Logic::EffectStyle *oox_effect); void convert(PPTX::Logic::EffectStyle *oox_effect);
void convert(PPTX::Logic::EffectLst *oox_effect_list); void convert(PPTX::Logic::EffectLst *oox_effect_list);
void convert(PPTX::Logic::InnerShdw *oox_effect); void convert(PPTX::Logic::InnerShdw *oox_effect);
......
<?xml version="1.0" encoding="windows-1251"?> <?xml version="1.0" encoding="windows-1251"?>
<VisualStudioProject <VisualStudioProject
ProjectType="Visual C++" ProjectType="Visual C++"
Version="8,00" Version="8.00"
Name="Oox2OdfConverter" Name="Oox2OdfConverter"
ProjectGUID="{BEE01B53-244A-44E6-8947-ED9342D9247E}" ProjectGUID="{BEE01B53-244A-44E6-8947-ED9342D9247E}"
RootNamespace="Oox2OdfConverter" RootNamespace="Oox2OdfConverter"
......
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