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