Commit 32d3c0e6 authored by ElenaSubbotina's avatar ElenaSubbotina

.

parent 33aeef2c
......@@ -200,7 +200,11 @@ double pt_to_cm(double Val)
return Val / 28.34467120181406;
}
double pt_to_mm(double Val)
{
return Val / 2.834467120181406;
}
double to_pt(const length & Val)
{
switch(Val.get_unit())
......@@ -247,7 +251,11 @@ double length::get_value_unit(unit Unit) const
{
return pt_to_cm( to_pt(*this) );
}
else
else if (Unit == mm)
{
return pt_to_mm( to_pt(*this) );
}
else
{
return 0.0;
}
......
......@@ -900,11 +900,11 @@ void style_page_layout_properties_attlist::add_attributes( const xml::attributes
{
CP_APPLY_ATTR(L"fo:page-width", fo_page_width_);
CP_APPLY_ATTR(L"fo:page-height", fo_page_height_);
common_num_format_attlist_.add_attributes(Attributes);
common_num_format_prefix_suffix_attlist_.add_attributes(Attributes);
CP_APPLY_ATTR(L"style:paper-tray-name", style_paper_tray_name_);
CP_APPLY_ATTR(L"style:print-orientation", style_print_orientation_);
common_num_format_attlist_.add_attributes(Attributes);
common_num_format_prefix_suffix_attlist_.add_attributes(Attributes);
common_horizontal_margin_attlist_.add_attributes(Attributes);
common_vertical_margin_attlist_.add_attributes(Attributes);
common_margin_attlist_.add_attributes(Attributes);
......@@ -1160,7 +1160,7 @@ void style_page_layout_properties_attlist::pptx_convert(oox::pptx_conversion_con
h = fo_page_height_->get_value_unit(length::emu);
if (h < 914400) h = 914400;
w_h = boost::lexical_cast<std::wstring>(h);
w_h = std::to_wstring(h);
}
std::wstring w_orient = L"custom";
......@@ -1260,6 +1260,55 @@ void style_page_layout_properties::xlsx_serialize(std::wostream & strm, oox::xls
{
CP_XML_WRITER(strm)
{
odf_types::common_horizontal_margin_attlist horizontal_margins = attlist_.common_horizontal_margin_attlist_;
odf_types::common_vertical_margin_attlist vertical_margins = attlist_.common_vertical_margin_attlist_;
if (horizontal_margins.fo_margin_left_ || horizontal_margins.fo_margin_right_ ||
vertical_margins.fo_margin_top_ || vertical_margins.fo_margin_bottom_ )
{
//_CP_OPT(odf_types::length) margin_top, margin_bottom;
//margin_top = Context.get_header_footer_context().header();
//margin_bottom = Context.get_header_footer_context().footer();
CP_XML_NODE(L"pageMargins")
{
if (horizontal_margins.fo_margin_left_ && horizontal_margins.fo_margin_left_->get_type() == odf_types::length_or_percent::Length)
CP_XML_ATTR(L"left" , horizontal_margins.fo_margin_left_->get_length().get_value_unit(odf_types::length::inch));
if (horizontal_margins.fo_margin_right_ && horizontal_margins.fo_margin_right_->get_type() == odf_types::length_or_percent::Length)
CP_XML_ATTR(L"right" , horizontal_margins.fo_margin_right_->get_length().get_value_unit(odf_types::length::inch));
if (vertical_margins.fo_margin_top_ && vertical_margins.fo_margin_top_->get_type() == odf_types::length_or_percent::Length)
CP_XML_ATTR(L"top" , vertical_margins.fo_margin_top_->get_length().get_value_unit(odf_types::length::inch));
if (vertical_margins.fo_margin_bottom_ && vertical_margins.fo_margin_bottom_->get_type() == odf_types::length_or_percent::Length)
CP_XML_ATTR(L"bottom" , vertical_margins.fo_margin_bottom_->get_length().get_value_unit(odf_types::length::inch));
CP_XML_ATTR(L"header" , vertical_margins.fo_margin_top_->get_length().get_value_unit(odf_types::length::inch));
CP_XML_ATTR(L"footer" , vertical_margins.fo_margin_bottom_->get_length().get_value_unit(odf_types::length::inch));
}
}
if (attlist_.fo_page_width_ || attlist_.fo_page_height_ || attlist_.style_print_orientation_)
{
CP_XML_NODE(L"pageSetup")
{
double h = 0, w = 0;
if (attlist_.fo_page_width_)
{
w = attlist_.fo_page_width_->get_value_unit(length::mm);
CP_XML_ATTR(L"paperWidth", (int)w);
}
if (attlist_.fo_page_height_)
{
h = attlist_.fo_page_height_->get_value_unit(length::mm);
CP_XML_ATTR(L"paperHeight", (int)h);
}
CP_XML_ATTR(L"paperUnits", L"mm");
if (attlist_.style_print_orientation_)
{
CP_XML_ATTR(L"orientation", *attlist_.style_print_orientation_);
}
}
}
if (elements_.style_background_image_)
{
oox::_oox_fill fill;
......
......@@ -1063,14 +1063,62 @@ void XlsxConverter::convert(OOX::Spreadsheet::CPageSetup *oox_page)
type = (int)oox_page->m_oOrientation->GetValue();
}
ods_context->page_layout_context()->set_page_orientation(type);
_CP_OPT(odf_types::length) width, height;
if (oox_page->m_oPaperWidth.IsInit() && oox_page->m_oPaperHeight.IsInit())
{
double w = oox_page->m_oPaperWidth->GetValue();
double h = oox_page->m_oPaperHeight->GetValue();
int unit = oox_page->m_oPaperUnits.IsInit() ? oox_page->m_oPaperUnits->GetValue() : 0;
switch(unit)
{
case 1:
width = odf_types::length(w, odf_types::length::cm);
height = odf_types::length(h, odf_types::length::cm);
case 2:
width = odf_types::length(w, odf_types::length::inch);
height = odf_types::length(h, odf_types::length::inch);
case 3:
width = odf_types::length(w, odf_types::length::pt);
height = odf_types::length(h, odf_types::length::pt);
case 4:
width = odf_types::length(w, odf_types::length::px);
height = odf_types::length(h, odf_types::length::px);
case 0:
default:
width = odf_types::length(w, odf_types::length::mm);
height = odf_types::length(h, odf_types::length::mm);
}
}
else if (oox_page->m_oPaperSize.IsInit())
{
switch(oox_page->m_oPaperSize->GetValue())
{
case SimpleTypes::Spreadsheet::pagesizeLetterPaper:
width = odf_types::length(8.5, odf_types::length::inch);
height = odf_types::length(11, odf_types::length::inch);
break;
case SimpleTypes::Spreadsheet::pagesizeA3Paper:
width = odf_types::length(210, odf_types::length::mm);
height = odf_types::length(297, odf_types::length::mm);
break;
case SimpleTypes::Spreadsheet::pagesizeA4Paper:
width = odf_types::length(297, odf_types::length::mm);
height = odf_types::length(420, odf_types::length::mm);
break;
//todooo
}
}
ods_context->page_layout_context()->set_page_size(width, height);
}
void XlsxConverter::convert(OOX::Spreadsheet::CPageMargins *oox_page)
void XlsxConverter::convert(OOX::Spreadsheet::CPageMargins *oox_page)
{
if (!oox_page) return;
_CP_OPT(double) top, left,right,header,footer,bottom;
ods_context->page_layout_context()->set_page_margin(top,left,bottom, right,header,footer);
ods_context->page_layout_context()->set_page_margin(top, left, bottom, right, header, footer);
}
void XlsxConverter::convert(OOX::Spreadsheet::CSheetFormatPr *oox_sheet_format_pr)
......
......@@ -1681,27 +1681,73 @@ namespace SimpleTypes
return this->m_eValue;
}
virtual std::wstring ToString () const
virtual std::wstring ToString () const
{
return std::to_wstring(this->m_eValue );
}
SimpleType_FromString (EPageSize)
SimpleType_Operator_Equal (CPageSize)
SimpleType_Operator_Equal (CPageSize)
};
enum EPageUnits
{
mm = 0,
cm = 1,
inch = 2,
pt = 3,
px = 4,
emu = 5
};
template<EPageUnits eDefValue = mm>
class CPageUnits : public CSimpleType<EPageUnits, eDefValue>
{
public:
CPageUnits() {}
virtual EPageUnits FromString(std::wstring &sValue)
{
if (sValue == L"in") this->m_eValue = inch;
else if (sValue == L"mm") this->m_eValue = mm;
else if (sValue == L"cm") this->m_eValue = cm;
else if (sValue == L"pt") this->m_eValue = pt;
else if (sValue == L"px") this->m_eValue = px;
return this->m_eValue;
}
virtual std::wstring ToString () const
{
std::wstring sResult;
switch(this->m_eValue)
{
case mm: sResult = L"mm";break;
case cm: sResult = L"cm";break;
case pt: sResult = L"pt";break;
case px: sResult = L"px";break;
case inch: sResult = L"in";break;
}
return sResult;
}
SimpleType_FromString (EPageUnits)
SimpleType_Operator_Equal (CPageUnits)
};
enum ETotalsRowFunction
{
totalrowfunctionAverage = 1,
totalrowfunctionCount = 2,
totalrowfunctionCountNums = 3,
totalrowfunctionCustom = 4,
totalrowfunctionMax = 5,
totalrowfunctionMin = 6,
totalrowfunctionNone = 7,
totalrowfunctionStdDev = 8,
totalrowfunctionSum = 9,
totalrowfunctionVar = 10
totalrowfunctionAverage = 1,
totalrowfunctionCount = 2,
totalrowfunctionCountNums = 3,
totalrowfunctionCustom = 4,
totalrowfunctionMax = 5,
totalrowfunctionMin = 6,
totalrowfunctionNone = 7,
totalrowfunctionStdDev = 8,
totalrowfunctionSum = 9,
totalrowfunctionVar = 10
};
template<ETotalsRowFunction eDefValue = totalrowfunctionNone>
class CTotalsRowFunction : public CSimpleType<ETotalsRowFunction, eDefValue>
{
......
......@@ -159,12 +159,18 @@ namespace OOX
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("orientation"), m_oOrientation)
WritingElement_ReadAttributes_Read_if ( oReader, _T("paperSize"), m_oPaperSize)
WritingElement_ReadAttributes_Read_if ( oReader, _T("paperUnits"), m_oPaperUnits)
WritingElement_ReadAttributes_Read_if ( oReader, _T("paperWidth"), m_oPaperWidth)
WritingElement_ReadAttributes_Read_if ( oReader, _T("paperHeight"), m_oPaperHeight)
WritingElement_ReadAttributes_Read_if ( oReader, _T("r:id"), m_oRId)
WritingElement_ReadAttributes_End( oReader )
}
nullable<SimpleTypes::CRelationshipId> m_oRId;
nullable<SimpleTypes::CPageOrientation<>> m_oOrientation;
nullable<SimpleTypes::Spreadsheet::CPageSize<>> m_oPaperSize;
nullable<SimpleTypes::CRelationshipId> m_oRId;
nullable<SimpleTypes::CPageOrientation<>> m_oOrientation;
nullable<SimpleTypes::Spreadsheet::CPageSize<>> m_oPaperSize;
nullable<SimpleTypes::Spreadsheet::CPageUnits<>> m_oPaperUnits;
nullable<SimpleTypes::CDouble> m_oPaperWidth;
nullable<SimpleTypes::CDouble> m_oPaperHeight;
};
class CPrintOptions : public WritingElement
{
......
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