Commit 202d9188 authored by Elen.Subbotina's avatar Elen.Subbotina Committed by Alexander Trofimov

......

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@63136 954022d7-b5bf-4e40-9824-e11837661b57
parent 739d4f95
...@@ -295,6 +295,14 @@ std::wstring odf2oox_converter::Impl::convert(const std::wstring& expr) ...@@ -295,6 +295,14 @@ std::wstring odf2oox_converter::Impl::convert(const std::wstring& expr)
replace_cells_range(workstr); replace_cells_range(workstr);
replace_semicolons(workstr); replace_semicolons(workstr);
replace_vertical(workstr); replace_vertical(workstr);
int res_find=0;
if ((res_find = workstr.find(L"CONCATINATE")) > 0)
{
//ìîãóò áûòü ÷àñòè÷íî çàäàíû äèàïàçîíû
//todooo
}
return workstr; return workstr;
} }
......
...@@ -22,11 +22,11 @@ std::pair<float, float> GetMaxDigitSizePixelsImpl(const std::wstring & fontName, ...@@ -22,11 +22,11 @@ std::pair<float, float> GetMaxDigitSizePixelsImpl(const std::wstring & fontName,
{ {
if (pFontManager == NULL) return std::pair<float, float>(7,8); if (pFontManager == NULL) return std::pair<float, float>(7,8);
HRESULT hr = S_OK; int hr = FALSE;
if (S_OK != (hr = pFontManager->LoadFontByName(fontName, fontSize, fontStyle, dpi, dpi ))) if (FALSE == (hr = pFontManager->LoadFontByName(fontName, fontSize, fontStyle, dpi, dpi )))
{ {
if (S_OK != (hr = pFontManager->LoadFontByName(L"Arial", fontSize, fontStyle, dpi, dpi ))) if (FALSE == (hr = pFontManager->LoadFontByName(L"Arial", fontSize, fontStyle, dpi, dpi )))
{ {
return std::pair<float, float>(7,8); return std::pair<float, float>(7,8);
} }
...@@ -34,9 +34,13 @@ std::pair<float, float> GetMaxDigitSizePixelsImpl(const std::wstring & fontName, ...@@ -34,9 +34,13 @@ std::pair<float, float> GetMaxDigitSizePixelsImpl(const std::wstring & fontName,
float maxWidth = 0; float maxWidth = 0;
float maxHeight = 0; float maxHeight = 0;
float minWidth = 0xffff;
float minHeight = 0xffff;
for (int i = 0; i <= 9; ++i) for (int i = 0; i <= 9; ++i)
{ {
if (S_OK != (hr = pFontManager->LoadString2( boost::lexical_cast<std::wstring>(i), 0, 0))) if (FALSE == (hr = pFontManager->LoadString2( boost::lexical_cast<std::wstring>(i), 0, 0)))
return std::pair<float, float>(7,8); return std::pair<float, float>(7,8);
TBBox box; TBBox box;
...@@ -48,15 +52,18 @@ std::pair<float, float> GetMaxDigitSizePixelsImpl(const std::wstring & fontName, ...@@ -48,15 +52,18 @@ std::pair<float, float> GetMaxDigitSizePixelsImpl(const std::wstring & fontName,
return std::pair<float, float>(7,8); return std::pair<float, float>(7,8);
} }
if (box.fMaxX > 0xffff-1 || box.fMaxY > 0xffff-1 || if (box.fMaxX < -0xffff+1 || box.fMaxY < -0xffff+1 ||
box.fMinX < 0xffff+1 || box.fMinY > 0xffff+1) box.fMinX > 0xffff-1 || box.fMinY > 0xffff-1)
return std::pair<float, float>(7,8); return std::pair<float, float>(7,8);
if (box.fMaxX - box.fMinX > maxWidth) maxWidth = box.fMaxX - box.fMinX; if (box.fMaxX - box.fMinX > maxWidth) maxWidth = box.fMaxX - box.fMinX;
if (box.fMaxY - box.fMinY > maxHeight) maxHeight = box.fMaxY - box.fMinY; if (box.fMaxY - box.fMinY > maxHeight) maxHeight = box.fMaxY - box.fMinY;
if (box.fMaxX - box.fMinX < minWidth) minWidth = box.fMaxX - box.fMinX;
if (box.fMaxY - box.fMinY < minHeight) minHeight = box.fMaxY - box.fMinY;
} }
return std::pair<float, float>(maxWidth,maxHeight); return std::pair<float, float>((minWidth + 2*maxWidth)/3.f,maxHeight);
} }
......
...@@ -16,6 +16,7 @@ public: ...@@ -16,6 +16,7 @@ public:
xlsx_cell_format(); xlsx_cell_format();
public: public:
XlsxCellType::type get_cell_type() const; XlsxCellType::type get_cell_type() const;
void set_cell_type(XlsxCellType::type type); void set_cell_type(XlsxCellType::type type);
int get_num_format() const; int get_num_format() const;
......
...@@ -26,6 +26,8 @@ public: ...@@ -26,6 +26,8 @@ public:
void add_format(std::wstring const & cond, std::wstring const & format); void add_format(std::wstring const & cond, std::wstring const & format);
void end_complex_format(); void end_complex_format();
//std::wstring default_data_style(int type);
private: private:
class Impl; class Impl;
_CP_SCOPED_PTR(Impl) impl_; _CP_SCOPED_PTR(Impl) impl_;
......
...@@ -128,6 +128,7 @@ size_t xlsx_style_manager::Impl::xfId(const odf_reader::text_format_properties_c ...@@ -128,6 +128,7 @@ size_t xlsx_style_manager::Impl::xfId(const odf_reader::text_format_properties_c
const xlsx_cell_format * xlxsCellFormat, const xlsx_cell_format * xlxsCellFormat,
const std::wstring &num_format, bool default_set, bool & is_visible ) const std::wstring &num_format, bool default_set, bool & is_visible )
{ {
bool is_visible_set = is_visible;
const size_t fontId = fonts_.fontId(textProp, parProp, cellProp); const size_t fontId = fonts_.fontId(textProp, parProp, cellProp);
is_visible = false; is_visible = false;
...@@ -137,7 +138,7 @@ size_t xlsx_style_manager::Impl::xfId(const odf_reader::text_format_properties_c ...@@ -137,7 +138,7 @@ size_t xlsx_style_manager::Impl::xfId(const odf_reader::text_format_properties_c
bool default_fill = false; bool default_fill = false;
const size_t fillId = fills_.fillId(textProp, parProp, cellProp, default_set,default_fill); const size_t fillId = fills_.fillId(textProp, parProp, cellProp, default_set,default_fill);
if (!default_border || !default_fill/* || (fillId >2 && default_set!=default_fill)*/) if (!default_border || !default_fill || is_visible_set/* || (fillId >2 && default_set!=default_fill)*/)
is_visible = true; is_visible = true;
xlsx_alignment alignment = OdfProperties2XlsxAlignment(textProp, parProp, cellProp); xlsx_alignment alignment = OdfProperties2XlsxAlignment(textProp, parProp, cellProp);
......
...@@ -29,8 +29,8 @@ const xlsx_table_state & xlsx_table_context::state() const ...@@ -29,8 +29,8 @@ const xlsx_table_state & xlsx_table_context::state() const
} }
xlsx_table_context:: xlsx_table_context::
xlsx_table_context(xlsx_conversion_context & Context, xlsx_text_context & textCotnext): context_(Context), xlsx_table_context(xlsx_conversion_context & Context, xlsx_text_context & textContext): context_(Context),
xlsx_text_context_(textCotnext) xlsx_text_context_(textContext)
{ {
} }
......
...@@ -41,6 +41,7 @@ public: ...@@ -41,6 +41,7 @@ public:
std::wstring end_span2(); std::wstring end_span2();
void start_cell_content(); void start_cell_content();
void set_cell_text_properties( odf_reader::text_format_properties_content * text_properties);
int end_cell_content(); int end_cell_content();
void start_comment_content(); void start_comment_content();
...@@ -51,7 +52,7 @@ public: ...@@ -51,7 +52,7 @@ public:
void write_shared_strings(std::wostream & strm); void write_shared_strings(std::wostream & strm);
void ApplyTextProperties(std::wstring style,odf_reader::text_format_properties_content & propertiesOut, odf_types::style_family::type Type); void ApplyTextProperties(std::wstring style, odf_reader::text_format_properties_content & propertiesOut, odf_types::style_family::type Type);
void set_local_styles_container(odf_reader::styles_container* local_styles_);//это если стили объектов содержатся в другом документе void set_local_styles_container(odf_reader::styles_container* local_styles_);//это если стили объектов содержатся в другом документе
...@@ -70,7 +71,7 @@ private: ...@@ -70,7 +71,7 @@ private:
bool in_cell_content; bool in_cell_content;
odf_reader::styles_container & styles_; odf_reader::styles_container & styles_;
odf_reader::text_format_properties_content * text_properties_cell_;
odf_reader::styles_container * local_styles_ptr_; odf_reader::styles_container * local_styles_ptr_;
std::wstring dump_text(); std::wstring dump_text();
...@@ -96,6 +97,7 @@ void xlsx_text_context::Impl::write_shared_strings(std::wostream & strm) ...@@ -96,6 +97,7 @@ void xlsx_text_context::Impl::write_shared_strings(std::wostream & strm)
xlsx_text_context::Impl::Impl(odf_reader::styles_container & styles): paragraphs_cout_(0),styles_(styles), xlsx_text_context::Impl::Impl(odf_reader::styles_container & styles): paragraphs_cout_(0),styles_(styles),
in_comment(false),in_draw(false),in_paragraph(false),in_span(false),in_cell_content(false) in_comment(false),in_draw(false),in_paragraph(false),in_span(false),in_cell_content(false)
{ {
text_properties_cell_ = NULL;
} }
void xlsx_text_context::Impl::add_text(const std::wstring & text) void xlsx_text_context::Impl::add_text(const std::wstring & text)
...@@ -206,18 +208,27 @@ void xlsx_text_context::Impl::ApplyTextProperties(std::wstring style,odf_reader: ...@@ -206,18 +208,27 @@ void xlsx_text_context::Impl::ApplyTextProperties(std::wstring style,odf_reader:
propertiesOut.apply_from(calc_text_properties_content(instances)); propertiesOut.apply_from(calc_text_properties_content(instances));
} }
void xlsx_text_context::Impl::set_cell_text_properties(odf_reader::text_format_properties_content * text_properties)
{
text_properties_cell_ = text_properties;
}
void xlsx_text_context::Impl::write_rPr(std::wostream & strm) void xlsx_text_context::Impl::write_rPr(std::wostream & strm)
{ {
if (paragraph_style_name_.length()<1 && span_style_name_.length()<1 && !(hyperlink_hId.length()>0 && in_draw) )return; if (paragraph_style_name_.length()<1 && span_style_name_.length()<1 && !(hyperlink_hId.length()>0 && in_draw) )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_; odf_reader::text_format_properties_content text_properties_span_;
ApplyTextProperties(span_style_name_, text_properties_span_,odf_types::style_family::Text);
ApplyTextProperties (paragraph_style_name_, text_properties_paragraph_ , odf_types::style_family::Paragraph);
ApplyTextProperties (span_style_name_, text_properties_span_ , odf_types::style_family::Text);
odf_reader::text_format_properties_content text_properties_; odf_reader::text_format_properties_content text_properties_;
if (in_cell_content && text_properties_cell_)
{
text_properties_.apply_from(*text_properties_cell_);
}
text_properties_.apply_from(text_properties_paragraph_); text_properties_.apply_from(text_properties_paragraph_);
text_properties_.apply_from(text_properties_span_); text_properties_.apply_from(text_properties_span_);
...@@ -334,6 +345,8 @@ void xlsx_text_context::Impl::start_cell_content() ...@@ -334,6 +345,8 @@ void xlsx_text_context::Impl::start_cell_content()
span_style_name_ = L""; span_style_name_ = L"";
in_cell_content = true; in_cell_content = true;
text_properties_cell_ = NULL;
} }
void xlsx_text_context::Impl::start_comment_content() void xlsx_text_context::Impl::start_comment_content()
...@@ -418,6 +431,12 @@ void xlsx_text_context::set_local_styles_container(odf_reader::styles_container* ...@@ -418,6 +431,12 @@ void xlsx_text_context::set_local_styles_container(odf_reader::styles_container*
return impl_->set_local_styles_container(local_styles_); return impl_->set_local_styles_container(local_styles_);
} }
void xlsx_text_context::set_cell_text_properties(odf_reader::text_format_properties_content *text_properties)
{
return impl_->set_cell_text_properties(text_properties);
}
void xlsx_text_context::add_text(const std::wstring & text) void xlsx_text_context::add_text(const std::wstring & text)
{ {
return impl_->add_text(text); return impl_->add_text(text);
......
...@@ -13,6 +13,8 @@ namespace odf_reader ...@@ -13,6 +13,8 @@ namespace odf_reader
{ {
class styles_container; class styles_container;
typedef boost::shared_ptr<styles_container> styles_container_ptr; typedef boost::shared_ptr<styles_container> styles_container_ptr;
class text_format_properties_content;
}; };
namespace oox { namespace oox {
...@@ -25,9 +27,8 @@ public: ...@@ -25,9 +27,8 @@ public:
xlsx_text_context(odf_reader::styles_container & styles_); xlsx_text_context(odf_reader::styles_container & styles_);
~xlsx_text_context(); ~xlsx_text_context();
public: public:
void set_local_styles_container(odf_reader::styles_container* local_styles_); void set_local_styles_container (odf_reader::styles_container *local_styles_);
void set_cell_text_properties (odf_reader::text_format_properties_content *text_properties);
void add_text(const std::wstring & text);
void start_paragraph(const std::wstring & styleName); void start_paragraph(const std::wstring & styleName);
void end_paragraph(); void end_paragraph();
...@@ -48,6 +49,8 @@ public: ...@@ -48,6 +49,8 @@ public:
void start_hyperlink(); void start_hyperlink();
void end_hyperlink(std::wstring hId); void end_hyperlink(std::wstring hId);
void add_text(const std::wstring & text);
void write_shared_strings(std::wostream & strm); void write_shared_strings(std::wostream & strm);
bool is_drawing_context(); bool is_drawing_context();
......
...@@ -7,8 +7,8 @@ ...@@ -7,8 +7,8 @@
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
#include <boost/regex.hpp> #include <boost/regex.hpp>
//#include <boost/date_time/gregorian/gregorian.hpp> #include <boost/date_time/gregorian/gregorian.hpp>
//#include <boost/date_time/posix_time/posix_time.hpp> #include <boost/date_time/posix_time/posix_time.hpp>
namespace cpdoccore { namespace cpdoccore {
...@@ -165,34 +165,30 @@ std::wstring cellType2Str(XlsxCellType::type type) ...@@ -165,34 +165,30 @@ std::wstring cellType2Str(XlsxCellType::type type)
boost::int64_t convertDate(int Year, int Month, int Day) boost::int64_t convertDate(int Year, int Month, int Day)
{ {
return 0; using namespace boost::gregorian;
//todooo !!!!
//using namespace boost::gregorian; boost::int64_t daysFrom1900 = date_duration(date(Year, Month, Day) - date(1900, 1, 1)).days() + 1;
//boost::int64_t daysFrom1900 = date_duration(date(Year, Month, Day) - date(1900, 1, 1)).days() + 1; if (Year <= 1900 &&
Month <= 2 &&
//if (Year <= 1900 && Day <= 29)
// Month <= 2 && {
// Day <= 29) return daysFrom1900;
//{ }
// return daysFrom1900; else
//} {
//else return daysFrom1900 + 1;
//{ }
// return daysFrom1900 + 1;
//}
} }
double convertTime(int hours, int minutes, double sec) double convertTime(int hours, int minutes, double sec)
{ {
//todooo !!!!! boost::posix_time::time_duration t(hours, minutes, 0);
t += boost::posix_time::millisec(static_cast<boost::uint32_t>(sec * 1000));
//boost::posix_time::time_duration t(hours, minutes, 0); boost::posix_time::time_duration day(24, 0, 0);
//t += boost::posix_time::millisec(static_cast<boost::uint32_t>(sec * 1000));
//boost::posix_time::time_duration day(24, 0, 0);
const boost::uint64_t m1 = 0;//t.total_milliseconds() ; const boost::uint64_t m1 = t.total_milliseconds() ;
const boost::uint64_t m2 = 1;//day.total_milliseconds() ; const boost::uint64_t m2 = day.total_milliseconds() ;
const double v = 1.0 * m1 / m2; const double v = 1.0 * m1 / m2;
return v; return v;
} }
......
...@@ -53,6 +53,7 @@ bool xlsx_xf::operator == (const xlsx_xf & rVal) const ...@@ -53,6 +53,7 @@ bool xlsx_xf::operator == (const xlsx_xf & rVal) const
{ {
const bool res = const bool res =
applyAlignment.get_value_or(false) == rVal.applyAlignment.get_value_or(false) && applyAlignment.get_value_or(false) == rVal.applyAlignment.get_value_or(false) &&
applyBorder.get_value_or(false) == rVal.applyBorder.get_value_or(false) &&
applyFill.get_value_or(false) == rVal.applyFill.get_value_or(false) && applyFill.get_value_or(false) == rVal.applyFill.get_value_or(false) &&
applyFont.get_value_or(false) == rVal.applyFont.get_value_or(false) && applyFont.get_value_or(false) == rVal.applyFont.get_value_or(false) &&
applyNumberForm.get_value_or(false) == rVal.applyNumberForm.get_value_or(false) && applyNumberForm.get_value_or(false) == rVal.applyNumberForm.get_value_or(false) &&
......
...@@ -391,7 +391,7 @@ public: ...@@ -391,7 +391,7 @@ public:
void add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name, document_context * Context); void add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name, document_context * Context);
bool docx_convert(oox::docx_conversion_context & Context) ; bool docx_convert(oox::docx_conversion_context & Context) ;
int xlsx_convert(oox::xlsx_conversion_context & Context) ; int xlsx_convert(oox::xlsx_conversion_context & Context, text_format_properties_content & text_properties) ;
bool pptx_convert(oox::pptx_conversion_context & Context) ; bool pptx_convert(oox::pptx_conversion_context & Context) ;
private: private:
......
...@@ -28,13 +28,16 @@ namespace odf_reader { ...@@ -28,13 +28,16 @@ namespace odf_reader {
static formulasconvert::odf2oox_converter formulas_converter; static formulasconvert::odf2oox_converter formulas_converter;
int table_table_cell_content::xlsx_convert(oox::xlsx_conversion_context & Context) int table_table_cell_content::xlsx_convert(oox::xlsx_conversion_context & Context, text_format_properties_content & text_properties)
{ {
Context.get_table_context().start_cell_content(); Context.get_table_context().start_cell_content();
Context.get_text_context().set_cell_text_properties(text_properties);
BOOST_FOREACH(office_element_ptr const & elm, text_content_) BOOST_FOREACH(office_element_ptr const & elm, text_content_)
{ {
elm->xlsx_convert(Context); elm->xlsx_convert(Context);
} }
const int sharedStrId = Context.get_table_context().end_cell_content(); const int sharedStrId = Context.get_table_context().end_cell_content();
return sharedStrId; return sharedStrId;
} }
...@@ -386,6 +389,7 @@ void table_table_column::xlsx_convert(oox::xlsx_conversion_context & Context) ...@@ -386,6 +389,7 @@ void table_table_column::xlsx_convert(oox::xlsx_conversion_context & Context)
size_t style_ = Context.get_style_manager().xfId(NULL,NULL, &cellFormatProperties, NULL, L"", set_default); size_t style_ = Context.get_style_manager().xfId(NULL,NULL, &cellFormatProperties, NULL, L"", set_default);
//if (style_>=0) //if (style_>=0)
if (set_default)
CP_XML_ATTR(L"style", style_ ); CP_XML_ATTR(L"style", style_ );
} }
} }
...@@ -489,8 +493,9 @@ std::wstring CalcCellDataStyle(oox::xlsx_conversion_context & Context, ...@@ -489,8 +493,9 @@ std::wstring CalcCellDataStyle(oox::xlsx_conversion_context & Context,
) )
{ {
odf_read_context & odfContext = Context.root()->odf_context(); odf_read_context & odfContext = Context.root()->odf_context();
style_instance * defaultCellStyle = odfContext.styleContainer().style_default_by_type(style_family::TableCell); style_instance * defaultCellStyle = odfContext.styleContainer().style_default_by_type(style_family::TableCell);
style_instance * defaultColumnCellStyle = odfContext.styleContainer().style_by_name(defaultColumnCellStyleName, style_family::TableCell,false); style_instance * defaultColumnCellStyle = odfContext.styleContainer().style_by_name (defaultColumnCellStyleName, style_family::TableCell,false);
style_instance * defaultRowCellStyle = odfContext.styleContainer().style_by_name(defaultRowCellStyleName, style_family::TableCell,false); style_instance * defaultRowCellStyle = odfContext.styleContainer().style_by_name(defaultRowCellStyleName, style_family::TableCell,false);
style_instance * cellStyle = odfContext.styleContainer().style_by_name(cellStyleName, style_family::TableCell,false); style_instance * cellStyle = odfContext.styleContainer().style_by_name(cellStyleName, style_family::TableCell,false);
...@@ -530,6 +535,7 @@ void table_table_cell::xlsx_convert(oox::xlsx_conversion_context & Context) ...@@ -530,6 +535,7 @@ void table_table_cell::xlsx_convert(oox::xlsx_conversion_context & Context)
bool skip_next_cell = false; bool skip_next_cell = false;
size_t xfId_last_set = 0; size_t xfId_last_set = 0;
bool is_style_visible = true; bool is_style_visible = true;
int empty_cell = 0;
for (unsigned int r = 0; r < table_table_cell_attlist_.table_number_columns_repeated_; ++r) for (unsigned int r = 0; r < table_table_cell_attlist_.table_number_columns_repeated_; ++r)
{ {
...@@ -538,8 +544,8 @@ void table_table_cell::xlsx_convert(oox::xlsx_conversion_context & Context) ...@@ -538,8 +544,8 @@ void table_table_cell::xlsx_convert(oox::xlsx_conversion_context & Context)
table_table_cell_attlist_extra_.table_number_rows_spanned_ - 1 table_table_cell_attlist_extra_.table_number_rows_spanned_ - 1
); );
if (!skip_next_cell) if (skip_next_cell)break;
{
// //
odf_read_context & odfContext = Context.root()->odf_context(); odf_read_context & odfContext = Context.root()->odf_context();
...@@ -585,10 +591,9 @@ void table_table_cell::xlsx_convert(oox::xlsx_conversion_context & Context) ...@@ -585,10 +591,9 @@ void table_table_cell::xlsx_convert(oox::xlsx_conversion_context & Context)
instances.push_back(cellStyle); instances.push_back(cellStyle);
} }
text_format_properties_content textFormatProperties = calc_text_properties_content(instances); text_format_properties_content textFormatProperties = calc_text_properties_content (instances);
paragraph_format_properties parFormatProperties = calc_paragraph_properties_content (instances);
paragraph_format_properties parFormatProperties = calc_paragraph_properties_content(instances); style_table_cell_properties_attlist cellFormatProperties = calc_table_cell_properties (instances);
style_table_cell_properties_attlist cellFormatProperties = calc_table_cell_properties(instances);
using oox::XlsxCellType; using oox::XlsxCellType;
XlsxCellType::type t_val = XlsxCellType::s; XlsxCellType::type t_val = XlsxCellType::s;
...@@ -665,33 +670,6 @@ void table_table_cell::xlsx_convert(oox::xlsx_conversion_context & Context) ...@@ -665,33 +670,6 @@ void table_table_cell::xlsx_convert(oox::xlsx_conversion_context & Context)
} }
std::wstring num_format = L""; std::wstring num_format = L"";
if (data_style.empty() && !formula.empty())
{
cpdoccore::formulasconvert::odf2oox_converter converter;
do {
std::wstring table, ref;
if (converter.find_first_ref(formula, table, ref))
{
if (table.empty())
table = Context.get_table_context().get_current_table_name();
std::wstring defaultColumnStyle, defaultRowStyle;
if (const office_element * elm =
search_table_cell(Context.get_spreadsheet(), table, ref, defaultColumnStyle, defaultRowStyle))
{
if (const table_table_cell * cell = dynamic_cast<const table_table_cell *>(elm))
{
const std::wstring cellStyleStr =
cell->table_table_cell_attlist_.table_style_name_.get_value_or(style_ref(L"")).style_name();
data_style = CalcCellDataStyle(Context, cellStyleStr, defaultColumnStyle, defaultRowStyle);
}
}
}
}
while (0);
}
if (!data_style.empty()) if (!data_style.empty())
{ {
...@@ -704,16 +682,16 @@ void table_table_cell::xlsx_convert(oox::xlsx_conversion_context & Context) ...@@ -704,16 +682,16 @@ void table_table_cell::xlsx_convert(oox::xlsx_conversion_context & Context)
} }
} }
oox::xlsx_cell_format cellFormat; oox::xlsx_cell_format cellFormat;
cellFormat.set_cell_type(t_val); cellFormat.set_cell_type(t_val);
cellFormat.set_num_format(oox::odf_string_to_build_in(odf_value_type)); cellFormat.set_num_format(oox::odf_string_to_build_in(odf_value_type));
is_style_visible = true; is_style_visible = (styleName.length() > 0 || defaultColumnCellStyle) ? true : false;
xfId_last_set= Context.get_style_manager().xfId(&textFormatProperties, &parFormatProperties, &cellFormatProperties, &cellFormat, num_format,false,is_style_visible); xfId_last_set= Context.get_style_manager().xfId(&textFormatProperties, &parFormatProperties, &cellFormatProperties, &cellFormat, num_format,false, is_style_visible);
const int sharedStringId = table_table_cell_content_.xlsx_convert(Context); const int sharedStringId = table_table_cell_content_.xlsx_convert(Context, textFormatProperties);
if (t_val == XlsxCellType::str && sharedStringId >=0) t_val = XlsxCellType::s;// , if (t_val == XlsxCellType::str && sharedStringId >=0) t_val = XlsxCellType::s;// ,
...@@ -726,11 +704,9 @@ void table_table_cell::xlsx_convert(oox::xlsx_conversion_context & Context) ...@@ -726,11 +704,9 @@ void table_table_cell::xlsx_convert(oox::xlsx_conversion_context & Context)
(t_val == XlsxCellType::b && bool_val) || (t_val == XlsxCellType::b && bool_val) ||
((t_val == XlsxCellType::str || XlsxCellType::inlineStr) && str_val))is_data_visible = true; ((t_val == XlsxCellType::str || XlsxCellType::inlineStr) && str_val))is_data_visible = true;
// . // .
if ( is_data_visible || (cellStyle && is_style_visible)) if ( is_data_visible || ((cellStyle || defaultColumnCellStyle) && is_style_visible))
{ {
Context.non_empty_row();
CP_XML_WRITER(strm) CP_XML_WRITER(strm)
{ {
CP_XML_NODE(L"c") CP_XML_NODE(L"c")
...@@ -780,15 +756,28 @@ void table_table_cell::xlsx_convert(oox::xlsx_conversion_context & Context) ...@@ -780,15 +756,28 @@ void table_table_cell::xlsx_convert(oox::xlsx_conversion_context & Context)
CP_XML_CONTENT((int)(bool_val.get())); CP_XML_CONTENT((int)(bool_val.get()));
} }
} }
} // c
} }
if ( is_data_visible || (cellStyle && is_style_visible))
{
Context.non_empty_row();
empty_cell = 0 ;
} }
else else
{
empty_cell++;
if (empty_cell > 2)
{ {
skip_next_cell = true; skip_next_cell = true;
} }
}
} // if (!skip_next_cell) }
}
else
{
skip_next_cell = true;
}
Context.end_table_cell(); Context.end_table_cell();
} }
...@@ -798,11 +787,14 @@ void table_covered_table_cell::xlsx_convert(oox::xlsx_conversion_context & Conte ...@@ -798,11 +787,14 @@ void table_covered_table_cell::xlsx_convert(oox::xlsx_conversion_context & Conte
{ {
std::wostream & strm = Context.current_sheet().sheetData(); std::wostream & strm = Context.current_sheet().sheetData();
const int sharedStringId = table_table_cell_content_.xlsx_convert(Context);
for (unsigned int r = 0; r < table_table_cell_attlist_.table_number_columns_repeated_; ++r) for (unsigned int r = 0; r < table_table_cell_attlist_.table_number_columns_repeated_; ++r)
{ {
Context.start_table_covered_cell(); Context.start_table_covered_cell();
const int xfId = Context.get_current_cell_style_id(); const int xfId = Context.get_current_cell_style_id();
CP_XML_WRITER(strm) CP_XML_WRITER(strm)
{ {
CP_XML_NODE(L"c") CP_XML_NODE(L"c")
...@@ -810,7 +802,17 @@ void table_covered_table_cell::xlsx_convert(oox::xlsx_conversion_context & Conte ...@@ -810,7 +802,17 @@ void table_covered_table_cell::xlsx_convert(oox::xlsx_conversion_context & Conte
CP_XML_ATTR(L"r", Context.current_cell_address()); CP_XML_ATTR(L"r", Context.current_cell_address());
if (xfId >= 0) if (xfId >= 0)
{
CP_XML_ATTR(L"s", xfId); CP_XML_ATTR(L"s", xfId);
}
if (sharedStringId >=0)
{
CP_XML_NODE(L"v")
{
CP_XML_CONTENT(sharedStringId);
}
}
} // c } // c
} }
......
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