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>
16#include <xmloff/xmltoken.hxx>
17#include <formula/grammar.hxx>
18
19using namespace com::sun::star;
20using 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
65void 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
75 pData->mpDataStream.reset(new sc::ImportPostProcessData::DataStream);
76 sc::ImportPostProcessData::DataStream& rData = *pData->mpDataStream;
77
78 rData.maURL = maURL;
79 rData.maRange = maRange;
82}
83
84/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static bool GetRangeFromString(ScRange &rRange, std::u16string_view rRangeStr, const ScDocument &rDocument, formula::FormulaGrammar::AddressConvention eConv, sal_Int32 &nOffset, sal_Unicode cSeparator=' ', sal_Unicode cQuote='\'')
void SetInvalid()
Definition: address.hxx:539
bool IsValid() const
Definition: address.hxx:544
virtual void SAL_CALL endFastElement(sal_Int32 nElement) override
ScXMLDataStreamContext(ScXMLImport &rImport, const rtl::Reference< sax_fastparser::FastAttributeList > &rAttrList)
sc::ImportPostProcessData::DataStream::InsertPos meInsertPos
virtual ~ScXMLDataStreamContext() override
This class exists only to provide GetScImport() to its derived classes.
ScXMLImport & GetScImport()
sc::ImportPostProcessData * GetPostProcessData()
Definition: xmlimprt.hxx:222
ScDocument * GetDocument()
Definition: xmlimprt.hxx:205
std::unique_ptr< sal_Int32[]> pData
TABLE
CAUTION! The following defines must be in the same namespace as the respective type.
Definition: broadcast.cxx:15
XML_INSERTION_POSITION
XML_EMPTY_LINE_REFRESH
XML_HREF
XML_TRUE
XML_TOP
XML_TARGET_RANGE_ADDRESS
bool IsXMLToken(std::u16string_view rString, enum XMLTokenEnum eToken)
Data stream data needs to be post-processed because it requires ScDocShell instance which is not avai...
Stores data imported from the file that need to be processed at the end of the import process.
#define XML_ELEMENT(prefix, name)