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 :
20 :
21 : #include "XMLTrackedChangesContext.hxx"
22 : #include "xmlimprt.hxx"
23 : #include "xmlconti.hxx"
24 : #include "XMLConverter.hxx"
25 : #include "cell.hxx"
26 : #include "textuno.hxx"
27 : #include "editutil.hxx"
28 : #include <xmloff/xmltoken.hxx>
29 : #include <xmloff/xmlnmspe.hxx>
30 : #include <xmloff/nmspmap.hxx>
31 : #include <xmloff/xmluconv.hxx>
32 : #include <sax/tools/converter.hxx>
33 : #include <svl/zforlist.hxx>
34 : #include <com/sun/star/text/XTextCursor.hpp>
35 : #include <com/sun/star/text/ControlCharacter.hpp>
36 :
37 : using rtl::OUString;
38 : using namespace com::sun::star;
39 : using namespace xmloff::token;
40 :
41 : using rtl::OUString;
42 :
43 : //-----------------------------------------------------------------------------
44 :
45 : class ScXMLChangeInfoContext : public SvXMLImportContext
46 : {
47 : ScMyActionInfo aInfo;
48 : ::rtl::OUStringBuffer sAuthorBuffer;
49 : ::rtl::OUStringBuffer sDateTimeBuffer;
50 : ::rtl::OUStringBuffer sCommentBuffer;
51 : ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper;
52 : sal_uInt32 nParagraphCount;
53 :
54 : const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
55 0 : ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
56 :
57 : public:
58 : ScXMLChangeInfoContext( ScXMLImport& rImport, sal_uInt16 nPrfx, const ::rtl::OUString& rLName,
59 : const ::com::sun::star::uno::Reference<
60 : ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
61 : ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper);
62 : virtual ~ScXMLChangeInfoContext();
63 :
64 : virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
65 : const ::rtl::OUString& rLocalName,
66 : const ::com::sun::star::uno::Reference<
67 : ::com::sun::star::xml::sax::XAttributeList>& xAttrList );
68 :
69 : virtual void EndElement();
70 : };
71 :
72 : //-----------------------------------------------------------------------------
73 :
74 : class ScXMLBigRangeContext : public SvXMLImportContext
75 : {
76 : ScBigRange& rBigRange;
77 :
78 : const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
79 0 : ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
80 :
81 : public:
82 : ScXMLBigRangeContext( ScXMLImport& rImport, sal_uInt16 nPrfx, const ::rtl::OUString& rLName,
83 : const ::com::sun::star::uno::Reference<
84 : ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
85 : ScBigRange& rBigRange);
86 : virtual ~ScXMLBigRangeContext();
87 :
88 : virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
89 : const ::rtl::OUString& rLocalName,
90 : const ::com::sun::star::uno::Reference<
91 : ::com::sun::star::xml::sax::XAttributeList>& xAttrList );
92 :
93 : virtual void EndElement();
94 : };
95 :
96 : //-----------------------------------------------------------------------------
97 :
98 : class ScXMLCellContentDeletionContext : public SvXMLImportContext
99 : {
100 : rtl::OUString sFormulaAddress;
101 : rtl::OUString sFormula;
102 : rtl::OUString sFormulaNmsp;
103 : rtl::OUString sInputString;
104 : ScBigRange aBigRange;
105 : double fValue;
106 : ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper;
107 : ScBaseCell* pCell;
108 : sal_uInt32 nID;
109 : sal_Int32 nMatrixCols;
110 : sal_Int32 nMatrixRows;
111 : formula::FormulaGrammar::Grammar eGrammar;
112 : sal_uInt16 nType;
113 : sal_uInt8 nMatrixFlag;
114 : sal_Bool bBigRange;
115 : sal_Bool bContainsCell;
116 :
117 : const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
118 0 : ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
119 :
120 : public:
121 : ScXMLCellContentDeletionContext( ScXMLImport& rImport, sal_uInt16 nPrfx, const ::rtl::OUString& rLName,
122 : const ::com::sun::star::uno::Reference<
123 : ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
124 : ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper);
125 : virtual ~ScXMLCellContentDeletionContext();
126 :
127 : virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
128 : const ::rtl::OUString& rLocalName,
129 : const ::com::sun::star::uno::Reference<
130 : ::com::sun::star::xml::sax::XAttributeList>& xAttrList );
131 :
132 : virtual void EndElement();
133 : };
134 :
135 : //-----------------------------------------------------------------------------
136 :
137 : class ScXMLDependenceContext : public SvXMLImportContext
138 : {
139 : ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper;
140 :
141 : const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
142 0 : ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
143 :
144 : public:
145 : ScXMLDependenceContext( ScXMLImport& rImport, sal_uInt16 nPrfx, const ::rtl::OUString& rLName,
146 : const ::com::sun::star::uno::Reference<
147 : ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
148 : ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper);
149 : virtual ~ScXMLDependenceContext();
150 :
151 : virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
152 : const ::rtl::OUString& rLocalName,
153 : const ::com::sun::star::uno::Reference<
154 : ::com::sun::star::xml::sax::XAttributeList>& xAttrList );
155 :
156 : virtual void EndElement();
157 : };
158 :
159 : //-----------------------------------------------------------------------------
160 :
161 : class ScXMLDependingsContext : public SvXMLImportContext
162 : {
163 : ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper;
164 :
165 : const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
166 0 : ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
167 :
168 : public:
169 : ScXMLDependingsContext( ScXMLImport& rImport, sal_uInt16 nPrfx, const ::rtl::OUString& rLName,
170 : const ::com::sun::star::uno::Reference<
171 : ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
172 : ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper);
173 : virtual ~ScXMLDependingsContext();
174 :
175 : virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
176 : const ::rtl::OUString& rLocalName,
177 : const ::com::sun::star::uno::Reference<
178 : ::com::sun::star::xml::sax::XAttributeList>& xAttrList );
179 :
180 : virtual void EndElement();
181 : };
182 :
183 : //-----------------------------------------------------------------------------
184 :
185 : class ScXMLChangeDeletionContext : public SvXMLImportContext
186 : {
187 : ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper;
188 :
189 : const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
190 0 : ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
191 :
192 : public:
193 : ScXMLChangeDeletionContext( ScXMLImport& rImport, sal_uInt16 nPrfx, const ::rtl::OUString& rLName,
194 : const ::com::sun::star::uno::Reference<
195 : ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
196 : ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper);
197 : virtual ~ScXMLChangeDeletionContext();
198 :
199 : virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
200 : const ::rtl::OUString& rLocalName,
201 : const ::com::sun::star::uno::Reference<
202 : ::com::sun::star::xml::sax::XAttributeList>& xAttrList );
203 :
204 : virtual void EndElement();
205 : };
206 :
207 : //-----------------------------------------------------------------------------
208 :
209 : class ScXMLDeletionsContext : public SvXMLImportContext
210 : {
211 : ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper;
212 :
213 : const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
214 0 : ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
215 :
216 : public:
217 : ScXMLDeletionsContext( ScXMLImport& rImport, sal_uInt16 nPrfx, const ::rtl::OUString& rLName,
218 : const ::com::sun::star::uno::Reference<
219 : ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
220 : ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper);
221 : virtual ~ScXMLDeletionsContext();
222 :
223 : virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
224 : const ::rtl::OUString& rLocalName,
225 : const ::com::sun::star::uno::Reference<
226 : ::com::sun::star::xml::sax::XAttributeList>& xAttrList );
227 :
228 : virtual void EndElement();
229 : };
230 :
231 : //-----------------------------------------------------------------------------
232 :
233 : class ScXMLChangeCellContext;
234 :
235 : class ScXMLChangeTextPContext : public SvXMLImportContext
236 : {
237 : ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList> xAttrList;
238 : rtl::OUString sLName;
239 : rtl::OUStringBuffer sText;
240 : ScXMLChangeCellContext* pChangeCellContext;
241 : SvXMLImportContext* pTextPContext;
242 : sal_uInt16 nPrefix;
243 :
244 : const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
245 0 : ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
246 :
247 : public:
248 :
249 : ScXMLChangeTextPContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
250 : const ::rtl::OUString& rLName,
251 : const ::com::sun::star::uno::Reference<
252 : ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
253 : ScXMLChangeCellContext* pChangeCellContext);
254 :
255 : virtual ~ScXMLChangeTextPContext();
256 :
257 : virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
258 : const ::rtl::OUString& rLocalName,
259 : const ::com::sun::star::uno::Reference<
260 : ::com::sun::star::xml::sax::XAttributeList>& xAttrList );
261 :
262 : virtual void Characters( const ::rtl::OUString& rChars );
263 :
264 : virtual void EndElement();
265 : };
266 :
267 : //-----------------------------------------------------------------------------
268 :
269 : class ScXMLChangeCellContext : public SvXMLImportContext
270 : {
271 : rtl::OUString sText;
272 : rtl::OUString& rInputString;
273 : ScBaseCell*& rOldCell;
274 : ScEditEngineTextObj* pEditTextObj;
275 : double& rDateTimeValue;
276 : double fValue;
277 : sal_uInt16& rType;
278 : sal_Bool bEmpty;
279 : sal_Bool bFirstParagraph;
280 : sal_Bool bString;
281 : sal_Bool bFormula;
282 :
283 : const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
284 0 : ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
285 :
286 : public:
287 : ScXMLChangeCellContext( ScXMLImport& rImport, sal_uInt16 nPrfx, const ::rtl::OUString& rLName,
288 : const ::com::sun::star::uno::Reference<
289 : ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
290 : ScBaseCell*& rOldCell, rtl::OUString& sAddress,
291 : rtl::OUString& rFormula, rtl::OUString& rFormulaNmsp,
292 : formula::FormulaGrammar::Grammar& rGrammar,
293 : rtl::OUString& rInputString, double& fValue, sal_uInt16& nType,
294 : sal_uInt8& nMatrixFlag, sal_Int32& nMatrixCols, sal_Int32& nMatrixRows);
295 : virtual ~ScXMLChangeCellContext();
296 :
297 : virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
298 : const ::rtl::OUString& rLocalName,
299 : const ::com::sun::star::uno::Reference<
300 : ::com::sun::star::xml::sax::XAttributeList>& xAttrList );
301 :
302 : void CreateTextPContext(sal_Bool bIsNewParagraph);
303 0 : sal_Bool IsEditCell() { return pEditTextObj != 0; }
304 0 : void SetText(const rtl::OUString& sTempText) { sText = sTempText; }
305 :
306 : virtual void EndElement();
307 : };
308 :
309 : //-----------------------------------------------------------------------------
310 :
311 : class ScXMLPreviousContext : public SvXMLImportContext
312 : {
313 : rtl::OUString sFormulaAddress;
314 : rtl::OUString sFormula;
315 : rtl::OUString sFormulaNmsp;
316 : rtl::OUString sInputString;
317 : double fValue;
318 : ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper;
319 : ScBaseCell* pOldCell;
320 : sal_uInt32 nID;
321 : sal_Int32 nMatrixCols;
322 : sal_Int32 nMatrixRows;
323 : formula::FormulaGrammar::Grammar eGrammar;
324 : sal_uInt16 nType;
325 : sal_uInt8 nMatrixFlag;
326 :
327 : const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
328 0 : ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
329 :
330 : public:
331 : ScXMLPreviousContext( ScXMLImport& rImport, sal_uInt16 nPrfx, const ::rtl::OUString& rLName,
332 : const ::com::sun::star::uno::Reference<
333 : ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
334 : ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper);
335 : virtual ~ScXMLPreviousContext();
336 :
337 : virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
338 : const ::rtl::OUString& rLocalName,
339 : const ::com::sun::star::uno::Reference<
340 : ::com::sun::star::xml::sax::XAttributeList>& xAttrList );
341 :
342 : virtual void EndElement();
343 : };
344 :
345 : //-----------------------------------------------------------------------------
346 :
347 : class ScXMLContentChangeContext : public SvXMLImportContext
348 : {
349 : ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper;
350 : ScBigRange aBigRange;
351 :
352 : const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
353 0 : ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
354 :
355 : public:
356 : ScXMLContentChangeContext( ScXMLImport& rImport, sal_uInt16 nPrfx, const ::rtl::OUString& rLName,
357 : const ::com::sun::star::uno::Reference<
358 : ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
359 : ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper);
360 : virtual ~ScXMLContentChangeContext();
361 :
362 : virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
363 : const ::rtl::OUString& rLocalName,
364 : const ::com::sun::star::uno::Reference<
365 : ::com::sun::star::xml::sax::XAttributeList>& xAttrList );
366 : virtual void EndElement();
367 : };
368 :
369 : //-----------------------------------------------------------------------------
370 :
371 : class ScXMLInsertionContext : public SvXMLImportContext
372 : {
373 : ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper;
374 :
375 : const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
376 0 : ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
377 :
378 : public:
379 : ScXMLInsertionContext( ScXMLImport& rImport, sal_uInt16 nPrfx, const ::rtl::OUString& rLName,
380 : const ::com::sun::star::uno::Reference<
381 : ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
382 : ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper);
383 : virtual ~ScXMLInsertionContext();
384 :
385 : virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
386 : const ::rtl::OUString& rLocalName,
387 : const ::com::sun::star::uno::Reference<
388 : ::com::sun::star::xml::sax::XAttributeList>& xAttrList );
389 : virtual void EndElement();
390 : };
391 :
392 : //-----------------------------------------------------------------------------
393 :
394 : class ScXMLInsertionCutOffContext : public SvXMLImportContext
395 : {
396 : ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper;
397 :
398 : const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
399 0 : ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
400 :
401 : public:
402 : ScXMLInsertionCutOffContext( ScXMLImport& rImport, sal_uInt16 nPrfx, const ::rtl::OUString& rLName,
403 : const ::com::sun::star::uno::Reference<
404 : ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
405 : ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper);
406 : virtual ~ScXMLInsertionCutOffContext();
407 :
408 : virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
409 : const ::rtl::OUString& rLocalName,
410 : const ::com::sun::star::uno::Reference<
411 : ::com::sun::star::xml::sax::XAttributeList>& xAttrList );
412 : virtual void EndElement();
413 : };
414 :
415 : //-----------------------------------------------------------------------------
416 :
417 : class ScXMLMovementCutOffContext : public SvXMLImportContext
418 : {
419 : ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper;
420 :
421 : const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
422 0 : ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
423 :
424 : public:
425 : ScXMLMovementCutOffContext( ScXMLImport& rImport, sal_uInt16 nPrfx, const ::rtl::OUString& rLName,
426 : const ::com::sun::star::uno::Reference<
427 : ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
428 : ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper);
429 : virtual ~ScXMLMovementCutOffContext();
430 :
431 : virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
432 : const ::rtl::OUString& rLocalName,
433 : const ::com::sun::star::uno::Reference<
434 : ::com::sun::star::xml::sax::XAttributeList>& xAttrList );
435 : virtual void EndElement();
436 : };
437 :
438 : //-----------------------------------------------------------------------------
439 :
440 : class ScXMLCutOffsContext : public SvXMLImportContext
441 : {
442 : ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper;
443 :
444 : const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
445 0 : ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
446 :
447 : public:
448 : ScXMLCutOffsContext( ScXMLImport& rImport, sal_uInt16 nPrfx, const ::rtl::OUString& rLName,
449 : const ::com::sun::star::uno::Reference<
450 : ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
451 : ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper);
452 : virtual ~ScXMLCutOffsContext();
453 :
454 : virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
455 : const ::rtl::OUString& rLocalName,
456 : const ::com::sun::star::uno::Reference<
457 : ::com::sun::star::xml::sax::XAttributeList>& xAttrList );
458 : virtual void EndElement();
459 : };
460 :
461 : //-----------------------------------------------------------------------------
462 :
463 : class ScXMLDeletionContext : public SvXMLImportContext
464 : {
465 : ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper;
466 :
467 : const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
468 0 : ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
469 :
470 : public:
471 : ScXMLDeletionContext( ScXMLImport& rImport, sal_uInt16 nPrfx, const ::rtl::OUString& rLName,
472 : const ::com::sun::star::uno::Reference<
473 : ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
474 : ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper);
475 : virtual ~ScXMLDeletionContext();
476 :
477 : virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
478 : const ::rtl::OUString& rLocalName,
479 : const ::com::sun::star::uno::Reference<
480 : ::com::sun::star::xml::sax::XAttributeList>& xAttrList );
481 : virtual void EndElement();
482 : };
483 :
484 : //-----------------------------------------------------------------------------
485 :
486 : class ScXMLMovementContext : public SvXMLImportContext
487 : {
488 : ScBigRange aSourceRange;
489 : ScBigRange aTargetRange;
490 : ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper;
491 :
492 : const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
493 0 : ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
494 :
495 : public:
496 : ScXMLMovementContext( ScXMLImport& rImport, sal_uInt16 nPrfx, const ::rtl::OUString& rLName,
497 : const ::com::sun::star::uno::Reference<
498 : ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
499 : ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper);
500 : virtual ~ScXMLMovementContext();
501 :
502 : virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
503 : const ::rtl::OUString& rLocalName,
504 : const ::com::sun::star::uno::Reference<
505 : ::com::sun::star::xml::sax::XAttributeList>& xAttrList );
506 : virtual void EndElement();
507 : };
508 :
509 : //-----------------------------------------------------------------------------
510 :
511 : class ScXMLRejectionContext : public SvXMLImportContext
512 : {
513 : ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper;
514 :
515 : const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
516 0 : ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
517 :
518 : public:
519 : ScXMLRejectionContext( ScXMLImport& rImport, sal_uInt16 nPrfx, const ::rtl::OUString& rLName,
520 : const ::com::sun::star::uno::Reference<
521 : ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
522 : ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper);
523 : virtual ~ScXMLRejectionContext();
524 :
525 : virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
526 : const ::rtl::OUString& rLocalName,
527 : const ::com::sun::star::uno::Reference<
528 : ::com::sun::star::xml::sax::XAttributeList>& xAttrList );
529 : virtual void EndElement();
530 : };
531 :
532 : //------------------------------------------------------------------
533 :
534 0 : ScXMLTrackedChangesContext::ScXMLTrackedChangesContext( ScXMLImport& rImport,
535 : sal_uInt16 nPrfx,
536 : const ::rtl::OUString& rLName,
537 : const uno::Reference<xml::sax::XAttributeList>& xAttrList,
538 : ScXMLChangeTrackingImportHelper* pTempChangeTrackingImportHelper ) :
539 : SvXMLImportContext( rImport, nPrfx, rLName ),
540 0 : pChangeTrackingImportHelper(pTempChangeTrackingImportHelper)
541 : {
542 0 : rImport.LockSolarMutex();
543 0 : pChangeTrackingImportHelper->SetChangeTrack(sal_True);
544 :
545 0 : sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0);
546 0 : for( sal_Int16 i=0; i < nAttrCount; ++i )
547 : {
548 0 : const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i ));
549 0 : rtl::OUString aLocalName;
550 0 : sal_uInt16 nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName(
551 0 : sAttrName, &aLocalName ));
552 0 : const rtl::OUString& sValue(xAttrList->getValueByIndex( i ));
553 0 : if (nPrefix == XML_NAMESPACE_TABLE)
554 : {
555 0 : if (IsXMLToken(aLocalName, XML_PROTECTION_KEY))
556 : {
557 0 : if (!sValue.isEmpty())
558 : {
559 0 : uno::Sequence<sal_Int8> aPass;
560 0 : ::sax::Converter::decodeBase64(aPass, sValue);
561 0 : pChangeTrackingImportHelper->SetProtection(aPass);
562 : }
563 : }
564 : }
565 0 : }
566 0 : }
567 :
568 0 : ScXMLTrackedChangesContext::~ScXMLTrackedChangesContext()
569 : {
570 0 : GetScImport().UnlockSolarMutex();
571 0 : }
572 :
573 0 : SvXMLImportContext *ScXMLTrackedChangesContext::CreateChildContext( sal_uInt16 nPrefix,
574 : const ::rtl::OUString& rLocalName,
575 : const ::com::sun::star::uno::Reference<
576 : ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
577 : {
578 0 : SvXMLImportContext *pContext(0);
579 :
580 0 : if (nPrefix == XML_NAMESPACE_TABLE)
581 : {
582 0 : if (IsXMLToken(rLocalName, XML_CELL_CONTENT_CHANGE))
583 : {
584 0 : pContext = new ScXMLContentChangeContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper);
585 : }
586 0 : else if (IsXMLToken(rLocalName, XML_INSERTION))
587 : {
588 0 : pContext = new ScXMLInsertionContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper);
589 : }
590 0 : else if (IsXMLToken(rLocalName, XML_DELETION))
591 : {
592 0 : pContext = new ScXMLDeletionContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper);
593 : }
594 0 : else if (IsXMLToken(rLocalName, XML_MOVEMENT))
595 : {
596 0 : pContext = new ScXMLMovementContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper);
597 : }
598 0 : else if (IsXMLToken(rLocalName, XML_REJECTION))
599 : {
600 0 : pContext = new ScXMLRejectionContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper);
601 : }
602 : }
603 :
604 0 : if( !pContext )
605 0 : pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
606 :
607 0 : return pContext;
608 : }
609 :
610 0 : void ScXMLTrackedChangesContext::EndElement()
611 : {
612 0 : }
613 :
614 0 : ScXMLChangeInfoContext::ScXMLChangeInfoContext( ScXMLImport& rImport,
615 : sal_uInt16 nPrfx,
616 : const ::rtl::OUString& rLName,
617 : const uno::Reference<xml::sax::XAttributeList>& xAttrList,
618 : ScXMLChangeTrackingImportHelper* pTempChangeTrackingImportHelper ) :
619 : SvXMLImportContext( rImport, nPrfx, rLName ),
620 : aInfo(),
621 : pChangeTrackingImportHelper(pTempChangeTrackingImportHelper),
622 0 : nParagraphCount(0)
623 : {
624 0 : sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0);
625 0 : for( sal_Int16 i=0; i < nAttrCount; ++i )
626 : {
627 0 : const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i ));
628 0 : rtl::OUString aLocalName;
629 0 : sal_uInt16 nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName(
630 0 : sAttrName, &aLocalName ));
631 0 : const rtl::OUString& sValue(xAttrList->getValueByIndex( i ));
632 :
633 0 : if (nPrefix == XML_NAMESPACE_OFFICE)
634 : {
635 0 : if (IsXMLToken(aLocalName, XML_CHG_AUTHOR))
636 : {
637 0 : sAuthorBuffer = sValue;
638 : }
639 0 : else if (IsXMLToken(aLocalName, XML_CHG_DATE_TIME))
640 : {
641 0 : sDateTimeBuffer = sValue;
642 : }
643 : }
644 0 : }
645 0 : }
646 :
647 0 : ScXMLChangeInfoContext::~ScXMLChangeInfoContext()
648 : {
649 0 : }
650 :
651 0 : SvXMLImportContext *ScXMLChangeInfoContext::CreateChildContext( sal_uInt16 nPrefix,
652 : const ::rtl::OUString& rLocalName,
653 : const ::com::sun::star::uno::Reference<
654 : ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
655 : {
656 0 : SvXMLImportContext *pContext(0);
657 :
658 0 : if( XML_NAMESPACE_DC == nPrefix )
659 : {
660 0 : if( IsXMLToken( rLocalName, XML_CREATOR ) )
661 : pContext = new ScXMLContentContext(GetScImport(), nPrefix,
662 0 : rLocalName, xAttrList, sAuthorBuffer);
663 0 : else if( IsXMLToken( rLocalName, XML_DATE ) )
664 : pContext = new ScXMLContentContext(GetScImport(), nPrefix,
665 0 : rLocalName, xAttrList, sDateTimeBuffer);
666 : }
667 0 : else if ((nPrefix == XML_NAMESPACE_TEXT) && (IsXMLToken(rLocalName, XML_P)) )
668 : {
669 0 : if(nParagraphCount)
670 0 : sCommentBuffer.append(static_cast<sal_Unicode>('\n'));
671 0 : ++nParagraphCount;
672 0 : pContext = new ScXMLContentContext( GetScImport(), nPrefix, rLocalName, xAttrList, sCommentBuffer);
673 : }
674 :
675 0 : if( !pContext )
676 0 : pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
677 :
678 0 : return pContext;
679 : }
680 :
681 0 : void ScXMLChangeInfoContext::EndElement()
682 : {
683 0 : aInfo.sUser = sAuthorBuffer.makeStringAndClear();
684 : ::sax::Converter::convertDateTime(aInfo.aDateTime,
685 0 : sDateTimeBuffer.makeStringAndClear());
686 0 : aInfo.sComment = sCommentBuffer.makeStringAndClear();
687 0 : pChangeTrackingImportHelper->SetActionInfo(aInfo);
688 0 : }
689 :
690 0 : ScXMLBigRangeContext::ScXMLBigRangeContext( ScXMLImport& rImport,
691 : sal_uInt16 nPrfx,
692 : const ::rtl::OUString& rLName,
693 : const uno::Reference<xml::sax::XAttributeList>& xAttrList,
694 : ScBigRange& rTempBigRange ) :
695 : SvXMLImportContext( rImport, nPrfx, rLName ),
696 0 : rBigRange(rTempBigRange)
697 : {
698 0 : sal_Bool bColumn(false);
699 0 : sal_Bool bRow(false);
700 0 : sal_Bool bTable(false);
701 0 : sal_Int32 nColumn(0);
702 0 : sal_Int32 nRow(0);
703 0 : sal_Int32 nTable(0);
704 0 : sal_Int32 nStartColumn(0);
705 0 : sal_Int32 nEndColumn(0);
706 0 : sal_Int32 nStartRow(0);
707 0 : sal_Int32 nEndRow(0);
708 0 : sal_Int32 nStartTable(0);
709 0 : sal_Int32 nEndTable(0);
710 0 : sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0);
711 0 : for( sal_Int16 i=0; i < nAttrCount; ++i )
712 : {
713 0 : const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i ));
714 0 : rtl::OUString aLocalName;
715 0 : sal_uInt16 nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName(
716 0 : sAttrName, &aLocalName ));
717 0 : const rtl::OUString& sValue(xAttrList->getValueByIndex( i ));
718 :
719 0 : if (nPrefix == XML_NAMESPACE_TABLE)
720 : {
721 0 : if (IsXMLToken(aLocalName, XML_COLUMN))
722 : {
723 0 : ::sax::Converter::convertNumber(nColumn, sValue);
724 0 : bColumn = sal_True;
725 : }
726 0 : else if (IsXMLToken(aLocalName, XML_ROW))
727 : {
728 0 : ::sax::Converter::convertNumber(nRow, sValue);
729 0 : bRow = sal_True;
730 : }
731 0 : else if (IsXMLToken(aLocalName, XML_TABLE))
732 : {
733 0 : ::sax::Converter::convertNumber(nTable, sValue);
734 0 : bTable = sal_True;
735 : }
736 0 : else if (IsXMLToken(aLocalName, XML_START_COLUMN))
737 0 : ::sax::Converter::convertNumber(nStartColumn, sValue);
738 0 : else if (IsXMLToken(aLocalName, XML_END_COLUMN))
739 0 : ::sax::Converter::convertNumber(nEndColumn, sValue);
740 0 : else if (IsXMLToken(aLocalName, XML_START_ROW))
741 0 : ::sax::Converter::convertNumber(nStartRow, sValue);
742 0 : else if (IsXMLToken(aLocalName, XML_END_ROW))
743 0 : ::sax::Converter::convertNumber(nEndRow, sValue);
744 0 : else if (IsXMLToken(aLocalName, XML_START_TABLE))
745 0 : ::sax::Converter::convertNumber(nStartTable, sValue);
746 0 : else if (IsXMLToken(aLocalName, XML_END_TABLE))
747 0 : ::sax::Converter::convertNumber(nEndTable, sValue);
748 : }
749 0 : }
750 0 : if (bColumn)
751 0 : nStartColumn = nEndColumn = nColumn;
752 0 : if (bRow)
753 0 : nStartRow = nEndRow = nRow;
754 0 : if (bTable)
755 0 : nStartTable = nEndTable = nTable;
756 : rBigRange.Set(nStartColumn, nStartRow, nStartTable,
757 0 : nEndColumn, nEndRow, nEndTable);
758 0 : }
759 :
760 0 : ScXMLBigRangeContext::~ScXMLBigRangeContext()
761 : {
762 0 : }
763 :
764 0 : SvXMLImportContext *ScXMLBigRangeContext::CreateChildContext( sal_uInt16 nPrefix,
765 : const ::rtl::OUString& rLocalName,
766 : const ::com::sun::star::uno::Reference<
767 : ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */ )
768 : {
769 0 : return new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
770 : }
771 :
772 0 : void ScXMLBigRangeContext::EndElement()
773 : {
774 0 : }
775 :
776 0 : ScXMLCellContentDeletionContext::ScXMLCellContentDeletionContext( ScXMLImport& rImport,
777 : sal_uInt16 nPrfx,
778 : const ::rtl::OUString& rLName,
779 : const uno::Reference<xml::sax::XAttributeList>& xAttrList,
780 : ScXMLChangeTrackingImportHelper* pTempChangeTrackingImportHelper) :
781 : SvXMLImportContext( rImport, nPrfx, rLName ),
782 : pChangeTrackingImportHelper(pTempChangeTrackingImportHelper),
783 : pCell(NULL),
784 : nID(0),
785 : nMatrixCols(0),
786 : nMatrixRows(0),
787 : nType(NUMBERFORMAT_ALL),
788 : nMatrixFlag(MM_NONE),
789 : bBigRange(false),
790 0 : bContainsCell(false)
791 : {
792 0 : sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0);
793 0 : for( sal_Int16 i=0; i < nAttrCount; ++i )
794 : {
795 0 : const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i ));
796 0 : rtl::OUString aLocalName;
797 0 : sal_uInt16 nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName(
798 0 : sAttrName, &aLocalName ));
799 0 : const rtl::OUString& sValue(xAttrList->getValueByIndex( i ));
800 :
801 0 : if (nPrefix == XML_NAMESPACE_TABLE)
802 : {
803 0 : if (IsXMLToken(aLocalName, XML_ID))
804 0 : nID = pChangeTrackingImportHelper->GetIDFromString(sValue);
805 : }
806 0 : }
807 0 : }
808 :
809 0 : ScXMLCellContentDeletionContext::~ScXMLCellContentDeletionContext()
810 : {
811 0 : }
812 :
813 0 : SvXMLImportContext *ScXMLCellContentDeletionContext::CreateChildContext( sal_uInt16 nPrefix,
814 : const ::rtl::OUString& rLocalName,
815 : const ::com::sun::star::uno::Reference<
816 : ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
817 : {
818 0 : SvXMLImportContext *pContext(0);
819 :
820 0 : if (nPrefix == XML_NAMESPACE_TABLE)
821 : {
822 0 : if (IsXMLToken(rLocalName, XML_CHANGE_TRACK_TABLE_CELL))
823 : {
824 0 : bContainsCell = sal_True;
825 : pContext = new ScXMLChangeCellContext(GetScImport(), nPrefix, rLocalName, xAttrList,
826 0 : pCell, sFormulaAddress, sFormula, sFormulaNmsp, eGrammar, sInputString, fValue, nType, nMatrixFlag, nMatrixCols, nMatrixRows );
827 : }
828 0 : else if (IsXMLToken(rLocalName, XML_CELL_ADDRESS))
829 : {
830 : OSL_ENSURE(!nID, "a action with a ID should not contain a BigRange");
831 0 : bBigRange = sal_True;
832 0 : pContext = new ScXMLBigRangeContext(GetScImport(), nPrefix, rLocalName, xAttrList, aBigRange);
833 : }
834 : }
835 :
836 0 : if( !pContext )
837 0 : pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
838 :
839 0 : return pContext;
840 : }
841 :
842 0 : void ScXMLCellContentDeletionContext::EndElement()
843 : {
844 : ScMyCellInfo* pCellInfo(new ScMyCellInfo(pCell, sFormulaAddress, sFormula, eGrammar, sInputString, fValue, nType,
845 0 : nMatrixFlag, nMatrixCols, nMatrixRows));
846 0 : if (nID)
847 0 : pChangeTrackingImportHelper->AddDeleted(nID, pCellInfo);
848 : else
849 0 : pChangeTrackingImportHelper->AddGenerated(pCellInfo, aBigRange);
850 0 : }
851 :
852 0 : ScXMLDependenceContext::ScXMLDependenceContext( ScXMLImport& rImport,
853 : sal_uInt16 nPrfx,
854 : const ::rtl::OUString& rLName,
855 : const uno::Reference<xml::sax::XAttributeList>& xAttrList,
856 : ScXMLChangeTrackingImportHelper* pTempChangeTrackingImportHelper ) :
857 : SvXMLImportContext( rImport, nPrfx, rLName ),
858 0 : pChangeTrackingImportHelper(pTempChangeTrackingImportHelper)
859 : {
860 0 : sal_uInt32 nID(0);
861 0 : sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0);
862 0 : for( sal_Int16 i=0; i < nAttrCount; ++i )
863 : {
864 0 : const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i ));
865 0 : rtl::OUString aLocalName;
866 0 : sal_uInt16 nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName(
867 0 : sAttrName, &aLocalName ));
868 0 : const rtl::OUString& sValue(xAttrList->getValueByIndex( i ));
869 :
870 0 : if (nPrefix == XML_NAMESPACE_TABLE)
871 : {
872 0 : if (IsXMLToken(aLocalName, XML_ID))
873 0 : nID = pChangeTrackingImportHelper->GetIDFromString(sValue);
874 : }
875 0 : }
876 0 : pChangeTrackingImportHelper->AddDependence(nID);
877 0 : }
878 :
879 0 : ScXMLDependenceContext::~ScXMLDependenceContext()
880 : {
881 0 : }
882 :
883 0 : SvXMLImportContext *ScXMLDependenceContext::CreateChildContext( sal_uInt16 nPrefix,
884 : const ::rtl::OUString& rLocalName,
885 : const ::com::sun::star::uno::Reference<
886 : ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */ )
887 : {
888 0 : return new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
889 : }
890 :
891 0 : void ScXMLDependenceContext::EndElement()
892 : {
893 0 : }
894 :
895 0 : ScXMLDependingsContext::ScXMLDependingsContext( ScXMLImport& rImport,
896 : sal_uInt16 nPrfx,
897 : const ::rtl::OUString& rLName,
898 : const uno::Reference<xml::sax::XAttributeList>& /* xAttrList */,
899 : ScXMLChangeTrackingImportHelper* pTempChangeTrackingImportHelper ) :
900 : SvXMLImportContext( rImport, nPrfx, rLName ),
901 0 : pChangeTrackingImportHelper(pTempChangeTrackingImportHelper)
902 : {
903 : // here are no attributes
904 0 : }
905 :
906 0 : ScXMLDependingsContext::~ScXMLDependingsContext()
907 : {
908 0 : }
909 :
910 0 : SvXMLImportContext *ScXMLDependingsContext::CreateChildContext( sal_uInt16 nPrefix,
911 : const ::rtl::OUString& rLocalName,
912 : const ::com::sun::star::uno::Reference<
913 : ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
914 : {
915 0 : SvXMLImportContext *pContext(0);
916 :
917 0 : if (nPrefix == XML_NAMESPACE_TABLE)
918 : {
919 : // #i80033# read both old (dependence) and new (dependency) elements
920 0 : if (IsXMLToken(rLocalName, XML_DEPENDENCE) || IsXMLToken(rLocalName, XML_DEPENDENCY))
921 0 : pContext = new ScXMLDependenceContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper);
922 : }
923 :
924 0 : if( !pContext )
925 0 : pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
926 :
927 0 : return pContext;
928 : }
929 :
930 0 : void ScXMLDependingsContext::EndElement()
931 : {
932 0 : }
933 :
934 0 : ScXMLChangeDeletionContext::ScXMLChangeDeletionContext( ScXMLImport& rImport,
935 : sal_uInt16 nPrfx,
936 : const ::rtl::OUString& rLName,
937 : const uno::Reference<xml::sax::XAttributeList>& xAttrList,
938 : ScXMLChangeTrackingImportHelper* pTempChangeTrackingImportHelper ) :
939 : SvXMLImportContext( rImport, nPrfx, rLName ),
940 0 : pChangeTrackingImportHelper(pTempChangeTrackingImportHelper)
941 : {
942 0 : sal_uInt32 nID(0);
943 0 : sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0);
944 0 : for( sal_Int16 i=0; i < nAttrCount; ++i )
945 : {
946 0 : const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i ));
947 0 : rtl::OUString aLocalName;
948 0 : sal_uInt16 nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName(
949 0 : sAttrName, &aLocalName ));
950 0 : const rtl::OUString& sValue(xAttrList->getValueByIndex( i ));
951 :
952 0 : if (nPrefix == XML_NAMESPACE_TABLE)
953 : {
954 0 : if (IsXMLToken(aLocalName, XML_ID))
955 0 : nID = pChangeTrackingImportHelper->GetIDFromString(sValue);
956 : }
957 0 : }
958 0 : pChangeTrackingImportHelper->AddDeleted(nID);
959 0 : }
960 :
961 0 : ScXMLChangeDeletionContext::~ScXMLChangeDeletionContext()
962 : {
963 0 : }
964 :
965 0 : SvXMLImportContext *ScXMLChangeDeletionContext::CreateChildContext( sal_uInt16 nPrefix,
966 : const ::rtl::OUString& rLocalName,
967 : const ::com::sun::star::uno::Reference<
968 : ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */ )
969 : {
970 0 : return new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
971 : }
972 :
973 0 : void ScXMLChangeDeletionContext::EndElement()
974 : {
975 0 : }
976 :
977 0 : ScXMLDeletionsContext::ScXMLDeletionsContext( ScXMLImport& rImport,
978 : sal_uInt16 nPrfx,
979 : const ::rtl::OUString& rLName,
980 : const uno::Reference<xml::sax::XAttributeList>& /* xAttrList */,
981 : ScXMLChangeTrackingImportHelper* pTempChangeTrackingImportHelper ) :
982 : SvXMLImportContext( rImport, nPrfx, rLName ),
983 0 : pChangeTrackingImportHelper(pTempChangeTrackingImportHelper)
984 : {
985 : // here are no attributes
986 0 : }
987 :
988 0 : ScXMLDeletionsContext::~ScXMLDeletionsContext()
989 : {
990 0 : }
991 :
992 0 : SvXMLImportContext *ScXMLDeletionsContext::CreateChildContext( sal_uInt16 nPrefix,
993 : const ::rtl::OUString& rLocalName,
994 : const ::com::sun::star::uno::Reference<
995 : ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
996 : {
997 0 : SvXMLImportContext *pContext(0);
998 :
999 0 : if (nPrefix == XML_NAMESPACE_TABLE)
1000 : {
1001 0 : if (IsXMLToken(rLocalName, XML_CHANGE_DELETION))
1002 0 : pContext = new ScXMLChangeDeletionContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper);
1003 0 : else if (IsXMLToken(rLocalName, XML_CELL_CONTENT_DELETION))
1004 0 : pContext = new ScXMLCellContentDeletionContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper);
1005 : }
1006 :
1007 0 : if( !pContext )
1008 0 : pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
1009 :
1010 0 : return pContext;
1011 : }
1012 :
1013 0 : void ScXMLDeletionsContext::EndElement()
1014 : {
1015 0 : }
1016 :
1017 0 : ScXMLChangeTextPContext::ScXMLChangeTextPContext( ScXMLImport& rImport,
1018 : sal_uInt16 nPrfx,
1019 : const ::rtl::OUString& rLName,
1020 : const ::com::sun::star::uno::Reference<
1021 : ::com::sun::star::xml::sax::XAttributeList>& xTempAttrList,
1022 : ScXMLChangeCellContext* pTempChangeCellContext) :
1023 : SvXMLImportContext( rImport, nPrfx, rLName ),
1024 : xAttrList(xTempAttrList),
1025 : sLName(rLName),
1026 : sText(),
1027 : pChangeCellContext(pTempChangeCellContext),
1028 : pTextPContext(NULL),
1029 0 : nPrefix(nPrfx)
1030 : {
1031 : // here are no attributes
1032 0 : }
1033 :
1034 0 : ScXMLChangeTextPContext::~ScXMLChangeTextPContext()
1035 : {
1036 0 : if (pTextPContext)
1037 0 : delete pTextPContext;
1038 0 : }
1039 :
1040 0 : SvXMLImportContext *ScXMLChangeTextPContext::CreateChildContext( sal_uInt16 nTempPrefix,
1041 : const ::rtl::OUString& rLName,
1042 : const ::com::sun::star::uno::Reference<
1043 : ::com::sun::star::xml::sax::XAttributeList>& xTempAttrList )
1044 : {
1045 0 : SvXMLImportContext *pContext(0);
1046 :
1047 0 : if ((nPrefix == XML_NAMESPACE_TEXT) && (IsXMLToken(rLName, XML_S)) && !pTextPContext)
1048 : {
1049 0 : sal_Int32 nRepeat(0);
1050 0 : sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0);
1051 0 : for( sal_Int16 i=0; i < nAttrCount; ++i )
1052 : {
1053 0 : const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i ));
1054 0 : const rtl::OUString& sValue(xAttrList->getValueByIndex( i ));
1055 0 : rtl::OUString aLocalName;
1056 0 : sal_uInt16 nPrfx(GetScImport().GetNamespaceMap().GetKeyByAttrName(
1057 0 : sAttrName, &aLocalName ));
1058 0 : if ((nPrfx == XML_NAMESPACE_TEXT) && (IsXMLToken(aLocalName, XML_C)))
1059 0 : nRepeat = sValue.toInt32();
1060 0 : }
1061 0 : if (nRepeat)
1062 0 : for (sal_Int32 j = 0; j < nRepeat; ++j)
1063 0 : sText.append(static_cast<sal_Unicode>(' '));
1064 : else
1065 0 : sText.append(static_cast<sal_Unicode>(' '));
1066 : }
1067 : else
1068 : {
1069 0 : if (!pChangeCellContext->IsEditCell())
1070 0 : pChangeCellContext->CreateTextPContext(false);
1071 0 : sal_Bool bWasContext (sal_True);
1072 0 : if (!pTextPContext)
1073 : {
1074 0 : bWasContext = false;
1075 0 : pTextPContext = GetScImport().GetTextImport()->CreateTextChildContext(
1076 0 : GetScImport(), nPrefix, sLName, xAttrList);
1077 : }
1078 0 : if (pTextPContext)
1079 : {
1080 0 : if (!bWasContext)
1081 0 : pTextPContext->Characters(sText.makeStringAndClear());
1082 0 : pContext = pTextPContext->CreateChildContext(nTempPrefix, rLName, xTempAttrList);
1083 : }
1084 : }
1085 :
1086 0 : if( !pContext )
1087 0 : pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
1088 :
1089 0 : return pContext;
1090 : }
1091 :
1092 0 : void ScXMLChangeTextPContext::Characters( const ::rtl::OUString& rChars )
1093 : {
1094 0 : if (!pTextPContext)
1095 0 : sText.append(rChars);
1096 : else
1097 0 : pTextPContext->Characters(rChars);
1098 0 : }
1099 :
1100 0 : void ScXMLChangeTextPContext::EndElement()
1101 : {
1102 0 : if (!pTextPContext)
1103 0 : pChangeCellContext->SetText(sText.makeStringAndClear());
1104 0 : }
1105 :
1106 0 : ScXMLChangeCellContext::ScXMLChangeCellContext( ScXMLImport& rImport,
1107 : sal_uInt16 nPrfx,
1108 : const ::rtl::OUString& rLName,
1109 : const uno::Reference<xml::sax::XAttributeList>& xAttrList,
1110 : ScBaseCell*& rTempOldCell, rtl::OUString& rAddress,
1111 : rtl::OUString& rFormula, rtl::OUString& rFormulaNmsp,
1112 : formula::FormulaGrammar::Grammar& rGrammar,
1113 : rtl::OUString& rTempInputString, double& fDateTimeValue, sal_uInt16& nType,
1114 : sal_uInt8& nMatrixFlag, sal_Int32& nMatrixCols, sal_Int32& nMatrixRows ) :
1115 : SvXMLImportContext( rImport, nPrfx, rLName ),
1116 : rInputString(rTempInputString),
1117 : rOldCell(rTempOldCell),
1118 : pEditTextObj(NULL),
1119 : rDateTimeValue(fDateTimeValue),
1120 : rType(nType),
1121 : bEmpty(sal_True),
1122 : bFirstParagraph(sal_True),
1123 : bString(sal_True),
1124 0 : bFormula(false)
1125 : {
1126 0 : sal_Bool bIsMatrix(false);
1127 0 : sal_Bool bIsCoveredMatrix(false);
1128 0 : sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0);
1129 0 : for( sal_Int16 i=0; i < nAttrCount; ++i )
1130 : {
1131 0 : const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i ));
1132 0 : rtl::OUString aLocalName;
1133 0 : sal_uInt16 nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName(
1134 0 : sAttrName, &aLocalName ));
1135 0 : const rtl::OUString& sValue(xAttrList->getValueByIndex( i ));
1136 :
1137 0 : if (nPrefix == XML_NAMESPACE_TABLE)
1138 : {
1139 0 : if (IsXMLToken(aLocalName, XML_FORMULA))
1140 : {
1141 0 : bEmpty = false;
1142 0 : GetScImport().ExtractFormulaNamespaceGrammar( rFormula, rFormulaNmsp, rGrammar, sValue );
1143 0 : bFormula = sal_True;
1144 : }
1145 0 : else if (IsXMLToken(aLocalName, XML_CELL_ADDRESS))
1146 : {
1147 0 : rAddress = sValue;
1148 : }
1149 0 : else if (IsXMLToken(aLocalName, XML_MATRIX_COVERED))
1150 : {
1151 0 : bIsCoveredMatrix = IsXMLToken(sValue, XML_TRUE);
1152 : }
1153 0 : else if (IsXMLToken(aLocalName, XML_NUMBER_MATRIX_COLUMNS_SPANNED))
1154 : {
1155 0 : bIsMatrix = sal_True;
1156 0 : ::sax::Converter::convertNumber(nMatrixCols, sValue);
1157 : }
1158 0 : else if (IsXMLToken(aLocalName, XML_NUMBER_MATRIX_ROWS_SPANNED))
1159 : {
1160 0 : bIsMatrix = sal_True;
1161 0 : ::sax::Converter::convertNumber(nMatrixRows, sValue);
1162 : }
1163 : }
1164 0 : else if (nPrefix == XML_NAMESPACE_OFFICE)
1165 : {
1166 0 : if (IsXMLToken(aLocalName, XML_VALUE_TYPE))
1167 : {
1168 0 : if (IsXMLToken(sValue, XML_FLOAT))
1169 0 : bString = false;
1170 0 : else if (IsXMLToken(sValue, XML_DATE))
1171 : {
1172 0 : rType = NUMBERFORMAT_DATE;
1173 0 : bString = false;
1174 : }
1175 0 : else if (IsXMLToken(sValue, XML_TIME))
1176 : {
1177 0 : rType = NUMBERFORMAT_TIME;
1178 0 : bString = false;
1179 : }
1180 : }
1181 0 : else if (IsXMLToken(aLocalName, XML_VALUE))
1182 : {
1183 0 : ::sax::Converter::convertDouble(fValue, sValue);
1184 0 : bEmpty = false;
1185 : }
1186 0 : else if (IsXMLToken(aLocalName, XML_DATE_VALUE))
1187 : {
1188 0 : bEmpty = false;
1189 0 : if (GetScImport().GetMM100UnitConverter().setNullDate(GetScImport().GetModel()))
1190 0 : GetScImport().GetMM100UnitConverter().convertDateTime(rDateTimeValue, sValue);
1191 0 : fValue = rDateTimeValue;
1192 : }
1193 0 : else if (IsXMLToken(aLocalName, XML_TIME_VALUE))
1194 : {
1195 0 : bEmpty = false;
1196 0 : ::sax::Converter::convertDuration(rDateTimeValue, sValue);
1197 0 : fValue = rDateTimeValue;
1198 : }
1199 : }
1200 0 : }
1201 0 : if (bIsCoveredMatrix)
1202 0 : nMatrixFlag = MM_REFERENCE;
1203 0 : else if (bIsMatrix && nMatrixRows && nMatrixCols)
1204 0 : nMatrixFlag = MM_FORMULA;
1205 0 : }
1206 :
1207 0 : ScXMLChangeCellContext::~ScXMLChangeCellContext()
1208 : {
1209 0 : }
1210 :
1211 0 : SvXMLImportContext *ScXMLChangeCellContext::CreateChildContext( sal_uInt16 nPrefix,
1212 : const ::rtl::OUString& rLocalName,
1213 : const ::com::sun::star::uno::Reference<
1214 : ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
1215 : {
1216 0 : SvXMLImportContext *pContext(0);
1217 :
1218 0 : if ((nPrefix == XML_NAMESPACE_TEXT) && (IsXMLToken(rLocalName, XML_P)))
1219 : {
1220 0 : bEmpty = false;
1221 0 : if (bFirstParagraph)
1222 : {
1223 0 : pContext = new ScXMLChangeTextPContext(GetScImport(), nPrefix, rLocalName, xAttrList, this);
1224 0 : bFirstParagraph = false;
1225 : }
1226 : else
1227 : {
1228 0 : if (!pEditTextObj)
1229 0 : CreateTextPContext(sal_True);
1230 0 : pContext = GetScImport().GetTextImport()->CreateTextChildContext(
1231 0 : GetScImport(), nPrefix, rLocalName, xAttrList);
1232 : }
1233 : }
1234 :
1235 0 : if( !pContext )
1236 0 : pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
1237 :
1238 0 : return pContext;
1239 : }
1240 :
1241 0 : void ScXMLChangeCellContext::CreateTextPContext(sal_Bool bIsNewParagraph)
1242 : {
1243 0 : if (GetScImport().GetDocument())
1244 : {
1245 0 : pEditTextObj = new ScEditEngineTextObj();
1246 0 : pEditTextObj->acquire();
1247 0 : pEditTextObj->GetEditEngine()->SetEditTextObjectPool(GetScImport().GetDocument()->GetEditPool());
1248 0 : uno::Reference <text::XText> xText(pEditTextObj);
1249 0 : if (xText.is())
1250 : {
1251 0 : uno::Reference<text::XTextCursor> xTextCursor(xText->createTextCursor());
1252 0 : if (bIsNewParagraph)
1253 : {
1254 0 : xText->setString(sText);
1255 0 : xTextCursor->gotoEnd(false);
1256 0 : uno::Reference < text::XTextRange > xTextRange (xTextCursor, uno::UNO_QUERY);
1257 0 : if (xTextRange.is())
1258 0 : xText->insertControlCharacter(xTextRange, text::ControlCharacter::PARAGRAPH_BREAK, false);
1259 : }
1260 0 : GetScImport().GetTextImport()->SetCursor(xTextCursor);
1261 0 : }
1262 : }
1263 0 : }
1264 :
1265 0 : void ScXMLChangeCellContext::EndElement()
1266 : {
1267 0 : if (!bEmpty)
1268 : {
1269 0 : if (pEditTextObj)
1270 : {
1271 0 : if (GetImport().GetTextImport()->GetCursor().is())
1272 : {
1273 : //GetImport().GetTextImport()->GetCursor()->gotoEnd(sal_False);
1274 0 : if( GetImport().GetTextImport()->GetCursor()->goLeft( 1, sal_True ) )
1275 : {
1276 0 : OUString sEmpty;
1277 0 : GetImport().GetTextImport()->GetText()->insertString(
1278 0 : GetImport().GetTextImport()->GetCursorAsRange(), sEmpty,
1279 0 : sal_True );
1280 : }
1281 : }
1282 0 : if (GetScImport().GetDocument())
1283 0 : rOldCell = new ScEditCell(pEditTextObj->CreateTextObject(), GetScImport().GetDocument(), GetScImport().GetDocument()->GetEditPool());
1284 0 : GetScImport().GetTextImport()->ResetCursor();
1285 0 : pEditTextObj->release();
1286 : }
1287 : else
1288 : {
1289 0 : if (!bFormula)
1290 : {
1291 0 : if (!sText.isEmpty() && bString)
1292 0 : rOldCell = new ScStringCell(sText);
1293 : else
1294 0 : rOldCell = new ScValueCell(fValue);
1295 0 : if (rType == NUMBERFORMAT_DATE || rType == NUMBERFORMAT_TIME)
1296 0 : rInputString = sText;
1297 : }
1298 : }
1299 : }
1300 : else
1301 0 : rOldCell = NULL;
1302 0 : }
1303 :
1304 0 : ScXMLPreviousContext::ScXMLPreviousContext( ScXMLImport& rImport,
1305 : sal_uInt16 nPrfx,
1306 : const ::rtl::OUString& rLName,
1307 : const uno::Reference<xml::sax::XAttributeList>& xAttrList,
1308 : ScXMLChangeTrackingImportHelper* pTempChangeTrackingImportHelper ) :
1309 : SvXMLImportContext( rImport, nPrfx, rLName ),
1310 : pChangeTrackingImportHelper(pTempChangeTrackingImportHelper),
1311 : pOldCell(NULL),
1312 : nID(0),
1313 : nMatrixCols(0),
1314 : nMatrixRows(0),
1315 : eGrammar( formula::FormulaGrammar::GRAM_STORAGE_DEFAULT),
1316 : nType(NUMBERFORMAT_ALL),
1317 0 : nMatrixFlag(MM_NONE)
1318 : {
1319 0 : sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0);
1320 0 : for( sal_Int16 i=0; i < nAttrCount; ++i )
1321 : {
1322 0 : const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i ));
1323 0 : rtl::OUString aLocalName;
1324 0 : sal_uInt16 nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName(
1325 0 : sAttrName, &aLocalName ));
1326 0 : const rtl::OUString& sValue(xAttrList->getValueByIndex( i ));
1327 :
1328 0 : if (nPrefix == XML_NAMESPACE_TABLE)
1329 : {
1330 0 : if (IsXMLToken(aLocalName, XML_ID))
1331 0 : nID = pChangeTrackingImportHelper->GetIDFromString(sValue);
1332 : }
1333 0 : }
1334 0 : }
1335 :
1336 0 : ScXMLPreviousContext::~ScXMLPreviousContext()
1337 : {
1338 0 : }
1339 :
1340 0 : SvXMLImportContext *ScXMLPreviousContext::CreateChildContext( sal_uInt16 nPrefix,
1341 : const ::rtl::OUString& rLocalName,
1342 : const ::com::sun::star::uno::Reference<
1343 : ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
1344 : {
1345 0 : SvXMLImportContext *pContext(0);
1346 :
1347 0 : if ((nPrefix == XML_NAMESPACE_TABLE) && (IsXMLToken(rLocalName, XML_CHANGE_TRACK_TABLE_CELL)))
1348 : pContext = new ScXMLChangeCellContext(GetScImport(), nPrefix, rLocalName, xAttrList,
1349 0 : pOldCell, sFormulaAddress, sFormula, sFormulaNmsp, eGrammar, sInputString, fValue, nType, nMatrixFlag, nMatrixCols, nMatrixRows);
1350 :
1351 0 : if( !pContext )
1352 0 : pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
1353 :
1354 0 : return pContext;
1355 : }
1356 :
1357 0 : void ScXMLPreviousContext::EndElement()
1358 : {
1359 : pChangeTrackingImportHelper->SetPreviousChange(nID, new ScMyCellInfo(pOldCell, sFormulaAddress, sFormula, eGrammar, sInputString,
1360 0 : fValue, nType, nMatrixFlag, nMatrixCols, nMatrixRows));
1361 0 : }
1362 :
1363 0 : ScXMLContentChangeContext::ScXMLContentChangeContext( ScXMLImport& rImport,
1364 : sal_uInt16 nPrfx,
1365 : const ::rtl::OUString& rLName,
1366 : const uno::Reference<xml::sax::XAttributeList>& xAttrList,
1367 : ScXMLChangeTrackingImportHelper* pTempChangeTrackingImportHelper ) :
1368 : SvXMLImportContext( rImport, nPrfx, rLName ),
1369 0 : pChangeTrackingImportHelper(pTempChangeTrackingImportHelper)
1370 : {
1371 0 : sal_uInt32 nActionNumber(0);
1372 0 : sal_uInt32 nRejectingNumber(0);
1373 0 : ScChangeActionState nActionState(SC_CAS_VIRGIN);
1374 :
1375 0 : sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0);
1376 0 : for( sal_Int16 i=0; i < nAttrCount; ++i )
1377 : {
1378 0 : const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i ));
1379 0 : rtl::OUString aLocalName;
1380 0 : sal_uInt16 nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName(
1381 0 : sAttrName, &aLocalName ));
1382 0 : const rtl::OUString& sValue(xAttrList->getValueByIndex( i ));
1383 :
1384 0 : if (nPrefix == XML_NAMESPACE_TABLE)
1385 : {
1386 0 : if (IsXMLToken(aLocalName, XML_ID))
1387 : {
1388 0 : nActionNumber = pChangeTrackingImportHelper->GetIDFromString(sValue);
1389 : }
1390 0 : else if (IsXMLToken(aLocalName, XML_ACCEPTANCE_STATE))
1391 : {
1392 0 : if (IsXMLToken(sValue, XML_ACCEPTED))
1393 0 : nActionState = SC_CAS_ACCEPTED;
1394 0 : else if (IsXMLToken(sValue, XML_REJECTED))
1395 0 : nActionState = SC_CAS_REJECTED;
1396 : }
1397 0 : else if (IsXMLToken(aLocalName, XML_REJECTING_CHANGE_ID))
1398 : {
1399 0 : nRejectingNumber = pChangeTrackingImportHelper->GetIDFromString(sValue);
1400 : }
1401 : }
1402 0 : }
1403 :
1404 0 : pChangeTrackingImportHelper->StartChangeAction(SC_CAT_CONTENT);
1405 0 : pChangeTrackingImportHelper->SetActionNumber(nActionNumber);
1406 0 : pChangeTrackingImportHelper->SetActionState(nActionState);
1407 0 : pChangeTrackingImportHelper->SetRejectingNumber(nRejectingNumber);
1408 0 : }
1409 :
1410 0 : ScXMLContentChangeContext::~ScXMLContentChangeContext()
1411 : {
1412 0 : }
1413 :
1414 0 : SvXMLImportContext *ScXMLContentChangeContext::CreateChildContext( sal_uInt16 nPrefix,
1415 : const ::rtl::OUString& rLocalName,
1416 : const ::com::sun::star::uno::Reference<
1417 : ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
1418 : {
1419 0 : SvXMLImportContext *pContext(0);
1420 :
1421 0 : if ((nPrefix == XML_NAMESPACE_OFFICE) && (IsXMLToken(rLocalName, XML_CHANGE_INFO)))
1422 : {
1423 0 : pContext = new ScXMLChangeInfoContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper);
1424 : }
1425 0 : else if (nPrefix == XML_NAMESPACE_TABLE)
1426 : {
1427 0 : if (IsXMLToken(rLocalName, XML_CELL_ADDRESS))
1428 : {
1429 0 : pContext = new ScXMLBigRangeContext(GetScImport(), nPrefix, rLocalName, xAttrList, aBigRange);
1430 : }
1431 0 : else if (IsXMLToken(rLocalName, XML_DEPENDENCIES))
1432 : {
1433 0 : pContext = new ScXMLDependingsContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper);
1434 : }
1435 0 : else if (IsXMLToken(rLocalName, XML_DELETIONS))
1436 0 : pContext = new ScXMLDeletionsContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper);
1437 0 : else if (IsXMLToken(rLocalName, XML_PREVIOUS))
1438 : {
1439 0 : pContext = new ScXMLPreviousContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper);
1440 : }
1441 : }
1442 :
1443 0 : if( !pContext )
1444 0 : pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
1445 :
1446 0 : return pContext;
1447 : }
1448 :
1449 0 : void ScXMLContentChangeContext::EndElement()
1450 : {
1451 0 : pChangeTrackingImportHelper->SetBigRange(aBigRange);
1452 0 : pChangeTrackingImportHelper->EndChangeAction();
1453 0 : }
1454 :
1455 0 : ScXMLInsertionContext::ScXMLInsertionContext( ScXMLImport& rImport,
1456 : sal_uInt16 nPrfx,
1457 : const ::rtl::OUString& rLName,
1458 : const uno::Reference<xml::sax::XAttributeList>& xAttrList,
1459 : ScXMLChangeTrackingImportHelper* pTempChangeTrackingImportHelper ) :
1460 : SvXMLImportContext( rImport, nPrfx, rLName ),
1461 0 : pChangeTrackingImportHelper(pTempChangeTrackingImportHelper)
1462 : {
1463 0 : sal_uInt32 nActionNumber(0);
1464 0 : sal_uInt32 nRejectingNumber(0);
1465 0 : sal_Int32 nPosition(0);
1466 0 : sal_Int32 nCount(1);
1467 0 : sal_Int32 nTable(0);
1468 0 : ScChangeActionState nActionState(SC_CAS_VIRGIN);
1469 0 : ScChangeActionType nActionType(SC_CAT_INSERT_COLS);
1470 :
1471 0 : sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0);
1472 0 : for( sal_Int16 i=0; i < nAttrCount; ++i )
1473 : {
1474 0 : const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i ));
1475 0 : rtl::OUString aLocalName;
1476 0 : sal_uInt16 nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName(
1477 0 : sAttrName, &aLocalName ));
1478 0 : const rtl::OUString& sValue(xAttrList->getValueByIndex( i ));
1479 :
1480 0 : if (nPrefix == XML_NAMESPACE_TABLE)
1481 : {
1482 0 : if (IsXMLToken(aLocalName, XML_ID))
1483 : {
1484 0 : nActionNumber = pChangeTrackingImportHelper->GetIDFromString(sValue);
1485 : }
1486 0 : else if (IsXMLToken(aLocalName, XML_ACCEPTANCE_STATE))
1487 : {
1488 0 : if (IsXMLToken(sValue, XML_ACCEPTED))
1489 0 : nActionState = SC_CAS_ACCEPTED;
1490 0 : else if (IsXMLToken(sValue, XML_REJECTED))
1491 0 : nActionState = SC_CAS_REJECTED;
1492 : }
1493 0 : else if (IsXMLToken(aLocalName, XML_REJECTING_CHANGE_ID))
1494 : {
1495 0 : nRejectingNumber = pChangeTrackingImportHelper->GetIDFromString(sValue);
1496 : }
1497 0 : else if (IsXMLToken(aLocalName, XML_TYPE))
1498 : {
1499 0 : if (IsXMLToken(sValue, XML_ROW))
1500 0 : nActionType = SC_CAT_INSERT_ROWS;
1501 0 : else if (IsXMLToken(sValue, XML_TABLE))
1502 0 : nActionType = SC_CAT_INSERT_TABS;
1503 : }
1504 0 : else if (IsXMLToken(aLocalName, XML_POSITION))
1505 : {
1506 0 : ::sax::Converter::convertNumber(nPosition, sValue);
1507 : }
1508 0 : else if (IsXMLToken(aLocalName, XML_TABLE))
1509 : {
1510 0 : ::sax::Converter::convertNumber(nTable, sValue);
1511 : }
1512 0 : else if (IsXMLToken(aLocalName, XML_COUNT))
1513 : {
1514 0 : ::sax::Converter::convertNumber(nCount, sValue);
1515 : }
1516 : }
1517 0 : }
1518 :
1519 0 : pChangeTrackingImportHelper->StartChangeAction(nActionType);
1520 0 : pChangeTrackingImportHelper->SetActionNumber(nActionNumber);
1521 0 : pChangeTrackingImportHelper->SetActionState(nActionState);
1522 0 : pChangeTrackingImportHelper->SetRejectingNumber(nRejectingNumber);
1523 0 : pChangeTrackingImportHelper->SetPosition(nPosition, nCount, nTable);
1524 0 : }
1525 :
1526 0 : ScXMLInsertionContext::~ScXMLInsertionContext()
1527 : {
1528 0 : }
1529 :
1530 0 : SvXMLImportContext *ScXMLInsertionContext::CreateChildContext( sal_uInt16 nPrefix,
1531 : const ::rtl::OUString& rLocalName,
1532 : const ::com::sun::star::uno::Reference<
1533 : ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
1534 : {
1535 0 : SvXMLImportContext *pContext(0);
1536 :
1537 0 : if ((nPrefix == XML_NAMESPACE_OFFICE) && (IsXMLToken(rLocalName, XML_CHANGE_INFO)))
1538 : {
1539 0 : pContext = new ScXMLChangeInfoContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper);
1540 : }
1541 0 : else if (nPrefix == XML_NAMESPACE_TABLE)
1542 : {
1543 0 : if (IsXMLToken(rLocalName, XML_DEPENDENCIES))
1544 0 : pContext = new ScXMLDependingsContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper);
1545 0 : else if (IsXMLToken(rLocalName, XML_DELETIONS))
1546 0 : pContext = new ScXMLDeletionsContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper);
1547 : }
1548 :
1549 0 : if( !pContext )
1550 0 : pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
1551 :
1552 0 : return pContext;
1553 : }
1554 :
1555 0 : void ScXMLInsertionContext::EndElement()
1556 : {
1557 0 : pChangeTrackingImportHelper->EndChangeAction();
1558 0 : }
1559 :
1560 0 : ScXMLInsertionCutOffContext::ScXMLInsertionCutOffContext( ScXMLImport& rImport,
1561 : sal_uInt16 nPrfx,
1562 : const ::rtl::OUString& rLName,
1563 : const uno::Reference<xml::sax::XAttributeList>& xAttrList,
1564 : ScXMLChangeTrackingImportHelper* pTempChangeTrackingImportHelper ) :
1565 : SvXMLImportContext( rImport, nPrfx, rLName ),
1566 0 : pChangeTrackingImportHelper(pTempChangeTrackingImportHelper)
1567 : {
1568 0 : sal_uInt32 nID(0);
1569 0 : sal_Int32 nPosition(0);
1570 0 : sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0);
1571 0 : for( sal_Int16 i=0; i < nAttrCount; ++i )
1572 : {
1573 0 : const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i ));
1574 0 : rtl::OUString aLocalName;
1575 0 : sal_uInt16 nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName(
1576 0 : sAttrName, &aLocalName ));
1577 0 : const rtl::OUString& sValue(xAttrList->getValueByIndex( i ));
1578 :
1579 0 : if (nPrefix == XML_NAMESPACE_TABLE)
1580 : {
1581 0 : if (IsXMLToken(aLocalName, XML_ID))
1582 : {
1583 0 : nID = pChangeTrackingImportHelper->GetIDFromString(sValue);
1584 : }
1585 0 : else if (IsXMLToken(aLocalName, XML_POSITION))
1586 : {
1587 0 : ::sax::Converter::convertNumber(nPosition, sValue);
1588 : }
1589 : }
1590 0 : }
1591 0 : pChangeTrackingImportHelper->SetInsertionCutOff(nID, nPosition);
1592 0 : }
1593 :
1594 0 : ScXMLInsertionCutOffContext::~ScXMLInsertionCutOffContext()
1595 : {
1596 0 : }
1597 :
1598 0 : SvXMLImportContext *ScXMLInsertionCutOffContext::CreateChildContext( sal_uInt16 nPrefix,
1599 : const ::rtl::OUString& rLocalName,
1600 : const ::com::sun::star::uno::Reference<
1601 : ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */ )
1602 : {
1603 0 : return new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
1604 : }
1605 :
1606 0 : void ScXMLInsertionCutOffContext::EndElement()
1607 : {
1608 0 : }
1609 :
1610 0 : ScXMLMovementCutOffContext::ScXMLMovementCutOffContext( ScXMLImport& rImport,
1611 : sal_uInt16 nPrfx,
1612 : const ::rtl::OUString& rLName,
1613 : const uno::Reference<xml::sax::XAttributeList>& xAttrList,
1614 : ScXMLChangeTrackingImportHelper* pTempChangeTrackingImportHelper ) :
1615 : SvXMLImportContext( rImport, nPrfx, rLName ),
1616 0 : pChangeTrackingImportHelper(pTempChangeTrackingImportHelper)
1617 : {
1618 0 : sal_uInt32 nID(0);
1619 0 : sal_Int32 nPosition(0);
1620 0 : sal_Int32 nStartPosition(0);
1621 0 : sal_Int32 nEndPosition(0);
1622 0 : sal_Bool bPosition(false);
1623 0 : sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0);
1624 0 : for( sal_Int16 i=0; i < nAttrCount; ++i )
1625 : {
1626 0 : const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i ));
1627 0 : rtl::OUString aLocalName;
1628 0 : sal_uInt16 nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName(
1629 0 : sAttrName, &aLocalName ));
1630 0 : const rtl::OUString& sValue(xAttrList->getValueByIndex( i ));
1631 :
1632 0 : if (nPrefix == XML_NAMESPACE_TABLE)
1633 : {
1634 0 : if (IsXMLToken(aLocalName, XML_ID))
1635 : {
1636 0 : nID = pChangeTrackingImportHelper->GetIDFromString(sValue);
1637 : }
1638 0 : else if (IsXMLToken(aLocalName, XML_POSITION))
1639 : {
1640 0 : bPosition = sal_True;
1641 0 : ::sax::Converter::convertNumber(nPosition, sValue);
1642 : }
1643 0 : else if (IsXMLToken(aLocalName, XML_START_POSITION))
1644 : {
1645 0 : ::sax::Converter::convertNumber(nStartPosition, sValue);
1646 : }
1647 0 : else if (IsXMLToken(aLocalName, XML_END_POSITION))
1648 : {
1649 0 : ::sax::Converter::convertNumber(nEndPosition, sValue);
1650 : }
1651 : }
1652 0 : }
1653 0 : if (bPosition)
1654 0 : nStartPosition = nEndPosition = nPosition;
1655 0 : pChangeTrackingImportHelper->AddMoveCutOff(nID, nStartPosition, nEndPosition);
1656 0 : }
1657 :
1658 0 : ScXMLMovementCutOffContext::~ScXMLMovementCutOffContext()
1659 : {
1660 0 : }
1661 :
1662 0 : SvXMLImportContext *ScXMLMovementCutOffContext::CreateChildContext( sal_uInt16 nPrefix,
1663 : const ::rtl::OUString& rLocalName,
1664 : const ::com::sun::star::uno::Reference<
1665 : ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */ )
1666 : {
1667 0 : return new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
1668 : }
1669 :
1670 0 : void ScXMLMovementCutOffContext::EndElement()
1671 : {
1672 0 : }
1673 :
1674 0 : ScXMLCutOffsContext::ScXMLCutOffsContext( ScXMLImport& rImport,
1675 : sal_uInt16 nPrfx,
1676 : const ::rtl::OUString& rLName,
1677 : const uno::Reference<xml::sax::XAttributeList>& /* xAttrList */,
1678 : ScXMLChangeTrackingImportHelper* pTempChangeTrackingImportHelper ) :
1679 : SvXMLImportContext( rImport, nPrfx, rLName ),
1680 0 : pChangeTrackingImportHelper(pTempChangeTrackingImportHelper)
1681 : {
1682 : // here are no attributes
1683 0 : }
1684 :
1685 0 : ScXMLCutOffsContext::~ScXMLCutOffsContext()
1686 : {
1687 0 : }
1688 :
1689 0 : SvXMLImportContext *ScXMLCutOffsContext::CreateChildContext( sal_uInt16 nPrefix,
1690 : const ::rtl::OUString& rLocalName,
1691 : const ::com::sun::star::uno::Reference<
1692 : ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
1693 : {
1694 0 : SvXMLImportContext *pContext(0);
1695 :
1696 0 : if (nPrefix == XML_NAMESPACE_TABLE)
1697 : {
1698 0 : if (IsXMLToken(rLocalName, XML_INSERTION_CUT_OFF))
1699 0 : pContext = new ScXMLInsertionCutOffContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper);
1700 0 : else if (IsXMLToken(rLocalName, XML_MOVEMENT_CUT_OFF))
1701 0 : pContext = new ScXMLMovementCutOffContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper);
1702 : }
1703 :
1704 0 : if( !pContext )
1705 0 : pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
1706 :
1707 0 : return pContext;
1708 : }
1709 :
1710 0 : void ScXMLCutOffsContext::EndElement()
1711 : {
1712 0 : }
1713 :
1714 0 : ScXMLDeletionContext::ScXMLDeletionContext( ScXMLImport& rImport,
1715 : sal_uInt16 nPrfx,
1716 : const ::rtl::OUString& rLName,
1717 : const uno::Reference<xml::sax::XAttributeList>& xAttrList,
1718 : ScXMLChangeTrackingImportHelper* pTempChangeTrackingImportHelper ) :
1719 : SvXMLImportContext( rImport, nPrfx, rLName ),
1720 0 : pChangeTrackingImportHelper(pTempChangeTrackingImportHelper)
1721 : {
1722 0 : sal_uInt32 nActionNumber(0);
1723 0 : sal_uInt32 nRejectingNumber(0);
1724 0 : sal_Int32 nPosition(0);
1725 0 : sal_Int32 nMultiSpanned(0);
1726 0 : sal_Int32 nTable(0);
1727 0 : ScChangeActionState nActionState(SC_CAS_VIRGIN);
1728 0 : ScChangeActionType nActionType(SC_CAT_DELETE_COLS);
1729 :
1730 0 : sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0);
1731 0 : for( sal_Int16 i=0; i < nAttrCount; i++ )
1732 : {
1733 0 : const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i ));
1734 0 : rtl::OUString aLocalName;
1735 0 : sal_uInt16 nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName(
1736 0 : sAttrName, &aLocalName ));
1737 0 : const rtl::OUString& sValue(xAttrList->getValueByIndex( i ));
1738 :
1739 0 : if (nPrefix == XML_NAMESPACE_TABLE)
1740 : {
1741 0 : if (IsXMLToken(aLocalName, XML_ID))
1742 : {
1743 0 : nActionNumber = pChangeTrackingImportHelper->GetIDFromString(sValue);
1744 : }
1745 0 : else if (IsXMLToken(aLocalName, XML_ACCEPTANCE_STATE))
1746 : {
1747 0 : if (IsXMLToken(sValue, XML_ACCEPTED))
1748 0 : nActionState = SC_CAS_ACCEPTED;
1749 0 : else if (IsXMLToken(sValue, XML_REJECTED))
1750 0 : nActionState = SC_CAS_REJECTED;
1751 : }
1752 0 : else if (IsXMLToken(aLocalName, XML_REJECTING_CHANGE_ID))
1753 : {
1754 0 : nRejectingNumber = pChangeTrackingImportHelper->GetIDFromString(sValue);
1755 : }
1756 0 : else if (IsXMLToken(aLocalName, XML_TYPE))
1757 : {
1758 0 : if (IsXMLToken(sValue, XML_ROW))
1759 : {
1760 0 : nActionType = SC_CAT_DELETE_ROWS;
1761 : }
1762 0 : else if (IsXMLToken(aLocalName, XML_TABLE))
1763 : {
1764 0 : nActionType = SC_CAT_DELETE_TABS;
1765 : }
1766 : }
1767 0 : else if (IsXMLToken(aLocalName, XML_POSITION))
1768 : {
1769 0 : ::sax::Converter::convertNumber(nPosition, sValue);
1770 : }
1771 0 : else if (IsXMLToken(aLocalName, XML_TABLE))
1772 : {
1773 0 : ::sax::Converter::convertNumber(nTable, sValue);
1774 : }
1775 0 : else if (IsXMLToken(aLocalName, XML_MULTI_DELETION_SPANNED))
1776 : {
1777 0 : ::sax::Converter::convertNumber(nMultiSpanned, sValue);
1778 : }
1779 : }
1780 0 : }
1781 :
1782 0 : pChangeTrackingImportHelper->StartChangeAction(nActionType);
1783 0 : pChangeTrackingImportHelper->SetActionNumber(nActionNumber);
1784 0 : pChangeTrackingImportHelper->SetActionState(nActionState);
1785 0 : pChangeTrackingImportHelper->SetRejectingNumber(nRejectingNumber);
1786 0 : pChangeTrackingImportHelper->SetPosition(nPosition, 1, nTable);
1787 0 : pChangeTrackingImportHelper->SetMultiSpanned(static_cast<sal_Int16>(nMultiSpanned));
1788 0 : }
1789 :
1790 0 : ScXMLDeletionContext::~ScXMLDeletionContext()
1791 : {
1792 0 : }
1793 :
1794 0 : SvXMLImportContext *ScXMLDeletionContext::CreateChildContext( sal_uInt16 nPrefix,
1795 : const ::rtl::OUString& rLocalName,
1796 : const ::com::sun::star::uno::Reference<
1797 : ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
1798 : {
1799 0 : SvXMLImportContext *pContext(0);
1800 :
1801 0 : if ((nPrefix == XML_NAMESPACE_OFFICE) && (IsXMLToken(rLocalName, XML_CHANGE_INFO)))
1802 : {
1803 0 : pContext = new ScXMLChangeInfoContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper);
1804 : }
1805 0 : else if (nPrefix == XML_NAMESPACE_TABLE)
1806 : {
1807 0 : if (IsXMLToken(rLocalName, XML_DEPENDENCIES))
1808 0 : pContext = new ScXMLDependingsContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper);
1809 0 : else if (IsXMLToken(rLocalName, XML_DELETIONS))
1810 0 : pContext = new ScXMLDeletionsContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper);
1811 0 : else if (IsXMLToken(rLocalName, XML_CUT_OFFS) || rLocalName.equalsAsciiL("cut_offs", 8))
1812 0 : pContext = new ScXMLCutOffsContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper);
1813 : else
1814 : {
1815 : OSL_FAIL("don't know this");
1816 : }
1817 : }
1818 :
1819 0 : if( !pContext )
1820 0 : pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
1821 :
1822 0 : return pContext;
1823 : }
1824 :
1825 0 : void ScXMLDeletionContext::EndElement()
1826 : {
1827 0 : pChangeTrackingImportHelper->EndChangeAction();
1828 0 : }
1829 :
1830 0 : ScXMLMovementContext::ScXMLMovementContext( ScXMLImport& rImport,
1831 : sal_uInt16 nPrfx,
1832 : const ::rtl::OUString& rLName,
1833 : const uno::Reference<xml::sax::XAttributeList>& xAttrList,
1834 : ScXMLChangeTrackingImportHelper* pTempChangeTrackingImportHelper ) :
1835 : SvXMLImportContext( rImport, nPrfx, rLName ),
1836 0 : pChangeTrackingImportHelper(pTempChangeTrackingImportHelper)
1837 : {
1838 0 : sal_uInt32 nActionNumber(0);
1839 0 : sal_uInt32 nRejectingNumber(0);
1840 0 : ScChangeActionState nActionState(SC_CAS_VIRGIN);
1841 :
1842 0 : sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0);
1843 0 : for( sal_Int16 i=0; i < nAttrCount; ++i )
1844 : {
1845 0 : const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i ));
1846 0 : rtl::OUString aLocalName;
1847 0 : sal_uInt16 nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName(
1848 0 : sAttrName, &aLocalName ));
1849 0 : const rtl::OUString& sValue(xAttrList->getValueByIndex( i ));
1850 :
1851 0 : if (nPrefix == XML_NAMESPACE_TABLE)
1852 : {
1853 0 : if (IsXMLToken(aLocalName, XML_ID))
1854 : {
1855 0 : nActionNumber = pChangeTrackingImportHelper->GetIDFromString(sValue);
1856 : }
1857 0 : else if (IsXMLToken(aLocalName, XML_ACCEPTANCE_STATE))
1858 : {
1859 0 : if (IsXMLToken(sValue, XML_ACCEPTED))
1860 0 : nActionState = SC_CAS_ACCEPTED;
1861 0 : else if (IsXMLToken(sValue, XML_REJECTED))
1862 0 : nActionState = SC_CAS_REJECTED;
1863 : }
1864 0 : else if (IsXMLToken(aLocalName, XML_REJECTING_CHANGE_ID))
1865 : {
1866 0 : nRejectingNumber = pChangeTrackingImportHelper->GetIDFromString(sValue);
1867 : }
1868 : }
1869 0 : }
1870 :
1871 0 : pChangeTrackingImportHelper->StartChangeAction(SC_CAT_MOVE);
1872 0 : pChangeTrackingImportHelper->SetActionNumber(nActionNumber);
1873 0 : pChangeTrackingImportHelper->SetActionState(nActionState);
1874 0 : pChangeTrackingImportHelper->SetRejectingNumber(nRejectingNumber);
1875 0 : }
1876 :
1877 0 : ScXMLMovementContext::~ScXMLMovementContext()
1878 : {
1879 0 : }
1880 :
1881 0 : SvXMLImportContext *ScXMLMovementContext::CreateChildContext( sal_uInt16 nPrefix,
1882 : const ::rtl::OUString& rLocalName,
1883 : const ::com::sun::star::uno::Reference<
1884 : ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
1885 : {
1886 0 : SvXMLImportContext *pContext(0);
1887 :
1888 0 : if ((nPrefix == XML_NAMESPACE_OFFICE) && (IsXMLToken(rLocalName, XML_CHANGE_INFO)))
1889 : {
1890 0 : pContext = new ScXMLChangeInfoContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper);
1891 : }
1892 0 : else if (nPrefix == XML_NAMESPACE_TABLE)
1893 : {
1894 0 : if (IsXMLToken(rLocalName, XML_DEPENDENCIES))
1895 0 : pContext = new ScXMLDependingsContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper);
1896 0 : else if (IsXMLToken(rLocalName, XML_DELETIONS))
1897 0 : pContext = new ScXMLDeletionsContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper);
1898 0 : else if (IsXMLToken(rLocalName, XML_SOURCE_RANGE_ADDRESS))
1899 0 : pContext = new ScXMLBigRangeContext(GetScImport(), nPrefix, rLocalName, xAttrList, aSourceRange);
1900 0 : else if (IsXMLToken(rLocalName, XML_TARGET_RANGE_ADDRESS))
1901 0 : pContext = new ScXMLBigRangeContext(GetScImport(), nPrefix, rLocalName, xAttrList, aTargetRange);
1902 : }
1903 :
1904 0 : if( !pContext )
1905 0 : pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
1906 :
1907 0 : return pContext;
1908 : }
1909 :
1910 0 : void ScXMLMovementContext::EndElement()
1911 : {
1912 0 : pChangeTrackingImportHelper->SetMoveRanges(aSourceRange, aTargetRange);
1913 0 : pChangeTrackingImportHelper->EndChangeAction();
1914 0 : }
1915 :
1916 0 : ScXMLRejectionContext::ScXMLRejectionContext( ScXMLImport& rImport,
1917 : sal_uInt16 nPrfx,
1918 : const ::rtl::OUString& rLName,
1919 : const uno::Reference<xml::sax::XAttributeList>& xAttrList,
1920 : ScXMLChangeTrackingImportHelper* pTempChangeTrackingImportHelper ) :
1921 : SvXMLImportContext( rImport, nPrfx, rLName ),
1922 0 : pChangeTrackingImportHelper(pTempChangeTrackingImportHelper)
1923 : {
1924 0 : sal_uInt32 nActionNumber(0);
1925 0 : sal_uInt32 nRejectingNumber(0);
1926 0 : ScChangeActionState nActionState(SC_CAS_VIRGIN);
1927 :
1928 0 : sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0);
1929 0 : for( sal_Int16 i=0; i < nAttrCount; ++i )
1930 : {
1931 0 : const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i ));
1932 0 : rtl::OUString aLocalName;
1933 0 : sal_uInt16 nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName(
1934 0 : sAttrName, &aLocalName ));
1935 0 : const rtl::OUString& sValue(xAttrList->getValueByIndex( i ));
1936 :
1937 0 : if (nPrefix == XML_NAMESPACE_TABLE)
1938 : {
1939 0 : if (IsXMLToken(aLocalName, XML_ID))
1940 : {
1941 0 : nActionNumber = pChangeTrackingImportHelper->GetIDFromString(sValue);
1942 : }
1943 0 : else if (IsXMLToken(aLocalName, XML_ACCEPTANCE_STATE))
1944 : {
1945 0 : if (IsXMLToken(sValue, XML_ACCEPTED))
1946 0 : nActionState = SC_CAS_ACCEPTED;
1947 0 : else if (IsXMLToken(sValue, XML_REJECTED))
1948 0 : nActionState = SC_CAS_REJECTED;
1949 : }
1950 0 : else if (IsXMLToken(aLocalName, XML_REJECTING_CHANGE_ID))
1951 : {
1952 0 : nRejectingNumber = pChangeTrackingImportHelper->GetIDFromString(sValue);
1953 : }
1954 : }
1955 0 : }
1956 :
1957 0 : pChangeTrackingImportHelper->StartChangeAction(SC_CAT_MOVE);
1958 0 : pChangeTrackingImportHelper->SetActionNumber(nActionNumber);
1959 0 : pChangeTrackingImportHelper->SetActionState(nActionState);
1960 0 : pChangeTrackingImportHelper->SetRejectingNumber(nRejectingNumber);
1961 0 : }
1962 :
1963 0 : ScXMLRejectionContext::~ScXMLRejectionContext()
1964 : {
1965 0 : }
1966 :
1967 0 : SvXMLImportContext *ScXMLRejectionContext::CreateChildContext( sal_uInt16 nPrefix,
1968 : const ::rtl::OUString& rLocalName,
1969 : const ::com::sun::star::uno::Reference<
1970 : ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
1971 : {
1972 0 : SvXMLImportContext *pContext(0);
1973 :
1974 0 : if ((nPrefix == XML_NAMESPACE_OFFICE) && (IsXMLToken(rLocalName, XML_CHANGE_INFO)))
1975 : {
1976 0 : pContext = new ScXMLChangeInfoContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper);
1977 : }
1978 0 : else if (nPrefix == XML_NAMESPACE_TABLE)
1979 : {
1980 0 : if (IsXMLToken(rLocalName, XML_DEPENDENCIES))
1981 0 : pContext = new ScXMLDependingsContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper);
1982 0 : else if (IsXMLToken(rLocalName, XML_DELETIONS))
1983 0 : pContext = new ScXMLDeletionsContext(GetScImport(), nPrefix, rLocalName, xAttrList, pChangeTrackingImportHelper);
1984 : }
1985 :
1986 0 : if( !pContext )
1987 0 : pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
1988 :
1989 0 : return pContext;
1990 : }
1991 :
1992 0 : void ScXMLRejectionContext::EndElement()
1993 : {
1994 0 : pChangeTrackingImportHelper->EndChangeAction();
1995 0 : }
1996 :
1997 :
1998 :
1999 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|