diff options
author | Ivo Hinkelmann <ihi@openoffice.org> | 2011-03-29 15:25:13 +0200 |
---|---|---|
committer | Ivo Hinkelmann <ihi@openoffice.org> | 2011-03-29 15:25:13 +0200 |
commit | cf9684554c4d689b7c7219085628d4548580e87e (patch) | |
tree | 68b1a7535dc1f094673276954c43df662a5f7b75 | |
parent | d2ef92c37766a4f5f0a4dd3a39ec59fe85b55a9b (diff) | |
parent | 30e9c4191ea73d13e3a8273d140491893078c90f (diff) |
CWS-TOOLING: integrate CWS ka102
25 files changed, 680 insertions, 249 deletions
diff --git a/drawinglayer/inc/drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx index 7f1c929a6e..8c4f79bcb2 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx @@ -103,6 +103,7 @@ #define PRIMITIVE2D_ID_EPSPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 60) #define PRIMITIVE2D_ID_DISCRETESHADOWPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 61) #define PRIMITIVE2D_ID_HIDDENGEOMETRYPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 62) +#define PRIMITIVE2D_ID_RENDERGRAPHICPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 63) ////////////////////////////////////////////////////////////////////////////// diff --git a/drawinglayer/inc/drawinglayer/primitive2d/rendergraphicprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/rendergraphicprimitive2d.hxx new file mode 100644 index 0000000000..1904394429 --- /dev/null +++ b/drawinglayer/inc/drawinglayer/primitive2d/rendergraphicprimitive2d.hxx @@ -0,0 +1,95 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_RENDERGRAPHICPRIMITIVE2D_HXX +#define INCLUDED_DRAWINGLAYER_PRIMITIVE2D_RENDERGRAPHICPRIMITIVE2D_HXX + +#include <drawinglayer/primitive2d/baseprimitive2d.hxx> +#include <basegfx/matrix/b2dhommatrix.hxx> +#include <vcl/rendergraphic.hxx> +#include <memory> + +////////////////////////////////////////////////////////////////////////////// +// RenderGraphicPrimitive2D class + +namespace vcl { class RenderGraphicRasterizer; } + +namespace drawinglayer +{ + namespace primitive2d + { + /** RenderGraphicPrimitive2D class + + This class is the central primitive for RenderGraphic-based primitives. + */ + class RenderGraphicPrimitive2D : public BasePrimitive2D + { + private: + /// the RenderGraphic data + vcl::RenderGraphic maRenderGraphic; + mutable std::auto_ptr< vcl::RenderGraphicRasterizer > mapCurrentRasterizer; + + /** the object transformation from unit coordinates, defining + size, shear, rotate and position + */ + basegfx::B2DHomMatrix maTransform; + + public: + /// constructor + RenderGraphicPrimitive2D( + const vcl::RenderGraphic& rRenderGraphic, + const basegfx::B2DHomMatrix& rTransform); + + /// data read access + inline const vcl::RenderGraphic& getRenderGraphic() const { return maRenderGraphic; } + inline const basegfx::B2DHomMatrix& getTransform() const { return maTransform; } + + // access to latest used vcl::GraphicRasterizer for possibly reusing + // an already rendered vcl::RenderGraphic with the same transform + // properties during the next rendering process + void setCurrentRasterizer() const; + void setCurrentRasterizer( const vcl::RenderGraphicRasterizer& rCurrentGraphicRasterizer ) const; + inline const vcl::RenderGraphicRasterizer* getCurrentRasterizer() const { return( mapCurrentRasterizer.get() ); } + + /// compare operator + virtual bool operator==(const BasePrimitive2D& rPrimitive) const; + + /// get range + virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const; + + /// provide unique ID + DeclPrimitrive2DIDBlock() + }; + } // end of namespace primitive2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +#endif // INCLUDED_DRAWINGLAYER_PRIMITIVE2D_RENDERGRAPHICPRIMITIVE2D_HXX + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/drawinglayer/inc/drawinglayer/processor2d/canvasprocessor.hxx b/drawinglayer/inc/drawinglayer/processor2d/canvasprocessor.hxx index 8a66fbc35c..5252751736 100644 --- a/drawinglayer/inc/drawinglayer/processor2d/canvasprocessor.hxx +++ b/drawinglayer/inc/drawinglayer/processor2d/canvasprocessor.hxx @@ -56,6 +56,7 @@ namespace drawinglayer { namespace primitive2d { class MetafilePrimitive2D; class TextSimplePortionPrimitive2D; class BitmapPrimitive2D; + class RenderGraphicPrimitive2D; class TransparencePrimitive2D; class PolygonStrokePrimitive2D; class FillBitmapPrimitive2D; @@ -108,6 +109,7 @@ namespace drawinglayer void impRenderMetafilePrimitive2D(const primitive2d::MetafilePrimitive2D& rMetaCandidate); void impRenderTextSimplePortionPrimitive2D(const primitive2d::TextSimplePortionPrimitive2D& rTextCandidate); void impRenderBitmapPrimitive2D(const primitive2d::BitmapPrimitive2D& rBitmapCandidate); + void impRenderRenderGraphicPrimitive2D(const primitive2d::RenderGraphicPrimitive2D& rRenderGraphicCandidate); void impRenderTransparencePrimitive2D(const primitive2d::TransparencePrimitive2D& rTransparenceCandidate); void impRenderPolygonStrokePrimitive2D(const primitive2d::PolygonStrokePrimitive2D& rPolygonStrokePrimitive); void impRenderFillBitmapPrimitive2D(const primitive2d::FillBitmapPrimitive2D& rFillBitmapPrimitive2D); diff --git a/drawinglayer/inc/drawinglayer/processor2d/vclprocessor2d.hxx b/drawinglayer/inc/drawinglayer/processor2d/vclprocessor2d.hxx index aad727e863..cb1e3b5516 100644 --- a/drawinglayer/inc/drawinglayer/processor2d/vclprocessor2d.hxx +++ b/drawinglayer/inc/drawinglayer/processor2d/vclprocessor2d.hxx @@ -41,6 +41,7 @@ namespace drawinglayer { namespace primitive2d { class TextSimplePortionPrimitive2D; class PolygonHairlinePrimitive2D; class BitmapPrimitive2D; + class RenderGraphicPrimitive2D; class FillBitmapPrimitive2D; class PolyPolygonGradientPrimitive2D; class PolyPolygonBitmapPrimitive2D; @@ -97,6 +98,7 @@ namespace drawinglayer void RenderTextSimpleOrDecoratedPortionPrimitive2D(const primitive2d::TextSimplePortionPrimitive2D& rTextCandidate); void RenderPolygonHairlinePrimitive2D(const primitive2d::PolygonHairlinePrimitive2D& rPolygonCandidate, bool bPixelBased); void RenderBitmapPrimitive2D(const primitive2d::BitmapPrimitive2D& rBitmapCandidate); + void RenderRenderGraphicPrimitive2D(const primitive2d::RenderGraphicPrimitive2D& rRenderGraphicCandidate); void RenderFillBitmapPrimitive2D(const primitive2d::FillBitmapPrimitive2D& rFillBitmapCandidate); void RenderPolyPolygonGradientPrimitive2D(const primitive2d::PolyPolygonGradientPrimitive2D& rPolygonCandidate); void RenderPolyPolygonBitmapPrimitive2D(const primitive2d::PolyPolygonBitmapPrimitive2D& rPolygonCandidate); diff --git a/drawinglayer/prj/d.lst b/drawinglayer/prj/d.lst index 54f087d317..10e692785a 100644 --- a/drawinglayer/prj/d.lst +++ b/drawinglayer/prj/d.lst @@ -13,6 +13,7 @@ mkdir: %_DEST%\inc%_EXT%\drawinglayer\primitive2d ..\inc\drawinglayer\primitive2d\backgroundcolorprimitive2d.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive2d\backgroundcolorprimitive2d.hxx ..\inc\drawinglayer\primitive2d\baseprimitive2d.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive2d\baseprimitive2d.hxx ..\inc\drawinglayer\primitive2d\bitmapprimitive2d.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive2d\bitmapprimitive2d.hxx +..\inc\drawinglayer\primitive2d\rendergraphicprimitive2d.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive2d\rendergraphicprimitive2d.hxx ..\inc\drawinglayer\primitive2d\borderlineprimitive2d.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive2d\borderlineprimitive2d.hxx ..\inc\drawinglayer\primitive2d\chartprimitive2d.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive2d\chartprimitive2d.hxx ..\inc\drawinglayer\primitive2d\controlprimitive2d.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive2d\controlprimitive2d.hxx diff --git a/drawinglayer/source/primitive2d/graphicprimitive2d.cxx b/drawinglayer/source/primitive2d/graphicprimitive2d.cxx index fd4467d449..07a10be75f 100644 --- a/drawinglayer/source/primitive2d/graphicprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/graphicprimitive2d.cxx @@ -31,6 +31,7 @@ #include <drawinglayer/primitive2d/graphicprimitive2d.hxx> #include <drawinglayer/animation/animationtiming.hxx> #include <drawinglayer/primitive2d/bitmapprimitive2d.hxx> +#include <drawinglayer/primitive2d/rendergraphicprimitive2d.hxx> #include <drawinglayer/primitive2d/animatedprimitive2d.hxx> #include <drawinglayer/primitive2d/metafileprimitive2d.hxx> #include <drawinglayer/primitive2d/transformprimitive2d.hxx> @@ -46,6 +47,7 @@ #include <vcl/graph.hxx> #include <vcl/virdev.hxx> #include <vcl/svapp.hxx> +#include <vcl/metaact.hxx> ////////////////////////////////////////////////////////////////////////////// // includes for testing MetafilePrimitive2D::create2DDecomposition @@ -260,7 +262,9 @@ namespace drawinglayer aSuppressGraphicAttr.SetCrop(0, 0, 0, 0); aSuppressGraphicAttr.SetRotation(0); aSuppressGraphicAttr.SetMirrorFlags(0); - const Graphic aTransformedGraphic(getGraphicObject().GetTransformedGraphic(&aSuppressGraphicAttr)); + + const GraphicObject& rGraphicObject = getGraphicObject(); + const Graphic aTransformedGraphic(rGraphicObject.GetTransformedGraphic(&aSuppressGraphicAttr)); switch(aTransformedGraphic.GetType()) { @@ -743,34 +747,43 @@ namespace drawinglayer { #endif // USE_DEBUG_CODE_TO_TEST_METAFILE_DECOMPOSE // create MetafilePrimitive2D - const Graphic aGraphic(getGraphicObject().GetGraphic()); const GDIMetaFile& rMetafile = aTransformedGraphic.GetGDIMetaFile(); - xPrimitive = Primitive2DReference( - new MetafilePrimitive2D( - aTransform, - rMetafile)); - - // #i100357# find out if clipping is needed for this primitive. Unfortunately, - // there exist Metafiles who's content is bigger than the proposed PrefSize set - // at them. This is an error, but we need to work around this - const Size aMetaFilePrefSize(rMetafile.GetPrefSize()); - const Size aMetaFileRealSize( - const_cast< GDIMetaFile& >(rMetafile).GetBoundRect( - *Application::GetDefaultDevice()).GetSize()); - - if(aMetaFileRealSize.getWidth() > aMetaFilePrefSize.getWidth() - || aMetaFileRealSize.getHeight() > aMetaFilePrefSize.getHeight()) + if( aTransformedGraphic.IsRenderGraphic() ) { - // clipping needed. Embed to MaskPrimitive2D. Create childs and mask polygon - const primitive2d::Primitive2DSequence aChildContent(&xPrimitive, 1); - basegfx::B2DPolygon aMaskPolygon(basegfx::tools::createUnitPolygon()); - aMaskPolygon.transform(aTransform); - xPrimitive = Primitive2DReference( - new MaskPrimitive2D( - basegfx::B2DPolyPolygon(aMaskPolygon), - aChildContent)); + new RenderGraphicPrimitive2D( + static_cast< MetaRenderGraphicAction* >(rMetafile.GetAction(0))->GetRenderGraphic(), + aTransform)); + } + else + { + xPrimitive = Primitive2DReference( + new MetafilePrimitive2D( + aTransform, + rMetafile)); + + // #i100357# find out if clipping is needed for this primitive. Unfortunately, + // there exist Metafiles who's content is bigger than the proposed PrefSize set + // at them. This is an error, but we need to work around this + const Size aMetaFilePrefSize(rMetafile.GetPrefSize()); + const Size aMetaFileRealSize( + const_cast< GDIMetaFile& >(rMetafile).GetBoundRect( + *Application::GetDefaultDevice()).GetSize()); + + if(aMetaFileRealSize.getWidth() > aMetaFilePrefSize.getWidth() + || aMetaFileRealSize.getHeight() > aMetaFilePrefSize.getHeight()) + { + // clipping needed. Embed to MaskPrimitive2D. Create childs and mask polygon + const primitive2d::Primitive2DSequence aChildContent(&xPrimitive, 1); + basegfx::B2DPolygon aMaskPolygon(basegfx::tools::createUnitPolygon()); + aMaskPolygon.transform(aTransform); + + xPrimitive = Primitive2DReference( + new MaskPrimitive2D( + basegfx::B2DPolyPolygon(aMaskPolygon), + aChildContent)); + } } #ifdef USE_DEBUG_CODE_TO_TEST_METAFILE_DECOMPOSE } @@ -808,16 +821,16 @@ namespace drawinglayer { const MapMode aMapMode100thmm(MAP_100TH_MM); - Size aBitmapSize(getGraphicObject().GetPrefSize()); + Size aBitmapSize(rGraphicObject.GetPrefSize()); // #i95968# better support PrefMapMode; special for MAP_PIXEL was missing - if(MAP_PIXEL == getGraphicObject().GetPrefMapMode().GetMapUnit()) + if(MAP_PIXEL == rGraphicObject.GetPrefMapMode().GetMapUnit()) { aBitmapSize = Application::GetDefaultDevice()->PixelToLogic(aBitmapSize, aMapMode100thmm); } else { - aBitmapSize = Application::GetDefaultDevice()->LogicToLogic(aBitmapSize, getGraphicObject().GetPrefMapMode(), aMapMode100thmm); + aBitmapSize = Application::GetDefaultDevice()->LogicToLogic(aBitmapSize, rGraphicObject.GetPrefMapMode(), aMapMode100thmm); } const double fDivX(aBitmapSize.Width() - getGraphicAttr().GetLeftCrop() - getGraphicAttr().GetRightCrop()); diff --git a/drawinglayer/source/primitive2d/makefile.mk b/drawinglayer/source/primitive2d/makefile.mk index 720769a0ef..77e59dca24 100644 --- a/drawinglayer/source/primitive2d/makefile.mk +++ b/drawinglayer/source/primitive2d/makefile.mk @@ -42,6 +42,7 @@ SLOFILES= \ $(SLO)$/baseprimitive2d.obj \ $(SLO)$/backgroundcolorprimitive2d.obj \ $(SLO)$/bitmapprimitive2d.obj \ + $(SLO)$/rendergraphicprimitive2d.obj \ $(SLO)$/borderlineprimitive2d.obj \ $(SLO)$/chartprimitive2d.obj \ $(SLO)$/controlprimitive2d.obj \ diff --git a/drawinglayer/source/primitive2d/metafileprimitive2d.cxx b/drawinglayer/source/primitive2d/metafileprimitive2d.cxx index 41af340084..208a95da71 100644 --- a/drawinglayer/source/primitive2d/metafileprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/metafileprimitive2d.cxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -63,6 +63,7 @@ #include <drawinglayer/primitive2d/textlineprimitive2d.hxx> #include <drawinglayer/primitive2d/textstrikeoutprimitive2d.hxx> #include <drawinglayer/primitive2d/epsprimitive2d.hxx> +#include <drawinglayer/primitive2d/rendergraphicprimitive2d.hxx> #include <numeric> ////////////////////////////////////////////////////////////////////////////// @@ -155,7 +156,7 @@ namespace void setLineColor(const basegfx::BColor& rNew) { if(rNew != maLineColor) maLineColor = rNew; } bool getLineColorActive() const { return mbLineColor; } void setLineColorActive(bool bNew) { if(bNew != mbLineColor) mbLineColor = bNew; } - + const basegfx::BColor& getFillColor() const { return maFillColor; } void setFillColor(const basegfx::BColor& rNew) { if(rNew != maFillColor) maFillColor = rNew; } bool getFillColorActive() const { return mbFillColor; } @@ -397,13 +398,13 @@ namespace { RegionHandle aRegionHandle(aRegion.BeginEnumRects()); Rectangle aRegionRectangle; - + while(aRegion.GetEnumRects(aRegionHandle, aRegionRectangle)) { if(!aRegionRectangle.IsEmpty()) { const basegfx::B2DRange aRegionRange( - aRegionRectangle.Left(), aRegionRectangle.Top(), + aRegionRectangle.Left(), aRegionRectangle.Top(), aRegionRectangle.Right(), aRegionRectangle.Bottom()); aRetval.append(basegfx::tools::createPolygonFromRect(aRegionRange)); } @@ -473,7 +474,7 @@ namespace // All Targets were pointers, but do not need to be deleted since they // were converted to UNO API references now, so they stay as long as - // referenced. Do NOT delete the C++ implementation classes here, but clear + // referenced. Do NOT delete the C++ implementation classes here, but clear // the buffer to not delete them in the destructor. aTargets.clear(); @@ -487,7 +488,7 @@ namespace new drawinglayer::primitive2d::MaskPrimitive2D( rClipPolyPolygon, xRetval)); - + xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xMask, 1); } } @@ -576,7 +577,7 @@ namespace drawinglayer public: /// constructor NonOverlappingFillGradientPrimitive2D( - const basegfx::B2DRange& rObjectRange, + const basegfx::B2DRange& rObjectRange, const attribute::FillGradientAttribute& rFillGradient) : FillGradientPrimitive2D(rObjectRange, rFillGradient) { @@ -617,7 +618,7 @@ namespace if(rMapMode.GetScaleX() != aNoScale || rMapMode.GetScaleY() != aNoScale) { aMapping.scale( - double(rMapMode.GetScaleX()), + double(rMapMode.GetScaleX()), double(rMapMode.GetScaleY())); } @@ -626,8 +627,8 @@ namespace /** helper to create a PointArrayPrimitive2D based on current context */ void createPointArrayPrimitive( - const std::vector< basegfx::B2DPoint >& rPositions, - TargetHolder& rTarget, + const std::vector< basegfx::B2DPoint >& rPositions, + TargetHolder& rTarget, PropertyHolder& rProperties, basegfx::BColor aBColor) { @@ -660,7 +661,7 @@ namespace /** helper to create a PolygonHairlinePrimitive2D based on current context */ void createHairlinePrimitive( const basegfx::B2DPolygon& rLinePolygon, - TargetHolder& rTarget, + TargetHolder& rTarget, PropertyHolder& rProperties) { if(rLinePolygon.count()) @@ -677,7 +678,7 @@ namespace /** helper to create a PolyPolygonColorPrimitive2D based on current context */ void createFillPrimitive( const basegfx::B2DPolyPolygon& rFillPolyPolygon, - TargetHolder& rTarget, + TargetHolder& rTarget, PropertyHolder& rProperties) { if(rFillPolyPolygon.count()) @@ -694,8 +695,8 @@ namespace /** helper to create a PolygonStrokePrimitive2D based on current context */ void createLinePrimitive( const basegfx::B2DPolygon& rLinePolygon, - const LineInfo& rLineInfo, - TargetHolder& rTarget, + const LineInfo& rLineInfo, + TargetHolder& rTarget, PropertyHolder& rProperties) { if(rLinePolygon.count()) @@ -760,14 +761,14 @@ namespace /** helper to create needed line and fill primitives based on current context */ void createHairlineAndFillPrimitive( const basegfx::B2DPolygon& rPolygon, - TargetHolder& rTarget, + TargetHolder& rTarget, PropertyHolder& rProperties) { if(rProperties.getFillColorActive()) { createFillPrimitive(basegfx::B2DPolyPolygon(rPolygon), rTarget, rProperties); } - + if(rProperties.getLineColorActive()) { createHairlinePrimitive(rPolygon, rTarget, rProperties); @@ -777,14 +778,14 @@ namespace /** helper to create needed line and fill primitives based on current context */ void createHairlineAndFillPrimitive( const basegfx::B2DPolyPolygon& rPolyPolygon, - TargetHolder& rTarget, + TargetHolder& rTarget, PropertyHolder& rProperties) { if(rProperties.getFillColorActive()) { createFillPrimitive(rPolyPolygon, rTarget, rProperties); } - + if(rProperties.getLineColorActive()) { for(sal_uInt32 a(0); a < rPolyPolygon.count(); a++) @@ -801,16 +802,16 @@ namespace transformed embedding of a BitmapPrimitive2D. */ void createBitmapExPrimitive( - const BitmapEx& rBitmapEx, + const BitmapEx& rBitmapEx, const Point& rPoint, - TargetHolder& rTarget, + TargetHolder& rTarget, PropertyHolder& rProperties) { if(!rBitmapEx.IsEmpty()) { basegfx::B2DPoint aPoint(rPoint.X(), rPoint.Y()); aPoint = rProperties.getTransformation() * aPoint; - + rTarget.append( new drawinglayer::primitive2d::DiscreteBitmapPrimitive2D( rBitmapEx, @@ -820,23 +821,23 @@ namespace /** helper to create BitmapPrimitive2D based on current context */ void createBitmapExPrimitive( - const BitmapEx& rBitmapEx, + const BitmapEx& rBitmapEx, const Point& rPoint, const Size& rSize, - TargetHolder& rTarget, + TargetHolder& rTarget, PropertyHolder& rProperties) { if(!rBitmapEx.IsEmpty()) { basegfx::B2DHomMatrix aObjectTransform; - + aObjectTransform.set(0, 0, rSize.Width()); aObjectTransform.set(1, 1, rSize.Height()); aObjectTransform.set(0, 2, rPoint.X()); aObjectTransform.set(1, 2, rPoint.Y()); - + aObjectTransform = rProperties.getTransformation() * aObjectTransform; - + rTarget.append( new drawinglayer::primitive2d::BitmapPrimitive2D( rBitmapEx, @@ -846,21 +847,21 @@ namespace /** helper to create a regular BotmapEx from a MaskAction (definitions which use a bitmap without transparence but define one of the colors as - transparent) + transparent) */ BitmapEx createMaskBmpEx(const Bitmap& rBitmap, const Color& rMaskColor) { const Color aWhite(COL_WHITE); BitmapPalette aBiLevelPalette(2); - + aBiLevelPalette[0] = aWhite; aBiLevelPalette[1] = rMaskColor; Bitmap aMask(rBitmap.CreateMask(aWhite)); Bitmap aSolid(rBitmap.GetSizePixel(), 1, &aBiLevelPalette); - + aSolid.Erase(rMaskColor); - + return BitmapEx(aSolid, aMask); } @@ -872,7 +873,7 @@ namespace const Color aStartColor(rGradient.GetStartColor()); const sal_uInt16 nStartIntens(rGradient.GetStartIntensity()); basegfx::BColor aStart(aStartColor.getBColor()); - + if(nStartIntens != 100) { const basegfx::BColor aBlack; @@ -882,7 +883,7 @@ namespace const Color aEndColor(rGradient.GetEndColor()); const sal_uInt16 nEndIntens(rGradient.GetEndIntensity()); basegfx::BColor aEnd(aEndColor.getBColor()); - + if(nEndIntens != 100) { const basegfx::BColor aBlack; @@ -893,29 +894,29 @@ namespace switch(rGradient.GetStyle()) { - case GRADIENT_LINEAR : + case GRADIENT_LINEAR : { aGradientStyle = drawinglayer::attribute::GRADIENTSTYLE_LINEAR; break; } - case GRADIENT_AXIAL : + case GRADIENT_AXIAL : { aGradientStyle = drawinglayer::attribute::GRADIENTSTYLE_AXIAL; break; } - case GRADIENT_RADIAL : + case GRADIENT_RADIAL : { aGradientStyle = drawinglayer::attribute::GRADIENTSTYLE_RADIAL; break; } - case GRADIENT_ELLIPTICAL : + case GRADIENT_ELLIPTICAL : { aGradientStyle = drawinglayer::attribute::GRADIENTSTYLE_ELLIPTICAL; break; } - case GRADIENT_SQUARE : + case GRADIENT_SQUARE : { - aGradientStyle = drawinglayer::attribute::GRADIENTSTYLE_SQUARE; + aGradientStyle = drawinglayer::attribute::GRADIENTSTYLE_SQUARE; break; } default : // GRADIENT_RECT @@ -945,14 +946,14 @@ namespace switch(rHatch.GetStyle()) { - default : // case HATCH_SINGLE : + default : // case HATCH_SINGLE : { - aHatchStyle = drawinglayer::attribute::HATCHSTYLE_SINGLE; + aHatchStyle = drawinglayer::attribute::HATCHSTYLE_SINGLE; break; } - case HATCH_DOUBLE : + case HATCH_DOUBLE : { - aHatchStyle = drawinglayer::attribute::HATCHSTYLE_DOUBLE; + aHatchStyle = drawinglayer::attribute::HATCHSTYLE_DOUBLE; break; } case HATCH_TRIPLE : @@ -961,7 +962,7 @@ namespace break; } } - + return drawinglayer::attribute::FillHatchAttribute( aHatchStyle, (double)rHatch.GetDistance(), @@ -991,7 +992,7 @@ namespace // // This ClipPolyPolygon is identical to the current one, so there is no need to // create a MaskPrimitive2D containing the up-to-now created primitives, but - // this was done before. While this does not lead to wrong primitive + // this was done before. While this does not lead to wrong primitive // representations of the metafile data, it creates unneccesarily expensive // representations. Just detecting when no really 'new' ClipPolyPolygon gets set // solves the problem. @@ -1015,7 +1016,7 @@ namespace // Here the old and the new are definitively different, maybe // old one and/or new one is not active. - // Handle deletion of old ClipPolyPolygon. The process evtl. created primitives which + // Handle deletion of old ClipPolyPolygon. The process evtl. created primitives which // belong to this active ClipPolyPolygon. These need to be embedded to a // MaskPrimitive2D accordingly. if(rPropertyHolders.Current().getClipPolyPolygonActive() && rTargetHolders.size() > 1) @@ -1140,7 +1141,7 @@ namespace else { // really a gradient - drawinglayer::primitive2d::BasePrimitive2D* pRetval = + drawinglayer::primitive2d::BasePrimitive2D* pRetval = new drawinglayer::primitive2d::FillGradientPrimitive2D( rRange, aAttribute); @@ -1201,7 +1202,7 @@ namespace if(rWallpaper.IsRect() && !rWallpaper.GetRect().IsEmpty()) { aWallpaperRange = basegfx::B2DRange( - rWallpaper.GetRect().Left(), rWallpaper.GetRect().Top(), + rWallpaper.GetRect().Left(), rWallpaper.GetRect().Top(), rWallpaper.GetRect().Right(), rWallpaper.GetRect().Bottom()); } @@ -1210,7 +1211,7 @@ namespace aWallpaperRange, aBitmapEx, eWallpaperStyle); - + if(rProperty.getTransformation().isIdentity()) { // add directly @@ -1373,7 +1374,7 @@ namespace // TextDecoratedPortionPrimitive2D is needed, create one pResult = new drawinglayer::primitive2d::TextDecoratedPortionPrimitive2D( - + // attributes for TextSimplePortionPrimitive2D aTextTransform, rText, @@ -1435,7 +1436,7 @@ namespace { // build text range const basegfx::B2DRange aTextRange( - 0.0, -aTextLayouterDevice.getFontAscent(), + 0.0, -aTextLayouterDevice.getFontAscent(), fTextWidth, aTextLayouterDevice.getFontDescent()); // create Transform @@ -1556,7 +1557,7 @@ namespace if(bStrikeoutUsed) { // create primitive geometry for strikeout - if(drawinglayer::primitive2d::TEXT_STRIKEOUT_SLASH == aTextStrikeout + if(drawinglayer::primitive2d::TEXT_STRIKEOUT_SLASH == aTextStrikeout || drawinglayer::primitive2d::TEXT_STRIKEOUT_X == aTextStrikeout) { // strikeout with character @@ -1641,9 +1642,9 @@ namespace I have marked the single MetaActions with: - SIMPLE, DONE: + SIMPLE, DONE: Simple, e.g nothing to do or value setting in the context - + CHECKED, WORKS WELL: Thoroughly tested with extra written test code which created a replacement Metafile just to test this action in various combinations @@ -1752,7 +1753,7 @@ namespace if(aLinePolygon.count()) { - if(pA->GetLineInfo() == aLineInfo + if(pA->GetLineInfo() == aLineInfo && aStart == aLinePolygon.getB2DPoint(aLinePolygon.count() - 1)) { aLinePolygon.append(aEnd); @@ -1773,7 +1774,7 @@ namespace aLinePolygon.append(aStart); aLinePolygon.append(aEnd); } - + nAction++; if(nAction < nCount) pAction = rMetaFile.GetAction(nAction); } @@ -1815,7 +1816,7 @@ namespace /** CHECKED, WORKS WELL */ /** The original OutputDevice::DrawRect paints nothing when nHor or nVer is zero; but just because the tools::Polygon operator creating the rounding does produce nonsense. I assume - this an error and create an unrounded rectangle in that case (implicit in + this an error and create an unrounded rectangle in that case (implicit in createPolygonFromRect) */ if(rPropertyHolders.Current().getLineOrFillActive()) @@ -1826,7 +1827,7 @@ namespace if(!rRectangle.IsEmpty()) { const basegfx::B2DRange aRange(rRectangle.Left(), rRectangle.Top(), rRectangle.Right(), rRectangle.Bottom()); - + if(!aRange.isEmpty()) { const sal_uInt32 nHor(pA->GetHorzRound()); @@ -2019,7 +2020,7 @@ namespace { nTextLength = nTextIndex > nStringLength ? 0 : nStringLength - nTextIndex; } - + if(nTextLength && rPropertyHolders.Current().getTextColorActive()) { // preapare DXArray (if used) @@ -2035,7 +2036,7 @@ namespace aDXArray.push_back((double)(*(pDXArray + a))); } } - + proccessMetaTextAction( pA->GetPoint(), pA->GetText(), @@ -2056,7 +2057,7 @@ namespace // Implemented getting the DXArray and checking for scale at all. If // scale is more than 3.5% different, scale the DXArray before usage. // New status: - + /** CHECKED, WORKS WELL */ const MetaStretchTextAction* pA = (const MetaStretchTextAction*)pAction; sal_uInt32 nTextLength(pA->GetLen()); @@ -2067,7 +2068,7 @@ namespace { nTextLength = nStringLength - nTextIndex; } - + if(nTextLength && rPropertyHolders.Current().getTextColorActive()) { drawinglayer::primitive2d::TextLayouterDevice aTextLayouterDevice; @@ -2108,7 +2109,7 @@ namespace rTargetHolders.Current(), rPropertyHolders.Current()); } - + break; } case META_TEXTRECT_ACTION : @@ -2118,7 +2119,7 @@ namespace const MetaTextRectAction* pA = (const MetaTextRectAction*)pAction; const Rectangle& rRectangle = pA->GetRect(); const sal_uInt32 nStringLength(pA->GetText().Len()); - + if(!rRectangle.IsEmpty() && 0 != nStringLength) { // The problem with this action is that it describes unlayouted text @@ -2284,7 +2285,7 @@ namespace { aCroppedBitmap.Crop(aCropRectangle); } - + const BitmapEx aCroppedBitmapEx(createMaskBmpEx(aCroppedBitmap, pA->GetColor())); createBitmapExPrimitive(aCroppedBitmapEx, pA->GetDestPoint(), pA->GetDestSize(), rTargetHolders.Current(), rPropertyHolders.Current()); } @@ -2306,13 +2307,13 @@ namespace const Gradient& rGradient = pA->GetGradient(); const drawinglayer::attribute::FillGradientAttribute aAttribute(createFillGradientAttribute(rGradient)); basegfx::B2DPolyPolygon aOutline(basegfx::tools::createPolygonFromRect(aRange)); - + if(aAttribute.getStartColor() == aAttribute.getEndColor()) { // not really a gradient. Create filled rectangle createFillPrimitive( - aOutline, - rTargetHolders.Current(), + aOutline, + rTargetHolders.Current(), rPropertyHolders.Current()); } else @@ -2386,13 +2387,13 @@ namespace /** CHECKED, WORKS WELL */ const MetaWallpaperAction* pA = (const MetaWallpaperAction*)pAction; Rectangle aWallpaperRectangle(pA->GetRect()); - + if(!aWallpaperRectangle.IsEmpty()) { const Wallpaper& rWallpaper = pA->GetWallpaper(); const WallpaperStyle eWallpaperStyle(rWallpaper.GetStyle()); basegfx::B2DRange aWallpaperRange( - aWallpaperRectangle.Left(), aWallpaperRectangle.Top(), + aWallpaperRectangle.Left(), aWallpaperRectangle.Top(), aWallpaperRectangle.Right(), aWallpaperRectangle.Bottom()); if(WALLPAPER_NULL != eWallpaperStyle) @@ -2440,7 +2441,7 @@ namespace { // new clipping. Get PolyPolygon and transform with current transformation basegfx::B2DPolyPolygon aNewClipPolyPolygon(getB2DPolyPolygonFromRegion(pA->GetRegion())); - + aNewClipPolyPolygon.transform(rPropertyHolders.Current().getTransformation()); HandleNewClipRegion(aNewClipPolyPolygon, rTargetHolders, rPropertyHolders); } @@ -2448,7 +2449,7 @@ namespace { // end clipping const basegfx::B2DPolyPolygon aEmptyPolyPolygon; - + HandleNewClipRegion(aEmptyPolyPolygon, rTargetHolders, rPropertyHolders); } @@ -2465,7 +2466,7 @@ namespace // intersect with empty rectangle will always give empty // ClipPolyPolygon; start new clipping with empty PolyPolygon const basegfx::B2DPolyPolygon aEmptyPolyPolygon; - + HandleNewClipRegion(aEmptyPolyPolygon, rTargetHolders, rPropertyHolders); } else @@ -2494,18 +2495,18 @@ namespace if(aOriginalPolyPolygon.count()) { aClippedPolyPolygon = basegfx::tools::clipPolyPolygonOnRange( - aOriginalPolyPolygon, - aClipRange, - true, + aOriginalPolyPolygon, + aClipRange, + true, false); } - + if(aClippedPolyPolygon != aOriginalPolyPolygon) { // start new clipping with intersected region HandleNewClipRegion( - aClippedPolyPolygon, - rTargetHolders, + aClippedPolyPolygon, + rTargetHolders, rPropertyHolders); } } @@ -2533,7 +2534,7 @@ namespace // intersect with empty region will always give empty // region; start new clipping with empty PolyPolygon const basegfx::B2DPolyPolygon aEmptyPolyPolygon; - + HandleNewClipRegion(aEmptyPolyPolygon, rTargetHolders, rPropertyHolders); } else @@ -2561,7 +2562,7 @@ namespace aClippedPolyPolygon = basegfx::tools::clipPolyPolygonOnPolyPolygon( aOriginalPolyPolygon, aNewClipPolyPolygon, true, false); } - + if(aClippedPolyPolygon != aOriginalPolyPolygon) { // start new clipping with intersected ClipPolyPolygon @@ -2611,7 +2612,7 @@ namespace } } } - + break; } case META_LINECOLOR_ACTION : @@ -2619,11 +2620,11 @@ namespace /** CHECKED, WORKS WELL */ const MetaLineColorAction* pA = (const MetaLineColorAction*)pAction; const bool bActive(pA->IsSetting()); - + rPropertyHolders.Current().setLineColorActive(bActive); if(bActive) rPropertyHolders.Current().setLineColor(pA->GetColor().getBColor()); - + break; } case META_FILLCOLOR_ACTION : @@ -2676,7 +2677,7 @@ namespace const MetaTextAlignAction* pA = (const MetaTextAlignAction*)pAction; const TextAlign aNewTextAlign = pA->GetTextAlign(); - // TextAlign is applied to the current font (as in + // TextAlign is applied to the current font (as in // OutputDevice::SetTextAlign which would be used when // playing the Metafile) if(rPropertyHolders.Current().getFont().GetAlign() != aNewTextAlign) @@ -2736,7 +2737,7 @@ namespace aMapping = getTransformFromMapMode(rMapMode) * aMapping; rPropertyHolders.Current().setMapUnit(rMapMode.GetMapUnit()); } - + if(!aMapping.isIdentity()) { aMapping = aMapping * rPropertyHolders.Current().getTransformation(); @@ -2778,7 +2779,7 @@ namespace { rPropertyHolders.Current().setTextColor(rFontColor.getBColor()); } - + // caution: do NOT decativate here on transparet, see // OutputDevice::SetFont(..) for more info // rPropertyHolders.Current().setTextColorActive(bActivate); @@ -2811,7 +2812,7 @@ namespace /** CHECKED, WORKS WELL */ const bool bRegionMayChange(rPropertyHolders.Current().getPushFlags() & PUSH_CLIPREGION); const bool bRasterOpMayChange(rPropertyHolders.Current().getPushFlags() & PUSH_RASTEROP); - + if(bRegionMayChange && rPropertyHolders.Current().getClipPolyPolygonActive()) { // end evtl. clipping @@ -2819,7 +2820,7 @@ namespace HandleNewClipRegion(aEmptyPolyPolygon, rTargetHolders, rPropertyHolders); } - + if(bRasterOpMayChange && rPropertyHolders.Current().isRasterOpActive()) { // end evtl. RasterOp @@ -2884,7 +2885,7 @@ namespace // back to old target rTargetHolders.Pop(); - + if(aSubContent.hasElements()) { rTargetHolders.Current().append( @@ -2916,7 +2917,7 @@ namespace aObjectTransform.set(1, 1, aRectangle.GetHeight()); aObjectTransform.set(0, 2, aRectangle.Left()); aObjectTransform.set(1, 2, aRectangle.Top()); - + // add current transformation aObjectTransform = rPropertyHolders.Current().getTransformation() * aObjectTransform; @@ -2927,7 +2928,7 @@ namespace pA->GetLink(), pA->GetSubstitute())); } - + break; } case META_REFPOINT_ACTION : @@ -2961,9 +2962,9 @@ namespace // checked files). It's used in combination with the current // Font. const MetaTextLineAction* pA = (const MetaTextLineAction*)pAction; - + proccessMetaTextLineAction( - *pA, + *pA, rTargetHolders.Current(), rPropertyHolders.Current()); @@ -2999,7 +3000,7 @@ namespace // check if gradient is a real gradient const Gradient& rGradient = pA->GetGradient(); const drawinglayer::attribute::FillGradientAttribute aAttribute(createFillGradientAttribute(rGradient)); - + if(aAttribute.getStartColor() == aAttribute.getEndColor()) { // not really a gradient; create UnifiedTransparencePrimitive2D @@ -3012,16 +3013,16 @@ namespace { // really a gradient. Create gradient sub-content (with correct scaling) basegfx::B2DRange aRange( - aTargetRectangle.Left(), aTargetRectangle.Top(), + aTargetRectangle.Left(), aTargetRectangle.Top(), aTargetRectangle.Right(), aTargetRectangle.Bottom()); aRange.transform(rPropertyHolders.Current().getTransformation()); // prepare gradient for transparent content const drawinglayer::primitive2d::Primitive2DReference xTransparence( new drawinglayer::primitive2d::FillGradientPrimitive2D( - aRange, + aRange, aAttribute)); - + // create transparence primitive rTargetHolders.Current().append( new drawinglayer::primitive2d::TransparencePrimitive2D( @@ -3068,10 +3069,37 @@ namespace break; } + case META_RENDERGRAPHIC_ACTION : + { + const MetaRenderGraphicAction* pA = (const MetaRenderGraphicAction*)pAction; + const Rectangle aRectangle(pA->GetPoint(), pA->GetSize()); + + if(!aRectangle.IsEmpty()) + { + // create object transform + basegfx::B2DHomMatrix aObjectTransform; + + aObjectTransform.set(0, 0, aRectangle.GetWidth()); + aObjectTransform.set(1, 1, aRectangle.GetHeight()); + aObjectTransform.set(0, 2, aRectangle.Left()); + aObjectTransform.set(1, 2, aRectangle.Top()); + + // add current transformation + aObjectTransform = rPropertyHolders.Current().getTransformation() * aObjectTransform; + + // embed using EpsPrimitive + rTargetHolders.Current().append( + new drawinglayer::primitive2d::RenderGraphicPrimitive2D( + pA->GetRenderGraphic(), + aObjectTransform ) ); + } + + break; + } case META_COMMENT_ACTION : { /** CHECKED, WORKS WELL */ - // I already implemented + // I already implemented // XPATHFILL_SEQ_BEGIN, XPATHFILL_SEQ_END // XPATHSTROKE_SEQ_BEGIN, XPATHSTROKE_SEQ_END, // but opted to remove these again; it works well without them @@ -3117,11 +3145,11 @@ namespace { // transform geometry aPolyPolygon.transform(rPropertyHolders.Current().getTransformation()); - + // get and check if gradient is a real gradient const Gradient& rGradient = pMetaGradientExAction->GetGradient(); const drawinglayer::attribute::FillGradientAttribute aAttribute(createFillGradientAttribute(rGradient)); - + if(aAttribute.getStartColor() == aAttribute.getEndColor()) { // not really a gradient @@ -3178,12 +3206,12 @@ namespace drawinglayer while(aTargetHolders.size() > 1) { - appendPrimitive2DSequenceToPrimitive2DSequence(xRetval, + appendPrimitive2DSequenceToPrimitive2DSequence(xRetval, aTargetHolders.Current().getPrimitive2DSequence(aPropertyHolders.Current())); aTargetHolders.Pop(); } - - appendPrimitive2DSequenceToPrimitive2DSequence(xRetval, + + appendPrimitive2DSequenceToPrimitive2DSequence(xRetval, aTargetHolders.Current().getPrimitive2DSequence(aPropertyHolders.Current())); if(xRetval.hasElements()) @@ -3213,7 +3241,7 @@ namespace drawinglayer } MetafilePrimitive2D::MetafilePrimitive2D( - const basegfx::B2DHomMatrix& rMetaFileTransform, + const basegfx::B2DHomMatrix& rMetaFileTransform, const GDIMetaFile& rMetaFile) : BufferedDecompositionPrimitive2D(), maMetaFileTransform(rMetaFileTransform), @@ -3227,7 +3255,7 @@ namespace drawinglayer { const MetafilePrimitive2D& rCompare = (MetafilePrimitive2D&)rPrimitive; - return (getTransform() == rCompare.getTransform() + return (getTransform() == rCompare.getTransform() && getMetaFile() == rCompare.getMetaFile()); } diff --git a/drawinglayer/source/primitive2d/rendergraphicprimitive2d.cxx b/drawinglayer/source/primitive2d/rendergraphicprimitive2d.cxx new file mode 100644 index 0000000000..c58990a420 --- /dev/null +++ b/drawinglayer/source/primitive2d/rendergraphicprimitive2d.cxx @@ -0,0 +1,92 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_drawinglayer.hxx" + +#include <drawinglayer/primitive2d/rendergraphicprimitive2d.hxx> +#include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx> +#include <basegfx/tools/canvastools.hxx> +#include <vcl/rendergraphicrasterizer.hxx> + +////////////////////////////////////////////////////////////////////////////// + +using namespace com::sun::star; + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive2d + { + RenderGraphicPrimitive2D::RenderGraphicPrimitive2D( + const vcl::RenderGraphic& rRenderGraphic, + const basegfx::B2DHomMatrix& rTransform) + : BasePrimitive2D(), + maRenderGraphic(rRenderGraphic), + maTransform(rTransform) + { + } + + void RenderGraphicPrimitive2D::setCurrentRasterizer() const + { + mapCurrentRasterizer.reset(); + } + + void RenderGraphicPrimitive2D::setCurrentRasterizer( const vcl::RenderGraphicRasterizer& rCurrentRasterizer ) const + { + mapCurrentRasterizer.reset( new vcl::RenderGraphicRasterizer( rCurrentRasterizer ) ); + } + + bool RenderGraphicPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const + { + if(BasePrimitive2D::operator==(rPrimitive)) + { + const RenderGraphicPrimitive2D& rCompare = (RenderGraphicPrimitive2D&)rPrimitive; + + return (getRenderGraphic() == rCompare.getRenderGraphic() + && getTransform() == rCompare.getTransform()); + } + + return false; + } + + basegfx::B2DRange RenderGraphicPrimitive2D::getB2DRange(const geometry::ViewInformation2D& /*rViewInformation*/) const + { + basegfx::B2DRange aRetval(0.0, 0.0, 1.0, 1.0); + aRetval.transform(maTransform); + return aRetval; + } + + // provide unique ID + ImplPrimitrive2DIDBlock(RenderGraphicPrimitive2D, PRIMITIVE2D_ID_RENDERGRAPHICPRIMITIVE2D) + + } // end of namespace primitive2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/drawinglayer/source/processor2d/hittestprocessor2d.cxx b/drawinglayer/source/processor2d/hittestprocessor2d.cxx index 9502df95a3..589c2e814d 100644 --- a/drawinglayer/source/processor2d/hittestprocessor2d.cxx +++ b/drawinglayer/source/processor2d/hittestprocessor2d.cxx @@ -528,6 +528,8 @@ namespace drawinglayer case PRIMITIVE2D_ID_FILLGRADIENTPRIMITIVE2D : case PRIMITIVE2D_ID_FILLHATCHPRIMITIVE2D : case PRIMITIVE2D_ID_PAGEPREVIEWPRIMITIVE2D : + case PRIMITIVE2D_ID_MEDIAPRIMITIVE2D: + case PRIMITIVE2D_ID_RENDERGRAPHICPRIMITIVE2D: { if(!getHitTextOnly()) { diff --git a/drawinglayer/source/processor2d/linegeometryextractor2d.cxx b/drawinglayer/source/processor2d/linegeometryextractor2d.cxx index cdf64d5e43..68d1b4942c 100644 --- a/drawinglayer/source/processor2d/linegeometryextractor2d.cxx +++ b/drawinglayer/source/processor2d/linegeometryextractor2d.cxx @@ -123,6 +123,7 @@ namespace drawinglayer case PRIMITIVE2D_ID_MARKERARRAYPRIMITIVE2D : case PRIMITIVE2D_ID_POINTARRAYPRIMITIVE2D : case PRIMITIVE2D_ID_BITMAPPRIMITIVE2D : + case PRIMITIVE2D_ID_RENDERGRAPHICPRIMITIVE2D : case PRIMITIVE2D_ID_METAFILEPRIMITIVE2D : case PRIMITIVE2D_ID_MASKPRIMITIVE2D : { diff --git a/drawinglayer/source/processor2d/textaspolygonextractor2d.cxx b/drawinglayer/source/processor2d/textaspolygonextractor2d.cxx index e36f76765f..c3ac630fa4 100644 --- a/drawinglayer/source/processor2d/textaspolygonextractor2d.cxx +++ b/drawinglayer/source/processor2d/textaspolygonextractor2d.cxx @@ -214,6 +214,7 @@ namespace drawinglayer case PRIMITIVE2D_ID_MARKERARRAYPRIMITIVE2D : case PRIMITIVE2D_ID_POINTARRAYPRIMITIVE2D : case PRIMITIVE2D_ID_BITMAPPRIMITIVE2D : + case PRIMITIVE2D_ID_RENDERGRAPHICPRIMITIVE2D : case PRIMITIVE2D_ID_METAFILEPRIMITIVE2D : case PRIMITIVE2D_ID_MASKPRIMITIVE2D : { diff --git a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx index 5846c9b620..e1ec446ce0 100644 --- a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx @@ -38,6 +38,7 @@ #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx> #include <drawinglayer/primitive2d/polygonprimitive2d.hxx> #include <drawinglayer/primitive2d/bitmapprimitive2d.hxx> +#include <drawinglayer/primitive2d/rendergraphicprimitive2d.hxx> #include <drawinglayer/primitive2d/metafileprimitive2d.hxx> #include <drawinglayer/primitive2d/maskprimitive2d.hxx> #include <basegfx/polygon/b2dpolygonclipper.hxx> @@ -1287,6 +1288,12 @@ namespace drawinglayer RenderBitmapPrimitive2D(static_cast< const primitive2d::BitmapPrimitive2D& >(rCandidate)); break; } + case PRIMITIVE2D_ID_RENDERGRAPHICPRIMITIVE2D : + { + // direct draw of transformed RenderGraphic primitive; use default processing + RenderRenderGraphicPrimitive2D(static_cast< const primitive2d::RenderGraphicPrimitive2D& >(rCandidate)); + break; + } case PRIMITIVE2D_ID_POLYPOLYGONBITMAPPRIMITIVE2D : { // need to handle PolyPolygonBitmapPrimitive2D here to support XPATHFILL_SEQ_BEGIN/XPATHFILL_SEQ_END diff --git a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx index c21f3bc87a..6eba230632 100644 --- a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx @@ -35,6 +35,7 @@ #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx> #include <drawinglayer/primitive2d/polygonprimitive2d.hxx> #include <drawinglayer/primitive2d/bitmapprimitive2d.hxx> +#include <drawinglayer/primitive2d/rendergraphicprimitive2d.hxx> #include <drawinglayer/primitive2d/fillbitmapprimitive2d.hxx> #include <drawinglayer/primitive2d/metafileprimitive2d.hxx> #include <drawinglayer/primitive2d/maskprimitive2d.hxx> @@ -193,6 +194,12 @@ namespace drawinglayer RenderBitmapPrimitive2D(static_cast< const primitive2d::BitmapPrimitive2D& >(rCandidate)); break; } + case PRIMITIVE2D_ID_RENDERGRAPHICPRIMITIVE2D : + { + // direct draw of transformed BitmapEx primitive + RenderRenderGraphicPrimitive2D(static_cast< const primitive2d::RenderGraphicPrimitive2D& >(rCandidate)); + break; + } case PRIMITIVE2D_ID_FILLBITMAPPRIMITIVE2D : { // direct draw of fillBitmapPrimitive diff --git a/drawinglayer/source/processor2d/vclprocessor2d.cxx b/drawinglayer/source/processor2d/vclprocessor2d.cxx index 71bb587339..550d1da105 100644 --- a/drawinglayer/source/processor2d/vclprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclprocessor2d.cxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -35,6 +35,7 @@ #include <vcl/outdev.hxx> #include <drawinglayer/primitive2d/polygonprimitive2d.hxx> #include <drawinglayer/primitive2d/bitmapprimitive2d.hxx> +#include <drawinglayer/primitive2d/rendergraphicprimitive2d.hxx> #include <vclhelperbitmaptransform.hxx> #include <basegfx/polygon/b2dpolygontools.hxx> #include <vclhelperbitmaprender.hxx> @@ -60,6 +61,7 @@ #include <vcl/metric.hxx> #include <drawinglayer/primitive2d/textenumsprimitive2d.hxx> #include <drawinglayer/primitive2d/epsprimitive2d.hxx> +#include <vcl/rendergraphicrasterizer.hxx> ////////////////////////////////////////////////////////////////////////////// // control support @@ -128,9 +130,9 @@ namespace drawinglayer { // Get the VCL font (use FontHeight as FontWidth) Font aFont(primitive2d::getVclFontFromFontAttribute( - rTextCandidate.getFontAttribute(), - aFontScaling.getX(), - aFontScaling.getY(), + rTextCandidate.getFontAttribute(), + aFontScaling.getX(), + aFontScaling.getY(), fRotate, rTextCandidate.getLocale())); @@ -140,7 +142,7 @@ namespace drawinglayer if( pTCPP != NULL ) { - + // set the color of text decorations const basegfx::BColor aTextlineColor = maBColorModifierStack.getModifiedColor(pTCPP->getTextlineColor()); mpOutputDevice->SetTextLineColor( Color(aTextlineColor) ); @@ -227,7 +229,7 @@ namespace drawinglayer const basegfx::B2DVector aPixelVector(maCurrentTransformation * basegfx::B2DVector(1.0, 0.0)); const double fPixelVectorFactor(aPixelVector.getLength()); - for(::std::vector< double >::const_iterator aStart(rTextCandidate.getDXArray().begin()); + for(::std::vector< double >::const_iterator aStart(rTextCandidate.getDXArray().begin()); aStart != rTextCandidate.getDXArray().end(); aStart++) { aTransformedDXArray.push_back(basegfx::fround((*aStart) * fPixelVectorFactor)); @@ -253,8 +255,8 @@ namespace drawinglayer if(aTransformedDXArray.size()) { mpOutputDevice->DrawTextArray( - aStartPoint, - rTextCandidate.getText(), + aStartPoint, + rTextCandidate.getText(), &(aTransformedDXArray[0]), rTextCandidate.getTextPosition(), rTextCandidate.getTextLength()); @@ -262,8 +264,8 @@ namespace drawinglayer else { mpOutputDevice->DrawText( - aStartPoint, - rTextCandidate.getText(), + aStartPoint, + rTextCandidate.getText(), rTextCandidate.getTextPosition(), rTextCandidate.getTextLength()); } @@ -302,7 +304,7 @@ namespace drawinglayer const basegfx::B2DRange& rDiscreteViewport = getViewInformation2D().getDiscreteViewport(); basegfx::B2DPolyPolygon aLocalPolyPolygon(basegfx::tools::clipPolygonOnRange( aLocalPolygon, rDiscreteViewport, true, false)); - + if(aLocalPolyPolygon.count()) { // subdivide @@ -324,7 +326,7 @@ namespace drawinglayer for(sal_uInt32 a(0); a < nCount; a++) { const basegfx::B2DPolygon aTempPolygon(aB2DTrapezoidVector[a].getB2DPolygon()); - + if(bShowOutlinesThere) { mpOutputDevice->SetFillColor(Color(aHairlineColor)); @@ -421,6 +423,75 @@ namespace drawinglayer } } + void VclProcessor2D::RenderRenderGraphicPrimitive2D(const primitive2d::RenderGraphicPrimitive2D& rRenderGraphicCandidate) + { + // create local transform + basegfx::B2DHomMatrix aLocalTransform(maCurrentTransformation * rRenderGraphicCandidate.getTransform()); + vcl::RenderGraphic aRenderGraphic(rRenderGraphicCandidate.getRenderGraphic()); + bool bPainted(false); + + if(maBColorModifierStack.count()) + { + // !!! TODO + // aRenderGraphic = impModifyRenderGraphic(maBColorModifierStack, aRenderGraphic); + + if(aRenderGraphic.IsEmpty()) + { + // color gets completely replaced, get it + const basegfx::BColor aModifiedColor(maBColorModifierStack.getModifiedColor(basegfx::BColor())); + basegfx::B2DPolygon aPolygon(basegfx::tools::createUnitPolygon()); + aPolygon.transform(aLocalTransform); + + mpOutputDevice->SetFillColor(Color(aModifiedColor)); + mpOutputDevice->SetLineColor(); + mpOutputDevice->DrawPolygon(aPolygon); + + bPainted = true; + } + } + + if(!bPainted) + { + // decompose matrix to check for shear, rotate and mirroring + basegfx::B2DVector aScale, aTranslate; + double fRotate, fShearX; + aLocalTransform.decompose(aScale, aTranslate, fRotate, fShearX); + + basegfx::B2DRange aOutlineRange(0.0, 0.0, 1.0, 1.0); + + if( basegfx::fTools::equalZero( fRotate ) ) + { + aOutlineRange.transform( aLocalTransform ); + } + else + { + // !!! TODO + // if rotated, create the unrotated output rectangle for the GraphicManager paint + /* + const basegfx::B2DHomMatrix aSimpleObjectMatrix(basegfx::tools::createScaleTranslateB2DHomMatrix( + fabs(aScale.getX()), fabs(aScale.getY()), + aTranslate.getX(), aTranslate.getY())); + + aOutlineRange.transform(aSimpleObjectMatrix); + */ + } + + // prepare dest coordinates + const Point aPoint( basegfx::fround(aOutlineRange.getMinX() ), + basegfx::fround(aOutlineRange.getMinY() ) ); + const Size aSize( basegfx::fround(aOutlineRange.getWidth() ), + basegfx::fround(aOutlineRange.getHeight() ) ); + const Size aSizePixel( mpOutputDevice->LogicToPixel( aSize ) ); + const vcl::RenderGraphicRasterizer aRasterizer( aRenderGraphic ); + const BitmapEx aBitmapEx( aRasterizer.Rasterize( aSizePixel, fRotate, fShearX ) ); + + if( !aBitmapEx.IsEmpty() ) + { + mpOutputDevice->DrawBitmapEx( aPoint, aSize, aBitmapEx ); + } + } + } + void VclProcessor2D::RenderFillBitmapPrimitive2D(const primitive2d::FillBitmapPrimitive2D& rFillBitmapCandidate) { const attribute::FillBitmapAttribute& rFillBitmapAttribute(rFillBitmapCandidate.getFillBitmap()); @@ -510,7 +581,7 @@ namespace drawinglayer // nBWidth, nBHeight is the pixel size of the neede bitmap. To not need to scale it // in vcl many times, create a size-optimized version const Size aNeededBitmapSizePixel(nBWidth, nBHeight); - + if(aNeededBitmapSizePixel != aBitmapEx.GetSizePixel()) { aBitmapEx.Scale(aNeededBitmapSizePixel); @@ -622,7 +693,7 @@ namespace drawinglayer { // with tiling, fill the whole PolyPolygon with the modifier color basegfx::B2DPolyPolygon aLocalPolyPolygon(rPolyPolygon); - + aLocalPolyPolygon.transform(maCurrentTransformation); mpOutputDevice->SetLineColor(); mpOutputDevice->SetFillColor(Color(rTopmostModifier.getBColor())); @@ -631,7 +702,7 @@ namespace drawinglayer else { // without tiling, only the area common to the bitmap tile and the - // PolyPolygon is filled. Create the bitmap tile area in object + // PolyPolygon is filled. Create the bitmap tile area in object // coordinates. For this, the object transformation needs to be created // from the already scaled PolyPolygon. The tile area in object // coordinates wil always be non-rotated, so it's not necessary to @@ -696,7 +767,7 @@ namespace drawinglayer const basegfx::B2DRange& rDiscreteViewport = getViewInformation2D().getDiscreteViewport(); aLocalPolyPolygon = basegfx::tools::clipPolyPolygonOnRange( aLocalPolyPolygon, rDiscreteViewport, true, false); - + if(aLocalPolyPolygon.count()) { // subdivide @@ -717,7 +788,7 @@ namespace drawinglayer for(sal_uInt32 a(0); a < nCount; a++) { const basegfx::B2DPolygon aTempPolygon(aB2DTrapezoidVector[a].getB2DPolygon()); - + if(bShowOutlinesThere) { mpOutputDevice->SetFillColor(Color(aPolygonColor)); @@ -740,7 +811,7 @@ namespace drawinglayer { mpOutputDevice->DrawPolyPolygon(aLocalPolyPolygon); - if(mnPolygonStrokePrimitive2D + if(mnPolygonStrokePrimitive2D && getOptionsDrawinglayer().IsAntiAliasing() && (mpOutputDevice->GetAntialiasing() & ANTIALIASING_ENABLE_B2DDRAW)) { @@ -775,7 +846,7 @@ namespace drawinglayer aScale = basegfx::absolute(aScale); fRotate += F_PI; } - + // get BoundRect basegfx::B2DRange aOutlineRange(rMetaCandidate.getB2DRange(getViewInformation2D())); aOutlineRange.transform(maCurrentTransformation); @@ -925,7 +996,7 @@ namespace drawinglayer // use decomposition process(rTransCandidate.get2DDecomposition(getViewInformation2D())); } - else + else { if(0.0 == rTransCandidate.getTransparence()) { @@ -947,7 +1018,7 @@ namespace drawinglayer // paint content to it process(rTransCandidate.getChildren()); - + // back to old OutDev mpOutputDevice = pLastOutputDevice; @@ -1073,19 +1144,19 @@ namespace drawinglayer { // get discrete half size const basegfx::B2DVector aDiscreteHalfSize( - (aBitmapSize.getWidth() - 1.0) * 0.5, + (aBitmapSize.getWidth() - 1.0) * 0.5, (aBitmapSize.getHeight() - 1.0) * 0.5); const bool bWasEnabled(mpOutputDevice->IsMapModeEnabled()); - // do not forget evtl. moved origin in target device MapMode when + // do not forget evtl. moved origin in target device MapMode when // switching it off; it would be missing and lead to wrong positions. // All his could be done using logic sizes and coordinates, too, but // we want a 1:1 bitmap rendering here, so it's more safe and faster // to work with switching off MapMode usage completely. const Point aOrigin(mpOutputDevice->GetMapMode().GetOrigin()); - + mpOutputDevice->EnableMapMode(false); - + for(std::vector< basegfx::B2DPoint >::const_iterator aIter(rPositions.begin()); aIter != rPositions.end(); aIter++) { const basegfx::B2DPoint aDiscreteTopLeft((maCurrentTransformation * (*aIter)) - aDiscreteHalfSize); @@ -1204,22 +1275,22 @@ namespace drawinglayer const double fDistance((fDiscreteLineWidth - 1.0) * 0.5); mpOutputDevice->DrawPolyLine(aCandidate, 0.0); - + aMat.set(0, 2, -fDistance); aMat.set(1, 2, 0.0); aCandidate.transform(aMat); mpOutputDevice->DrawPolyLine(aCandidate, 0.0); - + aMat.set(0, 2, fDistance); aMat.set(1, 2, -fDistance); aCandidate.transform(aMat); mpOutputDevice->DrawPolyLine(aCandidate, 0.0); - + aMat.set(0, 2, fDistance); aMat.set(1, 2, fDistance); aCandidate.transform(aMat); mpOutputDevice->DrawPolyLine(aCandidate, 0.0); - + aMat.set(0, 2, -fDistance); aMat.set(1, 2, fDistance); aCandidate.transform(aMat); @@ -1283,16 +1354,16 @@ namespace drawinglayer } } } - + if(!bDone) { // remeber that we enter a PolygonStrokePrimitive2D decomposition, // used for AA thick line drawing mnPolygonStrokePrimitive2D++; - + // line width is big enough for standard filled polygon visualisation or zero process(rPolygonStrokeCandidate.get2DDecomposition(getViewInformation2D())); - + // leave PolygonStrokePrimitive2D mnPolygonStrokePrimitive2D--; } @@ -1304,7 +1375,7 @@ namespace drawinglayer // primitive to handle embedded Eps data. On some devices, this can be // painted directly (mac, printer). // To be able to handle the replacement correctly, i need to handle it myself - // since DrawEPS will not be able e.g. to rotate the replacement. To be able + // since DrawEPS will not be able e.g. to rotate the replacement. To be able // to do that, i added a boolean return to OutputDevice::DrawEPS(..) // to know when EPS was handled directly already. basegfx::B2DRange aRange(0.0, 0.0, 1.0, 1.0); diff --git a/officecfg/registry/schema/org/openoffice/Office/Common.xcs b/officecfg/registry/schema/org/openoffice/Office/Common.xcs index ae171230dd..2475bd6f35 100644 --- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs +++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs @@ -4833,6 +4833,33 @@ <value>1</value> </prop> </group> + <group oor:name="SVG"> + <info> + <author>KA</author> + <desc>Specifies default settings of SVG export dialog.</desc> + </info> + <prop oor:name="TinyMode" oor:type="xs:boolean"> + <info> + <author>KA</author> + <desc>Specifies if SVG Tiny profile should be used for export.</desc> + </info> + <value>false</value> + </prop> + <prop oor:name="EmbedFonts" oor:type="xs:boolean"> + <info> + <author>KA</author> + <desc>Specifies if fonts should be embedded into SVG file.</desc> + </info> + <value>true</value> + </prop> + <prop oor:name="UseNativeTextDecoration" oor:type="xs:boolean"> + <info> + <author>KA</author> + <desc>Specifies if text decoration like underlining and strike-through be drawm by using SVG attributes (true) or by drawing SVG primitives (false).</desc> + </info> + <value>true</value> + </prop> + </group> </group> </group> <group oor:name="HTML"> diff --git a/svx/inc/svx/svdograf.hxx b/svx/inc/svx/svdograf.hxx index c29862b694..32430a8869 100644 --- a/svx/inc/svx/svdograf.hxx +++ b/svx/inc/svx/svdograf.hxx @@ -148,6 +148,8 @@ public: // Keep ATM for SD. sal_Bool IsAnimated() const; sal_Bool IsEPS() const; + sal_Bool IsRenderGraphic() const; + sal_Bool HasRenderGraphic() const; sal_Bool IsSwappedOut() const; const MapMode& GetGrafPrefMapMode() const; @@ -225,4 +227,3 @@ public: }; #endif //_SVDOGRAF_HXX - diff --git a/svx/source/dialog/_bmpmask.cxx b/svx/source/dialog/_bmpmask.cxx index 3b8ce7fbe1..d37a79a560 100644 --- a/svx/source/dialog/_bmpmask.cxx +++ b/svx/source/dialog/_bmpmask.cxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -1038,6 +1038,9 @@ GDIMetaFile SvxBmpMask::ImpMask( const GDIMetaFile& rMtf ) default: { + OSL_ENSURE( pAction->GetType() != META_RENDERGRAPHIC_ACTION, + "META_RENDERGRAPHIC_ACTION currently not supported at masking" ); + pAction->Duplicate(); aMtf.AddAction( pAction ); } diff --git a/svx/source/gallery2/galtheme.cxx b/svx/source/gallery2/galtheme.cxx index bc83eeda0b..8e652463a7 100644 --- a/svx/source/gallery2/galtheme.cxx +++ b/svx/source/gallery2/galtheme.cxx @@ -901,6 +901,7 @@ sal_Bool GalleryTheme::InsertGraphic( const Graphic& rGraphic, sal_uIntPtr nInse case( GFX_LINK_TYPE_NATIVE_WMF ): nExportFormat = CVT_WMF; break; case( GFX_LINK_TYPE_NATIVE_MET ): nExportFormat = CVT_MET; break; case( GFX_LINK_TYPE_NATIVE_PCT ): nExportFormat = CVT_PCT; break; + case( GFX_LINK_TYPE_NATIVE_SVG ): nExportFormat = CVT_SVG; break; default: break; } @@ -928,7 +929,7 @@ sal_Bool GalleryTheme::InsertGraphic( const Graphic& rGraphic, sal_uIntPtr nInse if( CVT_SVM == nExportFormat ) { GDIMetaFile aMtf( rGraphic.GetGDIMetaFile() ); - + aMtf.Write( *pOStm ); bRet = ( pOStm->GetError() == ERRCODE_NONE ); } diff --git a/svx/source/svdraw/svdedtv.cxx b/svx/source/svdraw/svdedtv.cxx index 08b92c97dc..e9ace5c2e2 100644 --- a/svx/source/svdraw/svdedtv.cxx +++ b/svx/source/svdraw/svdedtv.cxx @@ -644,8 +644,12 @@ void SdrEditView::CheckPossibilities() sal_Bool bGraf=HAS_BASE(SdrGrafObj,pObj); sal_Bool bOle2=HAS_BASE(SdrOle2Obj,pObj); - if( bGraf && ((SdrGrafObj*)pObj)->HasGDIMetaFile() && !((SdrGrafObj*)pObj)->IsEPS() ) + if( bGraf && + ((SdrGrafObj*)pObj)->HasGDIMetaFile() && + !( ((SdrGrafObj*)pObj)->IsEPS() || ((SdrGrafObj*)pObj)->IsRenderGraphic() ) ) + { bImportMtfPossible = sal_True; + } if (bOle2) bImportMtfPossible=((SdrOle2Obj*)pObj)->GetObjRef().is(); @@ -1043,4 +1047,3 @@ bool SdrEditView::IsUndoEnabled() const { return pMod->IsUndoEnabled(); } - diff --git a/svx/source/svdraw/svdfmtf.cxx b/svx/source/svdraw/svdfmtf.cxx index b1a80205de..3476f7ff8a 100644 --- a/svx/source/svdraw/svdfmtf.cxx +++ b/svx/source/svdraw/svdfmtf.cxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -195,7 +195,7 @@ sal_uIntPtr ImpSdrGDIMetaFileImport::DoImport(const GDIMetaFile& rMtf, case META_POP_ACTION : DoAction((MetaPopAction &)*pAct); break; case META_HATCH_ACTION : DoAction((MetaHatchAction &)*pAct); break; case META_COMMENT_ACTION : DoAction((MetaCommentAction &)*pAct, pMtf); break; - + case META_RENDERGRAPHIC_ACTION : DoAction((MetaRenderGraphicAction &)*pAct); break; } if(pProgrInfo != NULL) @@ -272,7 +272,7 @@ void ImpSdrGDIMetaFileImport::SetAttributes(SdrObject* pObj, FASTBOOL bForceText { bNoLine = sal_False; bNoFill = sal_False; FASTBOOL bLine=sal_True && !bForceTextAttr; - FASTBOOL bFill=pObj==NULL || pObj->IsClosedObj() && !bForceTextAttr; + FASTBOOL bFill=pObj==NULL || ( pObj->IsClosedObj() && !bForceTextAttr ); FASTBOOL bText=bForceTextAttr || (pObj!=NULL && pObj->GetOutlinerParaObject()!=NULL); if ( bLine ) @@ -482,9 +482,9 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaLineAction& rAct) SdrPathObj* pPath = new SdrPathObj(OBJ_LINE, basegfx::B2DPolyPolygon(aLine)); nLineWidth = nNewLineWidth; maLineJoin = rLineInfo.GetLineJoin(); - maDash = XDash(XDASH_RECT, - rLineInfo.GetDotCount(), rLineInfo.GetDotLen(), - rLineInfo.GetDashCount(), rLineInfo.GetDashLen(), + maDash = XDash(XDASH_RECT, + rLineInfo.GetDotCount(), rLineInfo.GetDotLen(), + rLineInfo.GetDashCount(), rLineInfo.GetDashLen(), rLineInfo.GetDistance()); SetAttributes(pPath); nLineWidth = 0; @@ -582,7 +582,7 @@ bool ImpSdrGDIMetaFileImport::CheckLastLineMerge(const basegfx::B2DPolygon& rSrc { return false; } - + if(aDstPoly.count()) { const sal_uInt32 nMaxDstPnt(aDstPoly.count() - 1L); @@ -683,13 +683,13 @@ void ImpSdrGDIMetaFileImport::DoAction( MetaPolyLineAction& rAct ) if(bCreateLineObject) { SdrPathObj* pPath = new SdrPathObj( - aSource.isClosed() ? OBJ_POLY : OBJ_PLIN, + aSource.isClosed() ? OBJ_POLY : OBJ_PLIN, basegfx::B2DPolyPolygon(aSource)); nLineWidth = nNewLineWidth; maLineJoin = rLineInfo.GetLineJoin(); - maDash = XDash(XDASH_RECT, - rLineInfo.GetDotCount(), rLineInfo.GetDotLen(), - rLineInfo.GetDashCount(), rLineInfo.GetDashLen(), + maDash = XDash(XDASH_RECT, + rLineInfo.GetDotCount(), rLineInfo.GetDotLen(), + rLineInfo.GetDashCount(), rLineInfo.GetDashLen(), rLineInfo.GetDistance()); SetAttributes(pPath); nLineWidth = 0; @@ -1025,4 +1025,25 @@ void ImpSdrGDIMetaFileImport::DoAction( MetaCommentAction& rAct, GDIMetaFile* pM } } +//////////////////////////////////////////////////////////////////////////////////////////////////// + +void ImpSdrGDIMetaFileImport::DoAction(MetaRenderGraphicAction& rAct) +{ + GDIMetaFile aMtf; + const ::vcl::RenderGraphic& rRenderGraphic = rAct.GetRenderGraphic(); + Rectangle aRect( rAct.GetPoint(), rAct.GetSize() ); + const Point aPos; + const Size aPrefSize( rRenderGraphic.GetPrefSize() ); + + aRect.Right()++; aRect.Bottom()++; + + aMtf.SetPrefMapMode( rRenderGraphic.GetPrefMapMode() ); + aMtf.SetPrefSize( aPrefSize ); + aMtf.AddAction( new MetaRenderGraphicAction( aPos, aPrefSize, rRenderGraphic ) ); + aMtf.WindStart(); + + SdrGrafObj* pGraf=new SdrGrafObj( aMtf, aRect ); + InsertObj( pGraf ); +} + // eof diff --git a/svx/source/svdraw/svdfmtf.hxx b/svx/source/svdraw/svdfmtf.hxx index d8b278b5fd..37d2e13631 100644 --- a/svx/source/svdraw/svdfmtf.hxx +++ b/svx/source/svdraw/svdfmtf.hxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -80,7 +80,7 @@ protected: SfxItemSet* pTextAttr; SdrPage* pPage; SdrModel* pModel; - SdrLayerID nLayer; + SdrLayerID nLayer; Color aOldLineColor; sal_Int32 nLineWidth; basegfx::B2DLineJoin maLineJoin; @@ -140,6 +140,7 @@ protected: void DoAction(MetaISectRectClipRegionAction& rAct) { rAct.Execute(&aVD); } void DoAction(MetaISectRegionClipRegionAction& rAct) { rAct.Execute(&aVD); } void DoAction(MetaCommentAction& rAct, GDIMetaFile* pMtf); + void DoAction(MetaRenderGraphicAction& rAct); void ImportText( const Point& rPos, const XubString& rStr, const MetaAction& rAct ); void SetAttributes(SdrObject* pObj, FASTBOOL bForceTextAttr=sal_False); diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx index 40dfcc82a6..7d50f44eae 100644 --- a/svx/source/svdraw/svdograf.cxx +++ b/svx/source/svdraw/svdograf.cxx @@ -504,6 +504,16 @@ sal_Bool SdrGrafObj::IsEPS() const return pGraphic->IsEPS(); } +sal_Bool SdrGrafObj::IsRenderGraphic() const +{ + return pGraphic->IsRenderGraphic(); +} + +sal_Bool SdrGrafObj::HasRenderGraphic() const +{ + return pGraphic->HasRenderGraphic(); +} + sal_Bool SdrGrafObj::IsSwappedOut() const { return mbIsPreview ? sal_True : pGraphic->IsSwappedOut(); @@ -658,6 +668,7 @@ void SdrGrafObj::ReleaseGraphicLink() void SdrGrafObj::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const { FASTBOOL bAnim = pGraphic->IsAnimated(); + FASTBOOL bRenderGraphic = pGraphic->HasRenderGraphic(); FASTBOOL bNoPresGrf = ( pGraphic->GetType() != GRAPHIC_NONE ) && !bEmptyPresObj; rInfo.bResizeFreeAllowed = aGeo.nDrehWink % 9000 == 0 || @@ -665,11 +676,11 @@ void SdrGrafObj::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const aGeo.nDrehWink % 27000 == 0; rInfo.bResizePropAllowed = sal_True; - rInfo.bRotateFreeAllowed = bNoPresGrf && !bAnim; - rInfo.bRotate90Allowed = bNoPresGrf && !bAnim; - rInfo.bMirrorFreeAllowed = bNoPresGrf && !bAnim; - rInfo.bMirror45Allowed = bNoPresGrf && !bAnim; - rInfo.bMirror90Allowed = !bEmptyPresObj; + rInfo.bRotateFreeAllowed = bNoPresGrf && !bAnim && !bRenderGraphic; + rInfo.bRotate90Allowed = bNoPresGrf && !bAnim && !bRenderGraphic; + rInfo.bMirrorFreeAllowed = bNoPresGrf && !bAnim && !bRenderGraphic; + rInfo.bMirror45Allowed = bNoPresGrf && !bAnim && !bRenderGraphic; + rInfo.bMirror90Allowed = !bEmptyPresObj && !bRenderGraphic; rInfo.bTransparenceAllowed = sal_False; rInfo.bGradientAllowed = sal_False; rInfo.bShearAllowed = sal_False; @@ -677,7 +688,7 @@ void SdrGrafObj::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const rInfo.bCanConvToPath = sal_False; rInfo.bCanConvToPathLineToArea = sal_False; rInfo.bCanConvToPolyLineToArea = sal_False; - rInfo.bCanConvToPoly = !IsEPS(); + rInfo.bCanConvToPoly = !IsEPS() && !bRenderGraphic; rInfo.bCanConvToContour = (rInfo.bCanConvToPoly || LineGeometryUsageIsNecessary()); } diff --git a/svx/source/tbxctrls/grafctrl.cxx b/svx/source/tbxctrls/grafctrl.cxx index 2a45ea6e0d..07f522e695 100644 --- a/svx/source/tbxctrls/grafctrl.cxx +++ b/svx/source/tbxctrls/grafctrl.cxx @@ -856,10 +856,8 @@ void SvxGrafAttrHelper::ExecuteGrafAttr( SfxRequest& rReq, SdrView& rView ) { SfxItemPool& rPool = rView.GetModel()->GetItemPool(); SfxItemSet aSet( rPool, SDRATTR_GRAF_FIRST, SDRATTR_GRAF_LAST ); - - const bool bUndo = rView.IsUndoEnabled(); - - String aUndoStr; + String aUndoStr; + const bool bUndo = rView.IsUndoEnabled(); if( bUndo ) { @@ -1139,7 +1137,29 @@ void SvxGrafAttrHelper::GetGrafAttrState( SfxItemSet& rSet, SdrView& rView ) SfxItemPool& rPool = rView.GetModel()->GetItemPool(); SfxItemSet aAttrSet( rPool ); SfxWhichIter aIter( rSet ); - sal_uInt16 nWhich = aIter.FirstWhich(); + sal_uInt16 nWhich = aIter.FirstWhich(); + const SdrMarkList& rMarkList = rView.GetMarkedObjectList(); + bool bEnableColors = true; + bool bEnableTransparency = true; + bool bEnableCrop = ( 1 == rMarkList.GetMarkCount() ); + + for( int i = 0, nCount = rMarkList.GetMarkCount(); i < nCount; ++i ) + { + SdrGrafObj* pGrafObj = dynamic_cast< SdrGrafObj* >( rMarkList.GetMark( i )->GetMarkedSdrObj() ); + + if( !pGrafObj || + ( pGrafObj->GetGraphicType() == GRAPHIC_NONE ) || + ( pGrafObj->GetGraphicType() == GRAPHIC_DEFAULT ) || + pGrafObj->HasRenderGraphic() ) + { + bEnableColors = bEnableTransparency = bEnableCrop = false; + break; + } + else if( bEnableTransparency && ( pGrafObj->HasGDIMetaFile() || pGrafObj->IsAnimated() ) ) + { + bEnableTransparency = false; + } + } rView.GetAttributes( aAttrSet ); @@ -1153,8 +1173,15 @@ void SvxGrafAttrHelper::GetGrafAttrState( SfxItemSet& rSet, SdrView& rView ) { if( SFX_ITEM_AVAILABLE <= aAttrSet.GetItemState( SDRATTR_GRAFMODE ) ) { - rSet.Put( SfxUInt16Item( nSlotId, - sal::static_int_cast< sal_uInt16 >( ITEMVALUE( aAttrSet, SDRATTR_GRAFMODE, SdrGrafModeItem ) ) ) ); + if( bEnableColors ) + { + rSet.Put( SfxUInt16Item( nSlotId, + sal::static_int_cast< sal_uInt16 >( ITEMVALUE( aAttrSet, SDRATTR_GRAFMODE, SdrGrafModeItem ) ) ) ); + } + else + { + rSet.DisableItem( SID_ATTR_GRAF_MODE ); + } } } break; @@ -1163,8 +1190,15 @@ void SvxGrafAttrHelper::GetGrafAttrState( SfxItemSet& rSet, SdrView& rView ) { if( SFX_ITEM_AVAILABLE <= aAttrSet.GetItemState( SDRATTR_GRAFRED ) ) { - rSet.Put( SfxInt16Item( nSlotId, - ITEMVALUE( aAttrSet, SDRATTR_GRAFRED, SdrGrafRedItem ) ) ); + if( bEnableColors ) + { + rSet.Put( SfxInt16Item( nSlotId, + ITEMVALUE( aAttrSet, SDRATTR_GRAFRED, SdrGrafRedItem ) ) ); + } + else + { + rSet.DisableItem( SID_ATTR_GRAF_RED ); + } } } break; @@ -1173,8 +1207,15 @@ void SvxGrafAttrHelper::GetGrafAttrState( SfxItemSet& rSet, SdrView& rView ) { if( SFX_ITEM_AVAILABLE <= aAttrSet.GetItemState( SDRATTR_GRAFGREEN ) ) { - rSet.Put( SfxInt16Item( nSlotId, - ITEMVALUE( aAttrSet, SDRATTR_GRAFGREEN, SdrGrafGreenItem ) ) ); + if( bEnableColors ) + { + rSet.Put( SfxInt16Item( nSlotId, + ITEMVALUE( aAttrSet, SDRATTR_GRAFGREEN, SdrGrafGreenItem ) ) ); + } + else + { + rSet.DisableItem( SID_ATTR_GRAF_GREEN ); + } } } break; @@ -1183,8 +1224,15 @@ void SvxGrafAttrHelper::GetGrafAttrState( SfxItemSet& rSet, SdrView& rView ) { if( SFX_ITEM_AVAILABLE <= aAttrSet.GetItemState( SDRATTR_GRAFBLUE ) ) { - rSet.Put( SfxInt16Item( nSlotId, - ITEMVALUE( aAttrSet, SDRATTR_GRAFBLUE, SdrGrafBlueItem ) ) ); + if( bEnableColors ) + { + rSet.Put( SfxInt16Item( nSlotId, + ITEMVALUE( aAttrSet, SDRATTR_GRAFBLUE, SdrGrafBlueItem ) ) ); + } + else + { + rSet.DisableItem( SID_ATTR_GRAF_BLUE ); + } } } break; @@ -1193,8 +1241,15 @@ void SvxGrafAttrHelper::GetGrafAttrState( SfxItemSet& rSet, SdrView& rView ) { if( SFX_ITEM_AVAILABLE <= aAttrSet.GetItemState( SDRATTR_GRAFLUMINANCE ) ) { - rSet.Put( SfxInt16Item( nSlotId, - ITEMVALUE( aAttrSet, SDRATTR_GRAFLUMINANCE, SdrGrafLuminanceItem ) ) ); + if( bEnableColors ) + { + rSet.Put( SfxInt16Item( nSlotId, + ITEMVALUE( aAttrSet, SDRATTR_GRAFLUMINANCE, SdrGrafLuminanceItem ) ) ); + } + else + { + rSet.DisableItem( SID_ATTR_GRAF_LUMINANCE ); + } } } break; @@ -1203,8 +1258,15 @@ void SvxGrafAttrHelper::GetGrafAttrState( SfxItemSet& rSet, SdrView& rView ) { if( SFX_ITEM_AVAILABLE <= aAttrSet.GetItemState( SDRATTR_GRAFCONTRAST ) ) { - rSet.Put( SfxInt16Item( nSlotId, - ITEMVALUE( aAttrSet, SDRATTR_GRAFCONTRAST, SdrGrafContrastItem ) ) ); + if( bEnableColors ) + { + rSet.Put( SfxInt16Item( nSlotId, + ITEMVALUE( aAttrSet, SDRATTR_GRAFCONTRAST, SdrGrafContrastItem ) ) ); + } + else + { + rSet.DisableItem( SID_ATTR_GRAF_CONTRAST ); + } } } break; @@ -1213,8 +1275,15 @@ void SvxGrafAttrHelper::GetGrafAttrState( SfxItemSet& rSet, SdrView& rView ) { if( SFX_ITEM_AVAILABLE <= aAttrSet.GetItemState( SDRATTR_GRAFGAMMA ) ) { - rSet.Put( SfxUInt32Item( nSlotId, - ITEMVALUE( aAttrSet, SDRATTR_GRAFGAMMA, SdrGrafGamma100Item ) ) ); + if( bEnableColors ) + { + rSet.Put( SfxUInt32Item( nSlotId, + ITEMVALUE( aAttrSet, SDRATTR_GRAFGAMMA, SdrGrafGamma100Item ) ) ); + } + else + { + rSet.DisableItem( SID_ATTR_GRAF_GAMMA ); + } } } break; @@ -1223,53 +1292,22 @@ void SvxGrafAttrHelper::GetGrafAttrState( SfxItemSet& rSet, SdrView& rView ) { if( SFX_ITEM_AVAILABLE <= aAttrSet.GetItemState( SDRATTR_GRAFTRANSPARENCE ) ) { - const SdrMarkList& rMarkList = rView.GetMarkedObjectList(); - sal_Bool bEnable = sal_True; - - for( sal_uInt16 i = 0, nCount = (sal_uInt16) rMarkList.GetMarkCount(); - ( i < nCount ) && bEnable; i++ ) + if( bEnableTransparency ) { - SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj(); - - if( !pObj || !pObj->ISA( SdrGrafObj ) || - ( (SdrGrafObj*) pObj )->HasGDIMetaFile() || - ( (SdrGrafObj*) pObj )->IsAnimated() ) - { - bEnable = sal_False; - } - } - - if( bEnable ) rSet.Put( SfxUInt16Item( nSlotId, ITEMVALUE( aAttrSet, SDRATTR_GRAFTRANSPARENCE, SdrGrafTransparenceItem ) ) ); + } else + { rSet.DisableItem( SID_ATTR_GRAF_TRANSPARENCE ); + } } } break; case( SID_ATTR_GRAF_CROP ): { - const SdrMarkList& rMarkList = rView.GetMarkedObjectList(); - sal_Bool bDisable = sal_True; - - if( 1 == rMarkList.GetMarkCount() ) - { - SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj(); - - if( pObj && pObj->ISA( SdrGrafObj ) ) - { - SdrGrafObj* pGrafObj = (SdrGrafObj*) pObj; - - if( ( pGrafObj->GetGraphicType() != GRAPHIC_NONE ) && - ( pGrafObj->GetGraphicType() != GRAPHIC_DEFAULT ) ) - { - bDisable = sal_False; - } - } - } - - if( bDisable ) + if( !bEnableCrop ) rSet.DisableItem( nSlotId ); } break; diff --git a/svx/source/xml/xmlgrhlp.cxx b/svx/source/xml/xmlgrhlp.cxx index d3aaefad59..3acdbd513f 100644 --- a/svx/source/xml/xmlgrhlp.cxx +++ b/svx/source/xml/xmlgrhlp.cxx @@ -153,7 +153,7 @@ SvXMLGraphicInputStream::SvXMLGraphicInputStream( const ::rtl::OUString& rGraphi { pStm->SetVersion( SOFFICE_FILEFORMAT_8 ); pStm->SetCompressMode( COMPRESSMODE_ZBITMAP ); - ( (GDIMetaFile&) aGraphic.GetGDIMetaFile() ).Write( *pStm ); + ( (GDIMetaFile&) aGraphic.GetGDIMetaFile() ).Write( *pStm, GDIMETAFILE_WRITE_REPLACEMENT_RENDERGRAPHIC ); bRet = ( pStm->GetError() == 0 ); } } @@ -543,7 +543,8 @@ String SvXMLGraphicHelper::ImplGetGraphicMimeType( const String& rFileName ) con { "gif", "image/gif" }, { "png", "image/png" }, { "jpg", "image/jpeg" }, - { "tif", "image/tiff" } + { "tif", "image/tiff" }, + { "svg", "image/svg+xml" } }; String aMimeType; @@ -648,7 +649,7 @@ sal_Bool SvXMLGraphicHelper::ImplWriteGraphic( const ::rtl::OUString& rPictureSt pStream->Write( rLink.GetData(), rLink.GetDataSize() ); } else - rMtf.Write( *pStream ); + rMtf.Write( *pStream, GDIMETAFILE_WRITE_REPLACEMENT_RENDERGRAPHIC ); bRet = ( pStream->GetError() == 0 ); } @@ -728,6 +729,7 @@ void SvXMLGraphicHelper::ImplInsertGraphicURL( const ::rtl::OUString& rURLStr, s case( GFX_LINK_TYPE_NATIVE_WMF ): aExtension = String( RTL_CONSTASCII_USTRINGPARAM( ".wmf" ) ); break; case( GFX_LINK_TYPE_NATIVE_MET ): aExtension = String( RTL_CONSTASCII_USTRINGPARAM( ".met" ) ); break; case( GFX_LINK_TYPE_NATIVE_PCT ): aExtension = String( RTL_CONSTASCII_USTRINGPARAM( ".pct" ) ); break; + case( GFX_LINK_TYPE_NATIVE_SVG ): aExtension = String( RTL_CONSTASCII_USTRINGPARAM( ".svg" ) ); break; default: aExtension = String( RTL_CONSTASCII_USTRINGPARAM( ".grf" ) ); @@ -1160,4 +1162,3 @@ Sequence< ::rtl::OUString > SAL_CALL SvXMLGraphicExportHelper_getSupportedServic } } // namespace svx - |