Commit 08be49c9 authored by Elen.Subbotina's avatar Elen.Subbotina Committed by Alexander Trofimov

OdfFile Reader & Writer - фиксы ошибок по результатам тестирования переносимости контента

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@63252 954022d7-b5bf-4e40-9824-e11837661b57
parent d21df344
......@@ -75,20 +75,26 @@ std::wstring styles_map::name(const std::wstring & Name, odf_types::style_family
{
return Name + L":" + boost::lexical_cast<std::wstring>(odf_types::style_family(Type));
}
void docx_conversion_context::add_element_to_run()
void docx_conversion_context::add_element_to_run(std::wstring parenStyleId)
{
if (!current_run_)
{
current_run_ = true;
output_stream() << L"<w:r>";
if (!text_properties_stack_.empty())
if (!text_properties_stack_.empty() || parenStyleId.length() > 0)
{
odf_reader::style_text_properties_ptr textProp = this->current_text_properties();
get_styles_context().start();
textProp->content().docx_convert(*this);
if (!text_properties_stack_.empty())
{
odf_reader::style_text_properties_ptr textProp = this->current_text_properties();
get_styles_context().start();
if(( textProp) && (textProp->content().r_style_))parenStyleId = _T("");
textProp->content().docx_convert(*this);
}
get_styles_context().docx_serialize_text_style( output_stream());
get_styles_context().docx_serialize_text_style( output_stream(), parenStyleId);
}
}
......@@ -153,7 +159,7 @@ oox_chart_context & docx_conversion_context::current_chart()
throw std::runtime_error("internal error");
}
}
void docx_conversion_context::add_new_run()
void docx_conversion_context::add_new_run(std::wstring parentStyleId)
{
finish_run();
if (get_comments_context().state()==1)
......@@ -161,7 +167,7 @@ void docx_conversion_context::add_new_run()
output_stream() << L"<w:commentRangeStart w:id=\"" << get_comments_context().current_id() << L"\" />";
get_comments_context().state(2);//active
}
add_element_to_run();
add_element_to_run(parentStyleId);
}
std::wstring docx_conversion_context::add_hyperlink(const std::wstring & href, bool draw)
......@@ -585,7 +591,7 @@ void docx_conversion_context::end_process_style_content()
docx_serialize_paragraph_style(output_stream(), automatic_parent_style_);
if (automatic_parent_style_.empty())
styles_context_.docx_serialize_text_style( output_stream());
styles_context_.docx_serialize_text_style( output_stream(), _T(""));
}
void docx_conversion_context::docx_serialize_paragraph_style(std::wostream & strm, const std::wstring & ParentId)
......@@ -955,7 +961,7 @@ void docx_conversion_context::add_note_reference()
{
if (process_note_ == footNote || process_note_ == endNote)
{
add_element_to_run();
add_element_to_run(_T(""));
output_stream() << ((process_note_ == footNote) ? L"<w:footnoteRef />" : L"<w:endnoteRef />");
finish_run();
process_note_ = (NoteType) (process_note_ + 1); //add ref set
......
......@@ -375,9 +375,9 @@ public:
return temp_stream_;
}
void add_element_to_run();
void add_element_to_run(std::wstring parenStyleId = _T(""));
void finish_run();
void add_new_run();
void add_new_run(std::wstring parentStyleId = _T(""));
bool get_run_state() { return current_run_; }
void set_run_state(bool Val) { current_run_ = Val; }
......
......@@ -216,8 +216,9 @@ void docx_serialize_text(std::wostream & strm, const std::vector<odf_reader::_pr
}
}
}
else
CP_XML_NODE(L"wps:bodyPr");
}
}
void docx_serialize_image(std::wostream & strm, _docx_drawing & val)
......
......@@ -67,7 +67,7 @@ std::wstringstream & styles_context::list_style()
return list_style_;
}
void styles_context::docx_serialize_text_style(std::wostream & strm)
void styles_context::docx_serialize_text_style(std::wostream & strm, std::wstring parenStyleId)
{
if (!text_style_.str().empty())
{
......@@ -75,6 +75,10 @@ void styles_context::docx_serialize_text_style(std::wostream & strm)
{
CP_XML_NODE(L"w:rPr")
{
if (parenStyleId.length() > 0)
{
CP_XML_STREAM() << L"<w:rStyle w:val=\"" << parenStyleId << L"\" />";
}
CP_XML_STREAM() << text_style_.str();
}
}
......
......@@ -24,7 +24,7 @@ public:
std::wstringstream & table_style();
std::wstringstream & list_style();
void docx_serialize_text_style(std::wostream & strm);
void docx_serialize_text_style(std::wostream & strm, std::wstring parenStyleId);
void docx_serialize_table_style(std::wostream & strm);
void pptx_serialize_table_style(std::wostream & strm);
......
......@@ -133,18 +133,15 @@ void oox_serialize_aLst(std::wostream & strm, const std::vector<odf_reader::_pro
odf_reader::GetProperty(prop, L"wordArt" , bWordArt);
odf_reader::GetProperty(prop, L"odf-custom-draw-index" , iShapeIndex);
if (!iShapeIndex)return;
int i = *iShapeIndex;
int count_values = 0, min_value = 0, max_value = 0;
if (!bWordArt)
if (!bWordArt && iShapeIndex)
{
count_values = _OO_OOX_custom_shapes[*iShapeIndex].count_values;
min_value = _OO_OOX_custom_shapes[*iShapeIndex].min;
max_value = _OO_OOX_custom_shapes[*iShapeIndex].max;
}
else
else if (iShapeIndex)
{
count_values = _OO_OOX_wordart[*iShapeIndex].count_values;
min_value = _OO_OOX_wordart[*iShapeIndex].min;
......@@ -156,7 +153,7 @@ void oox_serialize_aLst(std::wostream & strm, const std::vector<odf_reader::_pro
CP_XML_NODE(L"a:avLst")
{
_CP_OPT(std::wstring) strVal;
if (odf_reader::GetProperty(prop,L"draw-modifiers",strVal))
if (odf_reader::GetProperty(prop,L"draw-modifiers",strVal) && iShapeIndex)
{
std::vector< std::wstring > values;
boost::algorithm::split(values, strVal.get(), boost::algorithm::is_any_of(L" "), boost::algorithm::token_compress_on);
......
......@@ -546,7 +546,22 @@ void pptx_slide_context::add_rels( bool isInternal, std::wstring const & rid, st
{
impl_->add_additional_rels(isInternal, rid, ref, type);
}
void pptx_slide_context::set_footer()
{
impl_->footer = true;
}
void pptx_slide_context::set_header()
{
impl_->header = true;
}
void pptx_slide_context::set_page_number()
{
impl_->date_time = true;
}
void pptx_slide_context::set_date_time()
{
impl_->slideNum = true;
}
void pptx_slide_context::serialize_background(std::wostream & strm, bool always)
{
if (!always && ( (!impl_->background_fill_) || (impl_->background_fill_->type==0))) return;
......@@ -624,10 +639,10 @@ void pptx_slide_context::serialize_HeaderFooter(std::wostream & strm)
{
CP_XML_NODE(L"p:hf")
{
if(impl_->footer) CP_XML_ATTR(L"ftr",0);
if(impl_->header) CP_XML_ATTR(L"hdr",0);
if(impl_->date_time) CP_XML_ATTR(L"dt",0);
if(impl_->slideNum) CP_XML_ATTR(L"sldNum",0);
if(impl_->footer) CP_XML_ATTR(L"ftr",1);
if(impl_->header) CP_XML_ATTR(L"hdr",1);
if(impl_->date_time) CP_XML_ATTR(L"dt",1);
if(impl_->slideNum) CP_XML_ATTR(L"sldNum",1);
}
}
}
......
......@@ -82,6 +82,11 @@ public:
std::wstring const & ref,
mediaitems::Type type);
void set_footer();
void set_header();
void set_page_number();
void set_date_time();
private:
void process_common_properties(drawing_object_description& pic,_pptx_drawing & drawing);
void default_set();
......
......@@ -6,66 +6,15 @@ namespace cpdoccore { namespace odf_types {
std::wostream & operator << (std::wostream & _Wostream, const border_style & borderStyle)
{
std::wstring w_sz;
std::wstring w_color;
std::wstring w_val = L"single";
std::wstring w_space;
if (!borderStyle.initialized() || borderStyle.is_none())
{
w_val = L"none";
}
else if (borderStyle.initialized())
{
double width = borderStyle.get_length().get_value_unit(length::pt);
//borderLineWidths ? borderLineWidths->get_summ_unit(length::pt) : borderStyle.get_length().get_value_unit(length::pt);
int szInt = (int)(0.5 + 8.0 * width);
if (szInt <= 0)
szInt = 1;
w_sz = boost::lexical_cast<std::wstring>( szInt );
w_color = boost::lexical_cast<std::wstring>( borderStyle.get_color().get_hex_value() );
const std::wstring borderStyleStr = borderStyle.get_style();
if (szInt == 0)
w_val = L"none";
else if (borderStyleStr == L"solid"
|| borderStyleStr == L"single")
w_val = L"single";
else if (borderStyleStr == L"double")
w_val = L"double";
else if (borderStyleStr == L"dotted")
w_val = borderStyleStr;
else if (borderStyleStr == L"dashed")
w_val = borderStyleStr;
else if (borderStyleStr == L"groove")
w_val = L"thinThickMediumGap";
else if (borderStyleStr == L"ridge")
w_val = L"thickThinMediumGap";
else if (borderStyleStr == L"inset")
w_val = L"inset";
else if (borderStyleStr == L"outset")
w_val = L"outset";
else if (borderStyleStr == L"hidden")
w_val = L"nil";
}
std::wstring res;
if (!w_val.empty())
res += L" w:val=\"" + w_val + L"\" ";
if (!w_sz.empty())
res += L"w:sz=\"" + w_sz + L"\" ";
if (!w_color.empty())
res += L"w:color=\"" + w_color + L"\" ";
if (!w_space.empty())
res += L"w:space=\"" + w_space + L"\" ";
_Wostream << res;
_Wostream << borderStyle.set_border_style_;
return _Wostream;
}
border_style::border_style(const std::wstring & Value) : initialized_(false), none_(false)
{
set_border_style_ = Value;
std::wstring tmp = boost::algorithm::trim_copy(Value);
boost::algorithm::to_lower(tmp);
......@@ -94,6 +43,7 @@ border_style::border_style(const std::wstring & Value) : initialized_(false), no
{
}
}
initialized_ = true;
}
......@@ -102,5 +52,23 @@ border_style border_style::parse( const std::wstring & Value)
return border_style(Value);
}
border_style::border_style(const color & color_, const std::wstring & style_, const length & length_)
{
this->color_ = color_;
this->style_ = style_;
this->length_ = length_;
std::wstringstream s;
s << length_;
s << std::wstring(L" ");
s << style_;
s << std::wstring(L" ");
s << color_;
set_border_style_ = s.str();
}
}
}
......@@ -11,6 +11,7 @@ class border_style
public:
border_style(){}
border_style(const std::wstring & Value);
border_style(const color & color_, const std::wstring & style_, const length & length_);
static border_style parse(const std::wstring & Str);
public:
......@@ -20,8 +21,9 @@ public:
const color & get_color() const { return color_; }
bool is_none() const { return none_; }
std::wstring set_border_style_;
private:
bool none_;
bool none_;
bool initialized_;
length length_;
std::wstring style_;
......
......@@ -72,6 +72,9 @@ void common_draw_fill_attlist::add_attributes( const xml::attributes_wc_ptr & At
CP_APPLY_ATTR(L"draw:fill-hatch-solid", draw_fill_hatch_solid_);
CP_APPLY_ATTR(L"style:repeat", style_repeat_);
CP_APPLY_ATTR(L"draw:fill-image-width", draw_fill_image_width_);
CP_APPLY_ATTR(L"draw:fill-image-height", draw_fill_image_height_);
}
void common_draw_fill_attlist::serialize(CP_ATTR_NODE)
{
......@@ -92,6 +95,7 @@ void common_draw_fill_attlist::serialize(CP_ATTR_NODE)
CP_XML_ATTR_OPT(L"draw:fill-image-ref-point", draw_fill_image_ref_point_);
CP_XML_ATTR_OPT(L"draw:fill-image-ref-point-y", draw_fill_image_ref_point_y_);
CP_XML_ATTR_OPT(L"draw:fill-image-ref-point-x", draw_fill_image_ref_point_x_);
CP_XML_ATTR_OPT(L"draw:fill-image-width", draw_fill_image_width_);
CP_XML_ATTR_OPT(L"draw:fill-image-height", draw_fill_image_height_);
......@@ -112,6 +116,9 @@ void common_draw_fill_attlist::apply_from(const common_draw_fill_attlist & Other
_CP_APPLY_PROP2(style_repeat_);
_CP_APPLY_PROP2(draw_fill_color_);
_CP_APPLY_PROP2(draw_fill_image_width_);
_CP_APPLY_PROP2(draw_fill_image_height_);
}
void common_horizontal_margin_attlist::add_attributes( const xml::attributes_wc_ptr & Attributes )
......
......@@ -72,8 +72,8 @@ public:
_CP_OPT(percent) draw_fill_image_ref_point_y_;
_CP_OPT(percent) draw_fill_image_ref_point_x_;
_CP_OPT(length) draw_fill_image_width_;
_CP_OPT(length) draw_fill_image_height_;
_CP_OPT(length_or_percent) draw_fill_image_width_;
_CP_OPT(length_or_percent) draw_fill_image_height_;
};
// common-horizontal-margin-attlist
......
......@@ -391,7 +391,24 @@ void Compute_GraphicFill(const common_draw_fill_attlist & props, styles_lite_con
break;
}
}else
fill.bitmap->bTile = true;
{
fill.bitmap->bTile = true;// ????
if (props.draw_fill_image_width_ && props.draw_fill_image_height_)
{
if (props.draw_fill_image_width_->get_type() == odf_types::length_or_percent::Percent &&
props.draw_fill_image_height_->get_type() == odf_types::length_or_percent::Percent)
{
if (props.draw_fill_image_width_->get_percent().get_value() > 99.9 &&
props.draw_fill_image_height_->get_percent().get_value() > 99.9 &&
props.draw_fill_image_width_->get_percent().get_value() < 100.1 &&
props.draw_fill_image_height_->get_percent().get_value() < 100.1 )
{
fill.bitmap->bStretch = true;
fill.bitmap->bTile = false;
}
}
}
}
}
if (props.draw_fill_gradient_name_)
{
......
......@@ -916,7 +916,10 @@ void draw_shape::docx_convert(oox::docx_conversion_context & Context)
drawing.sub_type = sub_type_;
drawing.additional = additional_;// ...
drawing.additional.push_back(_property(L"text-content",Context.get_drawing_context().get_text_stream_shape()));
if (drawing.sub_type !=5 )//line
{
drawing.additional.push_back(_property(L"text-content",Context.get_drawing_context().get_text_stream_shape()));
}
Context.get_drawing_context().clear_stream_shape();
/////////
......@@ -941,7 +944,7 @@ void draw_shape::docx_convert(oox::docx_conversion_context & Context)
new_run = false;
}
else
Context.add_new_run();
Context.add_new_run(_T(""));
docx_serialize(strm, drawing);
......@@ -1048,7 +1051,7 @@ void draw_image::docx_convert(oox::docx_conversion_context & Context)
pState = Context.get_paragraph_state();
Context.set_paragraph_state(false);
Context.add_new_run();
Context.add_new_run(_T(""));
docx_serialize(strm,drawing);
Context.finish_run();
......@@ -1133,7 +1136,7 @@ void draw_text_box::docx_convert(oox::docx_conversion_context & Context)
pState = Context.get_paragraph_state();
Context.set_paragraph_state(false);
Context.add_new_run();
Context.add_new_run(_T(""));
docx_serialize(strm, drawing);
Context.finish_run();
......@@ -1227,7 +1230,7 @@ void draw_object::docx_convert(oox::docx_conversion_context & Context)
std::wostream & strm = Context.output_stream();
Context.add_new_run();
Context.add_new_run(_T(""));
docx_serialize(strm, drawing);
......
......@@ -136,6 +136,19 @@ void draw_page::pptx_convert(oox::pptx_conversion_context & Context)
{
Context.get_slide_context().set_transitionSpeed(properties->content().presentation_transition_speed_.get());
}
////////////////////////////////////////////////
if ((properties->content().presentation_display_footer_) && (*properties->content().presentation_display_footer_))
Context.get_slide_context().set_footer();
if ((properties->content().presentation_display_header_) && (*properties->content().presentation_display_header_))
Context.get_slide_context().set_header();
if ((properties->content().presentation_display_page_number_) && (*properties->content().presentation_display_page_number_))
Context.get_slide_context().set_page_number();
if ((properties->content().presentation_display_date_time_) && (*properties->content().presentation_display_date_time_))
Context.get_slide_context().set_date_time();
}
}
}
......
......@@ -282,6 +282,64 @@ void draw_polygon::reset_polygon_path()
}
}
}
///////////////////////////////////////
void draw_polyline_attlist::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"draw:points", draw_points_);
CP_APPLY_ATTR(L"svg:viewBox", svg_viewbox_);
}
// draw:polyline
const wchar_t * draw_polyline::ns = L"draw";
const wchar_t * draw_polyline::name = L"polyline";
void draw_polyline::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
draw_polyline_attlist_.add_attributes(Attributes);
draw_shape::add_attributes(Attributes);
sub_type_ = 8;
}
void draw_polyline::reset_polyline_path()
{
if (draw_polyline_attlist_.draw_points_)
{
std::vector<svg_path::_polyline> o_Polyline_pt;
std::vector<svg_path::_polyline> o_Polyline_cm;
bool res = svg_path::parsePolygon(o_Polyline_cm, draw_polyline_attlist_.draw_points_.get(), false);
_CP_OPT(double) start_x, start_y;
BOOST_FOREACH(svg_path::_polyline & poly, o_Polyline_cm)
{
for (long i=0;i<poly.points.size();i++)
{
if (poly.points[i].x)
{
if (!start_x)// .. ""
start_x = length(poly.points[i].x.get()/1000.,length::cm).get_value_unit(length::emu);
poly.points[i].x = length(poly.points[i].x.get()/1000.,length::cm).get_value_unit(length::emu) - *start_x;
}
if (poly.points[i].y)
{
if (!start_y)
start_y = length(poly.points[i].y.get()/1000.,length::cm).get_value_unit(length::emu);
poly.points[i].y = length(poly.points[i].y.get()/1000.,length::cm).get_value_unit(length::emu) - *start_y;
}
}
o_Polyline_pt.push_back(poly);
}
if (o_Polyline_pt.size()>0)
{
// xml-oox ... drawing .. ..
std::wstringstream output_;
svg_path::oox_serialize(output_, o_Polyline_pt);
additional_.push_back(odf_reader::_property(L"custom_path",output_.str()));
}
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
void draw_equation_attlist::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
......
......@@ -251,6 +251,38 @@ public:
CP_REGISTER_OFFICE_ELEMENT2(draw_polygon);
//////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////
class draw_polyline_attlist
{
public:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
_CP_OPT(std::wstring) draw_points_;
_CP_OPT(std::wstring) svg_viewbox_;
};
/////////////////////////////////////////////////////////////////////////
class draw_polyline : public draw_shape
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const ElementType type = typeDrawPolyline;
static const xml::NodeType xml_type = xml::typeElement;
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void xlsx_convert(oox::xlsx_conversion_context & Context);
virtual void docx_convert(oox::docx_conversion_context & Context);
virtual void pptx_convert(oox::pptx_conversion_context & Context);
draw_polyline_attlist draw_polyline_attlist_;
void reset_polyline_path();// svg -
};
CP_REGISTER_OFFICE_ELEMENT2(draw_polyline);
/////////////////////////////////////////////////////////////////////////////////////////////////////
class draw_custom_shape_attlist
{
public:
......
......@@ -146,6 +146,15 @@ void draw_polygon::docx_convert(oox::docx_conversion_context & Context)
reset_polygon_path();
draw_shape::docx_convert(Context);
}
void draw_polyline::docx_convert(oox::docx_conversion_context & Context)
{
if (Context.get_drawing_context().get_current_level() >0 )return;
common_docx_convert(Context);
//...
reset_polyline_path();
draw_shape::docx_convert(Context);
}
void draw_custom_shape::docx_convert(oox::docx_conversion_context & Context)
{
if (Context.get_drawing_context().get_current_level() >0 )return;
......
......@@ -186,6 +186,16 @@ void draw_polygon::pptx_convert(oox::pptx_conversion_context & Context)
Context.get_slide_context().end_shape();
}
void draw_polyline::pptx_convert(oox::pptx_conversion_context & Context)
{
reset_polyline_path();
///////////////////////////////////////////////////////////////////////
Context.get_slide_context().start_shape(sub_type_);
common_pptx_convert(Context);
Context.get_slide_context().end_shape();
}
void draw_custom_shape::pptx_convert(oox::pptx_conversion_context & Context)
{
Context.get_slide_context().start_shape(sub_type_);
......
......@@ -186,6 +186,16 @@ void draw_polygon::xlsx_convert(oox::xlsx_conversion_context & Context)
Context.get_drawing_context().end_shape();
}
void draw_polyline::xlsx_convert(oox::xlsx_conversion_context & Context)
{
reset_polyline_path();
///////////////////////////////////////////////////////////////////////
Context.get_drawing_context().start_shape(8);
common_xlsx_convert(Context);
Context.get_drawing_context().end_shape();
}
void draw_custom_shape::xlsx_convert(oox::xlsx_conversion_context & Context)
{
Context.get_drawing_context().start_shape(7);
......
......@@ -348,12 +348,8 @@ void span::docx_convert(oox::docx_conversion_context & Context)
else
{
const std::wstring id = Context.get_style_map().get( styleInst->name(), styleInst->type() );
Context.add_new_run();
Context.add_new_run(id);
addNewRun = true;
_Wostream << L"<w:rPr>";
_Wostream << L"<w:rStyle w:val=\"" << id << L"\" />";
_Wostream << L"</w:rPr>";
}
}
......@@ -578,12 +574,8 @@ void note::docx_convert(oox::docx_conversion_context & Context)
)
{
const std::wstring id = Context.get_style_map().get( styleInst->name(), styleInst->type() );
Context.add_new_run();
Context.add_new_run(id);
addNewRun = true;
_Wostream << L"<w:rPr>";
_Wostream << L"<w:rStyle w:val=\"" << id << L"\" />";
_Wostream << L"</w:rPr>";
}
}
......
......@@ -84,6 +84,10 @@ void drawing_page_properties::add_attributes( const xml::attributes_wc_ptr & Att
CP_APPLY_ATTR(L"presentation:transition-style", presentation_transition_style_);
CP_APPLY_ATTR(L"presentation:transition-speed", presentation_transition_speed_);
CP_APPLY_ATTR(L"presentation:display-footer", presentation_display_footer_);
CP_APPLY_ATTR(L"presentation:display-page-number", presentation_display_page_number_);
CP_APPLY_ATTR(L"presentation:display-date-time", presentation_display_date_time_);
CP_APPLY_ATTR(L"presentation:display-header", presentation_display_header_);
}
void drawing_page_properties::apply_from(const drawing_page_properties & Other)
{
......@@ -93,6 +97,16 @@ void drawing_page_properties::apply_from(const drawing_page_properties & Other)
_CP_APPLY_PROP2(draw_fill_image_width_);
_CP_APPLY_PROP2(draw_background_size_);
_CP_APPLY_PROP2(presentation_transition_type_);
_CP_APPLY_PROP2(presentation_transition_style_);
_CP_APPLY_PROP2(presentation_transition_speed_);
_CP_APPLY_PROP2(presentation_display_footer_);
_CP_APPLY_PROP2(presentation_display_page_number_);
_CP_APPLY_PROP2(presentation_display_date_time_);
_CP_APPLY_PROP2(presentation_display_header_);
}
}
}
......@@ -54,21 +54,21 @@ public:
void apply_from(const drawing_page_properties & Other);
odf_types::common_draw_fill_attlist common_draw_fill_attlist_;
anim_transition_filter_attlist anim_transition_filter_attlist_;
anim_transition_filter_attlist anim_transition_filter_attlist_;
_CP_OPT(odf_types::length) draw_fill_image_height_;
_CP_OPT(odf_types::length) draw_fill_image_width_;
_CP_OPT(odf_types::length_or_percent) draw_fill_image_height_;
_CP_OPT(odf_types::length_or_percent) draw_fill_image_width_;
_CP_OPT(std::wstring) draw_background_size_;//"border" or "full"
_CP_OPT(std::wstring) draw_background_size_;//"border" or "full"
_CP_OPT(std::wstring)presentation_transition_type_;//manual, automatic, semi-automatic ( )
_CP_OPT(std::wstring)presentation_transition_style_;//none, fade, move, uncover,clockwise, .... smil
_CP_OPT(std::wstring)presentation_transition_speed_;//slow, medium, fast
_CP_OPT(std::wstring) presentation_transition_type_;//manual, automatic, semi-automatic ( )
_CP_OPT(std::wstring) presentation_transition_style_;//none, fade, move, uncover,clockwise, .... smil
_CP_OPT(std::wstring) presentation_transition_speed_;//slow, medium, fast
//presentation:display-footer
//presentation:display-page-number
//presentation:display-date-time
//presentation:display-header
_CP_OPT(bool) presentation_display_footer_;
_CP_OPT(bool) presentation_display_page_number_;
_CP_OPT(bool) presentation_display_date_time_;
_CP_OPT(bool) presentation_display_header_;
//presentation:background-objects-visible
//presentation:background-visible
......
......@@ -267,12 +267,12 @@ int text_format_properties_content::process_font_weight(const optional<font_weig
{
if (FontWeight)
{
if (FontWeight->get_type() == font_weight::WBold) // TODO ???
return 1;
else
if (FontWeight->get_type() == font_weight::WNormal)
return -1;
else
return +1; //bold
}
return 0;
return 0; //not set
}
int text_format_properties_content::process_font_style(const optional<font_style>::Type & FontStyle)
......
......@@ -1438,8 +1438,10 @@ const wchar_t * hdrHeader = L"<w:hdr \
xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" \
xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" \
xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" \
xmlns:a14=\"http://schemas.microsoft.com/office/drawing/2010/main\" >";
//xmlns:v=\"urn:schemas-microsoft-com:vml\"
xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" \
xmlns:v=\"urn:schemas-microsoft-com:vml\" \
mc:Ignorable=\"w14 wp14\">";
const wchar_t * ftrHeader = L"<w:ftr \
xmlns:o=\"urn:schemas-microsoft-com:office:office\" \
xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" \
......@@ -1455,10 +1457,9 @@ const wchar_t * ftrHeader = L"<w:ftr \
xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" \
xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" \
xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" \
xmlns:a14=\"http://schemas.microsoft.com/office/drawing/2010/main\" >";
//mc:Ignorable=\"w14 wp14\"
//xmlns:v=\"urn:schemas-microsoft-com:vml\"
xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" \
xmlns:v=\"urn:schemas-microsoft-com:vml\" \
mc:Ignorable=\"w14 wp14\">";
void style_header::docx_convert(oox::docx_conversion_context & Context)
{
......
......@@ -379,7 +379,7 @@ void text_list_level_style_number::docx_convert(oox::docx_conversion_context & C
{
Context.get_styles_context().start();
textProperties->content().docx_convert(Context);//to style_context
Context.get_styles_context().docx_serialize_text_style( CP_XML_STREAM());//serialize style_context
Context.get_styles_context().docx_serialize_text_style( CP_XML_STREAM(), _T(""));//serialize style_context
}
}
}
......@@ -567,7 +567,7 @@ void text_list_level_style_bullet::docx_convert(oox::docx_conversion_context & C
{
Context.get_styles_context().start();
textProperties->content().docx_convert(Context);
Context.get_styles_context().docx_serialize_text_style(CP_XML_STREAM());
Context.get_styles_context().docx_serialize_text_style(CP_XML_STREAM(), _T(""));
}
}
}
......
......@@ -353,7 +353,7 @@ void paragraph::docx_convert(oox::docx_conversion_context & Context)
if (Context.check_page_break_after())
{
is_empty = false;
Context.add_new_run();
Context.add_new_run(_T(""));
_Wostream << L"<w:br w:type=\"page\" />";
Context.finish_run();
}
......
......@@ -2485,17 +2485,32 @@ void odf_drawing_context::set_image_style_repeat(int style)
else
impl_->current_graphic_properties->content().common_draw_fill_attlist_.style_repeat_ = style_repeat(style_repeat::NoRepeat);//default
}
void odf_drawing_context::set_image_client_rect(double l_pt, double t_pt, double r_pt, double b_pt)
void odf_drawing_context::set_image_client_rect_pt(double l, double t, double r, double b)
{
if (!impl_->current_graphic_properties)return;
//<top>, <right>, <bottom>, <left>
std::wstringstream str_stream;
str_stream << std::wstring(L"rect(")
<< length(length(t_pt,length::pt).get_value_unit(length::cm),length::cm) << std::wstring(L",")
<< length(length(r_pt,length::pt).get_value_unit(length::cm),length::cm) << std::wstring(L",")
<< length(length(b_pt,length::pt).get_value_unit(length::cm),length::cm) << std::wstring(L",")
<< length(length(l_pt,length::pt).get_value_unit(length::cm),length::cm) << std::wstring(L")");
<< length(length(t, length::pt).get_value_unit(length::cm),length::cm) << std::wstring(L",")
<< length(length(r, length::pt).get_value_unit(length::cm),length::cm) << std::wstring(L",")
<< length(length(b, length::pt).get_value_unit(length::cm),length::cm) << std::wstring(L",")
<< length(length(l, length::pt).get_value_unit(length::cm),length::cm) << std::wstring(L")");
impl_->current_graphic_properties->content().fo_clip_ = str_stream.str();
}
void odf_drawing_context::set_image_client_rect_inch(double l, double t, double r, double b)
{
if (!impl_->current_graphic_properties)return;
//<top>, <right>, <bottom>, <left>
std::wstringstream str_stream;
str_stream << std::wstring(L"rect(")
<< t << std::wstring(L"in, ")
<< r << std::wstring(L"in, ")
<< b << std::wstring(L"in, ")
<< l << std::wstring(L"in)");
impl_->current_graphic_properties->content().fo_clip_ = str_stream.str();
......
......@@ -179,7 +179,8 @@ public:
void end_bitmap_style();
//////////////////////////////////////////////////////////////////////////////////////
void set_image_style_repeat(int style);
void set_image_client_rect(double l_pt, double t_pt, double r_pt, double b_pt);
void set_image_client_rect_pt(double l, double t, double r, double b);
void set_image_client_rect_inch(double l, double t, double r, double b);
void set_bitmap_tile_align(int align);
void set_bitmap_tile_scale_x(double scale_x);
......
......@@ -275,7 +275,7 @@ void OoxConverter::convert(OOX::Vml::CImageData *vml_image_data)
if (vml_image_data->m_oCropRight.IsInit()) r_pt = vml_image_data->m_oCropRight->GetValue() * Width;
if (vml_image_data->m_oCropBottom.IsInit()) b_pt = vml_image_data->m_oCropBottom->GetValue()* Height;
odf_context()->drawing_context()->set_image_client_rect(l_pt ,t_pt ,r_pt, b_pt);
odf_context()->drawing_context()->set_image_client_rect_pt (l_pt ,t_pt ,r_pt, b_pt);
}
odf_context()->drawing_context()->end_bitmap_style();
......
......@@ -44,6 +44,7 @@ namespace Oox2Odf
{
if (impl_ )delete impl_ ;
}
void Converter::convert()
{
if (!impl_)return;
......@@ -62,6 +63,31 @@ namespace Oox2Odf
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
double OoxConverter::getSystemDPI()
{
#if defined (_WIN32) || defined(_WIN64)
HDC screen = GetDC(0);
int dpiX = GetDeviceCaps (screen, LOGPIXELSX);
int dpiY = GetDeviceCaps (screen, LOGPIXELSY);
ReleaseDC (0, screen);
return dpiX;
#elif defined (__linux__)
Display *dpy = XOpenDisplay (NULL);;
double xres = ((((double) DisplayWidth (dpy, 0)) * 25.4) / ((double) DisplayWidthMM(dpy, 0)));
double yres = ((((double) DisplayHeight(dpy, 0)) * 25.4) / ((double) DisplayHeightMM(dpy, 0)));
XCloseDisplay (dpy);
return xres;
#else
return 96.;
#endif
}
bool OoxConverter::UpdateProgress(long nComplete)
{
if (pCallBack)
......@@ -760,6 +786,11 @@ void OoxConverter::convert(OOX::Drawing::CBlipFillProperties *oox_bitmap_fill, C
}
if (oox_bitmap_fill->m_oSrcRect.IsInit() && Width >0 && Height >0)//
{
odf_context()->drawing_context()->set_image_client_rect_inch(
oox_bitmap_fill->m_oSrcRect->m_oL.GetValue() /100. * Width / currentSystemDPI,
oox_bitmap_fill->m_oSrcRect->m_oT.GetValue() /100. * Height/ currentSystemDPI,
oox_bitmap_fill->m_oSrcRect->m_oR.GetValue() /100. * Width / currentSystemDPI,
oox_bitmap_fill->m_oSrcRect->m_oB.GetValue() /100. * Height/ currentSystemDPI);
}
if (oox_bitmap_fill->m_oTile.IsInit())
{
......
......@@ -299,13 +299,18 @@ public:
oox_current_child_document = NULL;
pCallBack = CallBack;
bUserStopConvert = 0;}
bUserStopConvert = 0;
currentSystemDPI = getSystemDPI();
}
void set_fonts_directory (const std::wstring & fontsPath);
const ProgressCallback* pCallBack;
short bUserStopConvert;
bool UpdateProgress(long nComplete);
double currentSystemDPI;
double getSystemDPI();
//.......................................................................................................................
virtual cpdoccore::odf_writer::odf_conversion_context *odf_context() = 0;
......
......@@ -2186,10 +2186,11 @@ void DocxConverter::convert(OOX::Drawing::CPicture * oox_picture)
}
if (oox_picture->m_oBlipFill.m_oSrcRect.IsInit() && Width >0 && Height >0)
{
odt_context->drawing_context()->set_image_client_rect(oox_picture->m_oBlipFill.m_oSrcRect->m_oL.GetValue() * Width/100. ,
oox_picture->m_oBlipFill.m_oSrcRect->m_oT.GetValue() * Height/100.,
oox_picture->m_oBlipFill.m_oSrcRect->m_oR.GetValue() * Width/100. ,
oox_picture->m_oBlipFill.m_oSrcRect->m_oB.GetValue() * Height/100.);
odt_context->drawing_context()->set_image_client_rect_inch(
oox_picture->m_oBlipFill.m_oSrcRect->m_oL.GetValue() * Width/100. /currentSystemDPI,
oox_picture->m_oBlipFill.m_oSrcRect->m_oT.GetValue() * Height/100./currentSystemDPI,
oox_picture->m_oBlipFill.m_oSrcRect->m_oR.GetValue() * Width/100. /currentSystemDPI,
oox_picture->m_oBlipFill.m_oSrcRect->m_oB.GetValue() * Height/100./currentSystemDPI);
}
OoxConverter::convert(&oox_picture->m_oNvPicPr.m_oCNvPr);
......
......@@ -104,7 +104,7 @@ void XlsxConverter::convertDocument()
if (!xlsx_document) return;
if (!output_document) return;
if (!ods_context) return;
ods_context->start_document();
convert_styles();
......@@ -458,8 +458,14 @@ void XlsxConverter::convert(OOX::Spreadsheet::CCell *oox_cell)
}
}
if (oox_cell->m_oRichText.IsInit())
{
convert(oox_cell->m_oRichText.GetPointer());
}
ods_context->end_cell();
}
void XlsxConverter::convert_sharing_string(int number)
{
if (!ods_context) return;
......@@ -469,15 +475,18 @@ void XlsxConverter::convert_sharing_string(int number)
if (number <0 || (SharedStrings->m_oCount.IsInit() && number > SharedStrings->m_oCount->GetValue()))return;//???? m_oUniqueCount;
OOX::Spreadsheet::CSi* pSi = static_cast<OOX::Spreadsheet::CSi*>(SharedStrings->m_arrItems[number]);
if (pSi == NULL)return;
convert(static_cast<OOX::Spreadsheet::CSi*>(SharedStrings->m_arrItems[number]));
}
void XlsxConverter::convert(OOX::Spreadsheet::CSi* oox_rtf_text)
{
if (oox_rtf_text == NULL) return;
ods_context->start_cell_text();
for(int i = 0; i < pSi->m_arrItems.size(); ++i)
for(int i = 0; i < oox_rtf_text->m_arrItems.size(); ++i)
{
convert(pSi->m_arrItems[i]);
convert(oox_rtf_text->m_arrItems[i]);
}
ods_context->end_cell_text();
......@@ -1826,10 +1835,11 @@ void XlsxConverter::convert(OOX::Spreadsheet::CPic* oox_picture)
}
if (oox_picture->m_oBlipFill->m_oSrcRect.IsInit() && Width >0 && Height >0)
{
ods_context->drawing_context()->set_image_client_rect(oox_picture->m_oBlipFill->m_oSrcRect->m_oL.GetValue() * Width/100. ,
oox_picture->m_oBlipFill->m_oSrcRect->m_oT.GetValue() * Height/100.,
oox_picture->m_oBlipFill->m_oSrcRect->m_oR.GetValue() * Width/100. ,
oox_picture->m_oBlipFill->m_oSrcRect->m_oB.GetValue() * Height/100.);
ods_context->drawing_context()->set_image_client_rect_inch(
oox_picture->m_oBlipFill->m_oSrcRect->m_oL.GetValue()/100. * Width / currentSystemDPI ,
oox_picture->m_oBlipFill->m_oSrcRect->m_oT.GetValue()/100. * Height / currentSystemDPI ,
oox_picture->m_oBlipFill->m_oSrcRect->m_oR.GetValue()/100. * Width / currentSystemDPI ,
oox_picture->m_oBlipFill->m_oSrcRect->m_oB.GetValue()/100. * Height / currentSystemDPI );
}
if (oox_picture->m_oNvPicPr.IsInit())
{
......
......@@ -60,6 +60,7 @@ namespace OOX
class CSheetViews;
class CPageSetup;
class CPageMargins;
class CSi;
}
}
......@@ -174,6 +175,7 @@ namespace Oox2Odf
void convert(OOX::Spreadsheet::CIconSet *oox_cond_iconset);
void convert(OOX::Spreadsheet::CConditionalFormatValueObject*oox_cond_value);
void convert(OOX::Spreadsheet::CFormulaCF *oox_cond_formula);
void convert(OOX::Spreadsheet::CSi *oox_rtf_text);
void convert(double oox_size, _CP_OPT(odf_types::length) & odf_size);
void convert_sharing_string(int number);
......
......@@ -156,8 +156,8 @@ HRESULT COfficeOdfFileW::SaveToFileImpl(const std::wstring & srcPath,
//FileChecker !!
std::wstring COfficeOdfFileW::DetectTypeDocument(const std::wstring & Path)
{
return L"text";
//return L"spreadsheet";
//return L"text";
return L"spreadsheet";
}
void COfficeOdfFileW::OnProgressFunc (LPVOID lpParam, long nID, long nPercent)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment