summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArmin Le Grand <alg@apache.org>2013-10-31 14:43:21 +0000
committerLuboš Luňák <l.lunak@collabora.com>2014-03-24 16:10:31 +0100
commitc1455ec34b438f4d839c57e42066d02172e3de17 (patch)
tree36cfd59f94de7475545a7453dc20435eabbef2d0
parentcbe8ab2a9c65f7afe3caab004133d33e8c5521aa (diff)
Resolves: #i123500# unified Graphic processing to use GraphicPrimitive2D
(cherry picked from commit f5d69b2b8b002ca6905496a9d9065ef76b5641d7) Conflicts: sw/source/core/doc/notxtfrm.cxx (cherry picked from commit 2e5167528f7566dd9b000e50fc1610b7bf99132a) Signed-off-by: Luboš Luňák <l.lunak@centrum.cz> Conflicts: sw/source/core/doc/notxtfrm.cxx Change-Id: I1758aadcbe97ece271277378e62300b895421768
-rw-r--r--basegfx/source/matrix/b2dhommatrixtools.cxx42
-rw-r--r--include/basegfx/matrix/b2dhommatrixtools.hxx7
-rw-r--r--sw/inc/ndgrf.hxx1
-rw-r--r--sw/source/core/doc/notxtfrm.cxx122
4 files changed, 84 insertions, 88 deletions
diff --git a/basegfx/source/matrix/b2dhommatrixtools.cxx b/basegfx/source/matrix/b2dhommatrixtools.cxx
index 5666064d7933..7ebd0858ba3a 100644
--- a/basegfx/source/matrix/b2dhommatrixtools.cxx
+++ b/basegfx/source/matrix/b2dhommatrixtools.cxx
@@ -357,6 +357,48 @@ 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
diff --git a/include/basegfx/matrix/b2dhommatrixtools.hxx b/include/basegfx/matrix/b2dhommatrixtools.hxx
index ed255360f831..6b2b51092d01 100644
--- a/include/basegfx/matrix/b2dhommatrixtools.hxx
+++ b/include/basegfx/matrix/b2dhommatrixtools.hxx
@@ -23,9 +23,9 @@
#include <sal/types.h>
#include <basegfx/matrix/b2dhommatrix.hxx>
#include <basegfx/vector/b2dvector.hxx>
+#include <basegfx/range/b2drange.hxx>
#include <basegfx/basegfxdllapi.h>
-
///////////////////////////////////////////////////////////////////////////////
namespace basegfx
@@ -127,6 +127,11 @@ namespace basegfx
fRadiant);
}
+ /// special for the case to map from source range to target range
+ BASEGFX_DLLPUBLIC B2DHomMatrix createSourceRangeTargetRangeTransform(
+ const B2DRange& rSourceRange,
+ const B2DRange& rTargetRange);
+
} // end of namespace tools
} // end of namespace basegfx
diff --git a/sw/inc/ndgrf.hxx b/sw/inc/ndgrf.hxx
index e970615e9fe8..8c2d0f78b797 100644
--- a/sw/inc/ndgrf.hxx
+++ b/sw/inc/ndgrf.hxx
@@ -138,7 +138,6 @@ public:
/// wrappers for non-const calls at GraphicObject
void ReleaseGraphicFromCache() { maGrfObj.ReleaseFromCache(); }
- void DrawGraphicWithPDFHandling(OutputDevice& rOutDev, const Point& rPt, const Size& rSz, const GraphicAttr* pGrfAttr = NULL, const sal_uLong nFlags = GRFMGR_DRAW_STANDARD) { maGrfObj.DrawWithPDFHandling(rOutDev, rPt, rSz, pGrfAttr, nFlags); }
void StartGraphicAnimation(OutputDevice* pOut, const Point& rPt, const Size& rSz, long nExtraData = 0, const GraphicAttr* pAttr = NULL, sal_uLong nFlags = GRFMGR_DRAW_STANDARD, OutputDevice* pFirstFrameOutDev = NULL) { maGrfObj.StartAnimation(pOut, rPt, rSz, nExtraData, pAttr, nFlags, pFirstFrameOutDev); }
void StopGraphicAnimation(OutputDevice* pOut = NULL, long nExtraData = 0) { maGrfObj.StopAnimation(pOut, nExtraData); }
diff --git a/sw/source/core/doc/notxtfrm.cxx b/sw/source/core/doc/notxtfrm.cxx
index 28a7515a5ee0..9ed3b3117ca3 100644
--- a/sw/source/core/doc/notxtfrm.cxx
+++ b/sw/source/core/doc/notxtfrm.cxx
@@ -72,6 +72,7 @@
#include <basegfx/matrix/b2dhommatrix.hxx>
#include <drawinglayer/processor2d/processorfromoutputdevice.hxx>
#include <drawinglayer/processor2d/baseprocessor2d.hxx>
+#include <drawinglayer/primitive2d/graphicprimitive2d.hxx>
#include <basegfx/matrix/b2dhommatrixtools.hxx>
using namespace com::sun::star;
@@ -695,57 +696,19 @@ bool paintUsingPrimitivesHelper(
OutputDevice& rOutputDevice,
const drawinglayer::primitive2d::Primitive2DSequence& rSequence,
const basegfx::B2DRange& rSourceRange,
- const basegfx::B2DRange& rTargetRange,
- const sal_Int32 nLeftCrop = 0,
- const sal_Int32 nTopCrop = 0,
- const sal_Int32 nRightCrop = 0,
- const sal_Int32 nBottomCrop = 0,
- const bool bMirrorX = false,
- const bool bMirrorY = false)
+ const basegfx::B2DRange& rTargetRange)
{
- const double fSourceWidth(rSourceRange.getWidth());
- const double fSourceHeight(rSourceRange.getHeight());
-
- if(rSequence.hasElements() && !basegfx::fTools::equalZero(fSourceWidth) && !basegfx::fTools::equalZero(fSourceHeight))
+ if(rSequence.hasElements() && !basegfx::fTools::equalZero(rSourceRange.getWidth()) && !basegfx::fTools::equalZero(rSourceRange.getHeight()))
{
- // copy target range and apply evtl. cropping
- basegfx::B2DRange aTargetRange(rTargetRange);
-
- if(nLeftCrop || nTopCrop || nRightCrop || nBottomCrop)
- {
- // calculate original TargetRange
- const double fFactor100thmmToTwips(72.0 / 127.0);
-
- aTargetRange = basegfx::B2DRange(
- aTargetRange.getMinX() - (nLeftCrop * fFactor100thmmToTwips),
- aTargetRange.getMinY() - (nTopCrop * fFactor100thmmToTwips),
- aTargetRange.getMaxX() + (nRightCrop * fFactor100thmmToTwips),
- aTargetRange.getMaxY() + (nBottomCrop * fFactor100thmmToTwips));
- }
-
- const double fTargetWidth(aTargetRange.getWidth());
- const double fTargetHeight(aTargetRange.getHeight());
-
- if(!basegfx::fTools::equalZero(fTargetWidth) && !basegfx::fTools::equalZero(fTargetHeight))
+ if(!basegfx::fTools::equalZero(rTargetRange.getWidth()) && !basegfx::fTools::equalZero(rTargetRange.getHeight()))
{
- // map graphic range to target range. This will automatically include
- // tme mapping from Svg 1/100th mm content to twips since the target
- // range is twips already
- basegfx::B2DHomMatrix aMappingTransform(
- basegfx::tools::createTranslateB2DHomMatrix(
- -rSourceRange.getMinX(),
- -rSourceRange.getMinY()));
-
- aMappingTransform.scale(fTargetWidth / fSourceWidth, fTargetHeight / fSourceHeight);
- aMappingTransform.translate(aTargetRange.getMinX(), aTargetRange.getMinY());
-
- // apply mirrorings
- if(bMirrorX || bMirrorY)
- {
- aMappingTransform.translate(-aTargetRange.getCenterX(), -aTargetRange.getCenterY());
- aMappingTransform.scale(bMirrorX ? -1.0 : 1.0, bMirrorY ? -1.0 : 1.0); // #119176# small typo with X/Y
- aMappingTransform.translate(aTargetRange.getCenterX(), aTargetRange.getCenterY());
- }
+ // map graphic range to target range. This will e.g. automatically include
+ // tme mapping from 1/100th mm content to twips if needed when the target
+ // range is defined in twips
+ const basegfx::B2DHomMatrix aMappingTransform(
+ basegfx::tools::createSourceRangeTargetRangeTransform(
+ rSourceRange,
+ rTargetRange));
// Fill ViewInformation. Use MappingTransform here, so there is no need to
// embed the primitives to it. Use original TargetRange here so there is also
@@ -754,7 +717,7 @@ bool paintUsingPrimitivesHelper(
const drawinglayer::geometry::ViewInformation2D aViewInformation2D(
aMappingTransform,
rOutputDevice.GetViewTransformation(),
- aTargetRange,
+ rTargetRange,
0,
0.0,
uno::Sequence< beans::PropertyValue >());
@@ -863,14 +826,6 @@ void SwNoTxtFrm::PaintPicture( OutputDevice* pOut, const SwRect &rGrfArea ) cons
::lcl_PaintReplacement( aAlignedGrfArea, aTxt, *pShell, this, false );
bContinue = false;
}
- else if( rGrfObj.IsCached( pOut, aAlignedGrfArea.Pos(),
- aAlignedGrfArea.SSize(), &aGrfAttr ))
- {
- pGrfNd->DrawGraphicWithPDFHandling(*pOut,
- aAlignedGrfArea.Pos(), aAlignedGrfArea.SSize(),
- &aGrfAttr );
- bContinue = false;
- }
}
if( bContinue )
@@ -907,35 +862,30 @@ void SwNoTxtFrm::PaintPicture( OutputDevice* pOut, const SwRect &rGrfArea ) cons
}
else
{
- const SvgDataPtr& rSvgDataPtr = rGrfObj.GetGraphic().getSvgData();
- bool bDone(false);
-
- if(rSvgDataPtr.get())
- {
- // Graphic is Svg and can be painted as primitives (vector graphic)
- const basegfx::B2DRange aTargetRange(
- aAlignedGrfArea.Left(), aAlignedGrfArea.Top(),
- aAlignedGrfArea.Right(), aAlignedGrfArea.Bottom());
- const bool bCropped(aGrfAttr.IsCropped());
-
- bDone = paintUsingPrimitivesHelper(
- *pOut,
- rSvgDataPtr->getPrimitive2DSequence(),
- rSvgDataPtr->getRange(),
- aTargetRange,
- bCropped ? aGrfAttr.GetLeftCrop() : 0,
- bCropped ? aGrfAttr.GetTopCrop() : 0,
- bCropped ? aGrfAttr.GetRightCrop() : 0,
- bCropped ? aGrfAttr.GetBottomCrop() : 0,
- aGrfAttr.GetMirrorFlags() & BMP_MIRROR_HORZ,
- aGrfAttr.GetMirrorFlags() & BMP_MIRROR_VERT);
- }
-
- if(!bDone)
- {
- // fallback paint, uses replacement image
- pGrfNd->DrawGraphicWithPDFHandling(*pOut, aAlignedGrfArea.Pos(), aAlignedGrfArea.SSize(), &aGrfAttr);
- }
+ // unify using GraphicPrimitive2D
+ // -> the primitive handles all crop and mirror stuff
+ // -> the primitive renderer will create the needed pdf export data
+ // -> if bitmap conent, it will be cached system-dependent
+ const basegfx::B2DRange aTargetRange(
+ aAlignedGrfArea.Left(), aAlignedGrfArea.Top(),
+ aAlignedGrfArea.Right(), aAlignedGrfArea.Bottom());
+ const basegfx::B2DHomMatrix aTargetTransform(
+ basegfx::tools::createScaleTranslateB2DHomMatrix(
+ aTargetRange.getRange(),
+ aTargetRange.getMinimum()));
+ drawinglayer::primitive2d::Primitive2DSequence aContent;
+
+ aContent.realloc(1);
+ aContent[0] = new drawinglayer::primitive2d::GraphicPrimitive2D(
+ aTargetTransform,
+ rGrfObj.GetGraphic(),
+ aGrfAttr);
+
+ paintUsingPrimitivesHelper(
+ *pOut,
+ aContent,
+ aTargetRange,
+ aTargetRange);
}
}
else