/* -*- 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 class VclTextLayoutTest : public test::BootstrapFixture { public: VclTextLayoutTest() : BootstrapFixture(true, false) { } }; #if HAVE_MORE_FONTS CPPUNIT_TEST_FIXTURE(VclTextLayoutTest, testBreakLines_invalid_softbreak) { ScopedVclPtr device = VclPtr::Create(DeviceFormat::WITHOUT_ALPHA); device->SetOutputSizePixel(Size(1000, 1000)); device->SetFont(vcl::Font(u"DejaVu Sans"_ustr, u"Book"_ustr, Size(0, 11))); vcl::DefaultTextLayout aTextLayout(*device); const OUString sTestStr = u"textline_ text_"_ustr; const auto nTextWidth = device->GetTextWidth(u"text"_ustr); css::uno::Reference xHyph; css::uno::Reference xBI = vcl::unohelper::CreateBreakIterator(); // softbreak cannot be greater than the string length const auto nTextLen = 13; auto[nBreakPos, nLineWidth] = aTextLayout.BreakLine(nTextWidth, sTestStr, xHyph, xBI, false, nTextWidth, nTextLen, 15); const sal_Int32 nExpectedBreakPos = 13; CPPUNIT_ASSERT_EQUAL(nExpectedBreakPos, nBreakPos); } CPPUNIT_TEST_FIXTURE(VclTextLayoutTest, testBreakLines_hyphens) { ScopedVclPtr device = VclPtr::Create(DeviceFormat::WITHOUT_ALPHA); device->SetOutputSizePixel(Size(1000, 1000)); device->SetFont(vcl::Font(u"DejaVu Sans"_ustr, u"Book"_ustr, Size(0, 11))); vcl::DefaultTextLayout aTextLayout(*device); const OUString sTestStr = u"textline text-moretext"_ustr; const auto nTextWidth = device->GetTextWidth(u"textline text-moretex"_ustr); css::uno::Reference xContext( comphelper::getProcessComponentContext()); css::uno::Reference xLinguMgr = css::linguistic2::LinguServiceManager::create(xContext); css::uno::Reference xHyph = xLinguMgr->getHyphenator(); css::uno::Reference xBI = vcl::unohelper::CreateBreakIterator(); auto[nBreakPos, nLineWidth] = aTextLayout.BreakLine(nTextWidth, sTestStr, xHyph, xBI, true, nTextWidth, 13, 12); const sal_Int32 nExpectedBreakPos = 13; CPPUNIT_ASSERT_EQUAL(nExpectedBreakPos, nBreakPos); } CPPUNIT_TEST_FIXTURE(VclTextLayoutTest, testBreakLines_hyphen_word_under_two_chars) { ScopedVclPtr device = VclPtr::Create(DeviceFormat::WITHOUT_ALPHA); device->SetOutputSizePixel(Size(1000, 1000)); device->SetFont(vcl::Font(u"DejaVu Sans"_ustr, u"Book"_ustr, Size(0, 11))); vcl::DefaultTextLayout aTextLayout(*device); const OUString sTestStr = u"textline text-moretext"_ustr; const auto nTextWidth = device->GetTextWidth(u"te-moretex"_ustr); css::uno::Reference xContext( comphelper::getProcessComponentContext()); css::uno::Reference xLinguMgr = css::linguistic2::LinguServiceManager::create(xContext); css::uno::Reference xHyph = xLinguMgr->getHyphenator(); css::uno::Reference xBI = vcl::unohelper::CreateBreakIterator(); auto[nBreakPos, nLineWidth] = aTextLayout.BreakLine(nTextWidth, sTestStr, xHyph, xBI, true, nTextWidth, 2, 10); const sal_Int32 nExpectedBreakPos = 2; CPPUNIT_ASSERT_EQUAL(nExpectedBreakPos, nBreakPos); } #endif CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ stro/collabora/cp-6.0'>distro/collabora/cp-6.0 LibreOffice 核心代码仓库文档基金会
summaryrefslogtreecommitdiff
AgeCommit message (Expand)Author
2024-05-03makefile simplification: replace $(call gb_CustomTarget_get_workdir,foo)Christian Lohmaier