tdf#134210 Apply mirror property to custom cropped graphic.
Change-Id: I5bf2ba8fa432af8b6a560cc60c18bef799834fd0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110039 Tested-by: Jenkins Reviewed-by: Gülşah Köse <gulsah.kose@collabora.com>
This commit is contained in:
@@ -43,7 +43,9 @@ struct GraphicProperties
|
||||
/** Writes the properties to the passed property map. */
|
||||
void pushToPropMap(
|
||||
PropertyMap& rPropMap,
|
||||
const GraphicHelper& rGraphicHelper) const;
|
||||
const GraphicHelper& rGraphicHelper,
|
||||
bool bFlipH = false,
|
||||
bool bFlipV = false) const;
|
||||
};
|
||||
|
||||
} // namespace oox::drawingml
|
||||
|
||||
@@ -112,6 +112,28 @@ Reference< XGraphic > lclCropGraphic(uno::Reference<graphic::XGraphic> const & x
|
||||
return aReturnGraphic.GetXGraphic();
|
||||
}
|
||||
|
||||
Reference< XGraphic > lclMirrorGraphic(uno::Reference<graphic::XGraphic> const & xGraphic, bool bFlipH, bool bFlipV)
|
||||
{
|
||||
::Graphic aGraphic(xGraphic);
|
||||
::Graphic aReturnGraphic;
|
||||
|
||||
assert (aGraphic.GetType() == GraphicType::Bitmap);
|
||||
|
||||
BitmapEx aBitmapEx(aGraphic.GetBitmapEx());
|
||||
BmpMirrorFlags nMirrorFlags = BmpMirrorFlags::NONE;
|
||||
|
||||
if(bFlipH)
|
||||
nMirrorFlags |= BmpMirrorFlags::Horizontal;
|
||||
if(bFlipV)
|
||||
nMirrorFlags |= BmpMirrorFlags::Vertical;
|
||||
|
||||
aBitmapEx.Mirror(nMirrorFlags);
|
||||
|
||||
aReturnGraphic = ::Graphic(aBitmapEx);
|
||||
aReturnGraphic.setOriginURL(aGraphic.getOriginURL());
|
||||
|
||||
return aReturnGraphic.GetXGraphic();
|
||||
}
|
||||
|
||||
Reference< XGraphic > lclCheckAndApplyChangeColorTransform(const BlipFillProperties &aBlipProps, uno::Reference<graphic::XGraphic> const & xGraphic,
|
||||
const GraphicHelper& rGraphicHelper, const ::Color nPhClr)
|
||||
@@ -761,7 +783,7 @@ void FillProperties::pushToPropMap( ShapePropertyMap& rPropMap,
|
||||
rPropMap.setProperty( ShapeProperty::FillStyle, eFillStyle );
|
||||
}
|
||||
|
||||
void GraphicProperties::pushToPropMap( PropertyMap& rPropMap, const GraphicHelper& rGraphicHelper) const
|
||||
void GraphicProperties::pushToPropMap( PropertyMap& rPropMap, const GraphicHelper& rGraphicHelper, bool bFlipH, bool bFlipV) const
|
||||
{
|
||||
sal_Int16 nBrightness = getLimitedValue< sal_Int16, sal_Int32 >( maBlipProps.moBrightness.get( 0 ) / PER_PERCENT, -100, 100 );
|
||||
sal_Int16 nContrast = getLimitedValue< sal_Int16, sal_Int32 >( maBlipProps.moContrast.get( 0 ) / PER_PERCENT, -100, 100 );
|
||||
@@ -811,6 +833,11 @@ void GraphicProperties::pushToPropMap( PropertyMap& rPropMap, const GraphicHelpe
|
||||
xGraphic = lclRotateGraphic(xGraphic, Degree10(nAngle/10) );
|
||||
}
|
||||
|
||||
// We have not core feature that flips graphic in the shape.
|
||||
// Here we are applying flip property to bitmap directly.
|
||||
if(bFlipH || bFlipV)
|
||||
xGraphic = lclMirrorGraphic(xGraphic, bFlipH, bFlipV );
|
||||
|
||||
rPropMap.setProperty(PROP_FillBitmap, xGraphic);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -1049,8 +1049,13 @@ Reference< XShape > const & Shape::createAndInsert(
|
||||
aShapeProps.assignUsed( maDefaultShapeProperties );
|
||||
if(mnRotation != 0 && bIsCustomShape)
|
||||
aShapeProps.setProperty( PROP_RotateAngle, sal_Int32( NormAngle36000( Degree100(mnRotation / -600) ) ));
|
||||
if ( bIsEmbMedia || aServiceName == "com.sun.star.drawing.GraphicObjectShape" || aServiceName == "com.sun.star.drawing.OLE2Shape" || bIsCustomShape )
|
||||
mpGraphicPropertiesPtr->pushToPropMap( aShapeProps, rGraphicHelper );
|
||||
if( bIsEmbMedia ||
|
||||
bIsCustomShape ||
|
||||
aServiceName == "com.sun.star.drawing.GraphicObjectShape" ||
|
||||
aServiceName == "com.sun.star.drawing.OLE2Shape")
|
||||
{
|
||||
mpGraphicPropertiesPtr->pushToPropMap( aShapeProps, rGraphicHelper, mbFlipH, mbFlipV );
|
||||
}
|
||||
if ( mpTablePropertiesPtr && aServiceName == "com.sun.star.drawing.TableShape" )
|
||||
mpTablePropertiesPtr->pushToPropSet( rFilterBase, xSet, mpMasterTextListStyle );
|
||||
|
||||
|
||||
Binary file not shown.
@@ -212,6 +212,7 @@ public:
|
||||
void testTdf128684();
|
||||
void testShapeGlowEffectPPTXImpoer();
|
||||
void testShapeBlurPPTXImport();
|
||||
void testMirroredGraphic();
|
||||
|
||||
bool checkPattern(sd::DrawDocShellRef const & rDocRef, int nShapeNumber, std::vector<sal_uInt8>& rExpected);
|
||||
void testPatternImport();
|
||||
@@ -340,6 +341,7 @@ public:
|
||||
CPPUNIT_TEST(testTdf49856);
|
||||
CPPUNIT_TEST(testShapeGlowEffectPPTXImpoer);
|
||||
CPPUNIT_TEST(testShapeBlurPPTXImport);
|
||||
CPPUNIT_TEST(testMirroredGraphic);
|
||||
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
};
|
||||
@@ -3305,6 +3307,20 @@ void SdImportTest::testShapeBlurPPTXImport()
|
||||
|
||||
}
|
||||
|
||||
void SdImportTest::testMirroredGraphic()
|
||||
{
|
||||
sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/mirrored-graphic.pptx"), PPTX);
|
||||
uno::Reference<beans::XPropertySet> xShape(getShapeFromPage(0, 0, xDocShRef), uno::UNO_SET_THROW);
|
||||
CPPUNIT_ASSERT(xShape.is());
|
||||
uno::Reference<graphic::XGraphic> xGraphic;
|
||||
xShape->getPropertyValue("FillBitmap") >>= xGraphic;
|
||||
CPPUNIT_ASSERT(xGraphic.is());
|
||||
Graphic aGraphic(xGraphic);
|
||||
BitmapEx aBitmap(aGraphic.GetBitmapEx());
|
||||
CPPUNIT_ASSERT_EQUAL( Color(5196117), aBitmap.GetPixelColor( 0, 0 ));
|
||||
xDocShRef->DoClose();
|
||||
}
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTest);
|
||||
|
||||
CPPUNIT_PLUGIN_IMPLEMENT();
|
||||
|
||||
Reference in New Issue
Block a user