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
24 #include <rtl/ustring.hxx>
25 #include <vcl/outdev.hxx>
31 class SAL_NO_VTABLE ITextLayout
34 virtual long GetTextWidth( const OUString
& _rText
, sal_Int32 _nStartIndex
, sal_Int32 _nLength
) const = 0;
35 virtual void DrawText( const Point
& _rStartPoint
, const OUString
& _rText
, sal_Int32 _nStartIndex
, sal_Int32 _nLength
,
36 MetricVector
* _pVector
, OUString
* _pDisplayText
) = 0;
37 virtual bool GetCaretPositions( const OUString
& _rText
, long* _pCaretXArray
, sal_Int32 _nStartIndex
, sal_Int32 _nLength
) const = 0;
38 virtual sal_Int32
GetTextBreak( const OUString
& _rText
, long _nMaxTextWidth
, sal_Int32 _nStartIndex
, sal_Int32 _nLength
) const = 0;
39 virtual bool DecomposeTextRectAction() const = 0;
45 /** is an implementation of the ITextLayout interface which simply delegates its calls to the respective
46 methods of an OutputDevice instance, without any inbetween magic.
48 class DefaultTextLayout
: public ITextLayout
51 DefaultTextLayout( OutputDevice
& _rTargetDevice
)
52 : m_rTargetDevice( _rTargetDevice
)
55 virtual ~DefaultTextLayout();
57 // ITextLayout overridables
58 virtual long GetTextWidth( const OUString
& _rText
,
59 sal_Int32 _nStartIndex
,
60 sal_Int32 _nLength
) const SAL_OVERRIDE
;
62 virtual void DrawText( const Point
& _rStartPoint
,
63 const OUString
& _rText
,
64 sal_Int32 _nStartIndex
,
66 MetricVector
* _pVector
,
67 OUString
* _pDisplayText
) SAL_OVERRIDE
;
69 virtual bool GetCaretPositions( const OUString
& _rText
,
71 sal_Int32 _nStartIndex
,
72 sal_Int32 _nLength
) const SAL_OVERRIDE
;
74 virtual sal_Int32
GetTextBreak( const OUString
& _rText
,
76 sal_Int32 _nStartIndex
,
77 sal_Int32 _nLength
) const SAL_OVERRIDE
;
79 virtual bool DecomposeTextRectAction() const SAL_OVERRIDE
;
82 OutputDevice
& m_rTargetDevice
;
85 class ReferenceDeviceTextLayout
;
86 /** a class which allows rendering text of a Control onto a device, by taking into account the metrics of
89 class ControlTextRenderer
92 ControlTextRenderer( const Control
& _rControl
, OutputDevice
& _rTargetDevice
, OutputDevice
& _rReferenceDevice
);
93 virtual ~ControlTextRenderer();
95 Rectangle
DrawText( const Rectangle
& _rRect
,
96 const OUString
& _rText
, DrawTextFlags _nStyle
= DrawTextFlags::NONE
,
97 MetricVector
* _pVector
= NULL
, OUString
* _pDisplayText
= NULL
);
100 ControlTextRenderer( const ControlTextRenderer
& ) SAL_DELETED_FUNCTION
;
101 ControlTextRenderer
& operator=( const ControlTextRenderer
& ) SAL_DELETED_FUNCTION
;
104 ::std::unique_ptr
< ReferenceDeviceTextLayout
> m_pImpl
;
109 #endif // INCLUDED_VCL_INC_TEXTLAYOUT_HXX
111 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */