diff options
author | Armin Le Grand <alg@apache.org> | 2013-08-13 15:10:34 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2013-08-14 11:32:19 +0100 |
commit | b5c9668d34acdbce500609725760d6578debb95a (patch) | |
tree | 0e61d3bb269c40fb010b86684637a9be9cb13c1b /basegfx/source/matrix | |
parent | b74a2e6ee80e30ed42ef99e24f85eb1d2df346ca (diff) |
Resolves: #i122149# Corrected stuff around polygon-based clip regions
do not use them where not needed
(cherry picked from commit 4ccb1eb7d58005ab3b501b7c6ff128fadbcd5066)
Conflicts:
basegfx/inc/basegfx/matrix/b2dhommatrixtools.hxx
basegfx/inc/basegfx/polygon/b2dpolygontools.hxx
basegfx/inc/basegfx/polygon/b2dpolypolygontools.hxx
basegfx/inc/basegfx/tuple/b2dtuple.hxx
basegfx/inc/basegfx/tuple/b3dtuple.hxx
sc/source/ui/inc/output.hxx
sc/source/ui/view/gridwin.cxx
sc/source/ui/view/output.cxx
vcl/win/source/gdi/salgdi.cxx
Change-Id: Ie265814a51180bffe3c821a3f2148cb3bb54ecad
Diffstat (limited to 'basegfx/source/matrix')
-rw-r--r-- | basegfx/source/matrix/b2dhommatrixtools.cxx | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/basegfx/source/matrix/b2dhommatrixtools.cxx b/basegfx/source/matrix/b2dhommatrixtools.cxx index 5666064d7933..3e39fd5e4df6 100644 --- a/basegfx/source/matrix/b2dhommatrixtools.cxx +++ b/basegfx/source/matrix/b2dhommatrixtools.cxx @@ -357,6 +357,47 @@ namespace basegfx return aRetval; } + + /// special for the case to map from source range to target range + B2DHomMatrix createSourceRangeTargetRangeTransform( + const B2DRange& rSourceRange, + const B2DRange& rTargetRange) + { + B2DHomMatrix aRetval; + + if(&rSourceRange == &rTargetRange) + { + return aRetval; + } + + if(!fTools::equalZero(rSourceRange.getMinX()) || !fTools::equalZero(rSourceRange.getMinY())) + { + aRetval.set(0, 2, -rSourceRange.getMinX()); + aRetval.set(1, 2, -rSourceRange.getMinY()); + } + + const double fSourceW(rSourceRange.getWidth()); + const double fSourceH(rSourceRange.getHeight()); + const bool bDivX(!fTools::equalZero(fSourceW) && !fTools::equal(fSourceW, 1.0)); + const bool bDivY(!fTools::equalZero(fSourceH) && !fTools::equal(fSourceH, 1.0)); + const double fScaleX(bDivX ? rTargetRange.getWidth() / fSourceW : rTargetRange.getWidth()); + const double fScaleY(bDivY ? rTargetRange.getHeight() / fSourceH : rTargetRange.getHeight()); + + if(!fTools::equalZero(fScaleX) || !fTools::equalZero(fScaleY)) + { + aRetval.scale(fScaleX, fScaleY); + } + + if(!fTools::equalZero(rTargetRange.getMinX()) || !fTools::equalZero(rTargetRange.getMinY())) + { + aRetval.translate( + rTargetRange.getMinX(), + rTargetRange.getMinY()); + } + + return aRetval; + } + } // end of namespace tools } // end of namespace basegfx |