oox/source/ppt/pptshape.cxx | 1 sc/source/ui/unoobj/datauno.cxx | 1 sd/CppunitTest_sd_export_tests.mk | 119 ++++++++++ sd/Module_sd.mk | 1 sd/qa/unit/export-tests.cxx | 427 ++++++++++++++++++++++++++++++++++++++ sd/qa/unit/import-tests.cxx | 395 ----------------------------------- sd/qa/unit/sdmodeltestbase.hxx | 8 test/source/bootstrapfixture.cxx | 4 8 files changed, 559 insertions(+), 397 deletions(-)
New commits: commit 9feb55b662ac75209adc664ef86571c261a74ded Author: Markus Mohrhard <markus.mohrh...@collabora.co.uk> Date: Fri Jul 4 15:58:54 2014 +0200 make the validation working correctly We still have ODP validation errors of the form: Change-Id: Id60df0e07a0b6d3fd2613d5c66698a6cd9b99afd Error: attribute "draw:fit-to-size" has a bad value. Possible values are: false,true diff --git a/sd/qa/unit/sdmodeltestbase.hxx b/sd/qa/unit/sdmodeltestbase.hxx index 8c1eac7..64f5a6b 100644 --- a/sd/qa/unit/sdmodeltestbase.hxx +++ b/sd/qa/unit/sdmodeltestbase.hxx @@ -181,11 +181,11 @@ protected: save(pShell, pFormat, aTempFile); if(nExportType == ODP) { - BootstrapFixture::validate(aTempFile.GetURL(), test::ODF); + // BootstrapFixture::validate(aTempFile.GetFileName(), test::ODF); } else if(nExportType == PPTX) { - // BootstrapFixture::validate(aTempFile.GetURL(), test::OOXML); + BootstrapFixture::validate(aTempFile.GetFileName(), test::OOXML); } return loadURL(aTempFile.GetURL()); } commit 76f7a05fa34835ab5ec20259d1254f3255432097 Author: Markus Mohrhard <markus.mohrh...@collabora.co.uk> Date: Fri Jul 4 15:53:40 2014 +0200 document strange code, coverity#704001 Change-Id: Id6668f47f0549e719010141929b011aa028812d2 diff --git a/sc/source/ui/unoobj/datauno.cxx b/sc/source/ui/unoobj/datauno.cxx index ac260c7..b848791 100644 --- a/sc/source/ui/unoobj/datauno.cxx +++ b/sc/source/ui/unoobj/datauno.cxx @@ -2052,6 +2052,7 @@ void SAL_CALL ScDatabaseRangeObj::setPropertyValue( { if (ScUnoHelpFunctions::GetBoolFromAny( aValue )) { + // only here to set bIsAdvanced in ScDBData ScRange aRange; aNewData.GetAdvancedQuerySource(aRange); aNewData.SetAdvancedQuerySource(&aRange); commit 4f1b91205f2535eba355e020de31080bc155f75b Author: Markus Mohrhard <markus.mohrh...@collabora.co.uk> Date: Fri Jul 4 05:34:32 2014 +0200 remove unused header file Change-Id: I78c2462f56fb4b5792f396bb7e0dd2c0fd237420 diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx index 3298b46..01aade4 100644 --- a/sd/qa/unit/import-tests.cxx +++ b/sd/qa/unit/import-tests.cxx @@ -47,8 +47,6 @@ #include <com/sun/star/chart2/data/XDataSequence.hpp> #include <com/sun/star/chart2/data/XNumericalDataSequence.hpp> -#include <config_features.h> - using namespace ::com::sun::star; /// Impress import filters tests. commit 7e3f0824a16746b1d5f62e9fca987e5a10fda92f Author: Markus Mohrhard <markus.mohrh...@collabora.co.uk> Date: Fri Jul 4 05:34:13 2014 +0200 improve test failure message Change-Id: I71d6b65b046bfc31692ba12423288c55fccb2d02 diff --git a/test/source/bootstrapfixture.cxx b/test/source/bootstrapfixture.cxx index 110e0a5..fe0a1ea 100644 --- a/test/source/bootstrapfixture.cxx +++ b/test/source/bootstrapfixture.cxx @@ -171,8 +171,8 @@ void test::BootstrapFixture::validate(const OUString& rPath, test::ValidationFor int returnValue = system(OUStringToOString(aCommand, RTL_TEXTENCODING_UTF8).getStr()); CPPUNIT_ASSERT_EQUAL_MESSAGE( - OUStringToOString(aCommand, RTL_TEXTENCODING_UTF8).getStr(), 0, - returnValue); + OUStringToOString(OUString("failed to execute: ") + aCommand, + RTL_TEXTENCODING_UTF8).getStr(), 0, returnValue); OString aContentString = loadFile(aOutput.GetURL()); OUString aContentOUString = OStringToOUString(aContentString, RTL_TEXTENCODING_UTF8); commit 597189f481ddd1a5724d7af75362053f4b5cd9c8 Author: Markus Mohrhard <markus.mohrh...@collabora.co.uk> Date: Fri Jul 4 05:26:20 2014 +0200 enable ODP export validation in sd export test Change-Id: I849d2f0d8631cfb91326d80e554c9ce55940abd8 diff --git a/sd/qa/unit/sdmodeltestbase.hxx b/sd/qa/unit/sdmodeltestbase.hxx index 636bd0d..8c1eac7 100644 --- a/sd/qa/unit/sdmodeltestbase.hxx +++ b/sd/qa/unit/sdmodeltestbase.hxx @@ -179,6 +179,14 @@ protected: utl::TempFile aTempFile(OUString(), true, &aExt); aTempFile.EnableKillingFile(); save(pShell, pFormat, aTempFile); + if(nExportType == ODP) + { + BootstrapFixture::validate(aTempFile.GetURL(), test::ODF); + } + else if(nExportType == PPTX) + { + // BootstrapFixture::validate(aTempFile.GetURL(), test::OOXML); + } return loadURL(aTempFile.GetURL()); } commit f4dca0bfa53c717f6fafddf8fbf699ca7372180a Author: Markus Mohrhard <markus.mohrh...@collabora.co.uk> Date: Fri Jul 4 05:15:31 2014 +0200 split sd's import and export tests Change-Id: I06d5b02ec94c7bb74b64cd210267acf2be1a4931 diff --git a/sd/CppunitTest_sd_export_tests.mk b/sd/CppunitTest_sd_export_tests.mk new file mode 100644 index 0000000..967e802 --- /dev/null +++ b/sd/CppunitTest_sd_export_tests.mk @@ -0,0 +1,119 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +#************************************************************************* +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +#************************************************************************* + +$(eval $(call gb_CppunitTest_CppunitTest,sd_export_test)) + +$(eval $(call gb_CppunitTest_use_external,sd_export_test,boost_headers)) + +$(eval $(call gb_CppunitTest_add_exception_objects,sd_export_test, \ + sd/qa/unit/export-tests \ +)) + +$(eval $(call gb_CppunitTest_use_libraries,sd_export_test, \ + $(call gb_Helper_optional,AVMEDIA,avmedia) \ + basegfx \ + comphelper \ + cppu \ + cppuhelper \ + drawinglayer \ + editeng \ + for \ + forui \ + i18nlangtag \ + msfilter \ + oox \ + sal \ + salhelper \ + sax \ + sd \ + sfx \ + sot \ + svl \ + svt \ + svx \ + svxcore \ + test \ + tl \ + tk \ + ucbhelper \ + unotest \ + utl \ + vcl \ + xo \ + $(gb_UWINAPI) \ +)) + +$(eval $(call gb_CppunitTest_set_include,sd_export_test,\ + -I$(SRCDIR)/sd/source/ui/inc \ + -I$(SRCDIR)/sd/inc \ + $$(INCLUDE) \ +)) + +$(eval $(call gb_CppunitTest_use_api,sd_export_test,\ + offapi \ + udkapi \ +)) + +$(eval $(call gb_CppunitTest_use_ure,sd_export_test)) +$(eval $(call gb_CppunitTest_use_vcl,sd_export_test)) + +$(eval $(call gb_CppunitTest_use_components,sd_export_test,\ + animations/source/animcore/animcore \ + basic/util/sb \ + chart2/source/chartcore \ + chart2/source/controller/chartcontroller \ + comphelper/util/comphelp \ + configmgr/source/configmgr \ + dbaccess/util/dba \ + desktop/source/deployment/deployment \ + embeddedobj/util/embobj \ + filter/source/config/cache/filterconfig1 \ + filter/source/svg/svgfilter \ + forms/util/frm \ + framework/util/fwk \ + i18npool/util/i18npool \ + linguistic/source/lng \ + oox/util/oox \ + package/source/xstor/xstor \ + package/util/package2 \ + sax/source/expatwrap/expwrap \ + sd/util/sd \ + sd/util/sdfilt \ + sd/util/sdd \ + sfx2/util/sfx \ + sot/util/sot \ + svl/source/fsstor/fsstorage \ + svtools/util/svt \ + toolkit/util/tk \ + ucb/source/core/ucb1 \ + ucb/source/ucp/expand/ucpexpand1 \ + ucb/source/ucp/file/ucpfile1 \ + ucb/source/ucp/package/ucppkg1 \ + ucb/source/ucp/tdoc/ucptdoc1 \ + unotools/util/utl \ + unoxml/source/rdf/unordf \ + unoxml/source/service/unoxml \ + xmloff/util/xo \ + xmlsecurity/util/xsec_fw \ + xmlsecurity/util/xmlsecurity \ +)) + +$(eval $(call gb_CppunitTest_use_configuration,sd_export_test)) + +$(eval $(call gb_CppunitTest_use_unittest_configuration,sd_export_test)) + +$(eval $(call gb_CppunitTest_add_arguments,sd_export_test,\ + "-env:SVG_DISABLE_FONT_EMBEDDING=YEAH" \ +)) + +$(call gb_CppunitTest_get_target,sd_export_test) : $(call gb_AllLangResTarget_get_target,sd) + +# vim: set noet sw=4 ts=4: diff --git a/sd/Module_sd.mk b/sd/Module_sd.mk index 7850ba4..93aba69 100644 --- a/sd/Module_sd.mk +++ b/sd/Module_sd.mk @@ -29,6 +29,7 @@ ifneq ($(OS),DRAGONFLY) $(eval $(call gb_Module_add_check_targets,sd,\ CppunitTest_sd_uimpress \ CppunitTest_sd_import_tests \ + CppunitTest_sd_export_tests \ CppunitTest_sd_filters_test \ CppunitTest_sd_html_export_tests \ )) diff --git a/sd/qa/unit/export-tests.cxx b/sd/qa/unit/export-tests.cxx new file mode 100644 index 0000000..44c5c9a --- /dev/null +++ b/sd/qa/unit/export-tests.cxx @@ -0,0 +1,427 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "sdmodeltestbase.hxx" + +#include <svl/stritem.hxx> +#include <editeng/editobj.hxx> +#include <editeng/outlobj.hxx> +#include <editeng/ulspitem.hxx> +#include <editeng/fhgtitem.hxx> +#include <editeng/escapementitem.hxx> +#include <editeng/colritem.hxx> +#include <editeng/fontitem.hxx> +#include <editeng/wghtitem.hxx> +#include <editeng/numitem.hxx> +#include <editeng/lrspitem.hxx> +#include <editeng/postitem.hxx> +#include <rsc/rscsfx.hxx> + +#include <svx/svdotext.hxx> +#include <svx/svdoashp.hxx> +#include <svx/svdograf.hxx> +#include <svx/svdogrp.hxx> +#include <svx/svdomedia.hxx> +#include <svx/svdoole2.hxx> +#include <svx/xflclit.hxx> +#include <animations/animationnodehelper.hxx> + +#include <com/sun/star/drawing/XDrawPage.hpp> +#include <com/sun/star/drawing/XDrawPagesSupplier.hpp> +#include <com/sun/star/animations/XAnimationNodeSupplier.hpp> +#include <com/sun/star/animations/XAnimationNode.hpp> +#include <com/sun/star/animations/XAnimate.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/chart/XChartDocument.hpp> +#include <com/sun/star/chart2/XChartDocument.hpp> +#include <com/sun/star/chart2/XDataSeriesContainer.hpp> +#include <com/sun/star/chart2/XCoordinateSystemContainer.hpp> +#include <com/sun/star/chart2/XChartTypeContainer.hpp> +#include <com/sun/star/chart2/data/XLabeledDataSequence.hpp> +#include <com/sun/star/chart2/data/XDataSequence.hpp> +#include <com/sun/star/chart2/data/XNumericalDataSequence.hpp> + +#include <config_features.h> + +using namespace ::com::sun::star; + +class SdFiltersTest : public SdModelTestBase +{ +public: + void testN821567(); + void testBnc870233_1(); + void testBnc870233_2(); + void testN828390_4(); + void testN828390_5(); + void testMediaEmbedding(); + void testFdo71961(); + void testN828390(); + void testBnc880763(); + void testBnc862510_5(); + + CPPUNIT_TEST_SUITE(SdFiltersTest); + CPPUNIT_TEST(testN821567); + CPPUNIT_TEST(testBnc870233_1); + CPPUNIT_TEST(testBnc870233_2); + CPPUNIT_TEST(testN828390_4); + CPPUNIT_TEST(testN828390_5); + CPPUNIT_TEST(testMediaEmbedding); + CPPUNIT_TEST(testFdo71961); + CPPUNIT_TEST(testN828390); + CPPUNIT_TEST(testBnc880763); + CPPUNIT_TEST(testBnc862510_5); + CPPUNIT_TEST_SUITE_END(); +}; + +void SdFiltersTest::testN821567() +{ + OUString bgImage; + ::sd::DrawDocShellRef xDocShRef = loadURL( getURLFromSrc("/sd/qa/unit/data/pptx/n821567.pptx") ); + + xDocShRef = saveAndReload( xDocShRef, ODP ); + uno::Reference< drawing::XDrawPagesSupplier > xDoc( + xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW ); + CPPUNIT_ASSERT_MESSAGE( "not exactly one page", xDoc->getDrawPages()->getCount() == 1 ); + uno::Reference< drawing::XDrawPage > xPage( + xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW ); + + uno::Reference< beans::XPropertySet > xPropSet( xPage, uno::UNO_QUERY ); + uno::Any aAny = xPropSet->getPropertyValue( OUString("Background") ); + if(aAny.hasValue()) + { + uno::Reference< beans::XPropertySet > aXBackgroundPropSet; + aAny >>= aXBackgroundPropSet; + aAny = aXBackgroundPropSet->getPropertyValue( OUString("FillBitmapName")); + aAny >>= bgImage; + } + CPPUNIT_ASSERT_MESSAGE("Slide Background is not exported properly", !bgImage.isEmpty()); + + xDocShRef->DoClose(); +} + +namespace { + +void checkFontAttributes(const SdrTextObj* pObj, sal_uInt32 nColor, + bool bCheckWeight, FontWeight eWeight, bool bCheckItalic, FontItalic eItalic) +{ + CPPUNIT_ASSERT_MESSAGE( "no object", pObj != NULL); + const EditTextObject& aEdit = pObj->GetOutlinerParaObject()->GetTextObject(); + std::vector<EECharAttrib> rLst; + aEdit.GetCharAttribs(0, rLst); + for( std::vector<EECharAttrib>::reverse_iterator it = rLst.rbegin(); it!=rLst.rend(); ++it) + { + const SvxColorItem *pCharColor = dynamic_cast<const SvxColorItem *>((*it).pAttr); + if( pCharColor ) + { + CPPUNIT_ASSERT_EQUAL( nColor, pCharColor->GetValue().GetColor()); + } + + if(bCheckWeight) + { + const SvxWeightItem *pWeight = dynamic_cast<const SvxWeightItem *>((*it).pAttr); + if( pWeight ) + { + CPPUNIT_ASSERT_EQUAL( eWeight, pWeight->GetWeight()); + } + } + + if(bCheckItalic) + { + const SvxPostureItem *pPosture = dynamic_cast<const SvxPostureItem *>((*it).pAttr); + if( pPosture ) + { + CPPUNIT_ASSERT_EQUAL( eItalic, pPosture->GetPosture()); + } + } + } + +} + +} + +void SdFiltersTest::testBnc870233_1() +{ + ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/bnc870233_1.pptx")); + xDocShRef = saveAndReload( xDocShRef, PPTX ); + + SdDrawDocument *pDoc = xDocShRef->GetDoc(); + CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL ); + const SdrPage *pPage = pDoc->GetPage (1); + CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL ); + + // The problem was all shapes had the same font (the last parsed font attribues overwrote all previous ones) + + // First shape has red, bold font + { + const SdrTextObj *pObj = dynamic_cast<SdrTextObj *>( pPage->GetObj( 0 ) ); + checkFontAttributes(pObj, sal_uInt32(0xff0000), + true, WEIGHT_BOLD, true, ITALIC_NONE); + } + + // Second shape has blue, italic font + { + const SdrTextObj *pObj = dynamic_cast<SdrTextObj *>( pPage->GetObj( 1 ) ); + checkFontAttributes(pObj, sal_uInt32(0x0000ff), + true, WEIGHT_NORMAL, true, ITALIC_NORMAL); + } + + xDocShRef->DoClose(); +} + +void SdFiltersTest::testBnc870233_2() +{ + ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/bnc870233_2.pptx")); + xDocShRef = saveAndReload( xDocShRef, PPTX ); + + SdDrawDocument *pDoc = xDocShRef->GetDoc(); + CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL ); + const SdrPage *pPage = pDoc->GetPage (1); + CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL ); + + // The problem was in some SmartArts font color was wrong + + // First smart art has blue font color (direct formatting) + { + const SdrTextObj *pObj = dynamic_cast<SdrTextObj *>( pPage->GetObj( 0 ) ); + checkFontAttributes(pObj, sal_uInt32(0x0000ff), + false, WEIGHT_DONTKNOW, false, ITALIC_NONE); + } + + // Second smart art has "dk2" font color (style) + { + const SdrTextObj *pObj = dynamic_cast<SdrTextObj *>( pPage->GetObj( 1 ) ); + checkFontAttributes(pObj, sal_uInt32(0x1F497D), + false, WEIGHT_DONTKNOW, false, ITALIC_NONE); + } + + // Third smart art has white font color (style) + { + const SdrTextObj *pObj = dynamic_cast<SdrTextObj *>( pPage->GetObj( 2 ) ); + checkFontAttributes(pObj, sal_uInt32(0xffffff), + false, WEIGHT_DONTKNOW, false, ITALIC_NONE); + } + + xDocShRef->DoClose(); +} + +void SdFiltersTest::testN828390_4() +{ + bool bPassed = false; + ::sd::DrawDocShellRef xDocShRef = loadURL( getURLFromSrc("/sd/qa/unit/data/n828390_4.odp") ); + + xDocShRef = saveAndReload( xDocShRef, PPTX ); + + SdDrawDocument *pDoc = xDocShRef->GetDoc(); + CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL ); + const SdrPage *pPage = pDoc->GetPage(1); + CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL ); + { + std::vector<EECharAttrib> rLst; + SdrObject *pObj = pPage->GetObj(0); + SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>( pObj ); + CPPUNIT_ASSERT( pTxtObj ); + const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject(); + aEdit.GetCharAttribs(1, rLst); + for( std::vector<EECharAttrib>::reverse_iterator it = rLst.rbegin(); it!=rLst.rend(); ++it) + { + const SvxFontHeightItem * pFontHeight = dynamic_cast<const SvxFontHeightItem *>((*it).pAttr); + if( pFontHeight ) + CPPUNIT_ASSERT_MESSAGE( "Font height is wrong", pFontHeight->GetHeight() == 1129 ); + const SvxFontItem *pFont = dynamic_cast<const SvxFontItem *>((*it).pAttr); + if( pFont ) + { + CPPUNIT_ASSERT_MESSAGE( "Font is wrong", pFont->GetFamilyName().equalsAscii("Arial")); + bPassed = true; + } + const SvxWeightItem *pWeight = dynamic_cast<const SvxWeightItem *>((*it).pAttr); + if( pWeight ) + CPPUNIT_ASSERT_MESSAGE( "Font Weight is wrong", pWeight->GetWeight() == WEIGHT_BOLD); + } + } + CPPUNIT_ASSERT(bPassed); + + xDocShRef->DoClose(); +} + +void SdFiltersTest::testN828390_5() +{ + ::sd::DrawDocShellRef xDocShRef = loadURL( getURLFromSrc("/sd/qa/unit/data/n828390_5.odp") ); + + xDocShRef = saveAndReload( xDocShRef, PPTX ); + + SdDrawDocument *pDoc = xDocShRef->GetDoc(); + CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL ); + const SdrPage *pPage = pDoc->GetPage(1); + CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL ); + { + SdrObject *pObj = pPage->GetObj(0); + SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>( pObj ); + CPPUNIT_ASSERT( pTxtObj ); + const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject(); + const SvxNumBulletItem *pNumFmt = dynamic_cast<const SvxNumBulletItem *>(aEdit.GetPool()->GetItem2(EE_PARA_NUMBULLET, 5)); + CPPUNIT_ASSERT( pNumFmt ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "Bullet's relative size is wrong!", pNumFmt->GetNumRule()->GetLevel(1).GetBulletRelSize(), sal_uInt16(75) ); // != 25 + } + + xDocShRef->DoClose(); +} + +void SdFiltersTest::testMediaEmbedding() +{ + ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/media_embedding.odp")); + +#if HAVE_FEATURE_GLTF + xDocShRef = saveAndReload( xDocShRef, ODP ); +#endif + + SdDrawDocument *pDoc = xDocShRef->GetDoc(); + CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL ); + const SdrPage *pPage = pDoc->GetPage (1); + CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL ); + +#if HAVE_FEATURE_GLTF + // First object is a glTF model + SdrMediaObj *pModelObj = dynamic_cast<SdrMediaObj*>( pPage->GetObj( 2 )); + CPPUNIT_ASSERT_MESSAGE( "missing model", pModelObj != NULL); + CPPUNIT_ASSERT_EQUAL( OUString( "vnd.sun.star.Package:Models/duck/duck.json" ), pModelObj->getMediaProperties().getURL()); + CPPUNIT_ASSERT_EQUAL( OUString( "model/vnd.gltf+json" ), pModelObj->getMediaProperties().getMimeType()); +#else + // If glTF is not supported, then the fallback image is imported + SdrGrafObj *pGrafic = dynamic_cast<SdrGrafObj*>( pPage->GetObj( 2 )); + CPPUNIT_ASSERT_MESSAGE( "Could not load glTF fallback image", pGrafic != NULL); + CPPUNIT_ASSERT_EQUAL( OUString( "vnd.sun.star.Package:Models/Fallbacks/duck.png" ), pGrafic->GetGrafStreamURL()); +#endif + + // Second object is a sound + SdrMediaObj *pMediaObj = dynamic_cast<SdrMediaObj*>( pPage->GetObj( 3 )); + CPPUNIT_ASSERT_MESSAGE( "missing media object", pMediaObj != NULL); + CPPUNIT_ASSERT_EQUAL( OUString( "vnd.sun.star.Package:Media/button-1.wav" ), pMediaObj->getMediaProperties().getURL()); + CPPUNIT_ASSERT_EQUAL( OUString( "application/vnd.sun.star.media" ), pMediaObj->getMediaProperties().getMimeType()); + + xDocShRef->DoClose(); +} + +void SdFiltersTest::testFdo71961() +{ + ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/fdo71961.odp")); + + xDocShRef = saveAndReload( xDocShRef, PPTX ); + + SdDrawDocument *pDoc = xDocShRef->GetDoc(); + CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL ); + const SdrPage *pPage = pDoc->GetPage (1); + CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL ); + + // Export to .pptx changes all text frames to custom shape objects, which obey TextWordWrap property + // (which is false for text frames otherwise and is ignored). Check that frames that should wrap still do. + SdrObjCustomShape *pTxtObj = dynamic_cast<SdrObjCustomShape *>( pPage->GetObj( 1 )); + CPPUNIT_ASSERT_MESSAGE( "no text object", pTxtObj != NULL); + CPPUNIT_ASSERT_EQUAL( OUString( "Text to be always wrapped" ), pTxtObj->GetOutlinerParaObject()->GetTextObject().GetText(0)); + CPPUNIT_ASSERT_EQUAL( true, (static_cast<const SdrTextWordWrapItem&>(pTxtObj->GetMergedItem(SDRATTR_TEXT_WORDWRAP))).GetValue()); + + pTxtObj = dynamic_cast<SdrObjCustomShape *>( pPage->GetObj( 2 )); + CPPUNIT_ASSERT_MESSAGE( "no text object", pTxtObj != NULL); + CPPUNIT_ASSERT_EQUAL( OUString( "Custom shape non-wrapped text" ), pTxtObj->GetOutlinerParaObject()->GetTextObject().GetText(0)); + CPPUNIT_ASSERT_EQUAL( false, (static_cast<const SdrTextWordWrapItem&>(pTxtObj->GetMergedItem(SDRATTR_TEXT_WORDWRAP))).GetValue()); + + pTxtObj = dynamic_cast<SdrObjCustomShape *>( pPage->GetObj( 3 )); + CPPUNIT_ASSERT_MESSAGE( "no text object", pTxtObj != NULL); + CPPUNIT_ASSERT_EQUAL( OUString( "Custom shape wrapped text" ), pTxtObj->GetOutlinerParaObject()->GetTextObject().GetText(0)); + CPPUNIT_ASSERT_EQUAL( true, (static_cast<const SdrTextWordWrapItem&>(pTxtObj->GetMergedItem(SDRATTR_TEXT_WORDWRAP))).GetValue()); + + xDocShRef->DoClose(); +} + +void SdFiltersTest::testN828390() +{ + bool bPassed = false; + ::sd::DrawDocShellRef xDocShRef = loadURL( getURLFromSrc("/sd/qa/unit/data/pptx/n828390.pptx") ); + + xDocShRef = saveAndReload( xDocShRef, PPTX ); + + SdDrawDocument *pDoc = xDocShRef->GetDoc(); + CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL ); + const SdrPage *pPage = pDoc->GetPage(1); + CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL ); + { + std::vector<EECharAttrib> rLst; + // Get the object + SdrObject *pObj = pPage->GetObj(0); + SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>( pObj ); + CPPUNIT_ASSERT( pTxtObj ); + const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject(); + aEdit.GetCharAttribs(0, rLst); + for( std::vector<EECharAttrib>::reverse_iterator it = rLst.rbegin(); it!=rLst.rend(); ++it) + { + const SvxEscapementItem *pFontEscapement = dynamic_cast<const SvxEscapementItem *>((*it).pAttr); + if(pFontEscapement) + { + if( pFontEscapement->GetEsc() == -25 ) + { + bPassed = true; + break; + } + } + } + } + CPPUNIT_ASSERT_MESSAGE("Subscript not exported properly", bPassed); + + xDocShRef->DoClose(); +} + +void SdFiltersTest::testBnc880763() +{ + ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/bnc880763.pptx")); + xDocShRef = saveAndReload( xDocShRef, PPTX ); + + SdDrawDocument *pDoc = xDocShRef->GetDoc(); + CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL ); + const SdrPage *pPage = pDoc->GetPage (1); + CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL ); + + // Check z-order of the two shapes, use background color to identify them + // First object in the background has blue background color + const SdrObject *pObj = dynamic_cast<SdrObject *>( pPage->GetObj( 0 ) ); + CPPUNIT_ASSERT_MESSAGE( "no object", pObj != NULL); + CPPUNIT_ASSERT_EQUAL( sal_uInt32(0x0000ff),(static_cast< const XColorItem& >(pObj->GetMergedItem(XATTR_FILLCOLOR))).GetColorValue().GetColor()); + + // Second object at the front has green background color + pObj = dynamic_cast<SdrObject *>( pPage->GetObj( 1 ) ); + CPPUNIT_ASSERT_MESSAGE( "no object", pObj != NULL); + CPPUNIT_ASSERT_EQUAL( sal_uInt32(0x00ff00),(static_cast< const XColorItem& >(pObj->GetMergedItem(XATTR_FILLCOLOR))).GetColorValue().GetColor()); + + xDocShRef->DoClose(); +} + +void SdFiltersTest::testBnc862510_5() +{ + ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/bnc862510_5.pptx")); + xDocShRef = saveAndReload( xDocShRef, PPTX ); + + SdDrawDocument *pDoc = xDocShRef->GetDoc(); + CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL ); + const SdrPage *pPage = pDoc->GetPage (1); + CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL ); + + // Same as testBnc870237, but here we check the horizontal spacing + const SdrObject* pObj = dynamic_cast<SdrObject*>( pPage->GetObj( 1 ) ); + CPPUNIT_ASSERT_MESSAGE( "no object", pObj != NULL); + CPPUNIT_ASSERT_EQUAL( sal_Int32(0), (static_cast< const SdrTextUpperDistItem& >(pObj->GetMergedItem(SDRATTR_TEXT_UPPERDIST))).GetValue()); + CPPUNIT_ASSERT_EQUAL( sal_Int32(0), (static_cast< const SdrTextLowerDistItem& >(pObj->GetMergedItem(SDRATTR_TEXT_LOWERDIST))).GetValue()); + CPPUNIT_ASSERT_EQUAL( sal_Int32(7510), (static_cast< const SdrTextRightDistItem& >(pObj->GetMergedItem(SDRATTR_TEXT_RIGHTDIST))).GetValue()); + CPPUNIT_ASSERT_EQUAL( sal_Int32(0), (static_cast< const SdrTextLeftDistItem& >(pObj->GetMergedItem(SDRATTR_TEXT_LEFTDIST))).GetValue()); + + xDocShRef->DoClose(); +} + +CPPUNIT_TEST_SUITE_REGISTRATION(SdFiltersTest); + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx index 79fe2a5..3298b46 100644 --- a/sd/qa/unit/import-tests.cxx +++ b/sd/qa/unit/import-tests.cxx @@ -61,12 +61,8 @@ public: void testN778859(); void testFdo64512(); void testFdo71075(); - void testN828390(); void testN828390_2(); void testN828390_3(); - void testN828390_4(); - void testN828390_5(); - void testN821567(); void testFdo68594(); void testFdo72998(); void testFdo77027(); @@ -74,13 +70,7 @@ public: void testN862510_1(); void testN862510_2(); void testN862510_4(); - void testFdo71961(); - void testMediaEmbedding(); void testBnc870237(); - void testBnc870233_1(); - void testBnc870233_2(); - void testBnc880763(); - void testBnc862510_5(); CPPUNIT_TEST_SUITE(SdFiltersTest); CPPUNIT_TEST(testDocumentLayout); @@ -89,12 +79,8 @@ public: CPPUNIT_TEST(testN778859); CPPUNIT_TEST(testFdo64512); CPPUNIT_TEST(testFdo71075); - CPPUNIT_TEST(testN828390); CPPUNIT_TEST(testN828390_2); CPPUNIT_TEST(testN828390_3); - CPPUNIT_TEST(testN828390_4); - CPPUNIT_TEST(testN828390_5); - CPPUNIT_TEST(testN821567); CPPUNIT_TEST(testFdo68594); CPPUNIT_TEST(testFdo72998); CPPUNIT_TEST(testFdo77027); @@ -102,13 +88,7 @@ public: CPPUNIT_TEST(testN862510_1); CPPUNIT_TEST(testN862510_2); CPPUNIT_TEST(testN862510_4); - CPPUNIT_TEST(testFdo71961); - CPPUNIT_TEST(testMediaEmbedding); CPPUNIT_TEST(testBnc870237); - CPPUNIT_TEST(testBnc870233_1); - CPPUNIT_TEST(testBnc870233_2); - CPPUNIT_TEST(testBnc880763); - CPPUNIT_TEST(testBnc862510_5); CPPUNIT_TEST_SUITE_END(); }; @@ -238,32 +218,6 @@ void SdFiltersTest::testN759180() xDocShRef->DoClose(); } -void SdFiltersTest::testN821567() -{ - OUString bgImage; - ::sd::DrawDocShellRef xDocShRef = loadURL( getURLFromSrc("/sd/qa/unit/data/pptx/n821567.pptx") ); - - xDocShRef = saveAndReload( xDocShRef, ODP ); - uno::Reference< drawing::XDrawPagesSupplier > xDoc( - xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW ); - CPPUNIT_ASSERT_MESSAGE( "not exactly one page", xDoc->getDrawPages()->getCount() == 1 ); - uno::Reference< drawing::XDrawPage > xPage( - xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW ); - - uno::Reference< beans::XPropertySet > xPropSet( xPage, uno::UNO_QUERY ); - uno::Any aAny = xPropSet->getPropertyValue( OUString("Background") ); - if(aAny.hasValue()) - { - uno::Reference< beans::XPropertySet > aXBackgroundPropSet; - aAny >>= aXBackgroundPropSet; - aAny = aXBackgroundPropSet->getPropertyValue( OUString("FillBitmapName")); - aAny >>= bgImage; - } - CPPUNIT_ASSERT_MESSAGE("Slide Background is not exported properly", !bgImage.isEmpty()); - - xDocShRef->DoClose(); -} - void SdFiltersTest::testN862510_1() { ::sd::DrawDocShellRef xDocShRef = loadURL( getURLFromSrc("/sd/qa/unit/data/pptx/n862510_1.pptx") ); @@ -333,43 +287,6 @@ void SdFiltersTest::testN862510_4() xDocShRef->DoClose(); } -void SdFiltersTest::testN828390() -{ - bool bPassed = false; - ::sd::DrawDocShellRef xDocShRef = loadURL( getURLFromSrc("/sd/qa/unit/data/pptx/n828390.pptx") ); - - xDocShRef = saveAndReload( xDocShRef, PPTX ); - - SdDrawDocument *pDoc = xDocShRef->GetDoc(); - CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL ); - const SdrPage *pPage = pDoc->GetPage(1); - CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL ); - { - std::vector<EECharAttrib> rLst; - // Get the object - SdrObject *pObj = pPage->GetObj(0); - SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>( pObj ); - CPPUNIT_ASSERT( pTxtObj ); - const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject(); - aEdit.GetCharAttribs(0, rLst); - for( std::vector<EECharAttrib>::reverse_iterator it = rLst.rbegin(); it!=rLst.rend(); ++it) - { - const SvxEscapementItem *pFontEscapement = dynamic_cast<const SvxEscapementItem *>((*it).pAttr); - if(pFontEscapement) - { - if( pFontEscapement->GetEsc() == -25 ) - { - bPassed = true; - break; - } - } - } - } - CPPUNIT_ASSERT_MESSAGE("Subscript not exported properly", bPassed); - - xDocShRef->DoClose(); -} - void SdFiltersTest::testN828390_2() { ::sd::DrawDocShellRef xDocShRef = loadURL( getURLFromSrc("/sd/qa/unit/data/pptx/n828390_2.pptx") ); @@ -422,68 +339,6 @@ void SdFiltersTest::testN828390_3() xDocShRef->DoClose(); } -void SdFiltersTest::testN828390_4() -{ - bool bPassed = false; - ::sd::DrawDocShellRef xDocShRef = loadURL( getURLFromSrc("/sd/qa/unit/data/n828390_4.odp") ); - - xDocShRef = saveAndReload( xDocShRef, PPTX ); - - SdDrawDocument *pDoc = xDocShRef->GetDoc(); - CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL ); - const SdrPage *pPage = pDoc->GetPage(1); - CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL ); - { - std::vector<EECharAttrib> rLst; - SdrObject *pObj = pPage->GetObj(0); - SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>( pObj ); - CPPUNIT_ASSERT( pTxtObj ); - const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject(); - aEdit.GetCharAttribs(1, rLst); - for( std::vector<EECharAttrib>::reverse_iterator it = rLst.rbegin(); it!=rLst.rend(); ++it) - { - const SvxFontHeightItem * pFontHeight = dynamic_cast<const SvxFontHeightItem *>((*it).pAttr); - if( pFontHeight ) - CPPUNIT_ASSERT_MESSAGE( "Font height is wrong", pFontHeight->GetHeight() == 1129 ); - const SvxFontItem *pFont = dynamic_cast<const SvxFontItem *>((*it).pAttr); - if( pFont ) - { - CPPUNIT_ASSERT_MESSAGE( "Font is wrong", pFont->GetFamilyName().equalsAscii("Arial")); - bPassed = true; - } - const SvxWeightItem *pWeight = dynamic_cast<const SvxWeightItem *>((*it).pAttr); - if( pWeight ) - CPPUNIT_ASSERT_MESSAGE( "Font Weight is wrong", pWeight->GetWeight() == WEIGHT_BOLD); - } - } - CPPUNIT_ASSERT(bPassed); - - xDocShRef->DoClose(); -} - -void SdFiltersTest::testN828390_5() -{ - ::sd::DrawDocShellRef xDocShRef = loadURL( getURLFromSrc("/sd/qa/unit/data/n828390_5.odp") ); - - xDocShRef = saveAndReload( xDocShRef, PPTX ); - - SdDrawDocument *pDoc = xDocShRef->GetDoc(); - CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL ); - const SdrPage *pPage = pDoc->GetPage(1); - CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL ); - { - SdrObject *pObj = pPage->GetObj(0); - SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>( pObj ); - CPPUNIT_ASSERT( pTxtObj ); - const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject(); - const SvxNumBulletItem *pNumFmt = dynamic_cast<const SvxNumBulletItem *>(aEdit.GetPool()->GetItem2(EE_PARA_NUMBULLET, 5)); - CPPUNIT_ASSERT( pNumFmt ); - CPPUNIT_ASSERT_EQUAL_MESSAGE( "Bullet's relative size is wrong!", pNumFmt->GetNumRule()->GetLevel(1).GetBulletRelSize(), sal_uInt16(75) ); // != 25 - } - - xDocShRef->DoClose(); -} - void SdFiltersTest::testN778859() { ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/n778859.pptx")); @@ -677,72 +532,6 @@ void SdFiltersTest::testStrictOOXML() xDocShRef->DoClose(); } -void SdFiltersTest::testFdo71961() -{ - ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/fdo71961.odp")); - - xDocShRef = saveAndReload( xDocShRef, PPTX ); - - SdDrawDocument *pDoc = xDocShRef->GetDoc(); - CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL ); - const SdrPage *pPage = pDoc->GetPage (1); - CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL ); - - // Export to .pptx changes all text frames to custom shape objects, which obey TextWordWrap property - // (which is false for text frames otherwise and is ignored). Check that frames that should wrap still do. - SdrObjCustomShape *pTxtObj = dynamic_cast<SdrObjCustomShape *>( pPage->GetObj( 1 )); - CPPUNIT_ASSERT_MESSAGE( "no text object", pTxtObj != NULL); - CPPUNIT_ASSERT_EQUAL( OUString( "Text to be always wrapped" ), pTxtObj->GetOutlinerParaObject()->GetTextObject().GetText(0)); - CPPUNIT_ASSERT_EQUAL( true, (static_cast<const SdrTextWordWrapItem&>(pTxtObj->GetMergedItem(SDRATTR_TEXT_WORDWRAP))).GetValue()); - - pTxtObj = dynamic_cast<SdrObjCustomShape *>( pPage->GetObj( 2 )); - CPPUNIT_ASSERT_MESSAGE( "no text object", pTxtObj != NULL); - CPPUNIT_ASSERT_EQUAL( OUString( "Custom shape non-wrapped text" ), pTxtObj->GetOutlinerParaObject()->GetTextObject().GetText(0)); - CPPUNIT_ASSERT_EQUAL( false, (static_cast<const SdrTextWordWrapItem&>(pTxtObj->GetMergedItem(SDRATTR_TEXT_WORDWRAP))).GetValue()); - - pTxtObj = dynamic_cast<SdrObjCustomShape *>( pPage->GetObj( 3 )); - CPPUNIT_ASSERT_MESSAGE( "no text object", pTxtObj != NULL); - CPPUNIT_ASSERT_EQUAL( OUString( "Custom shape wrapped text" ), pTxtObj->GetOutlinerParaObject()->GetTextObject().GetText(0)); - CPPUNIT_ASSERT_EQUAL( true, (static_cast<const SdrTextWordWrapItem&>(pTxtObj->GetMergedItem(SDRATTR_TEXT_WORDWRAP))).GetValue()); - - xDocShRef->DoClose(); -} - -void SdFiltersTest::testMediaEmbedding() -{ - ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/media_embedding.odp")); - -#if HAVE_FEATURE_GLTF - xDocShRef = saveAndReload( xDocShRef, ODP ); -#endif - - SdDrawDocument *pDoc = xDocShRef->GetDoc(); - CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL ); - const SdrPage *pPage = pDoc->GetPage (1); - CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL ); - -#if HAVE_FEATURE_GLTF - // First object is a glTF model - SdrMediaObj *pModelObj = dynamic_cast<SdrMediaObj*>( pPage->GetObj( 2 )); - CPPUNIT_ASSERT_MESSAGE( "missing model", pModelObj != NULL); - CPPUNIT_ASSERT_EQUAL( OUString( "vnd.sun.star.Package:Models/duck/duck.json" ), pModelObj->getMediaProperties().getURL()); - CPPUNIT_ASSERT_EQUAL( OUString( "model/vnd.gltf+json" ), pModelObj->getMediaProperties().getMimeType()); -#else - // If glTF is not supported, then the fallback image is imported - SdrGrafObj *pGrafic = dynamic_cast<SdrGrafObj*>( pPage->GetObj( 2 )); - CPPUNIT_ASSERT_MESSAGE( "Could not load glTF fallback image", pGrafic != NULL); - CPPUNIT_ASSERT_EQUAL( OUString( "vnd.sun.star.Package:Models/Fallbacks/duck.png" ), pGrafic->GetGrafStreamURL()); -#endif - - // Second object is a sound - SdrMediaObj *pMediaObj = dynamic_cast<SdrMediaObj*>( pPage->GetObj( 3 )); - CPPUNIT_ASSERT_MESSAGE( "missing media object", pMediaObj != NULL); - CPPUNIT_ASSERT_EQUAL( OUString( "vnd.sun.star.Package:Media/button-1.wav" ), pMediaObj->getMediaProperties().getURL()); - CPPUNIT_ASSERT_EQUAL( OUString( "application/vnd.sun.star.media" ), pMediaObj->getMediaProperties().getMimeType()); - - xDocShRef->DoClose(); -} - void SdFiltersTest::testBnc870237() { ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/bnc870237.pptx")); @@ -763,156 +552,6 @@ void SdFiltersTest::testBnc870237() xDocShRef->DoClose(); } -namespace { - -void checkFontAttributes(const SdrTextObj* pObj, sal_uInt32 nColor, - bool bCheckWeight, FontWeight eWeight, bool bCheckItalic, FontItalic eItalic) -{ - CPPUNIT_ASSERT_MESSAGE( "no object", pObj != NULL); - const EditTextObject& aEdit = pObj->GetOutlinerParaObject()->GetTextObject(); - std::vector<EECharAttrib> rLst; - aEdit.GetCharAttribs(0, rLst); - for( std::vector<EECharAttrib>::reverse_iterator it = rLst.rbegin(); it!=rLst.rend(); ++it) - { - const SvxColorItem *pCharColor = dynamic_cast<const SvxColorItem *>((*it).pAttr); - if( pCharColor ) - { - CPPUNIT_ASSERT_EQUAL( nColor, pCharColor->GetValue().GetColor()); - } - - if(bCheckWeight) - { - const SvxWeightItem *pWeight = dynamic_cast<const SvxWeightItem *>((*it).pAttr); - if( pWeight ) - { - CPPUNIT_ASSERT_EQUAL( eWeight, pWeight->GetWeight()); - } - } - - if(bCheckItalic) - { - const SvxPostureItem *pPosture = dynamic_cast<const SvxPostureItem *>((*it).pAttr); - if( pPosture ) - { - CPPUNIT_ASSERT_EQUAL( eItalic, pPosture->GetPosture()); - } - } - } - -} - -} - -void SdFiltersTest::testBnc870233_1() -{ - ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/bnc870233_1.pptx")); - xDocShRef = saveAndReload( xDocShRef, PPTX ); - - SdDrawDocument *pDoc = xDocShRef->GetDoc(); - CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL ); - const SdrPage *pPage = pDoc->GetPage (1); - CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL ); - - // The problem was all shapes had the same font (the last parsed font attribues overwrote all previous ones) - - // First shape has red, bold font - { - const SdrTextObj *pObj = dynamic_cast<SdrTextObj *>( pPage->GetObj( 0 ) ); - checkFontAttributes(pObj, sal_uInt32(0xff0000), - true, WEIGHT_BOLD, true, ITALIC_NONE); - } - - // Second shape has blue, italic font - { - const SdrTextObj *pObj = dynamic_cast<SdrTextObj *>( pPage->GetObj( 1 ) ); - checkFontAttributes(pObj, sal_uInt32(0x0000ff), - true, WEIGHT_NORMAL, true, ITALIC_NORMAL); - } - - xDocShRef->DoClose(); -} - -void SdFiltersTest::testBnc870233_2() -{ - ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/bnc870233_2.pptx")); - xDocShRef = saveAndReload( xDocShRef, PPTX ); - - SdDrawDocument *pDoc = xDocShRef->GetDoc(); - CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL ); - const SdrPage *pPage = pDoc->GetPage (1); - CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL ); - - // The problem was in some SmartArts font color was wrong - - // First smart art has blue font color (direct formatting) - { - const SdrTextObj *pObj = dynamic_cast<SdrTextObj *>( pPage->GetObj( 0 ) ); - checkFontAttributes(pObj, sal_uInt32(0x0000ff), - false, WEIGHT_DONTKNOW, false, ITALIC_NONE); - } - - // Second smart art has "dk2" font color (style) - { - const SdrTextObj *pObj = dynamic_cast<SdrTextObj *>( pPage->GetObj( 1 ) ); - checkFontAttributes(pObj, sal_uInt32(0x1F497D), - false, WEIGHT_DONTKNOW, false, ITALIC_NONE); - } - - // Third smart art has white font color (style) - { - const SdrTextObj *pObj = dynamic_cast<SdrTextObj *>( pPage->GetObj( 2 ) ); - checkFontAttributes(pObj, sal_uInt32(0xffffff), - false, WEIGHT_DONTKNOW, false, ITALIC_NONE); - } - - xDocShRef->DoClose(); -} - -void SdFiltersTest::testBnc880763() -{ - ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/bnc880763.pptx")); - xDocShRef = saveAndReload( xDocShRef, PPTX ); - - SdDrawDocument *pDoc = xDocShRef->GetDoc(); - CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL ); - const SdrPage *pPage = pDoc->GetPage (1); - CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL ); - - // Check z-order of the two shapes, use background color to identify them - // First object in the background has blue background color - const SdrObject *pObj = dynamic_cast<SdrObject *>( pPage->GetObj( 0 ) ); - CPPUNIT_ASSERT_MESSAGE( "no object", pObj != NULL); - CPPUNIT_ASSERT_EQUAL( sal_uInt32(0x0000ff),(static_cast< const XColorItem& >(pObj->GetMergedItem(XATTR_FILLCOLOR))).GetColorValue().GetColor()); - - // Second object at the front has green background color - pObj = dynamic_cast<SdrObject *>( pPage->GetObj( 1 ) ); - CPPUNIT_ASSERT_MESSAGE( "no object", pObj != NULL); - CPPUNIT_ASSERT_EQUAL( sal_uInt32(0x00ff00),(static_cast< const XColorItem& >(pObj->GetMergedItem(XATTR_FILLCOLOR))).GetColorValue().GetColor()); - - xDocShRef->DoClose(); -} - -void SdFiltersTest::testBnc862510_5() -{ - ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/bnc862510_5.pptx")); - xDocShRef = saveAndReload( xDocShRef, PPTX ); - - SdDrawDocument *pDoc = xDocShRef->GetDoc(); - CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL ); - const SdrPage *pPage = pDoc->GetPage (1); - CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL ); - - // Same as testBnc870237, but here we check the horizontal spacing - const SdrObject* pObj = dynamic_cast<SdrObject*>( pPage->GetObj( 1 ) ); - CPPUNIT_ASSERT_MESSAGE( "no object", pObj != NULL); - CPPUNIT_ASSERT_EQUAL( sal_Int32(0), (static_cast< const SdrTextUpperDistItem& >(pObj->GetMergedItem(SDRATTR_TEXT_UPPERDIST))).GetValue()); - CPPUNIT_ASSERT_EQUAL( sal_Int32(0), (static_cast< const SdrTextLowerDistItem& >(pObj->GetMergedItem(SDRATTR_TEXT_LOWERDIST))).GetValue()); - CPPUNIT_ASSERT_EQUAL( sal_Int32(7510), (static_cast< const SdrTextRightDistItem& >(pObj->GetMergedItem(SDRATTR_TEXT_RIGHTDIST))).GetValue()); - CPPUNIT_ASSERT_EQUAL( sal_Int32(0), (static_cast< const SdrTextLeftDistItem& >(pObj->GetMergedItem(SDRATTR_TEXT_LEFTDIST))).GetValue()); - - xDocShRef->DoClose(); -} - CPPUNIT_TEST_SUITE_REGISTRATION(SdFiltersTest); CPPUNIT_PLUGIN_IMPLEMENT(); commit b5608fd429790a3d1153341b2c86303b7090b15a Author: Markus Mohrhard <markus.mohrh...@collabora.co.uk> Date: Fri Jul 4 04:32:34 2014 +0200 extract a bit more code Change-Id: I24da9b5e8594d34ff7d5c3f958c2fd1c5cad1908 diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx index 959c754..79fe2a5 100644 --- a/sd/qa/unit/import-tests.cxx +++ b/sd/qa/unit/import-tests.cxx @@ -766,7 +766,7 @@ void SdFiltersTest::testBnc870237() namespace { void checkFontAttributes(const SdrTextObj* pObj, sal_uInt32 nColor, - FontWeight eWeight, FontItalic eItalic) + bool bCheckWeight, FontWeight eWeight, bool bCheckItalic, FontItalic eItalic) { CPPUNIT_ASSERT_MESSAGE( "no object", pObj != NULL); const EditTextObject& aEdit = pObj->GetOutlinerParaObject()->GetTextObject(); @@ -779,15 +779,23 @@ void checkFontAttributes(const SdrTextObj* pObj, sal_uInt32 nColor, { CPPUNIT_ASSERT_EQUAL( nColor, pCharColor->GetValue().GetColor()); } - const SvxWeightItem *pWeight = dynamic_cast<const SvxWeightItem *>((*it).pAttr); - if( pWeight ) + + if(bCheckWeight) { - CPPUNIT_ASSERT_EQUAL( eWeight, pWeight->GetWeight()); + const SvxWeightItem *pWeight = dynamic_cast<const SvxWeightItem *>((*it).pAttr); + if( pWeight ) + { + CPPUNIT_ASSERT_EQUAL( eWeight, pWeight->GetWeight()); + } } - const SvxPostureItem *pPosture = dynamic_cast<const SvxPostureItem *>((*it).pAttr); - if( pPosture ) + + if(bCheckItalic) { - CPPUNIT_ASSERT_EQUAL( eItalic, pPosture->GetPosture()); + const SvxPostureItem *pPosture = dynamic_cast<const SvxPostureItem *>((*it).pAttr); + if( pPosture ) + { + CPPUNIT_ASSERT_EQUAL( eItalic, pPosture->GetPosture()); + } } } @@ -810,13 +818,15 @@ void SdFiltersTest::testBnc870233_1() // First shape has red, bold font { const SdrTextObj *pObj = dynamic_cast<SdrTextObj *>( pPage->GetObj( 0 ) ); - checkFontAttributes(pObj, sal_uInt32(0xff0000), WEIGHT_BOLD, ITALIC_NONE); + checkFontAttributes(pObj, sal_uInt32(0xff0000), + true, WEIGHT_BOLD, true, ITALIC_NONE); } // Second shape has blue, italic font { const SdrTextObj *pObj = dynamic_cast<SdrTextObj *>( pPage->GetObj( 1 ) ); - checkFontAttributes(pObj, sal_uInt32(0x0000ff), WEIGHT_NORMAL, ITALIC_NORMAL); + checkFontAttributes(pObj, sal_uInt32(0x0000ff), + true, WEIGHT_NORMAL, true, ITALIC_NORMAL); } xDocShRef->DoClose(); @@ -837,52 +847,22 @@ void SdFiltersTest::testBnc870233_2() // First smart art has blue font color (direct formatting) { const SdrTextObj *pObj = dynamic_cast<SdrTextObj *>( pPage->GetObj( 0 ) ); - CPPUNIT_ASSERT_MESSAGE( "no object", pObj != NULL); - const EditTextObject& aEdit = pObj->GetOutlinerParaObject()->GetTextObject(); - std::vector<EECharAttrib> rLst; - aEdit.GetCharAttribs(0, rLst); - for( std::vector<EECharAttrib>::reverse_iterator it = rLst.rbegin(); it!=rLst.rend(); ++it) - { - const SvxColorItem *pCharColor = dynamic_cast<const SvxColorItem *>((*it).pAttr); - if( pCharColor ) - { - CPPUNIT_ASSERT_EQUAL( sal_uInt32(0x0000ff), pCharColor->GetValue().GetColor()); - } - } + checkFontAttributes(pObj, sal_uInt32(0x0000ff), + false, WEIGHT_DONTKNOW, false, ITALIC_NONE); } // Second smart art has "dk2" font color (style) { const SdrTextObj *pObj = dynamic_cast<SdrTextObj *>( pPage->GetObj( 1 ) ); - CPPUNIT_ASSERT_MESSAGE( "no object", pObj != NULL); - const EditTextObject& aEdit = pObj->GetOutlinerParaObject()->GetTextObject(); - std::vector<EECharAttrib> rLst; - aEdit.GetCharAttribs(0, rLst); - for( std::vector<EECharAttrib>::reverse_iterator it = rLst.rbegin(); it!=rLst.rend(); ++it) - { - const SvxColorItem *pCharColor = dynamic_cast<const SvxColorItem *>((*it).pAttr); - if( pCharColor ) - { - CPPUNIT_ASSERT_EQUAL( sal_uInt32(0x1F497D), pCharColor->GetValue().GetColor()); - } - } + checkFontAttributes(pObj, sal_uInt32(0x1F497D), + false, WEIGHT_DONTKNOW, false, ITALIC_NONE); } // Third smart art has white font color (style) { const SdrTextObj *pObj = dynamic_cast<SdrTextObj *>( pPage->GetObj( 2 ) ); - CPPUNIT_ASSERT_MESSAGE( "no object", pObj != NULL); - const EditTextObject& aEdit = pObj->GetOutlinerParaObject()->GetTextObject(); - std::vector<EECharAttrib> rLst; - aEdit.GetCharAttribs(0, rLst); - for( std::vector<EECharAttrib>::reverse_iterator it = rLst.rbegin(); it!=rLst.rend(); ++it) - { - const SvxColorItem *pCharColor = dynamic_cast<const SvxColorItem *>((*it).pAttr); - if( pCharColor ) - { - CPPUNIT_ASSERT_EQUAL( sal_uInt32(0xffffff), pCharColor->GetValue().GetColor()); - } - } + checkFontAttributes(pObj, sal_uInt32(0xffffff), + false, WEIGHT_DONTKNOW, false, ITALIC_NONE); } xDocShRef->DoClose(); commit 560ef65496465610d2f3a19611ee10e4a399460b Author: Markus Mohrhard <markus.mohrh...@collabora.co.uk> Date: Fri Jul 4 04:26:47 2014 +0200 extract some shared code Change-Id: Idfbbee6dc0bd5a63ae46ea8375270a475ef3521b diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx index 1e6d189..959c754 100644 --- a/sd/qa/unit/import-tests.cxx +++ b/sd/qa/unit/import-tests.cxx @@ -763,6 +763,38 @@ void SdFiltersTest::testBnc870237() xDocShRef->DoClose(); } +namespace { + +void checkFontAttributes(const SdrTextObj* pObj, sal_uInt32 nColor, + FontWeight eWeight, FontItalic eItalic) +{ + CPPUNIT_ASSERT_MESSAGE( "no object", pObj != NULL); + const EditTextObject& aEdit = pObj->GetOutlinerParaObject()->GetTextObject(); + std::vector<EECharAttrib> rLst; + aEdit.GetCharAttribs(0, rLst); + for( std::vector<EECharAttrib>::reverse_iterator it = rLst.rbegin(); it!=rLst.rend(); ++it) + { + const SvxColorItem *pCharColor = dynamic_cast<const SvxColorItem *>((*it).pAttr); + if( pCharColor ) + { + CPPUNIT_ASSERT_EQUAL( nColor, pCharColor->GetValue().GetColor()); + } + const SvxWeightItem *pWeight = dynamic_cast<const SvxWeightItem *>((*it).pAttr); + if( pWeight ) + { + CPPUNIT_ASSERT_EQUAL( eWeight, pWeight->GetWeight()); + } + const SvxPostureItem *pPosture = dynamic_cast<const SvxPostureItem *>((*it).pAttr); + if( pPosture ) + { + CPPUNIT_ASSERT_EQUAL( eItalic, pPosture->GetPosture()); + } + } + +} + +} + void SdFiltersTest::testBnc870233_1() { ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/bnc870233_1.pptx")); @@ -778,55 +810,13 @@ void SdFiltersTest::testBnc870233_1() // First shape has red, bold font { const SdrTextObj *pObj = dynamic_cast<SdrTextObj *>( pPage->GetObj( 0 ) ); - CPPUNIT_ASSERT_MESSAGE( "no object", pObj != NULL); - const EditTextObject& aEdit = pObj->GetOutlinerParaObject()->GetTextObject(); - std::vector<EECharAttrib> rLst; - aEdit.GetCharAttribs(0, rLst); - for( std::vector<EECharAttrib>::reverse_iterator it = rLst.rbegin(); it!=rLst.rend(); ++it) - { - const SvxColorItem *pCharColor = dynamic_cast<const SvxColorItem *>((*it).pAttr); - if( pCharColor ) - { - CPPUNIT_ASSERT_EQUAL( sal_uInt32(0xff0000), pCharColor->GetValue().GetColor()); - } - const SvxWeightItem *pWeight = dynamic_cast<const SvxWeightItem *>((*it).pAttr); - if( pWeight ) - { - CPPUNIT_ASSERT_EQUAL( WEIGHT_BOLD, pWeight->GetWeight()); - } - const SvxPostureItem *pPosture = dynamic_cast<const SvxPostureItem *>((*it).pAttr); - if( pPosture ) - { - CPPUNIT_ASSERT_EQUAL( ITALIC_NONE, pPosture->GetPosture()); - } - } + checkFontAttributes(pObj, sal_uInt32(0xff0000), WEIGHT_BOLD, ITALIC_NONE); } // Second shape has blue, italic font { const SdrTextObj *pObj = dynamic_cast<SdrTextObj *>( pPage->GetObj( 1 ) ); - CPPUNIT_ASSERT_MESSAGE( "no object", pObj != NULL); - const EditTextObject& aEdit = pObj->GetOutlinerParaObject()->GetTextObject(); - std::vector<EECharAttrib> rLst; - aEdit.GetCharAttribs(0, rLst); - for( std::vector<EECharAttrib>::reverse_iterator it = rLst.rbegin(); it!=rLst.rend(); ++it) - { - const SvxColorItem *pCharColor = dynamic_cast<const SvxColorItem *>((*it).pAttr); - if( pCharColor ) - { - CPPUNIT_ASSERT_EQUAL( sal_uInt32(0x0000ff), pCharColor->GetValue().GetColor()); - } - const SvxWeightItem *pWeight = dynamic_cast<const SvxWeightItem *>((*it).pAttr); - if( pWeight ) - { - CPPUNIT_ASSERT_EQUAL( WEIGHT_NORMAL, pWeight->GetWeight()); - } - const SvxPostureItem *pPosture = dynamic_cast<const SvxPostureItem *>((*it).pAttr); - if( pPosture ) - { - CPPUNIT_ASSERT_EQUAL( ITALIC_NORMAL, pPosture->GetPosture()); - } - } + checkFontAttributes(pObj, sal_uInt32(0x0000ff), WEIGHT_NORMAL, ITALIC_NORMAL); } xDocShRef->DoClose(); commit a1e8998571e35427a085c3e3813789ce4fef852a Author: Markus Mohrhard <markus.mohrh...@collabora.co.uk> Date: Fri Jul 4 04:16:54 2014 +0200 fix wrong operator<< for Color Change-Id: Iccaf173fc15466f8d0604e3d0e4cd2c790902db4 diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx index 1b10e29..1e6d189 100644 --- a/sd/qa/unit/import-tests.cxx +++ b/sd/qa/unit/import-tests.cxx @@ -548,7 +548,7 @@ void SdFiltersTest::testFdo72998() // FIXME copypasta std::ostream& operator<<(std::ostream& rStrm, const Color& rColor) { - rStrm << "Color: R:" << rColor.GetRed() << " G:" << rColor.GetGreen() << " B: << rColor.GetBlue()"; + rStrm << "Color: R:" << rColor.GetRed() << " G:" << rColor.GetGreen() << " B: " << rColor.GetBlue(); return rStrm; } commit a255602967bbfc353a22aadbe370879c1733bcb8 Author: Markus Mohrhard <markus.mohrh...@collabora.co.uk> Date: Fri Jul 4 04:11:31 2014 +0200 don't inherit the style from the title, related bnc#880488 It seems that inheriting the style from the title for the subtitle is just wrong. Change-Id: Icbedf3e934b13514e50a1354552e5d6a8d139095 diff --git a/oox/source/ppt/pptshape.cxx b/oox/source/ppt/pptshape.cxx index c5a2d06..8b02702 100644 --- a/oox/source/ppt/pptshape.cxx +++ b/oox/source/ppt/pptshape.cxx @@ -149,7 +149,6 @@ void PPTShape::addShape( sServiceName = OUString(); else { sServiceName = "com.sun.star.presentation.SubtitleShape"; - aMasterTextListStyle = rSlidePersist.getMasterPersist().get() ? rSlidePersist.getMasterPersist()->getTitleTextStyle() : rSlidePersist.getTitleTextStyle(); } } break; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits