Author: sergey
Date: Mon Aug 22 11:52:11 2011
New Revision: 1160220
URL: http://svn.apache.org/viewvc?rev=1160220&view=rev
Log:
handle colors with opacity
Modified:
poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/converter/AbstractWordUtils.java
poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/converter/WordToFoUtils.java
Modified:
poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/converter/AbstractWordUtils.java
URL:
http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/converter/AbstractWordUtils.java?rev=1160220&r1=1160219&r2=1160220&view=diff
==============================================================================
---
poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/converter/AbstractWordUtils.java
(original)
+++
poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/converter/AbstractWordUtils.java
Mon Aug 22 11:52:11 2011
@@ -306,11 +306,22 @@ public class AbstractWordUtils
}
}
- public static String getColor24( int value )
+ public static String getOpacity( int argbValue )
{
- if ( value == -1 )
+ int opacity = (int) ( ( argbValue & 0xFF000000l ) >>> 24 );
+ if ( opacity == 0 || opacity == 0xFF )
+ return ".0";
+
+ return "" + ( opacity / (float) 0xFF );
+ }
+
+ public static String getColor24( int argbValue )
+ {
+ if ( argbValue == -1 )
throw new IllegalArgumentException( "This colorref is empty" );
+ int value = argbValue & 0x00FFFFFF;
+
// http://www.w3.org/TR/REC-html40/types.html#h-6.5
switch ( value )
{
Modified:
poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/converter/WordToFoUtils.java
URL:
http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/converter/WordToFoUtils.java?rev=1160220&r1=1160219&r2=1160220&view=diff
==============================================================================
---
poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/converter/WordToFoUtils.java
(original)
+++
poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/converter/WordToFoUtils.java
Mon Aug 22 11:52:11 2011
@@ -76,6 +76,12 @@ public class WordToFoUtils extends Abstr
{
inline.setAttribute( "color", getColor24( characterRun.getIco24()
) );
}
+ final int opacity = (int) ( characterRun.getIco24() & 0xFF000000l )
>>> 24;
+ if ( opacity != 0 && opacity != 0xFF )
+ {
+ inline.setAttribute( "opacity",
+ getOpacity( characterRun.getIco24() ) );
+ }
if ( characterRun.getLanguageCode() != 0 )
{
final String language = getLanguage(
characterRun.getLanguageCode() );
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]