Commit eb6fb03c authored by ElenaSubbotina's avatar ElenaSubbotina

Merge remote-tracking branch 'origin/hotfix/v5.0.1' into develop

parents 5e60456f ad40f51d
......@@ -477,6 +477,12 @@ namespace formulasconvert {
}
//todooo INDEX((A1:C6~A8:C11),2,2,2) - ???? - INDEX_emb.ods
}
else
{
size_t sz_workstr = workstr.length();
if (workstr.substr(0, min(3, sz_workstr)) == L"of:")//sample_02neu_crashes.ods
workstr = workstr.substr(3);
}
//-----------------------------------------------------------
......
......@@ -800,7 +800,7 @@ bool docx_conversion_context::process_page_properties(std::wostream & strm)
if (page_layout_instance_)
{
page_layout_instance_->docx_convert_serialize(strm, *this);
page_layout_instance_->docx_serialize(strm, *this);
}
else
{
......
......@@ -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");
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);
......
......@@ -555,6 +555,7 @@ void pptx_slide_context::Impl::process_image(drawing_object_description& obj, _p
bool isMediaInternal = false;
drawing.fill.bitmap->rId = get_mediaitems().add_or_find(obj.xlink_href_, typeImage, isMediaInternal, ref);
drawing.fill.bitmap->isInternal = isMediaInternal;
if (drawing.type == typeShape)
{
......@@ -649,9 +650,10 @@ void pptx_slide_context::Impl::process_media(drawing_object_description& obj, _p
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
......
......@@ -281,6 +281,11 @@ void xlsx_conditionalFormatting_context::set_formula(std::wstring f)
impl_->conditionalFormattings_.back().rules.back().formula_type = L"expression";
impl_->conditionalFormattings_.back().rules.back().formula = converter.convert_named_expr(val);
}
else if (0 <= (pos = f.find(L"is-error")))
{
impl_->conditionalFormattings_.back().rules.back().formula_type = L"containsErrors";
impl_->conditionalFormattings_.back().rules.back().formula = L"0";
}
else if (0 <= (pos = f.find(L"duplicate")))
{
impl_->conditionalFormattings_.back().rules.back().formula_type = L"duplicateValues";
......
......@@ -38,6 +38,8 @@
#include <cpdoccore/xml/simple_xml_writer.h>
#include"../../Common/DocxFormat/Source/XML/Utils.h"
#include"../../Common/DocxFormat/Source/base/types_32.h"
#include <map>
namespace cpdoccore {
......@@ -80,6 +82,7 @@ public:
bool repeat_item_labels = true;
int type_groups = 0;
int sort = 0;
std::wstring source_groups;
std::vector<int> subtotals;
......@@ -143,9 +146,13 @@ public:
bool data_on_row = false;
}current_;
void sort_fields();
void serialize_view(std::wostream & strm);
void serialize_cache(std::wostream & strm);
void serialize_type_field(CP_ATTR_NODE, _field & field);
private:
bool clear_header_map(std::map<size_t, size_t> & map)
{//отсев по секонд - нужны тока повторы
......@@ -243,12 +250,27 @@ private:
}
connections_ += strm.str();
}
};
xlsx_pivots_context::xlsx_pivots_context() : impl_(new xlsx_pivots_context::Impl())
{
}
void xlsx_pivots_context::Impl::sort_fields()
{
for (size_t i = 0; i < current_.fields.size(); i++)
{
if (current_.fields[i].type == 7)
continue;
if (!current_.fields[i].source_groups.empty() && i != current_.fields.size() -1)
{
current_.fields.push_back(current_.fields[i]);
current_.fields.erase(current_.fields.begin() + i , current_.fields.begin() + i + 1);
i--;
}
}
}
void xlsx_pivots_context::Impl::serialize_view(std::wostream & strm)
{
if (current_.headers.empty()) return;
......@@ -403,6 +425,7 @@ void xlsx_pivots_context::Impl::serialize_view(std::wostream & strm)
CP_XML_ATTR(L"colPageCount", 1);
}
}
std::map<std::wstring, bool> used_field_name;
CP_XML_NODE(L"pivotFields")
{
CP_XML_ATTR(L"count", current_.fields_count);
......@@ -411,6 +434,11 @@ void xlsx_pivots_context::Impl::serialize_view(std::wostream & strm)
if (current_.fields[i].type == 7)
continue;
if (used_field_name.end() != used_field_name.find(current_.fields[i].name))
continue;
used_field_name.insert(std::make_pair(current_.fields[i].name, true));
CP_XML_NODE(L"pivotField")
{
switch(current_.fields[i].type)
......@@ -554,9 +582,90 @@ void xlsx_pivots_context::Impl::serialize_view(std::wostream & strm)
}
}
}
void xlsx_pivots_context::Impl::serialize_type_field(CP_ATTR_NODE, _field & field)
{
_CP_OPT(bool) containsSemiMixedTypes;
_CP_OPT(bool) containsMixedTypes;
_CP_OPT(bool) containsNonDate;
_CP_OPT(bool) containsDate;
_CP_OPT(bool) containsString;
_CP_OPT(bool) containsBlank;
_CP_OPT(bool) containsNumber;
_CP_OPT(bool) containsInteger;
if (field.bDate & field.bNumber/* ||
field.bNumber & field.bString*/)
{
containsSemiMixedTypes = true;
}
else if (field.bDate & field.bString ||
field.bNumber & field.bString ||
field.bInteger & field.bString)
{
containsMixedTypes = true;
if (field.bInteger)
{
if (field.bNumber) field.bInteger = false;
field.bNumber = true;
}
}
else if (!field.bEmpty && !field.bString && !field.bBool)
{
containsSemiMixedTypes = false;
}
if (field.bDate &&
!(field.bNumber || field.bInteger || field.bString || field.bEmpty ))
{
containsNonDate = false;
}
if (field.bDate)
{
containsDate = true;
}
if (!field.bString &&
(field.bInteger || field.bDate || field.bNumber || field.bEmpty))
{
containsString = false;
if (field.bInteger)
{
if (field.bNumber) field.bInteger = false;
field.bNumber = true;
}
if (/*!field.bDate && */field.bEmpty)
containsNonDate = false;
}
if (field.bEmpty)
{
containsBlank = true;
}
if (field.bNumber)
{
containsNumber = true;
}
if (field.bInteger && !field.bDate)
{
if (containsMixedTypes)
{
containsNumber = true;
containsInteger = true;
}
else
containsInteger = true;
}
if (containsNonDate) CP_XML_ATTR(L"containsNonDate", *containsNonDate);
if (containsSemiMixedTypes) CP_XML_ATTR(L"containsSemiMixedTypes", *containsSemiMixedTypes);
if (containsString) CP_XML_ATTR(L"containsString", *containsString);
if (containsBlank) CP_XML_ATTR(L"containsBlank", *containsBlank);
if (containsMixedTypes) CP_XML_ATTR(L"containsMixedTypes", *containsMixedTypes);
if (containsDate) CP_XML_ATTR(L"containsDate", *containsDate);
if (containsNumber) CP_XML_ATTR(L"containsNumber", *containsNumber);
if (containsInteger) CP_XML_ATTR(L"containsInteger", *containsInteger);
}
void xlsx_pivots_context::Impl::serialize_cache(std::wostream & strm)
{
std::map<std::wstring, bool> used_field_name;
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"pivotCacheDefinition")
......@@ -611,11 +720,21 @@ void xlsx_pivots_context::Impl::serialize_cache(std::wostream & strm)
if (current_.fields[i].type == 7)
continue;
if (used_field_name.end() != used_field_name.find(current_.fields[i].name))
continue;
used_field_name.insert(std::make_pair(current_.fields[i].name, true));
CP_XML_NODE(L"cacheField")
{
CP_XML_ATTR(L"name", current_.fields[i].name);
CP_XML_ATTR(L"numFmtId", 0);
if (!current_.fields[i].source_groups.empty())
{
CP_XML_ATTR(L"databaseField", 0);
}
CP_XML_NODE(L"sharedItems")
{
if (current_.fields[i].caches.empty() == false/* &&
......@@ -631,47 +750,7 @@ void xlsx_pivots_context::Impl::serialize_cache(std::wostream & strm)
current_.fields[i].bString = false;
}
if ((current_.fields[i].bDate & current_.fields[i].bNumber) ||
(current_.fields[i].bNumber & current_.fields[i].bString))
{
CP_XML_ATTR(L"containsSemiMixedTypes", 1);
}
else if (current_.fields[i].bDate & current_.fields[i].bString)
{
CP_XML_ATTR(L"containsMixedTypes", 1);
}
else if (!current_.fields[i].bEmpty && !current_.fields[i].bString && !current_.fields[i].bBool)
{
CP_XML_ATTR(L"containsSemiMixedTypes", 0);
}
if (current_.fields[i].bDate &&
!(current_.fields[i].bNumber || current_.fields[i].bInteger || current_.fields[i].bString || current_.fields[i].bEmpty ))
{
CP_XML_ATTR(L"containsNonDate", 0);
}
if (current_.fields[i].bDate) CP_XML_ATTR(L"containsDate", 1);
if (!current_.fields[i].bString &&
(current_.fields[i].bInteger || current_.fields[i].bDate || current_.fields[i].bNumber || current_.fields[i].bEmpty))
{
CP_XML_ATTR(L"containsString", 0);
}
if (current_.fields[i].bEmpty) CP_XML_ATTR(L"containsBlank", 1);
if (current_.fields[i].bNumber) CP_XML_ATTR(L"containsNumber", 1);
if (current_.fields[i].bInteger && !current_.fields[i].bDate)
{
if (current_.fields[i].bString)
{
CP_XML_ATTR(L"containsInteger", 1);
}
else if (!current_.fields[i].bNumber)
{
CP_XML_ATTR(L"containsNumber", 1);
CP_XML_ATTR(L"containsInteger", 1);
}
}
serialize_type_field(CP_GET_XML_NODE(), current_.fields[i]);
if ( current_.fields[i].type_groups == 0 )
{
for (size_t j = 0; j < current_.fields[i].caches.size(); j++)
......@@ -691,7 +770,7 @@ void xlsx_pivots_context::Impl::serialize_cache(std::wostream & strm)
{
CP_XML_NODE(L"fieldGroup")
{
CP_XML_ATTR(L"base", i);
CP_XML_ATTR(L"base", 0);
CP_XML_NODE(L"rangePr")
{
switch(current_.fields[i].type_groups)
......@@ -824,6 +903,8 @@ int xlsx_pivots_context::end_table()
std::wstringstream cache_strm;
std::wstringstream rec_strm;
impl_->sort_fields();
impl_->serialize_view(view_strm);
impl_->serialize_cache(cache_strm);
......@@ -973,6 +1054,10 @@ void xlsx_pivots_context::set_field_groups(int type)
{
impl_->current_.fields.back().type_groups = type + 1;
}
void xlsx_pivots_context::set_field_groups_source(std::wstring name)
{
impl_->current_.fields.back().source_groups = name;
}
void xlsx_pivots_context::set_field_sort(int type)
{
impl_->current_.fields.back().sort = type + 1;
......@@ -1002,15 +1087,16 @@ void xlsx_pivots_context::add_field_cache(int index, std::wstring value)
_CP_OPT(double) dVal;
if (pos >= 0)//финановый .. todooo общее правило бы...
{
value = value.substr(pos + 1);
XmlUtils::replace_all(value, L",", L"");
XmlUtils::replace_all(value, L" ", L"");
XmlUtils::replace_all(value, L"\x00A0", L"");
//value = value.substr(pos + 1);
//XmlUtils::replace_all(value, L",", L"");
//XmlUtils::replace_all(value, L" ", L"");
//XmlUtils::replace_all(value, L"\x00A0", L"");
}
if (oox::IsNumber(value))
{
try
{
XmlUtils::replace_all(value, L",", L".");
dVal = boost::lexical_cast<double>(value);
}
catch(...)
......@@ -1021,7 +1107,7 @@ void xlsx_pivots_context::add_field_cache(int index, std::wstring value)
{
node_name = L"n";
int iVal = *dVal;
_INT64 iVal = *dVal;
if (abs(iVal - *dVal) > 0.00001)
{
value = std::to_wstring(*dVal);
......
......@@ -60,6 +60,7 @@ public:
void set_field_data_layout (bool val);
void set_field_sort (int type);
void set_field_groups (int type);
void set_field_groups_source(std::wstring name);
void set_repeat_item_labels(bool val);
void end_field();
......
......@@ -358,7 +358,18 @@ void xlsx_table_state::serialize_page_properties (std::wostream & strm)
page_layout->xlsx_serialize(strm, *context_);
}
void xlsx_table_state::serialize_background (std::wostream & strm)
{
if (tableBackground_.empty()) return;
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"picture")
{
CP_XML_ATTR(L"r:id", tableBackground_);
}
}
}
void xlsx_table_state::serialize_table_format (std::wostream & strm)
{
odf_reader::odf_read_context & odfContext = context_->root()->odf_context();
......
......@@ -125,12 +125,15 @@ public:
void start_hyperlink ();
std::wstring end_hyperlink (std::wstring const & ref, std::wstring const & href, std::wstring const & display);
void set_background (std::wstring rId) { tableBackground_ = rId; }
void serialize_conditionalFormatting (std::wostream & _Wostream);
void serialize_table_format (std::wostream & _Wostream);
void serialize_merge_cells (std::wostream & _Wostream);
void serialize_hyperlinks (std::wostream & _Wostream);
void serialize_ole_objects (std::wostream & _Wostream);
void serialize_page_properties (std::wostream & _Wostream);
void serialize_background (std::wostream & _Wostream);
void dump_rels_hyperlinks (rels & Rels);
void dump_rels_ole_objects (rels & Rels);
......@@ -154,6 +157,7 @@ private:
std::wstring tableName_;
int tableId_;
std::wstring tableBackground_;
std::wstring table_style_;
std::wstring table_row_style_;
......
......@@ -320,6 +320,10 @@ void xlsx_table_context::serialize_page_properties(std::wostream & _Wostream)
{
return state()->serialize_page_properties(_Wostream);
}
void xlsx_table_context::serialize_background(std::wostream & _Wostream)
{
return state()->serialize_background(_Wostream);
}
void xlsx_table_context::serialize_hyperlinks(std::wostream & _Wostream)
{
return state()->serialize_hyperlinks(_Wostream);
......
......@@ -90,6 +90,7 @@ public:
void serialize_hyperlinks (std::wostream & _Wostream);
void serialize_ole_objects (std::wostream & _Wostream);
void serialize_page_properties (std::wostream & _Wostream);
void serialize_background (std::wostream & _Wostream);
xlsx_table_metrics & get_table_metrics();
......
......@@ -47,7 +47,7 @@ namespace oox {
bool IsNumber(const std::wstring &value)
{
boost::wregex rule(L"\\-?^[0-9]*[.,]?[0-9]*$");
boost::wregex rule(L"^\\-{0,1}[0-9]*[.,]{0,1}[0-9]*$");
boost::match_results<std::wstring::const_iterator> results;
return boost::regex_search(value/*.begin(), value.end(), results*/, rule);
......
......@@ -476,8 +476,9 @@ void xlsx_conversion_context::end_table()
CP_XML_ATTR(L"r:id", drawingName.second);
}
}
}
get_table_context().serialize_background (current_sheet().drawing());
if (!get_comments_context().empty())
{
std::wstringstream strm;
......@@ -495,7 +496,6 @@ void xlsx_conversion_context::end_table()
current_sheet().set_comments_link(commentsName.first, commentsName.second);
current_sheet().set_vml_drawing_link(vml_drawingName.first, vml_drawingName.second);
}
//background picture
get_table_context().end_table();
}
......@@ -547,7 +547,10 @@ int xlsx_conversion_context::current_table_row()
std::wstring xlsx_conversion_context::current_cell_address()
{
return oox::getCellAddress(current_table_column(), current_table_row());
int col = current_table_column();
int row = current_table_row();
return oox::getCellAddress(col < 0 ? 0 : col, row < 0 ? 0 : row); //under covered cell
}
void xlsx_conversion_context::start_office_spreadsheet(const odf_reader::office_element * elm)
......
......@@ -91,47 +91,47 @@ smil_transition_type smil_transition_type::parse(const std::wstring & Str)
std::wstring tmp = Str;
boost::algorithm::to_lower(tmp);
if(tmp == L"barWipe") return smil_transition_type( barWipe );
else if(tmp == L"boxWipe") return smil_transition_type( boxWipe );
else if(tmp == L"fourboxWipe") return smil_transition_type( fourBoxWipe );
else if(tmp == L"barndoorWipe") return smil_transition_type( barnDoorWipe );
else if(tmp == L"diagonalWipe") return smil_transition_type( diagonalWipe );
else if(tmp == L"bowtieWipe") return smil_transition_type( bowTieWipe );
else if(tmp == L"miscdiagonalWipe") return smil_transition_type( miscDiagonalWipe );
else if(tmp == L"veeWipe") return smil_transition_type( veeWipe );
else if(tmp == L"barnveeWipe") return smil_transition_type( barnVeeWipe );
else if(tmp == L"zigzagWipe") return smil_transition_type( zigZagWipe );
else if(tmp == L"barnzigzagWipe") return smil_transition_type( barnZigZagWipe );
else if(tmp == L"irisWipe") return smil_transition_type( irisWipe);
else if(tmp == L"triangleWipe") return smil_transition_type( triangleWipe);
else if(tmp == L"arrowheadWipe") return smil_transition_type( arrowHeadWipe );
else if(tmp == L"pentagonWipe") return smil_transition_type( pentagonWipe );
else if(tmp == L"hexagonWipe") return smil_transition_type( hexagonWipe );
else if(tmp == L"ellipseWipe") return smil_transition_type( ellipseWipe );
else if(tmp == L"eyeWipe") return smil_transition_type( eyeWipe );
else if(tmp == L"roundrectWipe") return smil_transition_type( roundRectWipe );
else if(tmp == L"starWipe") return smil_transition_type( starWipe );
else if(tmp == L"miscshapeWipe") return smil_transition_type( miscShapeWipe );
else if(tmp == L"clockWipe") return smil_transition_type( clockWipe );
else if(tmp == L"pinwheelWipe") return smil_transition_type( pinWheelWipe );
else if(tmp == L"singlesweepWipe") return smil_transition_type( singleSweepWipe);
else if(tmp == L"fanWipe") return smil_transition_type( fanWipe );
else if(tmp == L"doublefanWipe") return smil_transition_type( doubleFanWipe );
else if(tmp == L"doublesweepWipe") return smil_transition_type( doubleSweepWipe );
else if(tmp == L"saloondoorWipe") return smil_transition_type( saloonDoorWipe );
else if(tmp == L"windshieldWipe") return smil_transition_type( windshieldWipe );
else if(tmp == L"snakeWipe") return smil_transition_type( snakeWipe );
else if(tmp == L"spiralWipe") return smil_transition_type( spiralWipe );
else if(tmp == L"parallelsnakesWipe")return smil_transition_type( parallelSnakesWipe );
else if(tmp == L"boxsnakesWipe") return smil_transition_type( boxSnakesWipe );
else if(tmp == L"waterfallWipe") return smil_transition_type( waterfallWipe );
else if(tmp == L"pushWipe") return smil_transition_type( pushWipe );
else if(tmp == L"slideWipe") return smil_transition_type( slideWipe );
if(tmp == L"barwipe") return smil_transition_type( barWipe );
else if(tmp == L"boxwipe") return smil_transition_type( boxWipe );
else if(tmp == L"fourboxwipe") return smil_transition_type( fourBoxWipe );
else if(tmp == L"barndoorwipe") return smil_transition_type( barnDoorWipe );
else if(tmp == L"diagonalwipe") return smil_transition_type( diagonalWipe );
else if(tmp == L"bowtiewipe") return smil_transition_type( bowTieWipe );
else if(tmp == L"miscdiagonalwipe") return smil_transition_type( miscDiagonalWipe );
else if(tmp == L"veewipe") return smil_transition_type( veeWipe );
else if(tmp == L"barnveewipe") return smil_transition_type( barnVeeWipe );
else if(tmp == L"zigzagwipe") return smil_transition_type( zigZagWipe );
else if(tmp == L"barnzigzagwipe") return smil_transition_type( barnZigZagWipe );
else if(tmp == L"iriswipe") return smil_transition_type( irisWipe);
else if(tmp == L"trianglewipe") return smil_transition_type( triangleWipe);
else if(tmp == L"arrowheadwipe") return smil_transition_type( arrowHeadWipe );
else if(tmp == L"pentagonwipe") return smil_transition_type( pentagonWipe );
else if(tmp == L"hexagonwipe") return smil_transition_type( hexagonWipe );
else if(tmp == L"ellipsewipe") return smil_transition_type( ellipseWipe );
else if(tmp == L"eyewipe") return smil_transition_type( eyeWipe );
else if(tmp == L"roundrectwipe") return smil_transition_type( roundRectWipe );
else if(tmp == L"starwipe") return smil_transition_type( starWipe );
else if(tmp == L"miscshapewipe") return smil_transition_type( miscShapeWipe );
else if(tmp == L"clockwipe") return smil_transition_type( clockWipe );
else if(tmp == L"pinwheelwipe") return smil_transition_type( pinWheelWipe );
else if(tmp == L"singlesweepwipe") return smil_transition_type( singleSweepWipe);
else if(tmp == L"fanwipe") return smil_transition_type( fanWipe );
else if(tmp == L"doublefanwipe") return smil_transition_type( doubleFanWipe );
else if(tmp == L"doublesweepwipe") return smil_transition_type( doubleSweepWipe );
else if(tmp == L"saloondoorwipe") return smil_transition_type( saloonDoorWipe );
else if(tmp == L"windshieldwipe") return smil_transition_type( windshieldWipe );
else if(tmp == L"snakewipe") return smil_transition_type( snakeWipe );
else if(tmp == L"spiralwipe") return smil_transition_type( spiralWipe );
else if(tmp == L"parallelsnakeswipe")return smil_transition_type( parallelSnakesWipe );
else if(tmp == L"boxsnakeswipe") return smil_transition_type( boxSnakesWipe );
else if(tmp == L"waterfallwipe") return smil_transition_type( waterfallWipe );
else if(tmp == L"pushwipe") return smil_transition_type( pushWipe );
else if(tmp == L"slidewipe") return smil_transition_type( slideWipe );
else if(tmp == L"fade") return smil_transition_type( fade );
else if(tmp == L"checkerboardWipe") return smil_transition_type( checkerBoardWipe);
else if(tmp == L"blindsWipe") return smil_transition_type( blindsWipe);
else if(tmp == L"checkerboardwipe") return smil_transition_type( checkerBoardWipe);
else if(tmp == L"blindswipe") return smil_transition_type( blindsWipe);
else if(tmp == L"dissolve") return smil_transition_type( dissolve);
else if(tmp == L"randombarWipe") return smil_transition_type( randomBarWipe);
else if(tmp == L"randombarwipe") return smil_transition_type( randomBarWipe);
else
{
return smil_transition_type( barWipe );
......
......@@ -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);
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";
......
......@@ -331,7 +331,7 @@ void page_layout_instance::xlsx_serialize(std::wostream & strm, oox::xlsx_conver
props->xlsx_serialize(strm, Context);
}
void page_layout_instance::docx_convert_serialize(std::wostream & strm, oox::docx_conversion_context & Context)
void page_layout_instance::docx_serialize(std::wostream & strm, oox::docx_conversion_context & Context)
{
const style_header_style * headerStyle = dynamic_cast<style_header_style *>(style_page_layout_->style_header_style_.get());
const style_footer_style * footerStyle = dynamic_cast<style_footer_style *>(style_page_layout_->style_footer_style_.get());
......@@ -357,7 +357,7 @@ void page_layout_instance::docx_convert_serialize(std::wostream & strm, oox::doc
style_page_layout_properties * props = properties();
if (props)
props->docx_convert_serialize(strm, Context);
props->docx_serialize(strm, Context);
}
void page_layout_instance::pptx_serialize(std::wostream & strm, oox::pptx_conversion_context & Context)
{
......
......@@ -193,9 +193,9 @@ public:
const std::wstring & name() const;
style_page_layout_properties * properties() const;
void docx_convert_serialize (std::wostream & strm, oox::docx_conversion_context & Context);
void xlsx_serialize (std::wostream & strm, oox::xlsx_conversion_context & Context);
void docx_serialize (std::wostream & strm, oox::docx_conversion_context & Context);
void pptx_serialize (std::wostream & strm, oox::pptx_conversion_context & Context);
void xlsx_serialize (std::wostream & strm, oox::xlsx_conversion_context & Context);
const style_page_layout * style_page_layout_;
......
......@@ -40,9 +40,10 @@
#include "serialize_elements.h"
#include <cpdoccore/odf/odf_document.h>
#include "../odf/odfcontext.h"
#include "odfcontext.h"
#include "../odf/calcs_styles.h"
#include "calcs_styles.h"
#include "../docx/xlsx_utils.h"
namespace cpdoccore {
......@@ -215,8 +216,12 @@ void office_annotation::xlsx_convert(oox::xlsx_conversion_context & Context)
const std::wstring textStyleName = office_annotation_attr_.draw_text_style_name_.get_value_or(L"");
std::wstring ref = Context.current_cell_address();
Context.get_comments_context().end_comment(ref,Context.current_table_column(), Context.current_table_row());
int col = Context.current_table_column(); if (col < 0) col = 0;
int row = Context.current_table_row(); if (row < 0) row = 0;
std::wstring ref = oox::getCellAddress(col, row);
Context.get_comments_context().end_comment(ref, col, row);
}
// officeooo:annotation
//////////////////////////////////////////////////////////////////////////////////////////////////
......
......@@ -152,7 +152,7 @@ void office_body::docx_convert(oox::docx_conversion_context & Context)
{
if (page_layout_instance * lastPageLayout = Context.root()->odf_context().pageLayoutContainer().page_layout_by_name(Context.get_page_properties()))
{
lastPageLayout->docx_convert_serialize(Context.output_stream(), Context);
lastPageLayout->docx_serialize(Context.output_stream(), Context);
//Context.remove_page_properties();
}
}
......
......@@ -90,20 +90,38 @@ void text::docx_convert(oox::docx_conversion_context & Context)
Context.get_delete_text_state())
return; //в ms нет рецензирования notes
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::wostream & strm = Context.output_stream();
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)
......
......@@ -1254,7 +1254,6 @@ bool style_page_layout_properties::docx_background_serialize(std::wostream & str
void style_page_layout_properties::xlsx_convert(oox::xlsx_conversion_context & Context)
{
}
void style_page_layout_properties::xlsx_serialize(std::wostream & strm, oox::xlsx_conversion_context & Context)
{
CP_XML_WRITER(strm)
......@@ -1319,6 +1318,7 @@ void style_page_layout_properties::xlsx_serialize(std::wostream & strm, oox::xls
}
}
}
}
if (elements_.style_background_image_)
{
oox::_oox_fill fill;
......@@ -1334,16 +1334,12 @@ void style_page_layout_properties::xlsx_serialize(std::wostream & strm, oox::xls
Context.get_drawing_context().get_drawings()->add(fill.bitmap->isInternal, fill.bitmap->rId, href, oox::typeImage, true);
}
CP_XML_NODE(L"picture")
{
CP_XML_ATTR(L"r:id", fill.bitmap->rId );
}
}
Context.get_table_context().state()->set_background(fill.bitmap->rId);
}
}
}
void style_page_layout_properties::docx_convert_serialize(std::wostream & strm, oox::docx_conversion_context & Context)
void style_page_layout_properties::docx_serialize(std::wostream & strm, oox::docx_conversion_context & Context)
{
style_columns * columns = dynamic_cast<style_columns *>( elements_.style_columns_.get());
......
......@@ -975,11 +975,12 @@ public:
static const ElementType type = typeStylePageLayout;
CPDOCCORE_DEFINE_VISITABLE();
void docx_convert_serialize (std::wostream & strm, oox::docx_conversion_context & Context);
void pptx_convert (oox::pptx_conversion_context & Context);
void xlsx_convert (oox::xlsx_conversion_context & Context);
bool docx_background_serialize(std::wostream & strm, oox::docx_conversion_context & Context, oox::_oox_fill & fill, int id);
void docx_serialize (std::wostream & strm, oox::docx_conversion_context & Context);
void xlsx_serialize(std::wostream & strm, oox::xlsx_conversion_context & Context);
void pptx_serialize(std::wostream & strm, oox::pptx_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
......
......@@ -406,6 +406,10 @@ void table_data_pilot_groups::xlsx_convert(oox::xlsx_conversion_context & Contex
if (table_grouped_by_)
Context.get_pivots_context().set_field_groups(table_grouped_by_->get_type());
if (table_source_field_name_)
Context.get_pivots_context().set_field_groups_source(*table_source_field_name_);
for (size_t i = 0; i < content_.size(); i++)
{
content_[i]->xlsx_convert(Context);
......
......@@ -304,8 +304,10 @@ bool CImageFileFormatChecker::isSvmFile(BYTE* pBuffer,DWORD dwBytes)
if (eFileType)return false;
if ( (6 <= dwBytes) &&(0x56 == pBuffer[0] && 0x43 == pBuffer[1] && 0x4c == pBuffer[2] && 0x4d == pBuffer[3]
&& 0x54 == pBuffer[4] && 0x46 == pBuffer[5] && 0x01 == pBuffer[6] && 0x00 == pBuffer[7]
&& 0x31 == pBuffer[8] && 0x00 == pBuffer[9] && 0x00 == pBuffer[10] && 0x00 == pBuffer[11]) )
&& 0x54 == pBuffer[4] && 0x46 == pBuffer[5] /*&& 0x01 == pBuffer[6] && 0x00 == pBuffer[7]
&& 0x31 == pBuffer[8]*/ && 0x00 == pBuffer[9] && 0x00 == pBuffer[10] && 0x00 == pBuffer[11]) )
//0x02, 0x00, 0x32,
//0x01,0x00, 0x031
return true;
return false;
......
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