Line data Source code
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 :
20 :
21 :
22 : #include "XMLCellRangeSourceContext.hxx"
23 :
24 : #include <sax/tools/converter.hxx>
25 :
26 : #include <xmloff/nmspmap.hxx>
27 : #include "xmlimprt.hxx"
28 :
29 : using namespace ::com::sun::star;
30 :
31 :
32 0 : ScMyImpCellRangeSource::ScMyImpCellRangeSource() :
33 : nColumns( 0 ),
34 : nRows( 0 ),
35 0 : nRefresh( 0 )
36 : {
37 0 : }
38 :
39 :
40 0 : ScXMLCellRangeSourceContext::ScXMLCellRangeSourceContext(
41 : ScXMLImport& rImport,
42 : sal_uInt16 nPrfx,
43 : const OUString& rLName,
44 : const uno::Reference< xml::sax::XAttributeList >& xAttrList,
45 : ScMyImpCellRangeSource* pCellRangeSource ) :
46 0 : SvXMLImportContext( rImport, nPrfx, rLName )
47 : {
48 0 : if( !xAttrList.is() ) return;
49 :
50 0 : sal_Int16 nAttrCount = xAttrList->getLength();
51 0 : const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetTableCellRangeSourceAttrTokenMap();
52 :
53 0 : for( sal_Int16 nIndex = 0; nIndex < nAttrCount; ++nIndex )
54 : {
55 0 : const OUString& sAttrName(xAttrList->getNameByIndex( nIndex ));
56 0 : const OUString& sValue(xAttrList->getValueByIndex( nIndex ));
57 0 : OUString aLocalName;
58 0 : sal_uInt16 nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
59 :
60 0 : switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
61 : {
62 : case XML_TOK_TABLE_CELL_RANGE_SOURCE_ATTR_NAME:
63 0 : pCellRangeSource->sSourceStr = sValue;
64 0 : break;
65 : case XML_TOK_TABLE_CELL_RANGE_SOURCE_ATTR_FILTER_NAME:
66 0 : pCellRangeSource->sFilterName = sValue;
67 0 : break;
68 : case XML_TOK_TABLE_CELL_RANGE_SOURCE_ATTR_FILTER_OPTIONS:
69 0 : pCellRangeSource->sFilterOptions = sValue;
70 0 : break;
71 : case XML_TOK_TABLE_CELL_RANGE_SOURCE_ATTR_HREF:
72 0 : pCellRangeSource->sURL = GetScImport().GetAbsoluteReference(sValue);
73 0 : break;
74 : case XML_TOK_TABLE_CELL_RANGE_SOURCE_ATTR_LAST_COLUMN:
75 : {
76 : sal_Int32 nValue;
77 0 : if (::sax::Converter::convertNumber( nValue, sValue, 1 ))
78 0 : pCellRangeSource->nColumns = nValue;
79 : else
80 0 : pCellRangeSource->nColumns = 1;
81 : }
82 0 : break;
83 : case XML_TOK_TABLE_CELL_RANGE_SOURCE_ATTR_LAST_ROW:
84 : {
85 : sal_Int32 nValue;
86 0 : if (::sax::Converter::convertNumber( nValue, sValue, 1 ))
87 0 : pCellRangeSource->nRows = nValue;
88 : else
89 0 : pCellRangeSource->nRows = 1;
90 : }
91 0 : break;
92 : case XML_TOK_TABLE_CELL_RANGE_SOURCE_ATTR_REFRESH_DELAY:
93 : {
94 : double fTime;
95 0 : if (::sax::Converter::convertDuration( fTime, sValue ))
96 0 : pCellRangeSource->nRefresh = std::max( (sal_Int32)(fTime * 86400.0), (sal_Int32)0 );
97 : }
98 0 : break;
99 : }
100 0 : }
101 : }
102 :
103 0 : ScXMLCellRangeSourceContext::~ScXMLCellRangeSourceContext()
104 : {
105 0 : }
106 :
107 0 : SvXMLImportContext *ScXMLCellRangeSourceContext::CreateChildContext(
108 : sal_uInt16 nPrefix,
109 : const OUString& rLName,
110 : const uno::Reference< xml::sax::XAttributeList>& /* xAttrList */ )
111 : {
112 0 : return new SvXMLImportContext( GetImport(), nPrefix, rLName );
113 : }
114 :
115 0 : void ScXMLCellRangeSourceContext::EndElement()
116 : {
117 0 : }
118 :
119 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|