summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2018-06-08 09:27:32 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2018-06-08 10:20:58 +0200
commit11d542352e1088a2c870b0e73e14e10266276483 (patch)
tree6ce8010f815f68c1fa28601ea1915376cb5b8bb5
parentbff31df1398b81c0348aebae2c346474724c4884 (diff)
tdf#118037 PPT import: fix lost crop of graphic
Regression from commit b11188835d3b87cd9d2a8cdb3da204cfda5d3e6e (DOC import: lazy-read images, 2018-04-20). Change-Id: Ie2155c971d94153352a9372a9795cbb9d820dd40 Reviewed-on: https://gerrit.libreoffice.org/55452 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org>
-rw-r--r--filter/source/msfilter/msdffimp.cxx3
-rw-r--r--sd/qa/unit/data/ppt/crop.pptbin0 -> 147456 bytes
-rw-r--r--sd/qa/unit/import-tests.cxx21
3 files changed, 24 insertions, 0 deletions
diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx
index 2e6843eb2d61..7d7e5e385390 100644
--- a/filter/source/msfilter/msdffimp.cxx
+++ b/filter/source/msfilter/msdffimp.cxx
@@ -3719,6 +3719,9 @@ static void lcl_ApplyCropping( const DffPropSet& rPropSet, SfxItemSet* pSet, Gra
BitmapEx aCropBitmap;
sal_uInt32 nTop( 0 ), nBottom( 0 ), nLeft( 0 ), nRight( 0 );
+ // Cropping has to be applied on a loaded graphic.
+ rGraf.makeAvailable();
+
if ( pSet ) // use crop attributes ?
aCropSize = lcl_GetPrefSize(rGraf, MapMode(MapUnit::Map100thMM));
else
diff --git a/sd/qa/unit/data/ppt/crop.ppt b/sd/qa/unit/data/ppt/crop.ppt
new file mode 100644
index 000000000000..844a4392a1d4
--- /dev/null
+++ b/sd/qa/unit/data/ppt/crop.ppt
Binary files differ
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index 9e07f8be4774..39f7f6df766e 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -75,6 +75,7 @@
#include <com/sun/star/table/XTableRows.hpp>
#include <com/sun/star/style/NumberingType.hpp>
#include <com/sun/star/frame/Desktop.hpp>
+#include <com/sun/star/text/GraphicCrop.hpp>
#include <stlpool.hxx>
#include <comphelper/processfactory.hxx>
@@ -187,6 +188,7 @@ public:
bool checkPattern(sd::DrawDocShellRef const & rDocRef, int nShapeNumber, std::vector<sal_uInt8>& rExpected);
void testPatternImport();
+ void testPptCrop();
CPPUNIT_TEST_SUITE(SdImportTest);
@@ -268,6 +270,7 @@ public:
CPPUNIT_TEST(testTdf116899);
CPPUNIT_TEST(testTdf77747);
CPPUNIT_TEST(testTdf116266);
+ CPPUNIT_TEST(testPptCrop);
CPPUNIT_TEST_SUITE_END();
};
@@ -634,6 +637,24 @@ void SdImportTest::testFdo68594()
xDocShRef->DoClose();
}
+void SdImportTest::testPptCrop()
+{
+ sd::DrawDocShellRef xDocShRef
+ = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/ppt/crop.ppt"), PPT);
+
+ uno::Reference<beans::XPropertySet> xPropertySet(
+ getShapeFromPage(/*nShape=*/1, /*nPage=*/0, xDocShRef));
+ text::GraphicCrop aCrop;
+ xPropertySet->getPropertyValue("GraphicCrop") >>= aCrop;
+ // These were all 0, lazy-loading broke cropping.
+ CPPUNIT_ASSERT_GREATER(static_cast<sal_Int32>(0), aCrop.Top);
+ CPPUNIT_ASSERT_GREATER(static_cast<sal_Int32>(0), aCrop.Bottom);
+ CPPUNIT_ASSERT_GREATER(static_cast<sal_Int32>(0), aCrop.Left);
+ CPPUNIT_ASSERT_GREATER(static_cast<sal_Int32>(0), aCrop.Right);
+
+ xDocShRef->DoClose();
+}
+
void SdImportTest::testFdo72998()
{
sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/cshapes.pptx"), PPTX);