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: XMLConstantsPropertyHandler.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 <tools/debug.hxx>
34 #include <xmloff/xmluconv.hxx>
35 #include <rtl/ustrbuf.hxx>
36 #include <com/sun/star/uno/Any.hxx>
37 #include <xmloff/XMLConstantsPropertyHandler.hxx>
39 using namespace ::com::sun::star::uno
;
40 using ::rtl::OUString
;
41 using ::rtl::OUStringBuffer
;
43 using ::xmloff::token::XMLTokenEnum
;
45 XMLConstantsPropertyHandler::XMLConstantsPropertyHandler(
46 const SvXMLEnumMapEntry
*pM
,
47 enum XMLTokenEnum eDflt
) :
53 XMLConstantsPropertyHandler::~XMLConstantsPropertyHandler()
57 sal_Bool
XMLConstantsPropertyHandler::importXML(
58 const OUString
& rStrImpValue
,
60 const SvXMLUnitConverter
& ) const
63 sal_Bool bRet
= SvXMLUnitConverter::convertEnum(
64 nEnum
, rStrImpValue
, pMap
);
67 rValue
<<= (sal_Int16
)nEnum
;
72 sal_Bool
XMLConstantsPropertyHandler::exportXML(
73 OUString
& rStrExpValue
,
75 const SvXMLUnitConverter
& ) const
79 sal_Bool bRet
= false;
83 if( rValue
.hasValue() && (rValue
.getValueTypeClass() == TypeClass_ENUM
))
85 nEnum
= *((sal_Int32
*)rValue
.getValue());
90 bRet
= (rValue
>>= nEnum
);
95 if( (nEnum
>= 0) && (nEnum
<= 0xffff) )
97 sal_uInt16 nConst
= static_cast<sal_uInt16
>( nEnum
);
99 bRet
= SvXMLUnitConverter::convertEnum(
100 aOut
, nConst
, pMap
, eDefault
);
102 rStrExpValue
= aOut
.makeStringAndClear();
106 DBG_ERROR("XMLConstantsPropertyHandler::exportXML() constant is out of range for implementation using sal_uInt16");
111 DBG_ERROR("XMLConstantsPropertyHandler::exportXML() could not convert any to sal_Int32");