LibreOffice Module sc (master)  1
datastreamimport.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 
10 #include "datastreamimport.hxx"
11 #include "xmlimprt.hxx"
12 
13 #include <rangeutl.hxx>
14 #include <importfilterdata.hxx>
15 #include <xmloff/xmlnamespace.hxx>
16 #include <xmloff/xmltoken.hxx>
17 #include <formula/grammar.hxx>
18 
19 using namespace com::sun::star;
20 using namespace xmloff::token;
21 
23  ScXMLImport& rImport,
25  ScXMLImportContext(rImport),
26  mbRefreshOnEmpty(false),
27  meInsertPos(sc::ImportPostProcessData::DataStream::InsertBottom)
28 {
29  if ( !rAttrList.is() )
30  return;
31 
32  for (auto &aIter : *rAttrList)
33  {
34  switch ( aIter.getToken() )
35  {
36  case XML_ELEMENT( XLINK, XML_HREF ):
37  maURL = GetScImport().GetAbsoluteReference( aIter.toString() );
38  break;
40  {
42  sal_Int32 nOffset = 0;
44  maRange, aIter.toString(), pDoc, formula::FormulaGrammar::CONV_OOO, nOffset))
46  }
47  break;
48  case XML_ELEMENT( CALC_EXT, XML_EMPTY_LINE_REFRESH ):
50  break;
51  case XML_ELEMENT( CALC_EXT, XML_INSERTION_POSITION ):
52  meInsertPos = IsXMLToken( aIter, XML_TOP ) ?
55  break;
56  default:
57  ;
58  }
59  }
60 }
61 
63 
64 void SAL_CALL ScXMLDataStreamContext::endFastElement( sal_Int32 /*nElement*/ )
65 {
66  if (!maRange.IsValid())
67  // Range must be valid.
68  return;
69 
71  if (!pData)
72  return;
73 
76 
77  rData.maURL = maURL;
78  rData.maRange = maRange;
80  rData.meInsertPos = meInsertPos;
81 }
82 
83 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Data stream data needs to be post-processed because it requires ScDocShell instance which is not avai...
static bool GetRangeFromString(ScRange &rRange, const OUString &rRangeStr, const ScDocument *pDocument, formula::FormulaGrammar::AddressConvention eConv, sal_Int32 &nOffset, sal_Unicode cSeparator= ' ', sal_Unicode cQuote= '\'')
bool IsXMLToken(const OUString &rString, enum XMLTokenEnum eToken)
std::unique_ptr< ContentProperties > pData
ScDocument * GetDocument()
Definition: xmlimprt.hxx:296
Stores data imported from the file that need to be processed at the end of the import process...
const ContentProperties & rData
XML_EMPTY_LINE_REFRESH
XML_INSERTION_POSITION
std::unique_ptr< DataStream > mpDataStream
This class exists only to provide GetScImport() to its derived classes.
virtual void SAL_CALL endFastElement(sal_Int32 nElement) override
XML_TOP
XML_HREF
ScXMLImport & GetScImport()
void SetInvalid()
Definition: address.hxx:542
bool IsValid() const
Definition: address.hxx:547
TABLE
OUString GetAbsoluteReference(const OUString &rValue) const
ScXMLDataStreamContext(ScXMLImport &rImport, const rtl::Reference< sax_fastparser::FastAttributeList > &rAttrList)
#define XML_ELEMENT(prefix, name)
XML_TARGET_RANGE_ADDRESS
virtual ~ScXMLDataStreamContext() override
XML_TRUE
sc::ImportPostProcessData::DataStream::InsertPos meInsertPos
sc::ImportPostProcessData * GetPostProcessData()
Definition: xmlimprt.hxx:321