diff options
author | Chris Sherlock <chris.sherlock79@gmail.com> | 2021-08-29 00:59:08 +1000 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2021-08-30 02:46:33 +0200 |
commit | 229136b7c9363bc758c9e925ccfd0c9bb34ceaec (patch) | |
tree | b5d2546256a9bb0e8740d242cce5e3c0cd3ee332 /vcl/source | |
parent | d350a1364a1c34b96d00f2f716c44882b7b57fe9 (diff) |
vcl: move TextLayoutCache into vcl::text namespace
Placed TextLayoutCache function into own source file and moved it into
the new vcl::text namespace. With this patch we will have these vcl::*
namespaces:
namespace vcl::bitmap
namespace vcl::CommandInfoProvider
namespace vcl::detail
namespace vcl::drawmode
namespace vcl::fileregistration
namespace vcl::filter
namespace vcl::font
namespace vcl::graphic
namespace vcl::lok
namespace vcl::pdf
namespace vcl::table
namespace vcl::test
namespace vcl::text
namespace vcl::unohelper
namespace vcl::unotools
Change-Id: Ia38c2d73715676a924cdbb0de6308a72a40ec3b3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121206
Reviewed-by: Hossein <hossein@libreoffice.org>
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Tested-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'vcl/source')
-rw-r--r-- | vcl/source/gdi/CommonSalLayout.cxx | 12 | ||||
-rw-r--r-- | vcl/source/gdi/sallayout.cxx | 2 | ||||
-rw-r--r-- | vcl/source/outdev/text.cxx | 14 | ||||
-rw-r--r-- | vcl/source/text/TextLayoutCache.cxx | 36 | ||||
-rw-r--r-- | vcl/source/window/window3.cxx | 2 |
5 files changed, 51 insertions, 15 deletions
diff --git a/vcl/source/gdi/CommonSalLayout.cxx b/vcl/source/gdi/CommonSalLayout.cxx index 4adf864a933b..b2d332c82958 100644 --- a/vcl/source/gdi/CommonSalLayout.cxx +++ b/vcl/source/gdi/CommonSalLayout.cxx @@ -150,9 +150,9 @@ namespace { } // namespace -std::shared_ptr<vcl::TextLayoutCache> GenericSalLayout::CreateTextLayoutCache(OUString const& rString) +std::shared_ptr<vcl::text::TextLayoutCache> GenericSalLayout::CreateTextLayoutCache(OUString const& rString) { - return std::make_shared<vcl::TextLayoutCache>(rString.getStr(), rString.getLength()); + return std::make_shared<vcl::text::TextLayoutCache>(rString.getStr(), rString.getLength()); } SalLayoutGlyphs GenericSalLayout::GetGlyphs() const @@ -278,15 +278,15 @@ bool GenericSalLayout::LayoutText(ImplLayoutArgs& rArgs, const SalLayoutGlyphsIm const int nLength = rArgs.mrStr.getLength(); const sal_Unicode *pStr = rArgs.mrStr.getStr(); - std::unique_ptr<vcl::TextLayoutCache> pNewScriptRun; - vcl::TextLayoutCache const* pTextLayout; + std::unique_ptr<vcl::text::TextLayoutCache> pNewScriptRun; + vcl::text::TextLayoutCache const* pTextLayout; if (rArgs.m_pTextLayoutCache) { pTextLayout = rArgs.m_pTextLayoutCache; // use cache! } else { - pNewScriptRun.reset(new vcl::TextLayoutCache(pStr, rArgs.mnEndCharPos)); + pNewScriptRun.reset(new vcl::text::TextLayoutCache(pStr, rArgs.mnEndCharPos)); pTextLayout = pNewScriptRun.get(); } @@ -342,7 +342,7 @@ bool GenericSalLayout::LayoutText(ImplLayoutArgs& rArgs, const SalLayoutGlyphsIm size_t k = 0; for (; k < pTextLayout->runs.size(); ++k) { - vcl::Run const& rRun(pTextLayout->runs[k]); + vcl::text::Run const& rRun(pTextLayout->runs[k]); if (rRun.nStart <= nCurrentPos && nCurrentPos < rRun.nEnd) { break; diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx index 7b8f2c2a2a05..a993b8131ca4 100644 --- a/vcl/source/gdi/sallayout.cxx +++ b/vcl/source/gdi/sallayout.cxx @@ -387,7 +387,7 @@ bool ImplLayoutRuns::GetRun( int* nMinRunPos, int* nEndRunPos, bool* bRightToLef ImplLayoutArgs::ImplLayoutArgs(const OUString& rStr, int nMinCharPos, int nEndCharPos, SalLayoutFlags nFlags, const LanguageTag& rLanguageTag, - vcl::TextLayoutCache const*const pLayoutCache) + vcl::text::TextLayoutCache const*const pLayoutCache) : maLanguageTag( rLanguageTag ), mnFlags( nFlags ), diff --git a/vcl/source/outdev/text.cxx b/vcl/source/outdev/text.cxx index d4d73d817654..b8cc324e14e9 100644 --- a/vcl/source/outdev/text.cxx +++ b/vcl/source/outdev/text.cxx @@ -836,7 +836,7 @@ void OutputDevice::DrawText( const Point& rStartPt, const OUString& rStr, } tools::Long OutputDevice::GetTextWidth( const OUString& rStr, sal_Int32 nIndex, sal_Int32 nLen, - vcl::TextLayoutCache const*const pLayoutCache, + vcl::text::TextLayoutCache const*const pLayoutCache, SalLayoutGlyphs const*const pSalLayoutCache) const { @@ -908,7 +908,7 @@ void OutputDevice::DrawTextArray( const Point& rStartPt, const OUString& rStr, tools::Long OutputDevice::GetTextArray( const OUString& rStr, tools::Long* pDXAry, sal_Int32 nIndex, sal_Int32 nLen, - vcl::TextLayoutCache const*const pLayoutCache, + vcl::text::TextLayoutCache const*const pLayoutCache, SalLayoutGlyphs const*const pSalLayoutCache) const { if( nIndex >= rStr.getLength() ) @@ -1101,7 +1101,7 @@ ImplLayoutArgs OutputDevice::ImplPrepareLayoutArgs( OUString& rStr, const sal_Int32 nMinIndex, const sal_Int32 nLen, DeviceCoordinate nPixelWidth, const DeviceCoordinate* pDXArray, SalLayoutFlags nLayoutFlags, - vcl::TextLayoutCache const*const pLayoutCache) const + vcl::text::TextLayoutCache const*const pLayoutCache) const { assert(nMinIndex >= 0); assert(nLen >= 0); @@ -1201,7 +1201,7 @@ std::unique_ptr<SalLayout> OutputDevice::ImplLayout(const OUString& rOrigStr, sal_Int32 nMinIndex, sal_Int32 nLen, const Point& rLogicalPos, tools::Long nLogicalWidth, const tools::Long* pDXArray, SalLayoutFlags flags, - vcl::TextLayoutCache const* pLayoutCache, + vcl::text::TextLayoutCache const* pLayoutCache, const SalLayoutGlyphs* pGlyphs) const { if (pGlyphs && !pGlyphs->IsValid()) @@ -1313,7 +1313,7 @@ std::unique_ptr<SalLayout> OutputDevice::ImplLayout(const OUString& rOrigStr, return pSalLayout; } -std::shared_ptr<vcl::TextLayoutCache> OutputDevice::CreateTextLayoutCache( +std::shared_ptr<vcl::text::TextLayoutCache> OutputDevice::CreateTextLayoutCache( OUString const& rString) { return GenericSalLayout::CreateTextLayoutCache(rString); @@ -1333,7 +1333,7 @@ bool OutputDevice::GetTextIsRTL( const OUString& rString, sal_Int32 nIndex, sal_ sal_Int32 OutputDevice::GetTextBreak( const OUString& rStr, tools::Long nTextWidth, sal_Int32 nIndex, sal_Int32 nLen, tools::Long nCharExtra, - vcl::TextLayoutCache const*const pLayoutCache, + vcl::text::TextLayoutCache const*const pLayoutCache, const SalLayoutGlyphs* pGlyphs) const { std::unique_ptr<SalLayout> pSalLayout = ImplLayout( rStr, nIndex, nLen, @@ -1365,7 +1365,7 @@ sal_Int32 OutputDevice::GetTextBreak( const OUString& rStr, tools::Long nTextWid sal_Unicode nHyphenChar, sal_Int32& rHyphenPos, sal_Int32 nIndex, sal_Int32 nLen, tools::Long nCharExtra, - vcl::TextLayoutCache const*const pLayoutCache) const + vcl::text::TextLayoutCache const*const pLayoutCache) const { rHyphenPos = -1; diff --git a/vcl/source/text/TextLayoutCache.cxx b/vcl/source/text/TextLayoutCache.cxx new file mode 100644 index 000000000000..00e9f9405358 --- /dev/null +++ b/vcl/source/text/TextLayoutCache.cxx @@ -0,0 +1,36 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <scrptrun.h> +#include <TextLayoutCache.hxx> + +namespace vcl::text +{ +TextLayoutCache::TextLayoutCache(sal_Unicode const* pStr, sal_Int32 const nEnd) +{ + vcl::ScriptRun aScriptRun(reinterpret_cast<const UChar*>(pStr), nEnd); + while (aScriptRun.next()) + { + runs.emplace_back(aScriptRun.getScriptStart(), aScriptRun.getScriptEnd(), + aScriptRun.getScriptCode()); + } +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/vcl/source/window/window3.cxx b/vcl/source/window/window3.cxx index 371b4066ed19..5b8dd5cff4ec 100644 --- a/vcl/source/window/window3.cxx +++ b/vcl/source/window/window3.cxx @@ -64,7 +64,7 @@ const Wallpaper& Window::GetBackground() const { return GetOutDev()->GetBackgrou bool Window::IsBackground() const { return GetOutDev()->IsBackground(); } tools::Long Window::GetTextHeight() const { return GetOutDev()->GetTextHeight(); } tools::Long Window::GetTextWidth(const OUString& rStr, sal_Int32 nIndex, sal_Int32 nLen, - vcl::TextLayoutCache const* pCache, + vcl::text::TextLayoutCache const* pCache, SalLayoutGlyphs const* const pLayoutCache) const { return GetOutDev()->GetTextWidth(rStr, nIndex, nLen, pCache, pLayoutCache); |