[Libreoffice-commits] core.git: Branch 'libreoffice-6-1' - filter/source sd/qa

Miklos Vajna vmiklos at collabora.co.uk
Fri Jun 8 20:58:00 UTC 2018


 filter/source/msfilter/msdffimp.cxx |    3 +++
 sd/qa/unit/data/ppt/crop.ppt        |binary
 sd/qa/unit/import-tests.cxx         |   21 +++++++++++++++++++++
 3 files changed, 24 insertions(+)

New commits:
commit aecab50c291a535bc0ccfd30b86060faf6bea994
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Fri Jun 8 09:27:32 2018 +0200

    tdf#118037 PPT import: fix lost crop of graphic
    
    Regression from commit b11188835d3b87cd9d2a8cdb3da204cfda5d3e6e (DOC
    import: lazy-read images, 2018-04-20).
    
    (cherry picked from commit 11d542352e1088a2c870b0e73e14e10266276483)
    
    Change-Id: Ie2155c971d94153352a9372a9795cbb9d820dd40
    Reviewed-on: https://gerrit.libreoffice.org/55468
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx
index 3e80858d9275..923013f96d82 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
Binary files /dev/null and b/sd/qa/unit/data/ppt/crop.ppt differ
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index 28474a88d4bb..cc2c11b01813 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -74,6 +74,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>
@@ -186,6 +187,7 @@ public:
 
     bool checkPattern(sd::DrawDocShellRef const & rDocRef, int nShapeNumber, std::vector<sal_uInt8>& rExpected);
     void testPatternImport();
+    void testPptCrop();
 
     CPPUNIT_TEST_SUITE(SdImportTest);
 
@@ -267,6 +269,7 @@ public:
     CPPUNIT_TEST(testTdf116899);
     CPPUNIT_TEST(testTdf77747);
     CPPUNIT_TEST(testTdf116266);
+    CPPUNIT_TEST(testPptCrop);
 
     CPPUNIT_TEST_SUITE_END();
 };
@@ -633,6 +636,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);


More information about the Libreoffice-commits mailing list