merge the formfield patch from ooo-build
[ooovba.git] / applied_patches / 0402-svg-import-opacity-fix.diff
blob9389b670594414b374039bb0fe7377bd3e2a7fea
1 Actually handling global svg opacity now
3 From: Thorsten Behrens <thb@openoffice.org>
6 ---
8 filter/source/svg/gfxtypes.hxx | 2 ++
9 filter/source/svg/svgreader.cxx | 38 ++++++++++++++++++++++----------------
10 2 files changed, 24 insertions(+), 16 deletions(-)
13 diff --git filter/source/svg/gfxtypes.hxx filter/source/svg/gfxtypes.hxx
14 index bdf66af..79d73d4 100644
15 --- filter/source/svg/gfxtypes.hxx
16 +++ filter/source/svg/gfxtypes.hxx
17 @@ -174,6 +174,7 @@ struct State
18 mbVisibility(true),
19 meFillType(SOLID),
20 mnFillOpacity(1.0),
21 + mnOpacity(1.0),
22 meStrokeType(NONE),
23 mnStrokeOpacity(1.0),
24 meViewportFillType(NONE),
25 @@ -220,6 +221,7 @@ struct State
27 PaintType meFillType;
28 double mnFillOpacity;
29 + double mnOpacity;
30 PaintType meStrokeType;
31 double mnStrokeOpacity;
32 PaintType meViewportFillType;
33 diff --git filter/source/svg/svgreader.cxx filter/source/svg/svgreader.cxx
34 index 1e4570c..8a33745 100644
35 --- filter/source/svg/svgreader.cxx
36 +++ filter/source/svg/svgreader.cxx
37 @@ -519,12 +519,12 @@ struct AnnotatingVisitor
38 rtl::OUString::valueOf(
39 maGradientStopVector[
40 rState.maFillGradient.maStops[0]].maStopColor.a*
41 - maCurrState.mnFillOpacity*100.0)+USTR("%" ) );
42 + maCurrState.mnFillOpacity*maCurrState.mnOpacity*100.0)+USTR("%" ) );
43 xAttrs->AddAttribute( USTR( "draw:start" ),
44 rtl::OUString::valueOf(
45 maGradientStopVector[
46 rState.maFillGradient.maStops[1]].maStopColor.a*
47 - maCurrState.mnFillOpacity*100.0)+USTR("%" ) );
48 + maCurrState.mnFillOpacity*maCurrState.mnOpacity*100.0)+USTR("%" ) );
49 xAttrs->AddAttribute( USTR( "draw:border" ), USTR("0%") );
50 mxDocumentHandler->startElement( USTR("draw:opacity"),
51 xUnoAttrs );
52 @@ -616,17 +616,17 @@ struct AnnotatingVisitor
53 xAttrs->AddAttribute( USTR( "draw:opacity-name" ),
54 getStyleName("svgopacity", rState.maFillGradient.mnId) );
56 - else if( maCurrState.mnFillOpacity != 1.0 )
57 + else if( maCurrState.mnFillOpacity*maCurrState.mnOpacity != 1.0 )
58 xAttrs->AddAttribute( USTR( "draw:opacity" ),
59 - rtl::OUString::valueOf(100.0*maCurrState.mnFillOpacity)+USTR("%") );
60 + rtl::OUString::valueOf(100.0*maCurrState.mnFillOpacity*maCurrState.mnOpacity)+USTR("%") );
62 else
64 xAttrs->AddAttribute( USTR( "draw:fill" ), USTR("solid"));
65 xAttrs->AddAttribute( USTR( "draw:fill-color" ), getOdfColor(rState.maFillColor));
66 - if( maCurrState.mnFillOpacity != 1.0 )
67 + if( maCurrState.mnFillOpacity*maCurrState.mnOpacity != 1.0 )
68 xAttrs->AddAttribute( USTR( "draw:opacity" ),
69 - rtl::OUString::valueOf(100.0*maCurrState.mnFillOpacity)+USTR("%") );
70 + rtl::OUString::valueOf(100.0*maCurrState.mnFillOpacity*maCurrState.mnOpacity)+USTR("%") );
73 else
74 @@ -652,9 +652,9 @@ struct AnnotatingVisitor
75 xAttrs->AddAttribute( USTR( "draw:stroke-linejoin"), USTR("round"));
76 else if( maCurrState.meLineJoin == basegfx::B2DLINEJOIN_BEVEL )
77 xAttrs->AddAttribute( USTR( "draw:stroke-linejoin"), USTR("bevel"));
78 - if( maCurrState.mnStrokeOpacity != 1.0 )
79 + if( maCurrState.mnStrokeOpacity*maCurrState.mnOpacity != 1.0 )
80 xAttrs->AddAttribute( USTR("svg:stroke-opacity"),
81 - rtl::OUString::valueOf(100.0*maCurrState.mnStrokeOpacity)+USTR("%"));
82 + rtl::OUString::valueOf(100.0*maCurrState.mnStrokeOpacity*maCurrState.mnOpacity)+USTR("%"));
85 mxDocumentHandler->startElement( USTR("style:graphic-properties"),
86 @@ -876,6 +876,12 @@ struct AnnotatingVisitor
87 maCurrState.meFillRule = maParentStates.back().meFillRule;
88 break;
90 + case XML_OPACITY:
91 + if( aValueUtf8 == "inherit" )
92 + maCurrState.mnOpacity = maParentStates.back().mnOpacity;
93 + else
94 + maCurrState.mnOpacity = aValueUtf8.toDouble();
95 + break;
96 case XML_FILL_OPACITY:
97 if( aValueUtf8 == "inherit" )
98 maCurrState.mnFillOpacity = maParentStates.back().mnFillOpacity;
99 @@ -2540,13 +2546,13 @@ struct ShapeRenderingVisitor
100 const BYTE cTransStart( 255-
101 basegfx::fround(mrGradientStopVector[
102 aState.maFillGradient.maStops[1]].maStopColor.a*
103 - aState.mnFillOpacity*255.0));
104 + aState.mnFillOpacity*maCurrState.mnOpacity*255.0));
105 const Color aTransStart( cTransStart, cTransStart, cTransStart );
107 const BYTE cTransEnd( 255-
108 basegfx::fround(mrGradientStopVector[
109 aState.maFillGradient.maStops[0]].maStopColor.a*
110 - aState.mnFillOpacity*255.0));
111 + aState.mnFillOpacity*maCurrState.mnOpacity*255.0));
112 const Color aTransEnd( cTransEnd, cTransEnd, cTransEnd );
114 // modulate gradient opacity with overall fill opacity
115 @@ -2594,10 +2600,10 @@ struct ShapeRenderingVisitor
116 else
117 mrOutDev.SetFillColor(getVclColor(aState.maFillColor));
119 - if( aState.mnFillOpacity != 1.0 )
120 + if( aState.mnFillOpacity*maCurrState.mnOpacity != 1.0 )
121 mrOutDev.DrawTransparent(::PolyPolygon(aPoly),
122 basegfx::fround(
123 - (1.0-aState.mnFillOpacity)*100.0));
124 + (1.0-(aState.mnFillOpacity*maCurrState.mnOpacity))*100.0));
125 else
126 mrOutDev.DrawPolyPolygon(::PolyPolygon(aPoly));
128 @@ -2652,10 +2658,10 @@ struct ShapeRenderingVisitor
130 for( sal_uInt32 i=0; i<aPolys.size(); ++i )
132 - if( aState.mnStrokeOpacity != 1.0 )
133 + if( aState.mnStrokeOpacity*maCurrState.mnOpacity != 1.0 )
134 mrOutDev.DrawTransparent(::PolyPolygon(aPolys[i]),
135 basegfx::fround(
136 - (1.0-aState.mnStrokeOpacity)*100.0));
137 + (1.0-(aState.mnStrokeOpacity*maCurrState.mnOpacity))*100.0));
138 else
139 mrOutDev.DrawPolyPolygon(::PolyPolygon(aPolys[i]));
141 @@ -2675,10 +2681,10 @@ struct ShapeRenderingVisitor
142 else
143 mrOutDev.SetLineColor(getVclColor(aState.maStrokeColor));
145 - if( aState.mnStrokeOpacity != 1.0 )
146 + if( aState.mnStrokeOpacity*maCurrState.mnOpacity != 1.0 )
147 mrOutDev.DrawTransparent(::PolyPolygon(aPoly),
148 basegfx::fround(
149 - (1.0-aState.mnStrokeOpacity)*100.0));
150 + (1.0-(aState.mnStrokeOpacity*maCurrState.mnOpacity))*100.0));
151 else
152 mrOutDev.DrawPolyPolygon(::PolyPolygon(aPoly));