Compare commits

..

25 Commits

Author SHA1 Message Date
23ba8a23a4 Fix multi-thread build crash 2018-10-21 15:37:15 +03:00
4df09fd25a Merge remote-tracking branch 'origin/hotfix/v5.2.3' into develop 2018-10-19 16:27:27 +03:00
8bae2e3255 . 2018-10-19 14:25:35 +03:00
6180fedb0b Merge remote-tracking branch 'origin/hotfix/v5.2.3' into develop 2018-10-19 13:05:15 +03:00
35113a76ca . 2018-10-19 12:10:06 +03:00
5895bc9641 Merge remote-tracking branch 'origin/hotfix/v5.2.3' into develop 2018-10-19 10:51:20 +03:00
a5a6686501 Merge remote-tracking branch 'origin/hotfix/v5.2.3' into develop 2018-10-19 10:50:49 +03:00
f776bb6c4e OdfFormatWriter - fix after testing 2018-10-19 10:36:02 +03:00
4c930e716b Merge remote-tracking branch 'origin/hotfix/v5.2.3' into develop 2018-10-17 15:38:13 +03:00
595ecae254 x2t - binary - native convert locked canvas - bix bug #28246 2018-10-17 13:29:55 +03:00
8d3e50f8c0 x2t - version up 2018-10-16 19:11:14 +03:00
2439106397 Fix crash on empty dash pen 2018-10-16 17:52:22 +03:00
8953b74579 Fix bug 39214 (text selection in pdf/xps) 2018-10-16 17:17:13 +03:00
bd7978e474 Correct test 2018-10-16 15:52:28 +03:00
95238af0f5 Merge branch 'hotfix/v5.2.3' of https://github.com/ONLYOFFICE/core into hotfix/v5.2.3 2018-10-15 14:02:06 +03:00
e83daf6c91 RtfFormatReader - fix bug #39315 2018-10-15 14:01:27 +03:00
a4cade5a58 Test for work with standart docs 2018-10-15 13:59:52 +03:00
4fb284ebee x2t - fix bug #39307 2018-10-15 13:12:27 +03:00
900ed115c7 Test for work with standart docs 2018-10-12 19:44:43 +03:00
d34b850c52 [ios][pe] events 2018-10-12 19:15:18 +03:00
cc31becec1 [x2t] Fix bug 39305
Fix String.ToString2 after f7a13e04d8
2018-10-12 16:39:01 +03:00
9b5f052c97 OdfFormatWriter - fix after testing 2018-10-11 17:57:45 +03:00
2017a8c692 OdfFormat - fix after testing 2018-10-10 19:29:31 +03:00
558c669fb6 Disable truetype fonts convertasion in html viewer 2018-10-10 15:58:26 +03:00
6268e8c3f3 PptxFormat - fix after testing 2018-10-10 11:27:39 +03:00
68 changed files with 1693 additions and 341 deletions

View File

@ -465,6 +465,10 @@ std::wstring oox2odf_converter::Impl::convert_formula(const std::wstring & expr)
boost::wregex(L"(?!([a-zA-Z]+\\d*\\())(([a-zA-Z]+\\!)?\\$?[a-zA-Z]*\\$?\\d*(\\:\\$?[a-zA-Z]*\\$?\\d*){0,1})"),
&oox2odf_converter::Impl::replace_arguments, boost::match_default | boost::format_all);
//SUBTOTAL(109,Expense31[Amount])
XmlUtils::replace_all( res, L"[", L"KVADRATIN");
XmlUtils::replace_all( res, L"]", L"KVADRATOUT");
if (res1 == res)
{
XmlUtils::replace_all( res1, L"KAVYCHKA", L"\""); //IMCONJUGATE_emb.xlsx

View File

@ -838,12 +838,20 @@ void common_draw_docx_convert(oox::docx_conversion_context & Context, union_comm
}
if (!drawing->isInline)
{
drawing->relativeHeight = L"2";
drawing->behindDoc = L"0";
if (((drawing->styleWrap && drawing->styleWrap->get_type() == style_wrap::RunThrough) ||
!drawing->styleWrap) && styleRunThrough && styleRunThrough->get_type() == run_through::Background)
{
drawing->behindDoc = L"1";
if (!drawing->styleWrap)
drawing->styleWrap = style_wrap(style_wrap::RunThrough);
}
if (!drawing->styleWrap)
drawing->styleWrap = style_wrap(style_wrap::Parallel);//у опен офис и мс разные дефолты
drawing->relativeHeight = L"2";
drawing->behindDoc = L"0";
_CP_OPT(int) zIndex = attlists_.shape_with_text_and_styles_.common_shape_draw_attlist_.draw_z_index_;
if (zIndex)//порядок отрисовки объектов
@ -853,13 +861,6 @@ void common_draw_docx_convert(oox::docx_conversion_context & Context, union_comm
else
drawing->relativeHeight = std::to_wstring( 2 + *zIndex );
}
if (drawing->styleWrap && drawing->styleWrap->get_type() == style_wrap::RunThrough
&& styleRunThrough && styleRunThrough->get_type() == run_through::Background)
{
drawing-> behindDoc = L"1";
}
drawing->margin_rect[0] = GetMargin(graphicProperties, sideLeft);
drawing->margin_rect[1] = GetMargin(graphicProperties, sideTop);
drawing->margin_rect[2] = GetMargin(graphicProperties, sideRight);

View File

@ -103,6 +103,7 @@ void draw_shape::common_docx_convert(oox::docx_conversion_context & Context)
{
std::wstring href = fill.bitmap->xlink_href_;
fill.bitmap->rId = Context.get_mediaitems().add_or_find(href, oox::typeImage, fill.bitmap->isInternal, href);
fill.bitmap->name_space = L"w14";
}
std::wstringstream strm_fill, strm_ln;

View File

@ -96,7 +96,7 @@ HRESULT convert_single(std::wstring srcFileName)
Oox2Odf::Converter converter(srcTempPath, type, L"C:\\Windows\\Fonts", NULL);
std::wstring sPassword = L"password";
std::wstring sPassword;// = L"password";
converter.convert();
converter.write(dstTempPath, srcTempPath, sPassword, L"hiuh56f56tfy7g");

View File

@ -209,7 +209,7 @@ static const _sh_typ Shape_Types_Mapping[] = // index === OOX::Drawing::EShapeTy
{ L"" , 7}, // shapetypeStar6,
{ L"" , 7}, // shapetypeStar7,
{ L"star8" , 7}, // shapetypeStar8,
{ L"mso-spt32" , 9}, // shapetypeStraightConnector1,
{ L"" , 9}, // shapetypeStraightConnector1,
{ L"striped-right-arrow" , 7}, // shapetypeStripedRightArrow,
{ L"" , 7}, // shapetypeSun,
{ L"" , 7}, // shapetypeSwooshArrow,

View File

@ -230,10 +230,11 @@ std::wstring odf_chart_context::Impl::convert_formula(std::wstring oox_formula)
else
{
//open office dont support defined names in chart formula
// 7501214.xlsx - частичное заполнение local-table
int col = -1, row = -1;
utils::parsing_ref( refs[0], col, row);
if (col < 0 && row < 0)
if (col < 0 && row < 0 && (odf_context_->type != SpreadsheetDocument))
{
local_table_enabled_ = true;
//find defined name ????
@ -1587,7 +1588,9 @@ void odf_chart_context::set_cash(std::wstring format, std::vector<std::wstring>
int col1 = -1, col2 = -1, row1 = -1, row2 = -1;
if (refs.size() < 1) return;
if (refs.size() < 1) return;
if (refs[0].empty()) return;
utils::parsing_ref( refs[0], col1, row1);
if (refs.size() > 1)
@ -1694,7 +1697,7 @@ int odf_chart_context::Impl::create_local_table_rows(int curr_row, ods_table_sta
add = false;
if (cells[i].row > curr_row + 1 && !header)
if (cells[i].row > curr_row + 1/* && !header*/)
{
office_element_ptr row_elm;

View File

@ -346,7 +346,7 @@ void odf_drawing_context::set_background_state(bool Val)
void odf_drawing_context::check_anchor()
{
return;
if ((impl_->is_footer_ || impl_->is_header_ || impl_->is_background_) && (impl_->anchor_settings_.run_through_) && (impl_->anchor_settings_.run_through_->get_type() == run_through::Background))
if ((/*impl_->is_footer_ || impl_->is_header_ ||*/ impl_->is_background_) && (impl_->anchor_settings_.run_through_) && (impl_->anchor_settings_.run_through_->get_type() == run_through::Background))
{
set_anchor(anchor_type::Char);
//подозрительно на подложку страницы
@ -926,6 +926,37 @@ void odf_drawing_context::end_shape()
if (line->draw_line_attlist_.svg_y1_ && impl_->current_drawing_state_.svg_height_ && !line->draw_line_attlist_.svg_y2_)
line->draw_line_attlist_.svg_y2_ = line->draw_line_attlist_.svg_y1_.get() + impl_->current_drawing_state_.svg_height_.get();
if (impl_->current_drawing_state_.rotateAngle_)
{
std::wstring strTransform;
odf_types::length x11 = odf_types::length((line->draw_line_attlist_.svg_x1_->get_value() + line->draw_line_attlist_.svg_x2_->get_value()) / 2., line->draw_line_attlist_.svg_x2_->get_unit());
odf_types::length y11 = odf_types::length((line->draw_line_attlist_.svg_y1_->get_value() + line->draw_line_attlist_.svg_y2_->get_value()) / 2., line->draw_line_attlist_.svg_y2_->get_unit());
//if (impl_->current_drawing_state_.in_group_)
{
if (line->draw_line_attlist_.svg_x1_&& line->draw_line_attlist_.svg_y1_)
{
strTransform += std::wstring(L" translate(-") + boost::lexical_cast<std::wstring>(x11)
+ std::wstring(L",-") + boost::lexical_cast<std::wstring>(y11)
+ std::wstring(L")" );
}
}
strTransform += std::wstring(L"rotate(") + boost::lexical_cast<std::wstring>(impl_->current_drawing_state_.rotateAngle_.get()) + std::wstring(L")");
if (line->draw_line_attlist_.svg_x1_&& line->draw_line_attlist_.svg_y1_)
{
strTransform += std::wstring(L" translate(") + boost::lexical_cast<std::wstring>(x11)
+ std::wstring(L",") + boost::lexical_cast<std::wstring>(y11)
+ std::wstring(L")" );
}
if (strTransform.empty() == false)
{
line->common_draw_attlists_.shape_with_text_and_styles_.common_shape_draw_attlist_.draw_transform_ = strTransform;
}
impl_->current_drawing_state_.rotateAngle_ = boost::none;
}
impl_->current_drawing_state_.svg_height_ = boost::none;
impl_->current_drawing_state_.svg_width_ = boost::none;
@ -1317,7 +1348,7 @@ void odf_drawing_context::set_no_fill()
switch(impl_->current_drawing_part_)
{
case Area:
if ((impl_->is_footer_ || impl_->is_header_ || impl_->is_background_) &&
if ((/*impl_->is_footer_ || impl_->is_header_ ||*/ impl_->is_background_) &&
(impl_->current_graphic_properties->common_draw_fill_attlist_.draw_fill_) &&
(impl_->current_graphic_properties->common_draw_fill_attlist_.draw_fill_->get_type() == draw_fill::bitmap))
{
@ -1367,7 +1398,7 @@ void odf_drawing_context::set_solid_fill(std::wstring 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_) &&
if ((/*impl_->is_footer_ || impl_->is_header_ ||*/ impl_->is_background_) &&
(impl_->current_graphic_properties->common_draw_fill_attlist_.draw_fill_) &&
(impl_->current_graphic_properties->common_draw_fill_attlist_.draw_fill_->get_type() == draw_fill::bitmap))
{
@ -2391,7 +2422,7 @@ void odf_drawing_context::set_textarea_padding(_CP_OPT(double) & left, _CP_OPT(d
//------------------------------------------------------------------------------------------------------------------
void odf_drawing_context::start_image(std::wstring odf_path)
{
if (impl_->is_footer_ || impl_->is_header_ || impl_->is_background_)
if (/*impl_->is_footer_ || impl_->is_header_ ||*/ impl_->is_background_)//AstraIntlCaseStudyFinal0.docx
{
start_shape(142/*SimpleTypes::shapetypeRect*/);
start_bitmap_style();
@ -2514,7 +2545,10 @@ void odf_drawing_context::set_text_box_min_size(bool val)
if (impl_->current_graphic_properties)
{
impl_->current_graphic_properties->draw_auto_grow_height_ = true;
impl_->current_graphic_properties->draw_auto_grow_width_ = true;
//impl_->current_graphic_properties->draw_auto_grow_width_ = true; //Example_2.xlsx
impl_->current_graphic_properties->draw_fit_to_size_ = false;
impl_->current_graphic_properties->style_shrink_to_fit_ = false;
}
if (impl_->current_drawing_state_.elements_.empty()) return;
@ -2675,7 +2709,7 @@ void odf_drawing_context::set_text_box_parent_style(std::wstring style_name)
void odf_drawing_context::end_image()
{
if (impl_->is_footer_ || impl_->is_header_ || impl_->is_background_)
if (/*impl_->is_footer_ || impl_->is_header_ ||*/ impl_->is_background_)
{
end_bitmap_style();
end_shape();

View File

@ -334,7 +334,7 @@ void ods_conversion_context::add_merge_cells(const std::wstring & ref)
int end_col = -1, end_row = -1;
utils::parsing_ref (ref_cells[0], start_col, start_row);
utils::parsing_ref (ref_cells[1], end_col, end_row);
utils::parsing_ref (ref_cells[1], end_col, end_row);
current_table().set_merge_cells(start_col,start_row, end_col, end_row);
@ -376,7 +376,7 @@ void ods_conversion_context::start_cell(std::wstring & ref, int xfd_style)
}
office_element_ptr cell_elm;
create_element(L"table", L"table-cell",cell_elm,this);
create_element(L"table", L"table-cell", cell_elm, this);
current_table().start_cell(cell_elm, style_elm);

View File

@ -80,11 +80,20 @@ std::wstring convert_date(const std::wstring & oox_date)
boost::gregorian::date date_ = boost::gregorian::date(1900, 1, 1) + boost::gregorian::date_duration(iDate-2);
////to for example, "1899-12-31T05:37:46.66569
std::wstring date_str = boost::lexical_cast<std::wstring>(date_.year())
std::wstring date_str;
try
{
date_str = boost::lexical_cast<std::wstring>(date_.year())
+ L"-" +
(date_.month() < 10 ? L"0": L"") + boost::lexical_cast<std::wstring>(date_.month().as_number())
+ L"-" +
(date_.day() < 10 ? L"0": L"") + boost::lexical_cast<std::wstring>(date_.day());
}
catch(...)
{
date_str = oox_date;
}
return date_str;
}
@ -471,21 +480,21 @@ void ods_table_state::set_row_default_cell_style(std::wstring & style_name)
office_element_ptr & ods_table_state::current_row_element()
{
if (rows_.size()>0)
if (false == rows_.empty())
return rows_.back().elm;
else
throw;
}
office_element_ptr & ods_table_state::current_cell_element()
{
if (cells_size_ >0)
if (cells_size_ > 0)
return cells_.back().elm;
else
throw;
}
ods_hyperlink_state & ods_table_state::current_hyperlink()
{
if ((cells_size_ >0 && hyperlinks_.size()>0) && (cells_.back().hyperlink_idx>=0) )
if ((cells_size_ >0 && !hyperlinks_.empty()) && (cells_.back().hyperlink_idx >= 0) )
{
return hyperlinks_[cells_.back().hyperlink_idx];
}
@ -829,8 +838,8 @@ void ods_table_state::set_cell_array_formula(std::wstring & formula, std::wstrin
std::vector<std::wstring> ref_cells;
boost::algorithm::split(ref_cells,ref, boost::algorithm::is_any_of(L":"), boost::algorithm::token_compress_on);
int row_span =0;
int col_span =0;
int row_span = 0;
int col_span = 0;
if (ref_cells.size() ==2)
{
@ -850,7 +859,7 @@ void ods_table_state::set_cell_array_formula(std::wstring & formula, std::wstrin
row_span = col_span = 1;//???
}
if (col_span >0 && row_span > 0)
if (col_span > 0 && row_span > 0)
{
table_table_cell* cell = dynamic_cast<table_table_cell*>(cells_.back().elm.get());
if (cell == NULL)return;
@ -1044,7 +1053,7 @@ void ods_table_state::set_cell_value(const std::wstring & value, bool need_cash)
void ods_table_state::end_cell()
{
if ( cells_size_ <1)return;
if ( cells_size_ < 1)return;
if (cells_.back().comment_idx >= 0)
{

View File

@ -658,6 +658,7 @@ std::map<std::wstring, std::wstring> odt_conversion_context::parse_instr_options
void odt_conversion_context::add_field_instr(const std::wstring &instr)
{
if (current_fields.empty()) return;
current_fields.back().instrText += instr;
}
void odt_conversion_context::set_field_instr()
@ -824,7 +825,7 @@ void odt_conversion_context::set_field_instr()
}
void odt_conversion_context::start_field(bool in_span)
{
if (false == current_fields.empty() && current_fields.back().status == 0)
if (false == current_fields.empty() && current_fields.back().status == 0 && current_fields.back().instrText.empty() )
return; //start_field из sdt
_field_state field;

View File

@ -136,6 +136,7 @@ oox_shape_ptr oox_shape::create(int ooxPrstGeomType)
case SimpleTypes::shapetypeBentUpArrow: return boost::make_shared<oox_shape_BentUpArrow>();
case SimpleTypes::shapetypeLeftRightUpArrow: return boost::make_shared<oox_shape_leftRightUpArrow>();
//case SimpleTypes::shapetypeStraightConnector1: return boost::make_shared<oox_shape_straightConnector1>();
//case (2001 + SimpleTypes::textshapetypeTextArchDown):
//case (2001 + SimpleTypes::textshapetypeTextArchDownPour):
//case (2001 + SimpleTypes::textshapetypeTextArchUp):
@ -176,7 +177,6 @@ oox_shape_ptr oox_shape::create(int ooxPrstGeomType)
//case (2001 + SimpleTypes::textshapetypeTextWave1):
//case (2001 + SimpleTypes::textshapetypeTextWave2):
//case (2001 + SimpleTypes::textshapetypeTextWave4):
//case SimpleTypes::shapetypeStraightConnector1: return boost::make_shared<oox_shape_straightConnector1>();
default:
if (ooxPrstGeomType > 2000) return boost::make_shared<oox_shape_textPlain>();

View File

@ -125,6 +125,7 @@ void graphic_format_properties::serialize(std::wostream & _Wostream ,const wchar
CP_XML_ATTR_OPT(L"draw:fit-to-size", draw_fit_to_size_);
CP_XML_ATTR_OPT(L"draw:fit-to-contour", draw_fit_to_contour_);
CP_XML_ATTR_OPT(L"draw:ole-draw-aspect", draw_ole_draw_aspect_);
CP_XML_ATTR_OPT(L"style:shrink-to-fit", style_shrink_to_fit_);
CP_XML_ATTR_OPT(L"draw:stroke", draw_stroke_);
CP_XML_ATTR_OPT(L"draw:stroke-dash", draw_stroke_dash_);

View File

@ -93,6 +93,7 @@ public:
_CP_OPT(odf_types::Bool) draw_auto_grow_height_;
_CP_OPT(odf_types::Bool) draw_auto_grow_width_;
_CP_OPT(odf_types::Bool) style_shrink_to_fit_;
_CP_OPT(odf_types::Bool) draw_fit_to_size_;
_CP_OPT(odf_types::Bool) draw_fit_to_contour_;
_CP_OPT(std::wstring) draw_wrap_influence_on_position_;

View File

@ -45,6 +45,7 @@
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/CxnSp.h"
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/SpTree.h"
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Table/Table.h"
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Effects/AlphaModFix.h"
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Colors/SrgbClr.h"
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Colors/PrstClr.h"
@ -513,9 +514,11 @@ void OoxConverter::convert(PPTX::Logic::GrpSpPr *oox_grpSpPr)
if (oox_grpSpPr->xfrm->rot.IsInit())
odf_context()->drawing_context()->set_group_rotate(oox_grpSpPr->xfrm->rot.get() / 60000.);
}
convert(oox_grpSpPr->EffectList.List.GetPointer());
convert(oox_grpSpPr->scene3d.GetPointer());
//UniFill Fill;
//EffectProperties EffectList;
//nullable<Scene3d> scene3d;
}
void OoxConverter::convert(PPTX::Logic::SpTree *oox_shape_tree)
@ -688,8 +691,8 @@ void OoxConverter::convert(PPTX::Logic::SpPr *oox_spPr, PPTX::Logic::ShapeStyle*
bool bLine = odf_context()->drawing_context()->isLineShape();
if (custGeom && !custGeom->cxnLst.empty())
bLine = true;
//if (custGeom && !custGeom->cxnLst.empty())
// bLine = true;
odf_context()->drawing_context()->start_area_properties();
{
@ -713,23 +716,14 @@ void OoxConverter::convert(PPTX::Logic::SpPr *oox_spPr, PPTX::Logic::ShapeStyle*
}
odf_context()->drawing_context()->end_line_properties();
//-----------------------------------------------------------------------------------------------------------------------------
PPTX::Logic::EffectLst* effectLst = NULL;
PPTX::Logic::EffectLst* effectLst = dynamic_cast<PPTX::Logic::EffectLst*>(oox_spPr->EffectList.List.GetPointer());
if (oox_spPr->EffectList.is<PPTX::Logic::EffectLst>())
{
effectLst = &oox_spPr->EffectList.as<PPTX::Logic::EffectLst>();
}
if (effectLst) convert(effectLst);
else if (oox_sp_style) convert(&oox_sp_style->effectRef, 3);
//convert(oox_spPr->ExtLst.GetPointer());
convert(oox_spPr->scene3d.GetPointer());
convert(oox_spPr->sp3d.GetPointer());
//nullable<OOX::Drawing::CEffectContainer> EffectDag;
//nullable<OOX::Drawing::COfficeArtExtensionList> ExtLst;
//nullable<OOX::Drawing::CScene3D> Scene3D;
//nullable<OOX::Drawing::CShape3D> Sp3D;
//-----------------------------------------------------------------------------------------------------------------------------
}
@ -844,15 +838,61 @@ void OoxConverter::convert(PPTX::Logic::AhPolar *oox_handle)
{
if (!oox_handle) return;
}
void OoxConverter::convert(PPTX::Logic::EffectDag *oox_effect_dag)
{
if (!oox_effect_dag) return;
//type - sib, value
for (size_t i = 0; i < oox_effect_dag->Effects.size(); ++i)
{
convert(oox_effect_dag->Effects[i].Effect.operator->());
}
}
void OoxConverter::convert(PPTX::Logic::EffectLst *oox_effect_list)
{
if (!oox_effect_list) return;
convert(oox_effect_list->blur.GetPointer());
convert(oox_effect_list->fillOverlay.GetPointer());
convert(oox_effect_list->glow.GetPointer());
convert(oox_effect_list->reflection.GetPointer());
convert(oox_effect_list->softEdge.GetPointer());
convert(oox_effect_list->innerShdw.GetPointer());
convert(oox_effect_list->outerShdw.GetPointer());
convert(oox_effect_list->prstShdw.GetPointer());
}
void OoxConverter::convert(PPTX::Logic::AlphaModFix *oox_alpha)
{
if (oox_alpha == NULL) return;
if (false == oox_alpha->amt.IsInit()) return;
odf_context()->drawing_context()->set_opacity(oox_alpha->amt.get() / 1000.);
}
void OoxConverter::convert(PPTX::Logic::Blur *oox_effect)
{
if (oox_effect == NULL) return;
}
void OoxConverter::convert(PPTX::Logic::FillOverlay *oox_effect)
{
if (oox_effect == NULL) return;
}
void OoxConverter::convert(PPTX::Logic::Reflection *oox_effect)
{
if (oox_effect == NULL) return;
}
void OoxConverter::convert(PPTX::Logic::Glow *oox_effect)
{
if (oox_effect == NULL) return;
}
void OoxConverter::convert(PPTX::Logic::SoftEdge *oox_effect)
{
if (oox_effect == NULL) return;
}
void OoxConverter::convert(PPTX::Logic::InnerShdw *oox_shadow)
{
if (oox_shadow == NULL) return;
@ -991,10 +1031,10 @@ void OoxConverter::convert(PPTX::Logic::BlipFill *oox_bitmap_fill)
odf_context()->drawing_context()->set_bitmap_link(pathImage);
//...
}
//for (size_t i = 0 ; i < oox_bitmap_fill->blip->m_arrEffects.size(); i++)
//{
// convert(oox_bitmap_fill->blip->m_arrEffects[i]);
//}
for (size_t i = 0 ; i < oox_bitmap_fill->blip->Effects.size(); i++)
{
convert(oox_bitmap_fill->blip->Effects[i].Effect.operator->());
}
}
if (oox_bitmap_fill->srcRect.IsInit() && Width > 0 && Height > 0)//часть изображения
{
@ -2293,7 +2333,7 @@ void OoxConverter::convert(PPTX::Logic::StyleRef *style_ref, int type)
if (index < 1000)
{
index -= 1;
if ((index >= 0) || (index < (int)theme->themeElements.fmtScheme.fillStyleLst.size()))
if (index >= 0 && index < (int)theme->themeElements.fmtScheme.fillStyleLst.size())
{
fill = &theme->themeElements.fmtScheme.fillStyleLst[index];
}
@ -2301,7 +2341,7 @@ void OoxConverter::convert(PPTX::Logic::StyleRef *style_ref, int type)
else if (index > 1000)
{
index -= 1001;
if ((index >= 0) || (index < (int)theme->themeElements.fmtScheme.bgFillStyleLst.size()))
if (index >= 0 && index < (int)theme->themeElements.fmtScheme.bgFillStyleLst.size())
{
fill = &theme->themeElements.fmtScheme.bgFillStyleLst[index];
}
@ -2312,15 +2352,15 @@ void OoxConverter::convert(PPTX::Logic::StyleRef *style_ref, int type)
else if (type == 2)
{
index -= 1;
if (index >= 0 || index < (int)theme->themeElements.fmtScheme.lnStyleLst.size())
if (index >= 0 && index < (int)theme->themeElements.fmtScheme.lnStyleLst.size())
{
convert(&theme->themeElements.fmtScheme.lnStyleLst[index], nARGB);
}
}
else if (type == 3)
else if (type == 3)
{
index -= 1;
if ((index >= 0) || (index < (int)theme->themeElements.fmtScheme.effectStyleLst.size()))
if (index >= 0 && index < (int)theme->themeElements.fmtScheme.effectStyleLst.size())
{
convert(&theme->themeElements.fmtScheme.effectStyleLst[index]);
}

View File

@ -483,9 +483,17 @@ void OoxConverter::convert(OOX::Vml::CFill *vml_fill)
odf_context()->drawing_context()->set_gradient_start(*sRgbColor1, no_set);
if (sRgbColor2)
odf_context()->drawing_context()->set_gradient_end(*sRgbColor2, no_set);
else
odf_context()->drawing_context()->set_gradient_end(L"#ffffff", no_set);
if (vml_fill->m_oAngle.IsInit())
{
odf_context()->drawing_context()->set_gradient_angle(vml_fill->m_oAngle->GetValue() + 90);
}
if (vml_fill->m_oFocusPosition.IsInit())
{
odf_context()->drawing_context()->set_gradient_center(vml_fill->m_oFocusPosition->GetX(), vml_fill->m_oFocusPosition->GetY());
}
odf_context()->drawing_context()->end_gradient_style();
}break;
@ -952,9 +960,9 @@ void OoxConverter::convert(OOX::Vml::CVmlCommonElements *vml_common)
delete oRgbColor;
}
}
for (std::vector<OOX::WritingElement*>::iterator it = vml_common->m_arrItems.begin(); it != vml_common->m_arrItems.end(); ++it)
for (size_t i = 0; i < vml_common->m_arrItems.size(); ++i)
{
convert(*it);
convert(vml_common->m_arrItems[i]);
}
if (vml_common->m_oFilled.IsInit() && vml_common->m_oFilled->GetValue() == SimpleTypes::booleanFalse)

View File

@ -61,6 +61,7 @@
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/GraphicFrame.h"
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Pic.h"
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/SmartArt.h"
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Effects/AlphaModFix.h"
#include "../../../Common/DocxFormat/Source/XlsxFormat/Worksheets/Sparkline.h"
#include "../../../OfficeCryptReader/source/CryptTransform.h"
@ -373,6 +374,7 @@ void OoxConverter::convert(OOX::WritingElement *oox_unknown)
case OOX::et_p_ShapeTree:
case OOX::et_a_GroupShape:
case OOX::et_w_GroupShape:
case OOX::et_lc_LockedCanvas:
{
convert(dynamic_cast<PPTX::Logic::SpTree *>(oox_unknown));
}break;
@ -443,14 +445,42 @@ void OoxConverter::convert(OOX::WritingElement *oox_unknown)
{
convert(dynamic_cast<PPTX::Logic::EffectStyle*>(oox_unknown));
}break;
//case OOX::et_a_alphaModFix:
//{
// OOX::Drawing::CAlphaModulateFixedEffect* pAlpha= dynamic_cast<OOX::Drawing::CAlphaModulateFixedEffect*>(oox_unknown);
// if (pAlpha)
// {
// odf_context()->drawing_context()->set_opacity(pAlpha->m_oAmt.GetValue());
// }
//}break;
case OOX::et_a_alphaModFix:
{
convert(dynamic_cast<PPTX::Logic::AlphaModFix*>(oox_unknown));
}break;
case OOX::et_a_blur:
{
convert(dynamic_cast<PPTX::Logic::Blur*>(oox_unknown));
}break;
case OOX::et_a_fillOverlay:
{
convert(dynamic_cast<PPTX::Logic::FillOverlay*>(oox_unknown));
}break;
case OOX::et_a_glow:
{
convert(dynamic_cast<PPTX::Logic::Glow*>(oox_unknown));
}break;
case OOX::et_a_innerShdw:
{
convert(dynamic_cast<PPTX::Logic::InnerShdw*>(oox_unknown));
}break;
case OOX::et_a_outerShdw:
{
convert(dynamic_cast<PPTX::Logic::OuterShdw*>(oox_unknown));
}break;
case OOX::et_a_reflection:
{
convert(dynamic_cast<PPTX::Logic::Reflection*>(oox_unknown));
}break;
case OOX::et_a_softEdge:
{
convert(dynamic_cast<PPTX::Logic::SoftEdge*>(oox_unknown));
}break;
case OOX::et_a_effectDag:
{
convert(dynamic_cast<PPTX::Logic::EffectDag*>(oox_unknown));
}break;
case OOX::et_v_imagedata:
{
convert(dynamic_cast<OOX::Vml::CImageData*>(oox_unknown));

View File

@ -294,6 +294,7 @@ namespace PPTX
class SolidFill;
class PattFill;
class EffectLst;
class EffectDag;
class FontRef;
class StyleRef;
class Ln;
@ -328,12 +329,18 @@ namespace PPTX
class QuadBezTo;
class CubicBezTo;
class Close;
class AhXY;
class AhPolar;
class EffectStyle;
class InnerShdw;
class OuterShdw;
class PrstShdw;
class AhXY;
class AhPolar;
class AlphaModFix;
class Blur;
class FillOverlay;
class Glow;
class Reflection;
class SoftEdge;
}
}
@ -448,12 +455,19 @@ public:
void convert(PPTX::Logic::Close *oox_geom_path);
void convert(PPTX::Logic::AhXY *oox_handle);
void convert(PPTX::Logic::AhPolar *oox_handle);
void convert(PPTX::Logic::EffectStyle *oox_effect);
void convert(PPTX::Logic::EffectLst *oox_effect_list);
void convert(PPTX::Logic::EffectDag *oox_effect_dag);
void convert(PPTX::Logic::InnerShdw *oox_effect);
void convert(PPTX::Logic::OuterShdw *oox_effect);
void convert(PPTX::Logic::PrstShdw *oox_effect);
void convert(PPTX::Logic::AlphaModFix *oox_effect);
void convert(PPTX::Logic::Blur *oox_effect);
void convert(PPTX::Logic::FillOverlay *oox_effect);
void convert(PPTX::Logic::Glow *oox_effect);
void convert(PPTX::Logic::Reflection *oox_effect);
void convert(PPTX::Logic::SoftEdge *oox_effect);
//.chart............................................................................................................................
void convert(OOX::Spreadsheet::CT_ChartSpace *oox_chart);
void convert(OOX::Spreadsheet::CT_Title *ct_title);

View File

@ -1205,7 +1205,8 @@ void OoxConverter::convert(OOX::Spreadsheet::CT_NumDataSource* val)
}
else if (val->m_numRef)
{
if (val->m_numRef->m_f)odf_context()->chart_context()->set_series_value_formula(*val->m_numRef->m_f);
if (val->m_numRef->m_f)
odf_context()->chart_context()->set_series_value_formula(*val->m_numRef->m_f);
convert(val->m_numRef->m_numCache, false, false);
}

View File

@ -352,6 +352,7 @@ void DocxConverter::convert(OOX::WritingElement *oox_unknown)
}break;
case OOX::et_w_GroupShape:
case OOX::et_p_ShapeTree:
case OOX::et_lc_LockedCanvas:
{
convert(dynamic_cast<PPTX::Logic::SpTree*>(oox_unknown));
}break;
@ -3000,6 +3001,11 @@ void DocxConverter::convert(OOX::Drawing::CAnchor *oox_anchor)
odt_context->drawing_context()->set_wrap_style(odf_types::style_wrap::Parallel);
wrap_set = true;
}
else if (oox_anchor->m_oWrapNone.IsInit())
{
odt_context->drawing_context()->set_wrap_style(odf_types::style_wrap::None);
wrap_set = true;
}
else if (oox_anchor->m_oAllowOverlap.IsInit())
{
odt_context->drawing_context()->set_overlap(oox_anchor->m_oAllowOverlap->ToBool());
@ -4363,13 +4369,22 @@ bool DocxConverter::convert(OOX::Logic::CTableProperty *oox_table_pr, odf_writer
}
else if (oox_table_pr->m_oTblLayout.IsInit() && oox_table_pr->m_oTblLayout->m_oType.IsInit())
{
table_properties->table_format_properties_.common_horizontal_margin_attlist_.fo_margin_left_ = odf_types::length(0,odf_types::length::cm);
table_properties->table_format_properties_.common_horizontal_margin_attlist_.fo_margin_left_ = odf_types::length(0, odf_types::length::cm);
table_properties->table_format_properties_.table_align_ = odf_types::table_align(odf_types::table_align::Left);
}
//if(oox_table_pr->m_oJc.IsInit() && oox_table_pr->m_oJc->m_oVal.IsInit())
//{
//}
if(oox_table_pr->m_oJc.IsInit() && oox_table_pr->m_oJc->m_oVal.IsInit())
{
switch(oox_table_pr->m_oJc->m_oVal->GetValue())
{
case 0: table_properties->table_format_properties_.table_align_ = odf_types::table_align(odf_types::table_align::Center); break;
case 2:
case 3: table_properties->table_format_properties_.table_align_ = odf_types::table_align(odf_types::table_align::Left); break;
case 1:
case 4: table_properties->table_format_properties_.table_align_ = odf_types::table_align(odf_types::table_align::Right); break;
default: break;
}
}
//nullable<ComplexTypes::Word::COnOff2<SimpleTypes::onoffTrue> > m_oBidiVisual;
//nullable<ComplexTypes::Word::CShading > m_oShade;
//nullable<ComplexTypes::Word::std::wstring_ > m_oTblCaption;

View File

@ -1297,7 +1297,8 @@ void PptxConverter::convert(PPTX::Logic::Bg *oox_background)
if (oox_background->bgPr.IsInit())
{
OoxConverter::convert(&oox_background->bgPr->Fill);
//EffectProperties EffectList;
convert(oox_background->bgPr->EffectList.List.GetPointer());
//nullable_bool shadeToTitle;
}
else if (oox_background->bgRef.IsInit())

View File

@ -43,6 +43,8 @@
#include "../../../Common/DocxFormat/Source/XlsxFormat/Pivot/PivotCacheDefinition.h"
#include "../../../Common/DocxFormat/Source/XlsxFormat/Pivot/PivotCacheRecords.h"
#include "../../../Common/DocxFormat/Source/DocxFormat/VmlDrawing.h"
#include "../OdfFormat/ods_conversion_context.h"
#include "../OdfFormat/odf_text_context.h"
@ -1115,10 +1117,14 @@ void XlsxConverter::convert(OOX::Spreadsheet::CSheetViews *oox_sheet_views)
std::wstring ref(selection->m_oActiveCell.get());
odf_writer::utils::parsing_ref (ref, ActiveCellX, ActiveCellY);
if (ActiveCellX >= 0 && ActiveCellY >= 0)
if (ActiveCellX > 0 && ActiveCellY > 0)
{
ods_context->settings_context()->add_property(L"CursorPositionX", L"int", std::to_wstring(ActiveCellX));
ods_context->settings_context()->add_property(L"CursorPositionY", L"int", std::to_wstring(ActiveCellY));
ods_context->settings_context()->add_property(L"CursorPositionX", L"int", std::to_wstring(ActiveCellX - 1));
ods_context->settings_context()->add_property(L"CursorPositionY", L"int", std::to_wstring(ActiveCellY - 1));
ods_context->settings_context()->add_property(L"PositionLeft", L"int", std::to_wstring(0));
ods_context->settings_context()->add_property(L"PositionRight", L"int", std::to_wstring(0));
ods_context->settings_context()->add_property(L"PositionTop", L"int", std::to_wstring(0));
ods_context->settings_context()->add_property(L"PositionBottom", L"int", std::to_wstring(ActiveCellY > 30 ? ActiveCellY - 2 : 0));
}
}
if (selection->m_oSqref.IsInit())
@ -1983,16 +1989,37 @@ void XlsxConverter::convert(OOX::Spreadsheet::CCellAnchor *oox_anchor)
if (!oox_anchor) return;
//////////////////
if (oox_anchor->m_oFrom.IsInit() || oox_anchor->m_oTo.IsInit())
if (oox_anchor->m_oFrom.IsInit() || oox_anchor->m_oTo.IsInit() ||
oox_anchor->m_oPos.IsInit() || oox_anchor->m_oExt.IsInit())
{
oox_table_position from={}, to={};
convert(oox_anchor->m_oFrom.GetPointer(), &from);
convert(oox_anchor->m_oTo.GetPointer(), &to);
double x1 = 0, y1 = 0, x2 = 0, y2 = 0;
double x1=0, y1=0, x2=0, y2=0;
ods_context->current_table().convert_position(from, x1, y1);
ods_context->current_table().convert_position(to, x2, y2);
if (oox_anchor->m_oFrom.IsInit())
{
convert(oox_anchor->m_oFrom.GetPointer(), &from);
ods_context->current_table().convert_position(from, x1, y1);
}
else if (oox_anchor->m_oPos.IsInit())
{
if (oox_anchor->m_oPos->m_oX.IsInit())
x1 = oox_anchor->m_oPos->m_oX->GetValue();
if (oox_anchor->m_oPos->m_oY.IsInit())
y1 = oox_anchor->m_oPos->m_oY->GetValue();
}
if (oox_anchor->m_oTo.IsInit())
{
convert(oox_anchor->m_oTo.GetPointer(), &to);
ods_context->current_table().convert_position(to, x2, y2);
}
else if (oox_anchor->m_oExt.IsInit())
{
if (oox_anchor->m_oExt->m_oCx.IsInit())
x2 = x1 + oox_anchor->m_oExt->m_oCx->GetValue();
if (oox_anchor->m_oExt->m_oCy.IsInit())
y2 = y1 + oox_anchor->m_oExt->m_oCy->GetValue();
}
ods_context->drawing_context()->set_drawings_rect(x1, y1, x2 - x1, y2 - y1);
}
@ -2100,10 +2127,77 @@ void XlsxConverter::convert(OOX::Spreadsheet::COleObjects *oox_objects, OOX::Spr
odf_ref_image = odf_context()->add_imageobject(pathImage);
}
//--------------------------------------------------------------------------------------------------
if (!bAnchor || odf_ref_image.empty())
if ((!bAnchor || odf_ref_image.empty()) && object->m_oShapeId.IsInit() && (oox_sheet->m_oLegacyDrawing.IsInit()) && (oox_sheet->m_oLegacyDrawing->m_oId.IsInit()))
{
//from vml drawing or oox drawing
//m_oShapeId;
//todooo вынести отдельно если понадобится еще для чего
OOX::CVmlDrawing *pVmlDrawing = NULL;
smart_ptr<OOX::File> oFileV = oox_sheet->Find(oox_sheet->m_oLegacyDrawing->m_oId->GetValue());
if (oFileV.IsInit() && OOX::FileTypes::VmlDrawing == oFileV->type())
{
pVmlDrawing = (OOX::CVmlDrawing*)oFileV.operator->();
}
OOX::WritingElement* pShapeElem = NULL;
std::wstring sShapeId = L"_x0000_s" + std::to_wstring(object->m_oShapeId->GetValue());
if (pVmlDrawing)
{
boost::unordered_map<std::wstring, OOX::CVmlDrawing::_vml_shape>::iterator pFind = pVmlDrawing->m_mapShapes.find(sShapeId);
if (pFind != pVmlDrawing->m_mapShapes.end())
{
pShapeElem = pFind->second.pElement;
}
}
OOX::Vml::CShape* pShape = static_cast<OOX::Vml::CShape*>(pShapeElem);
for(size_t j = 0; (pShape) && (j < pShape->m_arrItems.size()); ++j)
{
OOX::WritingElement* pChildElemShape = pShape->m_arrItems[j];
if(!bAnchor && OOX::et_v_ClientData == pChildElemShape->getType())
{
OOX::Vml::CClientData* pClientData = static_cast<OOX::Vml::CClientData*>(pChildElemShape);
SimpleTypes::Spreadsheet::CCellAnchorType<> eAnchorType;
OOX::Spreadsheet::CCellAnchor *pCellAnchor = new OOX::Spreadsheet::CCellAnchor(eAnchorType);
pClientData->toCellAnchor(pCellAnchor);
oox_table_position from = {}, to = {};
convert(pCellAnchor->m_oFrom.GetPointer(), &from);
convert(pCellAnchor->m_oTo.GetPointer(), &to);
delete pCellAnchor;
double x1 = 0, y1 = 0, x2 = 0, y2 = 0;
ods_context->current_table().convert_position(from, x1, y1);
ods_context->current_table().convert_position(to, x2, y2);
ods_context->drawing_context()->set_drawings_rect(x1, y1, x2 - x1, y2 - y1);
}
if(OOX::et_v_imagedata == pChildElemShape->getType())
{
OOX::Vml::CImageData* pImageData = static_cast<OOX::Vml::CImageData*>(pChildElemShape);
std::wstring sIdImageFileCache;
if (pImageData->m_oRelId.IsInit()) sIdImageFileCache = pImageData->m_oRelId->GetValue();
else if (pImageData->m_rId.IsInit()) sIdImageFileCache = pImageData->m_rId->GetValue();
else if (pImageData->m_rPict.IsInit()) sIdImageFileCache = pImageData->m_rPict->GetValue();
if (!sIdImageFileCache.empty())
{
//ищем физический файл ( rId относительно vml_drawing)
smart_ptr<OOX::File> pFile = pVmlDrawing->Find(sIdImageFileCache);
if (pFile.IsInit() && ( OOX::FileTypes::Image == pFile->type()))
{
OOX::Image* pImageFileCache = static_cast<OOX::Image*>(pFile.operator->());
if (pImageFileCache && odf_ref_image.empty())
{
odf_ref_image = odf_context()->add_imageobject(pImageFileCache->filename().GetPath());
}
}
}
}
}
}
//--------------------------------------------------------------------------------------------------
ods_context->drawing_context()->start_drawing();

View File

@ -1346,21 +1346,10 @@ std::wstring CDrawingConverter::ObjectToDrawingML(const std::wstring& sXml, int
oXmlWriter.WriteString(strMainProps);
if (oElem.is<PPTX::Logic::SpTree>())
{
oXmlWriter.WriteString(L"<a:graphic xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\">\
<a:graphicData uri=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\">");
}
else if (oElem.is<PPTX::Logic::Pic>())
{
oXmlWriter.WriteString(L"<a:graphic xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\">\
<a:graphicData uri=\"http://schemas.openxmlformats.org/drawingml/2006/picture\">");
}
else
{
oXmlWriter.WriteString(L"<a:graphic xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\">\
<a:graphicData uri=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\">");
}
std::wstring uri = oElem.GetUriElem();
oXmlWriter.WriteString(L"<a:graphic xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\"><a:graphicData uri=\"" + uri + L"\">");
oElem.toXmlWriter(&oXmlWriter);
oXmlWriter.WriteString(L"</a:graphicData></a:graphic>");
@ -4855,24 +4844,12 @@ HRESULT CDrawingConverter::SaveObject(LONG lStart, LONG lLength, const std::wstr
oXmlWriter.WriteString(L"<w:drawing>");
oXmlWriter.WriteString(strMainProps);
if (oElem.is<PPTX::Logic::SpTree>())
{
oXmlWriter.WriteString(L"<a:graphic xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\">\
<a:graphicData uri=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\">");
}
else if (oElem.is<PPTX::Logic::Pic>())
{
oXmlWriter.WriteString(L"<a:graphic xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\">\
<a:graphicData uri=\"http://schemas.openxmlformats.org/drawingml/2006/picture\">");
}
else
{
oXmlWriter.WriteString(L"<a:graphic xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\">\
<a:graphicData uri=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\">");
}
std::wstring uri = oElem.GetUriElem();
oXmlWriter.WriteString(L"<a:graphic xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\"><a:graphicData uri=\"" + uri + L"\">");
oElem.toXmlWriter(&oXmlWriter);
oXmlWriter.WriteString(L"</a:graphicData>\
</a:graphic>");
oXmlWriter.WriteString(L"</a:graphicData></a:graphic>");
oXmlWriter.WriteString(strMainPropsTail);
oXmlWriter.WriteString(bIsInline ? L"</wp:inline>" : L"</wp:anchor>");

View File

@ -190,6 +190,7 @@ namespace NSBinPptxRW
#define SPTREE_TYPE_OLE 6
#define SPTREE_TYPE_VIDEO 7
#define SPTREE_TYPE_AUDIO 8
#define SPTREE_TYPE_LOCKED_CANVAS 9
static BYTE SchemeClr_GetBYTECode(const std::wstring& sValue)
{
@ -274,9 +275,9 @@ static std::wstring SchemeClr_GetStringCode(const BYTE& val)
#define XMLWRITER_DOC_TYPE_PPTX 0
#define XMLWRITER_DOC_TYPE_DOCX 1
#define XMLWRITER_DOC_TYPE_XLSX 2
#define XMLWRITER_DOC_TYPE_CHART 3
#define XMLWRITER_DOC_TYPE_WORDART 4
#define XMLWRITER_DOC_TYPE_DOCX_CHILD 5
#define XMLWRITER_DOC_TYPE_CHART 3
#define XMLWRITER_DOC_TYPE_WORDART 4
#define XMLWRITER_DOC_TYPE_GRAPHICS 5
#define XMLWRITER_RECORD_TYPE_SPPR 0
#define XMLWRITER_RECORD_TYPE_CLRMAPOVR 1

View File

@ -192,8 +192,9 @@ namespace PPTX
{
std::wstring namespace_ = m_namespace;
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX) namespace_ = _T("wps");
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX) namespace_ = _T("xdr");
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX) namespace_ = L"wps";
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX) namespace_ = L"xdr";
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_GRAPHICS)namespace_ = L"a";
pWriter->StartNode(namespace_ + L":cNvCxnSpPr");

View File

@ -143,6 +143,7 @@ namespace PPTX
namespaceLockLink_ = PPTX::g_Namespaces.a.m_strLink;
namespace_ = L"wp";
}
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_GRAPHICS) namespace_ = L"a";
pWriter->StartNode(namespace_ + L":cNvGraphicFramePr");

View File

@ -58,9 +58,10 @@ namespace PPTX
virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const
{
std::wstring ns = m_namespace;
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX)
ns = L"xdr";
std::wstring namespace_ = m_namespace;
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX) namespace_ = L"xdr";
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_GRAPHICS) namespace_ = L"a";
if (!noChangeAspect.is_init() &&
!noGrp.is_init() &&
@ -70,11 +71,11 @@ namespace PPTX
!noSelect.is_init() &&
!noUngrp.is_init())
{
pWriter->WriteString(L"<" + ns + L":cNvGrpSpPr/>");
pWriter->WriteString(L"<" + namespace_ + L":cNvGrpSpPr/>");
return;
}
pWriter->WriteString(L"<" + ns + L":cNvGrpSpPr>");
pWriter->WriteString(L"<" + namespace_ + L":cNvGrpSpPr>");
pWriter->StartNode(_T("a:grpSpLocks"));
@ -90,7 +91,7 @@ namespace PPTX
pWriter->EndNode(_T("a:grpSpLocks"));
pWriter->WriteString(L"</" + ns + L":cNvGrpSpPr>");
pWriter->WriteString(L"</" + namespace_ + L":cNvGrpSpPr>");
}
void toXmlWriter2(const std::wstring& strNS, NSBinPptxRW::CXmlWriter* pWriter) const

View File

@ -169,6 +169,7 @@ namespace PPTX
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX) namespace_ = L"pic";
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX) namespace_ = L"xdr";
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_GRAPHICS) namespace_ = L"a";
pWriter->StartNode(namespace_ + L":cNvPicPr");

View File

@ -178,8 +178,9 @@ namespace PPTX
{
std::wstring namespace_ = m_namespace;
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX) namespace_= _T("pic");
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX) namespace_= _T("xdr");
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX) namespace_= L"pic";
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX) namespace_= L"xdr";
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_GRAPHICS)namespace_= L"a";
toXmlWriter2(namespace_, pWriter);

View File

@ -161,8 +161,9 @@ namespace PPTX
{
std::wstring namespace_ = m_namespace;
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX) namespace_ = _T("wps");
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX) namespace_ = _T("xdr");
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX) namespace_ = L"wps";
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX) namespace_ = L"xdr";
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_GRAPHICS) namespace_ = L"a";
pWriter->StartNode(namespace_ + L":cNvSpPr");

View File

@ -91,7 +91,8 @@ namespace PPTX
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX) namespace_ = L"wps";
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX) namespace_ = L"xdr";
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_GRAPHICS)namespace_ = L"a";
pWriter->StartNode(namespace_ + L":cxnSp");
pWriter->EndAttributes();
@ -101,10 +102,9 @@ namespace PPTX
if (style.is_init())
{
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX)
style->m_namespace = _T("wps");
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX)
style->m_namespace = _T("xdr");
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX) style->m_namespace = L"wps";
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX) style->m_namespace = L"xdr";
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_GRAPHICS)style->m_namespace = L"a";
pWriter->Write(style);
}

View File

@ -30,8 +30,6 @@
*
*/
#include "EffectProperties.h"
#include "EffectLst.h"
#include "EffectDag.h"
namespace PPTX
{

View File

@ -351,14 +351,12 @@ namespace PPTX
nvGraphicFramePr.toXmlWriter(pWriter);
if (xfrm.IsInit() && pWriter->m_lDocType != XMLWRITER_DOC_TYPE_DOCX)
{
std::wstring namespace_ = m_namespace;
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX && pWriter->m_lGroupIndex >= 0) namespace_ = L"xdr";
{
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX && pWriter->m_lGroupIndex >= 0) xfrm->m_ns = L"xdr";
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_GRAPHICS) xfrm->m_ns = L"a";
xfrm->m_ns = namespace_;
xfrm->toXmlWriter(pWriter);
}
if (table.is_init())
{
pWriter->WriteString (L"<a:graphic><a:graphicData uri=\"http://schemas.openxmlformats.org/drawingml/2006/table\">");
@ -378,6 +376,7 @@ namespace PPTX
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX && pWriter->m_lGroupIndex >= 0) namespace_ = L"wpg";
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX && pWriter->m_lGroupIndex >= 0) namespace_ = L"xdr";
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_GRAPHICS) namespace_ = L"a";
pWriter->StartNode(namespace_ + L":graphicFrame");
@ -752,7 +751,11 @@ namespace PPTX
olePic.Init();
olePic->blipFill.blip.Init();
olePic->blipFill.stretch.Init();
olePic->blipFill.stretch->fillRect.Init();
olePic->blipFill.srcRect.Init();
olePic->blipFill.blip->oleFilepathImage = NSDirectory::CreateTempFileWithUniqueName(sTempDirectory, L"img");

View File

@ -165,6 +165,7 @@ namespace PPTX
std::wstring namespace_ = m_namespace;
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX) namespace_ = L"wpg";
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX) namespace_ = L"xdr";
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_GRAPHICS) namespace_ = L"a";
pWriter->StartNode(namespace_ + L":grpSpPr");

View File

@ -109,8 +109,9 @@ namespace PPTX
{
std::wstring namespace_ = m_namespace;
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX) namespace_ = _T("wps");
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX) namespace_ = _T("xdr");
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX) namespace_ = L"wps";
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX) namespace_ = L"xdr";
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_GRAPHICS)namespace_ = L"a";
pWriter->StartNode(namespace_ + L":nvCxnSpPr");

View File

@ -117,7 +117,7 @@ namespace PPTX
return;
}
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX && pWriter->m_lGroupIndex >= 0)
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX && pWriter->m_lGroupIndex >= 0)
{
pWriter->StartNode(_T("xdr:nvGraphicFramePr"));
pWriter->EndAttributes();
@ -128,15 +128,20 @@ namespace PPTX
pWriter->EndNode(_T("xdr:nvGraphicFramePr"));
return;
}
std::wstring namespace_ = m_namespace;
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_GRAPHICS)
{
namespace_ = L"a";
}
pWriter->StartNode(_T("p:nvGraphicFramePr"));
pWriter->StartNode(namespace_ + L":nvGraphicFramePr");
pWriter->EndAttributes();
cNvPr.toXmlWriter(pWriter);
cNvGraphicFramePr.toXmlWriter(pWriter);
nvPr.toXmlWriter(pWriter);
pWriter->EndNode(_T("p:nvGraphicFramePr"));
pWriter->EndNode(namespace_ + L":nvGraphicFramePr");
}
virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const

View File

@ -79,6 +79,7 @@ namespace PPTX
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX) namespace_ = L"wpg";
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX) namespace_ = L"xdr";
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_GRAPHICS) namespace_ = L"a";
pWriter->StartNode(namespace_ + L":nvGrpSpPr");

View File

@ -129,6 +129,7 @@ namespace PPTX
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX) namespace_ = L"pic";
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX) namespace_ = L"xdr";
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_GRAPHICS) namespace_ = L"a";
pWriter->StartNode(namespace_ + L":nvPicPr");

View File

@ -125,8 +125,9 @@ namespace PPTX
{
std::wstring namespace_ = m_namespace;
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX) namespace_ = _T("wps");
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX) namespace_ = _T("xdr");
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX) namespace_ = L"wps";
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX) namespace_ = L"xdr";
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_GRAPHICS) namespace_ = L"a";
pWriter->StartNode( namespace_ + L":nvSpPr");

View File

@ -752,6 +752,7 @@ namespace PPTX
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX) namespace_ = L"xdr";
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX) namespace_ = L"pic";
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_GRAPHICS) namespace_ = L"a";
if (pWriter->m_lDocType != XMLWRITER_DOC_TYPE_XLSX &&
pWriter->m_lDocType != XMLWRITER_DOC_TYPE_DOCX)
@ -1497,7 +1498,11 @@ namespace PPTX
if(oleObject->m_oId.IsInit())
{
if (blipFill.blip.IsInit() == false)
{
blipFill.blip.Init();
blipFill.stretch.Init();
blipFill.stretch->fillRect.Init();
}
blipFill.blip->oleRid = oleObject->m_oId->get();
}
XmlMacroReadAttributeBase(node, L"spid", oleObject->m_sShapeId);

View File

@ -207,6 +207,7 @@ namespace PPTX
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX) name_ = L"wps:wsp";
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX) name_ = L"xdr:sp";
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_GRAPHICS) name_ = L"a:sp";
pWriter->StartNode(name_);
@ -236,21 +237,6 @@ namespace PPTX
pWriter->m_lFlag -= 0x02;
}
if (style.is_init())
{
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX) style->m_namespace = _T("wps");
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX) style->m_namespace = _T("xdr");
pWriter->Write(style);
}
if (pWriter->m_lDocType != XMLWRITER_DOC_TYPE_DOCX)
{
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX && txBody.is_init())
txBody->m_name = _T("xdr:txBody");
pWriter->Write(txBody);
}
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX)
{
bool bIsWritedBodyPr = false;
@ -279,7 +265,33 @@ namespace PPTX
pWriter->WriteString(_T("<wps:bodyPr rot=\"0\"><a:prstTxWarp prst=\"textNoShape\"><a:avLst/></a:prstTxWarp><a:noAutofit/></wps:bodyPr>"));
}
}
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_GRAPHICS)
{
txBody->m_name = L"a:txBody";
pWriter->StartNode(L"a:txSp");
pWriter->EndAttributes();
pWriter->Write(txBody);
pWriter->WriteString(L"<a:useSpRect/>");
pWriter->EndNode(L"a:txSp");
}
else
{
if (txBody.is_init())
{
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX)
txBody->m_name = L"xdr:txBody";
}
pWriter->Write(txBody);
}
if (style.is_init())
{
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX) style->m_namespace = L"wps";
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX) style->m_namespace = L"xdr";
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_GRAPHICS) style->m_namespace = L"a";
pWriter->Write(style);
}
pWriter->EndNode(name_);
}

View File

@ -80,24 +80,22 @@ namespace PPTX
virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const
{
std::wstring name_ = L"a:spPr";
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX)
{
if (0 == (pWriter->m_lFlag & 0x01))
pWriter->StartNode(_T("wps:spPr"));
else
pWriter->StartNode(_T("pic:spPr"));
if (0 == (pWriter->m_lFlag & 0x01)) name_ = L"wps:spPr";
else name_ = L"pic:spPr";
}
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX)
pWriter->StartNode(_T("xdr:spPr"));
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_CHART)
pWriter->StartNode(_T("c:spPr"));
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX) name_ = L"xdr:spPr";
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_CHART) name_ = L"c:spPr";
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_GRAPHICS) name_ = L"a:spPr";
else
{
if (0 != (pWriter->m_lFlag & 0x04))//theme
pWriter->StartNode(_T("a:spPr"));
else
pWriter->StartNode(_T("p:spPr"));
{//theme
if (0 != (pWriter->m_lFlag & 0x04)) name_ = L"a:spPr";
else name_ = L"p:spPr";
}
pWriter->StartNode(name_);
pWriter->StartAttributes();
pWriter->WriteAttribute(_T("bwMode"), bwMode);
@ -117,24 +115,7 @@ namespace PPTX
pWriter->Write(scene3d);
pWriter->Write(sp3d);
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX)
{
if (0 == (pWriter->m_lFlag & 0x01))
pWriter->EndNode(_T("wps:spPr"));
else
pWriter->EndNode(_T("pic:spPr"));
}
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX)
pWriter->EndNode(_T("xdr:spPr"));
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_CHART)
pWriter->EndNode(_T("c:spPr"));
else
{
if (0 != (pWriter->m_lFlag & 0x04))//theme
pWriter->EndNode(_T("a:spPr"));
else
pWriter->EndNode(_T("p:spPr"));
}
pWriter->EndNode(name_);
}
virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const

View File

@ -195,12 +195,14 @@ namespace PPTX
virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const
{
std::wstring name_;
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX)
{
if (pWriter->m_lGroupIndex == 0) name_ = L"wpg:wgp";
else name_ = L"wpg:grpSp";
}
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX) name_ = L"xdr:grpSp";
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_GRAPHICS) name_ = L"a:grpSp";
else
{
if (pWriter->m_lGroupIndex == 0) name_ = L"p:spTree";
@ -212,7 +214,7 @@ namespace PPTX
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX)
{
nvGrpSpPr.cNvGrpSpPr.toXmlWriter2(_T("wpg"), pWriter);
nvGrpSpPr.cNvGrpSpPr.toXmlWriter2(L"wpg", pWriter);
}
else
nvGrpSpPr.toXmlWriter(pWriter);
@ -221,8 +223,7 @@ namespace PPTX
pWriter->m_lGroupIndex++;
size_t nCount = SpTreeElems.size();
for (size_t i = 0; i < nCount; ++i)
for (size_t i = 0; i < SpTreeElems.size(); ++i)
SpTreeElems[i].toXmlWriter(pWriter);
pWriter->m_lGroupIndex--;
@ -252,7 +253,10 @@ namespace PPTX
virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const
{
pWriter->StartRecord(SPTREE_TYPE_SPTREE);
if (getType() == OOX::et_lc_LockedCanvas)
pWriter->StartRecord(SPTREE_TYPE_LOCKED_CANVAS);
else
pWriter->StartRecord(SPTREE_TYPE_SPTREE);
pWriter->WriteRecord1(0, nvGrpSpPr);
pWriter->WriteRecord1(1, grpSpPr);
@ -263,7 +267,8 @@ namespace PPTX
virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader)
{
LONG _end_rec = pReader->GetPos() + pReader->GetLong() + 4;
pReader->Skip(5); // type SPTREE + len
pReader->Skip(5); //+ len
while (pReader->GetPos() < _end_rec)
{
@ -329,11 +334,166 @@ namespace PPTX
nvGrpSpPr.SetParentPointer(this);
grpSpPr.SetParentPointer(this);
size_t count = SpTreeElems.size();
for (size_t i = 0; i < count; ++i)
for (size_t i = 0; i < SpTreeElems.size(); ++i)
SpTreeElems[i].SetParentPointer(this);
}
};
class LockedCanvas : public SpTree
{
public:
WritingElement_AdditionConstructors(LockedCanvas)
LockedCanvas() : SpTree(L"a")
{
}
LockedCanvas& operator=(const LockedCanvas& oSrc)
{
parentFile = oSrc.parentFile;
parentElement = oSrc.parentElement;
nvGrpSpPr = oSrc.nvGrpSpPr;
grpSpPr = oSrc.grpSpPr;
for (size_t i=0; i < oSrc.SpTreeElems.size(); i++)
SpTreeElems.push_back(oSrc.SpTreeElems[i]);
m_lGroupIndex = oSrc.m_lGroupIndex;
return *this;
}
virtual OOX::EElementType getType () const
{
return OOX::et_lc_LockedCanvas;
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
SpTree::fromXML(oReader);
}
virtual void fromXML(XmlUtils::CXmlNode& node)
{
SpTree::fromXML(node);
}
virtual std::wstring toXML() const
{
XmlUtils::CAttribute oAttr;
oAttr.Write(L"xmlns:lc", L"http://schemas.openxmlformats.org/drawingml/2006/lockedCanvas");
XmlUtils::CNodeValue oValue;
oValue.Write(nvGrpSpPr);
oValue.Write(grpSpPr);
oValue.WriteArray(SpTreeElems);
return XmlUtils::CreateNode(L"lc:lockedCanvas", oAttr, oValue);
}
virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const
{
BYTE lDocType = pWriter->m_lDocType;
pWriter->m_lDocType = XMLWRITER_DOC_TYPE_GRAPHICS;
pWriter->StartNode(L"lc:lockedCanvas");
pWriter->StartAttributes();
pWriter->WriteAttribute(L"xmlns:lc", L"http://schemas.openxmlformats.org/drawingml/2006/lockedCanvas");
pWriter->EndAttributes();
nvGrpSpPr.toXmlWriter(pWriter);
grpSpPr.toXmlWriter(pWriter);
pWriter->m_lGroupIndex++;
for (size_t i = 0; i < SpTreeElems.size(); ++i)
{
SpTreeElems[i].toXmlWriter(pWriter);
}
pWriter->m_lGroupIndex--;
pWriter->EndNode(L"lc:lockedCanvas");
pWriter->m_lDocType = lDocType;
}
virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const
{
BinDocxRW::CDocxSerializer* docx = pWriter->m_pMainDocument;
pWriter->m_pMainDocument = NULL;
pWriter->StartRecord(SPTREE_TYPE_LOCKED_CANVAS);
pWriter->WriteRecord1(0, nvGrpSpPr);
pWriter->WriteRecord1(1, grpSpPr);
pWriter->WriteRecordArray(2, 0, SpTreeElems);
pWriter->EndRecord();
pWriter->m_pMainDocument = docx;
}
virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader)
{
LONG _end_rec = pReader->GetPos() + pReader->GetLong() + 4;
pReader->Skip(5); // type + len
BinDocxRW::CDocxSerializer* docx = pReader->m_pMainDocument;
pReader->m_pMainDocument = NULL;
while (pReader->GetPos() < _end_rec)
{
BYTE _at = pReader->GetUChar();
switch (_at)
{
case 0:
{
nvGrpSpPr.fromPPTY(pReader);
break;
}
case 1:
{
grpSpPr.fromPPTY(pReader);
break;
}
case 2:
{
pReader->Skip(4); // len
ULONG _c = pReader->GetULong();
for (ULONG i = 0; i < _c; ++i)
{
pReader->Skip(1); // type (0)
LONG nElemLength = pReader->GetLong(); // len
//SpTreeElem::fromPPTY сразу делает GetChar, а toPPTY ничего не пишет если не инициализирован
if(nElemLength > 0)
{
SpTreeElem elm;
elm.fromPPTY(pReader);
if (elm.is_init())
{
if (elm.getType() == OOX::et_p_ShapeTree)
{
smart_ptr<SpTree> e = elm.GetElem().smart_dynamic_cast<SpTree>();
e->m_lGroupIndex = m_lGroupIndex + 1;
}
SpTreeElems.push_back(elm);
}
}
}
}
default:
{
break;
}
}
}
pReader->Seek(_end_rec);
pReader->m_pMainDocument = docx;
}
};
} // namespace Logic
} // namespace PPTX

View File

@ -89,7 +89,7 @@ namespace PPTX
if (oBlip.blip.is_init() && oBlip.blip->embed.is_init())
{
std::wstring fopacity = _T("");
std::wstring fopacity;
size_t eff_count = oBlip.blip->Effects.size();
for (size_t eff = 0; eff < eff_count; ++eff)
{
@ -108,7 +108,7 @@ namespace PPTX
if (nA > 65536)
nA = 65536;
fopacity = _T(" opacity=\"") + std::to_wstring(nA) + _T("f\"");
fopacity = L" opacity=\"" + std::to_wstring(nA) + L"f\"";
}
break;
}
@ -118,28 +118,28 @@ namespace PPTX
if (bOle || bSignature)
{
strAttr = _T(" filled=\"f\"");
strNode = _T("<v:imagedata r:id=\"") + strId + _T("\" o:title=\"\" />");
strAttr = L" filled=\"f\"";
strNode = L"<v:imagedata r:id=\"" + strId + L"\" o:title=\"\" />";
}
else
{
if (oBlip.tile.is_init())
strNode = _T("<v:fill r:id=\"") + strId + _T("\" o:title=\"\" type=\"tile\"") + fopacity + _T(" />");
strNode = L"<v:fill r:id=\"" + strId + L"\" o:title=\"\" type=\"tile\"" + fopacity + L" />";
else
strNode = _T("<v:fill r:id=\"") + strId + _T("\" o:title=\"\" type=\"frame\"") + fopacity + _T(" />");
strNode = L"<v:fill r:id=\"" + strId + L"\" o:title=\"\" type=\"frame\"" + fopacity + L" />";
}
}
}
else if (fill.is<SolidFill>())
{
ARGB = fill.as<SolidFill>().Color.GetRGBColor(oTheme, oClrMap, ARGB);
strAttr = _T(" fillcolor=\"") + GetHexColor(ARGB) + _T("\"");
strAttr = L" fillcolor=\"" + GetHexColor(ARGB) + L"\"";
BYTE A = (BYTE)((ARGB >> 24) & 0xFF);
if (A != 255)
{
int fopacity = 100 - (int)(((double)A / 255.0) * 65536);
strNode = _T("<v:fill opacity=\"") + std::to_wstring(fopacity) + _T("f\" />");
strNode = L"<v:fill opacity=\"" + std::to_wstring(fopacity) + L"f\" />";
}
}
else if (fill.is<GradFill>())
@ -148,29 +148,29 @@ namespace PPTX
if (oGrad.GsLst.size() > 0)
{
ARGB = oGrad.GsLst[0].color.GetRGBColor(oTheme, oClrMap, ARGB);
strAttr = _T(" fillcolor=\"") + GetHexColor(ARGB) + _T("\"");
strAttr = L" fillcolor=\"" + GetHexColor(ARGB) + L"\"";
BYTE A = (BYTE)((ARGB >> 24) & 0xFF);
if (A != 255)
{
int fopacity = 100 - (int)(((double)A / 255.0) * 65536);
strNode = _T("<v:fill opacity=\"") + std::to_wstring(fopacity) + _T("f\" />");
strNode = L"<v:fill opacity=\"" + std::to_wstring(fopacity) + L"f\" />";
}
}
}
else if (fill.is<NoFill>() || !fill.is_init())
{
strAttr = _T(" filled=\"f\"");
strAttr = L" filled=\"f\"";
}
else
{
strAttr = _T(" fillcolor=\"") + GetHexColor(ARGB) + _T("\"");
strAttr = L" fillcolor=\"" + GetHexColor(ARGB) + L"\"";
BYTE A = (BYTE)((ARGB >> 24) & 0xFF);
if (A != 255)
{
int fopacity = (int)(((double)A / 255.0) * 65536);
strNode = _T("<v:fill opacity=\"") + std::to_wstring(fopacity) + _T("f\" />");
strNode = L"<v:fill opacity=\"" + std::to_wstring(fopacity) + L"f\" />";
}
}
@ -200,10 +200,10 @@ namespace PPTX
if (line.Fill.is<SolidFill>())
{
ARGB = line.Fill.as<SolidFill>().Color.GetRGBColor(oTheme, oClrMap, ARGB);
strAttr = _T(" strokecolor=\"") + GetHexColor(ARGB) + _T("\"");
strAttr = L" strokecolor=\"" + GetHexColor(ARGB) + L"\"";
}
else if (bOle || bSignature)
strAttr = _T(" stroked=\"f\"");
strAttr = L" stroked=\"f\"";
if (line.w.is_init())
{
@ -241,15 +241,17 @@ namespace PPTX
{
std::wstring name = XmlUtils::GetNameNoNS(oReader.GetName());
if (name == _T("sp") || name == _T("wsp"))
if (name == L"sp" || name == L"wsp")
m_elem.reset(new Logic::Shape(oReader));
else if (name == _T("pic"))
else if (name == L"pic")
m_elem.reset(new Logic::Pic(oReader));
else if (name == _T("cxnSp"))
else if (name == L"cxnSp")
m_elem.reset(new Logic::CxnSp(oReader));
else if (name == _T("grpSp") || name == _T("wgp") || name == _T("spTree") || name == _T("lockedCanvas") || name == _T("wpc"))
else if (name == L"lockedCanvas")
m_elem.reset(new Logic::LockedCanvas(oReader));
else if (name == L"grpSp" || name == L"wgp" || name == L"spTree" || name == L"wpc")
m_elem.reset(new Logic::SpTree(oReader));
else if (name == _T("graphicFrame"))
else if (name == L"graphicFrame")
{
Logic::GraphicFrame *pGraphic = new Logic::GraphicFrame(oReader);
@ -258,7 +260,7 @@ namespace PPTX
else
RELEASEOBJECT(pGraphic);
}
else if (name == _T("AlternateContent"))
else if (name == L"AlternateContent")
{
if ( oReader.IsEmptyNode() )
return;
@ -291,21 +293,23 @@ namespace PPTX
{
std::wstring name = XmlUtils::GetNameNoNS(node.GetName());
if (name == _T("sp") || name == _T("wsp"))
if (name == L"sp" || name == L"wsp")
m_elem.reset(new Logic::Shape(node));
else if (name == _T("pic"))
else if (name == L"pic")
m_elem.reset(new Logic::Pic(node));
else if (name == _T("cxnSp"))
else if (name == L"cxnSp")
m_elem.reset(new Logic::CxnSp(node));
else if (name == _T("grpSp") || name == _T("wgp") || name == _T("spTree") || name == _T("lockedCanvas") || name == _T("wpc"))
else if (name == L"lockedCanvas")
m_elem.reset(new Logic::LockedCanvas(node));
else if (name == L"grpSp" || name == L"wgp" || name == L"spTree" || name == L"wpc")
m_elem.reset(new Logic::SpTree(node));
else if (name == _T("graphicFrame"))
else if (name == L"graphicFrame")
m_elem.reset(new Logic::GraphicFrame(node));
else if (name == _T("AlternateContent"))
else if (name == L"AlternateContent")
{
bool isEmpty = true;
XmlUtils::CXmlNode oNodeChoice;
if (node.GetNode(_T("mc:Choice"), oNodeChoice))
if (node.GetNode(L"mc:Choice", oNodeChoice))
{
XmlUtils::CXmlNode oNodeFall;
XmlUtils::CXmlNodes oNodesC;
@ -313,11 +317,11 @@ namespace PPTX
//todo better check (a14 can be math, slicer)
if(oNodeChoice.GetAttributeIfExist(L"Requires", sRequires) && L"a14" == sRequires)
{
oNodeChoice.GetNodes(_T("*"), oNodesC);
oNodeChoice.GetNodes(L"*", oNodesC);
}
else if (node.GetNode(_T("mc:Fallback"), oNodeFall))
else if (node.GetNode(L"mc:Fallback", oNodeFall))
{
oNodeFall.GetNodes(_T("*"), oNodesC);
oNodeFall.GetNodes(L"*", oNodesC);
}
if (1 == oNodesC.GetCount())
{
@ -337,6 +341,30 @@ namespace PPTX
else m_elem.reset();
}
std::wstring SpTreeElem::GetUriElem()
{
if (m_elem.IsInit() == false)
{
return L"";
//return L"http://schemas.microsoft.com/office/word/2010/wordprocessingShape";
}
else if (m_elem->getType() == OOX::et_lc_LockedCanvas)
{
return L"http://schemas.openxmlformats.org/drawingml/2006/lockedCanvas";
}
else if (m_elem->getType() == OOX::et_p_ShapeTree)
{
return L"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup";
}
else if (m_elem->getType() == OOX::et_pic)
{
return L"http://schemas.openxmlformats.org/drawingml/2006/picture";
}
else
{
return L"http://schemas.microsoft.com/office/word/2010/wordprocessingShape";
}
}
void SpTreeElem::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader)
{
BYTE _type = pReader->GetUChar();
@ -347,9 +375,8 @@ namespace PPTX
{
Logic::Shape* p = new Logic::Shape();
p->fromPPTY(pReader);
m_elem.reset(p);
break;
}
m_elem.reset(p);
}break;
case SPTREE_TYPE_OLE:
case SPTREE_TYPE_PIC:
case SPTREE_TYPE_AUDIO:
@ -369,16 +396,27 @@ namespace PPTX
}
p->fromPPTY(pReader);
m_elem.reset(p);
break;
}
m_elem.reset(p);
}break;
case SPTREE_TYPE_CXNSP:
{
Logic::CxnSp* p = new Logic::CxnSp();
p->fromPPTY(pReader);
m_elem.reset(p);
break;
}
m_elem.reset(p);
}break;
case SPTREE_TYPE_LOCKED_CANVAS:
{
Logic::LockedCanvas* p = new Logic::LockedCanvas();
pReader->Seek(pReader->GetPos() - 5); // type back + len
p->fromPPTY(pReader);
if (getType() == OOX::et_lc_LockedCanvas)
{
smart_ptr<PPTX::Logic::LockedCanvas> parent = GetElem().smart_dynamic_cast<PPTX::Logic::LockedCanvas>();
p->m_lGroupIndex = parent->m_lGroupIndex + 1;
}
m_elem.reset(p);
}break;
case SPTREE_TYPE_SPTREE:
{
Logic::SpTree* p = new Logic::SpTree();
@ -390,23 +428,19 @@ namespace PPTX
smart_ptr<PPTX::Logic::SpTree> parent = GetElem().smart_dynamic_cast<PPTX::Logic::SpTree>();
p->m_lGroupIndex = parent->m_lGroupIndex + 1;
}
m_elem.reset(p);
break;
}
m_elem.reset(p);
}break;
case SPTREE_TYPE_GRFRAME:
{
Logic::GraphicFrame* pFrame = new Logic::GraphicFrame();
pFrame->fromPPTY(pReader);
m_elem.reset(pFrame);
break;
}
m_elem.reset(pFrame);
}break;
case SPTREE_TYPE_NONE:
{
pReader->SkipRecord();
break;
}
default:
break;
{
pReader->SkipRecord();
}break;
}
}
@ -414,7 +448,7 @@ namespace PPTX
{
if (m_elem.IsInit())
return m_elem->toXML();
return _T("");
return L"";
}
void SpTreeElem::toXmlWriterVML (NSBinPptxRW::CXmlWriter* pWriter, smart_ptr<PPTX::Theme>& oTheme, smart_ptr<PPTX::Logic::ClrMap>& oClrMap, const WCHAR* pId) const
@ -434,6 +468,7 @@ namespace PPTX
if (oPic.IsInit()) oPic->toXmlWriterVML(pWriter, oTheme, oClrMap, pId);
}break;
case OOX::et_p_ShapeTree:
case OOX::et_lc_LockedCanvas:
{
smart_ptr<PPTX::Logic::SpTree> oSpTree = m_elem.smart_dynamic_cast<PPTX::Logic::SpTree>();
if (oSpTree.IsInit()) oSpTree->toXmlWriterVML(pWriter, oTheme, oClrMap, pId);

View File

@ -71,8 +71,7 @@ namespace PPTX
{
m_elem = oSrc.m_elem;
return *this;
}
}
virtual void fromXML(XmlUtils::CXmlNode& node);
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader);
@ -88,6 +87,7 @@ namespace PPTX
m_elem.reset(pElem);
}
virtual void fromPPTY (NSBinPptxRW::CBinaryFileReader* pReader);
virtual void toPPTY (NSBinPptxRW::CBinaryFileWriter* pWriter) const
{
@ -100,7 +100,8 @@ namespace PPTX
if (m_elem.is_init())
m_elem->toXmlWriter(pWriter);
}
std::wstring GetUriElem();
smart_ptr<WrapperWritingElement> GetElem()
{
return m_elem;

View File

@ -82,6 +82,7 @@ namespace PPTX
}
void UniEffect::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader)
{
LONG pos = pReader->GetPos();
ULONG rec_len = pReader->GetULong();
if (0 == rec_len)
return;
@ -92,11 +93,43 @@ namespace PPTX
{
case EFFECT_TYPE_ALPHAMODFIX: Effect = new PPTX::Logic::AlphaModFix(); break;
case EFFECT_TYPE_DUOTONE: Effect = new PPTX::Logic::Duotone(); break;
case EFFECT_TYPE_OUTERSHDW: Effect = new PPTX::Logic::OuterShdw(); break;
case EFFECT_TYPE_GLOW: Effect = new PPTX::Logic::Glow(); break;
case EFFECT_TYPE_XFRM: Effect = new PPTX::Logic::XfrmEffect(); break;
case EFFECT_TYPE_BLUR: Effect = new PPTX::Logic::Blur(); break;
case EFFECT_TYPE_PRSTSHDW: Effect = new PPTX::Logic::PrstShdw(); break;
case EFFECT_TYPE_INNERSHDW: Effect = new PPTX::Logic::InnerShdw(); break;
case EFFECT_TYPE_REFLECTION: Effect = new PPTX::Logic::Reflection(); break;
case EFFECT_TYPE_SOFTEDGE: Effect = new PPTX::Logic::SoftEdge(); break;
case EFFECT_TYPE_FILLOVERLAY: Effect = new PPTX::Logic::FillOverlay(); break;
case EFFECT_TYPE_ALPHACEILING: Effect = new PPTX::Logic::AlphaCeiling(); break;
case EFFECT_TYPE_ALPHAFLOOR: Effect = new PPTX::Logic::AlphaFloor(); break;
case EFFECT_TYPE_TINTEFFECT: Effect = new PPTX::Logic::TintEffect(); break;
case EFFECT_TYPE_RELOFF: Effect = new PPTX::Logic::RelOff(); break;
case EFFECT_TYPE_LUM: Effect = new PPTX::Logic::LumEffect(); break;
case EFFECT_TYPE_HSL: Effect = new PPTX::Logic::HslEffect(); break;
case EFFECT_TYPE_GRAYSCL: Effect = new PPTX::Logic::Grayscl(); break;
case EFFECT_TYPE_ALPHAREPL: Effect = new PPTX::Logic::AlphaRepl(); break;
case EFFECT_TYPE_ALPHAOUTSET: Effect = new PPTX::Logic::AlphaOutset(); break;
case EFFECT_TYPE_ALPHABILEVEL: Effect = new PPTX::Logic::AlphaBiLevel(); break;
case EFFECT_TYPE_BILEVEL: Effect = new PPTX::Logic::BiLevel(); break;
case EFFECT_TYPE_FILL: Effect = new PPTX::Logic::FillEffect(); break;
case EFFECT_TYPE_CLRREPL: Effect = new PPTX::Logic::ClrRepl(); break;
case EFFECT_TYPE_CLRCHANGE: Effect = new PPTX::Logic::ClrChange(); break;
case EFFECT_TYPE_ALPHAINV: Effect = new PPTX::Logic::AlphaInv(); break;
case EFFECT_TYPE_ALPHAMOD: Effect = new PPTX::Logic::AlphaMod(); break;
case EFFECT_TYPE_BLEND: Effect = new PPTX::Logic::Blend(); break;
}
pReader->Seek(pos);
if (Effect.is_init())
{
Effect->fromPPTY(pReader);
}
else
{
pReader->SkipRecord();
}
}
UniEffect::UniEffect(XmlUtils::CXmlNode& node)
{

View File

@ -87,7 +87,6 @@ namespace PPTX
if(is_init())
Effect->SetParentPointer(pParent);
};
private:
smart_ptr<WrapperWritingElement> Effect;
protected:
virtual void FillParentPointersForChilds(){};

View File

@ -121,8 +121,6 @@ namespace PPTX
}
}
public:
smart_ptr<WrapperWritingElement> Fill;
enum Type {notInit, noFill, solidFill, gradFill, blipFill, pattFill, grpFill};
Type m_type;

View File

@ -140,7 +140,6 @@ namespace PPTX
template<class T> T& as() {return static_cast<T&>(*Path2D);}
template<class T> const T& as() const {return static_cast<const T&>(*Path2D);}
public:
smart_ptr<PathBase> Path2D;
protected:
virtual void FillParentPointersForChilds(){};

View File

@ -1094,11 +1094,10 @@ bool RtfParagraphPropsCommand::ExecuteCommand(RtfDocument& oDocument, RtfReader&
else
{
paragraphProps->m_bInTable = 1;
if ( PROP_DEF == paragraphProps->m_nItap )
if ( PROP_DEF == paragraphProps->m_nItap)
paragraphProps->m_nItap = 1;
}
}
COMMAND_RTF_BOOL( "intbl", paragraphProps->m_bInTable, sCommand, hasParameter, parameter )
else if ( "itap" == sCommand && hasParameter)
{
//if (parameter == 0 && paragraphProps->m_bInTable && paragraphProps->m_nItap > 0)
@ -2340,6 +2339,32 @@ bool RtfOldListReader::ExecuteCommand( RtfDocument& oDocument, RtfReader& oReade
return false;
return true;
}
void RtfParagraphPropDestination::EndRows(RtfReader& oReader)
{
RtfTableRowPtr oNewTableRow ( new RtfTableRow() );
oNewTableRow->m_oProperty = oReader.m_oState->m_oRowProperty;
for( int k = (int)aCells.size() - 1; k >= 0 ; k-- )
{
if ( aCellItaps[k] == nCurItap )
{
oNewTableRow->InsertItem( aCells[k], 0 );
aCells.erase(aCells.begin() + k);
aCellItaps.erase(aCellItaps.begin() + k);
}
else
break;
}
//для каждого cell в row добавляем их свойства
for( int i = 0; i < oNewTableRow->GetCount() && i < oNewTableRow->m_oProperty.GetCount() ; i++ )
{
oNewTableRow->operator [](i)->m_oProperty = oNewTableRow->m_oProperty[i];
}
//Добавляем временный row
aRows.push_back( oNewTableRow );
aRowItaps.push_back( nCurItap );
}
//-------------------------------------------------------------------------------------------------------------------------------------------
void RtfParagraphPropDestination::AddItem( RtfParagraphPtr oItem, RtfReader& oReader, bool bEndCell, bool bEndRow )
@ -2351,6 +2376,8 @@ void RtfParagraphPropDestination::AddItem( RtfParagraphPtr oItem, RtfReader& oRe
{
if ( nCurItap > 0 ) //Если до этого были только параграфы в таблицах - завершаем таблицу
{
if (bEndRow) EndRows(oReader); //ê¡ñ¿ó¿ñπá½∞¡á∩ »α«úαá¼¼á.rtf
RtfTablePtr oNewTable ( new RtfTable() );
oNewTable->m_oProperty = oCurRowProperty;
@ -2416,30 +2443,10 @@ void RtfParagraphPropDestination::AddItem( RtfParagraphPtr oItem, RtfReader& oRe
aItaps.push_back( oItem->m_oProperty.m_nItap );
}
nCurItap = oItem->m_oProperty.m_nItap;
//закончилась строка
if ( bEndRow )
{
RtfTableRowPtr oNewTableRow ( new RtfTableRow() );
oNewTableRow->m_oProperty = oReader.m_oState->m_oRowProperty;
for( int k = (int)aCells.size() - 1; k >= 0 ; k-- )
{
if ( aCellItaps[k] == nCurItap )
{
oNewTableRow->InsertItem( aCells[k], 0 );
aCells.erase(aCells.begin() + k);
aCellItaps.erase(aCellItaps.begin() + k);
}
else
break;
}
//для каждого cell в row добавляем их свойства
for( int i = 0; i < (int)oNewTableRow->GetCount() && i < oNewTableRow->m_oProperty.GetCount() ; i++ )
oNewTableRow->operator [](i)->m_oProperty = oNewTableRow->m_oProperty[i];
//Добавляем временный row
aRows.push_back( oNewTableRow );
aRowItaps.push_back( nCurItap );
EndRows(oReader);
}
else
{

View File

@ -1656,6 +1656,7 @@ public:
void Finalize( RtfReader& oReader);
void EndRows(RtfReader& oReader);
void ExecuteNumberChar( RtfDocument& oDocument, RtfReader& oReader, RtfAbstractReader& oAbstrReader, int nWinChar, int nMacChar )
{
RtfFont oFont;

View File

@ -42,7 +42,8 @@ int OOXGraphicReader::Parse( ReaderParameter oParam , RtfShapePtr & pOutput)
if (m_ooxGraphic->element.is_init())
{
if (m_ooxGraphic->element.getType() == OOX::et_p_ShapeTree)
if (m_ooxGraphic->element.getType() == OOX::et_p_ShapeTree ||
m_ooxGraphic->element.getType() == OOX::et_lc_LockedCanvas)
{
OOXShapeGroupReader groupReader(dynamic_cast<PPTX::Logic::SpTree*>(m_ooxGraphic->element.GetElem().operator->()));
return (groupReader.Parse(oParam, pOutput) ? 1 : 0);

View File

@ -1924,7 +1924,8 @@ bool OOXShapeGroupReader::Parse( ReaderParameter oParam , RtfShapePtr& pOutput)
for (size_t i = 0; i < m_ooxGroup->SpTreeElems.size() ; i++ )
{
if (m_ooxGroup->SpTreeElems[i].getType() == OOX::et_p_ShapeTree)
if (m_ooxGroup->SpTreeElems[i].getType() == OOX::et_p_ShapeTree ||
m_ooxGroup->SpTreeElems[i].getType() == OOX::et_lc_LockedCanvas)
{
RtfShapePtr pNewShape( new RtfShape() );
pNewShape->m_bIsGroup = true;

View File

@ -704,7 +704,7 @@ namespace ComplexTypes
std::wstring sResult;
if ( m_sVal.IsInit() )
sResult += XmlUtils::EncodeXmlString(m_sVal.get(), false);
sResult += m_sVal.get();
return sResult;
}

View File

@ -4106,10 +4106,16 @@ namespace SimpleTypes
void ReadValue_Rotation(std::wstring& sValue)
{
m_oValue.dValue = sValue.empty() ? 0 : _wtof(sValue.c_str() );
m_oValue.dValue = sValue.empty() ? 0 : _wtof(sValue.c_str() );
if (sValue.find(_T("fd")) != -1)
m_oValue.dValue /= 6000;
if (sValue.find(_T("fd")) != std::wstring::npos)
{
m_oValue.dValue /= 6000.;
}
else if (sValue.find(_T("f")) == sValue.length() - 1)
{
m_oValue.dValue /= 65536.;
}
}
void ReadValue_Double(std::wstring& sValue)

View File

@ -357,6 +357,8 @@ namespace OOX
et_dsp_cNvPr,
et_dsp_txXfrm,
et_lc_LockedCanvas, // <lc:lockedCanvas>
et_graphicFrame, // <...:graphicFrame>
et_pic, // <...:pic>
et_cxnSp, // <...:cxnSp>

View File

@ -1 +1 @@
2.4.550.0
2.4.551.0

View File

@ -764,6 +764,8 @@
#define ASC_MENU_EVENT_TYPE_COLOR_SCHEMES 2404 // CAscColorSchemes
#define ASC_MENU_EVENT_TYPE_CHANGE_COLOR_SCHEME 2415 // SET(int)
#define ASC_MENU_EVENT_TYPE_GO_TO_INTERNAL_LINK 5000
#define ASC_SOCKET_EVENT_TYPE_OPEN 10000
#define ASC_SOCKET_EVENT_TYPE_ON_CLOSE 10010
#define ASC_SOCKET_EVENT_TYPE_MESSAGE 10020

View File

@ -618,6 +618,12 @@ namespace Aggplus
c_c_path.approximation_method(agg::curve_inc);
DashStyle eStyle = (DashStyle)pPen->DashStyle;
if (DashStyleCustom == eStyle)
{
if (0 == pPen->Count)
eStyle = DashStyleSolid;
}
agg::trans_affine* pAffine = &m_oFullTransform.m_internal->m_agg_mtx;
if (m_bIntegerGrid)
pAffine = new agg::trans_affine();

View File

@ -51,6 +51,9 @@ namespace NSOnlineOfficeBinToPdf
int m_nRasterW;
int m_nRasterH;
double m_dDpiX;
double m_dDpiY;
std::vector<std::wstring> m_arTempFiles;
public:
@ -70,6 +73,9 @@ namespace NSOnlineOfficeBinToPdf
m_nRasterW = 100;
m_nRasterH = 100;
m_dDpiX = 96.0;
m_dDpiY = 96.0;
}
~CMetafileToRenderterRaster_private()
@ -228,6 +234,14 @@ namespace NSOnlineOfficeBinToPdf
nRasterW = (int)(w * dKoef1 + 0.5);
nRasterH = (int)(h * dKoef1 + 0.5);
}
else if (2 == m_internal->m_nSaveType)
{
double w = oInfo.arSizes[nPageIndex].width;
double h = oInfo.arSizes[nPageIndex].height;
nRasterW = (int)((w * m_internal->m_dDpiX / 25.4) + 0.5);
nRasterH = (int)((h * m_internal->m_dDpiY / 25.4) + 0.5);
}
oFrame.put_Width(nRasterW);
oFrame.put_Height(nRasterH);
@ -347,4 +361,9 @@ namespace NSOnlineOfficeBinToPdf
{
m_internal->m_bIsOnlyFirst = value;
}
void CMetafileToRenderterRaster::SetOutputDpi(const double& dDpiX, const double& dDpiY)
{
m_internal->m_dDpiX = dDpiX;
m_internal->m_dDpiY = dDpiY;
}
}

View File

@ -81,6 +81,8 @@ namespace NSOnlineOfficeBinToPdf
bool GetIsOnlyFirst();
void SetIsOnlyFirst(const bool& value);
void SetOutputDpi(const double& dDpiX, const double& dDpiY);
};
}

View File

@ -60,9 +60,12 @@ core_windows {
LIB_GRAPHICS_PRI_PATH = $$PWD/../..
FREETYPE_VERSION=2.5.2
INCLUDEPATH += \
$$LIB_GRAPHICS_PRI_PATH/agg-2.4/include \
$$LIB_GRAPHICS_PRI_PATH/freetype-2.5.2/include \
$$LIB_GRAPHICS_PRI_PATH/freetype-$$FREETYPE_VERSION/include \
$$LIB_GRAPHICS_PRI_PATH/freetype-$$FREETYPE_VERSION/include/freetype \
$$LIB_GRAPHICS_PRI_PATH/cximage/jasper/include \
$$LIB_GRAPHICS_PRI_PATH/cximage/jpeg \
$$LIB_GRAPHICS_PRI_PATH/cximage/png \
@ -134,45 +137,46 @@ SOURCES += \
SOURCES += $$PWD/graphics_pri.cpp
SOURCES += $$LIB_GRAPHICS_PRI_PATH/freetype-2.5.2/src/base/ftbbox.c \
$$LIB_GRAPHICS_PRI_PATH/freetype-2.5.2/src/base/ftgxval.c \
$$LIB_GRAPHICS_PRI_PATH/freetype-2.5.2/src/base/ftlcdfil.c \
$$LIB_GRAPHICS_PRI_PATH/freetype-2.5.2/src/base/ftmm.c \
$$LIB_GRAPHICS_PRI_PATH/freetype-2.5.2/src/base/ftotval.c \
$$LIB_GRAPHICS_PRI_PATH/freetype-2.5.2/src/base/ftpatent.c \
$$LIB_GRAPHICS_PRI_PATH/freetype-2.5.2/src/base/ftpfr.c \
$$LIB_GRAPHICS_PRI_PATH/freetype-2.5.2/src/base/ftsynth.c \
$$LIB_GRAPHICS_PRI_PATH/freetype-2.5.2/src/base/fttype1.c \
$$LIB_GRAPHICS_PRI_PATH/freetype-2.5.2/src/base/ftwinfnt.c \
$$LIB_GRAPHICS_PRI_PATH/freetype-2.5.2/src/base/ftxf86.c \
$$LIB_GRAPHICS_PRI_PATH/freetype-2.5.2/src/pcf/pcf.c \
$$LIB_GRAPHICS_PRI_PATH/freetype-2.5.2/src/pfr/pfr.c \
$$LIB_GRAPHICS_PRI_PATH/freetype-2.5.2/src/psaux/psaux.c \
$$LIB_GRAPHICS_PRI_PATH/freetype-2.5.2/src/pshinter/pshinter.c \
$$LIB_GRAPHICS_PRI_PATH/freetype-2.5.2/src/psnames/psmodule.c \
$$LIB_GRAPHICS_PRI_PATH/freetype-2.5.2/src/raster/raster.c \
$$LIB_GRAPHICS_PRI_PATH/freetype-2.5.2/src/sfnt/sfnt.c \
$$LIB_GRAPHICS_PRI_PATH/freetype-2.5.2/src/truetype/truetype.c \
$$LIB_GRAPHICS_PRI_PATH/freetype-2.5.2/src/type1/type1.c \
$$LIB_GRAPHICS_PRI_PATH/freetype-2.5.2/src/cid/type1cid.c \
$$LIB_GRAPHICS_PRI_PATH/freetype-2.5.2/src/type42/type42.c \
$$LIB_GRAPHICS_PRI_PATH/freetype-2.5.2/src/winfonts/winfnt.c \
SOURCES += \
$$LIB_GRAPHICS_PRI_PATH/freetype-$$FREETYPE_VERSION/src/base/ftbbox.c \
$$LIB_GRAPHICS_PRI_PATH/freetype-$$FREETYPE_VERSION/src/base/ftgxval.c \
$$LIB_GRAPHICS_PRI_PATH/freetype-$$FREETYPE_VERSION/src/base/ftlcdfil.c \
$$LIB_GRAPHICS_PRI_PATH/freetype-$$FREETYPE_VERSION/src/base/ftmm.c \
$$LIB_GRAPHICS_PRI_PATH/freetype-$$FREETYPE_VERSION/src/base/ftotval.c \
$$LIB_GRAPHICS_PRI_PATH/freetype-$$FREETYPE_VERSION/src/base/ftpatent.c \
$$LIB_GRAPHICS_PRI_PATH/freetype-$$FREETYPE_VERSION/src/base/ftpfr.c \
$$LIB_GRAPHICS_PRI_PATH/freetype-$$FREETYPE_VERSION/src/base/ftsynth.c \
$$LIB_GRAPHICS_PRI_PATH/freetype-$$FREETYPE_VERSION/src/base/fttype1.c \
$$LIB_GRAPHICS_PRI_PATH/freetype-$$FREETYPE_VERSION/src/base/ftwinfnt.c \
$$LIB_GRAPHICS_PRI_PATH/freetype-$$FREETYPE_VERSION/src/base/ftxf86.c \
$$LIB_GRAPHICS_PRI_PATH/freetype-$$FREETYPE_VERSION/src/pcf/pcf.c \
$$LIB_GRAPHICS_PRI_PATH/freetype-$$FREETYPE_VERSION/src/pfr/pfr.c \
$$LIB_GRAPHICS_PRI_PATH/freetype-$$FREETYPE_VERSION/src/psaux/psaux.c \
$$LIB_GRAPHICS_PRI_PATH/freetype-$$FREETYPE_VERSION/src/pshinter/pshinter.c \
$$LIB_GRAPHICS_PRI_PATH/freetype-$$FREETYPE_VERSION/src/psnames/psmodule.c \
$$LIB_GRAPHICS_PRI_PATH/freetype-$$FREETYPE_VERSION/src/raster/raster.c \
$$LIB_GRAPHICS_PRI_PATH/freetype-$$FREETYPE_VERSION/src/sfnt/sfnt.c \
$$LIB_GRAPHICS_PRI_PATH/freetype-$$FREETYPE_VERSION/src/truetype/truetype.c \
$$LIB_GRAPHICS_PRI_PATH/freetype-$$FREETYPE_VERSION/src/type1/type1.c \
$$LIB_GRAPHICS_PRI_PATH/freetype-$$FREETYPE_VERSION/src/cid/type1cid.c \
$$LIB_GRAPHICS_PRI_PATH/freetype-$$FREETYPE_VERSION/src/type42/type42.c \
$$LIB_GRAPHICS_PRI_PATH/freetype-$$FREETYPE_VERSION/src/winfonts/winfnt.c \
\
$$LIB_GRAPHICS_PRI_PATH/freetype-2.5.2/src/autofit/autofit.c \
$$LIB_GRAPHICS_PRI_PATH/freetype-2.5.2/src/bdf/bdf.c \
$$LIB_GRAPHICS_PRI_PATH/freetype-2.5.2/src/cff/cff.c \
$$LIB_GRAPHICS_PRI_PATH/freetype-2.5.2/src/base/ftbase.c \
$$LIB_GRAPHICS_PRI_PATH/freetype-2.5.2/src/base/ftbitmap.c \
$$LIB_GRAPHICS_PRI_PATH/freetype-2.5.2/src/cache/ftcache.c \
$$LIB_GRAPHICS_PRI_PATH/freetype-2.5.2/src/base/ftfstype.c \
$$LIB_GRAPHICS_PRI_PATH/freetype-2.5.2/src/base/ftgasp.c \
$$LIB_GRAPHICS_PRI_PATH/freetype-2.5.2/src/base/ftglyph.c \
$$LIB_GRAPHICS_PRI_PATH/freetype-2.5.2/src/gzip/ftgzip.c \
$$LIB_GRAPHICS_PRI_PATH/freetype-2.5.2/src/base/ftinit.c \
$$LIB_GRAPHICS_PRI_PATH/freetype-2.5.2/src/lzw/ftlzw.c \
$$LIB_GRAPHICS_PRI_PATH/freetype-2.5.2/src/base/ftstroke.c \
$$LIB_GRAPHICS_PRI_PATH/freetype-2.5.2/src/base/ftsystem.c \
$$LIB_GRAPHICS_PRI_PATH/freetype-2.5.2/src/smooth/smooth.c
$$LIB_GRAPHICS_PRI_PATH/freetype-$$FREETYPE_VERSION/src/autofit/autofit.c \
$$LIB_GRAPHICS_PRI_PATH/freetype-$$FREETYPE_VERSION/src/bdf/bdf.c \
$$LIB_GRAPHICS_PRI_PATH/freetype-$$FREETYPE_VERSION/src/cff/cff.c \
$$LIB_GRAPHICS_PRI_PATH/freetype-$$FREETYPE_VERSION/src/base/ftbase.c \
$$LIB_GRAPHICS_PRI_PATH/freetype-$$FREETYPE_VERSION/src/base/ftbitmap.c \
$$LIB_GRAPHICS_PRI_PATH/freetype-$$FREETYPE_VERSION/src/cache/ftcache.c \
$$LIB_GRAPHICS_PRI_PATH/freetype-$$FREETYPE_VERSION/src/base/ftfstype.c \
$$LIB_GRAPHICS_PRI_PATH/freetype-$$FREETYPE_VERSION/src/base/ftgasp.c \
$$LIB_GRAPHICS_PRI_PATH/freetype-$$FREETYPE_VERSION/src/base/ftglyph.c \
$$LIB_GRAPHICS_PRI_PATH/freetype-$$FREETYPE_VERSION/src/gzip/ftgzip.c \
$$LIB_GRAPHICS_PRI_PATH/freetype-$$FREETYPE_VERSION/src/base/ftinit.c \
$$LIB_GRAPHICS_PRI_PATH/freetype-$$FREETYPE_VERSION/src/lzw/ftlzw.c \
$$LIB_GRAPHICS_PRI_PATH/freetype-$$FREETYPE_VERSION/src/base/ftstroke.c \
$$LIB_GRAPHICS_PRI_PATH/freetype-$$FREETYPE_VERSION/src/base/ftsystem.c \
$$LIB_GRAPHICS_PRI_PATH/freetype-$$FREETYPE_VERSION/src/smooth/smooth.c
SOURCES += \
$$LIB_GRAPHICS_PRI_PATH/cximage/jasper/base/jas_cm.c \

View File

@ -450,7 +450,7 @@ namespace NSHtmlRenderer
m_oCurrentInfo.m_lAscent = (USHORT)(lA);
m_oCurrentInfo.m_lDescent = (USHORT)(lD);
m_oCurrentInfo.m_lLineHeight = (USHORT)(lL);
m_oCurrentInfo.m_lUnitsPerEm = (USHORT)(lD);
m_oCurrentInfo.m_lUnitsPerEm = (USHORT)(lU);
}
};

View File

@ -1143,6 +1143,8 @@ namespace NSHtmlRenderer
int symbolsCount = 0;
oCur.GenerateArray(symbols, symbolsCount);
// есть проблема с композитными глифами (буква ё). пока отключу конвертацию
lFontConverterFlag = 0;
oFontConverter.ToOTF(oCur.m_strFontPath, strTempFont, (unsigned int*)symbols, symbolsCount, sName, lFontConverterFlag); // TRUETYPE only
RELEASEARRAYOBJECTS(symbols);

View File

@ -130,7 +130,7 @@ namespace PdfReader
// Выделяем память и копируем туда строку.
static char *CopyString(char *sString)
{
char *sResult = (char *)MemUtilsMalloc(strlen(sString) + 1);
char *sResult = (char *)MemUtilsMalloc((int)strlen(sString) + 1);
strcpy(sResult, sString);
return sResult;
}

View File

@ -73,11 +73,11 @@ namespace PdfReader
static std::wstring* AStringToPWString(const char* sString)
{
return new std::wstring(NSStringExt::CConverter::GetUnicodeFromSingleByteString((unsigned char*)sString, strlen(sString)));
return new std::wstring(NSStringExt::CConverter::GetUnicodeFromSingleByteString((unsigned char*)sString, (long)strlen(sString)));
}
static std::wstring AStringToWString(const char* sString)
{
return std::wstring(NSStringExt::CConverter::GetUnicodeFromSingleByteString((unsigned char*)sString, strlen(sString)));
return std::wstring(NSStringExt::CConverter::GetUnicodeFromSingleByteString((unsigned char*)sString, (long)strlen(sString)));
}

View File

@ -0,0 +1,19 @@
TEMPLATE = app
CONFIG += console c++11
CONFIG -= app_bundle
CONFIG -= qt
SOURCES += \
$$PWD/../../../../core/Common/OfficeFileFormatChecker2.cpp \
$$PWD/../../../../core/Common/3dParty/pole/pole.cpp \
$$PWD/../../../../core/Common/DocxFormat/Source/Base/unicode_util.cpp
SOURCES += main.cpp
CORE_ROOT_DIR = $$PWD/../../../../core
PWD_ROOT_DIR = $$PWD
include($$PWD/../../../Common/base.pri)
LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -lkernel -lgraphics
DESTDIR = $$PWD/build

View File

@ -0,0 +1,801 @@
#include <iostream>
#include "../../../Common/OfficeFileFormats.h"
#include "../../../Common/OfficeFileFormatChecker.h"
#include "../../../DesktopEditor/graphics/Timer.h"
#include "../../../DesktopEditor/graphics/TemporaryCS.h"
#include "../../../DesktopEditor/common/File.h"
#include "../../../DesktopEditor/common/Directory.h"
#include "../../../DesktopEditor/common/StringBuilder.h"
#include "../../../OfficeUtils/src/OfficeUtils.h"
#include "../../../DesktopEditor/fontengine/application_generate_fonts.h"
class CConverter;
class CInternalWorker
{
public:
std::map<int, bool> m_formats;
std::vector<std::wstring> m_files;
int m_nCount;
int m_nCurrent;
int m_nCurrentComplete;
std::wstring m_sInputFolder;
std::wstring m_sOutputFolder;
bool m_bIsStandard;
NSCriticalSection::CRITICAL_SECTION m_oCS;
NSCriticalSection::CRITICAL_SECTION m_oCS_OfficeUtils;
public:
CInternalWorker()
{
m_formats.insert(std::make_pair<int, bool>(AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX, true));
m_formats.insert(std::make_pair<int, bool>(AVS_OFFICESTUDIO_FILE_DOCUMENT_DOC, true));
m_formats.insert(std::make_pair<int, bool>(AVS_OFFICESTUDIO_FILE_DOCUMENT_ODT, true));
m_formats.insert(std::make_pair<int, bool>(AVS_OFFICESTUDIO_FILE_DOCUMENT_RTF, true));
m_formats.insert(std::make_pair<int, bool>(AVS_OFFICESTUDIO_FILE_DOCUMENT_TXT, true));
m_formats.insert(std::make_pair<int, bool>(AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTX, true));
m_formats.insert(std::make_pair<int, bool>(AVS_OFFICESTUDIO_FILE_PRESENTATION_PPSX, true));
m_formats.insert(std::make_pair<int, bool>(AVS_OFFICESTUDIO_FILE_PRESENTATION_PPT, true));
m_formats.insert(std::make_pair<int, bool>(AVS_OFFICESTUDIO_FILE_PRESENTATION_ODP, true));
m_formats.insert(std::make_pair<int, bool>(AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX, true));
m_formats.insert(std::make_pair<int, bool>(AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLS, true));
m_formats.insert(std::make_pair<int, bool>(AVS_OFFICESTUDIO_FILE_SPREADSHEET_ODS, true));
m_formats.insert(std::make_pair<int, bool>(AVS_OFFICESTUDIO_FILE_SPREADSHEET_CSV, true));
m_nCount = 0;
m_nCurrent = 0;
m_nCurrentComplete = 0;
m_oCS.InitializeCriticalSection();
m_oCS_OfficeUtils.InitializeCriticalSection();
}
~CInternalWorker()
{
m_oCS.DeleteCriticalSection();
m_oCS_OfficeUtils.DeleteCriticalSection();
}
CConverter* GetNextConverter();
void OnConvertFile(CConverter* pConverter, int nCode);
void Start(int nCores);
void Cancel();
void OpenDir(std::wstring sDir)
{
m_sInputFolder = sDir;
std::vector<std::wstring> arFiles = NSDirectory::GetFiles(sDir, true);
for (std::vector<std::wstring>::iterator iter = arFiles.begin(); iter != arFiles.end(); iter++)
{
std::wstring sExt = NSFile::GetFileExtention(*iter);
if (sExt == L"docx" || sExt == L"pptx" || sExt == L"xlsx")
m_files.push_back(*iter);
}
m_nCount = (int)m_files.size();
}
bool IsWork()
{
CTemporaryCS oCS(&m_oCS);
return (m_nCurrentComplete < m_nCount);
}
};
namespace NSX2T
{
int Convert(const std::wstring& sConverterPath, const std::wstring sXmlPath)
{
int nReturnCode = 0;
std::wstring sConverterExe = sConverterPath;
#ifdef WIN32
NSCommon::string_replace(sConverterExe, L"/", L"\\");
sConverterExe += L".exe";
std::wstring sApp = L"x2t ";
STARTUPINFO sturtupinfo;
ZeroMemory(&sturtupinfo,sizeof(STARTUPINFO));
sturtupinfo.cb = sizeof(STARTUPINFO);
sApp += (L"\"" + sXmlPath + L"\"");
wchar_t* pCommandLine = NULL;
if (true)
{
pCommandLine = new wchar_t[sApp.length() + 1];
memcpy(pCommandLine, sApp.c_str(), sApp.length() * sizeof(wchar_t));
pCommandLine[sApp.length()] = (wchar_t)'\0';
}
HANDLE ghJob = CreateJobObject(NULL, NULL);
if (ghJob)
{
JOBOBJECT_EXTENDED_LIMIT_INFORMATION jeli = { 0 };
// Configure all child processes associated with the job to terminate when the
jeli.BasicLimitInformation.LimitFlags = JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE;
if ( 0 == SetInformationJobObject( ghJob, JobObjectExtendedLimitInformation, &jeli, sizeof(jeli)))
{
CloseHandle(ghJob);
ghJob = NULL;
}
}
PROCESS_INFORMATION processinfo;
ZeroMemory(&processinfo,sizeof(PROCESS_INFORMATION));
BOOL bResult = CreateProcessW(sConverterExe.c_str(), pCommandLine,
NULL, NULL, TRUE, CREATE_NO_WINDOW, NULL, NULL, &sturtupinfo, &processinfo);
if (bResult && ghJob)
{
AssignProcessToJobObject(ghJob, processinfo.hProcess);
}
::WaitForSingleObject(processinfo.hProcess, INFINITE);
RELEASEARRAYOBJECTS(pCommandLine);
//get exit code
DWORD dwExitCode = 0;
if (GetExitCodeProcess(processinfo.hProcess, &dwExitCode))
{
nReturnCode = (int)dwExitCode;
}
CloseHandle(processinfo.hProcess);
CloseHandle(processinfo.hThread);
if (ghJob)
{
CloseHandle(ghJob);
ghJob = NULL;
}
#endif
#ifdef LINUX
pid_t pid = fork(); // create child process
int status;
std::string sProgramm = U_TO_UTF8(sConverterExe);
std::string sXmlA = U_TO_UTF8(sXmlPath);
switch (pid)
{
case -1: // error
break;
case 0: // child process
{
std::string sLibraryDir = sProgramm;
std::string sPATH = sProgramm;
if (std::string::npos != sProgramm.find_last_of('/'))
{
sLibraryDir = "LD_LIBRARY_PATH=" + sProgramm.substr(0, sProgramm.find_last_of('/'));
sPATH = "PATH=" + sProgramm.substr(0, sProgramm.find_last_of('/'));
}
#ifdef _MAC
sLibraryDir = "DY" + sLibraryDir;
#endif
const char* nargs[3];
nargs[0] = sProgramm.c_str();
nargs[1] = sXmlA.c_str();
nargs[2] = NULL;
#ifndef _MAC
const char* nenv[2];
nenv[0] = sLibraryDir.c_str();
nenv[1] = NULL;
#else
const char* nenv[3];
nenv[0] = sLibraryDir.c_str();
nenv[1] = sPATH.c_str();
nenv[2] = NULL;
#endif
execve(sProgramm.c_str(),
(char * const *)nargs,
(char * const *)nenv);
exit(EXIT_SUCCESS);
break;
}
default: // parent process, pid now contains the child pid
while (-1 == waitpid(pid, &status, 0)); // wait for child to complete
if (WIFEXITED(status))
{
nReturnCode = WEXITSTATUS(status);
}
break;
}
#endif
return nReturnCode;
}
}
class CConverter : public NSThreads::CBaseThread
{
public:
CInternalWorker* m_pInternal;
std::wstring m_file;
std::wstring m_folder_dst;
int m_format;
public:
CConverter(CInternalWorker* pWorker) : NSThreads::CBaseThread()
{
m_pInternal = pWorker;
}
virtual ~CConverter()
{
Stop();
}
virtual DWORD ThreadProc()
{
COfficeFileFormatChecker oChecker;
if (!oChecker.isOfficeFile(m_file))
{
m_bRunThread = FALSE;
m_pInternal->OnConvertFile(this, -1);
return 0;
}
m_format = oChecker.nFileType;
#if 0
std::map<int, bool>::iterator find = m_pInternal->m_formats.find(m_format);
if ((find == m_pInternal->m_formats.end()) || (find->second == false))
{
m_bRunThread = FALSE;
m_pInternal->OnConvertFile(this, -1);
return 0;
}
#endif
std::wstring sProcess = NSFile::GetProcessDirectory();
NSCommon::string_replace(sProcess, L"\\", L"/");
NSCommon::string_replace(m_file, L"\\", L"/");
std::wstring sDirectoryDst = m_folder_dst;
NSCommon::string_replace(sDirectoryDst, L"\\", L"/");
#ifdef WIN32
NSCommon::string_replace(m_file, L"//", L"\\\\");
#endif
NSDirectory::CreateDirectory(sDirectoryDst);
NSStringUtils::CStringBuilder oBuilder;
oBuilder.WriteString(L"<?xml version=\"1.0\" encoding=\"utf-8\"?><TaskQueueDataConvert><m_sFileFrom>");
std::wstring sFileDst = sDirectoryDst + L"/page.zip";
oBuilder.WriteEncodeXmlString(m_file);
oBuilder.WriteString(L"</m_sFileFrom><m_sFileTo>");
oBuilder.WriteEncodeXmlString(sFileDst);
oBuilder.WriteString(L"</m_sFileTo><m_nFormatTo>");
oBuilder.WriteString(std::to_wstring(AVS_OFFICESTUDIO_FILE_IMAGE));
oBuilder.WriteString(L"</m_nFormatTo><m_sThemeDir>./</m_sThemeDir><m_bDontSaveAdditional>true</m_bDontSaveAdditional><m_sAllFontsPath>");
oBuilder.WriteString(sProcess + L"/fonts");
oBuilder.WriteString(L"/AllFonts.js</m_sAllFontsPath><m_nCsvTxtEncoding>46</m_nCsvTxtEncoding><m_nCsvDelimiter>4</m_nCsvDelimiter>");
oBuilder.WriteString(L"<m_sFontDir>");
oBuilder.WriteEncodeXmlString(sProcess + L"/fonts");
oBuilder.WriteString(L"</m_sFontDir>");
oBuilder.WriteString(L"<m_oThumbnail><format>4</format><aspect>2</aspect><first>false</first><width>1000</width><height>1000</height></m_oThumbnail>");
oBuilder.WriteString(L"</TaskQueueDataConvert>");
std::wstring sXmlConvert = oBuilder.GetData();
std::wstring sTempFileForParams = sDirectoryDst + L"/params.xml";
NSFile::CFileBinary::SaveToFile(sTempFileForParams, sXmlConvert, true);
if (NSDirectory::Exists(sProcess + L"/converter"))
sProcess += L"/converter";
std::wstring sExe = sProcess + L"/x2t";
int nReturnCode = NSX2T::Convert(sExe, sTempFileForParams);
NSFile::CFileBinary::Remove(sTempFileForParams);
if (0 == nReturnCode)
{
CTemporaryCS oCS(&m_pInternal->m_oCS_OfficeUtils);
COfficeUtils oUtils;
if (S_OK == oUtils.ExtractToDirectory(sFileDst, sDirectoryDst, NULL, 0))
NSFile::CFileBinary::Remove(sFileDst);
}
if (!m_pInternal->m_bIsStandard)
{
// смотрим разницу
std::wstring strDirIn = NSFile::GetDirectoryName(m_file);
std::wstring strDirOut = sDirectoryDst;
std::wstring strDiffsMain = NSFile::GetDirectoryName(strDirOut) + L"/DIFF";
std::wstring strDiffs = strDiffsMain + L"/" + NSFile::GetFileName(m_file);
int nCountInPages = GetPagesCount(strDirIn);
int nCountOutPages = GetPagesCount(strDirOut);
if (nCountInPages != nCountOutPages)
{
if (!NSDirectory::Exists(strDiffsMain))
NSDirectory::CreateDirectory(strDiffsMain);
if (!NSDirectory::Exists(strDiffs))
NSDirectory::CreateDirectory(strDiffs);
if (nCountInPages > nCountOutPages)
nCountInPages = nCountOutPages;
std::wstring sFilePagesDiff = strDiffs + L"/pages_count";
NSFile::CFileBinary oFile;
oFile.CreateFileW(sFilePagesDiff);
oFile.CloseFile();
std::cout << "file (page count) : " << U_TO_UTF8(strDiffs) << std::endl;
}
for (int nPage = 0; nPage < nCountInPages; ++nPage)
{
std::wstring sPageI = strDirIn + L"/image" + std::to_wstring(nPage + 1) + L".png";
std::wstring sPageO = strDirOut + L"/image" + std::to_wstring(nPage + 1) + L".png";
std::wstring sPageDiff = strDiffs + L"/image" + std::to_wstring(nPage + 1) + L".png";
CBgraFrame frameI;
frameI.OpenFile(sPageI);
CBgraFrame frameO;
frameO.OpenFile(sPageO);
int nW_I = frameI.get_Width();
int nH_I = frameI.get_Height();
int nW_O = frameO.get_Width();
int nH_O = frameO.get_Height();
if (nW_I != nW_O || nH_I != nH_O)
{
if (!NSDirectory::Exists(strDiffsMain))
NSDirectory::CreateDirectory(strDiffsMain);
if (!NSDirectory::Exists(strDiffs))
NSDirectory::CreateDirectory(strDiffs);
std::wstring sFilePagesDiff = sPageDiff;
NSFile::CFileBinary oFile;
oFile.CreateFileW(sPageDiff);
oFile.WriteStringUTF8(L"sizes!");
oFile.CloseFile();
std::cout << "file (sizes) : " << U_TO_UTF8(sPageDiff) << ", (" << nW_I << ", " << nH_I << "), (" << nW_O << ", " << nH_O << ")" << std::endl;
continue;
}
BYTE* pDataI = frameI.get_Data();
BYTE* pDataO = frameO.get_Data();
size_t sizeMemory = 4 * nW_I * nH_I;
if (0 == memcmp(pDataI, pDataO, sizeMemory))
continue;
sizeMemory = nW_I * nH_I;
for (size_t pix = 0; pix < sizeMemory; ++pix)
{
if (pDataI[0] != pDataO[0] || pDataI[1] != pDataO[1] || pDataI[2] != pDataO[2])
{
if (pDataO[0] == 0x00 && pDataO[1] == 0x00 && pDataO[2] == 0xFF)
{
pDataO[0] = 0xFF;
pDataO[1] = 0x00;
pDataO[2] = 0x00;
}
else
{
pDataO[0] = 0x00;
pDataO[1] = 0x00;
pDataO[2] = 0xFF;
}
}
pDataI += 4;
pDataO += 4;
}
if (!NSDirectory::Exists(strDiffsMain))
NSDirectory::CreateDirectory(strDiffsMain);
if (!NSDirectory::Exists(strDiffs))
NSDirectory::CreateDirectory(strDiffs);
frameO.SaveFile(sPageDiff, 4);
std::cout << "file (diffs) : " << U_TO_UTF8(sPageDiff) << std::endl;
}
}
m_bRunThread = FALSE;
m_pInternal->OnConvertFile(this, nReturnCode);
return 0;
}
int GetPagesCount(const std::wstring& dir)
{
int nCount = 0;
std::vector<std::wstring> files = NSDirectory::GetFiles(dir, false);
for (std::vector<std::wstring>::iterator i = files.begin(); i != files.end(); i++)
{
std::wstring sExt = NSFile::GetFileExtention(*i);
if (sExt == L"png")
++nCount;
}
return nCount;
}
};
CConverter* CInternalWorker::GetNextConverter()
{
if (m_nCurrent >= m_nCount)
return NULL;
CConverter* pConverter = new CConverter(this);
pConverter->m_file = m_files[m_nCurrent];
++m_nCurrent;
std::wstring sName = NSFile::GetFileName(pConverter->m_file);
pConverter->m_folder_dst = m_sOutputFolder + L"/" + sName;
NSDirectory::CreateDirectory(pConverter->m_folder_dst);
if (m_bIsStandard)
NSFile::CFileBinary::Copy(pConverter->m_file, pConverter->m_folder_dst + L"/" + sName);
pConverter->Start(0);
return pConverter;
}
void CInternalWorker::OnConvertFile(CConverter* pConverter, int nCode)
{
CTemporaryCS oCS(&m_oCS);
std::cout << "file (complete) : " << U_TO_UTF8(m_files[m_nCurrentComplete]) << ", code : " << nCode << std::endl;
++m_nCurrentComplete;
RELEASEOBJECT(pConverter);
GetNextConverter();
}
void CInternalWorker::Start(int nCores)
{
CTemporaryCS oCS(&m_oCS);
int nSizeInit = nCores;
if (nSizeInit > m_nCount)
nSizeInit = m_nCount;
for (int i = 0; i < nSizeInit; ++i)
GetNextConverter();
}
void CInternalWorker::Cancel()
{
CTemporaryCS oCS(&m_oCS);
m_nCount = m_nCurrent;
}
#define ONLYOFFICE_FONTS_VERSION_ 1
void CheckFonts(const bool& bIsUseSystemFonts, std::vector<std::wstring>& arDirs)
{
std::vector<std::string> strFonts;
std::wstring strDirectory = NSFile::GetProcessDirectory() + L"/fonts";
if (!NSDirectory::Exists(strDirectory))
NSDirectory::CreateDirectory(strDirectory);
std::wstring strAllFontsJSPath = strDirectory + L"/AllFonts.js";
std::wstring strThumbnailsFolder = strDirectory;
std::wstring strFontsSelectionBin = strDirectory + L"/font_selection.bin";
if (true)
{
NSFile::CFileBinary oFile;
if (oFile.OpenFile(strDirectory + L"/fonts.log"))
{
int nSize = oFile.GetFileSize();
char* pBuffer = new char[nSize];
DWORD dwReaden = 0;
oFile.ReadFile((BYTE*)pBuffer, nSize, dwReaden);
oFile.CloseFile();
int nStart = 0;
int nCur = nStart;
for (; nCur < nSize; ++nCur)
{
if (pBuffer[nCur] == '\n')
{
int nEnd = nCur - 1;
if (nEnd > nStart)
{
std::string s(pBuffer + nStart, nEnd - nStart + 1);
strFonts.push_back(s);
}
nStart = nCur + 1;
}
}
delete[] pBuffer;
}
if (0 != strFonts.size())
{
// check version!!!
std::string sOO_Version = strFonts[0];
if (0 != sOO_Version.find("ONLYOFFICE_FONTS_VERSION_"))
{
strFonts.clear();
}
else
{
std::string sVersion = sOO_Version.substr(25);
int nVersion = std::stoi(sVersion);
if (nVersion != ONLYOFFICE_FONTS_VERSION_)
strFonts.clear();
else
strFonts.erase(strFonts.begin());
}
}
}
NSFonts::IApplicationFonts* oApplicationF = NSFonts::NSApplication::Create();
std::vector<std::wstring> strFontsW_Cur;
if (bIsUseSystemFonts)
strFontsW_Cur = oApplicationF->GetSetupFontFiles();
for (std::vector<std::wstring>::iterator i = arDirs.begin(); i != arDirs.end(); i++)
{
NSDirectory::GetFiles2(*i, strFontsW_Cur, true);
}
#if defined(_LINUX)
std::wstring sHome = GetHomeDirectory();
if (!sHome.empty())
{
#ifdef _MAC
NSDirectory::GetFiles2(sHome + L"/Library/Fonts", strFontsW_Cur, true);
#else
NSDirectory::GetFiles2(sHome + L"/.fonts", strFontsW_Cur, true);
NSDirectory::GetFiles2(sHome + L"/.local/share/fonts", strFontsW_Cur, true);
#endif
}
#endif
bool bIsEqual = true;
if (strFonts.size() != strFontsW_Cur.size())
bIsEqual = false;
if (bIsEqual)
{
int nCount = (int)strFonts.size();
for (int i = 0; i < nCount; ++i)
{
if (strFonts[i] != NSFile::CUtf8Converter::GetUtf8StringFromUnicode2(strFontsW_Cur[i].c_str(), strFontsW_Cur[i].length()))
{
bIsEqual = false;
break;
}
}
}
if (bIsEqual)
{
if (!NSFile::CFileBinary::Exists(strFontsSelectionBin))
bIsEqual = false;
}
if (!bIsEqual)
{
if (NSFile::CFileBinary::Exists(strAllFontsJSPath))
NSFile::CFileBinary::Remove(strAllFontsJSPath);
if (NSFile::CFileBinary::Exists(strFontsSelectionBin))
NSFile::CFileBinary::Remove(strFontsSelectionBin);
if (strFonts.size() != 0)
NSFile::CFileBinary::Remove(strDirectory + L"/fonts.log");
NSFile::CFileBinary oFile;
oFile.CreateFileW(strDirectory + L"/fonts.log");
oFile.WriteStringUTF8(L"ONLYOFFICE_FONTS_VERSION_");
oFile.WriteStringUTF8(std::to_wstring(ONLYOFFICE_FONTS_VERSION_));
oFile.WriteFile((BYTE*)"\n", 1);
int nCount = (int)strFontsW_Cur.size();
for (int i = 0; i < nCount; ++i)
{
oFile.WriteStringUTF8(strFontsW_Cur[i]);
oFile.WriteFile((BYTE*)"\n", 1);
}
oFile.CloseFile();
int nFlag = 3;
oApplicationF->InitializeFromArrayFiles(strFontsW_Cur, nFlag);
NSCommon::SaveAllFontsJS(oApplicationF, strAllFontsJSPath, strThumbnailsFolder, strFontsSelectionBin);
}
oApplicationF->Release();
}
std::wstring CorrectDir(const std::wstring& sDir)
{
if (sDir.empty())
return L"";
const wchar_t* data = sDir.c_str();
std::wstring::size_type pos1 = (data[0] == '\"') ? 1 : 0;
std::wstring::size_type pos2 = sDir.length();
if (data[pos2 - 1] == '\"')
--pos2;
if (pos2 > 0 && ((data[pos2 - 1] == '\\') || (data[pos2 - 1] == '/')))
--pos2;
return sDir.substr(pos1, pos2 - pos1);
}
/*
*
* --input="input-standard-files-dir"
* --output="output-dir"
* --standard // generate standarts
* --use-system-fonts="0/1/false/true"
* --font-dirs="C:\\Windows\\Fonts;/usr/share/fonts;"
* --cores=4
*
*/
#ifdef WIN32
int wmain(int argc, wchar_t** argv)
#else
int main(int argc, char** argv)
#endif
{
std::vector<std::wstring> arFontsDirs;
bool bIsStandard = false;
std::wstring strInputFolder = L"";
std::wstring strOutputFolder = L"";
bool bIsUseSystemFonts = true;
int nCores = 1;
for (int i = 0; i < argc; ++i)
{
#ifdef WIN32
std::wstring sParam(argv[i]);
#else
std::string sParamA(argv[i]);
std::wstring sParam = UTF8_TO_U(sParamA);
#endif
if (sParam.find(L"--") == 0)
{
std::wstring sKey = L"";
std::wstring sValue = L"";
std::wstring::size_type _pos = sParam.find('=');
if (std::wstring::npos == _pos)
{
sKey = sParam;
}
else
{
sKey = sParam.substr(0, _pos);
sValue = sParam.substr(_pos + 1);
}
if (sKey == L"--input")
{
strInputFolder = CorrectDir(sValue);
}
else if (sKey == L"--output")
{
strOutputFolder = CorrectDir(sValue);
}
else if (sKey == L"--standard")
{
bIsStandard = true;
}
else if (sKey == L"--use-system-fonts")
{
if (sValue == L"0" || sValue == L"false")
bIsUseSystemFonts = false;
}
else if (sKey == L"--font-dirs")
{
const wchar_t* src = sValue.c_str();
const wchar_t* limit = src + sValue.length();
const wchar_t* srcPrev = src;
while (src < limit)
{
if (*src == ';')
{
if (srcPrev != src)
{
arFontsDirs.push_back(std::wstring(srcPrev, src - srcPrev));
}
src++;
srcPrev = src;
}
else
src++;
}
if (src > srcPrev)
{
arFontsDirs.push_back(std::wstring(srcPrev, src - srcPrev));
}
}
else if (sKey == L"--cores")
{
nCores = std::stoi(sValue);
if (nCores < 1)
nCores = 1;
}
}
}
DWORD dwTime1 = NSTimers::GetTickCount();
CheckFonts(bIsUseSystemFonts, arFontsDirs);
#if 0
if (true)
{
strInputFolder = L"D:\\standard";
strOutputFolder = L"D:\\standard\\out";
bIsStandard = true;
}
else
{
strInputFolder = L"D:\\standard\\out";
strOutputFolder = L"D:\\standard\\check";
bIsStandard = false;
}
#endif
CInternalWorker oWorker;
oWorker.OpenDir(strInputFolder);
oWorker.m_sOutputFolder = strOutputFolder;
oWorker.m_bIsStandard = bIsStandard;
if (!NSDirectory::Exists(strOutputFolder))
NSDirectory::CreateDirectories(strOutputFolder);
oWorker.Start(nCores);
while (oWorker.IsWork())
NSThreads::Sleep(500);
DWORD dwTime2 = NSTimers::GetTickCount();
DWORD dwTimeDelta = (dwTime2 - dwTime1) / 1000;
std::cout << "time: " << dwTimeDelta << std::endl;
return 0;
}

View File

@ -41,6 +41,9 @@ X2tConverter.depends = \
OdfFileWriterLib \
XlsFormatLib
# build the project sequentially as listed in SUBDIRS !
CONFIG += ordered
# for run in qt from this solution
LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH
include(../../../Common/3dParty/icu/icu.pri)