Update ooo320-m1
[ooovba.git] / xmloff / source / text / XMLCalculationSettingsContext.cxx
blobcf9cbbfb5b45620f5b5a9af2d6da3f285cacf219
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: XMLCalculationSettingsContext.cxx,v $
10 * $Revision: 1.8 $
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 <XMLCalculationSettingsContext.hxx>
34 #include <com/sun/star/beans/XPropertySet.hpp>
35 #include <com/sun/star/text/XTextDocument.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::text;
49 using namespace ::xmloff::token;
51 XMLCalculationSettingsContext::XMLCalculationSettingsContext( SvXMLImport& rImport,
52 sal_uInt16 p_nPrefix,
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 )
57 , nYear( 1930 )
59 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
60 for( sal_Int16 i=0; i < nAttrCount; i++ )
62 rtl::OUString sAttrName = xAttrList->getNameByIndex( i );
63 rtl::OUString aLocalName;
64 sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName(
65 sAttrName, &aLocalName );
66 rtl::OUString sValue = xAttrList->getValueByIndex( i );
68 if (nPrefix == XML_NAMESPACE_TABLE)
70 if ( IsXMLToken( aLocalName, XML_NULL_YEAR ) )
72 sal_Int32 nTemp;
73 GetImport().GetMM100UnitConverter().convertNumber(nTemp, sValue);
74 nYear= static_cast <sal_Int16> (nTemp);
80 XMLCalculationSettingsContext::~XMLCalculationSettingsContext()
83 void XMLCalculationSettingsContext::EndElement()
85 if (nYear != 1930 )
87 Reference < XTextDocument > xTextDoc ( GetImport().GetModel(), UNO_QUERY);
88 if (xTextDoc.is())
90 Reference < XPropertySet > xPropSet ( xTextDoc, UNO_QUERY );
91 OUString sTwoDigitYear ( RTL_CONSTASCII_USTRINGPARAM ( "TwoDigitYear" ) );
92 Any aAny;
93 aAny <<= nYear;
94 xPropSet->setPropertyValue ( sTwoDigitYear, aAny );