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