update dev300-m58
[ooovba.git] / sc / source / filter / xml / XMLCellRangeSourceContext.cxx
blobe67a0e17c3eb85f1b29e0b0a910de29c4d98c95a
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: XMLCellRangeSourceContext.cxx,v $
10 * $Revision: 1.11 $
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_sc.hxx"
36 //___________________________________________________________________
37 #include "XMLCellRangeSourceContext.hxx"
38 #include <xmloff/nmspmap.hxx>
39 #include <xmloff/xmluconv.hxx>
40 #include "xmlimprt.hxx"
42 using ::rtl::OUString;
43 using namespace ::com::sun::star;
46 //___________________________________________________________________
48 ScMyImpCellRangeSource::ScMyImpCellRangeSource() :
49 nColumns( 0 ),
50 nRows( 0 ),
51 nRefresh( 0 )
56 //___________________________________________________________________
58 ScXMLCellRangeSourceContext::ScXMLCellRangeSourceContext(
59 ScXMLImport& rImport,
60 USHORT nPrfx,
61 const OUString& rLName,
62 const uno::Reference< xml::sax::XAttributeList >& xAttrList,
63 ScMyImpCellRangeSource* pCellRangeSource ) :
64 SvXMLImportContext( rImport, nPrfx, rLName )
66 if( !xAttrList.is() ) return;
68 sal_Int16 nAttrCount = xAttrList->getLength();
69 const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetTableCellRangeSourceAttrTokenMap();
71 for( sal_Int16 nIndex = 0; nIndex < nAttrCount; ++nIndex )
73 const rtl::OUString& sAttrName(xAttrList->getNameByIndex( nIndex ));
74 const OUString& sValue(xAttrList->getValueByIndex( nIndex ));
75 OUString aLocalName;
76 USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
78 switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
80 case XML_TOK_TABLE_CELL_RANGE_SOURCE_ATTR_NAME:
81 pCellRangeSource->sSourceStr = sValue;
82 break;
83 case XML_TOK_TABLE_CELL_RANGE_SOURCE_ATTR_FILTER_NAME:
84 pCellRangeSource->sFilterName = sValue;
85 break;
86 case XML_TOK_TABLE_CELL_RANGE_SOURCE_ATTR_FILTER_OPTIONS:
87 pCellRangeSource->sFilterOptions = sValue;
88 break;
89 case XML_TOK_TABLE_CELL_RANGE_SOURCE_ATTR_HREF:
90 pCellRangeSource->sURL = GetScImport().GetAbsoluteReference(sValue);
91 break;
92 case XML_TOK_TABLE_CELL_RANGE_SOURCE_ATTR_LAST_COLUMN:
94 sal_Int32 nValue;
95 if( SvXMLUnitConverter::convertNumber( nValue, sValue, 1 ) )
96 pCellRangeSource->nColumns = nValue;
97 else
98 pCellRangeSource->nColumns = 1;
100 break;
101 case XML_TOK_TABLE_CELL_RANGE_SOURCE_ATTR_LAST_ROW:
103 sal_Int32 nValue;
104 if( SvXMLUnitConverter::convertNumber( nValue, sValue, 1 ) )
105 pCellRangeSource->nRows = nValue;
106 else
107 pCellRangeSource->nRows = 1;
109 break;
110 case XML_TOK_TABLE_CELL_RANGE_SOURCE_ATTR_REFRESH_DELAY:
112 double fTime;
113 if( SvXMLUnitConverter::convertTime( fTime, sValue ) )
114 pCellRangeSource->nRefresh = Max( (sal_Int32)(fTime * 86400.0), (sal_Int32)0 );
116 break;
121 ScXMLCellRangeSourceContext::~ScXMLCellRangeSourceContext()
125 SvXMLImportContext *ScXMLCellRangeSourceContext::CreateChildContext(
126 USHORT nPrefix,
127 const OUString& rLName,
128 const uno::Reference< xml::sax::XAttributeList>& /* xAttrList */ )
130 return new SvXMLImportContext( GetImport(), nPrefix, rLName );
133 void ScXMLCellRangeSourceContext::EndElement()