Commit 42c94d5c authored by ElenaSubbotina's avatar ElenaSubbotina

OdfFormatReader - fix errors ...

parent 41b3c6fb
......@@ -239,7 +239,7 @@ namespace formulasconvert {
bool odf2oox_converter::Impl::check_formula(std::wstring& expr)
{
boost::match_results<std::wstring::const_iterator> res;
if (boost::regex_search(expr, res, boost::wregex(L"(?:[\\w]+:)?=(.+)"), boost::match_default))
if (boost::regex_search(expr, res, boost::wregex(L"^(?:[\\w]+:)?=(.+)"), boost::match_default))
{
expr = res[1].str();
while (expr.find(L"=") == 0)
......@@ -431,6 +431,7 @@ namespace formulasconvert {
if (isFormula)
{
boost::algorithm::replace_all(workstr, L"FDIST(", L"_xlfn.F.DIST(");
// ROUNDUP( - тут в oox 2 параметра - разрядность нужно - ,0) - EV Requirements v2.2.3.ods
int res_find=0;
if ((res_find = workstr.find(L"CONCATINATE")) > 0)
......
......@@ -399,9 +399,10 @@ void pptx_text_context::Impl::write_t(std::wostream & strm)
void pptx_text_context::Impl::write_rPr(std::wostream & strm)
{
if (paragraph_style_name_.length()<1 && span_style_name_.length()<1 && !(hyperlink_hId.length()>0) && base_style_name_.length()<1)return;
if (paragraph_style_name_.empty() && span_style_name_.empty() && !(!hyperlink_hId.empty()) && base_style_name_.empty())
return;
odf_reader::text_format_properties_content text_properties_paragraph_;
odf_reader::text_format_properties_content text_properties_paragraph_;
ApplyTextProperties (paragraph_style_name_, text_properties_paragraph_,odf_types::style_family::Paragraph);
odf_reader::text_format_properties_content text_properties_span_;
......@@ -415,6 +416,7 @@ void pptx_text_context::Impl::write_rPr(std::wostream & strm)
get_styles_context().start();
get_styles_context().hlinkClick() = hyperlink_hId;
text_properties_.pptx_convert(pptx_context_);
strm << get_styles_context().text_style().str();
......
......@@ -34,10 +34,10 @@
#include "xlsx_utils.h"
#include <vector>
#include <boost/lexical_cast.hpp>
#include <cpdoccore/xml/simple_xml_writer.h>
#include "../formulasconvert/formulasconvert.h"
namespace cpdoccore {
namespace oox {
......@@ -84,6 +84,7 @@ namespace oox {
_CP_OPT(std::wstring) formula_type;
_CP_OPT(std::wstring) text;
_CP_OPT(std::wstring) formula2;
_CP_OPT(int) rank;
//color scale icon set data_bar
std::vector<_cfvo> cfvo;
//color scale data_bar(1 element)
......@@ -138,7 +139,8 @@ public:
if (c.rules[j].operator_) CP_XML_ATTR(L"operator", *c.rules[j].operator_);
if (c.rules[j].stopIfTrue) CP_XML_ATTR(L"stopIfTrue", *c.rules[j].stopIfTrue);
if (c.rules[j].text) CP_XML_ATTR(L"text", *c.rules[j].text);
//CP_XML_ATTR(L"rank" , 0);
if (c.rules[j].rank) CP_XML_ATTR(L"rank", *c.rules[j].rank);
//CP_XML_ATTR(L"bottom" , 0);
//CP_XML_ATTR(L"equalAverage" , 0);
//CP_XML_ATTR(L"aboveAverage" , 0);
......@@ -271,12 +273,36 @@ void xlsx_conditionalFormatting_context::set_formula(std::wstring f)
}
else if (0 <= (pos = f.find(L"is-between(")))
{
impl_->conditionalFormattings_.back().rules.back().formula_type = L"expression";
impl_->conditionalFormattings_.back().rules.back().formula = converter.convert_named_expr(val);
}
else if (0 <= (pos = f.find(L"is-time(")))
{
impl_->conditionalFormattings_.back().rules.back().formula_type = L"expression";
impl_->conditionalFormattings_.back().rules.back().formula = converter.convert_named_expr(val);
}
else if (0 <= (pos = f.find(L"duplicate")))
{
impl_->conditionalFormattings_.back().rules.back().formula_type = L"duplicateValues";
}
else if (0 <= (pos = f.find(L"top")))
{
impl_->conditionalFormattings_.back().rules.back().formula_type = L"top10";
if (0 < (pos = f.find(L"percent")))
{
impl_->conditionalFormattings_.back().rules.back().percent = true;
}
if (0 <= (pos = f.find(L"(")))
{
val = f.substr(pos + 1, f.length() - pos - 2);
impl_->conditionalFormattings_.back().rules.back().rank = boost::lexical_cast<int>(val);
}
}
else if (0 <= (pos = f.find(L"contains-text")))
{
impl_->conditionalFormattings_.back().rules.back().formula_type = L"containsText";
impl_->conditionalFormattings_.back().rules.back().text = f.substr(15, f.length() - 17);
}
else
{
impl_->conditionalFormattings_.back().rules.back().formula_type = L"cellIs";
......@@ -293,11 +319,6 @@ void xlsx_conditionalFormatting_context::set_formula(std::wstring f)
{
val = converter.convert_named_expr( f );
}
else if (0 <= (pos = f.find(L"top")))
{
impl_->conditionalFormattings_.back().rules.back().formula_type = L"top10";
val = converter.convert_named_expr( f );
}
else if (0 <= (pos = f.find(L"!=")))
{
impl_->conditionalFormattings_.back().rules.back().operator_ = L"notEqual";
......@@ -328,12 +349,6 @@ void xlsx_conditionalFormatting_context::set_formula(std::wstring f)
impl_->conditionalFormattings_.back().rules.back().operator_ = L"greaterThan";
val = converter.convert_named_expr( f.substr(1) );
}
else if (0 <= (pos = f.find(L"contains-text")))
{
impl_->conditionalFormattings_.back().rules.back().formula_type = L"containsText";
impl_->conditionalFormattings_.back().rules.back().text = f.substr(15, f.length() - 17);
val.clear();
}
else if (0 <= (pos = f.find(L"between")))
{
impl_->conditionalFormattings_.back().rules.back().operator_ = L"between";
......@@ -353,8 +368,7 @@ void xlsx_conditionalFormatting_context::set_formula(std::wstring f)
if (!val.empty())
impl_->conditionalFormattings_.back().rules.back().formula = val;
}
}
}
void xlsx_conditionalFormatting_context::set_dataBar(_CP_OPT(int) min, _CP_OPT(int) max)
{
......
......@@ -119,6 +119,7 @@ private:
std::wstringstream paragraph_; //перманенто скидываемые параграфы
std::wstringstream run_; //перманенто скидываемые куски с быть может разными свойствами
std::wstring store_cell_string_;
xlsx_shared_strings xlsx_shared_strings_;
std::wstring paragraph_style_name_;//был вектор ... не нужен, так как в один момент времени может быть тока один стиль параграфа,текста,объекта при приходе нового - дампится
......@@ -427,12 +428,12 @@ std::wstring xlsx_text_context::Impl::dump_paragraph(/*bool last*/)
std::wstring xlsx_text_context::Impl::dump_run()
{
const std::wstring content = xml::utils::replace_text_to_xml(text_.str());
if (content.length()<1)
if (content.empty())
return L"";
std::wstring prefix_draw;
if (in_draw) prefix_draw=L"a:";
if (in_draw) prefix_draw = L"a:";
CP_XML_WRITER(run_)
{
......@@ -445,6 +446,7 @@ std::wstring xlsx_text_context::Impl::dump_run()
CP_XML_NODE(prefix_draw + L"t")
{
if (!in_draw)CP_XML_ATTR(L"xml:space", L"preserve");
CP_XML_STREAM() << content;
}
}
......@@ -452,19 +454,21 @@ std::wstring xlsx_text_context::Impl::dump_run()
}
}
hyperlink_hId =L"";
return content;
}
void xlsx_text_context::Impl::start_cell_content()
{
paragraphs_cout_ = 0;
local_styles_ptr_ =NULL;
paragraphs_cout_ = 0;
local_styles_ptr_ = NULL;
run_.str(std::wstring());
paragraph_.str(std::wstring());
text_.str(std::wstring());
store_cell_string_.clear();
hyperlink_hId.clear();
paragraph_style_name_ = L"";
span_style_name_ = L"";
......@@ -488,6 +492,13 @@ void xlsx_text_context::Impl::start_comment_content()
}
void xlsx_text_context::Impl::start_drawing_content()
{
if (in_cell_content)
{
dump_run();
store_cell_string_ = run_.str();
}
paragraphs_cout_ = 0;
run_.str(std::wstring());
......@@ -539,9 +550,12 @@ int xlsx_text_context::Impl::end_cell_content()
{
dump_run();
const int sharedStrId = run_.str().empty() ? (-1) : static_cast<int>(xlsx_shared_strings_.add(run_.str()));
//???? нужно ли здесь очищать все ????? - проверить стили на кучках - и проверить как меняются стили внутри одной ячейки - то есть здешнее переопределение внешнего стиля
in_cell_content = false;
std::wstring cell_string = store_cell_string_ + run_.str();
store_cell_string_.clear();
in_cell_content = false;
const int sharedStrId = cell_string.empty() ? (-1) : xlsx_shared_strings_.add(cell_string);
return sharedStrId;
}
......
......@@ -220,8 +220,11 @@ static const _shape_converter _OO_OOX_custom_shapes[]=
{L"concave-star6" ,L"" ,0 ,0 ,0 },
{L"signet" ,L"" ,0 ,0 ,0 },
{L"doorplate" ,L"" ,0 ,0 ,0 },
{L"" ,L"round1Rect" ,0 ,0 ,0 },
{L"" ,L"round1Rect" ,0 ,0 ,0 },
{L"" ,L"round2DiagRect" ,0 ,0 ,0 },
{L"" ,L"snip2DiagRect" ,0 ,0 ,0 },
{L"" ,L"round2SameRect" ,0 ,0 ,0 },
{L"" ,L"mathPlus" ,0 ,0 ,0 },
{L"" ,L"mathMinus" ,0 ,0 ,0 },
{L"" ,L"mathMultiply" ,0 ,0 ,0 },
......
......@@ -133,6 +133,9 @@ std::wostream & s::text_to_stream(std::wostream & _Wostream) const
else
_Wostream << std::wstring(1, L' ');
if (content_)
_Wostream << *content_;
return _Wostream;
}
......@@ -140,7 +143,10 @@ void s::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"text:c", text_c_);
}
void s::add_text(const std::wstring & Text)
{
content_ = Text;
}
void s::docx_convert(oox::docx_conversion_context & Context)
{
Context.add_element_to_run();
......
......@@ -51,7 +51,6 @@
namespace cpdoccore {
namespace odf_reader {
namespace text {
template <class ElementT>
......@@ -59,33 +58,25 @@ class paragraph_content_element : public paragraph_content_impl<ElementT>
{
};
// TODO:
// 5.6 Индексные метки
// 5.7 Метки изменений
// 5.8 Внедренные графические объекты и текстовые блоки
// simple text
//////////////////////////////////////////////////////////////////////////////////////////////////
class text : public paragraph_content_element<text>
{
public:
static office_element_ptr create(const std::wstring & Text);
public:
static const wchar_t * ns;
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeText;
static const ElementType type = typeTextText;
CPDOCCORE_DEFINE_VISITABLE();
public:
virtual void docx_convert(oox::docx_conversion_context & Context);
virtual void xlsx_convert(oox::xlsx_conversion_context & Context);
virtual void pptx_convert(oox::pptx_conversion_context & Context) ;
public:
virtual std::wostream & text_to_stream(std::wostream & _Wostream) const;
public:
bool preserve_;
text(const std::wstring & Text) : text_(Text) {preserve_ = true;};
text() {preserve_ = true;};
......@@ -94,15 +85,10 @@ public:
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)
{};
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) {}
virtual void add_text(const std::wstring & Text);
private:
std::wstring text_;
};
......@@ -118,16 +104,12 @@ public:
static const ElementType type = typeTextS;
CPDOCCORE_DEFINE_VISITABLE();
public:
virtual void docx_convert(oox::docx_conversion_context & Context);
virtual void xlsx_convert(oox::xlsx_conversion_context & Context);
virtual void pptx_convert(oox::pptx_conversion_context & Context) ;
public:
virtual std::wostream & text_to_stream(std::wostream & _Wostream) const;
public:
s(unsigned int c) : text_c_(c) {};
s() {};
......@@ -136,10 +118,10 @@ public:
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) {}
virtual void add_text(const std::wstring & Text) {}
virtual void add_text(const std::wstring & Text);
private:
_CP_OPT(unsigned int) text_c_;
_CP_OPT(std::wstring) content_;
};
CP_REGISTER_OFFICE_ELEMENT2(s);
......@@ -155,26 +137,22 @@ public:
static const ElementType type = typeTextTab;
CPDOCCORE_DEFINE_VISITABLE();
public:
tab(unsigned int ab_ref) : text_tab_ref_(ab_ref) {};
tab() {};
virtual void docx_convert(oox::docx_conversion_context & Context) ;
virtual void xlsx_convert(oox::xlsx_conversion_context & Context) ;
virtual void pptx_convert(oox::pptx_conversion_context & Context) ;
public:
virtual std::wostream & text_to_stream(std::wostream & _Wostream) const;
_CP_OPT(unsigned int) attr_tab_ref() const { return text_tab_ref_; }
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) {}
virtual void add_text(const std::wstring & Text) {}
public:
tab(unsigned int ab_ref) : text_tab_ref_(ab_ref) {};
tab() {};
_CP_OPT(unsigned int) attr_tab_ref() const { return text_tab_ref_; }
private:
_CP_OPT(unsigned int) text_tab_ref_;
};
......@@ -191,15 +169,12 @@ public:
static const ElementType type = typeTextLineBreak;
CPDOCCORE_DEFINE_VISITABLE();
public:
virtual void docx_convert(oox::docx_conversion_context & Context);
virtual void xlsx_convert(oox::xlsx_conversion_context & Context);
virtual void pptx_convert(oox::pptx_conversion_context & Context) ;
public:
virtual std::wostream & text_to_stream(std::wostream & _Wostream) const;
public:
line_break() {};
private:
......@@ -222,10 +197,9 @@ public:
static const ElementType type = typeTextBookmark;
CPDOCCORE_DEFINE_VISITABLE();
public:
virtual std::wostream & text_to_stream(std::wostream & _Wostream) const;
public:
bookmark() {}
bookmark() {}
bookmark(const std::wstring & Name) : text_name_(Name){};
const std::wstring & attr_name() const { return text_name_; }
......@@ -235,7 +209,6 @@ private:
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name) {}
virtual void add_text(const std::wstring & Text) {}
private:
std::wstring text_name_;
};
......@@ -252,10 +225,9 @@ public:
static const ElementType type = typeTextBookmarkStart;
CPDOCCORE_DEFINE_VISITABLE();
public:
virtual std::wostream & text_to_stream(std::wostream & _Wostream) const;
public:
bookmark_start() {}
bookmark_start() {}
bookmark_start(const std::wstring & Name) : text_name_(Name){};
const std::wstring & attr_name() const { return text_name_; }
......@@ -265,7 +237,6 @@ private:
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name) {}
virtual void add_text(const std::wstring & Text) {}
private:
std::wstring text_name_;
};
......@@ -282,10 +253,9 @@ public:
static const ElementType type = typeTextBookmarkEnd;
CPDOCCORE_DEFINE_VISITABLE();
public:
virtual std::wostream & text_to_stream(std::wostream & _Wostream) const;
public:
bookmark_end() {} ;
bookmark_end() {} ;
bookmark_end(const std::wstring & Name) : text_name_(Name){};
const std::wstring & attr_name() const { return text_name_; }
......@@ -295,7 +265,6 @@ private:
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name) {}
virtual void add_text(const std::wstring & Text) {}
private:
std::wstring text_name_;
};
......@@ -372,10 +341,9 @@ public:
static const ElementType type = typeTextReferenceMarkEnd;
CPDOCCORE_DEFINE_VISITABLE();
public:
virtual std::wostream & text_to_stream(std::wostream & _Wostream) const;
public:
reference_mark_end() {};
reference_mark_end() {};
reference_mark_end(const std::wstring & Name) : text_name_(Name){};
const std::wstring & attr_name() const { return text_name_; }
......@@ -385,7 +353,6 @@ private:
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name) {}
virtual void add_text(const std::wstring & Text) {}
private:
std::wstring text_name_;
};
......@@ -403,15 +370,13 @@ public:
static const ElementType type = typeTextSpan;
CPDOCCORE_DEFINE_VISITABLE();
public:
virtual void docx_convert(oox::docx_conversion_context & Context);
virtual void xlsx_convert(oox::xlsx_conversion_context & Context);
virtual void pptx_convert(oox::pptx_conversion_context & Context) ;
public:
virtual std::wostream & text_to_stream(std::wostream & _Wostream) const;
public:
span() {}
span() {}
office_element_ptr_array paragraph_content_;
......@@ -438,22 +403,19 @@ public:
static const ElementType type = typeTextA;
CPDOCCORE_DEFINE_VISITABLE();
public:
virtual void docx_convert(oox::docx_conversion_context & Context);
virtual void xlsx_convert(oox::xlsx_conversion_context & Context);
virtual void pptx_convert(oox::pptx_conversion_context & Context) ;
public:
virtual std::wostream & text_to_stream(std::wostream & _Wostream) const;
public:
a() {}
a() {}
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);
virtual void add_text(const std::wstring & Text);
private:
odf_types::common_xlink_attlist common_xlink_attlist_;
std::wstring office_name_;
......@@ -513,6 +475,7 @@ public:
CPDOCCORE_DEFINE_VISITABLE();
virtual std::wostream & text_to_stream(std::wostream & _Wostream) const;
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);
......@@ -660,7 +623,6 @@ public:
void docx_convert(oox::docx_conversion_context & Context);
void pptx_convert(oox::pptx_conversion_context & Context);
public:
virtual std::wostream & text_to_stream(std::wostream & _Wostream) const;
private:
......@@ -668,8 +630,7 @@ private:
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
virtual void add_text(const std::wstring & Text);
private:
// TODO: attributes
// todooo attributes
office_element_ptr_array text_;
};
......@@ -699,7 +660,7 @@ private:
virtual void add_text(const std::wstring & Text);
private:
// TODO: attributes
// todooo attributes
office_element_ptr_array text_;
};
......@@ -816,7 +777,6 @@ public:
void docx_convert(oox::docx_conversion_context & Context);
void pptx_convert(oox::pptx_conversion_context & Context);
public:
virtual std::wostream & text_to_stream(std::wostream & _Wostream) const;
private:
......@@ -824,8 +784,7 @@ private:
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
virtual void add_text(const std::wstring & Text);
private:
// TODO: attributes
// todooo attributes
office_element_ptr_array text_;
};
......@@ -846,7 +805,6 @@ public:
void docx_convert(oox::docx_conversion_context & Context);
void pptx_convert(oox::pptx_conversion_context & Context) ;
public:
virtual std::wostream & text_to_stream(std::wostream & _Wostream) const;
private:
......@@ -854,8 +812,7 @@ private:
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
virtual void add_text(const std::wstring & Text);
private:
// TODO: attributes
// todooo attributes
office_element_ptr_array text_;
};
......@@ -878,7 +835,6 @@ private:
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
virtual void add_text(const std::wstring & Text);
private:
office_element_ptr_array text_;
};
......
......@@ -62,6 +62,8 @@ static formulasconvert::odf2oox_converter formulas_converter;
int table_table_cell_content::xlsx_convert(oox::xlsx_conversion_context & Context, text_format_properties_content *text_properties)
{
if (elements_.empty()) return -1;
Context.get_table_context().start_cell_content();
Context.get_text_context().set_cell_text_properties(text_properties);
......@@ -136,6 +138,7 @@ void table_table_row::xlsx_convert(oox::xlsx_conversion_context & Context)
ht = ht_s.str();
}
}
int row_current = Context.current_table_row() + 1;
bool hidden = table_table_row_attlist_.table_visibility_.get_type() == table_visibility::Collapse;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment