diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2020-05-07 22:01:22 +0200 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2020-06-01 10:43:46 +0200 |
commit | efba780d6155317b592b6f5f73945a7851ec4d3b (patch) | |
tree | 94c513fa2d639fc9f9fff7cabb9a974501694424 /vcl/qa | |
parent | 1ee221ad65ff5e3a725e80777406ac7f94ff3a72 (diff) |
vcl: VectorGraphicSearch - for searching text inside PDF
Change-Id: Iee940a3927330c8739774ff3c1af15998f89193b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95254
Tested-by: Tomaž Vajngerl <quikee@gmail.com>
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'vcl/qa')
-rw-r--r-- | vcl/qa/cppunit/VectorGraphicSearchTest.cxx | 50 | ||||
-rw-r--r-- | vcl/qa/cppunit/data/Pangram.pdf | bin | 0 -> 16880 bytes |
2 files changed, 50 insertions, 0 deletions
diff --git a/vcl/qa/cppunit/VectorGraphicSearchTest.cxx b/vcl/qa/cppunit/VectorGraphicSearchTest.cxx new file mode 100644 index 000000000000..0ed21ccf9e26 --- /dev/null +++ b/vcl/qa/cppunit/VectorGraphicSearchTest.cxx @@ -0,0 +1,50 @@ +/* -*- 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/extensions/HelperMacros.h> +#include <unotest/bootstrapfixturebase.hxx> +#include <unotest/directories.hxx> + +#include <vcl/VectorGraphicSearch.hxx> +#include <vcl/graph.hxx> +#include <vcl/graphicfilter.hxx> +#include <tools/stream.hxx> + +class VectorGraphicSearchTest : public test::BootstrapFixtureBase +{ + OUString getFullUrl(const OUString& sFileName) + { + return m_directories.getURLFromSrc("/vcl/qa/cppunit/data/") + sFileName; + } + + void test(); + + CPPUNIT_TEST_SUITE(VectorGraphicSearchTest); + CPPUNIT_TEST(test); + CPPUNIT_TEST_SUITE_END(); +}; + +void VectorGraphicSearchTest::test() +{ + OUString aURL = getFullUrl("Pangram.pdf"); + SvFileStream aStream(aURL, StreamMode::READ); + GraphicFilter& rGraphicFilter = GraphicFilter::GetGraphicFilter(); + Graphic aGraphic = rGraphicFilter.ImportUnloadedGraphic(aStream); + aGraphic.makeAvailable(); + + VectorGraphicSearch aSearch(aGraphic); + CPPUNIT_ASSERT_EQUAL(true, aSearch.search("lazy")); + CPPUNIT_ASSERT_EQUAL(true, aSearch.next()); + CPPUNIT_ASSERT_EQUAL(34, aSearch.index()); +} + +CPPUNIT_TEST_SUITE_REGISTRATION(VectorGraphicSearchTest); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/qa/cppunit/data/Pangram.pdf b/vcl/qa/cppunit/data/Pangram.pdf Binary files differnew file mode 100644 index 000000000000..0714fda4e4dd --- /dev/null +++ b/vcl/qa/cppunit/data/Pangram.pdf |