Better shading algo for customshapes, better gradients

Some custom shapes can have shaded parts, like for example 3d can,
the bevelled buttons etc. Those shaded colors are calculated
internally, and have been way off at times. Now using HSV color
space & the originally documented luminance modifications in steps
of 10 percent. Compared to MSO, still no 100 percent match, but
that seems due to gamma correction there.
Additionally, starting with MSO12, gradients on those shaded surfaces
look much better; adapted code to display gradients equally nice.

Note that most of this patch also applies to ooxml import; note as
well that customshapes from *all* kind of input files (including ODF
docs) now look different than before; no real way of changing this
in a backward-compatible way, since behaviour of custom shapes is
mandated (mostly) by internal tables, and not stored in a file.

Applies patches/dev300/ppt-customshape-shading-fix (much of it was
accepted at OOo already, via i#102797)

Applies patches/dev300/ppt-customshape-shading-fix.diff: fixed prob
with line arrows - the extra-added single point polygons lead to
extra arrows randomly around the custom shape. i#105654
This commit is contained in:
Thorsten Behrens 2010-10-26 23:04:44 +02:00
parent 5e1626f2cf
commit f64ef72743
3 changed files with 19 additions and 2 deletions

View file

@ -509,10 +509,11 @@ namespace drawinglayer
{ {
// copy local polygon, it may be changed // copy local polygon, it may be changed
basegfx::B2DPolygon aLocalPolygon(getB2DPolygon()); basegfx::B2DPolygon aLocalPolygon(getB2DPolygon());
aLocalPolygon.removeDoublePoints();
basegfx::B2DPolyPolygon aArrowA; basegfx::B2DPolyPolygon aArrowA;
basegfx::B2DPolyPolygon aArrowB; basegfx::B2DPolyPolygon aArrowB;
if(!aLocalPolygon.isClosed()) if(!aLocalPolygon.isClosed() && aLocalPolygon.count() > 1)
{ {
// apply arrows // apply arrows
const double fPolyLength(basegfx::tools::getLength(aLocalPolygon)); const double fPolyLength(basegfx::tools::getLength(aLocalPolygon));

View file

@ -1735,6 +1735,22 @@ void EnhancedCustomShape2d::CreateSubPath( sal_uInt16& rSrcPt, sal_uInt16& rSegm
if(aNewB2DPolyPolygon.count()) if(aNewB2DPolyPolygon.count())
{ {
if( !bLineGeometryNeededOnly )
{
// hack aNewB2DPolyPolygon to fill logic rect - this is
// needed to produce gradient fills that look like mso
aNewB2DPolygon.clear();
aNewB2DPolygon.append(basegfx::B2DPoint(0,0));
aNewB2DPolygon.setClosed(true);
aNewB2DPolyPolygon.append(aNewB2DPolygon);
aNewB2DPolygon.clear();
aNewB2DPolygon.append(basegfx::B2DPoint(aLogicRect.GetWidth(),
aLogicRect.GetHeight()));
aNewB2DPolygon.setClosed(true);
aNewB2DPolyPolygon.append(aNewB2DPolygon);
}
// #i37011# // #i37011#
bool bForceCreateTwoObjects(false); bool bForceCreateTwoObjects(false);

View file

@ -633,7 +633,7 @@ void InsertMissingOutlinePoints( const Polygon& /*rOutlinePoly*/, const std::vec
void GetPoint( const Polygon& rPoly, const std::vector< double >& rDistances, const double& fX, double& fx1, double& fy1 ) void GetPoint( const Polygon& rPoly, const std::vector< double >& rDistances, const double& fX, double& fx1, double& fy1 )
{ {
fy1 = fx1 = 0.0; fy1 = fx1 = 0.0;
if ( rPoly.GetSize() ) if ( rPoly.GetSize() > 1 )
{ {
std::vector< double >::const_iterator aIter = std::lower_bound( rDistances.begin(), rDistances.end(), fX ); std::vector< double >::const_iterator aIter = std::lower_bound( rDistances.begin(), rDistances.end(), fX );
sal_uInt16 nIdx = sal::static_int_cast<sal_uInt16>( std::distance( rDistances.begin(), aIter ) ); sal_uInt16 nIdx = sal::static_int_cast<sal_uInt16>( std::distance( rDistances.begin(), aIter ) );