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_xmloff.hxx" 26 #include <postuhdl.hxx> 27 #include <xmloff/xmltoken.hxx> 28 #include <xmloff/xmluconv.hxx> 29 #include <rtl/ustrbuf.hxx> 30 #include <com/sun/star/uno/Any.hxx> 31 #include <com/sun/star/awt/FontSlant.hpp> 32 #include <tools/fontenum.hxx> 33 34 using ::rtl::OUString; 35 using ::rtl::OUStringBuffer; 36 37 using namespace ::com::sun::star; 38 using namespace ::xmloff::token; 39 40 SvXMLEnumMapEntry __READONLY_DATA aPostureGenericMapping[] = 41 { 42 { XML_POSTURE_NORMAL, ITALIC_NONE }, 43 { XML_POSTURE_ITALIC, ITALIC_NORMAL }, 44 { XML_POSTURE_OBLIQUE, ITALIC_OBLIQUE }, 45 { XML_TOKEN_INVALID, 0 } 46 }; 47 48 /////////////////////////////////////////////////////////////////////////////// 49 // 50 // class XMLPosturePropHdl 51 // 52 53 XMLPosturePropHdl::~XMLPosturePropHdl() 54 { 55 // nothing to do 56 } 57 58 sal_Bool XMLPosturePropHdl::importXML( const OUString& rStrImpValue, uno::Any& rValue, const SvXMLUnitConverter& ) const 59 { 60 sal_uInt16 ePosture; 61 sal_Bool bRet = SvXMLUnitConverter::convertEnum( ePosture, rStrImpValue, aPostureGenericMapping ); 62 if( bRet ) 63 rValue <<= (awt::FontSlant)ePosture; 64 65 return bRet; 66 } 67 68 sal_Bool XMLPosturePropHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue, const SvXMLUnitConverter& ) const 69 { 70 awt::FontSlant eSlant; 71 72 if( !( rValue >>= eSlant ) ) 73 { 74 sal_Int32 nValue = 0; 75 76 if( !( rValue >>= nValue ) ) 77 return sal_False; 78 79 eSlant = (awt::FontSlant)nValue; 80 } 81 82 OUStringBuffer aOut; 83 sal_Bool bRet = SvXMLUnitConverter::convertEnum( aOut, (sal_Int32)eSlant, aPostureGenericMapping ); 84 if( bRet ) 85 rStrExpValue = aOut.makeStringAndClear(); 86 87 return bRet; 88 } 89 90