LibreOffice Module xmloff (master)  1
SchXMLCalculationSettingsContext.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
21 #include <com/sun/star/beans/XPropertySet.hpp>
22 #include <com/sun/star/frame/XModel.hpp>
23 #include <com/sun/star/util/DateTime.hpp>
24 
25 #include <sax/tools/converter.hxx>
26 
27 #include <xmloff/xmlimp.hxx>
28 #include <xmloff/nmspmap.hxx>
29 #include <xmloff/xmlnmspe.hxx>
30 #include <xmloff/xmltoken.hxx>
31 
32 
33 using namespace ::com::sun::star::uno;
34 using namespace ::com::sun::star::beans;
35 using namespace ::com::sun::star;
36 using namespace ::xmloff::token;
37 
39  sal_uInt16 p_nPrefix,
40  const OUString& rLocalName,
41  const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList )
42 : SvXMLImportContext ( rImport, p_nPrefix, rLocalName )
43 {
45  const sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
46  for( sal_Int16 i=0; i < nAttrCount; i++ )
47  {
48  const OUString sAttrName = xAttrList->getNameByIndex( i );
49  OUString aLocalName;
50  const sal_uInt16 nPrefix = rMap.GetKeyByAttrName(sAttrName, &aLocalName );
51  if ( nPrefix == XML_NAMESPACE_TABLE && IsXMLToken( aLocalName, XML_DATE_VALUE ) )
52  {
53  util::DateTime aNullDate;
54  const OUString sValue = xAttrList->getValueByIndex( i );
55  ::sax::Converter::parseDateTime(aNullDate, sValue);
56  m_aNullDate <<= aNullDate;
57  }
58  }
59 }
61  const OUString& rLocalName,
62  const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList )
63 {
64  return new SchXMLCalculationSettingsContext(GetImport(),nPrefix,rLocalName,xAttrList);
65 }
66 
68 {
69  if ( m_aNullDate.hasValue() )
70  {
71  Reference < XPropertySet > xPropSet ( GetImport().GetModel(), UNO_QUERY );
72  xPropSet->setPropertyValue ( "NullDate", m_aNullDate );
73  }
74 }
75 
76 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool IsXMLToken(const OUString &rString, enum XMLTokenEnum eToken)
compare eToken to the string
Definition: xmltoken.cxx:3422
SvXMLImport & GetImport()
Definition: xmlictxt.hxx:62
SvXMLNamespaceMap & GetNamespaceMap()
Definition: xmlimp.hxx:397
virtual void EndElement() override
EndElement is called before a context will be destructed, but after an elements context has been pars...
sal_uInt16 GetKeyByAttrName(const OUString &rAttrName, OUString *pPrefix, OUString *pLocalName, OUString *pNamespace) const
Definition: nmspmap.cxx:437
virtual SvXMLImportContextRef CreateChildContext(sal_uInt16 nPrefix, const OUString &rLocalName, const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList) override
Create a children element context.
static bool parseDateTime(css::util::DateTime &rDateTime, const OUString &rString)
SchXMLCalculationSettingsContext(SvXMLImport &rImport, sal_uInt16 nPrefix, const OUString &rLocalName, const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList)
int i
This class deliberately does not support XWeak, to improve performance when loading large documents...
Definition: xmlictxt.hxx:44
Handling of tokens in XML:
constexpr sal_uInt16 XML_NAMESPACE_TABLE
Definition: xmlnmspe.hxx:32