sc/source/filter/inc/orcusinterface.hxx | 14 ++- sc/source/filter/orcus/interface.cxx | 144 ++++++++++++++++++++++++++++---- 2 files changed, 142 insertions(+), 16 deletions(-)
New commits: commit 79368a7a1df6f637ad19e5becdca93569fd50d81 Author: Jaskaran Singh <[email protected]> Date: Thu Jul 28 15:41:02 2016 +0530 Add facility for cell alignment to orcus interface Change-Id: If073c34bc9898f2a069815892431a2db22f43d3a diff --git a/sc/source/filter/inc/orcusinterface.hxx b/sc/source/filter/inc/orcusinterface.hxx index bfa04ba..8359ca4 100644 --- a/sc/source/filter/inc/orcusinterface.hxx +++ b/sc/source/filter/inc/orcusinterface.hxx @@ -15,6 +15,7 @@ #include <tools/color.hxx> #include <tools/fontenum.hxx> +#include <editeng/svxenum.hxx> #include "sharedformulagroups.hxx" @@ -348,6 +349,10 @@ private: size_t mnProtectionId; size_t mnNumberFormatId; size_t mnStyleXf; + bool mbAlignment; + + SvxCellHorJustify meHor_alignment; + SvxCellVerJustify meVer_alignment; xf(); }; diff --git a/sc/source/filter/orcus/interface.cxx b/sc/source/filter/orcus/interface.cxx index 8bb9d26..18013dc 100644 --- a/sc/source/filter/orcus/interface.cxx +++ b/sc/source/filter/orcus/interface.cxx @@ -39,6 +39,7 @@ #include <editeng/fhgtitem.hxx> #include <editeng/lineitem.hxx> #include <editeng/crossedoutitem.hxx> +#include <editeng/justifyitem.hxx> #include <formula/token.hxx> #include <tools/datetime.hxx> @@ -930,7 +931,10 @@ ScOrcusStyles::xf::xf(): mnBorderId(0), mnProtectionId(0), mnNumberFormatId(0), - mnStyleXf(0) + mnStyleXf(0), + mbAlignment(false), + meHor_alignment(SVX_HOR_JUSTIFY_LEFT), + meVer_alignment(SVX_VER_JUSTIFY_CENTER) { } @@ -992,6 +996,12 @@ void ScOrcusStyles::applyXfToItemSet(SfxItemSet& rSet, const xf& rXf) const number_format& rFormat = maNumberFormats[nNumberFormatId]; if (rFormat.mbHasNumberFormatAttr) rFormat.applyToItemSet(rSet, mrDoc); + + if(rXf.mbAlignment) + { + rSet.Put(SvxHorJustifyItem(rXf.meHor_alignment, ATTR_HOR_JUSTIFY)); + rSet.Put(SvxVerJustifyItem(rXf.meVer_alignment, ATTR_VER_JUSTIFY)); + } } void ScOrcusStyles::applyXfToItemSet(SfxItemSet& rSet, size_t xfId) @@ -1464,12 +1474,48 @@ void ScOrcusStyles::set_xf_apply_alignment(bool /*b*/) { } -void ScOrcusStyles::set_xf_horizontal_alignment(orcus::spreadsheet::hor_alignment_t /*align*/) +void ScOrcusStyles::set_xf_horizontal_alignment(orcus::spreadsheet::hor_alignment_t align) { + switch (align) + { + case os::hor_alignment_t::left: + maCurrentXF.meHor_alignment = SVX_HOR_JUSTIFY_LEFT; + break; + case os::hor_alignment_t::right: + maCurrentXF.meHor_alignment = SVX_HOR_JUSTIFY_RIGHT; + break; + case os::hor_alignment_t::center: + maCurrentXF.meHor_alignment = SVX_HOR_JUSTIFY_CENTER; + break; + case os::hor_alignment_t::justified: + maCurrentXF.meHor_alignment = SVX_HOR_JUSTIFY_STANDARD; + break; + default: + ; + } + maCurrentXF.mbAlignment = true; } -void ScOrcusStyles::set_xf_vertical_alignment(orcus::spreadsheet::ver_alignment_t /*align*/) +void ScOrcusStyles::set_xf_vertical_alignment(orcus::spreadsheet::ver_alignment_t align) { + switch (align) + { + case os::ver_alignment_t::top: + maCurrentXF.meVer_alignment = SVX_VER_JUSTIFY_TOP; + break; + case os::ver_alignment_t::bottom: + maCurrentXF.meVer_alignment = SVX_VER_JUSTIFY_BOTTOM; + break; + case os::ver_alignment_t::middle: + maCurrentXF.meVer_alignment = SVX_VER_JUSTIFY_CENTER; + break; + case os::ver_alignment_t::justified: + maCurrentXF.meVer_alignment = SVX_VER_JUSTIFY_STANDARD; + break; + default: + ; + } + maCurrentXF.mbAlignment = true; } // cell style entry commit 26839ead5de142256d6172ebbf51f7d4392f6daa Author: Jaskaran Singh <[email protected]> Date: Thu Jul 28 15:40:22 2016 +0530 Reform orcus interface to set border width Change-Id: Ic93b334205221548e4bd7920551034b1ccee4fa8 diff --git a/sc/source/filter/inc/orcusinterface.hxx b/sc/source/filter/inc/orcusinterface.hxx index 5a34ed8..bfa04ba 100644 --- a/sc/source/filter/inc/orcusinterface.hxx +++ b/sc/source/filter/inc/orcusinterface.hxx @@ -417,7 +417,7 @@ public: orcus::spreadsheet::color_elem_t red, orcus::spreadsheet::color_elem_t green, orcus::spreadsheet::color_elem_t blue) override; - virtual void set_border_width(orcus::spreadsheet::border_direction_t dir, orcus::length_t width) override; + virtual void set_border_width(orcus::spreadsheet::border_direction_t dir, double val, orcus::length_unit_t unit) override; virtual size_t commit_border() override; // cell protection diff --git a/sc/source/filter/orcus/interface.cxx b/sc/source/filter/orcus/interface.cxx index 0bfa9c8..8bb9d26 100644 --- a/sc/source/filter/orcus/interface.cxx +++ b/sc/source/filter/orcus/interface.cxx @@ -1319,10 +1319,10 @@ void ScOrcusStyles::set_border_color(orcus::spreadsheet::border_direction_t dir, current_line.maColor = Color(alpha, red, green, blue); } -void ScOrcusStyles::set_border_width(orcus::spreadsheet::border_direction_t dir, orcus::length_t width ) +void ScOrcusStyles::set_border_width(orcus::spreadsheet::border_direction_t dir, double val, orcus::length_unit_t unit ) { border::border_line& current_line = maCurrentBorder.border_lines[dir]; - current_line.mnWidth = translateToInternal(width.value, width.unit); + current_line.mnWidth = translateToInternal(val, unit); } size_t ScOrcusStyles::commit_border() commit c1f241e85a03048055dc66cc0193a7edba895198 Author: Jaskaran Singh <[email protected]> Date: Thu Jul 28 14:00:46 2016 +0530 Add odf strikeout to orcus interface Change-Id: Ibf8d1e7b0272fe4112fda0249eafef1aa5438d9a diff --git a/sc/source/filter/inc/orcusinterface.hxx b/sc/source/filter/inc/orcusinterface.hxx index 7f469e4..5a34ed8 100644 --- a/sc/source/filter/inc/orcusinterface.hxx +++ b/sc/source/filter/inc/orcusinterface.hxx @@ -260,10 +260,13 @@ private: bool mbHasFontAttr; bool mbHasUnderlineAttr; + bool mbHasStrikeout; FontLineStyle meUnderline; Color maUnderlineColor; + FontStrikeout meStrikeout; + font(); void applyToItemSet(SfxItemSet& rSet) const; @@ -390,6 +393,10 @@ public: orcus::spreadsheet::color_elem_t red, orcus::spreadsheet::color_elem_t green, orcus::spreadsheet::color_elem_t blue) override; + virtual void set_strikethrough_style(orcus::spreadsheet::strikethrough_style_t s); + virtual void set_strikethrough_type(orcus::spreadsheet::strikethrough_type_t s); + virtual void set_strikethrough_width(orcus::spreadsheet::strikethrough_width_t s); + virtual void set_strikethrough_text(orcus::spreadsheet::strikethrough_text_t s); virtual size_t commit_font() override; // fill diff --git a/sc/source/filter/orcus/interface.cxx b/sc/source/filter/orcus/interface.cxx index d59b2fa..0bfa9c8 100644 --- a/sc/source/filter/orcus/interface.cxx +++ b/sc/source/filter/orcus/interface.cxx @@ -38,6 +38,7 @@ #include <editeng/fontitem.hxx> #include <editeng/fhgtitem.hxx> #include <editeng/lineitem.hxx> +#include <editeng/crossedoutitem.hxx> #include <formula/token.hxx> #include <tools/datetime.hxx> @@ -758,8 +759,10 @@ ScOrcusStyles::font::font(): maColor(COL_WHITE), mbHasFontAttr(false), mbHasUnderlineAttr(false), + mbHasStrikeout(false), meUnderline(LINESTYLE_NONE), - maUnderlineColor(COL_WHITE) + maUnderlineColor(COL_WHITE), + meStrikeout(STRIKEOUT_NONE) { } @@ -791,11 +794,18 @@ std::ostream& operator<<(std::ostream& rStrm, const Color& rColor) void ScOrcusStyles::font::applyToItemSet(SfxItemSet& rSet) const { - FontItalic eItalic = mbItalic ? ITALIC_NORMAL : ITALIC_NONE; - rSet.Put(SvxPostureItem(eItalic, ATTR_FONT_POSTURE)); + if (mbHasFontAttr) + { + FontItalic eItalic = mbItalic ? ITALIC_NORMAL : ITALIC_NONE; + rSet.Put(SvxPostureItem(eItalic, ATTR_FONT_POSTURE)); + + FontWeight eWeight = mbBold ? WEIGHT_BOLD : WEIGHT_NORMAL; + rSet.Put(SvxWeightItem(eWeight, ATTR_FONT_WEIGHT)); - FontWeight eWeight = mbBold ? WEIGHT_BOLD : WEIGHT_NORMAL; - rSet.Put(SvxWeightItem(eWeight, ATTR_FONT_WEIGHT)); + rSet.Put( SvxColorItem(maColor, ATTR_FONT_COLOR)); + rSet.Put( SvxFontItem( FAMILY_DONTKNOW, maName, maName, PITCH_DONTKNOW, RTL_TEXTENCODING_DONTKNOW, ATTR_FONT )); + rSet.Put( SvxFontHeightItem (translateToInternal(mnSize, orcus::length_unit_t::point), 100, ATTR_FONT_HEIGHT)); + } if (mbHasUnderlineAttr) { @@ -804,9 +814,8 @@ void ScOrcusStyles::font::applyToItemSet(SfxItemSet& rSet) const rSet.Put(aUnderline); } - rSet.Put( SvxColorItem(maColor, ATTR_FONT_COLOR)); - rSet.Put( SvxFontItem( FAMILY_DONTKNOW, maName, maName, PITCH_DONTKNOW, RTL_TEXTENCODING_DONTKNOW, ATTR_FONT )); - rSet.Put( SvxFontHeightItem (translateToInternal(mnSize, orcus::length_unit_t::point), 100, ATTR_FONT_HEIGHT)); + if (mbHasStrikeout) + rSet.Put(SvxCrossedOutItem(meStrikeout, ATTR_FONT_CROSSEDOUT)); } void ScOrcusStyles::fill::applyToItemSet(SfxItemSet& rSet) const @@ -941,8 +950,7 @@ void ScOrcusStyles::applyXfToItemSet(SfxItemSet& rSet, const xf& rXf) } const font& rFont = maFonts[nFontId]; - if (rFont.mbHasFontAttr) - rFont.applyToItemSet(rSet); + rFont.applyToItemSet(rSet); size_t nFillId = rXf.mnFillId; if (nFillId >= maFills.size()) @@ -1142,6 +1150,66 @@ void ScOrcusStyles::set_font_color(orcus::spreadsheet::color_elem_t alpha, maCurrentFont.maColor = Color(alpha, red, green, blue); } +void ScOrcusStyles::set_strikethrough_style(orcus::spreadsheet::strikethrough_style_t /*s*/) +{ +} + +void ScOrcusStyles::set_strikethrough_type(orcus::spreadsheet::strikethrough_type_t s) +{ + if (maCurrentFont.meStrikeout != STRIKEOUT_BOLD && + maCurrentFont.meStrikeout != STRIKEOUT_SLASH && + maCurrentFont.meStrikeout != STRIKEOUT_X) + { + switch (s) + { + case os::strikethrough_type_t::unknown: + maCurrentFont.meStrikeout = STRIKEOUT_DONTKNOW; + break; + case os::strikethrough_type_t::none: + maCurrentFont.meStrikeout = STRIKEOUT_NONE; + break; + case os::strikethrough_type_t::single: + maCurrentFont.meStrikeout = STRIKEOUT_SINGLE; + break; + case os::strikethrough_type_t::double_type: + maCurrentFont.meStrikeout = STRIKEOUT_DOUBLE; + break; + default: + ; + } + } + maCurrentFont.mbHasStrikeout = true; +} + +void ScOrcusStyles::set_strikethrough_width(orcus::spreadsheet::strikethrough_width_t s) +{ + switch (s) + { + case os::strikethrough_width_t::bold: + maCurrentFont.meStrikeout = STRIKEOUT_BOLD; + break; + default: + ; + } + maCurrentFont.mbHasStrikeout = true; +} + +void ScOrcusStyles::set_strikethrough_text(orcus::spreadsheet::strikethrough_text_t s) +{ + switch (s) + { + case os::strikethrough_text_t::slash: + maCurrentFont.meStrikeout = STRIKEOUT_SLASH; + break; + case os::strikethrough_text_t::cross: + maCurrentFont.meStrikeout = STRIKEOUT_X; + break; + default: + ; + } + maCurrentFont.mbHasStrikeout = true; +} + size_t ScOrcusStyles::commit_font() { SAL_INFO("sc.orcus.style", "commit font"); _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
