Date: prev next · Thread: first prev next last
2013 Archives by date, by thread · List index


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/1526

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/26/1526/1

added Converter::convertColor with opacity parameter

Change-Id: I0f3759d8f75f2739b2815c37e8c81bc97e097ec8
---
M sax/inc/sax/tools/converter.hxx
M sax/source/tools/converter.cxx
2 files changed, 27 insertions(+), 2 deletions(-)



diff --git a/sax/inc/sax/tools/converter.hxx b/sax/inc/sax/tools/converter.hxx
index 601ce6c..8b84feb 100644
--- a/sax/inc/sax/tools/converter.hxx
+++ b/sax/inc/sax/tools/converter.hxx
@@ -95,10 +95,15 @@
     static void convertMeasurePx( ::rtl::OUStringBuffer& rBuffer,
                                   sal_Int32 nValue );
 
-    /** convert string to color */
+    /** convert string to rgb color */
     static bool convertColor( sal_Int32& rColor,
                               const ::rtl::OUString&rValue );
 
+    /** convert string to argb color */
+    static bool convertColor( sal_Int32& rColor,
+                              const ::rtl::OUString&rValue,
+                              const double alpha);
+
     /** convert color to string */
     static void convertColor( ::rtl::OUStringBuffer &rBuffer,
                               sal_Int32 nColor );
diff --git a/sax/source/tools/converter.cxx b/sax/source/tools/converter.cxx
index 78dd22b..e7fff9a 100644
--- a/sax/source/tools/converter.cxx
+++ b/sax/source/tools/converter.cxx
@@ -478,7 +478,7 @@
         return 0;
 }
 
-/** convert string to color */
+/** convert string to rgb color */
 bool Converter::convertColor( sal_Int32& rColor, const OUString& rValue )
 {
     if( rValue.getLength() != 7 || rValue[0] != '#' )
@@ -495,6 +495,26 @@
     return true;
 }
 
+/** convert string to rgba color */
+bool Converter::convertColor( sal_Int32& rColor, const OUString& rValue, const double alpha)
+{
+    if( rValue.getLength() != 7 || rValue[0] != '#' )
+        return false;
+
+    rColor = (int) (alpha * 255);
+    rColor <<= 8;
+
+    rColor |= lcl_gethex( rValue[1] ) * 16 + lcl_gethex( rValue[2] );
+    rColor <<= 8;
+
+    rColor |= ( lcl_gethex( rValue[3] ) * 16 + lcl_gethex( rValue[4] ) );
+    rColor <<= 8;
+
+    rColor |= ( lcl_gethex( rValue[5] ) * 16 + lcl_gethex( rValue[6] ) );
+
+    return true;
+}
+
 static sal_Char aHexTab[] = "0123456789abcdef";
 
 /** convert color to string */

-- 
To view, visit https://gerrit.libreoffice.org/1526
To unsubscribe, visit https://gerrit.libreoffice.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0f3759d8f75f2739b2815c37e8c81bc97e097ec8
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: master
Gerrit-Owner: Christina Roßmanith <ChrRossmanith@web.de>


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.