1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef SC_XMLDDELINKSCONTEXT_HXX
25 #define SC_XMLDDELINKSCONTEXT_HXX
26 
27 #include <xmloff/xmlictxt.hxx>
28 
29 #include <list>
30 
31 class ScXMLImport;
32 
33 class ScXMLDDELinksContext : public SvXMLImportContext
34 {
GetScImport() const35 	const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
GetScImport()36 	ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
37 public:
38 	ScXMLDDELinksContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
39 						const ::rtl::OUString& rLName,
40 						const ::com::sun::star::uno::Reference<
41 										::com::sun::star::xml::sax::XAttributeList>& xAttrList);
42 
43 	virtual ~ScXMLDDELinksContext();
44 
45 	virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
46 									 const ::rtl::OUString& rLocalName,
47 									 const ::com::sun::star::uno::Reference<
48 									  	::com::sun::star::xml::sax::XAttributeList>& xAttrList );
49 
50 	virtual void EndElement();
51 };
52 
53 struct ScDDELinkCell
54 {
55 	rtl::OUString sValue;
56 	double fValue;
57 	sal_Bool bString;
58 	sal_Bool bEmpty;
59 };
60 
61 typedef std::list<ScDDELinkCell> ScDDELinkCells;
62 
63 class ScXMLDDELinkContext : public SvXMLImportContext
64 {
65 	ScDDELinkCells	aDDELinkTable;
66 	ScDDELinkCells	aDDELinkRow;
67 	rtl::OUString	sApplication;
68 	rtl::OUString	sTopic;
69 	rtl::OUString	sItem;
70 	sal_Int32		nPosition;
71 	sal_Int32		nColumns;
72 	sal_Int32		nRows;
73 	sal_uInt8		nMode;
74 
GetScImport() const75 	const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
GetScImport()76 	ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
77 public:
78 	ScXMLDDELinkContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
79 						const ::rtl::OUString& rLName,
80 						const ::com::sun::star::uno::Reference<
81 										::com::sun::star::xml::sax::XAttributeList>& xAttrList);
82 
83 	virtual ~ScXMLDDELinkContext();
84 
85 	virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
86 									 const ::rtl::OUString& rLocalName,
87 									 const ::com::sun::star::uno::Reference<
88 									  	::com::sun::star::xml::sax::XAttributeList>& xAttrList );
89 
SetApplication(const rtl::OUString & sValue)90 	void SetApplication(const rtl::OUString& sValue) { sApplication = sValue; }
SetTopic(const rtl::OUString & sValue)91 	void SetTopic(const rtl::OUString& sValue) { sTopic = sValue; }
SetItem(const rtl::OUString & sValue)92 	void SetItem(const rtl::OUString& sValue) { sItem = sValue; }
SetMode(const sal_uInt8 nValue)93 	void SetMode(const sal_uInt8 nValue) { nMode = nValue; }
94 	void CreateDDELink();
AddColumns(const sal_Int32 nValue)95 	void AddColumns(const sal_Int32 nValue) { nColumns += nValue; }
AddRows(const sal_Int32 nValue)96 	void AddRows(const sal_Int32 nValue) { nRows += nValue; }
97 	void AddCellToRow(const ScDDELinkCell& aCell);
98 	void AddRowsToTable(const sal_Int32 nRows);
99 
100 	virtual void EndElement();
101 };
102 
103 class ScXMLDDESourceContext : public SvXMLImportContext
104 {
105 	ScXMLDDELinkContext* pDDELink;
106 
GetScImport() const107 	const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
GetScImport()108 	ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
109 public:
110 	ScXMLDDESourceContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
111 						const ::rtl::OUString& rLName,
112 						const ::com::sun::star::uno::Reference<
113 										::com::sun::star::xml::sax::XAttributeList>& xAttrList,
114 						ScXMLDDELinkContext* pDDELink);
115 
116 	virtual ~ScXMLDDESourceContext();
117 
118 	virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
119 									 const ::rtl::OUString& rLocalName,
120 									 const ::com::sun::star::uno::Reference<
121 									  	::com::sun::star::xml::sax::XAttributeList>& xAttrList );
122 
123 	virtual void EndElement();
124 };
125 
126 class ScXMLDDETableContext : public SvXMLImportContext
127 {
128 	ScXMLDDELinkContext* pDDELink;
129 
GetScImport() const130 	const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
GetScImport()131 	ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
132 public:
133 	ScXMLDDETableContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
134 						const ::rtl::OUString& rLName,
135 						const ::com::sun::star::uno::Reference<
136 										::com::sun::star::xml::sax::XAttributeList>& xAttrList,
137 						ScXMLDDELinkContext* pDDELink);
138 
139 	virtual ~ScXMLDDETableContext();
140 
141 	virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
142 									 const ::rtl::OUString& rLocalName,
143 									 const ::com::sun::star::uno::Reference<
144 									  	::com::sun::star::xml::sax::XAttributeList>& xAttrList );
145 
146 	virtual void EndElement();
147 };
148 
149 class ScXMLDDEColumnContext : public SvXMLImportContext
150 {
151 	ScXMLDDELinkContext* pDDELink;
152 
GetScImport() const153 	const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
GetScImport()154 	ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
155 public:
156 	ScXMLDDEColumnContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
157 						const ::rtl::OUString& rLName,
158 						const ::com::sun::star::uno::Reference<
159 										::com::sun::star::xml::sax::XAttributeList>& xAttrList,
160 						ScXMLDDELinkContext* pDDELink);
161 
162 	virtual ~ScXMLDDEColumnContext();
163 
164 	virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
165 									 const ::rtl::OUString& rLocalName,
166 									 const ::com::sun::star::uno::Reference<
167 									  	::com::sun::star::xml::sax::XAttributeList>& xAttrList );
168 
169 	virtual void EndElement();
170 };
171 
172 class ScXMLDDERowContext : public SvXMLImportContext
173 {
174 	ScXMLDDELinkContext*	pDDELink;
175 	sal_Int32 				nRows;
176 
GetScImport() const177 	const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
GetScImport()178 	ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
179 public:
180 	ScXMLDDERowContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
181 						const ::rtl::OUString& rLName,
182 						const ::com::sun::star::uno::Reference<
183 										::com::sun::star::xml::sax::XAttributeList>& xAttrList,
184 						ScXMLDDELinkContext* pDDELink);
185 
186 	virtual ~ScXMLDDERowContext();
187 
188 	virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
189 									 const ::rtl::OUString& rLocalName,
190 									 const ::com::sun::star::uno::Reference<
191 									  	::com::sun::star::xml::sax::XAttributeList>& xAttrList );
192 
193 	virtual void EndElement();
194 };
195 
196 class ScXMLDDECellContext : public SvXMLImportContext
197 {
198 	rtl::OUString	sValue;
199 	double			fValue;
200 	sal_Int32		nCells;
201 	sal_Bool		bString;
202 	sal_Bool		bString2;
203 	sal_Bool		bEmpty;
204 
205 	ScXMLDDELinkContext* pDDELink;
206 
GetScImport() const207 	const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
GetScImport()208 	ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
209 public:
210 	ScXMLDDECellContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
211 						const ::rtl::OUString& rLName,
212 						const ::com::sun::star::uno::Reference<
213 										::com::sun::star::xml::sax::XAttributeList>& xAttrList,
214 						ScXMLDDELinkContext* pDDELink);
215 
216 	virtual ~ScXMLDDECellContext();
217 
218 	virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
219 									 const ::rtl::OUString& rLocalName,
220 									 const ::com::sun::star::uno::Reference<
221 									  	::com::sun::star::xml::sax::XAttributeList>& xAttrList );
222 
223 	virtual void EndElement();
224 };
225 
226 #endif
227