Compare commits

..

11 Commits

Author SHA1 Message Date
28346c4571 Fix bug with squares in combobox fonts (& empty rects) 2018-09-20 14:53:10 +03:00
9810087ee1 Merge pull request #108 from ONLYOFFICE/release/v5.2.0
Release/v5.2.0
2018-09-20 14:38:32 +03:00
2b8e1456c2 . 2018-09-20 11:41:42 +03:00
274c000ce7 fix PdfReader 2018-09-20 11:35:30 +03:00
9e6dd1fbb1 fix OdfReader 2018-09-20 11:35:30 +03:00
49723e648a . 2018-09-19 11:29:43 +03:00
b0a2104b21 Merge commit 'de51052f6ae59ac36665fb3f85804081a888c7c5' into develop 2018-09-18 20:03:33 +03:00
e4986f4202 . 2018-09-18 19:35:06 +03:00
de51052f6a [bug] Fix file corruption after pasting picture with error 2018-09-18 18:47:12 +03:00
2c8efcb183 Merge pull request #106 from ONLYOFFICE/feature/provideARCtoKernel
send use ARC parameter to downloader
2018-09-14 18:46:40 +03:00
9c2a717870 send use ARC parameter to downloader 2018-09-14 17:03:12 +03:00
24 changed files with 397 additions and 175 deletions

View File

@ -310,6 +310,7 @@ typedef xml::writer::element<wchar_t> xml_element;
#define CP_XML_WRITER(STRM) if (bool _b_ = false) {} else for (xml_writer _xml_wr_((STRM));!_b_;_b_=true)
#define CP_XML_NODE(NAME) if (bool _b_ = false) {} else for (xml_element _xml_node_(_xml_wr_, (NAME));!_b_;_b_=true)
#define CP_XML_ATTR(NAME, VAL) _xml_node_.attr((NAME),(VAL))
#define CP_XML_ATTR2(NAME, VAL) _xml_node_.attr((std::wstring(NAME).c_str()),(VAL))
#define CP_XML_CONTENT(VAL) _xml_node_.contents((VAL))
#define CP_XML_STREAM() _xml_node_.stream()

View File

@ -53,55 +53,59 @@ namespace oox {
//////////////////////////////////////////////////////////////////////////////////////////////////////
void oox_serialize_none_fill(std::wostream & strm)
void oox_serialize_none_fill(std::wostream & strm, const std::wstring &ns)
{
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"a:noFill");
CP_XML_NODE(ns + L":noFill");
}
}
void oox_serialize_srgb(std::wostream & strm,std::wstring color,_CP_OPT(double) opacity)
void oox_serialize_srgb(std::wostream & strm, const std::wstring &color,_CP_OPT(double) opacity, const std::wstring &ns)
{
std::wstring ns_att = (ns == L"a" ? L"" : ns + L":");
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"a:srgbClr")
CP_XML_NODE(ns + L":srgbClr")
{
CP_XML_ATTR(L"val", color);
CP_XML_ATTR2(ns_att + L"val", color);
if (opacity)
{
CP_XML_NODE(L"a:alpha")
CP_XML_NODE(ns + L":alpha")
{
CP_XML_ATTR(L"val", std::to_wstring((int)(*opacity)*1000));// + L"%");
CP_XML_ATTR2(ns_att + L"val", std::to_wstring((int)(*opacity)*1000));// + L"%");
}
}
}
}
}
void oox_serialize_srgb(std::wostream & strm,std::wstring color,_CP_OPT(odf_types::percent) opacity)
void oox_serialize_srgb(std::wostream & strm, const std::wstring &color, _CP_OPT(odf_types::percent) opacity, const std::wstring &ns)
{
std::wstring ns_att = (ns == L"a" ? L"" : ns + L":");
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"a:srgbClr")
CP_XML_NODE(ns + L":srgbClr")
{
CP_XML_ATTR(L"val",color);
CP_XML_ATTR2(ns_att + L"val",color);
if (opacity)
{
CP_XML_NODE(L"a:alpha")
CP_XML_NODE(ns + L":alpha")
{
CP_XML_ATTR(L"val", std::to_wstring((int)opacity->get_value()*1000));// + L"%");
CP_XML_ATTR2(ns_att + L"val", std::to_wstring((int)opacity->get_value()*1000));// + L"%");
}
}
}
}
}
void oox_serialize_solid_fill(std::wostream & strm, const _oox_fill & val)
void oox_serialize_solid_fill(std::wostream & strm, const _oox_fill & val, const std::wstring &ns)
{
if (!val.solid)return;
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"a:solidFill")
CP_XML_NODE(ns + L":solidFill")
{
oox_serialize_srgb(CP_XML_STREAM(), val.solid->color, val.opacity);
oox_serialize_srgb(CP_XML_STREAM(), val.solid->color, val.opacity, ns);
}
}
@ -151,20 +155,25 @@ void vml_serialize_bitmap_fill(std::wostream & strm, const _oox_fill & val)
}
}
}
void oox_serialize_bitmap_fill(std::wostream & strm, const _oox_fill & val)
void oox_serialize_bitmap_fill(std::wostream & strm, const _oox_fill & val, const std::wstring &ns)
{
if (!val.bitmap) return;
std::wstring ns_att = (ns == L"a" ? L"" : ns + L":");
CP_XML_WRITER(strm)
{
CP_XML_NODE(std::wstring(val.bitmap->name_space + L":blipFill"))
{
//if (val.bitmap->rotate) CP_XML_ATTR(L"a:rotWithShape",*(val.bitmap->rotate));
//else CP_XML_ATTR(L"a:rotWithShape",1);
//if (val.bitmap->rotate) CP_XML_ATTR(ns + L":rotWithShape",*(val.bitmap->rotate));
//else CP_XML_ATTR(ns + L":rotWithShape",1);
if (val.bitmap->dpi) CP_XML_ATTR(L"a:dpi", *val.bitmap->dpi);
if (val.bitmap->dpi)
{
CP_XML_ATTR2(ns + L":dpi", *val.bitmap->dpi);
}
CP_XML_NODE(L"a:blip")
CP_XML_NODE(ns + L":blip")
{
if (val.bitmap->isInternal)
{
@ -176,38 +185,38 @@ void oox_serialize_bitmap_fill(std::wostream & strm, const _oox_fill & val)
if (val.opacity)
{
CP_XML_NODE(L"a:alphaModFix")
CP_XML_NODE(ns + L":alphaModFix")
{
CP_XML_ATTR(L"amt",(int)(*val.opacity * 1000));
CP_XML_ATTR2(ns_att + L"amt", (int)(*val.opacity * 1000));
}
}
}
if (val.bitmap->bCrop)
{
CP_XML_NODE(L"a:srcRect")
CP_XML_NODE(ns + L":srcRect")
{
CP_XML_ATTR(L"l", static_cast<int>(val.bitmap->cropRect[0]*1000));
CP_XML_ATTR(L"t", static_cast<int>(val.bitmap->cropRect[1]*1000));
CP_XML_ATTR(L"r", static_cast<int>(val.bitmap->cropRect[2]*1000));
CP_XML_ATTR(L"b", static_cast<int>(val.bitmap->cropRect[3]*1000));
CP_XML_ATTR2(ns_att + L"l", static_cast<int>(val.bitmap->cropRect[0]*1000));
CP_XML_ATTR2(ns_att + L"t", static_cast<int>(val.bitmap->cropRect[1]*1000));
CP_XML_ATTR2(ns_att + L"r", static_cast<int>(val.bitmap->cropRect[2]*1000));
CP_XML_ATTR2(ns_att + L"b", static_cast<int>(val.bitmap->cropRect[3]*1000));
}
}
if (val.bitmap->bTile)
{
CP_XML_NODE(L"a:tile")
CP_XML_NODE(ns + L":tile")
{
//tx="0" ty="0" sx="100000" sy="100000"
CP_XML_ATTR(L"flip", "none");
CP_XML_ATTR(L"algn", L"ctr");
CP_XML_ATTR2(ns_att + L"flip", "none");
CP_XML_ATTR2(ns_att + L"algn", L"ctr");
}
}
else if (val.bitmap->bStretch)
{
CP_XML_NODE(L"a:stretch")
CP_XML_NODE(ns + L":stretch")
{
if (!val.bitmap->bCrop)
{
CP_XML_NODE(L"a:fillRect");
CP_XML_NODE(ns + L":fillRect");
}
}
}
@ -269,25 +278,27 @@ void vml_serialize_gradient_fill(std::wostream & strm, const _oox_fill & val)
}
}
}
void oox_serialize_gradient_fill(std::wostream & strm, const _oox_fill & val)
void oox_serialize_gradient_fill(std::wostream & strm, const _oox_fill & val, const std::wstring &ns)
{
if (!val.gradient) return;
std::wstring ns_att = (ns == L"a" ? L"" : ns + L":");
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"a:gradFill")
CP_XML_NODE(ns + L":gradFill")
{
if (val.gradient->colors.size()>0)
{
CP_XML_NODE(L"a:gsLst")
CP_XML_NODE(ns + L":gsLst")
{
for (int i = 0; i < val.gradient->colors.size(); i++)
{
oox_gradient_fill::_color_position & col = val.gradient->colors[i];
CP_XML_NODE(L"a:gs")
CP_XML_NODE(ns + L":gs")
{
CP_XML_ATTR(L"pos", (int)(col.pos * 1000));//%
oox_serialize_srgb(CP_XML_STREAM(), col.color_ref, col.opacity);
CP_XML_ATTR2(ns_att + L"pos", (int)(col.pos * 1000));//%
oox_serialize_srgb(CP_XML_STREAM(), col.color_ref, col.opacity, ns);
}
}
}
@ -298,25 +309,25 @@ void oox_serialize_gradient_fill(std::wostream & strm, const _oox_fill & val)
switch(val.gradient->style)
{
case 0:
CP_XML_NODE(L"a:lin")
CP_XML_NODE(ns + L":lin")
{
CP_XML_ATTR(L"ang",(int)angle);//gr in rad
CP_XML_ATTR2(ns_att + L"ang",(int)angle);//gr in rad
}break;
case 1:
case 2:
case 3:
CP_XML_NODE(L"a:path")
CP_XML_NODE(ns + L":path")
{
if (val.gradient->style == 1) CP_XML_ATTR(L"path", L"rect");
if (val.gradient->style == 2) CP_XML_ATTR(L"path", L"circle");
if (val.gradient->style == 3) CP_XML_ATTR(L"path", L"shape");
if (val.gradient->style == 1) CP_XML_ATTR2(ns_att + L"path", L"rect");
if (val.gradient->style == 2) CP_XML_ATTR2(ns_att + L"path", L"circle");
if (val.gradient->style == 3) CP_XML_ATTR2(ns_att + L"path", L"shape");
CP_XML_NODE(L"a:fillToRect")
CP_XML_NODE(ns + L":fillToRect")
{
CP_XML_ATTR(L"l", (int)(val.gradient->rect[0] * 1000));
CP_XML_ATTR(L"t", (int)(val.gradient->rect[1] * 1000));
CP_XML_ATTR(L"r", (int)(val.gradient->rect[2] * 1000));
CP_XML_ATTR(L"b", (int)(val.gradient->rect[3] * 1000));
CP_XML_ATTR2(ns_att + L"l", (int)(val.gradient->rect[0] * 1000));
CP_XML_ATTR2(ns_att + L"t", (int)(val.gradient->rect[1] * 1000));
CP_XML_ATTR2(ns_att + L"r", (int)(val.gradient->rect[2] * 1000));
CP_XML_ATTR2(ns_att + L"b", (int)(val.gradient->rect[3] * 1000));
}
}break;
}
@ -324,22 +335,24 @@ void oox_serialize_gradient_fill(std::wostream & strm, const _oox_fill & val)
//tileRect (Tile Rectangle) §20.1.8.59
}
}
void oox_serialize_hatch_fill(std::wostream & strm, const _oox_fill & val)
void oox_serialize_hatch_fill(std::wostream & strm, const _oox_fill & val, const std::wstring &ns)
{
if (!val.hatch)return;
std::wstring ns_att = (ns == L"a" ? L"" : ns + L":");
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"a:pattFill")
CP_XML_NODE(ns + L":pattFill")
{
CP_XML_ATTR(L"prst",val.hatch->preset);
CP_XML_NODE(L"a:fgClr")//опять для ms важно что этот цвет перед back
CP_XML_ATTR2(ns_att + L"prst", val.hatch->preset);
CP_XML_NODE(ns + L":fgClr")//опять для ms важно что этот цвет перед back
{
oox_serialize_srgb(CP_XML_STREAM(), val.hatch->color_ref, val.opacity);
}
if (val.hatch->color_back_ref)
{
CP_XML_NODE(L"a:bgClr")
CP_XML_NODE(ns + L":bgClr")
{
oox_serialize_srgb(CP_XML_STREAM(), *val.hatch->color_back_ref ,val.opacity);
}
@ -379,23 +392,23 @@ void vml_serialize_background (std::wostream & strm, const _oox_fill & val, cons
}
}
void oox_serialize_fill (std::wostream & strm, const _oox_fill & val)
void oox_serialize_fill (std::wostream & strm, const _oox_fill & val, const std::wstring &ns)
{
switch (val.type)
{
case 0:
oox_serialize_none_fill(strm);
oox_serialize_none_fill(strm, ns);
break;
case 1:
oox_serialize_solid_fill(strm, val);
oox_serialize_solid_fill(strm, val, ns);
break;
case 2:
oox_serialize_bitmap_fill(strm, val);
oox_serialize_bitmap_fill(strm, val, ns);
break;
case 3:
oox_serialize_gradient_fill(strm, val);
oox_serialize_gradient_fill(strm, val, ns);
break;
case 4: oox_serialize_hatch_fill(strm, val);
case 4: oox_serialize_hatch_fill(strm, val, ns);
break;
}
}

View File

@ -143,10 +143,12 @@ namespace oox {
}
};
void vml_serialize_background (std::wostream & strm, const _oox_fill & val, const std::wstring & color, int id);
void oox_serialize_fill (std::wostream & strm, const _oox_fill & val);
void oox_serialize_srgb (std::wostream & strm,std::wstring color,_CP_OPT(double) opacity);
void oox_serialize_srgb (std::wostream & strm,std::wstring color,_CP_OPT(odf_types::percent) opacity);
void oox_serialize_bitmap_fill (std::wostream & strm, const _oox_fill & val);
void vml_serialize_background (std::wostream & strm, const _oox_fill & val, const std::wstring &color, int id);
void oox_serialize_srgb (std::wostream & strm, const std::wstring &color, _CP_OPT(double) opacity, const std::wstring &ns = L"a");
void oox_serialize_srgb (std::wostream & strm, const std::wstring &color, _CP_OPT(odf_types::percent) opacity, const std::wstring &ns = L"a");
void oox_serialize_bitmap_fill (std::wostream & strm, const _oox_fill & val, const std::wstring &ns = L"a");
void oox_serialize_fill (std::wostream & strm, const _oox_fill & val, const std::wstring &ns = L"a");
}
}

View File

@ -896,7 +896,7 @@ void common_draw_docx_convert(oox::docx_conversion_context & Context, union_comm
//////////////////////////////////////////
bool bTxbx = (drawing->sub_type == 1);
Compute_GraphicFill(graphicProperties.common_draw_fill_attlist_, graphicProperties.style_background_image_, Context.root()->odf_context().drawStyles() ,drawing->fill, bTxbx);
Compute_GraphicFill(graphicProperties.common_draw_fill_attlist_, graphicProperties.style_background_image_, Context.root()->odf_context().drawStyles(),drawing->fill, bTxbx);
if ((drawing->fill.bitmap) && (drawing->fill.bitmap->rId.empty()))
{
@ -1040,7 +1040,7 @@ void draw_shape::docx_convert(oox::docx_conversion_context & Context)
if (drawing.sub_type !=5 )//line
{
drawing.additional.push_back(_property(L"text-content",Context.get_drawing_context().get_text_stream_shape()));
drawing.additional.push_back(_property(L"text-content", Context.get_drawing_context().get_text_stream_shape()));
}
Context.get_drawing_context().clear_stream_shape();
@ -1055,7 +1055,7 @@ void draw_shape::docx_convert(oox::docx_conversion_context & Context)
bad_shape_ = false;
}
if (drawing.fill.type < 1 && !IsExistProperty(drawing.additional,L"stroke"))//бывает что и не определено ничего
if (drawing.fill.type < 1 && !IsExistProperty(drawing.additional, L"stroke"))//бывает что и не определено ничего
{
drawing.fill.solid = oox::oox_solid_fill::create();
drawing.fill.solid->color = L"729FCF";

View File

@ -69,7 +69,14 @@ void draw_shape_attlist::add_attributes( const xml::attributes_wc_ptr & Attribut
void draw_shape::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{
CP_CREATE_ELEMENT(content_);
if CP_CHECK_NAME(L"draw", L"enhanced-geometry")
{
CP_CREATE_ELEMENT(enhanced_geometry_);
}
else
{
CP_CREATE_ELEMENT(content_);
}
}
void draw_shape::add_attributes( const xml::attributes_wc_ptr & Attributes )
{

View File

@ -85,7 +85,8 @@ public:
odf_types::common_xlink_attlist xlink_attlist_;
_CP_OPT(std::wstring) draw_id_; //используется для анимашек
office_element_ptr_array content_;
office_element_ptr_array content_;
office_element_ptr enhanced_geometry_;
bool bad_shape_;
bool word_art_;

View File

@ -72,34 +72,43 @@ void draw_shape::common_docx_convert(oox::docx_conversion_context & Context)
Context.get_drawing_context().add_name_object(name.get_value_or(L"Shape"));
//////////////////////////////на другом контексте
//---------------------------сначала элементы графики потом все остальное
if (enhanced_geometry_)
enhanced_geometry_->docx_convert(Context);
//---------------------------на другом контексте
//тут может быть не только текст , но и таблицы, другие объекты ...
oox::StreamsManPtr prev = Context.get_stream_man();
std::wstringstream temp_stream(Context.get_drawing_context().get_text_stream_shape());
Context.set_stream_man( boost::shared_ptr<oox::streams_man>( new oox::streams_man(temp_stream) ));
//сначала элементы графики потом все остальное
for (size_t i = 0; i < content_.size(); i++)
{
ElementType type = content_[i]->get_type();
if (type == typeDrawCustomShape) // || ....
{
content_[i]->docx_convert(Context);
}
}
Context.reset_context_state();
if (word_art_)
{
const std::wstring styleName = common_draw_attlists_.shape_with_text_and_styles_.
common_shape_draw_attlist_.draw_style_name_.get_value_or(L"");
style_instance* styleInst = Context.root()->odf_context().styleContainer().style_by_name(styleName, odf_types::style_family::Graphic,Context.process_headers_footers_);
style_content * content = styleInst ? styleInst->content() : NULL;
graphic_format_properties * graphicProp = content ? content->get_graphic_properties() : NULL;
if (graphicProp)
{
oox::_oox_fill fill;
Compute_GraphicFill(graphicProp->common_draw_fill_attlist_, graphicProp->style_background_image_,
Context.root()->odf_context().drawStyles(), fill);
std::wstringstream strm;
oox::oox_serialize_fill(strm, fill, L"w14");
std::wstring textFill = strm.str();
}
}
for (size_t i = 0; i < content_.size(); i++)
{
ElementType type = content_[i]->get_type();
if (type != typeDrawCustomShape)
{
content_[i]->docx_convert(Context);
}
content_[i]->docx_convert(Context);
}
Context.back_context_state();

View File

@ -162,13 +162,22 @@ void draw_shape::common_pptx_convert(oox::pptx_conversion_context & Context)
}
////////////////////////////////////////////////////////////////////////////////////
Context.get_text_context().start_object();
if (enhanced_geometry_)
enhanced_geometry_->pptx_convert(Context);
if (word_art_)
{
//set fill & stroke to text
}
for (size_t i = 0; i < content_.size(); i++)
{
content_[i]->pptx_convert(Context);
}
std::wstring text_content_ = Context.get_text_context().end_object();
if (text_content_.length()>0)
if (!text_content_.empty())
{
Context.get_slide_context().set_property(_property(L"text-content",text_content_));
}

View File

@ -66,6 +66,9 @@ namespace odf_reader {
void draw_shape::common_xlsx_convert(oox::xlsx_conversion_context & Context)
{
if (enhanced_geometry_)
enhanced_geometry_->xlsx_convert(Context);
common_draw_shape_with_text_and_styles_attlist common_draw_attlist_ = common_draw_attlists_.shape_with_text_and_styles_;
const int z_index = common_draw_attlist_.common_shape_draw_attlist_.draw_z_index_.get_value_or(0);
@ -130,11 +133,17 @@ void draw_shape::common_xlsx_convert(oox::xlsx_conversion_context & Context)
oox::_oox_fill fill;
Compute_GraphicFill(properties.common_draw_fill_attlist_, properties.style_background_image_,
Context.root()->odf_context().drawStyles() ,fill);
Context.root()->odf_context().drawStyles(), fill);
Context.get_drawing_context().set_fill(fill);
//////////////////////////////////////////////////////////////////////////////////////
Context.get_text_context().start_drawing_content();
if (word_art_)
{
//Context.get_text_context().start_drawing_fill(fill);
}
for (size_t i = 0; i < content_.size(); i++)
{
content_[i]->xlsx_convert(Context);
@ -143,7 +152,7 @@ void draw_shape::common_xlsx_convert(oox::xlsx_conversion_context & Context)
if (!text_content_.empty())
{
Context.get_drawing_context().set_property(_property(L"text-content",text_content_));
Context.get_drawing_context().set_property(_property(L"text-content", text_content_));
}
Context.get_drawing_context().end_drawing();

View File

@ -200,7 +200,11 @@ odf_document::Impl::Impl(const std::wstring & srcPath, const std::wstring & temp
if (false == map_encryptions_.empty())
{
if (password.empty()) return;
if (password.empty())
{
bError = true;
return;
}
//decrypt files
tmp_folder_ = NSDirectory::CreateDirectoryWithUniqueName(tempPath);
@ -286,17 +290,22 @@ bool odf_document::Impl::decrypt_folder (const std::wstring &password, const std
bool result = true;
for (size_t i = 0; i < arFiles.size(); ++i)
{
result = false;
std::wstring sFileName = NSFile::GetFileName(arFiles[i]);
std::map<std::wstring, std::pair<office_element_ptr, int>>::iterator pFind = map_encryptions_.find(arFiles[i]);
if ( pFind != map_encryptions_.end() )
std::map<std::wstring, std::pair<office_element_ptr, int>>::iterator pFind;
if (false == map_encryptions_.empty())
{
result = decrypt_file(password, arFiles[i], dstPath + FILE_SEPARATOR_STR + sFileName, pFind->second.first, pFind->second.second);
if (false == result)
break;
pFind = map_encryptions_.find(arFiles[i]);
if ( pFind != map_encryptions_.end() )
{
result = decrypt_file(password, arFiles[i], dstPath + FILE_SEPARATOR_STR + sFileName, pFind->second.first, pFind->second.second);
if (false == result)
break;
}
}
else
if (!result && false == map_encryptions_extra_.empty())
{
pFind = map_encryptions_extra_.find(arFiles[i]);
if ( pFind != map_encryptions_.end() )
@ -306,10 +315,11 @@ bool odf_document::Impl::decrypt_folder (const std::wstring &password, const std
if (false == result)
break;
}
else
{
NSFile::CFileBinary::Copy(arFiles[i], dstPath + FILE_SEPARATOR_STR + sFileName);
}
}
if (!result)
{
NSFile::CFileBinary::Copy(arFiles[i], dstPath + FILE_SEPARATOR_STR + sFileName);
result = true;
}
}
for (size_t i = 0; result && i < arDirectories.size(); ++i)

View File

@ -1363,7 +1363,7 @@ void odf_drawing_context::set_solid_fill(std::wstring hexColor)
switch(impl_->current_drawing_part_)
{
case Area:
impl_->current_graphic_properties->common_draw_fill_attlist_.draw_fill_color_ = hexColor;
impl_->current_graphic_properties->common_draw_fill_attlist_.draw_fill_color_ = hexColor;
//impl_->current_graphic_properties->common_background_color_attlist_.fo_background_color_ = color(hexColor); - default transparent
//последнее нужно - что если будут вводить текст - под текстом будет цвет фона (или он поменяется в полях текста)
@ -2511,6 +2511,12 @@ void odf_drawing_context::start_text_box()
}
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;
}
if (impl_->current_drawing_state_.elements_.empty()) return;
draw_text_box* draw = dynamic_cast<draw_text_box*>(impl_->current_drawing_state_.elements_.back().elm.get());
@ -2829,7 +2835,8 @@ void odf_drawing_context::set_text(odf_text_context* text_context)
}
}
if (impl_->current_graphic_properties)
if ((impl_->current_graphic_properties) &&
!impl_->current_graphic_properties->draw_auto_grow_height_)
{
//автоувеличение при добавлении текста
impl_->current_graphic_properties->draw_auto_grow_height_ = false;

View File

@ -593,7 +593,7 @@ void OoxConverter::convert(PPTX::Logic::Shape *oox_shape)
if (oox_shape->txBody.IsInit()) bodyPr = oox_shape->txBody->bodyPr.GetPointer();
else bodyPr = oox_shape->oTextBoxBodyPr.GetPointer();
if (bodyPr && bodyPr->fromWordArt.get_value_or(false))
if ((bodyPr) && (bodyPr->prstTxWarp.IsInit()))
{
int wordart_type = convert(bodyPr->prstTxWarp.GetPointer());
if (wordart_type > 0) type = wordart_type;
@ -782,9 +782,16 @@ void OoxConverter::convert(PPTX::Logic::UniFill *oox_fill, DWORD nARGB)
int OoxConverter::convert(PPTX::Logic::PrstTxWarp *oox_text_preset)
{
if (oox_text_preset == NULL) return -1;
if (oox_text_preset->prst.GetBYTECode() == SimpleTypes::textshapetypeTextNoShape) return 2000;
return 2001 + oox_text_preset->prst.GetBYTECode();
if (oox_text_preset->prst.GetBYTECode() == SimpleTypes::textshapetypeTextNoShape ||
oox_text_preset->prst.GetBYTECode() == SimpleTypes::textshapetypeTextPlain) // в зависимости от других настроек
{
return 2000;
}
else
{
return 2001 + oox_text_preset->prst.GetBYTECode();
}
}
void OoxConverter::convert(PPTX::Logic::PrstGeom *oox_geom)
{
@ -1302,7 +1309,7 @@ void OoxConverter::convert(PPTX::Logic::BodyPr *oox_bodyPr)
switch(oox_bodyPr->Fit.type)
{
case PPTX::Logic::TextFit::FitSpAuto:
{//изменяемы размеры
{//изменяемы размеры шейпа под текст
odf_context()->drawing_context()->set_text_box_min_size(true);//уже выставленые в min
}break;
case PPTX::Logic::TextFit::FitNo:

View File

@ -254,7 +254,7 @@ void DocxConverter::convert_document()
//----------------------------------------------------------------------------------------------------------
convert(docx_document->m_pDocument->m_oSectPr.GetPointer(), false, L"Standard");
convert(docx_document->m_pDocument->m_oSectPr.GetPointer(), false, L"Standard", true);
odt_context->text_context()->clear_params();
@ -1507,7 +1507,7 @@ void DocxConverter::apply_HF_from(OOX::Logic::CSectionProperty *props, OOX::Logi
}
}
}
void DocxConverter::convert(OOX::Logic::CSectionProperty *oox_section_pr, bool bSection, const std::wstring & master_name)
void DocxConverter::convert(OOX::Logic::CSectionProperty *oox_section_pr, bool bSection, const std::wstring & master_name, bool bAlways)
{
if (oox_section_pr == NULL) return;
current_section_properties = NULL;
@ -1684,7 +1684,7 @@ void DocxConverter::convert(OOX::Logic::CSectionProperty *oox_section_pr, bool b
//nullable<SimpleTypes::CDecimalNumber<> > m_oChapStyle;
}
if (continuous == false || oox_section_pr->m_oTitlePg.IsInit())
if (continuous == false || oox_section_pr->m_oTitlePg.IsInit() || bAlways)
{
OOX::Logic::CSectionProperty* s = last_section_properties ? last_section_properties : oox_section_pr;
@ -2244,51 +2244,95 @@ void DocxConverter::convert(OOX::Logic::CRunProperty *oox_run_pr, odf_writer::st
text_properties->content_.fo_font_weight_ = odf_types::font_weight(odf_types::font_weight::WNormal);
}
bool set_color = false;
if (oox_run_pr->m_oTextFill.is_init() || oox_run_pr->m_oTextOutline.is_init())
{
odf_writer::odf_drawing_context *drawing_context = odf_context()->drawing_context();
if (drawing_context)
{
if (odf_context()->drawing_context()->change_text_box_2_wordart())
{
NSCommon::smart_ptr<PPTX::Logic::GradFill> gradFill = oox_run_pr->m_oTextFill.Fill.smart_dynamic_cast<PPTX::Logic::GradFill>();
NSCommon::smart_ptr<PPTX::Logic::SolidFill> solidFill = oox_run_pr->m_oTextFill.Fill.smart_dynamic_cast<PPTX::Logic::SolidFill>();
odf_context()->drawing_context()->start_area_properties(true);
if(gradFill.IsInit())
{
OoxConverter::convert(gradFill.operator->());
}
else if (solidFill.IsInit())
{
OoxConverter::convert(solidFill.operator->());
}
else
{
odf_context()->drawing_context()->set_no_fill();
}
odf_context()->drawing_context()->end_area_properties();
if (oox_run_pr->m_oTextOutline.IsInit())
{
odf_context()->drawing_context()->start_line_properties(true);
OoxConverter::convert(oox_run_pr->m_oTextOutline.operator->());
odf_context()->drawing_context()->end_line_properties();
}
set_color = true;
}
}
else{} //обычный текст .. градиент по телу абзаца (
}
odf_writer::odf_drawing_context *drawing_context = odf_context()->drawing_context();
if (!set_color && oox_run_pr->m_oColor.IsInit())
bool set_word_art = drawing_context ? drawing_context->is_wordart() : false;
NSCommon::smart_ptr<PPTX::Logic::GradFill> gradFill = oox_run_pr->m_oTextFill.Fill.smart_dynamic_cast<PPTX::Logic::GradFill>();
NSCommon::smart_ptr<PPTX::Logic::SolidFill> solidFill = oox_run_pr->m_oTextFill.Fill.smart_dynamic_cast<PPTX::Logic::SolidFill>();
bool bFillText = (oox_run_pr->m_oTextFill.m_type != PPTX::Logic::UniFill::notInit) &&
(oox_run_pr->m_oTextFill.m_type != PPTX::Logic::UniFill::noFill);
bool bOutlineText = ((oox_run_pr->m_oTextOutline.is_init()) &&
(oox_run_pr->m_oTextOutline->Fill.m_type != PPTX::Logic::UniFill::notInit) &&
(oox_run_pr->m_oTextOutline->Fill.m_type != PPTX::Logic::UniFill::noFill));
bool bOutline = oox_run_pr->m_oOutline.IsInit();
bool bColorText = !bOutline && (oox_run_pr->m_oColor.IsInit() && (oox_run_pr->m_oColor->m_oVal.IsInit() && oox_run_pr->m_oColor->m_oVal->GetValue() == SimpleTypes::hexcolorRGB));
_CP_OPT(odf_types::color) color;
if (oox_run_pr->m_oColor.IsInit())
{
if(oox_run_pr->m_oColor->m_oVal.IsInit() && oox_run_pr->m_oColor->m_oVal->GetValue() == SimpleTypes::hexcolorAuto)
text_properties->content_.fo_color_ = odf_types::color(L"#000000");
color = odf_types::color(L"#000000");
else
convert(oox_run_pr->m_oColor.GetPointer(),text_properties->content_.fo_color_);
convert(oox_run_pr->m_oColor.GetPointer(), color);
text_properties->content_.fo_color_ = color;
}
if (gradFill.is_init() || (bOutlineText && (bFillText || bColorText)))
{
set_word_art = true;
}
if (drawing_context && set_word_art)
{
if (drawing_context->change_text_box_2_wordart())
{
drawing_context->start_area_properties(true);
if(gradFill.IsInit())
{
OoxConverter::convert(gradFill.operator->());
}
else if (solidFill.IsInit())
{
OoxConverter::convert(solidFill.operator->());
}
else if (color)
{
drawing_context->set_solid_fill(color->get_hex_value());
}
else
{
drawing_context->set_no_fill();
}
drawing_context->end_area_properties();
if (oox_run_pr->m_oTextOutline.IsInit())
{
drawing_context->start_line_properties(true);
OoxConverter::convert(oox_run_pr->m_oTextOutline.operator->());
drawing_context->end_line_properties();
}
}
else
{
set_word_art = false;
}
}
std::wstring hexString;
_CP_OPT(double) opacity;
if (bOutlineText)
{
text_properties->content_.style_text_outline_ = true;
gradFill = oox_run_pr->m_oTextOutline->Fill.Fill.smart_dynamic_cast<PPTX::Logic::GradFill>();
solidFill = oox_run_pr->m_oTextOutline->Fill.Fill.smart_dynamic_cast<PPTX::Logic::SolidFill>();
}
if (solidFill.is_init())
{
OoxConverter::convert(&solidFill->Color, hexString, opacity);
}
else if ((gradFill.is_init()) && (false == gradFill->GsLst.empty()))
{
OoxConverter::convert(&gradFill->GsLst[0].color, hexString, opacity);
}
if (!hexString.empty())
{
text_properties->content_.fo_color_ = hexString;
}
//text_properties->content_.style_text_underline_type_= odf_types::line_type(odf_types::line_type::None); //нельзя..если будет выше наследуемого то подчеркивания не будет

View File

@ -183,7 +183,7 @@ namespace Oox2Odf
void convert(OOX::Logic::CBackground *oox_background, int type);
void convert(OOX::Logic::CSdt *oox_sdt);
void convert(OOX::Logic::CSectionProperty *oox_section_pr, bool bSection, const std::wstring & master_name = L"");
void convert(OOX::Logic::CSectionProperty *oox_section_pr, bool bSection, const std::wstring & master_name = L"", bool bAlways = false);
void convert(OOX::Logic::CParagraph *oox_paragraph);
void convert(OOX::Logic::CRun *oox_run);
void convert(OOX::Logic::CParagraphProperty *oox_para_prop, odf_writer::style_paragraph_properties *paragraph_properties);

View File

@ -218,9 +218,11 @@ namespace NSBinPptxRW
}
std::wstring strExts = _T(".jpg");
int nIndexExt = (int)strInput.rfind(wchar_t('.'));
//use GetFileName to avoid defining '.' in the directory as extension
std::wstring strFileName = NSFile::GetFileName(strInput);
int nIndexExt = (int)strFileName.rfind(wchar_t('.'));
if (-1 != nIndexExt)
strExts = strInput.substr(nIndexExt);
strExts = strFileName.substr(nIndexExt);
int typeAdditional = 0;
std::wstring strAdditional;

View File

@ -64,6 +64,7 @@ namespace OOX
m_mTable.insert( std::make_pair( _T("emf"), _T("image/x-emf")));
m_mTable.insert( std::make_pair( _T("emz"), _T("image/x-emz")));
m_mTable.insert( std::make_pair( _T("wmf"), _T("image/x-wmf")));
m_mTable.insert( std::make_pair( _T("svg"), _T("image/svg+xml")));
m_mTable.insert( std::make_pair( _T("svm"), _T("image/svm")));
m_mTable.insert( std::make_pair( _T("wav"), _T("audio/wav")));
m_mTable.insert( std::make_pair( _T("wma"), _T("audio/x-wma")));

View File

@ -102,3 +102,16 @@ void CFileDownloader::CheckSuspend()
{
return m_pInternal->CheckSuspend();
}
#ifdef _MAC
bool CFileDownloader::m_bIsARCEnabled = false;
void CFileDownloader::SetARCEnabled(const bool& enabled)
{
m_bIsARCEnabled = enabled;
}
bool CFileDownloader::GetARCEnabled()
{
return m_bIsARCEnabled;
}
#endif

View File

@ -41,6 +41,10 @@ protected:
// создаем в зависимости от платформы
CFileDownloader_private* m_pInternal;
#ifdef _MAC
static bool m_bIsARCEnabled;
#endif
public:
CFileDownloader(std::wstring sFileUrl, bool bDelete = true);
virtual ~CFileDownloader();
@ -63,4 +67,9 @@ public:
int GetPriority();
void CheckSuspend();
#ifdef _MAC
static void SetARCEnabled(const bool& enabled);
static bool GetARCEnabled();
#endif
};

View File

@ -1,4 +1,5 @@
#include "FileDownloader_private.h"
#include "FileDownloader.h"
#if _IOS
#import <Foundation/Foundation.h>
@ -27,12 +28,12 @@ public :
}
virtual int DownloadFile()
{
{
if (m_sFilePath.empty())
{
{
m_sFilePath = NSFile::CFileBinary::CreateTempFileWithUniqueName(NSFile::CFileBinary::GetTempPath(), L"DWD");
if (NSFile::CFileBinary::Exists(m_sFilePath))
NSFile::CFileBinary::Remove(m_sFilePath);
NSFile::CFileBinary::Remove(m_sFilePath);
}
NSString* stringURL = StringWToNSString(m_sFileUrl);
@ -50,9 +51,12 @@ public :
return 0;
#else
#ifndef _ASC_USE_ARC_
[stringURL release];
[url release];
[urlData release];
if (!CFileDownloader::GetARCEnabled())
{
[stringURL release];
[url release];
[urlData release];
}
#endif
#endif
return 0;
@ -62,8 +66,11 @@ public :
return 1;
#else
#ifndef _ASC_USE_ARC_
[stringURL release];
[url release];
if (!CFileDownloader::GetARCEnabled())
{
[stringURL release];
[url release];
}
#endif
#endif
return 1;

View File

@ -914,6 +914,25 @@ TFontCacheSizes CFontFile::GetChar(LONG lUnicode)
return oSizes;
}
double CFontFile::GetCharWidth(int gid)
{
if (!m_pFace)
return 0;
if (0 != FT_Load_Glyph(m_pFace, gid, 40970))
return 0;
FT_Glyph pGlyph = NULL;
if (0 != FT_Get_Glyph(m_pFace->glyph, &pGlyph))
return 0;
double dRet = (double)(m_pFace->glyph->linearHoriAdvance * m_dUnitsKoef / m_pFace->units_per_EM);
FT_Done_Glyph(pGlyph);
return dRet;
}
INT CFontFile::GetString(CGlyphString& oString)
{
int nCountGlyph = oString.GetLength();

View File

@ -239,6 +239,8 @@ public:
int SetCMapForCharCode(long lUnicode, int *pnCMapIndex);
int SetCMapForCharCode2(long lUnicode);
double GetCharWidth(int gid);
int GetKerning(FT_UInt unPrevGID, FT_UInt unGID);
void SetStringGID(const INT& bGID);
INT GetStringGID();

View File

@ -1,4 +1,4 @@
/*
/*
* (c) Copyright Ascensio System SIA 2010-2018
*
* This program is a free software product. You can redistribute it and/or
@ -256,7 +256,7 @@ namespace NSCommon
int nCount = 1;
++tmp;
while (nMask == *tmp && tmp < tmpLast)
while (tmp < tmpLast && nMask == *tmp)
{
++tmp;
nCount++;
@ -537,12 +537,13 @@ namespace NSCommon
pRenderer->put_FontFaceIndex(lFaceIndex);
pManager->LoadFontFromFile(strFontPath, lFaceIndex, 14, dDpi, dDpi);
bool bIsSymbol = FALSE;
bool bIsSymbol = false;
NSFonts::IFontFile* pFile = pManager->GetFile();
if (pManager->GetFile())
{
bIsSymbol = pManager->GetFile()->IsSymbolic(false);
}
if (pFile)
bIsSymbol = pFile->IsSymbolic(false);
std::wstring sFontName = pPair->second.m_sName;
if (bIsSymbol)
{
@ -557,6 +558,45 @@ namespace NSCommon
pRenderer->put_FontPath(pInfoCur->m_wsFontPath);
pRenderer->put_FontFaceIndex(0);
}
else if (pFile)
{
int nFontNameLen = (int)sFontName.length();
bool bIsPresentAll = true;
for (int nC = 0; nC < nFontNameLen; nC++)
{
int nCMapIndex = 0;
int nGid = pFile->SetCMapForCharCode(sFontName.at(nC), &nCMapIndex);
if (0 >= nGid)
{
bIsPresentAll = false;
break;
}
else
{
double offsetG = pFile->GetCharWidth(nGid);
if (offsetG < 0.0001)
{
bIsPresentAll = false;
break;
}
}
}
if (!bIsPresentAll)
{
NSFonts::CFontSelectFormat oSelectFormat;
oSelectFormat.wsName = new std::wstring(L"Arial");
NSFonts::CFontInfo* pInfoCur = pManager->GetFontInfoByParams(oSelectFormat);
if (NULL != pInfoCur)
{
pManager->LoadFontFromFile(pInfoCur->m_wsFontPath, 0, 14, dDpi, dDpi);
}
pRenderer->put_FontPath(pInfoCur->m_wsFontPath);
pRenderer->put_FontFaceIndex(0);
}
}
pRenderer->PathCommandStart();
pRenderer->BeginCommand(c_nClipType);
@ -568,7 +608,7 @@ namespace NSCommon
pRenderer->put_FontCharSpace(0);
pRenderer->put_FontSize(14);
pRenderer->CommandDrawText(pPair->second.m_sName, 5, 25.4 * (index * lH1_px + lH1_px) / dDpi - 2, 0, 0);
pRenderer->CommandDrawText(sFontName, 5, 25.4 * (index * lH1_px + lH1_px) / dDpi - 2, 0, 0);
pRenderer->BeginCommand(c_nResetClipType);
pRenderer->EndCommand(c_nResetClipType);

View File

@ -488,6 +488,7 @@ namespace NSFonts
virtual void SetFontMatrix(const double& fA, const double& fB, const double& fC, const double fD, double fE, double fF) = 0;
virtual int SetCMapForCharCode(long lUnicode, int *pnCMapIndex) = 0;
virtual double GetCharWidth(int gid) = 0;
};
namespace NSFontFile

View File

@ -172,15 +172,24 @@ namespace PdfReader
if (pEncryptDict->DictLookup("OE", &oOwnerEncryptionKey))
{
m_seOwnerEncryptionKey = oOwnerEncryptionKey.GetString()->Copy();
if (oOwnerEncryptionKey.IsString())
{
m_seOwnerEncryptionKey = oOwnerEncryptionKey.GetString()->Copy();
}
}
if (pEncryptDict->DictLookup("UE", &oUserEncryptionKey))
{
m_seUserEncryptionKey = oUserEncryptionKey.GetString()->Copy();
if (oUserEncryptionKey.IsString())
{
m_seUserEncryptionKey = oUserEncryptionKey.GetString()->Copy();
}
}
if (pEncryptDict->DictLookup("Perms", &oPermsValue))
{
m_sePermsValue = oPermsValue.GetString()->Copy();
if (oPermsValue.IsString())
{
m_sePermsValue = oPermsValue.GetString()->Copy();
}
}
if (oFileID.IsArray())