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

x2t - конвертация ms<->open office. готово.

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@63021 954022d7-b5bf-4e40-9824-e11837661b57
parent 7548ba71
......@@ -20,7 +20,7 @@ _CP_PTR(oox_axis_content) oox_axis_content::create(int type)
oox_axis_content::oox_axis_content(int type/*,std::wstring name*/)
{
//id_ = abs((int)*((_UINT32*)this));
id_ = abs((int)this);
id_ = abs((long)this);
type_=type; //dimension
}
void oox_axis_content::oox_serialize(std::wostream & _Wostream)
......@@ -204,4 +204,4 @@ void oox_axis_content::oox_serialize_content(std::wostream & _Wostream)
}
}
\ No newline at end of file
}
......@@ -47,10 +47,13 @@ void _mediaitems::add_or_find(const std::wstring & oox_ref, Type type, std::wst
output_fileName = utils::media::create_file_name(oox_ref, type, number);//guid???
std::wstring input_path = oox_ref;
boost::to_lower(input_path);
#if defined (_WIN32) || defined(_WIN64) // + mac???
boost::to_lower(input_path);
#endif
std::wstring output_path ;
std::wstring id;
BOOST_FOREACH(item const & elm, items_)
{
if (elm.oox_ref == input_path)
......
......@@ -409,8 +409,8 @@ void odf_drawing_context::end_drawing()
if (abs(rotate)>0.001)impl_->current_drawing_state_.rotateAngle = rotate;
}
double x = impl_->current_drawing_state_.svg_x_->get_value();
double y = impl_->current_drawing_state_.svg_y_->get_value();
double x = impl_->current_drawing_state_.svg_x_ ? impl_->current_drawing_state_.svg_x_->get_value() : 0;
double y = impl_->current_drawing_state_.svg_y_ ? impl_->current_drawing_state_.svg_y_->get_value() : 0;
if (impl_->current_drawing_state_.rotateAngle)
{
......@@ -1412,12 +1412,12 @@ void odf_drawing_context::set_position(_CP_OPT(double) & x_pt, _CP_OPT(double) &
{
y_pt = *y_pt * impl_->current_group_->scale_cy + impl_->current_group_->shift_y;
//+ (impl_->current_group_->flipV ? (impl_->current_group_->cy - 2 * y_pt): 0);
}
if (!impl_->current_drawing_state_.svg_x_ || impl_->current_drawing_state_.in_group && x_pt)
}
if ((!impl_->current_drawing_state_.svg_x_ || impl_->current_drawing_state_.in_group) && x_pt)
{
impl_->current_drawing_state_.svg_x_ = length(length(*x_pt,length::pt).get_value_unit(length::cm),length::cm);
}
if (!impl_->current_drawing_state_.svg_y_ || impl_->current_drawing_state_.in_group && y_pt)
if ((!impl_->current_drawing_state_.svg_y_ || impl_->current_drawing_state_.in_group) && y_pt)
{
impl_->current_drawing_state_.svg_y_ = length(length(*y_pt,length::pt).get_value_unit(length::cm),length::cm);
}
......@@ -1438,6 +1438,7 @@ void odf_drawing_context::get_size( double & width_pt, double & height_pt)
}
void odf_drawing_context::set_size( _CP_OPT(double) & width_pt, _CP_OPT(double) & height_pt)
{
if (impl_->current_drawing_state_.in_group)
{
if (width_pt)
......@@ -1452,8 +1453,8 @@ void odf_drawing_context::set_size( _CP_OPT(double) & width_pt, _CP_OPT(double)
}
}else
{
if (!impl_->current_drawing_state_.svg_width_) impl_->current_drawing_state_.svg_width_ = length(length(*width_pt,length::pt).get_value_unit(length::cm),length::cm);
if (!impl_->current_drawing_state_.svg_height_) impl_->current_drawing_state_.svg_height_= length(length(*height_pt,length::pt).get_value_unit(length::cm),length::cm);
if (!impl_->current_drawing_state_.svg_width_ && width_pt) impl_->current_drawing_state_.svg_width_ = length(length(*width_pt,length::pt).get_value_unit(length::cm),length::cm);
if (!impl_->current_drawing_state_.svg_height_ && height_pt) impl_->current_drawing_state_.svg_height_= length(length(*height_pt,length::pt).get_value_unit(length::cm),length::cm);
}
}
void odf_drawing_context::set_line_width(double pt)
......
......@@ -29,12 +29,12 @@ namespace Oox2Odf
{
return (Val * 360000 * 2.54) / 72;
}
Converter::Converter(const std::wstring & path, std::wstring type, const std::wstring & fontsPath, const ProgressCallback* CallBack)
Converter::Converter(const std::wstring & path, const std::wstring & type, const std::wstring & fontsPath, const ProgressCallback* CallBack)
{
impl_ = NULL;
if (type == L"text") impl_ = new DocxConverter(path, CallBack);
if (type == L"spreadsheet") impl_ = new XlsxConverter(path, CallBack);
if (type == _T("text")) impl_ = new DocxConverter(path, CallBack);
if (type == _T("spreadsheet")) impl_ = new XlsxConverter(path, CallBack);
if (impl_)
impl_->set_fonts_directory(fontsPath);
......
......@@ -31,12 +31,14 @@ namespace Oox2Odf
{
DocxConverter::DocxConverter(const std::wstring & path, const ProgressCallback* CallBack)
{
output_document = new odf_writer::package::odf_document(L"text");
const OOX::CPath oox_path(CString(path.c_str()));
pCallBack = CallBack;
docx_document = new OOX::CDocx(oox_path);
output_document = new odf_writer::package::odf_document(L"text");
odt_context = new odf_writer::odt_conversion_context(output_document);
const OOX::CPath oox_path(CString(path.c_str()));
docx_document = new OOX::CDocx(oox_path);
pCallBack = CallBack;
//set flags to default
last_section_properties = NULL;
......@@ -131,11 +133,8 @@ CString DocxConverter::find_link_by_id (CString sId, int type)
void DocxConverter::convertDocument()
{
if (!docx_document)return;
odt_context = new odf_writer::odt_conversion_context(output_document);
if (!odt_context)return;
if (!docx_document) return;
if (!odt_context) return;
odt_context->start_document();
......@@ -3520,19 +3519,23 @@ bool DocxConverter::convert(OOX::Logic::CTableProperty *oox_table_pr, odf_writer
if (oox_table_pr->m_oTblpPr->m_oTblpX.IsInit() && oox_table_pr->m_oTblpPr->m_oTblpY.IsInit()){}//floating position
else
{
_CP_OPT(odf_types::length) length, length_left, length_right;
_CP_OPT(odf_types::length) length_, length_left, length_right;
convert(static_cast<SimpleTypes::CUniversalMeasure *>(oox_table_pr->m_oTblpPr->m_oLeftFromText.GetPointer()), length_left);
table_properties->table_format_properties_.common_horizontal_margin_attlist_.fo_margin_left_ = odf_types::length(length_left->get_value_unit(odf_types::length::cm),odf_types::length::cm);
if (length_left)
table_properties->table_format_properties_.common_horizontal_margin_attlist_.fo_margin_left_ = odf_types::length(length_left->get_value_unit(odf_types::length::cm),odf_types::length::cm);
convert(static_cast<SimpleTypes::CUniversalMeasure *>(oox_table_pr->m_oTblpPr->m_oRightFromText.GetPointer()), length_right);
table_properties->table_format_properties_.common_horizontal_margin_attlist_.fo_margin_right_= odf_types::length(length_right->get_value_unit(odf_types::length::cm),odf_types::length::cm);
if (length_right)
table_properties->table_format_properties_.common_horizontal_margin_attlist_.fo_margin_right_= odf_types::length(length_right->get_value_unit(odf_types::length::cm),odf_types::length::cm);
convert(static_cast<SimpleTypes::CUniversalMeasure *>(oox_table_pr->m_oTblpPr->m_oTopFromText.GetPointer()), length);
table_properties->table_format_properties_.common_vertical_margin_attlist_.fo_margin_top_= odf_types::length(length->get_value_unit(odf_types::length::cm),odf_types::length::cm);
convert(static_cast<SimpleTypes::CUniversalMeasure *>(oox_table_pr->m_oTblpPr->m_oTopFromText.GetPointer()), length_);
if (length_)
table_properties->table_format_properties_.common_vertical_margin_attlist_.fo_margin_top_= odf_types::length(length_->get_value_unit(odf_types::length::cm),odf_types::length::cm);
convert(static_cast<SimpleTypes::CUniversalMeasure *>(oox_table_pr->m_oTblpPr->m_oBottomFromText.GetPointer()), length);
table_properties->table_format_properties_.common_vertical_margin_attlist_.fo_margin_bottom_= odf_types::length(length->get_value_unit(odf_types::length::cm),odf_types::length::cm);
convert(static_cast<SimpleTypes::CUniversalMeasure *>(oox_table_pr->m_oTblpPr->m_oBottomFromText.GetPointer()), length_);
if (length_)
table_properties->table_format_properties_.common_vertical_margin_attlist_.fo_margin_bottom_= odf_types::length(length_->get_value_unit(odf_types::length::cm),odf_types::length::cm);
if ((length_left && length_right ) && (*length_left == *length_right))
table_properties->table_format_properties_.table_align_ = odf_types::table_align(odf_types::table_align::Center);
......
......@@ -11,7 +11,7 @@ namespace Oox2Odf
{
public:
Converter(const std::wstring & path, std::wstring type, const std::wstring & fontsPath, const ProgressCallback* ffCallBack);
Converter(const std::wstring & path, const std::wstring & type, const std::wstring & fontsPath, const ProgressCallback* ffCallBack);
virtual ~Converter();
public:
......
......@@ -27,16 +27,17 @@ XlsxConverter::XlsxConverter(const std::wstring & path, const ProgressCallback*
{
const OOX::CPath oox_path(CString(path.c_str()));
pCallBack = CallBack;
xlsx_document = new OOX::Spreadsheet::CXlsx(oox_path);
xlsx_document = new OOX::Spreadsheet::CXlsx(oox_path);
output_document = new odf_writer::package::odf_document(L"spreadsheet");
ods_context = new odf_writer::ods_conversion_context(output_document);
xlsx_current_drawing = NULL;
pCallBack = CallBack;
xlsx_current_drawing = NULL;
if (UpdateProgress(400000))return;
}
void XlsxConverter::write(const std::wstring & path)
{
if (!output_document)return;
......@@ -100,12 +101,9 @@ CString XlsxConverter::find_link_by_id (CString sId, int type)
void XlsxConverter::convertDocument()
{
if (!xlsx_document)return;
if (!output_document)return;
ods_context = new odf_writer::ods_conversion_context(output_document);
if (!ods_context)return;
if (!xlsx_document) return;
if (!output_document) return;
if (!ods_context) return;
ods_context->start_document();
......
......@@ -268,7 +268,8 @@ namespace FileSystem {
{
struct stat sb;
if (stat(strFileName, &sb) == 0)
std::string sPathNameUtf8 = stringWstingToUtf8String (strFileName);
if (stat(sPathNameUtf8.c_str(), &sb) == 0)
{
if (S_ISDIR(sb.st_mode)) return true;
if (S_ISREG(sb.st_mode)) return true;
......
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