sc/source/filter/inc/orcusinterface.hxx | 13 +++ sc/source/filter/orcus/interface.cxx | 105 +++++++++++++++++++++++++++----- 2 files changed, 104 insertions(+), 14 deletions(-)
New commits: commit c76a1ece89ce22d245367ccd79b6c6e7bc2f522b Author: Markus Mohrhard <markus.mohrh...@googlemail.com> Date: Mon Aug 31 23:43:37 2015 +0200 orcus: don't leak old state into new style objects Change-Id: I744ff8be96bda2fff61c8fc23a067fdd9b2d4930 diff --git a/sc/source/filter/orcus/interface.cxx b/sc/source/filter/orcus/interface.cxx index d3edc4c..ee04869 100644 --- a/sc/source/filter/orcus/interface.cxx +++ b/sc/source/filter/orcus/interface.cxx @@ -974,6 +974,7 @@ size_t ScOrcusStyles::commit_font() { SAL_INFO("sc.orcus.style", "commit font"); maFonts.push_back(maCurrentFont); + maCurrentFont = ScOrcusStyles::font(); return maFonts.size() - 1; } @@ -1003,6 +1004,7 @@ size_t ScOrcusStyles::commit_fill() { SAL_INFO("sc.orcus.style", "commit fill"); maFills.push_back(maCurrentFill); + maCurrentFill = ScOrcusStyles::fill(); return maFills.size() - 1; } @@ -1051,6 +1053,7 @@ size_t ScOrcusStyles::commit_cell_protection() { SAL_INFO("sc.orcus.style", "commit cell protection"); maProtections.push_back(maCurrentProtection); + maCurrentProtection = ScOrcusStyles::protection(); return maProtections.size() - 1; } @@ -1072,6 +1075,7 @@ size_t ScOrcusStyles::commit_number_format() { SAL_INFO("sc.orcus.style", "commit number format"); maNumberFormats.push_back(maCurrentNumberFormat); + maCurrentNumberFormat = ScOrcusStyles::number_format(); return maNumberFormats.size() - 1; } commit 897b51239443430790babd507d63fd5d6fb4a727 Author: Markus Mohrhard <markus.mohrh...@googlemail.com> Date: Mon Aug 31 23:43:15 2015 +0200 import borders from orcus Change-Id: Ieab07fcd9bc89d81829d636bb854db37ad2ba9e0 diff --git a/sc/source/filter/inc/orcusinterface.hxx b/sc/source/filter/inc/orcusinterface.hxx index 5a08c80..d8a8056 100644 --- a/sc/source/filter/inc/orcusinterface.hxx +++ b/sc/source/filter/inc/orcusinterface.hxx @@ -285,6 +285,12 @@ private: struct border { + struct border_line + { + Color maColor; + }; + std::map<orcus::spreadsheet::border_direction_t, border_line> border_lines; + border(); void applyToItemSet(SfxItemSet& rSet) const; diff --git a/sc/source/filter/orcus/interface.cxx b/sc/source/filter/orcus/interface.cxx index 3609139..d3edc4c 100644 --- a/sc/source/filter/orcus/interface.cxx +++ b/sc/source/filter/orcus/interface.cxx @@ -28,6 +28,8 @@ #include <editeng/colritem.hxx> #include <editeng/brushitem.hxx> #include <editeng/udlnitem.hxx> +#include <editeng/boxitem.hxx> +#include <editeng/borderline.hxx> #include <formula/token.hxx> #include <tools/datetime.hxx> @@ -791,9 +793,44 @@ ScOrcusStyles::border::border() { } -void ScOrcusStyles::border::applyToItemSet(SfxItemSet& /*rSet*/) const +namespace { + +SvxBoxItemLine getDirection(os::border_direction_t dir) { - (void)this; // loplugin:staticmethods + switch (dir) + { + case os::border_right: + return SvxBoxItemLine::RIGHT; + break; + case os::border_left: + return SvxBoxItemLine::RIGHT; + break; + case os::border_top: + return SvxBoxItemLine::RIGHT; + break; + case os::border_bottom: + return SvxBoxItemLine::RIGHT; + break; + default: + break; + } + return SvxBoxItemLine::RIGHT; +} + +} + +void ScOrcusStyles::border::applyToItemSet(SfxItemSet& rSet) const +{ + SvxBoxItem aItem(ATTR_BORDER); + + for (auto& current_border_line : border_lines) + { + SvxBoxItemLine eDir = getDirection(current_border_line.first); + editeng::SvxBorderLine aLine(¤t_border_line.second.maColor, 1); + aItem.SetLine(&aLine, eDir); + } + + rSet.Put(aItem); } void ScOrcusStyles::number_format::applyToItemSet(SfxItemSet& /*rSet*/) const @@ -981,19 +1018,22 @@ void ScOrcusStyles::set_border_style(orcus::spreadsheet::border_direction_t /*di // implement later } -void ScOrcusStyles::set_border_color(orcus::spreadsheet::border_direction_t /*dir*/, - orcus::spreadsheet::color_elem_t, - orcus::spreadsheet::color_elem_t, - orcus::spreadsheet::color_elem_t, - orcus::spreadsheet::color_elem_t) +void ScOrcusStyles::set_border_color(orcus::spreadsheet::border_direction_t dir, + orcus::spreadsheet::color_elem_t alpha, + orcus::spreadsheet::color_elem_t red, + orcus::spreadsheet::color_elem_t green, + orcus::spreadsheet::color_elem_t blue) { - // implement later + border::border_line& current_line = maCurrentBorder.border_lines[dir]; + current_line.maColor = Color(alpha, red, green, blue); } size_t ScOrcusStyles::commit_border() { SAL_INFO("sc.orcus.style", "commit border"); - return 0; + maBorders.push_back(maCurrentBorder); + maCurrentBorder = ScOrcusStyles::border(); + return maBorders.size() - 1; } // cell protection commit d4ac7380e5675e165950c40edb45e6d17ac25b33 Author: Markus Mohrhard <markus.mohrh...@googlemail.com> Date: Mon Aug 31 02:06:21 2015 +0200 some work on orcus conditional format import Change-Id: I9ad88c0f7f935a247f0f21c7aa206312435ecafc diff --git a/sc/source/filter/inc/orcusinterface.hxx b/sc/source/filter/inc/orcusinterface.hxx index a61a282..5a08c80 100644 --- a/sc/source/filter/inc/orcusinterface.hxx +++ b/sc/source/filter/inc/orcusinterface.hxx @@ -18,6 +18,8 @@ #include "sharedformulagroups.hxx" +#include "conditio.hxx" + #include <rtl/strbuf.hxx> #define __ORCUS_STATIC_LIB @@ -135,6 +137,11 @@ private: SCTAB mnTab; ScDocument& mrDoc; + + std::unique_ptr<ScConditionalFormat> mpCurrentFormat; + std::unique_ptr<ScFormatEntry> mpCurrentEntry; + + condformat::ScFormatEntryType meEntryType; }; class ScOrcusAutoFilter : public orcus::spreadsheet::iface::import_auto_filter diff --git a/sc/source/filter/orcus/interface.cxx b/sc/source/filter/orcus/interface.cxx index c1551f9..3609139 100644 --- a/sc/source/filter/orcus/interface.cxx +++ b/sc/source/filter/orcus/interface.cxx @@ -283,10 +283,11 @@ void ScOrcusSheetProperties::set_merge_cell_range(const char* /*p_range*/, size_ ScOrcusConditionalFormat::ScOrcusConditionalFormat(SCTAB nTab, ScDocument& rDoc): mnTab(nTab), - mrDoc(rDoc) + mrDoc(rDoc), + mpCurrentFormat(new ScConditionalFormat(0, &mrDoc)), + meEntryType(condformat::CONDITION) { (void)mnTab; - (void)mrDoc; } ScOrcusConditionalFormat::~ScOrcusConditionalFormat() @@ -301,6 +302,7 @@ void ScOrcusConditionalFormat::set_color(os::color_elem_t /*alpha*/, os::color_e void ScOrcusConditionalFormat::set_condition_type(os::condition_type_t /*type*/) { + assert(meEntryType == condformat::CONDITION); SAL_INFO("sc.orcus.condformat", "set_condition_type"); } @@ -311,6 +313,7 @@ void ScOrcusConditionalFormat::set_formula(const char* /*p*/, size_t /*n*/) void ScOrcusConditionalFormat::set_date(os::condition_date_t /*date*/) { + assert(meEntryType == condformat::DATE); SAL_INFO("sc.orcus.condformat", "set_date"); } @@ -321,38 +324,45 @@ void ScOrcusConditionalFormat::commit_condition() void ScOrcusConditionalFormat::set_icon_name(const char* /*p*/, size_t /*n*/) { + assert(meEntryType == condformat::ICONSET); SAL_INFO("sc.orcus.condformat", "set_icon_name"); } void ScOrcusConditionalFormat::set_databar_gradient(bool /*gradient*/) { + assert(meEntryType == condformat::DATABAR); SAL_INFO("sc.orcus.condformat", "set_databar_gradient"); } void ScOrcusConditionalFormat::set_databar_axis(os::databar_axis_t /*axis*/) { + assert(meEntryType == condformat::DATABAR); SAL_INFO("sc.orcus.condformat", "set_databar_axis"); } void ScOrcusConditionalFormat::set_databar_color_positive(os::color_elem_t /*alpha*/, os::color_elem_t /*red*/, os::color_elem_t /*green*/, os::color_elem_t /*blue*/) { + assert(meEntryType == condformat::DATABAR); SAL_INFO("sc.orcus.condformat", "set_databar_color_positive"); } void ScOrcusConditionalFormat::set_databar_color_negative(os::color_elem_t /*alpha*/, os::color_elem_t /*red*/, os::color_elem_t /*green*/, os::color_elem_t /*blue*/) { + assert(meEntryType == condformat::DATABAR); SAL_INFO("sc.orcus.condformat", "set_databar_color_negative"); } void ScOrcusConditionalFormat::set_min_databar_length(double /*length*/) { + assert(meEntryType == condformat::DATABAR); SAL_INFO("sc.orcus.condformat", "set_min_databar_length"); } void ScOrcusConditionalFormat::set_max_databar_length(double /*length*/) { + assert(meEntryType == condformat::DATABAR); SAL_INFO("sc.orcus.condformat", "set_max_databar_length"); } @@ -363,6 +373,7 @@ void ScOrcusConditionalFormat::set_show_value(bool /*show*/) void ScOrcusConditionalFormat::set_iconset_reverse(bool /*reverse*/) { + assert(meEntryType == condformat::ICONSET); SAL_INFO("sc.orcus.condformat", "set_iconset_reverse"); } @@ -376,8 +387,27 @@ void ScOrcusConditionalFormat::set_operator(os::condition_operator_t /*condition SAL_INFO("sc.orcus.condformat", "set_operator"); } -void ScOrcusConditionalFormat::set_type(os::conditional_format_t /*type*/) +void ScOrcusConditionalFormat::set_type(os::conditional_format_t type) { + switch (type) + { + case os::conditional_format_condition: + case os::conditional_format_formula: + meEntryType = condformat::CONDITION; + // mpCurrentEntry.reset(new ScCondFormatEntry()); + break; + case os::conditional_format_date: + break; + case os::conditional_format_colorscale: + break; + case os::conditional_format_databar: + break; + case os::conditional_format_iconset: + break; + default: + SAL_INFO("sc.orcus.condformat", "unknown conditional_format_t value"); + break; + } SAL_INFO("sc.orcus.condformat", "set_type"); } @@ -391,15 +421,18 @@ void ScOrcusConditionalFormat::set_range(const char* /*p*/, size_t /*n*/) SAL_INFO("sc.orcus.condformat", "set_range"); } -void ScOrcusConditionalFormat::set_range(os::row_t /*row_start*/, os::col_t /*col_start*/, - os::row_t /*row_end*/, os::col_t /*col_end*/) +void ScOrcusConditionalFormat::set_range(os::row_t row_start, os::col_t col_start, + os::row_t row_end, os::col_t col_end) { SAL_INFO("sc.orcus.condformat", "set_range"); + ScRange aRange(col_start, row_start, mnTab, col_end, row_end, mnTab); + mpCurrentFormat->SetRange(aRange); } void ScOrcusConditionalFormat::commit_format() { SAL_INFO("sc.orcus.condformat", "commit_format"); + mpCurrentFormat.reset(new ScConditionalFormat(0, &mrDoc)); } ScOrcusSheet::ScOrcusSheet(ScDocumentImport& rDoc, SCTAB nTab, ScOrcusFactory& rFactory) : _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits