1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: csmaphdl.cxx,v $
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>
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()
71 sal_Bool
XMLCaseMapPropHdl::importXML( const OUString
& rStrImpValue
, uno::Any
& rValue
, const SvXMLUnitConverter
& ) const
74 sal_Bool bRet
= SvXMLUnitConverter::convertEnum(
75 nVal
, rStrImpValue
, pXML_Casemap_Enum
);
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();
88 if( rValue
>>= nValue
)
90 bRet
= SvXMLUnitConverter::convertEnum(
91 aOut
, nValue
, pXML_Casemap_Enum
);
93 rStrExpValue
= aOut
.makeStringAndClear();
99 ///////////////////////////////////////////////////////////////////////////////
101 // class XMLCaseMapVariantHdl
104 XMLCaseMapVariantHdl::~XMLCaseMapVariantHdl()
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
;
118 else if( IsXMLToken( rStrImpValue
, XML_CASEMAP_NORMAL
) )
120 rValue
<<= (sal_Int16
)style::CaseMap::NONE
;
127 sal_Bool
XMLCaseMapVariantHdl::exportXML( OUString
& rStrExpValue
, const uno::Any
& rValue
, const SvXMLUnitConverter
& ) const
129 sal_uInt16 nValue
= sal_uInt16();
132 if( rValue
>>= nValue
)
136 case style::CaseMap::NONE
:
137 aOut
.append( GetXMLToken(XML_CASEMAP_NORMAL
) );
139 case style::CaseMap::SMALLCAPS
:
140 aOut
.append( GetXMLToken(XML_CASEMAP_SMALL_CAPS
) );
145 rStrExpValue
= aOut
.makeStringAndClear();
146 return rStrExpValue
.getLength() != 0;