Compare commits

..

21 Commits

Author SHA1 Message Date
1393de8057 v5.3.0 2019-05-27 17:21:45 +03:00
2092aef589 [ios][odf] fixed build 2019-05-27 13:58:50 +03:00
eff937699b . 2019-05-27 13:39:25 +03:00
3efc1f0432 [ios][x2t] fixed build 2019-05-27 13:01:12 +03:00
69fee1ae0b . 2019-05-23 20:03:25 +03:00
a0cc6b6274 OdfFormatWriter - ...; fix vml comment 2019-05-23 17:28:24 +03:00
31eb395858 OdfFormat - ... 2019-05-21 19:05:00 +03:00
ed1019a004 Not writing transparency group in pdfa mode 2019-05-20 17:09:22 +03:00
4e554d128a Merge pull request #143 from ONLYOFFICE/feature/tester
Feature/tester
2019-05-20 14:39:17 +03:00
b8d441a327 Fix remove exe 2019-05-20 14:34:24 +03:00
8fb809bf4a tester 2019-05-20 14:22:26 +03:00
35c4d70cf5 Fix bug 41615 2019-05-20 11:57:52 +03:00
58952393f0 OdfFormat - data validations 2019-05-19 17:12:43 +03:00
0b987aeed2 Add variable for xp support 2019-05-17 15:00:16 +03:00
c7315e2f21 OdfFormatReader -... 2019-05-16 19:43:29 +03:00
aefb229343 [x2t] Fix typo (Core props) 2019-05-16 18:25:10 +03:00
ac080b3485 Merge commit 'eb9d69d1ec6f23036a820992cd1957463851ef04' into develop 2019-05-16 15:41:55 +03:00
eb9d69d1ec Fix svg bug 2019-05-15 19:28:02 +03:00
eb4ffee9e7 OdfFormat - ... 2019-05-15 19:07:34 +03:00
763347d8ec OdfFormatWriter -.. 2019-05-15 16:35:29 +03:00
9670d021c2 x2t - fix bug #41503 2019-05-14 19:22:20 +03:00
80 changed files with 2167 additions and 685 deletions

View File

@ -92,8 +92,9 @@ public:
std::wstring convert_conditional_formula(std::wstring const & expr);
// Лист1!$A$1 -> $Лист1.$A$1
std::wstring convert_named_ref (std::wstring const & expr);
std::wstring convert_named_ref(std::wstring const & expr);
std::wstring convert_named_formula(std::wstring const & expr);
bool is_simple_ref(std::wstring const & expr);
std::wstring get_table_name();

View File

@ -174,6 +174,7 @@ public:
}
void replace_named_ref(std::wstring & expr);
void replace_named_formula(std::wstring & expr);
bool is_simple_ref(std::wstring const & expr);
static bool isFindBaseCell_;
@ -195,7 +196,7 @@ void oox2odf_converter::Impl::replace_cells_range(std::wstring& expr, bool bSele
if (b)
{
boost::wregex re1(L"(\\$?[^\']+\\!)?([\\w^0-9$]*\\d*)\\:?([\\w^0-9$]*\\d*)?");
boost::wregex re1(L"(\\$?[^\\']+\\!)?([a-zA-Z$]+\\d*)(\\:[a-zA-Z$]+\\d*)?");
// $ Sheet2 ! $ A1 : $ B5
// $ Sheet2 ! $ A : $ A
// $ Sheet2 ! $ 1 : $ 1
@ -238,9 +239,11 @@ std::wstring oox2odf_converter::Impl::replace_cells_range_formater1(boost::wsmat
if (isFindBaseCell_ && table_name_.empty() && !sheet.empty())
{
table_name_ = sheet + L".$A$1";
table_name_ = L"$" + sheet + L".$A$1";
}
if (!sheet.empty() && (std::wstring::npos != c1.find(L"$"))) sheet = L"$" + sheet;
if (!c2.empty() && c2.substr(0, 1) == L":")
c2 = c2.substr(1);
s = L"[" + sheet + L"." + c1 + (c2.empty() ? L"" : (L":" + sheet + L"." + c2)) + std::wstring(L"]");
@ -281,10 +284,12 @@ std::wstring oox2odf_converter::Impl::replace_cells_range_formater2(boost::wsmat
if (isFindBaseCell_ && table_name_.empty() && !sheet.empty())
{
table_name_ = sheet + L".$A$1";
table_name_ = L"$" + sheet + L".$A$1";
}
if (!sheet.empty() && (std::wstring::npos != c1.find(L"$"))) sheet = L"$" + sheet;
if (!c2.empty() && c2.substr(0, 1) == L":")
c2 = c2.substr(1);
s = sheet + L"." + c1 + (c2.empty() ? L"" : (L":" + sheet + L"." + c2)) + std::wstring(L"");
}
@ -310,6 +315,19 @@ void oox2odf_converter::Impl::replace_named_formula(std::wstring & expr)
expr = convert_formula(expr);
isFindBaseCell_ = false;
}
bool oox2odf_converter::Impl::is_simple_ref(std::wstring const & expr)
{
if (expr.find(L"(") != std::wstring::npos) return false;
if (expr.find(L" ") != std::wstring::npos) return false;
if (expr.find(L";") != std::wstring::npos) return false;
boost::wsmatch match;
if (boost::regex_search(expr, match, boost::wregex(L"([\\w]+\\!)?\\$?[a-zA-Z]+\\$?\\d+(\\:\\$?[a-zA-Z]+\\$?\\d+)?")))
{
return true;
}
return false;
}
void oox2odf_converter::Impl::replace_named_ref(std::wstring & expr)
{
@ -644,6 +662,11 @@ std::wstring oox2odf_converter::convert_named_formula(const std::wstring& expr)
impl_->replace_named_formula(workstr);
return workstr;
}
bool oox2odf_converter::is_simple_ref(std::wstring const & expr)
{
return impl_->is_simple_ref(expr);
}
std::wstring oox2odf_converter::get_table_name()
{
return impl_->table_name_;

View File

@ -694,7 +694,7 @@ void docx_conversion_context::end_document()
output_document_->get_word_files().set_comments ( comments_context_);
output_document_->get_word_files().set_headers_footers( headers_footers_);
package::xl_drawings_ptr drawings = package::xl_drawings::create(chart_drawing_handle_->content());
package::xl_drawings_ptr drawings = package::xl_drawings::create(chart_drawing_handle_->content(), chart_drawing_handle_->content_vml());
output_document_->get_word_files().set_drawings(drawings);
package::content_types_file & content_file_ = output_document_->get_content_types_file();

View File

@ -73,7 +73,7 @@ std::pair<float, float> GetMaxDigitSizePixelsImpl(const std::wstring & fontName,
//if (FALSE == (hr = pFontManager->LoadString2( std::to_wstring(i), 0, 0)))
// return std::pair<float, float>(7,8);
if (FALSE == (hr = pFontManager->LoadString2( L"xxxxx" , 0, 0)))
if (FALSE == (hr = pFontManager->LoadString2( L"0123456789abcdefghijklmnopqrstuvwxyz" , 0, 0)))
return std::pair<float, float>(7,8);
TBBox box;
@ -96,7 +96,7 @@ std::pair<float, float> GetMaxDigitSizePixelsImpl(const std::wstring & fontName,
if (box.fMaxY - box.fMinY < minHeight) minHeight = box.fMaxY - box.fMinY;
}
double width = (minWidth + 2 * maxWidth) /3. /5.;
double width = (minWidth + 2 * maxWidth) /36. /3.;
return std::pair<float, float>(width, maxHeight);
}

View File

@ -131,7 +131,16 @@ static const std::wstring _ooxDashStyle[]=
L"dashDot",
L"sysDashDotDot"
};
static const std::wstring _vmlDashStyle[]=
{
L"none",
L"solid",
L"dot",
L"dash",
L"dash",
L"dashdot",
L"shortdashdotdot"
};
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":");
@ -152,7 +161,7 @@ void oox_serialize_ln(std::wostream & strm, const std::vector<odf_reader::_prope
odf_reader::GetProperty(prop, L"stroke" , iStroke);
odf_reader::GetProperty(prop, L"stroke-width" , dStrokeWidth);
odf_reader::GetProperty(prop, L"stroke-opacity" , dStrokeOpacity);
if ((!strStrokeColor && !iStroke && !dStrokeWidth) && !always_draw)return;
CP_XML_WRITER(strm)
@ -224,6 +233,69 @@ void oox_serialize_ln(std::wostream & strm, const std::vector<odf_reader::_prope
}
}
}
void vml_serialize_ln(std::wostream & strm, const std::vector<odf_reader::_property> & prop)
{
_CP_OPT(std::wstring) strStrokeColor;
_CP_OPT(int) iStroke;
_CP_OPT(double) dStrokeWidth;
_CP_OPT(double) dStrokeOpacity;
_CP_OPT(bool) bWordArt;
odf_reader::GetProperty(prop, L"wordArt", bWordArt);
odf_reader::GetProperty(prop, L"stroke-color" , strStrokeColor);
odf_reader::GetProperty(prop, L"stroke" , iStroke);
odf_reader::GetProperty(prop, L"stroke-width" , dStrokeWidth);
odf_reader::GetProperty(prop, L"stroke-opacity" , dStrokeOpacity);
if (!strStrokeColor && !iStroke && !dStrokeWidth) return;
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"v:stroke")
{
std::wstring color, dash_style ;
if (strStrokeColor) color = *strStrokeColor;
if (iStroke)
{
if (iStroke.get() != 0 ) dash_style = _vmlDashStyle[iStroke.get()];
}
if ((dStrokeWidth) && (*dStrokeWidth >= 0))
{
int val = dStrokeWidth.get() * 12700; //in emu (1 pt = 12700)
if (val < 10) val = 12700;
CP_XML_ATTR(L"weight", val);
}
if (false == color.empty())
{
CP_XML_ATTR(L"color", L"#" + color);
}
if (!dash_style.empty() && dash_style != L"solid")
{
CP_XML_ATTR(L"dashstyle", dash_style);
}
//odf_reader::GetProperty(prop,L"marker-start", strVal);
//if (strVal)
//{
//}
//odf_reader::GetProperty(prop,L"marker-end",strVal);
//if (strVal)
//{
//}
CP_XML_ATTR(L"startarrow", L"block");
CP_XML_ATTR(L"startarrowwidth", L"medium");
CP_XML_ATTR(L"startarrowlength", L"medium");
CP_XML_ATTR(L"joinstyle", L"round");
CP_XML_ATTR(L"endcap", L"flat");
}
}
}
void oox_serialize_aLst(std::wostream & strm, const std::vector<odf_reader::_property> & prop, const std::wstring & shapeGeomPreset, const std::wstring &ns)
{
std::wstring ns_att = (ns == L"a" ? L"" : ns + L":");

View File

@ -124,6 +124,7 @@ namespace oox {
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 vml_serialize_ln (std::wostream & strm, const std::vector<odf_reader::_property> & val);
}
}

View File

@ -245,7 +245,7 @@ void vml_serialize_gradient_fill(std::wostream & strm, const _oox_fill & val)
{
if (!val.gradient->colors.empty())
{
CP_XML_ATTR(L"color2", val.gradient->colors[val.gradient->colors.size() - 1].color_ref);
CP_XML_ATTR(L"color2", L"#" + val.gradient->colors[val.gradient->colors.size() - 1].color_ref);
std::wstring colors_value;
for (size_t i = 0; i < val.gradient->colors.size(); i++)
@ -404,6 +404,27 @@ void vml_serialize_background (std::wostream & strm, const _oox_fill & val, cons
}
}
void vml_serialize_fill (std::wostream & strm, const _oox_fill & val)
{
switch (val.type)
{
case 0:
break;
case 1:
vml_serialize_solid_fill(strm, val);
break;
case 2:
vml_serialize_bitmap_fill(strm, val);
break;
case 3:
vml_serialize_gradient_fill(strm, val);
break;
case 4:
//vml_serialize_hatch_fill(strm, val);
break;
}
}
void oox_serialize_fill (std::wostream & strm, const _oox_fill & val, const std::wstring &ns)
{
switch (val.type)

View File

@ -154,5 +154,6 @@ namespace oox {
void oox_serialize_bitmap_fill (std::wostream & strm, const _oox_fill & val, const std::wstring &ns = L"a");
void oox_serialize_fill (std::wostream & strm, const _oox_fill & val, const std::wstring &ns = L"a");
void vml_serialize_fill (std::wostream & strm, const _oox_fill & val);
}
}

View File

@ -51,7 +51,7 @@ public:
{
}
std::pair<std::wstring, std::wstring> add_comments_xml(std::wstring const & content,pptx_comments_ptr comments)
std::pair<std::wstring, std::wstring> add_comments_xml(std::wstring const & content, pptx_comments_ptr comments)
{
const std::wstring file_id = std::to_wstring(next_file_id_++);

View File

@ -39,14 +39,14 @@
namespace cpdoccore {
namespace oox {
unsigned int hex_string_to_int(std::wstring str)
{
unsigned int x;
std::wstringstream ss;
ss << std::hex << str;
ss >> x;
return x;
}
unsigned int hex_string_to_int(std::wstring str)
{
unsigned int x;
std::wstringstream ss;
ss << std::hex << str;
ss >> x;
return x;
}
class xlsx_comments::Impl
{
@ -94,127 +94,6 @@ public:
}
}
}
void serialize_vml(std::wostream & strm) const
{
_CP_OPT(std::wstring) strVal;
_CP_OPT(double) dVal;
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"xml")
{
CP_XML_ATTR(L"xmlns:v", L"urn:schemas-microsoft-com:vml");
CP_XML_ATTR(L"xmlns:o", L"urn:schemas-microsoft-com:office:office");
CP_XML_ATTR(L"xmlns:x", L"urn:schemas-microsoft-com:office:excel");
for (size_t i = 0; i < xlsx_comment_.size(); i++)
{
const _xlsx_comment & c = xlsx_comment_[i];
std::wstring str_fill_color_ = L"00003f";
if (odf_reader::GetProperty(c.graphicProperties_,L"fill-color",strVal))
str_fill_color_ = strVal.get();
CP_XML_NODE(L"v:shapetype")
{
CP_XML_ATTR(L"id", L"shapetype_202");
CP_XML_ATTR(L"coordsize", L"21600,21600");
CP_XML_ATTR(L"o:spt", L"202");
CP_XML_ATTR(L"path", L"m,l,21600l21600,21600l21600,xe");
CP_XML_NODE(L"v:stroke")
{
CP_XML_ATTR(L"joinstyle", L"miter");
}
CP_XML_NODE(L"v:path")
{
CP_XML_ATTR(L"gradientshapeok", L"t");
CP_XML_ATTR(L"o:connecttype", L"rect");
}
}
CP_XML_NODE(L"v:shape")
{
if( hex_string_to_int(str_fill_color_) !=0 )
{
CP_XML_ATTR(L"fillcolor", std::wstring(L"#") + str_fill_color_);
}//иначе это полная прозрачность
CP_XML_ATTR(L"id", L"shape_0");
std::wstring style = std::wstring(L"position:absolute;");
style += std::wstring(L"margin-left:") + boost::lexical_cast<std::wstring>(c.left_) + std::wstring(L"pt;");
style += std::wstring(L"margin-top:") + boost::lexical_cast<std::wstring>(c.top_) + std::wstring(L"pt;");
style += std::wstring(L"width:") + boost::lexical_cast<std::wstring>(c.width_) + std::wstring(L"pt;");
style += std::wstring(L"height:") + boost::lexical_cast<std::wstring>(c.height_) + std::wstring(L"pt;");
if (c.visibly_ == false)style += std::wstring(L"visibility:hidden;");
CP_XML_ATTR(L"style",style);
CP_XML_ATTR(L"type", L"shapetype_202");
//if (odf_reader::GetProperty(c.graphicProperties_,L"opacity",dVal))
//{
// CP_XML_ATTR(L"opacity", boost::lexical_cast<std::wstring>((int)(100.-dVal.get())) + L"%");
//}
//CP_XML_NODE(L"v:shadow")
//{
// CP_XML_ATTR(L"color", L"black");
// CP_XML_ATTR(L"obscured", L"t");
// CP_XML_ATTR(L"on", L"t");
//}
CP_XML_NODE(L"v:wrap")
{
CP_XML_ATTR(L"v:type", L"none");
}
CP_XML_NODE(L"v:fill")
{
CP_XML_ATTR(L"detectmouseclick", L"t");
if( hex_string_to_int(str_fill_color_) !=0 )
{
CP_XML_ATTR(L"color", std::wstring(L"#") + str_fill_color_);
CP_XML_ATTR(L"color2", std::wstring(L"#") + str_fill_color_);
CP_XML_ATTR(L"type", L"solid");
}//иначе это полная прозрачность
//if (odf_reader::GetProperty(c.graphicProperties_,L"opacity",dVal))
//{
// CP_XML_ATTR(L"opacity", (dVal.get())/100.);
// //CP_XML_ATTR(L"opacity2",(dVal.get())/100.);
//}
}
CP_XML_NODE(L"v:stroke")
{
if (odf_reader::GetProperty(c.graphicProperties_,L"stroke-color",strVal))
CP_XML_ATTR(L"color", std::wstring(L"#") + strVal.get());
else
CP_XML_ATTR(L"color",L"#3465af"); //синенький
if (odf_reader::GetProperty(c.graphicProperties_,L"stroke-opacity",dVal))
{
CP_XML_ATTR(L"opacity",(100.-dVal.get())/100.);
}
CP_XML_ATTR(L"endcap", L"flat");
CP_XML_ATTR(L"joinstyle", L"round");
CP_XML_ATTR(L"startarrow", L"block");
CP_XML_ATTR(L"v:startarrowwidth", L"medium");
CP_XML_ATTR(L"startarrowlength", L"medium");
}
CP_XML_NODE(L"x:ClientData")
{
CP_XML_ATTR(L"ObjectType", L"Note");
CP_XML_NODE(L"x:MoveWithCells"){}
CP_XML_NODE(L"x:SizeWithCells"){}
CP_XML_NODE(L"x:AutoFill"){CP_XML_CONTENT("False");}
CP_XML_NODE(L"x:Row"){CP_XML_CONTENT(c.row_);}
CP_XML_NODE(L"x:Column"){CP_XML_CONTENT(c.col_);}
}
}
}
}
}
}
bool empty() const
{
return ( xlsx_comment_.empty());
@ -264,11 +143,6 @@ void xlsx_serialize(std::wostream & _Wostream, xlsx_comments const & val)
val.impl_->serialize(_Wostream);
}
void xlsx_serialize_vml(std::wostream & _Wostream, xlsx_comments const & val)
{
val.impl_->serialize_vml(_Wostream);
}
xlsx_comments_ptr xlsx_comments::create()
{
return boost::make_shared<xlsx_comments>();

View File

@ -42,38 +42,24 @@ namespace oox {
struct _xlsx_comment
{
size_t left_, top_;
size_t width_, height_;
std::wstring ref_;
int col_;
int row_;
bool visibly_;
std::vector<odf_reader::_property> graphicProperties_;
std::wstring author_;
std::wstring content_;
};
//class rels;
class xlsx_comments;
typedef _CP_PTR(xlsx_comments) xlsx_comments_ptr;
struct comment_elm
{
comment_elm(std::wstring const & _filename, std::wstring const & _vml_filename, std::wstring const & _content, std::wstring const & _vml_content, xlsx_comments_ptr _comments)
: filename(_filename), content(_content), comments(_comments),vml_filename(_vml_filename),vml_content(_vml_content)
comment_elm(std::wstring const & _filename, std::wstring const & _content, xlsx_comments_ptr _comments)
: filename(_filename), content(_content), comments(_comments)
{}
xlsx_comments_ptr comments;
std::wstring filename;
std::wstring content;
std::wstring vml_filename;
std::wstring vml_content;
};
class xlsx_comments
@ -87,10 +73,7 @@ public:
void add(_xlsx_comment & d);
bool empty() const;
friend void docx_serialize(std::wostream & _Wostream, xlsx_comments const & val);
friend void xlsx_serialize(std::wostream & _Wostream, xlsx_comments const & val);
friend void xlsx_serialize_vml(std::wostream & _Wostream, xlsx_comments const & val);
private:
class Impl;

View File

@ -36,7 +36,6 @@
#include "../odf/datatypes/length.h"
#include "xlsx_utils.h"
//#include <formulasconvert.h>
namespace cpdoccore { namespace oox {
@ -46,32 +45,22 @@ typedef _CP_PTR(xlsx_comments) xlsx_comments_ptr;
class xlsx_comments_context_handle::Impl
{
public:
Impl()
: next_comments_id_(1) ,next_file_id_(1)
Impl() : next_comments_id_(1), next_file_id_(1)
{
}
std::pair<std::wstring, std::wstring> add_comments_xml(std::wstring const & content, std::wstring const & vml_content,xlsx_comments_ptr comments)
std::pair<std::wstring, std::wstring> add_comments_xml(std::wstring const & content, xlsx_comments_ptr comments)
{
const std::wstring file_id = std::to_wstring(next_file_id_++);
const std::wstring file_id = std::to_wstring(next_file_id_++);
const std::wstring fileName = std::wstring(L"comments") + file_id + L".xml";
const std::wstring vml_fileName = std::wstring(L"vmlDrawing") + file_id + L".vml";
comments_.push_back(comment_elm(fileName,vml_fileName, content, vml_content, comments));
comments_.push_back(comment_elm(fileName, content, comments));
const std::wstring id = std::to_wstring(next_comments_id_++);
const std::wstring rId = std::wstring(L"comId") + id;
return std::pair<std::wstring, std::wstring>(fileName, rId);
}
std::pair<std::wstring, std::wstring> get_vml_drawing_xml()
{
const std::wstring id = std::to_wstring(next_comments_id_++);
const std::wstring rId = std::wstring(L"comId") + id;
return std::pair<std::wstring, std::wstring>(comments_.back().vml_filename, rId);
}
const std::vector<comment_elm> & content() const
{
return comments_;
@ -89,25 +78,17 @@ xlsx_comments_context_handle::xlsx_comments_context_handle()
: impl_(new xlsx_comments_context_handle::Impl())
{
}
xlsx_comments_context_handle::~xlsx_comments_context_handle()
{
}
std::pair<std::wstring, std::wstring> xlsx_comments_context_handle::add_comments_xml(std::wstring const & content, std::wstring const & vml_content,xlsx_comments_ptr comments)
std::pair<std::wstring, std::wstring> xlsx_comments_context_handle::add_comments_xml(std::wstring const & content, xlsx_comments_ptr comments)
{
return impl_->add_comments_xml(content,vml_content, comments);
return impl_->add_comments_xml(content, comments);
}
std::pair<std::wstring, std::wstring> xlsx_comments_context_handle::get_vml_drawing_xml()
{
return impl_->get_vml_drawing_xml();
}
const std::vector<comment_elm> & xlsx_comments_context_handle::content() const
{
return impl_->content();
}
class xlsx_comments_context::Impl
{
public:
@ -127,10 +108,6 @@ public:
{
xlsx_serialize(strm, *xlsx_comments_);
}
void serialize_vml(std::wostream & strm)
{
xlsx_serialize_vml(strm, *xlsx_comments_);
}
bool empty() const
{
return xlsx_comments_->empty();
@ -154,40 +131,20 @@ xlsx_comments_context::~xlsx_comments_context()
{
}
void xlsx_comments_context::start_comment (double width_pt, double height_pt, double x_pt, double y_pt)
void xlsx_comments_context::start_comment(const std::wstring & ref)
{
impl_->current_.ref_ = L"";
impl_->current_.width_ = width_pt;
impl_->current_.height_ = height_pt;
impl_->current_.left_ = x_pt;
impl_->current_.top_ = y_pt;
impl_->current_.visibly_ = false;
impl_->current_.ref_ = ref;
}
void xlsx_comments_context::add_content(std::wstring content)
void xlsx_comments_context::add_content(const std::wstring & content)
{
impl_->current_.content_ = content;
}
void xlsx_comments_context::add_author(std::wstring author)
void xlsx_comments_context::add_author(const std::wstring & author)
{
impl_->current_.author_ = author;
}
void xlsx_comments_context::set_visibly(bool Val)
void xlsx_comments_context::end_comment()
{
impl_->current_.visibly_ = Val;
}
std::vector<odf_reader::_property> & xlsx_comments_context::get_draw_properties()
{
return impl_->current_.graphicProperties_;
}
void xlsx_comments_context::end_comment(std::wstring ref,int col, int row)
{
impl_->current_.ref_ = ref;
impl_->current_.col_ = col;
impl_->current_.row_ = row;
impl_->add_comment(impl_->current_);
}
@ -200,11 +157,6 @@ void xlsx_comments_context::serialize(std::wostream & strm)
{
impl_->serialize(strm);
}
void xlsx_comments_context::serialize_vml(std::wostream & strm)
{
impl_->serialize_vml(strm);
}
xlsx_comments_ptr xlsx_comments_context::get_comments()
{
return impl_->get_comments();

View File

@ -45,16 +45,13 @@ class xlsx_table_metrics;
class xlsx_comments;
typedef _CP_PTR(xlsx_comments) xlsx_comments_ptr;
class xlsx_comments_context_handle
{
public:
xlsx_comments_context_handle();
~xlsx_comments_context_handle();
std::pair<std::wstring, std::wstring> add_comments_xml(std::wstring const & content, std::wstring const & vml_content,xlsx_comments_ptr comments);
std::pair<std::wstring, std::wstring> get_vml_drawing_xml();
std::pair<std::wstring, std::wstring> add_comments_xml(std::wstring const & content, xlsx_comments_ptr comments);
const std::vector<comment_elm> & content() const;
friend class xlsx_comments_context;
@ -72,21 +69,16 @@ public:
xlsx_comments_context(xlsx_comments_context_handle & h);
~xlsx_comments_context();
void start_comment(double width_pt, double height_pt, double x_pt, double y_pt);
void start_comment(const std::wstring & ref);
void add_content(std::wstring content);
void add_author(std::wstring author);
void add_content(const std::wstring & content);
void add_author(const std::wstring & author);
std::vector<odf_reader::_property> & get_draw_properties();
void set_visibly(bool Val);
void end_comment(std::wstring ref,int col,int row);
void end_comment();
bool empty() const;
void serialize (std::wostream & strm);
void serialize_vml (std::wostream & strm);
void serialize (std::wostream & strm);
xlsx_comments_ptr get_comments();
private:

View File

@ -35,6 +35,30 @@
#include <xml/utils.h>
#include "../odf/datatypes/custom_shape_types_convert.h"
#include "../../formulasconvert/formulasconvert.h"
#define OBJ_Group 0x0000
#define OBJ_Line 0x0001
#define OBJ_Rectangle 0x0002
#define OBJ_Oval 0x0003
#define OBJ_Arc 0x0004
#define OBJ_Text 0x0006
#define OBJ_OfficeArt 0x001E
#define OBJ_Polygon 0x0009
#define OBJ_Picture 0x0008
#define OBJ_Chart 0x0005
#define OBJ_Button 0x0007
#define OBJ_CheckBox 0x000B
#define OBJ_RadioButton 0x000C
#define OBJ_EditBox 0x000D
#define OBJ_Label 0x000E
#define OBJ_DialogBox 0x000F
#define OBJ_SpinControl 0x0010
#define OBJ_Scrollbar 0x0011
#define OBJ_List 0x0012
#define OBJ_GroupBox 0x0013
#define OBJ_DropdownList 0x0014
#define OBJ_Note 0x0019
namespace cpdoccore {
namespace oox {
@ -48,7 +72,7 @@ std::wostream & operator << (std::wostream & strm, xlsx_drawing_position::type_t
}
}
void xlsx_serialize_text(std::wostream & strm, _xlsx_drawing & val, const std::wstring & ns)
void xml_serialize_text(std::wostream & strm, _xlsx_drawing & val, const std::wstring & ns)
{
_CP_OPT(std::wstring) strTextContent;
odf_reader::GetProperty ( val.additional, L"text-content", strTextContent);
@ -71,11 +95,17 @@ void xlsx_serialize_text(std::wostream & strm, _xlsx_drawing & val, const std::w
}
}
void xlsx_drawing_position::serialize(std::wostream & strm, const std::wstring & ns)
std::wstring xlsx_drawing_position::vml_serialize()
{
//emu -> pt = 1 / 12700 = 72.0 / (360000.0 * 2.54);
return std::to_wstring(position.col) + L"," + std::to_wstring((int)(position.colOff / 12700)) + L"," +
std::to_wstring(position.row) + L"," + std::to_wstring((int)(position.rowOff / 12700));
}
void xlsx_drawing_position::serialize(std::wostream & strm, const std::wstring & ns_title, const std::wstring & ns)
{
CP_XML_WRITER(strm)
{
CP_XML_NODE( ns + (ns.empty() ? L"" : L":") + (type == xlsx_drawing_position::from ? L"from" : L"to") )
CP_XML_NODE( ns_title + (ns_title.empty() ? L"" : L":") + (type == xlsx_drawing_position::from ? L"from" : L"to") )
{
CP_XML_NODE(ns + (ns.empty() ? L"" : L":") + L"col")
{
@ -100,7 +130,7 @@ void xlsx_drawing_position::serialize(std::wostream & strm, const std::wstring &
}
}
void xlsx_serialize_image(std::wostream & strm, _xlsx_drawing & val, const std::wstring & ns)
void xml_serialize_image(std::wostream & strm, _xlsx_drawing & val, const std::wstring & ns)
{
CP_XML_WRITER(strm)
{
@ -139,12 +169,12 @@ void xlsx_serialize_image(std::wostream & strm, _xlsx_drawing & val, const std::
}
oox_serialize_ln(CP_XML_STREAM(), val.additional);
}
xlsx_serialize_text(CP_XML_STREAM(), val, ns);
xml_serialize_text(CP_XML_STREAM(), val, ns);
}
} // CP_XML_WRITER
}
void xlsx_serialize_shape(std::wostream & strm, _xlsx_drawing & val, const std::wstring & ns)
void xml_serialize_shape(std::wostream & strm, _xlsx_drawing & val, const std::wstring & ns)
{
CP_XML_WRITER(strm)
{
@ -174,11 +204,11 @@ void xlsx_serialize_shape(std::wostream & strm, _xlsx_drawing & val, const std::
oox_serialize_ln(CP_XML_STREAM(),val.additional, val.lined);
} // xdr:spPr
xlsx_serialize_text(CP_XML_STREAM(), val, ns);
xml_serialize_text(CP_XML_STREAM(), val, ns);
}
} // CP_XML_WRITER
}
void xlsx_serialize_object(std::wostream & strm, _xlsx_drawing & val)
void xml_serialize_object(std::wostream & strm, _xlsx_drawing & val)
{//отображательная часть
CP_XML_WRITER(strm)
{
@ -206,7 +236,7 @@ void xlsx_serialize_object(std::wostream & strm, _xlsx_drawing & val)
}
}
}
void xlsx_serialize_group(std::wostream & strm, _xlsx_drawing & val, const std::wstring & ns)
void xml_serialize_group(std::wostream & strm, _xlsx_drawing & val, const std::wstring & ns)
{
CP_XML_WRITER(strm)
{
@ -231,7 +261,7 @@ void xlsx_serialize_group(std::wostream & strm, _xlsx_drawing & val, const std::
}
}
void xlsx_serialize_chart(std::wostream & strm, _xlsx_drawing & val)
void xml_serialize_chart(std::wostream & strm, _xlsx_drawing & val)
{//отображательная часть
CP_XML_WRITER(strm)
{
@ -266,36 +296,37 @@ void xlsx_serialize_chart(std::wostream & strm, _xlsx_drawing & val)
}
}
}
void xlsx_serialize(std::wostream & strm, _xlsx_drawing & val, const std::wstring & ns)
void xml_serialize(std::wostream & strm, _xlsx_drawing & val, const std::wstring & ns)
{
if (val.type == typeShape)
{
xlsx_serialize_shape(strm, val, ns);
xml_serialize_shape(strm, val, ns);
}
else if (val.type == typeImage)
{
xlsx_serialize_image(strm, val, ns);
xml_serialize_image(strm, val, ns);
}
else if (val.type == typeChart)
{
xlsx_serialize_chart(strm, val);
xml_serialize_chart(strm, val);
}
else if (val.type == typeGroupShape)
{
xlsx_serialize_group(strm, val, ns);
xml_serialize_group(strm, val, ns);
}
else if (val.type == typeOleObject ||
val.type == typeMsObject ||
val.type == typeControl)
{
xlsx_serialize_object(strm, val);
xml_serialize_object(strm, val);
}
}
void _xlsx_drawing::serialize(std::wostream & strm, const std::wstring & ns)
{
if (inGroup)
return xlsx_serialize(strm, *this, ns);
return xml_serialize(strm, *this, ns);
CP_XML_WRITER(strm)
{
@ -308,7 +339,7 @@ void _xlsx_drawing::serialize(std::wostream & strm, const std::wstring & ns)
from_.serialize (CP_XML_STREAM());
to_.serialize (CP_XML_STREAM());
xlsx_serialize (CP_XML_STREAM(), *this, ns);
xml_serialize (CP_XML_STREAM(), *this, ns);
CP_XML_NODE(ns + L":clientData");
}
}
@ -326,7 +357,7 @@ void _xlsx_drawing::serialize(std::wostream & strm, const std::wstring & ns)
CP_XML_ATTR(L"cx", cx);
CP_XML_ATTR(L"cy", cy);
}
xlsx_serialize(CP_XML_STREAM(), *this, ns);
xml_serialize(CP_XML_STREAM(), *this, ns);
CP_XML_NODE(ns + L":clientData");
}
}
@ -359,14 +390,12 @@ void _xlsx_drawing::serialize(std::wostream & strm, const std::wstring & ns)
CP_XML_STREAM() << ((double)y1 / *owner_cy_);
}
}
xlsx_serialize(CP_XML_STREAM(), *this, ns);
xml_serialize(CP_XML_STREAM(), *this, ns);
}
}
}
}
void _xlsx_drawing::serialize_object (std::wostream & strm)
{
if (type != typeOleObject && type != typeMsObject) return;
@ -390,9 +419,8 @@ void _xlsx_drawing::serialize_object (std::wostream & strm)
{
CP_XML_ATTR(L"moveWithCells", 1);
from_.serialize (CP_XML_STREAM(), L"");
to_.serialize (CP_XML_STREAM(), L"");
from_.serialize (CP_XML_STREAM(), L"", L"");
to_.serialize (CP_XML_STREAM(), L"", L"");
}
}
}
@ -422,8 +450,8 @@ void _xlsx_drawing::serialize_control (std::wostream & strm)
{
CP_XML_ATTR(L"moveWithCells", 1);
from_.serialize (CP_XML_STREAM(), L"");
to_.serialize (CP_XML_STREAM(), L"");
from_.serialize (CP_XML_STREAM(), L"", L"xdr");
to_.serialize (CP_XML_STREAM(), L"", L"xdr");
}
}
@ -431,6 +459,164 @@ void _xlsx_drawing::serialize_control (std::wostream & strm)
}
}
void _xlsx_drawing::serialize_vml(std::wostream & strm)
{
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"v:shape")
{
CP_XML_ATTR(L"id", L"_x0000_s" + std::to_wstring(id));
CP_XML_ATTR(L"type", sub_type == 9 ? L"#_x0000_t202" : L"#_x0000_t201");
std::wstring color;
if (fill.solid)
color = fill.solid->color;
if (!color.empty())
CP_XML_ATTR(L"fillcolor", L"#" + color);
CP_XML_ATTR(L"stroked", /*lined ? */L"t"/* : L"f"*/);
std::wstring style = L"position:absolute";
//style +="margin-left:414.3pt;margin-top:70.2pt;width:144.15pt;height:96.75pt";
CP_XML_ATTR(L"style", style);
CP_XML_NODE(L"v:shadow")
{
CP_XML_ATTR(L"on", L"t");
CP_XML_ATTR(L"obscured", L"t");
CP_XML_ATTR(L"color", L"black");
}
CP_XML_NODE(L"w10:wrap")
{
CP_XML_ATTR(L"type", L"none");
}
vml_serialize_fill(CP_XML_STREAM(), fill);
vml_serialize_ln(CP_XML_STREAM(), additional);
CP_XML_NODE(L"x:ClientData")
{
switch(sub_type)
{
case OBJ_Button: CP_XML_ATTR(L"ObjectType", L"Button"); break;
case OBJ_CheckBox: CP_XML_ATTR(L"ObjectType", L"Checkbox");break;
case OBJ_RadioButton: CP_XML_ATTR(L"ObjectType", L"Radio"); break;
case OBJ_EditBox: CP_XML_ATTR(L"ObjectType", L"Edit"); break;
case OBJ_Label: CP_XML_ATTR(L"ObjectType", L"Label"); break;
case OBJ_DialogBox: CP_XML_ATTR(L"ObjectType", L"Dialog"); break;
case OBJ_SpinControl: CP_XML_ATTR(L"ObjectType", L"Spin"); break;
case OBJ_Scrollbar: CP_XML_ATTR(L"ObjectType", L"Scroll"); break;
case OBJ_List: CP_XML_ATTR(L"ObjectType", L"List"); break;
case OBJ_DropdownList: CP_XML_ATTR(L"ObjectType", L"List"); break;
case OBJ_Note: CP_XML_ATTR(L"ObjectType", L"Note"); break;
}
CP_XML_NODE(L"x:MoveWithCells");
CP_XML_NODE(L"x:SizeWithCells");
CP_XML_NODE(L"x:Anchor")
{
CP_XML_STREAM() << from_.vml_serialize() << L"," << to_.vml_serialize();
}
CP_XML_NODE(L"x:AutoFill")
{
CP_XML_STREAM() << L"False";
}
_CP_OPT(int) base_col, base_row;
GetProperty(additional, L"base_col", base_col);
GetProperty(additional, L"base_row", base_row);
if (base_row)
{
CP_XML_NODE(L"x:Row")
{
CP_XML_STREAM() << *base_row;
}
}
if (base_col)
{
CP_XML_NODE(L"x:Column")
{
CP_XML_STREAM() << *base_col;
}
}
_CP_OPT(std::wstring) sVal;
GetProperty(additional, L"linked_cell", sVal);
if (sVal)
{
formulasconvert::odf2oox_converter converter;
std::wstring fmla = converter.convert_named_ref(*sVal);
CP_XML_NODE(L"x:FmlaLink")
{
CP_XML_STREAM() << fmla;
}
}
_CP_OPT(bool) visible;
GetProperty(additional, L"visible", visible);
if ((visible) && (*visible == false))
{
CP_XML_NODE(L"x:Visible")
{
CP_XML_STREAM() << L"False";
}
}
else
CP_XML_NODE(L"x:Visible");
_CP_OPT(int) nVal;
GetProperty(additional, L"min_value", nVal);
if (nVal)
{
CP_XML_NODE(L"x:Min")
{
CP_XML_STREAM() << *nVal;
}
}
GetProperty(additional, L"max_value", nVal);
if (nVal)
{
CP_XML_NODE(L"x:Max")
{
CP_XML_STREAM() << *nVal;
}
}
GetProperty(additional, L"step", nVal);
if (nVal)
{
CP_XML_NODE(L"x:Inc")
{
CP_XML_STREAM() << *nVal;
}
}
GetProperty(additional, L"page_step", nVal);
if (nVal)
{
CP_XML_NODE(L"x:Page")
{
CP_XML_STREAM() << *nVal;
}
}
GetProperty(additional, L"value", sVal);
if (sVal)
{
CP_XML_NODE(L"x:Val")
{
CP_XML_STREAM() << *sVal;
}
}
GetProperty(additional, L"orientation", sVal);
if (sVal)
{
if (*sVal == L"horizontal") CP_XML_NODE(L"x:Horiz");
else CP_XML_NODE(L"x:Vert");
}
}
}
}
}
}
}

View File

@ -49,10 +49,10 @@ struct xlsx_drawing_position
enum type_t {from, to} type;
xlsx_table_position position;
void serialize(std::wostream & _Wostream, const std::wstring & ns = L"xdr");
void serialize(std::wostream & _Wostream, const std::wstring & ns_title = L"xdr", const std::wstring & ns = L"xdr");
std::wstring vml_serialize();
};
class _xlsx_drawing : public _oox_drawing
{
public:
@ -71,6 +71,7 @@ public:
virtual void serialize (std::wostream & strm) {return serialize(strm, L"xdr");}
void serialize (std::wostream & strm, const std::wstring & ns);
void serialize_vml (std::wostream & strm);
void serialize_object (std::wostream & strm);
void serialize_control (std::wostream & strm);
};

View File

@ -53,15 +53,21 @@ namespace oox {
class xlsx_drawing_context_handle::Impl
{
public:
Impl(mediaitems_ptr & items) : items_(items), next_rId_(1), next_drawing_id_(1)
Impl(mediaitems_ptr & items) : items_(items), next_drawing_id_(1), next_vml_drawing_id_(1)
{
}
mediaitems_ptr & get_mediaitems() { return items_; }
size_t next_rId()
std::pair<std::wstring, std::wstring> add_drawing_vml(std::wstring const & content, xlsx_drawings_ptr drawings)
{
return next_rId_++;
const std::wstring id = std::to_wstring(next_vml_drawing_id_++);
const std::wstring fileName = std::wstring(L"vmlDrawing") + id + L".vml";
drawings_vml_.push_back(drawing_elm(fileName, content, drawings, typeDefault));
const std::wstring rId = std::wstring(L"rVId") + id;
return std::pair<std::wstring, std::wstring>(fileName, rId);
}
std::pair<std::wstring, std::wstring> add_drawing_xml(std::wstring const & content, xlsx_drawings_ptr drawings, RelsType const & type_)
@ -75,20 +81,26 @@ public:
return std::pair<std::wstring, std::wstring>(fileName, rId);
}
const std::vector<drawing_elm> & content() const
{
return drawings_;
}
const std::vector<drawing_elm> & content() const
{
return drawings_;
}
const std::vector<drawing_elm> & content_vml() const
{
return drawings_vml_;
}
private:
mediaitems_ptr items_;
std::vector<drawing_elm> drawings_;
std::vector<drawing_elm> drawings_;
std::vector<drawing_elm> drawings_vml_;
size_t next_rId_;
size_t next_drawing_id_;
size_t next_vml_drawing_id_;
};
xlsx_drawing_context_handle::xlsx_drawing_context_handle(mediaitems_ptr & items) :
impl_(new xlsx_drawing_context_handle::Impl(items))
next_rId_(1), impl_(new xlsx_drawing_context_handle::Impl(items))
{
}
@ -100,12 +112,19 @@ std::pair<std::wstring, std::wstring> xlsx_drawing_context_handle::add_drawing_x
{
return impl_->add_drawing_xml(content, drawings, type_);
}
std::pair<std::wstring, std::wstring> xlsx_drawing_context_handle::add_drawing_vml(std::wstring const & content, xlsx_drawings_ptr drawings)
{
return impl_->add_drawing_vml(content, drawings);
}
const std::vector<drawing_elm> & xlsx_drawing_context_handle::content() const
{
return impl_->content();
}
const std::vector<drawing_elm> & xlsx_drawing_context_handle::content_vml() const
{
return impl_->content_vml();
}
class xlsx_drawing_context::Impl
{
public:
@ -131,15 +150,21 @@ public:
{
xlsx_drawings_->serialize(strm, ns);
}
void serialize_vml(std::wostream & strm)
{
xlsx_drawings_->serialize_vml(strm);
}
bool empty() const
{
return xlsx_drawings_->empty();
}
bool vml_empty() const
{
return xlsx_drawings_->vml_empty();
}
size_t next_rId()
{
return handle_->impl_->next_rId();
return handle_->next_rId();
}
xlsx_drawings_ptr get_drawings()
@ -282,7 +307,29 @@ void xlsx_drawing_context::end_shape()
{
impl_->current_level_->push_back(impl_->object_description_);
}
void xlsx_drawing_context::start_comment(int base_col, int base_row)
{
impl_->object_description_.type_ = typeComment;
impl_->object_description_.shape_type_ = 19; // OBJ_Note object type for vml
set_property(odf_reader::_property(L"base_col", base_col));
set_property(odf_reader::_property(L"base_row", base_row));
}
void xlsx_drawing_context::end_comment()
{
impl_->current_level_->push_back(impl_->object_description_);
}
void xlsx_drawing_context::start_control(const std::wstring & ctrlPropId, int type)
{
impl_->object_description_.type_ = typeControl;
impl_->object_description_.shape_type_ = type; // object type for vml
impl_->object_description_.xlink_href_ = ctrlPropId;
}
void xlsx_drawing_context::end_control()
{
impl_->current_level_->push_back(impl_->object_description_);
}
void xlsx_drawing_context::set_use_image_replacement()
{
impl_->use_image_replacement_ = true;
@ -305,11 +352,6 @@ void xlsx_drawing_context::set_ms_object(const std::wstring & path, const std::w
impl_->object_description_.xlink_href_ = path;
impl_->object_description_.descriptor_ = progId;
}
void xlsx_drawing_context::set_control(const std::wstring & ctrlPropId)
{
impl_->object_description_.type_ = typeControl;
impl_->object_description_.xlink_href_ = ctrlPropId;
}
void xlsx_drawing_context::set_image(const std::wstring & path)
{
int pos_replaicement = path.find(L"ObjectReplacements");
@ -446,7 +488,10 @@ bool xlsx_drawing_context::empty() const
{
return impl_->empty();
}
bool xlsx_drawing_context::vml_empty() const
{
return impl_->vml_empty();
}
void xlsx_drawing_context::process_common_properties(drawing_object_description & obj, _xlsx_drawing & drawing, xlsx_table_metrics & table_metrics)
{
if (obj.anchor_.empty())
@ -585,7 +630,7 @@ void xlsx_drawing_context::process_image(drawing_object_description & obj, _xlsx
if (drawing.type == typeShape)
{
impl_->get_drawings()->add(isMediaInternal, drawing.fill.bitmap->rId, ref, typeImage);//собственно это не объект, а доп рел и ref объекта
impl_->get_drawings()->add(isMediaInternal, drawing.fill.bitmap->rId, ref, typeImage, false, false);//собственно это не объект, а доп рел и ref объекта
isMediaInternal=true;
std::wstring rId = impl_->get_mediaitems()->add_or_find(L"", typeShape, isMediaInternal, ref);
@ -597,7 +642,7 @@ void xlsx_drawing_context::process_image(drawing_object_description & obj, _xlsx
xlsx_drawings_->add(drawing, isMediaInternal, drawing.fill.bitmap->rId , ref, typeImage);//объект
if (drawing.inGroup)
impl_->get_drawings()->add(isMediaInternal, drawing.fill.bitmap->rId, ref, obj.type_); // не объект
impl_->get_drawings()->add(isMediaInternal, drawing.fill.bitmap->rId, ref, obj.type_, false, false); // не объект
}
}
@ -610,8 +655,9 @@ void xlsx_drawing_context::process_chart(drawing_object_description & obj,_xlsx_
xlsx_drawings_->add(drawing, isMediaInternal, drawing.objectId, ref, obj.type_);
if (drawing.inGroup)
impl_->get_drawings()->add(isMediaInternal, drawing.objectId, ref, obj.type_); // не объект
impl_->get_drawings()->add(isMediaInternal, drawing.objectId, ref, obj.type_, false, false); // не объект
}
void xlsx_drawing_context::process_object(drawing_object_description & obj, xlsx_table_metrics & table_metrics, _xlsx_drawing & drawing, xlsx_drawings_ptr xlsx_drawings_)
{
std::wstring ref;
@ -637,10 +683,11 @@ void xlsx_drawing_context::process_object(drawing_object_description & obj, xlsx
drawing.to_.position.rowOff = static_cast<size_t>(odf_types::length(to.rowOff, odf_types::length::pt).get_value_unit(odf_types::length::emu));
}
if (obj.type_ == typeControl)
if (obj.type_ == typeControl || obj.type_ == typeComment)
{
drawing.objectId = obj.xlink_href_;
xlsx_drawings_->add(drawing, isMediaInternal, drawing.objectId, ref, obj.type_);
xlsx_drawings_->add(drawing, isMediaInternal, drawing.objectId, ref, obj.type_, false);
}
else
{
@ -651,14 +698,14 @@ void xlsx_drawing_context::process_object(drawing_object_description & obj, xlsx
}
if (drawing.inGroup)
impl_->get_drawings()->add(isMediaInternal, drawing.objectId, ref, obj.type_); // не объект
impl_->get_drawings()->add(isMediaInternal, drawing.objectId, ref, obj.type_, false, false); // не объект
}
void xlsx_drawing_context::process_shape(drawing_object_description & obj,_xlsx_drawing & drawing, xlsx_drawings_ptr xlsx_drawings_)
{
std::wstring ref;
bool isMediaInternal = true;
std::wstring rId = impl_->get_mediaitems()->add_or_find(L"", obj.type_, isMediaInternal, ref);
std::wstring rId = impl_->get_mediaitems()->add_or_find(L"", obj.type_, isMediaInternal, ref);
xlsx_drawings_->add(drawing, isMediaInternal, rId, ref, obj.type_);
}
@ -702,7 +749,7 @@ void xlsx_drawing_context::process_group_objects(std::vector<drawing_object_desc
drawing.lined = obj.lined_;
drawing.connector = obj.connector_;
drawing.sub_type = obj.shape_type_;
drawing.sub_type = obj.shape_type_;
if (drawing.fill.bitmap)
{
@ -712,7 +759,7 @@ void xlsx_drawing_context::process_group_objects(std::vector<drawing_object_desc
drawing.fill.bitmap->rId = impl_->get_mediaitems()->add_or_find(drawing.fill.bitmap->xlink_href_, typeImage, isMediaInternal, ref);
bool in_sheet = (obj.type_== typeOleObject || obj.type_== typeMsObject) ? true : false;
impl_->get_drawings()->add(isMediaInternal, drawing.fill.bitmap->rId, ref, typeImage, in_sheet);//собственно это не объект, а доп рел и ref объекта
impl_->get_drawings()->add(isMediaInternal, drawing.fill.bitmap->rId, ref, typeImage, in_sheet, false);//собственно это не объект, а доп рел и ref объекта
//object dumps in sheet rels !!
}
@ -727,8 +774,8 @@ void xlsx_drawing_context::process_group_objects(std::vector<drawing_object_desc
case typeGroupShape: process_group ( obj, table_metrics, drawing, xlsx_drawings_); break;
case typeMsObject:
case typeOleObject:
case typeControl:
process_object ( obj, table_metrics, drawing, xlsx_drawings_); break;
case typeControl:
case typeComment: process_object ( obj, table_metrics, drawing, xlsx_drawings_); break;
}
}
}
@ -737,6 +784,10 @@ void xlsx_drawing_context::serialize(std::wostream & strm, const std::wstring& n
{
impl_->serialize(strm, ns);
}
void xlsx_drawing_context::serialize_vml(std::wostream & strm)
{
impl_->serialize_vml(strm);
}
xlsx_drawings_ptr xlsx_drawing_context::get_drawings()
{

View File

@ -63,10 +63,20 @@ public:
~xlsx_drawing_context_handle();
std::pair<std::wstring, std::wstring> add_drawing_xml(std::wstring const & content, xlsx_drawings_ptr drawings, RelsType const & type_ = typeDefault);
const std::vector<drawing_elm> & content() const;
std::pair<std::wstring, std::wstring> add_drawing_vml(std::wstring const & content, xlsx_drawings_ptr drawings);
const std::vector<drawing_elm> & content() const;
const std::vector<drawing_elm> & content_vml() const;
friend class xlsx_drawing_context;
size_t next_rId()
{
return next_rId_++;
}
private:
size_t next_rId_;
class Impl;
_CP_PTR(Impl) impl_;
};
@ -90,7 +100,6 @@ public:
void end_group ();
void start_shape(int type);
//...пока тока общие свойства ... частные для каждого объекта пооозже
void end_shape();
void start_frame();
@ -98,10 +107,15 @@ public:
void set_chart (const std::wstring & path);
void set_ole_object (const std::wstring & path, const std::wstring & progId);
void set_ms_object (const std::wstring & path, const std::wstring & progId);
void set_control (const std::wstring & ctrlPropId);
void set_text_box ();
void end_frame();
void start_control(const std::wstring & ctrlPropId, int type);
void end_control();
void start_comment(int base_col, int base_row);
void end_comment();
void set_rect(double width_pt, double height_pt, double x_pt, double y_pt);
void set_translate (double x_pt, double y_pt);
@ -110,13 +124,13 @@ public:
void set_rel_anchor (_INT32 owner_cx, _INT32 owner_cy);
void set_anchor (std::wstring anchor, double x_pt, double y_pt, bool group = false);
void set_property (odf_reader::_property p);
void set_clipping (const std::wstring & str );
void set_fill (_oox_fill & fill);
void set_is_line_shape(bool val);
void set_is_connector_shape(bool val);
void set_property (odf_reader::_property p);
std::vector<odf_reader::_property> & get_properties();
std::wstring add_hyperlink(std::wstring const & ref);
@ -124,9 +138,12 @@ public:
void set_use_image_replacement();
bool empty() const;
bool vml_empty() const;
void clear();
void serialize(std::wostream & strm, const std::wstring& ns = L"xdr");
void serialize_vml(std::wostream & strm);
std::wstring dump_path(std::vector<svg_path::_polyline> & path, double w,double h);

View File

@ -46,18 +46,25 @@ class xlsx_drawings::Impl
public:
void add(_xlsx_drawing const & d, bool isInternal, std::wstring const & rid, std::wstring const & ref, RelsType type, bool sheet_rel )//объект
{
xlsx_drawings_.push_back(d);
add (isInternal, rid, ref, type, sheet_rel);
for (size_t i = 0; i < d.hlinks.size(); i++)
{
xlsx_drawing_rels_.push_back(_rel(false, d.hlinks[i].hId, d.hlinks[i].hRef, typeHyperlink));
if (type == typeControl || type == typeControlProps || type == typeComment)
{
vml_drawings_.push_back(d);
add (isInternal, rid, ref, type, sheet_rel, true);
}
else
{
drawings_.push_back(d);
add (isInternal, rid, ref, type, sheet_rel, false);
for (size_t i = 0; i < d.hlinks.size(); i++)
{
drawing_rels_.push_back(_rel(false, d.hlinks[i].hId, d.hlinks[i].hRef, typeHyperlink));
}
if (!d.action.hId.empty())
drawing_rels_.push_back(_rel(false, d.action.hId, d.action.hRef, d.action.typeRels));
}
if (!d.action.hId.empty())
xlsx_drawing_rels_.push_back(_rel(false, d.action.hId, d.action.hRef, d.action.typeRels));
}
void add( bool isInternal, std::wstring const & rid, std::wstring const & ref, RelsType type, bool sheet_rel) //не объект
void add( bool isInternal, std::wstring const & rid, std::wstring const & ref, RelsType type, bool sheet_rel, bool vml_rel) //не объект
{
bool present = false;
@ -73,25 +80,37 @@ public:
if (!present)
xlsx_sheet_rels_.push_back (_rel(isInternal, rid, ref, type));
}
else
else if (vml_rel)
{
for (size_t i = 0 ; i < xlsx_drawing_rels_.size(); i++)
for (size_t i = 0 ; i < vml_drawing_rels_.size(); i++)
{
if (xlsx_drawing_rels_[i].rid == rid && xlsx_drawing_rels_[i].ref == ref)
if (vml_drawing_rels_[i].rid == rid && vml_drawing_rels_[i].ref == ref)
present = true;
}
if (!present)
xlsx_drawing_rels_.push_back(_rel(isInternal, rid, ref, type));
vml_drawing_rels_.push_back(_rel(isInternal, rid, ref, type));
}
else
{
for (size_t i = 0 ; i < drawing_rels_.size(); i++)
{
if (drawing_rels_[i].rid == rid && drawing_rels_[i].ref == ref)
present = true;
}
if (!present)
drawing_rels_.push_back(_rel(isInternal, rid, ref, type));
}
}
void serialize(std::wostream & strm, const std::wstring & ns)
{
if (drawings_.empty()) return;
if (inGroup)
{
for (size_t i = 0 ; i < xlsx_drawings_.size(); i++)
for (size_t i = 0 ; i < drawings_.size(); i++)
{
xlsx_drawings_[i].serialize(strm, ns);
drawings_[i].serialize(strm, ns);
}
}
else
@ -111,9 +130,74 @@ public:
CP_XML_ATTR(L"xmlns:a" , L"http://schemas.openxmlformats.org/drawingml/2006/main");
CP_XML_ATTR(L"xmlns:r" , L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
for (size_t i = 0 ; i < xlsx_drawings_.size(); i++)
for (size_t i = 0 ; i < drawings_.size(); i++)
{
xlsx_drawings_[i].serialize(CP_XML_STREAM(), ns);
drawings_[i].serialize(CP_XML_STREAM(), ns);
}
}
}
}
}
void serialize_vml(std::wostream & strm)
{
if (vml_drawings_.empty()) return;
if (inGroup)
{
for (size_t i = 0 ; i < vml_drawings_.size(); i++)
{
vml_drawings_[i].serialize_vml(strm);
}
}
else
{
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"xml")
{
CP_XML_ATTR(L"xmlns:v", L"urn:schemas-microsoft-com:vml");
CP_XML_ATTR(L"xmlns:o", L"urn:schemas-microsoft-com:office:office");
CP_XML_ATTR(L"xmlns:x", L"urn:schemas-microsoft-com:office:excel");
CP_XML_NODE(L"v:shapetype")
{
CP_XML_ATTR(L"id", L"_x0000_t201");
CP_XML_ATTR(L"o:spt", L"201"); // sptHostControl = 201
CP_XML_ATTR(L"coordsize", L"21600,21600");
CP_XML_ATTR(L"path", L"m,l,21600r21600,l21600,xe");
CP_XML_NODE(L"v:stroke")
{
CP_XML_ATTR(L"joinstyle", L"miter");
}
CP_XML_NODE(L"v:path")
{
CP_XML_ATTR(L"gradientshapeok", L"t");
CP_XML_ATTR(L"o:connecttype", L"rect");
}
}
CP_XML_NODE(L"v:shapetype")
{
CP_XML_ATTR(L"id", L"_x0000_t202");
CP_XML_ATTR(L"o:spt", L"202"); // sptTextBox = 202
CP_XML_ATTR(L"coordsize", L"21600,21600");
CP_XML_ATTR(L"path", L"m,l,21600l21600,21600l21600,xe");
CP_XML_NODE(L"v:stroke")
{
CP_XML_ATTR(L"joinstyle", L"miter");
}
CP_XML_NODE(L"v:path")
{
CP_XML_ATTR(L"gradientshapeok", L"t");
CP_XML_ATTR(L"o:connecttype", L"rect");
}
}
for (size_t i = 0 ; i < vml_drawings_.size(); i++)
{
vml_drawings_[i].serialize_vml(CP_XML_STREAM());
}
}
}
@ -121,41 +205,62 @@ public:
}
void serialize_objects(std::wostream & strm)
{
for (size_t i = 0 ; i < xlsx_drawings_.size(); i++)
for (size_t i = 0 ; i < drawings_.size(); i++)
{
if (xlsx_drawings_[i].type != typeOleObject && xlsx_drawings_[i].type != typeMsObject) continue;
if (drawings_[i].type != typeOleObject && drawings_[i].type != typeMsObject) continue;
xlsx_drawings_[i].serialize_object(strm);
drawings_[i].serialize_object(strm);
}
}
void serialize_controls(std::wostream & strm)
{
for (size_t i = 0 ; i < xlsx_drawings_.size(); i++)
for (size_t i = 0 ; i < vml_drawings_.size(); i++)
{
if (xlsx_drawings_[i].type != typeControl) continue;
if (vml_drawings_[i].type != typeControl) continue;
xlsx_drawings_[i].serialize_control(strm);
vml_drawings_[i].serialize_control(strm);
}
}
bool empty() const
{
return (xlsx_drawings_.empty());
return (drawings_.empty());
}
bool vml_empty() const
{
return (vml_drawings_.empty());
}
void dump_rels_drawing(rels & Rels)
{
for (size_t i = 0 ; i < xlsx_drawing_rels_.size(); i++)
for (size_t i = 0 ; i < drawing_rels_.size(); i++)
{
if (xlsx_drawing_rels_[i].type == typeImage ||
xlsx_drawing_rels_[i].type == typeMedia ||
xlsx_drawing_rels_[i].type == typeChart ||
xlsx_drawing_rels_[i].type == typeHyperlink )
if (drawing_rels_[i].type == typeImage ||
drawing_rels_[i].type == typeMedia ||
drawing_rels_[i].type == typeChart ||
drawing_rels_[i].type == typeHyperlink )
{
Rels.add(relationship( xlsx_drawing_rels_[i].rid,
mediaitems::get_rel_type(xlsx_drawing_rels_[i].type),
(xlsx_drawing_rels_[i].is_internal ? std::wstring(L"../") + xlsx_drawing_rels_[i].ref : xlsx_drawing_rels_[i].ref),
(xlsx_drawing_rels_[i].is_internal ? L"" : L"External")) );
Rels.add(relationship( drawing_rels_[i].rid,
mediaitems::get_rel_type(drawing_rels_[i].type),
(drawing_rels_[i].is_internal ? std::wstring(L"../") + drawing_rels_[i].ref : drawing_rels_[i].ref),
(drawing_rels_[i].is_internal ? L"" : L"External")) );
}
}
}
void dump_rels_vml_drawing(rels & Rels)
{
for (size_t i = 0 ; i < vml_drawing_rels_.size(); i++)
{
if (vml_drawing_rels_[i].type == typeImage ||
vml_drawing_rels_[i].type == typeMedia ||
vml_drawing_rels_[i].type == typeChart ||
vml_drawing_rels_[i].type == typeHyperlink )
{
Rels.add(relationship( vml_drawing_rels_[i].rid,
mediaitems::get_rel_type(vml_drawing_rels_[i].type),
(vml_drawing_rels_[i].is_internal ? std::wstring(L"../") + vml_drawing_rels_[i].ref : vml_drawing_rels_[i].ref),
(vml_drawing_rels_[i].is_internal ? L"" : L"External")) );
}
}
}
@ -173,9 +278,11 @@ public:
private:
std::vector<_xlsx_drawing> xlsx_drawings_;
std::vector<_xlsx_drawing> drawings_;
std::vector<_xlsx_drawing> vml_drawings_;
std::vector<_rel> xlsx_drawing_rels_;
std::vector<_rel> drawing_rels_;
std::vector<_rel> vml_drawing_rels_;
std::vector<_rel> xlsx_sheet_rels_;
};
@ -194,15 +301,19 @@ void xlsx_drawings::add(_xlsx_drawing const & d, bool isInternal, std::wstring c
impl_->add(d, isInternal, rid, ref, type, sheet_rel);
}
void xlsx_drawings::add( bool isInternal, std::wstring const & rid, std::wstring const & ref, RelsType type, bool sheet_rel)
void xlsx_drawings::add( bool isInternal, std::wstring const & rid, std::wstring const & ref, RelsType type, bool sheet_rel, bool vml_rel)
{
impl_->add(isInternal, rid, ref, type, sheet_rel);
impl_->add(isInternal, rid, ref, type, sheet_rel, vml_rel);
}
void xlsx_drawings::serialize(std::wostream & strm, const std::wstring & ns)
{
impl_->serialize(strm, ns);
}
void xlsx_drawings::serialize_vml(std::wostream & strm)
{
impl_->serialize_vml(strm);
}
void xlsx_drawings::serialize_objects(std::wostream & strm)
{
@ -217,12 +328,18 @@ bool xlsx_drawings::empty() const
{
return impl_->empty();
}
bool xlsx_drawings::vml_empty() const
{
return impl_->vml_empty();
}
void xlsx_drawings::dump_rels_drawing(rels & Rels)
{
return impl_->dump_rels_drawing(Rels);
}
void xlsx_drawings::dump_rels_vml_drawing(rels & Rels)
{
return impl_->dump_rels_vml_drawing(Rels);
}
void xlsx_drawings::dump_rels_sheet(rels & Rels)
{
return impl_->dump_rels_sheet(Rels);

View File

@ -66,13 +66,17 @@ public:
static xlsx_drawings_ptr create(bool inGroup);
void add ( _xlsx_drawing const & d, bool isInternal, std::wstring const & rid, std::wstring const & ref, RelsType type, bool sheet_rel = false );
void add ( bool isInternal, std::wstring const & rid, std::wstring const & ref, RelsType type, bool sheet_rel = false );
void add ( bool isInternal, std::wstring const & rid, std::wstring const & ref, RelsType type, bool sheet_rel, bool vml_rel);
bool empty () const;
void dump_rels_sheet (rels & Rels);
void dump_rels_drawing (rels & Rels);
bool empty() const;
bool vml_empty() const;
void dump_rels_sheet (rels & Rels);
void dump_rels_drawing (rels & Rels);
void dump_rels_vml_drawing (rels & Rels);
void serialize (std::wostream & _Wostream, const std::wstring & ns);
void serialize_vml (std::wostream & _Wostream);
void serialize_objects (std::wostream & _Wostream);
void serialize_controls (std::wostream & _Wostream);
private:

View File

@ -49,7 +49,6 @@ public:
std::wstringstream sheetFormat_;
std::wstringstream sheetData_;
std::wstringstream mergeCells_;
std::wstringstream drawing_;
std::wstringstream hyperlinks_;
std::wstringstream comments_;
std::wstringstream sort_;
@ -130,10 +129,6 @@ std::wostream & xlsx_xml_worksheet::autofilter()
{
return impl_->autofilter_;
}
std::wostream & xlsx_xml_worksheet::drawing()
{
return impl_->drawing_;
}
std::wostream & xlsx_xml_worksheet::comments()
{
return impl_->comments_;
@ -217,35 +212,40 @@ void xlsx_xml_worksheet::write_to(std::wostream & strm)
CP_XML_STREAM() << impl_->hyperlinks_.str();
}
}
if (!impl_->page_props_.str().empty())
if (false == impl_->page_props_.str().empty())
{
CP_XML_STREAM() << impl_->page_props_.str();
}//props выше legacyDrawing !!
CP_XML_STREAM() << impl_->drawing_.str();
if (!impl_->commentsId_.empty())
if (false == impl_->drawingId_.empty())
{
CP_XML_NODE(L"drawing")
{
CP_XML_ATTR(L"r:id", impl_->drawingId_);
}
}
if (false == impl_->vml_drawingId_.empty())
{
CP_XML_NODE(L"legacyDrawing")
{
CP_XML_ATTR(L"r:id",impl_->vml_drawingId_);
CP_XML_ATTR(L"r:id", impl_->vml_drawingId_);
}
}
if (!impl_->ole_objects_.str().empty())
if (false == impl_->ole_objects_.str().empty())
{
CP_XML_NODE(L"oleObjects")
{
CP_XML_STREAM() << impl_->ole_objects_.str();
}
}
if (!impl_->controls_.str().empty())
if (false == impl_->controls_.str().empty())
{
CP_XML_NODE(L"controls")
{
CP_XML_STREAM() << impl_->controls_.str();
}
}
if (!impl_->tableParts_.str().empty())
if (false == impl_->tableParts_.str().empty())
{
CP_XML_NODE(L"tableParts")
{

View File

@ -58,7 +58,6 @@ public:
std::wostream & sheetData();
std::wostream & hyperlinks();
std::wostream & mergeCells();
std::wostream & drawing();
std::wostream & comments();
std::wostream & autofilter();
std::wostream & tableParts();

View File

@ -558,18 +558,20 @@ void xl_control_props_files::write(const std::wstring & RootPath)
}
}
//------------------------------------------------------------------------------------------------------
xl_drawings_ptr xl_drawings::create(const std::vector<drawing_elm> & elms)
xl_drawings_ptr xl_drawings::create(const std::vector<drawing_elm> & elms, const std::vector<drawing_elm> & vml_elms)
{
return boost::make_shared<xl_drawings>(boost::ref(elms));
return boost::make_shared<xl_drawings>(boost::ref(elms), boost::ref(vml_elms));
}
void xl_drawings::write(const std::wstring & RootPath)
{
content_type * contentTypes = this->get_main_document()->get_content_types_file().content();
if (drawings_.empty() && vml_drawings_.empty()) return;
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"drawings";
NSDirectory::CreateDirectory(path.c_str());
content_type * contentTypes = this->get_main_document()->get_content_types_file().content();
pptx_document *pptx = dynamic_cast<pptx_document*>(this->get_main_document());
xlsx_document *xlsx = dynamic_cast<xlsx_document*>(this->get_main_document());
docx_document *docx = dynamic_cast<docx_document*>(this->get_main_document());
@ -594,6 +596,20 @@ void xl_drawings::write(const std::wstring & RootPath)
contentTypes->add_override(override_str + drawings_[i].filename, kDrawingCT);
}
for (size_t i = 0; i < vml_drawings_.size(); i++)
{
package::simple_element(vml_drawings_[i].filename, vml_drawings_[i].content).write(path);
rels_files relFiles;
rels_file_ptr r = rels_file::create(vml_drawings_[i].filename + L".rels");
vml_drawings_[i].drawings->dump_rels_vml_drawing(r->get_rels());
relFiles.add_rel_file(r);
relFiles.write(path);
//content types - default
}
}
//////////////////////////////
@ -604,9 +620,6 @@ xl_comments_ptr xl_comments::create(const std::vector<comment_elm> & elms)
void xl_comments::write(const std::wstring & RootPath)
{
std::wstring vml_path = RootPath + FILE_SEPARATOR_STR + L"drawings";
NSDirectory::CreateDirectory(vml_path.c_str());
for (size_t i = 0; i < comments_.size(); i++)
{
content_type * contentTypes = this->get_main_document()->get_content_types_file().content();
@ -615,7 +628,6 @@ void xl_comments::write(const std::wstring & RootPath)
contentTypes->add_override(std::wstring(L"/xl/") + comments_[i].filename, kWSConType);
package::simple_element(comments_[i].filename, comments_[i].content).write(RootPath);
package::simple_element(comments_[i].vml_filename, comments_[i].vml_content).write(vml_path);
}
}

View File

@ -244,20 +244,27 @@ class xl_drawings: public element
{
public:
virtual void write(const std::wstring & RootPath);
void set_rels(rels_files * rels)
{
rels_ = rels;
}
xl_drawings(const std::vector<drawing_elm> & elms) : drawings_ ( elms )
//void set_rels(rels_files * rels)
// {
// rels_ = rels;
// }
//void set_vml_rels(rels_files * rels)
// {
// vml_rels_ = rels;
// }
xl_drawings(const std::vector<drawing_elm> & elms, const std::vector<drawing_elm> & vml_elms) : drawings_(elms), vml_drawings_(vml_elms)
{
}
static xl_drawings_ptr create(const std::vector<drawing_elm> & elms);
static xl_drawings_ptr create(const std::vector<drawing_elm> & elms, const std::vector<drawing_elm> & vml_elms);
private:
const std::vector<drawing_elm> & drawings_;
rels_files * rels_;
const std::vector<drawing_elm> & vml_drawings_;
//rels_files * rels_;
//rels_files * vml_rels_;
};
//----------------------------------------------------------------------------------------------------------
class xl_control_props_files : public element

View File

@ -332,8 +332,8 @@ void xlsx_conversion_context::end_document()
output_document_->get_content_types_file().set_media(get_mediaitems());
output_document_->get_xl_files().set_media(get_mediaitems());
package::xl_drawings_ptr drawings = package::xl_drawings::create(drawing_context_handle_->content());
output_document_->get_xl_files().set_drawings(drawings);
package::xl_drawings_ptr drawings = package::xl_drawings::create(drawing_context_handle_->content(), drawing_context_handle_->content_vml());
output_document_->get_xl_files().set_drawings(drawings);
package::xl_comments_ptr comments = package::xl_comments::create(xlsx_comments_context_handle_.content());
output_document_->get_xl_files().set_comments(comments);
@ -514,33 +514,28 @@ void xlsx_conversion_context::end_table()
= drawing_context_handle_->add_drawing_xml(strm.str(), get_drawing_context().get_drawings() );
current_sheet().set_drawing_link(drawingName.first, drawingName.second);
CP_XML_WRITER(current_sheet().drawing())
{
CP_XML_NODE(L"drawing")
{
CP_XML_ATTR(L"r:id", drawingName.second);
}
}
}
get_table_context().serialize_background (current_sheet().drawing());
if (false == get_drawing_context().vml_empty())
{
std::wstringstream strm;
get_drawing_context().serialize_vml(strm);
const std::pair<std::wstring, std::wstring> vml_drawingName
= drawing_context_handle_->add_drawing_vml(strm.str(), get_drawing_context().get_drawings() );
if (!get_comments_context().empty())
current_sheet().set_vml_drawing_link(vml_drawingName.first, vml_drawingName.second);
}
//get_table_context().serialize_background (current_sheet().picture());
if (false == get_comments_context().empty())
{
std::wstringstream strm;
get_comments_context().serialize(strm);
std::wstringstream vml_strm;
get_comments_context().serialize_vml(vml_strm);
const std::pair<std::wstring, std::wstring> commentsName
= xlsx_comments_context_handle_.add_comments_xml(strm.str(), vml_strm.str(),get_comments_context().get_comments() );
const std::pair<std::wstring, std::wstring> vml_drawingName
=xlsx_comments_context_handle_.get_vml_drawing_xml();
= xlsx_comments_context_handle_.add_comments_xml(strm.str(), get_comments_context().get_comments() );
current_sheet().set_comments_link(commentsName.first, commentsName.second);
current_sheet().set_vml_drawing_link(vml_drawingName.first, vml_drawingName.second);
}
get_table_context().end_table();
}

View File

@ -112,7 +112,7 @@ void draw_shape::common_xlsx_convert(oox::xlsx_conversion_context & Context)
std::vector<const odf_reader::style_instance *> instances;
odf_reader::style_instance* styleInst =
Context.root()->odf_context().styleContainer().style_by_name(styleName, odf_types::style_family::Graphic,false/*Context.process_headers_footers_*/);
Context.root()->odf_context().styleContainer().style_by_name(styleName, odf_types::style_family::Graphic, false/*Context.process_headers_footers_*/);
if (styleInst)
{
style_instance * defaultStyle = Context.root()->odf_context().styleContainer().style_default_by_type(odf_types::style_family::Graphic);
@ -396,28 +396,75 @@ void draw_control::xlsx_convert(oox::xlsx_conversion_context & Context)
oox::forms_context::_state & state = Context.get_forms_context().get_state_element(*control_id_);
if (state.id.empty()) return;
form_element* control = dynamic_cast<form_element*>(state.element);
if (!control) return;
if (state.ctrlPropId.empty())
{
std::wstring target;
state.ctrlPropId = Context.get_mediaitems()->add_control_props(target);
std::wstringstream strm;
form_element* control = dynamic_cast<form_element*>(state.element);
if (control)
{
control->serialize_control_props(strm);
}
control->serialize_control_props(strm);
Context.add_control_props(state.ctrlPropId, target, strm.str());
}
Context.get_drawing_context().start_frame();
Context.get_drawing_context().set_control(state.ctrlPropId);
Context.get_drawing_context().start_control(state.ctrlPropId, control->object_type_);
common_xlsx_convert(Context);
if (control->linked_cell_)
{
Context.get_drawing_context().end_frame();
Context.get_drawing_context().set_property(_property(L"linked_cell", control->linked_cell_.get()));
}
if (control->disabled_)
{
Context.get_drawing_context().set_property(_property(L"disabled", control->disabled_->get()));
}
if (control->value_)
{
Context.get_drawing_context().set_property(_property(L"value", control->value_.get()));
}
else if (control->current_value_)
{
Context.get_drawing_context().set_property(_property(L"value", control->current_value_.get()));
}
//if (control->name_)
//{
// Context.get_drawing_context().set_name(control->name_.get());
//}
form_value_range* value_range = dynamic_cast<form_value_range*>(control);
if (value_range)
{
if (value_range->min_value_)
{
Context.get_drawing_context().set_property(_property(L"min_value", value_range->min_value_.get()));
}
if (value_range->max_value_)
{
Context.get_drawing_context().set_property(_property(L"max_value", value_range->max_value_.get()));
}
if (value_range->step_size_)
{
Context.get_drawing_context().set_property(_property(L"step", value_range->step_size_.get()));
}
if (value_range->page_step_size_)
{
Context.get_drawing_context().set_property(_property(L"page_step", value_range->page_step_size_.get()));
}
if (value_range->orientation_)
{
Context.get_drawing_context().set_property(_property(L"orientation", value_range->orientation_.get()));
}
}
//_CP_OPT(std::wstring) label_;
//_CP_OPT(std::wstring) title_;
//_CP_OPT(odf_types::Bool) dropdown_;
Context.get_drawing_context().end_control();
Context.get_drawing_context().clear();
}

View File

@ -41,7 +41,7 @@
#include <odf/odf_document.h>
#include "odfcontext.h"
#include "draw_common.h"
#include "calcs_styles.h"
#include "../docx/xlsx_utils.h"
@ -111,7 +111,7 @@ void office_annotation::add_child_element( xml::sax * Reader, const std::wstring
void office_annotation::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
office_annotation_attr_.add_attributes(Attributes);
attr_.add_attributes(Attributes);
}
void office_annotation::docx_convert(oox::docx_conversion_context & Context)
@ -159,19 +159,20 @@ void office_annotation::docx_convert(oox::docx_conversion_context & Context)
void office_annotation::xlsx_convert(oox::xlsx_conversion_context & Context)
{
const _CP_OPT(length) svg_widthVal = office_annotation_attr_.svg_width_;
const _CP_OPT(length) svg_widthVal = attr_.svg_width_;
const double width_cm = svg_widthVal.get_value_or(length(0)).get_value_unit(length::cm);
const double width_pt = svg_widthVal.get_value_or(length(0)).get_value_unit(length::pt);
const _CP_OPT(length) svg_heightVal =office_annotation_attr_.svg_height_;
const _CP_OPT(length) svg_heightVal =attr_.svg_height_;
const double height_cm = svg_heightVal.get_value_or(length(0)).get_value_unit(length::cm);
const double height_pt = svg_heightVal.get_value_or(length(0)).get_value_unit(length::pt);
const double x_pt = office_annotation_attr_.svg_x_.get_value_or(length(0)).get_value_unit(length::pt);
const double y_pt = office_annotation_attr_.svg_y_.get_value_or(length(0)).get_value_unit(length::pt);
/////////////////////////////////
const double x_pt = attr_.svg_x_.get_value_or(length(0)).get_value_unit(length::pt);
const double y_pt = attr_.svg_y_.get_value_or(length(0)).get_value_unit(length::pt);
//-----------------------------------------------
std::wstring date;
std::wstring author;
if (dc_date_)
@ -182,11 +183,14 @@ void office_annotation::xlsx_convert(oox::xlsx_conversion_context & Context)
{
author = xml::utils::replace_text_to_xml(dynamic_cast<dc_creator * >(dc_creator_.get())->content_);
}
////////////////////////////////////////
Context.get_comments_context().start_comment(width_pt, height_pt, x_pt, y_pt);
if (office_annotation_attr_.display_)
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().start_comment(ref);
if (attr_.display_)
{
Context.get_comments_context().set_visibly(office_annotation_attr_.display_.get());
}
Context.get_text_context().start_comment_content();
@ -196,13 +200,43 @@ void office_annotation::xlsx_convert(oox::xlsx_conversion_context & Context)
}
Context.get_comments_context().add_author(author);
Context.get_comments_context().add_content(Context.get_text_context().end_comment_content());
//----------- drawing part ---------------
Context.get_drawing_context().start_comment(col, row);
Context.get_drawing_context().start_drawing(L"");
Context.get_drawing_context().set_rect(width_pt, height_pt, x_pt, y_pt);
if (attr_.display_)
{
Context.get_drawing_context().set_property(_property(L"visibly", attr_.display_.get()));
}
//////////////////////////////////////////////////////////////////
/// Обрабатываем стиль draw
if (attr_.draw_style_name_)
{
std::vector<const odf_reader::style_instance *> instances;
odf_reader::style_instance* styleInst =
Context.root()->odf_context().styleContainer().style_by_name(*attr_.draw_style_name_, odf_types::style_family::Graphic, false/*Context.process_headers_footers_*/);
if (styleInst)
{
style_instance * defaultStyle = Context.root()->odf_context().styleContainer().style_default_by_type(odf_types::style_family::Graphic);
if (defaultStyle)instances.push_back(defaultStyle);
instances.push_back(styleInst);
}
graphic_format_properties properties = calc_graphic_properties_content(instances);
//-----------------------------------------------
properties.apply_to(Context.get_drawing_context().get_properties());
oox::_oox_fill fill;
Compute_GraphicFill(properties.common_draw_fill_attlist_, properties.style_background_image_,
Context.root()->odf_context().drawStyles(), fill);
Context.get_drawing_context().set_fill(fill);
}
//-----------------------------------------------
std::vector<const odf_reader::style_instance *> instances;
style_instance* styleInst = Context.root()->odf_context().styleContainer().style_by_name(
office_annotation_attr_.draw_style_name_.get_value_or(L""), odf_types::style_family::Graphic, false/*Context.process_headers_footers_*/);
attr_.draw_style_name_.get_value_or(L""), odf_types::style_family::Graphic, false/*Context.process_headers_footers_*/);
if (styleInst)
{
style_instance * defaultStyle = Context.root()->odf_context().styleContainer().style_default_by_type(odf_types::style_family::Graphic);
@ -212,16 +246,13 @@ void office_annotation::xlsx_convert(oox::xlsx_conversion_context & Context)
}
graphic_format_properties graphicProperties = calc_graphic_properties_content(instances);
graphicProperties.apply_to(Context.get_comments_context().get_draw_properties());
const std::wstring textStyleName = office_annotation_attr_.draw_text_style_name_.get_value_or(L"");
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);
const std::wstring textStyleName = attr_.draw_text_style_name_.get_value_or(L"");
Context.get_drawing_context().end_drawing();
Context.get_drawing_context().end_comment();
Context.get_drawing_context().clear();
//-----------------------------------------------
Context.get_comments_context().end_comment();
}
// officeooo:annotation
//////////////////////////////////////////////////////////////////////////////////////////////////
@ -246,13 +277,13 @@ void officeooo_annotation::add_child_element( xml::sax * Reader, const std::wstr
void officeooo_annotation::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
office_annotation_attr_.add_attributes(Attributes);
attr_.add_attributes(Attributes);
}
void officeooo_annotation::pptx_convert(oox::pptx_conversion_context & Context)
{
const double x = 8 * office_annotation_attr_.svg_x_.get_value_or(length(0)).get_value_unit(length::pt);
const double y = 8 * office_annotation_attr_.svg_y_.get_value_or(length(0)).get_value_unit(length::pt);
const double x = 8 * attr_.svg_x_.get_value_or(length(0)).get_value_unit(length::pt);
const double y = 8 * attr_.svg_y_.get_value_or(length(0)).get_value_unit(length::pt);
/////////////////////////////////
std::wstring date;
std::wstring author;
@ -283,7 +314,7 @@ void officeooo_annotation::pptx_convert(oox::pptx_conversion_context & Context)
/// Обрабатываем стиль draw
std::vector<const odf_reader::style_instance *> instances;
style_instance* styleInst = Context.root()->odf_context().styleContainer().style_by_name(
office_annotation_attr_.draw_style_name_.get_value_or(L""), odf_types::style_family::Graphic,false/*Context.process_headers_footers_*/);
attr_.draw_style_name_.get_value_or(L""), odf_types::style_family::Graphic,false/*Context.process_headers_footers_*/);
if (styleInst)
{
style_instance * defaultStyle = Context.root()->odf_context().styleContainer().style_default_by_type(odf_types::style_family::Graphic);
@ -295,7 +326,7 @@ void officeooo_annotation::pptx_convert(oox::pptx_conversion_context & Context)
graphicProperties.apply_to(Context.get_comments_context().get_draw_properties());
const std::wstring textStyleName = office_annotation_attr_.draw_text_style_name_.get_value_or(L"");
const std::wstring textStyleName = attr_.draw_text_style_name_.get_value_or(L"");
Context.get_comments_context().end_comment();
}

View File

@ -46,7 +46,6 @@ class office_annotation_attr
public:
void add_attributes( const xml::attributes_wc_ptr & Attributes );
public:
_CP_OPT(odf_types::length) svg_y_;
_CP_OPT(odf_types::length) svg_x_;
_CP_OPT(odf_types::length) svg_width_;
@ -123,9 +122,8 @@ private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
private:
office_element_ptr_array content_;
office_annotation_attr office_annotation_attr_;
office_annotation_attr attr_;
office_element_ptr dc_date_;
office_element_ptr dc_creator_;
@ -150,9 +148,8 @@ private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
private:
office_element_ptr_array content_;
office_annotation_attr office_annotation_attr_;
office_annotation_attr attr_;
office_element_ptr dc_date_;
office_element_ptr dc_creator_;

View File

@ -41,6 +41,30 @@
#include "serialize_elements.h"
#include "../formulasconvert/formulasconvert.h"
#define OBJ_Group 0x0000
#define OBJ_Line 0x0001
#define OBJ_Rectangle 0x0002
#define OBJ_Oval 0x0003
#define OBJ_Arc 0x0004
#define OBJ_Text 0x0006
#define OBJ_OfficeArt 0x001E
#define OBJ_Polygon 0x0009
#define OBJ_Picture 0x0008
#define OBJ_Chart 0x0005
#define OBJ_Button 0x0007
#define OBJ_CheckBox 0x000B
#define OBJ_RadioButton 0x000C
#define OBJ_EditBox 0x000D
#define OBJ_Label 0x000E
#define OBJ_DialogBox 0x000F
#define OBJ_SpinControl 0x0010
#define OBJ_Scrollbar 0x0011
#define OBJ_List 0x0012
#define OBJ_GroupBox 0x0013
#define OBJ_DropdownList 0x0014
#define OBJ_Note 0x0019
namespace cpdoccore {
namespace odf_reader {
@ -273,6 +297,7 @@ const wchar_t * form_button::name = L"button";
void form_button::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
object_type_ = OBJ_Button;
form_element::add_attributes(Attributes);
}
void form_button::docx_convert(oox::docx_conversion_context & Context)
@ -311,6 +336,7 @@ const wchar_t * form_text::name = L"text";
void form_text::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
object_type_ = OBJ_EditBox;
form_element::add_attributes(Attributes);
}
void form_text::docx_convert(oox::docx_conversion_context & Context)
@ -411,6 +437,7 @@ const wchar_t * form_fixed_text::name = L"fixed-text";
void form_fixed_text::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
object_type_ = OBJ_Label;
form_element::add_attributes(Attributes);
}
void form_fixed_text::docx_convert(oox::docx_conversion_context & Context)
@ -506,6 +533,8 @@ const wchar_t * form_checkbox::name = L"checkbox";
void form_checkbox::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
object_type_ = OBJ_CheckBox;
_CP_OPT(std::wstring) strVal;
CP_APPLY_ATTR(L"form:current-state", strVal);
@ -617,6 +646,7 @@ const wchar_t * form_combobox::name = L"combobox";
void form_combobox::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
object_type_ = OBJ_DropdownList;
form_element::add_attributes(Attributes);
CP_APPLY_ATTR(L"form:source-cell-range", source_cell_range_);
@ -662,7 +692,7 @@ void form_combobox::serialize_control_props(std::wostream & strm)
if (linked_cell_)
{
std::wstring fmla = converter.convert_named_expr(*linked_cell_);
std::wstring fmla = converter.convert_named_ref(*linked_cell_);
CP_XML_ATTR(L"fmlaLink", fmla);
}
if (source_cell_range_)
@ -737,6 +767,7 @@ const wchar_t * form_listbox::name = L"listbox";
void form_listbox::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
object_type_ = OBJ_List;
form_element::add_attributes(Attributes);
CP_APPLY_ATTR(L"form:source-cell-range", source_cell_range_);
@ -777,7 +808,7 @@ void form_listbox::serialize_control_props(std::wostream & strm)
if (linked_cell_)
{
std::wstring fmla = converter.convert_named_expr(*linked_cell_);
std::wstring fmla = converter.convert_named_ref(*linked_cell_);
CP_XML_ATTR(L"fmlaLink", fmla);
}
if (source_cell_range_)
@ -799,6 +830,7 @@ const wchar_t * form_date::name = L"date";
void form_date::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
object_type_ = 15;
form_element::add_attributes(Attributes);
}
void form_date::docx_convert(oox::docx_conversion_context & Context)
@ -873,6 +905,7 @@ const wchar_t * form_time::name = L"time";
void form_time::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
object_type_ = 16;
form_element::add_attributes(Attributes);
}
void form_time::docx_convert(oox::docx_conversion_context & Context)
@ -947,6 +980,8 @@ const wchar_t * form_value_range::name = L"value-range";
void form_value_range::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
object_type_ = OBJ_Scrollbar;
form_element::add_attributes(Attributes);
CP_APPLY_ATTR(L"form:min-value", min_value_);
@ -955,6 +990,20 @@ void form_value_range::add_attributes( const xml::attributes_wc_ptr & Attributes
CP_APPLY_ATTR(L"form:page-step-size", page_step_size_);
CP_APPLY_ATTR(L"form:orientation", orientation_);
CP_APPLY_ATTR(L"form:delay-for-repeat", delay_for_repeat_);
if (control_implementation_)
{
if (control_implementation_->find(L"SpinButton") != std::wstring::npos)
{
object_type_ = OBJ_SpinControl;
if (!orientation_) orientation_ = L"vertical";
}
else
{
object_type_ = OBJ_Scrollbar;
if (!orientation_) orientation_ = L"horizontal";
}
}
}
void form_value_range::docx_convert(oox::docx_conversion_context & Context)
{
@ -986,12 +1035,6 @@ void form_value_range::serialize_control_props(std::wostream & strm)
{
if (!control_implementation_) return;
std::wstring object_type;
if (control_implementation_->find(L"SpinButton") != std::wstring::npos)
object_type = L"Spin";
else
object_type = L"Scroll";
formulasconvert::odf2oox_converter converter;
CP_XML_WRITER(strm)
{
@ -999,13 +1042,13 @@ void form_value_range::serialize_control_props(std::wostream & strm)
{
CP_XML_ATTR(L"xmlns", L"http://schemas.microsoft.com/office/spreadsheetml/2009/9/main");
CP_XML_ATTR(L"objectType", object_type);
CP_XML_ATTR(L"objectType", object_type_ == OBJ_SpinControl ? L"Spin" : L"Scroll");
CP_XML_ATTR(L"noThreeD", L"1");
if (linked_cell_)
{
std::wstring fmla = converter.convert_named_expr(*linked_cell_);
std::wstring fmla = converter.convert_named_ref(*linked_cell_);
CP_XML_ATTR(L"fmlaLink", fmla);
}
if (value_) CP_XML_ATTR(L"val", *value_);

View File

@ -218,7 +218,7 @@ public:
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeFormElement;
form_element() {}
form_element() : object_type_(0) {}
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
@ -253,6 +253,9 @@ public:
_CP_OPT(std::wstring) xforms_bind_;
_CP_OPT(std::wstring) current_value_;
_CP_OPT(odf_types::Bool) dropdown_;
//----------------------------------------------------------------------------------------------
int object_type_;
};
// form:button

View File

@ -1372,7 +1372,7 @@ void style_page_layout_properties::xlsx_serialize(std::wostream & strm, oox::xls
std::wstring href = fill.bitmap->xlink_href_;
fill.bitmap->rId = Context.get_mediaitems()->add_or_find(href, oox::typeImage, fill.bitmap->isInternal, href);
Context.get_drawing_context().get_drawings()->add(fill.bitmap->isInternal, fill.bitmap->rId, href, oox::typeImage, true);
Context.get_drawing_context().get_drawings()->add(fill.bitmap->isInternal, fill.bitmap->rId, href, oox::typeImage, true, false);
}
Context.get_table_context().state()->set_background(fill.bitmap->rId);

View File

@ -385,7 +385,7 @@ void odf_chart_context::set_chart_size(_CP_OPT(double) width_pt, _CP_OPT(double)
chart->chart_chart_attlist_.common_draw_size_attlist_.svg_width_ = length(length(*width_pt,length::pt).get_value_unit(length::cm), length::cm);
chart->chart_chart_attlist_.common_draw_size_attlist_.svg_height_ = length(length(*height_pt,length::pt).get_value_unit(length::cm), length::cm);
}
void odf_chart_context::set_chart_type(std::wstring type)
void odf_chart_context::set_chart_type(const std::wstring & type)
{
chart_chart *chart = impl_->get_current_chart();
if (!chart)return;
@ -610,7 +610,7 @@ void odf_chart_context::set_chart_scatter_type(int type)
void odf_chart_context::start_group_series()
{
}
void odf_chart_context::start_series(std::wstring type)
void odf_chart_context::start_series(const std::wstring & type)
{
office_element_ptr elm;
create_element(L"chart", L"series", elm, impl_->odf_context_);
@ -677,6 +677,15 @@ void odf_chart_context::set_label_show_leader_line(bool val)
void odf_chart_context::set_label_show_legend_key(bool val)
{
}
void odf_chart_context::set_label_formula(const std::wstring & oox_formula) //в odf не поддерживается
{
std::wstring odf_formula = impl_->convert_formula(oox_formula);
if (!odf_formula.empty())
{
}
}
void odf_chart_context::set_label_show_percent(bool val)
{
if (!impl_->current_level_.back().chart_properties_)return;
@ -721,7 +730,7 @@ void odf_chart_context::end_group_series()
if (countX < 1 && countY > 1)
{
impl_->axis_[0].dimension == 1;
impl_->axis_[0].dimension = 1;
chart_axis *axis = dynamic_cast<chart_axis*>(impl_->axis_[0].elm.get());
axis->chart_axis_attlist_.chart_dimension_ = L"x";
countY--;
@ -760,7 +769,7 @@ void odf_chart_context::end_group_series()
impl_->axis_group_series_.clear();
}
void odf_chart_context::add_domain(std::wstring formula)
void odf_chart_context::add_domain(const std::wstring & formula)
{
size_t level = impl_->current_level_.size();
if (level == 0)return;
@ -779,7 +788,7 @@ void odf_chart_context::add_domain(std::wstring formula)
impl_->current_chart_state_.elements_.push_back(state);
}
void odf_chart_context::add_categories(std::wstring odf_formula, office_element_ptr & axis)
void odf_chart_context::add_categories(const std::wstring & odf_formula, office_element_ptr & axis)
{
office_element_ptr elm;
create_element(L"chart", L"categories", elm, impl_->odf_context_);
@ -942,26 +951,41 @@ void odf_chart_context::end_text()
{
odf_text_context *text_context_ = text_context();
if (text_context_ == NULL || impl_->current_level_.size() < 1 )return;
if (text_context_ == NULL || impl_->current_level_.empty())return;
for (size_t i = 0; i < text_context_->text_elements_list_.size(); i++)
{
if (text_context_->text_elements_list_[i].level ==0)
if (text_context_->text_elements_list_[i].level == 0)
{
impl_->current_level_.back().elm->add_child_element(text_context_->text_elements_list_[i].elm);
}
size_t level_root = impl_->current_level_.size() + 1;
odf_element_state state={text_context_->text_elements_list_[i].elm,
text_context_->text_elements_list_[i].style_name,
text_context_->text_elements_list_[i].style_elm,
text_context_->text_elements_list_[i].level + level_root};
odf_element_state state = { text_context_->text_elements_list_[i].elm,
text_context_->text_elements_list_[i].style_name,
text_context_->text_elements_list_[i].style_elm,
text_context_->text_elements_list_[i].level + level_root};
impl_->current_chart_state_.elements_.push_back(state);
}
impl_->odf_context_->end_text_context();
}
void odf_chart_context::add_text(const std::wstring & val)
{
office_element_ptr paragr_elm;
create_element(L"text", L"p", paragr_elm, impl_->odf_context_);
text_p* p = dynamic_cast<text_p*>(paragr_elm.get());
if (p)
p->add_text(val);
impl_->current_level_.back().elm->add_child_element(paragr_elm);
odf_element_state state = {paragr_elm, L"", office_element_ptr(), impl_->current_level_.size() + 1};
impl_->current_chart_state_.elements_.push_back(state);
}
void odf_chart_context::set_textarea_vertical_align(int align)
{
if (!impl_->current_level_.back().chart_properties_)return;
@ -1303,6 +1327,11 @@ void odf_chart_context::set_axis_id(unsigned int id)
{
if (impl_->axis_.size()>0)impl_->axis_.back().oox_id = id;
}
void odf_chart_context::set_axis_visible(bool val)
{
if (!impl_->current_level_.back().chart_properties_)return;
impl_->current_level_.back().chart_properties_->content_.chart_visible_ = val;
}
void odf_chart_context::set_axis_dimension(int type)
{
chart_axis *axis = impl_->get_current_axis();
@ -1394,7 +1423,7 @@ void odf_chart_context::set_layout_h(double *val,int mode)
if (plot_area)plot_area->chart_plot_area_attlist_.common_draw_size_attlist_.svg_height_ = height_cm;
}
void odf_chart_context::start_element(office_element_ptr & elm, office_element_ptr & style_elm, std::wstring style_name)
void odf_chart_context::start_element(office_element_ptr & elm, office_element_ptr & style_elm, const std::wstring & style_name)
{
size_t level = impl_->current_level_.size();
@ -1402,14 +1431,13 @@ void odf_chart_context::start_element(office_element_ptr & elm, office_element_p
//if (impl_->current_level_.size()>0) impl_->current_level_.back()->add_child_element(elm); не надо...наследование через start_element в drawing
odf_element_state state={elm, style_name, style_elm, level};
odf_chart_level_state level_state = {NULL,NULL,NULL,NULL,elm};
odf_chart_level_state level_state = {NULL, NULL, NULL, NULL, elm};
impl_->current_chart_state_.elements_.push_back(state);
style* style_ = dynamic_cast<style*>(style_elm.get());
if (style_)
{
style_name = style_->style_name_;
level_state.chart_properties_ = style_->content_.get_style_chart_properties();
}
impl_->current_level_.push_back(level_state);//стоит ли сюда перенести и current_chart_properties ????
@ -1485,7 +1513,7 @@ void odf_chart_context::end_chart()
impl_->clear_current();
}
void odf_chart_context::set_series_value_formula(std::wstring oox_formula)
void odf_chart_context::set_series_value_formula(const std::wstring & oox_formula)
{
std::wstring odf_formula = impl_->convert_formula(oox_formula);
@ -1502,7 +1530,7 @@ void odf_chart_context::set_series_value_formula(std::wstring oox_formula)
}
}
void odf_chart_context::set_series_label_formula(std::wstring oox_formula)
void odf_chart_context::set_series_label_formula(const std::wstring & oox_formula)
{
std::wstring odf_formula = impl_->convert_formula(oox_formula);
@ -1518,7 +1546,7 @@ void odf_chart_context::set_series_label_formula(std::wstring oox_formula)
}
}
void odf_chart_context::set_category_axis_formula(std::wstring oox_formula, int type)
void odf_chart_context::set_category_axis_formula(const std::wstring & oox_formula, int type)
{
std::wstring odf_formula = impl_->convert_formula(oox_formula);

View File

@ -59,7 +59,7 @@ public:
odf_text_context *text_context();
void start_chart (office_element_ptr & root);
void set_chart_type (std::wstring type);
void set_chart_type (const std::wstring & type);
void set_chart_3D (bool Val);
void set_chart_size (_CP_OPT(double) width_pt, _CP_OPT(double) height_pt);
void set_chart_colored (bool val);
@ -81,10 +81,10 @@ public:
void start_group_series();
void add_axis_group_series(unsigned int id);
void start_series (std::wstring type);
void set_series_value_formula (std::wstring oox_formula);
void set_series_label_formula (std::wstring oox_formula);
void set_category_axis_formula (std::wstring oox_formula,int type);
void start_series (const std::wstring & type);
void set_series_value_formula (const std::wstring & oox_formula);
void set_series_label_formula (const std::wstring & oox_formula);
void set_category_axis_formula (const std::wstring & oox_formula, int type);
void start_data_point_series (int count);
long get_count_data_points_series();
@ -93,7 +93,8 @@ public:
void end_series();
void end_group_series();
void set_label_name (std::wstring name);
void set_label_formula (const std::wstring & oox_formula);
void set_label_name (const std::wstring & name);
void set_label_delete (bool val);
void set_label_show_bubble_size (bool val);
void set_label_show_cat_name (bool val);
@ -116,6 +117,7 @@ public:
void set_axis_min(double val);
void set_axis_tick_minor(int type);
void set_axis_tick_major(int type);
void set_axis_visible(bool val);
void start_title();
void start_grid(int type);
void start_legend();
@ -131,9 +133,11 @@ public:
void set_stock_loss_marker_width(std::wstring val);
void start_stock_range_line();
void start_element(office_element_ptr & elm, office_element_ptr & style_elm, std::wstring style_name);
void start_element(office_element_ptr & elm, office_element_ptr & style_elm, const std::wstring & style_name);
void end_element();
void add_text(const std::wstring & val);
void start_text();
void end_text();
@ -141,8 +145,8 @@ public:
void set_textarea_padding (_CP_OPT(double) & left, _CP_OPT(double) & top, _CP_OPT(double) & right, _CP_OPT(double) & bottom);//in pt
void set_textarea_rotation (double val);
void add_domain(std::wstring formula);
void add_categories(std::wstring formula, office_element_ptr & axis);
void add_domain(const std::wstring & formula);
void add_categories(const std::wstring & formula, office_element_ptr & axis);
void set_layout_x(double *val,int mode);
void set_layout_y(double *val,int mode);

View File

@ -104,7 +104,7 @@ void odf_comment_context::start_comment(office_element_ptr &elm, int oox_id)
office_annotation* comm = dynamic_cast<office_annotation*>(elm.get());
if (!comm)return;
comm->office_annotation_attr_.name_ = impl_->comments_.back().odf_name;
comm->attr_.name_ = impl_->comments_.back().odf_name;
}
@ -117,7 +117,7 @@ void odf_comment_context::end_comment(office_element_ptr &elm, int oox_id)
office_annotation_end* comm = dynamic_cast<office_annotation_end*>(elm.get());
if (!comm)return;
comm->office_annotation_attr_.name_ = impl_->comments_[i].odf_name;
comm->attr_.name_ = impl_->comments_[i].odf_name;
impl_->comments_[i].state = 2;//stoped
@ -206,8 +206,8 @@ void odf_comment_context::set_position (double x, double y)
if (comm)
{
comm->office_annotation_attr_.svg_x_ = odf_types::length(x, odf_types::length::pt);
comm->office_annotation_attr_.svg_y_ = odf_types::length(y, odf_types::length::pt);
comm->attr_.svg_x_ = odf_types::length(x, odf_types::length::pt);
comm->attr_.svg_y_ = odf_types::length(y, odf_types::length::pt);
}
}

View File

@ -167,7 +167,9 @@ enum _drawing_part
Unknown = 0,
Area = 1,
Line = 2,
Shadow = 3
Shadow = 3,
Background = 4,
Border = 5
};
struct odf_drawing_state
{
@ -1253,9 +1255,9 @@ void odf_drawing_context::end_element()
impl_->current_level_.pop_back();
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void odf_drawing_context::start_area_properties(bool reset)
void odf_drawing_context::start_area_properties(bool bBackground)
{
impl_->current_drawing_part_ = Area;
impl_->current_drawing_part_ = bBackground ? Background : Area;
}
void odf_drawing_context::end_area_properties()
{
@ -1463,7 +1465,12 @@ void odf_drawing_context::set_solid_fill(std::wstring hexColor)
switch(impl_->current_drawing_part_)
{
case Background:
{
impl_->current_graphic_properties->common_background_color_attlist_.fo_background_color_ = color(hexColor);
}break;
case Area:
{
impl_->current_graphic_properties->common_draw_fill_attlist_.draw_fill_color_ = hexColor;
//impl_->current_graphic_properties->common_background_color_attlist_.fo_background_color_ = color(hexColor); - default transparent
//последнее нужно - что если будут вводить текст - под текстом будет цвет фона (или он поменяется в полях текста)
@ -1475,14 +1482,15 @@ void odf_drawing_context::set_solid_fill(std::wstring hexColor)
}
else
impl_->current_graphic_properties->common_draw_fill_attlist_.draw_fill_ = draw_fill::solid;
break;
}break;
case Line:
{
impl_->current_graphic_properties->svg_stroke_color_ = hexColor;
if (!impl_->current_graphic_properties->draw_stroke_)
impl_->current_graphic_properties->draw_stroke_ = line_style(line_style::Solid);//default
if (!impl_->current_graphic_properties->svg_stroke_width_)
impl_->current_graphic_properties->svg_stroke_width_ = length(length(1, length::pt).get_value_unit(length::cm), length::cm);//default
break;
}break;
}
}
@ -2591,7 +2599,20 @@ void odf_drawing_context::start_control(const std::wstring& id)
if (control == NULL)return;
control->control_id_ = id;
//--------------------
impl_->styles_context_->create_style(L"", style_family::Graphic, true, false, -1);
office_element_ptr & style_control_elm = impl_->styles_context_->last_state()->get_office_element();
std::wstring style_name;
style* style_ = dynamic_cast<style*>(style_control_elm.get());
if (style_)
{
style_name = style_->style_name_;
impl_->current_graphic_properties = style_->content_.get_graphic_properties();
}
control->common_draw_attlists_.shape_with_text_and_styles_.common_shape_draw_attlist_.draw_style_name_ = style_name;
//--------------------
start_element(control_elm);
}
void odf_drawing_context::end_control()

View File

@ -62,18 +62,18 @@ namespace utils
void calculate_size_font_symbols(_font_metrix & metrix, NSFonts::IApplicationFonts *appFonts)
{
double appr_px = _graphics_utils_::calculate_size_symbol_asc(metrix.font_name, metrix.font_size, metrix.italic, metrix.bold, appFonts);
std::pair<float,float> appr = _graphics_utils_::calculate_size_symbol_asc(metrix.font_name, metrix.font_size, metrix.italic, metrix.bold, appFonts);
if (appr_px <0.01)
if (appr.first < 0.01 || appr.second < 0.01)
{
appr_px = _graphics_utils_::calculate_size_symbol_win(metrix.font_name,metrix.font_size,false/*metrix.italic*/,false/*metrix.bold*/);
appr_px = ((int)(appr_px+0.5) + 2*(int)appr_px)/3.;
appr.first = _graphics_utils_::calculate_size_symbol_win(metrix.font_name,metrix.font_size,false/*metrix.italic*/,false/*metrix.bold*/);
appr.first = ((int)(appr.first + 0.5) + 2 * (int)appr.first)/3.;
}
if (appr_px > 0)
if (appr.first > 0)
{
//pixels to pt
metrix.approx_symbol_size = appr_px ;///1.1;//"1.2" волшебное число оО
metrix.approx_symbol_size = appr.first ;///1.1;//"1.2" волшебное число оО
metrix.IsCalc = true;
}
@ -102,6 +102,9 @@ void ods_conversion_context::end_document()
if (table_context_.table_defined_expressions_.root)
root_spreadsheet_->add_child_element(table_context_.table_defined_expressions_.root);
if (table_context_.table_content_validations_.root)
root_spreadsheet_->add_child_element(table_context_.table_content_validations_.root);
odf_conversion_context::end_document();
}
@ -295,7 +298,14 @@ void ods_conversion_context::end_comment()
current_table().end_comment(current_text_context_);
end_text_context();
}
void ods_conversion_context::set_comment_color(const std::wstring & color)
{
current_table().set_comment_color(color);
}
void ods_conversion_context::set_comment_visible(bool val)
{
current_table().set_comment_visible(val);
}
void ods_conversion_context::set_comment_rect(double l, double t, double w, double h)//in mm
{
current_table().set_comment_rect(l,t,w,h);
@ -331,11 +341,38 @@ void ods_conversion_context::add_hyperlink(const std::wstring & ref, const std::
current_table().add_hyperlink(ref, col, row, link, bLocation);
}
}
bool ods_conversion_context::start_data_validation(const std::wstring & ref, int type)
{
return table_context_.start_data_validation(ref, type);
}
void ods_conversion_context::end_data_validation()
{
table_context_.end_data_validation();
}
void ods_conversion_context::set_data_validation_allow_empty(bool val)
{
table_context_.set_data_validation_allow_empty(val);
}
void ods_conversion_context::set_data_validation_content(const std::wstring &val1, const std::wstring &val2)
{
table_context_.set_data_validation_content(val1, val2);
}
void ods_conversion_context::set_data_validation_operator(int val)
{
table_context_.set_data_validation_operator(val);
}
void ods_conversion_context::set_data_validation_error(const std::wstring &title, const std::wstring &content)
{
table_context_.set_data_validation_error(title, content);
}
void ods_conversion_context::set_data_validation_promt(const std::wstring &title, const std::wstring &content)
{
table_context_.set_data_validation_promt(title, content);
}
void ods_conversion_context::add_merge_cells(const std::wstring & ref)
{
std::vector<std::wstring> ref_cells;
boost::algorithm::split(ref_cells,ref, boost::algorithm::is_any_of(L":"), boost::algorithm::token_compress_on);
boost::algorithm::split(ref_cells, ref, boost::algorithm::is_any_of(L":"), boost::algorithm::token_compress_on);
if (ref_cells.size() != 2) return;//тута однозначно .. по правилам оохml

View File

@ -97,10 +97,20 @@ public:
void start_comment (int col, int row, std::wstring & author);
void set_comment_rect (double l, double t, double w, double h);
void set_comment_visible(bool val);
void set_comment_color (const std::wstring & color);
void end_comment ();
///////////////////////////////////////////////////////
ods_table_state & current_table() { return table_context_.state();}
/////////////////////////////////////////////////////
bool start_data_validation(const std::wstring & ref, int type);
void set_data_validation_operator(int val);
void set_data_validation_content(const std::wstring &val1, const std::wstring &val2);
void set_data_validation_allow_empty(bool val);
void set_data_validation_error(const std::wstring &title, const std::wstring &content);
void set_data_validation_promt(const std::wstring &title, const std::wstring &content);
void end_data_validation();
//-----------------------------------------------------------------------
ods_table_state & current_table() { return table_context_.state();}
//-----------------------------------------------------------------------
virtual void start_text_context();
virtual void end_text_context();

View File

@ -37,7 +37,9 @@
#include "ods_conversion_context.h"
#include "logging.h"
#include <iostream>
#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/classification.hpp>
#include "../../../ASCOfficeOdfFile/formulasconvert/formulasconvert.h"
@ -47,6 +49,32 @@ namespace cpdoccore {
namespace odf_writer {
std::wstring getColAddress(size_t col)
{
static const size_t r = (L'Z' - L'A' + 1);
std::wstring res;
size_t r0 = col / r;
if (r0 > 0)
{
const std::wstring rest = getColAddress(col - r * r0);
const std::wstring res = getColAddress(r0-1) + rest;
return res;
}
else
return std::wstring(1, (wchar_t)(L'A' + col));
}
std::wstring getRowAddress(size_t row)
{
return std::to_wstring(row + 1);
}
std::wstring getCellAddress(size_t col, size_t row)
{
return getColAddress(col) + getRowAddress(row);
}
ods_table_context::ods_table_context(ods_conversion_context & Context): context_(Context)
{
}
@ -125,7 +153,6 @@ void ods_table_context::set_table_part_autofilter(bool val)
void ods_table_context::end_table_part()
{
}
void ods_table_context::add_autofilter(std::wstring ref)
{
if (!table_database_ranges_.root) create_element(L"table", L"database-ranges",table_database_ranges_.root,&context_);
@ -147,6 +174,253 @@ void ods_table_context::add_autofilter(std::wstring ref)
table_database_ranges_.elements.push_back(elm);
}
bool ods_table_context::start_data_validation( const std::wstring &strRef, int type)
{
if (!table_content_validations_.root) create_element(L"table", L"content-validations", table_content_validations_.root, &context_);
office_element_ptr elm;
create_element(L"table", L"content-validation", elm, &context_);
table_content_validation *validation = dynamic_cast<table_content_validation*>(elm.get());
if (!validation) return false;
std::vector<std::wstring> arRefs;
boost::algorithm::split(arRefs, strRef, boost::algorithm::is_any_of(L" "), boost::algorithm::token_compress_on);
data_validation_state validation_state;
validation_state.name = L"DataValidation_" + std::to_wstring(state().data_validations_.size() + 1);
validation_state.elm = elm;
validation_state.type = type;
for (size_t i = 0; i < arRefs.size(); i++)
{
data_validation_state::_ref ref;
ref.ref = arRefs[i];
size_t r = arRefs[i].rfind(L":");
if (r == std::wstring::npos)
{
utils::parsing_ref (arRefs[i].substr(0, r), ref.col_start, ref.row_start);
ref.col_end = ref.col_start;
ref.row_end = ref.row_start;
}
else
{
utils::parsing_ref (arRefs[i].substr(0, r), ref.col_start, ref.row_start);
utils::parsing_ref (arRefs[i].substr(r + 1, arRefs[i].size() - r), ref.col_end, ref.row_end);
}
validation_state.refs.push_back(ref);
}
if (validation_state.refs.empty()) return false;
validation->table_base_cell_address_ = state().office_table_name_ + L"." + getCellAddress(validation_state.refs[0].col_start, validation_state.refs[0].row_start);
validation->table_name_ = validation_state.name;
table_content_validations_.root->add_child_element(elm);
table_content_validations_.elements.push_back(elm);
state().data_validations_.push_back(validation_state);
return true;
}
void ods_table_context::set_data_validation_allow_empty(bool val)
{
if (state().data_validations_.empty()) return;
table_content_validation *validation = dynamic_cast<table_content_validation*>(state().data_validations_.back().elm.get());
validation->table_allowempty_cell_ = val;
}
void ods_table_context::set_data_validation_operator(int val)
{
if (state().data_validations_.empty()) return;
state().data_validations_.back().operator_ = val;
}
void ods_table_context::set_data_validation_content( std::wstring oox_formula1, std::wstring oox_formula2)
{
if (state().data_validations_.empty()) return;
if (oox_formula1.empty() && oox_formula2.empty()) return;
std::wstring odf_formula1, odf_formula2;
if (false == oox_formula1.empty() && oox_formula1[0] == L'\"' && oox_formula1[oox_formula1.length() - 1] == L'\"')
{
oox_formula1 = oox_formula1.substr(1, oox_formula1.length() - 2);
std::vector<std::wstring> arItems;
boost::algorithm::split(arItems, oox_formula1, boost::algorithm::is_any_of(L","), boost::algorithm::token_compress_on);
for (size_t i = 0; i < arItems.size(); ++i)
{
odf_formula1 += L"\"" + arItems[i] + L"\"" + (i < arItems.size() - 1 ? L";" : L"");
}
}
else
{
formulasconvert::oox2odf_converter formulas_converter;
odf_formula1 = formulas_converter.convert_formula(oox_formula1);
if (false == odf_formula1.empty())
{
odf_formula1 = odf_formula1.substr(4);
}
}
if (false == oox_formula2.empty() && oox_formula2[0] == L'\"' && oox_formula2[oox_formula2.length() - 1] == L'\"')
{
oox_formula2 = oox_formula1.substr(1, oox_formula2.length() - 2);
std::vector<std::wstring> arItems;
std::wstring str = oox_formula2.substr(1, oox_formula1.length() - 2);
boost::algorithm::split(arItems, str,
boost::algorithm::is_any_of(L","),
boost::algorithm::token_compress_on);
for (size_t i = 0; i < arItems.size(); ++i)
{
odf_formula2 += L"\"" + arItems[i] + L"\"" + (i < arItems.size() - 1 ? L";" : L"");
}
}
else
{
formulasconvert::oox2odf_converter formulas_converter;
odf_formula2 = formulas_converter.convert_formula(oox_formula2);
if (false == odf_formula2.empty())
{
odf_formula2 = odf_formula2.substr(4);
}
}
table_content_validation *validation = dynamic_cast<table_content_validation*>(state().data_validations_.back().elm.get());
std::wstring odf_condition;
switch(state().data_validations_.back().operator_)
{
case 0: // SimpleTypes::spreadsheet::operatorBetween
odf_condition = L" and cell-content-between(" + odf_formula1 + L"," + odf_formula1 + L")"; break;
case 1: // SimpleTypes::spreadsheet::operatorNotBetween
odf_condition = L" and cell-content--not-between(" + odf_formula1 + L"," + odf_formula1 + L")"; break;
case 2: // SimpleTypes::spreadsheet::operatorEqual
odf_condition = L" and cell-content() == " + odf_formula1; break;
case 3: // SimpleTypes::spreadsheet::operatorNotEqual
odf_condition = L" and cell-content() <> " + odf_formula1; break;
case 4: // SimpleTypes::spreadsheet::operatorLessThan
odf_condition = L" and cell-content() < " + odf_formula1; break;
case 5: // SimpleTypes::spreadsheet::operatorLessThanOrEqual
odf_condition = L" and cell-content() <= " + odf_formula1; break;
case 6: // SimpleTypes::spreadsheet::operatorGreaterThan
odf_condition = L" and cell-content() > " + odf_formula1; break;
case 7: // SimpleTypes::spreadsheet::operatorGreaterThanOrEqual
odf_condition = L" and cell-content() >= " + odf_formula1; break;
}
switch (state().data_validations_.back().type)
{
case 0://SimpleTypes::spreadsheet::validationTypeNone:
break;
case 1://SimpleTypes::spreadsheet::validationTypeCustom:
break;
case 2://SimpleTypes::spreadsheet::validationTypeDate:
{
if (state().data_validations_.back().operator_ >= 0)
{
odf_condition = L"of:cell-content-is-date()" + odf_condition;
}
else
{
odf_condition = L"of:cell-content-is-date(" + odf_formula1 + L")";
}
}break;
case 3://SimpleTypes::spreadsheet::validationTypeDecimal:
{
if (state().data_validations_.back().operator_ >= 0)
{
odf_condition = L"of:cell-content-is-decimal-number()" + odf_condition;
}
else
{
odf_condition = L"of:cell-content-is-decimal-number(" + odf_formula1 + L")";
}
}break;
case 4://SimpleTypes::spreadsheet::validationTypeList:
{
odf_condition = L"of:cell-content-is-in-list(" + odf_formula1 + L")";
}break;
case 5://SimpleTypes::spreadsheet::validationTypeTextLength:
break;
case 6://SimpleTypes::spreadsheet::validationTypeTime:
{
if (state().data_validations_.back().operator_ >= 0)
{
odf_condition = L"of:cell-content-is-time()" + odf_condition;
}
else
{
odf_condition = L"of:cell-content-is-time(" + odf_formula1 + L")";
}
}break;
case 7://SimpleTypes::spreadsheet::validationTypeWhole:
{
if (state().data_validations_.back().operator_ >= 0)
{
odf_condition = L"of:cell-content-is-whole-number()" + odf_condition;
}
else
{
odf_condition = L"of:cell-content-is-whole-number(" + odf_formula1 + L")";
}
}break;
}
state().data_validations_.back().condition = odf_condition;
validation->table_condition_ = odf_condition;
}
void ods_table_context::set_data_validation_error(const std::wstring &title, const std::wstring &content)
{
if (state().data_validations_.empty()) return;
office_element_ptr elm;
create_element(L"table", L"error-message", elm, &context_);
table_content_validations_.elements.back()->add_child_element(elm);
table_error_message *error_message = dynamic_cast<table_error_message*>(elm.get());
if (error_message)
{
error_message->table_display_ = true;
if (false == title.empty()) error_message->table_title_ = title;
if (false == content.empty())
{
}
}
}
void ods_table_context::set_data_validation_promt(const std::wstring &title, const std::wstring &content)
{
if (state().data_validations_.empty()) return;
office_element_ptr elm;
create_element(L"table", L"help-message", elm, &context_);
table_content_validations_.elements.back()->add_child_element(elm);
table_help_message *help_message = dynamic_cast<table_help_message*>(elm.get());
if (help_message)
{
help_message->table_display_ = true;
if (false == title.empty()) help_message->table_title_ = title;
if (false == content.empty())
{
}
}
}
void ods_table_context::end_data_validation()
{
}
void ods_table_context::start_defined_expressions(office_element_ptr & root_elm)
{
table_defined_expressions_.root = root_elm;
@ -164,14 +438,14 @@ void ods_table_context::add_defined_range(const std::wstring & name, const std::
std::wstring odf_range = formulas_converter.convert_named_ref(cell_range);//todo - разделить конвертацию диапазонов/рэнжей на c [] и без
std::wstring odf_base_cell = formulas_converter.get_table_name() + L".$A$1";
std::wstring odf_base_cell = formulas_converter.get_table_name();
named_range->table_name_ = name;
named_range->table_cell_range_address_ = odf_range;
if (printable)
named_range->table_range_usable_as_ = L"print-range";
if (odf_base_cell.length() > 0)
if (false == odf_base_cell.empty())
named_range->table_base_cell_address_ = odf_base_cell;
table_defined_expressions_.elements.push_back(elm);
@ -197,23 +471,29 @@ void ods_table_context::add_defined_range(const std::wstring & name, const std::
}
void ods_table_context::add_defined_expression(const std::wstring & name, const std::wstring & value, int sheet_id, bool printable)
{
formulasconvert::oox2odf_converter formulas_converter;
bool simple_range = formulas_converter.is_simple_ref(value);
if (simple_range)//если простой - range, составной - выражение
return add_defined_range (name, value, sheet_id, printable);
office_element_ptr elm;
create_element(L"table", L"named-expression",elm, &context_);
table_named_expression* named_expression = dynamic_cast<table_named_expression*>(elm.get());
if (named_expression == NULL)return;
formulasconvert::oox2odf_converter formulas_converter;
std::wstring odf_value = formulas_converter.convert_named_formula(value);
std::wstring odf_base_cell = formulas_converter.get_table_name() + L".$A$1";
std::wstring odf_base_cell = formulas_converter.get_table_name();
named_expression->table_name_ = name;
named_expression->table_expression_ = odf_value;
if (sheet_id >=0 && sheet_id < table_state_list_.size())
{
odf_base_cell = table_state_list_[sheet_id].office_table_name_ + L".$A$1";
odf_base_cell = L"$" + table_state_list_[sheet_id].office_table_name_ + L".$A$1";
table_state_list_[sheet_id].add_definded_expression(elm);
if ( printable)

View File

@ -74,6 +74,13 @@ public:
void add_table_part_column(std::wstring name);
void end_table_part();
bool start_data_validation(const std::wstring &ref, int type);
void set_data_validation_operator(int val);
void set_data_validation_content(std::wstring val1, std::wstring val2);
void set_data_validation_allow_empty(bool val);
void set_data_validation_error(const std::wstring &title, const std::wstring &content);
void set_data_validation_promt(const std::wstring &title, const std::wstring &content);
void end_data_validation();
private:
ods_conversion_context & context_;
@ -82,6 +89,7 @@ private:
table_additional_elements_state table_defined_expressions_;
table_additional_elements_state table_database_ranges_;
table_additional_elements_state table_content_validations_;
friend class ods_conversion_context;

View File

@ -49,7 +49,6 @@
#include "style_table_properties.h"
#include "style_text_properties.h"
#include "style_paragraph_properties.h"
#include "style_graphic_properties.h"
namespace cpdoccore {
@ -496,15 +495,19 @@ void ods_table_state::set_row_height(double height)
bool ods_table_state::is_cell_hyperlink()
{
if (cells_size_ <1)return false;
return cells_.back().hyperlink_idx >=0 ? true : false;
if ( cells_size_ < 1 )return false;
return cells_.back().hyperlink_idx >= 0 ? true : false;
}
bool ods_table_state::is_cell_comment()
{
if (cells_size_ <1)return false;
if ( cells_size_ < 1 )return false;
return cells_.back().comment_idx >= 0 ? true : false;
}
bool ods_table_state::is_cell_data_validation()
{
if ( cells_size_ < 1 )return false;
return cells_.back().data_validation_name.empty() ? true : false;
}
int ods_table_state::is_cell_hyperlink(int col, int row)
{
for (size_t i = 0; i < hyperlinks_.size(); i++)
@ -516,6 +519,17 @@ int ods_table_state::is_cell_hyperlink(int col, int row)
}
return -1;
}
std::wstring ods_table_state::is_cell_data_validation(int col, int row)
{
for (size_t i = 0; i < data_validations_.size(); i++)
{
if (data_validations_[i].in_ref(col, row))
{
return data_validations_[i].name;
}
}
return L"";
}
int ods_table_state::is_cell_comment(int col, int row, unsigned int repeate_col)
{
for (size_t i = 0; i < comments_.size(); i++)
@ -616,8 +630,9 @@ void ods_table_state::start_cell(office_element_ptr & elm, office_element_ptr &
state.elm = elm; state.repeated = 1; state.style_name = style_name; state.style_elm = style_elm;
state.row = current_table_row_; state.col = current_table_column_ + 1;
state.hyperlink_idx = is_cell_hyperlink(state.col, state.row);
state.comment_idx = is_cell_comment(state.col, state.row);
state.hyperlink_idx = is_cell_hyperlink(state.col, state.row);
state.comment_idx = is_cell_comment(state.col, state.row);
state.data_validation_name = is_cell_data_validation(state.col, state.row);
current_table_column_ += state.repeated;
cells_.push_back(state);
@ -706,20 +721,51 @@ void ods_table_state::start_comment(int col, int row, std::wstring & author)
state.row = row; state.col = col; state.author = author;
create_element(L"office", L"annotation", state.elm, context_);
office_annotation * annotation = dynamic_cast<office_annotation*>(state.elm.get());
if (!annotation)return;
context_->styles_context()->create_style(L"", style_family::Graphic, true, false, -1);
office_element_ptr & style_elm = context_->styles_context()->last_state()->get_office_element();
state.graphic_properties = context_->styles_context()->last_state()->get_graphic_properties();
style* style_ = dynamic_cast<style*>(style_elm.get());
if (style_)
{
annotation->attr_.draw_style_name_ = style_->style_name_;
}
comments_.push_back(state);
}
void ods_table_state::set_comment_color(const std::wstring & color)
{
if (color.empty()) return;
if (comments_.empty()) return;
if (!comments_.back().graphic_properties) return;
comments_.back().graphic_properties->common_draw_fill_attlist_.draw_fill_color_ = L"#" + color;
comments_.back().graphic_properties->common_draw_fill_attlist_.draw_fill_ = odf_types::draw_fill::solid;
}
void ods_table_state::set_comment_visible(bool val)
{
if (comments_.empty()) return;
office_annotation * annotation = dynamic_cast<office_annotation*>(comments_.back().elm.get());
if (!annotation)return;
annotation->attr_.display_ = val;
}
void ods_table_state::set_comment_rect(double l, double t, double w, double h)
{
if (comments_.size() < 1)return;
if (comments_.empty())return;
office_annotation * annotation = dynamic_cast<office_annotation*>(comments_.back().elm.get());
if (!annotation)return;
annotation->office_annotation_attr_.svg_y_ = length(t/10.,length::cm);
annotation->office_annotation_attr_.svg_x_ = length(l/10.,length::cm);
annotation->office_annotation_attr_.svg_width_ = length(w/10.,length::cm);
annotation->office_annotation_attr_.svg_height_ = length(h/10.,length::cm);
annotation->attr_.svg_y_ = length(t/10.,length::cm);
annotation->attr_.svg_x_ = length(l/10.,length::cm);
annotation->attr_.svg_width_ = length(w/10.,length::cm);
annotation->attr_.svg_height_ = length(h/10.,length::cm);
}
void ods_table_state::end_comment(odf_text_context *text_context)
{
@ -756,7 +802,7 @@ void ods_table_state::check_spanned_cells()
int start_col = jt->first;
int end_col = jt->first + jt->second.spanned_cols;
for (size_t i = 0; i < cells_.size(); ++i)
for (size_t i = 0; i < cells_.size(); ++i) //todooo cells_ vector -> map by row
{
if (cells_[i].row > end_row) break;
@ -879,7 +925,7 @@ void ods_table_state::set_cell_formula(std::wstring & formula)
//test external link
bool bExternal = !ods_context->externals_.empty();
boost::wregex re(L"([\[]\\d+[\]])+");
boost::wregex re(L"([\\[]\\d+[\\]])+");
while(bExternal)
{
@ -996,7 +1042,7 @@ void ods_table_state::add_or_find_cell_shared_formula(std::wstring & formula, st
std::wstring odf_formula;
if (formula.size() > 0)
if (false == formula.empty())
{
odf_formula = formulas_converter_table.convert_formula(formula);
@ -1004,14 +1050,14 @@ void ods_table_state::add_or_find_cell_shared_formula(std::wstring & formula, st
std::vector<std::wstring> distance;
boost::algorithm::split(distance, ref,boost::algorithm::is_any_of(L":"), boost::algorithm::token_compress_on);
if (distance.size() >1)
if (distance.size() > 1)
{
int col1, row1, col2, row2;
utils::parsing_ref(distance[0],col1,row1);
utils::parsing_ref(distance[1],col2,row2);
if (row2-row1 >0)moving_type = 2;
if (col2-col1 >0)moving_type = 1;
if (row2 - row1 > 0) moving_type = 2;
if (col2 - col1 > 0)moving_type = 1;
}
ods_shared_formula_state state = {(unsigned int)ind, odf_formula,ref, current_table_column_,current_table_row_, moving_type};
shared_formulas_.push_back(state);
@ -1290,6 +1336,11 @@ void ods_table_state::end_cell()
cells_.back().elm->add_child_element(comm_elm);
comments_[cells_.back().comment_idx].used = true;
}
if (false == cells_.back().data_validation_name.empty())
{
table_table_cell* cell = dynamic_cast<table_table_cell*>(cells_.back().elm.get());
if (cell)cell->attlist_.table_content_validation_name_ = cells_.back().data_validation_name;
}
if (cells_.back().empty)
{
table_table_cell* cell = dynamic_cast<table_table_cell*>(cells_.back().elm.get());
@ -1405,8 +1456,9 @@ void ods_table_state::add_default_cell( unsigned int repeated)
state.row = current_table_row_;
state.col = current_table_column_ + 1;
state.hyperlink_idx = is_cell_hyperlink(state.col, current_table_row_);
state.comment_idx = comment_idx;
state.hyperlink_idx = is_cell_hyperlink(state.col, current_table_row_);
state.data_validation_name = is_cell_data_validation(state.col, current_table_row_);
state.comment_idx = comment_idx;
cells_.push_back(state);
cells_size_++;

View File

@ -43,6 +43,7 @@
#include "odf_controls_context.h"
#include "office_elements_create.h"
#include "style_graphic_properties.h"
#include "officevaluetype.h"
@ -185,6 +186,8 @@ struct ods_cell_state : ods_element_state
int hyperlink_idx = -1;
int comment_idx = -1;
std::wstring data_validation_name;
bool empty = true;
};
@ -206,6 +209,8 @@ struct ods_comment_state
office_element_ptr elm;
graphic_format_properties *graphic_properties = NULL;
bool used = false;
};
struct ods_shared_formula_state
@ -238,6 +243,38 @@ struct table_part_state
std::vector<std::pair<std::wstring, std::wstring>> columns; //name, odf_ref
};
struct data_validation_state
{
std::wstring name;
int type = 0;
int operator_ = -1;
office_element_ptr elm;
struct _ref
{
std::wstring ref;
int col_start = 0;
int row_start = 0;
int col_end = 0;
int row_end = 0;
};
std::vector<_ref> refs;
std::wstring condition;
bool in_ref(int col, int row)
{
for (size_t i = 0; i < refs.size(); i++)
{
if (col >= refs[i].col_start && col <= refs[i].col_end && row >= refs[i].row_start && row <= refs[i].row_end)
return true;
}
return false;
}
};
struct ods_array_formula_state
{
std::wstring formula;
@ -335,6 +372,8 @@ public:
void start_comment(int col, int row, std::wstring & author);
void set_comment_rect(double l, double t, double w, double h);
void set_comment_visible(bool val);
void set_comment_color(const std::wstring & color);
void end_comment(odf_text_context *text_context);
void set_merge_cells(int start_col, int start_row, int end_col, int end_row);
@ -342,11 +381,14 @@ public:
office_element_ptr & current_row_element();
office_element_ptr & current_cell_element();
bool is_cell_hyperlink ();
int is_cell_hyperlink (int col, int row);
bool is_cell_comment ();
int is_cell_comment (int col, int row, unsigned int repeate_col = 1);
int is_row_comment (int row, int repeate_row = 1);
bool is_cell_data_validation();
bool is_cell_hyperlink();
bool is_cell_comment();
int is_cell_hyperlink(int col, int row);
int is_cell_comment(int col, int row, unsigned int repeate_col = 1);
int is_row_comment(int row, int repeate_row = 1);
std::wstring is_cell_data_validation(int col, int row);
unsigned int get_last_row_repeated ();
@ -403,6 +445,7 @@ private:
std::vector<ods_element_state> columns_;
std::vector<ods_element_state> rows_;
// row column
std::map<int, std::map<int, _spanned_info>> map_merged_cells;
std::vector<office_element_ptr> current_level_;//постоянно меняющийся список уровней ("0-й элемент - сама таблица)
@ -415,6 +458,8 @@ private:
std::vector<table_part_state> table_parts_;
std::vector<data_validation_state> data_validations_;
odf_drawing_context drawing_context_;
odf_controls_context controls_context_;

View File

@ -62,15 +62,15 @@ namespace utils
double calculate_size_font_symbols(std::wstring str_test, std::wstring font_name, double font_size, NSFonts::IApplicationFonts *appFonts)
{
double appr_px = _graphics_utils_::calculate_size_symbol_asc(font_name, font_size, false, false, appFonts);
std::pair<float,float> appr = _graphics_utils_::calculate_size_symbol_asc(font_name, font_size, false, false, appFonts);
if (appr_px <0.01)
if (appr.first < 0.01 || appr.second < 0.01)
{
appr_px = _graphics_utils_::calculate_size_symbol_win(font_name, font_size, false, false, str_test);
appr.first = _graphics_utils_::calculate_size_symbol_win(font_name, font_size, false, false, str_test);
//appr_px = ((int)(appr_px+0.5) + 2*(int)appr_px)/3.;
}
return appr_px*0.55;
return appr.first * 0.55;
}
}
odt_conversion_context::odt_conversion_context(package::odf_document * outputDocument)

View File

@ -142,7 +142,7 @@ void office_annotation_end::serialize(std::wostream & _Wostream)
{
CP_XML_NODE_SIMPLE()
{
office_annotation_attr_.serialize(CP_GET_XML_NODE());
attr_.serialize(CP_GET_XML_NODE());
}
}
}
@ -152,7 +152,7 @@ void office_annotation::serialize(std::wostream & _Wostream)
{
CP_XML_NODE_SIMPLE()
{
office_annotation_attr_.serialize(CP_GET_XML_NODE());
attr_.serialize(CP_GET_XML_NODE());
if (dc_creator_)dc_creator_->serialize(CP_XML_STREAM());
if (dc_date_) dc_date_->serialize(CP_XML_STREAM());
@ -203,7 +203,7 @@ void officeooo_annotation::serialize(std::wostream & _Wostream)
{
CP_XML_NODE_SIMPLE()
{
office_annotation_attr_.serialize(CP_GET_XML_NODE());
attr_.serialize(CP_GET_XML_NODE());
if (dc_creator_)dc_creator_->serialize(CP_XML_STREAM());
if (dc_date_) dc_date_->serialize(CP_XML_STREAM());

View File

@ -122,7 +122,7 @@ public:
virtual void serialize(std::wostream & _Wostream);
office_annotation_attr office_annotation_attr_;
office_annotation_attr attr_;
private:
office_element_ptr_array content_;
@ -148,7 +148,7 @@ public:
virtual void serialize(std::wostream & _Wostream);
office_annotation_attr office_annotation_attr_;
office_annotation_attr attr_;
//
//private:
// office_element_ptr_array content_;
@ -176,7 +176,7 @@ public:
virtual void serialize(std::wostream & _Wostream);
private:
office_annotation_attr office_annotation_attr_;
office_annotation_attr attr_;
office_element_ptr_array content_;
office_element_ptr dc_date_;

View File

@ -52,11 +52,17 @@ const wchar_t * office_presentation::name = L"presentation";
void office_presentation::create_child_element(const std::wstring & Ns, const std::wstring & Name)
{
if CP_CHECK_NAME(L"draw", L"page")
{
CP_CREATE_ELEMENT(pages_);
}
else if CP_CHECK_NAME(L"presentation", L"footer-decl")
{
CP_CREATE_ELEMENT(footer_decls_);
}
else if CP_CHECK_NAME(L"presentation", L"date-time-decl")
{
CP_CREATE_ELEMENT(date_time_decls_);
}
}
void office_presentation::add_child_element( const office_element_ptr & child_element)

View File

@ -41,7 +41,6 @@
namespace cpdoccore {
namespace odf_writer {
// office:presentation
class office_presentation : public office_element_impl<office_presentation>
{
public:
@ -62,7 +61,6 @@ public:
office_element_ptr_array pages_;
};
CP_REGISTER_OFFICE_ELEMENT2(office_presentation);
}

View File

@ -48,12 +48,57 @@ const wchar_t * office_spreadsheet::name = L"spreadsheet";
void office_spreadsheet::create_child_element(const std::wstring & Ns, const std::wstring & Name)
{
CP_CREATE_ELEMENT(content_);
}
if CP_CHECK_NAME(L"office", L"forms")
{
CP_CREATE_ELEMENT(forms_);
}
else if CP_CHECK_NAME(L"table", L"database-ranges")
{
CP_CREATE_ELEMENT(database_ranges_);
}
else if CP_CHECK_NAME(L"table", L"named-expressions")
{
CP_CREATE_ELEMENT(named_expressions_);
}
else if CP_CHECK_NAME(L"table", L"data-pilot-tables")
{
CP_CREATE_ELEMENT(data_pilot_tables_);
}
else if CP_CHECK_NAME(L"table", L"content-validations")
{
CP_CREATE_ELEMENT(content_validations_);
}
else
CP_CREATE_ELEMENT(content_);}
void office_spreadsheet::add_child_element( const office_element_ptr & child_element)
{
content_.push_back(child_element);
ElementType type = child_element->get_type();
if ( type == typeOfficeForms)
{
forms_ = child_element;
}
else if ( type == typeTableContentValidations)
{
content_validations_ = child_element;
}
else if ( type == typeTableDataPilotTables)
{
data_pilot_tables_ = child_element;
}
else if ( type == typeTableDatabaseRanges)
{
database_ranges_ = child_element;
}
else if ( type == typeTableNamedExpressions)
{
named_expressions_ = child_element;
}
else
{
content_.push_back(child_element);
}
}
void office_spreadsheet::serialize(std::wostream & _Wostream)
{
@ -61,10 +106,25 @@ void office_spreadsheet::serialize(std::wostream & _Wostream)
{
CP_XML_NODE_SIMPLE()
{
if (forms_)
forms_->serialize(CP_XML_STREAM());
if (content_validations_)
content_validations_->serialize(CP_XML_STREAM());
for (size_t i = 0; i < content_.size(); i++)
{
content_[i]->serialize(CP_XML_STREAM());
}
if (data_pilot_tables_)
data_pilot_tables_->serialize(CP_XML_STREAM());
if (named_expressions_)
named_expressions_->serialize(CP_XML_STREAM());
if (database_ranges_)
database_ranges_->serialize(CP_XML_STREAM());
}
}
}

View File

@ -42,8 +42,6 @@
namespace cpdoccore {
namespace odf_writer {
/// \brief office:spreadsheet
class office_spreadsheet : public office_element_impl<office_spreadsheet>
{
public:
@ -55,25 +53,26 @@ public:
office_element_ptr_array & getContent(){return content_;}
virtual void create_child_element(const std::wstring & Ns, const std::wstring & Name);
virtual void add_child_element( const office_element_ptr & child_element);
virtual void serialize(std::wostream & _Wostream);
private:
// TODO: office-text-content-prelude:
// TODO: text-tracked-changes
// TODO: text-decls
// TODO: table-decls
office_element_ptr_array content_;
// TODO: text-page-sequence
// TODO: office-text-content-epilogue:
// TODO: table-functions
office_element_ptr named_expressions_;
office_element_ptr database_ranges_;
office_element_ptr data_pilot_tables_;
office_element_ptr content_validations_;
office_element_ptr_array content_;
office_element_ptr forms_;
// table:calculation-settings
// table:consolidation
// table:dde-links
// table:label-ranges
};
CP_REGISTER_OFFICE_ELEMENT2(office_spreadsheet);
}

View File

@ -68,7 +68,6 @@ public:
void serialize(std::wostream & strm, const wchar_t * ns, const wchar_t * name );
public:
_CP_OPT(odf_types::length_or_percent) fo_min_width_;
_CP_OPT(odf_types::length_or_percent) fo_min_height_;
_CP_OPT(odf_types::length_or_percent) fo_max_width_;

View File

@ -956,5 +956,119 @@ void table_shapes::serialize(std::wostream & _Wostream)
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * table_content_validations::ns = L"table";
const wchar_t * table_content_validations::name = L"content-validations";
void table_content_validations::create_child_element( const std::wstring & Ns, const std::wstring & Name)
{
CP_CREATE_ELEMENT(content_);
}
void table_content_validations::add_child_element( const office_element_ptr & child_element)
{
content_.push_back(child_element);
}
void table_content_validations::serialize(std::wostream & _Wostream)
{
CP_XML_WRITER(_Wostream)
{
CP_XML_NODE_SIMPLE()
{
for (size_t i = 0; i < content_.size(); i++)
{
content_[i]->serialize(CP_XML_STREAM());
}
}
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * table_content_validation::ns = L"table";
const wchar_t * table_content_validation::name = L"content-validation";
void table_content_validation::create_child_element( const std::wstring & Ns, const std::wstring & Name)
{
CP_CREATE_ELEMENT(content_);
}
void table_content_validation::add_child_element( const office_element_ptr & child_element)
{
content_.push_back(child_element);
}
void table_content_validation::serialize(std::wostream & _Wostream)
{
CP_XML_WRITER(_Wostream)
{
CP_XML_NODE_SIMPLE()
{
CP_XML_ATTR_OPT(L"table:name", table_name_);
CP_XML_ATTR_OPT(L"table:condition", table_condition_);
CP_XML_ATTR_OPT(L"table:display-list", table_display_list_);
CP_XML_ATTR_OPT(L"table:allow-empty-cell", table_allowempty_cell_);
CP_XML_ATTR_OPT(L"table:base-cell-address", table_base_cell_address_);
for (size_t i = 0; i < content_.size(); i++)
{
content_[i]->serialize(CP_XML_STREAM());
}
}
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * table_error_message::ns = L"table";
const wchar_t * table_error_message::name = L"error-message";
void table_error_message::create_child_element( const std::wstring & Ns, const std::wstring & Name)
{
CP_CREATE_ELEMENT(content_);
}
void table_error_message::add_child_element( const office_element_ptr & child_element)
{
content_.push_back(child_element);
}
void table_error_message::serialize(std::wostream & _Wostream)
{
CP_XML_WRITER(_Wostream)
{
CP_XML_NODE_SIMPLE()
{
CP_XML_ATTR_OPT(L"table:title", table_title_);
CP_XML_ATTR_OPT(L"table:message-type", table_message_type_);
CP_XML_ATTR_OPT(L"table:display", table_display_);
for (size_t i = 0; i < content_.size(); i++)
{
content_[i]->serialize(CP_XML_STREAM());
}
}
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * table_help_message::ns = L"table";
const wchar_t * table_help_message::name = L"help-message";
void table_help_message::create_child_element( const std::wstring & Ns, const std::wstring & Name)
{
CP_CREATE_ELEMENT(content_);
}
void table_help_message::add_child_element( const office_element_ptr & child_element)
{
content_.push_back(child_element);
}
void table_help_message::serialize(std::wostream & _Wostream)
{
CP_XML_WRITER(_Wostream)
{
CP_XML_NODE_SIMPLE()
{
CP_XML_ATTR_OPT(L"table:title", table_title_);
CP_XML_ATTR_OPT(L"table:message-type", table_message_type_);
CP_XML_ATTR_OPT(L"table:display", table_display_);
for (size_t i = 0; i < content_.size(); i++)
{
content_[i]->serialize(CP_XML_STREAM());
}
}
}
}
}
}

View File

@ -684,8 +684,101 @@ public:
office_element_ptr_array content_;
};
CP_REGISTER_OFFICE_ELEMENT2(table_shapes);
//table:content-validations
class table_content_validations : public office_element_impl<table_content_validations>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeTableContentValidations;
CPDOCCORE_DEFINE_VISITABLE();
virtual void create_child_element(const std::wstring & Ns, const std::wstring & Name);
virtual void add_child_element( const office_element_ptr & child_element);
virtual void serialize(std::wostream & _Wostream);
office_element_ptr_array content_;
};
CP_REGISTER_OFFICE_ELEMENT2(table_content_validations);
//table:content-validation
class table_content_validation : public office_element_impl<table_content_validation>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeTableContentValidation;
CPDOCCORE_DEFINE_VISITABLE();
virtual void create_child_element(const std::wstring & Ns, const std::wstring & Name);
virtual void add_child_element( const office_element_ptr & child_element);
virtual void serialize(std::wostream & _Wostream);
_CP_OPT(std::wstring) table_name_;
_CP_OPT(odf_types::Bool) table_allowempty_cell_;
_CP_OPT(std::wstring) table_display_list_;
_CP_OPT(std::wstring) table_condition_;
_CP_OPT(std::wstring) table_base_cell_address_;
office_element_ptr_array content_;
};
CP_REGISTER_OFFICE_ELEMENT2(table_content_validation);
//table:error-message
class table_error_message : public office_element_impl<table_error_message>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeTableErrorMassage;
CPDOCCORE_DEFINE_VISITABLE();
virtual void create_child_element(const std::wstring & Ns, const std::wstring & Name);
virtual void add_child_element( const office_element_ptr & child_element);
virtual void serialize(std::wostream & _Wostream);
_CP_OPT(std::wstring) table_title_;
_CP_OPT(odf_types::Bool) table_display_;
_CP_OPT(std::wstring) table_message_type_;
office_element_ptr_array content_;
};
CP_REGISTER_OFFICE_ELEMENT2(table_error_message);
//table:help-message
class table_help_message : public office_element_impl<table_help_message>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeTableHelpMassage;
CPDOCCORE_DEFINE_VISITABLE();
virtual void create_child_element(const std::wstring & Ns, const std::wstring & Name);
virtual void add_child_element( const office_element_ptr & child_element);
virtual void serialize(std::wostream & _Wostream);
_CP_OPT(std::wstring) table_title_;
_CP_OPT(odf_types::Bool) table_display_;
_CP_OPT(std::wstring) table_message_type_;
office_element_ptr_array content_;
};
CP_REGISTER_OFFICE_ELEMENT2(table_help_message);
}
}

View File

@ -112,8 +112,8 @@ void table_named_range::serialize(std::wostream & _Wostream)
CP_XML_NODE_SIMPLE()
{
CP_XML_ATTR_OPT(L"table:name", table_name_);
CP_XML_ATTR_OPT(L"table:cell-range-address", table_cell_range_address_);
CP_XML_ATTR_OPT(L"table:base-cell-address", table_base_cell_address_);
CP_XML_ATTR_OPT(L"table:cell-range-address", table_cell_range_address_);
CP_XML_ATTR_OPT(L"table:range-usable-as", table_range_usable_as_);
}
}
@ -131,8 +131,8 @@ void table_named_expression::serialize(std::wostream & _Wostream)
CP_XML_NODE_SIMPLE()
{
CP_XML_ATTR_OPT(L"table:name", table_name_);
CP_XML_ATTR_OPT(L"table:expression", table_expression_);
CP_XML_ATTR_OPT(L"table:base-cell-address", table_base_cell_address_);
CP_XML_ATTR_OPT(L"table:expression", table_expression_);
}
}
}

View File

@ -1998,7 +1998,7 @@ void OoxConverter::convert(PPTX::Logic::RunProperties *oox_run_pr, odf_writer::s
{
if (oox_run_pr->Fill.is_init())
{
drawing->start_area_properties(true);
drawing->start_area_properties();
convert(&oox_run_pr->Fill);
drawing->end_area_properties();
}

View File

@ -161,7 +161,21 @@ void OoxConverter::convert(OOX::Spreadsheet::CT_Tx* ct_tx)
{
if (ct_tx == NULL)return;
convert_chart_text(ct_tx->m_oRich.GetPointer());
if (ct_tx->m_oRich.IsInit())
{
convert_chart_text(ct_tx->m_oRich.GetPointer());
}
else if (ct_tx->m_strRef)
{
if (ct_tx->m_strRef->m_f)
odf_context()->chart_context()->set_label_formula(*ct_tx->m_strRef->m_f);
if ((ct_tx->m_strRef->m_strCache) && (false == ct_tx->m_strRef->m_strCache->m_pt.empty())
&& (ct_tx->m_strRef->m_strCache->m_pt[0]) && (ct_tx->m_strRef->m_strCache->m_pt[0]->m_v))
{
odf_context()->chart_context()->add_text(*ct_tx->m_strRef->m_strCache->m_pt[0]->m_v);
}
}
}
void OoxConverter::convert(OOX::Spreadsheet::CT_Layout* ct_layout)
{
@ -293,6 +307,10 @@ void OoxConverter::convert(OOX::Spreadsheet::CT_CatAx* axis)
convert(axis->m_oSpPr.GetPointer());
if ((axis->m_delete) && (axis->m_delete->m_val))
{
odf_context()->chart_context()->set_axis_visible(*axis->m_delete->m_val == false);
}
if (axis->m_scaling)
{
if (axis->m_scaling->m_logBase)
@ -336,6 +354,10 @@ void OoxConverter::convert(OOX::Spreadsheet::CT_DateAx* axis)
convert(axis->m_oSpPr.GetPointer());
if ((axis->m_delete) && (axis->m_delete->m_val))
{
odf_context()->chart_context()->set_axis_visible(*axis->m_delete->m_val == false);
}
if (axis->m_scaling)
{
if (axis->m_scaling->m_logBase)
@ -377,6 +399,10 @@ void OoxConverter::convert(OOX::Spreadsheet::CT_SerAx* axis)
convert(axis->m_oSpPr.GetPointer());
if ((axis->m_delete) && (axis->m_delete->m_val))
{
odf_context()->chart_context()->set_axis_visible(*axis->m_delete->m_val == false);
}
if (axis->m_scaling)
{
if (axis->m_scaling->m_logBase)
@ -417,6 +443,11 @@ void OoxConverter::convert(OOX::Spreadsheet::CT_ValAx* axis)
odf_context()->chart_context()->set_axis_id(*axis->m_axId->m_val);
convert(axis->m_oSpPr.GetPointer());
if ((axis->m_delete) && (axis->m_delete->m_val))
{
odf_context()->chart_context()->set_axis_visible(*axis->m_delete->m_val == false);
}
if (axis->m_scaling)
{

View File

@ -2298,7 +2298,7 @@ void DocxConverter::convert(OOX::Logic::CRunProperty *oox_run_pr, odf_writer::st
{
if (drawing_context->change_text_box_2_wordart())
{
drawing_context->start_area_properties(true);
drawing_context->start_area_properties();
if(gradFill.IsInit())
{
OoxConverter::convert(gradFill.operator->());

View File

@ -243,14 +243,8 @@ void XlsxConverter::convert(OOX::Spreadsheet::CDefinedName *oox_defined)
bool printable = false;
if (name == L"_xlnm.Print_Area")printable = true;
//todoooo !!!! сделать анализ на функцию, диапазон, константы .... !!!
if (false)//если простой - range, составной - выражение
ods_context->add_defined_range (name, oox_defined->m_oRef.get2(), sheet_id, printable);
else
ods_context->add_defined_expression (name, oox_defined->m_oRef.get2(), sheet_id, printable);
ods_context->add_defined_expression (name, oox_defined->m_oRef.get2(), sheet_id, printable);
}
}
void XlsxConverter::convert(OOX::Spreadsheet::CWorksheet *oox_sheet)
{
@ -305,6 +299,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CWorksheet *oox_sheet)
}
}
}
convert(oox_sheet->m_oDataValidations.GetPointer());
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//колонки
ods_context->start_columns();
@ -368,7 +363,6 @@ void XlsxConverter::convert(OOX::Spreadsheet::CWorksheet *oox_sheet)
}
/////////////////////////////////////////////////////////////////////////
convert(oox_sheet->m_oDataValidations.GetPointer());
convert(oox_sheet->m_oSheetViews.GetPointer());
convert(oox_sheet->m_oHeaderFooter.GetPointer());
convert(oox_sheet->m_oPageSetup.GetPointer());
@ -428,6 +422,36 @@ void XlsxConverter::convert(OOX::Spreadsheet::CDataValidations *oox_validations)
void XlsxConverter::convert(OOX::Spreadsheet::CDataValidation *oox_validation)
{
if (!oox_validation) return;
if (!oox_validation->m_oSqRef.IsInit()) return;
if (false == ods_context->start_data_validation(*oox_validation->m_oSqRef, oox_validation->m_oType.IsInit() ? oox_validation->m_oType->GetValue() : 0)) return;
if (oox_validation->m_oOperator.IsInit())
{
ods_context->set_data_validation_operator(oox_validation->m_oOperator->GetValue());
}
if (oox_validation->m_oAllowBlank.IsInit())
{
ods_context->set_data_validation_allow_empty(oox_validation->m_oAllowBlank->ToBool());
}
std::wstring formula_1, formula_2;
if (oox_validation->m_oFormula1.IsInit()) formula_1 = oox_validation->m_oFormula1->m_sText;
if (oox_validation->m_oFormula2.IsInit()) formula_2 = oox_validation->m_oFormula2->m_sText;
ods_context->set_data_validation_content(formula_1, formula_2);
if (oox_validation->m_oShowErrorMessage.IsInit() && oox_validation->m_oShowErrorMessage->ToBool())
{
ods_context->set_data_validation_error(oox_validation->m_oErrorTitle.IsInit() ? *oox_validation->m_oErrorTitle : L"",
oox_validation->m_oError.IsInit() ? *oox_validation->m_oError : L"");
}
if (oox_validation->m_oShowInputMessage.IsInit() && oox_validation->m_oShowInputMessage->ToBool())
{
ods_context->set_data_validation_promt(oox_validation->m_oPromptTitle.IsInit() ? *oox_validation->m_oPromptTitle : L"",
oox_validation->m_oPromt.IsInit() ? *oox_validation->m_oPromt : L"");
}
ods_context->end_data_validation();
}
void XlsxConverter::convert(OOX::Spreadsheet::CPictureWorksheet *oox_background)
@ -516,7 +540,18 @@ void XlsxConverter::convert(OOX::Spreadsheet::CCommentItem * oox_comment)
{
ods_context->set_comment_rect(oox_comment->m_dLeftMM.get(), oox_comment->m_dTopMM.get(), oox_comment->m_dWidthMM.get(), oox_comment->m_dHeightMM.get());
}
if (oox_comment->m_bVisible.IsInit())
{
ods_context->set_comment_visible(*oox_comment->m_bVisible);
}
if (oox_comment->m_sFillColorRgb.IsInit())
{
ods_context->set_comment_color(*oox_comment->m_sFillColorRgb);
}
else
{
ods_context->set_comment_color(L"CCFFFF"); //default ms
}
if (oox_comment->m_oText.IsInit())
{
for(size_t i = 0; i < oox_comment->m_oText->m_arrItems.size(); ++i)
@ -2390,7 +2425,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CControls *oox_controls, OOX::Spre
if (false == oCellAnchor.IsInit())
{
oCellAnchor.reset(new OOX::Spreadsheet::CCellAnchor(eAnchorType));
oCellAnchor->m_bShapeOle= true;
oCellAnchor->m_bShapeControl = true;
}
if ((oShape.IsInit()) && (OOX::et_v_shapetype != oShape->getType()))
{
@ -2459,11 +2494,15 @@ void XlsxConverter::convert(OOX::Spreadsheet::CControls *oox_controls, OOX::Spre
}
if (oFormControlPr->m_oFillColor.IsInit())
{
ods_context->drawing_context()->set_solid_fill(oFormControlPr->m_oFillColor->ToString());
ods_context->drawing_context()->start_area_properties(true);
ods_context->drawing_context()->set_solid_fill(oFormControlPr->m_oFillColor->ToString());
ods_context->drawing_context()->end_area_properties();
}
if (oFormControlPr->m_oBorderColor.IsInit())
{
ods_context->drawing_context()->set_line_color(oFormControlPr->m_oBorderColor->ToString());
ods_context->drawing_context()->start_line_properties();
ods_context->drawing_context()->set_line_color(oFormControlPr->m_oBorderColor->ToString());
ods_context->drawing_context()->end_line_properties();
}
if (oFormControlPr->m_oTextHAlign.IsInit())
{

View File

@ -150,13 +150,13 @@ namespace _graphics_utils_
#endif
return result;
}
double calculate_size_symbol_asc(std::wstring name, double size, bool italic, bool bold , NSFonts::IApplicationFonts *appFonts)
std::pair<float,float> calculate_size_symbol_asc(std::wstring name, double size, bool italic, bool bold , NSFonts::IApplicationFonts *appFonts)
{
if (name.empty())
name = L"Arial";
std::pair<float,float> val = cpdoccore::utils::GetMaxDigitSizePixels(name, size, 96., 0 , appFonts);
return val.first;
return val;
}
};

View File

@ -42,5 +42,5 @@ namespace _graphics_utils_
{
bool GetResolution(const wchar_t* fileName, double & Width, double &Height);
double calculate_size_symbol_win(std::wstring name, double size, bool italic, bool bold, std::wstring test_str = L"");
double calculate_size_symbol_asc(std::wstring name, double size, bool italic, bool bold , NSFonts::IApplicationFonts *appFonts);
std::pair<float,float> calculate_size_symbol_asc(std::wstring name, double size, bool italic, bool bold , NSFonts::IApplicationFonts *appFonts);
};

View File

@ -1818,7 +1818,7 @@ void CDrawingConverter::doc_LoadShape(PPTX::Logic::SpTreeElem *elem, XmlUtils::C
std::wstring strCoord1 = oNodeShape.GetAttributeOrValue(L"from");
std::wstring strCoord2 = oNodeShape.GetAttributeOrValue(L"to");
if (strCoord1 != L"" && strCoord2 != L"")
if (!strCoord1.empty() && !strCoord2.empty())
{
std::vector<std::wstring> oArray1;
boost::algorithm::split(oArray1, strCoord1, boost::algorithm::is_any_of(L","), boost::algorithm::token_compress_on);
@ -1905,7 +1905,7 @@ void CDrawingConverter::doc_LoadShape(PPTX::Logic::SpTreeElem *elem, XmlUtils::C
int nOffsetX = _POINTS[0] - _x;
int nOffsetY = _POINTS[1] - _y;
strStyleAdvenced = L";margin-left:" + std::to_wstring(_x) + L";margin-top:" + std::to_wstring(_y)
strStyleAdvenced += L";margin-left:" + std::to_wstring(_x) + L";margin-top:" + std::to_wstring(_y)
+ L";width:" + std::to_wstring(_r - _x) + L";height:" + std::to_wstring(_b - _y) + L";polyline_correct:true;";
double dKoefX = 21600.0 / (std::max)((_r - _x), 1);
@ -3313,8 +3313,11 @@ std::wstring CDrawingConverter::GetDrawingMainProps(XmlUtils::CXmlNode& oNode, P
{
bIsInline = true;
}
if ((oCssStyles.m_mapSettings.end() != oCssStyles.m_mapSettings.find(L"margin-left")) &&
if (((oCssStyles.m_mapSettings.end() != oCssStyles.m_mapSettings.find(L"margin-left")) &&
(oCssStyles.m_mapSettings.end() != oCssStyles.m_mapSettings.find(L"margin-top")))
||
((oCssStyles.m_mapSettings.end() != oCssStyles.m_mapSettings.find(L"left")) &&
(oCssStyles.m_mapSettings.end() != oCssStyles.m_mapSettings.find(L"top"))))
{
bIsMargin = true;
}
@ -3360,7 +3363,13 @@ std::wstring CDrawingConverter::GetDrawingMainProps(XmlUtils::CXmlNode& oNode, P
if (oCssStyles.m_mapSettings.end() != pFind)
{
left = (LONG)(dKoefSize * parserPoint.FromString(pFind->second) + 0.5);
std::vector<std::wstring> oArray1;
boost::algorithm::split(oArray1, pFind->second, boost::algorithm::is_any_of(L","), boost::algorithm::token_compress_on);
for (size_t i = 0; i < oArray1.size(); i++)
{
left += (LONG)(dKoefSize * parserPoint.FromString(oArray1[i]) + 0.5);
}
}
pFind = oCssStyles.m_mapSettings.find(L"margin-top");
@ -3370,7 +3379,12 @@ std::wstring CDrawingConverter::GetDrawingMainProps(XmlUtils::CXmlNode& oNode, P
if (oCssStyles.m_mapSettings.end() != pFind)
{
top = (LONG)(dKoefSize * parserPoint.FromString(pFind->second) + 0.5);
std::vector<std::wstring> oArray1;
boost::algorithm::split(oArray1, pFind->second, boost::algorithm::is_any_of(L","), boost::algorithm::token_compress_on);
for (size_t i = 0; i < oArray1.size(); i++)
{
top += (LONG)(dKoefSize * parserPoint.FromString(oArray1[i]) + 0.5);
}
}
}

View File

@ -79,7 +79,7 @@ namespace PPTX
XmlMacroReadNodeValueBase(oNode, _T("cp:revision"), revision);
XmlMacroReadNodeValueBase(oNode, _T("dc:subject"), subject);
XmlMacroReadNodeValueBase(oNode, _T("dc:title"), title);
XmlMacroReadNodeValueBase(oNode, _T("cp:version"), title);
XmlMacroReadNodeValueBase(oNode, _T("cp:version"), version);
}
virtual void write(const OOX::CPath& filename, const OOX::CPath& directory, OOX::CContentTypes& content)const
{
@ -217,7 +217,7 @@ namespace PPTX
pWriter->EndAttributes();
pWriter->WriteNodeValue2(_T("dc:title"), title);
pWriter->WriteNodeValue2(_T("dc:subject"), title);
pWriter->WriteNodeValue2(_T("dc:subject"), subject);
pWriter->WriteNodeValue2(_T("dc:creator"), creator);
pWriter->WriteNodeValue2(_T("cp:keywords"), keywords);
pWriter->WriteNodeValue2(_T("dc:description"), description);
@ -242,9 +242,9 @@ namespace PPTX
pWriter->WriteStringXML(*modified);
pWriter->WriteNodeEnd(_T("dcterms:modified"));
}
pWriter->WriteNodeValue2(_T("cp:category"), revision);
pWriter->WriteNodeValue2(_T("cp:contentStatus"), revision);
pWriter->WriteNodeValue2(_T("cp:version"), revision);
pWriter->WriteNodeValue2(_T("cp:category"), category);
pWriter->WriteNodeValue2(_T("cp:contentStatus"), contentStatus);
pWriter->WriteNodeValue2(_T("cp:version"), version);
pWriter->EndNode(_T("cp:coreProperties"));
}

View File

@ -103,7 +103,7 @@ namespace PPTX
pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart);
pWriter->WriteInt2(0, amt);
pWriter->WriteInt2(0, hue);
pWriter->WriteInt2(1, hue);
pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd);
pWriter->EndRecord();

View File

@ -40,6 +40,11 @@ namespace SimpleTypes
this->m_eValue = hexcolorAuto;
else
{
size_t split = sValue.find(L" ["); //index ala #ff9 [43]
if (std::wstring::npos != split)
{
sValue = sValue.substr(0, split);
}
//В документации не написано, что цвет может приходить строкой, но в реальных докуентах встречается и word это разруливает.
//CHighlightColor<highlightcolorNone> oHighlightColor(sValue);
CHighlightColor<> oHighlightColor(sValue);

View File

@ -1124,45 +1124,48 @@ namespace OOX
{
std::wstring sName = XmlUtils::GetNameNoNS(oReader.GetName());
if ( L"MoveWithCells" == sName ) m_oMoveWithCells = oReader.GetText2();
else if ( L"SizeWithCells" == sName ) m_oSizeWithCells = oReader.GetText2();
else if ( L"Anchor" == sName ) m_oAnchor = oReader.GetText2();
else if ( L"Row" == sName ) m_oRow = oReader.GetText2();
else if ( L"Column" == sName ) m_oColumn = oReader.GetText2();
else if ( L"DefaultSize" == sName ) m_oDefaultSize = oReader.GetText2();
else if ( L"AutoLine" == sName ) m_oAutoLine = oReader.GetText2();
else if ( L"AutoFill" == sName ) m_oAutoFill = oReader.GetText2();
else if ( L"AutoPict" == sName ) m_oAutoPict = oReader.GetText2();
else if ( L"AutoScale" == sName ) m_oAutoScale = oReader.GetText2();
else if ( L"FmlaLink" == sName ) m_oFmlaLink = oReader.GetText2();
else if ( L"FmlaRange" == sName ) m_oFmlaRange = oReader.GetText2();
else if ( L"FmlaMacro" == sName ) m_oFmlaMacro = oReader.GetText2();
else if ( L"FmlaTxbx" == sName ) m_oFmlaTxbx = oReader.GetText2();
else if ( L"FmlaGroup" == sName ) m_oFmlaGroup = oReader.GetText2();
else if ( L"CF" == sName ) m_oCf = oReader.GetText2();
else if ( L"Min" == sName ) m_oMin = oReader.GetText2();
else if ( L"Max" == sName ) m_oMax = oReader.GetText2();
else if ( L"Val" == sName ) m_oVal = oReader.GetText2();
else if ( L"Inc" == sName ) m_oInc = oReader.GetText2();
else if ( L"Sel" == sName ) m_oSel = oReader.GetText2();
else if ( L"WidthMin" == sName ) m_oWidthMin = oReader.GetText2();
else if ( L"Dx" == sName ) m_oDx = oReader.GetText2();
else if ( L"Page" == sName ) m_oPage = oReader.GetText2();
else if ( L"DropLines" == sName ) m_oDropLines = oReader.GetText2();
else if ( L"NoThreeD2" == sName ) m_oNoThreeD2 = oReader.GetText2();
else if ( L"NoThreeD" == sName ) m_oNoThreeD = oReader.GetText2();
else if ( L"DropStyle" == sName ) m_oDropStyle = oReader.GetText2();
else if ( L"FirstButton" == sName ) m_oFirstButton = oReader.GetText2();
else if ( L"VScroll" == sName ) m_oVScroll = oReader.GetText2();
else if ( L"Horiz" == sName ) m_oHoriz = oReader.GetText2();
else if ( L"TextHAlign" == sName ) m_oTextHAlign = oReader.GetText2();
else if ( L"TextVAlign" == sName ) m_oTextVAlign = oReader.GetText2();
else if ( L"Colored" == sName ) m_oColored = oReader.GetText2();
else if ( L"MultiLine" == sName ) m_oMultiLine = oReader.GetText2();
else if ( L"LockText" == sName ) m_oLockText = oReader.GetText2();
else if ( L"JustLastX" == sName ) m_oJustLastX = oReader.GetText2();
else if ( L"SecretEdit" == sName ) m_oSecretEdit = oReader.GetText2();
else if ( L"SelType" == sName ) m_oSelType = oReader.GetText2();
std::wstring sContent = oReader.GetText2();
if ( L"MoveWithCells" == sName ) m_oMoveWithCells = sContent.empty() ? L"t" : sContent;
else if ( L"SizeWithCells" == sName ) m_oSizeWithCells = sContent.empty() ? L"t" : sContent;
else if ( L"Anchor" == sName ) m_oAnchor = sContent;
else if ( L"Row" == sName ) m_oRow = sContent;
else if ( L"Column" == sName ) m_oColumn = sContent;
else if ( L"DefaultSize" == sName ) m_oDefaultSize = sContent.empty() ? L"t" : sContent;
else if ( L"AutoLine" == sName ) m_oAutoLine = sContent.empty() ? L"t" : sContent;
else if ( L"AutoFill" == sName ) m_oAutoFill = sContent.empty() ? L"t" : sContent;
else if ( L"AutoPict" == sName ) m_oAutoPict = sContent.empty() ? L"t" : sContent;
else if ( L"AutoScale" == sName ) m_oAutoScale = sContent.empty() ? L"t" : sContent;
else if ( L"FmlaLink" == sName ) m_oFmlaLink = sContent;
else if ( L"FmlaRange" == sName ) m_oFmlaRange = sContent;
else if ( L"FmlaMacro" == sName ) m_oFmlaMacro = sContent;
else if ( L"FmlaTxbx" == sName ) m_oFmlaTxbx = sContent;
else if ( L"FmlaGroup" == sName ) m_oFmlaGroup = sContent;
else if ( L"CF" == sName ) m_oCf = sContent;
else if ( L"Min" == sName ) m_oMin = sContent;
else if ( L"Max" == sName ) m_oMax = sContent;
else if ( L"Val" == sName ) m_oVal = sContent;
else if ( L"Inc" == sName ) m_oInc = sContent;
else if ( L"Sel" == sName ) m_oSel = sContent.empty() ? L"t" : sContent;
else if ( L"WidthMin" == sName ) m_oWidthMin = sContent;
else if ( L"Dx" == sName ) m_oDx = sContent;
else if ( L"Page" == sName ) m_oPage = sContent;
else if ( L"DropLines" == sName ) m_oDropLines = sContent;
else if ( L"NoThreeD2" == sName ) m_oNoThreeD2 = sContent.empty() ? L"t" : sContent;
else if ( L"NoThreeD" == sName ) m_oNoThreeD = sContent.empty() ? L"t" : sContent;
else if ( L"DropStyle" == sName ) m_oDropStyle = sContent;
else if ( L"FirstButton" == sName ) m_oFirstButton = sContent.empty() ? L"t" : sContent;
else if ( L"VScroll" == sName ) m_oVScroll = sContent.empty() ? L"t" : sContent;
else if ( L"Horiz" == sName ) m_oHoriz = sContent.empty() ? L"t" : sContent;
else if ( L"TextHAlign" == sName ) m_oTextHAlign = sContent;
else if ( L"TextVAlign" == sName ) m_oTextVAlign = sContent;
else if ( L"Colored" == sName ) m_oColored = sContent.empty() ? L"t" : sContent;
else if ( L"MultiLine" == sName ) m_oMultiLine = sContent.empty() ? L"t" : sContent;
else if ( L"LockText" == sName ) m_oLockText = sContent.empty() ? L"t" : sContent;
else if ( L"JustLastX" == sName ) m_oJustLastX = sContent.empty() ? L"t" : sContent;
else if ( L"SecretEdit" == sName ) m_oSecretEdit = sContent.empty() ? L"t" : sContent;
else if ( L"SelType" == sName ) m_oSelType = sContent;
else if ( L"Visible" == sName ) m_oVisible = sContent.empty() ? L"t" : sContent;
}
}
std::wstring CClientData::toXML() const

View File

@ -1529,6 +1529,7 @@ namespace OOX
nullable_int m_oVal;
nullable<SimpleTypes::Spreadsheet::CHorizontalAlignment<>> m_oTextHAlign;
nullable<SimpleTypes::Spreadsheet::CVerticalAlignment<>>m_oTextVAlign;
nullable_bool m_oVisible;
//x:Accel
//x:Accel2
@ -1555,7 +1556,6 @@ namespace OOX
//x:ScriptText
//x:UIObj
//x:ValidIds
//x:Visible
//x:VTEdit
};
//--------------------------------------------------------------------------------

View File

@ -380,7 +380,7 @@ xmlns:x=\"urn:schemas-microsoft-com:office:excel\">");
std::wstring sGfxdata;
if(comment->m_sGfxdata.IsInit())
sGfxdata = L"o:gfxdata=\"" + comment->m_sGfxdata.get2() + L"\"";
sGfxdata = L"o:gfxdata=\"" + *comment->m_sGfxdata + L"\"";
std::wstring sShape;
sShape += L"<v:shape id=\"_x0000_s" + boost::lexical_cast<std::wstring>(nIndex++) + L" \" type=\"#_x0000_t202\" style='position:absolute;";

View File

@ -52,17 +52,19 @@ namespace OOX
nullable<unsigned int> m_nTopOffset;
nullable<unsigned int> m_nRightOffset;
nullable<unsigned int> m_nBottomOffset;
nullable<double> m_dLeftMM;
nullable<double> m_dTopMM;
nullable<double> m_dWidthMM;
nullable<double> m_dHeightMM;
nullable<std::wstring> m_sAuthor;
nullable_double m_dLeftMM;
nullable_double m_dTopMM;
nullable_double m_dWidthMM;
nullable_double m_dHeightMM;
nullable_string m_sAuthor;
nullable<unsigned int> m_nRow;
nullable<unsigned int> m_nCol;
nullable<bool> m_bMove;
nullable<bool> m_bSize;
nullable<CSi> m_oText;
nullable<std::wstring> m_sGfxdata;
nullable_bool m_bMove;
nullable_bool m_bSize;
nullable<CSi> m_oText;
nullable_string m_sGfxdata;
nullable_bool m_bVisible;
nullable_string m_sFillColorRgb;
CCommentItem()
{
}

View File

@ -47,9 +47,6 @@ void CDataValidationFormula::fromXML(XmlUtils::CXmlLiteReader& oReader)
{
m_sNodeName = oReader.GetName();
if (oReader.IsEmptyNode())
return;
m_sText = oReader.GetText3();
}
@ -86,7 +83,7 @@ void CDataValidation::toXML2(NSStringUtils::CStringBuilder& writer, bool bExtend
WritingStringNullableAttrInt (L"showDropDown", m_oShowDropDown, m_oShowDropDown->GetValue());
WritingStringNullableAttrInt (L"showErrorMessage",m_oShowErrorMessage,m_oShowErrorMessage->GetValue());
WritingStringNullableAttrInt (L"showInputMessage",m_oShowInputMessage,m_oShowInputMessage->GetValue());
writer.WriteString(bExtendedWrite ? L">" : L"/>");
writer.WriteString(L">");
if (bExtendedWrite)
{
@ -106,8 +103,23 @@ void CDataValidation::toXML2(NSStringUtils::CStringBuilder& writer, bool bExtend
{
writer.WriteString(L"<xm:sqref>" + m_oSqRef.get() + L"</xm:sqref>");
}
writer.WriteString(L"</" + node_name + L">");
}
else
{
if (m_oFormula1.IsInit())
{
writer.WriteString(L"<formula1>");
writer.WriteString(m_oFormula1->m_sText);
writer.WriteString(L"</formula1>");
}
if (m_oFormula2.IsInit())
{
writer.WriteString(L"<formula2>");
writer.WriteString(m_oFormula2->m_sText);
writer.WriteString(L"</formula2>");
}
}
writer.WriteString(L"</" + node_name + L">");
}
void CDataValidation::fromXML(XmlUtils::CXmlLiteReader& oReader)
@ -137,7 +149,18 @@ void CDataValidation::fromXML(XmlUtils::CXmlLiteReader& oReader)
}
bool CDataValidation::IsExtended()
{
return (m_oFormula1.IsInit() || m_oFormula2.IsInit());
bool result = true;
if (m_oFormula1.IsInit())
{
if (m_oFormula1->m_sText.find(L"!") != std::wstring::npos && m_oFormula1->m_sText != L"#REF!")
result = false;
}
if (m_oFormula2.IsInit())
{
if (m_oFormula2->m_sText.find(L"!") != std::wstring::npos && m_oFormula2->m_sText != L"#REF!")
result = false;
}
return result;
}
void CDataValidation::ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{

View File

@ -117,7 +117,7 @@ namespace OOX
nullable<SimpleTypes::COnOff<>> m_oShowInputMessage;
nullable_string m_oSqRef; // ToDo переделать на тип "sqref" (18.18.76) - последовательность "ref", разделенные пробелом
//ext
mutable nullable_string m_oUuid;
nullable<CDataValidationFormula> m_oFormula1;
nullable<CDataValidationFormula> m_oFormula2;

View File

@ -344,13 +344,23 @@ namespace OOX
pCommentItem->m_nBottom = m_aAnchor[6];
pCommentItem->m_nBottomOffset = m_aAnchor[7];
}
pCommentItem->m_bMove = pClientData->m_oMoveWithCells;
pCommentItem->m_bSize = pClientData->m_oSizeWithCells;
pCommentItem->m_bVisible = pClientData->m_oVisible;
if(pClientData->m_oMoveWithCells.IsInit())
pCommentItem->m_bMove = *pClientData->m_oMoveWithCells;
if(pClientData->m_oSizeWithCells.IsInit())
pCommentItem->m_bSize = *pClientData->m_oSizeWithCells;
if (pShape->m_oFillColor.IsInit())
{
BYTE r = pShape->m_oFillColor->Get_R();
BYTE g = pShape->m_oFillColor->Get_G();
BYTE b = pShape->m_oFillColor->Get_B();
std::wstringstream sstream;
sstream << boost::wformat( L"%02X%02X%02X" ) % r % g % b;
for(size_t k = 0 ,length3 = pShape->m_oStyle->m_arrProperties.size(); k < length3; ++k)
pCommentItem->m_sFillColorRgb = sstream.str();
}
for(size_t k = 0; k < pShape->m_oStyle->m_arrProperties.size(); ++k)
{
if (pShape->m_oStyle->m_arrProperties[k] == NULL) continue;

View File

@ -37,6 +37,12 @@ CONFIG(debug, debug|release) {
#PLATFORM
win32 {
CONFIG += core_windows
WINDOWS_VERSION_XP = $$(WINDOWS_VERSION_XP)
!isEmpty(WINDOWS_VERSION_XP) {
CONFIG += build_xp
message(xp using)
}
}
DST_ARCH=$$QMAKE_TARGET.arch

View File

@ -173,6 +173,8 @@
17A7F02B1B13154500760AFB /* SvmPlayer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 17A7F0221B13154500760AFB /* SvmPlayer.cpp */; };
17DD67B71B7E2778000F800F /* lepton_utils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 17DD67B51B7E2778000F800F /* lepton_utils.cpp */; };
697B72D41E3B78D90054C17C /* EmfFile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 697B72D31E3B78D90054C17C /* EmfFile.cpp */; };
8AA0EB9B229BE96B00297DE5 /* SVGTransformer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8AA0EB99229BE96B00297DE5 /* SVGTransformer.cpp */; };
8AA0EB9C229BE96B00297DE5 /* SVGFramework.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8AA0EB9A229BE96B00297DE5 /* SVGFramework.cpp */; };
8AC2819D2195A582006FA3D7 /* StringExt.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8AC2819B2195A582006FA3D7 /* StringExt.cpp */; };
/* End PBXBuildFile section */
@ -436,6 +438,10 @@
17A7F0231B13154500760AFB /* SvmPlayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SvmPlayer.h; sourceTree = "<group>"; };
17DD67B51B7E2778000F800F /* lepton_utils.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = lepton_utils.cpp; sourceTree = "<group>"; };
697B72D31E3B78D90054C17C /* EmfFile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EmfFile.cpp; sourceTree = "<group>"; };
8AA0EB97229BE96B00297DE5 /* SVGFramework.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGFramework.h; sourceTree = "<group>"; };
8AA0EB98229BE96B00297DE5 /* SVGTransformer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGTransformer.h; sourceTree = "<group>"; };
8AA0EB99229BE96B00297DE5 /* SVGTransformer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGTransformer.cpp; sourceTree = "<group>"; };
8AA0EB9A229BE96B00297DE5 /* SVGFramework.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGFramework.cpp; sourceTree = "<group>"; };
8AC2819B2195A582006FA3D7 /* StringExt.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StringExt.cpp; path = ../../../common/StringExt.cpp; sourceTree = "<group>"; };
8AC2819C2195A582006FA3D7 /* StringExt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StringExt.h; path = ../../../common/StringExt.h; sourceTree = "<group>"; };
/* End PBXFileReference section */
@ -470,6 +476,7 @@
17A762BC1B0F35320046BC0B /* metafile */ = {
isa = PBXGroup;
children = (
8AA0EB96229BE96B00297DE5 /* svg */,
17A7F0191B13154500760AFB /* StarView */,
17A765081B0F3A3E0046BC0B /* Jp2 */,
17A7631F1B0F38FE0046BC0B /* JBig2 */,
@ -793,6 +800,18 @@
path = ../../../raster/Metafile/StarView;
sourceTree = "<group>";
};
8AA0EB96229BE96B00297DE5 /* svg */ = {
isa = PBXGroup;
children = (
8AA0EB97229BE96B00297DE5 /* SVGFramework.h */,
8AA0EB98229BE96B00297DE5 /* SVGTransformer.h */,
8AA0EB99229BE96B00297DE5 /* SVGTransformer.cpp */,
8AA0EB9A229BE96B00297DE5 /* SVGFramework.cpp */,
);
name = svg;
path = ../../../raster/Metafile/svg;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
@ -827,6 +846,7 @@
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
);
mainGroup = 17A762B11B0F35320046BC0B;
@ -1002,6 +1022,8 @@
17A763EF1B0F39370046BC0B /* bardecode.cpp in Sources */,
17A7631E1B0F389C0046BC0B /* MetaFileUtils.cpp in Sources */,
17A763231B0F39120046BC0B /* JBig2File.cpp in Sources */,
8AA0EB9C229BE96B00297DE5 /* SVGFramework.cpp in Sources */,
8AA0EB9B229BE96B00297DE5 /* SVGTransformer.cpp in Sources */,
17A765031B0F39370046BC0B /* writefile.cpp in Sources */,
17A764B11B0F39370046BC0B /* psio2stub.cpp in Sources */,
17A764FF1B0F39370046BC0B /* webpio.cpp in Sources */,

View File

@ -3003,8 +3003,9 @@ namespace SVG
bool CreateImage (BYTE* pBuffer, unsigned long Length, int ImageEncoder = INVALID_ENCODER)
{
return false;
}
private:
BYTE* m_pBuffer;
@ -5580,6 +5581,12 @@ namespace SVG
inline bool LoadFromFile (const std::wstring& strFile, Storage* model)
{
#if 0
std::wstring sExt = NSFile::GetFileExtention(strFile);
if (sExt != L"svg" && sExt != L"xml")
return false;
#endif
if (model)
{
m_model = model;
@ -5613,19 +5620,26 @@ namespace SVG
}
XmlUtils::CXmlNode oXml;
if (oXml.FromXmlString(sXml))
{
m_nLayerLevel = 0;
if (!oXml.FromXmlString(sXml))
return false;
if (Explore(oXml))
{
m_model->JoinXLinkReference();
m_model->JoinClipPathLinks();
m_model->JoinStyleLinks();
std::wstring sNodeName = oXml.GetName();
if (L"svg" != sNodeName &&
L"g" != sNodeName &&
L"xml" != sNodeName)
return false;
return true;
}
}
m_nLayerLevel = 0;
if (Explore(oXml))
{
m_model->JoinXLinkReference();
m_model->JoinClipPathLinks();
m_model->JoinStyleLinks();
return true;
}
}
return false;
@ -5922,8 +5936,9 @@ namespace SVG
std::wstring strXmlNode = oXmlNode.GetName();
if (!strXmlNode.empty())
{
if ('#' == strXmlNode.c_str()[0])
return false;
const char symbol = strXmlNode.c_str()[0];
if ('#' == symbol)
return NULL;
}
#ifdef _DEBUG

View File

@ -645,15 +645,18 @@ namespace PdfWriter
}
delete[] pA;
if (!m_pTransparencyGroup)
{
m_pTransparencyGroup = new CDictObject();
m_pTransparencyGroup->Add("Type", "Group");
m_pTransparencyGroup->Add("S", "Transparency");
m_pTransparencyGroup->Add("CS", "DeviceRGB");
}
if (!IsPDFA())
{
if (!m_pTransparencyGroup)
{
m_pTransparencyGroup = new CDictObject();
m_pTransparencyGroup->Add("Type", "Group");
m_pTransparencyGroup->Add("S", "Transparency");
m_pTransparencyGroup->Add("CS", "DeviceRGB");
}
pPage->Add("Group", m_pTransparencyGroup);
pPage->Add("Group", m_pTransparencyGroup);
}
double dWidth = pPage->GetWidth();
double dHeight = pPage->GetHeight();
@ -662,7 +665,8 @@ namespace PdfWriter
pXObject->Add("Type", "XObject");
pXObject->Add("Subtype", "Form");
pXObject->Add("BBox", CArrayObject::CreateBox(0, 0, dWidth, dHeight));
pXObject->Add("Group", m_pTransparencyGroup);
if (m_pTransparencyGroup)
pXObject->Add("Group", m_pTransparencyGroup);
CDictObject* pResources = new CDictObject();
pXObject->Add("Resources", pResources);
CDictObject* pResShadings = new CDictObject();

View File

@ -28,6 +28,7 @@ public:
std::wstring m_sOutputFolder;
bool m_bIsStandard;
bool m_bIsDiffAllInOne;
NSCriticalSection::CRITICAL_SECTION m_oCS;
NSCriticalSection::CRITICAL_SECTION m_oCS_OfficeUtils;
@ -55,6 +56,8 @@ public:
m_nCurrent = 0;
m_nCurrentComplete = 0;
m_bIsDiffAllInOne = true;
m_oCS.InitializeCriticalSection();
m_oCS_OfficeUtils.InitializeCriticalSection();
}
@ -521,7 +524,44 @@ public:
if (!NSDirectory::Exists(strDiffs))
NSDirectory::CreateDirectory(strDiffs);
frameO.SaveFile(sPageDiff, 4);
if (!m_pInternal->m_bIsDiffAllInOne)
{
frameO.SaveFile(sPageDiff, 4);
}
else
{
CBgraFrame frameOSrc;
frameOSrc.OpenFile(sPageO);
BYTE* pData1 = frameI.get_Data();
BYTE* pData2 = frameOSrc.get_Data();
BYTE* pData3 = frameO.get_Data();
int nRowW = 4 * nW_I;
BYTE* pDataAll = new BYTE[3 * nRowW * nH_I];
BYTE* pDataAllSrc = pDataAll;
for (int j = 0; j < nH_I; j++)
{
memcpy(pDataAll, pData1, nRowW);
pDataAll += nRowW;
pData1 += nRowW;
memcpy(pDataAll, pData2, nRowW);
pDataAll += nRowW;
pData2 += nRowW;
memcpy(pDataAll, pData3, nRowW);
pDataAll += nRowW;
pData3 += nRowW;
}
CBgraFrame oFrameAll;
oFrameAll.put_Data(pDataAllSrc);
oFrameAll.put_Width(3 * nW_I);
oFrameAll.put_Height(nH_I);
oFrameAll.put_Stride(-3 * nRowW);
oFrameAll.SaveFile(sPageDiff, 4);
}
std::cout << "file (diffs) : " << U_TO_UTF8(sPageDiff) << std::endl;
}

View File

@ -0,0 +1,22 @@
<Settings>
<file>./sdkjs/common/Native/native.js</file>
<file>./sdkjs/common/Native/jquery_native.js</file>
<file>./sdkjs/vendor/xregexp/xregexp-all-min.js</file>
<file>./fonts/AllFonts.js</file>
<htmlfile>./sdkjs/vendor/jquery/jquery.min.js</htmlfile>
<DoctSdk>
<file>./sdkjs/word/sdk-all-min.js</file>
<file>./sdkjs/common/libfont/js/fonts.js</file>
<file>./sdkjs/word/sdk-all.js</file>
</DoctSdk>
<PpttSdk>
<file>./sdkjs/slide/sdk-all-min.js</file>
<file>./sdkjs/common/libfont/js/fonts.js</file>
<file>./sdkjs/slide/sdk-all.js</file>
</PpttSdk>
<XlstSdk>
<file>./sdkjs/cell/sdk-all-min.js</file>
<file>./sdkjs/common/libfont/js/fonts.js</file>
<file>./sdkjs/cell/sdk-all.js</file>
</XlstSdk>
</Settings>

View File

@ -0,0 +1,14 @@
@echo OFF
rem
rem --input="input-standard-files-dir"
rem --output="output-dir"
rem --standard // generate standarts
rem --use-system-fonts="0/1/false/true"
rem --font-dirs="C:\\Windows\\Fonts;/usr/share/fonts;"
rem --cores=4
rem
set RUN_DIR=%~dp0..
cd "%RUN_DIR%"
RMDIR "%RUN_DIR%\result\check" /S /Q
StandardTester.exe --input="%RUN_DIR%\result\out" --output="%RUN_DIR%\result\check" --cores=1

View File

@ -0,0 +1,13 @@
@echo OFF
rem
rem --input="input-standard-files-dir"
rem --output="output-dir"
rem --standard // generate standarts
rem --use-system-fonts="0/1/false/true"
rem --font-dirs="C:\\Windows\\Fonts;/usr/share/fonts;"
rem --cores=4
rem
set RUN_DIR=%~dp0..
cd "%RUN_DIR%"
StandardTester.exe --input="%RUN_DIR%\result\standard" --output="%RUN_DIR%\result\out" --standard --cores=1

View File

@ -0,0 +1,36 @@
@echo OFF
set RUN_DIR=%~dp0..
set GIT_DIR=%RUN_DIR%\..\..\..\..\..
RMDIR "%RUN_DIR%\sdkjs" /S /Q
rem SDKJS UPDATE
md %RUN_DIR%\sdkjs\cell
copy "%GIT_DIR%\sdkjs\cell\sdk-all.js" "%RUN_DIR%\sdkjs\cell\sdk-all.js"
copy "%GIT_DIR%\sdkjs\cell\sdk-all-min.js" "%RUN_DIR%\sdkjs\cell\sdk-all-min.js"
md %RUN_DIR%\sdkjs\slide\themes
copy "%GIT_DIR%\sdkjs\slide\sdk-all.js" "%RUN_DIR%\sdkjs\slide\sdk-all.js"
copy "%GIT_DIR%\sdkjs\slide\sdk-all-min.js" "%RUN_DIR%\sdkjs\slide\sdk-all-min.js"
xcopy /S /E "%GIT_DIR%\sdkjs\slide\themes" "%RUN_DIR%\sdkjs\slide\themes\"
md %RUN_DIR%\sdkjs\word
copy "%GIT_DIR%\sdkjs\word\sdk-all.js" "%RUN_DIR%\sdkjs\word\sdk-all.js"
copy "%GIT_DIR%\sdkjs\word\sdk-all-min.js" "%RUN_DIR%\sdkjs\word\sdk-all-min.js"
md %RUN_DIR%\sdkjs\common\Native
md %RUN_DIR%\sdkjs\common\libfont\js
copy "%GIT_DIR%\sdkjs\common\Native\jquery_native.js" "%RUN_DIR%\sdkjs\common\Native\jquery_native.js"
copy "%GIT_DIR%\sdkjs\common\Native\native.js" "%RUN_DIR%\sdkjs\common\Native\native.js"
copy "%GIT_DIR%\sdkjs\common\libfont\js\fonts.js" "%RUN_DIR%\sdkjs\common\libfont\js\fonts.js"
md %RUN_DIR%\sdkjs\vendor\jquery
copy "%GIT_DIR%\web-apps-pro\vendor\jquery\jquery.min.js" "%RUN_DIR%\sdkjs\vendor\jquery\jquery.min.js"
md %RUN_DIR%\sdkjs\vendor\xregexp
copy "%GIT_DIR%\web-apps-pro\vendor\xregexp\xregexp-all-min.js" "%RUN_DIR%\sdkjs\vendor\xregexp\xregexp-all-min.js"
rem DLLs UPDATE
del /Q /F "%RUN_DIR%\*.dll"
del /Q /F "%RUN_DIR%\x2t.exe"
copy "%GIT_DIR%\server\FileConverter\bin\*.dll" "%RUN_DIR%\."
copy "%GIT_DIR%\server\FileConverter\bin\x2t.exe" "%RUN_DIR%\."

View File

@ -4943,7 +4943,7 @@ void BinaryWorksheetTableWriter::getSavedComment(OOX::Spreadsheet::CCommentItem&
{
if(oComment.m_sGfxdata.IsInit())
{
const std::wstring& sGfxData = oComment.m_sGfxdata.get2();
const std::wstring& sGfxData = *oComment.m_sGfxdata;
std::wstring sSignatureBase64Old(_T("WExTV"));//XLST
std::wstring sSignatureBase64(_T("WExTM"));//XLS2
//compatibility with fact that previously used long that can be 4 or 8 byte
@ -5180,7 +5180,7 @@ void BinaryWorksheetTableWriter::WriteCommentDataContent(OOX::Spreadsheet::CComm
if(pComment->m_sAuthor.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSer_CommentData::UserName);
m_oBcw.m_oStream.WriteStringW(pComment->m_sAuthor.get2());
m_oBcw.m_oStream.WriteStringW(*pComment->m_sAuthor);
}
}
}

View File

@ -3098,8 +3098,7 @@ int BinaryCommentReader::ReadComment(BYTE type, long length, void* poResult)
if(!sGfxdata.empty())
{
pNewComment->m_sGfxdata.Init();
pNewComment->m_sGfxdata->append(sGfxdata);
pNewComment->m_sGfxdata = sGfxdata;
}
}
READ1_DEF(length, res, this->ReadCommentDatas, pNewComment);