include/tools/color.hxx | 10 ++++++++ sc/uiconfig/scalc/ui/pivottablelayoutdialog.ui | 7 +++++ tools/qa/cppunit/test_color.cxx | 22 ++++++++++++++++++ tools/source/generic/color.cxx | 30 +++++++++++++++++++++++++ 4 files changed, 68 insertions(+), 1 deletion(-)
New commits: commit 5984cc83fe756f7483d1ac582b8adbef5042be8b Author: Tomaž Vajngerl <[email protected]> Date: Thu May 7 13:55:59 2015 +0900 Add ability to change tint/shade of a color. Change-Id: I6933393732d23fe9386cb8b768676887c026bd39 diff --git a/include/tools/color.hxx b/include/tools/color.hxx index f940dbc..c382f87 100644 --- a/include/tools/color.hxx +++ b/include/tools/color.hxx @@ -161,6 +161,16 @@ public: void IncreaseLuminance(sal_uInt8 cLumInc); void DecreaseLuminance(sal_uInt8 cLumDec); + /** + * Apply tint or shade to a color. + * + * The input value is the percentage (in 100th of percent) of how much the + * color changes towards the black (shade) or white (tint). If the value + * is positive, the color is tinted, if the value is negative, the color is + * shaded. + **/ + void ApplyTintOrShade(sal_Int16 n100thPercent); + void DecreaseContrast(sal_uInt8 cContDec); void Invert(); diff --git a/tools/source/generic/color.cxx b/tools/source/generic/color.cxx index 741cb15..453feae 100644 --- a/tools/source/generic/color.cxx +++ b/tools/source/generic/color.cxx @@ -29,6 +29,8 @@ #include <tools/rcid.h> #include <tools/resid.hxx> #include <tools/rc.h> +#include <tools/helpers.hxx> +#include <basegfx/color/bcolortools.hxx> static inline long _FRound( double fVal ) { @@ -113,6 +115,34 @@ bool Color::IsBright() const return GetLuminance() >= 245; } +void Color::ApplyTintOrShade(sal_Int16 n100thPercent) +{ + if (n100thPercent > 0) + { + basegfx::BColor aBColor = basegfx::tools::rgb2hsl(getBColor()); + + double fFactor = std::abs(n100thPercent) / 10000.0; + aBColor.setBlue(aBColor.getBlue() * fFactor + (100.0 - aBColor.getBlue())); + aBColor = basegfx::tools::hsl2rgb(aBColor); + + SetRed(sal_uInt8((aBColor.getRed() * 255.0) + 0.5)); + SetGreen(sal_uInt8((aBColor.getGreen() * 255.0) + 0.5)); + SetBlue(sal_uInt8((aBColor.getBlue() * 255.0) + 0.5)); + } + else if (n100thPercent < 0) + { + basegfx::BColor aBColor = basegfx::tools::rgb2hsl(getBColor()); + + double fFactor = std::abs(n100thPercent) / 10000.0; + aBColor.setBlue(aBColor.getBlue() * fFactor); + aBColor = basegfx::tools::hsl2rgb(aBColor); + + SetRed(sal_uInt8((aBColor.getRed() * 255.0) + 0.5)); + SetGreen(sal_uInt8((aBColor.getGreen() * 255.0) + 0.5)); + SetBlue(sal_uInt8((aBColor.getBlue() * 255.0) + 0.5)); + } +} + // color space conversion void Color::RGBtoHSB( sal_uInt16& nHue, sal_uInt16& nSat, sal_uInt16& nBri ) const commit 6719b36a66171f59b383ccc5e7497d208bd566aa Author: Tomaž Vajngerl <[email protected]> Date: Thu May 7 13:54:27 2015 +0900 Make pivot table resizable again to make it easier to work with. Change-Id: I205f7348993031e0dd72c74531ca67e3e87e809c diff --git a/sc/uiconfig/scalc/ui/pivottablelayoutdialog.ui b/sc/uiconfig/scalc/ui/pivottablelayoutdialog.ui index 89d4b82..ddaf807 100644 --- a/sc/uiconfig/scalc/ui/pivottablelayoutdialog.ui +++ b/sc/uiconfig/scalc/ui/pivottablelayoutdialog.ui @@ -7,7 +7,6 @@ <property name="can_focus">False</property> <property name="border_width">6</property> <property name="title" translatable="yes">Pivot Table Layout</property> - <property name="resizable">False</property> <property name="type_hint">dialog</property> <child internal-child="vbox"> <object class="GtkBox" id="dialog-vbox1"> @@ -97,6 +96,8 @@ <object class="GtkBox" id="box4"> <property name="visible">True</property> <property name="can_focus">False</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> <property name="orientation">vertical</property> <property name="spacing">6</property> <child> @@ -199,6 +200,8 @@ <object class="GtkBox" id="box6"> <property name="visible">True</property> <property name="can_focus">False</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> <property name="orientation">vertical</property> <property name="spacing">6</property> <child> @@ -248,6 +251,8 @@ <object class="GtkBox" id="box7"> <property name="visible">True</property> <property name="can_focus">False</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> <property name="orientation">vertical</property> <property name="spacing">6</property> <child> commit c89e590fb0bbf387e3d43f1cc9c26c7a4c429f64 Author: Tomaž Vajngerl <[email protected]> Date: Fri Apr 24 12:36:48 2015 +0900 extend color test - check read & write from stream Change-Id: Iac3c8d30acff0984a98a4b705957c0361a5ead2f diff --git a/tools/qa/cppunit/test_color.cxx b/tools/qa/cppunit/test_color.cxx index 6846fad..99f311f 100644 --- a/tools/qa/cppunit/test_color.cxx +++ b/tools/qa/cppunit/test_color.cxx @@ -13,6 +13,7 @@ #include "cppunit/extensions/HelperMacros.h" #include "cppunit/plugin/TestPlugIn.h" #include <tools/color.hxx> +#include <tools/stream.hxx> namespace { @@ -21,9 +22,11 @@ class Test: public CppUnit::TestFixture { public: void test_asRGBColor(); + void test_readAndWriteStream(); CPPUNIT_TEST_SUITE(Test); CPPUNIT_TEST(test_asRGBColor); + CPPUNIT_TEST(test_readAndWriteStream); CPPUNIT_TEST_SUITE_END(); }; @@ -54,6 +57,25 @@ void Test::test_asRGBColor() CPPUNIT_ASSERT_EQUAL(aColor.AsRGBHexString(), OUString("ffffff")); } +void Test::test_readAndWriteStream() +{ + { + SvMemoryStream aStream; + Color aWriteColor(0x12, 0x34, 0x56); + Color aReadColor; + + WriteColor(aStream, aWriteColor); + + aStream.Seek(STREAM_SEEK_TO_BEGIN); + + ReadColor(aStream, aReadColor); + + CPPUNIT_ASSERT_EQUAL(sal_uInt8(0x12), aReadColor.GetRed()); + CPPUNIT_ASSERT_EQUAL(sal_uInt8(0x34), aReadColor.GetGreen()); + CPPUNIT_ASSERT_EQUAL(sal_uInt8(0x56), aReadColor.GetBlue()); + } +} + CPPUNIT_TEST_SUITE_REGISTRATION(Test); }
_______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
