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  assert(pDoc);
43  sal_Int32 nOffset = 0;
45  maRange, aIter.toString(), *pDoc, formula::FormulaGrammar::CONV_OOO, nOffset))
47  }
48  break;
49  case XML_ELEMENT( CALC_EXT, XML_EMPTY_LINE_REFRESH ):
51  break;
52  case XML_ELEMENT( CALC_EXT, XML_INSERTION_POSITION ):
53  meInsertPos = IsXMLToken( aIter, XML_TOP ) ?
56  break;
57  default:
58  ;
59  }
60  }
61 }
62 
64 
65 void SAL_CALL ScXMLDataStreamContext::endFastElement( sal_Int32 /*nElement*/ )
66 {
67  if (!maRange.IsValid())
68  // Range must be valid.
69  return;
70 
72  if (!pData)
73  return;
74 
77 
78  rData.maURL = maURL;
79  rData.maRange = maRange;
81  rData.meInsertPos = meInsertPos;
82 }
83 
84 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Data stream data needs to be post-processed because it requires ScDocShell instance which is not avai...
std::unique_ptr< ContentProperties > pData
ScDocument * GetDocument()
Definition: xmlimprt.hxx:205
Stores data imported from the file that need to be processed at the end of the import process...
const ContentProperties & rData
bool IsXMLToken(std::u16string_view rString, enum XMLTokenEnum eToken)
XML_EMPTY_LINE_REFRESH
XML_INSERTION_POSITION
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
std::unique_ptr< DataStream > mpDataStream
static bool GetRangeFromString(ScRange &rRange, const OUString &rRangeStr, const ScDocument &rDocument, formula::FormulaGrammar::AddressConvention eConv, sal_Int32 &nOffset, sal_Unicode cSeparator= ' ', sal_Unicode cQuote= '\'')
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:541
bool IsValid() const
Definition: address.hxx:546
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:222