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)
replace_cells_range(workstr);
replace_semicolons(workstr);
replace_vertical(workstr);
int res_find=0;
if ((res_find = workstr.find(L"CONCATINATE")) > 0)
{
//ìîãóò áûòü ÷àñòè÷íî çàäàíû äèàïàçîíû
//todooo
}
return workstr;
}
......
......@@ -22,11 +22,11 @@ std::pair<float, float> GetMaxDigitSizePixelsImpl(const std::wstring & fontName,
{
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);
}
......@@ -34,9 +34,13 @@ std::pair<float, float> GetMaxDigitSizePixelsImpl(const std::wstring & fontName,
float maxWidth = 0;
float maxHeight = 0;
float minWidth = 0xffff;
float minHeight = 0xffff;
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);
TBBox box;
......@@ -48,15 +52,18 @@ std::pair<float, float> GetMaxDigitSizePixelsImpl(const std::wstring & fontName,
return std::pair<float, float>(7,8);
}
if (box.fMaxX > 0xffff-1 || box.fMaxY > 0xffff-1 ||
box.fMinX < 0xffff+1 || box.fMinY > 0xffff+1)
if (box.fMaxX < -0xffff+1 || box.fMaxY < -0xffff+1 ||
box.fMinX > 0xffff-1 || box.fMinY > 0xffff-1)
return std::pair<float, float>(7,8);
if (box.fMaxX - box.fMinX > maxWidth) maxWidth = box.fMaxX - box.fMinX;
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,14 +16,15 @@ public:
xlsx_cell_format();
public:
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;
void set_num_format(int numFmt);
int get_num_format() const;
void set_num_format(int numFmt);
private:
XlsxCellType::type cell_type_;
int num_format_;
XlsxCellType::type cell_type_;
int num_format_;
};
......
......@@ -26,6 +26,8 @@ public:
void add_format(std::wstring const & cond, std::wstring const & format);
void end_complex_format();
//std::wstring default_data_style(int type);
private:
class Impl;
_CP_SCOPED_PTR(Impl) impl_;
......
......@@ -128,6 +128,7 @@ size_t xlsx_style_manager::Impl::xfId(const odf_reader::text_format_properties_c
const xlsx_cell_format * xlxsCellFormat,
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);
is_visible = false;
......@@ -137,8 +138,8 @@ size_t xlsx_style_manager::Impl::xfId(const odf_reader::text_format_properties_c
bool default_fill = false;
const size_t fillId = fills_.fillId(textProp, parProp, cellProp, default_set,default_fill);
if (!default_border || !default_fill/* || (fillId >2 && default_set!=default_fill)*/)
is_visible = true;
if (!default_border || !default_fill || is_visible_set/* || (fillId >2 && default_set!=default_fill)*/)
is_visible = true;
xlsx_alignment alignment = OdfProperties2XlsxAlignment(textProp, parProp, cellProp);
const unsigned int id = next_index_;//static_cast<unsigned int>(cellXfs_.size());
......
......@@ -29,8 +29,8 @@ const xlsx_table_state & xlsx_table_context::state() const
}
xlsx_table_context::
xlsx_table_context(xlsx_conversion_context & Context, xlsx_text_context & textCotnext): context_(Context),
xlsx_text_context_(textCotnext)
xlsx_table_context(xlsx_conversion_context & Context, xlsx_text_context & textContext): context_(Context),
xlsx_text_context_(textContext)
{
}
......
......@@ -80,8 +80,8 @@ public:
void serialize_hyperlinks(std::wostream & _Wostream);
private:
xlsx_conversion_context & context_;
xlsx_text_context & xlsx_text_context_;
xlsx_conversion_context & context_;
xlsx_text_context & xlsx_text_context_;
std::list<xlsx_table_state> table_state_stack_;
};
......
......@@ -33,25 +33,26 @@ public:
public:
void add_text(const std::wstring & text);
void start_paragraph(const std::wstring & styleName);
void end_paragraph();
void start_paragraph(const std::wstring & styleName);
void end_paragraph();
void start_span(const std::wstring & styleName);
void end_span();
std::wstring end_span2();
void start_span(const std::wstring & styleName);
void end_span();
std::wstring end_span2();
void start_cell_content();
int end_cell_content();
void start_cell_content();
void set_cell_text_properties( odf_reader::text_format_properties_content * text_properties);
int end_cell_content();
void start_comment_content();
std::wstring end_comment_content();
void start_comment_content();
std::wstring end_comment_content();
void start_drawing_content();
std::wstring end_drawing_content();
void start_drawing_content();
std::wstring end_drawing_content();
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_);//это если стили объектов содержатся в другом документе
......@@ -69,17 +70,17 @@ private:
bool in_paragraph;
bool in_cell_content;
odf_reader::styles_container & styles_;
odf_reader::styles_container * local_styles_ptr_;
odf_reader::styles_container & styles_;
odf_reader::text_format_properties_content * text_properties_cell_;
odf_reader::styles_container * local_styles_ptr_;
std::wstring dump_text();
void write_rPr(std::wostream & strm);
size_t paragraphs_cout_; //???? тока из за начала отсчета?
std::wstringstream text_;
std::wstringstream output_;
std::wstringstream text_;
std::wstringstream output_;
xlsx_shared_strings xlsx_shared_strings_;
std::wstring paragraph_style_name_;//был вектор ... не нужен, так как в один момент времени может быть тока один стиль параграфа,текста,объекта при приходе нового - дампится
......@@ -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),
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)
......@@ -206,18 +208,27 @@ void xlsx_text_context::Impl::ApplyTextProperties(std::wstring style,odf_reader:
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)
{
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_;
ApplyTextProperties (paragraph_style_name_, text_properties_paragraph_,odf_types::style_family::Paragraph);
odf_reader::text_format_properties_content text_properties_paragraph_;
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_;
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_span_);
......@@ -334,6 +345,8 @@ void xlsx_text_context::Impl::start_cell_content()
span_style_name_ = L"";
in_cell_content = true;
text_properties_cell_ = NULL;
}
void xlsx_text_context::Impl::start_comment_content()
......@@ -418,6 +431,12 @@ void xlsx_text_context::set_local_styles_container(odf_reader::styles_container*
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)
{
return impl_->add_text(text);
......
......@@ -13,6 +13,8 @@ namespace odf_reader
{
class styles_container;
typedef boost::shared_ptr<styles_container> styles_container_ptr;
class text_format_properties_content;
};
namespace oox {
......@@ -25,28 +27,29 @@ public:
xlsx_text_context(odf_reader::styles_container & styles_);
~xlsx_text_context();
public:
void set_local_styles_container(odf_reader::styles_container* local_styles_);
void add_text(const std::wstring & text);
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 start_paragraph(const std::wstring & styleName);
void end_paragraph();
void start_paragraph(const std::wstring & styleName);
void end_paragraph();
void start_span(const std::wstring & styleName);
void end_span();
std::wstring end_span2();
void start_span(const std::wstring & styleName);
void end_span();
std::wstring end_span2();
void start_cell_content();
int end_cell_content();
void start_cell_content();
int end_cell_content();
void start_comment_content();
std::wstring end_comment_content();
void start_comment_content();
std::wstring end_comment_content();
void start_drawing_content();
std::wstring end_drawing_content();
void start_drawing_content();
std::wstring end_drawing_content();
void start_hyperlink();
void end_hyperlink(std::wstring hId);
void start_hyperlink();
void end_hyperlink(std::wstring hId);
void add_text(const std::wstring & text);
void write_shared_strings(std::wostream & strm);
......
......@@ -7,8 +7,8 @@
#include <boost/foreach.hpp>
#include <boost/regex.hpp>
//#include <boost/date_time/gregorian/gregorian.hpp>
//#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/date_time/gregorian/gregorian.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
namespace cpdoccore {
......@@ -165,34 +165,30 @@ std::wstring cellType2Str(XlsxCellType::type type)
boost::int64_t convertDate(int Year, int Month, int Day)
{
return 0;
//todooo !!!!
//using namespace boost::gregorian;
//boost::int64_t daysFrom1900 = date_duration(date(Year, Month, Day) - date(1900, 1, 1)).days() + 1;
//if (Year <= 1900 &&
// Month <= 2 &&
// Day <= 29)
//{
// return daysFrom1900;
//}
//else
//{
// return daysFrom1900 + 1;
//}
using namespace boost::gregorian;
boost::int64_t daysFrom1900 = date_duration(date(Year, Month, Day) - date(1900, 1, 1)).days() + 1;
if (Year <= 1900 &&
Month <= 2 &&
Day <= 29)
{
return daysFrom1900;
}
else
{
return daysFrom1900 + 1;
}
}
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 day(24, 0, 0);
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 day(24, 0, 0);
const boost::uint64_t m1 = 0;//t.total_milliseconds() ;
const boost::uint64_t m2 = 1;//day.total_milliseconds() ;
const boost::uint64_t m1 = t.total_milliseconds() ;
const boost::uint64_t m2 = day.total_milliseconds() ;
const double v = 1.0 * m1 / m2;
return v;
}
......
......@@ -52,20 +52,21 @@ void xlsx_serialize(std::wostream & _Wostream, const xlsx_xf & xf)
bool xlsx_xf::operator == (const xlsx_xf & rVal) const
{
const bool res =
applyAlignment.get_value_or(false) == rVal.applyAlignment.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) &&
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) &&
applyFont.get_value_or(false) == rVal.applyFont.get_value_or(false) &&
applyNumberForm.get_value_or(false) == rVal.applyNumberForm.get_value_or(false) &&
applyProtection.get_value_or(false) == rVal.applyProtection.get_value_or(false) &&
borderId == rVal.borderId &&
fillId == rVal.fillId &&
fontId == rVal.fontId &&
numFmtId == rVal.numFmtId &&
borderId == rVal.borderId &&
fillId == rVal.fillId &&
fontId == rVal.fontId &&
numFmtId == rVal.numFmtId &&
pivotButton.get_value_or(false) == rVal.pivotButton.get_value_or(false) &&
quotePrefix.get_value_or(false) == rVal.quotePrefix.get_value_or(false) &&
//xfId == rVal.xfId &&
alignment == rVal.alignment &&
protection == rVal.protection;
alignment == rVal.alignment &&
protection == rVal.protection;
return res;
}
......
......@@ -108,16 +108,16 @@ public:
void process_styles();
xlsx_text_context & get_text_context() { return xlsx_text_context_; }
xlsx_table_context & get_table_context() { return xlsx_table_context_; }
xlsx_text_context & get_text_context() { return xlsx_text_context_; }
xlsx_table_context & get_table_context() { return xlsx_table_context_; }
const xlsx_table_context & get_table_context() const { return xlsx_table_context_; }
xlsx_style_manager & get_style_manager() { return xlsx_style_; }
xlsx_style_manager & get_style_manager() { return xlsx_style_; }
xlsx_xml_worksheet & current_sheet();
oox_chart_context & current_chart();
num_format_context & get_num_format_context() { return num_format_context_; }
num_format_context & get_num_format_context() { return num_format_context_; }
size_t get_default_cell_style() const { return default_style_; }
xlsx_defined_names & get_xlsx_defined_names() { return xlsx_defined_names_; }
xlsx_defined_names & get_xlsx_defined_names() { return xlsx_defined_names_; }
xlsx_table_metrics & get_table_metrics();
xlsx_drawing_context & get_drawing_context();
xlsx_drawing_context_handle & get_drawing_context_handle();
......@@ -130,11 +130,11 @@ private:
void create_new_sheet(std::wstring const & name);
void dump_sheet();
package::xlsx_document *output_document_;
const odf_reader::office_element *spreadsheet_;
odf_reader::odf_document *odf_document_;
package::xlsx_document *output_document_;
const odf_reader::office_element *spreadsheet_;
odf_reader::odf_document *odf_document_;
CApplicationFonts *applicationFonts_;
CApplicationFonts *applicationFonts_;
std::vector<xlsx_xml_worksheet_ptr> sheets_;
std::vector<oox_chart_context_ptr> charts_;
......
......@@ -391,7 +391,7 @@ public:
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) ;
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) ;
private:
......@@ -429,9 +429,9 @@ private:
virtual void add_text(const std::wstring & Text);
public:
table_table_cell_attlist table_table_cell_attlist_;
table_table_cell_attlist_extra table_table_cell_attlist_extra_;
table_table_cell_content table_table_cell_content_;
table_table_cell_attlist table_table_cell_attlist_;
table_table_cell_attlist_extra table_table_cell_attlist_extra_;
table_table_cell_content table_table_cell_content_;
};
......
This diff is collapsed.
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