[Libreoffice-commits] core.git: sdext/source

Vort vvort at yandex.ru
Wed May 7 05:36:17 PDT 2014


 sdext/source/pdfimport/inc/pdfihelper.hxx        |    1 +
 sdext/source/pdfimport/misc/pdfihelper.cxx       |   11 ++++++++---
 sdext/source/pdfimport/tree/drawtreevisiting.cxx |   11 ++++++-----
 3 files changed, 15 insertions(+), 8 deletions(-)

New commits:
commit d7fc306cd72c4b1d36389ff4211216f6efde4869
Author: Vort <vvort at yandex.ru>
Date:   Wed May 7 10:20:41 2014 +0300

    fdo#78382 PDF Import: add opacity support for fill and stroke
    
    Change-Id: I76375280ee4726c1d497858165f38f4e8b4224cb
    Reviewed-on: https://gerrit.libreoffice.org/9268
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sdext/source/pdfimport/inc/pdfihelper.hxx b/sdext/source/pdfimport/inc/pdfihelper.hxx
index 259e3bd..b5c9b8c 100644
--- a/sdext/source/pdfimport/inc/pdfihelper.hxx
+++ b/sdext/source/pdfimport/inc/pdfihelper.hxx
@@ -72,6 +72,7 @@ namespace pdfi
 
     /// Convert color to "#FEFEFE" color notation
     OUString getColorString( const ::com::sun::star::rendering::ARGBColor& );
+    OUString getPercentString(double value);
 
     double GetAverageTransformationScale(const basegfx::B2DHomMatrix& matrix);
     void FillDashStyleProps(PropertyMap& props, const std::vector<double>& dashArray, double scale);
diff --git a/sdext/source/pdfimport/misc/pdfihelper.cxx b/sdext/source/pdfimport/misc/pdfihelper.cxx
index 862f11b..692ba87 100644
--- a/sdext/source/pdfimport/misc/pdfihelper.cxx
+++ b/sdext/source/pdfimport/misc/pdfihelper.cxx
@@ -96,12 +96,17 @@ OUString pdfi::getColorString( const rendering::ARGBColor& rCol )
         aBuf.append( '0' );
     aBuf.append( sal_Int32(nBlue), 16 );
 
-    // TODO(F3): respect alpha transparency (polygons etc.)
-    OSL_ASSERT(rCol.Alpha == 1.0);
-
     return aBuf.makeStringAndClear();
 }
 
+OUString pdfi::getPercentString(double value)
+{
+    OUStringBuffer buf(32);
+    buf.append(value);
+    buf.appendAscii("%");
+    return buf.makeStringAndClear();
+}
+
 OUString pdfi::unitMMString( double fMM )
 {
     OUStringBuffer aBuf( 32 );
diff --git a/sdext/source/pdfimport/tree/drawtreevisiting.cxx b/sdext/source/pdfimport/tree/drawtreevisiting.cxx
index 49c1959..008711d 100644
--- a/sdext/source/pdfimport/tree/drawtreevisiting.cxx
+++ b/sdext/source/pdfimport/tree/drawtreevisiting.cxx
@@ -808,6 +808,8 @@ void DrawXmlFinalizer::visit( PolyPolyElement& elem, const std::list< Element* >
         }
 
         aGCProps[ "svg:stroke-color" ] = getColorString(rGC.LineColor);
+        if (rGC.LineColor.Alpha != 1.0)
+            aGCProps["svg:stroke-opacity"] = getPercentString(rGC.LineColor.Alpha * 100.0);
         aGCProps[ "svg:stroke-width" ] = convertPixelToUnitString(rGC.LineWidth * scale);
         aGCProps[ "draw:stroke-linejoin" ] = rGC.GetLineJoinString();
         aGCProps[ "svg:stroke-linecap" ] = rGC.GetLineCapString();
@@ -821,7 +823,9 @@ void DrawXmlFinalizer::visit( PolyPolyElement& elem, const std::list< Element* >
     if( elem.Action & (PATH_FILL | PATH_EOFILL) )
     {
         aGCProps[ "draw:fill" ]   = "solid";
-        aGCProps[ "draw:fill-color" ] = getColorString( rGC.FillColor );
+        aGCProps[ "draw:fill-color" ] = getColorString(rGC.FillColor);
+        if (rGC.FillColor.Alpha != 1.0)
+            aGCProps["draw:opacity"] = getPercentString(rGC.FillColor.Alpha * 100.0);
     }
     else
     {
@@ -904,10 +908,7 @@ void DrawXmlFinalizer::visit( TextElement& elem, const std::list< Element* >::co
     if (((textScale >= 1) && (textScale <= 99)) ||
         ((textScale >= 101) && (textScale <= 999)))
     {
-        OUStringBuffer aBuf(32);
-        aBuf.append(textScale);
-        aBuf.appendAscii("%");
-        aFontProps[ "style:text-scale" ] = aBuf.makeStringAndClear();
+        aFontProps[ "style:text-scale" ] = getPercentString(textScale);
     }
 
     StyleContainer::Style aStyle( "style:style", aProps );


More information about the Libreoffice-commits mailing list