1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 <xmloff/nmspmap.hxx>
25 #include "xmlimprt.hxx"
27 using namespace ::com::sun::star
;
29 ScMyImpCellRangeSource::ScMyImpCellRangeSource() :
36 ScXMLCellRangeSourceContext::ScXMLCellRangeSourceContext(
39 const OUString
& rLName
,
40 const uno::Reference
< xml::sax::XAttributeList
>& xAttrList
,
41 ScMyImpCellRangeSource
* pCellRangeSource
) :
42 SvXMLImportContext( rImport
, nPrfx
, rLName
)
44 if( !xAttrList
.is() ) return;
46 sal_Int16 nAttrCount
= xAttrList
->getLength();
47 const SvXMLTokenMap
& rAttrTokenMap
= GetScImport().GetTableCellRangeSourceAttrTokenMap();
49 for( sal_Int16 nIndex
= 0; nIndex
< nAttrCount
; ++nIndex
)
51 const OUString
& sAttrName(xAttrList
->getNameByIndex( nIndex
));
52 const OUString
& sValue(xAttrList
->getValueByIndex( nIndex
));
54 sal_uInt16 nPrefix
= GetScImport().GetNamespaceMap().GetKeyByAttrName( sAttrName
, &aLocalName
);
56 switch( rAttrTokenMap
.Get( nPrefix
, aLocalName
) )
58 case XML_TOK_TABLE_CELL_RANGE_SOURCE_ATTR_NAME
:
59 pCellRangeSource
->sSourceStr
= sValue
;
61 case XML_TOK_TABLE_CELL_RANGE_SOURCE_ATTR_FILTER_NAME
:
62 pCellRangeSource
->sFilterName
= sValue
;
64 case XML_TOK_TABLE_CELL_RANGE_SOURCE_ATTR_FILTER_OPTIONS
:
65 pCellRangeSource
->sFilterOptions
= sValue
;
67 case XML_TOK_TABLE_CELL_RANGE_SOURCE_ATTR_HREF
:
68 pCellRangeSource
->sURL
= GetScImport().GetAbsoluteReference(sValue
);
70 case XML_TOK_TABLE_CELL_RANGE_SOURCE_ATTR_LAST_COLUMN
:
73 if (::sax::Converter::convertNumber( nValue
, sValue
, 1 ))
74 pCellRangeSource
->nColumns
= nValue
;
76 pCellRangeSource
->nColumns
= 1;
79 case XML_TOK_TABLE_CELL_RANGE_SOURCE_ATTR_LAST_ROW
:
82 if (::sax::Converter::convertNumber( nValue
, sValue
, 1 ))
83 pCellRangeSource
->nRows
= nValue
;
85 pCellRangeSource
->nRows
= 1;
88 case XML_TOK_TABLE_CELL_RANGE_SOURCE_ATTR_REFRESH_DELAY
:
91 if (::sax::Converter::convertDuration( fTime
, sValue
))
92 pCellRangeSource
->nRefresh
= std::max( (sal_Int32
)(fTime
* 86400.0), (sal_Int32
)0 );
99 ScXMLCellRangeSourceContext::~ScXMLCellRangeSourceContext()
103 SvXMLImportContext
*ScXMLCellRangeSourceContext::CreateChildContext(
105 const OUString
& rLName
,
106 const uno::Reference
< xml::sax::XAttributeList
>& /* xAttrList */ )
108 return new SvXMLImportContext( GetImport(), nPrefix
, rLName
);
111 void ScXMLCellRangeSourceContext::EndElement()
115 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */