/* -*- 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/. * * 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 . */ #pragma once #include #include #include #include #include #include #include class Control; namespace vcl { class VCL_DLLPUBLIC TextLayoutCommon { public: virtual tools::Long GetTextWidth( const OUString& _rText, sal_Int32 _nStartIndex, sal_Int32 _nLength ) const = 0; virtual void DrawText( const Point& _rStartPoint, const OUString& _rText, sal_Int32 _nStartIndex, sal_Int32 _nLength, std::vector< tools::Rectangle >* _pVector, OUString* _pDisplayText ) = 0; virtual tools::Long GetTextArray( const OUString& _rText, KernArray* _pDXArray, sal_Int32 _nStartIndex, sal_Int32 _nLength, bool bCaret = false ) const = 0; virtual sal_Int32 GetTextBreak( const OUString& _rText, tools::Long _nMaxTextWidth, sal_Int32 _nStartIndex, sal_Int32 _nLength ) const = 0; virtual bool DecomposeTextRectAction() const = 0; SAL_DLLPRIVATE OUString GetEllipsisString(OUString const& rOrigStr, tools::Long nMaxWidth, DrawTextFlags nStyle); std::tuple BreakLine(const tools::Long nWidth, OUString const& rStr, css::uno::Reference< css::linguistic2::XHyphenator > const& xHyph, css::uno::Reference& xBI, const bool bHyphenate, const tools::Long nOrigLineWidth, const sal_Int32 nPos, const sal_Int32 nLen); SAL_DLLPRIVATE std::tuple BreakLineSimple(const tools::Long nWidth, OUString const& rStr, const sal_Int32 nPos, sal_Int32 nBreakPos, const tools::Long nOrigLineWidth); SAL_DLLPRIVATE tools::Long GetTextLines(tools::Rectangle const& rRect, const tools::Long nTextHeight, ImplMultiTextLineInfo& rLineInfo, tools::Long nWidth, OUString const& rStr, DrawTextFlags nStyle); protected: SAL_DLLPRIVATE ~TextLayoutCommon() COVERITY_NOEXCEPT_FALSE; private: SAL_DLLPRIVATE OUString GetCenterEllipsisString(std::u16string_view rOrigStr, sal_Int32 nIndex, tools::Long nMaxWidth); SAL_DLLPRIVATE OUString GetEndEllipsisString(OUString const& rOrigStr, sal_Int32 nIndex, tools::Long nMaxWidth, bool bClipText); SAL_DLLPRIVATE OUString GetNewsEllipsisString(OUString const& rOrigStr, tools::Long nMaxWidth, DrawTextFlags nStyle); }; /** is an implementation of TextLayoutCommon which simply delegates its calls to the respective methods of an OutputDevice instance, without any inbetween magic. */ class VCL_DLLPUBLIC DefaultTextLayout final : public TextLayoutCommon { public: DefaultTextLayout( OutputDevice& _rTargetDevice ) : m_rTargetDevice( _rTargetDevice ) { } virtual ~DefaultTextLayout(); // TextLayoutCommon overridables SAL_DLLPRIVATE virtual tools::Long GetTextWidth( const OUString& _rText, sal_Int32 _nStartIndex, sal_Int32 _nLength ) const override; virtual void DrawText( const Point& _rStartPoint, const OUString& _rText, sal_Int32 _nStartIndex, sal_Int32 _nLength, std::vector< tools::Rectangle >* _pVector, OUString* _pDisplayText ) override; SAL_DLLPRIVATE virtual tools::Long GetTextArray( const OUString& _rText, KernArray* _pDXArray, sal_Int32 _nStartIndex, sal_Int32 _nLength, bool bCaret = false ) const override; SAL_DLLPRIVATE virtual sal_Int32 GetTextBreak( const OUString& _rText, tools::Long _nMaxTextWidth, sal_Int32 _nStartIndex, sal_Int32 _nLength ) const override; SAL_DLLPRIVATE virtual bool DecomposeTextRectAction() const override; private: OutputDevice& m_rTargetDevice; }; class ReferenceDeviceTextLayout; /** a class which allows rendering text of a Control onto a device, by taking into account the metrics of a reference device. */ class ControlTextRenderer final { public: ControlTextRenderer( const Control& _rControl, OutputDevice& _rTargetDevice, OutputDevice& _rReferenceDevice ); ~ControlTextRenderer(); tools::Rectangle DrawText( const tools::Rectangle& _rRect, const OUString& _rText, DrawTextFlags _nStyle, std::vector< tools::Rectangle >* _pVector, OUString* _pDisplayText, const Size* i_pDeviceSize ); tools::Rectangle GetTextRect( const tools::Rectangle& _rRect, const OUString& _rText, DrawTextFlags _nStyle, Size* o_pDeviceSize ); private: ControlTextRenderer( const ControlTextRenderer& ) = delete; ControlTextRenderer& operator=( const ControlTextRenderer& ) = delete; private: ::std::unique_ptr< ReferenceDeviceTextLayout > m_pImpl; }; } // namespace vcl /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -7-2+backports'>distro/lhm/libreoffice-7-2+backports LibreOffice 核心代码仓库文档基金会
summaryrefslogtreecommitdiff
AgeCommit message (Expand)Author
2022-05-20new loplugin:unnecessary lockingNoel Grandin
2022-05-18tdf#105972: pdf form: export date fields as date typeXisco Fauli
2022-05-18tdf#105972: pdf form: export time fields as time typeXisco Fauli
2022-05-17tdf#105972: pdf form: export numeric and currency fields as number typeXisco Fauli
2022-05-13tdf#148706: map value prop in numericfield to textXisco Fauli
2022-05-12tdf#143612: map SecondaryRefValue in form pdf exportXisco Fauli
2022-05-12related: tdf#148442: do not replace 'Yes' if onValue is emptyXisco Fauli
2022-05-11tdf#148442: map RefValue property to onValue in pdfXisco Fauli
2022-05-05use more o3tl::getTokenNoel Grandin
2022-05-03Use o3tl::make_unsigned in some placesStephan Bergmann
2022-05-03Just use Any ctor instead of makeAny in toolkitStephan Bergmann
2022-04-20loplugin:passstuffbyrefNoel Grandin
2022-04-11loplugin:stringview add check for getToken().toInt32Noel Grandin
2022-04-02Recheck modules t* with IWYUGabor Kelemen
2022-03-28Operate on VCL Menu with SolarMutex lockedStephan Bergmann
2022-03-05GetComponentServiceName can be constNoel Grandin
2022-02-22Add XWeak constructor and operator= to uno::WeakReferenceNoel Grandin
2022-02-09expand out IMPLEMENT_FORWARD_XTYPEPROVIDER3Noel Grandin
2022-01-20WASM --enable-wasm-strip now skips lots of LO codeArmin Le Grand (Allotropia)
2022-01-14make comphelper::OInterfaceContainerHelper4 more threadsafeNoel Grandin
2022-01-14no need to hold OInterfaceContainerHelper4 by unique_ptrNoel Grandin
2022-01-08Fix buildMike Kaganski
2022-01-08move UserData bodge into VCLXMenuCaolán McNamara
2021-12-27osl::Mutex->std::mutex in ODocumentCloserNoel Grandin
2021-12-27use comphelper::WeakComponentImplHelper in GridColumnNoel Grandin
2021-12-18use more cppu::BaseMutexNoel Grandin
2021-12-18tdf#146286 Crash/hang calling context menuNoel Grandin
2021-12-17osl::Mutex->std::mutex in VCLXMenuNoel Grandin
2021-12-17osl::Mutex->std::mutex in VCLXFontNoel Grandin
2021-12-16use more OInterfaceContainerHelper3 in toolkitCaolán McNamara
2021-11-29use more XPopupMenu methods over PopupMenu onesCaolán McNamara
2021-11-29move PopupMenu::IsInExecute out of vcl/include/menu.hxxCaolán McNamara
2021-11-28use more OInterfaceContainerHelper3 in toolkitNoel Grandin