[Libreoffice-commits] core.git: external/liborcus sc/source

Kohei Yoshida kohei.yoshida at gmail.com
Fri Feb 2 02:41:40 UTC 2018


 external/liborcus/0001-Alpha-value-of-0-means-fully-transparent.-I-m-sure-2.patch |   50 ++++++++++
 external/liborcus/0002-We-are-supposed-to-use-the-foreground-color-for-soli.patch |   49 +++++++++
 external/liborcus/UnpackedTarball_liborcus.mk                                     |    2 
 sc/source/filter/orcus/interface.cxx                                              |   15 ++-
 4 files changed, 111 insertions(+), 5 deletions(-)

New commits:
commit 20945a9a4de6684010fd5b3603595e6da543807d
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Wed Jan 31 21:27:44 2018 -0500

    Correctly import solid fill color.
    
    In orcus, a solid fill type uses the foreground color only and ignores
    the background color.  Also, let's not use the alpha component as it
    would cause the color to not get rendered at all.
    
    Some patches are applied against liborcus in order to adjust the ODF
    styles import code for this change.  These changes will be incorporated
    in 0.13.3.
    
    Change-Id: I9e8c243cc6a7f366de2393e7b7ecf77366f5f9ea
    Reviewed-on: https://gerrit.libreoffice.org/49071
    Reviewed-by: Kohei Yoshida <libreoffice at kohei.us>
    Tested-by: Kohei Yoshida <libreoffice at kohei.us>

diff --git a/external/liborcus/0001-Alpha-value-of-0-means-fully-transparent.-I-m-sure-2.patch b/external/liborcus/0001-Alpha-value-of-0-means-fully-transparent.-I-m-sure-2.patch
new file mode 100644
index 000000000000..6adae9ba2352
--- /dev/null
+++ b/external/liborcus/0001-Alpha-value-of-0-means-fully-transparent.-I-m-sure-2.patch
@@ -0,0 +1,50 @@
+From 98d2b3377da71b713a37f9004acff3c02c22ce2b Mon Sep 17 00:00:00 2001
+From: Kohei Yoshida <kohei.yoshida at gmail.com>
+Date: Wed, 31 Jan 2018 22:11:25 -0500
+Subject: [PATCH 1/2] Alpha value of 0 means fully transparent. I'm sure 255
+ was intended.
+
+(cherry picked from commit f7953a814d6a43205791b6cc01c528ef5d4b1ce3)
+---
+ src/liborcus/gnumeric_sheet_context.cpp | 4 ++--
+ src/liborcus/odf_styles_context.cpp     | 2 +-
+ 2 files changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/src/liborcus/gnumeric_sheet_context.cpp b/src/liborcus/gnumeric_sheet_context.cpp
+index 8659cc3..6bd1471 100644
+--- a/src/liborcus/gnumeric_sheet_context.cpp
++++ b/src/liborcus/gnumeric_sheet_context.cpp
+@@ -132,7 +132,7 @@ public:
+             {
+                 spreadsheet::color_elem_t red, green, blue;
+                 gnumeric_helper::parse_RGB_color_attribute(red, green, blue, attr.value);
+-                m_styles.set_fill_fg_color(0, red, green, blue);
++                m_styles.set_fill_fg_color(255, red, green, blue);
+ 
+                 m_fill = true;
+ 
+@@ -145,7 +145,7 @@ public:
+             {
+                 spreadsheet::color_elem_t red, green, blue;
+                 gnumeric_helper::parse_RGB_color_attribute(red, green, blue, attr.value);
+-                m_styles.set_fill_bg_color(0, red, green, blue);
++                m_styles.set_fill_bg_color(255, red, green, blue);
+ 
+                 m_fill = true;
+             }
+diff --git a/src/liborcus/odf_styles_context.cpp b/src/liborcus/odf_styles_context.cpp
+index d988f7d..f9c422a 100644
+--- a/src/liborcus/odf_styles_context.cpp
++++ b/src/liborcus/odf_styles_context.cpp
+@@ -739,7 +739,7 @@ void styles_context::start_element(xmlns_id_t ns, xml_token_t name, const std::v
+                     {
+                         spreadsheet::color_elem_t red, green, blue;
+                         func.get_background_color(red, green, blue);
+-                        mp_styles->set_fill_bg_color(0, red, green, blue);
++                        mp_styles->set_fill_bg_color(255, red, green, blue);
+                     }
+ 
+                     size_t fill_id = mp_styles->commit_fill();
+-- 
+2.7.4
+
diff --git a/external/liborcus/0002-We-are-supposed-to-use-the-foreground-color-for-soli.patch b/external/liborcus/0002-We-are-supposed-to-use-the-foreground-color-for-soli.patch
new file mode 100644
index 000000000000..ebb233ac7b8d
--- /dev/null
+++ b/external/liborcus/0002-We-are-supposed-to-use-the-foreground-color-for-soli.patch
@@ -0,0 +1,49 @@
+From 473526e1ca3a7117e2daf977e1b82a0a3977fc84 Mon Sep 17 00:00:00 2001
+From: Kohei Yoshida <kohei.yoshida at gmail.com>
+Date: Wed, 31 Jan 2018 22:24:45 -0500
+Subject: [PATCH 2/2] We are supposed to use the foreground color for solid
+ fill.
+
+(cherry picked from commit f821995022df8dd1e580dd22cf131584b2b1ac4f)
+---
+ src/liborcus/odf_styles_context.cpp      | 3 ++-
+ src/liborcus/odf_styles_context_test.cpp | 9 +++++----
+ 2 files changed, 7 insertions(+), 5 deletions(-)
+
+diff --git a/src/liborcus/odf_styles_context.cpp b/src/liborcus/odf_styles_context.cpp
+index f9c422a..e5f1cc6 100644
+--- a/src/liborcus/odf_styles_context.cpp
++++ b/src/liborcus/odf_styles_context.cpp
+@@ -739,7 +739,8 @@ void styles_context::start_element(xmlns_id_t ns, xml_token_t name, const std::v
+                     {
+                         spreadsheet::color_elem_t red, green, blue;
+                         func.get_background_color(red, green, blue);
+-                        mp_styles->set_fill_bg_color(255, red, green, blue);
++                        mp_styles->set_fill_pattern_type(ORCUS_ASCII("solid"));
++                        mp_styles->set_fill_fg_color(255, red, green, blue);
+                     }
+ 
+                     size_t fill_id = mp_styles->commit_fill();
+diff --git a/src/liborcus/odf_styles_context_test.cpp b/src/liborcus/odf_styles_context_test.cpp
+index 4c7eab5..7255a54 100644
+--- a/src/liborcus/odf_styles_context_test.cpp
++++ b/src/liborcus/odf_styles_context_test.cpp
+@@ -48,10 +48,11 @@ void test_odf_fill(orcus::spreadsheet::import_styles &styles)
+     std::cerr << std::hex << (int)fill;
+     const orcus::spreadsheet::fill_t* cell_fill = styles.get_fill(fill);
+     assert(cell_fill);
+-    std::cerr << std::hex << (int)cell_fill->bg_color.red;
+-    assert(cell_fill->bg_color.red == 0xfe);
+-    assert(cell_fill->bg_color.green == 0xff);
+-    assert(cell_fill->bg_color.blue == 0xcc);
++    std::cerr << std::hex << (int)cell_fill->fg_color.red;
++    assert(cell_fill->fg_color.red == 0xfe);
++    assert(cell_fill->fg_color.green == 0xff);
++    assert(cell_fill->fg_color.blue == 0xcc);
++    assert(cell_fill->pattern_type == "solid");
+ }
+ 
+ void test_odf_border(orcus::spreadsheet::import_styles &styles)
+-- 
+2.7.4
+
diff --git a/external/liborcus/UnpackedTarball_liborcus.mk b/external/liborcus/UnpackedTarball_liborcus.mk
index 3ab387e734be..3b49e0a58f63 100644
--- a/external/liborcus/UnpackedTarball_liborcus.mk
+++ b/external/liborcus/UnpackedTarball_liborcus.mk
@@ -18,6 +18,8 @@ $(eval $(call gb_UnpackedTarball_update_autoconf_configs,liborcus))
 $(eval $(call gb_UnpackedTarball_add_patches,liborcus,\
 	external/liborcus/0001-workaround-a-linking-problem-on-windows.patch \
 	external/liborcus/rpath.patch.0 \
+	external/liborcus/0001-Alpha-value-of-0-means-fully-transparent.-I-m-sure-2.patch \
+	external/liborcus/0002-We-are-supposed-to-use-the-foreground-color-for-soli.patch \
 ))
 
 ifeq ($(OS),WNT)
diff --git a/sc/source/filter/orcus/interface.cxx b/sc/source/filter/orcus/interface.cxx
index e40a71b446cb..4cfd8447e2d5 100644
--- a/sc/source/filter/orcus/interface.cxx
+++ b/sc/source/filter/orcus/interface.cxx
@@ -1148,7 +1148,8 @@ void ScOrcusStyles::fill::applyToItemSet(SfxItemSet& rSet) const
         return;
     }
 
-    rSet.Put(SvxBrushItem(maBgColor, ATTR_BACKGROUND));
+    if (maPattern.equalsIgnoreAsciiCase("solid"))
+        rSet.Put(SvxBrushItem(maFgColor, ATTR_BACKGROUND));
 }
 
 ScOrcusStyles::protection::protection():
@@ -1574,15 +1575,19 @@ void ScOrcusStyles::set_fill_pattern_type(const char* s, size_t n)
     maCurrentFill.mbHasFillAttr = true;
 }
 
-void ScOrcusStyles::set_fill_fg_color(orcus::spreadsheet::color_elem_t alpha, orcus::spreadsheet::color_elem_t red, orcus::spreadsheet::color_elem_t green, orcus::spreadsheet::color_elem_t blue)
+void ScOrcusStyles::set_fill_fg_color(
+    orcus::spreadsheet::color_elem_t /*alpha*/, orcus::spreadsheet::color_elem_t red, orcus::spreadsheet::color_elem_t green, orcus::spreadsheet::color_elem_t blue)
 {
-    maCurrentFill.maFgColor = Color(alpha, red, green, blue);
+    // Ignore the alpha element for now.
+    maCurrentFill.maFgColor = Color(red, green, blue);
     maCurrentFill.mbHasFillAttr = true;
 }
 
-void ScOrcusStyles::set_fill_bg_color(orcus::spreadsheet::color_elem_t alpha, orcus::spreadsheet::color_elem_t red, orcus::spreadsheet::color_elem_t green, orcus::spreadsheet::color_elem_t blue)
+void ScOrcusStyles::set_fill_bg_color(
+    orcus::spreadsheet::color_elem_t /*alpha*/, orcus::spreadsheet::color_elem_t red, orcus::spreadsheet::color_elem_t green, orcus::spreadsheet::color_elem_t blue)
 {
-    maCurrentFill.maBgColor = Color(alpha, red, green, blue);
+    // Ignore the alpha element for now.
+    maCurrentFill.maBgColor = Color(red, green, blue);
     maCurrentFill.mbHasFillAttr = true;
 }
 


More information about the Libreoffice-commits mailing list