1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_SC_SOURCE_FILTER_XML_XMLNEXPI_HXX
20 #define INCLUDED_SC_SOURCE_FILTER_XML_XMLNEXPI_HXX
22 #include <xmloff/xmlictxt.hxx>
23 #include <xmloff/xmlimp.hxx>
24 #include "address.hxx"
25 #include "xmlimprt.hxx"
27 #include <boost/shared_ptr.hpp>
29 struct ScMyNamedExpression
;
32 class ScXMLNamedExpressionsContext
: public SvXMLImportContext
34 const ScXMLImport
& GetScImport() const { return static_cast<const ScXMLImport
&>(GetImport()); }
35 ScXMLImport
& GetScImport() { return static_cast<ScXMLImport
&>(GetImport()); }
42 virtual ~Inserter() {}
43 virtual void insert(ScMyNamedExpression
* pExp
) = 0;
47 * Global named expressions are inserted into ScXMLImport, which does the
48 * bulk insertion at the end of the import.
50 class GlobalInserter
: public Inserter
53 GlobalInserter(ScXMLImport
& rImport
);
54 virtual void insert(ScMyNamedExpression
* pExp
) SAL_OVERRIDE
;
56 ScXMLImport
& mrImport
;
60 * Sheet local named expressions are inserted directly into ScRangeName
61 * instance of that sheet. TODO: the global ones should be inserted the
62 * same way for efficiency.
64 class SheetLocalInserter
: public Inserter
67 SheetLocalInserter(ScXMLImport
& rImport
, SCTAB nTab
);
68 virtual void insert(ScMyNamedExpression
* pExp
) SAL_OVERRIDE
;
70 ScXMLImport
& mrImport
;
74 ScXMLNamedExpressionsContext(
75 ScXMLImport
& rImport
, sal_uInt16 nPrfx
, const OUString
& rLName
,
76 const ::com::sun::star::uno::Reference
<
77 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
78 Inserter
* pInserter
);
80 virtual ~ScXMLNamedExpressionsContext();
82 virtual SvXMLImportContext
*CreateChildContext( sal_uInt16 nPrefix
,
83 const OUString
& rLocalName
,
84 const ::com::sun::star::uno::Reference
<
85 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
) SAL_OVERRIDE
;
87 virtual void EndElement() SAL_OVERRIDE
;
90 ::boost::shared_ptr
<Inserter
> mpInserter
;
93 class ScXMLNamedRangeContext
: public SvXMLImportContext
95 const ScXMLImport
& GetScImport() const { return static_cast<const ScXMLImport
&>(GetImport()); }
96 ScXMLImport
& GetScImport() { return static_cast<ScXMLImport
&>(GetImport()); }
100 ScXMLNamedRangeContext(
101 ScXMLImport
& rImport
, sal_uInt16 nPrfx
, const OUString
& rLName
,
102 const ::com::sun::star::uno::Reference
<
103 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
104 ScXMLNamedExpressionsContext::Inserter
* pInserter
);
106 virtual ~ScXMLNamedRangeContext();
108 virtual SvXMLImportContext
*CreateChildContext( sal_uInt16 nPrefix
,
109 const OUString
& rLocalName
,
110 const ::com::sun::star::uno::Reference
<
111 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
) SAL_OVERRIDE
;
113 virtual void EndElement() SAL_OVERRIDE
;
116 ScXMLNamedExpressionsContext::Inserter
* mpInserter
;
119 class ScXMLNamedExpressionContext
: public SvXMLImportContext
121 const ScXMLImport
& GetScImport() const { return static_cast<const ScXMLImport
&>(GetImport()); }
122 ScXMLImport
& GetScImport() { return static_cast<ScXMLImport
&>(GetImport()); }
126 ScXMLNamedExpressionContext(
127 ScXMLImport
& rImport
, sal_uInt16 nPrfx
, const OUString
& rLName
,
128 const ::com::sun::star::uno::Reference
<
129 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
130 ScXMLNamedExpressionsContext::Inserter
* pInserter
);
132 virtual ~ScXMLNamedExpressionContext();
134 virtual SvXMLImportContext
*CreateChildContext( sal_uInt16 nPrefix
,
135 const OUString
& rLocalName
,
136 const ::com::sun::star::uno::Reference
<
137 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
) SAL_OVERRIDE
;
139 virtual void EndElement() SAL_OVERRIDE
;
142 ScXMLNamedExpressionsContext::Inserter
* mpInserter
;
147 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */