Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : :
31 : :
32 : : //___________________________________________________________________
33 : : #include "XMLCellRangeSourceContext.hxx"
34 : :
35 : : #include <sax/tools/converter.hxx>
36 : :
37 : : #include <xmloff/nmspmap.hxx>
38 : : #include "xmlimprt.hxx"
39 : :
40 : : using ::rtl::OUString;
41 : : using namespace ::com::sun::star;
42 : :
43 : :
44 : : //___________________________________________________________________
45 : :
46 : 0 : ScMyImpCellRangeSource::ScMyImpCellRangeSource() :
47 : : nColumns( 0 ),
48 : : nRows( 0 ),
49 : 0 : nRefresh( 0 )
50 : : {
51 : 0 : }
52 : :
53 : :
54 : : //___________________________________________________________________
55 : :
56 : 0 : ScXMLCellRangeSourceContext::ScXMLCellRangeSourceContext(
57 : : ScXMLImport& rImport,
58 : : sal_uInt16 nPrfx,
59 : : const OUString& rLName,
60 : : const uno::Reference< xml::sax::XAttributeList >& xAttrList,
61 : : ScMyImpCellRangeSource* pCellRangeSource ) :
62 : 0 : SvXMLImportContext( rImport, nPrfx, rLName )
63 : : {
64 [ # # ]: 0 : if( !xAttrList.is() ) return;
65 : :
66 [ # # ][ # # ]: 0 : sal_Int16 nAttrCount = xAttrList->getLength();
67 [ # # ]: 0 : const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetTableCellRangeSourceAttrTokenMap();
68 : :
69 [ # # ]: 0 : for( sal_Int16 nIndex = 0; nIndex < nAttrCount; ++nIndex )
70 : : {
71 [ # # ][ # # ]: 0 : const rtl::OUString& sAttrName(xAttrList->getNameByIndex( nIndex ));
72 [ # # ][ # # ]: 0 : const OUString& sValue(xAttrList->getValueByIndex( nIndex ));
73 : 0 : OUString aLocalName;
74 [ # # ]: 0 : sal_uInt16 nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
75 : :
76 [ # # ][ # # : 0 : switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
# # # # #
# ]
77 : : {
78 : : case XML_TOK_TABLE_CELL_RANGE_SOURCE_ATTR_NAME:
79 : 0 : pCellRangeSource->sSourceStr = sValue;
80 : 0 : break;
81 : : case XML_TOK_TABLE_CELL_RANGE_SOURCE_ATTR_FILTER_NAME:
82 : 0 : pCellRangeSource->sFilterName = sValue;
83 : 0 : break;
84 : : case XML_TOK_TABLE_CELL_RANGE_SOURCE_ATTR_FILTER_OPTIONS:
85 : 0 : pCellRangeSource->sFilterOptions = sValue;
86 : 0 : break;
87 : : case XML_TOK_TABLE_CELL_RANGE_SOURCE_ATTR_HREF:
88 [ # # ]: 0 : pCellRangeSource->sURL = GetScImport().GetAbsoluteReference(sValue);
89 : 0 : break;
90 : : case XML_TOK_TABLE_CELL_RANGE_SOURCE_ATTR_LAST_COLUMN:
91 : : {
92 : : sal_Int32 nValue;
93 [ # # ][ # # ]: 0 : if (::sax::Converter::convertNumber( nValue, sValue, 1 ))
94 : 0 : pCellRangeSource->nColumns = nValue;
95 : : else
96 : 0 : pCellRangeSource->nColumns = 1;
97 : : }
98 : 0 : break;
99 : : case XML_TOK_TABLE_CELL_RANGE_SOURCE_ATTR_LAST_ROW:
100 : : {
101 : : sal_Int32 nValue;
102 [ # # ][ # # ]: 0 : if (::sax::Converter::convertNumber( nValue, sValue, 1 ))
103 : 0 : pCellRangeSource->nRows = nValue;
104 : : else
105 : 0 : pCellRangeSource->nRows = 1;
106 : : }
107 : 0 : break;
108 : : case XML_TOK_TABLE_CELL_RANGE_SOURCE_ATTR_REFRESH_DELAY:
109 : : {
110 : : double fTime;
111 [ # # ][ # # ]: 0 : if (::sax::Converter::convertDuration( fTime, sValue ))
112 : 0 : pCellRangeSource->nRefresh = Max( (sal_Int32)(fTime * 86400.0), (sal_Int32)0 );
113 : : }
114 : 0 : break;
115 : : }
116 : 0 : }
117 : : }
118 : :
119 : 0 : ScXMLCellRangeSourceContext::~ScXMLCellRangeSourceContext()
120 : : {
121 [ # # ]: 0 : }
122 : :
123 : 0 : SvXMLImportContext *ScXMLCellRangeSourceContext::CreateChildContext(
124 : : sal_uInt16 nPrefix,
125 : : const OUString& rLName,
126 : : const uno::Reference< xml::sax::XAttributeList>& /* xAttrList */ )
127 : : {
128 [ # # ]: 0 : return new SvXMLImportContext( GetImport(), nPrefix, rLName );
129 : : }
130 : :
131 : 0 : void ScXMLCellRangeSourceContext::EndElement()
132 : : {
133 : 0 : }
134 : :
135 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|