bump product version to 4.1.6.2
[LibreOffice.git] / vcl / inc / textlayout.hxx
blob0788a8a10565c1ad0d3edd69636188a695b0da54
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
28 #include <memory>
30 class Control;
32 //........................................................................
33 namespace vcl
35 //........................................................................
37 //====================================================================
38 //= ITextLayout
39 //====================================================================
40 class SAL_NO_VTABLE ITextLayout
42 public:
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;
50 protected:
51 ~ITextLayout() {}
54 //====================================================================
55 //= DefaultTextLayout
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
62 public:
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,
73 sal_Int32 _nLength
74 ) const;
75 virtual void DrawText(
76 const Point& _rStartPoint,
77 const OUString& _rText,
78 sal_Int32 _nStartIndex,
79 sal_Int32 _nLength,
80 MetricVector* _pVector,
81 OUString* _pDisplayText
83 virtual bool GetCaretPositions(
84 const OUString& _rText,
85 sal_Int32* _pCaretXArray,
86 sal_Int32 _nStartIndex,
87 sal_Int32 _nLength
88 ) const;
89 virtual xub_StrLen GetTextBreak(
90 const OUString& _rText,
91 long _nMaxTextWidth,
92 sal_Int32 _nStartIndex,
93 sal_Int32 _nLength
94 ) const;
95 virtual bool DecomposeTextRectAction() const;
97 private:
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
106 a reference device.
108 class ControlTextRenderer
110 public:
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 );
118 private:
119 ControlTextRenderer(); // never implemented
120 ControlTextRenderer( const ControlTextRenderer& ); // never implemented
121 ControlTextRenderer& operator=( const ControlTextRenderer& ); // never implemented
123 private:
124 ::std::auto_ptr< ReferenceDeviceTextLayout > m_pImpl;
127 //........................................................................
128 } // namespace vcl
129 //........................................................................
131 #endif // VCL_TEXTLAYOUT_HXX
133 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */