xref: /AOO41X/main/editeng/inc/editeng/svxfont.hxx (revision 4c5491ea21520f5347760e8fc7d072f082fcde5f)
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 #ifndef _SVX_SVXFONT_HXX
24 #define _SVX_SVXFONT_HXX
25 
26 #include <limits.h>     // USHRT_MAX
27 #include <editeng/svxenum.hxx>
28 #include <i18npool/lang.h>
29 #include <vcl/font.hxx>
30 #include "editeng/editengdllapi.h"
31 
32 class SvxDoCapitals;
33 class OutputDevice;
34 class Printer;
35 
36 class EDITENG_DLLPUBLIC SvxFont : public Font
37 {
38     LanguageType eLang;         // Language
39     SvxCaseMap   eCaseMap;      // Textauszeichnung
40     short nEsc;                 // Grad der Hoch-/Tiefstellung
41     sal_uInt8  nPropr;               // Grad der Verkleinerung der Fonthoehe
42     short nKern;                // Kerning in Pt
43 
44 public:
45     SvxFont();
46     SvxFont( const Font &rFont );
47     SvxFont( const SvxFont &rFont );
48 
49     // Methoden fuer die Hoch-/Tiefstellung
GetEscapement() const50     inline short GetEscapement() const { return nEsc; }
SetEscapement(const short nNewEsc)51     inline void SetEscapement( const short nNewEsc ) { nEsc = nNewEsc; }
52 
GetPropr() const53     inline sal_uInt8 GetPropr() const { return nPropr; }
SetPropr(const sal_uInt8 nNewPropr)54     inline void SetPropr( const sal_uInt8 nNewPropr ) { nPropr = nNewPropr; }
SetProprRel(const sal_uInt8 nNewPropr)55     inline void SetProprRel( const sal_uInt8 nNewPropr )
56         { SetPropr( (sal_uInt8)( (long)nNewPropr * (long)nPropr / 100L ) ); }
57 
58     // Kerning
GetFixKerning() const59     inline short GetFixKerning() const { return nKern; }
SetFixKerning(const short nNewKern)60     inline void  SetFixKerning( const short nNewKern ) { nKern = nNewKern; }
61 
GetCaseMap() const62     inline SvxCaseMap GetCaseMap() const { return eCaseMap; }
SetCaseMap(const SvxCaseMap eNew)63     inline void    SetCaseMap( const SvxCaseMap eNew ) { eCaseMap = eNew; }
64 
GetLanguage() const65     inline LanguageType GetLanguage() const { return eLang; }
SetLanguage(const LanguageType eNewLan)66     inline void SetLanguage( const LanguageType eNewLan )
67         { eLang = eNewLan;  Font::SetLanguage(eNewLan); }
68 
69     // Is-Methoden:
IsCaseMap() const70     inline sal_Bool IsCaseMap() const { return SVX_CASEMAP_NOT_MAPPED != eCaseMap; }
IsCapital() const71     inline sal_Bool IsCapital() const { return SVX_CASEMAP_KAPITAELCHEN == eCaseMap; }
IsKern() const72     inline sal_Bool IsKern() const { return 0 != nKern; }
IsEsc() const73     inline sal_Bool IsEsc() const { return 0 != nEsc; }
74 
75     // Versalien, Gemeine etc. beruecksichtigen
76     String CalcCaseMap( const String &rTxt ) const;
77 
78 // Der folgende Bereich wird nicht von jedem benoetigt, er kann deshalb
79 // ausgeklammert werden.
80 #ifndef REDUCEDSVXFONT
81     // Kapitaelchenbearbeitung
82     void DoOnCapitals( SvxDoCapitals &rDo,
83                        const sal_uInt16 nPartLen = USHRT_MAX ) const;
84 
85     void SetPhysFont( OutputDevice *pOut ) const;
86     Font ChgPhysFont( OutputDevice *pOut ) const;
87 
88     Size GetCapitalSize( const OutputDevice *pOut, const String &rTxt,
89                           const sal_uInt16 nIdx, const sal_uInt16 nLen) const;
90     void DrawCapital( OutputDevice *pOut, const Point &rPos, const String &rTxt,
91                       const sal_uInt16 nIdx, const sal_uInt16 nLen ) const;
92 
93     Size GetPhysTxtSize( const OutputDevice *pOut, const String &rTxt,
94                          const sal_uInt16 nIdx, const sal_uInt16 nLen ) const;
95 
96     Size GetPhysTxtSize( const OutputDevice *pOut, const String &rTxt );
97 
98     Size GetTxtSize( const OutputDevice *pOut, const String &rTxt,
99                       const sal_uInt16 nIdx = 0, const sal_uInt16 nLen = STRING_LEN );
100 
101     void DrawText( OutputDevice *pOut, const Point &rPos, const String &rTxt,
102                const sal_uInt16 nIdx = 0, const sal_uInt16 nLen = STRING_LEN ) const;
103 
104     void QuickDrawText( OutputDevice *pOut, const Point &rPos, const String &rTxt,
105                const sal_uInt16 nIdx = 0, const sal_uInt16 nLen = STRING_LEN, const sal_Int32* pDXArray = NULL ) const;
106 
107     Size QuickGetTextSize( const OutputDevice *pOut, const String &rTxt,
108                          const sal_uInt16 nIdx, const sal_uInt16 nLen, sal_Int32* pDXArray = NULL ) const;
109 
110     void DrawPrev( OutputDevice* pOut, Printer* pPrinter,
111                    const Point &rPos, const String &rTxt,
112                    const sal_uInt16 nIdx = 0, const sal_uInt16 nLen = STRING_LEN ) const;
113 
114 #endif // !REDUCEDSVXFONT
115     static void DrawArrow( OutputDevice &rOut, const Rectangle& rRect,
116         const Size& rSize, const Color& rCol, sal_Bool bLeft );
117     SvxFont&    operator=( const SvxFont& rFont );
118     SvxFont&    operator=( const Font& rFont );
119 };
120 
121 #endif // #ifndef   _SVX_SVXFONT_HXX
122 
123