Commit 1f9e3f4f authored by ElenaSubbotina's avatar ElenaSubbotina

OdpFormatReader - fix after testing

parent 828df16f
......@@ -181,7 +181,11 @@ std::wstring mediaitems::add_or_find(const std::wstring & href, RelsType type, b
sub_path = L"embeddings/";
}
else
{
isMediaInternal = is_internal(href, odf_packet_);
if (href.empty() && type == typeImage)
return L"";
}
int number=0;
......@@ -205,9 +209,9 @@ std::wstring mediaitems::add_or_find(const std::wstring & href, RelsType type, b
if ( type == typeChart) outputPath = outputPath + L".xml";
std::wstring id;
for (int i = 0 ; i < items_.size(); i++)
for (size_t i = 0 ; i < items_.size(); i++)
{
if (items_[i].href == inputPath)
if ((items_[i].href == inputPath && !inputPath.empty()) || (items_[i].type == type && inputPath.empty()))
{
id = items_[i].Id;
outputPath = items_[i].outputName;
......
......@@ -436,8 +436,14 @@ void _oox_drawing::serialize_shape(std::wostream & strm)
{
CP_XML_NODE(L"a:path")
{
CP_XML_ATTR(L"w", w ? *w : cx);
CP_XML_ATTR(L"h", h ? *h : cy);
int path_w = w ? *w : cx;
int path_h = h ? *h : cy;
if (path_w < 1) path_w = 1024;
if (path_h < 1) path_h = 1024;
CP_XML_ATTR(L"w", path_w);
CP_XML_ATTR(L"h", path_h);
if (sCustomPath)
{
......
......@@ -83,7 +83,7 @@ namespace oox {
class _oox_drawing
{
public:
_oox_drawing() : type(typeUnknown), id(0), x(0), y(0), cx(0), cy(0), sub_type(0), inGroup(false), name(L"object")
_oox_drawing() : type(typeUnknown), id(0), x(0), y(0), cx(0), cy(0), sub_type(0), inGroup(false), name(L"object"), extExternal(false)
{
}
RelsType type;
......@@ -103,6 +103,7 @@ namespace oox {
std::wstring objectProgId;
std::wstring extId;
bool extExternal;
_action_desc action;
std::vector<_hlink_desc> hlinks;
......
......@@ -37,7 +37,7 @@
namespace cpdoccore {
namespace oox {
oox_bitmap_fill::oox_bitmap_fill() : name_space(L"a"), bStretch(false), bCrop(false),bTile(false),isInternal(true)
oox_bitmap_fill::oox_bitmap_fill() : name_space(L"a"), bStretch(false), bCrop(false), bTile(false), isInternal(true)
{
memset(cropRect,0,sizeof(double)*4);
}
......@@ -186,10 +186,10 @@ void oox_serialize_bitmap_fill(std::wostream & strm, const _oox_fill & val)
{
CP_XML_NODE(L"a:srcRect")
{
CP_XML_ATTR(L"l", static_cast<size_t>(val.bitmap->cropRect[0]*1000));
CP_XML_ATTR(L"t", static_cast<size_t>(val.bitmap->cropRect[1]*1000));
CP_XML_ATTR(L"r", static_cast<size_t>(val.bitmap->cropRect[2]*1000));
CP_XML_ATTR(L"b", static_cast<size_t>(val.bitmap->cropRect[3]*1000));
CP_XML_ATTR(L"l", static_cast<int>(val.bitmap->cropRect[0]*1000));
CP_XML_ATTR(L"t", static_cast<int>(val.bitmap->cropRect[1]*1000));
CP_XML_ATTR(L"r", static_cast<int>(val.bitmap->cropRect[2]*1000));
CP_XML_ATTR(L"b", static_cast<int>(val.bitmap->cropRect[3]*1000));
}
}
if (val.bitmap->bTile)
......
......@@ -147,6 +147,6 @@ namespace oox {
void oox_serialize_fill (std::wostream & strm, const _oox_fill & val);
void oox_serialize_srgb (std::wostream & strm,std::wstring color,_CP_OPT(double) opacity);
void oox_serialize_srgb (std::wostream & strm,std::wstring color,_CP_OPT(odf_types::percent) opacity);
void oox_serialize_bitmap_fill (std::wostream & strm, const _oox_fill & val);
}
}
......@@ -70,13 +70,14 @@ static std::wstring get_mime_type(const std::wstring & extension)
else if (L"tif" == extension) return L"image/x-tiff";
else if (L"tiff" == extension) return L"image/x-tiff";
else if (L"pdf" == extension) return L"application/pdf";
else if (L"bmp" == extension) return L"image/bmp";
else if (L"wav" == extension) return L"audio/wav";
else if (L"mp3" == extension) return L"audio/mpeg";
else if (L"wma" == extension) return L"audio/x-ms-wma";
else if (L"m4a" == extension) return L"audio/unknown";
else if (L"avi" == extension) return L"video/avi";
else if (L"avi" == extension) return L"video/x-msvideo";
else if (L"wmv" == extension) return L"video/x-ms-wmv";
else if (L"mov" == extension) return L"video/unknown";
else if (L"mp4" == extension) return L"video/unknown";
......
......@@ -150,15 +150,30 @@ void pptx_serialize_media(std::wostream & strm, _pptx_drawing & val)
CP_XML_NODE(L"p14:media")
{
CP_XML_ATTR(L"xmlns:p14", L"http://schemas.microsoft.com/office/powerpoint/2010/main");
CP_XML_ATTR(L"r:embed", val.extId);
if (val.extExternal)
{
CP_XML_ATTR(L"r:link", val.extId);
}
else
{
CP_XML_ATTR(L"r:embed", val.extId);
}
}
}
}
}
}
if (val.fill.bitmap)
{
val.fill.bitmap->name_space = L"p";
oox_serialize_fill(CP_XML_STREAM(), val.fill);
oox_serialize_bitmap_fill(strm, val.fill);
val.fill.bitmap.reset();
}
else
{
CP_XML_NODE(L"p:blipFill");
}
CP_XML_NODE(L"p:spPr")
{
......@@ -169,7 +184,8 @@ void pptx_serialize_media(std::wostream & strm, _pptx_drawing & val)
CP_XML_ATTR(L"prst", L"rect");
CP_XML_NODE(L"a:avLst");
}
oox_serialize_ln(CP_XML_STREAM(), val.additional);
oox_serialize_fill (CP_XML_STREAM(), val.fill);
oox_serialize_ln (CP_XML_STREAM(), val.additional);
}
//_CP_OPT(std::wstring) strTextContent;
//odf::GetProperty(properties,L"text-content",strTextContent);
......
......@@ -554,8 +554,9 @@ void pptx_slide_context::Impl::process_image(drawing_object_description& obj, _p
std::wstring ref;/// это ссылка на выходной внешний объект
bool isMediaInternal = false;
drawing.fill.bitmap->rId = get_mediaitems().add_or_find(obj.xlink_href_, typeImage, isMediaInternal, ref);
drawing.fill.bitmap->rId = get_mediaitems().add_or_find(obj.xlink_href_, typeImage, isMediaInternal, ref);
drawing.fill.bitmap->isInternal = isMediaInternal;
if (drawing.type == typeShape)
{
add_additional_rels(isMediaInternal, drawing.fill.bitmap->rId, ref, typeImage);//собственно это не объект, а доп рел и ref объекта
......@@ -647,11 +648,12 @@ void pptx_slide_context::Impl::process_media(drawing_object_description& obj, _p
drawing.type = mediaitems::detectMediaType(obj.xlink_href_); //reset from Media to Audio, Video, ... QuickTime? AudioCD? ...
drawing.objectId = get_mediaitems().add_or_find(obj.xlink_href_, drawing.type, isMediaInternal, ref);
drawing.extId = L"ext" + drawing.objectId;
drawing.objectId = get_mediaitems().add_or_find(obj.xlink_href_, drawing.type, isMediaInternal, ref);
drawing.extId = L"ext" + drawing.objectId;
drawing.extExternal = !isMediaInternal;
add_drawing(drawing, false, drawing.objectId, L"NULL", drawing.type);
add_additional_rels( true, drawing.extId, ref, typeMedia);
add_additional_rels( isMediaInternal, drawing.extId, ref, typeMedia);
if (drawing.fill.bitmap)
{
......
......@@ -332,21 +332,34 @@ void oox_serialize_tcPr(std::wostream & strm, std::vector<const odf_reader::styl
}
if (style_cell_attlist.common_padding_attlist_.fo_padding_)
{
CP_XML_ATTR(L"marT", *style_cell_attlist.common_padding_attlist_.fo_padding_);
CP_XML_ATTR(L"marB", *style_cell_attlist.common_padding_attlist_.fo_padding_);
CP_XML_ATTR(L"marL", *style_cell_attlist.common_padding_attlist_.fo_padding_);
CP_XML_ATTR(L"marR", *style_cell_attlist.common_padding_attlist_.fo_padding_);
double padding = style_cell_attlist.common_padding_attlist_.fo_padding_->get_value_unit(odf_types::length::emu);
CP_XML_ATTR(L"marT", (long)padding);
CP_XML_ATTR(L"marB", (long)padding);
CP_XML_ATTR(L"marL", (long)padding);
CP_XML_ATTR(L"marR", (long)padding);
}
else
{
if (style_cell_attlist.common_padding_attlist_.fo_padding_top_)
CP_XML_ATTR(L"marT", *style_cell_attlist.common_padding_attlist_.fo_padding_top_);
{
double padding = style_cell_attlist.common_padding_attlist_.fo_padding_top_->get_value_unit(odf_types::length::emu);
CP_XML_ATTR(L"marT", (long)padding);
}
if (style_cell_attlist.common_padding_attlist_.fo_padding_bottom_)
CP_XML_ATTR(L"marB", *style_cell_attlist.common_padding_attlist_.fo_padding_bottom_);
{
double padding = style_cell_attlist.common_padding_attlist_.fo_padding_bottom_->get_value_unit(odf_types::length::emu);
CP_XML_ATTR(L"marB", (long)padding);
}
if (style_cell_attlist.common_padding_attlist_.fo_padding_left_)
CP_XML_ATTR(L"marL", *style_cell_attlist.common_padding_attlist_.fo_padding_left_);
{
double padding = style_cell_attlist.common_padding_attlist_.fo_padding_left_->get_value_unit(odf_types::length::emu);
CP_XML_ATTR(L"marL", (long)padding);
}
if (style_cell_attlist.common_padding_attlist_.fo_padding_right_)
CP_XML_ATTR(L"marR", *style_cell_attlist.common_padding_attlist_.fo_padding_right_);
{
double padding = style_cell_attlist.common_padding_attlist_.fo_padding_right_->get_value_unit(odf_types::length::emu);
CP_XML_ATTR(L"marR", (long)padding);
}
}
//vert //
//style_cell_attlist.pptx_serialize(Context, CP_XML_STREAM()); //nodes
......
......@@ -754,7 +754,7 @@ int ComputeMarginY(const style_page_layout_properties_attlist & pageProperties,
}
void common_draw_docx_convert(oox::docx_conversion_context & Context, const union_common_draw_attlists & attlists_, oox::_docx_drawing *drawing)
void common_draw_docx_convert(oox::docx_conversion_context & Context, union_common_draw_attlists & attlists_, oox::_docx_drawing *drawing)
{
const std::wstring styleName = attlists_.shape_with_text_and_styles_.
common_shape_draw_attlist_.draw_style_name_.get_value_or(L"");
......@@ -899,7 +899,16 @@ void common_draw_docx_convert(oox::docx_conversion_context & Context, const unio
}
}
///////////////////////////
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);
if (w_shape < 1) attlists_.rel_size_.common_draw_size_attlist_.svg_width_ = length(1, length::pt);
}
if (attlists_.rel_size_.common_draw_size_attlist_.svg_height_)
{
double h_shape = attlists_.rel_size_.common_draw_size_attlist_.svg_height_->get_value_unit(length::pt);
if (h_shape < 1) attlists_.rel_size_.common_draw_size_attlist_.svg_height_ = length(1, length::pt);
}
drawing->x = get_value_emu(attlists_.position_.svg_x_);
drawing->y = get_value_emu(attlists_.position_.svg_y_);
......
......@@ -298,6 +298,8 @@ void draw_enhanced_geometry::docx_convert(oox::docx_conversion_context & Context
shape->additional_.push_back(odf_reader::_property(L"custom_path", output_.str()));
set_shape = true;
int w = 0;
int h = 0;
if (draw_enhanced_geometry_attlist_.drawooo_sub_view_size_)
{
......@@ -306,8 +308,8 @@ void draw_enhanced_geometry::docx_convert(oox::docx_conversion_context & Context
if (splitted.size() == 2)
{
int w = boost::lexical_cast<int>(splitted[0]);
int h = boost::lexical_cast<int>(splitted[1]);
w = boost::lexical_cast<int>(splitted[0]);
h = boost::lexical_cast<int>(splitted[1]);
shape->additional_.push_back(odf_reader::_property(L"custom_path_w", w));
shape->additional_.push_back(odf_reader::_property(L"custom_path_h", h));
......@@ -320,6 +322,17 @@ void draw_enhanced_geometry::docx_convert(oox::docx_conversion_context & Context
int b = boost::lexical_cast<int>(splitted[3]);
}
//if (shape->common_draw_attlists_.rel_size_.common_draw_size_attlist_.svg_width_)
//{
// int w_shape = shape->common_draw_attlists_.rel_size_.common_draw_size_attlist_.svg_width_->get_value();
// if (w_shape < 1) shape->common_draw_attlists_.rel_size_.common_draw_size_attlist_.svg_width_ = length(1, length::pt);
//}
//if (shape->common_draw_attlists_.rel_size_.common_draw_size_attlist_.svg_height_)
//{
// int h_shape = shape->common_draw_attlists_.rel_size_.common_draw_size_attlist_.svg_height_->get_value();
// if (h_shape < 1) shape->common_draw_attlists_.rel_size_.common_draw_size_attlist_.svg_height_ = length(1, length::pt);
//}
}
}
}
......
......@@ -33,6 +33,7 @@
#include "math_layout_elements.h"
#include "math_token_elements.h"
#include "style_text_properties.h"
#include "math_limit_elements.h"
#include <cpdoccore/xml/xmlchar.h>
#include <cpdoccore/xml/attributes.h>
......@@ -297,8 +298,21 @@ void math_mstyle::oox_convert(oox::math_context & Context)
for (size_t i = 0; i < content_.size(); i++)
{
math_munder* munder_test = dynamic_cast<math_munder*>(content_[i].get());
math_mfrac* frac_test = dynamic_cast<math_mfrac*>(content_[i].get());
math_mrow* row_test = dynamic_cast<math_mrow*>(content_[i].get());
if (row_test || munder_test || frac_test)
Context.output_stream() << L"<m:e>";
office_math_element* math_element = dynamic_cast<office_math_element*>(content_[i].get());
math_element->oox_convert(Context);
math_element->oox_convert(Context);
if (row_test || munder_test || frac_test)
Context.output_stream() << L"</m:e>";
//office_math_element* math_element = dynamic_cast<office_math_element*>(content_[i].get());
//math_element->oox_convert(Context);
}
//reset to default math text props
Context.text_properties_ = odf_reader::style_text_properties_ptr(new odf_reader::style_text_properties());
......
......@@ -32,6 +32,7 @@
#include "math_table_elements.h"
#include "math_layout_elements.h"
#include "math_limit_elements.h"
#include <cpdoccore/xml/xmlchar.h>
#include <cpdoccore/xml/attributes.h>
......@@ -93,14 +94,18 @@ void math_mtr::oox_convert(oox::math_context & Context)
strm << L"<m:mr>";
for (size_t i = 0; i < content_.size(); i++)
{
math_mrow* mrow_test = dynamic_cast<math_mrow*>(content_[i].get());
if (mrow_test)
math_mrow* row_test = dynamic_cast<math_mrow*>(content_[i].get());
math_munder* munder_test = dynamic_cast<math_munder*>(content_[i].get());
math_mfrac* frac_test = dynamic_cast<math_mfrac*>(content_[i].get());
if (row_test || munder_test || frac_test)
Context.output_stream() << L"<m:e>";// EqArray записался в числитель вместо знаменателя.docx - дублирование
office_math_element* math_element = dynamic_cast<office_math_element*>(content_[i].get());
math_element->oox_convert(Context);
if (mrow_test)
if (row_test || munder_test || frac_test)
strm << L"</m:e>";
}
strm << L"</m:mr>";
......
......@@ -283,7 +283,12 @@ void math_mtext::add_text(const std::wstring & Text)
void math_mtext::oox_convert(oox::math_context & Context)
{
if (text_)
{
Context.output_stream() << L"<m:r><m:rPr><m:nor/></m:rPr><m:t>";
Context.output_stream() << *text_;
Context.output_stream() << L"</m:t></m:r>";
}
}
//----------------------------------------------------------------------------------------------------
const wchar_t * math_mglyph::ns = L"math";
......
......@@ -90,20 +90,38 @@ void text::docx_convert(oox::docx_conversion_context & Context)
Context.get_delete_text_state())
return; //в ms нет рецензирования notes
Context.add_element_to_run();
std::wostream & strm = Context.output_stream();
bool add_del_run = false;
if (Context.get_drawing_state_content() && Context.get_delete_text_state())
{ //0503IG-AddingFormattingText.odt - удаленый текст в удаленом объекте
oox::text_tracked_context::_state &state = Context.get_text_tracked_context().get_tracked_change(L"");
if (state.type == 2)
{
add_del_run = true;
Context.output_stream() << L"<w:del>";
}
}
Context.add_element_to_run();
std::wstring textNode = L"w:t";
if (Context.get_delete_text_state()) textNode = L"w:delText";
strm << L"<" << textNode;
Context.output_stream() << L"<" << textNode;
if (preserve_ && !Context.get_delete_text_state())
strm << L" xml:space=\"preserve\"";
strm << L">";
Context.output_stream() << L" xml:space=\"preserve\"";
Context.output_stream() << L">";
Context.output_stream() << xml::utils::replace_text_to_xml( text_ );
Context.output_stream() << L"</" << textNode << L">";
if (add_del_run)
{
Context.finish_run();
Context.output_stream() << L"</w:del>";
}
strm << xml::utils::replace_text_to_xml( text_ );
strm << L"</" << textNode << L">";
}
void text::xlsx_convert(oox::xlsx_conversion_context & Context)
......
......@@ -790,7 +790,7 @@ namespace svg_path
}
}
if ((aCurrPoly.points.size() > 0 || !bIsClosed) && !aCurrPoly.command.empty() && aCurrPoly.command != L"a:cubicBezTo")
if ((aCurrPoly.points.size() > 0/* || !bIsClosed*/) && !aCurrPoly.command.empty() && aCurrPoly.command != L"a:cubicBezTo")
{
// end-process last poly
......
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