diff options
-rw-r--r-- | drawinglayer/source/processor2d/vclprocessor2d.cxx | 25 | ||||
-rw-r--r-- | include/svx/bmpmask.hxx | 3 | ||||
-rw-r--r-- | include/svx/svdograf.hxx | 1 | ||||
-rw-r--r-- | slideshow/source/engine/shapes/backgroundshape.cxx | 23 | ||||
-rw-r--r-- | slideshow/source/engine/shapes/drawshape.cxx | 24 | ||||
-rw-r--r-- | slideshow/source/engine/shapes/gdimtftools.cxx | 39 | ||||
-rw-r--r-- | slideshow/source/engine/shapes/gdimtftools.hxx | 11 | ||||
-rw-r--r-- | svx/source/dialog/_bmpmask.cxx | 18 | ||||
-rw-r--r-- | svx/source/svdraw/svdedtv2.cxx | 26 | ||||
-rw-r--r-- | svx/source/svdraw/svdograf.cxx | 23 |
10 files changed, 98 insertions, 95 deletions
diff --git a/drawinglayer/source/processor2d/vclprocessor2d.cxx b/drawinglayer/source/processor2d/vclprocessor2d.cxx index 8544f4c44d03..900cada4db7a 100644 --- a/drawinglayer/source/processor2d/vclprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclprocessor2d.cxx @@ -87,6 +87,18 @@ namespace return nSteps; } + + // get metafile (copy it) + GDIMetaFile GetMetaFile(const drawinglayer::primitive2d::MetafilePrimitive2D& rMetaCandidate, const basegfx::BColorModifierStack& rColorModifierStack) + { + if (rColorModifierStack.count()) + { + const basegfx::BColor aRGBBaseColor(0, 0, 0); + const basegfx::BColor aRGBColor(rColorModifierStack.getModifiedColor(aRGBBaseColor)); + return rMetaCandidate.getMetaFile().GetMonochromeMtf(Color(aRGBColor)); + } + return rMetaCandidate.getMetaFile(); + } } namespace drawinglayer @@ -736,18 +748,7 @@ namespace drawinglayer (sal_Int32)floor(aOutlineRange.getMaxX()), (sal_Int32)floor(aOutlineRange.getMaxY())); // get metafile (copy it) - GDIMetaFile aMetaFile; - - if(maBColorModifierStack.count()) - { - const basegfx::BColor aRGBBaseColor(0, 0, 0); - const basegfx::BColor aRGBColor(maBColorModifierStack.getModifiedColor(aRGBBaseColor)); - aMetaFile = rMetaCandidate.getMetaFile().GetMonochromeMtf(Color(aRGBColor)); - } - else - { - aMetaFile = rMetaCandidate.getMetaFile(); - } + GDIMetaFile aMetaFile(GetMetaFile(rMetaCandidate, maBColorModifierStack)); // rotation if(!basegfx::fTools::equalZero(fRotate)) diff --git a/include/svx/bmpmask.hxx b/include/svx/bmpmask.hxx index 6705b1c5fe5b..c5066834d250 100644 --- a/include/svx/bmpmask.hxx +++ b/include/svx/bmpmask.hxx @@ -124,6 +124,9 @@ class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxBmpMask : public SfxDockingWindow BitmapEx ImpMaskTransparent( const BitmapEx& rBitmapEx, const Color& rColor, const long nTol ); + + GDIMetaFile GetMetaFile(const Graphic& rGraphic); + static BitmapEx ImpReplaceTransparency( const BitmapEx& rBmpEx, const Color& rColor ); static Animation ImpReplaceTransparency( const Animation& rAnim, diff --git a/include/svx/svdograf.hxx b/include/svx/svdograf.hxx index 77183c301de2..30c564342e9e 100644 --- a/include/svx/svdograf.hxx +++ b/include/svx/svdograf.hxx @@ -113,6 +113,7 @@ private: void ImpSetLinkedGraphic( const Graphic& rGraphic ); DECL_LINK( ImpSwapHdl, const GraphicObject*, SvStream* ); void onGraphicChanged(); + GDIMetaFile GetMetaFile(GraphicType &rGraphicType) const; public: diff --git a/slideshow/source/engine/shapes/backgroundshape.cxx b/slideshow/source/engine/shapes/backgroundshape.cxx index 4b4a5b1384a0..b119d8ac77ed 100644 --- a/slideshow/source/engine/shapes/backgroundshape.cxx +++ b/slideshow/source/engine/shapes/backgroundshape.cxx @@ -123,16 +123,20 @@ namespace slideshow { uno::Reference< beans::XPropertySet > xPropSet( xDrawPage, uno::UNO_QUERY_THROW ); - GDIMetaFileSharedPtr pMtf( new GDIMetaFile() ); - // first try the page background (overrides // masterpage background), then try masterpage - if( !getMetaFile( uno::Reference<lang::XComponent>(xDrawPage, uno::UNO_QUERY), - xDrawPage, *pMtf, MTF_LOAD_BACKGROUND_ONLY, - rContext.mxComponentContext ) && - !getMetaFile( uno::Reference<lang::XComponent>(xMasterPage, uno::UNO_QUERY), - xDrawPage, *pMtf, MTF_LOAD_BACKGROUND_ONLY, - rContext.mxComponentContext )) + GDIMetaFileSharedPtr xMtf = getMetaFile(uno::Reference<lang::XComponent>(xDrawPage, uno::UNO_QUERY), + xDrawPage, MTF_LOAD_BACKGROUND_ONLY, + rContext.mxComponentContext); + + if (!xMtf) + { + xMtf = getMetaFile( uno::Reference<lang::XComponent>(xMasterPage, uno::UNO_QUERY), + xDrawPage, MTF_LOAD_BACKGROUND_ONLY, + rContext.mxComponentContext ); + } + + if (!xMtf) { throw ShapeLoadFailedException(); } @@ -140,13 +144,12 @@ namespace slideshow // there is a special background shape, add it // as the first one - sal_Int32 nDocWidth=0; sal_Int32 nDocHeight=0; xPropSet->getPropertyValue("Width") >>= nDocWidth; xPropSet->getPropertyValue("Height") >>= nDocHeight; - mpMtf = pMtf; + mpMtf = xMtf; maBounds = ::basegfx::B2DRectangle( 0,0,nDocWidth, nDocHeight ); } diff --git a/slideshow/source/engine/shapes/drawshape.cxx b/slideshow/source/engine/shapes/drawshape.cxx index 877049b0b5ae..6bbdc534793f 100644 --- a/slideshow/source/engine/shapes/drawshape.cxx +++ b/slideshow/source/engine/shapes/drawshape.cxx @@ -82,12 +82,13 @@ namespace slideshow if ((mnCurrMtfLoadFlags & MTF_LOAD_SCROLL_TEXT_MTF) != MTF_LOAD_SCROLL_TEXT_MTF) { // reload with added flags: - mpCurrMtf.reset( new GDIMetaFile ); mnCurrMtfLoadFlags |= MTF_LOAD_SCROLL_TEXT_MTF; - getMetaFile( - uno::Reference<lang::XComponent>(mxShape, uno::UNO_QUERY), - mxPage, *mpCurrMtf, mnCurrMtfLoadFlags, - mxComponentContext ); + mpCurrMtf = getMetaFile(uno::Reference<lang::XComponent>(mxShape, uno::UNO_QUERY), + mxPage, mnCurrMtfLoadFlags, + mxComponentContext); + + if (!mpCurrMtf) + mpCurrMtf.reset( new GDIMetaFile ); // TODO(F1): Currently, the scroll metafile will // never contain any verbose text comments. Thus, @@ -402,13 +403,12 @@ namespace slideshow // must NOT be called from within initializer list, uses // state from mnCurrMtfLoadFlags! - mpCurrMtf.reset( new GDIMetaFile ); - getMetaFile( - uno::Reference<lang::XComponent>(xShape, uno::UNO_QUERY), - xContainingPage, *mpCurrMtf, mnCurrMtfLoadFlags, - mxComponentContext ); - ENSURE_OR_THROW( mpCurrMtf, - "DrawShape::DrawShape(): Invalid metafile" ); + mpCurrMtf = getMetaFile(uno::Reference<lang::XComponent>(xShape, uno::UNO_QUERY), + xContainingPage, mnCurrMtfLoadFlags, + mxComponentContext ); + if (!mpCurrMtf) + mpCurrMtf.reset(new GDIMetaFile); + maSubsetting.reset( mpCurrMtf ); prepareHyperlinkIndices(); diff --git a/slideshow/source/engine/shapes/gdimtftools.cxx b/slideshow/source/engine/shapes/gdimtftools.cxx index 6cd569e37aa1..c515b7a9fac1 100644 --- a/slideshow/source/engine/shapes/gdimtftools.cxx +++ b/slideshow/source/engine/shapes/gdimtftools.cxx @@ -127,7 +127,7 @@ public: against unsupported content, and, if necessary, returned as a pre-rendererd bitmap. */ - GDIMetaFile getMtf( bool bForeignSource ) const + GDIMetaFileSharedPtr getMtf( bool bForeignSource ) const { ::osl::MutexGuard aGuard( m_aMutex ); @@ -138,22 +138,19 @@ public: hasUnsupportedActions(aGraphic.GetGDIMetaFile()) ) ) { // wrap bitmap into GDIMetafile - GDIMetaFile aMtf; + GDIMetaFileSharedPtr xMtf(new GDIMetaFile); ::Point aEmptyPoint; ::BitmapEx aBmpEx( aGraphic.GetBitmapEx() ); - aMtf.AddAction( new MetaBmpExAction( aEmptyPoint, + xMtf->AddAction( new MetaBmpExAction( aEmptyPoint, aBmpEx ) ); - aMtf.SetPrefSize( aBmpEx.GetPrefSize() ); - aMtf.SetPrefMapMode( aBmpEx.GetPrefMapMode() ); + xMtf->SetPrefSize( aBmpEx.GetPrefSize() ); + xMtf->SetPrefMapMode( aBmpEx.GetPrefMapMode() ); - return aMtf; - } - else - { - return aGraphic.GetGDIMetaFile(); + return xMtf; } + return GDIMetaFileSharedPtr(new GDIMetaFile(aGraphic.GetGDIMetaFile())); } private: @@ -164,14 +161,16 @@ private: // Quick'n'dirty way: tunnel Graphic (only works for // in-process slideshow, of course) -bool getMetaFile( const uno::Reference< lang::XComponent >& xSource, - const uno::Reference< drawing::XDrawPage >& xContainingPage, - GDIMetaFile& rMtf, - int mtfLoadFlags, - const uno::Reference< uno::XComponentContext >& rxContext ) +GDIMetaFileSharedPtr getMetaFile( const uno::Reference< lang::XComponent >& xSource, + const uno::Reference< drawing::XDrawPage >& xContainingPage, + int mtfLoadFlags, + const uno::Reference< uno::XComponentContext >& rxContext ) { - ENSURE_OR_RETURN_FALSE( rxContext.is(), - "getMetaFile(): Invalid context" ); + if (!rxContext.is()) + { + SAL_WARN("slideshow.opengl", "getMetaFile(): Invalid context" ); + return GDIMetaFileSharedPtr(); + } // create dummy XGraphicRenderer, which receives the // generated XGraphic from the GraphicExporter @@ -212,9 +211,9 @@ bool getMetaFile( const uno::Reference< lang::XComponent >& xSource, xExporter->setSourceDocument( xSource ); if( !xExporter->filter( aProps ) ) - return false; + return GDIMetaFileSharedPtr(); - rMtf = pRenderer->getMtf( (mtfLoadFlags & MTF_LOAD_FOREIGN_SOURCE) != 0 ); + GDIMetaFileSharedPtr xMtf = pRenderer->getMtf( (mtfLoadFlags & MTF_LOAD_FOREIGN_SOURCE) != 0 ); // pRenderer is automatically destroyed when xRenderer // goes out of scope @@ -222,7 +221,7 @@ bool getMetaFile( const uno::Reference< lang::XComponent >& xSource, // TODO(E3): Error handling. Exporter might have // generated nothing, a bitmap, threw an exception, // whatever. - return true; + return xMtf; } sal_Int32 getNextActionOffset( MetaAction * pCurrAct ) diff --git a/slideshow/source/engine/shapes/gdimtftools.hxx b/slideshow/source/engine/shapes/gdimtftools.hxx index 59e91c554686..d27e6ed5d89b 100644 --- a/slideshow/source/engine/shapes/gdimtftools.hxx +++ b/slideshow/source/engine/shapes/gdimtftools.hxx @@ -90,14 +90,11 @@ namespace slideshow import (currently, the UnoGraphicExporter needs this information). - @param o_rMtf - Metafile to extract shape content into */ - bool getMetaFile( const css::uno::Reference< css::lang::XComponent >& xSource, - const css::uno::Reference< css::drawing::XDrawPage >& xContainingPage, - GDIMetaFile& o_rMtf, - int mtfLoadFlags, - const css::uno::Reference< css::uno::XComponentContext >& rxContext ); + GDIMetaFileSharedPtr getMetaFile( const css::uno::Reference< css::lang::XComponent >& xSource, + const css::uno::Reference< css::drawing::XDrawPage >& xContainingPage, + int mtfLoadFlags, + const css::uno::Reference< css::uno::XComponentContext >& rxContext ); /** Gets the next action offset for iterating meta actions which is most often returns 1. diff --git a/svx/source/dialog/_bmpmask.cxx b/svx/source/dialog/_bmpmask.cxx index 5eec4f8f7e8a..b7e194854c4f 100644 --- a/svx/source/dialog/_bmpmask.cxx +++ b/svx/source/dialog/_bmpmask.cxx @@ -608,7 +608,6 @@ sal_uInt16 SvxBmpMask::InitColorArrays( Color* pSrcCols, Color* pDstCols, sal_uI return nCount; } - Bitmap SvxBmpMask::ImpMask( const Bitmap& rBitmap ) { Bitmap aBitmap( rBitmap ); @@ -624,7 +623,6 @@ Bitmap SvxBmpMask::ImpMask( const Bitmap& rBitmap ) return aBitmap; } - BitmapEx SvxBmpMask::ImpMaskTransparent( const BitmapEx& rBitmapEx, const Color& rColor, const long nTol ) { EnterWait(); @@ -979,6 +977,13 @@ GDIMetaFile SvxBmpMask::ImpReplaceTransparency( const GDIMetaFile& rMtf, const C return aMtf; } +GDIMetaFile SvxBmpMask::GetMetaFile(const Graphic& rGraphic) +{ + // Replace transparency? + if (m_pCbxTrans->IsChecked()) + return ImpReplaceTransparency(rGraphic.GetGDIMetaFile(), m_pLbColorTrans->GetSelectEntryColor()); + return ImpMask(rGraphic.GetGDIMetaFile()); +} Graphic SvxBmpMask::Mask( const Graphic& rGraphic ) { @@ -1054,14 +1059,7 @@ Graphic SvxBmpMask::Mask( const Graphic& rGraphic ) case GraphicType::GdiMetafile: { - GDIMetaFile aMtf( aGraphic.GetGDIMetaFile() ); - - // Replace transparency? - if( m_pCbxTrans->IsChecked() ) - aMtf = ImpReplaceTransparency( aMtf, aReplColor ); - else - aMtf = ImpMask( aMtf ); - + GDIMetaFile aMtf(GetMetaFile(rGraphic)); Size aSize( aMtf.GetPrefSize() ); if ( aSize.Width() && aSize.Height() ) aGraphic = Graphic( aMtf ); diff --git a/svx/source/svdraw/svdedtv2.cxx b/svx/source/svdraw/svdedtv2.cxx index d0a15ece7dc6..9ed2ef55029f 100644 --- a/svx/source/svdraw/svdedtv2.cxx +++ b/svx/source/svdraw/svdedtv2.cxx @@ -2003,10 +2003,18 @@ void SdrEditView::ConvertMarkedToPolyObj() ImpConvertTo(false, false/*bLineToArea*/); } +namespace +{ + GDIMetaFile GetMetaFile(SdrGrafObj* pGraf) + { + if (pGraf->HasGDIMetaFile()) + return pGraf->GetTransformedGraphic(SdrGrafObjTransformsAttrs::COLOR|SdrGrafObjTransformsAttrs::MIRROR).GetGDIMetaFile(); + assert(pGraf->isEmbeddedSvg()); + return pGraf->getMetafileFromEmbeddedSvg(); + } +} // Metafile Import - - void SdrEditView::DoImportMarkedMtf(SvdProgressInfo *pProgrInfo) { const bool bUndo = IsUndoEnabled(); @@ -2040,19 +2048,9 @@ void SdrEditView::DoImportMarkedMtf(SvdProgressInfo *pProgrInfo) sal_uIntPtr nInsAnz=0; Rectangle aLogicRect; - if(pGraf && (pGraf->HasGDIMetaFile() || pGraf->isEmbeddedSvg())) + if (pGraf && (pGraf->HasGDIMetaFile() || pGraf->isEmbeddedSvg())) { - GDIMetaFile aMetaFile; - - if(pGraf->HasGDIMetaFile()) - { - aMetaFile = pGraf->GetTransformedGraphic(SdrGrafObjTransformsAttrs::COLOR|SdrGrafObjTransformsAttrs::MIRROR).GetGDIMetaFile(); - } - else if(pGraf->isEmbeddedSvg()) - { - aMetaFile = pGraf->getMetafileFromEmbeddedSvg(); - } - + GDIMetaFile aMetaFile(GetMetaFile(pGraf)); if(aMetaFile.GetActionSize()) { aLogicRect = pGraf->GetLogicRect(); diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx index 90f91f11fbb7..0103498ca4af 100644 --- a/svx/source/svdraw/svdograf.cxx +++ b/svx/source/svdraw/svdograf.cxx @@ -1044,27 +1044,30 @@ GDIMetaFile SdrGrafObj::getMetafileFromEmbeddedSvg() const return aRetval; } -SdrObject* SdrGrafObj::DoConvertToPolyObj(bool bBezier, bool bAddText ) const +GDIMetaFile SdrGrafObj::GetMetaFile(GraphicType &rGraphicType) const { - SdrObject* pRetval = nullptr; - GraphicType aGraphicType(GetGraphicType()); - GDIMetaFile aMtf; - - if(isEmbeddedSvg()) + if (isEmbeddedSvg()) { // Embedded Svg // There is currently no helper to create SdrObjects from primitives (even if I'm thinking // about writing one for some time). To get the roundtrip to SdrObjects it is necessary to // use the old converter path over the MetaFile mechanism. Create Metafile from Svg // primitives here pretty directly - aMtf = getMetafileFromEmbeddedSvg(); - aGraphicType = GraphicType::GdiMetafile; + rGraphicType = GraphicType::GdiMetafile; + return getMetafileFromEmbeddedSvg(); } - else if(GraphicType::GdiMetafile == aGraphicType) + else if (GraphicType::GdiMetafile == rGraphicType) { - aMtf = GetTransformedGraphic(SdrGrafObjTransformsAttrs::COLOR|SdrGrafObjTransformsAttrs::MIRROR).GetGDIMetaFile(); + return GetTransformedGraphic(SdrGrafObjTransformsAttrs::COLOR|SdrGrafObjTransformsAttrs::MIRROR).GetGDIMetaFile(); } + return GDIMetaFile(); +} +SdrObject* SdrGrafObj::DoConvertToPolyObj(bool bBezier, bool bAddText ) const +{ + SdrObject* pRetval = nullptr; + GraphicType aGraphicType(GetGraphicType()); + GDIMetaFile aMtf(GetMetaFile(aGraphicType)); switch(aGraphicType) { case GraphicType::GdiMetafile: |