Update ooo320-m1
[ooovba.git] / xmloff / source / style / csmaphdl.cxx
blobef36ff9e7055ceb13f456abbf85092ecc38df1b7
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: csmaphdl.cxx,v $
10 * $Revision: 1.12 $
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 <csmaphdl.hxx>
34 #include <xmloff/xmltoken.hxx>
35 #include <xmloff/xmluconv.hxx>
36 #include <rtl/ustrbuf.hxx>
37 #include <com/sun/star/style/CaseMap.hpp>
40 #include <com/sun/star/uno/Any.hxx>
42 #ifndef _XMLOFF_XMLEMENT_HXX
43 #include <xmloff/xmlelement.hxx>
44 #endif
46 using ::rtl::OUString;
47 using ::rtl::OUStringBuffer;
49 using namespace ::com::sun::star;
50 using namespace ::xmloff::token;
52 static SvXMLEnumMapEntry pXML_Casemap_Enum[] =
54 { XML_NONE, style::CaseMap::NONE },
55 { XML_CASEMAP_LOWERCASE, style::CaseMap::LOWERCASE },
56 { XML_CASEMAP_UPPERCASE, style::CaseMap::UPPERCASE },
57 { XML_CASEMAP_CAPITALIZE, style::CaseMap::TITLE },
58 { XML_TOKEN_INVALID, 0 }
61 ///////////////////////////////////////////////////////////////////////////////
63 // class XMLPosturePropHdl
66 XMLCaseMapPropHdl::~XMLCaseMapPropHdl()
68 // nothing to do
71 sal_Bool XMLCaseMapPropHdl::importXML( const OUString& rStrImpValue, uno::Any& rValue, const SvXMLUnitConverter& ) const
73 sal_uInt16 nVal;
74 sal_Bool bRet = SvXMLUnitConverter::convertEnum(
75 nVal, rStrImpValue, pXML_Casemap_Enum );
76 if( ( bRet ) )
77 rValue <<= nVal;
79 return bRet;
82 sal_Bool XMLCaseMapPropHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue, const SvXMLUnitConverter& ) const
84 sal_Bool bRet = sal_False;
85 sal_uInt16 nValue = sal_uInt16();
86 OUStringBuffer aOut;
88 if( rValue >>= nValue )
90 bRet = SvXMLUnitConverter::convertEnum(
91 aOut, nValue, pXML_Casemap_Enum );
92 if( bRet )
93 rStrExpValue = aOut.makeStringAndClear();
96 return bRet;
99 ///////////////////////////////////////////////////////////////////////////////
101 // class XMLCaseMapVariantHdl
104 XMLCaseMapVariantHdl::~XMLCaseMapVariantHdl()
106 // nothing to do
109 sal_Bool XMLCaseMapVariantHdl::importXML( const OUString& rStrImpValue, uno::Any& rValue, const SvXMLUnitConverter& ) const
111 sal_Bool bRet = sal_False;
113 if( IsXMLToken( rStrImpValue, XML_CASEMAP_SMALL_CAPS ) )
115 rValue <<= (sal_Int16)style::CaseMap::SMALLCAPS;
116 bRet = sal_True;
118 else if( IsXMLToken( rStrImpValue, XML_CASEMAP_NORMAL ) )
120 rValue <<= (sal_Int16)style::CaseMap::NONE;
121 bRet = sal_True;
124 return bRet;
127 sal_Bool XMLCaseMapVariantHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue, const SvXMLUnitConverter& ) const
129 sal_uInt16 nValue = sal_uInt16();
130 OUStringBuffer aOut;
132 if( rValue >>= nValue )
134 switch( nValue )
136 case style::CaseMap::NONE:
137 aOut.append( GetXMLToken(XML_CASEMAP_NORMAL) );
138 break;
139 case style::CaseMap::SMALLCAPS:
140 aOut.append( GetXMLToken(XML_CASEMAP_SMALL_CAPS) );
141 break;
145 rStrExpValue = aOut.makeStringAndClear();
146 return rStrExpValue.getLength() != 0;