1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_xmloff.hxx" 30 #include <SchXMLCalculationSettingsContext.hxx> 31 #include <com/sun/star/beans/XPropertySet.hpp> 32 #include <com/sun/star/util/DateTime.hpp> 33 #include <xmloff/xmlimp.hxx> 34 #include <xmloff/nmspmap.hxx> 35 #include "xmloff/xmlnmspe.hxx" 36 #include <xmloff/xmltoken.hxx> 37 #include <xmloff/xmluconv.hxx> 38 39 40 using ::rtl::OUString; 41 using ::rtl::OUStringBuffer; 42 43 using namespace ::com::sun::star::uno; 44 using namespace ::com::sun::star::beans; 45 using namespace ::com::sun::star; 46 using namespace ::xmloff::token; 47 48 SchXMLCalculationSettingsContext::SchXMLCalculationSettingsContext( SvXMLImport& rImport, 49 sal_uInt16 p_nPrefix, 50 const ::rtl::OUString& rLocalName, 51 const ::com::sun::star::uno::Reference< 52 ::com::sun::star::xml::sax::XAttributeList >& xAttrList ) 53 : SvXMLImportContext ( rImport, p_nPrefix, rLocalName ) 54 { 55 const SvXMLNamespaceMap& rMap = GetImport().GetNamespaceMap(); 56 const sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; 57 for( sal_Int16 i=0; i < nAttrCount; i++ ) 58 { 59 const rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); 60 rtl::OUString aLocalName; 61 const sal_uInt16 nPrefix = rMap.GetKeyByAttrName(sAttrName, &aLocalName ); 62 if ( nPrefix == XML_NAMESPACE_TABLE && IsXMLToken( aLocalName, XML_DATE_VALUE ) ) 63 { 64 util::DateTime aNullDate; 65 const rtl::OUString sValue = xAttrList->getValueByIndex( i ); 66 GetImport().GetMM100UnitConverter().convertDateTime(aNullDate, sValue); 67 m_aNullDate <<= aNullDate; 68 } 69 } 70 } 71 SvXMLImportContext* SchXMLCalculationSettingsContext::CreateChildContext( sal_uInt16 nPrefix, 72 const ::rtl::OUString& rLocalName, 73 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList ) 74 { 75 return new SchXMLCalculationSettingsContext(GetImport(),nPrefix,rLocalName,xAttrList); 76 } 77 78 void SchXMLCalculationSettingsContext::EndElement() 79 { 80 if ( m_aNullDate.hasValue() ) 81 { 82 Reference < XPropertySet > xPropSet ( GetImport().GetModel(), UNO_QUERY ); 83 ::rtl::OUString sNullDate( RTL_CONSTASCII_USTRINGPARAM ( "NullDate" ) ); 84 xPropSet->setPropertyValue ( sNullDate, m_aNullDate ); 85 } 86 } 87