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/drawingml/theme.hxx" 29 30 using ::rtl::OUString; 31 32 namespace oox { 33 namespace drawingml { 34 35 // ============================================================================ 36 37 Theme::Theme() 38 { 39 } 40 41 Theme::~Theme() 42 { 43 } 44 45 namespace { 46 47 template< typename Type > 48 const Type* lclGetStyleElement( const RefVector< Type >& rVector, sal_Int32 nIndex ) 49 { 50 return (rVector.empty() || (nIndex < 1)) ? 0 : 51 rVector.get( ::std::min( static_cast< sal_Int32 >( nIndex - 1 ), static_cast< sal_Int32 >( rVector.size() - 1 ) ) ).get(); 52 } 53 54 } // namespace 55 56 const FillProperties* Theme::getFillStyle( sal_Int32 nIndex ) const 57 { 58 return (nIndex >= 1000) ? 59 lclGetStyleElement( maBgFillStyleList, nIndex - 1000 ) : 60 lclGetStyleElement( maFillStyleList, nIndex ); 61 } 62 63 const LineProperties* Theme::getLineStyle( sal_Int32 nIndex ) const 64 { 65 return lclGetStyleElement( maLineStyleList, nIndex ); 66 } 67 68 const PropertyMap* Theme::getEffectStyle( sal_Int32 nIndex ) const 69 { 70 return lclGetStyleElement( maEffectStyleList, nIndex ); 71 } 72 73 const TextCharacterProperties* Theme::getFontStyle( sal_Int32 nSchemeType ) const 74 { 75 return maFontScheme.get( nSchemeType ).get(); 76 } 77 78 const TextFont* Theme::resolveFont( const OUString& rName ) const 79 { 80 /* Resolves the following names: 81 +mj-lt, +mj-ea, +mj-cs -- major Latin, Asian, Complex font 82 +mn-lt, +mn-ea, +mn-cs -- minor Latin, Asian, Complex font 83 */ 84 if( (rName.getLength() == 6) && (rName[ 0 ] == '+') && (rName[ 3 ] == '-') ) 85 { 86 const TextCharacterProperties* pCharProps = 0; 87 if( (rName[ 1 ] == 'm') && (rName[ 2 ] == 'j') ) 88 pCharProps = maFontScheme.get( XML_major ).get(); 89 else if( (rName[ 1 ] == 'm') && (rName[ 2 ] == 'n') ) 90 pCharProps = maFontScheme.get( XML_minor ).get(); 91 if( pCharProps ) 92 { 93 if( (rName[ 4 ] == 'l') && (rName[ 5 ] == 't') ) 94 return &pCharProps->maLatinFont; 95 if( (rName[ 4 ] == 'e') && (rName[ 5 ] == 'a') ) 96 return &pCharProps->maAsianFont; 97 if( (rName[ 4 ] == 'c') && (rName[ 5 ] == 's') ) 98 return &pCharProps->maComplexFont; 99 } 100 } 101 return 0; 102 } 103 104 // ============================================================================ 105 106 } // namespace drawingml 107 } // namespace oox 108 109