mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-04-07 13:55:33 +08:00
Compare commits
20 Commits
core-win-3
...
core-win-3
| Author | SHA1 | Date | |
|---|---|---|---|
| 55e4902d66 | |||
| 2dc1ad5af7 | |||
| ab0def1840 | |||
| 957972e3be | |||
| 49e31f2c0c | |||
| 4585e86fb7 | |||
| 6bcafa516a | |||
| e41f8019d6 | |||
| b378084925 | |||
| 99f47b43a5 | |||
| dc1999482e | |||
| 7c764f5b84 | |||
| 03316ea82d | |||
| 567f547d10 | |||
| a4a52ec016 | |||
| 1458b1c57f | |||
| 7d59211e67 | |||
| f68662827d | |||
| b9981cffef | |||
| 56b7889270 |
@ -232,6 +232,7 @@ void docx_serialize_image_child(std::wostream & strm, _docx_drawing & val)
|
||||
}
|
||||
|
||||
oox_serialize_ln(CP_XML_STREAM(), val.additional);
|
||||
oox_serialize_effects(CP_XML_STREAM(), val.additional);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -267,6 +268,7 @@ void docx_serialize_shape_child(std::wostream & strm, _docx_drawing & val)
|
||||
val.serialize_shape (CP_XML_STREAM());
|
||||
|
||||
oox_serialize_ln(CP_XML_STREAM(), val.additional);
|
||||
oox_serialize_effects(CP_XML_STREAM(), val.additional);
|
||||
}
|
||||
val.serialize_text(CP_XML_STREAM());
|
||||
}
|
||||
|
||||
@ -141,6 +141,67 @@ static const std::wstring _vmlDashStyle[]=
|
||||
L"dashdot",
|
||||
L"shortdashdotdot"
|
||||
};
|
||||
|
||||
void oox_serialize_effects(std::wostream & strm, const std::vector<odf_reader::_property> & prop)
|
||||
{
|
||||
_CP_OPT(bool) bShadow;
|
||||
_CP_OPT(std::wstring) strShadowColor;
|
||||
_CP_OPT(double) dShadowOpacity;
|
||||
_CP_OPT(double) dShadowOffsetX;
|
||||
_CP_OPT(double) dShadowOffsetY;
|
||||
|
||||
odf_reader::GetProperty(prop, L"shadow", bShadow);
|
||||
odf_reader::GetProperty(prop, L"shadow-color", strShadowColor);
|
||||
odf_reader::GetProperty(prop, L"shadow-opacity", dShadowOpacity);
|
||||
odf_reader::GetProperty(prop, L"shadow-offset-x", dShadowOffsetX);
|
||||
odf_reader::GetProperty(prop, L"shadow-offset-y", dShadowOffsetY);
|
||||
|
||||
CP_XML_WRITER(strm)
|
||||
{
|
||||
CP_XML_NODE(L"a:effectLst")
|
||||
{
|
||||
if ((bShadow) && (*bShadow))
|
||||
{
|
||||
CP_XML_NODE(L"a:outerShdw")
|
||||
{
|
||||
//CP_XML_ATTR(L"blurRad", 0);
|
||||
|
||||
double offsetX = dShadowOffsetX.get_value_or(0);
|
||||
double offsetY = dShadowOffsetY.get_value_or(0);
|
||||
|
||||
double dist = sqrt(offsetX * offsetX + offsetY * offsetY);
|
||||
double dir = (offsetX > 0 ? atan(offsetY / offsetX) : 0) * 180. / 3.1415926;
|
||||
|
||||
CP_XML_ATTR(L"dist", (int)(dist));
|
||||
CP_XML_ATTR(L"dir", (int)(dir * 60000));
|
||||
|
||||
CP_XML_ATTR(L"rotWithShape", L"0");
|
||||
CP_XML_ATTR(L"algn", L"tl");
|
||||
|
||||
CP_XML_NODE(L"a:srgbClr")
|
||||
{
|
||||
if (strShadowColor)
|
||||
{
|
||||
CP_XML_ATTR(L"val", *strShadowColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
CP_XML_ATTR(L"val", L"000000");
|
||||
}
|
||||
if (dShadowOpacity)
|
||||
{
|
||||
CP_XML_NODE(L"a:alpha")
|
||||
{
|
||||
CP_XML_ATTR(L"val", *dShadowOpacity * 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void oox_serialize_ln(std::wostream & strm, const std::vector<odf_reader::_property> & prop, bool always_draw, const std::wstring &ns)
|
||||
{
|
||||
std::wstring ns_att = (ns == L"a" ? L"" : ns + L":");
|
||||
@ -199,7 +260,7 @@ void oox_serialize_ln(std::wostream & strm, const std::vector<odf_reader::_prope
|
||||
|
||||
CP_XML_NODE(ns + L":srgbClr")
|
||||
{
|
||||
CP_XML_ATTR2(ns_att + L"val",color);
|
||||
CP_XML_ATTR2(ns_att + L"val", color);
|
||||
|
||||
if (dStrokeOpacity)
|
||||
{
|
||||
@ -233,6 +294,39 @@ void oox_serialize_ln(std::wostream & strm, const std::vector<odf_reader::_prope
|
||||
}
|
||||
}
|
||||
}
|
||||
void vml_serialize_text(std::wostream & strm, const std::vector<odf_reader::_property> & prop)
|
||||
{
|
||||
_CP_OPT(std::wstring) strTextContent;
|
||||
odf_reader::GetProperty(prop, L"text-content", strTextContent);
|
||||
|
||||
CP_XML_WRITER(strm)
|
||||
{
|
||||
if (strTextContent)
|
||||
{
|
||||
CP_XML_NODE(L"v:textbox")
|
||||
{
|
||||
CP_XML_ATTR(L"style", L"mso-direction-alt:auto");
|
||||
CP_XML_ATTR(L"o:singleclick", L"f");
|
||||
|
||||
CP_XML_NODE(L"div")
|
||||
{
|
||||
CP_XML_ATTR(L"style", L"text-align:left");
|
||||
|
||||
CP_XML_NODE(L"font")
|
||||
{
|
||||
CP_XML_ATTR(L"face", L"Segoe UI");
|
||||
CP_XML_ATTR(L"size", L"160");
|
||||
CP_XML_ATTR(L"color", L"#000000");
|
||||
|
||||
const std::wstring & test_string = strTextContent.get();
|
||||
CP_XML_STREAM() << test_string;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
void vml_serialize_ln(std::wostream & strm, const std::vector<odf_reader::_property> & prop)
|
||||
{
|
||||
_CP_OPT(std::wstring) strStrokeColor;
|
||||
|
||||
@ -124,8 +124,10 @@ namespace oox {
|
||||
void oox_serialize_ln (std::wostream & strm, const std::vector<odf_reader::_property> & val, bool always_draw = false, const std::wstring &ns = L"a");
|
||||
void oox_serialize_aLst (std::wostream & strm, const std::vector<odf_reader::_property> & val, const std::wstring & shapeGeomPreset, const std::wstring &ns = L"a");
|
||||
void oox_serialize_action (std::wostream & strm, const _action_desc & val);
|
||||
void oox_serialize_effects (std::wostream & strm, const std::vector<odf_reader::_property> & val);
|
||||
|
||||
void vml_serialize_ln (std::wostream & strm, const std::vector<odf_reader::_property> & val);
|
||||
void vml_serialize_text (std::wostream & strm, const std::vector<odf_reader::_property> & val);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -101,6 +101,7 @@ void pptx_serialize_image(std::wostream & strm, _pptx_drawing & val)
|
||||
CP_XML_NODE(L"a:avLst");
|
||||
}
|
||||
oox_serialize_ln(CP_XML_STREAM(), val.additional);
|
||||
oox_serialize_effects(CP_XML_STREAM(), val.additional);
|
||||
}
|
||||
//_CP_OPT(std::wstring) strTextContent;
|
||||
//odf::GetProperty(properties,L"text-content",strTextContent);
|
||||
@ -186,7 +187,8 @@ void pptx_serialize_media(std::wostream & strm, _pptx_drawing & val)
|
||||
}
|
||||
oox_serialize_fill (CP_XML_STREAM(), val.fill);
|
||||
oox_serialize_ln (CP_XML_STREAM(), val.additional);
|
||||
}
|
||||
oox_serialize_effects(CP_XML_STREAM(), val.additional);
|
||||
}
|
||||
//_CP_OPT(std::wstring) strTextContent;
|
||||
//odf::GetProperty(properties,L"text-content",strTextContent);
|
||||
//pptx_serialize_text(CP_XML_STREAM(),val.additional);
|
||||
@ -248,6 +250,7 @@ void pptx_serialize_shape(std::wostream & strm, _pptx_drawing & val)
|
||||
val.serialize_shape(CP_XML_STREAM());
|
||||
|
||||
oox_serialize_ln(CP_XML_STREAM(), val.additional);
|
||||
oox_serialize_effects(CP_XML_STREAM(), val.additional);
|
||||
}
|
||||
}
|
||||
pptx_serialize_text(CP_XML_STREAM(), val);
|
||||
@ -307,6 +310,7 @@ void pptx_serialize_connector(std::wostream & strm, _pptx_drawing & val)
|
||||
val.serialize_shape(CP_XML_STREAM());
|
||||
|
||||
oox_serialize_ln(CP_XML_STREAM(), val.additional);
|
||||
oox_serialize_effects(CP_XML_STREAM(), val.additional);
|
||||
}
|
||||
}
|
||||
pptx_serialize_text(CP_XML_STREAM(), val);
|
||||
|
||||
@ -481,7 +481,6 @@ void _xlsx_drawing::serialize_control (std::wostream & strm)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
void _xlsx_drawing::serialize_vml(std::wostream & strm)
|
||||
{
|
||||
@ -520,6 +519,8 @@ void _xlsx_drawing::serialize_vml(std::wostream & strm)
|
||||
|
||||
vml_serialize_ln(CP_XML_STREAM(), additional);
|
||||
|
||||
vml_serialize_text(CP_XML_STREAM(), additional);
|
||||
|
||||
CP_XML_NODE(L"x:ClientData")
|
||||
{
|
||||
switch(sub_type)
|
||||
|
||||
@ -301,14 +301,32 @@ void common_background_color_attlist::serialize(CP_ATTR_NODE)
|
||||
void common_shadow_attlist::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
CP_APPLY_ATTR(L"style:shadow", style_shadow_);
|
||||
|
||||
CP_APPLY_ATTR(L"draw:shadow", draw_shadow_);
|
||||
CP_APPLY_ATTR(L"draw:shadow-opacity", draw_shadow_opacity_);
|
||||
CP_APPLY_ATTR(L"draw:shadow-color", draw_shadow_color_);
|
||||
CP_APPLY_ATTR(L"draw:shadow-offset-y", draw_shadow_offset_y_);
|
||||
CP_APPLY_ATTR(L"draw:shadow-offset-x", draw_shadow_offset_x_);
|
||||
}
|
||||
void common_shadow_attlist::apply_from(const common_shadow_attlist & Other)
|
||||
{
|
||||
_CP_APPLY_PROP(style_shadow_, Other.style_shadow_);
|
||||
_CP_APPLY_PROP(style_shadow_, Other.style_shadow_);
|
||||
|
||||
_CP_APPLY_PROP(draw_shadow_, Other.draw_shadow_);
|
||||
_CP_APPLY_PROP(draw_shadow_opacity_, Other.draw_shadow_opacity_);
|
||||
_CP_APPLY_PROP(draw_shadow_color_, Other.draw_shadow_color_);
|
||||
_CP_APPLY_PROP(draw_shadow_offset_y_, Other.draw_shadow_offset_y_);
|
||||
_CP_APPLY_PROP(draw_shadow_offset_x_, Other.draw_shadow_offset_x_);
|
||||
}
|
||||
void common_shadow_attlist::serialize(CP_ATTR_NODE)
|
||||
{
|
||||
CP_XML_ATTR_OPT(L"style:shadow", style_shadow_);
|
||||
|
||||
CP_XML_ATTR_OPT(L"draw:shadow", draw_shadow_);
|
||||
CP_XML_ATTR_OPT(L"draw:shadow-opacity", draw_shadow_opacity_);
|
||||
CP_XML_ATTR_OPT(L"draw:shadow-color", draw_shadow_color_);
|
||||
CP_XML_ATTR_OPT(L"draw:shadow-offset-y", draw_shadow_offset_y_);
|
||||
CP_XML_ATTR_OPT(L"draw:shadow-offset-x", draw_shadow_offset_x_);
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
@ -214,8 +214,13 @@ public:
|
||||
void apply_from(const common_shadow_attlist & Other);
|
||||
void serialize(CP_ATTR_NODE);
|
||||
|
||||
_CP_OPT(shadow_type) style_shadow_;
|
||||
_CP_OPT(shadow_type) style_shadow_;
|
||||
|
||||
_CP_OPT(odf_types::shadow_type1) draw_shadow_;
|
||||
_CP_OPT(odf_types::percent) draw_shadow_opacity_;
|
||||
_CP_OPT(odf_types::color) draw_shadow_color_;
|
||||
_CP_OPT(odf_types::length) draw_shadow_offset_y_;
|
||||
_CP_OPT(odf_types::length) draw_shadow_offset_x_;
|
||||
};
|
||||
|
||||
// common-keep-with-next-attlist
|
||||
|
||||
@ -913,9 +913,9 @@ void common_draw_docx_convert(oox::docx_conversion_context & Context, union_comm
|
||||
{
|
||||
drawing->posOffsetV = (int)(length(0.01, length::cm).get_value_unit(length::emu));
|
||||
}
|
||||
//////////////////////////////////////////////
|
||||
//----------------------------------------------------
|
||||
graphicProperties.apply_to(drawing->additional);
|
||||
//////////////////////////////////////////
|
||||
//----------------------------------------------------
|
||||
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);
|
||||
@ -926,7 +926,7 @@ void common_draw_docx_convert(oox::docx_conversion_context & Context, union_comm
|
||||
drawing->fill.bitmap->rId = Context.get_mediaitems()->add_or_find(href, oox::typeImage, drawing->fill.bitmap->isInternal, href);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
//----------------------------------------------------
|
||||
drawing->additional.push_back(odf_reader::_property(L"border_width_left", Compute_BorderWidth(graphicProperties, sideLeft)));
|
||||
drawing->additional.push_back(odf_reader::_property(L"border_width_top", Compute_BorderWidth(graphicProperties, sideTop)));
|
||||
drawing->additional.push_back(odf_reader::_property(L"border_width_right", Compute_BorderWidth(graphicProperties, sideRight)));
|
||||
@ -941,7 +941,8 @@ void common_draw_docx_convert(oox::docx_conversion_context & Context, union_comm
|
||||
|
||||
}
|
||||
}
|
||||
///////////////////////////
|
||||
//----------------------------------------------------
|
||||
//----------------------------------------------------
|
||||
if (attlists_.rel_size_.common_draw_size_attlist_.svg_width_)
|
||||
{
|
||||
double w_shape = attlists_.rel_size_.common_draw_size_attlist_.svg_width_->get_value_unit(length::pt);
|
||||
|
||||
@ -433,6 +433,7 @@ void draw_control::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
if (control->label_)
|
||||
{
|
||||
Context.get_drawing_context().set_property(_property(L"label", control->label_.get()));
|
||||
Context.get_drawing_context().set_property(_property(L"text-content", control->label_.get()));
|
||||
}
|
||||
//if (control->name_)
|
||||
//{
|
||||
|
||||
@ -290,6 +290,45 @@ void form_element::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
|
||||
Context.get_forms_context().end_element();
|
||||
}
|
||||
// form:frame
|
||||
//----------------------------------------------------------------------------------
|
||||
const wchar_t * form_frame::ns = L"form";
|
||||
const wchar_t * form_frame::name = L"frame";
|
||||
|
||||
void form_frame::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
object_type_ = OBJ_GroupBox;
|
||||
form_element::add_attributes(Attributes);
|
||||
}
|
||||
void form_frame::docx_convert(oox::docx_conversion_context & Context)
|
||||
{
|
||||
Context.get_forms_context().start_element(1);
|
||||
|
||||
form_element::docx_convert(Context);
|
||||
}
|
||||
void form_frame::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
{
|
||||
Context.get_forms_context().start_element(1);
|
||||
Context.get_forms_context().set_element(dynamic_cast<form_element*>(this));
|
||||
|
||||
form_element::xlsx_convert(Context);
|
||||
}
|
||||
void form_frame::serialize_control_props(std::wostream & strm)
|
||||
{
|
||||
formulasconvert::odf2oox_converter converter;
|
||||
CP_XML_WRITER(strm)
|
||||
{
|
||||
CP_XML_NODE(L"formControlPr")
|
||||
{
|
||||
CP_XML_ATTR(L"xmlns", L"http://schemas.microsoft.com/office/spreadsheetml/2009/9/main");
|
||||
|
||||
CP_XML_ATTR(L"objectType", L"GBox");
|
||||
|
||||
CP_XML_ATTR(L"dx", L"20");
|
||||
CP_XML_ATTR(L"noThreeD", L"1");
|
||||
}
|
||||
}
|
||||
}
|
||||
// form:button
|
||||
//----------------------------------------------------------------------------------
|
||||
const wchar_t * form_button::ns = L"form";
|
||||
@ -638,7 +677,68 @@ void form_checkbox::docx_convert_field(oox::docx_conversion_context & Context, d
|
||||
Context.output_stream() << L"</w:t>";
|
||||
Context.finish_run();
|
||||
}
|
||||
// form:checkbox
|
||||
//----------------------------------------------------------------------------------
|
||||
const wchar_t * form_radio::ns = L"form";
|
||||
const wchar_t * form_radio::name = L"radio";
|
||||
|
||||
void form_radio::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
object_type_ = OBJ_RadioButton;
|
||||
|
||||
_CP_OPT(std::wstring) strVal;
|
||||
CP_APPLY_ATTR(L"form:current-selected", strVal);
|
||||
|
||||
if ((strVal) && (*strVal == L"true"))
|
||||
{
|
||||
current_state_ = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
current_state_ = false;
|
||||
}
|
||||
|
||||
form_element::add_attributes(Attributes);
|
||||
}
|
||||
void form_radio::docx_convert(oox::docx_conversion_context & Context)
|
||||
{
|
||||
Context.get_forms_context().start_element(3);
|
||||
Context.get_forms_context().set_element(dynamic_cast<form_element*>(this));
|
||||
|
||||
form_element::docx_convert(Context);
|
||||
|
||||
//only to activeX object
|
||||
}
|
||||
void form_radio::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
{
|
||||
Context.get_forms_context().start_element(3);
|
||||
Context.get_forms_context().set_element(dynamic_cast<form_element*>(this));
|
||||
|
||||
form_element::xlsx_convert(Context);
|
||||
}
|
||||
void form_radio::serialize_control_props(std::wostream & strm)
|
||||
{
|
||||
CP_XML_WRITER(strm)
|
||||
{
|
||||
CP_XML_NODE(L"formControlPr")
|
||||
{
|
||||
CP_XML_ATTR(L"xmlns", L"http://schemas.microsoft.com/office/spreadsheetml/2009/9/main");
|
||||
|
||||
CP_XML_ATTR(L"objectType", L"Radio");
|
||||
if (current_state_)
|
||||
CP_XML_ATTR(L"checked", L"Checked");
|
||||
|
||||
CP_XML_ATTR(L"dx", L"20");
|
||||
CP_XML_ATTR(L"noThreeD", L"1");
|
||||
}
|
||||
}
|
||||
}
|
||||
void form_radio::docx_convert_sdt(oox::docx_conversion_context & Context, draw_control *draw)
|
||||
{
|
||||
}
|
||||
void form_radio::docx_convert_field(oox::docx_conversion_context & Context, draw_control *draw)
|
||||
{
|
||||
}
|
||||
// form:combobox
|
||||
//----------------------------------------------------------------------------------
|
||||
const wchar_t * form_combobox::ns = L"form";
|
||||
|
||||
@ -257,7 +257,27 @@ public:
|
||||
|
||||
int object_type_;
|
||||
};
|
||||
//-----------------------------------------------------------------------------------------
|
||||
// form:frame
|
||||
class form_frame : public form_element
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typeFormFrame;
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
virtual void docx_convert(oox::docx_conversion_context & Context);
|
||||
virtual void xlsx_convert(oox::xlsx_conversion_context & Context);
|
||||
virtual void pptx_convert(oox::pptx_conversion_context & Context){}
|
||||
|
||||
virtual void serialize_control_props(std::wostream & strm);
|
||||
private:
|
||||
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(form_frame);
|
||||
//-----------------------------------------------------------------------------------------
|
||||
// form:button
|
||||
class form_button : public form_element
|
||||
{
|
||||
@ -318,10 +338,9 @@ public:
|
||||
//form:convert-empty-to-null
|
||||
//form:readonly
|
||||
//form:max-length
|
||||
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(form_text);
|
||||
|
||||
//--------------------------------------------------------------------------------------------
|
||||
// form:fixed-text
|
||||
class form_fixed_text : public form_element
|
||||
{
|
||||
@ -346,7 +365,7 @@ private:
|
||||
public:
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(form_fixed_text);
|
||||
|
||||
//--------------------------------------------------------------------------------------------
|
||||
// form:textarea
|
||||
class form_textarea : public form_text
|
||||
{
|
||||
@ -358,7 +377,7 @@ public:
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(form_textarea);
|
||||
|
||||
//--------------------------------------------------------------------------------------------
|
||||
// form:checkbox
|
||||
class form_checkbox : public form_text
|
||||
{
|
||||
@ -389,7 +408,30 @@ public:
|
||||
//form:visual-effect
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(form_checkbox);
|
||||
//--------------------------------------------------------------------------------------------
|
||||
// form:radio
|
||||
class form_radio : public form_checkbox
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typeFormRadio;
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
virtual void docx_convert(oox::docx_conversion_context & Context);
|
||||
virtual void xlsx_convert(oox::xlsx_conversion_context & Context);
|
||||
virtual void pptx_convert(oox::pptx_conversion_context & Context){}
|
||||
|
||||
virtual void docx_convert_sdt (oox::docx_conversion_context & Context, draw_control *draw);
|
||||
virtual void docx_convert_field (oox::docx_conversion_context & Context, draw_control* draw);
|
||||
|
||||
virtual void serialize_control_props(std::wostream & strm);
|
||||
private:
|
||||
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(form_radio);
|
||||
//--------------------------------------------------------------------------------------------
|
||||
// form:value-range
|
||||
class form_value_range : public form_element
|
||||
{
|
||||
|
||||
@ -158,13 +158,22 @@ void graphic_format_properties::apply_to(std::vector<_property> & properties)
|
||||
{
|
||||
properties.push_back(_property(L"contrast", common_draw_fill_attlist_.draw_contrast_->get_value()));
|
||||
}
|
||||
if (common_shadow_attlist_.draw_shadow_.get_value_or(shadow_type1::Hidden).get_type() == shadow_type1::Visible)
|
||||
{
|
||||
properties.push_back(_property(L"shadow", true));
|
||||
if (common_shadow_attlist_.draw_shadow_color_) properties.push_back(_property(L"shadow-color", common_shadow_attlist_.draw_shadow_color_->get_hex_value()));
|
||||
if (common_shadow_attlist_.draw_shadow_opacity_) properties.push_back(_property(L"shadow-opacity", common_shadow_attlist_.draw_shadow_opacity_->get_value()));
|
||||
if (common_shadow_attlist_.draw_shadow_offset_x_) properties.push_back(_property(L"shadow-offset-x", common_shadow_attlist_.draw_shadow_offset_x_->get_value_unit(length::emu)));
|
||||
if (common_shadow_attlist_.draw_shadow_offset_y_) properties.push_back(_property(L"shadow-offset-y", common_shadow_attlist_.draw_shadow_offset_y_->get_value_unit(length::emu)));
|
||||
}
|
||||
if (common_padding_attlist_.fo_padding_)
|
||||
{
|
||||
properties.push_back(_property(L"text-padding-left", common_padding_attlist_.fo_padding_->get_value_unit(length::emu)));
|
||||
properties.push_back(_property(L"text-padding-right", common_padding_attlist_.fo_padding_->get_value_unit(length::emu)));
|
||||
properties.push_back(_property(L"text-padding-top", common_padding_attlist_.fo_padding_->get_value_unit(length::emu)));
|
||||
properties.push_back(_property(L"text-padding-bottom", common_padding_attlist_.fo_padding_->get_value_unit(length::emu)));
|
||||
}else
|
||||
}
|
||||
else
|
||||
{
|
||||
if (common_padding_attlist_.fo_padding_left_)
|
||||
properties.push_back(_property(L"text-padding-left", common_padding_attlist_.fo_padding_left_->get_value_unit(length::emu)));
|
||||
|
||||
@ -45,7 +45,7 @@ namespace cpdoccore {
|
||||
namespace odf_writer {
|
||||
|
||||
|
||||
/// style:header-footer-properties-attlist
|
||||
// style:header-footer-properties-attlist
|
||||
class style_header_footer_properties_attlist
|
||||
{
|
||||
public:
|
||||
@ -53,11 +53,11 @@ public:
|
||||
|
||||
_CP_OPT(odf_types::length) svg_height_;
|
||||
_CP_OPT(odf_types::length) fo_min_height_;
|
||||
odf_types::common_horizontal_margin_attlist common_horizontal_margin_attlist_;
|
||||
odf_types::common_horizontal_margin_attlist common_horizontal_margin_attlist_;
|
||||
odf_types::common_vertical_margin_attlist common_vertical_margin_attlist_;
|
||||
odf_types::common_margin_attlist common_margin_attlist_;
|
||||
odf_types::common_border_attlist common_border_attlist_;
|
||||
odf_types::common_border_line_width_attlist common_border_line_width_attlist_;
|
||||
odf_types::common_border_line_width_attlist common_border_line_width_attlist_;
|
||||
odf_types::common_padding_attlist common_padding_attlist_;
|
||||
odf_types::common_background_color_attlist common_background_color_attlist_;
|
||||
odf_types::common_shadow_attlist common_shadow_attlist_;
|
||||
@ -65,7 +65,7 @@ public:
|
||||
|
||||
};
|
||||
|
||||
/// style:header-footer-properties
|
||||
// style:header-footer-properties
|
||||
class style_header_footer_properties : public office_element_impl<style_header_footer_properties>
|
||||
{
|
||||
public:
|
||||
@ -89,7 +89,7 @@ public:
|
||||
CP_REGISTER_OFFICE_ELEMENT2(style_header_footer_properties)
|
||||
|
||||
|
||||
/// common:style-header-footer-attlist
|
||||
// common:style-header-footer-attlist
|
||||
class common_style_header_footer_attlist
|
||||
{
|
||||
public:
|
||||
@ -98,7 +98,7 @@ public:
|
||||
|
||||
};
|
||||
|
||||
/// header:footer-content
|
||||
// header:footer-content
|
||||
class header_footer_content
|
||||
{
|
||||
public:
|
||||
|
||||
@ -133,7 +133,10 @@ struct anchor_settings
|
||||
_CP_OPT(anchor_type) anchor_type_;
|
||||
_CP_OPT(run_through) run_through_;
|
||||
|
||||
_CP_OPT(style_wrap) style_wrap_;
|
||||
_CP_OPT(style_wrap) style_wrap_;
|
||||
_CP_OPT(odf_types::integer_or_nolimit) style_number_wrapped_paragraphs_;
|
||||
_CP_OPT(odf_types::Bool) style_wrap_contour_;
|
||||
_CP_OPT(odf_types::wrap_contour_mode) style_wrap_contour_mode_;
|
||||
|
||||
void clear()
|
||||
{
|
||||
@ -159,6 +162,9 @@ struct anchor_settings
|
||||
fo_margin_bottom_ = boost::none;
|
||||
|
||||
style_wrap_ = boost::none;
|
||||
style_wrap_contour_ = boost::none;
|
||||
style_wrap_contour_mode_ = boost::none;
|
||||
style_number_wrapped_paragraphs_ = boost::none;
|
||||
}
|
||||
};
|
||||
|
||||
@ -434,6 +440,9 @@ void odf_drawing_context::start_group()
|
||||
|
||||
impl_->current_graphic_properties->style_wrap_ = impl_->anchor_settings_.style_wrap_;
|
||||
impl_->current_graphic_properties->style_run_through_ = impl_->anchor_settings_.run_through_;
|
||||
impl_->current_graphic_properties->style_wrap_contour_ = impl_->anchor_settings_.style_wrap_contour_;
|
||||
impl_->current_graphic_properties->style_wrap_contour_mode_ = impl_->anchor_settings_.style_wrap_contour_mode_;
|
||||
impl_->current_graphic_properties->style_number_wrapped_paragraphs_ = impl_->anchor_settings_.style_number_wrapped_paragraphs_;
|
||||
|
||||
impl_->current_graphic_properties->common_vertical_pos_attlist_.style_vertical_pos_ = impl_->anchor_settings_.style_vertical_pos_;
|
||||
impl_->current_graphic_properties->common_horizontal_pos_attlist_.style_horizontal_pos_ = impl_->anchor_settings_.style_horizontal_pos_;
|
||||
@ -664,7 +673,10 @@ void odf_drawing_context::end_drawing()
|
||||
draw->common_draw_attlists_.shape_with_text_and_styles_.common_text_anchor_attlist_.type_ = impl_->anchor_settings_.anchor_type_;
|
||||
|
||||
impl_->current_graphic_properties->style_wrap_ = impl_->anchor_settings_.style_wrap_;
|
||||
impl_->current_graphic_properties->style_run_through_ = impl_->anchor_settings_.run_through_;
|
||||
impl_->current_graphic_properties->style_run_through_ = impl_->anchor_settings_.run_through_;
|
||||
impl_->current_graphic_properties->style_wrap_contour_ = impl_->anchor_settings_.style_wrap_contour_;
|
||||
impl_->current_graphic_properties->style_wrap_contour_mode_ = impl_->anchor_settings_.style_wrap_contour_mode_;
|
||||
impl_->current_graphic_properties->style_number_wrapped_paragraphs_ = impl_->anchor_settings_.style_number_wrapped_paragraphs_;
|
||||
}
|
||||
//if (impl_->anchor_settings_.anchor_type_ && impl_->anchor_settings_.anchor_type_->get_type()== anchor_type::AsChar)
|
||||
//{
|
||||
@ -1343,17 +1355,17 @@ void odf_drawing_context::set_shadow(int type, std::wstring hexColor, _CP_OPT(do
|
||||
if (std::wstring::npos == res)
|
||||
hexColor = std::wstring(L"#") + hexColor;
|
||||
|
||||
impl_->current_graphic_properties->draw_shadow_offset_x_ = length(length(dist_pt,length::pt).get_value_unit(length::cm),length::cm);
|
||||
impl_->current_graphic_properties->common_shadow_attlist_.draw_shadow_offset_x_ = length(length(dist_pt, length::pt).get_value_unit(length::cm), length::cm);
|
||||
|
||||
if (dist_pt_y > 0)
|
||||
impl_->current_graphic_properties->draw_shadow_offset_y_ = length(length(dist_pt_y,length::pt).get_value_unit(length::cm),length::cm);
|
||||
impl_->current_graphic_properties->common_shadow_attlist_.draw_shadow_offset_y_ = length(length(dist_pt_y, length::pt).get_value_unit(length::cm), length::cm);
|
||||
else
|
||||
impl_->current_graphic_properties->draw_shadow_offset_y_ = length(length(dist_pt,length::pt).get_value_unit(length::cm),length::cm);
|
||||
impl_->current_graphic_properties->common_shadow_attlist_.draw_shadow_offset_y_ = length(length(dist_pt, length::pt).get_value_unit(length::cm), length::cm);
|
||||
|
||||
impl_->current_graphic_properties->draw_shadow_ = shadow_type1(shadow_type1::Visible);
|
||||
if (opacity) impl_->current_graphic_properties->draw_shadow_opacity_ = *opacity;
|
||||
impl_->current_graphic_properties->common_shadow_attlist_.draw_shadow_ = shadow_type1(shadow_type1::Visible);
|
||||
if (opacity) impl_->current_graphic_properties->common_shadow_attlist_.draw_shadow_opacity_ = *opacity;
|
||||
|
||||
impl_->current_graphic_properties->draw_shadow_color_ = hexColor;
|
||||
impl_->current_graphic_properties->common_shadow_attlist_.draw_shadow_color_ = hexColor;
|
||||
}
|
||||
|
||||
void odf_drawing_context::set_placeholder_id (std::wstring val)
|
||||
@ -1922,10 +1934,10 @@ void odf_drawing_context::set_wrap_style(style_wrap::type type)
|
||||
}
|
||||
void odf_drawing_context::set_wrap_contour()
|
||||
{
|
||||
if (!impl_->current_graphic_properties)return;
|
||||
impl_->anchor_settings_.style_wrap_contour_ = true;
|
||||
impl_->anchor_settings_.style_wrap_contour_mode_ = wrap_contour_mode(wrap_contour_mode::Full);
|
||||
impl_->anchor_settings_.style_number_wrapped_paragraphs_ = integer_or_nolimit(integer_or_nolimit::NoLimit);
|
||||
|
||||
impl_->current_graphic_properties->style_wrap_contour_ = true;
|
||||
impl_->current_graphic_properties->style_wrap_contour_mode_ = wrap_contour_mode(wrap_contour_mode::Full);
|
||||
}
|
||||
void odf_drawing_context::set_overlap (bool val)
|
||||
{
|
||||
@ -2936,25 +2948,25 @@ void odf_drawing_context::end_text_box()
|
||||
impl_->current_graphic_properties->common_border_attlist_.fo_border_ = ss.str();
|
||||
}
|
||||
|
||||
if (impl_->current_graphic_properties->draw_shadow_)
|
||||
if (impl_->current_graphic_properties->common_shadow_attlist_.draw_shadow_)
|
||||
{
|
||||
std::wstringstream shadow_style;
|
||||
|
||||
if (impl_->current_graphic_properties->draw_shadow_color_)
|
||||
shadow_style << *impl_->current_graphic_properties->draw_shadow_color_;
|
||||
if (impl_->current_graphic_properties->common_shadow_attlist_.draw_shadow_color_)
|
||||
shadow_style << *impl_->current_graphic_properties->common_shadow_attlist_.draw_shadow_color_;
|
||||
else shadow_style << L"#000000";
|
||||
|
||||
shadow_style << L" ";
|
||||
shadow_style << *impl_->current_graphic_properties->draw_shadow_offset_x_;
|
||||
shadow_style << *impl_->current_graphic_properties->common_shadow_attlist_.draw_shadow_offset_x_;
|
||||
shadow_style << L" ";
|
||||
shadow_style << *impl_->current_graphic_properties->draw_shadow_offset_y_;
|
||||
shadow_style << *impl_->current_graphic_properties->common_shadow_attlist_.draw_shadow_offset_y_;
|
||||
|
||||
impl_->current_graphic_properties->common_shadow_attlist_.style_shadow_ = shadow_style.str();
|
||||
|
||||
impl_->current_graphic_properties->draw_shadow_offset_x_ = boost::none;
|
||||
impl_->current_graphic_properties->draw_shadow_offset_y_ = boost::none;
|
||||
impl_->current_graphic_properties->draw_shadow_color_ = boost::none;
|
||||
impl_->current_graphic_properties->draw_shadow_ = boost::none;
|
||||
impl_->current_graphic_properties->common_shadow_attlist_.draw_shadow_offset_x_ = boost::none;
|
||||
impl_->current_graphic_properties->common_shadow_attlist_.draw_shadow_offset_y_ = boost::none;
|
||||
impl_->current_graphic_properties->common_shadow_attlist_.draw_shadow_color_ = boost::none;
|
||||
impl_->current_graphic_properties->common_shadow_attlist_.draw_shadow_ = boost::none;
|
||||
|
||||
if (!impl_->current_graphic_properties->common_border_attlist_.fo_border_)
|
||||
impl_->current_graphic_properties->common_border_attlist_.fo_border_ = std::wstring(L"#000000 solid 0.06pt");
|
||||
|
||||
@ -325,9 +325,9 @@ bool odf_page_layout_context::add_footer(int type)
|
||||
//настраить нужно 1 раз
|
||||
if (!layout_state_list_.back().footer_size_) return true;
|
||||
|
||||
style_header_footer_properties * footer_props = get_footer_properties();
|
||||
style_header_footer_properties *footer_props = get_footer_properties();
|
||||
if (!footer_props)return true;
|
||||
style_page_layout_properties * props = get_properties();
|
||||
style_page_layout_properties *props = get_properties();
|
||||
if (!props)return true;
|
||||
|
||||
length length_ = length(layout_state_list_.back().footer_size_->get_value_unit(length::cm),length::cm);
|
||||
@ -369,9 +369,13 @@ bool odf_page_layout_context::add_header(int type)
|
||||
create_element(L"style", L"header-left", root_header_footer_, odf_context_);
|
||||
}
|
||||
else if (type == 2)
|
||||
{
|
||||
create_element(L"style", L"header-first", root_header_footer_, odf_context_);
|
||||
}
|
||||
else
|
||||
{
|
||||
create_element(L"style", L"header", root_header_footer_, odf_context_);
|
||||
}
|
||||
|
||||
if (!root_header_footer_) return false;
|
||||
|
||||
@ -383,13 +387,13 @@ bool odf_page_layout_context::add_header(int type)
|
||||
//настроить нужно один раз
|
||||
if (!layout_state_list_.back().header_size_) return true;
|
||||
|
||||
style_header_footer_properties * header_props = get_header_properties();
|
||||
style_header_footer_properties *header_props = get_header_properties();
|
||||
if (!header_props)return true;
|
||||
|
||||
style_page_layout_properties * props = get_properties();
|
||||
style_page_layout_properties *props = get_properties();
|
||||
if (!props)return true;
|
||||
|
||||
length length_ = length(layout_state_list_.back().header_size_->get_value_unit(length::cm),length::cm);
|
||||
length length_ = length(layout_state_list_.back().header_size_->get_value_unit(length::cm), length::cm);
|
||||
|
||||
_CP_OPT(length) top_;
|
||||
|
||||
@ -418,6 +422,16 @@ bool odf_page_layout_context::add_header(int type)
|
||||
return true;
|
||||
}
|
||||
|
||||
void odf_page_layout_context::set_header_footer_image(office_element_ptr image)
|
||||
{
|
||||
style_header_footer_properties *header_footer_props = get_footer_properties();
|
||||
if (!header_footer_props)return;
|
||||
|
||||
if (!header_footer_props->style_background_image_ )// картинка общая для всех четных, нечетных, первых, так же нету центральных, левых, правых
|
||||
{
|
||||
header_footer_props->style_background_image_ = image;
|
||||
}
|
||||
}
|
||||
void odf_page_layout_context::set_page_border_offset (int type)
|
||||
{
|
||||
if (type < 1) return;
|
||||
|
||||
@ -98,12 +98,14 @@ public:
|
||||
bool add_footer(int type);
|
||||
void set_footer_size(_CP_OPT(odf_types::length) length_);
|
||||
|
||||
bool add_header(int type);
|
||||
bool add_header(int type);
|
||||
void set_header_size(_CP_OPT(odf_types::length) length_);
|
||||
|
||||
void set_background (_CP_OPT(odf_types::color) & color, int type);
|
||||
void set_header_footer_image (office_element_ptr image);
|
||||
void set_background (_CP_OPT(odf_types::color) & color, int type);
|
||||
|
||||
void set_page_number_format (_CP_OPT(int) & type, _CP_OPT(int) & start);
|
||||
|
||||
void set_page_number_format (_CP_OPT(int) & type, _CP_OPT(int) & start);
|
||||
|
||||
office_element_ptr root_header_footer_; //для топовых элементов в style:footer
|
||||
|
||||
|
||||
@ -161,7 +161,18 @@ void odf_text_context::add_text_date(const std::wstring & text)
|
||||
text_date* s = dynamic_cast<text_date*>(s_elm.get());
|
||||
if (s) s->add_text(text);
|
||||
|
||||
if (current_level_.size()>0)
|
||||
if (false == current_level_.empty())
|
||||
current_level_.back().elm->add_child_element(s_elm);
|
||||
}
|
||||
void odf_text_context::add_text_time(const std::wstring & text)
|
||||
{
|
||||
office_element_ptr s_elm;
|
||||
create_element(L"text", L"time", s_elm, odf_context_);
|
||||
|
||||
text_time* s = dynamic_cast<text_time*>(s_elm.get());
|
||||
if (s) s->add_text(text);
|
||||
|
||||
if (false == current_level_.empty())
|
||||
current_level_.back().elm->add_child_element(s_elm);
|
||||
}
|
||||
void odf_text_context::add_text_page_number(const std::wstring & text)
|
||||
@ -172,9 +183,43 @@ void odf_text_context::add_text_page_number(const std::wstring & text)
|
||||
text_page_number* s = dynamic_cast<text_page_number*>(s_elm.get());
|
||||
if (s) s->add_text(text);
|
||||
|
||||
if (current_level_.size()>0)
|
||||
if (false == current_level_.empty())
|
||||
current_level_.back().elm->add_child_element(s_elm);
|
||||
}
|
||||
void odf_text_context::add_text_page_count(const std::wstring & text)
|
||||
{
|
||||
office_element_ptr s_elm;
|
||||
create_element(L"text", L"page-count", s_elm, odf_context_);
|
||||
|
||||
text_page_count* s = dynamic_cast<text_page_count*>(s_elm.get());
|
||||
if (s) s->add_text(text);
|
||||
|
||||
if (false == current_level_.empty())
|
||||
current_level_.back().elm->add_child_element(s_elm);
|
||||
}
|
||||
void odf_text_context::add_text_file_name(const std::wstring &text)
|
||||
{
|
||||
office_element_ptr s_elm;
|
||||
create_element(L"text", L"file-name", s_elm, odf_context_);
|
||||
|
||||
text_file_name* s = dynamic_cast<text_file_name*>(s_elm.get());
|
||||
if (s) s->add_text(text);
|
||||
|
||||
if (false == current_level_.empty())
|
||||
current_level_.back().elm->add_child_element(s_elm);
|
||||
}
|
||||
void odf_text_context::add_text_sheet_name(const std::wstring &text)
|
||||
{
|
||||
office_element_ptr s_elm;
|
||||
create_element(L"text", L"sheet-name", s_elm, odf_context_);
|
||||
|
||||
text_sheet_name* s = dynamic_cast<text_sheet_name*>(s_elm.get());
|
||||
if (s) s->add_text(text);
|
||||
|
||||
if (false == current_level_.empty())
|
||||
current_level_.back().elm->add_child_element(s_elm);
|
||||
}
|
||||
|
||||
void odf_text_context::add_text_space(int count)
|
||||
{
|
||||
office_element_ptr s_elm;
|
||||
@ -188,7 +233,7 @@ void odf_text_context::add_text_space(int count)
|
||||
//odf_element_state state={ s_elm, L"", office_element_ptr(), level};
|
||||
//text_elements_list_.push_back(state);
|
||||
|
||||
if (current_level_.size()>0)
|
||||
if (false == current_level_.empty())
|
||||
current_level_.back().elm->add_child_element(s_elm);
|
||||
}
|
||||
void odf_text_context::set_symbol_font(const std::wstring & font)
|
||||
@ -262,7 +307,7 @@ void odf_text_context::start_paragraph(office_element_ptr & elm, bool styled)
|
||||
paragraph_properties_ = style_->content_.get_style_paragraph_properties();
|
||||
}
|
||||
}
|
||||
else if (parent_paragraph_style_.length() >0)
|
||||
else if (false == parent_paragraph_style_.empty())
|
||||
{
|
||||
text_p* p = dynamic_cast<text_p*>(elm.get());
|
||||
if (p)p->paragraph_.paragraph_attrs_.text_style_name_ = parent_paragraph_style_;
|
||||
@ -287,7 +332,7 @@ void odf_text_context::start_paragraph(office_element_ptr & elm, bool styled)
|
||||
|
||||
void odf_text_context::end_paragraph()
|
||||
{
|
||||
if (single_paragraph_ == false && current_level_.size() > 0)
|
||||
if (false == single_paragraph_ && false == current_level_.empty())
|
||||
{
|
||||
current_level_.pop_back();
|
||||
}
|
||||
|
||||
@ -83,11 +83,15 @@ public:
|
||||
|
||||
void set_single_object (bool bSingle, style_paragraph_properties *para_props, style_text_properties *text_props);
|
||||
|
||||
void add_text_content (const std::wstring & text);
|
||||
void add_text_content (const std::wstring &text);
|
||||
void add_text_space (int count);
|
||||
void add_text_date (const std::wstring & text);
|
||||
void add_text_page_number(const std::wstring & text);
|
||||
|
||||
void add_text_date (const std::wstring &text);
|
||||
void add_text_time (const std::wstring &text);
|
||||
void add_text_page_number(const std::wstring &text);
|
||||
void add_text_page_count(const std::wstring &text);
|
||||
void add_text_file_name (const std::wstring &text);
|
||||
void add_text_sheet_name(const std::wstring &text);
|
||||
|
||||
void set_symbol_font (const std::wstring & font);
|
||||
void set_symbol_text (int sym);
|
||||
|
||||
|
||||
@ -140,9 +140,13 @@ void ods_conversion_context::add_defined_expression( const std::wstring & name,
|
||||
{
|
||||
table_context_.add_defined_expression(name,value, sheet_id, printable);
|
||||
}
|
||||
void ods_conversion_context::add_header_footer_image(const std::wstring & name, office_element_ptr image)
|
||||
{
|
||||
current_table().mapHeaderFooterImages.insert(std::make_pair(name, image));
|
||||
}
|
||||
void ods_conversion_context::start_sheet()
|
||||
{
|
||||
create_element(L"table", L"table",root_spreadsheet_->getContent(),this);
|
||||
create_element(L"table", L"table", root_spreadsheet_->getContent(), this);
|
||||
table_context_.start_table(root_spreadsheet_->getContent().back());
|
||||
|
||||
drawing_context()->set_styles_context(styles_context());
|
||||
@ -589,6 +593,19 @@ void ods_conversion_context::add_text_content(const std::wstring & text)
|
||||
current_text_context_->add_text_content(text);
|
||||
}
|
||||
}
|
||||
|
||||
void ods_conversion_context::add_text(const std::wstring &text)
|
||||
{
|
||||
office_element_ptr paragr_elm;
|
||||
create_element(L"text", L"p", paragr_elm, this);
|
||||
|
||||
current_text_context_->start_paragraph(paragr_elm);
|
||||
|
||||
current_text_context_->add_text_content(text);
|
||||
|
||||
current_text_context_->end_paragraph();
|
||||
}
|
||||
|
||||
void ods_conversion_context::start_cell_text()
|
||||
{
|
||||
start_text_context();
|
||||
@ -663,7 +680,112 @@ void ods_conversion_context::end_table_view()
|
||||
settings_context()->end_table();
|
||||
settings_context()->set_current_view(-1);
|
||||
}
|
||||
bool ods_conversion_context::start_header(int type)// 0 - odd, 1 - first, 2 - even
|
||||
{
|
||||
if (page_layout_context()->add_header(type) == false) return false;
|
||||
if (page_layout_context()->last_master() == NULL) return false;
|
||||
|
||||
start_text_context();
|
||||
text_context()->set_styles_context(page_layout_context()->get_local_styles_context());
|
||||
|
||||
text_context()->start_element(page_layout_context()->last_master()->get_last_element());
|
||||
|
||||
if (false == current_table().mapHeaderFooterImages.empty())
|
||||
{
|
||||
std::wstring mask = std::wstring(L"H") + (type == 1 ? L"FIRST" : (type == 2 ? L"EVEN" : L""));
|
||||
|
||||
std::map<std::wstring, office_element_ptr>::iterator pFind;
|
||||
|
||||
pFind = current_table().mapHeaderFooterImages.find(L"C" + mask);
|
||||
if (pFind == current_table().mapHeaderFooterImages.end())
|
||||
{
|
||||
pFind = current_table().mapHeaderFooterImages.find(L"L" + mask);
|
||||
if (pFind == current_table().mapHeaderFooterImages.end())
|
||||
{
|
||||
pFind = current_table().mapHeaderFooterImages.find(L"R" + mask);
|
||||
}
|
||||
}
|
||||
|
||||
if (pFind != current_table().mapHeaderFooterImages.end())
|
||||
{
|
||||
page_layout_context()->set_header_footer_image(pFind->second);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool ods_conversion_context::start_footer(int type)
|
||||
{
|
||||
if (page_layout_context()->add_footer(type) == false) return false;
|
||||
if (page_layout_context()->last_master() == NULL) return false;
|
||||
|
||||
start_text_context();
|
||||
text_context()->set_styles_context(page_layout_context()->get_local_styles_context());
|
||||
|
||||
text_context()->start_element(page_layout_context()->last_master()->get_last_element());
|
||||
|
||||
if (false == current_table().mapHeaderFooterImages.empty())
|
||||
{
|
||||
std::wstring mask = std::wstring(L"F") + (type == 1 ? L"FIRST" : (type == 2 ? L"EVEN" : L""));
|
||||
|
||||
std::map<std::wstring, office_element_ptr>::iterator pFind;
|
||||
|
||||
pFind = current_table().mapHeaderFooterImages.find(L"C" + mask);
|
||||
if (pFind == current_table().mapHeaderFooterImages.end())
|
||||
{
|
||||
pFind = current_table().mapHeaderFooterImages.find(L"L" + mask);
|
||||
if (pFind == current_table().mapHeaderFooterImages.end())
|
||||
{
|
||||
pFind = current_table().mapHeaderFooterImages.find(L"R" + mask);
|
||||
}
|
||||
}
|
||||
|
||||
if (pFind != current_table().mapHeaderFooterImages.end())
|
||||
{
|
||||
page_layout_context()->set_header_footer_image(pFind->second);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
void ods_conversion_context::end_header_footer()
|
||||
{
|
||||
if (text_context()->current_level_.size() > 1)
|
||||
{
|
||||
text_context()->end_paragraph();
|
||||
end_header_footer_region();
|
||||
}
|
||||
text_context()->end_element();
|
||||
end_text_context();
|
||||
}
|
||||
void ods_conversion_context::start_header_footer_region(int type)
|
||||
{
|
||||
if (text_context()->current_level_.size() > 1)
|
||||
{
|
||||
text_context()->end_paragraph();
|
||||
end_header_footer_region();
|
||||
}
|
||||
|
||||
office_element_ptr region_elm_;
|
||||
|
||||
if (type == 1)
|
||||
{
|
||||
create_element(L"style", L"region-left", region_elm_, this);
|
||||
}
|
||||
else if (type == 2)
|
||||
{
|
||||
create_element(L"style", L"region-center", region_elm_, this);
|
||||
}
|
||||
else if (type == 3)
|
||||
{
|
||||
create_element(L"style", L"region-right", region_elm_, this);
|
||||
}
|
||||
|
||||
text_context()->start_element(region_elm_);
|
||||
text_context()->start_paragraph(false);
|
||||
}
|
||||
void ods_conversion_context::end_header_footer_region()
|
||||
{
|
||||
text_context()->end_element();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -120,6 +120,16 @@ public:
|
||||
void start_drawings();
|
||||
void end_drawings();
|
||||
|
||||
bool start_header(int type);
|
||||
bool start_footer(int type);
|
||||
void end_header_footer();
|
||||
void start_header_footer_region(int type);
|
||||
void end_header_footer_region();
|
||||
|
||||
void add_text(const std::wstring &text);
|
||||
|
||||
void add_header_footer_image(const std::wstring & name, office_element_ptr image);
|
||||
|
||||
double convert_symbol_width(double val);
|
||||
|
||||
void add_defined_range (const std::wstring & name, const std::wstring & cell_range, int sheet_id, bool printable = false);
|
||||
|
||||
@ -410,6 +410,8 @@ public:
|
||||
|
||||
std::wstring office_table_name_;
|
||||
std::vector<ods_comment_state> comments_;
|
||||
|
||||
std::map<std::wstring, office_element_ptr> mapHeaderFooterImages;
|
||||
private:
|
||||
|
||||
struct _spanned_info
|
||||
|
||||
@ -185,6 +185,8 @@ public:
|
||||
|
||||
bool is_paragraph_in_current_section_;
|
||||
|
||||
bool empty() {return current_root_elements_.empty();}
|
||||
|
||||
private:
|
||||
office_text* root_text_;
|
||||
office_element_ptr root_document_;
|
||||
|
||||
@ -367,10 +367,18 @@ void form_radio::serialize(std::wostream & _Wostream)
|
||||
{
|
||||
CP_XML_NODE_SIMPLE()
|
||||
{
|
||||
CP_XML_ATTR(L"form:selected", current_state_ ? L"true" : L"false");
|
||||
|
||||
form_element::serialize_attlist(CP_GET_XML_NODE());
|
||||
|
||||
if (current_state_)
|
||||
{
|
||||
CP_XML_ATTR(L"form:selected", current_state_ ? L"true" : L"false");
|
||||
CP_XML_ATTR(L"form:current-selected", current_state_ ? L"true" : L"false");
|
||||
}
|
||||
|
||||
CP_XML_ATTR(L"form:visual-effect", L"flat");
|
||||
CP_XML_ATTR(L"form:input-required", L"false");
|
||||
CP_XML_ATTR(L"form:group-name", L"autoGroup_formControl");
|
||||
|
||||
if (properties_) properties_->serialize(CP_XML_STREAM());
|
||||
if (office_event_listeners_) office_event_listeners_->serialize(CP_XML_STREAM());
|
||||
}
|
||||
@ -391,7 +399,9 @@ void form_checkbox::serialize(std::wostream & _Wostream)
|
||||
form_element::serialize_attlist(CP_GET_XML_NODE());
|
||||
|
||||
if (current_state_)
|
||||
{
|
||||
CP_XML_ATTR(L"form:current-state", L"checked" );
|
||||
}
|
||||
|
||||
if (properties_) properties_->serialize(CP_XML_STREAM());
|
||||
if (office_event_listeners_) office_event_listeners_->serialize(CP_XML_STREAM());
|
||||
|
||||
@ -157,13 +157,7 @@ void graphic_format_properties::serialize(std::wostream & _Wostream ,const wchar
|
||||
CP_XML_ATTR_OPT(L"style:overflow-behavior", style_overflow_behavior_);
|
||||
CP_XML_ATTR_OPT(L"style:mirror", style_mirror_);
|
||||
|
||||
//common_shadow_attlist_.serialize(CP_GET_XML_NODE());
|
||||
|
||||
CP_XML_ATTR_OPT(L"draw:shadow", draw_shadow_);
|
||||
CP_XML_ATTR_OPT(L"draw:shadow-opacity", draw_shadow_opacity_);
|
||||
CP_XML_ATTR_OPT(L"draw:shadow-color", draw_shadow_color_);
|
||||
CP_XML_ATTR_OPT(L"draw:shadow-offset-y", draw_shadow_offset_y_);
|
||||
CP_XML_ATTR_OPT(L"draw:shadow-offset-x", draw_shadow_offset_x_);
|
||||
common_shadow_attlist_.serialize(CP_GET_XML_NODE());
|
||||
|
||||
common_draw_rel_size_attlist_.serialize(CP_GET_XML_NODE());
|
||||
common_horizontal_margin_attlist_.serialize(CP_GET_XML_NODE());
|
||||
@ -176,7 +170,6 @@ void graphic_format_properties::serialize(std::wostream & _Wostream ,const wchar
|
||||
common_text_anchor_attlist_.serialize(CP_GET_XML_NODE());
|
||||
common_border_attlist_.serialize(CP_GET_XML_NODE());
|
||||
common_border_line_width_attlist_.serialize(CP_GET_XML_NODE());
|
||||
common_shadow_attlist_.serialize(CP_GET_XML_NODE());
|
||||
common_padding_attlist_.serialize(CP_GET_XML_NODE());
|
||||
common_background_color_attlist_.serialize(CP_GET_XML_NODE());
|
||||
}
|
||||
|
||||
@ -97,12 +97,6 @@ public:
|
||||
_CP_OPT(odf_types::Bool) draw_fit_to_contour_;
|
||||
_CP_OPT(std::wstring) draw_wrap_influence_on_position_;
|
||||
|
||||
//odf_types::common_shadow_attlist common_shadow_attlist_;
|
||||
_CP_OPT(odf_types::shadow_type1) draw_shadow_;
|
||||
_CP_OPT(odf_types::percent) draw_shadow_opacity_;
|
||||
_CP_OPT(odf_types::color) draw_shadow_color_;
|
||||
_CP_OPT(odf_types::length) draw_shadow_offset_y_;
|
||||
_CP_OPT(odf_types::length) draw_shadow_offset_x_;
|
||||
_CP_OPT(unsigned int) draw_ole_draw_aspect_;
|
||||
|
||||
odf_types::common_draw_fill_attlist common_draw_fill_attlist_;
|
||||
|
||||
@ -1450,6 +1450,84 @@ void style_font_face::serialize(std::wostream & strm)
|
||||
}
|
||||
}
|
||||
}
|
||||
// style:region-left
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
const wchar_t * style_region_left::ns = L"style";
|
||||
const wchar_t * style_region_left::name = L"region-left";
|
||||
|
||||
void style_region_left::add_child_element( const office_element_ptr & child)
|
||||
{
|
||||
content_.push_back(child);
|
||||
}
|
||||
void style_region_left::create_child_element(const std::wstring & Ns, const std::wstring & Name)
|
||||
{
|
||||
CP_CREATE_ELEMENT(content_);
|
||||
}
|
||||
void style_region_left::serialize(std::wostream & strm)
|
||||
{
|
||||
CP_XML_WRITER(strm)
|
||||
{
|
||||
CP_XML_NODE_SIMPLE()
|
||||
{
|
||||
for (size_t i = 0; i < content_.size(); i++)
|
||||
{
|
||||
content_[i]->serialize(CP_XML_STREAM());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// style:region-right
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
const wchar_t * style_region_right::ns = L"style";
|
||||
const wchar_t * style_region_right::name = L"region-right";
|
||||
|
||||
void style_region_right::add_child_element( const office_element_ptr & child)
|
||||
{
|
||||
content_.push_back(child);
|
||||
}
|
||||
void style_region_right::create_child_element(const std::wstring & Ns, const std::wstring & Name)
|
||||
{
|
||||
CP_CREATE_ELEMENT(content_);
|
||||
}
|
||||
void style_region_right::serialize(std::wostream & strm)
|
||||
{
|
||||
CP_XML_WRITER(strm)
|
||||
{
|
||||
CP_XML_NODE_SIMPLE()
|
||||
{
|
||||
for (size_t i = 0; i < content_.size(); i++)
|
||||
{
|
||||
content_[i]->serialize(CP_XML_STREAM());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// style:region-center
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
const wchar_t * style_region_center::ns = L"style";
|
||||
const wchar_t * style_region_center::name = L"region-center";
|
||||
|
||||
void style_region_center::add_child_element( const office_element_ptr & child)
|
||||
{
|
||||
content_.push_back(child);
|
||||
}
|
||||
void style_region_center::create_child_element(const std::wstring & Ns, const std::wstring & Name)
|
||||
{
|
||||
CP_CREATE_ELEMENT(content_);
|
||||
}
|
||||
void style_region_center::serialize(std::wostream & strm)
|
||||
{
|
||||
CP_XML_WRITER(strm)
|
||||
{
|
||||
CP_XML_NODE_SIMPLE()
|
||||
{
|
||||
for (size_t i = 0; i < content_.size(); i++)
|
||||
{
|
||||
content_[i]->serialize(CP_XML_STREAM());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -952,5 +952,65 @@ public:
|
||||
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(office_font_face_decls);
|
||||
|
||||
// style:region-left
|
||||
class style_region_left : public office_element_impl<style_region_left>
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typeStyleRegionLeft;
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
virtual void serialize(std::wostream & strm);
|
||||
virtual void create_child_element ( const std::wstring & Ns, const std::wstring & Name);
|
||||
virtual void add_child_element ( const office_element_ptr & child);
|
||||
|
||||
office_element_ptr_array content_;
|
||||
};
|
||||
|
||||
CP_REGISTER_OFFICE_ELEMENT2(style_region_left);
|
||||
|
||||
// style:region-right
|
||||
class style_region_right : public office_element_impl<style_region_right>
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typeStyleRegionRight;
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
virtual void serialize(std::wostream & strm);
|
||||
virtual void create_child_element ( const std::wstring & Ns, const std::wstring & Name);
|
||||
virtual void add_child_element ( const office_element_ptr & child);
|
||||
|
||||
office_element_ptr_array content_;
|
||||
|
||||
};
|
||||
|
||||
CP_REGISTER_OFFICE_ELEMENT2(style_region_right);
|
||||
|
||||
|
||||
// style:region-center
|
||||
class style_region_center : public office_element_impl<style_region_center>
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typeStyleRegionCenter;
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
virtual void serialize(std::wostream & strm);
|
||||
virtual void create_child_element ( const std::wstring & Ns, const std::wstring & Name);
|
||||
virtual void add_child_element ( const office_element_ptr & child);
|
||||
|
||||
office_element_ptr_array content_;
|
||||
|
||||
};
|
||||
|
||||
CP_REGISTER_OFFICE_ELEMENT2(style_region_center);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1026,7 +1026,13 @@ void OoxConverter::convert(PPTX::Logic::InnerShdw *oox_shadow, DWORD ARGB)
|
||||
|
||||
convert(&oox_shadow->Color, hexColor, opacity, ARGB);
|
||||
|
||||
odf_context()->drawing_context()->set_shadow(2, hexColor, opacity, oox_shadow->dist.IsInit() ? oox_shadow->dist.get() / 12700. : 0);
|
||||
double dist = oox_shadow->dist.IsInit() ? oox_shadow->dist.get() / 12700. : 0;
|
||||
double dir = oox_shadow->dir.IsInit() ? oox_shadow->dir.get() / 60000. : 0;
|
||||
|
||||
double offset_x = dist * cos(dir * M_PI / 180);
|
||||
double offset_y = dist * sin(dir * M_PI / 180);
|
||||
|
||||
odf_context()->drawing_context()->set_shadow(2, hexColor, opacity, offset_x, offset_y);
|
||||
}
|
||||
void OoxConverter::convert(PPTX::Logic::OuterShdw *oox_shadow, DWORD ARGB)
|
||||
{
|
||||
@ -1037,8 +1043,13 @@ void OoxConverter::convert(PPTX::Logic::OuterShdw *oox_shadow, DWORD ARGB)
|
||||
|
||||
convert(&oox_shadow->Color, hexColor, opacity, ARGB);
|
||||
|
||||
odf_context()->drawing_context()->set_shadow(1, hexColor, opacity, oox_shadow->dist.IsInit() ? oox_shadow->dist.get() / 12700. : 0);
|
||||
double dist = oox_shadow->dist.IsInit() ? oox_shadow->dist.get() / 12700. : 0;
|
||||
double dir = oox_shadow->dir.IsInit() ? oox_shadow->dir.get() / 60000. : 0;
|
||||
|
||||
double offset_x = dist * cos(dir * M_PI / 180);
|
||||
double offset_y = dist * sin(dir * M_PI / 180);
|
||||
|
||||
odf_context()->drawing_context()->set_shadow(1, hexColor, opacity, offset_x, offset_y);
|
||||
}
|
||||
void OoxConverter::convert(PPTX::Logic::PrstShdw *oox_shadow, DWORD ARGB)
|
||||
{
|
||||
|
||||
@ -611,7 +611,8 @@ void DocxConverter::convert(OOX::Logic::CParagraph *oox_paragraph)
|
||||
}
|
||||
else
|
||||
{
|
||||
convert(oox_paragraph->m_oParagraphProperty->m_oRPr.GetPointer(), text_properties);
|
||||
//Thesis.docx
|
||||
//convert(oox_paragraph->m_oParagraphProperty->m_oRPr.GetPointer(), text_properties);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -708,8 +709,8 @@ void DocxConverter::convert(OOX::Logic::CRun *oox_run)//wordprocessing 22.1.2.87
|
||||
|
||||
id_change_properties = convert(oox_run->m_oRunProperty->m_oRPrChange.GetPointer());
|
||||
|
||||
odt_context->styles_context()->create_style(L"",odf_types::style_family::Text, true, false, -1);
|
||||
odf_writer::style_text_properties * text_properties = odt_context->styles_context()->last_state()->get_text_properties();
|
||||
odt_context->styles_context()->create_style(L"", odf_types::style_family::Text, true, false, -1);
|
||||
odf_writer::style_text_properties *text_properties = odt_context->styles_context()->last_state()->get_text_properties();
|
||||
|
||||
convert(oox_run->m_oRunProperty, text_properties);
|
||||
}
|
||||
@ -1316,11 +1317,14 @@ void DocxConverter::convert(OOX::Logic::CParagraphProperty *oox_paragraph_pr, cp
|
||||
|
||||
convert(oox_paragraph_pr->m_oPBdr.GetPointer(), paragraph_properties);
|
||||
|
||||
if (oox_paragraph_pr->m_oRPr.IsInit())
|
||||
{
|
||||
odf_writer::style_text_properties * text_properties = odf_context()->text_context()->get_text_properties();
|
||||
if (text_properties)
|
||||
convert(oox_paragraph_pr->m_oRPr.GetPointer(), text_properties);
|
||||
if (odt_context->empty())
|
||||
{//Thesis.docx
|
||||
if (oox_paragraph_pr->m_oRPr.IsInit())
|
||||
{
|
||||
odf_writer::style_text_properties *text_properties = odf_context()->text_context()->get_text_properties();
|
||||
if (text_properties)
|
||||
convert(oox_paragraph_pr->m_oRPr.GetPointer(), text_properties);
|
||||
}
|
||||
}
|
||||
if (oox_paragraph_pr->m_oShd.IsInit())
|
||||
{
|
||||
@ -2923,7 +2927,9 @@ void DocxConverter::convert(OOX::Drawing::CAnchor *oox_anchor)
|
||||
|
||||
_CP_OPT(int) anchor_type_x, anchor_type_y;
|
||||
|
||||
bool bThrough = oox_anchor->m_oBehindDoc.IsInit() ? oox_anchor->m_oBehindDoc->ToBool(): false;
|
||||
bool bBackground = oox_anchor->m_oBehindDoc.IsInit() ? oox_anchor->m_oBehindDoc->ToBool(): false;
|
||||
|
||||
bool bThrough = oox_anchor->m_oAllowOverlap.IsInit() ? oox_anchor->m_oAllowOverlap->ToBool(): false;
|
||||
|
||||
if (oox_anchor->m_oPositionV.IsInit() && oox_anchor->m_oPositionV->m_oRelativeFrom.IsInit())
|
||||
{
|
||||
@ -2985,7 +2991,6 @@ void DocxConverter::convert(OOX::Drawing::CAnchor *oox_anchor)
|
||||
else if (oox_anchor->m_oWrapThrough.IsInit())//style:wrap="run-through" draw:wrap-influence-on-position style:wrap-contour
|
||||
{
|
||||
odt_context->drawing_context()->set_wrap_style(odf_types::style_wrap::RunThrough);
|
||||
|
||||
}
|
||||
else if (oox_anchor->m_oWrapTight.IsInit())
|
||||
{
|
||||
@ -2998,17 +3003,25 @@ void DocxConverter::convert(OOX::Drawing::CAnchor *oox_anchor)
|
||||
{
|
||||
case SimpleTypes::wraptextBothSides:
|
||||
{
|
||||
odt_context->drawing_context()->set_wrap_style(odf_types::style_wrap::Dynamic);
|
||||
if (bPolygon)
|
||||
{
|
||||
odt_context->drawing_context()->set_wrap_contour();
|
||||
}
|
||||
else
|
||||
{
|
||||
odt_context->drawing_context()->set_wrap_style(odf_types::style_wrap::Dynamic);
|
||||
}
|
||||
}break;
|
||||
case SimpleTypes::wraptextLargest: odt_context->drawing_context()->set_wrap_style(odf_types::style_wrap::Biggest); break;
|
||||
case SimpleTypes::wraptextLeft: odt_context->drawing_context()->set_wrap_style(odf_types::style_wrap::Left); break;
|
||||
case SimpleTypes::wraptextRight: odt_context->drawing_context()->set_wrap_style(odf_types::style_wrap::Right); break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
odt_context->drawing_context()->set_wrap_contour();
|
||||
}
|
||||
wrap_set = true;
|
||||
}
|
||||
else if (oox_anchor->m_oWrapTopAndBottom.IsInit())
|
||||
{
|
||||
@ -3020,9 +3033,12 @@ void DocxConverter::convert(OOX::Drawing::CAnchor *oox_anchor)
|
||||
odt_context->drawing_context()->set_wrap_style(odf_types::style_wrap::None);
|
||||
wrap_set = true;
|
||||
|
||||
if (bThrough)
|
||||
{//эффект_штурмовика.docx
|
||||
if (bThrough)//Silhouette_Project 11-11.docx
|
||||
{
|
||||
odt_context->drawing_context()->set_wrap_style(odf_types::style_wrap::RunThrough);
|
||||
}
|
||||
if(bBackground)//эффект_штурмовика.docx
|
||||
{
|
||||
odt_context->drawing_context()->set_object_background(true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -366,21 +366,236 @@ void XlsxConverter::convert(OOX::Spreadsheet::CWorksheet *oox_sheet)
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
convert(oox_sheet->m_oSheetViews.GetPointer());
|
||||
convert(oox_sheet->m_oHeaderFooter.GetPointer());
|
||||
convert(oox_sheet->m_oPageSetup.GetPointer());
|
||||
convert(oox_sheet->m_oPageMargins.GetPointer());
|
||||
convert(oox_sheet->m_oPicture.GetPointer());
|
||||
convert(oox_sheet->m_oSheetProtection.GetPointer());
|
||||
|
||||
convert(oox_sheet->m_oLegacyDrawingHF.GetPointer());
|
||||
convert(oox_sheet->m_oHeaderFooter.GetPointer());
|
||||
|
||||
OoxConverter::convert(oox_sheet->m_oExtLst.GetPointer());
|
||||
|
||||
xlsx_current_container = old_container;
|
||||
}
|
||||
void XlsxConverter::convert(OOX::Spreadsheet::CHeaderFooter * oox_header_footer)
|
||||
void XlsxConverter::convert(OOX::Spreadsheet::CLegacyDrawingHFWorksheet *oox_background)
|
||||
{
|
||||
if (!oox_background) return;
|
||||
if (!oox_background->m_oId.IsInit()) return;
|
||||
|
||||
smart_ptr<OOX::File> file = find_file_by_id(oox_background->m_oId->GetValue());
|
||||
smart_ptr<OOX::CVmlDrawing> vmlDrawing = file.smart_dynamic_cast<OOX::CVmlDrawing>();
|
||||
|
||||
if (false == vmlDrawing.IsInit()) return;
|
||||
|
||||
oox_current_child_document = dynamic_cast<OOX::IFileContainer*>(vmlDrawing.GetPointer());
|
||||
|
||||
for (boost::unordered_map<std::wstring, OOX::CVmlDrawing::_vml_shape>::iterator it = vmlDrawing->m_mapShapes.begin(); it!= vmlDrawing->m_mapShapes.end(); ++it)
|
||||
{
|
||||
OOX::Vml::CShape* pShape = dynamic_cast<OOX::Vml::CShape*>(it->second.pElement);
|
||||
|
||||
if ((pShape) && (pShape->m_sId.IsInit()))
|
||||
{
|
||||
for (size_t i = 0; i < pShape->m_arrItems.size(); ++i)
|
||||
{
|
||||
OOX::Vml::CImageData* pImage = dynamic_cast<OOX::Vml::CImageData*>(pShape->m_arrItems[i]);
|
||||
if (pImage)
|
||||
{
|
||||
odf_writer::office_element_ptr fill_image_element;
|
||||
|
||||
std::wstring pathImage, href, sID = pImage->m_oId.IsInit() ? pImage->m_rId->GetValue() : (pImage->m_oRelId.IsInit() ? pImage->m_oRelId->GetValue() : L"");
|
||||
|
||||
pathImage = find_link_by_id(sID, 1);
|
||||
href = ods_context->add_image(pathImage);
|
||||
|
||||
if (false == href.empty())
|
||||
{
|
||||
odf_writer::create_element(L"style", L"background-image", fill_image_element, ods_context);
|
||||
|
||||
odf_writer::style_background_image * fill_image = dynamic_cast<odf_writer::style_background_image*>(fill_image_element.get());
|
||||
if (!fill_image) return;
|
||||
|
||||
fill_image->xlink_attlist_ = odf_types::common_xlink_attlist();
|
||||
fill_image->xlink_attlist_->type_ = odf_types::xlink_type::Simple;
|
||||
fill_image->xlink_attlist_->actuate_ = odf_types::xlink_actuate::OnLoad;
|
||||
fill_image->xlink_attlist_->href_ = href;
|
||||
|
||||
ods_context->add_header_footer_image(*pShape->m_sId, fill_image_element);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
oox_current_child_document = NULL;
|
||||
}
|
||||
void XlsxConverter::convert(OOX::Spreadsheet::CHeaderFooter *oox_header_footer)
|
||||
{
|
||||
if (!oox_header_footer) return;
|
||||
|
||||
bool bFirst = oox_header_footer->m_oDifferentFirst.IsInit() ? oox_header_footer->m_oDifferentFirst->ToBool() : false;
|
||||
bool bEven = oox_header_footer->m_oDifferentOddEven.IsInit() ? oox_header_footer->m_oDifferentOddEven->ToBool() : false;
|
||||
|
||||
if (bEven || oox_header_footer->m_oOddHeader.IsInit())
|
||||
{
|
||||
if (true == ods_context->start_header(0))
|
||||
{
|
||||
convert(oox_header_footer->m_oOddHeader.GetPointer());
|
||||
}
|
||||
ods_context->end_header_footer();
|
||||
}
|
||||
if (bEven ||oox_header_footer->m_oOddFooter.IsInit())
|
||||
{
|
||||
if (true == ods_context->start_footer(0))
|
||||
{
|
||||
convert(oox_header_footer->m_oOddFooter.GetPointer());
|
||||
}
|
||||
ods_context->end_header_footer();
|
||||
}
|
||||
if (bEven ||oox_header_footer->m_oEvenHeader.IsInit())
|
||||
{
|
||||
if (true == ods_context->start_header(1))
|
||||
{
|
||||
convert(oox_header_footer->m_oEvenHeader.GetPointer());
|
||||
}
|
||||
ods_context->end_header_footer();
|
||||
}
|
||||
if (bEven ||oox_header_footer->m_oEvenFooter.IsInit())
|
||||
{
|
||||
if (true == ods_context->start_footer(1))
|
||||
{
|
||||
convert(oox_header_footer->m_oEvenFooter.GetPointer());
|
||||
}
|
||||
ods_context->end_header_footer();
|
||||
}
|
||||
if (bFirst || oox_header_footer->m_oFirstHeader.IsInit())
|
||||
{
|
||||
if (true == ods_context->start_header(2))
|
||||
{
|
||||
convert(oox_header_footer->m_oFirstHeader.GetPointer());
|
||||
}
|
||||
ods_context->end_header_footer();
|
||||
}
|
||||
if (bFirst || oox_header_footer->m_oFirstFooter.IsInit())
|
||||
{
|
||||
if (true == ods_context->start_footer(2))
|
||||
{
|
||||
convert(oox_header_footer->m_oFirstFooter.GetPointer());
|
||||
}
|
||||
ods_context->end_header_footer();
|
||||
}
|
||||
}
|
||||
void XlsxConverter::convert(OOX::Spreadsheet::CHeaderFooterElement *oox_header_footer)
|
||||
{
|
||||
if (!oox_header_footer) return;
|
||||
|
||||
size_t pos = 0;
|
||||
odf_writer::style_text_properties current_text_props;
|
||||
|
||||
int type_add = 0;
|
||||
while(pos < oox_header_footer->m_sText.size())
|
||||
{
|
||||
if (oox_header_footer->m_sText[pos] == L'&')
|
||||
{
|
||||
pos++;
|
||||
wchar_t comm = oox_header_footer->m_sText[pos];
|
||||
|
||||
switch(comm)
|
||||
{
|
||||
case 'L': ods_context->start_header_footer_region(1); pos++; break;
|
||||
case 'C': ods_context->start_header_footer_region(2); pos++; break;
|
||||
case 'R': ods_context->start_header_footer_region(3); pos++; break;
|
||||
|
||||
case 'A': type_add = 1; pos++; break;
|
||||
case 'P': type_add = 2; pos++; break;
|
||||
case 'N': type_add = 3; pos++; break;
|
||||
case 'D': type_add = 4; pos++; break;
|
||||
case 'T': type_add = 5; pos++; break;
|
||||
case 'F': type_add = 6; pos++; break;
|
||||
case 'Z': type_add = 7; pos++; break;
|
||||
case '&': type_add = 8; pos++; break;
|
||||
case 'G': pos++; break;
|
||||
|
||||
case 'E': current_text_props.content_.style_text_underline_type_ = odf_types::line_type::Double; pos++; break;
|
||||
case 'X': current_text_props.content_.style_text_position_ = odf_types::text_position(+33.); pos++; break;
|
||||
case 'Y': current_text_props.content_.style_text_position_ = odf_types::text_position(-33.); pos++; break;
|
||||
case 'B': current_text_props.content_.fo_font_weight_ = odf_types::font_weight(odf_types::font_weight::WBold); pos++; break;
|
||||
case 'I': current_text_props.content_.fo_font_style_ = odf_types::font_style(odf_types::font_style::Italic); pos++; break;
|
||||
case 'U': current_text_props.content_.style_text_underline_type_= odf_types::line_type(odf_types::line_type::Single); pos++; break;
|
||||
case 'S': current_text_props.content_.style_text_line_through_type_ = odf_types::line_type(odf_types::line_type::Single); pos++; break;
|
||||
case 'K':
|
||||
{
|
||||
pos++;
|
||||
std::wstring color = oox_header_footer->m_sText.substr(pos, 6); pos += 6;
|
||||
|
||||
current_text_props.content_.fo_color_ = odf_types::color(L"#" + color);
|
||||
};break;
|
||||
case '\"':
|
||||
{
|
||||
pos = oox_header_footer->m_sText.find(L'\"', pos + 1); pos++;
|
||||
}break;
|
||||
default:
|
||||
{
|
||||
int font_size = 0;
|
||||
pos++;
|
||||
if (comm >= L'0' && comm <= L'9')
|
||||
{
|
||||
font_size = comm - L'0';
|
||||
wchar_t comm1 = oox_header_footer->m_sText[pos];
|
||||
if (comm1 >= L'0' && comm1 <= L'9')
|
||||
{
|
||||
pos++;
|
||||
font_size = (font_size * 10) + (comm1 - L'0');
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
}
|
||||
if (font_size > 0)
|
||||
{
|
||||
current_text_props.content_.fo_font_size_ = odf_types::font_size(odf_types::length(font_size, odf_types::length::pt));
|
||||
}
|
||||
}break;
|
||||
|
||||
//&nn Prints the characters that follow in the specified font size. Use a two-digit number to specify a size in points.
|
||||
}
|
||||
size_t next = oox_header_footer->m_sText.find(L'&', pos);
|
||||
if (next == std::wstring::npos) next = oox_header_footer->m_sText.length();
|
||||
|
||||
if (type_add > 0 || next - pos > 0)
|
||||
{
|
||||
ods_context->text_context()->get_styles_context()->create_style(L"", odf_types::style_family::Text, true, false, -1);
|
||||
odf_writer::style_text_properties *text_properties = ods_context->text_context()->get_styles_context()->last_state()->get_text_properties();
|
||||
text_properties->content_.apply_from(current_text_props.content_);
|
||||
|
||||
ods_context->text_context()->start_span(true);
|
||||
|
||||
switch(type_add)
|
||||
{
|
||||
case 1: ods_context->text_context()->add_text_sheet_name(L"???"); break;
|
||||
case 2: ods_context->text_context()->add_text_page_number(L"1"); break;
|
||||
case 3: ods_context->text_context()->add_text_page_count(L"99"); break;
|
||||
case 4: ods_context->text_context()->add_text_date(L"00.00.0000"); break;
|
||||
case 5: ods_context->text_context()->add_text_time(L"00:00"); break;
|
||||
case 6: ods_context->text_context()->add_text_file_name(L"???"); break;
|
||||
case 7: ods_context->text_context()->add_text_file_name(L"???"); break;
|
||||
case 8: ods_context->text_context()->add_text_content(L"&"); break;
|
||||
}
|
||||
type_add = 0;
|
||||
std::wstring text;
|
||||
if (next - pos > 0)
|
||||
{
|
||||
text = oox_header_footer->m_sText.substr(pos, next - pos);
|
||||
if (false == text.empty())
|
||||
ods_context->text_context()->add_text_content(text);
|
||||
}
|
||||
ods_context->text_context()->end_span();
|
||||
}
|
||||
pos = next;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void XlsxConverter::convert(OOX::Spreadsheet::CSheetProtection *oox_prot)
|
||||
{
|
||||
if (!oox_prot) return;
|
||||
@ -923,9 +1138,9 @@ void XlsxConverter::convert(OOX::Spreadsheet::CRPr *oox_run_pr)
|
||||
bool automatic = true;
|
||||
bool root = false;
|
||||
|
||||
ods_context->styles_context()->create_style(L"",odf_types::style_family::Text, automatic, root, -1);
|
||||
ods_context->styles_context()->create_style(L"", odf_types::style_family::Text, automatic, root, -1);
|
||||
|
||||
odf_writer::style_text_properties * text_properties = ods_context->styles_context()->last_state()->get_text_properties();
|
||||
odf_writer::style_text_properties *text_properties = ods_context->styles_context()->last_state()->get_text_properties();
|
||||
if (text_properties == NULL)return;
|
||||
|
||||
if (oox_run_pr->m_oBold.IsInit())
|
||||
@ -1398,9 +1613,26 @@ void XlsxConverter::convert(OOX::Spreadsheet::CPageSetup *oox_page)
|
||||
void XlsxConverter::convert(OOX::Spreadsheet::CPageMargins *oox_page)
|
||||
{
|
||||
if (!oox_page) return;
|
||||
_CP_OPT(double) top, left,right,header,footer,bottom;
|
||||
_CP_OPT(odf_types::length) top, left, right, bottom, other;
|
||||
|
||||
ods_context->page_layout_context()->set_page_margin(top, left, bottom, right, header, footer);
|
||||
if (oox_page->m_oTop.IsInit()) top = odf_types::length(oox_page->m_oTop->GetValue(), odf_types::length::pt);
|
||||
if (oox_page->m_oLeft.IsInit()) left = odf_types::length(oox_page->m_oLeft->GetValue(), odf_types::length::pt);
|
||||
if (oox_page->m_oRight.IsInit()) right = odf_types::length(oox_page->m_oRight->GetValue(), odf_types::length::pt);
|
||||
if (oox_page->m_oBottom.IsInit()) bottom = odf_types::length(oox_page->m_oBottom->GetValue(), odf_types::length::pt);
|
||||
|
||||
ods_context->page_layout_context()->set_page_margin(top, left, bottom, right);
|
||||
|
||||
if (oox_page->m_oFooter.IsInit())
|
||||
{
|
||||
other = odf_types::length(oox_page->m_oFooter->GetValue(), odf_types::length::pt);
|
||||
ods_context->page_layout_context()->set_footer_size(other);
|
||||
}
|
||||
|
||||
if (oox_page->m_oHeader.IsInit())
|
||||
{
|
||||
other = odf_types::length(oox_page->m_oHeader->GetValue(), odf_types::length::pt);
|
||||
ods_context->page_layout_context()->set_header_size(other);
|
||||
}
|
||||
|
||||
}
|
||||
void XlsxConverter::convert(OOX::Spreadsheet::CSheetFormatPr *oox_sheet_format_pr)
|
||||
|
||||
@ -98,6 +98,8 @@ namespace OOX
|
||||
class CDataValidations;
|
||||
class CSheetProtection;
|
||||
class CDataValidation;
|
||||
class CHeaderFooterElement;
|
||||
class CLegacyDrawingHFWorksheet;
|
||||
}
|
||||
}
|
||||
|
||||
@ -163,6 +165,9 @@ namespace Oox2Odf
|
||||
void convert(OOX::Spreadsheet::CTableColumns *oox_table_part_columns);
|
||||
void convert(OOX::Spreadsheet::CPictureWorksheet *oox_background);
|
||||
void convert(OOX::Spreadsheet::CHeaderFooter *oox_header_footer);
|
||||
void convert(OOX::Spreadsheet::CLegacyDrawingHFWorksheet *oox_background);
|
||||
void convert(OOX::Spreadsheet::CHeaderFooterElement *oox_header_footer);
|
||||
void convert();
|
||||
|
||||
void convert(OOX::Spreadsheet::CCol *oox_column);
|
||||
void convert(OOX::Spreadsheet::CRow *oox_row, OOX::Spreadsheet::CRow *oox_row_prev);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -2615,7 +2615,7 @@ bool RtfParagraphPropDestination::ExecuteCommand(RtfDocument& oDocument, RtfRead
|
||||
}
|
||||
}
|
||||
|
||||
COMMAND_RTF_INT ( "uc", oReader.m_oState->m_nUD, sCommand, hasParameter, parameter)
|
||||
COMMAND_RTF_INT ( "uc", oReader.m_oState->m_nUnicodeClean, sCommand, hasParameter, parameter)
|
||||
//Tab todoooo перенести в ParagrProps (trackchanges)
|
||||
COMMAND_RTF_INT ( "tldot", m_oCurTab.m_eLeader, sCommand, true, RtfTab::tl_dot )
|
||||
COMMAND_RTF_INT ( "tlmdot", m_oCurTab.m_eLeader, sCommand, true, RtfTab::tl_mdot )
|
||||
|
||||
@ -51,7 +51,7 @@ bool RtfReader::Load()
|
||||
void RtfReader::PushState()
|
||||
{
|
||||
ReaderStatePtr psaveNew = ReaderStatePtr(new ReaderState());
|
||||
psaveNew -> m_nUD = m_oState->m_nUD;
|
||||
psaveNew -> m_nUnicodeClean = m_oState->m_nUnicodeClean;
|
||||
psaveNew -> m_oCharProp = m_oState->m_oCharProp;
|
||||
psaveNew -> m_oParagraphProp = m_oState->m_oParagraphProp;
|
||||
psaveNew -> m_oRowProperty = m_oState->m_oRowProperty;
|
||||
|
||||
@ -47,7 +47,7 @@ public:
|
||||
class ReaderState
|
||||
{
|
||||
public:
|
||||
int m_nUD; // количество символов игнорируемых за юникодом
|
||||
int m_nUnicodeClean; // количество символов игнорируемых за юникодом
|
||||
RtfCharProperty m_oCharProp;
|
||||
RtfParagraphProperty m_oParagraphProp;
|
||||
RtfRowProperty m_oRowProperty;
|
||||
@ -61,7 +61,7 @@ public:
|
||||
ReaderState()
|
||||
{
|
||||
m_bControlPresent = false;
|
||||
m_nUD = 1;
|
||||
m_nUnicodeClean = 1;
|
||||
m_oCharProp.SetDefaultRtf();
|
||||
m_oParagraphProp.SetDefaultRtf();
|
||||
m_oRowProperty.SetDefaultRtf();
|
||||
@ -129,14 +129,18 @@ public:
|
||||
switch (m_oTok.Type)
|
||||
{
|
||||
case RtfToken::GroupStart:
|
||||
ExecuteTextInternal2(oDocument, oReader, m_oTok.Key, m_nSkipChars);
|
||||
PushState(oReader);
|
||||
break;
|
||||
{
|
||||
ExecuteTextInternal2(oDocument, oReader, m_oTok.Key, m_nSkipChars);
|
||||
PushState(oReader);
|
||||
}break;
|
||||
case RtfToken::GroupEnd:
|
||||
ExecuteTextInternal2(oDocument, oReader, m_oTok.Key, m_nSkipChars);
|
||||
PopState(oDocument, oReader);
|
||||
break;
|
||||
{
|
||||
ExecuteTextInternal2(oDocument, oReader, m_oTok.Key, m_nSkipChars);
|
||||
|
||||
PopState(oDocument, oReader);
|
||||
}break;
|
||||
case RtfToken::Keyword:
|
||||
{
|
||||
ExecuteTextInternal2(oDocument, oReader, m_oTok.Key, m_nSkipChars);
|
||||
if( m_oTok.Key == "u")
|
||||
{
|
||||
@ -156,8 +160,9 @@ public:
|
||||
}
|
||||
if( true == m_bCanStartNewReader )
|
||||
m_bCanStartNewReader = false;
|
||||
break;
|
||||
}break;
|
||||
case RtfToken::Control:
|
||||
{
|
||||
if( m_oTok.Key == "42" )
|
||||
m_bSkip = true;
|
||||
if( m_oTok.Key == "39" && true == m_oTok.HasParameter )
|
||||
@ -165,10 +170,12 @@ public:
|
||||
oReader.m_oState->m_sCurText += m_oTok.Parameter ;
|
||||
oReader.m_oState->m_bControlPresent = true;
|
||||
}
|
||||
break;
|
||||
}break;
|
||||
case RtfToken::Text:
|
||||
oReader.m_oState->m_sCurText += m_oTok.Key;
|
||||
break;
|
||||
{
|
||||
oReader.m_oState->m_sCurText += m_oTok.Key;
|
||||
}break;
|
||||
|
||||
}
|
||||
if( false == m_bStopReader)
|
||||
m_oTok = oReader.m_oLex.NextToken();
|
||||
@ -272,10 +279,10 @@ public:
|
||||
std::wstring sResult = ExecuteTextInternalCodePage(oReader.m_oState->m_sCurText, oDocument, oReader);
|
||||
oReader.m_oState->m_sCurText.erase();
|
||||
oReader.m_oState->m_bControlPresent = false;
|
||||
if(sResult.length() > 0)
|
||||
if(false == sResult.empty())
|
||||
{
|
||||
std::string str;
|
||||
// ExecuteTextInternalSkipChars (sResult, oReader, str, nSkipChars); //vedomost.rtf
|
||||
ExecuteTextInternalSkipChars (sResult, oReader, str, nSkipChars);
|
||||
ExecuteText ( oDocument, oReader, sResult);
|
||||
}
|
||||
}
|
||||
@ -288,8 +295,9 @@ public:
|
||||
int nLength = (int)sResult.length();
|
||||
if( nSkipChars >= nLength )
|
||||
{
|
||||
nSkipChars -= nLength;
|
||||
sResult.clear();
|
||||
nSkipChars = 0; //vedomost.rtf
|
||||
//nSkipChars -= nLength;
|
||||
sResult.clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -300,7 +308,7 @@ public:
|
||||
if( "u" == sKey )
|
||||
{
|
||||
//надо правильно установить m_nSkipChars по значению \ucN
|
||||
nSkipChars = oReader.m_oState->m_nUD;
|
||||
nSkipChars = oReader.m_oState->m_nUnicodeClean;
|
||||
}
|
||||
}
|
||||
/*static */std::wstring ExecuteTextInternalCodePage( std::string & sCharString, RtfDocument & oDocument, RtfReader & oReader);
|
||||
|
||||
@ -1,241 +1,245 @@
|
||||
/*
|
||||
* (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
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "CFRecordType.h"
|
||||
#include "CFStream.h"
|
||||
#include "BinSmartPointers.h"
|
||||
#include "../Logic/GlobalWorkbookInfo.h"
|
||||
|
||||
#include "../../Common/common.h"
|
||||
#include "../Auxiliary/HelpFunc.h"
|
||||
#include "../../../../ASCOfficeDocFile/DocDocxConverter/OfficeDrawing/Record.h"
|
||||
|
||||
namespace XLS
|
||||
{
|
||||
|
||||
class CFRecord
|
||||
{
|
||||
public:
|
||||
CFRecord(CFStreamPtr stream, GlobalWorkbookInfoPtr global_info); // Create a record an read its data from the stream
|
||||
CFRecord(CFRecordType::TypeId type_id, GlobalWorkbookInfoPtr global_info); // Create an empty record
|
||||
~CFRecord();
|
||||
|
||||
void save(CFStreamPtr stream);
|
||||
void commitData();
|
||||
|
||||
const CFRecordType::TypeId getTypeId() const;
|
||||
const CFRecordType::TypeString& getTypeString() const;
|
||||
|
||||
const unsigned int getStreamPointer() const;
|
||||
// Pointer to the beginning of the cached data
|
||||
const char* getData() const ;
|
||||
const size_t getDataSize() const;
|
||||
const size_t getMaxRecordSize() const;
|
||||
void appendRawData(CFRecordPtr where_from);
|
||||
void appendRawData(const char* raw_data, const size_t size);
|
||||
void insertDataFromRecordToBeginning(CFRecordPtr where_from);
|
||||
|
||||
const bool isEOF() const; // whether all the data have bean read
|
||||
// Checks whether the specified number of unsigned chars present in the non-read part of the buffer
|
||||
// Doesn't generate an exception
|
||||
const bool checkFitReadSafe(const size_t size) const;
|
||||
// Checks whether the specified number of unsigned chars present in the non-read part of the buffer
|
||||
// Generates an exception
|
||||
bool checkFitRead(const size_t size) const;
|
||||
// Checks whether the specified number of unsigned chars fits in max size of the buffer
|
||||
// Doesn't generate an exception
|
||||
const bool checkFitWriteSafe(const size_t size) const;
|
||||
// Checks whether the specified number of unsigned chars fits in max size of the buffer
|
||||
// Generates an exception
|
||||
void checkFitWrite(const size_t size) const;
|
||||
void skipNunBytes(const size_t n); // Skip the specified number of unsigned chars without reading
|
||||
void RollRdPtrBack(const size_t n); // Move read pointer back to reread some data
|
||||
void resetPointerToBegin();
|
||||
void reserveNunBytes(const size_t n); // Skip the specified number of unsigned chars filled them in with zeros
|
||||
template<class DataType>
|
||||
void reserveNunBytes(const size_t n, const DataType fill_data) // Skip the specified number of unsigned chars filled them in with specified data
|
||||
{
|
||||
checkFitWrite(n);
|
||||
size_t odd_size = n / sizeof(DataType) * sizeof(DataType);
|
||||
for(size_t offset = 0; offset < odd_size; offset += sizeof(DataType))
|
||||
{
|
||||
reinterpret_cast<DataType*>(&intData[size_ + offset])[0] = fill_data;
|
||||
}
|
||||
for(size_t i = 0; i < n % sizeof(DataType); ++i)
|
||||
{
|
||||
intData[size_ + odd_size + i] = 0;
|
||||
}
|
||||
size_ += n;
|
||||
|
||||
}
|
||||
void registerDelayedDataReceiver(CFStream::DELAYED_DATA_SAVER fn, const size_t n, const CFRecordType::TypeId receiver_id = rt_NONE);
|
||||
void registerDelayedDataSource(const unsigned int data, const CFRecordType::TypeId receiver_id);
|
||||
void registerDelayedFilePointerSource(const CFRecordType::TypeId receiver_id);
|
||||
void registerDelayedFilePointerAndOffsetSource(const unsigned int offset, const CFRecordType::TypeId receiver_id);
|
||||
|
||||
template<class T>
|
||||
const T* getCurData() const
|
||||
{
|
||||
return reinterpret_cast<T*>(&data_[rdPtr]);
|
||||
}
|
||||
// Obtain the current rdPtr
|
||||
const size_t getRdPtr() const;
|
||||
|
||||
template<class T>
|
||||
bool loadAnyData(T& val)
|
||||
{
|
||||
////ASSERT(data_); // This throws if we use >> instead of <<
|
||||
if (checkFitRead(sizeof(T)))
|
||||
{
|
||||
val = * getCurData<T>();
|
||||
rdPtr += sizeof(T);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool loadAnyData(wchar_t & val);
|
||||
|
||||
template<class T>
|
||||
void storeAnyData(const T& val)
|
||||
{
|
||||
checkFitWrite(sizeof(T));
|
||||
*reinterpret_cast<T*>(&intData[size_]) = val;
|
||||
size_ += sizeof(T);
|
||||
}
|
||||
void storeLongData(const char* buf, const size_t size);
|
||||
|
||||
GlobalWorkbookInfoPtr getGlobalWorkbookInfo() { return global_info_; }
|
||||
|
||||
CFRecord& operator>>(unsigned char& val) { loadAnyData(val); return *this; }
|
||||
CFRecord& operator>>(unsigned short& val) { loadAnyData(val); return *this; }
|
||||
CFRecord& operator>>(unsigned int& val) { loadAnyData(val); return *this; }
|
||||
CFRecord& operator>>(int& val) { loadAnyData(val); return *this; }
|
||||
CFRecord& operator>>(double& val) { loadAnyData(val); return *this; }
|
||||
CFRecord& operator>>(_GUID_& val) { loadAnyData(val); return *this; }
|
||||
CFRecord& operator>>(short& val) { loadAnyData(val); return *this; }
|
||||
CFRecord& operator>>(char& val) { loadAnyData(val); return *this; }
|
||||
CFRecord& operator>>(bool& val);
|
||||
|
||||
private:
|
||||
static const size_t MAX_RECORD_SIZE = 8224;
|
||||
|
||||
CFStream::ReceiverItems receiver_items;
|
||||
CFStream::SourceItems source_items;
|
||||
|
||||
unsigned int file_ptr;
|
||||
CFRecordType::TypeId type_id_;
|
||||
size_t size_;
|
||||
char* data_;
|
||||
size_t rdPtr;
|
||||
static char intData[MAX_RECORD_SIZE];
|
||||
|
||||
GlobalWorkbookInfoPtr global_info_;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
CFRecord& operator>>(CFRecord& record, std::vector<T>& vec)
|
||||
{
|
||||
while(!record.isEOF())
|
||||
{
|
||||
T element;
|
||||
record >> element;
|
||||
vec.push_back(element);
|
||||
}
|
||||
return record;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
CFRecord& operator<<(CFRecord& record, std::vector<T>& vec)
|
||||
{
|
||||
for(typename std::vector<T>::iterator it = vec.begin(), itEnd = vec.end(); it != itEnd; ++it)
|
||||
{
|
||||
record << *it;
|
||||
}
|
||||
return record;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
|
||||
template<class T>
|
||||
CFRecord& operator>>(CFRecord & record, std::basic_string<T, std::char_traits<T>, std::allocator<T> >& str)
|
||||
{
|
||||
str.clear();
|
||||
T symbol;
|
||||
do
|
||||
{
|
||||
if (record.loadAnyData(symbol) == false)
|
||||
break;
|
||||
str += symbol;
|
||||
} while (symbol);
|
||||
return record;
|
||||
}
|
||||
|
||||
#else
|
||||
CFRecord& operator>>(CFRecord & record, std::string & str);
|
||||
CFRecord& operator>>(CFRecord & record, std::wstring & str);
|
||||
#endif
|
||||
|
||||
|
||||
template<class T>
|
||||
CFRecord& operator>>(CFRecord & record, _CP_OPT(T)& val)
|
||||
{
|
||||
T temp_val;
|
||||
if (record.loadAnyData(temp_val))
|
||||
{
|
||||
val = temp_val;
|
||||
}
|
||||
return record;
|
||||
}
|
||||
|
||||
|
||||
// moved out of the class to be higher in priority than the universal operator
|
||||
template<class T>
|
||||
CFRecord& operator<<(CFRecord & record, _CP_OPT(T)& val)
|
||||
{
|
||||
if (!val) return record;
|
||||
|
||||
T temp_val(*val);
|
||||
record.storeAnyData(temp_val);
|
||||
return record;
|
||||
}
|
||||
|
||||
#define DET_TYPE(num_bits) num_bits <= 8 ? unsigned char : num_bits <=16 ? unsigned short : unsigned int
|
||||
#define GETBIT(from, num) ((from & (1 << num)) != 0)
|
||||
#define GETBITS(from, numL, numH) ((from & (((1 << (numH - numL + 1)) - 1) << numL)) >> numL)
|
||||
#define SETBIT(to, num, setorclear) {setorclear ? to |= (1 << num) : to &= ~(1 << num);}
|
||||
#define SETBITS(to, numL, numH, val) {to &= ~(((1 << (numH - numL + 1)) - 1) << numL); to |= ((val & ((1 << (numH - numL + 1)) - 1)) << numL);}
|
||||
|
||||
} // namespace XLS
|
||||
/*
|
||||
* (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
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "CFRecordType.h"
|
||||
#include "CFStream.h"
|
||||
#include "BinSmartPointers.h"
|
||||
#include "../Logic/GlobalWorkbookInfo.h"
|
||||
|
||||
#include "../../Common/common.h"
|
||||
#include "../Auxiliary/HelpFunc.h"
|
||||
#include "../../../../ASCOfficeDocFile/DocDocxConverter/OfficeDrawing/Record.h"
|
||||
|
||||
namespace XLS
|
||||
{
|
||||
|
||||
class CFRecord
|
||||
{
|
||||
public:
|
||||
CFRecord(CFStreamPtr stream, GlobalWorkbookInfoPtr global_info); // Create a record an read its data from the stream
|
||||
CFRecord(CFRecordType::TypeId type_id, GlobalWorkbookInfoPtr global_info); // Create an empty record
|
||||
~CFRecord();
|
||||
|
||||
void save(CFStreamPtr stream);
|
||||
void commitData();
|
||||
|
||||
const CFRecordType::TypeId getTypeId() const;
|
||||
const CFRecordType::TypeString& getTypeString() const;
|
||||
|
||||
const unsigned int getStreamPointer() const;
|
||||
// Pointer to the beginning of the cached data
|
||||
const char* getData() const ;
|
||||
const size_t getDataSize() const;
|
||||
const size_t getMaxRecordSize() const;
|
||||
void appendRawData(CFRecordPtr where_from);
|
||||
void appendRawData(const char* raw_data, const size_t size);
|
||||
void insertDataFromRecordToBeginning(CFRecordPtr where_from);
|
||||
|
||||
const bool isEOF() const; // whether all the data have bean read
|
||||
// Checks whether the specified number of unsigned chars present in the non-read part of the buffer
|
||||
// Doesn't generate an exception
|
||||
const bool checkFitReadSafe(const size_t size) const;
|
||||
// Checks whether the specified number of unsigned chars present in the non-read part of the buffer
|
||||
// Generates an exception
|
||||
bool checkFitRead(const size_t size) const;
|
||||
// Checks whether the specified number of unsigned chars fits in max size of the buffer
|
||||
// Doesn't generate an exception
|
||||
const bool checkFitWriteSafe(const size_t size) const;
|
||||
// Checks whether the specified number of unsigned chars fits in max size of the buffer
|
||||
// Generates an exception
|
||||
void checkFitWrite(const size_t size) const;
|
||||
void skipNunBytes(const size_t n); // Skip the specified number of unsigned chars without reading
|
||||
void RollRdPtrBack(const size_t n); // Move read pointer back to reread some data
|
||||
void resetPointerToBegin();
|
||||
void reserveNunBytes(const size_t n); // Skip the specified number of unsigned chars filled them in with zeros
|
||||
template<class DataType>
|
||||
void reserveNunBytes(const size_t n, const DataType fill_data) // Skip the specified number of unsigned chars filled them in with specified data
|
||||
{
|
||||
checkFitWrite(n);
|
||||
size_t odd_size = n / sizeof(DataType) * sizeof(DataType);
|
||||
for(size_t offset = 0; offset < odd_size; offset += sizeof(DataType))
|
||||
{
|
||||
reinterpret_cast<DataType*>(&intData[size_ + offset])[0] = fill_data;
|
||||
}
|
||||
for(size_t i = 0; i < n % sizeof(DataType); ++i)
|
||||
{
|
||||
intData[size_ + odd_size + i] = 0;
|
||||
}
|
||||
size_ += n;
|
||||
|
||||
}
|
||||
void registerDelayedDataReceiver(CFStream::DELAYED_DATA_SAVER fn, const size_t n, const CFRecordType::TypeId receiver_id = rt_NONE);
|
||||
void registerDelayedDataSource(const unsigned int data, const CFRecordType::TypeId receiver_id);
|
||||
void registerDelayedFilePointerSource(const CFRecordType::TypeId receiver_id);
|
||||
void registerDelayedFilePointerAndOffsetSource(const unsigned int offset, const CFRecordType::TypeId receiver_id);
|
||||
|
||||
template<class T>
|
||||
const T* getCurData() const
|
||||
{
|
||||
return reinterpret_cast<T*>(&data_[rdPtr]);
|
||||
}
|
||||
// Obtain the current rdPtr
|
||||
const size_t getRdPtr() const;
|
||||
|
||||
template<class T>
|
||||
bool loadAnyData(T& val)
|
||||
{
|
||||
////ASSERT(data_); // This throws if we use >> instead of <<
|
||||
if (checkFitRead(sizeof(T)))
|
||||
{
|
||||
#ifdef __ANDROID__
|
||||
memcpy(&val, &data_[rdPtr], sizeof(T));
|
||||
#else
|
||||
val = * getCurData<T>();
|
||||
#endif
|
||||
rdPtr += sizeof(T);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool loadAnyData(wchar_t & val);
|
||||
|
||||
template<class T>
|
||||
void storeAnyData(const T& val)
|
||||
{
|
||||
checkFitWrite(sizeof(T));
|
||||
*reinterpret_cast<T*>(&intData[size_]) = val;
|
||||
size_ += sizeof(T);
|
||||
}
|
||||
void storeLongData(const char* buf, const size_t size);
|
||||
|
||||
GlobalWorkbookInfoPtr getGlobalWorkbookInfo() { return global_info_; }
|
||||
|
||||
CFRecord& operator>>(unsigned char& val) { loadAnyData(val); return *this; }
|
||||
CFRecord& operator>>(unsigned short& val) { loadAnyData(val); return *this; }
|
||||
CFRecord& operator>>(unsigned int& val) { loadAnyData(val); return *this; }
|
||||
CFRecord& operator>>(int& val) { loadAnyData(val); return *this; }
|
||||
CFRecord& operator>>(double& val) { loadAnyData(val); return *this; }
|
||||
CFRecord& operator>>(_GUID_& val) { loadAnyData(val); return *this; }
|
||||
CFRecord& operator>>(short& val) { loadAnyData(val); return *this; }
|
||||
CFRecord& operator>>(char& val) { loadAnyData(val); return *this; }
|
||||
CFRecord& operator>>(bool& val);
|
||||
|
||||
private:
|
||||
static const size_t MAX_RECORD_SIZE = 8224;
|
||||
|
||||
CFStream::ReceiverItems receiver_items;
|
||||
CFStream::SourceItems source_items;
|
||||
|
||||
unsigned int file_ptr;
|
||||
CFRecordType::TypeId type_id_;
|
||||
size_t size_;
|
||||
char* data_;
|
||||
size_t rdPtr;
|
||||
static char intData[MAX_RECORD_SIZE];
|
||||
|
||||
GlobalWorkbookInfoPtr global_info_;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
CFRecord& operator>>(CFRecord& record, std::vector<T>& vec)
|
||||
{
|
||||
while(!record.isEOF())
|
||||
{
|
||||
T element;
|
||||
record >> element;
|
||||
vec.push_back(element);
|
||||
}
|
||||
return record;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
CFRecord& operator<<(CFRecord& record, std::vector<T>& vec)
|
||||
{
|
||||
for(typename std::vector<T>::iterator it = vec.begin(), itEnd = vec.end(); it != itEnd; ++it)
|
||||
{
|
||||
record << *it;
|
||||
}
|
||||
return record;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
|
||||
template<class T>
|
||||
CFRecord& operator>>(CFRecord & record, std::basic_string<T, std::char_traits<T>, std::allocator<T> >& str)
|
||||
{
|
||||
str.clear();
|
||||
T symbol;
|
||||
do
|
||||
{
|
||||
if (record.loadAnyData(symbol) == false)
|
||||
break;
|
||||
str += symbol;
|
||||
} while (symbol);
|
||||
return record;
|
||||
}
|
||||
|
||||
#else
|
||||
CFRecord& operator>>(CFRecord & record, std::string & str);
|
||||
CFRecord& operator>>(CFRecord & record, std::wstring & str);
|
||||
#endif
|
||||
|
||||
|
||||
template<class T>
|
||||
CFRecord& operator>>(CFRecord & record, _CP_OPT(T)& val)
|
||||
{
|
||||
T temp_val;
|
||||
if (record.loadAnyData(temp_val))
|
||||
{
|
||||
val = temp_val;
|
||||
}
|
||||
return record;
|
||||
}
|
||||
|
||||
|
||||
// moved out of the class to be higher in priority than the universal operator
|
||||
template<class T>
|
||||
CFRecord& operator<<(CFRecord & record, _CP_OPT(T)& val)
|
||||
{
|
||||
if (!val) return record;
|
||||
|
||||
T temp_val(*val);
|
||||
record.storeAnyData(temp_val);
|
||||
return record;
|
||||
}
|
||||
|
||||
#define DET_TYPE(num_bits) num_bits <= 8 ? unsigned char : num_bits <=16 ? unsigned short : unsigned int
|
||||
#define GETBIT(from, num) ((from & (1 << num)) != 0)
|
||||
#define GETBITS(from, numL, numH) ((from & (((1 << (numH - numL + 1)) - 1) << numL)) >> numL)
|
||||
#define SETBIT(to, num, setorclear) {setorclear ? to |= (1 << num) : to &= ~(1 << num);}
|
||||
#define SETBITS(to, numL, numH, val) {to &= ~(((1 << (numH - numL + 1)) - 1) << numL); to |= ((val & ((1 << (numH - numL + 1)) - 1)) << numL);}
|
||||
|
||||
} // namespace XLS
|
||||
|
||||
@ -212,7 +212,7 @@ namespace OOX
|
||||
}
|
||||
return nLen;
|
||||
}
|
||||
_UINT16 CFormulaXLSB::toXLSB(NSBinPptxRW::CXlsbBinaryWriter& oStream)
|
||||
_UINT16 CFormulaXLSB::toXLSB(NSBinPptxRW::CXlsbBinaryWriter& oStream, bool bIsBlankFormula)
|
||||
{
|
||||
_UINT16 nFlags = 0;
|
||||
if(m_oCa.ToBool())
|
||||
@ -266,6 +266,10 @@ namespace OOX
|
||||
{
|
||||
nFlagsExt |= 0x1000;
|
||||
}
|
||||
if(bIsBlankFormula)
|
||||
{
|
||||
nFlagsExt |= 0x4000;
|
||||
}
|
||||
return nFlagsExt;
|
||||
}
|
||||
void CFormulaXLSB::toXLSBExt(NSBinPptxRW::CXlsbBinaryWriter& oStream)
|
||||
@ -369,9 +373,11 @@ namespace OOX
|
||||
case SimpleTypes::Spreadsheet::celltypeStr: nType = XLSB::rt_CELL_ST; break;
|
||||
}
|
||||
}
|
||||
bool bIsBlankFormula = false;
|
||||
if(XLSB::rt_CELL_BLANK == nType && bWriteFormula)
|
||||
{
|
||||
nType = XLSB::rt_CELL_ST;
|
||||
bIsBlankFormula = true;
|
||||
}
|
||||
|
||||
_UINT32 nLen = 4+4+2;
|
||||
@ -446,7 +452,7 @@ namespace OOX
|
||||
_UINT16 nFlags = 0;
|
||||
if(bWriteFormula)
|
||||
{
|
||||
nFlags = m_oFormula.toXLSB(oStream);
|
||||
nFlags = m_oFormula.toXLSB(oStream, bIsBlankFormula);
|
||||
}
|
||||
|
||||
if(m_oRichText.IsInit())
|
||||
@ -990,6 +996,11 @@ namespace OOX
|
||||
m_oFormula.Init();
|
||||
}
|
||||
m_oFormula->fromXLSBExt(oStream, nFlags);
|
||||
if(0 != (nFlags & 0x4000))
|
||||
{
|
||||
m_oType.reset(NULL);
|
||||
m_oValue.reset(NULL);
|
||||
}
|
||||
}
|
||||
if(0 != (nFlags & 0x2000))
|
||||
{
|
||||
|
||||
@ -62,7 +62,7 @@ namespace OOX
|
||||
void Clean();
|
||||
void fromXML(XmlUtils::CXmlLiteReader& oReader);
|
||||
_UINT32 getXLSBSize() const;
|
||||
_UINT16 toXLSB(NSBinPptxRW::CXlsbBinaryWriter& oStream);
|
||||
_UINT16 toXLSB(NSBinPptxRW::CXlsbBinaryWriter& oStream, bool bIsBlankFormula);
|
||||
void toXLSBExt(NSBinPptxRW::CXlsbBinaryWriter& oStream);
|
||||
public:
|
||||
bool m_bIsInit;
|
||||
|
||||
@ -95,6 +95,10 @@ SOURCES += ./../DesktopEditor/common/StringBuilder.cpp
|
||||
HEADERS += ./../DesktopEditor/common/StringExt.h
|
||||
SOURCES += ./../DesktopEditor/common/StringExt.cpp
|
||||
|
||||
# BYTE BUILDER
|
||||
HEADERS += ./../DesktopEditor/common/ByteBuilder.h
|
||||
SOURCES += ./../DesktopEditor/common/ByteBuilder.cpp
|
||||
|
||||
# BASE64
|
||||
HEADERS += ./../DesktopEditor/common/Base64.h
|
||||
SOURCES += ./../DesktopEditor/common/Base64.cpp
|
||||
|
||||
@ -15,7 +15,13 @@ TARGET = allthemesgen
|
||||
|
||||
DEFINES += KERNEL_USE_DYNAMIC_LIBRARY
|
||||
DEFINES += GRAPHICS_USE_DYNAMIC_LIBRARY
|
||||
LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -lgraphics -lkernel -lUnicodeConverter -ldoctrenderer
|
||||
LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -lgraphics -lkernel -lUnicodeConverter
|
||||
|
||||
build_xp {
|
||||
LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH/xp -ldoctrenderer
|
||||
} else {
|
||||
LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -ldoctrenderer
|
||||
}
|
||||
|
||||
core_windows {
|
||||
DEFINES -= UNICODE
|
||||
|
||||
212
DesktopEditor/common/ByteBuilder.cpp
Normal file
212
DesktopEditor/common/ByteBuilder.cpp
Normal file
@ -0,0 +1,212 @@
|
||||
/*
|
||||
* (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
|
||||
*
|
||||
*/
|
||||
#include "ByteBuilder.h"
|
||||
#include "File.h"
|
||||
|
||||
namespace NSMemoryUtils
|
||||
{
|
||||
CByteBuilder::CByteBuilder()
|
||||
{
|
||||
m_pData = NULL;
|
||||
m_lSize = 0;
|
||||
|
||||
m_pDataCur = m_pData;
|
||||
m_lSizeCur = m_lSize;
|
||||
}
|
||||
CByteBuilder::~CByteBuilder()
|
||||
{
|
||||
if (NULL != m_pData)
|
||||
free(m_pData);
|
||||
m_pData = NULL;
|
||||
}
|
||||
void CByteBuilder::AddSize(size_t nSize)
|
||||
{
|
||||
if (NULL == m_pData)
|
||||
{
|
||||
m_lSize = (std::max)((int)nSize, 1000);
|
||||
m_pData = (BYTE*)malloc(m_lSize * sizeof(BYTE));
|
||||
|
||||
m_lSizeCur = 0;
|
||||
m_pDataCur = m_pData;
|
||||
return;
|
||||
}
|
||||
|
||||
if ((m_lSizeCur + nSize) > m_lSize)
|
||||
{
|
||||
while ((m_lSizeCur + nSize) > m_lSize)
|
||||
{
|
||||
m_lSize *= 2;
|
||||
}
|
||||
|
||||
BYTE* pRealloc = (BYTE*)realloc(m_pData, m_lSize * sizeof(BYTE));
|
||||
if (NULL != pRealloc)
|
||||
{
|
||||
// реаллок сработал
|
||||
m_pData = pRealloc;
|
||||
m_pDataCur = m_pData + m_lSizeCur;
|
||||
}
|
||||
else
|
||||
{
|
||||
BYTE* pMalloc = (BYTE*)malloc(m_lSize * sizeof(BYTE));
|
||||
memcpy(pMalloc, m_pData, m_lSizeCur * sizeof(BYTE));
|
||||
|
||||
free(m_pData);
|
||||
m_pData = pMalloc;
|
||||
m_pDataCur = m_pData + m_lSizeCur;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CByteBuilder::WriteString(const std::string& sText)
|
||||
{
|
||||
int nSizeof = sizeof(char);
|
||||
size_t nSize = (sText.length() + 1) * nSizeof;
|
||||
AddSize(nSize);
|
||||
memcpy(m_pDataCur, sText.c_str(), nSize - nSizeof);
|
||||
|
||||
m_pDataCur += (nSize - nSizeof);
|
||||
(*((char*)m_pDataCur)) = 0;
|
||||
m_lSizeCur += nSize;
|
||||
m_pDataCur += nSizeof;
|
||||
}
|
||||
void CByteBuilder::WriteString(const std::wstring& sText)
|
||||
{
|
||||
int nSizeof = sizeof(wchar_t);
|
||||
size_t nSize = (sText.length() + 1) * nSizeof;
|
||||
AddSize(nSize);
|
||||
memcpy(m_pDataCur, sText.c_str(), nSize - nSizeof);
|
||||
|
||||
m_pDataCur += (nSize - nSizeof);
|
||||
(*((char*)m_pDataCur)) = 0;
|
||||
m_lSizeCur += nSize;
|
||||
m_pDataCur += nSizeof;
|
||||
}
|
||||
void CByteBuilder::WriteStringUTF8(const std::wstring& sText)
|
||||
{
|
||||
WriteString(U_TO_UTF8(sText));
|
||||
}
|
||||
|
||||
void CByteBuilder::WriteInt(const int& value)
|
||||
{
|
||||
int nSizeof = sizeof(int);
|
||||
AddSize(nSizeof);
|
||||
memcpy(m_pDataCur, &value, nSizeof);
|
||||
|
||||
m_lSizeCur += nSizeof;
|
||||
m_pDataCur += nSizeof;
|
||||
}
|
||||
|
||||
size_t CByteBuilder::GetCurSize()
|
||||
{
|
||||
return m_lSizeCur;
|
||||
}
|
||||
void CByteBuilder::SetCurSize(size_t lCurSize)
|
||||
{
|
||||
m_lSizeCur = lCurSize;
|
||||
m_pDataCur = m_pData + m_lSizeCur;
|
||||
}
|
||||
size_t CByteBuilder::GetSize()
|
||||
{
|
||||
return m_lSize;
|
||||
}
|
||||
|
||||
void CByteBuilder::Clear()
|
||||
{
|
||||
if (NULL != m_pData)
|
||||
free(m_pData);
|
||||
m_pData = NULL;
|
||||
|
||||
m_pData = NULL;
|
||||
m_lSize = 0;
|
||||
|
||||
m_pDataCur = m_pData;
|
||||
m_lSizeCur = 0;
|
||||
}
|
||||
void CByteBuilder::ClearNoAttack()
|
||||
{
|
||||
m_pDataCur = m_pData;
|
||||
m_lSizeCur = 0;
|
||||
}
|
||||
|
||||
BYTE* CByteBuilder::GetData()
|
||||
{
|
||||
return m_pData;
|
||||
}
|
||||
|
||||
// Reader
|
||||
CByteReader::CByteReader(BYTE* pData)
|
||||
{
|
||||
m_pData = pData;
|
||||
m_pDataCur = pData;
|
||||
}
|
||||
|
||||
CByteReader::~CByteReader()
|
||||
{
|
||||
}
|
||||
|
||||
std::string CByteReader::GetString()
|
||||
{
|
||||
BYTE* pEnd = m_pDataCur;
|
||||
while (*pEnd != 0)
|
||||
pEnd++;
|
||||
std::string sRet((char*)m_pDataCur, pEnd - m_pDataCur);
|
||||
m_pDataCur = pEnd + 1;
|
||||
return sRet;
|
||||
}
|
||||
std::wstring CByteReader::GetStringW()
|
||||
{
|
||||
wchar_t* pStart = (wchar_t*)m_pDataCur;
|
||||
wchar_t* pEnd = pStart;
|
||||
while (*pEnd != 0)
|
||||
pEnd++;
|
||||
std::wstring sRet((wchar_t*)m_pDataCur, pEnd - pStart);
|
||||
m_pDataCur += (((pEnd - pStart) + 1) * sizeof(wchar_t));
|
||||
return sRet;
|
||||
}
|
||||
std::wstring CByteReader::GetStringUTF8()
|
||||
{
|
||||
BYTE* pEnd = m_pDataCur;
|
||||
while (*pEnd != 0)
|
||||
pEnd++;
|
||||
std::string sRet((char*)m_pDataCur, pEnd - m_pDataCur);
|
||||
m_pDataCur = pEnd + 1;
|
||||
return UTF8_TO_U(sRet);
|
||||
}
|
||||
|
||||
int CByteReader::GetInt()
|
||||
{
|
||||
int nRet = 0;
|
||||
memcpy(&nRet, m_pDataCur, sizeof(int));
|
||||
m_pDataCur += sizeof(int);
|
||||
return nRet;
|
||||
}
|
||||
}
|
||||
94
DesktopEditor/common/ByteBuilder.h
Normal file
94
DesktopEditor/common/ByteBuilder.h
Normal file
@ -0,0 +1,94 @@
|
||||
/*
|
||||
* (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 _BUILD_BYTE_BUILDER_CROSSPLATFORM_H_
|
||||
#define _BUILD_BYTE_BUILDER_CROSSPLATFORM_H_
|
||||
|
||||
#include <string>
|
||||
#include <string.h>
|
||||
#include <algorithm>
|
||||
#include "Types.h"
|
||||
|
||||
#include "../../Common/kernel_config.h"
|
||||
|
||||
namespace NSMemoryUtils
|
||||
{
|
||||
class KERNEL_DECL CByteBuilder
|
||||
{
|
||||
private:
|
||||
BYTE* m_pData;
|
||||
size_t m_lSize;
|
||||
|
||||
BYTE* m_pDataCur;
|
||||
size_t m_lSizeCur;
|
||||
|
||||
public:
|
||||
CByteBuilder();
|
||||
~CByteBuilder();
|
||||
void AddSize(size_t nSize);
|
||||
|
||||
public:
|
||||
void WriteString(const std::string& sText);
|
||||
void WriteString(const std::wstring& sText);
|
||||
void WriteStringUTF8(const std::wstring& sText);
|
||||
|
||||
void WriteInt(const int& value);
|
||||
|
||||
size_t GetCurSize();
|
||||
void SetCurSize(size_t lCurSize);
|
||||
size_t GetSize();
|
||||
|
||||
void Clear();
|
||||
void ClearNoAttack();
|
||||
|
||||
BYTE* GetData();
|
||||
};
|
||||
|
||||
class KERNEL_DECL CByteReader
|
||||
{
|
||||
private:
|
||||
BYTE* m_pData;
|
||||
BYTE* m_pDataCur;
|
||||
|
||||
public:
|
||||
CByteReader(BYTE* pData);
|
||||
~CByteReader();
|
||||
|
||||
public:
|
||||
std::string GetString();
|
||||
std::wstring GetStringW();
|
||||
std::wstring GetStringUTF8();
|
||||
|
||||
int GetInt();
|
||||
};
|
||||
}
|
||||
|
||||
#endif // _BUILD_BYTE_BUILDER_CROSSPLATFORM_H_
|
||||
@ -34,6 +34,7 @@
|
||||
#include "../common/Directory.h"
|
||||
#include FT_SFNT_NAMES_H
|
||||
#include "fontdictionaryworker.h"
|
||||
#include "../common/ByteBuilder.h"
|
||||
|
||||
#ifndef min
|
||||
#define min(a,b) (((a) < (b)) ? (a) : (b))
|
||||
@ -643,6 +644,53 @@ void ReadNames(NSFonts::CFontInfo* pInfo, FT_Face pFace)
|
||||
}
|
||||
#endif
|
||||
|
||||
std::wstring CFontList::GetFontBySymbol(int symbol)
|
||||
{
|
||||
for (std::list<CFontRange>::iterator iter = m_listRanges.begin(); iter != m_listRanges.end(); iter++)
|
||||
{
|
||||
CFontRange& range = *iter;
|
||||
if (symbol <= range.Start && symbol >= range.End)
|
||||
{
|
||||
return range.Name;
|
||||
}
|
||||
}
|
||||
|
||||
// search range by symbol
|
||||
int _start = 0;
|
||||
int _end = m_nRangesCount - 1;
|
||||
|
||||
int _center = 0;
|
||||
|
||||
if (_start > _end)
|
||||
return L"";
|
||||
|
||||
while (_start < _end)
|
||||
{
|
||||
_center = (_start + _end) >> 1;
|
||||
CFontRange& _range = m_pRanges[_center];
|
||||
|
||||
if (_range.Start > symbol)
|
||||
_end = _center - 1;
|
||||
else if (_range.End < symbol)
|
||||
_start = _center + 1;
|
||||
else
|
||||
{
|
||||
m_listRanges.push_front(_range);
|
||||
return m_pRanges[_center].Name;
|
||||
}
|
||||
}
|
||||
|
||||
if (_start > _end)
|
||||
return L"";
|
||||
|
||||
CFontRange& _range = m_pRanges[_start];
|
||||
if (_range.Start > symbol || _range.End < symbol)
|
||||
return L"";
|
||||
|
||||
m_listRanges.push_front(_range);
|
||||
return m_pRanges[_start].Name;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
int CFontList::GetCharsetPenalty(ULONG ulCandRanges[6], unsigned char unReqCharset)
|
||||
{
|
||||
@ -980,7 +1028,7 @@ void CFontList::ToBuffer(BYTE** pDstData, LONG* pLen, std::wstring strDirectory,
|
||||
}
|
||||
|
||||
*pDstData = pData;
|
||||
*pLen = lDataSize;
|
||||
*pLen = (LONG)(pDataMem - pData);
|
||||
}
|
||||
|
||||
NSFonts::CFontInfo* CFontList::GetByParams(NSFonts::CFontSelectFormat& oSelect, bool bIsDictionaryUse)
|
||||
@ -1424,6 +1472,22 @@ bool CFontList::CheckLoadFromFolderBin(const std::wstring& strDirectory)
|
||||
Add(pFontInfo);
|
||||
}
|
||||
|
||||
if ((_pBuffer - pBuffer) < dwLen1)
|
||||
{
|
||||
NSMemoryUtils::CByteReader oReader(_pBuffer);
|
||||
m_nRangesCount = oReader.GetInt();
|
||||
|
||||
if (m_nRangesCount > 0)
|
||||
m_pRanges = new CFontRange[m_nRangesCount];
|
||||
|
||||
for (int nIndex = 0; nIndex < m_nRangesCount; ++nIndex)
|
||||
{
|
||||
m_pRanges[nIndex].Name = oReader.GetStringUTF8();
|
||||
m_pRanges[nIndex].Start = oReader.GetInt();
|
||||
m_pRanges[nIndex].End = oReader.GetInt();
|
||||
}
|
||||
}
|
||||
|
||||
RELEASEARRAYOBJECTS(pBuffer);
|
||||
|
||||
return true;
|
||||
@ -1515,6 +1579,11 @@ NSFonts::IFontManager* CApplicationFonts::GenerateFontManager()
|
||||
return pManager;
|
||||
}
|
||||
|
||||
std::wstring CApplicationFonts::GetFontBySymbol(int symbol)
|
||||
{
|
||||
return m_oList.GetFontBySymbol(symbol);
|
||||
}
|
||||
|
||||
#if defined(_WIN32) || defined (_WIN64)
|
||||
|
||||
#include <shlobj.h>
|
||||
@ -1640,7 +1709,7 @@ std::vector<std::wstring> CApplicationFonts::GetSetupFontFiles()
|
||||
GetUserNameW(sUserName, &nUserNameLen);
|
||||
std::wstring strUserName(sUserName, nUserNameLen - 1);
|
||||
|
||||
NSDirectory::GetFiles2(L"C:\\Users\\" + strUserName + L"\\AppData\\Local\\Microsoft\\Windows\\Fonts", oArray2, true);
|
||||
NSDirectory::GetFiles2(L"C:\\Users\\" + strUserName + L"\\AppData\\Local\\Microsoft\\Windows\\Fonts", oArray2, false);
|
||||
|
||||
for (std::vector<std::wstring>::iterator i = oArray2.begin(); i != oArray2.end(); i++)
|
||||
{
|
||||
|
||||
@ -36,6 +36,7 @@
|
||||
// на самом деле charset не учитывается
|
||||
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include "FontManager.h"
|
||||
|
||||
namespace NSFonts
|
||||
@ -47,6 +48,14 @@ namespace NSFonts
|
||||
};
|
||||
}
|
||||
|
||||
class CFontRange
|
||||
{
|
||||
public:
|
||||
std::wstring Name;
|
||||
int Start;
|
||||
int End;
|
||||
};
|
||||
|
||||
class CFontList : public NSFonts::IFontList
|
||||
{
|
||||
private:
|
||||
@ -56,6 +65,11 @@ private:
|
||||
std::map<std::wstring, int> m_mapNamesToIndex;
|
||||
std::vector<std::vector<std::wstring> > m_listLikes;
|
||||
|
||||
CFontRange* m_pRanges;
|
||||
int m_nRangesCount;
|
||||
|
||||
std::list<CFontRange> m_listRanges; // последние использованные (найденные)
|
||||
|
||||
public:
|
||||
CFontList()
|
||||
{
|
||||
@ -77,6 +91,9 @@ public:
|
||||
std::vector<std::wstring> ar1;
|
||||
ar1.push_back(L"OpenSymbol");
|
||||
m_listLikes.push_back(ar1);
|
||||
|
||||
m_pRanges = NULL;
|
||||
m_nRangesCount = 0;
|
||||
}
|
||||
~CFontList()
|
||||
{
|
||||
@ -86,6 +103,8 @@ public:
|
||||
RELEASEOBJECT(pTemp);
|
||||
}
|
||||
m_pList.clear();
|
||||
|
||||
RELEASEARRAYOBJECTS(m_pRanges);
|
||||
}
|
||||
|
||||
virtual std::vector<NSFonts::CFontInfo*>* GetFonts() { return &m_pList; }
|
||||
@ -121,6 +140,8 @@ public:
|
||||
void Add (NSFonts::CFontInfo* pInfo);
|
||||
NSFonts::CFontInfo* GetByParams (NSFonts::CFontSelectFormat& oSelect, bool bIsDictionaryUse = true);
|
||||
std::vector<NSFonts::CFontInfo*> GetAllByName (const std::wstring& strFontName);
|
||||
|
||||
std::wstring GetFontBySymbol(int symbol);
|
||||
};
|
||||
|
||||
class CApplicationFonts : public NSFonts::IApplicationFonts
|
||||
@ -128,7 +149,7 @@ class CApplicationFonts : public NSFonts::IApplicationFonts
|
||||
private:
|
||||
CApplicationFontStreams m_oStreams;
|
||||
CFontsCache m_oCache;
|
||||
CFontList m_oList;
|
||||
CFontList m_oList;
|
||||
|
||||
public:
|
||||
CApplicationFonts();
|
||||
@ -154,6 +175,8 @@ public:
|
||||
#endif
|
||||
|
||||
NSFonts::IFontManager* GenerateFontManager();
|
||||
|
||||
std::wstring GetFontBySymbol(int symbol);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@ -1,756 +1,220 @@
|
||||
/*
|
||||
* (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
|
||||
*
|
||||
*/
|
||||
//#include "ApplicationFonts.h"
|
||||
#include "ApplicationFontsWorker.h"
|
||||
#include "../common/File.h"
|
||||
#include "../common/Array.h"
|
||||
#include "../common/Directory.h"
|
||||
#include "./MemoryStream.h"
|
||||
#include "./../graphics/pro/Fonts.h"
|
||||
|
||||
using namespace NSFonts;
|
||||
|
||||
namespace NSFontsApplication
|
||||
{
|
||||
void string_replace(std::wstring& text, const std::wstring& replaceFrom, const std::wstring& replaceTo)
|
||||
{
|
||||
size_t posn = 0;
|
||||
while (std::wstring::npos != (posn = text.find(replaceFrom, posn)))
|
||||
{
|
||||
text.replace(posn, replaceFrom.length(), replaceTo);
|
||||
posn += replaceTo.length();
|
||||
}
|
||||
}
|
||||
|
||||
class CTextItem
|
||||
{
|
||||
protected:
|
||||
wchar_t* m_pData;
|
||||
size_t m_lSize;
|
||||
|
||||
wchar_t* m_pDataCur;
|
||||
size_t m_lSizeCur;
|
||||
|
||||
public:
|
||||
CTextItem()
|
||||
{
|
||||
m_pData = NULL;
|
||||
m_lSize = 0;
|
||||
|
||||
m_pDataCur = m_pData;
|
||||
m_lSizeCur = m_lSize;
|
||||
}
|
||||
CTextItem(const CTextItem& oSrc)
|
||||
{
|
||||
m_pData = NULL;
|
||||
*this = oSrc;
|
||||
}
|
||||
CTextItem& operator=(const CTextItem& oSrc)
|
||||
{
|
||||
RELEASEMEM(m_pData);
|
||||
|
||||
m_lSize = oSrc.m_lSize;
|
||||
m_lSizeCur = oSrc.m_lSizeCur;
|
||||
m_pData = (wchar_t*)malloc(m_lSize * sizeof(wchar_t));
|
||||
|
||||
memcpy(m_pData, oSrc.m_pData, m_lSizeCur * sizeof(wchar_t));
|
||||
|
||||
m_pDataCur = m_pData + m_lSizeCur;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
CTextItem(const size_t& nLen)
|
||||
{
|
||||
m_lSize = nLen;
|
||||
m_pData = (wchar_t*)malloc(m_lSize * sizeof(wchar_t));
|
||||
|
||||
m_lSizeCur = 0;
|
||||
m_pDataCur = m_pData;
|
||||
}
|
||||
CTextItem(wchar_t* pData, const size_t& nLen)
|
||||
{
|
||||
m_lSize = nLen;
|
||||
m_pData = (wchar_t*)malloc(m_lSize * sizeof(wchar_t));
|
||||
|
||||
memcpy(m_pData, pData, m_lSize * sizeof(wchar_t));
|
||||
|
||||
m_lSizeCur = m_lSize;
|
||||
m_pDataCur = m_pData + m_lSize;
|
||||
}
|
||||
CTextItem(wchar_t* pData, BYTE* pUnicodeChecker = NULL)
|
||||
{
|
||||
size_t nLen = GetStringLen(pData);
|
||||
|
||||
m_lSize = nLen;
|
||||
m_pData = (wchar_t*)malloc(m_lSize * sizeof(wchar_t));
|
||||
|
||||
memcpy(m_pData, pData, m_lSize * sizeof(wchar_t));
|
||||
|
||||
m_lSizeCur = m_lSize;
|
||||
m_pDataCur = m_pData + m_lSize;
|
||||
|
||||
if (NULL != pUnicodeChecker)
|
||||
{
|
||||
wchar_t* pMemory = m_pData;
|
||||
while (pMemory < m_pDataCur)
|
||||
{
|
||||
if (!pUnicodeChecker[*pMemory])
|
||||
*pMemory = wchar_t(' ');
|
||||
++pMemory;
|
||||
}
|
||||
}
|
||||
}
|
||||
virtual ~CTextItem()
|
||||
{
|
||||
RELEASEMEM(m_pData);
|
||||
}
|
||||
|
||||
inline void AddSize(const size_t& nSize)
|
||||
{
|
||||
if (NULL == m_pData)
|
||||
{
|
||||
m_lSize = 1000;
|
||||
if (nSize > m_lSize)
|
||||
m_lSize = nSize;
|
||||
|
||||
m_pData = (wchar_t*)malloc(m_lSize * sizeof(wchar_t));
|
||||
|
||||
m_lSizeCur = 0;
|
||||
m_pDataCur = m_pData;
|
||||
return;
|
||||
}
|
||||
|
||||
if ((m_lSizeCur + nSize) > m_lSize)
|
||||
{
|
||||
while ((m_lSizeCur + nSize) > m_lSize)
|
||||
{
|
||||
m_lSize *= 2;
|
||||
}
|
||||
|
||||
wchar_t* pRealloc = (wchar_t*)realloc(m_pData, m_lSize * sizeof(wchar_t));
|
||||
if (NULL != pRealloc)
|
||||
{
|
||||
// реаллок сработал
|
||||
m_pData = pRealloc;
|
||||
m_pDataCur = m_pData + m_lSizeCur;
|
||||
}
|
||||
else
|
||||
{
|
||||
wchar_t* pMalloc = (wchar_t*)malloc(m_lSize * sizeof(wchar_t));
|
||||
memcpy(pMalloc, m_pData, m_lSizeCur * sizeof(wchar_t));
|
||||
|
||||
free(m_pData);
|
||||
m_pData = pMalloc;
|
||||
m_pDataCur = m_pData + m_lSizeCur;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
inline void operator+=(const std::wstring& oTemp)
|
||||
{
|
||||
WriteString(oTemp.c_str(), oTemp.length());
|
||||
}
|
||||
inline wchar_t operator[](const size_t& nIndex)
|
||||
{
|
||||
if (nIndex < m_lSizeCur)
|
||||
return m_pData[nIndex];
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline void AddSpace()
|
||||
{
|
||||
AddSize(1);
|
||||
*m_pDataCur = wchar_t(' ');
|
||||
|
||||
++m_lSizeCur;
|
||||
++m_pDataCur;
|
||||
}
|
||||
inline void CorrectUnicode(const BYTE* pUnicodeChecker)
|
||||
{
|
||||
if (NULL != pUnicodeChecker)
|
||||
{
|
||||
wchar_t* pMemory = m_pData;
|
||||
while (pMemory < m_pDataCur)
|
||||
{
|
||||
if (!pUnicodeChecker[*pMemory])
|
||||
*pMemory = wchar_t(' ');
|
||||
++pMemory;
|
||||
}
|
||||
}
|
||||
}
|
||||
inline void RemoveLastSpaces()
|
||||
{
|
||||
wchar_t* pMemory = m_pDataCur - 1;
|
||||
while ((pMemory > m_pData) && (wchar_t(' ') == *pMemory))
|
||||
{
|
||||
--pMemory;
|
||||
--m_lSizeCur;
|
||||
--m_pDataCur;
|
||||
}
|
||||
|
||||
}
|
||||
inline bool IsSpace()
|
||||
{
|
||||
if (1 != m_lSizeCur)
|
||||
return false;
|
||||
return (wchar_t(' ') == *m_pData);
|
||||
}
|
||||
|
||||
public:
|
||||
inline void WriteString(const wchar_t* pString, const size_t& nLen)
|
||||
{
|
||||
AddSize(nLen);
|
||||
memcpy(m_pDataCur, pString, nLen * sizeof(wchar_t));
|
||||
m_pDataCur += nLen;
|
||||
m_lSizeCur += nLen;
|
||||
}
|
||||
inline size_t GetCurSize()
|
||||
{
|
||||
return m_lSizeCur;
|
||||
}
|
||||
inline size_t GetSize()
|
||||
{
|
||||
return m_lSize;
|
||||
}
|
||||
inline void Clear()
|
||||
{
|
||||
RELEASEMEM(m_pData);
|
||||
|
||||
m_pData = NULL;
|
||||
m_lSize = 0;
|
||||
|
||||
m_pDataCur = m_pData;
|
||||
m_lSizeCur = 0;
|
||||
}
|
||||
inline void ClearNoAttack()
|
||||
{
|
||||
m_pDataCur = m_pData;
|
||||
m_lSizeCur = 0;
|
||||
}
|
||||
|
||||
inline size_t GetStringLen(wchar_t* pData)
|
||||
{
|
||||
wchar_t* s = pData;
|
||||
for (; *s != 0; ++s);
|
||||
return (size_t)(s - pData);
|
||||
}
|
||||
|
||||
inline std::wstring GetCString()
|
||||
{
|
||||
std::wstring str(m_pData, (int)m_lSizeCur);
|
||||
return str;
|
||||
}
|
||||
inline wchar_t* GetBuffer()
|
||||
{
|
||||
return m_pData;
|
||||
}
|
||||
};
|
||||
|
||||
class CStringWriter : public CTextItem
|
||||
{
|
||||
public:
|
||||
CStringWriter() : CTextItem()
|
||||
{
|
||||
}
|
||||
virtual ~CStringWriter()
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
inline void Write(CStringWriter& oWriter)
|
||||
{
|
||||
CTextItem::WriteString(oWriter.m_pData, oWriter.m_lSizeCur);
|
||||
}
|
||||
};
|
||||
|
||||
class CFontInfoJS
|
||||
{
|
||||
public:
|
||||
std::wstring m_sName;
|
||||
|
||||
int m_lIndexR;
|
||||
int m_lFaceIndexR;
|
||||
int m_lIndexI;
|
||||
int m_lFaceIndexI;
|
||||
int m_lIndexB;
|
||||
int m_lFaceIndexB;
|
||||
int m_lIndexBI;
|
||||
int m_lFaceIndexBI;
|
||||
|
||||
CFontInfoJS()
|
||||
{
|
||||
m_sName = L"";
|
||||
|
||||
m_lIndexR = -1;
|
||||
m_lFaceIndexR = -1;
|
||||
m_lIndexI = -1;
|
||||
m_lFaceIndexI = -1;
|
||||
m_lIndexB = -1;
|
||||
m_lFaceIndexB = -1;
|
||||
m_lIndexBI = -1;
|
||||
m_lFaceIndexBI = -1;
|
||||
}
|
||||
|
||||
CFontInfoJS(const CFontInfoJS& oSrc)
|
||||
{
|
||||
*this = oSrc;
|
||||
}
|
||||
|
||||
CFontInfoJS& operator=(const CFontInfoJS& oSrc)
|
||||
{
|
||||
m_sName = oSrc.m_sName;
|
||||
|
||||
m_lIndexR = oSrc.m_lIndexR;
|
||||
m_lIndexI = oSrc.m_lIndexI;
|
||||
m_lIndexB = oSrc.m_lIndexB;
|
||||
m_lIndexBI = oSrc.m_lIndexBI;
|
||||
|
||||
m_lFaceIndexR = oSrc.m_lFaceIndexR;
|
||||
m_lFaceIndexI = oSrc.m_lFaceIndexI;
|
||||
m_lFaceIndexB = oSrc.m_lFaceIndexB;
|
||||
m_lFaceIndexBI = oSrc.m_lFaceIndexBI;
|
||||
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
static std::vector<std::wstring> SaveAllFontsJS(NSFonts::IApplicationFonts* applicationFonts, CStringWriter& oWriterJS)
|
||||
{
|
||||
std::vector<std::wstring> arrNames;
|
||||
|
||||
std::vector<NSFonts::CFontInfo*>* pList = applicationFonts->GetList()->GetFonts();
|
||||
|
||||
#ifdef _IOS
|
||||
|
||||
size_t nOldCount = pList->size();
|
||||
for (size_t i = 0; i < nOldCount; i++)
|
||||
{
|
||||
CFontInfo* pInfo = pList->operator [](i);
|
||||
|
||||
if (pInfo->m_wsFontName.find(L".") == 0)
|
||||
{
|
||||
pList->erase(pList->begin() + i);
|
||||
// странные шрифты какие-то есть в ios
|
||||
//pList->RemoveAt(i);
|
||||
i--;
|
||||
nOldCount--;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
size_t nCount = pList->size();
|
||||
|
||||
// сначала строим массив всех файлов шрифтов
|
||||
std::map<std::wstring, LONG> mapFontFiles;
|
||||
std::map<LONG, std::wstring> mapFontFiles2;
|
||||
LONG lFontFiles = 0;
|
||||
for (int i = 0; i < nCount; ++i)
|
||||
{
|
||||
CFontInfo* pInfo = pList->operator [](i);
|
||||
|
||||
if (mapFontFiles.find(pInfo->m_wsFontPath) == mapFontFiles.end())
|
||||
{
|
||||
mapFontFiles.insert(std::pair<std::wstring, LONG>(pInfo->m_wsFontPath, lFontFiles));
|
||||
mapFontFiles2.insert(std::pair<LONG, std::wstring>(lFontFiles, pInfo->m_wsFontPath));
|
||||
++lFontFiles;
|
||||
}
|
||||
}
|
||||
// -----------------------------------------
|
||||
|
||||
// теперь строим массив всех шрифтов по имени
|
||||
std::map<std::wstring, CFontInfoJS> mapFonts;
|
||||
CArray<std::wstring> arrFonts;
|
||||
|
||||
for (int i = 0; i < nCount; ++i)
|
||||
{
|
||||
CFontInfo* pInfo = (CFontInfo*)pList->operator [](i);
|
||||
std::wstring strPath = pInfo->m_wsFontPath;
|
||||
std::wstring strName = pInfo->m_wsFontName;
|
||||
|
||||
int lFontIndex = 0;
|
||||
int lFaceIndex = 0;
|
||||
|
||||
std::map<std::wstring, LONG>::iterator it = mapFontFiles.find(strPath);
|
||||
lFontIndex = (int)it->second;
|
||||
|
||||
if (pInfo->m_lIndex >= 0)
|
||||
lFaceIndex = (int)pInfo->m_lIndex;
|
||||
|
||||
std::map<std::wstring, CFontInfoJS>::iterator pPair = mapFonts.find(pInfo->m_wsFontName);
|
||||
if (mapFonts.end() != pPair)
|
||||
{
|
||||
pPair->second.m_sName = pInfo->m_wsFontName;
|
||||
|
||||
if (pInfo->m_bBold && pInfo->m_bItalic)
|
||||
{
|
||||
pPair->second.m_lIndexBI = lFontIndex;
|
||||
pPair->second.m_lFaceIndexBI = lFaceIndex;
|
||||
}
|
||||
else if (pInfo->m_bBold)
|
||||
{
|
||||
pPair->second.m_lIndexB = lFontIndex;
|
||||
pPair->second.m_lFaceIndexB = lFaceIndex;
|
||||
}
|
||||
else if (pInfo->m_bItalic)
|
||||
{
|
||||
pPair->second.m_lIndexI = lFontIndex;
|
||||
pPair->second.m_lFaceIndexI = lFaceIndex;
|
||||
}
|
||||
else
|
||||
{
|
||||
pPair->second.m_lIndexR = lFontIndex;
|
||||
pPair->second.m_lFaceIndexR = lFaceIndex;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CFontInfoJS fontInfo;
|
||||
|
||||
fontInfo.m_sName = pInfo->m_wsFontName;
|
||||
|
||||
if (pInfo->m_bBold && pInfo->m_bItalic)
|
||||
{
|
||||
fontInfo.m_lIndexBI = lFontIndex;
|
||||
fontInfo.m_lFaceIndexBI = lFaceIndex;
|
||||
}
|
||||
else if (pInfo->m_bBold)
|
||||
{
|
||||
fontInfo.m_lIndexB = lFontIndex;
|
||||
fontInfo.m_lFaceIndexB = lFaceIndex;
|
||||
}
|
||||
else if (pInfo->m_bItalic)
|
||||
{
|
||||
fontInfo.m_lIndexI = lFontIndex;
|
||||
fontInfo.m_lFaceIndexI = lFaceIndex;
|
||||
}
|
||||
else
|
||||
{
|
||||
fontInfo.m_lIndexR = lFontIndex;
|
||||
fontInfo.m_lFaceIndexR = lFaceIndex;
|
||||
}
|
||||
|
||||
mapFonts.insert(std::pair<std::wstring, CFontInfoJS>(fontInfo.m_sName, fontInfo));
|
||||
arrFonts.Add(fontInfo.m_sName);
|
||||
}
|
||||
}
|
||||
// -------------------------------------------
|
||||
|
||||
// теперь сортируем шрифты по имени ----------
|
||||
int nCountFonts = arrFonts.GetCount();
|
||||
for (int i = 0; i < nCountFonts; ++i)
|
||||
{
|
||||
for (int j = i + 1; j < nCountFonts; ++j)
|
||||
{
|
||||
if (arrFonts[i] > arrFonts[j])
|
||||
{
|
||||
std::wstring temp = arrFonts[i];
|
||||
arrFonts[i] = arrFonts[j];
|
||||
arrFonts[j] = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
// -------------------------------------------
|
||||
|
||||
// и самое главное. Здесь должен скидываться скрипт для работы со всеми шрифтами.
|
||||
// все объекты, которые позволят не знать о существующих фонтах
|
||||
if (true)
|
||||
{
|
||||
// сначала все файлы
|
||||
size_t nCountFiles = mapFontFiles.size();
|
||||
if (nCountFiles == 0)
|
||||
oWriterJS += (L"window[\"__fonts_files\"] = []; \n\n");
|
||||
else
|
||||
{
|
||||
std::wstring* pMassFiles = new std::wstring[nCountFiles];
|
||||
for ( std::map<std::wstring, LONG>::iterator pos = mapFontFiles.begin(); pos != mapFontFiles.end(); ++pos)
|
||||
{
|
||||
std::wstring strFontId = pos->first;
|
||||
|
||||
string_replace(strFontId, L"\\\\", L"\\");
|
||||
string_replace(strFontId, L"\\", L"/");
|
||||
|
||||
//int nStart = strFontId.find_last_of(wchar_t('\\'));
|
||||
//strFontId = strFontId.substr(nStart + 1);
|
||||
|
||||
pMassFiles[pos->second] = strFontId;
|
||||
}
|
||||
|
||||
oWriterJS += (L"window[\"__fonts_files\"] = [\n");
|
||||
for (size_t nIndex = 0; nIndex < nCountFiles; ++nIndex)
|
||||
{
|
||||
oWriterJS += (L"\"");
|
||||
oWriterJS += (pMassFiles[nIndex]);
|
||||
if (nIndex != (nCountFiles - 1))
|
||||
oWriterJS += (L"\",\n");
|
||||
else
|
||||
oWriterJS += (L"\"");
|
||||
}
|
||||
oWriterJS += (L"\n];\n\n");
|
||||
|
||||
delete [] pMassFiles;
|
||||
}
|
||||
|
||||
oWriterJS += L"window[\"__fonts_infos\"] = [\n";
|
||||
|
||||
for (int index = 0; index < nCountFonts; ++index)
|
||||
{
|
||||
std::map<std::wstring, CFontInfoJS>::iterator pPair = mapFonts.find(arrFonts[index]);
|
||||
|
||||
char buffer[1000];
|
||||
sprintf(buffer, "\",%d,%d,%d,%d,%d,%d,%d,%d]", pPair->second.m_lIndexR, pPair->second.m_lFaceIndexR,
|
||||
pPair->second.m_lIndexI, pPair->second.m_lFaceIndexI,
|
||||
pPair->second.m_lIndexB, pPair->second.m_lFaceIndexB,
|
||||
pPair->second.m_lIndexBI, pPair->second.m_lFaceIndexBI);
|
||||
|
||||
std::string sBuffer(buffer);
|
||||
|
||||
oWriterJS += L"[\"";
|
||||
oWriterJS += pPair->second.m_sName;
|
||||
oWriterJS += NSFile::CUtf8Converter::GetUnicodeFromCharPtr(sBuffer);
|
||||
|
||||
if (index != (nCountFonts - 1))
|
||||
oWriterJS += (L",\n");
|
||||
else
|
||||
oWriterJS += (L"\n");
|
||||
|
||||
arrNames.push_back(pPair->second.m_sName);
|
||||
}
|
||||
oWriterJS += (L"];\n\n");
|
||||
|
||||
if (true)
|
||||
{
|
||||
BYTE* pData = NULL;
|
||||
LONG lLen = 0;
|
||||
applicationFonts->GetList()->ToBuffer(&pData, &lLen, L"", true);
|
||||
|
||||
char* cData64 = NULL;
|
||||
int nData64Dst = 0;
|
||||
NSFile::CBase64Converter::Encode(pData, (int)lLen, cData64, nData64Dst, NSBase64::B64_BASE64_FLAG_NOCRLF);
|
||||
|
||||
std::wstring sData64 = NSFile::CUtf8Converter::GetUnicodeFromCharPtr(cData64, (LONG)nData64Dst, FALSE);
|
||||
|
||||
oWriterJS += (L"window[\"g_fonts_selection_bin\"] = \"");
|
||||
oWriterJS += sData64;
|
||||
oWriterJS += L"\";\n";
|
||||
|
||||
RELEASEARRAYOBJECTS(pData);
|
||||
RELEASEARRAYOBJECTS(cData64);
|
||||
}
|
||||
}
|
||||
|
||||
return arrNames;
|
||||
}
|
||||
|
||||
class CStreamReader
|
||||
{
|
||||
private:
|
||||
BYTE* Data;
|
||||
BYTE* DataEnd;
|
||||
BYTE* DataCur;
|
||||
|
||||
public:
|
||||
CStreamReader()
|
||||
{
|
||||
Data = NULL;
|
||||
DataEnd = NULL;
|
||||
DataCur = NULL;
|
||||
}
|
||||
CStreamReader(BYTE* pData, unsigned int nSize)
|
||||
{
|
||||
Data = pData;
|
||||
DataEnd = Data + nSize;
|
||||
DataCur = Data;
|
||||
}
|
||||
|
||||
inline bool IsNoEnd()
|
||||
{
|
||||
return (DataCur < DataEnd);
|
||||
}
|
||||
inline void Skip(int count)
|
||||
{
|
||||
DataCur += count;
|
||||
}
|
||||
inline BYTE* GetCur()
|
||||
{
|
||||
return DataCur;
|
||||
}
|
||||
|
||||
inline int GetInt32()
|
||||
{
|
||||
#ifdef _ARM_ALIGN_
|
||||
int ret = 0;
|
||||
memcpy(&ret, DataCur, sizeof(int));
|
||||
DataCur += 4;
|
||||
return ret;
|
||||
#else
|
||||
int ret = *((int*)DataCur);
|
||||
DataCur += 4;
|
||||
return ret;
|
||||
#endif
|
||||
}
|
||||
inline BYTE GetUChar()
|
||||
{
|
||||
BYTE ret = *DataCur;
|
||||
++DataCur;
|
||||
return ret;
|
||||
}
|
||||
inline std::string GetString1()
|
||||
{
|
||||
int nLen = GetInt32();
|
||||
if (0 == nLen)
|
||||
return "";
|
||||
|
||||
std::string s((char*)DataCur, nLen);
|
||||
DataCur += nLen;
|
||||
return s;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
CApplicationFontsWorker::CApplicationFontsWorker()
|
||||
{
|
||||
|
||||
}
|
||||
CApplicationFontsWorker::~CApplicationFontsWorker()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
std::vector<std::wstring> CApplicationFontsWorker::CheckApplication(bool bIsNeedSystemFonts,
|
||||
unsigned char* pDataSrc, unsigned int nLenSrc,
|
||||
unsigned char*& pDataDst, unsigned int& nLenDst)
|
||||
{
|
||||
std::vector<std::wstring> arrNames;
|
||||
|
||||
std::vector<std::wstring> fonts;
|
||||
NSFonts::IApplicationFonts* pFonts = NSFonts::NSApplication::Create();
|
||||
|
||||
pDataDst = NULL;
|
||||
nLenDst = 0;
|
||||
|
||||
if (bIsNeedSystemFonts)
|
||||
{
|
||||
fonts = pFonts->GetSetupFontFiles();
|
||||
}
|
||||
|
||||
for (std::vector<std::wstring>::iterator iter = m_arAdditionalFolders.begin(); iter != m_arAdditionalFolders.end(); ++iter)
|
||||
{
|
||||
NSDirectory::GetFiles2(*iter, fonts);
|
||||
}
|
||||
|
||||
if (NULL != pDataSrc)
|
||||
{
|
||||
// проверяем, поменялось ли чего
|
||||
NSFontsApplication::CStreamReader oReader(pDataSrc, nLenSrc);
|
||||
int nLenAllFonts = oReader.GetInt32();
|
||||
oReader.Skip(nLenAllFonts);
|
||||
|
||||
std::vector<std::wstring> arrOld;
|
||||
|
||||
int nCountCache = oReader.GetInt32();
|
||||
for (int i = 0; i < nCountCache; ++i)
|
||||
{
|
||||
int nLen = oReader.GetInt32();
|
||||
arrOld.push_back(NSFile::CUtf8Converter::GetUnicodeStringFromUTF8(oReader.GetCur(), (LONG)nLen));
|
||||
oReader.Skip(nLen);
|
||||
}
|
||||
|
||||
if (fonts.size() == arrOld.size())
|
||||
{
|
||||
int nCountFonts = (int)fonts.size();
|
||||
bool bIsBreak = false;
|
||||
for (int i = 0 ; i < nCountFonts; ++i)
|
||||
{
|
||||
if (fonts[i] != arrOld[i])
|
||||
{
|
||||
bIsBreak = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (bIsBreak)
|
||||
{
|
||||
// ничего не поменялось
|
||||
int nCountNames = oReader.GetInt32();
|
||||
for (int i = 0; i < nCountNames; ++i)
|
||||
{
|
||||
int nLen = oReader.GetInt32();
|
||||
arrNames.push_back(NSFile::CUtf8Converter::GetUnicodeStringFromUTF8(oReader.GetCur(), (LONG)nLen));
|
||||
oReader.Skip(nLen);
|
||||
}
|
||||
|
||||
return arrNames;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// произошли изменения
|
||||
pFonts->InitializeFromArrayFiles(fonts);
|
||||
|
||||
NSFontsApplication::CStringWriter oWriterJS;
|
||||
arrNames = NSFontsApplication::SaveAllFontsJS(pFonts, oWriterJS);
|
||||
|
||||
// теперь нужно записать новую дату
|
||||
NSMemoryStream::CMemoryStream oStream;
|
||||
std::string sAllFontsJS = NSFile::CUtf8Converter::GetUtf8StringFromUnicode2(oWriterJS.GetBuffer(), (LONG)oWriterJS.GetCurSize());
|
||||
oStream.WriteStringA2(sAllFontsJS.c_str(), (int)sAllFontsJS.length());
|
||||
|
||||
int nCountF = (int)fonts.size();
|
||||
oStream.WriteLONG((LONG)nCountF);
|
||||
|
||||
for (int i = 0; i < nCountF; ++i)
|
||||
{
|
||||
std::string sTmp = NSFile::CUtf8Converter::GetUtf8StringFromUnicode(fonts[i]);
|
||||
oStream.WriteStringA2(sTmp.c_str(), (int)sTmp.length());
|
||||
}
|
||||
|
||||
nCountF = (int)arrNames.size();
|
||||
oStream.WriteLONG((LONG)nCountF);
|
||||
for (std::vector<std::wstring>::iterator iter = arrNames.begin(); iter != arrNames.end(); ++iter)
|
||||
{
|
||||
std::string sTmp = NSFile::CUtf8Converter::GetUtf8StringFromUnicode(*iter);
|
||||
oStream.WriteStringA2(sTmp.c_str(), (int)sTmp.length());
|
||||
}
|
||||
|
||||
nLenDst = (unsigned int)oStream.GetSize();
|
||||
pDataDst = new unsigned char[nLenDst];
|
||||
memcpy(pDataDst, oStream.GetData(), (size_t)nLenDst);
|
||||
|
||||
return arrNames;
|
||||
}
|
||||
/*
|
||||
* (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
|
||||
*
|
||||
*/
|
||||
#include "ApplicationFontsWorker.h"
|
||||
#include "application_generate_fonts.h"
|
||||
|
||||
CApplicationFontsWorker::CApplicationFontsWorker()
|
||||
{
|
||||
m_bIsUseSystemFonts = true;
|
||||
m_bIsNeedThumbnails = true;
|
||||
m_bIsUseOpenType = true;
|
||||
}
|
||||
CApplicationFontsWorker::~CApplicationFontsWorker()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
NSFonts::IApplicationFonts* CApplicationFontsWorker::Check()
|
||||
{
|
||||
if (m_sDirectory.empty())
|
||||
return NULL;
|
||||
|
||||
std::wstring strAllFontsJSPath = m_sDirectory + L"/AllFonts.js";
|
||||
std::wstring strFontsSelectionBin = m_sDirectory + L"/font_selection.bin";
|
||||
|
||||
std::vector<std::string> strFonts;
|
||||
|
||||
if (true)
|
||||
{
|
||||
NSFile::CFileBinary oFile;
|
||||
if (oFile.OpenFile(m_sDirectory + L"/fonts.log"))
|
||||
{
|
||||
int nSize = oFile.GetFileSize();
|
||||
char* pBuffer = new char[nSize];
|
||||
DWORD dwReaden = 0;
|
||||
oFile.ReadFile((BYTE*)pBuffer, nSize, dwReaden);
|
||||
oFile.CloseFile();
|
||||
|
||||
int nStart = 0;
|
||||
int nCur = nStart;
|
||||
for (; nCur < nSize; ++nCur)
|
||||
{
|
||||
if (pBuffer[nCur] == '\n')
|
||||
{
|
||||
int nEnd = nCur - 1;
|
||||
if (nEnd > nStart)
|
||||
{
|
||||
std::string s(pBuffer + nStart, nEnd - nStart + 1);
|
||||
strFonts.push_back(s);
|
||||
}
|
||||
nStart = nCur + 1;
|
||||
}
|
||||
}
|
||||
|
||||
delete[] pBuffer;
|
||||
}
|
||||
|
||||
#ifdef ONLYOFFICE_FONTS_VERSION_
|
||||
if (0 != strFonts.size())
|
||||
{
|
||||
// check version!!!
|
||||
std::string sOO_Version = strFonts[0];
|
||||
if (0 != sOO_Version.find("ONLYOFFICE_FONTS_VERSION_"))
|
||||
{
|
||||
strFonts.clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string sVersion = sOO_Version.substr(25);
|
||||
int nVersion = std::stoi(sVersion);
|
||||
if (nVersion != ONLYOFFICE_FONTS_VERSION_)
|
||||
strFonts.clear();
|
||||
else
|
||||
strFonts.erase(strFonts.begin());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
NSFonts::IApplicationFonts* pApplicationF = NSFonts::NSApplication::Create();
|
||||
std::vector<std::wstring> strFontsW_Cur;
|
||||
|
||||
if (m_bIsUseSystemFonts)
|
||||
strFontsW_Cur = pApplicationF->GetSetupFontFiles();
|
||||
|
||||
#if defined(_LINUX) && !defined(__ANDROID__)
|
||||
std::wstring sHome = GetHomeDirectory();
|
||||
if (!sHome.empty())
|
||||
{
|
||||
#ifdef _MAC
|
||||
NSDirectory::GetFiles2(sHome + L"/Library/Fonts", strFontsW_Cur, true);
|
||||
#else
|
||||
NSDirectory::GetFiles2(sHome + L"/.fonts", strFontsW_Cur, true);
|
||||
NSDirectory::GetFiles2(sHome + L"/.local/share/fonts", strFontsW_Cur, true);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
for (std::vector<std::wstring>::iterator i = m_arAdditionalFolders.begin(); i != m_arAdditionalFolders.end(); i++)
|
||||
{
|
||||
NSDirectory::GetFiles2(*i, strFontsW_Cur, true);
|
||||
}
|
||||
|
||||
bool bIsEqual = true;
|
||||
if (strFonts.size() != strFontsW_Cur.size())
|
||||
bIsEqual = false;
|
||||
|
||||
if (bIsEqual)
|
||||
{
|
||||
int nCount = (int)strFonts.size();
|
||||
for (int i = 0; i < nCount; ++i)
|
||||
{
|
||||
if (strFonts[i] != NSFile::CUtf8Converter::GetUtf8StringFromUnicode2(strFontsW_Cur[i].c_str(), strFontsW_Cur[i].length()))
|
||||
{
|
||||
bIsEqual = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (bIsEqual)
|
||||
{
|
||||
if (!NSFile::CFileBinary::Exists(strFontsSelectionBin))
|
||||
bIsEqual = false;
|
||||
}
|
||||
|
||||
if (!bIsEqual)
|
||||
{
|
||||
if (NSFile::CFileBinary::Exists(strAllFontsJSPath))
|
||||
NSFile::CFileBinary::Remove(strAllFontsJSPath);
|
||||
if (NSFile::CFileBinary::Exists(strFontsSelectionBin))
|
||||
NSFile::CFileBinary::Remove(strFontsSelectionBin);
|
||||
|
||||
if (strFonts.size() != 0)
|
||||
NSFile::CFileBinary::Remove(m_sDirectory + L"/fonts.log");
|
||||
|
||||
NSFile::CFileBinary oFile;
|
||||
oFile.CreateFileW(m_sDirectory + L"/fonts.log");
|
||||
#ifdef ONLYOFFICE_FONTS_VERSION_
|
||||
oFile.WriteStringUTF8(L"ONLYOFFICE_FONTS_VERSION_");
|
||||
oFile.WriteStringUTF8(std::to_wstring(ONLYOFFICE_FONTS_VERSION_));
|
||||
oFile.WriteFile((BYTE*)"\n", 1);
|
||||
#endif
|
||||
int nCount = (int)strFontsW_Cur.size();
|
||||
for (int i = 0; i < nCount; ++i)
|
||||
{
|
||||
oFile.WriteStringUTF8(strFontsW_Cur[i]);
|
||||
oFile.WriteFile((BYTE*)"\n", 1);
|
||||
}
|
||||
oFile.CloseFile();
|
||||
|
||||
int nFlag = 3;
|
||||
if (!m_bIsUseOpenType)
|
||||
nFlag = 2;
|
||||
|
||||
pApplicationF->InitializeFromArrayFiles(strFontsW_Cur, nFlag);
|
||||
|
||||
NSCommon::SaveAllFontsJS(pApplicationF, strAllFontsJSPath, m_bIsNeedThumbnails ? m_sDirectory : L"", strFontsSelectionBin);
|
||||
}
|
||||
|
||||
pApplicationF->Release();
|
||||
pApplicationF = NSFonts::NSApplication::Create();
|
||||
pApplicationF->InitializeFromFolder(m_sDirectory);
|
||||
|
||||
return pApplicationF;
|
||||
}
|
||||
|
||||
std::string CApplicationFontsWorker::GetAllFonts()
|
||||
{
|
||||
std::string sAllFonts = "";
|
||||
NSFile::CFileBinary::ReadAllTextUtf8A(m_sDirectory + L"/AllFonts.js", sAllFonts);
|
||||
return sAllFonts;
|
||||
}
|
||||
|
||||
std::vector<std::wstring> CApplicationFontsWorker::GetFontNames(NSFonts::IApplicationFonts* pFonts)
|
||||
{
|
||||
std::vector<std::wstring> arNames;
|
||||
if (!pFonts || !pFonts->GetList())
|
||||
return arNames;
|
||||
std::vector<NSFonts::CFontInfo*>* arInfos = pFonts->GetList()->GetFonts();
|
||||
|
||||
std::map<std::wstring, bool> map;
|
||||
|
||||
for (std::vector<NSFonts::CFontInfo*>::iterator iter = arInfos->begin(); iter != arInfos->end(); iter++)
|
||||
{
|
||||
if (map.find((*iter)->m_wsFontName) == map.end())
|
||||
arNames.push_back((*iter)->m_wsFontName);
|
||||
}
|
||||
|
||||
std::sort(arNames.begin(), arNames.end());
|
||||
return arNames;
|
||||
}
|
||||
|
||||
@ -34,19 +34,25 @@
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "../graphics/pro/Fonts.h"
|
||||
|
||||
class CApplicationFontsWorker
|
||||
{
|
||||
public:
|
||||
std::vector<std::wstring> m_arAdditionalFolders;
|
||||
bool m_bIsUseSystemFonts;
|
||||
std::vector<std::wstring> m_arAdditionalFolders;
|
||||
std::wstring m_sDirectory;
|
||||
bool m_bIsNeedThumbnails;
|
||||
bool m_bIsUseOpenType;
|
||||
|
||||
public:
|
||||
CApplicationFontsWorker();
|
||||
~CApplicationFontsWorker();
|
||||
|
||||
std::vector<std::wstring> CheckApplication(bool bIsNeedSystemFonts,
|
||||
unsigned char* pDataSrc, unsigned int nLenSrc,
|
||||
unsigned char*& pDataDst, unsigned int& nLenDst);
|
||||
NSFonts::IApplicationFonts* Check();
|
||||
std::string GetAllFonts();
|
||||
|
||||
static std::vector<std::wstring> GetFontNames(NSFonts::IApplicationFonts* pFonts);
|
||||
};
|
||||
|
||||
#endif // _BUILD_APPLICATIONFONTSWORKER_H_
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -142,6 +142,13 @@ private:
|
||||
#define FONT_CACHE_SIZES_INDEXES_SIZE MAX_UNICODE_COUNT
|
||||
#define FONT_CACHE_SIZES_INDEXES_SIZE_2 MAX_UNICODE_COUNT2 // MAX_UNICODE_COUNT * sizeof(unsigned short)
|
||||
|
||||
class CVectorWorker
|
||||
{
|
||||
public:
|
||||
FT_Outline_Funcs* func_interface;
|
||||
void* user;
|
||||
};
|
||||
|
||||
class CFontStream;
|
||||
class CFontManager;
|
||||
class CFontFile : public NSFonts::IFontFile
|
||||
@ -229,6 +236,8 @@ public:
|
||||
bool SetTextMatrix(const double& fA, const double& fB, const double& fC, const double fD, double fE, double fF);
|
||||
void SetFontMatrix(const double& fA, const double& fB, const double& fC, const double fD, double fE, double fF);
|
||||
|
||||
TFontCacheSizes CacheGlyph(const int& code, const bool& isRaster, CVectorWorker* pWorker = NULL, const bool& isFromPicker = false);
|
||||
|
||||
INT GetString(CGlyphString& oString);
|
||||
INT GetString2(CGlyphString& oString);
|
||||
INT GetString2C(CGlyphString& oString);
|
||||
|
||||
@ -500,7 +500,7 @@ INT CFontManager::GetNextChar2(TGlyph*& pGlyph, float& fX, float& fY)
|
||||
if (!m_oString.GetNext(pGlyph))
|
||||
return FALSE;
|
||||
|
||||
if (glyphstateNormal == pGlyph->eState || (glyphstateDeafault == pGlyph->eState && NULL != m_pFont->m_pDefaultFont))
|
||||
if (glyphstateNormal == pGlyph->eState || (glyphstateDefault == pGlyph->eState && NULL != m_pFont->m_pDefaultFont))
|
||||
{
|
||||
fX = m_oString.m_fX + pGlyph->fX + pGlyph->oBitmap.nX;
|
||||
fY = m_oString.m_fY + pGlyph->fY - pGlyph->oBitmap.nY;
|
||||
@ -585,15 +585,15 @@ INT CFontManager::GetStringPath(NSFonts::ISimpleGraphicsPath* pInterface)
|
||||
{
|
||||
TGlyph* pCurGlyph = m_oString.GetAt(nIndex);
|
||||
CFontPath* pPath = NULL;
|
||||
if (glyphstateNormal == pCurGlyph->eState || (glyphstateDeafault == pCurGlyph->eState && NULL != m_pFont->m_pDefaultFont))
|
||||
if (glyphstateNormal == pCurGlyph->eState || (glyphstateDefault == pCurGlyph->eState && NULL != m_pFont->m_pDefaultFont))
|
||||
{
|
||||
if (glyphstateNormal == pCurGlyph->eState)
|
||||
{
|
||||
pPath = (CFontPath*)m_pFont->GetGlyphPath(pCurGlyph->lUnicode);
|
||||
pPath = (CFontPath*)m_pFont->GetGlyphPath(pCurGlyph->lUnicode);
|
||||
}
|
||||
else
|
||||
{
|
||||
pPath = (CFontPath*)m_pFont->m_pDefaultFont->GetGlyphPath(pCurGlyph->lUnicode);
|
||||
pPath = (CFontPath*)m_pFont->m_pDefaultFont->GetGlyphPath(pCurGlyph->lUnicode);
|
||||
}
|
||||
}
|
||||
|
||||
@ -778,3 +778,37 @@ void CFontManager::GetFace(double& d0, double& d1, double& d2)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CFontFile* CFontManager::GetFontFileBySymbol(CFontFile* pFile, int code)
|
||||
{
|
||||
std::wstring sName = m_pApplication->GetFontBySymbol(code);
|
||||
if (sName.empty())
|
||||
return NULL;
|
||||
|
||||
CFontFile* pFontOld = m_pFont;
|
||||
m_pFont = NULL;
|
||||
std::wstring sOldName = m_sName;
|
||||
|
||||
int nStyle = 0;
|
||||
if (pFile->m_bNeedDoBold || pFile->IsBold())
|
||||
nStyle |= 1;
|
||||
if (pFile->m_bNeedDoItalic || pFile->IsItalic())
|
||||
nStyle |= 2;
|
||||
|
||||
LoadFontByName(sName, pFile->m_dSize, nStyle, pFile->m_unHorDpi, pFile->m_unVerDpi);
|
||||
|
||||
if (!m_pFont)
|
||||
{
|
||||
m_pFont = pFontOld;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CFontFile* pFontNew = m_pFont;
|
||||
m_pFont = pFontOld;
|
||||
m_sName = sOldName;
|
||||
|
||||
memcpy(pFontNew->m_arrdTextMatrix, pFile->m_arrdTextMatrix, 6 * sizeof(double));
|
||||
pFontNew->UpdateMatrix2();
|
||||
|
||||
return pFontNew;
|
||||
}
|
||||
|
||||
@ -208,6 +208,8 @@ public:
|
||||
virtual void SetSubpixelRendering(const bool& hmul, const bool& vmul);
|
||||
|
||||
virtual void GetFace(double& d0, double& d1, double& d2);
|
||||
|
||||
CFontFile* GetFontFileBySymbol(CFontFile* pFile, int code);
|
||||
};
|
||||
|
||||
#endif // _BUILD_FONT_ENGINE_FONTMANAGER_H_
|
||||
|
||||
@ -61,7 +61,7 @@ public:
|
||||
enum EGlyphState
|
||||
{
|
||||
glyphstateNormal = 0, // символ отрисовался в нужном шрифте
|
||||
glyphstateDeafault, // символ отрисовался в дефолтовом шрифте
|
||||
glyphstateDefault, // символ отрисовался в дефолтовом шрифте
|
||||
glyphstateMiss // символ не отрисовался
|
||||
};
|
||||
|
||||
|
||||
@ -40,6 +40,7 @@
|
||||
#include "../common/Directory.h"
|
||||
#include "../common/Array.h"
|
||||
#include "../common/StringBuilder.h"
|
||||
#include "../common/ByteBuilder.h"
|
||||
|
||||
#ifndef ASC_APPLICATION_FONTS_NO_THUMBNAILS
|
||||
#include "../graphics/pro/Graphics.h"
|
||||
@ -632,6 +633,14 @@ namespace NSCommon
|
||||
RELEASEOBJECT(pManager);
|
||||
}
|
||||
#endif
|
||||
|
||||
NSMemoryUtils::CByteBuilder* pRangeBuilder = NULL;
|
||||
int nRangeBuilderCount = 0;
|
||||
if (0 != strFontSelectionBin.length())
|
||||
{
|
||||
pRangeBuilder = new NSMemoryUtils::CByteBuilder();
|
||||
pRangeBuilder->WriteInt(0);
|
||||
}
|
||||
|
||||
// и самое главное. Здесь должен скидываться скрипт для работы со всеми шрифтами.
|
||||
// все объекты, которые позволят не знать о существующих фонтах
|
||||
@ -939,12 +948,20 @@ namespace NSCommon
|
||||
|
||||
if (nFontPriority != 0)
|
||||
{
|
||||
++nRangeBuilderCount;
|
||||
oWriterJS.AddInt(nFontPriorityStart);
|
||||
oWriterJS.AddCharSafe(',');
|
||||
oWriterJS.AddInt(i - 1);
|
||||
oWriterJS.AddCharSafe(',');
|
||||
oWriterJS.AddInt(mapFontIndexes.find(arrFontsPriority[nFontPriority - 1].name)->second);
|
||||
oWriterJS.AddCharSafe(',');
|
||||
|
||||
if (pRangeBuilder)
|
||||
{
|
||||
pRangeBuilder->WriteStringUTF8(arrFontsPriority[nFontPriority - 1].name);
|
||||
pRangeBuilder->WriteInt(nFontPriorityStart);
|
||||
pRangeBuilder->WriteInt(i - 1);
|
||||
}
|
||||
}
|
||||
nFontPriority = nFontPriorityTest;
|
||||
nFontPriorityStart = i;
|
||||
@ -952,12 +969,20 @@ namespace NSCommon
|
||||
|
||||
if (nFontPriority != 0)
|
||||
{
|
||||
++nRangeBuilderCount;
|
||||
oWriterJS.AddInt(nFontPriorityStart);
|
||||
oWriterJS.AddCharSafe(',');
|
||||
oWriterJS.AddInt(nMaxSymbol - 1);
|
||||
oWriterJS.AddCharSafe(',');
|
||||
oWriterJS.AddInt(mapFontIndexes.find(arrFontsPriority[nFontPriority - 1].name)->second);
|
||||
oWriterJS.AddCharSafe(',');
|
||||
|
||||
if (pRangeBuilder)
|
||||
{
|
||||
pRangeBuilder->WriteStringUTF8(arrFontsPriority[nFontPriority - 1].name);
|
||||
pRangeBuilder->WriteInt(nFontPriorityStart);
|
||||
pRangeBuilder->WriteInt(nMaxSymbol - 1);
|
||||
}
|
||||
}
|
||||
|
||||
oWriterJS.SetCurSize(oWriterJS.GetCurSize() - 1);
|
||||
@ -1002,10 +1027,22 @@ namespace NSCommon
|
||||
NSFile::CFileBinary oFile;
|
||||
oFile.CreateFileW(strFontSelectionBin);
|
||||
oFile.WriteFile(pData, (DWORD)lLen);
|
||||
|
||||
if (pRangeBuilder)
|
||||
{
|
||||
size_t nPosCur = pRangeBuilder->GetCurSize();
|
||||
pRangeBuilder->SetCurSize(0);
|
||||
pRangeBuilder->WriteInt(nRangeBuilderCount);
|
||||
pRangeBuilder->SetCurSize(nPosCur);
|
||||
oFile.WriteFile(pRangeBuilder->GetData(), (DWORD)pRangeBuilder->GetCurSize());
|
||||
}
|
||||
|
||||
oFile.CloseFile();
|
||||
|
||||
RELEASEARRAYOBJECTS(pData);
|
||||
}
|
||||
|
||||
RELEASEOBJECT(pRangeBuilder);
|
||||
}
|
||||
|
||||
#ifdef _GENERATE_FONT_MAP_
|
||||
|
||||
@ -101,6 +101,28 @@ namespace NSCommon
|
||||
pStr[i] = pStr[i] + 'A' - 'a';
|
||||
}
|
||||
}
|
||||
static void makeLower(std::string& url)
|
||||
{
|
||||
int nLen = (int)url.length();
|
||||
char* pStr = (char*)url.c_str();
|
||||
|
||||
for (int i = 0; i < nLen; ++i)
|
||||
{
|
||||
if (pStr[i] >= 'A' && pStr[i] <= 'Z')
|
||||
pStr[i] = pStr[i] + 'a' - 'A';
|
||||
}
|
||||
}
|
||||
static void makeLowerW(std::wstring& url)
|
||||
{
|
||||
int nLen = (int)url.length();
|
||||
wchar_t* pStr = (wchar_t*)url.c_str();
|
||||
|
||||
for (int i = 0; i < nLen; ++i)
|
||||
{
|
||||
if (pStr[i] >= 'A' && pStr[i] <= 'Z')
|
||||
pStr[i] = pStr[i] + 'a' - 'A';
|
||||
}
|
||||
}
|
||||
|
||||
static void WriteLog(const std::string& sLogFile, const std::wstring& sData)
|
||||
{
|
||||
|
||||
@ -107,12 +107,18 @@ public:
|
||||
m_lMaxCount = 10;
|
||||
|
||||
m_oCS.InitializeCriticalSection();
|
||||
|
||||
if (m_pApplicationFonts)
|
||||
m_pApplicationFonts->AddRef();
|
||||
}
|
||||
|
||||
virtual ~CImageFilesCache()
|
||||
{
|
||||
Clear();
|
||||
m_oCS.DeleteCriticalSection();
|
||||
|
||||
if (m_pApplicationFonts)
|
||||
m_pApplicationFonts->Release();
|
||||
}
|
||||
|
||||
virtual void Clear()
|
||||
@ -179,9 +185,13 @@ public:
|
||||
return m_lRef;
|
||||
}
|
||||
|
||||
virtual void SetApplicationFonts(CApplicationFonts* pApplicationFonts)
|
||||
virtual void SetApplicationFonts(NSFonts::IApplicationFonts* pApplicationFonts)
|
||||
{
|
||||
m_pApplicationFonts = pApplicationFonts;
|
||||
if (m_pApplicationFonts)
|
||||
m_pApplicationFonts->Release();
|
||||
m_pApplicationFonts = (CApplicationFonts*)pApplicationFonts;
|
||||
if (m_pApplicationFonts)
|
||||
m_pApplicationFonts->AddRef();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -63,7 +63,7 @@ namespace NSImages
|
||||
|
||||
virtual ICacheImage* Lock(const std::wstring& strFile) = 0;
|
||||
|
||||
void SetApplicationFonts(NSFonts::IApplicationFonts* pApplicationFonts);
|
||||
virtual void SetApplicationFonts(NSFonts::IApplicationFonts* pApplicationFonts) = 0;
|
||||
};
|
||||
|
||||
namespace NSFilesCache
|
||||
|
||||
Reference in New Issue
Block a user