xref: /aoo41x/main/sw/source/ui/inc/fontcfg.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 #ifndef _FONTCFG_HXX
28 #define _FONTCFG_HXX
29 
30 #include <unotools/configitem.hxx>
31 #include <tools/string.hxx>
32 #include <i18npool/lang.h>
33 #include <tools/debug.hxx>
34 #include "swdllapi.h"
35 
36 #define FONT_STANDARD       0
37 #define FONT_OUTLINE        1
38 #define FONT_LIST           2
39 #define FONT_CAPTION        3
40 #define FONT_INDEX          4
41 #define FONT_STANDARD_CJK   5
42 #define FONT_OUTLINE_CJK    6
43 #define FONT_LIST_CJK       7
44 #define FONT_CAPTION_CJK    8
45 #define FONT_INDEX_CJK      9
46 #define FONT_STANDARD_CTL   10
47 #define FONT_OUTLINE_CTL    11
48 #define FONT_LIST_CTL       12
49 #define FONT_CAPTION_CTL    13
50 #define FONT_INDEX_CTL      14
51 #define DEF_FONT_COUNT      15
52 
53 #define FONT_PER_GROUP      5
54 
55 #define FONT_GROUP_DEFAULT  0
56 #define FONT_GROUP_CJK      1
57 #define FONT_GROUP_CTL      2
58 
59 //pt-size of fonts
60 #define FONTSIZE_DEFAULT            240
61 #define FONTSIZE_OUTLINE            280
62 
63 
64 class SW_DLLPUBLIC SwStdFontConfig : public utl::ConfigItem
65 {
66     String      sDefaultFonts[DEF_FONT_COUNT];
67     sal_Int32   nDefaultFontHeight[DEF_FONT_COUNT];
68 
69     SW_DLLPRIVATE com::sun::star::uno::Sequence<rtl::OUString>    GetPropertyNames();
70 
71     void ChangeString(sal_uInt16 nFontType, const String& rSet)
72         {
73             if(sDefaultFonts[nFontType] != rSet)
74             {
75                 SetModified();
76                 sDefaultFonts[nFontType] = rSet;
77             }
78         }
79 
80     void ChangeInt( sal_uInt16 nFontType, sal_Int32 nHeight );
81 
82 public:
83 	SwStdFontConfig();
84 	~SwStdFontConfig();
85 
86 	virtual void	Commit();
87 	virtual void Notify( const ::com::sun::star::uno::Sequence< rtl::OUString >& aPropertyNames );
88 
89     const String&   GetFontStandard(sal_uInt8 nFontGroup) const {return sDefaultFonts[FONT_STANDARD + FONT_PER_GROUP * nFontGroup];}
90     const String&   GetFontOutline(sal_uInt8 nFontGroup)  const {return sDefaultFonts[FONT_OUTLINE + FONT_PER_GROUP * nFontGroup];}
91     const String&   GetFontList   (sal_uInt8 nFontGroup)  const {return sDefaultFonts[FONT_LIST + FONT_PER_GROUP * nFontGroup];}
92     const String&   GetFontCaption(sal_uInt8 nFontGroup)  const {return sDefaultFonts[FONT_CAPTION + FONT_PER_GROUP * nFontGroup];}
93     const String&   GetFontIndex  (sal_uInt8 nFontGroup)  const {return sDefaultFonts[FONT_INDEX + FONT_PER_GROUP * nFontGroup];}
94 
95     const String&   GetFontFor(sal_uInt16 nFontType)  const {return sDefaultFonts[nFontType];}
96     sal_Bool            IsFontDefault(sal_uInt16 nFontType) const;
97 
98     void     SetFontStandard(const String& rSet, sal_uInt8 nFontGroup)
99                     {ChangeString(FONT_STANDARD + FONT_PER_GROUP * nFontGroup, rSet);}
100 
101     void     SetFontOutline(const String& rSet, sal_uInt8 nFontGroup)
102                     {    ChangeString(FONT_OUTLINE + FONT_PER_GROUP * nFontGroup, rSet);}
103     void     SetFontList   (const String& rSet, sal_uInt8 nFontGroup)
104                     {    ChangeString(FONT_LIST + FONT_PER_GROUP * nFontGroup, rSet);}
105     void     SetFontCaption(const String& rSet, sal_uInt8 nFontGroup)
106                     {    ChangeString(FONT_CAPTION + FONT_PER_GROUP * nFontGroup, rSet);}
107     void     SetFontIndex  (const String& rSet, sal_uInt8 nFontGroup)
108                     {    ChangeString(FONT_INDEX + FONT_PER_GROUP * nFontGroup, rSet);}
109 
110     void     SetFontHeight( sal_Int32 nHeight, sal_uInt8 nFont, sal_uInt8 nScriptType )
111                     {    ChangeInt(nFont + FONT_PER_GROUP * nScriptType, nHeight);}
112 
113     sal_Int32 GetFontHeight( sal_uInt8 nFont, sal_uInt8 nScriptType, LanguageType eLang );
114 
115     static String    GetDefaultFor(sal_uInt16 nFontType, LanguageType eLang);
116     static sal_Int32 GetDefaultHeightFor(sal_uInt16 nFontType, LanguageType eLang);
117 };
118 #endif
119 
120 
121