summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVort <vvort@yandex.ru>2014-05-07 10:20:41 +0300
committerCaolán McNamara <caolanm@redhat.com>2014-05-07 12:35:48 +0000
commitd7fc306cd72c4b1d36389ff4211216f6efde4869 (patch)
treeaf28a97926677f36f66847754c0aa04f8956b6fb
parent21e2f5b0b1bc86c5032242ee3505f8e07b54affa (diff)
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@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--sdext/source/pdfimport/inc/pdfihelper.hxx1
-rw-r--r--sdext/source/pdfimport/misc/pdfihelper.cxx11
-rw-r--r--sdext/source/pdfimport/tree/drawtreevisiting.cxx11
3 files changed, 15 insertions, 8 deletions
diff --git a/sdext/source/pdfimport/inc/pdfihelper.hxx b/sdext/source/pdfimport/inc/pdfihelper.hxx
index 259e3bdf3865..b5c9b8c8b7c4 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 862f11b5989f..692ba8731b01 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 49c1959041c7..008711d6eaa9 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 );