1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _SVTOOLS_SCRIPTEDTEXT_HXX
25 #define _SVTOOLS_SCRIPTEDTEXT_HXX
26 
27 #include "svtools/svtdllapi.h"
28 #include <tools/gen.hxx>
29 #include <com/sun/star/i18n/XBreakIterator.hpp>
30 
31 
32 namespace rtl { class OUString; }
33 class OutputDevice;
34 class Font;
35 class SvtScriptedTextHelper_Impl;
36 
37 
38 //_____________________________________________________________________________
39 
40 /**
41 This class provides drawing text with different script types on any output devices.
42 */
43 class SVT_DLLPUBLIC SvtScriptedTextHelper
44 {
45 private:
46     SvtScriptedTextHelper_Impl* mpImpl;             /// Implementation of class functionality.
47 
48                                 /** Assignment operator not implemented to prevent usage. */
49     SvtScriptedTextHelper&      operator=( const SvtScriptedTextHelper& );
50 
51 public:
52                                 /** Constructor sets an output device and no fonts.
53                                     @param  _rOutDevice
54                                     A reference to an output device. */
55                                 SvtScriptedTextHelper( OutputDevice& _rOutDevice );
56 
57                                 /** Constructor sets an output device and fonts for all script types.
58                                     @param  _rOutDevice
59                                     A reference to an output device.
60                                     @param  _pLatinFont
61                                     The font for latin characters.
62                                     @param  _pAsianFont
63                                     The font for asian characters.
64                                     @param  _pCmplxFont
65                                     The font for complex text layout. */
66                                 SvtScriptedTextHelper(
67                                     OutputDevice& _rOutDevice,
68                                     Font* _pLatinFont,
69                                     Font* _pAsianFont,
70                                     Font* _pCmplxFont );
71 
72                                 /** Copy constructor. */
73                                 SvtScriptedTextHelper(
74                                     const SvtScriptedTextHelper& _rCopy );
75 
76                                 /** Destructor. */
77     virtual                     ~SvtScriptedTextHelper();
78 
79                                 /** Sets new fonts and recalculates the text width.
80                                     @param  _pLatinFont
81                                     The font for latin characters.
82                                     @param  _pAsianFont
83                                     The font for asian characters.
84                                     @param  _pCmplxFont
85                                     The font for complex text layout. */
86     void                        SetFonts( Font* _pLatinFont, Font* _pAsianFont, Font* _pCmplxFont );
87 
88                                 /** Sets the default font of the current output device to all script types. */
89     void                        SetDefaultFont();
90 
91                                 /** Sets a new text and calculates all script breaks and the text width.
92                                     @param  _rText
93                                     The new text.
94                                     @param  _xBreakIter
95                                     The break iterator for iterating through the script portions. */
96     void                        SetText(
97                                     const ::rtl::OUString& _rText,
98                                     const ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XBreakIterator >& _xBreakIter );
99 
100                                 /** Returns the previously set text.
101                                     @return  The current text. */
102     const ::rtl::OUString&      GetText() const;
103 
104                                 /** Returns the calculated width the text will take in the current output device.
105                                     @return  The calculated text width. */
106     sal_Int32                   GetTextWidth() const;
107 
108                                 /** Returns the maximum height the text will take in the current output device.
109                                     @return  The maximum text height. */
110     sal_Int32                   GetTextHeight() const;
111 
112                                 /** Returns a size struct containing the width and height of the text in the current output device.
113                                     @return  A size struct with the text dimensions. */
114     const Size&                 GetTextSize() const;
115 
116                                 /** Draws the text in the current output device.
117                                     @param _rPos
118                                     The position of the top left edge of the text. */
119     void                        DrawText( const Point& _rPos );
120 };
121 
122 //_____________________________________________________________________________
123 
124 #endif
125 
126