Commit 77233f22 authored by Elen.Subbotina's avatar Elen.Subbotina Committed by Alexander Trofimov

(1.2.0.150): ASCOfficeOdfFileW


git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@58095 954022d7-b5bf-4e40-9824-e11837661b57
parent d1c6ef71
......@@ -362,7 +362,7 @@ public:
void serialize(CP_ATTR_NODE);
};
/////////////////////////////////////////////////////////////////////////
class draw_connector : public draw_shape
class draw_connector : public draw_line
{
public:
static const wchar_t * ns;
......@@ -374,7 +374,6 @@ public:
virtual void serialize(std::wostream & _Wostream);
draw_connector_attlist draw_connector_attlist_;
draw_line_attlist draw_line_attlist_;
void reset_svg_path();
void reset_svg_attributes();
......
......@@ -627,24 +627,6 @@ void odf_drawing_context::end_shape()
if (impl_->current_drawing_state_.path_.length()>1) path->draw_path_attlist_.svg_d_ = impl_->current_drawing_state_.path_;
if (impl_->current_drawing_state_.view_box_.length()>1) path->draw_path_attlist_.svg_viewbox_ = impl_->current_drawing_state_.view_box_;
}
////////////////////////////////////////////////////////////////////////////////////
draw_connector* connector = dynamic_cast<draw_connector*>(impl_->current_level_.back().get());
if (connector)
{
if (!connector->draw_connector_attlist_.draw_type_) connector->draw_connector_attlist_.draw_type_ = L"line";
connector->draw_line_attlist_.svg_x1_ = impl_->current_drawing_state_.svg_x_;
connector->draw_line_attlist_.svg_y1_ = impl_->current_drawing_state_.svg_y_;
if (impl_->current_drawing_state_.svg_x_ && impl_->current_drawing_state_.svg_width_)
connector->draw_line_attlist_.svg_x2_ = impl_->current_drawing_state_.svg_x_.get() + impl_->current_drawing_state_.svg_width_.get();
if (impl_->current_drawing_state_.svg_y_ && impl_->current_drawing_state_.svg_height_)
connector->draw_line_attlist_.svg_y2_ = impl_->current_drawing_state_.svg_y_.get() + impl_->current_drawing_state_.svg_height_.get();
impl_->current_drawing_state_.svg_height_ = boost::none;
impl_->current_drawing_state_.svg_width_ = boost::none;
}
////////////////////////////////////////////////////////////////////////////////////////////
draw_line* line = dynamic_cast<draw_line*>(impl_->current_level_.back().get());
if (line)
......@@ -660,6 +642,30 @@ void odf_drawing_context::end_shape()
impl_->current_drawing_state_.svg_height_ = boost::none;
impl_->current_drawing_state_.svg_width_ = boost::none;
if (impl_->current_drawing_state_.flipV)
{
_CP_OPT(length) tmp;
tmp = line->draw_line_attlist_.svg_y1_;
line->draw_line_attlist_.svg_y1_ = line->draw_line_attlist_.svg_y2_;
line->draw_line_attlist_.svg_y2_ = tmp;
}
if (impl_->current_drawing_state_.flipH)
{
_CP_OPT(length) tmp;
tmp = line->draw_line_attlist_.svg_x1_;
line->draw_line_attlist_.svg_x1_ = line->draw_line_attlist_.svg_x2_;
line->draw_line_attlist_.svg_x2_ = tmp;
}
}
////////////////////////////////////////////////////////////////////////////////////
draw_connector* connector = dynamic_cast<draw_connector*>(impl_->current_level_.back().get());
if (connector)
{
if (!connector->draw_connector_attlist_.draw_type_) connector->draw_connector_attlist_.draw_type_ = L"line";
}
//////////////////////////////////////////////////////////////////////////////////////////////////
......@@ -972,6 +978,8 @@ void odf_drawing_context::set_viewBox(double W, double H)
}
void odf_drawing_context::set_flip_H(bool bVal)
{
impl_->current_drawing_state_.flipH = bVal;
if (impl_->current_graphic_properties == NULL) return;
if (bVal == false)return;
//for image
......@@ -979,11 +987,11 @@ void odf_drawing_context::set_flip_H(bool bVal)
impl_->current_graphic_properties->content().style_mirror_ = *impl_->current_graphic_properties->content().style_mirror_ + std::wstring(L" horizontal");
else
impl_->current_graphic_properties->content().style_mirror_ = std::wstring(L"horizontal");
//else
impl_->current_drawing_state_.flipH = bVal;
}
void odf_drawing_context::set_flip_V(bool bVal)
{
impl_->current_drawing_state_.flipV = bVal;
if (impl_->current_graphic_properties == NULL) return;
if (bVal == false)return;
//for image
......@@ -991,8 +999,6 @@ void odf_drawing_context::set_flip_V(bool bVal)
impl_->current_graphic_properties->content().style_mirror_ = *impl_->current_graphic_properties->content().style_mirror_ + std::wstring(L" vertical");
else
impl_->current_graphic_properties->content().style_mirror_ = std::wstring(L"vertical");
//else
impl_->current_drawing_state_.flipV = bVal;
}
void odf_drawing_context::set_rotate(double dVal)
......@@ -1063,7 +1069,11 @@ void odf_drawing_context::set_anchor(int type)
if (impl_->is_footer_header_ && type == anchor_type::Page)
type = anchor_type::Paragraph;
impl_->anchor_settings_.anchor_type_ = anchor_type((anchor_type::type)type);
}
anchor_type::type odf_drawing_context::get_anchor()
{
if (impl_->anchor_settings_.anchor_type_) impl_->anchor_settings_.anchor_type_->get_type();
else return anchor_type::AsChar;
}
//////////////////////////////////////////////////////////////////////////////////////
void odf_drawing_context::set_vertical_rel(int from)
......@@ -1085,8 +1095,9 @@ void odf_drawing_context::set_vertical_rel(int from)
if (impl_->is_footer_header_ && ( from ==3 /*|| 5*/))
{
set_anchor(anchor_type::Paragraph);
//
//
impl_->anchor_settings_.style_wrap_ = style_wrap(style_wrap::RunThrough);
impl_->anchor_settings_.run_through_ = run_through(run_through::Background);
}
impl_->anchor_settings_.style_vertical_rel_ = vertical_rel(type);
......@@ -1120,7 +1131,7 @@ void odf_drawing_context::set_horizontal_rel(int from)
{
case 0: type = horizontal_rel::Char; break; // relfromhCharacter = 0,
case 1: type = horizontal_rel::Paragraph; break; // relfromhColumn = 1,
case 2: type = horizontal_rel::ParagraphStartMargin;break; // relfromhInsideMargin = 2, ???
case 2: type = horizontal_rel::Paragraph; break; // relfromhInsideMargin = 2, ???
case 3: type = horizontal_rel::PageStartMargin; break; // relfromhLeftMargin = 3,
case 4: type = horizontal_rel::ParagraphStartMargin;break; // relfromhMargin = 4, ???
case 5: type = horizontal_rel::ParagraphEndMargin; break; // relfromhOutsideMargin = 5,
......
......@@ -37,7 +37,8 @@ public:
void set_margin_top (double valPt);
void set_margin_bottom (double valPt);
void set_anchor (int type);//anchor_type
void set_anchor(int type);//anchor_type
anchor_type::type get_anchor();
void set_object_background(bool Val);
void set_object_foreground(bool Val);
......
......@@ -26,6 +26,8 @@ odf_page_layout_context::odf_page_layout_context(odf_conversion_context * Contex
even_and_left_headers_ = true;
current_page_width_ = 0;
}
odf_page_layout_context::~odf_page_layout_context()
......@@ -495,8 +497,10 @@ void odf_page_layout_context::set_page_size(_CP_OPT(length) width, _CP_OPT(lengt
if (!props)return;
if (width)
{
props->style_page_layout_properties_attlist_.fo_page_width_ =
length(width->get_value_unit(length::cm),length::cm);
}
if (height)
props->style_page_layout_properties_attlist_.fo_page_height_ =
length(height->get_value_unit(length::cm),length::cm);
......
......@@ -71,6 +71,7 @@ public:
void set_background(_CP_OPT(color) & color, int type);
double current_page_width_;
private:
bool even_and_left_headers_;
......
......@@ -271,6 +271,46 @@ void odf_table_context::set_default_column_width(double width)
{
impl_->default_column_width = width;
}
void odf_table_context::set_column_optimal(bool val)
{
if (impl_->empty()) return;
if (impl_->current_table().columns.size() < 1)return;
style *style_ = dynamic_cast<style*>(impl_->current_table().columns.back().style_elm.get());
if (style_ == NULL) return;
style_table_column_properties *properties = style_->style_content_.get_style_table_column_properties();
if (properties == NULL) return;
properties->style_table_column_properties_attlist_.style_use_optimal_column_width_ = val;
}
void odf_table_context::change_current_column_width(double width)
{
if (impl_->empty()) return;
if (impl_->current_table().columns.size() < 1)return;
int index = impl_->current_table().current_column ;
if (index < 0) return;
style *style_ = dynamic_cast<style*>(impl_->current_table().columns[index].style_elm.get());
if (style_ == NULL) return;
style_table_column_properties *properties = style_->style_content_.get_style_table_column_properties();
if (properties == NULL) return;
length length_ = length(length(width,length::pt).get_value_unit(length::cm),length::cm);
if (!properties->style_table_column_properties_attlist_.style_column_width_)
properties->style_table_column_properties_attlist_.style_column_width_ = length_;
else
{
double old_width = properties->style_table_column_properties_attlist_.style_column_width_->get_value_unit(length::pt);
if (old_width < width/* && width < impl_->odf_context_->page_layout_context()->current_page_width_*/)
properties->style_table_column_properties_attlist_.style_column_width_ = length_;
}
}
void odf_table_context::set_column_width(double width)
{
if (impl_->empty()) return;
......
......@@ -36,6 +36,7 @@ public:
void start_table(office_element_ptr &elm, bool styled = false);
void set_default_column_width(double width);
void change_current_column_width(double width);
void end_table();
void set_default_cell_properties(std::wstring style_name);
......@@ -60,6 +61,7 @@ public:
void add_column(office_element_ptr &elm, bool styled = false);
void set_column_width(double width);
void set_column_optimal(bool val);
......
......@@ -187,19 +187,42 @@ void odt_conversion_context::start_drawings()
drawing_context_.push_back(new_drawing_context_);
}
void odt_conversion_context::end_drawings(bool delete_only)
void odt_conversion_context::end_drawings()
{
if (drawing_context_.size() < 1) return;
office_element_ptr & elm = drawing_context()->get_root_element();
if (elm && text_context()->current_level_.size() > 0)
if (elm && text_context()->current_level_.size() > 0)//add to p or h !!!!!
{
if (!delete_only)text_context()->current_level_.back().elm->add_child_element(elm);
anchor_type::type anchor = drawing_context()->get_anchor();
bool bSet = false;
if ( anchor == anchor_type::Page || anchor == anchor_type::Paragraph)
{
for (long i = text_context()->current_level_.size()-1; i>=0; i--)
{
text_p *p = dynamic_cast<text_p*>(text_context()->current_level_[i].elm.get());
text_h *h = dynamic_cast<text_h*>(text_context()->current_level_[i].elm.get());
if (p || h)
{
bSet = true;
text_context()->current_level_[i].elm->add_child_element(elm);
break;
}
}
}
if (!bSet) text_context()->current_level_.back().elm->add_child_element(elm);
drawing_context()->clear();
drawing_context_.pop_back();
}
else// if (delete_only)
else
{
text_context()->start_element(elm);
text_context()->end_element();
drawing_context()->clear();
drawing_context_.pop_back();
}
......@@ -312,10 +335,11 @@ void odt_conversion_context::set_field_instr(std::wstring instr)
current_field_.type = 3;
}
res1 = instr.find(L"PAGEREF");
if (res1 >=0 && current_field_.type == 0) // - bookmark
if (res1 >=0 && current_field_.type == 0 ) // - bookmark
{
current_field_.type = 5;
current_field_.value = instr.substr(9, instr.length()-5);
if (instr.length() > 9)
current_field_.value = instr.substr(9, instr.length()-5);
}
res1 = instr.find(L"PAGE");
if (res1 >=0 && current_field_.type == 0)
......
......@@ -47,7 +47,7 @@ public:
odf_table_context * table_context();
void start_drawings();
void end_drawings(bool delete_only = false);
void end_drawings();
virtual void start_image(std::wstring & image_file_name);
void add_text_content (std::wstring & text);
......
......@@ -147,6 +147,22 @@ void OoxConverter::convert(SimpleTypes::Vml::CCssStyle *vml_style, bool group)
else
odf_context()->drawing_context()->set_rotate(360 - vml_style->m_arrProperties[i]->get_Value().dValue);
}break;
case SimpleTypes::Vml::cssptFlip:
{
switch(vml_style->m_arrProperties[i]->get_Value().eFlip)
{
case SimpleTypes::Vml::cssflipX:
odf_context()->drawing_context()->set_flip_H(true); break;
case SimpleTypes::Vml::cssflipY:
odf_context()->drawing_context()->set_flip_V(true); break;
case SimpleTypes::Vml::cssflipXY:
odf_context()->drawing_context()->set_flip_H(true);
odf_context()->drawing_context()->set_flip_V(true); break;
case SimpleTypes::Vml::cssflipYX:
odf_context()->drawing_context()->set_flip_V(true);
odf_context()->drawing_context()->set_flip_H(true); break;
}
}break;
}
}
if (group)
......@@ -271,6 +287,8 @@ void OoxConverter::convert(OOX::Vml::CLine *vml_line)
odf_context()->drawing_context()->set_position(x, y);
odf_context()->drawing_context()->set_size(width, height);
odf_context()->drawing_context()->set_anchor(2);
}
void OoxConverter::convert(OOX::Vml::COval *vml_oval)
......
......@@ -233,7 +233,7 @@ void OoxConverter::convert(OOX::Drawing::CShape *oox_shape)
if (type == SimpleTypes::shapetypeRect && oox_shape->m_oTxSp.IsInit() && oox_shape->m_oTxSp->m_oTxBody.IsInit()) type = 2000;
if ((type == 2000 || type == SimpleTypes::shapetypeRect ) && oox_shape->m_oTxSp->m_oTxBody->m_oBodyPr.IsInit()
&& oox_shape->m_oTxSp->m_oTxBody->m_oBodyPr->m_oPrstTxWrap.IsInit())
/*&& oox_shape->m_oTxSp->m_oTxBody->m_oBodyPr->m_oPrstTxWrap.IsInit()*/)
{
if (oox_shape->m_oTxSp->m_oTxBody->m_oBodyPr->m_oFromWordArt.ToBool())
{
......@@ -818,8 +818,7 @@ void OoxConverter::convert(OOX::Drawing::CGradientFillProperties *oox_grad_fill,
}
odf_context()->drawing_context()->set_gradient_type(grad_style);
if (oox_grad_fill->m_oGsLst.IsInit() && oox_grad_fill->m_oGsLst->m_arrGs.size()>1 &&
change_sheme_color && oox_grad_fill->m_oGsLst->m_arrGs[0])
if (oox_grad_fill->m_oGsLst.IsInit() && oox_grad_fill->m_oGsLst->m_arrGs.size()>1 && oox_grad_fill->m_oGsLst->m_arrGs[0])
{
std::wstring hexColorStart, hexColorEnd;
_CP_OPT(double) opacityStart, opacityEnd;
......
......@@ -757,6 +757,16 @@ void OoxConverter::convert(OOX::Spreadsheet::CT_BubbleSer* ser)
convert(ser->m_oSpPr.GetPointer());
convert(ser->m_dLbls);
convert(ser->m_xVal, 2);
convert(ser->m_tx);
if (ser->m_dPt.GetCount() > 0)
{
convert(NULL, ser->m_dPt);
}
odf_context()->chart_context()->end_series();
odf_context()->chart_context()->start_series(L"bubble");
convert(ser->m_oSpPr.GetPointer());
convert(ser->m_dLbls);
convert(ser->m_yVal);
convert(ser->m_tx);
if (ser->m_dPt.GetCount() > 0)
......@@ -764,6 +774,17 @@ void OoxConverter::convert(OOX::Spreadsheet::CT_BubbleSer* ser)
convert(NULL, ser->m_dPt);
}
odf_context()->chart_context()->end_series();
odf_context()->chart_context()->start_series(L"bubble");
convert(ser->m_oSpPr.GetPointer());
convert(ser->m_dLbls);
convert(ser->m_bubbleSize);
convert(ser->m_tx);
if (ser->m_dPt.GetCount() > 0)
{
convert(NULL, ser->m_dPt);
}
odf_context()->chart_context()->end_series();
}
void OoxConverter::convert(OOX::Spreadsheet::CT_SurfaceSer* ser)
{
......@@ -823,7 +844,17 @@ void OoxConverter::convert(OOX::Spreadsheet::CT_ScatterSer* ser)
odf_context()->chart_context()->start_series(L"scatter");
convert(ser->m_oSpPr.GetPointer());
convert(ser->m_dLbls);
convert(ser->m_xVal,2);//domain
convert(ser->m_xVal, 2);//domain
convert(ser->m_tx);
if (ser->m_marker || ser->m_dPt.GetCount() > 0)
{
convert(ser->m_marker, ser->m_dPt);
}
odf_context()->chart_context()->end_series();
odf_context()->chart_context()->start_series(L"scatter");
convert(ser->m_oSpPr.GetPointer());
convert(ser->m_dLbls);
convert(ser->m_yVal);
convert(ser->m_tx);
if (ser->m_marker || ser->m_dPt.GetCount() > 0)
......
......@@ -2298,8 +2298,8 @@ void DocxConverter::convert(OOX::Logic::CShape *oox_shape)
if (oox_shape->m_oTxBodyProperties->m_oFromWordArt.ToBool())
{
int wordart_type = OoxConverter::convert(oox_shape->m_oTxBodyProperties->m_oPrstTxWrap.GetPointer());
if (wordart_type >0)type = wordart_type;
}else type = 2000;
if (wordart_type >=0)type = wordart_type;
}
}
if (type < 0)return;
/////////////////////////////////////////////////////////////////////////////////
......@@ -2522,17 +2522,26 @@ void DocxConverter::convert_styles()
void DocxConverter::convert(OOX::Logic::CHyperlink *oox_hyperlink)
{
if (oox_hyperlink == NULL)return;
if (oox_hyperlink->m_oId.IsInit() == false) return;
std::wstring ref = find_link_by_id(oox_hyperlink->m_oId->GetValue(),2);
odt_context->start_hyperlink(ref);
for (unsigned int i=0; i< oox_hyperlink->m_arrItems.size(); i++)
if (oox_hyperlink->m_oId.IsInit()) //
{
convert(oox_hyperlink->m_arrItems[i]);
std::wstring ref = find_link_by_id(oox_hyperlink->m_oId->GetValue(),2);
odt_context->start_hyperlink(ref);
for (unsigned int i=0; i< oox_hyperlink->m_arrItems.size(); i++)
{
convert(oox_hyperlink->m_arrItems[i]);
}
odt_context->end_hyperlink();
}
else
{//
//anchor todooo
for (unsigned int i=0; i< oox_hyperlink->m_arrItems.size(); i++)
{
convert(oox_hyperlink->m_arrItems[i]);
}
}
odt_context->end_hyperlink();
//nullable<CString > m_sAnchor;
//nullable<CString > m_sDocLocation;
//nullable<SimpleTypes::COnOff<SimpleTypes::onoffFalse> > m_oHistory;
......@@ -3231,8 +3240,16 @@ void DocxConverter::convert(OOX::Logic::CTblGrid *oox_table_grid)
{
width = oox_table_grid->m_arrGridCol[i]->m_oW->ToPoints();
}
odt_context->add_table_column(width);
if (width > 0 && width < 5)
{
odt_context->table_context()->set_column_optimal(true);
width *=10;
//2222010_53102Reader final.docx
}
}
odt_context->end_table_columns();
}
......@@ -3575,6 +3592,12 @@ bool DocxConverter::convert(OOX::Logic::CTableCellProperties *oox_table_cell_pr,
else
table_cell_properties->style_table_cell_properties_attlist_.fo_wrap_option_ = odf::wrap_option(odf::wrap_option::Wrap);
}
if (oox_table_cell_pr->m_oTcW.IsInit() && oox_table_cell_pr->m_oTcW->m_oW.IsInit() &&
oox_table_cell_pr->m_oTcW->m_oType.IsInit() && oox_table_cell_pr->m_oTcW->m_oType->GetValue() == SimpleTypes::tblwidthDxa)
{
// :( //2222010_53102Reader final.docx -
odt_context->table_context()->change_current_column_width(oox_table_cell_pr->m_oTcW->m_oW->GetValue()/ 20.);//dxa type
}
//nullable<OOX::Logic::CHeaders > m_oHeaders;
......
......@@ -2,6 +2,6 @@
//1
//2
//0
//149
#define INTVER 1,2,0,149
#define STRVER "1,2,0,149\0"
//150
#define INTVER 1,2,0,150
#define STRVER "1,2,0,150\0"
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