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 <adjushdl.hxx> 31 #include <tools/solar.h> 32 #include <xmloff/xmltoken.hxx> 33 #include <xmloff/xmluconv.hxx> 34 #include <rtl/ustrbuf.hxx> 35 #include <com/sun/star/style/ParagraphAdjust.hpp> 36 #include <com/sun/star/uno/Any.hxx> 37 38 using namespace ::com::sun::star; 39 using ::rtl::OUString; 40 using ::rtl::OUStringBuffer; 41 42 using namespace ::xmloff::token; 43 44 SvXMLEnumMapEntry __READONLY_DATA pXML_Para_Adjust_Enum[] = 45 { 46 { XML_START, style::ParagraphAdjust_LEFT }, 47 { XML_END, style::ParagraphAdjust_RIGHT }, 48 { XML_CENTER, style::ParagraphAdjust_CENTER }, 49 { XML_JUSTIFY, style::ParagraphAdjust_BLOCK }, 50 { XML_JUSTIFIED, style::ParagraphAdjust_BLOCK }, // obsolete 51 { XML_LEFT, style::ParagraphAdjust_LEFT }, 52 { XML_RIGHT, style::ParagraphAdjust_RIGHT }, 53 { XML_TOKEN_INVALID, 0 } 54 }; 55 56 SvXMLEnumMapEntry __READONLY_DATA pXML_Para_Align_Last_Enum[] = 57 { 58 { XML_START, style::ParagraphAdjust_LEFT }, 59 { XML_CENTER, style::ParagraphAdjust_CENTER }, 60 { XML_JUSTIFY, style::ParagraphAdjust_BLOCK }, 61 { XML_JUSTIFIED, style::ParagraphAdjust_BLOCK }, // obsolete 62 { XML_TOKEN_INVALID, 0 } 63 }; 64 65 /////////////////////////////////////////////////////////////////////////////// 66 // 67 // class XMLParaAdjustPropHdl 68 // 69 70 XMLParaAdjustPropHdl::~XMLParaAdjustPropHdl() 71 { 72 // nothing to do 73 } 74 75 sal_Bool XMLParaAdjustPropHdl::importXML( const OUString& rStrImpValue, uno::Any& rValue, const SvXMLUnitConverter& ) const 76 { 77 sal_uInt16 eAdjust; 78 sal_Bool bRet = SvXMLUnitConverter::convertEnum( eAdjust, rStrImpValue, pXML_Para_Adjust_Enum ); 79 if( bRet ) 80 rValue <<= (sal_Int16)eAdjust; 81 82 return bRet; 83 } 84 85 sal_Bool XMLParaAdjustPropHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue, const SvXMLUnitConverter& ) const 86 { 87 if(!rValue.hasValue()) 88 return sal_False; //added by BerryJia for fixing Bug102407 2002-11-5 89 OUStringBuffer aOut; 90 sal_Int16 nVal = 0; 91 92 rValue >>= nVal; 93 94 sal_Bool bRet = SvXMLUnitConverter::convertEnum( aOut, nVal, pXML_Para_Adjust_Enum, XML_START ); 95 96 rStrExpValue = aOut.makeStringAndClear(); 97 98 return bRet; 99 } 100 101 /////////////////////////////////////////////////////////////////////////////// 102 // 103 // class XMLLastLineAdjustPropHdl 104 // 105 106 XMLLastLineAdjustPropHdl::~XMLLastLineAdjustPropHdl() 107 { 108 // nothing to do 109 } 110 111 sal_Bool XMLLastLineAdjustPropHdl::importXML( const OUString& rStrImpValue, uno::Any& rValue, const SvXMLUnitConverter& ) const 112 { 113 sal_uInt16 eAdjust; 114 sal_Bool bRet = SvXMLUnitConverter::convertEnum( eAdjust, rStrImpValue, pXML_Para_Align_Last_Enum ); 115 if( bRet ) 116 rValue <<= (sal_Int16)eAdjust; 117 118 return bRet; 119 } 120 121 sal_Bool XMLLastLineAdjustPropHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue, const SvXMLUnitConverter& ) const 122 { 123 OUStringBuffer aOut; 124 sal_Int16 nVal = 0; 125 sal_Bool bRet = sal_False; 126 127 rValue >>= nVal; 128 129 if( nVal != style::ParagraphAdjust_LEFT ) 130 bRet = SvXMLUnitConverter::convertEnum( aOut, nVal, pXML_Para_Align_Last_Enum, XML_START ); 131 132 rStrExpValue = aOut.makeStringAndClear(); 133 134 return bRet; 135 } 136 137