[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-4.1' - 2 commits - filter/CppunitTest_filter_xslt.mk filter/Module_filter.mk filter/qa filter/source sw/qa writerfilter/source
Michael Stahl
mstahl at redhat.com
Mon Mar 10 04:12:58 PDT 2014
filter/CppunitTest_filter_xslt.mk | 46 +++++
filter/Module_filter.mk | 4
filter/qa/cppunit/data/xslt/copy.xslt | 9 +
filter/qa/cppunit/xslt-test.cxx | 193 ++++++++++++++++++++++
filter/source/xsltfilter/LibXSLTTransformer.cxx | 5
sw/qa/extras/ooxmlexport/data/fdo65655.docx |binary
sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 16 +
writerfilter/source/dmapper/DomainMapper_Impl.cxx | 10 -
8 files changed, 280 insertions(+), 3 deletions(-)
New commits:
commit db04610862bf50e709bee11adba74da561df7f9e
Author: Michael Stahl <mstahl at redhat.com>
Date: Tue Mar 4 17:59:45 2014 +0100
filter: make LibXSLTTransformer init backward compatible
As reported by Fernand Vanrie, initializing the XSLT service can fail
because the LibXSLTTransformer::initialize was changed to require
the parameters as a nested Sequence; accept previous parameter
convention as a fall-back.
(regression from ca0ea73a4ab104031a16b5bac7a9bb6e57c77ba0)
(cherry picked from commit 6967da019b69767a15116de101d33a16b95c8a44)
filter: and we learn that BootstrapFixture requires boost headers
(cherry picked from commit bfdd18eb35f5c8bf7f713910ec35b853c7456969)
filter: don't wait forever if the xslt test fails
(cherry picked from commit 8af7a8953248dd184cd620b934ee6abc147f4076)
I imagine this should have a SAL_CALL decoration
(cherry picked from commit 62d6252d2cde33f6ef0e627c3192a63d43ba2a87)
filter: sigh... fix the xslt test to run on WNT too
(cherry picked from commit 4fcd5534348adcb61ab85b93478c272b8d9e8f8c)
Change-Id: I136e6e6338f11ffecf9f856f0736d1d0e6b17c3f
Reviewed-on: https://gerrit.libreoffice.org/8456
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/filter/CppunitTest_filter_xslt.mk b/filter/CppunitTest_filter_xslt.mk
new file mode 100644
index 0000000..90af9b0
--- /dev/null
+++ b/filter/CppunitTest_filter_xslt.mk
@@ -0,0 +1,46 @@
+# -*- 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,filter_xslt))
+
+$(eval $(call gb_CppunitTest_use_api,filter_xslt,\
+ offapi \
+ udkapi \
+))
+
+$(eval $(call gb_CppunitTest_use_ure,filter_xslt))
+
+$(eval $(call gb_CppunitTest_use_configuration,filter_xslt))
+
+$(eval $(call gb_CppunitTest_use_external,filter_xslt,boost_headers))
+
+$(eval $(call gb_CppunitTest_use_libraries,filter_xslt, \
+ comphelper \
+ test \
+ unotest \
+ cppuhelper \
+ cppu \
+ sal \
+ $(gb_UWINAPI) \
+))
+
+$(eval $(call gb_CppunitTest_use_components,filter_xslt,\
+ configmgr/source/configmgr \
+ fileaccess/source/fileacc \
+ filter/source/xsltfilter/xsltfilter \
+ i18npool/util/i18npool \
+ ucb/source/core/ucb1 \
+ ucb/source/ucp/file/ucpfile1 \
+))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,filter_xslt, \
+ filter/qa/cppunit/xslt-test \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/filter/Module_filter.mk b/filter/Module_filter.mk
index 559fb65..85480f7 100644
--- a/filter/Module_filter.mk
+++ b/filter/Module_filter.mk
@@ -75,6 +75,10 @@ $(eval $(call gb_Module_add_targets,filter,\
))
endif
+$(eval $(call gb_Module_add_check_targets,filter,\
+ CppunitTest_filter_xslt \
+))
+
ifneq ($(DISABLE_CVE_TESTS),TRUE)
$(eval $(call gb_Module_add_check_targets,filter,\
CppunitTest_filter_pict_test \
diff --git a/filter/qa/cppunit/data/xslt/copy.xslt b/filter/qa/cppunit/data/xslt/copy.xslt
new file mode 100644
index 0000000..d46172a
--- /dev/null
+++ b/filter/qa/cppunit/data/xslt/copy.xslt
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+<xsl:template match="/">
+ <xsl:copy-of select="/"/>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/filter/qa/cppunit/xslt-test.cxx b/filter/qa/cppunit/xslt-test.cxx
new file mode 100644
index 0000000..509d37c
--- /dev/null
+++ b/filter/qa/cppunit/xslt-test.cxx
@@ -0,0 +1,193 @@
+/* -*- 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 <limits>
+
+#include <cppunit/TestAssert.h>
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+#include <cppunit/plugin/TestPlugIn.h>
+
+#include <sal/types.h>
+
+#include <rtl/ref.hxx>
+
+#include <osl/file.hxx>
+#include <osl/thread.h>
+
+#include <com/sun/star/beans/NamedValue.hpp>
+#include <com/sun/star/io/XStreamListener.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/ucb/SimpleFileAccess.hpp>
+#include <com/sun/star/xml/xslt/XSLTTransformer.hpp>
+
+#include <cppuhelper/implbase1.hxx>
+
+#include <test/bootstrapfixture.hxx>
+
+
+using namespace std;
+using namespace ::com::sun::star;
+
+
+namespace {
+
+class XsltFilterTest
+ : public test::BootstrapFixture
+{
+public:
+ void testXsltCopyOld();
+ void testXsltCopyNew();
+
+ CPPUNIT_TEST_SUITE(XsltFilterTest);
+ CPPUNIT_TEST(testXsltCopyOld);
+ CPPUNIT_TEST(testXsltCopyNew);
+ CPPUNIT_TEST_SUITE_END();
+};
+
+struct Listener : public ::cppu::WeakImplHelper1<io::XStreamListener>
+{
+ bool m_bDone;
+
+ Listener() : m_bDone(false) {}
+
+ virtual void SAL_CALL disposing(const lang::EventObject&) throw() SAL_OVERRIDE {}
+ virtual void SAL_CALL started() throw() SAL_OVERRIDE { m_bDone = false; }
+ virtual void SAL_CALL closed() throw() SAL_OVERRIDE { m_bDone = true; }
+ virtual void SAL_CALL terminated() throw() SAL_OVERRIDE { m_bDone = true; }
+ virtual void SAL_CALL error(const uno::Any& e) throw() SAL_OVERRIDE
+ {
+ (void)e;
+ m_bDone = true; // set on error too, otherwise main thread waits forever
+ CPPUNIT_FAIL("exception while in XSLT");
+ }
+};
+
+void XsltFilterTest::testXsltCopyNew()
+{
+ OUString tempDirURL;
+ osl_getTempDirURL(&tempDirURL.pData);
+ oslFileHandle tempFile;
+ OUString tempURL;
+ osl::File::RC rc = osl::File::createTempFile(0, &tempFile, &tempURL);
+ CPPUNIT_ASSERT(osl::FileBase::E_None == rc);
+ osl_closeFile(tempFile); // close it so xSFA can open it on WNT
+
+ OUString source(
+ getURLFromSrc("/filter/source/xsltfilter/xsltfilter.component"));
+ uno::Sequence<uno::Any> args(7);
+ args[0] <<= beans::NamedValue("StylesheetURL",
+ uno::makeAny(getURLFromSrc("/filter/qa/cppunit/data/xslt/copy.xslt")));
+ args[1] <<= beans::NamedValue("SourceURL", uno::makeAny(source));
+ args[2] <<= beans::NamedValue("TargetURL", uno::makeAny(tempURL));
+ args[3] <<= beans::NamedValue("SourceBaseURL",
+ uno::makeAny(getURLFromSrc("/filter/source/xsltfilter/")));
+ args[4] <<= beans::NamedValue("TargetBaseURL", uno::makeAny(tempDirURL));
+ args[5] <<= beans::NamedValue("SystemType", uno::makeAny(OUString()));
+ args[6] <<= beans::NamedValue("PublicType", uno::makeAny(OUString()));
+
+ uno::Reference<ucb::XSimpleFileAccess3> xSFA =
+ ucb::SimpleFileAccess::create(getComponentContext());
+
+ uno::Reference<io::XInputStream> xIn = xSFA->openFileRead(source);
+ uno::Reference<io::XOutputStream> xOut = xSFA->openFileWrite(tempURL);
+
+ rtl::Reference<Listener> xListener = new Listener();
+
+ uno::Reference<xml::xslt::XXSLTTransformer> xXslt(
+ xml::xslt::XSLTTransformer::create(getComponentContext(), args));
+
+ xXslt->addListener(uno::Reference<io::XStreamListener>(xListener.get()));
+ xXslt->setInputStream(xIn);
+ xXslt->setOutputStream(xOut);
+
+ xXslt->start();
+
+ TimeValue delay;
+ delay.Seconds = 0;
+ delay.Nanosec = 1000000;
+ while (!xListener->m_bDone) { osl_waitThread(&delay); }
+
+ xIn->closeInput();
+ xOut->closeOutput();
+
+ osl::File foo(tempURL); // apparently it's necessary to open it again?
+ foo.open(osl_File_OpenFlag_Read);
+ sal_uInt64 size(0);
+ foo.getSize(size);
+ CPPUNIT_ASSERT(size > 1000); // check that something happened
+}
+
+void XsltFilterTest::testXsltCopyOld()
+{
+ OUString tempDirURL;
+ osl_getTempDirURL(&tempDirURL.pData);
+ oslFileHandle tempFile;
+ OUString tempURL;
+ osl::File::RC rc = osl::File::createTempFile(0, &tempFile, &tempURL);
+ CPPUNIT_ASSERT(osl::FileBase::E_None == rc);
+ osl_closeFile(tempFile); // close it so xSFA can open it on WNT
+
+ OUString source(
+ getURLFromSrc("/filter/source/xsltfilter/xsltfilter.component"));
+ uno::Sequence<uno::Any> args(7);
+ args[0] <<= beans::NamedValue("StylesheetURL",
+ uno::makeAny(getURLFromSrc("/filter/qa/cppunit/data/xslt/copy.xslt")));
+ args[1] <<= beans::NamedValue("SourceURL", uno::makeAny(source));
+ args[2] <<= beans::NamedValue("TargetURL", uno::makeAny(tempURL));
+ args[3] <<= beans::NamedValue("SourceBaseURL",
+ uno::makeAny(getURLFromSrc("/filter/source/xsltfilter/")));
+ args[4] <<= beans::NamedValue("TargetBaseURL", uno::makeAny(tempDirURL));
+ args[5] <<= beans::NamedValue("SystemType", uno::makeAny(OUString()));
+ args[6] <<= beans::NamedValue("PublicType", uno::makeAny(OUString()));
+
+
+ uno::Reference<ucb::XSimpleFileAccess3> xSFA =
+ ucb::SimpleFileAccess::create(getComponentContext());
+
+ uno::Reference<io::XInputStream> xIn = xSFA->openFileRead(source);
+ uno::Reference<io::XOutputStream> xOut = xSFA->openFileWrite(tempURL);
+
+ rtl::Reference<Listener> xListener = new Listener();
+
+ uno::Reference<xml::xslt::XXSLTTransformer> xXslt(
+ getMultiServiceFactory()->createInstance(
+ "com.sun.star.comp.documentconversion.LibXSLTTransformer"),
+ uno::UNO_QUERY_THROW);
+
+ uno::Reference<lang::XInitialization> xInit(xXslt, uno::UNO_QUERY_THROW);
+ xInit->initialize(args);
+ xXslt->addListener(uno::Reference<io::XStreamListener>(xListener.get()));
+ xXslt->setInputStream(xIn);
+ xXslt->setOutputStream(xOut);
+
+ xXslt->start();
+
+ TimeValue delay;
+ delay.Seconds = 0;
+ delay.Nanosec = 1000000;
+ while (!xListener->m_bDone) { osl_waitThread(&delay); }
+
+ xIn->closeInput();
+ xOut->closeOutput();
+
+ osl::File foo(tempURL); // apparently it's necessary to open it again?
+ foo.open(osl_File_OpenFlag_Read);
+ sal_uInt64 size(0);
+ foo.getSize(size);
+ CPPUNIT_ASSERT(size > 1000); // check that something happened
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(XsltFilterTest);
+
+}
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/filter/source/xsltfilter/LibXSLTTransformer.cxx b/filter/source/xsltfilter/LibXSLTTransformer.cxx
index b98d71c..ff747a5 100644
--- a/filter/source/xsltfilter/LibXSLTTransformer.cxx
+++ b/filter/source/xsltfilter/LibXSLTTransformer.cxx
@@ -475,7 +475,10 @@ namespace XSLT
throw (RuntimeException)
{
Sequence<Any> params;
- args[0] >>= params;
+ if (!(args[0] >>= params))
+ { // backward compatibility for old clients using createInstance
+ params = args;
+ }
xmlSubstituteEntitiesDefault(0);
m_parameters.clear();
for (int i = 0; i < params.getLength(); i++)
commit b8fc3d1942538835bc958d2685985f9896ce3d35
Author: Adam Co <rattles2013 at gmail.com>
Date: Tue Jun 11 18:21:27 2013 +0300
fdo#65655 : fix for Different_Odd_And_Even_Pages flag ignored
Signed-off-by: Miklos Vajna <vmiklos at suse.cz>
Conflicts:
sw/qa/extras/ooxmlexport/ooxmlexport.cxx
(cherry picked from commit db23f89b76cb61b215bcae5495eadba2b5ceace2)
Signed-off-by: Michael Stahl <mstahl at redhat.com>
Conflicts:
sw/qa/extras/ooxmlexport/ooxmlexport.cxx
Change-Id: Icf9949bb00aa905d22aedfd8f2b297dfa89dfedb
diff --git a/sw/qa/extras/ooxmlexport/data/fdo65655.docx b/sw/qa/extras/ooxmlexport/data/fdo65655.docx
new file mode 100644
index 0000000..5fe9451
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/fdo65655.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 1372151..21fa482 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -78,6 +78,7 @@ public:
void testCp1000015();
void testFdo70812();
void testBnc837302();
+ void testFdo65655();
CPPUNIT_TEST_SUITE(Test);
#if !defined(MACOSX) && !defined(WNT)
@@ -140,6 +141,7 @@ void Test::run()
{"cp1000015.odt", &Test::testCp1000015},
{"fdo70812.docx", &Test::testFdo70812},
{"bnc837302.docx", &Test::testBnc837302},
+ {"fdo65655.docx", &Test::testFdo65655},
};
// Don't test the first import of these, for some reason those tests fail
const char* aBlacklist[] = {
@@ -813,6 +815,20 @@ void Test::testBnc837302()
CPPUNIT_ASSERT_EQUAL(OUString(), aProperty);
}
+void Test::testFdo65655()
+{
+ // The problem was that the DOCX had a non-blank odd footer and a blank even footer
+ // The 'Different Odd & Even Pages' was turned on
+ // However - LO assumed that because the 'even' footer is blank - it should ignore the 'Different Odd & Even Pages' flag
+ // So it did not import it and did not export it
+ uno::Reference<beans::XPropertySet> xPropertySet(getStyles("PageStyles")->getByName(DEFAULT_STYLE), uno::UNO_QUERY);
+ sal_Bool bValue = false;
+ xPropertySet->getPropertyValue("HeaderIsShared") >>= bValue;
+ CPPUNIT_ASSERT_EQUAL(false, bool(bValue));
+ xPropertySet->getPropertyValue("FooterIsShared") >>= bValue;
+ CPPUNIT_ASSERT_EQUAL(false, bool(bValue));
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 429381d..5e0c200 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -1405,7 +1405,10 @@ void DomainMapper_Impl::PushPageHeader(SectionPropertyMap::PageType eType)
uno::makeAny(sal_True) );
// if a left header is available then header are not shared
bool bLeft = eType == SectionPropertyMap::PAGE_LEFT;
- if( bLeft && m_pSettingsTable->GetEvenAndOddHeaders())
+
+ // If the 'Different Even & Odd Pages' flag is turned on - do not ignore it
+ // Even if the 'Even' header is blank - the flag should be imported (so it would look in LO like in Word)
+ if( m_pSettingsTable->GetEvenAndOddHeaders())
xPageStyle->setPropertyValue(rPropNameSupplier.GetName(PROP_HEADER_IS_SHARED), uno::makeAny( false ));
//set the interface
@@ -1447,7 +1450,10 @@ void DomainMapper_Impl::PushPageFooter(SectionPropertyMap::PageType eType)
uno::makeAny(sal_True) );
// if a left header is available then footer is not shared
bool bLeft = eType == SectionPropertyMap::PAGE_LEFT;
- if( bLeft && m_pSettingsTable->GetEvenAndOddHeaders())
+
+ // If the 'Different Even & Odd Pages' flag is turned on - do not ignore it
+ // Even if the 'Even' footer is blank - the flag should be imported (so it would look in LO like in Word)
+ if( m_pSettingsTable->GetEvenAndOddHeaders())
xPageStyle->setPropertyValue(rPropNameSupplier.GetName(PROP_FOOTER_IS_SHARED), uno::makeAny( false ));
//set the interface
uno::Reference< text::XText > xFooterText;
More information about the Libreoffice-commits
mailing list