summaryrefslogtreecommitdiff
path: root/sax/source
diff options
context:
space:
mode:
authorChr. Rossmanith <ChrRossmanith@gmx.de>2012-11-30 22:03:16 +0100
committerChr. Rossmanith <ChrRossmanith@gmx.de>2013-01-07 19:39:46 +0100
commitb3a1909a792956ce3a6ab52675017304969d7a66 (patch)
treef3cce0e366a66ed2254c4901c3f17b0f001aad1e /sax/source
parent0d957d1c10eeb6e0d15cc2fbc56239c1ec40fb6c (diff)
added Converter::convertColor with opacity parameter
Change-Id: I0f3759d8f75f2739b2815c37e8c81bc97e097ec8
Diffstat (limited to 'sax/source')
-rw-r--r--sax/source/tools/converter.cxx22
1 files changed, 21 insertions, 1 deletions
diff --git a/sax/source/tools/converter.cxx b/sax/source/tools/converter.cxx
index 78dd22b79f0b..e7fff9ae6e9c 100644
--- a/sax/source/tools/converter.cxx
+++ b/sax/source/tools/converter.cxx
@@ -478,7 +478,7 @@ int lcl_gethex( int nChar )
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 @@ bool Converter::convertColor( sal_Int32& rColor, const OUString& rValue )
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 */