update dev300-m58
[ooovba.git] / oox / source / drawingml / theme.cxx
blobe1a7f634fa21bfd1ddb51be67fbf6ab984b71355
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"
33 using ::rtl::OUString;
35 namespace oox {
36 namespace drawingml {
38 // ============================================================================
40 Theme::Theme()
44 Theme::~Theme()
48 namespace {
50 template< typename Type >
51 const Type* lclGetStyleElement( const RefVector< Type >& rVector, sal_Int32 nIndex )
53 return (rVector.empty() || (nIndex < 1)) ? 0 :
54 rVector.get( ::std::min( static_cast< sal_Int32 >( nIndex - 1 ), static_cast< sal_Int32 >( rVector.size() - 1 ) ) ).get();
57 } // namespace
59 const FillProperties* Theme::getFillStyle( sal_Int32 nIndex ) const
61 return (nIndex >= 1000) ?
62 lclGetStyleElement( maBgFillStyleList, nIndex - 1000 ) :
63 lclGetStyleElement( maFillStyleList, nIndex );
66 const LineProperties* Theme::getLineStyle( sal_Int32 nIndex ) const
68 return lclGetStyleElement( maLineStyleList, nIndex );
71 const PropertyMap* Theme::getEffectStyle( sal_Int32 nIndex ) const
73 return lclGetStyleElement( maEffectStyleList, nIndex );
76 const TextCharacterProperties* Theme::getFontStyle( sal_Int32 nSchemeType ) const
78 return maFontScheme.get( nSchemeType ).get();
81 const TextFont* Theme::resolveFont( const OUString& rName ) const
83 /* Resolves the following names:
84 +mj-lt, +mj-ea, +mj-cs -- major Latin, Asian, Complex font
85 +mn-lt, +mn-ea, +mn-cs -- minor Latin, Asian, Complex font
87 if( (rName.getLength() == 6) && (rName[ 0 ] == '+') && (rName[ 3 ] == '-') )
89 const TextCharacterProperties* pCharProps = 0;
90 if( (rName[ 1 ] == 'm') && (rName[ 2 ] == 'j') )
91 pCharProps = maFontScheme.get( XML_major ).get();
92 else if( (rName[ 1 ] == 'm') && (rName[ 2 ] == 'n') )
93 pCharProps = maFontScheme.get( XML_minor ).get();
94 if( pCharProps )
96 if( (rName[ 4 ] == 'l') && (rName[ 5 ] == 't') )
97 return &pCharProps->maLatinFont;
98 if( (rName[ 4 ] == 'e') && (rName[ 5 ] == 'a') )
99 return &pCharProps->maAsianFont;
100 if( (rName[ 4 ] == 'c') && (rName[ 5 ] == 's') )
101 return &pCharProps->maComplexFont;
104 return 0;
107 // ============================================================================
109 } // namespace drawingml
110 } // namespace oox