Compare commits

...

14 Commits

Author SHA1 Message Date
fecfcfa7d2 . 2017-04-24 14:32:57 +03:00
29b5fa513a . 2017-04-24 13:26:50 +03:00
f9a19badbf DocFormatReader - fix embedded docx formula 2017-04-24 13:20:23 +03:00
d2630ea73c toXml - writer instead string; refreshedDate 2017-04-24 10:54:56 +03:00
a4a58c4782 x2t version up 2017-04-24 10:33:47 +03:00
29a3d80071 . 2017-04-23 16:36:12 +03:00
598bb419c0 OdfFormatWriter - presentation - fields 2017-04-23 16:31:00 +03:00
087da9d2ce . 2017-04-23 14:21:07 +03:00
c505aced48 . 2017-04-22 18:34:10 +03:00
959d5e5fcd OdfFormatWriter - presentation - fix multi-level list, master list styles 2017-04-22 13:05:10 +03:00
8ee0cf4b2c . 2017-04-21 19:26:01 +03:00
426342074e . 2017-04-21 19:08:59 +03:00
d2c092fe62 pivot 2017-04-21 15:05:23 +03:00
a336917338 OdfFormatWriter - image bullet presentation list style 2017-04-21 14:12:50 +03:00
41 changed files with 2203 additions and 622 deletions

View File

@ -136,14 +136,18 @@ namespace DocFileFormat
}
return btWin32;
}
bool ParseEmbeddedEquation( const std::string & xmlString, std::wstring & newXmlString)
bool VMLPictureMapping::ParseEmbeddedEquation( const std::string & xmlString, std::wstring & newXmlString)
{
newXmlString.clear();
std::wstring sTempXmlFile = NSDirectory::CreateTempFileWithUniqueName(
NSDirectory::GetTempPath(), L"emb");
sTempXmlFile += L".xml";
std::wstring sTempFolder = m_ctx->_doc->m_sTempFolder;
if (sTempFolder.empty())
{
sTempFolder = NSFile::CFileBinary::GetTempPath();
}
std::wstring sTempXmlFile = NSDirectory::CreateTempFileWithUniqueName(sTempFolder, L"emb");
NSFile::CFileBinary file;
file.CreateFileW(sTempXmlFile);
file.WriteFile((BYTE*)xmlString.c_str(), xmlString.size());
@ -186,6 +190,7 @@ namespace DocFileFormat
if (res) break;
}
}
NSFile::CFileBinary::Remove(sTempXmlFile);
return res;
}
//---------------------------------------------------------------
@ -297,8 +302,13 @@ namespace DocFileFormat
case metroBlob:
{
//встроенная неведомая хуйня
m_isEmbedded = true;
m_embeddedData = std::string((char*)iter->opComplex, iter->op);
m_isEmbedded = true;
m_embeddedData = std::string((char*)iter->opComplex, iter->op);
//if (ParseEmbeddedBlob( m_embeddedData, m_blobXml)) // todoooo
//{
// m_isEmbedded = false;
//}
}break;
//BORDERS
case borderBottomColor:

View File

@ -46,7 +46,6 @@ namespace DocFileFormat
{
class OleObject;
bool ParseEmbeddedEquation( const std::string & xmlString, std::wstring & newXmlString );
class VMLPictureMapping: public PropertiesMapping, public IMapping
{
@ -58,6 +57,7 @@ namespace DocFileFormat
/// Writes a border element
void writePictureBorder (const std::wstring & name, const BorderCode* brc);
void appendStyleProperty( std::wstring* b, const std::wstring& propName, const std::wstring& propValue ) const;
bool ParseEmbeddedEquation( const std::string & xmlString, std::wstring & newXmlString );
protected:
/// Copies the picture from the binary stream to the zip archive
/// and creates the relationships for the image.

View File

@ -86,6 +86,7 @@ namespace DocFileFormat
friend class Table;
friend class TableRow;
friend class VMLShapeMapping;
friend class VMLPictureMapping;
friend class OpenXmlPackage;
friend class TextboxMapping;

View File

@ -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

View File

@ -289,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;

View File

@ -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();

View File

@ -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++)
{

View File

@ -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 ();

View File

@ -108,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;
@ -120,14 +120,13 @@ void odf_lists_styles_context::start_style(int based_number)
{
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);
state.automatic = true; //document automatic style
}
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 = false; //office style
}
state.automatic = !bMaster;
text_list_style *style = dynamic_cast<text_list_style *>(elm.get());
if (style == NULL)return;
@ -560,8 +559,8 @@ void odf_lists_styles_context::set_bullet_image_size(double size)
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)
{
@ -574,9 +573,9 @@ 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)
{

View File

@ -64,7 +64,7 @@ public:
odf_lists_styles_context();
void set_odf_context(odf_conversion_context * Context);
void start_style(int abstract_number = -1);
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();

View File

@ -154,13 +154,35 @@ void odf_text_context::add_text_content(const std::wstring & text)
std::wstring last = text.substr(pos);
if (last.length() > 0)current_level_.back().elm->add_text(last);
}
void odf_text_context::add_text_date(const std::wstring & text)
{
office_element_ptr s_elm;
create_element(L"text", L"date", s_elm, odf_context_);
text_date* s = dynamic_cast<text_date*>(s_elm.get());
if (s) s->add_text(text);
if (current_level_.size()>0)
current_level_.back().elm->add_child_element(s_elm);
}
void odf_text_context::add_text_page_number(const std::wstring & text)
{
office_element_ptr s_elm;
create_element(L"text", L"page-number", s_elm, odf_context_);
text_page_number* s = dynamic_cast<text_page_number*>(s_elm.get());
if (s) s->add_text(text);
if (current_level_.size()>0)
current_level_.back().elm->add_child_element(s_elm);
}
void odf_text_context::add_text_space(int count)
{
office_element_ptr s_elm;
create_element(L"text", L"s", s_elm, odf_context_);
text_s* s = dynamic_cast<text_s*>(s_elm.get());
if (s)s->text_c_ = count;
if (s) s->text_c_ = count;
//необязательно хранить..
//int level = current_level_.size();

View File

@ -67,8 +67,10 @@ public:
void add_text_content (const std::wstring & text);
void add_text_space (int count);
void set_symbol_font (const std::wstring & font);
void add_text_date (const std::wstring & text);
void add_text_page_number(const std::wstring & text);
void set_symbol_font (const std::wstring & font);
void set_symbol_text (int sym);
void start_paragraph (bool styled = false);

View File

@ -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;

View File

@ -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 ();

View File

@ -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.;

View File

@ -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);

View File

@ -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)
{

View File

@ -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 ();

View File

@ -208,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);
@ -1096,16 +1100,7 @@ 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)
@ -1120,18 +1115,19 @@ void OoxConverter::convert_list_level(PPTX::Logic::TextParagraphPr *oox_para_pro
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 type = 13;
int pptx_type = buAutoNum.type.GetBYTECode();
if ( pptx_type < 3) type = 46;
if (pptx_type > 2 && pptx_type < 6) type = 60;
if (pptx_type > 28 && pptx_type < 32) type = 47;
if (pptx_type > 31 && pptx_type < 35) type = 61;
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, type);
odf_context()->styles_context()->lists_styles().start_style_level(level, odf_list_type);
if (buAutoNum.startAt.IsInit())
{
@ -1142,18 +1138,48 @@ void OoxConverter::convert_list_level(PPTX::Logic::TextParagraphPr *oox_para_pro
}
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, 5 );
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);
odf_context()->styles_context()->lists_styles().start_style_level(level, 1000 );
odf_context()->styles_context()->lists_styles().set_bullet_image(odf_context()->mediaitems()->items().back().odf_ref);
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();
@ -1162,10 +1188,10 @@ void OoxConverter::convert_list_level(PPTX::Logic::TextParagraphPr *oox_para_pro
convert(oox_para_props->defRPr.GetPointer(), text_properties);
if (oox_para_props->indent.IsInit())
if (oox_para_props->indent.IsInit() && level_props)
{
level_props->text_space_before_ = odf_types::length(- oox_para_props->indent.get() / 12700., odf_types::length::pt);
level_props->text_min_label_width_ = odf_types::length(1, odf_types::length::pt);
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
{
@ -1189,29 +1215,71 @@ void OoxConverter::convert_list_level(PPTX::Logic::TextParagraphPr *oox_para_pro
{
int res = 0;
if ((res = hexColor.find(L"#")) < 0) hexColor = std::wstring(L"#") + hexColor;
text_properties->content_.fo_color_ = odf_types::color(hexColor);
if (text_properties) text_properties->content_.fo_color_ = odf_types::color(hexColor);
}
}
if (oox_para_props->buSize.is<PPTX::Logic::BuSzTx>())
{
const PPTX::Logic::BuSzTx & buSzTx = oox_para_props->buSize.as<PPTX::Logic::BuSzTx>();
}
else 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())
text_properties->content_.fo_font_size_ = odf_types::percent(*buSzPct.val / 1000.);
}
else
text_properties->content_.fo_font_size_ = odf_types::percent(100.);
//-----------------------------------
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())
text_properties->content_.fo_font_size_ = odf_types::length(*buSzPts.val, odf_types::length::pt);
{
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 if (oox_para_props->buTypeface.is<PPTX::Logic::BuFontTx>())
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>();
}
@ -1221,45 +1289,41 @@ void OoxConverter::convert_list_level(PPTX::Logic::TextParagraphPr *oox_para_pro
std::wstring font = textFont.typeface;
convert_font(theme, font);
if (!font.empty()) text_properties->content_.fo_font_family_ = 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_list (PPTX::Logic::TextListStyle *oox_list_style)
{
if (!oox_list_style) return;
odf_context()->styles_context()->lists_styles().start_style();
for (int i = 0; i < 9; i++)
{
convert_list_level(oox_list_style->levels[0].GetPointer(), i);
}
odf_context()->styles_context()->lists_styles().end_style();
}
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_paragraph->pPr->lvl.IsInit())
if (oox_paragraph->pPr.IsInit())
{
list_level = *oox_paragraph->pPr->lvl;
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 && list_level >= 0 && list_level < 10)
if (oox_list_style)
{
if (oox_list_style->levels[list_level].IsInit())
oox_list_style->levels[list_level]->Merge(paraPr);
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);
@ -1274,7 +1338,6 @@ void OoxConverter::convert(PPTX::Logic::Paragraph *oox_paragraph, PPTX::Logic::T
list_present = true;
if (paraPr->ParagraphBullet.is<PPTX::Logic::BuNone>())
list_present = false;
else if (list_level == 0) list_level = 1;
}
//свойства могут быть приписаны не только к параграфу, но и к самому объекту
odf_writer::style_paragraph_properties* paragraph_properties = odf_context()->text_context()->get_paragraph_properties();
@ -1310,26 +1373,32 @@ void OoxConverter::convert(PPTX::Logic::Paragraph *oox_paragraph, PPTX::Logic::T
odf_context()->text_context()->list_state_.style_name = L"";
}
if (odf_context()->text_context()->list_state_.started_list == false)
if (list_local)
{
odf_context()->styles_context()->lists_styles().start_style();
convert_list_level(paraPr.GetPointer(), list_level - 1);
_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
list_style_name = odf_context()->styles_context()->lists_styles().get_style_name();
odf_context()->text_context()->start_list(list_style_name);
}
odf_context()->text_context()->start_list_item();
list_level++;
if (odf_context()->text_context()->list_state_.style_name == list_style_name)
list_style_name = L"";
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)
{
@ -1343,10 +1412,10 @@ void OoxConverter::convert(PPTX::Logic::Paragraph *oox_paragraph, PPTX::Logic::T
}
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)
@ -1658,6 +1727,45 @@ void OoxConverter::convert(PPTX::Logic::Run *oox_run)
void OoxConverter::convert(PPTX::Logic::Fld *oox_fld)
{
if (!oox_fld) return;
bool styled = false;
if (oox_fld->rPr.IsInit())
{
odf_writer::style_text_properties * text_properties = odf_context()->text_context()->get_text_properties();
if (!text_properties)
{
odf_context()->styles_context()->create_style(L"", odf_types::style_family::Text, true, false, -1);
text_properties = odf_context()->styles_context()->last_state()->get_text_properties();
styled = true;
}
convert(oox_fld->rPr.GetPointer(), text_properties);
}
odf_context()->text_context()->start_span(styled);
std::wstring fld_type = oox_fld->type.get_value_or(L"");
if ((oox_fld->rPr.IsInit()) && (oox_fld->rPr->hlinkClick.IsInit()) && (oox_fld->rPr->hlinkClick->id.IsInit()))
{
std::wstring hlink = find_link_by_id(oox_fld->rPr->hlinkClick->id.get(), 2);
odf_context()->text_context()->add_hyperlink(hlink, oox_fld->GetText());
}
else if (fld_type == L"slidenum")
{
odf_context()->text_context()->add_text_page_number( oox_fld->GetText());
}
else if (fld_type == L"datetime1")
{
odf_context()->text_context()->add_text_date( oox_fld->GetText());
}
else
{
odf_context()->text_context()->add_text_content( oox_fld->GetText());
}
odf_context()->text_context()->end_span();
}
void OoxConverter::convert(PPTX::Logic::Br *oox_br)
{
@ -1684,7 +1792,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;
@ -1692,6 +1813,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());

View File

@ -405,9 +405,9 @@ public:
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::TextListStyle *oox_list_style);
void convert_list_level (PPTX::Logic::TextParagraphPr *oox_para_props, int level);
void convert_list (PPTX::Logic::TextListStyle *oox_list_style);
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);

View File

@ -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;
@ -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)
{

View File

@ -259,6 +259,8 @@ void PptxConverter::convert_styles()
odp_context->page_layout_context()->create_layer_sets();
}
void PptxConverter::convert_settings()
{
@ -317,12 +319,15 @@ void PptxConverter::convert_slides()
if (pFind == m_mapMasters.end())
{
master_style_name = L"MasterPage";
if (bShowMasterSp)
{
if (slide->Master->cSld.attrName.IsInit()) master_style_name = slide->Master->cSld.attrName.get();
else if (current_theme->name.IsInit()) master_style_name = current_theme->name.get();
}
bool bShowLayoutMasterAnim = slide->Layout->showMasterPhAnim.get_value_or(true);
bool bShowLayoutMasterSp = slide->Layout->showMasterSp.get_value_or(true);
if (slide->Master->cSld.attrName.IsInit()) master_style_name = slide->Master->cSld.attrName.get();
else if (current_theme->name.IsInit()) master_style_name = current_theme->name.get();
master_style_name += L"_" ;
if (slide->Layout->cSld.attrName.IsInit()) master_style_name += slide->Layout->cSld.attrName.get();
else if (slide->Layout->attrType.IsInit()) master_style_name += slide->Layout->attrType->get();
else
@ -332,7 +337,8 @@ void PptxConverter::convert_slides()
convert_common();
current_slide = slide->Master.operator->();
if (bShowMasterSp)
if (bShowLayoutMasterSp && bShowMasterSp)
convert_slide(&slide->Master->cSld, current_txStyles, false);
else
convert(slide->Master->cSld.bg.GetPointer());
@ -340,7 +346,9 @@ void PptxConverter::convert_slides()
if (slide->Layout->clrMapOvr.IsInit() && slide->Layout->clrMapOvr->overrideClrMapping.IsInit())
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 +387,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->());
@ -946,63 +954,86 @@ void PptxConverter::convert_slide(PPTX::Logic::CSld *oox_slide, PPTX::Logic::TxS
odp_context->current_slide().set_page_name(oox_slide->attrName.get());
convert(oox_slide->bg.GetPointer());
bool bMaster = *odf_context()->drawing_context()->get_presentation();
for (size_t i = 0 ; i < oox_slide->spTree.SpTreeElems.size(); i++)
{
smart_ptr<PPTX::WrapperWritingElement> pElem = oox_slide->spTree.SpTreeElems[i].GetElem();
smart_ptr<PPTX::Logic::Shape> pShape = pElem.smart_dynamic_cast<PPTX::Logic::Shape>();
if (pShape.IsInit() && pShape->nvSpPr.nvPr.ph.is_init())
if (pShape.IsInit())
{
pShape->FillLevelUp();
if (!bPlaceholders)
continue;
PPTX::Logic::TextListStyle * listMasterStyle = NULL;
if (txStyles)
if (pShape->nvSpPr.nvPr.ph.is_init())
{
std::wstring type = pShape->nvSpPr.nvPr.ph->type.get_value_or(_T("body"));
if ((type == L"title") || (type == L"ctrTitle"))
listMasterStyle = txStyles->titleStyle.GetPointer();
else if ((type == L"body") || (type == L"subTitle") || (type == L"obj"))
listMasterStyle = txStyles->bodyStyle.GetPointer();
else if (type != L"")
listMasterStyle = txStyles->otherStyle.GetPointer();
}
PPTX::Logic::Shape update_shape;
if (listMasterStyle)
{
update_shape.txBody = new PPTX::Logic::TxBody();
pShape->FillLevelUp();
PPTX::Logic::TextListStyle *newListStyle = new PPTX::Logic::TextListStyle();
for (int i = 0; i < 10; i++)
if (pShape->nvSpPr.nvPr.ph->type.IsInit())
{
if(listMasterStyle->levels[i].is_init())
listMasterStyle->levels[i]->Merge(newListStyle->levels[i]);
int ph_type = pShape->nvSpPr.nvPr.ph->type->GetBYTECode();
if (!bMaster && (ph_type == 5 || ph_type == 6 || ph_type == 7 || ph_type == 12))
continue;
odf_context()->drawing_context()->set_placeholder_type(ph_type);
}
update_shape.txBody->lstStyle.reset(newListStyle);
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;
PPTX::Logic::TextListStyle * listMasterStyle = NULL;
if (txStyles)
{
std::wstring type = pShape->nvSpPr.nvPr.ph->type.get_value_or(_T("body"));
if ((type == L"title") || (type == L"ctrTitle"))
listMasterStyle = txStyles->titleStyle.GetPointer();
else if ((type == L"body") || (type == L"subTitle") || (type == L"obj"))
listMasterStyle = txStyles->bodyStyle.GetPointer();
else if (type != L"")
listMasterStyle = txStyles->otherStyle.GetPointer();
}
PPTX::Logic::Shape update_shape;
if (listMasterStyle)
{
update_shape.txBody = new PPTX::Logic::TxBody();
PPTX::Logic::TextListStyle *newListStyle = new PPTX::Logic::TextListStyle();
for (int i = 0; i < 10; i++)
{
if(listMasterStyle->levels[i].is_init())
listMasterStyle->levels[i]->Merge(newListStyle->levels[i]);
}
update_shape.txBody->lstStyle.reset(newListStyle);
}
pShape->Merge(update_shape);
OoxConverter::convert(&update_shape);
}
pShape->Merge(update_shape);
else if (pShape->txBody.IsInit() && presentation->defaultTextStyle.IsInit())
{//default text style with master clrScheme
PPTX::Logic::Shape update_shape;
update_shape.txBody = new PPTX::Logic::TxBody();
//if (pShape->IsListStyleEmpty() == false)
//{
// //create list style
//}else if (listMasterStyle)
//{
//}
presentation->defaultTextStyle->Merge(update_shape.txBody->lstStyle);
OoxConverter::convert(&update_shape);
pShape->Merge(update_shape);
OoxConverter::convert(&update_shape);
}
else
OoxConverter::convert(pShape.operator->());
}
else
{
OoxConverter::convert(pElem.operator->());
}
//convert(oox_slide->spTree.SpTreeElems[i].GetElem().operator->());
}
convert(oox_slide->controls.GetPointer());
}
@ -1030,7 +1061,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();

View File

@ -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;

View File

@ -457,13 +457,8 @@ namespace PPTX
if (txBody.IsInit() == false) return true;
if (txBody->lstStyle.IsInit() == false) return true;
for (int i = 0; i < 10; i++)
{
if (txBody->lstStyle->levels[i].IsInit())
return false;
}
return true;
return txBody->lstStyle->IsListStyleEmpty();
}
void Shape::Merge(Shape& shape, bool bIsSlidePlaceholder)

View File

@ -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
{

View File

@ -156,6 +156,15 @@ namespace PPTX
}
}
}
if (pShape->nvSpPr.nvPr.ph->idx.IsInit())
{
//not found in layout !! 100818_건강보험과_보건의료_김용익_최종.pptx
if (Master.IsInit())
{
Master->GetLevelUp(pShape);
}
}
}
}
virtual std::wstring GetMediaFullPathNameFromRId(const OOX::RId& rid)const

View File

@ -9,23 +9,343 @@
#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")
#pragma comment (lib, "Advapi32.lib")
//#define ENUMS_CERTS
class CXmlCanonicalizator
{
private:
class CXmlBuffer
{
public:
NSStringUtils::CStringBuilderA builder;
public:
CXmlBuffer()
{
}
~CXmlBuffer()
{
}
};
static int buffer_xmlBufferIOWrite(CXmlBuffer* buf, const char* buffer, int len)
{
buf->builder.WriteString(buffer, (size_t)len);
return len;
}
static int buffer_xmlBufferIOClose(CXmlBuffer* buf)
{
return 0;
}
static int buffer_xmlC14NIsVisibleCallback(void * user_data, xmlNodePtr node, xmlNodePtr parent)
{
if (node->type == XML_TEXT_NODE)
{
const char* cur = (char*)node->content;
size_t size = strlen(cur);
for (size_t i = 0; i < size; ++i, ++cur)
{
if (*cur != '\n' && *cur != '\r' && *cur != '\t')
return 1;
}
return 0;
}
return 1;
}
public:
static std::string Execute(const std::string& sXml, int mode)
{
xmlDocPtr xmlDoc = xmlParseMemory((char*)sXml.c_str(), (int)sXml.length());
CXmlBuffer bufferC14N;
xmlOutputBufferPtr _buffer = xmlOutputBufferCreateIO((xmlOutputWriteCallback)buffer_xmlBufferIOWrite,
(xmlOutputCloseCallback)buffer_xmlBufferIOClose,
&bufferC14N,
NULL);
xmlC14NExecute(xmlDoc, buffer_xmlC14NIsVisibleCallback, NULL, mode, NULL, 0, _buffer);
xmlOutputBufferClose(_buffer);
return bufferC14N.builder.GetData();
}
static std::string Execute(const std::wstring& sXmlFile, int mode)
{
std::string sXml;
NSFile::CFileBinary::ReadAllTextUtf8A(sXmlFile, sXml);
xmlDocPtr xmlDoc = xmlParseMemory((char*)sXml.c_str(), (int)sXml.length());
return Execute(sXml, mode);
}
};
class CXmlSigner
{
private:
PCCERT_CONTEXT m_context;
HCRYPTPROV m_hCryptProv;
public:
CXmlSigner(PCCERT_CONTEXT pCertContext)
{
m_context = pCertContext;
m_hCryptProv = NULL;
}
~CXmlSigner()
{
if (NULL != m_hCryptProv)
CryptReleaseContext(m_hCryptProv, 0);
}
public:
std::string Sign(std::string sXml)
{
BOOL bResult = TRUE;
DWORD dwKeySpec = 0;
HCRYPTHASH hHash = NULL;
if (NULL == m_hCryptProv)
bResult = CryptAcquireCertificatePrivateKey(m_context, 0, NULL, &m_hCryptProv, &dwKeySpec, NULL);
if (!bResult)
return "";
bResult = CryptCreateHash(m_hCryptProv, CALG_SHA1, 0, 0, &hHash);
if (!bResult)
return "";
bResult = CryptHashData(hHash, (BYTE*)sXml.c_str(), (DWORD)sXml.length(), 0);
if (!bResult)
{
CryptDestroyHash(hHash);
return "";
}
DWORD dwSigLen = 0;
BYTE* pbSignature = NULL;
bResult = CryptSignHash(hHash, dwKeySpec, NULL, 0, NULL, &dwSigLen);
if (!bResult)
{
CryptDestroyHash(hHash);
return "";
}
pbSignature = new BYTE[dwSigLen];
bResult = CryptSignHash(hHash, dwKeySpec, NULL, 0, pbSignature, &dwSigLen);
if (!bResult)
{
CryptDestroyHash(hHash);
return "";
}
BYTE* pbSignatureMem = new BYTE[dwSigLen];
ConvertEndian(pbSignature, pbSignatureMem, dwSigLen);
char* pBase64 = NULL;
int nBase64Len = 0;
NSFile::CBase64Converter::Encode(pbSignatureMem, (int)dwSigLen, pBase64, nBase64Len, NSBase64::B64_BASE64_FLAG_NONE);
delete[] pbSignature;
delete[] pbSignatureMem;
bResult = CryptDestroyHash(hHash);
std::string sReturn(pBase64, nBase64Len);
delete[] pBase64;
return sReturn;
}
std::string GetHash(std::string& sXml)
{
BOOL bResult = TRUE;
DWORD dwKeySpec = 0;
HCRYPTHASH hHash = NULL;
if (NULL == m_hCryptProv)
bResult = CryptAcquireCertificatePrivateKey(m_context, 0, NULL, &m_hCryptProv, &dwKeySpec, NULL);
if (!bResult)
return "";
bResult = CryptCreateHash(m_hCryptProv, CALG_SHA1, 0, 0, &hHash);
if (!bResult)
return "";
bResult = CryptHashData(hHash, (BYTE*)sXml.c_str(), (DWORD)sXml.length(), 0);
if (!bResult)
{
CryptDestroyHash(hHash);
return "";
}
DWORD cbHashSize = 0, dwCount = sizeof(DWORD);
bResult = CryptGetHashParam(hHash, HP_HASHSIZE, (BYTE*)&cbHashSize, &dwCount, 0);
if (!bResult)
{
CryptDestroyHash(hHash);
return "";
}
BYTE* pDataHashRaw = new BYTE[dwCount];
bResult = CryptGetHashParam(hHash, HP_HASHVAL, pDataHashRaw, &cbHashSize, 0);
delete[] pDataHashRaw;
CryptDestroyHash(hHash);
if (!bResult)
return "";
char* pBase64_hash = NULL;
int nBase64Len_hash = 0;
NSFile::CBase64Converter::Encode(pDataHashRaw, (int)cbHashSize, pBase64_hash, nBase64Len_hash, NSBase64::B64_BASE64_FLAG_NOCRLF);
std::string sReturn(pBase64_hash, nBase64Len_hash);
delete [] pBase64_hash;
return sReturn;
}
std::string GetHash(std::wstring& sXmlFile)
{
BOOL bResult = TRUE;
DWORD dwKeySpec = 0;
HCRYPTHASH hHash = NULL;
if (NULL == m_hCryptProv)
bResult = CryptAcquireCertificatePrivateKey(m_context, 0, NULL, &m_hCryptProv, &dwKeySpec, NULL);
if (!bResult)
return "";
BYTE* pFileData = NULL;
DWORD dwFileDataLen = 0;
NSFile::CFileBinary::ReadAllBytes(sXmlFile, &pFileData, dwFileDataLen);
if (0 == dwFileDataLen)
return "";
bResult = CryptCreateHash(m_hCryptProv, CALG_SHA1, 0, 0, &hHash);
if (!bResult)
{
RELEASEARRAYOBJECTS(pFileData);
return "";
}
bResult = CryptHashData(hHash, pFileData, dwFileDataLen, 0);
if (!bResult)
{
RELEASEARRAYOBJECTS(pFileData);
CryptDestroyHash(hHash);
return "";
}
DWORD cbHashSize = 0, dwCount = sizeof(DWORD);
bResult = CryptGetHashParam(hHash, HP_HASHSIZE, (BYTE*)&cbHashSize, &dwCount, 0);
if (!bResult)
{
RELEASEARRAYOBJECTS(pFileData);
CryptDestroyHash(hHash);
return "";
}
RELEASEARRAYOBJECTS(pFileData);
BYTE* pDataHashRaw = new BYTE[dwCount];
bResult = CryptGetHashParam(hHash, HP_HASHVAL, pDataHashRaw, &cbHashSize, 0);
delete[] pDataHashRaw;
CryptDestroyHash(hHash);
if (!bResult)
return "";
char* pBase64_hash = NULL;
int nBase64Len_hash = 0;
NSFile::CBase64Converter::Encode(pDataHashRaw, (int)cbHashSize, pBase64_hash, nBase64Len_hash, NSBase64::B64_BASE64_FLAG_NOCRLF);
std::string sReturn(pBase64_hash, nBase64Len_hash);
delete [] pBase64_hash;
return sReturn;
}
BOOL Verify(std::string& sXml, std::string& sXmlSignature)
{
DWORD dwKeySpec = 0;
HCRYPTHASH hHash = NULL;
HCRYPTKEY hPubKey = NULL;
BOOL bResult = TRUE;
if (NULL == m_hCryptProv)
bResult = CryptAcquireCertificatePrivateKey(m_context, 0, NULL, &m_hCryptProv, &dwKeySpec, NULL);
if (!bResult)
return FALSE;
bResult = CryptCreateHash(m_hCryptProv, CALG_SHA1, 0, 0, &hHash);
if (!bResult)
return FALSE;
BYTE* pDataHash = NULL;
DWORD dwHashLen = 0;
int nTmp = 0;
NSFile::CBase64Converter::Decode((char*)sXmlSignature.c_str(), (int)sXmlSignature.length(), pDataHash, nTmp);
dwHashLen = (DWORD)nTmp;
BYTE* pDataHashMem = new BYTE[dwHashLen];
ConvertEndian(pDataHash, pDataHashMem, dwHashLen);
RELEASEARRAYOBJECTS(pDataHash);
bResult = CryptHashData(hHash, (BYTE*)sXml.c_str(), (DWORD)sXml.length(), 0);
// Get the public key from the certificate
CryptImportPublicKeyInfo(m_hCryptProv, PKCS_7_ASN_ENCODING | X509_ASN_ENCODING, &m_context->pCertInfo->SubjectPublicKeyInfo, &hPubKey);
BOOL bResultRet = CryptVerifySignature(hHash, pDataHashMem, dwHashLen, hPubKey, NULL, 0);
delete[] pDataHashMem;
bResult = CryptDestroyHash(hHash);
CryptDestroyKey(hPubKey);
return bResultRet && bResult;
}
private:
void ConvertEndian(const BYTE* src, BYTE* dst, DWORD size)
{
for(BYTE* p = dst + size - 1; p >= dst; ++src, --p)
(*p) = (*src);
}
};
#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);
void ConvertEndian(const BYTE* src, BYTE* dst, DWORD size)
{
for(BYTE* p = dst + size - 1; p >= dst; ++src, --p)
(*p) = (*src);
}
bool Sign(PCCERT_CONTEXT pCertContext, std::wstring sFileXml, std::wstring sSignatureFile);
bool Verify(PCCERT_CONTEXT pCertContext, std::wstring sFileXml, std::wstring sSignatureFile);
void main(void)
{
@ -335,8 +655,8 @@ void main(void)
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
bool bRes = true;
bRes = Sign(hCertStore, pCertContext, NSFile::GetProcessDirectory() + L"/document2.xml", NSFile::GetProcessDirectory() + L"/result.txt");
bRes = Verify(hCertStore, pCertContext, NSFile::GetProcessDirectory() + L"/document2.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);
@ -353,125 +673,39 @@ 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;
DWORD dwKeySpec = 0;
HCRYPTHASH hHash = NULL;
std::string sXmlPrepare = CXmlCanonicalizator::Execute(sFileXml, XML_C14N_1_0);
BOOL bResult = FALSE;
DWORD dwSigLen = 0;
BYTE* pbSignature = NULL;
bResult = CryptAcquireCertificatePrivateKey(pCertContext, 0, NULL, &hCryptProv, &dwKeySpec, NULL);
bool bIsResult = ((dwKeySpec & AT_SIGNATURE) == AT_SIGNATURE);
// Create the hash object.
bResult = CryptCreateHash(hCryptProv, CALG_SHA1, 0, 0, &hHash);
BYTE* pDataSrc = NULL;
DWORD dwFileSrcLen = 0;
NSFile::CFileBinary::ReadAllBytes(sFileXml, &pDataSrc, dwFileSrcLen);
bResult = CryptHashData(hHash, pDataSrc, dwFileSrcLen, 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;
bResult = CryptSignHash(hHash, dwKeySpec, NULL, 0, NULL, &dwSigLen);
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);
CXmlSigner oSigner(pCertContext);
std::string sXmlSigned = oSigner.Sign(sXmlPrepare);
NSFile::CFileBinary oFile;
oFile.CreateFileW(sSignatureFile);
//oFile.WriteFile(pbSignature, dwSigLen);
char* pBase64 = NULL;
int nBase64Len = 0;
NSFile::CBase64Converter::Encode(pbSignatureMem, (int)dwSigLen, pBase64, nBase64Len, NSBase64::B64_BASE64_FLAG_NONE);
oFile.WriteFile((BYTE*)pBase64, (DWORD)nBase64Len);
oFile.WriteFile((BYTE*)sXmlSigned.c_str(), (DWORD)sXmlSigned.length());
oFile.CloseFile();
delete[] pbSignature;
delete[] pbSignatureMem;
delete[] pDataSrc;
bResult = CryptDestroyHash(hHash);
return (bResult == TRUE);
return (!sXmlSigned.empty());
}
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;
HCRYPTHASH hHash = NULL;
HCRYPTKEY hPubKey = NULL;
std::string sXmlUtf8;
NSFile::CFileBinary::ReadAllTextUtf8A(sFileXml, sXmlUtf8);
BOOL bResult = CryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT);
std::string sXmlUtf8Prepare = CXmlCanonicalizator::Execute(sXmlUtf8, XML_C14N_1_0);
// Create the hash object.
bResult = CryptCreateHash(hCryptProv, CALG_SHA1, 0, 0, &hHash);
std::string sXmlUtf8Signature;
NSFile::CFileBinary::ReadAllTextUtf8A(sSignatureFile, sXmlUtf8Signature);
BYTE* pDataSrc = NULL;
DWORD dwFileSrcLen = 0;
NSFile::CFileBinary::ReadAllBytes(sFileXml, &pDataSrc, dwFileSrcLen);
if (sXmlUtf8Prepare.empty() || sXmlUtf8Signature.empty())
return false;
BYTE* pDataHashBase64 = NULL;
DWORD dwFileHashSrcLenBase64 = 0;
NSFile::CFileBinary::ReadAllBytes(sSignatureFile, &pDataHashBase64, dwFileHashSrcLenBase64);
BYTE* pDataHash = NULL;
DWORD dwHashLen = 0;
int nTmp = 0;
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);
BOOL bResultRet = CryptVerifySignature(hHash, pDataHashMem, dwHashLen, hPubKey, NULL, 0);
delete[] pDataSrc;
delete[] pDataHash;
delete[] pDataHashMem;
delete[] pDataHashBase64;
bResult = CryptDestroyHash(hHash);
return bResultRet && bResult;
CXmlSigner oSigner(pCertContext);
return (TRUE == oSigner.Verify(sXmlUtf8Prepare, sXmlUtf8Signature));
}
bool SignDocument(std::wstring sFolderOOXML, PCCERT_CONTEXT pCertContext)
{
return true;
}

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,494 @@
/*
* (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(this.sName))
sName = val.sName;
if (string.IsNullOrEmpty(this.sNamespace))
sNamespace = val.sNamespace;
if (string.IsNullOrEmpty(this.sType))
sType = val.sType;
if (null == this.oSystemType)
oSystemType = val.oSystemType;
if (!this.bIsAttribute.HasValue)
bIsAttribute = val.bIsAttribute;
if (string.IsNullOrEmpty(this.sDefAttribute))
sDefAttribute = val.sDefAttribute;
if (!this.bQualified.HasValue)
bQualified = val.bQualified;
if (!this.nArrayRank.HasValue)
nArrayRank = val.nArrayRank;
if (!this.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 {
//nArrayRank=0;aArrayTypes=[CT_CalcCell];bIsArrayTypesHidden=true
//[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 {
//nArrayRank=0;aArrayTypes=[CT_Boolean, CT_DateTime, CT_Error, CT_Missing, CT_Number, CT_String];bIsArrayTypesHidden=true
//[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
//{
//nArrayRank=null;aArrayTypes=[CT_Consolidation, CT_ExtensionList, CT_WorksheetSource];bIsArrayTypesHidden=true
//[System.Xml.Serialization.XmlArrayItemAttribute("author", IsNullable=false)]
//public string[] authors {
//nArrayRank=0;aArrayTypes=[string];bIsArrayTypesHidden=false
//[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 {
//nArrayRank=1;aArrayTypes=[CT_Boolean, CT_DateTime, CT_Error, CT_Missing, CT_Number, CT_String, CT_Index];bIsArrayTypesHidden=false
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" };
//string[] aTargetTypes = new string[] { "CT_Workbook" };
//string[] aTargetTypes = new string[] { "CT_Comments" };
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)
{
GenMemberPivot TempMember = aTempMemebers[0];
TempMember.merge(oGenMember);
TempMember.nArrayRank = null;
}
oGenMember.aArrayTypes = aTempMemebers;
if (bXmlElementAttribute)
oGenMember.bIsArrayTypesHidden = true;
else
oGenMember.bIsArrayTypesHidden = false;
}
else
{
oGenMember.nArrayRank = null;
}
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;
}
}
}

View File

@ -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;
}

View File

@ -0,0 +1,792 @@
/*
* (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";
//string sFileJs = "Workbook.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");
//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(writer) {{\r\n", oGenClass.sName);
}
else
{
sb.AppendFormat("{0}.prototype.toXml = function(writer, 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)
{
for (int j = 0; j < oGenMember.aArrayTypes.Count; ++j)
{
InfoFromMemberElem(oGenMember.aArrayTypes[j], ref bNeedTextNode);
}
}
else
{
InfoFromMemberElem(oGenMember, ref bNeedTextNode);
}
aMembers.Add(oGenMember);
}
}
}
public void InfoFromMemberElem(GenMemberPivot oGenMember, ref bool bNeedTextNode)
{
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;
}
}
}
}
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)
{
if (false != oGenMember.bIsArrayTypesHidden)
sb.AppendFormat("this.{0} = [];\r\n", oGenMember.sName);
else
sb.AppendFormat("this.{0} = null;\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 name duplication\r\n", getNameWithPrefix(oGenClass, oGenMember), sCodeName);
}
sb.AppendFormat("this.{0} = [];\r\n", oGenMember.sName);
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];
if (null != oGenMember.aArrayTypes)
{
for (int j = 0; j < oGenMember.aArrayTypes.Count; ++j)
{
nCounter = ProcessOnTextNodeFromXmlMember(sb, oGenClass, oGenMember.aArrayTypes[j], nCounter);
}
}
else
{
nCounter = ProcessOnTextNodeFromXmlMember(sb, oGenClass, oGenMember, nCounter);
}
}
}
int ProcessOnTextNodeFromXmlMember(StringBuilder sb, GenClassPivot oGenClass, GenMemberPivot oGenMember, int nCounter)
{
if (null != oGenMember.oSystemType)
{
ProcessOnTextNodeFromXmlMemberPrefix(sb, oGenClass, oGenMember, nCounter);
ProcessOnTextNodeFromXmlMemberElem(sb, oGenMember, ProcessJsTypeFromXml(oGenMember.oSystemType, "text"));
nCounter = ProcessOnTextNodeFromXmlMemberPostfix(sb, nCounter);
}
else if (null != oGenMember.sType)
{
GenClassPivot oTemp;
if (m_mapProcessedClasses.TryGetValue(oGenMember.sType, out oTemp))
{
if (oTemp.bIsEnum)
{
ProcessOnTextNodeFromXmlMemberPrefix(sb, oGenClass, oGenMember, nCounter);
sb.AppendFormat("var val = {0}(text);\r\n", gc_sEnumFromXmlPrefix + oTemp.sName);
sb.AppendFormat("if(-1 !== val){{\r\n");
ProcessOnTextNodeFromXmlMemberElem(sb, oGenMember, "val");
sb.AppendFormat("}}\r\n");
nCounter = ProcessOnTextNodeFromXmlMemberPostfix(sb, nCounter);
}
}
}
return nCounter;
}
void ProcessOnTextNodeFromXmlMemberPrefix(StringBuilder sb, GenClassPivot oGenClass, GenMemberPivot oGenMember, int nCounter)
{
if (0 != nCounter)
sb.AppendFormat("else ");
sb.AppendFormat("if(\"{0}\" === this._curElem){{\r\n", getNameWithPrefix(oGenClass, oGenMember));
}
int ProcessOnTextNodeFromXmlMemberPostfix(StringBuilder sb, int nCounter)
{
sb.AppendFormat("}}\r\n");
nCounter++;
return nCounter;
}
void ProcessOnTextNodeFromXmlMemberElem(StringBuilder sb, GenMemberPivot oGenMember, string sCodeName)
{
if (oGenMember.nArrayRank.HasValue)
{
if (oGenMember.nArrayRank > 0)
{
sb.AppendFormat("this._curArray.push({0});\r\n", sCodeName);
}
else
{
sb.AppendFormat("this.{0}.push({1});\r\n", oGenMember.sName, sCodeName);
}
}
else
sb.AppendFormat("this.{0} = {1};\r\n", oGenMember.sName, sCodeName);
}
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);
string sCodeName;
if (oGenClass.isRoot())
{
sCodeName = "\"" + oGenClass.sRootName + "\"";
sb.AppendFormat("writer.WriteXmlString(\"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"yes\\\"?>\");\r\n");
sb.AppendFormat("writer.WriteXmlNodeStart({0});\r\n", sCodeName);
sb.AppendFormat("writer.WriteXmlString(\"{0}\");\r\n", gc_sNamespaceToXml);
}
else
{
sCodeName = "name";
sb.AppendFormat("writer.WriteXmlNodeStart({0});\r\n", sCodeName);
}
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("writer.WriteXmlNodeEnd({0}, true);\r\n", sCodeName);
for (int i = 0; i < aMembers.Count; ++i)
{
GenMemberPivot oGenMember = aMembers[i];
bool bNullCheck = true;
string sCodeElem;
if (oGenMember.nArrayRank > 0)
{
if (false == oGenMember.bIsArrayTypesHidden)
{
sb.AppendFormat("if(null !== {0}){{\r\n", oGenMember.sName);
}
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";
bNullCheck = false;
}
else
{
sCodeElem = "this." + oGenMember.sName;
}
if (null != oGenMember.aArrayTypes)
{
if (false == oGenMember.bIsArrayTypesHidden)
{
if (bNullCheck)
sb.AppendFormat("if(null !== {0}){{\r\n", sCodeElem);
sb.AppendFormat("writer.WriteXmlNodeEnd(\"{0}\", true);\r\n", getNameWithPrefix(oGenClass, oGenMember));
}
if (oGenMember.nArrayRank.HasValue)
{
string sCodeSubElem;
if (oGenMember.nArrayRank > 0)
{
sb.AppendFormat("for(var j = 0; j < {0}.length; ++j){{\r\n", sCodeElem);
sb.AppendFormat("var subelem = {0}[j];\r\n", sCodeElem);
sCodeSubElem = "subelem";
}
else
{
sb.AppendFormat("for(var i = 0; i < {0}.length; ++i){{\r\n", sCodeElem);
sb.AppendFormat("var elem = {0}[i];\r\n", sCodeElem);
sCodeSubElem = "elem";
}
if (1 == oGenMember.aArrayTypes.Count)
{
GenMemberPivot oTempMember = oGenMember.aArrayTypes[0];
ProcessMemberToXml(sb, oGenClass, oTempMember, sCodeSubElem, false);
}
else
{
for (int j = 0; j < oGenMember.aArrayTypes.Count; ++j)
{
GenMemberPivot oTempMember = oGenMember.aArrayTypes[j];
if (0 != j)
sb.AppendFormat("else ");
sb.AppendFormat("if({0} instanceof {1}){{\r\n", sCodeSubElem, oTempMember.sType);
sb.AppendFormat("{0}.toXml(writer, \"{1}\");\r\n", sCodeSubElem, 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("writer.WriteXmlNodeEnd(\"{0}\");\r\n", getNameWithPrefix(oGenClass, oGenMember));
if (bNullCheck)
sb.AppendFormat("}}\r\n");
}
}
else
{
ProcessMemberToXml(sb, oGenClass, oGenMember, sCodeElem, true);
}
if (oGenMember.nArrayRank > 0)
{
sb.AppendFormat("}}\r\n");
if (false == oGenMember.bIsArrayTypesHidden)
{
sb.AppendFormat("}}\r\n", oGenMember.sName);
}
}
}
sb.AppendFormat("writer.WriteXmlNodeEnd({0});\r\n", sCodeName);
}
else
sb.AppendFormat("writer.WriteXmlNodeEnd({0}, true, true);\r\n", sCodeName);
}
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)
{
ProcessJsTypeToXml(sb, sElemXmlName, oGenMember.oSystemType, sElemName, bIsAttribute);
}
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)
{
string sElemNameEnum = gc_sEnumToXmlPrefix + oGenClassMember.sName + "("+ sElemName + ")";
ProcessJsTypeToXml(sb, sElemXmlName, oGenMember.oSystemType, sElemNameEnum, bIsAttribute);
}
else
{
if (!bIsAttribute)
sb.AppendFormat("res += {0}.toXml(writer, \"{1}\");\r\n", sElemName, sElemXmlName);
}
}
}
if (checkNull)
{
sb.AppendFormat("}}\r\n");
}
}
void ProcessJsTypeToXml(StringBuilder sb, string sName, Type oType, string sVal, bool bAttribute)
{
switch (Type.GetTypeCode(oType))
{
case TypeCode.Boolean:
if(bAttribute)
{
sb.AppendFormat("writer.WriteXmlAttributeBool(\"{0}\", {1});\r\n", sName, sVal);
}
else
{
sb.AppendFormat("writer.WriteXmlNodeStart(\"{0}\", true);\r\n", sName);
sb.AppendFormat("writer.WriteXmlBool({0});\r\n", sVal);
sb.AppendFormat("writer.WriteXmlNodeEnd(\"{0}\");\r\n", sName);
}
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:
if (bAttribute)
{
sb.AppendFormat("writer.WriteXmlAttributeNumber(\"{0}\", {1});\r\n", sName, sVal);
}
else
{
sb.AppendFormat("writer.WriteXmlNodeStart(\"{0}\", true);\r\n", sName);
sb.AppendFormat("writer.WriteXmlNumber({0});\r\n", sVal);
sb.AppendFormat("writer.WriteXmlNodeEnd(\"{0}\");\r\n", sName);
}
break;
default:
if (bAttribute)
{
sb.AppendFormat("writer.WriteXmlAttributeString(\"{0}\", {1});\r\n", sName, sVal);
}
else
{
sb.AppendFormat("writer.WriteXmlNodeStart(\"{0}\", true);\r\n", sName);
sb.AppendFormat("writer.WriteXmlString({0});\r\n", sVal);
sb.AppendFormat("writer.WriteXmlNodeEnd(\"{0}\");\r\n", sName);
}
break;
}
}
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;
}
}
}

View File

@ -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)
{

View File

@ -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"/>

View File

@ -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"/>

View File

@ -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>

View File

@ -568,7 +568,7 @@
<xsd:attribute name="optimizeMemory" type="xsd:boolean" use="optional" default="false"/>
<xsd:attribute name="enableRefresh" type="xsd:boolean" use="optional" default="true"/>
<xsd:attribute name="refreshedBy" type="s:ST_Xstring" use="optional"/>
<xsd:attribute name="refreshedDateIso" type="xsd:dateTime" use="optional"/>
<xsd:attribute name="refreshedDate" type="xsd:double" use="optional"/>
<xsd:attribute name="backgroundQuery" type="xsd:boolean" default="false"/>
<xsd:attribute name="missingItemsLimit" type="xsd:unsignedInt" use="optional"/>
<xsd:attribute name="createdVersion" type="xsd:unsignedByte" use="optional" default="0"/>
@ -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"/>

View File

@ -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>

View File

@ -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();

View File

@ -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.

View File

@ -7,11 +7,10 @@
QT -= core
QT -= gui
VERSION = 2.4.448.000
VERSION = 2.4.450.0
DEFINES += INTVER=$$VERSION
TARGET = x2t
CORE_ROOT_DIR = $$PWD/../../..
PWD_ROOT_DIR = $$PWD