Compare commits

...

20 Commits

Author SHA1 Message Date
30a30d1bc6 [android][pe] fix runtime crash 2019-08-09 14:57:43 +03:00
d5d086d286 . 2019-08-08 13:14:43 +03:00
6822c8b7dd x2t - fix bug #42341 2019-08-08 12:12:49 +03:00
f4cdfc49bb [x2t] Fix typo 2019-08-07 17:03:29 +03:00
972f1ef4e5 [x2t] Add EffectProperties::fromPPTY; Fix EffectLst::fromPPTY 2019-08-05 18:07:56 +03:00
8fda74aefc [x2t] Fix bug 42288 2019-08-05 11:17:00 +03:00
7bba282321 [android][x2t] fix crash 2019-08-05 10:06:59 +03:00
8c8f59da80 [x2t] Add outlinePr to Editor.bin 2019-08-02 14:51:45 +03:00
3027a038d0 [x2t] Fix build 2019-08-02 11:31:43 +03:00
9c6ee2a171 [x2t] Fix NSStringExt::FindLastNotOf 2019-08-01 20:03:56 +03:00
e8d6092a95 Add return values to builder interface 2019-08-01 18:27:17 +03:00
3bc08e72dc Add return values to builder interface 2019-08-01 18:15:48 +03:00
c094962751 [x2t] Fix mailmerge 2019-07-29 16:23:48 +03:00
70f8abf0bf OdfFormat - fix users files 2019-07-29 13:38:18 +03:00
47318eef9c RtfFormatReader - fix users files 2019-07-26 17:33:24 +03:00
094a1d98d6 Add executable path to rpath 2019-07-26 16:55:00 +03:00
471219e59a [x2t] Fix dataValidations writing 2019-07-26 14:10:29 +03:00
2cfd2a0126 Change com object 2019-07-26 14:07:43 +03:00
f3ec039a01 Fix bug #42195
Fix the problem with reading EMF_BITBLT record in the EMF
2019-07-26 12:26:07 +03:00
f4795db0b8 Add allfonts path param 2019-07-26 11:30:21 +03:00
44 changed files with 1798 additions and 968 deletions

View File

@ -820,6 +820,16 @@ std::wstring docx_conversion_context::dump_settings_document()
{
CP_XML_NODE(L"w:mirrorMargins");
}
CP_XML_NODE(L"w:compat")
{
CP_XML_NODE(L"w:compatSetting")
{
CP_XML_ATTR(L"w:name", L"compatibilityMode" );
CP_XML_ATTR(L"w:uri", L"http://schemas.microsoft.com/office/word" );
CP_XML_ATTR(L"w:val", L"15" );
}
}
}
}
return output.str();

View File

@ -562,7 +562,6 @@ void Compute_GraphicFill(const common_draw_fill_attlist & props, const office_el
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * draw_a::ns = L"draw";
const wchar_t * draw_a::name = L"a";
/////////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -661,6 +661,10 @@ void dr3d_scene::serialize(std::wostream & _Wostream)
draw_shape::serialize(CP_XML_STREAM());
for (size_t i = 0; i < content_.size(); i++)
{
content_[i]->serialize(CP_XML_STREAM());
}
}
}
}
@ -771,5 +775,39 @@ void dr3d_sphere::serialize(std::wostream & _Wostream)
}
}
}
//-------------------------------------------------------------------------------------------
const wchar_t * draw_a::ns = L"draw";
const wchar_t * draw_a::name = L"a";
//-------------------------------------------------------------------------------------------
void draw_a::create_child_element( const std::wstring & Ns, const std::wstring & Name)
{
CP_CREATE_ELEMENT(content_);
}
void draw_a::add_child_element( const office_element_ptr & child_element)
{
if (!child_element) return;
content_.push_back(child_element);
}
void draw_a::serialize(std::wostream & _Wostream)
{
CP_XML_WRITER(_Wostream)
{
CP_XML_NODE_SIMPLE()
{
xlink_attlist_.serialize(CP_GET_XML_NODE());
CP_XML_ATTR_OPT(L"office:name", office_name_);
CP_XML_ATTR_OPT(L"text:style-name", text_style_name_);
CP_XML_ATTR_OPT(L"text:visited-style-name", text_visited_style_name_);
CP_XML_ATTR_OPT(L"office:target-frame-name",office_target_frame_name_);
for (size_t i = 0; i < content_.size(); i++)
{
content_[i]->serialize(CP_XML_STREAM());
}
}
}
}
}
}

View File

@ -34,6 +34,7 @@
#include "draw_base.h"
#include "common_attlists.h"
#include "targetframename.h"
namespace cpdoccore {
namespace odf_writer {
@ -553,5 +554,37 @@ public:
};
CP_REGISTER_OFFICE_ELEMENT2(dr3d_sphere);
//----------------------------------------------------------------------------------
// draw:a
//----------------------------------------------------------------------------------
class draw_a : public office_element_impl<draw_a>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const ElementType type = typeDrawA;
static const xml::NodeType xml_type = xml::typeElement;
CPDOCCORE_DEFINE_VISITABLE();
virtual void create_child_element(const std::wstring & Ns, const std::wstring & Name);
virtual void add_child_element( const office_element_ptr & child_element);
virtual void serialize(std::wostream & _Wostream);
office_element_ptr_array content_;
friend class odf_document;
odf_types::common_xlink_attlist xlink_attlist_;
_CP_OPT(std::wstring) office_name_;
_CP_OPT(odf_types::target_frame_name) office_target_frame_name_;
_CP_OPT(std::wstring) text_style_name_;
_CP_OPT(std::wstring) text_visited_style_name_;
};
CP_REGISTER_OFFICE_ELEMENT2(draw_a);
}
}

View File

@ -176,6 +176,7 @@ struct odf_drawing_state
void clear()
{
elements_.clear();
index_base = -1;
svg_x_ = boost::none;
svg_y_ = boost::none;
@ -248,6 +249,7 @@ struct odf_drawing_state
int oox_shape_preset_;
bool in_group_;
bool text_box_tableframe_;
int index_base;
};
@ -480,7 +482,7 @@ void odf_drawing_context::clear()
void odf_drawing_context::start_drawing()
{
//if (impl_->current_level_.size() < 1)
//if (impl_->current_level_.empty())
{
impl_->current_drawing_state_.svg_x_ = impl_->anchor_settings_.svg_x_;
impl_->current_drawing_state_.svg_y_ = impl_->anchor_settings_.svg_y_;
@ -500,7 +502,7 @@ void odf_drawing_context::start_drawing()
impl_->current_drawing_state_.svg_height_ = impl_->anchor_settings_.svg_height_;
}
//else
if (false == impl_->current_level_.empty())
if (false == impl_->current_level_.empty() && impl_->current_group_)
{
impl_->current_drawing_state_.in_group_ = true;
}
@ -522,7 +524,9 @@ void odf_drawing_context::end_drawing_background(odf_types::common_draw_fill_att
}
void odf_drawing_context::end_drawing()
{
draw_base* draw = impl_->current_drawing_state_.elements_.empty() ? NULL : dynamic_cast<draw_base*>(impl_->current_drawing_state_.elements_[0].elm.get());
int index = impl_->current_drawing_state_.index_base < 0 ? 0 : impl_->current_drawing_state_.index_base;
draw_base* draw = impl_->current_drawing_state_.elements_.empty() ? NULL : dynamic_cast<draw_base*>(impl_->current_drawing_state_.elements_[index].elm.get());
if (draw)
{
if (impl_->current_drawing_state_.presentation_class_ || impl_->current_drawing_state_.presentation_placeholder_)
@ -557,7 +561,7 @@ void odf_drawing_context::end_drawing()
_CP_OPT(double) rotate = impl_->current_drawing_state_.rotateAngle_;
if (impl_->current_drawing_state_.in_group_)
if (impl_->current_drawing_state_.in_group_ && impl_->current_group_)
{
odf_group_state_ptr gr = impl_->current_group_;
@ -618,7 +622,7 @@ void odf_drawing_context::end_drawing()
draw->common_draw_attlists_.rel_size_.common_draw_size_attlist_.svg_width_ = impl_->current_drawing_state_.svg_width_;
}
///////////////////////////////////////////////////////
presentation_placeholder * placeholder = impl_->current_drawing_state_.elements_.empty() ? NULL : dynamic_cast<presentation_placeholder*>(impl_->current_drawing_state_.elements_[0].elm.get());
presentation_placeholder * placeholder = impl_->current_drawing_state_.elements_.empty() ? NULL : dynamic_cast<presentation_placeholder*>(impl_->current_drawing_state_.elements_[index].elm.get());
if (placeholder)
{
placeholder->presentation_object_ = impl_->current_drawing_state_.presentation_class_;
@ -672,7 +676,7 @@ void odf_drawing_context::end_drawing()
if ( impl_->current_drawing_state_.elements_.empty() == false
&& impl_->current_drawing_state_.elements_[0].level == 0
&& impl_->current_drawing_state_.elements_[0].elm )
&& impl_->current_drawing_state_.elements_[0].elm ) // не base_index -> см draw_a
{
impl_->tops_elements_.push_back(impl_->current_drawing_state_.elements_[0].elm);
}
@ -772,6 +776,10 @@ void odf_drawing_context::Impl::create_draw_base(int type)
odf_element_state state={draw_elm, style_name, style_shape_elm, level};
if (current_drawing_state_.index_base < 0)
{
current_drawing_state_.index_base = (int)current_drawing_state_.elements_.size();
}
current_drawing_state_.elements_.push_back(state);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -1825,14 +1833,14 @@ void odf_drawing_context::set_vertical_rel(int from)
switch(from)
{
case 0: type = vertical_rel::Baseline; break;// relfromvBottomMargin ???
case 1: type = vertical_rel::PageContent; break;// relfromvInsideMargin ???
case 2: type = vertical_rel::Baseline; break;// relfromvLine
case 3: type = vertical_rel::PageContent; break;// relfromvMargin //Paragraph
case 4: type = vertical_rel::Baseline; break;// relfromvOutsideMargin ???
case 5: type = vertical_rel::Page; break;// relfromvPage
case 6: type = vertical_rel::Paragraph; break;// relfromvParagraph
case 7: type = vertical_rel::Baseline; break;// relfromvTopMargin ???
case 0: type = vertical_rel::Baseline; break;// relfromvBottomMargin ???
case 1: type = vertical_rel::ParagraphContent; break;// relfromvInsideMargin ???
case 2: type = vertical_rel::Baseline; break;// relfromvLine
case 3: type = vertical_rel::PageContent; break;// relfromvMargin //Paragraph
case 4: type = vertical_rel::Baseline; break;// relfromvOutsideMargin ???
case 5: type = vertical_rel::Page; break;// relfromvPage
case 6: type = vertical_rel::Paragraph; break;// relfromvParagraph
case 7: type = vertical_rel::Baseline; break;// relfromvTopMargin ???
}
impl_->anchor_settings_.style_vertical_rel_ = vertical_rel(type);
@ -2550,12 +2558,9 @@ void odf_drawing_context::start_image(std::wstring odf_path)
start_frame();
////добавить в стиль ссыль на базовый стиль Frame - зачемто нужно :(
//style* style_ = dynamic_cast<style*>(impl_->current_drawing_state_.elements_.back().style_elm.get());
//if (style_)
//{
// style_->style_parent_style_name_ = L"Frame";
//}
//добавить в стиль ссыль на базовый стиль Graphics - зачемто нужно :(
set_parent_style(L"Graphics");
///////////////////////////////////////////////////////////////////////////////////////////////
office_element_ptr image_elm;
create_element(L"draw", L"image", image_elm, impl_->odf_context_);
@ -2672,13 +2677,13 @@ void odf_drawing_context::start_text_box()
start_frame();
//if (impl_->is_footer_ ==false && impl_->is_header_ ==false)
// set_parent_style(L"Frame");
office_element_ptr text_box_elm;
create_element(L"draw", L"text-box", text_box_elm, impl_->odf_context_);
start_element(text_box_elm);
//if (impl_->is_footer_ ==false && impl_->is_header_ ==false)
// set_text_box_parent_style(L"Frame");
}
void odf_drawing_context::set_text_box_min_size(bool val)
{
@ -2763,12 +2768,47 @@ void odf_drawing_context::start_action(std::wstring value)
}
}
}
void odf_drawing_context::start_link_object(std::wstring href)
{
if (href.empty()) return;
office_element_ptr element, style;
create_element(L"draw", L"a", element, impl_->odf_context_);
size_t level = impl_->current_level_.size();
if (false == impl_->current_level_.empty())
impl_->current_level_.back()->add_child_element(element);
impl_->current_level_.push_back(element);
odf_element_state state={element, L"", style, level};
impl_->current_drawing_state_.elements_.push_back(state);
if (impl_->root_element_ == NULL)
{
impl_->root_element_ = element;
impl_->anchor_settings_.anchor_type_ = anchor_type::Paragraph;
}
draw_a* draw_a_ = dynamic_cast<draw_a*>(impl_->current_level_.back().get());
if (draw_a_)
{
draw_a_->xlink_attlist_.href_ = href;
draw_a_->xlink_attlist_.type_ = xlink_type::Simple;
draw_a_->xlink_attlist_.show_ = xlink_show::Embed;
draw_a_->xlink_attlist_.actuate_ = xlink_actuate::OnRequest;
}
}
void odf_drawing_context::end_link_object()
{
end_element();
}
void odf_drawing_context::add_link(std::wstring href)
{
if (href.empty()) return;
presentation_event_listener * event_ = dynamic_cast<presentation_event_listener*>(impl_->current_level_.back().get());
presentation_event_listener* event_ = dynamic_cast<presentation_event_listener*>(impl_->current_level_.back().get());
if (event_)
{
@ -2831,7 +2871,7 @@ void odf_drawing_context::set_text_box_tableframe(bool val)
impl_->current_drawing_state_.text_box_tableframe_ = val;
}
void odf_drawing_context::set_text_box_parent_style(std::wstring style_name)
void odf_drawing_context::set_parent_style(std::wstring style_name)
{
if (impl_->current_drawing_state_.elements_.empty()) return;
@ -2978,7 +3018,10 @@ bool odf_drawing_context::is_exist_content()
{
return (impl_->drawing_list_.empty() ? false : true);
}
bool odf_drawing_context::is_current_empty()
{
return impl_->current_drawing_state_.elements_.empty();
}
void odf_drawing_context::finalize(office_element_ptr & root_elm)//для привязки
{
for (size_t i = 0; i < impl_->tops_elements_.size(); i++)
@ -3624,12 +3667,17 @@ void odf_drawing_context::set_image_client_rect_inch(double l, double t, double
//<top>, <right>, <bottom>, <left>
std::wstringstream str_stream;
str_stream << std::wstring(L"rect(")
<< t << std::wstring(L"in, ")
<< r << std::wstring(L"in, ")
<< b << std::wstring(L"in, ")
<< l << std::wstring(L"in)");
//str_stream << std::wstring(L"rect(")
// << t << std::wstring(L"in, ")
// << r << std::wstring(L"in, ")
// << b << std::wstring(L"in, ")
// << l << std::wstring(L"in)");
str_stream << std::wstring(L"rect(")
<< (t * 2.54) << std::wstring(L"cm, ")
<< (r * 2.54) << std::wstring(L"cm, ")
<< (b * 2.54) << std::wstring(L"cm, ")
<< (l * 2.54) << std::wstring(L"cm)");
impl_->current_graphic_properties->fo_clip_ = str_stream.str();
}
@ -3660,7 +3708,7 @@ void odf_drawing_context::set_bitmap_tile_scale_x(double scale_x)
if (!impl_->current_graphic_properties)return;
impl_->current_graphic_properties->common_draw_fill_attlist_.draw_fill_image_width_ =
length(length(scale_x,length::pt).get_value_unit(length::cm),length::cm);
length(length(scale_x,length::pt).get_value_unit(length::inch), length::inch);
}
void odf_drawing_context::set_bitmap_tile_scale_y(double scale_y)
@ -3668,7 +3716,7 @@ void odf_drawing_context::set_bitmap_tile_scale_y(double scale_y)
if (!impl_->current_graphic_properties)return;
impl_->current_graphic_properties->common_draw_fill_attlist_.draw_fill_image_height_ =
length(length(scale_y,length::pt).get_value_unit(length::cm),length::cm);
length(length(scale_y,length::pt).get_value_unit(length::inch), length::inch);
}
void odf_drawing_context::set_bitmap_tile_translate_y(double y)

View File

@ -67,6 +67,8 @@ public:
void clear ();
void set_styles_context (odf_style_context* styles_context);//для embedded
void set_parent_style (std::wstring style_name);
void set_header_state (bool Val);
void set_footer_state (bool Val);
void set_background_state (bool Val);
@ -139,7 +141,6 @@ public:
void start_text_box ();
void set_text_box_min_size (bool val);
void set_text_box_min_size (double w_pt, double h_pt);
void set_text_box_parent_style (std::wstring style_name);
void set_text_box_tableframe (bool val);
void end_text_box ();
@ -155,6 +156,9 @@ public:
void start_media(std::wstring ref);
void end_media();
void start_link_object(std::wstring href);
void end_link_object();
void add_image_replacement();
void set_image_replacement(std::wstring ref);
@ -171,6 +175,7 @@ public:
void end_element ();
bool is_exist_content();
bool is_current_empty();
//////////////////////////////////////////////////////////////////////////////////////
void set_path (std::wstring path_string);
void add_path_element (std::wstring command, std::wstring elm);

View File

@ -104,7 +104,7 @@ void odf_text_context::set_single_object(bool bSingle, style_paragraph_propertie
void odf_text_context::add_text_content(const std::wstring & text)
{
if (current_level_.size() < 1) return;
if (current_level_.empty()) return;
//boost::wregex re(L"?:([ ]{2,})|(.+)");//(L"(\\w+)");
//std::list<std::wstring> result;
@ -361,7 +361,7 @@ void odf_text_context::start_span(bool styled)
text_elements_list_.push_back(state);
if (current_level_.size()>0)
if (false == current_level_.empty())
current_level_.back().elm->add_child_element(span_elm);
current_level_.push_back(state);
@ -371,7 +371,7 @@ void odf_text_context::end_span()
{
if (styles_context_ == NULL || single_paragraph_)return;
if (false == current_level_.empty())
if (false == current_level_.empty() && dynamic_cast<text_span*>(current_level_.back().elm.get()))
current_level_.pop_back();
text_properties_ = NULL;
@ -380,7 +380,7 @@ void odf_text_context::end_span()
void odf_text_context::start_list_item()
{
if (styles_context_ == NULL || single_paragraph_)return;
if (list_state_.levels.size() < 1) return;
if (list_state_.levels.empty()) return;
if (list_state_.levels.back()) end_list_item();
@ -406,7 +406,7 @@ void odf_text_context::start_list_item()
void odf_text_context::end_list_item()
{
if (styles_context_ == NULL || single_paragraph_) return;
if (list_state_.levels.size() < 1) return;
if (list_state_.levels.empty()) return;
if (list_state_.levels.back() == false) return;
@ -456,7 +456,7 @@ bool odf_text_context::start_list(std::wstring style_name) //todoooo add new_num
void odf_text_context::end_list()
{
if (styles_context_ == NULL || single_paragraph_)return;
if (list_state_.levels.size() < 1) return;
if (list_state_.levels.empty()) return;
if (list_state_.levels.back()) end_list_item();
@ -541,9 +541,9 @@ void odf_text_context::set_outline_level(int level)
void odf_text_context::add_text_style(office_element_ptr & style_elm, std::wstring style_name)
{
if (style_name.size() < 1 || !style_elm)return;
if (style_name.empty() || !style_elm)return;
if (current_level_.size() < 1 )return;
if (current_level_.empty() )return;
if (text_span* span = dynamic_cast<text_span*>(current_level_.back().elm.get()))
{

View File

@ -284,7 +284,14 @@ void odt_conversion_context::end_drawings()
}
}
}
if (!bSet) text_context()->current_level_.back().elm->add_child_element(elm);
if (!bSet)
{
if (text_context()->current_level_.size() > 1 && dynamic_cast<text_span*>(text_context()->current_level_.back().elm.get()))
{
text_context()->end_span();
}
text_context()->current_level_.back().elm->add_child_element(elm);
}
drawing_context()->clear();
drawing_context_.pop_back();
@ -845,12 +852,14 @@ void odt_conversion_context::separate_field()
}
void odt_conversion_context::set_master_page_name(std::wstring master_name)
{
if (current_root_elements_.size() < 1)// return; - эффект_штурмовика.docx - 1 страница !! (и ваще -
if (current_root_elements_.empty())// return; - эффект_штурмовика.docx - 1 страница !! (и ваще -
{
is_paragraph_in_current_section_ = true;
return;
}
if (current_master_page_ == master_name) return; // Newslette.docx
style *style_ = dynamic_cast<style*>(current_root_elements_.back().style_elm.get());
if (style_)
@ -863,6 +872,7 @@ void odt_conversion_context::set_master_page_name(std::wstring master_name)
if (text_context()->set_master_page_name(master_name))
is_paragraph_in_current_section_ = false;
}
current_master_page_ = master_name;
}
int odt_conversion_context::get_current_section_columns()
{
@ -930,7 +940,7 @@ void odt_conversion_context::add_section_columns(int count, double space_pt, boo
}
void odt_conversion_context::add_section_column(std::vector<std::pair<double, double>> width_space)
{
if (sections_.size() < 1 || width_space.size() < 1) return;
if (sections_.empty() || width_space.empty()) return;
style* style_ = dynamic_cast<style*>(sections_.back().style_elm.get());
if (!style_)return;
@ -1044,7 +1054,7 @@ void odt_conversion_context::start_list_item(int level, std::wstring style_name
text_context()->end_list();
}
if (text_context()->list_state_.levels.size() < 1)
if (text_context()->list_state_.levels.empty())
{
text_context()->list_state_.started_list = false;
text_context()->list_state_.style_name = L"";

View File

@ -198,6 +198,8 @@ private:
bool is_header_;
bool is_footer_;
bool is_background_;
std::wstring current_master_page_;
std::vector<odf_drawing_context_ptr> drawing_context_;
std::vector<odf_text_context_ptr> text_context_; //for embedded

View File

@ -360,7 +360,10 @@ void OoxConverter::convert(PPTX::Logic::Pic *oox_picture)
{
double Width = 0, Height = 0;
_graphics_utils_::GetResolution(pathImage.c_str(), Width, Height);
//inch
Width /= 96;
Height /= 96;
if (oox_picture->blipFill.tile.IsInit())
{
odf_context()->drawing_context()->set_image_style_repeat(2);
@ -371,11 +374,12 @@ void OoxConverter::convert(PPTX::Logic::Pic *oox_picture)
}
if (oox_picture->blipFill.srcRect.IsInit() && Width > 0 && Height >0 )
{
odf_context()->drawing_context()->set_image_client_rect_inch(
XmlUtils::GetInteger(oox_picture->blipFill.srcRect->l.get_value_or(L"0")) * Width /100. / 96.,
XmlUtils::GetInteger(oox_picture->blipFill.srcRect->t.get_value_or(L"0")) * Height /100. / 96.,
XmlUtils::GetInteger(oox_picture->blipFill.srcRect->r.get_value_or(L"0")) * Width /100. / 96.,
XmlUtils::GetInteger(oox_picture->blipFill.srcRect->b.get_value_or(L"0")) * Height /100. / 96.);
double l = XmlUtils::GetInteger( oox_picture->blipFill.srcRect->l.get_value_or(L"0")) /100000.;
double t = XmlUtils::GetInteger( oox_picture->blipFill.srcRect->t.get_value_or(L"0")) /100000.;
double r = XmlUtils::GetInteger( oox_picture->blipFill.srcRect->r.get_value_or(L"0")) /100000.;
double b = XmlUtils::GetInteger( oox_picture->blipFill.srcRect->b.get_value_or(L"0")) /100000.;
odf_context()->drawing_context()->set_image_client_rect_inch( l * Width, t * Height, r * Width, b * Height );
}
if (oox_picture->blipFill.blip.IsInit())
{
@ -1150,6 +1154,9 @@ void OoxConverter::convert(PPTX::Logic::BlipFill *oox_bitmap_fill)
{
odf_context()->drawing_context()->set_bitmap_link(pathImage);
_graphics_utils_::GetResolution(pathImage.c_str(), Width, Height);
Width /= 96; //to inch (current dpi file)
Height /= 96;
}
}
else if (oox_bitmap_fill->blip->link.IsInit())
@ -1167,10 +1174,10 @@ void OoxConverter::convert(PPTX::Logic::BlipFill *oox_bitmap_fill)
if (oox_bitmap_fill->srcRect.IsInit() && Width > 0 && Height > 0)//часть изображения
{
odf_context()->drawing_context()->set_image_client_rect_inch(
(oox_bitmap_fill->srcRect->l.IsInit() ? XmlUtils::GetInteger(oox_bitmap_fill->srcRect->l.get()) : 0 ) /100. * Width / 96.,
(oox_bitmap_fill->srcRect->t.IsInit() ? XmlUtils::GetInteger(oox_bitmap_fill->srcRect->t.get()) : 0 ) /100. * Height/ 96.,
(oox_bitmap_fill->srcRect->r.IsInit() ? XmlUtils::GetInteger(oox_bitmap_fill->srcRect->r.get()) : 0 ) /100. * Width / 96.,
(oox_bitmap_fill->srcRect->b.IsInit() ? XmlUtils::GetInteger(oox_bitmap_fill->srcRect->b.get()) : 0 ) /100. * Height/ 96.);
(oox_bitmap_fill->srcRect->l.IsInit() ? XmlUtils::GetInteger(oox_bitmap_fill->srcRect->l.get()) : 0 ) / 100000. * Width,
(oox_bitmap_fill->srcRect->t.IsInit() ? XmlUtils::GetInteger(oox_bitmap_fill->srcRect->t.get()) : 0 ) / 100000. * Height,
(oox_bitmap_fill->srcRect->r.IsInit() ? XmlUtils::GetInteger(oox_bitmap_fill->srcRect->r.get()) : 0 ) / 100000. * Width,
(oox_bitmap_fill->srcRect->b.IsInit() ? XmlUtils::GetInteger(oox_bitmap_fill->srcRect->b.get()) : 0 ) / 100000. * Height);
}
if (oox_bitmap_fill->tile.IsInit())
{
@ -1515,22 +1522,34 @@ void OoxConverter::convert(PPTX::Logic::CNvPr *oox_cnvPr)
}
if (oox_cnvPr->hlinkClick.IsInit())
{
odf_context()->drawing_context()->start_action(oox_cnvPr->hlinkClick->action.get_value_or(L""));
if (oox_cnvPr->hlinkClick->snd.IsInit())
{
std::wstring sound = find_link_by_id(oox_cnvPr->hlinkClick->snd->embed.get(), 3);
std::wstring href = odf_context()->add_media(sound);
odf_context()->drawing_context()->add_sound(href);
}
if (odf_context()->drawing_context()->is_current_empty())
{
if (oox_cnvPr->hlinkClick->id.IsInit())
{
std::wstring hlink = find_link_by_id(oox_cnvPr->hlinkClick->id.get(), 2);
odf_context()->drawing_context()->add_link(hlink);
odf_context()->drawing_context()->start_link_object(hlink);
}
odf_context()->drawing_context()->end_action();
}
else
{
odf_context()->drawing_context()->start_action(oox_cnvPr->hlinkClick->action.get_value_or(L""));
if (oox_cnvPr->hlinkClick->snd.IsInit())
{
std::wstring sound = find_link_by_id(oox_cnvPr->hlinkClick->snd->embed.get(), 3);
std::wstring href = odf_context()->add_media(sound);
odf_context()->drawing_context()->add_sound(href);
}
if (oox_cnvPr->hlinkClick->id.IsInit())
{
std::wstring hlink = find_link_by_id(oox_cnvPr->hlinkClick->id.get(), 2);
odf_context()->drawing_context()->add_link(hlink);
}
odf_context()->drawing_context()->end_action();
}
}
//nullable_string title;
//nullable<Hyperlink> hlinkHover;

View File

@ -1186,25 +1186,39 @@ void DocxConverter::convert(OOX::Logic::CParagraphProperty *oox_paragraph_pr, cp
if (oox_paragraph_pr->m_oPStyle.IsInit() && oox_paragraph_pr->m_oPStyle->m_sVal.IsInit())
{
std::wstring style_name = *oox_paragraph_pr->m_oPStyle->m_sVal;
odt_context->styles_context()->last_state()->set_parent_style_name(style_name);
/////////////////////////find parent properties
/////////////////////////find parent properties
odf_writer::style_paragraph_properties parent_paragraph_properties;
odt_context->styles_context()->calc_paragraph_properties(style_name, odf_types::style_family::Paragraph, &parent_paragraph_properties.content_);
odf_writer::style_text_properties parent_text_properties;
odt_context->styles_context()->calc_text_properties(style_name, odf_types::style_family::Paragraph, &parent_text_properties.content_);
odf_writer::odf_style_state_ptr style_state;
style_state = odt_context->styles_context()->last_state();
odf_writer::odf_drawing_context* drawing_context = odt_context->drawing_context();
if ((drawing_context) && (false == drawing_context->is_current_empty()))
{
paragraph_properties->apply_from(&parent_paragraph_properties);
odf_writer::style_text_properties* text_props = style_state->get_text_properties();
text_props->apply_from(&parent_text_properties);
}
else
{
style_state->set_parent_style_name(style_name);
}
if (parent_paragraph_properties.content_.outline_level_)
{
outline_level = *parent_paragraph_properties.content_.outline_level_;
}
//список тож явно ??? угу :( - выше + велосипед для хранения
odf_writer::style_text_properties parent_text_properties;
odt_context->styles_context()->calc_text_properties(style_name, odf_types::style_family::Paragraph, &parent_text_properties.content_);
if (parent_text_properties.content_.fo_font_size_)
{
current_font_size.push_back(parent_text_properties.content_.fo_font_size_->get_length().get_value_unit(odf_types::length::pt));
}
}
if (oox_paragraph_pr->m_oSpacing.IsInit())
@ -2236,22 +2250,24 @@ void DocxConverter::convert(OOX::Logic::CRunProperty *oox_run_pr, odf_writer::st
{
std::wstring style_name = *oox_run_pr->m_oRStyle->m_sVal;
odf_writer::odf_style_state_ptr style_state;
//if (is_list_styles)
//{
// style_state = odt_context->styles_context()->lists_styles()->last_state();
//}
//else
{
style_state = odt_context->styles_context()->last_state();
}
if (style_state)
{
style_state->set_parent_style_name(style_name);
}
odf_writer::style_text_properties parent_text_properties;
odt_context->styles_context()->calc_text_properties(style_name, odf_types::style_family::Text, &parent_text_properties.content_);
odf_writer::odf_style_state_ptr style_state;
style_state = odt_context->styles_context()->last_state();
if (style_state)
{
odf_writer::odf_drawing_context* drawing_context = odt_context->drawing_context();
if ((drawing_context) && (false == drawing_context->is_current_empty()))
{
text_properties->apply_from(&parent_text_properties);
}
else
{
style_state->set_parent_style_name(style_name);
}
}
if (parent_text_properties.content_.fo_font_size_)
{
@ -3027,6 +3043,16 @@ void DocxConverter::convert(OOX::Drawing::CAnchor *oox_anchor)
odt_context->drawing_context()->set_object_foreground(true);
}
}
if ((oox_anchor->m_oLayoutInCell.IsInit()) && (oox_anchor->m_oLayoutInCell->ToBool()))
{
if (odt_context->table_context()->empty() == false)
{//VillageofSchaumburg.docx
odt_context->drawing_context()->set_anchor(3);
odt_context->drawing_context()->set_vertical_rel(1); //paragraph content
odt_context->drawing_context()->set_horizontal_rel(1); //paragraph
}
}
if (oox_anchor->m_oRelativeHeight.IsInit())
{
int id = oox_anchor->m_oRelativeHeight->GetValue();
@ -3372,8 +3398,13 @@ void DocxConverter::convert(OOX::CDocDefaults *def_style)
/////////////////////////////////////////////////////////////////////////////////////////////////
//зачемто ?! для OpenOffice для врезок/фреймов нужен базовый стиль - без него другой тип геометрии oO !!!
odt_context->styles_context()->create_style(L"Frame", odf_types::style_family::Graphic,false, true);
odf_writer::graphic_format_properties * graphic_properties = odt_context->styles_context()->last_state()->get_graphic_properties();
odt_context->styles_context()->create_style(L"Frame", odf_types::style_family::Graphic, false, true);
odf_writer::graphic_format_properties* graphic_properties = odt_context->styles_context()->last_state()->get_graphic_properties();
//для image ?!
odt_context->styles_context()->create_style(L"Graphics", odf_types::style_family::Graphic, false, true);
graphic_properties = odt_context->styles_context()->last_state()->get_graphic_properties();
//if (graphic_properties)graphic_properties->content_.common_background_color_attlist_.fo_background_color_ = odf_types::background_color(odf_types::background_color::Transparent);
}
@ -4053,7 +4084,7 @@ void DocxConverter::convert(OOX::Logic::CTbl *oox_table)
odt_context->drawing_context()->set_text_box_tableframe(true);
odt_context->drawing_context()->set_text_box_min_size(0, 1.);
odt_context->drawing_context()->set_z_order(0x7fffffff - 1024/* + id_tables*/);
odt_context->drawing_context()->set_text_box_parent_style(L"Frame");
odt_context->drawing_context()->set_parent_style(L"Frame");
odt_context->drawing_context()->set_name(L"TableFrame");
odt_context->start_text_context();
}

View File

@ -53,7 +53,7 @@
namespace _graphics_utils_
{
bool GetResolution(const wchar_t* fileName, double & Width, double &Height) //pt
bool GetResolution(const wchar_t* fileName, double & Width, double &Height) //px
{
NSFile::CFileBinary file;
if (false == file.OpenFile(fileName)) return false;
@ -62,7 +62,7 @@ namespace _graphics_utils_
file.CloseFile();
if (file_size < 1) return false;
bool result =false;
bool result = false;
CBgraFrame image;
if (result = image.OpenFile(fileName, 0 ))

View File

@ -81,7 +81,7 @@ namespace PPTX
}
std::wstring EffectLst::toXML() const
{
std::wstring str = _T("<a:effectLst>");
std::wstring str;
if (blur.IsInit()) str += blur->toXML();
if (fillOverlay.IsInit()) str += fillOverlay->toXML();
if (glow.IsInit()) str += glow->toXML();
@ -91,11 +91,20 @@ namespace PPTX
if (reflection.IsInit()) str += reflection->toXML();
if (softEdge.IsInit()) str += softEdge->toXML();
str += _T("</a:effectLst>");
if (false == str.empty())
{
str += L"<a:effectLst>" + str + L"</a:effectLst>";
}
return str;
}
void EffectLst::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const
{
if (!blur.IsInit() && !fillOverlay.IsInit() && !glow.IsInit() && !innerShdw.IsInit() &&
!outerShdw.IsInit() && !prstShdw.IsInit() && !reflection.IsInit() && !softEdge.IsInit())
{
return;
}
pWriter->StartNode(L"a:effectLst");
pWriter->EndAttributes();
@ -131,14 +140,6 @@ namespace PPTX
BYTE _type = pReader->GetUChar();
LONG _end_rec = pReader->GetPos() + pReader->GetLong() + 4;
pReader->Skip(1);
while (true)
{
BYTE _at = pReader->GetUChar_TypeNode();
if (_at == NSBinPptxRW::g_nodeAttributeEnd)
break;
}
while (pReader->GetPos() < _end_rec)
{
BYTE _at = pReader->GetUChar();

View File

@ -35,7 +35,31 @@ namespace PPTX
{
namespace Logic
{
void EffectProperties::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader)
{
LONG pos = pReader->GetPos();
ULONG rec_len = pReader->GetULong();
if (0 == rec_len)
return;
BYTE rec = pReader->GetUChar();
switch(rec)
{
case EFFECTPROPERTIES_TYPE_LIST: List = new PPTX::Logic::EffectLst(); break;
case EFFECT_TYPE_DAG: List = new PPTX::Logic::EffectDag(); break;
}
pReader->Seek(pos);
if (List.is_init())
{
List->fromPPTY(pReader);
}
else
{
pReader->SkipRecord();
}
}
} // namespace Logic
} // namespace PPTX

View File

@ -116,6 +116,7 @@ namespace PPTX
if (List.is_init())
List->toPPTY(pWriter);
}
virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader);
virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const
{
if (List.is_init())
@ -135,4 +136,4 @@ namespace PPTX
} // namespace Logic
} // namespace PPTX
#endif // PPTX_LOGIC_EFFECTPROPERTIES_INCLUDE_H
#endif // PPTX_LOGIC_EFFECTPROPERTIES_INCLUDE_H

View File

@ -122,7 +122,20 @@ namespace PPTX
pWriter->WriteAttribute(L"prst", prst.get());
pWriter->EndAttributes();
Color.toXmlWriter(pWriter);
if (Color.is_init())
{
Color.toXmlWriter(pWriter);
}
else
{
pWriter->StartNode(L"a:scrgbClr");
pWriter->StartAttributes();
pWriter->WriteAttribute(L"r", 0);
pWriter->WriteAttribute(L"g", 0);
pWriter->WriteAttribute(L"b", 0);
pWriter->EndAttributes();
pWriter->EndNode(L"a:scrgbClr");
}
pWriter->EndNode(L"a:prstShdw");
}

View File

@ -232,12 +232,12 @@ std::wstring RtfFont::RenderToOOX(RenderParameter oRenderParameter)
else
{
RtfFont oCurFont;
if( true == poRtfDocument->m_oFontTable.GetFont(m_nID,oCurFont) )
if( true == poRtfDocument->m_oFontTable.GetFont(m_nID, oCurFont) )
{
std::wstring sHint;
switch(m_nCharset)
switch(oCurFont.m_nCharset)
{
case 128://Japanese
//case 128://Japanese //vedomost.rtf ????
case 129://Korean
case 130://Korean
case 134://China

View File

@ -275,7 +275,7 @@ public:
if(sResult.length() > 0)
{
std::string str;
ExecuteTextInternalSkipChars (sResult, oReader, str, nSkipChars);
// ExecuteTextInternalSkipChars (sResult, oReader, str, nSkipChars); //vedomost.rtf
ExecuteText ( oDocument, oReader, sResult);
}
}

View File

@ -1186,6 +1186,7 @@ namespace OOX
et_x_ConditionalFormatValueObject,
et_x_ConditionalFormatIconSet,
et_x_PageSetUpPr,
et_x_OutlinePr,
et_x_SheetPr,
et_x_Pane,
et_x_ExternalBook,

View File

@ -96,7 +96,7 @@ void CDataValidation::toXML2(NSStringUtils::CStringBuilder& writer, bool bExtend
if (m_oFormula2.IsInit())
{
writer.WriteString(L"<x14:formula2>");
m_oFormula1->toXML2(writer, true);
m_oFormula2->toXML2(writer, true);
writer.WriteString(L"</x14:formula2>");
}
if (m_oSqRef.IsInit())

View File

@ -750,6 +750,62 @@ namespace OOX
nullable<SimpleTypes::COnOff<>> m_oAutoPageBreaks;
nullable<SimpleTypes::COnOff<>> m_oFitToPage;
};
class COutlinePr : public WritingElement
{
public:
WritingElement_AdditionConstructors(COutlinePr)
COutlinePr()
{
}
virtual ~COutlinePr()
{
}
virtual void fromXML(XmlUtils::CXmlNode& node)
{
}
virtual std::wstring toXML() const
{
return _T("");
}
virtual void toXML(NSStringUtils::CStringBuilder& writer) const
{
writer.WriteString(_T("<outlinePr"));
WritingStringNullableAttrBool(L"applyStyles", m_oApplyStyles);
WritingStringNullableAttrBool(L"showOutlineSymbols", m_oShowOutlineSymbols);
WritingStringNullableAttrBool(L"summaryBelow", m_oSummaryBelow);
WritingStringNullableAttrBool(L"summaryRight", m_oSummaryRight);
writer.WriteString(_T("/>"));
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( !oReader.IsEmptyNode() )
oReader.ReadTillEnd();
}
virtual EElementType getType () const
{
return et_x_OutlinePr;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
// Читаем атрибуты
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("applyStyles"), m_oApplyStyles )
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("showOutlineSymbols"), m_oShowOutlineSymbols )
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("summaryBelow"), m_oSummaryBelow )
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("summaryRight"), m_oSummaryRight )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::COnOff<>> m_oApplyStyles;
nullable<SimpleTypes::COnOff<>> m_oShowOutlineSymbols;
nullable<SimpleTypes::COnOff<>> m_oSummaryBelow;
nullable<SimpleTypes::COnOff<>> m_oSummaryRight;
};
class CSheetPr : public WritingElement
{
public:
@ -784,6 +840,10 @@ namespace OOX
{
m_oTabColor->toXML2(writer, _T("tabColor"));
}
if (m_oOutlinePr.IsInit())
{
m_oOutlinePr->toXML(writer);
}
if (m_oPageSetUpPr.IsInit())
{
m_oPageSetUpPr->toXML(writer);
@ -805,10 +865,10 @@ namespace OOX
if ( _T("tabColor") == sName )
m_oTabColor = oReader;
if ( _T("pageSetUpPr") == sName )
else if ( _T("pageSetUpPr") == sName )
m_oPageSetUpPr = oReader;
//необработано:
//<outlinePr>
else if ( _T("outlinePr") == sName )
m_oOutlinePr = oReader;
}
}
virtual EElementType getType () const
@ -836,6 +896,7 @@ namespace OOX
public:
nullable<CColor> m_oTabColor;
nullable<CPageSetUpPr> m_oPageSetUpPr;
nullable<COutlinePr> m_oOutlinePr;
nullable<std::wstring> m_oCodeName;
nullable<SimpleTypes::COnOff<>> m_oEnableFormatConditionsCalculation;

View File

@ -35,6 +35,8 @@ core_windows {
core_linux {
LIBS += -lz -pthread
QMAKE_LFLAGS += -Wl,--rpath=./
}
SOURCES += main.cpp

View File

@ -29,6 +29,8 @@ core_windows {
core_linux {
LIBS += -lz -pthread
QMAKE_LFLAGS += -Wl,--rpath=./
}
SOURCES += main.cpp

View File

@ -235,6 +235,7 @@ int main(int argc, char** argv)
std::wstring sSrcThemesDir = L"";
std::wstring sX2tPath = L"";
std::wstring sOutputThumbnails = L"";
std::wstring sAllFonts = L"";
bool bIsNeedCorrectSdkAll = false;
for (int i = 0; i < argc; ++i)
@ -281,6 +282,10 @@ int main(int argc, char** argv)
bIsNeedCorrectSdkAll = true;
}
}
else if (sKey == L"--allfonts")
{
sAllFonts = sValue;
}
}
}
@ -328,8 +333,13 @@ int main(int argc, char** argv)
oBuilder.WriteString(L"</m_sFileFrom><m_sFileTo>");
oBuilder.WriteEncodeXmlString(sOut + L"/theme.bin");
oBuilder.WriteString(L"</m_sFileTo><m_nFormatTo>8192</m_nFormatTo><m_sThemeDir>./</m_sThemeDir>");
oBuilder.WriteString(L"<m_bDontSaveAdditional>true</m_bDontSaveAdditional><m_sAllFontsPath>");
oBuilder.WriteString(L"AllFonts.js</m_sAllFontsPath>");
oBuilder.WriteString(L"<m_bDontSaveAdditional>true</m_bDontSaveAdditional>");
if (!sAllFonts.empty())
{
oBuilder.WriteString(L"<m_sAllFontsPath>");
oBuilder.WriteString(sAllFonts);
oBuilder.WriteString(L"</m_sAllFontsPath>");
}
oBuilder.WriteString(L"</TaskQueueDataConvert>");
std::wstring sXmlConvert = oBuilder.GetData();
@ -373,7 +383,7 @@ int main(int argc, char** argv)
std::wstring sXmlDoctRenderer = oBuilder.GetData();
NSDoctRenderer::CDoctrenderer oRenderer;
oRenderer.LoadConfig(sX2tPath);
oRenderer.LoadConfig(sX2tPath, sAllFonts);
std::wstring sError;
bool bIsSuccess = oRenderer.Execute(sXmlDoctRenderer, sError);

View File

@ -267,7 +267,8 @@ namespace NSStringExt
}
static inline long FindLastNotOf(const wchar_t* str, unsigned int unLen, const wchar_t* chars)
{
long res = unLen - 1;
long res = unLen;
res--;
while(res >= 0)
{
long index = 0;

View File

@ -35,7 +35,7 @@
//
#define IDS_PROJNAME 100
#define IDR_ASCDOCBUILDER 101
#define IDR_ONLYOFFICEDOCBUILDER 101
// Next default values for new objects
//

View File

@ -0,0 +1,17 @@
SET SCRIPTPATH=%~dp0
CD /D %~dp0
SET VC64_PATH=%ProgramFiles(x86)%\Microsoft Visual Studio 14.0\Common7\IDE
SET VC32_PATH=%ProgramFiles%\Microsoft Visual Studio 14.0\Common7\IDE
setlocal enabledelayedexpansion
if defined ProgramFiles(x86) (
SET PATH=!VC64_PATH!;!PATH!
) else (
SET PATH=!VC32_PATH!;!PATH!
)
call devenv docbuilder.com.sln /Rebuild "Release|x64"
call devenv docbuilder.com.sln /Rebuild "Release|Win32"
exit /b 0

View File

@ -37,9 +37,9 @@
#include "docbuilder.h"
// The module attribute causes DllMain, DllRegisterServer and DllUnregisterServer to be automatically implemented for you
[ module(dll, uuid = "{B43F4AFD-2278-4175-992C-D7AE390507D8}",
name = "ascdocbuilder",
helpstring = "ascdocbuilder 1.0 Type Library",
resource_name = "IDR_ASCDOCBUILDER") ];
[ module(dll, uuid = "{7368AB25-7082-4815-8AE5-A30C2ABDD2A0}",
name = "onlyofficedocbuilder",
helpstring = "onlyofficedocbuilder 1.0 Type Library",
resource_name = "IDR_ONLYOFFICEDOCBUILDER") ];

View File

@ -60,11 +60,11 @@ BEGIN
BEGIN
BLOCK "040904e4"
BEGIN
VALUE "CompanyName", "Ascensio System SIA"
VALUE "FileDescription", "Ascensio System SIA docbuilder ActiveX DLL"
VALUE "CompanyName", "Ascensio System SIA 2019"
VALUE "FileDescription", "ONLYOFFICE docbuilder ActiveX DLL"
VALUE "FileVersion", "1.0.0.1"
VALUE "InternalName", "docbuilder.com.dll"
VALUE "LegalCopyright", "Ascensio System SIA Copyright (c) 2011-2016. All rights reserved."
VALUE "LegalCopyright", "Copyright (C) Ascensio System SIA 2019. All rights reserved."
VALUE "OriginalFilename", "docbuilder.com.dll"
VALUE "ProductName", "docbuilder.com"
VALUE "ProductVersion", "1.0.0.1"
@ -88,7 +88,7 @@ BEGIN
IDS_PROJNAME "docbuilder.com"
END
IDR_ASCDOCBUILDER REGISTRY "docbuilder.com.rgs"
IDR_ONLYOFFICEDOCBUILDER REGISTRY "docbuilder.com.rgs"
////////////////////////////////////////////////////////////////////////////

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
@ -26,25 +26,25 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<PlatformToolset>v120</PlatformToolset>
<PlatformToolset>v140</PlatformToolset>
<UseOfAtl>false</UseOfAtl>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<PlatformToolset>v120</PlatformToolset>
<PlatformToolset>v140</PlatformToolset>
<UseOfAtl>Dynamic</UseOfAtl>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<PlatformToolset>v120</PlatformToolset>
<PlatformToolset>v140</PlatformToolset>
<UseOfAtl>Dynamic</UseOfAtl>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<PlatformToolset>v120</PlatformToolset>
<PlatformToolset>v140</PlatformToolset>
<UseOfAtl>Dynamic</UseOfAtl>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
@ -121,16 +121,12 @@
<AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
<Link>
<RegisterOutput>true</RegisterOutput>
<RegisterOutput>false</RegisterOutput>
<MergedIDLBaseFileName>_docbuilder.idl</MergedIDLBaseFileName>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<TargetMachine>MachineX86</TargetMachine>
</Link>
<PostBuildEvent>
<Command>regsvr32 $(TargetPath)</Command>
<Message>Performing registration</Message>
</PostBuildEvent>
<CustomBuildStep>
<Command>
</Command>
@ -170,10 +166,6 @@
<SubSystem>Windows</SubSystem>
<TargetMachine>MachineX64</TargetMachine>
</Link>
<PostBuildEvent>
<Command>regsvr32 $(TargetPath)</Command>
<Message>Performing registration</Message>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<PreBuildEvent>
@ -194,7 +186,7 @@
<Optimization>MaxSpeed</Optimization>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;_USRDLL;_ATL_ATTRIBUTES;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
@ -205,7 +197,7 @@
<AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
<Link>
<RegisterOutput>true</RegisterOutput>
<RegisterOutput>false</RegisterOutput>
<MergedIDLBaseFileName>_docbuilder.idl</MergedIDLBaseFileName>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
@ -213,10 +205,6 @@
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>MachineX86</TargetMachine>
</Link>
<PostBuildEvent>
<Message>Performing registration</Message>
<Command>regsvr32 $(TargetPath)</Command>
</PostBuildEvent>
<CustomBuildStep>
<Command>
</Command>
@ -258,10 +246,6 @@
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>MachineX64</TargetMachine>
</Link>
<PostBuildEvent>
<Message>Performing registration</Message>
<Command>regsvr32 $(TargetPath)</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="docbuilder.com.cpp" />

View File

@ -31,6 +31,7 @@
*/
// docbuildercom.h : Declaration of the CDocbuilder
#pragma once
#include "stdafx.h"
#include "resource.h" // main symbols
#if defined(_WIN32_WCE) && !defined(_CE_DCOM) && !defined(_CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA)
@ -48,23 +49,37 @@ using namespace ATL;
#pragma comment(lib, "../../../build/lib/win_32/doctrenderer.lib")
#endif
#include "../docbuilder.h"
#include "../../common/File.h"
#include "../../../DesktopEditor/doctrenderer/docbuilder.h"
#include "../../../Common/OfficeFileFormats.h"
// IASCDocBuilder
[object, uuid("B0C0E80B-2076-4C33-BC6D-3DB1B0FE9687"), dual, pointer_default(unique)]
__interface IASCDocBuilder : IDispatch
// IONLYOFFICEDocBuilderValue
[object, uuid("2637FDFA-8473-4CB8-B90B-C23CB949D009"), dual, pointer_default(unique)]
__interface IONLYOFFICEDocBuilderValue : IDispatch
{
[id(100)] HRESULT IsEmpty([out, retval] VARIANT_BOOL* result);
[id(102)] HRESULT IsNull([out, retval] VARIANT_BOOL* result);
[id(103)] HRESULT IsUndefined([out, retval] VARIANT_BOOL* result);
[id(104)] HRESULT ToInt([out, retval] long* result);
[id(105)] HRESULT ToDouble([out, retval] double* result);
[id(106)] HRESULT ToString([out, retval] BSTR* result);
[id(107)] HRESULT GetProperty([in] BSTR name, [out, retval] IONLYOFFICEDocBuilderValue** result);
};
// IONLYOFFICEDocBuilder
[object, uuid("0C07B7E7-86A4-42E1-8E42-2FA961992E0F"), dual, pointer_default(unique)]
__interface IONLYOFFICEDocBuilder : IDispatch
{
[id(1)] HRESULT CreateInstance([in] VARIANT_BOOL checkFonts);
[id(100)] HRESULT OpenFile([in] BSTR path, [in] BSTR params, [out, retval] VARIANT_BOOL* result);
[id(101)] HRESULT CreateFile([in] int type, [out, retval] VARIANT_BOOL* result);
[id(101)] HRESULT CreateFile([in] BSTR type, [out, retval] VARIANT_BOOL* result);
[id(102)] HRESULT SetTmpFolder([in] BSTR folder);
[id(103)] HRESULT SaveFile([in] int type, [in] BSTR path, [out, retval] VARIANT_BOOL* result);
[id(103)] HRESULT SaveFile([in] BSTR type, [in] BSTR path, [out, retval] VARIANT_BOOL* result);
[id(104)] HRESULT CloseFile(void);
[id(105)] HRESULT ExecuteCommand([in] BSTR command, [out, retval] VARIANT_BOOL* result);
[id(106)] HRESULT Run([in] BSTR path, [out, retval] VARIANT_BOOL* result);
[id(107)] HRESULT RunText([in] BSTR commands, [out, retval] VARIANT_BOOL* result);
[id(108)] HRESULT SetProperty([in] BSTR key, [in] BSTR value);
[id(109)] HRESULT Execute([in] BSTR command, [out, retval] IONLYOFFICEDocBuilderValue** result);
[id(201)] HRESULT Initialize(void);
[id(202)] HRESULT Dispose(void);
@ -73,21 +88,116 @@ __interface IASCDocBuilder : IDispatch
[id(1002)] HRESULT GetAdditionalParam([in] BSTR ParamName, [out, retval] VARIANT* ParamValue);
};
// CASCDocBuilder
[coclass, uuid("227DE4AD-D992-4CCD-9704-0F041CE908F3"), threading(apartment), vi_progid("ASCDocBuilder.DocBuilder"), progid("ASCDocBuilder.DocBuilder.1"), version(1.0)]
class ATL_NO_VTABLE CASCDocBuilder : public IASCDocBuilder
static CStringW GetCurrentDllDirPath()
{
CStringW thisPath = L"";
WCHAR path[MAX_PATH];
HMODULE hm;
if (GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
(LPWSTR)&GetCurrentDllDirPath, &hm))
{
GetModuleFileNameW(hm, path, sizeof(path));
PathRemoveFileSpecW(path);
thisPath = CStringW(path);
if (!thisPath.IsEmpty() &&
thisPath.GetAt(thisPath.GetLength() - 1) != '\\')
thisPath += L"\\";
}
return thisPath;
}
// CONLYOFFICEDocBuilderValue
[coclass, uuid("85C41585-25D7-40F1-9CC6-FA17052650F4"), threading(apartment), vi_progid("ONLYOFFICE.BuilderValue"), progid("ONLYOFFICE.BuilderValue.1"), version(1.0)]
class ATL_NO_VTABLE CONLYOFFICEDocBuilderValue : public IONLYOFFICEDocBuilderValue
{
protected:
NSDoctRenderer::CDocBuilderValue m_oValue;
public:
CONLYOFFICEDocBuilderValue()
{
}
~CONLYOFFICEDocBuilderValue()
{
}
STDMETHOD(IsEmpty)(VARIANT_BOOL* result)
{
if (result)
*result = m_oValue.IsEmpty() ? VARIANT_TRUE : VARIANT_FALSE;
return S_OK;
}
STDMETHOD(IsNull)(VARIANT_BOOL* result)
{
if (result)
*result = m_oValue.IsNull() ? VARIANT_TRUE : VARIANT_FALSE;
return S_OK;
}
STDMETHOD(IsUndefined)(VARIANT_BOOL* result)
{
if (result)
*result = m_oValue.IsUndefined() ? VARIANT_TRUE : VARIANT_FALSE;
return S_OK;
}
STDMETHOD(ToInt)(long* result)
{
if (result)
*result = m_oValue.ToInt();
return S_OK;
}
STDMETHOD(ToDouble)(double* result)
{
if (result)
*result = m_oValue.ToDouble();
return S_OK;
}
STDMETHOD(ToString)(BSTR* result)
{
wchar_t* val = m_oValue.ToString();
if (result)
{
*result = NULL;
if (val)
{
CString sValue(val);
*result = sValue.AllocSysString();
}
}
if (val)
m_oValue.FreeString(val);
return S_OK;
}
STDMETHOD(GetProperty)(BSTR name, IONLYOFFICEDocBuilderValue** result)
{
if (result)
{
CoCreateInstance(__uuidof(CONLYOFFICEDocBuilderValue), NULL, CLSCTX_ALL, __uuidof(IONLYOFFICEDocBuilderValue), (void**)result);
((CONLYOFFICEDocBuilderValue*)(*result))->m_oValue = m_oValue.GetProperty(name);
}
return S_OK;
}
void* GetPrivate()
{
return &m_oValue;
}
};
// CONLYOFFICEDocBuilder
[coclass, uuid("9BF69F3C-1506-41B9-B8EE-2839948C02E9"), threading(apartment), vi_progid("ONLYOFFICE.Builder"), progid("ONLYOFFICE.Builder.1"), version(1.0)]
class ATL_NO_VTABLE CONLYOFFICEDocBuilder : public IONLYOFFICEDocBuilder
{
protected:
NSDoctRenderer::CDocBuilder* m_pBuilder;
public:
CASCDocBuilder()
CONLYOFFICEDocBuilder()
{
m_pBuilder = NULL;
this->CreateInstance(VARIANT_TRUE);
}
~CASCDocBuilder()
~CONLYOFFICEDocBuilder()
{
if (NULL != m_pBuilder)
delete m_pBuilder;
@ -98,6 +208,10 @@ public:
delete m_pBuilder;
m_pBuilder = new NSDoctRenderer::CDocBuilder();
CStringW sCurrentDir = GetCurrentDllDirPath();
BSTR bsCurrentDir = sCurrentDir.AllocSysString();
m_pBuilder->SetProperty("--work-directory", (wchar_t*)bsCurrentDir);
SysFreeString(bsCurrentDir);
return S_OK;
}
STDMETHOD(OpenFile)(BSTR path, BSTR params, VARIANT_BOOL* result)
@ -109,12 +223,19 @@ public:
*result = bRet ? VARIANT_TRUE : VARIANT_FALSE;
return S_OK;
}
STDMETHOD(CreateFile)(int type, VARIANT_BOOL* result)
STDMETHOD(CreateFile)(BSTR type, VARIANT_BOOL* result)
{
if (NULL == m_pBuilder)
return S_FALSE;
bool bRet = m_pBuilder->CreateFile(type);
int nType = AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX;
CStringW sType = (CString)type;
if (L"pptx" == sType)
nType = AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTX;
else if (L"xlsx" == sType)
nType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX;
bool bRet = m_pBuilder->CreateFile(nType);
*result = bRet ? VARIANT_TRUE : VARIANT_FALSE;
return S_OK;
}
@ -126,12 +247,45 @@ public:
m_pBuilder->SetTmpFolder(folder);
return S_OK;
}
STDMETHOD(SaveFile)(int type, BSTR path, VARIANT_BOOL* result)
STDMETHOD(SaveFile)(BSTR type, BSTR path, VARIANT_BOOL* result)
{
if (NULL == m_pBuilder)
return S_FALSE;
bool bRet = m_pBuilder->SaveFile(type, path);
int nType = AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX;
CStringW sType = (CString)type;
if (L"docx" == sType)
nType = AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX;
else if (L"doc" == sType)
nType = AVS_OFFICESTUDIO_FILE_DOCUMENT_DOC;
else if (L"odt" == sType)
nType = AVS_OFFICESTUDIO_FILE_DOCUMENT_ODT;
else if (L"rtf" == sType)
nType = AVS_OFFICESTUDIO_FILE_DOCUMENT_RTF;
else if (L"txt" == sType)
nType = AVS_OFFICESTUDIO_FILE_DOCUMENT_TXT;
else if (L"pptx" == sType)
nType = AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTX;
else if (L"odp" == sType)
nType = AVS_OFFICESTUDIO_FILE_PRESENTATION_ODP;
else if (L"xlsx" == sType)
nType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX;
else if (L"xls" == sType)
nType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLS;
else if (L"ods" == sType)
nType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_ODS;
else if (L"csv" == sType)
nType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_CSV;
else if (L"pdf" == sType)
nType = AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDF;
else if (L"image" == sType)
nType = AVS_OFFICESTUDIO_FILE_IMAGE;
else if (L"jpg" == sType)
nType = AVS_OFFICESTUDIO_FILE_IMAGE;
else if (L"png" == sType)
nType = AVS_OFFICESTUDIO_FILE_IMAGE;
bool bRet = m_pBuilder->SaveFile(nType, path);
*result = bRet ? VARIANT_TRUE : VARIANT_FALSE;
return S_OK;
}
@ -177,6 +331,18 @@ public:
m_pBuilder->SetPropertyW(key, value);
return S_OK;
}
STDMETHOD(Execute)(BSTR command, IONLYOFFICEDocBuilderValue** result)
{
if (NULL == m_pBuilder)
return S_FALSE;
if (result)
{
CoCreateInstance(__uuidof(CONLYOFFICEDocBuilderValue), NULL, CLSCTX_ALL, __uuidof(IONLYOFFICEDocBuilderValue), (void**)result);
m_pBuilder->ExecuteCommand(command, (NSDoctRenderer::CDocBuilderValue*)(((CONLYOFFICEDocBuilderValue*)(*result))->GetPrivate()));
}
return S_OK;
}
STDMETHOD(SetAdditionalParam)(BSTR ParamName, VARIANT ParamValue)
{

View File

@ -0,0 +1,116 @@
/*
* (c) Copyright Ascensio System SIA 2010-2019
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha
* street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#ifndef DOCBUILDER_H
#define DOCBUILDER_H
#ifdef _MSC_VER
#define BUILDING_DOCBUILDER __declspec(dllimport)
#else
#define BUILDING_DOCBUILDER
#endif
#define OFFICESTUDIO_FILE_DOCUMENT 0x0040
#define OFFICESTUDIO_FILE_DOCUMENT_DOCX OFFICESTUDIO_FILE_DOCUMENT + 0x0001
#define OFFICESTUDIO_FILE_DOCUMENT_DOC OFFICESTUDIO_FILE_DOCUMENT + 0x0002
#define OFFICESTUDIO_FILE_DOCUMENT_ODT OFFICESTUDIO_FILE_DOCUMENT + 0x0003
#define OFFICESTUDIO_FILE_DOCUMENT_RTF OFFICESTUDIO_FILE_DOCUMENT + 0x0004
#define OFFICESTUDIO_FILE_DOCUMENT_TXT OFFICESTUDIO_FILE_DOCUMENT + 0x0005
#define OFFICESTUDIO_FILE_DOCUMENT_DOTX OFFICESTUDIO_FILE_DOCUMENT + 0x000c
#define OFFICESTUDIO_FILE_DOCUMENT_OTT OFFICESTUDIO_FILE_DOCUMENT + 0x000f
#define OFFICESTUDIO_FILE_PRESENTATION 0x0080
#define OFFICESTUDIO_FILE_PRESENTATION_PPTX OFFICESTUDIO_FILE_PRESENTATION + 0x0001
#define OFFICESTUDIO_FILE_PRESENTATION_PPT OFFICESTUDIO_FILE_PRESENTATION + 0x0002
#define OFFICESTUDIO_FILE_PRESENTATION_ODP OFFICESTUDIO_FILE_PRESENTATION + 0x0003
#define OFFICESTUDIO_FILE_PRESENTATION_PPSX OFFICESTUDIO_FILE_PRESENTATION + 0x0004
#define OFFICESTUDIO_FILE_PRESENTATION_POTX OFFICESTUDIO_FILE_PRESENTATION + 0x0007
#define OFFICESTUDIO_FILE_PRESENTATION_OTP OFFICESTUDIO_FILE_PRESENTATION + 0x000a
#define OFFICESTUDIO_FILE_SPREADSHEET 0x0100
#define OFFICESTUDIO_FILE_SPREADSHEET_XLSX OFFICESTUDIO_FILE_SPREADSHEET + 0x0001
#define OFFICESTUDIO_FILE_SPREADSHEET_XLS OFFICESTUDIO_FILE_SPREADSHEET + 0x0002
#define OFFICESTUDIO_FILE_SPREADSHEET_ODS OFFICESTUDIO_FILE_SPREADSHEET + 0x0003
#define OFFICESTUDIO_FILE_SPREADSHEET_CSV OFFICESTUDIO_FILE_SPREADSHEET + 0x0004
#define OFFICESTUDIO_FILE_SPREADSHEET_XLTX OFFICESTUDIO_FILE_SPREADSHEET + 0x0006
#define OFFICESTUDIO_FILE_SPREADSHEET_OTS OFFICESTUDIO_FILE_SPREADSHEET + 0x0009
#define OFFICESTUDIO_FILE_CROSSPLATFORM 0x0200
#define OFFICESTUDIO_FILE_CROSSPLATFORM_PDF OFFICESTUDIO_FILE_CROSSPLATFORM + 0x0001
#define OFFICESTUDIO_FILE_CROSSPLATFORM_DJVU OFFICESTUDIO_FILE_CROSSPLATFORM + 0x0003
#define OFFICESTUDIO_FILE_CROSSPLATFORM_XPS OFFICESTUDIO_FILE_CROSSPLATFORM + 0x0004
#define OFFICESTUDIO_FILE_CROSSPLATFORM_PDFA OFFICESTUDIO_FILE_CROSSPLATFORM + 0x0009
#define OFFICESTUDIO_FILE_IMAGE 0x0400
#define OFFICESTUDIO_FILE_IMAGE_JPG OFFICESTUDIO_FILE_IMAGE + 0x0001
#define OFFICESTUDIO_FILE_IMAGE_PNG OFFICESTUDIO_FILE_IMAGE + 0x0005
#define OFFICESTUDIO_FILE_IMAGE_BMP OFFICESTUDIO_FILE_IMAGE + 0x0008
namespace NSDoctRenderer
{
class CDocBuilder_Private;
class BUILDING_DOCBUILDER CDocBuilder
{
public:
CDocBuilder();
~CDocBuilder();
public:
int OpenFile(const wchar_t* path, const wchar_t* params);
bool CreateFile(const int& type);
void SetTmpFolder(const wchar_t* folder);
int SaveFile(const int& type, const wchar_t* path, const wchar_t* params = 0);
void CloseFile();
bool ExecuteCommand(const wchar_t* command);
bool Run(const wchar_t* path);
bool RunTextW(const wchar_t* commands);
bool RunTextA(const char* commands);
void SetProperty(const char* param, const wchar_t* value);
void SetPropertyW(const wchar_t* param, const wchar_t* value);
void WriteData(const wchar_t* path, const wchar_t* value, const bool& append);
bool IsSaveWithDoctrendererMode();
char* GetVersion();
public:
static void Initialize();
static void Dispose();
private:
CDocBuilder_Private* m_pInternal;
};
}
#endif // DOCBUILDER_H

View File

@ -53,9 +53,9 @@ namespace NSDoctRenderer
int CDocBuilder::SaveFile(const int& type, const wchar_t* path, const wchar_t* params)
{
return m_pInternal->SaveFile(type, path, params);
}
bool CDocBuilder::ExecuteCommand(const wchar_t* command)
{
return m_pInternal->ExecuteCommand(command);
}
bool CDocBuilder::ExecuteCommand(const wchar_t* command, CDocBuilderValue* retValue)
{
return m_pInternal->ExecuteCommand(command, retValue);
}
}

View File

@ -35,7 +35,33 @@
#include "./common.h"
namespace NSDoctRenderer
{
{
class CDocBuilderValue_Private;
class Q_DECL_EXPORT CDocBuilderValue
{
public:
CDocBuilderValue();
CDocBuilderValue(const CDocBuilderValue& src);
CDocBuilderValue& operator=(const CDocBuilderValue& src);
~CDocBuilderValue();
void* private_get_internal();
public:
bool IsEmpty();
void Clear();
void FreeString(wchar_t* data);
bool IsNull();
bool IsUndefined();
int ToInt();
double ToDouble();
wchar_t* ToString();
CDocBuilderValue GetProperty(const wchar_t* name);
private:
CDocBuilderValue_Private* m_internal;
};
class CDocBuilder_Private;
class Q_DECL_EXPORT CDocBuilder
{
@ -49,7 +75,7 @@ namespace NSDoctRenderer
void SetTmpFolder(const wchar_t* folder);
int SaveFile(const int& type, const wchar_t* path, const wchar_t* params = 0);
void CloseFile();
bool ExecuteCommand(const wchar_t* command);
bool ExecuteCommand(const wchar_t* command, CDocBuilderValue* retValue = 0);
bool Run(const wchar_t* path);

View File

@ -60,6 +60,29 @@
#include "../../Common/FileDownloader/FileDownloader.h"
#endif
namespace NSDoctRenderer
{
class CDocBuilderValue_Private
{
public:
v8::Isolate* m_isolate;
v8::Local<v8::Value> m_value;
public:
CDocBuilderValue_Private()
{
m_isolate = NULL;
}
~CDocBuilderValue_Private()
{
}
void Clear()
{
m_value.Clear();
}
};
}
template <typename T>
class CScopeWrapper
{
@ -131,10 +154,13 @@ public:
std::cerr << sT << ": " << sE << std::endl;
}
bool ExecuteCommand(const std::wstring& command)
bool ExecuteCommand(const std::wstring& command, NSDoctRenderer::CDocBuilderValue* retValue = NULL)
{
LOGGER_SPEED_START
if (retValue)
retValue->Clear();
std::string commandA = U_TO_UTF8(command);
//commandA = "_api." + commandA;
@ -159,7 +185,7 @@ public:
}
else
{
script->Run();
v8::Local<v8::Value> retNativeVal = script->Run();
if (try_catch.HasCaught())
{
@ -171,6 +197,13 @@ public:
return false;
}
if (retValue)
{
NSDoctRenderer::CDocBuilderValue_Private* privateRet = (NSDoctRenderer::CDocBuilderValue_Private*)retValue->private_get_internal();
privateRet->m_isolate = m_isolate;
privateRet->m_value = retNativeVal;
}
}
LOGGER_SPEED_LAP("run_command")
@ -578,6 +611,92 @@ namespace NSDoctRenderer
std::string m_sArgumentJSON;
};
CDocBuilderValue::CDocBuilderValue()
{
m_internal = new CDocBuilderValue_Private();
}
CDocBuilderValue::CDocBuilderValue(const CDocBuilderValue& src)
{
m_internal->m_value = src.m_internal->m_value;
}
CDocBuilderValue& CDocBuilderValue::operator=(const CDocBuilderValue& src)
{
m_internal->m_value = src.m_internal->m_value;
return *this;
}
CDocBuilderValue::~CDocBuilderValue()
{
delete m_internal;
}
void* CDocBuilderValue::private_get_internal()
{
return (void*)m_internal;
}
bool CDocBuilderValue::IsEmpty()
{
return m_internal->m_value.IsEmpty();
}
void CDocBuilderValue::Clear()
{
m_internal->Clear();
}
bool CDocBuilderValue::IsNull()
{
if (m_internal->m_value.IsEmpty())
return false;
return m_internal->m_value->IsNull();
}
bool CDocBuilderValue::IsUndefined()
{
if (m_internal->m_value.IsEmpty())
return false;
return m_internal->m_value->IsUndefined();
}
int CDocBuilderValue::ToInt()
{
if (m_internal->m_value.IsEmpty() || !m_internal->m_value->IsInt32())
return 0;
return m_internal->m_value->ToInt32()->Value();
}
double CDocBuilderValue::ToDouble()
{
if (m_internal->m_value.IsEmpty() || !m_internal->m_value->IsNumber())
return 0;
return m_internal->m_value->ToNumber()->Value();
}
wchar_t* CDocBuilderValue::ToString()
{
if (m_internal->m_value.IsEmpty() || !m_internal->m_value->IsString())
return NULL;
std::wstring sValue = to_cstring(m_internal->m_value);
if (sValue.empty())
return NULL;
size_t len = sValue.length();
wchar_t* buffer = new wchar_t[len + 1];
memcpy(buffer, sValue.c_str(), len * sizeof(wchar_t));
buffer[len] = '\0';
return buffer;
}
void CDocBuilderValue::FreeString(wchar_t* data)
{
delete [] data;
}
CDocBuilderValue CDocBuilderValue::GetProperty(const wchar_t* name)
{
CDocBuilderValue ret;
if (m_internal->m_value.IsEmpty() || !m_internal->m_value->IsObject())
return ret;
std::wstring sProp(name);
std::string sPropA = U_TO_UTF8(sProp);
ret.m_internal->m_isolate = m_internal->m_isolate;
ret.m_internal->m_value = m_internal->m_value->ToObject()->Get(v8::String::NewFromUtf8(m_internal->m_isolate, sPropA.c_str()));
return ret;
}
class CDocBuilder_Private
{
public:
@ -1413,9 +1532,9 @@ namespace NSDoctRenderer
return nReturnCode;
}
bool ExecuteCommand(const std::wstring& command)
bool ExecuteCommand(const std::wstring& command, CDocBuilderValue* retValue = NULL)
{
if (command.length() < 7) // minimum command (!!!)
if (command.length() < 7 && !retValue) // minimum command (!!!)
return true;
Init();
@ -1442,7 +1561,7 @@ namespace NSDoctRenderer
return false;
}
return m_pWorker->ExecuteCommand(command);
return m_pWorker->ExecuteCommand(command, retValue);
}
std::string GetScript()

File diff suppressed because it is too large Load Diff

View File

@ -189,7 +189,12 @@ namespace NSMemoryStream
inline void WriteStringA(const char* pData, int nLen)
{
CheckBufferSize(nLen + sizeof(USHORT));
#ifdef __ANDROID__
memcpy(m_pBufferMem, &nLen, sizeof(USHORT));
#else
*((USHORT*)(m_pBufferMem)) = (USHORT)nLen;
#endif
m_pBufferMem += sizeof(USHORT);
memcpy(m_pBufferMem, pData, nLen);
@ -198,7 +203,12 @@ namespace NSMemoryStream
inline void WriteStringA2(const char* pData, int nLen)
{
CheckBufferSize(nLen + sizeof(INT));
*((INT*)(m_pBufferMem)) = (INT)nLen;
#ifdef __ANDROID__
memcpy(m_pBufferMem, &nLen, sizeof(INT));
#else
*((INT*)(m_pBufferMem)) = (INT)nLen;
#endif
m_pBufferMem += sizeof(INT);
memcpy(m_pBufferMem, pData, nLen);

View File

@ -825,7 +825,10 @@ static const struct ActionNamesEmf
BYTE* pBgraBuffer = NULL;
unsigned int ulWidth, ulHeight;
if (ReadImage(oBitmap.offBmiSrc, oBitmap.cbBmiSrc, oBitmap.offBitsSrc, oBitmap.cbBitsSrc, sizeof(TEmfBitBlt) + 8, &pBgraBuffer, &ulWidth, &ulHeight))
// sizeof использовать нельзя, т.к. мы используем double в структуре TEmfBitBlt, а читаем его 4-байтовым
unsigned int unEmfBitBltRecordSize = 100; // sizeof(TEmfBitBlt) + 8
if (ReadImage(oBitmap.offBmiSrc, oBitmap.cbBmiSrc, oBitmap.offBitsSrc, oBitmap.cbBitsSrc, unEmfBitBltRecordSize, &pBgraBuffer, &ulWidth, &ulHeight))
{
DrawImage(oBitmap.xDest, oBitmap.yDest, oBitmap.cxDest, oBitmap.cyDest, pBgraBuffer, ulWidth, ulHeight);
}

View File

@ -1000,7 +1000,7 @@ namespace NExtractTools
}
else
{
nRes = dir2zip(sFrom, sTo);
nRes = dir2zip(sResultPptxDir, sTo);
}
}
return nRes;
@ -3479,7 +3479,7 @@ namespace NExtractTools
_UINT32 nRes = 0;
if(AVS_OFFICESTUDIO_FILE_SPREADSHEET_CSV == nFormatFrom)
{
if(AVS_OFFICESTUDIO_FILE_CANVAS_SPREADSHEET == nFormatTo)
if(AVS_OFFICESTUDIO_FILE_CANVAS_SPREADSHEET == nFormatTo || AVS_OFFICESTUDIO_FILE_OTHER_JSON == nFormatTo)
{
nRes = csv2xlst_bin(sFrom, sTo, params);
}

View File

@ -1128,7 +1128,12 @@ namespace BinXlsxRW
TabColor = 9,
PageSetUpPr = 10,
AutoPageBreaks = 11,
FitToPage = 12
FitToPage = 12,
OutlinePr = 13,
ApplyStyles = 14,
ShowOutlineSymbols = 15,
SummaryBelow = 16,
SummaryRight = 17
};}
namespace c_oSer_Sparkline{enum c_oSer_Sparkline

View File

@ -5535,6 +5535,40 @@ void BinaryWorksheetTableWriter::WriteSheetPr(const OOX::Spreadsheet::CSheetPr&
WritePageSetUpPr(oSheetPr.m_oPageSetUpPr.get());
m_oBcw.WriteItemEnd(nCurPos);
}
if (oSheetPr.m_oOutlinePr.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSer_SheetPr::OutlinePr);
WriteOutlinePr(oSheetPr.m_oOutlinePr.get());
m_oBcw.WriteItemEnd(nCurPos);
}
}
void BinaryWorksheetTableWriter::WriteOutlinePr(const OOX::Spreadsheet::COutlinePr& oOutlinePr)
{
int nCurPos = 0;
if (oOutlinePr.m_oApplyStyles.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSer_SheetPr::ApplyStyles);
m_oBcw.m_oStream.WriteBOOL(oOutlinePr.m_oApplyStyles->ToBool());
m_oBcw.WriteItemEnd(nCurPos);
}
if (oOutlinePr.m_oShowOutlineSymbols.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSer_SheetPr::ShowOutlineSymbols);
m_oBcw.m_oStream.WriteBOOL(oOutlinePr.m_oShowOutlineSymbols->ToBool());
m_oBcw.WriteItemEnd(nCurPos);
}
if (oOutlinePr.m_oSummaryBelow.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSer_SheetPr::SummaryBelow);
m_oBcw.m_oStream.WriteBOOL(oOutlinePr.m_oSummaryBelow->ToBool());
m_oBcw.WriteItemEnd(nCurPos);
}
if (oOutlinePr.m_oSummaryRight.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSer_SheetPr::SummaryRight);
m_oBcw.m_oStream.WriteBOOL(oOutlinePr.m_oSummaryRight->ToBool());
m_oBcw.WriteItemEnd(nCurPos);
}
}
void BinaryWorksheetTableWriter::WritePageSetUpPr(const OOX::Spreadsheet::CPageSetUpPr& oPageSetUpPr)
{
@ -6229,26 +6263,27 @@ void BinaryWorksheetTableWriter::WriteSparklineGroup(const OOX::Spreadsheet::CSp
}
void BinaryWorksheetTableWriter::WriteDataValidations(const OOX::Spreadsheet::CDataValidations& oDataValidations)
{
int nCurPos = 0;
if (oDataValidations.m_oDisablePrompts.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSer_DataValidation::DisablePrompts);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Byte);
nCurPos = m_oBcw.WriteItemStart(c_oSer_DataValidation::DisablePrompts);
m_oBcw.m_oStream.WriteBOOL(oDataValidations.m_oDisablePrompts->ToBool());
m_oBcw.WriteItemEnd(nCurPos);
}
if (oDataValidations.m_oXWindow.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSer_DataValidation::XWindow);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
nCurPos = m_oBcw.WriteItemStart(c_oSer_DataValidation::XWindow);
m_oBcw.m_oStream.WriteLONG(oDataValidations.m_oXWindow->GetValue());
m_oBcw.WriteItemEnd(nCurPos);
}
if (oDataValidations.m_oYWindow.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSer_DataValidation::YWindow);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
nCurPos = m_oBcw.WriteItemStart(c_oSer_DataValidation::YWindow);
m_oBcw.m_oStream.WriteLONG(oDataValidations.m_oYWindow->GetValue());
m_oBcw.WriteItemEnd(nCurPos);
}
int nCurPos = m_oBcw.WriteItemStart(c_oSer_DataValidation::DataValidations);
nCurPos = m_oBcw.WriteItemStart(c_oSer_DataValidation::DataValidations);
WriteDataValidationsContent(oDataValidations);
m_oBcw.WriteItemEnd(nCurPos);
}
@ -6526,7 +6561,7 @@ _UINT32 BinaryFileWriter::Open(const std::wstring& sInputDir, const std::wstring
case BinXlsxRW::c_oFileTypes::XLSX:
default:
{
if (bIsNoBase64)
if (bIsNoBase64 && BinXlsxRW::c_oFileTypes::JSON != saveFileType)
{
pXlsx = new OOX::Spreadsheet::CXlsx();
pXlsx->m_bNeedCalcChain = false;

View File

@ -252,6 +252,7 @@ namespace BinXlsxRW
void WriteThreadedCommentMention(OOX::Spreadsheet::CThreadedCommentMention& oMention);
void WriteSheetPr(const OOX::Spreadsheet::CSheetPr& oSheetPr);
void WritePageSetUpPr(const OOX::Spreadsheet::CPageSetUpPr& oPageSetUpPr);
void WriteOutlinePr(const OOX::Spreadsheet::COutlinePr& oOutlinePr);
void WritemHeaderFooter(const OOX::Spreadsheet::CHeaderFooter& oHeaderFooter);
void WritemRowColBreaks(const OOX::Spreadsheet::CRowColBreaks& oRowColBreaks);
void WritemBreak(const OOX::Spreadsheet::CBreak& oBreak);

View File

@ -4222,6 +4222,39 @@ int BinaryWorksheetsTableReader::ReadSheetPr(BYTE type, long length, void* poRes
pSheetPr->m_oPageSetUpPr.Init();
READ1_DEF(length, res, this->ReadPageSetUpPr, pSheetPr->m_oPageSetUpPr.GetPointer());
}
else if(c_oSer_SheetPr::OutlinePr == type)
{
pSheetPr->m_oOutlinePr.Init();
READ1_DEF(length, res, this->ReadOutlinePr, pSheetPr->m_oOutlinePr.GetPointer());
}
else
res = c_oSerConstants::ReadUnknown;
return res;
}
int BinaryWorksheetsTableReader::ReadOutlinePr(BYTE type, long length, void* poResult)
{
OOX::Spreadsheet::COutlinePr* pOutlinePr = static_cast<OOX::Spreadsheet::COutlinePr*>(poResult);
int res = c_oSerConstants::ReadOk;
if(c_oSer_SheetPr::ApplyStyles == type)
{
pOutlinePr->m_oApplyStyles.Init();
pOutlinePr->m_oApplyStyles->FromBool(m_oBufferedStream.GetBool());
}
else if(c_oSer_SheetPr::ShowOutlineSymbols == type)
{
pOutlinePr->m_oShowOutlineSymbols.Init();
pOutlinePr->m_oShowOutlineSymbols->FromBool(m_oBufferedStream.GetBool());
}
else if(c_oSer_SheetPr::SummaryBelow == type)
{
pOutlinePr->m_oSummaryBelow.Init();
pOutlinePr->m_oSummaryBelow->FromBool(m_oBufferedStream.GetBool());
}
else if(c_oSer_SheetPr::SummaryRight == type)
{
pOutlinePr->m_oSummaryRight.Init();
pOutlinePr->m_oSummaryRight->FromBool(m_oBufferedStream.GetBool());
}
else
res = c_oSerConstants::ReadUnknown;
return res;

View File

@ -293,6 +293,7 @@ namespace BinXlsxRW
int ReadPane(BYTE type, long length, void* poResult);
int ReadSelection(BYTE type, long length, void* poResult);
int ReadSheetPr(BYTE type, long length, void* poResult);
int ReadOutlinePr(BYTE type, long length, void* poResult);
int ReadPageSetUpPr(BYTE type, long length, void* poResult);
int ReadColor(BYTE type, long length, void* poResult);
int ReadSheetFormatPr(BYTE type, long length, void* poResult);