1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: XMLCellRangeSourceContext.cxx,v $
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() :
56 //___________________________________________________________________
58 ScXMLCellRangeSourceContext::ScXMLCellRangeSourceContext(
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
));
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
;
83 case XML_TOK_TABLE_CELL_RANGE_SOURCE_ATTR_FILTER_NAME
:
84 pCellRangeSource
->sFilterName
= sValue
;
86 case XML_TOK_TABLE_CELL_RANGE_SOURCE_ATTR_FILTER_OPTIONS
:
87 pCellRangeSource
->sFilterOptions
= sValue
;
89 case XML_TOK_TABLE_CELL_RANGE_SOURCE_ATTR_HREF
:
90 pCellRangeSource
->sURL
= GetScImport().GetAbsoluteReference(sValue
);
92 case XML_TOK_TABLE_CELL_RANGE_SOURCE_ATTR_LAST_COLUMN
:
95 if( SvXMLUnitConverter::convertNumber( nValue
, sValue
, 1 ) )
96 pCellRangeSource
->nColumns
= nValue
;
98 pCellRangeSource
->nColumns
= 1;
101 case XML_TOK_TABLE_CELL_RANGE_SOURCE_ATTR_LAST_ROW
:
104 if( SvXMLUnitConverter::convertNumber( nValue
, sValue
, 1 ) )
105 pCellRangeSource
->nRows
= nValue
;
107 pCellRangeSource
->nRows
= 1;
110 case XML_TOK_TABLE_CELL_RANGE_SOURCE_ATTR_REFRESH_DELAY
:
113 if( SvXMLUnitConverter::convertTime( fTime
, sValue
) )
114 pCellRangeSource
->nRefresh
= Max( (sal_Int32
)(fTime
* 86400.0), (sal_Int32
)0 );
121 ScXMLCellRangeSourceContext::~ScXMLCellRangeSourceContext()
125 SvXMLImportContext
*ScXMLCellRangeSourceContext::CreateChildContext(
127 const OUString
& rLName
,
128 const uno::Reference
< xml::sax::XAttributeList
>& /* xAttrList */ )
130 return new SvXMLImportContext( GetImport(), nPrefix
, rLName
);
133 void ScXMLCellRangeSourceContext::EndElement()