mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-02-11 02:16:02 +08:00
Compare commits
25 Commits
core-windo
...
core/devel
| Author | SHA1 | Date | |
|---|---|---|---|
| a652f5d73f | |||
| 1602843aa6 | |||
| cdb7fb8ea6 | |||
| 6387e9fa69 | |||
| 4e8097c93d | |||
| 65254b57b2 | |||
| 95899e23a8 | |||
| 5c8757d346 | |||
| 234e19d68a | |||
| 62145b7204 | |||
| 8bcc6d1501 | |||
| 09ef46f333 | |||
| 1839350526 | |||
| d7587e91b1 | |||
| 7b0a342cf9 | |||
| 3d01b0782e | |||
| fecfcfa7d2 | |||
| 29b5fa513a | |||
| f9a19badbf | |||
| d2630ea73c | |||
| a4a58c4782 | |||
| 29a3d80071 | |||
| 598bb419c0 | |||
| 087da9d2ce | |||
| c505aced48 |
@ -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:
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -86,6 +86,7 @@ namespace DocFileFormat
|
||||
friend class Table;
|
||||
friend class TableRow;
|
||||
friend class VMLShapeMapping;
|
||||
friend class VMLPictureMapping;
|
||||
friend class OpenXmlPackage;
|
||||
friend class TextboxMapping;
|
||||
|
||||
|
||||
@ -54,7 +54,7 @@ int _tmain(int argc, _TCHAR* argv[])
|
||||
HRESULT hr = S_OK;
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
std::wstring srcFileName = argv[1];
|
||||
std::wstring dstPath = argc > 2 ? argv[2] : srcFileName + L"-my.pptx"; //xlsx pptx docx
|
||||
std::wstring dstPath = argc > 2 ? argv[2] : srcFileName + L"-my.docx"; //xlsx pptx docx
|
||||
|
||||
std::wstring outputDir = NSDirectory::GetFolderPath(dstPath);
|
||||
|
||||
|
||||
@ -453,6 +453,7 @@ void draw_enhanced_geometry_attlist::add_attributes( const xml::attributes_wc_pt
|
||||
CP_APPLY_ATTR(L"draw:modifiers" , draw_modifiers_);
|
||||
CP_APPLY_ATTR(L"draw:text-path" , draw_text_path_);
|
||||
CP_APPLY_ATTR(L"draw:enhanced-path" , draw_enhanced_path_);
|
||||
CP_APPLY_ATTR(L"drawooo:enhanced-path" , drawooo_enhanced_path_);
|
||||
CP_APPLY_ATTR(L"drawooo:sub-view-size" , drawooo_sub_view_size_);
|
||||
}
|
||||
// draw:enhanced_geometry
|
||||
@ -485,6 +486,9 @@ void draw_enhanced_geometry::add_child_element( xml::sax * Reader, const std::ws
|
||||
}
|
||||
void draw_enhanced_geometry::find_draw_type_oox()
|
||||
{
|
||||
word_art_ = false;
|
||||
bOoxType_ = false;
|
||||
|
||||
if (draw_enhanced_geometry_attlist_.draw_text_path_ &&
|
||||
*draw_enhanced_geometry_attlist_.draw_text_path_ == true)
|
||||
{
|
||||
@ -501,7 +505,7 @@ void draw_enhanced_geometry::find_draw_type_oox()
|
||||
{
|
||||
int count = sizeof(_OO_OOX_wordart) / sizeof(_shape_converter);
|
||||
|
||||
for (long i=0; i< count; i++)
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
if (_OO_OOX_wordart[i].odf_reader == odf_type)
|
||||
{
|
||||
@ -518,7 +522,7 @@ void draw_enhanced_geometry::find_draw_type_oox()
|
||||
|
||||
if (pos < 0)
|
||||
{
|
||||
for (long i=0; i< count; i++)
|
||||
for (long i = 0; i< count; i++)
|
||||
{
|
||||
if (_OO_OOX_custom_shapes[i].odf_reader == odf_type)
|
||||
{
|
||||
@ -529,8 +533,9 @@ void draw_enhanced_geometry::find_draw_type_oox()
|
||||
}
|
||||
else
|
||||
{
|
||||
bOoxType_ = true;
|
||||
std::wstring oox_type = odf_type.substr(pos + 6);
|
||||
for (long i=0; i< count; i++)
|
||||
for (long i = 0; i< count; i++)
|
||||
{
|
||||
if (_OO_OOX_custom_shapes[i].oox == oox_type)
|
||||
{
|
||||
@ -547,18 +552,18 @@ void draw_enhanced_geometry::find_draw_type_oox()
|
||||
}
|
||||
std::wstringstream str;
|
||||
|
||||
BOOST_FOREACH(const office_element_ptr & parElement, draw_handle_)
|
||||
for (size_t i = 0; i < draw_handle_.size(); i++)
|
||||
{
|
||||
draw_handle * handle = dynamic_cast<draw_handle *>(parElement.get());
|
||||
|
||||
int min = -1;
|
||||
int max = -1;
|
||||
draw_handle * handle = dynamic_cast<draw_handle *>(draw_handle_[i].get());
|
||||
if (!handle) continue;
|
||||
|
||||
int min = -1, max = -1;
|
||||
|
||||
try
|
||||
{
|
||||
min = parsing(handle->draw_handle_attlist_.draw_handle_range_y_minimum_);//пока статик .. и выдается только цыфровое значение
|
||||
if (min<0)min = parsing(handle->draw_handle_attlist_.draw_handle_range_x_minimum_);
|
||||
if (min<0)min = parsing(handle->draw_handle_attlist_.draw_handle_radius_range_minimum_);
|
||||
if (min < 0) min = parsing(handle->draw_handle_attlist_.draw_handle_range_x_minimum_);
|
||||
if (min < 0) min = parsing(handle->draw_handle_attlist_.draw_handle_radius_range_minimum_);
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
@ -574,7 +579,7 @@ void draw_enhanced_geometry::find_draw_type_oox()
|
||||
catch(...)
|
||||
{
|
||||
}
|
||||
draw_handle_geometry elm={min, max};
|
||||
draw_handle_geometry elm = {min, max};
|
||||
draw_handle_geometry_.push_back(elm);
|
||||
}
|
||||
}
|
||||
|
||||
@ -437,6 +437,7 @@ public:
|
||||
_CP_OPT(std::wstring) draw_modifiers_;
|
||||
_CP_OPT(bool) draw_text_path_;
|
||||
_CP_OPT(std::wstring) draw_enhanced_path_;
|
||||
_CP_OPT(std::wstring) drawooo_enhanced_path_;
|
||||
_CP_OPT(std::wstring) drawooo_sub_view_size_;
|
||||
};
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
@ -464,7 +465,9 @@ public:
|
||||
_CP_OPT(int) sub_type_;
|
||||
_CP_OPT(int) draw_type_oox_index_;
|
||||
_CP_OPT(std::wstring) svg_viewbox_;
|
||||
|
||||
bool word_art_;
|
||||
bool bOoxType_;
|
||||
|
||||
typedef std::pair<std::wstring,std::wstring> pair_string_value;
|
||||
|
||||
|
||||
@ -253,13 +253,19 @@ void draw_enhanced_geometry::docx_convert(oox::docx_conversion_context & Context
|
||||
|
||||
set_shape = true;
|
||||
}
|
||||
|
||||
if (sub_type_)
|
||||
{
|
||||
shape->sub_type_ = sub_type_.get();
|
||||
set_shape = true;
|
||||
}
|
||||
std::wstring odf_path;
|
||||
if (draw_enhanced_geometry_attlist_.drawooo_enhanced_path_)
|
||||
odf_path = draw_enhanced_geometry_attlist_.drawooo_enhanced_path_.get();
|
||||
else if (draw_enhanced_geometry_attlist_.draw_enhanced_path_)
|
||||
odf_path = draw_enhanced_geometry_attlist_.draw_enhanced_path_.get();
|
||||
|
||||
if (draw_enhanced_geometry_attlist_.draw_enhanced_path_)
|
||||
if (!odf_path.empty())
|
||||
{
|
||||
std::vector<::svg_path::_polyline> o_Polyline;
|
||||
|
||||
@ -267,7 +273,7 @@ void draw_enhanced_geometry::docx_convert(oox::docx_conversion_context & Context
|
||||
|
||||
try
|
||||
{
|
||||
res = ::svg_path::parseSvgD(o_Polyline, draw_enhanced_geometry_attlist_.draw_enhanced_path_.get(), true);
|
||||
res = ::svg_path::parseSvgD(o_Polyline, odf_path, true);
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
@ -316,8 +322,8 @@ void draw_enhanced_geometry::docx_convert(oox::docx_conversion_context & Context
|
||||
{
|
||||
if (draw_handle_geometry_[0].min < draw_handle_geometry_[0].max)
|
||||
{
|
||||
shape->additional_.push_back(_property(L"draw-modifiers-min",draw_handle_geometry_[0].min));
|
||||
shape->additional_.push_back(_property(L"draw-modifiers-max",draw_handle_geometry_[0].max));
|
||||
shape->additional_.push_back(_property(L"draw-modifiers-min", draw_handle_geometry_[0].min));
|
||||
shape->additional_.push_back(_property(L"draw-modifiers-max", draw_handle_geometry_[0].max));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -326,7 +332,6 @@ void draw_enhanced_geometry::docx_convert(oox::docx_conversion_context & Context
|
||||
{
|
||||
shape->bad_shape_ = true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -336,6 +336,7 @@ void odf_drawing_context::set_background_state(bool Val)
|
||||
impl_->is_background_ = Val;
|
||||
|
||||
impl_->current_graphic_properties = new graphic_format_properties();
|
||||
start_area_properties();
|
||||
}
|
||||
|
||||
void odf_drawing_context::check_anchor()
|
||||
@ -473,6 +474,7 @@ void odf_drawing_context::start_drawing()
|
||||
}
|
||||
void odf_drawing_context::end_drawing_background(odf_types::common_draw_fill_attlist & common_draw_attlist)
|
||||
{
|
||||
end_area_properties();
|
||||
if (impl_->current_drawing_state_.elements_.empty() == false) return;
|
||||
|
||||
if (!impl_->is_background_ || !impl_->current_graphic_properties) return;
|
||||
@ -491,15 +493,13 @@ void odf_drawing_context::end_drawing()
|
||||
draw_base* draw = dynamic_cast<draw_base*>(impl_->current_drawing_state_.elements_[0].elm.get());
|
||||
if (draw)
|
||||
{
|
||||
if (impl_->is_presentation_)
|
||||
if (impl_->current_drawing_state_.presentation_class_ || impl_->current_drawing_state_.presentation_placeholder_)
|
||||
{
|
||||
_CP_OPT(std::wstring) draw_layer;
|
||||
if (impl_->is_presentation_.get() == true)
|
||||
{//master
|
||||
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;
|
||||
|
||||
@ -1152,7 +1152,6 @@ void odf_drawing_context::set_hidden (bool bVal)
|
||||
void odf_drawing_context::set_opacity(double percent_)
|
||||
{
|
||||
if (!impl_->current_graphic_properties)return;
|
||||
if (percent_ < 0.01) return;
|
||||
|
||||
switch(impl_->current_drawing_part_)
|
||||
{
|
||||
@ -1186,10 +1185,14 @@ void odf_drawing_context::set_shadow(int type, std::wstring hexColor, _CP_OPT(do
|
||||
|
||||
void odf_drawing_context::set_placeholder_id (std::wstring val)
|
||||
{
|
||||
if (!impl_->is_presentation_) return;
|
||||
|
||||
impl_->current_drawing_state_.presentation_placeholder_ = val;
|
||||
}
|
||||
void odf_drawing_context::set_placeholder_type (int val)
|
||||
{
|
||||
if (!impl_->is_presentation_) return;
|
||||
|
||||
switch(val)
|
||||
{
|
||||
case 0: impl_->current_drawing_state_.presentation_class_ = presentation_class::outline; break;
|
||||
@ -1256,7 +1259,8 @@ _CP_OPT(odf_types::color) odf_drawing_context::get_line_color()
|
||||
}
|
||||
void odf_drawing_context::set_solid_fill(std::wstring hexColor)
|
||||
{
|
||||
if (!impl_->current_graphic_properties)return;
|
||||
if (!impl_->current_graphic_properties) return;
|
||||
if (hexColor.empty()) return;
|
||||
|
||||
int res = 0;
|
||||
if ((res = hexColor.find(L"#")) < 0) hexColor = std::wstring(L"#") + hexColor;
|
||||
@ -1265,7 +1269,7 @@ void odf_drawing_context::set_solid_fill(std::wstring hexColor)
|
||||
{
|
||||
case Area:
|
||||
impl_->current_graphic_properties->common_draw_fill_attlist_.draw_fill_color_ = hexColor;
|
||||
impl_->current_graphic_properties->common_background_color_attlist_.fo_background_color_ = color(hexColor);
|
||||
//impl_->current_graphic_properties->common_background_color_attlist_.fo_background_color_ = color(hexColor); - default transparent
|
||||
//последнее нужно - что если будут вводить текст - под текстом будет цвет фона (или он поменяется в полях текста)
|
||||
|
||||
if ((impl_->is_footer_ || impl_->is_header_ || impl_->is_background_) &&
|
||||
@ -1747,8 +1751,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)
|
||||
@ -2173,27 +2177,47 @@ void odf_drawing_context::set_textarea_writing_mode(int mode)
|
||||
paragraph_properties = style_->content_.get_style_paragraph_properties();
|
||||
}
|
||||
}
|
||||
if (paragraph_properties == NULL && impl_->current_paragraph_properties == NULL)return;
|
||||
|
||||
switch(mode)
|
||||
if (paragraph_properties)
|
||||
{
|
||||
case 5://textverticaltypeWordArtVert:
|
||||
case 6://textverticaltypeWordArtVertRtl:
|
||||
case 4://SimpleTypes::textverticaltypeVert270: //нужно отзеркалить по горизонтали текст
|
||||
case 3://SimpleTypes::textverticaltypeVert:
|
||||
case 2://SimpleTypes::textverticaltypeMongolianVert:
|
||||
paragraph_properties->content_.style_writing_mode_ = odf_types::writing_mode(odf_types::writing_mode::TbRl);
|
||||
impl_->current_paragraph_properties->content_.style_writing_mode_ = odf_types::writing_mode(odf_types::writing_mode::TbRl);
|
||||
break;
|
||||
case 0://SimpleTypes::textverticaltypeEaVert:
|
||||
paragraph_properties->content_.style_writing_mode_ = odf_types::writing_mode(odf_types::writing_mode::TbRl);
|
||||
impl_->current_paragraph_properties->content_.style_writing_mode_ = odf_types::writing_mode(odf_types::writing_mode::TbRl);
|
||||
break;
|
||||
case 1://SimpleTypes::textverticaltypeHorz:
|
||||
default:
|
||||
paragraph_properties->content_.style_writing_mode_ = odf_types::writing_mode(odf_types::writing_mode::LrTb);
|
||||
impl_->current_paragraph_properties->content_.style_writing_mode_ = odf_types::writing_mode(odf_types::writing_mode::LrTb);
|
||||
break;
|
||||
switch(mode)
|
||||
{
|
||||
case 5://textverticaltypeWordArtVert:
|
||||
case 6://textverticaltypeWordArtVertRtl:
|
||||
case 4://SimpleTypes::textverticaltypeVert270: //нужно отзеркалить по горизонтали текст
|
||||
case 3://SimpleTypes::textverticaltypeVert:
|
||||
case 2://SimpleTypes::textverticaltypeMongolianVert:
|
||||
|
||||
paragraph_properties->content_.style_writing_mode_ = odf_types::writing_mode(odf_types::writing_mode::TbRl);
|
||||
break;
|
||||
case 0://SimpleTypes::textverticaltypeEaVert:
|
||||
paragraph_properties->content_.style_writing_mode_ = odf_types::writing_mode(odf_types::writing_mode::TbRl);
|
||||
break;
|
||||
case 1://SimpleTypes::textverticaltypeHorz:
|
||||
default:
|
||||
paragraph_properties->content_.style_writing_mode_ = odf_types::writing_mode(odf_types::writing_mode::LrTb);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (impl_->current_paragraph_properties)
|
||||
{
|
||||
switch(mode)
|
||||
{
|
||||
case 5://textverticaltypeWordArtVert:
|
||||
case 6://textverticaltypeWordArtVertRtl:
|
||||
case 4://SimpleTypes::textverticaltypeVert270: //нужно отзеркалить по горизонтали текст
|
||||
case 3://SimpleTypes::textverticaltypeVert:
|
||||
case 2://SimpleTypes::textverticaltypeMongolianVert:
|
||||
impl_->current_paragraph_properties->content_.style_writing_mode_ = odf_types::writing_mode(odf_types::writing_mode::TbRl);
|
||||
break;
|
||||
case 0://SimpleTypes::textverticaltypeEaVert:
|
||||
impl_->current_paragraph_properties->content_.style_writing_mode_ = odf_types::writing_mode(odf_types::writing_mode::TbRl);
|
||||
break;
|
||||
case 1://SimpleTypes::textverticaltypeHorz:
|
||||
default:
|
||||
impl_->current_paragraph_properties->content_.style_writing_mode_ = odf_types::writing_mode(odf_types::writing_mode::LrTb);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
void odf_drawing_context::set_paragraph_properties(style_paragraph_properties *paragraph_properties)
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -266,8 +266,11 @@ void odt_conversion_context::end_drawings()
|
||||
}
|
||||
else
|
||||
{
|
||||
text_context()->start_element(elm);
|
||||
text_context()->end_element();
|
||||
if (elm)
|
||||
{
|
||||
text_context()->start_element(elm);
|
||||
text_context()->end_element();
|
||||
}
|
||||
|
||||
drawing_context()->clear();
|
||||
drawing_context_.pop_back();
|
||||
|
||||
@ -207,6 +207,8 @@ void text_list::create_child_element(const std::wstring & Ns, const std::wstring
|
||||
}
|
||||
void text_list::add_child_element( const office_element_ptr & child_element)
|
||||
{
|
||||
if (!child_element) return;
|
||||
|
||||
ElementType type = child_element->get_type();
|
||||
|
||||
if (type == typeTextListHeader)
|
||||
|
||||
@ -30,6 +30,8 @@
|
||||
*
|
||||
*/
|
||||
#include "PptxConverter.h"
|
||||
#include "DocxConverter.h"
|
||||
|
||||
#include "../utils.h"
|
||||
|
||||
#include "../../../Common/DocxFormat/Source/DocxFormat/Diagram/DiagramDrawing.h"
|
||||
@ -96,9 +98,6 @@ void OoxConverter::convert(PPTX::Logic::GraphicFrame *oox_graphic_frame)
|
||||
{
|
||||
if (!oox_graphic_frame)return;
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
odf_context()->drawing_context()->start_drawing();
|
||||
|
||||
convert(&oox_graphic_frame->nvGraphicFramePr);
|
||||
convert(oox_graphic_frame->xfrm.GetPointer());
|
||||
|
||||
@ -124,7 +123,6 @@ void OoxConverter::convert(PPTX::Logic::GraphicFrame *oox_graphic_frame)
|
||||
{
|
||||
OoxConverter::convert(oox_graphic_frame->element.GetElem().operator->());
|
||||
}
|
||||
odf_context()->drawing_context()->end_drawing();
|
||||
}
|
||||
void OoxConverter::convert(PPTX::Logic::NvGraphicFramePr *oox_framePr)
|
||||
{
|
||||
@ -192,7 +190,6 @@ void OoxConverter::convert(PPTX::Logic::Pic *oox_picture)
|
||||
|
||||
if (type != SimpleTypes::shapetypeRect)
|
||||
{
|
||||
odf_context()->drawing_context()->start_drawing();
|
||||
odf_context()->drawing_context()->start_shape(type);
|
||||
|
||||
convert(&oox_picture->spPr, oox_picture->style.GetPointer());
|
||||
@ -203,7 +200,6 @@ void OoxConverter::convert(PPTX::Logic::Pic *oox_picture)
|
||||
odf_context()->drawing_context()->end_area_properties();
|
||||
|
||||
odf_context()->drawing_context()->end_shape();
|
||||
odf_context()->drawing_context()->end_drawing();
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -227,7 +223,6 @@ void OoxConverter::convert(PPTX::Logic::Pic *oox_picture)
|
||||
}
|
||||
}
|
||||
|
||||
odf_context()->drawing_context()->start_drawing();
|
||||
odf_context()->drawing_context()->start_image(odf_ref);
|
||||
{
|
||||
double Width = 0, Height = 0;
|
||||
@ -255,7 +250,6 @@ void OoxConverter::convert(PPTX::Logic::Pic *oox_picture)
|
||||
|
||||
}
|
||||
odf_context()->drawing_context()->end_image();
|
||||
odf_context()->drawing_context()->end_drawing();
|
||||
}
|
||||
|
||||
void OoxConverter::convert(PPTX::Logic::SmartArt *oox_smart_art)
|
||||
@ -263,11 +257,11 @@ void OoxConverter::convert(PPTX::Logic::SmartArt *oox_smart_art)
|
||||
if (oox_smart_art == NULL) return;
|
||||
if (oox_smart_art->id_data.IsInit() == false) return;
|
||||
|
||||
oox_smart_art->LoadDrawing();
|
||||
oox_smart_art->LoadDrawing(current_document());
|
||||
|
||||
if (oox_smart_art->m_diag.IsInit())
|
||||
{
|
||||
_CP_OPT(double) x, y, width, height, cx, cy;
|
||||
_CP_OPT(double) x, y, width, height, cx = 1., cy= 1.;
|
||||
|
||||
odf_context()->drawing_context()->get_size (width, height);
|
||||
odf_context()->drawing_context()->get_position (x, y);
|
||||
@ -281,7 +275,9 @@ void OoxConverter::convert(PPTX::Logic::SmartArt *oox_smart_art)
|
||||
|
||||
for (size_t i = 0; i < oox_smart_art->m_diag->SpTreeElems.size(); i++)
|
||||
{
|
||||
convert(&oox_smart_art->m_diag->SpTreeElems[i]);
|
||||
odf_context()->drawing_context()->start_drawing();
|
||||
convert(&oox_smart_art->m_diag->SpTreeElems[i]);
|
||||
odf_context()->drawing_context()->end_drawing();
|
||||
}
|
||||
|
||||
odf_context()->drawing_context()->end_group();
|
||||
@ -398,7 +394,9 @@ void OoxConverter::convert(PPTX::Logic::SpTree *oox_shape_tree)
|
||||
|
||||
for (size_t i = 0; i < oox_shape_tree->SpTreeElems.size(); i++)
|
||||
{
|
||||
convert(oox_shape_tree->SpTreeElems[i].GetElem().operator->());
|
||||
odf_context()->drawing_context()->start_drawing();
|
||||
convert(oox_shape_tree->SpTreeElems[i].GetElem().operator->());
|
||||
odf_context()->drawing_context()->end_drawing();
|
||||
}
|
||||
|
||||
odf_context()->drawing_context()->end_group();
|
||||
@ -408,80 +406,105 @@ void OoxConverter::convert(PPTX::Logic::CxnSp *oox_connect)
|
||||
{
|
||||
if (oox_connect == NULL) return;
|
||||
|
||||
odf_context()->drawing_context()->start_drawing();
|
||||
|
||||
int type = SimpleTypes::shapetypeLine;
|
||||
int type = SimpleTypes::shapetypeLine;
|
||||
|
||||
if ( oox_connect->spPr.Geometry.is<PPTX::Logic::PrstGeom>() )
|
||||
{
|
||||
const PPTX::Logic::PrstGeom& prstGeom = oox_connect->spPr.Geometry.as<PPTX::Logic::PrstGeom>();
|
||||
|
||||
SimpleTypes::CShapeType<> preset;
|
||||
preset.FromString(prstGeom.prst.get());
|
||||
type = preset.GetValue();
|
||||
}
|
||||
odf_context()->drawing_context()->start_shape(type);
|
||||
if ( oox_connect->spPr.Geometry.is<PPTX::Logic::PrstGeom>() )
|
||||
{
|
||||
const PPTX::Logic::PrstGeom& prstGeom = oox_connect->spPr.Geometry.as<PPTX::Logic::PrstGeom>();
|
||||
|
||||
SimpleTypes::CShapeType<> preset;
|
||||
preset.FromString(prstGeom.prst.get());
|
||||
type = preset.GetValue();
|
||||
}
|
||||
odf_context()->drawing_context()->start_shape(type);
|
||||
|
||||
convert(&oox_connect->spPr, oox_connect->style.GetPointer());
|
||||
convert(&oox_connect->nvCxnSpPr);
|
||||
|
||||
odf_context()->drawing_context()->end_shape();
|
||||
|
||||
odf_context()->drawing_context()->end_drawing();
|
||||
}
|
||||
void OoxConverter::convert(PPTX::Logic::Shape *oox_shape)
|
||||
{
|
||||
if (oox_shape == NULL) return;
|
||||
|
||||
odf_context()->drawing_context()->start_drawing();
|
||||
_CP_OPT(bool) bMasterPresentation = odf_context()->drawing_context()->get_presentation();
|
||||
|
||||
int type = 1000; //custom
|
||||
if (oox_shape->txXfrm.IsInit())
|
||||
{
|
||||
odf_context()->drawing_context()->start_group();
|
||||
odf_context()->drawing_context()->start_drawing();
|
||||
}
|
||||
|
||||
int type = 1000; //custom
|
||||
|
||||
if (oox_shape->spPr.Geometry.is_init())
|
||||
if (oox_shape->spPr.Geometry.is_init())
|
||||
{
|
||||
if ( oox_shape->spPr.Geometry.is<PPTX::Logic::PrstGeom>() )
|
||||
{
|
||||
if ( oox_shape->spPr.Geometry.is<PPTX::Logic::PrstGeom>() )
|
||||
const PPTX::Logic::PrstGeom& prstGeom = oox_shape->spPr.Geometry.as<PPTX::Logic::PrstGeom>();
|
||||
|
||||
SimpleTypes::CShapeType<> preset;
|
||||
preset.FromString(prstGeom.prst.get());
|
||||
type = preset.GetValue();
|
||||
}
|
||||
|
||||
if (type == SimpleTypes::shapetypeRect && (oox_shape->txBody.IsInit() || oox_shape->oTextBoxShape.IsInit()))
|
||||
type = 2000;
|
||||
|
||||
if (type == 2000)
|
||||
{
|
||||
PPTX::Logic::BodyPr *bodyPr = NULL;
|
||||
if (oox_shape->txBody.IsInit()) bodyPr = oox_shape->txBody->bodyPr.GetPointer();
|
||||
else bodyPr = oox_shape->oTextBoxBodyPr.GetPointer();
|
||||
|
||||
if (bodyPr && bodyPr->fromWordArt.get_value_or(false))
|
||||
{
|
||||
const PPTX::Logic::PrstGeom& prstGeom = oox_shape->spPr.Geometry.as<PPTX::Logic::PrstGeom>();
|
||||
|
||||
SimpleTypes::CShapeType<> preset;
|
||||
preset.FromString(prstGeom.prst.get());
|
||||
type = preset.GetValue();
|
||||
}
|
||||
|
||||
if (type == SimpleTypes::shapetypeRect && oox_shape->txBody.IsInit()) type = 2000;
|
||||
|
||||
if (type == 2000 && oox_shape->txBody->bodyPr.IsInit()
|
||||
&& oox_shape->txBody->bodyPr->fromWordArt.get_value_or(false))
|
||||
{
|
||||
int wordart_type = convert(oox_shape->txBody->bodyPr->prstTxWarp.GetPointer());
|
||||
|
||||
int wordart_type = convert(bodyPr->prstTxWarp.GetPointer());
|
||||
if (wordart_type > 0) type = wordart_type;
|
||||
}
|
||||
}
|
||||
else if (oox_shape->nvSpPr.nvPr.ph.is_init())
|
||||
{
|
||||
type = 2000;
|
||||
}
|
||||
}
|
||||
else if (oox_shape->nvSpPr.nvPr.ph.is_init())
|
||||
{
|
||||
type = 2000;
|
||||
}
|
||||
|
||||
if (type < 0)return;
|
||||
if (type < 0)return;
|
||||
//-----------------------------------------------------------------------------
|
||||
odf_context()->drawing_context()->start_shape(type);
|
||||
|
||||
convert(&oox_shape->spPr, oox_shape->style.GetPointer());
|
||||
odf_context()->drawing_context()->start_shape(type);
|
||||
|
||||
convert(&oox_shape->spPr, oox_shape->style.GetPointer());
|
||||
|
||||
convert(&oox_shape->nvSpPr);
|
||||
convert(&oox_shape->nvSpPr);
|
||||
|
||||
if (oox_shape->txXfrm.IsInit() == false)
|
||||
if (oox_shape->txXfrm.IsInit() == false)
|
||||
{
|
||||
if (oox_shape->oTextBoxShape.IsInit()) //docx sdt
|
||||
{
|
||||
convert(oox_shape->txBody.GetPointer(), oox_shape->style.GetPointer());
|
||||
DocxConverter *docx_converter = dynamic_cast<DocxConverter*>(this);
|
||||
if (docx_converter)
|
||||
{
|
||||
odf_context()->start_text_context();
|
||||
docx_converter->convert(oox_shape->oTextBoxShape.GetPointer());
|
||||
odf_context()->drawing_context()->set_text( odf_context()->text_context());
|
||||
|
||||
convert(oox_shape->oTextBoxBodyPr.GetPointer());
|
||||
|
||||
if (oox_shape->style.IsInit())
|
||||
convert(&oox_shape->style->fontRef);
|
||||
odf_context()->end_text_context();
|
||||
}
|
||||
}
|
||||
else
|
||||
convert(oox_shape->txBody.GetPointer(), oox_shape->style.GetPointer());
|
||||
}
|
||||
|
||||
odf_context()->drawing_context()->end_shape();
|
||||
|
||||
odf_context()->drawing_context()->end_drawing();
|
||||
|
||||
if (oox_shape->txXfrm.IsInit())
|
||||
{
|
||||
odf_context()->drawing_context()->end_drawing();
|
||||
|
||||
odf_context()->drawing_context()->start_drawing();
|
||||
odf_context()->drawing_context()->start_text_box();
|
||||
|
||||
@ -494,6 +517,8 @@ void OoxConverter::convert(PPTX::Logic::Shape *oox_shape)
|
||||
|
||||
odf_context()->drawing_context()->end_text_box();
|
||||
odf_context()->drawing_context()->end_drawing();
|
||||
|
||||
odf_context()->drawing_context()->end_group();
|
||||
}
|
||||
}
|
||||
|
||||
@ -884,12 +909,19 @@ void OoxConverter::convert(PPTX::Logic::UniColor * color, std::wstring & hexStri
|
||||
if (!color) return;
|
||||
|
||||
convert(color, nARGB);
|
||||
|
||||
hexString = XmlUtils::IntToString(nARGB & 0x00FFFFFF, L"#%06X");
|
||||
|
||||
if ((nARGB >> 24) != 0xff)
|
||||
if (nARGB != 0)
|
||||
{
|
||||
hexString = XmlUtils::IntToString(nARGB & 0x00FFFFFF, L"#%06X");
|
||||
|
||||
if ((nARGB >> 24) != 0xff)
|
||||
{
|
||||
opacity = ((nARGB >> 24) /255.) * 100.;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
opacity = ((nARGB >> 24) /255.) * 100.;
|
||||
//not found in theme
|
||||
}
|
||||
}
|
||||
|
||||
@ -1147,8 +1179,6 @@ void OoxConverter::convert_list_level(PPTX::Logic::TextParagraphPr *oox_para_pro
|
||||
}
|
||||
if (bullet.is<PPTX::Logic::BuBlip>())
|
||||
{
|
||||
odf_list_type = 1000;
|
||||
|
||||
const PPTX::Logic::BuBlip & buBlip = bullet.as<PPTX::Logic::BuBlip>();
|
||||
|
||||
std::wstring odf_ref;
|
||||
@ -1158,6 +1188,9 @@ void OoxConverter::convert_list_level(PPTX::Logic::TextParagraphPr *oox_para_pro
|
||||
{
|
||||
std::wstring sID = buBlip.blip.embed->get();
|
||||
std::wstring pathImage = find_link_by_id(sID, 1);
|
||||
|
||||
if (pathImage.empty())
|
||||
pathImage = buBlip.blip.GetFullPicName(); // only for presentation merge shapes !!
|
||||
|
||||
odf_ref = odf_context()->add_image(pathImage);
|
||||
}
|
||||
@ -1167,8 +1200,18 @@ void OoxConverter::convert_list_level(PPTX::Logic::TextParagraphPr *oox_para_pro
|
||||
bEmbedded = false;
|
||||
}
|
||||
|
||||
odf_context()->styles_context()->lists_styles().start_style_level(level, odf_list_type );
|
||||
odf_context()->styles_context()->lists_styles().set_bullet_image(odf_ref);
|
||||
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();
|
||||
@ -1177,7 +1220,7 @@ 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_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);
|
||||
@ -1204,7 +1247,7 @@ 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);
|
||||
}
|
||||
}
|
||||
//-----------------------------------
|
||||
@ -1295,7 +1338,7 @@ void OoxConverter::convert(PPTX::Logic::Paragraph *oox_paragraph, PPTX::Logic::T
|
||||
bool list_present = false;
|
||||
std::wstring list_style_name;
|
||||
|
||||
int list_level = -1;
|
||||
int list_level = 0;//-1;
|
||||
|
||||
NSCommon::nullable<PPTX::Logic::TextParagraphPr> paraPr;
|
||||
|
||||
@ -1346,7 +1389,6 @@ void OoxConverter::convert(PPTX::Logic::Paragraph *oox_paragraph, PPTX::Logic::T
|
||||
if (odf_context()->drawing_context()->is_wordart())
|
||||
odf_context()->drawing_context()->set_paragraph_properties(paragraph_properties);
|
||||
}
|
||||
list_level++;
|
||||
|
||||
if (oox_paragraph->RunElems.empty() && list_present) list_present = false; // ms не обозначает присутствие списка, libra - показывает значек
|
||||
|
||||
@ -1363,21 +1405,18 @@ 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)
|
||||
{
|
||||
if (list_local)
|
||||
{
|
||||
_CP_OPT(bool) inStyles = odf_context()->drawing_context()->get_presentation();
|
||||
_CP_OPT(bool) inStyles = odf_context()->drawing_context()->get_presentation();
|
||||
|
||||
odf_context()->styles_context()->lists_styles().start_style(inStyles && *inStyles);
|
||||
convert_list_level(oox_paragraph->pPr.GetPointer(), list_level - 1);
|
||||
odf_context()->styles_context()->lists_styles().end_style();
|
||||
|
||||
}
|
||||
list_style_name = odf_context()->styles_context()->lists_styles().get_style_name(); //last added
|
||||
|
||||
//odf_context()->text_context()->start_list(list_style_name);
|
||||
}
|
||||
odf_context()->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_level++;
|
||||
|
||||
if (odf_context()->text_context()->list_state_.levels.size() < list_level)
|
||||
{
|
||||
@ -1720,6 +1759,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)
|
||||
{
|
||||
@ -1756,7 +1834,7 @@ void OoxConverter::convert(PPTX::Logic::TextListStyle *oox_list_style)
|
||||
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[0].GetPointer(), i);
|
||||
OoxConverter::convert_list_level(oox_list_style->levels[i].GetPointer(), i);
|
||||
}
|
||||
odf_context()->styles_context()->lists_styles().end_style();
|
||||
}
|
||||
|
||||
@ -70,7 +70,7 @@ void OoxConverter::convert(OOX::Vml::CShapeType *vml_shape_type)
|
||||
}
|
||||
//m_oPreferRelative//типо можно менять размер
|
||||
|
||||
for (unsigned int i=0 ; i < vml_shape_type->m_arrItems.size();i++)
|
||||
for (size_t i = 0; i < vml_shape_type->m_arrItems.size(); i++)
|
||||
{
|
||||
convert(vml_shape_type->m_arrItems[i]);
|
||||
}
|
||||
@ -86,6 +86,18 @@ void OoxConverter::convert(OOX::Vml::CShapeType *vml_shape_type)
|
||||
//m_arrItems
|
||||
//CVmlCommonElements
|
||||
}
|
||||
void OoxConverter::convert(OOX::Vml::CFormulas *vml_formulas)
|
||||
{
|
||||
if (vml_formulas == NULL) return;
|
||||
|
||||
for (size_t i = 0; i < vml_formulas->m_arrItems.size(); i++)
|
||||
{
|
||||
OOX::Vml::CF *cf = dynamic_cast<OOX::Vml::CF *>(vml_formulas->m_arrItems[i]);
|
||||
if (cf == NULL) continue;
|
||||
|
||||
//odf_context()->drawing_context()->add_formula(L"", cf->m_sEqn);
|
||||
}
|
||||
}
|
||||
|
||||
void OoxConverter::convert(SimpleTypes::Vml::CCssStyle *vml_style, bool group)
|
||||
{
|
||||
@ -95,7 +107,7 @@ void OoxConverter::convert(SimpleTypes::Vml::CCssStyle *vml_style, bool group)
|
||||
|
||||
_CP_OPT(int) anchor_type_x, anchor_type_y;
|
||||
|
||||
for (unsigned int i=0; i < vml_style->m_arrProperties.size(); i++)
|
||||
for (size_t i = 0; i < vml_style->m_arrProperties.size(); i++)
|
||||
{
|
||||
if (vml_style->m_arrProperties[i] == NULL) continue;
|
||||
|
||||
@ -693,17 +705,18 @@ void OoxConverter::convert(OOX::Vml::CTextbox *vml_textbox)
|
||||
odf_context()->drawing_context()->set_textarea_wrap(true);
|
||||
|
||||
DocxConverter *docx_converter = dynamic_cast<DocxConverter*>(this);
|
||||
|
||||
odf_context()->start_text_context();
|
||||
if (docx_converter)
|
||||
{
|
||||
for (unsigned int i=0 ; i < vml_textbox->m_oTxtbxContent->m_arrItems.size();i++)
|
||||
odf_context()->start_text_context();
|
||||
{
|
||||
if (docx_converter)
|
||||
for (size_t i = 0; i < vml_textbox->m_oTxtbxContent->m_arrItems.size(); i++)
|
||||
{
|
||||
docx_converter->convert(vml_textbox->m_oTxtbxContent->m_arrItems[i]);
|
||||
}
|
||||
odf_context()->drawing_context()->set_text( odf_context()->text_context());
|
||||
}
|
||||
odf_context()->drawing_context()->set_text( odf_context()->text_context());
|
||||
odf_context()->end_text_context();
|
||||
}
|
||||
odf_context()->end_text_context();
|
||||
|
||||
}
|
||||
void OoxConverter::convert(OOX::Vml::CTextPath *vml_textpath)
|
||||
@ -869,7 +882,7 @@ void OoxConverter::convert(OOX::Vml::CVmlCommonElements *vml_common)
|
||||
delete oRgbColor;
|
||||
}
|
||||
}
|
||||
for (unsigned int i=0 ; i < vml_common->m_arrItems.size();i++)
|
||||
for (size_t i = 0; i < vml_common->m_arrItems.size(); i++)
|
||||
{
|
||||
convert(vml_common->m_arrItems[i]);
|
||||
}
|
||||
@ -899,7 +912,7 @@ void OoxConverter::convert(OOX::Vml::CGroup *vml_group)
|
||||
odf_context()->drawing_context()->set_group_shift(vml_group->m_oCoordOrigin->GetX(), vml_group->m_oCoordOrigin->GetY());
|
||||
}
|
||||
|
||||
for (unsigned int i=0; i < vml_group->m_arrItems.size(); i++)
|
||||
for (size_t i = 0; i < vml_group->m_arrItems.size(); i++)
|
||||
{
|
||||
if (vml_group->m_arrItems[i] == NULL) continue;
|
||||
|
||||
|
||||
@ -130,6 +130,8 @@ bool OoxConverter::UpdateProgress(long nComplete)
|
||||
|
||||
void OoxConverter::set_fonts_directory(const std::wstring &fontsPath)
|
||||
{
|
||||
if (odf_context() == NULL) return;
|
||||
|
||||
odf_context()->set_fonts_directory(fontsPath);
|
||||
}
|
||||
|
||||
@ -143,18 +145,15 @@ void OoxConverter::convert(OOX::WritingElement *oox_unknown)
|
||||
{
|
||||
case OOX::et_graphicFrame:
|
||||
{
|
||||
PPTX::Logic::GraphicFrame* pGraphicFrame= dynamic_cast<PPTX::Logic::GraphicFrame*>(oox_unknown);
|
||||
convert(pGraphicFrame);
|
||||
convert(dynamic_cast<PPTX::Logic::GraphicFrame*>(oox_unknown));
|
||||
}break;
|
||||
case OOX::et_pic:
|
||||
{
|
||||
PPTX::Logic::Pic* pPic= dynamic_cast<PPTX::Logic::Pic*>(oox_unknown);
|
||||
convert(pPic);
|
||||
convert(dynamic_cast<PPTX::Logic::Pic*>(oox_unknown));
|
||||
}break;
|
||||
case OOX::et_dgm_DiagrammParts:
|
||||
{
|
||||
PPTX::Logic::SmartArt* pDiagrammParts = dynamic_cast<PPTX::Logic::SmartArt*>(oox_unknown);
|
||||
convert(pDiagrammParts);
|
||||
convert(dynamic_cast<PPTX::Logic::SmartArt*>(oox_unknown));
|
||||
}break;
|
||||
case OOX::et_a_Shape:
|
||||
case OOX::et_p_Shape:
|
||||
@ -266,18 +265,19 @@ void OoxConverter::convert(OOX::WritingElement *oox_unknown)
|
||||
}break;
|
||||
case OOX::et_v_fill:
|
||||
{
|
||||
OOX::Vml::CFill *vml = dynamic_cast<OOX::Vml::CFill*>(oox_unknown);
|
||||
convert(vml);
|
||||
convert(dynamic_cast<OOX::Vml::CFill*>(oox_unknown));
|
||||
}break;
|
||||
case OOX::et_v_stroke:
|
||||
{
|
||||
OOX::Vml::CStroke *vml = dynamic_cast<OOX::Vml::CStroke*>(oox_unknown);
|
||||
convert(vml);
|
||||
convert(dynamic_cast<OOX::Vml::CStroke*>(oox_unknown));
|
||||
}break;
|
||||
case OOX::et_v_formulas:
|
||||
{
|
||||
convert(dynamic_cast<OOX::Vml::CFormulas*>(oox_unknown));
|
||||
}break;
|
||||
case OOX::et_v_shadow:
|
||||
{
|
||||
OOX::Vml::CShadow *vml = dynamic_cast<OOX::Vml::CShadow*>(oox_unknown);
|
||||
convert(vml);
|
||||
convert(dynamic_cast<OOX::Vml::CShadow*>(oox_unknown));
|
||||
}break;
|
||||
case OOX::et_v_image:
|
||||
{
|
||||
|
||||
@ -245,6 +245,7 @@ namespace OOX
|
||||
class CTextPath;
|
||||
class CGroup;
|
||||
class CVmlCommonElements;
|
||||
class CFormulas;
|
||||
}
|
||||
namespace VmlWord
|
||||
{
|
||||
@ -354,10 +355,11 @@ public:
|
||||
double getSystemDPI();
|
||||
|
||||
//.......................................................................................................................
|
||||
virtual OOX::IFileContainer *current_document() = 0;
|
||||
virtual cpdoccore::odf_writer::odf_conversion_context *odf_context() = 0;
|
||||
virtual PPTX::Theme *oox_theme() = 0;
|
||||
virtual PPTX::Logic::ClrMap *oox_clrMap() {return NULL;}
|
||||
|
||||
|
||||
virtual std::wstring find_link_by_id(std::wstring sId, int t) = 0;
|
||||
virtual NSCommon::smart_ptr<OOX::File> find_file_by_id(std::wstring sId) = 0;
|
||||
|
||||
@ -510,6 +512,7 @@ public:
|
||||
void convert(OOX::VmlWord::CWrap *vml_wrap);
|
||||
void convert(OOX::Vml::CGroup *vml_group);
|
||||
void convert(OOX::Vml::CVmlCommonElements *vml_attr);
|
||||
void convert(OOX::Vml::CFormulas *vml_formulas);
|
||||
};
|
||||
|
||||
} // namespace Oox2Odf
|
||||
|
||||
@ -103,7 +103,16 @@ PPTX::Theme* DocxConverter::oox_theme()
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
OOX::IFileContainer* DocxConverter::current_document()
|
||||
{
|
||||
if (oox_current_child_document)
|
||||
return oox_current_child_document;
|
||||
else
|
||||
{
|
||||
OOX::CDocument *oox_doc = docx_document->GetDocument();
|
||||
return dynamic_cast<OOX::IFileContainer*>(oox_doc);
|
||||
}
|
||||
}
|
||||
NSCommon::smart_ptr<OOX::File> DocxConverter::find_file_by_id(std::wstring sId)
|
||||
{
|
||||
OOX::CDocument *oox_doc = docx_document->GetDocument();
|
||||
@ -317,16 +326,16 @@ void DocxConverter::convert(OOX::WritingElement *oox_unknown)
|
||||
// OOX::Logic::CShape* pShape = dynamic_cast<OOX::Logic::CShape*>(oox_unknown);
|
||||
// convert(pShape);
|
||||
//}break;
|
||||
//case OOX::et_w_pict:
|
||||
//{
|
||||
// OOX::Logic::CPicture* pPic = dynamic_cast<OOX::Logic::CPicture*>(oox_unknown);
|
||||
// convert(pPic);
|
||||
//}break;
|
||||
//case OOX::et_w_object:
|
||||
//{
|
||||
// OOX::Logic::CObject* pObj = dynamic_cast<OOX::Logic::CObject*>(oox_unknown);
|
||||
// convert(pObj);
|
||||
//}break;
|
||||
case OOX::et_w_pict:
|
||||
{
|
||||
OOX::Logic::CPicture* pPic = dynamic_cast<OOX::Logic::CPicture*>(oox_unknown);
|
||||
convert(pPic);
|
||||
}break;
|
||||
case OOX::et_w_object:
|
||||
{
|
||||
OOX::Logic::CObject* pObj = dynamic_cast<OOX::Logic::CObject*>(oox_unknown);
|
||||
convert(pObj);
|
||||
}break;
|
||||
case OOX::et_pic_pic:
|
||||
case OOX::et_pic:
|
||||
case OOX::et_p_pic:
|
||||
@ -353,23 +362,27 @@ void DocxConverter::convert(OOX::WritingElement *oox_unknown)
|
||||
}break;
|
||||
case OOX::et_w_commentReference:
|
||||
{
|
||||
OOX::Logic::CCommentReference* pCommRef = dynamic_cast<OOX::Logic::CCommentReference*>(oox_unknown);
|
||||
convert(pCommRef); //если нет Start - означает начало с предыдущего Run
|
||||
convert(dynamic_cast<OOX::Logic::CCommentReference*>(oox_unknown)); //если нет Start - означает начало с предыдущего Run
|
||||
}break;
|
||||
case OOX::et_w_footnoteReference:
|
||||
{
|
||||
OOX::Logic::CFootnoteReference* pRef= dynamic_cast<OOX::Logic::CFootnoteReference*>(oox_unknown);
|
||||
convert(pRef);
|
||||
convert(dynamic_cast<OOX::Logic::CFootnoteReference*>(oox_unknown));
|
||||
}break;
|
||||
case OOX::et_w_endnoteReference:
|
||||
{
|
||||
OOX::Logic::CEndnoteReference* pRef= dynamic_cast<OOX::Logic::CEndnoteReference*>(oox_unknown);
|
||||
convert(pRef);
|
||||
convert(dynamic_cast<OOX::Logic::CEndnoteReference*>(oox_unknown));
|
||||
}break;
|
||||
case OOX::et_w_endnoteRef:
|
||||
{
|
||||
//add ref ??? todoooo
|
||||
}break;
|
||||
case OOX::et_w_footnoteRef:
|
||||
{
|
||||
//add ref
|
||||
}break;
|
||||
case OOX::et_w_tbl:
|
||||
{
|
||||
OOX::Logic::CTbl* pTable= dynamic_cast<OOX::Logic::CTbl*>(oox_unknown);
|
||||
convert(pTable);
|
||||
convert(dynamic_cast<OOX::Logic::CTbl*>(oox_unknown));
|
||||
}break;
|
||||
case OOX::et_w_tr:
|
||||
{
|
||||
@ -381,6 +394,12 @@ void DocxConverter::convert(OOX::WritingElement *oox_unknown)
|
||||
OOX::Logic::CTc* pCell= dynamic_cast<OOX::Logic::CTc*>(oox_unknown);
|
||||
convert(pCell);
|
||||
}break;
|
||||
case OOX::et_w_bookmarkStart:
|
||||
{
|
||||
}break;
|
||||
case OOX::et_w_bookmarkEnd:
|
||||
{
|
||||
}break;
|
||||
default:
|
||||
{
|
||||
OoxConverter::convert(oox_unknown);
|
||||
@ -394,12 +413,15 @@ void DocxConverter::convert(OOX::Logic::CSdt *oox_sdt)
|
||||
//nullable<OOX::Logic::CSdtEndPr > m_oSdtEndPr;
|
||||
//nullable<OOX::Logic::CSdtPr > m_oSdtPr;
|
||||
|
||||
if (oox_sdt->m_oSdtContent.IsInit())
|
||||
convert(oox_sdt->m_oSdtContent.GetPointer());
|
||||
}
|
||||
void DocxConverter::convert(OOX::Logic::CSdtContent *oox_sdt)
|
||||
{
|
||||
if (oox_sdt == NULL) return;
|
||||
|
||||
for (size_t i = 0; i < oox_sdt->m_arrItems.size(); i++)
|
||||
{
|
||||
for (unsigned int i=0; i< oox_sdt->m_oSdtContent->m_arrItems.size(); i++)
|
||||
{
|
||||
convert(oox_sdt->m_oSdtContent->m_arrItems[i]);
|
||||
}
|
||||
convert(oox_sdt->m_arrItems[i]);
|
||||
}
|
||||
}
|
||||
void DocxConverter::convert(OOX::Logic::CParagraph *oox_paragraph)
|
||||
@ -2692,9 +2714,12 @@ void DocxConverter::convert(OOX::Drawing::CAnchor *oox_anchor)
|
||||
int id = oox_anchor->m_oRelativeHeight->GetValue();
|
||||
odf_context()->drawing_context()->set_z_order(id);
|
||||
}
|
||||
|
||||
OoxConverter::convert(oox_anchor->m_oDocPr.GetPointer());
|
||||
|
||||
convert(&oox_anchor->m_oGraphic);
|
||||
odf_context()->drawing_context()->start_drawing();
|
||||
OoxConverter::convert(&oox_anchor->m_oGraphic);
|
||||
odf_context()->drawing_context()->end_drawing();
|
||||
|
||||
odf_context()->drawing_context()->check_anchor();
|
||||
}
|
||||
@ -2724,9 +2749,12 @@ void DocxConverter::convert(OOX::Drawing::CInline *oox_inline)
|
||||
|
||||
odt_context->drawing_context()->set_vertical_rel(2);//line
|
||||
odt_context->drawing_context()->set_vertical_pos(1);//middle
|
||||
|
||||
|
||||
OoxConverter::convert(oox_inline->m_oDocPr.GetPointer());
|
||||
convert(&oox_inline->m_oGraphic);
|
||||
|
||||
odf_context()->drawing_context()->start_drawing();
|
||||
OoxConverter::convert(&oox_inline->m_oGraphic);
|
||||
odf_context()->drawing_context()->end_drawing();
|
||||
}
|
||||
|
||||
void DocxConverter::convert(SimpleTypes::CHexColor<> *color,
|
||||
@ -3017,7 +3045,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(false, oox_num_style->m_oAbstractNumId->GetValue());
|
||||
odt_context->styles_context()->lists_styles().start_style(true, oox_num_style->m_oAbstractNumId->GetValue());
|
||||
//// Childs
|
||||
//std::vector<OOX::Numbering::CLvl > m_arrLvl;
|
||||
//nullable<ComplexTypes::Word::CMultiLevelType > m_oMultiLevelType;
|
||||
|
||||
@ -95,6 +95,7 @@ namespace OOX
|
||||
class CTcBorders;
|
||||
class CTblBorders;
|
||||
class CSdt;
|
||||
class CSdtContent;
|
||||
class CBackground;
|
||||
class CLockedCanvas;
|
||||
|
||||
@ -146,12 +147,14 @@ namespace Oox2Odf
|
||||
virtual void convertDocument();
|
||||
virtual void write(const std::wstring & path);
|
||||
|
||||
virtual OOX::IFileContainer *current_document();
|
||||
virtual odf_writer::odf_conversion_context *odf_context();
|
||||
virtual PPTX::Theme *oox_theme();
|
||||
virtual std::wstring find_link_by_id (std::wstring sId, int t);
|
||||
virtual NSCommon::smart_ptr<OOX::File> find_file_by_id(std::wstring sId);
|
||||
|
||||
void convert(OOX::WritingElement *oox_unknown);
|
||||
void convert(OOX::WritingElement *oox_unknown);
|
||||
void convert(OOX::Logic::CSdtContent *oox_sdt);
|
||||
private:
|
||||
struct _section
|
||||
{
|
||||
@ -220,7 +223,7 @@ namespace Oox2Odf
|
||||
|
||||
void convert(OOX::Drawing::CAnchor *oox_anchor);
|
||||
void convert(OOX::Drawing::CInline *oox_inline);
|
||||
|
||||
|
||||
void convert(SimpleTypes::CTheme<> *oox_font_theme,_CP_OPT(std::wstring) & odf_font_name);
|
||||
void convert(ComplexTypes::Word::CColor *color, _CP_OPT(odf_types::color) & odf_color);
|
||||
void convert(SimpleTypes::CUniversalMeasure *oox_size, _CP_OPT(odf_types::length) & odf_size);
|
||||
|
||||
@ -60,7 +60,18 @@ namespace Oox2Odf
|
||||
{
|
||||
PptxConverter::PptxConverter(const std::wstring & path, const ProgressCallback* CallBack)
|
||||
{
|
||||
const OOX::CPath oox_path(std::wstring(path.c_str()));
|
||||
current_clrMap = NULL;
|
||||
current_slide = NULL;
|
||||
current_theme = NULL;
|
||||
current_tableStyles = NULL;
|
||||
|
||||
presentation = NULL;
|
||||
output_document = NULL;
|
||||
odp_context = NULL;
|
||||
|
||||
pCallBack = CallBack;
|
||||
|
||||
const OOX::CPath oox_path(std::wstring(path.c_str()));
|
||||
|
||||
pptx_document = new PPTX::Folder();
|
||||
if (!pptx_document->isValid(oox_path.GetPath())) // true ???
|
||||
@ -82,13 +93,6 @@ PptxConverter::PptxConverter(const std::wstring & path, const ProgressCallback*
|
||||
output_document = new odf_writer::package::odf_document(L"presentation");
|
||||
odp_context = new odf_writer::odp_conversion_context(output_document);
|
||||
|
||||
current_clrMap = NULL;
|
||||
current_slide = NULL;
|
||||
current_theme = NULL;
|
||||
current_tableStyles = NULL;
|
||||
|
||||
pCallBack = CallBack;
|
||||
|
||||
if (UpdateProgress(290000))return;
|
||||
}
|
||||
PptxConverter::~PptxConverter()
|
||||
@ -123,7 +127,15 @@ PPTX::Logic::ClrMap* PptxConverter::oox_clrMap()
|
||||
{
|
||||
return current_clrMap;
|
||||
}
|
||||
|
||||
OOX::IFileContainer* PptxConverter::current_document()
|
||||
{
|
||||
if (oox_current_child_document)
|
||||
return oox_current_child_document;
|
||||
else if (current_slide)
|
||||
return current_slide;
|
||||
else
|
||||
return pptx_document;
|
||||
}
|
||||
NSCommon::smart_ptr<OOX::File> PptxConverter::find_file_by_id(std::wstring sId)
|
||||
{
|
||||
smart_ptr<OOX::File> oFile;
|
||||
@ -319,12 +331,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
|
||||
@ -334,15 +349,17 @@ void PptxConverter::convert_slides()
|
||||
convert_common();
|
||||
|
||||
current_slide = slide->Master.operator->();
|
||||
if (bShowMasterSp)
|
||||
convert_slide(&slide->Master->cSld, current_txStyles, false);
|
||||
|
||||
if (bShowLayoutMasterSp && bShowMasterSp)
|
||||
convert_slide(&slide->Master->cSld, current_txStyles, false, true);
|
||||
else
|
||||
convert(slide->Master->cSld.bg.GetPointer());
|
||||
|
||||
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);
|
||||
current_slide = slide->Layout.operator->();
|
||||
|
||||
convert_slide(&slide->Layout->cSld, current_txStyles, true, bShowLayoutMasterSp);
|
||||
//add note master
|
||||
odp_context->end_master_slide();
|
||||
|
||||
@ -382,7 +399,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);
|
||||
convert_slide (slide->cSld.GetPointer(), current_txStyles, true, bShowMasterSp);
|
||||
convert (slide->comments.operator->());
|
||||
convert (slide->Note.operator->());
|
||||
|
||||
@ -938,7 +955,7 @@ void PptxConverter::convert(PPTX::Logic::Bg *oox_background)
|
||||
odp_context->end_drawings();
|
||||
}
|
||||
|
||||
void PptxConverter::convert_slide(PPTX::Logic::CSld *oox_slide, PPTX::Logic::TxStyles* txStyles, bool bPlaceholders)
|
||||
void PptxConverter::convert_slide(PPTX::Logic::CSld *oox_slide, PPTX::Logic::TxStyles* txStyles, bool bPlaceholders, bool bFillUp)
|
||||
{
|
||||
if (oox_slide == NULL) return;
|
||||
|
||||
@ -949,63 +966,90 @@ 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())
|
||||
odf_context()->drawing_context()->start_drawing();
|
||||
|
||||
if (pShape.IsInit())
|
||||
{
|
||||
pShape->FillLevelUp();
|
||||
|
||||
if (pShape->nvSpPr.nvPr.ph->type.IsInit())
|
||||
odf_context()->drawing_context()->set_placeholder_type(pShape->nvSpPr.nvPr.ph->type->GetBYTECode());
|
||||
else
|
||||
odf_context()->drawing_context()->set_placeholder_type(0);
|
||||
|
||||
if (pShape->nvSpPr.nvPr.ph->idx.IsInit())
|
||||
odf_context()->drawing_context()->set_placeholder_id(pShape->nvSpPr.nvPr.ph->idx.get());
|
||||
|
||||
if (!bPlaceholders)
|
||||
continue;
|
||||
|
||||
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();
|
||||
if (bFillUp)
|
||||
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]);
|
||||
}
|
||||
update_shape.txBody->lstStyle.reset(newListStyle);
|
||||
}
|
||||
|
||||
pShape->Merge(update_shape);
|
||||
int ph_type = pShape->nvSpPr.nvPr.ph->type->GetBYTECode();
|
||||
|
||||
OoxConverter::convert(&update_shape);
|
||||
//if (!bMaster && (ph_type == 5 || ph_type == 6 || ph_type == 7 || ph_type == 12))
|
||||
// continue;
|
||||
|
||||
odf_context()->drawing_context()->set_placeholder_type(ph_type);
|
||||
}
|
||||
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);
|
||||
}
|
||||
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();
|
||||
|
||||
presentation->defaultTextStyle->Merge(update_shape.txBody->lstStyle);
|
||||
|
||||
pShape->Merge(update_shape);
|
||||
OoxConverter::convert(&update_shape);
|
||||
}
|
||||
else
|
||||
OoxConverter::convert(pShape.operator->());
|
||||
}
|
||||
else
|
||||
{
|
||||
OoxConverter::convert(pElem.operator->());
|
||||
}
|
||||
odf_context()->drawing_context()->end_drawing();
|
||||
}
|
||||
convert(oox_slide->controls.GetPointer());
|
||||
}
|
||||
|
||||
@ -97,16 +97,17 @@ namespace Oox2Odf
|
||||
virtual void convertDocument();
|
||||
virtual void write(const std::wstring & path);
|
||||
|
||||
virtual OOX::IFileContainer *current_document();
|
||||
virtual odf_writer::odf_conversion_context *odf_context();
|
||||
virtual PPTX::Theme *oox_theme();
|
||||
virtual PPTX::Logic::ClrMap *oox_clrMap();
|
||||
|
||||
|
||||
virtual std::wstring find_link_by_id (std::wstring sId, int t);
|
||||
virtual NSCommon::smart_ptr<OOX::File> find_file_by_id (std::wstring sId);
|
||||
|
||||
void convert(OOX::WritingElement *oox_unknown);
|
||||
|
||||
void convert_slide (PPTX::Logic::CSld *oox_slide, PPTX::Logic::TxStyles* txStyles, bool bPlaceholders = true);
|
||||
void convert_slide (PPTX::Logic::CSld *oox_slide, PPTX::Logic::TxStyles* txStyles, bool bPlaceholders, bool bFillUp);
|
||||
void convert_layout (PPTX::Logic::CSld *oox_slide);
|
||||
void convert (PPTX::Comments *oox_comments);
|
||||
void convert (PPTX::NotesSlide *oox_note);
|
||||
|
||||
@ -94,6 +94,15 @@ PPTX::Theme* XlsxConverter::oox_theme()
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
OOX::IFileContainer* XlsxConverter::current_document()
|
||||
{
|
||||
if (xlsx_current_container)
|
||||
return xlsx_current_container;
|
||||
else if (oox_current_child_document)
|
||||
return oox_current_child_document;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
smart_ptr<OOX::File> XlsxConverter::find_file_by_id(std::wstring sId)
|
||||
{
|
||||
smart_ptr<OOX::File> oFile;
|
||||
@ -1718,7 +1727,9 @@ void XlsxConverter::convert(OOX::Spreadsheet::CCellAnchor *oox_anchor)
|
||||
if (oox_anchor->m_oExt.IsInit())
|
||||
{
|
||||
}
|
||||
OoxConverter::convert(oox_anchor->m_oElement.GetPointer());
|
||||
odf_context()->drawing_context()->start_drawing();
|
||||
OoxConverter::convert(oox_anchor->m_oElement.GetPointer());
|
||||
odf_context()->drawing_context()->end_drawing();
|
||||
}
|
||||
|
||||
void XlsxConverter::convert(OOX::Spreadsheet::CDrawing *oox_drawing)
|
||||
|
||||
@ -130,6 +130,7 @@ namespace Oox2Odf
|
||||
virtual void convertDocument();
|
||||
virtual void write(const std::wstring & path);
|
||||
|
||||
virtual OOX::IFileContainer *current_document();
|
||||
virtual odf_writer::odf_conversion_context *odf_context();
|
||||
virtual PPTX::Theme *oox_theme();
|
||||
virtual std::wstring find_link_by_id (std::wstring sId, int t);
|
||||
|
||||
@ -120,21 +120,29 @@ namespace PPTX
|
||||
oAttr.Write(_T("noResize"), noResize);
|
||||
oAttr.Write(_T("noSelect"), noSelect);
|
||||
|
||||
return XmlUtils::CreateNode(m_namespace + L":cNvGraphicFramePr", oAttr.m_strValue.empty() ? L"" : XmlUtils::CreateNode(L"a:graphicFrameLocks", oAttr));
|
||||
std::wstring namespaceLocks = L"a";
|
||||
if (m_namespace == L"wp") namespaceLocks = L"wp";
|
||||
|
||||
return XmlUtils::CreateNode(m_namespace + L":cNvGraphicFramePr", oAttr.m_strValue.empty() ? L"" : XmlUtils::CreateNode(namespaceLocks + L":graphicFrameLocks", oAttr));
|
||||
}
|
||||
|
||||
virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const
|
||||
{
|
||||
std::wstring namespace_ = m_namespace;
|
||||
std::wstring namespace_ = m_namespace;
|
||||
std::wstring namespaceLock_ = L"a";
|
||||
|
||||
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX) namespace_ = L"xdr";
|
||||
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX) namespace_ = L"wp";
|
||||
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX)
|
||||
{
|
||||
namespaceLock_ = L"wp";
|
||||
namespace_ = L"wp";
|
||||
}
|
||||
|
||||
pWriter->StartNode(namespace_ + L":cNvGraphicFramePr");
|
||||
|
||||
pWriter->EndAttributes();
|
||||
|
||||
pWriter->StartNode(_T("a:graphicFrameLocks"));
|
||||
pWriter->StartNode(namespaceLock_ + L"graphicFrameLocks");
|
||||
|
||||
pWriter->StartAttributes();
|
||||
|
||||
@ -147,7 +155,7 @@ namespace PPTX
|
||||
|
||||
pWriter->EndAttributes();
|
||||
|
||||
pWriter->EndNode(_T("a:graphicFrameLocks"));
|
||||
pWriter->EndNode(namespaceLock_ + L":graphicFrameLocks");
|
||||
|
||||
pWriter->EndNode(namespace_ + L":cNvGraphicFramePr");
|
||||
}
|
||||
|
||||
@ -53,12 +53,14 @@ namespace PPTX
|
||||
{
|
||||
name = oReader.GetName();
|
||||
|
||||
ReadAttributes( oReader );
|
||||
|
||||
if (XmlUtils::GetNameNoNS(name) == _T("alpha"))
|
||||
{
|
||||
ReadAttributes2( oReader );
|
||||
}
|
||||
else
|
||||
{
|
||||
ReadAttributes( oReader );
|
||||
}
|
||||
}
|
||||
void ReadAttributes2(XmlUtils::CXmlLiteReader& oReader)
|
||||
{
|
||||
@ -67,8 +69,14 @@ namespace PPTX
|
||||
WritingElement_ReadAttributes_ReadSingle ( oReader, _T("val"), sTmp)
|
||||
WritingElement_ReadAttributes_End( oReader )
|
||||
|
||||
if (val.is_init() && sTmp.is_init() && sTmp->find(wchar_t('%')) != -1)
|
||||
*val = (*val) * 1000;
|
||||
if (sTmp.is_init())
|
||||
{
|
||||
val = sTmp.get();
|
||||
if (val.is_init() && std::wstring::npos != sTmp->find(L"%"))
|
||||
{
|
||||
*val = (*val) * 1000;
|
||||
}
|
||||
}
|
||||
}
|
||||
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
|
||||
{
|
||||
@ -86,7 +94,7 @@ namespace PPTX
|
||||
nullable_string sTmp;
|
||||
node.ReadAttributeBase(L"val", sTmp);
|
||||
|
||||
if (val.is_init() && sTmp.is_init() && sTmp->find(wchar_t('%')) != -1)
|
||||
if (val.is_init() && sTmp.is_init() && std::wstring::npos != sTmp->find(L"%"))
|
||||
*val = (*val) * 1000;
|
||||
}
|
||||
}
|
||||
|
||||
@ -122,8 +122,8 @@ namespace PPTX
|
||||
|
||||
if (L"xfrm" == strName && strNamespace != L"xdr")
|
||||
xfrm = oReader;
|
||||
else if (L"nvGraphicFramePr" == strName)
|
||||
nvGraphicFramePr.fromXML( oReader );
|
||||
else if (L"cNvGraphicFramePr" == strName)
|
||||
nvGraphicFramePr.cNvGraphicFramePr.fromXML( oReader );
|
||||
|
||||
else if (L"graphic" == strName)
|
||||
{
|
||||
|
||||
@ -48,17 +48,15 @@ namespace PPTX
|
||||
{
|
||||
namespace Logic
|
||||
{
|
||||
void SmartArt::LoadDrawing(NSBinPptxRW::CBinaryFileWriter* pWriter)
|
||||
bool SmartArt::LoadDrawing(OOX::IFileContainer* pRels)
|
||||
{
|
||||
if (m_diag.IsInit())
|
||||
return ;
|
||||
return true;
|
||||
|
||||
OOX::IFileContainer* pRels = NULL;
|
||||
if (pWriter)
|
||||
{
|
||||
if (pWriter->m_pCurrentContainer->is_init())
|
||||
pRels = pWriter->m_pCurrentContainer->operator ->();
|
||||
}
|
||||
if(id_data.IsInit() == false) return false;
|
||||
if (pRels == NULL) return false;
|
||||
|
||||
bool result = false;
|
||||
|
||||
smart_ptr<OOX::File> oFileData;
|
||||
smart_ptr<OOX::File> oFileDrawing;
|
||||
@ -67,15 +65,12 @@ namespace PPTX
|
||||
OOX::CDiagramData* pDiagramData = NULL;
|
||||
OOX::CDiagramDrawing* pDiagramDrawing = NULL;
|
||||
|
||||
if(id_data.IsInit())
|
||||
{
|
||||
if (parentFileIs<OOX::IFileContainer>()) oFileData = parentFileAs<OOX::IFileContainer>().Find(*id_data);
|
||||
else if (pRels != NULL) oFileData = pRels->Find(*id_data);
|
||||
}
|
||||
oFileData = pRels->Find(*id_data);
|
||||
|
||||
if (oFileData.IsInit())
|
||||
{
|
||||
pDiagramData = dynamic_cast<OOX::CDiagramData*>(oFileData.operator->());
|
||||
if (pDiagramData) result = true; // это smart art ..есть у него drawing или нет - неважно
|
||||
|
||||
if ((pDiagramData) && (pDiagramData->m_oExtLst.IsInit()))
|
||||
{
|
||||
@ -131,6 +126,25 @@ namespace PPTX
|
||||
{
|
||||
//parse pDiagramData !!
|
||||
}
|
||||
return true;
|
||||
}
|
||||
void SmartArt::LoadDrawing(NSBinPptxRW::CBinaryFileWriter* pWriter)
|
||||
{
|
||||
if (m_diag.IsInit())
|
||||
return ;
|
||||
|
||||
OOX::IFileContainer & pRelsPPTX = parentFileAs<OOX::IFileContainer>();
|
||||
OOX::IFileContainer * pRels = NULL;
|
||||
|
||||
if (pWriter)
|
||||
{
|
||||
if (pWriter->m_pCurrentContainer->is_init())
|
||||
pRels = pWriter->m_pCurrentContainer->operator ->();
|
||||
}
|
||||
|
||||
bool result = LoadDrawing(&pRelsPPTX);
|
||||
if (!result)
|
||||
result = LoadDrawing( pRels );
|
||||
}
|
||||
void SmartArt::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const
|
||||
{
|
||||
|
||||
@ -115,6 +115,7 @@ namespace PPTX
|
||||
|
||||
public:
|
||||
void LoadDrawing(NSBinPptxRW::CBinaryFileWriter* pWriter = NULL);
|
||||
bool LoadDrawing(OOX::IFileContainer* pRels);
|
||||
};
|
||||
|
||||
class ChartRec : public WrapperWritingElement
|
||||
|
||||
@ -156,6 +156,16 @@ namespace PPTX
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (pShape->nvSpPr.nvPr.ph->idx.IsInit())
|
||||
{
|
||||
//not found in layout !! 100818_건강보험과_보건의료_김용익_최종.pptx
|
||||
bool bShapeMaster = showMasterSp.get_value_or(true);
|
||||
if (Master.IsInit() && bShapeMaster)
|
||||
{
|
||||
Master->GetLevelUp(pShape);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
virtual std::wstring GetMediaFullPathNameFromRId(const OOX::RId& rid)const
|
||||
|
||||
@ -26,10 +26,8 @@
|
||||
17C1FCBE1ACC429D006B99B3 /* EffectProperties.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 179A443D1AC57B83005A27F7 /* EffectProperties.cpp */; };
|
||||
17C1FCBF1ACC429D006B99B3 /* EffectLst.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 179A443B1AC57B83005A27F7 /* EffectLst.cpp */; };
|
||||
17C1FCC11ACC429D006B99B3 /* FileMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 179A43A31AC57B83005A27F7 /* FileMap.cpp */; };
|
||||
17C1FCC21ACC429D006B99B3 /* ShapeTextProperties.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 179A44AC1AC57B83005A27F7 /* ShapeTextProperties.cpp */; };
|
||||
17C1FCC31ACC429D006B99B3 /* TransitionBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 179A45051AC57B83005A27F7 /* TransitionBase.cpp */; };
|
||||
17C1FCC51ACC429D006B99B3 /* Shape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 179A44A71AC57B83005A27F7 /* Shape.cpp */; };
|
||||
17C1FCC61ACC429D006B99B3 /* ShapeProperties.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 179A44A91AC57B83005A27F7 /* ShapeProperties.cpp */; };
|
||||
17C1FCC71ACC429D006B99B3 /* BuildNodeBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 179A44DE1AC57B83005A27F7 /* BuildNodeBase.cpp */; };
|
||||
17C1FCC81ACC429D006B99B3 /* ContentPart.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 179A44311AC57B83005A27F7 /* ContentPart.cpp */; };
|
||||
17C1FCC91ACC429D006B99B3 /* CNvGrpSpPr.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 179A44241AC57B83005A27F7 /* CNvGrpSpPr.cpp */; };
|
||||
@ -306,7 +304,6 @@
|
||||
17C1FDFE1ACC429D006B99B3 /* XfrmEffect.h in Headers */ = {isa = PBXBuildFile; fileRef = 179A445C1AC57B83005A27F7 /* XfrmEffect.h */; };
|
||||
17C1FDFF1ACC429D006B99B3 /* ChartBuildType.h in Headers */ = {isa = PBXBuildFile; fileRef = 179A43B51AC57B83005A27F7 /* ChartBuildType.h */; };
|
||||
17C1FE001ACC429D006B99B3 /* SndAc.h in Headers */ = {isa = PBXBuildFile; fileRef = 179A45011AC57B83005A27F7 /* SndAc.h */; };
|
||||
17C1FE011ACC429D006B99B3 /* ShapeProperties.h in Headers */ = {isa = PBXBuildFile; fileRef = 179A44AA1AC57B83005A27F7 /* ShapeProperties.h */; };
|
||||
17C1FE021ACC429D006B99B3 /* AlphaModFix.h in Headers */ = {isa = PBXBuildFile; fileRef = 179A44451AC57B83005A27F7 /* AlphaModFix.h */; };
|
||||
17C1FE041ACC429D006B99B3 /* Duotone.h in Headers */ = {isa = PBXBuildFile; fileRef = 179A444D1AC57B83005A27F7 /* Duotone.h */; };
|
||||
17C1FE061ACC429D006B99B3 /* ColorBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 179A442A1AC57B83005A27F7 /* ColorBase.h */; };
|
||||
@ -396,7 +393,6 @@
|
||||
17C1FE601ACC429D006B99B3 /* Set.h in Headers */ = {isa = PBXBuildFile; fileRef = 179A44EB1AC57B83005A27F7 /* Set.h */; };
|
||||
17C1FE611ACC429D006B99B3 /* ShapeStyle.h in Headers */ = {isa = PBXBuildFile; fileRef = 179A44AB1AC57B83005A27F7 /* ShapeStyle.h */; };
|
||||
17C1FE621ACC429D006B99B3 /* BaseLimit.h in Headers */ = {isa = PBXBuildFile; fileRef = 179A43AE1AC57B83005A27F7 /* BaseLimit.h */; };
|
||||
17C1FE631ACC429D006B99B3 /* ShapeTextProperties.h in Headers */ = {isa = PBXBuildFile; fileRef = 179A44AD1AC57B83005A27F7 /* ShapeTextProperties.h */; };
|
||||
17C1FE641ACC429D006B99B3 /* BinReaderWriterDefines.h in Headers */ = {isa = PBXBuildFile; fileRef = 17D91A171AC5A4DF0096D788 /* BinReaderWriterDefines.h */; };
|
||||
17C1FE651ACC429D006B99B3 /* ClrMapOvr.h in Headers */ = {isa = PBXBuildFile; fileRef = 179A44211AC57B83005A27F7 /* ClrMapOvr.h */; };
|
||||
17C1FE661ACC429D006B99B3 /* Glow.h in Headers */ = {isa = PBXBuildFile; fileRef = 179A44511AC57B83005A27F7 /* Glow.h */; };
|
||||
@ -705,11 +701,7 @@
|
||||
179A44A61AC57B83005A27F7 /* Scene3d.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Scene3d.h; sourceTree = "<group>"; };
|
||||
179A44A71AC57B83005A27F7 /* Shape.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Shape.cpp; sourceTree = "<group>"; };
|
||||
179A44A81AC57B83005A27F7 /* Shape.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Shape.h; sourceTree = "<group>"; };
|
||||
179A44A91AC57B83005A27F7 /* ShapeProperties.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ShapeProperties.cpp; sourceTree = "<group>"; };
|
||||
179A44AA1AC57B83005A27F7 /* ShapeProperties.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ShapeProperties.h; sourceTree = "<group>"; };
|
||||
179A44AB1AC57B83005A27F7 /* ShapeStyle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ShapeStyle.h; sourceTree = "<group>"; };
|
||||
179A44AC1AC57B83005A27F7 /* ShapeTextProperties.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ShapeTextProperties.cpp; sourceTree = "<group>"; };
|
||||
179A44AD1AC57B83005A27F7 /* ShapeTextProperties.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ShapeTextProperties.h; sourceTree = "<group>"; };
|
||||
179A44AE1AC57B83005A27F7 /* SmartArt.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SmartArt.cpp; sourceTree = "<group>"; };
|
||||
179A44AF1AC57B83005A27F7 /* SmartArt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SmartArt.h; sourceTree = "<group>"; };
|
||||
179A44B01AC57B83005A27F7 /* Sp3d.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Sp3d.h; sourceTree = "<group>"; };
|
||||
@ -1176,11 +1168,7 @@
|
||||
179A44A61AC57B83005A27F7 /* Scene3d.h */,
|
||||
179A44A71AC57B83005A27F7 /* Shape.cpp */,
|
||||
179A44A81AC57B83005A27F7 /* Shape.h */,
|
||||
179A44A91AC57B83005A27F7 /* ShapeProperties.cpp */,
|
||||
179A44AA1AC57B83005A27F7 /* ShapeProperties.h */,
|
||||
179A44AB1AC57B83005A27F7 /* ShapeStyle.h */,
|
||||
179A44AC1AC57B83005A27F7 /* ShapeTextProperties.cpp */,
|
||||
179A44AD1AC57B83005A27F7 /* ShapeTextProperties.h */,
|
||||
179A44AE1AC57B83005A27F7 /* SmartArt.cpp */,
|
||||
179A44AF1AC57B83005A27F7 /* SmartArt.h */,
|
||||
179A44B01AC57B83005A27F7 /* Sp3d.h */,
|
||||
@ -1783,7 +1771,6 @@
|
||||
17C1FDFE1ACC429D006B99B3 /* XfrmEffect.h in Headers */,
|
||||
17C1FDFF1ACC429D006B99B3 /* ChartBuildType.h in Headers */,
|
||||
17C1FE001ACC429D006B99B3 /* SndAc.h in Headers */,
|
||||
17C1FE011ACC429D006B99B3 /* ShapeProperties.h in Headers */,
|
||||
17C1FE021ACC429D006B99B3 /* AlphaModFix.h in Headers */,
|
||||
17C1FE041ACC429D006B99B3 /* Duotone.h in Headers */,
|
||||
17C1FE061ACC429D006B99B3 /* ColorBase.h in Headers */,
|
||||
@ -1873,7 +1860,6 @@
|
||||
17C1FE601ACC429D006B99B3 /* Set.h in Headers */,
|
||||
17C1FE611ACC429D006B99B3 /* ShapeStyle.h in Headers */,
|
||||
17C1FE621ACC429D006B99B3 /* BaseLimit.h in Headers */,
|
||||
17C1FE631ACC429D006B99B3 /* ShapeTextProperties.h in Headers */,
|
||||
17C1FE641ACC429D006B99B3 /* BinReaderWriterDefines.h in Headers */,
|
||||
17C1FE651ACC429D006B99B3 /* ClrMapOvr.h in Headers */,
|
||||
17C1FE661ACC429D006B99B3 /* Glow.h in Headers */,
|
||||
@ -1981,11 +1967,9 @@
|
||||
17C1FCBF1ACC429D006B99B3 /* EffectLst.cpp in Sources */,
|
||||
695BC03A1C070DEF00817D7E /* ASCSVGWriter.cpp in Sources */,
|
||||
17C1FCC11ACC429D006B99B3 /* FileMap.cpp in Sources */,
|
||||
17C1FCC21ACC429D006B99B3 /* ShapeTextProperties.cpp in Sources */,
|
||||
696791821D9E8B81002CA4BA /* MathParaWrapper.cpp in Sources */,
|
||||
17C1FCC31ACC429D006B99B3 /* TransitionBase.cpp in Sources */,
|
||||
17C1FCC51ACC429D006B99B3 /* Shape.cpp in Sources */,
|
||||
17C1FCC61ACC429D006B99B3 /* ShapeProperties.cpp in Sources */,
|
||||
17C1FCC71ACC429D006B99B3 /* BuildNodeBase.cpp in Sources */,
|
||||
17C1FCC81ACC429D006B99B3 /* ContentPart.cpp in Sources */,
|
||||
17C1FCC91ACC429D006B99B3 /* CNvGrpSpPr.cpp in Sources */,
|
||||
|
||||
@ -246,4 +246,7 @@ HEADERS += docxformatlib.h \
|
||||
../Source/XlsxFormat/Worksheets/Sparkline.h \
|
||||
../Source/XlsxFormat/Ole/OleObjects.h \
|
||||
../Source/DocxFormat/Diagram/DiagramData.h \
|
||||
../Source/DocxFormat/Diagram/DiagramDrawing.h
|
||||
../Source/DocxFormat/Diagram/DiagramDrawing.h \
|
||||
../Source/XlsxFormat/Pivot/PivotTable.h \
|
||||
../Source/XlsxFormat/Pivot/PivotCacheDefinition.h \
|
||||
../Source/XlsxFormat/Pivot/PivotCacheRecords.h
|
||||
|
||||
@ -110,9 +110,16 @@ namespace OOX
|
||||
OOX::CPath oName = pFile->DefaultFileName();
|
||||
if(false == pFile->m_sOutputFilename.empty())
|
||||
oName.SetName(pFile->m_sOutputFilename, false);
|
||||
|
||||
OOX::CSystemUtility::CreateDirectories( oCurrent / oDefDir );
|
||||
pFile->write( oCurrent / oDefDir / oName, oDir / oDefDir, oContent );
|
||||
std::map<std::wstring, std::wstring>::const_iterator itFind = m_mNoWriteContainer.find(pPair->first);
|
||||
if(m_mNoWriteContainer.end() == itFind)
|
||||
{
|
||||
OOX::CSystemUtility::CreateDirectories( oCurrent / oDefDir );
|
||||
pFile->write( oCurrent / oDefDir / oName, oDir / oDefDir, oContent );
|
||||
}
|
||||
else if(itFind->second.length() > 0)
|
||||
{
|
||||
oDefDir = itFind->second;
|
||||
}
|
||||
if(true != pFile->m_bDoNotAddRels)
|
||||
{
|
||||
if (oDefDir.GetPath().length() > 0)//todooo перенести в CPath
|
||||
@ -187,16 +194,23 @@ namespace OOX
|
||||
mNamepair [oName.m_strFilename] = 1;
|
||||
else
|
||||
oName = oName + pNamePair->first;
|
||||
|
||||
OOX::CSystemUtility::CreateDirectories( oCurrent / oDefDir );
|
||||
smart_ptr<OOX::IFileBuilder> pFileBuilder = pFile.smart_dynamic_cast<OOX::IFileBuilder>();
|
||||
if ( pFileBuilder.is_init() )
|
||||
std::map<std::wstring, std::wstring>::const_iterator itFind = m_mNoWriteContainer.find(it->first);
|
||||
if(m_mNoWriteContainer.end() == itFind)
|
||||
{
|
||||
pFileBuilder->Finalize( oCurrent / oDefDir / oName, oDir / oDefDir, oContent );
|
||||
OOX::CSystemUtility::CreateDirectories( oCurrent / oDefDir );
|
||||
smart_ptr<OOX::IFileBuilder> pFileBuilder = pFile.smart_dynamic_cast<OOX::IFileBuilder>();
|
||||
if ( pFileBuilder.is_init() )
|
||||
{
|
||||
pFileBuilder->Finalize( oCurrent / oDefDir / oName, oDir / oDefDir, oContent );
|
||||
}
|
||||
else
|
||||
{
|
||||
pFile->write( oCurrent / oDefDir / oName, oDir / oDefDir, oContent );
|
||||
}
|
||||
}
|
||||
else
|
||||
else if(itFind->second.length() > 0)
|
||||
{
|
||||
pFile->write( oCurrent / oDefDir / oName, oDir / oDefDir, oContent );
|
||||
oDefDir = itFind->second;
|
||||
}
|
||||
|
||||
oRels.Registration( it->first, pFile->type(), oDefDir / oName );
|
||||
@ -386,6 +400,20 @@ namespace OOX
|
||||
m_mContainer [rId.get()] = pFile;
|
||||
}
|
||||
|
||||
const RId IFileContainer::AddNoWrite(const smart_ptr<OOX::File>& pFile, const std::wstring& oDefDir)
|
||||
{
|
||||
const RId rId = GetMaxRId().next();
|
||||
AddNoWrite( rId, pFile, oDefDir );
|
||||
return rId;
|
||||
}
|
||||
|
||||
void IFileContainer::AddNoWrite (const OOX::RId& rId, const smart_ptr<OOX::File>& pFile, const std::wstring& oDefDir)
|
||||
{
|
||||
m_lMaxRid = (std::max)( m_lMaxRid, rId.getNumber() );
|
||||
m_mContainer [rId.get()] = pFile;
|
||||
m_mNoWriteContainer[rId.get()] = oDefDir;
|
||||
}
|
||||
|
||||
smart_ptr<OOX::File> IFileContainer::Find(const FileType& oType) const
|
||||
{
|
||||
for (std::map<std::wstring, smart_ptr<OOX::File>>::const_iterator pPair = m_mContainer.begin(); pPair != m_mContainer.end(); ++pPair)
|
||||
|
||||
@ -67,6 +67,7 @@ namespace OOX
|
||||
static std::map<std::wstring, size_t> m_mapEnumeratedGlobal;
|
||||
protected:
|
||||
std::map<std::wstring, smart_ptr<OOX::File>> m_mContainer;
|
||||
std::map<std::wstring, std::wstring> m_mNoWriteContainer;
|
||||
size_t m_lMaxRid;
|
||||
|
||||
void Read (const OOX::CRels& oRels, const OOX::CPath& oRootPath, const CPath& oPath);
|
||||
@ -103,6 +104,8 @@ namespace OOX
|
||||
|
||||
const RId Add(smart_ptr<OOX::File>& pFile);
|
||||
void Add(const OOX::RId& rId, smart_ptr<OOX::File>& pFile);
|
||||
const RId AddNoWrite(const smart_ptr<OOX::File>& pFile, const std::wstring& oDefDir);
|
||||
void AddNoWrite(const OOX::RId& rId, const smart_ptr<OOX::File>& pFile, const std::wstring& oDefDir);
|
||||
|
||||
template<typename T>
|
||||
T& Find();
|
||||
|
||||
@ -81,6 +81,18 @@ namespace OOX
|
||||
const FileType ExternalLinks (L"externalLinks", L"externalLink.xml",
|
||||
_T("application/vnd.openxmlformats-officedocument.spreadsheetml.externalLink+xml"),
|
||||
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/externalLink"), true, true);
|
||||
|
||||
const FileType PivotTable (L"../pivotTables", L"pivotTable.xml",
|
||||
_T("application/vnd.openxmlformats-officedocument.spreadsheetml.pivotTable+xml"),
|
||||
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotTable"), true, true);
|
||||
|
||||
const FileType PivotCacheDefinition(L"pivotCache", L"pivotCacheDefinition.xml",
|
||||
_T("application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheDefinition+xml"),
|
||||
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheDefinition"), true);
|
||||
|
||||
const FileType PivotCacheRecords(L"", L"pivotCacheRecords.xml",
|
||||
_T("application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheRecords+xml"),
|
||||
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheRecords"), true, true);
|
||||
|
||||
|
||||
} // namespace FileTypes
|
||||
|
||||
142
Common/DocxFormat/Source/XlsxFormat/Pivot/PivotCacheDefinition.h
Normal file
142
Common/DocxFormat/Source/XlsxFormat/Pivot/PivotCacheDefinition.h
Normal file
@ -0,0 +1,142 @@
|
||||
/*
|
||||
* (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
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
#ifndef OOX_PIVOTCACHEDEFINITION_FILE_INCLUDE_H_
|
||||
#define OOX_PIVOTCACHEDEFINITION_FILE_INCLUDE_H_
|
||||
|
||||
#include "../CommonInclude.h"
|
||||
|
||||
|
||||
namespace OOX
|
||||
{
|
||||
namespace Spreadsheet
|
||||
{
|
||||
class CPivotCacheDefinition : public OOX::File, public OOX::IFileContainer
|
||||
{
|
||||
public:
|
||||
CPivotCacheDefinition()
|
||||
{
|
||||
m_bSpreadsheets = true;
|
||||
bIsWritten = false;
|
||||
m_pData = NULL;
|
||||
m_nDataLength = 0;
|
||||
}
|
||||
CPivotCacheDefinition(const CPath& oRootPath, const CPath& oPath)
|
||||
{
|
||||
m_bSpreadsheets = true;
|
||||
bIsWritten = false;
|
||||
m_pData = NULL;
|
||||
m_nDataLength = 0;
|
||||
read( oRootPath, oPath );
|
||||
}
|
||||
virtual ~CPivotCacheDefinition()
|
||||
{
|
||||
ClearItems();
|
||||
}
|
||||
public:
|
||||
|
||||
virtual void read(const CPath& oPath)
|
||||
{
|
||||
}
|
||||
virtual void read(const CPath& oRootPath, const CPath& oPath)
|
||||
{
|
||||
}
|
||||
virtual void write(const CPath& oPath, const CPath& oDirectory, CContentTypes& oContent) const
|
||||
{
|
||||
if(m_nDataLength > 0 && !bIsWritten)
|
||||
{
|
||||
NSFile::CFileBinary oFile;
|
||||
oFile.CreateFileW(oPath.GetPath());
|
||||
oFile.WriteFile(m_pData, m_nDataLength);
|
||||
oFile.CloseFile();
|
||||
|
||||
oContent.Registration( type().OverrideType(), oDirectory, oPath.GetFilename() );
|
||||
IFileContainer::Write( oPath, oDirectory, oContent );
|
||||
|
||||
//prevent repeated write
|
||||
bIsWritten = true;
|
||||
}
|
||||
}
|
||||
virtual const OOX::FileType type() const
|
||||
{
|
||||
return OOX::Spreadsheet::FileTypes::PivotCacheDefinition;
|
||||
}
|
||||
virtual const CPath DefaultDirectory() const
|
||||
{
|
||||
return type().DefaultDirectory();
|
||||
}
|
||||
virtual const CPath DefaultFileName() const
|
||||
{
|
||||
return type().DefaultFileName();
|
||||
}
|
||||
const CPath& GetReadPath()
|
||||
{
|
||||
return m_oReadPath;
|
||||
}
|
||||
void setData(BYTE* pData, long length, const std::wstring& srIdRecords)
|
||||
{
|
||||
if(srIdRecords.length() > 0)
|
||||
{
|
||||
const std::string srIdRecordsA( srIdRecords.begin(), srIdRecords.end() );
|
||||
std::string rIdAttr = " r:id=\""+ srIdRecordsA +"\"";
|
||||
m_nDataLength = length + rIdAttr.length();
|
||||
m_pData = new BYTE[m_nDataLength];
|
||||
long nTreshold = 220;
|
||||
memcpy(m_pData, pData, nTreshold);
|
||||
memcpy(m_pData + nTreshold, rIdAttr.c_str(), rIdAttr.length());
|
||||
memcpy(m_pData + nTreshold + rIdAttr.length(), pData + nTreshold, length - nTreshold);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
m_nDataLength = length;
|
||||
memcpy(m_pData, pData, length);
|
||||
}
|
||||
}
|
||||
private:
|
||||
CPath m_oReadPath;
|
||||
|
||||
void ClearItems()
|
||||
{
|
||||
m_nDataLength = 0;
|
||||
RELEASEARRAYOBJECTS(m_pData)
|
||||
}
|
||||
|
||||
public:
|
||||
mutable bool bIsWritten;
|
||||
BYTE* m_pData;
|
||||
long m_nDataLength;
|
||||
};
|
||||
} //Spreadsheet
|
||||
} // namespace OOX
|
||||
|
||||
#endif // OOX_PIVOTCACHEDEFINITION_FILE_INCLUDE_H_
|
||||
124
Common/DocxFormat/Source/XlsxFormat/Pivot/PivotCacheRecords.h
Normal file
124
Common/DocxFormat/Source/XlsxFormat/Pivot/PivotCacheRecords.h
Normal file
@ -0,0 +1,124 @@
|
||||
/*
|
||||
* (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
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
#ifndef OOX_PIVOTCACHERECORDS_FILE_INCLUDE_H_
|
||||
#define OOX_PIVOTCACHERECORDS_FILE_INCLUDE_H_
|
||||
|
||||
#include "../CommonInclude.h"
|
||||
|
||||
|
||||
namespace OOX
|
||||
{
|
||||
namespace Spreadsheet
|
||||
{
|
||||
class CPivotCacheRecords : public OOX::File, public OOX::IFileContainer
|
||||
{
|
||||
public:
|
||||
CPivotCacheRecords()
|
||||
{
|
||||
m_bSpreadsheets = true;
|
||||
m_pData = NULL;
|
||||
m_nDataLength = 0;
|
||||
}
|
||||
CPivotCacheRecords(const CPath& oRootPath, const CPath& oPath)
|
||||
{
|
||||
m_bSpreadsheets = true;
|
||||
m_pData = NULL;
|
||||
m_nDataLength = 0;
|
||||
read( oRootPath, oPath );
|
||||
}
|
||||
virtual ~CPivotCacheRecords()
|
||||
{
|
||||
ClearItems();
|
||||
}
|
||||
public:
|
||||
|
||||
virtual void read(const CPath& oPath)
|
||||
{
|
||||
}
|
||||
virtual void read(const CPath& oRootPath, const CPath& oPath)
|
||||
{
|
||||
}
|
||||
virtual void write(const CPath& oPath, const CPath& oDirectory, CContentTypes& oContent) const
|
||||
{
|
||||
if(m_nDataLength > 0)
|
||||
{
|
||||
NSFile::CFileBinary oFile;
|
||||
oFile.CreateFileW(oPath.GetPath());
|
||||
oFile.WriteFile(m_pData, m_nDataLength);
|
||||
oFile.CloseFile();
|
||||
|
||||
oContent.Registration(type().OverrideType(), oDirectory, oPath.GetFilename());
|
||||
|
||||
oContent.Registration( type().OverrideType(), oDirectory, oPath.GetFilename() );
|
||||
IFileContainer::Write( oPath, oDirectory, oContent );
|
||||
}
|
||||
}
|
||||
virtual const OOX::FileType type() const
|
||||
{
|
||||
return OOX::Spreadsheet::FileTypes::PivotCacheRecords;
|
||||
}
|
||||
virtual const CPath DefaultDirectory() const
|
||||
{
|
||||
return type().DefaultDirectory();
|
||||
}
|
||||
virtual const CPath DefaultFileName() const
|
||||
{
|
||||
return type().DefaultFileName();
|
||||
}
|
||||
const CPath& GetReadPath()
|
||||
{
|
||||
return m_oReadPath;
|
||||
}
|
||||
void setData(BYTE* pData, long length)
|
||||
{
|
||||
m_nDataLength = length;
|
||||
m_pData = new BYTE[length];
|
||||
memcpy(m_pData, pData, length);
|
||||
}
|
||||
private:
|
||||
CPath m_oReadPath;
|
||||
|
||||
void ClearItems()
|
||||
{
|
||||
m_nDataLength = 0;
|
||||
RELEASEARRAYOBJECTS(m_pData)
|
||||
}
|
||||
|
||||
public:
|
||||
BYTE* m_pData;
|
||||
long m_nDataLength;
|
||||
};
|
||||
} //Spreadsheet
|
||||
} // namespace OOX
|
||||
|
||||
#endif // OOX_PIVOTCACHERECORDS_FILE_INCLUDE_H_
|
||||
122
Common/DocxFormat/Source/XlsxFormat/Pivot/PivotTable.h
Normal file
122
Common/DocxFormat/Source/XlsxFormat/Pivot/PivotTable.h
Normal file
@ -0,0 +1,122 @@
|
||||
/*
|
||||
* (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
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
#ifndef OOX_PIVOTTABLE_FILE_INCLUDE_H_
|
||||
#define OOX_PIVOTTABLE_FILE_INCLUDE_H_
|
||||
|
||||
#include "../CommonInclude.h"
|
||||
|
||||
|
||||
namespace OOX
|
||||
{
|
||||
namespace Spreadsheet
|
||||
{
|
||||
class CPivotTable : public OOX::File, public OOX::IFileContainer
|
||||
{
|
||||
public:
|
||||
CPivotTable()
|
||||
{
|
||||
m_bSpreadsheets = true;
|
||||
m_pData = NULL;
|
||||
m_nDataLength = 0;
|
||||
}
|
||||
CPivotTable(const CPath& oRootPath, const CPath& oPath)
|
||||
{
|
||||
m_bSpreadsheets = true;
|
||||
m_pData = NULL;
|
||||
m_nDataLength = 0;
|
||||
read( oRootPath, oPath );
|
||||
}
|
||||
virtual ~CPivotTable()
|
||||
{
|
||||
ClearItems();
|
||||
}
|
||||
public:
|
||||
|
||||
virtual void read(const CPath& oPath)
|
||||
{
|
||||
}
|
||||
virtual void read(const CPath& oRootPath, const CPath& oPath)
|
||||
{
|
||||
}
|
||||
virtual void write(const CPath& oPath, const CPath& oDirectory, CContentTypes& oContent) const
|
||||
{
|
||||
if(m_nDataLength > 0)
|
||||
{
|
||||
NSFile::CFileBinary oFile;
|
||||
oFile.CreateFileW(oPath.GetPath());
|
||||
oFile.WriteFile(m_pData, m_nDataLength);
|
||||
oFile.CloseFile();
|
||||
|
||||
oContent.Registration( type().OverrideType(), oDirectory, oPath.GetFilename() );
|
||||
IFileContainer::Write( oPath, oDirectory, oContent );
|
||||
}
|
||||
}
|
||||
virtual const OOX::FileType type() const
|
||||
{
|
||||
return OOX::Spreadsheet::FileTypes::PivotTable;
|
||||
}
|
||||
virtual const CPath DefaultDirectory() const
|
||||
{
|
||||
return type().DefaultDirectory();
|
||||
}
|
||||
virtual const CPath DefaultFileName() const
|
||||
{
|
||||
return type().DefaultFileName();
|
||||
}
|
||||
const CPath& GetReadPath()
|
||||
{
|
||||
return m_oReadPath;
|
||||
}
|
||||
void setData(BYTE* pData, long length)
|
||||
{
|
||||
m_nDataLength = length;
|
||||
m_pData = new BYTE[length];
|
||||
memcpy(m_pData, pData, length);
|
||||
}
|
||||
private:
|
||||
CPath m_oReadPath;
|
||||
|
||||
void ClearItems()
|
||||
{
|
||||
m_nDataLength = 0;
|
||||
RELEASEARRAYOBJECTS(m_pData)
|
||||
}
|
||||
|
||||
public:
|
||||
BYTE* m_pData;
|
||||
long m_nDataLength;
|
||||
};
|
||||
} //Spreadsheet
|
||||
} // namespace OOX
|
||||
|
||||
#endif // OOX_PIVOTTABLE_FILE_INCLUDE_H_
|
||||
@ -198,6 +198,7 @@ namespace OOX
|
||||
WritingStringNullableAttrBool(L"applyBorder", m_oApplyBorder);
|
||||
WritingStringNullableAttrBool(L"applyAlignment", m_oApplyAlignment);
|
||||
WritingStringNullableAttrBool(L"quotePrefix", m_oQuotePrefix);
|
||||
WritingStringNullableAttrBool(L"pivotButton", m_oPivotButton);
|
||||
if(m_oAligment.IsInit())
|
||||
{
|
||||
writer.WriteString(_T(">"));
|
||||
|
||||
@ -137,6 +137,8 @@ namespace OOX
|
||||
m_oDefinedNames->toXML(sXml);
|
||||
|
||||
sXml.WriteString(_T("<calcPr calcId=\"145621\"/>"));
|
||||
if(m_oPivotCachesXml.IsInit())
|
||||
sXml.WriteString(m_oPivotCachesXml.get());
|
||||
sXml.WriteString(_T("</workbook>"));
|
||||
|
||||
std::wstring sPath = oPath.GetPath();
|
||||
@ -208,7 +210,7 @@ namespace OOX
|
||||
nullable<OOX::Spreadsheet::CSheets> m_oSheets;
|
||||
nullable<OOX::Spreadsheet::CWorkbookPr> m_oWorkbookPr;
|
||||
nullable<OOX::Spreadsheet::CExternalReferences> m_oExternalReferences;
|
||||
|
||||
nullable<std::wstring> m_oPivotCachesXml;
|
||||
};
|
||||
} //Spreadsheet
|
||||
} // namespace OOX
|
||||
|
||||
@ -47,6 +47,9 @@
|
||||
#include "CalcChain/CalcChain.h"
|
||||
#include "ExternalLinks/ExternalLinks.h"
|
||||
#include "ExternalLinks/ExternalLinkPath.h"
|
||||
#include "Pivot/PivotTable.h"
|
||||
#include "Pivot/PivotCacheDefinition.h"
|
||||
#include "Pivot/PivotCacheRecords.h"
|
||||
|
||||
#include "../../../DesktopEditor/common/Directory.h"
|
||||
|
||||
|
||||
@ -45,7 +45,8 @@
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#define U_TO_UTF8(val) NSFile::CUtf8Converter::GetUtf8StringFromUnicode2(val.c_str(), val.length())
|
||||
#define U_TO_UTF8(val) NSFile::CUtf8Converter::GetUtf8StringFromUnicode2(val.c_str(), (LONG)val.length())
|
||||
#define UTF8_TO_U(val) NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)val.c_str(), (LONG)val.length())
|
||||
|
||||
#if defined(__linux__) || defined(_MAC) && !defined(_IOS)
|
||||
#include <unistd.h>
|
||||
|
||||
@ -7,71 +7,336 @@
|
||||
#include <string>
|
||||
|
||||
#include "../../../common/File.h"
|
||||
#include "../../../common/Directory.h"
|
||||
#include "../../../common/BigInteger.h"
|
||||
|
||||
#include "../../../xml/include/xmlutils.h"
|
||||
#include "../../../xml/libxml2/include/libxml/c14n.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
#pragma comment (lib, "crypt32.lib")
|
||||
#pragma comment (lib, "cryptui.lib")
|
||||
#pragma comment (lib, "Advapi32.lib")
|
||||
|
||||
//#define ENUMS_CERTS
|
||||
|
||||
//////////////////////
|
||||
class CXmlBuffer
|
||||
class CXmlCanonicalizator
|
||||
{
|
||||
public:
|
||||
NSStringUtils::CStringBuilderA builder;
|
||||
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:
|
||||
CXmlBuffer()
|
||||
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();
|
||||
}
|
||||
~CXmlBuffer()
|
||||
|
||||
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);
|
||||
}
|
||||
};
|
||||
|
||||
static int xmlBufferIOWrite(CXmlBuffer* buf, const char* buffer, int len)
|
||||
class CXmlSigner
|
||||
{
|
||||
buf->builder.WriteString(buffer, (size_t)len);
|
||||
return len;
|
||||
}
|
||||
private:
|
||||
PCCERT_CONTEXT m_context;
|
||||
|
||||
static int xmlBufferIOClose(CXmlBuffer* buf)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int xmlC14NIsVisibleCallbackMy(void * user_data, xmlNodePtr node, xmlNodePtr parent)
|
||||
{
|
||||
if (node->type == XML_TEXT_NODE)
|
||||
public:
|
||||
CXmlSigner(PCCERT_CONTEXT pCertContext)
|
||||
{
|
||||
std::string sTmp((char*)node->content);
|
||||
if (std::string::npos != sTmp.find('\n') ||
|
||||
std::string::npos != sTmp.find('\r') ||
|
||||
std::string::npos != sTmp.find('\t'))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
m_context = pCertContext;
|
||||
}
|
||||
~CXmlSigner()
|
||||
{
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
//////////////////////
|
||||
public:
|
||||
|
||||
std::string Sign(std::string sXml)
|
||||
{
|
||||
BOOL bResult = TRUE;
|
||||
DWORD dwKeySpec = 0;
|
||||
HCRYPTHASH hHash = NULL;
|
||||
|
||||
HCRYPTPROV hCryptProv = NULL;
|
||||
bResult = CryptAcquireCertificatePrivateKey(m_context, 0, NULL, &hCryptProv, &dwKeySpec, NULL);
|
||||
|
||||
if (!bResult)
|
||||
return "";
|
||||
|
||||
bResult = CryptCreateHash(hCryptProv, CALG_SHA1, 0, 0, &hHash);
|
||||
if (!bResult)
|
||||
{
|
||||
CryptReleaseContext(hCryptProv, 0);
|
||||
return "";
|
||||
}
|
||||
|
||||
bResult = CryptHashData(hHash, (BYTE*)sXml.c_str(), (DWORD)sXml.length(), 0);
|
||||
if (!bResult)
|
||||
{
|
||||
CryptDestroyHash(hHash);
|
||||
CryptReleaseContext(hCryptProv, 0);
|
||||
return "";
|
||||
}
|
||||
|
||||
DWORD dwSigLen = 0;
|
||||
BYTE* pbSignature = NULL;
|
||||
bResult = CryptSignHash(hHash, dwKeySpec, NULL, 0, NULL, &dwSigLen);
|
||||
|
||||
if (!bResult)
|
||||
{
|
||||
CryptDestroyHash(hHash);
|
||||
CryptReleaseContext(hCryptProv, 0);
|
||||
return "";
|
||||
}
|
||||
|
||||
pbSignature = new BYTE[dwSigLen];
|
||||
bResult = CryptSignHash(hHash, dwKeySpec, NULL, 0, pbSignature, &dwSigLen);
|
||||
|
||||
if (!bResult)
|
||||
{
|
||||
CryptDestroyHash(hHash);
|
||||
CryptReleaseContext(hCryptProv, 0);
|
||||
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;
|
||||
|
||||
CryptReleaseContext(hCryptProv, 0);
|
||||
|
||||
return sReturn;
|
||||
}
|
||||
|
||||
std::string GetHash(BYTE* pData, DWORD dwSize)
|
||||
{
|
||||
BOOL bResult = TRUE;
|
||||
DWORD dwKeySpec = 0;
|
||||
HCRYPTHASH hHash = NULL;
|
||||
|
||||
HCRYPTPROV hCryptProv = NULL;
|
||||
|
||||
bResult = CryptAcquireCertificatePrivateKey(m_context, 0, NULL, &hCryptProv, &dwKeySpec, NULL);
|
||||
|
||||
if (!bResult)
|
||||
return "";
|
||||
|
||||
bResult = CryptCreateHash(hCryptProv, CALG_SHA1, 0, 0, &hHash);
|
||||
if (!bResult)
|
||||
{
|
||||
CryptReleaseContext(hCryptProv, 0);
|
||||
return "";
|
||||
}
|
||||
|
||||
bResult = CryptHashData(hHash, pData, dwSize, 0);
|
||||
if (!bResult)
|
||||
{
|
||||
CryptDestroyHash(hHash);
|
||||
CryptReleaseContext(hCryptProv, 0);
|
||||
return "";
|
||||
}
|
||||
|
||||
DWORD cbHashSize = 0, dwCount = sizeof(DWORD);
|
||||
bResult = CryptGetHashParam(hHash, HP_HASHSIZE, (BYTE*)&cbHashSize, &dwCount, 0);
|
||||
|
||||
if (!bResult)
|
||||
{
|
||||
CryptDestroyHash(hHash);
|
||||
CryptReleaseContext(hCryptProv, 0);
|
||||
return "";
|
||||
}
|
||||
|
||||
BYTE* pDataHashRaw = new BYTE[dwCount];
|
||||
|
||||
bResult = CryptGetHashParam(hHash, HP_HASHVAL, pDataHashRaw, &cbHashSize, 0);
|
||||
|
||||
if (!bResult)
|
||||
{
|
||||
CryptDestroyHash(hHash);
|
||||
CryptReleaseContext(hCryptProv, 0);
|
||||
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;
|
||||
|
||||
//delete [] pDataHashRaw;
|
||||
CryptDestroyHash(hHash);
|
||||
CryptReleaseContext(hCryptProv, 0);
|
||||
|
||||
return sReturn;
|
||||
}
|
||||
|
||||
std::string GetHash(std::string& sXml)
|
||||
{
|
||||
return GetHash((BYTE*)sXml.c_str(), (DWORD)sXml.length());
|
||||
}
|
||||
|
||||
std::string GetHash(std::wstring& sXmlFile)
|
||||
{
|
||||
BYTE* pFileData = NULL;
|
||||
DWORD dwFileDataLen = 0;
|
||||
NSFile::CFileBinary::ReadAllBytes(sXmlFile, &pFileData, dwFileDataLen);
|
||||
|
||||
if (0 == dwFileDataLen)
|
||||
return "";
|
||||
|
||||
std::string sReturn = GetHash(pFileData, dwFileDataLen);
|
||||
|
||||
RELEASEARRAYOBJECTS(pFileData);
|
||||
return sReturn;
|
||||
}
|
||||
|
||||
BOOL Verify(std::string& sXml, std::string& sXmlSignature)
|
||||
{
|
||||
DWORD dwKeySpec = 0;
|
||||
HCRYPTHASH hHash = NULL;
|
||||
HCRYPTKEY hPubKey = NULL;
|
||||
|
||||
HCRYPTPROV hCryptProv = NULL;
|
||||
BOOL bResult = CryptAcquireCertificatePrivateKey(m_context, 0, NULL, &hCryptProv, &dwKeySpec, NULL);
|
||||
|
||||
if (!bResult)
|
||||
return FALSE;
|
||||
|
||||
bResult = CryptCreateHash(hCryptProv, CALG_SHA1, 0, 0, &hHash);
|
||||
|
||||
if (!bResult)
|
||||
{
|
||||
CryptReleaseContext(hCryptProv, 0);
|
||||
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(hCryptProv, m_context->dwCertEncodingType, &m_context->pCertInfo->SubjectPublicKeyInfo, &hPubKey);
|
||||
|
||||
BOOL bResultRet = CryptVerifySignature(hHash, pDataHashMem, dwHashLen, hPubKey, NULL, 0);
|
||||
|
||||
delete[] pDataHashMem;
|
||||
|
||||
bResult = CryptDestroyHash(hHash);
|
||||
|
||||
CryptDestroyKey(hPubKey);
|
||||
CryptReleaseContext(hCryptProv, 0);
|
||||
|
||||
return bResultRet && bResult;
|
||||
}
|
||||
|
||||
std::string GetCertificateBase64()
|
||||
{
|
||||
char* pData = NULL;
|
||||
int nDataLen = 0;
|
||||
NSFile::CBase64Converter::Encode(m_context->pbCertEncoded, (int)m_context->cbCertEncoded, pData, nDataLen, NSBase64::B64_BASE64_FLAG_NOCRLF);
|
||||
std::string sReturn(pData, nDataLen);
|
||||
RELEASEARRAYOBJECTS(pData);
|
||||
return sReturn;
|
||||
}
|
||||
|
||||
std::string GetCertificateHash()
|
||||
{
|
||||
return GetHash(m_context->pbCertEncoded, (int)m_context->cbCertEncoded);
|
||||
}
|
||||
|
||||
public:
|
||||
static 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(PCCERT_CONTEXT pCertContext, std::wstring sFileXml, std::wstring sSignatureFile);
|
||||
bool Verify(PCCERT_CONTEXT pCertContext, std::wstring sFileXml, std::wstring sSignatureFile);
|
||||
|
||||
void ConvertEndian(const BYTE* src, BYTE* dst, DWORD size)
|
||||
{
|
||||
for(BYTE* p = dst + size - 1; p >= dst; ++src, --p)
|
||||
(*p) = (*src);
|
||||
}
|
||||
bool SignDocument(std::wstring sFolderOOXML, PCCERT_CONTEXT pCertContext);
|
||||
|
||||
void main(void)
|
||||
{
|
||||
@ -379,10 +644,19 @@ void main(void)
|
||||
MyHandleError("Select UI failed." );
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
bool bRes = true;
|
||||
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");
|
||||
if (false)
|
||||
{
|
||||
bool bRes = true;
|
||||
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");
|
||||
|
||||
CXmlSigner oSigner(pCertContext);
|
||||
std::string sCertBase64 = oSigner.GetCertificateBase64();
|
||||
std::string sCertHash = oSigner.GetCertificateHash();
|
||||
}
|
||||
|
||||
SignDocument(NSFile::GetProcessDirectory() + L"/ImageStamp", pCertContext);
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CertFreeCertificateContext(pCertContext);
|
||||
@ -401,141 +675,323 @@ void MyHandleError(LPTSTR psz)
|
||||
|
||||
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);
|
||||
|
||||
xmlDocPtr xmlDoc = xmlParseMemory((char*)pDataSrc, (int)dwFileSrcLen);
|
||||
|
||||
CXmlBuffer _bufferC14N;
|
||||
xmlOutputBufferPtr _buffer = xmlOutputBufferCreateIO((xmlOutputWriteCallback)xmlBufferIOWrite,
|
||||
(xmlOutputCloseCallback)xmlBufferIOClose,
|
||||
&_bufferC14N,
|
||||
NULL);
|
||||
|
||||
xmlC14NExecute(xmlDoc, xmlC14NIsVisibleCallbackMy, NULL, XML_C14N_1_0, NULL, 0, _buffer);
|
||||
|
||||
xmlOutputBufferClose(_buffer);
|
||||
|
||||
NSFile::CFileBinary oFileDump;
|
||||
oFileDump.CreateFileW(NSFile::GetProcessDirectory() + L"/123.txt");
|
||||
oFileDump.WriteFile((BYTE*)_bufferC14N.builder.GetBuffer(), (DWORD)_bufferC14N.builder.GetCurSize());
|
||||
oFileDump.CloseFile();
|
||||
|
||||
//bResult = CryptHashData(hHash, pDataSrc, dwFileSrcLen, 0);
|
||||
bResult = CryptHashData(hHash, (BYTE*)_bufferC14N.builder.GetBuffer(), (DWORD)_bufferC14N.builder.GetCurSize(), 0);
|
||||
|
||||
if (true)
|
||||
{
|
||||
DWORD cbHashSize = 0, dwCount = sizeof(DWORD);
|
||||
|
||||
BOOL b1 = CryptGetHashParam(hHash, HP_HASHSIZE, (BYTE*)&cbHashSize, &dwCount, 0);
|
||||
|
||||
BYTE* pDataHashRaw = new BYTE[dwCount];
|
||||
|
||||
BOOL b2 = CryptGetHashParam(hHash, HP_HASHVAL, pDataHashRaw, &cbHashSize, 0);
|
||||
|
||||
char* pBase64_hash = NULL;
|
||||
int nBase64Len_hash = 0;
|
||||
NSFile::CBase64Converter::Encode(pDataHashRaw, (int)cbHashSize, pBase64_hash, nBase64Len_hash, NSBase64::B64_BASE64_FLAG_NONE);
|
||||
|
||||
delete [] pBase64_hash;
|
||||
}
|
||||
|
||||
// Sign the hash object
|
||||
dwSigLen = 0;
|
||||
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(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));
|
||||
}
|
||||
|
||||
class COOXMLSigner
|
||||
{
|
||||
public:
|
||||
PCCERT_CONTEXT m_context;
|
||||
std::wstring m_sFolder;
|
||||
|
||||
CXmlSigner* m_signer;
|
||||
|
||||
public:
|
||||
COOXMLSigner(const std::wstring& sFolder, PCCERT_CONTEXT pContext)
|
||||
{
|
||||
m_sFolder = sFolder;
|
||||
m_context = pContext;
|
||||
m_signer = new CXmlSigner(pContext);
|
||||
}
|
||||
~COOXMLSigner()
|
||||
{
|
||||
RELEASEOBJECT(m_signer);
|
||||
}
|
||||
|
||||
std::wstring GetReference(const std::wstring& file, const std::wstring& content_type)
|
||||
{
|
||||
std::wstring sXml = L"<Reference URI=\"" + file + L"?ContentType=" + content_type + L"\">";
|
||||
sXml += L"<DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\"/>";
|
||||
sXml += L"<DigestValue>";
|
||||
sXml += UTF8_TO_U(m_signer->GetHash(m_sFolder + file));
|
||||
sXml += L"</DigestValue>";
|
||||
sXml += L"</Reference>";
|
||||
return sXml;
|
||||
}
|
||||
|
||||
std::string GetHashXml(const std::wstring& xml)
|
||||
{
|
||||
std::string sXmlSigned = U_TO_UTF8(xml);
|
||||
sXmlSigned = CXmlCanonicalizator::Execute(sXmlSigned, XML_C14N_1_0);
|
||||
return m_signer->GetHash(sXmlSigned);
|
||||
}
|
||||
|
||||
std::string GetReferenceMain(const std::wstring& xml, const std::wstring& id, const bool& isCannon = true)
|
||||
{
|
||||
std::wstring sXml1 = L"<Object xmlns=\"http://www.w3.org/2000/09/xmldsig#\"";
|
||||
if (id.empty())
|
||||
sXml1 += L">";
|
||||
else
|
||||
sXml1 += (L" Id=\"" + id + L"\">");
|
||||
sXml1 += xml;
|
||||
sXml1 += L"</Object>";
|
||||
|
||||
std::string sHash = GetHashXml(sXml1);
|
||||
|
||||
std::string sRet;
|
||||
if (isCannon)
|
||||
sRet = "<Transforms><Transform Algorithm=\"http://www.w3.org/TR/2001/REC-xml-c14n-20010315\"/></Transforms>";
|
||||
|
||||
sRet += ("<DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\"/><DigestValue>" + sHash + "</DigestValue>");
|
||||
|
||||
return sRet;
|
||||
}
|
||||
|
||||
std::wstring GetImageBase64(const std::wstring& file)
|
||||
{
|
||||
BYTE* pData = NULL;
|
||||
DWORD dwLen = 0;
|
||||
if (!NSFile::CFileBinary::ReadAllBytes(file, &pData, dwLen))
|
||||
return L"";
|
||||
|
||||
char* pDataC = NULL;
|
||||
int nLen = 0;
|
||||
NSFile::CBase64Converter::Encode(pData, (int)dwLen, pDataC, nLen, NSBase64::B64_BASE64_FLAG_NOCRLF);
|
||||
|
||||
std::wstring sReturn = NSFile::CUtf8Converter::GetUnicodeFromCharPtr(pDataC, (LONG)nLen, FALSE);
|
||||
|
||||
RELEASEARRAYOBJECTS(pData);
|
||||
RELEASEARRAYOBJECTS(pDataC);
|
||||
|
||||
return sReturn;
|
||||
}
|
||||
};
|
||||
|
||||
bool SignDocument(std::wstring sFolderOOXML, PCCERT_CONTEXT pCertContext)
|
||||
{
|
||||
std::wstring sFolder = NSFile::GetProcessDirectory();
|
||||
|
||||
COOXMLSigner oOOXMLSigner(sFolderOOXML, pCertContext);
|
||||
|
||||
std::string sSignedData;
|
||||
std::wstring sXmlData;
|
||||
|
||||
std::wstring sDataSign = L"2017-04-21T08:30:21Z";
|
||||
|
||||
sSignedData += "<CanonicalizationMethod Algorithm=\"http://www.w3.org/TR/2001/REC-xml-c14n-20010315\"/>\
|
||||
<SignatureMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#rsa-sha1\"/>";
|
||||
|
||||
if (true)
|
||||
{
|
||||
// idPackageObject
|
||||
std::wstring sXml = L"<Manifest>";
|
||||
|
||||
// TODO: rels
|
||||
if (true)
|
||||
{
|
||||
sXml += L"<Reference URI=\"/_rels/.rels?ContentType=application/vnd.openxmlformats-package.relationships+xml\">\
|
||||
<Transforms><Transform Algorithm=\"http://schemas.openxmlformats.org/package/2006/RelationshipTransform\">\
|
||||
<mdssi:RelationshipReference xmlns:mdssi=\"http://schemas.openxmlformats.org/package/2006/digital-signature\" SourceId=\"rId1\"/>\
|
||||
</Transform><Transform Algorithm=\"http://www.w3.org/TR/2001/REC-xml-c14n-20010315\"/></Transforms>\
|
||||
<DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\"/>\
|
||||
<DigestValue>1vWU/YTF/7t6ZjnE44gAFTbZvvA=</DigestValue>\
|
||||
</Reference>";
|
||||
|
||||
sXml += L"<Reference URI=\"/word/_rels/document.xml.rels?ContentType=application/vnd.openxmlformats-package.relationships+xml\">\
|
||||
<Transforms><Transform Algorithm=\"http://schemas.openxmlformats.org/package/2006/RelationshipTransform\">\
|
||||
<mdssi:RelationshipReference xmlns:mdssi=\"http://schemas.openxmlformats.org/package/2006/digital-signature\" SourceId=\"rId3\"/>\
|
||||
<mdssi:RelationshipReference xmlns:mdssi=\"http://schemas.openxmlformats.org/package/2006/digital-signature\" SourceId=\"rId2\"/>\
|
||||
<mdssi:RelationshipReference xmlns:mdssi=\"http://schemas.openxmlformats.org/package/2006/digital-signature\" SourceId=\"rId1\"/>\
|
||||
<mdssi:RelationshipReference xmlns:mdssi=\"http://schemas.openxmlformats.org/package/2006/digital-signature\" SourceId=\"rId6\"/>\
|
||||
<mdssi:RelationshipReference xmlns:mdssi=\"http://schemas.openxmlformats.org/package/2006/digital-signature\" SourceId=\"rId5\"/>\
|
||||
<mdssi:RelationshipReference xmlns:mdssi=\"http://schemas.openxmlformats.org/package/2006/digital-signature\" SourceId=\"rId4\"/>\
|
||||
</Transform><Transform Algorithm=\"http://www.w3.org/TR/2001/REC-xml-c14n-20010315\"/></Transforms>\
|
||||
<DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\"/>\
|
||||
<DigestValue>kVYCpjZZG3SU5+sOsB1PRnQSCzk=</DigestValue>\
|
||||
</Reference>";
|
||||
}
|
||||
|
||||
|
||||
sXml += oOOXMLSigner.GetReference(L"/word/document.xml", L"application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml");
|
||||
sXml += oOOXMLSigner.GetReference(L"/word/fontTable.xml", L"application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml");
|
||||
sXml += oOOXMLSigner.GetReference(L"/word/media/image1.emf", L"image/x-emf");
|
||||
sXml += oOOXMLSigner.GetReference(L"/word/settings.xml", L"application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml");
|
||||
sXml += oOOXMLSigner.GetReference(L"/word/styles.xml", L"application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml");
|
||||
sXml += oOOXMLSigner.GetReference(L"/word/theme/theme1.xml", L"application/vnd.openxmlformats-officedocument.theme+xml");
|
||||
sXml += oOOXMLSigner.GetReference(L"/word/webSettings.xml", L"application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml");
|
||||
|
||||
sXml += L"</Manifest>";
|
||||
|
||||
sXml += L"<SignatureProperties><SignatureProperty Id=\"idSignatureTime\" Target=\"#idPackageSignature\">";
|
||||
sXml += (L"<mdssi:SignatureTime xmlns:mdssi=\"http://schemas.openxmlformats.org/package/2006/digital-signature\">\
|
||||
<mdssi:Format>YYYY-MM-DDThh:mm:ssTZD</mdssi:Format>\
|
||||
<mdssi:Value>" + sDataSign + L"</mdssi:Value>\
|
||||
</mdssi:SignatureTime></SignatureProperty></SignatureProperties>");
|
||||
|
||||
sXmlData += (L"<Object Id=\"idPackageObject\">" + sXml + L"</Object>");
|
||||
|
||||
sSignedData += ("<Reference Type=\"http://www.w3.org/2000/09/xmldsig#Object\" URI=\"#idPackageObject\">" +
|
||||
oOOXMLSigner.GetReferenceMain(sXml, L"idPackageObject", false) + "</Reference>");
|
||||
}
|
||||
|
||||
|
||||
std::wstring sImageValid = oOOXMLSigner.GetImageBase64(sFolder + L"/../../../resources/valid.png");
|
||||
std::wstring sImageInValid = oOOXMLSigner.GetImageBase64(sFolder + L"/../../../resources/invalid.png");
|
||||
|
||||
if (true)
|
||||
{
|
||||
// idOfficeObject
|
||||
std::wstring sXml = L"<SignatureProperties>\
|
||||
<SignatureProperty Id=\"idOfficeV1Details\" Target=\"#idPackageSignature\">\
|
||||
<SignatureInfoV1 xmlns=\"http://schemas.microsoft.com/office/2006/digsig\">\
|
||||
<SetupID>{39B6B9C7-60AD-45A2-9F61-40C74A24042E}</SetupID>\
|
||||
<SignatureText></SignatureText>\
|
||||
<SignatureImage>" + sImageValid + L"</SignatureImage>\
|
||||
<SignatureComments/>\
|
||||
<WindowsVersion>10.0</WindowsVersion>\
|
||||
<OfficeVersion>16.0</OfficeVersion>\
|
||||
<ApplicationVersion>16.0</ApplicationVersion>\
|
||||
<Monitors>2</Monitors>\
|
||||
<HorizontalResolution>1680</HorizontalResolution>\
|
||||
<VerticalResolution>1050</VerticalResolution>\
|
||||
<ColorDepth>32</ColorDepth>\
|
||||
<SignatureProviderId>{00000000-0000-0000-0000-000000000000}</SignatureProviderId>\
|
||||
<SignatureProviderUrl/>\
|
||||
<SignatureProviderDetails>9</SignatureProviderDetails>\
|
||||
<SignatureType>2</SignatureType>\
|
||||
</SignatureInfoV1>\
|
||||
</SignatureProperty>\
|
||||
</SignatureProperties>";
|
||||
|
||||
sXmlData += (L"<Object Id=\"idOfficeObject\">" + sXml + L"</Object>");
|
||||
|
||||
sSignedData += ("<Reference Type=\"http://www.w3.org/2000/09/xmldsig#Object\" URI=\"#idOfficeObject\">" +
|
||||
oOOXMLSigner.GetReferenceMain(sXml, L"idOfficeObject", false) + "</Reference>");
|
||||
}
|
||||
|
||||
if (true)
|
||||
{
|
||||
DWORD dwNameLen = CertGetNameStringW(pCertContext, CERT_NAME_SIMPLE_DISPLAY_TYPE, CERT_NAME_ISSUER_FLAG, NULL, NULL, 0);
|
||||
wchar_t* pNameData = new wchar_t[dwNameLen];
|
||||
CertGetNameStringW(pCertContext, CERT_NAME_SIMPLE_DISPLAY_TYPE, CERT_NAME_ISSUER_FLAG, NULL, pNameData, dwNameLen);
|
||||
std::wstring sName(pNameData);
|
||||
RELEASEARRAYOBJECTS(pNameData);
|
||||
|
||||
int nNumberLen = (int)pCertContext->pCertInfo->SerialNumber.cbData;
|
||||
BYTE* pNumberData = new BYTE[nNumberLen];
|
||||
CXmlSigner::ConvertEndian(pCertContext->pCertInfo->SerialNumber.pbData, pNumberData, (DWORD)nNumberLen);
|
||||
CBigInteger oInteger(pNumberData, nNumberLen);
|
||||
delete[] pNumberData;
|
||||
|
||||
std::string sKeyA = oInteger.ToString();
|
||||
std::wstring sKey = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)sKeyA.c_str(), (LONG)sKeyA.length());
|
||||
|
||||
std::wstring sXml = (L"<xd:SignedSignatureProperties>\
|
||||
<xd:SigningTime>" + sDataSign + L"</xd:SigningTime>\
|
||||
<xd:SigningCertificate>\
|
||||
<xd:Cert>\
|
||||
<xd:CertDigest>\
|
||||
<DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\"/>\
|
||||
<DigestValue>MJJT2Y0iMxaPGVXBmOLb9bY60pA=</DigestValue>\
|
||||
</xd:CertDigest>\
|
||||
<xd:IssuerSerial>\
|
||||
<X509IssuerName>CN=" + sName + L"</X509IssuerName>\
|
||||
<X509SerialNumber>" + sKey + L"</X509SerialNumber>\
|
||||
</xd:IssuerSerial>\
|
||||
</xd:Cert>\
|
||||
</xd:SigningCertificate>\
|
||||
<xd:SignaturePolicyIdentifier>\
|
||||
<xd:SignaturePolicyImplied/>\
|
||||
</xd:SignaturePolicyIdentifier>\
|
||||
</xd:SignedSignatureProperties>");
|
||||
|
||||
std::wstring sSignedXml = L"<xd:SignedProperties xmlns=\"http://www.w3.org/2000/09/xmldsig#\" xmlns:xd=\"http://uri.etsi.org/01903/v1.3.2#\" Id=\"idSignedProperties\">";
|
||||
sSignedXml += sXml;
|
||||
sSignedXml += L"</xd:SignedProperties>";
|
||||
|
||||
sXmlData += L"<Object><xd:QualifyingProperties xmlns:xd=\"http://uri.etsi.org/01903/v1.3.2#\" Target=\"#idPackageSignature\">\
|
||||
<xd:SignedProperties Id=\"idSignedProperties\">";
|
||||
sXmlData += sXml;
|
||||
sXmlData += L"</xd:SignedProperties></xd:QualifyingProperties></Object>";
|
||||
|
||||
sSignedData += "<Reference Type=\"http://uri.etsi.org/01903#SignedProperties\" URI=\"#idSignedProperties\">\
|
||||
<Transforms><Transform Algorithm=\"http://www.w3.org/TR/2001/REC-xml-c14n-20010315\"/></Transforms>\
|
||||
<DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\"/><DigestValue>";
|
||||
|
||||
std::string sXmlTmp = CXmlCanonicalizator::Execute(U_TO_UTF8(sSignedXml), XML_C14N_1_0);
|
||||
sSignedData += oOOXMLSigner.m_signer->GetHash(sXmlTmp);
|
||||
|
||||
sSignedData += "</DigestValue></Reference>";
|
||||
}
|
||||
|
||||
if (true)
|
||||
{
|
||||
std::wstring sXml = sImageValid;
|
||||
|
||||
sXmlData += (L"<Object Id=\"idValidSigLnImg\">" + sXml + L"</Object>");
|
||||
|
||||
sSignedData += ("<Reference Type=\"http://www.w3.org/2000/09/xmldsig#Object\" URI=\"#idValidSigLnImg\">" +
|
||||
oOOXMLSigner.GetReferenceMain(sXml, L"idValidSigLnImg", false) + "</Reference>");
|
||||
}
|
||||
|
||||
if (true)
|
||||
{
|
||||
std::wstring sXml = sImageInValid;
|
||||
|
||||
sXmlData += (L"<Object Id=\"idInvalidSigLnImg\">" + sXml + L"</Object>");
|
||||
|
||||
sSignedData += ("<Reference Type=\"http://www.w3.org/2000/09/xmldsig#Object\" URI=\"#idInvalidSigLnImg\">" +
|
||||
oOOXMLSigner.GetReferenceMain(sXml, L"idInvalidSigLnImg", false) + "</Reference>");
|
||||
}
|
||||
|
||||
std::string sXmlPrepend = ("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Signature xmlns=\"http://www.w3.org/2000/09/xmldsig#\" Id=\"idPackageSignature\"><SignedInfo>");
|
||||
sXmlPrepend += sSignedData;
|
||||
sXmlPrepend += "</SignedInfo>";
|
||||
|
||||
sXmlPrepend += "<SignatureValue>";
|
||||
std::string sSignedInfo = "<SignedInfo xmlns=\"http://www.w3.org/2000/09/xmldsig#\">" + sSignedData + "</SignedInfo>";
|
||||
sSignedInfo = CXmlCanonicalizator::Execute(sSignedInfo, XML_C14N_1_0);
|
||||
sXmlPrepend += oOOXMLSigner.m_signer->Sign(sSignedInfo);
|
||||
sXmlPrepend += "</SignatureValue>";
|
||||
sXmlPrepend += ("<KeyInfo><X509Data><X509Certificate>" + oOOXMLSigner.m_signer->GetCertificateBase64() + "</X509Certificate></X509Data></KeyInfo>");
|
||||
|
||||
sXmlData = (UTF8_TO_U(sXmlPrepend) + sXmlData);
|
||||
sXmlData += L"</Signature>";
|
||||
|
||||
std::wstring sDirectory = sFolderOOXML + L"/_xmlsignatures";
|
||||
NSDirectory::CreateDirectory(sDirectory);
|
||||
|
||||
NSFile::CFileBinary oFile;
|
||||
oFile.CreateFileW(sDirectory + L"/origin.sigs");
|
||||
oFile.CloseFile();
|
||||
|
||||
NSFile::CFileBinary::SaveToFile(sDirectory + L"/sig1.xml", sXmlData, false);
|
||||
|
||||
NSDirectory::CreateDirectory(sDirectory + L"/_rels");
|
||||
|
||||
std::wstring sRels = L"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\
|
||||
<Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\">\
|
||||
<Relationship Id=\"rId1\" Type=\"http://schemas.openxmlformats.org/package/2006/relationships/digital-signature/signature\" Target=\"sig1.xml\"/>\
|
||||
</Relationships>";
|
||||
|
||||
NSFile::CFileBinary::SaveToFile(sDirectory + L"/_rels/origin.sigs.rels", sRels, false);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -75,23 +75,23 @@ namespace codegen
|
||||
}
|
||||
public void merge(GenMemberPivot val)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(val.sName))
|
||||
if (string.IsNullOrEmpty(this.sName))
|
||||
sName = val.sName;
|
||||
if (!string.IsNullOrEmpty(val.sNamespace))
|
||||
if (string.IsNullOrEmpty(this.sNamespace))
|
||||
sNamespace = val.sNamespace;
|
||||
if (!string.IsNullOrEmpty(val.sType))
|
||||
if (string.IsNullOrEmpty(this.sType))
|
||||
sType = val.sType;
|
||||
if (null != val.oSystemType)
|
||||
if (null == this.oSystemType)
|
||||
oSystemType = val.oSystemType;
|
||||
if (val.bIsAttribute.HasValue)
|
||||
if (!this.bIsAttribute.HasValue)
|
||||
bIsAttribute = val.bIsAttribute;
|
||||
if (!string.IsNullOrEmpty(val.sDefAttribute))
|
||||
if (string.IsNullOrEmpty(this.sDefAttribute))
|
||||
sDefAttribute = val.sDefAttribute;
|
||||
if (val.bQualified.HasValue)
|
||||
if (!this.bQualified.HasValue)
|
||||
bQualified = val.bQualified;
|
||||
if (val.nArrayRank.HasValue)
|
||||
if (!this.nArrayRank.HasValue)
|
||||
nArrayRank = val.nArrayRank;
|
||||
if (val.bIsArrayTypesHidden.HasValue)
|
||||
if (!this.bIsArrayTypesHidden.HasValue)
|
||||
bIsArrayTypesHidden = val.bIsArrayTypesHidden;
|
||||
}
|
||||
public void completeDefaults()
|
||||
@ -105,7 +105,7 @@ namespace codegen
|
||||
|
||||
//[System.Xml.Serialization.XmlElementAttribute("c")]
|
||||
//public CT_CalcCell[] c {
|
||||
//bIsArray=true;aArrayTypes=[CT_CalcCell]
|
||||
//nArrayRank=0;aArrayTypes=[CT_CalcCell];bIsArrayTypesHidden=true
|
||||
|
||||
//[System.Xml.Serialization.XmlElementAttribute("b", typeof(CT_Boolean))]
|
||||
//[System.Xml.Serialization.XmlElementAttribute("d", typeof(CT_DateTime))]
|
||||
@ -114,9 +114,18 @@ namespace codegen
|
||||
//[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)]
|
||||
@ -126,12 +135,7 @@ namespace codegen
|
||||
//[System.Xml.Serialization.XmlArrayItemAttribute("s", typeof(CT_String), IsNullable=false)]
|
||||
//[System.Xml.Serialization.XmlArrayItemAttribute("x", typeof(CT_Index), IsNullable=false)]
|
||||
//public object[][] r {
|
||||
|
||||
//[System.Xml.Serialization.XmlElementAttribute("consolidation", typeof(CT_Consolidation))]
|
||||
//[System.Xml.Serialization.XmlElementAttribute("extLst", typeof(CT_ExtensionList))]
|
||||
//[System.Xml.Serialization.XmlElementAttribute("worksheetSource", typeof(CT_WorksheetSource))]
|
||||
//public object Item
|
||||
//{
|
||||
//nArrayRank=1;aArrayTypes=[CT_Boolean, CT_DateTime, CT_Error, CT_Missing, CT_Number, CT_String, CT_Index];bIsArrayTypesHidden=false
|
||||
|
||||
public class GenClassPivot
|
||||
{
|
||||
@ -222,6 +226,9 @@ namespace codegen
|
||||
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>();
|
||||
|
||||
@ -419,16 +426,19 @@ namespace codegen
|
||||
{
|
||||
if (1 == aTempMemebers.Count)
|
||||
{
|
||||
oGenMember.merge(aTempMemebers[0]);
|
||||
GenMemberPivot TempMember = aTempMemebers[0];
|
||||
TempMember.merge(oGenMember);
|
||||
TempMember.nArrayRank = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
oGenMember.aArrayTypes = aTempMemebers;
|
||||
if (bXmlElementAttribute)
|
||||
oGenMember.bIsArrayTypesHidden = true;
|
||||
else
|
||||
oGenMember.bIsArrayTypesHidden = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
oGenMember.nArrayRank = null;
|
||||
}
|
||||
oGenMember.completeDefaults();
|
||||
return oGenMember;
|
||||
|
||||
@ -59,10 +59,10 @@ namespace codegen
|
||||
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");
|
||||
oJsSer.AppendFormat("function getXmlFromBool(val){{return val ? \"1\" : \"0\";}}\r\n");
|
||||
|
||||
//enums
|
||||
ProcessEnums(oJsSer, aEnums);
|
||||
@ -122,13 +122,13 @@ namespace codegen
|
||||
|
||||
sb.AppendFormat("function {0}(){{\r\n", oGenClass.sName);
|
||||
ProcessProperty(sb, aAttributes, aMembers, bNeedTextNode, bNeedDoubleArray);
|
||||
sb.AppendFormat("}}\r\n", oGenClass.sName);
|
||||
sb.AppendFormat("}}\r\n");
|
||||
|
||||
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);
|
||||
sb.AppendFormat("}};\r\n");
|
||||
}
|
||||
if (aMembers.Count > 0)
|
||||
{
|
||||
@ -144,30 +144,30 @@ namespace codegen
|
||||
sb.AppendFormat("newContext = null;\r\n");
|
||||
sb.AppendFormat("}}\r\n");
|
||||
sb.AppendFormat("return newContext;\r\n");
|
||||
sb.AppendFormat("}};\r\n", oGenClass.sName);
|
||||
sb.AppendFormat("}};\r\n");
|
||||
|
||||
if (bNeedTextNode)
|
||||
{
|
||||
sb.AppendFormat("{0}.prototype.onTextNode = function(text, uq) {{\r\n", oGenClass.sName);
|
||||
ProcessOnTextNodeFromXml(sb, oGenClass, aMembers);
|
||||
sb.AppendFormat("}};\r\n", oGenClass.sName);
|
||||
sb.AppendFormat("}};\r\n");
|
||||
}
|
||||
if (bNeedDoubleArray)
|
||||
{
|
||||
sb.AppendFormat("{0}.prototype.onEndNode = function(prevContext, elem) {{\r\n", oGenClass.sName);
|
||||
ProcessOnEndNodeFromXml(sb, oGenClass, aMembers);
|
||||
sb.AppendFormat("}};\r\n", oGenClass.sName);
|
||||
sb.AppendFormat("}};\r\n");
|
||||
}
|
||||
}
|
||||
if (aAttributes.Count > 0 || aMembers.Count > 0)
|
||||
{
|
||||
if (oGenClass.isRoot())
|
||||
{
|
||||
sb.AppendFormat("{0}.prototype.toXml = function() {{\r\n", oGenClass.sName);
|
||||
sb.AppendFormat("{0}.prototype.toXml = function(writer) {{\r\n", oGenClass.sName);
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.AppendFormat("{0}.prototype.toXml = function(name) {{\r\n", oGenClass.sName);
|
||||
sb.AppendFormat("{0}.prototype.toXml = function(writer, name) {{\r\n", oGenClass.sName);
|
||||
}
|
||||
sb.AppendFormat("var res = \"\";\r\n");
|
||||
ProcessToXml(sb, oGenClass);
|
||||
@ -190,28 +190,40 @@ namespace codegen
|
||||
{
|
||||
bNeedDoubleArray = true;
|
||||
}
|
||||
if (null == oGenMember.aArrayTypes)
|
||||
|
||||
if (null != oGenMember.aArrayTypes)
|
||||
{
|
||||
if (null != oGenMember.oSystemType)
|
||||
for (int j = 0; j < oGenMember.aArrayTypes.Count; ++j)
|
||||
{
|
||||
bNeedTextNode = true;
|
||||
}
|
||||
else if (null != oGenMember.sType)
|
||||
{
|
||||
GenClassPivot oTemp;
|
||||
if (m_mapProcessedClasses.TryGetValue(oGenMember.sType, out oTemp))
|
||||
{
|
||||
if (oTemp.bIsEnum)
|
||||
{
|
||||
bNeedTextNode = true;
|
||||
}
|
||||
}
|
||||
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)
|
||||
@ -237,7 +249,12 @@ namespace codegen
|
||||
{
|
||||
GenMemberPivot oGenMember = aMembers[i];
|
||||
if (oGenMember.nArrayRank.HasValue)
|
||||
sb.AppendFormat("this.{0} = [];\r\n", oGenMember.sName);
|
||||
{
|
||||
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)
|
||||
@ -285,7 +302,9 @@ namespace codegen
|
||||
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("if(newContext.readAttributes){{\r\n");
|
||||
sb.AppendFormat("newContext.readAttributes(attr, uq);\r\n");
|
||||
sb.AppendFormat("}}\r\n");
|
||||
sb.AppendFormat("}}\r\n", sName, sCodeName);
|
||||
return true;
|
||||
}
|
||||
@ -310,7 +329,8 @@ namespace codegen
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.AppendFormat("//todo check\r\n", getNameWithPrefix(oGenClass, oGenMember), sCodeName);
|
||||
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++;
|
||||
@ -383,30 +403,26 @@ namespace codegen
|
||||
for (int i = 0; i < aMembers.Count; ++i)
|
||||
{
|
||||
GenMemberPivot oGenMember = aMembers[i];
|
||||
nCounter = ProcessOnTextNodeFromXmlMember(sb, oGenClass, oGenMember, null, nCounter);
|
||||
}
|
||||
}
|
||||
int ProcessOnTextNodeFromXmlMember(StringBuilder sb, GenClassPivot oGenClass, GenMemberPivot oGenMember, GenMemberPivot oGenMemberContainer, int nCounter)
|
||||
{
|
||||
if (0 != nCounter)
|
||||
sb.AppendFormat("else ");
|
||||
sb.AppendFormat("if(\"{0}\" === this._curElem){{\r\n", getNameWithPrefix(oGenClass, oGenMember));
|
||||
|
||||
if (null != oGenMember.oSystemType)
|
||||
{
|
||||
if (oGenMember.nArrayRank.HasValue)
|
||||
if (null != oGenMember.aArrayTypes)
|
||||
{
|
||||
if (oGenMember.nArrayRank > 0)
|
||||
for (int j = 0; j < oGenMember.aArrayTypes.Count; ++j)
|
||||
{
|
||||
sb.AppendFormat("this._curArray.push({0});\r\n", ProcessJsTypeFromXml(oGenMember.oSystemType, "text"));
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.AppendFormat("this.{0}.push({1});\r\n", oGenMember.sName, ProcessJsTypeFromXml(oGenMember.oSystemType, "text"));
|
||||
nCounter = ProcessOnTextNodeFromXmlMember(sb, oGenClass, oGenMember.aArrayTypes[j], nCounter);
|
||||
}
|
||||
}
|
||||
else
|
||||
sb.AppendFormat("this.{0} = {1};\r\n", oGenMember.sName, ProcessJsTypeFromXml(oGenMember.oSystemType, "text"));
|
||||
{
|
||||
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)
|
||||
{
|
||||
@ -415,29 +431,46 @@ namespace codegen
|
||||
{
|
||||
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");
|
||||
if (oGenMember.nArrayRank.HasValue)
|
||||
{
|
||||
if (oGenMember.nArrayRank > 0)
|
||||
{
|
||||
sb.AppendFormat("this._curArray.push(val);\r\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.AppendFormat("this.{0}.push(val);\r\n", oGenMember.sName);
|
||||
}
|
||||
}
|
||||
else
|
||||
sb.AppendFormat("this.{0} = val;\r\n", oGenMember.sName);
|
||||
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;
|
||||
@ -450,6 +483,9 @@ namespace codegen
|
||||
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("if(!this.{0}){{\r\n", oGenMember.sName);
|
||||
sb.AppendFormat("this.{0} = [];\r\n", oGenMember.sName);
|
||||
sb.AppendFormat("}}\r\n");
|
||||
sb.AppendFormat("this.{0}.push(this._curArray);\r\n", oGenMember.sName);
|
||||
sb.AppendFormat("this._curArray = null;\r\n");
|
||||
sb.AppendFormat("}}\r\n");
|
||||
@ -527,15 +563,19 @@ namespace codegen
|
||||
bool bNeedDoubleArray = false;
|
||||
InfoFromMember(oGenClass, ref aAttributes, ref aMembers, ref bNeedTextNode, ref bNeedDoubleArray);
|
||||
|
||||
string sCodeName;
|
||||
if (oGenClass.isRoot())
|
||||
{
|
||||
sb.AppendFormat("res += \"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"yes\\\"?>\";\r\n");
|
||||
sb.AppendFormat("res += \"<{0}{1}\";\r\n", oGenClass.sRootName, gc_sNamespaceToXml);
|
||||
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
|
||||
{
|
||||
sb.AppendFormat("res += \"<\";\r\n");
|
||||
sb.AppendFormat("res += name;\r\n");
|
||||
sCodeName = "name";
|
||||
sb.AppendFormat("writer.WriteXmlNodeStart({0});\r\n", sCodeName);
|
||||
}
|
||||
|
||||
for (int i = 0; i < aAttributes.Count; ++i)
|
||||
@ -546,39 +586,62 @@ namespace codegen
|
||||
|
||||
if (aMembers.Count > 0)
|
||||
{
|
||||
sb.AppendFormat("res += \">\";\r\n");
|
||||
sb.AppendFormat("writer.WriteXmlNodeEnd({0}, true);\r\n", sCodeName);
|
||||
for (int i = 0; i < aMembers.Count; ++i)
|
||||
{
|
||||
GenMemberPivot oGenMember = aMembers[i];
|
||||
string sCodeElem;
|
||||
bool bNullCheck = true;
|
||||
string sCodeElem = "this." + oGenMember.sName;
|
||||
if (oGenMember.nArrayRank > 0)
|
||||
{
|
||||
sb.AppendFormat("for(var i = 0; i < this.{0}.length; ++i){{\r\n", oGenMember.sName);
|
||||
sb.AppendFormat("var elem = this.{0}[i];\r\n", oGenMember.sName);
|
||||
if (false == oGenMember.bIsArrayTypesHidden)
|
||||
{
|
||||
sb.AppendFormat("if(null !== {0}){{\r\n", sCodeElem);
|
||||
}
|
||||
sb.AppendFormat("for(var i = 0; i < {0}.length; ++i){{\r\n", sCodeElem);
|
||||
sb.AppendFormat("var elem = {0}[i];\r\n", sCodeElem);
|
||||
sCodeElem = "elem";
|
||||
}
|
||||
else
|
||||
{
|
||||
sCodeElem = "this." + oGenMember.sName;
|
||||
bNullCheck = false;
|
||||
}
|
||||
if (null != oGenMember.aArrayTypes)
|
||||
{
|
||||
if (false == oGenMember.bIsArrayTypesHidden)
|
||||
{
|
||||
sb.AppendFormat("res += \"<{0}>\";\r\n", getNameWithPrefix(oGenClass, oGenMember));
|
||||
if (bNullCheck)
|
||||
sb.AppendFormat("if(null !== {0}){{\r\n", sCodeElem);
|
||||
sb.AppendFormat("writer.WriteXmlNodeStart(\"{0}\", true);\r\n", getNameWithPrefix(oGenClass, oGenMember));
|
||||
}
|
||||
if (oGenMember.nArrayRank.HasValue)
|
||||
{
|
||||
sb.AppendFormat("for(var j = 0; j < {0}.length; ++j){{\r\n", sCodeElem);
|
||||
sb.AppendFormat("var subelem = {0}[j];\r\n", sCodeElem);
|
||||
for (int j = 0; j < oGenMember.aArrayTypes.Count; ++j)
|
||||
string sCodeSubElem;
|
||||
if (oGenMember.nArrayRank > 0)
|
||||
{
|
||||
GenMemberPivot oTempMember = oGenMember.aArrayTypes[j];
|
||||
if (0 != j)
|
||||
sb.AppendFormat("else ");
|
||||
sb.AppendFormat("if(subelem instanceof {0}){{\r\n", oTempMember.sType);
|
||||
sb.AppendFormat("res += subelem.toXml(\"{0}\");\r\n", getNameWithPrefix(oGenClass, oTempMember));
|
||||
sb.AppendFormat("}}\r\n");
|
||||
sb.AppendFormat("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");
|
||||
}
|
||||
@ -593,42 +656,29 @@ namespace codegen
|
||||
}
|
||||
if (false == oGenMember.bIsArrayTypesHidden)
|
||||
{
|
||||
sb.AppendFormat("res += \"</{0}>\";\r\n", getNameWithPrefix(oGenClass, oGenMember));
|
||||
sb.AppendFormat("writer.WriteXmlNodeEnd(\"{0}\");\r\n", getNameWithPrefix(oGenClass, oGenMember));
|
||||
if (bNullCheck)
|
||||
sb.AppendFormat("}}\r\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (oGenMember.nArrayRank.HasValue)
|
||||
{
|
||||
sb.AppendFormat("for(var i = 0; i < {0}.length; ++i){{\r\n", sCodeElem);
|
||||
sb.AppendFormat("var elem = {0}[i];\r\n", sCodeElem);
|
||||
ProcessMemberToXml(sb, oGenClass, oGenMember, "elem", false);
|
||||
sb.AppendFormat("}}\r\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
ProcessMemberToXml(sb, oGenClass, oGenMember, sCodeElem, true);
|
||||
}
|
||||
ProcessMemberToXml(sb, oGenClass, oGenMember, sCodeElem, true);
|
||||
}
|
||||
if (oGenMember.nArrayRank > 0)
|
||||
{
|
||||
sb.AppendFormat("}}\r\n");
|
||||
if (false == oGenMember.bIsArrayTypesHidden)
|
||||
{
|
||||
sb.AppendFormat("}}\r\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (oGenClass.isRoot())
|
||||
{
|
||||
sb.AppendFormat("res += \"</{0}>\";\r\n", oGenClass.sRootName);
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.AppendFormat("res += \"</\";\r\n");
|
||||
sb.AppendFormat("res += name;\r\n");
|
||||
sb.AppendFormat("res += \">\";\r\n");
|
||||
}
|
||||
sb.AppendFormat("writer.WriteXmlNodeEnd({0});\r\n", sCodeName);
|
||||
}
|
||||
else
|
||||
sb.AppendFormat("res += \"/>\";\r\n");
|
||||
sb.AppendFormat("writer.WriteXmlNodeEnd({0}, true, true);\r\n", sCodeName);
|
||||
}
|
||||
void ProcessMemberToXml(StringBuilder sb, GenClassPivot oGenClass, GenMemberPivot oGenMember, string sElemName, bool checkNull)
|
||||
{
|
||||
@ -642,15 +692,7 @@ namespace codegen
|
||||
|
||||
if (null != oGenMember.oSystemType)
|
||||
{
|
||||
if (bIsAttribute)
|
||||
sb.AppendFormat("res += \" {0}=\\\"\";\r\n", sElemXmlName);
|
||||
else
|
||||
sb.AppendFormat("res += \"<{0}>\";\r\n", sElemXmlName);
|
||||
sb.AppendFormat("res += {0};\r\n", ProcessJsTypeToXml(oGenMember.oSystemType, sElemName));
|
||||
if (bIsAttribute)
|
||||
sb.AppendFormat("res += \"\\\"\";\r\n");
|
||||
else
|
||||
sb.AppendFormat("res += \"</{0}>\";\r\n", sElemXmlName);
|
||||
ProcessJsTypeToXml(sb, sElemXmlName, oGenMember.oSystemType, sElemName, bIsAttribute);
|
||||
}
|
||||
else if (null != oGenMember.sType)
|
||||
{
|
||||
@ -660,20 +702,13 @@ namespace codegen
|
||||
{
|
||||
if (oGenClassMember.bIsEnum)
|
||||
{
|
||||
if (bIsAttribute)
|
||||
sb.AppendFormat("res += \" {0}=\\\"\";\r\n", sElemXmlName);
|
||||
else
|
||||
sb.AppendFormat("res += \"<{0}>\";\r\n", sElemXmlName);
|
||||
sb.AppendFormat("res += {0}{1}({2});\r\n", gc_sEnumToXmlPrefix, oGenClassMember.sName, sElemName);
|
||||
if (bIsAttribute)
|
||||
sb.AppendFormat("res += \"\\\"\";\r\n");
|
||||
else
|
||||
sb.AppendFormat("res += \"</{0}>\";\r\n", sElemXmlName);
|
||||
string sElemNameEnum = gc_sEnumToXmlPrefix + oGenClassMember.sName + "("+ sElemName + ")";
|
||||
ProcessJsTypeToXml(sb, sElemXmlName, oGenMember.oSystemType, sElemNameEnum, bIsAttribute);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!bIsAttribute)
|
||||
sb.AppendFormat("res += {0}.toXml(\"{1}\");\r\n", sElemName, sElemXmlName);
|
||||
sb.AppendFormat("res += {0}.toXml(writer, \"{1}\");\r\n", sElemName, sElemXmlName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -682,13 +717,21 @@ namespace codegen
|
||||
sb.AppendFormat("}}\r\n");
|
||||
}
|
||||
}
|
||||
string ProcessJsTypeToXml(Type oType, string sVal)
|
||||
void ProcessJsTypeToXml(StringBuilder sb, string sName, Type oType, string sVal, bool bAttribute)
|
||||
{
|
||||
string sRes;
|
||||
switch (Type.GetTypeCode(oType))
|
||||
{
|
||||
case TypeCode.Boolean:
|
||||
sRes = "getXmlFromBool(" + sVal + ")";
|
||||
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:
|
||||
@ -700,11 +743,30 @@ namespace codegen
|
||||
case TypeCode.UInt64:
|
||||
case TypeCode.Single:
|
||||
case TypeCode.Double:
|
||||
sRes = sVal + ".toString()";
|
||||
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.WriteXmlAttributeStringEncode(\"{0}\", {1});\r\n", sName, sVal);
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.AppendFormat("writer.WriteXmlNodeStart(\"{0}\", true);\r\n", sName);
|
||||
sb.AppendFormat("writer.WriteXmlStringEncode({0});\r\n", sVal);
|
||||
sb.AppendFormat("writer.WriteXmlNodeEnd(\"{0}\");\r\n", sName);
|
||||
}
|
||||
break;
|
||||
default: sRes = sVal; break;
|
||||
}
|
||||
return sRes;
|
||||
}
|
||||
|
||||
string getNameWithPrefix(GenClassPivot oGenClass, GenMemberPivot oGenMember)
|
||||
|
||||
@ -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"/>
|
||||
|
||||
@ -45,10 +45,35 @@ namespace TestDocsWithChart
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
getFilesAlternateContent();
|
||||
getFilesPivot();
|
||||
//getFilesAlternateContent();
|
||||
//getFiles();
|
||||
//convertFiles();
|
||||
}
|
||||
static void getFilesPivot()
|
||||
{
|
||||
string sDirInput = @"\\192.168.3.208\allusers\Files\XLSX";
|
||||
string sDirOutput = @"D:\Files\Pivot";
|
||||
String[] allfiles = System.IO.Directory.GetFiles(sDirInput, "*.*", System.IO.SearchOption.AllDirectories);
|
||||
for (var i = 0; i < allfiles.Length; ++i)
|
||||
{
|
||||
string file = allfiles[i];
|
||||
try
|
||||
{
|
||||
ZipArchive zip = ZipFile.OpenRead(file);
|
||||
foreach (ZipArchiveEntry entry in zip.Entries)
|
||||
{
|
||||
if (-1 != entry.FullName.IndexOf("pivotTable", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
System.IO.File.Copy(file, Path.Combine(sDirOutput, Path.GetFileName(file)), true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
|
||||
}
|
||||
}
|
||||
static void getFilesAlternateContent()
|
||||
{
|
||||
string sAlternateContent = ":Choice ";
|
||||
|
||||
@ -7,11 +7,10 @@
|
||||
QT -= core
|
||||
QT -= gui
|
||||
|
||||
VERSION = 2.4.448.000
|
||||
VERSION = 2.4.451.0
|
||||
DEFINES += INTVER=$$VERSION
|
||||
|
||||
TARGET = x2t
|
||||
|
||||
CORE_ROOT_DIR = $$PWD/../../..
|
||||
PWD_ROOT_DIR = $$PWD
|
||||
|
||||
|
||||
@ -185,8 +185,9 @@ namespace BinXlsxRW
|
||||
DefinedNames = 3,
|
||||
DefinedName = 4,
|
||||
ExternalReferences = 5,
|
||||
ExternalReference = 6
|
||||
|
||||
ExternalReference = 6,
|
||||
PivotCaches = 7,
|
||||
PivotCache = 8
|
||||
};}
|
||||
namespace c_oSerWorkbookPrTypes{enum c_oSerWorkbookPrTypes
|
||||
{
|
||||
@ -232,7 +233,8 @@ namespace BinXlsxRW
|
||||
SheetViews = 22,
|
||||
SheetView = 23,
|
||||
SheetPr = 24,
|
||||
SparklineGroups = 25
|
||||
SparklineGroups = 25,
|
||||
PivotTable = 26
|
||||
};}
|
||||
namespace c_oSerWorksheetPropTypes{enum c_oSerWorksheetPropTypes
|
||||
{
|
||||
@ -809,6 +811,14 @@ namespace BinXlsxRW
|
||||
AltText = 0,
|
||||
AltTextSummary = 1
|
||||
};}
|
||||
namespace c_oSer_PivotTypes{enum c_oSerPivotTypes
|
||||
{
|
||||
id = 0,
|
||||
cache = 1,
|
||||
record = 2,
|
||||
cacheId = 3,
|
||||
table = 4
|
||||
};}
|
||||
}
|
||||
|
||||
#endif //
|
||||
|
||||
@ -863,6 +863,13 @@ namespace BinXlsxRW
|
||||
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Byte);
|
||||
m_oBcw.m_oStream.WriteBOOL(xfs.m_oQuotePrefix->ToBool());
|
||||
}
|
||||
//PivotButton
|
||||
if(false != xfs.m_oPivotButton.IsInit())
|
||||
{
|
||||
m_oBcw.m_oStream.WriteBYTE(c_oSerXfsTypes::PivotButton);
|
||||
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Byte);
|
||||
m_oBcw.m_oStream.WriteBOOL(xfs.m_oPivotButton->ToBool());
|
||||
}
|
||||
//XfId
|
||||
if (false != xfs.m_oXfId.IsInit())
|
||||
{
|
||||
|
||||
@ -64,6 +64,27 @@ namespace BinXlsxRW {
|
||||
nIndex = _nIndex;
|
||||
}
|
||||
};
|
||||
class PivotCachesTemp
|
||||
{
|
||||
public:
|
||||
long nId;
|
||||
BYTE* pDefinitionData;
|
||||
long nDefinitionLength;
|
||||
OOX::Spreadsheet::CPivotCacheRecords* pRecords;
|
||||
long nCacheId;
|
||||
OOX::Spreadsheet::CPivotTable* pTable;
|
||||
public:
|
||||
PivotCachesTemp()
|
||||
{
|
||||
nId = -1;
|
||||
pDefinitionData = NULL;
|
||||
nDefinitionLength = 0;
|
||||
pRecords = NULL;
|
||||
nCacheId = -1;
|
||||
pTable = NULL;
|
||||
}
|
||||
};
|
||||
|
||||
class Binary_CommonReader2
|
||||
{
|
||||
protected:
|
||||
@ -1212,6 +1233,11 @@ namespace BinXlsxRW {
|
||||
pXfs->m_oQuotePrefix.Init();
|
||||
pXfs->m_oQuotePrefix->SetValue(false != m_oBufferedStream.GetBool() ? SimpleTypes::onoffTrue : SimpleTypes::onoffFalse);
|
||||
}
|
||||
else if(c_oSerXfsTypes::PivotButton == type)
|
||||
{
|
||||
pXfs->m_oPivotButton.Init();
|
||||
pXfs->m_oPivotButton->SetValue(false != m_oBufferedStream.GetBool() ? SimpleTypes::onoffTrue : SimpleTypes::onoffFalse);
|
||||
}
|
||||
else if(c_oSerXfsTypes::Aligment == type)
|
||||
{
|
||||
pXfs->m_oAligment.Init();
|
||||
@ -1477,8 +1503,9 @@ namespace BinXlsxRW {
|
||||
class BinaryWorkbookTableReader : public Binary_CommonReader<BinaryWorkbookTableReader>
|
||||
{
|
||||
OOX::Spreadsheet::CWorkbook& m_oWorkbook;
|
||||
std::map<long, NSCommon::smart_ptr<OOX::File>>& m_mapPivotCacheDefinitions;
|
||||
public:
|
||||
BinaryWorkbookTableReader(NSBinPptxRW::CBinaryFileReader& oBufferedStream, OOX::Spreadsheet::CWorkbook& oWorkbook):Binary_CommonReader(oBufferedStream), m_oWorkbook(oWorkbook)
|
||||
BinaryWorkbookTableReader(NSBinPptxRW::CBinaryFileReader& oBufferedStream, OOX::Spreadsheet::CWorkbook& oWorkbook, std::map<long, NSCommon::smart_ptr<OOX::File>>& mapPivotCacheDefinitions):Binary_CommonReader(oBufferedStream), m_oWorkbook(oWorkbook), m_mapPivotCacheDefinitions(mapPivotCacheDefinitions)
|
||||
{
|
||||
}
|
||||
int Read()
|
||||
@ -1508,6 +1535,13 @@ namespace BinXlsxRW {
|
||||
m_oWorkbook.m_oExternalReferences.Init();
|
||||
res = Read1(length, &BinaryWorkbookTableReader::ReadExternalReferences, this, poResult);
|
||||
}
|
||||
else if(c_oSerWorkbookTypes::PivotCaches == type)
|
||||
{
|
||||
m_oWorkbook.m_oPivotCachesXml.Init();
|
||||
m_oWorkbook.m_oPivotCachesXml->append(L"<pivotCaches>");
|
||||
res = Read1(length, &BinaryWorkbookTableReader::ReadPivotCaches, this, poResult);
|
||||
m_oWorkbook.m_oPivotCachesXml->append(L"</pivotCaches>");
|
||||
}
|
||||
else
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
return res;
|
||||
@ -1633,7 +1667,67 @@ namespace BinXlsxRW {
|
||||
{
|
||||
pDefinedName->m_oComment.Init();
|
||||
pDefinedName->m_oComment->append(m_oBufferedStream.GetString4(length));
|
||||
}
|
||||
}
|
||||
else
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
return res;
|
||||
};
|
||||
int ReadPivotCaches(BYTE type, long length, void* poResult)
|
||||
{
|
||||
int res = c_oSerConstants::ReadOk;
|
||||
if(c_oSerWorkbookTypes::PivotCache == type)
|
||||
{
|
||||
PivotCachesTemp oPivotCachesTemp;
|
||||
res = Read1(length, &BinaryWorkbookTableReader::ReadPivotCache, this, &oPivotCachesTemp);
|
||||
if(-1 != oPivotCachesTemp.nId && NULL != oPivotCachesTemp.pDefinitionData)
|
||||
{
|
||||
OOX::Spreadsheet::CPivotCacheDefinition* pDefinition = new OOX::Spreadsheet::CPivotCacheDefinition();
|
||||
std::wstring srIdRecords;
|
||||
if(NULL != oPivotCachesTemp.pRecords)
|
||||
{
|
||||
NSCommon::smart_ptr<OOX::File> pFileRecords(oPivotCachesTemp.pRecords);
|
||||
srIdRecords = pDefinition->Add(pFileRecords).ToString();
|
||||
}
|
||||
pDefinition->setData(oPivotCachesTemp.pDefinitionData, oPivotCachesTemp.nDefinitionLength, srIdRecords);
|
||||
NSCommon::smart_ptr<OOX::File> pFileDefinition(pDefinition);
|
||||
OOX::RId rIdDefinition = m_oWorkbook.Add(pFileDefinition);
|
||||
m_oWorkbook.m_oPivotCachesXml->append(L"<pivotCache cacheId=\"");
|
||||
m_oWorkbook.m_oPivotCachesXml->append(std::to_wstring(oPivotCachesTemp.nId));
|
||||
m_oWorkbook.m_oPivotCachesXml->append(L"\" r:id=\"");
|
||||
m_oWorkbook.m_oPivotCachesXml->append(rIdDefinition.ToString());
|
||||
m_oWorkbook.m_oPivotCachesXml->append(L"\"/>");
|
||||
|
||||
m_mapPivotCacheDefinitions[oPivotCachesTemp.nId] = pFileDefinition;
|
||||
}
|
||||
else
|
||||
{
|
||||
RELEASEOBJECT(oPivotCachesTemp.pRecords);
|
||||
}
|
||||
}
|
||||
else
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
return res;
|
||||
};
|
||||
int ReadPivotCache(BYTE type, long length, void* poResult)
|
||||
{
|
||||
PivotCachesTemp* pPivotCachesTemp = static_cast<PivotCachesTemp*>(poResult);
|
||||
int res = c_oSerConstants::ReadOk;
|
||||
if(c_oSer_PivotTypes::id == type)
|
||||
{
|
||||
pPivotCachesTemp->nId = m_oBufferedStream.GetLong();
|
||||
}
|
||||
else if(c_oSer_PivotTypes::cache == type)
|
||||
{
|
||||
pPivotCachesTemp->pDefinitionData = m_oBufferedStream.GetPointer(length);
|
||||
pPivotCachesTemp->nDefinitionLength = length;
|
||||
}
|
||||
else if(c_oSer_PivotTypes::record == type)
|
||||
{
|
||||
pPivotCachesTemp->pRecords = new OOX::Spreadsheet::CPivotCacheRecords();
|
||||
pPivotCachesTemp->pRecords->setData(m_oBufferedStream.GetPointer(length), length);
|
||||
}
|
||||
else
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
return res;
|
||||
};
|
||||
};
|
||||
@ -1876,14 +1970,15 @@ namespace BinXlsxRW {
|
||||
NSBinPptxRW::CDrawingConverter* m_pOfficeDrawingConverter;
|
||||
|
||||
std::map<std::wstring, OOX::Spreadsheet::CWorksheet*>& m_mapWorksheets;
|
||||
std::map<long, NSCommon::smart_ptr<OOX::File>>& m_mapPivotCacheDefinitions;
|
||||
|
||||
public:
|
||||
BinaryWorksheetsTableReader(NSBinPptxRW::CBinaryFileReader& oBufferedStream, OOX::Spreadsheet::CWorkbook& oWorkbook,
|
||||
OOX::Spreadsheet::CSharedStrings* pSharedStrings, std::map<std::wstring, OOX::Spreadsheet::CWorksheet*>& mapWorksheets,
|
||||
std::map<long, ImageObject*>& mapMedia, const std::wstring& sDestinationDir, const std::wstring& sMediaDir, SaveParams& oSaveParams,
|
||||
NSBinPptxRW::CDrawingConverter* pOfficeDrawingConverter)
|
||||
NSBinPptxRW::CDrawingConverter* pOfficeDrawingConverter, std::map<long, NSCommon::smart_ptr<OOX::File>>& mapPivotCacheDefinitions)
|
||||
: Binary_CommonReader(oBufferedStream), m_oWorkbook(oWorkbook), m_oBcr2(oBufferedStream), m_sMediaDir(sMediaDir), m_oSaveParams(oSaveParams),
|
||||
m_mapMedia(mapMedia), m_sDestinationDir(sDestinationDir), m_mapWorksheets(mapWorksheets), m_pSharedStrings(pSharedStrings)
|
||||
m_mapMedia(mapMedia), m_sDestinationDir(sDestinationDir), m_mapWorksheets(mapWorksheets), m_pSharedStrings(pSharedStrings),m_mapPivotCacheDefinitions(mapPivotCacheDefinitions)
|
||||
{
|
||||
m_pCurSheet = NULL;
|
||||
m_pCurWorksheet = NULL;
|
||||
@ -2110,10 +2205,45 @@ namespace BinXlsxRW {
|
||||
m_pCurWorksheet->m_oExtLst.Init();
|
||||
m_pCurWorksheet->m_oExtLst->m_arrExt.push_back(pOfficeArtExtension);
|
||||
}
|
||||
else if(c_oSerWorksheetsTypes::PivotTable == type)
|
||||
{
|
||||
PivotCachesTemp oPivotCachesTemp;
|
||||
res = Read1(length, &BinaryWorksheetsTableReader::ReadPivotTable, this, &oPivotCachesTemp);
|
||||
std::map<long, NSCommon::smart_ptr<OOX::File>>::const_iterator pair = m_mapPivotCacheDefinitions.find(oPivotCachesTemp.nCacheId);
|
||||
if(m_mapPivotCacheDefinitions.end() != pair && NULL != oPivotCachesTemp.pTable)
|
||||
{
|
||||
NSCommon::smart_ptr<OOX::File> pFileTable(oPivotCachesTemp.pTable);
|
||||
oPivotCachesTemp.pTable->AddNoWrite(pair->second, L"../pivotCache");
|
||||
m_pCurWorksheet->Add(pFileTable);
|
||||
}
|
||||
else
|
||||
{
|
||||
RELEASEOBJECT(oPivotCachesTemp.pTable);
|
||||
}
|
||||
}
|
||||
else
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
return res;
|
||||
}
|
||||
int ReadPivotTable(BYTE type, long length, void* poResult)
|
||||
{
|
||||
PivotCachesTemp* pPivotCachesTemp = static_cast<PivotCachesTemp*>(poResult);
|
||||
int res = c_oSerConstants::ReadOk;
|
||||
if(c_oSer_PivotTypes::cacheId == type)
|
||||
{
|
||||
pPivotCachesTemp->nCacheId =m_oBufferedStream.GetLong();
|
||||
}
|
||||
else if(c_oSer_PivotTypes::table == type)
|
||||
{
|
||||
OOX::Spreadsheet::CPivotTable* pPivotTable = new OOX::Spreadsheet::CPivotTable();
|
||||
pPivotTable->setData(m_oBufferedStream.GetPointer(length), length);
|
||||
pPivotCachesTemp->pTable = pPivotTable;
|
||||
}
|
||||
else
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
return res;
|
||||
}
|
||||
|
||||
int ReadWorksheetProp(BYTE type, long length, void* poResult)
|
||||
{
|
||||
int res = c_oSerConstants::ReadOk;
|
||||
@ -3841,6 +3971,7 @@ namespace BinXlsxRW {
|
||||
std::vector<long> aOffBits;
|
||||
long nOtherOffBits = -1;
|
||||
long nSharedStringsOffBits = -1;
|
||||
long nWorkbookOffBits = -1;
|
||||
BYTE mtLen = oBufferedStream.GetUChar();
|
||||
|
||||
for(int i = 0; i < mtLen; ++i)
|
||||
@ -3855,6 +3986,8 @@ namespace BinXlsxRW {
|
||||
nOtherOffBits = mtiOffBits;
|
||||
else if(c_oSerTableTypes::SharedStrings == mtiType)
|
||||
nSharedStringsOffBits = mtiOffBits;
|
||||
else if(c_oSerTableTypes::Workbook == mtiType)
|
||||
nWorkbookOffBits = mtiOffBits;
|
||||
else
|
||||
{
|
||||
aTypes.push_back(mtiType);
|
||||
@ -3883,8 +4016,16 @@ namespace BinXlsxRW {
|
||||
if(c_oSerConstants::ReadOk != res)
|
||||
return res;
|
||||
}
|
||||
|
||||
OOX::Spreadsheet::CWorkbook* pWorkbook = oXlsx.CreateWorkbook();
|
||||
std::map<long, NSCommon::smart_ptr<OOX::File>> m_mapPivotCacheDefinitions;
|
||||
if(-1 != nWorkbookOffBits)
|
||||
{
|
||||
oBufferedStream.Seek(nWorkbookOffBits);
|
||||
res = BinaryWorkbookTableReader(oBufferedStream, *pWorkbook, m_mapPivotCacheDefinitions).Read();
|
||||
if(c_oSerConstants::ReadOk != res)
|
||||
return res;
|
||||
}
|
||||
|
||||
for(size_t i = 0, length = aTypes.size(); i < length; ++i)
|
||||
{
|
||||
BYTE mtiType = aTypes[i];
|
||||
@ -3899,14 +4040,9 @@ namespace BinXlsxRW {
|
||||
res = BinaryStyleTableReader(oBufferedStream, *pStyles).Read();
|
||||
}
|
||||
break;
|
||||
case c_oSerTableTypes::Workbook:
|
||||
{
|
||||
res = BinaryWorkbookTableReader(oBufferedStream, *pWorkbook).Read();
|
||||
}
|
||||
break;
|
||||
case c_oSerTableTypes::Worksheets:
|
||||
{
|
||||
res = BinaryWorksheetsTableReader(oBufferedStream, *pWorkbook, pSharedStrings, oXlsx.GetWorksheets(), mapMedia, sOutDir, sMediaDir, oSaveParams, pOfficeDrawingConverter).Read();
|
||||
res = BinaryWorksheetsTableReader(oBufferedStream, *pWorkbook, pSharedStrings, oXlsx.GetWorksheets(), mapMedia, sOutDir, sMediaDir, oSaveParams, pOfficeDrawingConverter, m_mapPivotCacheDefinitions).Read();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user