You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by al...@apache.org on 2013/10/31 15:43:22 UTC
svn commit: r1537508 - in /openoffice/trunk/main/sw: inc/ndgrf.hxx
source/core/doc/notxtfrm.cxx
Author: alg
Date: Thu Oct 31 14:43:21 2013
New Revision: 1537508
URL: http://svn.apache.org/r1537508
Log:
i123500 unified Graphic processing to use GraphicPrimitive2D
Modified:
openoffice/trunk/main/sw/inc/ndgrf.hxx
openoffice/trunk/main/sw/source/core/doc/notxtfrm.cxx
Modified: openoffice/trunk/main/sw/inc/ndgrf.hxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sw/inc/ndgrf.hxx?rev=1537508&r1=1537507&r2=1537508&view=diff
==============================================================================
--- openoffice/trunk/main/sw/inc/ndgrf.hxx (original)
+++ openoffice/trunk/main/sw/inc/ndgrf.hxx Thu Oct 31 14:43:21 2013
@@ -154,7 +154,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); }
Modified: openoffice/trunk/main/sw/source/core/doc/notxtfrm.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sw/source/core/doc/notxtfrm.cxx?rev=1537508&r1=1537507&r2=1537508&view=diff
==============================================================================
--- openoffice/trunk/main/sw/source/core/doc/notxtfrm.cxx (original)
+++ openoffice/trunk/main/sw/source/core/doc/notxtfrm.cxx Thu Oct 31 14:43:21 2013
@@ -76,7 +76,7 @@
#include <basegfx/matrix/b2dhommatrixtools.hxx>
#include <drawinglayer/processor2d/processor2dtools.hxx>
#include <basegfx/matrix/b2dhommatrixtools.hxx>
-#include <drawinglayer/primitive2d/bitmapprimitive2d.hxx>
+#include <drawinglayer/primitive2d/graphicprimitive2d.hxx>
using namespace com::sun::star;
@@ -816,57 +816,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)
+ if(!basegfx::fTools::equalZero(rTargetRange.getWidth()) && !basegfx::fTools::equalZero(rTargetRange.getHeight()))
{
- // 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))
- {
- // 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
@@ -875,7 +837,7 @@ bool paintUsingPrimitivesHelper(
const drawinglayer::geometry::ViewInformation2D aViewInformation2D(
aMappingTransform,
rOutputDevice.GetViewTransformation(),
- aTargetRange,
+ rTargetRange,
0,
0.0,
uno::Sequence< beans::PropertyValue >());
@@ -983,14 +945,6 @@ void SwNoTxtFrm::PaintPicture( OutputDev
::lcl_PaintReplacement( aAlignedGrfArea, aTxt, *pShell, this, sal_False );
bContinue = sal_False;
}
- else if( rGrfObj.IsCached( pOut, aAlignedGrfArea.Pos(),
- aAlignedGrfArea.SSize(), &aGrfAttr ))
- {
- pGrfNd->DrawGraphicWithPDFHandling(*pOut,
- aAlignedGrfArea.Pos(), aAlignedGrfArea.SSize(),
- &aGrfAttr );
- bContinue = sal_False;
- }
}
if( bContinue )
@@ -1028,68 +982,30 @@ void SwNoTxtFrm::PaintPicture( OutputDev
}
else
{
- const SvgDataPtr& rSvgDataPtr = rGrfObj.GetGraphic().getSvgData();
- bool bDone(false);
+ // 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);
- 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());
- drawinglayer::primitive2d::Primitive2DSequence aContent;
- GraphicAttr aSuppressGraphicAttr(aGrfAttr);
-
- aSuppressGraphicAttr.SetCrop(0, 0, 0, 0);
- aSuppressGraphicAttr.SetRotation(0);
- aSuppressGraphicAttr.SetMirrorFlags(0);
-
- const bool bNeedTransformedGraphic(
- aSuppressGraphicAttr.IsSpecialDrawMode() ||
- aSuppressGraphicAttr.IsAdjusted() ||
- aSuppressGraphicAttr.IsMirrored() ||
- aSuppressGraphicAttr.IsRotated() ||
- aSuppressGraphicAttr.IsTransparent());
-
- if(bNeedTransformedGraphic)
- {
- // #122039# need to apply graphic transformation if GraphicAttr are used qwhich need this
- const Graphic aTransformedGraphic(rGrfObj.GetTransformedGraphic(&aSuppressGraphicAttr));
- const basegfx::B2DRange aRange(rSvgDataPtr->getRange());
- const basegfx::B2DHomMatrix aTransform(
- basegfx::tools::createScaleTranslateB2DHomMatrix(
- aRange.getRange(),
- aRange.getMinimum()));
-
- aContent.realloc(1);
- aContent[0] = new drawinglayer::primitive2d::BitmapPrimitive2D(
- aTransformedGraphic.GetBitmapEx(),
- aTransform);
- }
- else
- {
- aContent = rSvgDataPtr->getPrimitive2DSequence();
- }
-
- bDone = paintUsingPrimitivesHelper(
- *pOut,
- aContent,
- 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);
- }
+ paintUsingPrimitivesHelper(
+ *pOut,
+ aContent,
+ aTargetRange,
+ aTargetRange);
}
}
else