merge the formfield patch from ooo-build
[ooovba.git] / xmloff / source / style / adjushdl.cxx
blobc23cf3d0e84b1ffc83590989b814341c9c4c0b4f
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: adjushdl.cxx,v $
10 * $Revision: 1.13 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_xmloff.hxx"
33 #include <adjushdl.hxx>
34 #include <tools/solar.h>
35 #include <xmloff/xmltoken.hxx>
36 #include <xmloff/xmluconv.hxx>
37 #include <rtl/ustrbuf.hxx>
38 #include <com/sun/star/style/ParagraphAdjust.hpp>
39 #include <com/sun/star/uno/Any.hxx>
41 #ifndef _XMLOFF_XMLEMENT_HXX
42 #include <xmloff/xmlelement.hxx>
43 #endif
45 using namespace ::com::sun::star;
46 using ::rtl::OUString;
47 using ::rtl::OUStringBuffer;
49 using namespace ::xmloff::token;
51 SvXMLEnumMapEntry __READONLY_DATA pXML_Para_Adjust_Enum[] =
53 { XML_START, style::ParagraphAdjust_LEFT },
54 { XML_END, style::ParagraphAdjust_RIGHT },
55 { XML_CENTER, style::ParagraphAdjust_CENTER },
56 { XML_JUSTIFY, style::ParagraphAdjust_BLOCK },
57 { XML_JUSTIFIED, style::ParagraphAdjust_BLOCK }, // obsolete
58 { XML_LEFT, style::ParagraphAdjust_LEFT },
59 { XML_RIGHT, style::ParagraphAdjust_RIGHT },
60 { XML_TOKEN_INVALID, 0 }
63 SvXMLEnumMapEntry __READONLY_DATA pXML_Para_Align_Last_Enum[] =
65 { XML_START, style::ParagraphAdjust_LEFT },
66 { XML_CENTER, style::ParagraphAdjust_CENTER },
67 { XML_JUSTIFY, style::ParagraphAdjust_BLOCK },
68 { XML_JUSTIFIED, style::ParagraphAdjust_BLOCK }, // obsolete
69 { XML_TOKEN_INVALID, 0 }
72 ///////////////////////////////////////////////////////////////////////////////
74 // class XMLParaAdjustPropHdl
77 XMLParaAdjustPropHdl::~XMLParaAdjustPropHdl()
79 // nothing to do
82 sal_Bool XMLParaAdjustPropHdl::importXML( const OUString& rStrImpValue, uno::Any& rValue, const SvXMLUnitConverter& ) const
84 sal_uInt16 eAdjust;
85 sal_Bool bRet = SvXMLUnitConverter::convertEnum( eAdjust, rStrImpValue, pXML_Para_Adjust_Enum );
86 if( bRet )
87 rValue <<= (sal_Int16)eAdjust;
89 return bRet;
92 sal_Bool XMLParaAdjustPropHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue, const SvXMLUnitConverter& ) const
94 if(!rValue.hasValue())
95 return sal_False; //added by BerryJia for fixing Bug102407 2002-11-5
96 OUStringBuffer aOut;
97 sal_Int16 nVal = 0;
99 rValue >>= nVal;
101 sal_Bool bRet = SvXMLUnitConverter::convertEnum( aOut, nVal, pXML_Para_Adjust_Enum, XML_START );
103 rStrExpValue = aOut.makeStringAndClear();
105 return bRet;
108 ///////////////////////////////////////////////////////////////////////////////
110 // class XMLLastLineAdjustPropHdl
113 XMLLastLineAdjustPropHdl::~XMLLastLineAdjustPropHdl()
115 // nothing to do
118 sal_Bool XMLLastLineAdjustPropHdl::importXML( const OUString& rStrImpValue, uno::Any& rValue, const SvXMLUnitConverter& ) const
120 sal_uInt16 eAdjust;
121 sal_Bool bRet = SvXMLUnitConverter::convertEnum( eAdjust, rStrImpValue, pXML_Para_Align_Last_Enum );
122 if( bRet )
123 rValue <<= (sal_Int16)eAdjust;
125 return bRet;
128 sal_Bool XMLLastLineAdjustPropHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue, const SvXMLUnitConverter& ) const
130 OUStringBuffer aOut;
131 sal_Int16 nVal = 0;
132 sal_Bool bRet = sal_False;
134 rValue >>= nVal;
136 if( nVal != style::ParagraphAdjust_LEFT )
137 bRet = SvXMLUnitConverter::convertEnum( aOut, nVal, pXML_Para_Align_Last_Enum, XML_START );
139 rStrExpValue = aOut.makeStringAndClear();
141 return bRet;