summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorGülşah Köse <gulsah.kose@collabora.com>2021-02-01 17:03:33 +0300
committerXisco Fauli <xiscofauli@libreoffice.org>2021-02-16 12:00:37 +0100
commit33e69fb9ef450169e7d85ae3215fd9a4fc8082c2 (patch)
tree3cdfdc6259638b068e652c13d5d3779cc2c28787 /sd
parent5f4808d7536a4c551c8764ac2ac6be30ad975f69 (diff)
tdf#134210 Import crop position of bitmap filled shape.
Change-Id: I6a62d68cd0f57e53934851a2f53dae05bf7d3730 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110262 Tested-by: Jenkins Reviewed-by: Gülşah Köse <gulsah.kose@collabora.com> Signed-off-by: Xisco Fauli <xiscofauli@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110973
Diffstat (limited to 'sd')
-rw-r--r--sd/qa/unit/data/pptx/crop-position.pptxbin0 -> 175724 bytes
-rw-r--r--sd/qa/unit/export-tests-ooxml1.cxx29
-rw-r--r--sd/qa/unit/import-tests.cxx16
3 files changed, 40 insertions, 5 deletions
diff --git a/sd/qa/unit/data/pptx/crop-position.pptx b/sd/qa/unit/data/pptx/crop-position.pptx
new file mode 100644
index 000000000000..69507514e0b7
--- /dev/null
+++ b/sd/qa/unit/data/pptx/crop-position.pptx
Binary files differ
diff --git a/sd/qa/unit/export-tests-ooxml1.cxx b/sd/qa/unit/export-tests-ooxml1.cxx
index 0e938e05e9c7..a1e752834f1a 100644
--- a/sd/qa/unit/export-tests-ooxml1.cxx
+++ b/sd/qa/unit/export-tests-ooxml1.cxx
@@ -1145,17 +1145,36 @@ void SdOOXMLExportTest1::testCustomshapeBitmapfillSrcrect()
xDocShRef->DoClose();
xmlDocUniquePtr pXmlDoc = parseExport(tempFile, "ppt/slides/slide1.xml");
- const OString sXmlPath = "//a:blipFill/a:srcRect";
+
+ // tdf#132680
+ // We are preventing the side effect of DOCX improvement to PPTX case.
// Without the accompanying fix in place, this test would have failed with:
// - Expected: 1
// - Actual : 0
// - XPath '//a:blipFill/a:srcRect' number of nodes is incorrect
// i.e. <a:srcRect> was exported as <a:fillRect> in <a:stretch>, which made part of the image
// invisible.
- double fLeftPercent = std::round(getXPath(pXmlDoc, sXmlPath, "l").toDouble() / 1000);
- CPPUNIT_ASSERT_EQUAL(4.0, fLeftPercent);
- double fRightPercent = std::round(getXPath(pXmlDoc, sXmlPath, "r").toDouble() / 1000);
- CPPUNIT_ASSERT_EQUAL(4.0, fRightPercent);
+
+ // tdf#134210
+ // Original values of attribute of l and r in xml files: <a:srcRect l="4393" r="4393"/>
+ // Because of we have not core feature for cropping bitmap in custom shapes, we added cropping
+ // support to import filter. We modified the bitmap during import. As result the original
+ // image is cropped anymore (if we had the core feature for that, the original image would
+ // remain same, just we would see like cropped in the shape) To see the image in correct
+ // position in Microsoft Office too, we have to remove left right top bottom percentages
+ // anymore. In the future if we add core feature to LibreOffice, this test will failed with
+ // When we add the core feature, we should change the control value with 4393 as following.
+
+ //const OString sXmlPath = "//a:blipFill/a:srcRect";
+ //sal_Int32 nLeftPercent = getXPath(pXmlDoc, sXmlPath, "l").toInt32();
+ //CPPUNIT_ASSERT_EQUAL(sal_Int32(4393), nLeftPercent);
+ //sal_Int32 nRightPercent = getXPath(pXmlDoc, sXmlPath, "r").toInt32();
+ //CPPUNIT_ASSERT_EQUAL(sal_Int32(4393), nRightPercent);
+
+ assertXPathNoAttribute(pXmlDoc, "/p:sld/p:cSld/p:spTree/p:sp/p:spPr/a:blipFill/a:srcRect", "l");
+ assertXPathNoAttribute(pXmlDoc, "/p:sld/p:cSld/p:spTree/p:sp/p:spPr/a:blipFill/a:srcRect", "r");
+ assertXPathNoAttribute(pXmlDoc, "/p:sld/p:cSld/p:spTree/p:sp/p:spPr/a:blipFill/a:srcRect", "t");
+ assertXPathNoAttribute(pXmlDoc, "/p:sld/p:cSld/p:spTree/p:sp/p:spPr/a:blipFill/a:srcRect", "b");
}
void SdOOXMLExportTest1::testTdf100348FontworkBitmapFill()
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index eff937566383..9aefdd4ecc7b 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -217,6 +217,7 @@ public:
void testShapeGlowEffectPPTXImpoer();
void testShapeBlurPPTXImport();
void testMirroredGraphic();
+ void testCropPositionGraphic();
bool checkPattern(sd::DrawDocShellRef const & rDocRef, int nShapeNumber, std::vector<sal_uInt8>& rExpected);
void testPatternImport();
@@ -346,6 +347,7 @@ public:
CPPUNIT_TEST(testShapeGlowEffectPPTXImpoer);
CPPUNIT_TEST(testShapeBlurPPTXImport);
CPPUNIT_TEST(testMirroredGraphic);
+ CPPUNIT_TEST(testCropPositionGraphic);
CPPUNIT_TEST_SUITE_END();
};
@@ -3324,6 +3326,20 @@ void SdImportTest::testMirroredGraphic()
xDocShRef->DoClose();
}
+void SdImportTest::testCropPositionGraphic()
+{
+ sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/crop-position.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(8682893), aBitmap.GetPixelColor( 0, 0 ));
+ xDocShRef->DoClose();
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTest);
CPPUNIT_PLUGIN_IMPLEMENT();