diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2020-08-19 15:22:20 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2020-08-19 21:47:13 +0200 |
commit | 8a07588cb648e26a3fc06643b0210fc75201afb8 (patch) | |
tree | 2a570aac0e7705d7c5e4aa218660d37c68e13b7e /sfx2/qa | |
parent | 3194632c7ce8fb1b21a7d59d92a1ffb0cdafc4ea (diff) |
sd signature line: preserve current page after signing
Once the user adds a visible signature to a PDF file, we reload the
document, so what you see on the screen matches what's in the file (and
you can add a next signature).
Make sure that in case the signature is not on the first page, the
current page state is preserved.
Change-Id: Ia1780ce5602ee350855b6dec8340a65e63bf2d4e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100999
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'sfx2/qa')
-rw-r--r-- | sfx2/qa/cppunit/data/reload-page.odg | bin | 0 -> 8824 bytes | |||
-rw-r--r-- | sfx2/qa/cppunit/view.cxx | 87 |
2 files changed, 87 insertions, 0 deletions
diff --git a/sfx2/qa/cppunit/data/reload-page.odg b/sfx2/qa/cppunit/data/reload-page.odg Binary files differnew file mode 100644 index 000000000000..0e9cf08649a0 --- /dev/null +++ b/sfx2/qa/cppunit/data/reload-page.odg diff --git a/sfx2/qa/cppunit/view.cxx b/sfx2/qa/cppunit/view.cxx new file mode 100644 index 000000000000..e5ce404c21e9 --- /dev/null +++ b/sfx2/qa/cppunit/view.cxx @@ -0,0 +1,87 @@ +/* -*- 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 <test/bootstrapfixture.hxx> +#include <unotest/macros_test.hxx> + +#include <com/sun/star/frame/Desktop.hpp> +#include <com/sun/star/embed/XStorage.hpp> +#include <com/sun/star/drawing/XDrawView.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> + +#include <sfx2/app.hxx> +#include <sfx2/sfxsids.hrc> +#include <sfx2/viewfrm.hxx> +#include <svl/itemset.hxx> +#include <svl/intitem.hxx> +#include <sfx2/request.hxx> +#include <sfx2/bindings.hxx> + +using namespace com::sun::star; + +char const DATA_DIRECTORY[] = "/sfx2/qa/cppunit/data/"; + +/// Covers sfx2/source/view/ fixes. +class Sfx2ViewTest : public test::BootstrapFixture, public unotest::MacrosTest +{ +private: + uno::Reference<lang::XComponent> mxComponent; + +public: + void setUp() override; + void tearDown() override; + uno::Reference<lang::XComponent>& getComponent() { return mxComponent; } +}; + +void Sfx2ViewTest::setUp() +{ + test::BootstrapFixture::setUp(); + + mxDesktop.set(frame::Desktop::create(mxComponentContext)); +} + +void Sfx2ViewTest::tearDown() +{ + if (mxComponent.is()) + mxComponent->dispose(); + + test::BootstrapFixture::tearDown(); +} + +CPPUNIT_TEST_FIXTURE(Sfx2ViewTest, testReloadPage) +{ + // Load a document, which has 2 pages. + OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "reload-page.odg"; + getComponent() = loadFromDesktop(aURL); + + // Reload, and request to start on page 2. + SfxViewFrame* pFrame = SfxViewFrame::Current(); + SfxAllItemSet aSet(SfxGetpApp()->GetPool()); + aSet.Put(SfxInt32Item(SID_PAGE_NUMBER, 1)); + SfxRequest aReq(SID_RELOAD, SfxCallMode::SLOT, aSet); + pFrame->ExecReload_Impl(aReq); + uno::Reference<frame::XModel> xModel = SfxObjectShell::Current()->GetBaseModel(); + getComponent() = xModel; + + // Check the current page after reload. + uno::Reference<drawing::XDrawView> xController(xModel->getCurrentController(), uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xPage(xController->getCurrentPage(), uno::UNO_QUERY); + sal_Int32 nPage{}; + xPage->getPropertyValue("Number") >>= nPage; + + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 2 + // - Actual : 1 + // i.e. the document was opened on page 1, not page 2, SID_PAGE_NUMBER was ignored. + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2), nPage); +} + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |