diff options
author | Zolnai Tamás <tamas.zolnai@collabora.com> | 2014-02-12 12:06:10 +0100 |
---|---|---|
committer | Zolnai Tamás <tamas.zolnai@collabora.com> | 2014-02-12 13:20:31 +0100 |
commit | 682ab832522b1349f1714bcb16f6e83468ea2920 (patch) | |
tree | 4371361c2a94bb85cd9cb458db9a90022d271460 /sw | |
parent | b16f90f33143e6c8c9e8e2fa9cc55797b5bbff12 (diff) |
drawingML export\import: cropping of shape's fill texture
In Writer shapes had no cropping property so far. With this
commit this is introduced as a FillProperty and has the same
type as the cropping used for pictures
(Picture context menu > Picture > Crop).
Layout and UI will be an other step. On the UI it would be placed
on the Shape context menu -> Area, when Bitmap is selected as fill type.
Note: In case of picture/graphic, cropping property is imported from
and exported to a:srcRect instead of a:fillRect.
Change-Id: Idc1ed2d40cb20b6992e94f14e7e4d853e1f55d02
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/dml-shape-fillbitmapcrop.docx | bin | 0 -> 33037 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 26 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlimport/data/dml-shape-fillbitmapcrop.docx | bin | 0 -> 33037 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 24 |
4 files changed, 49 insertions, 1 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/dml-shape-fillbitmapcrop.docx b/sw/qa/extras/ooxmlexport/data/dml-shape-fillbitmapcrop.docx Binary files differnew file mode 100644 index 000000000000..6c401bae9399 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/dml-shape-fillbitmapcrop.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index 9bdbe36e2e08..cdab9c15f347 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -109,7 +109,8 @@ protected: "math-mso2k7.docx", "ImageCrop.docx", "test_GIF_ImageCrop.docx", - "test_PNG_ImageCrop.docx" + "test_PNG_ImageCrop.docx", + "dml-shape-fillbitmapcrop.docx" }; std::vector<const char*> vBlacklist(aBlacklist, aBlacklist + SAL_N_ELEMENTS(aBlacklist)); @@ -2940,6 +2941,29 @@ DECLARE_OOXMLEXPORT_TEST(testDMLTextFrameVertAdjust, "dml-textframe-vertadjust.d xFrame.set(getTextFrameByName("Rectangle 3"), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(drawing::TextVerticalAdjust_BOTTOM, getProperty<drawing::TextVerticalAdjust>(xFrame, "TextVerticalAdjust")); } + +DECLARE_OOXMLEXPORT_TEST(testDMLShapeFillBitmapCrop, "dml-shape-fillbitmapcrop.docx") +{ + // Test the new GraphicCrop property which is introduced to define + // cropping of shapes filled with a picture in stretch mode. + + // 1st shape has some cropping + text::GraphicCrop aGraphicCropStruct = getProperty<text::GraphicCrop>(getShape(1), "GraphicCrop"); + + CPPUNIT_ASSERT_EQUAL( sal_Int32( 454 ), aGraphicCropStruct.Left ); + CPPUNIT_ASSERT_EQUAL( sal_Int32( 367 ), aGraphicCropStruct.Right ); + CPPUNIT_ASSERT_EQUAL( sal_Int32( -454 ), aGraphicCropStruct.Top ); + CPPUNIT_ASSERT_EQUAL( sal_Int32( -367 ), aGraphicCropStruct.Bottom ); + + // 2nd shape has no cropping + aGraphicCropStruct = getProperty<text::GraphicCrop>(getShape(2), "GraphicCrop"); + + CPPUNIT_ASSERT_EQUAL( sal_Int32( 0 ), aGraphicCropStruct.Left ); + CPPUNIT_ASSERT_EQUAL( sal_Int32( 0 ), aGraphicCropStruct.Right ); + CPPUNIT_ASSERT_EQUAL( sal_Int32( 0 ), aGraphicCropStruct.Top ); + CPPUNIT_ASSERT_EQUAL( sal_Int32( 0 ), aGraphicCropStruct.Bottom ); + +} #endif CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/qa/extras/ooxmlimport/data/dml-shape-fillbitmapcrop.docx b/sw/qa/extras/ooxmlimport/data/dml-shape-fillbitmapcrop.docx Binary files differnew file mode 100644 index 000000000000..6c401bae9399 --- /dev/null +++ b/sw/qa/extras/ooxmlimport/data/dml-shape-fillbitmapcrop.docx diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx index 91c5ede584c0..8195558a545f 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx @@ -52,6 +52,7 @@ #include <vcl/svapp.hxx> #include <unotools/fltrcfg.hxx> #include <comphelper/sequenceashashmap.hxx> +#include <com/sun/star/text/GraphicCrop.hpp> #include <bordertest.hxx> @@ -1789,6 +1790,29 @@ DECLARE_OOXMLIMPORT_TEST(testDMLGroupShapeParaAdjust, "dml-groupshape-paraadjust // 7th line has no adjustment CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_LEFT), getProperty<sal_Int16>(getRun(getParagraphOfText(7, xText), 1), "ParaAdjust")); } + +DECLARE_OOXMLIMPORT_TEST(testDMLShapeFillBitmapCrop, "dml-shape-fillbitmapcrop.docx") +{ + // The same test can be found in ooxmlexport, but some rouding made on crop values so we can't test import and + // export with the same values. + + // 1st shape has some cropping + text::GraphicCrop aGraphicCropStruct = getProperty<text::GraphicCrop>(getShape(1), "GraphicCrop"); + + CPPUNIT_ASSERT_EQUAL( sal_Int32( 455 ), aGraphicCropStruct.Left ); + CPPUNIT_ASSERT_EQUAL( sal_Int32( 368 ), aGraphicCropStruct.Right ); + CPPUNIT_ASSERT_EQUAL( sal_Int32( -455 ), aGraphicCropStruct.Top ); + CPPUNIT_ASSERT_EQUAL( sal_Int32( -368 ), aGraphicCropStruct.Bottom ); + + // 2nd shape has no cropping + aGraphicCropStruct = getProperty<text::GraphicCrop>(getShape(2), "GraphicCrop"); + + CPPUNIT_ASSERT_EQUAL( sal_Int32( 0 ), aGraphicCropStruct.Left ); + CPPUNIT_ASSERT_EQUAL( sal_Int32( 0 ), aGraphicCropStruct.Right ); + CPPUNIT_ASSERT_EQUAL( sal_Int32( 0 ), aGraphicCropStruct.Top ); + CPPUNIT_ASSERT_EQUAL( sal_Int32( 0 ), aGraphicCropStruct.Bottom ); + +} #endif CPPUNIT_PLUGIN_IMPLEMENT(); |