diff options
-rw-r--r-- | filter/source/msfilter/svdfppt.cxx | 54 | ||||
-rw-r--r-- | sd/CppunitTest_sd_import_tests.mk | 1 | ||||
-rw-r--r-- | sd/qa/unit/data/ppt/tdf93124.ppt | bin | 0 -> 85504 bytes | |||
-rw-r--r-- | sd/qa/unit/import-tests.cxx | 51 |
4 files changed, 78 insertions, 28 deletions
diff --git a/filter/source/msfilter/svdfppt.cxx b/filter/source/msfilter/svdfppt.cxx index 437207f12503..7ac251cbfe02 100644 --- a/filter/source/msfilter/svdfppt.cxx +++ b/filter/source/msfilter/svdfppt.cxx @@ -893,7 +893,6 @@ SdrObject* SdrEscherImport::ProcessObj( SvStream& rSt, DffObjData& rObjData, voi eTHA = SDRTEXTHORZADJUST_LEFT; break; } - // if there is a 100% use of following attributes, the textbox can been aligned also in vertical direction switch ( eTextAnchor ) { case mso_anchorTopCentered : @@ -903,20 +902,20 @@ SdrObject* SdrEscherImport::ProcessObj( SvStream& rSt, DffObjData& rObjData, voi case mso_anchorBottomCenteredBaseline: { // check if it is sensible to use the centered alignment - sal_uInt32 nMask = PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_LEFT | PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_RIGHT; - if ( ( nTextFlags & nMask ) != nMask ) // if the textobject has left and also right aligned pararagraphs - eTVA = SDRTEXTVERTADJUST_CENTER; // the text has to be displayed using the full width; - } - break; - - default : - { - if ( nTextFlags == PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_LEFT ) - eTVA = SDRTEXTVERTADJUST_TOP; - else if ( nTextFlags == PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_RIGHT ) - eTVA = SDRTEXTVERTADJUST_BOTTOM; + const sal_uInt32 nMask = PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_LEFT | PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_CENTER | PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_RIGHT | PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_BLOCK; + switch (nTextFlags & nMask) + { + case PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_LEFT: + case PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_CENTER: + case PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_RIGHT: + case PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_BLOCK: + eTVA = SDRTEXTVERTADJUST_CENTER; // If the textobject has only one type of alignment, then the text has not to be displayed using the full width; + break; + } + break; } - break; + default: + break; } nMinFrameWidth = rTextRect.GetWidth() - ( nTextLeft + nTextRight ); } @@ -949,7 +948,6 @@ SdrObject* SdrEscherImport::ProcessObj( SvStream& rSt, DffObjData& rObjData, voi eTVA = SDRTEXTVERTADJUST_BOTTOM; break; } - // if there is a 100% usage of following attributes, the textbox can be aligned also in horizontal direction switch ( eTextAnchor ) { case mso_anchorTopCentered : @@ -959,20 +957,20 @@ SdrObject* SdrEscherImport::ProcessObj( SvStream& rSt, DffObjData& rObjData, voi case mso_anchorBottomCenteredBaseline: { // check if it is sensible to use the centered alignment - sal_uInt32 nMask = PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_LEFT | PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_RIGHT; - if ( ( nTextFlags & nMask ) != nMask ) // if the textobject has left and also right aligned pararagraphs - eTHA = SDRTEXTHORZADJUST_CENTER; // the text has to be displayed using the full width; - } - break; - - default : - { - if ( nTextFlags == PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_LEFT ) - eTHA = SDRTEXTHORZADJUST_LEFT; - else if ( nTextFlags == PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_RIGHT ) - eTHA = SDRTEXTHORZADJUST_RIGHT; + const sal_uInt32 nMask = PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_LEFT | PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_CENTER | PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_RIGHT | PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_BLOCK; + switch (nTextFlags & nMask) + { + case PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_LEFT: + case PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_CENTER: + case PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_RIGHT: + case PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_BLOCK: + eTHA = SDRTEXTHORZADJUST_CENTER; // If the textobject has only one type of alignment, then the text has not to be displayed using the full width; + break; + } + break; } - break; + default: + break; } nMinFrameHeight = rTextRect.GetHeight() - ( nTextTop + nTextBottom ); } diff --git a/sd/CppunitTest_sd_import_tests.mk b/sd/CppunitTest_sd_import_tests.mk index 6058e8e58cfc..33a7ad28d463 100644 --- a/sd/CppunitTest_sd_import_tests.mk +++ b/sd/CppunitTest_sd_import_tests.mk @@ -96,6 +96,7 @@ $(eval $(call gb_CppunitTest_use_components,sd_import_tests,\ sot/util/sot \ svl/source/fsstor/fsstorage \ svtools/util/svt \ + svx/util/svxcore \ toolkit/util/tk \ ucb/source/core/ucb1 \ ucb/source/ucp/expand/ucpexpand1 \ diff --git a/sd/qa/unit/data/ppt/tdf93124.ppt b/sd/qa/unit/data/ppt/tdf93124.ppt Binary files differnew file mode 100644 index 000000000000..fad847898cc6 --- /dev/null +++ b/sd/qa/unit/data/ppt/tdf93124.ppt diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx index 3ebd1116b957..e95cfecd1082 100644 --- a/sd/qa/unit/import-tests.cxx +++ b/sd/qa/unit/import-tests.cxx @@ -42,6 +42,7 @@ #include <sax/tools/converter.hxx> #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> +#include <com/sun/star/drawing/GraphicExportFilter.hpp> #include <com/sun/star/drawing/XDrawPage.hpp> #include <com/sun/star/drawing/XDrawPagesSupplier.hpp> #include <com/sun/star/drawing/XMasterPagesSupplier.hpp> @@ -64,6 +65,9 @@ #include <com/sun/star/table/XTableRows.hpp> #include <stlpool.hxx> +#include <comphelper/processfactory.hxx> +#include <vcl/pngread.hxx> +#include <vcl/bitmapaccess.hxx> using namespace ::com::sun::star; @@ -112,6 +116,7 @@ public: void testTdf93830(); void testTdf93097(); void testTdf62255(); + void testTdf93124(); void testTdf89927(); void testTdf93868(); void testTdf95932(); @@ -160,6 +165,7 @@ public: CPPUNIT_TEST(testTdf93830); CPPUNIT_TEST(testTdf93097); CPPUNIT_TEST(testTdf62255); + CPPUNIT_TEST(testTdf93124); CPPUNIT_TEST(testTdf89927); CPPUNIT_TEST(testTdf93868); CPPUNIT_TEST(testTdf95932); @@ -1259,6 +1265,51 @@ void SdImportTest::testTdf62255() xDocShRef->DoClose(); } +void SdImportTest::testTdf93124() +{ + sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/ppt/tdf93124.ppt"), PPT); + uno::Reference < uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext(); + uno::Reference< drawing::XGraphicExportFilter > xGraphicExporter = drawing::GraphicExportFilter::create(xContext); + + uno::Sequence< beans::PropertyValue > aFilterData(2); + aFilterData[0].Name = "PixelWidth"; + aFilterData[0].Value <<= (sal_Int32)(320); + aFilterData[1].Name = "PixelHeight"; + aFilterData[1].Value <<= (sal_Int32)(180); + + utl::TempFile aTempFile; + aTempFile.EnableKillingFile(); + + uno::Sequence< beans::PropertyValue > aDescriptor(3); + aDescriptor[0].Name = "URL"; + aDescriptor[0].Value <<= aTempFile.GetURL(); + aDescriptor[1].Name = "FilterName"; + aDescriptor[1].Value <<= OUString("PNG"); + aDescriptor[2].Name = "FilterData"; + aDescriptor[2].Value <<= aFilterData; + + uno::Reference< lang::XComponent > xPage(getPage(0, xDocShRef), uno::UNO_QUERY); + xGraphicExporter->setSourceDocument(xPage); + xGraphicExporter->filter(aDescriptor); + + SvFileStream aFileStream(aTempFile.GetURL(), StreamMode::READ); + vcl::PNGReader aPNGReader(aFileStream); + BitmapEx aBMPEx = aPNGReader.Read(); + Bitmap aBMP = aBMPEx.GetBitmap(); + BitmapReadAccess* pRead = aBMP.AcquireReadAccess(); + int nNonWhiteCount = 0; + // The word "Top" should be in rectangle 34,4 - 76,30. If text alignment is wrong, the rectangle will be white. + for (long nX = 34; nX < (34 + 43); ++nX) + for (long nY = 4; nY < (4 + 26); ++nY) + { + const Color aColor = pRead->GetColor(nY, nX); + if ((aColor.GetRed() != 0xff) || (aColor.GetGreen() != 0xff) || (aColor.GetBlue() != 0xff)) + ++nNonWhiteCount; + } + CPPUNIT_ASSERT_MESSAGE("Tdf93124: vertical alignment of text is incorrect!", nNonWhiteCount>100); + xDocShRef->DoClose(); +} + void SdImportTest::testTdf89927() { sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/tdf89927.pptx"), PPTX); |