1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_VCL_INC_TEXTLAYOUT_HXX
21 #define INCLUDED_VCL_INC_TEXTLAYOUT_HXX
29 class SAL_NO_VTABLE ITextLayout
32 virtual tools::Long
GetTextWidth( const OUString
& _rText
, sal_Int32 _nStartIndex
, sal_Int32 _nLength
) const = 0;
33 virtual void DrawText( const Point
& _rStartPoint
, const OUString
& _rText
, sal_Int32 _nStartIndex
, sal_Int32 _nLength
,
34 std::vector
< tools::Rectangle
>* _pVector
, OUString
* _pDisplayText
) = 0;
35 virtual void GetCaretPositions( const OUString
& _rText
, tools::Long
* _pCaretXArray
, sal_Int32 _nStartIndex
, sal_Int32 _nLength
) const = 0;
36 virtual sal_Int32
GetTextBreak( const OUString
& _rText
, tools::Long _nMaxTextWidth
, sal_Int32 _nStartIndex
, sal_Int32 _nLength
) const = 0;
37 virtual bool DecomposeTextRectAction() const = 0;
40 ~ITextLayout() COVERITY_NOEXCEPT_FALSE
{}
43 /** is an implementation of the ITextLayout interface which simply delegates its calls to the respective
44 methods of an OutputDevice instance, without any inbetween magic.
46 class DefaultTextLayout final
: public ITextLayout
49 DefaultTextLayout( OutputDevice
& _rTargetDevice
)
50 : m_rTargetDevice( _rTargetDevice
)
53 virtual ~DefaultTextLayout();
55 // ITextLayout overridables
56 virtual tools::Long
GetTextWidth( const OUString
& _rText
,
57 sal_Int32 _nStartIndex
,
58 sal_Int32 _nLength
) const override
;
60 virtual void DrawText( const Point
& _rStartPoint
,
61 const OUString
& _rText
,
62 sal_Int32 _nStartIndex
,
64 std::vector
< tools::Rectangle
>* _pVector
,
65 OUString
* _pDisplayText
) override
;
67 virtual void GetCaretPositions( const OUString
& _rText
,
68 tools::Long
* _pCaretXArray
,
69 sal_Int32 _nStartIndex
,
70 sal_Int32 _nLength
) const override
;
72 virtual sal_Int32
GetTextBreak( const OUString
& _rText
,
73 tools::Long _nMaxTextWidth
,
74 sal_Int32 _nStartIndex
,
75 sal_Int32 _nLength
) const override
;
77 virtual bool DecomposeTextRectAction() const override
;
80 OutputDevice
& m_rTargetDevice
;
83 class ReferenceDeviceTextLayout
;
84 /** a class which allows rendering text of a Control onto a device, by taking into account the metrics of
87 class ControlTextRenderer final
90 ControlTextRenderer( const Control
& _rControl
, OutputDevice
& _rTargetDevice
, OutputDevice
& _rReferenceDevice
);
91 ~ControlTextRenderer();
93 tools::Rectangle
DrawText( const tools::Rectangle
& _rRect
,
94 const OUString
& _rText
, DrawTextFlags _nStyle
,
95 std::vector
< tools::Rectangle
>* _pVector
, OUString
* _pDisplayText
, const Size
* i_pDeviceSize
);
97 tools::Rectangle
GetTextRect( const tools::Rectangle
& _rRect
,
98 const OUString
& _rText
, DrawTextFlags _nStyle
, Size
* o_pDeviceSize
);
101 ControlTextRenderer( const ControlTextRenderer
& ) = delete;
102 ControlTextRenderer
& operator=( const ControlTextRenderer
& ) = delete;
105 ::std::unique_ptr
< ReferenceDeviceTextLayout
> m_pImpl
;
110 #endif // INCLUDED_VCL_INC_TEXTLAYOUT_HXX
112 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */