Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / xmloff / source / chart / SchXMLCalculationSettingsContext.cxx
blob573941ec64d3c3f13254b53c89ae46b7a20b560e
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <SchXMLCalculationSettingsContext.hxx>
21 #include <com/sun/star/beans/XPropertySet.hpp>
22 #include <com/sun/star/util/DateTime.hpp>
24 #include <sax/tools/converter.hxx>
26 #include <xmloff/xmlimp.hxx>
27 #include <xmloff/nmspmap.hxx>
28 #include <xmloff/xmlnmspe.hxx>
29 #include <xmloff/xmltoken.hxx>
32 using namespace ::com::sun::star::uno;
33 using namespace ::com::sun::star::beans;
34 using namespace ::com::sun::star;
35 using namespace ::xmloff::token;
37 SchXMLCalculationSettingsContext::SchXMLCalculationSettingsContext( SvXMLImport& rImport,
38 sal_uInt16 p_nPrefix,
39 const OUString& rLocalName,
40 const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList )
41 : SvXMLImportContext ( rImport, p_nPrefix, rLocalName )
43 const SvXMLNamespaceMap& rMap = GetImport().GetNamespaceMap();
44 const sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
45 for( sal_Int16 i=0; i < nAttrCount; i++ )
47 const OUString sAttrName = xAttrList->getNameByIndex( i );
48 OUString aLocalName;
49 const sal_uInt16 nPrefix = rMap.GetKeyByAttrName(sAttrName, &aLocalName );
50 if ( nPrefix == XML_NAMESPACE_TABLE && IsXMLToken( aLocalName, XML_DATE_VALUE ) )
52 util::DateTime aNullDate;
53 const OUString sValue = xAttrList->getValueByIndex( i );
54 ::sax::Converter::parseDateTime(aNullDate, nullptr, sValue);
55 m_aNullDate <<= aNullDate;
59 SvXMLImportContext* SchXMLCalculationSettingsContext::CreateChildContext( sal_uInt16 nPrefix,
60 const OUString& rLocalName,
61 const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList )
63 return new SchXMLCalculationSettingsContext(GetImport(),nPrefix,rLocalName,xAttrList);
66 void SchXMLCalculationSettingsContext::EndElement()
68 if ( m_aNullDate.hasValue() )
70 Reference < XPropertySet > xPropSet ( GetImport().GetModel(), UNO_QUERY );
71 OUString sNullDate( "NullDate" );
72 xPropSet->setPropertyValue ( sNullDate, m_aNullDate );
76 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */