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 VCL_TEXTLAYOUT_HXX
21 #define VCL_TEXTLAYOUT_HXX
23 #include "vcl/outdev.hxx"
25 #include <tools/solar.h>
26 #include <tools/string.hxx>
32 //........................................................................
35 //........................................................................
37 //====================================================================
39 //====================================================================
40 class SAL_NO_VTABLE ITextLayout
43 virtual long GetTextWidth( const OUString
& _rText
, sal_Int32 _nStartIndex
, sal_Int32 _nLength
) const = 0;
44 virtual void DrawText( const Point
& _rStartPoint
, const OUString
& _rText
, sal_Int32 _nStartIndex
, sal_Int32 _nLength
,
45 MetricVector
* _pVector
, OUString
* _pDisplayText
) = 0;
46 virtual bool GetCaretPositions( const OUString
& _rText
, sal_Int32
* _pCaretXArray
, sal_Int32 _nStartIndex
, sal_Int32 _nLength
) const = 0;
47 virtual xub_StrLen
GetTextBreak( const OUString
& _rText
, long _nMaxTextWidth
, sal_Int32 _nStartIndex
, sal_Int32 _nLength
) const = 0;
48 virtual bool DecomposeTextRectAction() const = 0;
54 //====================================================================
56 //====================================================================
57 /** is an implementation of the ITextLayout interface which simply delegates its calls to the respective
58 methods of an OutputDevice instance, without any inbetween magic.
60 class DefaultTextLayout
: public ITextLayout
63 DefaultTextLayout( OutputDevice
& _rTargetDevice
)
64 :m_rTargetDevice( _rTargetDevice
)
67 virtual ~DefaultTextLayout();
69 // ITextLayout overridables
70 virtual long GetTextWidth(
71 const OUString
& _rText
,
72 sal_Int32 _nStartIndex
,
75 virtual void DrawText(
76 const Point
& _rStartPoint
,
77 const OUString
& _rText
,
78 sal_Int32 _nStartIndex
,
80 MetricVector
* _pVector
,
81 OUString
* _pDisplayText
83 virtual bool GetCaretPositions(
84 const OUString
& _rText
,
85 sal_Int32
* _pCaretXArray
,
86 sal_Int32 _nStartIndex
,
89 virtual xub_StrLen
GetTextBreak(
90 const OUString
& _rText
,
92 sal_Int32 _nStartIndex
,
95 virtual bool DecomposeTextRectAction() const;
98 OutputDevice
& m_rTargetDevice
;
101 //====================================================================
102 //= ControlTextRenderer
103 //====================================================================
104 class ReferenceDeviceTextLayout
;
105 /** a class which allows rendering text of a Control onto a device, by taking into account the metrics of
108 class ControlTextRenderer
111 ControlTextRenderer( const Control
& _rControl
, OutputDevice
& _rTargetDevice
, OutputDevice
& _rReferenceDevice
);
112 virtual ~ControlTextRenderer();
114 Rectangle
DrawText( const Rectangle
& _rRect
,
115 const XubString
& _rText
, sal_uInt16 _nStyle
= 0,
116 MetricVector
* _pVector
= NULL
, OUString
* _pDisplayText
= NULL
);
119 ControlTextRenderer(); // never implemented
120 ControlTextRenderer( const ControlTextRenderer
& ); // never implemented
121 ControlTextRenderer
& operator=( const ControlTextRenderer
& ); // never implemented
124 ::std::auto_ptr
< ReferenceDeviceTextLayout
> m_pImpl
;
127 //........................................................................
129 //........................................................................
131 #endif // VCL_TEXTLAYOUT_HXX
133 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */