sd/qa/unit/data/pptx/bnc591147.pptx |binary sd/qa/unit/import-tests.cxx | 37 +++++++++++++++++++ sw/CppunitTest_sw_htmlimport.mk | 56 ++++++++++++++++++++++++++++++ sw/Module_sw.mk | 1 sw/qa/extras/htmlimport/data/picture.html | 23 ++++++++++++ sw/qa/extras/htmlimport/htmlimport.cxx | 35 ++++++++++++++++++ sw/source/filter/html/htmlgrin.cxx | 19 +++------- 7 files changed, 159 insertions(+), 12 deletions(-)
New commits: commit a3ef3b658dea9b59ded319f2f092e73e4deaad24 Author: Matúš Kukan <[email protected]> Date: Wed Sep 17 18:50:04 2014 +0200 bnc#591147: unit test for media files import Change-Id: Ie45818c54d756628e9cbc2619e5ad43cedcac92c diff --git a/sd/qa/unit/data/pptx/bnc480256.pptx b/sd/qa/unit/data/pptx/bnc480256.pptx old mode 100755 new mode 100644 diff --git a/sd/qa/unit/data/pptx/bnc591147.pptx b/sd/qa/unit/data/pptx/bnc591147.pptx new file mode 100644 index 0000000..afa382e Binary files /dev/null and b/sd/qa/unit/data/pptx/bnc591147.pptx differ diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx index 91fec0f..6bc206a 100644 --- a/sd/qa/unit/import-tests.cxx +++ b/sd/qa/unit/import-tests.cxx @@ -77,6 +77,7 @@ public: void testBnc870237(); void testBnc887225(); void testBnc480256(); + void testBnc591147(); void testCreationDate(); void testBnc584721_1(); void testBnc584721_2(); @@ -102,6 +103,7 @@ public: CPPUNIT_TEST(testBnc870237); CPPUNIT_TEST(testBnc887225); CPPUNIT_TEST(testBnc480256); + CPPUNIT_TEST(testBnc591147); CPPUNIT_TEST(testCreationDate); CPPUNIT_TEST(testBnc584721_1); CPPUNIT_TEST(testBnc584721_2); @@ -773,6 +775,41 @@ void SdFiltersTest::testBnc584721_3() xDocShRef->DoClose(); } +void SdFiltersTest::testBnc591147() +{ + ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/bnc591147.pptx"), PPTX); + + // In the document, there are two slides with media files. + uno::Reference< drawing::XDrawPagesSupplier > xDoc( + xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW ); + CPPUNIT_ASSERT_EQUAL( sal_Int32(2), xDoc->getDrawPages()->getCount() ); + + // First page has video file inserted + uno::Reference< drawing::XDrawPage > xPage( + xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW ); + CPPUNIT_ASSERT_EQUAL( sal_Int32(1), xPage->getCount() ); + + uno::Reference< drawing::XShape > xShape(xPage->getByIndex(0), uno::UNO_QUERY_THROW ); + uno::Reference< beans::XPropertySet > xPropSet( xShape, uno::UNO_QUERY_THROW ); + OUString sVideoURL("emptyURL"); + bool bSucess = xPropSet->getPropertyValue("MediaURL") >>= sVideoURL; + CPPUNIT_ASSERT_MESSAGE( "MediaURL property is not set", bSucess ); + + // Second page has audio file inserted + xPage.set( xDoc->getDrawPages()->getByIndex(1), uno::UNO_QUERY_THROW ); + CPPUNIT_ASSERT_EQUAL( sal_Int32(1), xPage->getCount() ); + + xShape.set( xPage->getByIndex(0), uno::UNO_QUERY_THROW ); + xPropSet.set( xShape, uno::UNO_QUERY_THROW ); + OUString sAudioURL("emptyURL"); + bSucess = xPropSet->getPropertyValue("MediaURL") >>= sAudioURL; + CPPUNIT_ASSERT_MESSAGE( "MediaURL property is not set", bSucess ); + + CPPUNIT_ASSERT_MESSAGE( "sAudioURL and sVideoURL should not be equal", sAudioURL != sVideoURL ); + + xDocShRef->DoClose(); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SdFiltersTest); CPPUNIT_PLUGIN_IMPLEMENT(); commit bcf8dc3d9b9d2df6f6a67c71efc52630ff65371b Author: Matúš Kukan <[email protected]> Date: Wed Sep 17 11:56:24 2014 +0200 sw: html import test: local images shouldn't be file links (bnc#580834) Change-Id: Id35e03a3f814609e40e4beea778e66cce39054d1 diff --git a/sw/CppunitTest_sw_htmlimport.mk b/sw/CppunitTest_sw_htmlimport.mk new file mode 100644 index 0000000..3036076 --- /dev/null +++ b/sw/CppunitTest_sw_htmlimport.mk @@ -0,0 +1,56 @@ +# -*- 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,sw_htmlimport)) + +$(eval $(call gb_CppunitTest_add_exception_objects,sw_htmlimport, \ + sw/qa/extras/htmlimport/htmlimport \ +)) + +$(eval $(call gb_CppunitTest_use_libraries,sw_htmlimport, \ + comphelper \ + cppu \ + cppuhelper \ + i18nlangtag \ + sal \ + sw \ + test \ + tl \ + unotest \ + utl \ + vcl \ + $(gb_UWINAPI) \ +)) + +$(eval $(call gb_CppunitTest_use_externals,sw_htmlimport,\ + boost_headers \ + libxml2 \ +)) + +$(eval $(call gb_CppunitTest_set_include,sw_htmlimport,\ + -I$(SRCDIR)/sw/inc \ + -I$(SRCDIR)/sw/source/core/inc \ + -I$(SRCDIR)/sw/qa/extras/inc \ + $$(INCLUDE) \ +)) + +$(eval $(call gb_CppunitTest_use_sdk_api,sw_htmlimport)) + +$(eval $(call gb_CppunitTest_use_ure,sw_htmlimport)) +$(eval $(call gb_CppunitTest_use_vcl,sw_htmlimport)) + +$(eval $(call gb_CppunitTest_use_rdb,sw_htmlimport,services)) + +$(eval $(call gb_CppunitTest_use_configuration,sw_htmlimport)) + +$(eval $(call gb_CppunitTest_use_unittest_configuration,sw_htmlimport)) + +# vim: set noet sw=4 ts=4: diff --git a/sw/Module_sw.mk b/sw/Module_sw.mk index 7e645c8..3a3d75b 100644 --- a/sw/Module_sw.mk +++ b/sw/Module_sw.mk @@ -53,6 +53,7 @@ $(eval $(call gb_Module_add_check_targets,sw,\ $(eval $(call gb_Module_add_slowcheck_targets,sw,\ CppunitTest_sw_uwriter \ CppunitTest_sw_htmlexport \ + CppunitTest_sw_htmlimport \ CppunitTest_sw_macros_test \ CppunitTest_sw_ooxmlexport \ CppunitTest_sw_ooxmlexport2 \ diff --git a/sw/qa/extras/htmlimport/data/picture.html b/sw/qa/extras/htmlimport/data/picture.html new file mode 100644 index 0000000..c0b2e6c --- /dev/null +++ b/sw/qa/extras/htmlimport/data/picture.html @@ -0,0 +1,23 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<html xmlns="http://www.w3.org/1999/xhtml" lang="en"> + <body> + <div> + <p> + This document should contain only one link. (Edit -> Links...) + </p> + <p> + The picture below is supposed to be fully inserted into the document, not just as a link. + <br/> + <a style="display:inline-block;" href="http://www.libreoffice.org/" title="Go to the Home of LibreOffice and the LibreOffice Community page"> + <img src="../../../../../odk/docs/images/sdk_head-1.png" width="377" height="120px"/> + </a> + </p> + This one is supposed to be inserted as a link, since the source is "http://..." URL. + <br/> + <a style="display:inline-block;" href="http://www.libreoffice.org/" title="Go to the Home of LibreOffice and the LibreOffice Community page"> + <img src="http://www.libreoffice.org/themes/libo/images/logo.png" width="218px" height="45px"/> + </a> + </p> + </div> + </body> +</html> diff --git a/sw/qa/extras/htmlimport/htmlimport.cxx b/sw/qa/extras/htmlimport/htmlimport.cxx new file mode 100644 index 0000000..86b7b86 --- /dev/null +++ b/sw/qa/extras/htmlimport/htmlimport.cxx @@ -0,0 +1,35 @@ +/* + * 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 <swmodeltestbase.hxx> + +#include <sfx2/linkmgr.hxx> + +#include <docsh.hxx> +#include <editsh.hxx> + +class HtmlImportTest : public SwModelTestBase +{ + public: + HtmlImportTest() : SwModelTestBase("sw/qa/extras/htmlimport/data/", "HTML (StarWriter)") {} +}; + +#define DECLARE_HTMLIMPORT_TEST(TestName, filename) DECLARE_SW_IMPORT_TEST(TestName, filename, HtmlImportTest) + +DECLARE_HTMLIMPORT_TEST(testPictureImport, "picture.html") +{ + SwXTextDocument* pTxtDoc = dynamic_cast<SwXTextDocument *>(mxComponent.get()); + CPPUNIT_ASSERT(pTxtDoc); + // The document contains one embeded picture and one stored as a link. + const sfx2::LinkManager& rLinkManager = pTxtDoc->GetDocShell()->GetDoc()->GetEditShell()->GetLinkManager(); + CPPUNIT_ASSERT_EQUAL(size_t(1), rLinkManager.GetLinks().size()); +} + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit 3914a711060341345f15b83656457f90095f32d6 Author: Matúš Kukan <[email protected]> Date: Wed Sep 17 11:57:24 2014 +0200 bnc#580834: HTML import: Embed images if source URL is a local file. Use also INET_PROT_FILE to determine whether to import images as links. Change-Id: I072be21086505f6300463e4e3cfb276cbe506803 diff --git a/sw/source/filter/html/htmlgrin.cxx b/sw/source/filter/html/htmlgrin.cxx index 19d11da..5a08056 100644 --- a/sw/source/filter/html/htmlgrin.cxx +++ b/sw/source/filter/html/htmlgrin.cxx @@ -696,23 +696,18 @@ IMAGE_SETEVENT: Graphic aEmptyGrf; INetURLObject aGraphicURL( sGrfNm ); - if( aGraphicURL.GetProtocol() == INET_PROT_DATA ) + if (aGraphicURL.GetProtocol() == INET_PROT_DATA || + aGraphicURL.GetProtocol() == INET_PROT_FILE) { - SvMemoryStream* aStream = aGraphicURL.getData(); - if( aStream ) - { - GraphicFilter::GetGraphicFilter().ImportGraphic( aEmptyGrf, OUString(), *aStream ); - free( aStream ); - } - else - { - aEmptyGrf.SetDefaultType(); - } + if (GRFILTER_OK == GraphicFilter::GetGraphicFilter().ImportGraphic(aEmptyGrf, aGraphicURL)) + sGrfNm = ""; } - else + if (!sGrfNm.isEmpty()) { aEmptyGrf.SetDefaultType(); } + + // passing empty sGrfNm here, means we don't want the graphic to be linked SwFrmFmt *pFlyFmt = pDoc->getIDocumentContentOperations().Insert( *pPam, sGrfNm, aEmptyOUStr, &aEmptyGrf, &aFrmSet, NULL, NULL ); SwGrfNode *pGrfNd = pDoc->GetNodes()[ pFlyFmt->GetCntnt().GetCntntIdx()
_______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
