tdf#134210 Import support for custom stretch values.
Change-Id: I33ced8d667e37b7fb79f4c87b689f45966ac0097 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109658 Tested-by: Jenkins Reviewed-by: Gülşah Köse <gulsah.kose@collabora.com>
This commit is contained in:
committed by
Miklos Vajna
parent
e2b3b0b365
commit
2c96bd26ec
@@ -146,7 +146,8 @@ struct FillProperties
|
|||||||
sal_Int32 nShapeRotation = 0,
|
sal_Int32 nShapeRotation = 0,
|
||||||
::Color nPhClr = API_RGB_TRANSPARENT,
|
::Color nPhClr = API_RGB_TRANSPARENT,
|
||||||
bool bFlipH = false,
|
bool bFlipH = false,
|
||||||
bool bFlipV = false ) const;
|
bool bFlipV = false,
|
||||||
|
bool bIsCustomShape = false ) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace oox::drawingml
|
} // namespace oox::drawingml
|
||||||
|
@@ -87,6 +87,32 @@ Reference< XGraphic > lclRotateGraphic(uno::Reference<graphic::XGraphic> const &
|
|||||||
return aReturnGraphic.GetXGraphic();
|
return aReturnGraphic.GetXGraphic();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference< XGraphic > lclCropGraphic(uno::Reference<graphic::XGraphic> const & xGraphic, geometry::IntegerRectangle2D aFillRect)
|
||||||
|
{
|
||||||
|
::Graphic aGraphic(xGraphic);
|
||||||
|
::Graphic aReturnGraphic;
|
||||||
|
|
||||||
|
assert (aGraphic.GetType() == GraphicType::Bitmap);
|
||||||
|
|
||||||
|
BitmapEx aBitmapEx(aGraphic.GetBitmapEx());
|
||||||
|
|
||||||
|
sal_Int32 nOrigHeight = aBitmapEx.GetSizePixel().Height();
|
||||||
|
sal_Int32 nHeight = nOrigHeight;
|
||||||
|
sal_Int32 nTopCorr = nOrigHeight * -1 * static_cast<double>(aFillRect.Y1) / 100000;
|
||||||
|
nHeight += nTopCorr;
|
||||||
|
sal_Int32 nBottomCorr = nOrigHeight * -1 * static_cast<double>(aFillRect.Y2) / 100000;
|
||||||
|
nHeight += nBottomCorr;
|
||||||
|
|
||||||
|
aBitmapEx.Scale(Size(aBitmapEx.GetSizePixel().Width(), nHeight));
|
||||||
|
aBitmapEx.Crop(tools::Rectangle(Point(0, nTopCorr), Size(aBitmapEx.GetSizePixel().Width(), nOrigHeight)));
|
||||||
|
|
||||||
|
aReturnGraphic = ::Graphic(aBitmapEx);
|
||||||
|
aReturnGraphic.setOriginURL(aGraphic.getOriginURL());
|
||||||
|
|
||||||
|
return aReturnGraphic.GetXGraphic();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Reference< XGraphic > lclCheckAndApplyChangeColorTransform(const BlipFillProperties &aBlipProps, uno::Reference<graphic::XGraphic> const & xGraphic,
|
Reference< XGraphic > lclCheckAndApplyChangeColorTransform(const BlipFillProperties &aBlipProps, uno::Reference<graphic::XGraphic> const & xGraphic,
|
||||||
const GraphicHelper& rGraphicHelper, const ::Color nPhClr)
|
const GraphicHelper& rGraphicHelper, const ::Color nPhClr)
|
||||||
{
|
{
|
||||||
@@ -272,7 +298,7 @@ Color FillProperties::getBestSolidColor() const
|
|||||||
|
|
||||||
void FillProperties::pushToPropMap( ShapePropertyMap& rPropMap,
|
void FillProperties::pushToPropMap( ShapePropertyMap& rPropMap,
|
||||||
const GraphicHelper& rGraphicHelper, sal_Int32 nShapeRotation, ::Color nPhClr,
|
const GraphicHelper& rGraphicHelper, sal_Int32 nShapeRotation, ::Color nPhClr,
|
||||||
bool bFlipH, bool bFlipV ) const
|
bool bFlipH, bool bFlipV, bool bIsCustomShape) const
|
||||||
{
|
{
|
||||||
if( !moFillType.has() )
|
if( !moFillType.has() )
|
||||||
return;
|
return;
|
||||||
@@ -675,6 +701,12 @@ void FillProperties::pushToPropMap( ShapePropertyMap& rPropMap,
|
|||||||
if ( aFillRect.Y2 )
|
if ( aFillRect.Y2 )
|
||||||
aGraphCrop.Bottom = static_cast< sal_Int32 >( ( static_cast< double >( aOriginalSize.Height ) * aFillRect.Y2 ) / 100000 );
|
aGraphCrop.Bottom = static_cast< sal_Int32 >( ( static_cast< double >( aOriginalSize.Height ) * aFillRect.Y2 ) / 100000 );
|
||||||
rPropMap.setProperty(PROP_GraphicCrop, aGraphCrop);
|
rPropMap.setProperty(PROP_GraphicCrop, aGraphCrop);
|
||||||
|
|
||||||
|
if(bIsCustomShape)
|
||||||
|
{
|
||||||
|
xGraphic = lclCropGraphic(xGraphic, aFillRect);
|
||||||
|
rPropMap.setProperty(ShapeProperty::FillBitmap, xGraphic);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1058,7 +1058,7 @@ Reference< XShape > const & Shape::createAndInsert(
|
|||||||
if (getFillProperties().moFillType.has() && getFillProperties().moFillType.get() == XML_grpFill)
|
if (getFillProperties().moFillType.has() && getFillProperties().moFillType.get() == XML_grpFill)
|
||||||
getFillProperties().assignUsed(aFillProperties);
|
getFillProperties().assignUsed(aFillProperties);
|
||||||
if(!bIsCroppedGraphic)
|
if(!bIsCroppedGraphic)
|
||||||
aFillProperties.pushToPropMap( aShapeProps, rGraphicHelper, mnRotation, nFillPhClr, mbFlipH, mbFlipV );
|
aFillProperties.pushToPropMap( aShapeProps, rGraphicHelper, mnRotation, nFillPhClr, mbFlipH, mbFlipV, bIsCustomShape );
|
||||||
LineProperties aLineProperties = getActualLineProperties(pTheme);
|
LineProperties aLineProperties = getActualLineProperties(pTheme);
|
||||||
aLineProperties.pushToPropMap( aShapeProps, rGraphicHelper, nLinePhClr );
|
aLineProperties.pushToPropMap( aShapeProps, rGraphicHelper, nLinePhClr );
|
||||||
EffectProperties aEffectProperties = getActualEffectProperties(pTheme);
|
EffectProperties aEffectProperties = getActualEffectProperties(pTheme);
|
||||||
|
BIN
sd/qa/unit/data/pptx/tdf134210.pptx
Normal file
BIN
sd/qa/unit/data/pptx/tdf134210.pptx
Normal file
Binary file not shown.
@@ -200,6 +200,7 @@ public:
|
|||||||
void testTdf138148();
|
void testTdf138148();
|
||||||
void testTdf114488();
|
void testTdf114488();
|
||||||
void testTdf134174();
|
void testTdf134174();
|
||||||
|
void testTdf134210();
|
||||||
void testTdf114913();
|
void testTdf114913();
|
||||||
void testTdf114821();
|
void testTdf114821();
|
||||||
void testTdf115394();
|
void testTdf115394();
|
||||||
@@ -314,6 +315,7 @@ public:
|
|||||||
CPPUNIT_TEST(testTdf138148);
|
CPPUNIT_TEST(testTdf138148);
|
||||||
CPPUNIT_TEST(testTdf114488);
|
CPPUNIT_TEST(testTdf114488);
|
||||||
CPPUNIT_TEST(testTdf134174);
|
CPPUNIT_TEST(testTdf134174);
|
||||||
|
CPPUNIT_TEST(testTdf134210);
|
||||||
CPPUNIT_TEST(testTdf114913);
|
CPPUNIT_TEST(testTdf114913);
|
||||||
CPPUNIT_TEST(testTdf114821);
|
CPPUNIT_TEST(testTdf114821);
|
||||||
CPPUNIT_TEST(testTdf115394);
|
CPPUNIT_TEST(testTdf115394);
|
||||||
@@ -2748,6 +2750,23 @@ void SdImportTest::testTdf134174()
|
|||||||
xDocShRef->DoClose();
|
xDocShRef->DoClose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SdImportTest::testTdf134210()
|
||||||
|
{
|
||||||
|
sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/tdf134210.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(6708292), aBitmap.GetPixelColor( 0, 0 ));
|
||||||
|
|
||||||
|
xDocShRef->DoClose();
|
||||||
|
}
|
||||||
|
|
||||||
void SdImportTest::testTdf114913()
|
void SdImportTest::testTdf114913()
|
||||||
{
|
{
|
||||||
sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/tdf114913.pptx"), PPTX);
|
sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/tdf114913.pptx"), PPTX);
|
||||||
|
Reference in New Issue
Block a user