LibreOffice Module sc (master) 1
xmlnexpi.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
20#include "xmlnexpi.hxx"
21#include "xmlimprt.hxx"
22#include <document.hxx>
23
25#include <xmloff/xmltoken.hxx>
26
27using namespace com::sun::star;
28using namespace xmloff::token;
29
31
33{
34 mrImport.AddNamedExpression(std::move(aExp));
35}
36
38 mrImport(rImport), mnTab(nTab) {}
39
41{
42 mrImport.AddNamedExpression(mnTab, std::move(aExp));
43}
44
46 ScXMLImport& rImport,
47 std::shared_ptr<Inserter> pInserter ) :
48 ScXMLImportContext( rImport ),
49 mpInserter(std::move(pInserter))
50{
51 rImport.LockSolarMutex();
52}
53
55{
57}
58
59uno::Reference< xml::sax::XFastContextHandler > SAL_CALL ScXMLNamedExpressionsContext::createFastChildContext(
60 sal_Int32 nElement, const uno::Reference< xml::sax::XFastAttributeList >& xAttrList )
61{
62 SvXMLImportContext *pContext(nullptr);
65
66 switch (nElement)
67 {
69 pContext = new ScXMLNamedRangeContext(
70 GetScImport(), pAttribList, mpInserter.get() );
71 break;
73 pContext = new ScXMLNamedExpressionContext(
74 GetScImport(), pAttribList, mpInserter.get() );
75 break;
76 }
77
78 return pContext;
79}
80
82 ScXMLImport& rImport,
85 ScXMLImportContext( rImport )
86{
87 if (!pInserter)
88 return;
89
90 ScMyNamedExpression aNamedExpression;
91 // A simple table:cell-range-address is not a formula expression, stored
92 // without [] brackets but with dot, .A1
94 GetScImport().GetDocument()->GetStorageGrammar(),
96
97 if ( rAttrList.is() )
98 {
99 for (auto &aIter : *rAttrList)
100 {
101 switch (aIter.getToken())
102 {
103 case XML_ELEMENT( TABLE, XML_NAME ):
104 aNamedExpression.sName = aIter.toString();
105 break;
107 aNamedExpression.sContent = aIter.toString();
108 break;
110 aNamedExpression.sBaseCellAddress = aIter.toString();
111 break;
113 aNamedExpression.sRangeType = aIter.toString();
114 break;
115 }
116 }
117 }
118 aNamedExpression.bIsExpression = false;
119 pInserter->insert(std::move(aNamedExpression));
120}
121
123{
124}
125
127 ScXMLImport& rImport,
130 ScXMLImportContext( rImport )
131{
132 if (!pInserter)
133 return;
134
135 ScMyNamedExpression aNamedExpression;
136
137 if ( rAttrList.is() )
138 {
139 for (auto &aIter : *rAttrList)
140 {
141 switch (aIter.getToken())
142 {
143 case XML_ELEMENT( TABLE, XML_NAME ):
144 aNamedExpression.sName = aIter.toString();
145 break;
148 aNamedExpression.sContent, aNamedExpression.sContentNmsp,
149 aNamedExpression.eGrammar, aIter.toString() );
150 break;
152 aNamedExpression.sBaseCellAddress = aIter.toString();
153 break;
154 }
155 }
156 }
157 aNamedExpression.bIsExpression = true;
158 pInserter->insert(std::move(aNamedExpression));
159}
160
162{
163}
164
165/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
This class exists only to provide GetScImport() to its derived classes.
ScXMLImport & GetScImport()
void LockSolarMutex()
Definition: xmlimprt.cxx:1507
void UnlockSolarMutex()
Definition: xmlimprt.cxx:1525
void ExtractFormulaNamespaceGrammar(OUString &rFormula, OUString &rFormulaNmsp, ::formula::FormulaGrammar::Grammar &reGrammar, const OUString &rAttrValue, bool bRestrictToExternalNmsp=false) const
Extracts the formula string, the formula grammar namespace URL, and a grammar enum value from the pas...
Definition: xmlimprt.cxx:1568
virtual ~ScXMLNamedExpressionContext() override
Definition: xmlnexpi.cxx:161
ScXMLNamedExpressionContext(ScXMLImport &rImport, const rtl::Reference< sax_fastparser::FastAttributeList > &rAttrList, ScXMLNamedExpressionsContext::Inserter *pInserter)
Definition: xmlnexpi.cxx:126
virtual void insert(ScMyNamedExpression aExp) override
Definition: xmlnexpi.cxx:32
virtual void insert(ScMyNamedExpression aExp)=0
SheetLocalInserter(ScXMLImport &rImport, SCTAB nTab)
Definition: xmlnexpi.cxx:37
virtual void insert(ScMyNamedExpression aExp) override
Definition: xmlnexpi.cxx:40
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
Definition: xmlnexpi.cxx:59
ScXMLNamedExpressionsContext(ScXMLImport &rImport, std::shared_ptr< Inserter > pInserter)
Definition: xmlnexpi.cxx:45
virtual ~ScXMLNamedExpressionsContext() override
Definition: xmlnexpi.cxx:54
std::shared_ptr< Inserter > mpInserter
Definition: xmlnexpi.hxx:79
virtual ~ScXMLNamedRangeContext() override
Definition: xmlnexpi.cxx:122
ScXMLNamedRangeContext(ScXMLImport &rImport, const rtl::Reference< sax_fastparser::FastAttributeList > &rAttrList, ScXMLNamedExpressionsContext::Inserter *pInserter)
Definition: xmlnexpi.cxx:81
SvXMLImport & mrImport
static Grammar mergeToGrammar(const Grammar eGrammar, const AddressConvention eConv)
TABLE
FastAttributeList & castToFastAttributeList(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
XML_CELL_RANGE_ADDRESS
XML_NAMED_EXPRESSION
XML_RANGE_USABLE_AS
XML_EXPRESSION
XML_NAME
XML_BASE_CELL_ADDRESS
XML_NAMED_RANGE
OUString sBaseCellAddress
Definition: xmlimprt.hxx:70
formula::FormulaGrammar::Grammar eGrammar
Definition: xmlimprt.hxx:72
OUString sContentNmsp
Definition: xmlimprt.hxx:69
OUString sRangeType
Definition: xmlimprt.hxx:71
sal_Int16 SCTAB
Definition: types.hxx:22
#define XML_ELEMENT(prefix, name)