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