Update ooo320-m1
[ooovba.git] / oox / source / drawingml / theme.cxx
blob84e150672d1c38399dd8b12fcb5a7d79d838d5ce
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: theme.cxx,v $
10 * $Revision: 1.5.6.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include "oox/drawingml/theme.hxx"
32 #include "tokens.hxx"
34 using ::rtl::OUString;
36 namespace oox {
37 namespace drawingml {
39 // ============================================================================
41 Theme::Theme()
45 Theme::~Theme()
49 namespace {
51 template< typename Type >
52 const Type* lclGetStyleElement( const RefVector< Type >& rVector, sal_Int32 nIndex )
54 return (rVector.empty() || (nIndex < 1)) ? 0 :
55 rVector.get( ::std::min( static_cast< sal_Int32 >( nIndex - 1 ), static_cast< sal_Int32 >( rVector.size() - 1 ) ) ).get();
58 } // namespace
60 const FillProperties* Theme::getFillStyle( sal_Int32 nIndex ) const
62 return (nIndex >= 1000) ?
63 lclGetStyleElement( maBgFillStyleList, nIndex - 1000 ) :
64 lclGetStyleElement( maFillStyleList, nIndex );
67 const LineProperties* Theme::getLineStyle( sal_Int32 nIndex ) const
69 return lclGetStyleElement( maLineStyleList, nIndex );
72 const PropertyMap* Theme::getEffectStyle( sal_Int32 nIndex ) const
74 return lclGetStyleElement( maEffectStyleList, nIndex );
77 const TextCharacterProperties* Theme::getFontStyle( sal_Int32 nSchemeType ) const
79 return maFontScheme.get( nSchemeType ).get();
82 const TextFont* Theme::resolveFont( const OUString& rName ) const
84 /* Resolves the following names:
85 +mj-lt, +mj-ea, +mj-cs -- major Latin, Asian, Complex font
86 +mn-lt, +mn-ea, +mn-cs -- minor Latin, Asian, Complex font
88 if( (rName.getLength() == 6) && (rName[ 0 ] == '+') && (rName[ 3 ] == '-') )
90 const TextCharacterProperties* pCharProps = 0;
91 if( (rName[ 1 ] == 'm') && (rName[ 2 ] == 'j') )
92 pCharProps = maFontScheme.get( XML_major ).get();
93 else if( (rName[ 1 ] == 'm') && (rName[ 2 ] == 'n') )
94 pCharProps = maFontScheme.get( XML_minor ).get();
95 if( pCharProps )
97 if( (rName[ 4 ] == 'l') && (rName[ 5 ] == 't') )
98 return &pCharProps->maLatinFont;
99 if( (rName[ 4 ] == 'e') && (rName[ 5 ] == 'a') )
100 return &pCharProps->maAsianFont;
101 if( (rName[ 4 ] == 'c') && (rName[ 5 ] == 's') )
102 return &pCharProps->maComplexFont;
105 return 0;
108 // ============================================================================
110 } // namespace drawingml
111 } // namespace oox