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