Line data Source code
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 : #ifndef INCLUDED_SC_SOURCE_FILTER_XML_XMLNEXPI_HXX
20 : #define INCLUDED_SC_SOURCE_FILTER_XML_XMLNEXPI_HXX
21 :
22 : #include <xmloff/xmlictxt.hxx>
23 : #include <xmloff/xmlimp.hxx>
24 : #include "address.hxx"
25 : #include "xmlimprt.hxx"
26 :
27 : #include <boost/shared_ptr.hpp>
28 :
29 : struct ScMyNamedExpression;
30 : class ScRangeName;
31 :
32 : class ScXMLNamedExpressionsContext : public SvXMLImportContext
33 : {
34 : const ScXMLImport& GetScImport() const { return static_cast<const ScXMLImport&>(GetImport()); }
35 472 : ScXMLImport& GetScImport() { return static_cast<ScXMLImport&>(GetImport()); }
36 :
37 : public:
38 :
39 224 : class Inserter
40 : {
41 : public:
42 224 : virtual ~Inserter() {}
43 : virtual void insert(ScMyNamedExpression* pExp) = 0;
44 : };
45 :
46 : /**
47 : * Global named expressions are inserted into ScXMLImport, which does the
48 : * bulk insertion at the end of the import.
49 : */
50 432 : class GlobalInserter : public Inserter
51 : {
52 : public:
53 : GlobalInserter(ScXMLImport& rImport);
54 : virtual void insert(ScMyNamedExpression* pExp) SAL_OVERRIDE;
55 : private:
56 : ScXMLImport& mrImport;
57 : };
58 :
59 : /**
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.
63 : */
64 16 : class SheetLocalInserter : public Inserter
65 : {
66 : public:
67 : SheetLocalInserter(ScXMLImport& rImport, SCTAB nTab);
68 : virtual void insert(ScMyNamedExpression* pExp) SAL_OVERRIDE;
69 : private:
70 : ScXMLImport& mrImport;
71 : SCTAB mnTab;
72 : };
73 :
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 );
79 :
80 : virtual ~ScXMLNamedExpressionsContext();
81 :
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;
86 :
87 : virtual void EndElement() SAL_OVERRIDE;
88 :
89 : private:
90 : ::boost::shared_ptr<Inserter> mpInserter;
91 : };
92 :
93 : class ScXMLNamedRangeContext : public SvXMLImportContext
94 : {
95 : const ScXMLImport& GetScImport() const { return static_cast<const ScXMLImport&>(GetImport()); }
96 370 : ScXMLImport& GetScImport() { return static_cast<ScXMLImport&>(GetImport()); }
97 :
98 : public:
99 :
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 );
105 :
106 : virtual ~ScXMLNamedRangeContext();
107 :
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;
112 :
113 : virtual void EndElement() SAL_OVERRIDE;
114 :
115 : private:
116 : ScXMLNamedExpressionsContext::Inserter* mpInserter;
117 : };
118 :
119 : class ScXMLNamedExpressionContext : public SvXMLImportContext
120 : {
121 : const ScXMLImport& GetScImport() const { return static_cast<const ScXMLImport&>(GetImport()); }
122 250 : ScXMLImport& GetScImport() { return static_cast<ScXMLImport&>(GetImport()); }
123 :
124 : public:
125 :
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 );
131 :
132 : virtual ~ScXMLNamedExpressionContext();
133 :
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;
138 :
139 : virtual void EndElement() SAL_OVERRIDE;
140 :
141 : private:
142 : ScXMLNamedExpressionsContext::Inserter* mpInserter;
143 : };
144 :
145 : #endif
146 :
147 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|