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