[Libreoffice-commits] core.git: include/svx svx/CppunitTest_svx_unit.mk svx/qa svx/source

Tomaž Vajngerl tomaz.vajngerl at collabora.co.uk
Tue Feb 27 11:23:09 UTC 2018


 include/svx/xtable.hxx                 |    2 
 svx/CppunitTest_svx_unit.mk            |   11 ++++
 svx/qa/unit/XTableImportExportTest.cxx |   90 +++++++++++++++++++++++++++++++++
 svx/source/xml/xmlxtexp.cxx            |    2 
 4 files changed, 103 insertions(+), 2 deletions(-)

New commits:
commit 93596ffc94376b0b43a77f18f56ae9640127de5c
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Mon Feb 26 12:29:58 2018 +0900

    Fix exporting bitmap table + test
    
    Change-Id: I0577de02000c6aeb45bf1e950b9212beadacb05b
    Reviewed-on: https://gerrit.libreoffice.org/50334
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>

diff --git a/include/svx/xtable.hxx b/include/svx/xtable.hxx
index 76f93c18940e..1012303e0586 100644
--- a/include/svx/xtable.hxx
+++ b/include/svx/xtable.hxx
@@ -160,7 +160,7 @@ class SVX_DLLPUBLIC XPropertyList : public cppu::OWeakObject
 private:
     SAL_DLLPRIVATE void* operator new(size_t);
 protected:
-    SAL_DLLPRIVATE void operator delete(void *);
+    void operator delete(void *);
 protected:
     XPropertyListType   meType;
     OUString            maName; // not persistent
diff --git a/svx/CppunitTest_svx_unit.mk b/svx/CppunitTest_svx_unit.mk
index 0bac905a9dc9..41596e68c528 100644
--- a/svx/CppunitTest_svx_unit.mk
+++ b/svx/CppunitTest_svx_unit.mk
@@ -13,19 +13,30 @@ $(eval $(call gb_CppunitTest_use_external,svx_unit,boost_headers))
 
 $(eval $(call gb_CppunitTest_use_sdk_api,svx_unit))
 
+$(eval $(call gb_CppunitTest_set_include,svx_unit,\
+    -I$(SRCDIR)/svx/source/inc \
+    -I$(SRCDIR)/svx/inc \
+    $$(INCLUDE) \
+))
+
 $(eval $(call gb_CppunitTest_add_exception_objects,svx_unit, \
 	svx/qa/unit/svdraw/test_SdrTextObject \
 	svx/qa/unit/xoutdev \
+	svx/qa/unit/XTableImportExportTest \
 ))
 
 $(eval $(call gb_CppunitTest_use_libraries,svx_unit, \
 	sal \
 	sfx \
 	svxcore \
+	svx \
 	tl \
 	unotest \
 	vcl \
 	utl \
+	comphelper \
+	cppuhelper \
+	cppu \
 ))
 
 $(eval $(call gb_CppunitTest_use_sdk_api,svx_unit))
diff --git a/svx/qa/unit/XTableImportExportTest.cxx b/svx/qa/unit/XTableImportExportTest.cxx
new file mode 100644
index 000000000000..df08fa6190f5
--- /dev/null
+++ b/svx/qa/unit/XTableImportExportTest.cxx
@@ -0,0 +1,90 @@
+/* -*- 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 <config_features.h>
+
+#include <cppunit/TestAssert.h>
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+#include <sal/types.h>
+#include <sfx2/app.hxx>
+#include <unotools/tempfile.hxx>
+#include <svx/xtable.hxx>
+#include <vcl/bitmapex.hxx>
+#include <svx/XPropertyTable.hxx>
+
+#include <xmlxtexp.hxx>
+
+#include <com/sun/star/awt/XBitmap.hpp>
+
+using namespace css;
+
+class XTableImportExportTest : public CppUnit::TestFixture
+{
+public:
+    void testImportExport();
+
+    virtual void setUp() override
+    {
+        CppUnit::TestFixture::setUp();
+        SfxApplication::GetOrCreate();
+    }
+
+    CPPUNIT_TEST_SUITE(XTableImportExportTest);
+    CPPUNIT_TEST(testImportExport);
+    CPPUNIT_TEST_SUITE_END();
+};
+
+void XTableImportExportTest::testImportExport()
+{
+    utl::TempFile aTempFile(nullptr, true);
+    aTempFile.EnableKillingFile();
+    OUString aTempURL = aTempFile.GetURL();
+    BitmapChecksum aChecksum(0);
+
+    {
+        XBitmapList xBitmapList(aTempURL, "REF");
+        uno::Reference<container::XNameContainer> xNameContainer(xBitmapList.createInstance());
+        CPPUNIT_ASSERT(xNameContainer.is());
+
+        Bitmap aBitmap(Size(5, 5), 24);
+        aBitmap.Erase(COL_RED);
+        BitmapEx aBitmapEx(aBitmap);
+        Graphic aGraphic(aBitmapEx);
+        uno::Reference<awt::XBitmap> xBitmap(aGraphic.GetXGraphic(), css::uno::UNO_QUERY);
+
+        xNameContainer->insertByName("SomeBitmap", uno::makeAny(xBitmap));
+        xBitmapList.Save();
+
+        aChecksum = aBitmap.GetChecksum();
+    }
+
+    {
+        XBitmapList xBitmapList(aTempURL, "REF");
+        xBitmapList.Load();
+        uno::Reference<container::XNameContainer> xNameContainer(xBitmapList.createInstance());
+        CPPUNIT_ASSERT(xNameContainer.is());
+
+        uno::Any aAny = xNameContainer->getByName("SomeBitmap");
+        CPPUNIT_ASSERT(aAny.has<uno::Reference<awt::XBitmap>>());
+        auto xBitmap = aAny.get<uno::Reference<awt::XBitmap>>();
+        CPPUNIT_ASSERT(xBitmap.is());
+        uno::Reference<graphic::XGraphic> xGraphic(xBitmap, uno::UNO_QUERY);
+        CPPUNIT_ASSERT(xGraphic.is());
+        Graphic aGraphic(xGraphic);
+        CPPUNIT_ASSERT(aGraphic);
+        Bitmap aBitmap = aGraphic.GetBitmapEx().GetBitmap();
+        CPPUNIT_ASSERT_EQUAL(aChecksum, aBitmap.GetChecksum());
+    }
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(XTableImportExportTest);
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/xml/xmlxtexp.cxx b/svx/source/xml/xmlxtexp.cxx
index 2254de22e652..4db4101dc2c3 100644
--- a/svx/source/xml/xmlxtexp.cxx
+++ b/svx/source/xml/xmlxtexp.cxx
@@ -204,7 +204,7 @@ bool SvxXMLXTableExportComponent::save(
     INetURLObject aURLObj( rURL );
     bool bToStorage = aURLObj.GetProtocol() == INetProtocol::NotValid; // a relative path
 
-    bool bSaveAsStorage = xTable->getElementType() == cppu::UnoType<OUString>::get();
+    bool bSaveAsStorage = xTable->getElementType() == cppu::UnoType<awt::XBitmap>::get();
 
     if( pOptName )
         *pOptName = rURL;


More information about the Libreoffice-commits mailing list