summaryrefslogtreecommitdiffstats
path: root/svx/qa/unit/XTableImportExportTest.cxx
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 05:54:39 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 05:54:39 +0000
commit267c6f2ac71f92999e969232431ba04678e7437e (patch)
tree358c9467650e1d0a1d7227a21dac2e3d08b622b2 /svx/qa/unit/XTableImportExportTest.cxx
parentInitial commit. (diff)
downloadlibreoffice-267c6f2ac71f92999e969232431ba04678e7437e.tar.xz
libreoffice-267c6f2ac71f92999e969232431ba04678e7437e.zip
Adding upstream version 4:24.2.0.upstream/4%24.2.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'svx/qa/unit/XTableImportExportTest.cxx')
-rw-r--r--svx/qa/unit/XTableImportExportTest.cxx80
1 files changed, 80 insertions, 0 deletions
diff --git a/svx/qa/unit/XTableImportExportTest.cxx b/svx/qa/unit/XTableImportExportTest.cxx
new file mode 100644
index 0000000000..cfab5c47c5
--- /dev/null
+++ b/svx/qa/unit/XTableImportExportTest.cxx
@@ -0,0 +1,80 @@
+/* -*- 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 <cppunit/TestAssert.h>
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+#include <unotest/bootstrapfixturebase.hxx>
+
+#include <sal/types.h>
+#include <sfx2/app.hxx>
+#include <unotools/tempfile.hxx>
+#include <svx/xtable.hxx>
+#include <vcl/bitmapex.hxx>
+
+#include <com/sun/star/awt/XBitmap.hpp>
+#include <com/sun/star/graphic/XGraphic.hpp>
+
+using namespace css;
+
+class XTableImportExportTest : public CppUnit::TestFixture
+{
+public:
+ virtual void setUp() override
+ {
+ CppUnit::TestFixture::setUp();
+ SfxApplication::GetOrCreate();
+ }
+};
+
+CPPUNIT_TEST_FIXTURE(XTableImportExportTest, testImportExport)
+{
+ utl::TempFileNamed aTempFile(nullptr, true);
+ aTempFile.EnableKillingFile();
+ OUString aTempURL = aTempFile.GetURL();
+ BitmapChecksum aChecksum(0);
+
+ {
+ rtl::Reference<XBitmapList> xBitmapList = new XBitmapList(aTempURL, "REF");
+ uno::Reference<container::XNameContainer> xNameContainer(xBitmapList->createInstance());
+ CPPUNIT_ASSERT(xNameContainer.is());
+
+ Bitmap aBitmap(Size(5, 5), vcl::PixelFormat::N24_BPP);
+ 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::Any(xBitmap));
+ xBitmapList->Save();
+
+ aChecksum = aBitmap.GetChecksum();
+ }
+
+ {
+ rtl::Reference<XBitmapList> xBitmapList = new XBitmapList(aTempURL, "REF");
+ bool bResult = xBitmapList->Load();
+ CPPUNIT_ASSERT(bResult);
+ 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.IsNone());
+ Bitmap aBitmap = aGraphic.GetBitmapEx().GetBitmap();
+ CPPUNIT_ASSERT_EQUAL(aChecksum, aBitmap.GetChecksum());
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */