Version 6.4.0.3, tag libreoffice-6.4.0.3
[LibreOffice.git] / sc / source / filter / xml / XMLCellRangeSourceContext.cxx
blob936f565c93a6c067b28659091caa35cc1d71cadb
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 "XMLCellRangeSourceContext.hxx"
22 #include <sax/tools/converter.hxx>
24 #include "xmlimprt.hxx"
25 #include <xmloff/xmlnmspe.hxx>
27 using namespace ::com::sun::star;
28 using namespace xmloff::token;
30 ScMyImpCellRangeSource::ScMyImpCellRangeSource() :
31 nColumns( 0 ),
32 nRows( 0 ),
33 nRefresh( 0 )
37 ScXMLCellRangeSourceContext::ScXMLCellRangeSourceContext(
38 ScXMLImport& rImport,
39 const rtl::Reference<sax_fastparser::FastAttributeList>& rAttrList,
40 ScMyImpCellRangeSource* pCellRangeSource ) :
41 ScXMLImportContext( rImport )
43 if ( rAttrList.is() )
45 for (auto &aIter : *rAttrList)
47 switch (aIter.getToken())
49 case XML_ELEMENT( TABLE, XML_NAME ):
50 pCellRangeSource->sSourceStr = aIter.toString();
51 break;
52 case XML_ELEMENT( TABLE, XML_FILTER_NAME ):
53 pCellRangeSource->sFilterName = aIter.toString();
54 break;
55 case XML_ELEMENT( TABLE, XML_FILTER_OPTIONS ):
56 pCellRangeSource->sFilterOptions = aIter.toString();
57 break;
58 case XML_ELEMENT( XLINK, XML_HREF ):
59 pCellRangeSource->sURL = GetScImport().GetAbsoluteReference(aIter.toString());
60 break;
61 case XML_ELEMENT( TABLE, XML_LAST_COLUMN_SPANNED ):
63 sal_Int32 nValue;
64 if (::sax::Converter::convertNumber( nValue, aIter.toString(), 1 ))
65 pCellRangeSource->nColumns = nValue;
66 else
67 pCellRangeSource->nColumns = 1;
69 break;
70 case XML_ELEMENT( TABLE, XML_LAST_ROW_SPANNED ):
72 sal_Int32 nValue;
73 if (::sax::Converter::convertNumber( nValue, aIter.toString(), 1 ))
74 pCellRangeSource->nRows = nValue;
75 else
76 pCellRangeSource->nRows = 1;
78 break;
79 case XML_ELEMENT( TABLE, XML_REFRESH_DELAY ):
81 double fTime;
82 if (::sax::Converter::convertDuration( fTime, aIter.toString() ))
83 pCellRangeSource->nRefresh = std::max( static_cast<sal_Int32>(fTime * 86400.0), sal_Int32(0) );
85 break;
91 ScXMLCellRangeSourceContext::~ScXMLCellRangeSourceContext()
95 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */