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: SchXMLCalculationSettingsContext.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 <SchXMLCalculationSettingsContext.hxx>
34 #include <com/sun/star/beans/XPropertySet.hpp>
35 #include <com/sun/star/util/DateTime.hpp>
36 #include <xmloff/xmlimp.hxx>
37 #include <xmloff/nmspmap.hxx>
38 #include "xmlnmspe.hxx"
39 #include <xmloff/xmltoken.hxx>
40 #include <xmloff/xmluconv.hxx>
43 using ::rtl::OUString
;
44 using ::rtl::OUStringBuffer
;
46 using namespace ::com::sun::star::uno
;
47 using namespace ::com::sun::star::beans
;
48 using namespace ::com::sun::star
;
49 using namespace ::xmloff::token
;
51 SchXMLCalculationSettingsContext::SchXMLCalculationSettingsContext( SvXMLImport
& rImport
,
53 const ::rtl::OUString
& rLocalName
,
54 const ::com::sun::star::uno::Reference
<
55 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
)
56 : SvXMLImportContext ( rImport
, p_nPrefix
, rLocalName
)
58 const SvXMLNamespaceMap
& rMap
= GetImport().GetNamespaceMap();
59 const sal_Int16 nAttrCount
= xAttrList
.is() ? xAttrList
->getLength() : 0;
60 for( sal_Int16 i
=0; i
< nAttrCount
; i
++ )
62 const rtl::OUString sAttrName
= xAttrList
->getNameByIndex( i
);
63 rtl::OUString aLocalName
;
64 const sal_uInt16 nPrefix
= rMap
.GetKeyByAttrName(sAttrName
, &aLocalName
);
65 if ( nPrefix
== XML_NAMESPACE_TABLE
&& IsXMLToken( aLocalName
, XML_DATE_VALUE
) )
67 util::DateTime aNullDate
;
68 const rtl::OUString sValue
= xAttrList
->getValueByIndex( i
);
69 GetImport().GetMM100UnitConverter().convertDateTime(aNullDate
, sValue
);
70 m_aNullDate
<<= aNullDate
;
74 SvXMLImportContext
* SchXMLCalculationSettingsContext::CreateChildContext( USHORT nPrefix
,
75 const ::rtl::OUString
& rLocalName
,
76 const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
)
78 return new SchXMLCalculationSettingsContext(GetImport(),nPrefix
,rLocalName
,xAttrList
);
81 void SchXMLCalculationSettingsContext::EndElement()
83 if ( m_aNullDate
.hasValue() )
85 Reference
< XPropertySet
> xPropSet ( GetImport().GetModel(), UNO_QUERY
);
86 ::rtl::OUString
sNullDate( RTL_CONSTASCII_USTRINGPARAM ( "NullDate" ) );
87 xPropSet
->setPropertyValue ( sNullDate
, m_aNullDate
);