From 96baf8c69330d50af7d31ab9838bcd0ec7c8c50b Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Tue, 19 May 2020 21:03:02 +0200 Subject: tdf#130479 FODG import: fix handling of in styles Regression from the image handling rework, the problem was that the old, URL-based code had explicit handling of mxBase64Stream, while the new, XGraphic-based code assumed that by the time we reach the end of of the bitmap style element, maAny already contains the graphic. Fix the problem by improving XMLBitmapStyleContext::EndElement(), so it loads the graphic from the base64 stream if we don't have a graphic already. Change-Id: I6d90f1470a5b797fb51789901081ccd7a6fd29e7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94548 Tested-by: Jenkins Reviewed-by: Miklos Vajna --- xmloff/qa/unit/data/fill-image-base64.fodg | 230 +++++++++++++++++++++++++++++ xmloff/qa/unit/style.cxx | 76 ++++++++++ 2 files changed, 306 insertions(+) create mode 100644 xmloff/qa/unit/data/fill-image-base64.fodg create mode 100644 xmloff/qa/unit/style.cxx (limited to 'xmloff/qa') diff --git a/xmloff/qa/unit/data/fill-image-base64.fodg b/xmloff/qa/unit/data/fill-image-base64.fodg new file mode 100644 index 000000000000..ce0df9d1dd2f --- /dev/null +++ b/xmloff/qa/unit/data/fill-image-base64.fodg @@ -0,0 +1,230 @@ + + + + + + + + + + + + + + + + + + + + + + + + + iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAQAAAAAYLlVAAAABGdBTUEAALGPC/xhBQAAAAFz + UkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAA + AAJiS0dEAACqjSMyAAAACW9GRnMAAAAGAAAAAAAMc1XTAAAACXBIWXMAAA3XAAAN1wFCKJt4 + AAAACXZwQWcAAABMAAAAQACdMTgbAAABzUlEQVRo3u3ZPU/CQBjA8X+Jxs3ESUDj4iK+LA5+ + BBfjqBE1cXB2MlFAEqMgxvhNNL4sLsK3UPQL6ObkoAETz+FKW2mxCPRYnucWUu76/OC59C49 + cGOCKqrD9kHRc6ddPv7oW2WCwMh0nF63Myz7Tm8hPTNu0pgHMER3scepTbgK6enJNND83RLn + /878yRaPmgBZFDuMsNLeWB9gmFQHP77MIg9gsYciR50NFKvtjIy10yk84pSZA7DYpwR8scmF + QQCMuoQMpzbh0iAARrlnVn90CWHTsZcAiHPPdINQAuqsc2MQAAnKDUKWEhZ10twaBEDSJWQo + YlFj7S9CzwEegkXWIbQsRAQASFJhpplwbRAACS+hANRJBxMiAkDcJeQ4sQkBhYgMoJ+Ozlwo + 2YQ7AJ6CRxyiUGnVy3hVKb0Af9v7hUG2Wy9TEQCUelFTDULB2S+YKYGOMcpM6UIccOQnRA6A + cSp6ibfI+wkGADBGpTEd8xz1AaAfTQ7huA8AvUw5hVjuA0D/C5OaMN8XACRZ8F0zCggKAQhA + AAIQgAAEIAABCEAAAhCAAAQgAAH4zg3feY4w3Xs44M5+oW0qvCWoGcvaIlM3x/f/ab+O738A + hOCNQr34oD4AAAAldEVYdGNyZWF0ZS1kYXRlADIwMTAtMTItMjBUMTc6MDg6MzYrMDE6MDB6 + 5RscAAAAJXRFWHRtb2RpZnktZGF0ZQAyMDEwLTEyLTIwVDE3OjA4OjM3KzAxOjAwgyNmnAAA + AABJRU5ErkJggg== + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xmloff/qa/unit/style.cxx b/xmloff/qa/unit/style.cxx new file mode 100644 index 000000000000..0cb37346cc92 --- /dev/null +++ b/xmloff/qa/unit/style.cxx @@ -0,0 +1,76 @@ +/* -*- 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 +#include + +#include +#include +#include + +#include +#include +#include +#include +#include + +using namespace ::com::sun::star; + +char const DATA_DIRECTORY[] = "/xmloff/qa/unit/data/"; + +/// Covers xmloff/source/style/ fixes. +class XmloffStyleTest : public test::BootstrapFixture, public unotest::MacrosTest +{ +private: + uno::Reference mxComponent; + +public: + void setUp() override; + void tearDown() override; + uno::Reference& getComponent() { return mxComponent; } + void load(const OUString& rURL); +}; + +void XmloffStyleTest::setUp() +{ + test::BootstrapFixture::setUp(); + + mxDesktop.set(frame::Desktop::create(mxComponentContext)); +} + +void XmloffStyleTest::tearDown() +{ + if (mxComponent.is()) + mxComponent->dispose(); + + test::BootstrapFixture::tearDown(); +} + +void XmloffStyleTest::load(const OUString& rFileName) +{ + OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + rFileName; + mxComponent = loadFromDesktop(aURL); +} + +CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testFillImageBase64) +{ + // Load a flat ODG that has base64-encoded bitmap as a fill style. + load("fill-image-base64.fodg"); + uno::Reference xFactory(getComponent(), uno::UNO_QUERY); + uno::Reference xBitmaps( + xFactory->createInstance("com.sun.star.drawing.BitmapTable"), uno::UNO_QUERY); + + // Without the accompanying fix in place, this test would have failed, as the base64 stream was + // not considered when parsing the fill-image style. + CPPUNIT_ASSERT(xBitmaps->hasByName("libreoffice_0")); +} + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit