mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-02-11 02:16:02 +08:00
Compare commits
10 Commits
core-windo
...
core/devel
| Author | SHA1 | Date | |
|---|---|---|---|
| c505aced48 | |||
| 959d5e5fcd | |||
| 8ee0cf4b2c | |||
| 426342074e | |||
| d2c092fe62 | |||
| a336917338 | |||
| 8925ddeee5 | |||
| 84824631b2 | |||
| dc3ecb1fc0 | |||
| 266cef8c49 |
@ -67,30 +67,41 @@ public:
|
||||
odf_type_name =L"ooxml-snip2DiagRect";
|
||||
|
||||
modifiers = L"0 16667";
|
||||
enhanced_path = L"M ?f9 ?f2 L ?f13 ?f2 ?f1 ?f12 ?f1 ?f11 ?f10 ?f3 ?f12 ?f3 ?f0 ?f14 ?f0 ?f9 Z N";
|
||||
text_areas = L"?f17 ?f17 ?f18 ?f19";
|
||||
view_box = L"0 0 21600 21600";
|
||||
enhanced_path = L"M ?f3 0 L ?f7 0 ?f14 ?f6 ?f14 ?f5 ?f4 ?f17 ?f6 ?f17 0 ?f8 0 ?f3 Z N";
|
||||
text_areas = L"?f11 ?f11 ?f12 ?f13";
|
||||
view_box = L"0 0 0 0";
|
||||
|
||||
add(L"f0", L"left");
|
||||
add(L"f1", L"right");
|
||||
add(L"f2", L"top");
|
||||
add(L"f3", L"bottom");
|
||||
add(L"f4", L"?f3 - ?f2");
|
||||
add(L"f5", L"?f1 - ?f0");
|
||||
add(L"f6", L"min(?f5, ?f4)");
|
||||
add(L"f7", L"$0");
|
||||
add(L"f8", L"$1");
|
||||
add(L"f9", L"?f6 * ?f7 / 100000");
|
||||
add(L"f10", L"?f1 - ?f9");
|
||||
add(L"f11", L"?f3 - ?f9");
|
||||
add(L"f12", L"?f6 * ?f8 / 100000");
|
||||
add(L"f13", L"?f1 - ?f12");
|
||||
add(L"f14", L"?f3 - ?f12");
|
||||
add(L"f15", L"?f9 - ?f12");
|
||||
add(L"f16", L"if(?f15, ?f9, ?f12)");
|
||||
add(L"f17", L"?f16 / 2");
|
||||
add(L"f18", L"?f1 - ?f17");
|
||||
add(L"f19", L"?f3 - ?f17");
|
||||
add(L"f0", L"if(0-$0 ,0,if(50000-$0 ,$0 ,50000))");
|
||||
add(L"f1", L"if(0-$1 ,0,if(50000-$1 ,$1 ,50000))");
|
||||
add(L"f2", L"min(logwidth,logheight)");
|
||||
add(L"f3", L"?f2 *?f0 /100000");
|
||||
add(L"f4", L"logwidth+0-?f3 ");
|
||||
add(L"f5", L"logheight+0-?f3 ");
|
||||
add(L"f6", L"?f2 *?f1 /100000");
|
||||
add(L"f7", L"logwidth+0-?f6 ");
|
||||
add(L"f8", L"logheight+0-?f6 ");
|
||||
add(L"f9", L"?f3 +0-?f6 ");
|
||||
add(L"f10", L"if(?f9 ,?f3 ,?f6 )");
|
||||
add(L"f11", L"?f10 *1/2");
|
||||
add(L"f12", L"logwidth+0-?f11 ");
|
||||
add(L"f13", L"logheight+0-?f11 ");
|
||||
add(L"f14", L"logwidth");
|
||||
add(L"f15", L"logheight/2");
|
||||
add(L"f16", L"logwidth/2");
|
||||
add(L"f17", L"logheight");
|
||||
|
||||
_handle h;
|
||||
|
||||
h.position = L"?f3 0";
|
||||
h.x_maximum= L"50000";
|
||||
h.x_minimum= L"0";
|
||||
handles.push_back(h);
|
||||
|
||||
h.position = L"?f7 0";
|
||||
h.x_maximum= L"50000";
|
||||
h.x_minimum= L"0";
|
||||
handles.push_back(h);
|
||||
|
||||
}
|
||||
};
|
||||
class oox_shape_snip2SameRect : public oox_shape
|
||||
|
||||
@ -262,6 +262,7 @@ void odf_conversion_context::process_settings(_object & object, bool isRoot)
|
||||
void odf_conversion_context::process_styles(_object & object, bool isRoot)
|
||||
{
|
||||
create_element(L"office", L"styles", object.styles, this, true);//общие стили
|
||||
|
||||
object.style_context->process_office_styles(object.styles.back());
|
||||
page_layout_context()->process_office_styles(object.styles.back());
|
||||
|
||||
@ -288,7 +289,15 @@ office_element_ptr odf_conversion_context::start_tabs()
|
||||
create_element(L"style", L"tab-stops", temporary_.elm, this,true);
|
||||
return temporary_.elm;
|
||||
}
|
||||
std::wstring odf_conversion_context::add_image(const std::wstring & image_file_name)
|
||||
{
|
||||
if (image_file_name.empty()) return L"";
|
||||
|
||||
std::wstring odf_ref_name ;
|
||||
mediaitems()->add_or_find(image_file_name,_mediaitems::typeImage, odf_ref_name);
|
||||
|
||||
return odf_ref_name;
|
||||
}
|
||||
void odf_conversion_context::add_tab(_CP_OPT(int) type, _CP_OPT(length) _length, _CP_OPT(int) leader)
|
||||
{
|
||||
if (!temporary_.elm) return;
|
||||
|
||||
@ -95,7 +95,7 @@ public:
|
||||
virtual void start_text_context() = 0;
|
||||
virtual void end_text_context() = 0;
|
||||
|
||||
virtual void start_image(const std::wstring & image_file_name) = 0;
|
||||
std::wstring add_image(const std::wstring & image_file_name);
|
||||
|
||||
virtual odf_style_context * styles_context();
|
||||
|
||||
|
||||
@ -317,6 +317,11 @@ void odf_drawing_context::set_presentation (bool bMaster)
|
||||
impl_->is_presentation_ = bMaster;
|
||||
}
|
||||
|
||||
_CP_OPT(bool) odf_drawing_context::get_presentation ()
|
||||
{
|
||||
return impl_->is_presentation_;
|
||||
}
|
||||
|
||||
void odf_drawing_context::set_footer_state(bool Val)
|
||||
{
|
||||
impl_->is_footer_ = Val;
|
||||
@ -491,14 +496,20 @@ void odf_drawing_context::end_drawing()
|
||||
_CP_OPT(std::wstring) draw_layer;
|
||||
if (impl_->is_presentation_.get() == true)
|
||||
{//master
|
||||
if (impl_->current_drawing_state_.presentation_class_)
|
||||
draw_layer = L"backgroundobjects";
|
||||
else draw_layer = L"layout";
|
||||
draw_layer = L"backgroundobjects";
|
||||
//if (impl_->current_drawing_state_.presentation_class_)
|
||||
// draw_layer = L"backgroundobjects";
|
||||
//else draw_layer = L"layout";
|
||||
if (!impl_->current_drawing_state_.presentation_class_)
|
||||
impl_->current_drawing_state_.presentation_class_ = presentation_class::outline;
|
||||
|
||||
draw->common_draw_attlists_.shape_with_text_and_styles_.common_presentation_attlist_.presentation_user_transformed_ = true;
|
||||
draw->common_draw_attlists_.shape_with_text_and_styles_.common_presentation_attlist_.presentation_placeholder_ = false;
|
||||
}
|
||||
else
|
||||
{//slide
|
||||
if (impl_->current_drawing_state_.presentation_class_)
|
||||
draw_layer = L"layout";
|
||||
draw_layer = L"layout";
|
||||
}
|
||||
draw->common_draw_attlists_.shape_with_text_and_styles_.common_presentation_attlist_.presentation_class_ = impl_->current_drawing_state_.presentation_class_;
|
||||
draw->common_draw_attlists_.shape_with_text_and_styles_.common_shape_draw_attlist_.draw_layer_ = draw_layer;
|
||||
@ -696,7 +707,10 @@ void odf_drawing_context::Impl::create_draw_base(int type)
|
||||
draw_base* draw = dynamic_cast<draw_base*>(draw_elm.get());
|
||||
if (draw == NULL)return;
|
||||
//////////
|
||||
styles_context_->create_style(L"", style_family::Graphic, true, false, -1);
|
||||
if (is_presentation_ && current_drawing_state_.presentation_class_)
|
||||
styles_context_->create_style(L"", style_family::Presentation, true, false, -1);
|
||||
else
|
||||
styles_context_->create_style(L"", style_family::Graphic, true, false, -1);
|
||||
|
||||
office_element_ptr & style_shape_elm = styles_context_->last_state()->get_office_element();
|
||||
std::wstring style_name;
|
||||
@ -708,7 +722,10 @@ void odf_drawing_context::Impl::create_draw_base(int type)
|
||||
current_graphic_properties = style_->content_.get_graphic_properties();
|
||||
}
|
||||
|
||||
draw->common_draw_attlists_.shape_with_text_and_styles_.common_shape_draw_attlist_.draw_style_name_ = style_name;
|
||||
if (is_presentation_ && current_drawing_state_.presentation_class_)
|
||||
draw->common_draw_attlists_.shape_with_text_and_styles_.common_presentation_attlist_.presentation_style_name_ = style_name;
|
||||
else
|
||||
draw->common_draw_attlists_.shape_with_text_and_styles_.common_shape_draw_attlist_.draw_style_name_ = style_name;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
int level = current_level_.size();
|
||||
@ -1175,16 +1192,16 @@ void odf_drawing_context::set_placeholder_type (int val)
|
||||
{
|
||||
switch(val)
|
||||
{
|
||||
case 0: impl_->current_drawing_state_.presentation_class_ = presentation_class::text; break;
|
||||
case 1: impl_->current_drawing_state_.presentation_class_ = presentation_class::chart; break;
|
||||
case 0: impl_->current_drawing_state_.presentation_class_ = presentation_class::outline; break;
|
||||
case 1: impl_->current_drawing_state_.presentation_class_ = presentation_class::chart; break;
|
||||
case 2: impl_->current_drawing_state_.presentation_class_ = presentation_class::graphic; break;
|
||||
case 3: impl_->current_drawing_state_.presentation_class_ = presentation_class::title; break;
|
||||
case 4: impl_->current_drawing_state_.presentation_class_ = presentation_class::graphic; break;
|
||||
case 5: impl_->current_drawing_state_.presentation_class_ = presentation_class::date_time; break;
|
||||
case 6: impl_->current_drawing_state_.presentation_class_ = presentation_class::footer; break;
|
||||
case 7: impl_->current_drawing_state_.presentation_class_ = presentation_class::header; break;
|
||||
case 8: impl_->current_drawing_state_.presentation_class_ = presentation_class::object; break;
|
||||
case 9: impl_->current_drawing_state_.presentation_class_ = presentation_class::object; break;
|
||||
case 6: impl_->current_drawing_state_.presentation_class_ = presentation_class::footer; break;
|
||||
case 7: impl_->current_drawing_state_.presentation_class_ = presentation_class::header; break;
|
||||
case 8: impl_->current_drawing_state_.presentation_class_ = presentation_class::object; break;
|
||||
case 9: impl_->current_drawing_state_.presentation_class_ = presentation_class::object; break;
|
||||
case 10: impl_->current_drawing_state_.presentation_class_ = presentation_class::graphic; break;
|
||||
case 11: impl_->current_drawing_state_.presentation_class_ = presentation_class::graphic; break;
|
||||
case 12: impl_->current_drawing_state_.presentation_class_ = presentation_class::page_number;break;
|
||||
@ -1192,7 +1209,7 @@ void odf_drawing_context::set_placeholder_type (int val)
|
||||
case 14: impl_->current_drawing_state_.presentation_class_ = presentation_class::table; break;
|
||||
case 15: impl_->current_drawing_state_.presentation_class_ = presentation_class::title; break;
|
||||
default:
|
||||
impl_->current_drawing_state_.presentation_class_ = presentation_class::text; break;
|
||||
impl_->current_drawing_state_.presentation_class_ = presentation_class::outline; break;
|
||||
}
|
||||
//todooo draw_layer for master for sldnum, datetime ...
|
||||
}
|
||||
@ -1730,8 +1747,8 @@ void odf_drawing_context::set_group_position(_CP_OPT(double) x, _CP_OPT(double)
|
||||
impl_->current_group_->x = *change_x ;
|
||||
impl_->current_group_->y = *change_y ;
|
||||
|
||||
impl_->current_group_->shift_x = (*x - *change_x) ;
|
||||
impl_->current_group_->shift_y = (*y - *change_y) ;
|
||||
impl_->current_group_->shift_x = (*x /impl_->current_group_->scale_cx - *change_x) ;
|
||||
impl_->current_group_->shift_y = (*y /impl_->current_group_->scale_cy - *change_y) ;
|
||||
}
|
||||
|
||||
void odf_drawing_context::set_group_size( _CP_OPT(double) cx, _CP_OPT(double) cy, _CP_OPT(double) change_cx, _CP_OPT(double) change_cy)
|
||||
@ -2455,7 +2472,7 @@ void odf_drawing_context::set_text(odf_text_context* text_context)
|
||||
{
|
||||
if (text_context == NULL || impl_->current_level_.size() < 1 ) return;
|
||||
|
||||
if (impl_->is_presentation_ && *impl_->is_presentation_) return;
|
||||
//if (impl_->is_presentation_ && *impl_->is_presentation_) return;
|
||||
|
||||
for (size_t i = 0; i < text_context->text_elements_list_.size(); i++)
|
||||
{
|
||||
|
||||
@ -60,7 +60,8 @@ public:
|
||||
odf_drawing_context (odf_conversion_context *odf_context);
|
||||
~odf_drawing_context ();
|
||||
|
||||
void set_presentation (bool bMaster);
|
||||
void set_presentation (bool bMaster);
|
||||
_CP_OPT(bool) get_presentation ();
|
||||
|
||||
void set_drawings_rect (_CP_OPT(double) x_pt, _CP_OPT(double) y_pt, _CP_OPT(double) width_pt, _CP_OPT(double) height_pt);
|
||||
void clear ();
|
||||
@ -125,7 +126,7 @@ public:
|
||||
void start_frame ();
|
||||
void end_frame ();
|
||||
|
||||
void start_image (std::wstring file_path);
|
||||
void start_image (std::wstring odf_file_path);
|
||||
void end_image ();
|
||||
|
||||
bool change_text_box_2_wordart ();
|
||||
|
||||
@ -54,11 +54,12 @@ void odf_lists_styles_context::set_odf_context(odf_conversion_context * Context)
|
||||
odf_context_ = Context;
|
||||
}
|
||||
|
||||
void odf_lists_styles_context::process_styles(office_element_ptr root )
|
||||
void odf_lists_styles_context::process_styles(office_element_ptr root, bool automatic)
|
||||
{
|
||||
for (size_t i = 0; i < lists_format_array_.size(); i++)
|
||||
{
|
||||
if (lists_format_array_[i].elements.size() < 1) continue;
|
||||
if (lists_format_array_[i].elements.size() < 1) continue;
|
||||
if (lists_format_array_[i].automatic != automatic) continue;
|
||||
|
||||
root->add_child_element(lists_format_array_[i].elements[0]);
|
||||
}
|
||||
@ -92,7 +93,13 @@ std::wstring odf_lists_styles_context::get_style_name1(int oox_style_num)
|
||||
}
|
||||
std::wstring odf_lists_styles_context::get_style_name(int oox_style_num)
|
||||
{
|
||||
if (link_format_map_.count(oox_style_num) > 0)
|
||||
if (lists_format_array_.empty()) return L"";
|
||||
|
||||
if (oox_style_num < 0)
|
||||
{
|
||||
return lists_format_array_.back().odf_list_style_name;
|
||||
}
|
||||
else if (link_format_map_.count(oox_style_num) > 0)
|
||||
{
|
||||
return link_format_map_.at(oox_style_num);
|
||||
}
|
||||
@ -101,7 +108,7 @@ std::wstring odf_lists_styles_context::get_style_name(int oox_style_num)
|
||||
return L"";
|
||||
}
|
||||
}
|
||||
void odf_lists_styles_context::start_style(int based_number)
|
||||
void odf_lists_styles_context::start_style(bool bMaster, int based_number)
|
||||
{
|
||||
list_format_state state;
|
||||
|
||||
@ -109,21 +116,29 @@ void odf_lists_styles_context::start_style(int based_number)
|
||||
create_element(L"text", L"list-style", elm, odf_context_);
|
||||
state.elements.push_back(elm);
|
||||
|
||||
state.oox_based_number = based_number;
|
||||
state.odf_list_style_name = std::wstring(L"WWNum") + boost::lexical_cast<std::wstring>(based_number + 1);
|
||||
if (based_number < 0)
|
||||
{
|
||||
state.oox_based_number = lists_format_array_.size();
|
||||
state.odf_list_style_name = std::wstring(L"L") + boost::lexical_cast<std::wstring>(state.oox_based_number + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
state.oox_based_number = based_number;
|
||||
state.odf_list_style_name = std::wstring(L"WWNum") + boost::lexical_cast<std::wstring>(state.oox_based_number + 1);
|
||||
}
|
||||
state.automatic = !bMaster;
|
||||
|
||||
text_list_style *style = dynamic_cast<text_list_style *>(elm.get());
|
||||
if (style == NULL)return;
|
||||
|
||||
style->text_list_style_attr_.style_name_ = state.odf_list_style_name;
|
||||
|
||||
lists_format_array_.push_back(state); //перенести в end??
|
||||
}
|
||||
|
||||
style_list_level_properties * odf_lists_styles_context::get_list_level_properties()
|
||||
{
|
||||
if (lists_format_array_.size() < 1) return NULL;
|
||||
if (lists_format_array_.back().elements.size() <1) return NULL;
|
||||
if (lists_format_array_.empty()) return NULL;
|
||||
if (lists_format_array_.back().elements.empty()) return NULL;
|
||||
|
||||
text_list_level_style_number *style_number_ = dynamic_cast<text_list_level_style_number *>(lists_format_array_.back().elements.back().get());
|
||||
text_list_level_style_bullet *style_bullet_ = dynamic_cast<text_list_level_style_bullet *>(lists_format_array_.back().elements.back().get());
|
||||
@ -156,8 +171,8 @@ style_list_level_properties * odf_lists_styles_context::get_list_level_propertie
|
||||
}
|
||||
style_text_properties * odf_lists_styles_context::get_text_properties()
|
||||
{
|
||||
if (lists_format_array_.size() < 1) return NULL;
|
||||
if (lists_format_array_.back().elements.size() <1) return NULL;
|
||||
if (lists_format_array_.empty()) return NULL;
|
||||
if (lists_format_array_.back().elements.empty()) return NULL;
|
||||
|
||||
text_list_level_style_number *style_number_ = dynamic_cast<text_list_level_style_number *>(lists_format_array_.back().elements.back().get());
|
||||
text_list_level_style_bullet *style_bullet_ = dynamic_cast<text_list_level_style_bullet *>(lists_format_array_.back().elements.back().get());
|
||||
@ -167,14 +182,14 @@ style_text_properties * odf_lists_styles_context::get_text_properties()
|
||||
if (style_number_)
|
||||
{
|
||||
if (!style_number_->style_text_properties_)
|
||||
create_element(L"style", L"text-properties",style_number_->style_text_properties_,odf_context_);
|
||||
create_element(L"style", L"text-properties", style_number_->style_text_properties_, odf_context_);
|
||||
|
||||
props = dynamic_cast<style_text_properties *>(style_number_->style_text_properties_.get());
|
||||
}
|
||||
if (style_bullet_)
|
||||
{
|
||||
if (!style_bullet_->style_text_properties_)
|
||||
create_element(L"style", L"text-properties",style_bullet_->style_text_properties_,odf_context_);
|
||||
create_element(L"style", L"text-properties", style_bullet_->style_text_properties_, odf_context_);
|
||||
|
||||
props = dynamic_cast<style_text_properties *>(style_bullet_->style_text_properties_.get());
|
||||
}
|
||||
@ -190,8 +205,8 @@ style_text_properties * odf_lists_styles_context::get_text_properties()
|
||||
|
||||
style_list_level_label_alignment * odf_lists_styles_context::get_list_level_alignment_properties()
|
||||
{
|
||||
if (lists_format_array_.size() < 1) return NULL;
|
||||
if (lists_format_array_.back().elements.size() <1) return NULL;
|
||||
if (lists_format_array_.empty()) return NULL;
|
||||
if (lists_format_array_.back().elements.empty()) return NULL;
|
||||
|
||||
text_list_level_style_number *style_number_ = dynamic_cast<text_list_level_style_number *>(lists_format_array_.back().elements.back().get());
|
||||
text_list_level_style_bullet *style_bullet_ = dynamic_cast<text_list_level_style_bullet *>(lists_format_array_.back().elements.back().get());
|
||||
@ -201,21 +216,21 @@ style_list_level_label_alignment * odf_lists_styles_context::get_list_level_alig
|
||||
if (style_number_)
|
||||
{
|
||||
if (!style_number_->style_list_level_properties_)
|
||||
create_element(L"style", L"list-level-properties",style_number_->style_list_level_properties_,odf_context_);
|
||||
create_element(L"style", L"list-level-properties", style_number_->style_list_level_properties_, odf_context_);
|
||||
|
||||
props = dynamic_cast<style_list_level_properties *>(style_number_->style_list_level_properties_.get());
|
||||
}
|
||||
if (style_bullet_)
|
||||
{
|
||||
if (!style_bullet_->style_list_level_properties_)
|
||||
create_element(L"style", L"list-level-properties",style_bullet_->style_list_level_properties_,odf_context_);
|
||||
create_element(L"style", L"list-level-properties", style_bullet_->style_list_level_properties_, odf_context_);
|
||||
|
||||
props = dynamic_cast<style_list_level_properties *>(style_bullet_->style_list_level_properties_.get());
|
||||
}
|
||||
if (style_image_)
|
||||
{
|
||||
if (!style_image_->style_list_level_properties_)
|
||||
create_element(L"style", L"list-level-properties",style_image_->style_list_level_properties_,odf_context_);
|
||||
create_element(L"style", L"list-level-properties", style_image_->style_list_level_properties_, odf_context_);
|
||||
|
||||
props = dynamic_cast<style_list_level_properties *>(style_image_->style_list_level_properties_.get());
|
||||
}
|
||||
@ -223,14 +238,15 @@ style_list_level_label_alignment * odf_lists_styles_context::get_list_level_alig
|
||||
|
||||
if (!props->style_list_level_label_alignment_)
|
||||
{
|
||||
create_element(L"style", L"list-level-label-alignment" ,props->style_list_level_label_alignment_,odf_context_);
|
||||
create_element(L"style", L"list-level-label-alignment" , props->style_list_level_label_alignment_, odf_context_);
|
||||
}
|
||||
return dynamic_cast<style_list_level_label_alignment *>(props->style_list_level_label_alignment_.get());
|
||||
}
|
||||
|
||||
int odf_lists_styles_context::start_style_level(int level, int type)
|
||||
{
|
||||
if (lists_format_array_.size() < 1) return -1;
|
||||
if (lists_format_array_.empty()) return -1;
|
||||
|
||||
int odf_type =1;
|
||||
int format_type = -1;
|
||||
|
||||
@ -451,10 +467,10 @@ wchar_t convert_bullet_char(wchar_t c)
|
||||
}
|
||||
void odf_lists_styles_context::set_numeric_format(std::wstring val)
|
||||
{
|
||||
if (lists_format_array_.size() < 1) return;
|
||||
if (lists_format_array_.back().elements.size() <1) return ;
|
||||
if ( val.length() <1 )
|
||||
return;
|
||||
if ( lists_format_array_.empty() ) return;
|
||||
if ( lists_format_array_.back().elements.empty() ) return;
|
||||
|
||||
if ( val.empty() ) return;
|
||||
|
||||
text_list_level_style_number *style_number_ = dynamic_cast<text_list_level_style_number *>(lists_format_array_.back().elements.back().get());
|
||||
if (style_number_)
|
||||
@ -522,10 +538,10 @@ void odf_lists_styles_context::set_numeric_format(std::wstring val)
|
||||
}
|
||||
void odf_lists_styles_context::set_bullet_char(std::wstring val)
|
||||
{
|
||||
if (lists_format_array_.size() < 1) return;
|
||||
if (lists_format_array_.back().elements.size() <1) return ;
|
||||
if ( val.length() <1 )
|
||||
return;
|
||||
if ( lists_format_array_.empty() ) return;
|
||||
if ( lists_format_array_.back().elements.empty() ) return ;
|
||||
|
||||
if ( val.empty() ) return;
|
||||
|
||||
text_list_level_style_bullet *style_bullet_ = dynamic_cast<text_list_level_style_bullet *>(lists_format_array_.back().elements.back().get());
|
||||
|
||||
@ -536,20 +552,20 @@ void odf_lists_styles_context::set_bullet_char(std::wstring val)
|
||||
void odf_lists_styles_context::set_bullet_image_size(double size)
|
||||
{
|
||||
if (size < 0.1) return;
|
||||
if (lists_format_array_.size() < 1) return;
|
||||
if (lists_format_array_.back().elements.size() <1) return ;
|
||||
if (lists_format_array_.empty()) return;
|
||||
if (lists_format_array_.back().elements.empty()) return ;
|
||||
|
||||
style_list_level_properties *props = get_list_level_properties();
|
||||
|
||||
if(!props) return;
|
||||
|
||||
props->fo_width_ = length(length(size,length::pt).get_value_unit(length::cm),length::cm);
|
||||
props->fo_height_ = length(length(size,length::pt).get_value_unit(length::cm),length::cm);
|
||||
props->fo_width_ = length(length(size, length::pt).get_value_unit(length::cm), length::cm);
|
||||
props->fo_height_ = length(length(size, length::pt).get_value_unit(length::cm), length::cm);
|
||||
}
|
||||
void odf_lists_styles_context::set_bullet_image (std::wstring ref)
|
||||
{
|
||||
if (lists_format_array_.size() < 1) return;
|
||||
if (lists_format_array_.back().elements.size() <1) return ;
|
||||
if (lists_format_array_.empty()) return;
|
||||
if (lists_format_array_.back().elements.empty()) return ;
|
||||
|
||||
text_list_level_style_image *style_image_ = dynamic_cast<text_list_level_style_image *>(lists_format_array_.back().elements.back().get());
|
||||
|
||||
@ -557,14 +573,14 @@ void odf_lists_styles_context::set_bullet_image (std::wstring ref)
|
||||
|
||||
style_image_->text_list_level_style_image_attr_.common_xlink_attlist_.href_ = ref;
|
||||
|
||||
style_image_->text_list_level_style_image_attr_.common_xlink_attlist_.type_= xlink_type::Simple;
|
||||
style_image_->text_list_level_style_image_attr_.common_xlink_attlist_.show_ = xlink_show::Embed;
|
||||
style_image_->text_list_level_style_image_attr_.common_xlink_attlist_.actuate_= xlink_actuate::OnLoad;
|
||||
style_image_->text_list_level_style_image_attr_.common_xlink_attlist_.type_ = xlink_type::Simple;
|
||||
style_image_->text_list_level_style_image_attr_.common_xlink_attlist_.show_ = xlink_show::Embed;
|
||||
style_image_->text_list_level_style_image_attr_.common_xlink_attlist_.actuate_ = xlink_actuate::OnLoad;
|
||||
}
|
||||
void odf_lists_styles_context::set_start_number(int val)
|
||||
{
|
||||
if (lists_format_array_.size() < 1) return;
|
||||
if (lists_format_array_.back().elements.size() <1) return ;
|
||||
if (lists_format_array_.empty()) return;
|
||||
if (lists_format_array_.back().elements.empty()) return ;
|
||||
|
||||
text_list_level_style_number *style_number_ = dynamic_cast<text_list_level_style_number *>(lists_format_array_.back().elements.back().get());
|
||||
|
||||
@ -574,8 +590,8 @@ void odf_lists_styles_context::set_start_number(int val)
|
||||
}
|
||||
void odf_lists_styles_context::set_text_style_name(std::wstring name)
|
||||
{
|
||||
if (lists_format_array_.size() < 1) return;
|
||||
if (lists_format_array_.back().elements.size() <1) return ;
|
||||
if (lists_format_array_.empty()) return;
|
||||
if (lists_format_array_.back().elements.empty()) return ;
|
||||
|
||||
text_list_level_style_number *style_number_ = dynamic_cast<text_list_level_style_number *>(lists_format_array_.back().elements.back().get());
|
||||
text_list_level_style_bullet *style_bullet_ = dynamic_cast<text_list_level_style_bullet *>(lists_format_array_.back().elements.back().get());
|
||||
|
||||
@ -55,7 +55,7 @@ struct list_format_state
|
||||
std::vector<office_element_ptr> elements;
|
||||
|
||||
std::wstring odf_list_style_name;
|
||||
|
||||
bool automatic;
|
||||
};
|
||||
|
||||
class odf_lists_styles_context
|
||||
@ -64,7 +64,7 @@ public:
|
||||
odf_lists_styles_context();
|
||||
void set_odf_context(odf_conversion_context * Context);
|
||||
|
||||
void start_style(int abstract_number);
|
||||
void start_style(bool bMaster, int abstract_number = -1);
|
||||
int start_style_level(int level, int type);
|
||||
style_list_level_properties * get_list_level_properties();
|
||||
style_list_level_label_alignment * get_list_level_alignment_properties();
|
||||
@ -84,9 +84,9 @@ public:
|
||||
|
||||
void add_style(int oox_style_num, int oox_based_num);
|
||||
|
||||
void process_styles(office_element_ptr root );
|
||||
void process_styles(office_element_ptr root, bool automatic);
|
||||
|
||||
std::wstring get_style_name(int oox_style_num);
|
||||
std::wstring get_style_name(int oox_style_num = -1);
|
||||
std::wstring get_style_name1(int oox_style_num);
|
||||
private:
|
||||
std::vector<list_format_state> lists_format_array_;
|
||||
|
||||
@ -161,6 +161,7 @@ void odf_style_context::process_automatic_styles(office_element_ptr root )
|
||||
if (/*it->automatic_== true && */style_state_list_[i]->root_== false && style_state_list_[i]->odf_style_)
|
||||
root->add_child_element(style_state_list_[i]->odf_style_);
|
||||
}
|
||||
lists_styles_context_.process_styles(root, true);
|
||||
}
|
||||
|
||||
void odf_style_context::process_office_styles(office_element_ptr root )
|
||||
@ -175,7 +176,7 @@ void odf_style_context::process_office_styles(office_element_ptr root )
|
||||
root->add_child_element(style_state_list_[i]->odf_style_);
|
||||
}
|
||||
|
||||
lists_styles_context_.process_styles(root );
|
||||
lists_styles_context_.process_styles(root, false);
|
||||
}
|
||||
std::wstring odf_style_context::find_odf_style_name(int oox_id_style, style_family::type family, bool root, bool automatic)
|
||||
{
|
||||
|
||||
@ -147,14 +147,7 @@ void odp_conversion_context::end_drawings()
|
||||
{
|
||||
current_slide().drawing_context()->clear();
|
||||
}
|
||||
void odp_conversion_context::start_image(const std::wstring & image_file_name)
|
||||
{
|
||||
std::wstring odf_ref_name ;
|
||||
|
||||
mediaitems()->add_or_find(image_file_name,_mediaitems::typeImage,odf_ref_name);
|
||||
|
||||
current_slide().drawing_context()->start_image(odf_ref_name);
|
||||
}
|
||||
void odp_conversion_context::start_comment(int oox_comm_id)
|
||||
{
|
||||
office_element_ptr comm_elm;
|
||||
|
||||
@ -72,8 +72,6 @@ public:
|
||||
void start_drawings();
|
||||
void end_drawings();
|
||||
|
||||
virtual void start_image(const std::wstring & image_file_name);
|
||||
|
||||
void start_comment (int oox_comment_id);
|
||||
void end_comment ();
|
||||
void start_comment_content ();
|
||||
|
||||
@ -527,14 +527,7 @@ void ods_conversion_context::end_drawings()
|
||||
{
|
||||
current_table().drawing_context()->clear();
|
||||
}
|
||||
void ods_conversion_context::start_image(const std::wstring & image_file_name)
|
||||
{
|
||||
std::wstring odf_ref_name ;
|
||||
|
||||
mediaitems()->add_or_find(image_file_name,_mediaitems::typeImage,odf_ref_name);
|
||||
|
||||
current_table().drawing_context()->start_image(odf_ref_name);
|
||||
}
|
||||
double ods_conversion_context::convert_symbol_width(double val)
|
||||
{
|
||||
//width = ((int)((column_width * Digit_Width + 5) / Digit_Width * 256 )) / 256.;
|
||||
|
||||
@ -101,8 +101,6 @@ public:
|
||||
void start_drawings();
|
||||
void end_drawings();
|
||||
|
||||
virtual void start_image(const std::wstring & image_file_name);
|
||||
|
||||
double convert_symbol_width(double val);
|
||||
|
||||
void add_defined_range (const std::wstring & name, const std::wstring & cell_range, int sheet_id, bool printable = false);
|
||||
|
||||
@ -915,14 +915,6 @@ void odt_conversion_context::end_change (int id, int type)
|
||||
// return (text_changes_state_.current_types.back() == 2);
|
||||
//}
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
void odt_conversion_context::start_image(const std::wstring & image_file_name)
|
||||
{
|
||||
std::wstring odf_ref_name ;
|
||||
|
||||
mediaitems()->add_or_find(image_file_name, _mediaitems::typeImage,odf_ref_name);
|
||||
|
||||
drawing_context()->start_image(odf_ref_name);
|
||||
}
|
||||
|
||||
void odt_conversion_context::start_drop_cap(style_paragraph_properties *paragraph_properties)
|
||||
{
|
||||
|
||||
@ -82,8 +82,7 @@ public:
|
||||
void start_drawings ();
|
||||
void end_drawings ();
|
||||
|
||||
virtual void start_image(const std::wstring & image_file_name);
|
||||
void add_text_content (const std::wstring & text);
|
||||
void add_text_content (const std::wstring & text);
|
||||
|
||||
void start_paragraph (bool styled = false);
|
||||
void end_paragraph ();
|
||||
|
||||
@ -34,7 +34,6 @@
|
||||
|
||||
#include "../../../Common/DocxFormat/Source/DocxFormat/Diagram/DiagramDrawing.h"
|
||||
#include "../../../Common/DocxFormat/Source/XlsxFormat/Chart/Chart.h"
|
||||
|
||||
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/SpTreeElem.h"
|
||||
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/GraphicFrame.h"
|
||||
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Shape.h"
|
||||
@ -46,6 +45,7 @@
|
||||
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Colors/SrgbClr.h"
|
||||
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Colors/PrstClr.h"
|
||||
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Colors/SchemeClr.h"
|
||||
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/TextFont.h"
|
||||
|
||||
#include "../../../Common/DocxFormat/Source/Common/SimpleTypes_Drawing.h"
|
||||
#include "../../../Common/DocxFormat/Source/Common/SimpleTypes_Word.h"
|
||||
@ -55,6 +55,7 @@
|
||||
#include "../OdfFormat/odf_drawing_context.h"
|
||||
#include "../OdfFormat/style_text_properties.h"
|
||||
#include "../OdfFormat/style_paragraph_properties.h"
|
||||
#include "../OdfFormat/styles_list.h"
|
||||
|
||||
using namespace cpdoccore;
|
||||
|
||||
@ -207,23 +208,27 @@ void OoxConverter::convert(PPTX::Logic::Pic *oox_picture)
|
||||
}
|
||||
}
|
||||
|
||||
std::wstring pathImage;
|
||||
std::wstring odf_ref;
|
||||
std::wstring pathImage;
|
||||
if (oox_picture->blipFill.blip.IsInit())
|
||||
{
|
||||
std::wstring sID;
|
||||
|
||||
bool bEmbedded = true;
|
||||
if (oox_picture->blipFill.blip->embed.IsInit())
|
||||
{
|
||||
sID = oox_picture->blipFill.blip->embed->get();
|
||||
std::wstring sID = oox_picture->blipFill.blip->embed->get();
|
||||
pathImage = find_link_by_id(sID, 1);
|
||||
|
||||
odf_ref = odf_context()->add_image(pathImage);
|
||||
}
|
||||
else if (oox_picture->blipFill.blip->link.IsInit())
|
||||
{
|
||||
pathImage = oox_picture->blipFill.blip->link->get();
|
||||
odf_ref = oox_picture->blipFill.blip->link->get();
|
||||
bEmbedded = false;
|
||||
}
|
||||
}
|
||||
|
||||
odf_context()->drawing_context()->start_drawing();
|
||||
odf_context()->start_image(pathImage);
|
||||
odf_context()->drawing_context()->start_image(odf_ref);
|
||||
{
|
||||
double Width = 0, Height = 0;
|
||||
_graphics_utils_::GetResolution(pathImage.c_str(), Width, Height);
|
||||
@ -1095,48 +1100,249 @@ void OoxConverter::convert(PPTX::Logic::NvPr *oox_nvPr)
|
||||
{
|
||||
if (!oox_nvPr) return;
|
||||
|
||||
if (oox_nvPr->ph.is_init())
|
||||
{
|
||||
if (oox_nvPr->ph->type.IsInit())
|
||||
odf_context()->drawing_context()->set_placeholder_type(oox_nvPr->ph->type->GetBYTECode());
|
||||
if (oox_nvPr->ph->idx.IsInit())
|
||||
odf_context()->drawing_context()->set_placeholder_id(oox_nvPr->ph->idx.get());
|
||||
//nullable_bool hasCustomPrompt;
|
||||
//nullable_limit<Limit::Orient> orient;
|
||||
//nullable_limit<Limit::PlaceholderSize> sz;
|
||||
}
|
||||
//ph уровнем выше
|
||||
}
|
||||
|
||||
void OoxConverter::convert_list_level(PPTX::Logic::TextParagraphPr *oox_para_props, int level)
|
||||
{//одномерные списки тока
|
||||
//if (!oox_list)return;
|
||||
|
||||
if (!oox_para_props) return;
|
||||
|
||||
PPTX::Theme *theme = oox_theme();
|
||||
|
||||
PPTX::Logic::Bullet & bullet = oox_para_props->ParagraphBullet;
|
||||
|
||||
if (bullet.is<PPTX::Logic::BuNone>())return;
|
||||
|
||||
int odf_list_type = 13; // 1, 2, 3 ...
|
||||
|
||||
if (bullet.is<PPTX::Logic::BuAutoNum>())
|
||||
{
|
||||
const PPTX::Logic::BuAutoNum & buAutoNum = bullet.as<PPTX::Logic::BuAutoNum>();
|
||||
int pptx_type = buAutoNum.type.GetBYTECode();
|
||||
|
||||
if ( pptx_type < 3) odf_list_type = 46;
|
||||
if (pptx_type > 2 && pptx_type < 6) odf_list_type = 60;
|
||||
if (pptx_type > 28 && pptx_type < 32) odf_list_type = 47;
|
||||
if (pptx_type > 31 && pptx_type < 35) odf_list_type = 61;
|
||||
|
||||
odf_context()->styles_context()->lists_styles().start_style_level(level, odf_list_type);
|
||||
|
||||
if (buAutoNum.startAt.IsInit())
|
||||
{
|
||||
int start_value = *buAutoNum.startAt;
|
||||
if (start_value > 1)
|
||||
odf_context()->styles_context()->lists_styles().set_start_number(start_value);
|
||||
}
|
||||
}
|
||||
if (bullet.is<PPTX::Logic::BuChar>())
|
||||
{
|
||||
odf_list_type = 5;
|
||||
|
||||
const PPTX::Logic::BuChar & buChar = bullet.as<PPTX::Logic::BuChar>();
|
||||
odf_context()->styles_context()->lists_styles().start_style_level(level, odf_list_type);
|
||||
|
||||
odf_context()->styles_context()->lists_styles().set_bullet_char(buChar.Char);
|
||||
}
|
||||
if (bullet.is<PPTX::Logic::BuBlip>())
|
||||
{
|
||||
const PPTX::Logic::BuBlip & buBlip = bullet.as<PPTX::Logic::BuBlip>();
|
||||
|
||||
std::wstring odf_ref;
|
||||
bool bEmbedded = true;
|
||||
|
||||
if (buBlip.blip.embed.IsInit())
|
||||
{
|
||||
std::wstring sID = buBlip.blip.embed->get();
|
||||
std::wstring pathImage = find_link_by_id(sID, 1);
|
||||
|
||||
if (pathImage.empty())
|
||||
pathImage = buBlip.blip.GetFullPicName(); // only for presentation merge shapes !!
|
||||
|
||||
odf_ref = odf_context()->add_image(pathImage);
|
||||
}
|
||||
else if (buBlip.blip.link.IsInit())
|
||||
{
|
||||
odf_ref = buBlip.blip.link->get();
|
||||
bEmbedded = false;
|
||||
}
|
||||
|
||||
if (!odf_ref.empty())
|
||||
{
|
||||
odf_list_type = 1000;
|
||||
odf_context()->styles_context()->lists_styles().start_style_level(level, odf_list_type );
|
||||
odf_context()->styles_context()->lists_styles().set_bullet_image(odf_ref);
|
||||
}
|
||||
else
|
||||
{
|
||||
odf_list_type = 5;
|
||||
odf_context()->styles_context()->lists_styles().start_style_level(level, odf_list_type );
|
||||
odf_context()->styles_context()->lists_styles().set_bullet_char(L"\x2022");
|
||||
}
|
||||
}
|
||||
|
||||
//odf_writer::style_list_level_label_alignment * aligment_props = odf_context()->styles_context()->lists_styles().get_list_level_alignment_properties();
|
||||
odf_writer::style_list_level_properties * level_props = odf_context()->styles_context()->lists_styles().get_list_level_properties();
|
||||
odf_writer::style_text_properties * text_properties = odf_context()->styles_context()->lists_styles().get_text_properties();
|
||||
|
||||
convert(oox_para_props->defRPr.GetPointer(), text_properties);
|
||||
|
||||
if (oox_para_props->indent.IsInit() && level_props)
|
||||
{
|
||||
level_props->text_min_label_width_ = odf_types::length(- oox_para_props->indent.get() / 12700., odf_types::length::pt);
|
||||
level_props->text_space_before_ = odf_types::length(1, odf_types::length::pt);
|
||||
|
||||
}else
|
||||
{
|
||||
//aligment_props->fo_text_indent_ = odf_types::length(0, odf_types::length::cm);
|
||||
//aligment_props->fo_margin_left_ = odf_types::length(0, odf_types::length::cm);
|
||||
}
|
||||
|
||||
if (oox_para_props->buColor.is<PPTX::Logic::BuClrTx>())
|
||||
{
|
||||
const PPTX::Logic::BuClrTx & buClrTx = oox_para_props->buColor.as<PPTX::Logic::BuClrTx>();
|
||||
}
|
||||
if (oox_para_props->buColor.is<PPTX::Logic::BuClr>())
|
||||
{
|
||||
PPTX::Logic::BuClr & buClr = oox_para_props->buColor.as<PPTX::Logic::BuClr>();
|
||||
|
||||
std::wstring hexColor;
|
||||
_CP_OPT(double) opacity;
|
||||
|
||||
convert(&buClr.Color, hexColor, opacity);
|
||||
if (!hexColor.empty())
|
||||
{
|
||||
int res = 0;
|
||||
if ((res = hexColor.find(L"#")) < 0) hexColor = std::wstring(L"#") + hexColor;
|
||||
if (text_properties) text_properties->content_.fo_color_ = odf_types::color(hexColor);
|
||||
}
|
||||
}
|
||||
//-----------------------------------
|
||||
if (oox_para_props->buSize.is<PPTX::Logic::BuSzPts>())
|
||||
{
|
||||
const PPTX::Logic::BuSzPts & buSzPts = oox_para_props->buSize.as<PPTX::Logic::BuSzPts>();
|
||||
if (buSzPts.val.IsInit())
|
||||
{
|
||||
if (text_properties)
|
||||
text_properties->content_.fo_font_size_ = odf_types::length(*buSzPts.val, odf_types::length::pt);
|
||||
else if (odf_list_type == 1000)
|
||||
odf_context()->styles_context()->lists_styles().set_bullet_image_size(*buSzPts.val);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
double size_pt = oox_para_props->defRPr.IsInit() ? (oox_para_props->defRPr->sz.IsInit() ? *oox_para_props->defRPr->sz /100. : 0) : 0;
|
||||
|
||||
if (size_pt < 0.001 && odf_list_type == 1000)
|
||||
{
|
||||
odf_writer::style_text_properties * text_props = odf_context()->styles_context()->last_state(odf_types::style_family::Paragraph)->get_text_properties();
|
||||
if (text_props && text_props->content_.fo_font_size_)
|
||||
{
|
||||
size_pt = text_props->content_.fo_font_size_->get_length().get_value_unit(odf_types::length::pt);
|
||||
}
|
||||
if (size_pt < 0.001)
|
||||
{
|
||||
odf_writer::odf_style_state_ptr style_state;
|
||||
odf_context()->styles_context()->find_odf_default_style_state(odf_types::style_family::Text, style_state);
|
||||
if (style_state)
|
||||
text_props = style_state->get_text_properties();
|
||||
|
||||
if (text_props && text_props->content_.fo_font_size_)
|
||||
{
|
||||
size_pt = text_props->content_.fo_font_size_->get_length().get_value_unit(odf_types::length::pt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (oox_para_props->buSize.is<PPTX::Logic::BuSzTx>())
|
||||
{
|
||||
//equal tet size
|
||||
}
|
||||
|
||||
if (oox_para_props->buSize.is<PPTX::Logic::BuSzPct>())
|
||||
{
|
||||
const PPTX::Logic::BuSzPct & buSzPct = oox_para_props->buSize.as<PPTX::Logic::BuSzPct>();
|
||||
if (buSzPct.val.IsInit())
|
||||
{
|
||||
if (text_properties)
|
||||
text_properties->content_.fo_font_size_ = odf_types::percent(*buSzPct.val / 1000.);
|
||||
|
||||
size_pt *= *buSzPct.val / 100000.;
|
||||
}
|
||||
}
|
||||
if (text_properties && !text_properties->content_.fo_font_size_)
|
||||
text_properties->content_.fo_font_size_ = odf_types::percent(100.);
|
||||
else if (odf_list_type == 1000)
|
||||
{
|
||||
odf_context()->styles_context()->lists_styles().set_bullet_image_size(size_pt);
|
||||
}
|
||||
}
|
||||
//----------------
|
||||
if (oox_para_props->buTypeface.is<PPTX::Logic::BuFontTx>())
|
||||
{
|
||||
const PPTX::Logic::BuFontTx & buFontTx = oox_para_props->buTypeface.as<PPTX::Logic::BuFontTx>();
|
||||
}
|
||||
if (oox_para_props->buTypeface.is<PPTX::Logic::TextFont>())
|
||||
{
|
||||
const PPTX::Logic::TextFont & textFont = oox_para_props->buTypeface.as<PPTX::Logic::TextFont>();
|
||||
|
||||
std::wstring font = textFont.typeface;
|
||||
convert_font(theme, font);
|
||||
if (!font.empty() && text_properties)
|
||||
text_properties->content_.fo_font_family_ = font;
|
||||
}
|
||||
|
||||
odf_context()->styles_context()->lists_styles().end_style_level();
|
||||
}
|
||||
|
||||
void OoxConverter::convert(PPTX::Logic::Paragraph *oox_paragraph, PPTX::Logic::TextListStyle *oox_list_style)
|
||||
{
|
||||
if (!oox_paragraph)return;
|
||||
|
||||
bool styled = false;
|
||||
|
||||
bool list_local = false;
|
||||
bool list_present = false;
|
||||
std::wstring list_style_name;
|
||||
|
||||
int list_level = 0;
|
||||
int list_level = 0;//-1;
|
||||
|
||||
NSCommon::nullable<PPTX::Logic::TextParagraphPr> paraPr;
|
||||
|
||||
if (oox_paragraph->pPr.IsInit() || oox_list_style)
|
||||
if (oox_paragraph->pPr.IsInit())
|
||||
{
|
||||
if (oox_paragraph->pPr.IsInit())
|
||||
{
|
||||
if (oox_paragraph->pPr->ParagraphBullet.is_init())
|
||||
{
|
||||
list_present = true;
|
||||
list_level = 1;
|
||||
}
|
||||
if (oox_paragraph->pPr->lvl.IsInit())
|
||||
{
|
||||
list_level = *oox_paragraph->pPr->lvl;
|
||||
if (list_level > 0)
|
||||
list_present = true;
|
||||
}
|
||||
}
|
||||
if (oox_paragraph->pPr->lvl.IsInit())
|
||||
list_level = *oox_paragraph->pPr->lvl;
|
||||
if (oox_paragraph->pPr->ParagraphBullet.is_init())
|
||||
list_local = true;
|
||||
}
|
||||
|
||||
//свойства могут быть приписаны не только к параграфу, но и к самому объекту
|
||||
if (oox_list_style)
|
||||
{
|
||||
int i = (list_level >= 0 && list_level < 10) ? list_level : 0;
|
||||
|
||||
if (oox_list_style->levels[i].IsInit())
|
||||
oox_list_style->levels[i]->Merge(paraPr);
|
||||
}
|
||||
if (oox_paragraph->pPr.IsInit())
|
||||
oox_paragraph->pPr->Merge(paraPr);
|
||||
|
||||
if (paraPr.IsInit())
|
||||
{
|
||||
list_level = paraPr->lvl.IsInit() ? *paraPr->lvl : 0;
|
||||
|
||||
if (list_level > 0) list_present = true;
|
||||
if (paraPr->ParagraphBullet.is_init())
|
||||
{
|
||||
list_present = true;
|
||||
if (paraPr->ParagraphBullet.is<PPTX::Logic::BuNone>())
|
||||
list_present = false;
|
||||
}
|
||||
//свойства могут быть приписаны не только к параграфу, но и к самому объекту
|
||||
odf_writer::style_paragraph_properties* paragraph_properties = odf_context()->text_context()->get_paragraph_properties();
|
||||
odf_writer::style_text_properties* text_properties = NULL;
|
||||
|
||||
if (!paragraph_properties)
|
||||
{
|
||||
odf_context()->text_context()->get_styles_context()->create_style(L"", odf_types::style_family::Paragraph, true, false, -1);
|
||||
@ -1144,61 +1350,78 @@ void OoxConverter::convert(PPTX::Logic::Paragraph *oox_paragraph, PPTX::Logic::T
|
||||
paragraph_properties = odf_context()->text_context()->get_styles_context()->last_state()->get_paragraph_properties();
|
||||
text_properties = odf_context()->text_context()->get_styles_context()->last_state()->get_text_properties();
|
||||
|
||||
//if(list_present && oox_list_style)
|
||||
//{
|
||||
// list_style_name = odf_context->styles_context()->lists_styles().get_style_name(list_style_id);
|
||||
// odf_context->styles_context()->last_state()->set_list_style_name(list_style_name);
|
||||
//}
|
||||
styled = true;
|
||||
}
|
||||
convert(oox_list_style, list_level, paragraph_properties, text_properties);
|
||||
convert(oox_paragraph->pPr.GetPointer(), paragraph_properties, text_properties);
|
||||
convert(paraPr.GetPointer(), paragraph_properties, text_properties);
|
||||
|
||||
if (odf_context()->drawing_context()->is_wordart())
|
||||
odf_context()->drawing_context()->set_paragraph_properties(paragraph_properties);
|
||||
}
|
||||
}
|
||||
//list_level++;
|
||||
|
||||
if (oox_paragraph->RunElems.empty() && list_present) list_present = false; // ms не обозначает присутствие списка, libra - показывает значек
|
||||
|
||||
while (odf_context()->text_context()->list_state_.levels.size() > list_level)
|
||||
{
|
||||
odf_context()->text_context()->end_list();
|
||||
}
|
||||
|
||||
if(list_present)
|
||||
{
|
||||
while (odf_context()->text_context()->list_state_.levels.size() > list_level)
|
||||
{
|
||||
odf_context()->text_context()->end_list();
|
||||
}
|
||||
|
||||
if (odf_context()->text_context()->list_state_.levels.size() < 1)
|
||||
if (odf_context()->text_context()->list_state_.levels.empty())
|
||||
{
|
||||
odf_context()->text_context()->list_state_.started_list = false;
|
||||
odf_context()->text_context()->list_state_.style_name = L"";
|
||||
odf_context()->text_context()->list_state_.style_name = L"";
|
||||
}
|
||||
|
||||
if (odf_context()->text_context()->list_state_.started_list == false)
|
||||
{
|
||||
odf_context()->text_context()->start_list(list_style_name);
|
||||
//text_context()->set_list_continue(true); //??? держать в памяти все списки????
|
||||
if (list_local)
|
||||
{
|
||||
_CP_OPT(bool) inStyles = odf_context()->drawing_context()->get_presentation();
|
||||
|
||||
odf_context()->styles_context()->lists_styles().start_style(inStyles && *inStyles);
|
||||
convert_list_level(oox_paragraph->pPr.GetPointer(), list_level /*- 1*/);
|
||||
odf_context()->styles_context()->lists_styles().end_style();
|
||||
|
||||
}
|
||||
list_style_name = odf_context()->styles_context()->lists_styles().get_style_name(); //last added
|
||||
|
||||
//odf_context()->text_context()->start_list(list_style_name);
|
||||
}
|
||||
odf_context()->text_context()->start_list_item();
|
||||
|
||||
if (odf_context()->text_context()->list_state_.style_name == list_style_name)
|
||||
list_style_name = L"";
|
||||
list_level++;
|
||||
|
||||
while (odf_context()->text_context()->list_state_.levels.size() < list_level)
|
||||
if (odf_context()->text_context()->list_state_.levels.size() < list_level)
|
||||
{
|
||||
odf_context()->text_context()->start_list(list_style_name);
|
||||
odf_context()->text_context()->start_list_item();
|
||||
while (odf_context()->text_context()->list_state_.levels.size() < list_level)
|
||||
{
|
||||
odf_context()->text_context()->start_list(list_style_name);
|
||||
odf_context()->text_context()->start_list_item();
|
||||
|
||||
if (odf_context()->text_context()->list_state_.style_name == list_style_name)
|
||||
list_style_name = L"";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
odf_context()->text_context()->start_list_item();
|
||||
}
|
||||
else if (odf_context()->text_context()->list_state_.started_list == true)
|
||||
{
|
||||
odf_context()->text_context()->end_list();
|
||||
}
|
||||
odf_context()->text_context()->start_paragraph(styled);
|
||||
|
||||
for (size_t i=0; i< oox_paragraph->RunElems.size();i++)
|
||||
for (size_t i=0; i< oox_paragraph->RunElems.size(); i++)
|
||||
{
|
||||
convert(&oox_paragraph->RunElems[i].as<OOX::WritingElement>());
|
||||
}
|
||||
odf_context()->text_context()->end_paragraph();
|
||||
|
||||
if(list_present)
|
||||
{
|
||||
odf_context()->text_context()->end_list_item();
|
||||
}
|
||||
//if(list_present)
|
||||
//{
|
||||
// odf_context()->text_context()->end_list_item();
|
||||
//}
|
||||
}
|
||||
void OoxConverter::convert(PPTX::Logic::TextListStyle *oox_list_style, int level, odf_writer::style_paragraph_properties * paragraph_properties
|
||||
, odf_writer::style_text_properties * text_properties)
|
||||
@ -1536,7 +1759,20 @@ void OoxConverter::convert(PPTX::Logic::MoveTo *oox_geom_path)
|
||||
|
||||
odf_context()->drawing_context()->add_path_element(std::wstring(L"M"), path_elm);
|
||||
}
|
||||
void OoxConverter::convert(PPTX::Logic::TextListStyle *oox_list_style)
|
||||
{
|
||||
if (!oox_list_style) return;
|
||||
if (oox_list_style->IsListStyleEmpty()) return;
|
||||
|
||||
_CP_OPT(bool) inStyles = odf_context()->drawing_context()->get_presentation();
|
||||
|
||||
odf_context()->styles_context()->lists_styles().start_style(inStyles && *inStyles);
|
||||
for (int i = 0; i < 9; i++)
|
||||
{
|
||||
OoxConverter::convert_list_level(oox_list_style->levels[i].GetPointer(), i);
|
||||
}
|
||||
odf_context()->styles_context()->lists_styles().end_style();
|
||||
}
|
||||
void OoxConverter::convert(PPTX::Logic::TxBody *oox_txBody, PPTX::Logic::ShapeStyle* oox_style)
|
||||
{
|
||||
if (!oox_txBody) return;
|
||||
@ -1544,6 +1780,8 @@ void OoxConverter::convert(PPTX::Logic::TxBody *oox_txBody, PPTX::Logic::ShapeSt
|
||||
|
||||
odf_context()->start_text_context();
|
||||
|
||||
convert(oox_txBody->lstStyle.GetPointer());
|
||||
|
||||
for (size_t i = 0; i < oox_txBody->Paragrs.size(); i++)
|
||||
{
|
||||
convert(&oox_txBody->Paragrs[i], oox_txBody->lstStyle.GetPointer());
|
||||
|
||||
@ -263,6 +263,7 @@ namespace PPTX
|
||||
class Theme;
|
||||
namespace Logic
|
||||
{
|
||||
class Bullet;
|
||||
class ClrMap;
|
||||
class SpTreeElem;
|
||||
class GraphicFrame;
|
||||
@ -403,7 +404,10 @@ public:
|
||||
void convert(PPTX::Logic::NvCxnSpPr *oox_nvSpPr);
|
||||
void convert(PPTX::Logic::NvGrpSpPr *oox_nvSpPr);
|
||||
void convert(PPTX::Logic::NvPr *oox_nvPr);
|
||||
void convert(PPTX::Logic::Paragraph *oox_para, PPTX::Logic::TextListStyle *oox_list_style = NULL);
|
||||
void convert(PPTX::Logic::Paragraph *oox_para, PPTX::Logic::TextListStyle *oox_list_style = NULL);
|
||||
void convert(PPTX::Logic::TextListStyle *oox_list_style);
|
||||
|
||||
void convert_list_level (PPTX::Logic::TextParagraphPr *oox_para_props, int level);
|
||||
|
||||
void convert(PPTX::Logic::TextListStyle *oox_list_style, int level, cpdoccore::odf_writer::style_paragraph_properties *paragraph_properties,
|
||||
cpdoccore::odf_writer::style_text_properties *text_properties);
|
||||
|
||||
@ -3017,7 +3017,7 @@ void DocxConverter::convert(OOX::Numbering::CAbstractNum* oox_num_style)
|
||||
if (oox_num_style->m_oAbstractNumId.IsInit() == false) return;
|
||||
|
||||
|
||||
odt_context->styles_context()->lists_styles().start_style(oox_num_style->m_oAbstractNumId->GetValue());
|
||||
odt_context->styles_context()->lists_styles().start_style(false, oox_num_style->m_oAbstractNumId->GetValue());
|
||||
//// Childs
|
||||
//std::vector<OOX::Numbering::CLvl > m_arrLvl;
|
||||
//nullable<ComplexTypes::Word::CMultiLevelType > m_oMultiLevelType;
|
||||
@ -3049,7 +3049,7 @@ void DocxConverter::convert(OOX::Numbering::CLvl* oox_num_lvl)
|
||||
int type_list = odt_context->styles_context()->lists_styles().start_style_level(oox_num_lvl->m_oIlvl->GetValue(), oox_type_list );
|
||||
if (type_list < 0) return;
|
||||
|
||||
odf_writer::style_list_level_properties * level_props = odt_context->styles_context()->lists_styles().get_list_level_properties();
|
||||
odf_writer::style_list_level_properties * level_props = odt_context->styles_context()->lists_styles().get_list_level_properties();
|
||||
odf_writer::style_list_level_label_alignment * aligment_props = odt_context->styles_context()->lists_styles().get_list_level_alignment_properties();
|
||||
|
||||
if (level_props == NULL)return;
|
||||
@ -3101,8 +3101,8 @@ void DocxConverter::convert(OOX::Numbering::CLvl* oox_num_lvl)
|
||||
}
|
||||
}else
|
||||
{
|
||||
aligment_props->fo_text_indent_ = odf_types::length(0,odf_types::length::cm);
|
||||
aligment_props->fo_margin_left_ = odf_types::length(0,odf_types::length::cm);
|
||||
aligment_props->fo_text_indent_ = odf_types::length(0, odf_types::length::cm);
|
||||
aligment_props->fo_margin_left_ = odf_types::length(0, odf_types::length::cm);
|
||||
|
||||
}
|
||||
}
|
||||
@ -3114,7 +3114,7 @@ void DocxConverter::convert(OOX::Numbering::CLvl* oox_num_lvl)
|
||||
convert(oox_num_lvl->m_oRPr.GetPointer(), text_props);
|
||||
|
||||
//create text style for symbols list НА ЛОКАЛЬНОМ контексте - иначе пересечение имен стилей (todoo вытащить генерацию имен в общую часть)
|
||||
styles_context->create_style(L"",odf_types::style_family::Text, false, true, -1);
|
||||
styles_context->create_style(L"", odf_types::style_family::Text, false, true, -1);
|
||||
odf_writer::odf_style_state_ptr style_state = styles_context->last_state(odf_types::style_family::Text);
|
||||
if (style_state)
|
||||
{
|
||||
@ -3184,7 +3184,9 @@ void DocxConverter::convert(OOX::Numbering::CLvl* oox_num_lvl)
|
||||
|
||||
}
|
||||
if (type_list == 2 || type_list == 3)
|
||||
{
|
||||
odt_context->styles_context()->lists_styles().set_bullet_image_size(size_bullet_number_marker);
|
||||
}
|
||||
|
||||
if (oox_num_lvl->m_oLvlRestart.IsInit() && oox_num_lvl->m_oLvlRestart->m_oVal.IsInit() && type_list == 1)
|
||||
{
|
||||
|
||||
@ -259,6 +259,8 @@ void PptxConverter::convert_styles()
|
||||
odp_context->page_layout_context()->create_layer_sets();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void PptxConverter::convert_settings()
|
||||
{
|
||||
|
||||
@ -341,6 +343,7 @@ void PptxConverter::convert_slides()
|
||||
current_clrMap = slide->Layout->clrMapOvr->overrideClrMapping.GetPointer();
|
||||
current_slide = slide->Layout.operator->();
|
||||
convert_slide(&slide->Layout->cSld, current_txStyles, true);
|
||||
//add note master
|
||||
odp_context->end_master_slide();
|
||||
|
||||
m_mapMasters.insert(std::make_pair(master_name, master_style_name));
|
||||
@ -379,7 +382,7 @@ void PptxConverter::convert_slides()
|
||||
odp_context->current_slide().set_master_page (master_style_name);
|
||||
odp_context->current_slide().set_layout_page (layout_style_name);
|
||||
|
||||
convert_slide (slide->cSld.GetPointer(), current_txStyles, true);
|
||||
convert_slide (slide->cSld.GetPointer(), current_txStyles);
|
||||
convert (slide->comments.operator->());
|
||||
convert (slide->Note.operator->());
|
||||
|
||||
@ -955,6 +958,14 @@ void PptxConverter::convert_slide(PPTX::Logic::CSld *oox_slide, PPTX::Logic::TxS
|
||||
if (pShape.IsInit() && pShape->nvSpPr.nvPr.ph.is_init())
|
||||
{
|
||||
pShape->FillLevelUp();
|
||||
|
||||
if (pShape->nvSpPr.nvPr.ph->type.IsInit())
|
||||
odf_context()->drawing_context()->set_placeholder_type(pShape->nvSpPr.nvPr.ph->type->GetBYTECode());
|
||||
else
|
||||
odf_context()->drawing_context()->set_placeholder_type(0);
|
||||
|
||||
if (pShape->nvSpPr.nvPr.ph->idx.IsInit())
|
||||
odf_context()->drawing_context()->set_placeholder_id(pShape->nvSpPr.nvPr.ph->idx.get());
|
||||
|
||||
if (!bPlaceholders)
|
||||
continue;
|
||||
@ -986,16 +997,16 @@ void PptxConverter::convert_slide(PPTX::Logic::CSld *oox_slide, PPTX::Logic::TxS
|
||||
}
|
||||
update_shape.txBody->lstStyle.reset(newListStyle);
|
||||
}
|
||||
|
||||
|
||||
pShape->Merge(update_shape);
|
||||
|
||||
OoxConverter::convert(&update_shape);
|
||||
|
||||
//OoxConverter::convert(pShape.operator->());
|
||||
}
|
||||
else
|
||||
{
|
||||
OoxConverter::convert(pElem.operator->());
|
||||
}
|
||||
//convert(oox_slide->spTree.SpTreeElems[i].GetElem().operator->());
|
||||
}
|
||||
convert(oox_slide->controls.GetPointer());
|
||||
}
|
||||
@ -1023,7 +1034,11 @@ void PptxConverter::convert_layout(PPTX::Logic::CSld *oox_slide)
|
||||
odf_context()->drawing_context()->start_drawing();
|
||||
odf_context()->drawing_context()->start_element(elm);
|
||||
|
||||
OoxConverter::convert(&pShape->nvSpPr.nvPr);
|
||||
odf_context()->drawing_context()->set_placeholder_type(type);
|
||||
|
||||
if (pShape->nvSpPr.nvPr.ph->idx.IsInit())
|
||||
odf_context()->drawing_context()->set_placeholder_id(*pShape->nvSpPr.nvPr.ph->idx);
|
||||
|
||||
OoxConverter::convert(pShape->spPr.xfrm.GetPointer());
|
||||
|
||||
odf_context()->drawing_context()->end_element();
|
||||
|
||||
@ -1748,236 +1748,6 @@ void XlsxConverter::convert(OOX::Spreadsheet::CFromTo* oox_from_to, oox_table_po
|
||||
if (oox_from_to->m_oColOff.IsInit()) pos->col_off = oox_from_to->m_oColOff->GetValue();//pt
|
||||
}
|
||||
|
||||
//void XlsxConverter::convert(OOX::Spreadsheet::CGroupShape* oox_group_shape)
|
||||
//{
|
||||
// if (!oox_group_shape)return;
|
||||
// if (oox_group_shape->m_arrItems.size() < 1) return;
|
||||
//
|
||||
// ods_context->drawing_context()->start_group();
|
||||
//
|
||||
// if (oox_group_shape->m_oNvGroupSpPr.IsInit())
|
||||
// {
|
||||
// if (oox_group_shape->m_oNvGroupSpPr->m_oCNvPr.IsInit())
|
||||
// {
|
||||
// if (oox_group_shape->m_oNvGroupSpPr->m_oCNvPr->m_sName.IsInit())
|
||||
// ods_context->drawing_context()->set_group_name(*oox_group_shape->m_oNvGroupSpPr->m_oCNvPr->m_sName);
|
||||
// if (oox_group_shape->m_oNvGroupSpPr->m_oCNvPr->m_oId.IsInit())
|
||||
// ods_context->drawing_context()->set_group_z_order(oox_group_shape->m_oNvGroupSpPr->m_oCNvPr->m_oId->GetValue());
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// OoxConverter::convert(oox_group_shape->m_oGroupSpPr.GetPointer());
|
||||
//
|
||||
// for (unsigned int i=0; i < oox_group_shape->m_arrItems.size(); i++)
|
||||
// {
|
||||
// switch(oox_group_shape->m_arrItems[i]->getType())
|
||||
// {
|
||||
// case OOX::et_x_Shape:
|
||||
// {
|
||||
// OOX::Spreadsheet::CShape* item = dynamic_cast<OOX::Spreadsheet::CShape*>(oox_group_shape->m_arrItems[i]);
|
||||
// convert(item);
|
||||
// }break;
|
||||
// case OOX::et_x_ConnShape:
|
||||
// {
|
||||
// OOX::Spreadsheet::CConnShape* item = dynamic_cast<OOX::Spreadsheet::CConnShape*>(oox_group_shape->m_arrItems[i]);
|
||||
// convert(item);
|
||||
// }break;
|
||||
// case OOX::et_x_GroupShape:
|
||||
// {
|
||||
// OOX::Spreadsheet::CGroupShape* item = dynamic_cast<OOX::Spreadsheet::CGroupShape*>(oox_group_shape->m_arrItems[i]);
|
||||
// convert(item);
|
||||
// }break;
|
||||
// case OOX::et_x_Pic:
|
||||
// {
|
||||
// OOX::Spreadsheet::CPic* item = dynamic_cast<OOX::Spreadsheet::CPic*>(oox_group_shape->m_arrItems[i]);
|
||||
// convert(item);
|
||||
// }break;
|
||||
// }
|
||||
// }
|
||||
// ods_context->drawing_context()->end_group();
|
||||
//}
|
||||
//
|
||||
//void XlsxConverter::convert(OOX::Spreadsheet::CShape* oox_shape)
|
||||
//{
|
||||
// if (!oox_shape)return;
|
||||
// if (!oox_shape->m_oSpPr.IsInit()) return;
|
||||
//
|
||||
// ods_context->drawing_context()->start_drawing();
|
||||
//
|
||||
// int type = -1;
|
||||
// if (oox_shape->m_oSpPr->m_oCustGeom.IsInit())
|
||||
// {
|
||||
// type = 1000;//6???
|
||||
// }
|
||||
// if (oox_shape->m_oSpPr->m_oPrstGeom.IsInit())
|
||||
// {
|
||||
// OOX::Drawing::CPresetGeometry2D * geometry = oox_shape->m_oSpPr->m_oPrstGeom.GetPointer();
|
||||
// type =(geometry->m_oPrst.GetValue());
|
||||
// }
|
||||
//
|
||||
// if ((oox_shape->m_oNvSpPr.IsInit()) && (oox_shape->m_oNvSpPr->m_oCNvSpPr.IsInit()))
|
||||
// {
|
||||
// if (oox_shape->m_oNvSpPr->m_oCNvSpPr->m_otxBox.GetValue() == 1)
|
||||
// type = 2000; //textBox
|
||||
// }
|
||||
//
|
||||
// if (type < 0)return;
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// if (type == 2000) ods_context->drawing_context()->start_text_box();
|
||||
// else ods_context->drawing_context()->start_shape(type);
|
||||
//
|
||||
// {
|
||||
// OoxConverter::convert(oox_shape->m_oSpPr.GetPointer(), oox_shape->m_oShapeStyle.GetPointer());
|
||||
//
|
||||
// if (oox_shape->m_oNvSpPr.IsInit())
|
||||
// {
|
||||
// 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())
|
||||
// {
|
||||
// ods_context->start_text_context();
|
||||
// OoxConverter::convert(oox_shape->m_oTxBody->m_oBodyPr.GetPointer());
|
||||
//
|
||||
// for (unsigned int i=0 ; i < oox_shape->m_oTxBody->m_arrItems.size();i++)
|
||||
// {
|
||||
// OoxConverter::convert(oox_shape->m_oTxBody->m_arrItems[i]);
|
||||
// }
|
||||
// ods_context->drawing_context()->set_text( ods_context->text_context());
|
||||
// ods_context->end_text_context();
|
||||
//
|
||||
// }
|
||||
// }
|
||||
// if (type == 2000)ods_context->drawing_context()->end_text_box();
|
||||
// else ods_context->drawing_context()->end_shape();
|
||||
//
|
||||
// ods_context->drawing_context()->end_drawing();
|
||||
//
|
||||
//}
|
||||
//
|
||||
//void XlsxConverter::convert(OOX::Spreadsheet::CConnShape* oox_shape)
|
||||
//{
|
||||
// if (!oox_shape)return;
|
||||
// if (!oox_shape->m_oSpPr.IsInit()) return;
|
||||
//
|
||||
// ods_context->drawing_context()->start_drawing();
|
||||
//
|
||||
// int type = -1;
|
||||
// if (oox_shape->m_oSpPr->m_eGeomType == OOX::Drawing::geomtypeCustom)
|
||||
// {
|
||||
// type = 1000;//?????
|
||||
// }
|
||||
// else if (oox_shape->m_oSpPr->m_eGeomType == OOX::Drawing::geomtypePreset)
|
||||
// {
|
||||
// if (oox_shape->m_oSpPr->m_oPrstGeom.IsInit())
|
||||
// {
|
||||
// OOX::Drawing::CPresetGeometry2D * geometry = oox_shape->m_oSpPr->m_oPrstGeom.GetPointer();
|
||||
// type = (int)(geometry->m_oPrst.GetValue());
|
||||
// }
|
||||
// }
|
||||
// if (type < 0)return;
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// ods_context->drawing_context()->start_shape(type);
|
||||
// {
|
||||
// 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();
|
||||
//
|
||||
// if (oox_shape->m_oNvConnSpPr.IsInit())
|
||||
// {
|
||||
// if (oox_shape->m_oNvConnSpPr->m_oCNvPr.IsInit())
|
||||
// {
|
||||
// OoxConverter::convert(oox_shape->m_oNvConnSpPr->m_oCNvPr.GetPointer());
|
||||
// }
|
||||
//
|
||||
// if (oox_shape->m_oNvConnSpPr->m_oCNvConnSpPr.IsInit())
|
||||
// {
|
||||
// }
|
||||
// }
|
||||
// //avLst
|
||||
// }
|
||||
// ods_context->drawing_context()->end_shape();
|
||||
// ods_context->drawing_context()->end_drawing();
|
||||
//}
|
||||
//
|
||||
//
|
||||
//void XlsxConverter::convert(OOX::Spreadsheet::CPic* oox_picture)
|
||||
//{
|
||||
// if (!oox_picture)return;
|
||||
// if (!oox_picture->m_oBlipFill.IsInit()) return; // невeрная структура оох
|
||||
//
|
||||
// ods_context->drawing_context()->start_drawing();
|
||||
//
|
||||
// std::wstring pathImage;
|
||||
// double Width=0, Height = 0;
|
||||
//
|
||||
// if (oox_picture->m_oBlipFill->m_oBlip.IsInit())
|
||||
// {
|
||||
// std::wstring sID = oox_picture->m_oBlipFill->m_oBlip->m_oEmbed.GetValue();
|
||||
// pathImage = find_link_by_id(sID,1);
|
||||
//
|
||||
// if (pathImage.empty())
|
||||
// {
|
||||
// sID = oox_picture->m_oBlipFill->m_oBlip->m_oLink.GetValue();
|
||||
// //???
|
||||
// }
|
||||
// _graphics_utils_::GetResolution(pathImage.c_str(), Width, Height);
|
||||
// }
|
||||
// ods_context->start_image(pathImage);
|
||||
// {
|
||||
// if (oox_picture->m_oBlipFill->m_oTile.IsInit())
|
||||
// {
|
||||
// ods_context->drawing_context()->set_image_style_repeat(2);
|
||||
// }
|
||||
// if (oox_picture->m_oBlipFill->m_oStretch.IsInit())
|
||||
// {
|
||||
// ods_context->drawing_context()->set_image_style_repeat(1);
|
||||
// }
|
||||
// if (oox_picture->m_oBlipFill->m_oSrcRect.IsInit() && Width >0 && Height >0)
|
||||
// {
|
||||
// ods_context->drawing_context()->set_image_client_rect_inch(
|
||||
// oox_picture->m_oBlipFill->m_oSrcRect->m_oL.GetValue()/100. * Width / currentSystemDPI ,
|
||||
// oox_picture->m_oBlipFill->m_oSrcRect->m_oT.GetValue()/100. * Height / currentSystemDPI ,
|
||||
// oox_picture->m_oBlipFill->m_oSrcRect->m_oR.GetValue()/100. * Width / currentSystemDPI ,
|
||||
// oox_picture->m_oBlipFill->m_oSrcRect->m_oB.GetValue()/100. * Height / currentSystemDPI );
|
||||
// }
|
||||
// if (oox_picture->m_oNvPicPr.IsInit())
|
||||
// {
|
||||
// OoxConverter::convert(oox_picture->m_oNvPicPr->m_oCNvPr.GetPointer());
|
||||
//
|
||||
// if (oox_picture->m_oNvPicPr->m_oCNvPicPr.IsInit())
|
||||
// {
|
||||
// if (oox_picture->m_oNvPicPr->m_oCNvPicPr->m_oPicLocks.IsInit())
|
||||
// {
|
||||
// //if (oox_picture->m_oNvPicPr->m_oCNvPicPr->m_oPicLocks->m_oNoChangeAspect)
|
||||
// //{
|
||||
// //}
|
||||
// //if (oox_picture->m_oNvPicPr->m_oCNvPicPr->m_oPicLocks->m_oNoCrop))
|
||||
// //{
|
||||
// //}
|
||||
// //if (oox_picture->m_oNvPicPr->m_oCNvPicPr->m_oPicLocks->m_oNoResize)
|
||||
// //{
|
||||
// //}
|
||||
// }
|
||||
// //m_oExtLst
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// OoxConverter::convert(oox_picture->m_oSpPr.GetPointer(), oox_picture->m_oShapeStyle.GetPointer());
|
||||
//
|
||||
// }
|
||||
// ods_context->drawing_context()->end_image();
|
||||
// ods_context->drawing_context()->end_drawing();
|
||||
//}
|
||||
//
|
||||
void XlsxConverter::convert(OOX::Spreadsheet::CConditionalFormatting *oox_cond_fmt)
|
||||
{
|
||||
if (!oox_cond_fmt)return;
|
||||
|
||||
@ -437,7 +437,6 @@ namespace PPTX
|
||||
pWriter->EndRecord();
|
||||
}
|
||||
|
||||
|
||||
void Shape::FillLevelUp()
|
||||
{
|
||||
if ((m_pLevelUp == NULL) && (nvSpPr.nvPr.ph.IsInit()))
|
||||
@ -452,6 +451,16 @@ namespace PPTX
|
||||
}
|
||||
}
|
||||
|
||||
bool Shape::IsListStyleEmpty()
|
||||
{
|
||||
if ((m_pLevelUp) && (m_pLevelUp->IsListStyleEmpty() == false)) return false;
|
||||
|
||||
if (txBody.IsInit() == false) return true;
|
||||
if (txBody->lstStyle.IsInit() == false) return true;
|
||||
|
||||
return txBody->lstStyle->IsListStyleEmpty();
|
||||
}
|
||||
|
||||
void Shape::Merge(Shape& shape, bool bIsSlidePlaceholder)
|
||||
{
|
||||
if (m_pLevelUp)
|
||||
|
||||
@ -303,6 +303,7 @@ namespace PPTX
|
||||
|
||||
void FillLevelUp();
|
||||
void Merge(Shape& shape, bool bIsSlidePlaceholder = false);
|
||||
bool IsListStyleEmpty();
|
||||
|
||||
void SetLevelUpElement( Shape* p){m_pLevelUp = p;};
|
||||
|
||||
|
||||
@ -171,6 +171,20 @@ namespace PPTX
|
||||
|
||||
pReader->Seek(_end_rec);
|
||||
}
|
||||
bool IsListStyleEmpty()
|
||||
{
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
if (levels[i].IsInit())
|
||||
{
|
||||
if (levels[i]->ParagraphBullet.is_init() == false) continue;
|
||||
if (levels[i]->ParagraphBullet.is<PPTX::Logic::BuNone>())continue;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void Merge(nullable<TextListStyle>& lstStyle)const
|
||||
{
|
||||
|
||||
427
DesktopEditor/common/BigInteger.h
Normal file
427
DesktopEditor/common/BigInteger.h
Normal file
@ -0,0 +1,427 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2017
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
|
||||
* EU, LV-1021.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
#ifndef _BUILD_BIGINTEGER_CROSSPLATFORM_H_
|
||||
#define _BUILD_BIGINTEGER_CROSSPLATFORM_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
class CBigInteger
|
||||
{
|
||||
protected:
|
||||
std::string m_value;
|
||||
bool m_isNegative;
|
||||
|
||||
public:
|
||||
|
||||
CBigInteger()
|
||||
{
|
||||
m_value = "0";
|
||||
m_isNegative = false;
|
||||
}
|
||||
|
||||
CBigInteger(unsigned char* data, int size)
|
||||
{
|
||||
m_isNegative = false;
|
||||
m_value = "0";
|
||||
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
CBigInteger tmp((int)data[i]);
|
||||
|
||||
for (int j = size - 1 - i; j > 0; --j)
|
||||
tmp *= 256;
|
||||
|
||||
*this += tmp;
|
||||
}
|
||||
}
|
||||
|
||||
CBigInteger(std::string data, int nBase = 10)
|
||||
{
|
||||
m_isNegative = false;
|
||||
|
||||
if (10 == nBase)
|
||||
{
|
||||
m_value = data;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_value = "0";
|
||||
int len = (int)data.length();
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
int val = 0;
|
||||
char _c = data[i];
|
||||
if (_c >= '0' && _c <= '9')
|
||||
val = _c - '0';
|
||||
else if (_c >= 'A' && _c <= 'F')
|
||||
val = 10 + _c - 'A';
|
||||
else if (_c >= 'a' && _c <= 'f')
|
||||
val = 10 + _c - 'a';
|
||||
|
||||
CBigInteger tmp(val);
|
||||
for (int j = len - 1 - i; j > 0; --j)
|
||||
tmp *= nBase;
|
||||
|
||||
*this += tmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CBigInteger(int value)
|
||||
{
|
||||
if (value < 0)
|
||||
{
|
||||
m_isNegative = true;
|
||||
m_value = std::to_string(-value);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_isNegative = false;
|
||||
m_value = std::to_string(value);
|
||||
}
|
||||
}
|
||||
|
||||
std::string GetValue()
|
||||
{
|
||||
return m_value;
|
||||
}
|
||||
bool IsNegative()
|
||||
{
|
||||
return m_isNegative;
|
||||
}
|
||||
|
||||
void operator = (CBigInteger b)
|
||||
{
|
||||
m_value = b.m_value;
|
||||
m_isNegative = b.m_isNegative;
|
||||
}
|
||||
|
||||
bool operator == (CBigInteger b)
|
||||
{
|
||||
return equals((*this) , b);
|
||||
}
|
||||
|
||||
bool operator != (CBigInteger b)
|
||||
{
|
||||
return !equals((*this) , b);
|
||||
}
|
||||
|
||||
bool operator > (CBigInteger b)
|
||||
{
|
||||
return greater((*this) , b);
|
||||
}
|
||||
|
||||
bool operator < (CBigInteger b)
|
||||
{
|
||||
return less((*this) , b);
|
||||
}
|
||||
|
||||
bool operator >= (CBigInteger b)
|
||||
{
|
||||
return equals((*this) , b) || greater((*this), b);
|
||||
}
|
||||
|
||||
bool operator <= (CBigInteger b)
|
||||
{
|
||||
return equals((*this) , b) || less((*this) , b);
|
||||
}
|
||||
|
||||
CBigInteger absolute()
|
||||
{
|
||||
return CBigInteger(m_value); // +ve by default
|
||||
}
|
||||
|
||||
CBigInteger& operator ++()
|
||||
{
|
||||
// prefix
|
||||
(*this) = (*this) + 1;
|
||||
return (*this);
|
||||
}
|
||||
|
||||
CBigInteger operator ++(int)
|
||||
{
|
||||
// postfix
|
||||
CBigInteger before = (*this);
|
||||
(*this) = (*this) + 1;
|
||||
return before;
|
||||
}
|
||||
|
||||
CBigInteger& operator --()
|
||||
{
|
||||
// prefix
|
||||
(*this) = (*this) - 1;
|
||||
return (*this);
|
||||
}
|
||||
|
||||
CBigInteger operator --(int)
|
||||
{
|
||||
// postfix
|
||||
CBigInteger before = (*this);
|
||||
(*this) = (*this) - 1;
|
||||
return before;
|
||||
}
|
||||
|
||||
CBigInteger operator + (CBigInteger b)
|
||||
{
|
||||
CBigInteger addition;
|
||||
if (m_isNegative == b.m_isNegative)
|
||||
{
|
||||
// both +ve or -ve
|
||||
addition.m_value = (add(m_value, b.m_value));
|
||||
addition.m_isNegative = m_isNegative;
|
||||
}
|
||||
else
|
||||
{
|
||||
// sign different
|
||||
if (absolute() > b.absolute())
|
||||
{
|
||||
addition.m_value = subtract(m_value, b.m_value);
|
||||
addition.m_isNegative = m_isNegative;
|
||||
}
|
||||
else
|
||||
{
|
||||
addition.m_value = subtract(b.m_value, m_value);
|
||||
addition.m_isNegative = b.m_isNegative;
|
||||
}
|
||||
}
|
||||
|
||||
if (addition.m_value == "0") // avoid (-0) problem
|
||||
addition.m_isNegative = false;
|
||||
|
||||
return addition;
|
||||
}
|
||||
|
||||
CBigInteger operator - (CBigInteger b)
|
||||
{
|
||||
b.m_isNegative = !b.m_isNegative; // x - y = x + (-y)
|
||||
return (*this) + b;
|
||||
}
|
||||
|
||||
CBigInteger operator * (CBigInteger b)
|
||||
{
|
||||
CBigInteger mul;
|
||||
|
||||
mul.m_value = multiply(m_value, b.m_value);
|
||||
mul.m_isNegative = (m_isNegative != b.m_isNegative);
|
||||
|
||||
if (mul.m_value == "0") // avoid (-0) problem
|
||||
mul.m_isNegative = false;
|
||||
|
||||
return mul;
|
||||
}
|
||||
|
||||
CBigInteger& operator += (CBigInteger b)
|
||||
{
|
||||
(*this) = (*this) + b;
|
||||
return (*this);
|
||||
}
|
||||
|
||||
CBigInteger& operator -= (CBigInteger b)
|
||||
{
|
||||
(*this) = (*this) - b;
|
||||
return (*this);
|
||||
}
|
||||
|
||||
CBigInteger& operator *= (CBigInteger b)
|
||||
{
|
||||
(*this) = (*this) * b;
|
||||
return (*this);
|
||||
}
|
||||
|
||||
CBigInteger operator -() { // unary minus sign
|
||||
return (*this) * -1;
|
||||
}
|
||||
|
||||
std::string ToString()
|
||||
{
|
||||
// for conversion from BigInteger to string
|
||||
std::string signedString = ( m_isNegative ) ? "-" : ""; // if +ve, don't print + sign
|
||||
signedString += m_value;
|
||||
return signedString;
|
||||
}
|
||||
|
||||
private:
|
||||
bool equals(CBigInteger n1, CBigInteger n2)
|
||||
{
|
||||
return ((n1.m_value == n2.m_value) && (n1.m_isNegative == n2.m_isNegative));
|
||||
}
|
||||
|
||||
bool less(CBigInteger n1, CBigInteger n2)
|
||||
{
|
||||
bool sign1 = n1.m_isNegative;
|
||||
bool sign2 = n2.m_isNegative;
|
||||
|
||||
if (sign1 && !sign2)
|
||||
return true;
|
||||
else if (!sign1 && sign2)
|
||||
return false;
|
||||
else if (!sign1)
|
||||
{
|
||||
std::string::size_type _size1 = n1.m_value.length();
|
||||
std::string::size_type _size2 = n2.m_value.length();
|
||||
if (_size1 < _size2)
|
||||
return true;
|
||||
if (_size1 > _size2)
|
||||
return false;
|
||||
return n1.m_value < n2.m_value;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string::size_type _size1 = n1.m_value.length();
|
||||
std::string::size_type _size2 = n2.m_value.length();
|
||||
|
||||
if (_size1 > _size2)
|
||||
return true;
|
||||
if (_size1 < _size2)
|
||||
return false;
|
||||
return n1.m_value.compare(n2.m_value) > 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool greater(CBigInteger n1, CBigInteger n2)
|
||||
{
|
||||
return !equals(n1, n2) && !less(n1, n2);
|
||||
}
|
||||
|
||||
std::string add(std::string number1, std::string number2)
|
||||
{
|
||||
std::string add = (number1.length() > number2.length()) ? number1 : number2;
|
||||
char carry = '0';
|
||||
int differenceInLength = (int)(number1.size() - number2.size());
|
||||
|
||||
if (differenceInLength > 0)
|
||||
number2.insert(0, differenceInLength, '0');
|
||||
else
|
||||
number1.insert(0, -differenceInLength, '0');
|
||||
|
||||
if (differenceInLength < 0)
|
||||
differenceInLength = -differenceInLength;
|
||||
|
||||
for (int i = number1.size() - 1; i >= 0; --i)
|
||||
{
|
||||
add[i] = ((carry-'0')+(number1[i]-'0')+(number2[i]-'0')) + '0';
|
||||
|
||||
if(i != 0)
|
||||
{
|
||||
if(add[i] > '9')
|
||||
{
|
||||
add[i] -= 10;
|
||||
carry = '1';
|
||||
}
|
||||
else
|
||||
{
|
||||
carry = '0';
|
||||
}
|
||||
}
|
||||
}
|
||||
if (add[0] > '9')
|
||||
{
|
||||
add[0] -= 10;
|
||||
add.insert(0, 1, '1');
|
||||
}
|
||||
return add;
|
||||
}
|
||||
|
||||
std::string subtract(std::string number1, std::string number2)
|
||||
{
|
||||
std::string sub = (number1.length() > number2.length()) ? number1 : number2;
|
||||
int differenceInLength = (int)(number1.size() - number2.size());
|
||||
|
||||
if (differenceInLength > 0)
|
||||
number2.insert(0, differenceInLength, '0');
|
||||
else
|
||||
number1.insert(0, -differenceInLength, '0');
|
||||
|
||||
if (differenceInLength < 0)
|
||||
differenceInLength = -differenceInLength;
|
||||
|
||||
for (int i = number1.length() - 1; i >= 0; --i)
|
||||
{
|
||||
if (number1[i] < number2[i])
|
||||
{
|
||||
number1[i] += 10;
|
||||
number1[i-1]--;
|
||||
}
|
||||
sub[i] = ((number1[i]-'0')-(number2[i]-'0')) + '0';
|
||||
}
|
||||
|
||||
while (sub[0]=='0' && sub.length() != 1) // erase leading zeros
|
||||
sub.erase(0, 1);
|
||||
|
||||
return sub;
|
||||
}
|
||||
|
||||
std::string multiply(std::string n1, std::string n2)
|
||||
{
|
||||
if (n1.length() > n2.length())
|
||||
n1.swap(n2);
|
||||
|
||||
std::string res = "0";
|
||||
for (int i = n1.length() - 1; i >= 0; --i)
|
||||
{
|
||||
std::string temp = n2;
|
||||
int currentDigit = n1[i] - '0';
|
||||
int carry = 0;
|
||||
|
||||
for (int j = temp.length() - 1; j >= 0; --j)
|
||||
{
|
||||
temp[j] = ((temp[j]-'0') * currentDigit) + carry;
|
||||
|
||||
if (temp[j] > 9)
|
||||
{
|
||||
carry = (temp[j] / 10);
|
||||
temp[j] -= (carry * 10);
|
||||
}
|
||||
else
|
||||
{
|
||||
carry = 0;
|
||||
}
|
||||
|
||||
temp[j] += '0'; // back to string mood
|
||||
}
|
||||
|
||||
if (carry > 0)
|
||||
temp.insert(0, 1, (carry+'0'));
|
||||
|
||||
temp.append((n1.length() - i - 1), '0'); // as like mult by 10, 100, 1000, 10000 and so on
|
||||
|
||||
res = add(res, temp); // O(n)
|
||||
}
|
||||
|
||||
while (res[0] == '0' && res.length() != 1) // erase leading zeros
|
||||
res.erase(0,1);
|
||||
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
#endif //_BUILD_BIGINTEGER_CROSSPLATFORM_H_
|
||||
@ -0,0 +1,22 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 14
|
||||
VisualStudioVersion = 14.0.25420.1
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sha1_C14N", "ConsoleApplication1\Sha1_C14N.csproj", "{A945E071-111A-41E0-8BB0-4F7755EBB77B}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{A945E071-111A-41E0-8BB0-4F7755EBB77B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{A945E071-111A-41E0-8BB0-4F7755EBB77B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{A945E071-111A-41E0-8BB0-4F7755EBB77B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A945E071-111A-41E0-8BB0-4F7755EBB77B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
|
||||
</startup>
|
||||
</configuration>
|
||||
@ -0,0 +1,77 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using System.Xml;
|
||||
using System.Security;
|
||||
using System.Security.Cryptography;
|
||||
using System.Security.Cryptography.Xml;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.IO;
|
||||
|
||||
namespace Sha1_C14N
|
||||
{
|
||||
class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
XmlDocument docStripped = new XmlDocument();
|
||||
//docStripped.Load(@"D:\GIT\core\DesktopEditor\xmlsec\test\windows_list_serts\Debug\debug\document.xml");
|
||||
docStripped.Load("D:\\444.txt");
|
||||
|
||||
XmlDsigC14NTransform t = new XmlDsigC14NTransform();
|
||||
t.LoadInput(docStripped);
|
||||
Stream s = (Stream)t.GetOutput(typeof(Stream));
|
||||
|
||||
BinaryReader br = new BinaryReader(s);
|
||||
byte[] b = br.ReadBytes((int)s.Length);
|
||||
|
||||
File.Delete("D:\\1.txt");
|
||||
var fileStream = File.Create("D:\\1.txt");
|
||||
s.Seek(0, SeekOrigin.Begin);
|
||||
s.CopyTo(fileStream);
|
||||
fileStream.Close();
|
||||
|
||||
s.Seek(0, SeekOrigin.Begin);
|
||||
|
||||
SHA1 sha1 = SHA1.Create();
|
||||
byte[] hash = sha1.ComputeHash(s);
|
||||
string base64String = Convert.ToBase64String(hash);
|
||||
|
||||
FileStream fRes = File.Create("D:\\res.bin");
|
||||
fRes.Write(hash, 0, hash.Length);
|
||||
fRes.Close();
|
||||
|
||||
SHA1 sha33 = SHA1.Create();
|
||||
byte[] hash33 = sha33.ComputeHash(b);
|
||||
string base64String2 = Convert.ToBase64String(hash33);
|
||||
|
||||
FileStream s1 = File.OpenRead(@"D:\GIT\core\DesktopEditor\xmlsec\test\windows_list_serts\Debug\debug\document2.xml");
|
||||
SHA1 sha11 = SHA1.Create();
|
||||
byte[] hash11 = sha11.ComputeHash(s1);
|
||||
string base64_11 = Convert.ToBase64String(hash11);
|
||||
|
||||
X509Store my = new X509Store(StoreName.My, StoreLocation.CurrentUser);
|
||||
my.Open(OpenFlags.ReadOnly);
|
||||
|
||||
// Find the certificate we’ll use to sign
|
||||
RSACryptoServiceProvider csp = null;
|
||||
foreach (X509Certificate2 cert in my.Certificates)
|
||||
{
|
||||
string sName = cert.Subject;
|
||||
if (cert.Subject.Contains("Oleg.Korshul"))
|
||||
{
|
||||
csp = (RSACryptoServiceProvider)cert.PrivateKey;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
byte[] signedData = csp.SignHash(hash11, CryptoConfig.MapNameToOID("SHA1"));
|
||||
string signedDataBase64 = Convert.ToBase64String(signedData);
|
||||
|
||||
Console.WriteLine(base64_11);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// Управление общими сведениями о сборке осуществляется с помощью
|
||||
// набора атрибутов. Измените значения этих атрибутов, чтобы изменить сведения,
|
||||
// связанные со сборкой.
|
||||
[assembly: AssemblyTitle("Sha1_C14N")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("Sha1_C14N")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2017")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Параметр ComVisible со значением FALSE делает типы в сборке невидимыми
|
||||
// для COM-компонентов. Если требуется обратиться к типу в этой сборке через
|
||||
// COM, задайте атрибуту ComVisible значение TRUE для этого типа.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// Следующий GUID служит для идентификации библиотеки типов, если этот проект будет видимым для COM
|
||||
[assembly: Guid("a945e071-111a-41e0-8bb0-4f7755ebb77b")]
|
||||
|
||||
// Сведения о версии сборки состоят из следующих четырех значений:
|
||||
//
|
||||
// Основной номер версии
|
||||
// Дополнительный номер версии
|
||||
// Номер сборки
|
||||
// Редакция
|
||||
//
|
||||
// Можно задать все значения или принять номера сборки и редакции по умолчанию
|
||||
// используя "*", как показано ниже:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
@ -0,0 +1,61 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{A945E071-111A-41E0-8BB0-4F7755EBB77B}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>ConsoleApplication1</RootNamespace>
|
||||
<AssemblyName>ConsoleApplication1</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Security" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
@ -7,6 +7,10 @@
|
||||
#include <string>
|
||||
|
||||
#include "../../../common/File.h"
|
||||
#include "../../../common/BigInteger.h"
|
||||
|
||||
#include "../../../xml/include/xmlutils.h"
|
||||
#include "../../../xml/libxml2/include/libxml/c14n.h"
|
||||
|
||||
#pragma comment (lib, "crypt32.lib")
|
||||
#pragma comment (lib, "cryptui.lib")
|
||||
@ -14,14 +18,79 @@
|
||||
|
||||
//#define ENUMS_CERTS
|
||||
|
||||
//////////////////////
|
||||
class CXmlBuffer
|
||||
{
|
||||
public:
|
||||
NSStringUtils::CStringBuilderA builder;
|
||||
|
||||
public:
|
||||
CXmlBuffer()
|
||||
{
|
||||
}
|
||||
~CXmlBuffer()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
static int xmlBufferIOWrite(CXmlBuffer* buf, const char* buffer, int len)
|
||||
{
|
||||
buf->builder.WriteString(buffer, (size_t)len);
|
||||
return len;
|
||||
}
|
||||
|
||||
static int xmlBufferIOClose(CXmlBuffer* buf)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int xmlC14NIsVisibleCallbackMy(void * user_data, xmlNodePtr node, xmlNodePtr parent)
|
||||
{
|
||||
if (node->type == XML_TEXT_NODE)
|
||||
{
|
||||
std::string sTmp((char*)node->content);
|
||||
if (std::string::npos != sTmp.find('\n') ||
|
||||
std::string::npos != sTmp.find('\r') ||
|
||||
std::string::npos != sTmp.find('\t'))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
//////////////////////
|
||||
|
||||
#define MY_ENCODING_TYPE (PKCS_7_ASN_ENCODING | X509_ASN_ENCODING)
|
||||
void MyHandleError(char *s);
|
||||
|
||||
bool Sign(HCERTSTORE hStoreHandle, PCCERT_CONTEXT pCertContext, std::wstring sFileXml, std::wstring sSignatureFile);
|
||||
bool Verify(HCERTSTORE hStoreHandle, PCCERT_CONTEXT pCertContext, std::wstring sFileXml, std::wstring sSignatureFile);
|
||||
bool Sign(PCCERT_CONTEXT pCertContext, std::wstring sFileXml, std::wstring sSignatureFile);
|
||||
bool Verify(PCCERT_CONTEXT pCertContext, std::wstring sFileXml, std::wstring sSignatureFile);
|
||||
|
||||
void ConvertEndian(const BYTE* src, BYTE* dst, DWORD size)
|
||||
{
|
||||
for(BYTE* p = dst + size - 1; p >= dst; ++src, --p)
|
||||
(*p) = (*src);
|
||||
}
|
||||
|
||||
void main(void)
|
||||
{
|
||||
if (false)
|
||||
{
|
||||
CBigInteger int1("345097");
|
||||
CBigInteger int2("87960324");
|
||||
|
||||
CBigInteger val1 = int1 + int2;
|
||||
CBigInteger val2 = int1 - int2;
|
||||
CBigInteger val3 = int1 * int2;
|
||||
|
||||
CBigInteger int3("66A1F302407647974D18D489855371B5", 16);
|
||||
|
||||
unsigned char buffer[16] = { 0x66, 0xA1, 0xF3, 0x02, 0x40, 0x76, 0x47, 0x97, 0x4D, 0x18, 0xD4, 0x89, 0x85, 0x53, 0x71, 0xB5 };
|
||||
CBigInteger val4(buffer, 16);
|
||||
|
||||
std::string sValue = int3.ToString();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Copyright (C) Microsoft. All rights reserved.
|
||||
@ -312,8 +381,8 @@ void main(void)
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
bool bRes = true;
|
||||
bRes = Sign(hCertStore, pCertContext, NSFile::GetProcessDirectory() + L"/document.xml", NSFile::GetProcessDirectory() + L"/result.txt");
|
||||
bRes = Verify(hCertStore, pCertContext, NSFile::GetProcessDirectory() + L"/document.xml", NSFile::GetProcessDirectory() + L"/result.txt");
|
||||
bRes = Sign(pCertContext, NSFile::GetProcessDirectory() + L"/test.xml", NSFile::GetProcessDirectory() + L"/result.txt");
|
||||
bRes = Verify(pCertContext, NSFile::GetProcessDirectory() + L"/test.xml", NSFile::GetProcessDirectory() + L"/result.txt");
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CertFreeCertificateContext(pCertContext);
|
||||
@ -330,7 +399,7 @@ void MyHandleError(LPTSTR psz)
|
||||
exit(1);
|
||||
} // End of MyHandleError.
|
||||
|
||||
bool Sign(HCERTSTORE hStoreHandle, PCCERT_CONTEXT pCertContext, std::wstring sFileXml, std::wstring sSignatureFile)
|
||||
bool Sign(PCCERT_CONTEXT pCertContext, std::wstring sFileXml, std::wstring sSignatureFile)
|
||||
{
|
||||
// Variables
|
||||
HCRYPTPROV hCryptProv = NULL;
|
||||
@ -342,8 +411,6 @@ bool Sign(HCERTSTORE hStoreHandle, PCCERT_CONTEXT pCertContext, std::wstring sFi
|
||||
DWORD dwSigLen = 0;
|
||||
BYTE* pbSignature = NULL;
|
||||
|
||||
// Open the certificate store.
|
||||
|
||||
bResult = CryptAcquireCertificatePrivateKey(pCertContext, 0, NULL, &hCryptProv, &dwKeySpec, NULL);
|
||||
|
||||
bool bIsResult = ((dwKeySpec & AT_SIGNATURE) == AT_SIGNATURE);
|
||||
@ -355,7 +422,42 @@ bool Sign(HCERTSTORE hStoreHandle, PCCERT_CONTEXT pCertContext, std::wstring sFi
|
||||
DWORD dwFileSrcLen = 0;
|
||||
NSFile::CFileBinary::ReadAllBytes(sFileXml, &pDataSrc, dwFileSrcLen);
|
||||
|
||||
bResult = CryptHashData(hHash, pDataSrc, dwFileSrcLen, 0);
|
||||
xmlDocPtr xmlDoc = xmlParseMemory((char*)pDataSrc, (int)dwFileSrcLen);
|
||||
|
||||
CXmlBuffer _bufferC14N;
|
||||
xmlOutputBufferPtr _buffer = xmlOutputBufferCreateIO((xmlOutputWriteCallback)xmlBufferIOWrite,
|
||||
(xmlOutputCloseCallback)xmlBufferIOClose,
|
||||
&_bufferC14N,
|
||||
NULL);
|
||||
|
||||
xmlC14NExecute(xmlDoc, xmlC14NIsVisibleCallbackMy, NULL, XML_C14N_1_0, NULL, 0, _buffer);
|
||||
|
||||
xmlOutputBufferClose(_buffer);
|
||||
|
||||
NSFile::CFileBinary oFileDump;
|
||||
oFileDump.CreateFileW(NSFile::GetProcessDirectory() + L"/123.txt");
|
||||
oFileDump.WriteFile((BYTE*)_bufferC14N.builder.GetBuffer(), (DWORD)_bufferC14N.builder.GetCurSize());
|
||||
oFileDump.CloseFile();
|
||||
|
||||
//bResult = CryptHashData(hHash, pDataSrc, dwFileSrcLen, 0);
|
||||
bResult = CryptHashData(hHash, (BYTE*)_bufferC14N.builder.GetBuffer(), (DWORD)_bufferC14N.builder.GetCurSize(), 0);
|
||||
|
||||
if (true)
|
||||
{
|
||||
DWORD cbHashSize = 0, dwCount = sizeof(DWORD);
|
||||
|
||||
BOOL b1 = CryptGetHashParam(hHash, HP_HASHSIZE, (BYTE*)&cbHashSize, &dwCount, 0);
|
||||
|
||||
BYTE* pDataHashRaw = new BYTE[dwCount];
|
||||
|
||||
BOOL b2 = CryptGetHashParam(hHash, HP_HASHVAL, pDataHashRaw, &cbHashSize, 0);
|
||||
|
||||
char* pBase64_hash = NULL;
|
||||
int nBase64Len_hash = 0;
|
||||
NSFile::CBase64Converter::Encode(pDataHashRaw, (int)cbHashSize, pBase64_hash, nBase64Len_hash, NSBase64::B64_BASE64_FLAG_NONE);
|
||||
|
||||
delete [] pBase64_hash;
|
||||
}
|
||||
|
||||
// Sign the hash object
|
||||
dwSigLen = 0;
|
||||
@ -364,18 +466,27 @@ bool Sign(HCERTSTORE hStoreHandle, PCCERT_CONTEXT pCertContext, std::wstring sFi
|
||||
pbSignature = new BYTE[dwSigLen];
|
||||
bResult = CryptSignHash(hHash, dwKeySpec, NULL, 0, pbSignature, &dwSigLen);
|
||||
|
||||
NSFile::CFileBinary oFileTmp;
|
||||
oFileTmp.CreateFileW(NSFile::GetProcessDirectory() + L"/HASH.bin");
|
||||
oFileTmp.WriteFile(pbSignature, dwSigLen);
|
||||
oFileTmp.CloseFile();
|
||||
|
||||
BYTE* pbSignatureMem = new BYTE[dwSigLen];
|
||||
ConvertEndian(pbSignature, pbSignatureMem, dwSigLen);
|
||||
|
||||
NSFile::CFileBinary oFile;
|
||||
oFile.CreateFileW(sSignatureFile);
|
||||
|
||||
//oFile.WriteFile(pbSignature, dwSigLen);
|
||||
char* pBase64 = NULL;
|
||||
int nBase64Len = 0;
|
||||
NSFile::CBase64Converter::Encode(pbSignature, (int)dwSigLen, pBase64, nBase64Len, NSBase64::B64_BASE64_FLAG_NONE);
|
||||
NSFile::CBase64Converter::Encode(pbSignatureMem, (int)dwSigLen, pBase64, nBase64Len, NSBase64::B64_BASE64_FLAG_NONE);
|
||||
oFile.WriteFile((BYTE*)pBase64, (DWORD)nBase64Len);
|
||||
|
||||
oFile.CloseFile();
|
||||
|
||||
delete[] pbSignature;
|
||||
delete[] pbSignatureMem;
|
||||
delete[] pDataSrc;
|
||||
|
||||
bResult = CryptDestroyHash(hHash);
|
||||
@ -383,7 +494,7 @@ bool Sign(HCERTSTORE hStoreHandle, PCCERT_CONTEXT pCertContext, std::wstring sFi
|
||||
return (bResult == TRUE);
|
||||
}
|
||||
|
||||
bool Verify(HCERTSTORE hStoreHandle, PCCERT_CONTEXT pCertContext, std::wstring sFileXml, std::wstring sSignatureFile)
|
||||
bool Verify(PCCERT_CONTEXT pCertContext, std::wstring sFileXml, std::wstring sSignatureFile)
|
||||
{
|
||||
DWORD dwKeySpec = 0;
|
||||
HCRYPTPROV hCryptProv = NULL;
|
||||
@ -409,18 +520,22 @@ bool Verify(HCERTSTORE hStoreHandle, PCCERT_CONTEXT pCertContext, std::wstring s
|
||||
NSFile::CBase64Converter::Decode((char*)pDataHashBase64, (int)dwFileHashSrcLenBase64, pDataHash, nTmp);
|
||||
dwHashLen = (DWORD)nTmp;
|
||||
|
||||
BYTE* pDataHashMem = new BYTE[dwHashLen];
|
||||
ConvertEndian(pDataHash, pDataHashMem, dwHashLen);
|
||||
|
||||
bResult = CryptHashData(hHash, pDataSrc, dwFileSrcLen, 0);
|
||||
|
||||
// Get the public key from the certificate
|
||||
CryptImportPublicKeyInfo(hCryptProv, PKCS_7_ASN_ENCODING | X509_ASN_ENCODING, &pCertContext->pCertInfo->SubjectPublicKeyInfo, &hPubKey);
|
||||
|
||||
bResult = CryptVerifySignature(hHash, pDataHash, dwHashLen, hPubKey, NULL, 0);
|
||||
BOOL bResultRet = CryptVerifySignature(hHash, pDataHashMem, dwHashLen, hPubKey, NULL, 0);
|
||||
|
||||
delete[] pDataSrc;
|
||||
delete[] pDataHash;
|
||||
delete[] pDataHashMem;
|
||||
delete[] pDataHashBase64;
|
||||
|
||||
bResult = CryptDestroyHash(hHash);
|
||||
|
||||
return bResult;
|
||||
return bResultRet && bResult;
|
||||
}
|
||||
|
||||
@ -6,6 +6,30 @@ TEMPLATE = app
|
||||
CONFIG += console
|
||||
CONFIG -= app_bundle
|
||||
|
||||
CORE_ROOT_DIR = $$PWD/../../../../
|
||||
PWD_ROOT_DIR = $$PWD
|
||||
include($$CORE_ROOT_DIR/Common/base.pri)
|
||||
|
||||
DEFINES -= UNICODE
|
||||
|
||||
DEFINES += \
|
||||
LIBXML_READER_ENABLED \
|
||||
LIBXML_PUSH_ENABLED \
|
||||
LIBXML_HTML_ENABLED \
|
||||
LIBXML_XPATH_ENABLED \
|
||||
LIBXML_OUTPUT_ENABLED \
|
||||
LIBXML_C14N_ENABLED \
|
||||
LIBXML_SAX1_ENABLED \
|
||||
LIBXML_TREE_ENABLED \
|
||||
LIBXML_XPTR_ENABLED \
|
||||
LIBXML_STATIC
|
||||
|
||||
SOURCES += main.cpp
|
||||
|
||||
LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -llibxml
|
||||
|
||||
INCLUDEPATH += \
|
||||
$$CORE_ROOT_DIR/DesktopEditor/xml/libxml2/include \
|
||||
$$CORE_ROOT_DIR/DesktopEditor/xml/libxml2/include/libxml
|
||||
|
||||
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 10.00
|
||||
# Visual C# Express 2008
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 14
|
||||
VisualStudioVersion = 14.0.25420.1
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "codegen", "codegen\codegen.csproj", "{B3AE10A0-6AB5-42EC-A83B-92012431B445}"
|
||||
EndProject
|
||||
Global
|
||||
|
||||
484
Test/Applications/DocxFormatCodeGen/codegen/CodeGenPivot.cs
Normal file
484
Test/Applications/DocxFormatCodeGen/codegen/CodeGenPivot.cs
Normal file
@ -0,0 +1,484 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2017
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
|
||||
* EU, LV-1021.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
using System.Xml.Schema;
|
||||
using System.Xml.Serialization;
|
||||
using System.IO;
|
||||
using System.Collections;
|
||||
using System.CodeDom;
|
||||
using System.CodeDom.Compiler;
|
||||
|
||||
namespace codegen
|
||||
{
|
||||
public class GenMemberPivot
|
||||
{
|
||||
public string sName;
|
||||
public string sNamespace;
|
||||
|
||||
public string sType;
|
||||
public Type oSystemType;
|
||||
|
||||
public bool? bIsAttribute;
|
||||
public string sDefAttribute;
|
||||
|
||||
public bool? bQualified;//нужно ли при записи в xml писать prefix
|
||||
|
||||
public int? nArrayRank;
|
||||
public List<GenMemberPivot> aArrayTypes;
|
||||
public bool? bIsArrayTypesHidden;
|
||||
|
||||
public GenMemberPivot(string _sName)
|
||||
{
|
||||
sName = _sName;
|
||||
sNamespace = null;
|
||||
sType = null;
|
||||
oSystemType = null;
|
||||
bIsAttribute = null;
|
||||
sDefAttribute = null;
|
||||
bQualified = null;
|
||||
nArrayRank = null;
|
||||
bIsArrayTypesHidden = null;
|
||||
aArrayTypes = null;
|
||||
}
|
||||
public void merge(GenMemberPivot val)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(val.sName))
|
||||
sName = val.sName;
|
||||
if (!string.IsNullOrEmpty(val.sNamespace))
|
||||
sNamespace = val.sNamespace;
|
||||
if (!string.IsNullOrEmpty(val.sType))
|
||||
sType = val.sType;
|
||||
if (null != val.oSystemType)
|
||||
oSystemType = val.oSystemType;
|
||||
if (val.bIsAttribute.HasValue)
|
||||
bIsAttribute = val.bIsAttribute;
|
||||
if (!string.IsNullOrEmpty(val.sDefAttribute))
|
||||
sDefAttribute = val.sDefAttribute;
|
||||
if (val.bQualified.HasValue)
|
||||
bQualified = val.bQualified;
|
||||
if (val.nArrayRank.HasValue)
|
||||
nArrayRank = val.nArrayRank;
|
||||
if (val.bIsArrayTypesHidden.HasValue)
|
||||
bIsArrayTypesHidden = val.bIsArrayTypesHidden;
|
||||
}
|
||||
public void completeDefaults()
|
||||
{
|
||||
if (!bIsAttribute.HasValue)
|
||||
bIsAttribute = false;
|
||||
if (!bQualified.HasValue)
|
||||
bQualified = true;
|
||||
}
|
||||
}
|
||||
|
||||
//[System.Xml.Serialization.XmlElementAttribute("c")]
|
||||
//public CT_CalcCell[] c {
|
||||
//bIsArray=true;aArrayTypes=[CT_CalcCell]
|
||||
|
||||
//[System.Xml.Serialization.XmlElementAttribute("b", typeof(CT_Boolean))]
|
||||
//[System.Xml.Serialization.XmlElementAttribute("d", typeof(CT_DateTime))]
|
||||
//[System.Xml.Serialization.XmlElementAttribute("e", typeof(CT_Error))]
|
||||
//[System.Xml.Serialization.XmlElementAttribute("m", typeof(CT_Missing))]
|
||||
//[System.Xml.Serialization.XmlElementAttribute("n", typeof(CT_Number))]
|
||||
//[System.Xml.Serialization.XmlElementAttribute("s", typeof(CT_String))]
|
||||
//public object[] Items {
|
||||
|
||||
//[System.Xml.Serialization.XmlArrayItemAttribute("author", IsNullable=false)]
|
||||
//public string[] authors {
|
||||
|
||||
//[System.Xml.Serialization.XmlArrayItemAttribute("b", typeof(CT_Boolean), IsNullable=false)]
|
||||
//[System.Xml.Serialization.XmlArrayItemAttribute("d", typeof(CT_DateTime), IsNullable=false)]
|
||||
//[System.Xml.Serialization.XmlArrayItemAttribute("e", typeof(CT_Error), IsNullable=false)]
|
||||
//[System.Xml.Serialization.XmlArrayItemAttribute("m", typeof(CT_Missing), IsNullable=false)]
|
||||
//[System.Xml.Serialization.XmlArrayItemAttribute("n", typeof(CT_Number), IsNullable=false)]
|
||||
//[System.Xml.Serialization.XmlArrayItemAttribute("s", typeof(CT_String), IsNullable=false)]
|
||||
//[System.Xml.Serialization.XmlArrayItemAttribute("x", typeof(CT_Index), IsNullable=false)]
|
||||
//public object[][] r {
|
||||
|
||||
//[System.Xml.Serialization.XmlElementAttribute("consolidation", typeof(CT_Consolidation))]
|
||||
//[System.Xml.Serialization.XmlElementAttribute("extLst", typeof(CT_ExtensionList))]
|
||||
//[System.Xml.Serialization.XmlElementAttribute("worksheetSource", typeof(CT_WorksheetSource))]
|
||||
//public object Item
|
||||
//{
|
||||
|
||||
public class GenClassPivot
|
||||
{
|
||||
public string sName;
|
||||
public string sNamespace;
|
||||
public bool bIsEnum;
|
||||
public List<GenMemberPivot> aMembers = new List<GenMemberPivot>();
|
||||
public string sRootName;
|
||||
public GenClassPivot(string _sName, string _sNamespace)
|
||||
{
|
||||
sName = _sName;
|
||||
sNamespace = _sNamespace;
|
||||
bIsEnum = false;
|
||||
sRootName = "";
|
||||
}
|
||||
public bool isRoot()
|
||||
{
|
||||
return !string.IsNullOrEmpty(this.sRootName);
|
||||
}
|
||||
}
|
||||
class CodeGenPivot
|
||||
{
|
||||
Dictionary<string, GenClassPivot> m_mapGeneratedClasses = new Dictionary<string, GenClassPivot>();
|
||||
int m_nItemsChoiceTypeCount = 0;
|
||||
public void Start(string sDirIn, string sDirCppXmlOut, string sDirCppBinOut, string sDirJsBinOut, ValidationEventHandler oValidationEventHandler)
|
||||
{
|
||||
string sChartNamespace = "http://purl.oclc.org/ooxml/spreadsheetml/main";
|
||||
|
||||
string[] aFiles = Directory.GetFiles(sDirIn);
|
||||
XmlSchemaSet schemaSet = new XmlSchemaSet();
|
||||
schemaSet.ValidationEventHandler += oValidationEventHandler;
|
||||
for (int i = 0; i < aFiles.Length; i++)
|
||||
{
|
||||
string sFile = aFiles[i];
|
||||
if (".xsd" == Path.GetExtension(sFile))
|
||||
schemaSet.Add(null, sFile);
|
||||
}
|
||||
schemaSet.Compile();
|
||||
XmlSchema chartSchema = null;
|
||||
XmlSchemas schemas = new XmlSchemas();
|
||||
foreach (XmlSchema schema in schemaSet.Schemas())
|
||||
{
|
||||
if (schema.TargetNamespace == sChartNamespace)
|
||||
{
|
||||
chartSchema = schema;
|
||||
schemas.Add(schema);
|
||||
}
|
||||
}
|
||||
if (null != chartSchema)
|
||||
{
|
||||
CodeNamespace ns = new CodeNamespace();
|
||||
XmlCodeExporter exporter = new XmlCodeExporter(ns);
|
||||
|
||||
CodeGenerationOptions generationOptions = CodeGenerationOptions.GenerateProperties;
|
||||
|
||||
|
||||
XmlSchemaImporter importer = new XmlSchemaImporter(schemas, generationOptions, new ImportContext(new CodeIdentifiers(), false));
|
||||
|
||||
foreach (XmlSchemaElement element in chartSchema.Elements.Values)
|
||||
{
|
||||
XmlTypeMapping mapping = importer.ImportTypeMapping(element.QualifiedName);
|
||||
exporter.ExportTypeMapping(mapping);
|
||||
}
|
||||
CodeGenerator.ValidateIdentifiers(ns);
|
||||
|
||||
////Microsoft.CSharp.CSharpCodeProvider oProvider;
|
||||
|
||||
//// output the C# code
|
||||
//Microsoft.CSharp.CSharpCodeProvider codeProvider = new Microsoft.CSharp.CSharpCodeProvider();
|
||||
|
||||
//using (StringWriter writer = new StringWriter())
|
||||
//{
|
||||
// codeProvider.GenerateCodeFromNamespace(ns, writer, new CodeGeneratorOptions());
|
||||
// string sCode = writer.GetStringBuilder().ToString();
|
||||
//}
|
||||
|
||||
List<GenClassPivot> aGenClasses = PreProcess(ns, chartSchema);
|
||||
|
||||
aGenClasses = FilterClassesPivot(aGenClasses);
|
||||
|
||||
//(new CodegenCPP()).Process(sDirCppXmlOut, sDirCppBinOut, aGenClasses);
|
||||
//(new CodegenJS()).Process(sDirJsBinOut, aGenClasses);
|
||||
(new CodegenJSXml()).Process(sDirJsBinOut, aGenClasses);
|
||||
}
|
||||
}
|
||||
List<GenClassPivot> FilterClassesPivot(List<GenClassPivot> aInput)
|
||||
{
|
||||
Queue<GenClassPivot> aTemp = new Queue<GenClassPivot>();
|
||||
List<GenClassPivot> aRes = new List<GenClassPivot>();
|
||||
string[] aTargetTypes = new string[] { "CT_PivotCacheDefinition", "CT_PivotCacheRecords", "CT_pivotTableDefinition" };
|
||||
Dictionary<string, bool> mapTargetSubTypes = new Dictionary<string, bool>();
|
||||
Dictionary<string, bool> namspaces = new Dictionary<string, bool>();
|
||||
|
||||
Dictionary<string, GenClassPivot> mapAllClasses = new Dictionary<string, GenClassPivot>();
|
||||
for (int i = 0; i < aInput.Count; ++i)
|
||||
{
|
||||
GenClassPivot oGenClass = aInput[i];
|
||||
if (0 == aTargetTypes.Length || -1 != Array.IndexOf(aTargetTypes, oGenClass.sName))
|
||||
aTemp.Enqueue(oGenClass);
|
||||
mapAllClasses[oGenClass.sName] = oGenClass;
|
||||
}
|
||||
while (aTemp.Count > 0)
|
||||
{
|
||||
GenClassPivot oGenClass = aTemp.Dequeue();
|
||||
if (!mapTargetSubTypes.ContainsKey(oGenClass.sName))
|
||||
{
|
||||
mapTargetSubTypes.Add(oGenClass.sName, true);
|
||||
aRes.Add(oGenClass);
|
||||
for (int j = 0; j < oGenClass.aMembers.Count; ++j)
|
||||
{
|
||||
GenMemberPivot oGenMember = oGenClass.aMembers[j];
|
||||
|
||||
GenClassPivot oTempClass;
|
||||
if (null != oGenMember.sType && mapAllClasses.TryGetValue(oGenMember.sType, out oTempClass))
|
||||
{
|
||||
namspaces[oTempClass.sNamespace] = true;
|
||||
|
||||
aTemp.Enqueue(oTempClass);
|
||||
}
|
||||
if (null != oGenMember.aArrayTypes)
|
||||
{
|
||||
for (int k = 0; k < oGenMember.aArrayTypes.Count; ++k)
|
||||
{
|
||||
GenMemberPivot oGenMemberArrayTypes = oGenMember.aArrayTypes[k];
|
||||
if (null != oGenMemberArrayTypes.sType && mapAllClasses.TryGetValue(oGenMemberArrayTypes.sType, out oTempClass))
|
||||
{
|
||||
aTemp.Enqueue(oTempClass);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return aRes;
|
||||
}
|
||||
List<GenClassPivot> PreProcess(CodeNamespace code, XmlSchema schema)
|
||||
{
|
||||
List<GenClassPivot> aGenClasses = new List<GenClassPivot>();
|
||||
for (int i = 0; i < code.Types.Count; ++i)
|
||||
{
|
||||
GenClassPivot oNewClass = PreProcessClass(aGenClasses, code.Types[i]);
|
||||
if (null != oNewClass)
|
||||
aGenClasses.Add(oNewClass);
|
||||
}
|
||||
return aGenClasses;
|
||||
}
|
||||
GenClassPivot PreProcessClass(List<GenClassPivot> aGenClasses, CodeTypeDeclaration type)
|
||||
{
|
||||
GenClassPivot oGenClass = null;
|
||||
//получаем xml namespace
|
||||
string sNamespace = null;
|
||||
bool bIncludeInSchema = true;
|
||||
string sRootName = "";
|
||||
for (int i = 0; i < type.CustomAttributes.Count; i++)
|
||||
{
|
||||
CodeAttributeDeclaration attribute = type.CustomAttributes[i];
|
||||
if (attribute.Name == "System.Xml.Serialization.XmlTypeAttribute")
|
||||
{
|
||||
foreach (CodeAttributeArgument argument in attribute.Arguments)
|
||||
{
|
||||
if (argument.Name == "Namespace")
|
||||
sNamespace = ((CodePrimitiveExpression)argument.Value).Value.ToString();
|
||||
else if (argument.Name == "IncludeInSchema")
|
||||
bIncludeInSchema = Convert.ToBoolean(((CodePrimitiveExpression)argument.Value).Value);
|
||||
//todo argument.Name == "TypeName"
|
||||
}
|
||||
}
|
||||
else if (attribute.Name == "System.Xml.Serialization.XmlRootAttribute")
|
||||
{
|
||||
foreach (CodeAttributeArgument argument in attribute.Arguments)
|
||||
{
|
||||
if (argument.Name == "Namespace")
|
||||
sNamespace = ((CodePrimitiveExpression)argument.Value).Value.ToString();
|
||||
else if ("" == argument.Name)
|
||||
sRootName = ((CodePrimitiveExpression)argument.Value).Value.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (bIncludeInSchema)
|
||||
{
|
||||
oGenClass = new GenClassPivot(type.Name, sNamespace);
|
||||
oGenClass.sRootName = sRootName;
|
||||
int nItemsElementName = 0;
|
||||
if (type.IsEnum)
|
||||
{
|
||||
oGenClass.bIsEnum = true;
|
||||
for (int i = 0; i < type.Members.Count; ++i)
|
||||
{
|
||||
CodeTypeMember member = type.Members[i];
|
||||
GenMemberPivot oGenMember = new GenMemberPivot(member.Name);
|
||||
for (int j = 0; j < member.CustomAttributes.Count; j++)
|
||||
{
|
||||
CodeAttributeDeclaration attribute = member.CustomAttributes[j];
|
||||
if (attribute.Name == "System.Xml.Serialization.XmlEnumAttribute")
|
||||
ParseArguments(attribute.Arguments, oGenMember);
|
||||
}
|
||||
oGenClass.aMembers.Add(oGenMember);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < type.Members.Count; ++i)
|
||||
{
|
||||
CodeTypeMember member = type.Members[i];
|
||||
//CodeMemberField пропускаем
|
||||
CodeMemberProperty codeMemberProperty = member as CodeMemberProperty;
|
||||
if (codeMemberProperty != null)
|
||||
{
|
||||
GenMemberPivot oNewGenMember = PreProcessProperty(aGenClasses, codeMemberProperty, oGenClass, ref nItemsElementName);
|
||||
if (null != oNewGenMember)
|
||||
oGenClass.aMembers.Add(oNewGenMember);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return oGenClass;
|
||||
}
|
||||
GenMemberPivot PreProcessProperty(List<GenClassPivot> aGenClasses, CodeMemberProperty codeMemberProperty, GenClassPivot oGenClass, ref int nItemsElementName)
|
||||
{
|
||||
GenMemberPivot oGenMember = new GenMemberPivot(codeMemberProperty.Name);
|
||||
bool bIgnore = false;
|
||||
InitMemberType(oGenMember, codeMemberProperty.Type.BaseType);
|
||||
if (null != codeMemberProperty.Type.ArrayElementType)
|
||||
{
|
||||
oGenMember.nArrayRank = codeMemberProperty.Type.ArrayElementType.ArrayRank;
|
||||
}
|
||||
bool bXmlElementAttribute = false;
|
||||
List<GenMemberPivot> aTempMemebers = new List<GenMemberPivot>();
|
||||
for (int i = 0; i < codeMemberProperty.CustomAttributes.Count; i++)
|
||||
{
|
||||
CodeAttributeDeclaration attribute = codeMemberProperty.CustomAttributes[i];
|
||||
if (attribute.Name == "System.Xml.Serialization.XmlAttributeAttribute")
|
||||
{
|
||||
oGenMember.bQualified = false;
|
||||
oGenMember.bIsAttribute = true;
|
||||
ParseArguments(attribute.Arguments, oGenMember);
|
||||
//todo могут быть повторы имен атрибутов и child nodes.
|
||||
}
|
||||
else if (attribute.Name == "System.ComponentModel.DefaultValueAttribute")
|
||||
{
|
||||
if (attribute.Arguments.Count > 0)
|
||||
{
|
||||
CodeExpression oCodeExpression = attribute.Arguments[attribute.Arguments.Count - 1].Value;
|
||||
//todo other
|
||||
if (oCodeExpression is CodePrimitiveExpression)
|
||||
oGenMember.sDefAttribute = ((oCodeExpression as CodePrimitiveExpression)).Value.ToString();
|
||||
else if (oCodeExpression is CodeFieldReferenceExpression)
|
||||
oGenMember.sDefAttribute = ((oCodeExpression as CodeFieldReferenceExpression)).FieldName;
|
||||
}
|
||||
}
|
||||
else if (attribute.Name == "System.Xml.Serialization.XmlIgnoreAttribute")
|
||||
bIgnore = true;
|
||||
else if (attribute.Name == "System.Xml.Serialization.XmlElementAttribute")
|
||||
{
|
||||
bXmlElementAttribute = true;
|
||||
GenMemberPivot oTemp = new GenMemberPivot(null);
|
||||
ParseArguments(attribute.Arguments, oTemp);
|
||||
aTempMemebers.Add(oTemp);
|
||||
}
|
||||
else if (attribute.Name == "System.Xml.Serialization.XmlArrayItemAttribute")
|
||||
{
|
||||
GenMemberPivot oTemp = new GenMemberPivot(null);
|
||||
ParseArguments(attribute.Arguments, oTemp);
|
||||
aTempMemebers.Add(oTemp);
|
||||
}
|
||||
else if (attribute.Name == "System.Xml.Serialization.XmlArrayAttribute")
|
||||
{
|
||||
ParseArguments(attribute.Arguments, oGenMember);
|
||||
}
|
||||
//todo не всегда прописан
|
||||
//else if (attribute.Name == "System.Xml.Serialization.XmlChoiceIdentifierAttribute")
|
||||
//{
|
||||
// if (attribute.Arguments.Count > 0)
|
||||
// {
|
||||
// CodePrimitiveExpression oPrimitiveExpression = attribute.Arguments[0].Value as CodePrimitiveExpression;
|
||||
// oGenMember.sChoiceIdentifier = oPrimitiveExpression.Value.ToString();
|
||||
// }
|
||||
//}
|
||||
}
|
||||
if (bIgnore)
|
||||
return null;
|
||||
else
|
||||
{
|
||||
if (aTempMemebers.Count > 0)
|
||||
{
|
||||
if (1 == aTempMemebers.Count)
|
||||
{
|
||||
oGenMember.merge(aTempMemebers[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
oGenMember.aArrayTypes = aTempMemebers;
|
||||
if (bXmlElementAttribute)
|
||||
oGenMember.bIsArrayTypesHidden = true;
|
||||
else
|
||||
oGenMember.bIsArrayTypesHidden = false;
|
||||
}
|
||||
}
|
||||
oGenMember.completeDefaults();
|
||||
return oGenMember;
|
||||
}
|
||||
}
|
||||
void ParseArguments(CodeAttributeArgumentCollection oArguments, GenMemberPivot oGenMember)
|
||||
{
|
||||
CodePrimitiveExpression oPrimitiveExpression = null;
|
||||
CodeTypeOfExpression oTypeOfExpression = null;
|
||||
string sNamespace = null;
|
||||
bool? bForm = null;
|
||||
foreach (CodeAttributeArgument argument in oArguments)
|
||||
{
|
||||
if ("" == argument.Name)
|
||||
{
|
||||
if (argument.Value is CodePrimitiveExpression)
|
||||
oPrimitiveExpression = argument.Value as CodePrimitiveExpression;
|
||||
else if (argument.Value is CodeTypeOfExpression)
|
||||
oTypeOfExpression = argument.Value as CodeTypeOfExpression;
|
||||
}
|
||||
else if ("Namespace" == argument.Name)
|
||||
sNamespace = ((CodePrimitiveExpression)argument.Value).Value.ToString();
|
||||
else if ("Form" == argument.Name)
|
||||
{
|
||||
string sValue = ((CodeFieldReferenceExpression)argument.Value).FieldName;
|
||||
if ("Qualified" == sValue)
|
||||
bForm = true;
|
||||
else if ("Unqualified" == sValue)
|
||||
bForm = false;
|
||||
}
|
||||
}
|
||||
if (null != oPrimitiveExpression)
|
||||
oGenMember.sName = oPrimitiveExpression.Value.ToString();
|
||||
if (null != oTypeOfExpression)
|
||||
InitMemberType(oGenMember, oTypeOfExpression.Type.BaseType);
|
||||
if (null != sNamespace)
|
||||
oGenMember.sNamespace = sNamespace;
|
||||
if (bForm.HasValue)
|
||||
oGenMember.bQualified = bForm.Value;
|
||||
}
|
||||
void InitMemberType(GenMemberPivot oGenMember, string sBaseType)
|
||||
{
|
||||
if (-1 != sBaseType.IndexOf("System."))
|
||||
{
|
||||
oGenMember.oSystemType = Type.GetType(sBaseType);
|
||||
if (null == oGenMember.oSystemType)
|
||||
oGenMember.oSystemType = typeof(string);
|
||||
}
|
||||
else
|
||||
oGenMember.sType = sBaseType;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -51,7 +51,6 @@ namespace codegen
|
||||
StringBuilder m_oDocxFromToBinaryCPP = new StringBuilder();
|
||||
StringBuilder m_oDocxTypesH = new StringBuilder();
|
||||
Dictionary<string, GenClass> m_mapProcessedClasses = new Dictionary<string, GenClass>();
|
||||
Dictionary<string, string> m_mapNamespaceToPrefix = new Dictionary<string, string>() { { "http://purl.oclc.org/ooxml/drawingml/chart", "c:" }, { "http://purl.oclc.org/ooxml/drawingml/main", "a:" }, { "http://purl.oclc.org/ooxml/officeDocument/relationships", "r:" }, { "http://schemas.openxmlformats.org/markup-compatibility/2006", "mc:" }, { "http://schemas.microsoft.com/office/drawing/2007/8/2/chart", "c14:" } };
|
||||
|
||||
string gc_sNamespaceToXml = " xmlns:c=\\\"http://schemas.openxmlformats.org/drawingml/2006/chart\\\" xmlns:a=\\\"http://schemas.openxmlformats.org/drawingml/2006/main\\\" xmlns:r=\\\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\\\" xmlns:mc=\\\"http://schemas.openxmlformats.org/markup-compatibility/2006\\\" xmlns:c14=\\\"http://schemas.microsoft.com/office/drawing/2007/8/2/chart\\\"";
|
||||
string gc_sTypePattern = "et_";
|
||||
@ -573,7 +572,7 @@ namespace codegen
|
||||
if (null != sMemberNamespace && oGenMember.bQualified)
|
||||
{
|
||||
string sShortNamespace;
|
||||
if (m_mapNamespaceToPrefix.TryGetValue(sMemberNamespace, out sShortNamespace))
|
||||
if (Utils.m_mapNamespaceToPrefix.TryGetValue(sMemberNamespace, out sShortNamespace))
|
||||
sElemName = sShortNamespace + sElemName;
|
||||
}
|
||||
|
||||
|
||||
731
Test/Applications/DocxFormatCodeGen/codegen/CodegenJSPivot.cs
Normal file
731
Test/Applications/DocxFormatCodeGen/codegen/CodegenJSPivot.cs
Normal file
@ -0,0 +1,731 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2017
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
|
||||
* EU, LV-1021.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
|
||||
namespace codegen
|
||||
{
|
||||
class CodegenJSXml
|
||||
{
|
||||
Dictionary<string, GenClassPivot> m_mapProcessedClasses = new Dictionary<string, GenClassPivot>();
|
||||
string gc_sEnumFromXmlPrefix = "FromXml_";
|
||||
string gc_sEnumToXmlPrefix = "ToXml_";
|
||||
string gc_sNamespaceToXml = " xmlns=\\\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\\\" xmlns:r=\\\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\\\"";
|
||||
|
||||
public void Process(string sOutputDir, List<GenClassPivot> aGenClasses)
|
||||
{
|
||||
StringBuilder oJsSer = new StringBuilder();
|
||||
List<GenClassPivot> aEnums = new List<GenClassPivot>();
|
||||
List<GenClassPivot> aClasses = new List<GenClassPivot>();
|
||||
for (int i = 0; i < aGenClasses.Count; ++i)
|
||||
{
|
||||
GenClassPivot oGenClass = aGenClasses[i];
|
||||
if (oGenClass.bIsEnum)
|
||||
aEnums.Add(oGenClass);
|
||||
else
|
||||
aClasses.Add(oGenClass);
|
||||
m_mapProcessedClasses[oGenClass.sName] = oGenClass;
|
||||
}
|
||||
string sFileJs = "PivotTables.js";
|
||||
oJsSer.AppendFormat("\"use strict\";\r\n");
|
||||
oJsSer.AppendFormat(Utils.gc_sFilePrefix);
|
||||
oJsSer.AppendFormat("function getBoolFromXml(val){{return \"0\"!==val && \"false\"!==val && \"off\"!==val;}}\r\n");
|
||||
oJsSer.AppendFormat("function getXmlFromBool(val){{return val ? \"1\" : \"0\";}}\r\n");
|
||||
|
||||
//enums
|
||||
ProcessEnums(oJsSer, aEnums);
|
||||
//FromXml
|
||||
for (int i = 0; i < aClasses.Count; ++i)
|
||||
ProcessClass(oJsSer, aClasses[i]);
|
||||
File.WriteAllText(Path.Combine(sOutputDir, sFileJs), oJsSer.ToString());
|
||||
}
|
||||
public void ProcessEnums(StringBuilder sb, List<GenClassPivot> aGenClasses)
|
||||
{
|
||||
for (int i = 0; i < aGenClasses.Count; ++i)
|
||||
{
|
||||
GenClassPivot oGenClass = aGenClasses[i];
|
||||
for (int j = 0; j < oGenClass.aMembers.Count; ++j)
|
||||
{
|
||||
GenMemberPivot oGenMember = oGenClass.aMembers[j];
|
||||
sb.AppendFormat("var {0} = {1};\r\n", Utils.GetEnumElemName(oGenClass.sName, oGenMember.sName), j);
|
||||
}
|
||||
sb.AppendFormat("\r\n");
|
||||
}
|
||||
for (int i = 0; i < aGenClasses.Count; ++i)
|
||||
{
|
||||
GenClassPivot oGenClass = aGenClasses[i];
|
||||
sb.AppendFormat("function {0}{1}(val)\r\n{{\r\n", gc_sEnumFromXmlPrefix, oGenClass.sName);
|
||||
sb.AppendFormat("var res = -1;\r\n");
|
||||
for (int j = 0; j < oGenClass.aMembers.Count; ++j)
|
||||
{
|
||||
GenMemberPivot member = oGenClass.aMembers[j];
|
||||
if (0 == j)
|
||||
sb.AppendFormat("if(\"{0}\"===val)\r\nres={1};\r\n", member.sName, Utils.GetEnumElemName(oGenClass.sName, member.sName));
|
||||
else
|
||||
sb.AppendFormat("else if(\"{0}\"===val)\r\nres={1};\r\n", member.sName, Utils.GetEnumElemName(oGenClass.sName, member.sName));
|
||||
}
|
||||
sb.AppendFormat("return res;\r\n}}\r\n");
|
||||
sb.AppendFormat("function {0}{1}(val)\r\n{{\r\n", gc_sEnumToXmlPrefix, oGenClass.sName);
|
||||
sb.AppendFormat("var res = \"\";\r\n");
|
||||
for (int j = 0; j < oGenClass.aMembers.Count; ++j)
|
||||
{
|
||||
GenMemberPivot member = oGenClass.aMembers[j];
|
||||
if (0 == j)
|
||||
sb.AppendFormat("if({0}===val)\r\nres=\"{1}\";\r\n", Utils.GetEnumElemName(oGenClass.sName, member.sName), member.sName);
|
||||
else
|
||||
sb.AppendFormat("else if({0}===val)\r\nres=\"{1}\";\r\n", Utils.GetEnumElemName(oGenClass.sName, member.sName), member.sName);
|
||||
}
|
||||
sb.AppendFormat("return res;\r\n}}\r\n");
|
||||
sb.AppendFormat("\r\n");
|
||||
|
||||
}
|
||||
}
|
||||
public void ProcessClass(StringBuilder sb, GenClassPivot oGenClass)
|
||||
{
|
||||
List<GenMemberPivot> aAttributes = new List<GenMemberPivot>();
|
||||
List<GenMemberPivot> aMembers = new List<GenMemberPivot>();
|
||||
bool bNeedTextNode = false;
|
||||
bool bNeedDoubleArray = false;
|
||||
InfoFromMember(oGenClass, ref aAttributes, ref aMembers, ref bNeedTextNode, ref bNeedDoubleArray);
|
||||
|
||||
sb.AppendFormat("function {0}(){{\r\n", oGenClass.sName);
|
||||
ProcessProperty(sb, aAttributes, aMembers, bNeedTextNode, bNeedDoubleArray);
|
||||
sb.AppendFormat("}}\r\n", oGenClass.sName);
|
||||
|
||||
if (aAttributes.Count > 0)
|
||||
{
|
||||
sb.AppendFormat("{0}.prototype.readAttributes = function(attr, uq) {{\r\n", oGenClass.sName);
|
||||
ProcessAttributesFromXml(sb, oGenClass, aAttributes);
|
||||
sb.AppendFormat("}};\r\n", oGenClass.sName);
|
||||
}
|
||||
if (aMembers.Count > 0)
|
||||
{
|
||||
sb.AppendFormat("{0}.prototype.onStartNode = function(elem, attr, uq) {{\r\n", oGenClass.sName);
|
||||
sb.AppendFormat("var newContext = this;\r\n");
|
||||
int nCounter = 0;
|
||||
if (oGenClass.isRoot() && ProcessRootFromXml(sb, oGenClass, "elem"))
|
||||
{
|
||||
nCounter++;
|
||||
}
|
||||
ProcessOnStartNodeFromXml(sb, oGenClass, aMembers, nCounter, "elem");
|
||||
sb.AppendFormat("else {{\r\n");
|
||||
sb.AppendFormat("newContext = null;\r\n");
|
||||
sb.AppendFormat("}}\r\n");
|
||||
sb.AppendFormat("return newContext;\r\n");
|
||||
sb.AppendFormat("}};\r\n", oGenClass.sName);
|
||||
|
||||
if (bNeedTextNode)
|
||||
{
|
||||
sb.AppendFormat("{0}.prototype.onTextNode = function(text, uq) {{\r\n", oGenClass.sName);
|
||||
ProcessOnTextNodeFromXml(sb, oGenClass, aMembers);
|
||||
sb.AppendFormat("}};\r\n", oGenClass.sName);
|
||||
}
|
||||
if (bNeedDoubleArray)
|
||||
{
|
||||
sb.AppendFormat("{0}.prototype.onEndNode = function(prevContext, elem) {{\r\n", oGenClass.sName);
|
||||
ProcessOnEndNodeFromXml(sb, oGenClass, aMembers);
|
||||
sb.AppendFormat("}};\r\n", oGenClass.sName);
|
||||
}
|
||||
}
|
||||
if (aAttributes.Count > 0 || aMembers.Count > 0)
|
||||
{
|
||||
if (oGenClass.isRoot())
|
||||
{
|
||||
sb.AppendFormat("{0}.prototype.toXml = function() {{\r\n", oGenClass.sName);
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.AppendFormat("{0}.prototype.toXml = function(name) {{\r\n", oGenClass.sName);
|
||||
}
|
||||
sb.AppendFormat("var res = \"\";\r\n");
|
||||
ProcessToXml(sb, oGenClass);
|
||||
sb.AppendFormat("return res;\r\n");
|
||||
sb.AppendFormat("}};\r\n");
|
||||
}
|
||||
}
|
||||
public void InfoFromMember(GenClassPivot oGenClass, ref List<GenMemberPivot> aAttributes, ref List<GenMemberPivot> aMembers, ref bool bNeedTextNode, ref bool bNeedDoubleArray)
|
||||
{
|
||||
for (int i = 0; i < oGenClass.aMembers.Count; ++i)
|
||||
{
|
||||
GenMemberPivot oGenMember = oGenClass.aMembers[i];
|
||||
if (true == oGenMember.bIsAttribute)
|
||||
{
|
||||
aAttributes.Add(oGenMember);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (oGenMember.nArrayRank.HasValue && oGenMember.nArrayRank > 0)
|
||||
{
|
||||
bNeedDoubleArray = true;
|
||||
}
|
||||
if (null == oGenMember.aArrayTypes)
|
||||
{
|
||||
if (null != oGenMember.oSystemType)
|
||||
{
|
||||
bNeedTextNode = true;
|
||||
}
|
||||
else if (null != oGenMember.sType)
|
||||
{
|
||||
GenClassPivot oTemp;
|
||||
if (m_mapProcessedClasses.TryGetValue(oGenMember.sType, out oTemp))
|
||||
{
|
||||
if (oTemp.bIsEnum)
|
||||
{
|
||||
bNeedTextNode = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
aMembers.Add(oGenMember);
|
||||
}
|
||||
}
|
||||
}
|
||||
void ProcessProperty(StringBuilder sb, List<GenMemberPivot> aAttributes, List<GenMemberPivot> aMembers, bool bNeedTextNode, bool bNeedDoubleArray)
|
||||
{
|
||||
if (aAttributes.Count > 0)
|
||||
{
|
||||
sb.AppendFormat("//Attributes\r\n");
|
||||
for (int i = 0; i < aAttributes.Count; ++i)
|
||||
{
|
||||
GenMemberPivot oGenMember = aAttributes[i];
|
||||
if (!string.IsNullOrEmpty(oGenMember.sDefAttribute))
|
||||
{
|
||||
sb.AppendFormat("this.{0} = null;//{1}\r\n", oGenMember.sName, oGenMember.sDefAttribute.ToLower());
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.AppendFormat("this.{0} = null;\r\n", oGenMember.sName);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (aMembers.Count > 0)
|
||||
{
|
||||
sb.AppendFormat("//Members\r\n");
|
||||
for (int i = 0; i < aMembers.Count; ++i)
|
||||
{
|
||||
GenMemberPivot oGenMember = aMembers[i];
|
||||
if (oGenMember.nArrayRank.HasValue)
|
||||
sb.AppendFormat("this.{0} = [];\r\n", oGenMember.sName);
|
||||
else
|
||||
{
|
||||
if (null != oGenMember.aArrayTypes)
|
||||
{
|
||||
for (int j = 0; j < oGenMember.aArrayTypes.Count; ++j)
|
||||
{
|
||||
GenMemberPivot oTempMember = oGenMember.aArrayTypes[j];
|
||||
if (!string.IsNullOrEmpty(oTempMember.sDefAttribute))
|
||||
{
|
||||
sb.AppendFormat("this.{0} = null;//{1}\r\n", oTempMember.sName, oTempMember.sDefAttribute.ToLower());
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.AppendFormat("this.{0} = null;\r\n", oTempMember.sName);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!string.IsNullOrEmpty(oGenMember.sDefAttribute))
|
||||
{
|
||||
sb.AppendFormat("this.{0} = null;//{1}\r\n", oGenMember.sName, oGenMember.sDefAttribute.ToLower());
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.AppendFormat("this.{0} = null;\r\n", oGenMember.sName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (bNeedTextNode || bNeedDoubleArray)
|
||||
{
|
||||
sb.AppendFormat("//internal\r\n");
|
||||
if (bNeedTextNode)
|
||||
sb.AppendFormat("this._curElem = null;\r\n");
|
||||
if (bNeedDoubleArray)
|
||||
sb.AppendFormat("this._curArray = null;\r\n");
|
||||
}
|
||||
|
||||
}
|
||||
bool ProcessRootFromXml(StringBuilder sb, GenClassPivot oGenClass, string sCodeName)
|
||||
{
|
||||
string sName = oGenClass.sRootName;
|
||||
if (!string.IsNullOrEmpty(sName))
|
||||
{
|
||||
sb.AppendFormat("if(\"{0}\" === {1}){{\r\n", sName, sCodeName);
|
||||
sb.AppendFormat("newContext.readAttributes(attr, uq);\r\n", sName, sCodeName);
|
||||
sb.AppendFormat("}}\r\n", sName, sCodeName);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
void ProcessOnStartNodeFromXml(StringBuilder sb, GenClassPivot oGenClass, List<GenMemberPivot> aMembers, int nCounter, string sCodeName)
|
||||
{
|
||||
for (int i = 0; i < aMembers.Count; ++i)
|
||||
{
|
||||
GenMemberPivot oGenMember = aMembers[i];
|
||||
if (null != oGenMember.aArrayTypes)
|
||||
{
|
||||
if (false == oGenMember.bIsArrayTypesHidden)
|
||||
{
|
||||
if (0 != nCounter)
|
||||
sb.AppendFormat("else ");
|
||||
//todo rework
|
||||
sb.AppendFormat("if(\"{0}\" === {1}){{\r\n", getNameWithPrefix(oGenClass, oGenMember), sCodeName);
|
||||
if (oGenMember.nArrayRank > 0)
|
||||
{
|
||||
sb.AppendFormat("this._curArray = [];\r\n", getNameWithPrefix(oGenClass, oGenMember), sCodeName);
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.AppendFormat("//todo check\r\n", getNameWithPrefix(oGenClass, oGenMember), sCodeName);
|
||||
}
|
||||
sb.AppendFormat("}}\r\n", getNameWithPrefix(oGenClass, oGenMember), sCodeName);
|
||||
nCounter++;
|
||||
}
|
||||
for (int j = 0; j < oGenMember.aArrayTypes.Count; ++j)
|
||||
{
|
||||
nCounter = ProcessOnStartNodeFromXmlMember(sb, oGenClass, oGenMember.aArrayTypes[j], oGenMember, sCodeName, nCounter);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nCounter = ProcessOnStartNodeFromXmlMember(sb, oGenClass, oGenMember, null, sCodeName, nCounter);
|
||||
}
|
||||
}
|
||||
}
|
||||
int ProcessOnStartNodeFromXmlMember(StringBuilder sb, GenClassPivot oGenClass, GenMemberPivot oGenMember, GenMemberPivot oGenMemberContainer, string sCodeName, int nCounter)
|
||||
{
|
||||
if (0 != nCounter)
|
||||
sb.AppendFormat("else ");
|
||||
sb.AppendFormat("if(\"{0}\" === {1}){{\r\n", getNameWithPrefix(oGenClass, oGenMember), sCodeName);
|
||||
|
||||
if (null != oGenMember.oSystemType)
|
||||
{
|
||||
sb.AppendFormat("this._curElem = {0};\r\n", sCodeName);
|
||||
}
|
||||
else if (null != oGenMember.sType)
|
||||
{
|
||||
GenClassPivot oTemp;
|
||||
if (m_mapProcessedClasses.TryGetValue(oGenMember.sType, out oTemp))
|
||||
{
|
||||
if (oTemp.bIsEnum)
|
||||
{
|
||||
sb.AppendFormat("this._curElem = {0};\r\n", sCodeName);
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.AppendFormat("newContext = new {0}();\r\n", oGenMember.sType);
|
||||
sb.AppendFormat("if(newContext.readAttributes){{\r\n");
|
||||
sb.AppendFormat("newContext.readAttributes(attr, uq);\r\n", oGenMember.sType);
|
||||
sb.AppendFormat("}}\r\n");
|
||||
GenMemberPivot oTargetMember = null != oGenMemberContainer ? oGenMemberContainer : oGenMember;
|
||||
if (oTargetMember.nArrayRank.HasValue)
|
||||
{
|
||||
if (oTargetMember.nArrayRank > 0)
|
||||
{
|
||||
sb.AppendFormat("this._curArray.push(newContext);\r\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.AppendFormat("this.{0}.push(newContext);\r\n", oTargetMember.sName);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//oGenMember not mistake
|
||||
//right way to store oGenMemberContainer in one object, but we prefer separete types
|
||||
sb.AppendFormat("this.{0} = newContext;\r\n", oGenMember.sName);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
sb.AppendFormat("}}\r\n");
|
||||
nCounter++;
|
||||
return nCounter;
|
||||
}
|
||||
void ProcessOnTextNodeFromXml(StringBuilder sb, GenClassPivot oGenClass, List<GenMemberPivot> aMembers)
|
||||
{
|
||||
int nCounter = 0;
|
||||
for (int i = 0; i < aMembers.Count; ++i)
|
||||
{
|
||||
GenMemberPivot oGenMember = aMembers[i];
|
||||
nCounter = ProcessOnTextNodeFromXmlMember(sb, oGenClass, oGenMember, null, nCounter);
|
||||
}
|
||||
}
|
||||
int ProcessOnTextNodeFromXmlMember(StringBuilder sb, GenClassPivot oGenClass, GenMemberPivot oGenMember, GenMemberPivot oGenMemberContainer, int nCounter)
|
||||
{
|
||||
if (0 != nCounter)
|
||||
sb.AppendFormat("else ");
|
||||
sb.AppendFormat("if(\"{0}\" === this._curElem){{\r\n", getNameWithPrefix(oGenClass, oGenMember));
|
||||
|
||||
if (null != oGenMember.oSystemType)
|
||||
{
|
||||
if (oGenMember.nArrayRank.HasValue)
|
||||
{
|
||||
if (oGenMember.nArrayRank > 0)
|
||||
{
|
||||
sb.AppendFormat("this._curArray.push({0});\r\n", ProcessJsTypeFromXml(oGenMember.oSystemType, "text"));
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.AppendFormat("this.{0}.push({1});\r\n", oGenMember.sName, ProcessJsTypeFromXml(oGenMember.oSystemType, "text"));
|
||||
}
|
||||
}
|
||||
else
|
||||
sb.AppendFormat("this.{0} = {1};\r\n", oGenMember.sName, ProcessJsTypeFromXml(oGenMember.oSystemType, "text"));
|
||||
}
|
||||
else if (null != oGenMember.sType)
|
||||
{
|
||||
GenClassPivot oTemp;
|
||||
if (m_mapProcessedClasses.TryGetValue(oGenMember.sType, out oTemp))
|
||||
{
|
||||
if (oTemp.bIsEnum)
|
||||
{
|
||||
sb.AppendFormat("var val = {0}(text);\r\n", gc_sEnumFromXmlPrefix + oTemp.sName);
|
||||
sb.AppendFormat("if(-1 !== val){{\r\n");
|
||||
if (oGenMember.nArrayRank.HasValue)
|
||||
{
|
||||
if (oGenMember.nArrayRank > 0)
|
||||
{
|
||||
sb.AppendFormat("this._curArray.push(val);\r\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.AppendFormat("this.{0}.push(val);\r\n", oGenMember.sName);
|
||||
}
|
||||
}
|
||||
else
|
||||
sb.AppendFormat("this.{0} = val;\r\n", oGenMember.sName);
|
||||
sb.AppendFormat("}}\r\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
sb.AppendFormat("}}\r\n");
|
||||
nCounter++;
|
||||
return nCounter;
|
||||
}
|
||||
void ProcessOnEndNodeFromXml(StringBuilder sb, GenClassPivot oGenClass, List<GenMemberPivot> aMembers)
|
||||
{
|
||||
int nCounter = 0;
|
||||
for (int i = 0; i < aMembers.Count; ++i)
|
||||
{
|
||||
GenMemberPivot oGenMember = aMembers[i];
|
||||
if (oGenMember.nArrayRank > 0)
|
||||
{
|
||||
if (0 != nCounter)
|
||||
sb.AppendFormat("else ");
|
||||
sb.AppendFormat("if(\"{0}\" === elem){{\r\n", getNameWithPrefix(oGenClass, oGenMember));
|
||||
sb.AppendFormat("if(this._curArray && this._curArray.length > 0){{\r\n");
|
||||
sb.AppendFormat("this.{0}.push(this._curArray);\r\n", oGenMember.sName);
|
||||
sb.AppendFormat("this._curArray = null;\r\n");
|
||||
sb.AppendFormat("}}\r\n");
|
||||
sb.AppendFormat("}}\r\n");
|
||||
nCounter++;
|
||||
}
|
||||
}
|
||||
}
|
||||
void ProcessAttributesFromXml(StringBuilder sb, GenClassPivot oGenClass, List<GenMemberPivot> aAttributes)
|
||||
{
|
||||
sb.AppendFormat("if(attr()){{\r\n");
|
||||
sb.AppendFormat("var vals = attr();\r\n");
|
||||
sb.AppendFormat("var val;\r\n");
|
||||
for (int i = 0; i < aAttributes.Count; ++i)
|
||||
{
|
||||
GenMemberPivot oGenMember = aAttributes[i];
|
||||
sb.AppendFormat("val = vals[\"{0}\"];\r\n", getNameWithPrefix(oGenClass, oGenMember));
|
||||
sb.AppendFormat("if(undefined !== val){{\r\n");
|
||||
if (null != oGenMember.oSystemType)
|
||||
{
|
||||
sb.AppendFormat("this.{0} = {1};\r\n", oGenMember.sName, ProcessJsTypeFromXml(oGenMember.oSystemType, "val"));
|
||||
}
|
||||
else if (null != oGenMember.sType)
|
||||
{
|
||||
GenClassPivot oTemp;
|
||||
if (m_mapProcessedClasses.TryGetValue(oGenMember.sType, out oTemp))
|
||||
{
|
||||
if (oTemp.bIsEnum)
|
||||
{
|
||||
sb.AppendFormat("val = {0}(val);\r\n", gc_sEnumFromXmlPrefix + oTemp.sName);
|
||||
sb.AppendFormat("if(-1 !== val){{\r\n");
|
||||
sb.AppendFormat("this.{0} = val;\r\n", oGenMember.sName);
|
||||
sb.AppendFormat("}}\r\n");
|
||||
}
|
||||
//else
|
||||
// sb.AppendFormat("pNewElem->fromXML(oReader);\r\n");
|
||||
}
|
||||
}
|
||||
sb.AppendFormat("}}\r\n");
|
||||
}
|
||||
sb.AppendFormat("}}\r\n");
|
||||
}
|
||||
|
||||
string ProcessJsTypeFromXml(Type oType, string sVal)
|
||||
{
|
||||
string sRes;
|
||||
//todo
|
||||
switch (Type.GetTypeCode(oType))
|
||||
{
|
||||
case TypeCode.Boolean:
|
||||
sRes = "getBoolFromXml(" + sVal + ")";
|
||||
break;
|
||||
case TypeCode.Byte:
|
||||
case TypeCode.SByte:
|
||||
case TypeCode.Int16:
|
||||
case TypeCode.Int32:
|
||||
case TypeCode.Int64:
|
||||
case TypeCode.UInt16:
|
||||
case TypeCode.UInt32:
|
||||
case TypeCode.UInt64:
|
||||
case TypeCode.Single:
|
||||
case TypeCode.Double:
|
||||
sRes = sVal + " - 0";
|
||||
break;
|
||||
default: sRes = "uq(" + sVal + ")"; break;
|
||||
}
|
||||
return sRes;
|
||||
}
|
||||
|
||||
void ProcessToXml(StringBuilder sb, GenClassPivot oGenClass)
|
||||
{
|
||||
List<GenMemberPivot> aAttributes = new List<GenMemberPivot>();
|
||||
List<GenMemberPivot> aMembers = new List<GenMemberPivot>();
|
||||
bool bNeedTextNode = false;
|
||||
bool bNeedDoubleArray = false;
|
||||
InfoFromMember(oGenClass, ref aAttributes, ref aMembers, ref bNeedTextNode, ref bNeedDoubleArray);
|
||||
|
||||
if (oGenClass.isRoot())
|
||||
{
|
||||
sb.AppendFormat("res += \"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"yes\\\"?>\";\r\n");
|
||||
sb.AppendFormat("res += \"<{0}{1}\";\r\n", oGenClass.sRootName, gc_sNamespaceToXml);
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.AppendFormat("res += \"<\";\r\n");
|
||||
sb.AppendFormat("res += name;\r\n");
|
||||
}
|
||||
|
||||
for (int i = 0; i < aAttributes.Count; ++i)
|
||||
{
|
||||
GenMemberPivot oGenMember = aAttributes[i];
|
||||
ProcessMemberToXml(sb, oGenClass, oGenMember, "this." + oGenMember.sName, true);
|
||||
}
|
||||
|
||||
if (aMembers.Count > 0)
|
||||
{
|
||||
sb.AppendFormat("res += \">\";\r\n");
|
||||
for (int i = 0; i < aMembers.Count; ++i)
|
||||
{
|
||||
GenMemberPivot oGenMember = aMembers[i];
|
||||
string sCodeElem;
|
||||
if (oGenMember.nArrayRank > 0)
|
||||
{
|
||||
sb.AppendFormat("for(var i = 0; i < this.{0}.length; ++i){{\r\n", oGenMember.sName);
|
||||
sb.AppendFormat("var elem = this.{0}[i];\r\n", oGenMember.sName);
|
||||
sCodeElem = "elem";
|
||||
}
|
||||
else
|
||||
{
|
||||
sCodeElem = "this." + oGenMember.sName;
|
||||
}
|
||||
if (null != oGenMember.aArrayTypes)
|
||||
{
|
||||
if (false == oGenMember.bIsArrayTypesHidden)
|
||||
{
|
||||
sb.AppendFormat("res += \"<{0}>\";\r\n", getNameWithPrefix(oGenClass, oGenMember));
|
||||
}
|
||||
if (oGenMember.nArrayRank.HasValue)
|
||||
{
|
||||
sb.AppendFormat("for(var j = 0; j < {0}.length; ++j){{\r\n", sCodeElem);
|
||||
sb.AppendFormat("var subelem = {0}[j];\r\n", sCodeElem);
|
||||
for (int j = 0; j < oGenMember.aArrayTypes.Count; ++j)
|
||||
{
|
||||
GenMemberPivot oTempMember = oGenMember.aArrayTypes[j];
|
||||
if (0 != j)
|
||||
sb.AppendFormat("else ");
|
||||
sb.AppendFormat("if(subelem instanceof {0}){{\r\n", oTempMember.sType);
|
||||
sb.AppendFormat("res += subelem.toXml(\"{0}\");\r\n", getNameWithPrefix(oGenClass, oTempMember));
|
||||
sb.AppendFormat("}}\r\n");
|
||||
}
|
||||
sb.AppendFormat("}}\r\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
//right way to store oGenMemberContainer in one object, but we prefer separete types
|
||||
for (int j = 0; j < oGenMember.aArrayTypes.Count; ++j)
|
||||
{
|
||||
GenMemberPivot oTempMember = oGenMember.aArrayTypes[j];
|
||||
ProcessMemberToXml(sb, oGenClass, oTempMember, "this." + oTempMember.sName, true);
|
||||
}
|
||||
}
|
||||
if (false == oGenMember.bIsArrayTypesHidden)
|
||||
{
|
||||
sb.AppendFormat("res += \"</{0}>\";\r\n", getNameWithPrefix(oGenClass, oGenMember));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (oGenMember.nArrayRank.HasValue)
|
||||
{
|
||||
sb.AppendFormat("for(var i = 0; i < {0}.length; ++i){{\r\n", sCodeElem);
|
||||
sb.AppendFormat("var elem = {0}[i];\r\n", sCodeElem);
|
||||
ProcessMemberToXml(sb, oGenClass, oGenMember, "elem", false);
|
||||
sb.AppendFormat("}}\r\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
ProcessMemberToXml(sb, oGenClass, oGenMember, sCodeElem, true);
|
||||
}
|
||||
}
|
||||
if (oGenMember.nArrayRank > 0)
|
||||
{
|
||||
sb.AppendFormat("}}\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (oGenClass.isRoot())
|
||||
{
|
||||
sb.AppendFormat("res += \"</{0}>\";\r\n", oGenClass.sRootName);
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.AppendFormat("res += \"</\";\r\n");
|
||||
sb.AppendFormat("res += name;\r\n");
|
||||
sb.AppendFormat("res += \">\";\r\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
sb.AppendFormat("res += \"/>\";\r\n");
|
||||
}
|
||||
void ProcessMemberToXml(StringBuilder sb, GenClassPivot oGenClass, GenMemberPivot oGenMember, string sElemName, bool checkNull)
|
||||
{
|
||||
string sElemXmlName = getNameWithPrefix(oGenClass, oGenMember);
|
||||
bool bIsAttribute = true == oGenMember.bIsAttribute;
|
||||
|
||||
if (checkNull)
|
||||
{
|
||||
sb.AppendFormat("if(null !== {0}){{\r\n", sElemName);
|
||||
}
|
||||
|
||||
if (null != oGenMember.oSystemType)
|
||||
{
|
||||
if (bIsAttribute)
|
||||
sb.AppendFormat("res += \" {0}=\\\"\";\r\n", sElemXmlName);
|
||||
else
|
||||
sb.AppendFormat("res += \"<{0}>\";\r\n", sElemXmlName);
|
||||
sb.AppendFormat("res += {0};\r\n", ProcessJsTypeToXml(oGenMember.oSystemType, sElemName));
|
||||
if (bIsAttribute)
|
||||
sb.AppendFormat("res += \"\\\"\";\r\n");
|
||||
else
|
||||
sb.AppendFormat("res += \"</{0}>\";\r\n", sElemXmlName);
|
||||
}
|
||||
else if (null != oGenMember.sType)
|
||||
{
|
||||
GenClassPivot oGenClassMember = null;
|
||||
m_mapProcessedClasses.TryGetValue(oGenMember.sType, out oGenClassMember);
|
||||
if (null != oGenClassMember || m_mapProcessedClasses.TryGetValue(oGenMember.sType, out oGenClassMember))
|
||||
{
|
||||
if (oGenClassMember.bIsEnum)
|
||||
{
|
||||
if (bIsAttribute)
|
||||
sb.AppendFormat("res += \" {0}=\\\"\";\r\n", sElemXmlName);
|
||||
else
|
||||
sb.AppendFormat("res += \"<{0}>\";\r\n", sElemXmlName);
|
||||
sb.AppendFormat("res += {0}{1}({2});\r\n", gc_sEnumToXmlPrefix, oGenClassMember.sName, sElemName);
|
||||
if (bIsAttribute)
|
||||
sb.AppendFormat("res += \"\\\"\";\r\n");
|
||||
else
|
||||
sb.AppendFormat("res += \"</{0}>\";\r\n", sElemXmlName);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!bIsAttribute)
|
||||
sb.AppendFormat("res += {0}.toXml(\"{1}\");\r\n", sElemName, sElemXmlName);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (checkNull)
|
||||
{
|
||||
sb.AppendFormat("}}\r\n");
|
||||
}
|
||||
}
|
||||
string ProcessJsTypeToXml(Type oType, string sVal)
|
||||
{
|
||||
string sRes;
|
||||
switch (Type.GetTypeCode(oType))
|
||||
{
|
||||
case TypeCode.Boolean:
|
||||
sRes = "getXmlFromBool(" + sVal + ")";
|
||||
break;
|
||||
case TypeCode.Byte:
|
||||
case TypeCode.SByte:
|
||||
case TypeCode.Int16:
|
||||
case TypeCode.Int32:
|
||||
case TypeCode.Int64:
|
||||
case TypeCode.UInt16:
|
||||
case TypeCode.UInt32:
|
||||
case TypeCode.UInt64:
|
||||
case TypeCode.Single:
|
||||
case TypeCode.Double:
|
||||
sRes = sVal + ".toString()";
|
||||
break;
|
||||
default: sRes = sVal; break;
|
||||
}
|
||||
return sRes;
|
||||
}
|
||||
|
||||
string getNameWithPrefix(GenClassPivot oGenClass, GenMemberPivot oGenMember)
|
||||
{
|
||||
string sShortNamespace = "";
|
||||
if (true == oGenMember.bQualified)
|
||||
{
|
||||
string sMemberNamespace = null;
|
||||
GenClassPivot oGenClassMember = null;
|
||||
if (null != oGenMember.sNamespace)
|
||||
sMemberNamespace = oGenMember.sNamespace;
|
||||
else if (null != oGenMember.sType && m_mapProcessedClasses.TryGetValue(oGenMember.sType, out oGenClassMember))
|
||||
sMemberNamespace = oGenClassMember.sNamespace;
|
||||
else
|
||||
sMemberNamespace = oGenClass.sNamespace;
|
||||
if (null != sMemberNamespace)
|
||||
{
|
||||
Utils.m_mapNamespaceToPrefix.TryGetValue(sMemberNamespace, out sShortNamespace);
|
||||
}
|
||||
}
|
||||
return sShortNamespace + oGenMember.sName;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -45,7 +45,8 @@ namespace codegen
|
||||
static string sDirJsBinOut = @"..\..\gen\";
|
||||
static void Main(string[] args)
|
||||
{
|
||||
(new codegen.CodeGen()).Start(sDirIn, sDirCppXmlOut, sDirCppBinOut, sDirJsBinOut, ValidationCallback);
|
||||
//(new codegen.CodeGen()).Start(sDirIn, sDirCppXmlOut, sDirCppBinOut, sDirJsBinOut, ValidationCallback);
|
||||
(new codegen.CodeGenPivot()).Start(sDirIn, sDirCppXmlOut, sDirCppBinOut, sDirJsBinOut, ValidationCallback);
|
||||
}
|
||||
static void ValidationCallback(object sender, ValidationEventArgs args)
|
||||
{
|
||||
|
||||
@ -5,7 +5,6 @@
|
||||
xmlns="http://purl.oclc.org/ooxml/drawingml/chart"
|
||||
xmlns:cdr="http://purl.oclc.org/ooxml/drawingml/chartDrawing"
|
||||
xmlns:s="http://purl.oclc.org/ooxml/officeDocument/sharedTypes"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
targetNamespace="http://purl.oclc.org/ooxml/drawingml/chart" elementFormDefault="qualified"
|
||||
attributeFormDefault="unqualified" blockDefault="#all">
|
||||
<xsd:import namespace="http://purl.oclc.org/ooxml/officeDocument/relationships"
|
||||
@ -15,7 +14,6 @@
|
||||
schemaLocation="dml-chartDrawing.xsd"/>
|
||||
<xsd:import namespace="http://purl.oclc.org/ooxml/officeDocument/sharedTypes"
|
||||
schemaLocation="shared-commonSimpleTypes.xsd"/>
|
||||
<xsd:import namespace="http://schemas.openxmlformats.org/markup-compatibility/2006" schemaLocation="mce.xsd"/>
|
||||
<xsd:complexType name="CT_Boolean">
|
||||
<xsd:attribute name="val" type="xsd:boolean" use="optional" default="true"/>
|
||||
</xsd:complexType>
|
||||
@ -1432,7 +1430,6 @@
|
||||
<xsd:element name="date1904" type="CT_Boolean" minOccurs="0" maxOccurs="1"/>
|
||||
<xsd:element name="lang" type="CT_TextLanguageID" minOccurs="0" maxOccurs="1"/>
|
||||
<xsd:element name="roundedCorners" type="CT_Boolean" minOccurs="0" maxOccurs="1"/>
|
||||
<xsd:element ref="mc:AlternateContent" minOccurs="0" maxOccurs="1"/>
|
||||
<xsd:element name="style" type="CT_Style" minOccurs="0" maxOccurs="1"/>
|
||||
<xsd:element name="clrMapOvr" type="a:CT_ColorMapping" minOccurs="0" maxOccurs="1"/>
|
||||
<xsd:element name="pivotSource" type="CT_PivotSource" minOccurs="0" maxOccurs="1"/>
|
||||
|
||||
@ -1441,7 +1441,7 @@
|
||||
<xsd:group ref="EG_ShadeProperties" minOccurs="0" maxOccurs="1"/>
|
||||
<xsd:element name="tileRect" type="CT_RelativeRect" minOccurs="0" maxOccurs="1"/>
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="flip" type="ST_TileFlipMode" use="optional"/>
|
||||
<xsd:attribute name="flip" type="ST_TileFlipMode" use="optional" default="none"/>
|
||||
<xsd:attribute name="rotWithShape" type="xsd:boolean" use="optional"/>
|
||||
</xsd:complexType>
|
||||
<xsd:complexType name="CT_TileInfoProperties">
|
||||
@ -1449,7 +1449,7 @@
|
||||
<xsd:attribute name="ty" type="ST_Coordinate" use="optional"/>
|
||||
<xsd:attribute name="sx" type="ST_Percentage" use="optional"/>
|
||||
<xsd:attribute name="sy" type="ST_Percentage" use="optional"/>
|
||||
<xsd:attribute name="flip" type="ST_TileFlipMode" use="optional"/>
|
||||
<xsd:attribute name="flip" type="ST_TileFlipMode" use="optional" default="none"/>
|
||||
<xsd:attribute name="algn" type="ST_RectAlignment" use="optional"/>
|
||||
</xsd:complexType>
|
||||
<xsd:complexType name="CT_StretchInfoProperties">
|
||||
@ -2118,7 +2118,7 @@
|
||||
</xsd:restriction>
|
||||
</xsd:simpleType>
|
||||
<xsd:complexType name="CT_LineEndProperties">
|
||||
<xsd:attribute name="type" type="ST_LineEndType" use="optional"/>
|
||||
<xsd:attribute name="type" type="ST_LineEndType" use="optional" default="none"/>
|
||||
<xsd:attribute name="w" type="ST_LineEndWidth" use="optional"/>
|
||||
<xsd:attribute name="len" type="ST_LineEndLength" use="optional"/>
|
||||
</xsd:complexType>
|
||||
@ -2896,7 +2896,7 @@
|
||||
<xsd:attribute name="u" type="ST_TextUnderlineType" use="optional"/>
|
||||
<xsd:attribute name="strike" type="ST_TextStrikeType" use="optional"/>
|
||||
<xsd:attribute name="kern" type="ST_TextNonNegativePoint" use="optional"/>
|
||||
<xsd:attribute name="cap" type="ST_TextCapsType" use="optional"/>
|
||||
<xsd:attribute name="cap" type="ST_TextCapsType" use="optional" default="none"/>
|
||||
<xsd:attribute name="spc" type="ST_TextPoint" use="optional"/>
|
||||
<xsd:attribute name="normalizeH" type="xsd:boolean" use="optional"/>
|
||||
<xsd:attribute name="baseline" type="ST_Percentage" use="optional"/>
|
||||
|
||||
@ -518,7 +518,7 @@
|
||||
<xsd:element name="cBhvr" type="CT_TLCommonBehaviorData" minOccurs="1" maxOccurs="1"/>
|
||||
<xsd:element name="progress" type="CT_TLAnimVariant" minOccurs="0" maxOccurs="1"/>
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="transition" type="ST_TLAnimateEffectTransition" use="optional"/>
|
||||
<xsd:attribute name="transition" type="ST_TLAnimateEffectTransition" default="in" use="optional"/>
|
||||
<xsd:attribute name="filter" type="xsd:string" use="optional"/>
|
||||
<xsd:attribute name="prLst" type="xsd:string" use="optional"/>
|
||||
</xsd:complexType>
|
||||
|
||||
@ -3374,8 +3374,8 @@
|
||||
</xsd:complexType>
|
||||
<xsd:complexType name="CT_CellAlignment">
|
||||
<xsd:attribute name="horizontal" type="ST_HorizontalAlignment" use="optional"/>
|
||||
<xsd:attribute name="vertical" type="ST_VerticalAlignment" use="optional"/>
|
||||
<xsd:attribute name="textRotation" type="xsd:unsignedInt" use="optional"/>
|
||||
<xsd:attribute name="vertical" type="ST_VerticalAlignment" default="bottom" use="optional"/>
|
||||
<xsd:attribute name="textRotation" type="ST_TextRotation" use="optional"/>
|
||||
<xsd:attribute name="wrapText" type="xsd:boolean" use="optional"/>
|
||||
<xsd:attribute name="indent" type="xsd:unsignedInt" use="optional"/>
|
||||
<xsd:attribute name="relativeIndent" type="xsd:int" use="optional"/>
|
||||
@ -3383,6 +3383,20 @@
|
||||
<xsd:attribute name="shrinkToFit" type="xsd:boolean" use="optional"/>
|
||||
<xsd:attribute name="readingOrder" type="xsd:unsignedInt" use="optional"/>
|
||||
</xsd:complexType>
|
||||
<xsd:simpleType name="ST_TextRotation">
|
||||
<xsd:union>
|
||||
<xsd:simpleType>
|
||||
<xsd:restriction base="xsd:nonNegativeInteger">
|
||||
<xsd:maxInclusive value="180"/>
|
||||
</xsd:restriction>
|
||||
</xsd:simpleType>
|
||||
<xsd:simpleType>
|
||||
<xsd:restriction base="xsd:nonNegativeInteger">
|
||||
<xsd:enumeration value="255"/>
|
||||
</xsd:restriction>
|
||||
</xsd:simpleType>
|
||||
</xsd:union>
|
||||
</xsd:simpleType>
|
||||
<xsd:simpleType name="ST_BorderStyle">
|
||||
<xsd:restriction base="xsd:string">
|
||||
<xsd:enumeration value="none"/>
|
||||
|
||||
@ -42,7 +42,7 @@
|
||||
</xsd:restriction>
|
||||
</xsd:simpleType>
|
||||
<xsd:complexType name="CT_Charset">
|
||||
<xsd:attribute name="characterSet" type="s:ST_String" use="optional"/>
|
||||
<xsd:attribute name="characterSet" type="s:ST_String" use="optional" default="ISO-8859-1"/>
|
||||
</xsd:complexType>
|
||||
<xsd:simpleType name="ST_DecimalNumberOrPercent">
|
||||
<xsd:union memberTypes="s:ST_Percentage"/>
|
||||
@ -185,7 +185,7 @@
|
||||
</xsd:simpleType>
|
||||
<xsd:complexType name="CT_Underline">
|
||||
<xsd:attribute name="val" type="ST_Underline" use="optional"/>
|
||||
<xsd:attribute name="color" type="ST_HexColor" use="optional"/>
|
||||
<xsd:attribute name="color" type="ST_HexColor" use="optional" default="auto"/>
|
||||
<xsd:attribute name="themeColor" type="ST_ThemeColor" use="optional"/>
|
||||
<xsd:attribute name="themeTint" type="ST_UcharHexNumber" use="optional"/>
|
||||
<xsd:attribute name="themeShade" type="ST_UcharHexNumber" use="optional"/>
|
||||
@ -403,12 +403,12 @@
|
||||
</xsd:simpleType>
|
||||
<xsd:complexType name="CT_Border">
|
||||
<xsd:attribute name="val" type="ST_Border" use="required"/>
|
||||
<xsd:attribute name="color" type="ST_HexColor" use="optional"/>
|
||||
<xsd:attribute name="color" type="ST_HexColor" use="optional" default="auto"/>
|
||||
<xsd:attribute name="themeColor" type="ST_ThemeColor" use="optional"/>
|
||||
<xsd:attribute name="themeTint" type="ST_UcharHexNumber" use="optional"/>
|
||||
<xsd:attribute name="themeShade" type="ST_UcharHexNumber" use="optional"/>
|
||||
<xsd:attribute name="sz" type="ST_EighthPointMeasure" use="optional"/>
|
||||
<xsd:attribute name="space" type="ST_PointMeasure" use="optional"/>
|
||||
<xsd:attribute name="space" type="ST_PointMeasure" use="optional" default="0"/>
|
||||
<xsd:attribute name="shadow" type="s:ST_OnOff" use="optional"/>
|
||||
<xsd:attribute name="frame" type="s:ST_OnOff" use="optional"/>
|
||||
</xsd:complexType>
|
||||
@ -594,14 +594,14 @@
|
||||
</xsd:restriction>
|
||||
</xsd:simpleType>
|
||||
<xsd:complexType name="CT_Spacing">
|
||||
<xsd:attribute name="before" type="s:ST_TwipsMeasure" use="optional"/>
|
||||
<xsd:attribute name="beforeLines" type="ST_DecimalNumber" use="optional"/>
|
||||
<xsd:attribute name="beforeAutospacing" type="s:ST_OnOff" use="optional"/>
|
||||
<xsd:attribute name="after" type="s:ST_TwipsMeasure" use="optional"/>
|
||||
<xsd:attribute name="afterLines" type="ST_DecimalNumber" use="optional"/>
|
||||
<xsd:attribute name="afterAutospacing" type="s:ST_OnOff" use="optional"/>
|
||||
<xsd:attribute name="line" type="ST_SignedTwipsMeasure" use="optional"/>
|
||||
<xsd:attribute name="lineRule" type="ST_LineSpacingRule" use="optional"/>
|
||||
<xsd:attribute name="before" type="s:ST_TwipsMeasure" use="optional" default="0"/>
|
||||
<xsd:attribute name="beforeLines" type="ST_DecimalNumber" use="optional" default="0"/>
|
||||
<xsd:attribute name="beforeAutospacing" type="s:ST_OnOff" use="optional" default="off"/>
|
||||
<xsd:attribute name="after" type="s:ST_TwipsMeasure" use="optional" default="0"/>
|
||||
<xsd:attribute name="afterLines" type="ST_DecimalNumber" use="optional" default="0"/>
|
||||
<xsd:attribute name="afterAutospacing" type="s:ST_OnOff" use="optional" default="off"/>
|
||||
<xsd:attribute name="line" type="ST_SignedTwipsMeasure" use="optional" default="0"/>
|
||||
<xsd:attribute name="lineRule" type="ST_LineSpacingRule" use="optional" default="auto"/>
|
||||
</xsd:complexType>
|
||||
<xsd:complexType name="CT_Ind">
|
||||
<xsd:attribute name="start" type="ST_SignedTwipsMeasure" use="optional"/>
|
||||
@ -669,7 +669,7 @@
|
||||
<xsd:attribute name="lang" type="s:ST_Lang" use="required"/>
|
||||
<xsd:attribute name="vendorID" type="s:ST_String" use="required"/>
|
||||
<xsd:attribute name="dllVersion" type="s:ST_String" use="required"/>
|
||||
<xsd:attribute name="nlCheck" type="s:ST_OnOff" use="optional"/>
|
||||
<xsd:attribute name="nlCheck" type="s:ST_OnOff" use="optional" default="off"/>
|
||||
<xsd:attribute name="checkStyle" type="s:ST_OnOff" use="required"/>
|
||||
<xsd:attribute name="appName" type="s:ST_String" use="required"/>
|
||||
</xsd:complexType>
|
||||
@ -1101,7 +1101,7 @@
|
||||
<xsd:sequence>
|
||||
<xsd:element name="drawing" type="CT_Drawing" minOccurs="0"/>
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="color" type="ST_HexColor" use="optional"/>
|
||||
<xsd:attribute name="color" type="ST_HexColor" use="optional" default="auto"/>
|
||||
<xsd:attribute name="themeColor" type="ST_ThemeColor" use="optional"/>
|
||||
<xsd:attribute name="themeTint" type="ST_UcharHexNumber" use="optional"/>
|
||||
<xsd:attribute name="themeShade" type="ST_UcharHexNumber" use="optional"/>
|
||||
@ -1405,9 +1405,9 @@
|
||||
<xsd:element name="bottom" type="CT_BottomPageBorder" minOccurs="0"/>
|
||||
<xsd:element name="right" type="CT_PageBorder" minOccurs="0"/>
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="zOrder" type="ST_PageBorderZOrder" use="optional"/>
|
||||
<xsd:attribute name="zOrder" type="ST_PageBorderZOrder" use="optional" default="front"/>
|
||||
<xsd:attribute name="display" type="ST_PageBorderDisplay" use="optional"/>
|
||||
<xsd:attribute name="offsetFrom" type="ST_PageBorderOffset" use="optional"/>
|
||||
<xsd:attribute name="offsetFrom" type="ST_PageBorderOffset" use="optional" default="text"/>
|
||||
</xsd:complexType>
|
||||
<xsd:complexType name="CT_PageBorder">
|
||||
<xsd:complexContent>
|
||||
@ -1450,27 +1450,27 @@
|
||||
</xsd:simpleType>
|
||||
<xsd:complexType name="CT_LineNumber">
|
||||
<xsd:attribute name="countBy" type="ST_DecimalNumber" use="optional"/>
|
||||
<xsd:attribute name="start" type="ST_DecimalNumber" use="optional"/>
|
||||
<xsd:attribute name="start" type="ST_DecimalNumber" use="optional" default="1"/>
|
||||
<xsd:attribute name="distance" type="s:ST_TwipsMeasure" use="optional"/>
|
||||
<xsd:attribute name="restart" type="ST_LineNumberRestart" use="optional"/>
|
||||
<xsd:attribute name="restart" type="ST_LineNumberRestart" use="optional" default="newPage"/>
|
||||
</xsd:complexType>
|
||||
<xsd:complexType name="CT_PageNumber">
|
||||
<xsd:attribute name="fmt" type="ST_NumberFormat" use="optional"/>
|
||||
<xsd:attribute name="fmt" type="ST_NumberFormat" use="optional" default="decimal"/>
|
||||
<xsd:attribute name="start" type="ST_DecimalNumber" use="optional"/>
|
||||
<xsd:attribute name="chapStyle" type="ST_DecimalNumber" use="optional"/>
|
||||
<xsd:attribute name="chapSep" type="ST_ChapterSep" use="optional"/>
|
||||
<xsd:attribute name="chapSep" type="ST_ChapterSep" use="optional" default="hyphen"/>
|
||||
</xsd:complexType>
|
||||
<xsd:complexType name="CT_Column">
|
||||
<xsd:attribute name="w" type="s:ST_TwipsMeasure" use="optional"/>
|
||||
<xsd:attribute name="space" type="s:ST_TwipsMeasure" use="optional"/>
|
||||
<xsd:attribute name="space" type="s:ST_TwipsMeasure" use="optional" default="0"/>
|
||||
</xsd:complexType>
|
||||
<xsd:complexType name="CT_Columns">
|
||||
<xsd:sequence minOccurs="0">
|
||||
<xsd:element name="col" type="CT_Column" maxOccurs="45"/>
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="equalWidth" type="s:ST_OnOff" use="optional"/>
|
||||
<xsd:attribute name="space" type="s:ST_TwipsMeasure" use="optional"/>
|
||||
<xsd:attribute name="num" type="ST_DecimalNumber" use="optional"/>
|
||||
<xsd:attribute name="space" type="s:ST_TwipsMeasure" use="optional" default="720"/>
|
||||
<xsd:attribute name="num" type="ST_DecimalNumber" use="optional" default="1"/>
|
||||
<xsd:attribute name="sep" type="s:ST_OnOff" use="optional"/>
|
||||
</xsd:complexType>
|
||||
<xsd:simpleType name="ST_VerticalJc">
|
||||
@ -1713,7 +1713,6 @@
|
||||
<xsd:restriction base="xsd:string">
|
||||
<xsd:enumeration value="default"/>
|
||||
<xsd:enumeration value="eastAsia"/>
|
||||
<xsd:enumeration value="cs"/>
|
||||
</xsd:restriction>
|
||||
</xsd:simpleType>
|
||||
<xsd:simpleType name="ST_Theme">
|
||||
@ -1941,7 +1940,7 @@
|
||||
<xsd:sequence>
|
||||
<xsd:element name="listItem" type="CT_SdtListItem" minOccurs="0" maxOccurs="unbounded"/>
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="lastValue" type="s:ST_String" use="optional"/>
|
||||
<xsd:attribute name="lastValue" type="s:ST_String" use="optional" default=""/>
|
||||
</xsd:complexType>
|
||||
<xsd:complexType name="CT_SdtDocPart">
|
||||
<xsd:sequence>
|
||||
@ -1954,7 +1953,7 @@
|
||||
<xsd:sequence>
|
||||
<xsd:element name="listItem" type="CT_SdtListItem" minOccurs="0" maxOccurs="unbounded"/>
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="lastValue" type="s:ST_String" use="optional"/>
|
||||
<xsd:attribute name="lastValue" type="s:ST_String" use="optional" default=""/>
|
||||
</xsd:complexType>
|
||||
<xsd:complexType name="CT_Placeholder">
|
||||
<xsd:sequence>
|
||||
|
||||
@ -45,6 +45,7 @@ namespace codegen
|
||||
public static string gc_sSerToBinEnumPrefix = "c_oSer";
|
||||
public static string gc_sItemsChoiceType = "ItemsChoiceType";
|
||||
public static string gc_sItemsElementName = "ItemsElementName";
|
||||
public static Dictionary<string, string> m_mapNamespaceToPrefix = new Dictionary<string, string>() { { "http://purl.oclc.org/ooxml/drawingml/chart", "c:" }, { "http://purl.oclc.org/ooxml/drawingml/main", "a:" }, { "http://purl.oclc.org/ooxml/officeDocument/relationships", "r:" }, { "http://schemas.openxmlformats.org/markup-compatibility/2006", "mc:" }, { "http://schemas.microsoft.com/office/drawing/2007/8/2/chart", "c14:" } };
|
||||
public static string GetEnumElemName(string sEnumName, string sElemName)
|
||||
{
|
||||
return sEnumName.ToLower() + sElemName.ToUpper();
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
@ -10,8 +10,29 @@
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>codepeg2</RootNamespace>
|
||||
<AssemblyName>codepeg2</AssemblyName>
|
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<FileUpgradeFlags>
|
||||
</FileUpgradeFlags>
|
||||
<UpgradeBackupLocation>
|
||||
</UpgradeBackupLocation>
|
||||
<OldToolsVersion>3.5</OldToolsVersion>
|
||||
<TargetFrameworkProfile />
|
||||
<PublishUrl>publish\</PublishUrl>
|
||||
<Install>true</Install>
|
||||
<InstallFrom>Disk</InstallFrom>
|
||||
<UpdateEnabled>false</UpdateEnabled>
|
||||
<UpdateMode>Foreground</UpdateMode>
|
||||
<UpdateInterval>7</UpdateInterval>
|
||||
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
||||
<UpdatePeriodically>false</UpdatePeriodically>
|
||||
<UpdateRequired>false</UpdateRequired>
|
||||
<MapFileExtensions>true</MapFileExtensions>
|
||||
<ApplicationRevision>0</ApplicationRevision>
|
||||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
@ -21,6 +42,7 @@
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
@ -29,6 +51,7 @@
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
@ -48,11 +71,14 @@
|
||||
<Compile Include="CodeGen.cs" />
|
||||
<Compile Include="CodegenCPP.cs" />
|
||||
<Compile Include="CodegenJS.cs" />
|
||||
<Compile Include="CodegenJSPivot.cs" />
|
||||
<Compile Include="CodeGenPivot.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Utils.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
<None Include="Resource\chart20070802.xsd" />
|
||||
<None Include="Resource\dml-chart.xsd" />
|
||||
<None Include="Resource\dml-chartDrawing.xsd" />
|
||||
@ -77,6 +103,13 @@
|
||||
<None Include="Resource\sml.xsd" />
|
||||
<None Include="Resource\wml.xsd" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1</ProductName>
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
||||
Reference in New Issue
Block a user