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 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_sd.hxx" 30 #include <i18npool/mslangid.hxx> 31 #include <comphelper/propertysetinfo.hxx> 32 #include <editeng/eeitem.hxx> 33 #include <svx/unopool.hxx> 34 35 #include "drawdoc.hxx" 36 37 using namespace ::com::sun::star; 38 using namespace ::rtl; 39 using namespace ::cppu; 40 using namespace ::comphelper; 41 42 LanguageType SdUnoGetLanguage( const lang::Locale& rLocale ) 43 { 44 // empty language -> LANGUAGE_SYSTEM 45 if ( rLocale.Language.getLength() == 0 ) 46 return LANGUAGE_SYSTEM; 47 48 LanguageType eRet = MsLangId::convertLocaleToLanguage( rLocale ); 49 if ( eRet == LANGUAGE_NONE ) 50 eRet = LANGUAGE_SYSTEM; //! or throw an exception? 51 52 return eRet; 53 } 54 55 class SdUnoDrawPool : public SvxUnoDrawPool 56 { 57 public: 58 SdUnoDrawPool( SdDrawDocument* pModel ) throw(); 59 virtual ~SdUnoDrawPool() throw(); 60 61 protected: 62 virtual void putAny( SfxItemPool* pPool, const PropertyMapEntry* pEntry, const uno::Any& rValue ) throw( beans::UnknownPropertyException, lang::IllegalArgumentException); 63 64 private: 65 SdDrawDocument* mpDrawModel; 66 }; 67 68 SdUnoDrawPool::SdUnoDrawPool( SdDrawDocument* pModel ) throw() 69 : SvxUnoDrawPool( pModel ), mpDrawModel( pModel ) 70 { 71 } 72 73 SdUnoDrawPool::~SdUnoDrawPool() throw() 74 { 75 } 76 77 void SdUnoDrawPool::putAny( SfxItemPool* pPool, const comphelper::PropertyMapEntry* pEntry, const uno::Any& rValue ) 78 throw(beans::UnknownPropertyException, lang::IllegalArgumentException) 79 { 80 switch( pEntry->mnHandle ) 81 { 82 case EE_CHAR_LANGUAGE: 83 case EE_CHAR_LANGUAGE_CJK: 84 case EE_CHAR_LANGUAGE_CTL: 85 { 86 lang::Locale aLocale; 87 if( rValue >>= aLocale ) 88 mpDrawModel->SetLanguage( 89 SdUnoGetLanguage( aLocale ), 90 (const sal_uInt16)pEntry->mnHandle ); 91 } 92 } 93 SvxUnoDrawPool::putAny( pPool, pEntry, rValue ); 94 } 95 96 uno::Reference< uno::XInterface > SdUnoCreatePool( SdDrawDocument* pDrawModel ) 97 { 98 return (uno::XAggregation*)new SdUnoDrawPool( pDrawModel ); 99 } 100