xref: /trunk/main/oox/source/xls/themebuffer.cxx (revision ffd38472365e95f6a578737bc9a5eb0fac624a86)
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 #include "oox/xls/themebuffer.hxx"
23 
24 #include "oox/xls/stylesbuffer.hxx"
25 
26 namespace oox {
27 namespace xls {
28 
29 // ============================================================================
30 
31 using ::oox::drawingml::ClrScheme;
32 
33 // ============================================================================
34 
35 namespace {
36 
37 /** Specifies default theme fonts for a specific locale. */
38 struct BuiltinThemeFont
39 {
40     const sal_Char*     mpcLocale;          // The locale for this font setting.
41     const sal_Char*     mpcHeadFont;        // Default heading font.
42     const sal_Char*     mpcBodyFont;        // Default body font.
43 };
44 
45 #define FONT_JA "\357\274\255\357\274\263 \357\274\260\343\202\264\343\202\267\343\203\203\343\202\257"
46 #define FONT_KO "\353\247\221\354\235\200 \352\263\240\353\224\225"
47 #define FONT_CS "\345\256\213\344\275\223"
48 #define FONT_CT "\346\226\260\347\264\260\346\230\216\351\253\224"
49 
50 static const BuiltinThemeFont spBuiltinThemeFonts[] =
51 { //  locale    headings font           body font
52     { "*",      "Cambria",              "Calibri"           }, // Default
53     { "ar",     "Times New Roman",      "Arial"             }, // Arabic
54     { "bn",     "Vrinda",               "Vrinda"            }, // Bengali
55     { "div",    "MV Boli",              "MV Boli"           }, // Divehi
56     { "fa",     "Times New Roman",      "Arial"             }, // Farsi
57     { "gu",     "Shruti",               "Shruti"            }, // Gujarati
58     { "he",     "Times New Roman",      "Arial"             }, // Hebrew
59     { "hi",     "Mangal",               "Mangal"            }, // Hindi
60     { "ja",     FONT_JA,                FONT_JA             }, // Japanese
61     { "kn",     "Tunga",                "Tunga"             }, // Kannada
62     { "ko",     FONT_KO,                FONT_KO             }, // Korean
63     { "kok",    "Mangal",               "Mangal"            }, // Konkani
64     { "ml",     "Kartika",              "Kartika"           }, // Malayalam
65     { "mr",     "Mangal",               "Mangal"            }, // Marathi
66     { "pa",     "Raavi",                "Raavi"             }, // Punjabi
67     { "sa",     "Mangal",               "Mangal"            }, // Sanskrit
68     { "syr",    "Estrangelo Edessa",    "Estrangelo Edessa" }, // Syriac
69     { "ta",     "Latha",                "Latha"             }, // Tamil
70     { "te",     "Gautami",              "Gautami"           }, // Telugu
71     { "th",     "Tahoma",               "Tahoma"            }, // Thai
72     { "ur",     "Times New Roman",      "Arial"             }, // Urdu
73     { "vi",     "Times New Roman",      "Arial"             }, // Vietnamese
74     { "zh",     FONT_CS,                FONT_CS             }, // Chinese, Simplified
75     { "zh-HK",  FONT_CT,                FONT_CT             }, // Chinese, Hong Kong
76     { "zh-MO",  FONT_CT,                FONT_CT             }, // Chinese, Macau
77     { "zh-TW",  FONT_CT,                FONT_CT             }  // Chinese, Taiwan
78 };
79 
80 } // namespace
81 
82 // ----------------------------------------------------------------------------
83 
84 ThemeBuffer::ThemeBuffer( const WorkbookHelper& rHelper ) :
85     WorkbookHelper( rHelper ),
86     mxDefFontModel( new FontModel )
87 {
88     switch( getFilterType() )
89     {
90         case FILTER_OOXML:
91             //! TODO: locale dependent font name
92             mxDefFontModel->maName = CREATE_OUSTRING( "Cambria" );
93             mxDefFontModel->mfHeight = 11.0;
94         break;
95         case FILTER_BIFF:
96             //! TODO: BIFF dependent font name
97             mxDefFontModel->maName = CREATE_OUSTRING( "Arial" );
98             mxDefFontModel->mfHeight = 10.0;
99         break;
100         case FILTER_UNKNOWN: break;
101     }
102 }
103 
104 ThemeBuffer::~ThemeBuffer()
105 {
106 }
107 
108 sal_Int32 ThemeBuffer::getColorByToken( sal_Int32 nToken ) const
109 {
110     sal_Int32 nColor = 0;
111     return getClrScheme().getColor( nToken, nColor ) ? nColor : API_RGB_TRANSPARENT;
112 }
113 
114 // ============================================================================
115 
116 } // namespace xls
117 } // namespace oox
118 
119 /* vim: set noet sw=4 ts=4: */
120