1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #include <csmaphdl.hxx>
30 #include <xmloff/xmltoken.hxx>
31 #include <xmloff/xmluconv.hxx>
32 #include <rtl/ustrbuf.hxx>
33 #include <com/sun/star/style/CaseMap.hpp>
34 #include <com/sun/star/uno/Any.hxx>
36 using ::rtl::OUString
;
37 using ::rtl::OUStringBuffer
;
39 using namespace ::com::sun::star
;
40 using namespace ::xmloff::token
;
42 static SvXMLEnumMapEntry pXML_Casemap_Enum
[] =
44 { XML_NONE
, style::CaseMap::NONE
},
45 { XML_CASEMAP_LOWERCASE
, style::CaseMap::LOWERCASE
},
46 { XML_CASEMAP_UPPERCASE
, style::CaseMap::UPPERCASE
},
47 { XML_CASEMAP_CAPITALIZE
, style::CaseMap::TITLE
},
48 { XML_TOKEN_INVALID
, 0 }
51 ///////////////////////////////////////////////////////////////////////////////
53 // class XMLPosturePropHdl
56 XMLCaseMapPropHdl::~XMLCaseMapPropHdl()
61 sal_Bool
XMLCaseMapPropHdl::importXML( const OUString
& rStrImpValue
, uno::Any
& rValue
, const SvXMLUnitConverter
& ) const
64 sal_Bool bRet
= SvXMLUnitConverter::convertEnum(
65 nVal
, rStrImpValue
, pXML_Casemap_Enum
);
72 sal_Bool
XMLCaseMapPropHdl::exportXML( OUString
& rStrExpValue
, const uno::Any
& rValue
, const SvXMLUnitConverter
& ) const
74 sal_Bool bRet
= sal_False
;
75 sal_uInt16 nValue
= sal_uInt16();
78 if( rValue
>>= nValue
)
80 bRet
= SvXMLUnitConverter::convertEnum(
81 aOut
, nValue
, pXML_Casemap_Enum
);
83 rStrExpValue
= aOut
.makeStringAndClear();
89 ///////////////////////////////////////////////////////////////////////////////
91 // class XMLCaseMapVariantHdl
94 XMLCaseMapVariantHdl::~XMLCaseMapVariantHdl()
99 sal_Bool
XMLCaseMapVariantHdl::importXML( const OUString
& rStrImpValue
, uno::Any
& rValue
, const SvXMLUnitConverter
& ) const
101 sal_Bool bRet
= sal_False
;
103 if( IsXMLToken( rStrImpValue
, XML_CASEMAP_SMALL_CAPS
) )
105 rValue
<<= (sal_Int16
)style::CaseMap::SMALLCAPS
;
108 else if( IsXMLToken( rStrImpValue
, XML_CASEMAP_NORMAL
) )
110 rValue
<<= (sal_Int16
)style::CaseMap::NONE
;
117 sal_Bool
XMLCaseMapVariantHdl::exportXML( OUString
& rStrExpValue
, const uno::Any
& rValue
, const SvXMLUnitConverter
& ) const
119 sal_uInt16 nValue
= sal_uInt16();
122 if( rValue
>>= nValue
)
126 case style::CaseMap::NONE
:
127 aOut
.append( GetXMLToken(XML_CASEMAP_NORMAL
) );
129 case style::CaseMap::SMALLCAPS
:
130 aOut
.append( GetXMLToken(XML_CASEMAP_SMALL_CAPS
) );
135 rStrExpValue
= aOut
.makeStringAndClear();
136 return !rStrExpValue
.isEmpty();
139 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */