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