LibreOffice Module sc (master)  1
XMLCellRangeSourceContext.cxx
Go to the documentation of this file.
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 
21 
22 #include <sax/tools/converter.hxx>
23 
24 #include "xmlimprt.hxx"
25 #include <xmloff/xmlnamespace.hxx>
26 
27 using namespace ::com::sun::star;
28 using namespace xmloff::token;
29 
31  nColumns( 0 ),
32  nRows( 0 ),
33  nRefresh( 0 )
34 {
35 }
36 
38  ScXMLImport& rImport,
40  ScMyImpCellRangeSource* pCellRangeSource ) :
41  ScXMLImportContext( rImport )
42 {
43  if ( !rAttrList.is() )
44  return;
45 
46  for (auto &aIter : *rAttrList)
47  {
48  switch (aIter.getToken())
49  {
50  case XML_ELEMENT( TABLE, XML_NAME ):
51  pCellRangeSource->sSourceStr = aIter.toString();
52  break;
54  pCellRangeSource->sFilterName = aIter.toString();
55  break;
57  pCellRangeSource->sFilterOptions = aIter.toString();
58  break;
59  case XML_ELEMENT( XLINK, XML_HREF ):
60  pCellRangeSource->sURL = GetScImport().GetAbsoluteReference(aIter.toString());
61  break;
63  {
64  sal_Int32 nValue;
65  if (::sax::Converter::convertNumber( nValue, aIter.toString(), 1 ))
66  pCellRangeSource->nColumns = nValue;
67  else
68  pCellRangeSource->nColumns = 1;
69  }
70  break;
72  {
73  sal_Int32 nValue;
74  if (::sax::Converter::convertNumber( nValue, aIter.toString(), 1 ))
75  pCellRangeSource->nRows = nValue;
76  else
77  pCellRangeSource->nRows = 1;
78  }
79  break;
81  {
82  double fTime;
83  if (::sax::Converter::convertDuration( fTime, aIter.toString() ))
84  pCellRangeSource->nRefresh = std::max( static_cast<sal_Int32>(fTime * 86400.0), sal_Int32(0) );
85  }
86  break;
87  }
88  }
89 }
90 
92 {
93 }
94 
95 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
ScXMLCellRangeSourceContext(ScXMLImport &rImport, const rtl::Reference< sax_fastparser::FastAttributeList > &rAttrList, ScMyImpCellRangeSource *pCellRangeSource)
XML_NAME
XML_FILTER_OPTIONS
XML_LAST_ROW_SPANNED
This class exists only to provide GetScImport() to its derived classes.
XML_REFRESH_DELAY
XML_HREF
static void convertDuration(OUStringBuffer &rBuffer, const double fTime)
ScXMLImport & GetScImport()
TABLE
OUString GetAbsoluteReference(const OUString &rValue) const
XML_FILTER_NAME
#define XML_ELEMENT(prefix, name)
sal_Int16 nValue
static bool convertNumber(sal_Int32 &rValue, std::u16string_view aString, sal_Int32 nMin=SAL_MIN_INT32, sal_Int32 nMax=SAL_MAX_INT32)
XML_LAST_COLUMN_SPANNED