Commit 9e1e29f0 authored by Elen.Subbotina's avatar Elen.Subbotina Committed by Alexander Trofimov

......

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@56978 954022d7-b5bf-4e40-9824-e11837661b57
parent 51a643fb
......@@ -16,7 +16,6 @@
#include "oox_shape_defines.h"
#include "Shapes\odf_shape_mapping.h"
#include "styles.h"
#include "style_table_properties.h"
......@@ -24,6 +23,8 @@
#include "style_paragraph_properties.h"
#include "style_graphic_properties.h"
namespace cpdoccore
{
namespace odf
......@@ -70,6 +71,8 @@ struct anchor_settings
_CP_OPT(anchor_type) anchor_type_;
_CP_OPT(style_wrap) style_wrap_;
void clear()
{
svg_x_ = boost::none;
......@@ -92,6 +95,8 @@ struct anchor_settings
fo_margin_top_ = boost::none;
fo_margin_right_ = boost::none;
fo_margin_bottom_ = boost::none;
style_wrap_ = boost::none;
}
};
......@@ -407,6 +412,8 @@ void odf_drawing_context::end_drawing()
draw->common_draw_attlists_.shape_with_text_and_styles_.common_draw_shape_with_styles_attlist_.common_text_spreadsheet_shape_attlist_.common_text_anchor_attlist_.type_ = impl_->anchor_settings_.anchor_type_;
//impl_->current_graphic_properties->content().common_text_anchor_attlist_.type_ = impl_->anchor_settings_.anchor_type_;
impl_->current_graphic_properties->content().style_wrap_ = impl_->anchor_settings_.style_wrap_;
///////////////////////////////////////////////////
impl_->drawing_list_.push_back(impl_->current_drawing_state_);
......@@ -898,6 +905,12 @@ void odf_drawing_context::set_horizontal_pos(double offset_pt)
{
impl_->anchor_settings_.style_horizontal_pos_svg_x_ = length(length(offset_pt,length::pt).get_value_unit(length::cm),length::cm);
}
void odf_drawing_context::set_wrap_style(style_wrap::type type)
{
impl_->anchor_settings_.style_wrap_ = style_wrap(type);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void odf_drawing_context::set_position(double x_pt, double y_pt)
{
......
......@@ -12,6 +12,7 @@
#include "office_elements_create.h"
#include "anchortype.h"
#include "stylewrap.h"
namespace cpdoccore {
namespace odf
......@@ -46,6 +47,8 @@ public:
void set_horizontal_pos(int align);
void set_horizontal_pos(double offset_pt);
void set_wrap_style(style_wrap::type style);
///////////////////////////////////////////////////////////////////////////////////////////////////////////
office_element_ptr & get_current_style_element() ;
......
......@@ -50,6 +50,15 @@ void odf_style_state::set_name(std::wstring & name)
style_->style_name_ = name;
}
void odf_style_state::set_display_name(std::wstring & name)
{
style* style_ = dynamic_cast<style*>(odf_style_.get());
if (!style_)return;
style_->style_display_name_ = name;
}
std::wstring & odf_style_state::get_name()
{
style* style_ = dynamic_cast<style*>(odf_style_.get());
......
......@@ -49,6 +49,8 @@ public:
void set_parent_style_name(std::wstring & name) ;
void set_data_style_name(std::wstring & name);
void set_display_name(std::wstring & name);
//////////////////////////////////////////////////////////////////////////////////////////
style_text_properties * get_text_properties();
style_paragraph_properties * get_paragraph_properties() ;
......
......@@ -94,6 +94,10 @@ const wchar_t * text_line_break::name = L"line-break";
void text_line_break::serialize(std::wostream & _Wostream)
{
CP_XML_WRITER(_Wostream)
{
CP_XML_NODE_SIMPLE();
}
}
......
......@@ -6,6 +6,7 @@
#include "../utils.h"
#include <DocxFormat\Docx.h>
#include <DocxFormat\External\Hyperlink.h>
#include <XlsxFormat\Chart\Chart.h>
#include <boost/foreach.hpp>
......@@ -55,23 +56,40 @@ OOX::CTheme* DocxConverter::oox_theme()
}
CString DocxConverter::find_link_by_id (CString sId, int type)
{
OOX::CDocument *oox_doc = docx_document->GetDocument();
if (oox_doc == NULL)return L"";
CString ref;
if (type==1)
{
if (docx_document->GetDocument())
{
smart_ptr<OOX::File> oFile = docx_document->GetDocument()->Find(sId);
if (oFile.IsInit() && OOX::FileTypes::Image == oFile->type())
if (oFile.IsInit())
{
if (type==1 && OOX::FileTypes::Image == oFile->type())
{
OOX::Image* pImage = (OOX::Image*)oFile.operator->();
ref = pImage->filename().GetPath();
}
if (type == 2 && OOX::FileTypes::HyperLink == oFile->type())
{
OOX::HyperLink* pHyperlink = (OOX::HyperLink*)oFile.operator->();
ref = pHyperlink->Uri().GetPath();
}
}
if (ref.GetLength() < 1 && oox_current_chart)
{
smart_ptr<OOX::File> oFile = oox_current_chart->Find(sId);
if (oFile.IsInit() && OOX::FileTypes::Image == oFile->type())
if (oFile.IsInit())
{
if (type==1 && OOX::FileTypes::Image == oFile->type())
{
OOX::Image* pImage = (OOX::Image*)oFile.operator->();
ref = pImage->filename().GetPath();
}
if (type==2 && oFile.IsInit() && OOX::FileTypes::Image == oFile->type())
{
OOX::Image* pImage = (OOX::Image*)oFile.operator->();
......@@ -133,6 +151,11 @@ void DocxConverter::convert(OOX::WritingElement *oox_unknown)
OOX::Logic::CParagraphProperty* pPProp= static_cast<OOX::Logic::CParagraphProperty*>(oox_unknown);
convert(pPProp);
}break;
case OOX::et_w_hyperlink:
{
OOX::Logic::CHyperlink* pH= static_cast<OOX::Logic::CHyperlink*>(oox_unknown);
convert(pH);
}break;
case OOX::et_w_rPr:
{
OOX::Logic::CRunProperty* pRProp= static_cast<OOX::Logic::CRunProperty*>(oox_unknown);
......@@ -158,6 +181,19 @@ void DocxConverter::convert(OOX::WritingElement *oox_unknown)
OOX::Logic::CGroupShape* pGroupShape= static_cast<OOX::Logic::CGroupShape*>(oox_unknown);
convert(pGroupShape);
}break;
case OOX::et_w_commentRangeEnd:
{
OOX::Logic::CShape* pShape = static_cast<OOX::Logic::CShape*>(oox_unknown);
convert(pShape);
}break;
case OOX::et_w_commentRangeStart:
{
OOX::Logic::CShape* pShape = static_cast<OOX::Logic::CShape*>(oox_unknown);
convert(pShape);
}break;
case OOX::et_w_commentReference:
{
}break;
default:
{
OoxConverter::convert(oox_unknown);
......@@ -209,6 +245,16 @@ void DocxConverter::convert(OOX::Logic::CRun *oox_run)//wordprocessing 22.1.2.87
// Run - -
switch(oox_run->m_arrItems[i]->getType())
{
case OOX::et_w_fldChar:
{
OOX::Logic::CFldChar* pFldChar= static_cast<OOX::Logic::CFldChar*>(oox_run->m_arrItems[i]);
convert(pFldChar);
}break;
case OOX::et_w_instrText:
{
OOX::Logic::CInstrText* pInstrText= static_cast<OOX::Logic::CInstrText*>(oox_run->m_arrItems[i]);
convert(pInstrText);
}break;
case OOX::et_w_rPr:
{
styled = true;
......@@ -270,30 +316,49 @@ void DocxConverter::convert(OOX::Logic::CRun *oox_run)//wordprocessing 22.1.2.87
//ruby
//softHyphen
//delInstrText
//fldChar
//instrText
default:
convert(oox_run->m_arrItems[i]);
}
}
if (styled)
{
odf::odf_style_state * state = odt_context->styles_context()->last_state(odf::style_family::Text);
if (state)
odt_context->text_context()->add_text_style(state->get_office_element(),state->get_name());
//odf::odf_style_state * state = odt_context->styles_context()->last_state(odf::style_family::Text);
//if (state)
// odt_context->text_context()->add_text_style(state->get_office_element(),state->get_name());
//
}
odt_context->end_run();
}
void DocxConverter::convert(OOX::Logic::CFldChar *oox_fld)
{
if (oox_fld == NULL) return;
//nullable<SimpleTypes::COnOff<> > m_oDirty;
//nullable<SimpleTypes::COnOff<> > m_oFldLock;
//nullable<OOX::Logic::CFFData > m_oFFData;
if (oox_fld->m_oFldCharType.IsInit())
{
if (oox_fld->m_oFldCharType->GetValue() == SimpleTypes::fldchartypeBegin) odt_context->start_field();
if (oox_fld->m_oFldCharType->GetValue() == SimpleTypes::fldchartypeEnd) odt_context->end_field();
}
}
void DocxConverter::convert(OOX::Logic::CInstrText *oox_instr)
{
if (oox_instr == NULL) return;
odt_context->set_field_instr(string2std_string(oox_instr->m_sText));
}
void DocxConverter::convert(OOX::Logic::CParagraphProperty *oox_paragraph_pr, cpdoccore::odf::style_paragraph_properties * paragraph_properties)
{
if (!oox_paragraph_pr) return;
if (!paragraph_properties) return;
if (oox_paragraph_pr->m_oPStyle.IsInit())
if (oox_paragraph_pr->m_oPStyle.IsInit() && oox_paragraph_pr->m_oPStyle->m_sVal.IsInit())
{
//add parent style ...
odt_context->styles_context()->last_state().set_parent_style_name(string2std_string(*oox_paragraph_pr->m_oPStyle->m_sVal));
}
if (oox_paragraph_pr->m_oSpacing.IsInit())
......@@ -375,7 +440,8 @@ void DocxConverter::convert(OOX::Logic::CParagraphProperty *oox_paragraph_pr, cp
}
}
//m_oWordWrap
//if (oox_paragraph_pr->m_oWordWrap.IsInit()) odt_context->set_word_wrap(oox_paragraph_pr->m_oWordWrap->ToBool());
convert(oox_paragraph_pr->m_oPBdr.GetPointer(), paragraph_properties);
if (oox_paragraph_pr->m_oRPr.IsInit())// !!!
......@@ -383,10 +449,6 @@ void DocxConverter::convert(OOX::Logic::CParagraphProperty *oox_paragraph_pr, cp
odf::style_text_properties * text_properties = odf_context()->text_context()->get_text_properties();
if (text_properties)
convert(oox_paragraph_pr->m_oRPr.GetPointer(), text_properties);
// family !!!
//convert(oox_paragraph_pr->m_oDefRunProperty.GetPointer());
//odf_context()->text_context()->set_parent_span_style(odf_context()->styles_context()->last_state().get_name());
}
if (oox_paragraph_pr->m_oShd.IsInit())
{
......@@ -396,6 +458,24 @@ void DocxConverter::convert(OOX::Logic::CParagraphProperty *oox_paragraph_pr, cp
if (odf_color)
paragraph_properties->content().fo_background_color_ = *odf_color;
}
if (oox_paragraph_pr->m_oTextDirection.IsInit() && oox_paragraph_pr->m_oTextDirection->m_oVal.IsInit())
{
switch(oox_paragraph_pr->m_oTextDirection->m_oVal->GetValue())
{
case SimpleTypes::textdirectionLr :
paragraph_properties->content().style_writing_mode_= odf::writing_mode(odf::writing_mode::Lr); break;
case SimpleTypes::textdirectionLrV :
paragraph_properties->content().style_writing_mode_= odf::writing_mode(odf::writing_mode::LrTb); break;
case SimpleTypes::textdirectionRl :
paragraph_properties->content().style_writing_mode_= odf::writing_mode(odf::writing_mode::Rl); break;
case SimpleTypes::textdirectionRlV :
paragraph_properties->content().style_writing_mode_= odf::writing_mode(odf::writing_mode::RlTb); break;
case SimpleTypes::textdirectionTb :
paragraph_properties->content().style_writing_mode_= odf::writing_mode(odf::writing_mode::Tb); break;
case SimpleTypes::textdirectionTbV :
paragraph_properties->content().style_writing_mode_= odf::writing_mode(odf::writing_mode::TbLr); break;
}
}
//m_oSectPr
}
......@@ -521,6 +601,10 @@ void DocxConverter::convert(OOX::Logic::CRunProperty *oox_run_pr, odf::style_tex
if (oox_run_pr == NULL) return;
if (text_properties == NULL)return;
if (oox_run_pr->m_oRStyle.IsInit() && oox_run_pr->m_oRStyle->m_sVal.IsInit())
{
odt_context->styles_context()->last_state().set_parent_style_name(string2std_string(*oox_run_pr->m_oRStyle->m_sVal));
}
if (oox_run_pr->m_oBold.IsInit())
{
if (oox_run_pr->m_oBold->m_oVal.ToBool() ==true)
......@@ -721,7 +805,28 @@ void DocxConverter::convert(OOX::Drawing::CAnchor *oox_anchor)
else
odt_context->drawing_context()->set_horizontal_pos(SimpleTypes::alignhLeft);
}
//if (oox_anchor->m_oWrapNone.IsInit())
//{
//}
if (oox_anchor->m_oWrapSquare.IsInit())
{
if (oox_anchor->m_oWrapSquare->m_oWrapText.IsInit() && oox_anchor->m_oWrapSquare->m_oWrapText->GetValue() == SimpleTypes::wraptextLargest)
odt_context->drawing_context()->set_wrap_style(odf::style_wrap::Dynamic);
else
odt_context->drawing_context()->set_wrap_style(odf::style_wrap::Parallel);
}
if (oox_anchor->m_oWrapThrough.IsInit())//style:wrap="run-through" draw:wrap-influence-on-position style:wrap-contour
{
odt_context->drawing_context()->set_wrap_style(odf::style_wrap::RunThrough);
}
if (oox_anchor->m_oWrapTight.IsInit())
{
odt_context->drawing_context()->set_wrap_style(odf::style_wrap::Parallel);
}
if (oox_anchor->m_oWrapTopAndBottom.IsInit())
{
odt_context->drawing_context()->set_wrap_style(odf::style_wrap::Parallel);
}
convert(oox_anchor->m_oGraphic.GetPointer());
}
void DocxConverter::convert(OOX::Drawing::CInline *oox_inline)
......@@ -1034,6 +1139,29 @@ 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 (long i=0; i< oox_hyperlink->m_arrItems.GetSize(); 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;
//nullable<CString > m_sTgtFrame;
//nullable<CString > m_sTooltip;
}
void DocxConverter::convert(OOX::CDocDefaults *def_style)
{
if (def_style == NULL)return;
......@@ -1055,9 +1183,62 @@ void DocxConverter::convert(OOX::CDocDefaults *def_style)
}
void DocxConverter::convert(OOX::CStyle *style)
void DocxConverter::convert(OOX::CStyle *oox_style)
{
if (style == NULL)return;
if (oox_style == NULL)return;
if (oox_style->m_oType.IsInit() == false)return;
odf::style_family family = odf::style_family::None;
if ( SimpleTypes::styletypeNumbering == oox_style->m_oType->GetValue())
{
return;
}
switch(oox_style->m_oType->GetValue())
{
case SimpleTypes::styletypeCharacter : family = odf::style_family::Text; break;
case SimpleTypes::styletypeParagraph : family = odf::style_family::Paragraph; break;
case SimpleTypes::styletypeTable : family = odf::style_family::Table; break;
}
if (family == odf::style_family::None) return;
std::wstring oox_name = oox_style->m_sStyleId.IsInit() ? string2std_string(*oox_style->m_sStyleId) : L"";
odt_context->styles_context()->create_style(oox_name,family, false, true, -1);
if (oox_style->m_oName.IsInit() && oox_style->m_oName->m_sVal.IsInit())
odt_context->styles_context()->last_state().set_display_name(string2std_string(*oox_style->m_oName->m_sVal));
if (oox_style->m_oRunPr.IsInit())
{
odf::style_text_properties * text_properties = odt_context->styles_context()->last_state().get_text_properties();
convert(oox_style->m_oRunPr.GetPointer(), text_properties);
}
if (oox_style->m_oBasedOn.IsInit() && oox_style->m_oBasedOn->m_sVal.IsInit())
odt_context->styles_context()->last_state().set_parent_style_name(string2std_string(*oox_style->m_oBasedOn->m_sVal));
//nullable<SimpleTypes::COnOff<> > m_oCustomStyle;
//nullable<SimpleTypes::COnOff<> > m_oDefault;
//nullable<ComplexTypes::Word::CString_ > m_oAliases;
//nullable<ComplexTypes::Word::COnOff2<SimpleTypes::onoffTrue>> m_oAutoRedefine;
//nullable<ComplexTypes::Word::COnOff2<SimpleTypes::onoffTrue>> m_oHidden;
//nullable<ComplexTypes::Word::COnOff2<SimpleTypes::onoffTrue>> m_oLocked;
//nullable<ComplexTypes::Word::COnOff2<SimpleTypes::onoffTrue>> m_oPersonal;
//nullable<ComplexTypes::Word::COnOff2<SimpleTypes::onoffTrue>> m_oPersonalCompose;
//nullable<ComplexTypes::Word::COnOff2<SimpleTypes::onoffTrue>> m_oPersonalReply;
//nullable<ComplexTypes::Word::COnOff2<SimpleTypes::onoffTrue>> m_oQFormat;
//nullable<ComplexTypes::Word::COnOff2<SimpleTypes::onoffTrue>> m_oSemiHidden;
//nullable<OOX::Logic::CTableProperty > m_oTblPr;
//CSimpleArray<OOX::Logic::CTableStyleProperties > m_arrTblStylePr;
//nullable<OOX::Logic::CTableCellProperties > m_oTcPr;
//nullable<OOX::Logic::CTableRowProperties > m_oTrPr;
//nullable<ComplexTypes::Word::CDecimalNumber > m_oUiPriority;
//nullable<ComplexTypes::Word::COnOff2<SimpleTypes::onoffTrue>> m_oUnhideWhenUsed;
}
......
......@@ -27,6 +27,9 @@ namespace OOX
class CGroupShape;
class CShape;
class CPBdr;
class CHyperlink;
class CFldChar;
class CInstrText;
}
}
......@@ -88,7 +91,10 @@ namespace Oox2Odf
void convert(OOX::Logic::CRunProperty *oox_run_prop, odf::style_text_properties *text_properties);
void convert(OOX::Logic::CPBdr *oox_border, odf::style_paragraph_properties *paragraph_properties);
void convert(ComplexTypes::Word::CShading *oox_shading, odf::style_text_properties *text_properties );
void convert(OOX::Logic::CFldChar *oox_fld);
void convert(OOX::Logic::CInstrText *oox_instr);
void convert(OOX::Logic::CText *oox_text);
void convert(OOX::Logic::CHyperlink *oox_hyperlink);
void convert(OOX::Logic::CAlternateContent *oox_alt_content);
void convert(OOX::Logic::CDrawing *oox_drawing);
void convert(OOX::Drawing::CAnchor *oox_anchor);
......@@ -97,7 +103,7 @@ namespace Oox2Odf
void convert(OOX::Logic::CGroupShape *oox_group_shape);
void convert(OOX::Logic::CShape *oox_shape);
void convert(OOX::Drawing::CChart *oox_chart);
void convert(OOX::Drawing::CPicture *oox_chart);
void convert(OOX::Drawing::CPicture *oox_picture);
void convert(ComplexTypes::Word::CColor *color, _CP_OPT(odf::color) & odf_color);
void convert(SimpleTypes::CUniversalMeasure *oox_size, _CP_OPT(odf::length) & odf_size);
void convert(SimpleTypes::CUniversalMeasure *oox_size, _CP_OPT(odf::length_or_percent) & odf_size);
......
......@@ -1316,13 +1316,12 @@ void XlsxConverter::convert(OOX::Spreadsheet::CCellStyle * cell_style, int oox_i
ods_context->styles_context()->create_style(style_name,odf::style_family::TableCell, automatic, root, oox_id);
odf::style* style = dynamic_cast<odf::style*>(ods_context->styles_context()->last_state().get_office_element().get());
if (!style)return;
if (style_name.length() > 0)ods_context->styles_context()->last_state().set_display_name(style_name);
int parent_id = cell_style->m_oXfId.IsInit() ? cell_style->m_oXfId->GetValue() : -1;
if (parent_id >=0)
style->style_parent_style_name_ = ods_context->styles_context()->find_odf_style_name(parent_id, odf::style_family::TableCell,true);
ods_context->styles_context()->last_state().set_parent_style_name(ods_context->styles_context()->find_odf_style_name(parent_id, odf::style_family::TableCell,true));
//m_oBuiltinId, m_oCustomBuiltin, m_oHidden, m_oILevel; ???????
}
......
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